@a5c-ai/adapters-cli 5.1.1-staging.52898ebfc24f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/bootstrap.d.ts +13 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap.js +59 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/commands/adapters.d.ts +4 -0
- package/dist/commands/adapters.d.ts.map +1 -0
- package/dist/commands/adapters.js +5 -0
- package/dist/commands/adapters.js.map +1 -0
- package/dist/commands/agent.d.ts +11 -0
- package/dist/commands/agent.d.ts.map +1 -0
- package/dist/commands/agent.js +219 -0
- package/dist/commands/agent.js.map +1 -0
- package/dist/commands/auth.d.ts +4 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +5 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/config.d.ts +4 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +5 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/detect-host.d.ts +4 -0
- package/dist/commands/detect-host.d.ts.map +1 -0
- package/dist/commands/detect-host.js +5 -0
- package/dist/commands/detect-host.js.map +1 -0
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +120 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/gateway/index.d.ts +5 -0
- package/dist/commands/gateway/index.d.ts.map +1 -0
- package/dist/commands/gateway/index.js +39 -0
- package/dist/commands/gateway/index.js.map +1 -0
- package/dist/commands/gateway/serve.d.ts +5 -0
- package/dist/commands/gateway/serve.d.ts.map +1 -0
- package/dist/commands/gateway/serve.js +76 -0
- package/dist/commands/gateway/serve.js.map +1 -0
- package/dist/commands/gateway/status.d.ts +2 -0
- package/dist/commands/gateway/status.d.ts.map +1 -0
- package/dist/commands/gateway/status.js +24 -0
- package/dist/commands/gateway/status.js.map +1 -0
- package/dist/commands/gateway/tokens.d.ts +2 -0
- package/dist/commands/gateway/tokens.d.ts.map +1 -0
- package/dist/commands/gateway/tokens.js +85 -0
- package/dist/commands/gateway/tokens.js.map +1 -0
- package/dist/commands/help.d.ts +13 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +501 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/hooks.d.ts +16 -0
- package/dist/commands/hooks.d.ts.map +1 -0
- package/dist/commands/hooks.js +207 -0
- package/dist/commands/hooks.js.map +1 -0
- package/dist/commands/install-helpers.d.ts +5 -0
- package/dist/commands/install-helpers.d.ts.map +1 -0
- package/dist/commands/install-helpers.js +5 -0
- package/dist/commands/install-helpers.js.map +1 -0
- package/dist/commands/install.d.ts +4 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +5 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/launch-bridge-hooks.d.ts +8 -0
- package/dist/commands/launch-bridge-hooks.d.ts.map +1 -0
- package/dist/commands/launch-bridge-hooks.js +8 -0
- package/dist/commands/launch-bridge-hooks.js.map +1 -0
- package/dist/commands/launch-completion-engine.d.ts +7 -0
- package/dist/commands/launch-completion-engine.d.ts.map +1 -0
- package/dist/commands/launch-completion-engine.js +8 -0
- package/dist/commands/launch-completion-engine.js.map +1 -0
- package/dist/commands/launch.d.ts +8 -0
- package/dist/commands/launch.d.ts.map +1 -0
- package/dist/commands/launch.js +8 -0
- package/dist/commands/launch.js.map +1 -0
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +93 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/models.d.ts +8 -0
- package/dist/commands/models.d.ts.map +1 -0
- package/dist/commands/models.js +306 -0
- package/dist/commands/models.js.map +1 -0
- package/dist/commands/plugin.d.ts +3 -0
- package/dist/commands/plugin.d.ts.map +1 -0
- package/dist/commands/plugin.js +96 -0
- package/dist/commands/plugin.js.map +1 -0
- package/dist/commands/profiles.d.ts +8 -0
- package/dist/commands/profiles.d.ts.map +1 -0
- package/dist/commands/profiles.js +206 -0
- package/dist/commands/profiles.js.map +1 -0
- package/dist/commands/remote.d.ts +30 -0
- package/dist/commands/remote.d.ts.map +1 -0
- package/dist/commands/remote.js +204 -0
- package/dist/commands/remote.js.map +1 -0
- package/dist/commands/run.d.ts +27 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +355 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/sessions.d.ts +8 -0
- package/dist/commands/sessions.d.ts.map +1 -0
- package/dist/commands/sessions.js +225 -0
- package/dist/commands/sessions.js.map +1 -0
- package/dist/commands/skill.d.ts +10 -0
- package/dist/commands/skill.d.ts.map +1 -0
- package/dist/commands/skill.js +217 -0
- package/dist/commands/skill.js.map +1 -0
- package/dist/commands/tui.d.ts +3 -0
- package/dist/commands/tui.d.ts.map +1 -0
- package/dist/commands/tui.js +57 -0
- package/dist/commands/tui.js.map +1 -0
- package/dist/commands/workspaces.d.ts +4 -0
- package/dist/commands/workspaces.d.ts.map +1 -0
- package/dist/commands/workspaces.js +187 -0
- package/dist/commands/workspaces.js.map +1 -0
- package/dist/exit-codes.d.ts +32 -0
- package/dist/exit-codes.d.ts.map +1 -0
- package/dist/exit-codes.js +68 -0
- package/dist/exit-codes.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +216 -0
- package/dist/index.js.map +1 -0
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.d.ts.map +1 -0
- package/dist/index.test.js +23 -0
- package/dist/index.test.js.map +1 -0
- package/dist/lib/agent-capabilities.d.ts +6 -0
- package/dist/lib/agent-capabilities.d.ts.map +1 -0
- package/dist/lib/agent-capabilities.js +63 -0
- package/dist/lib/agent-capabilities.js.map +1 -0
- package/dist/lib/agent-skill-paths.d.ts +9 -0
- package/dist/lib/agent-skill-paths.d.ts.map +1 -0
- package/dist/lib/agent-skill-paths.js +70 -0
- package/dist/lib/agent-skill-paths.js.map +1 -0
- package/dist/lib/agent-subagent-paths.d.ts +8 -0
- package/dist/lib/agent-subagent-paths.d.ts.map +1 -0
- package/dist/lib/agent-subagent-paths.js +64 -0
- package/dist/lib/agent-subagent-paths.js.map +1 -0
- package/dist/loggingConfig.d.ts +11 -0
- package/dist/loggingConfig.d.ts.map +1 -0
- package/dist/loggingConfig.js +17 -0
- package/dist/loggingConfig.js.map +1 -0
- package/dist/output.d.ts +55 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +129 -0
- package/dist/output.js.map +1 -0
- package/dist/parse-args.d.ts +57 -0
- package/dist/parse-args.d.ts.map +1 -0
- package/dist/parse-args.js +261 -0
- package/dist/parse-args.js.map +1 -0
- package/dist/read-stdin.d.ts +1 -0
- package/dist/read-stdin.d.ts.map +1 -0
- package/dist/read-stdin.js +14 -0
- package/dist/read-stdin.js.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `adapters remote install <host>` / `adapters remote update <host>`.
|
|
3
|
+
*
|
|
4
|
+
* Self-install pipeline — uses `buildInvocationCommand()` to build each step
|
|
5
|
+
* so the transport (ssh/docker/k8s) is selectable via `--mode` and works
|
|
6
|
+
* uniformly across environments.
|
|
7
|
+
*
|
|
8
|
+
* Steps:
|
|
9
|
+
* 1. Probe: `adapters --version` — check if adapters is on the remote.
|
|
10
|
+
* 2. Install: `npm install -g @a5c-ai/adapters-cli` if missing (or --force).
|
|
11
|
+
* 3. Harness: `adapters install <harness>` — deploy the desired harness.
|
|
12
|
+
* 4. Verify: `adapters detect --all --json` — confirm the harness is active.
|
|
13
|
+
*/
|
|
14
|
+
import type { AgentMuxClient } from '@a5c-ai/comm-adapter';
|
|
15
|
+
import type { ParsedArgs, FlagDef } from '../parse-args.js';
|
|
16
|
+
export declare const REMOTE_FLAGS: Record<string, FlagDef>;
|
|
17
|
+
/** Minimal spawner used by the remote command. Injectable for tests. */
|
|
18
|
+
export type RemoteSpawner = (command: string, args: string[]) => Promise<{
|
|
19
|
+
code: number;
|
|
20
|
+
stdout: string;
|
|
21
|
+
stderr: string;
|
|
22
|
+
}>;
|
|
23
|
+
export interface RemoteCommandDeps {
|
|
24
|
+
spawner?: RemoteSpawner;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* `adapters remote install <host> [--mode ssh|docker|k8s|local] [--harness <agent>]`
|
|
28
|
+
* `adapters remote update <host> ...`
|
|
29
|
+
*/
|
|
30
|
+
export declare function remoteCommand(_client: AgentMuxClient, args: ParsedArgs, deps?: RemoteCommandDeps): Promise<number>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/commands/remote.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAK5D,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAUhD,CAAC;AAEF,wEAAwE;AACxE,MAAM,MAAM,aAAa,GAAG,CAC1B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,KACX,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAmB/D,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB;AAmDD;;;GAGG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,UAAU,EAChB,IAAI,GAAE,iBAAsB,GAC3B,OAAO,CAAC,MAAM,CAAC,CA6GjB"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `adapters remote install <host>` / `adapters remote update <host>`.
|
|
3
|
+
*
|
|
4
|
+
* Self-install pipeline — uses `buildInvocationCommand()` to build each step
|
|
5
|
+
* so the transport (ssh/docker/k8s) is selectable via `--mode` and works
|
|
6
|
+
* uniformly across environments.
|
|
7
|
+
*
|
|
8
|
+
* Steps:
|
|
9
|
+
* 1. Probe: `adapters --version` — check if adapters is on the remote.
|
|
10
|
+
* 2. Install: `npm install -g @a5c-ai/adapters-cli` if missing (or --force).
|
|
11
|
+
* 3. Harness: `adapters install <harness>` — deploy the desired harness.
|
|
12
|
+
* 4. Verify: `adapters detect --all --json` — confirm the harness is active.
|
|
13
|
+
*/
|
|
14
|
+
import { spawn } from 'node:child_process';
|
|
15
|
+
import { buildInvocationCommand } from '@a5c-ai/comm-adapter';
|
|
16
|
+
import { flagBool, flagStr } from '../parse-args.js';
|
|
17
|
+
import { ExitCode } from '../exit-codes.js';
|
|
18
|
+
import { printJsonOk, printJsonError, printError } from '../output.js';
|
|
19
|
+
export const REMOTE_FLAGS = {
|
|
20
|
+
'mode': { type: 'string' }, // ssh | docker | k8s | local
|
|
21
|
+
'harness': { type: 'string' }, // agent to install (default: claude)
|
|
22
|
+
'image': { type: 'string' }, // docker image
|
|
23
|
+
'identity-file': { type: 'string' }, // ssh key
|
|
24
|
+
'port': { type: 'number' }, // ssh port
|
|
25
|
+
'namespace': { type: 'string' }, // k8s namespace
|
|
26
|
+
'context': { type: 'string' }, // k8s context
|
|
27
|
+
'force': { type: 'boolean' },
|
|
28
|
+
'dry-run': { type: 'boolean' },
|
|
29
|
+
};
|
|
30
|
+
const defaultSpawner = (command, args) => new Promise((resolve, reject) => {
|
|
31
|
+
const child = spawn(command, args, {
|
|
32
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
33
|
+
shell: false,
|
|
34
|
+
windowsHide: true,
|
|
35
|
+
});
|
|
36
|
+
let stdout = '';
|
|
37
|
+
let stderr = '';
|
|
38
|
+
child.stdout?.setEncoding('utf8');
|
|
39
|
+
child.stderr?.setEncoding('utf8');
|
|
40
|
+
child.stdout?.on('data', (c) => { stdout += c; });
|
|
41
|
+
child.stderr?.on('data', (c) => { stderr += c; });
|
|
42
|
+
child.on('error', (err) => reject(err));
|
|
43
|
+
child.on('exit', (code) => resolve({ code: code ?? 1, stdout, stderr }));
|
|
44
|
+
});
|
|
45
|
+
/** Build a SpawnArgs shell for a given adapters (or npm) command. */
|
|
46
|
+
function makeSpawnArgs(command, args, cwd) {
|
|
47
|
+
return { command, args, env: {}, cwd, usePty: false };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Resolve the InvocationMode for a given CLI invocation of `adapters remote`.
|
|
51
|
+
* The first positional after the subcommand is typically the host (for ssh)
|
|
52
|
+
* or is ignored for docker/k8s/local (which read image/namespace from flags).
|
|
53
|
+
*/
|
|
54
|
+
function buildMode(modeFlag, host, args) {
|
|
55
|
+
switch (modeFlag) {
|
|
56
|
+
case 'local':
|
|
57
|
+
return { mode: 'local' };
|
|
58
|
+
case 'docker': {
|
|
59
|
+
const image = flagStr(args.flags, 'image');
|
|
60
|
+
if (!image)
|
|
61
|
+
throw new Error('--mode=docker requires --image=<image>');
|
|
62
|
+
return { mode: 'docker', image };
|
|
63
|
+
}
|
|
64
|
+
case 'k8s': {
|
|
65
|
+
const ns = flagStr(args.flags, 'namespace');
|
|
66
|
+
const ctx = flagStr(args.flags, 'context');
|
|
67
|
+
const m = {
|
|
68
|
+
mode: 'k8s',
|
|
69
|
+
...(ns !== undefined ? { namespace: ns } : {}),
|
|
70
|
+
...(ctx !== undefined ? { context: ctx } : {}),
|
|
71
|
+
};
|
|
72
|
+
return m;
|
|
73
|
+
}
|
|
74
|
+
case 'ssh':
|
|
75
|
+
default: {
|
|
76
|
+
if (!host)
|
|
77
|
+
throw new Error('ssh mode requires a <host> positional argument');
|
|
78
|
+
const port = flagStr(args.flags, 'port');
|
|
79
|
+
const id = flagStr(args.flags, 'identity-file');
|
|
80
|
+
const m = {
|
|
81
|
+
mode: 'ssh',
|
|
82
|
+
host,
|
|
83
|
+
...(port !== undefined ? { port: Number(port) } : {}),
|
|
84
|
+
...(id !== undefined ? { identityFile: id } : {}),
|
|
85
|
+
};
|
|
86
|
+
return m;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* `adapters remote install <host> [--mode ssh|docker|k8s|local] [--harness <agent>]`
|
|
92
|
+
* `adapters remote update <host> ...`
|
|
93
|
+
*/
|
|
94
|
+
export async function remoteCommand(_client, args, deps = {}) {
|
|
95
|
+
const jsonMode = flagBool(args.flags, 'json') === true;
|
|
96
|
+
const spawner = deps.spawner ?? defaultSpawner;
|
|
97
|
+
const sub = args.subcommand ?? args.positionals[0];
|
|
98
|
+
if (sub !== 'install' && sub !== 'update') {
|
|
99
|
+
const msg = 'Usage: adapters remote install <host> [--mode ssh|docker|k8s] [--harness <agent>]';
|
|
100
|
+
if (jsonMode)
|
|
101
|
+
printJsonError('VALIDATION_ERROR', msg);
|
|
102
|
+
else
|
|
103
|
+
printError(msg);
|
|
104
|
+
return ExitCode.USAGE_ERROR;
|
|
105
|
+
}
|
|
106
|
+
// Positional order: `remote install <host>` — when parser assigned `sub` as
|
|
107
|
+
// subcommand the host is positionals[0]; when it put `install` in positionals[0]
|
|
108
|
+
// the host is positionals[1].
|
|
109
|
+
const host = args.subcommand === sub ? args.positionals[0] : args.positionals[1];
|
|
110
|
+
const modeFlag = flagStr(args.flags, 'mode') ?? 'ssh';
|
|
111
|
+
const harness = flagStr(args.flags, 'harness') ?? 'claude';
|
|
112
|
+
const force = flagBool(args.flags, 'force') === true;
|
|
113
|
+
const dryRun = flagBool(args.flags, 'dry-run') === true;
|
|
114
|
+
let invocation;
|
|
115
|
+
try {
|
|
116
|
+
invocation = buildMode(modeFlag, host, args);
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
120
|
+
if (jsonMode)
|
|
121
|
+
printJsonError('VALIDATION_ERROR', msg);
|
|
122
|
+
else
|
|
123
|
+
printError(msg);
|
|
124
|
+
return ExitCode.USAGE_ERROR;
|
|
125
|
+
}
|
|
126
|
+
const cwd = process.cwd();
|
|
127
|
+
const steps = [];
|
|
128
|
+
const runStep = async (step, cmd, cmdArgs) => {
|
|
129
|
+
const spawnArgs = makeSpawnArgs(cmd, cmdArgs, cwd);
|
|
130
|
+
const inv = buildInvocationCommand(invocation, spawnArgs, 'adapters-remote');
|
|
131
|
+
const entry = { step, command: inv.command, args: inv.args };
|
|
132
|
+
steps.push(entry);
|
|
133
|
+
if (dryRun) {
|
|
134
|
+
entry.result = { code: 0, stdout: '', stderr: '' };
|
|
135
|
+
if (!jsonMode)
|
|
136
|
+
process.stdout.write(`[dry-run] ${inv.command} ${inv.args.join(' ')}\n`);
|
|
137
|
+
return entry.result;
|
|
138
|
+
}
|
|
139
|
+
if (!jsonMode)
|
|
140
|
+
process.stdout.write(`=> ${step}: ${inv.command} ${inv.args.slice(0, 6).join(' ')}${inv.args.length > 6 ? ' ...' : ''}\n`);
|
|
141
|
+
const r = await spawner(inv.command, inv.args);
|
|
142
|
+
entry.result = r;
|
|
143
|
+
return r;
|
|
144
|
+
};
|
|
145
|
+
// Step 1: probe adapters
|
|
146
|
+
const probe = await runStep('probe', 'adapters', ['--version']);
|
|
147
|
+
const needsInstall = sub === 'update' || probe.code !== 0 || force;
|
|
148
|
+
// Step 2: install adapters itself if missing (or forced / update)
|
|
149
|
+
if (needsInstall) {
|
|
150
|
+
const npmVerb = sub === 'update' ? 'update' : 'install';
|
|
151
|
+
const npm = await runStep('adapters-self', 'npm', [npmVerb, '-g', '@a5c-ai/adapters-cli']);
|
|
152
|
+
if (!dryRun && npm.code !== 0) {
|
|
153
|
+
const msg = `npm ${npmVerb} failed on remote (code ${npm.code})`;
|
|
154
|
+
if (jsonMode)
|
|
155
|
+
printJsonError('INTERNAL', msg);
|
|
156
|
+
else
|
|
157
|
+
printError(msg);
|
|
158
|
+
if (!jsonMode && npm.stderr)
|
|
159
|
+
process.stderr.write(npm.stderr);
|
|
160
|
+
return ExitCode.GENERAL_ERROR;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// Step 3: install harness
|
|
164
|
+
const harnessVerb = sub === 'update' ? 'update' : 'install';
|
|
165
|
+
const installArgs = [harnessVerb, harness];
|
|
166
|
+
if (force && sub === 'install')
|
|
167
|
+
installArgs.push('--force');
|
|
168
|
+
const hres = await runStep('harness', 'adapters', installArgs);
|
|
169
|
+
if (!dryRun && hres.code !== 0) {
|
|
170
|
+
const msg = `adapters ${harnessVerb} ${harness} failed on remote (code ${hres.code})`;
|
|
171
|
+
if (jsonMode)
|
|
172
|
+
printJsonError('INTERNAL', msg);
|
|
173
|
+
else
|
|
174
|
+
printError(msg);
|
|
175
|
+
if (!jsonMode && hres.stderr)
|
|
176
|
+
process.stderr.write(hres.stderr);
|
|
177
|
+
return ExitCode.GENERAL_ERROR;
|
|
178
|
+
}
|
|
179
|
+
// Step 4: verify
|
|
180
|
+
const verify = await runStep('verify', 'adapters', ['detect', '--all', '--json']);
|
|
181
|
+
if (jsonMode) {
|
|
182
|
+
printJsonOk({
|
|
183
|
+
host: host ?? null,
|
|
184
|
+
mode: modeFlag,
|
|
185
|
+
harness,
|
|
186
|
+
subcommand: sub,
|
|
187
|
+
dryRun: dryRun || undefined,
|
|
188
|
+
steps: steps.map((s) => ({
|
|
189
|
+
step: s.step,
|
|
190
|
+
command: s.command,
|
|
191
|
+
args: s.args,
|
|
192
|
+
code: s.result?.code ?? null,
|
|
193
|
+
stdout: s.result?.stdout ?? '',
|
|
194
|
+
stderr: s.result?.stderr ?? '',
|
|
195
|
+
})),
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
process.stdout.write(`\n${sub === 'update' ? 'Updated' : 'Installed'} ${harness} on ${host ?? modeFlag} (mode=${modeFlag}).\n` +
|
|
200
|
+
(verify.stdout ? `\nVerify output:\n${verify.stdout}\n` : ''));
|
|
201
|
+
}
|
|
202
|
+
return ExitCode.SUCCESS;
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=remote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../../src/commands/remote.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAO3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEvE,MAAM,CAAC,MAAM,YAAY,GAA4B;IACnD,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAW,6BAA6B;IAClE,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAQ,qCAAqC;IAC1E,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAU,eAAe;IACpD,eAAe,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,UAAU;IAC/C,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAW,WAAW;IAChD,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAM,gBAAgB;IACrD,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAQ,cAAc;IACnD,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IAC5B,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;CAC/B,CAAC;AAQF,MAAM,cAAc,GAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CACtD,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+1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `adapters run` command implementation.
|
|
3
|
+
*
|
|
4
|
+
* @see docs/10-cli-reference.md Section 6
|
|
5
|
+
*/
|
|
6
|
+
import type { AgentMuxClient } from '@a5c-ai/comm-adapter';
|
|
7
|
+
import type { ParsedArgs } from '../parse-args.js';
|
|
8
|
+
import type { FlagDef } from '../parse-args.js';
|
|
9
|
+
/** Run-specific flag definitions. */
|
|
10
|
+
export declare const RUN_FLAGS: Record<string, FlagDef>;
|
|
11
|
+
/**
|
|
12
|
+
* Validate mutual exclusion rules.
|
|
13
|
+
* Returns an error message or null if valid.
|
|
14
|
+
*/
|
|
15
|
+
export declare function validateRunFlags(flags: Record<string, string | boolean | string[]>): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Build RunOptions from parsed args.
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildRunOptions(args: ParsedArgs, registeredAgents: Set<string>): {
|
|
20
|
+
agent?: string;
|
|
21
|
+
prompt?: string;
|
|
22
|
+
options: Record<string, unknown>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Execute the run command.
|
|
26
|
+
*/
|
|
27
|
+
export declare function runCommand(client: AgentMuxClient, args: ParsedArgs): Promise<number>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAQhD,qCAAqC;AACrC,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAsC7C,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,CAAC,GAAG,MAAM,GAAG,IAAI,CAgBlG;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,UAAU,EAChB,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,GAC5B;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CA+FvE;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAyH1F"}
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `adapters run` command implementation.
|
|
3
|
+
*
|
|
4
|
+
* @see docs/10-cli-reference.md Section 6
|
|
5
|
+
*/
|
|
6
|
+
import * as path from 'node:path';
|
|
7
|
+
import { AgentMuxError } from '@a5c-ai/comm-adapter';
|
|
8
|
+
import { flagStr, flagNum, flagBool, flagArr } from '../parse-args.js';
|
|
9
|
+
import { ExitCode, errorCodeToExitCode } from '../exit-codes.js';
|
|
10
|
+
import { printError, printJsonError } from '../output.js';
|
|
11
|
+
import { readStdin } from '../read-stdin.js';
|
|
12
|
+
/** Run-specific flag definitions. */
|
|
13
|
+
export const RUN_FLAGS = {
|
|
14
|
+
'stream': { type: 'boolean' },
|
|
15
|
+
'thinking-effort': { type: 'string' },
|
|
16
|
+
'thinking-budget': { type: 'number' },
|
|
17
|
+
'temperature': { type: 'number' },
|
|
18
|
+
'top-p': { type: 'number' },
|
|
19
|
+
'top-k': { type: 'number' },
|
|
20
|
+
'thinking-override': { type: 'string' },
|
|
21
|
+
'max-tokens': { type: 'number' },
|
|
22
|
+
'max-output-tokens': { type: 'number' },
|
|
23
|
+
'max-turns': { type: 'number' },
|
|
24
|
+
'session': { type: 'string' },
|
|
25
|
+
'fork': { type: 'string' },
|
|
26
|
+
'no-session': { type: 'boolean' },
|
|
27
|
+
'system': { type: 'string' },
|
|
28
|
+
'system-mode': { type: 'string' },
|
|
29
|
+
'cwd': { type: 'string' },
|
|
30
|
+
'env': { type: 'string', repeatable: true },
|
|
31
|
+
'yolo': { type: 'boolean' },
|
|
32
|
+
'deny': { type: 'boolean' },
|
|
33
|
+
'timeout': { type: 'number' },
|
|
34
|
+
'inactivity-timeout': { type: 'number' },
|
|
35
|
+
'output-format': { type: 'string' },
|
|
36
|
+
'tag': { type: 'string', repeatable: true },
|
|
37
|
+
'run-id': { type: 'string' },
|
|
38
|
+
'attach': { type: 'string', repeatable: true },
|
|
39
|
+
'skill': { type: 'string', repeatable: true },
|
|
40
|
+
'agents-doc': { type: 'string' },
|
|
41
|
+
'mcp-server': { type: 'string', repeatable: true },
|
|
42
|
+
'project-id': { type: 'string' },
|
|
43
|
+
'profile': { type: 'string' },
|
|
44
|
+
'prompt': { short: 'p', type: 'string' },
|
|
45
|
+
'non-interactive': { type: 'boolean' },
|
|
46
|
+
'interactive': { short: 'i', type: 'boolean' },
|
|
47
|
+
'quiet': { short: 'q', type: 'boolean' },
|
|
48
|
+
'no-stream': { type: 'boolean' },
|
|
49
|
+
'use-mock-harness': { type: 'boolean' },
|
|
50
|
+
'mock-scenario': { type: 'string' },
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Validate mutual exclusion rules.
|
|
54
|
+
* Returns an error message or null if valid.
|
|
55
|
+
*/
|
|
56
|
+
export function validateRunFlags(flags) {
|
|
57
|
+
const session = flagBool(flags, 'session') !== undefined || flagStr(flags, 'session') !== undefined;
|
|
58
|
+
const noSession = flagBool(flags, 'no-session') === true;
|
|
59
|
+
const fork = flagStr(flags, 'fork') !== undefined;
|
|
60
|
+
const yolo = flagBool(flags, 'yolo') === true;
|
|
61
|
+
const deny = flagBool(flags, 'deny') === true;
|
|
62
|
+
const stream = flagBool(flags, 'stream') === true;
|
|
63
|
+
const noStream = flagBool(flags, 'no-stream') === true;
|
|
64
|
+
if (session && noSession)
|
|
65
|
+
return 'Cannot use --session with --no-session';
|
|
66
|
+
if (session && fork)
|
|
67
|
+
return 'Cannot use --session with --fork';
|
|
68
|
+
if (fork && noSession)
|
|
69
|
+
return 'Cannot use --fork with --no-session';
|
|
70
|
+
if (yolo && deny)
|
|
71
|
+
return 'Cannot use --yolo with --deny';
|
|
72
|
+
if (stream && noStream)
|
|
73
|
+
return 'Cannot use --stream with --no-stream';
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Build RunOptions from parsed args.
|
|
78
|
+
*/
|
|
79
|
+
export function buildRunOptions(args, registeredAgents) {
|
|
80
|
+
const { flags, positionals } = args;
|
|
81
|
+
const interactiveFlag = flagBool(flags, 'interactive') === true;
|
|
82
|
+
// Resolve agent and prompt from flags/positionals.
|
|
83
|
+
let agent = flagStr(flags, 'agent');
|
|
84
|
+
const promptFlag = flagStr(flags, 'prompt');
|
|
85
|
+
let prompt = promptFlag;
|
|
86
|
+
if (positionals.length >= 1) {
|
|
87
|
+
const positionalAgent = !agent && registeredAgents.has(positionals[0]);
|
|
88
|
+
if (positionalAgent) {
|
|
89
|
+
agent = positionals[0];
|
|
90
|
+
}
|
|
91
|
+
if (prompt === undefined) {
|
|
92
|
+
prompt = positionalAgent ? positionals.slice(1).join(' ') || undefined : positionals.join(' ');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Parse --env KEY=VALUE pairs
|
|
96
|
+
const envArr = flagArr(flags, 'env');
|
|
97
|
+
const env = {};
|
|
98
|
+
for (const entry of envArr) {
|
|
99
|
+
const eqIdx = entry.indexOf('=');
|
|
100
|
+
if (eqIdx !== -1) {
|
|
101
|
+
env[entry.slice(0, eqIdx)] = entry.slice(eqIdx + 1);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Determine approval mode
|
|
105
|
+
let approvalMode;
|
|
106
|
+
if (flagBool(flags, 'yolo'))
|
|
107
|
+
approvalMode = 'yolo';
|
|
108
|
+
else if (flagBool(flags, 'deny'))
|
|
109
|
+
approvalMode = 'deny';
|
|
110
|
+
// Determine stream mode
|
|
111
|
+
let stream;
|
|
112
|
+
if (flagBool(flags, 'stream') === true)
|
|
113
|
+
stream = true;
|
|
114
|
+
if (flagBool(flags, 'no-stream') === true)
|
|
115
|
+
stream = false;
|
|
116
|
+
// Parse thinking override
|
|
117
|
+
let thinkingOverride;
|
|
118
|
+
const toStr = flagStr(flags, 'thinking-override');
|
|
119
|
+
if (toStr) {
|
|
120
|
+
try {
|
|
121
|
+
thinkingOverride = JSON.parse(toStr);
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
// Will be caught by validation
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const maxOutputTokens = flagNum(flags, 'max-output-tokens') ?? flagNum(flags, 'max-tokens');
|
|
128
|
+
const options = {
|
|
129
|
+
agent,
|
|
130
|
+
prompt,
|
|
131
|
+
model: flagStr(flags, 'model'),
|
|
132
|
+
stream,
|
|
133
|
+
thinkingEffort: flagStr(flags, 'thinking-effort'),
|
|
134
|
+
thinkingBudgetTokens: flagNum(flags, 'thinking-budget'),
|
|
135
|
+
thinkingOverride,
|
|
136
|
+
temperature: flagNum(flags, 'temperature'),
|
|
137
|
+
topP: flagNum(flags, 'top-p'),
|
|
138
|
+
topK: flagNum(flags, 'top-k'),
|
|
139
|
+
maxOutputTokens,
|
|
140
|
+
maxTurns: flagNum(flags, 'max-turns'),
|
|
141
|
+
sessionId: flagStr(flags, 'session'),
|
|
142
|
+
forkSessionId: flagStr(flags, 'fork'),
|
|
143
|
+
noSession: flagBool(flags, 'no-session'),
|
|
144
|
+
systemPrompt: flagStr(flags, 'system'),
|
|
145
|
+
systemPromptMode: flagStr(flags, 'system-mode'),
|
|
146
|
+
cwd: flagStr(flags, 'cwd'),
|
|
147
|
+
env: Object.keys(env).length > 0 ? env : undefined,
|
|
148
|
+
approvalMode,
|
|
149
|
+
timeout: flagNum(flags, 'timeout'),
|
|
150
|
+
inactivityTimeout: flagNum(flags, 'inactivity-timeout'),
|
|
151
|
+
outputFormat: flagStr(flags, 'output-format'),
|
|
152
|
+
tags: flagArr(flags, 'tag').length > 0 ? flagArr(flags, 'tag') : undefined,
|
|
153
|
+
runId: flagStr(flags, 'run-id'),
|
|
154
|
+
skills: flagArr(flags, 'skill').length > 0 ? flagArr(flags, 'skill') : undefined,
|
|
155
|
+
agentsDoc: flagStr(flags, 'agents-doc'),
|
|
156
|
+
projectId: flagStr(flags, 'project-id'),
|
|
157
|
+
profile: flagStr(flags, 'profile'),
|
|
158
|
+
nonInteractive: flagBool(flags, 'non-interactive') === true && promptFlag !== undefined && !interactiveFlag ? true : undefined,
|
|
159
|
+
interactive: interactiveFlag ? true : undefined,
|
|
160
|
+
};
|
|
161
|
+
// Remove undefined entries
|
|
162
|
+
for (const key of Object.keys(options)) {
|
|
163
|
+
if (options[key] === undefined) {
|
|
164
|
+
delete options[key];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return { agent, prompt, options };
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Execute the run command.
|
|
171
|
+
*/
|
|
172
|
+
export async function runCommand(client, args) {
|
|
173
|
+
const jsonMode = flagBool(args.flags, 'json') === true;
|
|
174
|
+
const interactiveFlag = flagBool(args.flags, 'interactive') === true;
|
|
175
|
+
// Validate mutual exclusions
|
|
176
|
+
const exclusionError = validateRunFlags(args.flags);
|
|
177
|
+
if (exclusionError) {
|
|
178
|
+
if (jsonMode) {
|
|
179
|
+
printJsonError('VALIDATION_ERROR', exclusionError);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
printError(exclusionError);
|
|
183
|
+
}
|
|
184
|
+
return ExitCode.USAGE_ERROR;
|
|
185
|
+
}
|
|
186
|
+
// Get registered agents for positional resolution
|
|
187
|
+
const adapters = client.adapters.list();
|
|
188
|
+
const agentNames = new Set(adapters.map((a) => a.agent));
|
|
189
|
+
const { agent, prompt, options } = buildRunOptions(args, agentNames);
|
|
190
|
+
const explicitPrompt = prompt ?? options['prompt'];
|
|
191
|
+
const stdinPrompt = explicitPrompt === undefined && process.stdin.isTTY === false
|
|
192
|
+
? await readStdin()
|
|
193
|
+
: undefined;
|
|
194
|
+
const resolvedPrompt = explicitPrompt
|
|
195
|
+
?? (stdinPrompt && stdinPrompt.trim() ? stdinPrompt : undefined)
|
|
196
|
+
?? (interactiveFlag ? ' ' : undefined);
|
|
197
|
+
if (!agent && !options['agent']) {
|
|
198
|
+
if (jsonMode) {
|
|
199
|
+
printJsonError('VALIDATION_ERROR', 'No agent specified. Use --agent or provide agent as first argument.');
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
printError('No agent specified. Use --agent or provide agent as first argument.');
|
|
203
|
+
}
|
|
204
|
+
return ExitCode.USAGE_ERROR;
|
|
205
|
+
}
|
|
206
|
+
const effectiveAgent = agent ?? options['agent'];
|
|
207
|
+
const adapterRegistry = client.adapters;
|
|
208
|
+
const selectedAdapter = effectiveAgent && typeof adapterRegistry.get === 'function'
|
|
209
|
+
? adapterRegistry.get(effectiveAgent)
|
|
210
|
+
: undefined;
|
|
211
|
+
// Interactive mode is now supported via PTY spawn in spawn-runner.
|
|
212
|
+
// Pass it through to RunOptions so the spawn layer uses node-pty.
|
|
213
|
+
if (!resolvedPrompt) {
|
|
214
|
+
if (jsonMode) {
|
|
215
|
+
printJsonError('VALIDATION_ERROR', 'No prompt specified. Provide a prompt argument or pipe via stdin.');
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
printError('No prompt specified. Provide a prompt argument or pipe via stdin.');
|
|
219
|
+
}
|
|
220
|
+
return ExitCode.USAGE_ERROR;
|
|
221
|
+
}
|
|
222
|
+
const useMock = flagBool(args.flags, 'use-mock-harness') === true ||
|
|
223
|
+
process.env['USE_MOCK_HARNESS'] === '1' ||
|
|
224
|
+
process.env['USE_MOCK_HARNESS'] === 'true';
|
|
225
|
+
const mockScenario = flagStr(args.flags, 'mock-scenario');
|
|
226
|
+
if (useMock) {
|
|
227
|
+
const effectiveAgent = agent ?? options['agent'];
|
|
228
|
+
if (effectiveAgent) {
|
|
229
|
+
swapInMockAdapter(client, effectiveAgent, mockScenario);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
try {
|
|
233
|
+
let runOpts = {
|
|
234
|
+
agent: effectiveAgent,
|
|
235
|
+
prompt: resolvedPrompt,
|
|
236
|
+
...options,
|
|
237
|
+
};
|
|
238
|
+
if (typeof runOpts.profile === 'string' && runOpts.profile.length > 0) {
|
|
239
|
+
runOpts = await client.profiles.apply(runOpts.profile, runOpts);
|
|
240
|
+
}
|
|
241
|
+
const handle = client.run(runOpts);
|
|
242
|
+
// If we get here, stream events
|
|
243
|
+
if (jsonMode) {
|
|
244
|
+
// JSONL mode
|
|
245
|
+
for await (const event of handle) {
|
|
246
|
+
process.stdout.write(JSON.stringify(event) + '\n');
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
for await (const event of handle) {
|
|
251
|
+
if (event.type === 'text_delta') {
|
|
252
|
+
process.stdout.write(event.delta);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const result = await handle.result();
|
|
257
|
+
if (jsonMode) {
|
|
258
|
+
process.stdout.write(JSON.stringify({ type: 'run_result', ...result }) + '\n');
|
|
259
|
+
}
|
|
260
|
+
return runResultToExitCode(result);
|
|
261
|
+
}
|
|
262
|
+
catch (err) {
|
|
263
|
+
if (err instanceof AgentMuxError) {
|
|
264
|
+
if (jsonMode) {
|
|
265
|
+
printJsonError(err.code, err.message, err.recoverable);
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
printError(err.message);
|
|
269
|
+
}
|
|
270
|
+
return errorCodeToExitCode(err.code);
|
|
271
|
+
}
|
|
272
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
273
|
+
if (jsonMode) {
|
|
274
|
+
printJsonError('INTERNAL', message);
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
printError(message);
|
|
278
|
+
}
|
|
279
|
+
return ExitCode.GENERAL_ERROR;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function runResultToExitCode(result) {
|
|
283
|
+
if (result.exitReason === 'completed') {
|
|
284
|
+
return ExitCode.SUCCESS;
|
|
285
|
+
}
|
|
286
|
+
if (result.error?.code) {
|
|
287
|
+
return errorCodeToExitCode(result.error.code);
|
|
288
|
+
}
|
|
289
|
+
switch (result.exitReason) {
|
|
290
|
+
case 'timeout':
|
|
291
|
+
case 'inactivity':
|
|
292
|
+
return ExitCode.TIMEOUT;
|
|
293
|
+
case 'aborted':
|
|
294
|
+
case 'interrupted':
|
|
295
|
+
return ExitCode.ABORTED;
|
|
296
|
+
case 'crashed':
|
|
297
|
+
case 'killed':
|
|
298
|
+
return ExitCode.AGENT_CRASHED;
|
|
299
|
+
default:
|
|
300
|
+
return ExitCode.GENERAL_ERROR;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const MOCK_SCENARIO_ALIASES = {
|
|
304
|
+
'claude-basic': 'claude:basic-text',
|
|
305
|
+
'codex-basic': 'codex:basic-text',
|
|
306
|
+
'gemini-basic': 'gemini:basic-text',
|
|
307
|
+
'copilot-basic': 'copilot:basic-text',
|
|
308
|
+
'cursor-basic': 'cursor:basic-text',
|
|
309
|
+
'opencode-basic': 'opencode:basic-text',
|
|
310
|
+
'pi-basic': 'pi:basic-text',
|
|
311
|
+
'omp-basic': 'omp:basic-text',
|
|
312
|
+
'openclaw-basic': 'openclaw:basic-text',
|
|
313
|
+
'hermes-basic': 'hermes:basic-text',
|
|
314
|
+
};
|
|
315
|
+
function resolveMockScenarioName(agent, scenario) {
|
|
316
|
+
const requested = scenario ?? `${agent}-basic`;
|
|
317
|
+
return MOCK_SCENARIO_ALIASES[requested] ?? requested;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Replace the target agent's registered adapter with a wrapper whose
|
|
321
|
+
* `buildSpawnArgs` redirects the spawn to the `mock-harness` binary.
|
|
322
|
+
* Enables `--use-mock-harness` / `USE_MOCK_HARNESS=1` for offline E2E.
|
|
323
|
+
*
|
|
324
|
+
* The scenario name defaults to `<agent>-basic` (resolved by the mock's
|
|
325
|
+
* scenario registry at runtime); override with `--mock-scenario <name>`.
|
|
326
|
+
*/
|
|
327
|
+
function swapInMockAdapter(client, agent, scenario) {
|
|
328
|
+
const original = client.adapters.get(agent);
|
|
329
|
+
if (!original)
|
|
330
|
+
return;
|
|
331
|
+
const mockBin = process.env['AGENT_MUX_MOCK_HARNESS_BIN'] ?? 'mock-harness';
|
|
332
|
+
const scenarioName = resolveMockScenarioName(agent, scenario);
|
|
333
|
+
const mockExt = path.extname(mockBin).toLowerCase();
|
|
334
|
+
const launchWithNode = ['.js', '.mjs', '.cjs'].includes(mockExt);
|
|
335
|
+
const wrapped = Object.create(original);
|
|
336
|
+
wrapped.buildSpawnArgs = function mockBuildSpawnArgs(options) {
|
|
337
|
+
const real = original.buildSpawnArgs(options);
|
|
338
|
+
return {
|
|
339
|
+
...real,
|
|
340
|
+
command: launchWithNode ? process.execPath : mockBin,
|
|
341
|
+
args: launchWithNode
|
|
342
|
+
? [mockBin, '--scenario', scenarioName, '--agent', agent]
|
|
343
|
+
: ['--scenario', scenarioName, '--agent', agent],
|
|
344
|
+
usePty: false,
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
const registry = client.adapters;
|
|
348
|
+
if (typeof registry.unregister === 'function') {
|
|
349
|
+
registry.unregister(agent);
|
|
350
|
+
}
|
|
351
|
+
if (typeof registry.register === 'function') {
|
|
352
|
+
registry.register(wrapped);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
//# sourceMappingURL=run.js.map
|