@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/index.js CHANGED
@@ -22607,6 +22607,7 @@ async function createSdkStdioAcpClient(options) {
22607
22607
  cwd = getBridgeWorkspaceDirectory(),
22608
22608
  backendAgentType,
22609
22609
  onSessionUpdate,
22610
+ onRequest,
22610
22611
  onFileChange,
22611
22612
  killSubprocessAfterCancelMs,
22612
22613
  onAgentSubprocessExit
@@ -22658,13 +22659,23 @@ async function createSdkStdioAcpClient(options) {
22658
22659
  backendAgentType,
22659
22660
  onSessionUpdate
22660
22661
  });
22662
+ let permissionSeq = 0;
22663
+ const pendingPermissionResolvers = /* @__PURE__ */ new Map();
22661
22664
  const client = (_agent) => ({
22662
22665
  async requestPermission(params) {
22663
- const opt = params?.options?.[0];
22664
- if (opt && typeof opt.optionId === "string") {
22665
- return { outcome: { outcome: "selected", optionId: opt.optionId } };
22666
+ const requestId = `perm-${++permissionSeq}`;
22667
+ const paramsRecord = params != null && typeof params === "object" ? params : {};
22668
+ try {
22669
+ onRequest?.({
22670
+ requestId,
22671
+ method: "session/request_permission",
22672
+ params: paramsRecord
22673
+ });
22674
+ } catch {
22666
22675
  }
22667
- return { outcome: { outcome: "cancelled" } };
22676
+ return await new Promise((resolve15) => {
22677
+ pendingPermissionResolvers.set(requestId, resolve15);
22678
+ });
22668
22679
  },
22669
22680
  async readTextFile(params) {
22670
22681
  const abs = resolveSafePathUnderCwd(cwd, params.path);
@@ -22771,6 +22782,10 @@ async function createSdkStdioAcpClient(options) {
22771
22782
  }
22772
22783
  },
22773
22784
  async cancel() {
22785
+ for (const [id, resolve15] of [...pendingPermissionResolvers.entries()]) {
22786
+ pendingPermissionResolvers.delete(id);
22787
+ resolve15({ outcome: { outcome: "cancelled" } });
22788
+ }
22774
22789
  try {
22775
22790
  await connection.cancel({ sessionId });
22776
22791
  } catch {
@@ -22784,7 +22799,11 @@ async function createSdkStdioAcpClient(options) {
22784
22799
  t.unref?.();
22785
22800
  }
22786
22801
  },
22787
- resolveRequest() {
22802
+ resolveRequest(requestId, result) {
22803
+ const resolve15 = pendingPermissionResolvers.get(requestId);
22804
+ if (!resolve15) return;
22805
+ pendingPermissionResolvers.delete(requestId);
22806
+ resolve15(result);
22788
22807
  },
22789
22808
  disconnect() {
22790
22809
  child.kill();
@@ -28697,7 +28716,13 @@ async function createCursorAcpClient(options) {
28697
28716
  return;
28698
28717
  }
28699
28718
  if (method === "session/request_permission" && typeof id === "number") {
28700
- respond(id, { outcome: { outcome: "selected", optionId: "allow-once" } });
28719
+ const params = msg.params ?? {};
28720
+ pendingRequests.set(id, { method, params });
28721
+ onRequest?.({
28722
+ requestId: String(id),
28723
+ method,
28724
+ params
28725
+ });
28701
28726
  return;
28702
28727
  }
28703
28728
  if (typeof id === "number" && method) {
@@ -28794,8 +28819,15 @@ async function createCursorAcpClient(options) {
28794
28819
  return new Promise((res, rej) => {
28795
28820
  child.stdin.write(line, (err) => err ? rej(err) : res());
28796
28821
  });
28822
+ }, cancelPendingPermissionRequests2 = function() {
28823
+ for (const [reqId, pending2] of [...pendingRequests.entries()]) {
28824
+ if (pending2.method === "session/request_permission") {
28825
+ respond(reqId, { outcome: { outcome: "cancelled" } });
28826
+ pendingRequests.delete(reqId);
28827
+ }
28828
+ }
28797
28829
  };
28798
- var sendSessionCancelNotification = sendSessionCancelNotification2;
28830
+ var sendSessionCancelNotification = sendSessionCancelNotification2, cancelPendingPermissionRequests = cancelPendingPermissionRequests2;
28799
28831
  await send("initialize", {
28800
28832
  protocolVersion: 1,
28801
28833
  clientCapabilities: { fs: { readTextFile: true, writeTextFile: true }, terminal: false },
@@ -28863,6 +28895,7 @@ async function createCursorAcpClient(options) {
28863
28895
  }
28864
28896
  },
28865
28897
  async cancel() {
28898
+ cancelPendingPermissionRequests2();
28866
28899
  await sendSessionCancelNotification2();
28867
28900
  },
28868
28901
  resolveRequest(requestId, result) {
@@ -29155,14 +29188,16 @@ function createBridgeOnRequest(opts) {
29155
29188
  const sessionId = routing.sessionId;
29156
29189
  const sendReq = getSendRequest();
29157
29190
  if (!runId || !sendReq) return;
29191
+ const kind = request.method === "cursor/create_plan" ? "plan" : request.method === "session/request_permission" ? "permission" : "question";
29192
+ const sessionUpdate = request.method === "cursor/create_plan" ? "plan" : request.method === "session/request_permission" ? "permission" : "question";
29158
29193
  try {
29159
29194
  sendReq({
29160
29195
  type: "session_update",
29161
29196
  ...sessionId ? { sessionId } : {},
29162
29197
  runId,
29163
- kind: request.method === "cursor/create_plan" ? "plan" : "question",
29198
+ kind,
29164
29199
  payload: {
29165
- sessionUpdate: request.method === "cursor/create_plan" ? "plan" : "question",
29200
+ sessionUpdate,
29166
29201
  requestId: request.requestId,
29167
29202
  method: request.method,
29168
29203
  params: request.params
@@ -29597,6 +29632,9 @@ function createBridgeOnSessionUpdate(opts) {
29597
29632
  pathTracker.accumulatedPathsByToolKey.delete(toolKey);
29598
29633
  }
29599
29634
  if (runId && send) {
29635
+ if (updateKind === "permission") {
29636
+ return;
29637
+ }
29600
29638
  try {
29601
29639
  send({
29602
29640
  type: "session_update",