codeam-cli 2.61.71 → 2.61.72

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 +6 -0
  2. package/dist/index.js +678 -608
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2172,11 +2172,11 @@ function quiet(fn) {
2172
2172
  log.debug(TAG, "ignored sync error", err);
2173
2173
  }
2174
2174
  }
2175
- function rmIfExistsQuiet(path80) {
2175
+ function rmIfExistsQuiet(path81) {
2176
2176
  try {
2177
- fs2.rmSync(path80, { force: true });
2177
+ fs2.rmSync(path81, { force: true });
2178
2178
  } catch (err) {
2179
- log.debug(TAG, `rmIfExists failed for ${path80}`, err);
2179
+ log.debug(TAG, `rmIfExists failed for ${path81}`, err);
2180
2180
  }
2181
2181
  }
2182
2182
  function killQuiet(target, signal = "SIGTERM") {
@@ -2322,9 +2322,9 @@ var _default = makeConfig();
2322
2322
  var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, clearAll, saveCliConfig, loadCliConfig } = _default;
2323
2323
 
2324
2324
  // src/commands/pair-auto.ts
2325
- var fs58 = __toESM(require("fs"));
2325
+ var fs59 = __toESM(require("fs"));
2326
2326
  var os49 = __toESM(require("os"));
2327
- var path62 = __toESM(require("path"));
2327
+ var path63 = __toESM(require("path"));
2328
2328
  var import_crypto4 = require("crypto");
2329
2329
 
2330
2330
  // src/services/telemetry.service.ts
@@ -2360,8 +2360,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
2360
2360
  return decodedFile;
2361
2361
  };
2362
2362
  }
2363
- function normalizeWindowsPath(path80) {
2364
- return path80.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
2363
+ function normalizeWindowsPath(path81) {
2364
+ return path81.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
2365
2365
  }
2366
2366
 
2367
2367
  // ../../node_modules/@posthog/core/dist/featureFlagUtils.mjs
@@ -4841,9 +4841,9 @@ async function addSourceContext(frames) {
4841
4841
  LRU_FILE_CONTENTS_CACHE.reduce();
4842
4842
  return frames;
4843
4843
  }
4844
- function getContextLinesFromFile(path80, ranges, output) {
4844
+ function getContextLinesFromFile(path81, ranges, output) {
4845
4845
  return new Promise((resolve9) => {
4846
- const stream = (0, import_node_fs.createReadStream)(path80);
4846
+ const stream = (0, import_node_fs.createReadStream)(path81);
4847
4847
  const lineReaded = (0, import_node_readline.createInterface)({
4848
4848
  input: stream
4849
4849
  });
@@ -4858,7 +4858,7 @@ function getContextLinesFromFile(path80, ranges, output) {
4858
4858
  let rangeStart = range[0];
4859
4859
  let rangeEnd = range[1];
4860
4860
  function onStreamError() {
4861
- LRU_FILE_CONTENTS_FS_READ_FAILED.set(path80, 1);
4861
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(path81, 1);
4862
4862
  lineReaded.close();
4863
4863
  lineReaded.removeAllListeners();
4864
4864
  destroyStreamAndResolve();
@@ -4919,8 +4919,8 @@ function clearLineContext(frame) {
4919
4919
  delete frame.context_line;
4920
4920
  delete frame.post_context;
4921
4921
  }
4922
- function shouldSkipContextLinesForFile(path80) {
4923
- return path80.startsWith("node:") || path80.endsWith(".min.js") || path80.endsWith(".min.cjs") || path80.endsWith(".min.mjs") || path80.startsWith("data:");
4922
+ function shouldSkipContextLinesForFile(path81) {
4923
+ return path81.startsWith("node:") || path81.endsWith(".min.js") || path81.endsWith(".min.cjs") || path81.endsWith(".min.mjs") || path81.startsWith("data:");
4924
4924
  }
4925
4925
  function shouldSkipContextLinesForFrame(frame) {
4926
4926
  if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
@@ -7074,7 +7074,7 @@ function readAnonId() {
7074
7074
  }
7075
7075
  function superProperties() {
7076
7076
  return {
7077
- cliVersion: true ? "2.61.71" : "0.0.0-dev",
7077
+ cliVersion: true ? "2.61.72" : "0.0.0-dev",
7078
7078
  nodeVersion: process.version,
7079
7079
  platform: process.platform,
7080
7080
  arch: process.arch,
@@ -7255,7 +7255,7 @@ var os4 = __toESM(require("os"));
7255
7255
  // package.json
7256
7256
  var package_default = {
7257
7257
  name: "codeam-cli",
7258
- version: "2.61.71",
7258
+ version: "2.61.72",
7259
7259
  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.",
7260
7260
  type: "commonjs",
7261
7261
  main: "dist/index.js",
@@ -7868,12 +7868,14 @@ function computePollDelay({ baseMs, failures }) {
7868
7868
  }
7869
7869
 
7870
7870
  // src/services/headroom/proxy-supervisor.ts
7871
- var fs6 = __toESM(require("fs"));
7871
+ var fs7 = __toESM(require("fs"));
7872
7872
  var os6 = __toESM(require("os"));
7873
- var path5 = __toESM(require("path"));
7873
+ var path6 = __toESM(require("path"));
7874
7874
 
7875
7875
  // src/services/headroom/proxy-process.ts
7876
7876
  var import_child_process2 = require("child_process");
7877
+ var fs6 = __toESM(require("fs"));
7878
+ var path5 = __toESM(require("path"));
7877
7879
 
7878
7880
  // src/services/headroom/budget-args.ts
7879
7881
  function buildBudgetProxyArgs(env) {
@@ -7891,6 +7893,9 @@ var path4 = __toESM(require("path"));
7891
7893
  function headroomProxyPidfilePath() {
7892
7894
  return path4.join(os5.homedir(), ".codeam", "headroom-proxy.pid");
7893
7895
  }
7896
+ function headroomProxySpawnLockPath() {
7897
+ return path4.join(os5.homedir(), ".codeam", "headroom-proxy.spawn.lock");
7898
+ }
7894
7899
  function writeHeadroomProxyPidfile(pid) {
7895
7900
  if (!pid) return;
7896
7901
  try {
@@ -7917,6 +7922,18 @@ function isPidAlive(pid) {
7917
7922
  return false;
7918
7923
  }
7919
7924
  }
7925
+ function isHeadroomProxyProcessAlive() {
7926
+ const pid = readHeadroomProxyPidfile();
7927
+ return pid !== null && isPidAlive(pid);
7928
+ }
7929
+ function headroomProxyPidfileAgeMs(nowMs) {
7930
+ try {
7931
+ const { mtimeMs } = fs5.statSync(headroomProxyPidfilePath());
7932
+ return Math.max(0, nowMs - mtimeMs);
7933
+ } catch {
7934
+ return null;
7935
+ }
7936
+ }
7920
7937
  function pkillFallback() {
7921
7938
  try {
7922
7939
  const killer = (0, import_node_child_process.spawn)("pkill", ["-TERM", "-f", "headroom.*proxy"], {
@@ -7952,8 +7969,45 @@ function killHeadroomProxy() {
7952
7969
  }
7953
7970
 
7954
7971
  // src/services/headroom/proxy-process.ts
7955
- function spawnHeadroomProxy(logging) {
7972
+ var PROXY_SPAWN_LOCK_TTL_MS = 45e3;
7973
+ function acquireSpawnLock(nowMs) {
7974
+ const lockPath = headroomProxySpawnLockPath();
7975
+ try {
7976
+ fs6.mkdirSync(path5.dirname(lockPath), { recursive: true, mode: 448 });
7977
+ fs6.writeFileSync(lockPath, `${process.pid}
7978
+ `, { flag: "wx", mode: 384 });
7979
+ return true;
7980
+ } catch {
7981
+ try {
7982
+ const { mtimeMs } = fs6.statSync(lockPath);
7983
+ if (nowMs - mtimeMs > PROXY_SPAWN_LOCK_TTL_MS) {
7984
+ fs6.writeFileSync(lockPath, `${process.pid}
7985
+ `, { mode: 384 });
7986
+ return true;
7987
+ }
7988
+ } catch {
7989
+ }
7990
+ return false;
7991
+ }
7992
+ }
7993
+ function refreshSpawnLock() {
7994
+ try {
7995
+ const lockPath = headroomProxySpawnLockPath();
7996
+ fs6.mkdirSync(path5.dirname(lockPath), { recursive: true, mode: 448 });
7997
+ fs6.writeFileSync(lockPath, `${process.pid}
7998
+ `, { mode: 384 });
7999
+ } catch {
8000
+ }
8001
+ }
8002
+ function spawnHeadroomProxy(logging, opts = {}) {
7956
8003
  try {
8004
+ const nowMs = Date.now();
8005
+ if (opts.force) {
8006
+ refreshSpawnLock();
8007
+ } else if (!acquireSpawnLock(nowMs)) {
8008
+ log.info(logging.tag, "proxy spawn skipped \u2014 another spawn is in flight");
8009
+ return;
8010
+ }
7957
8011
  const proxyEnv = {
7958
8012
  ...process.env,
7959
8013
  HEADROOM_KOMPRESS_BACKEND: "onnx_cpu"
@@ -7978,6 +8032,7 @@ function spawnHeadroomProxy(logging) {
7978
8032
  }
7979
8033
 
7980
8034
  // src/services/headroom/proxy-supervisor.ts
8035
+ var PROXY_STARTUP_GRACE_MS = 45e3;
7981
8036
  async function ensureHeadroomProxy(deps) {
7982
8037
  if (!deps.isConfigured()) return "skip";
7983
8038
  let alive = false;
@@ -7987,21 +8042,24 @@ async function ensureHeadroomProxy(deps) {
7987
8042
  alive = false;
7988
8043
  }
7989
8044
  if (alive) return "alive";
7990
- log.warn("headroom-supervisor", "proxy :8787 is down \u2014 respawning");
8045
+ if (deps.proxyProcessAlive()) return "starting";
8046
+ const ageMs = deps.proxyStartupAgeMs();
8047
+ if (ageMs !== null && ageMs < PROXY_STARTUP_GRACE_MS) return "starting";
8048
+ log.warn("headroom-supervisor", "proxy :8787 is confirmed down \u2014 respawning");
7991
8049
  deps.spawnProxy();
7992
8050
  return "respawned";
7993
8051
  }
7994
8052
  function isHeadroomConfiguredReal(homeDir2 = os6.homedir()) {
7995
8053
  if (process.env.HEADROOM_ENABLED === "1") return true;
7996
- const csEnv = path5.join(homeDir2, ".codeam", "codespace-env.json");
8054
+ const csEnv = path6.join(homeDir2, ".codeam", "codespace-env.json");
7997
8055
  try {
7998
- const j2 = JSON.parse(fs6.readFileSync(csEnv, "utf8"));
8056
+ const j2 = JSON.parse(fs7.readFileSync(csEnv, "utf8"));
7999
8057
  if (j2.HEADROOM_ENABLED === "1" || j2.HEADROOM_ENABLED === 1) return true;
8000
8058
  } catch {
8001
8059
  }
8002
- const settings = path5.join(homeDir2, ".claude", "settings.json");
8060
+ const settings = path6.join(homeDir2, ".claude", "settings.json");
8003
8061
  try {
8004
- if (fs6.readFileSync(settings, "utf8").includes("127.0.0.1:8787")) return true;
8062
+ if (fs7.readFileSync(settings, "utf8").includes("127.0.0.1:8787")) return true;
8005
8063
  } catch {
8006
8064
  }
8007
8065
  return false;
@@ -8031,6 +8089,8 @@ function makeRealProxySupervisorDeps() {
8031
8089
  return {
8032
8090
  isConfigured: () => isHeadroomConfiguredReal(),
8033
8091
  probeAlive: probeProxyAliveReal,
8092
+ proxyProcessAlive: () => isHeadroomProxyProcessAlive(),
8093
+ proxyStartupAgeMs: () => headroomProxyPidfileAgeMs(Date.now()),
8034
8094
  spawnProxy: spawnProxyReal
8035
8095
  };
8036
8096
  }
@@ -8427,7 +8487,7 @@ var CommandRelayService = class _CommandRelayService {
8427
8487
  // fresh + clear the "CLI update available" banner after a self-update
8428
8488
  // (a codespace that reinstalls @latest reconnects via heartbeat, not
8429
8489
  // pair/reconnect). Older backends ignore the extra field.
8430
- ..."2.61.71" ? { ideVersion: "2.61.71" } : {}
8490
+ ..."2.61.72" ? { ideVersion: "2.61.72" } : {}
8431
8491
  }).then(() => log.trace("relay", `heartbeat ok online=${online}`)).catch((err) => log.trace("relay", `heartbeat failed online=${online}`, err));
8432
8492
  }
8433
8493
  /**
@@ -8493,9 +8553,9 @@ var CommandRelayService = class _CommandRelayService {
8493
8553
 
8494
8554
  // src/services/file-watcher.service.ts
8495
8555
  var import_child_process3 = require("child_process");
8496
- var fs7 = __toESM(require("fs"));
8556
+ var fs8 = __toESM(require("fs"));
8497
8557
  var os7 = __toESM(require("os"));
8498
- var path6 = __toESM(require("path"));
8558
+ var path7 = __toESM(require("path"));
8499
8559
  var import_ignore = __toESM(require("ignore"));
8500
8560
 
8501
8561
  // src/services/file-watcher/diff-parser.ts
@@ -8687,18 +8747,18 @@ var _findGitRootSeam = {
8687
8747
  resolve: _defaultFindGitRoot
8688
8748
  };
8689
8749
  function _defaultFindGitRoot(startDir) {
8690
- let dir = path6.resolve(startDir);
8750
+ let dir = path7.resolve(startDir);
8691
8751
  const seen = /* @__PURE__ */ new Set();
8692
8752
  for (let i = 0; i < 256; i++) {
8693
8753
  if (seen.has(dir)) return null;
8694
8754
  seen.add(dir);
8695
8755
  try {
8696
- const gitPath = path6.join(dir, ".git");
8697
- const stat3 = fs7.statSync(gitPath, { throwIfNoEntry: false });
8756
+ const gitPath = path7.join(dir, ".git");
8757
+ const stat3 = fs8.statSync(gitPath, { throwIfNoEntry: false });
8698
8758
  if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
8699
8759
  } catch {
8700
8760
  }
8701
- const parent = path6.dirname(dir);
8761
+ const parent = path7.dirname(dir);
8702
8762
  if (parent === dir) return null;
8703
8763
  dir = parent;
8704
8764
  }
@@ -8943,7 +9003,7 @@ var FileWatcherService = class {
8943
9003
  }
8944
9004
  async emitForFile(absPath, changeType) {
8945
9005
  if (this.stopped) return;
8946
- const fileDir = path6.dirname(absPath);
9006
+ const fileDir = path7.dirname(absPath);
8947
9007
  let gitRoot = this.gitRootByDir.get(fileDir);
8948
9008
  if (gitRoot === void 0) {
8949
9009
  gitRoot = findGitRoot(fileDir);
@@ -8956,19 +9016,19 @@ var FileWatcherService = class {
8956
9016
  );
8957
9017
  return;
8958
9018
  }
8959
- const relPathInRepo = path6.relative(gitRoot, absPath);
9019
+ const relPathInRepo = path7.relative(gitRoot, absPath);
8960
9020
  if (!relPathInRepo || relPathInRepo.startsWith("..")) return;
8961
9021
  const matcher = this.getGitIgnoreMatcher(gitRoot);
8962
9022
  if (matcher && matcher.ignores(relPathInRepo)) {
8963
9023
  log.trace(
8964
9024
  "fileWatcher",
8965
- `${relPathInRepo} ignored by ${path6.basename(gitRoot)}/.gitignore \u2014 suppressing emit`
9025
+ `${relPathInRepo} ignored by ${path7.basename(gitRoot)}/.gitignore \u2014 suppressing emit`
8966
9026
  );
8967
9027
  return;
8968
9028
  }
8969
9029
  this.opts.onRepoDirty?.(gitRoot);
8970
- const repoPath = path6.relative(this.opts.workingDir, gitRoot);
8971
- const repoName = path6.basename(gitRoot);
9030
+ const repoPath = path7.relative(this.opts.workingDir, gitRoot);
9031
+ const repoName = path7.basename(gitRoot);
8972
9032
  let diffText = "";
8973
9033
  let fileStatus = "modified";
8974
9034
  if (changeType === "unlink") {
@@ -9143,7 +9203,7 @@ var FileWatcherService = class {
9143
9203
  collectGitignoreFiles(repoRoot, dir, matcher) {
9144
9204
  let entries;
9145
9205
  try {
9146
- entries = fs7.readdirSync(dir, { withFileTypes: true });
9206
+ entries = fs8.readdirSync(dir, { withFileTypes: true });
9147
9207
  } catch {
9148
9208
  return;
9149
9209
  }
@@ -9152,16 +9212,16 @@ var FileWatcherService = class {
9152
9212
  );
9153
9213
  if (gitignoreEntry) {
9154
9214
  try {
9155
- const body = fs7.readFileSync(path6.join(dir, ".gitignore"), "utf8");
9156
- const rel = path6.relative(repoRoot, dir).replace(/\\/g, "/");
9215
+ const body = fs8.readFileSync(path7.join(dir, ".gitignore"), "utf8");
9216
+ const rel = path7.relative(repoRoot, dir).replace(/\\/g, "/");
9157
9217
  const prefixed = body.split(/\r?\n/).map((line) => {
9158
9218
  const trimmed = line.trim();
9159
9219
  if (!trimmed || trimmed.startsWith("#")) return line;
9160
9220
  if (!rel) return line;
9161
9221
  if (trimmed.startsWith("!")) {
9162
- return "!" + path6.posix.join(rel, trimmed.slice(1));
9222
+ return "!" + path7.posix.join(rel, trimmed.slice(1));
9163
9223
  }
9164
- return path6.posix.join(rel, trimmed);
9224
+ return path7.posix.join(rel, trimmed);
9165
9225
  }).join("\n");
9166
9226
  matcher.add(prefixed);
9167
9227
  } catch {
@@ -9170,7 +9230,7 @@ var FileWatcherService = class {
9170
9230
  for (const entry of entries) {
9171
9231
  if (!entry.isDirectory()) continue;
9172
9232
  if (entry.name === ".git") continue;
9173
- const childAbs = path6.join(dir, entry.name);
9233
+ const childAbs = path7.join(dir, entry.name);
9174
9234
  if (isIgnoredFilePath(childAbs)) continue;
9175
9235
  this.collectGitignoreFiles(repoRoot, childAbs, matcher);
9176
9236
  }
@@ -9801,9 +9861,9 @@ function closeAllTerminals() {
9801
9861
  }
9802
9862
 
9803
9863
  // src/commands/start/handlers.ts
9804
- var fs57 = __toESM(require("fs"));
9864
+ var fs58 = __toESM(require("fs"));
9805
9865
  var os48 = __toESM(require("os"));
9806
- var path61 = __toESM(require("path"));
9866
+ var path62 = __toESM(require("path"));
9807
9867
  var import_crypto3 = require("crypto");
9808
9868
  var import_child_process24 = require("child_process");
9809
9869
 
@@ -10005,8 +10065,8 @@ function parsePayload2(schema, raw) {
10005
10065
  }
10006
10066
 
10007
10067
  // src/services/file-ops.service.ts
10008
- var fs8 = __toESM(require("fs/promises"));
10009
- var path8 = __toESM(require("path"));
10068
+ var fs9 = __toESM(require("fs/promises"));
10069
+ var path9 = __toESM(require("path"));
10010
10070
  var MAX_FILE_BYTES = 5 * 1024 * 1024;
10011
10071
  var MAX_WALK_DEPTH = 6;
10012
10072
  var MAX_VISITED_DIRS = 5e3;
@@ -10041,12 +10101,12 @@ var SUBDIR_IGNORE = /* @__PURE__ */ new Set([
10041
10101
  "__pycache__"
10042
10102
  ]);
10043
10103
  function isUnder(parent, candidate) {
10044
- const rel = path8.relative(parent, candidate);
10045
- return rel === "" || !rel.startsWith("..") && !path8.isAbsolute(rel);
10104
+ const rel = path9.relative(parent, candidate);
10105
+ return rel === "" || !rel.startsWith("..") && !path9.isAbsolute(rel);
10046
10106
  }
10047
10107
  async function isExistingFile(absPath) {
10048
10108
  try {
10049
- const stat3 = await fs8.stat(absPath);
10109
+ const stat3 = await fs9.stat(absPath);
10050
10110
  return stat3.isFile();
10051
10111
  } catch {
10052
10112
  return false;
@@ -10059,13 +10119,13 @@ async function walkForSuffix(dir, needleVariants, depth, ctx) {
10059
10119
  ctx.visited++;
10060
10120
  let entries = [];
10061
10121
  try {
10062
- entries = await fs8.readdir(dir, { withFileTypes: true });
10122
+ entries = await fs9.readdir(dir, { withFileTypes: true });
10063
10123
  } catch {
10064
10124
  return;
10065
10125
  }
10066
10126
  for (const e of entries) {
10067
10127
  if (!e.isFile()) continue;
10068
- const full = path8.join(dir, e.name);
10128
+ const full = path9.join(dir, e.name);
10069
10129
  if (needleVariants.some((needle) => full.endsWith(needle))) {
10070
10130
  ctx.matches.push(full);
10071
10131
  if (ctx.matches.length >= ctx.cap) return;
@@ -10075,21 +10135,21 @@ async function walkForSuffix(dir, needleVariants, depth, ctx) {
10075
10135
  if (!e.isDirectory()) continue;
10076
10136
  if (SUBDIR_IGNORE.has(e.name)) continue;
10077
10137
  if (e.name.startsWith(".") && SUBDIR_IGNORE.has(e.name)) continue;
10078
- await walkForSuffix(path8.join(dir, e.name), needleVariants, depth + 1, ctx);
10138
+ await walkForSuffix(path9.join(dir, e.name), needleVariants, depth + 1, ctx);
10079
10139
  if (ctx.matches.length >= ctx.cap) return;
10080
10140
  }
10081
10141
  }
10082
10142
  async function findFile(rawPath) {
10083
10143
  const cwd = process.cwd();
10084
- if (path8.isAbsolute(rawPath)) {
10085
- const abs = path8.normalize(rawPath);
10144
+ if (path9.isAbsolute(rawPath)) {
10145
+ const abs = path9.normalize(rawPath);
10086
10146
  if (isUnder(cwd, abs) && await isExistingFile(abs)) return abs;
10087
10147
  }
10088
- const direct = path8.resolve(cwd, rawPath);
10148
+ const direct = path9.resolve(cwd, rawPath);
10089
10149
  if (isUnder(cwd, direct) && await isExistingFile(direct)) return direct;
10090
- const normalized = path8.normalize(rawPath).replace(/^[./\\]+/, "");
10150
+ const normalized = path9.normalize(rawPath).replace(/^[./\\]+/, "");
10091
10151
  const needles = [
10092
- `${path8.sep}${normalized}`,
10152
+ `${path9.sep}${normalized}`,
10093
10153
  `/${normalized}`
10094
10154
  ].filter((v, i, a) => a.indexOf(v) === i);
10095
10155
  const ctx = { visited: 0, matches: [], cap: 16 };
@@ -10103,7 +10163,7 @@ async function findWriteTarget(rawPath) {
10103
10163
  const found = await findFile(rawPath);
10104
10164
  if (found) return found;
10105
10165
  const cwd = process.cwd();
10106
- const fallback = path8.isAbsolute(rawPath) ? path8.normalize(rawPath) : path8.resolve(cwd, rawPath);
10166
+ const fallback = path9.isAbsolute(rawPath) ? path9.normalize(rawPath) : path9.resolve(cwd, rawPath);
10107
10167
  if (!isUnder(cwd, fallback)) return null;
10108
10168
  return fallback;
10109
10169
  }
@@ -10120,11 +10180,11 @@ async function readProjectFile(rawPath) {
10120
10180
  if (!abs) {
10121
10181
  return { error: `File not found in the project tree: ${rawPath}` };
10122
10182
  }
10123
- const stat3 = await fs8.stat(abs);
10183
+ const stat3 = await fs9.stat(abs);
10124
10184
  if (stat3.size > MAX_FILE_BYTES) {
10125
10185
  return { error: `File too large (${(stat3.size / 1024 / 1024).toFixed(1)} MB > ${MAX_FILE_BYTES / 1024 / 1024} MB).` };
10126
10186
  }
10127
- const buf = await fs8.readFile(abs);
10187
+ const buf = await fs9.readFile(abs);
10128
10188
  if (looksBinary(buf)) {
10129
10189
  return { error: "Binary file \u2014 refusing to open in a code editor." };
10130
10190
  }
@@ -10143,8 +10203,8 @@ async function writeProjectFile(rawPath, content) {
10143
10203
  if (Buffer.byteLength(content, "utf-8") > MAX_FILE_BYTES) {
10144
10204
  return { error: "Content too large." };
10145
10205
  }
10146
- await fs8.mkdir(path8.dirname(abs), { recursive: true });
10147
- await fs8.writeFile(abs, content, "utf-8");
10206
+ await fs9.mkdir(path9.dirname(abs), { recursive: true });
10207
+ await fs9.writeFile(abs, content, "utf-8");
10148
10208
  return { ok: true };
10149
10209
  } catch (e) {
10150
10210
  const msg = e instanceof Error ? e.message : "Write failed";
@@ -10155,8 +10215,8 @@ async function writeProjectFile(rawPath, content) {
10155
10215
  // src/services/project-ops.service.ts
10156
10216
  var import_child_process5 = require("child_process");
10157
10217
  var import_util = require("util");
10158
- var fs9 = __toESM(require("fs/promises"));
10159
- var path9 = __toESM(require("path"));
10218
+ var fs10 = __toESM(require("fs/promises"));
10219
+ var path10 = __toESM(require("path"));
10160
10220
  var execFileP = (0, import_util.promisify)(import_child_process5.execFile);
10161
10221
  var PROJECT_IGNORE = /* @__PURE__ */ new Set([
10162
10222
  "node_modules",
@@ -10204,7 +10264,7 @@ async function listProjectFiles(opts = {}) {
10204
10264
  }
10205
10265
  let entries = [];
10206
10266
  try {
10207
- entries = await fs9.readdir(dir, { withFileTypes: true });
10267
+ entries = await fs10.readdir(dir, { withFileTypes: true });
10208
10268
  } catch {
10209
10269
  return;
10210
10270
  }
@@ -10214,18 +10274,18 @@ async function listProjectFiles(opts = {}) {
10214
10274
  return;
10215
10275
  }
10216
10276
  if (PROJECT_IGNORE.has(e.name)) continue;
10217
- const full = path9.join(dir, e.name);
10277
+ const full = path10.join(dir, e.name);
10218
10278
  if (e.isDirectory()) {
10219
10279
  if (depth >= 12) continue;
10220
10280
  await walk(full, depth + 1);
10221
10281
  } else if (e.isFile()) {
10222
- const rel = path9.relative(root, full);
10282
+ const rel = path10.relative(root, full);
10223
10283
  if (q2 && !rel.toLowerCase().includes(q2) && !e.name.toLowerCase().includes(q2)) {
10224
10284
  continue;
10225
10285
  }
10226
10286
  let size = 0;
10227
10287
  try {
10228
- const st3 = await fs9.stat(full);
10288
+ const st3 = await fs10.stat(full);
10229
10289
  size = st3.size;
10230
10290
  } catch {
10231
10291
  }
@@ -10327,8 +10387,8 @@ async function gitStatus(cwd) {
10327
10387
  let hasMergeInProgress = false;
10328
10388
  try {
10329
10389
  const gitDir = (await git(["rev-parse", "--git-dir"], root)).stdout.trim();
10330
- const mergeHead = path9.isAbsolute(gitDir) ? path9.join(gitDir, "MERGE_HEAD") : path9.join(root, gitDir, "MERGE_HEAD");
10331
- await fs9.access(mergeHead);
10390
+ const mergeHead = path10.isAbsolute(gitDir) ? path10.join(gitDir, "MERGE_HEAD") : path10.join(root, gitDir, "MERGE_HEAD");
10391
+ await fs10.access(mergeHead);
10332
10392
  hasMergeInProgress = true;
10333
10393
  } catch {
10334
10394
  }
@@ -10474,7 +10534,7 @@ async function jsSearchFiles(opts, cwd, cap) {
10474
10534
  }
10475
10535
  let content = "";
10476
10536
  try {
10477
- content = await fs9.readFile(path9.join(cwd, f.path), "utf8");
10537
+ content = await fs10.readFile(path10.join(cwd, f.path), "utf8");
10478
10538
  } catch {
10479
10539
  continue;
10480
10540
  }
@@ -10551,14 +10611,14 @@ function formatRemaining(expiresAt) {
10551
10611
 
10552
10612
  // src/services/apply-file-review.service.ts
10553
10613
  var import_child_process6 = require("child_process");
10554
- var fs10 = __toESM(require("fs"));
10555
- var path10 = __toESM(require("path"));
10614
+ var fs11 = __toESM(require("fs"));
10615
+ var path11 = __toESM(require("path"));
10556
10616
  async function applyFileReview(workingDir, filePath, action) {
10557
- if (filePath.includes("..") || path10.isAbsolute(filePath)) {
10617
+ if (filePath.includes("..") || path11.isAbsolute(filePath)) {
10558
10618
  return { ok: false, action, filePath, error: "invalid file path" };
10559
10619
  }
10560
- const absFile = path10.resolve(workingDir, filePath);
10561
- const repoRoot = findGitRoot2(path10.dirname(absFile));
10620
+ const absFile = path11.resolve(workingDir, filePath);
10621
+ const repoRoot = findGitRoot2(path11.dirname(absFile));
10562
10622
  if (!repoRoot) {
10563
10623
  return {
10564
10624
  ok: false,
@@ -10567,7 +10627,7 @@ async function applyFileReview(workingDir, filePath, action) {
10567
10627
  error: `no enclosing git repo for ${filePath}`
10568
10628
  };
10569
10629
  }
10570
- const relInRepo = path10.relative(repoRoot, absFile);
10630
+ const relInRepo = path11.relative(repoRoot, absFile);
10571
10631
  if (!relInRepo || relInRepo.startsWith("..")) {
10572
10632
  return { ok: false, action, filePath, error: "path escapes repo root" };
10573
10633
  }
@@ -10616,17 +10676,17 @@ function runGit2(cwd, args2) {
10616
10676
  });
10617
10677
  }
10618
10678
  function findGitRoot2(startDir) {
10619
- let dir = path10.resolve(startDir);
10679
+ let dir = path11.resolve(startDir);
10620
10680
  const seen = /* @__PURE__ */ new Set();
10621
10681
  for (let i = 0; i < 256; i++) {
10622
10682
  if (seen.has(dir)) return null;
10623
10683
  seen.add(dir);
10624
10684
  try {
10625
- const stat3 = fs10.statSync(path10.join(dir, ".git"), { throwIfNoEntry: false });
10685
+ const stat3 = fs11.statSync(path11.join(dir, ".git"), { throwIfNoEntry: false });
10626
10686
  if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
10627
10687
  } catch {
10628
10688
  }
10629
- const parent = path10.dirname(dir);
10689
+ const parent = path11.dirname(dir);
10630
10690
  if (parent === dir) return null;
10631
10691
  dir = parent;
10632
10692
  }
@@ -10635,8 +10695,8 @@ function findGitRoot2(startDir) {
10635
10695
 
10636
10696
  // src/commands/link.ts
10637
10697
  var import_node_crypto8 = require("crypto");
10638
- var fs30 = __toESM(require("fs"));
10639
- var path34 = __toESM(require("path"));
10698
+ var fs31 = __toESM(require("fs"));
10699
+ var path35 = __toESM(require("path"));
10640
10700
  var import_chokidar = __toESM(require("chokidar"));
10641
10701
  var import_picocolors2 = __toESM(require("picocolors"));
10642
10702
 
@@ -12691,19 +12751,19 @@ function parseFrame(frame, dispatch) {
12691
12751
  }
12692
12752
 
12693
12753
  // src/os/posix.ts
12694
- var fs12 = __toESM(require("fs"));
12754
+ var fs13 = __toESM(require("fs"));
12695
12755
  var os9 = __toESM(require("os"));
12696
- var path13 = __toESM(require("path"));
12756
+ var path14 = __toESM(require("path"));
12697
12757
  var import_node_crypto2 = require("crypto");
12698
12758
 
12699
12759
  // src/os/strategy.ts
12700
- var path11 = __toESM(require("path"));
12760
+ var path12 = __toESM(require("path"));
12701
12761
  function findInPathFor(name, opts) {
12702
- const dirs = (process.env.PATH ?? "").split(path11.delimiter).filter(Boolean);
12762
+ const dirs = (process.env.PATH ?? "").split(path12.delimiter).filter(Boolean);
12703
12763
  const candidates = opts.candidates(name);
12704
12764
  for (const dir of dirs) {
12705
12765
  for (const candidate of candidates) {
12706
- const full = path11.join(dir, candidate);
12766
+ const full = path12.join(dir, candidate);
12707
12767
  try {
12708
12768
  opts.accessSync(full, opts.accessFlag);
12709
12769
  return full;
@@ -12716,9 +12776,9 @@ function findInPathFor(name, opts) {
12716
12776
 
12717
12777
  // src/services/pty/unix.strategy.ts
12718
12778
  var import_child_process7 = require("child_process");
12719
- var fs11 = __toESM(require("fs"));
12779
+ var fs12 = __toESM(require("fs"));
12720
12780
  var os8 = __toESM(require("os"));
12721
- var path12 = __toESM(require("path"));
12781
+ var path13 = __toESM(require("path"));
12722
12782
 
12723
12783
  // src/services/pty/types.ts
12724
12784
  function findInPath(name) {
@@ -12800,8 +12860,8 @@ var UnixPtyStrategy = class {
12800
12860
  }
12801
12861
  const cols = process.stdout.columns || 220;
12802
12862
  const rows = process.stdout.rows || 50;
12803
- this.helperPath = path12.join(os8.tmpdir(), "codeam-pty-helper.py");
12804
- fs11.writeFileSync(this.helperPath, PYTHON_PTY_HELPER, { mode: 420 });
12863
+ this.helperPath = path13.join(os8.tmpdir(), "codeam-pty-helper.py");
12864
+ fs12.writeFileSync(this.helperPath, PYTHON_PTY_HELPER, { mode: 420 });
12805
12865
  this.proc = (0, import_child_process7.spawn)(python, [this.helperPath, cmd, ...args2], {
12806
12866
  stdio: ["pipe", "pipe", "inherit"],
12807
12867
  cwd,
@@ -12942,7 +13002,7 @@ var PosixOsStrategy = class {
12942
13002
  }
12943
13003
  scratchPath(prefix) {
12944
13004
  const tag = `${process.pid}-${(0, import_node_crypto2.randomBytes)(4).toString("hex")}`;
12945
- return path13.join(os9.tmpdir(), `${prefix}-${tag}`);
13005
+ return path14.join(os9.tmpdir(), `${prefix}-${tag}`);
12946
13006
  }
12947
13007
  devNull() {
12948
13008
  return "/dev/null";
@@ -12950,8 +13010,8 @@ var PosixOsStrategy = class {
12950
13010
  findInPath(name) {
12951
13011
  return findInPathFor(name, {
12952
13012
  candidates: () => [name],
12953
- accessFlag: fs12.constants.X_OK,
12954
- accessSync: fs12.accessSync
13013
+ accessFlag: fs13.constants.X_OK,
13014
+ accessSync: fs13.accessSync
12955
13015
  });
12956
13016
  }
12957
13017
  augmentPath(dirs) {
@@ -12979,15 +13039,15 @@ var LinuxOsStrategy = class extends PosixOsStrategy {
12979
13039
  };
12980
13040
 
12981
13041
  // src/os/win32.ts
12982
- var fs13 = __toESM(require("fs"));
13042
+ var fs14 = __toESM(require("fs"));
12983
13043
  var os10 = __toESM(require("os"));
12984
- var path15 = __toESM(require("path"));
13044
+ var path16 = __toESM(require("path"));
12985
13045
  var import_node_crypto3 = require("crypto");
12986
13046
 
12987
13047
  // src/services/pty/windows-conpty.strategy.ts
12988
- var path14 = __toESM(require("path"));
13048
+ var path15 = __toESM(require("path"));
12989
13049
  function loadNodePty2() {
12990
- const vendoredPath = path14.join(__dirname, "vendor", "node-pty");
13050
+ const vendoredPath = path15.join(__dirname, "vendor", "node-pty");
12991
13051
  try {
12992
13052
  return require(vendoredPath);
12993
13053
  } catch (vendorErr) {
@@ -13177,21 +13237,21 @@ var Win32OsStrategy = class {
13177
13237
  }
13178
13238
  scratchPath(prefix) {
13179
13239
  const tag = `${process.pid}-${(0, import_node_crypto3.randomBytes)(4).toString("hex")}`;
13180
- return path15.join(os10.tmpdir(), `${prefix}-${tag}`);
13240
+ return path16.join(os10.tmpdir(), `${prefix}-${tag}`);
13181
13241
  }
13182
13242
  devNull() {
13183
13243
  return "NUL";
13184
13244
  }
13185
13245
  findInPath(name) {
13186
- const hasExt = path15.extname(name).length > 0;
13246
+ const hasExt = path16.extname(name).length > 0;
13187
13247
  return findInPathFor(name, {
13188
13248
  candidates: (n) => hasExt ? [n] : [...WINDOWS_EXEC_EXTS.map((ext) => `${n}${ext}`), n],
13189
13249
  // Windows has no Unix execute bit; presence + matching extension
13190
13250
  // IS the executability check. X_OK on Windows is a no-op alias
13191
13251
  // for F_OK at the libuv layer anyway, but F_OK makes intent
13192
13252
  // explicit.
13193
- accessFlag: fs13.constants.F_OK,
13194
- accessSync: fs13.accessSync
13253
+ accessFlag: fs14.constants.F_OK,
13254
+ accessSync: fs14.accessSync
13195
13255
  });
13196
13256
  }
13197
13257
  augmentPath(dirs) {
@@ -13228,7 +13288,7 @@ var Win32OsStrategy = class {
13228
13288
  return `"${escaped.replace(/[&|^<>()%!]/g, "^$&")}"`;
13229
13289
  }
13230
13290
  buildLaunch(binaryPath, extraArgs = []) {
13231
- const ext = path15.extname(binaryPath).toLowerCase();
13291
+ const ext = path16.extname(binaryPath).toLowerCase();
13232
13292
  if (ext === ".cmd" || ext === ".bat") {
13233
13293
  return { cmd: "cmd.exe", args: ["/c", binaryPath, ...extraArgs] };
13234
13294
  }
@@ -13291,20 +13351,20 @@ function buildClaudeLaunch(extraArgs = [], os60 = createOsStrategy()) {
13291
13351
 
13292
13352
  // src/agents/claude/installer.ts
13293
13353
  var import_child_process9 = require("child_process");
13294
- var path16 = __toESM(require("path"));
13354
+ var path17 = __toESM(require("path"));
13295
13355
  var os11 = __toESM(require("os"));
13296
13356
  function probeInstallDirs() {
13297
13357
  const home = os11.homedir();
13298
13358
  if (process.platform === "win32") {
13299
13359
  return [
13300
- path16.join(home, ".claude", "local"),
13301
- path16.join(home, "AppData", "Local", "AnthropicClaude"),
13302
- path16.join(home, "AppData", "Local", "Programs", "AnthropicClaude")
13360
+ path17.join(home, ".claude", "local"),
13361
+ path17.join(home, "AppData", "Local", "AnthropicClaude"),
13362
+ path17.join(home, "AppData", "Local", "Programs", "AnthropicClaude")
13303
13363
  ];
13304
13364
  }
13305
13365
  return [
13306
- path16.join(home, ".local", "bin"),
13307
- path16.join(home, ".claude", "local"),
13366
+ path17.join(home, ".local", "bin"),
13367
+ path17.join(home, ".claude", "local"),
13308
13368
  "/usr/local/bin"
13309
13369
  ];
13310
13370
  }
@@ -13313,7 +13373,7 @@ function isAvailable() {
13313
13373
  }
13314
13374
  function augmentPath() {
13315
13375
  const dirs = probeInstallDirs();
13316
- const sep7 = path16.delimiter;
13376
+ const sep7 = path17.delimiter;
13317
13377
  const current = process.env.PATH ?? "";
13318
13378
  const existing = new Set(current.split(sep7).filter(Boolean));
13319
13379
  const additions = dirs.filter((d3) => !existing.has(d3));
@@ -13375,9 +13435,9 @@ var import_node_child_process3 = require("child_process");
13375
13435
 
13376
13436
  // src/agents/claude/local-token.ts
13377
13437
  var import_node_child_process2 = require("child_process");
13378
- var fs14 = __toESM(require("fs"));
13438
+ var fs15 = __toESM(require("fs"));
13379
13439
  var os12 = __toESM(require("os"));
13380
- var path17 = __toESM(require("path"));
13440
+ var path18 = __toESM(require("path"));
13381
13441
  var import_node_util3 = require("util");
13382
13442
  var execFileP2 = (0, import_node_util3.promisify)(import_node_child_process2.execFile);
13383
13443
  var KEYCHAIN_SERVICE_NAMES = [
@@ -13389,15 +13449,15 @@ var KEYCHAIN_SERVICE_NAMES = [
13389
13449
  function claudeCredentialsPaths() {
13390
13450
  const home = os12.homedir();
13391
13451
  return [
13392
- path17.join(home, ".claude", ".credentials.json"),
13393
- path17.join(home, ".config", "claude", ".credentials.json")
13452
+ path18.join(home, ".claude", ".credentials.json"),
13453
+ path18.join(home, ".config", "claude", ".credentials.json")
13394
13454
  ];
13395
13455
  }
13396
13456
  async function extractLocalClaudeToken() {
13397
13457
  const agentState = readClaudeAgentState();
13398
13458
  for (const flat of claudeCredentialsPaths()) {
13399
- if (!fs14.existsSync(flat)) continue;
13400
- const credential = fs14.readFileSync(flat, "utf8").trim();
13459
+ if (!fs15.existsSync(flat)) continue;
13460
+ const credential = fs15.readFileSync(flat, "utf8").trim();
13401
13461
  if (credential.length > 0) {
13402
13462
  return { method: "oauth", credential, source: "flat-file", agentState };
13403
13463
  }
@@ -13422,10 +13482,10 @@ async function extractLocalClaudeToken() {
13422
13482
  }
13423
13483
  function readClaudeAgentState() {
13424
13484
  const STATE_MAX_BYTES = 256 * 1024;
13425
- const candidate = path17.join(os12.homedir(), ".claude.json");
13485
+ const candidate = path18.join(os12.homedir(), ".claude.json");
13426
13486
  try {
13427
- if (!fs14.existsSync(candidate)) return void 0;
13428
- const buf = fs14.readFileSync(candidate);
13487
+ if (!fs15.existsSync(candidate)) return void 0;
13488
+ const buf = fs15.readFileSync(candidate);
13429
13489
  if (buf.length === 0 || buf.length > STATE_MAX_BYTES) return void 0;
13430
13490
  const text = buf.toString("utf8").trim();
13431
13491
  return text.length > 0 ? text : void 0;
@@ -13512,9 +13572,9 @@ function claudeLoginLauncher() {
13512
13572
  }
13513
13573
 
13514
13574
  // src/agents/claude/quota.ts
13515
- var fs15 = __toESM(require("fs"));
13575
+ var fs16 = __toESM(require("fs"));
13516
13576
  var os13 = __toESM(require("os"));
13517
- var path18 = __toESM(require("path"));
13577
+ var path19 = __toESM(require("path"));
13518
13578
  var import_child_process10 = require("child_process");
13519
13579
  var HELPER_SCRIPT = `import os,pty,sys,select,signal,struct,fcntl,termios,errno
13520
13580
  m,s=pty.openpty()
@@ -13577,8 +13637,8 @@ async function fetchClaudeQuota() {
13577
13637
  resolve9(null);
13578
13638
  return;
13579
13639
  }
13580
- const helperPath = path18.join(os13.tmpdir(), "codeam-quota-helper.py");
13581
- fs15.writeFileSync(helperPath, HELPER_SCRIPT, { mode: 420 });
13640
+ const helperPath = path19.join(os13.tmpdir(), "codeam-quota-helper.py");
13641
+ fs16.writeFileSync(helperPath, HELPER_SCRIPT, { mode: 420 });
13582
13642
  const python = findInPath("python3") ?? findInPath("python");
13583
13643
  if (!python) {
13584
13644
  resolve9(null);
@@ -13605,7 +13665,7 @@ async function fetchClaudeQuota() {
13605
13665
  } catch {
13606
13666
  }
13607
13667
  try {
13608
- fs15.unlinkSync(helperPath);
13668
+ fs16.unlinkSync(helperPath);
13609
13669
  } catch {
13610
13670
  }
13611
13671
  resolve9(result);
@@ -13689,24 +13749,24 @@ async function spawnAndCapture(cmd, args2, opts = {}) {
13689
13749
  }
13690
13750
 
13691
13751
  // src/agents/claude/history.ts
13692
- var fs16 = __toESM(require("fs"));
13693
- var path19 = __toESM(require("path"));
13752
+ var fs17 = __toESM(require("fs"));
13753
+ var path20 = __toESM(require("path"));
13694
13754
  var os14 = __toESM(require("os"));
13695
13755
  function encodeCwd(cwd) {
13696
13756
  return cwd.replace(/[\\/:_]/g, "-");
13697
13757
  }
13698
13758
  function resolveHistoryDir(cwd, projectsRoot) {
13699
- const root = projectsRoot ?? path19.join(os14.homedir(), ".claude", "projects");
13700
- const primary = path19.join(root, encodeCwd(cwd));
13701
- if (fs16.existsSync(primary)) return primary;
13759
+ const root = projectsRoot ?? path20.join(os14.homedir(), ".claude", "projects");
13760
+ const primary = path20.join(root, encodeCwd(cwd));
13761
+ if (fs17.existsSync(primary)) return primary;
13702
13762
  try {
13703
- const entries = fs16.readdirSync(root, { withFileTypes: true });
13763
+ const entries = fs17.readdirSync(root, { withFileTypes: true });
13704
13764
  const wanted = encodeCwd(cwd);
13705
13765
  for (const e of entries) {
13706
13766
  if (!e.isDirectory()) continue;
13707
13767
  const candidate = e.name.replace(/-+/g, "-");
13708
13768
  if (candidate === wanted.replace(/-+/g, "-")) {
13709
- return path19.join(root, e.name);
13769
+ return path20.join(root, e.name);
13710
13770
  }
13711
13771
  }
13712
13772
  } catch {
@@ -13716,31 +13776,31 @@ function resolveHistoryDir(cwd, projectsRoot) {
13716
13776
  function resolveHistoryFile(cwd, sessionId, projectsRoot) {
13717
13777
  const dir = resolveHistoryDir(cwd, projectsRoot);
13718
13778
  if (!dir) return null;
13719
- const filePath = path19.join(dir, `${sessionId}.jsonl`);
13720
- return fs16.existsSync(filePath) ? filePath : null;
13779
+ const filePath = path20.join(dir, `${sessionId}.jsonl`);
13780
+ return fs17.existsSync(filePath) ? filePath : null;
13721
13781
  }
13722
13782
  function getCurrentUsage(historyDir, bootTimeMs = 0) {
13723
13783
  const GRACE_MS = 5e3;
13724
13784
  const cutoff = bootTimeMs > 0 ? bootTimeMs - GRACE_MS : 0;
13725
13785
  let entries;
13726
13786
  try {
13727
- entries = fs16.readdirSync(historyDir, { withFileTypes: true });
13787
+ entries = fs17.readdirSync(historyDir, { withFileTypes: true });
13728
13788
  } catch {
13729
13789
  return null;
13730
13790
  }
13731
13791
  const files = entries.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
13732
13792
  try {
13733
- const stat3 = fs16.statSync(path19.join(historyDir, e.name));
13793
+ const stat3 = fs17.statSync(path20.join(historyDir, e.name));
13734
13794
  return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
13735
13795
  } catch {
13736
13796
  return { name: e.name, mtime: 0, birthtime: 0 };
13737
13797
  }
13738
13798
  }).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
13739
13799
  if (files.length === 0) return null;
13740
- const filePath = path19.join(historyDir, files[0].name);
13800
+ const filePath = path20.join(historyDir, files[0].name);
13741
13801
  let raw;
13742
13802
  try {
13743
- raw = fs16.readFileSync(filePath, "utf8");
13803
+ raw = fs17.readFileSync(filePath, "utf8");
13744
13804
  } catch {
13745
13805
  return null;
13746
13806
  }
@@ -13785,7 +13845,7 @@ function parseHistoryFile(filePath) {
13785
13845
  const out2 = [];
13786
13846
  let raw;
13787
13847
  try {
13788
- raw = fs16.readFileSync(filePath, "utf8");
13848
+ raw = fs17.readFileSync(filePath, "utf8");
13789
13849
  } catch {
13790
13850
  return out2;
13791
13851
  }
@@ -13830,7 +13890,7 @@ function listResumableSessions(cwd) {
13830
13890
  if (!dir) return [];
13831
13891
  let entries;
13832
13892
  try {
13833
- entries = fs16.readdirSync(dir, { withFileTypes: true });
13893
+ entries = fs17.readdirSync(dir, { withFileTypes: true });
13834
13894
  } catch {
13835
13895
  return [];
13836
13896
  }
@@ -13838,15 +13898,15 @@ function listResumableSessions(cwd) {
13838
13898
  for (const entry of entries) {
13839
13899
  if (!entry.isFile() || !entry.name.endsWith(".jsonl")) continue;
13840
13900
  const id = entry.name.slice(0, -".jsonl".length);
13841
- const filePath = path19.join(dir, entry.name);
13901
+ const filePath = path20.join(dir, entry.name);
13842
13902
  let timestamp = Date.now();
13843
13903
  try {
13844
- timestamp = fs16.statSync(filePath).mtimeMs;
13904
+ timestamp = fs17.statSync(filePath).mtimeMs;
13845
13905
  } catch {
13846
13906
  }
13847
13907
  let summary = "";
13848
13908
  try {
13849
- const raw = fs16.readFileSync(filePath, "utf8");
13909
+ const raw = fs17.readFileSync(filePath, "utf8");
13850
13910
  for (const line of raw.split("\n")) {
13851
13911
  if (!line.trim()) continue;
13852
13912
  try {
@@ -14012,21 +14072,21 @@ var ClaudeRuntimeStrategy = class {
14012
14072
  };
14013
14073
 
14014
14074
  // src/agents/claude/deploy.ts
14015
- var fs18 = __toESM(require("fs"));
14075
+ var fs19 = __toESM(require("fs"));
14016
14076
  var os16 = __toESM(require("os"));
14017
- var path21 = __toESM(require("path"));
14077
+ var path22 = __toESM(require("path"));
14018
14078
 
14019
14079
  // src/agents/claude/credentials.ts
14020
14080
  var import_child_process12 = require("child_process");
14021
- var fs17 = __toESM(require("fs"));
14081
+ var fs18 = __toESM(require("fs"));
14022
14082
  var os15 = __toESM(require("os"));
14023
- var path20 = __toESM(require("path"));
14083
+ var path21 = __toESM(require("path"));
14024
14084
  var import_util2 = require("util");
14025
14085
  var execFileP3 = (0, import_util2.promisify)(import_child_process12.execFile);
14026
14086
  async function detectLocalClaudeCredentials() {
14027
- const localClaudeDir = path20.join(os15.homedir(), ".claude");
14028
- const flat = path20.join(localClaudeDir, ".credentials.json");
14029
- if (fs17.existsSync(flat)) {
14087
+ const localClaudeDir = path21.join(os15.homedir(), ".claude");
14088
+ const flat = path21.join(localClaudeDir, ".credentials.json");
14089
+ if (fs18.existsSync(flat)) {
14030
14090
  return { source: "flat-file", description: "~/.claude/.credentials.json" };
14031
14091
  }
14032
14092
  if (os15.platform() === "darwin") {
@@ -14044,9 +14104,9 @@ async function detectLocalClaudeCredentials() {
14044
14104
  return { source: "none", description: "" };
14045
14105
  }
14046
14106
  async function bridgeClaudeCredentials(provider, workspaceId) {
14047
- const localClaudeDir = path20.join(os15.homedir(), ".claude");
14048
- const fileBased = path20.join(localClaudeDir, ".credentials.json");
14049
- if (fs17.existsSync(fileBased)) {
14107
+ const localClaudeDir = path21.join(os15.homedir(), ".claude");
14108
+ const fileBased = path21.join(localClaudeDir, ".credentials.json");
14109
+ if (fs18.existsSync(fileBased)) {
14050
14110
  return { source: "flat-file", description: "~/.claude/.credentials.json" };
14051
14111
  }
14052
14112
  if (process.platform === "darwin") {
@@ -14138,8 +14198,8 @@ var ClaudeDeployStrategy = class {
14138
14198
  process.exit(1);
14139
14199
  }
14140
14200
  claudeStep.stop("\u2713 Claude CLI installed");
14141
- const localClaudeDir = path21.join(os16.homedir(), ".claude");
14142
- const haveLocalClaude = fs18.existsSync(localClaudeDir) && fs18.statSync(localClaudeDir).isDirectory();
14201
+ const localClaudeDir = path22.join(os16.homedir(), ".claude");
14202
+ const haveLocalClaude = fs19.existsSync(localClaudeDir) && fs19.statSync(localClaudeDir).isDirectory();
14143
14203
  if (haveLocalClaude) {
14144
14204
  const copyStep = fe();
14145
14205
  copyStep.start("Copying local Claude config to workspace\u2026");
@@ -14193,10 +14253,10 @@ var ClaudeDeployStrategy = class {
14193
14253
  }
14194
14254
  }
14195
14255
  if (opts.bridged !== "none") {
14196
- const localClaudeJson = path21.join(os16.homedir(), ".claude.json");
14197
- if (fs18.existsSync(localClaudeJson)) {
14256
+ const localClaudeJson = path22.join(os16.homedir(), ".claude.json");
14257
+ if (fs19.existsSync(localClaudeJson)) {
14198
14258
  try {
14199
- const contents = fs18.readFileSync(localClaudeJson);
14259
+ const contents = fs19.readFileSync(localClaudeJson);
14200
14260
  await provider.uploadFile(
14201
14261
  workspaceId,
14202
14262
  "/home/codespace/.claude.json",
@@ -14229,7 +14289,7 @@ var ClaudeDeployStrategy = class {
14229
14289
 
14230
14290
  // src/agents/codex/runtime.ts
14231
14291
  var import_node_child_process5 = require("child_process");
14232
- var path24 = __toESM(require("path"));
14292
+ var path25 = __toESM(require("path"));
14233
14293
 
14234
14294
  // src/agents/codex/history.ts
14235
14295
  var import_node_fs3 = __toESM(require("fs"));
@@ -14589,16 +14649,16 @@ function getCurrentUsage2(historyDir) {
14589
14649
  var import_node_child_process4 = require("child_process");
14590
14650
 
14591
14651
  // src/agents/codex/local-token.ts
14592
- var fs20 = __toESM(require("fs"));
14652
+ var fs21 = __toESM(require("fs"));
14593
14653
  var os18 = __toESM(require("os"));
14594
- var path23 = __toESM(require("path"));
14654
+ var path24 = __toESM(require("path"));
14595
14655
  function codexCredentialsPath() {
14596
- return path23.join(os18.homedir(), ".codex", "auth.json");
14656
+ return path24.join(os18.homedir(), ".codex", "auth.json");
14597
14657
  }
14598
14658
  async function extractLocalCodexToken() {
14599
14659
  const file = codexCredentialsPath();
14600
- if (!fs20.existsSync(file)) return null;
14601
- const credential = fs20.readFileSync(file, "utf8").trim();
14660
+ if (!fs21.existsSync(file)) return null;
14661
+ const credential = fs21.readFileSync(file, "utf8").trim();
14602
14662
  if (credential.length === 0) return null;
14603
14663
  return { method: "oauth", credential, source: "flat-file" };
14604
14664
  }
@@ -14821,7 +14881,7 @@ function augmentNpmGlobalBin(os60) {
14821
14881
  if (result.status !== 0) return;
14822
14882
  const prefix = result.stdout.toString().trim();
14823
14883
  if (!prefix) return;
14824
- const binDir = os60.id === "win32" ? prefix : path24.join(prefix, "bin");
14884
+ const binDir = os60.id === "win32" ? prefix : path25.join(prefix, "bin");
14825
14885
  os60.augmentPath([binDir]);
14826
14886
  } catch {
14827
14887
  }
@@ -14947,9 +15007,9 @@ async function ensureCoderabbitInstalled(os60) {
14947
15007
 
14948
15008
  // src/agents/coderabbit/link.ts
14949
15009
  var import_node_child_process7 = require("child_process");
14950
- var fs22 = __toESM(require("fs"));
15010
+ var fs23 = __toESM(require("fs"));
14951
15011
  var os20 = __toESM(require("os"));
14952
- var path26 = __toESM(require("path"));
15012
+ var path27 = __toESM(require("path"));
14953
15013
 
14954
15014
  // src/agents/strategy.ts
14955
15015
  function validateNonEmptyCredential(token) {
@@ -14958,12 +15018,12 @@ function validateNonEmptyCredential(token) {
14958
15018
 
14959
15019
  // src/agents/coderabbit/link.ts
14960
15020
  function authPath() {
14961
- return path26.join(os20.homedir(), ".coderabbit", "auth.json");
15021
+ return path27.join(os20.homedir(), ".coderabbit", "auth.json");
14962
15022
  }
14963
15023
  async function extractLocalCoderabbitToken() {
14964
15024
  const file = authPath();
14965
- if (!fs22.existsSync(file)) return null;
14966
- const credential = fs22.readFileSync(file, "utf8").trim();
15025
+ if (!fs23.existsSync(file)) return null;
15026
+ const credential = fs23.readFileSync(file, "utf8").trim();
14967
15027
  if (credential.length === 0) return null;
14968
15028
  return { method: "oauth", credential, source: "flat-file" };
14969
15029
  }
@@ -15036,8 +15096,8 @@ function pickLine(obj) {
15036
15096
  function toHunk(raw, groupSeverity) {
15037
15097
  if (!raw || typeof raw !== "object") return null;
15038
15098
  const o = raw;
15039
- const path80 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
15040
- if (!path80) return null;
15099
+ const path81 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
15100
+ if (!path81) return null;
15041
15101
  const message = asString(
15042
15102
  pick(o, [
15043
15103
  "comment",
@@ -15054,7 +15114,7 @@ function toHunk(raw, groupSeverity) {
15054
15114
  const severity = normSeverity(pick(o, ["severity", "level", "priority", "impact"])) ?? normSeverity(groupSeverity);
15055
15115
  const locObj = pick(o, ["location"]) ?? o;
15056
15116
  return {
15057
- path: path80.trim(),
15117
+ path: path81.trim(),
15058
15118
  line: pickLine(o) ?? pickLine(locObj),
15059
15119
  severity,
15060
15120
  message: (title && message ? `${title}: ${message}` : title || message).trim() || "(no message)"
@@ -15137,10 +15197,10 @@ function parsePlain(stdout) {
15137
15197
  for (const line of stdout.split(/\r?\n/)) {
15138
15198
  const m = line.match(HUNK_LINE_RE);
15139
15199
  if (!m) continue;
15140
- const [, path80, lineNo, sevToken, message] = m;
15141
- if (!path80 || !lineNo || !message) continue;
15200
+ const [, path81, lineNo, sevToken, message] = m;
15201
+ if (!path81 || !lineNo || !message) continue;
15142
15202
  hunks.push({
15143
- path: path80.trim(),
15203
+ path: path81.trim(),
15144
15204
  line: Number(lineNo),
15145
15205
  severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
15146
15206
  message: message.trim().replace(/^[*-]\s+/, "")
@@ -15303,39 +15363,39 @@ CodeRabbit review timed out after ${Math.round(
15303
15363
  };
15304
15364
 
15305
15365
  // src/agents/cursor/history.ts
15306
- var fs23 = __toESM(require("fs"));
15366
+ var fs24 = __toESM(require("fs"));
15307
15367
  var os21 = __toESM(require("os"));
15308
- var path27 = __toESM(require("path"));
15368
+ var path28 = __toESM(require("path"));
15309
15369
  var import_node_crypto5 = require("crypto");
15310
- var HISTORY_ROOT = path27.join(os21.homedir(), ".cursor", "projects");
15311
- var CURSOR_HOME = path27.join(os21.homedir(), ".cursor");
15370
+ var HISTORY_ROOT = path28.join(os21.homedir(), ".cursor", "projects");
15371
+ var CURSOR_HOME = path28.join(os21.homedir(), ".cursor");
15312
15372
  var STORE_FILES = ["store.db", "store.db-wal", "store.db-shm"];
15313
15373
  function acpSessionDir(sessionId) {
15314
- return path27.join(CURSOR_HOME, "acp-sessions", sessionId);
15374
+ return path28.join(CURSOR_HOME, "acp-sessions", sessionId);
15315
15375
  }
15316
15376
  function nativeStoreDir(cwd, sessionId) {
15317
- const chatsRoot = path27.join(CURSOR_HOME, "chats");
15377
+ const chatsRoot = path28.join(CURSOR_HOME, "chats");
15318
15378
  let buckets = [];
15319
15379
  try {
15320
- buckets = fs23.readdirSync(chatsRoot);
15380
+ buckets = fs24.readdirSync(chatsRoot);
15321
15381
  } catch {
15322
15382
  }
15323
15383
  for (const b of buckets) {
15324
- const candidate = path27.join(chatsRoot, b, sessionId);
15325
- if (fs23.existsSync(path27.join(candidate, "store.db"))) return candidate;
15384
+ const candidate = path28.join(chatsRoot, b, sessionId);
15385
+ if (fs24.existsSync(path28.join(candidate, "store.db"))) return candidate;
15326
15386
  }
15327
- const computed = path27.join(chatsRoot, (0, import_node_crypto5.createHash)("md5").update(cwd).digest("hex"), sessionId);
15328
- return fs23.existsSync(computed) ? computed : null;
15387
+ const computed = path28.join(chatsRoot, (0, import_node_crypto5.createHash)("md5").update(cwd).digest("hex"), sessionId);
15388
+ return fs24.existsSync(computed) ? computed : null;
15329
15389
  }
15330
15390
  function copyStoreFiles(srcDir, dstDir) {
15331
- fs23.mkdirSync(dstDir, { recursive: true });
15391
+ fs24.mkdirSync(dstDir, { recursive: true });
15332
15392
  for (const f of STORE_FILES) {
15333
- const dst = path27.join(dstDir, f);
15334
- if (fs23.existsSync(dst)) fs23.rmSync(dst, { force: true });
15393
+ const dst = path28.join(dstDir, f);
15394
+ if (fs24.existsSync(dst)) fs24.rmSync(dst, { force: true });
15335
15395
  }
15336
15396
  for (const f of STORE_FILES) {
15337
- const src = path27.join(srcDir, f);
15338
- if (fs23.existsSync(src)) fs23.copyFileSync(src, path27.join(dstDir, f));
15397
+ const src = path28.join(srcDir, f);
15398
+ if (fs24.existsSync(src)) fs24.copyFileSync(src, path28.join(dstDir, f));
15339
15399
  }
15340
15400
  }
15341
15401
  function bridgeNativeToAcp(cwd, sessionId) {
@@ -15347,8 +15407,8 @@ function bridgeNativeToAcp(cwd, sessionId) {
15347
15407
  }
15348
15408
  const dst = acpSessionDir(sessionId);
15349
15409
  copyStoreFiles(src, dst);
15350
- fs23.writeFileSync(
15351
- path27.join(dst, "meta.json"),
15410
+ fs24.writeFileSync(
15411
+ path28.join(dst, "meta.json"),
15352
15412
  JSON.stringify({ schemaVersion: 1, cwd })
15353
15413
  );
15354
15414
  log.info("cursor", `baton bridge native\u2192acp ok (${sessionId.slice(0, 8)})`);
@@ -15359,11 +15419,11 @@ function bridgeNativeToAcp(cwd, sessionId) {
15359
15419
  function bridgeAcpToNative(cwd, sessionId) {
15360
15420
  try {
15361
15421
  const src = acpSessionDir(sessionId);
15362
- if (!fs23.existsSync(path27.join(src, "store.db"))) {
15422
+ if (!fs24.existsSync(path28.join(src, "store.db"))) {
15363
15423
  log.warn("cursor", `baton bridge: no acp store for ${sessionId.slice(0, 8)} \u2014 skip`);
15364
15424
  return;
15365
15425
  }
15366
- const dst = nativeStoreDir(cwd, sessionId) ?? path27.join(CURSOR_HOME, "chats", (0, import_node_crypto5.createHash)("md5").update(cwd).digest("hex"), sessionId);
15426
+ const dst = nativeStoreDir(cwd, sessionId) ?? path28.join(CURSOR_HOME, "chats", (0, import_node_crypto5.createHash)("md5").update(cwd).digest("hex"), sessionId);
15367
15427
  copyStoreFiles(src, dst);
15368
15428
  log.info("cursor", `baton bridge acp\u2192native ok (${sessionId.slice(0, 8)})`);
15369
15429
  } catch (err) {
@@ -15374,26 +15434,26 @@ function encodeCursorCwd(cwd) {
15374
15434
  return cwd.replace(/^[/\\]+/, "").replace(/[/\\:]/g, "-");
15375
15435
  }
15376
15436
  function resolveHistoryFile3(cwd, sessionId, root = HISTORY_ROOT) {
15377
- const rel = path27.join("agent-transcripts", sessionId, `${sessionId}.jsonl`);
15378
- const primary = path27.join(root, encodeCursorCwd(cwd), rel);
15379
- if (fs23.existsSync(primary)) return primary;
15437
+ const rel = path28.join("agent-transcripts", sessionId, `${sessionId}.jsonl`);
15438
+ const primary = path28.join(root, encodeCursorCwd(cwd), rel);
15439
+ if (fs24.existsSync(primary)) return primary;
15380
15440
  let entries;
15381
15441
  try {
15382
- entries = fs23.readdirSync(root, { withFileTypes: true });
15442
+ entries = fs24.readdirSync(root, { withFileTypes: true });
15383
15443
  } catch {
15384
15444
  return null;
15385
15445
  }
15386
15446
  for (const e of entries) {
15387
15447
  if (!e.isDirectory()) continue;
15388
- const candidate = path27.join(root, e.name, rel);
15389
- if (fs23.existsSync(candidate)) return candidate;
15448
+ const candidate = path28.join(root, e.name, rel);
15449
+ if (fs24.existsSync(candidate)) return candidate;
15390
15450
  }
15391
15451
  return null;
15392
15452
  }
15393
15453
  function resolveHistoryDir3(cwd) {
15394
- if (!fs23.existsSync(HISTORY_ROOT)) return null;
15395
- const dir = path27.join(HISTORY_ROOT, encodeCursorCwd(cwd));
15396
- return fs23.existsSync(dir) ? dir : null;
15454
+ if (!fs24.existsSync(HISTORY_ROOT)) return null;
15455
+ const dir = path28.join(HISTORY_ROOT, encodeCursorCwd(cwd));
15456
+ return fs24.existsSync(dir) ? dir : null;
15397
15457
  }
15398
15458
  function extractText2(content) {
15399
15459
  if (!Array.isArray(content)) return "";
@@ -15406,7 +15466,7 @@ function unwrapUserQuery(text) {
15406
15466
  function parseHistoryFile3(filePath) {
15407
15467
  let raw;
15408
15468
  try {
15409
- raw = fs23.readFileSync(filePath, "utf8");
15469
+ raw = fs24.readFileSync(filePath, "utf8");
15410
15470
  } catch {
15411
15471
  return [];
15412
15472
  }
@@ -15444,16 +15504,16 @@ function getCurrentUsage3(_historyDir) {
15444
15504
  var import_node_child_process9 = require("child_process");
15445
15505
 
15446
15506
  // src/agents/cursor/local-token.ts
15447
- var fs24 = __toESM(require("fs"));
15507
+ var fs25 = __toESM(require("fs"));
15448
15508
  var os22 = __toESM(require("os"));
15449
- var path28 = __toESM(require("path"));
15509
+ var path29 = __toESM(require("path"));
15450
15510
  function cursorCredentialsPath() {
15451
- return path28.join(os22.homedir(), ".cursor", "auth.json");
15511
+ return path29.join(os22.homedir(), ".cursor", "auth.json");
15452
15512
  }
15453
15513
  async function extractLocalCursorToken() {
15454
15514
  const file = cursorCredentialsPath();
15455
- if (!fs24.existsSync(file)) return null;
15456
- const credential = fs24.readFileSync(file, "utf8").trim();
15515
+ if (!fs25.existsSync(file)) return null;
15516
+ const credential = fs25.readFileSync(file, "utf8").trim();
15457
15517
  if (credential.length === 0) return null;
15458
15518
  return { method: "oauth", credential, source: "flat-file" };
15459
15519
  }
@@ -15696,12 +15756,12 @@ var CursorRuntimeStrategy = class {
15696
15756
  };
15697
15757
 
15698
15758
  // src/agents/aider/history.ts
15699
- var fs25 = __toESM(require("fs"));
15700
- var path29 = __toESM(require("path"));
15759
+ var fs26 = __toESM(require("fs"));
15760
+ var path30 = __toESM(require("path"));
15701
15761
  var AIDER_HISTORY_FILE = ".aider.chat.history.md";
15702
15762
  function resolveHistoryDir4(cwd) {
15703
- const candidate = path29.join(cwd, AIDER_HISTORY_FILE);
15704
- return fs25.existsSync(candidate) ? cwd : null;
15763
+ const candidate = path30.join(cwd, AIDER_HISTORY_FILE);
15764
+ return fs26.existsSync(candidate) ? cwd : null;
15705
15765
  }
15706
15766
  function parseHistoryFile4(_filePath) {
15707
15767
  return [];
@@ -15714,10 +15774,10 @@ function getCurrentUsage4(_historyDir) {
15714
15774
  var import_node_child_process11 = require("child_process");
15715
15775
 
15716
15776
  // src/agents/aider/local-token.ts
15717
- var fs26 = __toESM(require("fs"));
15777
+ var fs27 = __toESM(require("fs"));
15718
15778
  var os23 = __toESM(require("os"));
15719
- var path30 = __toESM(require("path"));
15720
- var AIDER_CONF_FILE = path30.join(os23.homedir(), ".aider.conf.yml");
15779
+ var path31 = __toESM(require("path"));
15780
+ var AIDER_CONF_FILE = path31.join(os23.homedir(), ".aider.conf.yml");
15721
15781
  var API_KEY_ENV_VARS = [
15722
15782
  "ANTHROPIC_API_KEY",
15723
15783
  "OPENAI_API_KEY",
@@ -15732,8 +15792,8 @@ async function extractLocalAiderToken() {
15732
15792
  return { method: "api_key", credential: value.trim(), source: "flat-file" };
15733
15793
  }
15734
15794
  }
15735
- if (fs26.existsSync(AIDER_CONF_FILE)) {
15736
- const conf = fs26.readFileSync(AIDER_CONF_FILE, "utf8");
15795
+ if (fs27.existsSync(AIDER_CONF_FILE)) {
15796
+ const conf = fs27.readFileSync(AIDER_CONF_FILE, "utf8");
15737
15797
  const match = conf.match(/^api-key:\s*['"]?([^'"\n]+)['"]?\s*$/m);
15738
15798
  if (match) {
15739
15799
  return { method: "api_key", credential: match[1].trim(), source: "flat-file" };
@@ -15916,19 +15976,19 @@ var import_node_crypto6 = require("crypto");
15916
15976
  var import_node_child_process12 = require("child_process");
15917
15977
 
15918
15978
  // src/agents/gemini/local-token.ts
15919
- var fs27 = __toESM(require("fs"));
15979
+ var fs28 = __toESM(require("fs"));
15920
15980
  var os24 = __toESM(require("os"));
15921
- var path31 = __toESM(require("path"));
15981
+ var path32 = __toESM(require("path"));
15922
15982
  function geminiCredentialsPath() {
15923
- return path31.join(os24.homedir(), ".gemini", "oauth_creds.json");
15983
+ return path32.join(os24.homedir(), ".gemini", "oauth_creds.json");
15924
15984
  }
15925
15985
  function geminiCredentialsPaths() {
15926
15986
  return [geminiCredentialsPath()];
15927
15987
  }
15928
15988
  async function extractLocalGeminiToken() {
15929
15989
  const file = geminiCredentialsPath();
15930
- if (!fs27.existsSync(file)) return null;
15931
- const credential = fs27.readFileSync(file, "utf8").trim();
15990
+ if (!fs28.existsSync(file)) return null;
15991
+ const credential = fs28.readFileSync(file, "utf8").trim();
15932
15992
  if (credential.length === 0) return null;
15933
15993
  return { method: "oauth", credential, source: "flat-file" };
15934
15994
  }
@@ -15984,20 +16044,20 @@ function geminiLoginLauncher() {
15984
16044
  }
15985
16045
 
15986
16046
  // src/agents/gemini/history.ts
15987
- var fs28 = __toESM(require("fs"));
16047
+ var fs29 = __toESM(require("fs"));
15988
16048
  var os25 = __toESM(require("os"));
15989
- var path32 = __toESM(require("path"));
15990
- var GEMINI_ROOT = path32.join(os25.homedir(), ".gemini");
16049
+ var path33 = __toESM(require("path"));
16050
+ var GEMINI_ROOT = path33.join(os25.homedir(), ".gemini");
15991
16051
  function projectNameForCwd(cwd, root) {
15992
16052
  try {
15993
16053
  const parsed = JSON.parse(
15994
- fs28.readFileSync(path32.join(root, "projects.json"), "utf8")
16054
+ fs29.readFileSync(path33.join(root, "projects.json"), "utf8")
15995
16055
  );
15996
16056
  const map = parsed.projects;
15997
16057
  if (map && typeof map === "object") {
15998
16058
  if (typeof map[cwd] === "string") return map[cwd];
15999
16059
  try {
16000
- const rp = fs28.realpathSync(cwd);
16060
+ const rp = fs29.realpathSync(cwd);
16001
16061
  if (typeof map[rp] === "string") return map[rp];
16002
16062
  } catch {
16003
16063
  }
@@ -16006,7 +16066,7 @@ function projectNameForCwd(cwd, root) {
16006
16066
  } catch (err) {
16007
16067
  log.debug("gemini", `projects.json unreadable at ${root} \u2014 using basename fallback`, err);
16008
16068
  }
16009
- return path32.basename(cwd) || null;
16069
+ return path33.basename(cwd) || null;
16010
16070
  }
16011
16071
  function resolveHistoryDir5(cwd, root = GEMINI_ROOT) {
16012
16072
  const name = projectNameForCwd(cwd, root);
@@ -16014,8 +16074,8 @@ function resolveHistoryDir5(cwd, root = GEMINI_ROOT) {
16014
16074
  log.warn("gemini", `resolveHistoryDir \u2014 could not derive a project name for cwd=${cwd}`);
16015
16075
  return null;
16016
16076
  }
16017
- const dir = path32.join(root, "tmp", name, "chats");
16018
- if (!fs28.existsSync(dir)) {
16077
+ const dir = path33.join(root, "tmp", name, "chats");
16078
+ if (!fs29.existsSync(dir)) {
16019
16079
  log.debug("gemini", `resolveHistoryDir \u2014 chats dir not present yet: ${dir} (project=${name})`);
16020
16080
  return null;
16021
16081
  }
@@ -16027,7 +16087,7 @@ function resolveHistoryFile4(cwd, sessionId, root = GEMINI_ROOT) {
16027
16087
  if (!dir) return null;
16028
16088
  let files;
16029
16089
  try {
16030
- files = fs28.readdirSync(dir).filter((f) => f.startsWith("session-") && f.endsWith(".jsonl"));
16090
+ files = fs29.readdirSync(dir).filter((f) => f.startsWith("session-") && f.endsWith(".jsonl"));
16031
16091
  } catch (err) {
16032
16092
  log.warn("gemini", `resolveHistoryFile \u2014 cannot read chats dir ${dir} (id8=${id8})`, err);
16033
16093
  return null;
@@ -16039,12 +16099,12 @@ function resolveHistoryFile4(cwd, sessionId, root = GEMINI_ROOT) {
16039
16099
  const byName = files.find((f) => id8.length > 0 && f.includes(id8));
16040
16100
  if (byName) {
16041
16101
  log.info("gemini", `resolveHistoryFile \u2014 matched by filename id8=${id8}: ${byName}`);
16042
- return path32.join(dir, byName);
16102
+ return path33.join(dir, byName);
16043
16103
  }
16044
16104
  for (const f of files) {
16045
- const full = path32.join(dir, f);
16105
+ const full = path33.join(dir, f);
16046
16106
  try {
16047
- const firstLine = fs28.readFileSync(full, "utf8").split("\n", 1)[0] ?? "";
16107
+ const firstLine = fs29.readFileSync(full, "utf8").split("\n", 1)[0] ?? "";
16048
16108
  const hdr = JSON.parse(firstLine);
16049
16109
  if (hdr.sessionId === sessionId) {
16050
16110
  log.info("gemini", `resolveHistoryFile \u2014 matched by header sessionId: ${f}`);
@@ -16057,7 +16117,7 @@ function resolveHistoryFile4(cwd, sessionId, root = GEMINI_ROOT) {
16057
16117
  let newest = null;
16058
16118
  for (const f of files) {
16059
16119
  try {
16060
- const mtime = fs28.statSync(path32.join(dir, f)).mtimeMs;
16120
+ const mtime = fs29.statSync(path33.join(dir, f)).mtimeMs;
16061
16121
  if (!newest || mtime > newest.mtime) newest = { file: f, mtime };
16062
16122
  } catch {
16063
16123
  }
@@ -16066,7 +16126,7 @@ function resolveHistoryFile4(cwd, sessionId, root = GEMINI_ROOT) {
16066
16126
  "gemini",
16067
16127
  `resolveHistoryFile \u2014 no id8=${id8} match among ${files.length} file(s) in ${dir}; falling back to newest=${newest?.file ?? "none"}`
16068
16128
  );
16069
- return newest ? path32.join(dir, newest.file) : null;
16129
+ return newest ? path33.join(dir, newest.file) : null;
16070
16130
  }
16071
16131
  function extractGeminiText(content) {
16072
16132
  const fromParts = (arr) => Array.isArray(arr) ? arr.map((p2) => {
@@ -16094,7 +16154,7 @@ function isSyntheticGeminiTurn(text) {
16094
16154
  function parseHistoryFile5(filePath) {
16095
16155
  let raw;
16096
16156
  try {
16097
- raw = fs28.readFileSync(filePath, "utf8");
16157
+ raw = fs29.readFileSync(filePath, "utf8");
16098
16158
  } catch (err) {
16099
16159
  log.warn("gemini", `parseHistoryFile \u2014 cannot read ${filePath}`, err);
16100
16160
  return [];
@@ -16135,7 +16195,7 @@ function parseHistoryFile5(filePath) {
16135
16195
  }
16136
16196
  log.trace(
16137
16197
  "gemini",
16138
- `parseHistoryFile \u2014 ${out2.length} turn(s) from ${path32.basename(filePath)}` + (malformed > 0 ? ` (${malformed} malformed line(s) skipped)` : "")
16198
+ `parseHistoryFile \u2014 ${out2.length} turn(s) from ${path33.basename(filePath)}` + (malformed > 0 ? ` (${malformed} malformed line(s) skipped)` : "")
16139
16199
  );
16140
16200
  return out2;
16141
16201
  }
@@ -16279,42 +16339,42 @@ var import_node_os3 = require("os");
16279
16339
  var import_node_path4 = require("path");
16280
16340
 
16281
16341
  // src/agents/kimi/history.ts
16282
- var fs29 = __toESM(require("fs"));
16342
+ var fs30 = __toESM(require("fs"));
16283
16343
  var os26 = __toESM(require("os"));
16284
- var path33 = __toESM(require("path"));
16344
+ var path34 = __toESM(require("path"));
16285
16345
  var import_node_crypto7 = require("crypto");
16286
16346
  function kimiHome() {
16287
- return process.env.KIMI_CODE_HOME || path33.join(os26.homedir(), ".kimi-code");
16347
+ return process.env.KIMI_CODE_HOME || path34.join(os26.homedir(), ".kimi-code");
16288
16348
  }
16289
16349
  function workDirKey(cwd) {
16290
16350
  const hash = (0, import_node_crypto7.createHash)("sha256").update(cwd).digest("hex").slice(0, 12);
16291
- return `wd_${path33.basename(cwd)}_${hash}`;
16351
+ return `wd_${path34.basename(cwd)}_${hash}`;
16292
16352
  }
16293
16353
  function resolveHistoryDir6(cwd) {
16294
- const dir = path33.join(kimiHome(), "sessions", workDirKey(cwd));
16295
- if (!fs29.existsSync(dir)) {
16354
+ const dir = path34.join(kimiHome(), "sessions", workDirKey(cwd));
16355
+ if (!fs30.existsSync(dir)) {
16296
16356
  log.debug("kimi", `resolveHistoryDir \u2014 session bucket not present yet: ${dir}`);
16297
16357
  return null;
16298
16358
  }
16299
16359
  return dir;
16300
16360
  }
16301
- var WIRE_REL = path33.join("agents", "main", "wire.jsonl");
16361
+ var WIRE_REL = path34.join("agents", "main", "wire.jsonl");
16302
16362
  function resolveHistoryFile5(cwd, sessionId) {
16303
16363
  const fromIndex = sessionDirFromIndex(sessionId);
16304
16364
  if (fromIndex) {
16305
- const p2 = path33.join(fromIndex, WIRE_REL);
16306
- if (fs29.existsSync(p2)) return p2;
16365
+ const p2 = path34.join(fromIndex, WIRE_REL);
16366
+ if (fs30.existsSync(p2)) return p2;
16307
16367
  }
16308
- const bucket = path33.join(kimiHome(), "sessions", workDirKey(cwd));
16309
- const computed = path33.join(bucket, sessionId, WIRE_REL);
16310
- if (fs29.existsSync(computed)) return computed;
16368
+ const bucket = path34.join(kimiHome(), "sessions", workDirKey(cwd));
16369
+ const computed = path34.join(bucket, sessionId, WIRE_REL);
16370
+ if (fs30.existsSync(computed)) return computed;
16311
16371
  const scanned = scanBucketsForSession(sessionId);
16312
16372
  if (scanned) return scanned;
16313
16373
  return null;
16314
16374
  }
16315
16375
  function sessionDirFromIndex(sessionId) {
16316
16376
  try {
16317
- const raw = fs29.readFileSync(path33.join(kimiHome(), "session_index.jsonl"), "utf8");
16377
+ const raw = fs30.readFileSync(path34.join(kimiHome(), "session_index.jsonl"), "utf8");
16318
16378
  for (const line of raw.split("\n")) {
16319
16379
  if (!line.includes(sessionId)) continue;
16320
16380
  try {
@@ -16330,22 +16390,22 @@ function sessionDirFromIndex(sessionId) {
16330
16390
  return null;
16331
16391
  }
16332
16392
  function scanBucketsForSession(sessionId) {
16333
- const sessionsRoot = path33.join(kimiHome(), "sessions");
16393
+ const sessionsRoot = path34.join(kimiHome(), "sessions");
16334
16394
  let buckets;
16335
16395
  try {
16336
- buckets = fs29.readdirSync(sessionsRoot, { withFileTypes: true });
16396
+ buckets = fs30.readdirSync(sessionsRoot, { withFileTypes: true });
16337
16397
  } catch {
16338
16398
  return null;
16339
16399
  }
16340
16400
  for (const b of buckets) {
16341
16401
  if (!b.isDirectory()) continue;
16342
- const candidate = path33.join(sessionsRoot, b.name, sessionId, WIRE_REL);
16343
- if (fs29.existsSync(candidate)) return candidate;
16402
+ const candidate = path34.join(sessionsRoot, b.name, sessionId, WIRE_REL);
16403
+ if (fs30.existsSync(candidate)) return candidate;
16344
16404
  }
16345
16405
  return null;
16346
16406
  }
16347
16407
  async function discoverSessionId2(cwd, opts) {
16348
- const bucket = path33.join(kimiHome(), "sessions", workDirKey(cwd));
16408
+ const bucket = path34.join(kimiHome(), "sessions", workDirKey(cwd));
16349
16409
  const floor = opts.sinceMs - 2e3;
16350
16410
  const deadline = Date.now() + (opts.timeoutMs ?? 15e3);
16351
16411
  for (; ; ) {
@@ -16358,7 +16418,7 @@ async function discoverSessionId2(cwd, opts) {
16358
16418
  function newestSessionSince(bucket, floorMs) {
16359
16419
  let entries;
16360
16420
  try {
16361
- entries = fs29.readdirSync(bucket, { withFileTypes: true });
16421
+ entries = fs30.readdirSync(bucket, { withFileTypes: true });
16362
16422
  } catch {
16363
16423
  return null;
16364
16424
  }
@@ -16368,7 +16428,7 @@ function newestSessionSince(bucket, floorMs) {
16368
16428
  if (!e.isDirectory() || !e.name.startsWith("session_")) continue;
16369
16429
  let mtime;
16370
16430
  try {
16371
- mtime = fs29.statSync(path33.join(bucket, e.name)).mtimeMs;
16431
+ mtime = fs30.statSync(path34.join(bucket, e.name)).mtimeMs;
16372
16432
  } catch {
16373
16433
  continue;
16374
16434
  }
@@ -16389,7 +16449,7 @@ function joinTextParts(parts) {
16389
16449
  function parseHistoryFile6(filePath) {
16390
16450
  let raw;
16391
16451
  try {
16392
- raw = fs29.readFileSync(filePath, "utf8");
16452
+ raw = fs30.readFileSync(filePath, "utf8");
16393
16453
  } catch {
16394
16454
  return [];
16395
16455
  }
@@ -16767,7 +16827,7 @@ function parseLinkArgs(args2) {
16767
16827
  if (apiKeyFileArg) {
16768
16828
  const filePath = apiKeyFileArg.slice("--api-key-file=".length);
16769
16829
  try {
16770
- apiKey = fs30.readFileSync(path34.resolve(filePath), "utf8").trim();
16830
+ apiKey = fs31.readFileSync(path35.resolve(filePath), "utf8").trim();
16771
16831
  } catch (err) {
16772
16832
  throw new Error(`Could not read --api-key-file ${filePath}: ${err.message}`);
16773
16833
  }
@@ -16894,7 +16954,7 @@ async function link(args2 = []) {
16894
16954
  return;
16895
16955
  }
16896
16956
  if (parsed.tokenFile) {
16897
- const credential = fs30.readFileSync(path34.resolve(parsed.tokenFile), "utf8").trim();
16957
+ const credential = fs31.readFileSync(path35.resolve(parsed.tokenFile), "utf8").trim();
16898
16958
  if (!credential) {
16899
16959
  showError(`--token-file ${parsed.tokenFile} is empty.`);
16900
16960
  process.exit(1);
@@ -17114,13 +17174,13 @@ async function linkDryRunPreflight(ctx) {
17114
17174
  var import_node_child_process16 = require("child_process");
17115
17175
  var import_node_os4 = require("os");
17116
17176
  var import_node_fs5 = require("fs");
17117
- var path36 = __toESM(require("path"));
17177
+ var path37 = __toESM(require("path"));
17118
17178
 
17119
17179
  // src/agents/coderabbit/oauth.ts
17120
17180
  var import_node_child_process15 = require("child_process");
17121
- var fs31 = __toESM(require("fs"));
17181
+ var fs32 = __toESM(require("fs"));
17122
17182
  var os27 = __toESM(require("os"));
17123
- var path35 = __toESM(require("path"));
17183
+ var path36 = __toESM(require("path"));
17124
17184
  function parseCoderabbitAuthEvent(line) {
17125
17185
  const l = line.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "").trim();
17126
17186
  if (!l || l[0] !== "{") return null;
@@ -17169,8 +17229,8 @@ function resolvePython() {
17169
17229
  function spawnCoderabbitLoginProc(cmd, args2) {
17170
17230
  const python = resolvePython();
17171
17231
  if (python) {
17172
- const helper = path35.join(os27.tmpdir(), "codeam-cr-pty.py");
17173
- fs31.writeFileSync(helper, PYTHON_PTY_HELPER, { mode: 420 });
17232
+ const helper = path36.join(os27.tmpdir(), "codeam-cr-pty.py");
17233
+ fs32.writeFileSync(helper, PYTHON_PTY_HELPER, { mode: 420 });
17174
17234
  return (0, import_node_child_process15.spawn)(python, [helper, cmd, ...args2], {
17175
17235
  stdio: ["pipe", "pipe", "pipe"],
17176
17236
  env: { ...process.env, TERM: "xterm-256color", COLUMNS: "220", LINES: "50" },
@@ -17281,7 +17341,7 @@ function runCoderabbitOAuthLogin(deps) {
17281
17341
  });
17282
17342
  }
17283
17343
  function coderabbitDir(home) {
17284
- return path35.join(home ?? os27.homedir(), ".coderabbit");
17344
+ return path36.join(home ?? os27.homedir(), ".coderabbit");
17285
17345
  }
17286
17346
  var NON_CREDENTIAL = /* @__PURE__ */ new Set(["doctor.json", "machine-id"]);
17287
17347
  function snapshotCredentialDir(home) {
@@ -17289,14 +17349,14 @@ function snapshotCredentialDir(home) {
17289
17349
  const snap = {};
17290
17350
  let entries;
17291
17351
  try {
17292
- entries = fs31.readdirSync(dir, { withFileTypes: true });
17352
+ entries = fs32.readdirSync(dir, { withFileTypes: true });
17293
17353
  } catch {
17294
17354
  return snap;
17295
17355
  }
17296
17356
  for (const e of entries) {
17297
17357
  if (!e.isFile() || NON_CREDENTIAL.has(e.name)) continue;
17298
17358
  try {
17299
- const st3 = fs31.statSync(path35.join(dir, e.name));
17359
+ const st3 = fs32.statSync(path36.join(dir, e.name));
17300
17360
  snap[e.name] = `${st3.mtimeMs}:${st3.size}`;
17301
17361
  } catch {
17302
17362
  }
@@ -17314,7 +17374,7 @@ function diffCapturedCredential(before, home) {
17314
17374
  }
17315
17375
  if (!best) return null;
17316
17376
  try {
17317
- return { file: best.file, contents: fs31.readFileSync(path35.join(dir, best.file), "utf8") };
17377
+ return { file: best.file, contents: fs32.readFileSync(path36.join(dir, best.file), "utf8") };
17318
17378
  } catch {
17319
17379
  return null;
17320
17380
  }
@@ -17391,7 +17451,7 @@ function collectChangedFiles(cwd) {
17391
17451
  return [...byPath.values()];
17392
17452
  }
17393
17453
  function restoreCoderabbitOauthBlob(value) {
17394
- const dir = path36.join((0, import_node_os4.homedir)(), ".coderabbit");
17454
+ const dir = path37.join((0, import_node_os4.homedir)(), ".coderabbit");
17395
17455
  (0, import_node_fs5.mkdirSync)(dir, { recursive: true });
17396
17456
  let file = "auth.json";
17397
17457
  let contents = value.trim();
@@ -17399,13 +17459,13 @@ function restoreCoderabbitOauthBlob(value) {
17399
17459
  try {
17400
17460
  const parsed = JSON.parse(contents);
17401
17461
  if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
17402
- file = path36.basename(parsed.file);
17462
+ file = path37.basename(parsed.file);
17403
17463
  contents = parsed.contents;
17404
17464
  }
17405
17465
  } catch {
17406
17466
  }
17407
17467
  }
17408
- (0, import_node_fs5.writeFileSync)(path36.join(dir, file), contents, { mode: 384 });
17468
+ (0, import_node_fs5.writeFileSync)(path37.join(dir, file), contents, { mode: 384 });
17409
17469
  }
17410
17470
  async function configureCoderabbit(input, deps = {}) {
17411
17471
  const os60 = deps.os ?? createOsStrategy();
@@ -17418,10 +17478,10 @@ async function configureCoderabbit(input, deps = {}) {
17418
17478
  const home = os60.homeDir();
17419
17479
  os60.augmentPath(
17420
17480
  os60.id === "win32" ? [
17421
- path36.join(home, ".local", "bin"),
17422
- path36.join(process.env.APPDATA ?? path36.join(home, "AppData", "Roaming"), "npm"),
17423
- path36.join(home, "scoop", "shims")
17424
- ] : [path36.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"]
17481
+ path37.join(home, ".local", "bin"),
17482
+ path37.join(process.env.APPDATA ?? path37.join(home, "AppData", "Roaming"), "npm"),
17483
+ path37.join(home, "scoop", "shims")
17484
+ ] : [path37.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"]
17425
17485
  );
17426
17486
  const installed2 = os60.findInPath("coderabbit") !== null;
17427
17487
  const base = () => ({
@@ -17720,8 +17780,8 @@ function defaultRunGh(args2) {
17720
17780
  // src/commands/host-agent.ts
17721
17781
  var import_node_child_process25 = require("child_process");
17722
17782
  var os38 = __toESM(require("os"));
17723
- var fs43 = __toESM(require("fs"));
17724
- var path46 = __toESM(require("path"));
17783
+ var fs44 = __toESM(require("fs"));
17784
+ var path47 = __toESM(require("path"));
17725
17785
 
17726
17786
  // src/integrations/manifest.ts
17727
17787
  var import_node_fs7 = __toESM(require("fs"));
@@ -17867,9 +17927,9 @@ function describeReason(reason) {
17867
17927
  }
17868
17928
 
17869
17929
  // src/commands/host/host-client.ts
17870
- var fs35 = __toESM(require("fs"));
17930
+ var fs36 = __toESM(require("fs"));
17871
17931
  var os31 = __toESM(require("os"));
17872
- var path39 = __toESM(require("path"));
17932
+ var path40 = __toESM(require("path"));
17873
17933
  var import_node_crypto9 = require("crypto");
17874
17934
  function sampleCpuTimes() {
17875
17935
  let idle = 0;
@@ -17917,7 +17977,7 @@ function apiBase() {
17917
17977
  return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
17918
17978
  }
17919
17979
  function hostIdentityPath() {
17920
- return path39.join(os31.homedir(), ".codeam", "host-agent.json");
17980
+ return path40.join(os31.homedir(), ".codeam", "host-agent.json");
17921
17981
  }
17922
17982
  function collectOsInfo() {
17923
17983
  return {
@@ -17929,7 +17989,7 @@ function collectOsInfo() {
17929
17989
  }
17930
17990
  function loadHostIdentity() {
17931
17991
  try {
17932
- const raw = fs35.readFileSync(hostIdentityPath(), "utf8");
17992
+ const raw = fs36.readFileSync(hostIdentityPath(), "utf8");
17933
17993
  const parsed = JSON.parse(raw);
17934
17994
  if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
17935
17995
  const p2 = parsed;
@@ -17948,8 +18008,8 @@ function loadHostIdentity() {
17948
18008
  }
17949
18009
  function saveHostIdentity(identity) {
17950
18010
  const file = hostIdentityPath();
17951
- fs35.mkdirSync(path39.dirname(file), { recursive: true, mode: 448 });
17952
- fs35.writeFileSync(file, JSON.stringify(identity, null, 2), {
18011
+ fs36.mkdirSync(path40.dirname(file), { recursive: true, mode: 448 });
18012
+ fs36.writeFileSync(file, JSON.stringify(identity, null, 2), {
17953
18013
  encoding: "utf8",
17954
18014
  mode: 384
17955
18015
  });
@@ -17994,7 +18054,7 @@ function isTerminalEnrollError(err) {
17994
18054
  }
17995
18055
  function deleteHostIdentity() {
17996
18056
  try {
17997
- fs35.rmSync(hostIdentityPath(), { force: true });
18057
+ fs36.rmSync(hostIdentityPath(), { force: true });
17998
18058
  } catch {
17999
18059
  }
18000
18060
  }
@@ -18129,17 +18189,17 @@ async function reportDeployProgress(auth, deployId, step, message, sessionId) {
18129
18189
  }
18130
18190
 
18131
18191
  // src/commands/host/workspace.ts
18132
- var fs36 = __toESM(require("fs"));
18192
+ var fs37 = __toESM(require("fs"));
18133
18193
  var os32 = __toESM(require("os"));
18134
- var path40 = __toESM(require("path"));
18194
+ var path41 = __toESM(require("path"));
18135
18195
  var import_node_child_process19 = require("child_process");
18136
18196
  var import_node_util4 = require("util");
18137
18197
  var execFileP4 = (0, import_node_util4.promisify)(import_node_child_process19.execFile);
18138
18198
  function isAbsolutePathTarget(target) {
18139
- return path40.isAbsolute(target);
18199
+ return path41.isAbsolute(target);
18140
18200
  }
18141
18201
  function selfHostedWorkspaceRoot() {
18142
- return path40.join(os32.homedir(), ".codeam", "self-hosted");
18202
+ return path41.join(os32.homedir(), ".codeam", "self-hosted");
18143
18203
  }
18144
18204
  function nonInteractiveGitEnv() {
18145
18205
  return {
@@ -18209,15 +18269,15 @@ async function configureGitCredentials(dest, repoRef, cloneToken, provider = "gi
18209
18269
  const isGitlab = provider === "gitlab";
18210
18270
  if (isGitlab ? !gitlabProjectPath(repoRef.trim()) : !githubOwnerRepo(repoRef.trim())) return;
18211
18271
  if (!cloneToken) return;
18212
- const credFile = path40.join(dest, ".git", "codeam-credentials");
18272
+ const credFile = path41.join(dest, ".git", "codeam-credentials");
18213
18273
  const credLine = isGitlab ? `https://oauth2:${cloneToken}@gitlab.com
18214
18274
  ` : `https://x-access-token:${cloneToken}@github.com
18215
18275
  `;
18216
- fs36.writeFileSync(credFile, credLine, { mode: 384 });
18276
+ fs37.writeFileSync(credFile, credLine, { mode: 384 });
18217
18277
  restrictToOwner(credFile);
18218
18278
  const env = nonInteractiveGitEnv();
18219
18279
  const git2 = (args2) => execFileP4("git", ["-C", dest, ...args2], { timeout: 3e4, env });
18220
- const credFilePosix = credFile.split(path40.sep).join("/");
18280
+ const credFilePosix = credFile.split(path41.sep).join("/");
18221
18281
  await git2(["config", "--local", "--replace-all", "credential.helper", ""]).catch(() => {
18222
18282
  });
18223
18283
  await git2([
@@ -18250,17 +18310,17 @@ function maskToken(text, cloneToken) {
18250
18310
  }
18251
18311
  async function prepareWorkspace(repoOrPath, deployId, cloneToken, provider = "github", branch) {
18252
18312
  if (isAbsolutePathTarget(repoOrPath)) {
18253
- if (!fs36.existsSync(repoOrPath)) {
18313
+ if (!fs37.existsSync(repoOrPath)) {
18254
18314
  throw new Error(`deploy target path does not exist: ${repoOrPath}`);
18255
18315
  }
18256
18316
  return repoOrPath;
18257
18317
  }
18258
- const dest = path40.join(selfHostedWorkspaceRoot(), deployId);
18259
- if (fs36.existsSync(path40.join(dest, ".git"))) {
18318
+ const dest = path41.join(selfHostedWorkspaceRoot(), deployId);
18319
+ if (fs37.existsSync(path41.join(dest, ".git"))) {
18260
18320
  if (cloneToken) await configureGitCredentials(dest, repoOrPath, cloneToken, provider);
18261
18321
  return dest;
18262
18322
  }
18263
- fs36.mkdirSync(selfHostedWorkspaceRoot(), { recursive: true, mode: 448 });
18323
+ fs37.mkdirSync(selfHostedWorkspaceRoot(), { recursive: true, mode: 448 });
18264
18324
  const cloneUrl = repoCloneUrl(repoOrPath, cloneToken, provider);
18265
18325
  const cloneArgs = branch ? ["clone", "--depth", "1", "--branch", branch, cloneUrl, dest] : ["clone", "--depth", "1", cloneUrl, dest];
18266
18326
  try {
@@ -18278,9 +18338,9 @@ async function prepareWorkspace(repoOrPath, deployId, cloneToken, provider = "gi
18278
18338
  }
18279
18339
 
18280
18340
  // src/commands/host/agent-provisioning.ts
18281
- var fs37 = __toESM(require("fs"));
18341
+ var fs38 = __toESM(require("fs"));
18282
18342
  var os33 = __toESM(require("os"));
18283
- var path41 = __toESM(require("path"));
18343
+ var path42 = __toESM(require("path"));
18284
18344
  var PUBLIC_TO_INTERNAL_AGENT = {
18285
18345
  claude_code: "claude",
18286
18346
  claude: "claude",
@@ -18297,22 +18357,22 @@ function toInternalAgentId(publicAgentId) {
18297
18357
  return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
18298
18358
  }
18299
18359
  function ensureDir(dir) {
18300
- fs37.mkdirSync(dir, { recursive: true, mode: 448 });
18360
+ fs38.mkdirSync(dir, { recursive: true, mode: 448 });
18301
18361
  }
18302
18362
  function writeFile0600(filePath, contents) {
18303
- ensureDir(path41.dirname(filePath));
18304
- fs37.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
18363
+ ensureDir(path42.dirname(filePath));
18364
+ fs38.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
18305
18365
  restrictToOwner(filePath);
18306
18366
  }
18307
18367
  function rmIfExists(filePath) {
18308
18368
  try {
18309
- fs37.rmSync(filePath, { force: true });
18369
+ fs38.rmSync(filePath, { force: true });
18310
18370
  } catch {
18311
18371
  }
18312
18372
  }
18313
18373
  var claudeProvisioner = {
18314
18374
  write(auth, home) {
18315
- const credentialsJson = path41.join(home, ".claude", ".credentials.json");
18375
+ const credentialsJson = path42.join(home, ".claude", ".credentials.json");
18316
18376
  if (auth.kind === "api_key") {
18317
18377
  rmIfExists(credentialsJson);
18318
18378
  return { ANTHROPIC_API_KEY: auth.value };
@@ -18324,8 +18384,8 @@ var claudeProvisioner = {
18324
18384
  } else {
18325
18385
  rmIfExists(credentialsJson);
18326
18386
  }
18327
- const claudeJson = path41.join(home, ".claude.json");
18328
- if (!fs37.existsSync(claudeJson)) {
18387
+ const claudeJson = path42.join(home, ".claude.json");
18388
+ if (!fs38.existsSync(claudeJson)) {
18329
18389
  writeFile0600(
18330
18390
  claudeJson,
18331
18391
  JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
@@ -18336,7 +18396,7 @@ var claudeProvisioner = {
18336
18396
  };
18337
18397
  var codexProvisioner = {
18338
18398
  write(auth, home) {
18339
- const authJson = path41.join(home, ".codex", "auth.json");
18399
+ const authJson = path42.join(home, ".codex", "auth.json");
18340
18400
  if (auth.kind === "api_key") {
18341
18401
  rmIfExists(authJson);
18342
18402
  return { OPENAI_API_KEY: auth.value };
@@ -18347,8 +18407,8 @@ var codexProvisioner = {
18347
18407
  };
18348
18408
  var geminiProvisioner = {
18349
18409
  write(auth, home) {
18350
- const settingsJson = path41.join(home, ".gemini", "settings.json");
18351
- const oauthCreds = path41.join(home, ".gemini", "oauth_creds.json");
18410
+ const settingsJson = path42.join(home, ".gemini", "settings.json");
18411
+ const oauthCreds = path42.join(home, ".gemini", "oauth_creds.json");
18352
18412
  if (auth.kind === "api_key") {
18353
18413
  rmIfExists(oauthCreds);
18354
18414
  writeFile0600(settingsJson, '{"security":{"auth":{"selectedType":"gemini-api-key"}}}');
@@ -18361,7 +18421,7 @@ var geminiProvisioner = {
18361
18421
  };
18362
18422
  var cursorProvisioner = {
18363
18423
  write(auth, home) {
18364
- const authJson = path41.join(home, ".config", "cursor", "auth.json");
18424
+ const authJson = path42.join(home, ".config", "cursor", "auth.json");
18365
18425
  if (auth.kind === "api_key") {
18366
18426
  rmIfExists(authJson);
18367
18427
  return { CURSOR_API_KEY: auth.value };
@@ -18403,22 +18463,22 @@ max_context_size = 262144
18403
18463
  var kimiProvisioner = {
18404
18464
  write(auth, home) {
18405
18465
  const credentialsFiles = [
18406
- path41.join(home, ".kimi", "credentials", "kimi-code.json"),
18407
- path41.join(home, ".kimi-code", "credentials", "kimi-code.json")
18466
+ path42.join(home, ".kimi", "credentials", "kimi-code.json"),
18467
+ path42.join(home, ".kimi-code", "credentials", "kimi-code.json")
18408
18468
  ];
18409
18469
  if (auth.kind === "api_key") {
18410
18470
  credentialsFiles.forEach(rmIfExists);
18411
18471
  return { KIMI_API_KEY: auth.value };
18412
18472
  }
18413
18473
  credentialsFiles.forEach((f) => writeFile0600(f, auth.value));
18414
- writeFile0600(path41.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
18474
+ writeFile0600(path42.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
18415
18475
  return {};
18416
18476
  }
18417
18477
  };
18418
18478
  var coderabbitProvisioner = {
18419
18479
  write(auth, home) {
18420
- const dir = path41.join(home, ".coderabbit");
18421
- const authJson = path41.join(dir, "auth.json");
18480
+ const dir = path42.join(home, ".coderabbit");
18481
+ const authJson = path42.join(dir, "auth.json");
18422
18482
  if (auth.kind === "api_key") {
18423
18483
  rmIfExists(authJson);
18424
18484
  return { CODERABBIT_API_KEY: auth.value };
@@ -18430,13 +18490,13 @@ var coderabbitProvisioner = {
18430
18490
  try {
18431
18491
  const parsed = JSON.parse(value);
18432
18492
  if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
18433
- file = path41.basename(parsed.file);
18493
+ file = path42.basename(parsed.file);
18434
18494
  contents = parsed.contents;
18435
18495
  }
18436
18496
  } catch {
18437
18497
  }
18438
18498
  }
18439
- writeFile0600(path41.join(dir, file), contents);
18499
+ writeFile0600(path42.join(dir, file), contents);
18440
18500
  return {};
18441
18501
  }
18442
18502
  };
@@ -18474,11 +18534,11 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os33.homedir(
18474
18534
 
18475
18535
  // src/commands/host/git-tooling.ts
18476
18536
  var import_node_child_process20 = require("child_process");
18477
- var fs38 = __toESM(require("fs"));
18537
+ var fs39 = __toESM(require("fs"));
18478
18538
  var os34 = __toESM(require("os"));
18479
- var path42 = __toESM(require("path"));
18539
+ var path43 = __toESM(require("path"));
18480
18540
  function codeamBinDir() {
18481
- return process.env.CODEAM_BIN_DIR ?? path42.join(os34.homedir(), ".codeam", "bin");
18541
+ return process.env.CODEAM_BIN_DIR ?? path43.join(os34.homedir(), ".codeam", "bin");
18482
18542
  }
18483
18543
  var FALLBACK_GH_VERSION = "2.62.0";
18484
18544
  var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
@@ -18510,7 +18570,7 @@ async function download(url2, dest) {
18510
18570
  const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
18511
18571
  if (!res.ok || !res.body) return false;
18512
18572
  const buf = Buffer.from(await res.arrayBuffer());
18513
- fs38.writeFileSync(dest, buf);
18573
+ fs39.writeFileSync(dest, buf);
18514
18574
  return true;
18515
18575
  } catch {
18516
18576
  return false;
@@ -18533,8 +18593,8 @@ async function ensureGhCli(runner, token, deps = {}) {
18533
18593
  const version3 = await resolveVersionFn(token);
18534
18594
  const asset = `gh_${version3}_${osToken}_${arch2}`;
18535
18595
  const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
18536
- const tmpRoot = fs38.mkdtempSync(path42.join(os34.tmpdir(), "codeam-gh-"));
18537
- const archive = path42.join(tmpRoot, `${asset}.${ext}`);
18596
+ const tmpRoot = fs39.mkdtempSync(path43.join(os34.tmpdir(), "codeam-gh-"));
18597
+ const archive = path43.join(tmpRoot, `${asset}.${ext}`);
18538
18598
  if (!await downloadFn(url2, archive)) {
18539
18599
  log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
18540
18600
  return null;
@@ -18544,16 +18604,16 @@ async function ensureGhCli(runner, token, deps = {}) {
18544
18604
  log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
18545
18605
  return null;
18546
18606
  }
18547
- const extractedBin = path42.join(tmpRoot, asset, "bin", binaryName);
18548
- if (!fs38.existsSync(extractedBin)) {
18607
+ const extractedBin = path43.join(tmpRoot, asset, "bin", binaryName);
18608
+ if (!fs39.existsSync(extractedBin)) {
18549
18609
  log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
18550
18610
  return null;
18551
18611
  }
18552
18612
  const binDir = codeamBinDir();
18553
- fs38.mkdirSync(binDir, { recursive: true });
18554
- const target = path42.join(binDir, binaryName);
18555
- fs38.copyFileSync(extractedBin, target);
18556
- fs38.chmodSync(target, 493);
18613
+ fs39.mkdirSync(binDir, { recursive: true });
18614
+ const target = path43.join(binDir, binaryName);
18615
+ fs39.copyFileSync(extractedBin, target);
18616
+ fs39.chmodSync(target, 493);
18557
18617
  log.info("host-agent", `gh installed to ${target} (v${version3})`);
18558
18618
  return target;
18559
18619
  } catch (e) {
@@ -18613,8 +18673,8 @@ async function ensureGlabCli(runner, deps = {}) {
18613
18673
  const version3 = await resolveLatestGlabVersion();
18614
18674
  const asset = `glab_${version3}_${osToken}_${arch2}`;
18615
18675
  const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
18616
- const tmpRoot = fs38.mkdtempSync(path42.join(os34.tmpdir(), "codeam-glab-"));
18617
- const archive = path42.join(tmpRoot, `${asset}.${ext}`);
18676
+ const tmpRoot = fs39.mkdtempSync(path43.join(os34.tmpdir(), "codeam-glab-"));
18677
+ const archive = path43.join(tmpRoot, `${asset}.${ext}`);
18618
18678
  if (!await downloadFn(url2, archive)) {
18619
18679
  log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
18620
18680
  return null;
@@ -18625,20 +18685,20 @@ async function ensureGlabCli(runner, deps = {}) {
18625
18685
  return null;
18626
18686
  }
18627
18687
  const candidates = [
18628
- path42.join(tmpRoot, "bin", binaryName),
18629
- path42.join(tmpRoot, asset, "bin", binaryName),
18630
- path42.join(tmpRoot, binaryName)
18688
+ path43.join(tmpRoot, "bin", binaryName),
18689
+ path43.join(tmpRoot, asset, "bin", binaryName),
18690
+ path43.join(tmpRoot, binaryName)
18631
18691
  ];
18632
- const extractedBin = candidates.find((c2) => fs38.existsSync(c2));
18692
+ const extractedBin = candidates.find((c2) => fs39.existsSync(c2));
18633
18693
  if (!extractedBin) {
18634
18694
  log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
18635
18695
  return null;
18636
18696
  }
18637
18697
  const binDir = codeamBinDir();
18638
- fs38.mkdirSync(binDir, { recursive: true });
18639
- const target = path42.join(binDir, binaryName);
18640
- fs38.copyFileSync(extractedBin, target);
18641
- fs38.chmodSync(target, 493);
18698
+ fs39.mkdirSync(binDir, { recursive: true });
18699
+ const target = path43.join(binDir, binaryName);
18700
+ fs39.copyFileSync(extractedBin, target);
18701
+ fs39.chmodSync(target, 493);
18642
18702
  log.info("host-agent", `glab installed to ${target} (v${version3})`);
18643
18703
  return target;
18644
18704
  } catch (e) {
@@ -19126,24 +19186,24 @@ async function ensureModernPython(runner) {
19126
19186
  }
19127
19187
 
19128
19188
  // src/commands/host/headroom-bootstrap.ts
19129
- var fs40 = __toESM(require("fs"));
19130
- var path44 = __toESM(require("path"));
19189
+ var fs41 = __toESM(require("fs"));
19190
+ var path45 = __toESM(require("path"));
19131
19191
  var os36 = __toESM(require("os"));
19132
19192
 
19133
19193
  // src/commands/host/headroom-config.ts
19134
- var fs39 = __toESM(require("fs"));
19194
+ var fs40 = __toESM(require("fs"));
19135
19195
  var os35 = __toESM(require("os"));
19136
- var path43 = __toESM(require("path"));
19196
+ var path44 = __toESM(require("path"));
19137
19197
  function headroomConfigPath() {
19138
- return path43.join(os35.homedir(), ".codeam", "headroom-config.json");
19198
+ return path44.join(os35.homedir(), ".codeam", "headroom-config.json");
19139
19199
  }
19140
19200
  function persistHeadroomConfig(config) {
19141
19201
  try {
19142
19202
  const file = headroomConfigPath();
19143
- fs39.mkdirSync(path43.dirname(file), { recursive: true, mode: 448 });
19203
+ fs40.mkdirSync(path44.dirname(file), { recursive: true, mode: 448 });
19144
19204
  const tmp = `${file}.tmp-${process.pid}`;
19145
- fs39.writeFileSync(tmp, JSON.stringify(config, null, 2), { encoding: "utf8", mode: 384 });
19146
- fs39.renameSync(tmp, file);
19205
+ fs40.writeFileSync(tmp, JSON.stringify(config, null, 2), { encoding: "utf8", mode: 384 });
19206
+ fs40.renameSync(tmp, file);
19147
19207
  restrictToOwner(file);
19148
19208
  } catch (err) {
19149
19209
  log.warn(
@@ -19154,20 +19214,20 @@ function persistHeadroomConfig(config) {
19154
19214
  }
19155
19215
  function agentSettingsPath(kind) {
19156
19216
  const home = os35.homedir();
19157
- if (kind === "claude") return path43.join(home, ".claude", "settings.json");
19158
- if (kind === "codex") return path43.join(home, ".codex", "auth.json");
19159
- if (kind === "copilot") return path43.join(home, ".config", "github-copilot", "hosts.json");
19217
+ if (kind === "claude") return path44.join(home, ".claude", "settings.json");
19218
+ if (kind === "codex") return path44.join(home, ".codex", "auth.json");
19219
+ if (kind === "copilot") return path44.join(home, ".config", "github-copilot", "hosts.json");
19160
19220
  return null;
19161
19221
  }
19162
19222
  function backupAgentHeadroomConfig(kind) {
19163
19223
  const src = agentSettingsPath(kind);
19164
19224
  if (!src) return;
19165
19225
  try {
19166
- if (!fs39.existsSync(src)) return;
19167
- const dest = path43.join(os35.homedir(), ".codeam", `headroom-backup-${kind}.json`);
19168
- fs39.mkdirSync(path43.dirname(dest), { recursive: true, mode: 448 });
19169
- fs39.copyFileSync(src, dest);
19170
- fs39.chmodSync(dest, 384);
19226
+ if (!fs40.existsSync(src)) return;
19227
+ const dest = path44.join(os35.homedir(), ".codeam", `headroom-backup-${kind}.json`);
19228
+ fs40.mkdirSync(path44.dirname(dest), { recursive: true, mode: 448 });
19229
+ fs40.copyFileSync(src, dest);
19230
+ fs40.chmodSync(dest, 384);
19171
19231
  log.info("host-agent", `headroom config backup: ${src} \u2192 ${dest}`);
19172
19232
  } catch (err) {
19173
19233
  log.warn(
@@ -19179,12 +19239,12 @@ function backupAgentHeadroomConfig(kind) {
19179
19239
  function restoreAgentHeadroomConfig(kind) {
19180
19240
  const dest = agentSettingsPath(kind);
19181
19241
  if (!dest) return false;
19182
- const src = path43.join(os35.homedir(), ".codeam", `headroom-backup-${kind}.json`);
19183
- if (!fs39.existsSync(src)) return false;
19242
+ const src = path44.join(os35.homedir(), ".codeam", `headroom-backup-${kind}.json`);
19243
+ if (!fs40.existsSync(src)) return false;
19184
19244
  try {
19185
- fs39.mkdirSync(path43.dirname(dest), { recursive: true, mode: 448 });
19186
- fs39.copyFileSync(src, dest);
19187
- fs39.chmodSync(dest, 384);
19245
+ fs40.mkdirSync(path44.dirname(dest), { recursive: true, mode: 448 });
19246
+ fs40.copyFileSync(src, dest);
19247
+ fs40.chmodSync(dest, 384);
19188
19248
  log.info("host-agent", `headroom config restored: ${src} \u2192 ${dest}`);
19189
19249
  return true;
19190
19250
  } catch (err) {
@@ -19197,7 +19257,7 @@ function restoreAgentHeadroomConfig(kind) {
19197
19257
  }
19198
19258
  function readHeadroomChildEnv() {
19199
19259
  try {
19200
- const raw = fs39.readFileSync(headroomConfigPath(), "utf8");
19260
+ const raw = fs40.readFileSync(headroomConfigPath(), "utf8");
19201
19261
  const parsed = JSON.parse(raw);
19202
19262
  if (typeof parsed !== "object" || parsed === null) return {};
19203
19263
  const o = parsed;
@@ -19233,49 +19293,49 @@ function bundledClaudeBinDir() {
19233
19293
  const roots = /* @__PURE__ */ new Set();
19234
19294
  let dir = __dirname;
19235
19295
  for (let i = 0; i < 6; i++) {
19236
- roots.add(path44.join(dir, "node_modules"));
19237
- const parent = path44.dirname(dir);
19296
+ roots.add(path45.join(dir, "node_modules"));
19297
+ const parent = path45.dirname(dir);
19238
19298
  if (parent === dir) break;
19239
19299
  dir = parent;
19240
19300
  }
19241
19301
  try {
19242
19302
  const main2 = require.resolve("@anthropic-ai/claude-agent-sdk");
19243
- const marker = `${path44.sep}@anthropic-ai${path44.sep}`;
19303
+ const marker = `${path45.sep}@anthropic-ai${path45.sep}`;
19244
19304
  const idx = main2.lastIndexOf(marker);
19245
19305
  if (idx !== -1) roots.add(main2.slice(0, idx));
19246
19306
  } catch {
19247
19307
  }
19248
19308
  for (const nm of roots) {
19249
- const atAnthropic = path44.join(nm, "@anthropic-ai");
19309
+ const atAnthropic = path45.join(nm, "@anthropic-ai");
19250
19310
  let entries;
19251
19311
  try {
19252
- entries = fs40.readdirSync(atAnthropic);
19312
+ entries = fs41.readdirSync(atAnthropic);
19253
19313
  } catch {
19254
19314
  continue;
19255
19315
  }
19256
19316
  for (const entry of entries) {
19257
19317
  if (!entry.startsWith("claude-agent-sdk-")) continue;
19258
- const bin = path44.join(atAnthropic, entry, "claude");
19259
- if (fs40.existsSync(bin)) return path44.dirname(bin);
19318
+ const bin = path45.join(atAnthropic, entry, "claude");
19319
+ if (fs41.existsSync(bin)) return path45.dirname(bin);
19260
19320
  }
19261
19321
  }
19262
19322
  return null;
19263
19323
  }
19264
19324
  async function getFreeDiskBytes(dir) {
19265
19325
  try {
19266
- const s = await fs40.promises.statfs(dir);
19326
+ const s = await fs41.promises.statfs(dir);
19267
19327
  return s.bsize * s.bavail;
19268
19328
  } catch {
19269
19329
  return null;
19270
19330
  }
19271
19331
  }
19272
19332
  function headroomModelsCached() {
19273
- const hubDir = process.env.HUGGINGFACE_HUB_CACHE || path44.join(
19274
- process.env.HF_HOME || path44.join(os36.homedir(), ".cache", "huggingface"),
19333
+ const hubDir = process.env.HUGGINGFACE_HUB_CACHE || path45.join(
19334
+ process.env.HF_HOME || path45.join(os36.homedir(), ".cache", "huggingface"),
19275
19335
  "hub"
19276
19336
  );
19277
19337
  return HEADROOM_MODELS.every(
19278
- (m) => fs40.existsSync(path44.join(hubDir, `models--${m.repo.replace("/", "--")}`))
19338
+ (m) => fs41.existsSync(path45.join(hubDir, `models--${m.repo.replace("/", "--")}`))
19279
19339
  );
19280
19340
  }
19281
19341
  async function setupHeadroomForSelfHosted(agent, runner = defaultHeadroomRunner, opts = {}) {
@@ -19344,7 +19404,7 @@ async function setupHeadroomForSelfHosted(agent, runner = defaultHeadroomRunner,
19344
19404
  if (initKind === "claude") {
19345
19405
  const claudeDir = bundledClaudeBinDir();
19346
19406
  if (claudeDir) {
19347
- initEnv.PATH = `${claudeDir}${path44.delimiter}${process.env["PATH"] ?? ""}`;
19407
+ initEnv.PATH = `${claudeDir}${path45.delimiter}${process.env["PATH"] ?? ""}`;
19348
19408
  log.info("host-agent", `headroom init: bundled claude on PATH (${claudeDir})`);
19349
19409
  } else {
19350
19410
  log.warn("host-agent", "headroom init: bundled claude binary not found \u2014 init may fail");
@@ -19366,11 +19426,16 @@ async function setupHeadroomForSelfHosted(agent, runner = defaultHeadroomRunner,
19366
19426
  return false;
19367
19427
  }
19368
19428
  onProgress("proxy");
19369
- spawnHeadroomProxy({
19370
- tag: "host-agent",
19371
- spawnErrorMsg: (detail) => `headroom proxy warm-start error (best-effort): ${detail}`,
19372
- failureMsg: (detail) => `headroom proxy warm-start failed (best-effort): ${detail}`
19373
- });
19429
+ spawnHeadroomProxy(
19430
+ {
19431
+ tag: "host-agent",
19432
+ spawnErrorMsg: (detail) => `headroom proxy warm-start error (best-effort): ${detail}`,
19433
+ failureMsg: (detail) => `headroom proxy warm-start failed (best-effort): ${detail}`
19434
+ },
19435
+ // First deliberate warm-start of the deploy — take priority over any
19436
+ // supervisor tick racing it.
19437
+ { force: true }
19438
+ );
19374
19439
  onProgress("ready");
19375
19440
  return true;
19376
19441
  }
@@ -19379,9 +19444,9 @@ async function setupHeadroomForSelfHosted(agent, runner = defaultHeadroomRunner,
19379
19444
  var import_node_child_process23 = require("child_process");
19380
19445
 
19381
19446
  // src/lib/updateNotifier.ts
19382
- var fs41 = __toESM(require("fs"));
19447
+ var fs42 = __toESM(require("fs"));
19383
19448
  var os37 = __toESM(require("os"));
19384
- var path45 = __toESM(require("path"));
19449
+ var path46 = __toESM(require("path"));
19385
19450
  var https6 = __toESM(require("https"));
19386
19451
  var import_node_child_process22 = require("child_process");
19387
19452
  var import_picocolors3 = __toESM(require("picocolors"));
@@ -19390,12 +19455,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
19390
19455
  var TTL_MS = 24 * 60 * 60 * 1e3;
19391
19456
  var REQUEST_TIMEOUT_MS = 1500;
19392
19457
  function cachePath() {
19393
- const dir = path45.join(os37.homedir(), ".codeam");
19394
- return path45.join(dir, "update-check.json");
19458
+ const dir = path46.join(os37.homedir(), ".codeam");
19459
+ return path46.join(dir, "update-check.json");
19395
19460
  }
19396
19461
  function readCache() {
19397
19462
  try {
19398
- const raw = fs41.readFileSync(cachePath(), "utf8");
19463
+ const raw = fs42.readFileSync(cachePath(), "utf8");
19399
19464
  const parsed = JSON.parse(raw);
19400
19465
  if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
19401
19466
  return parsed;
@@ -19406,10 +19471,10 @@ function readCache() {
19406
19471
  function writeCache(cache) {
19407
19472
  try {
19408
19473
  const file = cachePath();
19409
- fs41.mkdirSync(path45.dirname(file), { recursive: true });
19474
+ fs42.mkdirSync(path46.dirname(file), { recursive: true });
19410
19475
  const tmp = `${file}.${process.pid}.tmp`;
19411
- fs41.writeFileSync(tmp, JSON.stringify(cache));
19412
- fs41.renameSync(tmp, file);
19476
+ fs42.writeFileSync(tmp, JSON.stringify(cache));
19477
+ fs42.renameSync(tmp, file);
19413
19478
  } catch {
19414
19479
  }
19415
19480
  }
@@ -19483,8 +19548,8 @@ function isLinkedInstall() {
19483
19548
  timeout: 2e3
19484
19549
  }).trim();
19485
19550
  if (!root) return false;
19486
- const pkgPath = path45.join(root, PKG_NAME);
19487
- return fs41.lstatSync(pkgPath).isSymbolicLink();
19551
+ const pkgPath = path46.join(root, PKG_NAME);
19552
+ return fs42.lstatSync(pkgPath).isSymbolicLink();
19488
19553
  } catch {
19489
19554
  return false;
19490
19555
  }
@@ -19520,7 +19585,7 @@ function maybeAutoUpdate(currentVersion, latest) {
19520
19585
  return;
19521
19586
  }
19522
19587
  try {
19523
- fs41.unlinkSync(cachePath());
19588
+ fs42.unlinkSync(cachePath());
19524
19589
  } catch {
19525
19590
  }
19526
19591
  process.stderr.write(` ${import_picocolors3.default.green("\u2713")} Updated. Resuming session...
@@ -19536,7 +19601,7 @@ async function autoUpgradeBeforeCriticalCommand() {
19536
19601
  if (process.env.NODE_ENV === "test") return;
19537
19602
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
19538
19603
  if (process.env.CI) return;
19539
- const current = true ? "2.61.71" : null;
19604
+ const current = true ? "2.61.72" : null;
19540
19605
  if (!current) return;
19541
19606
  const cache = readCache();
19542
19607
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -19553,7 +19618,7 @@ function checkForUpdates() {
19553
19618
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
19554
19619
  if (process.env.CI) return;
19555
19620
  if (!process.stdout.isTTY) return;
19556
- const current = true ? "2.61.71" : null;
19621
+ const current = true ? "2.61.72" : null;
19557
19622
  if (!current) return;
19558
19623
  const cache = readCache();
19559
19624
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -19573,7 +19638,7 @@ var SELF_UPDATE_INTERVAL_MS = 60 * 60 * 1e3;
19573
19638
  var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
19574
19639
  var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
19575
19640
  function currentCliVersion() {
19576
- return true ? "2.61.71" : null;
19641
+ return true ? "2.61.72" : null;
19577
19642
  }
19578
19643
  function runCmd(cmd, args2, timeoutMs) {
19579
19644
  return new Promise((resolve9) => {
@@ -19640,7 +19705,7 @@ async function runSelfUpdate() {
19640
19705
 
19641
19706
  // src/commands/host/teardown.ts
19642
19707
  var import_node_child_process24 = require("child_process");
19643
- var fs42 = __toESM(require("fs"));
19708
+ var fs43 = __toESM(require("fs"));
19644
19709
  var defaultDisableService = () => {
19645
19710
  try {
19646
19711
  (0, import_node_child_process24.execFileSync)("systemctl", ["disable", "--now", "codeam-host-agent"], { stdio: "ignore" });
@@ -19649,7 +19714,7 @@ var defaultDisableService = () => {
19649
19714
  };
19650
19715
  var defaultTeardownHeadroom = () => {
19651
19716
  try {
19652
- const kind = JSON.parse(fs42.readFileSync(headroomConfigPath(), "utf8")).agent;
19717
+ const kind = JSON.parse(fs43.readFileSync(headroomConfigPath(), "utf8")).agent;
19653
19718
  if (kind) {
19654
19719
  (0, import_node_child_process24.execFileSync)("headroom", ["unwrap", kind], { stdio: "ignore", timeout: 15e3 });
19655
19720
  }
@@ -19717,8 +19782,8 @@ function maybeResumeLocalHeadroomReporter(ctx) {
19717
19782
  if (process.env["HEADROOM_ENABLED"] === "1") return null;
19718
19783
  try {
19719
19784
  const file = headroomConfigPath();
19720
- if (!fs43.existsSync(file)) return null;
19721
- const cfg = JSON.parse(fs43.readFileSync(file, "utf8"));
19785
+ if (!fs44.existsSync(file)) return null;
19786
+ const cfg = JSON.parse(fs44.readFileSync(file, "utf8"));
19722
19787
  if (!cfg?.enabled) return null;
19723
19788
  const agent = cfg.agent ?? "claude";
19724
19789
  const ingestUrl = `${resolveApiBaseUrl()}/api/sessions/${ctx.sessionId}/headroom-savings`;
@@ -20300,13 +20365,13 @@ var HostAgentSupervisor = class {
20300
20365
  const relay = this.relay;
20301
20366
  if (!relay) return;
20302
20367
  const raw = cmd.payload?.path;
20303
- const target = typeof raw === "string" && raw.trim() ? path46.resolve(raw.trim()) : os38.homedir();
20368
+ const target = typeof raw === "string" && raw.trim() ? path47.resolve(raw.trim()) : os38.homedir();
20304
20369
  try {
20305
- const dirents = await fs43.promises.readdir(target, { withFileTypes: true });
20370
+ const dirents = await fs44.promises.readdir(target, { withFileTypes: true });
20306
20371
  const entries = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
20307
20372
  (a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
20308
20373
  );
20309
- const parent = path46.dirname(target);
20374
+ const parent = path47.dirname(target);
20310
20375
  await relay.sendResult(cmd.id, "completed", {
20311
20376
  path: target,
20312
20377
  // null at the filesystem root so the UI can hide the ".." affordance.
@@ -20536,14 +20601,14 @@ var HostAgentSupervisor = class {
20536
20601
  API_TIMEOUT_MS: "3000000",
20537
20602
  CODEAM_AUTO_TOKEN: payload.autoPairToken
20538
20603
  };
20539
- const houseConfigDir = path46.join(
20604
+ const houseConfigDir = path47.join(
20540
20605
  os38.homedir(),
20541
20606
  ".codeam",
20542
20607
  "house-claude",
20543
20608
  payload.deployId
20544
20609
  );
20545
20610
  try {
20546
- fs43.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
20611
+ fs44.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
20547
20612
  } catch {
20548
20613
  }
20549
20614
  childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
@@ -20570,13 +20635,13 @@ var HostAgentSupervisor = class {
20570
20635
  if ((payload.repoProvider ?? "github") === "gitlab") {
20571
20636
  const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
20572
20637
  if (glabCmd) {
20573
- childEnv.PATH = `${codeamBinDir()}${path46.delimiter}${childEnv.PATH}`;
20638
+ childEnv.PATH = `${codeamBinDir()}${path47.delimiter}${childEnv.PATH}`;
20574
20639
  await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
20575
20640
  }
20576
20641
  } else {
20577
20642
  const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
20578
20643
  if (ghCmd) {
20579
- childEnv.PATH = `${codeamBinDir()}${path46.delimiter}${childEnv.PATH}`;
20644
+ childEnv.PATH = `${codeamBinDir()}${path47.delimiter}${childEnv.PATH}`;
20580
20645
  await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
20581
20646
  }
20582
20647
  }
@@ -20872,12 +20937,12 @@ var HostAgentSupervisor = class {
20872
20937
  this.children.delete(deployId);
20873
20938
  }
20874
20939
  const dirs = [
20875
- path46.join(selfHostedWorkspaceRoot(), deployId),
20876
- path46.join(os38.homedir(), ".codeam", "house-claude", deployId)
20940
+ path47.join(selfHostedWorkspaceRoot(), deployId),
20941
+ path47.join(os38.homedir(), ".codeam", "house-claude", deployId)
20877
20942
  ];
20878
20943
  for (const dir of dirs) {
20879
20944
  try {
20880
- fs43.rmSync(dir, { recursive: true, force: true });
20945
+ fs44.rmSync(dir, { recursive: true, force: true });
20881
20946
  } catch (err) {
20882
20947
  log.warn(
20883
20948
  "host-agent",
@@ -21014,9 +21079,9 @@ async function configureHeadroom(action, ctx, deps) {
21014
21079
  }
21015
21080
 
21016
21081
  // src/services/headroom/budget-relaunch.ts
21017
- var fs44 = __toESM(require("fs"));
21082
+ var fs45 = __toESM(require("fs"));
21018
21083
  var os39 = __toESM(require("os"));
21019
- var path47 = __toESM(require("path"));
21084
+ var path48 = __toESM(require("path"));
21020
21085
  var import_child_process13 = require("child_process");
21021
21086
  function amendDeploymentManifestBudget(manifest, budget) {
21022
21087
  const rawArgs = manifest.proxy_args ?? [];
@@ -21050,7 +21115,7 @@ function amendDeploymentManifestBudget(manifest, budget) {
21050
21115
  return { ...manifest, proxy_args: newArgs, base_env: newEnv };
21051
21116
  }
21052
21117
  function findHeadroomDeployments(homeDir2, deps) {
21053
- const deployDir = path47.join(homeDir2, ".headroom", "deploy");
21118
+ const deployDir = path48.join(homeDir2, ".headroom", "deploy");
21054
21119
  let profiles;
21055
21120
  try {
21056
21121
  profiles = deps.readDir(deployDir);
@@ -21059,7 +21124,7 @@ function findHeadroomDeployments(homeDir2, deps) {
21059
21124
  }
21060
21125
  const results = [];
21061
21126
  for (const profile of profiles) {
21062
- const manifestPath = path47.join(deployDir, profile, "manifest.json");
21127
+ const manifestPath = path48.join(deployDir, profile, "manifest.json");
21063
21128
  let raw;
21064
21129
  try {
21065
21130
  raw = deps.readJson(manifestPath);
@@ -21091,8 +21156,8 @@ async function applyBudgetToHeadroom(budget, deps) {
21091
21156
  }
21092
21157
  function writeManifestReal(manifestPath, manifest) {
21093
21158
  const tmp = manifestPath + ".codeam.tmp";
21094
- fs44.writeFileSync(tmp, JSON.stringify(manifest, null, 2) + "\n", { mode: 384 });
21095
- fs44.renameSync(tmp, manifestPath);
21159
+ fs45.writeFileSync(tmp, JSON.stringify(manifest, null, 2) + "\n", { mode: 384 });
21160
+ fs45.renameSync(tmp, manifestPath);
21096
21161
  }
21097
21162
  function restartDeploymentReal(profile) {
21098
21163
  try {
@@ -21115,18 +21180,23 @@ function killProxyReal() {
21115
21180
  killHeadroomProxy();
21116
21181
  }
21117
21182
  function spawnProxyReal2(_budget) {
21118
- spawnHeadroomProxy({
21119
- tag: "headroom-budget",
21120
- spawnErrorMsg: (detail) => `proxy relaunch error (best-effort): ${detail}`,
21121
- failureMsg: (detail) => `proxy relaunch failed (best-effort): ${detail}`
21122
- });
21183
+ spawnHeadroomProxy(
21184
+ {
21185
+ tag: "headroom-budget",
21186
+ spawnErrorMsg: (detail) => `proxy relaunch error (best-effort): ${detail}`,
21187
+ failureMsg: (detail) => `proxy relaunch failed (best-effort): ${detail}`
21188
+ },
21189
+ // Deliberate relaunch (killProxyReal already ran) — must never be swallowed
21190
+ // by a lock a liveness supervisor happens to hold.
21191
+ { force: true }
21192
+ );
21123
21193
  }
21124
21194
  function makeRealApplyBudgetDeps() {
21125
21195
  const homeDir2 = os39.homedir();
21126
21196
  return {
21127
21197
  findDeployments: () => findHeadroomDeployments(homeDir2, {
21128
- readDir: (dir) => fs44.readdirSync(dir),
21129
- readJson: (filePath) => JSON.parse(fs44.readFileSync(filePath, "utf8"))
21198
+ readDir: (dir) => fs45.readdirSync(dir),
21199
+ readJson: (filePath) => JSON.parse(fs45.readFileSync(filePath, "utf8"))
21130
21200
  }),
21131
21201
  writeManifest: writeManifestReal,
21132
21202
  restartDeployment: restartDeploymentReal,
@@ -21136,16 +21206,16 @@ function makeRealApplyBudgetDeps() {
21136
21206
  }
21137
21207
 
21138
21208
  // src/services/preview/port-registry.ts
21139
- var fs45 = __toESM(require("fs"));
21209
+ var fs46 = __toESM(require("fs"));
21140
21210
  var os40 = __toESM(require("os"));
21141
- var path48 = __toESM(require("path"));
21211
+ var path49 = __toESM(require("path"));
21142
21212
  var import_child_process14 = require("child_process");
21143
21213
  function registryPath() {
21144
- return path48.join(os40.homedir(), ".codeam", "preview-ports.json");
21214
+ return path49.join(os40.homedir(), ".codeam", "preview-ports.json");
21145
21215
  }
21146
21216
  function readRegistry() {
21147
21217
  try {
21148
- const raw = fs45.readFileSync(registryPath(), "utf8");
21218
+ const raw = fs46.readFileSync(registryPath(), "utf8");
21149
21219
  const parsed = JSON.parse(raw);
21150
21220
  if (parsed && typeof parsed === "object") return parsed;
21151
21221
  } catch {
@@ -21155,10 +21225,10 @@ function readRegistry() {
21155
21225
  function writeRegistry(reg) {
21156
21226
  try {
21157
21227
  const file = registryPath();
21158
- fs45.mkdirSync(path48.dirname(file), { recursive: true });
21228
+ fs46.mkdirSync(path49.dirname(file), { recursive: true });
21159
21229
  const tmp = `${file}.tmp`;
21160
- fs45.writeFileSync(tmp, JSON.stringify(reg), "utf8");
21161
- fs45.renameSync(tmp, file);
21230
+ fs46.writeFileSync(tmp, JSON.stringify(reg), "utf8");
21231
+ fs46.renameSync(tmp, file);
21162
21232
  } catch (err) {
21163
21233
  log.warn("preview", `port-registry write failed: ${err instanceof Error ? err.message : String(err)}`);
21164
21234
  }
@@ -21894,8 +21964,8 @@ function activePreviewSessionIds() {
21894
21964
 
21895
21965
  // src/services/preview/start-orchestrator.ts
21896
21966
  var import_child_process18 = require("child_process");
21897
- var fs50 = __toESM(require("fs"));
21898
- var path53 = __toESM(require("path"));
21967
+ var fs51 = __toESM(require("fs"));
21968
+ var path54 = __toESM(require("path"));
21899
21969
  var import_which2 = __toESM(require("which"));
21900
21970
  var INSTALL_TIMEOUT_MS = 5 * 6e4;
21901
21971
  var SETUP_TIMEOUT_MS = 2 * 6e4;
@@ -21962,8 +22032,8 @@ function normalizeDetectionForSpawn(detection, cwd) {
21962
22032
  if (args2.length === 0) return detection;
21963
22033
  const binName = args2[0];
21964
22034
  if (binName.startsWith("-")) return detection;
21965
- const binPath = path53.join(cwd, "node_modules", ".bin", binName);
21966
- if (!fs50.existsSync(binPath)) return detection;
22035
+ const binPath = path54.join(cwd, "node_modules", ".bin", binName);
22036
+ if (!fs51.existsSync(binPath)) return detection;
21967
22037
  return {
21968
22038
  ...detection,
21969
22039
  command: binPath,
@@ -22327,9 +22397,9 @@ async function establishTunnel(ctx, dev) {
22327
22397
 
22328
22398
  // src/beads/bd-adapter.ts
22329
22399
  var import_child_process19 = require("child_process");
22330
- var fs51 = __toESM(require("fs"));
22400
+ var fs52 = __toESM(require("fs"));
22331
22401
  var os42 = __toESM(require("os"));
22332
- var path54 = __toESM(require("path"));
22402
+ var path55 = __toESM(require("path"));
22333
22403
  var BD_PACKAGE = "@beads/bd";
22334
22404
  function resolveBundledBdBinary() {
22335
22405
  return _resolveSeam.resolveBundled();
@@ -22341,11 +22411,11 @@ function _defaultResolveBundled() {
22341
22411
  } catch {
22342
22412
  return null;
22343
22413
  }
22344
- const binDir = path54.join(path54.dirname(pkgJsonPath), "bin");
22414
+ const binDir = path55.join(path55.dirname(pkgJsonPath), "bin");
22345
22415
  const binaryName = process.platform === "win32" ? "bd.exe" : "bd";
22346
- const binaryPath = path54.join(binDir, binaryName);
22416
+ const binaryPath = path55.join(binDir, binaryName);
22347
22417
  try {
22348
- fs51.accessSync(binaryPath, fs51.constants.F_OK);
22418
+ fs52.accessSync(binaryPath, fs52.constants.F_OK);
22349
22419
  return binaryPath;
22350
22420
  } catch {
22351
22421
  return null;
@@ -22355,13 +22425,13 @@ function resolveBdOnPath() {
22355
22425
  return _resolveSeam.resolveOnPath();
22356
22426
  }
22357
22427
  function _defaultResolveOnPath() {
22358
- const dirs = (process.env.PATH ?? "").split(path54.delimiter).filter(Boolean);
22428
+ const dirs = (process.env.PATH ?? "").split(path55.delimiter).filter(Boolean);
22359
22429
  const candidates = process.platform === "win32" ? ["bd.exe", "bd.cmd", "bd"] : ["bd"];
22360
22430
  for (const dir of dirs) {
22361
22431
  for (const candidate of candidates) {
22362
- const full = path54.join(dir, candidate);
22432
+ const full = path55.join(dir, candidate);
22363
22433
  try {
22364
- fs51.accessSync(full, fs51.constants.F_OK);
22434
+ fs52.accessSync(full, fs52.constants.F_OK);
22365
22435
  return full;
22366
22436
  } catch {
22367
22437
  }
@@ -22538,9 +22608,9 @@ function coerceIssue(row, projectKey) {
22538
22608
 
22539
22609
  // src/beads/provisioner.ts
22540
22610
  var import_child_process23 = require("child_process");
22541
- var fs54 = __toESM(require("fs"));
22611
+ var fs55 = __toESM(require("fs"));
22542
22612
  var os44 = __toESM(require("os"));
22543
- var path57 = __toESM(require("path"));
22613
+ var path58 = __toESM(require("path"));
22544
22614
 
22545
22615
  // src/beads/install-bd.ts
22546
22616
  var import_child_process20 = require("child_process");
@@ -22605,9 +22675,9 @@ async function installBd(platform3 = process.platform) {
22605
22675
 
22606
22676
  // src/beads/install-dolt.ts
22607
22677
  var import_child_process21 = require("child_process");
22608
- var fs52 = __toESM(require("fs"));
22678
+ var fs53 = __toESM(require("fs"));
22609
22679
  var os43 = __toESM(require("os"));
22610
- var path55 = __toESM(require("path"));
22680
+ var path56 = __toESM(require("path"));
22611
22681
  var DOLT_INSTALL_SH_URL = "https://github.com/dolthub/dolt/releases/latest/download/install.sh";
22612
22682
  var DOLT_MSI_URL = "https://github.com/dolthub/dolt/releases/latest/download/dolt-windows-amd64.msi";
22613
22683
  function resolveDoltInstallStrategy(platform3) {
@@ -22703,7 +22773,7 @@ var _doltPathSeam = {
22703
22773
  },
22704
22774
  exists: (p2) => {
22705
22775
  try {
22706
- fs52.accessSync(p2, fs52.constants.F_OK);
22776
+ fs53.accessSync(p2, fs53.constants.F_OK);
22707
22777
  return true;
22708
22778
  } catch {
22709
22779
  return false;
@@ -22714,7 +22784,7 @@ function doltBinaryNames(platform3) {
22714
22784
  return platform3 === "win32" ? ["dolt.exe", "dolt.cmd", "dolt"] : ["dolt"];
22715
22785
  }
22716
22786
  function knownDoltDirs(platform3) {
22717
- const P3 = platform3 === "win32" ? path55.win32 : path55.posix;
22787
+ const P3 = platform3 === "win32" ? path56.win32 : path56.posix;
22718
22788
  const home = _doltPathSeam.homedir();
22719
22789
  if (platform3 === "win32") {
22720
22790
  return [
@@ -22730,7 +22800,7 @@ function knownDoltDirs(platform3) {
22730
22800
  ].filter(Boolean);
22731
22801
  }
22732
22802
  function ensureDoltResolvable(platform3 = process.platform) {
22733
- const P3 = platform3 === "win32" ? path55.win32 : path55.posix;
22803
+ const P3 = platform3 === "win32" ? path56.win32 : path56.posix;
22734
22804
  const delim = platform3 === "win32" ? ";" : ":";
22735
22805
  const names = doltBinaryNames(platform3);
22736
22806
  const pathDirs = _doltPathSeam.getPath().split(delim).filter(Boolean);
@@ -22866,8 +22936,8 @@ async function ensureSharedServer(adapter, options = {}) {
22866
22936
  // src/beads/project-key.ts
22867
22937
  var import_child_process22 = require("child_process");
22868
22938
  var crypto2 = __toESM(require("crypto"));
22869
- var fs53 = __toESM(require("fs"));
22870
- var path56 = __toESM(require("path"));
22939
+ var fs54 = __toESM(require("fs"));
22940
+ var path57 = __toESM(require("path"));
22871
22941
  function normalizeOrigin(raw) {
22872
22942
  const trimmed = raw.trim();
22873
22943
  if (!trimmed) return null;
@@ -22893,17 +22963,17 @@ function normalizeOrigin(raw) {
22893
22963
  return `${host2}/${pathPart}`;
22894
22964
  }
22895
22965
  function findRepoRoot(cwd) {
22896
- let dir = path56.resolve(cwd);
22966
+ let dir = path57.resolve(cwd);
22897
22967
  const seen = /* @__PURE__ */ new Set();
22898
22968
  for (let i = 0; i < 256; i++) {
22899
22969
  if (seen.has(dir)) return null;
22900
22970
  seen.add(dir);
22901
22971
  try {
22902
- const stat3 = fs53.statSync(path56.join(dir, ".git"), { throwIfNoEntry: false });
22972
+ const stat3 = fs54.statSync(path57.join(dir, ".git"), { throwIfNoEntry: false });
22903
22973
  if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
22904
22974
  } catch {
22905
22975
  }
22906
- const parent = path56.dirname(dir);
22976
+ const parent = path57.dirname(dir);
22907
22977
  if (parent === dir) return null;
22908
22978
  dir = parent;
22909
22979
  }
@@ -22914,7 +22984,7 @@ var _execSeam2 = {
22914
22984
  const out2 = (0, import_child_process22.execFileSync)(file, args2, opts);
22915
22985
  return typeof out2 === "string" ? out2 : out2.toString("utf8");
22916
22986
  },
22917
- realpath: (p2) => fs53.realpathSync(p2)
22987
+ realpath: (p2) => fs54.realpathSync(p2)
22918
22988
  };
22919
22989
  function readOrigin(cwd) {
22920
22990
  try {
@@ -22943,7 +23013,7 @@ function deriveProjectIdentity(cwd = process.cwd()) {
22943
23013
  } catch {
22944
23014
  }
22945
23015
  const hash = crypto2.createHash("sha256").update(real).digest("hex");
22946
- return { projectKey: `path:${hash}`, projectLabel: path56.basename(real) || "project" };
23016
+ return { projectKey: `path:${hash}`, projectLabel: path57.basename(real) || "project" };
22947
23017
  }
22948
23018
 
22949
23019
  // src/beads/project-prefix.ts
@@ -22993,14 +23063,14 @@ var _linkSeam = {
22993
23063
  homedir: () => os44.homedir(),
22994
23064
  isWritableDir: (dir) => {
22995
23065
  try {
22996
- fs54.accessSync(dir, fs54.constants.W_OK);
23066
+ fs55.accessSync(dir, fs55.constants.W_OK);
22997
23067
  return true;
22998
23068
  } catch {
22999
23069
  return false;
23000
23070
  }
23001
23071
  },
23002
23072
  ensureDir: (dir) => {
23003
- fs54.mkdirSync(dir, { recursive: true });
23073
+ fs55.mkdirSync(dir, { recursive: true });
23004
23074
  },
23005
23075
  /**
23006
23076
  * A directory to symlink `bd` into so the AGENT's shell + Claude Code's
@@ -23021,9 +23091,9 @@ var _linkSeam = {
23021
23091
  * which `linkBdOntoPath` creates if missing.
23022
23092
  */
23023
23093
  cliBinDir: () => {
23024
- const pathDirs = (process.env.PATH ?? "").split(path57.delimiter).filter(Boolean);
23094
+ const pathDirs = (process.env.PATH ?? "").split(path58.delimiter).filter(Boolean);
23025
23095
  const home = _linkSeam.homedir();
23026
- const localBin = home ? path57.join(home, ".local", "bin") : null;
23096
+ const localBin = home ? path58.join(home, ".local", "bin") : null;
23027
23097
  if (localBin) {
23028
23098
  try {
23029
23099
  _linkSeam.ensureDir(localBin);
@@ -23033,16 +23103,16 @@ var _linkSeam = {
23033
23103
  const candidates = [];
23034
23104
  if (localBin) candidates.push(localBin);
23035
23105
  try {
23036
- candidates.push(path57.dirname(process.execPath));
23106
+ candidates.push(path58.dirname(process.execPath));
23037
23107
  } catch {
23038
23108
  }
23039
23109
  candidates.push("/usr/local/bin");
23040
23110
  const entry = process.argv[1];
23041
23111
  if (entry) {
23042
23112
  try {
23043
- candidates.push(path57.dirname(fs54.realpathSync(entry)));
23113
+ candidates.push(path58.dirname(fs55.realpathSync(entry)));
23044
23114
  } catch {
23045
- candidates.push(path57.dirname(entry));
23115
+ candidates.push(path58.dirname(entry));
23046
23116
  }
23047
23117
  }
23048
23118
  const onPathWritable = candidates.find(
@@ -23054,20 +23124,20 @@ var _linkSeam = {
23054
23124
  /** Current symlink target at `linkPath`, or null when absent / not a link. */
23055
23125
  readlink: (linkPath) => {
23056
23126
  try {
23057
- return fs54.readlinkSync(linkPath);
23127
+ return fs55.readlinkSync(linkPath);
23058
23128
  } catch {
23059
23129
  return null;
23060
23130
  }
23061
23131
  },
23062
- unlink: (linkPath) => fs54.unlinkSync(linkPath),
23063
- symlink: (target, linkPath) => fs54.symlinkSync(target, linkPath)
23132
+ unlink: (linkPath) => fs55.unlinkSync(linkPath),
23133
+ symlink: (target, linkPath) => fs55.symlinkSync(target, linkPath)
23064
23134
  };
23065
23135
  function linkBdOntoPath(binaryPath) {
23066
23136
  if (_linkSeam.platform() === "win32") return;
23067
23137
  const binDir = _linkSeam.cliBinDir();
23068
23138
  if (!binDir) return;
23069
23139
  _linkSeam.ensureDir(binDir);
23070
- const linkPath = path57.join(binDir, "bd");
23140
+ const linkPath = path58.join(binDir, "bd");
23071
23141
  if (linkPath === binaryPath) return;
23072
23142
  const current = _linkSeam.readlink(linkPath);
23073
23143
  if (current === binaryPath) return;
@@ -23262,7 +23332,7 @@ function dedupeRecipes(agents) {
23262
23332
 
23263
23333
  // src/beads/watcher.ts
23264
23334
  var crypto4 = __toESM(require("crypto"));
23265
- var path58 = __toESM(require("path"));
23335
+ var path59 = __toESM(require("path"));
23266
23336
  var API_BASE6 = resolveApiBaseUrl();
23267
23337
  var DEBOUNCE_MS2 = 400;
23268
23338
  var ZERO_SUMMARY = {
@@ -23286,7 +23356,7 @@ var BeadsWatcher = class {
23286
23356
  constructor(opts) {
23287
23357
  this.opts = opts;
23288
23358
  this.bd = opts.adapter ?? new BdAdapter({ cwd: opts.cwd, beadsDir: opts.beadsDir });
23289
- this.feedPath = opts.feedPath ?? path58.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
23359
+ this.feedPath = opts.feedPath ?? path59.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
23290
23360
  this.apiBase = opts.apiBaseUrl ?? API_BASE6;
23291
23361
  }
23292
23362
  opts;
@@ -23785,8 +23855,8 @@ function cleanupAttachmentTempFiles() {
23785
23855
  function saveFilesTemp(files) {
23786
23856
  return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
23787
23857
  const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
23788
- const tmpPath = path61.join(os48.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
23789
- fs57.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
23858
+ const tmpPath = path62.join(os48.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
23859
+ fs58.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
23790
23860
  pendingAttachmentFiles.add(tmpPath);
23791
23861
  return tmpPath;
23792
23862
  });
@@ -23998,9 +24068,9 @@ var listFiles = async (ctx, cmd, parsed) => {
23998
24068
  await ctx.relay.sendResult(cmd.id, "completed", result);
23999
24069
  };
24000
24070
  var envReadH = async (ctx, cmd) => {
24001
- const envPath = path61.join(process.cwd(), ".env");
24071
+ const envPath = path62.join(process.cwd(), ".env");
24002
24072
  try {
24003
- const raw = await fs57.promises.readFile(envPath, "utf8");
24073
+ const raw = await fs58.promises.readFile(envPath, "utf8");
24004
24074
  await ctx.relay.sendResult(cmd.id, "completed", {
24005
24075
  exists: true,
24006
24076
  vars: parseDotenv(raw)
@@ -24031,14 +24101,14 @@ var envWriteH = async (ctx, cmd, parsed) => {
24031
24101
  }
24032
24102
  seen.add(v.key);
24033
24103
  }
24034
- const envPath = path61.join(process.cwd(), ".env");
24035
- const tmpPath = path61.join(process.cwd(), ".env.codeam.tmp");
24104
+ const envPath = path62.join(process.cwd(), ".env");
24105
+ const tmpPath = path62.join(process.cwd(), ".env.codeam.tmp");
24036
24106
  try {
24037
- await fs57.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
24038
- await fs57.promises.rename(tmpPath, envPath);
24107
+ await fs58.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
24108
+ await fs58.promises.rename(tmpPath, envPath);
24039
24109
  await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
24040
24110
  } catch (err) {
24041
- await fs57.promises.rm(tmpPath, { force: true }).catch(() => void 0);
24111
+ await fs58.promises.rm(tmpPath, { force: true }).catch(() => void 0);
24042
24112
  await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
24043
24113
  }
24044
24114
  };
@@ -24087,7 +24157,7 @@ var headroomConfigureH = async (ctx, cmd, parsed) => {
24087
24157
  let configuredAgent = rawAgentId;
24088
24158
  if (!configuredAgent) {
24089
24159
  try {
24090
- const raw = JSON.parse(fs57.readFileSync(headroomConfigPath(), "utf8"));
24160
+ const raw = JSON.parse(fs58.readFileSync(headroomConfigPath(), "utf8"));
24091
24161
  configuredAgent = raw.agent ?? "";
24092
24162
  } catch {
24093
24163
  }
@@ -24121,7 +24191,7 @@ var headroomConfigureH = async (ctx, cmd, parsed) => {
24121
24191
  persist: persistHeadroomConfig,
24122
24192
  readEnabled: () => {
24123
24193
  try {
24124
- const raw = JSON.parse(fs57.readFileSync(headroomConfigPath(), "utf8"));
24194
+ const raw = JSON.parse(fs58.readFileSync(headroomConfigPath(), "utf8"));
24125
24195
  return raw.enabled === true;
24126
24196
  } catch {
24127
24197
  return false;
@@ -24425,7 +24495,7 @@ var headroomBudgetH = async (ctx, cmd) => {
24425
24495
  }
24426
24496
  let headroomActive = false;
24427
24497
  try {
24428
- const raw = JSON.parse(fs57.readFileSync(headroomConfigPath(), "utf8"));
24498
+ const raw = JSON.parse(fs58.readFileSync(headroomConfigPath(), "utf8"));
24429
24499
  headroomActive = raw.enabled === true;
24430
24500
  } catch {
24431
24501
  }
@@ -24435,7 +24505,7 @@ var headroomBudgetH = async (ctx, cmd) => {
24435
24505
  }
24436
24506
  let existingConfig = { enabled: true };
24437
24507
  try {
24438
- existingConfig = JSON.parse(fs57.readFileSync(headroomConfigPath(), "utf8"));
24508
+ existingConfig = JSON.parse(fs58.readFileSync(headroomConfigPath(), "utf8"));
24439
24509
  } catch {
24440
24510
  }
24441
24511
  if (payload.budgetEnabled && payload.budgetUsd != null) {
@@ -24548,9 +24618,9 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
24548
24618
  function buildNpmInstallInvocation(opts) {
24549
24619
  const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
24550
24620
  const execPath = opts?.execPath ?? process.execPath;
24551
- const exists2 = opts?.existsSync ?? fs57.existsSync;
24621
+ const exists2 = opts?.existsSync ?? fs58.existsSync;
24552
24622
  const platform3 = opts?.platform ?? process.platform;
24553
- const p2 = platform3 === "win32" ? path61.win32 : path61.posix;
24623
+ const p2 = platform3 === "win32" ? path62.win32 : path62.posix;
24554
24624
  const normalized = entryScript.split(/[\\/]/).join("/");
24555
24625
  const marker = "/lib/node_modules/codeam-cli/";
24556
24626
  const markerIdx = normalized.indexOf(marker);
@@ -24572,7 +24642,7 @@ function isPermissionError(stderr) {
24572
24642
  function resolveGlobalNodeModulesDir(opts) {
24573
24643
  const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
24574
24644
  const platform3 = opts?.platform ?? process.platform;
24575
- const p2 = platform3 === "win32" ? path61.win32 : path61.posix;
24645
+ const p2 = platform3 === "win32" ? path62.win32 : path62.posix;
24576
24646
  const marker = "/lib/node_modules/codeam-cli/";
24577
24647
  const markerIdx = entryScript.split(/[\\/]/).join("/").indexOf(marker);
24578
24648
  if (markerIdx <= 0) return null;
@@ -24582,9 +24652,9 @@ function resolveGlobalNodeModulesDir(opts) {
24582
24652
  var STALE_STAGING_AGE_MS = CLI_UPDATE_INSTALL_TIMEOUT_MS;
24583
24653
  function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
24584
24654
  if (!nodeModulesDir) return 0;
24585
- const readdirSync12 = deps?.readdirSync ?? fs57.readdirSync;
24586
- const statSync15 = deps?.statSync ?? fs57.statSync;
24587
- const rmSync8 = deps?.rmSync ?? fs57.rmSync;
24655
+ const readdirSync12 = deps?.readdirSync ?? fs58.readdirSync;
24656
+ const statSync17 = deps?.statSync ?? fs58.statSync;
24657
+ const rmSync8 = deps?.rmSync ?? fs58.rmSync;
24588
24658
  let removed = 0;
24589
24659
  let entries;
24590
24660
  try {
@@ -24594,9 +24664,9 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
24594
24664
  }
24595
24665
  for (const name of entries) {
24596
24666
  if (!/^\.codeam-cli-/.test(name)) continue;
24597
- const full = path61.join(nodeModulesDir, name);
24667
+ const full = path62.join(nodeModulesDir, name);
24598
24668
  try {
24599
- const st3 = statSync15(full);
24669
+ const st3 = statSync17(full);
24600
24670
  if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
24601
24671
  rmSync8(full, { recursive: true, force: true });
24602
24672
  removed++;
@@ -25456,11 +25526,11 @@ function resolveTokenValue(args2) {
25456
25526
  }
25457
25527
  const fileFlag = args2.find((a) => a.startsWith("--token-file="));
25458
25528
  if (fileFlag) {
25459
- const path80 = fileFlag.slice("--token-file=".length);
25529
+ const path81 = fileFlag.slice("--token-file=".length);
25460
25530
  try {
25461
- const content = fs58.readFileSync(path80, "utf8").trim();
25462
- if (content.length === 0) fail(`--token-file ${path80} is empty`);
25463
- rmIfExistsQuiet(path80);
25531
+ const content = fs59.readFileSync(path81, "utf8").trim();
25532
+ if (content.length === 0) fail(`--token-file ${path81} is empty`);
25533
+ rmIfExistsQuiet(path81);
25464
25534
  return content;
25465
25535
  } catch (err) {
25466
25536
  fail(`Could not read --token-file: ${err.message}`);
@@ -25550,7 +25620,7 @@ async function claim(token, pluginId, pluginSecretHash) {
25550
25620
  }
25551
25621
  }
25552
25622
  function pairAutoLockPath() {
25553
- return path62.join(os49.homedir(), ".codeam", "pair-auto.lock");
25623
+ return path63.join(os49.homedir(), ".codeam", "pair-auto.lock");
25554
25624
  }
25555
25625
  function isLivePairAuto(pid) {
25556
25626
  if (!Number.isInteger(pid) || pid <= 0 || pid === process.pid) return false;
@@ -25560,7 +25630,7 @@ function isLivePairAuto(pid) {
25560
25630
  if (e.code !== "EPERM") return false;
25561
25631
  }
25562
25632
  try {
25563
- return fs58.readFileSync(`/proc/${pid}/cmdline`, "utf8").includes("codeam");
25633
+ return fs59.readFileSync(`/proc/${pid}/cmdline`, "utf8").includes("codeam");
25564
25634
  } catch {
25565
25635
  return true;
25566
25636
  }
@@ -25570,24 +25640,24 @@ function isLiveCodeam(pid) {
25570
25640
  }
25571
25641
  function daemonLockPath(sessionId) {
25572
25642
  const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
25573
- return path62.join(os49.homedir(), ".codeam", `daemon-${safe}.lock`);
25643
+ return path63.join(os49.homedir(), ".codeam", `daemon-${safe}.lock`);
25574
25644
  }
25575
25645
  function acquireDaemonLock(sessionId) {
25576
25646
  const lockPath = daemonLockPath(sessionId);
25577
25647
  try {
25578
- fs58.mkdirSync(path62.dirname(lockPath), { recursive: true });
25648
+ fs59.mkdirSync(path63.dirname(lockPath), { recursive: true });
25579
25649
  try {
25580
- fs58.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
25650
+ fs59.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
25581
25651
  } catch (e) {
25582
25652
  if (e.code !== "EEXIST") throw e;
25583
- const holder = Number(fs58.readFileSync(lockPath, "utf8").trim());
25653
+ const holder = Number(fs59.readFileSync(lockPath, "utf8").trim());
25584
25654
  if (holder && holder !== process.pid && isLiveCodeam(holder)) return false;
25585
- fs58.writeFileSync(lockPath, String(process.pid));
25655
+ fs59.writeFileSync(lockPath, String(process.pid));
25586
25656
  }
25587
25657
  const release3 = () => {
25588
25658
  try {
25589
- if (fs58.existsSync(lockPath) && Number(fs58.readFileSync(lockPath, "utf8").trim()) === process.pid) {
25590
- fs58.unlinkSync(lockPath);
25659
+ if (fs59.existsSync(lockPath) && Number(fs59.readFileSync(lockPath, "utf8").trim()) === process.pid) {
25660
+ fs59.unlinkSync(lockPath);
25591
25661
  }
25592
25662
  } catch {
25593
25663
  }
@@ -25609,19 +25679,19 @@ function acquireDaemonLock(sessionId) {
25609
25679
  function acquireSingletonLock() {
25610
25680
  const lockPath = pairAutoLockPath();
25611
25681
  try {
25612
- fs58.mkdirSync(path62.dirname(lockPath), { recursive: true });
25682
+ fs59.mkdirSync(path63.dirname(lockPath), { recursive: true });
25613
25683
  try {
25614
- fs58.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
25684
+ fs59.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
25615
25685
  } catch (e) {
25616
25686
  if (e.code !== "EEXIST") throw e;
25617
- const holder = Number(fs58.readFileSync(lockPath, "utf8").trim());
25687
+ const holder = Number(fs59.readFileSync(lockPath, "utf8").trim());
25618
25688
  if (isLivePairAuto(holder)) return false;
25619
- fs58.writeFileSync(lockPath, String(process.pid));
25689
+ fs59.writeFileSync(lockPath, String(process.pid));
25620
25690
  }
25621
25691
  process.once("exit", () => {
25622
25692
  try {
25623
- if (fs58.existsSync(lockPath) && Number(fs58.readFileSync(lockPath, "utf8").trim()) === process.pid) {
25624
- fs58.unlinkSync(lockPath);
25693
+ if (fs59.existsSync(lockPath) && Number(fs59.readFileSync(lockPath, "utf8").trim()) === process.pid) {
25694
+ fs59.unlinkSync(lockPath);
25625
25695
  }
25626
25696
  } catch {
25627
25697
  }
@@ -26068,7 +26138,7 @@ var AgentService = class _AgentService {
26068
26138
  };
26069
26139
 
26070
26140
  // src/agents/acp/adapters.ts
26071
- var path64 = __toESM(require("path"));
26141
+ var path65 = __toESM(require("path"));
26072
26142
 
26073
26143
  // src/agents/acp/agent-binary.ts
26074
26144
  var import_fs4 = __toESM(require("fs"));
@@ -26358,13 +26428,13 @@ function resolveBin(pkgName, binName) {
26358
26428
  try {
26359
26429
  const manifestPath = require_.resolve(`${pkgName}/package.json`);
26360
26430
  const manifest = require_(`${pkgName}/package.json`);
26361
- const pkgDir = path64.dirname(manifestPath);
26431
+ const pkgDir = path65.dirname(manifestPath);
26362
26432
  const bin = manifest.bin;
26363
26433
  if (!bin) return null;
26364
- if (typeof bin === "string") return path64.resolve(pkgDir, bin);
26434
+ if (typeof bin === "string") return path65.resolve(pkgDir, bin);
26365
26435
  const target = binName ?? Object.keys(bin)[0];
26366
26436
  if (!target || !bin[target]) return null;
26367
- return path64.resolve(pkgDir, bin[target]);
26437
+ return path65.resolve(pkgDir, bin[target]);
26368
26438
  } catch {
26369
26439
  return null;
26370
26440
  }
@@ -26514,8 +26584,8 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
26514
26584
  var import_node_crypto11 = require("crypto");
26515
26585
 
26516
26586
  // src/services/history.service.ts
26517
- var fs60 = __toESM(require("fs"));
26518
- var path65 = __toESM(require("path"));
26587
+ var fs61 = __toESM(require("fs"));
26588
+ var path66 = __toESM(require("path"));
26519
26589
  var os51 = __toESM(require("os"));
26520
26590
  var https7 = __toESM(require("https"));
26521
26591
  var http6 = __toESM(require("http"));
@@ -26543,7 +26613,7 @@ function parseJsonl(filePath) {
26543
26613
  const messages = [];
26544
26614
  let raw;
26545
26615
  try {
26546
- raw = fs60.readFileSync(filePath, "utf8");
26616
+ raw = fs61.readFileSync(filePath, "utf8");
26547
26617
  } catch (err) {
26548
26618
  if (err.code !== "ENOENT") {
26549
26619
  log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
@@ -26684,7 +26754,7 @@ var HistoryService = class _HistoryService {
26684
26754
  return this._quotaPercent === null || Date.now() - this._quotaFetchedAt > ttlMs;
26685
26755
  }
26686
26756
  get projectDir() {
26687
- return this.runtime.resolveHistoryDir(this.cwd) ?? path65.join(os51.homedir(), ".claude", "projects", encodeCwd(this.cwd));
26757
+ return this.runtime.resolveHistoryDir(this.cwd) ?? path66.join(os51.homedir(), ".claude", "projects", encodeCwd(this.cwd));
26688
26758
  }
26689
26759
  /** Set the current Claude conversation ID (extracted from /cost command or session start) */
26690
26760
  setCurrentConversationId(id) {
@@ -26696,7 +26766,7 @@ var HistoryService = class _HistoryService {
26696
26766
  /** Return the current message count in the active conversation. */
26697
26767
  getCurrentMessageCount() {
26698
26768
  if (!this.currentConversationId) return 0;
26699
- const filePath = path65.join(this.projectDir, `${this.currentConversationId}.jsonl`);
26769
+ const filePath = path66.join(this.projectDir, `${this.currentConversationId}.jsonl`);
26700
26770
  return parseJsonl(filePath).length;
26701
26771
  }
26702
26772
  /**
@@ -26707,7 +26777,7 @@ var HistoryService = class _HistoryService {
26707
26777
  const deadline = Date.now() + timeoutMs;
26708
26778
  while (Date.now() < deadline) {
26709
26779
  if (!this.currentConversationId) return null;
26710
- const filePath = path65.join(this.projectDir, `${this.currentConversationId}.jsonl`);
26780
+ const filePath = path66.join(this.projectDir, `${this.currentConversationId}.jsonl`);
26711
26781
  const messages = parseJsonl(filePath);
26712
26782
  if (messages.length > previousCount) {
26713
26783
  for (let i = messages.length - 1; i >= previousCount; i--) {
@@ -26733,16 +26803,16 @@ var HistoryService = class _HistoryService {
26733
26803
  const dir = this.projectDir;
26734
26804
  const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
26735
26805
  try {
26736
- const files = fs60.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
26806
+ const files = fs61.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
26737
26807
  try {
26738
- const stat3 = fs60.statSync(path65.join(dir, e.name));
26808
+ const stat3 = fs61.statSync(path66.join(dir, e.name));
26739
26809
  return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
26740
26810
  } catch {
26741
26811
  return { name: e.name, mtime: 0, birthtime: 0 };
26742
26812
  }
26743
26813
  }).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
26744
26814
  if (files.length > 0) {
26745
- this.currentConversationId = path65.basename(files[0].name, ".jsonl");
26815
+ this.currentConversationId = path66.basename(files[0].name, ".jsonl");
26746
26816
  }
26747
26817
  } catch {
26748
26818
  }
@@ -26776,13 +26846,13 @@ var HistoryService = class _HistoryService {
26776
26846
  const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
26777
26847
  let entries;
26778
26848
  try {
26779
- entries = fs60.readdirSync(dir, { withFileTypes: true });
26849
+ entries = fs61.readdirSync(dir, { withFileTypes: true });
26780
26850
  } catch {
26781
26851
  return null;
26782
26852
  }
26783
26853
  const files = entries.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
26784
26854
  try {
26785
- const stat3 = fs60.statSync(path65.join(dir, e.name));
26855
+ const stat3 = fs61.statSync(path66.join(dir, e.name));
26786
26856
  return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
26787
26857
  } catch {
26788
26858
  return { name: e.name, mtime: 0, birthtime: 0 };
@@ -26791,12 +26861,12 @@ var HistoryService = class _HistoryService {
26791
26861
  if (files.length === 0) return null;
26792
26862
  const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
26793
26863
  if (!files.some((f) => f.name === targetFile)) return null;
26794
- return this.extractUsageFromFile(path65.join(dir, targetFile));
26864
+ return this.extractUsageFromFile(path66.join(dir, targetFile));
26795
26865
  }
26796
26866
  extractUsageFromFile(filePath) {
26797
26867
  let raw;
26798
26868
  try {
26799
- raw = fs60.readFileSync(filePath, "utf8");
26869
+ raw = fs61.readFileSync(filePath, "utf8");
26800
26870
  } catch {
26801
26871
  return null;
26802
26872
  }
@@ -26841,9 +26911,9 @@ var HistoryService = class _HistoryService {
26841
26911
  let totalCost = 0;
26842
26912
  let files;
26843
26913
  try {
26844
- files = fs60.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
26914
+ files = fs61.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
26845
26915
  try {
26846
- return fs60.statSync(path65.join(projectDir, f)).mtimeMs >= monthStartMs;
26916
+ return fs61.statSync(path66.join(projectDir, f)).mtimeMs >= monthStartMs;
26847
26917
  } catch {
26848
26918
  return false;
26849
26919
  }
@@ -26854,7 +26924,7 @@ var HistoryService = class _HistoryService {
26854
26924
  for (const file of files) {
26855
26925
  let raw;
26856
26926
  try {
26857
- raw = fs60.readFileSync(path65.join(projectDir, file), "utf8");
26927
+ raw = fs61.readFileSync(path66.join(projectDir, file), "utf8");
26858
26928
  } catch {
26859
26929
  continue;
26860
26930
  }
@@ -26933,7 +27003,7 @@ var HistoryService = class _HistoryService {
26933
27003
  if (this.runtime.resolveHistoryFile) {
26934
27004
  return this.runtime.resolveHistoryFile(this.cwd, sessionId);
26935
27005
  }
26936
- return path65.join(this.projectDir, `${sessionId}.jsonl`);
27006
+ return path66.join(this.projectDir, `${sessionId}.jsonl`);
26937
27007
  }
26938
27008
  /**
26939
27009
  * Parse a conversation's messages from disk, agent-aware. Claude uses the
@@ -26967,7 +27037,7 @@ var HistoryService = class _HistoryService {
26967
27037
  };
26968
27038
  });
26969
27039
  }
26970
- return parseJsonl(path65.join(this.projectDir, `${sessionId}.jsonl`));
27040
+ return parseJsonl(path66.join(this.projectDir, `${sessionId}.jsonl`));
26971
27041
  }
26972
27042
  async loadConversation(sessionId) {
26973
27043
  const messages = this.readConversation(sessionId);
@@ -27035,7 +27105,7 @@ var HistoryService = class _HistoryService {
27035
27105
  if (!filePath) return false;
27036
27106
  let mtimeMs;
27037
27107
  try {
27038
- mtimeMs = fs60.statSync(filePath).mtimeMs;
27108
+ mtimeMs = fs61.statSync(filePath).mtimeMs;
27039
27109
  } catch {
27040
27110
  return false;
27041
27111
  }
@@ -27110,10 +27180,10 @@ var HistoryService = class _HistoryService {
27110
27180
 
27111
27181
  // src/agents/acp/client.ts
27112
27182
  var import_node_child_process29 = require("child_process");
27113
- var fs61 = __toESM(require("fs/promises"));
27183
+ var fs62 = __toESM(require("fs/promises"));
27114
27184
  var fsSync = __toESM(require("fs"));
27115
27185
  var os53 = __toESM(require("os"));
27116
- var path67 = __toESM(require("path"));
27186
+ var path68 = __toESM(require("path"));
27117
27187
  var import_node_stream = require("stream");
27118
27188
 
27119
27189
  // ../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
@@ -31139,7 +31209,7 @@ function createIdleTimeout(idleMs, makeError, activeIdleMs = idleMs) {
31139
31209
  }
31140
31210
 
31141
31211
  // src/agents/acp/internal-paths.ts
31142
- var path66 = __toESM(require("path"));
31212
+ var path67 = __toESM(require("path"));
31143
31213
  var os52 = __toESM(require("os"));
31144
31214
  var INTERNAL_TOKENS = [".codeam", "house-claude"];
31145
31215
  function textReferencesInternal(text) {
@@ -31148,10 +31218,10 @@ function textReferencesInternal(text) {
31148
31218
  }
31149
31219
  function pathIsInternal(p2, homeDir2 = os52.homedir()) {
31150
31220
  if (!p2) return false;
31151
- const abs = path66.resolve(p2);
31152
- const home = path66.resolve(homeDir2);
31153
- const within = (root) => abs === root || abs.startsWith(root + path66.sep);
31154
- return within(path66.join(home, ".codeam")) || within(path66.join(home, ".beads")) || abs === path66.join(home, ".codeam-host.log") || abs.includes(`${path66.sep}house-claude${path66.sep}`) || abs.endsWith(`${path66.sep}house-claude`);
31221
+ const abs = path67.resolve(p2);
31222
+ const home = path67.resolve(homeDir2);
31223
+ const within = (root) => abs === root || abs.startsWith(root + path67.sep);
31224
+ return within(path67.join(home, ".codeam")) || within(path67.join(home, ".beads")) || abs === path67.join(home, ".codeam-host.log") || abs.includes(`${path67.sep}house-claude${path67.sep}`) || abs.endsWith(`${path67.sep}house-claude`);
31155
31225
  }
31156
31226
  function toolCallReferencesInternal(call) {
31157
31227
  if (textReferencesInternal(call.title)) return true;
@@ -31935,7 +32005,7 @@ var AcpClient = class {
31935
32005
  throw new RequestError(-32002, INTERNAL_BLOCK_REASON, { uri: params.path });
31936
32006
  }
31937
32007
  try {
31938
- const content = await fs61.readFile(params.path, "utf8");
32008
+ const content = await fs62.readFile(params.path, "utf8");
31939
32009
  return applyLineRange(content, params.line ?? null, params.limit ?? null);
31940
32010
  } catch (err) {
31941
32011
  const code = err.code;
@@ -31958,7 +32028,7 @@ var AcpClient = class {
31958
32028
  throw new RequestError(-32002, INTERNAL_BLOCK_REASON, { uri: params.path });
31959
32029
  }
31960
32030
  try {
31961
- await fs61.writeFile(params.path, params.content, "utf8");
32031
+ await fs62.writeFile(params.path, params.content, "utf8");
31962
32032
  return {};
31963
32033
  } catch (err) {
31964
32034
  const code = err.code;
@@ -32023,24 +32093,24 @@ function knownAgentBinaryDirs() {
32023
32093
  out2.push("/tmp/codeam-node20/bin");
32024
32094
  for (const root of [
32025
32095
  "/usr/local/share/nvm/versions/node",
32026
- path67.join(home, ".nvm/versions/node")
32096
+ path68.join(home, ".nvm/versions/node")
32027
32097
  ]) {
32028
32098
  try {
32029
32099
  for (const child of fsSync.readdirSync(root)) {
32030
- out2.push(path67.join(root, child, "bin"));
32100
+ out2.push(path68.join(root, child, "bin"));
32031
32101
  }
32032
32102
  } catch {
32033
32103
  }
32034
32104
  }
32035
- out2.push(path67.join(home, ".volta/bin"));
32105
+ out2.push(path68.join(home, ".volta/bin"));
32036
32106
  out2.push("/usr/local/bin");
32037
32107
  out2.push("/usr/bin");
32038
- out2.push(path67.join(home, ".local/bin"));
32039
- out2.push(path67.join(home, "bin"));
32108
+ out2.push(path68.join(home, ".local/bin"));
32109
+ out2.push(path68.join(home, "bin"));
32040
32110
  if (process.platform === "win32") {
32041
32111
  const { LOCALAPPDATA, APPDATA } = process.env;
32042
- if (LOCALAPPDATA) out2.push(path67.join(LOCALAPPDATA, "cursor-agent"));
32043
- if (APPDATA) out2.push(path67.join(APPDATA, "npm"));
32112
+ if (LOCALAPPDATA) out2.push(path68.join(LOCALAPPDATA, "cursor-agent"));
32113
+ if (APPDATA) out2.push(path68.join(APPDATA, "npm"));
32044
32114
  }
32045
32115
  return out2.filter((p2) => {
32046
32116
  try {
@@ -32052,7 +32122,7 @@ function knownAgentBinaryDirs() {
32052
32122
  }
32053
32123
  function expandPathForAgentBinaries(existingPath) {
32054
32124
  const existing = new Set(
32055
- existingPath.split(path67.delimiter).filter((p2) => p2.length > 0)
32125
+ existingPath.split(path68.delimiter).filter((p2) => p2.length > 0)
32056
32126
  );
32057
32127
  const additions = [];
32058
32128
  for (const dir of knownAgentBinaryDirs()) {
@@ -32062,7 +32132,7 @@ function expandPathForAgentBinaries(existingPath) {
32062
32132
  }
32063
32133
  }
32064
32134
  if (additions.length === 0) return existingPath;
32065
- return [...additions, existingPath].filter((p2) => p2.length > 0).join(path67.delimiter);
32135
+ return [...additions, existingPath].filter((p2) => p2.length > 0).join(path68.delimiter);
32066
32136
  }
32067
32137
 
32068
32138
  // src/agents/acp/headroom-budget-proxy.ts
@@ -32544,15 +32614,15 @@ function commonPrefixLength(a, b) {
32544
32614
 
32545
32615
  // src/agents/acp/onboarding.ts
32546
32616
  var import_child_process27 = require("child_process");
32547
- var fs62 = __toESM(require("fs"));
32617
+ var fs63 = __toESM(require("fs"));
32548
32618
  var os54 = __toESM(require("os"));
32549
- var path68 = __toESM(require("path"));
32619
+ var path69 = __toESM(require("path"));
32550
32620
  var _onboardingSeam = {
32551
- markerPath: (sessionId) => path68.join(os54.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
32552
- exists: (p2) => fs62.existsSync(p2),
32621
+ markerPath: (sessionId) => path69.join(os54.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
32622
+ exists: (p2) => fs63.existsSync(p2),
32553
32623
  write: (p2) => {
32554
- fs62.mkdirSync(path68.dirname(p2), { recursive: true });
32555
- fs62.writeFileSync(p2, "");
32624
+ fs63.mkdirSync(path69.dirname(p2), { recursive: true });
32625
+ fs63.writeFileSync(p2, "");
32556
32626
  },
32557
32627
  disabled: () => {
32558
32628
  const v = process.env.CODEAM_ONBOARDING_DISABLED;
@@ -32589,7 +32659,7 @@ function resolveRepoName(cwd) {
32589
32659
  if (name) return name;
32590
32660
  }
32591
32661
  }
32592
- const base = path68.basename(cwd || "");
32662
+ const base = path69.basename(cwd || "");
32593
32663
  if (base && !isUuid(base)) return base;
32594
32664
  return "this project";
32595
32665
  }
@@ -32841,13 +32911,13 @@ var import_crypto5 = require("crypto");
32841
32911
 
32842
32912
  // src/services/turn-files/git-changeset.ts
32843
32913
  var import_child_process28 = require("child_process");
32844
- var fs64 = __toESM(require("fs/promises"));
32845
- var path70 = __toESM(require("path"));
32914
+ var fs65 = __toESM(require("fs/promises"));
32915
+ var path71 = __toESM(require("path"));
32846
32916
 
32847
32917
  // src/services/turn-files/review-ignore.ts
32848
32918
  var import_ignore2 = __toESM(require("ignore"));
32849
- var fs63 = __toESM(require("fs"));
32850
- var path69 = __toESM(require("path"));
32919
+ var fs64 = __toESM(require("fs"));
32920
+ var path70 = __toESM(require("path"));
32851
32921
  var CURATED_REVIEW_IGNORE = [
32852
32922
  // Google Cloud SDK (the incident) — installs a huge python tree.
32853
32923
  "google-cloud-sdk/",
@@ -32886,7 +32956,7 @@ var CURATED_REVIEW_IGNORE = [
32886
32956
  function makeReviewIgnore(repoRoot) {
32887
32957
  const ig = (0, import_ignore2.default)().add(CURATED_REVIEW_IGNORE);
32888
32958
  try {
32889
- const custom = fs63.readFileSync(path69.join(repoRoot, ".codeam", "reviewignore"), "utf8");
32959
+ const custom = fs64.readFileSync(path70.join(repoRoot, ".codeam", "reviewignore"), "utf8");
32890
32960
  ig.add(custom);
32891
32961
  } catch {
32892
32962
  }
@@ -32931,7 +33001,7 @@ async function collectRepoChangeset(opts) {
32931
33001
  let stats;
32932
33002
  if (!truncated && row.fileStatus === "added" && numstatEntry === void 0) {
32933
33003
  const lineCount = await readUntrackedLineCount(
32934
- path70.join(opts.repoRoot, row.filePath)
33004
+ path71.join(opts.repoRoot, row.filePath)
32935
33005
  );
32936
33006
  stats = { added: lineCount, removed: 0 };
32937
33007
  } else {
@@ -32962,7 +33032,7 @@ function readUntrackedLineCount(absPath) {
32962
33032
  }
32963
33033
  async function defaultReadUntrackedLineCount(absPath) {
32964
33034
  try {
32965
- const content = await fs64.readFile(absPath, "utf8");
33035
+ const content = await fs65.readFile(absPath, "utf8");
32966
33036
  let count = 0;
32967
33037
  let pos = -1;
32968
33038
  while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
@@ -33054,7 +33124,7 @@ function defaultRunGit(cwd, args2) {
33054
33124
  });
33055
33125
  }
33056
33126
  async function discoverRepos(workingDir, maxDepth = 4) {
33057
- const fs70 = await import("fs/promises");
33127
+ const fs71 = await import("fs/promises");
33058
33128
  const out2 = [];
33059
33129
  await walk(workingDir, 0);
33060
33130
  return out2;
@@ -33062,7 +33132,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
33062
33132
  if (depth > maxDepth) return;
33063
33133
  let entries = [];
33064
33134
  try {
33065
- const dirents = await fs70.readdir(dir, { withFileTypes: true });
33135
+ const dirents = await fs71.readdir(dir, { withFileTypes: true });
33066
33136
  entries = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
33067
33137
  } catch {
33068
33138
  return;
@@ -33073,8 +33143,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
33073
33143
  if (hasGit) {
33074
33144
  out2.push({
33075
33145
  repoRoot: dir,
33076
- repoPath: path70.relative(workingDir, dir),
33077
- repoName: path70.basename(dir)
33146
+ repoPath: path71.relative(workingDir, dir),
33147
+ repoName: path71.basename(dir)
33078
33148
  });
33079
33149
  return;
33080
33150
  }
@@ -33082,14 +33152,14 @@ async function discoverRepos(workingDir, maxDepth = 4) {
33082
33152
  if (!entry.isDirectory) continue;
33083
33153
  if (entry.name === "node_modules") continue;
33084
33154
  if (entry.name === "dist" || entry.name === "build") continue;
33085
- await walk(path70.join(dir, entry.name), depth + 1);
33155
+ await walk(path71.join(dir, entry.name), depth + 1);
33086
33156
  }
33087
33157
  }
33088
33158
  }
33089
33159
 
33090
33160
  // src/services/turn-files/files-outbox.ts
33091
- var fs65 = __toESM(require("fs/promises"));
33092
- var path71 = __toESM(require("path"));
33161
+ var fs66 = __toESM(require("fs/promises"));
33162
+ var path72 = __toESM(require("path"));
33093
33163
  var import_os12 = require("os");
33094
33164
  var HOME_OUTBOX_DIR = ".codeam/outbox";
33095
33165
  var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
@@ -33122,16 +33192,16 @@ var FilesOutbox = class {
33122
33192
  backoffIndex = 0;
33123
33193
  stopped = false;
33124
33194
  constructor(opts) {
33125
- const base = opts.baseDir ?? path71.join(homeDir(), HOME_OUTBOX_DIR);
33126
- this.filePath = path71.join(base, `${opts.sessionId}.jsonl`);
33195
+ const base = opts.baseDir ?? path72.join(homeDir(), HOME_OUTBOX_DIR);
33196
+ this.filePath = path72.join(base, `${opts.sessionId}.jsonl`);
33127
33197
  this.post = opts.post;
33128
33198
  this.autoSchedule = opts.autoSchedule !== false;
33129
33199
  }
33130
33200
  /** Persist the entry to disk and trigger a flush. Returns once the
33131
33201
  * line is durable on disk (not once the POST succeeds). */
33132
33202
  async enqueue(entry) {
33133
- await fs65.mkdir(path71.dirname(this.filePath), { recursive: true });
33134
- await fs65.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
33203
+ await fs66.mkdir(path72.dirname(this.filePath), { recursive: true });
33204
+ await fs66.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
33135
33205
  this.backoffIndex = 0;
33136
33206
  if (this.autoSchedule) this.scheduleFlush(0);
33137
33207
  }
@@ -33222,7 +33292,7 @@ var FilesOutbox = class {
33222
33292
  async readAll() {
33223
33293
  let raw = "";
33224
33294
  try {
33225
- raw = await fs65.readFile(this.filePath, "utf8");
33295
+ raw = await fs66.readFile(this.filePath, "utf8");
33226
33296
  } catch {
33227
33297
  return [];
33228
33298
  }
@@ -33246,12 +33316,12 @@ var FilesOutbox = class {
33246
33316
  async rewrite(entries) {
33247
33317
  const tmpPath = `${this.filePath}.${process.pid}.tmp`;
33248
33318
  if (entries.length === 0) {
33249
- await fs65.unlink(this.filePath).catch(() => void 0);
33319
+ await fs66.unlink(this.filePath).catch(() => void 0);
33250
33320
  return;
33251
33321
  }
33252
33322
  const payload = entries.map((e) => JSON.stringify(e)).join("\n") + "\n";
33253
- await fs65.writeFile(tmpPath, payload, "utf8");
33254
- await fs65.rename(tmpPath, this.filePath);
33323
+ await fs66.writeFile(tmpPath, payload, "utf8");
33324
+ await fs66.rename(tmpPath, this.filePath);
33255
33325
  }
33256
33326
  };
33257
33327
  function applyJitter(ms) {
@@ -36257,8 +36327,8 @@ function startClaudeCredentialSync(opts) {
36257
36327
  }
36258
36328
 
36259
36329
  // src/beads/workflow-hint.ts
36260
- var fs66 = __toESM(require("fs"));
36261
- var path72 = __toESM(require("path"));
36330
+ var fs67 = __toESM(require("fs"));
36331
+ var path73 = __toESM(require("path"));
36262
36332
  var os55 = __toESM(require("os"));
36263
36333
  var BEADS_HINT_MARKER = "<!-- codeam:beads-workflow -->";
36264
36334
  var BEADS_HINT = `${BEADS_HINT_MARKER}
@@ -36275,20 +36345,20 @@ This environment uses **bd (beads)** for issue/task tracking and persistent memo
36275
36345
  ${BEADS_HINT_MARKER}`;
36276
36346
  function ensureBeadsWorkflowHint(homeDir2 = os55.homedir()) {
36277
36347
  try {
36278
- const file = path72.join(homeDir2, ".claude", "CLAUDE.md");
36348
+ const file = path73.join(homeDir2, ".claude", "CLAUDE.md");
36279
36349
  let existing = "";
36280
36350
  try {
36281
- existing = fs66.readFileSync(file, "utf8");
36351
+ existing = fs67.readFileSync(file, "utf8");
36282
36352
  } catch {
36283
36353
  }
36284
36354
  if (existing.includes(BEADS_HINT_MARKER)) return;
36285
- fs66.mkdirSync(path72.dirname(file), { recursive: true });
36355
+ fs67.mkdirSync(path73.dirname(file), { recursive: true });
36286
36356
  const next = existing.trim() ? `${existing.trimEnd()}
36287
36357
 
36288
36358
  ${BEADS_HINT}
36289
36359
  ` : `${BEADS_HINT}
36290
36360
  `;
36291
- fs66.writeFileSync(file, next);
36361
+ fs67.writeFileSync(file, next);
36292
36362
  } catch {
36293
36363
  }
36294
36364
  }
@@ -36697,7 +36767,7 @@ var AcpDriver = class {
36697
36767
  };
36698
36768
 
36699
36769
  // src/baton/transcript-mirror.ts
36700
- var fs67 = __toESM(require("fs"));
36770
+ var fs68 = __toESM(require("fs"));
36701
36771
  var TranscriptMirror = class {
36702
36772
  constructor(deps) {
36703
36773
  this.deps = deps;
@@ -36764,7 +36834,7 @@ var TranscriptMirror = class {
36764
36834
  }
36765
36835
  };
36766
36836
  function defaultWatch(file, onChange) {
36767
- const w3 = fs67.watch(file, { persistent: false }, () => onChange());
36837
+ const w3 = fs68.watch(file, { persistent: false }, () => onChange());
36768
36838
  return () => w3.close();
36769
36839
  }
36770
36840
 
@@ -37026,16 +37096,16 @@ function toEpochMs(ts) {
37026
37096
  }
37027
37097
 
37028
37098
  // src/agents/claude/onboarding.ts
37029
- var fs68 = __toESM(require("fs"));
37099
+ var fs69 = __toESM(require("fs"));
37030
37100
  var os57 = __toESM(require("os"));
37031
- var path73 = __toESM(require("path"));
37101
+ var path74 = __toESM(require("path"));
37032
37102
  var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
37033
37103
  function ensureClaudeOnboarded(cwd) {
37034
37104
  try {
37035
- const file = path73.join(os57.homedir(), ".claude.json");
37105
+ const file = path74.join(os57.homedir(), ".claude.json");
37036
37106
  let config = {};
37037
37107
  try {
37038
- config = JSON.parse(fs68.readFileSync(file, "utf8"));
37108
+ config = JSON.parse(fs69.readFileSync(file, "utf8"));
37039
37109
  } catch {
37040
37110
  }
37041
37111
  let changed = false;
@@ -37060,8 +37130,8 @@ function ensureClaudeOnboarded(cwd) {
37060
37130
  }
37061
37131
  }
37062
37132
  if (!changed) return;
37063
- fs68.mkdirSync(path73.dirname(file), { recursive: true });
37064
- fs68.writeFileSync(file, JSON.stringify(config, null, 2));
37133
+ fs69.mkdirSync(path74.dirname(file), { recursive: true });
37134
+ fs69.writeFileSync(file, JSON.stringify(config, null, 2));
37065
37135
  log.info(
37066
37136
  "claude",
37067
37137
  `pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
@@ -37788,7 +37858,7 @@ var import_picocolors11 = __toESM(require("picocolors"));
37788
37858
  var import_child_process29 = require("child_process");
37789
37859
  var import_util4 = require("util");
37790
37860
  var import_picocolors9 = __toESM(require("picocolors"));
37791
- var path74 = __toESM(require("path"));
37861
+ var path75 = __toESM(require("path"));
37792
37862
  var execFileP6 = (0, import_util4.promisify)(import_child_process29.execFile);
37793
37863
  var MAX_BUFFER = 8 * 1024 * 1024;
37794
37864
  function resetStdinForChild() {
@@ -38277,7 +38347,7 @@ var GitHubCodespacesProvider = class {
38277
38347
  });
38278
38348
  }
38279
38349
  async uploadFile(workspaceId, remotePath, contents, options = {}) {
38280
- const remoteDir = path74.posix.dirname(remotePath);
38350
+ const remoteDir = path75.posix.dirname(remotePath);
38281
38351
  const parts = [
38282
38352
  `mkdir -p ${shellQuote(remoteDir)}`,
38283
38353
  `cat > ${shellQuote(remotePath)}`
@@ -38347,7 +38417,7 @@ function shellQuote(s) {
38347
38417
  // src/services/providers/gitpod.ts
38348
38418
  var import_child_process30 = require("child_process");
38349
38419
  var import_util5 = require("util");
38350
- var path75 = __toESM(require("path"));
38420
+ var path76 = __toESM(require("path"));
38351
38421
  var import_picocolors10 = __toESM(require("picocolors"));
38352
38422
  var execFileP7 = (0, import_util5.promisify)(import_child_process30.execFile);
38353
38423
  var MAX_BUFFER2 = 8 * 1024 * 1024;
@@ -38587,7 +38657,7 @@ var GitpodProvider = class {
38587
38657
  });
38588
38658
  }
38589
38659
  async uploadFile(workspaceId, remotePath, contents, options = {}) {
38590
- const remoteDir = path75.posix.dirname(remotePath);
38660
+ const remoteDir = path76.posix.dirname(remotePath);
38591
38661
  const parts = [
38592
38662
  `mkdir -p ${shellQuote2(remoteDir)}`,
38593
38663
  `cat > ${shellQuote2(remotePath)}`
@@ -38623,7 +38693,7 @@ function shellQuote2(s) {
38623
38693
  // src/services/providers/gitlab-workspaces.ts
38624
38694
  var import_child_process31 = require("child_process");
38625
38695
  var import_util6 = require("util");
38626
- var path76 = __toESM(require("path"));
38696
+ var path77 = __toESM(require("path"));
38627
38697
  var execFileP8 = (0, import_util6.promisify)(import_child_process31.execFile);
38628
38698
  var MAX_BUFFER3 = 8 * 1024 * 1024;
38629
38699
  var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
@@ -38883,7 +38953,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
38883
38953
  }
38884
38954
  async uploadFile(workspaceId, remotePath, contents, options = {}) {
38885
38955
  const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
38886
- const remoteDir = path76.posix.dirname(remotePath);
38956
+ const remoteDir = path77.posix.dirname(remotePath);
38887
38957
  const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
38888
38958
  if (options.mode != null) {
38889
38959
  parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
@@ -38951,7 +39021,7 @@ function shellQuote3(s) {
38951
39021
  // src/services/providers/railway.ts
38952
39022
  var import_child_process32 = require("child_process");
38953
39023
  var import_util7 = require("util");
38954
- var path77 = __toESM(require("path"));
39024
+ var path78 = __toESM(require("path"));
38955
39025
  var execFileP9 = (0, import_util7.promisify)(import_child_process32.execFile);
38956
39026
  var MAX_BUFFER4 = 8 * 1024 * 1024;
38957
39027
  function resetStdinForChild4() {
@@ -39187,7 +39257,7 @@ var RailwayProvider = class {
39187
39257
  if (!projectId || !serviceId) {
39188
39258
  throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
39189
39259
  }
39190
- const remoteDir = path77.posix.dirname(remotePath);
39260
+ const remoteDir = path78.posix.dirname(remotePath);
39191
39261
  const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
39192
39262
  if (options.mode != null) {
39193
39263
  parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
@@ -39833,8 +39903,8 @@ async function invite() {
39833
39903
  var import_node_dns = require("dns");
39834
39904
  var import_node_util5 = require("util");
39835
39905
  var import_node_crypto13 = require("crypto");
39836
- var fs69 = __toESM(require("fs"));
39837
- var path78 = __toESM(require("path"));
39906
+ var fs70 = __toESM(require("fs"));
39907
+ var path79 = __toESM(require("path"));
39838
39908
  var import_picocolors14 = __toESM(require("picocolors"));
39839
39909
  var dnsResolveP = (0, import_node_util5.promisify)(import_node_dns.resolve);
39840
39910
  async function checkDns(apiBase2) {
@@ -39890,13 +39960,13 @@ async function checkHealth(apiBase2) {
39890
39960
  }
39891
39961
  }
39892
39962
  function checkConfigDir() {
39893
- const dir = path78.join(require("os").homedir(), ".codeam");
39963
+ const dir = path79.join(require("os").homedir(), ".codeam");
39894
39964
  try {
39895
- fs69.mkdirSync(dir, { recursive: true, mode: 448 });
39896
- const probe = path78.join(dir, ".doctor-probe");
39897
- fs69.writeFileSync(probe, "ok", { mode: 384 });
39898
- const read2 = fs69.readFileSync(probe, "utf8");
39899
- fs69.unlinkSync(probe);
39965
+ fs70.mkdirSync(dir, { recursive: true, mode: 448 });
39966
+ const probe = path79.join(dir, ".doctor-probe");
39967
+ fs70.writeFileSync(probe, "ok", { mode: 384 });
39968
+ const read2 = fs70.readFileSync(probe, "utf8");
39969
+ fs70.unlinkSync(probe);
39900
39970
  if (read2 !== "ok") throw new Error("write/read round-trip mismatch");
39901
39971
  return {
39902
39972
  id: "config-dir",
@@ -39960,7 +40030,7 @@ function checkNodePty() {
39960
40030
  detail: "not required on this platform"
39961
40031
  };
39962
40032
  }
39963
- const vendoredPath = path78.join(__dirname, "vendor", "node-pty");
40033
+ const vendoredPath = path79.join(__dirname, "vendor", "node-pty");
39964
40034
  for (const target of [vendoredPath, "node-pty"]) {
39965
40035
  try {
39966
40036
  require(target);
@@ -40002,7 +40072,7 @@ function checkChokidar() {
40002
40072
  }
40003
40073
  async function doctor(args2 = []) {
40004
40074
  const json = args2.includes("--json");
40005
- const cliVersion = true ? "2.61.71" : "0.0.0-dev";
40075
+ const cliVersion = true ? "2.61.72" : "0.0.0-dev";
40006
40076
  const apiBase2 = resolveApiBaseUrl();
40007
40077
  const diagnosticId = (0, import_node_crypto13.randomUUID)();
40008
40078
  log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
@@ -40524,7 +40594,7 @@ async function mcpRun(args2) {
40524
40594
  // src/commands/version.ts
40525
40595
  var import_picocolors15 = __toESM(require("picocolors"));
40526
40596
  function version2() {
40527
- const v = true ? "2.61.71" : "unknown";
40597
+ const v = true ? "2.61.72" : "unknown";
40528
40598
  console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
40529
40599
  }
40530
40600