@buildautomaton/cli 0.1.25 → 0.1.26
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 +126 -14
- package/dist/cli.js.map +4 -4
- package/dist/index.js +126 -14
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22933,8 +22933,77 @@ function isClaudeCodePermissionMode(value) {
|
|
|
22933
22933
|
return MODE_SET.has(value);
|
|
22934
22934
|
}
|
|
22935
22935
|
|
|
22936
|
+
// ../types/src/cli-permission-mode.ts
|
|
22937
|
+
var CLI_PERMISSION_MODE_DEFAULT = "default";
|
|
22938
|
+
var CLI_PERMISSION_MODE_DANGEROUS = "dangerous";
|
|
22939
|
+
function normalizeCliPermissionModeInput(raw) {
|
|
22940
|
+
if (typeof raw !== "string") return CLI_PERMISSION_MODE_DEFAULT;
|
|
22941
|
+
const t = raw.trim();
|
|
22942
|
+
if (t === CLI_PERMISSION_MODE_DANGEROUS) return CLI_PERMISSION_MODE_DANGEROUS;
|
|
22943
|
+
if (t === "standard") return CLI_PERMISSION_MODE_DEFAULT;
|
|
22944
|
+
return CLI_PERMISSION_MODE_DEFAULT;
|
|
22945
|
+
}
|
|
22946
|
+
|
|
22947
|
+
// ../types/src/acp-permission-auto-approve.ts
|
|
22948
|
+
function isRejectKind(kind) {
|
|
22949
|
+
return kind === "reject_once" || kind === "reject_always";
|
|
22950
|
+
}
|
|
22951
|
+
function normalizeOptions(raw) {
|
|
22952
|
+
if (!Array.isArray(raw)) return [];
|
|
22953
|
+
const out = [];
|
|
22954
|
+
for (const item of raw) {
|
|
22955
|
+
if (item == null || typeof item !== "object" || Array.isArray(item)) continue;
|
|
22956
|
+
const o = item;
|
|
22957
|
+
const rawId = o.optionId ?? o.id;
|
|
22958
|
+
const optionId = typeof rawId === "string" && rawId.trim() !== "" ? rawId.trim() : typeof rawId === "number" && Number.isFinite(rawId) ? String(rawId) : "";
|
|
22959
|
+
if (!optionId) continue;
|
|
22960
|
+
const kind = typeof o.kind === "string" ? o.kind : void 0;
|
|
22961
|
+
out.push({ optionId, ...kind ? { kind } : {} });
|
|
22962
|
+
}
|
|
22963
|
+
return out;
|
|
22964
|
+
}
|
|
22965
|
+
function pickAllowOption(options) {
|
|
22966
|
+
const nonReject = options.filter((o) => !isRejectKind(o.kind));
|
|
22967
|
+
if (nonReject.length === 0) return null;
|
|
22968
|
+
const allowOnce = nonReject.find((o) => o.kind === "allow_once");
|
|
22969
|
+
if (allowOnce) return allowOnce;
|
|
22970
|
+
const notAlways = nonReject.filter((o) => o.kind !== "allow_always");
|
|
22971
|
+
if (notAlways.length > 0) return notAlways[0] ?? null;
|
|
22972
|
+
return nonReject.find((o) => o.kind === "allow_always") ?? nonReject[0] ?? null;
|
|
22973
|
+
}
|
|
22974
|
+
function firstNonEmptyOptionsArray(...candidates) {
|
|
22975
|
+
for (const c of candidates) {
|
|
22976
|
+
if (Array.isArray(c) && c.length > 0) return c;
|
|
22977
|
+
}
|
|
22978
|
+
const fallback = candidates[0];
|
|
22979
|
+
return Array.isArray(fallback) ? fallback : [];
|
|
22980
|
+
}
|
|
22981
|
+
function extractAcpPermissionRequestOptionArray(params) {
|
|
22982
|
+
const toolCall = params.toolCall;
|
|
22983
|
+
const fromToolCall = toolCall != null && typeof toolCall === "object" && !Array.isArray(toolCall) ? toolCall : null;
|
|
22984
|
+
return firstNonEmptyOptionsArray(
|
|
22985
|
+
params.options,
|
|
22986
|
+
params.permissionOptions,
|
|
22987
|
+
fromToolCall?.options,
|
|
22988
|
+
fromToolCall?.permissionOptions
|
|
22989
|
+
);
|
|
22990
|
+
}
|
|
22991
|
+
function buildCliAutoApprovedPermissionRpcResult(requestParams) {
|
|
22992
|
+
const opt = pickAllowOption(normalizeOptions(extractAcpPermissionRequestOptionArray(requestParams)));
|
|
22993
|
+
if (!opt) return null;
|
|
22994
|
+
const kind = opt.kind?.trim();
|
|
22995
|
+
return {
|
|
22996
|
+
outcome: {
|
|
22997
|
+
outcome: "selected",
|
|
22998
|
+
optionId: opt.optionId,
|
|
22999
|
+
...kind ? { _meta: { permissionOptionKind: kind } } : {}
|
|
23000
|
+
}
|
|
23001
|
+
};
|
|
23002
|
+
}
|
|
23003
|
+
|
|
22936
23004
|
// ../types/src/agent-config.ts
|
|
22937
23005
|
var AGENT_CONFIG_CLAUDE_PERMISSION_MODE_KEY = "claude_permission_mode";
|
|
23006
|
+
var AGENT_CONFIG_CLI_PERMISSION_MODE_KEY = "cli_permission_mode";
|
|
22938
23007
|
function getClaudePermissionModeFromAgentConfig(config2) {
|
|
22939
23008
|
if (!config2) return null;
|
|
22940
23009
|
const raw = config2[AGENT_CONFIG_CLAUDE_PERMISSION_MODE_KEY];
|
|
@@ -22942,6 +23011,10 @@ function getClaudePermissionModeFromAgentConfig(config2) {
|
|
|
22942
23011
|
const t = raw.trim();
|
|
22943
23012
|
return isClaudeCodePermissionMode(t) ? t : null;
|
|
22944
23013
|
}
|
|
23014
|
+
function getCliPermissionModeFromAgentConfig(config2) {
|
|
23015
|
+
if (!config2) return CLI_PERMISSION_MODE_DEFAULT;
|
|
23016
|
+
return normalizeCliPermissionModeInput(config2[AGENT_CONFIG_CLI_PERMISSION_MODE_KEY]);
|
|
23017
|
+
}
|
|
22945
23018
|
|
|
22946
23019
|
// src/agents/acp/claude-acp-permission-from-session.ts
|
|
22947
23020
|
function flattenSelectOptions(options) {
|
|
@@ -23172,6 +23245,22 @@ async function sendAcpPromptViaTransport(transport, ctx, sessionId, promptText)
|
|
|
23172
23245
|
}
|
|
23173
23246
|
}
|
|
23174
23247
|
|
|
23248
|
+
// src/agents/acp/clients/sdk/sdk-stdio-permission-request-handshake.ts
|
|
23249
|
+
function awaitSdkStdioPermissionRequestHandshake(params) {
|
|
23250
|
+
const { requestId, paramsRecord, pending, onRequest } = params;
|
|
23251
|
+
return new Promise((resolve16) => {
|
|
23252
|
+
pending.set(requestId, { resolve: resolve16, params: paramsRecord });
|
|
23253
|
+
try {
|
|
23254
|
+
onRequest?.({
|
|
23255
|
+
requestId,
|
|
23256
|
+
method: "session/request_permission",
|
|
23257
|
+
params: paramsRecord
|
|
23258
|
+
});
|
|
23259
|
+
} catch {
|
|
23260
|
+
}
|
|
23261
|
+
});
|
|
23262
|
+
}
|
|
23263
|
+
|
|
23175
23264
|
// src/agents/acp/clients/sdk/sdk-acp-session-transport.ts
|
|
23176
23265
|
function createSdkAcpSessionTransport(connection) {
|
|
23177
23266
|
const c = connection;
|
|
@@ -23282,16 +23371,11 @@ async function createSdkStdioAcpClient(options) {
|
|
|
23282
23371
|
async requestPermission(params) {
|
|
23283
23372
|
const requestId = `perm-${++permissionSeq}`;
|
|
23284
23373
|
const paramsRecord = params != null && typeof params === "object" ? params : {};
|
|
23285
|
-
|
|
23286
|
-
|
|
23287
|
-
|
|
23288
|
-
|
|
23289
|
-
|
|
23290
|
-
});
|
|
23291
|
-
} catch {
|
|
23292
|
-
}
|
|
23293
|
-
return await new Promise((resolve17) => {
|
|
23294
|
-
pendingPermissionReplies.set(requestId, { resolve: resolve17, params: paramsRecord });
|
|
23374
|
+
return await awaitSdkStdioPermissionRequestHandshake({
|
|
23375
|
+
requestId,
|
|
23376
|
+
paramsRecord,
|
|
23377
|
+
pending: pendingPermissionReplies,
|
|
23378
|
+
onRequest
|
|
23295
23379
|
});
|
|
23296
23380
|
},
|
|
23297
23381
|
async readTextFile(params) {
|
|
@@ -23791,7 +23875,7 @@ function installBridgeProcessResilience() {
|
|
|
23791
23875
|
}
|
|
23792
23876
|
|
|
23793
23877
|
// src/cli-version.ts
|
|
23794
|
-
var CLI_VERSION = "0.1.
|
|
23878
|
+
var CLI_VERSION = "0.1.26".length > 0 ? "0.1.26" : "0.0.0-dev";
|
|
23795
23879
|
|
|
23796
23880
|
// ../../node_modules/.pnpm/open@10.2.0/node_modules/open/index.js
|
|
23797
23881
|
import process7 from "node:process";
|
|
@@ -30603,7 +30687,7 @@ function createBridgeOnFileChange(opts) {
|
|
|
30603
30687
|
|
|
30604
30688
|
// src/agents/acp/hooks/bridge-on-request.ts
|
|
30605
30689
|
function createBridgeOnRequest(opts) {
|
|
30606
|
-
const { routing, getSendRequest, log: log2 } = opts;
|
|
30690
|
+
const { routing, getSendRequest, log: log2, getAutoApproveAcpPermissions, resolveAcpPermissionRequest } = opts;
|
|
30607
30691
|
return (request) => {
|
|
30608
30692
|
const runId = routing.runId;
|
|
30609
30693
|
const sessionId = routing.sessionId;
|
|
@@ -30611,6 +30695,26 @@ function createBridgeOnRequest(opts) {
|
|
|
30611
30695
|
if (!runId || !sendReq) return;
|
|
30612
30696
|
const kind = request.method === "cursor/create_plan" ? "plan" : request.method === "session/request_permission" ? "permission" : "question";
|
|
30613
30697
|
const sessionUpdate = request.method === "cursor/create_plan" ? "plan" : request.method === "session/request_permission" ? "permission" : "question";
|
|
30698
|
+
if (request.method === "session/request_permission" && getAutoApproveAcpPermissions() && resolveAcpPermissionRequest) {
|
|
30699
|
+
const params = request.params != null && typeof request.params === "object" && !Array.isArray(request.params) ? request.params : {};
|
|
30700
|
+
const auto = buildCliAutoApprovedPermissionRpcResult(params);
|
|
30701
|
+
if (auto != null) {
|
|
30702
|
+
try {
|
|
30703
|
+
resolveAcpPermissionRequest(request.requestId, auto);
|
|
30704
|
+
log2(
|
|
30705
|
+
`[Bridge service] CLI dangerous mode: auto-approved permission requestId=${request.requestId} runId=${runId}`
|
|
30706
|
+
);
|
|
30707
|
+
return;
|
|
30708
|
+
} catch (err) {
|
|
30709
|
+
log2(
|
|
30710
|
+
`[Bridge service] CLI dangerous mode: auto-approve failed (${errorMessage(err)}); forwarding permission`
|
|
30711
|
+
);
|
|
30712
|
+
}
|
|
30713
|
+
}
|
|
30714
|
+
log2(
|
|
30715
|
+
`[Bridge service] CLI dangerous mode: no allow option to auto-select; forwarding permission requestId=${request.requestId}`
|
|
30716
|
+
);
|
|
30717
|
+
}
|
|
30614
30718
|
try {
|
|
30615
30719
|
sendReq({
|
|
30616
30720
|
type: "session_update",
|
|
@@ -31161,6 +31265,7 @@ async function ensureAcpClient(options) {
|
|
|
31161
31265
|
sendRequest,
|
|
31162
31266
|
log: log2
|
|
31163
31267
|
} = options;
|
|
31268
|
+
state.latestAgentConfigForBridgeHooks = agentConfig != null && typeof agentConfig === "object" && !Array.isArray(agentConfig) ? agentConfig : null;
|
|
31164
31269
|
const targetSessionParentPath = resolveSessionParentPathForAgentProcess(sessionParentPath);
|
|
31165
31270
|
if (state.acpStartPromise && !state.acpHandle) {
|
|
31166
31271
|
await state.acpStartPromise;
|
|
@@ -31218,7 +31323,11 @@ async function ensureAcpClient(options) {
|
|
|
31218
31323
|
sessionParentPath: targetSessionParentPath,
|
|
31219
31324
|
getSendSessionUpdate: () => sendSessionUpdate,
|
|
31220
31325
|
getSendRequest: () => sendRequest,
|
|
31221
|
-
log: log2
|
|
31326
|
+
log: log2,
|
|
31327
|
+
getAutoApproveAcpPermissions: () => getCliPermissionModeFromAgentConfig(state.latestAgentConfigForBridgeHooks) === CLI_PERMISSION_MODE_DANGEROUS,
|
|
31328
|
+
resolveAcpPermissionRequest: (requestId, result) => {
|
|
31329
|
+
state.acpHandle?.resolveRequest?.(requestId, result);
|
|
31330
|
+
}
|
|
31222
31331
|
});
|
|
31223
31332
|
const persisted = cloudSessionId != null && cloudSessionId !== "" && preferredAgentType != null && preferredAgentType !== "" ? readLocalAgentSessionFile(cloudSessionId) : null;
|
|
31224
31333
|
const persistedAcpSessionId = persisted && persisted.backendAgentType === preferredAgentType && typeof persisted.acpSessionId === "string" && persisted.acpSessionId.trim() !== "" ? persisted.acpSessionId.trim() : null;
|
|
@@ -31254,6 +31363,7 @@ async function ensureAcpClient(options) {
|
|
|
31254
31363
|
state.acpStartPromise = null;
|
|
31255
31364
|
state.acpAgentKey = null;
|
|
31256
31365
|
state.activeSessionConfigOptions = null;
|
|
31366
|
+
state.latestAgentConfigForBridgeHooks = null;
|
|
31257
31367
|
state.lastAcpStartError = "Agent subprocess exited";
|
|
31258
31368
|
},
|
|
31259
31369
|
...hooks,
|
|
@@ -31284,7 +31394,8 @@ async function createAcpManager(options) {
|
|
|
31284
31394
|
lastAcpStartError: null,
|
|
31285
31395
|
lastAcpCwd: null,
|
|
31286
31396
|
acpAgentKey: null,
|
|
31287
|
-
activeSessionConfigOptions: null
|
|
31397
|
+
activeSessionConfigOptions: null,
|
|
31398
|
+
latestAgentConfigForBridgeHooks: null
|
|
31288
31399
|
};
|
|
31289
31400
|
let backendFallbackAgentType = null;
|
|
31290
31401
|
const promptRouting = {};
|
|
@@ -31426,6 +31537,7 @@ async function createAcpManager(options) {
|
|
|
31426
31537
|
state.acpStartPromise = null;
|
|
31427
31538
|
state.acpAgentKey = null;
|
|
31428
31539
|
state.activeSessionConfigOptions = null;
|
|
31540
|
+
state.latestAgentConfigForBridgeHooks = null;
|
|
31429
31541
|
}
|
|
31430
31542
|
return {
|
|
31431
31543
|
setPreferredAgentType,
|