@buildautomaton/cli 0.1.80 → 0.1.82

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
@@ -4208,8 +4208,8 @@ var init_parseUtil = __esm({
4208
4208
  init_errors();
4209
4209
  init_en();
4210
4210
  makeIssue = (params) => {
4211
- const { data, path: path84, errorMaps, issueData } = params;
4212
- const fullPath = [...path84, ...issueData.path || []];
4211
+ const { data, path: path86, errorMaps, issueData } = params;
4212
+ const fullPath = [...path86, ...issueData.path || []];
4213
4213
  const fullIssue = {
4214
4214
  ...issueData,
4215
4215
  path: fullPath
@@ -4517,11 +4517,11 @@ var init_types = __esm({
4517
4517
  init_parseUtil();
4518
4518
  init_util();
4519
4519
  ParseInputLazyPath = class {
4520
- constructor(parent, value, path84, key) {
4520
+ constructor(parent, value, path86, key) {
4521
4521
  this._cachedPath = [];
4522
4522
  this.parent = parent;
4523
4523
  this.data = value;
4524
- this._path = path84;
4524
+ this._path = path86;
4525
4525
  this._key = key;
4526
4526
  }
4527
4527
  get path() {
@@ -8182,10 +8182,10 @@ function assignProp(target, prop, value) {
8182
8182
  configurable: true
8183
8183
  });
8184
8184
  }
8185
- function getElementAtPath(obj, path84) {
8186
- if (!path84)
8185
+ function getElementAtPath(obj, path86) {
8186
+ if (!path86)
8187
8187
  return obj;
8188
- return path84.reduce((acc, key) => acc?.[key], obj);
8188
+ return path86.reduce((acc, key) => acc?.[key], obj);
8189
8189
  }
8190
8190
  function promiseAllObject(promisesObj) {
8191
8191
  const keys = Object.keys(promisesObj);
@@ -8434,11 +8434,11 @@ function aborted(x, startIndex = 0) {
8434
8434
  }
8435
8435
  return false;
8436
8436
  }
8437
- function prefixIssues(path84, issues) {
8437
+ function prefixIssues(path86, issues) {
8438
8438
  return issues.map((iss) => {
8439
8439
  var _a2;
8440
8440
  (_a2 = iss).path ?? (_a2.path = []);
8441
- iss.path.unshift(path84);
8441
+ iss.path.unshift(path86);
8442
8442
  return iss;
8443
8443
  });
8444
8444
  }
@@ -8627,7 +8627,7 @@ function treeifyError(error40, _mapper) {
8627
8627
  return issue2.message;
8628
8628
  };
8629
8629
  const result = { errors: [] };
8630
- const processError = (error41, path84 = []) => {
8630
+ const processError = (error41, path86 = []) => {
8631
8631
  var _a2, _b;
8632
8632
  for (const issue2 of error41.issues) {
8633
8633
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -8637,7 +8637,7 @@ function treeifyError(error40, _mapper) {
8637
8637
  } else if (issue2.code === "invalid_element") {
8638
8638
  processError({ issues: issue2.issues }, issue2.path);
8639
8639
  } else {
8640
- const fullpath = [...path84, ...issue2.path];
8640
+ const fullpath = [...path86, ...issue2.path];
8641
8641
  if (fullpath.length === 0) {
8642
8642
  result.errors.push(mapper(issue2));
8643
8643
  continue;
@@ -8667,9 +8667,9 @@ function treeifyError(error40, _mapper) {
8667
8667
  processError(error40);
8668
8668
  return result;
8669
8669
  }
8670
- function toDotPath(path84) {
8670
+ function toDotPath(path86) {
8671
8671
  const segs = [];
8672
- for (const seg of path84) {
8672
+ for (const seg of path86) {
8673
8673
  if (typeof seg === "number")
8674
8674
  segs.push(`[${seg}]`);
8675
8675
  else if (typeof seg === "symbol")
@@ -21132,8 +21132,8 @@ var init_acp = __esm({
21132
21132
  this.#requestHandler = requestHandler;
21133
21133
  this.#notificationHandler = notificationHandler;
21134
21134
  this.#stream = stream;
21135
- this.#closedPromise = new Promise((resolve35) => {
21136
- this.#abortController.signal.addEventListener("abort", () => resolve35());
21135
+ this.#closedPromise = new Promise((resolve36) => {
21136
+ this.#abortController.signal.addEventListener("abort", () => resolve36());
21137
21137
  });
21138
21138
  this.#receive();
21139
21139
  }
@@ -21282,8 +21282,8 @@ var init_acp = __esm({
21282
21282
  }
21283
21283
  async sendRequest(method, params) {
21284
21284
  const id = this.#nextRequestId++;
21285
- const responsePromise = new Promise((resolve35, reject) => {
21286
- this.#pendingResponses.set(id, { resolve: resolve35, reject });
21285
+ const responsePromise = new Promise((resolve36, reject) => {
21286
+ this.#pendingResponses.set(id, { resolve: resolve36, reject });
21287
21287
  });
21288
21288
  await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
21289
21289
  return responsePromise;
@@ -21651,7 +21651,7 @@ var init_activity_tracker = __esm({
21651
21651
 
21652
21652
  // src/runtime/yield-to-event-loop.ts
21653
21653
  function yieldToEventLoop() {
21654
- return new Promise((resolve35) => setImmediate(resolve35));
21654
+ return new Promise((resolve36) => setImmediate(resolve36));
21655
21655
  }
21656
21656
  var init_yield_to_event_loop = __esm({
21657
21657
  "src/runtime/yield-to-event-loop.ts"() {
@@ -21692,7 +21692,7 @@ async function yieldUntilFileBrowserReadsIdle(pollMs = 5) {
21692
21692
  while (getFileBrowserInFlightReadCount() > 0) {
21693
21693
  await yieldToEventLoop();
21694
21694
  if (getFileBrowserInFlightReadCount() > 0) {
21695
- await new Promise((resolve35) => setTimeout(resolve35, pollMs));
21695
+ await new Promise((resolve36) => setTimeout(resolve36, pollMs));
21696
21696
  }
21697
21697
  }
21698
21698
  }
@@ -21702,7 +21702,7 @@ async function yieldUntilFileBrowserBrowseIdle(pollMs = 5) {
21702
21702
  const browseCooldownDone = lastActivityAt === 0 || Date.now() - lastActivityAt >= BROWSE_INDEX_COOLDOWN_MS;
21703
21703
  if (inFlightRequests2 === 0 && browseCooldownDone) return;
21704
21704
  await yieldToEventLoop();
21705
- await new Promise((resolve35) => setTimeout(resolve35, pollMs));
21705
+ await new Promise((resolve36) => setTimeout(resolve36, pollMs));
21706
21706
  }
21707
21707
  }
21708
21708
  async function yieldUntilFileBrowserIdle(pollMs = 5) {
@@ -21879,8 +21879,8 @@ function createRequestId(prefix) {
21879
21879
  }
21880
21880
  function waitForWorkerReady() {
21881
21881
  if (workerReady) return Promise.resolve();
21882
- return new Promise((resolve35) => {
21883
- workerReadyWaiters.push(resolve35);
21882
+ return new Promise((resolve36) => {
21883
+ workerReadyWaiters.push(resolve36);
21884
21884
  });
21885
21885
  }
21886
21886
  function registerWorkerReadyListener(listener) {
@@ -21892,7 +21892,7 @@ function registerWorkerReadyListener(listener) {
21892
21892
  }
21893
21893
  function markWorkerReady() {
21894
21894
  workerReady = true;
21895
- for (const resolve35 of workerReadyWaiters) resolve35();
21895
+ for (const resolve36 of workerReadyWaiters) resolve36();
21896
21896
  workerReadyWaiters = [];
21897
21897
  workerReadyListener?.();
21898
21898
  }
@@ -22039,7 +22039,7 @@ async function waitForOuterCodeNavCacheAccessAsync() {
22039
22039
  if (isCliImmediateShutdownRequested() || isSymbolIndexWorkerShutdownRequested()) {
22040
22040
  throw new CliSqliteInterrupted();
22041
22041
  }
22042
- await new Promise((resolve35) => setTimeout(resolve35, 5));
22042
+ await new Promise((resolve36) => setTimeout(resolve36, 5));
22043
22043
  await yieldToEventLoop();
22044
22044
  }
22045
22045
  }
@@ -22376,7 +22376,7 @@ function readMigrationSql(filename, ...searchSubdirs) {
22376
22376
  join2(moduleDir, "..", sub, filename),
22377
22377
  join2(moduleDir, "..", "..", "dist", sub, filename)
22378
22378
  ]);
22379
- const resolved = candidates.find((path84) => existsSync(path84));
22379
+ const resolved = candidates.find((path86) => existsSync(path86));
22380
22380
  if (!resolved) {
22381
22381
  throw new Error(`Missing SQLite migration SQL: ${filename} (searched ${searchSubdirs.join(", ")})`);
22382
22382
  }
@@ -23454,7 +23454,7 @@ var require_ignore = __commonJS({
23454
23454
  // path matching.
23455
23455
  // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
23456
23456
  // @returns {TestResult} true if a file is ignored
23457
- test(path84, checkUnignored, mode) {
23457
+ test(path86, checkUnignored, mode) {
23458
23458
  let ignored = false;
23459
23459
  let unignored = false;
23460
23460
  let matchedRule;
@@ -23463,7 +23463,7 @@ var require_ignore = __commonJS({
23463
23463
  if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
23464
23464
  return;
23465
23465
  }
23466
- const matched = rule[mode].test(path84);
23466
+ const matched = rule[mode].test(path86);
23467
23467
  if (!matched) {
23468
23468
  return;
23469
23469
  }
@@ -23484,17 +23484,17 @@ var require_ignore = __commonJS({
23484
23484
  var throwError = (message, Ctor) => {
23485
23485
  throw new Ctor(message);
23486
23486
  };
23487
- var checkPath = (path84, originalPath, doThrow) => {
23488
- if (!isString(path84)) {
23487
+ var checkPath = (path86, originalPath, doThrow) => {
23488
+ if (!isString(path86)) {
23489
23489
  return doThrow(
23490
23490
  `path must be a string, but got \`${originalPath}\``,
23491
23491
  TypeError
23492
23492
  );
23493
23493
  }
23494
- if (!path84) {
23494
+ if (!path86) {
23495
23495
  return doThrow(`path must not be empty`, TypeError);
23496
23496
  }
23497
- if (checkPath.isNotRelative(path84)) {
23497
+ if (checkPath.isNotRelative(path86)) {
23498
23498
  const r = "`path.relative()`d";
23499
23499
  return doThrow(
23500
23500
  `path should be a ${r} string, but got "${originalPath}"`,
@@ -23503,7 +23503,7 @@ var require_ignore = __commonJS({
23503
23503
  }
23504
23504
  return true;
23505
23505
  };
23506
- var isNotRelative = (path84) => REGEX_TEST_INVALID_PATH.test(path84);
23506
+ var isNotRelative = (path86) => REGEX_TEST_INVALID_PATH.test(path86);
23507
23507
  checkPath.isNotRelative = isNotRelative;
23508
23508
  checkPath.convert = (p) => p;
23509
23509
  var Ignore = class {
@@ -23533,19 +23533,19 @@ var require_ignore = __commonJS({
23533
23533
  }
23534
23534
  // @returns {TestResult}
23535
23535
  _test(originalPath, cache2, checkUnignored, slices) {
23536
- const path84 = originalPath && checkPath.convert(originalPath);
23536
+ const path86 = originalPath && checkPath.convert(originalPath);
23537
23537
  checkPath(
23538
- path84,
23538
+ path86,
23539
23539
  originalPath,
23540
23540
  this._strictPathCheck ? throwError : RETURN_FALSE
23541
23541
  );
23542
- return this._t(path84, cache2, checkUnignored, slices);
23542
+ return this._t(path86, cache2, checkUnignored, slices);
23543
23543
  }
23544
- checkIgnore(path84) {
23545
- if (!REGEX_TEST_TRAILING_SLASH.test(path84)) {
23546
- return this.test(path84);
23544
+ checkIgnore(path86) {
23545
+ if (!REGEX_TEST_TRAILING_SLASH.test(path86)) {
23546
+ return this.test(path86);
23547
23547
  }
23548
- const slices = path84.split(SLASH).filter(Boolean);
23548
+ const slices = path86.split(SLASH).filter(Boolean);
23549
23549
  slices.pop();
23550
23550
  if (slices.length) {
23551
23551
  const parent = this._t(
@@ -23558,18 +23558,18 @@ var require_ignore = __commonJS({
23558
23558
  return parent;
23559
23559
  }
23560
23560
  }
23561
- return this._rules.test(path84, false, MODE_CHECK_IGNORE);
23561
+ return this._rules.test(path86, false, MODE_CHECK_IGNORE);
23562
23562
  }
23563
- _t(path84, cache2, checkUnignored, slices) {
23564
- if (path84 in cache2) {
23565
- return cache2[path84];
23563
+ _t(path86, cache2, checkUnignored, slices) {
23564
+ if (path86 in cache2) {
23565
+ return cache2[path86];
23566
23566
  }
23567
23567
  if (!slices) {
23568
- slices = path84.split(SLASH).filter(Boolean);
23568
+ slices = path86.split(SLASH).filter(Boolean);
23569
23569
  }
23570
23570
  slices.pop();
23571
23571
  if (!slices.length) {
23572
- return cache2[path84] = this._rules.test(path84, checkUnignored, MODE_IGNORE);
23572
+ return cache2[path86] = this._rules.test(path86, checkUnignored, MODE_IGNORE);
23573
23573
  }
23574
23574
  const parent = this._t(
23575
23575
  slices.join(SLASH) + SLASH,
@@ -23577,29 +23577,29 @@ var require_ignore = __commonJS({
23577
23577
  checkUnignored,
23578
23578
  slices
23579
23579
  );
23580
- return cache2[path84] = parent.ignored ? parent : this._rules.test(path84, checkUnignored, MODE_IGNORE);
23580
+ return cache2[path86] = parent.ignored ? parent : this._rules.test(path86, checkUnignored, MODE_IGNORE);
23581
23581
  }
23582
- ignores(path84) {
23583
- return this._test(path84, this._ignoreCache, false).ignored;
23582
+ ignores(path86) {
23583
+ return this._test(path86, this._ignoreCache, false).ignored;
23584
23584
  }
23585
23585
  createFilter() {
23586
- return (path84) => !this.ignores(path84);
23586
+ return (path86) => !this.ignores(path86);
23587
23587
  }
23588
23588
  filter(paths) {
23589
23589
  return makeArray(paths).filter(this.createFilter());
23590
23590
  }
23591
23591
  // @returns {TestResult}
23592
- test(path84) {
23593
- return this._test(path84, this._testCache, true);
23592
+ test(path86) {
23593
+ return this._test(path86, this._testCache, true);
23594
23594
  }
23595
23595
  };
23596
23596
  var factory = (options) => new Ignore(options);
23597
- var isPathValid = (path84) => checkPath(path84 && checkPath.convert(path84), path84, RETURN_FALSE);
23597
+ var isPathValid = (path86) => checkPath(path86 && checkPath.convert(path86), path86, RETURN_FALSE);
23598
23598
  var setupWindows = () => {
23599
23599
  const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
23600
23600
  checkPath.convert = makePosix;
23601
23601
  const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
23602
- checkPath.isNotRelative = (path84) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path84) || isNotRelative(path84);
23602
+ checkPath.isNotRelative = (path86) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path86) || isNotRelative(path86);
23603
23603
  };
23604
23604
  if (
23605
23605
  // Detect `process` so that it can run in browsers.
@@ -26790,7 +26790,7 @@ var init_setup_handlers = __esm({
26790
26790
  // src/code-nav/symbol-index/worker/handle-message.ts
26791
26791
  async function waitForActiveWorkerHandlersIdle(pollMs = 10) {
26792
26792
  while (activeWorkerHandlers > 0) {
26793
- await new Promise((resolve35) => setTimeout(resolve35, pollMs));
26793
+ await new Promise((resolve36) => setTimeout(resolve36, pollMs));
26794
26794
  }
26795
26795
  }
26796
26796
  async function handleRequestMessage(port, msg) {
@@ -27033,9 +27033,9 @@ async function requestWorker(message) {
27033
27033
  }
27034
27034
  ensureWorkerStarted();
27035
27035
  await ensureWorkerReadyForRequests();
27036
- return new Promise((resolve35, reject) => {
27036
+ return new Promise((resolve36, reject) => {
27037
27037
  pendingRequests.set(message.requestId, {
27038
- resolve: (value) => resolve35(value),
27038
+ resolve: (value) => resolve36(value),
27039
27039
  reject
27040
27040
  });
27041
27041
  postToWorker(message);
@@ -27061,37 +27061,37 @@ async function shutdownWorkerThread() {
27061
27061
  if (activeWorker != null) {
27062
27062
  setWorker(null);
27063
27063
  await Promise.race([
27064
- new Promise((resolve35) => {
27064
+ new Promise((resolve36) => {
27065
27065
  const onMessage = (message) => {
27066
27066
  if (message.type !== "shutdownComplete") return;
27067
27067
  activeWorker.off("message", onMessage);
27068
- resolve35();
27068
+ resolve36();
27069
27069
  };
27070
27070
  activeWorker.on("message", onMessage);
27071
27071
  try {
27072
27072
  activeWorker.postMessage({ type: "shutdown" });
27073
27073
  } catch {
27074
27074
  activeWorker.off("message", onMessage);
27075
- resolve35();
27075
+ resolve36();
27076
27076
  }
27077
27077
  }),
27078
- new Promise((resolve35) => setTimeout(resolve35, WORKER_SHUTDOWN_GRACE_MS))
27078
+ new Promise((resolve36) => setTimeout(resolve36, WORKER_SHUTDOWN_GRACE_MS))
27079
27079
  ]);
27080
27080
  await activeWorker.terminate();
27081
27081
  } else {
27082
27082
  const inProcess = getInProcessBridge();
27083
27083
  if (inProcess != null) {
27084
27084
  await Promise.race([
27085
- new Promise((resolve35) => {
27085
+ new Promise((resolve36) => {
27086
27086
  const onMessage = (message) => {
27087
27087
  if (message.type !== "shutdownComplete") return;
27088
27088
  inProcess.off("message", onMessage);
27089
- resolve35();
27089
+ resolve36();
27090
27090
  };
27091
27091
  inProcess.on("message", onMessage);
27092
27092
  inProcess.postMessage({ type: "shutdown" });
27093
27093
  }),
27094
- new Promise((resolve35) => setTimeout(resolve35, WORKER_SHUTDOWN_GRACE_MS))
27094
+ new Promise((resolve36) => setTimeout(resolve36, WORKER_SHUTDOWN_GRACE_MS))
27095
27095
  ]);
27096
27096
  }
27097
27097
  }
@@ -27977,10 +27977,10 @@ var require_src2 = __commonJS({
27977
27977
  var fs_1 = __require("fs");
27978
27978
  var debug_1 = __importDefault(require_src());
27979
27979
  var log2 = debug_1.default("@kwsites/file-exists");
27980
- function check2(path84, isFile, isDirectory) {
27981
- log2(`checking %s`, path84);
27980
+ function check2(path86, isFile, isDirectory) {
27981
+ log2(`checking %s`, path86);
27982
27982
  try {
27983
- const stat2 = fs_1.statSync(path84);
27983
+ const stat2 = fs_1.statSync(path86);
27984
27984
  if (stat2.isFile() && isFile) {
27985
27985
  log2(`[OK] path represents a file`);
27986
27986
  return true;
@@ -28000,8 +28000,8 @@ var require_src2 = __commonJS({
28000
28000
  throw e;
28001
28001
  }
28002
28002
  }
28003
- function exists2(path84, type = exports.READABLE) {
28004
- return check2(path84, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
28003
+ function exists2(path86, type = exports.READABLE) {
28004
+ return check2(path86, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
28005
28005
  }
28006
28006
  exports.exists = exists2;
28007
28007
  exports.FILE = 1;
@@ -28247,21 +28247,45 @@ function sendWsMessage(ws, payload) {
28247
28247
  // src/files/cwd/index.ts
28248
28248
  init_bridge_root();
28249
28249
 
28250
+ // src/agents/acp/clients/format-stderr-for-terminal.ts
28251
+ var STDERR_TERMINAL_CHUNK_MAX = 400;
28252
+ function formatStderrForTerminal(text, maxChars = STDERR_TERMINAL_CHUNK_MAX) {
28253
+ if (!text) return text;
28254
+ const bodyIdx = text.indexOf("; body:");
28255
+ if (bodyIdx >= 0) {
28256
+ const s = `${text.slice(0, bodyIdx)}; body: [omitted]`;
28257
+ return s.length <= maxChars ? `${s}
28258
+ ` : `${s.slice(0, maxChars)}\u2026 [stderr truncated]
28259
+ `;
28260
+ }
28261
+ const trimmed2 = text.trimStart();
28262
+ if (text.length > maxChars && (trimmed2.startsWith("{") || trimmed2.startsWith('"') || trimmed2.startsWith("["))) {
28263
+ return "";
28264
+ }
28265
+ if (text.length <= maxChars) return text;
28266
+ return `${text.slice(0, maxChars)}\u2026 [stderr truncated]
28267
+ `;
28268
+ }
28269
+
28250
28270
  // src/agents/acp/clients/agent-stderr-capture.ts
28251
- var STDERR_CAPTURE_MAX = 48e3;
28252
- function createStderrCapture(child) {
28271
+ var STDERR_CAPTURE_MAX = 4e3;
28272
+ function createStderrCapture(_child) {
28253
28273
  const chunks = [];
28254
28274
  let total = 0;
28255
28275
  return {
28256
28276
  append(chunk) {
28257
- try {
28258
- process.stderr.write(chunk);
28259
- } catch {
28277
+ const forTerminal = formatStderrForTerminal(chunk.toString("utf8"));
28278
+ if (forTerminal) {
28279
+ try {
28280
+ process.stderr.write(forTerminal);
28281
+ } catch {
28282
+ }
28260
28283
  }
28261
- if (total >= STDERR_CAPTURE_MAX) return;
28262
- const n = Math.min(chunk.length, STDERR_CAPTURE_MAX - total);
28284
+ if (!forTerminal || total >= STDERR_CAPTURE_MAX) return;
28285
+ const buf = Buffer.from(forTerminal, "utf8");
28286
+ const n = Math.min(buf.length, STDERR_CAPTURE_MAX - total);
28263
28287
  if (n <= 0) return;
28264
- chunks.push(n === chunk.length ? chunk : chunk.subarray(0, n));
28288
+ chunks.push(n === buf.length ? buf : buf.subarray(0, n));
28265
28289
  total += n;
28266
28290
  },
28267
28291
  getText() {
@@ -28340,10 +28364,10 @@ async function killChildProcessTreeGracefully(child, graceMs = ACP_PROCESS_TREE_
28340
28364
  }
28341
28365
  await killProcessTree(pid, "SIGTERM");
28342
28366
  if (graceMs <= 0) return;
28343
- const exited = new Promise((resolve35) => {
28344
- child.once("exit", () => resolve35());
28367
+ const exited = new Promise((resolve36) => {
28368
+ child.once("exit", () => resolve36());
28345
28369
  });
28346
- await Promise.race([exited, new Promise((resolve35) => setTimeout(resolve35, graceMs))]);
28370
+ await Promise.race([exited, new Promise((resolve36) => setTimeout(resolve36, graceMs))]);
28347
28371
  if (child.exitCode == null && child.signalCode == null) {
28348
28372
  await killProcessTree(pid, "SIGKILL");
28349
28373
  }
@@ -28360,8 +28384,8 @@ async function gracefulAcpSubprocessDisconnect(params) {
28360
28384
  await transport.closeSession?.(sessionId);
28361
28385
  } catch {
28362
28386
  }
28363
- await new Promise((resolve35) => {
28364
- const timer = setTimeout(resolve35, ACP_GRACEFUL_SESSION_CLOSE_WAIT_MS);
28387
+ await new Promise((resolve36) => {
28388
+ const timer = setTimeout(resolve36, ACP_GRACEFUL_SESSION_CLOSE_WAIT_MS);
28365
28389
  timer.unref?.();
28366
28390
  });
28367
28391
  }
@@ -29511,11 +29535,11 @@ function createSdkStdioExtNotificationHandler(options) {
29511
29535
  // src/agents/acp/clients/sdk/sdk-stdio-permission-request-handshake.ts
29512
29536
  function awaitSdkStdioPermissionRequestHandshake(params) {
29513
29537
  const { requestId, paramsRecord, pending: pending2, onRequest } = params;
29514
- return new Promise((resolve35) => {
29515
- pending2.set(requestId, { resolve: resolve35, params: paramsRecord });
29538
+ return new Promise((resolve36) => {
29539
+ pending2.set(requestId, { resolve: resolve36, params: paramsRecord });
29516
29540
  if (onRequest == null) {
29517
29541
  pending2.delete(requestId);
29518
- resolve35({ outcome: { outcome: "denied" } });
29542
+ resolve36({ outcome: { outcome: "denied" } });
29519
29543
  return;
29520
29544
  }
29521
29545
  try {
@@ -30027,10 +30051,10 @@ function createSdkStdioInitSettle(child) {
30027
30051
  forceAcpSubprocessDisconnect(child);
30028
30052
  reject(err);
30029
30053
  },
30030
- settleResolve(resolve35, handle) {
30054
+ settleResolve(resolve36, handle) {
30031
30055
  if (initSettled) return;
30032
30056
  initSettled = true;
30033
- resolve35(handle);
30057
+ resolve36(handle);
30034
30058
  }
30035
30059
  };
30036
30060
  }
@@ -30119,7 +30143,7 @@ async function createSdkStdioAcpClient(options) {
30119
30143
  onFileChange,
30120
30144
  stderrCapture
30121
30145
  });
30122
- return new Promise((resolve35, reject) => {
30146
+ return new Promise((resolve36, reject) => {
30123
30147
  const init = createSdkStdioInitSettle(child);
30124
30148
  child.on("error", (err) => {
30125
30149
  init.settleReject(reject, new Error(formatSpawnError(err, command[0])));
@@ -30144,7 +30168,7 @@ async function createSdkStdioAcpClient(options) {
30144
30168
  protocolVersion: PROTOCOL_VERSION2
30145
30169
  });
30146
30170
  init.settleResolve(
30147
- resolve35,
30171
+ resolve36,
30148
30172
  createSdkStdioHandle({
30149
30173
  child,
30150
30174
  sessionId: established.sessionId,
@@ -30280,19 +30304,19 @@ function buildLocalHttpRequestOptions(built) {
30280
30304
  }
30281
30305
  function runLocalHttpRequestOnce(mod, built) {
30282
30306
  const opts = buildLocalHttpRequestOptions(built);
30283
- return new Promise((resolve35) => {
30307
+ return new Promise((resolve36) => {
30284
30308
  const req = mod.request(opts, (res) => {
30285
30309
  const chunks = [];
30286
30310
  res.on("data", (chunk) => chunks.push(chunk));
30287
30311
  res.on("end", () => {
30288
- resolve35({
30312
+ resolve36({
30289
30313
  statusCode: res.statusCode ?? 0,
30290
30314
  headers: incomingMessageHeaders(res),
30291
30315
  body: Buffer.concat(chunks)
30292
30316
  });
30293
30317
  });
30294
30318
  res.on("error", (err) => {
30295
- resolve35({
30319
+ resolve36({
30296
30320
  statusCode: 0,
30297
30321
  headers: {},
30298
30322
  body: Buffer.alloc(0),
@@ -30304,7 +30328,7 @@ function runLocalHttpRequestOnce(mod, built) {
30304
30328
  req.destroy(new Error(`Local preview request timed out after ${LOCAL_PROXY_REQUEST_TIMEOUT_MS}ms`));
30305
30329
  });
30306
30330
  req.on("error", (err) => {
30307
- resolve35({
30331
+ resolve36({
30308
30332
  statusCode: 0,
30309
30333
  headers: {},
30310
30334
  body: Buffer.alloc(0),
@@ -30360,14 +30384,14 @@ async function proxyToLocalStreaming(request, callbacks) {
30360
30384
  const isHttps = request.url.startsWith("https:");
30361
30385
  const mod = await loadHttpModule(isHttps);
30362
30386
  const opts = buildLocalHttpRequestOptions(built);
30363
- await new Promise((resolve35) => {
30387
+ await new Promise((resolve36) => {
30364
30388
  const req = mod.request(opts, (res) => {
30365
30389
  try {
30366
30390
  callbacks.onStart(res.statusCode ?? 0, incomingMessageHeaders(res));
30367
30391
  } catch (err) {
30368
30392
  req.destroy();
30369
30393
  callbacks.onError(err instanceof Error ? err.message : String(err));
30370
- resolve35();
30394
+ resolve36();
30371
30395
  return;
30372
30396
  }
30373
30397
  res.on("data", (chunk) => {
@@ -30380,11 +30404,11 @@ async function proxyToLocalStreaming(request, callbacks) {
30380
30404
  });
30381
30405
  res.on("end", () => {
30382
30406
  callbacks.onEnd();
30383
- resolve35();
30407
+ resolve36();
30384
30408
  });
30385
30409
  res.on("error", (err) => {
30386
30410
  callbacks.onError(err.message);
30387
- resolve35();
30411
+ resolve36();
30388
30412
  });
30389
30413
  });
30390
30414
  req.setTimeout(LOCAL_PROXY_REQUEST_TIMEOUT_MS, () => {
@@ -30392,7 +30416,7 @@ async function proxyToLocalStreaming(request, callbacks) {
30392
30416
  });
30393
30417
  req.on("error", (err) => {
30394
30418
  callbacks.onError(err.message);
30395
- resolve35();
30419
+ resolve36();
30396
30420
  });
30397
30421
  if (built.sendingBody && built.body != null) {
30398
30422
  req.write(built.body);
@@ -30422,8 +30446,8 @@ function randomSecret() {
30422
30446
  }
30423
30447
  return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
30424
30448
  }
30425
- async function requestPreviewApi(port, secret, method, path84, body) {
30426
- const url2 = `http://127.0.0.1:${port}${path84}`;
30449
+ async function requestPreviewApi(port, secret, method, path86, body) {
30450
+ const url2 = `http://127.0.0.1:${port}${path86}`;
30427
30451
  const headers = {
30428
30452
  [PREVIEW_SECRET_HEADER]: secret,
30429
30453
  "Content-Type": "application/json"
@@ -30435,7 +30459,7 @@ async function requestPreviewApi(port, secret, method, path84, body) {
30435
30459
  });
30436
30460
  const data = await res.json().catch(() => ({}));
30437
30461
  if (!res.ok) {
30438
- throw new Error(data?.error ?? `Preview API ${method} ${path84}: ${res.status}`);
30462
+ throw new Error(data?.error ?? `Preview API ${method} ${path86}: ${res.status}`);
30439
30463
  }
30440
30464
  return data;
30441
30465
  }
@@ -31093,14 +31117,14 @@ var baseOpen = async (options) => {
31093
31117
  }
31094
31118
  const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
31095
31119
  if (options.wait) {
31096
- return new Promise((resolve35, reject) => {
31120
+ return new Promise((resolve36, reject) => {
31097
31121
  subprocess.once("error", reject);
31098
31122
  subprocess.once("close", (exitCode) => {
31099
31123
  if (!options.allowNonzeroExitCode && exitCode > 0) {
31100
31124
  reject(new Error(`Exited with code ${exitCode}`));
31101
31125
  return;
31102
31126
  }
31103
- resolve35(subprocess);
31127
+ resolve36(subprocess);
31104
31128
  });
31105
31129
  });
31106
31130
  }
@@ -31682,8 +31706,8 @@ function createPendingAuthOnClose(params) {
31682
31706
  // src/auth/pending/pending-auth-session.ts
31683
31707
  function createPendingAuthSession() {
31684
31708
  let resolveAuth;
31685
- const authPromise = new Promise((resolve35) => {
31686
- resolveAuth = resolve35;
31709
+ const authPromise = new Promise((resolve36) => {
31710
+ resolveAuth = resolve36;
31687
31711
  });
31688
31712
  return {
31689
31713
  ws: null,
@@ -31737,7 +31761,7 @@ function createPendingAuthOnMessage(params) {
31737
31761
  }
31738
31762
 
31739
31763
  // src/cli-version.ts
31740
- var CLI_VERSION = "0.1.80".length > 0 ? "0.1.80" : "0.0.0-dev";
31764
+ var CLI_VERSION = "0.1.82".length > 0 ? "0.1.82" : "0.0.0-dev";
31741
31765
 
31742
31766
  // src/auth/pending/pending-auth-on-open.ts
31743
31767
  function createPendingAuthOnOpen(params) {
@@ -33775,7 +33799,7 @@ async function createCursorAcpClient(options) {
33775
33799
  onFileChange,
33776
33800
  stderrCapture
33777
33801
  });
33778
- return new Promise((resolve35, reject) => {
33802
+ return new Promise((resolve36, reject) => {
33779
33803
  child.on("error", (err) => {
33780
33804
  killChildProcessTree(child, "SIGKILL");
33781
33805
  reject(new Error(formatSpawnError(err, command[0])));
@@ -33788,7 +33812,7 @@ async function createCursorAcpClient(options) {
33788
33812
  skipBrowserAuthenticate,
33789
33813
  incomingDeps: { dbgFs, sessionCtx, onSessionUpdate, onRequest }
33790
33814
  });
33791
- resolve35(
33815
+ resolve36(
33792
33816
  createCursorAcpHandle({
33793
33817
  child,
33794
33818
  sessionId: established.sessionId,
@@ -35227,8 +35251,8 @@ async function runGitTask(fn) {
35227
35251
  }
35228
35252
  async function yieldToEventLoop2() {
35229
35253
  throwIfGitShutdownRequested();
35230
- await new Promise((resolve35) => {
35231
- setImmediate(resolve35);
35254
+ await new Promise((resolve36) => {
35255
+ setImmediate(resolve36);
35232
35256
  });
35233
35257
  throwIfGitShutdownRequested();
35234
35258
  }
@@ -35265,8 +35289,8 @@ async function execGitFile(args, options) {
35265
35289
  }
35266
35290
 
35267
35291
  // src/git/changes/parse/normalize-git-diff-path.ts
35268
- function normalizeGitDiffPath(path84) {
35269
- return path84.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
35292
+ function normalizeGitDiffPath(path86) {
35293
+ return path86.replace(/\\/g, "/").replace(/\/ +/g, "/").trim();
35270
35294
  }
35271
35295
 
35272
35296
  // src/git/changes/parse/parse-name-status-entries.ts
@@ -36755,11 +36779,11 @@ function isServerNotRunningError(err) {
36755
36779
  }
36756
36780
  function closeHttpServer(server) {
36757
36781
  if (!server) return Promise.resolve();
36758
- return new Promise((resolve35) => {
36782
+ return new Promise((resolve36) => {
36759
36783
  server.close((err) => {
36760
36784
  if (err && !isServerNotRunningError(err)) {
36761
36785
  }
36762
- resolve35();
36786
+ resolve36();
36763
36787
  });
36764
36788
  });
36765
36789
  }
@@ -36772,7 +36796,7 @@ var RequestBodyTooLargeError = class extends Error {
36772
36796
  }
36773
36797
  };
36774
36798
  function readJsonBody(req) {
36775
- return new Promise((resolve35, reject) => {
36799
+ return new Promise((resolve36, reject) => {
36776
36800
  const chunks = [];
36777
36801
  let total = 0;
36778
36802
  let tooLarge = false;
@@ -36792,11 +36816,11 @@ function readJsonBody(req) {
36792
36816
  try {
36793
36817
  const raw = Buffer.concat(chunks).toString("utf8").trim();
36794
36818
  if (!raw) {
36795
- resolve35({});
36819
+ resolve36({});
36796
36820
  return;
36797
36821
  }
36798
36822
  const parsed = JSON.parse(raw);
36799
- resolve35(parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {});
36823
+ resolve36(parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {});
36800
36824
  } catch (e) {
36801
36825
  reject(e);
36802
36826
  }
@@ -36854,7 +36878,7 @@ function createBridgeAccessRequestHandler(registry2) {
36854
36878
  // src/mcp/bridge-access/start-server.ts
36855
36879
  function startBridgeAccessServer(registry2) {
36856
36880
  const server = http.createServer(createBridgeAccessRequestHandler(registry2));
36857
- return new Promise((resolve35, reject) => {
36881
+ return new Promise((resolve36, reject) => {
36858
36882
  server.once("error", reject);
36859
36883
  server.listen(0, "127.0.0.1", () => {
36860
36884
  const addr = server.address();
@@ -36862,7 +36886,7 @@ function startBridgeAccessServer(registry2) {
36862
36886
  reject(new Error("Bridge access server did not bind"));
36863
36887
  return;
36864
36888
  }
36865
- resolve35({
36889
+ resolve36({
36866
36890
  port: addr.port,
36867
36891
  close: () => closeHttpServer(server)
36868
36892
  });
@@ -39469,8 +39493,8 @@ function pathspec(...paths) {
39469
39493
  cache.set(key, paths);
39470
39494
  return key;
39471
39495
  }
39472
- function isPathSpec(path84) {
39473
- return path84 instanceof String && cache.has(path84);
39496
+ function isPathSpec(path86) {
39497
+ return path86 instanceof String && cache.has(path86);
39474
39498
  }
39475
39499
  function toPaths(pathSpec) {
39476
39500
  return cache.get(pathSpec) || [];
@@ -39559,8 +39583,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
39559
39583
  function forEachLineWithContent(input, callback) {
39560
39584
  return toLinesWithContent(input, true).map((line) => callback(line));
39561
39585
  }
39562
- function folderExists(path84) {
39563
- return (0, import_file_exists.exists)(path84, import_file_exists.FOLDER);
39586
+ function folderExists(path86) {
39587
+ return (0, import_file_exists.exists)(path86, import_file_exists.FOLDER);
39564
39588
  }
39565
39589
  function append(target, item) {
39566
39590
  if (Array.isArray(target)) {
@@ -39964,8 +39988,8 @@ function checkIsRepoRootTask() {
39964
39988
  commands,
39965
39989
  format: "utf-8",
39966
39990
  onError,
39967
- parser(path84) {
39968
- return /^\.(git)?$/.test(path84.trim());
39991
+ parser(path86) {
39992
+ return /^\.(git)?$/.test(path86.trim());
39969
39993
  }
39970
39994
  };
39971
39995
  }
@@ -40399,11 +40423,11 @@ function parseGrep(grep) {
40399
40423
  const paths = /* @__PURE__ */ new Set();
40400
40424
  const results = {};
40401
40425
  forEachLineWithContent(grep, (input) => {
40402
- const [path84, line, preview] = input.split(NULL);
40403
- paths.add(path84);
40404
- (results[path84] = results[path84] || []).push({
40426
+ const [path86, line, preview] = input.split(NULL);
40427
+ paths.add(path86);
40428
+ (results[path86] = results[path86] || []).push({
40405
40429
  line: asNumber(line),
40406
- path: path84,
40430
+ path: path86,
40407
40431
  preview
40408
40432
  });
40409
40433
  });
@@ -41168,14 +41192,14 @@ var init_hash_object = __esm2({
41168
41192
  init_task();
41169
41193
  }
41170
41194
  });
41171
- function parseInit(bare, path84, text) {
41195
+ function parseInit(bare, path86, text) {
41172
41196
  const response = String(text).trim();
41173
41197
  let result;
41174
41198
  if (result = initResponseRegex.exec(response)) {
41175
- return new InitSummary(bare, path84, false, result[1]);
41199
+ return new InitSummary(bare, path86, false, result[1]);
41176
41200
  }
41177
41201
  if (result = reInitResponseRegex.exec(response)) {
41178
- return new InitSummary(bare, path84, true, result[1]);
41202
+ return new InitSummary(bare, path86, true, result[1]);
41179
41203
  }
41180
41204
  let gitDir = "";
41181
41205
  const tokens = response.split(" ");
@@ -41186,7 +41210,7 @@ function parseInit(bare, path84, text) {
41186
41210
  break;
41187
41211
  }
41188
41212
  }
41189
- return new InitSummary(bare, path84, /^re/i.test(response), gitDir);
41213
+ return new InitSummary(bare, path86, /^re/i.test(response), gitDir);
41190
41214
  }
41191
41215
  var InitSummary;
41192
41216
  var initResponseRegex;
@@ -41195,9 +41219,9 @@ var init_InitSummary = __esm2({
41195
41219
  "src/lib/responses/InitSummary.ts"() {
41196
41220
  "use strict";
41197
41221
  InitSummary = class {
41198
- constructor(bare, path84, existing, gitDir) {
41222
+ constructor(bare, path86, existing, gitDir) {
41199
41223
  this.bare = bare;
41200
- this.path = path84;
41224
+ this.path = path86;
41201
41225
  this.existing = existing;
41202
41226
  this.gitDir = gitDir;
41203
41227
  }
@@ -41209,7 +41233,7 @@ var init_InitSummary = __esm2({
41209
41233
  function hasBareCommand(command) {
41210
41234
  return command.includes(bareCommand);
41211
41235
  }
41212
- function initTask(bare = false, path84, customArgs) {
41236
+ function initTask(bare = false, path86, customArgs) {
41213
41237
  const commands = ["init", ...customArgs];
41214
41238
  if (bare && !hasBareCommand(commands)) {
41215
41239
  commands.splice(1, 0, bareCommand);
@@ -41218,7 +41242,7 @@ function initTask(bare = false, path84, customArgs) {
41218
41242
  commands,
41219
41243
  format: "utf-8",
41220
41244
  parser(text) {
41221
- return parseInit(commands.includes("--bare"), path84, text);
41245
+ return parseInit(commands.includes("--bare"), path86, text);
41222
41246
  }
41223
41247
  };
41224
41248
  }
@@ -42034,12 +42058,12 @@ var init_FileStatusSummary = __esm2({
42034
42058
  "use strict";
42035
42059
  fromPathRegex = /^(.+)\0(.+)$/;
42036
42060
  FileStatusSummary = class {
42037
- constructor(path84, index, working_dir) {
42038
- this.path = path84;
42061
+ constructor(path86, index, working_dir) {
42062
+ this.path = path86;
42039
42063
  this.index = index;
42040
42064
  this.working_dir = working_dir;
42041
42065
  if (index === "R" || working_dir === "R") {
42042
- const detail = fromPathRegex.exec(path84) || [null, path84, path84];
42066
+ const detail = fromPathRegex.exec(path86) || [null, path86, path86];
42043
42067
  this.from = detail[2] || "";
42044
42068
  this.path = detail[1] || "";
42045
42069
  }
@@ -42070,14 +42094,14 @@ function splitLine(result, lineStr) {
42070
42094
  default:
42071
42095
  return;
42072
42096
  }
42073
- function data(index, workingDir, path84) {
42097
+ function data(index, workingDir, path86) {
42074
42098
  const raw = `${index}${workingDir}`;
42075
42099
  const handler = parsers6.get(raw);
42076
42100
  if (handler) {
42077
- handler(result, path84);
42101
+ handler(result, path86);
42078
42102
  }
42079
42103
  if (raw !== "##" && raw !== "!!") {
42080
- result.files.push(new FileStatusSummary(path84, index, workingDir));
42104
+ result.files.push(new FileStatusSummary(path86, index, workingDir));
42081
42105
  }
42082
42106
  }
42083
42107
  }
@@ -42386,9 +42410,9 @@ var init_simple_git_api = __esm2({
42386
42410
  next
42387
42411
  );
42388
42412
  }
42389
- hashObject(path84, write) {
42413
+ hashObject(path86, write) {
42390
42414
  return this._runTask(
42391
- hashObjectTask(path84, write === true),
42415
+ hashObjectTask(path86, write === true),
42392
42416
  trailingFunctionArgument(arguments)
42393
42417
  );
42394
42418
  }
@@ -42741,8 +42765,8 @@ var init_branch = __esm2({
42741
42765
  }
42742
42766
  });
42743
42767
  function toPath(input) {
42744
- const path84 = input.trim().replace(/^["']|["']$/g, "");
42745
- return path84 && normalize3(path84);
42768
+ const path86 = input.trim().replace(/^["']|["']$/g, "");
42769
+ return path86 && normalize3(path86);
42746
42770
  }
42747
42771
  var parseCheckIgnore;
42748
42772
  var init_CheckIgnore = __esm2({
@@ -43056,8 +43080,8 @@ __export2(sub_module_exports, {
43056
43080
  subModuleTask: () => subModuleTask,
43057
43081
  updateSubModuleTask: () => updateSubModuleTask
43058
43082
  });
43059
- function addSubModuleTask(repo, path84) {
43060
- return subModuleTask(["add", repo, path84]);
43083
+ function addSubModuleTask(repo, path86) {
43084
+ return subModuleTask(["add", repo, path86]);
43061
43085
  }
43062
43086
  function initSubModuleTask(customArgs) {
43063
43087
  return subModuleTask(["init", ...customArgs]);
@@ -43390,8 +43414,8 @@ var require_git = __commonJS2({
43390
43414
  }
43391
43415
  return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
43392
43416
  };
43393
- Git2.prototype.submoduleAdd = function(repo, path84, then) {
43394
- return this._runTask(addSubModuleTask2(repo, path84), trailingFunctionArgument2(arguments));
43417
+ Git2.prototype.submoduleAdd = function(repo, path86, then) {
43418
+ return this._runTask(addSubModuleTask2(repo, path86), trailingFunctionArgument2(arguments));
43395
43419
  };
43396
43420
  Git2.prototype.submoduleUpdate = function(args, then) {
43397
43421
  return this._runTask(
@@ -44130,8 +44154,8 @@ function parseNumstatEntries(lines) {
44130
44154
  }
44131
44155
  function parseNumstat(lines) {
44132
44156
  const m = /* @__PURE__ */ new Map();
44133
- for (const [path84, entry] of parseNumstatEntries(lines)) {
44134
- m.set(path84, { additions: entry.additions, deletions: entry.deletions });
44157
+ for (const [path86, entry] of parseNumstatEntries(lines)) {
44158
+ m.set(path86, { additions: entry.additions, deletions: entry.deletions });
44135
44159
  }
44136
44160
  return m;
44137
44161
  }
@@ -48219,7 +48243,7 @@ init_symbol_index_file_ready();
48219
48243
  var CODE_NAV_INDEX_READY_WAIT_MS = 75;
48220
48244
  var CODE_NAV_INDEX_READY_POLL_MS = 15;
48221
48245
  function delay2(ms) {
48222
- return new Promise((resolve35) => setTimeout(resolve35, ms));
48246
+ return new Promise((resolve36) => setTimeout(resolve36, ms));
48223
48247
  }
48224
48248
  async function waitForSymbolIndexReady(sessionParentPath, reqPath, maxWaitMs = CODE_NAV_INDEX_READY_WAIT_MS) {
48225
48249
  const deadline = Date.now() + maxWaitMs;
@@ -48351,12 +48375,12 @@ function parseOptionalInt2(raw) {
48351
48375
  return Number.isInteger(parsed) ? parsed : void 0;
48352
48376
  }
48353
48377
  function parseCodeNavParams(url2) {
48354
- const path84 = url2.searchParams.get("path") ?? "";
48378
+ const path86 = url2.searchParams.get("path") ?? "";
48355
48379
  const opRaw = url2.searchParams.get("op")?.trim();
48356
48380
  const op = opRaw === "references" ? "references" : opRaw === "symbols" ? "symbols" : opRaw === "definitions" ? "definitions" : "definition";
48357
48381
  const line = parseOptionalInt2(url2.searchParams.get("line")) ?? 1;
48358
48382
  const column = parseOptionalInt2(url2.searchParams.get("column")) ?? 0;
48359
- return { path: path84, op, line, column };
48383
+ return { path: path86, op, line, column };
48360
48384
  }
48361
48385
  function parseCodeNavPath(url2) {
48362
48386
  const raw = url2.searchParams.get("path")?.trim();
@@ -48532,7 +48556,7 @@ function createLocalShortcutRequestHandler(ctx) {
48532
48556
  var RESTART_DELAY_MS = 250;
48533
48557
  var MAX_RESTART_ATTEMPTS = 5;
48534
48558
  function listenOnPort(server, port) {
48535
- return new Promise((resolve35, reject) => {
48559
+ return new Promise((resolve36, reject) => {
48536
48560
  server.once("error", reject);
48537
48561
  server.listen(port, "127.0.0.1", () => {
48538
48562
  const addr = server.address();
@@ -48540,12 +48564,12 @@ function listenOnPort(server, port) {
48540
48564
  reject(new Error("Local shortcut server did not bind"));
48541
48565
  return;
48542
48566
  }
48543
- resolve35(addr.port);
48567
+ resolve36(addr.port);
48544
48568
  });
48545
48569
  });
48546
48570
  }
48547
48571
  function delay3(ms) {
48548
- return new Promise((resolve35) => setTimeout(resolve35, ms));
48572
+ return new Promise((resolve36) => setTimeout(resolve36, ms));
48549
48573
  }
48550
48574
  function startLocalShortcutServer(ctx) {
48551
48575
  let closed = false;
@@ -48745,7 +48769,8 @@ var API_TO_BRIDGE_MESSAGE_TYPES = [
48745
48769
  "install_agent",
48746
48770
  "refresh_local_skills",
48747
48771
  "bridge_git_context_request",
48748
- "list_repo_branches_request"
48772
+ "list_repo_branches_request",
48773
+ "bridge_git_checkout_request"
48749
48774
  ];
48750
48775
  var API_TO_BRIDGE_TYPE_SET = new Set(API_TO_BRIDGE_MESSAGE_TYPES);
48751
48776
  function parseApiToBridgeMessage(data, log2) {
@@ -49438,10 +49463,10 @@ async function awaitGitStatePreparation(options) {
49438
49463
  try {
49439
49464
  return await Promise.race([
49440
49465
  work,
49441
- new Promise((resolve35) => {
49466
+ new Promise((resolve36) => {
49442
49467
  timer = setTimeout(() => {
49443
49468
  log2(`[Agent] ${label} exceeded ${timeoutMs}ms; continuing without it.`);
49444
- resolve35(fallback);
49469
+ resolve36(fallback);
49445
49470
  }, timeoutMs);
49446
49471
  timer.unref?.();
49447
49472
  })
@@ -50100,7 +50125,7 @@ var handleInstallSkillsMessage = (msg, deps) => {
50100
50125
  import { spawn as spawn11 } from "node:child_process";
50101
50126
  import * as readline3 from "node:readline";
50102
50127
  function runStreamingCommand(command, args, options) {
50103
- return new Promise((resolve35, reject) => {
50128
+ return new Promise((resolve36, reject) => {
50104
50129
  const child = spawn11(command, args, {
50105
50130
  env: options.env,
50106
50131
  stdio: ["ignore", "pipe", "pipe"]
@@ -50133,7 +50158,7 @@ function runStreamingCommand(command, args, options) {
50133
50158
  if (timer) clearTimeout(timer);
50134
50159
  if (!settled) {
50135
50160
  settled = true;
50136
- resolve35({ code, signal });
50161
+ resolve36({ code, signal });
50137
50162
  }
50138
50163
  });
50139
50164
  });
@@ -50572,6 +50597,23 @@ async function listRepoBranchRefs(repoPath) {
50572
50597
  }
50573
50598
  }
50574
50599
 
50600
+ // src/git/checkout/pending-checkouts.ts
50601
+ var pendingByRelPath = /* @__PURE__ */ new Map();
50602
+ function beginPendingCheckout(row) {
50603
+ const relPath = row.relPath.trim() || ".";
50604
+ pendingByRelPath.set(relPath, {
50605
+ relPath,
50606
+ folderName: row.folderName.trim() || (relPath === "." ? "repo" : relPath),
50607
+ remoteUrl: row.remoteUrl
50608
+ });
50609
+ }
50610
+ function endPendingCheckout(relPath) {
50611
+ pendingByRelPath.delete(relPath.trim() || ".");
50612
+ }
50613
+ function listPendingCheckouts() {
50614
+ return [...pendingByRelPath.values()];
50615
+ }
50616
+
50575
50617
  // src/git/bridge-git-context.ts
50576
50618
  function folderNameForRelPath(relPath, bridgeRoot) {
50577
50619
  if (relPath === "." || relPath === "") {
@@ -50608,7 +50650,23 @@ async function getBridgeGitContext(bridgeRoot = getBridgeRoot()) {
50608
50650
  relPath,
50609
50651
  folderName: folderNameForRelPath(relPath, bridgeResolved),
50610
50652
  currentBranch,
50611
- remoteUrl
50653
+ remoteUrl,
50654
+ cloning: false
50655
+ });
50656
+ }
50657
+ const seen = new Set(rows.map((r) => r.relPath));
50658
+ for (const pending2 of listPendingCheckouts()) {
50659
+ if (seen.has(pending2.relPath)) {
50660
+ const row = rows.find((r) => r.relPath === pending2.relPath);
50661
+ if (row) row.cloning = true;
50662
+ continue;
50663
+ }
50664
+ rows.push({
50665
+ relPath: pending2.relPath,
50666
+ folderName: pending2.folderName,
50667
+ currentBranch: null,
50668
+ remoteUrl: pending2.remoteUrl,
50669
+ cloning: true
50612
50670
  });
50613
50671
  }
50614
50672
  rows.sort((a, b) => a.relPath.localeCompare(b.relPath));
@@ -50668,6 +50726,143 @@ function handleListRepoBranchesRequestMessage(msg, getWs) {
50668
50726
  })();
50669
50727
  }
50670
50728
 
50729
+ // src/git/checkout/bridge-git-checkout.ts
50730
+ import * as fs64 from "node:fs/promises";
50731
+ import * as path85 from "node:path";
50732
+
50733
+ // src/git/checkout/normalize-clone-url.ts
50734
+ function normalizeCloneUrl(url2) {
50735
+ const u = url2.trim();
50736
+ if (!u.startsWith("http://") && !u.startsWith("https://")) {
50737
+ throw new Error("Only http(s) git remote URLs are supported");
50738
+ }
50739
+ return u.endsWith(".git") ? u : `${u}.git`;
50740
+ }
50741
+ function cloneUrlWithHttpsAuth(url2, auth) {
50742
+ const normalized = normalizeCloneUrl(url2);
50743
+ if (!auth) return normalized;
50744
+ const parsed = new URL(normalized);
50745
+ parsed.username = auth.username;
50746
+ parsed.password = auth.password;
50747
+ return parsed.toString();
50748
+ }
50749
+
50750
+ // src/git/checkout/resolve-checkout-target.ts
50751
+ import * as fs63 from "node:fs/promises";
50752
+ import * as path84 from "node:path";
50753
+ var FOLDER_NAME_RE = /^[A-Za-z0-9._-]+$/;
50754
+ async function pathExists(p) {
50755
+ try {
50756
+ await fs63.access(p);
50757
+ return true;
50758
+ } catch {
50759
+ return false;
50760
+ }
50761
+ }
50762
+ async function resolveCheckoutTarget(opts) {
50763
+ const bridgeRoot = getBridgeRoot();
50764
+ if (opts.layout === "monorepo") {
50765
+ if (await isGitRepoDirectory(bridgeRoot)) {
50766
+ throw new Error("Bridge root is already a git repository");
50767
+ }
50768
+ const entries = await fs63.readdir(bridgeRoot).catch(() => []);
50769
+ if (entries.length > 0) {
50770
+ throw new Error("Bridge root must be empty to initialize a monorepo checkout");
50771
+ }
50772
+ return { targetDir: bridgeRoot, relPath: "." };
50773
+ }
50774
+ const folder = (opts.folderName ?? "").trim();
50775
+ if (!folder || folder === "." || folder === ".." || !FOLDER_NAME_RE.test(folder)) {
50776
+ throw new Error("folderName must be a single path segment (letters, numbers, . _ -)");
50777
+ }
50778
+ if (await isGitRepoDirectory(bridgeRoot)) {
50779
+ throw new Error("Cannot add a nested repo while the bridge root is itself a git repository");
50780
+ }
50781
+ const targetDir = path84.resolve(bridgeRoot, folder);
50782
+ if (!targetDir.startsWith(bridgeRoot + path84.sep)) {
50783
+ throw new Error("Invalid folderName");
50784
+ }
50785
+ if (await pathExists(targetDir)) {
50786
+ throw new Error(`Folder already exists: ${folder}`);
50787
+ }
50788
+ return { targetDir, relPath: folder };
50789
+ }
50790
+
50791
+ // src/git/checkout/bridge-git-checkout.ts
50792
+ async function bridgeGitCheckout(params) {
50793
+ const cloneUrl = (params.cloneUrl ?? "").trim();
50794
+ if (!cloneUrl) throw new Error("cloneUrl required");
50795
+ const { targetDir, relPath } = await resolveCheckoutTarget({
50796
+ layout: params.layout,
50797
+ folderName: params.folderName
50798
+ });
50799
+ const folderName = relPath === "." ? "repo" : relPath;
50800
+ beginPendingCheckout({ relPath, folderName, remoteUrl: cloneUrl });
50801
+ const parent = path85.dirname(targetDir);
50802
+ await fs64.mkdir(parent, { recursive: true });
50803
+ if (relPath !== ".") {
50804
+ await fs64.mkdir(targetDir, { recursive: true });
50805
+ }
50806
+ const url2 = cloneUrlWithHttpsAuth(cloneUrl, params.auth ?? null);
50807
+ try {
50808
+ await execGitFile(["clone", "--", url2, targetDir], {
50809
+ cwd: parent,
50810
+ env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }
50811
+ });
50812
+ return { relPath, folderName };
50813
+ } catch (e) {
50814
+ if (relPath !== ".") {
50815
+ await fs64.rm(targetDir, { recursive: true, force: true }).catch(() => void 0);
50816
+ }
50817
+ const msg = e instanceof Error ? e.message : String(e);
50818
+ throw new Error(
50819
+ msg.includes("Authentication") || msg.includes("403") || msg.includes("401") ? `Clone failed (auth?): ${msg}` : `Clone failed: ${msg}`
50820
+ );
50821
+ } finally {
50822
+ endPendingCheckout(relPath);
50823
+ }
50824
+ }
50825
+
50826
+ // src/routing/handlers/bridge-git-checkout-messages.ts
50827
+ function handleBridgeGitCheckoutRequestMessage(msg, getWs) {
50828
+ void (async () => {
50829
+ const socket = getWs();
50830
+ if (!socket) return;
50831
+ const layout = msg.layout === "multi_repo" ? "multi_repo" : msg.layout === "monorepo" ? "monorepo" : null;
50832
+ if (!layout) {
50833
+ sendWsMessage(socket, {
50834
+ type: "bridge_git_checkout_response",
50835
+ id: msg.id,
50836
+ error: "layout must be monorepo or multi_repo"
50837
+ });
50838
+ return;
50839
+ }
50840
+ try {
50841
+ const user = typeof msg.authUsername === "string" ? msg.authUsername : "";
50842
+ const pass = typeof msg.authPassword === "string" ? msg.authPassword : "";
50843
+ const result = await bridgeGitCheckout({
50844
+ layout,
50845
+ folderName: msg.folderName,
50846
+ cloneUrl: msg.cloneUrl ?? "",
50847
+ auth: user && pass ? { username: user, password: pass } : null
50848
+ });
50849
+ sendWsMessage(socket, {
50850
+ type: "bridge_git_checkout_response",
50851
+ id: msg.id,
50852
+ ok: true,
50853
+ relPath: result.relPath,
50854
+ folderName: result.folderName
50855
+ });
50856
+ } catch (e) {
50857
+ sendWsMessage(socket, {
50858
+ type: "bridge_git_checkout_response",
50859
+ id: msg.id,
50860
+ error: e instanceof Error ? e.message : String(e)
50861
+ });
50862
+ }
50863
+ })();
50864
+ }
50865
+
50671
50866
  // src/routing/dispatch/file-browser.ts
50672
50867
  function dispatchBridgeFileBrowserMessage(msg, deps) {
50673
50868
  switch (msg.type) {
@@ -50686,6 +50881,9 @@ function dispatchBridgeFileBrowserMessage(msg, deps) {
50686
50881
  case "list_repo_branches_request":
50687
50882
  handleListRepoBranchesRequestMessage(msg, deps.getWs);
50688
50883
  break;
50884
+ case "bridge_git_checkout_request":
50885
+ handleBridgeGitCheckoutRequestMessage(msg, deps.getWs);
50886
+ break;
50689
50887
  }
50690
50888
  }
50691
50889
 
@@ -50726,6 +50924,7 @@ function dispatchBridgeMessage(msg, deps) {
50726
50924
  case "code_nav":
50727
50925
  case "bridge_git_context_request":
50728
50926
  case "list_repo_branches_request":
50927
+ case "bridge_git_checkout_request":
50729
50928
  dispatchBridgeFileBrowserMessage(msg, deps);
50730
50929
  break;
50731
50930
  }
@@ -51191,12 +51390,12 @@ async function runConnectedBridge(options, restartWithoutAuth) {
51191
51390
  let cleanupKeyCommand;
51192
51391
  let bridgeClose = null;
51193
51392
  let endConnectedSession;
51194
- const sessionDone = new Promise((resolve35) => {
51195
- endConnectedSession = resolve35;
51393
+ const sessionDone = new Promise((resolve36) => {
51394
+ endConnectedSession = resolve36;
51196
51395
  });
51197
51396
  let resolveHandleReady;
51198
- const handleReady = new Promise((resolve35) => {
51199
- resolveHandleReady = resolve35;
51397
+ const handleReady = new Promise((resolve36) => {
51398
+ resolveHandleReady = resolve36;
51200
51399
  });
51201
51400
  const handleRef = { current: null };
51202
51401
  const signals = installConnectedBridgeSignals({