@1agents/acp-service 0.10.12 → 0.11.1
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/dist/src/acp-connection.js +33 -0
- package/dist/src/bridge.js +44 -1
- package/dist/src/capacity-queue.d.ts +3 -1
- package/dist/src/capacity-queue.js +4 -0
- package/dist/src/catalog.js +13 -3
- package/package.json +4 -4
- package/skills/acp-service/SKILL.md +1 -1
- package/vendor/dsh/adapter.d.ts +6 -0
- package/vendor/dsh/adapter.js +23 -0
- package/vendor/dsh/index.js +19 -0
- package/vendor/runtime/README.md +36 -11
- package/vendor/runtime/dist/{agent-registry-DxcyXXqb.js → agent-registry-CsdsVpJb.js} +209 -177
- package/vendor/runtime/dist/agent-registry-CsdsVpJb.js.map +1 -0
- package/vendor/runtime/dist/agent-registry.d.ts +0 -2
- package/vendor/runtime/dist/agent-registry.d.ts.map +1 -1
- package/vendor/runtime/dist/agent-registry.js +1 -1
- package/vendor/runtime/dist/{cli-BKmMxgix.js → cli-B5gQOSDl.js} +33 -14
- package/vendor/runtime/dist/cli-B5gQOSDl.js.map +1 -0
- package/vendor/runtime/dist/cli.d.ts +2 -6
- package/vendor/runtime/dist/cli.d.ts.map +1 -1
- package/vendor/runtime/dist/cli.js +189 -164
- package/vendor/runtime/dist/cli.js.map +1 -1
- package/vendor/runtime/dist/{client-C5zneoBs.d.ts → client-D5y4RXME.d.ts} +4 -12
- package/vendor/runtime/dist/client-D5y4RXME.d.ts.map +1 -0
- package/vendor/runtime/dist/docs-site/CLI.html +19 -21
- package/vendor/runtime/dist/docs-site/VISION.html +3 -2
- package/vendor/runtime/dist/docs-site/agents.html +10 -15
- package/vendor/runtime/dist/docs-site/assets/agents/Apache-2.0.txt +202 -0
- package/vendor/runtime/dist/docs-site/assets/agents/LobeHub-MIT.txt +21 -0
- package/vendor/runtime/dist/docs-site/assets/agents/Mux-AGPL-3.0.txt +661 -0
- package/vendor/runtime/dist/docs-site/assets/agents/README.md +41 -0
- package/vendor/runtime/dist/docs-site/assets/agents/ante.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/antigravity.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/claude.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/codex.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/copilot.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/cursor.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/deepseek-harness.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/devin.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/droid.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/fast-agent.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/fx.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/gemini.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/goose.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/grok-build.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/iflow.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/junie.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/kilocode.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/kimi.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/kiro.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/mcode.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/mux.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/octomind.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/openclaw.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/opencode.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/pi.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/pool.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/qoder.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/qwen.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/trae.png +0 -0
- package/vendor/runtime/dist/docs-site/assets/agents/zeroclaw.png +0 -0
- package/vendor/runtime/dist/docs-site/compare.html +8 -7
- package/vendor/runtime/dist/docs-site/config.html +5 -4
- package/vendor/runtime/dist/docs-site/custom-agents.html +13 -13
- package/vendor/runtime/dist/docs-site/exit-codes.html +4 -3
- package/vendor/runtime/dist/docs-site/flows.html +21 -8
- package/vendor/runtime/dist/docs-site/index.html +7 -6
- package/vendor/runtime/dist/docs-site/install.html +7 -6
- package/vendor/runtime/dist/docs-site/llms.txt +6 -6
- package/vendor/runtime/dist/docs-site/output-formats.html +9 -8
- package/vendor/runtime/dist/docs-site/permissions.html +5 -4
- package/vendor/runtime/dist/docs-site/prompting.html +9 -7
- package/vendor/runtime/dist/docs-site/quickstart.html +5 -4
- package/vendor/runtime/dist/docs-site/releasing.html +9 -8
- package/vendor/runtime/dist/docs-site/runtime-environment.html +28 -5
- package/vendor/runtime/dist/docs-site/runtime-process-lifecycle.html +13 -7
- package/vendor/runtime/dist/docs-site/safe-errors.html +3 -2
- package/vendor/runtime/dist/docs-site/session-control.html +7 -6
- package/vendor/runtime/dist/docs-site/session-watch.html +6 -5
- package/vendor/runtime/dist/docs-site/sessions.html +13 -10
- package/vendor/runtime/dist/docs-site/shared-sessions.html +7 -4
- package/vendor/runtime/dist/{flows-VrII9VKZ.js → flows-CDj5YcTh.js} +136 -68
- package/vendor/runtime/dist/flows-CDj5YcTh.js.map +1 -0
- package/vendor/runtime/dist/flows.d.ts +28 -19
- package/vendor/runtime/dist/flows.d.ts.map +1 -1
- package/vendor/runtime/dist/flows.js +1 -1
- package/vendor/runtime/dist/{invocation-options-DHMZ5Rrb.js → input-file-BsfVGZgn.js} +30 -15
- package/vendor/runtime/dist/input-file-BsfVGZgn.js.map +1 -0
- package/vendor/runtime/dist/{ipc-CNNM5DP_.js → ipc-DfqJsbk6.js} +114 -146
- package/vendor/runtime/dist/ipc-DfqJsbk6.js.map +1 -0
- package/vendor/runtime/dist/{output-DtzXtiBc.js → output-DOIF4iFc.js} +20 -47
- package/vendor/runtime/dist/output-DOIF4iFc.js.map +1 -0
- package/vendor/runtime/dist/{queue-owner-runtime-ehuh3SQU.js → queue-owner-runtime-DHBQbjXo.js} +394 -258
- package/vendor/runtime/dist/queue-owner-runtime-DHBQbjXo.js.map +1 -0
- package/vendor/runtime/dist/runtime.d.ts +37 -36
- package/vendor/runtime/dist/runtime.d.ts.map +1 -1
- package/vendor/runtime/dist/runtime.js +117 -172
- package/vendor/runtime/dist/runtime.js.map +1 -1
- package/vendor/runtime/dist/{session-options-NjpFwf-c.d.ts → session-options-Ci4aw1oD.d.ts} +13 -16
- package/vendor/runtime/dist/session-options-Ci4aw1oD.d.ts.map +1 -0
- package/vendor/runtime/dist/{session-watch-CbKfGRkZ.js → session-watch-DRwFHcWw.js} +5 -6
- package/vendor/runtime/dist/{session-watch-CbKfGRkZ.js.map → session-watch-DRwFHcWw.js.map} +1 -1
- package/vendor/runtime/dist/{watch-BGt4kcE6.js → watch-CUDGkljG.js} +3 -4
- package/vendor/runtime/dist/{watch-BGt4kcE6.js.map → watch-CUDGkljG.js.map} +1 -1
- package/vendor/runtime/package.json +3 -3
- package/vendor/runtime/skills/acpx/SKILL.md +42 -11
- package/vendor/runtime/dist/agent-registry-DxcyXXqb.js.map +0 -1
- package/vendor/runtime/dist/cli-BKmMxgix.js.map +0 -1
- package/vendor/runtime/dist/client-C5zneoBs.d.ts.map +0 -1
- package/vendor/runtime/dist/flows-VrII9VKZ.js.map +0 -1
- package/vendor/runtime/dist/invocation-options-DHMZ5Rrb.js.map +0 -1
- package/vendor/runtime/dist/ipc-CNNM5DP_.js.map +0 -1
- package/vendor/runtime/dist/output-DtzXtiBc.js.map +0 -1
- package/vendor/runtime/dist/queue-owner-runtime-ehuh3SQU.js.map +0 -1
- package/vendor/runtime/dist/session-options-NjpFwf-c.d.ts.map +0 -1
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { A as findGitRepositoryRoot, B as writeSessionRecord, Ct as isProcessAlive, Dt as normalizeOutputError, Ft as OUTPUT_FORMATS, H as parseSessionRecord, I as normalizeName, K as normalizeAgentSessionId, M as findSessionByDirectoryWalk, Nt as EXIT_CODES, P as listSessions, R as readSessionRecord, S as parsePromptSource, St as _usingCtx, U as canonicalAgentCommand, Ut as AgentSpawnError, Vt as AcpxOperationalError, W as serializeSessionRecordForDisk, _t as sessionEventActivePath, an as __exportAll, bt as writePrivateFile, ft as boundedEventMaxSegments, j as findSession, k as absolutePath, l as probeQueueOwnerHealth, pt as defaultSessionEventLog, vt as sessionEventLockPath, w as textPrompt, wt as exitCodeForOutputErrorCode, x as mergePromptSourceWithText, y as PromptInputValidationError } from "./ipc-DfqJsbk6.js";
|
|
3
|
+
import { C as renderArgvIdentity, i as DEFAULT_AGENT_NAME, l as normalizeAgentName$1, s as listBuiltInAgents } from "./agent-registry-CsdsVpJb.js";
|
|
4
|
+
import { ct as listSessionEvents, d as flushPerfMetricsCapture, dt as TimeoutError, f as installPerfMetricsCapture, i as runOnce, lt as isLegacyZedCodexAcpInvocation, mt as withTimeout, n as runSessionQueueOwner, ot as acquireSessionImport, s as DISCARD_OUTPUT_FORMATTER, st as acquireSessionScope, tt as getAcpxVersion, u as buildQueueOwnerArgOverride, ut as InterruptedError } from "./queue-owner-runtime-DHBQbjXo.js";
|
|
5
|
+
import { C as resolveOutputPolicy, D as resolveSessionsListFlags, E as resolveSessionNameFromFlags, S as resolveGlobalFlags, T as resolvePromptFlags, _ as parsePruneBeforeDate, a as addExecConfigOption, b as parseTtlSeconds, c as addSessionNameOption, d as parseAllowedTools, f as parseDaysOlderThan, g as parseOutputFormat$1, h as parseNonEmptyValue, i as sessionOptionsFromGlobalFlags, l as addSessionOption, m as parseMaxTurns, n as resolvePermissionPolicyFromFlags, o as addGlobalFlags, p as parseHistoryLimit, r as sessionConnectionOptions, s as addPromptInputOption, t as readCliInputFile, v as parseSessionName, w as resolvePermissionMode, x as resolveAgentInvocation, y as parseTimeoutSeconds } from "./input-file-BsfVGZgn.js";
|
|
6
|
+
import { n as getTextErrorRemediationHints, o as toTimerMilliseconds, t as createOutputFormatter } from "./output-DOIF4iFc.js";
|
|
7
7
|
import { realpathSync } from "node:fs";
|
|
8
8
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { Command, CommanderError, InvalidArgumentError, Option } from "commander";
|
|
11
11
|
import fs$1 from "node:fs/promises";
|
|
12
12
|
import os from "node:os";
|
|
13
|
+
import { isDeepStrictEqual } from "node:util";
|
|
13
14
|
import { ZodError, z } from "zod";
|
|
14
15
|
import { createHash, randomUUID } from "node:crypto";
|
|
15
16
|
import { text } from "node:stream/consumers";
|
|
16
17
|
import { performance } from "node:perf_hooks";
|
|
17
|
-
|
|
18
|
+
// src/cli-public.ts
|
|
18
19
|
function configurePublicCli(options) {
|
|
19
20
|
const builtInAgents = options.listBuiltInAgents(options.config.agents);
|
|
20
21
|
for (const agentName of builtInAgents) options.registerAgentCommand(options.program, agentName, options.config);
|
|
@@ -54,8 +55,7 @@ Examples:
|
|
|
54
55
|
acpx claude "refactor auth"
|
|
55
56
|
acpx --agent ./my-custom-server "do something"`);
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
-
//#region src/session/export.ts
|
|
58
|
+
// src/session/export.ts
|
|
59
59
|
var SessionExportError = class extends AcpxOperationalError {
|
|
60
60
|
code;
|
|
61
61
|
exitCode = 2;
|
|
@@ -74,26 +74,17 @@ function sessionLookupError(message, code) {
|
|
|
74
74
|
async function loadSessionRecord(sessionLookup) {
|
|
75
75
|
const cwd = path.resolve(sessionLookup.cwd ?? process.cwd());
|
|
76
76
|
const name = normalizeName(sessionLookup.name);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (session.agentCommand !== sessionLookup.agentCommand || session.cwd !== cwd) return false;
|
|
86
|
-
if (name == null) return session.name == null;
|
|
87
|
-
return session.name === name;
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
const matches = (await listSessions()).filter((session) => {
|
|
91
|
-
if (session.cwd !== cwd) return false;
|
|
77
|
+
const active = await findSession({
|
|
78
|
+
agentCommand: sessionLookup.agentCommand,
|
|
79
|
+
cwd,
|
|
80
|
+
name
|
|
81
|
+
});
|
|
82
|
+
if (active) return active;
|
|
83
|
+
return (await listSessions()).find((session) => {
|
|
84
|
+
if (session.agentCommand !== sessionLookup.agentCommand || session.cwd !== cwd) return false;
|
|
92
85
|
if (name == null) return session.name == null;
|
|
93
86
|
return session.name === name;
|
|
94
87
|
});
|
|
95
|
-
if (matches.length > 1) throw sessionLookupError("multiple sessions match export lookup", "ambiguous-session");
|
|
96
|
-
return matches[0];
|
|
97
88
|
}
|
|
98
89
|
function parseEventLockPayload(raw) {
|
|
99
90
|
try {
|
|
@@ -118,6 +109,11 @@ async function isSessionActive(record) {
|
|
|
118
109
|
if (record.closed) return false;
|
|
119
110
|
return isProcessAlive(record.pid) || await hasLiveEventLock(record.acpxRecordId);
|
|
120
111
|
}
|
|
112
|
+
async function assertExportCheckpointUnchanged(record) {
|
|
113
|
+
const active = await isSessionActive(record);
|
|
114
|
+
const current = await readSessionRecord(record.acpxRecordId);
|
|
115
|
+
if (active || !isDeepStrictEqual(current, record)) throw sessionLookupError("session changed while exporting; close it first with `acpx sessions close` and retry", "session-locked");
|
|
116
|
+
}
|
|
121
117
|
function cwdRelativeToHome(cwd, home) {
|
|
122
118
|
const relative = path.relative(home, cwd);
|
|
123
119
|
if (relative.length === 0) return ".";
|
|
@@ -156,6 +152,7 @@ async function exportSession(sessionLookup, outputPath) {
|
|
|
156
152
|
},
|
|
157
153
|
history: await listSessionEvents(record.acpxRecordId, record.eventLog.max_segments)
|
|
158
154
|
};
|
|
155
|
+
await assertExportCheckpointUnchanged(record);
|
|
159
156
|
const target = await resolveExportTarget(outputPath);
|
|
160
157
|
await writePrivateFile(target, `${JSON.stringify(exported, null, 2)}\n`, { privateDirectory: false });
|
|
161
158
|
}
|
|
@@ -177,8 +174,7 @@ function normalizeAgentName(agentName) {
|
|
|
177
174
|
if (!normalized || normalized.length === 0) return;
|
|
178
175
|
return normalized === "factory-droid" || normalized === "factorydroid" ? "droid" : normalized;
|
|
179
176
|
}
|
|
180
|
-
|
|
181
|
-
//#region src/session/import.ts
|
|
177
|
+
// src/session/import.ts
|
|
182
178
|
const SUPPORTED_FORMAT_VERSION = 1;
|
|
183
179
|
const exportedSessionSchema = z.object({
|
|
184
180
|
format_version: z.literal(SUPPORTED_FORMAT_VERSION),
|
|
@@ -268,6 +264,8 @@ function assertExpectedAgentCommand(parsed, sourceRecord, options) {
|
|
|
268
264
|
stateCommand: sourceRecord.agentCommand,
|
|
269
265
|
expectedAgentCommand
|
|
270
266
|
})) {
|
|
267
|
+
if (options.expectedAgentArgv) sourceRecord.agentArgv = [...options.expectedAgentArgv];
|
|
268
|
+
else if (sourceRecord.agentCommand !== expectedAgentCommand) sourceRecord.agentArgv = void 0;
|
|
271
269
|
sourceRecord.agentCommand = expectedAgentCommand;
|
|
272
270
|
return;
|
|
273
271
|
}
|
|
@@ -283,15 +281,15 @@ function normalizeAgentIdentity(agentName) {
|
|
|
283
281
|
return normalized === "factory-droid" || normalized === "factorydroid" ? "droid" : normalized;
|
|
284
282
|
}
|
|
285
283
|
function agentCommandMatchesExpected(archivedCommand, expectedAgentCommand, expectedAgentName) {
|
|
286
|
-
if (archivedCommand === expectedAgentCommand) return true;
|
|
284
|
+
if (archivedCommand === expectedAgentCommand || canonicalAgentCommand(archivedCommand) === expectedAgentCommand) return true;
|
|
287
285
|
return expectedAgentName ? commandLooksLikeBuiltInAgent(archivedCommand, expectedAgentName) : false;
|
|
288
286
|
}
|
|
289
287
|
function commandLooksLikeBuiltInAgent(command, agentName) {
|
|
290
288
|
const normalized = command.trim();
|
|
291
289
|
switch (agentName) {
|
|
292
|
-
case "pi": return /(?:^|\s)pi-acp(?:@|\s|$)/.test(normalized);
|
|
293
|
-
case "codex": return /(?:^|\s)@agentclientprotocol\/codex-acp(?:@|\s|$)/.test(normalized);
|
|
294
|
-
case "claude": return /(?:^|\s)@agentclientprotocol\/claude-agent-acp(?:@|\s|$)/.test(normalized);
|
|
290
|
+
case "pi": return /(?:^|\s|=)pi-acp(?:@|\s|$)/.test(normalized);
|
|
291
|
+
case "codex": return /(?:^|\s|=)@agentclientprotocol\/codex-acp(?:@|\s|$)/.test(normalized);
|
|
292
|
+
case "claude": return /(?:^|\s|=)@agentclientprotocol\/claude-agent-acp(?:@|\s|$)/.test(normalized);
|
|
295
293
|
default: return false;
|
|
296
294
|
}
|
|
297
295
|
}
|
|
@@ -375,15 +373,13 @@ async function importSession(archivePath, options = {}) {
|
|
|
375
373
|
await _usingCtx$1.d();
|
|
376
374
|
}
|
|
377
375
|
}
|
|
378
|
-
|
|
379
|
-
//#region src/cli/output/json-output.ts
|
|
376
|
+
// src/cli/output/json-output.ts
|
|
380
377
|
function emitJsonResult(format, payload) {
|
|
381
378
|
if (format !== "json") return false;
|
|
382
379
|
process.stdout.write(`${JSON.stringify(payload)}\n`);
|
|
383
380
|
return true;
|
|
384
381
|
}
|
|
385
|
-
|
|
386
|
-
//#region src/cli/prompt-input.ts
|
|
382
|
+
// src/cli/prompt-input.ts
|
|
387
383
|
async function readPromptInput(filePath, promptText, cwd, positionalLabel = "argument") {
|
|
388
384
|
try {
|
|
389
385
|
if (filePath) return await readPromptFile(filePath, promptText, cwd);
|
|
@@ -399,13 +395,65 @@ async function readPromptInput(filePath, promptText, cwd, positionalLabel = "arg
|
|
|
399
395
|
}
|
|
400
396
|
}
|
|
401
397
|
async function readPromptFile(filePath, promptText, cwd) {
|
|
402
|
-
const source = filePath === "-" ? await text(process.stdin) : await
|
|
398
|
+
const source = filePath === "-" ? await text(process.stdin) : await readCliInputFile(path.resolve(cwd, filePath), "Prompt file");
|
|
403
399
|
const prompt = mergePromptSourceWithText(source, promptText);
|
|
404
400
|
if (prompt.length === 0) throw new InvalidArgumentError("Prompt from --file is empty");
|
|
405
401
|
return prompt;
|
|
406
402
|
}
|
|
407
|
-
|
|
408
|
-
|
|
403
|
+
// src/cli/prompt-interruption.ts
|
|
404
|
+
const INTERRUPT_CANCEL_WAIT_MS = 2500;
|
|
405
|
+
/** CLI interruption cancels its own request; ordinary observer detach does not. */
|
|
406
|
+
async function withPromptInterrupts(submit, cancel) {
|
|
407
|
+
const requestId = randomUUID();
|
|
408
|
+
const observer = new AbortController();
|
|
409
|
+
const interrupted = new InterruptedError();
|
|
410
|
+
let accepted = false;
|
|
411
|
+
let releaseAdmission;
|
|
412
|
+
const admission = new Promise((resolve) => {
|
|
413
|
+
releaseAdmission = resolve;
|
|
414
|
+
});
|
|
415
|
+
let cancellation;
|
|
416
|
+
const onInterrupt = () => {
|
|
417
|
+
cancellation ??= withTimeout(admission.then(async () => {
|
|
418
|
+
if (accepted && !observer.signal.aborted) await cancel(requestId);
|
|
419
|
+
}), INTERRUPT_CANCEL_WAIT_MS).catch((error) => {
|
|
420
|
+
if (error instanceof TimeoutError) throw new Error("Timed out cancelling foreground prompt; request outcome is unknown. Inspect the same session with status, sessions history, or sessions watch before resubmitting.", { cause: error });
|
|
421
|
+
throw error;
|
|
422
|
+
}).finally(() => observer.abort(interrupted));
|
|
423
|
+
cancellation.catch(() => {});
|
|
424
|
+
};
|
|
425
|
+
const signals = [
|
|
426
|
+
"SIGINT",
|
|
427
|
+
"SIGTERM",
|
|
428
|
+
"SIGHUP"
|
|
429
|
+
];
|
|
430
|
+
for (const signal of signals) process.on(signal, onInterrupt);
|
|
431
|
+
try {
|
|
432
|
+
const result = await submit({
|
|
433
|
+
requestId,
|
|
434
|
+
signal: observer.signal,
|
|
435
|
+
onQueueAccepted: () => {
|
|
436
|
+
accepted = true;
|
|
437
|
+
releaseAdmission();
|
|
438
|
+
}
|
|
439
|
+
}).finally(releaseAdmission);
|
|
440
|
+
if (cancellation) {
|
|
441
|
+
await cancellation;
|
|
442
|
+
throw interrupted;
|
|
443
|
+
}
|
|
444
|
+
return result;
|
|
445
|
+
} catch (error) {
|
|
446
|
+
if (cancellation && (accepted || error === interrupted)) {
|
|
447
|
+
await cancellation;
|
|
448
|
+
throw interrupted;
|
|
449
|
+
}
|
|
450
|
+
throw error;
|
|
451
|
+
} finally {
|
|
452
|
+
releaseAdmission();
|
|
453
|
+
for (const signal of signals) process.off(signal, onInterrupt);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
// src/cli/command-handlers.ts
|
|
409
457
|
var NoSessionError = class extends Error {
|
|
410
458
|
constructor(message) {
|
|
411
459
|
super(message);
|
|
@@ -416,11 +464,11 @@ let sessionModulePromise;
|
|
|
416
464
|
let outputModulePromise;
|
|
417
465
|
let outputRenderModulePromise;
|
|
418
466
|
function loadSessionModule() {
|
|
419
|
-
sessionModulePromise ??= import("./output-
|
|
467
|
+
sessionModulePromise ??= import("./output-DOIF4iFc.js").then((n) => n.s);
|
|
420
468
|
return sessionModulePromise;
|
|
421
469
|
}
|
|
422
470
|
function loadOutputModule() {
|
|
423
|
-
outputModulePromise ??= import("./output-
|
|
471
|
+
outputModulePromise ??= import("./output-DOIF4iFc.js").then((n) => n.r);
|
|
424
472
|
return outputModulePromise;
|
|
425
473
|
}
|
|
426
474
|
function loadOutputRenderModule() {
|
|
@@ -515,7 +563,7 @@ async function handlePrompt(explicitAgentName, promptParts, flags, command, conf
|
|
|
515
563
|
suppressReads: outputPolicy.suppressReads
|
|
516
564
|
});
|
|
517
565
|
await printPromptSessionBanner(record, agent.cwd, outputPolicy.format, outputPolicy.jsonStrict);
|
|
518
|
-
const
|
|
566
|
+
const send = (submission) => sendSession({
|
|
519
567
|
...sessionConnectionOptions(globalFlags, config),
|
|
520
568
|
sessionId: record.acpxRecordId,
|
|
521
569
|
prompt,
|
|
@@ -530,8 +578,17 @@ async function handlePrompt(explicitAgentName, promptParts, flags, command, conf
|
|
|
530
578
|
maxQueueDepth: config.queueMaxDepth,
|
|
531
579
|
promptRetries: globalFlags.promptRetries,
|
|
532
580
|
waitForCompletion: promptFlags.wait,
|
|
533
|
-
sessionOptions: sessionOptionsFromGlobalFlags(globalFlags)
|
|
581
|
+
sessionOptions: sessionOptionsFromGlobalFlags(globalFlags),
|
|
582
|
+
...submission
|
|
534
583
|
});
|
|
584
|
+
const result = promptFlags.wait ? await withPromptInterrupts(send, async (targetRequestId) => {
|
|
585
|
+
const { tryCancelOnRunningOwner } = await import("./ipc-DfqJsbk6.js").then((n) => n.t);
|
|
586
|
+
return await tryCancelOnRunningOwner({
|
|
587
|
+
sessionId: record.acpxRecordId,
|
|
588
|
+
targetRequestId,
|
|
589
|
+
verbose: globalFlags.verbose
|
|
590
|
+
});
|
|
591
|
+
}) : await send(void 0);
|
|
535
592
|
if ("queued" in result) {
|
|
536
593
|
printQueuedPromptByFormat(result, outputPolicy.format);
|
|
537
594
|
return;
|
|
@@ -902,7 +959,7 @@ async function handleSessionsWatch(explicitAgentName, flags, command, config) {
|
|
|
902
959
|
includeClosed: true
|
|
903
960
|
});
|
|
904
961
|
if (!record) throw new Error(missingScopedSessionMessage(agent, sessionName));
|
|
905
|
-
const { runSessionWatch } = await import("./session-watch-
|
|
962
|
+
const { runSessionWatch } = await import("./session-watch-DRwFHcWw.js");
|
|
906
963
|
await runSessionWatch(record, {
|
|
907
964
|
cursor: flags.cursor,
|
|
908
965
|
policy: resolveRequestedOutputPolicy(globalFlags)
|
|
@@ -935,7 +992,8 @@ async function handleSessionsImport(explicitAgentName, archivePath, flags, comma
|
|
|
935
992
|
name: flags.name,
|
|
936
993
|
newCwd: flags.destinationCwd ? path.resolve(globalFlags.cwd, flags.destinationCwd) : void 0,
|
|
937
994
|
expectedAgentName: globalFlags.agent ? void 0 : agent.agentName,
|
|
938
|
-
expectedAgentCommand: agent.agentCommand
|
|
995
|
+
expectedAgentCommand: agent.agentCommand,
|
|
996
|
+
expectedAgentArgv: agent.agentArgv
|
|
939
997
|
});
|
|
940
998
|
if (emitJsonResult(globalFlags.format, {
|
|
941
999
|
action: "session_imported",
|
|
@@ -961,8 +1019,7 @@ async function handleSessionsPrune(explicitAgentName, flags, command, config) {
|
|
|
961
1019
|
dryRun: flags.dryRun
|
|
962
1020
|
}), globalFlags.format);
|
|
963
1021
|
}
|
|
964
|
-
|
|
965
|
-
//#region src/cli/compare-args.ts
|
|
1022
|
+
// src/cli/compare-args.ts
|
|
966
1023
|
function addCompareOptions(command) {
|
|
967
1024
|
return command.option("--cwd <dir>", "Target workspace").option("--approve-all", "Auto-approve all permission requests").option("--approve-reads", "Auto-approve read/search requests and prompt for writes").option("--deny-all", "Deny all permission requests").option("--timeout <seconds>", "Per-agent timeout in seconds", parseTimeoutSeconds).option("--format <fmt>", "Output format: text, json, quiet", parseOutputFormat$1).option("--json", "Alias for --format json").option("-f, --file <path>", "Read prompt text from file path (use - for stdin)", (value) => parseNonEmptyValue("Prompt file", value)).option("--prompt-file <path>", "Alias for --file", (value) => parseNonEmptyValue("Prompt file", value));
|
|
968
1025
|
}
|
|
@@ -992,8 +1049,7 @@ function scanCompareArgs(argv) {
|
|
|
992
1049
|
...output
|
|
993
1050
|
};
|
|
994
1051
|
}
|
|
995
|
-
|
|
996
|
-
//#region src/cli/compare-command.ts
|
|
1052
|
+
// src/cli/compare-command.ts
|
|
997
1053
|
const DEFAULT_COMPARE_TIMEOUT_MS = 3e5;
|
|
998
1054
|
const FINAL_MESSAGE_PREVIEW_CHARS = 200;
|
|
999
1055
|
function asRecord$2(value) {
|
|
@@ -1054,46 +1110,15 @@ function captureSessionUpdate(notification, capture) {
|
|
|
1054
1110
|
}
|
|
1055
1111
|
if (update.sessionUpdate === "usage_update") captureUsage(update, capture);
|
|
1056
1112
|
}
|
|
1057
|
-
function
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
function buildSuccessRow(agentName, result, capture, startedAt) {
|
|
1061
|
-
const permissionStats = result.permissionStats;
|
|
1062
|
-
return {
|
|
1063
|
-
agent: agentName,
|
|
1064
|
-
status: result.stopReason === "cancelled" ? "cancelled" : rowStatusFromPermissionStats(permissionStats),
|
|
1065
|
-
stop_reason: result.stopReason,
|
|
1066
|
-
wall_ms: Math.round(performance.now() - startedAt),
|
|
1067
|
-
input_tokens: capture.usage.input_tokens ?? null,
|
|
1068
|
-
output_tokens: capture.usage.output_tokens ?? null,
|
|
1069
|
-
total_tokens: capture.usage.total_tokens ?? null,
|
|
1070
|
-
final_message: truncate(collapseWhitespace(capture.finalMessage), FINAL_MESSAGE_PREVIEW_CHARS),
|
|
1071
|
-
error: null,
|
|
1072
|
-
permission_requests: permissionStats.requested,
|
|
1073
|
-
permission_denied: permissionStats.denied + permissionStats.cancelled,
|
|
1074
|
-
...result._meta === void 0 ? {} : { _meta: result._meta }
|
|
1075
|
-
};
|
|
1113
|
+
function rowStatusFromResult(result) {
|
|
1114
|
+
if (result.stopReason === "cancelled") return "cancelled";
|
|
1115
|
+
return result.permissionStats.denied + result.permissionStats.cancelled > 0 ? "permission_denied" : "ok";
|
|
1076
1116
|
}
|
|
1077
1117
|
function rowStatusFromError(error) {
|
|
1078
1118
|
if (error instanceof TimeoutError) return "cancelled";
|
|
1079
1119
|
const { code } = normalizeOutputError(error);
|
|
1080
1120
|
return code === "PERMISSION_PROMPT_UNAVAILABLE" || code === "PERMISSION_DENIED" ? "permission_denied" : "error";
|
|
1081
1121
|
}
|
|
1082
|
-
function buildErrorRow(agentName, caught, capture, startedAt) {
|
|
1083
|
-
return {
|
|
1084
|
-
agent: agentName,
|
|
1085
|
-
status: rowStatusFromError(caught),
|
|
1086
|
-
stop_reason: null,
|
|
1087
|
-
wall_ms: Math.round(performance.now() - startedAt),
|
|
1088
|
-
input_tokens: capture.usage.input_tokens ?? null,
|
|
1089
|
-
output_tokens: capture.usage.output_tokens ?? null,
|
|
1090
|
-
total_tokens: capture.usage.total_tokens ?? null,
|
|
1091
|
-
final_message: truncate(collapseWhitespace(capture.finalMessage), FINAL_MESSAGE_PREVIEW_CHARS),
|
|
1092
|
-
error: truncate(collapseWhitespace(caught instanceof Error ? caught.message : String(caught)), FINAL_MESSAGE_PREVIEW_CHARS),
|
|
1093
|
-
permission_requests: capture.permissionStats.requested,
|
|
1094
|
-
permission_denied: capture.permissionStats.denied + capture.permissionStats.cancelled
|
|
1095
|
-
};
|
|
1096
|
-
}
|
|
1097
1122
|
async function runAgentForCompare(params) {
|
|
1098
1123
|
const capture = {
|
|
1099
1124
|
finalMessage: "",
|
|
@@ -1106,6 +1131,11 @@ async function runAgentForCompare(params) {
|
|
|
1106
1131
|
}
|
|
1107
1132
|
};
|
|
1108
1133
|
const t0 = performance.now();
|
|
1134
|
+
let status;
|
|
1135
|
+
let stopReason = null;
|
|
1136
|
+
let error = null;
|
|
1137
|
+
let permissionStats;
|
|
1138
|
+
let meta;
|
|
1109
1139
|
try {
|
|
1110
1140
|
const agent = resolveAgentInvocation(params.agentName, params.globalFlags, params.config);
|
|
1111
1141
|
const result = await runOnce({
|
|
@@ -1126,10 +1156,29 @@ async function runAgentForCompare(params) {
|
|
|
1126
1156
|
capture.permissionStats = stats;
|
|
1127
1157
|
}
|
|
1128
1158
|
});
|
|
1129
|
-
|
|
1159
|
+
permissionStats = result.permissionStats;
|
|
1160
|
+
status = rowStatusFromResult(result);
|
|
1161
|
+
stopReason = result.stopReason;
|
|
1162
|
+
meta = result._meta;
|
|
1130
1163
|
} catch (caught) {
|
|
1131
|
-
|
|
1164
|
+
permissionStats = capture.permissionStats;
|
|
1165
|
+
status = rowStatusFromError(caught);
|
|
1166
|
+
error = truncate(collapseWhitespace(caught instanceof Error ? caught.message : String(caught)), FINAL_MESSAGE_PREVIEW_CHARS);
|
|
1132
1167
|
}
|
|
1168
|
+
return {
|
|
1169
|
+
agent: params.agentName,
|
|
1170
|
+
status,
|
|
1171
|
+
stop_reason: stopReason,
|
|
1172
|
+
wall_ms: Math.round(performance.now() - t0),
|
|
1173
|
+
input_tokens: capture.usage.input_tokens ?? null,
|
|
1174
|
+
output_tokens: capture.usage.output_tokens ?? null,
|
|
1175
|
+
total_tokens: capture.usage.total_tokens ?? null,
|
|
1176
|
+
final_message: truncate(collapseWhitespace(capture.finalMessage), FINAL_MESSAGE_PREVIEW_CHARS),
|
|
1177
|
+
error,
|
|
1178
|
+
permission_requests: permissionStats.requested,
|
|
1179
|
+
permission_denied: permissionStats.denied + permissionStats.cancelled,
|
|
1180
|
+
...meta === void 0 ? {} : { _meta: meta }
|
|
1181
|
+
};
|
|
1133
1182
|
}
|
|
1134
1183
|
function formatCell(value) {
|
|
1135
1184
|
if (value == null || value === "") return "-";
|
|
@@ -1252,8 +1301,7 @@ function registerCompareCommand(program, config) {
|
|
|
1252
1301
|
else updateCompareExitCode(rows);
|
|
1253
1302
|
});
|
|
1254
1303
|
}
|
|
1255
|
-
|
|
1256
|
-
//#region src/mcp-servers.ts
|
|
1304
|
+
// src/mcp-servers.ts
|
|
1257
1305
|
function asRecord$1(value) {
|
|
1258
1306
|
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
1259
1307
|
return value;
|
|
@@ -1337,8 +1385,7 @@ function parseOptionalMcpServers(value, sourcePath, fieldName = "mcpServers") {
|
|
|
1337
1385
|
if (value === void 0) return;
|
|
1338
1386
|
return parseMcpServers(value, sourcePath, fieldName);
|
|
1339
1387
|
}
|
|
1340
|
-
|
|
1341
|
-
//#region src/cli/config.ts
|
|
1388
|
+
// src/cli/config.ts
|
|
1342
1389
|
const DEFAULT_TTL_MS = 3e5;
|
|
1343
1390
|
const DEFAULT_PERMISSION_MODE = "approve-reads";
|
|
1344
1391
|
const DEFAULT_NON_INTERACTIVE_PERMISSION_POLICY = "deny";
|
|
@@ -1486,35 +1533,27 @@ async function readConfigFile(filePath) {
|
|
|
1486
1533
|
throw new Error(`Invalid JSON in ${filePath}: ${reason}`, { cause: error });
|
|
1487
1534
|
}
|
|
1488
1535
|
if (!isObject(parsed)) throw new Error(`Invalid config in ${filePath}: expected top-level JSON object`);
|
|
1489
|
-
return
|
|
1490
|
-
config: parsed,
|
|
1491
|
-
exists: true
|
|
1492
|
-
};
|
|
1536
|
+
return parsed;
|
|
1493
1537
|
} catch (error) {
|
|
1494
|
-
if (error.code === "ENOENT") return
|
|
1538
|
+
if (error.code === "ENOENT") return;
|
|
1495
1539
|
throw error;
|
|
1496
1540
|
}
|
|
1497
1541
|
}
|
|
1498
|
-
async function loadExplicitMcpConfig(
|
|
1499
|
-
if (!configuredPath) return
|
|
1500
|
-
const
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
return {
|
|
1504
|
-
path: resolvedPath,
|
|
1505
|
-
config: result.config
|
|
1506
|
-
};
|
|
1542
|
+
async function loadExplicitMcpConfig(configuredPath) {
|
|
1543
|
+
if (!configuredPath) return;
|
|
1544
|
+
const config = await readConfigFile(configuredPath);
|
|
1545
|
+
if (config === void 0) throw new Error(`MCP config file not found: ${configuredPath}`);
|
|
1546
|
+
return config;
|
|
1507
1547
|
}
|
|
1508
1548
|
async function loadResolvedConfig(cwd, options = {}) {
|
|
1509
1549
|
const globalPath = defaultGlobalConfigPath();
|
|
1510
1550
|
const projectPath = projectConfigPath(cwd);
|
|
1511
|
-
const
|
|
1551
|
+
const mcpConfigPath = options.mcpConfigPath ? path.resolve(cwd, options.mcpConfigPath) : void 0;
|
|
1552
|
+
const [globalConfig, projectConfig, mcpConfig] = await Promise.all([
|
|
1512
1553
|
readConfigFile(globalPath),
|
|
1513
1554
|
readConfigFile(projectPath),
|
|
1514
|
-
loadExplicitMcpConfig(
|
|
1555
|
+
loadExplicitMcpConfig(mcpConfigPath)
|
|
1515
1556
|
]);
|
|
1516
|
-
const globalConfig = globalResult.config;
|
|
1517
|
-
const projectConfig = projectResult.config;
|
|
1518
1557
|
function resolveScalar(key, parse, fallback) {
|
|
1519
1558
|
return parse(projectConfig?.[key], projectPath) ?? parse(globalConfig?.[key], globalPath) ?? fallback;
|
|
1520
1559
|
}
|
|
@@ -1536,7 +1575,7 @@ async function loadResolvedConfig(cwd, options = {}) {
|
|
|
1536
1575
|
...parseAuth(globalConfig?.auth, globalPath),
|
|
1537
1576
|
...parseAuth(projectConfig?.auth, projectPath)
|
|
1538
1577
|
};
|
|
1539
|
-
const mcpServers = resolveMcpServers(projectConfig, projectPath, globalConfig, globalPath,
|
|
1578
|
+
const mcpServers = resolveMcpServers(projectConfig, projectPath, globalConfig, globalPath, mcpConfig, mcpConfigPath);
|
|
1540
1579
|
const disableExec = resolveScalar("disableExec", parseDisableExec, DEFAULT_DISABLE_EXEC);
|
|
1541
1580
|
return {
|
|
1542
1581
|
...scalar,
|
|
@@ -1546,10 +1585,10 @@ async function loadResolvedConfig(cwd, options = {}) {
|
|
|
1546
1585
|
mcpServers,
|
|
1547
1586
|
globalPath,
|
|
1548
1587
|
projectPath,
|
|
1549
|
-
mcpConfigPath
|
|
1550
|
-
mcpConfigFingerprint:
|
|
1551
|
-
hasGlobalConfig:
|
|
1552
|
-
hasProjectConfig:
|
|
1588
|
+
mcpConfigPath,
|
|
1589
|
+
mcpConfigFingerprint: mcpConfigPath ? createHash("sha256").update(JSON.stringify(mcpServers)).digest("hex") : void 0,
|
|
1590
|
+
hasGlobalConfig: globalConfig !== void 0,
|
|
1591
|
+
hasProjectConfig: projectConfig !== void 0
|
|
1553
1592
|
};
|
|
1554
1593
|
}
|
|
1555
1594
|
function hasConfigKey(config, key) {
|
|
@@ -1624,8 +1663,7 @@ async function initGlobalConfigFile() {
|
|
|
1624
1663
|
created: true
|
|
1625
1664
|
};
|
|
1626
1665
|
}
|
|
1627
|
-
|
|
1628
|
-
//#region src/cli/config-command.ts
|
|
1666
|
+
// src/cli/config-command.ts
|
|
1629
1667
|
async function handleConfigShow(command, config) {
|
|
1630
1668
|
const globalFlags = resolveGlobalFlags(command, config);
|
|
1631
1669
|
const payload = {
|
|
@@ -1678,8 +1716,7 @@ function registerConfigCommand(program, config) {
|
|
|
1678
1716
|
await handleConfigShow(this, config);
|
|
1679
1717
|
});
|
|
1680
1718
|
}
|
|
1681
|
-
|
|
1682
|
-
//#region src/cli/output/render.ts
|
|
1719
|
+
// src/cli/output/render.ts
|
|
1683
1720
|
var render_exports = /* @__PURE__ */ __exportAll({
|
|
1684
1721
|
agentSessionIdPayload: () => agentSessionIdPayload,
|
|
1685
1722
|
classifySessionConnectionStatus: () => classifySessionConnectionStatus,
|
|
@@ -1878,8 +1915,7 @@ function agentSessionIdPayload(agentSessionId) {
|
|
|
1878
1915
|
if (!normalized) return {};
|
|
1879
1916
|
return { agentSessionId: normalized };
|
|
1880
1917
|
}
|
|
1881
|
-
|
|
1882
|
-
//#region src/cli/status-command.ts
|
|
1918
|
+
// src/cli/status-command.ts
|
|
1883
1919
|
function formatUptime(startedAt) {
|
|
1884
1920
|
if (!startedAt) return;
|
|
1885
1921
|
const startedMs = Date.parse(startedAt);
|
|
@@ -1942,9 +1978,9 @@ async function printSessionStatus(record, format) {
|
|
|
1942
1978
|
const health = await probeQueueOwnerHealth(record.acpxRecordId);
|
|
1943
1979
|
const statusState = resolveStatusState(record, health);
|
|
1944
1980
|
const payload = createStatusPayload(record, health, statusState);
|
|
1945
|
-
const running =
|
|
1946
|
-
const dead =
|
|
1947
|
-
if (
|
|
1981
|
+
const running = statusState === "running";
|
|
1982
|
+
const dead = statusState === "dead";
|
|
1983
|
+
if (emitJsonResult(format, statusJsonPayload(record, payload, statusState, running, dead))) return;
|
|
1948
1984
|
if (format === "quiet") {
|
|
1949
1985
|
process.stdout.write(`${payload.status}\n`);
|
|
1950
1986
|
return;
|
|
@@ -1952,7 +1988,7 @@ async function printSessionStatus(record, format) {
|
|
|
1952
1988
|
printTextStatus(payload, dead);
|
|
1953
1989
|
}
|
|
1954
1990
|
function createStatusPayload(record, health, statusState) {
|
|
1955
|
-
const running =
|
|
1991
|
+
const running = statusState === "running";
|
|
1956
1992
|
const acpx = statusAcpxFields(record);
|
|
1957
1993
|
return {
|
|
1958
1994
|
sessionId: record.acpxRecordId,
|
|
@@ -1962,10 +1998,10 @@ function createStatusPayload(record, health, statusState) {
|
|
|
1962
1998
|
model: acpx.model,
|
|
1963
1999
|
mode: acpx.mode,
|
|
1964
2000
|
availableModels: acpx.availableModels,
|
|
1965
|
-
uptime: running ?
|
|
1966
|
-
lastPromptTime:
|
|
1967
|
-
exitCode: running ? null :
|
|
1968
|
-
signal: running ? null :
|
|
2001
|
+
uptime: running ? formatUptime(record.agentStartedAt) ?? null : null,
|
|
2002
|
+
lastPromptTime: record.lastPromptAt ?? null,
|
|
2003
|
+
exitCode: running ? null : record.lastAgentExitCode ?? null,
|
|
2004
|
+
signal: running ? null : record.lastAgentExitSignal ?? null,
|
|
1969
2005
|
...agentSessionIdPayload(record.agentSessionId)
|
|
1970
2006
|
};
|
|
1971
2007
|
}
|
|
@@ -1980,24 +2016,6 @@ function statusPid(health) {
|
|
|
1980
2016
|
if (health.pidAlive) return health.pid ?? null;
|
|
1981
2017
|
return null;
|
|
1982
2018
|
}
|
|
1983
|
-
function optionalStatusString(value) {
|
|
1984
|
-
return value ?? null;
|
|
1985
|
-
}
|
|
1986
|
-
function optionalStatusNumber(value) {
|
|
1987
|
-
return value ?? null;
|
|
1988
|
-
}
|
|
1989
|
-
function optionalStatusSignal(value) {
|
|
1990
|
-
return value ?? null;
|
|
1991
|
-
}
|
|
1992
|
-
function isRunningStatus(status) {
|
|
1993
|
-
return status === "running";
|
|
1994
|
-
}
|
|
1995
|
-
function isDeadStatus(status) {
|
|
1996
|
-
return status === "dead";
|
|
1997
|
-
}
|
|
1998
|
-
function emitStatusJson(format, record, payload, statusState, running, dead) {
|
|
1999
|
-
return emitJsonResult(format, statusJsonPayload(record, payload, statusState, running, dead));
|
|
2000
|
-
}
|
|
2001
2019
|
function statusJsonPayload(record, payload, statusState, running, dead) {
|
|
2002
2020
|
const result = {
|
|
2003
2021
|
action: "status_snapshot",
|
|
@@ -2045,8 +2063,7 @@ function registerStatusCommand(parent, explicitAgentName, config, description) {
|
|
|
2045
2063
|
await handleStatus(explicitAgentName, flags, this, config);
|
|
2046
2064
|
});
|
|
2047
2065
|
}
|
|
2048
|
-
|
|
2049
|
-
//#region src/cli/command-registration.ts
|
|
2066
|
+
// src/cli/command-registration.ts
|
|
2050
2067
|
var LocalAttributeOption = class extends Option {
|
|
2051
2068
|
localAttributeName;
|
|
2052
2069
|
constructor(flags, description, localAttributeName) {
|
|
@@ -2058,7 +2075,10 @@ var LocalAttributeOption = class extends Option {
|
|
|
2058
2075
|
}
|
|
2059
2076
|
};
|
|
2060
2077
|
function addSessionsListOptions(command) {
|
|
2061
|
-
return command.option("--local", "List local acpx session records instead of agent protocol sessions").option("--cursor <cursor>", "Opaque ACP session/list cursor", (value) =>
|
|
2078
|
+
return command.option("--local", "List local acpx session records instead of agent protocol sessions").option("--cursor <cursor>", "Opaque ACP session/list cursor", (value) => {
|
|
2079
|
+
parseNonEmptyValue("Cursor", value);
|
|
2080
|
+
return value;
|
|
2081
|
+
}).option("--filter-cwd <dir>", "Filter agent sessions by working directory", (value) => parseNonEmptyValue("Filter cwd", value));
|
|
2062
2082
|
}
|
|
2063
2083
|
function registerSessionsCommand(parent, explicitAgentName, config) {
|
|
2064
2084
|
const sessionsCommand = parent.command("sessions").description("List, ensure, create, or close sessions for this agent");
|
|
@@ -2148,10 +2168,11 @@ function registerAgentCommand(program, agentName, config) {
|
|
|
2148
2168
|
registerSessionsCommand(agentCommand, agentName, config);
|
|
2149
2169
|
}
|
|
2150
2170
|
function registerFlowCommand(program, config) {
|
|
2151
|
-
program.command("flow").description("Run multi-step ACP workflows from flow files").command("run").description("Run a flow file").argument("<file>", "Flow module path").option("--input-json <json>", "Flow input as JSON").option("--input-file <path>", "Read flow input JSON from file").option("--default-agent <name>", "Default agent profile for ACP nodes without profile", (value) => parseNonEmptyValue("Default agent", value)).action(async function(file, flags) {
|
|
2152
|
-
const { handleFlowRun } = await import("./cli-
|
|
2171
|
+
const runCommand = program.command("flow").description("Run multi-step ACP workflows from flow files").command("run").description("Run a flow file").argument("<file>", "Flow module path").option("--input-json <json>", "Flow input as JSON").option("--input-file <path>", "Read flow input JSON from file").option("--default-agent <name>", "Default agent profile for ACP nodes without profile", (value) => parseNonEmptyValue("Default agent", value)).action(async function(file, flags) {
|
|
2172
|
+
const { handleFlowRun } = await import("./cli-B5gQOSDl.js");
|
|
2153
2173
|
await handleFlowRun(file, flags, this, config);
|
|
2154
2174
|
});
|
|
2175
|
+
addExecConfigOption(runCommand, "Default ACP session config option for flow nodes (repeatable)");
|
|
2155
2176
|
}
|
|
2156
2177
|
function registerDefaultCommands(program, config) {
|
|
2157
2178
|
registerSharedAgentSubcommands(program, void 0, config, {
|
|
@@ -2167,8 +2188,7 @@ function registerDefaultCommands(program, config) {
|
|
|
2167
2188
|
registerCompareCommand(program, config);
|
|
2168
2189
|
registerFlowCommand(program, config);
|
|
2169
2190
|
}
|
|
2170
|
-
|
|
2171
|
-
//#region src/session/queue/owner-input.ts
|
|
2191
|
+
// src/session/queue/owner-input.ts
|
|
2172
2192
|
function asRecord(value) {
|
|
2173
2193
|
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
2174
2194
|
return value;
|
|
@@ -2261,8 +2281,7 @@ async function runQueueOwnerFromStdin() {
|
|
|
2261
2281
|
if (!payload) throw new Error("queue owner startup payload is empty");
|
|
2262
2282
|
await runSessionQueueOwner(parseQueueOwnerPayload(payload));
|
|
2263
2283
|
}
|
|
2264
|
-
|
|
2265
|
-
//#region src/cli-core.ts
|
|
2284
|
+
// src/cli-core.ts
|
|
2266
2285
|
const TOP_LEVEL_VERBS = /* @__PURE__ */ new Set([
|
|
2267
2286
|
"prompt",
|
|
2268
2287
|
"exec",
|
|
@@ -2516,15 +2535,24 @@ async function maybeHandleSkillflag(argv) {
|
|
|
2516
2535
|
includeBundledSkill: false
|
|
2517
2536
|
});
|
|
2518
2537
|
}
|
|
2519
|
-
function createProgram(
|
|
2538
|
+
function createProgram(requestedOutputPolicy) {
|
|
2520
2539
|
const program = new Command();
|
|
2521
2540
|
program.name("acpx").description("Headless CLI client for the Agent Client Protocol").version(getAcpxVersion()).enablePositionalOptions().showHelpAfterError();
|
|
2522
|
-
if (
|
|
2541
|
+
if (requestedOutputPolicy.jsonStrict) program.configureOutput({
|
|
2523
2542
|
writeOut: () => {},
|
|
2524
2543
|
writeErr: () => {}
|
|
2525
2544
|
});
|
|
2545
|
+
else if (requestedOutputPolicy.format === "quiet") program.configureOutput({ writeErr: () => {} });
|
|
2546
|
+
else program.configureOutput({ outputError: (message, write) => {
|
|
2547
|
+
commanderPrintedError = true;
|
|
2548
|
+
write(message);
|
|
2549
|
+
} });
|
|
2526
2550
|
return program;
|
|
2527
2551
|
}
|
|
2552
|
+
let commanderPrintedError = false;
|
|
2553
|
+
function commanderReportedError(outputPolicy) {
|
|
2554
|
+
return outputPolicy.format === "text" && commanderPrintedError;
|
|
2555
|
+
}
|
|
2528
2556
|
async function handleProgramParseError(error, requestedOutputPolicy) {
|
|
2529
2557
|
if (error instanceof CommanderError) {
|
|
2530
2558
|
if (error.code === "commander.helpDisplayed" || error.code === "commander.version" || error.code === "commander.help" && error.exitCode === 0) process.exit(EXIT_CODES.SUCCESS);
|
|
@@ -2532,7 +2560,7 @@ async function handleProgramParseError(error, requestedOutputPolicy) {
|
|
|
2532
2560
|
defaultCode: "USAGE",
|
|
2533
2561
|
origin: "cli"
|
|
2534
2562
|
});
|
|
2535
|
-
await emitRequestedError(error, normalized, requestedOutputPolicy);
|
|
2563
|
+
if (!commanderReportedError(requestedOutputPolicy)) await emitRequestedError(error, normalized, requestedOutputPolicy);
|
|
2536
2564
|
process.exit(exitCodeForOutputErrorCode(normalized.code));
|
|
2537
2565
|
}
|
|
2538
2566
|
if (error instanceof InterruptedError) process.exit(EXIT_CODES.INTERRUPTED);
|
|
@@ -2565,8 +2593,11 @@ async function main(argv = process.argv) {
|
|
|
2565
2593
|
...resolveOutputPolicy(detectRequestedOutputFormat(rawArgs, config.format), requestedJsonStrict),
|
|
2566
2594
|
suppressReads: requestedOutputPolicy.suppressReads
|
|
2567
2595
|
};
|
|
2568
|
-
const program = createProgram(
|
|
2596
|
+
const program = createProgram(requestedOutputPolicy);
|
|
2569
2597
|
addGlobalFlags(program);
|
|
2598
|
+
program.exitOverride((error) => {
|
|
2599
|
+
throw error;
|
|
2600
|
+
});
|
|
2570
2601
|
configurePublicCli({
|
|
2571
2602
|
program,
|
|
2572
2603
|
argv: rawArgs,
|
|
@@ -2581,9 +2612,6 @@ async function main(argv = process.argv) {
|
|
|
2581
2612
|
await handlePrompt(void 0, promptParts, {}, command, config);
|
|
2582
2613
|
}
|
|
2583
2614
|
});
|
|
2584
|
-
program.exitOverride((error) => {
|
|
2585
|
-
throw error;
|
|
2586
|
-
});
|
|
2587
2615
|
await program.parseAsync(normalizedArgv);
|
|
2588
2616
|
} catch (error) {
|
|
2589
2617
|
await handleProgramParseError(error, requestedOutputPolicy);
|
|
@@ -2595,8 +2623,7 @@ function normalizeLifecycleScriptArgs(rawArgs) {
|
|
|
2595
2623
|
if (rawArgs[0] === "--" && (process.env.npm_lifecycle_event || process.env.npm_lifecycle_script)) return rawArgs.slice(1);
|
|
2596
2624
|
return rawArgs;
|
|
2597
2625
|
}
|
|
2598
|
-
|
|
2599
|
-
//#region src/cli/broken-pipe.ts
|
|
2626
|
+
// src/cli/broken-pipe.ts
|
|
2600
2627
|
function handleBrokenPipeError(error, mode, exit = (code) => process.exit(code)) {
|
|
2601
2628
|
if (error.code !== "EPIPE") throw error;
|
|
2602
2629
|
if (mode === "exit") exit(0);
|
|
@@ -2606,8 +2633,7 @@ function installBrokenPipeHandler(stream, mode) {
|
|
|
2606
2633
|
handleBrokenPipeError(error, mode);
|
|
2607
2634
|
});
|
|
2608
2635
|
}
|
|
2609
|
-
|
|
2610
|
-
//#region src/cli.ts
|
|
2636
|
+
// src/cli.ts
|
|
2611
2637
|
function isCliEntrypoint(argv) {
|
|
2612
2638
|
const entry = argv[1];
|
|
2613
2639
|
if (!entry) return false;
|
|
@@ -2626,7 +2652,6 @@ if (isCliEntrypoint(process.argv)) {
|
|
|
2626
2652
|
if (queueOwnerArgOverride) process.env.ACPX_QUEUE_OWNER_ARGS ??= queueOwnerArgOverride;
|
|
2627
2653
|
main(process.argv);
|
|
2628
2654
|
}
|
|
2629
|
-
//#endregion
|
|
2630
2655
|
export { formatPromptSessionBannerLine, parseAllowedTools, parseMaxTurns, parseTtlSeconds };
|
|
2631
2656
|
|
|
2632
2657
|
//# sourceMappingURL=cli.js.map
|