@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/index.js CHANGED
@@ -4175,8 +4175,8 @@ var init_parseUtil = __esm({
4175
4175
  init_errors();
4176
4176
  init_en();
4177
4177
  makeIssue = (params) => {
4178
- const { data, path: path73, errorMaps, issueData } = params;
4179
- const fullPath = [...path73, ...issueData.path || []];
4178
+ const { data, path: path74, errorMaps, issueData } = params;
4179
+ const fullPath = [...path74, ...issueData.path || []];
4180
4180
  const fullIssue = {
4181
4181
  ...issueData,
4182
4182
  path: fullPath
@@ -4484,11 +4484,11 @@ var init_types = __esm({
4484
4484
  init_parseUtil();
4485
4485
  init_util();
4486
4486
  ParseInputLazyPath = class {
4487
- constructor(parent, value, path73, key) {
4487
+ constructor(parent, value, path74, key) {
4488
4488
  this._cachedPath = [];
4489
4489
  this.parent = parent;
4490
4490
  this.data = value;
4491
- this._path = path73;
4491
+ this._path = path74;
4492
4492
  this._key = key;
4493
4493
  }
4494
4494
  get path() {
@@ -8103,10 +8103,10 @@ function assignProp(target, prop, value) {
8103
8103
  configurable: true
8104
8104
  });
8105
8105
  }
8106
- function getElementAtPath(obj, path73) {
8107
- if (!path73)
8106
+ function getElementAtPath(obj, path74) {
8107
+ if (!path74)
8108
8108
  return obj;
8109
- return path73.reduce((acc, key) => acc?.[key], obj);
8109
+ return path74.reduce((acc, key) => acc?.[key], obj);
8110
8110
  }
8111
8111
  function promiseAllObject(promisesObj) {
8112
8112
  const keys = Object.keys(promisesObj);
@@ -8355,11 +8355,11 @@ function aborted(x, startIndex = 0) {
8355
8355
  }
8356
8356
  return false;
8357
8357
  }
8358
- function prefixIssues(path73, issues) {
8358
+ function prefixIssues(path74, issues) {
8359
8359
  return issues.map((iss) => {
8360
8360
  var _a2;
8361
8361
  (_a2 = iss).path ?? (_a2.path = []);
8362
- iss.path.unshift(path73);
8362
+ iss.path.unshift(path74);
8363
8363
  return iss;
8364
8364
  });
8365
8365
  }
@@ -8548,7 +8548,7 @@ function treeifyError(error40, _mapper) {
8548
8548
  return issue2.message;
8549
8549
  };
8550
8550
  const result = { errors: [] };
8551
- const processError = (error41, path73 = []) => {
8551
+ const processError = (error41, path74 = []) => {
8552
8552
  var _a2, _b;
8553
8553
  for (const issue2 of error41.issues) {
8554
8554
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -8558,7 +8558,7 @@ function treeifyError(error40, _mapper) {
8558
8558
  } else if (issue2.code === "invalid_element") {
8559
8559
  processError({ issues: issue2.issues }, issue2.path);
8560
8560
  } else {
8561
- const fullpath = [...path73, ...issue2.path];
8561
+ const fullpath = [...path74, ...issue2.path];
8562
8562
  if (fullpath.length === 0) {
8563
8563
  result.errors.push(mapper(issue2));
8564
8564
  continue;
@@ -8588,9 +8588,9 @@ function treeifyError(error40, _mapper) {
8588
8588
  processError(error40);
8589
8589
  return result;
8590
8590
  }
8591
- function toDotPath(path73) {
8591
+ function toDotPath(path74) {
8592
8592
  const segs = [];
8593
- for (const seg of path73) {
8593
+ for (const seg of path74) {
8594
8594
  if (typeof seg === "number")
8595
8595
  segs.push(`[${seg}]`);
8596
8596
  else if (typeof seg === "symbol")
@@ -21596,7 +21596,7 @@ var require_ignore = __commonJS({
21596
21596
  // path matching.
21597
21597
  // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
21598
21598
  // @returns {TestResult} true if a file is ignored
21599
- test(path73, checkUnignored, mode) {
21599
+ test(path74, checkUnignored, mode) {
21600
21600
  let ignored = false;
21601
21601
  let unignored = false;
21602
21602
  let matchedRule;
@@ -21605,7 +21605,7 @@ var require_ignore = __commonJS({
21605
21605
  if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
21606
21606
  return;
21607
21607
  }
21608
- const matched = rule[mode].test(path73);
21608
+ const matched = rule[mode].test(path74);
21609
21609
  if (!matched) {
21610
21610
  return;
21611
21611
  }
@@ -21626,17 +21626,17 @@ var require_ignore = __commonJS({
21626
21626
  var throwError = (message, Ctor) => {
21627
21627
  throw new Ctor(message);
21628
21628
  };
21629
- var checkPath = (path73, originalPath, doThrow) => {
21630
- if (!isString(path73)) {
21629
+ var checkPath = (path74, originalPath, doThrow) => {
21630
+ if (!isString(path74)) {
21631
21631
  return doThrow(
21632
21632
  `path must be a string, but got \`${originalPath}\``,
21633
21633
  TypeError
21634
21634
  );
21635
21635
  }
21636
- if (!path73) {
21636
+ if (!path74) {
21637
21637
  return doThrow(`path must not be empty`, TypeError);
21638
21638
  }
21639
- if (checkPath.isNotRelative(path73)) {
21639
+ if (checkPath.isNotRelative(path74)) {
21640
21640
  const r = "`path.relative()`d";
21641
21641
  return doThrow(
21642
21642
  `path should be a ${r} string, but got "${originalPath}"`,
@@ -21645,7 +21645,7 @@ var require_ignore = __commonJS({
21645
21645
  }
21646
21646
  return true;
21647
21647
  };
21648
- var isNotRelative = (path73) => REGEX_TEST_INVALID_PATH.test(path73);
21648
+ var isNotRelative = (path74) => REGEX_TEST_INVALID_PATH.test(path74);
21649
21649
  checkPath.isNotRelative = isNotRelative;
21650
21650
  checkPath.convert = (p) => p;
21651
21651
  var Ignore = class {
@@ -21675,19 +21675,19 @@ var require_ignore = __commonJS({
21675
21675
  }
21676
21676
  // @returns {TestResult}
21677
21677
  _test(originalPath, cache2, checkUnignored, slices) {
21678
- const path73 = originalPath && checkPath.convert(originalPath);
21678
+ const path74 = originalPath && checkPath.convert(originalPath);
21679
21679
  checkPath(
21680
- path73,
21680
+ path74,
21681
21681
  originalPath,
21682
21682
  this._strictPathCheck ? throwError : RETURN_FALSE
21683
21683
  );
21684
- return this._t(path73, cache2, checkUnignored, slices);
21684
+ return this._t(path74, cache2, checkUnignored, slices);
21685
21685
  }
21686
- checkIgnore(path73) {
21687
- if (!REGEX_TEST_TRAILING_SLASH.test(path73)) {
21688
- return this.test(path73);
21686
+ checkIgnore(path74) {
21687
+ if (!REGEX_TEST_TRAILING_SLASH.test(path74)) {
21688
+ return this.test(path74);
21689
21689
  }
21690
- const slices = path73.split(SLASH).filter(Boolean);
21690
+ const slices = path74.split(SLASH).filter(Boolean);
21691
21691
  slices.pop();
21692
21692
  if (slices.length) {
21693
21693
  const parent = this._t(
@@ -21700,18 +21700,18 @@ var require_ignore = __commonJS({
21700
21700
  return parent;
21701
21701
  }
21702
21702
  }
21703
- return this._rules.test(path73, false, MODE_CHECK_IGNORE);
21703
+ return this._rules.test(path74, false, MODE_CHECK_IGNORE);
21704
21704
  }
21705
- _t(path73, cache2, checkUnignored, slices) {
21706
- if (path73 in cache2) {
21707
- return cache2[path73];
21705
+ _t(path74, cache2, checkUnignored, slices) {
21706
+ if (path74 in cache2) {
21707
+ return cache2[path74];
21708
21708
  }
21709
21709
  if (!slices) {
21710
- slices = path73.split(SLASH).filter(Boolean);
21710
+ slices = path74.split(SLASH).filter(Boolean);
21711
21711
  }
21712
21712
  slices.pop();
21713
21713
  if (!slices.length) {
21714
- return cache2[path73] = this._rules.test(path73, checkUnignored, MODE_IGNORE);
21714
+ return cache2[path74] = this._rules.test(path74, checkUnignored, MODE_IGNORE);
21715
21715
  }
21716
21716
  const parent = this._t(
21717
21717
  slices.join(SLASH) + SLASH,
@@ -21719,29 +21719,29 @@ var require_ignore = __commonJS({
21719
21719
  checkUnignored,
21720
21720
  slices
21721
21721
  );
21722
- return cache2[path73] = parent.ignored ? parent : this._rules.test(path73, checkUnignored, MODE_IGNORE);
21722
+ return cache2[path74] = parent.ignored ? parent : this._rules.test(path74, checkUnignored, MODE_IGNORE);
21723
21723
  }
21724
- ignores(path73) {
21725
- return this._test(path73, this._ignoreCache, false).ignored;
21724
+ ignores(path74) {
21725
+ return this._test(path74, this._ignoreCache, false).ignored;
21726
21726
  }
21727
21727
  createFilter() {
21728
- return (path73) => !this.ignores(path73);
21728
+ return (path74) => !this.ignores(path74);
21729
21729
  }
21730
21730
  filter(paths) {
21731
21731
  return makeArray(paths).filter(this.createFilter());
21732
21732
  }
21733
21733
  // @returns {TestResult}
21734
- test(path73) {
21735
- return this._test(path73, this._testCache, true);
21734
+ test(path74) {
21735
+ return this._test(path74, this._testCache, true);
21736
21736
  }
21737
21737
  };
21738
21738
  var factory = (options) => new Ignore(options);
21739
- var isPathValid = (path73) => checkPath(path73 && checkPath.convert(path73), path73, RETURN_FALSE);
21739
+ var isPathValid = (path74) => checkPath(path74 && checkPath.convert(path74), path74, RETURN_FALSE);
21740
21740
  var setupWindows = () => {
21741
21741
  const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
21742
21742
  checkPath.convert = makePosix;
21743
21743
  const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
21744
- checkPath.isNotRelative = (path73) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path73) || isNotRelative(path73);
21744
+ checkPath.isNotRelative = (path74) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path74) || isNotRelative(path74);
21745
21745
  };
21746
21746
  if (
21747
21747
  // Detect `process` so that it can run in browsers.
@@ -22530,10 +22530,10 @@ var require_src2 = __commonJS({
22530
22530
  var fs_1 = __require("fs");
22531
22531
  var debug_1 = __importDefault(require_src());
22532
22532
  var log2 = debug_1.default("@kwsites/file-exists");
22533
- function check2(path73, isFile, isDirectory) {
22534
- log2(`checking %s`, path73);
22533
+ function check2(path74, isFile, isDirectory) {
22534
+ log2(`checking %s`, path74);
22535
22535
  try {
22536
- const stat2 = fs_1.statSync(path73);
22536
+ const stat2 = fs_1.statSync(path74);
22537
22537
  if (stat2.isFile() && isFile) {
22538
22538
  log2(`[OK] path represents a file`);
22539
22539
  return true;
@@ -22553,8 +22553,8 @@ var require_src2 = __commonJS({
22553
22553
  throw e;
22554
22554
  }
22555
22555
  }
22556
- function exists2(path73, type = exports.READABLE) {
22557
- return check2(path73, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
22556
+ function exists2(path74, type = exports.READABLE) {
22557
+ return check2(path74, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
22558
22558
  }
22559
22559
  exports.exists = exists2;
22560
22560
  exports.FILE = 1;
@@ -23715,9 +23715,9 @@ function parseChangeSummaryJson(raw, allowedPaths, options) {
23715
23715
  const rawPath = typeof o.path === "string" ? o.path.trim() : "";
23716
23716
  const summary = typeof o.summary === "string" ? o.summary.trim() : "";
23717
23717
  if (!rawPath || !summary) continue;
23718
- const path73 = skip ? normalizeRepoRelativePath(rawPath) || rawPath : resolveChangeSummaryPathAgainstAllowed(rawPath, allowedPaths);
23719
- if (!path73) continue;
23720
- rows.push({ path: path73, summary: clampSummaryToAtMostTwoLines(summary) });
23718
+ const path74 = skip ? normalizeRepoRelativePath(rawPath) || rawPath : resolveChangeSummaryPathAgainstAllowed(rawPath, allowedPaths);
23719
+ if (!path74) continue;
23720
+ rows.push({ path: path74, summary: clampSummaryToAtMostTwoLines(summary) });
23721
23721
  }
23722
23722
  return rows;
23723
23723
  }
@@ -25044,8 +25044,8 @@ function randomSecret() {
25044
25044
  }
25045
25045
  return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
25046
25046
  }
25047
- async function requestPreviewApi(port, secret, method, path73, body) {
25048
- const url2 = `http://127.0.0.1:${port}${path73}`;
25047
+ async function requestPreviewApi(port, secret, method, path74, body) {
25048
+ const url2 = `http://127.0.0.1:${port}${path74}`;
25049
25049
  const headers = {
25050
25050
  [PREVIEW_SECRET_HEADER]: secret,
25051
25051
  "Content-Type": "application/json"
@@ -25057,7 +25057,7 @@ async function requestPreviewApi(port, secret, method, path73, body) {
25057
25057
  });
25058
25058
  const data = await res.json().catch(() => ({}));
25059
25059
  if (!res.ok) {
25060
- throw new Error(data?.error ?? `Preview API ${method} ${path73}: ${res.status}`);
25060
+ throw new Error(data?.error ?? `Preview API ${method} ${path74}: ${res.status}`);
25061
25061
  }
25062
25062
  return data;
25063
25063
  }
@@ -25272,7 +25272,7 @@ function installBridgeProcessResilience() {
25272
25272
  }
25273
25273
 
25274
25274
  // src/cli-version.ts
25275
- var CLI_VERSION = "0.1.58".length > 0 ? "0.1.58" : "0.0.0-dev";
25275
+ var CLI_VERSION = "0.1.60".length > 0 ? "0.1.60" : "0.0.0-dev";
25276
25276
 
25277
25277
  // src/connection/heartbeat/constants.ts
25278
25278
  var BRIDGE_APP_HEARTBEAT_INTERVAL_MS = 1e4;
@@ -26387,8 +26387,8 @@ function runPendingAuth(options) {
26387
26387
  };
26388
26388
  }
26389
26389
 
26390
- // src/dev-servers/manager/dev-server-constants.ts
26391
- var BRIDGE_CLOSE_DEV_SERVER_GRACE_MS = 0;
26390
+ // src/preview-environments/manager/preview-environment-constants.ts
26391
+ var BRIDGE_CLOSE_PREVIEW_ENVIRONMENT_GRACE_MS = 0;
26392
26392
  var BRIDGE_SHUTDOWN_GRACE_MS = 8e3;
26393
26393
 
26394
26394
  // src/runtime/cli-process-interrupt.ts
@@ -26807,7 +26807,7 @@ function readMigrationSql(filename, ...searchSubdirs) {
26807
26807
  join(moduleDir, "..", sub, filename),
26808
26808
  join(moduleDir, "..", "..", "dist", sub, filename)
26809
26809
  ]);
26810
- const resolved = candidates.find((path73) => existsSync(path73));
26810
+ const resolved = candidates.find((path74) => existsSync(path74));
26811
26811
  if (!resolved) {
26812
26812
  throw new Error(`Missing SQLite migration SQL: ${filename} (searched ${searchSubdirs.join(", ")})`);
26813
26813
  }
@@ -27095,7 +27095,7 @@ async function ensureCodeNavCacheSqliteInitialized() {
27095
27095
  }
27096
27096
 
27097
27097
  // src/connection/close-bridge-connection.ts
27098
- async function closeBridgeConnection(state, acpManager, devServerManager, log2) {
27098
+ async function closeBridgeConnection(state, acpManager, previewEnvironmentManager, log2) {
27099
27099
  requestCliImmediateShutdown();
27100
27100
  const say = log2 ?? logImmediate;
27101
27101
  say("Cleaning up connections\u2026");
@@ -27133,9 +27133,9 @@ async function closeBridgeConnection(state, acpManager, devServerManager, log2)
27133
27133
  }
27134
27134
  state.currentWs = null;
27135
27135
  }
27136
- if (devServerManager) {
27137
- say("Stopping local dev server processes\u2026");
27138
- await devServerManager.shutdownAllGraceful({ graceMs: BRIDGE_CLOSE_DEV_SERVER_GRACE_MS });
27136
+ if (previewEnvironmentManager) {
27137
+ say("Stopping local preview environment processes\u2026");
27138
+ await previewEnvironmentManager.shutdownAllGraceful({ graceMs: BRIDGE_CLOSE_PREVIEW_ENVIRONMENT_GRACE_MS });
27139
27139
  }
27140
27140
  try {
27141
27141
  closeAllCliSqliteConnections();
@@ -32194,8 +32194,8 @@ async function execGitFile(args, options) {
32194
32194
  }
32195
32195
 
32196
32196
  // src/git/changes/parse/normalize-git-diff-path.ts
32197
- function normalizeGitDiffPath(path73) {
32198
- return path73.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
32197
+ function normalizeGitDiffPath(path74) {
32198
+ return path74.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
32199
32199
  }
32200
32200
 
32201
32201
  // src/git/changes/parse/parse-name-status-entries.ts
@@ -32482,9 +32482,9 @@ async function collectTurnGitDiffFromPreTurnSnapshot(options) {
32482
32482
  // src/agents/acp/put-summarize-change-summaries.ts
32483
32483
  async function putEncryptedChangeSummaryRows(params) {
32484
32484
  const base = params.apiBaseUrl.replace(/\/+$/, "");
32485
- const entries = params.rows.map(({ path: path73, summary }) => {
32485
+ const entries = params.rows.map(({ path: path74, summary }) => {
32486
32486
  const enc = params.e2ee.encryptFields({ summary }, ["summary"]);
32487
- return { path: path73, summary: JSON.stringify(enc) };
32487
+ return { path: path74, summary: JSON.stringify(enc) };
32488
32488
  });
32489
32489
  const res = await fetch(
32490
32490
  `${base}/internal/sessions/${encodeURIComponent(params.sessionId)}/follow-ups/summarize-changes`,
@@ -33609,8 +33609,8 @@ function pathspec(...paths) {
33609
33609
  cache.set(key, paths);
33610
33610
  return key;
33611
33611
  }
33612
- function isPathSpec(path73) {
33613
- return path73 instanceof String && cache.has(path73);
33612
+ function isPathSpec(path74) {
33613
+ return path74 instanceof String && cache.has(path74);
33614
33614
  }
33615
33615
  function toPaths(pathSpec) {
33616
33616
  return cache.get(pathSpec) || [];
@@ -33699,8 +33699,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
33699
33699
  function forEachLineWithContent(input, callback) {
33700
33700
  return toLinesWithContent(input, true).map((line) => callback(line));
33701
33701
  }
33702
- function folderExists(path73) {
33703
- return (0, import_file_exists.exists)(path73, import_file_exists.FOLDER);
33702
+ function folderExists(path74) {
33703
+ return (0, import_file_exists.exists)(path74, import_file_exists.FOLDER);
33704
33704
  }
33705
33705
  function append(target, item) {
33706
33706
  if (Array.isArray(target)) {
@@ -34104,8 +34104,8 @@ function checkIsRepoRootTask() {
34104
34104
  commands,
34105
34105
  format: "utf-8",
34106
34106
  onError,
34107
- parser(path73) {
34108
- return /^\.(git)?$/.test(path73.trim());
34107
+ parser(path74) {
34108
+ return /^\.(git)?$/.test(path74.trim());
34109
34109
  }
34110
34110
  };
34111
34111
  }
@@ -34539,11 +34539,11 @@ function parseGrep(grep) {
34539
34539
  const paths = /* @__PURE__ */ new Set();
34540
34540
  const results = {};
34541
34541
  forEachLineWithContent(grep, (input) => {
34542
- const [path73, line, preview] = input.split(NULL);
34543
- paths.add(path73);
34544
- (results[path73] = results[path73] || []).push({
34542
+ const [path74, line, preview] = input.split(NULL);
34543
+ paths.add(path74);
34544
+ (results[path74] = results[path74] || []).push({
34545
34545
  line: asNumber(line),
34546
- path: path73,
34546
+ path: path74,
34547
34547
  preview
34548
34548
  });
34549
34549
  });
@@ -35308,14 +35308,14 @@ var init_hash_object = __esm2({
35308
35308
  init_task();
35309
35309
  }
35310
35310
  });
35311
- function parseInit(bare, path73, text) {
35311
+ function parseInit(bare, path74, text) {
35312
35312
  const response = String(text).trim();
35313
35313
  let result;
35314
35314
  if (result = initResponseRegex.exec(response)) {
35315
- return new InitSummary(bare, path73, false, result[1]);
35315
+ return new InitSummary(bare, path74, false, result[1]);
35316
35316
  }
35317
35317
  if (result = reInitResponseRegex.exec(response)) {
35318
- return new InitSummary(bare, path73, true, result[1]);
35318
+ return new InitSummary(bare, path74, true, result[1]);
35319
35319
  }
35320
35320
  let gitDir = "";
35321
35321
  const tokens = response.split(" ");
@@ -35326,7 +35326,7 @@ function parseInit(bare, path73, text) {
35326
35326
  break;
35327
35327
  }
35328
35328
  }
35329
- return new InitSummary(bare, path73, /^re/i.test(response), gitDir);
35329
+ return new InitSummary(bare, path74, /^re/i.test(response), gitDir);
35330
35330
  }
35331
35331
  var InitSummary;
35332
35332
  var initResponseRegex;
@@ -35335,9 +35335,9 @@ var init_InitSummary = __esm2({
35335
35335
  "src/lib/responses/InitSummary.ts"() {
35336
35336
  "use strict";
35337
35337
  InitSummary = class {
35338
- constructor(bare, path73, existing, gitDir) {
35338
+ constructor(bare, path74, existing, gitDir) {
35339
35339
  this.bare = bare;
35340
- this.path = path73;
35340
+ this.path = path74;
35341
35341
  this.existing = existing;
35342
35342
  this.gitDir = gitDir;
35343
35343
  }
@@ -35349,7 +35349,7 @@ var init_InitSummary = __esm2({
35349
35349
  function hasBareCommand(command) {
35350
35350
  return command.includes(bareCommand);
35351
35351
  }
35352
- function initTask(bare = false, path73, customArgs) {
35352
+ function initTask(bare = false, path74, customArgs) {
35353
35353
  const commands = ["init", ...customArgs];
35354
35354
  if (bare && !hasBareCommand(commands)) {
35355
35355
  commands.splice(1, 0, bareCommand);
@@ -35358,7 +35358,7 @@ function initTask(bare = false, path73, customArgs) {
35358
35358
  commands,
35359
35359
  format: "utf-8",
35360
35360
  parser(text) {
35361
- return parseInit(commands.includes("--bare"), path73, text);
35361
+ return parseInit(commands.includes("--bare"), path74, text);
35362
35362
  }
35363
35363
  };
35364
35364
  }
@@ -36174,12 +36174,12 @@ var init_FileStatusSummary = __esm2({
36174
36174
  "use strict";
36175
36175
  fromPathRegex = /^(.+)\0(.+)$/;
36176
36176
  FileStatusSummary = class {
36177
- constructor(path73, index, working_dir) {
36178
- this.path = path73;
36177
+ constructor(path74, index, working_dir) {
36178
+ this.path = path74;
36179
36179
  this.index = index;
36180
36180
  this.working_dir = working_dir;
36181
36181
  if (index === "R" || working_dir === "R") {
36182
- const detail = fromPathRegex.exec(path73) || [null, path73, path73];
36182
+ const detail = fromPathRegex.exec(path74) || [null, path74, path74];
36183
36183
  this.from = detail[2] || "";
36184
36184
  this.path = detail[1] || "";
36185
36185
  }
@@ -36210,14 +36210,14 @@ function splitLine(result, lineStr) {
36210
36210
  default:
36211
36211
  return;
36212
36212
  }
36213
- function data(index, workingDir, path73) {
36213
+ function data(index, workingDir, path74) {
36214
36214
  const raw = `${index}${workingDir}`;
36215
36215
  const handler = parsers6.get(raw);
36216
36216
  if (handler) {
36217
- handler(result, path73);
36217
+ handler(result, path74);
36218
36218
  }
36219
36219
  if (raw !== "##" && raw !== "!!") {
36220
- result.files.push(new FileStatusSummary(path73, index, workingDir));
36220
+ result.files.push(new FileStatusSummary(path74, index, workingDir));
36221
36221
  }
36222
36222
  }
36223
36223
  }
@@ -36526,9 +36526,9 @@ var init_simple_git_api = __esm2({
36526
36526
  next
36527
36527
  );
36528
36528
  }
36529
- hashObject(path73, write) {
36529
+ hashObject(path74, write) {
36530
36530
  return this._runTask(
36531
- hashObjectTask(path73, write === true),
36531
+ hashObjectTask(path74, write === true),
36532
36532
  trailingFunctionArgument(arguments)
36533
36533
  );
36534
36534
  }
@@ -36881,8 +36881,8 @@ var init_branch = __esm2({
36881
36881
  }
36882
36882
  });
36883
36883
  function toPath(input) {
36884
- const path73 = input.trim().replace(/^["']|["']$/g, "");
36885
- return path73 && normalize3(path73);
36884
+ const path74 = input.trim().replace(/^["']|["']$/g, "");
36885
+ return path74 && normalize3(path74);
36886
36886
  }
36887
36887
  var parseCheckIgnore;
36888
36888
  var init_CheckIgnore = __esm2({
@@ -37196,8 +37196,8 @@ __export2(sub_module_exports, {
37196
37196
  subModuleTask: () => subModuleTask,
37197
37197
  updateSubModuleTask: () => updateSubModuleTask
37198
37198
  });
37199
- function addSubModuleTask(repo, path73) {
37200
- return subModuleTask(["add", repo, path73]);
37199
+ function addSubModuleTask(repo, path74) {
37200
+ return subModuleTask(["add", repo, path74]);
37201
37201
  }
37202
37202
  function initSubModuleTask(customArgs) {
37203
37203
  return subModuleTask(["init", ...customArgs]);
@@ -37530,8 +37530,8 @@ var require_git = __commonJS2({
37530
37530
  }
37531
37531
  return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
37532
37532
  };
37533
- Git2.prototype.submoduleAdd = function(repo, path73, then) {
37534
- return this._runTask(addSubModuleTask2(repo, path73), trailingFunctionArgument2(arguments));
37533
+ Git2.prototype.submoduleAdd = function(repo, path74, then) {
37534
+ return this._runTask(addSubModuleTask2(repo, path74), trailingFunctionArgument2(arguments));
37535
37535
  };
37536
37536
  Git2.prototype.submoduleUpdate = function(args, then) {
37537
37537
  return this._runTask(
@@ -38267,8 +38267,8 @@ function parseNumstatEntries(lines) {
38267
38267
  }
38268
38268
  function parseNumstat(lines) {
38269
38269
  const m = /* @__PURE__ */ new Map();
38270
- for (const [path73, entry] of parseNumstatEntries(lines)) {
38271
- m.set(path73, { additions: entry.additions, deletions: entry.deletions });
38270
+ for (const [path74, entry] of parseNumstatEntries(lines)) {
38271
+ m.set(path74, { additions: entry.additions, deletions: entry.deletions });
38272
38272
  }
38273
38273
  return m;
38274
38274
  }
@@ -39575,18 +39575,32 @@ import * as fs27 from "node:fs";
39575
39575
  // src/git/worktrees/worktree-remove.ts
39576
39576
  import * as fs26 from "node:fs";
39577
39577
 
39578
+ // src/worktrees/is-removable-session-worktree-checkout-path.ts
39579
+ import path42 from "node:path";
39580
+ function isBridgeRootCheckoutPath(checkoutPath) {
39581
+ return normalizeResolvedPath(checkoutPath) === normalizeResolvedPath(getBridgeRoot());
39582
+ }
39583
+ function isRemovableSessionWorktreeCheckoutPath(checkoutPath, worktreesRootPath) {
39584
+ if (isBridgeRootCheckoutPath(checkoutPath)) return false;
39585
+ const normalized = normalizeResolvedPath(checkoutPath);
39586
+ const worktreesRoot = normalizeResolvedPath(worktreesRootPath);
39587
+ const rel = path42.relative(worktreesRoot, normalized);
39588
+ if (rel === "" || rel.startsWith("..") || path42.isAbsolute(rel)) return false;
39589
+ return true;
39590
+ }
39591
+
39578
39592
  // src/git/worktrees/resolve-main-repo-from-git-file.ts
39579
39593
  import * as fs25 from "node:fs";
39580
- import * as path42 from "node:path";
39594
+ import * as path43 from "node:path";
39581
39595
  function resolveMainRepoFromWorktreeGitFile(wt) {
39582
- const gitDirFile = path42.join(wt, ".git");
39596
+ const gitDirFile = path43.join(wt, ".git");
39583
39597
  if (!fs25.existsSync(gitDirFile) || !fs25.statSync(gitDirFile).isFile()) return "";
39584
39598
  const first2 = fs25.readFileSync(gitDirFile, "utf8").trim();
39585
39599
  const m = first2.match(/^gitdir:\s*(.+)$/im);
39586
39600
  if (!m) return "";
39587
- const gitWorktreePath = path42.resolve(wt, m[1].trim());
39588
- const gitDir = path42.dirname(path42.dirname(gitWorktreePath));
39589
- return path42.dirname(gitDir);
39601
+ const gitWorktreePath = path43.resolve(wt, m[1].trim());
39602
+ const gitDir = path43.dirname(path43.dirname(gitWorktreePath));
39603
+ return path43.dirname(gitDir);
39590
39604
  }
39591
39605
 
39592
39606
  // src/git/worktrees/worktree-remove.ts
@@ -39594,32 +39608,44 @@ async function gitWorktreeRemoveForce(worktreePath) {
39594
39608
  const mainRepo = resolveMainRepoFromWorktreeGitFile(worktreePath);
39595
39609
  if (mainRepo) {
39596
39610
  await cliSimpleGit(mainRepo).raw(["worktree", "remove", "--force", worktreePath]);
39597
- } else {
39598
- fs26.rmSync(worktreePath, { recursive: true, force: true });
39611
+ return true;
39599
39612
  }
39613
+ if (isBridgeRootCheckoutPath(worktreePath)) return false;
39614
+ fs26.rmSync(worktreePath, { recursive: true, force: true });
39615
+ return true;
39600
39616
  }
39601
39617
 
39602
39618
  // src/worktrees/remove-session-worktrees.ts
39603
- async function removeSessionWorktrees(paths, log2) {
39619
+ async function removeSessionWorktrees(paths, worktreesRootPath, log2) {
39604
39620
  for (const wt of paths) {
39621
+ if (!isRemovableSessionWorktreeCheckoutPath(wt, worktreesRootPath)) {
39622
+ log2(`[worktrees] Skipping removal of ${wt} (bridge root or outside worktrees root).`);
39623
+ continue;
39624
+ }
39605
39625
  try {
39606
- await gitWorktreeRemoveForce(wt);
39607
- log2(`[worktrees] Removed worktree ${wt}`);
39626
+ const removed = await gitWorktreeRemoveForce(wt);
39627
+ if (removed) {
39628
+ log2(`[worktrees] Removed worktree ${wt}`);
39629
+ } else {
39630
+ log2(`[worktrees] Skipping removal of ${wt} (bridge root).`);
39631
+ }
39608
39632
  } catch (e) {
39609
39633
  log2(`[worktrees] Remove failed for ${wt}: ${e instanceof Error ? e.message : String(e)}`);
39610
- try {
39611
- fs27.rmSync(wt, { recursive: true, force: true });
39612
- } catch {
39634
+ if (isRemovableSessionWorktreeCheckoutPath(wt, worktreesRootPath)) {
39635
+ try {
39636
+ fs27.rmSync(wt, { recursive: true, force: true });
39637
+ } catch {
39638
+ }
39613
39639
  }
39614
39640
  }
39615
39641
  }
39616
39642
  }
39617
39643
 
39618
39644
  // src/worktrees/manager/git/remove-session-worktree-checkouts.ts
39619
- async function removeSessionWorktreeCheckouts(cache2, sessionId, log2) {
39645
+ async function removeSessionWorktreeCheckouts(cache2, sessionId, worktreesRootPath, log2) {
39620
39646
  const paths = cache2.clearSession(sessionId);
39621
39647
  if (!paths?.length) return;
39622
- await removeSessionWorktrees(paths, log2);
39648
+ await removeSessionWorktrees(paths, worktreesRootPath, log2);
39623
39649
  }
39624
39650
 
39625
39651
  // src/git/branches/rename-branch.ts
@@ -39652,11 +39678,11 @@ async function renameSessionWorktreeBranch(cache2, sessionId, newBranch, log2) {
39652
39678
 
39653
39679
  // src/worktrees/discovery/discover-session-worktree-on-disk.ts
39654
39680
  import * as fs31 from "node:fs";
39655
- import * as path47 from "node:path";
39681
+ import * as path48 from "node:path";
39656
39682
 
39657
39683
  // src/worktrees/discovery/collect-worktree-paths.ts
39658
39684
  import * as fs29 from "node:fs";
39659
- import * as path44 from "node:path";
39685
+ import * as path45 from "node:path";
39660
39686
 
39661
39687
  // src/worktrees/discovery/disk-walk-constants.ts
39662
39688
  var DISK_WALK_YIELD_EVERY = 64;
@@ -39685,7 +39711,7 @@ function shouldSkipDiskWalkEntry(name) {
39685
39711
 
39686
39712
  // src/worktrees/discovery/disk-walk-utils.ts
39687
39713
  import * as fs28 from "node:fs";
39688
- import * as path43 from "node:path";
39714
+ import * as path44 from "node:path";
39689
39715
  async function yieldDuringDiskWalk(state) {
39690
39716
  state.entries++;
39691
39717
  if (state.entries % DISK_WALK_YIELD_EVERY !== 0) return true;
@@ -39695,7 +39721,7 @@ async function yieldDuringDiskWalk(state) {
39695
39721
  }
39696
39722
  async function isGitDir(dirPath) {
39697
39723
  try {
39698
- await fs28.promises.access(path43.join(dirPath, ".git"));
39724
+ await fs28.promises.access(path44.join(dirPath, ".git"));
39699
39725
  return true;
39700
39726
  } catch {
39701
39727
  return false;
@@ -39709,7 +39735,7 @@ async function collectGitRepoRootsUnderDirectory(rootPath) {
39709
39735
  const walk = async (dir) => {
39710
39736
  if (!await yieldDuringDiskWalk(state)) return;
39711
39737
  if (await isGitDir(dir)) {
39712
- out.push(path44.resolve(dir));
39738
+ out.push(path45.resolve(dir));
39713
39739
  return;
39714
39740
  }
39715
39741
  let entries;
@@ -39720,12 +39746,12 @@ async function collectGitRepoRootsUnderDirectory(rootPath) {
39720
39746
  }
39721
39747
  for (const e of entries) {
39722
39748
  if (shouldSkipDiskWalkEntry(e.name)) continue;
39723
- const full = path44.join(dir, e.name);
39749
+ const full = path45.join(dir, e.name);
39724
39750
  if (!e.isDirectory()) continue;
39725
39751
  await walk(full);
39726
39752
  }
39727
39753
  };
39728
- await walk(path44.resolve(rootPath));
39754
+ await walk(path45.resolve(rootPath));
39729
39755
  return { paths: [...new Set(out)], entriesVisited: state.entries };
39730
39756
  }
39731
39757
  async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK_MAX_DEPTH) {
@@ -39742,10 +39768,10 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
39742
39768
  }
39743
39769
  for (const e of entries) {
39744
39770
  if (shouldSkipDiskWalkEntry(e.name)) continue;
39745
- const full = path44.join(dir, e.name);
39771
+ const full = path45.join(dir, e.name);
39746
39772
  if (!e.isDirectory()) continue;
39747
39773
  if (e.name === sessionId) {
39748
- if (await isGitDir(full)) out.push(path44.resolve(full));
39774
+ if (await isGitDir(full)) out.push(path45.resolve(full));
39749
39775
  continue;
39750
39776
  }
39751
39777
  if (await isGitDir(full)) continue;
@@ -39757,14 +39783,14 @@ async function collectWorktreeRootsNamed(root, sessionId, maxDepth = LEGACY_WALK
39757
39783
  }
39758
39784
 
39759
39785
  // src/worktrees/discovery/layout-keys-for-bridge-root.ts
39760
- import * as path45 from "node:path";
39786
+ import * as path46 from "node:path";
39761
39787
  function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
39762
- const bridge = path45.resolve(bridgeRoot);
39788
+ const bridge = path46.resolve(bridgeRoot);
39763
39789
  const preferred = getLauncherDirNameIfPresent(layout, bridgeRoot);
39764
39790
  const relevant = layout.launcherCwds.filter((e) => {
39765
- const entry = path45.resolve(e.absolutePath);
39766
- return bridge === entry || bridge.startsWith(entry + path45.sep) || entry.startsWith(bridge + path45.sep);
39767
- }).sort((a, b) => path45.resolve(b.absolutePath).length - path45.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
39791
+ const entry = path46.resolve(e.absolutePath);
39792
+ return bridge === entry || bridge.startsWith(entry + path46.sep) || entry.startsWith(bridge + path46.sep);
39793
+ }).sort((a, b) => path46.resolve(b.absolutePath).length - path46.resolve(a.absolutePath).length).map((e) => e.dirName).filter((name) => keysOnDisk.includes(name));
39768
39794
  const ordered = [];
39769
39795
  const seen = /* @__PURE__ */ new Set();
39770
39796
  const add = (k) => {
@@ -39783,7 +39809,7 @@ function layoutKeysForBridgeRoot(layout, bridgeRoot, keysOnDisk) {
39783
39809
 
39784
39810
  // src/worktrees/discovery/try-binding-from-session-directory.ts
39785
39811
  import * as fs30 from "node:fs";
39786
- import * as path46 from "node:path";
39812
+ import * as path47 from "node:path";
39787
39813
  async function tryBindingFromSessionDirectory(sessionDir) {
39788
39814
  let st;
39789
39815
  try {
@@ -39794,7 +39820,7 @@ async function tryBindingFromSessionDirectory(sessionDir) {
39794
39820
  if (!st.isDirectory()) return null;
39795
39821
  const { paths: worktreePaths } = await collectGitRepoRootsUnderDirectory(sessionDir);
39796
39822
  if (worktreePaths.length === 0) return null;
39797
- const abs = path46.resolve(sessionDir);
39823
+ const abs = path47.resolve(sessionDir);
39798
39824
  return {
39799
39825
  sessionParentPath: abs,
39800
39826
  workingTreeRelRoot: abs,
@@ -39818,7 +39844,7 @@ async function discoverSessionWorktreeOnDisk(options) {
39818
39844
  try {
39819
39845
  for (const name of await fs31.promises.readdir(worktreesRootPath)) {
39820
39846
  if (name.startsWith(".")) continue;
39821
- const p = path47.join(worktreesRootPath, name);
39847
+ const p = path48.join(worktreesRootPath, name);
39822
39848
  let st;
39823
39849
  try {
39824
39850
  st = await fs31.promises.stat(p);
@@ -39835,7 +39861,7 @@ async function discoverSessionWorktreeOnDisk(options) {
39835
39861
  for (const key of keys) {
39836
39862
  if (isCliImmediateShutdownRequested()) return null;
39837
39863
  await yieldToEventLoop();
39838
- const layoutRoot = path47.join(worktreesRootPath, key);
39864
+ const layoutRoot = path48.join(worktreesRootPath, key);
39839
39865
  let layoutSt;
39840
39866
  try {
39841
39867
  layoutSt = await fs31.promises.stat(layoutRoot);
@@ -39843,16 +39869,16 @@ async function discoverSessionWorktreeOnDisk(options) {
39843
39869
  continue;
39844
39870
  }
39845
39871
  if (!layoutSt.isDirectory()) continue;
39846
- const sessionDir = path47.join(layoutRoot, sid);
39872
+ const sessionDir = path48.join(layoutRoot, sid);
39847
39873
  const nested = await tryBindingFromSessionDirectory(sessionDir);
39848
39874
  if (nested) return nested;
39849
39875
  const legacy = await collectWorktreeRootsNamed(layoutRoot, sid);
39850
39876
  if (legacy.paths.length > 0) {
39851
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path47.resolve(legacy.paths[0]);
39877
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacy.paths) ?? path48.resolve(legacy.paths[0]);
39852
39878
  return {
39853
- sessionParentPath: path47.resolve(isolated),
39854
- workingTreeRelRoot: path47.resolve(layoutRoot),
39855
- repoCheckoutPaths: legacy.paths.map((p) => path47.resolve(p))
39879
+ sessionParentPath: path48.resolve(isolated),
39880
+ workingTreeRelRoot: path48.resolve(layoutRoot),
39881
+ repoCheckoutPaths: legacy.paths.map((p) => path48.resolve(p))
39856
39882
  };
39857
39883
  }
39858
39884
  }
@@ -39861,29 +39887,29 @@ async function discoverSessionWorktreeOnDisk(options) {
39861
39887
 
39862
39888
  // src/worktrees/discovery/discover-session-worktrees-under-session-worktree-root.ts
39863
39889
  import * as fs32 from "node:fs";
39864
- import * as path49 from "node:path";
39890
+ import * as path50 from "node:path";
39865
39891
 
39866
39892
  // src/worktrees/discovery/discover-legacy-binding-ascending-from-checkout.ts
39867
- import * as path48 from "node:path";
39893
+ import * as path49 from "node:path";
39868
39894
  async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPath) {
39869
39895
  const sid = sessionId.trim();
39870
39896
  if (!sid) return null;
39871
- const hintR = path48.resolve(checkoutPath);
39897
+ const hintR = path49.resolve(checkoutPath);
39872
39898
  let best = null;
39873
- let cur = path48.dirname(hintR);
39899
+ let cur = path49.dirname(hintR);
39874
39900
  for (let i = 0; i < 40; i++) {
39875
39901
  if (isCliImmediateShutdownRequested()) return best;
39876
39902
  await yieldToEventLoop();
39877
39903
  const paths = await collectWorktreeRootsNamed(cur, sid);
39878
- if (paths.paths.some((p) => path48.resolve(p) === hintR)) {
39879
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path48.resolve(paths.paths[0]);
39904
+ if (paths.paths.some((p) => path49.resolve(p) === hintR)) {
39905
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(paths.paths) ?? path49.resolve(paths.paths[0]);
39880
39906
  best = {
39881
- sessionParentPath: path48.resolve(isolated),
39882
- workingTreeRelRoot: path48.resolve(cur),
39883
- repoCheckoutPaths: paths.paths.map((p) => path48.resolve(p))
39907
+ sessionParentPath: path49.resolve(isolated),
39908
+ workingTreeRelRoot: path49.resolve(cur),
39909
+ repoCheckoutPaths: paths.paths.map((p) => path49.resolve(p))
39884
39910
  };
39885
39911
  }
39886
- const next = path48.dirname(cur);
39912
+ const next = path49.dirname(cur);
39887
39913
  if (next === cur) break;
39888
39914
  cur = next;
39889
39915
  }
@@ -39894,12 +39920,12 @@ async function discoverLegacyBindingAscendingFromCheckout(sessionId, checkoutPat
39894
39920
  async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionWorktreeRootPathOrHint, sessionId) {
39895
39921
  const sid = sessionId.trim();
39896
39922
  if (!sid) return null;
39897
- const hint = path49.resolve(sessionWorktreeRootPathOrHint);
39898
- const underHint = await tryBindingFromSessionDirectory(path49.join(hint, sid));
39923
+ const hint = path50.resolve(sessionWorktreeRootPathOrHint);
39924
+ const underHint = await tryBindingFromSessionDirectory(path50.join(hint, sid));
39899
39925
  if (underHint) return underHint;
39900
39926
  const direct = await tryBindingFromSessionDirectory(hint);
39901
39927
  if (direct) {
39902
- if (path49.basename(hint) === sid && await isGitDir(hint)) {
39928
+ if (path50.basename(hint) === sid && await isGitDir(hint)) {
39903
39929
  const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
39904
39930
  if (legacyFromCheckout && legacyFromCheckout.repoCheckoutPaths.length > direct.repoCheckoutPaths.length) {
39905
39931
  return legacyFromCheckout;
@@ -39907,7 +39933,7 @@ async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionWorktreeR
39907
39933
  }
39908
39934
  return direct;
39909
39935
  }
39910
- if (path49.basename(hint) === sid && await isGitDir(hint)) {
39936
+ if (path50.basename(hint) === sid && await isGitDir(hint)) {
39911
39937
  const legacyFromCheckout = await discoverLegacyBindingAscendingFromCheckout(sid, hint);
39912
39938
  if (legacyFromCheckout) return legacyFromCheckout;
39913
39939
  }
@@ -39920,11 +39946,11 @@ async function discoverSessionWorktreesUnderSessionWorktreeRoot(sessionWorktreeR
39920
39946
  if (!st.isDirectory()) return null;
39921
39947
  const legacyPaths = await collectWorktreeRootsNamed(hint, sid);
39922
39948
  if (legacyPaths.paths.length === 0) return null;
39923
- const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path49.resolve(legacyPaths.paths[0]);
39949
+ const isolated = resolveIsolatedSessionParentPathFromCheckouts(legacyPaths.paths) ?? path50.resolve(legacyPaths.paths[0]);
39924
39950
  return {
39925
- sessionParentPath: path49.resolve(isolated),
39951
+ sessionParentPath: path50.resolve(isolated),
39926
39952
  workingTreeRelRoot: hint,
39927
- repoCheckoutPaths: legacyPaths.paths.map((p) => path49.resolve(p))
39953
+ repoCheckoutPaths: legacyPaths.paths.map((p) => path50.resolve(p))
39928
39954
  };
39929
39955
  }
39930
39956
 
@@ -39986,11 +40012,11 @@ function parseSessionParent(v) {
39986
40012
 
39987
40013
  // src/worktrees/prepare-new-session-worktrees.ts
39988
40014
  import * as fs34 from "node:fs";
39989
- import * as path51 from "node:path";
40015
+ import * as path52 from "node:path";
39990
40016
 
39991
40017
  // src/git/discover-repos.ts
39992
40018
  import * as fs33 from "node:fs";
39993
- import * as path50 from "node:path";
40019
+ import * as path51 from "node:path";
39994
40020
  var GIT_DISCOVER_YIELD_EVERY = 32;
39995
40021
  async function yieldGitDiscoverWork(entryCount) {
39996
40022
  if (entryCount > 0 && entryCount % GIT_DISCOVER_YIELD_EVERY === 0) {
@@ -39999,7 +40025,7 @@ async function yieldGitDiscoverWork(entryCount) {
39999
40025
  }
40000
40026
  async function discoverGitRepos(cwd = getBridgeRoot()) {
40001
40027
  const result = [];
40002
- const cwdResolved = path50.resolve(cwd);
40028
+ const cwdResolved = path51.resolve(cwd);
40003
40029
  if (await isGitRepoDirectory(cwdResolved)) {
40004
40030
  const remoteUrl = await getRemoteOriginUrl(cwdResolved);
40005
40031
  result.push({ absolutePath: cwdResolved, remoteUrl });
@@ -40014,7 +40040,7 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
40014
40040
  await yieldGitDiscoverWork(i + 1);
40015
40041
  const ent = entries[i];
40016
40042
  if (!ent.isDirectory()) continue;
40017
- const childPath2 = path50.join(cwdResolved, ent.name);
40043
+ const childPath2 = path51.join(cwdResolved, ent.name);
40018
40044
  if (await isGitRepoDirectory(childPath2)) {
40019
40045
  const remoteUrl = await getRemoteOriginUrl(childPath2);
40020
40046
  result.push({ absolutePath: childPath2, remoteUrl });
@@ -40023,12 +40049,12 @@ async function discoverGitRepos(cwd = getBridgeRoot()) {
40023
40049
  return result;
40024
40050
  }
40025
40051
  async function discoverGitReposUnderRoot(rootPath) {
40026
- const root = path50.resolve(rootPath);
40052
+ const root = path51.resolve(rootPath);
40027
40053
  const roots = [];
40028
40054
  let walkEntries = 0;
40029
40055
  async function walk(dir) {
40030
40056
  if (await isGitRepoDirectory(dir)) {
40031
- roots.push(path50.resolve(dir));
40057
+ roots.push(path51.resolve(dir));
40032
40058
  return;
40033
40059
  }
40034
40060
  let entries;
@@ -40041,7 +40067,7 @@ async function discoverGitReposUnderRoot(rootPath) {
40041
40067
  await yieldGitDiscoverWork(++walkEntries);
40042
40068
  const ent = entries[i];
40043
40069
  if (!ent.isDirectory() || ent.name === ".git") continue;
40044
- await walk(path50.join(dir, ent.name));
40070
+ await walk(path51.join(dir, ent.name));
40045
40071
  }
40046
40072
  }
40047
40073
  await walk(root);
@@ -40076,10 +40102,10 @@ function resolveBaseRefForRepo(relNorm, baseBranches) {
40076
40102
  }
40077
40103
  async function prepareNewSessionWorktrees(options) {
40078
40104
  const { worktreesRootPath, bridgeRoot, sessionId, layout, log: log2, worktreeBaseBranches } = options;
40079
- const bridgeResolved = path51.resolve(bridgeRoot);
40105
+ const bridgeResolved = path52.resolve(bridgeRoot);
40080
40106
  const cwdKey = allocateDirNameForLauncherCwd(layout, bridgeResolved);
40081
- const bridgeKeyDir = path51.join(worktreesRootPath, cwdKey);
40082
- const sessionDir = path51.join(bridgeKeyDir, sessionId);
40107
+ const bridgeKeyDir = path52.join(worktreesRootPath, cwdKey);
40108
+ const sessionDir = path52.join(bridgeKeyDir, sessionId);
40083
40109
  const repos = await discoverGitReposUnderRoot(bridgeResolved);
40084
40110
  if (repos.length === 0) {
40085
40111
  log2("[worktrees] No Git repositories under bridge root; skipping worktree creation.");
@@ -40089,12 +40115,12 @@ async function prepareNewSessionWorktrees(options) {
40089
40115
  const worktreePaths = [];
40090
40116
  fs34.mkdirSync(sessionDir, { recursive: true });
40091
40117
  for (const repo of repos) {
40092
- let rel = path51.relative(bridgeResolved, repo.absolutePath);
40093
- if (rel.startsWith("..") || path51.isAbsolute(rel)) continue;
40118
+ let rel = path52.relative(bridgeResolved, repo.absolutePath);
40119
+ if (rel.startsWith("..") || path52.isAbsolute(rel)) continue;
40094
40120
  const relNorm = normalizeRepoRelPath2(rel === "" ? "." : rel);
40095
- const wtPath = relNorm === "." ? sessionDir : path51.join(sessionDir, relNorm);
40121
+ const wtPath = relNorm === "." ? sessionDir : path52.join(sessionDir, relNorm);
40096
40122
  if (relNorm !== ".") {
40097
- fs34.mkdirSync(path51.dirname(wtPath), { recursive: true });
40123
+ fs34.mkdirSync(path52.dirname(wtPath), { recursive: true });
40098
40124
  }
40099
40125
  const baseRef = resolveBaseRefForRepo(relNorm, worktreeBaseBranches);
40100
40126
  try {
@@ -40147,9 +40173,9 @@ async function resolveExistingSessionParentPath(sessionId, cache2, discover) {
40147
40173
  }
40148
40174
 
40149
40175
  // src/worktrees/manager/resolve-explicit-session-parent-path.ts
40150
- import * as path52 from "node:path";
40176
+ import * as path53 from "node:path";
40151
40177
  async function resolveExplicitSessionParentPath(params) {
40152
- const resolved = path52.resolve(params.parentPathRaw);
40178
+ const resolved = path53.resolve(params.parentPathRaw);
40153
40179
  if (parseSessionParent(params.sessionParent) !== "worktrees_root") {
40154
40180
  return resolved;
40155
40181
  }
@@ -40166,7 +40192,7 @@ async function resolveExplicitSessionParentPath(params) {
40166
40192
  await yieldToEventLoop();
40167
40193
  const tryRoot = await discoverSessionWorktreesUnderSessionWorktreeRoot(cur, params.sessionId);
40168
40194
  if (tryRoot) return rememberAndReturn(tryRoot);
40169
- const next = path52.dirname(cur);
40195
+ const next = path53.dirname(cur);
40170
40196
  if (next === cur) break;
40171
40197
  cur = next;
40172
40198
  }
@@ -40276,7 +40302,7 @@ function createSessionWorktreeGitApi(ctx) {
40276
40302
  await renameSessionWorktreeBranch(ctx.cache, sessionId, newBranch, ctx.log);
40277
40303
  },
40278
40304
  async removeSessionWorktrees(sessionId) {
40279
- await removeSessionWorktreeCheckouts(ctx.cache, sessionId, ctx.log);
40305
+ await removeSessionWorktreeCheckouts(ctx.cache, sessionId, ctx.worktreesRootPath, ctx.log);
40280
40306
  },
40281
40307
  async commitSession(params) {
40282
40308
  return commitSessionWorktree(ctx.cache, params);
@@ -40305,17 +40331,17 @@ var SessionWorktreeManager = class {
40305
40331
  };
40306
40332
 
40307
40333
  // src/worktrees/manager/default-worktrees-root-path.ts
40308
- import * as path53 from "node:path";
40334
+ import * as path54 from "node:path";
40309
40335
  import os9 from "node:os";
40310
40336
  function defaultWorktreesRootPath() {
40311
- return path53.join(os9.homedir(), ".buildautomaton", "worktrees");
40337
+ return path54.join(os9.homedir(), ".buildautomaton", "worktrees");
40312
40338
  }
40313
40339
 
40314
40340
  // src/files/watch-file-index.ts
40315
- import path58 from "node:path";
40341
+ import path59 from "node:path";
40316
40342
 
40317
40343
  // src/files/index/build-file-index.ts
40318
- import path54 from "node:path";
40344
+ import path55 from "node:path";
40319
40345
 
40320
40346
  // src/files/index/file-index-sqlite-lock.ts
40321
40347
  var fileIndexChain = Promise.resolve();
@@ -40406,7 +40432,7 @@ function assertNotShutdown2() {
40406
40432
  if (isCliImmediateShutdownRequested()) throw new CliSqliteInterrupted();
40407
40433
  }
40408
40434
  async function buildFileIndexAsync(cwd) {
40409
- const resolved = path54.resolve(cwd);
40435
+ const resolved = path55.resolve(cwd);
40410
40436
  await yieldToEventLoop();
40411
40437
  assertNotShutdown2();
40412
40438
  const paths = await collectWorkspacePathsAsync(resolved);
@@ -40419,7 +40445,7 @@ async function buildFileIndexAsync(cwd) {
40419
40445
  }
40420
40446
 
40421
40447
  // src/files/index/ensure-file-index.ts
40422
- import path55 from "node:path";
40448
+ import path56 from "node:path";
40423
40449
 
40424
40450
  // src/files/index/search-file-index.ts
40425
40451
  function escapeLikePattern(fragment) {
@@ -40471,7 +40497,7 @@ async function searchBridgeFilePathsAsync(resolvedCwd, query, limit = 100) {
40471
40497
 
40472
40498
  // src/files/index/ensure-file-index.ts
40473
40499
  async function ensureFileIndexAsync(cwd) {
40474
- const resolved = path55.resolve(cwd);
40500
+ const resolved = path56.resolve(cwd);
40475
40501
  if (await bridgeFileIndexIsPopulated(resolved)) {
40476
40502
  return { fromCache: true, pathCount: await bridgeFileIndexPathCount(resolved) };
40477
40503
  }
@@ -40520,10 +40546,10 @@ function createFileIndexFsWatcher(resolved, schedule) {
40520
40546
 
40521
40547
  // src/files/index/file-index-incremental-symbol-updates.ts
40522
40548
  import fs35 from "node:fs";
40523
- import path56 from "node:path";
40549
+ import path57 from "node:path";
40524
40550
  async function applyIncrementalSymbolIndexUpdates(resolved, relPaths) {
40525
40551
  for (const rel of relPaths) {
40526
- const absPath = path56.join(resolved, rel);
40552
+ const absPath = path57.join(resolved, rel);
40527
40553
  try {
40528
40554
  const stat2 = await fs35.promises.stat(absPath);
40529
40555
  if (stat2.isFile()) {
@@ -40543,9 +40569,9 @@ async function applyIncrementalSymbolIndexUpdates(resolved, relPaths) {
40543
40569
  }
40544
40570
 
40545
40571
  // src/files/index/file-index-initial-builds.ts
40546
- import path57 from "node:path";
40572
+ import path58 from "node:path";
40547
40573
  async function runInitialIndexBuilds(cwd = getBridgeRoot()) {
40548
- const resolved = path57.resolve(cwd);
40574
+ const resolved = path58.resolve(cwd);
40549
40575
  try {
40550
40576
  await buildFileIndexAsync(resolved);
40551
40577
  await buildSymbolIndexAsync(resolved);
@@ -40563,7 +40589,7 @@ function scheduleInitialIndexBuilds(cwd = getBridgeRoot()) {
40563
40589
  // src/files/watch-file-index.ts
40564
40590
  var MAX_INCREMENTAL_SYMBOL_UPDATES = 512;
40565
40591
  function startFileIndexWatcher(cwd = getBridgeRoot()) {
40566
- const resolved = path58.resolve(cwd);
40592
+ const resolved = path59.resolve(cwd);
40567
40593
  let timer = null;
40568
40594
  const pendingSymbolUpdates = /* @__PURE__ */ new Set();
40569
40595
  let needsFullSymbolRebuild = false;
@@ -40625,14 +40651,14 @@ function startFileIndexWatcher(cwd = getBridgeRoot()) {
40625
40651
  }
40626
40652
 
40627
40653
  // src/connection/create-bridge-connection.ts
40628
- import * as path72 from "node:path";
40654
+ import * as path73 from "node:path";
40629
40655
 
40630
- // src/dev-servers/manager/dev-server-manager.ts
40656
+ // src/preview-environments/manager/preview-environment-manager.ts
40631
40657
  import { rm as rm2 } from "node:fs/promises";
40632
40658
 
40633
- // src/dev-servers/process/send-server-status.ts
40634
- function sendDevServerStatus(getWs, serverId, status, options) {
40635
- const payload = { type: "server_status", serverId, status };
40659
+ // src/preview-environments/process/send-preview-environment-status.ts
40660
+ function sendPreviewEnvironmentStatus(getWs, environmentId, status, options) {
40661
+ const payload = { type: "preview_environment_status", environmentId, status };
40636
40662
  if (options?.detail) payload.detail = options.detail;
40637
40663
  if (options?.tails) {
40638
40664
  payload.stdoutTail = options.tails.stdout;
@@ -40645,12 +40671,12 @@ function sendDevServerStatus(getWs, serverId, status, options) {
40645
40671
  });
40646
40672
  }
40647
40673
 
40648
- // src/dev-servers/process/terminate-child-process.ts
40674
+ // src/preview-environments/process/terminate-child-process.ts
40649
40675
  async function sigtermAndWaitForExit(proc, graceMs, log2, shortId) {
40650
40676
  const exited = new Promise((resolve32) => {
40651
40677
  proc.once("exit", () => resolve32());
40652
40678
  });
40653
- log2(`[dev-server] Sending SIGTERM to ${shortId} (pid=${proc.pid ?? "?"}).`);
40679
+ log2(`[preview-environment] Sending SIGTERM to ${shortId} (pid=${proc.pid ?? "?"}).`);
40654
40680
  try {
40655
40681
  proc.kill("SIGTERM");
40656
40682
  } catch {
@@ -40659,7 +40685,7 @@ async function sigtermAndWaitForExit(proc, graceMs, log2, shortId) {
40659
40685
  }
40660
40686
  function forceKillChild(proc, log2, shortId, graceMs) {
40661
40687
  log2(
40662
- `[dev-server] ${shortId} did not exit within ${graceMs}ms; sending SIGKILL (pid=${proc.pid ?? "?"}).`
40688
+ `[preview-environment] ${shortId} did not exit within ${graceMs}ms; sending SIGKILL (pid=${proc.pid ?? "?"}).`
40663
40689
  );
40664
40690
  proc.removeAllListeners();
40665
40691
  try {
@@ -40668,10 +40694,10 @@ function forceKillChild(proc, log2, shortId, graceMs) {
40668
40694
  }
40669
40695
  }
40670
40696
 
40671
- // src/dev-servers/process/wire-dev-server-child-process.ts
40697
+ // src/preview-environments/process/wire-preview-environment-child-process.ts
40672
40698
  import fs36 from "node:fs";
40673
40699
 
40674
- // src/dev-servers/manager/forward-pipe.ts
40700
+ // src/preview-environments/manager/forward-pipe.ts
40675
40701
  function forwardChildPipe(childReadable, terminal, onData) {
40676
40702
  if (!childReadable) return;
40677
40703
  childReadable.on("data", (chunk) => {
@@ -40687,16 +40713,16 @@ function forwardChildPipe(childReadable, terminal, onData) {
40687
40713
  });
40688
40714
  }
40689
40715
 
40690
- // src/dev-servers/process/wire-dev-server-child-process.ts
40691
- function wireDevServerChildProcess(d) {
40692
- const { proc, serverId, title } = d;
40716
+ // src/preview-environments/process/wire-preview-environment-child-process.ts
40717
+ function wirePreviewEnvironmentChildProcess(d) {
40718
+ const { proc, environmentId, title } = d;
40693
40719
  forwardChildPipe(proc.stdout, null, (chunk) => {
40694
40720
  d.stdoutTail.push(chunk);
40695
- d.pushRemoteLogChunk(serverId, "stdout", chunk);
40721
+ d.pushRemoteLogChunk(environmentId, "stdout", chunk);
40696
40722
  });
40697
40723
  forwardChildPipe(proc.stderr, null, (chunk) => {
40698
40724
  d.stderrTail.push(chunk);
40699
- d.pushRemoteLogChunk(serverId, "stderr", chunk);
40725
+ d.pushRemoteLogChunk(environmentId, "stderr", chunk);
40700
40726
  });
40701
40727
  if (d.mergedLogPath && d.mergedCleanupDir) {
40702
40728
  const pollIv = setInterval(() => {
@@ -40712,7 +40738,7 @@ function wireDevServerChildProcess(d) {
40712
40738
  d.mergedReadPos.value = buf.length;
40713
40739
  if (chunk.length === 0) return;
40714
40740
  d.stdoutTail.push(chunk);
40715
- d.pushRemoteLogChunk(serverId, "stdout", chunk);
40741
+ d.pushRemoteLogChunk(environmentId, "stdout", chunk);
40716
40742
  });
40717
40743
  }, 100);
40718
40744
  d.setPollInterval(pollIv);
@@ -40730,10 +40756,10 @@ function wireDevServerChildProcess(d) {
40730
40756
  d.rmMergedCleanupDir(cleanupDir);
40731
40757
  }
40732
40758
  if (signal) {
40733
- d.log(`[dev-server] ${title} stopped (signal: ${String(signal)}).`);
40759
+ d.log(`[preview-environment] ${title} stopped (signal: ${String(signal)}).`);
40734
40760
  } else if (code !== null && code !== 0) {
40735
40761
  const errTail = d.stderrTail.getTail().slice(-3).join("\n");
40736
- d.log(`[dev-server] ${title} exited with code ${code}${errTail ? `
40762
+ d.log(`[preview-environment] ${title} exited with code ${code}${errTail ? `
40737
40763
  ${errTail}` : ""}`);
40738
40764
  }
40739
40765
  d.detachProcessFromManager();
@@ -40748,7 +40774,7 @@ ${errTail}` : ""}`);
40748
40774
  const chunk = Buffer.from(buf.subarray(d.mergedReadPos.value));
40749
40775
  if (chunk.length > 0) {
40750
40776
  d.stdoutTail.push(chunk);
40751
- d.pushRemoteLogChunk(serverId, "stdout", chunk);
40777
+ d.pushRemoteLogChunk(environmentId, "stdout", chunk);
40752
40778
  }
40753
40779
  }
40754
40780
  finishExit();
@@ -40772,12 +40798,12 @@ ${errTail}` : ""}`);
40772
40798
  d.clearTailBuffers();
40773
40799
  const msg = err instanceof Error ? err.message : String(err);
40774
40800
  const errno = typeof err === "object" && err && "code" in err ? String(err.code) : "";
40775
- d.log(`[dev-server] ${title} process error: ${msg}${errno ? ` (${errno})` : ""}`);
40801
+ d.log(`[preview-environment] ${title} process error: ${msg}${errno ? ` (${errno})` : ""}`);
40776
40802
  d.sendStatus("error", msg, tails);
40777
40803
  });
40778
40804
  }
40779
40805
 
40780
- // src/dev-servers/manager/dev-server-env.ts
40806
+ // src/preview-environments/manager/preview-environment-env.ts
40781
40807
  function substituteCommand(cmd, env) {
40782
40808
  return cmd.replace(/\$\{([^}]+)\}/g, (_, key) => env[key] != null ? String(env[key]) : "");
40783
40809
  }
@@ -40813,15 +40839,15 @@ function envForSpawn(base, userEnv, ports) {
40813
40839
  return out;
40814
40840
  }
40815
40841
 
40816
- // src/dev-servers/manager/parse-config.ts
40817
- function parseDevServerDefs(servers) {
40842
+ // src/preview-environments/manager/parse-config.ts
40843
+ function parsePreviewEnvironmentDefs(servers) {
40818
40844
  const out = [];
40819
40845
  if (!Array.isArray(servers)) return out;
40820
40846
  for (const s of servers) {
40821
40847
  if (!s || typeof s !== "object") continue;
40822
40848
  const o = s;
40823
- const serverId = typeof o.serverId === "string" ? o.serverId : "";
40824
- if (!serverId) continue;
40849
+ const environmentId = typeof o.environmentId === "string" ? o.environmentId : "";
40850
+ if (!environmentId) continue;
40825
40851
  const envRaw = o.env;
40826
40852
  const env = Array.isArray(envRaw) ? envRaw.map((e) => {
40827
40853
  if (!e || typeof e !== "object") return null;
@@ -40834,7 +40860,7 @@ function parseDevServerDefs(servers) {
40834
40860
  const portsRaw = o.ports;
40835
40861
  const ports = Array.isArray(portsRaw) ? portsRaw.filter((p) => typeof p === "number" && Number.isInteger(p) && p > 0 && p < 65536) : [];
40836
40862
  out.push({
40837
- serverId,
40863
+ environmentId,
40838
40864
  name: typeof o.name === "string" ? o.name : "",
40839
40865
  command: typeof o.command === "string" ? o.command : "",
40840
40866
  env,
@@ -40844,7 +40870,7 @@ function parseDevServerDefs(servers) {
40844
40870
  return out;
40845
40871
  }
40846
40872
 
40847
- // src/dev-servers/manager/shell-spawn/utils.ts
40873
+ // src/preview-environments/manager/shell-spawn/utils.ts
40848
40874
  import fs37 from "node:fs";
40849
40875
  function isSpawnEbadf(e) {
40850
40876
  return typeof e === "object" && e !== null && "code" in e && e.code === "EBADF";
@@ -40867,7 +40893,7 @@ function pipedStdoutStderrFor(attemptStdio) {
40867
40893
  return attemptStdio !== "inherit" && Array.isArray(attemptStdio) && attemptStdio[1] === "pipe" && attemptStdio[2] === "pipe";
40868
40894
  }
40869
40895
 
40870
- // src/dev-servers/manager/shell-spawn/try-spawn-piped-via-sh.ts
40896
+ // src/preview-environments/manager/shell-spawn/try-spawn-piped-via-sh.ts
40871
40897
  import { spawn as spawn6 } from "node:child_process";
40872
40898
  function trySpawnPipedViaSh(command, env, cwd, signal) {
40873
40899
  const attempts = [
@@ -40910,7 +40936,7 @@ function trySpawnPipedViaSh(command, env, cwd, signal) {
40910
40936
  return { ok: false, lastErr };
40911
40937
  }
40912
40938
 
40913
- // src/dev-servers/manager/shell-spawn/try-spawn-shell-true-piped.ts
40939
+ // src/preview-environments/manager/shell-spawn/try-spawn-shell-true-piped.ts
40914
40940
  import { spawn as spawn7 } from "node:child_process";
40915
40941
  function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal) {
40916
40942
  try {
@@ -40931,14 +40957,14 @@ function trySpawnShellTruePiped(command, env, cwd, devNullFd, signal) {
40931
40957
  }
40932
40958
  }
40933
40959
 
40934
- // src/dev-servers/manager/shell-spawn/try-spawn-merged-log-file.ts
40960
+ // src/preview-environments/manager/shell-spawn/try-spawn-merged-log-file.ts
40935
40961
  import { spawn as spawn8 } from "node:child_process";
40936
40962
  import fs38 from "node:fs";
40937
40963
  import { tmpdir } from "node:os";
40938
- import path59 from "node:path";
40964
+ import path60 from "node:path";
40939
40965
  function trySpawnMergedLogFile(command, env, cwd, signal) {
40940
- const tmpRoot = fs38.mkdtempSync(path59.join(tmpdir(), "ba-devsrv-log-"));
40941
- const logPath = path59.join(tmpRoot, "combined.log");
40966
+ const tmpRoot = fs38.mkdtempSync(path60.join(tmpdir(), "ba-devsrv-log-"));
40967
+ const logPath = path60.join(tmpRoot, "combined.log");
40942
40968
  let logFd;
40943
40969
  try {
40944
40970
  logFd = fs38.openSync(logPath, "a");
@@ -40978,19 +41004,19 @@ function trySpawnMergedLogFile(command, env, cwd, signal) {
40978
41004
  }
40979
41005
  }
40980
41006
 
40981
- // src/dev-servers/manager/shell-spawn/try-spawn-shell-script-log-redirect.ts
41007
+ // src/preview-environments/manager/shell-spawn/try-spawn-shell-script-log-redirect.ts
40982
41008
  import { spawn as spawn9 } from "node:child_process";
40983
41009
  import fs39 from "node:fs";
40984
41010
  import { tmpdir as tmpdir2 } from "node:os";
40985
- import path60 from "node:path";
41011
+ import path61 from "node:path";
40986
41012
  function shSingleQuote(s) {
40987
41013
  return `'${s.replace(/'/g, `'\\''`)}'`;
40988
41014
  }
40989
41015
  function trySpawnShellScriptLogRedirectUnix(command, env, cwd, signal) {
40990
- const tmpRoot = fs39.mkdtempSync(path60.join(tmpdir2(), "ba-devsrv-sh-"));
40991
- const logPath = path60.join(tmpRoot, "combined.log");
40992
- const innerPath = path60.join(tmpRoot, "_cmd.sh");
40993
- const runnerPath = path60.join(tmpRoot, "_run.sh");
41016
+ const tmpRoot = fs39.mkdtempSync(path61.join(tmpdir2(), "ba-devsrv-sh-"));
41017
+ const logPath = path61.join(tmpRoot, "combined.log");
41018
+ const innerPath = path61.join(tmpRoot, "_cmd.sh");
41019
+ const runnerPath = path61.join(tmpRoot, "_run.sh");
40994
41020
  try {
40995
41021
  fs39.writeFileSync(innerPath, `#!/bin/sh
40996
41022
  ${command}
@@ -41021,9 +41047,9 @@ cd ${shSingleQuote(cwd)}
41021
41047
  }
41022
41048
  }
41023
41049
  function trySpawnShellScriptLogRedirectWin(command, env, cwd, signal) {
41024
- const tmpRoot = fs39.mkdtempSync(path60.join(tmpdir2(), "ba-devsrv-sh-"));
41025
- const logPath = path60.join(tmpRoot, "combined.log");
41026
- const runnerPath = path60.join(tmpRoot, "_run.bat");
41050
+ const tmpRoot = fs39.mkdtempSync(path61.join(tmpdir2(), "ba-devsrv-sh-"));
41051
+ const logPath = path61.join(tmpRoot, "combined.log");
41052
+ const runnerPath = path61.join(tmpRoot, "_run.bat");
41027
41053
  const q = (p) => `"${p.replace(/"/g, '""')}"`;
41028
41054
  const com = process.env.ComSpec || "cmd.exe";
41029
41055
  try {
@@ -41054,7 +41080,7 @@ ${command} >> ${q(logPath)} 2>&1\r
41054
41080
  }
41055
41081
  }
41056
41082
 
41057
- // src/dev-servers/manager/shell-spawn/try-spawn-inherit.ts
41083
+ // src/preview-environments/manager/shell-spawn/try-spawn-inherit.ts
41058
41084
  import { spawn as spawn10 } from "node:child_process";
41059
41085
  function trySpawnInheritStdio(command, env, cwd, signal) {
41060
41086
  const opts = {
@@ -41074,7 +41100,7 @@ function trySpawnInheritStdio(command, env, cwd, signal) {
41074
41100
  return { proc, pipedStdoutStderr: false };
41075
41101
  }
41076
41102
 
41077
- // src/dev-servers/manager/shell-spawn/shell-spawn.ts
41103
+ // src/preview-environments/manager/shell-spawn/shell-spawn.ts
41078
41104
  function shellSpawn(command, env, cwd, options) {
41079
41105
  const signal = options?.signal;
41080
41106
  const piped = trySpawnPipedViaSh(command, env, cwd, signal);
@@ -41101,7 +41127,7 @@ function shellSpawn(command, env, cwd, options) {
41101
41127
  }
41102
41128
  }
41103
41129
 
41104
- // src/dev-servers/manager/stream-tail.ts
41130
+ // src/preview-environments/manager/stream-tail.ts
41105
41131
  var MAX_TAIL_LINES = 80;
41106
41132
  var MAX_LINE_CHARS = 8192;
41107
41133
  var MAX_PENDING_CHARS = 65536;
@@ -41137,11 +41163,11 @@ var StreamTail = class {
41137
41163
  }
41138
41164
  };
41139
41165
 
41140
- // src/dev-servers/manager/dev-server-firehose-messages.ts
41166
+ // src/preview-environments/manager/preview-environment-firehose-messages.ts
41141
41167
  function buildFirehoseSnapshotMessage(params) {
41142
41168
  const payload = {
41143
41169
  type: "log_snapshot",
41144
- serverId: params.serverId,
41170
+ environmentId: params.environmentId,
41145
41171
  viewerId: params.viewerId,
41146
41172
  stdoutTail: params.tails.stdout,
41147
41173
  stderrTail: params.tails.stderr
@@ -41151,15 +41177,15 @@ function buildFirehoseSnapshotMessage(params) {
41151
41177
  function buildFirehoseLogChunkMessage(params) {
41152
41178
  const payload = {
41153
41179
  type: "log_chunk",
41154
- serverId: params.serverId,
41180
+ environmentId: params.environmentId,
41155
41181
  stream: params.stream,
41156
41182
  text: params.text
41157
41183
  };
41158
41184
  return params.e2ee ? params.e2ee.encryptFields(payload, ["text"]) : payload;
41159
41185
  }
41160
41186
 
41161
- // src/dev-servers/manager/dev-server-firehose-sink.ts
41162
- var DevServerFirehoseSink = class {
41187
+ // src/preview-environments/manager/preview-environment-firehose-sink.ts
41188
+ var PreviewEnvironmentFirehoseSink = class {
41163
41189
  constructor(options) {
41164
41190
  this.options = options;
41165
41191
  }
@@ -41172,31 +41198,31 @@ var DevServerFirehoseSink = class {
41172
41198
  this.firehoseSend = null;
41173
41199
  this.logViewerRefCountByServerId.clear();
41174
41200
  }
41175
- openLogViewer(serverId, viewerId) {
41176
- const next = (this.logViewerRefCountByServerId.get(serverId) ?? 0) + 1;
41177
- this.logViewerRefCountByServerId.set(serverId, next);
41178
- this.sendSnapshot(serverId, viewerId);
41201
+ openLogViewer(environmentId, viewerId) {
41202
+ const next = (this.logViewerRefCountByServerId.get(environmentId) ?? 0) + 1;
41203
+ this.logViewerRefCountByServerId.set(environmentId, next);
41204
+ this.sendSnapshot(environmentId, viewerId);
41179
41205
  }
41180
- closeLogViewer(serverId) {
41181
- const n = (this.logViewerRefCountByServerId.get(serverId) ?? 0) - 1;
41182
- if (n <= 0) this.logViewerRefCountByServerId.delete(serverId);
41183
- else this.logViewerRefCountByServerId.set(serverId, n);
41206
+ closeLogViewer(environmentId) {
41207
+ const n = (this.logViewerRefCountByServerId.get(environmentId) ?? 0) - 1;
41208
+ if (n <= 0) this.logViewerRefCountByServerId.delete(environmentId);
41209
+ else this.logViewerRefCountByServerId.set(environmentId, n);
41184
41210
  }
41185
- pushLogChunk(serverId, stream, chunk) {
41186
- if ((this.logViewerRefCountByServerId.get(serverId) ?? 0) <= 0) return;
41187
- if (!this.options.isPipedCaptureEnabled(serverId)) return;
41211
+ pushLogChunk(environmentId, stream, chunk) {
41212
+ if ((this.logViewerRefCountByServerId.get(environmentId) ?? 0) <= 0) return;
41213
+ if (!this.options.isPipedCaptureEnabled(environmentId)) return;
41188
41214
  if (!this.firehoseSend) return;
41189
41215
  const text = chunk.toString("utf8");
41190
41216
  setImmediate(() => {
41191
41217
  if (!this.firehoseSend) return;
41192
- this.firehoseSend(buildFirehoseLogChunkMessage({ serverId, stream, text, e2ee: this.options.e2ee }));
41218
+ this.firehoseSend(buildFirehoseLogChunkMessage({ environmentId, stream, text, e2ee: this.options.e2ee }));
41193
41219
  });
41194
41220
  }
41195
- sendSnapshot(serverId, viewerId) {
41221
+ sendSnapshot(environmentId, viewerId) {
41196
41222
  const payload = buildFirehoseSnapshotMessage({
41197
- serverId,
41223
+ environmentId,
41198
41224
  viewerId,
41199
- tails: this.options.getTails(serverId),
41225
+ tails: this.options.getTails(environmentId),
41200
41226
  e2ee: this.options.e2ee
41201
41227
  });
41202
41228
  setImmediate(() => {
@@ -41207,19 +41233,19 @@ var DevServerFirehoseSink = class {
41207
41233
  }
41208
41234
  };
41209
41235
 
41210
- // src/dev-servers/manager/cleanup-merged-log-dir.ts
41236
+ // src/preview-environments/manager/cleanup-merged-log-dir.ts
41211
41237
  import { rm } from "node:fs/promises";
41212
- function cleanupMergedLogDirForServer(map2, serverId) {
41213
- const mergedDir = map2.get(serverId);
41238
+ function cleanupMergedLogDirForServer(map2, environmentId) {
41239
+ const mergedDir = map2.get(environmentId);
41214
41240
  if (!mergedDir) return;
41215
- map2.delete(serverId);
41241
+ map2.delete(environmentId);
41216
41242
  void rm(mergedDir, { recursive: true, force: true }).catch(() => {
41217
41243
  });
41218
41244
  }
41219
41245
 
41220
- // src/dev-servers/manager/dev-server-manager.ts
41246
+ // src/preview-environments/manager/preview-environment-manager.ts
41221
41247
  var emptyTails = () => ({ stdout: [], stderr: [] });
41222
- var DevServerManager = class {
41248
+ var PreviewEnvironmentManager = class {
41223
41249
  defsById = /* @__PURE__ */ new Map();
41224
41250
  processes = /* @__PURE__ */ new Map();
41225
41251
  streamTailsByServerId = /* @__PURE__ */ new Map();
@@ -41238,9 +41264,9 @@ var DevServerManager = class {
41238
41264
  this.log = options.log;
41239
41265
  this.getBridgeRoot = options.getBridgeRoot ?? (() => process.cwd());
41240
41266
  this.e2ee = options.e2ee;
41241
- this.firehoseSink = new DevServerFirehoseSink({
41242
- getTails: (serverId) => this.snapshotTails(serverId),
41243
- isPipedCaptureEnabled: (serverId) => this.pipedCaptureByServerId.get(serverId) === true,
41267
+ this.firehoseSink = new PreviewEnvironmentFirehoseSink({
41268
+ getTails: (environmentId) => this.snapshotTails(environmentId),
41269
+ isPipedCaptureEnabled: (environmentId) => this.pipedCaptureByServerId.get(environmentId) === true,
41244
41270
  e2ee: this.e2ee
41245
41271
  });
41246
41272
  }
@@ -41250,89 +41276,89 @@ var DevServerManager = class {
41250
41276
  detachFirehose() {
41251
41277
  this.firehoseSink.detach();
41252
41278
  }
41253
- handleFirehoseLogViewerOpen(serverId, _viewerId) {
41254
- this.firehoseSink.openLogViewer(serverId, _viewerId);
41279
+ handleFirehoseLogViewerOpen(environmentId, _viewerId) {
41280
+ this.firehoseSink.openLogViewer(environmentId, _viewerId);
41255
41281
  }
41256
- handleFirehoseLogViewerClose(serverId, _viewerId) {
41257
- this.firehoseSink.closeLogViewer(serverId);
41282
+ handleFirehoseLogViewerClose(environmentId, _viewerId) {
41283
+ this.firehoseSink.closeLogViewer(environmentId);
41258
41284
  }
41259
41285
  applyConfig(servers) {
41260
41286
  this.defsById.clear();
41261
- for (const d of parseDevServerDefs(servers)) {
41262
- this.defsById.set(d.serverId, d);
41287
+ for (const d of parsePreviewEnvironmentDefs(servers)) {
41288
+ this.defsById.set(d.environmentId, d);
41263
41289
  }
41264
41290
  }
41265
- snapshotTails(serverId) {
41266
- const t = this.streamTailsByServerId.get(serverId);
41291
+ snapshotTails(environmentId) {
41292
+ const t = this.streamTailsByServerId.get(environmentId);
41267
41293
  if (!t) return { stdout: [], stderr: [] };
41268
41294
  return { stdout: t.stdout.getTail(), stderr: t.stderr.getTail() };
41269
41295
  }
41270
- clearTails(serverId) {
41271
- this.streamTailsByServerId.delete(serverId);
41296
+ clearTails(environmentId) {
41297
+ this.streamTailsByServerId.delete(environmentId);
41272
41298
  }
41273
- sendStatus(serverId, status, detail, tails) {
41274
- sendDevServerStatus(this.getWs, serverId, status, { detail, tails });
41299
+ sendStatus(environmentId, status, detail, tails) {
41300
+ sendPreviewEnvironmentStatus(this.getWs, environmentId, status, { detail, tails });
41275
41301
  }
41276
- bumpGeneration(serverId) {
41277
- const nextGen = (this.spawnGenerationByServerId.get(serverId) ?? 0) + 1;
41278
- this.spawnGenerationByServerId.set(serverId, nextGen);
41302
+ bumpGeneration(environmentId) {
41303
+ const nextGen = (this.spawnGenerationByServerId.get(environmentId) ?? 0) + 1;
41304
+ this.spawnGenerationByServerId.set(environmentId, nextGen);
41279
41305
  }
41280
- clearPoll(serverId) {
41281
- const poll = this.mergedLogPollByServerId.get(serverId);
41306
+ clearPoll(environmentId) {
41307
+ const poll = this.mergedLogPollByServerId.get(environmentId);
41282
41308
  if (poll) {
41283
41309
  clearInterval(poll);
41284
- this.mergedLogPollByServerId.delete(serverId);
41310
+ this.mergedLogPollByServerId.delete(environmentId);
41285
41311
  }
41286
41312
  }
41287
- abortSpawn(serverId) {
41288
- this.abortControllersByServerId.get(serverId)?.abort();
41289
- this.abortControllersByServerId.delete(serverId);
41313
+ abortSpawn(environmentId) {
41314
+ this.abortControllersByServerId.get(environmentId)?.abort();
41315
+ this.abortControllersByServerId.delete(environmentId);
41290
41316
  }
41291
- stop(serverId) {
41292
- const tails = this.snapshotTails(serverId);
41293
- if (this.processes.has(serverId)) {
41294
- this.sendStatus(serverId, "stopping", void 0, tails);
41317
+ stop(environmentId) {
41318
+ const tails = this.snapshotTails(environmentId);
41319
+ if (this.processes.has(environmentId)) {
41320
+ this.sendStatus(environmentId, "stopping", void 0, tails);
41295
41321
  }
41296
- this.bumpGeneration(serverId);
41297
- this.abortSpawn(serverId);
41298
- this.clearPoll(serverId);
41299
- const proc = this.processes.get(serverId);
41322
+ this.bumpGeneration(environmentId);
41323
+ this.abortSpawn(environmentId);
41324
+ this.clearPoll(environmentId);
41325
+ const proc = this.processes.get(environmentId);
41300
41326
  if (proc) {
41301
41327
  proc.removeAllListeners();
41302
41328
  try {
41303
41329
  proc.kill("SIGTERM");
41304
41330
  } catch {
41305
41331
  }
41306
- this.processes.delete(serverId);
41332
+ this.processes.delete(environmentId);
41307
41333
  }
41308
- this.clearTails(serverId);
41309
- this.pipedCaptureByServerId.delete(serverId);
41310
- cleanupMergedLogDirForServer(this.mergedLogCleanupDirByServerId, serverId);
41311
- this.sendStatus(serverId, "stopped", void 0, tails);
41334
+ this.clearTails(environmentId);
41335
+ this.pipedCaptureByServerId.delete(environmentId);
41336
+ cleanupMergedLogDirForServer(this.mergedLogCleanupDirByServerId, environmentId);
41337
+ this.sendStatus(environmentId, "stopped", void 0, tails);
41312
41338
  }
41313
- start(serverId) {
41314
- const def = this.defsById.get(serverId);
41339
+ start(environmentId) {
41340
+ const def = this.defsById.get(environmentId);
41315
41341
  if (!def) {
41316
- this.log(`[dev-server] Unknown server id ${serverId.slice(0, 8)}\u2026`);
41317
- this.sendStatus(serverId, "error", "Unknown server", emptyTails());
41342
+ this.log(`[preview-environment] Unknown server id ${environmentId.slice(0, 8)}\u2026`);
41343
+ this.sendStatus(environmentId, "error", "Unknown server", emptyTails());
41318
41344
  return;
41319
41345
  }
41320
41346
  if (!def.command.trim()) {
41321
- this.sendStatus(serverId, "idle", "No command configured", emptyTails());
41347
+ this.sendStatus(environmentId, "idle", "No command configured", emptyTails());
41322
41348
  return;
41323
41349
  }
41324
- this.stop(serverId);
41325
- this.sendStatus(serverId, "starting", void 0, emptyTails());
41350
+ this.stop(environmentId);
41351
+ this.sendStatus(environmentId, "starting", void 0, emptyTails());
41326
41352
  const ac = new AbortController();
41327
- this.abortControllersByServerId.set(serverId, ac);
41353
+ this.abortControllersByServerId.set(environmentId, ac);
41328
41354
  const cwd = this.getBridgeRoot();
41329
41355
  const childEnv = envForSpawn(process.env, def.env, def.ports);
41330
41356
  const cmd = substituteCommand(def.command.trim(), childEnv);
41331
- const title = def.name.trim() || serverId.slice(0, 8);
41332
- this.log(`[dev-server] Starting ${title}: ${cmd.slice(0, 120)}${cmd.length > 120 ? "\u2026" : ""}`);
41333
- const scheduledGen = this.spawnGenerationByServerId.get(serverId) ?? 0;
41357
+ const title = def.name.trim() || environmentId.slice(0, 8);
41358
+ this.log(`[preview-environment] Starting ${title}: ${cmd.slice(0, 120)}${cmd.length > 120 ? "\u2026" : ""}`);
41359
+ const scheduledGen = this.spawnGenerationByServerId.get(environmentId) ?? 0;
41334
41360
  setImmediate(() => {
41335
- if ((this.spawnGenerationByServerId.get(serverId) ?? 0) !== scheduledGen) {
41361
+ if ((this.spawnGenerationByServerId.get(environmentId) ?? 0) !== scheduledGen) {
41336
41362
  return;
41337
41363
  }
41338
41364
  let proc;
@@ -41349,12 +41375,12 @@ var DevServerManager = class {
41349
41375
  mergedCleanupDir = spawned.mergedLogCleanupDir;
41350
41376
  } catch (e) {
41351
41377
  const msg = e instanceof Error ? e.message : String(e);
41352
- this.log(`[dev-server] Failed to start ${title}: ${msg}`);
41353
- this.abortControllersByServerId.delete(serverId);
41354
- this.sendStatus(serverId, "error", msg, emptyTails());
41378
+ this.log(`[preview-environment] Failed to start ${title}: ${msg}`);
41379
+ this.abortControllersByServerId.delete(environmentId);
41380
+ this.sendStatus(environmentId, "error", msg, emptyTails());
41355
41381
  return;
41356
41382
  }
41357
- if ((this.spawnGenerationByServerId.get(serverId) ?? 0) !== scheduledGen) {
41383
+ if ((this.spawnGenerationByServerId.get(environmentId) ?? 0) !== scheduledGen) {
41358
41384
  try {
41359
41385
  proc.removeAllListeners();
41360
41386
  proc.kill("SIGTERM");
@@ -41363,89 +41389,89 @@ var DevServerManager = class {
41363
41389
  return;
41364
41390
  }
41365
41391
  if (!pipedStdoutStderr) {
41366
- this.log(`[dev-server] ${title} running (inherited stdio; bridge log preview disabled)`);
41392
+ this.log(`[preview-environment] ${title} running (inherited stdio; bridge log preview disabled)`);
41367
41393
  } else if (mergedLogPath && mergedCleanupDir) {
41368
41394
  this.log(
41369
- `[dev-server] ${title} running (logs captured via temp file; open the browser log viewer for live output)`
41395
+ `[preview-environment] ${title} running (logs captured via temp file; open the browser log viewer for live output)`
41370
41396
  );
41371
41397
  }
41372
- this.pipedCaptureByServerId.set(serverId, pipedStdoutStderr);
41398
+ this.pipedCaptureByServerId.set(environmentId, pipedStdoutStderr);
41373
41399
  const stdoutTail = new StreamTail();
41374
41400
  const stderrTail = new StreamTail();
41375
- this.streamTailsByServerId.set(serverId, { stdout: stdoutTail, stderr: stderrTail });
41401
+ this.streamTailsByServerId.set(environmentId, { stdout: stdoutTail, stderr: stderrTail });
41376
41402
  if (mergedLogPath && mergedCleanupDir) {
41377
- this.mergedLogCleanupDirByServerId.set(serverId, mergedCleanupDir);
41403
+ this.mergedLogCleanupDirByServerId.set(environmentId, mergedCleanupDir);
41378
41404
  }
41379
41405
  const mergedReadPos = { value: 0 };
41380
- this.processes.set(serverId, proc);
41381
- wireDevServerChildProcess({
41382
- serverId,
41406
+ this.processes.set(environmentId, proc);
41407
+ wirePreviewEnvironmentChildProcess({
41408
+ environmentId,
41383
41409
  title,
41384
41410
  proc,
41385
41411
  mergedLogPath,
41386
41412
  mergedCleanupDir,
41387
41413
  mergedReadPos,
41388
41414
  scheduledGen,
41389
- getSpawnGeneration: () => this.spawnGenerationByServerId.get(serverId) ?? 0,
41415
+ getSpawnGeneration: () => this.spawnGenerationByServerId.get(environmentId) ?? 0,
41390
41416
  log: this.log,
41391
41417
  stdoutTail,
41392
41418
  stderrTail,
41393
41419
  pushRemoteLogChunk: (sid, stream, chunk) => this.firehoseSink.pushLogChunk(sid, stream, chunk),
41394
- sendStatus: (status, detail, tails) => this.sendStatus(serverId, status, detail, tails),
41420
+ sendStatus: (status, detail, tails) => this.sendStatus(environmentId, status, detail, tails),
41395
41421
  setPollInterval: (iv) => {
41396
- if (iv) this.mergedLogPollByServerId.set(serverId, iv);
41397
- else this.mergedLogPollByServerId.delete(serverId);
41422
+ if (iv) this.mergedLogPollByServerId.set(environmentId, iv);
41423
+ else this.mergedLogPollByServerId.delete(environmentId);
41398
41424
  },
41399
- getPollInterval: () => this.mergedLogPollByServerId.get(serverId),
41425
+ getPollInterval: () => this.mergedLogPollByServerId.get(environmentId),
41400
41426
  detachProcessFromManager: () => {
41401
- this.processes.delete(serverId);
41402
- this.pipedCaptureByServerId.delete(serverId);
41403
- this.abortControllersByServerId.delete(serverId);
41404
- this.mergedLogCleanupDirByServerId.delete(serverId);
41427
+ this.processes.delete(environmentId);
41428
+ this.pipedCaptureByServerId.delete(environmentId);
41429
+ this.abortControllersByServerId.delete(environmentId);
41430
+ this.mergedLogCleanupDirByServerId.delete(environmentId);
41405
41431
  },
41406
41432
  rmMergedCleanupDir: (dir) => {
41407
41433
  void rm2(dir, { recursive: true, force: true }).catch(() => {
41408
41434
  });
41409
41435
  },
41410
- clearTailBuffers: () => this.clearTails(serverId)
41436
+ clearTailBuffers: () => this.clearTails(environmentId)
41411
41437
  });
41412
- this.sendStatus(serverId, "running", `pid=${proc.pid ?? "?"}`, {
41438
+ this.sendStatus(environmentId, "running", `pid=${proc.pid ?? "?"}`, {
41413
41439
  stdout: stdoutTail.getTail(),
41414
41440
  stderr: stderrTail.getTail()
41415
41441
  });
41416
41442
  });
41417
41443
  }
41418
- handleControl(serverId, action) {
41444
+ handleControl(environmentId, action) {
41419
41445
  if (action === "stop") {
41420
- this.stop(serverId);
41446
+ this.stop(environmentId);
41421
41447
  return;
41422
41448
  }
41423
- this.start(serverId);
41449
+ this.start(environmentId);
41424
41450
  }
41425
41451
  async shutdownAllGraceful(opts) {
41426
41452
  const graceMs = opts?.graceMs ?? BRIDGE_SHUTDOWN_GRACE_MS;
41427
41453
  const pairs = [...this.processes.entries()];
41428
41454
  if (pairs.length === 0) return;
41429
41455
  this.log(
41430
- `[dev-server] Stopping ${pairs.length} local dev server process${pairs.length === 1 ? "" : "es"}\u2026`
41456
+ `[preview-environment] Stopping ${pairs.length} local preview environment process${pairs.length === 1 ? "" : "es"}\u2026`
41431
41457
  );
41432
- await Promise.all(pairs.map(([serverId, proc]) => this.gracefulTerminateOrUnknown(serverId, proc, graceMs)));
41458
+ await Promise.all(pairs.map(([environmentId, proc]) => this.gracefulTerminateOrUnknown(environmentId, proc, graceMs)));
41433
41459
  }
41434
- async gracefulTerminateOrUnknown(serverId, proc, graceMs) {
41435
- const shortId = `${serverId.slice(0, 8)}\u2026`;
41460
+ async gracefulTerminateOrUnknown(environmentId, proc, graceMs) {
41461
+ const shortId = `${environmentId.slice(0, 8)}\u2026`;
41436
41462
  await sigtermAndWaitForExit(proc, graceMs, this.log, shortId);
41437
- if (!this.processes.has(serverId) || this.processes.get(serverId) !== proc) {
41463
+ if (!this.processes.has(environmentId) || this.processes.get(environmentId) !== proc) {
41438
41464
  return;
41439
41465
  }
41440
- this.bumpGeneration(serverId);
41466
+ this.bumpGeneration(environmentId);
41441
41467
  forceKillChild(proc, this.log, shortId, graceMs);
41442
- this.processes.delete(serverId);
41443
- this.clearPoll(serverId);
41444
- this.pipedCaptureByServerId.delete(serverId);
41445
- cleanupMergedLogDirForServer(this.mergedLogCleanupDirByServerId, serverId);
41446
- const tails = this.snapshotTails(serverId);
41447
- this.clearTails(serverId);
41448
- this.sendStatus(serverId, "unknown", "Bridge closed before process exited", tails);
41468
+ this.processes.delete(environmentId);
41469
+ this.clearPoll(environmentId);
41470
+ this.pipedCaptureByServerId.delete(environmentId);
41471
+ cleanupMergedLogDirForServer(this.mergedLogCleanupDirByServerId, environmentId);
41472
+ const tails = this.snapshotTails(environmentId);
41473
+ this.clearTails(environmentId);
41474
+ this.sendStatus(environmentId, "unknown", "Bridge closed before process exited", tails);
41449
41475
  }
41450
41476
  };
41451
41477
 
@@ -41503,20 +41529,20 @@ function createFirehoseMessageRouter() {
41503
41529
  };
41504
41530
  }
41505
41531
 
41506
- // src/firehose/routing/handlers/dev-server-logs-viewer-open.ts
41507
- var handleDevServerLogsViewerOpen = (msg, deps) => {
41508
- const serverId = typeof msg.serverId === "string" ? msg.serverId : "";
41532
+ // src/firehose/routing/handlers/preview-environment-logs-viewer-open.ts
41533
+ var handlePreviewEnvironmentLogsViewerOpen = (msg, deps) => {
41534
+ const environmentId = typeof msg.environmentId === "string" ? msg.environmentId : "";
41509
41535
  const viewerId = typeof msg.viewerId === "string" ? msg.viewerId : "";
41510
- if (!serverId || !viewerId) return;
41511
- deps.devServerManager.handleFirehoseLogViewerOpen(serverId, viewerId);
41536
+ if (!environmentId || !viewerId) return;
41537
+ deps.previewEnvironmentManager.handleFirehoseLogViewerOpen(environmentId, viewerId);
41512
41538
  };
41513
41539
 
41514
- // src/firehose/routing/handlers/dev-server-logs-viewer-close.ts
41515
- var handleDevServerLogsViewerClose = (msg, deps) => {
41516
- const serverId = typeof msg.serverId === "string" ? msg.serverId : "";
41540
+ // src/firehose/routing/handlers/preview-environment-logs-viewer-close.ts
41541
+ var handlePreviewEnvironmentLogsViewerClose = (msg, deps) => {
41542
+ const environmentId = typeof msg.environmentId === "string" ? msg.environmentId : "";
41517
41543
  const viewerId = typeof msg.viewerId === "string" ? msg.viewerId : "";
41518
- if (!serverId || !viewerId) return;
41519
- deps.devServerManager.handleFirehoseLogViewerClose(serverId, viewerId);
41544
+ if (!environmentId || !viewerId) return;
41545
+ deps.previewEnvironmentManager.handleFirehoseLogViewerClose(environmentId, viewerId);
41520
41546
  };
41521
41547
 
41522
41548
  // src/firehose/routing/handlers/proxy-message.ts
@@ -41565,8 +41591,8 @@ var handleFirehoseIdentified = (_msg, _deps) => {
41565
41591
  // src/firehose/routing/dispatch-firehose-message.ts
41566
41592
  var router = createFirehoseMessageRouter();
41567
41593
  router.register("identified", handleFirehoseIdentified);
41568
- router.register("log_viewer_open", handleDevServerLogsViewerOpen);
41569
- router.register("log_viewer_close", handleDevServerLogsViewerClose);
41594
+ router.register("log_viewer_open", handlePreviewEnvironmentLogsViewerOpen);
41595
+ router.register("log_viewer_close", handlePreviewEnvironmentLogsViewerClose);
41570
41596
  router.register("proxy", handleProxyMessage);
41571
41597
  function dispatchFirehoseJsonMessage(msg, deps) {
41572
41598
  router.dispatch(msg, deps);
@@ -41596,7 +41622,7 @@ function connectFirehose(options) {
41596
41622
  bridgeName,
41597
41623
  proxyPorts,
41598
41624
  log: log2,
41599
- devServerManager,
41625
+ previewEnvironmentManager,
41600
41626
  onOpen,
41601
41627
  onClose,
41602
41628
  suppressWebSocketErrors
@@ -41616,7 +41642,7 @@ function connectFirehose(options) {
41616
41642
  const deps = {
41617
41643
  ws,
41618
41644
  log: log2,
41619
- devServerManager,
41645
+ previewEnvironmentManager,
41620
41646
  pendingProxyBody,
41621
41647
  startStreamingProxy: (pr) => startStreamingProxy(ws, log2, pr)
41622
41648
  };
@@ -41624,7 +41650,7 @@ function connectFirehose(options) {
41624
41650
  disposeClientPing();
41625
41651
  clearClientPing = attachWebSocketClientPing(ws, CLI_WEBSOCKET_CLIENT_PING_MS);
41626
41652
  onOpen?.();
41627
- devServerManager.attachFirehose(firehoseSend);
41653
+ previewEnvironmentManager.attachFirehose(firehoseSend);
41628
41654
  sendWsMessage(ws, { type: "identify", workspaceId, bridgeName, proxyPorts });
41629
41655
  });
41630
41656
  ws.on("message", (raw) => {
@@ -41641,7 +41667,7 @@ function connectFirehose(options) {
41641
41667
  });
41642
41668
  ws.on("close", (code, reason) => {
41643
41669
  disposeClientPing();
41644
- devServerManager.detachFirehose();
41670
+ previewEnvironmentManager.detachFirehose();
41645
41671
  const reasonStr = typeof reason === "string" ? reason : reason.toString();
41646
41672
  onClose?.(code, reasonStr);
41647
41673
  });
@@ -41657,7 +41683,7 @@ function connectFirehose(options) {
41657
41683
  return {
41658
41684
  close() {
41659
41685
  disposeClientPing();
41660
- devServerManager.detachFirehose();
41686
+ previewEnvironmentManager.detachFirehose();
41661
41687
  safeCloseWebSocket(ws);
41662
41688
  },
41663
41689
  isConnected: () => ws.readyState === wrapper_default.OPEN
@@ -41666,7 +41692,7 @@ function connectFirehose(options) {
41666
41692
 
41667
41693
  // src/connection/attach-firehose-after-identified.ts
41668
41694
  function attachFirehoseAfterIdentified(ctx, params) {
41669
- const { state, devServerManager, logFn } = ctx;
41695
+ const { state, previewEnvironmentManager, logFn } = ctx;
41670
41696
  function clearFirehoseReconnectTimer() {
41671
41697
  if (state.firehoseReconnectTimeout != null) {
41672
41698
  clearTimeout(state.firehoseReconnectTimeout);
@@ -41732,7 +41758,7 @@ function attachFirehoseAfterIdentified(ctx, params) {
41732
41758
  bridgeName: params.bridgeName,
41733
41759
  proxyPorts: params.proxyPorts,
41734
41760
  log: logFn,
41735
- devServerManager,
41761
+ previewEnvironmentManager,
41736
41762
  suppressWebSocketErrors: () => !state.closedByUser && state.firehoseOutage.startedAt != null,
41737
41763
  onOpen: () => {
41738
41764
  if (myGen !== state.firehoseGeneration) return;
@@ -41775,14 +41801,14 @@ function attachFirehoseAfterIdentified(ctx, params) {
41775
41801
 
41776
41802
  // src/connection/create-bridge-identified-handler.ts
41777
41803
  function createOnBridgeIdentified(opts) {
41778
- const { devServerManager, firehoseServerUrl, workspaceId, state, logFn } = opts;
41779
- const firehoseCtx = { state, devServerManager, logFn };
41804
+ const { previewEnvironmentManager, firehoseServerUrl, workspaceId, state, logFn } = opts;
41805
+ const firehoseCtx = { state, previewEnvironmentManager, logFn };
41780
41806
  return (msg) => {
41781
41807
  const bridgeName = msg.bridgeName;
41782
41808
  const proxyPorts = Array.isArray(msg.proxyPorts) ? msg.proxyPorts : [];
41783
- const devServers = msg.devServers ?? [];
41809
+ const previewEnvironments = msg.previewEnvironments ?? [];
41784
41810
  setImmediate(() => {
41785
- devServerManager.applyConfig(devServers);
41811
+ previewEnvironmentManager.applyConfig(previewEnvironments);
41786
41812
  if (!firehoseServerUrl || typeof bridgeName !== "string" || !bridgeName) return;
41787
41813
  state.firehoseReconnectAttempt = 0;
41788
41814
  attachFirehoseAfterIdentified(firehoseCtx, {
@@ -41805,15 +41831,15 @@ async function yieldSkillDiscoveryWork(entryCount) {
41805
41831
 
41806
41832
  // src/skills/discovery/discover-local-skills.ts
41807
41833
  import fs40 from "node:fs";
41808
- import path61 from "node:path";
41834
+ import path62 from "node:path";
41809
41835
  function collectSkillFromDir(rel, base, name, seenKeys, out) {
41810
- const dir = path61.join(base, name);
41836
+ const dir = path62.join(base, name);
41811
41837
  try {
41812
41838
  if (!fs40.statSync(dir).isDirectory()) return;
41813
41839
  } catch {
41814
41840
  return;
41815
41841
  }
41816
- const skillMd = path61.join(dir, "SKILL.md");
41842
+ const skillMd = path62.join(dir, "SKILL.md");
41817
41843
  if (!fs40.existsSync(skillMd)) return;
41818
41844
  const key = `${rel}/${name}`;
41819
41845
  if (seenKeys.has(key)) return;
@@ -41826,7 +41852,7 @@ async function discoverLocalSkillsAsync(cwd) {
41826
41852
  let work = 0;
41827
41853
  for (const rel of SKILL_DISCOVERY_ROOTS) {
41828
41854
  await yieldSkillDiscoveryWork(++work);
41829
- const base = path61.join(cwd, rel);
41855
+ const base = path62.join(cwd, rel);
41830
41856
  if (!fs40.existsSync(base) || !fs40.statSync(base).isDirectory()) continue;
41831
41857
  let entries = [];
41832
41858
  try {
@@ -41844,15 +41870,15 @@ async function discoverLocalSkillsAsync(cwd) {
41844
41870
 
41845
41871
  // src/skills/discovery/discover-skill-layout-roots.ts
41846
41872
  import fs41 from "node:fs";
41847
- import path62 from "node:path";
41873
+ import path63 from "node:path";
41848
41874
  function collectLayoutSkill(rel, base, name, skills2) {
41849
- const dir = path62.join(base, name);
41875
+ const dir = path63.join(base, name);
41850
41876
  try {
41851
41877
  if (!fs41.statSync(dir).isDirectory()) return;
41852
41878
  } catch {
41853
41879
  return;
41854
41880
  }
41855
- if (!fs41.existsSync(path62.join(dir, "SKILL.md"))) return;
41881
+ if (!fs41.existsSync(path63.join(dir, "SKILL.md"))) return;
41856
41882
  const relPath = `${rel}/${name}`.replace(/\\/g, "/");
41857
41883
  skills2.push({ name, relPath });
41858
41884
  }
@@ -41861,7 +41887,7 @@ async function discoverSkillLayoutRootsAsync(cwd) {
41861
41887
  let work = 0;
41862
41888
  for (const rel of SKILL_DISCOVERY_ROOTS) {
41863
41889
  await yieldSkillDiscoveryWork(++work);
41864
- const base = path62.join(cwd, rel);
41890
+ const base = path63.join(cwd, rel);
41865
41891
  if (!fs41.existsSync(base) || !fs41.statSync(base).isDirectory()) continue;
41866
41892
  let entries = [];
41867
41893
  try {
@@ -41958,8 +41984,8 @@ var API_TO_BRIDGE_MESSAGE_TYPES = [
41958
41984
  "auth_token",
41959
41985
  "bridge_identified",
41960
41986
  "ha",
41961
- "dev_servers_config",
41962
- "server_control",
41987
+ "preview_environments_config",
41988
+ "preview_environment_control",
41963
41989
  "agent_config",
41964
41990
  "prompt_queue_state",
41965
41991
  "prompt",
@@ -42019,7 +42045,7 @@ var handleBridgeIdentified = (msg, deps) => {
42019
42045
  deps.onBridgeIdentified({
42020
42046
  bridgeName: msg.bridgeName,
42021
42047
  proxyPorts: msg.proxyPorts,
42022
- devServers: msg.devServers
42048
+ previewEnvironments: msg.previewEnvironments
42023
42049
  });
42024
42050
  setImmediate(() => {
42025
42051
  void (async () => {
@@ -42213,7 +42239,7 @@ import fs43 from "node:fs";
42213
42239
 
42214
42240
  // src/git/snapshot/capture.ts
42215
42241
  import * as fs42 from "node:fs";
42216
- import * as path63 from "node:path";
42242
+ import * as path64 from "node:path";
42217
42243
 
42218
42244
  // src/git/snapshot/git.ts
42219
42245
  async function gitStashCreate(repoRoot, log2) {
@@ -42253,7 +42279,7 @@ async function gitRun(repoRoot, args, log2, label) {
42253
42279
  async function resolveSnapshotRepoRoots(options) {
42254
42280
  const { worktreePaths, fallbackCwd, sessionId, log: log2 } = options;
42255
42281
  if (worktreePaths?.length) {
42256
- const uniq = [...new Set(worktreePaths.map((p) => path63.resolve(p)))];
42282
+ const uniq = [...new Set(worktreePaths.map((p) => path64.resolve(p)))];
42257
42283
  return uniq;
42258
42284
  }
42259
42285
  try {
@@ -42261,7 +42287,7 @@ async function resolveSnapshotRepoRoots(options) {
42261
42287
  const mapped = repos.map((r) => r.absolutePath);
42262
42288
  const sid = sessionId?.trim();
42263
42289
  if (sid) {
42264
- const filtered = mapped.filter((root) => path63.basename(root) === sid);
42290
+ const filtered = mapped.filter((root) => path64.basename(root) === sid);
42265
42291
  if (filtered.length > 0) return filtered;
42266
42292
  }
42267
42293
  return mapped;
@@ -42292,7 +42318,7 @@ async function capturePreTurnSnapshot(options) {
42292
42318
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
42293
42319
  repos
42294
42320
  };
42295
- const filePath = path63.join(dir, `${runId}.json`);
42321
+ const filePath = path64.join(dir, `${runId}.json`);
42296
42322
  try {
42297
42323
  fs42.writeFileSync(filePath, JSON.stringify(payload, null, 2), "utf8");
42298
42324
  } catch (e) {
@@ -42635,9 +42661,9 @@ function parseChangeSummarySnapshots(raw) {
42635
42661
  for (const item of raw) {
42636
42662
  if (!item || typeof item !== "object") continue;
42637
42663
  const o = item;
42638
- const path73 = typeof o.path === "string" && o.path.trim() !== "" ? o.path.trim() : "";
42639
- if (!path73) continue;
42640
- const row = { path: path73 };
42664
+ const path74 = typeof o.path === "string" && o.path.trim() !== "" ? o.path.trim() : "";
42665
+ if (!path74) continue;
42666
+ const row = { path: path74 };
42641
42667
  if (typeof o.patchContent === "string") row.patchContent = o.patchContent;
42642
42668
  if (typeof o.oldText === "string") row.oldText = o.oldText;
42643
42669
  if (typeof o.newText === "string") row.newText = o.newText;
@@ -42866,11 +42892,11 @@ async function resolveFileBrowserSessionParent(sessionWorktreeManager, sessionId
42866
42892
  import fs45 from "node:fs";
42867
42893
 
42868
42894
  // src/files/ensure-under-cwd.ts
42869
- import path64 from "node:path";
42895
+ import path65 from "node:path";
42870
42896
  function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
42871
- const normalized = path64.normalize(relativePath).replace(/^(\.\/)+/, "");
42872
- const resolved = path64.resolve(cwd, normalized);
42873
- if (!resolved.startsWith(cwd + path64.sep) && resolved !== cwd) {
42897
+ const normalized = path65.normalize(relativePath).replace(/^(\.\/)+/, "");
42898
+ const resolved = path65.resolve(cwd, normalized);
42899
+ if (!resolved.startsWith(cwd + path65.sep) && resolved !== cwd) {
42874
42900
  return null;
42875
42901
  }
42876
42902
  return resolved;
@@ -42880,11 +42906,11 @@ function ensureUnderCwd(relativePath, cwd = getBridgeRoot()) {
42880
42906
  var LIST_DIR_YIELD_EVERY = 256;
42881
42907
 
42882
42908
  // src/files/list-dir/map-dir-entry.ts
42883
- import path65 from "node:path";
42909
+ import path66 from "node:path";
42884
42910
  import fs44 from "node:fs";
42885
42911
  async function mapDirEntry(d, relativePath, resolved) {
42886
- const entryPath = path65.join(relativePath || ".", d.name).replace(/\\/g, "/");
42887
- const fullPath = path65.join(resolved, d.name);
42912
+ const entryPath = path66.join(relativePath || ".", d.name).replace(/\\/g, "/");
42913
+ const fullPath = path66.join(resolved, d.name);
42888
42914
  let isDir = d.isDirectory();
42889
42915
  if (d.isSymbolicLink()) {
42890
42916
  try {
@@ -42934,13 +42960,13 @@ async function listDirAsync(relativePath, sessionParentPath = getBridgeRoot()) {
42934
42960
  }
42935
42961
 
42936
42962
  // src/files/handle-file-browser-search.ts
42937
- import path66 from "node:path";
42963
+ import path67 from "node:path";
42938
42964
  var SEARCH_LIMIT = 100;
42939
42965
  function handleFileBrowserSearch(msg, socket, e2ee, sessionWorktreeManager) {
42940
42966
  void (async () => {
42941
42967
  await yieldToEventLoop();
42942
42968
  const q = typeof msg.q === "string" ? msg.q : "";
42943
- const sessionParentPath = path66.resolve(
42969
+ const sessionParentPath = path67.resolve(
42944
42970
  sessionWorktreeManager != null ? await resolveFileBrowserSessionParent(sessionWorktreeManager, msg.sessionId) : getBridgeRoot()
42945
42971
  );
42946
42972
  if (!await bridgeFileIndexIsPopulated(sessionParentPath)) {
@@ -43150,13 +43176,13 @@ function triggerSymbolIndexBuild(parentPath) {
43150
43176
  }
43151
43177
 
43152
43178
  // src/git/tree/resolve-repo-abs-path.ts
43153
- import * as path67 from "node:path";
43179
+ import * as path68 from "node:path";
43154
43180
  function resolveRepoAbsPathFromBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
43155
- const bridgeResolved = path67.resolve(bridgeRoot);
43181
+ const bridgeResolved = path68.resolve(bridgeRoot);
43156
43182
  const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
43157
- const repoPath = rel === "" ? bridgeResolved : path67.join(bridgeResolved, rel);
43158
- const resolved = path67.resolve(repoPath);
43159
- if (!resolved.startsWith(bridgeResolved + path67.sep) && resolved !== bridgeResolved) {
43183
+ const repoPath = rel === "" ? bridgeResolved : path68.join(bridgeResolved, rel);
43184
+ const resolved = path68.resolve(repoPath);
43185
+ if (!resolved.startsWith(bridgeResolved + path68.sep) && resolved !== bridgeResolved) {
43160
43186
  return null;
43161
43187
  }
43162
43188
  return resolved;
@@ -43939,7 +43965,7 @@ function isValidRemoteSkillInstallItem(item) {
43939
43965
 
43940
43966
  // src/skills/install/install-remote-skills-async.ts
43941
43967
  import fs49 from "node:fs";
43942
- import path68 from "node:path";
43968
+ import path69 from "node:path";
43943
43969
 
43944
43970
  // src/skills/install/constants.ts
43945
43971
  var INSTALL_SKILLS_YIELD_EVERY = 16;
@@ -43950,8 +43976,8 @@ async function writeInstallFileAsync(skillDir, f, filesWritten) {
43950
43976
  if (++filesWritten.count % INSTALL_SKILLS_YIELD_EVERY === 0) {
43951
43977
  await yieldToEventLoop();
43952
43978
  }
43953
- const dest = path68.join(skillDir, f.path);
43954
- await fs49.promises.mkdir(path68.dirname(dest), { recursive: true });
43979
+ const dest = path69.join(skillDir, f.path);
43980
+ await fs49.promises.mkdir(path69.dirname(dest), { recursive: true });
43955
43981
  if (f.text !== void 0) {
43956
43982
  await fs49.promises.writeFile(dest, f.text, "utf8");
43957
43983
  } else if (f.base64) {
@@ -43967,7 +43993,7 @@ async function installRemoteSkillsAsync(cwd, targetDir, items) {
43967
43993
  try {
43968
43994
  for (const item of items) {
43969
43995
  if (!isValidRemoteSkillInstallItem(item)) continue;
43970
- const skillDir = path68.join(cwd, targetDir, item.skillName);
43996
+ const skillDir = path69.join(cwd, targetDir, item.skillName);
43971
43997
  for (const f of item.files) {
43972
43998
  await writeInstallFileAsync(skillDir, f, filesWritten);
43973
43999
  }
@@ -44282,31 +44308,31 @@ var handleRevertTurnSnapshotMessage = (msg, deps) => {
44282
44308
  })();
44283
44309
  };
44284
44310
 
44285
- // src/routing/handlers/dev-server-control.ts
44286
- var handleDevServerControl = (msg, deps) => {
44311
+ // src/routing/handlers/preview-environment-control.ts
44312
+ var handlePreviewEnvironmentControl = (msg, deps) => {
44287
44313
  let wire;
44288
44314
  try {
44289
44315
  wire = deps.e2ee ? deps.e2ee.decryptMessage(msg) : msg;
44290
44316
  } catch (e) {
44291
- deps.log(`[E2EE] Could not decrypt dev server command: ${e instanceof Error ? e.message : String(e)}`);
44317
+ deps.log(`[E2EE] Could not decrypt preview environment command: ${e instanceof Error ? e.message : String(e)}`);
44292
44318
  return;
44293
44319
  }
44294
- const serverId = typeof wire.serverId === "string" ? wire.serverId : "";
44320
+ const environmentId = typeof wire.environmentId === "string" ? wire.environmentId : "";
44295
44321
  const action = wire.action === "start" || wire.action === "stop" ? wire.action : null;
44296
- if (!serverId || !action) return;
44297
- deps.devServerManager?.handleControl(serverId, action);
44322
+ if (!environmentId || !action) return;
44323
+ deps.previewEnvironmentManager?.handleControl(environmentId, action);
44298
44324
  };
44299
44325
 
44300
- // src/routing/handlers/dev-servers-config.ts
44301
- var handleDevServersConfig = (msg, deps) => {
44302
- const devServers = msg.devServers;
44326
+ // src/routing/handlers/preview-environments-config.ts
44327
+ var handlePreviewEnvironmentsConfig = (msg, deps) => {
44328
+ const previewEnvironments = msg.previewEnvironments;
44303
44329
  setImmediate(() => {
44304
- deps.devServerManager?.applyConfig(devServers ?? []);
44330
+ deps.previewEnvironmentManager?.applyConfig(previewEnvironments ?? []);
44305
44331
  });
44306
44332
  };
44307
44333
 
44308
44334
  // src/git/bridge-git-context.ts
44309
- import * as path69 from "node:path";
44335
+ import * as path70 from "node:path";
44310
44336
 
44311
44337
  // src/git/branches/get-current-branch.ts
44312
44338
  async function getCurrentBranch(repoPath) {
@@ -44356,12 +44382,12 @@ async function listRepoBranchRefs(repoPath) {
44356
44382
  // src/git/bridge-git-context.ts
44357
44383
  function folderNameForRelPath(relPath, bridgeRoot) {
44358
44384
  if (relPath === "." || relPath === "") {
44359
- return path69.basename(path69.resolve(bridgeRoot)) || "repo";
44385
+ return path70.basename(path70.resolve(bridgeRoot)) || "repo";
44360
44386
  }
44361
- return path69.basename(relPath) || relPath;
44387
+ return path70.basename(relPath) || relPath;
44362
44388
  }
44363
44389
  async function discoverGitReposForBridgeContext(bridgeRoot) {
44364
- const root = path69.resolve(bridgeRoot);
44390
+ const root = path70.resolve(bridgeRoot);
44365
44391
  if (await isGitRepoDirectory(root)) {
44366
44392
  const remoteUrl = await getRemoteOriginUrl(root);
44367
44393
  return [{ absolutePath: root, remoteUrl }];
@@ -44369,19 +44395,19 @@ async function discoverGitReposForBridgeContext(bridgeRoot) {
44369
44395
  const [deep, shallow] = await Promise.all([discoverGitReposUnderRoot(root), discoverGitRepos(root)]);
44370
44396
  const byPath = /* @__PURE__ */ new Map();
44371
44397
  for (const repo of [...deep, ...shallow]) {
44372
- byPath.set(path69.resolve(repo.absolutePath), repo);
44398
+ byPath.set(path70.resolve(repo.absolutePath), repo);
44373
44399
  }
44374
44400
  return [...byPath.values()];
44375
44401
  }
44376
44402
  async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
44377
- const bridgeResolved = path69.resolve(bridgeRoot);
44403
+ const bridgeResolved = path70.resolve(bridgeRoot);
44378
44404
  const repos = await discoverGitReposForBridgeContext(bridgeResolved);
44379
44405
  const rows = [];
44380
44406
  for (let i = 0; i < repos.length; i++) {
44381
44407
  if (i > 0) await yieldToEventLoop();
44382
44408
  const repo = repos[i];
44383
- let rel = path69.relative(bridgeResolved, repo.absolutePath);
44384
- if (rel.startsWith("..") || path69.isAbsolute(rel)) continue;
44409
+ let rel = path70.relative(bridgeResolved, repo.absolutePath);
44410
+ if (rel.startsWith("..") || path70.isAbsolute(rel)) continue;
44385
44411
  const relPath = rel === "" ? "." : rel.replace(/\\/g, "/");
44386
44412
  const currentBranch = await getCurrentBranch(repo.absolutePath);
44387
44413
  const remoteUrl = repo.remoteUrl.trim() || null;
@@ -44396,11 +44422,11 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
44396
44422
  return rows;
44397
44423
  }
44398
44424
  async function listRepoBranchesForBridge(repoRelPath, bridgeRoot = getBridgeRoot()) {
44399
- const bridgeResolved = path69.resolve(bridgeRoot);
44425
+ const bridgeResolved = path70.resolve(bridgeRoot);
44400
44426
  const rel = repoRelPath.trim() === "." ? "" : repoRelPath.trim().replace(/\\/g, "/");
44401
- const repoPath = rel === "" ? bridgeResolved : path69.join(bridgeResolved, rel);
44402
- const resolved = path69.resolve(repoPath);
44403
- if (!resolved.startsWith(bridgeResolved + path69.sep) && resolved !== bridgeResolved) {
44427
+ const repoPath = rel === "" ? bridgeResolved : path70.join(bridgeResolved, rel);
44428
+ const resolved = path70.resolve(repoPath);
44429
+ if (!resolved.startsWith(bridgeResolved + path70.sep) && resolved !== bridgeResolved) {
44404
44430
  return [];
44405
44431
  }
44406
44432
  return listRepoBranchRefs(resolved);
@@ -44461,11 +44487,11 @@ function dispatchBridgeMessage(msg, deps) {
44461
44487
  case "ha":
44462
44488
  handleBridgeHeartbeatAck(msg, deps);
44463
44489
  break;
44464
- case "dev_servers_config":
44465
- handleDevServersConfig(msg, deps);
44490
+ case "preview_environments_config":
44491
+ handlePreviewEnvironmentsConfig(msg, deps);
44466
44492
  break;
44467
- case "server_control":
44468
- handleDevServerControl(msg, deps);
44493
+ case "preview_environment_control":
44494
+ handlePreviewEnvironmentControl(msg, deps);
44469
44495
  break;
44470
44496
  case "agent_config":
44471
44497
  handleAgentConfigMessage(msg, deps);
@@ -45356,7 +45382,7 @@ async function createBridgeAccessState(options = {}) {
45356
45382
  }
45357
45383
 
45358
45384
  // src/agents/capabilities/warmup-agent-capabilities-on-connect.ts
45359
- import * as path71 from "node:path";
45385
+ import * as path72 from "node:path";
45360
45386
 
45361
45387
  // src/sqlite/hash-json-sha256.ts
45362
45388
  import { createHash } from "node:crypto";
@@ -45423,7 +45449,7 @@ function listCliAgentCapabilityCacheForWorkspace(db, workspaceId) {
45423
45449
  }
45424
45450
 
45425
45451
  // src/agents/capabilities/probe-one-agent-type-for-capabilities.ts
45426
- import * as path70 from "node:path";
45452
+ import * as path71 from "node:path";
45427
45453
  async function probeOneAgentTypeForCapabilities(params) {
45428
45454
  const { agentType, cwd, workspaceId, log: log2, reportAgentCapabilities, bridgeReport = true, shouldContinue } = params;
45429
45455
  const canContinue = () => shouldContinue?.() !== false;
@@ -45461,7 +45487,7 @@ async function probeOneAgentTypeForCapabilities(params) {
45461
45487
  if (!canContinue()) return false;
45462
45488
  handle = await resolved.createClient({
45463
45489
  command: resolved.command,
45464
- cwd: path70.resolve(cwd),
45490
+ cwd: path71.resolve(cwd),
45465
45491
  backendAgentType: agentType,
45466
45492
  sessionMode: "agent",
45467
45493
  persistedAcpSessionId: null,
@@ -45539,7 +45565,7 @@ async function warmupAgentCapabilitiesOnConnect(params) {
45539
45565
  const { workspaceId, log: log2, getWs } = params;
45540
45566
  const isCurrent = beginAgentCapabilityWarmupRun();
45541
45567
  if (!isCurrent()) return;
45542
- const cwd = path71.resolve(getBridgeRoot());
45568
+ const cwd = path72.resolve(getBridgeRoot());
45543
45569
  async function sendBatchFromCache() {
45544
45570
  if (!isCurrent()) return;
45545
45571
  const socket = getWs();
@@ -45652,7 +45678,7 @@ function createBridgeMessageDeps(params) {
45652
45678
  sendLocalSkillsReport,
45653
45679
  reportAutoDetectedAgents,
45654
45680
  warmupAgentCapabilitiesOnConnect: warmupAgentCapabilitiesOnConnect2,
45655
- devServerManager,
45681
+ previewEnvironmentManager,
45656
45682
  e2ee,
45657
45683
  cloudApiBaseUrl,
45658
45684
  getCloudAccessToken
@@ -45669,7 +45695,7 @@ function createBridgeMessageDeps(params) {
45669
45695
  sendLocalSkillsReport,
45670
45696
  reportAutoDetectedAgents,
45671
45697
  warmupAgentCapabilitiesOnConnect: warmupAgentCapabilitiesOnConnect2,
45672
- devServerManager,
45698
+ previewEnvironmentManager,
45673
45699
  e2ee,
45674
45700
  cloudApiBaseUrl,
45675
45701
  getCloudAccessToken
@@ -45739,10 +45765,10 @@ async function createBridgeConnection(options) {
45739
45765
  initialIndexBuildsScheduled = true;
45740
45766
  scheduleInitialIndexBuilds(getBridgeRoot());
45741
45767
  };
45742
- const devServerManager = new DevServerManager({ getWs, log: logFn, getBridgeRoot, e2ee });
45768
+ const previewEnvironmentManager = new PreviewEnvironmentManager({ getWs, log: logFn, getBridgeRoot, e2ee });
45743
45769
  const bridgeHeartbeat = createBridgeHeartbeatController({ getWs, log: logFn });
45744
45770
  const baseOnBridgeIdentified = createOnBridgeIdentified({
45745
- devServerManager,
45771
+ previewEnvironmentManager,
45746
45772
  firehoseServerUrl,
45747
45773
  workspaceId,
45748
45774
  state,
@@ -45768,14 +45794,14 @@ async function createBridgeConnection(options) {
45768
45794
  log: logFn,
45769
45795
  getWs
45770
45796
  }),
45771
- devServerManager,
45797
+ previewEnvironmentManager,
45772
45798
  e2ee,
45773
45799
  cloudApiBaseUrl: apiUrl,
45774
45800
  getCloudAccessToken: () => tokens.accessToken
45775
45801
  });
45776
45802
  const identifyReportedPaths = {
45777
- bridgeRootPath: path72.resolve(getBridgeRoot()),
45778
- worktreesRootPath: path72.resolve(worktreesRootPath)
45803
+ bridgeRootPath: path73.resolve(getBridgeRoot()),
45804
+ worktreesRootPath: path73.resolve(worktreesRootPath)
45779
45805
  };
45780
45806
  const { connect } = createMainBridgeWebSocketLifecycle({
45781
45807
  state,
@@ -45801,7 +45827,7 @@ async function createBridgeConnection(options) {
45801
45827
  requestCliImmediateShutdown();
45802
45828
  stopFileIndexWatcher();
45803
45829
  bridgeHeartbeat.stop();
45804
- await closeBridgeConnection(state, acpManager, devServerManager, logFn);
45830
+ await closeBridgeConnection(state, acpManager, previewEnvironmentManager, logFn);
45805
45831
  await bridgeAccess.close();
45806
45832
  }
45807
45833
  };