@buildautomaton/cli 0.1.36 → 0.1.37
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.js +124 -7
- package/dist/cli.js.map +4 -4
- package/dist/index.js +124 -7
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -25064,7 +25064,7 @@ var {
|
|
|
25064
25064
|
} = import_index.default;
|
|
25065
25065
|
|
|
25066
25066
|
// src/cli-version.ts
|
|
25067
|
-
var CLI_VERSION = "0.1.
|
|
25067
|
+
var CLI_VERSION = "0.1.37".length > 0 ? "0.1.37" : "0.0.0-dev";
|
|
25068
25068
|
|
|
25069
25069
|
// src/cli/defaults.ts
|
|
25070
25070
|
var DEFAULT_API_URL = process.env.BUILDAUTOMATON_API_URL ?? "https://api.buildautomaton.com";
|
|
@@ -27711,6 +27711,16 @@ function isClaudeCodePermissionMode(value) {
|
|
|
27711
27711
|
return MODE_SET.has(value);
|
|
27712
27712
|
}
|
|
27713
27713
|
|
|
27714
|
+
// ../types/src/codex-permission-mode.ts
|
|
27715
|
+
function isCodexPermissionMode(value) {
|
|
27716
|
+
return value.trim() !== "";
|
|
27717
|
+
}
|
|
27718
|
+
function normalizeCodexPermissionModeInput(raw) {
|
|
27719
|
+
if (typeof raw !== "string") return null;
|
|
27720
|
+
const t = raw.trim();
|
|
27721
|
+
return isCodexPermissionMode(t) ? t : null;
|
|
27722
|
+
}
|
|
27723
|
+
|
|
27714
27724
|
// ../types/src/cli-permission-mode.ts
|
|
27715
27725
|
var CLI_PERMISSION_MODE_DEFAULT = "default";
|
|
27716
27726
|
var CLI_PERMISSION_MODE_DANGEROUS = "dangerous";
|
|
@@ -27782,6 +27792,7 @@ function buildCliAutoApprovedPermissionRpcResult(requestParams) {
|
|
|
27782
27792
|
// ../types/src/agent-config.ts
|
|
27783
27793
|
var AGENT_CONFIG_CLAUDE_PERMISSION_MODE_KEY = "claude_permission_mode";
|
|
27784
27794
|
var AGENT_CONFIG_CLI_PERMISSION_MODE_KEY = "cli_permission_mode";
|
|
27795
|
+
var AGENT_CONFIG_CODEX_PERMISSION_MODE_KEY = "codex_permission_mode";
|
|
27785
27796
|
var AGENT_CONFIG_AGENT_MODEL_KEY = "agent_model";
|
|
27786
27797
|
function getClaudePermissionModeFromAgentConfig(config2) {
|
|
27787
27798
|
if (!config2) return null;
|
|
@@ -27794,6 +27805,10 @@ function getCliPermissionModeFromAgentConfig(config2) {
|
|
|
27794
27805
|
if (!config2) return CLI_PERMISSION_MODE_DEFAULT;
|
|
27795
27806
|
return normalizeCliPermissionModeInput(config2[AGENT_CONFIG_CLI_PERMISSION_MODE_KEY]);
|
|
27796
27807
|
}
|
|
27808
|
+
function getCodexPermissionModeFromAgentConfig(config2) {
|
|
27809
|
+
if (!config2) return null;
|
|
27810
|
+
return normalizeCodexPermissionModeInput(config2[AGENT_CONFIG_CODEX_PERMISSION_MODE_KEY]);
|
|
27811
|
+
}
|
|
27797
27812
|
function getAgentModelFromAgentConfig(config2) {
|
|
27798
27813
|
if (!config2) return null;
|
|
27799
27814
|
const cur = config2[AGENT_CONFIG_AGENT_MODEL_KEY];
|
|
@@ -33394,8 +33409,60 @@ async function applyClaudePermissionFromAcpSession(params) {
|
|
|
33394
33409
|
}
|
|
33395
33410
|
}
|
|
33396
33411
|
|
|
33397
|
-
// src/agents/acp/
|
|
33412
|
+
// src/agents/acp/codex-acp-permission-from-session.ts
|
|
33398
33413
|
function flattenSelectOptions2(options) {
|
|
33414
|
+
if (options == null || options.length === 0) return [];
|
|
33415
|
+
const first2 = options[0];
|
|
33416
|
+
if (first2 != null && typeof first2 === "object" && "group" in first2 && first2.group != null) {
|
|
33417
|
+
return options.flatMap(
|
|
33418
|
+
(g) => Array.isArray(g.options) ? g.options : []
|
|
33419
|
+
);
|
|
33420
|
+
}
|
|
33421
|
+
return options;
|
|
33422
|
+
}
|
|
33423
|
+
function pickModeConfigOption2(configOptions) {
|
|
33424
|
+
if (configOptions == null || configOptions.length === 0) return null;
|
|
33425
|
+
const byCategory = configOptions.find((o) => o.category === "mode");
|
|
33426
|
+
if (byCategory) return byCategory;
|
|
33427
|
+
return configOptions.find((o) => o.id === "mode") ?? null;
|
|
33428
|
+
}
|
|
33429
|
+
async function applyCodexPermissionFromAcpSession(params) {
|
|
33430
|
+
const { sessionId, agentConfig, configOptions, modes, setSessionConfigOption, setSessionMode, logDebug: logDebug2 } = params;
|
|
33431
|
+
const desiredMode = getCodexPermissionModeFromAgentConfig(agentConfig);
|
|
33432
|
+
if (desiredMode == null) return;
|
|
33433
|
+
const modeOpt = pickModeConfigOption2(configOptions ?? null);
|
|
33434
|
+
if (modeOpt != null) {
|
|
33435
|
+
const flat = flattenSelectOptions2(modeOpt.options);
|
|
33436
|
+
const allowed = flat.some((o) => o.value === desiredMode);
|
|
33437
|
+
if (allowed && modeOpt.currentValue !== desiredMode) {
|
|
33438
|
+
try {
|
|
33439
|
+
logDebug2(
|
|
33440
|
+
`[Agent] Codex: sending ACP session/set_config_option (mode) configId=${JSON.stringify(modeOpt.id)} value=${JSON.stringify(desiredMode)} was=${JSON.stringify(modeOpt.currentValue)} sessionId=${sessionId.slice(0, 8)}\u2026`
|
|
33441
|
+
);
|
|
33442
|
+
await setSessionConfigOption({ sessionId, configId: modeOpt.id, value: desiredMode });
|
|
33443
|
+
} catch (e) {
|
|
33444
|
+
logDebug2(`[Agent] Codex: session/set_config_option failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
33445
|
+
}
|
|
33446
|
+
}
|
|
33447
|
+
return;
|
|
33448
|
+
}
|
|
33449
|
+
if (modes?.availableModes?.length) {
|
|
33450
|
+
const allowed = modes.availableModes.some((m) => m.id === desiredMode);
|
|
33451
|
+
if (allowed && desiredMode !== modes.currentModeId) {
|
|
33452
|
+
try {
|
|
33453
|
+
logDebug2(
|
|
33454
|
+
`[Agent] Codex: sending ACP session/set_mode modeId=${JSON.stringify(desiredMode)} was=${JSON.stringify(modes.currentModeId ?? null)} sessionId=${sessionId.slice(0, 8)}\u2026`
|
|
33455
|
+
);
|
|
33456
|
+
await setSessionMode({ sessionId, modeId: desiredMode });
|
|
33457
|
+
} catch (e) {
|
|
33458
|
+
logDebug2(`[Agent] Codex: session/set_mode failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
33459
|
+
}
|
|
33460
|
+
}
|
|
33461
|
+
}
|
|
33462
|
+
}
|
|
33463
|
+
|
|
33464
|
+
// src/agents/acp/apply-acp-model-from-agent-session.ts
|
|
33465
|
+
function flattenSelectOptions3(options) {
|
|
33399
33466
|
if (options == null || options.length === 0) return [];
|
|
33400
33467
|
const first2 = options[0];
|
|
33401
33468
|
if (first2 != null && typeof first2 === "object" && "group" in first2 && first2.group != null) {
|
|
@@ -33420,7 +33487,7 @@ async function applyAcpModelFromAcpSession(params) {
|
|
|
33420
33487
|
if (desired == null) return;
|
|
33421
33488
|
const modelOpt = pickModelConfigOption(configOptions ?? null);
|
|
33422
33489
|
if (modelOpt == null) return;
|
|
33423
|
-
const flat =
|
|
33490
|
+
const flat = flattenSelectOptions3(modelOpt.options);
|
|
33424
33491
|
const allowed = flat.some((o) => o.value === desired);
|
|
33425
33492
|
if (!allowed) return;
|
|
33426
33493
|
if (modelOpt.currentValue === desired) return;
|
|
@@ -33500,12 +33567,41 @@ function parseAcpInitAgentCapabilities(initResult) {
|
|
|
33500
33567
|
}
|
|
33501
33568
|
|
|
33502
33569
|
// src/agents/acp/clients/shared/bootstrap-acp-wire-session.ts
|
|
33570
|
+
function configOptionsWithModes(configOptions, modes) {
|
|
33571
|
+
const modeState = modes && typeof modes === "object" ? modes : null;
|
|
33572
|
+
if (!modeState?.availableModes?.length) return configOptions;
|
|
33573
|
+
const hasModeConfig = Array.isArray(configOptions) && configOptions.some((raw) => {
|
|
33574
|
+
if (raw == null || typeof raw !== "object" || Array.isArray(raw)) return false;
|
|
33575
|
+
const o = raw;
|
|
33576
|
+
return o.category === "mode" || o.id === "mode";
|
|
33577
|
+
});
|
|
33578
|
+
if (hasModeConfig) return configOptions;
|
|
33579
|
+
return [
|
|
33580
|
+
...configOptions ?? [],
|
|
33581
|
+
{
|
|
33582
|
+
id: "mode",
|
|
33583
|
+
name: "Mode",
|
|
33584
|
+
type: "select",
|
|
33585
|
+
category: "mode",
|
|
33586
|
+
currentValue: modeState.currentModeId ?? null,
|
|
33587
|
+
options: modeState.availableModes.map((m) => {
|
|
33588
|
+
const r = m;
|
|
33589
|
+
return {
|
|
33590
|
+
value: m.id,
|
|
33591
|
+
name: m.name ?? m.id,
|
|
33592
|
+
...typeof r.description === "string" && r.description.trim() !== "" ? { description: r.description.trim() } : {}
|
|
33593
|
+
};
|
|
33594
|
+
})
|
|
33595
|
+
}
|
|
33596
|
+
];
|
|
33597
|
+
}
|
|
33503
33598
|
async function bootstrapAcpWireSession(transport, ctx, initializeRequest) {
|
|
33504
33599
|
const initResult = await transport.initialize(initializeRequest);
|
|
33505
33600
|
const { canResume, canLoad, promptSupportsImage } = parseAcpInitAgentCapabilities(initResult);
|
|
33506
33601
|
ctx.agentPromptImageSupported = promptSupportsImage;
|
|
33507
33602
|
await transport.afterInitialize?.();
|
|
33508
33603
|
const established = await establishAcpSessionWithTransport(transport, ctx, canResume, canLoad);
|
|
33604
|
+
established.configOptions = configOptionsWithModes(established.configOptions, established.modes);
|
|
33509
33605
|
const sessionId = established.sessionId;
|
|
33510
33606
|
ctx.onAcpSessionEstablished?.({
|
|
33511
33607
|
acpSessionId: sessionId,
|
|
@@ -33528,6 +33624,22 @@ async function bootstrapAcpWireSession(transport, ctx, initializeRequest) {
|
|
|
33528
33624
|
logDebug: ctx.logDebug
|
|
33529
33625
|
});
|
|
33530
33626
|
}
|
|
33627
|
+
if (ctx.backendAgentType === "codex-acp") {
|
|
33628
|
+
const cfg = ctx.agentConfig != null && typeof ctx.agentConfig === "object" && !Array.isArray(ctx.agentConfig) ? ctx.agentConfig : null;
|
|
33629
|
+
const configOptionsTyped = established.configOptions;
|
|
33630
|
+
const modesTyped = established.modes;
|
|
33631
|
+
await applyCodexPermissionFromAcpSession({
|
|
33632
|
+
sessionId,
|
|
33633
|
+
agentConfig: cfg,
|
|
33634
|
+
configOptions: configOptionsForPermission(ctx.getActiveConfigOptions, configOptionsTyped),
|
|
33635
|
+
modes: modesTyped,
|
|
33636
|
+
setSessionConfigOption: transport.setSessionConfigOption ? (p) => transport.setSessionConfigOption(p) : async () => {
|
|
33637
|
+
},
|
|
33638
|
+
setSessionMode: transport.setSessionMode ? (p) => transport.setSessionMode(p) : async () => {
|
|
33639
|
+
},
|
|
33640
|
+
logDebug: ctx.logDebug
|
|
33641
|
+
});
|
|
33642
|
+
}
|
|
33531
33643
|
const cfgAll = ctx.agentConfig != null && typeof ctx.agentConfig === "object" && !Array.isArray(ctx.agentConfig) ? ctx.agentConfig : null;
|
|
33532
33644
|
const configOptionsForModel = established.configOptions;
|
|
33533
33645
|
if (transport.setSessionConfigOption) {
|
|
@@ -33900,13 +34012,18 @@ function isCodexAcpCommand(command) {
|
|
|
33900
34012
|
const i = command.indexOf("@zed-industries/codex-acp");
|
|
33901
34013
|
return i >= 0 && (i === 0 || command[i - 1] === "npx" || command[i - 1] === "bunx");
|
|
33902
34014
|
}
|
|
33903
|
-
function buildCodexAcpSpawnCommand(base, _sessionMode) {
|
|
34015
|
+
function buildCodexAcpSpawnCommand(base, _sessionMode, _agentConfig) {
|
|
33904
34016
|
return [...base];
|
|
33905
34017
|
}
|
|
33906
34018
|
async function createCodexAcpClient(options) {
|
|
33907
34019
|
const base = options.command?.length && options.command.some((a) => a.includes("codex-acp")) ? options.command : [...DEFAULT_CODEX_ACP_COMMAND];
|
|
33908
|
-
const command = buildCodexAcpSpawnCommand(base, options.sessionMode);
|
|
33909
|
-
return createSdkStdioAcpClient({
|
|
34020
|
+
const command = buildCodexAcpSpawnCommand(base, options.sessionMode, options.agentConfig);
|
|
34021
|
+
return createSdkStdioAcpClient({
|
|
34022
|
+
...options,
|
|
34023
|
+
command,
|
|
34024
|
+
/** Codex ACP can ignore `session/cancel`; mirror Claude Code's subprocess fallback. */
|
|
34025
|
+
killSubprocessAfterCancelMs: options.killSubprocessAfterCancelMs ?? 2500
|
|
34026
|
+
});
|
|
33910
34027
|
}
|
|
33911
34028
|
|
|
33912
34029
|
// src/agents/acp/clients/cursor/cursor-acp-client.ts
|
|
@@ -34304,7 +34421,7 @@ function resolveAgentCommand(preferredAgentType) {
|
|
|
34304
34421
|
command,
|
|
34305
34422
|
label: preferredAgentType,
|
|
34306
34423
|
createClient: createCodexAcpClient,
|
|
34307
|
-
spawnCommandForSession: (sessionMode,
|
|
34424
|
+
spawnCommandForSession: (sessionMode, agentConfig) => buildCodexAcpSpawnCommand(command, sessionMode, agentConfig)
|
|
34308
34425
|
};
|
|
34309
34426
|
}
|
|
34310
34427
|
if (useKiroAcp(preferredAgentType, command)) {
|