acpx 0.12.0 → 0.13.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.
- package/README.md +11 -3
- package/dist/{cli-CxsS1XQp.js → cli-D52eGvxU.js} +5 -4
- package/dist/cli-D52eGvxU.js.map +1 -0
- package/dist/cli.d.ts +2 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +84 -25
- package/dist/cli.js.map +1 -1
- package/dist/{client-DwNyFauq.d.ts → client-BeKvumq9.d.ts} +4 -3
- package/dist/client-BeKvumq9.d.ts.map +1 -0
- package/dist/{flags-Bjq_XQ4-.js → flags---9OR06b.js} +36 -9
- package/dist/flags---9OR06b.js.map +1 -0
- package/dist/{flows-Db_LZKu9.js → flows-CYfjwbn2.js} +14 -4
- package/dist/flows-CYfjwbn2.js.map +1 -0
- package/dist/flows.d.ts +6 -2
- package/dist/flows.d.ts.map +1 -1
- package/dist/flows.js +1 -1
- package/dist/{live-checkpoint-ClPCSdrW.js → live-checkpoint-CBecfnSH.js} +226 -20
- package/dist/live-checkpoint-CBecfnSH.js.map +1 -0
- package/dist/{output-CjdF5rHk.js → output-CzN8vLdE.js} +150 -18
- package/dist/output-CzN8vLdE.js.map +1 -0
- package/dist/runtime.d.ts +18 -14
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +34 -11
- package/dist/runtime.js.map +1 -1
- package/dist/{session-options-jkYbBxGE.d.ts → session-options-CTdZvr68.d.ts} +4 -2
- package/dist/session-options-CTdZvr68.d.ts.map +1 -0
- package/package.json +27 -27
- package/skills/acpx/SKILL.md +10 -7
- package/dist/cli-CxsS1XQp.js.map +0 -1
- package/dist/client-DwNyFauq.d.ts.map +0 -1
- package/dist/flags-Bjq_XQ4-.js.map +0 -1
- package/dist/flows-Db_LZKu9.js.map +0 -1
- package/dist/live-checkpoint-ClPCSdrW.js.map +0 -1
- package/dist/output-CjdF5rHk.js.map +0 -1
- package/dist/session-options-jkYbBxGE.d.ts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { At as withInterrupt, Bt as isRetryablePromptError, C as mergeSessionOptions, Ct as isPromptInput, D as applyLifecycleSnapshotToRecord, Dt as textPrompt, E as applyConversation, Et as promptToDisplayText, F as modelStateFromConfigOptions, G as findSessionByDirectoryWalk, H as absolutePath, Ht as extractAcpError, J as listSessionsForAgent, Jt as OUTPUT_ERROR_CODES, K as isoNow, N as assertRequestedModelSupported, Ot as InterruptedError, Q as writeSessionRecord, R as splitCommandLine, S as advertisedModelState, T as sessionOptionsFromRecord, U as findGitRepositoryRoot, Vt as normalizeOutputError, W as findSession, Wt as toAcpErrorPayload, X as pruneSessions, Y as normalizeName, Yt as OUTPUT_ERROR_ORIGINS, Z as resolveSessionRecord, _ as createSessionConversation, _t as sessionEventSegmentPath, a as applyRequestedModelIfAdvertised, at as recordPerfDuration, b as recordSessionUpdate, bt as parseJsonRpcErrorMessage, c as setCurrentModelId, ct as startPerfTimer, d as setDesiredModelId, dt as normalizeRuntimeSessionId, f as syncAdvertisedModelState, g as cloneSessionConversation, gt as sessionEventLockPath, h as cloneSessionAcpxState, ht as sessionEventActivePath, i as connectAndLoadSession, it as measurePerf, jt as withTimeout, k as AcpClient, kt as TimeoutError, l as setDesiredConfigOption, m as applyConfigOptionsToState, mt as sessionBaseDir, n as runPromptTurn, nn as QueueConnectionError, nt as getPerfMetricsSnapshot, o as currentModelIdFromSetModelResponse, ot as resetPerfMetrics, p as applyConfigOptionsToRecord, pt as defaultSessionEventLog, q as listSessions, r as withConnectedSession, rn as QueueProtocolError, rt as incrementPerfCounter, s as clearDesiredConfigOption, st as setPerfGauge, t as LiveSessionCheckpoint, tt as formatPerfMetric, u as setDesiredModeId, v as recordClientOperation, vt as extractSessionUpdateNotification, w as persistSessionOptions, x as trimConversationForRuntime, xt as parsePromptStopReason, y as recordPromptSubmission, yt as isAcpJsonRpcMessage, zt as formatErrorMessage } from "./live-checkpoint-CBecfnSH.js";
|
|
2
2
|
import fs, { mkdtempSync, realpathSync, writeFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import fs$1 from "node:fs/promises";
|
|
@@ -104,18 +104,26 @@ function isQueueOwnerHeartbeatStale(owner) {
|
|
|
104
104
|
}
|
|
105
105
|
async function ensureQueueDir() {
|
|
106
106
|
const baseDir = queueBaseDir();
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
try {
|
|
108
|
+
await fs$1.mkdir(baseDir, {
|
|
109
|
+
recursive: true,
|
|
110
|
+
mode: 448
|
|
111
|
+
});
|
|
112
|
+
await fs$1.chmod(baseDir, 448);
|
|
113
|
+
} catch (error) {
|
|
114
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
115
|
+
throw new Error(`Failed to prepare queue directory ${baseDir}: ${message}`, { cause: error });
|
|
116
|
+
}
|
|
112
117
|
const socketDir = queueSocketBaseDir();
|
|
113
|
-
if (socketDir) {
|
|
118
|
+
if (socketDir) try {
|
|
114
119
|
await fs$1.mkdir(socketDir, {
|
|
115
120
|
recursive: true,
|
|
116
121
|
mode: 448
|
|
117
122
|
});
|
|
118
123
|
await fs$1.chmod(socketDir, 448);
|
|
124
|
+
} catch (error) {
|
|
125
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
126
|
+
throw new Error(`Failed to prepare queue socket directory ${socketDir}: ${message}`, { cause: error });
|
|
119
127
|
}
|
|
120
128
|
}
|
|
121
129
|
async function removeSocketFile(socketPath) {
|
|
@@ -1310,6 +1318,7 @@ async function submitToQueueOwner(owner, options) {
|
|
|
1310
1318
|
owner,
|
|
1311
1319
|
request,
|
|
1312
1320
|
onAccepted: ({ resolve }) => {
|
|
1321
|
+
options.onQueueAccepted?.();
|
|
1313
1322
|
options.outputFormatter.setContext({ sessionId: options.sessionId });
|
|
1314
1323
|
if (!options.waitForCompletion) resolve({
|
|
1315
1324
|
queued: true,
|
|
@@ -1602,6 +1611,7 @@ function buildDirectConnectedSessionOptions(options, run) {
|
|
|
1602
1611
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
1603
1612
|
authCredentials: options.authCredentials,
|
|
1604
1613
|
authPolicy: options.authPolicy,
|
|
1614
|
+
fs: options.fs,
|
|
1605
1615
|
terminal: options.terminal,
|
|
1606
1616
|
timeoutMs: options.timeoutMs,
|
|
1607
1617
|
verbose: options.verbose,
|
|
@@ -1685,6 +1695,7 @@ async function setSessionMode(options) {
|
|
|
1685
1695
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
1686
1696
|
authCredentials: options.authCredentials,
|
|
1687
1697
|
authPolicy: options.authPolicy,
|
|
1698
|
+
fs: options.fs,
|
|
1688
1699
|
terminal: options.terminal,
|
|
1689
1700
|
timeoutMs: options.timeoutMs,
|
|
1690
1701
|
verbose: options.verbose
|
|
@@ -1711,6 +1722,7 @@ async function setSessionModel(options) {
|
|
|
1711
1722
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
1712
1723
|
authCredentials: options.authCredentials,
|
|
1713
1724
|
authPolicy: options.authPolicy,
|
|
1725
|
+
fs: options.fs,
|
|
1714
1726
|
terminal: options.terminal,
|
|
1715
1727
|
timeoutMs: options.timeoutMs,
|
|
1716
1728
|
verbose: options.verbose
|
|
@@ -1742,6 +1754,7 @@ async function setSessionConfigOption(options) {
|
|
|
1742
1754
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
1743
1755
|
authCredentials: options.authCredentials,
|
|
1744
1756
|
authPolicy: options.authPolicy,
|
|
1757
|
+
fs: options.fs,
|
|
1745
1758
|
terminal: options.terminal,
|
|
1746
1759
|
timeoutMs: options.timeoutMs,
|
|
1747
1760
|
verbose: options.verbose
|
|
@@ -1840,6 +1853,7 @@ async function createSessionRecordWithClient(client, options) {
|
|
|
1840
1853
|
acpSessionId: sessionId,
|
|
1841
1854
|
agentSessionId,
|
|
1842
1855
|
agentCommand: options.agentCommand,
|
|
1856
|
+
agentArgv: options.agentArgv,
|
|
1843
1857
|
cwd,
|
|
1844
1858
|
name: normalizeName(options.name),
|
|
1845
1859
|
createdAt: now,
|
|
@@ -1918,6 +1932,7 @@ async function resumeSessionRecordWithClient(client, options, cwd) {
|
|
|
1918
1932
|
async function createSessionWithClient(options) {
|
|
1919
1933
|
const client = new AcpClient({
|
|
1920
1934
|
agentCommand: options.agentCommand,
|
|
1935
|
+
agentArgv: options.agentArgv,
|
|
1921
1936
|
cwd: absolutePath(options.cwd),
|
|
1922
1937
|
mcpServers: options.mcpServers,
|
|
1923
1938
|
permissionMode: options.permissionMode,
|
|
@@ -1925,6 +1940,7 @@ async function createSessionWithClient(options) {
|
|
|
1925
1940
|
permissionPolicy: options.permissionPolicy,
|
|
1926
1941
|
authCredentials: options.authCredentials,
|
|
1927
1942
|
authPolicy: options.authPolicy,
|
|
1943
|
+
fs: options.fs,
|
|
1928
1944
|
terminal: options.terminal,
|
|
1929
1945
|
verbose: options.verbose,
|
|
1930
1946
|
sessionOptions: options.sessionOptions
|
|
@@ -1954,6 +1970,7 @@ async function createSession(options) {
|
|
|
1954
1970
|
async function listAgentSessions(options) {
|
|
1955
1971
|
const client = new AcpClient({
|
|
1956
1972
|
agentCommand: options.agentCommand,
|
|
1973
|
+
agentArgv: options.agentArgv,
|
|
1957
1974
|
cwd: absolutePath(options.cwd),
|
|
1958
1975
|
mcpServers: options.mcpServers,
|
|
1959
1976
|
permissionMode: options.permissionMode,
|
|
@@ -1961,6 +1978,7 @@ async function listAgentSessions(options) {
|
|
|
1961
1978
|
permissionPolicy: options.permissionPolicy,
|
|
1962
1979
|
authCredentials: options.authCredentials,
|
|
1963
1980
|
authPolicy: options.authPolicy,
|
|
1981
|
+
fs: options.fs,
|
|
1964
1982
|
terminal: options.terminal,
|
|
1965
1983
|
verbose: options.verbose
|
|
1966
1984
|
});
|
|
@@ -2008,6 +2026,7 @@ async function ensureSession(options) {
|
|
|
2008
2026
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
2009
2027
|
authCredentials: options.authCredentials,
|
|
2010
2028
|
authPolicy: options.authPolicy,
|
|
2029
|
+
fs: options.fs,
|
|
2011
2030
|
terminal: options.terminal,
|
|
2012
2031
|
timeoutMs: options.timeoutMs,
|
|
2013
2032
|
verbose: options.verbose
|
|
@@ -2022,6 +2041,7 @@ async function ensureSession(options) {
|
|
|
2022
2041
|
return {
|
|
2023
2042
|
record: await createSession({
|
|
2024
2043
|
agentCommand: options.agentCommand,
|
|
2044
|
+
agentArgv: options.agentArgv,
|
|
2025
2045
|
cwd,
|
|
2026
2046
|
name: options.name,
|
|
2027
2047
|
resumeSessionId: options.resumeSessionId,
|
|
@@ -2031,6 +2051,7 @@ async function ensureSession(options) {
|
|
|
2031
2051
|
permissionPolicy: options.permissionPolicy,
|
|
2032
2052
|
authCredentials: options.authCredentials,
|
|
2033
2053
|
authPolicy: options.authPolicy,
|
|
2054
|
+
fs: options.fs,
|
|
2034
2055
|
terminal: options.terminal,
|
|
2035
2056
|
timeoutMs: options.timeoutMs,
|
|
2036
2057
|
verbose: options.verbose,
|
|
@@ -2292,6 +2313,7 @@ function queueOwnerRuntimeOptionsFromSend(options) {
|
|
|
2292
2313
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
2293
2314
|
authCredentials: options.authCredentials,
|
|
2294
2315
|
authPolicy: options.authPolicy,
|
|
2316
|
+
fs: options.fs,
|
|
2295
2317
|
terminal: options.terminal,
|
|
2296
2318
|
suppressSdkConsoleErrors: options.suppressSdkConsoleErrors,
|
|
2297
2319
|
verbose: options.verbose,
|
|
@@ -2311,7 +2333,9 @@ function writeQueueOwnerPayloadFile(payload) {
|
|
|
2311
2333
|
});
|
|
2312
2334
|
return payloadPath;
|
|
2313
2335
|
}
|
|
2314
|
-
|
|
2336
|
+
/** Max stderr bytes retained for cold-start diagnostics. */
|
|
2337
|
+
const QUEUE_OWNER_STARTUP_STDERR_MAX_BYTES = 4e3;
|
|
2338
|
+
function buildQueueOwnerSpawnOptions(payloadFilePath, opts) {
|
|
2315
2339
|
const env = {
|
|
2316
2340
|
...process.env,
|
|
2317
2341
|
[QUEUE_OWNER_PAYLOAD_FILE_ENV]: payloadFilePath
|
|
@@ -2319,14 +2343,77 @@ function buildQueueOwnerSpawnOptions(payloadFilePath) {
|
|
|
2319
2343
|
delete env[QUEUE_OWNER_PAYLOAD_ENV];
|
|
2320
2344
|
return {
|
|
2321
2345
|
detached: true,
|
|
2322
|
-
stdio:
|
|
2346
|
+
stdio: opts?.captureStderr === true ? [
|
|
2347
|
+
"ignore",
|
|
2348
|
+
"ignore",
|
|
2349
|
+
"pipe"
|
|
2350
|
+
] : "ignore",
|
|
2323
2351
|
env,
|
|
2324
2352
|
windowsHide: true
|
|
2325
2353
|
};
|
|
2326
2354
|
}
|
|
2355
|
+
function formatQueueOwnerStartupFailure(params) {
|
|
2356
|
+
const parts = [`Session queue owner failed to start for session ${params.sessionId}`];
|
|
2357
|
+
if (params.exit.spawnError) parts.push(`spawn error: ${params.exit.spawnError.message}`);
|
|
2358
|
+
else if (params.exit.exited) {
|
|
2359
|
+
const codePart = params.exit.code === null ? "null" : String(params.exit.code);
|
|
2360
|
+
const signalPart = params.exit.signal ? `, signal ${params.exit.signal}` : "";
|
|
2361
|
+
parts.push(`exited with code ${codePart}${signalPart} before binding its socket`);
|
|
2362
|
+
}
|
|
2363
|
+
const tail = params.logTail.trim();
|
|
2364
|
+
if (tail.length > 0) parts.push(`stderr:\n${tail}`);
|
|
2365
|
+
return parts.join(": ");
|
|
2366
|
+
}
|
|
2327
2367
|
function spawnQueueOwnerProcess(options) {
|
|
2328
2368
|
const payloadPath = writeQueueOwnerPayloadFile(JSON.stringify(options));
|
|
2329
|
-
|
|
2369
|
+
let exited = false;
|
|
2370
|
+
let code = null;
|
|
2371
|
+
let signal = null;
|
|
2372
|
+
let spawnError;
|
|
2373
|
+
let capturing = true;
|
|
2374
|
+
let stderrTail = Buffer.alloc(0);
|
|
2375
|
+
const child = spawn(process.execPath, resolveQueueOwnerSpawnArgs(), buildQueueOwnerSpawnOptions(payloadPath, { captureStderr: true }));
|
|
2376
|
+
const stopStartupCapture = () => {
|
|
2377
|
+
if (!capturing) return;
|
|
2378
|
+
capturing = false;
|
|
2379
|
+
const stderr = child.stderr;
|
|
2380
|
+
if (!stderr) return;
|
|
2381
|
+
stderr.removeAllListeners("data");
|
|
2382
|
+
stderr.on("data", () => {});
|
|
2383
|
+
stderr.resume();
|
|
2384
|
+
stderr.unref();
|
|
2385
|
+
};
|
|
2386
|
+
child.stderr?.on("data", (chunk) => {
|
|
2387
|
+
if (!capturing) return;
|
|
2388
|
+
const buf = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
|
|
2389
|
+
const combined = Buffer.concat([stderrTail, buf]);
|
|
2390
|
+
stderrTail = combined.length > 4e3 ? combined.subarray(combined.length - QUEUE_OWNER_STARTUP_STDERR_MAX_BYTES) : combined;
|
|
2391
|
+
});
|
|
2392
|
+
child.stderr?.on("error", () => {});
|
|
2393
|
+
child.on("error", (error) => {
|
|
2394
|
+
spawnError = error;
|
|
2395
|
+
});
|
|
2396
|
+
child.on("close", (exitCode, exitSignal) => {
|
|
2397
|
+
exited = true;
|
|
2398
|
+
code = exitCode;
|
|
2399
|
+
signal = exitSignal;
|
|
2400
|
+
stopStartupCapture();
|
|
2401
|
+
});
|
|
2402
|
+
child.unref();
|
|
2403
|
+
return {
|
|
2404
|
+
pid: child.pid,
|
|
2405
|
+
getExitState: () => ({
|
|
2406
|
+
exited,
|
|
2407
|
+
code,
|
|
2408
|
+
signal,
|
|
2409
|
+
...spawnError ? { spawnError } : {}
|
|
2410
|
+
}),
|
|
2411
|
+
readLogTail: (maxBytes = QUEUE_OWNER_STARTUP_STDERR_MAX_BYTES) => {
|
|
2412
|
+
const start = Math.max(0, stderrTail.length - maxBytes);
|
|
2413
|
+
return stderrTail.subarray(start).toString("utf8");
|
|
2414
|
+
},
|
|
2415
|
+
stopStartupCapture
|
|
2416
|
+
};
|
|
2330
2417
|
}
|
|
2331
2418
|
//#endregion
|
|
2332
2419
|
//#region src/session/events.ts
|
|
@@ -2892,6 +2979,7 @@ async function runSessionPrompt(options) {
|
|
|
2892
2979
|
const ownClient = options.client == null;
|
|
2893
2980
|
const client = options.client ?? new AcpClient({
|
|
2894
2981
|
agentCommand: record.agentCommand,
|
|
2982
|
+
agentArgv: record.agentArgv,
|
|
2895
2983
|
cwd: absolutePath(record.cwd),
|
|
2896
2984
|
mcpServers: options.mcpServers,
|
|
2897
2985
|
permissionMode: options.permissionMode,
|
|
@@ -2899,6 +2987,7 @@ async function runSessionPrompt(options) {
|
|
|
2899
2987
|
permissionPolicy: options.permissionPolicy,
|
|
2900
2988
|
authCredentials: options.authCredentials,
|
|
2901
2989
|
authPolicy: options.authPolicy,
|
|
2990
|
+
fs: options.fs,
|
|
2902
2991
|
terminal: options.terminal,
|
|
2903
2992
|
suppressSdkConsoleErrors: options.suppressSdkConsoleErrors,
|
|
2904
2993
|
verbose: options.verbose,
|
|
@@ -2908,6 +2997,7 @@ async function runSessionPrompt(options) {
|
|
|
2908
2997
|
permissionMode: options.permissionMode,
|
|
2909
2998
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
2910
2999
|
permissionPolicy: options.permissionPolicy,
|
|
3000
|
+
fs: options.fs,
|
|
2911
3001
|
terminal: options.terminal,
|
|
2912
3002
|
suppressSdkConsoleErrors: options.suppressSdkConsoleErrors,
|
|
2913
3003
|
verbose: options.verbose
|
|
@@ -3093,7 +3183,8 @@ async function runSessionPrompt(options) {
|
|
|
3093
3183
|
const savePromptSuccess = async (response) => {
|
|
3094
3184
|
await flushPendingMessages(false);
|
|
3095
3185
|
output.flush();
|
|
3096
|
-
|
|
3186
|
+
const now = isoNow();
|
|
3187
|
+
record.lastUsedAt = now;
|
|
3097
3188
|
record.closed = false;
|
|
3098
3189
|
record.closedAt = void 0;
|
|
3099
3190
|
record.protocolVersion = client.initializeResult?.protocolVersion;
|
|
@@ -3169,6 +3260,7 @@ async function runOnce(options) {
|
|
|
3169
3260
|
const acpErrors = new AcpErrorTracker();
|
|
3170
3261
|
const client = new AcpClient({
|
|
3171
3262
|
agentCommand: options.agentCommand,
|
|
3263
|
+
agentArgv: options.agentArgv,
|
|
3172
3264
|
cwd: absolutePath(options.cwd),
|
|
3173
3265
|
mcpServers: options.mcpServers,
|
|
3174
3266
|
permissionMode: options.permissionMode,
|
|
@@ -3176,6 +3268,7 @@ async function runOnce(options) {
|
|
|
3176
3268
|
permissionPolicy: options.permissionPolicy,
|
|
3177
3269
|
authCredentials: options.authCredentials,
|
|
3178
3270
|
authPolicy: options.authPolicy,
|
|
3271
|
+
fs: options.fs,
|
|
3179
3272
|
terminal: options.terminal,
|
|
3180
3273
|
suppressSdkConsoleErrors: options.suppressSdkConsoleErrors,
|
|
3181
3274
|
verbose: options.verbose,
|
|
@@ -3264,6 +3357,7 @@ async function sendSessionDirect(options) {
|
|
|
3264
3357
|
permissionPolicy: options.permissionPolicy,
|
|
3265
3358
|
authCredentials: options.authCredentials,
|
|
3266
3359
|
authPolicy: options.authPolicy,
|
|
3360
|
+
fs: options.fs,
|
|
3267
3361
|
terminal: options.terminal,
|
|
3268
3362
|
outputFormatter: options.outputFormatter,
|
|
3269
3363
|
errorEmissionPolicy: options.errorEmissionPolicy,
|
|
@@ -3282,7 +3376,7 @@ async function sendSessionDirect(options) {
|
|
|
3282
3376
|
const QUEUE_OWNER_STARTUP_MAX_ATTEMPTS = 120;
|
|
3283
3377
|
const QUEUE_OWNER_HEARTBEAT_INTERVAL_MS = 5e3;
|
|
3284
3378
|
const QUEUE_OWNER_ACTIVE_TURN_CANCEL_GRACE_MS = 750;
|
|
3285
|
-
async function submitToRunningOwner(options, waitForCompletion) {
|
|
3379
|
+
async function submitToRunningOwner(options, waitForCompletion, extras) {
|
|
3286
3380
|
return await trySubmitToRunningOwner({
|
|
3287
3381
|
sessionId: options.sessionId,
|
|
3288
3382
|
message: promptToDisplayText(options.prompt),
|
|
@@ -3299,18 +3393,21 @@ async function submitToRunningOwner(options, waitForCompletion) {
|
|
|
3299
3393
|
promptRetries: options.promptRetries,
|
|
3300
3394
|
waitForCompletion,
|
|
3301
3395
|
verbose: options.verbose,
|
|
3302
|
-
sessionOptions: options.sessionOptions
|
|
3396
|
+
sessionOptions: options.sessionOptions,
|
|
3397
|
+
onQueueAccepted: extras?.onQueueAccepted
|
|
3303
3398
|
});
|
|
3304
3399
|
}
|
|
3305
3400
|
function createQueueOwnerSharedClient(options, sessionRecord) {
|
|
3306
3401
|
return new AcpClient({
|
|
3307
3402
|
agentCommand: sessionRecord.agentCommand,
|
|
3403
|
+
agentArgv: sessionRecord.agentArgv,
|
|
3308
3404
|
cwd: absolutePath(sessionRecord.cwd),
|
|
3309
3405
|
mcpServers: options.mcpServers,
|
|
3310
3406
|
permissionMode: options.permissionMode,
|
|
3311
3407
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
3312
3408
|
authCredentials: options.authCredentials,
|
|
3313
3409
|
authPolicy: options.authPolicy,
|
|
3410
|
+
fs: options.fs,
|
|
3314
3411
|
terminal: options.terminal,
|
|
3315
3412
|
suppressSdkConsoleErrors: options.suppressSdkConsoleErrors,
|
|
3316
3413
|
verbose: options.verbose,
|
|
@@ -3328,6 +3425,7 @@ function createQueueOwnerTurnController(options) {
|
|
|
3328
3425
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
3329
3426
|
authCredentials: options.authCredentials,
|
|
3330
3427
|
authPolicy: options.authPolicy,
|
|
3428
|
+
fs: options.fs,
|
|
3331
3429
|
terminal: options.terminal,
|
|
3332
3430
|
timeoutMs,
|
|
3333
3431
|
verbose: options.verbose
|
|
@@ -3341,6 +3439,7 @@ function createQueueOwnerTurnController(options) {
|
|
|
3341
3439
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
3342
3440
|
authCredentials: options.authCredentials,
|
|
3343
3441
|
authPolicy: options.authPolicy,
|
|
3442
|
+
fs: options.fs,
|
|
3344
3443
|
terminal: options.terminal,
|
|
3345
3444
|
timeoutMs,
|
|
3346
3445
|
verbose: options.verbose
|
|
@@ -3355,6 +3454,7 @@ function createQueueOwnerTurnController(options) {
|
|
|
3355
3454
|
nonInteractivePermissions: options.nonInteractivePermissions,
|
|
3356
3455
|
authCredentials: options.authCredentials,
|
|
3357
3456
|
authPolicy: options.authPolicy,
|
|
3457
|
+
fs: options.fs,
|
|
3358
3458
|
terminal: options.terminal,
|
|
3359
3459
|
timeoutMs,
|
|
3360
3460
|
verbose: options.verbose
|
|
@@ -3366,6 +3466,9 @@ function logDeferredCancelFailure(error, verbose) {
|
|
|
3366
3466
|
if (!verbose) return;
|
|
3367
3467
|
process.stderr.write(`[acpx] failed to apply deferred cancel: ${formatErrorMessage(error)}\n`);
|
|
3368
3468
|
}
|
|
3469
|
+
function queueOwnerExitIsFatal(exit) {
|
|
3470
|
+
return exit.exited && (exit.spawnError !== void 0 || exit.code !== 0 || exit.signal !== null);
|
|
3471
|
+
}
|
|
3369
3472
|
function logQueueOwnerReady(params) {
|
|
3370
3473
|
if (!params.verbose) return;
|
|
3371
3474
|
process.stderr.write(`[acpx] queue owner ready for session ${params.sessionId} (ttlMs=${params.ttlMs}, maxQueueDepth=${params.maxQueueDepth})\n`);
|
|
@@ -3602,14 +3705,42 @@ async function sendSession(options) {
|
|
|
3602
3705
|
const waitForCompletion = options.waitForCompletion !== false;
|
|
3603
3706
|
const queuedToOwner = await submitToRunningOwner(options, waitForCompletion);
|
|
3604
3707
|
if (queuedToOwner) return queuedToOwner;
|
|
3605
|
-
spawnQueueOwnerProcess(queueOwnerRuntimeOptionsFromSend(options));
|
|
3708
|
+
const owner = spawnQueueOwnerProcess(queueOwnerRuntimeOptionsFromSend(options));
|
|
3709
|
+
const onQueueAccepted = () => {
|
|
3710
|
+
owner.stopStartupCapture();
|
|
3711
|
+
};
|
|
3606
3712
|
for (let attempt = 0; attempt < QUEUE_OWNER_STARTUP_MAX_ATTEMPTS; attempt += 1) {
|
|
3607
|
-
const queued = await submitToRunningOwner(options, waitForCompletion);
|
|
3608
|
-
if (queued)
|
|
3713
|
+
const queued = await submitToRunningOwner(options, waitForCompletion, { onQueueAccepted });
|
|
3714
|
+
if (queued) {
|
|
3715
|
+
owner.stopStartupCapture();
|
|
3716
|
+
return queued;
|
|
3717
|
+
}
|
|
3718
|
+
const exit = owner.getExitState();
|
|
3719
|
+
if (queueOwnerExitIsFatal(exit)) {
|
|
3720
|
+
const message = formatQueueOwnerStartupFailure({
|
|
3721
|
+
sessionId: options.sessionId,
|
|
3722
|
+
exit,
|
|
3723
|
+
logTail: owner.readLogTail()
|
|
3724
|
+
});
|
|
3725
|
+
owner.stopStartupCapture();
|
|
3726
|
+
throw new Error(message);
|
|
3727
|
+
}
|
|
3609
3728
|
await waitMs(50);
|
|
3610
3729
|
}
|
|
3611
|
-
|
|
3730
|
+
const finalExit = owner.getExitState();
|
|
3731
|
+
const message = formatQueueOwnerStartupFailure({
|
|
3732
|
+
sessionId: options.sessionId,
|
|
3733
|
+
exit: finalExit.exited ? finalExit : {
|
|
3734
|
+
exited: false,
|
|
3735
|
+
code: null,
|
|
3736
|
+
signal: null
|
|
3737
|
+
},
|
|
3738
|
+
logTail: owner.readLogTail()
|
|
3739
|
+
});
|
|
3740
|
+
owner.stopStartupCapture();
|
|
3741
|
+
throw new Error(message);
|
|
3612
3742
|
}
|
|
3743
|
+
const queueOwnerRuntimeTestInternals = { queueOwnerExitIsFatal };
|
|
3613
3744
|
//#endregion
|
|
3614
3745
|
//#region src/session/session.ts
|
|
3615
3746
|
var session_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -3632,6 +3763,7 @@ var session_exports = /* @__PURE__ */ __exportAll({
|
|
|
3632
3763
|
mergeConnectedModelState: () => mergeConnectedModelState,
|
|
3633
3764
|
normalizeQueueOwnerTtlMs: () => normalizeQueueOwnerTtlMs,
|
|
3634
3765
|
pruneSessions: () => pruneSessions,
|
|
3766
|
+
queueOwnerRuntimeTestInternals: () => queueOwnerRuntimeTestInternals,
|
|
3635
3767
|
runOnce: () => runOnce,
|
|
3636
3768
|
runQueuedTask: () => runQueuedTask,
|
|
3637
3769
|
runSessionQueueOwner: () => runSessionQueueOwner,
|
|
@@ -4590,4 +4722,4 @@ function createOutputFormatter(format, options = {}) {
|
|
|
4590
4722
|
//#endregion
|
|
4591
4723
|
export { runSessionQueueOwner as a, buildQueueOwnerArgOverride as c, createSessionWithClient as d, cancelSessionPrompt as f, __exportAll as g, isProcessAlive as h, session_exports as i, flushPerfMetricsCapture as l, DEFAULT_QUEUE_OWNER_TTL_MS as m, getTextErrorRemediationHints as n, runOnce as o, probeQueueOwnerHealth as p, output_exports as r, sendSessionDirect as s, createOutputFormatter as t, installPerfMetricsCapture as u };
|
|
4592
4724
|
|
|
4593
|
-
//# sourceMappingURL=output-
|
|
4725
|
+
//# sourceMappingURL=output-CzN8vLdE.js.map
|