acpx 0.20.0 → 0.21.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/{agent-registry-Gtwn7nMp.js → agent-registry-Cz9fD9H1.js} +5 -8
- package/dist/{agent-registry-Gtwn7nMp.js.map → agent-registry-Cz9fD9H1.js.map} +1 -1
- package/dist/agent-registry.d.ts +0 -2
- package/dist/agent-registry.d.ts.map +1 -1
- package/dist/agent-registry.js +1 -1
- package/dist/{cli-CnufHoAJ.js → cli-BLEPj7lL.js} +6 -8
- package/dist/{cli-CnufHoAJ.js.map → cli-BLEPj7lL.js.map} +1 -1
- package/dist/cli.d.ts +1 -5
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +27 -45
- package/dist/cli.js.map +1 -1
- package/dist/{client-R5OmZ--S.d.ts → client-D12zqSyN.d.ts} +3 -8
- package/dist/client-D12zqSyN.d.ts.map +1 -0
- package/dist/{flows-CTRAV28u.js → flows-BVpRv0Df.js} +19 -33
- package/dist/{flows-CTRAV28u.js.map → flows-BVpRv0Df.js.map} +1 -1
- package/dist/flows.d.ts +2 -14
- package/dist/flows.d.ts.map +1 -1
- package/dist/flows.js +1 -1
- package/dist/{invocation-options-DE3Z_fqa.js → invocation-options-VJlayf-0.js} +16 -12
- package/dist/{invocation-options-DE3Z_fqa.js.map → invocation-options-VJlayf-0.js.map} +1 -1
- package/dist/{ipc-D2BC99hf.js → ipc-BbYFsKOj.js} +38 -69
- package/dist/ipc-BbYFsKOj.js.map +1 -0
- package/dist/{output-B1Srnvko.js → output-mqRHzGzM.js} +10 -17
- package/dist/{output-B1Srnvko.js.map → output-mqRHzGzM.js.map} +1 -1
- package/dist/{queue-owner-runtime-Be8sr9L5.js → queue-owner-runtime-B0mPqOu4.js} +168 -117
- package/dist/queue-owner-runtime-B0mPqOu4.js.map +1 -0
- package/dist/runtime.d.ts +18 -26
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +29 -32
- package/dist/runtime.js.map +1 -1
- package/dist/{session-options-DQlqgFv2.d.ts → session-options-BlnP3WAc.d.ts} +8 -7
- package/dist/session-options-BlnP3WAc.d.ts.map +1 -0
- package/dist/{session-watch-CpYYtV62.js → session-watch-BnIxHQrU.js} +5 -6
- package/dist/{session-watch-CpYYtV62.js.map → session-watch-BnIxHQrU.js.map} +1 -1
- package/dist/{watch-Db2D1eYN.js → watch-bQXyUy3z.js} +3 -4
- package/dist/{watch-Db2D1eYN.js.map → watch-bQXyUy3z.js.map} +1 -1
- package/package.json +20 -20
- package/skills/acpx/SKILL.md +27 -1
- package/dist/client-R5OmZ--S.d.ts.map +0 -1
- package/dist/ipc-D2BC99hf.js.map +0 -1
- package/dist/queue-owner-runtime-Be8sr9L5.js.map +0 -1
- package/dist/session-options-DQlqgFv2.d.ts.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as measurePerf, $t as UnsupportedPromptContentError, Bt as AgentStartupError, C as textPrompt, Dt as normalizeOutputError, Et as isRetryablePromptError, F as normalizeName, G as normalizeAgentSessionId, Gt as PermissionDeniedError, H as canonicalAgentCommand, Ht as ClaudeAcpSessionCreateTimeoutError, Jt as SessionConfigOptionReplayError, K as SESSION_JOURNAL_SCHEMA, Kt as PermissionPromptUnavailableError, L as readSessionRecord, Lt as AcpxOperationalError, M as isoNow$1, O as absolutePath, Ot as extractAcpError, Q as incrementPerfCounter, Qt as SessionResumeRequiredError, R as resolveSessionRecord, Rt as AgentDisconnectedError, S as promptToDisplayText, St as isProcessAlive, T as lockOwnerPid, Tt as isAcpQueryClosedBeforeResponseError, Ut as CopilotAcpUnsupportedError, Vt as AuthPolicyError, W as extractAgentSessionId, Wt as GeminiAcpStartupTimeoutError, X as formatPerfMetric, Xt as SessionModelReplayError, Yt as SessionModeReplayError, Z as getPerfMetricsSnapshot, _ as ProcessDescendants, _t as sessionEventLockPath, a as trySetModelOnRunningOwner, at as isAcpMessageObject, d as releaseQueueOwnerLease, et as resetPerfMetrics, f as terminateProcess, ft as defaultSessionEventLog, g as QueueLeaseGuardSettlementError, gt as sessionEventActivePath, h as waitMs$1, ht as sessionBaseDir, i as trySetModeOnRunningOwner, it as isAcpJsonRpcMessage, j as findSessionByDirectoryWalk, k as findGitRepositoryRoot, kt as isAcpResourceNotFoundError, m as tryAcquireQueueOwnerLease, mt as retainedEventMaxSegments, n as tryCloseSessionOnRunningOwner, nt as startPerfTimer, o as trySubmitToRunningOwner, ot as isSessionUpdateNotification, p as terminateQueueOwnerForSession, pt as existingEventSegmentIndices, q as SessionJournalReader, qt as QueueConnectionError, r as trySetConfigOptionOnRunningOwner, s as SessionQueueOwner, t as tryCancelOnRunningOwner, tt as setPerfGauge, u as refreshQueueOwnerLease, vt as sessionEventSegmentPath, w as createLockOwner, wt as formatErrorMessage, y as getUnsupportedPromptContentMessage, z as writeSessionRecord, zt as AgentSpawnError } from "./ipc-
|
|
2
|
-
import { A as requireAgentStdio, C as PROCESS_HELPER_TIMEOUT_MS, D as isoNow$2, E as isChildProcessRunning, F as waitForChildExit, I as waitForSpawn, M as resolveAgentSessionCwd, N as runTimedExecFile, P as splitCommandLine, T as basenameToken, _ as buildSpawnCommandOptions, b as readWindowsEnvValue, f as resolveBuiltInAgentLaunch, g as buildAgentSpawnCommand, j as resolveAgentCommandParts, v as buildTerminalShellSpawnCommand, w as asAbsoluteCwd, x as resolveWindowsExecutablePath, y as buildTerminalSpawnCommand } from "./agent-registry-
|
|
1
|
+
import { $ as measurePerf, $t as UnsupportedPromptContentError, Bt as AgentStartupError, C as textPrompt, Dt as normalizeOutputError, Et as isRetryablePromptError, F as normalizeName, G as normalizeAgentSessionId, Gt as PermissionDeniedError, H as canonicalAgentCommand, Ht as ClaudeAcpSessionCreateTimeoutError, Jt as SessionConfigOptionReplayError, K as SESSION_JOURNAL_SCHEMA, Kt as PermissionPromptUnavailableError, L as readSessionRecord, Lt as AcpxOperationalError, M as isoNow$1, O as absolutePath, Ot as extractAcpError, Q as incrementPerfCounter, Qt as SessionResumeRequiredError, R as resolveSessionRecord, Rt as AgentDisconnectedError, S as promptToDisplayText, St as isProcessAlive, T as lockOwnerPid, Tt as isAcpQueryClosedBeforeResponseError, Ut as CopilotAcpUnsupportedError, Vt as AuthPolicyError, W as extractAgentSessionId, Wt as GeminiAcpStartupTimeoutError, X as formatPerfMetric, Xt as SessionModelReplayError, Yt as SessionModeReplayError, Z as getPerfMetricsSnapshot, _ as ProcessDescendants, _t as sessionEventLockPath, a as trySetModelOnRunningOwner, at as isAcpMessageObject, d as releaseQueueOwnerLease, et as resetPerfMetrics, f as terminateProcess, ft as defaultSessionEventLog, g as QueueLeaseGuardSettlementError, gt as sessionEventActivePath, h as waitMs$1, ht as sessionBaseDir, i as trySetModeOnRunningOwner, it as isAcpJsonRpcMessage, j as findSessionByDirectoryWalk, k as findGitRepositoryRoot, kt as isAcpResourceNotFoundError, m as tryAcquireQueueOwnerLease, mt as retainedEventMaxSegments, n as tryCloseSessionOnRunningOwner, nt as startPerfTimer, o as trySubmitToRunningOwner, ot as isSessionUpdateNotification, p as terminateQueueOwnerForSession, pt as existingEventSegmentIndices, q as SessionJournalReader, qt as QueueConnectionError, r as trySetConfigOptionOnRunningOwner, s as SessionQueueOwner, t as tryCancelOnRunningOwner, tt as setPerfGauge, u as refreshQueueOwnerLease, vt as sessionEventSegmentPath, w as createLockOwner, wt as formatErrorMessage, y as getUnsupportedPromptContentMessage, z as writeSessionRecord, zt as AgentSpawnError } from "./ipc-BbYFsKOj.js";
|
|
2
|
+
import { A as requireAgentStdio, C as PROCESS_HELPER_TIMEOUT_MS, D as isoNow$2, E as isChildProcessRunning, F as waitForChildExit, I as waitForSpawn, M as resolveAgentSessionCwd, N as runTimedExecFile, P as splitCommandLine, T as basenameToken, _ as buildSpawnCommandOptions, b as readWindowsEnvValue, f as resolveBuiltInAgentLaunch, g as buildAgentSpawnCommand, j as resolveAgentCommandParts, v as buildTerminalShellSpawnCommand, w as asAbsoluteCwd, x as resolveWindowsExecutablePath, y as buildTerminalSpawnCommand } from "./agent-registry-Cz9fD9H1.js";
|
|
3
3
|
import fs, { readFileSync, realpathSync } from "node:fs";
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
5
|
import path from "node:path";
|
|
@@ -16,7 +16,7 @@ import { FsSafeError } from "@openclaw/fs-safe/errors";
|
|
|
16
16
|
import { isPathInside } from "@openclaw/fs-safe/path";
|
|
17
17
|
import { root } from "@openclaw/fs-safe/root";
|
|
18
18
|
import readline from "node:readline/promises";
|
|
19
|
-
|
|
19
|
+
// src/async-control.ts
|
|
20
20
|
var TimeoutError = class extends Error {
|
|
21
21
|
constructor(timeoutMs) {
|
|
22
22
|
super(`Timed out after ${timeoutMs}ms`);
|
|
@@ -76,8 +76,7 @@ async function withInterrupt(run, onInterrupt) {
|
|
|
76
76
|
run().then((result) => finish(() => resolve(result)), (error) => finish(() => reject(error)));
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
//#region src/acp/codex-compat.ts
|
|
79
|
+
// src/acp/codex-compat.ts
|
|
81
80
|
function isLegacyZedCodexAcpInvocation(agentCommand) {
|
|
82
81
|
return /@zed-industries\/codex-acp\b/u.test(agentCommand);
|
|
83
82
|
}
|
|
@@ -95,8 +94,7 @@ function codexPermissionNotice(request, response, agentName) {
|
|
|
95
94
|
const selectedId = response.outcome.optionId;
|
|
96
95
|
return request.options.find((option) => option.optionId === selectedId)?.kind === "reject_once" && selectedId === "cancel" ? "Permission refused using Codex's cancellation option; this can end the current turn. The operation was not approved." : void 0;
|
|
97
96
|
}
|
|
98
|
-
|
|
99
|
-
//#region src/session/events.ts
|
|
97
|
+
// src/session/events.ts
|
|
100
98
|
async function ensureSessionDir() {
|
|
101
99
|
await fs$1.mkdir(sessionBaseDir(), {
|
|
102
100
|
recursive: true,
|
|
@@ -359,8 +357,7 @@ async function listSessionEvents(sessionId, maxSegments) {
|
|
|
359
357
|
eventLog: { max_segments: maxSegments }
|
|
360
358
|
}).readAcpMessages();
|
|
361
359
|
}
|
|
362
|
-
|
|
363
|
-
//#region src/session/turn-ownership.ts
|
|
360
|
+
// src/session/turn-ownership.ts
|
|
364
361
|
const LOCK_RETRY_MS = 15;
|
|
365
362
|
const INCOMPLETE_RESERVATION_GRACE_MS = 15e3;
|
|
366
363
|
let lastCreatedAt = 0;
|
|
@@ -599,16 +596,14 @@ async function acquireSessionOwnership(requestedPath, signal) {
|
|
|
599
596
|
await setTimeout$1(LOCK_RETRY_MS, void 0, { signal });
|
|
600
597
|
}
|
|
601
598
|
}
|
|
602
|
-
|
|
603
|
-
//#region src/session/execution/contracts.ts
|
|
599
|
+
// src/session/execution/contracts.ts
|
|
604
600
|
const DEFAULT_QUEUE_OWNER_TTL_MS = 3e5;
|
|
605
601
|
function normalizeQueueOwnerTtlMs(ttlMs) {
|
|
606
602
|
if (ttlMs == null) return DEFAULT_QUEUE_OWNER_TTL_MS;
|
|
607
603
|
if (!Number.isFinite(ttlMs) || ttlMs < 0) return DEFAULT_QUEUE_OWNER_TTL_MS;
|
|
608
604
|
return Math.round(ttlMs);
|
|
609
605
|
}
|
|
610
|
-
|
|
611
|
-
//#region src/file-read-window.ts
|
|
606
|
+
// src/file-read-window.ts
|
|
612
607
|
function sliceReadWindow(content, line, limit) {
|
|
613
608
|
if (line == null && limit == null) return content;
|
|
614
609
|
const lines = content.split("\n");
|
|
@@ -618,8 +613,7 @@ function sliceReadWindow(content, line, limit) {
|
|
|
618
613
|
const endIndex = maxLines == null ? lines.length : Math.min(lines.length, startIndex + maxLines);
|
|
619
614
|
return lines.slice(startIndex, endIndex).join("\n");
|
|
620
615
|
}
|
|
621
|
-
|
|
622
|
-
//#region src/permission-prompt.ts
|
|
616
|
+
// src/permission-prompt.ts
|
|
623
617
|
function visiblePromptText(value) {
|
|
624
618
|
let rendered = "";
|
|
625
619
|
for (const character of value) {
|
|
@@ -687,8 +681,7 @@ function writePromptDetails(options) {
|
|
|
687
681
|
if (options.header) process.stderr.write(`\n${visiblePromptText(options.header)}\n`);
|
|
688
682
|
if (options.details && options.details.trim().length > 0) process.stderr.write(`${options.details.split("\n").map(visiblePromptText).join("\n")}\n`);
|
|
689
683
|
}
|
|
690
|
-
|
|
691
|
-
//#region src/filesystem.ts
|
|
684
|
+
// src/filesystem.ts
|
|
692
685
|
const WRITE_PREVIEW_MAX_LINES = 16;
|
|
693
686
|
const WRITE_PREVIEW_MAX_CHARS = 1200;
|
|
694
687
|
function nowIso$1() {
|
|
@@ -844,8 +837,7 @@ var FileSystemHandlers = class {
|
|
|
844
837
|
this.onOperation?.(operation);
|
|
845
838
|
}
|
|
846
839
|
};
|
|
847
|
-
|
|
848
|
-
//#region src/permissions.ts
|
|
840
|
+
// src/permissions.ts
|
|
849
841
|
const PERMISSION_MODE_RANK = {
|
|
850
842
|
"deny-all": 0,
|
|
851
843
|
"approve-reads": 1,
|
|
@@ -1115,8 +1107,7 @@ function classifyPermissionDecision(params, response) {
|
|
|
1115
1107
|
if (selectedOption.kind === "allow_once" || selectedOption.kind === "allow_always") return "approved";
|
|
1116
1108
|
return "denied";
|
|
1117
1109
|
}
|
|
1118
|
-
|
|
1119
|
-
//#region src/acp/agent-command.ts
|
|
1110
|
+
// src/acp/agent-command.ts
|
|
1120
1111
|
const DEFAULT_AGENT_CLOSE_AFTER_STDIN_END_MS = 100;
|
|
1121
1112
|
const QODER_AGENT_CLOSE_AFTER_STDIN_END_MS = 750;
|
|
1122
1113
|
const GEMINI_ACP_STARTUP_TIMEOUT_MS = 15e3;
|
|
@@ -1292,8 +1283,91 @@ function resolveClaudeCodeExecutable(platform = process.platform, env = process.
|
|
|
1292
1283
|
if (readWindowsEnvValue(env, "CLAUDE_CODE_EXECUTABLE")) return;
|
|
1293
1284
|
return resolveWindowsExecutablePath("claude", env, cwd);
|
|
1294
1285
|
}
|
|
1295
|
-
|
|
1296
|
-
|
|
1286
|
+
// src/acp/inherited-env.ts
|
|
1287
|
+
const AUTH_GRANT_PREFIX = "ACPX_AUTH_";
|
|
1288
|
+
const POSIX_ESSENTIAL_NAMES = [
|
|
1289
|
+
"PATH",
|
|
1290
|
+
"HOME",
|
|
1291
|
+
"USER",
|
|
1292
|
+
"LOGNAME",
|
|
1293
|
+
"SHELL",
|
|
1294
|
+
"LANG",
|
|
1295
|
+
"LANGUAGE",
|
|
1296
|
+
"TZ",
|
|
1297
|
+
"TMPDIR",
|
|
1298
|
+
"TMP",
|
|
1299
|
+
"TEMP"
|
|
1300
|
+
];
|
|
1301
|
+
const WINDOWS_ESSENTIAL_NAMES = [
|
|
1302
|
+
"SYSTEMROOT",
|
|
1303
|
+
"WINDIR",
|
|
1304
|
+
"SYSTEMDRIVE",
|
|
1305
|
+
"COMSPEC",
|
|
1306
|
+
"PATHEXT",
|
|
1307
|
+
"USERPROFILE",
|
|
1308
|
+
"HOMEDRIVE",
|
|
1309
|
+
"HOMEPATH",
|
|
1310
|
+
"USERNAME",
|
|
1311
|
+
"USERDOMAIN",
|
|
1312
|
+
"APPDATA",
|
|
1313
|
+
"LOCALAPPDATA",
|
|
1314
|
+
"PROGRAMDATA",
|
|
1315
|
+
"ALLUSERSPROFILE",
|
|
1316
|
+
"PROGRAMFILES",
|
|
1317
|
+
"PROGRAMFILES(X86)",
|
|
1318
|
+
"PROGRAMW6432",
|
|
1319
|
+
"COMMONPROGRAMFILES",
|
|
1320
|
+
"COMMONPROGRAMFILES(X86)",
|
|
1321
|
+
"COMMONPROGRAMW6432"
|
|
1322
|
+
];
|
|
1323
|
+
const ESSENTIAL_PREFIXES = ["LC_", "XDG_"];
|
|
1324
|
+
/** Environment name as compared on this platform: Windows names are case-insensitive. */
|
|
1325
|
+
function envNameKey(name) {
|
|
1326
|
+
return process.platform === "win32" ? name.toUpperCase() : name;
|
|
1327
|
+
}
|
|
1328
|
+
function essentialNames() {
|
|
1329
|
+
return process.platform === "win32" ? [...POSIX_ESSENTIAL_NAMES, ...WINDOWS_ESSENTIAL_NAMES] : POSIX_ESSENTIAL_NAMES;
|
|
1330
|
+
}
|
|
1331
|
+
function isEnvName(name) {
|
|
1332
|
+
return typeof name === "string" && name.length > 0 && !name.includes("=") && !name.includes("\0");
|
|
1333
|
+
}
|
|
1334
|
+
function validateEnvNames(option, names) {
|
|
1335
|
+
if (!Array.isArray(names) || !names.every(isEnvName)) throw new Error(`Invalid ${option}: expected an array of non-empty names without NUL or '='`);
|
|
1336
|
+
return names;
|
|
1337
|
+
}
|
|
1338
|
+
/** Validate and copy an embedder's name list once, when a client or runtime is constructed. */
|
|
1339
|
+
function snapshotEnvNames(option, names) {
|
|
1340
|
+
return names === void 0 ? void 0 : [...validateEnvNames(option, names)];
|
|
1341
|
+
}
|
|
1342
|
+
function inheritedNameFilter(policy) {
|
|
1343
|
+
const blocked = new Set((policy?.block ?? []).map(envNameKey));
|
|
1344
|
+
const allowed = policy?.allow ? new Set([...essentialNames(), ...policy.allow].map(envNameKey)) : void 0;
|
|
1345
|
+
return (name) => {
|
|
1346
|
+
const key = envNameKey(name);
|
|
1347
|
+
if (key.startsWith(AUTH_GRANT_PREFIX)) return true;
|
|
1348
|
+
if (blocked.has(key)) return false;
|
|
1349
|
+
return !allowed || allowed.has(key) || ESSENTIAL_PREFIXES.some((p) => key.startsWith(p));
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
/** Whether a parent environment name reaches agent children under this policy. */
|
|
1353
|
+
function isInheritedEnvName(policy, name) {
|
|
1354
|
+
return inheritedNameFilter(policy)(name);
|
|
1355
|
+
}
|
|
1356
|
+
/** Whether the policy changes inheritance at all; with neither list set it does not. */
|
|
1357
|
+
function hasInheritedEnvPolicy(policy) {
|
|
1358
|
+
return policy?.allow !== void 0 || (policy?.block?.length ?? 0) > 0;
|
|
1359
|
+
}
|
|
1360
|
+
/** Copy the parent environment, keeping only the names this policy lets children inherit. */
|
|
1361
|
+
function inheritParentEnvironment(policy) {
|
|
1362
|
+
const env = { ...process.env };
|
|
1363
|
+
if (!hasInheritedEnvPolicy(policy)) return env;
|
|
1364
|
+
validateEnvNames("agentProcessEnvAllow", policy?.allow ?? []);
|
|
1365
|
+
validateEnvNames("agentProcessEnvBlock", policy?.block ?? []);
|
|
1366
|
+
const inherits = inheritedNameFilter(policy);
|
|
1367
|
+
for (const name of Object.keys(env)) if (!inherits(name)) delete env[name];
|
|
1368
|
+
return env;
|
|
1369
|
+
}
|
|
1370
|
+
// src/acp/auth-env.ts
|
|
1297
1371
|
const AUTH_ENV_PREFIX = "ACPX_AUTH_";
|
|
1298
1372
|
function toEnvToken(value) {
|
|
1299
1373
|
return value.trim().replace(/[^a-zA-Z0-9]+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
|
|
@@ -1344,9 +1418,9 @@ function promotePrefixedAuthEnvironment(env) {
|
|
|
1344
1418
|
function validateAgentProcessEnv(agentProcessEnv) {
|
|
1345
1419
|
for (const [key, value] of Object.entries(agentProcessEnv ?? {})) if (typeof value !== "string" || key.includes("=") || key.includes("\0") || value.includes("\0")) throw new Error("Invalid agentProcessEnv: environment entries cannot contain NUL or names with '='");
|
|
1346
1420
|
}
|
|
1347
|
-
function buildAgentEnvironment(authCredentials, sessionEnv, agentProcessEnv) {
|
|
1421
|
+
function buildAgentEnvironment(authCredentials, sessionEnv, agentProcessEnv, inheritedEnv) {
|
|
1348
1422
|
validateAgentProcessEnv(agentProcessEnv);
|
|
1349
|
-
const env =
|
|
1423
|
+
const env = inheritParentEnvironment(inheritedEnv);
|
|
1350
1424
|
const protectedAuthEnvKeys = promotePrefixedAuthEnvironment(env);
|
|
1351
1425
|
if (authCredentials) for (const [methodId, credential] of Object.entries(authCredentials)) {
|
|
1352
1426
|
addAuthCredentialEnvKeys(protectedAuthEnvKeys, methodId, credential);
|
|
@@ -1396,10 +1470,10 @@ function resolveConfiguredAuthCredential(methodId, authCredentials) {
|
|
|
1396
1470
|
const configCredentials = authCredentials ?? {};
|
|
1397
1471
|
return configCredentials[methodId] ?? configCredentials[toEnvToken(methodId)];
|
|
1398
1472
|
}
|
|
1399
|
-
function buildAgentSpawnOptions(cwd, authCredentials, sessionEnv, agentProcessEnv) {
|
|
1473
|
+
function buildAgentSpawnOptions(cwd, authCredentials, sessionEnv, agentProcessEnv, inheritedEnv) {
|
|
1400
1474
|
return {
|
|
1401
1475
|
cwd,
|
|
1402
|
-
env: buildAgentEnvironment(authCredentials, sessionEnv, agentProcessEnv),
|
|
1476
|
+
env: buildAgentEnvironment(authCredentials, sessionEnv, agentProcessEnv, inheritedEnv),
|
|
1403
1477
|
stdio: [
|
|
1404
1478
|
"pipe",
|
|
1405
1479
|
"pipe",
|
|
@@ -1408,8 +1482,7 @@ function buildAgentSpawnOptions(cwd, authCredentials, sessionEnv, agentProcessEn
|
|
|
1408
1482
|
windowsHide: true
|
|
1409
1483
|
};
|
|
1410
1484
|
}
|
|
1411
|
-
|
|
1412
|
-
//#region src/version.ts
|
|
1485
|
+
// src/version.ts
|
|
1413
1486
|
const UNKNOWN_VERSION = "0.0.0-unknown";
|
|
1414
1487
|
const MODULE_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
1415
1488
|
let cachedVersion = null;
|
|
@@ -1451,8 +1524,7 @@ function getAcpxVersion() {
|
|
|
1451
1524
|
cachedVersion = resolveAcpxVersion();
|
|
1452
1525
|
return cachedVersion;
|
|
1453
1526
|
}
|
|
1454
|
-
|
|
1455
|
-
//#region src/acp/client-protocol.ts
|
|
1527
|
+
// src/acp/client-protocol.ts
|
|
1456
1528
|
const DEVIN_COMPATIBILITY_CLIENT_CAPABILITIES_META = Object.freeze({ "cognition.ai/requestDiagnostics": true });
|
|
1457
1529
|
const DEVIN_COMPATIBILITY_CLIENT_NAME = "windsurf";
|
|
1458
1530
|
const DEFAULT_DEVIN_COMPATIBILITY_CLIENT_VERSION = "1.110.1";
|
|
@@ -1484,8 +1556,7 @@ function resolveClientCapabilities(params) {
|
|
|
1484
1556
|
_meta: DEVIN_COMPATIBILITY_CLIENT_CAPABILITIES_META
|
|
1485
1557
|
};
|
|
1486
1558
|
}
|
|
1487
|
-
|
|
1488
|
-
//#region src/acp/command-probe.ts
|
|
1559
|
+
// src/acp/command-probe.ts
|
|
1489
1560
|
var CommandProbeAdmissionError = class extends Error {
|
|
1490
1561
|
reason;
|
|
1491
1562
|
constructor(reason) {
|
|
@@ -1551,8 +1622,7 @@ function captureCommandProbeOutput(child, timeoutMs, retire) {
|
|
|
1551
1622
|
}
|
|
1552
1623
|
};
|
|
1553
1624
|
}
|
|
1554
|
-
|
|
1555
|
-
//#region src/acp/model-config-state.ts
|
|
1625
|
+
// src/acp/model-config-state.ts
|
|
1556
1626
|
function asRecord$2(value) {
|
|
1557
1627
|
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
1558
1628
|
return value;
|
|
@@ -1611,8 +1681,7 @@ function modelStateFromConfigOptions(configOptions) {
|
|
|
1611
1681
|
}
|
|
1612
1682
|
return selected;
|
|
1613
1683
|
}
|
|
1614
|
-
|
|
1615
|
-
//#region src/acp/model-support.ts
|
|
1684
|
+
// src/acp/model-support.ts
|
|
1616
1685
|
const REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE = "ACP_MODEL_UNSUPPORTED";
|
|
1617
1686
|
const REQUESTED_MODEL_UNSUPPORTED_REASONS = ["missing-capability", "unadvertised-model"];
|
|
1618
1687
|
var RequestedModelUnsupportedError = class extends Error {
|
|
@@ -1698,8 +1767,7 @@ function assertRequestedModelSupported(params) {
|
|
|
1698
1767
|
throw new RequestedModelUnsupportedError(`Cannot ${params.context === "replay" ? "replay saved model" : "apply --model"} "${params.requestedModel}": the ACP agent did not advertise that model. Available models: ${formatAvailableModelIds(params.models)}.`, "unadvertised-model");
|
|
1699
1768
|
}
|
|
1700
1769
|
}
|
|
1701
|
-
|
|
1702
|
-
//#region src/acp/ndjson-stream.ts
|
|
1770
|
+
// src/acp/ndjson-stream.ts
|
|
1703
1771
|
const DEFAULT_MAX_ACP_MESSAGE_BYTES = 67108864;
|
|
1704
1772
|
var AcpMessageLimitError = class extends AcpxOperationalError {
|
|
1705
1773
|
constructor(limit) {
|
|
@@ -1790,8 +1858,7 @@ function createNdJsonMessageStream(agentCommand, output, input, maxMessageBytes,
|
|
|
1790
1858
|
} })
|
|
1791
1859
|
};
|
|
1792
1860
|
}
|
|
1793
|
-
|
|
1794
|
-
//#region src/acp/observed-stream.ts
|
|
1861
|
+
// src/acp/observed-stream.ts
|
|
1795
1862
|
function observeAcpStream(base, options) {
|
|
1796
1863
|
const elicitationRequestIds = /* @__PURE__ */ new Set();
|
|
1797
1864
|
const shouldSuppressInboundReplaySessionUpdate = (message) => {
|
|
@@ -1858,8 +1925,7 @@ function promptRequestOwner(message) {
|
|
|
1858
1925
|
sessionId
|
|
1859
1926
|
} : void 0;
|
|
1860
1927
|
}
|
|
1861
|
-
|
|
1862
|
-
//#region src/acp/session-control-errors.ts
|
|
1928
|
+
// src/acp/session-control-errors.ts
|
|
1863
1929
|
const SESSION_CONTROL_UNSUPPORTED_ACP_CODES = /* @__PURE__ */ new Set([-32601, -32602]);
|
|
1864
1930
|
function asRecord$1(value) {
|
|
1865
1931
|
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
@@ -1885,8 +1951,7 @@ function maybeWrapSessionControlError(method, error, context) {
|
|
|
1885
1951
|
wrapped.acp = acp;
|
|
1886
1952
|
return wrapped;
|
|
1887
1953
|
}
|
|
1888
|
-
|
|
1889
|
-
//#region src/acp/terminal-manager.ts
|
|
1954
|
+
// src/acp/terminal-manager.ts
|
|
1890
1955
|
const DEFAULT_TERMINAL_OUTPUT_LIMIT_BYTES = 65536;
|
|
1891
1956
|
const DEFAULT_KILL_GRACE_MS = 1500;
|
|
1892
1957
|
function nowIso() {
|
|
@@ -1896,14 +1961,14 @@ function toCommandLine(command, args) {
|
|
|
1896
1961
|
const renderedArgs = (args ?? []).map((arg) => JSON.stringify(arg)).join(" ");
|
|
1897
1962
|
return renderedArgs.length > 0 ? `${command} ${renderedArgs}` : command;
|
|
1898
1963
|
}
|
|
1899
|
-
function toEnvObject(env) {
|
|
1900
|
-
if (!env
|
|
1901
|
-
const merged =
|
|
1902
|
-
for (const entry of env) merged[entry.name] = entry.value;
|
|
1964
|
+
function toEnvObject(env, inheritedEnv) {
|
|
1965
|
+
if (!env?.length && !hasInheritedEnvPolicy(inheritedEnv)) return;
|
|
1966
|
+
const merged = inheritParentEnvironment(inheritedEnv);
|
|
1967
|
+
for (const entry of env ?? []) merged[entry.name] = entry.value;
|
|
1903
1968
|
return merged;
|
|
1904
1969
|
}
|
|
1905
|
-
function buildTerminalSpawnOptions(command, cwd, env, platform = process.platform) {
|
|
1906
|
-
const resolvedEnv = toEnvObject(env);
|
|
1970
|
+
function buildTerminalSpawnOptions(command, cwd, env, platform = process.platform, inheritedEnv) {
|
|
1971
|
+
const resolvedEnv = toEnvObject(env, inheritedEnv);
|
|
1907
1972
|
return buildSpawnCommandOptions(command, {
|
|
1908
1973
|
cwd,
|
|
1909
1974
|
env: resolvedEnv,
|
|
@@ -1955,6 +2020,7 @@ function waitMs(ms) {
|
|
|
1955
2020
|
function onStreamError() {}
|
|
1956
2021
|
var TerminalManager = class {
|
|
1957
2022
|
cwd;
|
|
2023
|
+
inheritedEnv;
|
|
1958
2024
|
permissionMode;
|
|
1959
2025
|
nonInteractivePermissions;
|
|
1960
2026
|
onOperation;
|
|
@@ -1968,6 +2034,7 @@ var TerminalManager = class {
|
|
|
1968
2034
|
constructor(options) {
|
|
1969
2035
|
this.outputCeilingBytes = readTerminalOutputCeiling();
|
|
1970
2036
|
this.cwd = options.cwd;
|
|
2037
|
+
this.inheritedEnv = options.inheritedEnv;
|
|
1971
2038
|
this.permissionMode = options.permissionMode;
|
|
1972
2039
|
this.nonInteractivePermissions = options.nonInteractivePermissions ?? "deny";
|
|
1973
2040
|
this.onOperation = options.onOperation;
|
|
@@ -2004,7 +2071,10 @@ var TerminalManager = class {
|
|
|
2004
2071
|
assertControlAuthority(authority);
|
|
2005
2072
|
if (!approved) throw new PermissionDeniedError("Permission denied for terminal/create");
|
|
2006
2073
|
const outputByteLimit = resolveTerminalOutputLimit(params.outputByteLimit, this.outputCeilingBytes);
|
|
2007
|
-
const { proc, spawnCommand } = await spawnTerminalProcess(params,
|
|
2074
|
+
const { proc, spawnCommand } = await spawnTerminalProcess(params, {
|
|
2075
|
+
cwd: this.cwd,
|
|
2076
|
+
inheritedEnv: this.inheritedEnv
|
|
2077
|
+
}, authority);
|
|
2008
2078
|
let resolveExit = () => {};
|
|
2009
2079
|
const exitPromise = new Promise((resolve) => {
|
|
2010
2080
|
resolveExit = resolve;
|
|
@@ -2272,24 +2342,24 @@ var TerminalManager = class {
|
|
|
2272
2342
|
return true;
|
|
2273
2343
|
}
|
|
2274
2344
|
};
|
|
2275
|
-
async function spawnTerminalProcess(params,
|
|
2345
|
+
async function spawnTerminalProcess(params, context, authority) {
|
|
2276
2346
|
const directCommand = buildTerminalSpawnCommand(params.command, params.args);
|
|
2277
2347
|
try {
|
|
2278
2348
|
return {
|
|
2279
|
-
proc: await spawnAndWait(directCommand, params,
|
|
2349
|
+
proc: await spawnAndWait(directCommand, params, context, authority),
|
|
2280
2350
|
spawnCommand: directCommand
|
|
2281
2351
|
};
|
|
2282
2352
|
} catch (error) {
|
|
2283
|
-
const fallbackCommand = params.args === void 0 && isNotFoundSpawnError(error) ? buildTerminalFallbackSpawnCommand(params.command, params.cwd ??
|
|
2353
|
+
const fallbackCommand = params.args === void 0 && isNotFoundSpawnError(error) ? buildTerminalFallbackSpawnCommand(params.command, params.cwd ?? context.cwd) : void 0;
|
|
2284
2354
|
if (!fallbackCommand) throw error;
|
|
2285
2355
|
return {
|
|
2286
|
-
proc: await spawnAndWait(fallbackCommand, params,
|
|
2356
|
+
proc: await spawnAndWait(fallbackCommand, params, context, authority),
|
|
2287
2357
|
spawnCommand: fallbackCommand
|
|
2288
2358
|
};
|
|
2289
2359
|
}
|
|
2290
2360
|
}
|
|
2291
|
-
async function spawnAndWait(spawnCommand, params,
|
|
2292
|
-
const spawnOptions = buildTerminalSpawnOptions(spawnCommand.command, params.cwd ??
|
|
2361
|
+
async function spawnAndWait(spawnCommand, params, context, authority) {
|
|
2362
|
+
const spawnOptions = buildTerminalSpawnOptions(spawnCommand.command, params.cwd ?? context.cwd, params.env, process.platform, context.inheritedEnv);
|
|
2293
2363
|
if (process.platform !== "win32") spawnOptions.detached = true;
|
|
2294
2364
|
assertControlAuthority(authority);
|
|
2295
2365
|
const proc = spawn(spawnCommand.command, spawnCommand.args, spawnOptions);
|
|
@@ -2397,8 +2467,7 @@ function hasLivePid(pids) {
|
|
|
2397
2467
|
}
|
|
2398
2468
|
return false;
|
|
2399
2469
|
}
|
|
2400
|
-
|
|
2401
|
-
//#region src/acp/client.ts
|
|
2470
|
+
// src/acp/client.ts
|
|
2402
2471
|
const REPLAY_IDLE_MS = 80;
|
|
2403
2472
|
const REPLAY_DRAIN_TIMEOUT_MS = 5e3;
|
|
2404
2473
|
const DRAIN_POLL_INTERVAL_MS = 20;
|
|
@@ -2543,6 +2612,8 @@ var AcpClient = class {
|
|
|
2543
2612
|
...options,
|
|
2544
2613
|
cwd: asAbsoluteCwd(options.cwd),
|
|
2545
2614
|
agentProcessEnv: options.agentProcessEnv ? { ...options.agentProcessEnv } : void 0,
|
|
2615
|
+
agentProcessEnvAllow: snapshotEnvNames("agentProcessEnvAllow", options.agentProcessEnvAllow),
|
|
2616
|
+
agentProcessEnvBlock: snapshotEnvNames("agentProcessEnvBlock", options.agentProcessEnvBlock),
|
|
2546
2617
|
authPolicy: options.authPolicy ?? "skip",
|
|
2547
2618
|
permissionPolicy: snapshotPermissionPolicy(options.permissionPolicy),
|
|
2548
2619
|
elicitationModes: normalizeElicitationModes(options.elicitationModes)
|
|
@@ -2564,6 +2635,7 @@ var AcpClient = class {
|
|
|
2564
2635
|
});
|
|
2565
2636
|
this.terminalManager = new TerminalManager({
|
|
2566
2637
|
cwd: this.options.cwd,
|
|
2638
|
+
inheritedEnv: this.inheritedEnvPolicy(),
|
|
2567
2639
|
permissionMode: this.options.permissionMode,
|
|
2568
2640
|
nonInteractivePermissions: this.options.nonInteractivePermissions,
|
|
2569
2641
|
onOperation: (operation) => {
|
|
@@ -2725,7 +2797,7 @@ var AcpClient = class {
|
|
|
2725
2797
|
const configuredCommand = resolveAgentCommandParts(this.options.agentCommand, this.options.agentArgv);
|
|
2726
2798
|
const resolvedBuiltInLaunch = resolveBuiltInAgentLaunch(this.options.agentCommand);
|
|
2727
2799
|
const spawnCommand = resolvedBuiltInLaunch?.command ?? configuredCommand.command;
|
|
2728
|
-
const spawnOptions = buildAgentSpawnOptions(this.options.cwd, this.options.authCredentials, this.options.sessionOptions?.env, this.options.agentProcessEnv);
|
|
2800
|
+
const spawnOptions = buildAgentSpawnOptions(this.options.cwd, this.options.authCredentials, this.options.sessionOptions?.env, this.options.agentProcessEnv, this.inheritedEnvPolicy());
|
|
2729
2801
|
const commandContext = {
|
|
2730
2802
|
env: spawnOptions.env,
|
|
2731
2803
|
readOutput: async (command, args, timeoutMs, diagnostic = false) => {
|
|
@@ -3527,8 +3599,14 @@ var AcpClient = class {
|
|
|
3527
3599
|
if (agentManagedSelection) return agentManagedSelection;
|
|
3528
3600
|
}
|
|
3529
3601
|
}
|
|
3602
|
+
inheritedEnvPolicy() {
|
|
3603
|
+
return {
|
|
3604
|
+
allow: this.options.agentProcessEnvAllow,
|
|
3605
|
+
block: this.options.agentProcessEnvBlock
|
|
3606
|
+
};
|
|
3607
|
+
}
|
|
3530
3608
|
readAgentSpecificEnvCredential(methodId) {
|
|
3531
|
-
if (!this.isGrokBuildAcpCommand() || methodId !== "xai.api_key") return;
|
|
3609
|
+
if (!this.isGrokBuildAcpCommand() || methodId !== "xai.api_key" || !isInheritedEnvName(this.inheritedEnvPolicy(), "XAI_API_KEY")) return;
|
|
3532
3610
|
const value = process.env.XAI_API_KEY;
|
|
3533
3611
|
return typeof value === "string" && value.trim().length > 0 ? value : void 0;
|
|
3534
3612
|
}
|
|
@@ -3941,8 +4019,7 @@ var AcpClient = class {
|
|
|
3941
4019
|
await this.waitForSessionUpdateDrain(options?.idleMs ?? 0, options?.timeoutMs ?? 0);
|
|
3942
4020
|
}
|
|
3943
4021
|
};
|
|
3944
|
-
|
|
3945
|
-
//#region src/session/model-state.ts
|
|
4022
|
+
// src/session/model-state.ts
|
|
3946
4023
|
function configOptionsAreAuthoritative(state) {
|
|
3947
4024
|
return state.model_control === "config_option";
|
|
3948
4025
|
}
|
|
@@ -3989,8 +4066,7 @@ function applyConfigOptionsModelState(state, configOptions) {
|
|
|
3989
4066
|
else if (preservesLegacyControl) state.model_control = "legacy_set_model";
|
|
3990
4067
|
else clearAdvertisedModelState(state);
|
|
3991
4068
|
}
|
|
3992
|
-
|
|
3993
|
-
//#region src/session/conversation-reducer.ts
|
|
4069
|
+
// src/session/conversation-reducer.ts
|
|
3994
4070
|
function resolveUserMessageId(value) {
|
|
3995
4071
|
return typeof value === "string" ? value : value();
|
|
3996
4072
|
}
|
|
@@ -4437,8 +4513,7 @@ function applySessionInfoUpdate(conversation, update) {
|
|
|
4437
4513
|
if (hasOwn(update, "title")) conversation.title = update.title ?? null;
|
|
4438
4514
|
if (hasOwn(update, "updatedAt")) conversation.updated_at = update.updatedAt ?? conversation.updated_at;
|
|
4439
4515
|
}
|
|
4440
|
-
|
|
4441
|
-
//#region src/session/conversation-retention.ts
|
|
4516
|
+
// src/session/conversation-retention.ts
|
|
4442
4517
|
const MAX_RUNTIME_MESSAGES = 200;
|
|
4443
4518
|
const MAX_RUNTIME_AGENT_TEXT_CHARS = 8e3;
|
|
4444
4519
|
const MAX_RUNTIME_THINKING_CHARS = 4e3;
|
|
@@ -4483,8 +4558,7 @@ function trimRuntimeToolResult(result) {
|
|
|
4483
4558
|
if ("Text" in result.content) result.content.Text = trimRuntimeText(result.content.Text, MAX_RUNTIME_TOOL_IO_CHARS);
|
|
4484
4559
|
if (typeof result.output === "string") result.output = trimRuntimeText(result.output, MAX_RUNTIME_TOOL_IO_CHARS);
|
|
4485
4560
|
}
|
|
4486
|
-
|
|
4487
|
-
//#region src/session/conversation-model.ts
|
|
4561
|
+
// src/session/conversation-model.ts
|
|
4488
4562
|
function isoNow() {
|
|
4489
4563
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
4490
4564
|
}
|
|
@@ -4516,8 +4590,7 @@ function recordClientOperation(conversation, state, _operation, timestamp = isoN
|
|
|
4516
4590
|
trimConversationForRuntime(conversation);
|
|
4517
4591
|
return acpx;
|
|
4518
4592
|
}
|
|
4519
|
-
|
|
4520
|
-
//#region src/runtime/engine/lifecycle.ts
|
|
4593
|
+
// src/runtime/engine/lifecycle.ts
|
|
4521
4594
|
function createInitialSessionRecord(params) {
|
|
4522
4595
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4523
4596
|
return {
|
|
@@ -4582,8 +4655,7 @@ function applyConversation(record, conversation) {
|
|
|
4582
4655
|
record.cumulative_cost = conversation.cumulative_cost;
|
|
4583
4656
|
record.request_token_usage = conversation.request_token_usage;
|
|
4584
4657
|
}
|
|
4585
|
-
|
|
4586
|
-
//#region src/runtime/engine/session-options.ts
|
|
4658
|
+
// src/runtime/engine/session-options.ts
|
|
4587
4659
|
function mergeSessionOptions(preferred, fallback) {
|
|
4588
4660
|
const merged = { ...fallback };
|
|
4589
4661
|
assignDefinedOption(merged, "model", preferred?.model);
|
|
@@ -4681,8 +4753,7 @@ function storedMaxTurns(value) {
|
|
|
4681
4753
|
function nonEmptyString(value) {
|
|
4682
4754
|
return typeof value === "string" && value.trim().length > 0 ? value : void 0;
|
|
4683
4755
|
}
|
|
4684
|
-
|
|
4685
|
-
//#region src/session/mode-preference.ts
|
|
4756
|
+
// src/session/mode-preference.ts
|
|
4686
4757
|
function ensureAcpxState(state) {
|
|
4687
4758
|
return state ?? {};
|
|
4688
4759
|
}
|
|
@@ -4727,8 +4798,7 @@ function syncAdvertisedModelState(record, models) {
|
|
|
4727
4798
|
applyAdvertisedModelState(acpx, models);
|
|
4728
4799
|
record.acpx = acpx;
|
|
4729
4800
|
}
|
|
4730
|
-
|
|
4731
|
-
//#region src/session/model-application.ts
|
|
4801
|
+
// src/session/model-application.ts
|
|
4732
4802
|
function currentModelIdFromSetModelResponse(response, fallbackModelId) {
|
|
4733
4803
|
return modelStateFromConfigOptions(response?.configOptions)?.currentModelId ?? fallbackModelId;
|
|
4734
4804
|
}
|
|
@@ -4759,8 +4829,7 @@ async function applyRequestedModelIfAdvertised(params) {
|
|
|
4759
4829
|
response: await withTimeout(params.client.setSessionModel(params.sessionId, requestedModel, params.models, params.authority), params.timeoutMs)
|
|
4760
4830
|
};
|
|
4761
4831
|
}
|
|
4762
|
-
|
|
4763
|
-
//#region src/session/config-options.ts
|
|
4832
|
+
// src/session/config-options.ts
|
|
4764
4833
|
function applyConfigOptionsToState(state, configOptions) {
|
|
4765
4834
|
const acpxState = cloneSessionAcpxState(state) ?? {};
|
|
4766
4835
|
applyConfigOptionsModelState(acpxState, configOptions);
|
|
@@ -4824,8 +4893,7 @@ function applyConfigOptionSelection(state, configId, value, response, modelConfi
|
|
|
4824
4893
|
value
|
|
4825
4894
|
});
|
|
4826
4895
|
}
|
|
4827
|
-
|
|
4828
|
-
//#region src/session/execution/direct-lifetime.ts
|
|
4896
|
+
// src/session/execution/direct-lifetime.ts
|
|
4829
4897
|
function ownDirectClient(client, signal) {
|
|
4830
4898
|
let closing;
|
|
4831
4899
|
const cancel = async () => {
|
|
@@ -4848,8 +4916,7 @@ function ownDirectClient(client, signal) {
|
|
|
4848
4916
|
function directExecutionError(error, signal) {
|
|
4849
4917
|
return signal?.aborted && error instanceof AgentDisconnectedError ? signal.reason : error;
|
|
4850
4918
|
}
|
|
4851
|
-
|
|
4852
|
-
//#region src/runtime/engine/reconnect.ts
|
|
4919
|
+
// src/runtime/engine/reconnect.ts
|
|
4853
4920
|
const SESSION_LOAD_UNSUPPORTED_CODES = /* @__PURE__ */ new Set([-32601, -32602]);
|
|
4854
4921
|
function createReplayState(authority) {
|
|
4855
4922
|
let failure;
|
|
@@ -5249,8 +5316,7 @@ async function createFreshRuntimeSession(client, record, timeoutMs, authority) {
|
|
|
5249
5316
|
createdFreshSession: true
|
|
5250
5317
|
};
|
|
5251
5318
|
}
|
|
5252
|
-
|
|
5253
|
-
//#region src/runtime/engine/connected-session.ts
|
|
5319
|
+
// src/runtime/engine/connected-session.ts
|
|
5254
5320
|
function createActiveSessionController(params) {
|
|
5255
5321
|
const getActiveSessionId = () => params.getActiveSessionId();
|
|
5256
5322
|
return {
|
|
@@ -5360,8 +5426,7 @@ async function withConnectedSession(options) {
|
|
|
5360
5426
|
await options.saveRecord(record).catch(() => {});
|
|
5361
5427
|
}
|
|
5362
5428
|
}
|
|
5363
|
-
|
|
5364
|
-
//#region src/session/execution/prompt-runner.ts
|
|
5429
|
+
// src/session/execution/prompt-runner.ts
|
|
5365
5430
|
function buildDirectConnectedSessionOptions(options, run) {
|
|
5366
5431
|
return {
|
|
5367
5432
|
sessionRecordId: options.sessionRecordId,
|
|
@@ -5467,8 +5532,7 @@ async function runSessionSetConfigOptionDirect(options) {
|
|
|
5467
5532
|
loadError: result.loadError
|
|
5468
5533
|
};
|
|
5469
5534
|
}
|
|
5470
|
-
|
|
5471
|
-
//#region src/session/execution/windows-process-command.ts
|
|
5535
|
+
// src/session/execution/windows-process-command.ts
|
|
5472
5536
|
function skipSeparators(value) {
|
|
5473
5537
|
return value.replace(/^[ \t]+/u, "");
|
|
5474
5538
|
}
|
|
@@ -5550,8 +5614,7 @@ function splitWindowsProcessCommandLine(commandLine) {
|
|
|
5550
5614
|
}
|
|
5551
5615
|
return argv;
|
|
5552
5616
|
}
|
|
5553
|
-
|
|
5554
|
-
//#region src/session/execution/session-control.ts
|
|
5617
|
+
// src/session/execution/session-control.ts
|
|
5555
5618
|
async function cancelSessionPrompt(options) {
|
|
5556
5619
|
const cancelled = await tryCancelOnRunningOwner(options);
|
|
5557
5620
|
return {
|
|
@@ -5761,8 +5824,7 @@ async function closeSession(sessionId) {
|
|
|
5761
5824
|
await ownership[Symbol.asyncDispose]();
|
|
5762
5825
|
}
|
|
5763
5826
|
}
|
|
5764
|
-
|
|
5765
|
-
//#region src/session/execution/session-management.ts
|
|
5827
|
+
// src/session/execution/session-management.ts
|
|
5766
5828
|
async function createSessionRecordWithClient(client, options, resumedRecordId) {
|
|
5767
5829
|
const cwd = absolutePath(options.cwd);
|
|
5768
5830
|
await withTimeout(client.start({ signal: options.signal }), options.timeoutMs);
|
|
@@ -6013,8 +6075,7 @@ async function ensureSessionWithOwnership(options, cwd) {
|
|
|
6013
6075
|
created: true
|
|
6014
6076
|
};
|
|
6015
6077
|
}
|
|
6016
|
-
|
|
6017
|
-
//#region src/perf-metrics-capture.ts
|
|
6078
|
+
// src/perf-metrics-capture.ts
|
|
6018
6079
|
const PERF_METRICS_FILE_ENV = "ACPX_PERF_METRICS_FILE";
|
|
6019
6080
|
let installed = false;
|
|
6020
6081
|
let flushed = false;
|
|
@@ -6098,8 +6159,7 @@ function installPerfMetricsCapture(options = {}) {
|
|
|
6098
6159
|
process.once(signal, handler);
|
|
6099
6160
|
}
|
|
6100
6161
|
}
|
|
6101
|
-
|
|
6102
|
-
//#region src/session/queue/control-admission.ts
|
|
6162
|
+
// src/session/queue/control-admission.ts
|
|
6103
6163
|
var QueueControlDeadline = class {
|
|
6104
6164
|
controller = new AbortController();
|
|
6105
6165
|
admissionSignal;
|
|
@@ -6268,8 +6328,7 @@ var QueueOwnerControlAdmission = class {
|
|
|
6268
6328
|
return operation;
|
|
6269
6329
|
}
|
|
6270
6330
|
};
|
|
6271
|
-
|
|
6272
|
-
//#region src/session/queue/owner-turn-controller.ts
|
|
6331
|
+
// src/session/queue/owner-turn-controller.ts
|
|
6273
6332
|
var QueueOwnerTurnController = class {
|
|
6274
6333
|
state = "idle";
|
|
6275
6334
|
pendingCancel = false;
|
|
@@ -6330,8 +6389,7 @@ var QueueOwnerTurnController = class {
|
|
|
6330
6389
|
return cancelled;
|
|
6331
6390
|
}
|
|
6332
6391
|
};
|
|
6333
|
-
|
|
6334
|
-
//#region src/session/execution/owned-controls.ts
|
|
6392
|
+
// src/session/execution/owned-controls.ts
|
|
6335
6393
|
async function acceptControl(options, invoke, apply, deadline = new QueueControlDeadline()) {
|
|
6336
6394
|
deadline.assertActive();
|
|
6337
6395
|
const raw = invoke(deadline.authority).then(async (response) => {
|
|
@@ -6462,8 +6520,7 @@ async function runIdleOwnerControl(options, invoke) {
|
|
|
6462
6520
|
await ownership[Symbol.asyncDispose]();
|
|
6463
6521
|
}
|
|
6464
6522
|
}
|
|
6465
|
-
|
|
6466
|
-
//#region src/session/execution/queue-owner-process.ts
|
|
6523
|
+
// src/session/execution/queue-owner-process.ts
|
|
6467
6524
|
function isNonEmptyStringArray(value) {
|
|
6468
6525
|
return Array.isArray(value) && value.length > 0 && value.every((entry) => typeof entry === "string" && entry.length > 0);
|
|
6469
6526
|
}
|
|
@@ -6635,8 +6692,7 @@ function spawnQueueOwnerProcess(options, queueOwnerArgs) {
|
|
|
6635
6692
|
stopStartupCapture
|
|
6636
6693
|
};
|
|
6637
6694
|
}
|
|
6638
|
-
|
|
6639
|
-
//#region src/runtime/engine/prompt-turn.ts
|
|
6695
|
+
// src/runtime/engine/prompt-turn.ts
|
|
6640
6696
|
const SESSION_REPLY_IDLE_MS = 1e3;
|
|
6641
6697
|
const SESSION_REPLY_DRAIN_TIMEOUT_MS = 5e3;
|
|
6642
6698
|
function responseMetaField(meta) {
|
|
@@ -6692,8 +6748,7 @@ async function runPromptTurn(params) {
|
|
|
6692
6748
|
lifetime.abort();
|
|
6693
6749
|
}
|
|
6694
6750
|
}
|
|
6695
|
-
|
|
6696
|
-
//#region src/session/live-checkpoint.ts
|
|
6751
|
+
// src/session/live-checkpoint.ts
|
|
6697
6752
|
const DEFAULT_LIVE_CHECKPOINT_INTERVAL_MS = 500;
|
|
6698
6753
|
var LiveSessionCheckpoint = class {
|
|
6699
6754
|
save;
|
|
@@ -6750,8 +6805,7 @@ var LiveSessionCheckpoint = class {
|
|
|
6750
6805
|
}
|
|
6751
6806
|
}
|
|
6752
6807
|
};
|
|
6753
|
-
|
|
6754
|
-
//#region src/session/execution/discard-output.ts
|
|
6808
|
+
// src/session/execution/discard-output.ts
|
|
6755
6809
|
const DISCARD_OUTPUT_FORMATTER = {
|
|
6756
6810
|
setContext() {},
|
|
6757
6811
|
onAcpMessage() {},
|
|
@@ -6759,8 +6813,7 @@ const DISCARD_OUTPUT_FORMATTER = {
|
|
|
6759
6813
|
onPermissionEscalation() {},
|
|
6760
6814
|
flush() {}
|
|
6761
6815
|
};
|
|
6762
|
-
|
|
6763
|
-
//#region src/session/execution/runtime.ts
|
|
6816
|
+
// src/session/execution/runtime.ts
|
|
6764
6817
|
const INTERRUPT_CANCEL_WAIT_MS = 2500;
|
|
6765
6818
|
var QueueTaskOutputFormatter = class {
|
|
6766
6819
|
requestId;
|
|
@@ -7709,8 +7762,7 @@ async function sendSessionDirect(options, control) {
|
|
|
7709
7762
|
await closeProvidedClient?.();
|
|
7710
7763
|
}
|
|
7711
7764
|
}
|
|
7712
|
-
|
|
7713
|
-
//#region src/session/execution/queue-owner-runtime.ts
|
|
7765
|
+
// src/session/execution/queue-owner-runtime.ts
|
|
7714
7766
|
const QUEUE_OWNER_STARTUP_MAX_ATTEMPTS = 120;
|
|
7715
7767
|
const QUEUE_OWNER_HEARTBEAT_INTERVAL_MS = 5e3;
|
|
7716
7768
|
const QUEUE_OWNER_ACTIVE_TURN_CANCEL_GRACE_MS = 750;
|
|
@@ -8119,7 +8171,6 @@ async function sendSession(options) {
|
|
|
8119
8171
|
}
|
|
8120
8172
|
}
|
|
8121
8173
|
const queueOwnerRuntimeTestInternals = { queueOwnerExitIsFatal };
|
|
8122
|
-
|
|
8123
|
-
export { isRequestedModelUnsupportedError as $, applyInitialModelSelection as A, reconcileAgentSessionId as B, setSessionModeOnOwner as C, connectAndLoadSession as D, withConnectedSession as E, persistSessionOptions as F, recordSessionUpdate as G, createSessionConversation as H, sessionOptionsFromRecord as I, advertisedModelState as J, trimConversationForRuntime as K, applyConversation as L, applyRequestedModelIfAdvertised as M, setDesiredModeId as N, applyConfigOptionSelection as O, normalizeSessionOptionShape as P, RequestedModelUnsupportedError as Q, applyLifecycleSnapshotToRecord as R, setSessionMode as S, setSessionModelOnOwner as T, recordClientOperation as U, cloneSessionConversation as V, recordPromptSubmission as W, REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE as X, AcpClient as Y, REQUESTED_MODEL_UNSUPPORTED_REASONS as Z, cancelSessionPrompt as _, runQueuedTask as a, normalizeQueueOwnerTtlMs as at, setSessionConfigOption as b, LiveSessionCheckpoint as c, listSessionEvents as ct, flushPerfMetricsCapture as d, TimeoutError as dt, resolveRequestedConfigOption as et, installPerfMetricsCapture as f, assertControlAuthority as ft, listAgentSessions as g, ensureSession as h, runOnce as i, DEFAULT_QUEUE_OWNER_TTL_MS as it, applyModelSelection as j, applyConfigOptionsToRecord as k, runPromptTurn as l, isLegacyZedCodexAcpInvocation as lt, createSessionWithClient as m, withTimeout as mt, runSessionQueueOwner as n, getAcpxVersion as nt, sendSessionDirect as o, acquireSessionImport as ot, createSession as p, withInterrupt as pt, cloneSessionAcpxState as q, sendSession as r, permissionModeSatisfies as rt, DISCARD_OUTPUT_FORMATTER as s, acquireSessionScope as st, queueOwnerRuntimeTestInternals as t, resolveRequestedModelId as tt, buildQueueOwnerArgOverride as u, InterruptedError as ut, closeSession as v, setSessionModel as w, setSessionConfigOptionOnOwner as x, sessionControlTestInternals as y, createInitialSessionRecord as z };
|
|
8174
|
+
export { isRequestedModelUnsupportedError as $, applyInitialModelSelection as A, reconcileAgentSessionId as B, setSessionModeOnOwner as C, connectAndLoadSession as D, withConnectedSession as E, persistSessionOptions as F, recordSessionUpdate as G, createSessionConversation as H, sessionOptionsFromRecord as I, advertisedModelState as J, trimConversationForRuntime as K, applyConversation as L, applyRequestedModelIfAdvertised as M, setDesiredModeId as N, applyConfigOptionSelection as O, normalizeSessionOptionShape as P, RequestedModelUnsupportedError as Q, applyLifecycleSnapshotToRecord as R, setSessionMode as S, setSessionModelOnOwner as T, recordClientOperation as U, cloneSessionConversation as V, recordPromptSubmission as W, REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE as X, AcpClient as Y, REQUESTED_MODEL_UNSUPPORTED_REASONS as Z, cancelSessionPrompt as _, runQueuedTask as a, DEFAULT_QUEUE_OWNER_TTL_MS as at, setSessionConfigOption as b, LiveSessionCheckpoint as c, acquireSessionScope as ct, flushPerfMetricsCapture as d, InterruptedError as dt, resolveRequestedConfigOption as et, installPerfMetricsCapture as f, TimeoutError as ft, listAgentSessions as g, ensureSession as h, withTimeout as ht, runOnce as i, permissionModeSatisfies as it, applyModelSelection as j, applyConfigOptionsToRecord as k, runPromptTurn as l, listSessionEvents as lt, createSessionWithClient as m, withInterrupt as mt, runSessionQueueOwner as n, getAcpxVersion as nt, sendSessionDirect as o, normalizeQueueOwnerTtlMs as ot, createSession as p, assertControlAuthority as pt, cloneSessionAcpxState as q, sendSession as r, snapshotEnvNames as rt, DISCARD_OUTPUT_FORMATTER as s, acquireSessionImport as st, queueOwnerRuntimeTestInternals as t, resolveRequestedModelId as tt, buildQueueOwnerArgOverride as u, isLegacyZedCodexAcpInvocation as ut, closeSession as v, setSessionModel as w, setSessionConfigOptionOnOwner as x, sessionControlTestInternals as y, createInitialSessionRecord as z };
|
|
8124
8175
|
|
|
8125
|
-
//# sourceMappingURL=queue-owner-runtime-
|
|
8176
|
+
//# sourceMappingURL=queue-owner-runtime-B0mPqOu4.js.map
|