@buildautomaton/cli 0.1.58 → 0.1.60

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,7 +973,7 @@ 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 path75 = __require("node:path");
976
+ var path76 = __require("node:path");
977
977
  var fs53 = __require("node:fs");
978
978
  var process8 = __require("node:process");
979
979
  var { Argument: Argument2, humanReadableArgName } = require_argument();
@@ -1906,9 +1906,9 @@ 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 = path75.resolve(baseDir, baseName);
1909
+ const localBin = path76.resolve(baseDir, baseName);
1910
1910
  if (fs53.existsSync(localBin)) return localBin;
1911
- if (sourceExt.includes(path75.extname(baseName))) return void 0;
1911
+ if (sourceExt.includes(path76.extname(baseName))) return void 0;
1912
1912
  const foundExt = sourceExt.find(
1913
1913
  (ext) => fs53.existsSync(`${localBin}${ext}`)
1914
1914
  );
@@ -1926,17 +1926,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
1926
1926
  } catch (err) {
1927
1927
  resolvedScriptPath = this._scriptPath;
1928
1928
  }
1929
- executableDir = path75.resolve(
1930
- path75.dirname(resolvedScriptPath),
1929
+ executableDir = path76.resolve(
1930
+ path76.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 = path75.basename(
1937
+ const legacyName = path76.basename(
1938
1938
  this._scriptPath,
1939
- path75.extname(this._scriptPath)
1939
+ path76.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(path75.extname(executableFile));
1950
+ launchWithNode = sourceExt.includes(path76.extname(executableFile));
1951
1951
  let proc;
1952
1952
  if (process8.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 = path75.basename(filename, path75.extname(filename));
2790
+ this._name = path76.basename(filename, path76.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(path76) {
2805
- if (path76 === void 0) return this._executableDir;
2806
- this._executableDir = path76;
2804
+ executableDir(path77) {
2805
+ if (path77 === void 0) return this._executableDir;
2806
+ this._executableDir = path77;
2807
2807
  return this;
2808
2808
  }
2809
2809
  /**
@@ -7061,8 +7061,8 @@ var init_parseUtil = __esm({
7061
7061
  init_errors();
7062
7062
  init_en();
7063
7063
  makeIssue = (params) => {
7064
- const { data, path: path75, errorMaps, issueData } = params;
7065
- const fullPath = [...path75, ...issueData.path || []];
7064
+ const { data, path: path76, errorMaps, issueData } = params;
7065
+ const fullPath = [...path76, ...issueData.path || []];
7066
7066
  const fullIssue = {
7067
7067
  ...issueData,
7068
7068
  path: fullPath
@@ -7370,11 +7370,11 @@ var init_types = __esm({
7370
7370
  init_parseUtil();
7371
7371
  init_util();
7372
7372
  ParseInputLazyPath = class {
7373
- constructor(parent, value, path75, key) {
7373
+ constructor(parent, value, path76, key) {
7374
7374
  this._cachedPath = [];
7375
7375
  this.parent = parent;
7376
7376
  this.data = value;
7377
- this._path = path75;
7377
+ this._path = path76;
7378
7378
  this._key = key;
7379
7379
  }
7380
7380
  get path() {
@@ -11099,10 +11099,10 @@ function assignProp(target, prop, value) {
11099
11099
  configurable: true
11100
11100
  });
11101
11101
  }
11102
- function getElementAtPath(obj, path75) {
11103
- if (!path75)
11102
+ function getElementAtPath(obj, path76) {
11103
+ if (!path76)
11104
11104
  return obj;
11105
- return path75.reduce((acc, key) => acc?.[key], obj);
11105
+ return path76.reduce((acc, key) => acc?.[key], obj);
11106
11106
  }
11107
11107
  function promiseAllObject(promisesObj) {
11108
11108
  const keys = Object.keys(promisesObj);
@@ -11351,11 +11351,11 @@ function aborted(x, startIndex = 0) {
11351
11351
  }
11352
11352
  return false;
11353
11353
  }
11354
- function prefixIssues(path75, issues) {
11354
+ function prefixIssues(path76, issues) {
11355
11355
  return issues.map((iss) => {
11356
11356
  var _a2;
11357
11357
  (_a2 = iss).path ?? (_a2.path = []);
11358
- iss.path.unshift(path75);
11358
+ iss.path.unshift(path76);
11359
11359
  return iss;
11360
11360
  });
11361
11361
  }
@@ -11544,7 +11544,7 @@ function treeifyError(error40, _mapper) {
11544
11544
  return issue2.message;
11545
11545
  };
11546
11546
  const result = { errors: [] };
11547
- const processError = (error41, path75 = []) => {
11547
+ const processError = (error41, path76 = []) => {
11548
11548
  var _a2, _b;
11549
11549
  for (const issue2 of error41.issues) {
11550
11550
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -11554,7 +11554,7 @@ function treeifyError(error40, _mapper) {
11554
11554
  } else if (issue2.code === "invalid_element") {
11555
11555
  processError({ issues: issue2.issues }, issue2.path);
11556
11556
  } else {
11557
- const fullpath = [...path75, ...issue2.path];
11557
+ const fullpath = [...path76, ...issue2.path];
11558
11558
  if (fullpath.length === 0) {
11559
11559
  result.errors.push(mapper(issue2));
11560
11560
  continue;
@@ -11584,9 +11584,9 @@ function treeifyError(error40, _mapper) {
11584
11584
  processError(error40);
11585
11585
  return result;
11586
11586
  }
11587
- function toDotPath(path75) {
11587
+ function toDotPath(path76) {
11588
11588
  const segs = [];
11589
- for (const seg of path75) {
11589
+ for (const seg of path76) {
11590
11590
  if (typeof seg === "number")
11591
11591
  segs.push(`[${seg}]`);
11592
11592
  else if (typeof seg === "symbol")
@@ -24592,7 +24592,7 @@ var require_ignore = __commonJS({
24592
24592
  // path matching.
24593
24593
  // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
24594
24594
  // @returns {TestResult} true if a file is ignored
24595
- test(path75, checkUnignored, mode) {
24595
+ test(path76, checkUnignored, mode) {
24596
24596
  let ignored = false;
24597
24597
  let unignored = false;
24598
24598
  let matchedRule;
@@ -24601,7 +24601,7 @@ var require_ignore = __commonJS({
24601
24601
  if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
24602
24602
  return;
24603
24603
  }
24604
- const matched = rule[mode].test(path75);
24604
+ const matched = rule[mode].test(path76);
24605
24605
  if (!matched) {
24606
24606
  return;
24607
24607
  }
@@ -24622,17 +24622,17 @@ var require_ignore = __commonJS({
24622
24622
  var throwError = (message, Ctor) => {
24623
24623
  throw new Ctor(message);
24624
24624
  };
24625
- var checkPath = (path75, originalPath, doThrow) => {
24626
- if (!isString(path75)) {
24625
+ var checkPath = (path76, originalPath, doThrow) => {
24626
+ if (!isString(path76)) {
24627
24627
  return doThrow(
24628
24628
  `path must be a string, but got \`${originalPath}\``,
24629
24629
  TypeError
24630
24630
  );
24631
24631
  }
24632
- if (!path75) {
24632
+ if (!path76) {
24633
24633
  return doThrow(`path must not be empty`, TypeError);
24634
24634
  }
24635
- if (checkPath.isNotRelative(path75)) {
24635
+ if (checkPath.isNotRelative(path76)) {
24636
24636
  const r = "`path.relative()`d";
24637
24637
  return doThrow(
24638
24638
  `path should be a ${r} string, but got "${originalPath}"`,
@@ -24641,7 +24641,7 @@ var require_ignore = __commonJS({
24641
24641
  }
24642
24642
  return true;
24643
24643
  };
24644
- var isNotRelative = (path75) => REGEX_TEST_INVALID_PATH.test(path75);
24644
+ var isNotRelative = (path76) => REGEX_TEST_INVALID_PATH.test(path76);
24645
24645
  checkPath.isNotRelative = isNotRelative;
24646
24646
  checkPath.convert = (p) => p;
24647
24647
  var Ignore = class {
@@ -24671,19 +24671,19 @@ var require_ignore = __commonJS({
24671
24671
  }
24672
24672
  // @returns {TestResult}
24673
24673
  _test(originalPath, cache2, checkUnignored, slices) {
24674
- const path75 = originalPath && checkPath.convert(originalPath);
24674
+ const path76 = originalPath && checkPath.convert(originalPath);
24675
24675
  checkPath(
24676
- path75,
24676
+ path76,
24677
24677
  originalPath,
24678
24678
  this._strictPathCheck ? throwError : RETURN_FALSE
24679
24679
  );
24680
- return this._t(path75, cache2, checkUnignored, slices);
24680
+ return this._t(path76, cache2, checkUnignored, slices);
24681
24681
  }
24682
- checkIgnore(path75) {
24683
- if (!REGEX_TEST_TRAILING_SLASH.test(path75)) {
24684
- return this.test(path75);
24682
+ checkIgnore(path76) {
24683
+ if (!REGEX_TEST_TRAILING_SLASH.test(path76)) {
24684
+ return this.test(path76);
24685
24685
  }
24686
- const slices = path75.split(SLASH).filter(Boolean);
24686
+ const slices = path76.split(SLASH).filter(Boolean);
24687
24687
  slices.pop();
24688
24688
  if (slices.length) {
24689
24689
  const parent = this._t(
@@ -24696,18 +24696,18 @@ var require_ignore = __commonJS({
24696
24696
  return parent;
24697
24697
  }
24698
24698
  }
24699
- return this._rules.test(path75, false, MODE_CHECK_IGNORE);
24699
+ return this._rules.test(path76, false, MODE_CHECK_IGNORE);
24700
24700
  }
24701
- _t(path75, cache2, checkUnignored, slices) {
24702
- if (path75 in cache2) {
24703
- return cache2[path75];
24701
+ _t(path76, cache2, checkUnignored, slices) {
24702
+ if (path76 in cache2) {
24703
+ return cache2[path76];
24704
24704
  }
24705
24705
  if (!slices) {
24706
- slices = path75.split(SLASH).filter(Boolean);
24706
+ slices = path76.split(SLASH).filter(Boolean);
24707
24707
  }
24708
24708
  slices.pop();
24709
24709
  if (!slices.length) {
24710
- return cache2[path75] = this._rules.test(path75, checkUnignored, MODE_IGNORE);
24710
+ return cache2[path76] = this._rules.test(path76, checkUnignored, MODE_IGNORE);
24711
24711
  }
24712
24712
  const parent = this._t(
24713
24713
  slices.join(SLASH) + SLASH,
@@ -24715,29 +24715,29 @@ var require_ignore = __commonJS({
24715
24715
  checkUnignored,
24716
24716
  slices
24717
24717
  );
24718
- return cache2[path75] = parent.ignored ? parent : this._rules.test(path75, checkUnignored, MODE_IGNORE);
24718
+ return cache2[path76] = parent.ignored ? parent : this._rules.test(path76, checkUnignored, MODE_IGNORE);
24719
24719
  }
24720
- ignores(path75) {
24721
- return this._test(path75, this._ignoreCache, false).ignored;
24720
+ ignores(path76) {
24721
+ return this._test(path76, this._ignoreCache, false).ignored;
24722
24722
  }
24723
24723
  createFilter() {
24724
- return (path75) => !this.ignores(path75);
24724
+ return (path76) => !this.ignores(path76);
24725
24725
  }
24726
24726
  filter(paths) {
24727
24727
  return makeArray(paths).filter(this.createFilter());
24728
24728
  }
24729
24729
  // @returns {TestResult}
24730
- test(path75) {
24731
- return this._test(path75, this._testCache, true);
24730
+ test(path76) {
24731
+ return this._test(path76, this._testCache, true);
24732
24732
  }
24733
24733
  };
24734
24734
  var factory = (options) => new Ignore(options);
24735
- var isPathValid = (path75) => checkPath(path75 && checkPath.convert(path75), path75, RETURN_FALSE);
24735
+ var isPathValid = (path76) => checkPath(path76 && checkPath.convert(path76), path76, RETURN_FALSE);
24736
24736
  var setupWindows = () => {
24737
24737
  const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
24738
24738
  checkPath.convert = makePosix;
24739
24739
  const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
24740
- checkPath.isNotRelative = (path75) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path75) || isNotRelative(path75);
24740
+ checkPath.isNotRelative = (path76) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path76) || isNotRelative(path76);
24741
24741
  };
24742
24742
  if (
24743
24743
  // Detect `process` so that it can run in browsers.
@@ -25526,10 +25526,10 @@ var require_src2 = __commonJS({
25526
25526
  var fs_1 = __require("fs");
25527
25527
  var debug_1 = __importDefault(require_src());
25528
25528
  var log2 = debug_1.default("@kwsites/file-exists");
25529
- function check2(path75, isFile, isDirectory) {
25530
- log2(`checking %s`, path75);
25529
+ function check2(path76, isFile, isDirectory) {
25530
+ log2(`checking %s`, path76);
25531
25531
  try {
25532
- const stat3 = fs_1.statSync(path75);
25532
+ const stat3 = fs_1.statSync(path76);
25533
25533
  if (stat3.isFile() && isFile) {
25534
25534
  log2(`[OK] path represents a file`);
25535
25535
  return true;
@@ -25549,8 +25549,8 @@ var require_src2 = __commonJS({
25549
25549
  throw e;
25550
25550
  }
25551
25551
  }
25552
- function exists2(path75, type = exports.READABLE) {
25553
- return check2(path75, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
25552
+ function exists2(path76, type = exports.READABLE) {
25553
+ return check2(path76, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
25554
25554
  }
25555
25555
  exports.exists = exists2;
25556
25556
  exports.FILE = 1;
@@ -25631,7 +25631,7 @@ var {
25631
25631
  } = import_index.default;
25632
25632
 
25633
25633
  // src/cli-version.ts
25634
- var CLI_VERSION = "0.1.58".length > 0 ? "0.1.58" : "0.0.0-dev";
25634
+ var CLI_VERSION = "0.1.60".length > 0 ? "0.1.60" : "0.0.0-dev";
25635
25635
 
25636
25636
  // src/cli/defaults.ts
25637
25637
  var DEFAULT_API_URL = process.env.BUILDAUTOMATON_API_URL ?? "https://api.buildautomaton.com";
@@ -25639,7 +25639,7 @@ var DEFAULT_FIREHOSE_URL = "https://buildautomaton-firehose.fly.dev";
25639
25639
 
25640
25640
  // src/cli/run-cli-action.ts
25641
25641
  import * as fs52 from "node:fs";
25642
- import * as path74 from "node:path";
25642
+ import * as path75 from "node:path";
25643
25643
 
25644
25644
  // src/cli-log-level.ts
25645
25645
  var verbosity = "info";
@@ -27439,8 +27439,8 @@ function runPendingAuth(options) {
27439
27439
  };
27440
27440
  }
27441
27441
 
27442
- // src/dev-servers/manager/dev-server-constants.ts
27443
- var BRIDGE_CLOSE_DEV_SERVER_GRACE_MS = 0;
27442
+ // src/preview-environments/manager/preview-environment-constants.ts
27443
+ var BRIDGE_CLOSE_PREVIEW_ENVIRONMENT_GRACE_MS = 0;
27444
27444
  var BRIDGE_SHUTDOWN_GRACE_MS = 8e3;
27445
27445
 
27446
27446
  // src/runtime/cli-process-interrupt.ts
@@ -27859,7 +27859,7 @@ function readMigrationSql(filename, ...searchSubdirs) {
27859
27859
  join2(moduleDir, "..", sub, filename),
27860
27860
  join2(moduleDir, "..", "..", "dist", sub, filename)
27861
27861
  ]);
27862
- const resolved = candidates.find((path75) => existsSync(path75));
27862
+ const resolved = candidates.find((path76) => existsSync(path76));
27863
27863
  if (!resolved) {
27864
27864
  throw new Error(`Missing SQLite migration SQL: ${filename} (searched ${searchSubdirs.join(", ")})`);
27865
27865
  }
@@ -28147,7 +28147,7 @@ async function ensureCodeNavCacheSqliteInitialized() {
28147
28147
  }
28148
28148
 
28149
28149
  // src/connection/close-bridge-connection.ts
28150
- async function closeBridgeConnection(state, acpManager, devServerManager, log2) {
28150
+ async function closeBridgeConnection(state, acpManager, previewEnvironmentManager, log2) {
28151
28151
  requestCliImmediateShutdown();
28152
28152
  const say = log2 ?? logImmediate;
28153
28153
  say("Cleaning up connections\u2026");
@@ -28185,9 +28185,9 @@ async function closeBridgeConnection(state, acpManager, devServerManager, log2)
28185
28185
  }
28186
28186
  state.currentWs = null;
28187
28187
  }
28188
- if (devServerManager) {
28189
- say("Stopping local dev server processes\u2026");
28190
- await devServerManager.shutdownAllGraceful({ graceMs: BRIDGE_CLOSE_DEV_SERVER_GRACE_MS });
28188
+ if (previewEnvironmentManager) {
28189
+ say("Stopping local preview environment processes\u2026");
28190
+ await previewEnvironmentManager.shutdownAllGraceful({ graceMs: BRIDGE_CLOSE_PREVIEW_ENVIRONMENT_GRACE_MS });
28191
28191
  }
28192
28192
  try {
28193
28193
  closeAllCliSqliteConnections();
@@ -28888,9 +28888,9 @@ function parseChangeSummaryJson(raw, allowedPaths, options) {
28888
28888
  const rawPath = typeof o.path === "string" ? o.path.trim() : "";
28889
28889
  const summary = typeof o.summary === "string" ? o.summary.trim() : "";
28890
28890
  if (!rawPath || !summary) continue;
28891
- const path75 = skip ? normalizeRepoRelativePath(rawPath) || rawPath : resolveChangeSummaryPathAgainstAllowed(rawPath, allowedPaths);
28892
- if (!path75) continue;
28893
- rows.push({ path: path75, summary: clampSummaryToAtMostTwoLines(summary) });
28891
+ const path76 = skip ? normalizeRepoRelativePath(rawPath) || rawPath : resolveChangeSummaryPathAgainstAllowed(rawPath, allowedPaths);
28892
+ if (!path76) continue;
28893
+ rows.push({ path: path76, summary: clampSummaryToAtMostTwoLines(summary) });
28894
28894
  }
28895
28895
  return rows;
28896
28896
  }
@@ -35246,8 +35246,8 @@ async function execGitFile(args, options) {
35246
35246
  }
35247
35247
 
35248
35248
  // src/git/changes/parse/normalize-git-diff-path.ts
35249
- function normalizeGitDiffPath(path75) {
35250
- return path75.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
35249
+ function normalizeGitDiffPath(path76) {
35250
+ return path76.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
35251
35251
  }
35252
35252
 
35253
35253
  // src/git/changes/parse/parse-name-status-entries.ts
@@ -35534,9 +35534,9 @@ async function collectTurnGitDiffFromPreTurnSnapshot(options) {
35534
35534
  // src/agents/acp/put-summarize-change-summaries.ts
35535
35535
  async function putEncryptedChangeSummaryRows(params) {
35536
35536
  const base = params.apiBaseUrl.replace(/\/+$/, "");
35537
- const entries = params.rows.map(({ path: path75, summary }) => {
35537
+ const entries = params.rows.map(({ path: path76, summary }) => {
35538
35538
  const enc = params.e2ee.encryptFields({ summary }, ["summary"]);
35539
- return { path: path75, summary: JSON.stringify(enc) };
35539
+ return { path: path76, summary: JSON.stringify(enc) };
35540
35540
  });
35541
35541
  const res = await fetch(
35542
35542
  `${base}/internal/sessions/${encodeURIComponent(params.sessionId)}/follow-ups/summarize-changes`,
@@ -36569,8 +36569,8 @@ function pathspec(...paths) {
36569
36569
  cache.set(key, paths);
36570
36570
  return key;
36571
36571
  }
36572
- function isPathSpec(path75) {
36573
- return path75 instanceof String && cache.has(path75);
36572
+ function isPathSpec(path76) {
36573
+ return path76 instanceof String && cache.has(path76);
36574
36574
  }
36575
36575
  function toPaths(pathSpec) {
36576
36576
  return cache.get(pathSpec) || [];
@@ -36659,8 +36659,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
36659
36659
  function forEachLineWithContent(input, callback) {
36660
36660
  return toLinesWithContent(input, true).map((line) => callback(line));
36661
36661
  }
36662
- function folderExists(path75) {
36663
- return (0, import_file_exists.exists)(path75, import_file_exists.FOLDER);
36662
+ function folderExists(path76) {
36663
+ return (0, import_file_exists.exists)(path76, import_file_exists.FOLDER);
36664
36664
  }
36665
36665
  function append(target, item) {
36666
36666
  if (Array.isArray(target)) {
@@ -37064,8 +37064,8 @@ function checkIsRepoRootTask() {
37064
37064
  commands,
37065
37065
  format: "utf-8",
37066
37066
  onError,
37067
- parser(path75) {
37068
- return /^\.(git)?$/.test(path75.trim());
37067
+ parser(path76) {
37068
+ return /^\.(git)?$/.test(path76.trim());
37069
37069
  }
37070
37070
  };
37071
37071
  }
@@ -37499,11 +37499,11 @@ function parseGrep(grep) {
37499
37499
  const paths = /* @__PURE__ */ new Set();
37500
37500
  const results = {};
37501
37501
  forEachLineWithContent(grep, (input) => {
37502
- const [path75, line, preview] = input.split(NULL);
37503
- paths.add(path75);
37504
- (results[path75] = results[path75] || []).push({
37502
+ const [path76, line, preview] = input.split(NULL);
37503
+ paths.add(path76);
37504
+ (results[path76] = results[path76] || []).push({
37505
37505
  line: asNumber(line),
37506
- path: path75,
37506
+ path: path76,
37507
37507
  preview
37508
37508
  });
37509
37509
  });
@@ -38268,14 +38268,14 @@ var init_hash_object = __esm2({
38268
38268
  init_task();
38269
38269
  }
38270
38270
  });
38271
- function parseInit(bare, path75, text) {
38271
+ function parseInit(bare, path76, text) {
38272
38272
  const response = String(text).trim();
38273
38273
  let result;
38274
38274
  if (result = initResponseRegex.exec(response)) {
38275
- return new InitSummary(bare, path75, false, result[1]);
38275
+ return new InitSummary(bare, path76, false, result[1]);
38276
38276
  }
38277
38277
  if (result = reInitResponseRegex.exec(response)) {
38278
- return new InitSummary(bare, path75, true, result[1]);
38278
+ return new InitSummary(bare, path76, true, result[1]);
38279
38279
  }
38280
38280
  let gitDir = "";
38281
38281
  const tokens = response.split(" ");
@@ -38286,7 +38286,7 @@ function parseInit(bare, path75, text) {
38286
38286
  break;
38287
38287
  }
38288
38288
  }
38289
- return new InitSummary(bare, path75, /^re/i.test(response), gitDir);
38289
+ return new InitSummary(bare, path76, /^re/i.test(response), gitDir);
38290
38290
  }
38291
38291
  var InitSummary;
38292
38292
  var initResponseRegex;
@@ -38295,9 +38295,9 @@ var init_InitSummary = __esm2({
38295
38295
  "src/lib/responses/InitSummary.ts"() {
38296
38296
  "use strict";
38297
38297
  InitSummary = class {
38298
- constructor(bare, path75, existing, gitDir) {
38298
+ constructor(bare, path76, existing, gitDir) {
38299
38299
  this.bare = bare;
38300
- this.path = path75;
38300
+ this.path = path76;
38301
38301
  this.existing = existing;
38302
38302
  this.gitDir = gitDir;
38303
38303
  }
@@ -38309,7 +38309,7 @@ var init_InitSummary = __esm2({
38309
38309
  function hasBareCommand(command) {
38310
38310
  return command.includes(bareCommand);
38311
38311
  }
38312
- function initTask(bare = false, path75, customArgs) {
38312
+ function initTask(bare = false, path76, customArgs) {
38313
38313
  const commands = ["init", ...customArgs];
38314
38314
  if (bare && !hasBareCommand(commands)) {
38315
38315
  commands.splice(1, 0, bareCommand);
@@ -38318,7 +38318,7 @@ function initTask(bare = false, path75, customArgs) {
38318
38318
  commands,
38319
38319
  format: "utf-8",
38320
38320
  parser(text) {
38321
- return parseInit(commands.includes("--bare"), path75, text);
38321
+ return parseInit(commands.includes("--bare"), path76, text);
38322
38322
  }
38323
38323
  };
38324
38324
  }
@@ -39134,12 +39134,12 @@ var init_FileStatusSummary = __esm2({
39134
39134
  "use strict";
39135
39135
  fromPathRegex = /^(.+)\0(.+)$/;
39136
39136
  FileStatusSummary = class {
39137
- constructor(path75, index, working_dir) {
39138
- this.path = path75;
39137
+ constructor(path76, index, working_dir) {
39138
+ this.path = path76;
39139
39139
  this.index = index;
39140
39140
  this.working_dir = working_dir;
39141
39141
  if (index === "R" || working_dir === "R") {
39142
- const detail = fromPathRegex.exec(path75) || [null, path75, path75];
39142
+ const detail = fromPathRegex.exec(path76) || [null, path76, path76];
39143
39143
  this.from = detail[2] || "";
39144
39144
  this.path = detail[1] || "";
39145
39145
  }
@@ -39170,14 +39170,14 @@ function splitLine(result, lineStr) {
39170
39170
  default:
39171
39171
  return;
39172
39172
  }
39173
- function data(index, workingDir, path75) {
39173
+ function data(index, workingDir, path76) {
39174
39174
  const raw = `${index}${workingDir}`;
39175
39175
  const handler = parsers6.get(raw);
39176
39176
  if (handler) {
39177
- handler(result, path75);
39177
+ handler(result, path76);
39178
39178
  }
39179
39179
  if (raw !== "##" && raw !== "!!") {
39180
- result.files.push(new FileStatusSummary(path75, index, workingDir));
39180
+ result.files.push(new FileStatusSummary(path76, index, workingDir));
39181
39181
  }
39182
39182
  }
39183
39183
  }
@@ -39486,9 +39486,9 @@ var init_simple_git_api = __esm2({
39486
39486
  next
39487
39487
  );
39488
39488
  }
39489
- hashObject(path75, write) {
39489
+ hashObject(path76, write) {
39490
39490
  return this._runTask(
39491
- hashObjectTask(path75, write === true),
39491
+ hashObjectTask(path76, write === true),
39492
39492
  trailingFunctionArgument(arguments)
39493
39493
  );
39494
39494
  }
@@ -39841,8 +39841,8 @@ var init_branch = __esm2({
39841
39841
  }
39842
39842
  });
39843
39843
  function toPath(input) {
39844
- const path75 = input.trim().replace(/^["']|["']$/g, "");
39845
- return path75 && normalize3(path75);
39844
+ const path76 = input.trim().replace(/^["']|["']$/g, "");
39845
+ return path76 && normalize3(path76);
39846
39846
  }
39847
39847
  var parseCheckIgnore;
39848
39848
  var init_CheckIgnore = __esm2({
@@ -40156,8 +40156,8 @@ __export2(sub_module_exports, {
40156
40156
  subModuleTask: () => subModuleTask,
40157
40157
  updateSubModuleTask: () => updateSubModuleTask
40158
40158
  });
40159
- function addSubModuleTask(repo, path75) {
40160
- return subModuleTask(["add", repo, path75]);
40159
+ function addSubModuleTask(repo, path76) {
40160
+ return subModuleTask(["add", repo, path76]);
40161
40161
  }
40162
40162
  function initSubModuleTask(customArgs) {
40163
40163
  return subModuleTask(["init", ...customArgs]);
@@ -40490,8 +40490,8 @@ var require_git = __commonJS2({
40490
40490
  }
40491
40491
  return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
40492
40492
  };
40493
- Git2.prototype.submoduleAdd = function(repo, path75, then) {
40494
- return this._runTask(addSubModuleTask2(repo, path75), trailingFunctionArgument2(arguments));
40493
+ Git2.prototype.submoduleAdd = function(repo, path76, then) {
40494
+ return this._runTask(addSubModuleTask2(repo, path76), trailingFunctionArgument2(arguments));
40495
40495
  };
40496
40496
  Git2.prototype.submoduleUpdate = function(args, then) {
40497
40497
  return this._runTask(
@@ -41227,8 +41227,8 @@ function parseNumstatEntries(lines) {
41227
41227
  }
41228
41228
  function parseNumstat(lines) {
41229
41229
  const m = /* @__PURE__ */ new Map();
41230
- for (const [path75, entry] of parseNumstatEntries(lines)) {
41231
- m.set(path75, { additions: entry.additions, deletions: entry.deletions });
41230
+ for (const [path76, entry] of parseNumstatEntries(lines)) {
41231
+ m.set(path76, { additions: entry.additions, deletions: entry.deletions });
41232
41232
  }
41233
41233
  return m;
41234
41234
  }
@@ -42535,18 +42535,32 @@ import * as fs28 from "node:fs";
42535
42535
  // src/git/worktrees/worktree-remove.ts
42536
42536
  import * as fs27 from "node:fs";
42537
42537
 
42538
+ // src/worktrees/is-removable-session-worktree-checkout-path.ts
42539
+ import path43 from "node:path";
42540
+ function isBridgeRootCheckoutPath(checkoutPath) {
42541
+ return normalizeResolvedPath(checkoutPath) === normalizeResolvedPath(getBridgeRoot());
42542
+ }
42543
+ function isRemovableSessionWorktreeCheckoutPath(checkoutPath, worktreesRootPath) {
42544
+ if (isBridgeRootCheckoutPath(checkoutPath)) return false;
42545
+ const normalized = normalizeResolvedPath(checkoutPath);
42546
+ const worktreesRoot = normalizeResolvedPath(worktreesRootPath);
42547
+ const rel = path43.relative(worktreesRoot, normalized);
42548
+ if (rel === "" || rel.startsWith("..") || path43.isAbsolute(rel)) return false;
42549
+ return true;
42550
+ }
42551
+
42538
42552
  // src/git/worktrees/resolve-main-repo-from-git-file.ts
42539
42553
  import * as fs26 from "node:fs";
42540
- import * as path43 from "node:path";
42554
+ import * as path44 from "node:path";
42541
42555
  function resolveMainRepoFromWorktreeGitFile(wt) {
42542
- const gitDirFile = path43.join(wt, ".git");
42556
+ const gitDirFile = path44.join(wt, ".git");
42543
42557
  if (!fs26.existsSync(gitDirFile) || !fs26.statSync(gitDirFile).isFile()) return "";
42544
42558
  const first2 = fs26.readFileSync(gitDirFile, "utf8").trim();
42545
42559
  const m = first2.match(/^gitdir:\s*(.+)$/im);
42546
42560
  if (!m) return "";
42547
- const gitWorktreePath = path43.resolve(wt, m[1].trim());
42548
- const gitDir = path43.dirname(path43.dirname(gitWorktreePath));
42549
- return path43.dirname(gitDir);
42561
+ const gitWorktreePath = path44.resolve(wt, m[1].trim());
42562
+ const gitDir = path44.dirname(path44.dirname(gitWorktreePath));
42563
+ return path44.dirname(gitDir);
42550
42564
  }
42551
42565
 
42552
42566
  // src/git/worktrees/worktree-remove.ts
@@ -42554,32 +42568,44 @@ async function gitWorktreeRemoveForce(worktreePath) {
42554
42568
  const mainRepo = resolveMainRepoFromWorktreeGitFile(worktreePath);
42555
42569
  if (mainRepo) {
42556
42570
  await cliSimpleGit(mainRepo).raw(["worktree", "remove", "--force", worktreePath]);
42557
- } else {
42558
- fs27.rmSync(worktreePath, { recursive: true, force: true });
42571
+ return true;
42559
42572
  }
42573
+ if (isBridgeRootCheckoutPath(worktreePath)) return false;
42574
+ fs27.rmSync(worktreePath, { recursive: true, force: true });
42575
+ return true;
42560
42576
  }
42561
42577
 
42562
42578
  // src/worktrees/remove-session-worktrees.ts
42563
- async function removeSessionWorktrees(paths, log2) {
42579
+ async function removeSessionWorktrees(paths, worktreesRootPath, log2) {
42564
42580
  for (const wt of paths) {
42581
+ if (!isRemovableSessionWorktreeCheckoutPath(wt, worktreesRootPath)) {
42582
+ log2(`[worktrees] Skipping removal of ${wt} (bridge root or outside worktrees root).`);
42583
+ continue;
42584
+ }
42565
42585
  try {
42566
- await gitWorktreeRemoveForce(wt);
42567
- log2(`[worktrees] Removed worktree ${wt}`);
42586
+ const removed = await gitWorktreeRemoveForce(wt);
42587
+ if (removed) {
42588
+ log2(`[worktrees] Removed worktree ${wt}`);
42589
+ } else {
42590
+ log2(`[worktrees] Skipping removal of ${wt} (bridge root).`);
42591
+ }
42568
42592
  } catch (e) {
42569
42593
  log2(`[worktrees] Remove failed for ${wt}: ${e instanceof Error ? e.message : String(e)}`);
42570
- try {
42571
- fs28.rmSync(wt, { recursive: true, force: true });
42572
- } catch {
42594
+ if (isRemovableSessionWorktreeCheckoutPath(wt, worktreesRootPath)) {
42595
+ try {
42596
+ fs28.rmSync(wt, { recursive: true, force: true });
42597
+ } catch {
42598
+ }
42573
42599
  }
42574
42600
  }
42575
42601
  }
42576
42602
  }
42577
42603
 
42578
42604
  // src/worktrees/manager/git/remove-session-worktree-checkouts.ts
42579
- async function removeSessionWorktreeCheckouts(cache2, sessionId, log2) {
42605
+ async function removeSessionWorktreeCheckouts(cache2, sessionId, worktreesRootPath, log2) {
42580
42606
  const paths = cache2.clearSession(sessionId);
42581
42607
  if (!paths?.length) return;
42582
- await removeSessionWorktrees(paths, log2);
42608
+ await removeSessionWorktrees(paths, worktreesRootPath, log2);
42583
42609
  }
42584
42610
 
42585
42611
  // src/git/branches/rename-branch.ts
@@ -42612,11 +42638,11 @@ async function renameSessionWorktreeBranch(cache2, sessionId, newBranch, log2) {
42612
42638
 
42613
42639
  // src/worktrees/discovery/discover-session-worktree-on-disk.ts
42614
42640
  import * as fs32 from "node:fs";
42615
- import * as path48 from "node:path";
42641
+ import * as path49 from "node:path";
42616
42642
 
42617
42643
  // src/worktrees/discovery/collect-worktree-paths.ts
42618
42644
  import * as fs30 from "node:fs";
42619
- import * as path45 from "node:path";
42645
+ import * as path46 from "node:path";
42620
42646
 
42621
42647
  // src/worktrees/discovery/disk-walk-constants.ts
42622
42648
  var DISK_WALK_YIELD_EVERY = 64;
@@ -42645,7 +42671,7 @@ function shouldSkipDiskWalkEntry(name) {
42645
42671
 
42646
42672
  // src/worktrees/discovery/disk-walk-utils.ts
42647
42673
  import * as fs29 from "node:fs";
42648
- import * as path44 from "node:path";
42674
+ import * as path45 from "node:path";
42649
42675
  async function yieldDuringDiskWalk(state) {
42650
42676
  state.entries++;
42651
42677
  if (state.entries % DISK_WALK_YIELD_EVERY !== 0) return true;
@@ -42655,7 +42681,7 @@ async function yieldDuringDiskWalk(state) {
42655
42681
  }
42656
42682
  async function isGitDir(dirPath) {
42657
42683
  try {
42658
- await fs29.promises.access(path44.join(dirPath, ".git"));
42684
+ await fs29.promises.access(path45.join(dirPath, ".git"));
42659
42685
  return true;
42660
42686
  } catch {
42661
42687
  return false;
@@ -42669,7 +42695,7 @@ async function collectGitRepoRootsUnderDirectory(rootPath) {
42669
42695
  const walk = async (dir) => {
42670
42696
  if (!await yieldDuringDiskWalk(state)) return;
42671
42697
  if (await isGitDir(dir)) {
42672
- out.push(path45.resolve(dir));
42698
+ out.push(path46.resolve(dir));
42673
42699
  return;
42674
42700
  }
42675
42701
  let entries;
@@ -42680,12 +42706,12 @@ async function collectGitRepoRootsUnderDirectory(rootPath) {
42680
42706
  }
42681
42707
  for (const e of entries) {
42682
42708
  if (shouldSkipDiskWalkEntry(e.name)) continue;
42683
- const full = path45.join(dir, e.name);
42709
+ const full = path46.join(dir, e.name);
42684
42710
  if (!e.isDirectory()) continue;
42685
42711
  await walk(full);
42686
42712
  }
42687
42713
  };
42688
- await walk(path45.resolve(rootPath));
42714
+ await walk(path46.resolve(rootPath));
42689
42715
  return { paths: [...new Set(out)], entriesVisited: state.entries };
42690
42716
  }
42691
42717
  async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK_MAX_DEPTH) {
@@ -42702,10 +42728,10 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
42702
42728
  }
42703
42729
  for (const e of entries) {
42704
42730
  if (shouldSkipDiskWalkEntry(e.name)) continue;
42705
- const full = path45.join(dir, e.name);
42731
+ const full = path46.join(dir, e.name);
42706
42732
  if (!e.isDirectory()) continue;
42707
42733
  if (e.name === sessionId) {
42708
- if (await isGitDir(full)) out.push(path45.resolve(full));
42734
+ if (await isGitDir(full)) out.push(path46.resolve(full));
42709
42735
  continue;
42710
42736
  }
42711
42737
  if (await isGitDir(full)) continue;
@@ -42717,14 +42743,14 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
42717
42743
  }
42718
42744
 
42719
42745
  // src/worktrees/discovery/layout-keys-for-bridge-root.ts
42720
- import * as path46 from "node:path";
42746
+ import * as path47 from "node:path";
42721
42747
  function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
42722
- const bridge = path46.resolve(bridgeRoot);
42748
+ const bridge = path47.resolve(bridgeRoot);
42723
42749
  const preferred = getLauncherDirNameIfPresent(layout, bridgeRoot);
42724
42750
  const relevant = layout.launcherCwds.filter((e) => {
42725
- const entry = path46.resolve(e.absolutePath);
42726
- return bridge === entry || bridge.startsWith(entry + path46.sep) || entry.startsWith(bridge + path46.sep);
42727
- }).sort((a, b) => path46.resolve(b.absolutePath).length - path46.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
42751
+ const entry = path47.resolve(e.absolutePath);
42752
+ return bridge === entry || bridge.startsWith(entry + path47.sep) || entry.startsWith(bridge + path47.sep);
42753
+ }).sort((a, b) => path47.resolve(b.absolutePath).length - path47.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
42728
42754
  const ordered = [];
42729
42755
  const seen = /* @__PURE__ */ new Set();
42730
42756
  const add = (k) => {
@@ -42743,7 +42769,7 @@ function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
42743
42769
 
42744
42770
  // src/worktrees/discovery/try-binding-from-session-directory.ts
42745
42771
  import * as fs31 from "node:fs";
42746
- import * as path47 from "node:path";
42772
+ import * as path48 from "node:path";
42747
42773
  async function tryBindingFromSessionDirectory(sessionDir) {
42748
42774
  let st;
42749
42775
  try {
@@ -42754,7 +42780,7 @@ async function tryBindingFromSessionDirectory(sessionDir) {
42754
42780
  if (!st.isDirectory()) return null;
42755
42781
  const { paths: worktreePaths } = await collectGitRepoRootsUnderDirectory(sessionDir);
42756
42782
  if (worktreePaths.length === 0) return null;
42757
- const abs = path47.resolve(sessionDir);
42783
+ const abs = path48.resolve(sessionDir);
42758
42784
  return {
42759
42785
  sessionParentPath: abs,
42760
42786
  workingTreeRelRoot: abs,
@@ -42778,7 +42804,7 @@ async function discoverSessionWorktreeOnDisk(options) {
42778
42804
  try {
42779
42805
  for (const name of await fs32.promises.readdir(worktreesRootPath)) {
42780
42806
  if (name.startsWith(".")) continue;
42781
- const p = path48.join(worktreesRootPath, name);
42807
+ const p = path49.join(worktreesRootPath, name);
42782
42808
  let st;
42783
42809
  try {
42784
42810
  st = await fs32.promises.stat(p);
@@ -42795,7 +42821,7 @@ async function discoverSessionWorktreeOnDisk(options) {
42795
42821
  for (const key of keys) {
42796
42822
  if (isCliImmediateShutdownRequested()) return null;
42797
42823
  await yieldToEventLoop();
42798
- const layoutRoot = path48.join(worktreesRootPath, key);
42824
+ const layoutRoot = path49.join(worktreesRootPath, key);
42799
42825
  let layoutSt;
42800
42826
  try {
42801
42827
  layoutSt = await fs32.promises.stat(layoutRoot);
@@ -42803,16 +42829,16 @@ async function discoverSessionWorktreeOnDisk(options) {
42803
42829
  continue;
42804
42830
  }
42805
42831
  if (!layoutSt.isDirectory()) continue;
42806
- const sessionDir = path48.join(layoutRoot, sid);
42832
+ const sessionDir = path49.join(layoutRoot, sid);
42807
42833
  const nested = await tryBindingFromSessionDirectory(sessionDir);
42808
42834
  if (nested) return nested;
42809
42835
  const legacy = await collectWorktreeRootsNamed(layoutRoot, sid);
42810
42836
  if (legacy.paths.length > 0) {
42811
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path48.resolve(legacy.paths[0]);
42837
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path49.resolve(legacy.paths[0]);
42812
42838
  return {
42813
- sessionParentPath: path48.resolve(isolated),
42814
- workingTreeRelRoot: path48.resolve(layoutRoot),
42815
- repoCheckoutPaths: legacy.paths.map((p) => path48.resolve(p))
42839
+ sessionParentPath: path49.resolve(isolated),
42840
+ workingTreeRelRoot: path49.resolve(layoutRoot),
42841
+ repoCheckoutPaths: legacy.paths.map((p) => path49.resolve(p))
42816
42842
  };
42817
42843
  }
42818
42844
  }
@@ -42821,29 +42847,29 @@ async function discoverSessionWorktreeOnDisk(options) {
42821
42847
 
42822
42848
  // src/worktrees/discovery/discover-session-worktrees-under-session-worktree-root.ts
42823
42849
  import * as fs33 from "node:fs";
42824
- import * as path50 from "node:path";
42850
+ import * as path51 from "node:path";
42825
42851
 
42826
42852
  // src/worktrees/discovery/discover-legacy-binding-ascending-from-checkout.ts
42827
- import * as path49 from "node:path";
42853
+ import * as path50 from "node:path";
42828
42854
  async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPath) {
42829
42855
  const sid = sessionId.trim();
42830
42856
  if (!sid) return null;
42831
- const hintR = path49.resolve(checkoutPath);
42857
+ const hintR = path50.resolve(checkoutPath);
42832
42858
  let best = null;
42833
- let cur = path49.dirname(hintR);
42859
+ let cur = path50.dirname(hintR);
42834
42860
  for (let i = 0; i < 40; i++) {
42835
42861
  if (isCliImmediateShutdownRequested()) return best;
42836
42862
  await yieldToEventLoop();
42837
42863
  const paths = await collectWorktreeRootsNamed(cur, sid);
42838
- if (paths.paths.some((p) => path49.resolve(p) === hintR)) {
42839
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path49.resolve(paths.paths[0]);
42864
+ if (paths.paths.some((p) => path50.resolve(p) === hintR)) {
42865
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path50.resolve(paths.paths[0]);
42840
42866
  best = {
42841
- sessionParentPath: path49.resolve(isolated),
42842
- workingTreeRelRoot: path49.resolve(cur),
42843
- repoCheckoutPaths: paths.paths.map((p) => path49.resolve(p))
42867
+ sessionParentPath: path50.resolve(isolated),
42868
+ workingTreeRelRoot: path50.resolve(cur),
42869
+ repoCheckoutPaths: paths.paths.map((p) => path50.resolve(p))
42844
42870
  };
42845
42871
  }
42846
- const next = path49.dirname(cur);
42872
+ const next = path50.dirname(cur);
42847
42873
  if (next === cur) break;
42848
42874
  cur = next;
42849
42875
  }
@@ -42854,12 +42880,12 @@ async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPat
42854
42880
  async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionWorktreeRootPathOrHint, sessionId) {
42855
42881
  const sid = sessionId.trim();
42856
42882
  if (!sid) return null;
42857
- const hint = path50.resolve(sessionWorktreeRootPathOrHint);
42858
- const underHint = await tryBindingFromSessionDirectory(path50.join(hint, sid));
42883
+ const hint = path51.resolve(sessionWorktreeRootPathOrHint);
42884
+ const underHint = await tryBindingFromSessionDirectory(path51.join(hint, sid));
42859
42885
  if (underHint) return underHint;
42860
42886
  const direct = await tryBindingFromSessionDirectory(hint);
42861
42887
  if (direct) {
42862
- if (path50.basename(hint) === sid && await isGitDir(hint)) {
42888
+ if (path51.basename(hint) === sid && await isGitDir(hint)) {
42863
42889
  const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
42864
42890
  if (legacyFromCheckout && legacyFromCheckout.repoCheckoutPaths.length > direct.repoCheckoutPaths.length) {
42865
42891
  return legacyFromCheckout;
@@ -42867,7 +42893,7 @@ async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionWorktreeR
42867
42893
  }
42868
42894
  return direct;
42869
42895
  }
42870
- if (path50.basename(hint) === sid && await isGitDir(hint)) {
42896
+ if (path51.basename(hint) === sid && await isGitDir(hint)) {
42871
42897
  const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
42872
42898
  if (legacyFromCheckout) return legacyFromCheckout;
42873
42899
  }
@@ -42880,11 +42906,11 @@ async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionWorktreeR
42880
42906
  if (!st.isDirectory()) return null;
42881
42907
  const legacyPaths = await collectWorktreeRootsNamed(hint, sid);
42882
42908
  if (legacyPaths.paths.length === 0) return null;
42883
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path50.resolve(legacyPaths.paths[0]);
42909
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path51.resolve(legacyPaths.paths[0]);
42884
42910
  return {
42885
- sessionParentPath: path50.resolve(isolated),
42911
+ sessionParentPath: path51.resolve(isolated),
42886
42912
  workingTreeRelRoot: hint,
42887
- repoCheckoutPaths: legacyPaths.paths.map((p) => path50.resolve(p))
42913
+ repoCheckoutPaths: legacyPaths.paths.map((p) => path51.resolve(p))
42888
42914
  };
42889
42915
  }
42890
42916
 
@@ -42946,11 +42972,11 @@ function parseSessionParent(v) {
42946
42972
 
42947
42973
  // src/worktrees/prepare-new-session-worktrees.ts
42948
42974
  import * as fs35 from "node:fs";
42949
- import * as path52 from "node:path";
42975
+ import * as path53 from "node:path";
42950
42976
 
42951
42977
  // src/git/discover-repos.ts
42952
42978
  import * as fs34 from "node:fs";
42953
- import * as path51 from "node:path";
42979
+ import * as path52 from "node:path";
42954
42980
  var GIT_DISCOVER_YIELD_EVERY = 32;
42955
42981
  async function yieldGitDiscoverWork(entryCount) {
42956
42982
  if (entryCount > 0 && entryCount % GIT_DISCOVER_YIELD_EVERY === 0) {
@@ -42959,7 +42985,7 @@ async function yieldGitDiscoverWork(entryCount) {
42959
42985
  }
42960
42986
  async function discoverGitRepos(cwd = getBridgeRoot()) {
42961
42987
  const result = [];
42962
- const cwdResolved = path51.resolve(cwd);
42988
+ const cwdResolved = path52.resolve(cwd);
42963
42989
  if (await isGitRepoDirectory(cwdResolved)) {
42964
42990
  const remoteUrl = await getRemoteOriginUrl(cwdResolved);
42965
42991
  result.push({ absolutePath: cwdResolved, remoteUrl });
@@ -42974,7 +43000,7 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
42974
43000
  await yieldGitDiscoverWork(i + 1);
42975
43001
  const ent = entries[i];
42976
43002
  if (!ent.isDirectory()) continue;
42977
- const childPath2 = path51.join(cwdResolved, ent.name);
43003
+ const childPath2 = path52.join(cwdResolved, ent.name);
42978
43004
  if (await isGitRepoDirectory(childPath2)) {
42979
43005
  const remoteUrl = await getRemoteOriginUrl(childPath2);
42980
43006
  result.push({ absolutePath: childPath2, remoteUrl });
@@ -42983,12 +43009,12 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
42983
43009
  return result;
42984
43010
  }
42985
43011
  async function discoverGitReposUnderRoot(rootPath) {
42986
- const root = path51.resolve(rootPath);
43012
+ const root = path52.resolve(rootPath);
42987
43013
  const roots = [];
42988
43014
  let walkEntries = 0;
42989
43015
  async function walk(dir) {
42990
43016
  if (await isGitRepoDirectory(dir)) {
42991
- roots.push(path51.resolve(dir));
43017
+ roots.push(path52.resolve(dir));
42992
43018
  return;
42993
43019
  }
42994
43020
  let entries;
@@ -43001,7 +43027,7 @@ async function discoverGitReposUnderRoot(rootPath) {
43001
43027
  await yieldGitDiscoverWork(++walkEntries);
43002
43028
  const ent = entries[i];
43003
43029
  if (!ent.isDirectory() || ent.name === ".git") continue;
43004
- await walk(path51.join(dir, ent.name));
43030
+ await walk(path52.join(dir, ent.name));
43005
43031
  }
43006
43032
  }
43007
43033
  await walk(root);
@@ -43036,10 +43062,10 @@ function resolveBaseRefForRepo(relNorm, baseBranches) {
43036
43062
  }
43037
43063
  async function prepareNewSessionWorktrees(options) {
43038
43064
  const { worktreesRootPath, bridgeRoot, sessionId, layout, log: log2, worktreeBaseBranches } = options;
43039
- const bridgeResolved = path52.resolve(bridgeRoot);
43065
+ const bridgeResolved = path53.resolve(bridgeRoot);
43040
43066
  const cwdKey = allocateDirNameForLauncherCwd(layout, bridgeResolved);
43041
- const bridgeKeyDir = path52.join(worktreesRootPath, cwdKey);
43042
- const sessionDir = path52.join(bridgeKeyDir, sessionId);
43067
+ const bridgeKeyDir = path53.join(worktreesRootPath, cwdKey);
43068
+ const sessionDir = path53.join(bridgeKeyDir, sessionId);
43043
43069
  const repos = await discoverGitReposUnderRoot(bridgeResolved);
43044
43070
  if (repos.length === 0) {
43045
43071
  log2("[worktrees] No Git repositories under bridge root; skipping worktree creation.");
@@ -43049,12 +43075,12 @@ async function prepareNewSessionWorktrees(options) {
43049
43075
  const worktreePaths = [];
43050
43076
  fs35.mkdirSync(sessionDir, { recursive: true });
43051
43077
  for (const repo of repos) {
43052
- let rel = path52.relative(bridgeResolved, repo.absolutePath);
43053
- if (rel.startsWith("..") || path52.isAbsolute(rel)) continue;
43078
+ let rel = path53.relative(bridgeResolved, repo.absolutePath);
43079
+ if (rel.startsWith("..") || path53.isAbsolute(rel)) continue;
43054
43080
  const relNorm = normalizeRepoRelPath2(rel === "" ? "." : rel);
43055
- const wtPath = relNorm === "." ? sessionDir : path52.join(sessionDir, relNorm);
43081
+ const wtPath = relNorm === "." ? sessionDir : path53.join(sessionDir, relNorm);
43056
43082
  if (relNorm !== ".") {
43057
- fs35.mkdirSync(path52.dirname(wtPath), { recursive: true });
43083
+ fs35.mkdirSync(path53.dirname(wtPath), { recursive: true });
43058
43084
  }
43059
43085
  const baseRef = resolveBaseRefForRepo(relNorm, worktreeBaseBranches);
43060
43086
  try {
@@ -43107,9 +43133,9 @@ async function resolveExistingSessionParentPath(sessionId, cache2, discover) {
43107
43133
  }
43108
43134
 
43109
43135
  // src/worktrees/manager/resolve-explicit-session-parent-path.ts
43110
- import * as path53 from "node:path";
43136
+ import * as path54 from "node:path";
43111
43137
  async function resolveExplicitSessionParentPath(params) {
43112
- const resolved = path53.resolve(params.parentPathRaw);
43138
+ const resolved = path54.resolve(params.parentPathRaw);
43113
43139
  if (parseSessionParent(params.sessionParent) !== "worktrees_root") {
43114
43140
  return resolved;
43115
43141
  }
@@ -43126,7 +43152,7 @@ async function resolveExplicitSessionParentPath(params) {
43126
43152
  await yieldToEventLoop();
43127
43153
  const tryRoot = await discoverSessionWorktreesUnderSessionWorktreeRoot(cur, params.sessionId);
43128
43154
  if (tryRoot) return rememberAndReturn(tryRoot);
43129
- const next = path53.dirname(cur);
43155
+ const next = path54.dirname(cur);
43130
43156
  if (next === cur) break;
43131
43157
  cur = next;
43132
43158
  }
@@ -43236,7 +43262,7 @@ function createSessionWorktreeGitApi(ctx) {
43236
43262
  await renameSessionWorktreeBranch(ctx.cache, sessionId, newBranch, ctx.log);
43237
43263
  },
43238
43264
  async removeSessionWorktrees(sessionId) {
43239
- await removeSessionWorktreeCheckouts(ctx.cache, sessionId, ctx.log);
43265
+ await removeSessionWorktreeCheckouts(ctx.cache, sessionId, ctx.worktreesRootPath, ctx.log);
43240
43266
  },
43241
43267
  async commitSession(params) {
43242
43268
  return commitSessionWorktree(ctx.cache, params);
@@ -43265,17 +43291,17 @@ var SessionWorktreeManager = class {
43265
43291
  };
43266
43292
 
43267
43293
  // src/worktrees/manager/default-worktrees-root-path.ts
43268
- import * as path54 from "node:path";
43294
+ import * as path55 from "node:path";
43269
43295
  import os9 from "node:os";
43270
43296
  function defaultWorktreesRootPath() {
43271
- return path54.join(os9.homedir(), ".buildautomaton", "worktrees");
43297
+ return path55.join(os9.homedir(), ".buildautomaton", "worktrees");
43272
43298
  }
43273
43299
 
43274
43300
  // src/files/watch-file-index.ts
43275
- import path59 from "node:path";
43301
+ import path60 from "node:path";
43276
43302
 
43277
43303
  // src/files/index/build-file-index.ts
43278
- import path55 from "node:path";
43304
+ import path56 from "node:path";
43279
43305
 
43280
43306
  // src/files/index/file-index-sqlite-lock.ts
43281
43307
  var fileIndexChain = Promise.resolve();
@@ -43366,7 +43392,7 @@ function assertNotShutdown2() {
43366
43392
  if (isCliImmediateShutdownRequested()) throw new CliSqliteInterrupted();
43367
43393
  }
43368
43394
  async function buildFileIndexAsync(cwd) {
43369
- const resolved = path55.resolve(cwd);
43395
+ const resolved = path56.resolve(cwd);
43370
43396
  await yieldToEventLoop();
43371
43397
  assertNotShutdown2();
43372
43398
  const paths = await collectWorkspacePathsAsync(resolved);
@@ -43379,7 +43405,7 @@ async function buildFileIndexAsync(cwd) {
43379
43405
  }
43380
43406
 
43381
43407
  // src/files/index/ensure-file-index.ts
43382
- import path56 from "node:path";
43408
+ import path57 from "node:path";
43383
43409
 
43384
43410
  // src/files/index/search-file-index.ts
43385
43411
  function escapeLikePattern(fragment) {
@@ -43431,7 +43457,7 @@ async function searchBridgeFilePathsAsync(resolvedCwd, query, limit = 100) {
43431
43457
 
43432
43458
  // src/files/index/ensure-file-index.ts
43433
43459
  async function ensureFileIndexAsync(cwd) {
43434
- const resolved = path56.resolve(cwd);
43460
+ const resolved = path57.resolve(cwd);
43435
43461
  if (await bridgeFileIndexIsPopulated(resolved)) {
43436
43462
  return { fromCache: true, pathCount: await bridgeFileIndexPathCount(resolved) };
43437
43463
  }
@@ -43480,10 +43506,10 @@ function createFileIndexFsWatcher(resolved, schedule) {
43480
43506
 
43481
43507
  // src/files/index/file-index-incremental-symbol-updates.ts
43482
43508
  import fs36 from "node:fs";
43483
- import path57 from "node:path";
43509
+ import path58 from "node:path";
43484
43510
  async function applyIncrementalSymbolIndexUpdates(resolved, relPaths) {
43485
43511
  for (const rel of relPaths) {
43486
- const absPath = path57.join(resolved, rel);
43512
+ const absPath = path58.join(resolved, rel);
43487
43513
  try {
43488
43514
  const stat3 = await fs36.promises.stat(absPath);
43489
43515
  if (stat3.isFile()) {
@@ -43503,9 +43529,9 @@ async function applyIncrementalSymbolIndexUpdates(resolved, relPaths) {
43503
43529
  }
43504
43530
 
43505
43531
  // src/files/index/file-index-initial-builds.ts
43506
- import path58 from "node:path";
43532
+ import path59 from "node:path";
43507
43533
  async function runInitialIndexBuilds(cwd = getBridgeRoot()) {
43508
- const resolved = path58.resolve(cwd);
43534
+ const resolved = path59.resolve(cwd);
43509
43535
  try {
43510
43536
  await buildFileIndexAsync(resolved);
43511
43537
  await buildSymbolIndexAsync(resolved);
@@ -43523,7 +43549,7 @@ function scheduleInitialIndexBuilds(cwd = getBridgeRoot()) {
43523
43549
  // src/files/watch-file-index.ts
43524
43550
  var MAX_INCREMENTAL_SYMBOL_UPDATES = 512;
43525
43551
  function startFileIndexWatcher(cwd = getBridgeRoot()) {
43526
- const resolved = path59.resolve(cwd);
43552
+ const resolved = path60.resolve(cwd);
43527
43553
  let timer = null;
43528
43554
  const pendingSymbolUpdates = /* @__PURE__ */ new Set();
43529
43555
  let needsFullSymbolRebuild = false;
@@ -43585,14 +43611,14 @@ function startFileIndexWatcher(cwd = getBridgeRoot()) {
43585
43611
  }
43586
43612
 
43587
43613
  // src/connection/create-bridge-connection.ts
43588
- import * as path73 from "node:path";
43614
+ import * as path74 from "node:path";
43589
43615
 
43590
- // src/dev-servers/manager/dev-server-manager.ts
43616
+ // src/preview-environments/manager/preview-environment-manager.ts
43591
43617
  import { rm as rm2 } from "node:fs/promises";
43592
43618
 
43593
- // src/dev-servers/process/send-server-status.ts
43594
- function sendDevServerStatus(getWs, serverId, status, options) {
43595
- const payload = { type: "server_status", serverId, status };
43619
+ // src/preview-environments/process/send-preview-environment-status.ts
43620
+ function sendPreviewEnvironmentStatus(getWs, environmentId, status, options) {
43621
+ const payload = { type: "preview_environment_status", environmentId, status };
43596
43622
  if (options?.detail) payload.detail = options.detail;
43597
43623
  if (options?.tails) {
43598
43624
  payload.stdoutTail = options.tails.stdout;
@@ -43605,12 +43631,12 @@ function sendDevServerStatus(getWs, serverId, status, options) {
43605
43631
  });
43606
43632
  }
43607
43633
 
43608
- // src/dev-servers/process/terminate-child-process.ts
43634
+ // src/preview-environments/process/terminate-child-process.ts
43609
43635
  async function sigtermAndWaitForExit(proc, graceMs, log2, shortId) {
43610
43636
  const exited = new Promise((resolve34) => {
43611
43637
  proc.once("exit", () => resolve34());
43612
43638
  });
43613
- log2(`[dev-server] Sending SIGTERM to ${shortId} (pid=${proc.pid ?? "?"}).`);
43639
+ log2(`[preview-environment] Sending SIGTERM to ${shortId} (pid=${proc.pid ?? "?"}).`);
43614
43640
  try {
43615
43641
  proc.kill("SIGTERM");
43616
43642
  } catch {
@@ -43619,7 +43645,7 @@ async function sigtermAndWaitForExit(proc, graceMs, log2, shortId) {
43619
43645
  }
43620
43646
  function forceKillChild(proc, log2, shortId, graceMs) {
43621
43647
  log2(
43622
- `[dev-server] ${shortId} did not exit within ${graceMs}ms; sending SIGKILL (pid=${proc.pid ?? "?"}).`
43648
+ `[preview-environment] ${shortId} did not exit within ${graceMs}ms; sending SIGKILL (pid=${proc.pid ?? "?"}).`
43623
43649
  );
43624
43650
  proc.removeAllListeners();
43625
43651
  try {
@@ -43628,10 +43654,10 @@ function forceKillChild(proc, log2, shortId, graceMs) {
43628
43654
  }
43629
43655
  }
43630
43656
 
43631
- // src/dev-servers/process/wire-dev-server-child-process.ts
43657
+ // src/preview-environments/process/wire-preview-environment-child-process.ts
43632
43658
  import fs37 from "node:fs";
43633
43659
 
43634
- // src/dev-servers/manager/forward-pipe.ts
43660
+ // src/preview-environments/manager/forward-pipe.ts
43635
43661
  function forwardChildPipe(childReadable, terminal, onData) {
43636
43662
  if (!childReadable) return;
43637
43663
  childReadable.on("data", (chunk) => {
@@ -43647,16 +43673,16 @@ function forwardChildPipe(childReadable, terminal, onData) {
43647
43673
  });
43648
43674
  }
43649
43675
 
43650
- // src/dev-servers/process/wire-dev-server-child-process.ts
43651
- function wireDevServerChildProcess(d) {
43652
- const { proc, serverId, title } = d;
43676
+ // src/preview-environments/process/wire-preview-environment-child-process.ts
43677
+ function wirePreviewEnvironmentChildProcess(d) {
43678
+ const { proc, environmentId, title } = d;
43653
43679
  forwardChildPipe(proc.stdout, null, (chunk) => {
43654
43680
  d.stdoutTail.push(chunk);
43655
- d.pushRemoteLogChunk(serverId, "stdout", chunk);
43681
+ d.pushRemoteLogChunk(environmentId, "stdout", chunk);
43656
43682
  });
43657
43683
  forwardChildPipe(proc.stderr, null, (chunk) => {
43658
43684
  d.stderrTail.push(chunk);
43659
- d.pushRemoteLogChunk(serverId, "stderr", chunk);
43685
+ d.pushRemoteLogChunk(environmentId, "stderr", chunk);
43660
43686
  });
43661
43687
  if (d.mergedLogPath && d.mergedCleanupDir) {
43662
43688
  const pollIv = setInterval(() => {
@@ -43672,7 +43698,7 @@ function wireDevServerChildProcess(d) {
43672
43698
  d.mergedReadPos.value = buf.length;
43673
43699
  if (chunk.length === 0) return;
43674
43700
  d.stdoutTail.push(chunk);
43675
- d.pushRemoteLogChunk(serverId, "stdout", chunk);
43701
+ d.pushRemoteLogChunk(environmentId, "stdout", chunk);
43676
43702
  });
43677
43703
  }, 100);
43678
43704
  d.setPollInterval(pollIv);
@@ -43690,10 +43716,10 @@ function wireDevServerChildProcess(d) {
43690
43716
  d.rmMergedCleanupDir(cleanupDir);
43691
43717
  }
43692
43718
  if (signal) {
43693
- d.log(`[dev-server] ${title} stopped (signal: ${String(signal)}).`);
43719
+ d.log(`[preview-environment] ${title} stopped (signal: ${String(signal)}).`);
43694
43720
  } else if (code !== null && code !== 0) {
43695
43721
  const errTail = d.stderrTail.getTail().slice(-3).join("\n");
43696
- d.log(`[dev-server] ${title} exited with code ${code}${errTail ? `
43722
+ d.log(`[preview-environment] ${title} exited with code ${code}${errTail ? `
43697
43723
  ${errTail}` : ""}`);
43698
43724
  }
43699
43725
  d.detachProcessFromManager();
@@ -43708,7 +43734,7 @@ ${errTail}` : ""}`);
43708
43734
  const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
43709
43735
  if (chunk.length > 0) {
43710
43736
  d.stdoutTail.push(chunk);
43711
- d.pushRemoteLogChunk(serverId, "stdout", chunk);
43737
+ d.pushRemoteLogChunk(environmentId, "stdout", chunk);
43712
43738
  }
43713
43739
  }
43714
43740
  finishExit();
@@ -43732,12 +43758,12 @@ ${errTail}` : ""}`);
43732
43758
  d.clearTailBuffers();
43733
43759
  const msg = err instanceof Error ? err.message : String(err);
43734
43760
  const errno = typeof err === "object" && err && "code" in err ? String(err.code) : "";
43735
- d.log(`[dev-server] ${title} process error: ${msg}${errno ? ` (${errno})` : ""}`);
43761
+ d.log(`[preview-environment] ${title} process error: ${msg}${errno ? ` (${errno})` : ""}`);
43736
43762
  d.sendStatus("error", msg, tails);
43737
43763
  });
43738
43764
  }
43739
43765
 
43740
- // src/dev-servers/manager/dev-server-env.ts
43766
+ // src/preview-environments/manager/preview-environment-env.ts
43741
43767
  function substituteCommand(cmd, env) {
43742
43768
  return cmd.replace(/\$\{([^}]+)\}/g, (_, key) => env[key] != null ? String(env[key]) : "");
43743
43769
  }
@@ -43773,15 +43799,15 @@ function envForSpawn(base, userEnv, ports) {
43773
43799
  return out;
43774
43800
  }
43775
43801
 
43776
- // src/dev-servers/manager/parse-config.ts
43777
- function parseDevServerDefs(servers) {
43802
+ // src/preview-environments/manager/parse-config.ts
43803
+ function parsePreviewEnvironmentDefs(servers) {
43778
43804
  const out = [];
43779
43805
  if (!Array.isArray(servers)) return out;
43780
43806
  for (const s of servers) {
43781
43807
  if (!s || typeof s !== "object") continue;
43782
43808
  const o = s;
43783
- const serverId = typeof o.serverId === "string" ? o.serverId : "";
43784
- if (!serverId) continue;
43809
+ const environmentId = typeof o.environmentId === "string" ? o.environmentId : "";
43810
+ if (!environmentId) continue;
43785
43811
  const envRaw = o.env;
43786
43812
  const env = Array.isArray(envRaw) ? envRaw.map((e) => {
43787
43813
  if (!e || typeof e !== "object") return null;
@@ -43794,7 +43820,7 @@ function parseDevServerDefs(servers) {
43794
43820
  const portsRaw = o.ports;
43795
43821
  const ports = Array.isArray(portsRaw) ? portsRaw.filter((p) => typeof p === "number" && Number.isInteger(p) && p > 0 && p < 65536) : [];
43796
43822
  out.push({
43797
- serverId,
43823
+ environmentId,
43798
43824
  name: typeof o.name === "string" ? o.name : "",
43799
43825
  command: typeof o.command === "string" ? o.command : "",
43800
43826
  env,
@@ -43804,7 +43830,7 @@ function parseDevServerDefs(servers) {
43804
43830
  return out;
43805
43831
  }
43806
43832
 
43807
- // src/dev-servers/manager/shell-spawn/utils.ts
43833
+ // src/preview-environments/manager/shell-spawn/utils.ts
43808
43834
  import fs38 from "node:fs";
43809
43835
  function isSpawnEbadf(e) {
43810
43836
  return typeof e === "object" && e !== null && "code" in e && e.code === "EBADF";
@@ -43827,7 +43853,7 @@ function pipedStdoutStderrFor(attemptStdio) {
43827
43853
  return attemptStdio !== "inherit" && Array.isArray(attemptStdio) && attemptStdio[1] === "pipe" && attemptStdio[2] === "pipe";
43828
43854
  }
43829
43855
 
43830
- // src/dev-servers/manager/shell-spawn/try-spawn-piped-via-sh.ts
43856
+ // src/preview-environments/manager/shell-spawn/try-spawn-piped-via-sh.ts
43831
43857
  import { spawn as spawn5 } from "node:child_process";
43832
43858
  function trySpawnPipedViaSh(command, env, cwd, signal) {
43833
43859
  const attempts = [
@@ -43870,7 +43896,7 @@ function trySpawnPipedViaSh(command, env, cwd, signal) {
43870
43896
  return { ok: false, lastErr };
43871
43897
  }
43872
43898
 
43873
- // src/dev-servers/manager/shell-spawn/try-spawn-shell-true-piped.ts
43899
+ // src/preview-environments/manager/shell-spawn/try-spawn-shell-true-piped.ts
43874
43900
  import { spawn as spawn6 } from "node:child_process";
43875
43901
  function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal) {
43876
43902
  try {
@@ -43891,14 +43917,14 @@ function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal) {
43891
43917
  }
43892
43918
  }
43893
43919
 
43894
- // src/dev-servers/manager/shell-spawn/try-spawn-merged-log-file.ts
43920
+ // src/preview-environments/manager/shell-spawn/try-spawn-merged-log-file.ts
43895
43921
  import { spawn as spawn7 } from "node:child_process";
43896
43922
  import fs39 from "node:fs";
43897
43923
  import { tmpdir } from "node:os";
43898
- import path60 from "node:path";
43924
+ import path61 from "node:path";
43899
43925
  function trySpawnMergedLogFile(command, env, cwd, signal) {
43900
- const tmpRoot = fs39.mkdtempSync(path60.join(tmpdir(), "ba-devsrv-log-"));
43901
- const logPath = path60.join(tmpRoot, "combined.log");
43926
+ const tmpRoot = fs39.mkdtempSync(path61.join(tmpdir(), "ba-devsrv-log-"));
43927
+ const logPath = path61.join(tmpRoot, "combined.log");
43902
43928
  let logFd;
43903
43929
  try {
43904
43930
  logFd = fs39.openSync(logPath, "a");
@@ -43938,19 +43964,19 @@ function trySpawnMergedLogFile(command, env, cwd, signal) {
43938
43964
  }
43939
43965
  }
43940
43966
 
43941
- // src/dev-servers/manager/shell-spawn/try-spawn-shell-script-log-redirect.ts
43967
+ // src/preview-environments/manager/shell-spawn/try-spawn-shell-script-log-redirect.ts
43942
43968
  import { spawn as spawn8 } from "node:child_process";
43943
43969
  import fs40 from "node:fs";
43944
43970
  import { tmpdir as tmpdir2 } from "node:os";
43945
- import path61 from "node:path";
43971
+ import path62 from "node:path";
43946
43972
  function shSingleQuote(s) {
43947
43973
  return `'${s.replace(/'/g, `'\\''`)}'`;
43948
43974
  }
43949
43975
  function trySpawnShellScriptLogRedirectUnix(command, env, cwd, signal) {
43950
- const tmpRoot = fs40.mkdtempSync(path61.join(tmpdir2(), "ba-devsrv-sh-"));
43951
- const logPath = path61.join(tmpRoot, "combined.log");
43952
- const innerPath = path61.join(tmpRoot, "_cmd.sh");
43953
- const runnerPath = path61.join(tmpRoot, "_run.sh");
43976
+ const tmpRoot = fs40.mkdtempSync(path62.join(tmpdir2(), "ba-devsrv-sh-"));
43977
+ const logPath = path62.join(tmpRoot, "combined.log");
43978
+ const innerPath = path62.join(tmpRoot, "_cmd.sh");
43979
+ const runnerPath = path62.join(tmpRoot, "_run.sh");
43954
43980
  try {
43955
43981
  fs40.writeFileSync(innerPath, `#!/bin/sh
43956
43982
  ${command}
@@ -43981,9 +44007,9 @@ cd ${shSingleQuote(cwd)}
43981
44007
  }
43982
44008
  }
43983
44009
  function trySpawnShellScriptLogRedirectWin(command, env, cwd, signal) {
43984
- const tmpRoot = fs40.mkdtempSync(path61.join(tmpdir2(), "ba-devsrv-sh-"));
43985
- const logPath = path61.join(tmpRoot, "combined.log");
43986
- const runnerPath = path61.join(tmpRoot, "_run.bat");
44010
+ const tmpRoot = fs40.mkdtempSync(path62.join(tmpdir2(), "ba-devsrv-sh-"));
44011
+ const logPath = path62.join(tmpRoot, "combined.log");
44012
+ const runnerPath = path62.join(tmpRoot, "_run.bat");
43987
44013
  const q = (p) => `"${p.replace(/"/g, '""')}"`;
43988
44014
  const com = process.env.ComSpec || "cmd.exe";
43989
44015
  try {
@@ -44014,7 +44040,7 @@ ${command} >> ${q(logPath)} 2>&1\r
44014
44040
  }
44015
44041
  }
44016
44042
 
44017
- // src/dev-servers/manager/shell-spawn/try-spawn-inherit.ts
44043
+ // src/preview-environments/manager/shell-spawn/try-spawn-inherit.ts
44018
44044
  import { spawn as spawn9 } from "node:child_process";
44019
44045
  function trySpawnInheritStdio(command, env, cwd, signal) {
44020
44046
  const opts = {
@@ -44034,7 +44060,7 @@ function trySpawnInheritStdio(command, env, cwd, signal) {
44034
44060
  return { proc, pipedStdoutStderr: false };
44035
44061
  }
44036
44062
 
44037
- // src/dev-servers/manager/shell-spawn/shell-spawn.ts
44063
+ // src/preview-environments/manager/shell-spawn/shell-spawn.ts
44038
44064
  function shellSpawn(command, env, cwd, options) {
44039
44065
  const signal = options?.signal;
44040
44066
  const piped = trySpawnPipedViaSh(command, env, cwd, signal);
@@ -44061,7 +44087,7 @@ function shellSpawn(command, env, cwd, options) {
44061
44087
  }
44062
44088
  }
44063
44089
 
44064
- // src/dev-servers/manager/stream-tail.ts
44090
+ // src/preview-environments/manager/stream-tail.ts
44065
44091
  var MAX_TAIL_LINES = 80;
44066
44092
  var MAX_LINE_CHARS = 8192;
44067
44093
  var MAX_PENDING_CHARS = 65536;
@@ -44097,11 +44123,11 @@ var StreamTail = class {
44097
44123
  }
44098
44124
  };
44099
44125
 
44100
- // src/dev-servers/manager/dev-server-firehose-messages.ts
44126
+ // src/preview-environments/manager/preview-environment-firehose-messages.ts
44101
44127
  function buildFirehoseSnapshotMessage(params) {
44102
44128
  const payload = {
44103
44129
  type: "log_snapshot",
44104
- serverId: params.serverId,
44130
+ environmentId: params.environmentId,
44105
44131
  viewerId: params.viewerId,
44106
44132
  stdoutTail: params.tails.stdout,
44107
44133
  stderrTail: params.tails.stderr
@@ -44111,15 +44137,15 @@ function buildFirehoseSnapshotMessage(params) {
44111
44137
  function buildFirehoseLogChunkMessage(params) {
44112
44138
  const payload = {
44113
44139
  type: "log_chunk",
44114
- serverId: params.serverId,
44140
+ environmentId: params.environmentId,
44115
44141
  stream: params.stream,
44116
44142
  text: params.text
44117
44143
  };
44118
44144
  return params.e2ee ? params.e2ee.encryptFields(payload, ["text"]) : payload;
44119
44145
  }
44120
44146
 
44121
- // src/dev-servers/manager/dev-server-firehose-sink.ts
44122
- var DevServerFirehoseSink = class {
44147
+ // src/preview-environments/manager/preview-environment-firehose-sink.ts
44148
+ var PreviewEnvironmentFirehoseSink = class {
44123
44149
  constructor(options) {
44124
44150
  this.options = options;
44125
44151
  }
@@ -44132,31 +44158,31 @@ var DevServerFirehoseSink = class {
44132
44158
  this.firehoseSend = null;
44133
44159
  this.logViewerRefCountByServerId.clear();
44134
44160
  }
44135
- openLogViewer(serverId, viewerId) {
44136
- const next = (this.logViewerRefCountByServerId.get(serverId) ?? 0) + 1;
44137
- this.logViewerRefCountByServerId.set(serverId, next);
44138
- this.sendSnapshot(serverId, viewerId);
44161
+ openLogViewer(environmentId, viewerId) {
44162
+ const next = (this.logViewerRefCountByServerId.get(environmentId) ?? 0) + 1;
44163
+ this.logViewerRefCountByServerId.set(environmentId, next);
44164
+ this.sendSnapshot(environmentId, viewerId);
44139
44165
  }
44140
- closeLogViewer(serverId) {
44141
- const n = (this.logViewerRefCountByServerId.get(serverId) ?? 0) - 1;
44142
- if (n <= 0) this.logViewerRefCountByServerId.delete(serverId);
44143
- else this.logViewerRefCountByServerId.set(serverId, n);
44166
+ closeLogViewer(environmentId) {
44167
+ const n = (this.logViewerRefCountByServerId.get(environmentId) ?? 0) - 1;
44168
+ if (n <= 0) this.logViewerRefCountByServerId.delete(environmentId);
44169
+ else this.logViewerRefCountByServerId.set(environmentId, n);
44144
44170
  }
44145
- pushLogChunk(serverId, stream, chunk) {
44146
- if ((this.logViewerRefCountByServerId.get(serverId) ?? 0) <= 0) return;
44147
- if (!this.options.isPipedCaptureEnabled(serverId)) return;
44171
+ pushLogChunk(environmentId, stream, chunk) {
44172
+ if ((this.logViewerRefCountByServerId.get(environmentId) ?? 0) <= 0) return;
44173
+ if (!this.options.isPipedCaptureEnabled(environmentId)) return;
44148
44174
  if (!this.firehoseSend) return;
44149
44175
  const text = chunk.toString("utf8");
44150
44176
  setImmediate(() => {
44151
44177
  if (!this.firehoseSend) return;
44152
- this.firehoseSend(buildFirehoseLogChunkMessage({ serverId, stream, text, e2ee: this.options.e2ee }));
44178
+ this.firehoseSend(buildFirehoseLogChunkMessage({ environmentId, stream, text, e2ee: this.options.e2ee }));
44153
44179
  });
44154
44180
  }
44155
- sendSnapshot(serverId, viewerId) {
44181
+ sendSnapshot(environmentId, viewerId) {
44156
44182
  const payload = buildFirehoseSnapshotMessage({
44157
- serverId,
44183
+ environmentId,
44158
44184
  viewerId,
44159
- tails: this.options.getTails(serverId),
44185
+ tails: this.options.getTails(environmentId),
44160
44186
  e2ee: this.options.e2ee
44161
44187
  });
44162
44188
  setImmediate(() => {
@@ -44167,19 +44193,19 @@ var DevServerFirehoseSink = class {
44167
44193
  }
44168
44194
  };
44169
44195
 
44170
- // src/dev-servers/manager/cleanup-merged-log-dir.ts
44196
+ // src/preview-environments/manager/cleanup-merged-log-dir.ts
44171
44197
  import { rm } from "node:fs/promises";
44172
- function cleanupMergedLogDirForServer(map2, serverId) {
44173
- const mergedDir = map2.get(serverId);
44198
+ function cleanupMergedLogDirForServer(map2, environmentId) {
44199
+ const mergedDir = map2.get(environmentId);
44174
44200
  if (!mergedDir) return;
44175
- map2.delete(serverId);
44201
+ map2.delete(environmentId);
44176
44202
  void rm(mergedDir, { recursive: true, force: true }).catch(() => {
44177
44203
  });
44178
44204
  }
44179
44205
 
44180
- // src/dev-servers/manager/dev-server-manager.ts
44206
+ // src/preview-environments/manager/preview-environment-manager.ts
44181
44207
  var emptyTails = () => ({ stdout: [], stderr: [] });
44182
- var DevServerManager = class {
44208
+ var PreviewEnvironmentManager = class {
44183
44209
  defsById = /* @__PURE__ */ new Map();
44184
44210
  processes = /* @__PURE__ */ new Map();
44185
44211
  streamTailsByServerId = /* @__PURE__ */ new Map();
@@ -44198,9 +44224,9 @@ var DevServerManager = class {
44198
44224
  this.log = options.log;
44199
44225
  this.getBridgeRoot = options.getBridgeRoot ?? (() => process.cwd());
44200
44226
  this.e2ee = options.e2ee;
44201
- this.firehoseSink = new DevServerFirehoseSink({
44202
- getTails: (serverId) => this.snapshotTails(serverId),
44203
- isPipedCaptureEnabled: (serverId) => this.pipedCaptureByServerId.get(serverId) === true,
44227
+ this.firehoseSink = new PreviewEnvironmentFirehoseSink({
44228
+ getTails: (environmentId) => this.snapshotTails(environmentId),
44229
+ isPipedCaptureEnabled: (environmentId) => this.pipedCaptureByServerId.get(environmentId) === true,
44204
44230
  e2ee: this.e2ee
44205
44231
  });
44206
44232
  }
@@ -44210,89 +44236,89 @@ var DevServerManager = class {
44210
44236
  detachFirehose() {
44211
44237
  this.firehoseSink.detach();
44212
44238
  }
44213
- handleFirehoseLogViewerOpen(serverId, _viewerId) {
44214
- this.firehoseSink.openLogViewer(serverId, _viewerId);
44239
+ handleFirehoseLogViewerOpen(environmentId, _viewerId) {
44240
+ this.firehoseSink.openLogViewer(environmentId, _viewerId);
44215
44241
  }
44216
- handleFirehoseLogViewerClose(serverId, _viewerId) {
44217
- this.firehoseSink.closeLogViewer(serverId);
44242
+ handleFirehoseLogViewerClose(environmentId, _viewerId) {
44243
+ this.firehoseSink.closeLogViewer(environmentId);
44218
44244
  }
44219
44245
  applyConfig(servers) {
44220
44246
  this.defsById.clear();
44221
- for (const d of parseDevServerDefs(servers)) {
44222
- this.defsById.set(d.serverId, d);
44247
+ for (const d of parsePreviewEnvironmentDefs(servers)) {
44248
+ this.defsById.set(d.environmentId, d);
44223
44249
  }
44224
44250
  }
44225
- snapshotTails(serverId) {
44226
- const t = this.streamTailsByServerId.get(serverId);
44251
+ snapshotTails(environmentId) {
44252
+ const t = this.streamTailsByServerId.get(environmentId);
44227
44253
  if (!t) return { stdout: [], stderr: [] };
44228
44254
  return { stdout: t.stdout.getTail(), stderr: t.stderr.getTail() };
44229
44255
  }
44230
- clearTails(serverId) {
44231
- this.streamTailsByServerId.delete(serverId);
44256
+ clearTails(environmentId) {
44257
+ this.streamTailsByServerId.delete(environmentId);
44232
44258
  }
44233
- sendStatus(serverId, status, detail, tails) {
44234
- sendDevServerStatus(this.getWs, serverId, status, { detail, tails });
44259
+ sendStatus(environmentId, status, detail, tails) {
44260
+ sendPreviewEnvironmentStatus(this.getWs, environmentId, status, { detail, tails });
44235
44261
  }
44236
- bumpGeneration(serverId) {
44237
- const nextGen = (this.spawnGenerationByServerId.get(serverId) ?? 0) + 1;
44238
- this.spawnGenerationByServerId.set(serverId, nextGen);
44262
+ bumpGeneration(environmentId) {
44263
+ const nextGen = (this.spawnGenerationByServerId.get(environmentId) ?? 0) + 1;
44264
+ this.spawnGenerationByServerId.set(environmentId, nextGen);
44239
44265
  }
44240
- clearPoll(serverId) {
44241
- const poll = this.mergedLogPollByServerId.get(serverId);
44266
+ clearPoll(environmentId) {
44267
+ const poll = this.mergedLogPollByServerId.get(environmentId);
44242
44268
  if (poll) {
44243
44269
  clearInterval(poll);
44244
- this.mergedLogPollByServerId.delete(serverId);
44270
+ this.mergedLogPollByServerId.delete(environmentId);
44245
44271
  }
44246
44272
  }
44247
- abortSpawn(serverId) {
44248
- this.abortControllersByServerId.get(serverId)?.abort();
44249
- this.abortControllersByServerId.delete(serverId);
44273
+ abortSpawn(environmentId) {
44274
+ this.abortControllersByServerId.get(environmentId)?.abort();
44275
+ this.abortControllersByServerId.delete(environmentId);
44250
44276
  }
44251
- stop(serverId) {
44252
- const tails = this.snapshotTails(serverId);
44253
- if (this.processes.has(serverId)) {
44254
- this.sendStatus(serverId, "stopping", void 0, tails);
44277
+ stop(environmentId) {
44278
+ const tails = this.snapshotTails(environmentId);
44279
+ if (this.processes.has(environmentId)) {
44280
+ this.sendStatus(environmentId, "stopping", void 0, tails);
44255
44281
  }
44256
- this.bumpGeneration(serverId);
44257
- this.abortSpawn(serverId);
44258
- this.clearPoll(serverId);
44259
- const proc = this.processes.get(serverId);
44282
+ this.bumpGeneration(environmentId);
44283
+ this.abortSpawn(environmentId);
44284
+ this.clearPoll(environmentId);
44285
+ const proc = this.processes.get(environmentId);
44260
44286
  if (proc) {
44261
44287
  proc.removeAllListeners();
44262
44288
  try {
44263
44289
  proc.kill("SIGTERM");
44264
44290
  } catch {
44265
44291
  }
44266
- this.processes.delete(serverId);
44292
+ this.processes.delete(environmentId);
44267
44293
  }
44268
- this.clearTails(serverId);
44269
- this.pipedCaptureByServerId.delete(serverId);
44270
- cleanupMergedLogDirForServer(this.mergedLogCleanupDirByServerId, serverId);
44271
- this.sendStatus(serverId, "stopped", void 0, tails);
44294
+ this.clearTails(environmentId);
44295
+ this.pipedCaptureByServerId.delete(environmentId);
44296
+ cleanupMergedLogDirForServer(this.mergedLogCleanupDirByServerId, environmentId);
44297
+ this.sendStatus(environmentId, "stopped", void 0, tails);
44272
44298
  }
44273
- start(serverId) {
44274
- const def = this.defsById.get(serverId);
44299
+ start(environmentId) {
44300
+ const def = this.defsById.get(environmentId);
44275
44301
  if (!def) {
44276
- this.log(`[dev-server] Unknown server id ${serverId.slice(0, 8)}\u2026`);
44277
- this.sendStatus(serverId, "error", "Unknown server", emptyTails());
44302
+ this.log(`[preview-environment] Unknown server id ${environmentId.slice(0, 8)}\u2026`);
44303
+ this.sendStatus(environmentId, "error", "Unknown server", emptyTails());
44278
44304
  return;
44279
44305
  }
44280
44306
  if (!def.command.trim()) {
44281
- this.sendStatus(serverId, "idle", "No command configured", emptyTails());
44307
+ this.sendStatus(environmentId, "idle", "No command configured", emptyTails());
44282
44308
  return;
44283
44309
  }
44284
- this.stop(serverId);
44285
- this.sendStatus(serverId, "starting", void 0, emptyTails());
44310
+ this.stop(environmentId);
44311
+ this.sendStatus(environmentId, "starting", void 0, emptyTails());
44286
44312
  const ac = new AbortController();
44287
- this.abortControllersByServerId.set(serverId, ac);
44313
+ this.abortControllersByServerId.set(environmentId, ac);
44288
44314
  const cwd = this.getBridgeRoot();
44289
44315
  const childEnv = envForSpawn(process.env, def.env, def.ports);
44290
44316
  const cmd = substituteCommand(def.command.trim(), childEnv);
44291
- const title = def.name.trim() || serverId.slice(0, 8);
44292
- this.log(`[dev-server] Starting ${title}: ${cmd.slice(0, 120)}${cmd.length > 120 ? "\u2026" : ""}`);
44293
- const scheduledGen = this.spawnGenerationByServerId.get(serverId) ?? 0;
44317
+ const title = def.name.trim() || environmentId.slice(0, 8);
44318
+ this.log(`[preview-environment] Starting ${title}: ${cmd.slice(0, 120)}${cmd.length > 120 ? "\u2026" : ""}`);
44319
+ const scheduledGen = this.spawnGenerationByServerId.get(environmentId) ?? 0;
44294
44320
  setImmediate(() => {
44295
- if ((this.spawnGenerationByServerId.get(serverId) ?? 0) !== scheduledGen) {
44321
+ if ((this.spawnGenerationByServerId.get(environmentId) ?? 0) !== scheduledGen) {
44296
44322
  return;
44297
44323
  }
44298
44324
  let proc;
@@ -44309,12 +44335,12 @@ var DevServerManager = class {
44309
44335
  mergedCleanupDir = spawned.mergedLogCleanupDir;
44310
44336
  } catch (e) {
44311
44337
  const msg = e instanceof Error ? e.message : String(e);
44312
- this.log(`[dev-server] Failed to start ${title}: ${msg}`);
44313
- this.abortControllersByServerId.delete(serverId);
44314
- this.sendStatus(serverId, "error", msg, emptyTails());
44338
+ this.log(`[preview-environment] Failed to start ${title}: ${msg}`);
44339
+ this.abortControllersByServerId.delete(environmentId);
44340
+ this.sendStatus(environmentId, "error", msg, emptyTails());
44315
44341
  return;
44316
44342
  }
44317
- if ((this.spawnGenerationByServerId.get(serverId) ?? 0) !== scheduledGen) {
44343
+ if ((this.spawnGenerationByServerId.get(environmentId) ?? 0) !== scheduledGen) {
44318
44344
  try {
44319
44345
  proc.removeAllListeners();
44320
44346
  proc.kill("SIGTERM");
@@ -44323,89 +44349,89 @@ var DevServerManager = class {
44323
44349
  return;
44324
44350
  }
44325
44351
  if (!pipedStdoutStderr) {
44326
- this.log(`[dev-server] ${title} running (inherited stdio; bridge log preview disabled)`);
44352
+ this.log(`[preview-environment] ${title} running (inherited stdio; bridge log preview disabled)`);
44327
44353
  } else if (mergedLogPath && mergedCleanupDir) {
44328
44354
  this.log(
44329
- `[dev-server] ${title} running (logs captured via temp file; open the browser log viewer for live output)`
44355
+ `[preview-environment] ${title} running (logs captured via temp file; open the browser log viewer for live output)`
44330
44356
  );
44331
44357
  }
44332
- this.pipedCaptureByServerId.set(serverId, pipedStdoutStderr);
44358
+ this.pipedCaptureByServerId.set(environmentId, pipedStdoutStderr);
44333
44359
  const stdoutTail = new StreamTail();
44334
44360
  const stderrTail = new StreamTail();
44335
- this.streamTailsByServerId.set(serverId, { stdout: stdoutTail, stderr: stderrTail });
44361
+ this.streamTailsByServerId.set(environmentId, { stdout: stdoutTail, stderr: stderrTail });
44336
44362
  if (mergedLogPath && mergedCleanupDir) {
44337
- this.mergedLogCleanupDirByServerId.set(serverId, mergedCleanupDir);
44363
+ this.mergedLogCleanupDirByServerId.set(environmentId, mergedCleanupDir);
44338
44364
  }
44339
44365
  const mergedReadPos = { value: 0 };
44340
- this.processes.set(serverId, proc);
44341
- wireDevServerChildProcess({
44342
- serverId,
44366
+ this.processes.set(environmentId, proc);
44367
+ wirePreviewEnvironmentChildProcess({
44368
+ environmentId,
44343
44369
  title,
44344
44370
  proc,
44345
44371
  mergedLogPath,
44346
44372
  mergedCleanupDir,
44347
44373
  mergedReadPos,
44348
44374
  scheduledGen,
44349
- getSpawnGeneration: () => this.spawnGenerationByServerId.get(serverId) ?? 0,
44375
+ getSpawnGeneration: () => this.spawnGenerationByServerId.get(environmentId) ?? 0,
44350
44376
  log: this.log,
44351
44377
  stdoutTail,
44352
44378
  stderrTail,
44353
44379
  pushRemoteLogChunk: (sid, stream, chunk) => this.firehoseSink.pushLogChunk(sid, stream, chunk),
44354
- sendStatus: (status, detail, tails) => this.sendStatus(serverId, status, detail, tails),
44380
+ sendStatus: (status, detail, tails) => this.sendStatus(environmentId, status, detail, tails),
44355
44381
  setPollInterval: (iv) => {
44356
- if (iv) this.mergedLogPollByServerId.set(serverId, iv);
44357
- else this.mergedLogPollByServerId.delete(serverId);
44382
+ if (iv) this.mergedLogPollByServerId.set(environmentId, iv);
44383
+ else this.mergedLogPollByServerId.delete(environmentId);
44358
44384
  },
44359
- getPollInterval: () => this.mergedLogPollByServerId.get(serverId),
44385
+ getPollInterval: () => this.mergedLogPollByServerId.get(environmentId),
44360
44386
  detachProcessFromManager: () => {
44361
- this.processes.delete(serverId);
44362
- this.pipedCaptureByServerId.delete(serverId);
44363
- this.abortControllersByServerId.delete(serverId);
44364
- this.mergedLogCleanupDirByServerId.delete(serverId);
44387
+ this.processes.delete(environmentId);
44388
+ this.pipedCaptureByServerId.delete(environmentId);
44389
+ this.abortControllersByServerId.delete(environmentId);
44390
+ this.mergedLogCleanupDirByServerId.delete(environmentId);
44365
44391
  },
44366
44392
  rmMergedCleanupDir: (dir) => {
44367
44393
  void rm2(dir, { recursive: true, force: true }).catch(() => {
44368
44394
  });
44369
44395
  },
44370
- clearTailBuffers: () => this.clearTails(serverId)
44396
+ clearTailBuffers: () => this.clearTails(environmentId)
44371
44397
  });
44372
- this.sendStatus(serverId, "running", `pid=${proc.pid ?? "?"}`, {
44398
+ this.sendStatus(environmentId, "running", `pid=${proc.pid ?? "?"}`, {
44373
44399
  stdout: stdoutTail.getTail(),
44374
44400
  stderr: stderrTail.getTail()
44375
44401
  });
44376
44402
  });
44377
44403
  }
44378
- handleControl(serverId, action) {
44404
+ handleControl(environmentId, action) {
44379
44405
  if (action === "stop") {
44380
- this.stop(serverId);
44406
+ this.stop(environmentId);
44381
44407
  return;
44382
44408
  }
44383
- this.start(serverId);
44409
+ this.start(environmentId);
44384
44410
  }
44385
44411
  async shutdownAllGraceful(opts) {
44386
44412
  const graceMs = opts?.graceMs ?? BRIDGE_SHUTDOWN_GRACE_MS;
44387
44413
  const pairs = [...this.processes.entries()];
44388
44414
  if (pairs.length === 0) return;
44389
44415
  this.log(
44390
- `[dev-server] Stopping ${pairs.length} local dev server process${pairs.length === 1 ? "" : "es"}\u2026`
44416
+ `[preview-environment] Stopping ${pairs.length} local preview environment process${pairs.length === 1 ? "" : "es"}\u2026`
44391
44417
  );
44392
- await Promise.all(pairs.map(([serverId, proc]) => this.gracefulTerminateOrUnknown(serverId, proc, graceMs)));
44418
+ await Promise.all(pairs.map(([environmentId, proc]) => this.gracefulTerminateOrUnknown(environmentId, proc, graceMs)));
44393
44419
  }
44394
- async gracefulTerminateOrUnknown(serverId, proc, graceMs) {
44395
- const shortId = `${serverId.slice(0, 8)}\u2026`;
44420
+ async gracefulTerminateOrUnknown(environmentId, proc, graceMs) {
44421
+ const shortId = `${environmentId.slice(0, 8)}\u2026`;
44396
44422
  await sigtermAndWaitForExit(proc, graceMs, this.log, shortId);
44397
- if (!this.processes.has(serverId) || this.processes.get(serverId) !== proc) {
44423
+ if (!this.processes.has(environmentId) || this.processes.get(environmentId) !== proc) {
44398
44424
  return;
44399
44425
  }
44400
- this.bumpGeneration(serverId);
44426
+ this.bumpGeneration(environmentId);
44401
44427
  forceKillChild(proc, this.log, shortId, graceMs);
44402
- this.processes.delete(serverId);
44403
- this.clearPoll(serverId);
44404
- this.pipedCaptureByServerId.delete(serverId);
44405
- cleanupMergedLogDirForServer(this.mergedLogCleanupDirByServerId, serverId);
44406
- const tails = this.snapshotTails(serverId);
44407
- this.clearTails(serverId);
44408
- this.sendStatus(serverId, "unknown", "Bridge closed before process exited", tails);
44428
+ this.processes.delete(environmentId);
44429
+ this.clearPoll(environmentId);
44430
+ this.pipedCaptureByServerId.delete(environmentId);
44431
+ cleanupMergedLogDirForServer(this.mergedLogCleanupDirByServerId, environmentId);
44432
+ const tails = this.snapshotTails(environmentId);
44433
+ this.clearTails(environmentId);
44434
+ this.sendStatus(environmentId, "unknown", "Bridge closed before process exited", tails);
44409
44435
  }
44410
44436
  };
44411
44437
 
@@ -44631,20 +44657,20 @@ function createFirehoseMessageRouter() {
44631
44657
  };
44632
44658
  }
44633
44659
 
44634
- // src/firehose/routing/handlers/dev-server-logs-viewer-open.ts
44635
- var handleDevServerLogsViewerOpen = (msg, deps) => {
44636
- const serverId = typeof msg.serverId === "string" ? msg.serverId : "";
44660
+ // src/firehose/routing/handlers/preview-environment-logs-viewer-open.ts
44661
+ var handlePreviewEnvironmentLogsViewerOpen = (msg, deps) => {
44662
+ const environmentId = typeof msg.environmentId === "string" ? msg.environmentId : "";
44637
44663
  const viewerId = typeof msg.viewerId === "string" ? msg.viewerId : "";
44638
- if (!serverId || !viewerId) return;
44639
- deps.devServerManager.handleFirehoseLogViewerOpen(serverId, viewerId);
44664
+ if (!environmentId || !viewerId) return;
44665
+ deps.previewEnvironmentManager.handleFirehoseLogViewerOpen(environmentId, viewerId);
44640
44666
  };
44641
44667
 
44642
- // src/firehose/routing/handlers/dev-server-logs-viewer-close.ts
44643
- var handleDevServerLogsViewerClose = (msg, deps) => {
44644
- const serverId = typeof msg.serverId === "string" ? msg.serverId : "";
44668
+ // src/firehose/routing/handlers/preview-environment-logs-viewer-close.ts
44669
+ var handlePreviewEnvironmentLogsViewerClose = (msg, deps) => {
44670
+ const environmentId = typeof msg.environmentId === "string" ? msg.environmentId : "";
44645
44671
  const viewerId = typeof msg.viewerId === "string" ? msg.viewerId : "";
44646
- if (!serverId || !viewerId) return;
44647
- deps.devServerManager.handleFirehoseLogViewerClose(serverId, viewerId);
44672
+ if (!environmentId || !viewerId) return;
44673
+ deps.previewEnvironmentManager.handleFirehoseLogViewerClose(environmentId, viewerId);
44648
44674
  };
44649
44675
 
44650
44676
  // src/firehose/routing/handlers/proxy-message.ts
@@ -44693,8 +44719,8 @@ var handleFirehoseIdentified = (_msg, _deps) => {
44693
44719
  // src/firehose/routing/dispatch-firehose-message.ts
44694
44720
  var router = createFirehoseMessageRouter();
44695
44721
  router.register("identified", handleFirehoseIdentified);
44696
- router.register("log_viewer_open", handleDevServerLogsViewerOpen);
44697
- router.register("log_viewer_close", handleDevServerLogsViewerClose);
44722
+ router.register("log_viewer_open", handlePreviewEnvironmentLogsViewerOpen);
44723
+ router.register("log_viewer_close", handlePreviewEnvironmentLogsViewerClose);
44698
44724
  router.register("proxy", handleProxyMessage);
44699
44725
  function dispatchFirehoseJsonMessage(msg, deps) {
44700
44726
  router.dispatch(msg, deps);
@@ -44724,7 +44750,7 @@ function connectFirehose(options) {
44724
44750
  bridgeName,
44725
44751
  proxyPorts,
44726
44752
  log: log2,
44727
- devServerManager,
44753
+ previewEnvironmentManager,
44728
44754
  onOpen,
44729
44755
  onClose,
44730
44756
  suppressWebSocketErrors
@@ -44744,7 +44770,7 @@ function connectFirehose(options) {
44744
44770
  const deps = {
44745
44771
  ws,
44746
44772
  log: log2,
44747
- devServerManager,
44773
+ previewEnvironmentManager,
44748
44774
  pendingProxyBody,
44749
44775
  startStreamingProxy: (pr) => startStreamingProxy(ws, log2, pr)
44750
44776
  };
@@ -44752,7 +44778,7 @@ function connectFirehose(options) {
44752
44778
  disposeClientPing();
44753
44779
  clearClientPing = attachWebSocketClientPing(ws, CLI_WEBSOCKET_CLIENT_PING_MS);
44754
44780
  onOpen?.();
44755
- devServerManager.attachFirehose(firehoseSend);
44781
+ previewEnvironmentManager.attachFirehose(firehoseSend);
44756
44782
  sendWsMessage(ws, { type: "identify", workspaceId, bridgeName, proxyPorts });
44757
44783
  });
44758
44784
  ws.on("message", (raw) => {
@@ -44769,7 +44795,7 @@ function connectFirehose(options) {
44769
44795
  });
44770
44796
  ws.on("close", (code, reason) => {
44771
44797
  disposeClientPing();
44772
- devServerManager.detachFirehose();
44798
+ previewEnvironmentManager.detachFirehose();
44773
44799
  const reasonStr = typeof reason === "string" ? reason : reason.toString();
44774
44800
  onClose?.(code, reasonStr);
44775
44801
  });
@@ -44785,7 +44811,7 @@ function connectFirehose(options) {
44785
44811
  return {
44786
44812
  close() {
44787
44813
  disposeClientPing();
44788
- devServerManager.detachFirehose();
44814
+ previewEnvironmentManager.detachFirehose();
44789
44815
  safeCloseWebSocket(ws);
44790
44816
  },
44791
44817
  isConnected: () => ws.readyState === wrapper_default.OPEN
@@ -44794,7 +44820,7 @@ function connectFirehose(options) {
44794
44820
 
44795
44821
  // src/connection/attach-firehose-after-identified.ts
44796
44822
  function attachFirehoseAfterIdentified(ctx, params) {
44797
- const { state, devServerManager, logFn } = ctx;
44823
+ const { state, previewEnvironmentManager, logFn } = ctx;
44798
44824
  function clearFirehoseReconnectTimer() {
44799
44825
  if (state.firehoseReconnectTimeout != null) {
44800
44826
  clearTimeout(state.firehoseReconnectTimeout);
@@ -44860,7 +44886,7 @@ function attachFirehoseAfterIdentified(ctx, params) {
44860
44886
  bridgeName: params.bridgeName,
44861
44887
  proxyPorts: params.proxyPorts,
44862
44888
  log: logFn,
44863
- devServerManager,
44889
+ previewEnvironmentManager,
44864
44890
  suppressWebSocketErrors: () => !state.closedByUser && state.firehoseOutage.startedAt != null,
44865
44891
  onOpen: () => {
44866
44892
  if (myGen !== state.firehoseGeneration) return;
@@ -44903,14 +44929,14 @@ function attachFirehoseAfterIdentified(ctx, params) {
44903
44929
 
44904
44930
  // src/connection/create-bridge-identified-handler.ts
44905
44931
  function createOnBridgeIdentified(opts) {
44906
- const { devServerManager, firehoseServerUrl, workspaceId, state, logFn } = opts;
44907
- const firehoseCtx = { state, devServerManager, logFn };
44932
+ const { previewEnvironmentManager, firehoseServerUrl, workspaceId, state, logFn } = opts;
44933
+ const firehoseCtx = { state, previewEnvironmentManager, logFn };
44908
44934
  return (msg) => {
44909
44935
  const bridgeName = msg.bridgeName;
44910
44936
  const proxyPorts = Array.isArray(msg.proxyPorts) ? msg.proxyPorts : [];
44911
- const devServers = msg.devServers ?? [];
44937
+ const previewEnvironments = msg.previewEnvironments ?? [];
44912
44938
  setImmediate(() => {
44913
- devServerManager.applyConfig(devServers);
44939
+ previewEnvironmentManager.applyConfig(previewEnvironments);
44914
44940
  if (!firehoseServerUrl || typeof bridgeName !== "string" || !bridgeName) return;
44915
44941
  state.firehoseReconnectAttempt = 0;
44916
44942
  attachFirehoseAfterIdentified(firehoseCtx, {
@@ -44933,15 +44959,15 @@ async function yieldSkillDiscoveryWork(entryCount) {
44933
44959
 
44934
44960
  // src/skills/discovery/discover-local-skills.ts
44935
44961
  import fs41 from "node:fs";
44936
- import path62 from "node:path";
44962
+ import path63 from "node:path";
44937
44963
  function collectSkillFromDir(rel, base, name, seenKeys, out) {
44938
- const dir = path62.join(base, name);
44964
+ const dir = path63.join(base, name);
44939
44965
  try {
44940
44966
  if (!fs41.statSync(dir).isDirectory()) return;
44941
44967
  } catch {
44942
44968
  return;
44943
44969
  }
44944
- const skillMd = path62.join(dir, "SKILL.md");
44970
+ const skillMd = path63.join(dir, "SKILL.md");
44945
44971
  if (!fs41.existsSync(skillMd)) return;
44946
44972
  const key = `${rel}/${name}`;
44947
44973
  if (seenKeys.has(key)) return;
@@ -44954,7 +44980,7 @@ async function discoverLocalSkillsAsync(cwd) {
44954
44980
  let work = 0;
44955
44981
  for (const rel of SKILL_DISCOVERY_ROOTS) {
44956
44982
  await yieldSkillDiscoveryWork(++work);
44957
- const base = path62.join(cwd, rel);
44983
+ const base = path63.join(cwd, rel);
44958
44984
  if (!fs41.existsSync(base) || !fs41.statSync(base).isDirectory()) continue;
44959
44985
  let entries = [];
44960
44986
  try {
@@ -44972,15 +44998,15 @@ async function discoverLocalSkillsAsync(cwd) {
44972
44998
 
44973
44999
  // src/skills/discovery/discover-skill-layout-roots.ts
44974
45000
  import fs42 from "node:fs";
44975
- import path63 from "node:path";
45001
+ import path64 from "node:path";
44976
45002
  function collectLayoutSkill(rel, base, name, skills2) {
44977
- const dir = path63.join(base, name);
45003
+ const dir = path64.join(base, name);
44978
45004
  try {
44979
45005
  if (!fs42.statSync(dir).isDirectory()) return;
44980
45006
  } catch {
44981
45007
  return;
44982
45008
  }
44983
- if (!fs42.existsSync(path63.join(dir, "SKILL.md"))) return;
45009
+ if (!fs42.existsSync(path64.join(dir, "SKILL.md"))) return;
44984
45010
  const relPath = `${rel}/${name}`.replace(/\\/g, "/");
44985
45011
  skills2.push({ name, relPath });
44986
45012
  }
@@ -44989,7 +45015,7 @@ async function discoverSkillLayoutRootsAsync(cwd) {
44989
45015
  let work = 0;
44990
45016
  for (const rel of SKILL_DISCOVERY_ROOTS) {
44991
45017
  await yieldSkillDiscoveryWork(++work);
44992
- const base = path63.join(cwd, rel);
45018
+ const base = path64.join(cwd, rel);
44993
45019
  if (!fs42.existsSync(base) || !fs42.statSync(base).isDirectory()) continue;
44994
45020
  let entries = [];
44995
45021
  try {
@@ -45086,8 +45112,8 @@ var API_TO_BRIDGE_MESSAGE_TYPES = [
45086
45112
  "auth_token",
45087
45113
  "bridge_identified",
45088
45114
  "ha",
45089
- "dev_servers_config",
45090
- "server_control",
45115
+ "preview_environments_config",
45116
+ "preview_environment_control",
45091
45117
  "agent_config",
45092
45118
  "prompt_queue_state",
45093
45119
  "prompt",
@@ -45147,7 +45173,7 @@ var handleBridgeIdentified = (msg, deps) => {
45147
45173
  deps.onBridgeIdentified({
45148
45174
  bridgeName: msg.bridgeName,
45149
45175
  proxyPorts: msg.proxyPorts,
45150
- devServers: msg.devServers
45176
+ previewEnvironments: msg.previewEnvironments
45151
45177
  });
45152
45178
  setImmediate(() => {
45153
45179
  void (async () => {
@@ -45341,7 +45367,7 @@ import fs44 from "node:fs";
45341
45367
 
45342
45368
  // src/git/snapshot/capture.ts
45343
45369
  import * as fs43 from "node:fs";
45344
- import * as path64 from "node:path";
45370
+ import * as path65 from "node:path";
45345
45371
 
45346
45372
  // src/git/snapshot/git.ts
45347
45373
  async function gitStashCreate(repoRoot, log2) {
@@ -45381,7 +45407,7 @@ async function gitRun(repoRoot, args, log2, label) {
45381
45407
  async function resolveSnapshotRepoRoots(options) {
45382
45408
  const { worktreePaths, fallbackCwd, sessionId, log: log2 } = options;
45383
45409
  if (worktreePaths?.length) {
45384
- const uniq = [...new Set(worktreePaths.map((p) => path64.resolve(p)))];
45410
+ const uniq = [...new Set(worktreePaths.map((p) => path65.resolve(p)))];
45385
45411
  return uniq;
45386
45412
  }
45387
45413
  try {
@@ -45389,7 +45415,7 @@ async function resolveSnapshotRepoRoots(options) {
45389
45415
  const mapped = repos.map((r) => r.absolutePath);
45390
45416
  const sid = sessionId?.trim();
45391
45417
  if (sid) {
45392
- const filtered = mapped.filter((root) => path64.basename(root) === sid);
45418
+ const filtered = mapped.filter((root) => path65.basename(root) === sid);
45393
45419
  if (filtered.length > 0) return filtered;
45394
45420
  }
45395
45421
  return mapped;
@@ -45420,7 +45446,7 @@ async function capturePreTurnSnapshot(options) {
45420
45446
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
45421
45447
  repos
45422
45448
  };
45423
- const filePath = path64.join(dir, `${runId}.json`);
45449
+ const filePath = path65.join(dir, `${runId}.json`);
45424
45450
  try {
45425
45451
  fs43.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
45426
45452
  } catch (e) {
@@ -45763,9 +45789,9 @@ function parseChangeSummarySnapshots(raw) {
45763
45789
  for (const item of raw) {
45764
45790
  if (!item || typeof item !== "object") continue;
45765
45791
  const o = item;
45766
- const path75 = typeof o.path === "string" && o.path.trim() !== "" ? o.path.trim() : "";
45767
- if (!path75) continue;
45768
- const row = { path: path75 };
45792
+ const path76 = typeof o.path === "string" && o.path.trim() !== "" ? o.path.trim() : "";
45793
+ if (!path76) continue;
45794
+ const row = { path: path76 };
45769
45795
  if (typeof o.patchContent === "string") row.patchContent = o.patchContent;
45770
45796
  if (typeof o.oldText === "string") row.oldText = o.oldText;
45771
45797
  if (typeof o.newText === "string") row.newText = o.newText;
@@ -45976,8 +46002,8 @@ function randomSecret() {
45976
46002
  }
45977
46003
  return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
45978
46004
  }
45979
- async function requestPreviewApi(port, secret, method, path75, body) {
45980
- const url2 = `http://127.0.0.1:${port}${path75}`;
46005
+ async function requestPreviewApi(port, secret, method, path76, body) {
46006
+ const url2 = `http://127.0.0.1:${port}${path76}`;
45981
46007
  const headers = {
45982
46008
  [PREVIEW_SECRET_HEADER]: secret,
45983
46009
  "Content-Type": "application/json"
@@ -45989,7 +46015,7 @@ async function requestPreviewApi(port, secret, method, path75, body) {
45989
46015
  });
45990
46016
  const data = await res.json().catch(() => ({}));
45991
46017
  if (!res.ok) {
45992
- throw new Error(data?.error ?? `Preview API ${method} ${path75}: ${res.status}`);
46018
+ throw new Error(data?.error ?? `Preview API ${method} ${path76}: ${res.status}`);
45993
46019
  }
45994
46020
  return data;
45995
46021
  }
@@ -46168,11 +46194,11 @@ async function resolveFileBrowserSessionParent(sessionWorktreeManager, sessionId
46168
46194
  import fs46 from "node:fs";
46169
46195
 
46170
46196
  // src/files/ensure-under-cwd.ts
46171
- import path65 from "node:path";
46197
+ import path66 from "node:path";
46172
46198
  function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
46173
- const normalized = path65.normalize(relativePath).replace(/^(\.\/)+/, "");
46174
- const resolved = path65.resolve(cwd, normalized);
46175
- if (!resolved.startsWith(cwd + path65.sep) && resolved !== cwd) {
46199
+ const normalized = path66.normalize(relativePath).replace(/^(\.\/)+/, "");
46200
+ const resolved = path66.resolve(cwd, normalized);
46201
+ if (!resolved.startsWith(cwd + path66.sep) && resolved !== cwd) {
46176
46202
  return null;
46177
46203
  }
46178
46204
  return resolved;
@@ -46182,11 +46208,11 @@ function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
46182
46208
  var LIST_DIR_YIELD_EVERY = 256;
46183
46209
 
46184
46210
  // src/files/list-dir/map-dir-entry.ts
46185
- import path66 from "node:path";
46211
+ import path67 from "node:path";
46186
46212
  import fs45 from "node:fs";
46187
46213
  async function mapDirEntry(d, relativePath, resolved) {
46188
- const entryPath = path66.join(relativePath || ".", d.name).replace(/\\/g, "/");
46189
- const fullPath = path66.join(resolved, d.name);
46214
+ const entryPath = path67.join(relativePath || ".", d.name).replace(/\\/g, "/");
46215
+ const fullPath = path67.join(resolved, d.name);
46190
46216
  let isDir = d.isDirectory();
46191
46217
  if (d.isSymbolicLink()) {
46192
46218
  try {
@@ -46236,13 +46262,13 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
46236
46262
  }
46237
46263
 
46238
46264
  // src/files/handle-file-browser-search.ts
46239
- import path67 from "node:path";
46265
+ import path68 from "node:path";
46240
46266
  var SEARCH_LIMIT = 100;
46241
46267
  function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
46242
46268
  void (async () => {
46243
46269
  await yieldToEventLoop();
46244
46270
  const q = typeof msg.q === "string" ? msg.q : "";
46245
- const sessionParentPath = path67.resolve(
46271
+ const sessionParentPath = path68.resolve(
46246
46272
  sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
46247
46273
  );
46248
46274
  if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
@@ -46452,13 +46478,13 @@ function triggerSymbolIndexBuild(parentPath) {
46452
46478
  }
46453
46479
 
46454
46480
  // src/git/tree/resolve-repo-abs-path.ts
46455
- import * as path68 from "node:path";
46481
+ import * as path69 from "node:path";
46456
46482
  function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
46457
- const bridgeResolved = path68.resolve(bridgeRoot);
46483
+ const bridgeResolved = path69.resolve(bridgeRoot);
46458
46484
  const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
46459
- const repoPath = rel === "" ? bridgeResolved : path68.join(bridgeResolved, rel);
46460
- const resolved = path68.resolve(repoPath);
46461
- if (!resolved.startsWith(bridgeResolved + path68.sep) && resolved !== bridgeResolved) {
46485
+ const repoPath = rel === "" ? bridgeResolved : path69.join(bridgeResolved, rel);
46486
+ const resolved = path69.resolve(repoPath);
46487
+ if (!resolved.startsWith(bridgeResolved + path69.sep) && resolved !== bridgeResolved) {
46462
46488
  return null;
46463
46489
  }
46464
46490
  return resolved;
@@ -47241,7 +47267,7 @@ function isValidRemoteSkillInstallItem(item) {
47241
47267
 
47242
47268
  // src/skills/install/install-remote-skills-async.ts
47243
47269
  import fs50 from "node:fs";
47244
- import path69 from "node:path";
47270
+ import path70 from "node:path";
47245
47271
 
47246
47272
  // src/skills/install/constants.ts
47247
47273
  var INSTALL_SKILLS_YIELD_EVERY = 16;
@@ -47252,8 +47278,8 @@ async function writeInstallFileAsync(skillDir, f, filesWritten) {
47252
47278
  if (++filesWritten.count % INSTALL_SKILLS_YIELD_EVERY === 0) {
47253
47279
  await yieldToEventLoop();
47254
47280
  }
47255
- const dest = path69.join(skillDir, f.path);
47256
- await fs50.promises.mkdir(path69.dirname(dest), { recursive: true });
47281
+ const dest = path70.join(skillDir, f.path);
47282
+ await fs50.promises.mkdir(path70.dirname(dest), { recursive: true });
47257
47283
  if (f.text !== void 0) {
47258
47284
  await fs50.promises.writeFile(dest, f.text, "utf8");
47259
47285
  } else if (f.base64) {
@@ -47269,7 +47295,7 @@ async function installRemoteSkillsAsync(cwd, targetDir, items) {
47269
47295
  try {
47270
47296
  for (const item of items) {
47271
47297
  if (!isValidRemoteSkillInstallItem(item)) continue;
47272
- const skillDir = path69.join(cwd, targetDir, item.skillName);
47298
+ const skillDir = path70.join(cwd, targetDir, item.skillName);
47273
47299
  for (const f of item.files) {
47274
47300
  await writeInstallFileAsync(skillDir, f, filesWritten);
47275
47301
  }
@@ -47584,31 +47610,31 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
47584
47610
  })();
47585
47611
  };
47586
47612
 
47587
- // src/routing/handlers/dev-server-control.ts
47588
- var handleDevServerControl = (msg, deps) => {
47613
+ // src/routing/handlers/preview-environment-control.ts
47614
+ var handlePreviewEnvironmentControl = (msg, deps) => {
47589
47615
  let wire;
47590
47616
  try {
47591
47617
  wire = deps.e2ee ? deps.e2ee.decryptMessage(msg) : msg;
47592
47618
  } catch (e) {
47593
- deps.log(`[E2EE] Could not decrypt dev server command: ${e instanceof Error ? e.message : String(e)}`);
47619
+ deps.log(`[E2EE] Could not decrypt preview environment command: ${e instanceof Error ? e.message : String(e)}`);
47594
47620
  return;
47595
47621
  }
47596
- const serverId = typeof wire.serverId === "string" ? wire.serverId : "";
47622
+ const environmentId = typeof wire.environmentId === "string" ? wire.environmentId : "";
47597
47623
  const action = wire.action === "start" || wire.action === "stop" ? wire.action : null;
47598
- if (!serverId || !action) return;
47599
- deps.devServerManager?.handleControl(serverId, action);
47624
+ if (!environmentId || !action) return;
47625
+ deps.previewEnvironmentManager?.handleControl(environmentId, action);
47600
47626
  };
47601
47627
 
47602
- // src/routing/handlers/dev-servers-config.ts
47603
- var handleDevServersConfig = (msg, deps) => {
47604
- const devServers = msg.devServers;
47628
+ // src/routing/handlers/preview-environments-config.ts
47629
+ var handlePreviewEnvironmentsConfig = (msg, deps) => {
47630
+ const previewEnvironments = msg.previewEnvironments;
47605
47631
  setImmediate(() => {
47606
- deps.devServerManager?.applyConfig(devServers ?? []);
47632
+ deps.previewEnvironmentManager?.applyConfig(previewEnvironments ?? []);
47607
47633
  });
47608
47634
  };
47609
47635
 
47610
47636
  // src/git/bridge-git-context.ts
47611
- import * as path70 from "node:path";
47637
+ import * as path71 from "node:path";
47612
47638
 
47613
47639
  // src/git/branches/get-current-branch.ts
47614
47640
  async function getCurrentBranch(repoPath) {
@@ -47658,12 +47684,12 @@ async function listRepoBranchRefs(repoPath) {
47658
47684
  // src/git/bridge-git-context.ts
47659
47685
  function folderNameForRelPath(relPath, bridgeRoot) {
47660
47686
  if (relPath === "." || relPath === "") {
47661
- return path70.basename(path70.resolve(bridgeRoot)) || "repo";
47687
+ return path71.basename(path71.resolve(bridgeRoot)) || "repo";
47662
47688
  }
47663
- return path70.basename(relPath) || relPath;
47689
+ return path71.basename(relPath) || relPath;
47664
47690
  }
47665
47691
  async function discoverGitReposForBridgeContext(bridgeRoot) {
47666
- const root = path70.resolve(bridgeRoot);
47692
+ const root = path71.resolve(bridgeRoot);
47667
47693
  if (await isGitRepoDirectory(root)) {
47668
47694
  const remoteUrl = await getRemoteOriginUrl(root);
47669
47695
  return [{ absolutePath: root, remoteUrl }];
@@ -47671,19 +47697,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
47671
47697
  const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
47672
47698
  const byPath = /* @__PURE__ */ new Map();
47673
47699
  for (const repo of [...deep, ...shallow]) {
47674
- byPath.set(path70.resolve(repo.absolutePath), repo);
47700
+ byPath.set(path71.resolve(repo.absolutePath), repo);
47675
47701
  }
47676
47702
  return [...byPath.values()];
47677
47703
  }
47678
47704
  async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
47679
- const bridgeResolved = path70.resolve(bridgeRoot);
47705
+ const bridgeResolved = path71.resolve(bridgeRoot);
47680
47706
  const repos = await discoverGitReposForBridgeContext(bridgeResolved);
47681
47707
  const rows = [];
47682
47708
  for (let i = 0; i < repos.length; i++) {
47683
47709
  if (i > 0) await yieldToEventLoop();
47684
47710
  const repo = repos[i];
47685
- let rel = path70.relative(bridgeResolved, repo.absolutePath);
47686
- if (rel.startsWith("..") || path70.isAbsolute(rel)) continue;
47711
+ let rel = path71.relative(bridgeResolved, repo.absolutePath);
47712
+ if (rel.startsWith("..") || path71.isAbsolute(rel)) continue;
47687
47713
  const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
47688
47714
  const currentBranch = await getCurrentBranch(repo.absolutePath);
47689
47715
  const remoteUrl = repo.remoteUrl.trim() || null;
@@ -47698,11 +47724,11 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
47698
47724
  return rows;
47699
47725
  }
47700
47726
  async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
47701
- const bridgeResolved = path70.resolve(bridgeRoot);
47727
+ const bridgeResolved = path71.resolve(bridgeRoot);
47702
47728
  const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
47703
- const repoPath = rel === "" ? bridgeResolved : path70.join(bridgeResolved, rel);
47704
- const resolved = path70.resolve(repoPath);
47705
- if (!resolved.startsWith(bridgeResolved + path70.sep) && resolved !== bridgeResolved) {
47729
+ const repoPath = rel === "" ? bridgeResolved : path71.join(bridgeResolved, rel);
47730
+ const resolved = path71.resolve(repoPath);
47731
+ if (!resolved.startsWith(bridgeResolved + path71.sep) && resolved !== bridgeResolved) {
47706
47732
  return [];
47707
47733
  }
47708
47734
  return listRepoBranchRefs(resolved);
@@ -47763,11 +47789,11 @@ function dispatchBridgeMessage(msg, deps) {
47763
47789
  case "ha":
47764
47790
  handleBridgeHeartbeatAck(msg, deps);
47765
47791
  break;
47766
- case "dev_servers_config":
47767
- handleDevServersConfig(msg, deps);
47792
+ case "preview_environments_config":
47793
+ handlePreviewEnvironmentsConfig(msg, deps);
47768
47794
  break;
47769
- case "server_control":
47770
- handleDevServerControl(msg, deps);
47795
+ case "preview_environment_control":
47796
+ handlePreviewEnvironmentControl(msg, deps);
47771
47797
  break;
47772
47798
  case "agent_config":
47773
47799
  handleAgentConfigMessage(msg, deps);
@@ -48579,7 +48605,7 @@ async function createBridgeAccessState(options = {}) {
48579
48605
  }
48580
48606
 
48581
48607
  // src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
48582
- import * as path72 from "node:path";
48608
+ import * as path73 from "node:path";
48583
48609
 
48584
48610
  // src/sqlite/hash-json-sha256.ts
48585
48611
  import { createHash as createHash2 } from "node:crypto";
@@ -48646,7 +48672,7 @@ function listCliAgentCapabilityCacheForWorkspace(db, workspaceId) {
48646
48672
  }
48647
48673
 
48648
48674
  // src/agents/capabilities/probe-one-agent-type-for-capabilities.ts
48649
- import * as path71 from "node:path";
48675
+ import * as path72 from "node:path";
48650
48676
  async function probeOneAgentTypeForCapabilities(params) {
48651
48677
  const { agentType, cwd, workspaceId, log: log2, reportAgentCapabilities, bridgeReport = true, shouldContinue } = params;
48652
48678
  const canContinue = () => shouldContinue?.() !== false;
@@ -48684,7 +48710,7 @@ async function probeOneAgentTypeForCapabilities(params) {
48684
48710
  if (!canContinue()) return false;
48685
48711
  handle = await resolved.createClient({
48686
48712
  command: resolved.command,
48687
- cwd: path71.resolve(cwd),
48713
+ cwd: path72.resolve(cwd),
48688
48714
  backendAgentType: agentType,
48689
48715
  sessionMode: "agent",
48690
48716
  persistedAcpSessionId: null,
@@ -48762,7 +48788,7 @@ async function warmupAgentCapabilitiesOnConnect(params) {
48762
48788
  const { workspaceId, log: log2, getWs } = params;
48763
48789
  const isCurrent = beginAgentCapabilityWarmupRun();
48764
48790
  if (!isCurrent()) return;
48765
- const cwd = path72.resolve(getBridgeRoot());
48791
+ const cwd = path73.resolve(getBridgeRoot());
48766
48792
  async function sendBatchFromCache() {
48767
48793
  if (!isCurrent()) return;
48768
48794
  const socket = getWs();
@@ -48875,7 +48901,7 @@ function createBridgeMessageDeps(params) {
48875
48901
  sendLocalSkillsReport,
48876
48902
  reportAutoDetectedAgents,
48877
48903
  warmupAgentCapabilitiesOnConnect: warmupAgentCapabilitiesOnConnect2,
48878
- devServerManager,
48904
+ previewEnvironmentManager,
48879
48905
  e2ee,
48880
48906
  cloudApiBaseUrl,
48881
48907
  getCloudAccessToken
@@ -48892,7 +48918,7 @@ function createBridgeMessageDeps(params) {
48892
48918
  sendLocalSkillsReport,
48893
48919
  reportAutoDetectedAgents,
48894
48920
  warmupAgentCapabilitiesOnConnect: warmupAgentCapabilitiesOnConnect2,
48895
- devServerManager,
48921
+ previewEnvironmentManager,
48896
48922
  e2ee,
48897
48923
  cloudApiBaseUrl,
48898
48924
  getCloudAccessToken
@@ -48962,10 +48988,10 @@ async function createBridgeConnection(options) {
48962
48988
  initialIndexBuildsScheduled = true;
48963
48989
  scheduleInitialIndexBuilds(getBridgeRoot());
48964
48990
  };
48965
- const devServerManager = new DevServerManager({ getWs, log: logFn, getBridgeRoot, e2ee });
48991
+ const previewEnvironmentManager = new PreviewEnvironmentManager({ getWs, log: logFn, getBridgeRoot, e2ee });
48966
48992
  const bridgeHeartbeat = createBridgeHeartbeatController({ getWs, log: logFn });
48967
48993
  const baseOnBridgeIdentified = createOnBridgeIdentified({
48968
- devServerManager,
48994
+ previewEnvironmentManager,
48969
48995
  firehoseServerUrl,
48970
48996
  workspaceId,
48971
48997
  state,
@@ -48991,14 +49017,14 @@ async function createBridgeConnection(options) {
48991
49017
  log: logFn,
48992
49018
  getWs
48993
49019
  }),
48994
- devServerManager,
49020
+ previewEnvironmentManager,
48995
49021
  e2ee,
48996
49022
  cloudApiBaseUrl: apiUrl,
48997
49023
  getCloudAccessToken: () => tokens.accessToken
48998
49024
  });
48999
49025
  const identifyReportedPaths = {
49000
- bridgeRootPath: path73.resolve(getBridgeRoot()),
49001
- worktreesRootPath: path73.resolve(worktreesRootPath)
49026
+ bridgeRootPath: path74.resolve(getBridgeRoot()),
49027
+ worktreesRootPath: path74.resolve(worktreesRootPath)
49002
49028
  };
49003
49029
  const { connect } = createMainBridgeWebSocketLifecycle({
49004
49030
  state,
@@ -49024,7 +49050,7 @@ async function createBridgeConnection(options) {
49024
49050
  requestCliImmediateShutdown();
49025
49051
  stopFileIndexWatcher();
49026
49052
  bridgeHeartbeat.stop();
49027
- await closeBridgeConnection(state, acpManager, devServerManager, logFn);
49053
+ await closeBridgeConnection(state, acpManager, previewEnvironmentManager, logFn);
49028
49054
  await bridgeAccess.close();
49029
49055
  }
49030
49056
  };
@@ -49255,7 +49281,7 @@ async function runCliAction(program2, opts) {
49255
49281
  const firehoseServerUrl = opts.firehoseUrl ?? opts.proxyUrl ?? process.env.BUILDAUTOMATON_FIREHOSE_URL ?? process.env.BUILDAUTOMATON_PROXY_URL ?? DEFAULT_FIREHOSE_URL;
49256
49282
  const bridgeRootOpt = (opts.bridgeRoot && typeof opts.bridgeRoot === "string" && opts.bridgeRoot.trim() ? opts.bridgeRoot.trim() : null) ?? (opts.cwd && typeof opts.cwd === "string" && opts.cwd.trim() ? opts.cwd.trim() : null);
49257
49283
  if (bridgeRootOpt) {
49258
- const resolvedBridgeRoot = path74.resolve(process.cwd(), bridgeRootOpt);
49284
+ const resolvedBridgeRoot = path75.resolve(process.cwd(), bridgeRootOpt);
49259
49285
  try {
49260
49286
  const st = fs52.statSync(resolvedBridgeRoot);
49261
49287
  if (!st.isDirectory()) {
@@ -49277,7 +49303,7 @@ async function runCliAction(program2, opts) {
49277
49303
  );
49278
49304
  let worktreesRootPath;
49279
49305
  if (opts.worktreesRoot && opts.worktreesRoot.trim()) {
49280
- worktreesRootPath = path74.resolve(opts.worktreesRoot.trim());
49306
+ worktreesRootPath = path75.resolve(opts.worktreesRoot.trim());
49281
49307
  }
49282
49308
  const e2eCertificates = opts.e2eeCertificatesDir?.trim() ? await loadOrCreateE2eCertificates(opts.e2eeCertificatesDir.trim()) : void 0;
49283
49309
  if (e2eCertificates) {