@buildautomaton/cli 0.1.7 → 0.1.8

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 CHANGED
@@ -31059,6 +31059,7 @@ async function createSdkStdioAcpClient(options) {
31059
31059
  cwd = getBridgeWorkspaceDirectory(),
31060
31060
  backendAgentType,
31061
31061
  onSessionUpdate,
31062
+ onRequest,
31062
31063
  onFileChange,
31063
31064
  killSubprocessAfterCancelMs,
31064
31065
  onAgentSubprocessExit
@@ -31110,13 +31111,23 @@ async function createSdkStdioAcpClient(options) {
31110
31111
  backendAgentType,
31111
31112
  onSessionUpdate
31112
31113
  });
31114
+ let permissionSeq = 0;
31115
+ const pendingPermissionResolvers = /* @__PURE__ */ new Map();
31113
31116
  const client = (_agent) => ({
31114
31117
  async requestPermission(params) {
31115
- const opt = params?.options?.[0];
31116
- if (opt && typeof opt.optionId === "string") {
31117
- return { outcome: { outcome: "selected", optionId: opt.optionId } };
31118
+ const requestId = `perm-${++permissionSeq}`;
31119
+ const paramsRecord = params != null && typeof params === "object" ? params : {};
31120
+ try {
31121
+ onRequest?.({
31122
+ requestId,
31123
+ method: "session/request_permission",
31124
+ params: paramsRecord
31125
+ });
31126
+ } catch {
31118
31127
  }
31119
- return { outcome: { outcome: "cancelled" } };
31128
+ return await new Promise((resolve16) => {
31129
+ pendingPermissionResolvers.set(requestId, resolve16);
31130
+ });
31120
31131
  },
31121
31132
  async readTextFile(params) {
31122
31133
  const abs = resolveSafePathUnderCwd(cwd, params.path);
@@ -31223,6 +31234,10 @@ async function createSdkStdioAcpClient(options) {
31223
31234
  }
31224
31235
  },
31225
31236
  async cancel() {
31237
+ for (const [id, resolve16] of [...pendingPermissionResolvers.entries()]) {
31238
+ pendingPermissionResolvers.delete(id);
31239
+ resolve16({ outcome: { outcome: "cancelled" } });
31240
+ }
31226
31241
  try {
31227
31242
  await connection.cancel({ sessionId });
31228
31243
  } catch {
@@ -31236,7 +31251,11 @@ async function createSdkStdioAcpClient(options) {
31236
31251
  t.unref?.();
31237
31252
  }
31238
31253
  },
31239
- resolveRequest() {
31254
+ resolveRequest(requestId, result) {
31255
+ const resolve16 = pendingPermissionResolvers.get(requestId);
31256
+ if (!resolve16) return;
31257
+ pendingPermissionResolvers.delete(requestId);
31258
+ resolve16(result);
31240
31259
  },
31241
31260
  disconnect() {
31242
31261
  child.kill();
@@ -31453,7 +31472,13 @@ async function createCursorAcpClient(options) {
31453
31472
  return;
31454
31473
  }
31455
31474
  if (method === "session/request_permission" && typeof id === "number") {
31456
- respond(id, { outcome: { outcome: "selected", optionId: "allow-once" } });
31475
+ const params = msg.params ?? {};
31476
+ pendingRequests.set(id, { method, params });
31477
+ onRequest?.({
31478
+ requestId: String(id),
31479
+ method,
31480
+ params
31481
+ });
31457
31482
  return;
31458
31483
  }
31459
31484
  if (typeof id === "number" && method) {
@@ -31550,8 +31575,15 @@ async function createCursorAcpClient(options) {
31550
31575
  return new Promise((res, rej) => {
31551
31576
  child.stdin.write(line, (err) => err ? rej(err) : res());
31552
31577
  });
31578
+ }, cancelPendingPermissionRequests2 = function() {
31579
+ for (const [reqId, pending2] of [...pendingRequests.entries()]) {
31580
+ if (pending2.method === "session/request_permission") {
31581
+ respond(reqId, { outcome: { outcome: "cancelled" } });
31582
+ pendingRequests.delete(reqId);
31583
+ }
31584
+ }
31553
31585
  };
31554
- var sendSessionCancelNotification = sendSessionCancelNotification2;
31586
+ var sendSessionCancelNotification = sendSessionCancelNotification2, cancelPendingPermissionRequests = cancelPendingPermissionRequests2;
31555
31587
  await send("initialize", {
31556
31588
  protocolVersion: 1,
31557
31589
  clientCapabilities: { fs: { readTextFile: true, writeTextFile: true }, terminal: false },
@@ -31619,6 +31651,7 @@ async function createCursorAcpClient(options) {
31619
31651
  }
31620
31652
  },
31621
31653
  async cancel() {
31654
+ cancelPendingPermissionRequests2();
31622
31655
  await sendSessionCancelNotification2();
31623
31656
  },
31624
31657
  resolveRequest(requestId, result) {
@@ -31911,14 +31944,16 @@ function createBridgeOnRequest(opts) {
31911
31944
  const sessionId = routing.sessionId;
31912
31945
  const sendReq = getSendRequest();
31913
31946
  if (!runId || !sendReq) return;
31947
+ const kind = request.method === "cursor/create_plan" ? "plan" : request.method === "session/request_permission" ? "permission" : "question";
31948
+ const sessionUpdate = request.method === "cursor/create_plan" ? "plan" : request.method === "session/request_permission" ? "permission" : "question";
31914
31949
  try {
31915
31950
  sendReq({
31916
31951
  type: "session_update",
31917
31952
  ...sessionId ? { sessionId } : {},
31918
31953
  runId,
31919
- kind: request.method === "cursor/create_plan" ? "plan" : "question",
31954
+ kind,
31920
31955
  payload: {
31921
- sessionUpdate: request.method === "cursor/create_plan" ? "plan" : "question",
31956
+ sessionUpdate,
31922
31957
  requestId: request.requestId,
31923
31958
  method: request.method,
31924
31959
  params: request.params
@@ -32353,6 +32388,9 @@ function createBridgeOnSessionUpdate(opts) {
32353
32388
  pathTracker.accumulatedPathsByToolKey.delete(toolKey);
32354
32389
  }
32355
32390
  if (runId && send) {
32391
+ if (updateKind === "permission") {
32392
+ return;
32393
+ }
32356
32394
  try {
32357
32395
  send({
32358
32396
  type: "session_update",