@buildautomaton/cli 0.1.89 → 0.1.90

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
@@ -973,8 +973,8 @@ var require_command = __commonJS({
973
973
  "../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/command.js"(exports) {
974
974
  var EventEmitter2 = __require("node:events").EventEmitter;
975
975
  var childProcess2 = __require("node:child_process");
976
- var path91 = __require("node:path");
977
- var fs69 = __require("node:fs");
976
+ var path88 = __require("node:path");
977
+ var fs66 = __require("node:fs");
978
978
  var process9 = __require("node:process");
979
979
  var { Argument: Argument2, humanReadableArgName } = require_argument();
980
980
  var { CommanderError: CommanderError2 } = require_error();
@@ -1906,11 +1906,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1906
1906
  let launchWithNode = false;
1907
1907
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1908
1908
  function findFile(baseDir, baseName) {
1909
- const localBin = path91.resolve(baseDir, baseName);
1910
- if (fs69.existsSync(localBin)) return localBin;
1911
- if (sourceExt.includes(path91.extname(baseName))) return void 0;
1909
+ const localBin = path88.resolve(baseDir, baseName);
1910
+ if (fs66.existsSync(localBin)) return localBin;
1911
+ if (sourceExt.includes(path88.extname(baseName))) return void 0;
1912
1912
  const foundExt = sourceExt.find(
1913
- (ext) => fs69.existsSync(`${localBin}${ext}`)
1913
+ (ext) => fs66.existsSync(`${localBin}${ext}`)
1914
1914
  );
1915
1915
  if (foundExt) return `${localBin}${foundExt}`;
1916
1916
  return void 0;
@@ -1922,21 +1922,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
1922
1922
  if (this._scriptPath) {
1923
1923
  let resolvedScriptPath;
1924
1924
  try {
1925
- resolvedScriptPath = fs69.realpathSync(this._scriptPath);
1925
+ resolvedScriptPath = fs66.realpathSync(this._scriptPath);
1926
1926
  } catch (err) {
1927
1927
  resolvedScriptPath = this._scriptPath;
1928
1928
  }
1929
- executableDir = path91.resolve(
1930
- path91.dirname(resolvedScriptPath),
1929
+ executableDir = path88.resolve(
1930
+ path88.dirname(resolvedScriptPath),
1931
1931
  executableDir
1932
1932
  );
1933
1933
  }
1934
1934
  if (executableDir) {
1935
1935
  let localFile = findFile(executableDir, executableFile);
1936
1936
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1937
- const legacyName = path91.basename(
1937
+ const legacyName = path88.basename(
1938
1938
  this._scriptPath,
1939
- path91.extname(this._scriptPath)
1939
+ path88.extname(this._scriptPath)
1940
1940
  );
1941
1941
  if (legacyName !== this._name) {
1942
1942
  localFile = findFile(
@@ -1947,7 +1947,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1947
1947
  }
1948
1948
  executableFile = localFile || executableFile;
1949
1949
  }
1950
- launchWithNode = sourceExt.includes(path91.extname(executableFile));
1950
+ launchWithNode = sourceExt.includes(path88.extname(executableFile));
1951
1951
  let proc;
1952
1952
  if (process9.platform !== "win32") {
1953
1953
  if (launchWithNode) {
@@ -2787,7 +2787,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2787
2787
  * @return {Command}
2788
2788
  */
2789
2789
  nameFromFilename(filename) {
2790
- this._name = path91.basename(filename, path91.extname(filename));
2790
+ this._name = path88.basename(filename, path88.extname(filename));
2791
2791
  return this;
2792
2792
  }
2793
2793
  /**
@@ -2801,9 +2801,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2801
2801
  * @param {string} [path]
2802
2802
  * @return {(string|null|Command)}
2803
2803
  */
2804
- executableDir(path92) {
2805
- if (path92 === void 0) return this._executableDir;
2806
- this._executableDir = path92;
2804
+ executableDir(path89) {
2805
+ if (path89 === void 0) return this._executableDir;
2806
+ this._executableDir = path89;
2807
2807
  return this;
2808
2808
  }
2809
2809
  /**
@@ -6662,7 +6662,6 @@ function normalizeResolvedPath(resolved) {
6662
6662
  }
6663
6663
  var init_normalize_resolved_path = __esm({
6664
6664
  "../bridge/src/paths/normalize-resolved-path.ts"() {
6665
- "use strict";
6666
6665
  }
6667
6666
  });
6668
6667
 
@@ -6690,7 +6689,7 @@ var require_tree_kill = __commonJS({
6690
6689
  "../../node_modules/.pnpm/tree-kill@1.2.2/node_modules/tree-kill/index.js"(exports, module) {
6691
6690
  "use strict";
6692
6691
  var childProcess2 = __require("child_process");
6693
- var spawn12 = childProcess2.spawn;
6692
+ var spawn11 = childProcess2.spawn;
6694
6693
  var exec = childProcess2.exec;
6695
6694
  module.exports = function(pid, signal, callback) {
6696
6695
  if (typeof signal === "function" && callback === void 0) {
@@ -6715,7 +6714,7 @@ var require_tree_kill = __commonJS({
6715
6714
  break;
6716
6715
  case "darwin":
6717
6716
  buildProcessTree(pid, tree, pidsToProcess, function(parentPid) {
6718
- return spawn12("pgrep", ["-P", parentPid]);
6717
+ return spawn11("pgrep", ["-P", parentPid]);
6719
6718
  }, function() {
6720
6719
  killAll(tree, signal, callback);
6721
6720
  });
@@ -6727,7 +6726,7 @@ var require_tree_kill = __commonJS({
6727
6726
  // break;
6728
6727
  default:
6729
6728
  buildProcessTree(pid, tree, pidsToProcess, function(parentPid) {
6730
- return spawn12("ps", ["-o", "pid", "--no-headers", "--ppid", parentPid]);
6729
+ return spawn11("ps", ["-o", "pid", "--no-headers", "--ppid", parentPid]);
6731
6730
  }, function() {
6732
6731
  killAll(tree, signal, callback);
6733
6732
  });
@@ -6795,7 +6794,7 @@ var require_tree_kill = __commonJS({
6795
6794
  }
6796
6795
  });
6797
6796
 
6798
- // ../bridge/src/cli-log-level.ts
6797
+ // ../bridge/src/cli/cli-log-level.ts
6799
6798
  function setCliLogVerbosity(level) {
6800
6799
  verbosity = level;
6801
6800
  }
@@ -6807,13 +6806,12 @@ function isCliTrace() {
6807
6806
  }
6808
6807
  var verbosity;
6809
6808
  var init_cli_log_level = __esm({
6810
- "../bridge/src/cli-log-level.ts"() {
6811
- "use strict";
6809
+ "../bridge/src/cli/cli-log-level.ts"() {
6812
6810
  verbosity = "info";
6813
6811
  }
6814
6812
  });
6815
6813
 
6816
- // ../bridge/src/log.ts
6814
+ // ../bridge/src/cli/log.ts
6817
6815
  function timestampPrefix() {
6818
6816
  const time3 = (/* @__PURE__ */ new Date()).toISOString().slice(11, 19);
6819
6817
  return `[${time3}]`;
@@ -6835,8 +6833,7 @@ function logTrace(line) {
6835
6833
  console.log(`${timestampPrefix()} [trace] ${line}`);
6836
6834
  }
6837
6835
  var init_log = __esm({
6838
- "../bridge/src/log.ts"() {
6839
- "use strict";
6836
+ "../bridge/src/cli/log.ts"() {
6840
6837
  init_cli_log_level();
6841
6838
  }
6842
6839
  });
@@ -7088,10 +7085,10 @@ function mergeDefs(...defs) {
7088
7085
  function cloneDef(schema) {
7089
7086
  return mergeDefs(schema._zod.def);
7090
7087
  }
7091
- function getElementAtPath(obj, path91) {
7092
- if (!path91)
7088
+ function getElementAtPath(obj, path88) {
7089
+ if (!path88)
7093
7090
  return obj;
7094
- return path91.reduce((acc, key) => acc?.[key], obj);
7091
+ return path88.reduce((acc, key) => acc?.[key], obj);
7095
7092
  }
7096
7093
  function promiseAllObject(promisesObj) {
7097
7094
  const keys = Object.keys(promisesObj);
@@ -7419,11 +7416,11 @@ function explicitlyAborted(x, startIndex = 0) {
7419
7416
  }
7420
7417
  return false;
7421
7418
  }
7422
- function prefixIssues(path91, issues) {
7419
+ function prefixIssues(path88, issues) {
7423
7420
  return issues.map((iss) => {
7424
7421
  var _a4;
7425
7422
  (_a4 = iss).path ?? (_a4.path = []);
7426
- iss.path.unshift(path91);
7423
+ iss.path.unshift(path88);
7427
7424
  return iss;
7428
7425
  });
7429
7426
  }
@@ -7640,16 +7637,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
7640
7637
  }
7641
7638
  function formatError(error51, mapper = (issue2) => issue2.message) {
7642
7639
  const fieldErrors = { _errors: [] };
7643
- const processError = (error52, path91 = []) => {
7640
+ const processError = (error52, path88 = []) => {
7644
7641
  for (const issue2 of error52.issues) {
7645
7642
  if (issue2.code === "invalid_union" && issue2.errors.length) {
7646
- issue2.errors.map((issues) => processError({ issues }, [...path91, ...issue2.path]));
7643
+ issue2.errors.map((issues) => processError({ issues }, [...path88, ...issue2.path]));
7647
7644
  } else if (issue2.code === "invalid_key") {
7648
- processError({ issues: issue2.issues }, [...path91, ...issue2.path]);
7645
+ processError({ issues: issue2.issues }, [...path88, ...issue2.path]);
7649
7646
  } else if (issue2.code === "invalid_element") {
7650
- processError({ issues: issue2.issues }, [...path91, ...issue2.path]);
7647
+ processError({ issues: issue2.issues }, [...path88, ...issue2.path]);
7651
7648
  } else {
7652
- const fullpath = [...path91, ...issue2.path];
7649
+ const fullpath = [...path88, ...issue2.path];
7653
7650
  if (fullpath.length === 0) {
7654
7651
  fieldErrors._errors.push(mapper(issue2));
7655
7652
  } else {
@@ -7676,17 +7673,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
7676
7673
  }
7677
7674
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
7678
7675
  const result = { errors: [] };
7679
- const processError = (error52, path91 = []) => {
7676
+ const processError = (error52, path88 = []) => {
7680
7677
  var _a4, _b;
7681
7678
  for (const issue2 of error52.issues) {
7682
7679
  if (issue2.code === "invalid_union" && issue2.errors.length) {
7683
- issue2.errors.map((issues) => processError({ issues }, [...path91, ...issue2.path]));
7680
+ issue2.errors.map((issues) => processError({ issues }, [...path88, ...issue2.path]));
7684
7681
  } else if (issue2.code === "invalid_key") {
7685
- processError({ issues: issue2.issues }, [...path91, ...issue2.path]);
7682
+ processError({ issues: issue2.issues }, [...path88, ...issue2.path]);
7686
7683
  } else if (issue2.code === "invalid_element") {
7687
- processError({ issues: issue2.issues }, [...path91, ...issue2.path]);
7684
+ processError({ issues: issue2.issues }, [...path88, ...issue2.path]);
7688
7685
  } else {
7689
- const fullpath = [...path91, ...issue2.path];
7686
+ const fullpath = [...path88, ...issue2.path];
7690
7687
  if (fullpath.length === 0) {
7691
7688
  result.errors.push(mapper(issue2));
7692
7689
  continue;
@@ -7718,8 +7715,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
7718
7715
  }
7719
7716
  function toDotPath(_path) {
7720
7717
  const segs = [];
7721
- const path91 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
7722
- for (const seg of path91) {
7718
+ const path88 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
7719
+ for (const seg of path88) {
7723
7720
  if (typeof seg === "number")
7724
7721
  segs.push(`[${seg}]`);
7725
7722
  else if (typeof seg === "symbol")
@@ -21149,13 +21146,13 @@ function resolveRef(ref, ctx) {
21149
21146
  if (!ref.startsWith("#")) {
21150
21147
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
21151
21148
  }
21152
- const path91 = ref.slice(1).split("/").filter(Boolean);
21153
- if (path91.length === 0) {
21149
+ const path88 = ref.slice(1).split("/").filter(Boolean);
21150
+ if (path88.length === 0) {
21154
21151
  return ctx.rootSchema;
21155
21152
  }
21156
21153
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
21157
- if (path91[0] === defsKey) {
21158
- const key = path91[1];
21154
+ if (path88[0] === defsKey) {
21155
+ const key = path88[1];
21159
21156
  if (!key || !ctx.defs[key]) {
21160
21157
  throw new Error(`Reference not found: ${ref}`);
21161
21158
  }
@@ -24035,7 +24032,6 @@ function yieldToEventLoop() {
24035
24032
  }
24036
24033
  var init_yield_to_event_loop = __esm({
24037
24034
  "../bridge/src/runtime/yield-to-event-loop.ts"() {
24038
- "use strict";
24039
24035
  }
24040
24036
  });
24041
24037
 
@@ -24046,7 +24042,6 @@ function isSymbolIndexDeferredError(err) {
24046
24042
  var SymbolIndexDeferredError;
24047
24043
  var init_deferred_indexing = __esm({
24048
24044
  "../bridge/src/code-nav/symbol-index/deferred-indexing.ts"() {
24049
- "use strict";
24050
24045
  SymbolIndexDeferredError = class extends Error {
24051
24046
  constructor() {
24052
24047
  super("Symbol indexing deferred for file browser");
@@ -24113,7 +24108,6 @@ var init_idle_yield = __esm({
24113
24108
  // ../bridge/src/files/browser/in-flight.ts
24114
24109
  var init_in_flight = __esm({
24115
24110
  "../bridge/src/files/browser/in-flight.ts"() {
24116
- "use strict";
24117
24111
  init_activity_shared();
24118
24112
  init_activity_types();
24119
24113
  init_activity_tracker();
@@ -24242,7 +24236,6 @@ function maybeLogCodeNavCacheWorkerError(message) {
24242
24236
  var diagnosticSink, lastDiagnosticKey;
24243
24237
  var init_code_nav_cache_log = __esm({
24244
24238
  "../bridge/src/sqlite/code-nav-cache/code-nav-cache-log.ts"() {
24245
- "use strict";
24246
24239
  init_log();
24247
24240
  init_sqlite_errors();
24248
24241
  init_sqlite_lock_path();
@@ -24379,7 +24372,6 @@ function resetCodeNavCacheAvailabilityForTests() {
24379
24372
  var initState, initPromise, CodeNavCacheUnavailableError;
24380
24373
  var init_code_nav_cache_availability = __esm({
24381
24374
  "../bridge/src/sqlite/code-nav-cache/code-nav-cache-availability.ts"() {
24382
- "use strict";
24383
24375
  init_log();
24384
24376
  init_in_flight();
24385
24377
  init_sqlite_errors();
@@ -24756,7 +24748,7 @@ function readMigrationSql(filename, ...searchSubdirs) {
24756
24748
  join2(moduleDir, "..", sub, filename),
24757
24749
  join2(moduleDir, "..", "..", "dist", sub, filename)
24758
24750
  ]);
24759
- const resolved = candidates.find((path91) => existsSync(path91));
24751
+ const resolved = candidates.find((path88) => existsSync(path88));
24760
24752
  if (!resolved) {
24761
24753
  throw new Error(`Missing SQLite migration SQL: ${filename} (searched ${searchSubdirs.join(", ")})`);
24762
24754
  }
@@ -25073,7 +25065,6 @@ async function ensureCodeNavCacheSqliteInitialized() {
25073
25065
  var safeCloseCodeNavCacheSqliteDatabase, openCodeNavCacheSqliteConnection;
25074
25066
  var init_database = __esm({
25075
25067
  "../bridge/src/sqlite/code-nav-cache/database.ts"() {
25076
- "use strict";
25077
25068
  init_code_nav_cache_availability();
25078
25069
  init_instance();
25079
25070
  init_sqlite_errors();
@@ -25102,7 +25093,6 @@ function runCodeNavCacheWriteTransaction(db, fn) {
25102
25093
  }
25103
25094
  var init_code_nav_cache_sqlite_transaction = __esm({
25104
25095
  "../bridge/src/sqlite/code-nav-cache/code-nav-cache-sqlite-transaction.ts"() {
25105
- "use strict";
25106
25096
  }
25107
25097
  });
25108
25098
 
@@ -25157,7 +25147,6 @@ function getPromptQueuesDirectory() {
25157
25147
  }
25158
25148
  var init_paths2 = __esm({
25159
25149
  "../bridge/src/prompt-turn-queue/paths.ts"() {
25160
- "use strict";
25161
25150
  }
25162
25151
  });
25163
25152
 
@@ -25447,7 +25436,6 @@ function closeAllCliSqliteConnections() {
25447
25436
  var legacyImportDoneForPath, cliSqlite, safeCloseCliSqliteDatabase, openCliSqliteConnection, withCliSqliteSync, withCliSqlite, ensureCliSqliteInitialized;
25448
25437
  var init_cli_database = __esm({
25449
25438
  "../bridge/src/sqlite/cli-database.ts"() {
25450
- "use strict";
25451
25439
  init_cli_process_interrupt();
25452
25440
  init_cli_sqlite_paths();
25453
25441
  init_access();
@@ -25834,7 +25822,7 @@ var require_ignore = __commonJS({
25834
25822
  // path matching.
25835
25823
  // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
25836
25824
  // @returns {TestResult} true if a file is ignored
25837
- test(path91, checkUnignored, mode) {
25825
+ test(path88, checkUnignored, mode) {
25838
25826
  let ignored = false;
25839
25827
  let unignored = false;
25840
25828
  let matchedRule;
@@ -25843,7 +25831,7 @@ var require_ignore = __commonJS({
25843
25831
  if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
25844
25832
  return;
25845
25833
  }
25846
- const matched = rule[mode].test(path91);
25834
+ const matched = rule[mode].test(path88);
25847
25835
  if (!matched) {
25848
25836
  return;
25849
25837
  }
@@ -25864,17 +25852,17 @@ var require_ignore = __commonJS({
25864
25852
  var throwError = (message, Ctor) => {
25865
25853
  throw new Ctor(message);
25866
25854
  };
25867
- var checkPath = (path91, originalPath, doThrow) => {
25868
- if (!isString(path91)) {
25855
+ var checkPath = (path88, originalPath, doThrow) => {
25856
+ if (!isString(path88)) {
25869
25857
  return doThrow(
25870
25858
  `path must be a string, but got \`${originalPath}\``,
25871
25859
  TypeError
25872
25860
  );
25873
25861
  }
25874
- if (!path91) {
25862
+ if (!path88) {
25875
25863
  return doThrow(`path must not be empty`, TypeError);
25876
25864
  }
25877
- if (checkPath.isNotRelative(path91)) {
25865
+ if (checkPath.isNotRelative(path88)) {
25878
25866
  const r = "`path.relative()`d";
25879
25867
  return doThrow(
25880
25868
  `path should be a ${r} string, but got "${originalPath}"`,
@@ -25883,7 +25871,7 @@ var require_ignore = __commonJS({
25883
25871
  }
25884
25872
  return true;
25885
25873
  };
25886
- var isNotRelative = (path91) => REGEX_TEST_INVALID_PATH.test(path91);
25874
+ var isNotRelative = (path88) => REGEX_TEST_INVALID_PATH.test(path88);
25887
25875
  checkPath.isNotRelative = isNotRelative;
25888
25876
  checkPath.convert = (p) => p;
25889
25877
  var Ignore = class {
@@ -25913,19 +25901,19 @@ var require_ignore = __commonJS({
25913
25901
  }
25914
25902
  // @returns {TestResult}
25915
25903
  _test(originalPath, cache2, checkUnignored, slices) {
25916
- const path91 = originalPath && checkPath.convert(originalPath);
25904
+ const path88 = originalPath && checkPath.convert(originalPath);
25917
25905
  checkPath(
25918
- path91,
25906
+ path88,
25919
25907
  originalPath,
25920
25908
  this._strictPathCheck ? throwError : RETURN_FALSE
25921
25909
  );
25922
- return this._t(path91, cache2, checkUnignored, slices);
25910
+ return this._t(path88, cache2, checkUnignored, slices);
25923
25911
  }
25924
- checkIgnore(path91) {
25925
- if (!REGEX_TEST_TRAILING_SLASH.test(path91)) {
25926
- return this.test(path91);
25912
+ checkIgnore(path88) {
25913
+ if (!REGEX_TEST_TRAILING_SLASH.test(path88)) {
25914
+ return this.test(path88);
25927
25915
  }
25928
- const slices = path91.split(SLASH).filter(Boolean);
25916
+ const slices = path88.split(SLASH).filter(Boolean);
25929
25917
  slices.pop();
25930
25918
  if (slices.length) {
25931
25919
  const parent = this._t(
@@ -25938,18 +25926,18 @@ var require_ignore = __commonJS({
25938
25926
  return parent;
25939
25927
  }
25940
25928
  }
25941
- return this._rules.test(path91, false, MODE_CHECK_IGNORE);
25929
+ return this._rules.test(path88, false, MODE_CHECK_IGNORE);
25942
25930
  }
25943
- _t(path91, cache2, checkUnignored, slices) {
25944
- if (path91 in cache2) {
25945
- return cache2[path91];
25931
+ _t(path88, cache2, checkUnignored, slices) {
25932
+ if (path88 in cache2) {
25933
+ return cache2[path88];
25946
25934
  }
25947
25935
  if (!slices) {
25948
- slices = path91.split(SLASH).filter(Boolean);
25936
+ slices = path88.split(SLASH).filter(Boolean);
25949
25937
  }
25950
25938
  slices.pop();
25951
25939
  if (!slices.length) {
25952
- return cache2[path91] = this._rules.test(path91, checkUnignored, MODE_IGNORE);
25940
+ return cache2[path88] = this._rules.test(path88, checkUnignored, MODE_IGNORE);
25953
25941
  }
25954
25942
  const parent = this._t(
25955
25943
  slices.join(SLASH) + SLASH,
@@ -25957,29 +25945,29 @@ var require_ignore = __commonJS({
25957
25945
  checkUnignored,
25958
25946
  slices
25959
25947
  );
25960
- return cache2[path91] = parent.ignored ? parent : this._rules.test(path91, checkUnignored, MODE_IGNORE);
25948
+ return cache2[path88] = parent.ignored ? parent : this._rules.test(path88, checkUnignored, MODE_IGNORE);
25961
25949
  }
25962
- ignores(path91) {
25963
- return this._test(path91, this._ignoreCache, false).ignored;
25950
+ ignores(path88) {
25951
+ return this._test(path88, this._ignoreCache, false).ignored;
25964
25952
  }
25965
25953
  createFilter() {
25966
- return (path91) => !this.ignores(path91);
25954
+ return (path88) => !this.ignores(path88);
25967
25955
  }
25968
25956
  filter(paths) {
25969
25957
  return makeArray(paths).filter(this.createFilter());
25970
25958
  }
25971
25959
  // @returns {TestResult}
25972
- test(path91) {
25973
- return this._test(path91, this._testCache, true);
25960
+ test(path88) {
25961
+ return this._test(path88, this._testCache, true);
25974
25962
  }
25975
25963
  };
25976
25964
  var factory = (options) => new Ignore(options);
25977
- var isPathValid = (path91) => checkPath(path91 && checkPath.convert(path91), path91, RETURN_FALSE);
25965
+ var isPathValid = (path88) => checkPath(path88 && checkPath.convert(path88), path88, RETURN_FALSE);
25978
25966
  var setupWindows = () => {
25979
25967
  const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
25980
25968
  checkPath.convert = makePosix;
25981
25969
  const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
25982
- checkPath.isNotRelative = (path91) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path91) || isNotRelative(path91);
25970
+ checkPath.isNotRelative = (path88) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path88) || isNotRelative(path88);
25983
25971
  };
25984
25972
  if (
25985
25973
  // Detect `process` so that it can run in browsers.
@@ -29524,12 +29512,11 @@ __export(lifecycle_exports, {
29524
29512
  });
29525
29513
  var init_lifecycle2 = __esm({
29526
29514
  "../bridge/src/code-nav/symbol-index/worker/lifecycle.ts"() {
29527
- "use strict";
29528
29515
  init_lifecycle();
29529
29516
  }
29530
29517
  });
29531
29518
 
29532
- // ../bridge/src/runtime/cli-process-interrupt.ts
29519
+ // ../bridge/src/cli/teardown/cli-process-interrupt.ts
29533
29520
  function requestCliImmediateShutdown() {
29534
29521
  if (cliImmediateShutdownRequested) return;
29535
29522
  cliImmediateShutdownRequested = true;
@@ -29576,7 +29563,7 @@ async function delayMsUnlessShutdownRequested(ms) {
29576
29563
  }
29577
29564
  var cliImmediateShutdownRequested, symbolIndexShutdownPromise;
29578
29565
  var init_cli_process_interrupt = __esm({
29579
- "../bridge/src/runtime/cli-process-interrupt.ts"() {
29566
+ "../bridge/src/cli/teardown/cli-process-interrupt.ts"() {
29580
29567
  "use strict";
29581
29568
  cliImmediateShutdownRequested = false;
29582
29569
  symbolIndexShutdownPromise = null;
@@ -30357,10 +30344,10 @@ var require_src2 = __commonJS({
30357
30344
  var fs_1 = __require("fs");
30358
30345
  var debug_1 = __importDefault(require_src());
30359
30346
  var log2 = debug_1.default("@kwsites/file-exists");
30360
- function check2(path91, isFile, isDirectory) {
30361
- log2(`checking %s`, path91);
30347
+ function check2(path88, isFile, isDirectory) {
30348
+ log2(`checking %s`, path88);
30362
30349
  try {
30363
- const stat3 = fs_1.statSync(path91);
30350
+ const stat3 = fs_1.statSync(path88);
30364
30351
  if (stat3.isFile() && isFile) {
30365
30352
  log2(`[OK] path represents a file`);
30366
30353
  return true;
@@ -30380,8 +30367,8 @@ var require_src2 = __commonJS({
30380
30367
  throw e;
30381
30368
  }
30382
30369
  }
30383
- function exists2(path91, type = exports.READABLE) {
30384
- return check2(path91, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
30370
+ function exists2(path88, type = exports.READABLE) {
30371
+ return check2(path88, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
30385
30372
  }
30386
30373
  exports.exists = exists2;
30387
30374
  exports.FILE = 1;
@@ -30462,14 +30449,14 @@ var {
30462
30449
  } = import_index.default;
30463
30450
 
30464
30451
  // src/cli-version.ts
30465
- var CLI_VERSION = "0.1.89".length > 0 ? "0.1.89" : "0.0.0-dev";
30452
+ var CLI_VERSION = "0.1.90".length > 0 ? "0.1.90" : "0.0.0-dev";
30466
30453
 
30467
30454
  // src/cli/defaults.ts
30468
30455
  var DEFAULT_API_URL = process.env.BUILDAUTOMATON_API_URL ?? "https://api.buildautomaton.com";
30469
30456
  var DEFAULT_FIREHOSE_URL = "https://buildautomaton-firehose.fly.dev";
30470
30457
 
30471
30458
  // src/cli/run-cli-action.ts
30472
- import * as path90 from "node:path";
30459
+ import * as path87 from "node:path";
30473
30460
 
30474
30461
  // ../../node_modules/.pnpm/ws@8.19.0/node_modules/ws/wrapper.mjs
30475
30462
  var import_stream = __toESM(require_stream(), 1);
@@ -30479,7 +30466,7 @@ var import_websocket = __toESM(require_websocket(), 1);
30479
30466
  var import_websocket_server = __toESM(require_websocket_server(), 1);
30480
30467
  var wrapper_default = import_websocket.default;
30481
30468
 
30482
- // ../bridge/src/connection/cli-ws-client.ts
30469
+ // ../bridge/src/connection/ws/cli-ws-client.ts
30483
30470
  import https from "node:https";
30484
30471
  var CLI_WEBSOCKET_CLIENT_PING_MS = 25e3;
30485
30472
  function attachWebSocketClientPing(ws, intervalMs) {
@@ -30539,11 +30526,11 @@ function safeSendWebSocketBinary(ws, data) {
30539
30526
  }
30540
30527
  }
30541
30528
 
30542
- // ../bridge/src/connection/create-ws-bridge-options.ts
30529
+ // ../bridge/src/connection/ws/create-ws-bridge-options.ts
30543
30530
  var BRIDGE_AUTH_ERROR_HEADER = "x-bridge-auth-error";
30544
30531
  var BRIDGE_AUTH_ERROR_TOKEN_INVALID = "token_invalid";
30545
30532
 
30546
- // ../bridge/src/connection/dispatch-ws-inbound-message.ts
30533
+ // ../bridge/src/connection/ws/dispatch-ws-inbound-message.ts
30547
30534
  function dispatchWsInboundMessage(raw, ws, onMessage, isActiveSocket) {
30548
30535
  if (isActiveSocket && !isActiveSocket(ws)) return;
30549
30536
  try {
@@ -30562,7 +30549,7 @@ function dispatchWsInboundMessage(raw, ws, onMessage, isActiveSocket) {
30562
30549
  }
30563
30550
  }
30564
30551
 
30565
- // ../bridge/src/connection/parse-compact-heartbeat-ack.ts
30552
+ // ../bridge/src/connection/heartbeat/parse-compact-heartbeat-ack.ts
30566
30553
  function tryParseCompactHeartbeatAck(raw) {
30567
30554
  let str = null;
30568
30555
  if (typeof raw === "string") {
@@ -30588,7 +30575,7 @@ function tryParseCompactHeartbeatAck(raw) {
30588
30575
  }
30589
30576
  }
30590
30577
 
30591
- // ../bridge/src/connection/create-ws-bridge.ts
30578
+ // ../bridge/src/connection/ws/create-ws-bridge.ts
30592
30579
  function createWsBridge(options) {
30593
30580
  const {
30594
30581
  url: url2,
@@ -30745,7 +30732,7 @@ function formatSpawnError(err, command) {
30745
30732
  }
30746
30733
 
30747
30734
  // ../bridge/src/agents/acp/clients/kill-process-tree.ts
30748
- var import_tree_kill = __toESM(require_tree_kill(), 1);
30735
+ var import_tree_kill = __toESM(require_tree_kill());
30749
30736
  import { promisify } from "node:util";
30750
30737
  var treeKillAsync = promisify(import_tree_kill.default);
30751
30738
  var ACP_PROCESS_TREE_KILL_GRACE_MS = 2500;
@@ -30814,7 +30801,7 @@ function forceAcpSubprocessDisconnect(child) {
30814
30801
  killChildProcessTree(child, "SIGKILL");
30815
30802
  }
30816
30803
 
30817
- // ../bridge/src/lib/local-agent-auth.ts
30804
+ // ../bridge/src/agents/local-agent-auth.ts
30818
30805
  var LOCAL_AGENT_AUTH_ERROR_HINTS = {
30819
30806
  "kiro-acp": [/not logged in/i, /kiro-cli\s+login/i, /log in with kiro-cli/i],
30820
30807
  "cursor-cli": [/cursor_login/i, /authenticate.*cursor/i, /not logged in.*cursor/i, /run:\s*agent\s+login/i],
@@ -31450,8 +31437,8 @@ function getErrorMap() {
31450
31437
 
31451
31438
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
31452
31439
  var makeIssue = (params) => {
31453
- const { data, path: path91, errorMaps, issueData } = params;
31454
- const fullPath = [...path91, ...issueData.path || []];
31440
+ const { data, path: path88, errorMaps, issueData } = params;
31441
+ const fullPath = [...path88, ...issueData.path || []];
31455
31442
  const fullIssue = {
31456
31443
  ...issueData,
31457
31444
  path: fullPath
@@ -31567,11 +31554,11 @@ var errorUtil;
31567
31554
 
31568
31555
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
31569
31556
  var ParseInputLazyPath = class {
31570
- constructor(parent, value, path91, key) {
31557
+ constructor(parent, value, path88, key) {
31571
31558
  this._cachedPath = [];
31572
31559
  this.parent = parent;
31573
31560
  this.data = value;
31574
- this._path = path91;
31561
+ this._path = path88;
31575
31562
  this._key = key;
31576
31563
  }
31577
31564
  get path() {
@@ -36952,188 +36939,14 @@ async function proxyToLocalStreaming(request, callbacks) {
36952
36939
  });
36953
36940
  }
36954
36941
 
36955
- // ../bridge/src/skills/preview.ts
36956
- import { spawn as spawn2 } from "node:child_process";
36957
- var PREVIEW_API_BASE_PATH = "/__preview";
36958
- var PREVIEW_SECRET_HEADER = "X-Preview-Secret";
36959
- var DEFAULT_PORT = 3e3;
36960
- var DEFAULT_COMMAND = "npm run preview";
36961
- var PREVIEW_COMMAND_ENV = "BUILDAUTOMATON_PREVIEW_COMMAND";
36962
- var PREVIEW_PORT_ENV = "BUILDAUTOMATON_PREVIEW_PORT";
36963
- var previewProcess = null;
36964
- var previewPort = DEFAULT_PORT;
36965
- var previewSecret = "";
36966
- function getPreviewCommand() {
36967
- return process.env[PREVIEW_COMMAND_ENV]?.trim() || DEFAULT_COMMAND;
36968
- }
36969
- function randomSecret() {
36970
- const bytes = new Uint8Array(32);
36971
- if (typeof crypto !== "undefined" && crypto.getRandomValues) {
36972
- crypto.getRandomValues(bytes);
36973
- }
36974
- return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
36975
- }
36976
- async function requestPreviewApi(port, secret, method, path91, body) {
36977
- const url2 = `http://127.0.0.1:${port}${path91}`;
36978
- const headers = {
36979
- [PREVIEW_SECRET_HEADER]: secret,
36980
- "Content-Type": "application/json"
36981
- };
36982
- const res = await fetch(url2, {
36983
- method,
36984
- headers,
36985
- body: body !== void 0 ? JSON.stringify(body) : void 0
36986
- });
36987
- const data = await res.json().catch(() => ({}));
36988
- if (!res.ok) {
36989
- throw new Error(data?.error ?? `Preview API ${method} ${path91}: ${res.status}`);
36990
- }
36991
- return data;
36992
- }
36993
- var OPERATIONS = [
36994
- {
36995
- id: "start",
36996
- description: "Start the preview server process (runs the configured command with PORT and PREVIEW_SECRET).",
36997
- params: [
36998
- { name: "port", description: "Port for the preview server", type: "number", required: false }
36999
- ]
37000
- },
37001
- {
37002
- id: "stop",
37003
- description: "Stop the preview server via POST /__preview/stop (graceful shutdown).",
37004
- params: []
37005
- },
37006
- {
37007
- id: "status",
37008
- description: "Return status from GET /__preview/status (running, url).",
37009
- params: []
37010
- }
37011
- ];
37012
- var previewSkill = {
37013
- id: "preview",
37014
- name: "Preview",
37015
- description: "Start and manage a local preview server that implements the BuildAutomaton Preview Server API. Configure the command with BUILDAUTOMATON_PREVIEW_COMMAND (default: npm run preview). The server receives PORT and PREVIEW_SECRET and must expose /__preview/status and /__preview/stop.",
37016
- operations: OPERATIONS,
37017
- async execute(operationId, params) {
37018
- const command = getPreviewCommand();
37019
- switch (operationId) {
37020
- case "start": {
37021
- if (previewProcess) {
37022
- return {
37023
- ok: false,
37024
- message: "Preview server already running",
37025
- url: `http://localhost:${previewPort}`
37026
- };
37027
- }
37028
- const port = params.port ?? (Number(process.env[PREVIEW_PORT_ENV]) || DEFAULT_PORT);
37029
- previewPort = port;
37030
- previewSecret = randomSecret();
37031
- const isWindows = process.platform === "win32";
37032
- const parts = command.split(/\s+/);
37033
- const exe = parts[0];
37034
- const args = parts.slice(1);
37035
- previewProcess = spawn2(isWindows && exe === "npm" ? "npm.cmd" : exe, args, {
37036
- cwd: getBridgeRoot(),
37037
- stdio: ["ignore", "pipe", "pipe"],
37038
- env: {
37039
- ...process.env,
37040
- PORT: String(port),
37041
- PREVIEW_SECRET: previewSecret
37042
- }
37043
- });
37044
- previewProcess.stdout?.on("data", (d) => process.stdout.write(d));
37045
- previewProcess.stderr?.on("data", (d) => process.stderr.write(d));
37046
- previewProcess.on("exit", (code) => {
37047
- previewProcess = null;
37048
- if (code !== null && code !== 0) {
37049
- process.stderr.write(`Preview server exited with code ${code}
37050
- `);
37051
- }
37052
- });
37053
- return {
37054
- ok: true,
37055
- message: `Preview server starting (${command}, port=${port})`,
37056
- url: `http://localhost:${port}`,
37057
- port
37058
- };
37059
- }
37060
- case "stop": {
37061
- if (!previewProcess) {
37062
- return { ok: true, message: "No preview server was running" };
37063
- }
37064
- if (!previewSecret) {
37065
- previewProcess.kill("SIGTERM");
37066
- previewProcess = null;
37067
- return { ok: true, message: "Preview process stopped (no secret)" };
37068
- }
37069
- try {
37070
- await requestPreviewApi(
37071
- previewPort,
37072
- previewSecret,
37073
- "POST",
37074
- `${PREVIEW_API_BASE_PATH}/stop`
37075
- );
37076
- } catch (e) {
37077
- previewProcess.kill("SIGTERM");
37078
- }
37079
- previewProcess = null;
37080
- previewSecret = "";
37081
- return { ok: true, message: "Preview server stop requested" };
37082
- }
37083
- case "status": {
37084
- if (!previewProcess || !previewSecret) {
37085
- return {
37086
- running: previewProcess != null,
37087
- url: previewProcess ? `http://localhost:${previewPort}` : void 0,
37088
- message: previewProcess ? `Process running at http://localhost:${previewPort}` : "No preview server running"
37089
- };
37090
- }
37091
- try {
37092
- const status = await requestPreviewApi(
37093
- previewPort,
37094
- previewSecret,
37095
- "GET",
37096
- `${PREVIEW_API_BASE_PATH}/status`
37097
- );
37098
- return {
37099
- running: status.status === "running",
37100
- status: status.status,
37101
- url: status.url ?? `http://localhost:${previewPort}`,
37102
- message: status.message ?? (status.status === "running" ? "Preview server running" : "Stopping")
37103
- };
37104
- } catch {
37105
- return {
37106
- running: previewProcess != null,
37107
- url: `http://localhost:${previewPort}`,
37108
- message: "Process running but status endpoint unreachable (server may not implement Preview Server API yet)"
37109
- };
37110
- }
37111
- }
37112
- default:
37113
- throw new Error(`Unknown operation: ${operationId}`);
37114
- }
37115
- }
37116
- };
37117
-
37118
- // ../bridge/src/skills/index.ts
37119
- var skills = [previewSkill];
37120
- function getSkill(id) {
37121
- return skills.find((s) => s.id === id);
37122
- }
37123
- async function callSkill(skillId, operationId, params) {
37124
- const skill = getSkill(skillId);
37125
- if (!skill) throw new Error(`Skill not found: ${skillId}`);
37126
- return skill.execute(operationId, params);
37127
- }
37128
-
37129
36942
  // ../bridge/src/index.ts
37130
36943
  init_log();
37131
36944
  init_cli_log_level();
37132
36945
 
37133
- // ../bridge/src/run-bridge.ts
36946
+ // ../bridge/src/cli/run-bridge.ts
37134
36947
  init_log();
37135
36948
 
37136
- // ../bridge/src/process-bridge-resilience.ts
36949
+ // ../bridge/src/cli/teardown/process-bridge-resilience.ts
37137
36950
  init_log();
37138
36951
  var installed = false;
37139
36952
  function installBridgeProcessResilience() {
@@ -37147,7 +36960,7 @@ function installBridgeProcessResilience() {
37147
36960
  });
37148
36961
  }
37149
36962
 
37150
- // ../bridge/src/run-bridge-connected.ts
36963
+ // ../bridge/src/cli/run-bridge-connected.ts
37151
36964
  init_log();
37152
36965
 
37153
36966
  // ../bridge/src/agents/acp/clients/bridge-agent-path.ts
@@ -38294,7 +38107,7 @@ function startFileIndexWatcher(cwd = getBridgeRoot()) {
38294
38107
  };
38295
38108
  }
38296
38109
 
38297
- // ../bridge/src/connection/create-bridge-connection.ts
38110
+ // ../bridge/src/connection/runtime/create-bridge-connection.ts
38298
38111
  init_cli_process_interrupt();
38299
38112
 
38300
38113
  // ../bridge/src/preview-environments/manager/constants.ts
@@ -38302,13 +38115,13 @@ var BRIDGE_CLOSE_PREVIEW_ENVIRONMENT_GRACE_MS = 0;
38302
38115
  var BRIDGE_SHUTDOWN_GRACE_MS = 8e3;
38303
38116
  var PREVIEW_ENVIRONMENT_STOP_GRACE_MS = 2500;
38304
38117
 
38305
- // ../bridge/src/connection/close-bridge-connection.ts
38118
+ // ../bridge/src/connection/runtime/close-bridge-connection.ts
38306
38119
  init_log();
38307
38120
  init_cli_process_interrupt();
38308
38121
  init_cli_database();
38309
38122
  init_database();
38310
38123
 
38311
- // ../bridge/src/connection/ws-close-diagnostics.ts
38124
+ // ../bridge/src/connection/ws/ws-close-diagnostics.ts
38312
38125
  function describeWebSocketCloseCode(code) {
38313
38126
  const known = {
38314
38127
  1e3: "normal closure",
@@ -38408,7 +38221,7 @@ function beginDeferredDisconnectForReconnect(options) {
38408
38221
  }
38409
38222
  }
38410
38223
 
38411
- // ../bridge/src/connection/close-bridge-connection.ts
38224
+ // ../bridge/src/connection/runtime/close-bridge-connection.ts
38412
38225
  async function closeBridgeConnection(state, acpManager, previewEnvironmentManager, log2) {
38413
38226
  requestCliImmediateShutdown();
38414
38227
  const say = log2 ?? logImmediate;
@@ -38544,7 +38357,7 @@ function resolveSessionParentPathForAgentProcess(resolvedSessionParentPath) {
38544
38357
  return getBridgeRoot();
38545
38358
  }
38546
38359
 
38547
- // ../bridge/src/error-message.ts
38360
+ // ../bridge/src/cli/error-message.ts
38548
38361
  function errorMessage(err) {
38549
38362
  if (err instanceof Error) return err.message;
38550
38363
  if (err != null && typeof err === "object" && "message" in err)
@@ -39348,10 +39161,10 @@ async function initCursorAcpWire(options) {
39348
39161
  }
39349
39162
 
39350
39163
  // ../bridge/src/agents/acp/clients/cursor/spawn-cursor-acp-process.ts
39351
- import { spawn as spawn3 } from "node:child_process";
39164
+ import { spawn as spawn2 } from "node:child_process";
39352
39165
  function spawnCursorAcpProcess(options) {
39353
39166
  const isWindows = process.platform === "win32";
39354
- const child = spawn3(options.command[0], options.command.slice(1), {
39167
+ const child = spawn2(options.command[0], options.command.slice(1), {
39355
39168
  cwd: options.cwd,
39356
39169
  stdio: ["pipe", "pipe", "pipe"],
39357
39170
  env: bridgeInstalledAgentAuthProcessEnv(process.env),
@@ -39543,7 +39356,7 @@ function resolveAgentCommand(preferredAgentType) {
39543
39356
  import { existsSync as existsSync4, statSync } from "node:fs";
39544
39357
 
39545
39358
  // ../bridge/src/git/git-exec.ts
39546
- import { execFile as execFile2, execFileSync as execFileSync2, spawn as spawn4 } from "node:child_process";
39359
+ import { execFile as execFile2, execFileSync as execFileSync2, spawn as spawn3 } from "node:child_process";
39547
39360
  import { promisify as promisify3 } from "node:util";
39548
39361
 
39549
39362
  // ../bridge/src/git/git-runtime.ts
@@ -40837,8 +40650,8 @@ function augmentPromptResultAuthFields(agentType, errorText) {
40837
40650
  init_yield_to_event_loop();
40838
40651
 
40839
40652
  // ../bridge/src/git/changes/parse/normalize-git-diff-path.ts
40840
- function normalizeGitDiffPath(path91) {
40841
- return path91.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
40653
+ function normalizeGitDiffPath(path88) {
40654
+ return path88.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
40842
40655
  }
40843
40656
 
40844
40657
  // ../bridge/src/git/changes/parse/parse-name-status-entries.ts
@@ -41549,15 +41362,12 @@ async function createAcpManager(options) {
41549
41362
  };
41550
41363
  }
41551
41364
 
41552
- // ../bridge/src/lib/e2ee/cli-e2ee-key.ts
41553
- import { createHash, randomBytes } from "node:crypto";
41554
-
41555
- // ../e2ee/src/constants.ts
41365
+ // ../bridge/src/e2ee/constants.ts
41556
41366
  var E2EE_ALG = "A1";
41557
41367
  var E2EE_KEY_BYTES = 32;
41558
41368
  var E2EE_NONCE_BYTES = 12;
41559
41369
 
41560
- // ../e2ee/src/types.ts
41370
+ // ../bridge/src/e2ee/types.ts
41561
41371
  function isE2eeEnvelope(value) {
41562
41372
  if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
41563
41373
  const o = value;
@@ -41569,7 +41379,7 @@ function isE2eeKeyRecord(value) {
41569
41379
  return typeof o.id === "string" && o.id.length > 0 && typeof o.name === "string" && o.name.length > 0 && o.a === E2EE_ALG && typeof o.k === "string" && o.k.length > 0 && typeof o.createdAt === "string" && o.createdAt.length > 0;
41570
41380
  }
41571
41381
 
41572
- // ../e2ee/src/encoding.ts
41382
+ // ../bridge/src/e2ee/encoding.ts
41573
41383
  function base64UrlEncode(bytes) {
41574
41384
  let binary = "";
41575
41385
  for (let i = 0; i < bytes.length; i += 1) binary += String.fromCharCode(bytes[i]);
@@ -41585,7 +41395,7 @@ function base64UrlDecode(value) {
41585
41395
  return out;
41586
41396
  }
41587
41397
 
41588
- // ../e2ee/src/pem.ts
41398
+ // ../bridge/src/e2ee/pem.ts
41589
41399
  var E2EE_PEM_LABEL = "BUILD AUTOMATON E2EE KEY";
41590
41400
  function pemHeaderValue(headers, name) {
41591
41401
  return headers[name.toLowerCase()];
@@ -41658,7 +41468,8 @@ function serializeE2eeKeyRecord(key) {
41658
41468
  ].join("\n");
41659
41469
  }
41660
41470
 
41661
- // ../bridge/src/lib/e2ee/cli-e2ee-key.ts
41471
+ // ../bridge/src/e2ee/cli-e2ee-key.ts
41472
+ import { createHash, randomBytes } from "node:crypto";
41662
41473
  function createE2eeKeyRecord(name) {
41663
41474
  const raw = randomBytes(E2EE_KEY_BYTES);
41664
41475
  const digest = createHash("sha256").update(raw).digest();
@@ -41671,7 +41482,7 @@ function createE2eeKeyRecord(name) {
41671
41482
  };
41672
41483
  }
41673
41484
 
41674
- // ../bridge/src/lib/e2ee/cli-e2ee-runtime.ts
41485
+ // ../bridge/src/e2ee/cli-e2ee-runtime.ts
41675
41486
  import { createCipheriv, createDecipheriv, randomBytes as randomBytes2 } from "node:crypto";
41676
41487
  function nonceFromCounter(prefix, counter) {
41677
41488
  const nonce = Buffer.alloc(E2EE_NONCE_BYTES);
@@ -41750,7 +41561,7 @@ function createCliE2eeRuntime(key) {
41750
41561
  };
41751
41562
  }
41752
41563
 
41753
- // ../bridge/src/lib/e2ee/decrypt-stored-e2ee-content.ts
41564
+ // ../bridge/src/e2ee/decrypt-stored-e2ee-content.ts
41754
41565
  function parseJsonObject(raw) {
41755
41566
  try {
41756
41567
  const parsed = JSON.parse(raw);
@@ -41816,6 +41627,126 @@ function decryptCliE2eeMessageField(payload, field, e2ee) {
41816
41627
  return typeof value === "string" ? value : JSON.stringify(value);
41817
41628
  }
41818
41629
 
41630
+ // ../bridge/src/e2ee/certificates.ts
41631
+ import * as fs20 from "node:fs/promises";
41632
+ import * as path34 from "node:path";
41633
+ var E2E_CERTIFICATE_ALGORITHM = "A1";
41634
+ var CERTIFICATE_FILE_EXTENSIONS = /* @__PURE__ */ new Set([".pem", ".key", ".crt"]);
41635
+ function certificateFromKey({
41636
+ raw,
41637
+ name,
41638
+ createdAt
41639
+ }) {
41640
+ try {
41641
+ const key = parseE2eeKeyRecord(raw, name);
41642
+ return {
41643
+ ...key,
41644
+ name: key.name || name,
41645
+ algorithm: E2E_CERTIFICATE_ALGORITHM,
41646
+ pemBundle: serializeE2eeKeyRecord({ ...key, createdAt: key.createdAt || createdAt })
41647
+ };
41648
+ } catch {
41649
+ return void 0;
41650
+ }
41651
+ }
41652
+ function baseNameForCertificate(fileName) {
41653
+ return path34.basename(fileName, path34.extname(fileName)) || "BuildAutomaton E2EE certificate";
41654
+ }
41655
+ async function readCertificateFiles(directory) {
41656
+ let entries;
41657
+ try {
41658
+ entries = await fs20.readdir(directory, { withFileTypes: true });
41659
+ } catch (err) {
41660
+ const nodeErr = err;
41661
+ if (nodeErr.code === "ENOENT") return [];
41662
+ throw err;
41663
+ }
41664
+ const certificates = [];
41665
+ for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
41666
+ if (!entry.isFile() || !CERTIFICATE_FILE_EXTENSIONS.has(path34.extname(entry.name).toLowerCase())) continue;
41667
+ const filePath = path34.join(directory, entry.name);
41668
+ const raw = await fs20.readFile(filePath, "utf8").catch(() => void 0);
41669
+ if (!raw) continue;
41670
+ const stat3 = await fs20.stat(filePath).catch(() => void 0);
41671
+ const certificate = certificateFromKey({
41672
+ raw,
41673
+ name: baseNameForCertificate(entry.name),
41674
+ createdAt: stat3?.mtime?.toISOString() ?? (/* @__PURE__ */ new Date()).toISOString()
41675
+ });
41676
+ if (certificate) {
41677
+ certificates.push(certificate);
41678
+ }
41679
+ }
41680
+ return certificates;
41681
+ }
41682
+ function createCertificate(directory) {
41683
+ const baseName = path34.basename(directory) || "BuildAutomaton E2EE certificate";
41684
+ const key = createE2eeKeyRecord(baseName);
41685
+ return {
41686
+ ...key,
41687
+ algorithm: E2E_CERTIFICATE_ALGORITHM,
41688
+ pemBundle: serializeE2eeKeyRecord(key)
41689
+ };
41690
+ }
41691
+ async function loadOrCreateE2eCertificates(directory) {
41692
+ const resolved = path34.resolve(directory);
41693
+ await fs20.mkdir(resolved, { recursive: true, mode: 448 });
41694
+ const existing = await readCertificateFiles(resolved);
41695
+ if (existing.length > 0) {
41696
+ return {
41697
+ directory: resolved,
41698
+ certificates: existing,
41699
+ activeCertificate: existing[0],
41700
+ generated: false
41701
+ };
41702
+ }
41703
+ const certificate = createCertificate(resolved);
41704
+ const fileName = `buildautomaton-e2ee-key-${certificate.id.slice(0, 12)}.pem`;
41705
+ await fs20.writeFile(path34.join(resolved, fileName), certificate.pemBundle, {
41706
+ mode: 384
41707
+ });
41708
+ return {
41709
+ directory: resolved,
41710
+ certificates: [certificate],
41711
+ activeCertificate: certificate,
41712
+ generated: true
41713
+ };
41714
+ }
41715
+
41716
+ // ../bridge/src/e2ee/key-command.ts
41717
+ import * as readline2 from "node:readline";
41718
+ function installE2eCertificateKeyCommand({
41719
+ log: log2,
41720
+ onOpenCertificate,
41721
+ onInterrupt
41722
+ }) {
41723
+ if (!process.stdin.isTTY || typeof process.stdin.setRawMode !== "function") {
41724
+ log2("[E2EE] Press c to import the E2EE key in a browser when running in an interactive terminal.");
41725
+ return () => {
41726
+ };
41727
+ }
41728
+ readline2.emitKeypressEvents(process.stdin);
41729
+ process.stdin.setRawMode(true);
41730
+ process.stdin.resume();
41731
+ const onKeypress = (str, key) => {
41732
+ if (key?.ctrl && key.name === "c") {
41733
+ onInterrupt();
41734
+ return;
41735
+ }
41736
+ if (!key?.ctrl && !key?.meta && (key?.name === "c" || str === "c")) {
41737
+ onOpenCertificate();
41738
+ }
41739
+ };
41740
+ process.stdin.on("keypress", onKeypress);
41741
+ log2("[E2EE] Press c to import the active E2EE key into the browser.");
41742
+ return () => {
41743
+ process.stdin.off("keypress", onKeypress);
41744
+ if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
41745
+ process.stdin.setRawMode(false);
41746
+ }
41747
+ };
41748
+ }
41749
+
41819
41750
  // ../bridge/src/mcp/create-empty-mcp-tool-registry.ts
41820
41751
  function createEmptyMcpToolRegistry() {
41821
41752
  return {
@@ -41964,7 +41895,7 @@ async function createBridgeAccessState(options) {
41964
41895
  }
41965
41896
 
41966
41897
  // ../bridge/src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
41967
- import * as path35 from "node:path";
41898
+ import * as path36 from "node:path";
41968
41899
 
41969
41900
  // ../bridge/src/agents/detect-local-agent-types.ts
41970
41901
  init_yield_to_event_loop();
@@ -42069,7 +42000,7 @@ function listCliAgentCapabilityCacheForWorkspace(db, workspaceId) {
42069
42000
  init_cli_database();
42070
42001
 
42071
42002
  // ../bridge/src/agents/capabilities/probe-one-agent-type-for-capabilities.ts
42072
- import * as path34 from "node:path";
42003
+ import * as path35 from "node:path";
42073
42004
  init_cli_database();
42074
42005
  init_cli_process_interrupt();
42075
42006
  async function probeOneAgentTypeForCapabilities(params) {
@@ -42109,7 +42040,7 @@ async function probeOneAgentTypeForCapabilities(params) {
42109
42040
  if (!canContinue()) return false;
42110
42041
  handle = await resolved.createClient({
42111
42042
  command: resolved.command,
42112
- cwd: path34.resolve(cwd),
42043
+ cwd: path35.resolve(cwd),
42113
42044
  backendAgentType: agentType,
42114
42045
  sessionMode: "agent",
42115
42046
  persistedAcpSessionId: null,
@@ -42202,7 +42133,7 @@ async function warmupAgentCapabilitiesOnConnect(params) {
42202
42133
  const { workspaceId, log: log2, getWs } = params;
42203
42134
  const isCurrent = beginAgentCapabilityWarmupRun();
42204
42135
  if (!isCurrent()) return;
42205
- const cwd = path35.resolve(getBridgeRoot());
42136
+ const cwd = path36.resolve(getBridgeRoot());
42206
42137
  async function sendBatchFromCache() {
42207
42138
  if (!isCurrent()) return;
42208
42139
  const socket = getWs();
@@ -42268,7 +42199,7 @@ async function warmupAgentCapabilitiesOnConnect(params) {
42268
42199
  })();
42269
42200
  }
42270
42201
 
42271
- // ../bridge/src/connection/create-bridge-agent-capabilities-reporter.ts
42202
+ // ../bridge/src/connection/reports/create-bridge-agent-capabilities-reporter.ts
42272
42203
  init_cli_database();
42273
42204
  function createAgentCapabilitiesReporter(params) {
42274
42205
  const { workspaceId, getWs } = params;
@@ -42304,7 +42235,7 @@ function createWarmupAgentCapabilitiesOnConnect(params) {
42304
42235
  };
42305
42236
  }
42306
42237
 
42307
- // ../bridge/src/connection/create-bridge-access-and-acp.ts
42238
+ // ../bridge/src/connection/setup/create-bridge-access-and-acp.ts
42308
42239
  async function createBridgeAccessAndAcp(options) {
42309
42240
  const { plugin, workspaceId, getWs, log: log2 } = options;
42310
42241
  const e2ee = options.e2eCertificate ? createCliE2eeRuntime(options.e2eCertificate) : void 0;
@@ -42327,8 +42258,8 @@ async function createBridgeAccessAndAcp(options) {
42327
42258
  return { e2ee, acpManager, bridgeAccessPromise };
42328
42259
  }
42329
42260
 
42330
- // ../bridge/src/connection/create-bridge-preview-stack.ts
42331
- import * as path38 from "node:path";
42261
+ // ../bridge/src/connection/setup/create-bridge-preview-stack.ts
42262
+ import * as path39 from "node:path";
42332
42263
 
42333
42264
  // ../bridge/src/preview-environments/manager/firehose-messages.ts
42334
42265
  function buildFirehoseSnapshotMessage(params) {
@@ -42646,7 +42577,7 @@ function attachChildErrorHandler(d) {
42646
42577
  }
42647
42578
 
42648
42579
  // ../bridge/src/preview-environments/process/wire/handle-exit.ts
42649
- import fs20 from "node:fs";
42580
+ import fs21 from "node:fs";
42650
42581
  function logStopLine(d, code, signal) {
42651
42582
  const { title } = d;
42652
42583
  if (signal) {
@@ -42685,7 +42616,7 @@ function attachChildExitHandler(d) {
42685
42616
  const cleanupDir = d.mergedCleanupDir;
42686
42617
  const mergedPath = d.mergedLogPath;
42687
42618
  if (mergedPath && !stale) {
42688
- fs20.readFile(mergedPath, (err, buf) => {
42619
+ fs21.readFile(mergedPath, (err, buf) => {
42689
42620
  if (!err && buf.length > d.mergedReadPos.value) {
42690
42621
  const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
42691
42622
  if (chunk.length > 0) {
@@ -42731,7 +42662,7 @@ function wireChildOutputPipes(d) {
42731
42662
  }
42732
42663
 
42733
42664
  // ../bridge/src/preview-environments/process/wire/poll-merged-log.ts
42734
- import fs21 from "node:fs";
42665
+ import fs22 from "node:fs";
42735
42666
  function startMergedLogPoll(d) {
42736
42667
  if (!d.mergedLogPath || !d.mergedCleanupDir) return;
42737
42668
  const { environmentId } = d;
@@ -42741,7 +42672,7 @@ function startMergedLogPoll(d) {
42741
42672
  d.setPollInterval(void 0);
42742
42673
  return;
42743
42674
  }
42744
- fs21.readFile(d.mergedLogPath, (err, buf) => {
42675
+ fs22.readFile(d.mergedLogPath, (err, buf) => {
42745
42676
  if (err || (d.getSpawnGeneration() ?? 0) !== d.scheduledGen) return;
42746
42677
  if (buf.length <= d.mergedReadPos.value) return;
42747
42678
  const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
@@ -42956,7 +42887,7 @@ function previewEnvironmentSpawnOptions(lifecycle = DEFAULT_PREVIEW_ENVIRONMENT_
42956
42887
  }
42957
42888
 
42958
42889
  // ../bridge/src/preview-environments/manager/shell-spawn/utils.ts
42959
- import fs22 from "node:fs";
42890
+ import fs23 from "node:fs";
42960
42891
  function mergePreviewEnvironmentSpawnOptions(opts, lifecycle = DEFAULT_PREVIEW_ENVIRONMENT_PROCESS_LIFECYCLE) {
42961
42892
  return { ...opts, ...previewEnvironmentSpawnOptions(lifecycle) };
42962
42893
  }
@@ -42965,7 +42896,7 @@ function isSpawnEbadf(e) {
42965
42896
  }
42966
42897
  function rmDirQuiet(dir) {
42967
42898
  try {
42968
- fs22.rmSync(dir, { recursive: true, force: true });
42899
+ fs23.rmSync(dir, { recursive: true, force: true });
42969
42900
  } catch {
42970
42901
  }
42971
42902
  }
@@ -42973,7 +42904,7 @@ var cachedDevNullReadFd;
42973
42904
  function devNullReadFd() {
42974
42905
  if (cachedDevNullReadFd === void 0) {
42975
42906
  const devPath = process.platform === "win32" ? "nul" : "/dev/null";
42976
- cachedDevNullReadFd = fs22.openSync(devPath, "r");
42907
+ cachedDevNullReadFd = fs23.openSync(devPath, "r");
42977
42908
  }
42978
42909
  return cachedDevNullReadFd;
42979
42910
  }
@@ -42982,7 +42913,7 @@ function pipedStdoutStderrFor(attemptStdio) {
42982
42913
  }
42983
42914
 
42984
42915
  // ../bridge/src/preview-environments/manager/shell-spawn/try-spawn-piped-via-sh.ts
42985
- import { spawn as spawn5 } from "node:child_process";
42916
+ import { spawn as spawn4 } from "node:child_process";
42986
42917
  function trySpawnPipedViaSh(command, env, cwd, signal, lifecycle) {
42987
42918
  const attempts = [
42988
42919
  { stdio: [devNullReadFd(), "pipe", "pipe"], endStdin: false },
@@ -43006,9 +42937,9 @@ function trySpawnPipedViaSh(command, env, cwd, signal, lifecycle) {
43006
42937
  if (process.platform === "win32") {
43007
42938
  opts.windowsHide = true;
43008
42939
  const com = process.env.ComSpec || "cmd.exe";
43009
- proc = spawn5(com, ["/d", "/s", "/c", command], opts);
42940
+ proc = spawn4(com, ["/d", "/s", "/c", command], opts);
43010
42941
  } else {
43011
- proc = spawn5("/bin/sh", ["-c", command], opts);
42942
+ proc = spawn4("/bin/sh", ["-c", command], opts);
43012
42943
  }
43013
42944
  if (attempt.endStdin) {
43014
42945
  proc.stdin?.end();
@@ -43028,7 +42959,7 @@ function trySpawnPipedViaSh(command, env, cwd, signal, lifecycle) {
43028
42959
  }
43029
42960
 
43030
42961
  // ../bridge/src/preview-environments/manager/shell-spawn/try-spawn-shell-true-piped.ts
43031
- import { spawn as spawn6 } from "node:child_process";
42962
+ import { spawn as spawn5 } from "node:child_process";
43032
42963
  function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal, lifecycle) {
43033
42964
  try {
43034
42965
  const opts = mergePreviewEnvironmentSpawnOptions(
@@ -43044,7 +42975,7 @@ function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal, lifecycle)
43044
42975
  if (process.platform === "win32") {
43045
42976
  opts.windowsHide = true;
43046
42977
  }
43047
- return spawn6(command, opts);
42978
+ return spawn5(command, opts);
43048
42979
  } catch (e) {
43049
42980
  if (isSpawnEbadf(e)) return null;
43050
42981
  throw e;
@@ -43052,16 +42983,16 @@ function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal, lifecycle)
43052
42983
  }
43053
42984
 
43054
42985
  // ../bridge/src/preview-environments/manager/shell-spawn/try-spawn-merged-log-file.ts
43055
- import { spawn as spawn7 } from "node:child_process";
43056
- import fs23 from "node:fs";
42986
+ import { spawn as spawn6 } from "node:child_process";
42987
+ import fs24 from "node:fs";
43057
42988
  import { tmpdir } from "node:os";
43058
- import path36 from "node:path";
42989
+ import path37 from "node:path";
43059
42990
  function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
43060
- const tmpRoot = fs23.mkdtempSync(path36.join(tmpdir(), "ba-devsrv-log-"));
43061
- const logPath = path36.join(tmpRoot, "combined.log");
42991
+ const tmpRoot = fs24.mkdtempSync(path37.join(tmpdir(), "ba-devsrv-log-"));
42992
+ const logPath = path37.join(tmpRoot, "combined.log");
43062
42993
  let logFd;
43063
42994
  try {
43064
- logFd = fs23.openSync(logPath, "a");
42995
+ logFd = fs24.openSync(logPath, "a");
43065
42996
  } catch {
43066
42997
  rmDirQuiet(tmpRoot);
43067
42998
  return null;
@@ -43070,7 +43001,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
43070
43001
  try {
43071
43002
  let proc;
43072
43003
  if (process.platform === "win32") {
43073
- proc = spawn7(
43004
+ proc = spawn6(
43074
43005
  process.env.ComSpec || "cmd.exe",
43075
43006
  ["/d", "/s", "/c", command],
43076
43007
  mergePreviewEnvironmentSpawnOptions(
@@ -43079,13 +43010,13 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
43079
43010
  )
43080
43011
  );
43081
43012
  } else {
43082
- proc = spawn7(
43013
+ proc = spawn6(
43083
43014
  "/bin/sh",
43084
43015
  ["-c", command],
43085
43016
  mergePreviewEnvironmentSpawnOptions({ env, cwd, stdio, ...signal ? { signal } : {} }, lifecycle)
43086
43017
  );
43087
43018
  }
43088
- fs23.closeSync(logFd);
43019
+ fs24.closeSync(logFd);
43089
43020
  return {
43090
43021
  proc,
43091
43022
  pipedStdoutStderr: true,
@@ -43094,7 +43025,7 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
43094
43025
  };
43095
43026
  } catch (e) {
43096
43027
  try {
43097
- fs23.closeSync(logFd);
43028
+ fs24.closeSync(logFd);
43098
43029
  } catch {
43099
43030
  }
43100
43031
  rmDirQuiet(tmpRoot);
@@ -43104,30 +43035,30 @@ function trySpawnMergedLogFile(command, env, cwd, signal, lifecycle) {
43104
43035
  }
43105
43036
 
43106
43037
  // ../bridge/src/preview-environments/manager/shell-spawn/try-spawn-shell-script-log-redirect.ts
43107
- import { spawn as spawn8 } from "node:child_process";
43108
- import fs24 from "node:fs";
43038
+ import { spawn as spawn7 } from "node:child_process";
43039
+ import fs25 from "node:fs";
43109
43040
  import { tmpdir as tmpdir2 } from "node:os";
43110
- import path37 from "node:path";
43041
+ import path38 from "node:path";
43111
43042
  function shSingleQuote(s) {
43112
43043
  return `'${s.replace(/'/g, `'\\''`)}'`;
43113
43044
  }
43114
43045
  function trySpawnShellScriptLogRedirectUnix(command, env, cwd, signal, lifecycle) {
43115
- const tmpRoot = fs24.mkdtempSync(path37.join(tmpdir2(), "ba-devsrv-sh-"));
43116
- const logPath = path37.join(tmpRoot, "combined.log");
43117
- const innerPath = path37.join(tmpRoot, "_cmd.sh");
43118
- const runnerPath = path37.join(tmpRoot, "_run.sh");
43046
+ const tmpRoot = fs25.mkdtempSync(path38.join(tmpdir2(), "ba-devsrv-sh-"));
43047
+ const logPath = path38.join(tmpRoot, "combined.log");
43048
+ const innerPath = path38.join(tmpRoot, "_cmd.sh");
43049
+ const runnerPath = path38.join(tmpRoot, "_run.sh");
43119
43050
  try {
43120
- fs24.writeFileSync(innerPath, `#!/bin/sh
43051
+ fs25.writeFileSync(innerPath, `#!/bin/sh
43121
43052
  ${command}
43122
43053
  `);
43123
- fs24.writeFileSync(
43054
+ fs25.writeFileSync(
43124
43055
  runnerPath,
43125
43056
  `#!/bin/sh
43126
43057
  cd ${shSingleQuote(cwd)}
43127
43058
  /bin/sh ${shSingleQuote(innerPath)} >>${shSingleQuote(logPath)} 2>&1
43128
43059
  `
43129
43060
  );
43130
- const proc = spawn8(
43061
+ const proc = spawn7(
43131
43062
  "/bin/sh",
43132
43063
  [runnerPath],
43133
43064
  mergePreviewEnvironmentSpawnOptions(
@@ -43148,20 +43079,20 @@ cd ${shSingleQuote(cwd)}
43148
43079
  }
43149
43080
  }
43150
43081
  function trySpawnShellScriptLogRedirectWin(command, env, cwd, signal, lifecycle) {
43151
- const tmpRoot = fs24.mkdtempSync(path37.join(tmpdir2(), "ba-devsrv-sh-"));
43152
- const logPath = path37.join(tmpRoot, "combined.log");
43153
- const runnerPath = path37.join(tmpRoot, "_run.bat");
43082
+ const tmpRoot = fs25.mkdtempSync(path38.join(tmpdir2(), "ba-devsrv-sh-"));
43083
+ const logPath = path38.join(tmpRoot, "combined.log");
43084
+ const runnerPath = path38.join(tmpRoot, "_run.bat");
43154
43085
  const q = (p) => `"${p.replace(/"/g, '""')}"`;
43155
43086
  const com = process.env.ComSpec || "cmd.exe";
43156
43087
  try {
43157
- fs24.writeFileSync(
43088
+ fs25.writeFileSync(
43158
43089
  runnerPath,
43159
43090
  `@ECHO OFF\r
43160
43091
  CD /D ${q(cwd)}\r
43161
43092
  ${command} >> ${q(logPath)} 2>&1\r
43162
43093
  `
43163
43094
  );
43164
- const proc = spawn8(
43095
+ const proc = spawn7(
43165
43096
  com,
43166
43097
  ["/d", "/s", "/c", q(runnerPath)],
43167
43098
  mergePreviewEnvironmentSpawnOptions(
@@ -43183,7 +43114,7 @@ ${command} >> ${q(logPath)} 2>&1\r
43183
43114
  }
43184
43115
 
43185
43116
  // ../bridge/src/preview-environments/manager/shell-spawn/try-spawn-inherit.ts
43186
- import { spawn as spawn9 } from "node:child_process";
43117
+ import { spawn as spawn8 } from "node:child_process";
43187
43118
  function trySpawnInheritStdio(command, env, cwd, signal, lifecycle) {
43188
43119
  const opts = mergePreviewEnvironmentSpawnOptions(
43189
43120
  {
@@ -43198,9 +43129,9 @@ function trySpawnInheritStdio(command, env, cwd, signal, lifecycle) {
43198
43129
  if (process.platform === "win32") {
43199
43130
  opts.windowsHide = true;
43200
43131
  const com = process.env.ComSpec || "cmd.exe";
43201
- proc = spawn9(com, ["/d", "/s", "/c", command], opts);
43132
+ proc = spawn8(com, ["/d", "/s", "/c", command], opts);
43202
43133
  } else {
43203
- proc = spawn9("/bin/sh", ["-c", command], opts);
43134
+ proc = spawn8("/bin/sh", ["-c", command], opts);
43204
43135
  }
43205
43136
  return { proc, pipedStdoutStderr: false };
43206
43137
  }
@@ -43456,7 +43387,7 @@ var PreviewEnvironmentManager = class {
43456
43387
  }
43457
43388
  };
43458
43389
 
43459
- // ../bridge/src/connection/create-bridge-preview-stack.ts
43390
+ // ../bridge/src/connection/setup/create-bridge-preview-stack.ts
43460
43391
  function createBridgePreviewStack(options) {
43461
43392
  const previewEnvironmentManager = new PreviewEnvironmentManager({
43462
43393
  getWs: options.getWs,
@@ -43472,15 +43403,15 @@ function createBridgePreviewStack(options) {
43472
43403
  scheduleInitialIndexBuilds(getBridgeRoot());
43473
43404
  };
43474
43405
  const identifyReportedPaths = {
43475
- bridgeRootPath: path38.resolve(getBridgeRoot()),
43476
- worktreesRootPath: path38.resolve(options.worktreesRootPath),
43406
+ bridgeRootPath: path39.resolve(getBridgeRoot()),
43407
+ worktreesRootPath: path39.resolve(options.worktreesRootPath),
43477
43408
  localShortcutPort: 0,
43478
43409
  localShortcutToken: ""
43479
43410
  };
43480
43411
  return { previewEnvironmentManager, scheduleInitialIndexBuildsOnce, identifyReportedPaths };
43481
43412
  }
43482
43413
 
43483
- // ../bridge/src/connection/create-bridge-identified-handler.ts
43414
+ // ../bridge/src/connection/identify/create-bridge-identified-handler.ts
43484
43415
  function createOnBridgeIdentified(opts) {
43485
43416
  const { plugin, previewEnvironmentManager, workspaceId, logFn } = opts;
43486
43417
  return (msg) => {
@@ -43496,7 +43427,7 @@ function createOnBridgeIdentified(opts) {
43496
43427
  };
43497
43428
  }
43498
43429
 
43499
- // ../bridge/src/connection/create-bridge-identified-with-heartbeat.ts
43430
+ // ../bridge/src/connection/identify/create-bridge-identified-with-heartbeat.ts
43500
43431
  function createBridgeIdentifiedWithHeartbeat(params) {
43501
43432
  const { bridgeHeartbeat, log: log2, ...identifiedOpts } = params;
43502
43433
  const onBridgeIdentified = createOnBridgeIdentified({ ...identifiedOpts, logFn: log2 });
@@ -43674,10 +43605,10 @@ function createBridgeHeartbeatController(params) {
43674
43605
  };
43675
43606
  }
43676
43607
 
43677
- // ../bridge/src/cli-version.ts
43678
- var CLI_VERSION2 = "0.1.89".length > 0 ? "0.1.89" : "0.0.0-dev";
43608
+ // ../bridge/src/cli/cli-version.ts
43609
+ var CLI_VERSION2 = "0.1.90".length > 0 ? "0.1.90" : "0.0.0-dev";
43679
43610
 
43680
- // ../bridge/src/connection/send-bridge-identify.ts
43611
+ // ../bridge/src/connection/identify/send-bridge-identify.ts
43681
43612
  function sendBridgeIdentify(ws, params) {
43682
43613
  if (!ws) return;
43683
43614
  const { identifyReportedPaths, e2ee } = params;
@@ -43694,7 +43625,7 @@ function sendBridgeIdentify(ws, params) {
43694
43625
  }
43695
43626
  var BRIDGE_IDENTIFY_REFRESH_EVERY_TICKS = 6;
43696
43627
 
43697
- // ../bridge/src/connection/create-bridge-identify-heartbeat.ts
43628
+ // ../bridge/src/connection/identify/create-bridge-identify-heartbeat.ts
43698
43629
  function createBridgeIdentifyHeartbeat(params) {
43699
43630
  const { getWs, log: log2, identifyReportedPaths, e2ee } = params;
43700
43631
  return createBridgeHeartbeatController({
@@ -43707,7 +43638,7 @@ function createBridgeIdentifyHeartbeat(params) {
43707
43638
  });
43708
43639
  }
43709
43640
 
43710
- // ../bridge/src/connection/create-bridge-message-deps.ts
43641
+ // ../bridge/src/connection/runtime/create-bridge-message-deps.ts
43711
43642
  function createBridgeMessageDeps(params) {
43712
43643
  const {
43713
43644
  getWs,
@@ -43717,7 +43648,6 @@ function createBridgeMessageDeps(params) {
43717
43648
  previewWorktreeManager,
43718
43649
  onBridgeIdentified,
43719
43650
  bridgeHeartbeat,
43720
- sendLocalSkillsReport,
43721
43651
  reportAutoDetectedAgents,
43722
43652
  warmupAgentCapabilitiesOnConnect: warmupAgentCapabilitiesOnConnect2,
43723
43653
  previewEnvironmentManager,
@@ -43735,7 +43665,6 @@ function createBridgeMessageDeps(params) {
43735
43665
  onBridgeHeartbeatAck: (seq) => {
43736
43666
  bridgeHeartbeat.onAck(seq);
43737
43667
  },
43738
- sendLocalSkillsReport,
43739
43668
  reportAutoDetectedAgents,
43740
43669
  warmupAgentCapabilitiesOnConnect: warmupAgentCapabilitiesOnConnect2,
43741
43670
  previewEnvironmentManager,
@@ -43745,114 +43674,8 @@ function createBridgeMessageDeps(params) {
43745
43674
  };
43746
43675
  }
43747
43676
 
43748
- // ../bridge/src/skills/discovery/skill-discovery-roots.ts
43749
- init_constants();
43750
- init_yield_to_event_loop();
43751
- var SKILL_DISCOVERY_ROOTS = [".agents/skills", ".claude/skills", ".cursor/skills", "skills"];
43752
- async function yieldSkillDiscoveryWork(entryCount) {
43753
- if (entryCount > 0 && entryCount % INDEX_WORK_YIELD_EVERY === 0) {
43754
- await yieldToEventLoop();
43755
- }
43756
- }
43757
-
43758
- // ../bridge/src/skills/discovery/discover-local-skills.ts
43759
- import fs25 from "node:fs";
43760
- import path39 from "node:path";
43761
- function collectSkillFromDir(rel, base, name, seenKeys, out) {
43762
- const dir = path39.join(base, name);
43763
- try {
43764
- if (!fs25.statSync(dir).isDirectory()) return;
43765
- } catch {
43766
- return;
43767
- }
43768
- const skillMd = path39.join(dir, "SKILL.md");
43769
- if (!fs25.existsSync(skillMd)) return;
43770
- const key = `${rel}/${name}`;
43771
- if (seenKeys.has(key)) return;
43772
- seenKeys.add(key);
43773
- out.push({ skillKey: name, path: `${rel}/${name}`.replace(/\\/g, "/") });
43774
- }
43775
- async function discoverLocalSkillsAsync(cwd) {
43776
- const out = [];
43777
- const seenKeys = /* @__PURE__ */ new Set();
43778
- let work = 0;
43779
- for (const rel of SKILL_DISCOVERY_ROOTS) {
43780
- await yieldSkillDiscoveryWork(++work);
43781
- const base = path39.join(cwd, rel);
43782
- if (!fs25.existsSync(base) || !fs25.statSync(base).isDirectory()) continue;
43783
- let entries = [];
43784
- try {
43785
- entries = fs25.readdirSync(base);
43786
- } catch {
43787
- continue;
43788
- }
43789
- for (let i = 0; i < entries.length; i++) {
43790
- await yieldSkillDiscoveryWork(++work);
43791
- collectSkillFromDir(rel, base, entries[i], seenKeys, out);
43792
- }
43793
- }
43794
- return out;
43795
- }
43796
-
43797
- // ../bridge/src/skills/discovery/discover-skill-layout-roots.ts
43798
- import fs26 from "node:fs";
43799
- import path40 from "node:path";
43800
- function collectLayoutSkill(rel, base, name, skills2) {
43801
- const dir = path40.join(base, name);
43802
- try {
43803
- if (!fs26.statSync(dir).isDirectory()) return;
43804
- } catch {
43805
- return;
43806
- }
43807
- if (!fs26.existsSync(path40.join(dir, "SKILL.md"))) return;
43808
- const relPath = `${rel}/${name}`.replace(/\\/g, "/");
43809
- skills2.push({ name, relPath });
43810
- }
43811
- async function discoverSkillLayoutRootsAsync(cwd) {
43812
- const roots = [];
43813
- let work = 0;
43814
- for (const rel of SKILL_DISCOVERY_ROOTS) {
43815
- await yieldSkillDiscoveryWork(++work);
43816
- const base = path40.join(cwd, rel);
43817
- if (!fs26.existsSync(base) || !fs26.statSync(base).isDirectory()) continue;
43818
- let entries = [];
43819
- try {
43820
- entries = fs26.readdirSync(base);
43821
- } catch {
43822
- continue;
43823
- }
43824
- const skills2 = [];
43825
- for (let i = 0; i < entries.length; i++) {
43826
- await yieldSkillDiscoveryWork(++work);
43827
- collectLayoutSkill(rel, base, entries[i], skills2);
43828
- }
43829
- if (skills2.length > 0) {
43830
- roots.push({ path: rel.replace(/\\/g, "/"), skills: skills2 });
43831
- }
43832
- }
43833
- return roots;
43834
- }
43835
-
43836
- // ../bridge/src/connection/create-bridge-local-reports.ts
43677
+ // ../bridge/src/connection/reports/create-bridge-local-reports.ts
43837
43678
  init_cli_process_interrupt();
43838
- function createSendLocalSkillsReport(getWs, logFn) {
43839
- return () => {
43840
- setImmediate(() => {
43841
- void (async () => {
43842
- try {
43843
- const socket = getWs();
43844
- if (!socket || socket.readyState !== wrapper_default.OPEN) return;
43845
- const skills2 = await discoverLocalSkillsAsync(getBridgeRoot());
43846
- sendWsMessage(socket, { type: "local_skills", skills: skills2 });
43847
- } catch (e) {
43848
- logFn(
43849
- `[Bridge service] Local skills report failed: ${e instanceof Error ? e.message : String(e)}`
43850
- );
43851
- }
43852
- })();
43853
- });
43854
- };
43855
- }
43856
43679
  function createReportAutoDetectedAgents(getWs, logFn) {
43857
43680
  return async () => {
43858
43681
  if (isCliImmediateShutdownRequested()) return;
@@ -43870,7 +43693,7 @@ function createReportAutoDetectedAgents(getWs, logFn) {
43870
43693
  };
43871
43694
  }
43872
43695
 
43873
- // ../bridge/src/connection/create-bridge-runtime-message-deps.ts
43696
+ // ../bridge/src/connection/runtime/create-bridge-runtime-message-deps.ts
43874
43697
  function createBridgeRuntimeMessageDeps(params) {
43875
43698
  const {
43876
43699
  plugin,
@@ -43893,7 +43716,6 @@ function createBridgeRuntimeMessageDeps(params) {
43893
43716
  previewWorktreeManager,
43894
43717
  onBridgeIdentified,
43895
43718
  bridgeHeartbeat,
43896
- sendLocalSkillsReport: createSendLocalSkillsReport(getWs, log2),
43897
43719
  reportAutoDetectedAgents: createReportAutoDetectedAgents(getWs, log2),
43898
43720
  warmupAgentCapabilitiesOnConnect: createWarmupAgentCapabilitiesOnConnect({
43899
43721
  workspaceId,
@@ -43909,7 +43731,7 @@ function createBridgeRuntimeMessageDeps(params) {
43909
43731
  });
43910
43732
  }
43911
43733
 
43912
- // ../bridge/src/connection/create-bridge-runtime-message-setup.ts
43734
+ // ../bridge/src/connection/runtime/create-bridge-runtime-message-setup.ts
43913
43735
  function createBridgeRuntimeMessageSetup(options) {
43914
43736
  const {
43915
43737
  plugin,
@@ -43955,12 +43777,12 @@ function createBridgeRuntimeMessageSetup(options) {
43955
43777
  }
43956
43778
 
43957
43779
  // ../bridge/src/worktrees/worktree-layout-file.ts
43958
- import * as fs27 from "node:fs";
43959
- import * as path41 from "node:path";
43780
+ import * as fs26 from "node:fs";
43781
+ import * as path40 from "node:path";
43960
43782
  import os7 from "node:os";
43961
43783
  var LAYOUT_FILENAME = "worktree-launcher-layout.json";
43962
43784
  function defaultWorktreeLayoutPath() {
43963
- return path41.join(os7.homedir(), ".buildautomaton", LAYOUT_FILENAME);
43785
+ return path40.join(os7.homedir(), ".buildautomaton", LAYOUT_FILENAME);
43964
43786
  }
43965
43787
  function normalizeLoadedLayout(raw) {
43966
43788
  if (raw && typeof raw === "object" && "launcherCwds" in raw) {
@@ -43972,8 +43794,8 @@ function normalizeLoadedLayout(raw) {
43972
43794
  function loadWorktreeLayout() {
43973
43795
  try {
43974
43796
  const p = defaultWorktreeLayoutPath();
43975
- if (!fs27.existsSync(p)) return { launcherCwds: [] };
43976
- const raw = JSON.parse(fs27.readFileSync(p, "utf8"));
43797
+ if (!fs26.existsSync(p)) return { launcherCwds: [] };
43798
+ const raw = JSON.parse(fs26.readFileSync(p, "utf8"));
43977
43799
  return normalizeLoadedLayout(raw);
43978
43800
  } catch {
43979
43801
  return { launcherCwds: [] };
@@ -43981,24 +43803,24 @@ function loadWorktreeLayout() {
43981
43803
  }
43982
43804
  function saveWorktreeLayout(layout) {
43983
43805
  try {
43984
- const dir = path41.dirname(defaultWorktreeLayoutPath());
43985
- fs27.mkdirSync(dir, { recursive: true });
43986
- fs27.writeFileSync(defaultWorktreeLayoutPath(), JSON.stringify(layout, null, 2), "utf8");
43806
+ const dir = path40.dirname(defaultWorktreeLayoutPath());
43807
+ fs26.mkdirSync(dir, { recursive: true });
43808
+ fs26.writeFileSync(defaultWorktreeLayoutPath(), JSON.stringify(layout, null, 2), "utf8");
43987
43809
  } catch {
43988
43810
  }
43989
43811
  }
43990
43812
  function baseNameSafe(pathString) {
43991
- return path41.basename(pathString).replace(/[^a-zA-Z0-9._-]+/g, "-") || "cwd";
43813
+ return path40.basename(pathString).replace(/[^a-zA-Z0-9._-]+/g, "-") || "cwd";
43992
43814
  }
43993
43815
  function getLauncherDirNameIfPresent(layout, bridgeRootPath2) {
43994
- const norm = path41.resolve(bridgeRootPath2);
43995
- const existing = layout.launcherCwds.find((e) => path41.resolve(e.absolutePath) === norm);
43816
+ const norm = path40.resolve(bridgeRootPath2);
43817
+ const existing = layout.launcherCwds.find((e) => path40.resolve(e.absolutePath) === norm);
43996
43818
  return existing?.dirName;
43997
43819
  }
43998
43820
  function allocateDirNameForLauncherCwd(layout, bridgeRootPath2) {
43999
43821
  const existing = getLauncherDirNameIfPresent(layout, bridgeRootPath2);
44000
43822
  if (existing) return existing;
44001
- const norm = path41.resolve(bridgeRootPath2);
43823
+ const norm = path40.resolve(bridgeRootPath2);
44002
43824
  const base = baseNameSafe(norm);
44003
43825
  const used = new Set(layout.launcherCwds.map((e) => e.dirName));
44004
43826
  let name = base;
@@ -44060,7 +43882,7 @@ var import_debug = __toESM(require_src(), 1);
44060
43882
  var import_promise_deferred = __toESM(require_dist2(), 1);
44061
43883
  var import_promise_deferred2 = __toESM(require_dist2(), 1);
44062
43884
  import { Buffer as Buffer2 } from "node:buffer";
44063
- import { spawn as spawn10 } from "child_process";
43885
+ import { spawn as spawn9 } from "child_process";
44064
43886
  import { normalize as normalize3 } from "node:path";
44065
43887
  import { EventEmitter } from "node:events";
44066
43888
  var __defProp2 = Object.defineProperty;
@@ -44091,8 +43913,8 @@ function pathspec(...paths) {
44091
43913
  cache.set(key, paths);
44092
43914
  return key;
44093
43915
  }
44094
- function isPathSpec(path91) {
44095
- return path91 instanceof String && cache.has(path91);
43916
+ function isPathSpec(path88) {
43917
+ return path88 instanceof String && cache.has(path88);
44096
43918
  }
44097
43919
  function toPaths(pathSpec) {
44098
43920
  return cache.get(pathSpec) || [];
@@ -44181,8 +44003,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
44181
44003
  function forEachLineWithContent(input, callback) {
44182
44004
  return toLinesWithContent(input, true).map((line) => callback(line));
44183
44005
  }
44184
- function folderExists(path91) {
44185
- return (0, import_file_exists.exists)(path91, import_file_exists.FOLDER);
44006
+ function folderExists(path88) {
44007
+ return (0, import_file_exists.exists)(path88, import_file_exists.FOLDER);
44186
44008
  }
44187
44009
  function append(target, item) {
44188
44010
  if (Array.isArray(target)) {
@@ -44586,8 +44408,8 @@ function checkIsRepoRootTask() {
44586
44408
  commands,
44587
44409
  format: "utf-8",
44588
44410
  onError,
44589
- parser(path91) {
44590
- return /^\.(git)?$/.test(path91.trim());
44411
+ parser(path88) {
44412
+ return /^\.(git)?$/.test(path88.trim());
44591
44413
  }
44592
44414
  };
44593
44415
  }
@@ -45021,11 +44843,11 @@ function parseGrep(grep) {
45021
44843
  const paths = /* @__PURE__ */ new Set();
45022
44844
  const results = {};
45023
44845
  forEachLineWithContent(grep, (input) => {
45024
- const [path91, line, preview] = input.split(NULL);
45025
- paths.add(path91);
45026
- (results[path91] = results[path91] || []).push({
44846
+ const [path88, line, preview] = input.split(NULL);
44847
+ paths.add(path88);
44848
+ (results[path88] = results[path88] || []).push({
45027
44849
  line: asNumber(line),
45028
- path: path91,
44850
+ path: path88,
45029
44851
  preview
45030
44852
  });
45031
44853
  });
@@ -45448,7 +45270,7 @@ var init_git_executor_chain = __esm2({
45448
45270
  rejection = reason || rejection;
45449
45271
  }
45450
45272
  });
45451
- const spawned = spawn10(command, args, spawnOptions);
45273
+ const spawned = spawn9(command, args, spawnOptions);
45452
45274
  spawned.stdout.on(
45453
45275
  "data",
45454
45276
  onDataReceived(stdOut, "stdOut", logger, outputLogger.step("stdOut"))
@@ -45790,14 +45612,14 @@ var init_hash_object = __esm2({
45790
45612
  init_task();
45791
45613
  }
45792
45614
  });
45793
- function parseInit(bare, path91, text) {
45615
+ function parseInit(bare, path88, text) {
45794
45616
  const response = String(text).trim();
45795
45617
  let result;
45796
45618
  if (result = initResponseRegex.exec(response)) {
45797
- return new InitSummary(bare, path91, false, result[1]);
45619
+ return new InitSummary(bare, path88, false, result[1]);
45798
45620
  }
45799
45621
  if (result = reInitResponseRegex.exec(response)) {
45800
- return new InitSummary(bare, path91, true, result[1]);
45622
+ return new InitSummary(bare, path88, true, result[1]);
45801
45623
  }
45802
45624
  let gitDir = "";
45803
45625
  const tokens = response.split(" ");
@@ -45808,7 +45630,7 @@ function parseInit(bare, path91, text) {
45808
45630
  break;
45809
45631
  }
45810
45632
  }
45811
- return new InitSummary(bare, path91, /^re/i.test(response), gitDir);
45633
+ return new InitSummary(bare, path88, /^re/i.test(response), gitDir);
45812
45634
  }
45813
45635
  var InitSummary;
45814
45636
  var initResponseRegex;
@@ -45817,9 +45639,9 @@ var init_InitSummary = __esm2({
45817
45639
  "src/lib/responses/InitSummary.ts"() {
45818
45640
  "use strict";
45819
45641
  InitSummary = class {
45820
- constructor(bare, path91, existing, gitDir) {
45642
+ constructor(bare, path88, existing, gitDir) {
45821
45643
  this.bare = bare;
45822
- this.path = path91;
45644
+ this.path = path88;
45823
45645
  this.existing = existing;
45824
45646
  this.gitDir = gitDir;
45825
45647
  }
@@ -45831,7 +45653,7 @@ var init_InitSummary = __esm2({
45831
45653
  function hasBareCommand(command) {
45832
45654
  return command.includes(bareCommand);
45833
45655
  }
45834
- function initTask(bare = false, path91, customArgs) {
45656
+ function initTask(bare = false, path88, customArgs) {
45835
45657
  const commands = ["init", ...customArgs];
45836
45658
  if (bare && !hasBareCommand(commands)) {
45837
45659
  commands.splice(1, 0, bareCommand);
@@ -45840,7 +45662,7 @@ function initTask(bare = false, path91, customArgs) {
45840
45662
  commands,
45841
45663
  format: "utf-8",
45842
45664
  parser(text) {
45843
- return parseInit(commands.includes("--bare"), path91, text);
45665
+ return parseInit(commands.includes("--bare"), path88, text);
45844
45666
  }
45845
45667
  };
45846
45668
  }
@@ -46656,12 +46478,12 @@ var init_FileStatusSummary = __esm2({
46656
46478
  "use strict";
46657
46479
  fromPathRegex = /^(.+)\0(.+)$/;
46658
46480
  FileStatusSummary = class {
46659
- constructor(path91, index, working_dir) {
46660
- this.path = path91;
46481
+ constructor(path88, index, working_dir) {
46482
+ this.path = path88;
46661
46483
  this.index = index;
46662
46484
  this.working_dir = working_dir;
46663
46485
  if (index === "R" || working_dir === "R") {
46664
- const detail = fromPathRegex.exec(path91) || [null, path91, path91];
46486
+ const detail = fromPathRegex.exec(path88) || [null, path88, path88];
46665
46487
  this.from = detail[2] || "";
46666
46488
  this.path = detail[1] || "";
46667
46489
  }
@@ -46692,14 +46514,14 @@ function splitLine(result, lineStr) {
46692
46514
  default:
46693
46515
  return;
46694
46516
  }
46695
- function data(index, workingDir, path91) {
46517
+ function data(index, workingDir, path88) {
46696
46518
  const raw = `${index}${workingDir}`;
46697
46519
  const handler = parsers6.get(raw);
46698
46520
  if (handler) {
46699
- handler(result, path91);
46521
+ handler(result, path88);
46700
46522
  }
46701
46523
  if (raw !== "##" && raw !== "!!") {
46702
- result.files.push(new FileStatusSummary(path91, index, workingDir));
46524
+ result.files.push(new FileStatusSummary(path88, index, workingDir));
46703
46525
  }
46704
46526
  }
46705
46527
  }
@@ -47008,9 +46830,9 @@ var init_simple_git_api = __esm2({
47008
46830
  next
47009
46831
  );
47010
46832
  }
47011
- hashObject(path91, write) {
46833
+ hashObject(path88, write) {
47012
46834
  return this._runTask(
47013
- hashObjectTask(path91, write === true),
46835
+ hashObjectTask(path88, write === true),
47014
46836
  trailingFunctionArgument(arguments)
47015
46837
  );
47016
46838
  }
@@ -47363,8 +47185,8 @@ var init_branch = __esm2({
47363
47185
  }
47364
47186
  });
47365
47187
  function toPath(input) {
47366
- const path91 = input.trim().replace(/^["']|["']$/g, "");
47367
- return path91 && normalize3(path91);
47188
+ const path88 = input.trim().replace(/^["']|["']$/g, "");
47189
+ return path88 && normalize3(path88);
47368
47190
  }
47369
47191
  var parseCheckIgnore;
47370
47192
  var init_CheckIgnore = __esm2({
@@ -47678,8 +47500,8 @@ __export2(sub_module_exports, {
47678
47500
  subModuleTask: () => subModuleTask,
47679
47501
  updateSubModuleTask: () => updateSubModuleTask
47680
47502
  });
47681
- function addSubModuleTask(repo, path91) {
47682
- return subModuleTask(["add", repo, path91]);
47503
+ function addSubModuleTask(repo, path88) {
47504
+ return subModuleTask(["add", repo, path88]);
47683
47505
  }
47684
47506
  function initSubModuleTask(customArgs) {
47685
47507
  return subModuleTask(["init", ...customArgs]);
@@ -48012,8 +47834,8 @@ var require_git = __commonJS2({
48012
47834
  }
48013
47835
  return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
48014
47836
  };
48015
- Git2.prototype.submoduleAdd = function(repo, path91, then) {
48016
- return this._runTask(addSubModuleTask2(repo, path91), trailingFunctionArgument2(arguments));
47837
+ Git2.prototype.submoduleAdd = function(repo, path88, then) {
47838
+ return this._runTask(addSubModuleTask2(repo, path88), trailingFunctionArgument2(arguments));
48017
47839
  };
48018
47840
  Git2.prototype.submoduleUpdate = function(args, then) {
48019
47841
  return this._runTask(
@@ -48752,8 +48574,8 @@ function parseNumstatEntries(lines) {
48752
48574
  }
48753
48575
  function parseNumstat(lines) {
48754
48576
  const m = /* @__PURE__ */ new Map();
48755
- for (const [path91, entry] of parseNumstatEntries(lines)) {
48756
- m.set(path91, { additions: entry.additions, deletions: entry.deletions });
48577
+ for (const [path88, entry] of parseNumstatEntries(lines)) {
48578
+ m.set(path88, { additions: entry.additions, deletions: entry.deletions });
48757
48579
  }
48758
48580
  return m;
48759
48581
  }
@@ -48882,7 +48704,7 @@ async function resolveDefaultRemoteBranchSha(g, remote) {
48882
48704
  }
48883
48705
 
48884
48706
  // ../bridge/src/git/commits/remote-tracking/resolve-base-sha-for-unpushed-commits.ts
48885
- import * as path42 from "node:path";
48707
+ import * as path41 from "node:path";
48886
48708
  var BASE_SHA_CACHE_TTL_MS = 3e4;
48887
48709
  var baseShaCache = /* @__PURE__ */ new Map();
48888
48710
  async function resolveBaseShaForUnpushedCommitsUncached(g) {
@@ -48893,7 +48715,7 @@ async function resolveBaseShaForUnpushedCommitsUncached(g) {
48893
48715
  }
48894
48716
  async function resolveBaseShaForUnpushedCommits(g, repoDir) {
48895
48717
  if (repoDir) {
48896
- const key = path42.resolve(repoDir);
48718
+ const key = path41.resolve(repoDir);
48897
48719
  const now = Date.now();
48898
48720
  const cached2 = baseShaCache.get(key);
48899
48721
  if (cached2 && cached2.expiresAt > now) return cached2.baseSha;
@@ -49028,17 +48850,17 @@ function formatRemoteDisplayLabel(remoteUrl) {
49028
48850
  }
49029
48851
 
49030
48852
  // ../bridge/src/git/changes/repo/get-working-tree-change-repo-details.ts
49031
- import * as path52 from "node:path";
48853
+ import * as path51 from "node:path";
49032
48854
 
49033
48855
  // ../bridge/src/git/changes/repo/build-working-tree-change-repo-detail.ts
49034
- import * as path51 from "node:path";
48856
+ import * as path50 from "node:path";
49035
48857
 
49036
48858
  // ../bridge/src/git/is-git-repo.ts
49037
- import * as fs28 from "node:fs";
49038
- import * as path43 from "node:path";
48859
+ import * as fs27 from "node:fs";
48860
+ import * as path42 from "node:path";
49039
48861
  async function isGitRepoDirectory(dirPath) {
49040
48862
  try {
49041
- await fs28.promises.access(path43.join(dirPath, ".git"));
48863
+ await fs27.promises.access(path42.join(dirPath, ".git"));
49042
48864
  return true;
49043
48865
  } catch {
49044
48866
  return false;
@@ -49046,12 +48868,12 @@ async function isGitRepoDirectory(dirPath) {
49046
48868
  }
49047
48869
 
49048
48870
  // ../bridge/src/git/changes/listing/apply-untracked-file-stats.ts
49049
- import * as fs29 from "node:fs";
49050
- import * as path44 from "node:path";
48871
+ import * as fs28 from "node:fs";
48872
+ import * as path43 from "node:path";
49051
48873
 
49052
48874
  // ../bridge/src/git/changes/lines/count-lines.ts
49053
48875
  import { createReadStream } from "node:fs";
49054
- import * as readline2 from "node:readline";
48876
+ import * as readline3 from "node:readline";
49055
48877
  function countLinesInText(text) {
49056
48878
  return splitTextIntoDiffLines(text).length;
49057
48879
  }
@@ -49060,7 +48882,7 @@ async function countTextFileLines(filePath) {
49060
48882
  const maxBytes = 512e3;
49061
48883
  let lines = 0;
49062
48884
  const stream = createReadStream(filePath, { encoding: "utf8" });
49063
- const rl = readline2.createInterface({ input: stream, crlfDelay: Infinity });
48885
+ const rl = readline3.createInterface({ input: stream, crlfDelay: Infinity });
49064
48886
  for await (const _line of rl) {
49065
48887
  lines += 1;
49066
48888
  bytes += Buffer.byteLength(String(_line), "utf8") + 1;
@@ -49079,7 +48901,7 @@ function createUntrackedStatsApplier(options) {
49079
48901
  if (!options.untrackedSet.has(pathInRepo)) return;
49080
48902
  if (options.nameByPath.has(pathInRepo)) return;
49081
48903
  if (row.change === "moved") return;
49082
- const repoFilePath = path44.join(options.repoGitCwd, pathInRepo);
48904
+ const repoFilePath = path43.join(options.repoGitCwd, pathInRepo);
49083
48905
  const fromGit = await numstatFromGitNoIndex(options.g, pathInRepo);
49084
48906
  if (fromGit) {
49085
48907
  row.additions = fromGit.additions;
@@ -49087,7 +48909,7 @@ function createUntrackedStatsApplier(options) {
49087
48909
  return;
49088
48910
  }
49089
48911
  try {
49090
- const st = await fs29.promises.stat(repoFilePath);
48912
+ const st = await fs28.promises.stat(repoFilePath);
49091
48913
  row.additions = st.isFile() ? await countTextFileLines(repoFilePath) : 0;
49092
48914
  } catch {
49093
48915
  row.additions = 0;
@@ -49164,7 +48986,7 @@ async function buildChangedFileRowsFromPaths(options) {
49164
48986
  }
49165
48987
 
49166
48988
  // ../bridge/src/git/changes/listing/enrich-working-tree-file-rows.ts
49167
- import * as path46 from "node:path";
48989
+ import * as path45 from "node:path";
49168
48990
 
49169
48991
  // ../bridge/src/git/changes/patch/patch-truncate.ts
49170
48992
  function truncatePatch(s) {
@@ -49252,10 +49074,10 @@ async function readGitBlobLines(repoCwd, pathInRepo) {
49252
49074
  }
49253
49075
 
49254
49076
  // ../bridge/src/git/changes/patch/hydrate/read-worktree-file-lines.ts
49255
- import * as fs30 from "node:fs";
49077
+ import * as fs29 from "node:fs";
49256
49078
  async function readWorktreeFileLines(filePath) {
49257
49079
  try {
49258
- const raw = await fs30.promises.readFile(filePath, "utf8");
49080
+ const raw = await fs29.promises.readFile(filePath, "utf8");
49259
49081
  return raw.split(/\r?\n/);
49260
49082
  } catch {
49261
49083
  return null;
@@ -49393,8 +49215,8 @@ async function unifiedDiffForFileInRange(repoCwd, range, pathInRepo, change, mov
49393
49215
  }
49394
49216
 
49395
49217
  // ../bridge/src/git/changes/total-lines/resolve-changed-file-total-lines.ts
49396
- import * as fs31 from "node:fs";
49397
- import * as path45 from "node:path";
49218
+ import * as fs30 from "node:fs";
49219
+ import * as path44 from "node:path";
49398
49220
  var MAX_BYTES = 512e3;
49399
49221
  async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
49400
49222
  const spec = `${ref}:${pathInRepo}`;
@@ -49414,13 +49236,13 @@ async function countLinesInGitRef(repoGitCwd, ref, pathInRepo) {
49414
49236
  }
49415
49237
  async function resolveWorkingTreeFileTotalLines(options) {
49416
49238
  if (options.isBinary) return null;
49417
- const filePath = path45.join(options.repoGitCwd, options.pathInRepo);
49239
+ const filePath = path44.join(options.repoGitCwd, options.pathInRepo);
49418
49240
  if (options.change === "removed") {
49419
49241
  return countLinesInGitRef(options.repoGitCwd, "HEAD", options.pathInRepo);
49420
49242
  }
49421
49243
  if (options.change === "moved" || options.change === "modified") {
49422
49244
  try {
49423
- const st = await fs31.promises.stat(filePath);
49245
+ const st = await fs30.promises.stat(filePath);
49424
49246
  if (!st.isFile()) return null;
49425
49247
  return await countTextFileLines(filePath);
49426
49248
  } catch {
@@ -49463,7 +49285,7 @@ async function enrichWorkingTreeFileRows(options) {
49463
49285
  row.workspaceRelPath,
49464
49286
  options.repoPathRelativeToWorkspaceRoot
49465
49287
  );
49466
- const filePath = path46.join(options.repoGitCwd, filePathRelativeToRepoRoot);
49288
+ const filePath = path45.join(options.repoGitCwd, filePathRelativeToRepoRoot);
49467
49289
  const hydrateKind = row.change === "moved" ? "modified" : row.change;
49468
49290
  let patch = await unifiedDiffForFile(
49469
49291
  options.repoGitCwd,
@@ -49621,7 +49443,7 @@ async function listChangedFilesForRepo(repoGitCwd, repoPathRelativeToWorkspaceRo
49621
49443
  }
49622
49444
 
49623
49445
  // ../bridge/src/git/changes/listing/list-changed-files-for-commit.ts
49624
- import * as path47 from "node:path";
49446
+ import * as path46 from "node:path";
49625
49447
 
49626
49448
  // ../bridge/src/git/changes/listing/enrich-commit-file-rows.ts
49627
49449
  async function enrichCommitFileRows(options) {
@@ -49666,7 +49488,7 @@ async function parentForCommitDiff(g, sha) {
49666
49488
  var COMMIT_FILES_CACHE_TTL_MS = 5 * 6e4;
49667
49489
  var commitFilesCache = /* @__PURE__ */ new Map();
49668
49490
  function commitFilesCacheKey(repoGitCwd, commitSha) {
49669
- return `${path47.resolve(repoGitCwd)}:${commitSha}`;
49491
+ return `${path46.resolve(repoGitCwd)}:${commitSha}`;
49670
49492
  }
49671
49493
  async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspaceRoot, commitSha, options = {}) {
49672
49494
  const cacheKey = commitFilesCacheKey(repoGitCwd, commitSha);
@@ -49721,7 +49543,7 @@ async function listChangedFilesForCommit(repoGitCwd, repoPathRelativeToWorkspace
49721
49543
  }
49722
49544
 
49723
49545
  // ../bridge/src/git/commits/list-unpushed-commits.ts
49724
- import * as path48 from "node:path";
49546
+ import * as path47 from "node:path";
49725
49547
 
49726
49548
  // ../bridge/src/git/commits/lib/parse-log-lines.ts
49727
49549
  function parseLogShaDateSubjectLines(raw) {
@@ -49756,7 +49578,7 @@ async function gitLogNotReachableFromBase(g, baseSha, headSha) {
49756
49578
  }
49757
49579
  }
49758
49580
  async function listUnpushedCommits(repoDir) {
49759
- const key = path48.resolve(repoDir);
49581
+ const key = path47.resolve(repoDir);
49760
49582
  const now = Date.now();
49761
49583
  const cached2 = unpushedCache.get(key);
49762
49584
  if (cached2 && cached2.expiresAt > now) return cached2.commits;
@@ -49817,7 +49639,7 @@ async function loadRecentAndUnpushedCommitsForRepoDetail(repoDir, recentCommitsL
49817
49639
  }
49818
49640
 
49819
49641
  // ../bridge/src/git/changes/repo/load-working-tree-change-repo-git-info.ts
49820
- import * as path49 from "node:path";
49642
+ import * as path48 from "node:path";
49821
49643
 
49822
49644
  // ../bridge/src/git/remote-origin-url.ts
49823
49645
  async function getRemoteOriginUrl(gitDir) {
@@ -49832,7 +49654,7 @@ async function getRemoteOriginUrl(gitDir) {
49832
49654
 
49833
49655
  // ../bridge/src/git/changes/repo/load-working-tree-change-repo-git-info.ts
49834
49656
  async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
49835
- const resolvedCheckoutPath = path49.resolve(checkoutPath);
49657
+ const resolvedCheckoutPath = path48.resolve(checkoutPath);
49836
49658
  const git = cliSimpleGit(resolvedCheckoutPath);
49837
49659
  await yieldToEventLoop2();
49838
49660
  const [branch, remoteUrl] = await Promise.all([
@@ -49847,14 +49669,14 @@ async function loadWorkingTreeChangeRepoGitInfo(checkoutPath) {
49847
49669
  }
49848
49670
 
49849
49671
  // ../bridge/src/git/changes/repo/resolve-repo-path-relative-to-workspace-root.ts
49850
- import * as path50 from "node:path";
49672
+ import * as path49 from "node:path";
49851
49673
  async function resolveRepoPathRelativeToWorkspaceRoot(options) {
49852
- const checkoutPath = path50.resolve(options.checkoutPath);
49674
+ const checkoutPath = path49.resolve(options.checkoutPath);
49853
49675
  const git = cliSimpleGit(checkoutPath);
49854
- const sessionParentPath = options.sessionParentPath ? path50.resolve(options.sessionParentPath) : null;
49676
+ const sessionParentPath = options.sessionParentPath ? path49.resolve(options.sessionParentPath) : null;
49855
49677
  let repoPathRelativeToWorkspaceRoot;
49856
49678
  if (sessionParentPath) {
49857
- const checkoutPathRelativeToSessionParent = path50.relative(sessionParentPath, checkoutPath);
49679
+ const checkoutPathRelativeToSessionParent = path49.relative(sessionParentPath, checkoutPath);
49858
49680
  repoPathRelativeToWorkspaceRoot = checkoutPathRelativeToSessionParent === "" ? "." : checkoutPathRelativeToSessionParent.replace(/\\/g, "/");
49859
49681
  } else {
49860
49682
  let gitTopLevel = checkoutPath;
@@ -49864,8 +49686,8 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
49864
49686
  } catch {
49865
49687
  gitTopLevel = checkoutPath;
49866
49688
  }
49867
- const gitTopLevelRelativeToBridgeRoot = path50.relative(options.bridgeRoot, path50.resolve(gitTopLevel)).replace(/\\/g, "/") || ".";
49868
- repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ? path50.basename(path50.resolve(gitTopLevel)) : gitTopLevelRelativeToBridgeRoot;
49689
+ const gitTopLevelRelativeToBridgeRoot = path49.relative(options.bridgeRoot, path49.resolve(gitTopLevel)).replace(/\\/g, "/") || ".";
49690
+ repoPathRelativeToWorkspaceRoot = gitTopLevelRelativeToBridgeRoot.startsWith("..") ? path49.basename(path49.resolve(gitTopLevel)) : gitTopLevelRelativeToBridgeRoot;
49869
49691
  }
49870
49692
  return normalizeRepoPathRelativeToWorkspaceRoot(
49871
49693
  repoPathRelativeToWorkspaceRoot === "" ? "." : repoPathRelativeToWorkspaceRoot
@@ -49874,10 +49696,10 @@ async function resolveRepoPathRelativeToWorkspaceRoot(options) {
49874
49696
 
49875
49697
  // ../bridge/src/git/changes/repo/build-working-tree-change-repo-detail.ts
49876
49698
  async function buildWorkingTreeChangeRepoDetail(options) {
49877
- const checkoutPath = path51.resolve(options.targetPath);
49699
+ const checkoutPath = path50.resolve(options.targetPath);
49878
49700
  if (!await isGitRepoDirectory(checkoutPath)) return null;
49879
49701
  const isCommitView = options.basis.kind === "commit";
49880
- const sessionParentPath = options.sessionParentPath ? path51.resolve(options.sessionParentPath) : null;
49702
+ const sessionParentPath = options.sessionParentPath ? path50.resolve(options.sessionParentPath) : null;
49881
49703
  const git = cliSimpleGit(checkoutPath);
49882
49704
  const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
49883
49705
  checkoutPath,
@@ -49925,8 +49747,8 @@ async function buildWorkingTreeChangeRepoDetail(options) {
49925
49747
 
49926
49748
  // ../bridge/src/git/changes/repo/get-working-tree-change-repo-details.ts
49927
49749
  async function getWorkingTreeChangeRepoDetails(options) {
49928
- const bridgeRoot = path52.resolve(getBridgeRoot());
49929
- const sessionParentPath = options.sessionParentPath ? path52.resolve(options.sessionParentPath) : null;
49750
+ const bridgeRoot = path51.resolve(getBridgeRoot());
49751
+ const sessionParentPath = options.sessionParentPath ? path51.resolve(options.sessionParentPath) : null;
49930
49752
  const out = [];
49931
49753
  const filter = options.repoFilterRelPath != null ? normalizeRepoPathRelativeToWorkspaceRoot(options.repoFilterRelPath) : null;
49932
49754
  const basisInput = options.basis ?? { kind: "working" };
@@ -49957,9 +49779,9 @@ async function getWorkingTreeChangeRepoDetails(options) {
49957
49779
  }
49958
49780
 
49959
49781
  // ../bridge/src/git/changes/repo/get-working-tree-change-file-patch.ts
49960
- import * as path53 from "node:path";
49782
+ import * as path52 from "node:path";
49961
49783
  async function getWorkingTreeChangeFilePatch(options) {
49962
- const repoGitCwd = path53.resolve(options.repoGitCwd);
49784
+ const repoGitCwd = path52.resolve(options.repoGitCwd);
49963
49785
  if (!await isGitRepoDirectory(repoGitCwd)) {
49964
49786
  throw new Error("Not a git repository");
49965
49787
  }
@@ -49998,7 +49820,7 @@ async function getWorkingTreeChangeFilePatch(options) {
49998
49820
  });
49999
49821
  return { patchContent: patchContent2, totalLines: totalLines2 };
50000
49822
  }
50001
- const filePath = path53.join(repoGitCwd, filePathRelativeToRepoRoot);
49823
+ const filePath = path52.join(repoGitCwd, filePathRelativeToRepoRoot);
50002
49824
  const hydrateKind = options.change === "moved" ? "modified" : options.change;
50003
49825
  let patchContent = await unifiedDiffForFile(
50004
49826
  repoGitCwd,
@@ -50044,18 +49866,18 @@ function parseWorkingTreeChangeKind(value) {
50044
49866
  }
50045
49867
 
50046
49868
  // ../bridge/src/worktrees/manager/git/get-session-working-tree-change-file-patch.ts
50047
- import * as path54 from "node:path";
49869
+ import * as path53 from "node:path";
50048
49870
  async function getSessionWorkingTreeChangeFilePatch(cache2, sessionId, discover, opts) {
50049
49871
  const targets = await resolveCommitTargetsAsync(sessionId, cache2, discover);
50050
- const bridgeRoot = path54.resolve(getBridgeRoot());
50051
- const sessionParentPath = cache2.getSessionParentPath(sessionId) ? path54.resolve(cache2.getSessionParentPath(sessionId)) : null;
49872
+ const bridgeRoot = path53.resolve(getBridgeRoot());
49873
+ const sessionParentPath = cache2.getSessionParentPath(sessionId) ? path53.resolve(cache2.getSessionParentPath(sessionId)) : null;
50052
49874
  const repoPathRelativeToWorkspaceRootFilter = normalizeRepoPathRelativeToWorkspaceRoot(
50053
49875
  opts.repoRelPath.trim()
50054
49876
  );
50055
49877
  let result = null;
50056
49878
  await forEachWithGitYield(targets, async (targetPath) => {
50057
49879
  if (result) return;
50058
- const checkoutPath = path54.resolve(targetPath);
49880
+ const checkoutPath = path53.resolve(targetPath);
50059
49881
  if (!await isGitRepoDirectory(checkoutPath)) return;
50060
49882
  const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
50061
49883
  checkoutPath,
@@ -50088,13 +49910,13 @@ async function pushSessionUpstream(cache2, sessionId, discover) {
50088
49910
  }
50089
49911
 
50090
49912
  // ../bridge/src/worktrees/remove-session-worktrees.ts
50091
- import * as fs34 from "node:fs";
49913
+ import * as fs33 from "node:fs";
50092
49914
 
50093
49915
  // ../bridge/src/git/worktrees/worktree-remove.ts
50094
- import * as fs33 from "node:fs";
49916
+ import * as fs32 from "node:fs";
50095
49917
 
50096
49918
  // ../bridge/src/worktrees/is-removable-session-worktree-checkout-path.ts
50097
- import path55 from "node:path";
49919
+ import path54 from "node:path";
50098
49920
  init_normalize_resolved_path();
50099
49921
  function isBridgeRootCheckoutPath(checkoutPath) {
50100
49922
  return normalizeResolvedPath(checkoutPath) === normalizeResolvedPath(getBridgeRoot());
@@ -50103,23 +49925,23 @@ function isRemovableSessionWorktreeCheckoutPath(checkoutPath, worktreesRootPath)
50103
49925
  if (isBridgeRootCheckoutPath(checkoutPath)) return false;
50104
49926
  const normalized = normalizeResolvedPath(checkoutPath);
50105
49927
  const worktreesRoot = normalizeResolvedPath(worktreesRootPath);
50106
- const rel = path55.relative(worktreesRoot, normalized);
50107
- if (rel === "" || rel.startsWith("..") || path55.isAbsolute(rel)) return false;
49928
+ const rel = path54.relative(worktreesRoot, normalized);
49929
+ if (rel === "" || rel.startsWith("..") || path54.isAbsolute(rel)) return false;
50108
49930
  return true;
50109
49931
  }
50110
49932
 
50111
49933
  // ../bridge/src/git/worktrees/resolve-main-repo-from-git-file.ts
50112
- import * as fs32 from "node:fs";
50113
- import * as path56 from "node:path";
49934
+ import * as fs31 from "node:fs";
49935
+ import * as path55 from "node:path";
50114
49936
  function resolveMainRepoFromWorktreeGitFile(wt) {
50115
- const gitDirFile = path56.join(wt, ".git");
50116
- if (!fs32.existsSync(gitDirFile) || !fs32.statSync(gitDirFile).isFile()) return "";
50117
- const first2 = fs32.readFileSync(gitDirFile, "utf8").trim();
49937
+ const gitDirFile = path55.join(wt, ".git");
49938
+ if (!fs31.existsSync(gitDirFile) || !fs31.statSync(gitDirFile).isFile()) return "";
49939
+ const first2 = fs31.readFileSync(gitDirFile, "utf8").trim();
50118
49940
  const m = first2.match(/^gitdir:\s*(.+)$/im);
50119
49941
  if (!m) return "";
50120
- const gitWorktreePath = path56.resolve(wt, m[1].trim());
50121
- const gitDir = path56.dirname(path56.dirname(gitWorktreePath));
50122
- return path56.dirname(gitDir);
49942
+ const gitWorktreePath = path55.resolve(wt, m[1].trim());
49943
+ const gitDir = path55.dirname(path55.dirname(gitWorktreePath));
49944
+ return path55.dirname(gitDir);
50123
49945
  }
50124
49946
 
50125
49947
  // ../bridge/src/git/worktrees/worktree-remove.ts
@@ -50130,7 +49952,7 @@ async function gitWorktreeRemoveForce(worktreePath) {
50130
49952
  return true;
50131
49953
  }
50132
49954
  if (isBridgeRootCheckoutPath(worktreePath)) return false;
50133
- fs33.rmSync(worktreePath, { recursive: true, force: true });
49955
+ fs32.rmSync(worktreePath, { recursive: true, force: true });
50134
49956
  return true;
50135
49957
  }
50136
49958
 
@@ -50152,7 +49974,7 @@ async function removeSessionWorktrees(paths, worktreesRootPath, log2) {
50152
49974
  log2(`[worktrees] Remove failed for ${wt}: ${e instanceof Error ? e.message : String(e)}`);
50153
49975
  if (isRemovableSessionWorktreeCheckoutPath(wt, worktreesRootPath)) {
50154
49976
  try {
50155
- fs34.rmSync(wt, { recursive: true, force: true });
49977
+ fs33.rmSync(wt, { recursive: true, force: true });
50156
49978
  } catch {
50157
49979
  }
50158
49980
  }
@@ -50208,12 +50030,12 @@ async function renameSessionWorktreeBranch(cache2, sessionId, newBranch, log2) {
50208
50030
  // ../bridge/src/worktrees/discovery/discover-session-worktree-on-disk.ts
50209
50031
  init_cli_process_interrupt();
50210
50032
  init_yield_to_event_loop();
50211
- import * as fs38 from "node:fs";
50212
- import * as path61 from "node:path";
50033
+ import * as fs37 from "node:fs";
50034
+ import * as path60 from "node:path";
50213
50035
 
50214
50036
  // ../bridge/src/worktrees/discovery/collect-worktree-paths.ts
50215
- import * as fs36 from "node:fs";
50216
- import * as path58 from "node:path";
50037
+ import * as fs35 from "node:fs";
50038
+ import * as path57 from "node:path";
50217
50039
 
50218
50040
  // ../bridge/src/worktrees/discovery/disk-walk-constants.ts
50219
50041
  var DISK_WALK_YIELD_EVERY = 64;
@@ -50243,8 +50065,8 @@ function shouldSkipDiskWalkEntry(name) {
50243
50065
  // ../bridge/src/worktrees/discovery/disk-walk-utils.ts
50244
50066
  init_cli_process_interrupt();
50245
50067
  init_yield_to_event_loop();
50246
- import * as fs35 from "node:fs";
50247
- import * as path57 from "node:path";
50068
+ import * as fs34 from "node:fs";
50069
+ import * as path56 from "node:path";
50248
50070
  async function yieldDuringDiskWalk(state) {
50249
50071
  state.entries++;
50250
50072
  if (state.entries % DISK_WALK_YIELD_EVERY !== 0) return true;
@@ -50254,7 +50076,7 @@ async function yieldDuringDiskWalk(state) {
50254
50076
  }
50255
50077
  async function isGitDir(dirPath) {
50256
50078
  try {
50257
- await fs35.promises.access(path57.join(dirPath, ".git"));
50079
+ await fs34.promises.access(path56.join(dirPath, ".git"));
50258
50080
  return true;
50259
50081
  } catch {
50260
50082
  return false;
@@ -50268,23 +50090,23 @@ async function collectGitRepoRootsUnderDirectory(rootPath) {
50268
50090
  const walk = async (dir) => {
50269
50091
  if (!await yieldDuringDiskWalk(state)) return;
50270
50092
  if (await isGitDir(dir)) {
50271
- out.push(path58.resolve(dir));
50093
+ out.push(path57.resolve(dir));
50272
50094
  return;
50273
50095
  }
50274
50096
  let entries;
50275
50097
  try {
50276
- entries = await fs36.promises.readdir(dir, { withFileTypes: true });
50098
+ entries = await fs35.promises.readdir(dir, { withFileTypes: true });
50277
50099
  } catch {
50278
50100
  return;
50279
50101
  }
50280
50102
  for (const e of entries) {
50281
50103
  if (shouldSkipDiskWalkEntry(e.name)) continue;
50282
- const full = path58.join(dir, e.name);
50104
+ const full = path57.join(dir, e.name);
50283
50105
  if (!e.isDirectory()) continue;
50284
50106
  await walk(full);
50285
50107
  }
50286
50108
  };
50287
- await walk(path58.resolve(rootPath));
50109
+ await walk(path57.resolve(rootPath));
50288
50110
  return { paths: [...new Set(out)], entriesVisited: state.entries };
50289
50111
  }
50290
50112
  async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK_MAX_DEPTH) {
@@ -50295,16 +50117,16 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
50295
50117
  if (!await yieldDuringDiskWalk(state)) return;
50296
50118
  let entries;
50297
50119
  try {
50298
- entries = await fs36.promises.readdir(dir, { withFileTypes: true });
50120
+ entries = await fs35.promises.readdir(dir, { withFileTypes: true });
50299
50121
  } catch {
50300
50122
  return;
50301
50123
  }
50302
50124
  for (const e of entries) {
50303
50125
  if (shouldSkipDiskWalkEntry(e.name)) continue;
50304
- const full = path58.join(dir, e.name);
50126
+ const full = path57.join(dir, e.name);
50305
50127
  if (!e.isDirectory()) continue;
50306
50128
  if (e.name === sessionId) {
50307
- if (await isGitDir(full)) out.push(path58.resolve(full));
50129
+ if (await isGitDir(full)) out.push(path57.resolve(full));
50308
50130
  continue;
50309
50131
  }
50310
50132
  if (await isGitDir(full)) continue;
@@ -50316,14 +50138,14 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
50316
50138
  }
50317
50139
 
50318
50140
  // ../bridge/src/worktrees/discovery/layout-keys-for-bridge-root.ts
50319
- import * as path59 from "node:path";
50141
+ import * as path58 from "node:path";
50320
50142
  function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
50321
- const bridge = path59.resolve(bridgeRoot);
50143
+ const bridge = path58.resolve(bridgeRoot);
50322
50144
  const preferred = getLauncherDirNameIfPresent(layout, bridgeRoot);
50323
50145
  const relevant = layout.launcherCwds.filter((e) => {
50324
- const entry = path59.resolve(e.absolutePath);
50325
- return bridge === entry || bridge.startsWith(entry + path59.sep) || entry.startsWith(bridge + path59.sep);
50326
- }).sort((a, b) => path59.resolve(b.absolutePath).length - path59.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
50146
+ const entry = path58.resolve(e.absolutePath);
50147
+ return bridge === entry || bridge.startsWith(entry + path58.sep) || entry.startsWith(bridge + path58.sep);
50148
+ }).sort((a, b) => path58.resolve(b.absolutePath).length - path58.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
50327
50149
  const ordered = [];
50328
50150
  const seen = /* @__PURE__ */ new Set();
50329
50151
  const add = (k) => {
@@ -50341,19 +50163,19 @@ function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
50341
50163
  }
50342
50164
 
50343
50165
  // ../bridge/src/worktrees/discovery/try-binding-from-isolated-directory.ts
50344
- import * as fs37 from "node:fs";
50345
- import * as path60 from "node:path";
50166
+ import * as fs36 from "node:fs";
50167
+ import * as path59 from "node:path";
50346
50168
  async function tryBindingFromIsolatedDirectory(scopeDir) {
50347
50169
  let st;
50348
50170
  try {
50349
- st = await fs37.promises.stat(scopeDir);
50171
+ st = await fs36.promises.stat(scopeDir);
50350
50172
  } catch {
50351
50173
  return null;
50352
50174
  }
50353
50175
  if (!st.isDirectory()) return null;
50354
50176
  const { paths: worktreePaths } = await collectGitRepoRootsUnderDirectory(scopeDir);
50355
50177
  if (worktreePaths.length === 0) return null;
50356
- const abs = path60.resolve(scopeDir);
50178
+ const abs = path59.resolve(scopeDir);
50357
50179
  return {
50358
50180
  parentPath: abs,
50359
50181
  repoCheckoutPaths: worktreePaths
@@ -50376,7 +50198,7 @@ async function discoverSessionWorktreeOnDisk(options) {
50376
50198
  const sid = sessionId.trim();
50377
50199
  if (!sid) return null;
50378
50200
  try {
50379
- await fs38.promises.access(worktreesRootPath);
50201
+ await fs37.promises.access(worktreesRootPath);
50380
50202
  } catch {
50381
50203
  return null;
50382
50204
  }
@@ -50385,13 +50207,13 @@ async function discoverSessionWorktreeOnDisk(options) {
50385
50207
  if (preferredKey) keysOnDisk.push(preferredKey);
50386
50208
  const scanState = { entries: 0 };
50387
50209
  try {
50388
- for (const name of await fs38.promises.readdir(worktreesRootPath)) {
50210
+ for (const name of await fs37.promises.readdir(worktreesRootPath)) {
50389
50211
  if (!await yieldDuringDiskWalk(scanState)) break;
50390
50212
  if (name.startsWith(".")) continue;
50391
- const p = path61.join(worktreesRootPath, name);
50213
+ const p = path60.join(worktreesRootPath, name);
50392
50214
  let st;
50393
50215
  try {
50394
- st = await fs38.promises.stat(p);
50216
+ st = await fs37.promises.stat(p);
50395
50217
  } catch {
50396
50218
  continue;
50397
50219
  }
@@ -50405,23 +50227,23 @@ async function discoverSessionWorktreeOnDisk(options) {
50405
50227
  for (const key of keys) {
50406
50228
  if (isCliImmediateShutdownRequested()) return null;
50407
50229
  await yieldToEventLoop();
50408
- const layoutRoot = path61.join(worktreesRootPath, key);
50230
+ const layoutRoot = path60.join(worktreesRootPath, key);
50409
50231
  let layoutSt;
50410
50232
  try {
50411
- layoutSt = await fs38.promises.stat(layoutRoot);
50233
+ layoutSt = await fs37.promises.stat(layoutRoot);
50412
50234
  } catch {
50413
50235
  continue;
50414
50236
  }
50415
50237
  if (!layoutSt.isDirectory()) continue;
50416
- const sessionDir = path61.join(layoutRoot, sid);
50238
+ const sessionDir = path60.join(layoutRoot, sid);
50417
50239
  const nested = await tryBindingFromSessionDirectory(sessionDir);
50418
50240
  if (nested) return nested;
50419
50241
  const legacy = await collectWorktreeRootsNamed(layoutRoot, sid);
50420
50242
  if (legacy.paths.length > 0) {
50421
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path61.resolve(legacy.paths[0]);
50243
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path60.resolve(legacy.paths[0]);
50422
50244
  return {
50423
- sessionParentPath: path61.resolve(isolated),
50424
- repoCheckoutPaths: legacy.paths.map((p) => path61.resolve(p))
50245
+ sessionParentPath: path60.resolve(isolated),
50246
+ repoCheckoutPaths: legacy.paths.map((p) => path60.resolve(p))
50425
50247
  };
50426
50248
  }
50427
50249
  }
@@ -50429,31 +50251,31 @@ async function discoverSessionWorktreeOnDisk(options) {
50429
50251
  }
50430
50252
 
50431
50253
  // ../bridge/src/worktrees/discovery/discover-session-worktrees-under-session-worktree-root.ts
50432
- import * as fs39 from "node:fs";
50433
- import * as path63 from "node:path";
50254
+ import * as fs38 from "node:fs";
50255
+ import * as path62 from "node:path";
50434
50256
 
50435
50257
  // ../bridge/src/worktrees/discovery/discover-legacy-binding-ascending-from-checkout.ts
50436
50258
  init_cli_process_interrupt();
50437
50259
  init_yield_to_event_loop();
50438
- import * as path62 from "node:path";
50260
+ import * as path61 from "node:path";
50439
50261
  async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPath) {
50440
50262
  const sid = sessionId.trim();
50441
50263
  if (!sid) return null;
50442
- const hintR = path62.resolve(checkoutPath);
50264
+ const hintR = path61.resolve(checkoutPath);
50443
50265
  let best = null;
50444
- let cur = path62.dirname(hintR);
50266
+ let cur = path61.dirname(hintR);
50445
50267
  for (let i = 0; i < 40; i++) {
50446
50268
  if (isCliImmediateShutdownRequested()) return best;
50447
50269
  await yieldToEventLoop();
50448
50270
  const paths = await collectWorktreeRootsNamed(cur, sid);
50449
- if (paths.paths.some((p) => path62.resolve(p) === hintR)) {
50450
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path62.resolve(paths.paths[0]);
50271
+ if (paths.paths.some((p) => path61.resolve(p) === hintR)) {
50272
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path61.resolve(paths.paths[0]);
50451
50273
  best = {
50452
- sessionParentPath: path62.resolve(isolated),
50453
- repoCheckoutPaths: paths.paths.map((p) => path62.resolve(p))
50274
+ sessionParentPath: path61.resolve(isolated),
50275
+ repoCheckoutPaths: paths.paths.map((p) => path61.resolve(p))
50454
50276
  };
50455
50277
  }
50456
- const next = path62.dirname(cur);
50278
+ const next = path61.dirname(cur);
50457
50279
  if (next === cur) break;
50458
50280
  cur = next;
50459
50281
  }
@@ -50464,12 +50286,12 @@ async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPat
50464
50286
  async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPathOrHint, sessionId) {
50465
50287
  const sid = sessionId.trim();
50466
50288
  if (!sid) return null;
50467
- const hint = path63.resolve(sessionParentPathOrHint);
50468
- const underHint = await tryBindingFromSessionDirectory(path63.join(hint, sid));
50289
+ const hint = path62.resolve(sessionParentPathOrHint);
50290
+ const underHint = await tryBindingFromSessionDirectory(path62.join(hint, sid));
50469
50291
  if (underHint) return underHint;
50470
50292
  const direct = await tryBindingFromSessionDirectory(hint);
50471
50293
  if (direct) {
50472
- if (path63.basename(hint) === sid && await isGitDir(hint)) {
50294
+ if (path62.basename(hint) === sid && await isGitDir(hint)) {
50473
50295
  const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
50474
50296
  if (legacyFromCheckout && legacyFromCheckout.repoCheckoutPaths.length > direct.repoCheckoutPaths.length) {
50475
50297
  return legacyFromCheckout;
@@ -50477,23 +50299,23 @@ async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionParentPat
50477
50299
  }
50478
50300
  return direct;
50479
50301
  }
50480
- if (path63.basename(hint) === sid && await isGitDir(hint)) {
50302
+ if (path62.basename(hint) === sid && await isGitDir(hint)) {
50481
50303
  const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
50482
50304
  if (legacyFromCheckout) return legacyFromCheckout;
50483
50305
  }
50484
50306
  let st;
50485
50307
  try {
50486
- st = await fs39.promises.stat(hint);
50308
+ st = await fs38.promises.stat(hint);
50487
50309
  } catch {
50488
50310
  return null;
50489
50311
  }
50490
50312
  if (!st.isDirectory()) return null;
50491
50313
  const legacyPaths = await collectWorktreeRootsNamed(hint, sid);
50492
50314
  if (legacyPaths.paths.length === 0) return null;
50493
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path63.resolve(legacyPaths.paths[0]);
50315
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path62.resolve(legacyPaths.paths[0]);
50494
50316
  return {
50495
- sessionParentPath: path63.resolve(isolated),
50496
- repoCheckoutPaths: legacyPaths.paths.map((p) => path63.resolve(p))
50317
+ sessionParentPath: path62.resolve(isolated),
50318
+ repoCheckoutPaths: legacyPaths.paths.map((p) => path62.resolve(p))
50497
50319
  };
50498
50320
  }
50499
50321
 
@@ -50554,11 +50376,11 @@ function parseSessionParent(v) {
50554
50376
  }
50555
50377
 
50556
50378
  // ../bridge/src/worktrees/prepare/prepare-new-isolated-worktrees.ts
50557
- import * as fs43 from "node:fs";
50379
+ import * as fs42 from "node:fs";
50558
50380
 
50559
50381
  // ../bridge/src/git/discover-repos.ts
50560
- import * as fs40 from "node:fs";
50561
- import * as path64 from "node:path";
50382
+ import * as fs39 from "node:fs";
50383
+ import * as path63 from "node:path";
50562
50384
  init_yield_to_event_loop();
50563
50385
  var GIT_DISCOVER_YIELD_EVERY = 32;
50564
50386
  async function yieldGitDiscoverWork(entryCount) {
@@ -50568,14 +50390,14 @@ async function yieldGitDiscoverWork(entryCount) {
50568
50390
  }
50569
50391
  async function discoverGitRepos(cwd = getBridgeRoot()) {
50570
50392
  const result = [];
50571
- const cwdResolved = path64.resolve(cwd);
50393
+ const cwdResolved = path63.resolve(cwd);
50572
50394
  if (await isGitRepoDirectory(cwdResolved)) {
50573
50395
  const remoteUrl = await getRemoteOriginUrl(cwdResolved);
50574
50396
  result.push({ absolutePath: cwdResolved, remoteUrl });
50575
50397
  }
50576
50398
  let entries;
50577
50399
  try {
50578
- entries = fs40.readdirSync(cwdResolved, { withFileTypes: true });
50400
+ entries = fs39.readdirSync(cwdResolved, { withFileTypes: true });
50579
50401
  } catch {
50580
50402
  return result;
50581
50403
  }
@@ -50583,7 +50405,7 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
50583
50405
  await yieldGitDiscoverWork(i + 1);
50584
50406
  const ent = entries[i];
50585
50407
  if (!ent.isDirectory()) continue;
50586
- const childPath2 = path64.join(cwdResolved, ent.name);
50408
+ const childPath2 = path63.join(cwdResolved, ent.name);
50587
50409
  if (await isGitRepoDirectory(childPath2)) {
50588
50410
  const remoteUrl = await getRemoteOriginUrl(childPath2);
50589
50411
  result.push({ absolutePath: childPath2, remoteUrl });
@@ -50592,17 +50414,17 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
50592
50414
  return result;
50593
50415
  }
50594
50416
  async function discoverGitReposUnderRoot(rootPath) {
50595
- const root = path64.resolve(rootPath);
50417
+ const root = path63.resolve(rootPath);
50596
50418
  const roots = [];
50597
50419
  let walkEntries = 0;
50598
50420
  async function walk(dir) {
50599
50421
  if (await isGitRepoDirectory(dir)) {
50600
- roots.push(path64.resolve(dir));
50422
+ roots.push(path63.resolve(dir));
50601
50423
  return;
50602
50424
  }
50603
50425
  let entries;
50604
50426
  try {
50605
- entries = fs40.readdirSync(dir, { withFileTypes: true });
50427
+ entries = fs39.readdirSync(dir, { withFileTypes: true });
50606
50428
  } catch {
50607
50429
  return;
50608
50430
  }
@@ -50610,7 +50432,7 @@ async function discoverGitReposUnderRoot(rootPath) {
50610
50432
  await yieldGitDiscoverWork(++walkEntries);
50611
50433
  const ent = entries[i];
50612
50434
  if (!ent.isDirectory() || ent.name === ".git") continue;
50613
- await walk(path64.join(dir, ent.name));
50435
+ await walk(path63.join(dir, ent.name));
50614
50436
  }
50615
50437
  }
50616
50438
  await walk(root);
@@ -50626,8 +50448,8 @@ async function discoverGitReposUnderRoot(rootPath) {
50626
50448
  }
50627
50449
 
50628
50450
  // ../bridge/src/worktrees/prepare/add-isolated-repo-worktree.ts
50629
- import * as fs42 from "node:fs";
50630
- import * as path66 from "node:path";
50451
+ import * as fs41 from "node:fs";
50452
+ import * as path65 from "node:path";
50631
50453
 
50632
50454
  // ../bridge/src/git/worktrees/worktree-add.ts
50633
50455
  async function gitWorktreeAddBranch(mainRepoPath, worktreePath, branch, baseRef = "HEAD") {
@@ -50643,8 +50465,8 @@ async function gitWorktreeAddExistingBranch(mainRepoPath, worktreePath, branch)
50643
50465
  }
50644
50466
 
50645
50467
  // ../bridge/src/worktrees/prepare/copy-bridge-files-along-worktree-path.ts
50646
- import * as fs41 from "node:fs";
50647
- import * as path65 from "node:path";
50468
+ import * as fs40 from "node:fs";
50469
+ import * as path64 from "node:path";
50648
50470
  var BRIDGE_FILES_ALONG_WORKTREE_PATH = ["AGENTS.md"];
50649
50471
  function copyBridgeFilesAlongWorktreePath(options) {
50650
50472
  const { bridgeRoot, scopeDir, repoPathRelativeToBridgeRoot, log: log2 } = options;
@@ -50653,19 +50475,19 @@ function copyBridgeFilesAlongWorktreePath(options) {
50653
50475
  const segments = repoPathRelativeToBridgeRoot.split("/").filter(Boolean);
50654
50476
  for (let i = 0; i < segments.length; i++) {
50655
50477
  const prefix = segments.slice(0, i).join("/");
50656
- const bridgeDir = prefix ? path65.join(bridgeRoot, prefix) : bridgeRoot;
50657
- const destDir = prefix ? path65.join(scopeDir, prefix) : scopeDir;
50478
+ const bridgeDir = prefix ? path64.join(bridgeRoot, prefix) : bridgeRoot;
50479
+ const destDir = prefix ? path64.join(scopeDir, prefix) : scopeDir;
50658
50480
  for (const fileName of fileNames) {
50659
50481
  copyFileIfPresent(bridgeDir, destDir, fileName, log2);
50660
50482
  }
50661
50483
  }
50662
50484
  }
50663
50485
  function copyFileIfPresent(srcDir, destDir, fileName, log2) {
50664
- const src = path65.join(srcDir, fileName);
50665
- if (!fs41.existsSync(src)) return;
50666
- const dest = path65.join(destDir, fileName);
50486
+ const src = path64.join(srcDir, fileName);
50487
+ if (!fs40.existsSync(src)) return;
50488
+ const dest = path64.join(destDir, fileName);
50667
50489
  try {
50668
- fs41.copyFileSync(src, dest);
50490
+ fs40.copyFileSync(src, dest);
50669
50491
  log2?.(`[worktrees] Copied ${fileName} to ${dest}`);
50670
50492
  } catch (e) {
50671
50493
  log2?.(
@@ -50697,16 +50519,16 @@ async function addIsolatedRepoWorktree(options) {
50697
50519
  worktreeBaseBranches,
50698
50520
  log: log2
50699
50521
  } = options;
50700
- const repoPathRelativeToBridgeRootRaw = path66.relative(bridgeResolved, repoAbsolutePath);
50701
- if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path66.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
50522
+ const repoPathRelativeToBridgeRootRaw = path65.relative(bridgeResolved, repoAbsolutePath);
50523
+ if (repoPathRelativeToBridgeRootRaw.startsWith("..") || path65.isAbsolute(repoPathRelativeToBridgeRootRaw)) {
50702
50524
  return null;
50703
50525
  }
50704
50526
  const repoPathRelativeToBridgeRoot = normalizeRepoPathRelativeToWorkspaceRoot(
50705
50527
  repoPathRelativeToBridgeRootRaw === "" ? "." : repoPathRelativeToBridgeRootRaw
50706
50528
  );
50707
- const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path66.join(scopeDir, repoPathRelativeToBridgeRoot);
50529
+ const worktreePath = repoPathRelativeToBridgeRoot === "." ? scopeDir : path65.join(scopeDir, repoPathRelativeToBridgeRoot);
50708
50530
  if (repoPathRelativeToBridgeRoot !== ".") {
50709
- fs42.mkdirSync(path66.dirname(worktreePath), { recursive: true });
50531
+ fs41.mkdirSync(path65.dirname(worktreePath), { recursive: true });
50710
50532
  copyBridgeFilesAlongWorktreePath({
50711
50533
  bridgeRoot: bridgeResolved,
50712
50534
  scopeDir,
@@ -50734,7 +50556,7 @@ async function addIsolatedRepoWorktree(options) {
50734
50556
  }
50735
50557
 
50736
50558
  // ../bridge/src/worktrees/prepare/resolve-isolated-scope-dir.ts
50737
- import * as path67 from "node:path";
50559
+ import * as path66 from "node:path";
50738
50560
 
50739
50561
  // ../bridge/src/worktrees/worktree-layout-kind.ts
50740
50562
  function sanitizeWorktreeBranchSegment(value) {
@@ -50764,10 +50586,10 @@ function previewDeployBranchName(environmentId) {
50764
50586
 
50765
50587
  // ../bridge/src/worktrees/prepare/resolve-isolated-scope-dir.ts
50766
50588
  function resolveIsolatedScopeDir(options) {
50767
- const bridgeResolved = path67.resolve(options.bridgeRoot);
50589
+ const bridgeResolved = path66.resolve(options.bridgeRoot);
50768
50590
  const cwdKey = allocateDirNameForLauncherCwd(options.layout, bridgeResolved);
50769
- const bridgeKeyDir = path67.join(options.worktreesRootPath, cwdKey);
50770
- const scopeDir = path67.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
50591
+ const bridgeKeyDir = path66.join(options.worktreesRootPath, cwdKey);
50592
+ const scopeDir = path66.join(bridgeKeyDir, ...layoutDirSegments(options.kind, options.scopeId));
50771
50593
  return { bridgeResolved, scopeDir };
50772
50594
  }
50773
50595
 
@@ -50797,7 +50619,7 @@ async function prepareNewIsolatedWorktrees(options) {
50797
50619
  return null;
50798
50620
  }
50799
50621
  const worktreePaths = [];
50800
- fs43.mkdirSync(scopeDir, { recursive: true });
50622
+ fs42.mkdirSync(scopeDir, { recursive: true });
50801
50623
  await forEachWithGitYield(repos, async (repo) => {
50802
50624
  const worktreePath = await addIsolatedRepoWorktree({
50803
50625
  kind,
@@ -50869,10 +50691,10 @@ async function resolveExistingSessionParentPath(sessionId, cache2, discover) {
50869
50691
  }
50870
50692
 
50871
50693
  // ../bridge/src/worktrees/manager/resolve-explicit-session-parent-path.ts
50872
- import * as path68 from "node:path";
50694
+ import * as path67 from "node:path";
50873
50695
  init_yield_to_event_loop();
50874
50696
  async function resolveExplicitSessionParentPath(params) {
50875
- const resolved = path68.resolve(params.parentPathRaw);
50697
+ const resolved = path67.resolve(params.parentPathRaw);
50876
50698
  if (parseSessionParent(params.sessionParent) !== "worktrees_root") {
50877
50699
  return resolved;
50878
50700
  }
@@ -50889,7 +50711,7 @@ async function resolveExplicitSessionParentPath(params) {
50889
50711
  await yieldToEventLoop();
50890
50712
  const tryRoot = await discoverSessionWorktreesUnderSessionWorktreeRoot(cur, params.sessionId);
50891
50713
  if (tryRoot) return rememberAndReturn(tryRoot);
50892
- const next = path68.dirname(cur);
50714
+ const next = path67.dirname(cur);
50893
50715
  if (next === cur) break;
50894
50716
  cur = next;
50895
50717
  }
@@ -51050,15 +50872,15 @@ var SessionWorktreeManager = class {
51050
50872
  };
51051
50873
 
51052
50874
  // ../bridge/src/worktrees/discovery/discover-preview-worktree-on-disk.ts
51053
- import * as fs44 from "node:fs";
51054
- import * as path69 from "node:path";
50875
+ import * as fs43 from "node:fs";
50876
+ import * as path68 from "node:path";
51055
50877
  init_yield_to_event_loop();
51056
50878
  async function discoverPreviewWorktreeOnDisk(options) {
51057
50879
  const { environmentId, worktreesRootPath, layout, bridgeRoot } = options;
51058
50880
  const eid = environmentId.trim();
51059
50881
  if (!eid) return null;
51060
50882
  try {
51061
- await fs44.promises.access(worktreesRootPath);
50883
+ await fs43.promises.access(worktreesRootPath);
51062
50884
  } catch {
51063
50885
  return null;
51064
50886
  }
@@ -51067,13 +50889,13 @@ async function discoverPreviewWorktreeOnDisk(options) {
51067
50889
  if (preferredKey) keysOnDisk.push(preferredKey);
51068
50890
  const scanState = { entries: 0 };
51069
50891
  try {
51070
- for (const name of await fs44.promises.readdir(worktreesRootPath)) {
50892
+ for (const name of await fs43.promises.readdir(worktreesRootPath)) {
51071
50893
  if (!await yieldDuringDiskWalk(scanState)) break;
51072
50894
  if (name.startsWith(".")) continue;
51073
- const p = path69.join(worktreesRootPath, name);
50895
+ const p = path68.join(worktreesRootPath, name);
51074
50896
  let st;
51075
50897
  try {
51076
- st = await fs44.promises.stat(p);
50898
+ st = await fs43.promises.stat(p);
51077
50899
  } catch {
51078
50900
  continue;
51079
50901
  }
@@ -51087,7 +50909,7 @@ async function discoverPreviewWorktreeOnDisk(options) {
51087
50909
  const previewDirRel = layoutDirSegments("preview_environment", eid);
51088
50910
  for (const key of keys) {
51089
50911
  await yieldToEventLoop();
51090
- const previewDir = path69.join(worktreesRootPath, key, ...previewDirRel);
50912
+ const previewDir = path68.join(worktreesRootPath, key, ...previewDirRel);
51091
50913
  const binding = await tryBindingFromIsolatedDirectory(previewDir);
51092
50914
  if (binding) return binding;
51093
50915
  }
@@ -51214,7 +51036,7 @@ var PreviewWorktreeManager = class {
51214
51036
  };
51215
51037
 
51216
51038
  // ../bridge/src/worktrees/deploy/deploy-session-to-preview-environment.ts
51217
- import * as path73 from "node:path";
51039
+ import * as path72 from "node:path";
51218
51040
 
51219
51041
  // ../bridge/src/git/worktrees/reset-worktree-to-branch.ts
51220
51042
  async function gitResetWorktreeToBranch(worktreePath, branch) {
@@ -51225,8 +51047,8 @@ async function gitResetWorktreeToBranch(worktreePath, branch) {
51225
51047
  }
51226
51048
 
51227
51049
  // ../bridge/src/worktrees/deploy/capture-and-apply-wip.ts
51228
- import * as fs45 from "node:fs";
51229
- import * as path70 from "node:path";
51050
+ import * as fs44 from "node:fs";
51051
+ import * as path69 from "node:path";
51230
51052
 
51231
51053
  // ../bridge/src/git/is-not-a-git-repository-error.ts
51232
51054
  function isNotAGitRepositoryError(e) {
@@ -51288,12 +51110,12 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
51288
51110
  if (!ap.ok) return ap;
51289
51111
  }
51290
51112
  await forEachWithGitYield(wip.untrackedPaths, async (rel) => {
51291
- const src = path70.join(sourceRepoPath, rel);
51292
- const dst = path70.join(targetRepoPath, rel);
51113
+ const src = path69.join(sourceRepoPath, rel);
51114
+ const dst = path69.join(targetRepoPath, rel);
51293
51115
  try {
51294
- if (!fs45.existsSync(src)) return;
51295
- fs45.mkdirSync(path70.dirname(dst), { recursive: true });
51296
- fs45.copyFileSync(src, dst);
51116
+ if (!fs44.existsSync(src)) return;
51117
+ fs44.mkdirSync(path69.dirname(dst), { recursive: true });
51118
+ fs44.copyFileSync(src, dst);
51297
51119
  } catch (e) {
51298
51120
  log2(
51299
51121
  `[worktrees] Failed to copy untracked ${rel}: ${e instanceof Error ? e.message : String(e)}`
@@ -51304,14 +51126,14 @@ async function applyWorkingTreeWip(targetRepoPath, sourceRepoPath, wip, log2) {
51304
51126
  }
51305
51127
 
51306
51128
  // ../bridge/src/worktrees/deploy/resolve-isolated-checkout-for-repo-path-relative-to-workspace-root.ts
51307
- import * as path71 from "node:path";
51129
+ import * as path70 from "node:path";
51308
51130
  async function resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot(options) {
51309
51131
  const { checkoutPaths, sessionParentPath, bridgeRoot, repoPathRelativeToWorkspaceRoot } = options;
51310
- const resolvedSessionParentPath = sessionParentPath ? path71.resolve(sessionParentPath) : null;
51132
+ const resolvedSessionParentPath = sessionParentPath ? path70.resolve(sessionParentPath) : null;
51311
51133
  let match = null;
51312
51134
  await forEachWithGitYield(checkoutPaths, async (checkoutPath) => {
51313
51135
  if (match) return;
51314
- const resolvedCheckoutPath = path71.resolve(checkoutPath);
51136
+ const resolvedCheckoutPath = path70.resolve(checkoutPath);
51315
51137
  if (!await isGitRepoDirectory(resolvedCheckoutPath)) return;
51316
51138
  const resolvedRepoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
51317
51139
  checkoutPath: resolvedCheckoutPath,
@@ -51365,7 +51187,7 @@ async function applySessionWipToPreviewCheckouts(options) {
51365
51187
  }
51366
51188
 
51367
51189
  // ../bridge/src/worktrees/deploy/collect-session-repo-deploy-states.ts
51368
- import * as path72 from "node:path";
51190
+ import * as path71 from "node:path";
51369
51191
 
51370
51192
  // ../bridge/src/git/branches/create-or-update-branch.ts
51371
51193
  async function gitCreateOrUpdateBranch(repoPath, branch, startRef, options) {
@@ -51402,19 +51224,19 @@ async function collectSessionRepoDeployStates(options) {
51402
51224
  const sessionParentPath = sessionWorktreeManager.getSessionParentPath(sid);
51403
51225
  const states = [];
51404
51226
  await forEachWithGitYield(sessionTargets, async (sessionCheckout) => {
51405
- const checkoutPath = path72.resolve(sessionCheckout);
51227
+ const checkoutPath = path71.resolve(sessionCheckout);
51406
51228
  if (!await isGitRepoDirectory(checkoutPath)) return;
51407
51229
  const repoPathRelativeToWorkspaceRoot = await resolveRepoPathRelativeToWorkspaceRoot({
51408
51230
  checkoutPath,
51409
51231
  bridgeRoot,
51410
- sessionParentPath: sessionParentPath ? path72.resolve(sessionParentPath) : null
51232
+ sessionParentPath: sessionParentPath ? path71.resolve(sessionParentPath) : null
51411
51233
  });
51412
51234
  if (!repoPathRelativeToWorkspaceRoot) return;
51413
51235
  const mainRepoPath = resolveMainRepoPath(checkoutPath);
51414
51236
  const headSha = (await cliSimpleGit(checkoutPath).revparse(["HEAD"])).trim();
51415
51237
  const previewCheckout = previewCheckoutPaths.length > 0 ? await resolveIsolatedCheckoutForRepoPathRelativeToWorkspaceRoot({
51416
51238
  checkoutPaths: previewCheckoutPaths,
51417
- sessionParentPath: previewParentPath ? path72.resolve(previewParentPath) : null,
51239
+ sessionParentPath: previewParentPath ? path71.resolve(previewParentPath) : null,
51418
51240
  bridgeRoot,
51419
51241
  repoPathRelativeToWorkspaceRoot
51420
51242
  }) : null;
@@ -51434,7 +51256,7 @@ async function deploySessionToPreviewEnvironment(options) {
51434
51256
  const eid = options.environmentId.trim();
51435
51257
  if (!sid || !eid) return { ok: false, error: "sessionId and environmentId are required" };
51436
51258
  const deployBranch = previewDeployBranchName(eid);
51437
- const bridgeRoot = path73.resolve(getBridgeRoot());
51259
+ const bridgeRoot = path72.resolve(getBridgeRoot());
51438
51260
  await previewWorktreeManager.ensureCached(eid);
51439
51261
  const existingPreviewParentPath = previewWorktreeManager.getPreviewParentPath(eid) ?? null;
51440
51262
  const existingPreviewCheckoutPaths = previewWorktreeManager.getRepoCheckoutPaths(eid) ?? [];
@@ -51474,13 +51296,13 @@ async function deploySessionToPreviewEnvironment(options) {
51474
51296
  }
51475
51297
 
51476
51298
  // ../bridge/src/worktrees/manager/default-worktrees-root-path.ts
51477
- import * as path74 from "node:path";
51299
+ import * as path73 from "node:path";
51478
51300
  import os8 from "node:os";
51479
51301
  function defaultWorktreesRootPath() {
51480
- return path74.join(os8.homedir(), ".buildautomaton", "worktrees");
51302
+ return path73.join(os8.homedir(), ".buildautomaton", "worktrees");
51481
51303
  }
51482
51304
 
51483
- // ../bridge/src/connection/create-bridge-worktree-managers.ts
51305
+ // ../bridge/src/connection/setup/create-bridge-worktree-managers.ts
51484
51306
  function createBridgeWorktreeManagers(options) {
51485
51307
  const worktreesRootPath = options.worktreesRootPath ?? defaultWorktreesRootPath();
51486
51308
  return {
@@ -51602,14 +51424,14 @@ function assertBridgeWorkspace(ctx) {
51602
51424
  }
51603
51425
 
51604
51426
  // ../bridge/src/files/list-dir/index.ts
51605
- import fs47 from "node:fs";
51427
+ import fs46 from "node:fs";
51606
51428
 
51607
51429
  // ../bridge/src/files/ensure-under-cwd.ts
51608
- import path75 from "node:path";
51430
+ import path74 from "node:path";
51609
51431
  function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
51610
- const normalized = path75.normalize(relativePath).replace(/^(\.\/)+/, "");
51611
- const resolved = path75.resolve(cwd, normalized);
51612
- if (!resolved.startsWith(cwd + path75.sep) && resolved !== cwd) {
51432
+ const normalized = path74.normalize(relativePath).replace(/^(\.\/)+/, "");
51433
+ const resolved = path74.resolve(cwd, normalized);
51434
+ if (!resolved.startsWith(cwd + path74.sep) && resolved !== cwd) {
51613
51435
  return null;
51614
51436
  }
51615
51437
  return resolved;
@@ -51622,15 +51444,15 @@ init_yield_to_event_loop();
51622
51444
  var LIST_DIR_YIELD_EVERY = 256;
51623
51445
 
51624
51446
  // ../bridge/src/files/list-dir/map-dir-entry.ts
51625
- import path76 from "node:path";
51626
- import fs46 from "node:fs";
51447
+ import path75 from "node:path";
51448
+ import fs45 from "node:fs";
51627
51449
  async function mapDirEntry(d, relativePath, resolved) {
51628
- const entryPath = path76.join(relativePath || ".", d.name).replace(/\\/g, "/");
51629
- const fullPath = path76.join(resolved, d.name);
51450
+ const entryPath = path75.join(relativePath || ".", d.name).replace(/\\/g, "/");
51451
+ const fullPath = path75.join(resolved, d.name);
51630
51452
  let isDir = d.isDirectory();
51631
51453
  if (d.isSymbolicLink()) {
51632
51454
  try {
51633
- const targetStat = await fs46.promises.stat(fullPath);
51455
+ const targetStat = await fs45.promises.stat(fullPath);
51634
51456
  isDir = targetStat.isDirectory();
51635
51457
  } catch {
51636
51458
  isDir = false;
@@ -51660,7 +51482,7 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
51660
51482
  return { error: "Path is outside working directory" };
51661
51483
  }
51662
51484
  try {
51663
- const names = await fs47.promises.readdir(resolved, { withFileTypes: true });
51485
+ const names = await fs46.promises.readdir(resolved, { withFileTypes: true });
51664
51486
  const entries = [];
51665
51487
  for (let i = 0; i < names.length; i++) {
51666
51488
  if (i > 0 && i % LIST_DIR_YIELD_EVERY === 0) {
@@ -51676,13 +51498,13 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
51676
51498
  }
51677
51499
 
51678
51500
  // ../bridge/src/git/tree/resolve-repo-abs-path.ts
51679
- import * as path77 from "node:path";
51501
+ import * as path76 from "node:path";
51680
51502
  function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
51681
- const bridgeResolved = path77.resolve(bridgeRoot);
51503
+ const bridgeResolved = path76.resolve(bridgeRoot);
51682
51504
  const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
51683
- const repoPath = rel === "" ? bridgeResolved : path77.join(bridgeResolved, rel);
51684
- const resolved = path77.resolve(repoPath);
51685
- if (!resolved.startsWith(bridgeResolved + path77.sep) && resolved !== bridgeResolved) {
51505
+ const repoPath = rel === "" ? bridgeResolved : path76.join(bridgeResolved, rel);
51506
+ const resolved = path76.resolve(repoPath);
51507
+ if (!resolved.startsWith(bridgeResolved + path76.sep) && resolved !== bridgeResolved) {
51686
51508
  return null;
51687
51509
  }
51688
51510
  return resolved;
@@ -52163,25 +51985,25 @@ async function GET2(ctx) {
52163
51985
  init_in_flight();
52164
51986
 
52165
51987
  // ../bridge/src/files/read/read-file-async.ts
52166
- import fs53 from "node:fs";
51988
+ import fs52 from "node:fs";
52167
51989
  init_yield_to_event_loop();
52168
51990
 
52169
51991
  // ../bridge/src/files/read/resolve-file-cache.ts
52170
- import fs48 from "node:fs";
52171
- import path78 from "node:path";
51992
+ import fs47 from "node:fs";
51993
+ import path77 from "node:path";
52172
51994
  var RESOLVE_CACHE_MAX = 4096;
52173
51995
  var resolveCache = /* @__PURE__ */ new Map();
52174
51996
  function resolveCacheKey(sessionParentPath, relativePath) {
52175
51997
  return `${sessionParentPath}\0${relativePath}`;
52176
51998
  }
52177
51999
  function pathStaysUnderParent(filePath, sessionParentPath) {
52178
- const parent = path78.resolve(sessionParentPath);
52179
- const resolved = path78.resolve(filePath);
52180
- return resolved === parent || resolved.startsWith(`${parent}${path78.sep}`);
52000
+ const parent = path77.resolve(sessionParentPath);
52001
+ const resolved = path77.resolve(filePath);
52002
+ return resolved === parent || resolved.startsWith(`${parent}${path77.sep}`);
52181
52003
  }
52182
52004
  function statMatchesCacheSync(entry) {
52183
52005
  try {
52184
- const stat3 = fs48.statSync(entry.path);
52006
+ const stat3 = fs47.statSync(entry.path);
52185
52007
  return stat3.isFile() && stat3.mtimeMs === entry.mtimeMs && stat3.size === entry.size;
52186
52008
  } catch {
52187
52009
  return false;
@@ -52214,7 +52036,7 @@ function joinInflightResolve(cacheKey, factory) {
52214
52036
  }
52215
52037
 
52216
52038
  // ../bridge/src/files/read/resolve-file-for-read-core.ts
52217
- import fs49 from "node:fs";
52039
+ import fs48 from "node:fs";
52218
52040
  import { isMainThread as isMainThread4 } from "node:worker_threads";
52219
52041
  function resolveFileForReadImplSync(relativePath, sessionParentPath) {
52220
52042
  const cacheKey = resolveCacheKey(sessionParentPath, relativePath);
@@ -52224,13 +52046,13 @@ function resolveFileForReadImplSync(relativePath, sessionParentPath) {
52224
52046
  let size;
52225
52047
  let mtimeMs;
52226
52048
  try {
52227
- const lstat = fs49.lstatSync(resolved);
52049
+ const lstat = fs48.lstatSync(resolved);
52228
52050
  if (lstat.isSymbolicLink()) {
52229
- real = fs49.realpathSync(resolved);
52051
+ real = fs48.realpathSync(resolved);
52230
52052
  if (!pathStaysUnderParent(real, sessionParentPath)) {
52231
52053
  return { error: "Path is outside working directory" };
52232
52054
  }
52233
- const stat3 = fs49.statSync(real);
52055
+ const stat3 = fs48.statSync(real);
52234
52056
  if (!stat3.isFile()) return { error: "Not a file" };
52235
52057
  size = stat3.size;
52236
52058
  mtimeMs = stat3.mtimeMs;
@@ -52258,13 +52080,13 @@ async function resolveFileForReadImpl(relativePath, sessionParentPath) {
52258
52080
  let size;
52259
52081
  let mtimeMs;
52260
52082
  try {
52261
- const lstat = await fs49.promises.lstat(resolved);
52083
+ const lstat = await fs48.promises.lstat(resolved);
52262
52084
  if (lstat.isSymbolicLink()) {
52263
- real = await fs49.promises.realpath(resolved);
52085
+ real = await fs48.promises.realpath(resolved);
52264
52086
  if (!pathStaysUnderParent(real, sessionParentPath)) {
52265
52087
  return { error: "Path is outside working directory" };
52266
52088
  }
52267
- const stat3 = await fs49.promises.stat(real);
52089
+ const stat3 = await fs48.promises.stat(real);
52268
52090
  if (!stat3.isFile()) return { error: "Not a file" };
52269
52091
  size = stat3.size;
52270
52092
  mtimeMs = stat3.mtimeMs;
@@ -52313,7 +52135,7 @@ async function resolveFilePathAsync(relativePath, sessionParentPath = getBridgeR
52313
52135
 
52314
52136
  // ../bridge/src/files/read/read-file-range-async.ts
52315
52137
  init_yield_to_event_loop();
52316
- import fs50 from "node:fs";
52138
+ import fs49 from "node:fs";
52317
52139
  import { StringDecoder as StringDecoder2 } from "node:string_decoder";
52318
52140
 
52319
52141
  // ../bridge/src/files/read/read-file-range-line-zero.ts
@@ -52427,8 +52249,8 @@ function finishLineZeroTail(state, tail, resultLines, fileSize, lineChunkSize, l
52427
52249
 
52428
52250
  // ../bridge/src/files/read/read-file-range-async.ts
52429
52251
  async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE, fileSizeIn) {
52430
- const fileSize = fileSizeIn ?? (await fs50.promises.stat(filePath)).size;
52431
- const fd = await fs50.promises.open(filePath, "r");
52252
+ const fileSize = fileSizeIn ?? (await fs49.promises.stat(filePath)).size;
52253
+ const fd = await fs49.promises.open(filePath, "r");
52432
52254
  const bufSize = 64 * 1024;
52433
52255
  const buf = Buffer.alloc(bufSize);
52434
52256
  const decoder = new StringDecoder2("utf8");
@@ -52529,7 +52351,7 @@ async function readFileRangeAsync(filePath, startLine, endLine, lineOffsetIn, li
52529
52351
  }
52530
52352
 
52531
52353
  // ../bridge/src/files/read/read-small-file-range-async.ts
52532
- import fs51 from "node:fs";
52354
+ import fs50 from "node:fs";
52533
52355
  import { isMainThread as isMainThread5 } from "node:worker_threads";
52534
52356
  var SMALL_FILE_RANGE_MAX_BYTES = 512 * 1024;
52535
52357
  function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize) {
@@ -52559,7 +52381,7 @@ function sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize,
52559
52381
  };
52560
52382
  }
52561
52383
  function readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize = LINE_CHUNK_SIZE) {
52562
- const raw = fs51.readFileSync(filePath, "utf8");
52384
+ const raw = fs50.readFileSync(filePath, "utf8");
52563
52385
  const lines = raw.split(/\r?\n/);
52564
52386
  return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
52565
52387
  }
@@ -52567,28 +52389,28 @@ async function readSmallFileRangeAsync(filePath, fileSize, startLine, endLine, l
52567
52389
  if (isMainThread5) {
52568
52390
  return readSmallFileRangeSync(filePath, fileSize, startLine, endLine, lineOffsetIn, lineChunkSize);
52569
52391
  }
52570
- const raw = await fs51.promises.readFile(filePath, "utf8");
52392
+ const raw = await fs50.promises.readFile(filePath, "utf8");
52571
52393
  const lines = raw.split(/\r?\n/);
52572
52394
  return sliceLineRange(lines, startLine, endLine, lineOffsetIn, lineChunkSize, fileSize);
52573
52395
  }
52574
52396
 
52575
52397
  // ../bridge/src/files/read/read-file-buffer-full-async.ts
52576
52398
  init_yield_to_event_loop();
52577
- import fs52 from "node:fs";
52399
+ import fs51 from "node:fs";
52578
52400
  import { isMainThread as isMainThread6 } from "node:worker_threads";
52579
52401
  var READ_CHUNK_BYTES = 256 * 1024;
52580
52402
  var MAIN_THREAD_SYNC_READ_MAX_BYTES = 512 * 1024;
52581
52403
  async function readFileBufferFullAsync(filePath, knownSize) {
52582
52404
  if (isMainThread6) {
52583
- const size2 = knownSize ?? fs52.statSync(filePath).size;
52405
+ const size2 = knownSize ?? fs51.statSync(filePath).size;
52584
52406
  if (size2 <= MAIN_THREAD_SYNC_READ_MAX_BYTES) {
52585
52407
  await yieldToEventLoop();
52586
- const buffer = fs52.readFileSync(filePath);
52408
+ const buffer = fs51.readFileSync(filePath);
52587
52409
  return { buffer, size: buffer.length };
52588
52410
  }
52589
52411
  }
52590
- const size = knownSize ?? (await fs52.promises.stat(filePath)).size;
52591
- const fd = await fs52.promises.open(filePath, "r");
52412
+ const size = knownSize ?? (await fs51.promises.stat(filePath)).size;
52413
+ const fd = await fs51.promises.open(filePath, "r");
52592
52414
  const chunks = [];
52593
52415
  let position = 0;
52594
52416
  let bytesSinceYield = 0;
@@ -52691,7 +52513,7 @@ async function readFileAsync(relativePath, startLine, endLine, lineOffset, lineC
52691
52513
  }
52692
52514
  if (hasRange) {
52693
52515
  if (fileSize == null) {
52694
- const stat3 = await fs53.promises.stat(resolvedPath);
52516
+ const stat3 = await fs52.promises.stat(resolvedPath);
52695
52517
  fileSize = stat3.size;
52696
52518
  }
52697
52519
  const read2 = fileSize <= SMALL_FILE_RANGE_MAX_BYTES ? await readSmallFileRangeAsync(
@@ -52989,12 +52811,12 @@ function parseOptionalInt2(raw) {
52989
52811
  return Number.isInteger(parsed) ? parsed : void 0;
52990
52812
  }
52991
52813
  function parseCodeNavParams(url2) {
52992
- const path91 = url2.searchParams.get("path") ?? "";
52814
+ const path88 = url2.searchParams.get("path") ?? "";
52993
52815
  const opRaw = url2.searchParams.get("op")?.trim();
52994
52816
  const op = opRaw === "references" ? "references" : opRaw === "symbols" ? "symbols" : opRaw === "definitions" ? "definitions" : "definition";
52995
52817
  const line = parseOptionalInt2(url2.searchParams.get("line")) ?? 1;
52996
52818
  const column = parseOptionalInt2(url2.searchParams.get("column")) ?? 0;
52997
- return { path: path91, op, line, column };
52819
+ return { path: path88, op, line, column };
52998
52820
  }
52999
52821
  function parseCodeNavPath(url2) {
53000
52822
  const raw = url2.searchParams.get("path")?.trim();
@@ -53251,7 +53073,7 @@ async function createLocalShortcut(params) {
53251
53073
  };
53252
53074
  }
53253
53075
 
53254
- // ../bridge/src/connection/create-bridge-connection-runtime.ts
53076
+ // ../bridge/src/connection/runtime/create-bridge-connection-runtime.ts
53255
53077
  async function createBridgeConnectionRuntime(options, params) {
53256
53078
  const { plugin, workspaceId } = options;
53257
53079
  const { state, getWs, logFn } = params;
@@ -53596,7 +53418,7 @@ function logDuplicateBridgeWarning(log2, result) {
53596
53418
  }
53597
53419
  }
53598
53420
 
53599
- // ../bridge/src/connection/create-main-bridge-reconnect-state.ts
53421
+ // ../bridge/src/connection/reconnect/create-main-bridge-reconnect-state.ts
53600
53422
  function createMainBridgeReconnectState() {
53601
53423
  const state = {
53602
53424
  closedByUser: false,
@@ -53615,7 +53437,7 @@ function createMainBridgeReconnectState() {
53615
53437
  };
53616
53438
  }
53617
53439
 
53618
- // ../bridge/src/connection/ensure-bridge-connection-databases.ts
53440
+ // ../bridge/src/connection/runtime/ensure-bridge-connection-databases.ts
53619
53441
  init_cli_database();
53620
53442
  init_code_nav_cache_availability();
53621
53443
  async function ensureBridgeConnectionDatabases(log2) {
@@ -53623,7 +53445,7 @@ async function ensureBridgeConnectionDatabases(log2) {
53623
53445
  void startCodeNavCacheInitialization(log2);
53624
53446
  }
53625
53447
 
53626
- // ../bridge/src/types/api-to-bridge-messages.ts
53448
+ // ../bridge/src/connection/protocol/api-to-bridge-messages.ts
53627
53449
  var API_TO_BRIDGE_MESSAGE_TYPES = [
53628
53450
  "auth_token",
53629
53451
  "bridge_identified",
@@ -53641,14 +53463,10 @@ var API_TO_BRIDGE_MESSAGE_TYPES = [
53641
53463
  "session_discarded",
53642
53464
  "revert_turn_snapshot",
53643
53465
  "cursor_request_response",
53644
- "skill_call",
53645
53466
  "file_browser_request",
53646
53467
  "file_browser_search",
53647
53468
  "code_nav",
53648
- "skill_layout_request",
53649
- "install_skills",
53650
53469
  "install_agent",
53651
- "refresh_local_skills",
53652
53470
  "bridge_git_context_request",
53653
53471
  "list_repo_branches_request",
53654
53472
  "bridge_git_checkout_request"
@@ -53670,15 +53488,14 @@ function parseApiToBridgeMessage(data, log2) {
53670
53488
  return data;
53671
53489
  }
53672
53490
 
53673
- // ../bridge/src/routing/handlers/auth-token.ts
53491
+ // ../bridge/src/connection/routing/handlers/auth-token.ts
53674
53492
  var handleAuthToken = (msg, { log: log2 }) => {
53675
53493
  if (typeof msg.token !== "string") return;
53676
53494
  log2("Received auth token. Save it for future runs:");
53677
53495
  log2(` export BUILDAUTOMATON_AUTH_TOKEN="${msg.token}"`);
53678
53496
  };
53679
53497
 
53680
- // ../bridge/src/routing/handlers/bridge-identified.ts
53681
- init_cli_process_interrupt();
53498
+ // ../bridge/src/connection/routing/handlers/bridge-identified.ts
53682
53499
  var handleBridgeIdentified = (msg, deps) => {
53683
53500
  if (typeof msg.bridgeName !== "string") return;
53684
53501
  deps.onBridgeIdentified({
@@ -53705,19 +53522,9 @@ var handleBridgeIdentified = (msg, deps) => {
53705
53522
  }
53706
53523
  })();
53707
53524
  });
53708
- setImmediate(() => {
53709
- if (isCliImmediateShutdownRequested()) return;
53710
- try {
53711
- deps.sendLocalSkillsReport?.();
53712
- } catch (e) {
53713
- deps.log(
53714
- `[Bridge service] Local skills report failed: ${e instanceof Error ? e.message : String(e)}`
53715
- );
53716
- }
53717
- });
53718
53525
  };
53719
53526
 
53720
- // ../bridge/src/routing/handlers/installed-agent-auth-sync.ts
53527
+ // ../bridge/src/connection/routing/handlers/installed-agent-auth-sync.ts
53721
53528
  var handleInstalledAgentAuthSync = (msg) => {
53722
53529
  const entries = Array.isArray(msg.entries) ? msg.entries : [];
53723
53530
  setBridgeInstalledAgentAuthEnv(
@@ -53727,6 +53534,241 @@ var handleInstalledAgentAuthSync = (msg) => {
53727
53534
  );
53728
53535
  };
53729
53536
 
53537
+ // ../bridge/src/agents/install/run-streaming-command.ts
53538
+ import { spawn as spawn10 } from "node:child_process";
53539
+ import * as readline4 from "node:readline";
53540
+ function runStreamingCommand(command, args, options) {
53541
+ return new Promise((resolve39, reject) => {
53542
+ const child = spawn10(command, args, {
53543
+ env: options.env,
53544
+ stdio: ["ignore", "pipe", "pipe"]
53545
+ });
53546
+ let settled = false;
53547
+ const timer = options.timeoutMs != null ? setTimeout(() => {
53548
+ child.kill("SIGKILL");
53549
+ if (!settled) {
53550
+ settled = true;
53551
+ reject(new Error(`Command timed out after ${options.timeoutMs}ms`));
53552
+ }
53553
+ }, options.timeoutMs) : null;
53554
+ const onLine = (line) => {
53555
+ if (line.length > 0) options.onLine?.(line);
53556
+ };
53557
+ if (child.stdout) {
53558
+ readline4.createInterface({ input: child.stdout, crlfDelay: Infinity }).on("line", onLine);
53559
+ }
53560
+ if (child.stderr) {
53561
+ readline4.createInterface({ input: child.stderr, crlfDelay: Infinity }).on("line", onLine);
53562
+ }
53563
+ child.on("error", (err) => {
53564
+ if (timer) clearTimeout(timer);
53565
+ if (!settled) {
53566
+ settled = true;
53567
+ reject(err);
53568
+ }
53569
+ });
53570
+ child.on("close", (code, signal) => {
53571
+ if (timer) clearTimeout(timer);
53572
+ if (!settled) {
53573
+ settled = true;
53574
+ resolve39({ code, signal });
53575
+ }
53576
+ });
53577
+ });
53578
+ }
53579
+
53580
+ // ../bridge/src/agents/install/commands/run-npm-global-install.ts
53581
+ async function runNpmGlobalInstall(packageName, env, options) {
53582
+ const result = await runStreamingCommand("npm", ["install", "-g", packageName], {
53583
+ env: bridgeAgentPathEnv(env),
53584
+ timeoutMs: options?.timeoutMs ?? 3e5,
53585
+ onLine: options?.onLine
53586
+ });
53587
+ if (result.code !== 0) {
53588
+ throw new Error(`npm install -g ${packageName} failed (exit ${result.code ?? "signal"})`);
53589
+ }
53590
+ }
53591
+
53592
+ // ../bridge/src/agents/install/commands/claude-code.ts
53593
+ var claudeCodeInstallCommand = {
53594
+ agentType: "claude-code",
53595
+ detectCommand: "claude",
53596
+ async install(ctx) {
53597
+ ctx.onProgress?.("Installing Anthropic Claude Code");
53598
+ await runNpmGlobalInstall(
53599
+ "@anthropic-ai/claude-code",
53600
+ { ...ctx.env, ANTHROPIC_API_KEY: ctx.authToken },
53601
+ { onLine: (line) => ctx.onProgress?.("Installing Anthropic Claude Code", line) }
53602
+ );
53603
+ }
53604
+ };
53605
+
53606
+ // ../bridge/src/agents/install/commands/codex-acp.ts
53607
+ var codexAcpInstallCommand = {
53608
+ agentType: "codex-acp",
53609
+ detectCommand: "codex",
53610
+ async install(ctx) {
53611
+ ctx.onProgress?.("Installing Codex");
53612
+ await runNpmGlobalInstall(
53613
+ "@openai/codex",
53614
+ { ...ctx.env, OPENAI_API_KEY: ctx.authToken },
53615
+ { onLine: (line) => ctx.onProgress?.("Installing Codex", line) }
53616
+ );
53617
+ }
53618
+ };
53619
+
53620
+ // ../bridge/src/agents/install/commands/cursor-cli.ts
53621
+ var cursorCliInstallCommand = {
53622
+ agentType: "cursor-cli",
53623
+ detectCommand: "agent",
53624
+ alternateDetectCommands: ["cursor-agent"],
53625
+ async install(ctx) {
53626
+ ctx.onProgress?.("Installing Cursor CLI");
53627
+ const result = await runStreamingCommand(
53628
+ "bash",
53629
+ ["-lc", "curl -fsSL https://cursor.com/install | bash"],
53630
+ {
53631
+ timeoutMs: 3e5,
53632
+ env: { ...bridgeAgentPathEnv(ctx.env), CURSOR_API_KEY: ctx.authToken },
53633
+ onLine: (line) => ctx.onProgress?.("Installing Cursor CLI", line)
53634
+ }
53635
+ );
53636
+ if (result.code !== 0) {
53637
+ throw new Error(`Cursor CLI install failed (exit ${result.code ?? "signal"})`);
53638
+ }
53639
+ }
53640
+ };
53641
+
53642
+ // ../bridge/src/agents/install/commands/opencode.ts
53643
+ var opencodeInstallCommand = {
53644
+ agentType: "opencode",
53645
+ detectCommand: "opencode",
53646
+ async install(ctx) {
53647
+ ctx.onProgress?.("Installing OpenCode");
53648
+ await runNpmGlobalInstall(
53649
+ "opencode-ai",
53650
+ { ...ctx.env, OPENCODE_API_KEY: ctx.authToken },
53651
+ { onLine: (line) => ctx.onProgress?.("Installing OpenCode", line) }
53652
+ );
53653
+ }
53654
+ };
53655
+
53656
+ // ../bridge/src/agents/install/commands/index.ts
53657
+ var COMMANDS = [
53658
+ claudeCodeInstallCommand,
53659
+ codexAcpInstallCommand,
53660
+ cursorCliInstallCommand,
53661
+ opencodeInstallCommand
53662
+ ];
53663
+ var byType = new Map(COMMANDS.map((c) => [c.agentType, c]));
53664
+ function getAgentInstallCommand(agentType) {
53665
+ return byType.get(agentType);
53666
+ }
53667
+
53668
+ // ../bridge/src/agents/install/install-local-agent.ts
53669
+ async function installLocalAgentOnBridge(params) {
53670
+ const spec = INSTALLABLE_BRIDGE_AGENTS.find((a) => a.value === params.agentType);
53671
+ if (!spec) return { success: false, error: `Unsupported agent type: ${params.agentType}` };
53672
+ const command = getAgentInstallCommand(params.agentType);
53673
+ if (!command) return { success: false, error: `No install command for ${params.agentType}` };
53674
+ params.onProgress?.(`Configuring ${spec.label} credentials`);
53675
+ try {
53676
+ await command.install({
53677
+ authToken: params.authToken,
53678
+ onProgress: params.onProgress,
53679
+ env: { ...process.env, [spec.tokenEnvVar]: params.authToken }
53680
+ });
53681
+ } catch (e) {
53682
+ const msg = e instanceof Error ? e.message : String(e);
53683
+ return { success: false, error: msg };
53684
+ }
53685
+ ensureBridgeAgentPathInProcessEnv();
53686
+ const detectNames = [
53687
+ command.detectCommand,
53688
+ ...command.alternateDetectCommands ?? []
53689
+ ];
53690
+ let found = false;
53691
+ for (const name of detectNames) {
53692
+ if (await waitForCommandOnPath(name)) {
53693
+ found = true;
53694
+ break;
53695
+ }
53696
+ }
53697
+ if (!found) {
53698
+ return { success: false, error: `${command.detectCommand} not found on PATH after install` };
53699
+ }
53700
+ return { success: true };
53701
+ }
53702
+
53703
+ // ../bridge/src/connection/routing/handlers/install-agent.ts
53704
+ var handleInstallAgentMessage = (msg, deps) => {
53705
+ const processId = typeof msg.processId === "string" ? msg.processId : "";
53706
+ const agentId = typeof msg.agentId === "string" ? msg.agentId : "";
53707
+ const tokenId = typeof msg.tokenId === "string" ? msg.tokenId : "";
53708
+ const agentType = typeof msg.agentType === "string" ? msg.agentType : "";
53709
+ const authToken = typeof msg.authToken === "string" ? msg.authToken : "";
53710
+ if (!processId || !agentId || !tokenId || !agentType || !authToken) return;
53711
+ void (async () => {
53712
+ const socket = deps.getWs();
53713
+ let pendingLines = [];
53714
+ let flushTimer = null;
53715
+ const sendProgress = (message, logOutput) => {
53716
+ if (!socket) return;
53717
+ sendWsMessage(socket, {
53718
+ type: "install_agent_progress",
53719
+ processId,
53720
+ agentId,
53721
+ tokenId,
53722
+ agentType,
53723
+ step: "agent_install_package",
53724
+ message,
53725
+ ...logOutput ? { logOutput } : {}
53726
+ });
53727
+ };
53728
+ const flushLines = (message) => {
53729
+ if (flushTimer) {
53730
+ clearTimeout(flushTimer);
53731
+ flushTimer = null;
53732
+ }
53733
+ if (pendingLines.length === 0) return;
53734
+ const logOutput = pendingLines.join("\n");
53735
+ pendingLines = [];
53736
+ sendProgress(message, logOutput);
53737
+ };
53738
+ const result = await installLocalAgentOnBridge({
53739
+ agentType,
53740
+ authToken,
53741
+ onProgress: (message, logOutput) => {
53742
+ if (logOutput == null) {
53743
+ flushLines(message);
53744
+ sendProgress(message);
53745
+ return;
53746
+ }
53747
+ pendingLines.push(logOutput);
53748
+ if (!flushTimer) {
53749
+ flushTimer = setTimeout(() => flushLines(message), 100);
53750
+ }
53751
+ }
53752
+ });
53753
+ flushLines("Installing agent packages on the bridge machine.");
53754
+ if (socket) {
53755
+ sendWsMessage(socket, {
53756
+ type: "install_agent_result",
53757
+ processId,
53758
+ agentId,
53759
+ tokenId,
53760
+ agentType,
53761
+ success: result.success,
53762
+ error: result.error
53763
+ });
53764
+ }
53765
+ if (result.success) await deps.reportAutoDetectedAgents?.();
53766
+ if (!result.success) {
53767
+ deps.log(`[Bridge service] Install agent failed: ${result.error ?? "unknown"}`);
53768
+ }
53769
+ })();
53770
+ };
53771
+
53730
53772
  // ../bridge/src/connection/heartbeat/ack.ts
53731
53773
  var handleBridgeHeartbeatAck = (msg, deps) => {
53732
53774
  const raw = msg.s;
@@ -53734,7 +53776,7 @@ var handleBridgeHeartbeatAck = (msg, deps) => {
53734
53776
  deps.onBridgeHeartbeatAck?.(Math.trunc(raw));
53735
53777
  };
53736
53778
 
53737
- // ../bridge/src/routing/dispatch/connection.ts
53779
+ // ../bridge/src/connection/routing/dispatch/connection.ts
53738
53780
  function dispatchBridgeConnectionMessage(msg, deps) {
53739
53781
  switch (msg.type) {
53740
53782
  case "auth_token":
@@ -53746,13 +53788,16 @@ function dispatchBridgeConnectionMessage(msg, deps) {
53746
53788
  case "installed_agent_auth_sync":
53747
53789
  handleInstalledAgentAuthSync(msg, deps);
53748
53790
  break;
53791
+ case "install_agent":
53792
+ handleInstallAgentMessage(msg, deps);
53793
+ break;
53749
53794
  case "ha":
53750
53795
  handleBridgeHeartbeatAck(msg, deps);
53751
53796
  break;
53752
53797
  }
53753
53798
  }
53754
53799
 
53755
- // ../bridge/src/routing/handlers/preview-environment-control.ts
53800
+ // ../bridge/src/connection/routing/handlers/preview-environment-control.ts
53756
53801
  var handlePreviewEnvironmentControl = (msg, deps) => {
53757
53802
  let wire;
53758
53803
  try {
@@ -53767,7 +53812,7 @@ var handlePreviewEnvironmentControl = (msg, deps) => {
53767
53812
  deps.previewEnvironmentManager?.handleControl(environmentId, action);
53768
53813
  };
53769
53814
 
53770
- // ../bridge/src/routing/handlers/preview-environments-config.ts
53815
+ // ../bridge/src/connection/routing/handlers/preview-environments-config.ts
53771
53816
  var VALID_PORT = (p) => typeof p === "number" && Number.isInteger(p) && p > 0 && p < 65536;
53772
53817
  var handlePreviewEnvironmentsConfig = (msg, deps) => {
53773
53818
  const previewEnvironments = msg.previewEnvironments;
@@ -53782,13 +53827,13 @@ var handlePreviewEnvironmentsConfig = (msg, deps) => {
53782
53827
  });
53783
53828
  };
53784
53829
 
53785
- // ../bridge/src/routing/handlers/send-deploy-session-to-preview-result.ts
53830
+ // ../bridge/src/connection/routing/handlers/send-deploy-session-to-preview-result.ts
53786
53831
  function sendDeploySessionToPreviewResult(ws, id, payload) {
53787
53832
  if (!ws) return;
53788
53833
  sendWsMessage(ws, { type: "deploy_session_to_preview_result", id, ...payload });
53789
53834
  }
53790
53835
 
53791
- // ../bridge/src/routing/handlers/deploy-session-to-preview.ts
53836
+ // ../bridge/src/connection/routing/handlers/deploy-session-to-preview.ts
53792
53837
  var handleDeploySessionToPreviewMessage = (msg, deps) => {
53793
53838
  if (typeof msg.id !== "string") return;
53794
53839
  const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
@@ -53816,7 +53861,7 @@ var handleDeploySessionToPreviewMessage = (msg, deps) => {
53816
53861
  })();
53817
53862
  };
53818
53863
 
53819
- // ../bridge/src/routing/dispatch/preview.ts
53864
+ // ../bridge/src/connection/routing/dispatch/preview.ts
53820
53865
  function dispatchBridgePreviewMessage(msg, deps) {
53821
53866
  switch (msg.type) {
53822
53867
  case "preview_environments_config":
@@ -53837,7 +53882,7 @@ function handleBridgeAgentConfig(msg, { acpManager }) {
53837
53882
  acpManager.setPreferredAgentType(msg.agents[0].type);
53838
53883
  }
53839
53884
 
53840
- // ../bridge/src/routing/handlers/agent-config.ts
53885
+ // ../bridge/src/connection/routing/handlers/agent-config.ts
53841
53886
  var handleAgentConfigMessage = (msg, deps) => {
53842
53887
  handleBridgeAgentConfig(msg, deps);
53843
53888
  };
@@ -54059,18 +54104,18 @@ function hasRunningTurn(turns) {
54059
54104
  }
54060
54105
 
54061
54106
  // ../bridge/src/prompt-turn-queue/runner/run-local-revert-before-queued-prompt.ts
54062
- import fs56 from "node:fs";
54107
+ import fs55 from "node:fs";
54063
54108
 
54064
54109
  // ../bridge/src/git/snapshot/capture.ts
54065
- import * as fs55 from "node:fs";
54066
- import * as path80 from "node:path";
54110
+ import * as fs54 from "node:fs";
54111
+ import * as path79 from "node:path";
54067
54112
 
54068
54113
  // ../bridge/src/git/snapshot/apply-pre-turn-snapshot.ts
54069
- import * as fs54 from "node:fs";
54114
+ import * as fs53 from "node:fs";
54070
54115
  async function applyPreTurnSnapshot(filePath, log2) {
54071
54116
  let data;
54072
54117
  try {
54073
- data = JSON.parse(fs54.readFileSync(filePath, "utf8"));
54118
+ data = JSON.parse(fs53.readFileSync(filePath, "utf8"));
54074
54119
  } catch (error51) {
54075
54120
  return { ok: false, error: error51 instanceof Error ? error51.message : String(error51) };
54076
54121
  }
@@ -54099,18 +54144,18 @@ async function applyPreTurnSnapshot(filePath, log2) {
54099
54144
  }
54100
54145
 
54101
54146
  // ../bridge/src/git/snapshot/resolve-repo-roots.ts
54102
- import * as path79 from "node:path";
54147
+ import * as path78 from "node:path";
54103
54148
  async function resolveSnapshotRepoRoots(options) {
54104
54149
  const { worktreePaths, fallbackCwd, sessionId, log: log2 } = options;
54105
54150
  if (worktreePaths?.length) {
54106
- const paths = [...new Set(worktreePaths.map((p) => path79.resolve(p)))];
54151
+ const paths = [...new Set(worktreePaths.map((p) => path78.resolve(p)))];
54107
54152
  return (await Promise.all(paths.map(async (p) => await isGitRepoDirectory(p) ? p : null))).filter((p) => p != null);
54108
54153
  }
54109
54154
  try {
54110
54155
  const roots = (await discoverGitReposUnderRoot(fallbackCwd)).map((repo) => repo.absolutePath);
54111
54156
  const sid = sessionId?.trim();
54112
54157
  if (!sid) return roots;
54113
- const sessionRoots = roots.filter((root) => path79.basename(root) === sid);
54158
+ const sessionRoots = roots.filter((root) => path78.basename(root) === sid);
54114
54159
  return sessionRoots.length > 0 ? sessionRoots : roots;
54115
54160
  } catch (error51) {
54116
54161
  log2(`[snapshot] Discover repositories failed: ${error51 instanceof Error ? error51.message : String(error51)}`);
@@ -54132,7 +54177,7 @@ async function capturePreTurnSnapshot(options) {
54132
54177
  });
54133
54178
  const dir = snapshotsDirForCwd(agentCwd);
54134
54179
  try {
54135
- fs55.mkdirSync(dir, { recursive: true });
54180
+ fs54.mkdirSync(dir, { recursive: true });
54136
54181
  } catch (e) {
54137
54182
  return { ok: false, error: e instanceof Error ? e.message : String(e) };
54138
54183
  }
@@ -54141,9 +54186,9 @@ async function capturePreTurnSnapshot(options) {
54141
54186
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
54142
54187
  repos
54143
54188
  };
54144
- const filePath = path80.join(dir, `${runId}.json`);
54189
+ const filePath = path79.join(dir, `${runId}.json`);
54145
54190
  try {
54146
- fs55.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
54191
+ fs54.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
54147
54192
  } catch (e) {
54148
54193
  return { ok: false, error: e instanceof Error ? e.message : String(e) };
54149
54194
  }
@@ -54163,7 +54208,7 @@ async function runLocalRevertBeforeQueuedPrompt(next, deps) {
54163
54208
  const agentBase = deps.sessionWorktreeManager.getSessionWorktreeRootForSession(sid) ?? getBridgeRoot();
54164
54209
  const file2 = snapshotFilePath(agentBase, tid);
54165
54210
  try {
54166
- await fs56.promises.access(file2, fs56.constants.F_OK);
54211
+ await fs55.promises.access(file2, fs55.constants.F_OK);
54167
54212
  } catch {
54168
54213
  deps.log(
54169
54214
  `[Queue] requeued_with_revert: no pre-turn snapshot for ${tid.slice(0, 8)}\u2026; continuing without revert.`
@@ -54534,7 +54579,7 @@ function handleBridgePrompt(msg, deps) {
54534
54579
  });
54535
54580
  }
54536
54581
 
54537
- // ../bridge/src/routing/handlers/prompt.ts
54582
+ // ../bridge/src/connection/routing/handlers/prompt.ts
54538
54583
  var handlePromptMessage = (msg, deps) => {
54539
54584
  handleBridgePrompt(msg, deps);
54540
54585
  };
@@ -54559,7 +54604,7 @@ function enqueueLatestPromptQueueStateWork(work) {
54559
54604
  });
54560
54605
  }
54561
54606
 
54562
- // ../bridge/src/routing/handlers/prompt-queue-state.ts
54607
+ // ../bridge/src/connection/routing/handlers/prompt-queue-state.ts
54563
54608
  var handlePromptQueueStateMessage = (msg, deps) => {
54564
54609
  enqueueLatestPromptQueueStateWork(async () => {
54565
54610
  try {
@@ -54576,12 +54621,12 @@ function handleBridgeSessionRequestResponse(msg, { acpManager }) {
54576
54621
  acpManager.resolveRequest(msg.requestId, msg.result ?? {});
54577
54622
  }
54578
54623
 
54579
- // ../bridge/src/routing/handlers/session-request-response.ts
54624
+ // ../bridge/src/connection/routing/handlers/session-request-response.ts
54580
54625
  var handleSessionRequestResponseMessage = (msg, deps) => {
54581
54626
  handleBridgeSessionRequestResponse(msg, deps);
54582
54627
  };
54583
54628
 
54584
- // ../bridge/src/routing/handlers/git/handle-session-git-commit.ts
54629
+ // ../bridge/src/connection/routing/handlers/git/handle-session-git-commit.ts
54585
54630
  async function handleSessionGitCommitAction(deps, sessionId, msg, reply) {
54586
54631
  const branch = typeof msg.branch === "string" ? msg.branch : "";
54587
54632
  const message = typeof msg.message === "string" ? msg.message : "";
@@ -54611,7 +54656,7 @@ async function handleSessionGitCommitAction(deps, sessionId, msg, reply) {
54611
54656
  });
54612
54657
  }
54613
54658
 
54614
- // ../bridge/src/routing/handlers/git/session-git-changes-params.ts
54659
+ // ../bridge/src/connection/routing/handlers/git/session-git-changes-params.ts
54615
54660
  function readString(value) {
54616
54661
  return typeof value === "string" ? value.trim() : "";
54617
54662
  }
@@ -54639,7 +54684,7 @@ function parseSessionGitChangesParams(msg) {
54639
54684
  };
54640
54685
  }
54641
54686
 
54642
- // ../bridge/src/routing/handlers/git/handle-session-git-get-change-file-patch.ts
54687
+ // ../bridge/src/connection/routing/handlers/git/handle-session-git-get-change-file-patch.ts
54643
54688
  async function handleSessionGitGetChangeFilePatchAction(deps, msg, reply) {
54644
54689
  const changes = parseSessionGitChangesParams(msg);
54645
54690
  const { repoRelPath: repoRel, view, commitSha, fileWorkspaceRelPath, fileChange, fileMovedFromWorkspaceRelPath } = changes;
@@ -54672,7 +54717,7 @@ async function handleSessionGitGetChangeFilePatchAction(deps, msg, reply) {
54672
54717
  );
54673
54718
  }
54674
54719
 
54675
- // ../bridge/src/routing/handlers/git/coalesce-list-changes.ts
54720
+ // ../bridge/src/connection/routing/handlers/git/coalesce-list-changes.ts
54676
54721
  var listChangesInflight = /* @__PURE__ */ new Map();
54677
54722
  function normalizeListChangesRepoPathRelativeToWorkspaceRoot(repoRelPath) {
54678
54723
  if (!repoRelPath?.trim()) return "";
@@ -54698,7 +54743,7 @@ function getSessionWorkingTreeChangeDetailsCoalesced(sessionWorktreeManager, ses
54698
54743
  return promise2;
54699
54744
  }
54700
54745
 
54701
- // ../bridge/src/routing/handlers/git/handle-session-git-list-changes.ts
54746
+ // ../bridge/src/connection/routing/handlers/git/handle-session-git-list-changes.ts
54702
54747
  async function handleSessionGitListChangesAction(deps, msg, reply) {
54703
54748
  const changes = parseSessionGitChangesParams(msg);
54704
54749
  const { repoRelPath: repoRel, view, commitSha, recentCommitsLimit } = changes;
@@ -54724,7 +54769,7 @@ async function handleSessionGitListChangesAction(deps, msg, reply) {
54724
54769
  reply({ ok: true, repos }, ["repos"]);
54725
54770
  }
54726
54771
 
54727
- // ../bridge/src/routing/handlers/git/handle-session-git-push.ts
54772
+ // ../bridge/src/connection/routing/handlers/git/handle-session-git-push.ts
54728
54773
  async function handleSessionGitPushAction(deps, sessionId, reply) {
54729
54774
  const pushRes = await deps.sessionWorktreeManager.pushSessionUpstream(sessionId);
54730
54775
  if (!pushRes.ok) {
@@ -54740,7 +54785,7 @@ async function handleSessionGitPushAction(deps, sessionId, reply) {
54740
54785
  });
54741
54786
  }
54742
54787
 
54743
- // ../bridge/src/routing/handlers/git/handle-session-git-status.ts
54788
+ // ../bridge/src/connection/routing/handlers/git/handle-session-git-status.ts
54744
54789
  async function handleSessionGitStatusAction(deps, sessionId, reply) {
54745
54790
  const r = await deps.sessionWorktreeManager.getSessionWorkingTreeStatus(sessionId);
54746
54791
  reply({
@@ -54751,7 +54796,7 @@ async function handleSessionGitStatusAction(deps, sessionId, reply) {
54751
54796
  });
54752
54797
  }
54753
54798
 
54754
- // ../bridge/src/routing/handlers/git/send-session-git-result.ts
54799
+ // ../bridge/src/connection/routing/handlers/git/send-session-git-result.ts
54755
54800
  function sendSessionGitResult(ws, id, payload, e2ee, encryptedFields = []) {
54756
54801
  if (!ws) return;
54757
54802
  const message = { type: "session_git_result", id, ...payload };
@@ -54762,7 +54807,7 @@ function sendSessionGitResult(ws, id, payload, e2ee, encryptedFields = []) {
54762
54807
  sendWsMessage(ws, wire);
54763
54808
  }
54764
54809
 
54765
- // ../bridge/src/routing/handlers/git/session-git-request.ts
54810
+ // ../bridge/src/connection/routing/handlers/git/session-git-request.ts
54766
54811
  var handleSessionGitRequestMessage = (msg, deps) => {
54767
54812
  if (typeof msg.id !== "string") return;
54768
54813
  const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
@@ -54796,7 +54841,7 @@ var handleSessionGitRequestMessage = (msg, deps) => {
54796
54841
  })();
54797
54842
  };
54798
54843
 
54799
- // ../bridge/src/routing/handlers/rename-session-branch.ts
54844
+ // ../bridge/src/connection/routing/handlers/rename-session-branch.ts
54800
54845
  var handleRenameSessionBranchMessage = (msg, deps) => {
54801
54846
  const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
54802
54847
  const newBranch = typeof msg.newBranch === "string" ? msg.newBranch : "";
@@ -54804,7 +54849,7 @@ var handleRenameSessionBranchMessage = (msg, deps) => {
54804
54849
  void deps.sessionWorktreeManager.renameSessionBranch(sessionId, newBranch);
54805
54850
  };
54806
54851
 
54807
- // ../bridge/src/routing/handlers/session-archived.ts
54852
+ // ../bridge/src/connection/routing/handlers/session-archived.ts
54808
54853
  var handleSessionArchivedMessage = (msg, deps) => {
54809
54854
  const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
54810
54855
  if (!sessionId) return;
@@ -54812,7 +54857,7 @@ var handleSessionArchivedMessage = (msg, deps) => {
54812
54857
  void deps.sessionWorktreeManager.removeSessionWorktrees(sessionId);
54813
54858
  };
54814
54859
 
54815
- // ../bridge/src/routing/handlers/session-discarded.ts
54860
+ // ../bridge/src/connection/routing/handlers/session-discarded.ts
54816
54861
  var handleSessionDiscardedMessage = (msg, deps) => {
54817
54862
  const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
54818
54863
  if (!sessionId) return;
@@ -54820,8 +54865,8 @@ var handleSessionDiscardedMessage = (msg, deps) => {
54820
54865
  void deps.sessionWorktreeManager.removeSessionWorktrees(sessionId);
54821
54866
  };
54822
54867
 
54823
- // ../bridge/src/routing/handlers/revert-turn-snapshot.ts
54824
- import * as fs57 from "node:fs";
54868
+ // ../bridge/src/connection/routing/handlers/revert-turn-snapshot.ts
54869
+ import * as fs56 from "node:fs";
54825
54870
  var handleRevertTurnSnapshotMessage = (msg, deps) => {
54826
54871
  const id = typeof msg.id === "string" ? msg.id : "";
54827
54872
  const sessionId = typeof msg.sessionId === "string" ? msg.sessionId : "";
@@ -54834,7 +54879,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
54834
54879
  const agentBase = sessionWorktreeManager.getSessionWorktreeRootForSession(sessionId) ?? getBridgeRoot();
54835
54880
  const file2 = snapshotFilePath(agentBase, turnId);
54836
54881
  try {
54837
- await fs57.promises.access(file2, fs57.constants.F_OK);
54882
+ await fs56.promises.access(file2, fs56.constants.F_OK);
54838
54883
  } catch {
54839
54884
  sendWsMessage(s, {
54840
54885
  type: "revert_turn_snapshot_result",
@@ -54854,7 +54899,7 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
54854
54899
  })();
54855
54900
  };
54856
54901
 
54857
- // ../bridge/src/routing/dispatch/session.ts
54902
+ // ../bridge/src/connection/routing/dispatch/session.ts
54858
54903
  function dispatchBridgeSessionMessage(msg, deps) {
54859
54904
  switch (msg.type) {
54860
54905
  case "agent_config":
@@ -54887,382 +54932,6 @@ function dispatchBridgeSessionMessage(msg, deps) {
54887
54932
  }
54888
54933
  }
54889
54934
 
54890
- // ../bridge/src/skills/handle-skill-call.ts
54891
- function handleSkillCall(msg, socket, log2) {
54892
- callSkill(msg.skillId, msg.operationId, msg.params ?? {}).then((result) => {
54893
- sendWsMessage(socket, { type: "skill_result", id: msg.id, result });
54894
- }).catch((err) => {
54895
- sendWsMessage(socket, { type: "skill_result", id: msg.id, error: String(err) });
54896
- log2(`[Bridge service] Skill invocation failed (${msg.skillId}/${msg.operationId}): ${err}`);
54897
- });
54898
- }
54899
-
54900
- // ../bridge/src/routing/handlers/skill-call.ts
54901
- var handleSkillCallMessage = (msg, { getWs, log: log2 }) => {
54902
- const skillId = typeof msg.skillId === "string" ? msg.skillId : "";
54903
- const operationId = typeof msg.operationId === "string" ? msg.operationId : "";
54904
- if (!skillId || !operationId) return;
54905
- const socket = getWs();
54906
- if (!socket) return;
54907
- handleSkillCall(
54908
- { id: msg.id, skillId, operationId, params: msg.params },
54909
- socket,
54910
- log2
54911
- );
54912
- };
54913
-
54914
- // ../bridge/src/routing/handlers/skill-layout-request.ts
54915
- function handleSkillLayoutRequest(msg, deps) {
54916
- const id = typeof msg.id === "string" ? msg.id : "";
54917
- void (async () => {
54918
- const socket = deps.getWs();
54919
- const roots = await discoverSkillLayoutRootsAsync(getBridgeRoot());
54920
- if (socket) {
54921
- sendWsMessage(socket, { type: "skill_layout_response", id, roots });
54922
- }
54923
- })();
54924
- }
54925
-
54926
- // ../bridge/src/skills/install/is-valid-install-item.ts
54927
- function isValidRemoteSkillInstallItem(item) {
54928
- if (item === null || typeof item !== "object") return false;
54929
- const o = item;
54930
- return typeof o.sourceId === "string" && typeof o.skillName === "string" && typeof o.versionHash === "string" && Array.isArray(o.files);
54931
- }
54932
-
54933
- // ../bridge/src/skills/install/install-remote-skills-async.ts
54934
- init_yield_to_event_loop();
54935
- import fs58 from "node:fs";
54936
- import path81 from "node:path";
54937
-
54938
- // ../bridge/src/skills/install/constants.ts
54939
- var INSTALL_SKILLS_YIELD_EVERY = 16;
54940
-
54941
- // ../bridge/src/skills/install/install-remote-skills-async.ts
54942
- async function writeInstallFileAsync(skillDir, f, filesWritten) {
54943
- if (typeof f.path !== "string" || !f.text && !f.base64) return;
54944
- if (++filesWritten.count % INSTALL_SKILLS_YIELD_EVERY === 0) {
54945
- await yieldToEventLoop();
54946
- }
54947
- const dest = path81.join(skillDir, f.path);
54948
- await fs58.promises.mkdir(path81.dirname(dest), { recursive: true });
54949
- if (f.text !== void 0) {
54950
- await fs58.promises.writeFile(dest, f.text, "utf8");
54951
- } else if (f.base64) {
54952
- await fs58.promises.writeFile(dest, Buffer.from(f.base64, "base64"));
54953
- }
54954
- }
54955
- async function installRemoteSkillsAsync(cwd, targetDir, items) {
54956
- const installed2 = [];
54957
- if (!Array.isArray(items)) {
54958
- return { success: false, error: "Invalid items" };
54959
- }
54960
- const filesWritten = { count: 0 };
54961
- try {
54962
- for (const item of items) {
54963
- if (!isValidRemoteSkillInstallItem(item)) continue;
54964
- const skillDir = path81.join(cwd, targetDir, item.skillName);
54965
- for (const f of item.files) {
54966
- await writeInstallFileAsync(skillDir, f, filesWritten);
54967
- }
54968
- installed2.push({
54969
- sourceId: item.sourceId,
54970
- skillName: item.skillName,
54971
- versionHash: item.versionHash
54972
- });
54973
- }
54974
- return { success: true, installed: installed2 };
54975
- } catch (e) {
54976
- return { success: false, error: e instanceof Error ? e.message : String(e) };
54977
- }
54978
- }
54979
-
54980
- // ../bridge/src/routing/handlers/install-skills.ts
54981
- var handleInstallSkillsMessage = (msg, deps) => {
54982
- const id = typeof msg.id === "string" ? msg.id : "";
54983
- const targetDir = typeof msg.targetDir === "string" && msg.targetDir.trim() ? msg.targetDir.trim() : ".agents/skills";
54984
- const rawItems = msg.items;
54985
- const cwd = getBridgeRoot();
54986
- void (async () => {
54987
- const socket = deps.getWs();
54988
- const result = await installRemoteSkillsAsync(cwd, targetDir, rawItems);
54989
- if (!result.success) {
54990
- const err = result.error ?? "Invalid items";
54991
- deps.log(`[Bridge service] Install skills failed: ${err}`);
54992
- if (socket) {
54993
- sendWsMessage(socket, { type: "install_skills_result", id, success: false, error: err });
54994
- }
54995
- return;
54996
- }
54997
- if (socket) {
54998
- sendWsMessage(socket, { type: "install_skills_result", id, success: true, installed: result.installed });
54999
- }
55000
- })();
55001
- };
55002
-
55003
- // ../bridge/src/agents/install/run-streaming-command.ts
55004
- import { spawn as spawn11 } from "node:child_process";
55005
- import * as readline3 from "node:readline";
55006
- function runStreamingCommand(command, args, options) {
55007
- return new Promise((resolve39, reject) => {
55008
- const child = spawn11(command, args, {
55009
- env: options.env,
55010
- stdio: ["ignore", "pipe", "pipe"]
55011
- });
55012
- let settled = false;
55013
- const timer = options.timeoutMs != null ? setTimeout(() => {
55014
- child.kill("SIGKILL");
55015
- if (!settled) {
55016
- settled = true;
55017
- reject(new Error(`Command timed out after ${options.timeoutMs}ms`));
55018
- }
55019
- }, options.timeoutMs) : null;
55020
- const onLine = (line) => {
55021
- if (line.length > 0) options.onLine?.(line);
55022
- };
55023
- if (child.stdout) {
55024
- readline3.createInterface({ input: child.stdout, crlfDelay: Infinity }).on("line", onLine);
55025
- }
55026
- if (child.stderr) {
55027
- readline3.createInterface({ input: child.stderr, crlfDelay: Infinity }).on("line", onLine);
55028
- }
55029
- child.on("error", (err) => {
55030
- if (timer) clearTimeout(timer);
55031
- if (!settled) {
55032
- settled = true;
55033
- reject(err);
55034
- }
55035
- });
55036
- child.on("close", (code, signal) => {
55037
- if (timer) clearTimeout(timer);
55038
- if (!settled) {
55039
- settled = true;
55040
- resolve39({ code, signal });
55041
- }
55042
- });
55043
- });
55044
- }
55045
-
55046
- // ../bridge/src/agents/install/commands/run-npm-global-install.ts
55047
- async function runNpmGlobalInstall(packageName, env, options) {
55048
- const result = await runStreamingCommand("npm", ["install", "-g", packageName], {
55049
- env: bridgeAgentPathEnv(env),
55050
- timeoutMs: options?.timeoutMs ?? 3e5,
55051
- onLine: options?.onLine
55052
- });
55053
- if (result.code !== 0) {
55054
- throw new Error(`npm install -g ${packageName} failed (exit ${result.code ?? "signal"})`);
55055
- }
55056
- }
55057
-
55058
- // ../bridge/src/agents/install/commands/claude-code.ts
55059
- var claudeCodeInstallCommand = {
55060
- agentType: "claude-code",
55061
- detectCommand: "claude",
55062
- async install(ctx) {
55063
- ctx.onProgress?.("Installing Anthropic Claude Code");
55064
- await runNpmGlobalInstall(
55065
- "@anthropic-ai/claude-code",
55066
- { ...ctx.env, ANTHROPIC_API_KEY: ctx.authToken },
55067
- { onLine: (line) => ctx.onProgress?.("Installing Anthropic Claude Code", line) }
55068
- );
55069
- }
55070
- };
55071
-
55072
- // ../bridge/src/agents/install/commands/codex-acp.ts
55073
- var codexAcpInstallCommand = {
55074
- agentType: "codex-acp",
55075
- detectCommand: "codex",
55076
- async install(ctx) {
55077
- ctx.onProgress?.("Installing Codex");
55078
- await runNpmGlobalInstall(
55079
- "@openai/codex",
55080
- { ...ctx.env, OPENAI_API_KEY: ctx.authToken },
55081
- { onLine: (line) => ctx.onProgress?.("Installing Codex", line) }
55082
- );
55083
- }
55084
- };
55085
-
55086
- // ../bridge/src/agents/install/commands/cursor-cli.ts
55087
- var cursorCliInstallCommand = {
55088
- agentType: "cursor-cli",
55089
- detectCommand: "agent",
55090
- alternateDetectCommands: ["cursor-agent"],
55091
- async install(ctx) {
55092
- ctx.onProgress?.("Installing Cursor CLI");
55093
- const result = await runStreamingCommand(
55094
- "bash",
55095
- ["-lc", "curl -fsSL https://cursor.com/install | bash"],
55096
- {
55097
- timeoutMs: 3e5,
55098
- env: { ...bridgeAgentPathEnv(ctx.env), CURSOR_API_KEY: ctx.authToken },
55099
- onLine: (line) => ctx.onProgress?.("Installing Cursor CLI", line)
55100
- }
55101
- );
55102
- if (result.code !== 0) {
55103
- throw new Error(`Cursor CLI install failed (exit ${result.code ?? "signal"})`);
55104
- }
55105
- }
55106
- };
55107
-
55108
- // ../bridge/src/agents/install/commands/opencode.ts
55109
- var opencodeInstallCommand = {
55110
- agentType: "opencode",
55111
- detectCommand: "opencode",
55112
- async install(ctx) {
55113
- ctx.onProgress?.("Installing OpenCode");
55114
- await runNpmGlobalInstall(
55115
- "opencode-ai",
55116
- { ...ctx.env, OPENCODE_API_KEY: ctx.authToken },
55117
- { onLine: (line) => ctx.onProgress?.("Installing OpenCode", line) }
55118
- );
55119
- }
55120
- };
55121
-
55122
- // ../bridge/src/agents/install/commands/index.ts
55123
- var COMMANDS = [
55124
- claudeCodeInstallCommand,
55125
- codexAcpInstallCommand,
55126
- cursorCliInstallCommand,
55127
- opencodeInstallCommand
55128
- ];
55129
- var byType = new Map(COMMANDS.map((c) => [c.agentType, c]));
55130
- function getAgentInstallCommand(agentType) {
55131
- return byType.get(agentType);
55132
- }
55133
-
55134
- // ../bridge/src/agents/install/install-local-agent.ts
55135
- async function installLocalAgentOnBridge(params) {
55136
- const spec = INSTALLABLE_BRIDGE_AGENTS.find((a) => a.value === params.agentType);
55137
- if (!spec) return { success: false, error: `Unsupported agent type: ${params.agentType}` };
55138
- const command = getAgentInstallCommand(params.agentType);
55139
- if (!command) return { success: false, error: `No install command for ${params.agentType}` };
55140
- params.onProgress?.(`Configuring ${spec.label} credentials`);
55141
- try {
55142
- await command.install({
55143
- authToken: params.authToken,
55144
- onProgress: params.onProgress,
55145
- env: { ...process.env, [spec.tokenEnvVar]: params.authToken }
55146
- });
55147
- } catch (e) {
55148
- const msg = e instanceof Error ? e.message : String(e);
55149
- return { success: false, error: msg };
55150
- }
55151
- ensureBridgeAgentPathInProcessEnv();
55152
- const detectNames = [
55153
- command.detectCommand,
55154
- ...command.alternateDetectCommands ?? []
55155
- ];
55156
- let found = false;
55157
- for (const name of detectNames) {
55158
- if (await waitForCommandOnPath(name)) {
55159
- found = true;
55160
- break;
55161
- }
55162
- }
55163
- if (!found) {
55164
- return { success: false, error: `${command.detectCommand} not found on PATH after install` };
55165
- }
55166
- return { success: true };
55167
- }
55168
-
55169
- // ../bridge/src/routing/handlers/install-agent.ts
55170
- var handleInstallAgentMessage = (msg, deps) => {
55171
- const processId = typeof msg.processId === "string" ? msg.processId : "";
55172
- const agentId = typeof msg.agentId === "string" ? msg.agentId : "";
55173
- const tokenId = typeof msg.tokenId === "string" ? msg.tokenId : "";
55174
- const agentType = typeof msg.agentType === "string" ? msg.agentType : "";
55175
- const authToken = typeof msg.authToken === "string" ? msg.authToken : "";
55176
- if (!processId || !agentId || !tokenId || !agentType || !authToken) return;
55177
- void (async () => {
55178
- const socket = deps.getWs();
55179
- let pendingLines = [];
55180
- let flushTimer = null;
55181
- const sendProgress = (message, logOutput) => {
55182
- if (!socket) return;
55183
- sendWsMessage(socket, {
55184
- type: "install_agent_progress",
55185
- processId,
55186
- agentId,
55187
- tokenId,
55188
- agentType,
55189
- step: "agent_install_package",
55190
- message,
55191
- ...logOutput ? { logOutput } : {}
55192
- });
55193
- };
55194
- const flushLines = (message) => {
55195
- if (flushTimer) {
55196
- clearTimeout(flushTimer);
55197
- flushTimer = null;
55198
- }
55199
- if (pendingLines.length === 0) return;
55200
- const logOutput = pendingLines.join("\n");
55201
- pendingLines = [];
55202
- sendProgress(message, logOutput);
55203
- };
55204
- const result = await installLocalAgentOnBridge({
55205
- agentType,
55206
- authToken,
55207
- onProgress: (message, logOutput) => {
55208
- if (logOutput == null) {
55209
- flushLines(message);
55210
- sendProgress(message);
55211
- return;
55212
- }
55213
- pendingLines.push(logOutput);
55214
- if (!flushTimer) {
55215
- flushTimer = setTimeout(() => flushLines(message), 100);
55216
- }
55217
- }
55218
- });
55219
- flushLines("Installing agent packages on the bridge machine.");
55220
- if (socket) {
55221
- sendWsMessage(socket, {
55222
- type: "install_agent_result",
55223
- processId,
55224
- agentId,
55225
- tokenId,
55226
- agentType,
55227
- success: result.success,
55228
- error: result.error
55229
- });
55230
- }
55231
- if (result.success) await deps.reportAutoDetectedAgents?.();
55232
- if (!result.success) {
55233
- deps.log(`[Bridge service] Install agent failed: ${result.error ?? "unknown"}`);
55234
- }
55235
- })();
55236
- };
55237
-
55238
- // ../bridge/src/routing/handlers/refresh-local-skills.ts
55239
- var handleRefreshLocalSkills = (_msg, deps) => {
55240
- setImmediate(() => {
55241
- deps.sendLocalSkillsReport?.();
55242
- });
55243
- };
55244
-
55245
- // ../bridge/src/routing/dispatch/skills.ts
55246
- function dispatchBridgeSkillsMessage(msg, deps) {
55247
- switch (msg.type) {
55248
- case "skill_call":
55249
- handleSkillCallMessage(msg, deps);
55250
- break;
55251
- case "skill_layout_request":
55252
- handleSkillLayoutRequest(msg, deps);
55253
- break;
55254
- case "install_skills":
55255
- handleInstallSkillsMessage(msg, deps);
55256
- break;
55257
- case "install_agent":
55258
- handleInstallAgentMessage(msg, deps);
55259
- break;
55260
- case "refresh_local_skills":
55261
- handleRefreshLocalSkills(msg, deps);
55262
- break;
55263
- }
55264
- }
55265
-
55266
54935
  // ../bridge/src/files/browser/send-file-browser-message.ts
55267
54936
  function sendFileBrowserMessage(socket, e2ee, payload) {
55268
54937
  sendWsMessage(socket, e2ee ? e2ee.encryptFields(payload, ["entries", "content", "totalLines", "size", "lineOffset"]) : payload);
@@ -55324,13 +54993,13 @@ function handleFileBrowserRequest(msg, socket, e2ee, sessionWorktreeManager) {
55324
54993
 
55325
54994
  // ../bridge/src/files/handle-file-browser-search.ts
55326
54995
  init_yield_to_event_loop();
55327
- import path82 from "node:path";
54996
+ import path80 from "node:path";
55328
54997
  var SEARCH_LIMIT = 100;
55329
54998
  function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
55330
54999
  void (async () => {
55331
55000
  await yieldToEventLoop();
55332
55001
  const q = typeof msg.q === "string" ? msg.q : "";
55333
- const sessionParentPath = path82.resolve(
55002
+ const sessionParentPath = path80.resolve(
55334
55003
  sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
55335
55004
  );
55336
55005
  if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
@@ -55362,7 +55031,7 @@ function triggerFileIndexBuild(sessionParentPath = getBridgeRoot()) {
55362
55031
  });
55363
55032
  }
55364
55033
 
55365
- // ../bridge/src/routing/handlers/file-browser-messages.ts
55034
+ // ../bridge/src/connection/routing/handlers/file-browser-messages.ts
55366
55035
  function handleFileBrowserRequestMessage(msg, { getWs, e2ee, sessionWorktreeManager }) {
55367
55036
  if (typeof msg.id !== "string" || typeof msg.path !== "string") return;
55368
55037
  const socket = getWs();
@@ -55406,7 +55075,7 @@ function handleCodeNavRequest(msg, socket, e2ee, sessionWorktreeManager) {
55406
55075
  // ../bridge/src/code-nav/handlers/trigger-symbol-index-build.ts
55407
55076
  init_normalize_resolved_path();
55408
55077
 
55409
- // ../bridge/src/routing/handlers/code-nav-messages.ts
55078
+ // ../bridge/src/connection/routing/handlers/code-nav-messages.ts
55410
55079
  function handleFileBrowserCodeNavMessage(msg, { getWs, e2ee, sessionWorktreeManager }) {
55411
55080
  if (typeof msg.id !== "string" || typeof msg.path !== "string") return;
55412
55081
  const socket = getWs();
@@ -55428,7 +55097,7 @@ function handleFileBrowserCodeNavMessage(msg, { getWs, e2ee, sessionWorktreeMana
55428
55097
  }
55429
55098
 
55430
55099
  // ../bridge/src/git/bridge-git-context.ts
55431
- import * as path83 from "node:path";
55100
+ import * as path81 from "node:path";
55432
55101
  init_yield_to_event_loop();
55433
55102
 
55434
55103
  // ../bridge/src/git/branches/get-current-branch.ts
@@ -55496,12 +55165,12 @@ function listPendingCheckouts() {
55496
55165
  // ../bridge/src/git/bridge-git-context.ts
55497
55166
  function folderNameForRelPath(relPath, bridgeRoot) {
55498
55167
  if (relPath === "." || relPath === "") {
55499
- return path83.basename(path83.resolve(bridgeRoot)) || "repo";
55168
+ return path81.basename(path81.resolve(bridgeRoot)) || "repo";
55500
55169
  }
55501
- return path83.basename(relPath) || relPath;
55170
+ return path81.basename(relPath) || relPath;
55502
55171
  }
55503
55172
  async function discoverGitReposForBridgeContext(bridgeRoot) {
55504
- const root = path83.resolve(bridgeRoot);
55173
+ const root = path81.resolve(bridgeRoot);
55505
55174
  if (await isGitRepoDirectory(root)) {
55506
55175
  const remoteUrl = await getRemoteOriginUrl(root);
55507
55176
  return [{ absolutePath: root, remoteUrl }];
@@ -55509,19 +55178,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
55509
55178
  const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
55510
55179
  const byPath = /* @__PURE__ */ new Map();
55511
55180
  for (const repo of [...deep, ...shallow]) {
55512
- byPath.set(path83.resolve(repo.absolutePath), repo);
55181
+ byPath.set(path81.resolve(repo.absolutePath), repo);
55513
55182
  }
55514
55183
  return [...byPath.values()];
55515
55184
  }
55516
55185
  async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
55517
- const bridgeResolved = path83.resolve(bridgeRoot);
55186
+ const bridgeResolved = path81.resolve(bridgeRoot);
55518
55187
  const repos = await discoverGitReposForBridgeContext(bridgeResolved);
55519
55188
  const rows = [];
55520
55189
  for (let i = 0; i < repos.length; i++) {
55521
55190
  if (i > 0) await yieldToEventLoop();
55522
55191
  const repo = repos[i];
55523
- let rel = path83.relative(bridgeResolved, repo.absolutePath);
55524
- if (rel.startsWith("..") || path83.isAbsolute(rel)) continue;
55192
+ let rel = path81.relative(bridgeResolved, repo.absolutePath);
55193
+ if (rel.startsWith("..") || path81.isAbsolute(rel)) continue;
55525
55194
  const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
55526
55195
  const currentBranch = await getCurrentBranch(repo.absolutePath);
55527
55196
  const remoteUrl = repo.remoteUrl.trim() || null;
@@ -55552,17 +55221,17 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
55552
55221
  return rows;
55553
55222
  }
55554
55223
  async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
55555
- const bridgeResolved = path83.resolve(bridgeRoot);
55224
+ const bridgeResolved = path81.resolve(bridgeRoot);
55556
55225
  const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
55557
- const repoPath = rel === "" ? bridgeResolved : path83.join(bridgeResolved, rel);
55558
- const resolved = path83.resolve(repoPath);
55559
- if (!resolved.startsWith(bridgeResolved + path83.sep) && resolved !== bridgeResolved) {
55226
+ const repoPath = rel === "" ? bridgeResolved : path81.join(bridgeResolved, rel);
55227
+ const resolved = path81.resolve(repoPath);
55228
+ if (!resolved.startsWith(bridgeResolved + path81.sep) && resolved !== bridgeResolved) {
55560
55229
  return [];
55561
55230
  }
55562
55231
  return listRepoBranchRefs(resolved);
55563
55232
  }
55564
55233
 
55565
- // ../bridge/src/routing/handlers/bridge-git-context-messages.ts
55234
+ // ../bridge/src/connection/routing/handlers/bridge-git-context-messages.ts
55566
55235
  function handleBridgeGitContextRequestMessage(msg, getWs) {
55567
55236
  void (async () => {
55568
55237
  const socket = getWs();
@@ -55606,8 +55275,8 @@ function handleListRepoBranchesRequestMessage(msg, getWs) {
55606
55275
  }
55607
55276
 
55608
55277
  // ../bridge/src/git/checkout/bridge-git-checkout.ts
55609
- import * as fs60 from "node:fs/promises";
55610
- import * as path85 from "node:path";
55278
+ import * as fs58 from "node:fs/promises";
55279
+ import * as path83 from "node:path";
55611
55280
 
55612
55281
  // ../bridge/src/git/checkout/normalize-clone-url.ts
55613
55282
  function normalizeCloneUrl(url2) {
@@ -55627,12 +55296,12 @@ function cloneUrlWithHttpsAuth(url2, auth) {
55627
55296
  }
55628
55297
 
55629
55298
  // ../bridge/src/git/checkout/resolve-checkout-target.ts
55630
- import * as fs59 from "node:fs/promises";
55631
- import * as path84 from "node:path";
55299
+ import * as fs57 from "node:fs/promises";
55300
+ import * as path82 from "node:path";
55632
55301
  var FOLDER_NAME_RE = /^[A-Za-z0-9._-]+$/;
55633
55302
  async function pathExists(p) {
55634
55303
  try {
55635
- await fs59.access(p);
55304
+ await fs57.access(p);
55636
55305
  return true;
55637
55306
  } catch {
55638
55307
  return false;
@@ -55644,7 +55313,7 @@ async function resolveCheckoutTarget(opts) {
55644
55313
  if (await isGitRepoDirectory(bridgeRoot)) {
55645
55314
  throw new Error("Bridge root is already a git repository");
55646
55315
  }
55647
- const entries = await fs59.readdir(bridgeRoot).catch(() => []);
55316
+ const entries = await fs57.readdir(bridgeRoot).catch(() => []);
55648
55317
  if (entries.length > 0) {
55649
55318
  throw new Error("Bridge root must be empty to initialize a monorepo checkout");
55650
55319
  }
@@ -55657,8 +55326,8 @@ async function resolveCheckoutTarget(opts) {
55657
55326
  if (await isGitRepoDirectory(bridgeRoot)) {
55658
55327
  throw new Error("Cannot add a nested repo while the bridge root is itself a git repository");
55659
55328
  }
55660
- const targetDir = path84.resolve(bridgeRoot, folder);
55661
- if (!targetDir.startsWith(bridgeRoot + path84.sep)) {
55329
+ const targetDir = path82.resolve(bridgeRoot, folder);
55330
+ if (!targetDir.startsWith(bridgeRoot + path82.sep)) {
55662
55331
  throw new Error("Invalid folderName");
55663
55332
  }
55664
55333
  if (await pathExists(targetDir)) {
@@ -55677,10 +55346,10 @@ async function bridgeGitCheckout(params) {
55677
55346
  });
55678
55347
  const folderName = relPath === "." ? "repo" : relPath;
55679
55348
  beginPendingCheckout({ relPath, folderName, remoteUrl: cloneUrl });
55680
- const parent = path85.dirname(targetDir);
55681
- await fs60.mkdir(parent, { recursive: true });
55349
+ const parent = path83.dirname(targetDir);
55350
+ await fs58.mkdir(parent, { recursive: true });
55682
55351
  if (relPath !== ".") {
55683
- await fs60.mkdir(targetDir, { recursive: true });
55352
+ await fs58.mkdir(targetDir, { recursive: true });
55684
55353
  }
55685
55354
  const url2 = cloneUrlWithHttpsAuth(cloneUrl, params.auth ?? null);
55686
55355
  try {
@@ -55691,7 +55360,7 @@ async function bridgeGitCheckout(params) {
55691
55360
  return { relPath, folderName };
55692
55361
  } catch (e) {
55693
55362
  if (relPath !== ".") {
55694
- await fs60.rm(targetDir, { recursive: true, force: true }).catch(() => void 0);
55363
+ await fs58.rm(targetDir, { recursive: true, force: true }).catch(() => void 0);
55695
55364
  }
55696
55365
  const msg = e instanceof Error ? e.message : String(e);
55697
55366
  throw new Error(
@@ -55702,7 +55371,7 @@ async function bridgeGitCheckout(params) {
55702
55371
  }
55703
55372
  }
55704
55373
 
55705
- // ../bridge/src/routing/handlers/bridge-git-checkout-messages.ts
55374
+ // ../bridge/src/connection/routing/handlers/bridge-git-checkout-messages.ts
55706
55375
  function handleBridgeGitCheckoutRequestMessage(msg, getWs) {
55707
55376
  void (async () => {
55708
55377
  const socket = getWs();
@@ -55742,7 +55411,7 @@ function handleBridgeGitCheckoutRequestMessage(msg, getWs) {
55742
55411
  })();
55743
55412
  }
55744
55413
 
55745
- // ../bridge/src/routing/dispatch/file-browser.ts
55414
+ // ../bridge/src/connection/routing/dispatch/file-browser.ts
55746
55415
  function dispatchBridgeFileBrowserMessage(msg, deps) {
55747
55416
  switch (msg.type) {
55748
55417
  case "file_browser_request":
@@ -55766,12 +55435,13 @@ function dispatchBridgeFileBrowserMessage(msg, deps) {
55766
55435
  }
55767
55436
  }
55768
55437
 
55769
- // ../bridge/src/routing/dispatch/index.ts
55438
+ // ../bridge/src/connection/routing/dispatch/index.ts
55770
55439
  function dispatchBridgeMessage(msg, deps) {
55771
55440
  switch (msg.type) {
55772
55441
  case "auth_token":
55773
55442
  case "bridge_identified":
55774
55443
  case "installed_agent_auth_sync":
55444
+ case "install_agent":
55775
55445
  case "ha":
55776
55446
  dispatchBridgeConnectionMessage(msg, deps);
55777
55447
  break;
@@ -55791,13 +55461,6 @@ function dispatchBridgeMessage(msg, deps) {
55791
55461
  case "cursor_request_response":
55792
55462
  dispatchBridgeSessionMessage(msg, deps);
55793
55463
  break;
55794
- case "skill_call":
55795
- case "skill_layout_request":
55796
- case "install_skills":
55797
- case "install_agent":
55798
- case "refresh_local_skills":
55799
- dispatchBridgeSkillsMessage(msg, deps);
55800
- break;
55801
55464
  case "file_browser_request":
55802
55465
  case "file_browser_search":
55803
55466
  case "code_nav":
@@ -55809,7 +55472,7 @@ function dispatchBridgeMessage(msg, deps) {
55809
55472
  }
55810
55473
  }
55811
55474
 
55812
- // ../bridge/src/routing/handle-bridge-message.ts
55475
+ // ../bridge/src/connection/routing/handle-bridge-message.ts
55813
55476
  function normalizeInboundBridgeWebSocketJson(data) {
55814
55477
  if (data === null || typeof data !== "object" || Array.isArray(data)) return data;
55815
55478
  const o = data;
@@ -55827,7 +55490,7 @@ function handleBridgeMessage(data, deps, sourceWs) {
55827
55490
  dispatchBridgeMessage(msg, deps);
55828
55491
  }
55829
55492
 
55830
- // ../bridge/src/connection/main-bridge-auth-refresh-handler.ts
55493
+ // ../bridge/src/connection/ws/main-bridge-auth-refresh-handler.ts
55831
55494
  function resetAfterAuthInvalid(params) {
55832
55495
  const { state } = params;
55833
55496
  state.reconnectAttempt = 0;
@@ -55874,7 +55537,7 @@ function createMainBridgeAuthRefreshHandler(params, connect) {
55874
55537
  };
55875
55538
  }
55876
55539
 
55877
- // ../bridge/src/connection/main-bridge-ws-close-handler.ts
55540
+ // ../bridge/src/connection/ws/main-bridge-ws-close-handler.ts
55878
55541
  function createMainBridgeCloseHandler(params, connect) {
55879
55542
  const { state, logFn, bridgeHeartbeat } = params;
55880
55543
  return (code, reason) => {
@@ -55912,7 +55575,7 @@ function createMainBridgeCloseHandler(params, connect) {
55912
55575
  };
55913
55576
  }
55914
55577
 
55915
- // ../bridge/src/connection/report-git-repos.ts
55578
+ // ../bridge/src/connection/reports/report-git-repos.ts
55916
55579
  function reportGitRepos(getWs, log2) {
55917
55580
  setImmediate(() => {
55918
55581
  discoverGitRepos().then((repos) => {
@@ -55933,7 +55596,7 @@ function reportGitRepos(getWs, log2) {
55933
55596
  });
55934
55597
  }
55935
55598
 
55936
- // ../bridge/src/connection/main-bridge-ws-open-handler.ts
55599
+ // ../bridge/src/connection/ws/main-bridge-ws-open-handler.ts
55937
55600
  function createMainBridgeOpenHandler(params) {
55938
55601
  const {
55939
55602
  state,
@@ -55978,7 +55641,7 @@ function createMainBridgeOpenHandler(params) {
55978
55641
  };
55979
55642
  }
55980
55643
 
55981
- // ../bridge/src/connection/main-bridge-ws-lifecycle.ts
55644
+ // ../bridge/src/connection/ws/main-bridge-ws-lifecycle.ts
55982
55645
  function createMainBridgeWebSocketLifecycle(params) {
55983
55646
  const {
55984
55647
  state,
@@ -56063,7 +55726,7 @@ function createMainBridgeWebSocketLifecycle(params) {
56063
55726
  return { connect };
56064
55727
  }
56065
55728
 
56066
- // ../bridge/src/connection/create-bridge-connection.ts
55729
+ // ../bridge/src/connection/runtime/create-bridge-connection.ts
56067
55730
  init_log();
56068
55731
  async function createBridgeConnection(options) {
56069
55732
  const { plugin, workspaceId, justAuthenticated, onAuthInvalid, persistTokens } = options;
@@ -56113,41 +55776,7 @@ async function createBridgeConnection(options) {
56113
55776
  };
56114
55777
  }
56115
55778
 
56116
- // ../bridge/src/e2e-certificates/key-command.ts
56117
- import * as readline4 from "node:readline";
56118
- function installE2eCertificateKeyCommand({
56119
- log: log2,
56120
- onOpenCertificate,
56121
- onInterrupt
56122
- }) {
56123
- if (!process.stdin.isTTY || typeof process.stdin.setRawMode !== "function") {
56124
- log2("[E2EE] Press c to import the E2EE key in a browser when running in an interactive terminal.");
56125
- return () => {
56126
- };
56127
- }
56128
- readline4.emitKeypressEvents(process.stdin);
56129
- process.stdin.setRawMode(true);
56130
- process.stdin.resume();
56131
- const onKeypress = (str, key) => {
56132
- if (key?.ctrl && key.name === "c") {
56133
- onInterrupt();
56134
- return;
56135
- }
56136
- if (!key?.ctrl && !key?.meta && (key?.name === "c" || str === "c")) {
56137
- onOpenCertificate();
56138
- }
56139
- };
56140
- process.stdin.on("keypress", onKeypress);
56141
- log2("[E2EE] Press c to import the active E2EE key into the browser.");
56142
- return () => {
56143
- process.stdin.off("keypress", onKeypress);
56144
- if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
56145
- process.stdin.setRawMode(false);
56146
- }
56147
- };
56148
- }
56149
-
56150
- // ../bridge/src/run-bridge-e2ee-key-command.ts
55779
+ // ../bridge/src/cli/run-bridge-e2ee-key-command.ts
56151
55780
  function installConnectedBridgeE2eeKeyCommand(params) {
56152
55781
  const openImport = params.plugin.cloud?.openCertificateImportUrl;
56153
55782
  if (!openImport) return () => {
@@ -56170,7 +55799,7 @@ function installConnectedBridgeE2eeKeyCommand(params) {
56170
55799
  });
56171
55800
  }
56172
55801
 
56173
- // ../bridge/src/run-bridge-connected-signals.ts
55802
+ // ../bridge/src/cli/teardown/run-bridge-connected-signals.ts
56174
55803
  init_log();
56175
55804
  init_cli_process_interrupt();
56176
55805
  function installConnectedBridgeSignals(params) {
@@ -56204,7 +55833,7 @@ function installConnectedBridgeSignals(params) {
56204
55833
  };
56205
55834
  }
56206
55835
 
56207
- // ../bridge/src/run-bridge-on-auth-invalid.ts
55836
+ // ../bridge/src/cli/teardown/run-bridge-on-auth-invalid.ts
56208
55837
  init_cli_process_interrupt();
56209
55838
  async function closeBridgeForReauth(params) {
56210
55839
  params.log("[Bridge service] Access token invalid or revoked; re-authenticating\u2026");
@@ -56215,7 +55844,7 @@ async function closeBridgeForReauth(params) {
56215
55844
  params.endConnectedSession();
56216
55845
  }
56217
55846
 
56218
- // ../bridge/src/run-bridge-connected.ts
55847
+ // ../bridge/src/cli/run-bridge-connected.ts
56219
55848
  init_cli_database();
56220
55849
  async function runConnectedBridge(options, restartWithoutAuth) {
56221
55850
  const { plugin, workspaceId, authToken, refreshToken, justAuthenticated, worktreesRootPath, e2eCertificate } = options;
@@ -56290,7 +55919,7 @@ async function runConnectedBridge(options, restartWithoutAuth) {
56290
55919
  await restartWithoutAuth({ plugin, worktreesRootPath, e2eCertificate });
56291
55920
  }
56292
55921
 
56293
- // ../bridge/src/run-bridge.ts
55922
+ // ../bridge/src/cli/run-bridge.ts
56294
55923
  init_cli_process_interrupt();
56295
55924
  async function runBridge(options) {
56296
55925
  installBridgeProcessResilience();
@@ -56367,99 +55996,13 @@ function startStreamingProxy(ws, log2, pr) {
56367
55996
  });
56368
55997
  }
56369
55998
 
56370
- // ../bridge/src/e2e-certificates/certificates.ts
56371
- import * as fs61 from "node:fs/promises";
56372
- import * as path86 from "node:path";
56373
- var E2E_CERTIFICATE_ALGORITHM = "A1";
56374
- var CERTIFICATE_FILE_EXTENSIONS = /* @__PURE__ */ new Set([".pem", ".key", ".crt"]);
56375
- function certificateFromKey({
56376
- raw,
56377
- name,
56378
- createdAt
56379
- }) {
56380
- try {
56381
- const key = parseE2eeKeyRecord(raw, name);
56382
- return {
56383
- ...key,
56384
- name: key.name || name,
56385
- algorithm: E2E_CERTIFICATE_ALGORITHM,
56386
- pemBundle: serializeE2eeKeyRecord({ ...key, createdAt: key.createdAt || createdAt })
56387
- };
56388
- } catch {
56389
- return void 0;
56390
- }
56391
- }
56392
- function baseNameForCertificate(fileName) {
56393
- return path86.basename(fileName, path86.extname(fileName)) || "BuildAutomaton E2EE certificate";
56394
- }
56395
- async function readCertificateFiles(directory) {
56396
- let entries;
56397
- try {
56398
- entries = await fs61.readdir(directory, { withFileTypes: true });
56399
- } catch (err) {
56400
- const nodeErr = err;
56401
- if (nodeErr.code === "ENOENT") return [];
56402
- throw err;
56403
- }
56404
- const certificates = [];
56405
- for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
56406
- if (!entry.isFile() || !CERTIFICATE_FILE_EXTENSIONS.has(path86.extname(entry.name).toLowerCase())) continue;
56407
- const filePath = path86.join(directory, entry.name);
56408
- const raw = await fs61.readFile(filePath, "utf8").catch(() => void 0);
56409
- if (!raw) continue;
56410
- const stat3 = await fs61.stat(filePath).catch(() => void 0);
56411
- const certificate = certificateFromKey({
56412
- raw,
56413
- name: baseNameForCertificate(entry.name),
56414
- createdAt: stat3?.mtime?.toISOString() ?? (/* @__PURE__ */ new Date()).toISOString()
56415
- });
56416
- if (certificate) {
56417
- certificates.push(certificate);
56418
- }
56419
- }
56420
- return certificates;
56421
- }
56422
- function createCertificate(directory) {
56423
- const baseName = path86.basename(directory) || "BuildAutomaton E2EE certificate";
56424
- const key = createE2eeKeyRecord(baseName);
56425
- return {
56426
- ...key,
56427
- algorithm: E2E_CERTIFICATE_ALGORITHM,
56428
- pemBundle: serializeE2eeKeyRecord(key)
56429
- };
56430
- }
56431
- async function loadOrCreateE2eCertificates(directory) {
56432
- const resolved = path86.resolve(directory);
56433
- await fs61.mkdir(resolved, { recursive: true, mode: 448 });
56434
- const existing = await readCertificateFiles(resolved);
56435
- if (existing.length > 0) {
56436
- return {
56437
- directory: resolved,
56438
- certificates: existing,
56439
- activeCertificate: existing[0],
56440
- generated: false
56441
- };
56442
- }
56443
- const certificate = createCertificate(resolved);
56444
- const fileName = `buildautomaton-e2ee-key-${certificate.id.slice(0, 12)}.pem`;
56445
- await fs61.writeFile(path86.join(resolved, fileName), certificate.pemBundle, {
56446
- mode: 384
56447
- });
56448
- return {
56449
- directory: resolved,
56450
- certificates: [certificate],
56451
- activeCertificate: certificate,
56452
- generated: true
56453
- };
56454
- }
56455
-
56456
55999
  // src/config.ts
56457
- import fs62 from "node:fs";
56458
- import path87 from "node:path";
56000
+ import fs59 from "node:fs";
56001
+ import path84 from "node:path";
56459
56002
  import os9 from "node:os";
56460
56003
  function getConfigPath() {
56461
- const dir = path87.join(os9.homedir(), ".buildautomaton");
56462
- return path87.join(dir, "config.json");
56004
+ const dir = path84.join(os9.homedir(), ".buildautomaton");
56005
+ return path84.join(dir, "config.json");
56463
56006
  }
56464
56007
  function normalizeApiUrl(url2) {
56465
56008
  return url2.replace(/\/$/, "");
@@ -56467,7 +56010,7 @@ function normalizeApiUrl(url2) {
56467
56010
  function readRawConfig() {
56468
56011
  try {
56469
56012
  const p = getConfigPath();
56470
- const raw = fs62.readFileSync(p, "utf8");
56013
+ const raw = fs59.readFileSync(p, "utf8");
56471
56014
  return JSON.parse(raw);
56472
56015
  } catch {
56473
56016
  return null;
@@ -56495,14 +56038,14 @@ function readConfigForApi(apiUrl) {
56495
56038
  }
56496
56039
  function writeConfigForApi(apiUrl, auth) {
56497
56040
  const p = getConfigPath();
56498
- const dir = path87.dirname(p);
56041
+ const dir = path84.dirname(p);
56499
56042
  const key = normalizeApiUrl(apiUrl);
56500
56043
  const prev = readRawConfig() ?? {};
56501
56044
  const servers = { ...prev.servers ?? {}, [key]: { ...auth } };
56502
56045
  const next = { ...prev, servers };
56503
56046
  try {
56504
- if (!fs62.existsSync(dir)) fs62.mkdirSync(dir, { recursive: true });
56505
- fs62.writeFileSync(p, JSON.stringify(next, null, 2), "utf8");
56047
+ if (!fs59.existsSync(dir)) fs59.mkdirSync(dir, { recursive: true });
56048
+ fs59.writeFileSync(p, JSON.stringify(next, null, 2), "utf8");
56506
56049
  } catch (e) {
56507
56050
  console.error("Could not save authentication config:", e);
56508
56051
  }
@@ -56511,22 +56054,22 @@ function clearConfigForApi(apiUrl) {
56511
56054
  const key = normalizeApiUrl(apiUrl);
56512
56055
  try {
56513
56056
  const p = getConfigPath();
56514
- if (!fs62.existsSync(p)) return;
56057
+ if (!fs59.existsSync(p)) return;
56515
56058
  const prev = readRawConfig();
56516
56059
  if (!prev) return;
56517
56060
  const servers = { ...prev.servers ?? {} };
56518
56061
  delete servers[key];
56519
56062
  const next = { ...prev, servers };
56520
56063
  if (Object.keys(servers).length === 0 && !prev.workspaceId) {
56521
- fs62.unlinkSync(p);
56064
+ fs59.unlinkSync(p);
56522
56065
  return;
56523
56066
  }
56524
56067
  if (Object.keys(servers).length === 0 && prev.workspaceId && prev.apiUrl && normalizeApiUrl(prev.apiUrl) === key) {
56525
56068
  const { workspaceId: _w, token: _t, refreshToken: _r, apiUrl: _a4, ...rest } = prev;
56526
- fs62.writeFileSync(p, JSON.stringify(rest, null, 2), "utf8");
56069
+ fs59.writeFileSync(p, JSON.stringify(rest, null, 2), "utf8");
56527
56070
  return;
56528
56071
  }
56529
- fs62.writeFileSync(p, JSON.stringify(next, null, 2), "utf8");
56072
+ fs59.writeFileSync(p, JSON.stringify(next, null, 2), "utf8");
56530
56073
  } catch {
56531
56074
  }
56532
56075
  }
@@ -56534,30 +56077,30 @@ function clearConfigForApi(apiUrl) {
56534
56077
  // ../../node_modules/.pnpm/open@10.2.0/node_modules/open/index.js
56535
56078
  import process8 from "node:process";
56536
56079
  import { Buffer as Buffer3 } from "node:buffer";
56537
- import path88 from "node:path";
56080
+ import path85 from "node:path";
56538
56081
  import { fileURLToPath as fileURLToPath7 } from "node:url";
56539
56082
  import { promisify as promisify8 } from "node:util";
56540
56083
  import childProcess from "node:child_process";
56541
- import fs67, { constants as fsConstants2 } from "node:fs/promises";
56084
+ import fs64, { constants as fsConstants2 } from "node:fs/promises";
56542
56085
 
56543
56086
  // ../../node_modules/.pnpm/wsl-utils@0.1.0/node_modules/wsl-utils/index.js
56544
56087
  import process4 from "node:process";
56545
- import fs66, { constants as fsConstants } from "node:fs/promises";
56088
+ import fs63, { constants as fsConstants } from "node:fs/promises";
56546
56089
 
56547
56090
  // ../../node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.js
56548
56091
  import process3 from "node:process";
56549
56092
  import os10 from "node:os";
56550
- import fs65 from "node:fs";
56093
+ import fs62 from "node:fs";
56551
56094
 
56552
56095
  // ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
56553
- import fs64 from "node:fs";
56096
+ import fs61 from "node:fs";
56554
56097
 
56555
56098
  // ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
56556
- import fs63 from "node:fs";
56099
+ import fs60 from "node:fs";
56557
56100
  var isDockerCached;
56558
56101
  function hasDockerEnv() {
56559
56102
  try {
56560
- fs63.statSync("/.dockerenv");
56103
+ fs60.statSync("/.dockerenv");
56561
56104
  return true;
56562
56105
  } catch {
56563
56106
  return false;
@@ -56565,7 +56108,7 @@ function hasDockerEnv() {
56565
56108
  }
56566
56109
  function hasDockerCGroup() {
56567
56110
  try {
56568
- return fs63.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
56111
+ return fs60.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
56569
56112
  } catch {
56570
56113
  return false;
56571
56114
  }
@@ -56581,7 +56124,7 @@ function isDocker() {
56581
56124
  var cachedResult;
56582
56125
  var hasContainerEnv = () => {
56583
56126
  try {
56584
- fs64.statSync("/run/.containerenv");
56127
+ fs61.statSync("/run/.containerenv");
56585
56128
  return true;
56586
56129
  } catch {
56587
56130
  return false;
@@ -56606,12 +56149,12 @@ var isWsl = () => {
56606
56149
  return true;
56607
56150
  }
56608
56151
  try {
56609
- if (fs65.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
56152
+ if (fs62.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
56610
56153
  return !isInsideContainer();
56611
56154
  }
56612
56155
  } catch {
56613
56156
  }
56614
- if (fs65.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs65.existsSync("/run/WSL")) {
56157
+ if (fs62.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs62.existsSync("/run/WSL")) {
56615
56158
  return !isInsideContainer();
56616
56159
  }
56617
56160
  return false;
@@ -56629,14 +56172,14 @@ var wslDrivesMountPoint = /* @__PURE__ */ (() => {
56629
56172
  const configFilePath2 = "/etc/wsl.conf";
56630
56173
  let isConfigFileExists = false;
56631
56174
  try {
56632
- await fs66.access(configFilePath2, fsConstants.F_OK);
56175
+ await fs63.access(configFilePath2, fsConstants.F_OK);
56633
56176
  isConfigFileExists = true;
56634
56177
  } catch {
56635
56178
  }
56636
56179
  if (!isConfigFileExists) {
56637
56180
  return defaultMountPoint;
56638
56181
  }
56639
- const configContent = await fs66.readFile(configFilePath2, { encoding: "utf8" });
56182
+ const configContent = await fs63.readFile(configFilePath2, { encoding: "utf8" });
56640
56183
  const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
56641
56184
  if (!configMountPoint) {
56642
56185
  return defaultMountPoint;
@@ -56790,8 +56333,8 @@ async function defaultBrowser2() {
56790
56333
 
56791
56334
  // ../../node_modules/.pnpm/open@10.2.0/node_modules/open/index.js
56792
56335
  var execFile7 = promisify8(childProcess.execFile);
56793
- var __dirname = path88.dirname(fileURLToPath7(import.meta.url));
56794
- var localXdgOpenPath = path88.join(__dirname, "xdg-open");
56336
+ var __dirname = path85.dirname(fileURLToPath7(import.meta.url));
56337
+ var localXdgOpenPath = path85.join(__dirname, "xdg-open");
56795
56338
  var { platform, arch } = process8;
56796
56339
  async function getWindowsDefaultBrowserFromWsl() {
56797
56340
  const powershellPath = await powerShellPath();
@@ -56941,7 +56484,7 @@ var baseOpen = async (options) => {
56941
56484
  const isBundled = !__dirname || __dirname === "/";
56942
56485
  let exeLocalXdgOpen = false;
56943
56486
  try {
56944
- await fs67.access(localXdgOpenPath, fsConstants2.X_OK);
56487
+ await fs64.access(localXdgOpenPath, fsConstants2.X_OK);
56945
56488
  exeLocalXdgOpen = true;
56946
56489
  } catch {
56947
56490
  }
@@ -57697,6 +57240,14 @@ function createBridgeMcpToolRegistry(shared) {
57697
57240
  };
57698
57241
  }
57699
57242
 
57243
+ // ../e2ee/src/encoding.ts
57244
+ function base64UrlEncode2(bytes) {
57245
+ let binary = "";
57246
+ for (let i = 0; i < bytes.length; i += 1) binary += String.fromCharCode(bytes[i]);
57247
+ const b64 = btoa(binary);
57248
+ return b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
57249
+ }
57250
+
57700
57251
  // src/agents/acp/fetch-session-attachments.ts
57701
57252
  function metaSaysEncrypted(meta3) {
57702
57253
  if (!meta3) return false;
@@ -57766,7 +57317,7 @@ async function fetchSessionAttachmentPayloadsForAgent(params) {
57766
57317
  if (!k || !n) {
57767
57318
  return { ok: false, error: "Invalid encrypted attachment metadata (missing key id or nonce)." };
57768
57319
  }
57769
- const c = base64UrlEncode(buf);
57320
+ const c = base64UrlEncode2(buf);
57770
57321
  imageBytes = e2ee.decryptEnvelopeToBuffer({ k, n, c });
57771
57322
  } else {
57772
57323
  imageBytes = buf;
@@ -58353,13 +57904,13 @@ function toTokens(auth) {
58353
57904
  }
58354
57905
 
58355
57906
  // src/cli/chdir-to-bridge-root.ts
58356
- import * as fs68 from "node:fs";
58357
- import * as path89 from "node:path";
57907
+ import * as fs65 from "node:fs";
57908
+ import * as path86 from "node:path";
58358
57909
  function chdirToBridgeRoot(bridgeRootOpt) {
58359
57910
  if (!bridgeRootOpt) return;
58360
- const resolved = path89.resolve(process.cwd(), bridgeRootOpt);
57911
+ const resolved = path86.resolve(process.cwd(), bridgeRootOpt);
58361
57912
  try {
58362
- if (!fs68.statSync(resolved).isDirectory()) {
57913
+ if (!fs65.statSync(resolved).isDirectory()) {
58363
57914
  console.error(`Bridge root is not a directory: ${resolved}`);
58364
57915
  process.exit(1);
58365
57916
  }
@@ -58393,7 +57944,7 @@ async function runCliAction(program2, opts) {
58393
57944
  initBridgeRoot();
58394
57945
  console.log(colorize(GOLDEN_YELLOW, `[Bridge] Using ${getBridgeRoot()} as the bridge root.`));
58395
57946
  let worktreesRootPath;
58396
- if (opts.worktreesRoot?.trim()) worktreesRootPath = path90.resolve(opts.worktreesRoot.trim());
57947
+ if (opts.worktreesRoot?.trim()) worktreesRootPath = path87.resolve(opts.worktreesRoot.trim());
58397
57948
  const e2eCertificates = opts.e2eeCertificatesDir?.trim() ? await loadOrCreateE2eCertificates(opts.e2eeCertificatesDir.trim()) : void 0;
58398
57949
  if (e2eCertificates) {
58399
57950
  const action = e2eCertificates.generated ? "Generated" : "Loaded";