UNPKG

alwaysai

Version:

The alwaysAI command-line interface (CLI)

43 lines 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SshSpawner = void 0; const spawner_base_1 = require("./spawner-base"); const gnu_spawner_1 = require("./gnu-spawner"); const resolve_posix_path_1 = require("../resolve-posix-path"); const paths_1 = require("../../paths"); function SshSpawner(opts) { const resolvePath = (0, resolve_posix_path_1.ResolvePosixPath)(opts.targetPath); return (0, gnu_spawner_1.GnuSpawner)(Object.assign({ resolvePath }, (0, spawner_base_1.SpawnerBase)(translate))); function translate(cmd) { if (cmd.superuser) { throw new Error(`${SshSpawner.name} does not support cmd option "superuser"`); } const exe = 'ssh'; const args = [ '-i', paths_1.PRIVATE_KEY_FILE_PATH, '-o', 'BatchMode=yes', '-o', 'StrictHostKeyChecking=no' ]; if (cmd.tty) { args.push('-t'); } if (cmd.expose5000) { args.push('-L', '5000:0.0.0.0:5000'); } args.push(opts.targetHostname, cmd.cwd ? `cd "${resolvePath(cmd.cwd)}" && ${cmd.exe}` : cmd.exe); if (cmd.args) { args.push(...cmd.args); } const translated = { exe, args, input: cmd.input }; return translated; } } exports.SshSpawner = SshSpawner; //# sourceMappingURL=ssh-spawner.js.map