@buildautomaton/cli 0.1.34 → 0.1.35

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
@@ -8000,8 +8000,8 @@ function getElementAtPath(obj, path41) {
8000
8000
  }
8001
8001
  function promiseAllObject(promisesObj) {
8002
8002
  const keys = Object.keys(promisesObj);
8003
- const promises3 = keys.map((key) => promisesObj[key]);
8004
- return Promise.all(promises3).then((results) => {
8003
+ const promises5 = keys.map((key) => promisesObj[key]);
8004
+ return Promise.all(promises5).then((results) => {
8005
8005
  const resolvedObj = {};
8006
8006
  for (let i = 0; i < keys.length; i++) {
8007
8007
  resolvedObj[keys[i]] = results[i];
@@ -22158,20 +22158,22 @@ function createWsBridge(options) {
22158
22158
  onOpen?.();
22159
22159
  });
22160
22160
  ws.on("message", (raw) => {
22161
- try {
22162
- let data;
22163
- if (typeof raw === "string") {
22164
- data = JSON.parse(raw);
22165
- } else if (Buffer.isBuffer(raw) || raw instanceof ArrayBuffer) {
22166
- const str = Buffer.isBuffer(raw) ? raw.toString("utf8") : Buffer.from(raw).toString("utf8");
22167
- data = JSON.parse(str);
22168
- } else {
22169
- data = raw;
22161
+ setImmediate(() => {
22162
+ try {
22163
+ let data;
22164
+ if (typeof raw === "string") {
22165
+ data = JSON.parse(raw);
22166
+ } else if (Buffer.isBuffer(raw) || raw instanceof ArrayBuffer) {
22167
+ const str = Buffer.isBuffer(raw) ? raw.toString("utf8") : Buffer.from(raw).toString("utf8");
22168
+ data = JSON.parse(str);
22169
+ } else {
22170
+ data = raw;
22171
+ }
22172
+ onMessage?.(data);
22173
+ } catch {
22174
+ onMessage?.(raw);
22170
22175
  }
22171
- onMessage?.(data);
22172
- } catch {
22173
- onMessage?.(raw);
22174
- }
22176
+ });
22175
22177
  });
22176
22178
  ws.on("close", (code, reason) => {
22177
22179
  disposeClientPing();
@@ -23962,7 +23964,7 @@ function installBridgeProcessResilience() {
23962
23964
  }
23963
23965
 
23964
23966
  // src/cli-version.ts
23965
- var CLI_VERSION = "0.1.34".length > 0 ? "0.1.34" : "0.0.0-dev";
23967
+ var CLI_VERSION = "0.1.35".length > 0 ? "0.1.35" : "0.0.0-dev";
23966
23968
 
23967
23969
  // src/connection/heartbeat/constants.ts
23968
23970
  var BRIDGE_APP_HEARTBEAT_INTERVAL_MS = 1e4;
@@ -32186,7 +32188,7 @@ async function ensureAcpClient(options) {
32186
32188
  if (!state.acpStartPromise) {
32187
32189
  let statOk = false;
32188
32190
  try {
32189
- const st = fs15.statSync(targetSessionParentPath);
32191
+ const st = await fs15.promises.stat(targetSessionParentPath);
32190
32192
  statOk = st.isDirectory();
32191
32193
  if (!statOk) {
32192
32194
  state.lastAcpStartError = `Agent cwd is not a directory: ${targetSessionParentPath}`;
@@ -35040,11 +35042,13 @@ function connectFirehose(options) {
35040
35042
  if (Buffer.isBuffer(raw) && tryConsumeBinaryProxyBody(raw, deps)) {
35041
35043
  return;
35042
35044
  }
35043
- try {
35044
- const text = Buffer.isBuffer(raw) ? raw.toString("utf8") : String(raw);
35045
- dispatchFirehoseJsonMessage(JSON.parse(text), deps);
35046
- } catch {
35047
- }
35045
+ setImmediate(() => {
35046
+ try {
35047
+ const text = Buffer.isBuffer(raw) ? raw.toString("utf8") : String(raw);
35048
+ dispatchFirehoseJsonMessage(JSON.parse(text), deps);
35049
+ } catch {
35050
+ }
35051
+ });
35048
35052
  });
35049
35053
  ws.on("close", (code, reason) => {
35050
35054
  disposeClientPing();
@@ -35560,7 +35564,9 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
35560
35564
  const tid = typeof pl.snapshotRevertTurnId === "string" && pl.snapshotRevertTurnId.trim() !== "" ? pl.snapshotRevertTurnId.trim() : next.turnId;
35561
35565
  const agentBase = deps.sessionWorktreeManager.getSessionWorktreeRootForSession(sid) ?? getBridgeRoot();
35562
35566
  const file2 = snapshotFilePath(agentBase, tid);
35563
- if (!fs31.existsSync(file2)) {
35567
+ try {
35568
+ await fs31.promises.access(file2, fs31.constants.F_OK);
35569
+ } catch {
35564
35570
  deps.log(
35565
35571
  `[Queue] requeued_with_revert: no pre-turn snapshot for ${tid.slice(0, 8)}\u2026; continuing without revert.`
35566
35572
  );
@@ -36557,7 +36563,9 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
36557
36563
  if (!s) return;
36558
36564
  const agentBase = sessionWorktreeManager.getSessionWorktreeRootForSession(sessionId) ?? getBridgeRoot();
36559
36565
  const file2 = snapshotFilePath(agentBase, turnId);
36560
- if (!fs35.existsSync(file2)) {
36566
+ try {
36567
+ await fs35.promises.access(file2, fs35.constants.F_OK);
36568
+ } catch {
36561
36569
  sendWsMessage(s, {
36562
36570
  type: "revert_turn_snapshot_result",
36563
36571
  id,
@@ -36676,9 +36684,7 @@ function handleBridgeMessage(data, deps) {
36676
36684
  if (!deps.getWs()) return;
36677
36685
  const msg = parseApiToBridgeMessage(normalizeInboundBridgeWebSocketJson(data), deps.log);
36678
36686
  if (!msg) return;
36679
- setImmediate(() => {
36680
- dispatchBridgeMessage(msg, deps);
36681
- });
36687
+ dispatchBridgeMessage(msg, deps);
36682
36688
  }
36683
36689
 
36684
36690
  // src/auth/refresh-bridge-tokens.ts
@@ -37323,25 +37329,27 @@ async function createBridgeConnection(options) {
37323
37329
  }
37324
37330
  function sendAgentCapabilitiesToBridge(info) {
37325
37331
  if (!Array.isArray(info.configOptions) || info.configOptions.length === 0) return;
37326
- let changed = false;
37327
- try {
37328
- changed = withCliSqliteSync(
37329
- (db) => upsertCliAgentCapabilityCache(db, {
37330
- workspaceId,
37331
- agentType: info.agentType,
37332
- configOptions: info.configOptions
37333
- })
37334
- );
37335
- } catch (e) {
37336
- if (e instanceof CliSqliteInterrupted) return;
37337
- }
37338
- if (!changed) return;
37339
- const socket = getWs();
37340
- if (!socket || socket.readyState !== wrapper_default.OPEN) return;
37341
- sendWsMessage(socket, {
37342
- type: "agent_capabilities",
37343
- agentType: info.agentType,
37344
- configOptions: info.configOptions
37332
+ setImmediate(() => {
37333
+ let changed = false;
37334
+ try {
37335
+ changed = withCliSqliteSync(
37336
+ (db) => upsertCliAgentCapabilityCache(db, {
37337
+ workspaceId,
37338
+ agentType: info.agentType,
37339
+ configOptions: info.configOptions
37340
+ })
37341
+ );
37342
+ } catch (e) {
37343
+ if (e instanceof CliSqliteInterrupted) return;
37344
+ }
37345
+ if (!changed) return;
37346
+ const socket = getWs();
37347
+ if (!socket || socket.readyState !== wrapper_default.OPEN) return;
37348
+ sendWsMessage(socket, {
37349
+ type: "agent_capabilities",
37350
+ agentType: info.agentType,
37351
+ configOptions: info.configOptions
37352
+ });
37345
37353
  });
37346
37354
  }
37347
37355
  const worktreesRootPath = options.worktreesRootPath ?? defaultWorktreesRootPath();