alwaysai
Version:
The alwaysAI command-line interface (CLI)
65 lines • 2.61 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.appShellCliLeaf = void 0;
const alwayscli_1 = require("@alwaysai/alwayscli");
const app_1 = require("../../core/app");
const paths_1 = require("../../paths");
const constants_1 = require("../../constants");
exports.appShellCliLeaf = (0, alwayscli_1.CliLeaf)({
name: 'shell',
description: 'Launch a bash shell in the target directory',
namedInputs: {
'no-container': (0, alwayscli_1.CliFlagInput)({
description: 'Open the shell on the target host, not in a container on the target host'
}),
superuser: (0, alwayscli_1.CliFlagInput)({
description: 'Open the shell as superuser "root"'
})
},
async action(_, opts) {
const targetJsonFile = (0, app_1.TargetJsonFile)();
const targetJson = targetJsonFile.read();
const tty = process.stdin.isTTY;
switch (targetJson.targetProtocol) {
case 'docker:': {
targetJsonFile.readContainerSpawner().runForegroundSync({
exe: '/bin/bash',
args: ['--rcfile', paths_1.VENV_BIN_ACTIVATE],
tty,
cwd: '.',
expose5000: true,
superuser: opts.superuser
});
break;
}
case 'ssh+docker:': {
if (opts['no-container']) {
if (opts.superuser) {
throw new alwayscli_1.CliTerseError('--superuser is not yet supported with --no-container');
}
targetJsonFile.readHostSpawner().runForegroundSync({
exe: '/bin/bash',
tty,
cwd: '.',
expose5000: true
});
}
else {
targetJsonFile.readContainerSpawner().runForegroundSync({
exe: '/bin/bash',
args: ['--rcfile', paths_1.VENV_BIN_ACTIVATE],
tty,
cwd: '.',
expose5000: true,
superuser: opts.superuser
});
}
break;
}
default: {
throw new alwayscli_1.CliTerseError(`${constants_1.ALWAYSAI_CLI_EXECUTABLE_NAME} app shell only supports the following protocols: "docker:", "ssh+docker:"`);
}
}
}
});
//# sourceMappingURL=shell.js.map