@buildautomaton/cli 0.1.91 → 0.1.93

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
@@ -24125,7 +24125,6 @@ function isCliSqliteLockError(e) {
24125
24125
  var CliSqliteInterrupted;
24126
24126
  var init_sqlite_errors = __esm({
24127
24127
  "../bridge/src/sqlite/sqlite-errors.ts"() {
24128
- "use strict";
24129
24128
  CliSqliteInterrupted = class extends Error {
24130
24129
  name = "CliSqliteInterrupted";
24131
24130
  constructor() {
@@ -24236,7 +24235,6 @@ function maybeLogCodeNavCacheWorkerError(message) {
24236
24235
  var diagnosticSink, lastDiagnosticKey;
24237
24236
  var init_code_nav_cache_log = __esm({
24238
24237
  "../bridge/src/sqlite/code-nav-cache/code-nav-cache-log.ts"() {
24239
- "use strict";
24240
24238
  init_log();
24241
24239
  init_sqlite_errors();
24242
24240
  init_sqlite_lock_path();
@@ -24924,7 +24922,6 @@ function withCodeNavCacheSqliteWorkLock(fn) {
24924
24922
  var chain, workLockDepth;
24925
24923
  var init_code_nav_cache_sqlite_work_lock = __esm({
24926
24924
  "../bridge/src/sqlite/code-nav-cache/code-nav-cache-sqlite-work-lock.ts"() {
24927
- "use strict";
24928
24925
  init_code_nav_cache_paths();
24929
24926
  chain = Promise.resolve();
24930
24927
  workLockDepth = 0;
@@ -30450,7 +30447,7 @@ var {
30450
30447
  } = import_index.default;
30451
30448
 
30452
30449
  // src/cli-version.ts
30453
- var CLI_VERSION = "0.1.91".length > 0 ? "0.1.91" : "0.0.0-dev";
30450
+ var CLI_VERSION = "0.1.93".length > 0 ? "0.1.93" : "0.0.0-dev";
30454
30451
 
30455
30452
  // src/cli/defaults.ts
30456
30453
  var DEFAULT_API_URL = process.env.BUILDAUTOMATON_API_URL ?? "https://api.buildautomaton.com";
@@ -30606,6 +30603,7 @@ function createWsBridge(options) {
30606
30603
  });
30607
30604
  ws.on("open", () => {
30608
30605
  disposeClientPing();
30606
+ if (isActiveSocket && !isActiveSocket(ws)) return;
30609
30607
  if (clientPingIntervalMs != null && clientPingIntervalMs > 0) {
30610
30608
  clearClientPing = attachWebSocketClientPing(ws, clientPingIntervalMs);
30611
30609
  }
@@ -30625,10 +30623,12 @@ function createWsBridge(options) {
30625
30623
  });
30626
30624
  ws.on("close", (code, reason) => {
30627
30625
  disposeClientPing();
30628
- onClose?.(code, reason.toString());
30626
+ if (isActiveSocket && !isActiveSocket(ws)) return;
30627
+ onClose?.(code, reason.toString(), ws);
30629
30628
  });
30630
30629
  ws.on("error", (err) => {
30631
30630
  disposeClientPing();
30631
+ if (isActiveSocket && !isActiveSocket(ws)) return;
30632
30632
  onError2?.(err);
30633
30633
  });
30634
30634
  return ws;
@@ -35946,6 +35946,24 @@ var RoleLengthWireSchema = external_exports.discriminatedUnion("type", [
35946
35946
  external_exports.object({ type: external_exports.literal("session_count"), max_sessions: MaxSessionsSchema })
35947
35947
  ]);
35948
35948
 
35949
+ // ../types/src/role-access-restrictions.ts
35950
+ var EMPTY_ROLE_ACCESS_RESTRICTIONS = {
35951
+ sessionsOwnAndExplicitOnly: false,
35952
+ bridgesOwnAndExplicitOnly: false,
35953
+ sessionsReadOnlyExceptOwn: false,
35954
+ codeChangesAgentModifiedOnly: false,
35955
+ codeChangesHidden: false
35956
+ };
35957
+ function roleAccessRestrictionsToWire(restrictions) {
35958
+ return {
35959
+ sessions_own_and_explicit_only: restrictions.sessionsOwnAndExplicitOnly,
35960
+ bridges_own_and_explicit_only: restrictions.bridgesOwnAndExplicitOnly,
35961
+ sessions_read_only_except_own: restrictions.sessionsReadOnlyExceptOwn,
35962
+ code_changes_agent_modified_only: restrictions.codeChangesAgentModifiedOnly,
35963
+ code_changes_hidden: restrictions.codeChangesHidden
35964
+ };
35965
+ }
35966
+
35949
35967
  // ../types/src/role-details.ts
35950
35968
  var InitialPeriodDaysSchema = external_exports.number().int().min(ROLE_PERIOD_MIN_DAYS).max(ROLE_PERIOD_MAX_DAYS);
35951
35969
  var AgentSubscriptionIdsSchema = external_exports.array(external_exports.string().min(1)).default([]);
@@ -35955,15 +35973,33 @@ var RoleDetailsSchema = external_exports.object({
35955
35973
  length: RoleLengthSchema.nullable(),
35956
35974
  agentSubscriptionIds: AgentSubscriptionIdsSchema,
35957
35975
  sessionsOwnAndExplicitOnly: BoolFalseSchema,
35958
- bridgesOwnAndExplicitOnly: BoolFalseSchema
35976
+ bridgesOwnAndExplicitOnly: BoolFalseSchema,
35977
+ sessionsReadOnlyExceptOwn: BoolFalseSchema,
35978
+ codeChangesAgentModifiedOnly: BoolFalseSchema,
35979
+ codeChangesHidden: BoolFalseSchema
35959
35980
  });
35960
35981
  var RoleDetailsWireSchema = external_exports.object({
35961
35982
  payment: RolePaymentModelWireSchema.nullable(),
35962
35983
  length: RoleLengthWireSchema.nullable(),
35963
35984
  agent_subscription_ids: AgentSubscriptionIdsSchema,
35964
35985
  sessions_own_and_explicit_only: BoolFalseSchema,
35965
- bridges_own_and_explicit_only: BoolFalseSchema
35966
- });
35986
+ bridges_own_and_explicit_only: BoolFalseSchema,
35987
+ sessions_read_only_except_own: BoolFalseSchema,
35988
+ code_changes_agent_modified_only: BoolFalseSchema,
35989
+ code_changes_hidden: BoolFalseSchema
35990
+ });
35991
+ var EMPTY_ROLE_DETAILS = {
35992
+ payment: null,
35993
+ length: null,
35994
+ agentSubscriptionIds: [],
35995
+ ...EMPTY_ROLE_ACCESS_RESTRICTIONS
35996
+ };
35997
+ var EMPTY_ROLE_DETAILS_WIRE = {
35998
+ payment: null,
35999
+ length: null,
36000
+ agent_subscription_ids: [],
36001
+ ...roleAccessRestrictionsToWire(EMPTY_ROLE_ACCESS_RESTRICTIONS)
36002
+ };
35967
36003
 
35968
36004
  // ../bridge/src/agents/acp/safe-fs-path.ts
35969
36005
  import * as path2 from "node:path";
@@ -38817,15 +38853,31 @@ function queueCursorCreatePlanRequest(method, id, msg, deps) {
38817
38853
  }
38818
38854
 
38819
38855
  // ../bridge/src/agents/providers/cursor/cursor-incoming-cursor-task.ts
38820
- function buildCursorTaskToolCallUpdate(params) {
38856
+ function asRecord2(v) {
38857
+ return v != null && typeof v === "object" && !Array.isArray(v) ? v : null;
38858
+ }
38859
+ function flattenCursorTaskParams(params) {
38860
+ const nested = asRecord2(params.task) ?? asRecord2(params.data) ?? asRecord2(params.payload) ?? asRecord2(params.cursorTask);
38861
+ return nested ? { ...nested, ...params } : params;
38862
+ }
38863
+ function stringField(params, ...keys) {
38864
+ for (const key of keys) {
38865
+ const v = params[key];
38866
+ if (typeof v === "string" && v.trim()) return v.trim();
38867
+ }
38868
+ return void 0;
38869
+ }
38870
+ function buildCursorTaskToolCallUpdate(rawParams) {
38871
+ const params = flattenCursorTaskParams(rawParams);
38821
38872
  const toolCallId = params.toolCallId ?? params.tool_call_id;
38822
38873
  if (typeof toolCallId !== "string" || !toolCallId.trim()) return null;
38823
- const description = typeof params.description === "string" ? params.description.trim() : "";
38874
+ const description = stringField(params, "description");
38824
38875
  const prompt = typeof params.prompt === "string" ? params.prompt : void 0;
38825
38876
  const subagentType = params.subagentType ?? params.subagent_type;
38826
38877
  const model = typeof params.model === "string" ? params.model : void 0;
38827
- const agentId = typeof params.agentId === "string" ? params.agentId : typeof params.agent_id === "string" ? params.agent_id : void 0;
38828
- const durationMs = typeof params.durationMs === "number" ? params.durationMs : typeof params.duration_ms === "number" ? params.duration_ms : void 0;
38878
+ const agentId = stringField(params, "agentId", "agent_id");
38879
+ const rawDuration = params.durationMs ?? params.duration_ms;
38880
+ const durationMs = typeof rawDuration === "number" && Number.isFinite(rawDuration) && rawDuration > 0 ? rawDuration : void 0;
38829
38881
  const isBackground = typeof params.isBackground === "boolean" ? params.isBackground : typeof params.is_background === "boolean" ? params.is_background : typeof params.runInBackground === "boolean" ? params.runInBackground : typeof params.run_in_background === "boolean" ? params.run_in_background : void 0;
38830
38882
  return {
38831
38883
  sessionUpdate: "tool_call_update",
@@ -38994,7 +39046,7 @@ function writeCreatePlanFile(params) {
38994
39046
  }
38995
39047
 
38996
39048
  // ../bridge/src/agents/providers/cursor/enrich-create-plan-rpc-result.ts
38997
- function asRecord2(v) {
39049
+ function asRecord3(v) {
38998
39050
  return v != null && typeof v === "object" && !Array.isArray(v) ? v : null;
38999
39051
  }
39000
39052
  function resolveAcceptedPlanMarkdown(outcome, pendingParams) {
@@ -39003,8 +39055,8 @@ function resolveAcceptedPlanMarkdown(outcome, pendingParams) {
39003
39055
  return "";
39004
39056
  }
39005
39057
  function enrichCreatePlanRpcResult(result, pendingParams, cloudSessionId) {
39006
- const root = asRecord2(result);
39007
- const outcome = asRecord2(root?.outcome);
39058
+ const root = asRecord3(result);
39059
+ const outcome = asRecord3(root?.outcome);
39008
39060
  if (!outcome) return result;
39009
39061
  const kind = typeof outcome.outcome === "string" ? outcome.outcome : "";
39010
39062
  if (kind !== "accepted") {
@@ -43743,7 +43795,7 @@ function createBridgeHeartbeatController(params) {
43743
43795
  }
43744
43796
 
43745
43797
  // ../bridge/src/cli/cli-version.ts
43746
- var CLI_VERSION2 = "0.1.91".length > 0 ? "0.1.91" : "0.0.0-dev";
43798
+ var CLI_VERSION2 = "0.1.93".length > 0 ? "0.1.93" : "0.0.0-dev";
43747
43799
 
43748
43800
  // ../bridge/src/connection/identify/send-bridge-identify.ts
43749
43801
  function sendBridgeIdentify(ws, params) {
@@ -55542,12 +55594,12 @@ function createMainBridgeAuthRefreshHandler(params, connect) {
55542
55594
  // ../bridge/src/connection/ws/main-bridge-ws-close-handler.ts
55543
55595
  function createMainBridgeCloseHandler(params, connect) {
55544
55596
  const { state, logFn, bridgeHeartbeat } = params;
55545
- return (code, reason) => {
55597
+ return (code, reason, closedWs) => {
55598
+ if (state.currentWs !== closedWs) return;
55546
55599
  bridgeHeartbeat?.stop();
55547
55600
  try {
55548
- const was = state.currentWs;
55549
55601
  state.currentWs = null;
55550
- if (was) was.removeAllListeners();
55602
+ closedWs.removeAllListeners();
55551
55603
  const willReconnect = !state.closedByUser;
55552
55604
  if (willReconnect) {
55553
55605
  const duplicateResult = evaluateDuplicateBridgeDisconnect(