@buildautomaton/cli 0.1.43 → 0.1.45

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
@@ -24468,7 +24468,7 @@ function installBridgeProcessResilience() {
24468
24468
  }
24469
24469
 
24470
24470
  // src/cli-version.ts
24471
- var CLI_VERSION = "0.1.43".length > 0 ? "0.1.43" : "0.0.0-dev";
24471
+ var CLI_VERSION = "0.1.45".length > 0 ? "0.1.45" : "0.0.0-dev";
24472
24472
 
24473
24473
  // src/connection/heartbeat/constants.ts
24474
24474
  var BRIDGE_APP_HEARTBEAT_INTERVAL_MS = 1e4;
@@ -26116,38 +26116,38 @@ async function closeBridgeConnection(state, acpManager, devServerManager, log2)
26116
26116
  // src/agents/acp/acp-prompt-routing-registry.ts
26117
26117
  var AcpPromptRoutingRegistry = class {
26118
26118
  runs = /* @__PURE__ */ new Map();
26119
- streamingRunIdByAcpAgent = /* @__PURE__ */ new Map();
26119
+ streamingRunIdBySessionAgent = /* @__PURE__ */ new Map();
26120
26120
  registerRun(route) {
26121
26121
  this.runs.set(route.runId, route);
26122
26122
  }
26123
26123
  unregisterRun(runId) {
26124
26124
  this.runs.delete(runId);
26125
- for (const [acpAgentKey, streamingRunId] of this.streamingRunIdByAcpAgent.entries()) {
26125
+ for (const [sessionAgentKey, streamingRunId] of this.streamingRunIdBySessionAgent.entries()) {
26126
26126
  if (streamingRunId === runId) {
26127
- this.streamingRunIdByAcpAgent.delete(acpAgentKey);
26127
+ this.streamingRunIdBySessionAgent.delete(sessionAgentKey);
26128
26128
  }
26129
26129
  }
26130
26130
  }
26131
26131
  isRegisteredRun(runId) {
26132
26132
  return this.runs.has(runId);
26133
26133
  }
26134
- setStreamingRunId(acpAgentKey, runId) {
26134
+ setStreamingRunId(sessionAgentKey, runId) {
26135
26135
  if (runId) {
26136
- this.streamingRunIdByAcpAgent.set(acpAgentKey, runId);
26136
+ this.streamingRunIdBySessionAgent.set(sessionAgentKey, runId);
26137
26137
  } else {
26138
- this.streamingRunIdByAcpAgent.delete(acpAgentKey);
26138
+ this.streamingRunIdBySessionAgent.delete(sessionAgentKey);
26139
26139
  }
26140
26140
  }
26141
- clearStreamingRunId(acpAgentKey, runId) {
26142
- if (this.streamingRunIdByAcpAgent.get(acpAgentKey) === runId) {
26143
- this.streamingRunIdByAcpAgent.delete(acpAgentKey);
26141
+ clearStreamingRunId(sessionAgentKey, runId) {
26142
+ if (this.streamingRunIdBySessionAgent.get(sessionAgentKey) === runId) {
26143
+ this.streamingRunIdBySessionAgent.delete(sessionAgentKey);
26144
26144
  }
26145
26145
  }
26146
- getStreamingRunId(acpAgentKey) {
26147
- return this.streamingRunIdByAcpAgent.get(acpAgentKey);
26146
+ getStreamingRunId(sessionAgentKey) {
26147
+ return this.streamingRunIdBySessionAgent.get(sessionAgentKey);
26148
26148
  }
26149
- resolveRouting(acpAgentKey) {
26150
- const runId = this.streamingRunIdByAcpAgent.get(acpAgentKey);
26149
+ resolveRouting(sessionAgentKey) {
26150
+ const runId = this.streamingRunIdBySessionAgent.get(sessionAgentKey);
26151
26151
  if (!runId) return void 0;
26152
26152
  return this.runs.get(runId);
26153
26153
  }
@@ -26170,9 +26170,9 @@ function createAcpManagerContext(options) {
26170
26170
  async function cancelRun(ctx, runId) {
26171
26171
  const meta = ctx.runDispatch.get(runId);
26172
26172
  if (!meta) return false;
26173
- const streamingRunId = ctx.promptRouting.getStreamingRunId(meta.acpAgentKey);
26173
+ const streamingRunId = ctx.promptRouting.getStreamingRunId(meta.acpSessionAgentKey);
26174
26174
  if (streamingRunId && streamingRunId !== runId) return false;
26175
- const handle = ctx.acpAgents.get(meta.acpAgentKey)?.acpHandle;
26175
+ const handle = ctx.acpAgents.get(meta.acpSessionAgentKey)?.acpHandle;
26176
26176
  if (handle?.cancel) {
26177
26177
  ctx.log("[Agent] Stop requested");
26178
26178
  try {
@@ -26265,9 +26265,9 @@ async function execProbeShutdownAware(file2, args, timeoutMs) {
26265
26265
 
26266
26266
  // src/agents/acp/clients/claude-code-acp-client.ts
26267
26267
  var BACKEND_LOCAL_AGENT_TYPE = "claude-code";
26268
+ var CLAUDE_ACP_ADAPTER_NPX_ARGS = ["--yes", "@agentclientprotocol/claude-agent-acp"];
26268
26269
  async function detectLocalAgentPresence() {
26269
- if (await isCommandOnPath("claude")) return true;
26270
- return execProbeShutdownAware("npx", ["--yes", "@anthropic-ai/claude-code", "--version"], 3e3);
26270
+ return execProbeShutdownAware("npx", [...CLAUDE_ACP_ADAPTER_NPX_ARGS, "--help"], 8e3);
26271
26271
  }
26272
26272
  function buildClaudeCodeAcpSpawnCommand(base, _sessionMode) {
26273
26273
  return [...base];
@@ -27102,6 +27102,8 @@ function createBridgeOnRequest(opts) {
27102
27102
  ...sessionId ? { sessionId } : {},
27103
27103
  runId,
27104
27104
  kind,
27105
+ /** Top-level for bridge DO jobs / web push when `payload` is E2EE-encrypted. */
27106
+ requestId: request.requestId,
27105
27107
  payload: {
27106
27108
  sessionUpdate,
27107
27109
  requestId: request.requestId,
@@ -27708,6 +27710,11 @@ function writeLocalAgentSessionFile(cloudSessionId, patch) {
27708
27710
  }
27709
27711
 
27710
27712
  // src/agents/acp/acp-agent.ts
27713
+ function computeAcpSessionAgentKey(cloudSessionId, acpAgentKey) {
27714
+ const sid = cloudSessionId?.trim();
27715
+ if (!sid) return `::${acpAgentKey}`;
27716
+ return `${sid}::${acpAgentKey}`;
27717
+ }
27711
27718
  function computeAcpAgentKey(preferredAgentType, mode, agentConfig) {
27712
27719
  const resolved = resolveAgentCommand(preferredAgentType);
27713
27720
  if (!resolved) return null;
@@ -33182,11 +33189,11 @@ async function sendPromptToAgent(options) {
33182
33189
  }
33183
33190
 
33184
33191
  // src/agents/acp/manager/get-acp-agent-state.ts
33185
- function getAcpAgentState(ctx, acpAgentKey) {
33186
- let state = ctx.acpAgents.get(acpAgentKey);
33192
+ function getAcpSessionAgentState(ctx, acpSessionAgentKey) {
33193
+ let state = ctx.acpAgents.get(acpSessionAgentKey);
33187
33194
  if (!state) {
33188
33195
  state = createEmptyAcpClientState();
33189
- ctx.acpAgents.set(acpAgentKey, state);
33196
+ ctx.acpAgents.set(acpSessionAgentKey, state);
33190
33197
  }
33191
33198
  return state;
33192
33199
  }
@@ -33230,11 +33237,12 @@ function handlePrompt(ctx, opts) {
33230
33237
  return;
33231
33238
  }
33232
33239
  const activeAcpAgentKey = acpAgentKey;
33240
+ const activeAcpSessionAgentKey = computeAcpSessionAgentKey(sessionId, activeAcpAgentKey);
33233
33241
  ctx.pendingCancelRunIds.delete(activeRunId);
33234
33242
  ctx.promptRouting.registerRun({ sessionId, runId: activeRunId });
33235
- ctx.runDispatch.set(activeRunId, { acpAgentKey: activeAcpAgentKey });
33243
+ ctx.runDispatch.set(activeRunId, { acpSessionAgentKey: activeAcpSessionAgentKey });
33236
33244
  async function run() {
33237
- const acpAgentState = getAcpAgentState(ctx, activeAcpAgentKey);
33245
+ const acpAgentState = getAcpSessionAgentState(ctx, activeAcpSessionAgentKey);
33238
33246
  const handle = await ensureAcpClient({
33239
33247
  state: acpAgentState,
33240
33248
  acpAgentKey: activeAcpAgentKey,
@@ -33242,7 +33250,7 @@ function handlePrompt(ctx, opts) {
33242
33250
  mode,
33243
33251
  agentConfig: agentConfig ?? null,
33244
33252
  sessionParentPath,
33245
- resolveRouting: () => ctx.promptRouting.resolveRouting(activeAcpAgentKey),
33253
+ resolveRouting: () => ctx.promptRouting.resolveRouting(activeAcpSessionAgentKey),
33246
33254
  cloudSessionId: sessionId,
33247
33255
  sendSessionUpdate,
33248
33256
  sendRequest: sendSessionUpdate,
@@ -33285,7 +33293,7 @@ function handlePrompt(ctx, opts) {
33285
33293
  });
33286
33294
  return;
33287
33295
  }
33288
- ctx.promptRouting.setStreamingRunId(activeAcpAgentKey, activeRunId);
33296
+ ctx.promptRouting.setStreamingRunId(activeAcpSessionAgentKey, activeRunId);
33289
33297
  try {
33290
33298
  await sendPromptToAgent({
33291
33299
  handle,
@@ -33306,7 +33314,7 @@ function handlePrompt(ctx, opts) {
33306
33314
  attachments
33307
33315
  });
33308
33316
  } finally {
33309
- ctx.promptRouting.clearStreamingRunId(activeAcpAgentKey, activeRunId);
33317
+ ctx.promptRouting.clearStreamingRunId(activeAcpSessionAgentKey, activeRunId);
33310
33318
  }
33311
33319
  }
33312
33320
  void run().finally(() => {