@buildautomaton/cli 0.1.76 → 0.1.77

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
@@ -31064,7 +31064,7 @@ var {
31064
31064
  } = import_index.default;
31065
31065
 
31066
31066
  // src/cli-version.ts
31067
- var CLI_VERSION = "0.1.76".length > 0 ? "0.1.76" : "0.0.0-dev";
31067
+ var CLI_VERSION = "0.1.77".length > 0 ? "0.1.77" : "0.0.0-dev";
31068
31068
 
31069
31069
  // src/cli/defaults.ts
31070
31070
  var DEFAULT_API_URL = process.env.BUILDAUTOMATON_API_URL ?? "https://api.buildautomaton.com";
@@ -36205,9 +36205,12 @@ function cancelPendingCursorPermissionRequests(pendingRequests2, respond) {
36205
36205
  // src/agents/acp/clients/cursor/create-cursor-acp-handle.ts
36206
36206
  function createCursorAcpHandle(options) {
36207
36207
  let teardownStarted = false;
36208
+ let cancelFallback = null;
36208
36209
  async function disconnectGracefully() {
36209
36210
  if (teardownStarted) return;
36210
36211
  teardownStarted = true;
36212
+ if (cancelFallback) clearTimeout(cancelFallback);
36213
+ cancelFallback = null;
36211
36214
  cancelPendingCursorPermissionRequests(options.pendingRequests, options.wire.respond);
36212
36215
  try {
36213
36216
  await options.transport.cancelSession(options.sessionId);
@@ -36233,7 +36236,17 @@ function createCursorAcpHandle(options) {
36233
36236
  },
36234
36237
  async cancel() {
36235
36238
  cancelPendingCursorPermissionRequests(options.pendingRequests, options.wire.respond);
36236
- await options.transport.cancelSession(options.sessionId);
36239
+ try {
36240
+ await options.transport.cancelSession(options.sessionId);
36241
+ } catch {
36242
+ }
36243
+ if (cancelFallback) return;
36244
+ cancelFallback = setTimeout(() => {
36245
+ if (options.child.exitCode == null && options.child.signalCode == null) {
36246
+ void disconnectGracefully();
36247
+ }
36248
+ }, 5e3);
36249
+ cancelFallback.unref?.();
36237
36250
  },
36238
36251
  resolveRequest(requestId, result) {
36239
36252
  if (options.pendingRequests.has(requestId)) {
@@ -37989,6 +38002,66 @@ function augmentPromptResultAuthFields(agentType, errorText) {
37989
38002
  return { agentAuthRequired: true, agentType };
37990
38003
  }
37991
38004
 
38005
+ // src/agents/planning/submit-planning-todos-for-turn.ts
38006
+ async function submitPlanningTodosForTurn(params) {
38007
+ const token = params.getCloudAccessToken();
38008
+ if (!token.trim()) return { ok: false, error: "Missing cloud access token" };
38009
+ const base = params.cloudApiBaseUrl.replace(/\/$/, "");
38010
+ const url2 = `${base}/internal/sessions/todos/submit`;
38011
+ const res = await fetch(url2, {
38012
+ method: "POST",
38013
+ headers: {
38014
+ Authorization: `Bearer ${token}`,
38015
+ "Content-Type": "application/json"
38016
+ },
38017
+ body: JSON.stringify({
38018
+ sessionId: params.sessionId,
38019
+ turnId: params.turnId,
38020
+ items: params.items
38021
+ })
38022
+ });
38023
+ if (!res.ok) {
38024
+ const body = await res.json().catch(() => null);
38025
+ return { ok: false, error: body?.error ?? `Planning todo submit failed (${res.status})` };
38026
+ }
38027
+ return { ok: true };
38028
+ }
38029
+
38030
+ // src/agents/planning/maybe-submit-planning-todos-after-agent-success.ts
38031
+ async function maybeSubmitPlanningTodosAfterAgentSuccess(params) {
38032
+ const { sessionId, runId, resultSuccess, output, cloudApiBaseUrl, getCloudAccessToken, log: log2 } = params;
38033
+ const buffered = runId ? getPlanningSessionTurnOutput(runId) : "";
38034
+ const outputFromResult = typeof output === "string" ? output : "";
38035
+ const outputStr = buffered.trim() !== "" ? buffered : outputFromResult;
38036
+ if (!sessionId || !runId || !resultSuccess || outputStr.trim() === "") {
38037
+ return { submitted: false, suppressOutput: false };
38038
+ }
38039
+ if (!cloudApiBaseUrl || !getCloudAccessToken) {
38040
+ return { submitted: false, suppressOutput: false };
38041
+ }
38042
+ const items = parsePlanningTodoAgentJson(outputStr);
38043
+ if (items.length === 0) {
38044
+ return { submitted: false, suppressOutput: false };
38045
+ }
38046
+ const result = await submitPlanningTodosForTurn({
38047
+ sessionId,
38048
+ turnId: runId,
38049
+ items,
38050
+ cloudApiBaseUrl,
38051
+ getCloudAccessToken
38052
+ });
38053
+ if (!result.ok) {
38054
+ log2(`[Agent] Planning todo submit failed: ${result.error}`);
38055
+ return { submitted: false, suppressOutput: false };
38056
+ }
38057
+ if (runId) consumePlanningSessionTurnOutput(runId);
38058
+ log2(`[Agent] Planning session: stored ${items.length} todo(s) via internal API`);
38059
+ return { submitted: true, suppressOutput: true };
38060
+ }
38061
+
38062
+ // src/agents/acp/prompts/report-post-turn-enrichment.ts
38063
+ init_yield_to_event_loop();
38064
+
37992
38065
  // src/git/git-runtime.ts
37993
38066
  init_cli_process_interrupt();
37994
38067
  var activeGitChildProcesses = /* @__PURE__ */ new Set();
@@ -38351,61 +38424,30 @@ async function collectTurnGitDiffFromPreTurnSnapshot(options) {
38351
38424
  });
38352
38425
  }
38353
38426
 
38354
- // src/agents/planning/submit-planning-todos-for-turn.ts
38355
- async function submitPlanningTodosForTurn(params) {
38356
- const token = params.getCloudAccessToken();
38357
- if (!token.trim()) return { ok: false, error: "Missing cloud access token" };
38358
- const base = params.cloudApiBaseUrl.replace(/\/$/, "");
38359
- const url2 = `${base}/internal/sessions/todos/submit`;
38360
- const res = await fetch(url2, {
38361
- method: "POST",
38362
- headers: {
38363
- Authorization: `Bearer ${token}`,
38364
- "Content-Type": "application/json"
38365
- },
38366
- body: JSON.stringify({
38367
- sessionId: params.sessionId,
38368
- turnId: params.turnId,
38369
- items: params.items
38370
- })
38371
- });
38372
- if (!res.ok) {
38373
- const body = await res.json().catch(() => null);
38374
- return { ok: false, error: body?.error ?? `Planning todo submit failed (${res.status})` };
38375
- }
38376
- return { ok: true };
38377
- }
38378
-
38379
- // src/agents/planning/maybe-submit-planning-todos-after-agent-success.ts
38380
- async function maybeSubmitPlanningTodosAfterAgentSuccess(params) {
38381
- const { sessionId, runId, resultSuccess, output, cloudApiBaseUrl, getCloudAccessToken, log: log2 } = params;
38382
- const buffered = runId ? getPlanningSessionTurnOutput(runId) : "";
38383
- const outputFromResult = typeof output === "string" ? output : "";
38384
- const outputStr = buffered.trim() !== "" ? buffered : outputFromResult;
38385
- if (!sessionId || !runId || !resultSuccess || outputStr.trim() === "") {
38386
- return { submitted: false, suppressOutput: false };
38387
- }
38388
- if (!cloudApiBaseUrl || !getCloudAccessToken) {
38389
- return { submitted: false, suppressOutput: false };
38390
- }
38391
- const items = parsePlanningTodoAgentJson(outputStr);
38392
- if (items.length === 0) {
38393
- return { submitted: false, suppressOutput: false };
38394
- }
38395
- const result = await submitPlanningTodosForTurn({
38396
- sessionId,
38397
- turnId: runId,
38398
- items,
38399
- cloudApiBaseUrl,
38400
- getCloudAccessToken
38427
+ // src/agents/acp/prompts/report-post-turn-enrichment.ts
38428
+ function reportPostTurnEnrichment(options) {
38429
+ void (async () => {
38430
+ const {
38431
+ sessionId,
38432
+ runId,
38433
+ agentCwd,
38434
+ result,
38435
+ sendSessionUpdate,
38436
+ log: log2
38437
+ } = options;
38438
+ await yieldToEventLoop();
38439
+ if (sessionId && runId && sendSessionUpdate && agentCwd && result.success) {
38440
+ await collectTurnGitDiffFromPreTurnSnapshot({
38441
+ sessionId,
38442
+ runId,
38443
+ agentCwd,
38444
+ sendSessionUpdate,
38445
+ log: log2
38446
+ });
38447
+ }
38448
+ })().catch((error40) => {
38449
+ options.log(`[Agent] Post-turn enrichment failed: ${error40 instanceof Error ? error40.message : String(error40)}`);
38401
38450
  });
38402
- if (!result.ok) {
38403
- log2(`[Agent] Planning todo submit failed: ${result.error}`);
38404
- return { submitted: false, suppressOutput: false };
38405
- }
38406
- if (runId) consumePlanningSessionTurnOutput(runId);
38407
- log2(`[Agent] Planning session: stored ${items.length} todo(s) via internal API`);
38408
- return { submitted: true, suppressOutput: true };
38409
38451
  }
38410
38452
 
38411
38453
  // src/agents/acp/prompts/finalize-and-send-prompt-result.ts
@@ -38425,16 +38467,7 @@ async function finalizeAndSendPromptResult(params) {
38425
38467
  sendSessionUpdate,
38426
38468
  log: log2
38427
38469
  } = params;
38428
- if (sessionId && runId && sendSessionUpdate && agentCwd && result.success) {
38429
- await collectTurnGitDiffFromPreTurnSnapshot({
38430
- sessionId,
38431
- runId,
38432
- agentCwd,
38433
- sendSessionUpdate,
38434
- log: log2
38435
- });
38436
- }
38437
- const planningTodosSubmit = await maybeSubmitPlanningTodosAfterAgentSuccess({
38470
+ const planningTodosSubmit = isPlanningSession ? await maybeSubmitPlanningTodosAfterAgentSuccess({
38438
38471
  sessionId,
38439
38472
  runId,
38440
38473
  resultSuccess: result.success === true,
@@ -38442,11 +38475,11 @@ async function finalizeAndSendPromptResult(params) {
38442
38475
  cloudApiBaseUrl,
38443
38476
  getCloudAccessToken,
38444
38477
  log: log2
38445
- });
38478
+ }) : { suppressOutput: false };
38479
+ const planningFallbackOutput = !planningTodosSubmit.suppressOutput && isPlanningSession && runId ? consumePlanningSessionTurnOutput(runId) : "";
38446
38480
  const errStr = typeof result.error === "string" ? result.error : void 0;
38447
38481
  const resultStop = typeof result.stopReason === "string" ? result.stopReason.trim() : "";
38448
38482
  const cancelledByAgent = resultStop.toLowerCase() === "cancelled" || errStr != null && isUserEndedSessionTurnErrorText(errStr);
38449
- const planningFallbackOutput = !planningTodosSubmit.suppressOutput && isPlanningSession && runId ? consumePlanningSessionTurnOutput(runId) : "";
38450
38483
  sendResult({
38451
38484
  type: "prompt_result",
38452
38485
  id: promptId,
@@ -38467,6 +38500,14 @@ async function finalizeAndSendPromptResult(params) {
38467
38500
  );
38468
38501
  }
38469
38502
  }
38503
+ void reportPostTurnEnrichment({
38504
+ sessionId,
38505
+ runId,
38506
+ agentCwd,
38507
+ result,
38508
+ sendSessionUpdate,
38509
+ log: log2
38510
+ });
38470
38511
  }
38471
38512
 
38472
38513
  // src/agents/acp/build-forked-session-agent-prompt.ts
@@ -38923,7 +38964,6 @@ async function sendPromptToAgent(options) {
38923
38964
  followUpCatalogPromptId,
38924
38965
  cloudApiBaseUrl,
38925
38966
  getCloudAccessToken,
38926
- e2ee,
38927
38967
  sendResult,
38928
38968
  sendSessionUpdate,
38929
38969
  log: log2
@@ -38946,16 +38986,6 @@ async function sendPromptToAgent(options) {
38946
38986
  }
38947
38987
  }
38948
38988
 
38949
- // src/agents/acp/manager/get-acp-agent-state.ts
38950
- function getAcpSessionAgentState(ctx, acpSessionAgentKey) {
38951
- let state = ctx.acpAgents.get(acpSessionAgentKey);
38952
- if (!state) {
38953
- state = createEmptyAcpClientState();
38954
- ctx.acpAgents.set(acpSessionAgentKey, state);
38955
- }
38956
- return state;
38957
- }
38958
-
38959
38989
  // src/agents/acp/manager/handle-pending-prompt-cancel.ts
38960
38990
  async function handlePendingPromptCancel(params) {
38961
38991
  const { ctx, activeRunId, promptId, sessionId, handle, sendResult } = params;
@@ -38979,94 +39009,104 @@ async function handlePendingPromptCancel(params) {
38979
39009
  return true;
38980
39010
  }
38981
39011
 
38982
- // src/agents/acp/manager/run-acp-prompt.ts
38983
- async function runAcpPrompt(ctx, runCtx, opts) {
38984
- const {
38985
- promptText,
38986
- promptId,
38987
- sessionId,
38988
- mode,
38989
- agentConfig,
38990
- sessionParentPath,
38991
- sendResult,
38992
- sendSessionUpdate,
38993
- followUpCatalogPromptId,
38994
- cloudApiBaseUrl,
38995
- getCloudAccessToken,
38996
- e2ee,
38997
- attachments,
38998
- isNewSession
38999
- } = opts;
39000
- const { activeRunId, activeAcpAgentKey, activeAcpSessionAgentKey, preferredForPrompt } = runCtx;
39001
- const acpAgentState = getAcpSessionAgentState(ctx, activeAcpSessionAgentKey);
39002
- const handle = await ensureAcpClient({
39003
- state: acpAgentState,
39004
- acpAgentKey: activeAcpAgentKey,
39005
- preferredAgentType: preferredForPrompt,
39006
- mode,
39007
- agentConfig: agentConfig ?? null,
39008
- sessionParentPath,
39009
- resolveRouting: () => ctx.promptRouting.resolveRouting(activeAcpSessionAgentKey),
39010
- cloudSessionId: sessionId,
39011
- bridgeAccessPort: ctx.getBridgeAccessPort(),
39012
- sendSessionUpdate,
39013
- sendRequest: sendSessionUpdate,
39014
- log: ctx.log,
39015
- reportAgentCapabilities: ctx.reportAgentCapabilities
39016
- });
39017
- if (!handle) {
39018
- const errMsg = acpAgentState.lastAcpStartError || "No agent configured. Register local agents on this bridge in the app.";
39019
- const evaluated = Boolean(preferredForPrompt && errMsg.trim());
39020
- const suggestsAuth = evaluated ? localAgentErrorSuggestsAuth(preferredForPrompt, errMsg) : false;
39021
- const auth = suggestsAuth && preferredForPrompt ? { agentAuthRequired: true, agentType: preferredForPrompt } : {};
39022
- sendResult({
39012
+ // src/agents/acp/manager/dispatch-acp-prompt.ts
39013
+ async function dispatchAcpPrompt(ctx, runCtx, opts, handle) {
39014
+ const { activeRunId, activeAcpSessionAgentKey, preferredForPrompt } = runCtx;
39015
+ if (!ctx.promptRouting.isRegisteredRun(activeRunId)) {
39016
+ opts.sendResult({
39023
39017
  type: "prompt_result",
39024
- id: promptId,
39025
- ...sessionId ? { sessionId } : {},
39018
+ id: opts.promptId,
39019
+ ...opts.sessionId ? { sessionId: opts.sessionId } : {},
39026
39020
  runId: activeRunId,
39027
39021
  success: false,
39028
- error: errMsg,
39029
- ...auth
39022
+ error: "Prompt dispatch was superseded before the agent started."
39030
39023
  });
39031
39024
  return;
39032
39025
  }
39033
- if (!ctx.promptRouting.isRegisteredRun(activeRunId)) {
39034
- return;
39035
- }
39036
39026
  const cancelled = await handlePendingPromptCancel({
39037
39027
  ctx,
39038
39028
  activeRunId,
39039
- promptId,
39040
- sessionId,
39029
+ promptId: opts.promptId,
39030
+ sessionId: opts.sessionId,
39041
39031
  handle,
39042
- sendResult
39032
+ sendResult: opts.sendResult
39043
39033
  });
39044
39034
  if (cancelled) return;
39045
39035
  ctx.promptRouting.setStreamingRunId(activeAcpSessionAgentKey, activeRunId);
39046
39036
  try {
39047
39037
  await sendPromptToAgent({
39048
39038
  handle,
39049
- promptText,
39050
- promptId,
39051
- sessionId,
39039
+ promptText: opts.promptText,
39040
+ promptId: opts.promptId,
39041
+ sessionId: opts.sessionId,
39052
39042
  runId: activeRunId,
39053
39043
  agentType: preferredForPrompt,
39054
- agentCwd: resolveSessionParentPathForAgentProcess(sessionParentPath),
39055
- sendResult,
39056
- sendSessionUpdate,
39044
+ agentCwd: resolveSessionParentPathForAgentProcess(opts.sessionParentPath),
39045
+ sendResult: opts.sendResult,
39046
+ sendSessionUpdate: opts.sendSessionUpdate,
39057
39047
  log: ctx.log,
39058
- followUpCatalogPromptId,
39059
- cloudApiBaseUrl,
39060
- getCloudAccessToken,
39061
- e2ee,
39062
- attachments,
39063
- isNewSession
39048
+ followUpCatalogPromptId: opts.followUpCatalogPromptId,
39049
+ cloudApiBaseUrl: opts.cloudApiBaseUrl,
39050
+ getCloudAccessToken: opts.getCloudAccessToken,
39051
+ e2ee: opts.e2ee,
39052
+ attachments: opts.attachments,
39053
+ isNewSession: opts.isNewSession
39064
39054
  });
39065
39055
  } finally {
39066
39056
  ctx.promptRouting.clearStreamingRunId(activeAcpSessionAgentKey, activeRunId);
39067
39057
  }
39068
39058
  }
39069
39059
 
39060
+ // src/agents/acp/manager/get-acp-agent-state.ts
39061
+ function getAcpSessionAgentState(ctx, acpSessionAgentKey) {
39062
+ let state = ctx.acpAgents.get(acpSessionAgentKey);
39063
+ if (!state) {
39064
+ state = createEmptyAcpClientState();
39065
+ ctx.acpAgents.set(acpSessionAgentKey, state);
39066
+ }
39067
+ return state;
39068
+ }
39069
+
39070
+ // src/agents/acp/manager/ensure-acp-prompt-client.ts
39071
+ async function ensureAcpPromptClient(ctx, runCtx, opts) {
39072
+ const state = getAcpSessionAgentState(ctx, runCtx.activeAcpSessionAgentKey);
39073
+ const handle = await ensureAcpClient({
39074
+ state,
39075
+ acpAgentKey: runCtx.activeAcpAgentKey,
39076
+ preferredAgentType: runCtx.preferredForPrompt,
39077
+ mode: opts.mode,
39078
+ agentConfig: opts.agentConfig ?? null,
39079
+ sessionParentPath: opts.sessionParentPath,
39080
+ resolveRouting: () => ctx.promptRouting.resolveRouting(runCtx.activeAcpSessionAgentKey),
39081
+ cloudSessionId: opts.sessionId,
39082
+ bridgeAccessPort: ctx.getBridgeAccessPort(),
39083
+ sendSessionUpdate: opts.sendSessionUpdate,
39084
+ sendRequest: opts.sendSessionUpdate,
39085
+ log: ctx.log,
39086
+ reportAgentCapabilities: ctx.reportAgentCapabilities
39087
+ });
39088
+ if (handle) return handle;
39089
+ const error40 = state.lastAcpStartError || "No agent configured. Register local agents on this bridge in the app.";
39090
+ const agentType = runCtx.preferredForPrompt;
39091
+ const requiresAuth = Boolean(agentType && localAgentErrorSuggestsAuth(agentType, error40));
39092
+ opts.sendResult({
39093
+ type: "prompt_result",
39094
+ id: opts.promptId,
39095
+ ...opts.sessionId ? { sessionId: opts.sessionId } : {},
39096
+ runId: runCtx.activeRunId,
39097
+ success: false,
39098
+ error: error40,
39099
+ ...requiresAuth && agentType ? { agentAuthRequired: true, agentType } : {}
39100
+ });
39101
+ return null;
39102
+ }
39103
+
39104
+ // src/agents/acp/manager/run-acp-prompt.ts
39105
+ async function runAcpPrompt(ctx, runCtx, opts) {
39106
+ const handle = await ensureAcpPromptClient(ctx, runCtx, opts);
39107
+ if (handle) await dispatchAcpPrompt(ctx, runCtx, opts, handle);
39108
+ }
39109
+
39070
39110
  // src/agents/acp/manager/handle-prompt.ts
39071
39111
  function handlePrompt(ctx, opts) {
39072
39112
  const { promptId, sessionId, runId, mode, agentType, agentConfig, sendResult } = opts;
@@ -51924,9 +51964,6 @@ function setRunIdQueueKey(runId, queueKey) {
51924
51964
  runIdToQueueKey.set(runId, queueKey);
51925
51965
  locallyDispatchedRunIds.add(runId);
51926
51966
  }
51927
- function isLocallyDispatchedRun(runId) {
51928
- return locallyDispatchedRunIds.has(runId);
51929
- }
51930
51967
  function deleteRunIdQueueKey(runId) {
51931
51968
  const queueKey = runIdToQueueKey.get(runId);
51932
51969
  runIdToQueueKey.delete(runId);
@@ -51953,11 +51990,39 @@ async function dispatchStartedPromptQueueRuns(entries, started, deps) {
51953
51990
 
51954
51991
  // src/prompt-turn-queue/runner/handle-prompt-queue-cancellations.ts
51955
51992
  init_yield_to_event_loop();
51993
+
51994
+ // src/prompt-turn-queue/client-report.ts
51995
+ function sendPromptQueueClientReport(ws, queues) {
51996
+ if (!ws) return false;
51997
+ const wireQueues = {};
51998
+ for (const [queueKey, rows] of Object.entries(queues)) {
51999
+ wireQueues[queueKey] = rows.map((r) => ({ turnId: r.turnId, clientState: r.cliState }));
52000
+ }
52001
+ sendWsMessage(ws, { type: "prompt_queue_client_report", queues: wireQueues });
52002
+ return true;
52003
+ }
52004
+
52005
+ // src/prompt-turn-queue/runner/finalize-prompt-turn-on-bridge.ts
52006
+ async function finalizePromptTurnOnBridge(getWs, runId, success2, opts) {
52007
+ if (!runId) return false;
52008
+ const queueKey = deleteRunIdQueueKey(runId);
52009
+ if (!queueKey) return false;
52010
+ const f = await readPersistedQueue(queueKey);
52011
+ if (!f) return false;
52012
+ const t = f.turns.find((x) => x.turnId === runId);
52013
+ if (!t) return false;
52014
+ t.lastCliState = opts?.terminalCliState ?? (success2 ? "stopped" : "failed");
52015
+ await writePersistedQueue(f);
52016
+ sendPromptQueueClientReport(getWs(), { [queueKey]: [{ turnId: runId, cliState: t.lastCliState }] });
52017
+ return true;
52018
+ }
52019
+
52020
+ // src/prompt-turn-queue/runner/handle-prompt-queue-cancellations.ts
51956
52021
  async function handlePromptQueueCancellations(entries, deps) {
51957
52022
  for (const [queueKey] of entries) {
51958
52023
  const file2 = await readPersistedQueue(queueKey);
51959
52024
  const turn = file2?.turns.find((row) => row.bridgeServerState === "cancel_requested" && row.lastCliState === "running");
51960
- if (!turn || getRunIdQueueKey(turn.turnId) !== queueKey || !isLocallyDispatchedRun(turn.turnId)) {
52025
+ if (!turn || getRunIdQueueKey(turn.turnId) !== queueKey) {
51961
52026
  await yieldToEventLoop();
51962
52027
  continue;
51963
52028
  }
@@ -51966,7 +52031,8 @@ async function handlePromptQueueCancellations(entries, deps) {
51966
52031
  await yieldToEventLoop();
51967
52032
  continue;
51968
52033
  }
51969
- deps.log(`[Queue] cancel_requested for ${turn.turnId.slice(0, 8)}\u2026 but no local ACP run remains.`);
52034
+ deps.log(`[Queue] No local ACP run remains for ${turn.turnId.slice(0, 8)}\u2026; reconciling cancelled turn.`);
52035
+ await finalizePromptTurnOnBridge(deps.getWs, turn.turnId, false, { terminalCliState: "cancelled" });
51970
52036
  await yieldToEventLoop();
51971
52037
  }
51972
52038
  }
@@ -51994,17 +52060,6 @@ function promptQueueSnapshotEntries(queues) {
51994
52060
  // src/prompt-turn-queue/runner/start-prompt-queue-runs.ts
51995
52061
  init_yield_to_event_loop();
51996
52062
 
51997
- // src/prompt-turn-queue/client-report.ts
51998
- function sendPromptQueueClientReport(ws, queues) {
51999
- if (!ws) return false;
52000
- const wireQueues = {};
52001
- for (const [queueKey, rows] of Object.entries(queues)) {
52002
- wireQueues[queueKey] = rows.map((r) => ({ turnId: r.turnId, clientState: r.cliState }));
52003
- }
52004
- sendWsMessage(ws, { type: "prompt_queue_client_report", queues: wireQueues });
52005
- return true;
52006
- }
52007
-
52008
52063
  // src/prompt-turn-queue/runner/queue-selection.ts
52009
52064
  function pickNextRunnableTurn(turns) {
52010
52065
  for (const t of turns) {
@@ -52178,21 +52233,6 @@ async function applyPromptQueueStateFromServer(msg, deps) {
52178
52233
  await dispatchStartedPromptQueueRuns(entries, started, deps);
52179
52234
  }
52180
52235
 
52181
- // src/prompt-turn-queue/runner/finalize-prompt-turn-on-bridge.ts
52182
- async function finalizePromptTurnOnBridge(getWs, runId, success2, opts) {
52183
- if (!runId) return false;
52184
- const queueKey = deleteRunIdQueueKey(runId);
52185
- if (!queueKey) return false;
52186
- const f = await readPersistedQueue(queueKey);
52187
- if (!f) return false;
52188
- const t = f.turns.find((x) => x.turnId === runId);
52189
- if (!t) return false;
52190
- t.lastCliState = opts?.terminalCliState ?? (success2 ? "stopped" : "failed");
52191
- await writePersistedQueue(f);
52192
- sendPromptQueueClientReport(getWs(), { [queueKey]: [{ turnId: runId, cliState: t.lastCliState }] });
52193
- return true;
52194
- }
52195
-
52196
52236
  // src/agents/acp/from-bridge/bridge-prompt-wiring.ts
52197
52237
  function createBridgePromptSenders(deps, getWs) {
52198
52238
  const sendBridgeMessage = (message, encryptedFields = []) => {
@@ -52382,17 +52422,14 @@ function handleBridgePrompt(msg, deps) {
52382
52422
  log2(
52383
52423
  `[Bridge service] Prompt ignored: empty or missing prompt text (session ${typeof msg.sessionId === "string" ? msg.sessionId.slice(0, 8) : "\u2014"}\u2026, run ${typeof msg.runId === "string" ? msg.runId.slice(0, 8) : "\u2014"}\u2026).`
52384
52424
  );
52385
- senders.sendBridgeMessage(
52386
- {
52387
- type: "prompt_result",
52388
- ...promptId ? { id: promptId } : {},
52389
- ...sessionId ? { sessionId } : {},
52390
- ...runId ? { runId } : {},
52391
- success: false,
52392
- error: "Empty or missing prompt text from the bridge; this turn was not sent to the agent."
52393
- },
52394
- ["error"]
52395
- );
52425
+ senders.sendResult({
52426
+ type: "prompt_result",
52427
+ ...promptId ? { id: promptId } : {},
52428
+ ...sessionId ? { sessionId } : {},
52429
+ ...runId ? { runId } : {},
52430
+ success: false,
52431
+ error: "Empty or missing prompt text from the bridge; this turn was not sent to the agent."
52432
+ });
52396
52433
  return;
52397
52434
  }
52398
52435
  const isNewSession = msg.isNewSession === true;