@buildautomaton/cli 0.1.93 → 0.1.94

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
@@ -23755,6 +23755,15 @@ var init_acp = __esm({
23755
23755
  }
23756
23756
  });
23757
23757
 
23758
+ // ../bridge/src/runtime/yield-to-event-loop.ts
23759
+ function yieldToEventLoop() {
23760
+ return new Promise((resolve39) => setImmediate(resolve39));
23761
+ }
23762
+ var init_yield_to_event_loop = __esm({
23763
+ "../bridge/src/runtime/yield-to-event-loop.ts"() {
23764
+ }
23765
+ });
23766
+
23758
23767
  // ../bridge/src/files/index/constants.ts
23759
23768
  import path3 from "node:path";
23760
23769
  import os from "node:os";
@@ -24026,15 +24035,6 @@ var init_activity_tracker = __esm({
24026
24035
  }
24027
24036
  });
24028
24037
 
24029
- // ../bridge/src/runtime/yield-to-event-loop.ts
24030
- function yieldToEventLoop() {
24031
- return new Promise((resolve39) => setImmediate(resolve39));
24032
- }
24033
- var init_yield_to_event_loop = __esm({
24034
- "../bridge/src/runtime/yield-to-event-loop.ts"() {
24035
- }
24036
- });
24037
-
24038
24038
  // ../bridge/src/code-nav/symbol-index/deferred-indexing.ts
24039
24039
  function isSymbolIndexDeferredError(err) {
24040
24040
  return err instanceof SymbolIndexDeferredError;
@@ -24371,6 +24371,7 @@ function resetCodeNavCacheAvailabilityForTests() {
24371
24371
  var initState, initPromise, CodeNavCacheUnavailableError;
24372
24372
  var init_code_nav_cache_availability = __esm({
24373
24373
  "../bridge/src/sqlite/code-nav-cache/code-nav-cache-availability.ts"() {
24374
+ "use strict";
24374
24375
  init_log();
24375
24376
  init_in_flight();
24376
24377
  init_sqlite_errors();
@@ -24922,6 +24923,7 @@ function withCodeNavCacheSqliteWorkLock(fn) {
24922
24923
  var chain, workLockDepth;
24923
24924
  var init_code_nav_cache_sqlite_work_lock = __esm({
24924
24925
  "../bridge/src/sqlite/code-nav-cache/code-nav-cache-sqlite-work-lock.ts"() {
24926
+ "use strict";
24925
24927
  init_code_nav_cache_paths();
24926
24928
  chain = Promise.resolve();
24927
24929
  workLockDepth = 0;
@@ -30447,7 +30449,7 @@ var {
30447
30449
  } = import_index.default;
30448
30450
 
30449
30451
  // src/cli-version.ts
30450
- var CLI_VERSION = "0.1.93".length > 0 ? "0.1.93" : "0.0.0-dev";
30452
+ var CLI_VERSION = "0.1.94".length > 0 ? "0.1.94" : "0.0.0-dev";
30451
30453
 
30452
30454
  // src/cli/defaults.ts
30453
30455
  var DEFAULT_API_URL = process.env.BUILDAUTOMATON_API_URL ?? "https://api.buildautomaton.com";
@@ -30467,6 +30469,12 @@ var wrapper_default = import_websocket.default;
30467
30469
  // ../bridge/src/connection/ws/cli-ws-client.ts
30468
30470
  import https from "node:https";
30469
30471
  var CLI_WEBSOCKET_CLIENT_PING_MS = 25e3;
30472
+ var CLI_WEBSOCKET_HANDSHAKE_TIMEOUT_MS = 15e3;
30473
+ var sharedWssAgent = null;
30474
+ function cliWssAgent() {
30475
+ sharedWssAgent ??= new https.Agent({ rejectUnauthorized: false, keepAlive: true });
30476
+ return sharedWssAgent;
30477
+ }
30470
30478
  function attachWebSocketClientPing(ws, intervalMs) {
30471
30479
  let timer = null;
30472
30480
  function clear() {
@@ -30487,9 +30495,12 @@ function attachWebSocketClientPing(ws, intervalMs) {
30487
30495
  return clear;
30488
30496
  }
30489
30497
  function buildCliWebSocketClientOptions(wsUrl) {
30490
- const wsOptions = { perMessageDeflate: false };
30498
+ const wsOptions = {
30499
+ perMessageDeflate: false,
30500
+ handshakeTimeout: CLI_WEBSOCKET_HANDSHAKE_TIMEOUT_MS
30501
+ };
30491
30502
  if (wsUrl.startsWith("wss://")) {
30492
- wsOptions.agent = new https.Agent({ rejectUnauthorized: false });
30503
+ wsOptions.agent = cliWssAgent();
30493
30504
  }
30494
30505
  return wsOptions;
30495
30506
  }
@@ -30503,6 +30514,15 @@ function safeCloseWebSocket(ws) {
30503
30514
  ws.removeAllListeners();
30504
30515
  return;
30505
30516
  }
30517
+ if (ws.readyState === wrapper_default.CONNECTING) {
30518
+ ws.once("error", () => {
30519
+ });
30520
+ ws.once("close", () => {
30521
+ ws.removeAllListeners();
30522
+ });
30523
+ ws.terminate();
30524
+ return;
30525
+ }
30506
30526
  ws.once("close", () => {
30507
30527
  ws.removeAllListeners();
30508
30528
  });
@@ -30733,7 +30753,7 @@ function formatSpawnError(err, command) {
30733
30753
  }
30734
30754
 
30735
30755
  // ../bridge/src/agents/acp/clients/kill-process-tree.ts
30736
- var import_tree_kill = __toESM(require_tree_kill());
30756
+ var import_tree_kill = __toESM(require_tree_kill(), 1);
30737
30757
  import { promisify } from "node:util";
30738
30758
  var treeKillAsync = promisify(import_tree_kill.default);
30739
30759
  var ACP_PROCESS_TREE_KILL_GRACE_MS = 2500;
@@ -36525,7 +36545,25 @@ function spawnSdkStdioProcess(options) {
36525
36545
  return { child, stderrCapture };
36526
36546
  }
36527
36547
 
36548
+ // ../bridge/src/agents/acp/clients/listen-for-acp-client-abort.ts
36549
+ function listenForAcpClientAbort(child, signal, onAbort) {
36550
+ if (!signal) return () => {
36551
+ };
36552
+ const fire = () => {
36553
+ killChildProcessTree(child, "SIGKILL");
36554
+ onAbort();
36555
+ };
36556
+ if (signal.aborted) {
36557
+ fire();
36558
+ return () => {
36559
+ };
36560
+ }
36561
+ signal.addEventListener("abort", fire, { once: true });
36562
+ return () => signal.removeEventListener("abort", fire);
36563
+ }
36564
+
36528
36565
  // ../bridge/src/agents/acp/clients/sdk/sdk-stdio-acp-client.ts
36566
+ init_yield_to_event_loop();
36529
36567
  async function createSdkStdioAcpClient(options) {
36530
36568
  const { PROTOCOL_VERSION: PROTOCOL_VERSION2 } = await Promise.resolve().then(() => (init_acp(), acp_exports));
36531
36569
  const {
@@ -36543,13 +36581,18 @@ async function createSdkStdioAcpClient(options) {
36543
36581
  onAcpConfigOptionsUpdated,
36544
36582
  getActiveConfigOptions,
36545
36583
  afterSessionEstablished,
36546
- createExtNotificationHandler
36584
+ createExtNotificationHandler,
36585
+ signal
36547
36586
  } = options;
36587
+ if (signal?.aborted) {
36588
+ throw new Error("ACP client aborted");
36589
+ }
36548
36590
  const { child, stderrCapture } = spawnSdkStdioProcess({
36549
36591
  command,
36550
36592
  cwd,
36551
36593
  onAgentSubprocessExit
36552
36594
  });
36595
+ await yieldToEventLoop();
36553
36596
  const sessionCtx = createSdkStdioSessionContext({
36554
36597
  cwd,
36555
36598
  mcpServers: options.mcpServers,
@@ -36565,7 +36608,11 @@ async function createSdkStdioAcpClient(options) {
36565
36608
  });
36566
36609
  return new Promise((resolve39, reject) => {
36567
36610
  const init = createSdkStdioInitSettle(child);
36611
+ const stopAbort = listenForAcpClientAbort(child, signal, () => {
36612
+ init.settleReject(reject, new Error("ACP client aborted"));
36613
+ });
36568
36614
  child.on("error", (err) => {
36615
+ stopAbort();
36569
36616
  init.settleReject(reject, new Error(formatSpawnError(err, command[0])));
36570
36617
  });
36571
36618
  attachSdkStdioStderrAuthWatch({
@@ -36599,7 +36646,9 @@ async function createSdkStdioAcpClient(options) {
36599
36646
  killSubprocessAfterCancelMs
36600
36647
  })
36601
36648
  );
36649
+ stopAbort();
36602
36650
  } catch (err) {
36651
+ stopAbort();
36603
36652
  if (init.settled) return;
36604
36653
  init.settleReject(
36605
36654
  reject,
@@ -36871,22 +36920,12 @@ function installBridgeProcessResilience() {
36871
36920
  init_log();
36872
36921
 
36873
36922
  // ../bridge/src/agents/acp/clients/bridge-agent-path.ts
36874
- import { execFileSync } from "node:child_process";
36875
36923
  import { homedir } from "node:os";
36876
36924
  import { join } from "node:path";
36877
36925
  function getBridgeAgentPathEntries(home = process.env.HOME ?? homedir()) {
36878
- const entries = [
36879
- join(home, ".local", "bin"),
36880
- join(home, ".npm-global", "bin"),
36881
- "/usr/local/bin"
36882
- ];
36926
+ const entries = [join(home, ".local", "bin"), join(home, ".npm-global", "bin"), "/usr/local/bin"];
36883
36927
  const prefix = process.env.NPM_CONFIG_PREFIX;
36884
36928
  if (prefix) entries.push(join(prefix, "bin"));
36885
- try {
36886
- const npmBin = execFileSync("npm", ["bin", "-g"], { encoding: "utf8", timeout: 2e3 }).trim();
36887
- if (npmBin) entries.push(npmBin);
36888
- } catch {
36889
- }
36890
36929
  return entries;
36891
36930
  }
36892
36931
  function augmentPath(pathValue, extra) {
@@ -38128,6 +38167,22 @@ function beginDeferredDisconnectForReconnect(options) {
38128
38167
  }
38129
38168
  }
38130
38169
 
38170
+ // ../bridge/src/connection/ws/dispose-previous-bridge-socket.ts
38171
+ function disposePreviousBridgeSocket(ws) {
38172
+ if (!ws) return;
38173
+ ws.removeAllListeners();
38174
+ ws.once("error", () => {
38175
+ });
38176
+ ws.once("close", () => {
38177
+ ws.removeAllListeners();
38178
+ });
38179
+ try {
38180
+ if (ws.readyState === wrapper_default.CONNECTING) ws.terminate();
38181
+ else ws.close();
38182
+ } catch {
38183
+ }
38184
+ }
38185
+
38131
38186
  // ../bridge/src/connection/runtime/close-bridge-connection.ts
38132
38187
  async function closeBridgeConnection(state, acpManager, previewEnvironmentManager, log2) {
38133
38188
  requestCliImmediateShutdown();
@@ -38144,16 +38199,7 @@ async function closeBridgeConnection(state, acpManager, previewEnvironmentManage
38144
38199
  await acpManager.disconnect();
38145
38200
  if (state.currentWs) {
38146
38201
  say("Closing bridge connection to the cloud\u2026");
38147
- state.currentWs.removeAllListeners();
38148
- const wsState = state.currentWs.readyState;
38149
- if (wsState === 1 || wsState === 2) {
38150
- state.currentWs.close();
38151
- } else {
38152
- state.currentWs.on("error", () => {
38153
- });
38154
- state.currentWs.on("close", () => {
38155
- });
38156
- }
38202
+ disposePreviousBridgeSocket(state.currentWs);
38157
38203
  state.currentWs = null;
38158
38204
  }
38159
38205
  if (previewEnvironmentManager) {
@@ -39347,7 +39393,8 @@ async function createCursorAcpClient(options) {
39347
39393
  onAcpSessionEstablished,
39348
39394
  onAcpConfigOptionsUpdated,
39349
39395
  onAgentSubprocessExit,
39350
- afterSessionEstablished
39396
+ afterSessionEstablished,
39397
+ signal
39351
39398
  } = options;
39352
39399
  const dbgFs = process.env.BUILDAUTOMATON_DEBUG_ACP_FS === "1";
39353
39400
  const spawnEnv = bridgeInstalledAgentAuthProcessEnv(process.env);
@@ -39372,7 +39419,11 @@ async function createCursorAcpClient(options) {
39372
39419
  stderrCapture
39373
39420
  });
39374
39421
  return new Promise((resolve39, reject) => {
39422
+ const stopAbort = listenForAcpClientAbort(child, signal, () => {
39423
+ reject(new Error("ACP client aborted"));
39424
+ });
39375
39425
  child.on("error", (err) => {
39426
+ stopAbort();
39376
39427
  killChildProcessTree(child, "SIGKILL");
39377
39428
  reject(new Error(formatSpawnError(err, command[0])));
39378
39429
  });
@@ -39384,6 +39435,7 @@ async function createCursorAcpClient(options) {
39384
39435
  skipBrowserAuthenticate,
39385
39436
  incomingDeps: { dbgFs, sessionCtx, onSessionUpdate, onRequest }
39386
39437
  });
39438
+ stopAbort();
39387
39439
  resolve39(
39388
39440
  createCursorAcpHandle({
39389
39441
  child,
@@ -39396,6 +39448,7 @@ async function createCursorAcpClient(options) {
39396
39448
  })
39397
39449
  );
39398
39450
  } catch (err) {
39451
+ stopAbort();
39399
39452
  killChildProcessTree(child, "SIGKILL");
39400
39453
  const merged = mergeErrorWithStderr(formatJsonRpcStyleError(err), stderrCapture.getText());
39401
39454
  reject(merged ? new Error(merged) : err instanceof Error ? err : new Error(String(err)));
@@ -39562,7 +39615,7 @@ function getAgentTypeDisplayName(agentType) {
39562
39615
  import { existsSync as existsSync4, statSync } from "node:fs";
39563
39616
 
39564
39617
  // ../bridge/src/git/git-exec.ts
39565
- import { execFile as execFile2, execFileSync as execFileSync2, spawn as spawn4 } from "node:child_process";
39618
+ import { execFile as execFile2, execFileSync, spawn as spawn4 } from "node:child_process";
39566
39619
  import { promisify as promisify3 } from "node:util";
39567
39620
 
39568
39621
  // ../bridge/src/git/git-runtime.ts
@@ -39620,7 +39673,7 @@ init_cli_process_interrupt();
39620
39673
  var execFileAsync2 = promisify3(execFile2);
39621
39674
  var GIT_SYNC_STDIO = ["ignore", "pipe", "pipe"];
39622
39675
  function execGitFileSync(args, options) {
39623
- return execFileSync2("git", args, {
39676
+ return execFileSync("git", args, {
39624
39677
  encoding: "utf8",
39625
39678
  maxBuffer: 10 * 1024 * 1024,
39626
39679
  ...options,
@@ -42188,45 +42241,53 @@ function listCliAgentCapabilityCacheForWorkspace(db, workspaceId) {
42188
42241
  // ../bridge/src/agents/capabilities/probe-agent-capabilities-for-types.ts
42189
42242
  init_cli_database();
42190
42243
 
42244
+ // ../bridge/src/agents/capabilities/agent-capability-warmup-run.ts
42245
+ init_cli_process_interrupt();
42246
+ var warmupEpoch = 0;
42247
+ var probedTypesThisProcess = /* @__PURE__ */ new Set();
42248
+ function cancelInFlightAgentCapabilityWarmup() {
42249
+ warmupEpoch += 1;
42250
+ }
42251
+ function beginAgentCapabilityWarmupRun() {
42252
+ const epoch = warmupEpoch += 1;
42253
+ return () => epoch === warmupEpoch && !isCliImmediateShutdownRequested();
42254
+ }
42255
+ function wasAgentCapabilityTypeProbedThisProcess(agentType) {
42256
+ return probedTypesThisProcess.has(agentType);
42257
+ }
42258
+ function markAgentCapabilityTypeProbedThisProcess(agentType) {
42259
+ probedTypesThisProcess.add(agentType);
42260
+ }
42261
+ function shouldSkipCapabilityProbeThisProcess(agentType) {
42262
+ if (process.env.BUILDAUTOMATON_FORCE_PROBE_ACP_CAPABILITIES === "1") return false;
42263
+ return wasAgentCapabilityTypeProbedThisProcess(agentType);
42264
+ }
42265
+
42191
42266
  // ../bridge/src/agents/capabilities/probe-one-agent-type-for-capabilities.ts
42192
42267
  import * as path35 from "node:path";
42193
42268
  init_cli_database();
42269
+ init_yield_to_event_loop();
42194
42270
  init_cli_process_interrupt();
42271
+ var ACP_CAPABILITY_PROBE_TIMEOUT_MS = 12e3;
42195
42272
  async function probeOneAgentTypeForCapabilities(params) {
42196
42273
  const { agentType, cwd, workspaceId, log: log2, reportAgentCapabilities, bridgeReport = true, shouldContinue } = params;
42197
- const canContinue = () => shouldContinue?.() !== false;
42274
+ const canContinue = () => shouldContinue?.() !== false && !isCliImmediateShutdownRequested();
42198
42275
  if (!canContinue()) return false;
42199
42276
  const resolved = resolveAgentCommand(agentType);
42200
42277
  if (!resolved) return false;
42201
- let sqliteChanged = false;
42202
- const reportedRef = { done: false };
42203
- const tryReport = (co) => {
42204
- if (reportedRef.done) return;
42205
- if (!Array.isArray(co) || co.length === 0) return;
42206
- reportedRef.done = true;
42207
- let changed = false;
42208
- try {
42209
- changed = withCliSqliteSync(
42210
- (db) => upsertCliAgentCapabilityCache(db, {
42211
- workspaceId,
42212
- agentType,
42213
- configOptions: co
42214
- })
42215
- );
42216
- } catch {
42217
- }
42218
- sqliteChanged ||= changed;
42219
- if (bridgeReport && changed) {
42220
- reportAgentCapabilities?.({ agentType, configOptions: co });
42221
- }
42222
- };
42278
+ await yieldToEventLoop();
42279
+ if (!canContinue()) return false;
42280
+ markAgentCapabilityTypeProbedThisProcess(agentType);
42281
+ let pendingCo = null;
42282
+ const ac = new AbortController();
42283
+ const abortTimer = setTimeout(() => ac.abort(), ACP_CAPABILITY_PROBE_TIMEOUT_MS);
42284
+ abortTimer.unref?.();
42285
+ const abortIfStale = setInterval(() => {
42286
+ if (!canContinue()) ac.abort();
42287
+ }, 50);
42288
+ abortIfStale.unref?.();
42223
42289
  let handle = null;
42224
- const killTimer = setTimeout(() => {
42225
- void handle?.disconnectGracefully();
42226
- }, 28e3);
42227
- killTimer.unref?.();
42228
42290
  try {
42229
- if (!canContinue()) return false;
42230
42291
  handle = await resolved.createClient({
42231
42292
  command: resolved.command,
42232
42293
  cwd: path35.resolve(cwd),
@@ -42234,12 +42295,13 @@ async function probeOneAgentTypeForCapabilities(params) {
42234
42295
  sessionMode: "agent",
42235
42296
  persistedAcpSessionId: null,
42236
42297
  agentConfig: null,
42298
+ signal: ac.signal,
42237
42299
  getActiveConfigOptions: () => null,
42238
42300
  onAcpSessionEstablished: (info) => {
42239
- tryReport(info.configOptions ?? null);
42301
+ if (Array.isArray(info.configOptions) && info.configOptions.length > 0) pendingCo = info.configOptions;
42240
42302
  },
42241
42303
  onAcpConfigOptionsUpdated: (co) => {
42242
- tryReport(co);
42304
+ if (Array.isArray(co) && co.length > 0) pendingCo = co;
42243
42305
  },
42244
42306
  onAgentSubprocessExit: () => {
42245
42307
  },
@@ -42252,13 +42314,21 @@ async function probeOneAgentTypeForCapabilities(params) {
42252
42314
  `[Bridge service] Agent capability probe (${agentType}): ${e instanceof Error ? e.message : String(e)}`
42253
42315
  );
42254
42316
  } finally {
42255
- clearTimeout(killTimer);
42317
+ clearTimeout(abortTimer);
42318
+ clearInterval(abortIfStale);
42256
42319
  try {
42257
42320
  await handle?.disconnectGracefully();
42258
42321
  } catch {
42259
42322
  }
42260
42323
  }
42261
- return sqliteChanged;
42324
+ if (!pendingCo || !canContinue()) return false;
42325
+ const configOptions = pendingCo;
42326
+ await yieldToEventLoop();
42327
+ const changed = await withCliSqlite(
42328
+ (db) => upsertCliAgentCapabilityCache(db, { workspaceId, agentType, configOptions })
42329
+ );
42330
+ if (bridgeReport && changed) reportAgentCapabilities?.({ agentType, configOptions });
42331
+ return changed;
42262
42332
  }
42263
42333
 
42264
42334
  // ../bridge/src/agents/capabilities/probe-agent-capabilities-for-types.ts
@@ -42277,9 +42347,10 @@ async function probeAgentCapabilitiesForDetectedTypes(params) {
42277
42347
  let changedCount = 0;
42278
42348
  for (let i = 0; i < agentTypes.length; i++) {
42279
42349
  if (!canContinue()) return changedCount;
42280
- if (i > 0) await yieldToEventLoop();
42350
+ await yieldToEventLoop();
42281
42351
  const agentType = agentTypes[i];
42282
42352
  if (!agentType.trim()) continue;
42353
+ if (shouldSkipCapabilityProbeThisProcess(agentType)) continue;
42283
42354
  if (!forceAllTypes) {
42284
42355
  try {
42285
42356
  if (process.env.BUILDAUTOMATON_FORCE_PROBE_ACP_CAPABILITIES !== "1" && await withCliSqlite((db) => hasNonEmptyAgentCapabilityCache(db, workspaceId, agentType))) {
@@ -42305,19 +42376,6 @@ async function probeAgentCapabilitiesForDetectedTypes(params) {
42305
42376
  // ../bridge/src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
42306
42377
  init_yield_to_event_loop();
42307
42378
  init_cli_database();
42308
-
42309
- // ../bridge/src/agents/capabilities/agent-capability-warmup-run.ts
42310
- init_cli_process_interrupt();
42311
- var warmupEpoch = 0;
42312
- function cancelInFlightAgentCapabilityWarmup() {
42313
- warmupEpoch += 1;
42314
- }
42315
- function beginAgentCapabilityWarmupRun() {
42316
- const epoch = warmupEpoch += 1;
42317
- return () => epoch === warmupEpoch && !isCliImmediateShutdownRequested();
42318
- }
42319
-
42320
- // ../bridge/src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
42321
42379
  async function warmupAgentCapabilitiesOnConnect(params) {
42322
42380
  const { workspaceId, log: log2, getWs } = params;
42323
42381
  const isCurrent = beginAgentCapabilityWarmupRun();
@@ -42329,8 +42387,7 @@ async function warmupAgentCapabilitiesOnConnect(params) {
42329
42387
  if (!socket || socket.readyState !== wrapper_default.OPEN) return;
42330
42388
  try {
42331
42389
  const rows = await withCliSqlite((db) => listCliAgentCapabilityCacheForWorkspace(db, workspaceId));
42332
- if (!isCurrent()) return;
42333
- if (rows.length === 0) return;
42390
+ if (!isCurrent() || rows.length === 0) return;
42334
42391
  sendWsMessage(socket, {
42335
42392
  type: "agent_capabilities_batch",
42336
42393
  items: rows.map((r) => ({ agentType: r.agentType, configOptions: r.configOptions }))
@@ -42344,46 +42401,30 @@ async function warmupAgentCapabilitiesOnConnect(params) {
42344
42401
  }
42345
42402
  await sendBatchFromCache();
42346
42403
  if (!isCurrent()) return;
42347
- let types = [];
42348
- try {
42349
- types = [...await detectLocalAgentTypes()];
42350
- } catch (e) {
42351
- log2(`[Bridge service] detectLocalAgentTypes failed: ${e instanceof Error ? e.message : String(e)}`);
42352
- }
42353
- if (!isCurrent()) return;
42354
- try {
42355
- const n = await probeAgentCapabilitiesForDetectedTypes({
42356
- agentTypes: types,
42357
- cwd,
42358
- workspaceId,
42359
- log: log2,
42360
- bridgeReport: false,
42361
- forceAllTypes: false,
42362
- shouldContinue: isCurrent
42363
- });
42364
- if (n > 0) await sendBatchFromCache();
42365
- } catch (e) {
42366
- if (e instanceof CliSqliteInterrupted) return;
42367
- log2(`[Bridge service] Agent capability probe (missing cache) failed: ${e instanceof Error ? e.message : String(e)}`);
42368
- }
42369
- if (!isCurrent()) return;
42370
42404
  void (async () => {
42371
42405
  try {
42372
42406
  await yieldToEventLoop();
42373
42407
  if (!isCurrent()) return;
42408
+ let types = [];
42409
+ try {
42410
+ types = [...await detectLocalAgentTypes()];
42411
+ } catch (e) {
42412
+ log2(`[Bridge service] detectLocalAgentTypes failed: ${e instanceof Error ? e.message : String(e)}`);
42413
+ }
42414
+ if (!isCurrent()) return;
42374
42415
  const n = await probeAgentCapabilitiesForDetectedTypes({
42375
42416
  agentTypes: types,
42376
42417
  cwd,
42377
42418
  workspaceId,
42378
42419
  log: log2,
42379
42420
  bridgeReport: false,
42380
- forceAllTypes: true,
42421
+ forceAllTypes: false,
42381
42422
  shouldContinue: isCurrent
42382
42423
  });
42383
42424
  if (n > 0) await sendBatchFromCache();
42384
42425
  } catch (e) {
42385
42426
  if (e instanceof CliSqliteInterrupted) return;
42386
- log2(`[Bridge service] Agent capability lazy refresh failed: ${e instanceof Error ? e.message : String(e)}`);
42427
+ log2(`[Bridge service] Agent capability probe failed: ${e instanceof Error ? e.message : String(e)}`);
42387
42428
  }
42388
42429
  })();
42389
42430
  }
@@ -43795,7 +43836,7 @@ function createBridgeHeartbeatController(params) {
43795
43836
  }
43796
43837
 
43797
43838
  // ../bridge/src/cli/cli-version.ts
43798
- var CLI_VERSION2 = "0.1.93".length > 0 ? "0.1.93" : "0.0.0-dev";
43839
+ var CLI_VERSION2 = "0.1.94".length > 0 ? "0.1.94" : "0.0.0-dev";
43799
43840
 
43800
43841
  // ../bridge/src/connection/identify/send-bridge-identify.ts
43801
43842
  function sendBridgeIdentify(ws, params) {
@@ -53694,7 +53735,6 @@ var handleBridgeIdentified = (msg, deps) => {
53694
53735
  });
53695
53736
  setImmediate(() => {
53696
53737
  void (async () => {
53697
- cancelInFlightAgentCapabilityWarmup();
53698
53738
  try {
53699
53739
  await deps.reportAutoDetectedAgents?.();
53700
53740
  } catch (e) {
@@ -53702,13 +53742,11 @@ var handleBridgeIdentified = (msg, deps) => {
53702
53742
  `[Bridge service] Auto-detect agents failed: ${e instanceof Error ? e.message : String(e)}`
53703
53743
  );
53704
53744
  }
53705
- try {
53706
- await deps.warmupAgentCapabilitiesOnConnect?.();
53707
- } catch (e) {
53745
+ void deps.warmupAgentCapabilitiesOnConnect?.()?.catch((e) => {
53708
53746
  deps.log(
53709
53747
  `[Bridge service] Agent capability warmup failed: ${e instanceof Error ? e.message : String(e)}`
53710
53748
  );
53711
- }
53749
+ });
53712
53750
  })();
53713
53751
  });
53714
53752
  };
@@ -55596,6 +55634,7 @@ function createMainBridgeCloseHandler(params, connect) {
55596
55634
  const { state, logFn, bridgeHeartbeat } = params;
55597
55635
  return (code, reason, closedWs) => {
55598
55636
  if (state.currentWs !== closedWs) return;
55637
+ cancelInFlightAgentCapabilityWarmup();
55599
55638
  bridgeHeartbeat?.stop();
55600
55639
  try {
55601
55640
  state.currentWs = null;
@@ -55723,20 +55762,8 @@ function createMainBridgeWebSocketLifecycle(params) {
55723
55762
  }
55724
55763
  }
55725
55764
  bridgeHeartbeat?.stop();
55726
- const prev = state.currentWs;
55727
- if (prev) {
55728
- prev.removeAllListeners();
55729
- prev.once("error", () => {
55730
- });
55731
- prev.once("close", () => {
55732
- prev.removeAllListeners();
55733
- });
55734
- try {
55735
- prev.close();
55736
- } catch {
55737
- }
55738
- state.currentWs = null;
55739
- }
55765
+ disposePreviousBridgeSocket(state.currentWs);
55766
+ state.currentWs = null;
55740
55767
  try {
55741
55768
  const url2 = plugin.transport.resolveControlPlaneUrl({
55742
55769
  workspaceId,
@@ -56298,7 +56325,7 @@ async function defaultBrowserId() {
56298
56325
  // ../../node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js
56299
56326
  import process6 from "node:process";
56300
56327
  import { promisify as promisify5 } from "node:util";
56301
- import { execFile as execFile4, execFileSync as execFileSync3 } from "node:child_process";
56328
+ import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
56302
56329
  var execFileAsync4 = promisify5(execFile4);
56303
56330
  async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
56304
56331
  if (process6.platform !== "darwin") {