{"version":3,"file":"remote-cli.d.ts","sourceRoot":"","sources":["../../../src/core/remote-execution/remote-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAuBH,wBAAgB,gBAAgB,IAAI,MAAM,CAOzC;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAoF1E","sourcesContent":["/**\n * Remote Execution — CLI (2.14.0).\n *\n * `jensen remote register|probe|status|list`\n *\n * Operator surface for the remote target catalog + reachability. It never\n * exposes an unrestricted remote shell; authoritative execution stays on the\n * Mission → Assignment → Worker path.\n */\n\nimport chalk from \"chalk\";\nimport { createFileRemoteTargetRegistry } from \"./file-remote-target-registry.js\";\nimport { RemoteTargetRegistry } from \"./remote-target-registry.js\";\nimport type { RemoteExecutionTarget } from \"./remote-target-types.js\";\nimport { SshRemoteExecutionTransport } from \"./ssh-transport.js\";\n\nfunction flagValue(args: string[], name: string): string | undefined {\n\tconst idx = args.indexOf(name);\n\tif (idx === -1) return undefined;\n\treturn args[idx + 1];\n}\n\nfunction printJson(payload: unknown): void {\n\tprocess.stdout.write(`${JSON.stringify(payload, null, 2)}\\n`);\n}\n\nfunction renderError(error: unknown): void {\n\tconst message = error instanceof Error ? error.message : String(error);\n\tprocess.stderr.write(`${chalk.red(message)}\\n`);\n}\n\nexport function printRemoteUsage(): string {\n\treturn [\n\t\t\"  remote register --target-id <ID> --host <HOST> --user <USER> --platform windows|linux|macos --arch x64|arm64 [--temp-root <DIR>]\",\n\t\t\"  remote probe <TARGET_ID> [--json]\",\n\t\t\"  remote status <TARGET_ID> [--json]\",\n\t\t\"  remote list [--json]\",\n\t].join(\"\\n\");\n}\n\nexport async function handleRemoteCommand(args: string[]): Promise<boolean> {\n\tif (args[0] !== \"remote\") return false;\n\tconst sub = args[1];\n\tconst json = args.includes(\"--json\");\n\tconst registry = new RemoteTargetRegistry({\n\t\tstore: createFileRemoteTargetRegistry(),\n\t\ttransport: new SshRemoteExecutionTransport(),\n\t});\n\n\ttry {\n\t\tswitch (sub) {\n\t\t\tcase \"register\": {\n\t\t\t\tconst targetId = flagValue(args, \"--target-id\");\n\t\t\t\tconst host = flagValue(args, \"--host\");\n\t\t\t\tconst user = flagValue(args, \"--user\");\n\t\t\t\tconst platform = flagValue(args, \"--platform\");\n\t\t\t\tconst arch = flagValue(args, \"--arch\");\n\t\t\t\tconst tempRoot = flagValue(args, \"--temp-root\");\n\t\t\t\tif (!targetId || !host || !user || !platform || !arch) {\n\t\t\t\t\tprocess.stderr.write(\"remote register requires --target-id, --host, --user, --platform, --arch\\n\");\n\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tconst target: RemoteExecutionTarget = {\n\t\t\t\t\ttargetId,\n\t\t\t\t\ttransport: \"ssh\",\n\t\t\t\t\thost,\n\t\t\t\t\tuser,\n\t\t\t\t\tplatform: platform as RemoteExecutionTarget[\"platform\"],\n\t\t\t\t\tarch: arch as RemoteExecutionTarget[\"arch\"],\n\t\t\t\t\tconnection: { remoteTempRoot: tempRoot },\n\t\t\t\t};\n\t\t\t\tconst registered = await registry.register(target);\n\t\t\t\tif (json) printJson({ status: \"registered\", target: registered });\n\t\t\t\telse process.stdout.write(`registered remote target ${registered.targetId}\\n`);\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tcase \"probe\":\n\t\t\tcase \"status\": {\n\t\t\t\tconst targetId = args[2];\n\t\t\t\tif (!targetId) {\n\t\t\t\t\tprocess.stderr.write(`remote ${sub} requires <TARGET_ID>\\n`);\n\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tconst health = await registry.probe(targetId);\n\t\t\t\tif (json) printJson(health);\n\t\t\t\telse {\n\t\t\t\t\tprocess.stdout.write(\n\t\t\t\t\t\t`${health.targetId}  [${health.status}]${health.remoteHost ? ` host=${health.remoteHost}` : \"\"}${health.remoteUser ? ` user=${health.remoteUser}` : \"\"}\\n`,\n\t\t\t\t\t);\n\t\t\t\t\tif (health.summary) process.stdout.write(`  ${health.summary}\\n`);\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tcase \"list\": {\n\t\t\t\tconst result = await registry.list();\n\t\t\t\tif (json) printJson(result);\n\t\t\t\telse {\n\t\t\t\t\tif (result.entries.length === 0 && result.corrupt.length === 0) {\n\t\t\t\t\t\tprocess.stdout.write(\"(no remote targets)\\n\");\n\t\t\t\t\t}\n\t\t\t\t\tfor (const target of result.entries) {\n\t\t\t\t\t\tprocess.stdout.write(\n\t\t\t\t\t\t\t`${target.targetId}  ${target.user}@${target.host}  ${target.platform}/${target.arch}\\n`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tfor (const corrupt of result.corrupt) {\n\t\t\t\t\t\tprocess.stdout.write(chalk.yellow(`${corrupt.targetId}  [CORRUPT] ${corrupt.diagnostic}\\n`));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t} catch (error) {\n\t\trenderError(error);\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n}\n"]}