@buildautomaton/cli 0.1.44 → 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.44".length > 0 ? "0.1.44" : "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 {
@@ -27710,6 +27710,11 @@ function writeLocalAgentSessionFile(cloudSessionId, patch) {
27710
27710
  }
27711
27711
 
27712
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
+ }
27713
27718
  function computeAcpAgentKey(preferredAgentType, mode, agentConfig) {
27714
27719
  const resolved = resolveAgentCommand(preferredAgentType);
27715
27720
  if (!resolved) return null;
@@ -33184,11 +33189,11 @@ async function sendPromptToAgent(options) {
33184
33189
  }
33185
33190
 
33186
33191
  // src/agents/acp/manager/get-acp-agent-state.ts
33187
- function getAcpAgentState(ctx, acpAgentKey) {
33188
- let state = ctx.acpAgents.get(acpAgentKey);
33192
+ function getAcpSessionAgentState(ctx, acpSessionAgentKey) {
33193
+ let state = ctx.acpAgents.get(acpSessionAgentKey);
33189
33194
  if (!state) {
33190
33195
  state = createEmptyAcpClientState();
33191
- ctx.acpAgents.set(acpAgentKey, state);
33196
+ ctx.acpAgents.set(acpSessionAgentKey, state);
33192
33197
  }
33193
33198
  return state;
33194
33199
  }
@@ -33232,11 +33237,12 @@ function handlePrompt(ctx, opts) {
33232
33237
  return;
33233
33238
  }
33234
33239
  const activeAcpAgentKey = acpAgentKey;
33240
+ const activeAcpSessionAgentKey = computeAcpSessionAgentKey(sessionId, activeAcpAgentKey);
33235
33241
  ctx.pendingCancelRunIds.delete(activeRunId);
33236
33242
  ctx.promptRouting.registerRun({ sessionId, runId: activeRunId });
33237
- ctx.runDispatch.set(activeRunId, { acpAgentKey: activeAcpAgentKey });
33243
+ ctx.runDispatch.set(activeRunId, { acpSessionAgentKey: activeAcpSessionAgentKey });
33238
33244
  async function run() {
33239
- const acpAgentState = getAcpAgentState(ctx, activeAcpAgentKey);
33245
+ const acpAgentState = getAcpSessionAgentState(ctx, activeAcpSessionAgentKey);
33240
33246
  const handle = await ensureAcpClient({
33241
33247
  state: acpAgentState,
33242
33248
  acpAgentKey: activeAcpAgentKey,
@@ -33244,7 +33250,7 @@ function handlePrompt(ctx, opts) {
33244
33250
  mode,
33245
33251
  agentConfig: agentConfig ?? null,
33246
33252
  sessionParentPath,
33247
- resolveRouting: () => ctx.promptRouting.resolveRouting(activeAcpAgentKey),
33253
+ resolveRouting: () => ctx.promptRouting.resolveRouting(activeAcpSessionAgentKey),
33248
33254
  cloudSessionId: sessionId,
33249
33255
  sendSessionUpdate,
33250
33256
  sendRequest: sendSessionUpdate,
@@ -33287,7 +33293,7 @@ function handlePrompt(ctx, opts) {
33287
33293
  });
33288
33294
  return;
33289
33295
  }
33290
- ctx.promptRouting.setStreamingRunId(activeAcpAgentKey, activeRunId);
33296
+ ctx.promptRouting.setStreamingRunId(activeAcpSessionAgentKey, activeRunId);
33291
33297
  try {
33292
33298
  await sendPromptToAgent({
33293
33299
  handle,
@@ -33308,7 +33314,7 @@ function handlePrompt(ctx, opts) {
33308
33314
  attachments
33309
33315
  });
33310
33316
  } finally {
33311
- ctx.promptRouting.clearStreamingRunId(activeAcpAgentKey, activeRunId);
33317
+ ctx.promptRouting.clearStreamingRunId(activeAcpSessionAgentKey, activeRunId);
33312
33318
  }
33313
33319
  }
33314
33320
  void run().finally(() => {