@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/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.26".length > 0 ? "0.1.26" : "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";
|
|
@@ -27204,8 +27204,77 @@ function isClaudeCodePermissionMode(value) {
|
|
|
27204
27204
|
return MODE_SET.has(value);
|
|
27205
27205
|
}
|
|
27206
27206
|
|
|
27207
|
+
// ../types/src/cli-permission-mode.ts
|
|
27208
|
+
var CLI_PERMISSION_MODE_DEFAULT = "default";
|
|
27209
|
+
var CLI_PERMISSION_MODE_DANGEROUS = "dangerous";
|
|
27210
|
+
function normalizeCliPermissionModeInput(raw) {
|
|
27211
|
+
if (typeof raw !== "string") return CLI_PERMISSION_MODE_DEFAULT;
|
|
27212
|
+
const t = raw.trim();
|
|
27213
|
+
if (t === CLI_PERMISSION_MODE_DANGEROUS) return CLI_PERMISSION_MODE_DANGEROUS;
|
|
27214
|
+
if (t === "standard") return CLI_PERMISSION_MODE_DEFAULT;
|
|
27215
|
+
return CLI_PERMISSION_MODE_DEFAULT;
|
|
27216
|
+
}
|
|
27217
|
+
|
|
27218
|
+
// ../types/src/acp-permission-auto-approve.ts
|
|
27219
|
+
function isRejectKind(kind) {
|
|
27220
|
+
return kind === "reject_once" || kind === "reject_always";
|
|
27221
|
+
}
|
|
27222
|
+
function normalizeOptions(raw) {
|
|
27223
|
+
if (!Array.isArray(raw)) return [];
|
|
27224
|
+
const out = [];
|
|
27225
|
+
for (const item of raw) {
|
|
27226
|
+
if (item == null || typeof item !== "object" || Array.isArray(item)) continue;
|
|
27227
|
+
const o = item;
|
|
27228
|
+
const rawId = o.optionId ?? o.id;
|
|
27229
|
+
const optionId = typeof rawId === "string" && rawId.trim() !== "" ? rawId.trim() : typeof rawId === "number" && Number.isFinite(rawId) ? String(rawId) : "";
|
|
27230
|
+
if (!optionId) continue;
|
|
27231
|
+
const kind = typeof o.kind === "string" ? o.kind : void 0;
|
|
27232
|
+
out.push({ optionId, ...kind ? { kind } : {} });
|
|
27233
|
+
}
|
|
27234
|
+
return out;
|
|
27235
|
+
}
|
|
27236
|
+
function pickAllowOption(options) {
|
|
27237
|
+
const nonReject = options.filter((o) => !isRejectKind(o.kind));
|
|
27238
|
+
if (nonReject.length === 0) return null;
|
|
27239
|
+
const allowOnce = nonReject.find((o) => o.kind === "allow_once");
|
|
27240
|
+
if (allowOnce) return allowOnce;
|
|
27241
|
+
const notAlways = nonReject.filter((o) => o.kind !== "allow_always");
|
|
27242
|
+
if (notAlways.length > 0) return notAlways[0] ?? null;
|
|
27243
|
+
return nonReject.find((o) => o.kind === "allow_always") ?? nonReject[0] ?? null;
|
|
27244
|
+
}
|
|
27245
|
+
function firstNonEmptyOptionsArray(...candidates) {
|
|
27246
|
+
for (const c of candidates) {
|
|
27247
|
+
if (Array.isArray(c) && c.length > 0) return c;
|
|
27248
|
+
}
|
|
27249
|
+
const fallback = candidates[0];
|
|
27250
|
+
return Array.isArray(fallback) ? fallback : [];
|
|
27251
|
+
}
|
|
27252
|
+
function extractAcpPermissionRequestOptionArray(params) {
|
|
27253
|
+
const toolCall = params.toolCall;
|
|
27254
|
+
const fromToolCall = toolCall != null && typeof toolCall === "object" && !Array.isArray(toolCall) ? toolCall : null;
|
|
27255
|
+
return firstNonEmptyOptionsArray(
|
|
27256
|
+
params.options,
|
|
27257
|
+
params.permissionOptions,
|
|
27258
|
+
fromToolCall?.options,
|
|
27259
|
+
fromToolCall?.permissionOptions
|
|
27260
|
+
);
|
|
27261
|
+
}
|
|
27262
|
+
function buildCliAutoApprovedPermissionRpcResult(requestParams) {
|
|
27263
|
+
const opt = pickAllowOption(normalizeOptions(extractAcpPermissionRequestOptionArray(requestParams)));
|
|
27264
|
+
if (!opt) return null;
|
|
27265
|
+
const kind = opt.kind?.trim();
|
|
27266
|
+
return {
|
|
27267
|
+
outcome: {
|
|
27268
|
+
outcome: "selected",
|
|
27269
|
+
optionId: opt.optionId,
|
|
27270
|
+
...kind ? { _meta: { permissionOptionKind: kind } } : {}
|
|
27271
|
+
}
|
|
27272
|
+
};
|
|
27273
|
+
}
|
|
27274
|
+
|
|
27207
27275
|
// ../types/src/agent-config.ts
|
|
27208
27276
|
var AGENT_CONFIG_CLAUDE_PERMISSION_MODE_KEY = "claude_permission_mode";
|
|
27277
|
+
var AGENT_CONFIG_CLI_PERMISSION_MODE_KEY = "cli_permission_mode";
|
|
27209
27278
|
function getClaudePermissionModeFromAgentConfig(config2) {
|
|
27210
27279
|
if (!config2) return null;
|
|
27211
27280
|
const raw = config2[AGENT_CONFIG_CLAUDE_PERMISSION_MODE_KEY];
|
|
@@ -27213,6 +27282,10 @@ function getClaudePermissionModeFromAgentConfig(config2) {
|
|
|
27213
27282
|
const t = raw.trim();
|
|
27214
27283
|
return isClaudeCodePermissionMode(t) ? t : null;
|
|
27215
27284
|
}
|
|
27285
|
+
function getCliPermissionModeFromAgentConfig(config2) {
|
|
27286
|
+
if (!config2) return CLI_PERMISSION_MODE_DEFAULT;
|
|
27287
|
+
return normalizeCliPermissionModeInput(config2[AGENT_CONFIG_CLI_PERMISSION_MODE_KEY]);
|
|
27288
|
+
}
|
|
27216
27289
|
|
|
27217
27290
|
// src/git/session-git-queue.ts
|
|
27218
27291
|
import { execFile as execFile7 } from "node:child_process";
|
|
@@ -32758,6 +32831,22 @@ async function sendAcpPromptViaTransport(transport, ctx, sessionId, promptText)
|
|
|
32758
32831
|
}
|
|
32759
32832
|
}
|
|
32760
32833
|
|
|
32834
|
+
// src/agents/acp/clients/sdk/sdk-stdio-permission-request-handshake.ts
|
|
32835
|
+
function awaitSdkStdioPermissionRequestHandshake(params) {
|
|
32836
|
+
const { requestId, paramsRecord, pending, onRequest } = params;
|
|
32837
|
+
return new Promise((resolve18) => {
|
|
32838
|
+
pending.set(requestId, { resolve: resolve18, params: paramsRecord });
|
|
32839
|
+
try {
|
|
32840
|
+
onRequest?.({
|
|
32841
|
+
requestId,
|
|
32842
|
+
method: "session/request_permission",
|
|
32843
|
+
params: paramsRecord
|
|
32844
|
+
});
|
|
32845
|
+
} catch {
|
|
32846
|
+
}
|
|
32847
|
+
});
|
|
32848
|
+
}
|
|
32849
|
+
|
|
32761
32850
|
// src/agents/acp/clients/sdk/sdk-acp-session-transport.ts
|
|
32762
32851
|
function createSdkAcpSessionTransport(connection) {
|
|
32763
32852
|
const c = connection;
|
|
@@ -32868,16 +32957,11 @@ async function createSdkStdioAcpClient(options) {
|
|
|
32868
32957
|
async requestPermission(params) {
|
|
32869
32958
|
const requestId = `perm-${++permissionSeq}`;
|
|
32870
32959
|
const paramsRecord = params != null && typeof params === "object" ? params : {};
|
|
32871
|
-
|
|
32872
|
-
|
|
32873
|
-
|
|
32874
|
-
|
|
32875
|
-
|
|
32876
|
-
});
|
|
32877
|
-
} catch {
|
|
32878
|
-
}
|
|
32879
|
-
return await new Promise((resolve19) => {
|
|
32880
|
-
pendingPermissionReplies.set(requestId, { resolve: resolve19, params: paramsRecord });
|
|
32960
|
+
return await awaitSdkStdioPermissionRequestHandshake({
|
|
32961
|
+
requestId,
|
|
32962
|
+
paramsRecord,
|
|
32963
|
+
pending: pendingPermissionReplies,
|
|
32964
|
+
onRequest
|
|
32881
32965
|
});
|
|
32882
32966
|
},
|
|
32883
32967
|
async readTextFile(params) {
|
|
@@ -33578,7 +33662,7 @@ function createBridgeOnFileChange(opts) {
|
|
|
33578
33662
|
|
|
33579
33663
|
// src/agents/acp/hooks/bridge-on-request.ts
|
|
33580
33664
|
function createBridgeOnRequest(opts) {
|
|
33581
|
-
const { routing, getSendRequest, log: log2 } = opts;
|
|
33665
|
+
const { routing, getSendRequest, log: log2, getAutoApproveAcpPermissions, resolveAcpPermissionRequest } = opts;
|
|
33582
33666
|
return (request) => {
|
|
33583
33667
|
const runId = routing.runId;
|
|
33584
33668
|
const sessionId = routing.sessionId;
|
|
@@ -33586,6 +33670,26 @@ function createBridgeOnRequest(opts) {
|
|
|
33586
33670
|
if (!runId || !sendReq) return;
|
|
33587
33671
|
const kind = request.method === "cursor/create_plan" ? "plan" : request.method === "session/request_permission" ? "permission" : "question";
|
|
33588
33672
|
const sessionUpdate = request.method === "cursor/create_plan" ? "plan" : request.method === "session/request_permission" ? "permission" : "question";
|
|
33673
|
+
if (request.method === "session/request_permission" && getAutoApproveAcpPermissions() && resolveAcpPermissionRequest) {
|
|
33674
|
+
const params = request.params != null && typeof request.params === "object" && !Array.isArray(request.params) ? request.params : {};
|
|
33675
|
+
const auto = buildCliAutoApprovedPermissionRpcResult(params);
|
|
33676
|
+
if (auto != null) {
|
|
33677
|
+
try {
|
|
33678
|
+
resolveAcpPermissionRequest(request.requestId, auto);
|
|
33679
|
+
log2(
|
|
33680
|
+
`[Bridge service] CLI dangerous mode: auto-approved permission requestId=${request.requestId} runId=${runId}`
|
|
33681
|
+
);
|
|
33682
|
+
return;
|
|
33683
|
+
} catch (err) {
|
|
33684
|
+
log2(
|
|
33685
|
+
`[Bridge service] CLI dangerous mode: auto-approve failed (${errorMessage(err)}); forwarding permission`
|
|
33686
|
+
);
|
|
33687
|
+
}
|
|
33688
|
+
}
|
|
33689
|
+
log2(
|
|
33690
|
+
`[Bridge service] CLI dangerous mode: no allow option to auto-select; forwarding permission requestId=${request.requestId}`
|
|
33691
|
+
);
|
|
33692
|
+
}
|
|
33589
33693
|
try {
|
|
33590
33694
|
sendReq({
|
|
33591
33695
|
type: "session_update",
|
|
@@ -34136,6 +34240,7 @@ async function ensureAcpClient(options) {
|
|
|
34136
34240
|
sendRequest,
|
|
34137
34241
|
log: log2
|
|
34138
34242
|
} = options;
|
|
34243
|
+
state.latestAgentConfigForBridgeHooks = agentConfig != null && typeof agentConfig === "object" && !Array.isArray(agentConfig) ? agentConfig : null;
|
|
34139
34244
|
const targetSessionParentPath = resolveSessionParentPathForAgentProcess(sessionParentPath);
|
|
34140
34245
|
if (state.acpStartPromise && !state.acpHandle) {
|
|
34141
34246
|
await state.acpStartPromise;
|
|
@@ -34193,7 +34298,11 @@ async function ensureAcpClient(options) {
|
|
|
34193
34298
|
sessionParentPath: targetSessionParentPath,
|
|
34194
34299
|
getSendSessionUpdate: () => sendSessionUpdate,
|
|
34195
34300
|
getSendRequest: () => sendRequest,
|
|
34196
|
-
log: log2
|
|
34301
|
+
log: log2,
|
|
34302
|
+
getAutoApproveAcpPermissions: () => getCliPermissionModeFromAgentConfig(state.latestAgentConfigForBridgeHooks) === CLI_PERMISSION_MODE_DANGEROUS,
|
|
34303
|
+
resolveAcpPermissionRequest: (requestId, result) => {
|
|
34304
|
+
state.acpHandle?.resolveRequest?.(requestId, result);
|
|
34305
|
+
}
|
|
34197
34306
|
});
|
|
34198
34307
|
const persisted = cloudSessionId != null && cloudSessionId !== "" && preferredAgentType != null && preferredAgentType !== "" ? readLocalAgentSessionFile(cloudSessionId) : null;
|
|
34199
34308
|
const persistedAcpSessionId = persisted && persisted.backendAgentType === preferredAgentType && typeof persisted.acpSessionId === "string" && persisted.acpSessionId.trim() !== "" ? persisted.acpSessionId.trim() : null;
|
|
@@ -34229,6 +34338,7 @@ async function ensureAcpClient(options) {
|
|
|
34229
34338
|
state.acpStartPromise = null;
|
|
34230
34339
|
state.acpAgentKey = null;
|
|
34231
34340
|
state.activeSessionConfigOptions = null;
|
|
34341
|
+
state.latestAgentConfigForBridgeHooks = null;
|
|
34232
34342
|
state.lastAcpStartError = "Agent subprocess exited";
|
|
34233
34343
|
},
|
|
34234
34344
|
...hooks,
|
|
@@ -34259,7 +34369,8 @@ async function createAcpManager(options) {
|
|
|
34259
34369
|
lastAcpStartError: null,
|
|
34260
34370
|
lastAcpCwd: null,
|
|
34261
34371
|
acpAgentKey: null,
|
|
34262
|
-
activeSessionConfigOptions: null
|
|
34372
|
+
activeSessionConfigOptions: null,
|
|
34373
|
+
latestAgentConfigForBridgeHooks: null
|
|
34263
34374
|
};
|
|
34264
34375
|
let backendFallbackAgentType = null;
|
|
34265
34376
|
const promptRouting = {};
|
|
@@ -34401,6 +34512,7 @@ async function createAcpManager(options) {
|
|
|
34401
34512
|
state.acpStartPromise = null;
|
|
34402
34513
|
state.acpAgentKey = null;
|
|
34403
34514
|
state.activeSessionConfigOptions = null;
|
|
34515
|
+
state.latestAgentConfigForBridgeHooks = null;
|
|
34404
34516
|
}
|
|
34405
34517
|
return {
|
|
34406
34518
|
setPreferredAgentType,
|