@1agents/acp-service 0.2.0 → 0.4.0

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.
Files changed (73) hide show
  1. package/README.md +57 -33
  2. package/dist/bin/acp-service.js +2 -2
  3. package/dist/src/bridge.d.ts +2 -2
  4. package/dist/src/bridge.js +2 -2
  5. package/dist/src/catalog-descriptors.js +0 -10
  6. package/dist/src/catalog.js +20 -3
  7. package/dist/src/manifest.js +1 -1
  8. package/package.json +26 -7
  9. package/vendor/runtime/LICENSE +21 -0
  10. package/vendor/runtime/README.md +115 -0
  11. package/vendor/runtime/dist/agent-registry-CMg8LHKY.js +806 -0
  12. package/vendor/runtime/dist/agent-registry-CMg8LHKY.js.map +1 -0
  13. package/vendor/runtime/dist/agent-registry.d.ts +70 -0
  14. package/vendor/runtime/dist/agent-registry.d.ts.map +1 -0
  15. package/vendor/runtime/dist/agent-registry.js +2 -0
  16. package/vendor/runtime/dist/cli-DUHyAADv.js +182 -0
  17. package/vendor/runtime/dist/cli-DUHyAADv.js.map +1 -0
  18. package/vendor/runtime/dist/cli.d.ts +12 -0
  19. package/vendor/runtime/dist/cli.d.ts.map +1 -0
  20. package/vendor/runtime/dist/cli.js +2632 -0
  21. package/vendor/runtime/dist/cli.js.map +1 -0
  22. package/vendor/runtime/dist/client-DjkWknf7.d.ts +262 -0
  23. package/vendor/runtime/dist/client-DjkWknf7.d.ts.map +1 -0
  24. package/vendor/runtime/dist/docs-site/.nojekyll +0 -0
  25. package/vendor/runtime/dist/docs-site/CLI.html +832 -0
  26. package/vendor/runtime/dist/docs-site/CNAME +1 -0
  27. package/vendor/runtime/dist/docs-site/VISION.html +415 -0
  28. package/vendor/runtime/dist/docs-site/agents.html +391 -0
  29. package/vendor/runtime/dist/docs-site/compare.html +359 -0
  30. package/vendor/runtime/dist/docs-site/config.html +450 -0
  31. package/vendor/runtime/dist/docs-site/custom-agents.html +408 -0
  32. package/vendor/runtime/dist/docs-site/exit-codes.html +347 -0
  33. package/vendor/runtime/dist/docs-site/favicon.svg +21 -0
  34. package/vendor/runtime/dist/docs-site/flows.html +497 -0
  35. package/vendor/runtime/dist/docs-site/index.html +367 -0
  36. package/vendor/runtime/dist/docs-site/install.html +386 -0
  37. package/vendor/runtime/dist/docs-site/llms.txt +35 -0
  38. package/vendor/runtime/dist/docs-site/output-formats.html +403 -0
  39. package/vendor/runtime/dist/docs-site/permissions.html +413 -0
  40. package/vendor/runtime/dist/docs-site/prompting.html +460 -0
  41. package/vendor/runtime/dist/docs-site/proof-2026-07-18-grok-ext-methods/index.html +336 -0
  42. package/vendor/runtime/dist/docs-site/quickstart.html +382 -0
  43. package/vendor/runtime/dist/docs-site/runtime-environment.html +329 -0
  44. package/vendor/runtime/dist/docs-site/runtime-process-lifecycle.html +335 -0
  45. package/vendor/runtime/dist/docs-site/session-control.html +406 -0
  46. package/vendor/runtime/dist/docs-site/session-watch.html +354 -0
  47. package/vendor/runtime/dist/docs-site/sessions.html +486 -0
  48. package/vendor/runtime/dist/docs-site/shared-sessions.html +377 -0
  49. package/vendor/runtime/dist/flows-CiJSCy4D.js +2474 -0
  50. package/vendor/runtime/dist/flows-CiJSCy4D.js.map +1 -0
  51. package/vendor/runtime/dist/flows.d.ts +334 -0
  52. package/vendor/runtime/dist/flows.d.ts.map +1 -0
  53. package/vendor/runtime/dist/flows.js +2 -0
  54. package/vendor/runtime/dist/invocation-options-BlIySxIw.js +345 -0
  55. package/vendor/runtime/dist/invocation-options-BlIySxIw.js.map +1 -0
  56. package/vendor/runtime/dist/ipc-BlljKR2b.js +5336 -0
  57. package/vendor/runtime/dist/ipc-BlljKR2b.js.map +1 -0
  58. package/vendor/runtime/dist/output-BzXQKArM.js +1012 -0
  59. package/vendor/runtime/dist/output-BzXQKArM.js.map +1 -0
  60. package/vendor/runtime/dist/queue-owner-runtime-DSFdsS_y.js +8867 -0
  61. package/vendor/runtime/dist/queue-owner-runtime-DSFdsS_y.js.map +1 -0
  62. package/vendor/runtime/dist/runtime.d.ts +1156 -0
  63. package/vendor/runtime/dist/runtime.d.ts.map +1 -0
  64. package/vendor/runtime/dist/runtime.js +3675 -0
  65. package/vendor/runtime/dist/runtime.js.map +1 -0
  66. package/vendor/runtime/dist/session-options-ORCchZGk.d.ts +426 -0
  67. package/vendor/runtime/dist/session-options-ORCchZGk.d.ts.map +1 -0
  68. package/vendor/runtime/dist/session-watch-BiBTBMz4.js +76 -0
  69. package/vendor/runtime/dist/session-watch-BiBTBMz4.js.map +1 -0
  70. package/vendor/runtime/dist/watch-iYiP-lOo.js +85 -0
  71. package/vendor/runtime/dist/watch-iYiP-lOo.js.map +1 -0
  72. package/vendor/runtime/package.json +46 -0
  73. package/vendor/runtime/skills/acpx/SKILL.md +688 -0
@@ -0,0 +1,806 @@
1
+ import fs from "node:fs";
2
+ import { fileURLToPath } from "node:url";
3
+ import path from "node:path";
4
+ import { execFile } from "node:child_process";
5
+ //#region src/acp/client-process.ts
6
+ const PROCESS_HELPER_TIMEOUT_MS = 8e3;
7
+ const PROCESS_HELPER_MAX_BUFFER_BYTES = 33554432;
8
+ async function runTimedExecFile(command, args, options = {}) {
9
+ const timeoutMs = Math.max(1, Math.round(options.timeoutMs ?? 8e3));
10
+ return await new Promise((resolve, reject) => {
11
+ let settled = false;
12
+ let timer;
13
+ const child = execFile(command, [...args], {
14
+ encoding: "utf8",
15
+ maxBuffer: options.maxBufferBytes ?? 33554432,
16
+ killSignal: "SIGKILL",
17
+ windowsHide: options.windowsHide,
18
+ env: options.env
19
+ }, (error, stdout) => {
20
+ if (settled) return;
21
+ settled = true;
22
+ if (timer) clearTimeout(timer);
23
+ if (error) {
24
+ reject(error);
25
+ return;
26
+ }
27
+ resolve(stdout);
28
+ });
29
+ timer = setTimeout(() => {
30
+ if (settled) return;
31
+ settled = true;
32
+ const killed = child.kill("SIGKILL");
33
+ child.stdout?.destroy();
34
+ child.stderr?.destroy();
35
+ child.unref();
36
+ reject(Object.assign(/* @__PURE__ */ new Error(`${command} timed out after ${timeoutMs}ms`), {
37
+ code: "ETIMEDOUT",
38
+ killed,
39
+ signal: "SIGKILL"
40
+ }));
41
+ }, timeoutMs);
42
+ });
43
+ }
44
+ function normalizeAgentCommandInput(value) {
45
+ if (typeof value === "string") return { agentCommand: value };
46
+ const parts = toCommandParts([...value]);
47
+ const argv = [parts.command, ...parts.args];
48
+ return {
49
+ agentCommand: renderArgvIdentity(argv),
50
+ agentArgv: argv
51
+ };
52
+ }
53
+ const IDENTITY_SAFE_ARG_RE = /^[A-Za-z0-9_@%+=:,./^~-]+$/u;
54
+ function renderArgvIdentity(argv) {
55
+ return argv.map((arg) => IDENTITY_SAFE_ARG_RE.test(arg) ? arg : JSON.stringify(arg)).join(" ");
56
+ }
57
+ function isoNow() {
58
+ return (/* @__PURE__ */ new Date()).toISOString();
59
+ }
60
+ function waitForSpawn(child) {
61
+ return new Promise((resolve, reject) => {
62
+ const onSpawn = () => {
63
+ child.off("error", onError);
64
+ resolve();
65
+ };
66
+ const onError = (error) => {
67
+ child.off("spawn", onSpawn);
68
+ reject(error);
69
+ };
70
+ child.once("spawn", onSpawn);
71
+ child.once("error", onError);
72
+ });
73
+ }
74
+ function isChildProcessRunning(child) {
75
+ return child.exitCode == null && child.signalCode == null;
76
+ }
77
+ function requireAgentStdio(child) {
78
+ if (!child.stdin || !child.stdout || !child.stderr) throw new Error("ACP agent must be spawned with piped stdin/stdout/stderr");
79
+ return child;
80
+ }
81
+ function waitForChildExit(child, timeoutMs) {
82
+ if (!isChildProcessRunning(child)) return Promise.resolve(true);
83
+ return new Promise((resolve) => {
84
+ let settled = false;
85
+ const timer = setTimeout(() => {
86
+ finish(false);
87
+ }, Math.max(0, timeoutMs));
88
+ const finish = (value) => {
89
+ if (settled) return;
90
+ settled = true;
91
+ child.off("close", onExitLike);
92
+ child.off("exit", onExitLike);
93
+ clearTimeout(timer);
94
+ resolve(value);
95
+ };
96
+ const onExitLike = () => {
97
+ finish(true);
98
+ };
99
+ child.once("close", onExitLike);
100
+ child.once("exit", onExitLike);
101
+ });
102
+ }
103
+ function resolveAgentCommandParts(value, argv, platform = process.platform) {
104
+ if (argv) {
105
+ const parts = toCommandParts([...argv]);
106
+ assertWindowsLaunchableCommand(parts.command, platform);
107
+ return parts;
108
+ }
109
+ if (platform === "win32") throw new Error("Raw agent command strings are not supported on Windows. Configure the agent with an argv array, for example: \"argv\": [\"agent.exe\", \"--acp\"]. Legacy agents.<name>.args arrays are migrated automatically. Existing sessions without saved argv must be closed and recreated.");
110
+ return splitCommandLine(value);
111
+ }
112
+ function assertWindowsLaunchableCommand(command, platform) {
113
+ if (platform === "win32" && path.extname(command).toLowerCase() === ".sh") throw new Error(`Windows cannot launch shell script executable "${command}" directly. Configure an explicit interpreter argv, for example: "argv": ["bash", "${command}"]. acpx does not infer interpreters.`);
114
+ }
115
+ function splitCommandLine(value) {
116
+ const state = {
117
+ current: "",
118
+ quote: null,
119
+ escaping: false,
120
+ parts: [],
121
+ hasPart: false
122
+ };
123
+ for (const ch of value) readCommandLineChar(state, ch);
124
+ if (state.escaping) {
125
+ state.current += "\\";
126
+ state.hasPart = true;
127
+ }
128
+ if (state.quote) throw new Error("Invalid --agent command: unterminated quote");
129
+ flushCommandLinePart(state);
130
+ return toCommandParts(state.parts);
131
+ }
132
+ function toCommandParts(parts) {
133
+ if (parts.length === 0 || parts[0] === "") throw new Error("Invalid --agent command: empty command");
134
+ return {
135
+ command: parts[0],
136
+ args: parts.slice(1)
137
+ };
138
+ }
139
+ function readCommandLineChar(state, ch) {
140
+ if (state.escaping) {
141
+ state.current += ch;
142
+ state.escaping = false;
143
+ state.hasPart = true;
144
+ } else if (ch === "\\" && state.quote !== "'") state.escaping = true;
145
+ else if (state.quote) {
146
+ if (ch === state.quote) state.quote = null;
147
+ else state.current += ch;
148
+ state.hasPart = true;
149
+ } else readUnquotedCommandLineChar(state, ch);
150
+ }
151
+ function readUnquotedCommandLineChar(state, ch) {
152
+ if (ch === "'" || ch === "\"") {
153
+ state.quote = ch;
154
+ state.hasPart = true;
155
+ } else if (/\s/.test(ch)) flushCommandLinePart(state);
156
+ else {
157
+ state.current += ch;
158
+ state.hasPart = true;
159
+ }
160
+ }
161
+ function flushCommandLinePart(state) {
162
+ if (state.hasPart) {
163
+ state.parts.push(state.current);
164
+ state.current = "";
165
+ state.hasPart = false;
166
+ }
167
+ }
168
+ function asAbsoluteCwd(cwd) {
169
+ return path.resolve(cwd);
170
+ }
171
+ async function resolveAgentSessionCwd(cwd, agentCommand, options = {}) {
172
+ const resolved = asAbsoluteCwd(cwd);
173
+ if (!shouldTranslateWslWindowsCwd(agentCommand, options)) return resolved;
174
+ const translated = (await (options.runWslpath ?? runWslpath)(resolved)).trim();
175
+ if (!translated) throw new Error(`wslpath returned an empty Windows path for cwd: ${resolved}`);
176
+ return translated;
177
+ }
178
+ function shouldTranslateWslWindowsCwd(agentCommand, options) {
179
+ if (!isWsl(options)) return false;
180
+ try {
181
+ const { command } = splitCommandLine(agentCommand);
182
+ return isWindowsExecutableCommand(command);
183
+ } catch {
184
+ return false;
185
+ }
186
+ }
187
+ function isWsl(options) {
188
+ if ((options.platform ?? process.platform) !== "linux") return false;
189
+ return (options.existsSync ?? fs.existsSync)("/proc/sys/fs/binfmt_misc/WSLInterop");
190
+ }
191
+ const WINDOWS_EXECUTABLE_EXTENSION_RE = /\.(?:exe|cmd|bat)$/u;
192
+ function isWindowsExecutableCommand(command) {
193
+ const normalized = command.toLowerCase();
194
+ return WINDOWS_EXECUTABLE_EXTENSION_RE.test(normalized);
195
+ }
196
+ async function runWslpath(cwd) {
197
+ return await runTimedExecFile("wslpath", ["-w", cwd]);
198
+ }
199
+ function basenameToken(value) {
200
+ return path.basename(value).toLowerCase().replace(/\.(cmd|exe|bat)$/u, "");
201
+ }
202
+ //#endregion
203
+ //#region src/spawn-command-options.ts
204
+ function readWindowsEnvValue(env, key) {
205
+ const matchedKey = Object.keys(env).find((entry) => entry.toUpperCase() === key);
206
+ return matchedKey ? env[matchedKey] : void 0;
207
+ }
208
+ function windowsExecutableExtensions(env) {
209
+ return (readWindowsEnvValue(env, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((value) => value.trim().toLowerCase()).filter((value) => value.length > 0);
210
+ }
211
+ function commandCandidates(command, env) {
212
+ if (path.extname(command).length > 0) return [command];
213
+ return windowsExecutableExtensions(env).map((extension) => `${command}${extension}`);
214
+ }
215
+ function commandHasPath(command) {
216
+ return command.includes("/") || command.includes("\\") || path.isAbsolute(command);
217
+ }
218
+ function resolveWindowsPathCommand(command, env, cwd) {
219
+ const candidates = commandCandidates(command, env);
220
+ const pathValue = readWindowsEnvValue(env, "PATH");
221
+ if (!pathValue) return;
222
+ for (const directory of pathValue.split(";")) {
223
+ const resolved = findExistingCommandInDirectory(directory, candidates, cwd);
224
+ if (resolved) return resolved;
225
+ }
226
+ }
227
+ function findExistingCommandInDirectory(directory, candidates, cwd) {
228
+ const trimmedDirectory = directory.trim();
229
+ if (trimmedDirectory.length === 0) return;
230
+ return candidates.map((candidate) => fromWorkingDirectory(path.join(trimmedDirectory, candidate), cwd)).find((resolved) => fs.existsSync(resolved));
231
+ }
232
+ function fromWorkingDirectory(value, cwd) {
233
+ return cwd !== void 0 && !path.isAbsolute(value) ? path.resolve(cwd, value) : value;
234
+ }
235
+ function resolveWindowsWrapperToken(token, wrapperPath) {
236
+ const relative = token.match(/%~?dp0%?\s*[\\/]*(.*)$/i)?.[1]?.trim();
237
+ if (!relative) return;
238
+ const candidate = path.resolve(path.dirname(wrapperPath), relative.replace(/[\\/]+/g, path.sep).replace(/^[\\/]+/, ""));
239
+ return path.extname(candidate).toLowerCase() === ".exe" && fs.existsSync(candidate) ? candidate : void 0;
240
+ }
241
+ function resolveWindowsWrapperExecutable(wrapperPath) {
242
+ if (!fs.existsSync(wrapperPath)) return;
243
+ try {
244
+ return [...fs.readFileSync(wrapperPath, "utf8").matchAll(/"([^"\r\n]*)"/g)].map((match) => resolveWindowsWrapperToken(match[1] ?? "", wrapperPath)).find((candidate) => candidate !== void 0);
245
+ } catch {
246
+ return;
247
+ }
248
+ }
249
+ function resolveWindowsCommand(command, env = process.env, cwd) {
250
+ const candidates = commandCandidates(command, env);
251
+ if (commandHasPath(command)) return candidates.map((candidate) => fromWorkingDirectory(candidate, cwd)).find((candidate) => fs.existsSync(candidate));
252
+ return resolveWindowsPathCommand(command, env, cwd);
253
+ }
254
+ /**
255
+ * Resolve a Windows command to a native executable suitable for direct spawn.
256
+ *
257
+ * Batch and PowerShell shims are intentionally rejected unless they point at a
258
+ * real `.exe` entrypoint. Callers that need shell execution should use the
259
+ * command-specific shell policy instead.
260
+ */
261
+ function resolveWindowsExecutablePath(command, env = process.env, cwd) {
262
+ const resolved = resolveWindowsCommand(command, env, cwd);
263
+ if (!resolved) return;
264
+ const absolute = path.resolve(resolved);
265
+ const extension = path.extname(absolute).toLowerCase();
266
+ if (extension === ".exe") return absolute;
267
+ if (extension !== ".cmd" && extension !== ".bat" && extension !== ".ps1") return;
268
+ const siblingExecutable = `${absolute.slice(0, -extension.length)}.exe`;
269
+ return fs.existsSync(siblingExecutable) ? siblingExecutable : resolveWindowsWrapperExecutable(absolute);
270
+ }
271
+ function shouldUseWindowsBatchShell(command, platform = process.platform, env = process.env, cwd) {
272
+ if (platform !== "win32") return false;
273
+ const resolvedCommand = resolveWindowsCommand(command, env, cwd) ?? command;
274
+ const ext = path.extname(resolvedCommand).toLowerCase();
275
+ return ext === ".cmd" || ext === ".bat";
276
+ }
277
+ const CMD_META_CHAR_RE = /([()\][%!^"`<>&|;, *?])/gu;
278
+ const CMD_SHIM_RE = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/iu;
279
+ function escapeCmdCommand(value) {
280
+ return value.replace(CMD_META_CHAR_RE, "^$1");
281
+ }
282
+ function escapeCmdArgument(value, doubleEscapeMeta) {
283
+ const escaped = `"${escapeBackslashesForQuoting(value)}"`.replace(CMD_META_CHAR_RE, "^$1");
284
+ return doubleEscapeMeta ? escaped.replace(CMD_META_CHAR_RE, "^$1") : escaped;
285
+ }
286
+ function escapeBackslashesForQuoting(value) {
287
+ let result = "";
288
+ let backslashes = 0;
289
+ for (const char of value) {
290
+ if (char === "\\") {
291
+ backslashes += 1;
292
+ continue;
293
+ }
294
+ result += "\\".repeat(char === "\"" ? backslashes * 2 + 1 : backslashes) + char;
295
+ backslashes = 0;
296
+ }
297
+ return result + "\\".repeat(backslashes * 2);
298
+ }
299
+ function buildAgentSpawnCommand(command, args, platform = process.platform, env = process.env, cwd) {
300
+ if (!shouldUseWindowsBatchShell(command, platform, env, cwd)) return {
301
+ command,
302
+ args: [...args]
303
+ };
304
+ const resolvedCommand = path.win32.normalize(resolveWindowsCommand(command, env, cwd) ?? command);
305
+ const doubleEscapeMeta = CMD_SHIM_RE.test(resolvedCommand);
306
+ const shellCommand = [escapeCmdCommand(resolvedCommand), ...args.map((arg) => escapeCmdArgument(arg, doubleEscapeMeta))].join(" ");
307
+ return {
308
+ command: readWindowsEnvValue(env, "COMSPEC") ?? "cmd.exe",
309
+ args: [
310
+ "/d",
311
+ "/s",
312
+ "/c",
313
+ `"${shellCommand}"`
314
+ ],
315
+ windowsVerbatimArguments: true
316
+ };
317
+ }
318
+ function buildSpawnCommandOptions(command, options, platform = process.platform, env = process.env, cwd) {
319
+ if (!shouldUseWindowsBatchShell(command, platform, env, cwd)) return options;
320
+ return {
321
+ ...options,
322
+ shell: true
323
+ };
324
+ }
325
+ function buildTerminalSpawnCommand(command, args) {
326
+ return {
327
+ command,
328
+ args: args ?? [],
329
+ killProcessGroup: false
330
+ };
331
+ }
332
+ function buildTerminalShellSpawnCommand(command, platform = process.platform) {
333
+ if (platform === "win32") return {
334
+ command: "cmd.exe",
335
+ args: [
336
+ "/d",
337
+ "/s",
338
+ "/c",
339
+ command
340
+ ],
341
+ killProcessGroup: true
342
+ };
343
+ return {
344
+ command: "/bin/sh",
345
+ args: ["-c", command],
346
+ killProcessGroup: true
347
+ };
348
+ }
349
+ /** Finds an installed entrypoint without executing it. */
350
+ function resolveInstalledExecutable(command) {
351
+ if (process.platform === "win32") {
352
+ const resolved = resolveWindowsCommand(command);
353
+ return resolved && fs.statSync(resolved, { throwIfNoEntry: false })?.isFile() ? path.resolve(resolved) : void 0;
354
+ }
355
+ return (command.includes("/") ? [path.resolve(command)] : (process.env.PATH ?? "").split(path.delimiter).map((directory) => path.resolve(directory, command))).find((candidate) => {
356
+ try {
357
+ fs.accessSync(candidate, fs.constants.X_OK);
358
+ return fs.statSync(candidate).isFile();
359
+ } catch {
360
+ return false;
361
+ }
362
+ });
363
+ }
364
+ //#endregion
365
+ //#region src/agent-registry.ts
366
+ const ACP_ADAPTER_PACKAGE_RANGES = {
367
+ pi: "^0.0.33",
368
+ codex: "^1.1.5",
369
+ claude: "^0.81.2",
370
+ mux: "^0.28.0"
371
+ };
372
+ const AGENT_DEFINITIONS = {
373
+ pi: {
374
+ name: "Pi",
375
+ argv: ["npx", `pi-acp@${ACP_ADAPTER_PACKAGE_RANGES.pi}`],
376
+ installedArgv: ["pi-acp"],
377
+ requiredCommands: ["pi"],
378
+ package: {
379
+ packageName: "pi-acp",
380
+ packageRange: ACP_ADAPTER_PACKAGE_RANGES.pi,
381
+ preferredBinName: "pi-acp"
382
+ }
383
+ },
384
+ openclaw: {
385
+ name: "OpenClaw",
386
+ argv: ["openclaw", "acp"]
387
+ },
388
+ codex: {
389
+ name: "Codex",
390
+ argv: [
391
+ "npx",
392
+ "-y",
393
+ `@agentclientprotocol/codex-acp@${ACP_ADAPTER_PACKAGE_RANGES.codex}`
394
+ ],
395
+ installedArgv: ["codex-acp"],
396
+ package: {
397
+ packageName: "@agentclientprotocol/codex-acp",
398
+ packageRange: ACP_ADAPTER_PACKAGE_RANGES.codex,
399
+ preferredBinName: "codex-acp",
400
+ legacyFallbackCommands: []
401
+ },
402
+ packageExecFallback: true
403
+ },
404
+ claude: {
405
+ name: "Claude Code",
406
+ argv: [
407
+ "npx",
408
+ "-y",
409
+ `@agentclientprotocol/claude-agent-acp@${ACP_ADAPTER_PACKAGE_RANGES.claude}`
410
+ ],
411
+ installedArgv: ["claude-agent-acp"],
412
+ package: {
413
+ packageName: "@agentclientprotocol/claude-agent-acp",
414
+ packageRange: ACP_ADAPTER_PACKAGE_RANGES.claude,
415
+ preferredBinName: "claude-agent-acp",
416
+ legacyFallbackCommands: [`npm exec @agentclientprotocol/claude-agent-acp@${ACP_ADAPTER_PACKAGE_RANGES.claude}`]
417
+ },
418
+ packageExecFallback: true
419
+ },
420
+ gemini: {
421
+ name: "Gemini CLI",
422
+ argv: ["gemini", "--acp"]
423
+ },
424
+ cursor: {
425
+ name: "Cursor",
426
+ argv: ["cursor-agent", "acp"]
427
+ },
428
+ copilot: {
429
+ name: "GitHub Copilot",
430
+ argv: [
431
+ "copilot",
432
+ "--acp",
433
+ "--stdio"
434
+ ]
435
+ },
436
+ antigravity: {
437
+ name: "Google Antigravity",
438
+ argv: process.platform === "win32" ? ["agy_acp_server.exe"] : ["agy_acp_server.par", ...process.platform === "linux" ? ["--uid="] : []]
439
+ },
440
+ devin: {
441
+ name: "Devin",
442
+ argv: ["devin", "acp"]
443
+ },
444
+ droid: {
445
+ name: "Factory Droid",
446
+ argv: [
447
+ "droid",
448
+ "exec",
449
+ "--output-format",
450
+ "acp"
451
+ ]
452
+ },
453
+ "fast-agent": {
454
+ name: "Fast Agent",
455
+ argv: [
456
+ "uvx",
457
+ "fast-agent-mcp",
458
+ "acp"
459
+ ]
460
+ },
461
+ fx: {
462
+ name: "fx",
463
+ argv: ["fx", "acp"]
464
+ },
465
+ "grok-build": {
466
+ name: "Grok Build",
467
+ argv: [
468
+ "grok",
469
+ "agent",
470
+ "stdio"
471
+ ]
472
+ },
473
+ iflow: {
474
+ name: "iFlow",
475
+ argv: ["iflow", "--experimental-acp"]
476
+ },
477
+ junie: {
478
+ name: "Junie",
479
+ argv: ["junie", "--acp=true"]
480
+ },
481
+ kilocode: {
482
+ name: "Kilo Code",
483
+ argv: [
484
+ "npx",
485
+ "-y",
486
+ "@kilocode/cli",
487
+ "acp"
488
+ ],
489
+ installedArgv: ["kilo", "acp"]
490
+ },
491
+ kimi: {
492
+ name: "Kimi Code",
493
+ argv: ["kimi", "acp"]
494
+ },
495
+ kiro: {
496
+ name: "Kiro",
497
+ argv: ["kiro-cli-chat", "acp"]
498
+ },
499
+ mcode: {
500
+ name: "MCode",
501
+ argv: ["mcode", "acp"]
502
+ },
503
+ mux: {
504
+ name: "Mux",
505
+ argv: [
506
+ "npx",
507
+ "-y",
508
+ `mux@${ACP_ADAPTER_PACKAGE_RANGES.mux}`,
509
+ "acp"
510
+ ],
511
+ installedArgv: ["mux", "acp"]
512
+ },
513
+ opencode: {
514
+ name: "OpenCode",
515
+ argv: [
516
+ "npx",
517
+ "-y",
518
+ "opencode-ai",
519
+ "acp"
520
+ ],
521
+ installedArgv: ["opencode", "acp"]
522
+ },
523
+ pool: {
524
+ name: "Poolside",
525
+ argv: ["pool", "acp"]
526
+ },
527
+ qoder: {
528
+ name: "Qoder",
529
+ argv: ["qodercli", "--acp"]
530
+ },
531
+ qwen: {
532
+ name: "Qwen Code",
533
+ argv: ["qwen", "--acp"]
534
+ },
535
+ trae: {
536
+ name: "Trae",
537
+ argv: [
538
+ "traecli",
539
+ "acp",
540
+ "serve"
541
+ ]
542
+ },
543
+ zeroclaw: {
544
+ name: "ZeroClaw",
545
+ argv: ["zeroclaw", "acp"]
546
+ }
547
+ };
548
+ const AGENT_ARGV_REGISTRY = Object.fromEntries(Object.entries(AGENT_DEFINITIONS).map(([id, definition]) => [id, [...definition.argv]]));
549
+ const AGENT_REGISTRY = Object.fromEntries(Object.entries(AGENT_DEFINITIONS).map(([id, definition]) => [id, definition.argv.join(" ")]));
550
+ const BUILT_IN_AGENT_PACKAGES = Object.fromEntries(Object.entries(AGENT_DEFINITIONS).flatMap(([id, definition]) => definition.packageExecFallback && definition.package ? [[id, {
551
+ ...definition.package,
552
+ fallbackCommand: definition.argv.join(" ")
553
+ }]] : []));
554
+ function isPackageExecution(argv) {
555
+ const command = path.win32.basename(argv[0]).toLowerCase().replace(/\.(cmd|exe|bat)$/, "");
556
+ if ([
557
+ "npx",
558
+ "uvx",
559
+ "npm",
560
+ "pnpm",
561
+ "bunx"
562
+ ].includes(command)) return true;
563
+ switch (command) {
564
+ case "bun": return argv[1] === "x";
565
+ case "uv": return argv[1] === "tool" && argv[2] === "run";
566
+ case "node": return /(?:npm|npx)-cli\.js$/u.test(argv[1] ?? "");
567
+ default: return false;
568
+ }
569
+ }
570
+ function inspectionDefinition(id, override) {
571
+ const definition = Object.hasOwn(AGENT_DEFINITIONS, id) ? AGENT_DEFINITIONS[id] : void 0;
572
+ if (!override) return definition;
573
+ let argv = override;
574
+ if (typeof argv === "string") {
575
+ const parsed = splitCommandLine(argv);
576
+ argv = [parsed.command, ...parsed.args];
577
+ }
578
+ return {
579
+ name: definition?.name ?? id,
580
+ argv
581
+ };
582
+ }
583
+ function inspectAgent(agentId, override, options = {}) {
584
+ const id = resolveCanonicalAgentName(agentId);
585
+ const definition = inspectionDefinition(id, override);
586
+ if (!definition) return;
587
+ const argv = definition.installedArgv ?? definition.argv;
588
+ if (isPackageExecution(argv)) return;
589
+ const launch = inspectLaunch(argv, definition.package ? {
590
+ ...definition.package,
591
+ fallbackCommand: definition.argv.join(" ")
592
+ } : void 0, options);
593
+ return {
594
+ id,
595
+ name: definition.name,
596
+ launch: inspectPrerequisites(launch, definition.requiredCommands ?? [], options)
597
+ };
598
+ }
599
+ function inspectPrerequisites(launch, requiredCommands, options) {
600
+ const resolveExecutable = options.resolveExecutable ?? resolveInstalledExecutable;
601
+ const missingCommands = requiredCommands.filter((command) => !resolveExecutable(command)).map((name) => ({
602
+ kind: "command",
603
+ name
604
+ }));
605
+ if (missingCommands.length === 0) return launch;
606
+ return {
607
+ kind: "missing",
608
+ requirements: [...launch.kind === "missing" ? launch.requirements : [], ...missingCommands]
609
+ };
610
+ }
611
+ function inspectLaunch(argv, spec, options) {
612
+ const command = (options.resolveExecutable ?? resolveInstalledExecutable)(argv[0]);
613
+ if (command) return {
614
+ kind: "installed",
615
+ argv: [command, ...argv.slice(1)]
616
+ };
617
+ if (!spec) return {
618
+ kind: "missing",
619
+ requirements: [{
620
+ kind: "command",
621
+ name: argv[0]
622
+ }]
623
+ };
624
+ const installed = resolveInstalledBuiltInAgentLaunchForSpec(spec, options);
625
+ return installed ? {
626
+ kind: "installed",
627
+ argv: [installed.command, ...installed.args]
628
+ } : {
629
+ kind: "missing",
630
+ requirements: [{
631
+ kind: "package",
632
+ name: spec.packageName
633
+ }]
634
+ };
635
+ }
636
+ const AGENT_ALIASES = {
637
+ "factory-droid": "droid",
638
+ factorydroid: "droid",
639
+ claudecode: "claude"
640
+ };
641
+ const DEFAULT_AGENT_NAME = "codex";
642
+ function normalizeAgentName(value) {
643
+ return value.trim().toLowerCase();
644
+ }
645
+ function resolveCanonicalAgentName(value) {
646
+ const normalized = normalizeAgentName(value);
647
+ return Object.hasOwn(AGENT_ALIASES, normalized) ? AGENT_ALIASES[normalized] : normalized;
648
+ }
649
+ function findAgentEntry(registry, agentName) {
650
+ const normalized = normalizeAgentName(agentName);
651
+ const canonical = resolveCanonicalAgentName(agentName);
652
+ return Object.hasOwn(registry, normalized) ? registry[normalized] : Object.hasOwn(registry, canonical) ? registry[canonical] : void 0;
653
+ }
654
+ function mergeAgentRegistry(overrides) {
655
+ if (!overrides) return { ...AGENT_REGISTRY };
656
+ const entries = Object.entries(AGENT_REGISTRY);
657
+ for (const [name, command] of Object.entries(overrides)) {
658
+ const normalized = normalizeAgentName(name);
659
+ if (!normalized || !command.trim()) continue;
660
+ entries.push([normalized, command.trim()]);
661
+ }
662
+ return Object.fromEntries(entries);
663
+ }
664
+ function resolveAgentCommand(agentName, overrides) {
665
+ return findAgentEntry(mergeAgentRegistry(overrides), agentName) ?? agentName;
666
+ }
667
+ function resolveAgentArgv(agentName) {
668
+ const argv = findAgentEntry(AGENT_ARGV_REGISTRY, agentName);
669
+ return argv ? [...argv] : void 0;
670
+ }
671
+ function findBuiltInAgentPackage(agentCommand) {
672
+ const normalized = agentCommand.trim();
673
+ return Object.values(BUILT_IN_AGENT_PACKAGES).find((spec) => spec.fallbackCommand === normalized || spec.legacyFallbackCommands?.includes(normalized));
674
+ }
675
+ function defaultResolvePackageRoot(packageName) {
676
+ const segments = packageName.split("/");
677
+ let cursor = path.dirname(fileURLToPath(import.meta.url));
678
+ while (true) {
679
+ const candidateRoot = path.join(cursor, "node_modules", ...segments);
680
+ const manifestPath = path.join(candidateRoot, "package.json");
681
+ if (fs.existsSync(manifestPath)) try {
682
+ if (JSON.parse(fs.readFileSync(manifestPath, "utf8")).name === packageName) return candidateRoot;
683
+ } catch {}
684
+ const parent = path.dirname(cursor);
685
+ if (parent === cursor) throw new Error(`Built-in agent package not found: ${packageName}`);
686
+ cursor = parent;
687
+ }
688
+ }
689
+ function resolvePackageBin(spec, manifest) {
690
+ if (typeof manifest.bin === "string") return manifest.bin;
691
+ if (!manifest.bin || typeof manifest.bin !== "object") return;
692
+ return manifest.bin[spec.preferredBinName] ?? (Object.keys(manifest.bin).length === 1 ? Object.values(manifest.bin)[0] : void 0);
693
+ }
694
+ function defaultResolveNpmCliPath(execPath) {
695
+ const candidate = path.resolve(path.dirname(execPath), "..", "lib", "node_modules", "npm", "bin", "npm-cli.js");
696
+ if (!fs.existsSync(candidate)) throw new Error(`npm CLI not found for execPath: ${execPath}`);
697
+ return candidate;
698
+ }
699
+ function resolveInstalledBuiltInAgentLaunch(agentCommand, options = {}) {
700
+ const spec = findBuiltInAgentPackage(agentCommand);
701
+ if (!spec) return;
702
+ return resolveInstalledBuiltInAgentLaunchForSpec(spec, options);
703
+ }
704
+ function resolveInstalledBuiltInAgentLaunchForSpec(spec, options) {
705
+ const readFileSync = options.readFileSync ?? fs.readFileSync;
706
+ const existsSync = options.existsSync ?? fs.existsSync;
707
+ const resolvePackageRoot = options.resolvePackageRoot ?? defaultResolvePackageRoot;
708
+ try {
709
+ const resolved = resolveInstalledBuiltInAgentPackage(spec, {
710
+ readFileSync,
711
+ existsSync,
712
+ resolvePackageRoot
713
+ });
714
+ if (!resolved) return;
715
+ return {
716
+ source: "installed",
717
+ command: process.execPath,
718
+ args: [resolved.binPath],
719
+ packageName: spec.packageName,
720
+ packageRange: spec.packageRange,
721
+ packageVersion: resolved.packageVersion,
722
+ binPath: resolved.binPath
723
+ };
724
+ } catch {
725
+ return;
726
+ }
727
+ }
728
+ function resolveInstalledBuiltInAgentPackage(spec, options) {
729
+ const packageRoot = options.resolvePackageRoot(spec.packageName);
730
+ if (!packageRoot) return;
731
+ const manifest = JSON.parse(options.readFileSync(path.join(packageRoot, "package.json"), "utf8"));
732
+ if (manifest.name !== spec.packageName) return;
733
+ const relativeBinPath = resolvePackageBin(spec, manifest);
734
+ if (!relativeBinPath) return;
735
+ const binPath = path.resolve(packageRoot, relativeBinPath);
736
+ return options.existsSync(binPath) ? {
737
+ packageVersion: manifest.version,
738
+ binPath
739
+ } : void 0;
740
+ }
741
+ function resolvePackageExecBuiltInAgentLaunch(agentCommand, options = {}) {
742
+ const spec = findBuiltInAgentPackage(agentCommand);
743
+ if (!spec) return;
744
+ const existsSync = options.existsSync ?? fs.existsSync;
745
+ const execPath = options.execPath ?? process.execPath;
746
+ const resolveNpmCliPath = options.resolveNpmCliPath ?? defaultResolveNpmCliPath;
747
+ try {
748
+ const npmCliPath = resolveNpmCliPath(execPath);
749
+ if (!existsSync(npmCliPath)) return;
750
+ return {
751
+ source: "package-exec",
752
+ command: execPath,
753
+ args: [
754
+ npmCliPath,
755
+ "exec",
756
+ "--yes",
757
+ `--package=${spec.packageName}@${spec.packageRange}`,
758
+ "--",
759
+ spec.preferredBinName
760
+ ],
761
+ packageName: spec.packageName,
762
+ packageRange: spec.packageRange,
763
+ npmCliPath
764
+ };
765
+ } catch {
766
+ return;
767
+ }
768
+ }
769
+ function resolveBuiltInAgentLaunch(agentCommand, options = {}) {
770
+ return resolveInstalledBuiltInAgentLaunch(agentCommand, options) ?? resolvePackageExecBuiltInAgentLaunch(agentCommand, options);
771
+ }
772
+ function listBuiltInAgents(overrides) {
773
+ return [.../* @__PURE__ */ new Set([...Object.keys(AGENT_REGISTRY), ...Object.keys(overrides ?? {})])];
774
+ }
775
+ function createAgentRegistry(params) {
776
+ const overrides = normalizeRegistryOverrides(params?.overrides);
777
+ return {
778
+ resolve(agentName) {
779
+ return findAgentEntry(overrides, agentName) ?? resolveAgentArgv(agentName) ?? resolveAgentCommand(agentName);
780
+ },
781
+ list() {
782
+ return listBuiltInAgents(overrides);
783
+ },
784
+ inspect(agentId) {
785
+ return inspectAgent(agentId, findAgentEntry(overrides, agentId), params);
786
+ }
787
+ };
788
+ }
789
+ function normalizeRegistryOverrides(values) {
790
+ const entries = [];
791
+ for (const [name, value] of Object.entries(values ?? {})) {
792
+ const normalizedName = normalizeAgentName(name);
793
+ if (!normalizedName) continue;
794
+ const normalizedValue = normalizeRegistryOverride(value);
795
+ if (normalizedValue) entries.push([normalizedName, normalizedValue]);
796
+ }
797
+ return Object.fromEntries(entries);
798
+ }
799
+ function normalizeRegistryOverride(value) {
800
+ if (typeof value === "string") return value.trim() || void 0;
801
+ return value.length > 0 && value[0]?.length ? [...value] : void 0;
802
+ }
803
+ //#endregion
804
+ export { renderArgvIdentity as A, PROCESS_HELPER_MAX_BUFFER_BYTES as C, isChildProcessRunning as D, basenameToken as E, splitCommandLine as F, waitForChildExit as I, waitForSpawn as L, resolveAgentCommandParts as M, resolveAgentSessionCwd as N, isoNow as O, runTimedExecFile as P, resolveWindowsExecutablePath as S, asAbsoluteCwd as T, buildSpawnCommandOptions as _, createAgentRegistry as a, readWindowsEnvValue as b, mergeAgentRegistry as c, resolveAgentCommand as d, resolveBuiltInAgentLaunch as f, buildAgentSpawnCommand as g, resolvePackageExecBuiltInAgentLaunch as h, DEFAULT_AGENT_NAME as i, requireAgentStdio as j, normalizeAgentCommandInput as k, normalizeAgentName as l, resolveInstalledBuiltInAgentLaunch as m, AGENT_REGISTRY as n, findBuiltInAgentPackage as o, resolveCanonicalAgentName as p, BUILT_IN_AGENT_PACKAGES as r, listBuiltInAgents as s, AGENT_ARGV_REGISTRY as t, resolveAgentArgv as u, buildTerminalShellSpawnCommand as v, PROCESS_HELPER_TIMEOUT_MS as w, resolveWindowsCommand as x, buildTerminalSpawnCommand as y };
805
+
806
+ //# sourceMappingURL=agent-registry-CMg8LHKY.js.map