codeam-cli 2.76.22 → 2.76.23

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/index.js +691 -672
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3802,9 +3802,9 @@ var _default = makeConfig();
3802
3802
  var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, setSessionAgent, setSquadAuto, getSquadAuto, clearAll, saveCliConfig, loadCliConfig } = _default;
3803
3803
 
3804
3804
  // src/commands/pair-auto.ts
3805
- var fs66 = __toESM(require("fs"));
3806
- var os48 = __toESM(require("os"));
3807
- var path74 = __toESM(require("path"));
3805
+ var fs67 = __toESM(require("fs"));
3806
+ var os49 = __toESM(require("os"));
3807
+ var path75 = __toESM(require("path"));
3808
3808
  var import_crypto4 = require("crypto");
3809
3809
 
3810
3810
  // src/services/telemetry.service.ts
@@ -10617,7 +10617,7 @@ function readAnonId() {
10617
10617
  }
10618
10618
  function superProperties() {
10619
10619
  return {
10620
- cliVersion: true ? "2.76.22" : "0.0.0-dev",
10620
+ cliVersion: true ? "2.76.23" : "0.0.0-dev",
10621
10621
  nodeVersion: process.version,
10622
10622
  platform: process.platform,
10623
10623
  arch: process.arch,
@@ -10866,7 +10866,7 @@ var http = __toESM(require("http"));
10866
10866
  // package.json
10867
10867
  var package_default = {
10868
10868
  name: "codeam-cli",
10869
- version: "2.76.22",
10869
+ version: "2.76.23",
10870
10870
  description: "Workflow-continuity bridge for AI coding agents. Wrap Claude Code or Codex in a PTY and supervise, approve, and redirect the session from any device \u2014 async. The terminal companion for CodeAgent Mobile.",
10871
10871
  type: "commonjs",
10872
10872
  main: "dist/index.js",
@@ -12229,7 +12229,7 @@ var CommandRelayService = class _CommandRelayService {
12229
12229
  // fresh + clear the "CLI update available" banner after a self-update
12230
12230
  // (a codespace that reinstalls @latest reconnects via heartbeat, not
12231
12231
  // pair/reconnect). Older backends ignore the extra field.
12232
- ..."2.76.22" ? { ideVersion: "2.76.22" } : {}
12232
+ ..."2.76.23" ? { ideVersion: "2.76.23" } : {}
12233
12233
  };
12234
12234
  try {
12235
12235
  const res = await _postJson(`${API_BASE2}/api/plugin/heartbeat`, body, this.pollSecretHeader());
@@ -13710,12 +13710,54 @@ function closeAllTerminals() {
13710
13710
  }
13711
13711
 
13712
13712
  // src/commands/start/handlers.ts
13713
- var fs65 = __toESM(require("fs"));
13714
- var os47 = __toESM(require("os"));
13715
- var path73 = __toESM(require("path"));
13713
+ var fs66 = __toESM(require("fs"));
13714
+ var os48 = __toESM(require("os"));
13715
+ var path74 = __toESM(require("path"));
13716
13716
  var import_crypto3 = require("crypto");
13717
13717
  var import_child_process25 = require("child_process");
13718
13718
 
13719
+ // src/services/turn-marker.ts
13720
+ var fs6 = __toESM(require("fs"));
13721
+ var os6 = __toESM(require("os"));
13722
+ var path7 = __toESM(require("path"));
13723
+ var depth = 0;
13724
+ function codeamHome() {
13725
+ return path7.join(os6.homedir(), ".codeam");
13726
+ }
13727
+ function turnMarkerPath(pid = process.pid, home = codeamHome()) {
13728
+ return path7.join(home, "turns", String(pid));
13729
+ }
13730
+ function mark() {
13731
+ try {
13732
+ const file = turnMarkerPath();
13733
+ fs6.mkdirSync(path7.dirname(file), { recursive: true });
13734
+ fs6.writeFileSync(file, String(Date.now()));
13735
+ } catch {
13736
+ }
13737
+ }
13738
+ function clear() {
13739
+ try {
13740
+ fs6.rmSync(turnMarkerPath(), { force: true });
13741
+ } catch {
13742
+ }
13743
+ }
13744
+ async function withTurnMarker(fn) {
13745
+ if (depth++ === 0) mark();
13746
+ try {
13747
+ return await fn();
13748
+ } finally {
13749
+ if (--depth === 0) clear();
13750
+ }
13751
+ }
13752
+ function isProcessMidTurn(pid, home) {
13753
+ if (!pid) return false;
13754
+ try {
13755
+ return fs6.existsSync(turnMarkerPath(pid, home));
13756
+ } catch {
13757
+ return false;
13758
+ }
13759
+ }
13760
+
13719
13761
  // src/lib/payload.ts
13720
13762
  var import_zod2 = require("zod");
13721
13763
  var fileEntrySchema = import_zod2.z.object({
@@ -13933,8 +13975,8 @@ function parsePayload2(schema, raw) {
13933
13975
  }
13934
13976
 
13935
13977
  // src/services/file-ops.service.ts
13936
- var fs6 = __toESM(require("fs/promises"));
13937
- var path7 = __toESM(require("path"));
13978
+ var fs7 = __toESM(require("fs/promises"));
13979
+ var path8 = __toESM(require("path"));
13938
13980
  var MAX_FILE_BYTES = 5 * 1024 * 1024;
13939
13981
  var MAX_WALK_DEPTH = 6;
13940
13982
  var MAX_VISITED_DIRS = 5e3;
@@ -13969,12 +14011,12 @@ var SUBDIR_IGNORE = /* @__PURE__ */ new Set([
13969
14011
  "__pycache__"
13970
14012
  ]);
13971
14013
  function isUnder(parent, candidate) {
13972
- const rel = path7.relative(parent, candidate);
13973
- return rel === "" || !rel.startsWith("..") && !path7.isAbsolute(rel);
14014
+ const rel = path8.relative(parent, candidate);
14015
+ return rel === "" || !rel.startsWith("..") && !path8.isAbsolute(rel);
13974
14016
  }
13975
14017
  async function isExistingFile(absPath) {
13976
14018
  try {
13977
- const stat3 = await fs6.stat(absPath);
14019
+ const stat3 = await fs7.stat(absPath);
13978
14020
  return stat3.isFile();
13979
14021
  } catch {
13980
14022
  return false;
@@ -13987,13 +14029,13 @@ async function walkForSuffix(dir, needleVariants, depth2, ctx) {
13987
14029
  ctx.visited++;
13988
14030
  let entries2 = [];
13989
14031
  try {
13990
- entries2 = await fs6.readdir(dir, { withFileTypes: true });
14032
+ entries2 = await fs7.readdir(dir, { withFileTypes: true });
13991
14033
  } catch {
13992
14034
  return;
13993
14035
  }
13994
14036
  for (const e of entries2) {
13995
14037
  if (!e.isFile()) continue;
13996
- const full = path7.join(dir, e.name);
14038
+ const full = path8.join(dir, e.name);
13997
14039
  if (needleVariants.some((needle) => full.endsWith(needle))) {
13998
14040
  ctx.matches.push(full);
13999
14041
  if (ctx.matches.length >= ctx.cap) return;
@@ -14003,21 +14045,21 @@ async function walkForSuffix(dir, needleVariants, depth2, ctx) {
14003
14045
  if (!e.isDirectory()) continue;
14004
14046
  if (SUBDIR_IGNORE.has(e.name)) continue;
14005
14047
  if (e.name.startsWith(".") && SUBDIR_IGNORE.has(e.name)) continue;
14006
- await walkForSuffix(path7.join(dir, e.name), needleVariants, depth2 + 1, ctx);
14048
+ await walkForSuffix(path8.join(dir, e.name), needleVariants, depth2 + 1, ctx);
14007
14049
  if (ctx.matches.length >= ctx.cap) return;
14008
14050
  }
14009
14051
  }
14010
14052
  async function findFile(rawPath) {
14011
14053
  const cwd = process.cwd();
14012
- if (path7.isAbsolute(rawPath)) {
14013
- const abs = path7.normalize(rawPath);
14054
+ if (path8.isAbsolute(rawPath)) {
14055
+ const abs = path8.normalize(rawPath);
14014
14056
  if (isUnder(cwd, abs) && await isExistingFile(abs)) return abs;
14015
14057
  }
14016
- const direct = path7.resolve(cwd, rawPath);
14058
+ const direct = path8.resolve(cwd, rawPath);
14017
14059
  if (isUnder(cwd, direct) && await isExistingFile(direct)) return direct;
14018
- const normalized = path7.normalize(rawPath).replace(/^[./\\]+/, "");
14060
+ const normalized = path8.normalize(rawPath).replace(/^[./\\]+/, "");
14019
14061
  const needles = [
14020
- `${path7.sep}${normalized}`,
14062
+ `${path8.sep}${normalized}`,
14021
14063
  `/${normalized}`
14022
14064
  ].filter((v, i, a) => a.indexOf(v) === i);
14023
14065
  const ctx = { visited: 0, matches: [], cap: 16 };
@@ -14031,7 +14073,7 @@ async function findWriteTarget(rawPath) {
14031
14073
  const found = await findFile(rawPath);
14032
14074
  if (found) return found;
14033
14075
  const cwd = process.cwd();
14034
- const fallback = path7.isAbsolute(rawPath) ? path7.normalize(rawPath) : path7.resolve(cwd, rawPath);
14076
+ const fallback = path8.isAbsolute(rawPath) ? path8.normalize(rawPath) : path8.resolve(cwd, rawPath);
14035
14077
  if (!isUnder(cwd, fallback)) return null;
14036
14078
  return fallback;
14037
14079
  }
@@ -14048,11 +14090,11 @@ async function readProjectFile(rawPath) {
14048
14090
  if (!abs) {
14049
14091
  return { error: `File not found in the project tree: ${rawPath}` };
14050
14092
  }
14051
- const stat3 = await fs6.stat(abs);
14093
+ const stat3 = await fs7.stat(abs);
14052
14094
  if (stat3.size > MAX_FILE_BYTES) {
14053
14095
  return { error: `File too large (${(stat3.size / 1024 / 1024).toFixed(1)} MB > ${MAX_FILE_BYTES / 1024 / 1024} MB).` };
14054
14096
  }
14055
- const buf = await fs6.readFile(abs);
14097
+ const buf = await fs7.readFile(abs);
14056
14098
  if (looksBinary(buf)) {
14057
14099
  return { error: "Binary file \u2014 refusing to open in a code editor." };
14058
14100
  }
@@ -14071,8 +14113,8 @@ async function writeProjectFile(rawPath, content) {
14071
14113
  if (Buffer.byteLength(content, "utf-8") > MAX_FILE_BYTES) {
14072
14114
  return { error: "Content too large." };
14073
14115
  }
14074
- await fs6.mkdir(path7.dirname(abs), { recursive: true });
14075
- await fs6.writeFile(abs, content, "utf-8");
14116
+ await fs7.mkdir(path8.dirname(abs), { recursive: true });
14117
+ await fs7.writeFile(abs, content, "utf-8");
14076
14118
  return { ok: true };
14077
14119
  } catch (e) {
14078
14120
  const msg = e instanceof Error ? e.message : "Write failed";
@@ -14083,8 +14125,8 @@ async function writeProjectFile(rawPath, content) {
14083
14125
  // src/services/project-ops.service.ts
14084
14126
  var import_child_process5 = require("child_process");
14085
14127
  var import_util = require("util");
14086
- var fs7 = __toESM(require("fs/promises"));
14087
- var path8 = __toESM(require("path"));
14128
+ var fs8 = __toESM(require("fs/promises"));
14129
+ var path9 = __toESM(require("path"));
14088
14130
  var execFileP = (0, import_util.promisify)(import_child_process5.execFile);
14089
14131
  var PROJECT_IGNORE = /* @__PURE__ */ new Set([
14090
14132
  "node_modules",
@@ -14138,7 +14180,7 @@ async function listProjectFiles(opts = {}) {
14138
14180
  }
14139
14181
  let entries2 = [];
14140
14182
  try {
14141
- entries2 = await fs7.readdir(dir, { withFileTypes: true });
14183
+ entries2 = await fs8.readdir(dir, { withFileTypes: true });
14142
14184
  } catch {
14143
14185
  return;
14144
14186
  }
@@ -14148,18 +14190,18 @@ async function listProjectFiles(opts = {}) {
14148
14190
  return;
14149
14191
  }
14150
14192
  if (isProjectIgnored(e.name)) continue;
14151
- const full = path8.join(dir, e.name);
14193
+ const full = path9.join(dir, e.name);
14152
14194
  if (e.isDirectory()) {
14153
14195
  if (depth2 >= 12) continue;
14154
14196
  await walk2(full, depth2 + 1);
14155
14197
  } else if (e.isFile()) {
14156
- const rel = path8.relative(root, full);
14198
+ const rel = path9.relative(root, full);
14157
14199
  if (q2 && !rel.toLowerCase().includes(q2) && !e.name.toLowerCase().includes(q2)) {
14158
14200
  continue;
14159
14201
  }
14160
14202
  let size = 0;
14161
14203
  try {
14162
- const st3 = await fs7.stat(full);
14204
+ const st3 = await fs8.stat(full);
14163
14205
  size = st3.size;
14164
14206
  } catch {
14165
14207
  }
@@ -14261,8 +14303,8 @@ async function gitStatus(cwd) {
14261
14303
  let hasMergeInProgress = false;
14262
14304
  try {
14263
14305
  const gitDir = (await git(["rev-parse", "--git-dir"], root)).stdout.trim();
14264
- const mergeHead = path8.isAbsolute(gitDir) ? path8.join(gitDir, "MERGE_HEAD") : path8.join(root, gitDir, "MERGE_HEAD");
14265
- await fs7.access(mergeHead);
14306
+ const mergeHead = path9.isAbsolute(gitDir) ? path9.join(gitDir, "MERGE_HEAD") : path9.join(root, gitDir, "MERGE_HEAD");
14307
+ await fs8.access(mergeHead);
14266
14308
  hasMergeInProgress = true;
14267
14309
  } catch {
14268
14310
  }
@@ -14408,7 +14450,7 @@ async function jsSearchFiles(opts, cwd, cap) {
14408
14450
  }
14409
14451
  let content = "";
14410
14452
  try {
14411
- content = await fs7.readFile(path8.join(cwd, f.path), "utf8");
14453
+ content = await fs8.readFile(path9.join(cwd, f.path), "utf8");
14412
14454
  } catch {
14413
14455
  continue;
14414
14456
  }
@@ -14485,14 +14527,14 @@ function formatRemaining(expiresAt) {
14485
14527
 
14486
14528
  // src/services/apply-file-review.service.ts
14487
14529
  var import_child_process6 = require("child_process");
14488
- var fs8 = __toESM(require("fs"));
14489
- var path9 = __toESM(require("path"));
14530
+ var fs9 = __toESM(require("fs"));
14531
+ var path10 = __toESM(require("path"));
14490
14532
  async function applyFileReview(workingDir, filePath, action) {
14491
- if (filePath.includes("..") || path9.isAbsolute(filePath)) {
14533
+ if (filePath.includes("..") || path10.isAbsolute(filePath)) {
14492
14534
  return { ok: false, action, filePath, error: "invalid file path" };
14493
14535
  }
14494
- const absFile = path9.resolve(workingDir, filePath);
14495
- const repoRoot = findGitRoot2(path9.dirname(absFile));
14536
+ const absFile = path10.resolve(workingDir, filePath);
14537
+ const repoRoot = findGitRoot2(path10.dirname(absFile));
14496
14538
  if (!repoRoot) {
14497
14539
  return {
14498
14540
  ok: false,
@@ -14501,7 +14543,7 @@ async function applyFileReview(workingDir, filePath, action) {
14501
14543
  error: `no enclosing git repo for ${filePath}`
14502
14544
  };
14503
14545
  }
14504
- const relInRepo = path9.relative(repoRoot, absFile);
14546
+ const relInRepo = path10.relative(repoRoot, absFile);
14505
14547
  if (!relInRepo || relInRepo.startsWith("..")) {
14506
14548
  return { ok: false, action, filePath, error: "path escapes repo root" };
14507
14549
  }
@@ -14550,17 +14592,17 @@ function runGit2(cwd, args2) {
14550
14592
  });
14551
14593
  }
14552
14594
  function findGitRoot2(startDir) {
14553
- let dir = path9.resolve(startDir);
14595
+ let dir = path10.resolve(startDir);
14554
14596
  const seen2 = /* @__PURE__ */ new Set();
14555
14597
  for (let i = 0; i < 256; i++) {
14556
14598
  if (seen2.has(dir)) return null;
14557
14599
  seen2.add(dir);
14558
14600
  try {
14559
- const stat3 = fs8.statSync(path9.join(dir, ".git"), { throwIfNoEntry: false });
14601
+ const stat3 = fs9.statSync(path10.join(dir, ".git"), { throwIfNoEntry: false });
14560
14602
  if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
14561
14603
  } catch {
14562
14604
  }
14563
- const parent = path9.dirname(dir);
14605
+ const parent = path10.dirname(dir);
14564
14606
  if (parent === dir) return null;
14565
14607
  dir = parent;
14566
14608
  }
@@ -14569,8 +14611,8 @@ function findGitRoot2(startDir) {
14569
14611
 
14570
14612
  // src/commands/link.ts
14571
14613
  var import_node_crypto9 = require("crypto");
14572
- var fs31 = __toESM(require("fs"));
14573
- var path38 = __toESM(require("path"));
14614
+ var fs32 = __toESM(require("fs"));
14615
+ var path39 = __toESM(require("path"));
14574
14616
  var import_chokidar = __toESM(require("chokidar"));
14575
14617
  var import_picocolors2 = __toESM(require("picocolors"));
14576
14618
 
@@ -16644,19 +16686,19 @@ function parseFrame(frame, dispatch) {
16644
16686
  }
16645
16687
 
16646
16688
  // src/os/posix.ts
16647
- var fs10 = __toESM(require("fs"));
16648
- var os7 = __toESM(require("os"));
16649
- var path12 = __toESM(require("path"));
16689
+ var fs11 = __toESM(require("fs"));
16690
+ var os8 = __toESM(require("os"));
16691
+ var path13 = __toESM(require("path"));
16650
16692
  var import_node_crypto2 = require("crypto");
16651
16693
 
16652
16694
  // src/os/strategy.ts
16653
- var path10 = __toESM(require("path"));
16695
+ var path11 = __toESM(require("path"));
16654
16696
  function findInPathFor(name, opts) {
16655
- const dirs = (process.env.PATH ?? "").split(path10.delimiter).filter(Boolean);
16697
+ const dirs = (process.env.PATH ?? "").split(path11.delimiter).filter(Boolean);
16656
16698
  const candidates = opts.candidates(name);
16657
16699
  for (const dir of dirs) {
16658
16700
  for (const candidate of candidates) {
16659
- const full = path10.join(dir, candidate);
16701
+ const full = path11.join(dir, candidate);
16660
16702
  try {
16661
16703
  opts.accessSync(full, opts.accessFlag);
16662
16704
  return full;
@@ -16669,9 +16711,9 @@ function findInPathFor(name, opts) {
16669
16711
 
16670
16712
  // src/services/pty/unix.strategy.ts
16671
16713
  var import_child_process7 = require("child_process");
16672
- var fs9 = __toESM(require("fs"));
16673
- var os6 = __toESM(require("os"));
16674
- var path11 = __toESM(require("path"));
16714
+ var fs10 = __toESM(require("fs"));
16715
+ var os7 = __toESM(require("os"));
16716
+ var path12 = __toESM(require("path"));
16675
16717
 
16676
16718
  // src/services/pty/types.ts
16677
16719
  function findInPath(name) {
@@ -16767,8 +16809,8 @@ var UnixPtyStrategy = class {
16767
16809
  }
16768
16810
  const cols = process.stdout.columns || 220;
16769
16811
  const rows = process.stdout.rows || 50;
16770
- this.helperPath = path11.join(os6.tmpdir(), "codeam-pty-helper.py");
16771
- fs9.writeFileSync(this.helperPath, PYTHON_PTY_HELPER, { mode: 420 });
16812
+ this.helperPath = path12.join(os7.tmpdir(), "codeam-pty-helper.py");
16813
+ fs10.writeFileSync(this.helperPath, PYTHON_PTY_HELPER, { mode: 420 });
16772
16814
  this.proc = (0, import_child_process7.spawn)(python, [this.helperPath, cmd, ...args2], {
16773
16815
  stdio: ["pipe", "pipe", "inherit"],
16774
16816
  cwd,
@@ -16936,11 +16978,11 @@ var UnixPtyStrategy = class {
16936
16978
  // src/os/posix.ts
16937
16979
  var PosixOsStrategy = class {
16938
16980
  homeDir() {
16939
- return os7.homedir();
16981
+ return os8.homedir();
16940
16982
  }
16941
16983
  scratchPath(prefix) {
16942
16984
  const tag = `${process.pid}-${(0, import_node_crypto2.randomBytes)(4).toString("hex")}`;
16943
- return path12.join(os7.tmpdir(), `${prefix}-${tag}`);
16985
+ return path13.join(os8.tmpdir(), `${prefix}-${tag}`);
16944
16986
  }
16945
16987
  devNull() {
16946
16988
  return "/dev/null";
@@ -16948,8 +16990,8 @@ var PosixOsStrategy = class {
16948
16990
  findInPath(name) {
16949
16991
  return findInPathFor(name, {
16950
16992
  candidates: () => [name],
16951
- accessFlag: fs10.constants.X_OK,
16952
- accessSync: fs10.accessSync
16993
+ accessFlag: fs11.constants.X_OK,
16994
+ accessSync: fs11.accessSync
16953
16995
  });
16954
16996
  }
16955
16997
  augmentPath(dirs) {
@@ -16994,15 +17036,15 @@ var LinuxOsStrategy = class extends PosixOsStrategy {
16994
17036
  };
16995
17037
 
16996
17038
  // src/os/win32.ts
16997
- var fs11 = __toESM(require("fs"));
16998
- var os8 = __toESM(require("os"));
16999
- var path14 = __toESM(require("path"));
17039
+ var fs12 = __toESM(require("fs"));
17040
+ var os9 = __toESM(require("os"));
17041
+ var path15 = __toESM(require("path"));
17000
17042
  var import_node_crypto3 = require("crypto");
17001
17043
 
17002
17044
  // src/services/pty/windows-conpty.strategy.ts
17003
- var path13 = __toESM(require("path"));
17045
+ var path14 = __toESM(require("path"));
17004
17046
  function loadNodePty2() {
17005
- const vendoredPath = path13.join(__dirname, "vendor", "node-pty");
17047
+ const vendoredPath = path14.join(__dirname, "vendor", "node-pty");
17006
17048
  try {
17007
17049
  return require(vendoredPath);
17008
17050
  } catch (vendorErr) {
@@ -17194,25 +17236,25 @@ var WINDOWS_EXEC_EXTS = [".exe", ".cmd", ".bat", ".ps1"];
17194
17236
  var Win32OsStrategy = class {
17195
17237
  id = "win32";
17196
17238
  homeDir() {
17197
- return os8.homedir();
17239
+ return os9.homedir();
17198
17240
  }
17199
17241
  scratchPath(prefix) {
17200
17242
  const tag = `${process.pid}-${(0, import_node_crypto3.randomBytes)(4).toString("hex")}`;
17201
- return path14.join(os8.tmpdir(), `${prefix}-${tag}`);
17243
+ return path15.join(os9.tmpdir(), `${prefix}-${tag}`);
17202
17244
  }
17203
17245
  devNull() {
17204
17246
  return "NUL";
17205
17247
  }
17206
17248
  findInPath(name) {
17207
- const hasExt = path14.extname(name).length > 0;
17249
+ const hasExt = path15.extname(name).length > 0;
17208
17250
  return findInPathFor(name, {
17209
17251
  candidates: (n) => hasExt ? [n] : [...WINDOWS_EXEC_EXTS.map((ext) => `${n}${ext}`), n],
17210
17252
  // Windows has no Unix execute bit; presence + matching extension
17211
17253
  // IS the executability check. X_OK on Windows is a no-op alias
17212
17254
  // for F_OK at the libuv layer anyway, but F_OK makes intent
17213
17255
  // explicit.
17214
- accessFlag: fs11.constants.F_OK,
17215
- accessSync: fs11.accessSync
17256
+ accessFlag: fs12.constants.F_OK,
17257
+ accessSync: fs12.accessSync
17216
17258
  });
17217
17259
  }
17218
17260
  augmentPath(dirs) {
@@ -17249,7 +17291,7 @@ var Win32OsStrategy = class {
17249
17291
  return `"${escaped.replace(/[&|^<>()%!]/g, "^$&")}"`;
17250
17292
  }
17251
17293
  buildLaunch(binaryPath, extraArgs = []) {
17252
- const ext = path14.extname(binaryPath).toLowerCase();
17294
+ const ext = path15.extname(binaryPath).toLowerCase();
17253
17295
  if (ext === ".cmd" || ext === ".bat") {
17254
17296
  return { cmd: "cmd.exe", args: ["/c", binaryPath, ...extraArgs] };
17255
17297
  }
@@ -17325,20 +17367,20 @@ function buildClaudeLaunch(extraArgs = [], os74 = createOsStrategy()) {
17325
17367
 
17326
17368
  // src/agents/claude/installer.ts
17327
17369
  var import_child_process9 = require("child_process");
17328
- var path15 = __toESM(require("path"));
17329
- var os9 = __toESM(require("os"));
17370
+ var path16 = __toESM(require("path"));
17371
+ var os10 = __toESM(require("os"));
17330
17372
  function probeInstallDirs() {
17331
- const home = os9.homedir();
17373
+ const home = os10.homedir();
17332
17374
  if (process.platform === "win32") {
17333
17375
  return [
17334
- path15.join(home, ".claude", "local"),
17335
- path15.join(home, "AppData", "Local", "AnthropicClaude"),
17336
- path15.join(home, "AppData", "Local", "Programs", "AnthropicClaude")
17376
+ path16.join(home, ".claude", "local"),
17377
+ path16.join(home, "AppData", "Local", "AnthropicClaude"),
17378
+ path16.join(home, "AppData", "Local", "Programs", "AnthropicClaude")
17337
17379
  ];
17338
17380
  }
17339
17381
  return [
17340
- path15.join(home, ".local", "bin"),
17341
- path15.join(home, ".claude", "local"),
17382
+ path16.join(home, ".local", "bin"),
17383
+ path16.join(home, ".claude", "local"),
17342
17384
  "/usr/local/bin"
17343
17385
  ];
17344
17386
  }
@@ -17347,7 +17389,7 @@ function isAvailable() {
17347
17389
  }
17348
17390
  function augmentPath() {
17349
17391
  const dirs = probeInstallDirs();
17350
- const sep8 = path15.delimiter;
17392
+ const sep8 = path16.delimiter;
17351
17393
  const current2 = process.env.PATH ?? "";
17352
17394
  const existing = new Set(current2.split(sep8).filter(Boolean));
17353
17395
  const additions = dirs.filter((d3) => !existing.has(d3));
@@ -17438,9 +17480,9 @@ var import_node_child_process3 = require("child_process");
17438
17480
 
17439
17481
  // src/agents/claude/local-token.ts
17440
17482
  var import_node_child_process2 = require("child_process");
17441
- var fs12 = __toESM(require("fs"));
17442
- var os10 = __toESM(require("os"));
17443
- var path16 = __toESM(require("path"));
17483
+ var fs13 = __toESM(require("fs"));
17484
+ var os11 = __toESM(require("os"));
17485
+ var path17 = __toESM(require("path"));
17444
17486
  var import_node_util4 = require("util");
17445
17487
  var execFileP2 = (0, import_node_util4.promisify)(import_node_child_process2.execFile);
17446
17488
  var KEYCHAIN_SERVICE_NAMES = [
@@ -17450,17 +17492,17 @@ var KEYCHAIN_SERVICE_NAMES = [
17450
17492
  "Anthropic Claude"
17451
17493
  ];
17452
17494
  function claudeCredentialsPaths() {
17453
- const home = os10.homedir();
17495
+ const home = os11.homedir();
17454
17496
  return [
17455
- path16.join(home, ".claude", ".credentials.json"),
17456
- path16.join(home, ".config", "claude", ".credentials.json")
17497
+ path17.join(home, ".claude", ".credentials.json"),
17498
+ path17.join(home, ".config", "claude", ".credentials.json")
17457
17499
  ];
17458
17500
  }
17459
17501
  async function extractLocalClaudeToken() {
17460
17502
  const agentState = readClaudeAgentState();
17461
17503
  for (const flat of claudeCredentialsPaths()) {
17462
- if (!fs12.existsSync(flat)) continue;
17463
- const credential = fs12.readFileSync(flat, "utf8").trim();
17504
+ if (!fs13.existsSync(flat)) continue;
17505
+ const credential = fs13.readFileSync(flat, "utf8").trim();
17464
17506
  if (credential.length > 0) {
17465
17507
  return { method: "oauth", credential, source: "flat-file", agentState };
17466
17508
  }
@@ -17485,10 +17527,10 @@ async function extractLocalClaudeToken() {
17485
17527
  }
17486
17528
  function readClaudeAgentState() {
17487
17529
  const STATE_MAX_BYTES = 256 * 1024;
17488
- const candidate = path16.join(os10.homedir(), ".claude.json");
17530
+ const candidate = path17.join(os11.homedir(), ".claude.json");
17489
17531
  try {
17490
- if (!fs12.existsSync(candidate)) return void 0;
17491
- const buf = fs12.readFileSync(candidate);
17532
+ if (!fs13.existsSync(candidate)) return void 0;
17533
+ const buf = fs13.readFileSync(candidate);
17492
17534
  if (buf.length === 0 || buf.length > STATE_MAX_BYTES) return void 0;
17493
17535
  const text = buf.toString("utf8").trim();
17494
17536
  return text.length > 0 ? text : void 0;
@@ -17577,9 +17619,9 @@ function claudeLoginLauncher() {
17577
17619
  }
17578
17620
 
17579
17621
  // src/agents/claude/quota.ts
17580
- var fs13 = __toESM(require("fs"));
17581
- var os11 = __toESM(require("os"));
17582
- var path17 = __toESM(require("path"));
17622
+ var fs14 = __toESM(require("fs"));
17623
+ var os12 = __toESM(require("os"));
17624
+ var path18 = __toESM(require("path"));
17583
17625
  var import_child_process10 = require("child_process");
17584
17626
  var HELPER_SCRIPT = `import os,pty,sys,select,signal,struct,fcntl,termios,errno
17585
17627
  m,s=pty.openpty()
@@ -17642,8 +17684,8 @@ async function fetchClaudeQuota() {
17642
17684
  resolve13(null);
17643
17685
  return;
17644
17686
  }
17645
- const helperPath = path17.join(os11.tmpdir(), "codeam-quota-helper.py");
17646
- fs13.writeFileSync(helperPath, HELPER_SCRIPT, { mode: 420 });
17687
+ const helperPath = path18.join(os12.tmpdir(), "codeam-quota-helper.py");
17688
+ fs14.writeFileSync(helperPath, HELPER_SCRIPT, { mode: 420 });
17647
17689
  const python = findInPath("python3") ?? findInPath("python");
17648
17690
  if (!python) {
17649
17691
  resolve13(null);
@@ -17670,7 +17712,7 @@ async function fetchClaudeQuota() {
17670
17712
  } catch {
17671
17713
  }
17672
17714
  try {
17673
- fs13.unlinkSync(helperPath);
17715
+ fs14.unlinkSync(helperPath);
17674
17716
  } catch {
17675
17717
  }
17676
17718
  resolve13(result);
@@ -17805,37 +17847,37 @@ function readOneShotConversations(cwd, homeDir2) {
17805
17847
  }
17806
17848
 
17807
17849
  // src/agents/claude/history.ts
17808
- var fs15 = __toESM(require("fs"));
17850
+ var fs16 = __toESM(require("fs"));
17809
17851
 
17810
17852
  // src/agents/claude-memory-file.ts
17811
- var os13 = __toESM(require("os"));
17812
- var path19 = __toESM(require("path"));
17853
+ var os14 = __toESM(require("os"));
17854
+ var path20 = __toESM(require("path"));
17813
17855
  function claudeMemoryFile(homeDir2, env = process.env) {
17814
- if (homeDir2) return path19.join(homeDir2, ".claude", "CLAUDE.md");
17815
- return path19.join(claudeConfigDir(env), "CLAUDE.md");
17856
+ if (homeDir2) return path20.join(homeDir2, ".claude", "CLAUDE.md");
17857
+ return path20.join(claudeConfigDir(env), "CLAUDE.md");
17816
17858
  }
17817
17859
  function claudeConfigDir(env = currentAgentEnv()) {
17818
17860
  const configDir = env.CLAUDE_CONFIG_DIR?.trim();
17819
- return configDir ? configDir : path19.join(os13.homedir(), ".claude");
17861
+ return configDir ? configDir : path20.join(os14.homedir(), ".claude");
17820
17862
  }
17821
17863
 
17822
17864
  // src/agents/claude/history.ts
17823
- var path20 = __toESM(require("path"));
17865
+ var path21 = __toESM(require("path"));
17824
17866
  function encodeCwd(cwd) {
17825
17867
  return cwd.replace(/[\\/:_.]/g, "-");
17826
17868
  }
17827
17869
  function resolveHistoryDir(cwd, projectsRoot) {
17828
- const root = projectsRoot ?? path20.join(claudeConfigDir(), "projects");
17829
- const primary = path20.join(root, encodeCwd(cwd));
17830
- if (fs15.existsSync(primary)) return primary;
17870
+ const root = projectsRoot ?? path21.join(claudeConfigDir(), "projects");
17871
+ const primary = path21.join(root, encodeCwd(cwd));
17872
+ if (fs16.existsSync(primary)) return primary;
17831
17873
  try {
17832
- const entries2 = fs15.readdirSync(root, { withFileTypes: true });
17874
+ const entries2 = fs16.readdirSync(root, { withFileTypes: true });
17833
17875
  const wanted = encodeCwd(cwd);
17834
17876
  for (const e of entries2) {
17835
17877
  if (!e.isDirectory()) continue;
17836
17878
  const candidate = e.name.replace(/-+/g, "-");
17837
17879
  if (candidate === wanted.replace(/-+/g, "-")) {
17838
- return path20.join(root, e.name);
17880
+ return path21.join(root, e.name);
17839
17881
  }
17840
17882
  }
17841
17883
  } catch {
@@ -17845,31 +17887,31 @@ function resolveHistoryDir(cwd, projectsRoot) {
17845
17887
  function resolveHistoryFile(cwd, sessionId, projectsRoot) {
17846
17888
  const dir = resolveHistoryDir(cwd, projectsRoot);
17847
17889
  if (!dir) return null;
17848
- const filePath = path20.join(dir, `${sessionId}.jsonl`);
17849
- return fs15.existsSync(filePath) ? filePath : null;
17890
+ const filePath = path21.join(dir, `${sessionId}.jsonl`);
17891
+ return fs16.existsSync(filePath) ? filePath : null;
17850
17892
  }
17851
17893
  function getCurrentUsage(historyDir, bootTimeMs = 0) {
17852
17894
  const GRACE_MS = 5e3;
17853
17895
  const cutoff = bootTimeMs > 0 ? bootTimeMs - GRACE_MS : 0;
17854
17896
  let entries2;
17855
17897
  try {
17856
- entries2 = fs15.readdirSync(historyDir, { withFileTypes: true });
17898
+ entries2 = fs16.readdirSync(historyDir, { withFileTypes: true });
17857
17899
  } catch {
17858
17900
  return null;
17859
17901
  }
17860
17902
  const files = entries2.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
17861
17903
  try {
17862
- const stat3 = fs15.statSync(path20.join(historyDir, e.name));
17904
+ const stat3 = fs16.statSync(path21.join(historyDir, e.name));
17863
17905
  return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
17864
17906
  } catch {
17865
17907
  return { name: e.name, mtime: 0, birthtime: 0 };
17866
17908
  }
17867
17909
  }).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
17868
17910
  if (files.length === 0) return null;
17869
- const filePath = path20.join(historyDir, files[0].name);
17911
+ const filePath = path21.join(historyDir, files[0].name);
17870
17912
  let raw;
17871
17913
  try {
17872
- raw = fs15.readFileSync(filePath, "utf8");
17914
+ raw = fs16.readFileSync(filePath, "utf8");
17873
17915
  } catch {
17874
17916
  return null;
17875
17917
  }
@@ -17937,7 +17979,7 @@ function parseHistoryFile(filePath) {
17937
17979
  const exitPlanIds = /* @__PURE__ */ new Set();
17938
17980
  let raw;
17939
17981
  try {
17940
- raw = fs15.readFileSync(filePath, "utf8");
17982
+ raw = fs16.readFileSync(filePath, "utf8");
17941
17983
  } catch {
17942
17984
  return out2;
17943
17985
  }
@@ -17983,7 +18025,7 @@ function listResumableSessions(cwd) {
17983
18025
  if (!dir) return [];
17984
18026
  let entries2;
17985
18027
  try {
17986
- entries2 = fs15.readdirSync(dir, { withFileTypes: true });
18028
+ entries2 = fs16.readdirSync(dir, { withFileTypes: true });
17987
18029
  } catch {
17988
18030
  return [];
17989
18031
  }
@@ -17991,15 +18033,15 @@ function listResumableSessions(cwd) {
17991
18033
  for (const entry of entries2) {
17992
18034
  if (!entry.isFile() || !entry.name.endsWith(".jsonl")) continue;
17993
18035
  const id = entry.name.slice(0, -".jsonl".length);
17994
- const filePath = path20.join(dir, entry.name);
18036
+ const filePath = path21.join(dir, entry.name);
17995
18037
  let timestamp = Date.now();
17996
18038
  try {
17997
- timestamp = fs15.statSync(filePath).mtimeMs;
18039
+ timestamp = fs16.statSync(filePath).mtimeMs;
17998
18040
  } catch {
17999
18041
  }
18000
18042
  let summary = "";
18001
18043
  try {
18002
- const raw = fs15.readFileSync(filePath, "utf8");
18044
+ const raw = fs16.readFileSync(filePath, "utf8");
18003
18045
  for (const line of raw.split("\n")) {
18004
18046
  if (!line.trim()) continue;
18005
18047
  try {
@@ -18030,19 +18072,19 @@ var SWITCH_PROBE_BYTES = 256 * 1024;
18030
18072
  function isClearedConversationFile(filePath) {
18031
18073
  let fd;
18032
18074
  try {
18033
- fd = fs15.openSync(filePath, "r");
18075
+ fd = fs16.openSync(filePath, "r");
18034
18076
  } catch {
18035
18077
  return false;
18036
18078
  }
18037
18079
  let raw;
18038
18080
  try {
18039
18081
  const buf = Buffer.alloc(SWITCH_PROBE_BYTES);
18040
- const n = fs15.readSync(fd, buf, 0, SWITCH_PROBE_BYTES, 0);
18082
+ const n = fs16.readSync(fd, buf, 0, SWITCH_PROBE_BYTES, 0);
18041
18083
  raw = buf.toString("utf8", 0, n);
18042
18084
  } catch {
18043
18085
  return false;
18044
18086
  } finally {
18045
- fs15.closeSync(fd);
18087
+ fs16.closeSync(fd);
18046
18088
  }
18047
18089
  if (!raw.includes(CLEAR_COMMAND_ECHO) && !raw.includes("SessionStart:clear")) return false;
18048
18090
  for (const line of raw.split("\n")) {
@@ -18069,16 +18111,16 @@ function isClearedConversationFile(filePath) {
18069
18111
  function appendedTailHasResumeMarker(filePath, fromOffset) {
18070
18112
  let fd;
18071
18113
  try {
18072
- fd = fs15.openSync(filePath, "r");
18114
+ fd = fs16.openSync(filePath, "r");
18073
18115
  } catch {
18074
18116
  return false;
18075
18117
  }
18076
18118
  try {
18077
- const size = fs15.fstatSync(fd).size;
18119
+ const size = fs16.fstatSync(fd).size;
18078
18120
  const len = Math.min(Math.max(size - fromOffset, 0), SWITCH_PROBE_BYTES);
18079
18121
  if (len <= 0) return false;
18080
18122
  const buf = Buffer.alloc(len);
18081
- const n = fs15.readSync(fd, buf, 0, len, fromOffset);
18123
+ const n = fs16.readSync(fd, buf, 0, len, fromOffset);
18082
18124
  const raw = buf.toString("utf8", 0, n);
18083
18125
  if (!raw.includes('"last-prompt"')) return false;
18084
18126
  for (const line of raw.split("\n")) {
@@ -18092,11 +18134,11 @@ function appendedTailHasResumeMarker(filePath, fromOffset) {
18092
18134
  } catch {
18093
18135
  return false;
18094
18136
  } finally {
18095
- fs15.closeSync(fd);
18137
+ fs16.closeSync(fd);
18096
18138
  }
18097
18139
  }
18098
18140
  function watchConversationSwitch(cwd, opts, onSwitch, projectsRoot) {
18099
- const root = projectsRoot ?? path20.join(claudeConfigDir(), "projects");
18141
+ const root = projectsRoot ?? path21.join(claudeConfigDir(), "projects");
18100
18142
  let currentId = opts.currentId;
18101
18143
  const baseline = /* @__PURE__ */ new Map();
18102
18144
  const unclassified = /* @__PURE__ */ new Map();
@@ -18105,13 +18147,13 @@ function watchConversationSwitch(cwd, opts, onSwitch, projectsRoot) {
18105
18147
  let closed = false;
18106
18148
  const fileSize = (file) => {
18107
18149
  try {
18108
- return fs15.statSync(file).size;
18150
+ return fs16.statSync(file).size;
18109
18151
  } catch {
18110
18152
  return null;
18111
18153
  }
18112
18154
  };
18113
18155
  const switchTo = (dir, id, kind) => {
18114
- const leaving = fileSize(path20.join(dir, `${currentId}.jsonl`));
18156
+ const leaving = fileSize(path21.join(dir, `${currentId}.jsonl`));
18115
18157
  if (leaving !== null) baseline.set(currentId, leaving);
18116
18158
  baseline.delete(id);
18117
18159
  unclassified.delete(id);
@@ -18122,7 +18164,7 @@ function watchConversationSwitch(cwd, opts, onSwitch, projectsRoot) {
18122
18164
  if (closed) return;
18123
18165
  let entries2;
18124
18166
  try {
18125
- entries2 = fs15.readdirSync(dir);
18167
+ entries2 = fs16.readdirSync(dir);
18126
18168
  } catch {
18127
18169
  return;
18128
18170
  }
@@ -18130,7 +18172,7 @@ function watchConversationSwitch(cwd, opts, onSwitch, projectsRoot) {
18130
18172
  if (!name.endsWith(".jsonl")) continue;
18131
18173
  const id = name.slice(0, -".jsonl".length);
18132
18174
  if (id === currentId) continue;
18133
- const file = path20.join(dir, name);
18175
+ const file = path21.join(dir, name);
18134
18176
  const size = fileSize(file);
18135
18177
  if (size === null) continue;
18136
18178
  const known = baseline.get(id);
@@ -18156,18 +18198,18 @@ function watchConversationSwitch(cwd, opts, onSwitch, projectsRoot) {
18156
18198
  rootWatcher = null;
18157
18199
  if (initial) {
18158
18200
  try {
18159
- for (const name of fs15.readdirSync(dir)) {
18201
+ for (const name of fs16.readdirSync(dir)) {
18160
18202
  if (!name.endsWith(".jsonl")) continue;
18161
18203
  const id = name.slice(0, -".jsonl".length);
18162
18204
  if (id === currentId) continue;
18163
- const size = fileSize(path20.join(dir, name));
18205
+ const size = fileSize(path21.join(dir, name));
18164
18206
  if (size !== null) baseline.set(id, size);
18165
18207
  }
18166
18208
  } catch {
18167
18209
  }
18168
18210
  }
18169
18211
  try {
18170
- dirWatcher = fs15.watch(dir, { persistent: false }, () => scan(dir));
18212
+ dirWatcher = fs16.watch(dir, { persistent: false }, () => scan(dir));
18171
18213
  } catch {
18172
18214
  return false;
18173
18215
  }
@@ -18176,8 +18218,8 @@ function watchConversationSwitch(cwd, opts, onSwitch, projectsRoot) {
18176
18218
  };
18177
18219
  if (!attachDir(true)) {
18178
18220
  try {
18179
- fs15.mkdirSync(root, { recursive: true });
18180
- rootWatcher = fs15.watch(root, { persistent: false }, () => {
18221
+ fs16.mkdirSync(root, { recursive: true });
18222
+ rootWatcher = fs16.watch(root, { persistent: false }, () => {
18181
18223
  if (!closed && !dirWatcher) attachDir(false);
18182
18224
  });
18183
18225
  } catch {
@@ -18352,24 +18394,24 @@ var ClaudeRuntimeStrategy = class {
18352
18394
  };
18353
18395
 
18354
18396
  // src/agents/claude/deploy.ts
18355
- var fs17 = __toESM(require("fs"));
18356
- var os15 = __toESM(require("os"));
18357
- var path22 = __toESM(require("path"));
18397
+ var fs18 = __toESM(require("fs"));
18398
+ var os16 = __toESM(require("os"));
18399
+ var path23 = __toESM(require("path"));
18358
18400
 
18359
18401
  // src/agents/claude/credentials.ts
18360
18402
  var import_child_process12 = require("child_process");
18361
- var fs16 = __toESM(require("fs"));
18362
- var os14 = __toESM(require("os"));
18363
- var path21 = __toESM(require("path"));
18403
+ var fs17 = __toESM(require("fs"));
18404
+ var os15 = __toESM(require("os"));
18405
+ var path22 = __toESM(require("path"));
18364
18406
  var import_util2 = require("util");
18365
18407
  var execFileP3 = (0, import_util2.promisify)(import_child_process12.execFile);
18366
18408
  async function detectLocalClaudeCredentials() {
18367
- const localClaudeDir = path21.join(os14.homedir(), ".claude");
18368
- const flat = path21.join(localClaudeDir, ".credentials.json");
18369
- if (fs16.existsSync(flat)) {
18409
+ const localClaudeDir = path22.join(os15.homedir(), ".claude");
18410
+ const flat = path22.join(localClaudeDir, ".credentials.json");
18411
+ if (fs17.existsSync(flat)) {
18370
18412
  return { source: "flat-file", description: "~/.claude/.credentials.json" };
18371
18413
  }
18372
- if (os14.platform() === "darwin") {
18414
+ if (os15.platform() === "darwin") {
18373
18415
  try {
18374
18416
  await execFileP3(
18375
18417
  "security",
@@ -18384,9 +18426,9 @@ async function detectLocalClaudeCredentials() {
18384
18426
  return { source: "none", description: "" };
18385
18427
  }
18386
18428
  async function bridgeClaudeCredentials(provider, workspaceId) {
18387
- const localClaudeDir = path21.join(os14.homedir(), ".claude");
18388
- const fileBased = path21.join(localClaudeDir, ".credentials.json");
18389
- if (fs16.existsSync(fileBased)) {
18429
+ const localClaudeDir = path22.join(os15.homedir(), ".claude");
18430
+ const fileBased = path22.join(localClaudeDir, ".credentials.json");
18431
+ if (fs17.existsSync(fileBased)) {
18390
18432
  return { source: "flat-file", description: "~/.claude/.credentials.json" };
18391
18433
  }
18392
18434
  if (process.platform === "darwin") {
@@ -18478,8 +18520,8 @@ var ClaudeDeployStrategy = class {
18478
18520
  process.exit(1);
18479
18521
  }
18480
18522
  claudeStep.stop("\u2713 Claude CLI installed");
18481
- const localClaudeDir = path22.join(os15.homedir(), ".claude");
18482
- const haveLocalClaude = fs17.existsSync(localClaudeDir) && fs17.statSync(localClaudeDir).isDirectory();
18523
+ const localClaudeDir = path23.join(os16.homedir(), ".claude");
18524
+ const haveLocalClaude = fs18.existsSync(localClaudeDir) && fs18.statSync(localClaudeDir).isDirectory();
18483
18525
  if (haveLocalClaude) {
18484
18526
  const copyStep = fe();
18485
18527
  copyStep.start("Copying local Claude config to workspace\u2026");
@@ -18533,10 +18575,10 @@ var ClaudeDeployStrategy = class {
18533
18575
  }
18534
18576
  }
18535
18577
  if (opts.bridged !== "none") {
18536
- const localClaudeJson = path22.join(os15.homedir(), ".claude.json");
18537
- if (fs17.existsSync(localClaudeJson)) {
18578
+ const localClaudeJson = path23.join(os16.homedir(), ".claude.json");
18579
+ if (fs18.existsSync(localClaudeJson)) {
18538
18580
  try {
18539
- const contents = fs17.readFileSync(localClaudeJson);
18581
+ const contents = fs18.readFileSync(localClaudeJson);
18540
18582
  await provider.uploadFile(
18541
18583
  workspaceId,
18542
18584
  "/home/codespace/.claude.json",
@@ -18569,7 +18611,7 @@ var ClaudeDeployStrategy = class {
18569
18611
 
18570
18612
  // src/agents/codex/runtime.ts
18571
18613
  var import_node_child_process5 = require("child_process");
18572
- var path26 = __toESM(require("path"));
18614
+ var path27 = __toESM(require("path"));
18573
18615
 
18574
18616
  // src/agents/codex/history.ts
18575
18617
  var import_node_fs4 = __toESM(require("fs"));
@@ -18577,9 +18619,9 @@ var import_node_path4 = __toESM(require("path"));
18577
18619
  var import_node_os2 = __toESM(require("os"));
18578
18620
 
18579
18621
  // src/agents/acp/squad-roster.ts
18580
- var fs18 = __toESM(require("fs"));
18581
- var os16 = __toESM(require("os"));
18582
- var path23 = __toESM(require("path"));
18622
+ var fs19 = __toESM(require("fs"));
18623
+ var os17 = __toESM(require("os"));
18624
+ var path24 = __toESM(require("path"));
18583
18625
  var PROMPT_MAX = 500;
18584
18626
  var REPLY_SUMMARY_MAX = 1e3;
18585
18627
  var PREAMBLE_MAX = 2e3;
@@ -18598,11 +18640,11 @@ function defaultMember() {
18598
18640
  };
18599
18641
  }
18600
18642
  function journalPathFor(homeDir2, sessionId) {
18601
- return path23.join(homeDir2, ".codeam", `squad-journal-${sessionId}.json`);
18643
+ return path24.join(homeDir2, ".codeam", `squad-journal-${sessionId}.json`);
18602
18644
  }
18603
18645
  function loadJournal(journalPath) {
18604
18646
  try {
18605
- const raw = JSON.parse(fs18.readFileSync(journalPath, "utf-8"));
18647
+ const raw = JSON.parse(fs19.readFileSync(journalPath, "utf-8"));
18606
18648
  return Array.isArray(raw.turns) ? raw.turns : [];
18607
18649
  } catch {
18608
18650
  return [];
@@ -18630,7 +18672,7 @@ var SquadState = class {
18630
18672
  turns;
18631
18673
  members = /* @__PURE__ */ new Map();
18632
18674
  constructor(opts) {
18633
- this.journalPath = journalPathFor(opts.homeDir ?? os16.homedir(), opts.sessionId);
18675
+ this.journalPath = journalPathFor(opts.homeDir ?? os17.homedir(), opts.sessionId);
18634
18676
  this.turns = loadJournal(this.journalPath);
18635
18677
  if (opts.auto) this.setAuto(opts.auto);
18636
18678
  }
@@ -18717,8 +18759,8 @@ var SquadState = class {
18717
18759
  }
18718
18760
  persist() {
18719
18761
  try {
18720
- fs18.mkdirSync(path23.dirname(this.journalPath), { recursive: true, mode: 448 });
18721
- fs18.writeFileSync(this.journalPath, JSON.stringify({ turns: this.turns }), { mode: 384 });
18762
+ fs19.mkdirSync(path24.dirname(this.journalPath), { recursive: true, mode: 448 });
18763
+ fs19.writeFileSync(this.journalPath, JSON.stringify({ turns: this.turns }), { mode: 384 });
18722
18764
  } catch {
18723
18765
  }
18724
18766
  }
@@ -19234,16 +19276,16 @@ function getCurrentUsage2(historyDir) {
19234
19276
  var import_node_child_process4 = require("child_process");
19235
19277
 
19236
19278
  // src/agents/codex/local-token.ts
19237
- var fs20 = __toESM(require("fs"));
19238
- var os18 = __toESM(require("os"));
19239
- var path25 = __toESM(require("path"));
19279
+ var fs21 = __toESM(require("fs"));
19280
+ var os19 = __toESM(require("os"));
19281
+ var path26 = __toESM(require("path"));
19240
19282
  function codexCredentialsPath() {
19241
- return path25.join(os18.homedir(), ".codex", "auth.json");
19283
+ return path26.join(os19.homedir(), ".codex", "auth.json");
19242
19284
  }
19243
19285
  async function extractLocalCodexToken() {
19244
19286
  const file = codexCredentialsPath();
19245
- if (!fs20.existsSync(file)) return null;
19246
- const credential = fs20.readFileSync(file, "utf8").trim();
19287
+ if (!fs21.existsSync(file)) return null;
19288
+ const credential = fs21.readFileSync(file, "utf8").trim();
19247
19289
  if (credential.length === 0) return null;
19248
19290
  return { method: "oauth", credential, source: "flat-file" };
19249
19291
  }
@@ -19484,7 +19526,7 @@ function augmentNpmGlobalBin(os74) {
19484
19526
  if (result.status !== 0) return;
19485
19527
  const prefix = result.stdout.toString().trim();
19486
19528
  if (!prefix) return;
19487
- const binDir = os74.id === "win32" ? prefix : path26.join(prefix, "bin");
19529
+ const binDir = os74.id === "win32" ? prefix : path27.join(prefix, "bin");
19488
19530
  os74.augmentPath([binDir]);
19489
19531
  } catch {
19490
19532
  }
@@ -19569,7 +19611,7 @@ var import_node_child_process9 = require("child_process");
19569
19611
  // src/agents/coderabbit/installer.ts
19570
19612
  var import_node_child_process7 = require("child_process");
19571
19613
  var import_node_fs6 = require("fs");
19572
- var path28 = __toESM(require("path"));
19614
+ var path29 = __toESM(require("path"));
19573
19615
 
19574
19616
  // src/commands/host/os-packages.ts
19575
19617
  var import_node_child_process6 = require("child_process");
@@ -19683,7 +19725,7 @@ function writeUnzipShim(os74, runner) {
19683
19725
  const python = ["python3", "python"].find((p2) => runner.which(p2));
19684
19726
  if (!python) return null;
19685
19727
  const dir = os74.scratchPath("codeam-cr-prereq");
19686
- const shim = path28.join(dir, "unzip");
19728
+ const shim = path29.join(dir, "unzip");
19687
19729
  const script = `#!/bin/sh
19688
19730
  set -e
19689
19731
  archive=""
@@ -19833,9 +19875,9 @@ async function ensureCoderabbitInstalled(os74, deps = {}) {
19833
19875
 
19834
19876
  // src/agents/coderabbit/link.ts
19835
19877
  var import_node_child_process8 = require("child_process");
19836
- var fs22 = __toESM(require("fs"));
19837
- var os20 = __toESM(require("os"));
19838
- var path29 = __toESM(require("path"));
19878
+ var fs23 = __toESM(require("fs"));
19879
+ var os21 = __toESM(require("os"));
19880
+ var path30 = __toESM(require("path"));
19839
19881
 
19840
19882
  // src/agents/strategy.ts
19841
19883
  function validateNonEmptyCredential(token) {
@@ -19844,12 +19886,12 @@ function validateNonEmptyCredential(token) {
19844
19886
 
19845
19887
  // src/agents/coderabbit/link.ts
19846
19888
  function authPath() {
19847
- return path29.join(os20.homedir(), ".coderabbit", "auth.json");
19889
+ return path30.join(os21.homedir(), ".coderabbit", "auth.json");
19848
19890
  }
19849
19891
  async function extractLocalCoderabbitToken() {
19850
19892
  const file = authPath();
19851
- if (!fs22.existsSync(file)) return null;
19852
- const credential = fs22.readFileSync(file, "utf8").trim();
19893
+ if (!fs23.existsSync(file)) return null;
19894
+ const credential = fs23.readFileSync(file, "utf8").trim();
19853
19895
  if (credential.length === 0) return null;
19854
19896
  return { method: "oauth", credential, source: "flat-file" };
19855
19897
  }
@@ -20193,39 +20235,39 @@ CodeRabbit review timed out after ${Math.round(
20193
20235
  };
20194
20236
 
20195
20237
  // src/agents/cursor/history.ts
20196
- var fs23 = __toESM(require("fs"));
20197
- var os21 = __toESM(require("os"));
20198
- var path30 = __toESM(require("path"));
20238
+ var fs24 = __toESM(require("fs"));
20239
+ var os22 = __toESM(require("os"));
20240
+ var path31 = __toESM(require("path"));
20199
20241
  var import_node_crypto6 = require("crypto");
20200
- var HISTORY_ROOT = path30.join(os21.homedir(), ".cursor", "projects");
20201
- var CURSOR_HOME = path30.join(os21.homedir(), ".cursor");
20242
+ var HISTORY_ROOT = path31.join(os22.homedir(), ".cursor", "projects");
20243
+ var CURSOR_HOME = path31.join(os22.homedir(), ".cursor");
20202
20244
  var STORE_FILES = ["store.db", "store.db-wal", "store.db-shm"];
20203
20245
  function acpSessionDir(sessionId) {
20204
- return path30.join(CURSOR_HOME, "acp-sessions", sessionId);
20246
+ return path31.join(CURSOR_HOME, "acp-sessions", sessionId);
20205
20247
  }
20206
20248
  function nativeStoreDir(cwd, sessionId) {
20207
- const chatsRoot = path30.join(CURSOR_HOME, "chats");
20249
+ const chatsRoot = path31.join(CURSOR_HOME, "chats");
20208
20250
  let buckets = [];
20209
20251
  try {
20210
- buckets = fs23.readdirSync(chatsRoot);
20252
+ buckets = fs24.readdirSync(chatsRoot);
20211
20253
  } catch {
20212
20254
  }
20213
20255
  for (const b of buckets) {
20214
- const candidate = path30.join(chatsRoot, b, sessionId);
20215
- if (fs23.existsSync(path30.join(candidate, "store.db"))) return candidate;
20256
+ const candidate = path31.join(chatsRoot, b, sessionId);
20257
+ if (fs24.existsSync(path31.join(candidate, "store.db"))) return candidate;
20216
20258
  }
20217
- const computed = path30.join(chatsRoot, (0, import_node_crypto6.createHash)("md5").update(cwd).digest("hex"), sessionId);
20218
- return fs23.existsSync(computed) ? computed : null;
20259
+ const computed = path31.join(chatsRoot, (0, import_node_crypto6.createHash)("md5").update(cwd).digest("hex"), sessionId);
20260
+ return fs24.existsSync(computed) ? computed : null;
20219
20261
  }
20220
20262
  function copyStoreFiles(srcDir, dstDir) {
20221
- fs23.mkdirSync(dstDir, { recursive: true });
20263
+ fs24.mkdirSync(dstDir, { recursive: true });
20222
20264
  for (const f of STORE_FILES) {
20223
- const dst = path30.join(dstDir, f);
20224
- if (fs23.existsSync(dst)) fs23.rmSync(dst, { force: true });
20265
+ const dst = path31.join(dstDir, f);
20266
+ if (fs24.existsSync(dst)) fs24.rmSync(dst, { force: true });
20225
20267
  }
20226
20268
  for (const f of STORE_FILES) {
20227
- const src = path30.join(srcDir, f);
20228
- if (fs23.existsSync(src)) fs23.copyFileSync(src, path30.join(dstDir, f));
20269
+ const src = path31.join(srcDir, f);
20270
+ if (fs24.existsSync(src)) fs24.copyFileSync(src, path31.join(dstDir, f));
20229
20271
  }
20230
20272
  }
20231
20273
  function bridgeNativeToAcp(cwd, sessionId) {
@@ -20237,8 +20279,8 @@ function bridgeNativeToAcp(cwd, sessionId) {
20237
20279
  }
20238
20280
  const dst = acpSessionDir(sessionId);
20239
20281
  copyStoreFiles(src, dst);
20240
- fs23.writeFileSync(
20241
- path30.join(dst, "meta.json"),
20282
+ fs24.writeFileSync(
20283
+ path31.join(dst, "meta.json"),
20242
20284
  JSON.stringify({ schemaVersion: 1, cwd })
20243
20285
  );
20244
20286
  log.info("cursor", `baton bridge native\u2192acp ok (${sessionId.slice(0, 8)})`);
@@ -20249,11 +20291,11 @@ function bridgeNativeToAcp(cwd, sessionId) {
20249
20291
  function bridgeAcpToNative(cwd, sessionId) {
20250
20292
  try {
20251
20293
  const src = acpSessionDir(sessionId);
20252
- if (!fs23.existsSync(path30.join(src, "store.db"))) {
20294
+ if (!fs24.existsSync(path31.join(src, "store.db"))) {
20253
20295
  log.warn("cursor", `baton bridge: no acp store for ${sessionId.slice(0, 8)} \u2014 skip`);
20254
20296
  return;
20255
20297
  }
20256
- const dst = nativeStoreDir(cwd, sessionId) ?? path30.join(CURSOR_HOME, "chats", (0, import_node_crypto6.createHash)("md5").update(cwd).digest("hex"), sessionId);
20298
+ const dst = nativeStoreDir(cwd, sessionId) ?? path31.join(CURSOR_HOME, "chats", (0, import_node_crypto6.createHash)("md5").update(cwd).digest("hex"), sessionId);
20257
20299
  copyStoreFiles(src, dst);
20258
20300
  log.info("cursor", `baton bridge acp\u2192native ok (${sessionId.slice(0, 8)})`);
20259
20301
  } catch (err) {
@@ -20264,26 +20306,26 @@ function encodeCursorCwd(cwd) {
20264
20306
  return cwd.replace(/^[/\\]+/, "").replace(/[/\\:]/g, "-");
20265
20307
  }
20266
20308
  function resolveHistoryFile3(cwd, sessionId, root = HISTORY_ROOT) {
20267
- const rel = path30.join("agent-transcripts", sessionId, `${sessionId}.jsonl`);
20268
- const primary = path30.join(root, encodeCursorCwd(cwd), rel);
20269
- if (fs23.existsSync(primary)) return primary;
20309
+ const rel = path31.join("agent-transcripts", sessionId, `${sessionId}.jsonl`);
20310
+ const primary = path31.join(root, encodeCursorCwd(cwd), rel);
20311
+ if (fs24.existsSync(primary)) return primary;
20270
20312
  let entries2;
20271
20313
  try {
20272
- entries2 = fs23.readdirSync(root, { withFileTypes: true });
20314
+ entries2 = fs24.readdirSync(root, { withFileTypes: true });
20273
20315
  } catch {
20274
20316
  return null;
20275
20317
  }
20276
20318
  for (const e of entries2) {
20277
20319
  if (!e.isDirectory()) continue;
20278
- const candidate = path30.join(root, e.name, rel);
20279
- if (fs23.existsSync(candidate)) return candidate;
20320
+ const candidate = path31.join(root, e.name, rel);
20321
+ if (fs24.existsSync(candidate)) return candidate;
20280
20322
  }
20281
20323
  return null;
20282
20324
  }
20283
20325
  function resolveHistoryDir3(cwd) {
20284
- if (!fs23.existsSync(HISTORY_ROOT)) return null;
20285
- const dir = path30.join(HISTORY_ROOT, encodeCursorCwd(cwd));
20286
- return fs23.existsSync(dir) ? dir : null;
20326
+ if (!fs24.existsSync(HISTORY_ROOT)) return null;
20327
+ const dir = path31.join(HISTORY_ROOT, encodeCursorCwd(cwd));
20328
+ return fs24.existsSync(dir) ? dir : null;
20287
20329
  }
20288
20330
  function extractText2(content) {
20289
20331
  if (!Array.isArray(content)) return "";
@@ -20296,7 +20338,7 @@ function unwrapUserQuery(text) {
20296
20338
  function parseHistoryFile3(filePath) {
20297
20339
  let raw;
20298
20340
  try {
20299
- raw = fs23.readFileSync(filePath, "utf8");
20341
+ raw = fs24.readFileSync(filePath, "utf8");
20300
20342
  } catch {
20301
20343
  return [];
20302
20344
  }
@@ -20334,16 +20376,16 @@ function getCurrentUsage3(_historyDir) {
20334
20376
  var import_node_child_process10 = require("child_process");
20335
20377
 
20336
20378
  // src/agents/cursor/local-token.ts
20337
- var fs24 = __toESM(require("fs"));
20338
- var os22 = __toESM(require("os"));
20339
- var path31 = __toESM(require("path"));
20379
+ var fs25 = __toESM(require("fs"));
20380
+ var os23 = __toESM(require("os"));
20381
+ var path32 = __toESM(require("path"));
20340
20382
  function cursorCredentialsPath() {
20341
- return path31.join(os22.homedir(), ".cursor", "auth.json");
20383
+ return path32.join(os23.homedir(), ".cursor", "auth.json");
20342
20384
  }
20343
20385
  async function extractLocalCursorToken() {
20344
20386
  const file = cursorCredentialsPath();
20345
- if (!fs24.existsSync(file)) return null;
20346
- const credential = fs24.readFileSync(file, "utf8").trim();
20387
+ if (!fs25.existsSync(file)) return null;
20388
+ const credential = fs25.readFileSync(file, "utf8").trim();
20347
20389
  if (credential.length === 0) return null;
20348
20390
  return { method: "oauth", credential, source: "flat-file" };
20349
20391
  }
@@ -20588,12 +20630,12 @@ var CursorRuntimeStrategy = class {
20588
20630
  };
20589
20631
 
20590
20632
  // src/agents/aider/history.ts
20591
- var fs25 = __toESM(require("fs"));
20592
- var path32 = __toESM(require("path"));
20633
+ var fs26 = __toESM(require("fs"));
20634
+ var path33 = __toESM(require("path"));
20593
20635
  var AIDER_HISTORY_FILE = ".aider.chat.history.md";
20594
20636
  function resolveHistoryDir4(cwd) {
20595
- const candidate = path32.join(cwd, AIDER_HISTORY_FILE);
20596
- return fs25.existsSync(candidate) ? cwd : null;
20637
+ const candidate = path33.join(cwd, AIDER_HISTORY_FILE);
20638
+ return fs26.existsSync(candidate) ? cwd : null;
20597
20639
  }
20598
20640
  function parseHistoryFile4(_filePath) {
20599
20641
  return [];
@@ -20606,10 +20648,10 @@ function getCurrentUsage4(_historyDir) {
20606
20648
  var import_node_child_process12 = require("child_process");
20607
20649
 
20608
20650
  // src/agents/aider/local-token.ts
20609
- var fs26 = __toESM(require("fs"));
20610
- var os23 = __toESM(require("os"));
20611
- var path33 = __toESM(require("path"));
20612
- var AIDER_CONF_FILE = path33.join(os23.homedir(), ".aider.conf.yml");
20651
+ var fs27 = __toESM(require("fs"));
20652
+ var os24 = __toESM(require("os"));
20653
+ var path34 = __toESM(require("path"));
20654
+ var AIDER_CONF_FILE = path34.join(os24.homedir(), ".aider.conf.yml");
20613
20655
  var API_KEY_ENV_VARS = [
20614
20656
  "ANTHROPIC_API_KEY",
20615
20657
  "OPENAI_API_KEY",
@@ -20624,8 +20666,8 @@ async function extractLocalAiderToken() {
20624
20666
  return { method: "api_key", credential: value.trim(), source: "flat-file" };
20625
20667
  }
20626
20668
  }
20627
- if (fs26.existsSync(AIDER_CONF_FILE)) {
20628
- const conf = fs26.readFileSync(AIDER_CONF_FILE, "utf8");
20669
+ if (fs27.existsSync(AIDER_CONF_FILE)) {
20670
+ const conf = fs27.readFileSync(AIDER_CONF_FILE, "utf8");
20629
20671
  const match = conf.match(/^api-key:\s*['"]?([^'"\n]+)['"]?\s*$/m);
20630
20672
  if (match) {
20631
20673
  return { method: "api_key", credential: match[1].trim(), source: "flat-file" };
@@ -21021,19 +21063,19 @@ var import_node_crypto7 = require("crypto");
21021
21063
  var import_node_child_process13 = require("child_process");
21022
21064
 
21023
21065
  // src/agents/gemini/local-token.ts
21024
- var fs28 = __toESM(require("fs"));
21025
- var os25 = __toESM(require("os"));
21026
- var path35 = __toESM(require("path"));
21066
+ var fs29 = __toESM(require("fs"));
21067
+ var os26 = __toESM(require("os"));
21068
+ var path36 = __toESM(require("path"));
21027
21069
  function geminiCredentialsPath() {
21028
- return path35.join(os25.homedir(), ".gemini", "oauth_creds.json");
21070
+ return path36.join(os26.homedir(), ".gemini", "oauth_creds.json");
21029
21071
  }
21030
21072
  function geminiCredentialsPaths() {
21031
21073
  return [geminiCredentialsPath()];
21032
21074
  }
21033
21075
  async function extractLocalGeminiToken() {
21034
21076
  const file = geminiCredentialsPath();
21035
- if (!fs28.existsSync(file)) return null;
21036
- const credential = fs28.readFileSync(file, "utf8").trim();
21077
+ if (!fs29.existsSync(file)) return null;
21078
+ const credential = fs29.readFileSync(file, "utf8").trim();
21037
21079
  if (credential.length === 0) return null;
21038
21080
  return { method: "oauth", credential, source: "flat-file" };
21039
21081
  }
@@ -21089,20 +21131,20 @@ function geminiLoginLauncher() {
21089
21131
  }
21090
21132
 
21091
21133
  // src/agents/gemini/history.ts
21092
- var fs29 = __toESM(require("fs"));
21093
- var os26 = __toESM(require("os"));
21094
- var path36 = __toESM(require("path"));
21095
- var GEMINI_ROOT = path36.join(os26.homedir(), ".gemini");
21134
+ var fs30 = __toESM(require("fs"));
21135
+ var os27 = __toESM(require("os"));
21136
+ var path37 = __toESM(require("path"));
21137
+ var GEMINI_ROOT = path37.join(os27.homedir(), ".gemini");
21096
21138
  function projectNameForCwd(cwd, root) {
21097
21139
  try {
21098
21140
  const parsed = JSON.parse(
21099
- fs29.readFileSync(path36.join(root, "projects.json"), "utf8")
21141
+ fs30.readFileSync(path37.join(root, "projects.json"), "utf8")
21100
21142
  );
21101
21143
  const map = parsed.projects;
21102
21144
  if (map && typeof map === "object") {
21103
21145
  if (typeof map[cwd] === "string") return map[cwd];
21104
21146
  try {
21105
- const rp = fs29.realpathSync(cwd);
21147
+ const rp = fs30.realpathSync(cwd);
21106
21148
  if (typeof map[rp] === "string") return map[rp];
21107
21149
  } catch {
21108
21150
  }
@@ -21111,7 +21153,7 @@ function projectNameForCwd(cwd, root) {
21111
21153
  } catch (err) {
21112
21154
  log.debug("gemini", `projects.json unreadable at ${root} \u2014 using basename fallback`, err);
21113
21155
  }
21114
- return path36.basename(cwd) || null;
21156
+ return path37.basename(cwd) || null;
21115
21157
  }
21116
21158
  function resolveHistoryDir5(cwd, root = GEMINI_ROOT) {
21117
21159
  const name = projectNameForCwd(cwd, root);
@@ -21119,8 +21161,8 @@ function resolveHistoryDir5(cwd, root = GEMINI_ROOT) {
21119
21161
  log.warn("gemini", `resolveHistoryDir \u2014 could not derive a project name for cwd=${cwd}`);
21120
21162
  return null;
21121
21163
  }
21122
- const dir = path36.join(root, "tmp", name, "chats");
21123
- if (!fs29.existsSync(dir)) {
21164
+ const dir = path37.join(root, "tmp", name, "chats");
21165
+ if (!fs30.existsSync(dir)) {
21124
21166
  log.debug("gemini", `resolveHistoryDir \u2014 chats dir not present yet: ${dir} (project=${name})`);
21125
21167
  return null;
21126
21168
  }
@@ -21132,7 +21174,7 @@ function resolveHistoryFile4(cwd, sessionId, root = GEMINI_ROOT) {
21132
21174
  if (!dir) return null;
21133
21175
  let files;
21134
21176
  try {
21135
- files = fs29.readdirSync(dir).filter((f) => f.startsWith("session-") && f.endsWith(".jsonl"));
21177
+ files = fs30.readdirSync(dir).filter((f) => f.startsWith("session-") && f.endsWith(".jsonl"));
21136
21178
  } catch (err) {
21137
21179
  log.warn("gemini", `resolveHistoryFile \u2014 cannot read chats dir ${dir} (id8=${id8})`, err);
21138
21180
  return null;
@@ -21144,12 +21186,12 @@ function resolveHistoryFile4(cwd, sessionId, root = GEMINI_ROOT) {
21144
21186
  const byName = files.find((f) => id8.length > 0 && f.includes(id8));
21145
21187
  if (byName) {
21146
21188
  log.info("gemini", `resolveHistoryFile \u2014 matched by filename id8=${id8}: ${byName}`);
21147
- return path36.join(dir, byName);
21189
+ return path37.join(dir, byName);
21148
21190
  }
21149
21191
  for (const f of files) {
21150
- const full = path36.join(dir, f);
21192
+ const full = path37.join(dir, f);
21151
21193
  try {
21152
- const firstLine = fs29.readFileSync(full, "utf8").split("\n", 1)[0] ?? "";
21194
+ const firstLine = fs30.readFileSync(full, "utf8").split("\n", 1)[0] ?? "";
21153
21195
  const hdr = JSON.parse(firstLine);
21154
21196
  if (hdr.sessionId === sessionId) {
21155
21197
  log.info("gemini", `resolveHistoryFile \u2014 matched by header sessionId: ${f}`);
@@ -21162,7 +21204,7 @@ function resolveHistoryFile4(cwd, sessionId, root = GEMINI_ROOT) {
21162
21204
  let newest = null;
21163
21205
  for (const f of files) {
21164
21206
  try {
21165
- const mtime = fs29.statSync(path36.join(dir, f)).mtimeMs;
21207
+ const mtime = fs30.statSync(path37.join(dir, f)).mtimeMs;
21166
21208
  if (!newest || mtime > newest.mtime) newest = { file: f, mtime };
21167
21209
  } catch {
21168
21210
  }
@@ -21171,7 +21213,7 @@ function resolveHistoryFile4(cwd, sessionId, root = GEMINI_ROOT) {
21171
21213
  "gemini",
21172
21214
  `resolveHistoryFile \u2014 no id8=${id8} match among ${files.length} file(s) in ${dir}; falling back to newest=${newest?.file ?? "none"}`
21173
21215
  );
21174
- return newest ? path36.join(dir, newest.file) : null;
21216
+ return newest ? path37.join(dir, newest.file) : null;
21175
21217
  }
21176
21218
  function extractGeminiText(content) {
21177
21219
  const fromParts = (arr) => Array.isArray(arr) ? arr.map((p2) => {
@@ -21199,7 +21241,7 @@ function isSyntheticGeminiTurn(text) {
21199
21241
  function parseHistoryFile5(filePath) {
21200
21242
  let raw;
21201
21243
  try {
21202
- raw = fs29.readFileSync(filePath, "utf8");
21244
+ raw = fs30.readFileSync(filePath, "utf8");
21203
21245
  } catch (err) {
21204
21246
  log.warn("gemini", `parseHistoryFile \u2014 cannot read ${filePath}`, err);
21205
21247
  return [];
@@ -21240,7 +21282,7 @@ function parseHistoryFile5(filePath) {
21240
21282
  }
21241
21283
  log.trace(
21242
21284
  "gemini",
21243
- `parseHistoryFile \u2014 ${out2.length} turn(s) from ${path36.basename(filePath)}` + (malformed > 0 ? ` (${malformed} malformed line(s) skipped)` : "")
21285
+ `parseHistoryFile \u2014 ${out2.length} turn(s) from ${path37.basename(filePath)}` + (malformed > 0 ? ` (${malformed} malformed line(s) skipped)` : "")
21244
21286
  );
21245
21287
  return out2;
21246
21288
  }
@@ -21386,42 +21428,42 @@ var import_node_os4 = require("os");
21386
21428
  var import_node_path6 = require("path");
21387
21429
 
21388
21430
  // src/agents/kimi/history.ts
21389
- var fs30 = __toESM(require("fs"));
21390
- var os27 = __toESM(require("os"));
21391
- var path37 = __toESM(require("path"));
21431
+ var fs31 = __toESM(require("fs"));
21432
+ var os28 = __toESM(require("os"));
21433
+ var path38 = __toESM(require("path"));
21392
21434
  var import_node_crypto8 = require("crypto");
21393
21435
  function kimiHome() {
21394
- return process.env.KIMI_CODE_HOME || path37.join(os27.homedir(), ".kimi-code");
21436
+ return process.env.KIMI_CODE_HOME || path38.join(os28.homedir(), ".kimi-code");
21395
21437
  }
21396
21438
  function workDirKey(cwd) {
21397
21439
  const hash = (0, import_node_crypto8.createHash)("sha256").update(cwd).digest("hex").slice(0, 12);
21398
- return `wd_${path37.basename(cwd)}_${hash}`;
21440
+ return `wd_${path38.basename(cwd)}_${hash}`;
21399
21441
  }
21400
21442
  function resolveHistoryDir6(cwd) {
21401
- const dir = path37.join(kimiHome(), "sessions", workDirKey(cwd));
21402
- if (!fs30.existsSync(dir)) {
21443
+ const dir = path38.join(kimiHome(), "sessions", workDirKey(cwd));
21444
+ if (!fs31.existsSync(dir)) {
21403
21445
  log.debug("kimi", `resolveHistoryDir \u2014 session bucket not present yet: ${dir}`);
21404
21446
  return null;
21405
21447
  }
21406
21448
  return dir;
21407
21449
  }
21408
- var WIRE_REL = path37.join("agents", "main", "wire.jsonl");
21450
+ var WIRE_REL = path38.join("agents", "main", "wire.jsonl");
21409
21451
  function resolveHistoryFile5(cwd, sessionId) {
21410
21452
  const fromIndex = sessionDirFromIndex(sessionId);
21411
21453
  if (fromIndex) {
21412
- const p2 = path37.join(fromIndex, WIRE_REL);
21413
- if (fs30.existsSync(p2)) return p2;
21454
+ const p2 = path38.join(fromIndex, WIRE_REL);
21455
+ if (fs31.existsSync(p2)) return p2;
21414
21456
  }
21415
- const bucket = path37.join(kimiHome(), "sessions", workDirKey(cwd));
21416
- const computed = path37.join(bucket, sessionId, WIRE_REL);
21417
- if (fs30.existsSync(computed)) return computed;
21457
+ const bucket = path38.join(kimiHome(), "sessions", workDirKey(cwd));
21458
+ const computed = path38.join(bucket, sessionId, WIRE_REL);
21459
+ if (fs31.existsSync(computed)) return computed;
21418
21460
  const scanned = scanBucketsForSession(sessionId);
21419
21461
  if (scanned) return scanned;
21420
21462
  return null;
21421
21463
  }
21422
21464
  function sessionDirFromIndex(sessionId) {
21423
21465
  try {
21424
- const raw = fs30.readFileSync(path37.join(kimiHome(), "session_index.jsonl"), "utf8");
21466
+ const raw = fs31.readFileSync(path38.join(kimiHome(), "session_index.jsonl"), "utf8");
21425
21467
  for (const line of raw.split("\n")) {
21426
21468
  if (!line.includes(sessionId)) continue;
21427
21469
  try {
@@ -21437,22 +21479,22 @@ function sessionDirFromIndex(sessionId) {
21437
21479
  return null;
21438
21480
  }
21439
21481
  function scanBucketsForSession(sessionId) {
21440
- const sessionsRoot = path37.join(kimiHome(), "sessions");
21482
+ const sessionsRoot = path38.join(kimiHome(), "sessions");
21441
21483
  let buckets;
21442
21484
  try {
21443
- buckets = fs30.readdirSync(sessionsRoot, { withFileTypes: true });
21485
+ buckets = fs31.readdirSync(sessionsRoot, { withFileTypes: true });
21444
21486
  } catch {
21445
21487
  return null;
21446
21488
  }
21447
21489
  for (const b of buckets) {
21448
21490
  if (!b.isDirectory()) continue;
21449
- const candidate = path37.join(sessionsRoot, b.name, sessionId, WIRE_REL);
21450
- if (fs30.existsSync(candidate)) return candidate;
21491
+ const candidate = path38.join(sessionsRoot, b.name, sessionId, WIRE_REL);
21492
+ if (fs31.existsSync(candidate)) return candidate;
21451
21493
  }
21452
21494
  return null;
21453
21495
  }
21454
21496
  async function discoverSessionId2(cwd, opts) {
21455
- const bucket = path37.join(kimiHome(), "sessions", workDirKey(cwd));
21497
+ const bucket = path38.join(kimiHome(), "sessions", workDirKey(cwd));
21456
21498
  const floor = opts.sinceMs - 2e3;
21457
21499
  const deadline = Date.now() + (opts.timeoutMs ?? 15e3);
21458
21500
  for (; ; ) {
@@ -21465,7 +21507,7 @@ async function discoverSessionId2(cwd, opts) {
21465
21507
  function newestSessionSince(bucket, floorMs) {
21466
21508
  let entries2;
21467
21509
  try {
21468
- entries2 = fs30.readdirSync(bucket, { withFileTypes: true });
21510
+ entries2 = fs31.readdirSync(bucket, { withFileTypes: true });
21469
21511
  } catch {
21470
21512
  return null;
21471
21513
  }
@@ -21475,7 +21517,7 @@ function newestSessionSince(bucket, floorMs) {
21475
21517
  if (!e.isDirectory() || !e.name.startsWith("session_")) continue;
21476
21518
  let mtime;
21477
21519
  try {
21478
- mtime = fs30.statSync(path37.join(bucket, e.name)).mtimeMs;
21520
+ mtime = fs31.statSync(path38.join(bucket, e.name)).mtimeMs;
21479
21521
  } catch {
21480
21522
  continue;
21481
21523
  }
@@ -21496,7 +21538,7 @@ function joinTextParts(parts) {
21496
21538
  function parseHistoryFile6(filePath) {
21497
21539
  let raw;
21498
21540
  try {
21499
- raw = fs30.readFileSync(filePath, "utf8");
21541
+ raw = fs31.readFileSync(filePath, "utf8");
21500
21542
  } catch {
21501
21543
  return [];
21502
21544
  }
@@ -21878,7 +21920,7 @@ function parseLinkArgs(args2) {
21878
21920
  if (apiKeyFileArg) {
21879
21921
  const filePath = apiKeyFileArg.slice("--api-key-file=".length);
21880
21922
  try {
21881
- apiKey = fs31.readFileSync(path38.resolve(filePath), "utf8").trim();
21923
+ apiKey = fs32.readFileSync(path39.resolve(filePath), "utf8").trim();
21882
21924
  } catch (err) {
21883
21925
  throw new Error(`Could not read --api-key-file ${filePath}: ${err.message}`);
21884
21926
  }
@@ -22005,7 +22047,7 @@ async function link(args2 = []) {
22005
22047
  return;
22006
22048
  }
22007
22049
  if (parsed.tokenFile) {
22008
- const credential = fs31.readFileSync(path38.resolve(parsed.tokenFile), "utf8").trim();
22050
+ const credential = fs32.readFileSync(path39.resolve(parsed.tokenFile), "utf8").trim();
22009
22051
  if (!credential) {
22010
22052
  showError(`--token-file ${parsed.tokenFile} is empty.`);
22011
22053
  process.exit(1);
@@ -22260,13 +22302,13 @@ function makePreviewHeartbeatReaffirm(deps) {
22260
22302
  // src/agents/coderabbit/configure.ts
22261
22303
  var import_node_child_process17 = require("child_process");
22262
22304
  var import_node_fs7 = require("fs");
22263
- var path40 = __toESM(require("path"));
22305
+ var path41 = __toESM(require("path"));
22264
22306
 
22265
22307
  // src/agents/coderabbit/oauth.ts
22266
22308
  var import_node_child_process16 = require("child_process");
22267
- var fs32 = __toESM(require("fs"));
22268
- var os28 = __toESM(require("os"));
22269
- var path39 = __toESM(require("path"));
22309
+ var fs33 = __toESM(require("fs"));
22310
+ var os29 = __toESM(require("os"));
22311
+ var path40 = __toESM(require("path"));
22270
22312
  function parseCoderabbitAuthEvent(line) {
22271
22313
  const l = line.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "").trim();
22272
22314
  if (!l || l[0] !== "{") return null;
@@ -22315,8 +22357,8 @@ function resolvePython() {
22315
22357
  function spawnCoderabbitLoginProc(cmd, args2) {
22316
22358
  const python = resolvePython();
22317
22359
  if (python) {
22318
- const helper = path39.join(os28.tmpdir(), "codeam-cr-pty.py");
22319
- fs32.writeFileSync(helper, PYTHON_PTY_HELPER, { mode: 420 });
22360
+ const helper = path40.join(os29.tmpdir(), "codeam-cr-pty.py");
22361
+ fs33.writeFileSync(helper, PYTHON_PTY_HELPER, { mode: 420 });
22320
22362
  return (0, import_node_child_process16.spawn)(python, [helper, cmd, ...args2], {
22321
22363
  stdio: ["pipe", "pipe", "pipe"],
22322
22364
  env: { ...process.env, TERM: "xterm-256color", COLUMNS: "220", LINES: "50" },
@@ -22427,7 +22469,7 @@ function runCoderabbitOAuthLogin(deps) {
22427
22469
  });
22428
22470
  }
22429
22471
  function coderabbitDir(home) {
22430
- return path39.join(home ?? os28.homedir(), ".coderabbit");
22472
+ return path40.join(home ?? os29.homedir(), ".coderabbit");
22431
22473
  }
22432
22474
  var NON_CREDENTIAL = /* @__PURE__ */ new Set(["doctor.json", "machine-id"]);
22433
22475
  function snapshotCredentialDir(home) {
@@ -22435,14 +22477,14 @@ function snapshotCredentialDir(home) {
22435
22477
  const snap = {};
22436
22478
  let entries2;
22437
22479
  try {
22438
- entries2 = fs32.readdirSync(dir, { withFileTypes: true });
22480
+ entries2 = fs33.readdirSync(dir, { withFileTypes: true });
22439
22481
  } catch {
22440
22482
  return snap;
22441
22483
  }
22442
22484
  for (const e of entries2) {
22443
22485
  if (!e.isFile() || NON_CREDENTIAL.has(e.name)) continue;
22444
22486
  try {
22445
- const st3 = fs32.statSync(path39.join(dir, e.name));
22487
+ const st3 = fs33.statSync(path40.join(dir, e.name));
22446
22488
  snap[e.name] = `${st3.mtimeMs}:${st3.size}`;
22447
22489
  } catch {
22448
22490
  }
@@ -22460,7 +22502,7 @@ function diffCapturedCredential(before, home) {
22460
22502
  }
22461
22503
  if (!best) return null;
22462
22504
  try {
22463
- return { file: best.file, contents: fs32.readFileSync(path39.join(dir, best.file), "utf8") };
22505
+ return { file: best.file, contents: fs33.readFileSync(path40.join(dir, best.file), "utf8") };
22464
22506
  } catch {
22465
22507
  return null;
22466
22508
  }
@@ -22537,7 +22579,7 @@ function collectChangedFiles(cwd) {
22537
22579
  return [...byPath.values()];
22538
22580
  }
22539
22581
  function restoreCoderabbitOauthBlob(os74, value) {
22540
- const dir = path40.join(os74.homeDir(), ".coderabbit");
22582
+ const dir = path41.join(os74.homeDir(), ".coderabbit");
22541
22583
  (0, import_node_fs7.mkdirSync)(dir, { recursive: true });
22542
22584
  let file = "auth.json";
22543
22585
  let contents = value.trim();
@@ -22545,13 +22587,13 @@ function restoreCoderabbitOauthBlob(os74, value) {
22545
22587
  try {
22546
22588
  const parsed = JSON.parse(contents);
22547
22589
  if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
22548
- file = path40.basename(parsed.file);
22590
+ file = path41.basename(parsed.file);
22549
22591
  contents = parsed.contents;
22550
22592
  }
22551
22593
  } catch {
22552
22594
  }
22553
22595
  }
22554
- (0, import_node_fs7.writeFileSync)(path40.join(dir, file), contents, { mode: 384 });
22596
+ (0, import_node_fs7.writeFileSync)(path41.join(dir, file), contents, { mode: 384 });
22555
22597
  }
22556
22598
  function installFailureMessage(result) {
22557
22599
  return result.error ?? "CodeRabbit CLI could not be installed";
@@ -22567,10 +22609,10 @@ async function configureCoderabbit(input, deps = {}) {
22567
22609
  const home = os74.homeDir();
22568
22610
  os74.augmentPath(
22569
22611
  os74.id === "win32" ? [
22570
- path40.join(home, ".local", "bin"),
22571
- path40.join(process.env.APPDATA ?? path40.join(home, "AppData", "Roaming"), "npm"),
22572
- path40.join(home, "scoop", "shims")
22573
- ] : [path40.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"]
22612
+ path41.join(home, ".local", "bin"),
22613
+ path41.join(process.env.APPDATA ?? path41.join(home, "AppData", "Roaming"), "npm"),
22614
+ path41.join(home, "scoop", "shims")
22615
+ ] : [path41.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"]
22574
22616
  );
22575
22617
  const installed2 = os74.findInPath("coderabbit") !== null;
22576
22618
  const base = () => ({
@@ -22889,9 +22931,9 @@ var import_node_child_process22 = require("child_process");
22889
22931
  var import_node_util7 = require("util");
22890
22932
 
22891
22933
  // src/commands/host/workspace.ts
22892
- var fs34 = __toESM(require("fs"));
22893
- var os30 = __toESM(require("os"));
22894
- var path41 = __toESM(require("path"));
22934
+ var fs35 = __toESM(require("fs"));
22935
+ var os31 = __toESM(require("os"));
22936
+ var path42 = __toESM(require("path"));
22895
22937
  var import_node_child_process20 = require("child_process");
22896
22938
  var import_node_util5 = require("util");
22897
22939
 
@@ -22931,18 +22973,18 @@ function restrictToOwner(filePath) {
22931
22973
  // src/commands/host/workspace.ts
22932
22974
  var execFileP4 = (0, import_node_util5.promisify)(import_node_child_process20.execFile);
22933
22975
  function isAbsolutePathTarget(target) {
22934
- return path41.isAbsolute(target);
22976
+ return path42.isAbsolute(target);
22935
22977
  }
22936
22978
  function selfHostedWorkspaceRoot() {
22937
- return path41.join(os30.homedir(), ".codeam", "self-hosted");
22979
+ return path42.join(os31.homedir(), ".codeam", "self-hosted");
22938
22980
  }
22939
22981
  function deployIdFromWorkspace(cwd) {
22940
22982
  if (!cwd) return null;
22941
22983
  const root = selfHostedWorkspaceRoot();
22942
- const resolved = path41.resolve(cwd);
22943
- const rel = path41.relative(root, resolved);
22944
- if (!rel || rel.startsWith("..") || path41.isAbsolute(rel)) return null;
22945
- const parts = rel.split(path41.sep).filter(Boolean);
22984
+ const resolved = path42.resolve(cwd);
22985
+ const rel = path42.relative(root, resolved);
22986
+ if (!rel || rel.startsWith("..") || path42.isAbsolute(rel)) return null;
22987
+ const parts = rel.split(path42.sep).filter(Boolean);
22946
22988
  if (parts.length !== 1) return null;
22947
22989
  return parts[0];
22948
22990
  }
@@ -23014,15 +23056,15 @@ async function configureGitCredentials(dest, repoRef, cloneToken, provider = "gi
23014
23056
  const isGitlab = provider === "gitlab";
23015
23057
  if (isGitlab ? !gitlabProjectPath(repoRef.trim()) : !githubOwnerRepo(repoRef.trim())) return;
23016
23058
  if (!cloneToken) return;
23017
- const credFile = path41.join(dest, ".git", "codeam-credentials");
23059
+ const credFile = path42.join(dest, ".git", "codeam-credentials");
23018
23060
  const credLine = isGitlab ? `https://oauth2:${cloneToken}@gitlab.com
23019
23061
  ` : `https://x-access-token:${cloneToken}@github.com
23020
23062
  `;
23021
- fs34.writeFileSync(credFile, credLine, { mode: 384 });
23063
+ fs35.writeFileSync(credFile, credLine, { mode: 384 });
23022
23064
  restrictToOwner(credFile);
23023
23065
  const env = nonInteractiveGitEnv();
23024
23066
  const git2 = (args2) => execFileP4("git", ["-C", dest, ...args2], { timeout: 3e4, env });
23025
- const credFilePosix = credFile.split(path41.sep).join("/");
23067
+ const credFilePosix = credFile.split(path42.sep).join("/");
23026
23068
  await git2(["config", "--local", "--replace-all", "credential.helper", ""]).catch(() => {
23027
23069
  });
23028
23070
  await git2([
@@ -23055,17 +23097,17 @@ function maskToken(text, cloneToken) {
23055
23097
  }
23056
23098
  async function prepareWorkspace(repoOrPath, deployId, cloneToken, provider = "github", branch) {
23057
23099
  if (isAbsolutePathTarget(repoOrPath)) {
23058
- if (!fs34.existsSync(repoOrPath)) {
23100
+ if (!fs35.existsSync(repoOrPath)) {
23059
23101
  throw new Error(`deploy target path does not exist: ${repoOrPath}`);
23060
23102
  }
23061
23103
  return repoOrPath;
23062
23104
  }
23063
- const dest = path41.join(selfHostedWorkspaceRoot(), deployId);
23064
- if (fs34.existsSync(path41.join(dest, ".git"))) {
23105
+ const dest = path42.join(selfHostedWorkspaceRoot(), deployId);
23106
+ if (fs35.existsSync(path42.join(dest, ".git"))) {
23065
23107
  if (cloneToken) await configureGitCredentials(dest, repoOrPath, cloneToken, provider);
23066
23108
  return dest;
23067
23109
  }
23068
- fs34.mkdirSync(selfHostedWorkspaceRoot(), { recursive: true, mode: 448 });
23110
+ fs35.mkdirSync(selfHostedWorkspaceRoot(), { recursive: true, mode: 448 });
23069
23111
  const cloneUrl = repoCloneUrl(repoOrPath, cloneToken, provider);
23070
23112
  const cloneArgs = branch ? ["clone", "--depth", "1", "--branch", branch, cloneUrl, dest] : ["clone", "--depth", "1", cloneUrl, dest];
23071
23113
  try {
@@ -23207,21 +23249,21 @@ function buildZip(cwd, list, outFile) {
23207
23249
 
23208
23250
  // src/scratch/export-registry.ts
23209
23251
  var import_crypto2 = require("crypto");
23210
- var fs38 = __toESM(require("fs"));
23211
- var os31 = __toESM(require("os"));
23212
- var path45 = __toESM(require("path"));
23252
+ var fs39 = __toESM(require("fs"));
23253
+ var os32 = __toESM(require("os"));
23254
+ var path46 = __toESM(require("path"));
23213
23255
  var entries = /* @__PURE__ */ new Map();
23214
23256
  var EXPORT_TTL_MS = 6e5;
23215
23257
  var RETRY_WINDOW_MS = 6e4;
23216
23258
  var EXPORT_PATH_PREFIX = "/.codeam/export/";
23217
- var exportsBaseDir = () => path45.join(os31.homedir(), ".codeam", "exports");
23218
- var exportDir = () => path45.join(exportsBaseDir(), String(process.pid));
23259
+ var exportsBaseDir = () => path46.join(os32.homedir(), ".codeam", "exports");
23260
+ var exportDir = () => path46.join(exportsBaseDir(), String(process.pid));
23219
23261
  function drop(token) {
23220
23262
  const e = entries.get(token);
23221
23263
  if (!e) return;
23222
23264
  clearTimeout(e.timer);
23223
23265
  entries.delete(token);
23224
- fs38.rmSync(e.file, { force: true });
23266
+ fs39.rmSync(e.file, { force: true });
23225
23267
  }
23226
23268
  function armExpiry(token, ms) {
23227
23269
  const timer = setTimeout(() => {
@@ -23253,7 +23295,7 @@ function handleExportRequest(req, res) {
23253
23295
  if (req.method !== "GET" || !req.url?.startsWith(EXPORT_PATH_PREFIX)) return false;
23254
23296
  const token = req.url.slice(EXPORT_PATH_PREFIX.length).split("?")[0];
23255
23297
  const e = entries.get(token);
23256
- if (!e || e.inFlight || !fs38.existsSync(e.file)) {
23298
+ if (!e || e.inFlight || !fs39.existsSync(e.file)) {
23257
23299
  res.statusCode = 404;
23258
23300
  res.end();
23259
23301
  return true;
@@ -23265,7 +23307,7 @@ function handleExportRequest(req, res) {
23265
23307
  "Content-Disposition": 'attachment; filename="project.zip"',
23266
23308
  "Cache-Control": "no-store"
23267
23309
  });
23268
- const stream = fs38.createReadStream(e.file);
23310
+ const stream = fs39.createReadStream(e.file);
23269
23311
  stream.on("error", () => res.destroy());
23270
23312
  stream.pipe(res);
23271
23313
  res.on("finish", () => {
@@ -23295,16 +23337,16 @@ function purgeExports() {
23295
23337
  const base = exportsBaseDir();
23296
23338
  let names;
23297
23339
  try {
23298
- names = fs38.readdirSync(base);
23340
+ names = fs39.readdirSync(base);
23299
23341
  } catch {
23300
23342
  return;
23301
23343
  }
23302
23344
  for (const name of names) {
23303
- const abs = path45.join(base, name);
23345
+ const abs = path46.join(base, name);
23304
23346
  try {
23305
- const st3 = fs38.lstatSync(abs);
23347
+ const st3 = fs39.lstatSync(abs);
23306
23348
  const stale = st3.isDirectory() && /^\d+$/.test(name) ? Number(name) === process.pid || !isPidAlive(Number(name)) : Date.now() - st3.mtimeMs > EXPORT_TTL_MS;
23307
- if (stale) fs38.rmSync(abs, { recursive: true, force: true });
23349
+ if (stale) fs39.rmSync(abs, { recursive: true, force: true });
23308
23350
  } catch {
23309
23351
  }
23310
23352
  }
@@ -23441,16 +23483,16 @@ async function spawnNamedTunnel(bin, token, port) {
23441
23483
  }
23442
23484
 
23443
23485
  // src/services/preview/port-registry.ts
23444
- var fs40 = __toESM(require("fs"));
23445
- var os33 = __toESM(require("os"));
23446
- var path47 = __toESM(require("path"));
23486
+ var fs41 = __toESM(require("fs"));
23487
+ var os34 = __toESM(require("os"));
23488
+ var path48 = __toESM(require("path"));
23447
23489
  var import_child_process15 = require("child_process");
23448
23490
  function registryPath2() {
23449
- return path47.join(os33.homedir(), ".codeam", "preview-ports.json");
23491
+ return path48.join(os34.homedir(), ".codeam", "preview-ports.json");
23450
23492
  }
23451
23493
  function readRegistry() {
23452
23494
  try {
23453
- const raw = fs40.readFileSync(registryPath2(), "utf8");
23495
+ const raw = fs41.readFileSync(registryPath2(), "utf8");
23454
23496
  const parsed = JSON.parse(raw);
23455
23497
  if (parsed && typeof parsed === "object") return parsed;
23456
23498
  } catch {
@@ -23460,10 +23502,10 @@ function readRegistry() {
23460
23502
  function writeRegistry(reg) {
23461
23503
  try {
23462
23504
  const file = registryPath2();
23463
- fs40.mkdirSync(path47.dirname(file), { recursive: true });
23505
+ fs41.mkdirSync(path48.dirname(file), { recursive: true });
23464
23506
  const tmp = `${file}.tmp`;
23465
- fs40.writeFileSync(tmp, JSON.stringify(reg), "utf8");
23466
- fs40.renameSync(tmp, file);
23507
+ fs41.writeFileSync(tmp, JSON.stringify(reg), "utf8");
23508
+ fs41.renameSync(tmp, file);
23467
23509
  } catch (err) {
23468
23510
  log.warn("preview", `port-registry write failed: ${err instanceof Error ? err.message : String(err)}`);
23469
23511
  }
@@ -23529,7 +23571,7 @@ function reclaimOwnOrphanPort(port) {
23529
23571
 
23530
23572
  // src/services/preview/host-allow.ts
23531
23573
  var import_fs3 = require("fs");
23532
- var path48 = __toESM(require("path"));
23574
+ var path49 = __toESM(require("path"));
23533
23575
  var NEXT_ALLOWED_ORIGINS = [
23534
23576
  "*.trycloudflare.com",
23535
23577
  "*.preview.codeagent-mobile.com",
@@ -23549,7 +23591,7 @@ var MARKER_DIR = ".codeam";
23549
23591
  var MARKER_FILE = "preview-host-allow.json";
23550
23592
  var ORIG_INFIX = ".codeam-orig";
23551
23593
  function markerPath(cwd) {
23552
- return path48.join(cwd, MARKER_DIR, MARKER_FILE);
23594
+ return path49.join(cwd, MARKER_DIR, MARKER_FILE);
23553
23595
  }
23554
23596
  async function fileExists(p2) {
23555
23597
  try {
@@ -23562,13 +23604,13 @@ async function fileExists(p2) {
23562
23604
  async function findConfigFile(cwd, framework) {
23563
23605
  const base = CONFIG_BASENAMES[framework];
23564
23606
  for (const ext of CONFIG_EXTS) {
23565
- if (await fileExists(path48.join(cwd, `${base}${ext}`))) return `${base}${ext}`;
23607
+ if (await fileExists(path49.join(cwd, `${base}${ext}`))) return `${base}${ext}`;
23566
23608
  }
23567
23609
  return null;
23568
23610
  }
23569
23611
  async function dependsOn(cwd, pkgName) {
23570
23612
  try {
23571
- const raw = await import_fs3.promises.readFile(path48.join(cwd, "package.json"), "utf8");
23613
+ const raw = await import_fs3.promises.readFile(path49.join(cwd, "package.json"), "utf8");
23572
23614
  const pkg = JSON.parse(raw);
23573
23615
  return !!(pkg.dependencies?.[pkgName] ?? pkg.devDependencies?.[pkgName]);
23574
23616
  } catch {
@@ -23576,11 +23618,11 @@ async function dependsOn(cwd, pkgName) {
23576
23618
  }
23577
23619
  }
23578
23620
  async function isEsmConfig(cwd, configFile) {
23579
- const ext = path48.extname(configFile);
23621
+ const ext = path49.extname(configFile);
23580
23622
  if (ext === ".mjs" || ext === ".mts" || ext === ".ts") return true;
23581
23623
  if (ext === ".cjs") return false;
23582
23624
  try {
23583
- const raw = await import_fs3.promises.readFile(path48.join(cwd, "package.json"), "utf8");
23625
+ const raw = await import_fs3.promises.readFile(path49.join(cwd, "package.json"), "utf8");
23584
23626
  return JSON.parse(raw).type === "module";
23585
23627
  } catch {
23586
23628
  return false;
@@ -23671,7 +23713,7 @@ async function isOurShim(abs) {
23671
23713
  }
23672
23714
  }
23673
23715
  async function writeMarker(cwd, marker) {
23674
- await import_fs3.promises.mkdir(path48.join(cwd, MARKER_DIR), { recursive: true });
23716
+ await import_fs3.promises.mkdir(path49.join(cwd, MARKER_DIR), { recursive: true });
23675
23717
  await import_fs3.promises.writeFile(markerPath(cwd), JSON.stringify(marker, null, 2), "utf8");
23676
23718
  }
23677
23719
  async function readMarker(cwd) {
@@ -23686,9 +23728,9 @@ async function restorePreviewHostAllow(cwd) {
23686
23728
  const marker = await readMarker(cwd);
23687
23729
  if (!marker) return;
23688
23730
  try {
23689
- const configAbs = path48.join(cwd, marker.configFile);
23731
+ const configAbs = path49.join(cwd, marker.configFile);
23690
23732
  if (marker.backupFile) {
23691
- const backupAbs = path48.join(cwd, marker.backupFile);
23733
+ const backupAbs = path49.join(cwd, marker.backupFile);
23692
23734
  if (await fileExists(backupAbs)) {
23693
23735
  await import_fs3.promises.rm(configAbs, { force: true });
23694
23736
  await import_fs3.promises.rename(backupAbs, configAbs);
@@ -23721,26 +23763,26 @@ async function applyPreviewHostAllow(cwd) {
23721
23763
  }
23722
23764
  if (!framework) return;
23723
23765
  if (existing) {
23724
- const ext = path48.extname(existing);
23766
+ const ext = path49.extname(existing);
23725
23767
  const origBasename = `${CONFIG_BASENAMES[framework]}${ORIG_INFIX}${ext}`;
23726
- if (await isOurShim(path48.join(cwd, existing))) {
23727
- const origAbs = path48.join(cwd, origBasename);
23768
+ if (await isOurShim(path49.join(cwd, existing))) {
23769
+ const origAbs = path49.join(cwd, origBasename);
23728
23770
  if (!await fileExists(origAbs) || await isOurShim(origAbs)) {
23729
23771
  log.warn("preview", `host-allow: ${existing} is a leftover shim with no original \u2014 skipped`);
23730
23772
  return;
23731
23773
  }
23732
- await import_fs3.promises.rm(path48.join(cwd, existing), { force: true });
23733
- await import_fs3.promises.rename(origAbs, path48.join(cwd, existing));
23774
+ await import_fs3.promises.rm(path49.join(cwd, existing), { force: true });
23775
+ await import_fs3.promises.rename(origAbs, path49.join(cwd, existing));
23734
23776
  log.info("preview", `host-allow: restored ${existing} from a leftover ${origBasename}`);
23735
23777
  }
23736
23778
  const esm = await isEsmConfig(cwd, existing);
23737
- await import_fs3.promises.rename(path48.join(cwd, existing), path48.join(cwd, origBasename));
23738
- await import_fs3.promises.writeFile(path48.join(cwd, existing), shimFor(framework, origBasename, esm), "utf8");
23779
+ await import_fs3.promises.rename(path49.join(cwd, existing), path49.join(cwd, origBasename));
23780
+ await import_fs3.promises.writeFile(path49.join(cwd, existing), shimFor(framework, origBasename, esm), "utf8");
23739
23781
  await writeMarker(cwd, { framework, configFile: existing, backupFile: origBasename });
23740
23782
  log.info("preview", `host-allow: wrapped ${existing} (${framework}) for tunnel access`);
23741
23783
  } else {
23742
23784
  const configFile = `${CONFIG_BASENAMES[framework]}.mjs`;
23743
- await import_fs3.promises.writeFile(path48.join(cwd, configFile), shimFor(framework, null, true), "utf8");
23785
+ await import_fs3.promises.writeFile(path49.join(cwd, configFile), shimFor(framework, null, true), "utf8");
23744
23786
  await writeMarker(cwd, { framework, configFile, backupFile: null });
23745
23787
  log.info("preview", `host-allow: created ${configFile} (${framework}) for tunnel access`);
23746
23788
  }
@@ -23750,8 +23792,8 @@ async function applyPreviewHostAllow(cwd) {
23750
23792
  }
23751
23793
 
23752
23794
  // src/services/preview/build-heal.ts
23753
- var fs42 = __toESM(require("fs"));
23754
- var path49 = __toESM(require("path"));
23795
+ var fs43 = __toESM(require("fs"));
23796
+ var path50 = __toESM(require("path"));
23755
23797
  var BUILD_MARKER_NAME = "BUILD_ID";
23756
23798
  var DEFAULT_DEBOUNCE_MS = 1500;
23757
23799
  var DEFAULT_MAX_RESTARTS = 3;
@@ -23760,7 +23802,7 @@ function isBuildHealSupported(framework) {
23760
23802
  }
23761
23803
  function defaultWatchDir(dir, onEvent) {
23762
23804
  try {
23763
- const w3 = fs42.watch(dir, { persistent: false }, (_eventType, filename) => onEvent(filename));
23805
+ const w3 = fs43.watch(dir, { persistent: false }, (_eventType, filename) => onEvent(filename));
23764
23806
  w3.on("error", () => {
23765
23807
  try {
23766
23808
  w3.close();
@@ -23783,7 +23825,7 @@ function resetBuildHealState(sessionId) {
23783
23825
  }
23784
23826
  function readMarker2(markerPath5) {
23785
23827
  try {
23786
- return fs42.readFileSync(markerPath5, "utf8").trim();
23828
+ return fs43.readFileSync(markerPath5, "utf8").trim();
23787
23829
  } catch {
23788
23830
  return null;
23789
23831
  }
@@ -23792,8 +23834,8 @@ function watchForBuildClobber(deps) {
23792
23834
  const watchDir = deps.watchDir ?? defaultWatchDir;
23793
23835
  const debounceMs = deps.debounceMs ?? DEFAULT_DEBOUNCE_MS;
23794
23836
  const maxRestarts = deps.maxRestarts ?? DEFAULT_MAX_RESTARTS;
23795
- const nextDir = path49.join(deps.cwd, ".next");
23796
- const markerPath5 = path49.join(nextDir, BUILD_MARKER_NAME);
23837
+ const nextDir = path50.join(deps.cwd, ".next");
23838
+ const markerPath5 = path50.join(nextDir, BUILD_MARKER_NAME);
23797
23839
  let stopped = false;
23798
23840
  let debounceTimer = null;
23799
23841
  let dirUnwatch = null;
@@ -23852,12 +23894,12 @@ function watchForBuildClobber(deps) {
23852
23894
  if (filename === null || filename === BUILD_MARKER_NAME) onMarkerTouched();
23853
23895
  });
23854
23896
  };
23855
- if (fs42.existsSync(nextDir)) {
23897
+ if (fs43.existsSync(nextDir)) {
23856
23898
  attachDirWatch();
23857
23899
  } else {
23858
23900
  cwdUnwatch = watchDir(deps.cwd, (filename) => {
23859
23901
  if (stopped || dirUnwatch) return;
23860
- if ((filename === ".next" || filename === null) && fs42.existsSync(nextDir)) {
23902
+ if ((filename === ".next" || filename === null) && fs43.existsSync(nextDir)) {
23861
23903
  cwdUnwatch?.();
23862
23904
  cwdUnwatch = null;
23863
23905
  attachDirWatch();
@@ -23957,7 +23999,7 @@ function quoteIfNeeded(value) {
23957
23999
 
23958
24000
  // src/services/preview/expo.ts
23959
24001
  var http6 = __toESM(require("http"));
23960
- var path51 = __toESM(require("path"));
24002
+ var path52 = __toESM(require("path"));
23961
24003
  var EXPO_PACKAGER_PROXY_URL_ENV = "EXPO_PACKAGER_PROXY_URL";
23962
24004
  function stripExpoTunnelFlag(args2) {
23963
24005
  return args2.filter((a) => a !== "--tunnel" && !a.startsWith("--tunnel="));
@@ -23966,7 +24008,7 @@ function ensureExpoPortArg(command2, args2, port) {
23966
24008
  const hasPort = args2.some((a) => a === "--port" || a.startsWith("--port="));
23967
24009
  if (hasPort) return [...args2];
23968
24010
  const out2 = [...args2];
23969
- if (path51.basename(command2) === "npm" && !out2.includes("--")) out2.push("--");
24011
+ if (path52.basename(command2) === "npm" && !out2.includes("--")) out2.push("--");
23970
24012
  out2.push("--port", String(port));
23971
24013
  return out2;
23972
24014
  }
@@ -24594,8 +24636,8 @@ function isJsInstallCommand(cmd, args2) {
24594
24636
  }
24595
24637
 
24596
24638
  // src/services/preview/script-candidates.ts
24597
- var fs46 = __toESM(require("fs"));
24598
- var path54 = __toESM(require("path"));
24639
+ var fs47 = __toESM(require("fs"));
24640
+ var path55 = __toESM(require("path"));
24599
24641
  var EXCLUDE_RE = /(^|:)(deploy|publish|release|build|test|e2e|lint|format|typecheck|type-check|clean|prebuild|postinstall|preinstall|prepare|install|migrate|seed|db|prisma|codegen|storybook-build)(:|$)/i;
24600
24642
  var EXCLUDE_BODY_RE = /\b(run:android|run:ios|gradlew|fastlane|xcodebuild|eas build|eas submit)\b/i;
24601
24643
  var MAX_APPS = 40;
@@ -24613,7 +24655,7 @@ function frameworkFor(pkg, body) {
24613
24655
  }
24614
24656
  function readPkg(file) {
24615
24657
  try {
24616
- return JSON.parse(fs46.readFileSync(file, "utf8"));
24658
+ return JSON.parse(fs47.readFileSync(file, "utf8"));
24617
24659
  } catch {
24618
24660
  return null;
24619
24661
  }
@@ -24623,7 +24665,7 @@ function expandGlob(root, pattern) {
24623
24665
  if (!clean.endsWith("/*")) return [clean];
24624
24666
  const base = clean.slice(0, -2);
24625
24667
  try {
24626
- return fs46.readdirSync(path54.join(root, base), { withFileTypes: true }).filter((d3) => d3.isDirectory() && !d3.name.startsWith(".") && d3.name !== "node_modules").map((d3) => path54.join(base, d3.name));
24668
+ return fs47.readdirSync(path55.join(root, base), { withFileTypes: true }).filter((d3) => d3.isDirectory() && !d3.name.startsWith(".") && d3.name !== "node_modules").map((d3) => path55.join(base, d3.name));
24627
24669
  } catch {
24628
24670
  return [];
24629
24671
  }
@@ -24632,7 +24674,7 @@ function workspaceDirs(root, rootPkg) {
24632
24674
  const ws = rootPkg?.workspaces;
24633
24675
  const patterns = Array.isArray(ws) ? ws : ws?.packages ?? [];
24634
24676
  try {
24635
- const pnpm = fs46.readFileSync(path54.join(root, "pnpm-workspace.yaml"), "utf8");
24677
+ const pnpm = fs47.readFileSync(path55.join(root, "pnpm-workspace.yaml"), "utf8");
24636
24678
  for (const m of pnpm.matchAll(/^\s*-\s*['"]?([^'"\n]+)['"]?\s*$/gm)) patterns.push(m[1]);
24637
24679
  } catch {
24638
24680
  }
@@ -24643,14 +24685,14 @@ function workspaceDirs(root, rootPkg) {
24643
24685
  }
24644
24686
  function listScriptCandidates(root) {
24645
24687
  const out2 = [];
24646
- const rootPkg = readPkg(path54.join(root, "package.json"));
24688
+ const rootPkg = readPkg(path55.join(root, "package.json"));
24647
24689
  const add = (pkg, appDir) => {
24648
24690
  for (const [script, body] of Object.entries(pkg.scripts ?? {})) {
24649
24691
  if (out2.length >= MAX_CANDIDATES) return;
24650
24692
  if (EXCLUDE_RE.test(script) || EXCLUDE_BODY_RE.test(body)) continue;
24651
24693
  const fw = frameworkFor(pkg, body);
24652
24694
  out2.push({
24653
- app: pkg.name ?? (appDir === "." ? path54.basename(root) : appDir),
24695
+ app: pkg.name ?? (appDir === "." ? path55.basename(root) : appDir),
24654
24696
  appDir,
24655
24697
  script,
24656
24698
  body,
@@ -24664,8 +24706,8 @@ function listScriptCandidates(root) {
24664
24706
  };
24665
24707
  if (rootPkg) add(rootPkg, ".");
24666
24708
  for (const dir of workspaceDirs(root, rootPkg)) {
24667
- const pkg = readPkg(path54.join(root, dir, "package.json"));
24668
- if (pkg) add(pkg, dir.split(path54.sep).join("/"));
24709
+ const pkg = readPkg(path55.join(root, dir, "package.json"));
24710
+ if (pkg) add(pkg, dir.split(path55.sep).join("/"));
24669
24711
  }
24670
24712
  return out2;
24671
24713
  }
@@ -25417,31 +25459,31 @@ async function readActivePreviewMarker(cwd, homeDir2) {
25417
25459
  }
25418
25460
 
25419
25461
  // src/agents/acp/guardrail-config.ts
25420
- var fs51 = __toESM(require("fs"));
25421
- var path59 = __toESM(require("path"));
25422
- var os36 = __toESM(require("os"));
25462
+ var fs52 = __toESM(require("fs"));
25463
+ var path60 = __toESM(require("path"));
25464
+ var os37 = __toESM(require("os"));
25423
25465
  var current = null;
25424
- function guardrailConfigPath(homeDir2 = os36.homedir()) {
25425
- return path59.join(homeDir2, ".codeam", "guardrails.json");
25466
+ function guardrailConfigPath(homeDir2 = os37.homedir()) {
25467
+ return path60.join(homeDir2, ".codeam", "guardrails.json");
25426
25468
  }
25427
- function loadGuardrailPolicy(homeDir2 = os36.homedir()) {
25469
+ function loadGuardrailPolicy(homeDir2 = os37.homedir()) {
25428
25470
  try {
25429
- current = normalizeGuardrailPolicy(JSON.parse(fs51.readFileSync(guardrailConfigPath(homeDir2), "utf8")));
25471
+ current = normalizeGuardrailPolicy(JSON.parse(fs52.readFileSync(guardrailConfigPath(homeDir2), "utf8")));
25430
25472
  } catch {
25431
25473
  current = { ...DEFAULT_GUARDRAIL_POLICY };
25432
25474
  }
25433
25475
  return current;
25434
25476
  }
25435
- function getGuardrailPolicy(homeDir2 = os36.homedir()) {
25477
+ function getGuardrailPolicy(homeDir2 = os37.homedir()) {
25436
25478
  return current ?? loadGuardrailPolicy(homeDir2);
25437
25479
  }
25438
- function setGuardrailPolicy(raw, homeDir2 = os36.homedir()) {
25480
+ function setGuardrailPolicy(raw, homeDir2 = os37.homedir()) {
25439
25481
  const next = normalizeGuardrailPolicy(raw);
25440
25482
  current = next;
25441
25483
  try {
25442
25484
  const p2 = guardrailConfigPath(homeDir2);
25443
- fs51.mkdirSync(path59.dirname(p2), { recursive: true });
25444
- fs51.writeFileSync(p2, JSON.stringify(next, null, 2));
25485
+ fs52.mkdirSync(path60.dirname(p2), { recursive: true });
25486
+ fs52.writeFileSync(p2, JSON.stringify(next, null, 2));
25445
25487
  } catch {
25446
25488
  }
25447
25489
  return next;
@@ -25457,22 +25499,22 @@ function shouldOfferOneMRecovery(opts) {
25457
25499
  }
25458
25500
 
25459
25501
  // src/commands/host/house-proxy-config.ts
25460
- var fs52 = __toESM(require("fs"));
25461
- var os37 = __toESM(require("os"));
25462
- var path60 = __toESM(require("path"));
25502
+ var fs53 = __toESM(require("fs"));
25503
+ var os38 = __toESM(require("os"));
25504
+ var path61 = __toESM(require("path"));
25463
25505
  function houseProxyConfigPath() {
25464
- return path60.join(os37.homedir(), ".codeam", "house-proxy.json");
25506
+ return path61.join(os38.homedir(), ".codeam", "house-proxy.json");
25465
25507
  }
25466
25508
  var DEPLOY_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
25467
25509
  function deployHouseProxyConfigPath(deployId) {
25468
25510
  if (!DEPLOY_ID_RE.test(deployId) || deployId.includes("..")) return null;
25469
- return path60.join(os37.homedir(), ".codeam", "house-proxy", `${deployId}.json`);
25511
+ return path61.join(os38.homedir(), ".codeam", "house-proxy", `${deployId}.json`);
25470
25512
  }
25471
25513
  function writeJson0600(file, value) {
25472
- fs52.mkdirSync(path60.dirname(file), { recursive: true, mode: 448 });
25514
+ fs53.mkdirSync(path61.dirname(file), { recursive: true, mode: 448 });
25473
25515
  const tmp = `${file}.tmp-${process.pid}`;
25474
- fs52.writeFileSync(tmp, JSON.stringify(value, null, 2), { encoding: "utf8", mode: 384 });
25475
- fs52.renameSync(tmp, file);
25516
+ fs53.writeFileSync(tmp, JSON.stringify(value, null, 2), { encoding: "utf8", mode: 384 });
25517
+ fs53.renameSync(tmp, file);
25476
25518
  restrictToOwner(file);
25477
25519
  }
25478
25520
  function persistHouseProxyConfig(config, deployId) {
@@ -25489,7 +25531,7 @@ function persistHouseProxyConfig(config, deployId) {
25489
25531
  }
25490
25532
  function clearHouseProxyConfig(deployId) {
25491
25533
  try {
25492
- fs52.rmSync(houseProxyConfigPath(), { force: true });
25534
+ fs53.rmSync(houseProxyConfigPath(), { force: true });
25493
25535
  const perDeploy = deployId ? deployHouseProxyConfigPath(deployId) : null;
25494
25536
  if (perDeploy) writeJson0600(perDeploy, { none: true });
25495
25537
  } catch {
@@ -25512,12 +25554,12 @@ function houseProxyTokenExpiring(token, nowSec, windowSec = HOUSE_PROXY_REFRESH_
25512
25554
  }
25513
25555
  function persistedConfigFile(deployId) {
25514
25556
  const perDeploy = deployId ? deployHouseProxyConfigPath(deployId) : null;
25515
- const file = perDeploy && fs52.existsSync(perDeploy) ? perDeploy : houseProxyConfigPath();
25516
- return fs52.existsSync(file) ? file : null;
25557
+ const file = perDeploy && fs53.existsSync(perDeploy) ? perDeploy : houseProxyConfigPath();
25558
+ return fs53.existsSync(file) ? file : null;
25517
25559
  }
25518
25560
  function readConfigObject(file) {
25519
25561
  try {
25520
- const parsed = JSON.parse(fs52.readFileSync(file, "utf8"));
25562
+ const parsed = JSON.parse(fs53.readFileSync(file, "utf8"));
25521
25563
  return typeof parsed === "object" && parsed !== null ? parsed : null;
25522
25564
  } catch {
25523
25565
  return null;
@@ -25550,8 +25592,8 @@ function rewriteHouseProxyToken(deployId, freshToken) {
25550
25592
  function readHouseProxyChildEnv(deployId) {
25551
25593
  try {
25552
25594
  const perDeploy = deployId ? deployHouseProxyConfigPath(deployId) : null;
25553
- const file = perDeploy && fs52.existsSync(perDeploy) ? perDeploy : houseProxyConfigPath();
25554
- const raw = fs52.readFileSync(file, "utf8");
25595
+ const file = perDeploy && fs53.existsSync(perDeploy) ? perDeploy : houseProxyConfigPath();
25596
+ const raw = fs53.readFileSync(file, "utf8");
25555
25597
  const parsed = JSON.parse(raw);
25556
25598
  if (typeof parsed !== "object" || parsed === null) return {};
25557
25599
  const o = parsed;
@@ -25661,9 +25703,9 @@ function pickHouseProxyEnv(env) {
25661
25703
  }
25662
25704
 
25663
25705
  // src/lib/provider-routing.ts
25664
- var fs53 = __toESM(require("fs"));
25665
- var os38 = __toESM(require("os"));
25666
- var path61 = __toESM(require("path"));
25706
+ var fs54 = __toESM(require("fs"));
25707
+ var os39 = __toESM(require("os"));
25708
+ var path62 = __toESM(require("path"));
25667
25709
  var PROVIDER_BASE_URL_ENV_KEYS = [
25668
25710
  "ANTHROPIC_BASE_URL",
25669
25711
  "OPENAI_BASE_URL",
@@ -25685,15 +25727,15 @@ function redactUrlToOrigin(raw) {
25685
25727
  }
25686
25728
  }
25687
25729
  function readOpencodeProviderOrigins(opts = {}) {
25688
- const home = opts.homeDir ?? os38.homedir();
25689
- const readFile8 = opts.readFile ?? ((f) => fs53.readFileSync(f, "utf8"));
25730
+ const home = opts.homeDir ?? os39.homedir();
25731
+ const readFile8 = opts.readFile ?? ((f) => fs54.readFileSync(f, "utf8"));
25690
25732
  const candidates = [];
25691
25733
  if (opts.cwd) {
25692
- candidates.push(path61.join(opts.cwd, "opencode.json"), path61.join(opts.cwd, "opencode.jsonc"));
25734
+ candidates.push(path62.join(opts.cwd, "opencode.json"), path62.join(opts.cwd, "opencode.jsonc"));
25693
25735
  }
25694
25736
  candidates.push(
25695
- path61.join(home, ".config", "opencode", "opencode.json"),
25696
- path61.join(home, ".config", "opencode", "opencode.jsonc")
25737
+ path62.join(home, ".config", "opencode", "opencode.json"),
25738
+ path62.join(home, ".config", "opencode", "opencode.jsonc")
25697
25739
  );
25698
25740
  const out2 = [];
25699
25741
  const seen2 = /* @__PURE__ */ new Set();
@@ -26028,19 +26070,19 @@ function adapterExitMessage(opts) {
26028
26070
 
26029
26071
  // src/services/preview/start-orchestrator.ts
26030
26072
  var import_child_process20 = require("child_process");
26031
- var fs56 = __toESM(require("fs"));
26032
- var path64 = __toESM(require("path"));
26073
+ var fs57 = __toESM(require("fs"));
26074
+ var path65 = __toESM(require("path"));
26033
26075
  var import_which3 = __toESM(require("which"));
26034
26076
 
26035
26077
  // src/services/project-env/index.ts
26036
26078
  var import_fs6 = require("fs");
26037
- var path63 = __toESM(require("path"));
26079
+ var path64 = __toESM(require("path"));
26038
26080
 
26039
26081
  // src/beads/project-key.ts
26040
26082
  var import_child_process19 = require("child_process");
26041
26083
  var crypto2 = __toESM(require("crypto"));
26042
- var fs54 = __toESM(require("fs"));
26043
- var path62 = __toESM(require("path"));
26084
+ var fs55 = __toESM(require("fs"));
26085
+ var path63 = __toESM(require("path"));
26044
26086
  function normalizeOrigin(raw) {
26045
26087
  const trimmed = raw.trim();
26046
26088
  if (!trimmed) return null;
@@ -26066,17 +26108,17 @@ function normalizeOrigin(raw) {
26066
26108
  return `${host2}/${pathPart}`;
26067
26109
  }
26068
26110
  function findRepoRoot(cwd) {
26069
- let dir = path62.resolve(cwd);
26111
+ let dir = path63.resolve(cwd);
26070
26112
  const seen2 = /* @__PURE__ */ new Set();
26071
26113
  for (let i = 0; i < 256; i++) {
26072
26114
  if (seen2.has(dir)) return null;
26073
26115
  seen2.add(dir);
26074
26116
  try {
26075
- const stat3 = fs54.statSync(path62.join(dir, ".git"), { throwIfNoEntry: false });
26117
+ const stat3 = fs55.statSync(path63.join(dir, ".git"), { throwIfNoEntry: false });
26076
26118
  if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
26077
26119
  } catch {
26078
26120
  }
26079
- const parent = path62.dirname(dir);
26121
+ const parent = path63.dirname(dir);
26080
26122
  if (parent === dir) return null;
26081
26123
  dir = parent;
26082
26124
  }
@@ -26087,7 +26129,7 @@ var _execSeam3 = {
26087
26129
  const out2 = (0, import_child_process19.execFileSync)(file, args2, opts);
26088
26130
  return typeof out2 === "string" ? out2 : out2.toString("utf8");
26089
26131
  },
26090
- realpath: (p2) => fs54.realpathSync(p2)
26132
+ realpath: (p2) => fs55.realpathSync(p2)
26091
26133
  };
26092
26134
  function readOrigin(cwd) {
26093
26135
  try {
@@ -26116,7 +26158,7 @@ function deriveProjectIdentity(cwd = process.cwd()) {
26116
26158
  } catch {
26117
26159
  }
26118
26160
  const hash = crypto2.createHash("sha256").update(real).digest("hex");
26119
- return { projectKey: `path:${hash}`, projectLabel: path62.basename(real) || "project" };
26161
+ return { projectKey: `path:${hash}`, projectLabel: path63.basename(real) || "project" };
26120
26162
  }
26121
26163
 
26122
26164
  // src/services/project-env/index.ts
@@ -26129,7 +26171,7 @@ async function readIfExists(p2) {
26129
26171
  }
26130
26172
  async function syncProjectEnvUp(cwd, ctx) {
26131
26173
  if (!ctx.pluginAuthToken) return;
26132
- const content = await readIfExists(path63.join(cwd, ".env"));
26174
+ const content = await readIfExists(path64.join(cwd, ".env"));
26133
26175
  if (content == null) return;
26134
26176
  try {
26135
26177
  const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
@@ -26151,7 +26193,7 @@ async function syncProjectEnvUp(cwd, ctx) {
26151
26193
  }
26152
26194
  async function restoreProjectEnvIfMissing(cwd, ctx) {
26153
26195
  if (!ctx.pluginAuthToken) return false;
26154
- const envPath = path63.join(cwd, ".env");
26196
+ const envPath = path64.join(cwd, ".env");
26155
26197
  if (await readIfExists(envPath) != null) return false;
26156
26198
  try {
26157
26199
  const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
@@ -26162,7 +26204,7 @@ async function restoreProjectEnvIfMissing(cwd, ctx) {
26162
26204
  projectKey
26163
26205
  });
26164
26206
  if (!stored) return false;
26165
- const tmp = path63.join(cwd, ".env.codeam-restore.tmp");
26207
+ const tmp = path64.join(cwd, ".env.codeam-restore.tmp");
26166
26208
  await import_fs6.promises.writeFile(tmp, stored.content, { encoding: "utf8", mode: 384 });
26167
26209
  await import_fs6.promises.rename(tmp, envPath);
26168
26210
  log.info("project-env", `restored .env (${stored.keyCount} vars) for ${projectLabel}`);
@@ -26926,8 +26968,8 @@ function normalizeDetectionForSpawn(detection, cwd) {
26926
26968
  if (args2.length === 0) return detection;
26927
26969
  const binName = args2[0];
26928
26970
  if (binName.startsWith("-")) return detection;
26929
- const binPath = path64.join(cwd, "node_modules", ".bin", binName);
26930
- if (!fs56.existsSync(binPath)) return detection;
26971
+ const binPath = path65.join(cwd, "node_modules", ".bin", binName);
26972
+ if (!fs57.existsSync(binPath)) return detection;
26931
26973
  return {
26932
26974
  ...detection,
26933
26975
  command: binPath,
@@ -27340,9 +27382,9 @@ async function bringUpPublicUrl(ctx, tunnelPort) {
27340
27382
 
27341
27383
  // src/beads/bd-adapter.ts
27342
27384
  var import_child_process21 = require("child_process");
27343
- var fs57 = __toESM(require("fs"));
27344
- var os39 = __toESM(require("os"));
27345
- var path65 = __toESM(require("path"));
27385
+ var fs58 = __toESM(require("fs"));
27386
+ var os40 = __toESM(require("os"));
27387
+ var path66 = __toESM(require("path"));
27346
27388
  var BD_PACKAGE = "@beads/bd";
27347
27389
  function resolveBundledBdBinary() {
27348
27390
  return _resolveSeam.resolveBundled();
@@ -27354,11 +27396,11 @@ function _defaultResolveBundled() {
27354
27396
  } catch {
27355
27397
  return null;
27356
27398
  }
27357
- const binDir = path65.join(path65.dirname(pkgJsonPath), "bin");
27399
+ const binDir = path66.join(path66.dirname(pkgJsonPath), "bin");
27358
27400
  const binaryName = process.platform === "win32" ? "bd.exe" : "bd";
27359
- const binaryPath = path65.join(binDir, binaryName);
27401
+ const binaryPath = path66.join(binDir, binaryName);
27360
27402
  try {
27361
- fs57.accessSync(binaryPath, fs57.constants.F_OK);
27403
+ fs58.accessSync(binaryPath, fs58.constants.F_OK);
27362
27404
  return binaryPath;
27363
27405
  } catch {
27364
27406
  return null;
@@ -27368,13 +27410,13 @@ function resolveBdOnPath() {
27368
27410
  return _resolveSeam.resolveOnPath();
27369
27411
  }
27370
27412
  function _defaultResolveOnPath() {
27371
- const dirs = (process.env.PATH ?? "").split(path65.delimiter).filter(Boolean);
27413
+ const dirs = (process.env.PATH ?? "").split(path66.delimiter).filter(Boolean);
27372
27414
  const candidates = process.platform === "win32" ? ["bd.exe", "bd.cmd", "bd"] : ["bd"];
27373
27415
  for (const dir of dirs) {
27374
27416
  for (const candidate of candidates) {
27375
- const full = path65.join(dir, candidate);
27417
+ const full = path66.join(dir, candidate);
27376
27418
  try {
27377
- fs57.accessSync(full, fs57.constants.F_OK);
27419
+ fs58.accessSync(full, fs58.constants.F_OK);
27378
27420
  return full;
27379
27421
  } catch {
27380
27422
  }
@@ -27459,7 +27501,7 @@ var BdAdapter = class {
27459
27501
  const env = { ...process.env };
27460
27502
  if (!env.HOME) {
27461
27503
  try {
27462
- const home = os39.homedir();
27504
+ const home = os40.homedir();
27463
27505
  if (home) env.HOME = home;
27464
27506
  } catch {
27465
27507
  }
@@ -27549,9 +27591,9 @@ function coerceIssue(row, projectKey) {
27549
27591
 
27550
27592
  // src/beads/provisioner.ts
27551
27593
  var import_child_process24 = require("child_process");
27552
- var fs59 = __toESM(require("fs"));
27553
- var os41 = __toESM(require("os"));
27554
- var path67 = __toESM(require("path"));
27594
+ var fs60 = __toESM(require("fs"));
27595
+ var os42 = __toESM(require("os"));
27596
+ var path68 = __toESM(require("path"));
27555
27597
 
27556
27598
  // src/beads/install-bd.ts
27557
27599
  var import_child_process22 = require("child_process");
@@ -27616,9 +27658,9 @@ async function installBd(platform3 = process.platform) {
27616
27658
 
27617
27659
  // src/beads/install-dolt.ts
27618
27660
  var import_child_process23 = require("child_process");
27619
- var fs58 = __toESM(require("fs"));
27620
- var os40 = __toESM(require("os"));
27621
- var path66 = __toESM(require("path"));
27661
+ var fs59 = __toESM(require("fs"));
27662
+ var os41 = __toESM(require("os"));
27663
+ var path67 = __toESM(require("path"));
27622
27664
  var DOLT_INSTALL_SH_URL = "https://github.com/dolthub/dolt/releases/latest/download/install.sh";
27623
27665
  var DOLT_MSI_URL = "https://github.com/dolthub/dolt/releases/latest/download/dolt-windows-amd64.msi";
27624
27666
  function resolveDoltInstallStrategy(platform3) {
@@ -27707,14 +27749,14 @@ async function installDoltToDir(targetDir, platform3 = process.platform, arch2 =
27707
27749
  return result;
27708
27750
  }
27709
27751
  var _doltPathSeam = {
27710
- homedir: () => os40.homedir(),
27752
+ homedir: () => os41.homedir(),
27711
27753
  getPath: () => process.env.PATH ?? "",
27712
27754
  setPath: (p2) => {
27713
27755
  process.env.PATH = p2;
27714
27756
  },
27715
27757
  exists: (p2) => {
27716
27758
  try {
27717
- fs58.accessSync(p2, fs58.constants.F_OK);
27759
+ fs59.accessSync(p2, fs59.constants.F_OK);
27718
27760
  return true;
27719
27761
  } catch {
27720
27762
  return false;
@@ -27725,7 +27767,7 @@ function doltBinaryNames(platform3) {
27725
27767
  return platform3 === "win32" ? ["dolt.exe", "dolt.cmd", "dolt"] : ["dolt"];
27726
27768
  }
27727
27769
  function knownDoltDirs(platform3) {
27728
- const P3 = platform3 === "win32" ? path66.win32 : path66.posix;
27770
+ const P3 = platform3 === "win32" ? path67.win32 : path67.posix;
27729
27771
  const home = _doltPathSeam.homedir();
27730
27772
  if (platform3 === "win32") {
27731
27773
  return [
@@ -27741,7 +27783,7 @@ function knownDoltDirs(platform3) {
27741
27783
  ].filter(Boolean);
27742
27784
  }
27743
27785
  function ensureDoltResolvable(platform3 = process.platform) {
27744
- const P3 = platform3 === "win32" ? path66.win32 : path66.posix;
27786
+ const P3 = platform3 === "win32" ? path67.win32 : path67.posix;
27745
27787
  const delim = platform3 === "win32" ? ";" : ":";
27746
27788
  const names = doltBinaryNames(platform3);
27747
27789
  const pathDirs = _doltPathSeam.getPath().split(delim).filter(Boolean);
@@ -27918,10 +27960,10 @@ var _provisionSeam = {
27918
27960
  /** Does the project's git remote carry Dolt data (`refs/dolt/data`)? */
27919
27961
  remoteHasDoltData,
27920
27962
  /** Throwaway cwd for a user-level-only `bd setup` (see GLOBAL_ONLY_RECIPES). */
27921
- makeSetupCwd: () => fs59.mkdtempSync(path67.join(os41.tmpdir(), "codeam-bd-setup-")),
27963
+ makeSetupCwd: () => fs60.mkdtempSync(path68.join(os42.tmpdir(), "codeam-bd-setup-")),
27922
27964
  removeSetupCwd: (dir) => {
27923
27965
  try {
27924
- fs59.rmSync(dir, { recursive: true, force: true });
27966
+ fs60.rmSync(dir, { recursive: true, force: true });
27925
27967
  } catch {
27926
27968
  }
27927
27969
  }
@@ -27943,17 +27985,17 @@ function remoteHasDoltData(cwd) {
27943
27985
  }
27944
27986
  var _linkSeam = {
27945
27987
  platform: () => process.platform,
27946
- homedir: () => os41.homedir(),
27988
+ homedir: () => os42.homedir(),
27947
27989
  isWritableDir: (dir) => {
27948
27990
  try {
27949
- fs59.accessSync(dir, fs59.constants.W_OK);
27991
+ fs60.accessSync(dir, fs60.constants.W_OK);
27950
27992
  return true;
27951
27993
  } catch {
27952
27994
  return false;
27953
27995
  }
27954
27996
  },
27955
27997
  ensureDir: (dir) => {
27956
- fs59.mkdirSync(dir, { recursive: true });
27998
+ fs60.mkdirSync(dir, { recursive: true });
27957
27999
  },
27958
28000
  /**
27959
28001
  * A directory to symlink `bd` into so the AGENT's shell + Claude Code's
@@ -27974,9 +28016,9 @@ var _linkSeam = {
27974
28016
  * which `linkBdOntoPath` creates if missing.
27975
28017
  */
27976
28018
  cliBinDir: () => {
27977
- const pathDirs = (process.env.PATH ?? "").split(path67.delimiter).filter(Boolean);
28019
+ const pathDirs = (process.env.PATH ?? "").split(path68.delimiter).filter(Boolean);
27978
28020
  const home = _linkSeam.homedir();
27979
- const localBin = home ? path67.join(home, ".local", "bin") : null;
28021
+ const localBin = home ? path68.join(home, ".local", "bin") : null;
27980
28022
  if (localBin) {
27981
28023
  try {
27982
28024
  _linkSeam.ensureDir(localBin);
@@ -27986,16 +28028,16 @@ var _linkSeam = {
27986
28028
  const candidates = [];
27987
28029
  if (localBin) candidates.push(localBin);
27988
28030
  try {
27989
- candidates.push(path67.dirname(process.execPath));
28031
+ candidates.push(path68.dirname(process.execPath));
27990
28032
  } catch {
27991
28033
  }
27992
28034
  candidates.push("/usr/local/bin");
27993
28035
  const entry = process.argv[1];
27994
28036
  if (entry) {
27995
28037
  try {
27996
- candidates.push(path67.dirname(fs59.realpathSync(entry)));
28038
+ candidates.push(path68.dirname(fs60.realpathSync(entry)));
27997
28039
  } catch {
27998
- candidates.push(path67.dirname(entry));
28040
+ candidates.push(path68.dirname(entry));
27999
28041
  }
28000
28042
  }
28001
28043
  const onPathWritable = candidates.find(
@@ -28007,20 +28049,20 @@ var _linkSeam = {
28007
28049
  /** Current symlink target at `linkPath`, or null when absent / not a link. */
28008
28050
  readlink: (linkPath) => {
28009
28051
  try {
28010
- return fs59.readlinkSync(linkPath);
28052
+ return fs60.readlinkSync(linkPath);
28011
28053
  } catch {
28012
28054
  return null;
28013
28055
  }
28014
28056
  },
28015
- unlink: (linkPath) => fs59.unlinkSync(linkPath),
28016
- symlink: (target, linkPath) => fs59.symlinkSync(target, linkPath)
28057
+ unlink: (linkPath) => fs60.unlinkSync(linkPath),
28058
+ symlink: (target, linkPath) => fs60.symlinkSync(target, linkPath)
28017
28059
  };
28018
28060
  function linkBdOntoPath(binaryPath) {
28019
28061
  if (_linkSeam.platform() === "win32") return;
28020
28062
  const binDir = _linkSeam.cliBinDir();
28021
28063
  if (!binDir) return;
28022
28064
  _linkSeam.ensureDir(binDir);
28023
- const linkPath = path67.join(binDir, "bd");
28065
+ const linkPath = path68.join(binDir, "bd");
28024
28066
  if (linkPath === binaryPath) return;
28025
28067
  const current2 = _linkSeam.readlink(linkPath);
28026
28068
  if (current2 === binaryPath) return;
@@ -28239,16 +28281,16 @@ function dedupeRecipes(agents) {
28239
28281
  }
28240
28282
  function ensureLocalGitExclude(cwd, patterns) {
28241
28283
  try {
28242
- const gitDir = path67.join(cwd, ".git");
28243
- if (!fs59.statSync(gitDir).isDirectory()) return;
28244
- const file = path67.join(gitDir, "info", "exclude");
28245
- fs59.mkdirSync(path67.dirname(file), { recursive: true });
28246
- const current2 = fs59.existsSync(file) ? fs59.readFileSync(file, "utf8") : "";
28284
+ const gitDir = path68.join(cwd, ".git");
28285
+ if (!fs60.statSync(gitDir).isDirectory()) return;
28286
+ const file = path68.join(gitDir, "info", "exclude");
28287
+ fs60.mkdirSync(path68.dirname(file), { recursive: true });
28288
+ const current2 = fs60.existsSync(file) ? fs60.readFileSync(file, "utf8") : "";
28247
28289
  const have = new Set(current2.split(/\r?\n/).map((l) => l.trim()));
28248
28290
  const missing = patterns.filter((p2) => !have.has(p2));
28249
28291
  if (missing.length === 0) return;
28250
28292
  const prefix = current2.length > 0 && !current2.endsWith("\n") ? "\n" : "";
28251
- fs59.appendFileSync(file, `${prefix}# CodeAgent: beads state stays local
28293
+ fs60.appendFileSync(file, `${prefix}# CodeAgent: beads state stays local
28252
28294
  ${missing.join("\n")}
28253
28295
  `);
28254
28296
  } catch {
@@ -28257,7 +28299,7 @@ ${missing.join("\n")}
28257
28299
 
28258
28300
  // src/beads/watcher.ts
28259
28301
  var crypto4 = __toESM(require("crypto"));
28260
- var path68 = __toESM(require("path"));
28302
+ var path69 = __toESM(require("path"));
28261
28303
  var API_BASE5 = resolveApiBaseUrl();
28262
28304
  var DEBOUNCE_MS2 = 400;
28263
28305
  var ZERO_SUMMARY = {
@@ -28281,7 +28323,7 @@ var BeadsWatcher = class {
28281
28323
  constructor(opts) {
28282
28324
  this.opts = opts;
28283
28325
  this.bd = opts.adapter ?? new BdAdapter({ cwd: opts.cwd, beadsDir: opts.beadsDir });
28284
- this.feedPath = opts.feedPath ?? path68.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
28326
+ this.feedPath = opts.feedPath ?? path69.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
28285
28327
  this.apiBase = opts.apiBaseUrl ?? API_BASE5;
28286
28328
  }
28287
28329
  opts;
@@ -28926,8 +28968,8 @@ function cleanupAttachmentTempFiles() {
28926
28968
  function saveFilesTemp(files) {
28927
28969
  return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
28928
28970
  const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
28929
- const tmpPath = path73.join(os47.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
28930
- fs65.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
28971
+ const tmpPath = path74.join(os48.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
28972
+ fs66.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
28931
28973
  pendingAttachmentFiles.add(tmpPath);
28932
28974
  return tmpPath;
28933
28975
  });
@@ -29173,10 +29215,10 @@ var listFiles = async (ctx, cmd, parsed) => {
29173
29215
  await ctx.relay.sendResult(cmd.id, "completed", result);
29174
29216
  };
29175
29217
  var envReadH = async (ctx, cmd) => {
29176
- const envPath = path73.join(process.cwd(), ".env");
29218
+ const envPath = path74.join(process.cwd(), ".env");
29177
29219
  await restoreProjectEnvIfMissing(process.cwd(), ctx);
29178
29220
  try {
29179
- const raw = await fs65.promises.readFile(envPath, "utf8");
29221
+ const raw = await fs66.promises.readFile(envPath, "utf8");
29180
29222
  await ctx.relay.sendResult(cmd.id, "completed", {
29181
29223
  exists: true,
29182
29224
  vars: parseDotenv(raw)
@@ -29205,7 +29247,7 @@ var envParseH = async (ctx, cmd, parsed) => {
29205
29247
  const existing = /* @__PURE__ */ new Map();
29206
29248
  if (!replace) {
29207
29249
  try {
29208
- const raw = await fs65.promises.readFile(path73.join(process.cwd(), ".env"), "utf8");
29250
+ const raw = await fs66.promises.readFile(path74.join(process.cwd(), ".env"), "utf8");
29209
29251
  for (const v of parseDotenv(raw)) existing.set(v.key, v.value);
29210
29252
  } catch {
29211
29253
  }
@@ -29245,15 +29287,15 @@ var envWriteH = async (ctx, cmd, parsed) => {
29245
29287
  }
29246
29288
  seen2.add(v.key);
29247
29289
  }
29248
- const envPath = path73.join(process.cwd(), ".env");
29249
- const tmpPath = path73.join(process.cwd(), ".env.codeam.tmp");
29290
+ const envPath = path74.join(process.cwd(), ".env");
29291
+ const tmpPath = path74.join(process.cwd(), ".env.codeam.tmp");
29250
29292
  try {
29251
- await fs65.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
29252
- await fs65.promises.rename(tmpPath, envPath);
29293
+ await fs66.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
29294
+ await fs66.promises.rename(tmpPath, envPath);
29253
29295
  await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
29254
29296
  void syncProjectEnvUp(process.cwd(), ctx);
29255
29297
  } catch (err) {
29256
- await fs65.promises.rm(tmpPath, { force: true }).catch(() => void 0);
29298
+ await fs66.promises.rm(tmpPath, { force: true }).catch(() => void 0);
29257
29299
  await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
29258
29300
  }
29259
29301
  };
@@ -29602,9 +29644,9 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
29602
29644
  function buildNpmInstallInvocation(opts) {
29603
29645
  const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
29604
29646
  const execPath = opts?.execPath ?? process.execPath;
29605
- const exists2 = opts?.existsSync ?? fs65.existsSync;
29647
+ const exists2 = opts?.existsSync ?? fs66.existsSync;
29606
29648
  const platform3 = opts?.platform ?? process.platform;
29607
- const p2 = platform3 === "win32" ? path73.win32 : path73.posix;
29649
+ const p2 = platform3 === "win32" ? path74.win32 : path74.posix;
29608
29650
  const normalized = entryScript.split(/[\\/]/).join("/");
29609
29651
  const marker = "/lib/node_modules/codeam-cli/";
29610
29652
  const markerIdx = normalized.indexOf(marker);
@@ -29623,7 +29665,7 @@ function isPermissionError(stderr) {
29623
29665
  function resolveGlobalNodeModulesDir(opts) {
29624
29666
  const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
29625
29667
  const platform3 = opts?.platform ?? process.platform;
29626
- const p2 = platform3 === "win32" ? path73.win32 : path73.posix;
29668
+ const p2 = platform3 === "win32" ? path74.win32 : path74.posix;
29627
29669
  const marker = "/lib/node_modules/codeam-cli/";
29628
29670
  const markerIdx = entryScript.split(/[\\/]/).join("/").indexOf(marker);
29629
29671
  if (markerIdx <= 0) return null;
@@ -29633,9 +29675,9 @@ function resolveGlobalNodeModulesDir(opts) {
29633
29675
  var STALE_STAGING_AGE_MS = CLI_UPDATE_INSTALL_TIMEOUT_MS;
29634
29676
  function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
29635
29677
  if (!nodeModulesDir) return 0;
29636
- const readdirSync18 = deps?.readdirSync ?? fs65.readdirSync;
29637
- const statSync17 = deps?.statSync ?? fs65.statSync;
29638
- const rmSync15 = deps?.rmSync ?? fs65.rmSync;
29678
+ const readdirSync18 = deps?.readdirSync ?? fs66.readdirSync;
29679
+ const statSync17 = deps?.statSync ?? fs66.statSync;
29680
+ const rmSync15 = deps?.rmSync ?? fs66.rmSync;
29639
29681
  let removed = 0;
29640
29682
  let entries2;
29641
29683
  try {
@@ -29645,7 +29687,7 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
29645
29687
  }
29646
29688
  for (const name of entries2) {
29647
29689
  if (!/^\.codeam-cli-/.test(name)) continue;
29648
- const full = path73.join(nodeModulesDir, name);
29690
+ const full = path74.join(nodeModulesDir, name);
29649
29691
  try {
29650
29692
  const st3 = statSync17(full);
29651
29693
  if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
@@ -30304,17 +30346,19 @@ function startPreviewFromDetection(ctx, detection, pluginAuthToken, opts = {}) {
30304
30346
  void offerScratchSaveOnce(ctx, pluginAuthToken);
30305
30347
  }
30306
30348
  };
30307
- return runPreviewStart({
30308
- sessionId: ctx.sessionId,
30309
- detection,
30310
- cwd: process.cwd(),
30311
- emit: emit2,
30312
- // Auth for the per-repo `.env` vault restore, performed INSIDE the bring-up
30313
- // (provisionDeps stage, after the reuse short-circuit) so a fresh session of
30314
- // this repo picks up its saved `.env` before the dev server spawns. Optional
30315
- // — a caller without a token just skips the restore.
30316
- projectEnvAuth: { pluginId: ctx.pluginId, pluginAuthToken }
30317
- }).then(() => maybeAttachBuildHeal(ctx, pluginAuthToken)).catch((err) => {
30349
+ return withTurnMarker(
30350
+ () => runPreviewStart({
30351
+ sessionId: ctx.sessionId,
30352
+ detection,
30353
+ cwd: process.cwd(),
30354
+ emit: emit2,
30355
+ // Auth for the per-repo `.env` vault restore, performed INSIDE the bring-up
30356
+ // (provisionDeps stage, after the reuse short-circuit) so a fresh session of
30357
+ // this repo picks up its saved `.env` before the dev server spawns. Optional
30358
+ // — a caller without a token just skips the restore.
30359
+ projectEnvAuth: { pluginId: ctx.pluginId, pluginAuthToken }
30360
+ })
30361
+ ).then(() => maybeAttachBuildHeal(ctx, pluginAuthToken)).catch((err) => {
30318
30362
  const message = err instanceof Error ? err.message : String(err);
30319
30363
  log.warn("preview", `start crashed before ready: ${message}`);
30320
30364
  emit2(USER_EVENTS.PREVIEW_ERROR, {
@@ -30792,7 +30836,7 @@ function resolveTokenValue(args2) {
30792
30836
  if (fileFlag) {
30793
30837
  const path115 = fileFlag.slice("--token-file=".length);
30794
30838
  try {
30795
- const content = fs66.readFileSync(path115, "utf8").trim();
30839
+ const content = fs67.readFileSync(path115, "utf8").trim();
30796
30840
  if (content.length === 0) fail(`--token-file ${path115} is empty`);
30797
30841
  rmIfExistsQuiet(path115);
30798
30842
  return content;
@@ -30886,12 +30930,12 @@ async function claim(token, pluginId, pluginSecretHash) {
30886
30930
  }
30887
30931
  }
30888
30932
  function pairAutoLockPath() {
30889
- return path74.join(os48.homedir(), ".codeam", "pair-auto.lock");
30933
+ return path75.join(os49.homedir(), ".codeam", "pair-auto.lock");
30890
30934
  }
30891
30935
  var procRoot = "/proc";
30892
30936
  function readProcFile(rel) {
30893
30937
  try {
30894
- return fs66.readFileSync(path74.join(procRoot, rel), "utf8");
30938
+ return fs67.readFileSync(path75.join(procRoot, rel), "utf8");
30895
30939
  } catch {
30896
30940
  return void 0;
30897
30941
  }
@@ -30912,7 +30956,7 @@ function currentBootId() {
30912
30956
  function readLockRecord(lockPath) {
30913
30957
  let raw;
30914
30958
  try {
30915
- raw = fs66.readFileSync(lockPath, "utf8");
30959
+ raw = fs67.readFileSync(lockPath, "utf8");
30916
30960
  } catch {
30917
30961
  return void 0;
30918
30962
  }
@@ -30961,7 +31005,7 @@ function isLiveLockHolder(rec) {
30961
31005
  }
30962
31006
  function releaseOwnLock(lockPath) {
30963
31007
  try {
30964
- if (readLockRecord(lockPath)?.pid === process.pid) fs66.unlinkSync(lockPath);
31008
+ if (readLockRecord(lockPath)?.pid === process.pid) fs67.unlinkSync(lockPath);
30965
31009
  } catch {
30966
31010
  }
30967
31011
  }
@@ -30985,7 +31029,7 @@ function snapshotProcessTree(root) {
30985
31029
  const children = /* @__PURE__ */ new Map();
30986
31030
  let entries2 = [];
30987
31031
  try {
30988
- entries2 = fs66.readdirSync(procRoot).filter((e) => /^\d+$/.test(e));
31032
+ entries2 = fs67.readdirSync(procRoot).filter((e) => /^\d+$/.test(e));
30989
31033
  } catch {
30990
31034
  }
30991
31035
  for (const e of entries2) {
@@ -31020,18 +31064,18 @@ function signalProcessTree(refs, signal) {
31020
31064
  }
31021
31065
  function daemonLockPath(sessionId) {
31022
31066
  const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
31023
- return path74.join(os48.homedir(), ".codeam", `daemon-${safe}.lock`);
31067
+ return path75.join(os49.homedir(), ".codeam", `daemon-${safe}.lock`);
31024
31068
  }
31025
31069
  function acquireDaemonLock(sessionId) {
31026
31070
  const lockPath = daemonLockPath(sessionId);
31027
31071
  try {
31028
- fs66.mkdirSync(path74.dirname(lockPath), { recursive: true });
31072
+ fs67.mkdirSync(path75.dirname(lockPath), { recursive: true });
31029
31073
  try {
31030
- fs66.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
31074
+ fs67.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
31031
31075
  } catch (e) {
31032
31076
  if (e.code !== "EEXIST") throw e;
31033
31077
  if (isLiveLockHolder(readLockRecord(lockPath))) return false;
31034
- fs66.writeFileSync(lockPath, ownLockBody());
31078
+ fs67.writeFileSync(lockPath, ownLockBody());
31035
31079
  }
31036
31080
  const release3 = () => releaseOwnLock(lockPath);
31037
31081
  process.once("exit", release3);
@@ -31051,13 +31095,13 @@ function acquireDaemonLock(sessionId) {
31051
31095
  function acquireSingletonLock() {
31052
31096
  const lockPath = pairAutoLockPath();
31053
31097
  try {
31054
- fs66.mkdirSync(path74.dirname(lockPath), { recursive: true });
31098
+ fs67.mkdirSync(path75.dirname(lockPath), { recursive: true });
31055
31099
  try {
31056
- fs66.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
31100
+ fs67.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
31057
31101
  } catch (e) {
31058
31102
  if (e.code !== "EEXIST") throw e;
31059
31103
  if (isLiveLockHolder(readLockRecord(lockPath))) return false;
31060
- fs66.writeFileSync(lockPath, ownLockBody());
31104
+ fs67.writeFileSync(lockPath, ownLockBody());
31061
31105
  }
31062
31106
  process.once("exit", () => releaseOwnLock(lockPath));
31063
31107
  return true;
@@ -31483,7 +31527,7 @@ var AgentService = class _AgentService {
31483
31527
  };
31484
31528
 
31485
31529
  // src/agents/acp/adapters.ts
31486
- var path75 = __toESM(require("path"));
31530
+ var path76 = __toESM(require("path"));
31487
31531
 
31488
31532
  // src/agents/kimi/installer.ts
31489
31533
  var import_node_child_process26 = require("child_process");
@@ -31603,13 +31647,13 @@ function resolveBin(pkgName, binName) {
31603
31647
  try {
31604
31648
  const manifestPath = require_.resolve(`${pkgName}/package.json`);
31605
31649
  const manifest = require_(`${pkgName}/package.json`);
31606
- const pkgDir = path75.dirname(manifestPath);
31650
+ const pkgDir = path76.dirname(manifestPath);
31607
31651
  const bin = manifest.bin;
31608
31652
  if (!bin) return null;
31609
- if (typeof bin === "string") return path75.resolve(pkgDir, bin);
31653
+ if (typeof bin === "string") return path76.resolve(pkgDir, bin);
31610
31654
  const target = binName ?? Object.keys(bin)[0];
31611
31655
  if (!target || !bin[target]) return null;
31612
- return path75.resolve(pkgDir, bin[target]);
31656
+ return path76.resolve(pkgDir, bin[target]);
31613
31657
  } catch {
31614
31658
  return null;
31615
31659
  }
@@ -31624,7 +31668,7 @@ function npmAdapterPackageDir(agent) {
31624
31668
  const pkg = NPM_ADAPTER_PACKAGES[agent];
31625
31669
  if (!pkg) return null;
31626
31670
  try {
31627
- return path75.dirname(require_.resolve(`${pkg}/package.json`));
31671
+ return path76.dirname(require_.resolve(`${pkg}/package.json`));
31628
31672
  } catch {
31629
31673
  return null;
31630
31674
  }
@@ -31804,8 +31848,8 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
31804
31848
  }
31805
31849
 
31806
31850
  // src/agents/acp/prefetch-module-graph.ts
31807
- var fs67 = __toESM(require("fs"));
31808
- var path76 = __toESM(require("path"));
31851
+ var fs68 = __toESM(require("fs"));
31852
+ var path77 = __toESM(require("path"));
31809
31853
  var LOADABLE_EXT = /* @__PURE__ */ new Set([".js", ".mjs", ".cjs", ".json", ".node"]);
31810
31854
  var DEFAULT_MODULE_GRAPH_LIMITS = {
31811
31855
  maxFiles: 2e3,
@@ -31814,23 +31858,23 @@ var DEFAULT_MODULE_GRAPH_LIMITS = {
31814
31858
  concurrency: 16
31815
31859
  };
31816
31860
  var realFs = {
31817
- readdir: (dir) => fs67.promises.readdir(dir, { withFileTypes: true }),
31818
- readFile: (file) => fs67.promises.readFile(file),
31819
- stat: (file) => fs67.promises.stat(file)
31861
+ readdir: (dir) => fs68.promises.readdir(dir, { withFileTypes: true }),
31862
+ readFile: (file) => fs68.promises.readFile(file),
31863
+ stat: (file) => fs68.promises.stat(file)
31820
31864
  };
31821
31865
  function findPackageDir(dep, fromDir) {
31822
31866
  let dir = fromDir;
31823
31867
  for (; ; ) {
31824
- const candidate = path76.join(dir, "node_modules", dep);
31825
- if (fs67.existsSync(path76.join(candidate, "package.json"))) return candidate;
31826
- const parent = path76.dirname(dir);
31868
+ const candidate = path77.join(dir, "node_modules", dep);
31869
+ if (fs68.existsSync(path77.join(candidate, "package.json"))) return candidate;
31870
+ const parent = path77.dirname(dir);
31827
31871
  if (parent === dir) return null;
31828
31872
  dir = parent;
31829
31873
  }
31830
31874
  }
31831
31875
  function runtimeDependencies(pkgDir) {
31832
31876
  try {
31833
- const manifest = JSON.parse(fs67.readFileSync(path76.join(pkgDir, "package.json"), "utf8"));
31877
+ const manifest = JSON.parse(fs68.readFileSync(path77.join(pkgDir, "package.json"), "utf8"));
31834
31878
  return Object.keys(manifest.dependencies ?? {});
31835
31879
  } catch {
31836
31880
  return [];
@@ -31849,14 +31893,14 @@ async function packageFiles(pkgDir, fsd, out2, maxFiles) {
31849
31893
  for (const entry of entries2) {
31850
31894
  if (out2.length >= maxFiles) return;
31851
31895
  if (entry.name.startsWith(".")) continue;
31852
- const full = path76.join(dir, entry.name);
31896
+ const full = path77.join(dir, entry.name);
31853
31897
  if (entry.isDirectory()) {
31854
31898
  if (entry.name !== "node_modules") stack.push(full);
31855
31899
  continue;
31856
31900
  }
31857
31901
  if (!entry.isFile()) continue;
31858
31902
  if (entry.name.endsWith(".d.ts") || entry.name.endsWith(".map")) continue;
31859
- if (LOADABLE_EXT.has(path76.extname(entry.name))) out2.push(full);
31903
+ if (LOADABLE_EXT.has(path77.extname(entry.name))) out2.push(full);
31860
31904
  }
31861
31905
  }
31862
31906
  }
@@ -31866,7 +31910,7 @@ async function collectModuleGraphFiles(rootPkgDir, limits = DEFAULT_MODULE_GRAPH
31866
31910
  const queue = [rootPkgDir];
31867
31911
  while (queue.length > 0 && files.length < limits.maxFiles) {
31868
31912
  const pkgDir = queue.shift();
31869
- const key = fs67.existsSync(pkgDir) ? fs67.realpathSync(pkgDir) : pkgDir;
31913
+ const key = fs68.existsSync(pkgDir) ? fs68.realpathSync(pkgDir) : pkgDir;
31870
31914
  if (seen2.has(key)) continue;
31871
31915
  seen2.add(key);
31872
31916
  await packageFiles(pkgDir, fsd, files, limits.maxFiles);
@@ -32012,8 +32056,8 @@ function noteProviderBillingSignal(opts) {
32012
32056
  }
32013
32057
 
32014
32058
  // src/services/history.service.ts
32015
- var fs69 = __toESM(require("fs"));
32016
- var path78 = __toESM(require("path"));
32059
+ var fs70 = __toESM(require("fs"));
32060
+ var path79 = __toESM(require("path"));
32017
32061
  var https6 = __toESM(require("https"));
32018
32062
  var http10 = __toESM(require("http"));
32019
32063
  var import_zod3 = require("zod");
@@ -32074,7 +32118,7 @@ function parseJsonl(filePath) {
32074
32118
  const messages = [];
32075
32119
  let raw;
32076
32120
  try {
32077
- raw = fs69.readFileSync(filePath, "utf8");
32121
+ raw = fs70.readFileSync(filePath, "utf8");
32078
32122
  } catch (err) {
32079
32123
  if (err.code !== "ENOENT") {
32080
32124
  log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
@@ -32234,7 +32278,7 @@ var HistoryService = class _HistoryService {
32234
32278
  // session-start upload answered false, the active-conversation pointer was
32235
32279
  // never re-pointed after a Box wake, and the app opened an empty "New
32236
32280
  // conversation" over the resumed one (QA box, 2026-09-29).
32237
- path78.join(claudeConfigDir(), "projects", encodeCwd(this.cwd));
32281
+ path79.join(claudeConfigDir(), "projects", encodeCwd(this.cwd));
32238
32282
  }
32239
32283
  /** Set the current Claude conversation ID (extracted from /cost command or session start) */
32240
32284
  setCurrentConversationId(id) {
@@ -32246,7 +32290,7 @@ var HistoryService = class _HistoryService {
32246
32290
  /** Return the current message count in the active conversation. */
32247
32291
  getCurrentMessageCount() {
32248
32292
  if (!this.currentConversationId) return 0;
32249
- const filePath = path78.join(this.projectDir, `${this.currentConversationId}.jsonl`);
32293
+ const filePath = path79.join(this.projectDir, `${this.currentConversationId}.jsonl`);
32250
32294
  return parseJsonl(filePath).length;
32251
32295
  }
32252
32296
  /**
@@ -32257,7 +32301,7 @@ var HistoryService = class _HistoryService {
32257
32301
  const deadline = Date.now() + timeoutMs;
32258
32302
  while (Date.now() < deadline) {
32259
32303
  if (!this.currentConversationId) return null;
32260
- const filePath = path78.join(this.projectDir, `${this.currentConversationId}.jsonl`);
32304
+ const filePath = path79.join(this.projectDir, `${this.currentConversationId}.jsonl`);
32261
32305
  const messages = parseJsonl(filePath);
32262
32306
  if (messages.length > previousCount) {
32263
32307
  for (let i = messages.length - 1; i >= previousCount; i--) {
@@ -32284,18 +32328,18 @@ var HistoryService = class _HistoryService {
32284
32328
  const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
32285
32329
  const oneShots = readOneShotConversations(this.cwd);
32286
32330
  try {
32287
- const files = fs69.readdirSync(dir, { withFileTypes: true }).filter(
32288
- (e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(path78.basename(e.name, ".jsonl"))
32331
+ const files = fs70.readdirSync(dir, { withFileTypes: true }).filter(
32332
+ (e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(path79.basename(e.name, ".jsonl"))
32289
32333
  ).map((e) => {
32290
32334
  try {
32291
- const stat3 = fs69.statSync(path78.join(dir, e.name));
32335
+ const stat3 = fs70.statSync(path79.join(dir, e.name));
32292
32336
  return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
32293
32337
  } catch {
32294
32338
  return { name: e.name, mtime: 0, birthtime: 0 };
32295
32339
  }
32296
32340
  }).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
32297
32341
  if (files.length > 0) {
32298
- this.currentConversationId = path78.basename(files[0].name, ".jsonl");
32342
+ this.currentConversationId = path79.basename(files[0].name, ".jsonl");
32299
32343
  }
32300
32344
  } catch {
32301
32345
  }
@@ -32329,13 +32373,13 @@ var HistoryService = class _HistoryService {
32329
32373
  const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
32330
32374
  let entries2;
32331
32375
  try {
32332
- entries2 = fs69.readdirSync(dir, { withFileTypes: true });
32376
+ entries2 = fs70.readdirSync(dir, { withFileTypes: true });
32333
32377
  } catch {
32334
32378
  return null;
32335
32379
  }
32336
32380
  const files = entries2.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
32337
32381
  try {
32338
- const stat3 = fs69.statSync(path78.join(dir, e.name));
32382
+ const stat3 = fs70.statSync(path79.join(dir, e.name));
32339
32383
  return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
32340
32384
  } catch {
32341
32385
  return { name: e.name, mtime: 0, birthtime: 0 };
@@ -32344,12 +32388,12 @@ var HistoryService = class _HistoryService {
32344
32388
  if (files.length === 0) return null;
32345
32389
  const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
32346
32390
  if (!files.some((f) => f.name === targetFile)) return null;
32347
- return this.extractUsageFromFile(path78.join(dir, targetFile));
32391
+ return this.extractUsageFromFile(path79.join(dir, targetFile));
32348
32392
  }
32349
32393
  extractUsageFromFile(filePath) {
32350
32394
  let raw;
32351
32395
  try {
32352
- raw = fs69.readFileSync(filePath, "utf8");
32396
+ raw = fs70.readFileSync(filePath, "utf8");
32353
32397
  } catch {
32354
32398
  return null;
32355
32399
  }
@@ -32401,9 +32445,9 @@ var HistoryService = class _HistoryService {
32401
32445
  let totalCost = 0;
32402
32446
  let files;
32403
32447
  try {
32404
- files = fs69.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
32448
+ files = fs70.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
32405
32449
  try {
32406
- return fs69.statSync(path78.join(projectDir, f)).mtimeMs >= monthStartMs;
32450
+ return fs70.statSync(path79.join(projectDir, f)).mtimeMs >= monthStartMs;
32407
32451
  } catch {
32408
32452
  return false;
32409
32453
  }
@@ -32414,7 +32458,7 @@ var HistoryService = class _HistoryService {
32414
32458
  for (const file of files) {
32415
32459
  let raw;
32416
32460
  try {
32417
- raw = fs69.readFileSync(path78.join(projectDir, file), "utf8");
32461
+ raw = fs70.readFileSync(path79.join(projectDir, file), "utf8");
32418
32462
  } catch {
32419
32463
  continue;
32420
32464
  }
@@ -32493,7 +32537,7 @@ var HistoryService = class _HistoryService {
32493
32537
  if (this.runtime.resolveHistoryFile) {
32494
32538
  return this.runtime.resolveHistoryFile(this.cwd, sessionId);
32495
32539
  }
32496
- return path78.join(this.projectDir, `${sessionId}.jsonl`);
32540
+ return path79.join(this.projectDir, `${sessionId}.jsonl`);
32497
32541
  }
32498
32542
  /**
32499
32543
  * Parse a conversation's messages from disk, agent-aware. Claude uses the
@@ -32531,7 +32575,7 @@ var HistoryService = class _HistoryService {
32531
32575
  };
32532
32576
  });
32533
32577
  }
32534
- return parseJsonl(path78.join(this.projectDir, `${sessionId}.jsonl`));
32578
+ return parseJsonl(path79.join(this.projectDir, `${sessionId}.jsonl`));
32535
32579
  }
32536
32580
  /** One in-flight full upload per conversation — the baton mirror and a
32537
32581
  * `get_conversation` used to upload the same transcript concurrently. */
@@ -32613,7 +32657,7 @@ var HistoryService = class _HistoryService {
32613
32657
  if (!filePath) return false;
32614
32658
  let mtimeMs;
32615
32659
  try {
32616
- mtimeMs = fs69.statSync(filePath).mtimeMs;
32660
+ mtimeMs = fs70.statSync(filePath).mtimeMs;
32617
32661
  } catch {
32618
32662
  return false;
32619
32663
  }
@@ -32688,10 +32732,10 @@ var HistoryService = class _HistoryService {
32688
32732
 
32689
32733
  // src/agents/acp/client.ts
32690
32734
  var import_node_child_process28 = require("child_process");
32691
- var fs70 = __toESM(require("fs/promises"));
32735
+ var fs71 = __toESM(require("fs/promises"));
32692
32736
  var fsSync = __toESM(require("fs"));
32693
- var os51 = __toESM(require("os"));
32694
- var path80 = __toESM(require("path"));
32737
+ var os52 = __toESM(require("os"));
32738
+ var path81 = __toESM(require("path"));
32695
32739
  var import_node_stream = require("stream");
32696
32740
 
32697
32741
  // ../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
@@ -36717,8 +36761,8 @@ function createIdleTimeout(idleMs, makeError, activeIdleMs = idleMs) {
36717
36761
  }
36718
36762
 
36719
36763
  // src/agents/acp/internal-paths.ts
36720
- var path79 = __toESM(require("path"));
36721
- var os50 = __toESM(require("os"));
36764
+ var path80 = __toESM(require("path"));
36765
+ var os51 = __toESM(require("os"));
36722
36766
  var INTERNAL_TOKENS = [".codeam", "house-claude"];
36723
36767
  var PROSE_ONLY_TOOL_KINDS = /* @__PURE__ */ new Set(["think", "switch_mode"]);
36724
36768
  function isProseOnlyToolKind(kind) {
@@ -36730,13 +36774,13 @@ function textReferencesInternal(text) {
36730
36774
  const scrubbed = text.replace(SELF_HOSTED_WORKSPACE_RE, " ");
36731
36775
  return INTERNAL_TOKENS.some((t2) => scrubbed.includes(t2));
36732
36776
  }
36733
- function pathIsInternal(p2, homeDir2 = os50.homedir()) {
36777
+ function pathIsInternal(p2, homeDir2 = os51.homedir()) {
36734
36778
  if (!p2) return false;
36735
- const abs = path79.resolve(p2);
36736
- const home = path79.resolve(homeDir2);
36737
- const within = (root) => abs === root || abs.startsWith(root + path79.sep);
36738
- if (within(path79.join(home, ".codeam", "self-hosted"))) return false;
36739
- return within(path79.join(home, ".codeam")) || within(path79.join(home, ".beads")) || abs === path79.join(home, ".codeam-host.log") || abs.includes(`${path79.sep}house-claude${path79.sep}`) || abs.endsWith(`${path79.sep}house-claude`);
36779
+ const abs = path80.resolve(p2);
36780
+ const home = path80.resolve(homeDir2);
36781
+ const within = (root) => abs === root || abs.startsWith(root + path80.sep);
36782
+ if (within(path80.join(home, ".codeam", "self-hosted"))) return false;
36783
+ return within(path80.join(home, ".codeam")) || within(path80.join(home, ".beads")) || abs === path80.join(home, ".codeam-host.log") || abs.includes(`${path80.sep}house-claude${path80.sep}`) || abs.endsWith(`${path80.sep}house-claude`);
36740
36784
  }
36741
36785
  function toolCallReferencesInternal(call, homeDir2) {
36742
36786
  if (call.locations?.some((l) => pathIsInternal(l.path, homeDir2))) return true;
@@ -37870,7 +37914,7 @@ var AcpClient = class {
37870
37914
  throw new RequestError(-32002, GUARDRAIL_SECRET_READ_BLOCK_REASON, { uri: params.path });
37871
37915
  }
37872
37916
  try {
37873
- const content = await fs70.readFile(params.path, "utf8");
37917
+ const content = await fs71.readFile(params.path, "utf8");
37874
37918
  return applyLineRange(content, params.line ?? null, params.limit ?? null);
37875
37919
  } catch (err) {
37876
37920
  const code = err.code;
@@ -37891,7 +37935,7 @@ var AcpClient = class {
37891
37935
  throw new RequestError(-32002, INTERNAL_BLOCK_REASON, { uri: params.path });
37892
37936
  }
37893
37937
  try {
37894
- await fs70.writeFile(params.path, params.content, "utf8");
37938
+ await fs71.writeFile(params.path, params.content, "utf8");
37895
37939
  return {};
37896
37940
  } catch (err) {
37897
37941
  const code = err.code;
@@ -37979,30 +38023,30 @@ function applyLineRange(content, line, limit) {
37979
38023
  return { content: lines.slice(start2, end).join("\n") };
37980
38024
  }
37981
38025
  function knownAgentBinaryDirs() {
37982
- const home = os51.homedir();
38026
+ const home = os52.homedir();
37983
38027
  const out2 = [];
37984
38028
  out2.push("/tmp/codeam-node20/bin");
37985
38029
  for (const root of [
37986
38030
  "/usr/local/share/nvm/versions/node",
37987
- path80.join(home, ".nvm/versions/node")
38031
+ path81.join(home, ".nvm/versions/node")
37988
38032
  ]) {
37989
38033
  try {
37990
38034
  for (const child of fsSync.readdirSync(root)) {
37991
- out2.push(path80.join(root, child, "bin"));
38035
+ out2.push(path81.join(root, child, "bin"));
37992
38036
  }
37993
38037
  } catch {
37994
38038
  }
37995
38039
  }
37996
- out2.push(path80.join(home, ".volta/bin"));
38040
+ out2.push(path81.join(home, ".volta/bin"));
37997
38041
  out2.push("/usr/local/bin");
37998
38042
  out2.push("/usr/bin");
37999
- out2.push(path80.join(home, ".local/bin"));
38000
- out2.push(path80.join(home, "bin"));
38043
+ out2.push(path81.join(home, ".local/bin"));
38044
+ out2.push(path81.join(home, "bin"));
38001
38045
  out2.push(...agentInstallBinDirs());
38002
38046
  if (process.platform === "win32") {
38003
38047
  const { LOCALAPPDATA, APPDATA } = process.env;
38004
- if (LOCALAPPDATA) out2.push(path80.join(LOCALAPPDATA, "cursor-agent"));
38005
- if (APPDATA) out2.push(path80.join(APPDATA, "npm"));
38048
+ if (LOCALAPPDATA) out2.push(path81.join(LOCALAPPDATA, "cursor-agent"));
38049
+ if (APPDATA) out2.push(path81.join(APPDATA, "npm"));
38006
38050
  }
38007
38051
  return out2.filter((p2) => {
38008
38052
  try {
@@ -38013,7 +38057,7 @@ function knownAgentBinaryDirs() {
38013
38057
  });
38014
38058
  }
38015
38059
  function expandPathForAgentBinaries(existingPath) {
38016
- const existing = new Set(existingPath.split(path80.delimiter).filter((p2) => p2.length > 0));
38060
+ const existing = new Set(existingPath.split(path81.delimiter).filter((p2) => p2.length > 0));
38017
38061
  const additions = [];
38018
38062
  for (const dir of knownAgentBinaryDirs()) {
38019
38063
  if (!existing.has(dir)) {
@@ -38022,17 +38066,17 @@ function expandPathForAgentBinaries(existingPath) {
38022
38066
  }
38023
38067
  }
38024
38068
  if (additions.length === 0) return existingPath;
38025
- return [...additions, existingPath].filter((p2) => p2.length > 0).join(path80.delimiter);
38069
+ return [...additions, existingPath].filter((p2) => p2.length > 0).join(path81.delimiter);
38026
38070
  }
38027
38071
 
38028
38072
  // src/commands/host/agent-install.ts
38029
38073
  var import_child_process27 = require("child_process");
38030
- var os52 = __toESM(require("os"));
38074
+ var os53 = __toESM(require("os"));
38031
38075
  function runAgentInstallScript(script, opts = {}) {
38032
38076
  const timeoutMs = opts.timeoutMs ?? 18e4;
38033
38077
  const scope = opts.logScope ?? "agent-install";
38034
38078
  return new Promise((resolve13) => {
38035
- const home = process.env.HOME || os52.homedir();
38079
+ const home = process.env.HOME || os53.homedir();
38036
38080
  const child = (0, import_child_process27.spawn)("sh", ["-c", script], {
38037
38081
  env: { ...process.env, HOME: home },
38038
38082
  stdio: ["ignore", "pipe", "pipe"]
@@ -38294,9 +38338,9 @@ async function performAgentSwitch(deps, rawAgentId, fastPath = {}) {
38294
38338
  }
38295
38339
 
38296
38340
  // src/commands/host/agent-provisioning.ts
38297
- var fs71 = __toESM(require("fs"));
38298
- var os53 = __toESM(require("os"));
38299
- var path81 = __toESM(require("path"));
38341
+ var fs72 = __toESM(require("fs"));
38342
+ var os54 = __toESM(require("os"));
38343
+ var path82 = __toESM(require("path"));
38300
38344
  var PUBLIC_TO_INTERNAL_AGENT = {
38301
38345
  claude_code: "claude",
38302
38346
  claude: "claude",
@@ -38313,22 +38357,22 @@ function toInternalAgentId(publicAgentId) {
38313
38357
  return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
38314
38358
  }
38315
38359
  function ensureDir(dir) {
38316
- fs71.mkdirSync(dir, { recursive: true, mode: 448 });
38360
+ fs72.mkdirSync(dir, { recursive: true, mode: 448 });
38317
38361
  }
38318
38362
  function writeFile0600(filePath, contents) {
38319
- ensureDir(path81.dirname(filePath));
38320
- fs71.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
38363
+ ensureDir(path82.dirname(filePath));
38364
+ fs72.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
38321
38365
  restrictToOwner(filePath);
38322
38366
  }
38323
38367
  function rmIfExists(filePath) {
38324
38368
  try {
38325
- fs71.rmSync(filePath, { force: true });
38369
+ fs72.rmSync(filePath, { force: true });
38326
38370
  } catch {
38327
38371
  }
38328
38372
  }
38329
38373
  var claudeProvisioner = {
38330
38374
  write(auth, home) {
38331
- const credentialsJson = path81.join(home, ".claude", ".credentials.json");
38375
+ const credentialsJson = path82.join(home, ".claude", ".credentials.json");
38332
38376
  if (auth.kind === "api_key") {
38333
38377
  rmIfExists(credentialsJson);
38334
38378
  return { ANTHROPIC_API_KEY: auth.value };
@@ -38340,8 +38384,8 @@ var claudeProvisioner = {
38340
38384
  } else {
38341
38385
  rmIfExists(credentialsJson);
38342
38386
  }
38343
- const claudeJson = path81.join(home, ".claude.json");
38344
- if (!fs71.existsSync(claudeJson)) {
38387
+ const claudeJson = path82.join(home, ".claude.json");
38388
+ if (!fs72.existsSync(claudeJson)) {
38345
38389
  writeFile0600(
38346
38390
  claudeJson,
38347
38391
  JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
@@ -38352,7 +38396,7 @@ var claudeProvisioner = {
38352
38396
  };
38353
38397
  var codexProvisioner = {
38354
38398
  write(auth, home) {
38355
- const authJson = path81.join(home, ".codex", "auth.json");
38399
+ const authJson = path82.join(home, ".codex", "auth.json");
38356
38400
  if (auth.kind === "api_key") {
38357
38401
  writeFile0600(authJson, JSON.stringify({ auth_mode: "apikey", OPENAI_API_KEY: auth.value }));
38358
38402
  return { OPENAI_API_KEY: auth.value };
@@ -38375,7 +38419,7 @@ function codexLoginStamp(raw) {
38375
38419
  function keepsFresherCodexLogin(authJsonPath, incoming) {
38376
38420
  let onDisk;
38377
38421
  try {
38378
- onDisk = fs71.readFileSync(authJsonPath, "utf8");
38422
+ onDisk = fs72.readFileSync(authJsonPath, "utf8");
38379
38423
  } catch {
38380
38424
  return false;
38381
38425
  }
@@ -38386,8 +38430,8 @@ function keepsFresherCodexLogin(authJsonPath, incoming) {
38386
38430
  }
38387
38431
  var geminiProvisioner = {
38388
38432
  write(auth, home) {
38389
- const settingsJson = path81.join(home, ".gemini", "settings.json");
38390
- const oauthCreds = path81.join(home, ".gemini", "oauth_creds.json");
38433
+ const settingsJson = path82.join(home, ".gemini", "settings.json");
38434
+ const oauthCreds = path82.join(home, ".gemini", "oauth_creds.json");
38391
38435
  if (auth.kind === "api_key") {
38392
38436
  rmIfExists(oauthCreds);
38393
38437
  writeFile0600(settingsJson, '{"security":{"auth":{"selectedType":"gemini-api-key"}}}');
@@ -38400,7 +38444,7 @@ var geminiProvisioner = {
38400
38444
  };
38401
38445
  var cursorProvisioner = {
38402
38446
  write(auth, home) {
38403
- const authJson = path81.join(home, ".config", "cursor", "auth.json");
38447
+ const authJson = path82.join(home, ".config", "cursor", "auth.json");
38404
38448
  if (auth.kind === "api_key") {
38405
38449
  rmIfExists(authJson);
38406
38450
  return { CURSOR_API_KEY: auth.value };
@@ -38442,22 +38486,22 @@ max_context_size = 262144
38442
38486
  var kimiProvisioner = {
38443
38487
  write(auth, home) {
38444
38488
  const credentialsFiles = [
38445
- path81.join(home, ".kimi", "credentials", "kimi-code.json"),
38446
- path81.join(home, ".kimi-code", "credentials", "kimi-code.json")
38489
+ path82.join(home, ".kimi", "credentials", "kimi-code.json"),
38490
+ path82.join(home, ".kimi-code", "credentials", "kimi-code.json")
38447
38491
  ];
38448
38492
  if (auth.kind === "api_key") {
38449
38493
  credentialsFiles.forEach(rmIfExists);
38450
38494
  return { KIMI_API_KEY: auth.value };
38451
38495
  }
38452
38496
  credentialsFiles.forEach((f) => writeFile0600(f, auth.value));
38453
- writeFile0600(path81.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
38497
+ writeFile0600(path82.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
38454
38498
  return {};
38455
38499
  }
38456
38500
  };
38457
38501
  var coderabbitProvisioner = {
38458
38502
  write(auth, home) {
38459
- const dir = path81.join(home, ".coderabbit");
38460
- const authJson = path81.join(dir, "auth.json");
38503
+ const dir = path82.join(home, ".coderabbit");
38504
+ const authJson = path82.join(dir, "auth.json");
38461
38505
  if (auth.kind === "api_key") {
38462
38506
  rmIfExists(authJson);
38463
38507
  return { CODERABBIT_API_KEY: auth.value };
@@ -38469,13 +38513,13 @@ var coderabbitProvisioner = {
38469
38513
  try {
38470
38514
  const parsed = JSON.parse(value);
38471
38515
  if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
38472
- file = path81.basename(parsed.file);
38516
+ file = path82.basename(parsed.file);
38473
38517
  contents = parsed.contents;
38474
38518
  }
38475
38519
  } catch {
38476
38520
  }
38477
38521
  }
38478
- writeFile0600(path81.join(dir, file), contents);
38522
+ writeFile0600(path82.join(dir, file), contents);
38479
38523
  return {};
38480
38524
  }
38481
38525
  };
@@ -38507,7 +38551,7 @@ var UnsupportedAgentError = class extends Error {
38507
38551
  this.agentId = agentId;
38508
38552
  }
38509
38553
  };
38510
- function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os53.homedir()) {
38554
+ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os54.homedir()) {
38511
38555
  const internal = toInternalAgentId(publicAgentId);
38512
38556
  if (!internal) throw new UnsupportedAgentError(publicAgentId);
38513
38557
  const provisioner = PROVISIONERS[internal];
@@ -38516,8 +38560,8 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os53.homedir(
38516
38560
  }
38517
38561
 
38518
38562
  // src/beads/workflow-hint.ts
38519
- var fs72 = __toESM(require("fs"));
38520
- var path82 = __toESM(require("path"));
38563
+ var fs73 = __toESM(require("fs"));
38564
+ var path83 = __toESM(require("path"));
38521
38565
  var BEADS_HINT_MARKER = "<!-- codeam:beads-workflow -->";
38522
38566
  var BEADS_HINT = `${BEADS_HINT_MARKER}
38523
38567
  # Beads (bd) \u2014 task tracking + persistent memory (ALWAYS use it)
@@ -38544,11 +38588,11 @@ function ensureBeadsWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2)) {
38544
38588
  try {
38545
38589
  let existing = "";
38546
38590
  try {
38547
- existing = fs72.readFileSync(file, "utf8");
38591
+ existing = fs73.readFileSync(file, "utf8");
38548
38592
  } catch {
38549
38593
  }
38550
38594
  if (existing.includes(BEADS_HINT)) return;
38551
- fs72.mkdirSync(path82.dirname(file), { recursive: true });
38595
+ fs73.mkdirSync(path83.dirname(file), { recursive: true });
38552
38596
  let next;
38553
38597
  const open = existing.indexOf(BEADS_HINT_MARKER);
38554
38598
  const close = open === -1 ? -1 : existing.indexOf(BEADS_HINT_MARKER, open + BEADS_HINT_MARKER.length);
@@ -38561,40 +38605,40 @@ ${BEADS_HINT}
38561
38605
  ` : `${BEADS_HINT}
38562
38606
  `;
38563
38607
  }
38564
- fs72.writeFileSync(file, next);
38608
+ fs73.writeFileSync(file, next);
38565
38609
  } catch {
38566
38610
  }
38567
38611
  }
38568
38612
 
38569
38613
  // src/agents/agent-standard.ts
38570
- var fs73 = __toESM(require("fs"));
38571
- var path83 = __toESM(require("path"));
38572
- var os54 = __toESM(require("os"));
38614
+ var fs74 = __toESM(require("fs"));
38615
+ var path84 = __toESM(require("path"));
38616
+ var os55 = __toESM(require("os"));
38573
38617
  function ensureAgentStandard(homeDir2, file = claudeMemoryFile(homeDir2)) {
38574
38618
  try {
38575
38619
  let existing = "";
38576
38620
  try {
38577
- existing = fs73.readFileSync(file, "utf8");
38621
+ existing = fs74.readFileSync(file, "utf8");
38578
38622
  } catch {
38579
38623
  }
38580
38624
  if (existing.includes(AGENT_STANDARD_MARKER)) return;
38581
- fs73.mkdirSync(path83.dirname(file), { recursive: true });
38625
+ fs74.mkdirSync(path84.dirname(file), { recursive: true });
38582
38626
  const next = existing.trim() ? `${existing.trimEnd()}
38583
38627
 
38584
38628
  ${AGENT_STANDARD_BLOCK}
38585
38629
  ` : `${AGENT_STANDARD_BLOCK}
38586
38630
  `;
38587
- fs73.writeFileSync(file, next);
38631
+ fs74.writeFileSync(file, next);
38588
38632
  } catch {
38589
38633
  }
38590
38634
  }
38591
38635
  var _agentStandardSeam = {
38592
38636
  isLocalSession: () => isLocalSession(),
38593
- markerPath: (sessionId) => path83.join(os54.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
38594
- exists: (p2) => fs73.existsSync(p2),
38637
+ markerPath: (sessionId) => path84.join(os55.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
38638
+ exists: (p2) => fs74.existsSync(p2),
38595
38639
  write: (p2) => {
38596
- fs73.mkdirSync(path83.dirname(p2), { recursive: true });
38597
- fs73.writeFileSync(p2, "");
38640
+ fs74.mkdirSync(path84.dirname(p2), { recursive: true });
38641
+ fs74.writeFileSync(p2, "");
38598
38642
  }
38599
38643
  };
38600
38644
  function isClaude(agent) {
@@ -39329,15 +39373,15 @@ function withholdTrailingPartialFenceMarker(text) {
39329
39373
 
39330
39374
  // src/agents/acp/onboarding.ts
39331
39375
  var import_child_process28 = require("child_process");
39332
- var fs75 = __toESM(require("fs"));
39333
- var os55 = __toESM(require("os"));
39334
- var path85 = __toESM(require("path"));
39376
+ var fs76 = __toESM(require("fs"));
39377
+ var os56 = __toESM(require("os"));
39378
+ var path86 = __toESM(require("path"));
39335
39379
  var _onboardingSeam = {
39336
- markerPath: (sessionId) => path85.join(os55.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
39337
- exists: (p2) => fs75.existsSync(p2),
39380
+ markerPath: (sessionId) => path86.join(os56.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
39381
+ exists: (p2) => fs76.existsSync(p2),
39338
39382
  write: (p2) => {
39339
- fs75.mkdirSync(path85.dirname(p2), { recursive: true });
39340
- fs75.writeFileSync(p2, "");
39383
+ fs76.mkdirSync(path86.dirname(p2), { recursive: true });
39384
+ fs76.writeFileSync(p2, "");
39341
39385
  },
39342
39386
  disabled: () => {
39343
39387
  const v = process.env.CODEAM_ONBOARDING_DISABLED;
@@ -39374,7 +39418,7 @@ function resolveRepoName(cwd) {
39374
39418
  if (name) return name;
39375
39419
  }
39376
39420
  }
39377
- const base = path85.basename(cwd || "");
39421
+ const base = path86.basename(cwd || "");
39378
39422
  if (base && !isUuid(base)) return base;
39379
39423
  return "this project";
39380
39424
  }
@@ -39774,14 +39818,14 @@ var import_crypto5 = require("crypto");
39774
39818
 
39775
39819
  // src/services/turn-files/git-changeset.ts
39776
39820
  var import_child_process29 = require("child_process");
39777
- var fs77 = __toESM(require("fs/promises"));
39821
+ var fs78 = __toESM(require("fs/promises"));
39778
39822
  var import_fs10 = require("fs");
39779
- var path87 = __toESM(require("path"));
39823
+ var path88 = __toESM(require("path"));
39780
39824
 
39781
39825
  // src/services/turn-files/review-ignore.ts
39782
39826
  var import_ignore2 = __toESM(require("ignore"));
39783
- var fs76 = __toESM(require("fs"));
39784
- var path86 = __toESM(require("path"));
39827
+ var fs77 = __toESM(require("fs"));
39828
+ var path87 = __toESM(require("path"));
39785
39829
  var CURATED_REVIEW_IGNORE = [
39786
39830
  // Google Cloud SDK (the incident) — installs a huge python tree.
39787
39831
  "google-cloud-sdk/",
@@ -39825,7 +39869,7 @@ var CURATED_REVIEW_IGNORE = [
39825
39869
  function makeReviewIgnore(repoRoot) {
39826
39870
  const ig = (0, import_ignore2.default)().add(CURATED_REVIEW_IGNORE);
39827
39871
  try {
39828
- const custom = fs76.readFileSync(path86.join(repoRoot, ".codeam", "reviewignore"), "utf8");
39872
+ const custom = fs77.readFileSync(path87.join(repoRoot, ".codeam", "reviewignore"), "utf8");
39829
39873
  ig.add(custom);
39830
39874
  } catch {
39831
39875
  }
@@ -39860,7 +39904,7 @@ async function collectRepoChangeset(opts) {
39860
39904
  const rows = parseStatus(status2).filter(
39861
39905
  (row) => !isIgnoredFilePath(row.filePath) && !reviewIgnore(row.filePath) && // A socket, FIFO or device node is never a change to review (a
39862
39906
  // `cc-socks/1522.sock` reached the Files tab).
39863
- isReviewablePath(path87.join(opts.repoRoot, row.filePath))
39907
+ isReviewablePath(path88.join(opts.repoRoot, row.filePath))
39864
39908
  );
39865
39909
  const MAX_CHANGESET_FILES = Math.max(1, Number(process.env.CODEAM_MAX_CHANGESET_FILES ?? 500));
39866
39910
  const truncated = rows.length > MAX_CHANGESET_FILES;
@@ -39877,7 +39921,7 @@ async function collectRepoChangeset(opts) {
39877
39921
  let stats;
39878
39922
  if (!truncated && row.fileStatus === "added" && numstatEntry === void 0) {
39879
39923
  const lineCount = await readUntrackedLineCount(
39880
- path87.join(opts.repoRoot, row.filePath)
39924
+ path88.join(opts.repoRoot, row.filePath)
39881
39925
  );
39882
39926
  stats = { added: lineCount, removed: 0 };
39883
39927
  } else {
@@ -39908,7 +39952,7 @@ function readUntrackedLineCount(absPath) {
39908
39952
  }
39909
39953
  async function defaultReadUntrackedLineCount(absPath) {
39910
39954
  try {
39911
- const content = await fs77.readFile(absPath, "utf8");
39955
+ const content = await fs78.readFile(absPath, "utf8");
39912
39956
  let count = 0;
39913
39957
  let pos = -1;
39914
39958
  while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
@@ -40019,8 +40063,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
40019
40063
  if (hasGit) {
40020
40064
  out2.push({
40021
40065
  repoRoot: dir,
40022
- repoPath: path87.relative(workingDir, dir),
40023
- repoName: path87.basename(dir)
40066
+ repoPath: path88.relative(workingDir, dir),
40067
+ repoName: path88.basename(dir)
40024
40068
  });
40025
40069
  return;
40026
40070
  }
@@ -40028,7 +40072,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
40028
40072
  if (!entry.isDirectory) continue;
40029
40073
  if (entry.name === "node_modules") continue;
40030
40074
  if (entry.name === "dist" || entry.name === "build") continue;
40031
- await walk2(path87.join(dir, entry.name), depth2 + 1);
40075
+ await walk2(path88.join(dir, entry.name), depth2 + 1);
40032
40076
  }
40033
40077
  }
40034
40078
  }
@@ -40042,8 +40086,8 @@ function isReviewablePath(absPath) {
40042
40086
  }
40043
40087
 
40044
40088
  // src/services/turn-files/files-outbox.ts
40045
- var fs78 = __toESM(require("fs/promises"));
40046
- var path88 = __toESM(require("path"));
40089
+ var fs79 = __toESM(require("fs/promises"));
40090
+ var path89 = __toESM(require("path"));
40047
40091
  var import_os14 = require("os");
40048
40092
  var HOME_OUTBOX_DIR = ".codeam/outbox";
40049
40093
  var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
@@ -40076,16 +40120,16 @@ var FilesOutbox = class {
40076
40120
  backoffIndex = 0;
40077
40121
  stopped = false;
40078
40122
  constructor(opts) {
40079
- const base = opts.baseDir ?? path88.join(homeDir(), HOME_OUTBOX_DIR);
40080
- this.filePath = path88.join(base, `${opts.sessionId}.jsonl`);
40123
+ const base = opts.baseDir ?? path89.join(homeDir(), HOME_OUTBOX_DIR);
40124
+ this.filePath = path89.join(base, `${opts.sessionId}.jsonl`);
40081
40125
  this.post = opts.post;
40082
40126
  this.autoSchedule = opts.autoSchedule !== false;
40083
40127
  }
40084
40128
  /** Persist the entry to disk and trigger a flush. Returns once the
40085
40129
  * line is durable on disk (not once the POST succeeds). */
40086
40130
  async enqueue(entry) {
40087
- await fs78.mkdir(path88.dirname(this.filePath), { recursive: true });
40088
- await fs78.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
40131
+ await fs79.mkdir(path89.dirname(this.filePath), { recursive: true });
40132
+ await fs79.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
40089
40133
  this.backoffIndex = 0;
40090
40134
  if (this.autoSchedule) this.scheduleFlush(0);
40091
40135
  }
@@ -40176,7 +40220,7 @@ var FilesOutbox = class {
40176
40220
  async readAll() {
40177
40221
  let raw = "";
40178
40222
  try {
40179
- raw = await fs78.readFile(this.filePath, "utf8");
40223
+ raw = await fs79.readFile(this.filePath, "utf8");
40180
40224
  } catch {
40181
40225
  return [];
40182
40226
  }
@@ -40200,12 +40244,12 @@ var FilesOutbox = class {
40200
40244
  async rewrite(entries2) {
40201
40245
  const tmpPath = `${this.filePath}.${process.pid}.tmp`;
40202
40246
  if (entries2.length === 0) {
40203
- await fs78.unlink(this.filePath).catch(() => void 0);
40247
+ await fs79.unlink(this.filePath).catch(() => void 0);
40204
40248
  return;
40205
40249
  }
40206
40250
  const payload = entries2.map((e) => JSON.stringify(e)).join("\n") + "\n";
40207
- await fs78.writeFile(tmpPath, payload, "utf8");
40208
- await fs78.rename(tmpPath, this.filePath);
40251
+ await fs79.writeFile(tmpPath, payload, "utf8");
40252
+ await fs79.rename(tmpPath, this.filePath);
40209
40253
  }
40210
40254
  };
40211
40255
  function applyJitter(ms) {
@@ -40552,48 +40596,6 @@ async function readActiveConversationMarker(cwd, homeDir2) {
40552
40596
  }
40553
40597
  }
40554
40598
 
40555
- // src/services/turn-marker.ts
40556
- var fs80 = __toESM(require("fs"));
40557
- var os57 = __toESM(require("os"));
40558
- var path90 = __toESM(require("path"));
40559
- var depth = 0;
40560
- function codeamHome() {
40561
- return path90.join(os57.homedir(), ".codeam");
40562
- }
40563
- function turnMarkerPath(pid = process.pid, home = codeamHome()) {
40564
- return path90.join(home, "turns", String(pid));
40565
- }
40566
- function mark() {
40567
- try {
40568
- const file = turnMarkerPath();
40569
- fs80.mkdirSync(path90.dirname(file), { recursive: true });
40570
- fs80.writeFileSync(file, String(Date.now()));
40571
- } catch {
40572
- }
40573
- }
40574
- function clear() {
40575
- try {
40576
- fs80.rmSync(turnMarkerPath(), { force: true });
40577
- } catch {
40578
- }
40579
- }
40580
- async function withTurnMarker(fn) {
40581
- if (depth++ === 0) mark();
40582
- try {
40583
- return await fn();
40584
- } finally {
40585
- if (--depth === 0) clear();
40586
- }
40587
- }
40588
- function isProcessMidTurn(pid, home) {
40589
- if (!pid) return false;
40590
- try {
40591
- return fs80.existsSync(turnMarkerPath(pid, home));
40592
- } catch {
40593
- return false;
40594
- }
40595
- }
40596
-
40597
40599
  // src/packs/gates.ts
40598
40600
  var import_node_child_process29 = require("child_process");
40599
40601
  var fs81 = __toESM(require("fs"));
@@ -51267,7 +51269,7 @@ async function autoUpgradeBeforeCriticalCommand() {
51267
51269
  if (process.env.NODE_ENV === "test") return;
51268
51270
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
51269
51271
  if (process.env.CI) return;
51270
- const current2 = true ? "2.76.22" : null;
51272
+ const current2 = true ? "2.76.23" : null;
51271
51273
  if (!current2) return;
51272
51274
  const cache = readCache();
51273
51275
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -51284,7 +51286,7 @@ function checkForUpdates() {
51284
51286
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
51285
51287
  if (process.env.CI) return;
51286
51288
  if (!process.stdout.isTTY) return;
51287
- const current2 = true ? "2.76.22" : null;
51289
+ const current2 = true ? "2.76.23" : null;
51288
51290
  if (!current2) return;
51289
51291
  const cache = readCache();
51290
51292
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -51561,12 +51563,13 @@ var path109 = __toESM(require("path"));
51561
51563
  var SELF_UPDATE_PKG = "codeam-cli";
51562
51564
  var SELF_UPDATE_INTERVAL_MS = 60 * 60 * 1e3;
51563
51565
  var SELF_UPDATE_STARTUP_DELAY_MS = 5e3;
51566
+ var SELF_UPDATE_BOOT_QUIET_MS = 10 * 6e4;
51564
51567
  var SELF_UPDATE_DEFER_MAX_MS = 24 * 60 * 60 * 1e3;
51565
51568
  var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
51566
51569
  var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
51567
51570
  var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
51568
51571
  function currentCliVersion() {
51569
- return true ? "2.76.22" : null;
51572
+ return true ? "2.76.23" : null;
51570
51573
  }
51571
51574
  async function installedVersion(deps) {
51572
51575
  const ls = await deps.run(
@@ -51777,7 +51780,7 @@ function signalHostReady(send = process.send?.bind(process)) {
51777
51780
  }
51778
51781
  function defaultDeps() {
51779
51782
  return {
51780
- ownVersion: true ? "2.76.22" : null,
51783
+ ownVersion: true ? "2.76.23" : null,
51781
51784
  root: cliVersionsRoot(),
51782
51785
  args: process.argv.slice(3),
51783
51786
  execPath: process.execPath,
@@ -52322,6 +52325,8 @@ var HostAgentSupervisor = class {
52322
52325
  /** epoch ms when the CURRENT pending restart was first owed — the ceiling
52323
52326
  * in {@link SELF_UPDATE_DEFER_MAX_MS} is measured from here. */
52324
52327
  pendingRestartSince = null;
52328
+ /** epoch ms of `start()`; null until then. See {@link SELF_UPDATE_BOOT_QUIET_MS}. */
52329
+ startedAt = null;
52325
52330
  /** Guards the one-shot 'connected' telemetry on the first heartbeat. */
52326
52331
  reportedConnected = false;
52327
52332
  /** Live-metrics collector — stateful across beats (CPU delta + latency). */
@@ -52383,6 +52388,7 @@ var HostAgentSupervisor = class {
52383
52388
  }
52384
52389
  /** Open the control channel (reusing the relay) + start heartbeats. */
52385
52390
  start() {
52391
+ this.startedAt = this.now();
52386
52392
  if (process.env.CODESPACES === "true") {
52387
52393
  log.info("keep-awake", "skipped (codespace \u2014 no physical sleep to prevent)");
52388
52394
  } else if (this.isContainerEnv()) {
@@ -52558,6 +52564,13 @@ var HostAgentSupervisor = class {
52558
52564
  maybeRestartForUpdate(version3) {
52559
52565
  const midTurn = [...this.children.values()].some((c2) => this.isChildMidTurn(c2.proc.pid));
52560
52566
  const fleetBusy = this.fleetLanes.size > 0;
52567
+ if (this.justBootedWithSessions()) {
52568
+ log.info(
52569
+ "host-agent",
52570
+ `self-update: ${version3} installed but sessions resumed by this boot are being served \u2014 deferring restart to the next idle tick (or the next boot)`
52571
+ );
52572
+ return false;
52573
+ }
52561
52574
  if (midTurn || fleetBusy) {
52562
52575
  const since = this.pendingRestartSince ?? this.now();
52563
52576
  const waited = this.now() - since;
@@ -52576,6 +52589,12 @@ var HostAgentSupervisor = class {
52576
52589
  this.onUpdated(version3);
52577
52590
  return true;
52578
52591
  }
52592
+ /** Inside the post-boot quiet window AND serving (or still resuming) a session. */
52593
+ justBootedWithSessions() {
52594
+ if (this.startedAt === null) return false;
52595
+ if (this.now() - this.startedAt >= SELF_UPDATE_BOOT_QUIET_MS) return false;
52596
+ return this.children.size > 0 || this.pendingOrphanReplacements > 0 || [...this.resumeStates.values()].some((st3) => st3.timer !== null);
52597
+ }
52579
52598
  /** Number of live children — for tests + diagnostics. */
52580
52599
  childCount() {
52581
52600
  return this.children.size;
@@ -54288,7 +54307,7 @@ function checkChokidar() {
54288
54307
  }
54289
54308
  async function doctor(args2 = []) {
54290
54309
  const json = args2.includes("--json");
54291
- const cliVersion = true ? "2.76.22" : "0.0.0-dev";
54310
+ const cliVersion = true ? "2.76.23" : "0.0.0-dev";
54292
54311
  const apiBase2 = resolveApiBaseUrl();
54293
54312
  const diagnosticId = (0, import_node_crypto17.randomUUID)();
54294
54313
  log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
@@ -54824,7 +54843,7 @@ async function mcpWarm(argv = [], opts = {}) {
54824
54843
  // src/commands/version.ts
54825
54844
  var import_picocolors15 = __toESM(require("picocolors"));
54826
54845
  function version2() {
54827
- const v = true ? "2.76.22" : "unknown";
54846
+ const v = true ? "2.76.23" : "unknown";
54828
54847
  console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
54829
54848
  }
54830
54849