acpx 0.20.0 → 0.21.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/dist/{cli-CnufHoAJ.js → cli-I6rP9FGr.js} +4 -4
- package/dist/{cli-CnufHoAJ.js.map → cli-I6rP9FGr.js.map} +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +7 -7
- package/dist/{client-R5OmZ--S.d.ts → client-BaAmQKNy.d.ts} +3 -2
- package/dist/{client-R5OmZ--S.d.ts.map → client-BaAmQKNy.d.ts.map} +1 -1
- package/dist/{flows-CTRAV28u.js → flows-7PaF7X66.js} +3 -3
- package/dist/{flows-CTRAV28u.js.map → flows-7PaF7X66.js.map} +1 -1
- package/dist/flows.d.ts +2 -2
- package/dist/flows.js +1 -1
- package/dist/{invocation-options-DE3Z_fqa.js → invocation-options-TRskRIuI.js} +12 -5
- package/dist/{invocation-options-DE3Z_fqa.js.map → invocation-options-TRskRIuI.js.map} +1 -1
- package/dist/ipc-D2BC99hf.js.map +1 -1
- package/dist/{output-B1Srnvko.js → output-CkfCaQfo.js} +2 -2
- package/dist/{output-B1Srnvko.js.map → output-CkfCaQfo.js.map} +1 -1
- package/dist/{queue-owner-runtime-Be8sr9L5.js → queue-owner-runtime-CNrWkR8J.js} +120 -21
- package/dist/queue-owner-runtime-CNrWkR8J.js.map +1 -0
- package/dist/runtime.d.ts +18 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +13 -3
- package/dist/runtime.js.map +1 -1
- package/dist/{session-options-DQlqgFv2.d.ts → session-options-DVr_JUL7.d.ts} +8 -1
- package/dist/session-options-DVr_JUL7.d.ts.map +1 -0
- package/dist/{session-watch-CpYYtV62.js → session-watch-BLLknspd.js} +2 -2
- package/dist/{session-watch-CpYYtV62.js.map → session-watch-BLLknspd.js.map} +1 -1
- package/package.json +2 -2
- package/skills/acpx/SKILL.md +26 -1
- package/dist/queue-owner-runtime-Be8sr9L5.js.map +0 -1
- package/dist/session-options-DQlqgFv2.d.ts.map +0 -1
|
@@ -1293,6 +1293,91 @@ function resolveClaudeCodeExecutable(platform = process.platform, env = process.
|
|
|
1293
1293
|
return resolveWindowsExecutablePath("claude", env, cwd);
|
|
1294
1294
|
}
|
|
1295
1295
|
//#endregion
|
|
1296
|
+
//#region src/acp/inherited-env.ts
|
|
1297
|
+
const AUTH_GRANT_PREFIX = "ACPX_AUTH_";
|
|
1298
|
+
const POSIX_ESSENTIAL_NAMES = [
|
|
1299
|
+
"PATH",
|
|
1300
|
+
"HOME",
|
|
1301
|
+
"USER",
|
|
1302
|
+
"LOGNAME",
|
|
1303
|
+
"SHELL",
|
|
1304
|
+
"LANG",
|
|
1305
|
+
"LANGUAGE",
|
|
1306
|
+
"TZ",
|
|
1307
|
+
"TMPDIR",
|
|
1308
|
+
"TMP",
|
|
1309
|
+
"TEMP"
|
|
1310
|
+
];
|
|
1311
|
+
const WINDOWS_ESSENTIAL_NAMES = [
|
|
1312
|
+
"SYSTEMROOT",
|
|
1313
|
+
"WINDIR",
|
|
1314
|
+
"SYSTEMDRIVE",
|
|
1315
|
+
"COMSPEC",
|
|
1316
|
+
"PATHEXT",
|
|
1317
|
+
"USERPROFILE",
|
|
1318
|
+
"HOMEDRIVE",
|
|
1319
|
+
"HOMEPATH",
|
|
1320
|
+
"USERNAME",
|
|
1321
|
+
"USERDOMAIN",
|
|
1322
|
+
"APPDATA",
|
|
1323
|
+
"LOCALAPPDATA",
|
|
1324
|
+
"PROGRAMDATA",
|
|
1325
|
+
"ALLUSERSPROFILE",
|
|
1326
|
+
"PROGRAMFILES",
|
|
1327
|
+
"PROGRAMFILES(X86)",
|
|
1328
|
+
"PROGRAMW6432",
|
|
1329
|
+
"COMMONPROGRAMFILES",
|
|
1330
|
+
"COMMONPROGRAMFILES(X86)",
|
|
1331
|
+
"COMMONPROGRAMW6432"
|
|
1332
|
+
];
|
|
1333
|
+
const ESSENTIAL_PREFIXES = ["LC_", "XDG_"];
|
|
1334
|
+
/** Environment name as compared on this platform: Windows names are case-insensitive. */
|
|
1335
|
+
function envNameKey(name) {
|
|
1336
|
+
return process.platform === "win32" ? name.toUpperCase() : name;
|
|
1337
|
+
}
|
|
1338
|
+
function essentialNames() {
|
|
1339
|
+
return process.platform === "win32" ? [...POSIX_ESSENTIAL_NAMES, ...WINDOWS_ESSENTIAL_NAMES] : POSIX_ESSENTIAL_NAMES;
|
|
1340
|
+
}
|
|
1341
|
+
function isEnvName(name) {
|
|
1342
|
+
return typeof name === "string" && name.length > 0 && !name.includes("=") && !name.includes("\0");
|
|
1343
|
+
}
|
|
1344
|
+
function validateEnvNames(option, names) {
|
|
1345
|
+
if (!Array.isArray(names) || !names.every(isEnvName)) throw new Error(`Invalid ${option}: expected an array of non-empty names without NUL or '='`);
|
|
1346
|
+
return names;
|
|
1347
|
+
}
|
|
1348
|
+
/** Validate and copy an embedder's name list once, when a client or runtime is constructed. */
|
|
1349
|
+
function snapshotEnvNames(option, names) {
|
|
1350
|
+
return names === void 0 ? void 0 : [...validateEnvNames(option, names)];
|
|
1351
|
+
}
|
|
1352
|
+
function inheritedNameFilter(policy) {
|
|
1353
|
+
const blocked = new Set((policy?.block ?? []).map(envNameKey));
|
|
1354
|
+
const allowed = policy?.allow ? new Set([...essentialNames(), ...policy.allow].map(envNameKey)) : void 0;
|
|
1355
|
+
return (name) => {
|
|
1356
|
+
const key = envNameKey(name);
|
|
1357
|
+
if (key.startsWith(AUTH_GRANT_PREFIX)) return true;
|
|
1358
|
+
if (blocked.has(key)) return false;
|
|
1359
|
+
return !allowed || allowed.has(key) || ESSENTIAL_PREFIXES.some((p) => key.startsWith(p));
|
|
1360
|
+
};
|
|
1361
|
+
}
|
|
1362
|
+
/** Whether a parent environment name reaches agent children under this policy. */
|
|
1363
|
+
function isInheritedEnvName(policy, name) {
|
|
1364
|
+
return inheritedNameFilter(policy)(name);
|
|
1365
|
+
}
|
|
1366
|
+
/** Whether the policy changes inheritance at all; with neither list set it does not. */
|
|
1367
|
+
function hasInheritedEnvPolicy(policy) {
|
|
1368
|
+
return policy?.allow !== void 0 || (policy?.block?.length ?? 0) > 0;
|
|
1369
|
+
}
|
|
1370
|
+
/** Copy the parent environment, keeping only the names this policy lets children inherit. */
|
|
1371
|
+
function inheritParentEnvironment(policy) {
|
|
1372
|
+
const env = { ...process.env };
|
|
1373
|
+
if (!hasInheritedEnvPolicy(policy)) return env;
|
|
1374
|
+
validateEnvNames("agentProcessEnvAllow", policy?.allow ?? []);
|
|
1375
|
+
validateEnvNames("agentProcessEnvBlock", policy?.block ?? []);
|
|
1376
|
+
const inherits = inheritedNameFilter(policy);
|
|
1377
|
+
for (const name of Object.keys(env)) if (!inherits(name)) delete env[name];
|
|
1378
|
+
return env;
|
|
1379
|
+
}
|
|
1380
|
+
//#endregion
|
|
1296
1381
|
//#region src/acp/auth-env.ts
|
|
1297
1382
|
const AUTH_ENV_PREFIX = "ACPX_AUTH_";
|
|
1298
1383
|
function toEnvToken(value) {
|
|
@@ -1344,9 +1429,9 @@ function promotePrefixedAuthEnvironment(env) {
|
|
|
1344
1429
|
function validateAgentProcessEnv(agentProcessEnv) {
|
|
1345
1430
|
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
1431
|
}
|
|
1347
|
-
function buildAgentEnvironment(authCredentials, sessionEnv, agentProcessEnv) {
|
|
1432
|
+
function buildAgentEnvironment(authCredentials, sessionEnv, agentProcessEnv, inheritedEnv) {
|
|
1348
1433
|
validateAgentProcessEnv(agentProcessEnv);
|
|
1349
|
-
const env =
|
|
1434
|
+
const env = inheritParentEnvironment(inheritedEnv);
|
|
1350
1435
|
const protectedAuthEnvKeys = promotePrefixedAuthEnvironment(env);
|
|
1351
1436
|
if (authCredentials) for (const [methodId, credential] of Object.entries(authCredentials)) {
|
|
1352
1437
|
addAuthCredentialEnvKeys(protectedAuthEnvKeys, methodId, credential);
|
|
@@ -1396,10 +1481,10 @@ function resolveConfiguredAuthCredential(methodId, authCredentials) {
|
|
|
1396
1481
|
const configCredentials = authCredentials ?? {};
|
|
1397
1482
|
return configCredentials[methodId] ?? configCredentials[toEnvToken(methodId)];
|
|
1398
1483
|
}
|
|
1399
|
-
function buildAgentSpawnOptions(cwd, authCredentials, sessionEnv, agentProcessEnv) {
|
|
1484
|
+
function buildAgentSpawnOptions(cwd, authCredentials, sessionEnv, agentProcessEnv, inheritedEnv) {
|
|
1400
1485
|
return {
|
|
1401
1486
|
cwd,
|
|
1402
|
-
env: buildAgentEnvironment(authCredentials, sessionEnv, agentProcessEnv),
|
|
1487
|
+
env: buildAgentEnvironment(authCredentials, sessionEnv, agentProcessEnv, inheritedEnv),
|
|
1403
1488
|
stdio: [
|
|
1404
1489
|
"pipe",
|
|
1405
1490
|
"pipe",
|
|
@@ -1896,14 +1981,14 @@ function toCommandLine(command, args) {
|
|
|
1896
1981
|
const renderedArgs = (args ?? []).map((arg) => JSON.stringify(arg)).join(" ");
|
|
1897
1982
|
return renderedArgs.length > 0 ? `${command} ${renderedArgs}` : command;
|
|
1898
1983
|
}
|
|
1899
|
-
function toEnvObject(env) {
|
|
1900
|
-
if (!env
|
|
1901
|
-
const merged =
|
|
1902
|
-
for (const entry of env) merged[entry.name] = entry.value;
|
|
1984
|
+
function toEnvObject(env, inheritedEnv) {
|
|
1985
|
+
if (!env?.length && !hasInheritedEnvPolicy(inheritedEnv)) return;
|
|
1986
|
+
const merged = inheritParentEnvironment(inheritedEnv);
|
|
1987
|
+
for (const entry of env ?? []) merged[entry.name] = entry.value;
|
|
1903
1988
|
return merged;
|
|
1904
1989
|
}
|
|
1905
|
-
function buildTerminalSpawnOptions(command, cwd, env, platform = process.platform) {
|
|
1906
|
-
const resolvedEnv = toEnvObject(env);
|
|
1990
|
+
function buildTerminalSpawnOptions(command, cwd, env, platform = process.platform, inheritedEnv) {
|
|
1991
|
+
const resolvedEnv = toEnvObject(env, inheritedEnv);
|
|
1907
1992
|
return buildSpawnCommandOptions(command, {
|
|
1908
1993
|
cwd,
|
|
1909
1994
|
env: resolvedEnv,
|
|
@@ -1955,6 +2040,7 @@ function waitMs(ms) {
|
|
|
1955
2040
|
function onStreamError() {}
|
|
1956
2041
|
var TerminalManager = class {
|
|
1957
2042
|
cwd;
|
|
2043
|
+
inheritedEnv;
|
|
1958
2044
|
permissionMode;
|
|
1959
2045
|
nonInteractivePermissions;
|
|
1960
2046
|
onOperation;
|
|
@@ -1968,6 +2054,7 @@ var TerminalManager = class {
|
|
|
1968
2054
|
constructor(options) {
|
|
1969
2055
|
this.outputCeilingBytes = readTerminalOutputCeiling();
|
|
1970
2056
|
this.cwd = options.cwd;
|
|
2057
|
+
this.inheritedEnv = options.inheritedEnv;
|
|
1971
2058
|
this.permissionMode = options.permissionMode;
|
|
1972
2059
|
this.nonInteractivePermissions = options.nonInteractivePermissions ?? "deny";
|
|
1973
2060
|
this.onOperation = options.onOperation;
|
|
@@ -2004,7 +2091,10 @@ var TerminalManager = class {
|
|
|
2004
2091
|
assertControlAuthority(authority);
|
|
2005
2092
|
if (!approved) throw new PermissionDeniedError("Permission denied for terminal/create");
|
|
2006
2093
|
const outputByteLimit = resolveTerminalOutputLimit(params.outputByteLimit, this.outputCeilingBytes);
|
|
2007
|
-
const { proc, spawnCommand } = await spawnTerminalProcess(params,
|
|
2094
|
+
const { proc, spawnCommand } = await spawnTerminalProcess(params, {
|
|
2095
|
+
cwd: this.cwd,
|
|
2096
|
+
inheritedEnv: this.inheritedEnv
|
|
2097
|
+
}, authority);
|
|
2008
2098
|
let resolveExit = () => {};
|
|
2009
2099
|
const exitPromise = new Promise((resolve) => {
|
|
2010
2100
|
resolveExit = resolve;
|
|
@@ -2272,24 +2362,24 @@ var TerminalManager = class {
|
|
|
2272
2362
|
return true;
|
|
2273
2363
|
}
|
|
2274
2364
|
};
|
|
2275
|
-
async function spawnTerminalProcess(params,
|
|
2365
|
+
async function spawnTerminalProcess(params, context, authority) {
|
|
2276
2366
|
const directCommand = buildTerminalSpawnCommand(params.command, params.args);
|
|
2277
2367
|
try {
|
|
2278
2368
|
return {
|
|
2279
|
-
proc: await spawnAndWait(directCommand, params,
|
|
2369
|
+
proc: await spawnAndWait(directCommand, params, context, authority),
|
|
2280
2370
|
spawnCommand: directCommand
|
|
2281
2371
|
};
|
|
2282
2372
|
} catch (error) {
|
|
2283
|
-
const fallbackCommand = params.args === void 0 && isNotFoundSpawnError(error) ? buildTerminalFallbackSpawnCommand(params.command, params.cwd ??
|
|
2373
|
+
const fallbackCommand = params.args === void 0 && isNotFoundSpawnError(error) ? buildTerminalFallbackSpawnCommand(params.command, params.cwd ?? context.cwd) : void 0;
|
|
2284
2374
|
if (!fallbackCommand) throw error;
|
|
2285
2375
|
return {
|
|
2286
|
-
proc: await spawnAndWait(fallbackCommand, params,
|
|
2376
|
+
proc: await spawnAndWait(fallbackCommand, params, context, authority),
|
|
2287
2377
|
spawnCommand: fallbackCommand
|
|
2288
2378
|
};
|
|
2289
2379
|
}
|
|
2290
2380
|
}
|
|
2291
|
-
async function spawnAndWait(spawnCommand, params,
|
|
2292
|
-
const spawnOptions = buildTerminalSpawnOptions(spawnCommand.command, params.cwd ??
|
|
2381
|
+
async function spawnAndWait(spawnCommand, params, context, authority) {
|
|
2382
|
+
const spawnOptions = buildTerminalSpawnOptions(spawnCommand.command, params.cwd ?? context.cwd, params.env, process.platform, context.inheritedEnv);
|
|
2293
2383
|
if (process.platform !== "win32") spawnOptions.detached = true;
|
|
2294
2384
|
assertControlAuthority(authority);
|
|
2295
2385
|
const proc = spawn(spawnCommand.command, spawnCommand.args, spawnOptions);
|
|
@@ -2543,6 +2633,8 @@ var AcpClient = class {
|
|
|
2543
2633
|
...options,
|
|
2544
2634
|
cwd: asAbsoluteCwd(options.cwd),
|
|
2545
2635
|
agentProcessEnv: options.agentProcessEnv ? { ...options.agentProcessEnv } : void 0,
|
|
2636
|
+
agentProcessEnvAllow: snapshotEnvNames("agentProcessEnvAllow", options.agentProcessEnvAllow),
|
|
2637
|
+
agentProcessEnvBlock: snapshotEnvNames("agentProcessEnvBlock", options.agentProcessEnvBlock),
|
|
2546
2638
|
authPolicy: options.authPolicy ?? "skip",
|
|
2547
2639
|
permissionPolicy: snapshotPermissionPolicy(options.permissionPolicy),
|
|
2548
2640
|
elicitationModes: normalizeElicitationModes(options.elicitationModes)
|
|
@@ -2564,6 +2656,7 @@ var AcpClient = class {
|
|
|
2564
2656
|
});
|
|
2565
2657
|
this.terminalManager = new TerminalManager({
|
|
2566
2658
|
cwd: this.options.cwd,
|
|
2659
|
+
inheritedEnv: this.inheritedEnvPolicy(),
|
|
2567
2660
|
permissionMode: this.options.permissionMode,
|
|
2568
2661
|
nonInteractivePermissions: this.options.nonInteractivePermissions,
|
|
2569
2662
|
onOperation: (operation) => {
|
|
@@ -2725,7 +2818,7 @@ var AcpClient = class {
|
|
|
2725
2818
|
const configuredCommand = resolveAgentCommandParts(this.options.agentCommand, this.options.agentArgv);
|
|
2726
2819
|
const resolvedBuiltInLaunch = resolveBuiltInAgentLaunch(this.options.agentCommand);
|
|
2727
2820
|
const spawnCommand = resolvedBuiltInLaunch?.command ?? configuredCommand.command;
|
|
2728
|
-
const spawnOptions = buildAgentSpawnOptions(this.options.cwd, this.options.authCredentials, this.options.sessionOptions?.env, this.options.agentProcessEnv);
|
|
2821
|
+
const spawnOptions = buildAgentSpawnOptions(this.options.cwd, this.options.authCredentials, this.options.sessionOptions?.env, this.options.agentProcessEnv, this.inheritedEnvPolicy());
|
|
2729
2822
|
const commandContext = {
|
|
2730
2823
|
env: spawnOptions.env,
|
|
2731
2824
|
readOutput: async (command, args, timeoutMs, diagnostic = false) => {
|
|
@@ -3527,8 +3620,14 @@ var AcpClient = class {
|
|
|
3527
3620
|
if (agentManagedSelection) return agentManagedSelection;
|
|
3528
3621
|
}
|
|
3529
3622
|
}
|
|
3623
|
+
inheritedEnvPolicy() {
|
|
3624
|
+
return {
|
|
3625
|
+
allow: this.options.agentProcessEnvAllow,
|
|
3626
|
+
block: this.options.agentProcessEnvBlock
|
|
3627
|
+
};
|
|
3628
|
+
}
|
|
3530
3629
|
readAgentSpecificEnvCredential(methodId) {
|
|
3531
|
-
if (!this.isGrokBuildAcpCommand() || methodId !== "xai.api_key") return;
|
|
3630
|
+
if (!this.isGrokBuildAcpCommand() || methodId !== "xai.api_key" || !isInheritedEnvName(this.inheritedEnvPolicy(), "XAI_API_KEY")) return;
|
|
3532
3631
|
const value = process.env.XAI_API_KEY;
|
|
3533
3632
|
return typeof value === "string" && value.trim().length > 0 ? value : void 0;
|
|
3534
3633
|
}
|
|
@@ -8120,6 +8219,6 @@ async function sendSession(options) {
|
|
|
8120
8219
|
}
|
|
8121
8220
|
const queueOwnerRuntimeTestInternals = { queueOwnerExitIsFatal };
|
|
8122
8221
|
//#endregion
|
|
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,
|
|
8222
|
+
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
8223
|
|
|
8125
|
-
//# sourceMappingURL=queue-owner-runtime-
|
|
8224
|
+
//# sourceMappingURL=queue-owner-runtime-CNrWkR8J.js.map
|