@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/cli.js CHANGED
@@ -11857,8 +11857,8 @@ function getElementAtPath(obj, path43) {
11857
11857
  }
11858
11858
  function promiseAllObject(promisesObj) {
11859
11859
  const keys = Object.keys(promisesObj);
11860
- const promises3 = keys.map((key) => promisesObj[key]);
11861
- return Promise.all(promises3).then((results) => {
11860
+ const promises5 = keys.map((key) => promisesObj[key]);
11861
+ return Promise.all(promises5).then((results) => {
11862
11862
  const resolvedObj = {};
11863
11863
  for (let i = 0; i < keys.length; i++) {
11864
11864
  resolvedObj[keys[i]] = results[i];
@@ -25064,7 +25064,7 @@ var {
25064
25064
  } = import_index.default;
25065
25065
 
25066
25066
  // src/cli-version.ts
25067
- var CLI_VERSION = "0.1.34".length > 0 ? "0.1.34" : "0.0.0-dev";
25067
+ var CLI_VERSION = "0.1.35".length > 0 ? "0.1.35" : "0.0.0-dev";
25068
25068
 
25069
25069
  // src/cli/defaults.ts
25070
25070
  var DEFAULT_API_URL = process.env.BUILDAUTOMATON_API_URL ?? "https://api.buildautomaton.com";
@@ -25607,20 +25607,22 @@ function createWsBridge(options) {
25607
25607
  onOpen?.();
25608
25608
  });
25609
25609
  ws.on("message", (raw) => {
25610
- try {
25611
- let data;
25612
- if (typeof raw === "string") {
25613
- data = JSON.parse(raw);
25614
- } else if (Buffer.isBuffer(raw) || raw instanceof ArrayBuffer) {
25615
- const str = Buffer.isBuffer(raw) ? raw.toString("utf8") : Buffer.from(raw).toString("utf8");
25616
- data = JSON.parse(str);
25617
- } else {
25618
- data = raw;
25610
+ setImmediate(() => {
25611
+ try {
25612
+ let data;
25613
+ if (typeof raw === "string") {
25614
+ data = JSON.parse(raw);
25615
+ } else if (Buffer.isBuffer(raw) || raw instanceof ArrayBuffer) {
25616
+ const str = Buffer.isBuffer(raw) ? raw.toString("utf8") : Buffer.from(raw).toString("utf8");
25617
+ data = JSON.parse(str);
25618
+ } else {
25619
+ data = raw;
25620
+ }
25621
+ onMessage?.(data);
25622
+ } catch {
25623
+ onMessage?.(raw);
25619
25624
  }
25620
- onMessage?.(data);
25621
- } catch {
25622
- onMessage?.(raw);
25623
- }
25625
+ });
25624
25626
  });
25625
25627
  ws.on("close", (code, reason) => {
25626
25628
  disposeClientPing();
@@ -35146,7 +35148,7 @@ async function ensureAcpClient(options) {
35146
35148
  if (!state.acpStartPromise) {
35147
35149
  let statOk = false;
35148
35150
  try {
35149
- const st = fs16.statSync(targetSessionParentPath);
35151
+ const st = await fs16.promises.stat(targetSessionParentPath);
35150
35152
  statOk = st.isDirectory();
35151
35153
  if (!statOk) {
35152
35154
  state.lastAcpStartError = `Agent cwd is not a directory: ${targetSessionParentPath}`;
@@ -38168,11 +38170,13 @@ function connectFirehose(options) {
38168
38170
  if (Buffer.isBuffer(raw) && tryConsumeBinaryProxyBody(raw, deps)) {
38169
38171
  return;
38170
38172
  }
38171
- try {
38172
- const text = Buffer.isBuffer(raw) ? raw.toString("utf8") : String(raw);
38173
- dispatchFirehoseJsonMessage(JSON.parse(text), deps);
38174
- } catch {
38175
- }
38173
+ setImmediate(() => {
38174
+ try {
38175
+ const text = Buffer.isBuffer(raw) ? raw.toString("utf8") : String(raw);
38176
+ dispatchFirehoseJsonMessage(JSON.parse(text), deps);
38177
+ } catch {
38178
+ }
38179
+ });
38176
38180
  });
38177
38181
  ws.on("close", (code, reason) => {
38178
38182
  disposeClientPing();
@@ -38688,7 +38692,9 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
38688
38692
  const tid = typeof pl.snapshotRevertTurnId === "string" && pl.snapshotRevertTurnId.trim() !== "" ? pl.snapshotRevertTurnId.trim() : next.turnId;
38689
38693
  const agentBase = deps.sessionWorktreeManager.getSessionWorktreeRootForSession(sid) ?? getBridgeRoot();
38690
38694
  const file2 = snapshotFilePath(agentBase, tid);
38691
- if (!fs32.existsSync(file2)) {
38695
+ try {
38696
+ await fs32.promises.access(file2, fs32.constants.F_OK);
38697
+ } catch {
38692
38698
  deps.log(
38693
38699
  `[Queue] requeued_with_revert: no pre-turn snapshot for ${tid.slice(0, 8)}\u2026; continuing without revert.`
38694
38700
  );
@@ -39859,7 +39865,9 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
39859
39865
  if (!s) return;
39860
39866
  const agentBase = sessionWorktreeManager.getSessionWorktreeRootForSession(sessionId) ?? getBridgeRoot();
39861
39867
  const file2 = snapshotFilePath(agentBase, turnId);
39862
- if (!fs36.existsSync(file2)) {
39868
+ try {
39869
+ await fs36.promises.access(file2, fs36.constants.F_OK);
39870
+ } catch {
39863
39871
  sendWsMessage(s, {
39864
39872
  type: "revert_turn_snapshot_result",
39865
39873
  id,
@@ -39978,9 +39986,7 @@ function handleBridgeMessage(data, deps) {
39978
39986
  if (!deps.getWs()) return;
39979
39987
  const msg = parseApiToBridgeMessage(normalizeInboundBridgeWebSocketJson(data), deps.log);
39980
39988
  if (!msg) return;
39981
- setImmediate(() => {
39982
- dispatchBridgeMessage(msg, deps);
39983
- });
39989
+ dispatchBridgeMessage(msg, deps);
39984
39990
  }
39985
39991
 
39986
39992
  // src/auth/refresh-bridge-tokens.ts
@@ -40546,25 +40552,27 @@ async function createBridgeConnection(options) {
40546
40552
  }
40547
40553
  function sendAgentCapabilitiesToBridge(info) {
40548
40554
  if (!Array.isArray(info.configOptions) || info.configOptions.length === 0) return;
40549
- let changed = false;
40550
- try {
40551
- changed = withCliSqliteSync(
40552
- (db) => upsertCliAgentCapabilityCache(db, {
40553
- workspaceId,
40554
- agentType: info.agentType,
40555
- configOptions: info.configOptions
40556
- })
40557
- );
40558
- } catch (e) {
40559
- if (e instanceof CliSqliteInterrupted) return;
40560
- }
40561
- if (!changed) return;
40562
- const socket = getWs();
40563
- if (!socket || socket.readyState !== wrapper_default.OPEN) return;
40564
- sendWsMessage(socket, {
40565
- type: "agent_capabilities",
40566
- agentType: info.agentType,
40567
- configOptions: info.configOptions
40555
+ setImmediate(() => {
40556
+ let changed = false;
40557
+ try {
40558
+ changed = withCliSqliteSync(
40559
+ (db) => upsertCliAgentCapabilityCache(db, {
40560
+ workspaceId,
40561
+ agentType: info.agentType,
40562
+ configOptions: info.configOptions
40563
+ })
40564
+ );
40565
+ } catch (e) {
40566
+ if (e instanceof CliSqliteInterrupted) return;
40567
+ }
40568
+ if (!changed) return;
40569
+ const socket = getWs();
40570
+ if (!socket || socket.readyState !== wrapper_default.OPEN) return;
40571
+ sendWsMessage(socket, {
40572
+ type: "agent_capabilities",
40573
+ agentType: info.agentType,
40574
+ configOptions: info.configOptions
40575
+ });
40568
40576
  });
40569
40577
  }
40570
40578
  const worktreesRootPath = options.worktreesRootPath ?? defaultWorktreesRootPath();