codeam-cli 2.60.14 → 2.60.16

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 +12 -0
  2. package/dist/index.js +565 -421
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -778,11 +778,11 @@ function quiet(fn) {
778
778
  log.debug(TAG, "ignored sync error", err);
779
779
  }
780
780
  }
781
- function rmIfExistsQuiet(path69) {
781
+ function rmIfExistsQuiet(path70) {
782
782
  try {
783
- fs2.rmSync(path69, { force: true });
783
+ fs2.rmSync(path70, { force: true });
784
784
  } catch (err) {
785
- log.debug(TAG, `rmIfExists failed for ${path69}`, err);
785
+ log.debug(TAG, `rmIfExists failed for ${path70}`, err);
786
786
  }
787
787
  }
788
788
  function killQuiet(target, signal = "SIGTERM") {
@@ -928,9 +928,9 @@ var _default = makeConfig();
928
928
  var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, clearAll, saveCliConfig, loadCliConfig } = _default;
929
929
 
930
930
  // src/commands/pair-auto.ts
931
- var fs52 = __toESM(require("fs"));
932
- var os41 = __toESM(require("os"));
933
- var path55 = __toESM(require("path"));
931
+ var fs53 = __toESM(require("fs"));
932
+ var os42 = __toESM(require("os"));
933
+ var path56 = __toESM(require("path"));
934
934
  var import_crypto4 = require("crypto");
935
935
 
936
936
  // src/services/telemetry.service.ts
@@ -966,8 +966,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
966
966
  return decodedFile;
967
967
  };
968
968
  }
969
- function normalizeWindowsPath(path69) {
970
- return path69.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
969
+ function normalizeWindowsPath(path70) {
970
+ return path70.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
971
971
  }
972
972
 
973
973
  // ../../node_modules/@posthog/core/dist/featureFlagUtils.mjs
@@ -3447,9 +3447,9 @@ async function addSourceContext(frames) {
3447
3447
  LRU_FILE_CONTENTS_CACHE.reduce();
3448
3448
  return frames;
3449
3449
  }
3450
- function getContextLinesFromFile(path69, ranges, output) {
3450
+ function getContextLinesFromFile(path70, ranges, output) {
3451
3451
  return new Promise((resolve7) => {
3452
- const stream = (0, import_node_fs.createReadStream)(path69);
3452
+ const stream = (0, import_node_fs.createReadStream)(path70);
3453
3453
  const lineReaded = (0, import_node_readline.createInterface)({
3454
3454
  input: stream
3455
3455
  });
@@ -3464,7 +3464,7 @@ function getContextLinesFromFile(path69, ranges, output) {
3464
3464
  let rangeStart = range[0];
3465
3465
  let rangeEnd = range[1];
3466
3466
  function onStreamError() {
3467
- LRU_FILE_CONTENTS_FS_READ_FAILED.set(path69, 1);
3467
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(path70, 1);
3468
3468
  lineReaded.close();
3469
3469
  lineReaded.removeAllListeners();
3470
3470
  destroyStreamAndResolve();
@@ -3525,8 +3525,8 @@ function clearLineContext(frame) {
3525
3525
  delete frame.context_line;
3526
3526
  delete frame.post_context;
3527
3527
  }
3528
- function shouldSkipContextLinesForFile(path69) {
3529
- return path69.startsWith("node:") || path69.endsWith(".min.js") || path69.endsWith(".min.cjs") || path69.endsWith(".min.mjs") || path69.startsWith("data:");
3528
+ function shouldSkipContextLinesForFile(path70) {
3529
+ return path70.startsWith("node:") || path70.endsWith(".min.js") || path70.endsWith(".min.cjs") || path70.endsWith(".min.mjs") || path70.startsWith("data:");
3530
3530
  }
3531
3531
  function shouldSkipContextLinesForFrame(frame) {
3532
3532
  if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
@@ -5680,7 +5680,7 @@ function readAnonId() {
5680
5680
  }
5681
5681
  function superProperties() {
5682
5682
  return {
5683
- cliVersion: true ? "2.60.14" : "0.0.0-dev",
5683
+ cliVersion: true ? "2.60.16" : "0.0.0-dev",
5684
5684
  nodeVersion: process.version,
5685
5685
  platform: process.platform,
5686
5686
  arch: process.arch,
@@ -5861,7 +5861,7 @@ var os4 = __toESM(require("os"));
5861
5861
  // package.json
5862
5862
  var package_default = {
5863
5863
  name: "codeam-cli",
5864
- version: "2.60.14",
5864
+ version: "2.60.16",
5865
5865
  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.",
5866
5866
  type: "commonjs",
5867
5867
  main: "dist/index.js",
@@ -6932,7 +6932,7 @@ var CommandRelayService = class {
6932
6932
  // fresh + clear the "CLI update available" banner after a self-update
6933
6933
  // (a codespace that reinstalls @latest reconnects via heartbeat, not
6934
6934
  // pair/reconnect). Older backends ignore the extra field.
6935
- ..."2.60.14" ? { ideVersion: "2.60.14" } : {}
6935
+ ..."2.60.16" ? { ideVersion: "2.60.16" } : {}
6936
6936
  }).then(() => log.trace("relay", `heartbeat ok online=${online}`)).catch((err) => log.trace("relay", `heartbeat failed online=${online}`, err));
6937
6937
  }
6938
6938
  /**
@@ -7159,10 +7159,10 @@ var WINDOWS_LEGACY_JUNCTIONS = [
7159
7159
  /[\\/]Start Menu([\\/]|$)/i,
7160
7160
  /[\\/]Templates([\\/]|$)/i
7161
7161
  ];
7162
- function isUnsafeWindowsWatchRoot(dir, homedir39) {
7162
+ function isUnsafeWindowsWatchRoot(dir, homedir40) {
7163
7163
  const norm = (p2) => p2.replace(/\//g, "\\").replace(/\\+$/, "").toLowerCase();
7164
7164
  const cwd = norm(dir);
7165
- const home = norm(homedir39);
7165
+ const home = norm(homedir40);
7166
7166
  if (cwd === home) return true;
7167
7167
  if (/^[a-z]:$/.test(cwd)) return true;
7168
7168
  const sysRoots = [
@@ -8306,9 +8306,9 @@ function closeAllTerminals() {
8306
8306
  }
8307
8307
 
8308
8308
  // src/commands/start/handlers.ts
8309
- var fs51 = __toESM(require("fs"));
8310
- var os40 = __toESM(require("os"));
8311
- var path54 = __toESM(require("path"));
8309
+ var fs52 = __toESM(require("fs"));
8310
+ var os41 = __toESM(require("os"));
8311
+ var path55 = __toESM(require("path"));
8312
8312
  var import_crypto3 = require("crypto");
8313
8313
  var import_child_process23 = require("child_process");
8314
8314
 
@@ -9089,9 +9089,9 @@ function findGitRoot2(startDir) {
9089
9089
  }
9090
9090
 
9091
9091
  // src/commands/link.ts
9092
- var import_node_crypto6 = require("crypto");
9093
- var fs29 = __toESM(require("fs"));
9094
- var path33 = __toESM(require("path"));
9092
+ var import_node_crypto7 = require("crypto");
9093
+ var fs30 = __toESM(require("fs"));
9094
+ var path34 = __toESM(require("path"));
9095
9095
  var import_chokidar = __toESM(require("chokidar"));
9096
9096
  var import_picocolors2 = __toESM(require("picocolors"));
9097
9097
 
@@ -11738,10 +11738,10 @@ function buildForPlatform(platform3) {
11738
11738
  var import_node_crypto4 = require("crypto");
11739
11739
 
11740
11740
  // src/agents/claude/resolver.ts
11741
- function buildClaudeLaunch(extraArgs = [], os48 = createOsStrategy()) {
11742
- const found = os48.findInPath("claude") ?? os48.findInPath("claude-code");
11741
+ function buildClaudeLaunch(extraArgs = [], os49 = createOsStrategy()) {
11742
+ const found = os49.findInPath("claude") ?? os49.findInPath("claude-code");
11743
11743
  if (!found) return null;
11744
- return os48.buildLaunch(found, extraArgs);
11744
+ return os49.buildLaunch(found, extraArgs);
11745
11745
  }
11746
11746
 
11747
11747
  // src/agents/claude/installer.ts
@@ -12331,8 +12331,8 @@ var ClaudeRuntimeStrategy = class {
12331
12331
  meta = getAgent("claude");
12332
12332
  mode = "interactive";
12333
12333
  os;
12334
- constructor(os48) {
12335
- this.os = os48;
12334
+ constructor(os49) {
12335
+ this.os = os49;
12336
12336
  }
12337
12337
  /**
12338
12338
  * Claude Code's react-ink TUI enables bracketed-paste mode at
@@ -13031,8 +13031,8 @@ function codexCredentialLocator() {
13031
13031
  function codexLoginLauncher() {
13032
13032
  return {
13033
13033
  async ensureInstalled() {
13034
- const os48 = createOsStrategy();
13035
- return os48.findInPath("codex") !== null;
13034
+ const os49 = createOsStrategy();
13035
+ return os49.findInPath("codex") !== null;
13036
13036
  },
13037
13037
  launch() {
13038
13038
  return (0, import_node_child_process4.spawn)("codex", ["login"], { stdio: "inherit" });
@@ -13055,8 +13055,8 @@ var CodexRuntimeStrategy = class {
13055
13055
  meta = getAgent("codex");
13056
13056
  mode = "interactive";
13057
13057
  os;
13058
- constructor(os48) {
13059
- this.os = os48;
13058
+ constructor(os49) {
13059
+ this.os = os49;
13060
13060
  }
13061
13061
  async prepareLaunch() {
13062
13062
  let binary = this.os.findInPath("codex");
@@ -13155,12 +13155,12 @@ var CodexRuntimeStrategy = class {
13155
13155
  });
13156
13156
  }
13157
13157
  };
13158
- function resolveNpm(os48) {
13159
- return os48.id === "win32" ? "npm.cmd" : "npm";
13158
+ function resolveNpm(os49) {
13159
+ return os49.id === "win32" ? "npm.cmd" : "npm";
13160
13160
  }
13161
- async function installCodexViaNpm(os48) {
13161
+ async function installCodexViaNpm(os49) {
13162
13162
  return new Promise((resolve7, reject) => {
13163
- const proc = (0, import_node_child_process5.spawn)(resolveNpm(os48), ["install", "-g", "@openai/codex"], {
13163
+ const proc = (0, import_node_child_process5.spawn)(resolveNpm(os49), ["install", "-g", "@openai/codex"], {
13164
13164
  stdio: "inherit"
13165
13165
  });
13166
13166
  proc.on("close", (code) => {
@@ -13177,16 +13177,16 @@ async function installCodexViaNpm(os48) {
13177
13177
  });
13178
13178
  });
13179
13179
  }
13180
- function augmentNpmGlobalBin(os48) {
13180
+ function augmentNpmGlobalBin(os49) {
13181
13181
  try {
13182
- const result = (0, import_node_child_process5.spawnSync)(resolveNpm(os48), ["prefix", "-g"], {
13182
+ const result = (0, import_node_child_process5.spawnSync)(resolveNpm(os49), ["prefix", "-g"], {
13183
13183
  stdio: ["ignore", "pipe", "ignore"]
13184
13184
  });
13185
13185
  if (result.status !== 0) return;
13186
13186
  const prefix = result.stdout.toString().trim();
13187
13187
  if (!prefix) return;
13188
- const binDir = os48.id === "win32" ? prefix : path24.join(prefix, "bin");
13189
- os48.augmentPath([binDir]);
13188
+ const binDir = os49.id === "win32" ? prefix : path24.join(prefix, "bin");
13189
+ os49.augmentPath([binDir]);
13190
13190
  } catch {
13191
13191
  }
13192
13192
  }
@@ -13270,9 +13270,9 @@ var import_node_child_process8 = require("child_process");
13270
13270
  // src/agents/coderabbit/installer.ts
13271
13271
  var import_node_child_process6 = require("child_process");
13272
13272
  var INSTALL_URL = "https://cli.coderabbit.ai/install.sh";
13273
- async function ensureCoderabbitInstalled(os48) {
13274
- if (os48.findInPath("coderabbit")) return true;
13275
- if (os48.id === "win32") {
13273
+ async function ensureCoderabbitInstalled(os49) {
13274
+ if (os49.findInPath("coderabbit")) return true;
13275
+ if (os49.id === "win32") {
13276
13276
  console.error(
13277
13277
  "\n \u2717 CodeRabbit on Windows requires WSL.\n Install the CLI inside your WSL distribution\n (curl -fsSL https://cli.coderabbit.ai/install.sh | sh)\n then re-run `codeam link coderabbit` from WSL.\n"
13278
13278
  );
@@ -13287,8 +13287,8 @@ async function ensureCoderabbitInstalled(os48) {
13287
13287
  proc.on("error", () => resolve7(false));
13288
13288
  });
13289
13289
  if (!ok) return false;
13290
- os48.augmentPath([`${os48.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
13291
- return os48.findInPath("coderabbit") !== null;
13290
+ os49.augmentPath([`${os49.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
13291
+ return os49.findInPath("coderabbit") !== null;
13292
13292
  }
13293
13293
 
13294
13294
  // src/agents/coderabbit/link.ts
@@ -13323,10 +13323,10 @@ function coderabbitCredentialLocator() {
13323
13323
  validate: validateNonEmptyCredential
13324
13324
  };
13325
13325
  }
13326
- function coderabbitLoginLauncher(os48) {
13326
+ function coderabbitLoginLauncher(os49) {
13327
13327
  return {
13328
13328
  async ensureInstalled() {
13329
- return ensureCoderabbitInstalled(os48);
13329
+ return ensureCoderabbitInstalled(os49);
13330
13330
  },
13331
13331
  launch() {
13332
13332
  return (0, import_node_child_process7.spawn)("coderabbit", ["login"], { stdio: "inherit" });
@@ -13349,11 +13349,11 @@ function parseReview(stdout) {
13349
13349
  for (const line of lines) {
13350
13350
  const m = line.match(HUNK_LINE_RE);
13351
13351
  if (!m) continue;
13352
- const [, path69, lineNo, sevToken, message] = m;
13353
- if (!path69 || !lineNo || !message) continue;
13352
+ const [, path70, lineNo, sevToken, message] = m;
13353
+ if (!path70 || !lineNo || !message) continue;
13354
13354
  const cleanedMessage = message.trim().replace(/^[*-]\s+/, "");
13355
13355
  hunks.push({
13356
- path: path69.trim(),
13356
+ path: path70.trim(),
13357
13357
  line: Number(lineNo),
13358
13358
  severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
13359
13359
  message: cleanedMessage
@@ -13372,8 +13372,8 @@ var CoderabbitRuntimeStrategy = class {
13372
13372
  meta = getAgent("coderabbit");
13373
13373
  mode = "batch";
13374
13374
  os;
13375
- constructor(os48) {
13376
- this.os = os48;
13375
+ constructor(os49) {
13376
+ this.os = os49;
13377
13377
  }
13378
13378
  getDefaultArgs() {
13379
13379
  return ["review"];
@@ -13547,10 +13547,10 @@ function cursorCredentialLocator() {
13547
13547
  validate: validateNonEmptyCredential
13548
13548
  };
13549
13549
  }
13550
- function cursorLoginLauncher(os48) {
13550
+ function cursorLoginLauncher(os49) {
13551
13551
  return {
13552
13552
  async ensureInstalled() {
13553
- if (os48.findInPath("cursor-agent")) return true;
13553
+ if (os49.findInPath("cursor-agent")) return true;
13554
13554
  console.error(
13555
13555
  "\n \u2717 cursor-agent binary not on PATH.\n Install Cursor (https://cursor.com/) and ensure the CLI\n plugin is enabled, then re-run `codeam link cursor`.\n"
13556
13556
  );
@@ -13612,8 +13612,8 @@ var CursorRuntimeStrategy = class {
13612
13612
  meta = getAgent("cursor");
13613
13613
  mode = "interactive";
13614
13614
  os;
13615
- constructor(os48) {
13616
- this.os = os48;
13615
+ constructor(os49) {
13616
+ this.os = os49;
13617
13617
  }
13618
13618
  async prepareLaunch() {
13619
13619
  const binary = this.os.findInPath("cursor-agent");
@@ -13759,10 +13759,10 @@ function aiderCredentialLocator() {
13759
13759
  validate: validateNonEmptyCredential
13760
13760
  };
13761
13761
  }
13762
- function aiderLoginLauncher(os48) {
13762
+ function aiderLoginLauncher(os49) {
13763
13763
  return {
13764
13764
  async ensureInstalled() {
13765
- if (os48.findInPath("aider")) return true;
13765
+ if (os49.findInPath("aider")) return true;
13766
13766
  console.error(
13767
13767
  "\n \u2717 aider binary not on PATH.\n Install Aider:\n pip install aider-chat\n then re-run `codeam link aider`.\n"
13768
13768
  );
@@ -13772,7 +13772,7 @@ function aiderLoginLauncher(os48) {
13772
13772
  console.error(
13773
13773
  "\n Aider has no interactive login flow.\n Set ANTHROPIC_API_KEY or OPENAI_API_KEY in your shell,\n or re-run `codeam link aider --api-key=<your-key>`.\n"
13774
13774
  );
13775
- return (0, import_node_child_process10.spawn)(os48.id === "win32" ? "cmd.exe" : "sh", os48.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
13775
+ return (0, import_node_child_process10.spawn)(os49.id === "win32" ? "cmd.exe" : "sh", os49.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
13776
13776
  stdio: "ignore"
13777
13777
  });
13778
13778
  }
@@ -13844,8 +13844,8 @@ var AiderRuntimeStrategy = class {
13844
13844
  meta = getAgent("aider");
13845
13845
  mode = "interactive";
13846
13846
  os;
13847
- constructor(os48) {
13848
- this.os = os48;
13847
+ constructor(os49) {
13848
+ this.os = os49;
13849
13849
  }
13850
13850
  async prepareLaunch() {
13851
13851
  const binary = this.os.findInPath("aider");
@@ -13977,8 +13977,8 @@ function geminiCredentialLocator() {
13977
13977
  function geminiLoginLauncher() {
13978
13978
  return {
13979
13979
  async ensureInstalled() {
13980
- const os48 = createOsStrategy();
13981
- return os48.findInPath("gemini") !== null;
13980
+ const os49 = createOsStrategy();
13981
+ return os49.findInPath("gemini") !== null;
13982
13982
  },
13983
13983
  launch() {
13984
13984
  return (0, import_node_child_process11.spawn)("gemini", ["auth", "login"], { stdio: "inherit" });
@@ -14168,8 +14168,8 @@ var GeminiRuntimeStrategy = class {
14168
14168
  meta = getAgent("gemini");
14169
14169
  mode = "interactive";
14170
14170
  os;
14171
- constructor(os48) {
14172
- this.os = os48;
14171
+ constructor(os49) {
14172
+ this.os = os49;
14173
14173
  }
14174
14174
  async prepareLaunch() {
14175
14175
  const binary = this.os.findInPath("gemini");
@@ -14280,6 +14280,135 @@ var GeminiRuntimeStrategy = class {
14280
14280
  var import_node_child_process12 = require("child_process");
14281
14281
  var import_node_os3 = require("os");
14282
14282
  var import_node_path4 = require("path");
14283
+
14284
+ // src/agents/kimi/history.ts
14285
+ var fs29 = __toESM(require("fs"));
14286
+ var os26 = __toESM(require("os"));
14287
+ var path33 = __toESM(require("path"));
14288
+ var import_node_crypto6 = require("crypto");
14289
+ function kimiHome() {
14290
+ return process.env.KIMI_CODE_HOME || path33.join(os26.homedir(), ".kimi-code");
14291
+ }
14292
+ function workDirKey(cwd) {
14293
+ const hash = (0, import_node_crypto6.createHash)("sha256").update(cwd).digest("hex").slice(0, 12);
14294
+ return `wd_${path33.basename(cwd)}_${hash}`;
14295
+ }
14296
+ function resolveHistoryDir6(cwd) {
14297
+ const dir = path33.join(kimiHome(), "sessions", workDirKey(cwd));
14298
+ if (!fs29.existsSync(dir)) {
14299
+ log.debug("kimi", `resolveHistoryDir \u2014 session bucket not present yet: ${dir}`);
14300
+ return null;
14301
+ }
14302
+ return dir;
14303
+ }
14304
+ var WIRE_REL = path33.join("agents", "main", "wire.jsonl");
14305
+ function resolveHistoryFile5(cwd, sessionId) {
14306
+ const fromIndex = sessionDirFromIndex(sessionId);
14307
+ if (fromIndex) {
14308
+ const p2 = path33.join(fromIndex, WIRE_REL);
14309
+ if (fs29.existsSync(p2)) return p2;
14310
+ }
14311
+ const bucket = path33.join(kimiHome(), "sessions", workDirKey(cwd));
14312
+ const computed = path33.join(bucket, sessionId, WIRE_REL);
14313
+ if (fs29.existsSync(computed)) return computed;
14314
+ const scanned = scanBucketsForSession(sessionId);
14315
+ if (scanned) return scanned;
14316
+ return null;
14317
+ }
14318
+ function sessionDirFromIndex(sessionId) {
14319
+ try {
14320
+ const raw = fs29.readFileSync(path33.join(kimiHome(), "session_index.jsonl"), "utf8");
14321
+ for (const line of raw.split("\n")) {
14322
+ if (!line.includes(sessionId)) continue;
14323
+ try {
14324
+ const rec = JSON.parse(line);
14325
+ if (rec.sessionId === sessionId && typeof rec.sessionDir === "string") {
14326
+ return rec.sessionDir;
14327
+ }
14328
+ } catch {
14329
+ }
14330
+ }
14331
+ } catch {
14332
+ }
14333
+ return null;
14334
+ }
14335
+ function scanBucketsForSession(sessionId) {
14336
+ const sessionsRoot = path33.join(kimiHome(), "sessions");
14337
+ let buckets;
14338
+ try {
14339
+ buckets = fs29.readdirSync(sessionsRoot, { withFileTypes: true });
14340
+ } catch {
14341
+ return null;
14342
+ }
14343
+ for (const b of buckets) {
14344
+ if (!b.isDirectory()) continue;
14345
+ const candidate = path33.join(sessionsRoot, b.name, sessionId, WIRE_REL);
14346
+ if (fs29.existsSync(candidate)) return candidate;
14347
+ }
14348
+ return null;
14349
+ }
14350
+ function joinTextParts(parts) {
14351
+ if (!Array.isArray(parts)) return "";
14352
+ return parts.filter((p2) => p2 && p2.type === "text" && typeof p2.text === "string").map((p2) => p2.text).join("").trim();
14353
+ }
14354
+ function parseHistoryFile6(filePath) {
14355
+ let raw;
14356
+ try {
14357
+ raw = fs29.readFileSync(filePath, "utf8");
14358
+ } catch {
14359
+ return [];
14360
+ }
14361
+ const out2 = [];
14362
+ let idx = 0;
14363
+ let assistantBuf = "";
14364
+ let assistantTime = 0;
14365
+ const flushAssistant = () => {
14366
+ const text = assistantBuf.trim();
14367
+ if (text) {
14368
+ out2.push({
14369
+ id: `kimi:${idx}`,
14370
+ role: "agent",
14371
+ text,
14372
+ timestamp: new Date(assistantTime || 0).toISOString()
14373
+ });
14374
+ idx += 1;
14375
+ }
14376
+ assistantBuf = "";
14377
+ assistantTime = 0;
14378
+ };
14379
+ for (const line of raw.split("\n")) {
14380
+ if (!line.trim()) continue;
14381
+ let rec;
14382
+ try {
14383
+ rec = JSON.parse(line);
14384
+ } catch {
14385
+ continue;
14386
+ }
14387
+ if (rec.type === "turn.prompt") {
14388
+ flushAssistant();
14389
+ const text = joinTextParts(rec.input);
14390
+ if (text) {
14391
+ out2.push({
14392
+ id: `kimi:${idx}`,
14393
+ role: "user",
14394
+ text,
14395
+ timestamp: new Date(rec.time || 0).toISOString()
14396
+ });
14397
+ idx += 1;
14398
+ }
14399
+ } else if (rec.type === "context.append_loop_event" && rec.event?.type === "content.part" && rec.event.part?.type === "text" && typeof rec.event.part.text === "string") {
14400
+ assistantBuf += rec.event.part.text;
14401
+ if (!assistantTime) assistantTime = rec.time || 0;
14402
+ }
14403
+ }
14404
+ flushAssistant();
14405
+ return out2;
14406
+ }
14407
+ function getCurrentUsage5(_historyDir) {
14408
+ return null;
14409
+ }
14410
+
14411
+ // src/agents/kimi/runtime.ts
14283
14412
  var KIMI_CONTEXT_WINDOW = 262144;
14284
14413
  var KIMI_MODELS = [
14285
14414
  { id: "kimi-for-coding", label: "Kimi for Coding", contextWindow: KIMI_CONTEXT_WINDOW }
@@ -14293,8 +14422,8 @@ var KimiRuntimeStrategy = class {
14293
14422
  meta = getAgent("kimi");
14294
14423
  mode = "interactive";
14295
14424
  os;
14296
- constructor(os48) {
14297
- this.os = os48;
14425
+ constructor(os49) {
14426
+ this.os = os49;
14298
14427
  }
14299
14428
  async prepareLaunch() {
14300
14429
  const binary = this.os.findInPath("kimi");
@@ -14306,17 +14435,29 @@ var KimiRuntimeStrategy = class {
14306
14435
  const launch = this.os.buildLaunch(binary, []);
14307
14436
  return { cmd: launch.cmd, args: launch.args };
14308
14437
  }
14309
- resumeLaunchArgs(_sessionId, _opts) {
14310
- return [];
14438
+ /** Re-attach the same conversation on baton hand-back — kimi resumes a session
14439
+ * by id with `kimi -S <id>` (`-S, --session [id]`). */
14440
+ resumeLaunchArgs(sessionId, _opts) {
14441
+ return ["-S", sessionId];
14311
14442
  }
14312
- resolveHistoryDir(_cwd) {
14313
- return null;
14443
+ resolveHistoryDir(cwd) {
14444
+ return resolveHistoryDir6(cwd);
14314
14445
  }
14315
- parseHistoryFile(_filePath) {
14316
- return [];
14446
+ /**
14447
+ * `<KIMI_CODE_HOME>/sessions/wd_<key>/<sessionId>/agents/main/wire.jsonl`.
14448
+ * Implementing this is what lets the baton engage for Kimi
14449
+ * (`runtimeSupportsBaton`), so LOCAL_DRIVE can tail the transcript and Take
14450
+ * Control resumes the SAME conversation over ACP `session/load` — verified
14451
+ * live: `kimi acp` advertises `loadSession:true`.
14452
+ */
14453
+ resolveHistoryFile(cwd, sessionId) {
14454
+ return resolveHistoryFile5(cwd, sessionId);
14317
14455
  }
14318
- getCurrentUsage(_historyDir) {
14319
- return null;
14456
+ parseHistoryFile(filePath) {
14457
+ return parseHistoryFile6(filePath);
14458
+ }
14459
+ getCurrentUsage(historyDir) {
14460
+ return getCurrentUsage5(historyDir);
14320
14461
  }
14321
14462
  async fetchWeeklyUsage() {
14322
14463
  return null;
@@ -14383,19 +14524,19 @@ var KimiRuntimeStrategy = class {
14383
14524
 
14384
14525
  // src/agents/registry.ts
14385
14526
  var runtimeBuilders = {
14386
- claude: (os48) => new ClaudeRuntimeStrategy(os48),
14387
- codex: (os48) => new CodexRuntimeStrategy(os48),
14388
- coderabbit: (os48) => new CoderabbitRuntimeStrategy(os48),
14389
- cursor: (os48) => new CursorRuntimeStrategy(os48),
14390
- aider: (os48) => new AiderRuntimeStrategy(os48),
14391
- gemini: (os48) => new GeminiRuntimeStrategy(os48),
14392
- kimi: (os48) => new KimiRuntimeStrategy(os48)
14527
+ claude: (os49) => new ClaudeRuntimeStrategy(os49),
14528
+ codex: (os49) => new CodexRuntimeStrategy(os49),
14529
+ coderabbit: (os49) => new CoderabbitRuntimeStrategy(os49),
14530
+ cursor: (os49) => new CursorRuntimeStrategy(os49),
14531
+ aider: (os49) => new AiderRuntimeStrategy(os49),
14532
+ gemini: (os49) => new GeminiRuntimeStrategy(os49),
14533
+ kimi: (os49) => new KimiRuntimeStrategy(os49)
14393
14534
  };
14394
14535
  var deployBuilders = {
14395
14536
  claude: () => new ClaudeDeployStrategy(),
14396
14537
  codex: () => new CodexDeployStrategy()
14397
14538
  };
14398
- function createAgentStrategy(agent, os48 = createOsStrategy()) {
14539
+ function createAgentStrategy(agent, os49 = createOsStrategy()) {
14399
14540
  if (!AGENT_REGISTRY[agent]?.enabled) {
14400
14541
  throw new Error(
14401
14542
  `Agent "${agent}" is not supported in this codeam-cli version. Upgrade with 'npm i -g codeam-cli@latest'.`
@@ -14405,10 +14546,10 @@ function createAgentStrategy(agent, os48 = createOsStrategy()) {
14405
14546
  if (!build) {
14406
14547
  throw new Error(`No runtime strategy registered for agent "${agent}"`);
14407
14548
  }
14408
- return build(os48);
14549
+ return build(os49);
14409
14550
  }
14410
- function createInteractiveAgentStrategy(agent, os48 = createOsStrategy()) {
14411
- const s = createAgentStrategy(agent, os48);
14551
+ function createInteractiveAgentStrategy(agent, os49 = createOsStrategy()) {
14552
+ const s = createAgentStrategy(agent, os49);
14412
14553
  if (s.mode !== "interactive") {
14413
14554
  throw new Error(
14414
14555
  `Agent "${agent}" is a batch agent; use createAgentStrategy + .runOneShot for one-shot reviews.`
@@ -14464,7 +14605,7 @@ function parseLinkArgs(args2) {
14464
14605
  if (apiKeyFileArg) {
14465
14606
  const filePath = apiKeyFileArg.slice("--api-key-file=".length);
14466
14607
  try {
14467
- apiKey = fs29.readFileSync(path33.resolve(filePath), "utf8").trim();
14608
+ apiKey = fs30.readFileSync(path34.resolve(filePath), "utf8").trim();
14468
14609
  } catch (err) {
14469
14610
  throw new Error(`Could not read --api-key-file ${filePath}: ${err.message}`);
14470
14611
  }
@@ -14491,9 +14632,9 @@ async function link(args2 = []) {
14491
14632
  await linkDryRunPreflight(ctx);
14492
14633
  return;
14493
14634
  }
14494
- const pluginId = (0, import_node_crypto6.randomUUID)();
14495
- const pollSecret = (0, import_node_crypto6.randomBytes)(32).toString("base64url");
14496
- const pluginSecretHash = (0, import_node_crypto6.createHash)("sha256").update(pollSecret).digest("hex");
14635
+ const pluginId = (0, import_node_crypto7.randomUUID)();
14636
+ const pollSecret = (0, import_node_crypto7.randomBytes)(32).toString("base64url");
14637
+ const pluginSecretHash = (0, import_node_crypto7.createHash)("sha256").update(pollSecret).digest("hex");
14497
14638
  const spin = dist_exports.spinner();
14498
14639
  spin.start("Requesting pairing code...");
14499
14640
  const pairing = await requestCode(pluginId, pluginSecretHash);
@@ -14591,7 +14732,7 @@ async function link(args2 = []) {
14591
14732
  return;
14592
14733
  }
14593
14734
  if (parsed.tokenFile) {
14594
- const credential = fs29.readFileSync(path33.resolve(parsed.tokenFile), "utf8").trim();
14735
+ const credential = fs30.readFileSync(path34.resolve(parsed.tokenFile), "utf8").trim();
14595
14736
  if (!credential) {
14596
14737
  showError(`--token-file ${parsed.tokenFile} is empty.`);
14597
14738
  process.exit(1);
@@ -14809,14 +14950,14 @@ async function linkDryRunPreflight(ctx) {
14809
14950
 
14810
14951
  // src/commands/host-agent.ts
14811
14952
  var import_node_child_process20 = require("child_process");
14812
- var os33 = __toESM(require("os"));
14813
- var fs39 = __toESM(require("fs"));
14814
- var path41 = __toESM(require("path"));
14953
+ var os34 = __toESM(require("os"));
14954
+ var fs40 = __toESM(require("fs"));
14955
+ var path42 = __toESM(require("path"));
14815
14956
 
14816
14957
  // src/commands/host/host-client.ts
14817
- var fs31 = __toESM(require("fs"));
14818
- var os27 = __toESM(require("os"));
14819
- var path34 = __toESM(require("path"));
14958
+ var fs32 = __toESM(require("fs"));
14959
+ var os28 = __toESM(require("os"));
14960
+ var path35 = __toESM(require("path"));
14820
14961
 
14821
14962
  // src/lib/restrict-to-owner.ts
14822
14963
  var import_node_fs5 = __toESM(require("fs"));
@@ -14855,7 +14996,7 @@ function restrictToOwner(filePath) {
14855
14996
  function sampleCpuTimes() {
14856
14997
  let idle = 0;
14857
14998
  let total = 0;
14858
- for (const cpu of os27.cpus()) {
14999
+ for (const cpu of os28.cpus()) {
14859
15000
  const t2 = cpu.times;
14860
15001
  idle += t2.idle;
14861
15002
  total += t2.user + t2.nice + t2.sys + t2.idle + t2.irq;
@@ -14874,8 +15015,8 @@ var MetricsCollector = class {
14874
15015
  const prev = this.prevCpu;
14875
15016
  this.prevCpu = current;
14876
15017
  if (!prev) {
14877
- const cores = os27.cpus().length || 1;
14878
- const proxy = os27.loadavg()[0] / cores * 100;
15018
+ const cores = os28.cpus().length || 1;
15019
+ const proxy = os28.loadavg()[0] / cores * 100;
14879
15020
  return Math.min(100, Math.max(0, Math.round(proxy)));
14880
15021
  }
14881
15022
  const idleDelta = current.idle - prev.idle;
@@ -14888,8 +15029,8 @@ var MetricsCollector = class {
14888
15029
  collect() {
14889
15030
  return {
14890
15031
  cpuPct: this.cpuPct(),
14891
- ramUsedMb: Math.round((os27.totalmem() - os27.freemem()) / 1048576),
14892
- ramTotalMb: Math.round(os27.totalmem() / 1048576),
15032
+ ramUsedMb: Math.round((os28.totalmem() - os28.freemem()) / 1048576),
15033
+ ramTotalMb: Math.round(os28.totalmem() / 1048576),
14893
15034
  latencyMs: this.lastLatencyMs
14894
15035
  };
14895
15036
  }
@@ -14898,19 +15039,19 @@ function apiBase() {
14898
15039
  return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
14899
15040
  }
14900
15041
  function hostIdentityPath() {
14901
- return path34.join(os27.homedir(), ".codeam", "host-agent.json");
15042
+ return path35.join(os28.homedir(), ".codeam", "host-agent.json");
14902
15043
  }
14903
15044
  function collectOsInfo() {
14904
15045
  return {
14905
- distro: os27.platform(),
14906
- arch: os27.arch(),
14907
- kernel: os27.release(),
15046
+ distro: os28.platform(),
15047
+ arch: os28.arch(),
15048
+ kernel: os28.release(),
14908
15049
  nodeVersion: process.versions.node
14909
15050
  };
14910
15051
  }
14911
15052
  function loadHostIdentity() {
14912
15053
  try {
14913
- const raw = fs31.readFileSync(hostIdentityPath(), "utf8");
15054
+ const raw = fs32.readFileSync(hostIdentityPath(), "utf8");
14914
15055
  const parsed = JSON.parse(raw);
14915
15056
  if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
14916
15057
  const p2 = parsed;
@@ -14923,8 +15064,8 @@ function loadHostIdentity() {
14923
15064
  }
14924
15065
  function saveHostIdentity(identity) {
14925
15066
  const file = hostIdentityPath();
14926
- fs31.mkdirSync(path34.dirname(file), { recursive: true, mode: 448 });
14927
- fs31.writeFileSync(file, JSON.stringify(identity, null, 2), {
15067
+ fs32.mkdirSync(path35.dirname(file), { recursive: true, mode: 448 });
15068
+ fs32.writeFileSync(file, JSON.stringify(identity, null, 2), {
14928
15069
  encoding: "utf8",
14929
15070
  mode: 384
14930
15071
  });
@@ -14969,7 +15110,7 @@ function isTerminalEnrollError(err) {
14969
15110
  }
14970
15111
  function deleteHostIdentity() {
14971
15112
  try {
14972
- fs31.rmSync(hostIdentityPath(), { force: true });
15113
+ fs32.rmSync(hostIdentityPath(), { force: true });
14973
15114
  } catch {
14974
15115
  }
14975
15116
  }
@@ -15092,17 +15233,17 @@ async function reportDeployProgress(auth, deployId, step, message, sessionId) {
15092
15233
  }
15093
15234
 
15094
15235
  // src/commands/host/workspace.ts
15095
- var fs32 = __toESM(require("fs"));
15096
- var os28 = __toESM(require("os"));
15097
- var path35 = __toESM(require("path"));
15236
+ var fs33 = __toESM(require("fs"));
15237
+ var os29 = __toESM(require("os"));
15238
+ var path36 = __toESM(require("path"));
15098
15239
  var import_node_child_process14 = require("child_process");
15099
15240
  var import_node_util4 = require("util");
15100
15241
  var execFileP4 = (0, import_node_util4.promisify)(import_node_child_process14.execFile);
15101
15242
  function isAbsolutePathTarget(target) {
15102
- return path35.isAbsolute(target);
15243
+ return path36.isAbsolute(target);
15103
15244
  }
15104
15245
  function selfHostedWorkspaceRoot() {
15105
- return path35.join(os28.homedir(), ".codeam", "self-hosted");
15246
+ return path36.join(os29.homedir(), ".codeam", "self-hosted");
15106
15247
  }
15107
15248
  function nonInteractiveGitEnv() {
15108
15249
  return {
@@ -15155,13 +15296,13 @@ async function fetchGithubIdentity(token) {
15155
15296
  async function configureGitCredentials(dest, repoRef, cloneToken) {
15156
15297
  const gh = githubOwnerRepo(repoRef.trim());
15157
15298
  if (!gh || !cloneToken) return;
15158
- const credFile = path35.join(dest, ".git", "codeam-credentials");
15159
- fs32.writeFileSync(credFile, `https://x-access-token:${cloneToken}@github.com
15299
+ const credFile = path36.join(dest, ".git", "codeam-credentials");
15300
+ fs33.writeFileSync(credFile, `https://x-access-token:${cloneToken}@github.com
15160
15301
  `, { mode: 384 });
15161
15302
  restrictToOwner(credFile);
15162
15303
  const env = nonInteractiveGitEnv();
15163
15304
  const git2 = (args2) => execFileP4("git", ["-C", dest, ...args2], { timeout: 3e4, env });
15164
- const credFilePosix = credFile.split(path35.sep).join("/");
15305
+ const credFilePosix = credFile.split(path36.sep).join("/");
15165
15306
  await git2(["config", "--local", "--replace-all", "credential.helper", ""]).catch(() => {
15166
15307
  });
15167
15308
  await git2([
@@ -15197,17 +15338,17 @@ function maskToken(text, cloneToken) {
15197
15338
  }
15198
15339
  async function prepareWorkspace(repoOrPath, deployId, cloneToken) {
15199
15340
  if (isAbsolutePathTarget(repoOrPath)) {
15200
- if (!fs32.existsSync(repoOrPath)) {
15341
+ if (!fs33.existsSync(repoOrPath)) {
15201
15342
  throw new Error(`deploy target path does not exist: ${repoOrPath}`);
15202
15343
  }
15203
15344
  return repoOrPath;
15204
15345
  }
15205
- const dest = path35.join(selfHostedWorkspaceRoot(), deployId);
15206
- if (fs32.existsSync(path35.join(dest, ".git"))) {
15346
+ const dest = path36.join(selfHostedWorkspaceRoot(), deployId);
15347
+ if (fs33.existsSync(path36.join(dest, ".git"))) {
15207
15348
  if (cloneToken) await configureGitCredentials(dest, repoOrPath, cloneToken);
15208
15349
  return dest;
15209
15350
  }
15210
- fs32.mkdirSync(selfHostedWorkspaceRoot(), { recursive: true, mode: 448 });
15351
+ fs33.mkdirSync(selfHostedWorkspaceRoot(), { recursive: true, mode: 448 });
15211
15352
  const cloneUrl = repoCloneUrl(repoOrPath, cloneToken);
15212
15353
  try {
15213
15354
  await execFileP4("git", ["clone", "--depth", "1", cloneUrl, dest], {
@@ -15224,9 +15365,9 @@ async function prepareWorkspace(repoOrPath, deployId, cloneToken) {
15224
15365
  }
15225
15366
 
15226
15367
  // src/commands/host/agent-provisioning.ts
15227
- var fs33 = __toESM(require("fs"));
15228
- var os29 = __toESM(require("os"));
15229
- var path36 = __toESM(require("path"));
15368
+ var fs34 = __toESM(require("fs"));
15369
+ var os30 = __toESM(require("os"));
15370
+ var path37 = __toESM(require("path"));
15230
15371
  var PUBLIC_TO_INTERNAL_AGENT = {
15231
15372
  claude_code: "claude",
15232
15373
  claude: "claude",
@@ -15242,22 +15383,22 @@ function toInternalAgentId(publicAgentId) {
15242
15383
  return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
15243
15384
  }
15244
15385
  function ensureDir(dir) {
15245
- fs33.mkdirSync(dir, { recursive: true, mode: 448 });
15386
+ fs34.mkdirSync(dir, { recursive: true, mode: 448 });
15246
15387
  }
15247
15388
  function writeFile0600(filePath, contents) {
15248
- ensureDir(path36.dirname(filePath));
15249
- fs33.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
15389
+ ensureDir(path37.dirname(filePath));
15390
+ fs34.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
15250
15391
  restrictToOwner(filePath);
15251
15392
  }
15252
15393
  function rmIfExists(filePath) {
15253
15394
  try {
15254
- fs33.rmSync(filePath, { force: true });
15395
+ fs34.rmSync(filePath, { force: true });
15255
15396
  } catch {
15256
15397
  }
15257
15398
  }
15258
15399
  var claudeProvisioner = {
15259
15400
  write(auth, home) {
15260
- const credentialsJson = path36.join(home, ".claude", ".credentials.json");
15401
+ const credentialsJson = path37.join(home, ".claude", ".credentials.json");
15261
15402
  if (auth.kind === "api_key") {
15262
15403
  rmIfExists(credentialsJson);
15263
15404
  return { ANTHROPIC_API_KEY: auth.value };
@@ -15269,8 +15410,8 @@ var claudeProvisioner = {
15269
15410
  } else {
15270
15411
  rmIfExists(credentialsJson);
15271
15412
  }
15272
- const claudeJson = path36.join(home, ".claude.json");
15273
- if (!fs33.existsSync(claudeJson)) {
15413
+ const claudeJson = path37.join(home, ".claude.json");
15414
+ if (!fs34.existsSync(claudeJson)) {
15274
15415
  writeFile0600(
15275
15416
  claudeJson,
15276
15417
  JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
@@ -15281,7 +15422,7 @@ var claudeProvisioner = {
15281
15422
  };
15282
15423
  var codexProvisioner = {
15283
15424
  write(auth, home) {
15284
- const authJson = path36.join(home, ".codex", "auth.json");
15425
+ const authJson = path37.join(home, ".codex", "auth.json");
15285
15426
  if (auth.kind === "api_key") {
15286
15427
  rmIfExists(authJson);
15287
15428
  return { OPENAI_API_KEY: auth.value };
@@ -15292,8 +15433,8 @@ var codexProvisioner = {
15292
15433
  };
15293
15434
  var geminiProvisioner = {
15294
15435
  write(auth, home) {
15295
- const settingsJson = path36.join(home, ".gemini", "settings.json");
15296
- const oauthCreds = path36.join(home, ".gemini", "oauth_creds.json");
15436
+ const settingsJson = path37.join(home, ".gemini", "settings.json");
15437
+ const oauthCreds = path37.join(home, ".gemini", "oauth_creds.json");
15297
15438
  if (auth.kind === "api_key") {
15298
15439
  rmIfExists(oauthCreds);
15299
15440
  writeFile0600(settingsJson, '{"security":{"auth":{"selectedType":"gemini-api-key"}}}');
@@ -15306,7 +15447,7 @@ var geminiProvisioner = {
15306
15447
  };
15307
15448
  var cursorProvisioner = {
15308
15449
  write(auth, home) {
15309
- const authJson = path36.join(home, ".config", "cursor", "auth.json");
15450
+ const authJson = path37.join(home, ".config", "cursor", "auth.json");
15310
15451
  if (auth.kind === "api_key") {
15311
15452
  rmIfExists(authJson);
15312
15453
  return { CURSOR_API_KEY: auth.value };
@@ -15331,12 +15472,15 @@ var cursorProvisioner = {
15331
15472
  };
15332
15473
  var kimiProvisioner = {
15333
15474
  write(auth, home) {
15334
- const credentialsFile = path36.join(home, ".kimi-code", "credentials", "kimi.json");
15475
+ const credentialsFiles = [
15476
+ path37.join(home, ".kimi", "credentials", "kimi-code.json"),
15477
+ path37.join(home, ".kimi-code", "credentials", "kimi-code.json")
15478
+ ];
15335
15479
  if (auth.kind === "api_key") {
15336
- rmIfExists(credentialsFile);
15480
+ credentialsFiles.forEach(rmIfExists);
15337
15481
  return { KIMI_API_KEY: auth.value };
15338
15482
  }
15339
- writeFile0600(credentialsFile, auth.value);
15483
+ credentialsFiles.forEach((f) => writeFile0600(f, auth.value));
15340
15484
  return {};
15341
15485
  }
15342
15486
  };
@@ -15355,7 +15499,7 @@ var UnsupportedAgentError = class extends Error {
15355
15499
  this.agentId = agentId;
15356
15500
  }
15357
15501
  };
15358
- function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os29.homedir()) {
15502
+ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os30.homedir()) {
15359
15503
  const internal = toInternalAgentId(publicAgentId);
15360
15504
  if (!internal) throw new UnsupportedAgentError(publicAgentId);
15361
15505
  const provisioner = PROVISIONERS[internal];
@@ -15365,11 +15509,11 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os29.homedir(
15365
15509
 
15366
15510
  // src/commands/host/git-tooling.ts
15367
15511
  var import_node_child_process15 = require("child_process");
15368
- var fs34 = __toESM(require("fs"));
15369
- var os30 = __toESM(require("os"));
15370
- var path37 = __toESM(require("path"));
15512
+ var fs35 = __toESM(require("fs"));
15513
+ var os31 = __toESM(require("os"));
15514
+ var path38 = __toESM(require("path"));
15371
15515
  function codeamBinDir() {
15372
- return process.env.CODEAM_BIN_DIR ?? path37.join(os30.homedir(), ".codeam", "bin");
15516
+ return process.env.CODEAM_BIN_DIR ?? path38.join(os31.homedir(), ".codeam", "bin");
15373
15517
  }
15374
15518
  var FALLBACK_GH_VERSION = "2.62.0";
15375
15519
  var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
@@ -15401,7 +15545,7 @@ async function download(url, dest) {
15401
15545
  const res = await fetch(url, { headers: { "User-Agent": "codeam-cli" } });
15402
15546
  if (!res.ok || !res.body) return false;
15403
15547
  const buf = Buffer.from(await res.arrayBuffer());
15404
- fs34.writeFileSync(dest, buf);
15548
+ fs35.writeFileSync(dest, buf);
15405
15549
  return true;
15406
15550
  } catch {
15407
15551
  return false;
@@ -15424,8 +15568,8 @@ async function ensureGhCli(runner, token, deps = {}) {
15424
15568
  const version3 = await resolveVersionFn(token);
15425
15569
  const asset = `gh_${version3}_${osToken}_${arch2}`;
15426
15570
  const url = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
15427
- const tmpRoot = fs34.mkdtempSync(path37.join(os30.tmpdir(), "codeam-gh-"));
15428
- const archive = path37.join(tmpRoot, `${asset}.${ext}`);
15571
+ const tmpRoot = fs35.mkdtempSync(path38.join(os31.tmpdir(), "codeam-gh-"));
15572
+ const archive = path38.join(tmpRoot, `${asset}.${ext}`);
15429
15573
  if (!await downloadFn(url, archive)) {
15430
15574
  log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
15431
15575
  return null;
@@ -15435,16 +15579,16 @@ async function ensureGhCli(runner, token, deps = {}) {
15435
15579
  log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
15436
15580
  return null;
15437
15581
  }
15438
- const extractedBin = path37.join(tmpRoot, asset, "bin", binaryName);
15439
- if (!fs34.existsSync(extractedBin)) {
15582
+ const extractedBin = path38.join(tmpRoot, asset, "bin", binaryName);
15583
+ if (!fs35.existsSync(extractedBin)) {
15440
15584
  log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
15441
15585
  return null;
15442
15586
  }
15443
15587
  const binDir = codeamBinDir();
15444
- fs34.mkdirSync(binDir, { recursive: true });
15445
- const target = path37.join(binDir, binaryName);
15446
- fs34.copyFileSync(extractedBin, target);
15447
- fs34.chmodSync(target, 493);
15588
+ fs35.mkdirSync(binDir, { recursive: true });
15589
+ const target = path38.join(binDir, binaryName);
15590
+ fs35.copyFileSync(extractedBin, target);
15591
+ fs35.chmodSync(target, 493);
15448
15592
  log.info("host-agent", `gh installed to ${target} (v${version3})`);
15449
15593
  return target;
15450
15594
  } catch (e) {
@@ -15931,23 +16075,23 @@ async function ensureModernPython(runner) {
15931
16075
  }
15932
16076
 
15933
16077
  // src/commands/host/headroom-bootstrap.ts
15934
- var fs36 = __toESM(require("fs"));
15935
- var path39 = __toESM(require("path"));
16078
+ var fs37 = __toESM(require("fs"));
16079
+ var path40 = __toESM(require("path"));
15936
16080
 
15937
16081
  // src/commands/host/headroom-config.ts
15938
- var fs35 = __toESM(require("fs"));
15939
- var os31 = __toESM(require("os"));
15940
- var path38 = __toESM(require("path"));
16082
+ var fs36 = __toESM(require("fs"));
16083
+ var os32 = __toESM(require("os"));
16084
+ var path39 = __toESM(require("path"));
15941
16085
  function headroomConfigPath() {
15942
- return path38.join(os31.homedir(), ".codeam", "headroom-config.json");
16086
+ return path39.join(os32.homedir(), ".codeam", "headroom-config.json");
15943
16087
  }
15944
16088
  function persistHeadroomConfig(config) {
15945
16089
  try {
15946
16090
  const file = headroomConfigPath();
15947
- fs35.mkdirSync(path38.dirname(file), { recursive: true, mode: 448 });
16091
+ fs36.mkdirSync(path39.dirname(file), { recursive: true, mode: 448 });
15948
16092
  const tmp = `${file}.tmp-${process.pid}`;
15949
- fs35.writeFileSync(tmp, JSON.stringify(config, null, 2), { encoding: "utf8", mode: 384 });
15950
- fs35.renameSync(tmp, file);
16093
+ fs36.writeFileSync(tmp, JSON.stringify(config, null, 2), { encoding: "utf8", mode: 384 });
16094
+ fs36.renameSync(tmp, file);
15951
16095
  restrictToOwner(file);
15952
16096
  } catch (err) {
15953
16097
  log.warn(
@@ -15957,21 +16101,21 @@ function persistHeadroomConfig(config) {
15957
16101
  }
15958
16102
  }
15959
16103
  function agentSettingsPath(kind) {
15960
- const home = os31.homedir();
15961
- if (kind === "claude") return path38.join(home, ".claude", "settings.json");
15962
- if (kind === "codex") return path38.join(home, ".codex", "auth.json");
15963
- if (kind === "copilot") return path38.join(home, ".config", "github-copilot", "hosts.json");
16104
+ const home = os32.homedir();
16105
+ if (kind === "claude") return path39.join(home, ".claude", "settings.json");
16106
+ if (kind === "codex") return path39.join(home, ".codex", "auth.json");
16107
+ if (kind === "copilot") return path39.join(home, ".config", "github-copilot", "hosts.json");
15964
16108
  return null;
15965
16109
  }
15966
16110
  function backupAgentHeadroomConfig(kind) {
15967
16111
  const src = agentSettingsPath(kind);
15968
16112
  if (!src) return;
15969
16113
  try {
15970
- if (!fs35.existsSync(src)) return;
15971
- const dest = path38.join(os31.homedir(), ".codeam", `headroom-backup-${kind}.json`);
15972
- fs35.mkdirSync(path38.dirname(dest), { recursive: true, mode: 448 });
15973
- fs35.copyFileSync(src, dest);
15974
- fs35.chmodSync(dest, 384);
16114
+ if (!fs36.existsSync(src)) return;
16115
+ const dest = path39.join(os32.homedir(), ".codeam", `headroom-backup-${kind}.json`);
16116
+ fs36.mkdirSync(path39.dirname(dest), { recursive: true, mode: 448 });
16117
+ fs36.copyFileSync(src, dest);
16118
+ fs36.chmodSync(dest, 384);
15975
16119
  log.info("host-agent", `headroom config backup: ${src} \u2192 ${dest}`);
15976
16120
  } catch (err) {
15977
16121
  log.warn(
@@ -15983,12 +16127,12 @@ function backupAgentHeadroomConfig(kind) {
15983
16127
  function restoreAgentHeadroomConfig(kind) {
15984
16128
  const dest = agentSettingsPath(kind);
15985
16129
  if (!dest) return false;
15986
- const src = path38.join(os31.homedir(), ".codeam", `headroom-backup-${kind}.json`);
15987
- if (!fs35.existsSync(src)) return false;
16130
+ const src = path39.join(os32.homedir(), ".codeam", `headroom-backup-${kind}.json`);
16131
+ if (!fs36.existsSync(src)) return false;
15988
16132
  try {
15989
- fs35.mkdirSync(path38.dirname(dest), { recursive: true, mode: 448 });
15990
- fs35.copyFileSync(src, dest);
15991
- fs35.chmodSync(dest, 384);
16133
+ fs36.mkdirSync(path39.dirname(dest), { recursive: true, mode: 448 });
16134
+ fs36.copyFileSync(src, dest);
16135
+ fs36.chmodSync(dest, 384);
15992
16136
  log.info("host-agent", `headroom config restored: ${src} \u2192 ${dest}`);
15993
16137
  return true;
15994
16138
  } catch (err) {
@@ -16001,7 +16145,7 @@ function restoreAgentHeadroomConfig(kind) {
16001
16145
  }
16002
16146
  function readHeadroomChildEnv() {
16003
16147
  try {
16004
- const raw = fs35.readFileSync(headroomConfigPath(), "utf8");
16148
+ const raw = fs36.readFileSync(headroomConfigPath(), "utf8");
16005
16149
  const parsed = JSON.parse(raw);
16006
16150
  if (typeof parsed !== "object" || parsed === null) return {};
16007
16151
  const o = parsed;
@@ -16037,37 +16181,37 @@ function bundledClaudeBinDir() {
16037
16181
  const roots = /* @__PURE__ */ new Set();
16038
16182
  let dir = __dirname;
16039
16183
  for (let i = 0; i < 6; i++) {
16040
- roots.add(path39.join(dir, "node_modules"));
16041
- const parent = path39.dirname(dir);
16184
+ roots.add(path40.join(dir, "node_modules"));
16185
+ const parent = path40.dirname(dir);
16042
16186
  if (parent === dir) break;
16043
16187
  dir = parent;
16044
16188
  }
16045
16189
  try {
16046
16190
  const main2 = require.resolve("@anthropic-ai/claude-agent-sdk");
16047
- const marker = `${path39.sep}@anthropic-ai${path39.sep}`;
16191
+ const marker = `${path40.sep}@anthropic-ai${path40.sep}`;
16048
16192
  const idx = main2.lastIndexOf(marker);
16049
16193
  if (idx !== -1) roots.add(main2.slice(0, idx));
16050
16194
  } catch {
16051
16195
  }
16052
16196
  for (const nm of roots) {
16053
- const atAnthropic = path39.join(nm, "@anthropic-ai");
16197
+ const atAnthropic = path40.join(nm, "@anthropic-ai");
16054
16198
  let entries;
16055
16199
  try {
16056
- entries = fs36.readdirSync(atAnthropic);
16200
+ entries = fs37.readdirSync(atAnthropic);
16057
16201
  } catch {
16058
16202
  continue;
16059
16203
  }
16060
16204
  for (const entry of entries) {
16061
16205
  if (!entry.startsWith("claude-agent-sdk-")) continue;
16062
- const bin = path39.join(atAnthropic, entry, "claude");
16063
- if (fs36.existsSync(bin)) return path39.dirname(bin);
16206
+ const bin = path40.join(atAnthropic, entry, "claude");
16207
+ if (fs37.existsSync(bin)) return path40.dirname(bin);
16064
16208
  }
16065
16209
  }
16066
16210
  return null;
16067
16211
  }
16068
16212
  async function getFreeDiskBytes(dir) {
16069
16213
  try {
16070
- const s = await fs36.promises.statfs(dir);
16214
+ const s = await fs37.promises.statfs(dir);
16071
16215
  return s.bsize * s.bavail;
16072
16216
  } catch {
16073
16217
  return null;
@@ -16129,7 +16273,7 @@ async function setupHeadroomForSelfHosted(agent, runner = defaultHeadroomRunner,
16129
16273
  if (initKind === "claude") {
16130
16274
  const claudeDir = bundledClaudeBinDir();
16131
16275
  if (claudeDir) {
16132
- initEnv.PATH = `${claudeDir}${path39.delimiter}${process.env["PATH"] ?? ""}`;
16276
+ initEnv.PATH = `${claudeDir}${path40.delimiter}${process.env["PATH"] ?? ""}`;
16133
16277
  log.info("host-agent", `headroom init: bundled claude on PATH (${claudeDir})`);
16134
16278
  } else {
16135
16279
  log.warn("host-agent", "headroom init: bundled claude binary not found \u2014 init may fail");
@@ -16164,9 +16308,9 @@ async function setupHeadroomForSelfHosted(agent, runner = defaultHeadroomRunner,
16164
16308
  var import_node_child_process18 = require("child_process");
16165
16309
 
16166
16310
  // src/lib/updateNotifier.ts
16167
- var fs37 = __toESM(require("fs"));
16168
- var os32 = __toESM(require("os"));
16169
- var path40 = __toESM(require("path"));
16311
+ var fs38 = __toESM(require("fs"));
16312
+ var os33 = __toESM(require("os"));
16313
+ var path41 = __toESM(require("path"));
16170
16314
  var https6 = __toESM(require("https"));
16171
16315
  var import_node_child_process17 = require("child_process");
16172
16316
  var import_picocolors3 = __toESM(require("picocolors"));
@@ -16175,12 +16319,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
16175
16319
  var TTL_MS = 24 * 60 * 60 * 1e3;
16176
16320
  var REQUEST_TIMEOUT_MS = 1500;
16177
16321
  function cachePath() {
16178
- const dir = path40.join(os32.homedir(), ".codeam");
16179
- return path40.join(dir, "update-check.json");
16322
+ const dir = path41.join(os33.homedir(), ".codeam");
16323
+ return path41.join(dir, "update-check.json");
16180
16324
  }
16181
16325
  function readCache() {
16182
16326
  try {
16183
- const raw = fs37.readFileSync(cachePath(), "utf8");
16327
+ const raw = fs38.readFileSync(cachePath(), "utf8");
16184
16328
  const parsed = JSON.parse(raw);
16185
16329
  if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
16186
16330
  return parsed;
@@ -16191,10 +16335,10 @@ function readCache() {
16191
16335
  function writeCache(cache) {
16192
16336
  try {
16193
16337
  const file = cachePath();
16194
- fs37.mkdirSync(path40.dirname(file), { recursive: true });
16338
+ fs38.mkdirSync(path41.dirname(file), { recursive: true });
16195
16339
  const tmp = `${file}.${process.pid}.tmp`;
16196
- fs37.writeFileSync(tmp, JSON.stringify(cache));
16197
- fs37.renameSync(tmp, file);
16340
+ fs38.writeFileSync(tmp, JSON.stringify(cache));
16341
+ fs38.renameSync(tmp, file);
16198
16342
  } catch {
16199
16343
  }
16200
16344
  }
@@ -16268,8 +16412,8 @@ function isLinkedInstall() {
16268
16412
  timeout: 2e3
16269
16413
  }).trim();
16270
16414
  if (!root) return false;
16271
- const pkgPath = path40.join(root, PKG_NAME);
16272
- return fs37.lstatSync(pkgPath).isSymbolicLink();
16415
+ const pkgPath = path41.join(root, PKG_NAME);
16416
+ return fs38.lstatSync(pkgPath).isSymbolicLink();
16273
16417
  } catch {
16274
16418
  return false;
16275
16419
  }
@@ -16305,7 +16449,7 @@ function maybeAutoUpdate(currentVersion, latest) {
16305
16449
  return;
16306
16450
  }
16307
16451
  try {
16308
- fs37.unlinkSync(cachePath());
16452
+ fs38.unlinkSync(cachePath());
16309
16453
  } catch {
16310
16454
  }
16311
16455
  process.stderr.write(` ${import_picocolors3.default.green("\u2713")} Updated. Resuming session...
@@ -16321,7 +16465,7 @@ async function autoUpgradeBeforeCriticalCommand() {
16321
16465
  if (process.env.NODE_ENV === "test") return;
16322
16466
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
16323
16467
  if (process.env.CI) return;
16324
- const current = true ? "2.60.14" : null;
16468
+ const current = true ? "2.60.16" : null;
16325
16469
  if (!current) return;
16326
16470
  const cache = readCache();
16327
16471
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -16338,7 +16482,7 @@ function checkForUpdates() {
16338
16482
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
16339
16483
  if (process.env.CI) return;
16340
16484
  if (!process.stdout.isTTY) return;
16341
- const current = true ? "2.60.14" : null;
16485
+ const current = true ? "2.60.16" : null;
16342
16486
  if (!current) return;
16343
16487
  const cache = readCache();
16344
16488
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -16358,7 +16502,7 @@ var SELF_UPDATE_INTERVAL_MS = 60 * 60 * 1e3;
16358
16502
  var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
16359
16503
  var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
16360
16504
  function currentCliVersion() {
16361
- return true ? "2.60.14" : null;
16505
+ return true ? "2.60.16" : null;
16362
16506
  }
16363
16507
  function runCmd(cmd, args2, timeoutMs) {
16364
16508
  return new Promise((resolve7) => {
@@ -16425,7 +16569,7 @@ async function runSelfUpdate() {
16425
16569
 
16426
16570
  // src/commands/host/teardown.ts
16427
16571
  var import_node_child_process19 = require("child_process");
16428
- var fs38 = __toESM(require("fs"));
16572
+ var fs39 = __toESM(require("fs"));
16429
16573
  var defaultDisableService = () => {
16430
16574
  try {
16431
16575
  (0, import_node_child_process19.execFileSync)("systemctl", ["disable", "--now", "codeam-host-agent"], { stdio: "ignore" });
@@ -16434,7 +16578,7 @@ var defaultDisableService = () => {
16434
16578
  };
16435
16579
  var defaultTeardownHeadroom = () => {
16436
16580
  try {
16437
- const kind = JSON.parse(fs38.readFileSync(headroomConfigPath(), "utf8")).agent;
16581
+ const kind = JSON.parse(fs39.readFileSync(headroomConfigPath(), "utf8")).agent;
16438
16582
  if (kind) {
16439
16583
  (0, import_node_child_process19.execFileSync)("headroom", ["unwrap", kind], { stdio: "ignore", timeout: 15e3 });
16440
16584
  }
@@ -16502,8 +16646,8 @@ function maybeResumeLocalHeadroomReporter(ctx) {
16502
16646
  if (process.env["HEADROOM_ENABLED"] === "1") return null;
16503
16647
  try {
16504
16648
  const file = headroomConfigPath();
16505
- if (!fs39.existsSync(file)) return null;
16506
- const cfg = JSON.parse(fs39.readFileSync(file, "utf8"));
16649
+ if (!fs40.existsSync(file)) return null;
16650
+ const cfg = JSON.parse(fs40.readFileSync(file, "utf8"));
16507
16651
  if (!cfg?.enabled) return null;
16508
16652
  const agent = cfg.agent ?? "claude";
16509
16653
  const ingestUrl = `${resolveApiBaseUrl()}/api/sessions/${ctx.sessionId}/headroom-savings`;
@@ -16908,9 +17052,9 @@ var HostAgentSupervisor = class {
16908
17052
  API_TIMEOUT_MS: "3000000",
16909
17053
  CODEAM_AUTO_TOKEN: payload.autoPairToken
16910
17054
  };
16911
- const houseConfigDir = path41.join(os33.homedir(), ".codeam", "house-claude");
17055
+ const houseConfigDir = path42.join(os34.homedir(), ".codeam", "house-claude");
16912
17056
  try {
16913
- fs39.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
17057
+ fs40.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
16914
17058
  } catch {
16915
17059
  }
16916
17060
  childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
@@ -16928,14 +17072,14 @@ var HostAgentSupervisor = class {
16928
17072
  report("installing", "installing agent CLI");
16929
17073
  await this.runAgentInstall(payload.agentInstallScript);
16930
17074
  }
16931
- const home = process.env.HOME || os33.homedir();
17075
+ const home = process.env.HOME || os34.homedir();
16932
17076
  childEnv.PATH = `${home}/.local/bin:${process.env.PATH ?? ""}`;
16933
17077
  if (payload.cloneToken) {
16934
17078
  try {
16935
17079
  report("preparing", "configuring git tooling");
16936
17080
  const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
16937
17081
  if (ghCmd) {
16938
- childEnv.PATH = `${codeamBinDir()}${path41.delimiter}${childEnv.PATH}`;
17082
+ childEnv.PATH = `${codeamBinDir()}${path42.delimiter}${childEnv.PATH}`;
16939
17083
  await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
16940
17084
  }
16941
17085
  } catch (e) {
@@ -16951,7 +17095,7 @@ var HostAgentSupervisor = class {
16951
17095
  }
16952
17096
  if (payload.headroomEnabled && payload.headroomAgent && payload.headroomSavingsIngestUrl && isHeadroomSupportedAgent(payload.headroomAgent)) {
16953
17097
  report("headroom", "setting up Headroom proxy");
16954
- const freeBytes = await this.getFreeDisk(os33.homedir());
17098
+ const freeBytes = await this.getFreeDisk(os34.homedir());
16955
17099
  const alreadyInstalled = this.isHeadroomInstalled();
16956
17100
  if (!alreadyInstalled && freeBytes !== null && freeBytes < HEADROOM_MIN_FREE_DISK_BYTES) {
16957
17101
  const freeGb = (freeBytes / 1e9).toFixed(1);
@@ -17073,7 +17217,7 @@ var HostAgentSupervisor = class {
17073
17217
  */
17074
17218
  runAgentInstall(script) {
17075
17219
  return new Promise((resolve7) => {
17076
- const home = process.env.HOME || os33.homedir();
17220
+ const home = process.env.HOME || os34.homedir();
17077
17221
  const child = (0, import_node_child_process20.spawn)("sh", ["-c", script], {
17078
17222
  env: { ...process.env, HOME: home },
17079
17223
  stdio: ["ignore", "pipe", "pipe"]
@@ -17257,9 +17401,9 @@ async function configureHeadroom(action, ctx, deps) {
17257
17401
  }
17258
17402
 
17259
17403
  // src/services/headroom/budget-relaunch.ts
17260
- var fs40 = __toESM(require("fs"));
17261
- var os34 = __toESM(require("os"));
17262
- var path42 = __toESM(require("path"));
17404
+ var fs41 = __toESM(require("fs"));
17405
+ var os35 = __toESM(require("os"));
17406
+ var path43 = __toESM(require("path"));
17263
17407
  var import_child_process13 = require("child_process");
17264
17408
  function amendDeploymentManifestBudget(manifest, budget) {
17265
17409
  const rawArgs = manifest.proxy_args ?? [];
@@ -17293,7 +17437,7 @@ function amendDeploymentManifestBudget(manifest, budget) {
17293
17437
  return { ...manifest, proxy_args: newArgs, base_env: newEnv };
17294
17438
  }
17295
17439
  function findHeadroomDeployments(homeDir2, deps) {
17296
- const deployDir = path42.join(homeDir2, ".headroom", "deploy");
17440
+ const deployDir = path43.join(homeDir2, ".headroom", "deploy");
17297
17441
  let profiles;
17298
17442
  try {
17299
17443
  profiles = deps.readDir(deployDir);
@@ -17302,7 +17446,7 @@ function findHeadroomDeployments(homeDir2, deps) {
17302
17446
  }
17303
17447
  const results = [];
17304
17448
  for (const profile of profiles) {
17305
- const manifestPath = path42.join(deployDir, profile, "manifest.json");
17449
+ const manifestPath = path43.join(deployDir, profile, "manifest.json");
17306
17450
  let raw;
17307
17451
  try {
17308
17452
  raw = deps.readJson(manifestPath);
@@ -17334,8 +17478,8 @@ async function applyBudgetToHeadroom(budget, deps) {
17334
17478
  }
17335
17479
  function writeManifestReal(manifestPath, manifest) {
17336
17480
  const tmp = manifestPath + ".codeam.tmp";
17337
- fs40.writeFileSync(tmp, JSON.stringify(manifest, null, 2) + "\n", { mode: 384 });
17338
- fs40.renameSync(tmp, manifestPath);
17481
+ fs41.writeFileSync(tmp, JSON.stringify(manifest, null, 2) + "\n", { mode: 384 });
17482
+ fs41.renameSync(tmp, manifestPath);
17339
17483
  }
17340
17484
  function restartDeploymentReal(profile) {
17341
17485
  try {
@@ -17365,11 +17509,11 @@ function spawnProxyReal2(_budget) {
17365
17509
  });
17366
17510
  }
17367
17511
  function makeRealApplyBudgetDeps() {
17368
- const homeDir2 = os34.homedir();
17512
+ const homeDir2 = os35.homedir();
17369
17513
  return {
17370
17514
  findDeployments: () => findHeadroomDeployments(homeDir2, {
17371
- readDir: (dir) => fs40.readdirSync(dir),
17372
- readJson: (filePath) => JSON.parse(fs40.readFileSync(filePath, "utf8"))
17515
+ readDir: (dir) => fs41.readdirSync(dir),
17516
+ readJson: (filePath) => JSON.parse(fs41.readFileSync(filePath, "utf8"))
17373
17517
  }),
17374
17518
  writeManifest: writeManifestReal,
17375
17519
  restartDeployment: restartDeploymentReal,
@@ -18049,8 +18193,8 @@ function activePreviewSessionIds() {
18049
18193
 
18050
18194
  // src/services/preview/start-orchestrator.ts
18051
18195
  var import_child_process17 = require("child_process");
18052
- var fs45 = __toESM(require("fs"));
18053
- var path47 = __toESM(require("path"));
18196
+ var fs46 = __toESM(require("fs"));
18197
+ var path48 = __toESM(require("path"));
18054
18198
  var import_which2 = __toESM(require("which"));
18055
18199
  var INSTALL_TIMEOUT_MS = 5 * 6e4;
18056
18200
  var SETUP_TIMEOUT_MS = 2 * 6e4;
@@ -18117,8 +18261,8 @@ function normalizeDetectionForSpawn(detection, cwd) {
18117
18261
  if (args2.length === 0) return detection;
18118
18262
  const binName = args2[0];
18119
18263
  if (binName.startsWith("-")) return detection;
18120
- const binPath = path47.join(cwd, "node_modules", ".bin", binName);
18121
- if (!fs45.existsSync(binPath)) return detection;
18264
+ const binPath = path48.join(cwd, "node_modules", ".bin", binName);
18265
+ if (!fs46.existsSync(binPath)) return detection;
18122
18266
  return {
18123
18267
  ...detection,
18124
18268
  command: binPath,
@@ -18468,9 +18612,9 @@ async function establishTunnel(ctx, dev) {
18468
18612
 
18469
18613
  // src/beads/bd-adapter.ts
18470
18614
  var import_child_process18 = require("child_process");
18471
- var fs46 = __toESM(require("fs"));
18472
- var os36 = __toESM(require("os"));
18473
- var path48 = __toESM(require("path"));
18615
+ var fs47 = __toESM(require("fs"));
18616
+ var os37 = __toESM(require("os"));
18617
+ var path49 = __toESM(require("path"));
18474
18618
  var BD_PACKAGE = "@beads/bd";
18475
18619
  function resolveBundledBdBinary() {
18476
18620
  return _resolveSeam.resolveBundled();
@@ -18482,11 +18626,11 @@ function _defaultResolveBundled() {
18482
18626
  } catch {
18483
18627
  return null;
18484
18628
  }
18485
- const binDir = path48.join(path48.dirname(pkgJsonPath), "bin");
18629
+ const binDir = path49.join(path49.dirname(pkgJsonPath), "bin");
18486
18630
  const binaryName = process.platform === "win32" ? "bd.exe" : "bd";
18487
- const binaryPath = path48.join(binDir, binaryName);
18631
+ const binaryPath = path49.join(binDir, binaryName);
18488
18632
  try {
18489
- fs46.accessSync(binaryPath, fs46.constants.F_OK);
18633
+ fs47.accessSync(binaryPath, fs47.constants.F_OK);
18490
18634
  return binaryPath;
18491
18635
  } catch {
18492
18636
  return null;
@@ -18496,13 +18640,13 @@ function resolveBdOnPath() {
18496
18640
  return _resolveSeam.resolveOnPath();
18497
18641
  }
18498
18642
  function _defaultResolveOnPath() {
18499
- const dirs = (process.env.PATH ?? "").split(path48.delimiter).filter(Boolean);
18643
+ const dirs = (process.env.PATH ?? "").split(path49.delimiter).filter(Boolean);
18500
18644
  const candidates = process.platform === "win32" ? ["bd.exe", "bd.cmd", "bd"] : ["bd"];
18501
18645
  for (const dir of dirs) {
18502
18646
  for (const candidate of candidates) {
18503
- const full = path48.join(dir, candidate);
18647
+ const full = path49.join(dir, candidate);
18504
18648
  try {
18505
- fs46.accessSync(full, fs46.constants.F_OK);
18649
+ fs47.accessSync(full, fs47.constants.F_OK);
18506
18650
  return full;
18507
18651
  } catch {
18508
18652
  }
@@ -18587,7 +18731,7 @@ var BdAdapter = class {
18587
18731
  const env = { ...process.env };
18588
18732
  if (!env.HOME) {
18589
18733
  try {
18590
- const home = os36.homedir();
18734
+ const home = os37.homedir();
18591
18735
  if (home) env.HOME = home;
18592
18736
  } catch {
18593
18737
  }
@@ -18679,9 +18823,9 @@ function coerceIssue(row, projectKey) {
18679
18823
 
18680
18824
  // src/beads/provisioner.ts
18681
18825
  var import_child_process22 = require("child_process");
18682
- var fs49 = __toESM(require("fs"));
18683
- var os38 = __toESM(require("os"));
18684
- var path51 = __toESM(require("path"));
18826
+ var fs50 = __toESM(require("fs"));
18827
+ var os39 = __toESM(require("os"));
18828
+ var path52 = __toESM(require("path"));
18685
18829
 
18686
18830
  // src/beads/install-bd.ts
18687
18831
  var import_child_process19 = require("child_process");
@@ -18746,9 +18890,9 @@ async function installBd(platform3 = process.platform) {
18746
18890
 
18747
18891
  // src/beads/install-dolt.ts
18748
18892
  var import_child_process20 = require("child_process");
18749
- var fs47 = __toESM(require("fs"));
18750
- var os37 = __toESM(require("os"));
18751
- var path49 = __toESM(require("path"));
18893
+ var fs48 = __toESM(require("fs"));
18894
+ var os38 = __toESM(require("os"));
18895
+ var path50 = __toESM(require("path"));
18752
18896
  var DOLT_INSTALL_SH_URL = "https://github.com/dolthub/dolt/releases/latest/download/install.sh";
18753
18897
  var DOLT_MSI_URL = "https://github.com/dolthub/dolt/releases/latest/download/dolt-windows-amd64.msi";
18754
18898
  function resolveDoltInstallStrategy(platform3) {
@@ -18788,11 +18932,11 @@ function resolveDoltInstallStrategy(platform3) {
18788
18932
  }
18789
18933
  var DOLT_RELEASE_BASE = "https://github.com/dolthub/dolt/releases/latest/download";
18790
18934
  function doltPlatformTuple(platform3, arch2) {
18791
- const os48 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
18935
+ const os49 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
18792
18936
  const a = arch2 === "x64" ? "amd64" : arch2 === "arm64" ? "arm64" : null;
18793
18937
  if (!a) return null;
18794
- if (os48 === "windows" && a !== "amd64") return null;
18795
- return `${os48}-${a}`;
18938
+ if (os49 === "windows" && a !== "amd64") return null;
18939
+ return `${os49}-${a}`;
18796
18940
  }
18797
18941
  function resolveDoltTarballStrategy(targetDir, platform3, arch2) {
18798
18942
  const tuple = doltPlatformTuple(platform3, arch2);
@@ -18837,14 +18981,14 @@ async function installDoltToDir(targetDir, platform3 = process.platform, arch2 =
18837
18981
  return result;
18838
18982
  }
18839
18983
  var _doltPathSeam = {
18840
- homedir: () => os37.homedir(),
18984
+ homedir: () => os38.homedir(),
18841
18985
  getPath: () => process.env.PATH ?? "",
18842
18986
  setPath: (p2) => {
18843
18987
  process.env.PATH = p2;
18844
18988
  },
18845
18989
  exists: (p2) => {
18846
18990
  try {
18847
- fs47.accessSync(p2, fs47.constants.F_OK);
18991
+ fs48.accessSync(p2, fs48.constants.F_OK);
18848
18992
  return true;
18849
18993
  } catch {
18850
18994
  return false;
@@ -18855,7 +18999,7 @@ function doltBinaryNames(platform3) {
18855
18999
  return platform3 === "win32" ? ["dolt.exe", "dolt.cmd", "dolt"] : ["dolt"];
18856
19000
  }
18857
19001
  function knownDoltDirs(platform3) {
18858
- const P3 = platform3 === "win32" ? path49.win32 : path49.posix;
19002
+ const P3 = platform3 === "win32" ? path50.win32 : path50.posix;
18859
19003
  const home = _doltPathSeam.homedir();
18860
19004
  if (platform3 === "win32") {
18861
19005
  return [
@@ -18871,7 +19015,7 @@ function knownDoltDirs(platform3) {
18871
19015
  ].filter(Boolean);
18872
19016
  }
18873
19017
  function ensureDoltResolvable(platform3 = process.platform) {
18874
- const P3 = platform3 === "win32" ? path49.win32 : path49.posix;
19018
+ const P3 = platform3 === "win32" ? path50.win32 : path50.posix;
18875
19019
  const delim = platform3 === "win32" ? ";" : ":";
18876
19020
  const names = doltBinaryNames(platform3);
18877
19021
  const pathDirs = _doltPathSeam.getPath().split(delim).filter(Boolean);
@@ -19007,8 +19151,8 @@ async function ensureSharedServer(adapter, options = {}) {
19007
19151
  // src/beads/project-key.ts
19008
19152
  var import_child_process21 = require("child_process");
19009
19153
  var crypto2 = __toESM(require("crypto"));
19010
- var fs48 = __toESM(require("fs"));
19011
- var path50 = __toESM(require("path"));
19154
+ var fs49 = __toESM(require("fs"));
19155
+ var path51 = __toESM(require("path"));
19012
19156
  function normalizeOrigin(raw) {
19013
19157
  const trimmed = raw.trim();
19014
19158
  if (!trimmed) return null;
@@ -19034,17 +19178,17 @@ function normalizeOrigin(raw) {
19034
19178
  return `${host2}/${pathPart}`;
19035
19179
  }
19036
19180
  function findRepoRoot(cwd) {
19037
- let dir = path50.resolve(cwd);
19181
+ let dir = path51.resolve(cwd);
19038
19182
  const seen = /* @__PURE__ */ new Set();
19039
19183
  for (let i = 0; i < 256; i++) {
19040
19184
  if (seen.has(dir)) return null;
19041
19185
  seen.add(dir);
19042
19186
  try {
19043
- const stat3 = fs48.statSync(path50.join(dir, ".git"), { throwIfNoEntry: false });
19187
+ const stat3 = fs49.statSync(path51.join(dir, ".git"), { throwIfNoEntry: false });
19044
19188
  if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
19045
19189
  } catch {
19046
19190
  }
19047
- const parent = path50.dirname(dir);
19191
+ const parent = path51.dirname(dir);
19048
19192
  if (parent === dir) return null;
19049
19193
  dir = parent;
19050
19194
  }
@@ -19055,7 +19199,7 @@ var _execSeam2 = {
19055
19199
  const out2 = (0, import_child_process21.execFileSync)(file, args2, opts);
19056
19200
  return typeof out2 === "string" ? out2 : out2.toString("utf8");
19057
19201
  },
19058
- realpath: (p2) => fs48.realpathSync(p2)
19202
+ realpath: (p2) => fs49.realpathSync(p2)
19059
19203
  };
19060
19204
  function readOrigin(cwd) {
19061
19205
  try {
@@ -19084,7 +19228,7 @@ function deriveProjectIdentity(cwd = process.cwd()) {
19084
19228
  } catch {
19085
19229
  }
19086
19230
  const hash = crypto2.createHash("sha256").update(real).digest("hex");
19087
- return { projectKey: `path:${hash}`, projectLabel: path50.basename(real) || "project" };
19231
+ return { projectKey: `path:${hash}`, projectLabel: path51.basename(real) || "project" };
19088
19232
  }
19089
19233
 
19090
19234
  // src/beads/project-prefix.ts
@@ -19129,17 +19273,17 @@ var _provisionSeam = {
19129
19273
  };
19130
19274
  var _linkSeam = {
19131
19275
  platform: () => process.platform,
19132
- homedir: () => os38.homedir(),
19276
+ homedir: () => os39.homedir(),
19133
19277
  isWritableDir: (dir) => {
19134
19278
  try {
19135
- fs49.accessSync(dir, fs49.constants.W_OK);
19279
+ fs50.accessSync(dir, fs50.constants.W_OK);
19136
19280
  return true;
19137
19281
  } catch {
19138
19282
  return false;
19139
19283
  }
19140
19284
  },
19141
19285
  ensureDir: (dir) => {
19142
- fs49.mkdirSync(dir, { recursive: true });
19286
+ fs50.mkdirSync(dir, { recursive: true });
19143
19287
  },
19144
19288
  /**
19145
19289
  * A directory to symlink `bd` into so the AGENT's shell + Claude Code's
@@ -19160,9 +19304,9 @@ var _linkSeam = {
19160
19304
  * which `linkBdOntoPath` creates if missing.
19161
19305
  */
19162
19306
  cliBinDir: () => {
19163
- const pathDirs = (process.env.PATH ?? "").split(path51.delimiter).filter(Boolean);
19307
+ const pathDirs = (process.env.PATH ?? "").split(path52.delimiter).filter(Boolean);
19164
19308
  const home = _linkSeam.homedir();
19165
- const localBin = home ? path51.join(home, ".local", "bin") : null;
19309
+ const localBin = home ? path52.join(home, ".local", "bin") : null;
19166
19310
  if (localBin) {
19167
19311
  try {
19168
19312
  _linkSeam.ensureDir(localBin);
@@ -19172,16 +19316,16 @@ var _linkSeam = {
19172
19316
  const candidates = [];
19173
19317
  if (localBin) candidates.push(localBin);
19174
19318
  try {
19175
- candidates.push(path51.dirname(process.execPath));
19319
+ candidates.push(path52.dirname(process.execPath));
19176
19320
  } catch {
19177
19321
  }
19178
19322
  candidates.push("/usr/local/bin");
19179
19323
  const entry = process.argv[1];
19180
19324
  if (entry) {
19181
19325
  try {
19182
- candidates.push(path51.dirname(fs49.realpathSync(entry)));
19326
+ candidates.push(path52.dirname(fs50.realpathSync(entry)));
19183
19327
  } catch {
19184
- candidates.push(path51.dirname(entry));
19328
+ candidates.push(path52.dirname(entry));
19185
19329
  }
19186
19330
  }
19187
19331
  const onPathWritable = candidates.find(
@@ -19193,20 +19337,20 @@ var _linkSeam = {
19193
19337
  /** Current symlink target at `linkPath`, or null when absent / not a link. */
19194
19338
  readlink: (linkPath) => {
19195
19339
  try {
19196
- return fs49.readlinkSync(linkPath);
19340
+ return fs50.readlinkSync(linkPath);
19197
19341
  } catch {
19198
19342
  return null;
19199
19343
  }
19200
19344
  },
19201
- unlink: (linkPath) => fs49.unlinkSync(linkPath),
19202
- symlink: (target, linkPath) => fs49.symlinkSync(target, linkPath)
19345
+ unlink: (linkPath) => fs50.unlinkSync(linkPath),
19346
+ symlink: (target, linkPath) => fs50.symlinkSync(target, linkPath)
19203
19347
  };
19204
19348
  function linkBdOntoPath(binaryPath) {
19205
19349
  if (_linkSeam.platform() === "win32") return;
19206
19350
  const binDir = _linkSeam.cliBinDir();
19207
19351
  if (!binDir) return;
19208
19352
  _linkSeam.ensureDir(binDir);
19209
- const linkPath = path51.join(binDir, "bd");
19353
+ const linkPath = path52.join(binDir, "bd");
19210
19354
  if (linkPath === binaryPath) return;
19211
19355
  const current = _linkSeam.readlink(linkPath);
19212
19356
  if (current === binaryPath) return;
@@ -19401,7 +19545,7 @@ function dedupeRecipes(agents) {
19401
19545
 
19402
19546
  // src/beads/watcher.ts
19403
19547
  var crypto4 = __toESM(require("crypto"));
19404
- var path52 = __toESM(require("path"));
19548
+ var path53 = __toESM(require("path"));
19405
19549
  var API_BASE6 = resolveApiBaseUrl();
19406
19550
  var DEBOUNCE_MS2 = 400;
19407
19551
  var ZERO_SUMMARY = {
@@ -19425,7 +19569,7 @@ var BeadsWatcher = class {
19425
19569
  constructor(opts) {
19426
19570
  this.opts = opts;
19427
19571
  this.bd = opts.adapter ?? new BdAdapter({ cwd: opts.cwd, beadsDir: opts.beadsDir });
19428
- this.feedPath = opts.feedPath ?? path52.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
19572
+ this.feedPath = opts.feedPath ?? path53.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
19429
19573
  this.apiBase = opts.apiBaseUrl ?? API_BASE6;
19430
19574
  }
19431
19575
  opts;
@@ -19842,8 +19986,8 @@ function cleanupAttachmentTempFiles() {
19842
19986
  function saveFilesTemp(files) {
19843
19987
  return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
19844
19988
  const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
19845
- const tmpPath = path54.join(os40.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
19846
- fs51.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
19989
+ const tmpPath = path55.join(os41.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
19990
+ fs52.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
19847
19991
  pendingAttachmentFiles.add(tmpPath);
19848
19992
  return tmpPath;
19849
19993
  });
@@ -20055,9 +20199,9 @@ var listFiles = async (ctx, cmd, parsed) => {
20055
20199
  await ctx.relay.sendResult(cmd.id, "completed", result);
20056
20200
  };
20057
20201
  var envReadH = async (ctx, cmd) => {
20058
- const envPath = path54.join(process.cwd(), ".env");
20202
+ const envPath = path55.join(process.cwd(), ".env");
20059
20203
  try {
20060
- const raw = await fs51.promises.readFile(envPath, "utf8");
20204
+ const raw = await fs52.promises.readFile(envPath, "utf8");
20061
20205
  await ctx.relay.sendResult(cmd.id, "completed", {
20062
20206
  exists: true,
20063
20207
  vars: parseDotenv(raw)
@@ -20088,14 +20232,14 @@ var envWriteH = async (ctx, cmd, parsed) => {
20088
20232
  }
20089
20233
  seen.add(v.key);
20090
20234
  }
20091
- const envPath = path54.join(process.cwd(), ".env");
20092
- const tmpPath = path54.join(process.cwd(), ".env.codeam.tmp");
20235
+ const envPath = path55.join(process.cwd(), ".env");
20236
+ const tmpPath = path55.join(process.cwd(), ".env.codeam.tmp");
20093
20237
  try {
20094
- await fs51.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
20095
- await fs51.promises.rename(tmpPath, envPath);
20238
+ await fs52.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
20239
+ await fs52.promises.rename(tmpPath, envPath);
20096
20240
  await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
20097
20241
  } catch (err) {
20098
- await fs51.promises.rm(tmpPath, { force: true }).catch(() => void 0);
20242
+ await fs52.promises.rm(tmpPath, { force: true }).catch(() => void 0);
20099
20243
  await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
20100
20244
  }
20101
20245
  };
@@ -20139,7 +20283,7 @@ var headroomConfigureH = async (ctx, cmd, parsed) => {
20139
20283
  let configuredAgent = rawAgentId;
20140
20284
  if (!configuredAgent) {
20141
20285
  try {
20142
- const raw = JSON.parse(fs51.readFileSync(headroomConfigPath(), "utf8"));
20286
+ const raw = JSON.parse(fs52.readFileSync(headroomConfigPath(), "utf8"));
20143
20287
  configuredAgent = raw.agent ?? "";
20144
20288
  } catch {
20145
20289
  }
@@ -20173,7 +20317,7 @@ var headroomConfigureH = async (ctx, cmd, parsed) => {
20173
20317
  persist: persistHeadroomConfig,
20174
20318
  readEnabled: () => {
20175
20319
  try {
20176
- const raw = JSON.parse(fs51.readFileSync(headroomConfigPath(), "utf8"));
20320
+ const raw = JSON.parse(fs52.readFileSync(headroomConfigPath(), "utf8"));
20177
20321
  return raw.enabled === true;
20178
20322
  } catch {
20179
20323
  return false;
@@ -20262,7 +20406,7 @@ var headroomBudgetH = async (ctx, cmd) => {
20262
20406
  }
20263
20407
  let headroomActive = false;
20264
20408
  try {
20265
- const raw = JSON.parse(fs51.readFileSync(headroomConfigPath(), "utf8"));
20409
+ const raw = JSON.parse(fs52.readFileSync(headroomConfigPath(), "utf8"));
20266
20410
  headroomActive = raw.enabled === true;
20267
20411
  } catch {
20268
20412
  }
@@ -20272,7 +20416,7 @@ var headroomBudgetH = async (ctx, cmd) => {
20272
20416
  }
20273
20417
  let existingConfig = { enabled: true };
20274
20418
  try {
20275
- existingConfig = JSON.parse(fs51.readFileSync(headroomConfigPath(), "utf8"));
20419
+ existingConfig = JSON.parse(fs52.readFileSync(headroomConfigPath(), "utf8"));
20276
20420
  } catch {
20277
20421
  }
20278
20422
  if (payload.budgetEnabled && payload.budgetUsd != null) {
@@ -20385,13 +20529,13 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
20385
20529
  function buildNpmInstallInvocation(opts) {
20386
20530
  const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
20387
20531
  const execPath = opts?.execPath ?? process.execPath;
20388
- const exists2 = opts?.existsSync ?? fs51.existsSync;
20389
- const normalized = entryScript.split(path54.sep).join("/");
20532
+ const exists2 = opts?.existsSync ?? fs52.existsSync;
20533
+ const normalized = entryScript.split(path55.sep).join("/");
20390
20534
  const marker = "/lib/node_modules/codeam-cli/";
20391
20535
  const markerIdx = normalized.indexOf(marker);
20392
20536
  const prefix = markerIdx > 0 ? entryScript.slice(0, markerIdx) : null;
20393
- const siblingNpm = path54.join(
20394
- path54.dirname(execPath),
20537
+ const siblingNpm = path55.join(
20538
+ path55.dirname(execPath),
20395
20539
  process.platform === "win32" ? "npm.cmd" : "npm"
20396
20540
  );
20397
20541
  const command2 = exists2(siblingNpm) ? siblingNpm : "npm";
@@ -21233,11 +21377,11 @@ function resolveTokenValue(args2) {
21233
21377
  }
21234
21378
  const fileFlag = args2.find((a) => a.startsWith("--token-file="));
21235
21379
  if (fileFlag) {
21236
- const path69 = fileFlag.slice("--token-file=".length);
21380
+ const path70 = fileFlag.slice("--token-file=".length);
21237
21381
  try {
21238
- const content = fs52.readFileSync(path69, "utf8").trim();
21239
- if (content.length === 0) fail(`--token-file ${path69} is empty`);
21240
- rmIfExistsQuiet(path69);
21382
+ const content = fs53.readFileSync(path70, "utf8").trim();
21383
+ if (content.length === 0) fail(`--token-file ${path70} is empty`);
21384
+ rmIfExistsQuiet(path70);
21241
21385
  return content;
21242
21386
  } catch (err) {
21243
21387
  fail(`Could not read --token-file: ${err.message}`);
@@ -21266,7 +21410,7 @@ async function claimOnce(token, pluginId, pluginSecretHash) {
21266
21410
  pluginId,
21267
21411
  ideName: "codeam-cli (codespace)",
21268
21412
  ideVersion: process.env.npm_package_version ?? "unknown",
21269
- hostname: os41.hostname(),
21413
+ hostname: os42.hostname(),
21270
21414
  codespaceName: process.env.CODESPACE_NAME ?? "",
21271
21415
  // Current git branch of the codespace's working directory, so the
21272
21416
  // backend can populate `PairedSession.branch` for the codespace pair.
@@ -21327,7 +21471,7 @@ async function claim(token, pluginId, pluginSecretHash) {
21327
21471
  }
21328
21472
  }
21329
21473
  function pairAutoLockPath() {
21330
- return path55.join(os41.homedir(), ".codeam", "pair-auto.lock");
21474
+ return path56.join(os42.homedir(), ".codeam", "pair-auto.lock");
21331
21475
  }
21332
21476
  function isLivePairAuto(pid) {
21333
21477
  if (!Number.isInteger(pid) || pid <= 0 || pid === process.pid) return false;
@@ -21337,7 +21481,7 @@ function isLivePairAuto(pid) {
21337
21481
  if (e.code !== "EPERM") return false;
21338
21482
  }
21339
21483
  try {
21340
- return fs52.readFileSync(`/proc/${pid}/cmdline`, "utf8").includes("codeam");
21484
+ return fs53.readFileSync(`/proc/${pid}/cmdline`, "utf8").includes("codeam");
21341
21485
  } catch {
21342
21486
  return true;
21343
21487
  }
@@ -21347,24 +21491,24 @@ function isLiveCodeam(pid) {
21347
21491
  }
21348
21492
  function daemonLockPath(sessionId) {
21349
21493
  const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
21350
- return path55.join(os41.homedir(), ".codeam", `daemon-${safe}.lock`);
21494
+ return path56.join(os42.homedir(), ".codeam", `daemon-${safe}.lock`);
21351
21495
  }
21352
21496
  function acquireDaemonLock(sessionId) {
21353
21497
  const lockPath = daemonLockPath(sessionId);
21354
21498
  try {
21355
- fs52.mkdirSync(path55.dirname(lockPath), { recursive: true });
21499
+ fs53.mkdirSync(path56.dirname(lockPath), { recursive: true });
21356
21500
  try {
21357
- fs52.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
21501
+ fs53.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
21358
21502
  } catch (e) {
21359
21503
  if (e.code !== "EEXIST") throw e;
21360
- const holder = Number(fs52.readFileSync(lockPath, "utf8").trim());
21504
+ const holder = Number(fs53.readFileSync(lockPath, "utf8").trim());
21361
21505
  if (holder && holder !== process.pid && isLiveCodeam(holder)) return false;
21362
- fs52.writeFileSync(lockPath, String(process.pid));
21506
+ fs53.writeFileSync(lockPath, String(process.pid));
21363
21507
  }
21364
21508
  const release3 = () => {
21365
21509
  try {
21366
- if (fs52.existsSync(lockPath) && Number(fs52.readFileSync(lockPath, "utf8").trim()) === process.pid) {
21367
- fs52.unlinkSync(lockPath);
21510
+ if (fs53.existsSync(lockPath) && Number(fs53.readFileSync(lockPath, "utf8").trim()) === process.pid) {
21511
+ fs53.unlinkSync(lockPath);
21368
21512
  }
21369
21513
  } catch {
21370
21514
  }
@@ -21386,19 +21530,19 @@ function acquireDaemonLock(sessionId) {
21386
21530
  function acquireSingletonLock() {
21387
21531
  const lockPath = pairAutoLockPath();
21388
21532
  try {
21389
- fs52.mkdirSync(path55.dirname(lockPath), { recursive: true });
21533
+ fs53.mkdirSync(path56.dirname(lockPath), { recursive: true });
21390
21534
  try {
21391
- fs52.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
21535
+ fs53.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
21392
21536
  } catch (e) {
21393
21537
  if (e.code !== "EEXIST") throw e;
21394
- const holder = Number(fs52.readFileSync(lockPath, "utf8").trim());
21538
+ const holder = Number(fs53.readFileSync(lockPath, "utf8").trim());
21395
21539
  if (isLivePairAuto(holder)) return false;
21396
- fs52.writeFileSync(lockPath, String(process.pid));
21540
+ fs53.writeFileSync(lockPath, String(process.pid));
21397
21541
  }
21398
21542
  process.once("exit", () => {
21399
21543
  try {
21400
- if (fs52.existsSync(lockPath) && Number(fs52.readFileSync(lockPath, "utf8").trim()) === process.pid) {
21401
- fs52.unlinkSync(lockPath);
21544
+ if (fs53.existsSync(lockPath) && Number(fs53.readFileSync(lockPath, "utf8").trim()) === process.pid) {
21545
+ fs53.unlinkSync(lockPath);
21402
21546
  }
21403
21547
  } catch {
21404
21548
  }
@@ -21843,7 +21987,7 @@ var AgentService = class _AgentService {
21843
21987
  };
21844
21988
 
21845
21989
  // src/agents/acp/adapters.ts
21846
- var path57 = __toESM(require("path"));
21990
+ var path58 = __toESM(require("path"));
21847
21991
 
21848
21992
  // src/agents/acp/agent-binary.ts
21849
21993
  var import_fs4 = __toESM(require("fs"));
@@ -21876,14 +22020,14 @@ function defaultSdkDir() {
21876
22020
  return resolveSdkDirViaRequire();
21877
22021
  }
21878
22022
  function resolveClaudeNativeBinary(deps = {}) {
21879
- const existsSync25 = deps.existsSync ?? import_fs4.default.existsSync;
22023
+ const existsSync26 = deps.existsSync ?? import_fs4.default.existsSync;
21880
22024
  const platformKey = deps.platformKey ?? currentPlatformKey();
21881
22025
  const sdkDir = deps.sdkDir !== void 0 ? deps.sdkDir : defaultSdkDir();
21882
22026
  if (!sdkDir) return null;
21883
22027
  const scopeDir = import_path8.default.dirname(sdkDir);
21884
22028
  const binName = platformKey.startsWith("win32-") ? "claude.exe" : "claude";
21885
22029
  const candidate = import_path8.default.join(scopeDir, `claude-agent-sdk-${platformKey}`, binName);
21886
- return existsSync25(candidate) ? candidate : null;
22030
+ return existsSync26(candidate) ? candidate : null;
21887
22031
  }
21888
22032
  var realSleep = (ms) => new Promise((resolve7) => setTimeout(resolve7, ms));
21889
22033
  async function waitForClaudeNativeBinary(opts = {}) {
@@ -21934,18 +22078,18 @@ async function waitForCommandOnPath(cmd, opts = {}) {
21934
22078
  return check();
21935
22079
  }
21936
22080
  function resolveCursorAgentBinary(deps = {}) {
21937
- const existsSync25 = deps.existsSync ?? import_fs4.default.existsSync;
22081
+ const existsSync26 = deps.existsSync ?? import_fs4.default.existsSync;
21938
22082
  const platform3 = deps.platform ?? process.platform;
21939
22083
  const env = deps.env ?? process.env;
21940
22084
  if (platform3 === "win32") {
21941
22085
  const localAppData = env.LOCALAPPDATA;
21942
22086
  if (!localAppData) return null;
21943
22087
  const exe = import_path8.default.win32.join(localAppData, "cursor-agent", "cursor-agent.exe");
21944
- return existsSync25(exe) ? exe : null;
22088
+ return existsSync26(exe) ? exe : null;
21945
22089
  }
21946
22090
  const home = deps.homedir ?? import_os8.default.homedir();
21947
22091
  const unix = import_path8.default.posix.join(home, ".local", "bin", "cursor-agent");
21948
- return existsSync25(unix) ? unix : null;
22092
+ return existsSync26(unix) ? unix : null;
21949
22093
  }
21950
22094
  async function waitForCursorAgent(opts = {}) {
21951
22095
  const timeoutMs = opts.timeoutMs ?? 18e4;
@@ -22025,13 +22169,13 @@ function resolveBin(pkgName, binName) {
22025
22169
  try {
22026
22170
  const manifestPath = require_.resolve(`${pkgName}/package.json`);
22027
22171
  const manifest = require_(`${pkgName}/package.json`);
22028
- const pkgDir = path57.dirname(manifestPath);
22172
+ const pkgDir = path58.dirname(manifestPath);
22029
22173
  const bin = manifest.bin;
22030
22174
  if (!bin) return null;
22031
- if (typeof bin === "string") return path57.resolve(pkgDir, bin);
22175
+ if (typeof bin === "string") return path58.resolve(pkgDir, bin);
22032
22176
  const target = binName ?? Object.keys(bin)[0];
22033
22177
  if (!target || !bin[target]) return null;
22034
- return path57.resolve(pkgDir, bin[target]);
22178
+ return path58.resolve(pkgDir, bin[target]);
22035
22179
  } catch {
22036
22180
  return null;
22037
22181
  }
@@ -22124,12 +22268,12 @@ function requiresAcp(agent) {
22124
22268
  }
22125
22269
 
22126
22270
  // src/agents/acp/runner.ts
22127
- var import_node_crypto8 = require("crypto");
22271
+ var import_node_crypto9 = require("crypto");
22128
22272
 
22129
22273
  // src/services/history.service.ts
22130
- var fs54 = __toESM(require("fs"));
22131
- var path58 = __toESM(require("path"));
22132
- var os43 = __toESM(require("os"));
22274
+ var fs55 = __toESM(require("fs"));
22275
+ var path59 = __toESM(require("path"));
22276
+ var os44 = __toESM(require("os"));
22133
22277
  var https7 = __toESM(require("https"));
22134
22278
  var http6 = __toESM(require("http"));
22135
22279
  var import_zod2 = require("zod");
@@ -22156,7 +22300,7 @@ function parseJsonl(filePath) {
22156
22300
  const messages = [];
22157
22301
  let raw;
22158
22302
  try {
22159
- raw = fs54.readFileSync(filePath, "utf8");
22303
+ raw = fs55.readFileSync(filePath, "utf8");
22160
22304
  } catch (err) {
22161
22305
  if (err.code !== "ENOENT") {
22162
22306
  log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
@@ -22297,7 +22441,7 @@ var HistoryService = class _HistoryService {
22297
22441
  return this._quotaPercent === null || Date.now() - this._quotaFetchedAt > ttlMs;
22298
22442
  }
22299
22443
  get projectDir() {
22300
- return this.runtime.resolveHistoryDir(this.cwd) ?? path58.join(os43.homedir(), ".claude", "projects", encodeCwd(this.cwd));
22444
+ return this.runtime.resolveHistoryDir(this.cwd) ?? path59.join(os44.homedir(), ".claude", "projects", encodeCwd(this.cwd));
22301
22445
  }
22302
22446
  /** Set the current Claude conversation ID (extracted from /cost command or session start) */
22303
22447
  setCurrentConversationId(id) {
@@ -22309,7 +22453,7 @@ var HistoryService = class _HistoryService {
22309
22453
  /** Return the current message count in the active conversation. */
22310
22454
  getCurrentMessageCount() {
22311
22455
  if (!this.currentConversationId) return 0;
22312
- const filePath = path58.join(this.projectDir, `${this.currentConversationId}.jsonl`);
22456
+ const filePath = path59.join(this.projectDir, `${this.currentConversationId}.jsonl`);
22313
22457
  return parseJsonl(filePath).length;
22314
22458
  }
22315
22459
  /**
@@ -22320,7 +22464,7 @@ var HistoryService = class _HistoryService {
22320
22464
  const deadline = Date.now() + timeoutMs;
22321
22465
  while (Date.now() < deadline) {
22322
22466
  if (!this.currentConversationId) return null;
22323
- const filePath = path58.join(this.projectDir, `${this.currentConversationId}.jsonl`);
22467
+ const filePath = path59.join(this.projectDir, `${this.currentConversationId}.jsonl`);
22324
22468
  const messages = parseJsonl(filePath);
22325
22469
  if (messages.length > previousCount) {
22326
22470
  for (let i = messages.length - 1; i >= previousCount; i--) {
@@ -22346,16 +22490,16 @@ var HistoryService = class _HistoryService {
22346
22490
  const dir = this.projectDir;
22347
22491
  const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
22348
22492
  try {
22349
- const files = fs54.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
22493
+ const files = fs55.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
22350
22494
  try {
22351
- const stat3 = fs54.statSync(path58.join(dir, e.name));
22495
+ const stat3 = fs55.statSync(path59.join(dir, e.name));
22352
22496
  return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
22353
22497
  } catch {
22354
22498
  return { name: e.name, mtime: 0, birthtime: 0 };
22355
22499
  }
22356
22500
  }).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
22357
22501
  if (files.length > 0) {
22358
- this.currentConversationId = path58.basename(files[0].name, ".jsonl");
22502
+ this.currentConversationId = path59.basename(files[0].name, ".jsonl");
22359
22503
  }
22360
22504
  } catch {
22361
22505
  }
@@ -22389,13 +22533,13 @@ var HistoryService = class _HistoryService {
22389
22533
  const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
22390
22534
  let entries;
22391
22535
  try {
22392
- entries = fs54.readdirSync(dir, { withFileTypes: true });
22536
+ entries = fs55.readdirSync(dir, { withFileTypes: true });
22393
22537
  } catch {
22394
22538
  return null;
22395
22539
  }
22396
22540
  const files = entries.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
22397
22541
  try {
22398
- const stat3 = fs54.statSync(path58.join(dir, e.name));
22542
+ const stat3 = fs55.statSync(path59.join(dir, e.name));
22399
22543
  return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
22400
22544
  } catch {
22401
22545
  return { name: e.name, mtime: 0, birthtime: 0 };
@@ -22404,12 +22548,12 @@ var HistoryService = class _HistoryService {
22404
22548
  if (files.length === 0) return null;
22405
22549
  const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
22406
22550
  if (!files.some((f) => f.name === targetFile)) return null;
22407
- return this.extractUsageFromFile(path58.join(dir, targetFile));
22551
+ return this.extractUsageFromFile(path59.join(dir, targetFile));
22408
22552
  }
22409
22553
  extractUsageFromFile(filePath) {
22410
22554
  let raw;
22411
22555
  try {
22412
- raw = fs54.readFileSync(filePath, "utf8");
22556
+ raw = fs55.readFileSync(filePath, "utf8");
22413
22557
  } catch {
22414
22558
  return null;
22415
22559
  }
@@ -22454,9 +22598,9 @@ var HistoryService = class _HistoryService {
22454
22598
  let totalCost = 0;
22455
22599
  let files;
22456
22600
  try {
22457
- files = fs54.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
22601
+ files = fs55.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
22458
22602
  try {
22459
- return fs54.statSync(path58.join(projectDir, f)).mtimeMs >= monthStartMs;
22603
+ return fs55.statSync(path59.join(projectDir, f)).mtimeMs >= monthStartMs;
22460
22604
  } catch {
22461
22605
  return false;
22462
22606
  }
@@ -22467,7 +22611,7 @@ var HistoryService = class _HistoryService {
22467
22611
  for (const file of files) {
22468
22612
  let raw;
22469
22613
  try {
22470
- raw = fs54.readFileSync(path58.join(projectDir, file), "utf8");
22614
+ raw = fs55.readFileSync(path59.join(projectDir, file), "utf8");
22471
22615
  } catch {
22472
22616
  continue;
22473
22617
  }
@@ -22546,7 +22690,7 @@ var HistoryService = class _HistoryService {
22546
22690
  if (this.runtime.resolveHistoryFile) {
22547
22691
  return this.runtime.resolveHistoryFile(this.cwd, sessionId);
22548
22692
  }
22549
- return path58.join(this.projectDir, `${sessionId}.jsonl`);
22693
+ return path59.join(this.projectDir, `${sessionId}.jsonl`);
22550
22694
  }
22551
22695
  /**
22552
22696
  * Parse a conversation's messages from disk, agent-aware. Claude uses the
@@ -22580,7 +22724,7 @@ var HistoryService = class _HistoryService {
22580
22724
  };
22581
22725
  });
22582
22726
  }
22583
- return parseJsonl(path58.join(this.projectDir, `${sessionId}.jsonl`));
22727
+ return parseJsonl(path59.join(this.projectDir, `${sessionId}.jsonl`));
22584
22728
  }
22585
22729
  async loadConversation(sessionId) {
22586
22730
  const messages = this.readConversation(sessionId);
@@ -22636,7 +22780,7 @@ var HistoryService = class _HistoryService {
22636
22780
  if (!filePath) return false;
22637
22781
  let mtimeMs;
22638
22782
  try {
22639
- mtimeMs = fs54.statSync(filePath).mtimeMs;
22783
+ mtimeMs = fs55.statSync(filePath).mtimeMs;
22640
22784
  } catch {
22641
22785
  return false;
22642
22786
  }
@@ -22705,10 +22849,10 @@ var HistoryService = class _HistoryService {
22705
22849
 
22706
22850
  // src/agents/acp/client.ts
22707
22851
  var import_node_child_process22 = require("child_process");
22708
- var fs55 = __toESM(require("fs/promises"));
22852
+ var fs56 = __toESM(require("fs/promises"));
22709
22853
  var fsSync = __toESM(require("fs"));
22710
- var os44 = __toESM(require("os"));
22711
- var path59 = __toESM(require("path"));
22854
+ var os45 = __toESM(require("os"));
22855
+ var path60 = __toESM(require("path"));
22712
22856
  var import_node_stream = require("stream");
22713
22857
 
22714
22858
  // ../../node_modules/@agentclientprotocol/sdk/dist/acp.js
@@ -25622,7 +25766,7 @@ var AcpClient = class {
25622
25766
  },
25623
25767
  readTextFile: async (params) => {
25624
25768
  try {
25625
- const content = await fs55.readFile(params.path, "utf8");
25769
+ const content = await fs56.readFile(params.path, "utf8");
25626
25770
  return applyLineRange(content, params.line ?? null, params.limit ?? null);
25627
25771
  } catch (err) {
25628
25772
  const code = err.code;
@@ -25642,7 +25786,7 @@ var AcpClient = class {
25642
25786
  },
25643
25787
  writeTextFile: async (params) => {
25644
25788
  try {
25645
- await fs55.writeFile(params.path, params.content, "utf8");
25789
+ await fs56.writeFile(params.path, params.content, "utf8");
25646
25790
  return {};
25647
25791
  } catch (err) {
25648
25792
  const code = err.code;
@@ -25691,29 +25835,29 @@ function applyLineRange(content, line, limit) {
25691
25835
  return { content: lines.slice(start2, end).join("\n") };
25692
25836
  }
25693
25837
  function knownAgentBinaryDirs() {
25694
- const home = os44.homedir();
25838
+ const home = os45.homedir();
25695
25839
  const out2 = [];
25696
25840
  out2.push("/tmp/codeam-node20/bin");
25697
25841
  for (const root of [
25698
25842
  "/usr/local/share/nvm/versions/node",
25699
- path59.join(home, ".nvm/versions/node")
25843
+ path60.join(home, ".nvm/versions/node")
25700
25844
  ]) {
25701
25845
  try {
25702
25846
  for (const child of fsSync.readdirSync(root)) {
25703
- out2.push(path59.join(root, child, "bin"));
25847
+ out2.push(path60.join(root, child, "bin"));
25704
25848
  }
25705
25849
  } catch {
25706
25850
  }
25707
25851
  }
25708
- out2.push(path59.join(home, ".volta/bin"));
25852
+ out2.push(path60.join(home, ".volta/bin"));
25709
25853
  out2.push("/usr/local/bin");
25710
25854
  out2.push("/usr/bin");
25711
- out2.push(path59.join(home, ".local/bin"));
25712
- out2.push(path59.join(home, "bin"));
25855
+ out2.push(path60.join(home, ".local/bin"));
25856
+ out2.push(path60.join(home, "bin"));
25713
25857
  if (process.platform === "win32") {
25714
25858
  const { LOCALAPPDATA, APPDATA } = process.env;
25715
- if (LOCALAPPDATA) out2.push(path59.join(LOCALAPPDATA, "cursor-agent"));
25716
- if (APPDATA) out2.push(path59.join(APPDATA, "npm"));
25859
+ if (LOCALAPPDATA) out2.push(path60.join(LOCALAPPDATA, "cursor-agent"));
25860
+ if (APPDATA) out2.push(path60.join(APPDATA, "npm"));
25717
25861
  }
25718
25862
  return out2.filter((p2) => {
25719
25863
  try {
@@ -25725,7 +25869,7 @@ function knownAgentBinaryDirs() {
25725
25869
  }
25726
25870
  function expandPathForAgentBinaries(existingPath) {
25727
25871
  const existing = new Set(
25728
- existingPath.split(path59.delimiter).filter((p2) => p2.length > 0)
25872
+ existingPath.split(path60.delimiter).filter((p2) => p2.length > 0)
25729
25873
  );
25730
25874
  const additions = [];
25731
25875
  for (const dir of knownAgentBinaryDirs()) {
@@ -25735,7 +25879,7 @@ function expandPathForAgentBinaries(existingPath) {
25735
25879
  }
25736
25880
  }
25737
25881
  if (additions.length === 0) return existingPath;
25738
- return [...additions, existingPath].filter((p2) => p2.length > 0).join(path59.delimiter);
25882
+ return [...additions, existingPath].filter((p2) => p2.length > 0).join(path60.delimiter);
25739
25883
  }
25740
25884
 
25741
25885
  // src/agents/acp/headroom-budget-proxy.ts
@@ -26217,15 +26361,15 @@ function commonPrefixLength(a, b) {
26217
26361
 
26218
26362
  // src/agents/acp/onboarding.ts
26219
26363
  var import_child_process26 = require("child_process");
26220
- var fs56 = __toESM(require("fs"));
26221
- var os45 = __toESM(require("os"));
26222
- var path60 = __toESM(require("path"));
26364
+ var fs57 = __toESM(require("fs"));
26365
+ var os46 = __toESM(require("os"));
26366
+ var path61 = __toESM(require("path"));
26223
26367
  var _onboardingSeam = {
26224
- markerPath: (sessionId) => path60.join(os45.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
26225
- exists: (p2) => fs56.existsSync(p2),
26368
+ markerPath: (sessionId) => path61.join(os46.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
26369
+ exists: (p2) => fs57.existsSync(p2),
26226
26370
  write: (p2) => {
26227
- fs56.mkdirSync(path60.dirname(p2), { recursive: true });
26228
- fs56.writeFileSync(p2, "");
26371
+ fs57.mkdirSync(path61.dirname(p2), { recursive: true });
26372
+ fs57.writeFileSync(p2, "");
26229
26373
  },
26230
26374
  disabled: () => {
26231
26375
  const v = process.env.CODEAM_ONBOARDING_DISABLED;
@@ -26262,7 +26406,7 @@ function resolveRepoName(cwd) {
26262
26406
  if (name) return name;
26263
26407
  }
26264
26408
  }
26265
- const base = path60.basename(cwd || "");
26409
+ const base = path61.basename(cwd || "");
26266
26410
  if (base && !isUuid(base)) return base;
26267
26411
  return "this project";
26268
26412
  }
@@ -26325,7 +26469,7 @@ async function runOnboardingTurn(opts) {
26325
26469
  }
26326
26470
 
26327
26471
  // src/agents/acp/mappers.ts
26328
- var import_node_crypto7 = require("crypto");
26472
+ var import_node_crypto8 = require("crypto");
26329
26473
  function mapSessionUpdate(notification) {
26330
26474
  const update = notification.update;
26331
26475
  switch (update.sessionUpdate) {
@@ -26388,7 +26532,7 @@ function mapPermissionRequest(request) {
26388
26532
  }
26389
26533
  return {
26390
26534
  event: {
26391
- questionId: (0, import_node_crypto7.randomUUID)(),
26535
+ questionId: (0, import_node_crypto8.randomUUID)(),
26392
26536
  prompt,
26393
26537
  options: labels.length > 0 ? labels : void 0
26394
26538
  },
@@ -26398,7 +26542,7 @@ function mapPermissionRequest(request) {
26398
26542
  }
26399
26543
  function messageChunkId(messageId) {
26400
26544
  if (typeof messageId === "string" && messageId.length > 0) return messageId;
26401
- return (0, import_node_crypto7.randomUUID)();
26545
+ return (0, import_node_crypto8.randomUUID)();
26402
26546
  }
26403
26547
  function extractText4(content) {
26404
26548
  if (!content || typeof content !== "object") return null;
@@ -26514,8 +26658,8 @@ var import_crypto5 = require("crypto");
26514
26658
 
26515
26659
  // src/services/turn-files/git-changeset.ts
26516
26660
  var import_child_process27 = require("child_process");
26517
- var fs57 = __toESM(require("fs/promises"));
26518
- var path61 = __toESM(require("path"));
26661
+ var fs58 = __toESM(require("fs/promises"));
26662
+ var path62 = __toESM(require("path"));
26519
26663
  async function collectRepoChangeset(opts) {
26520
26664
  const status2 = await runGit3(opts.repoRoot, ["status", "--porcelain=v1", "-z"]);
26521
26665
  if (status2 === null) return null;
@@ -26533,7 +26677,7 @@ async function collectRepoChangeset(opts) {
26533
26677
  let stats;
26534
26678
  if (row.fileStatus === "added" && numstatEntry === void 0) {
26535
26679
  const lineCount = await readUntrackedLineCount(
26536
- path61.join(opts.repoRoot, row.filePath)
26680
+ path62.join(opts.repoRoot, row.filePath)
26537
26681
  );
26538
26682
  stats = { added: lineCount, removed: 0 };
26539
26683
  } else {
@@ -26564,7 +26708,7 @@ function readUntrackedLineCount(absPath) {
26564
26708
  }
26565
26709
  async function defaultReadUntrackedLineCount(absPath) {
26566
26710
  try {
26567
- const content = await fs57.readFile(absPath, "utf8");
26711
+ const content = await fs58.readFile(absPath, "utf8");
26568
26712
  let count = 0;
26569
26713
  let pos = -1;
26570
26714
  while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
@@ -26656,7 +26800,7 @@ function defaultRunGit(cwd, args2) {
26656
26800
  });
26657
26801
  }
26658
26802
  async function discoverRepos(workingDir, maxDepth = 4) {
26659
- const fs62 = await import("fs/promises");
26803
+ const fs63 = await import("fs/promises");
26660
26804
  const out2 = [];
26661
26805
  await walk(workingDir, 0);
26662
26806
  return out2;
@@ -26664,7 +26808,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
26664
26808
  if (depth > maxDepth) return;
26665
26809
  let entries = [];
26666
26810
  try {
26667
- const dirents = await fs62.readdir(dir, { withFileTypes: true });
26811
+ const dirents = await fs63.readdir(dir, { withFileTypes: true });
26668
26812
  entries = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
26669
26813
  } catch {
26670
26814
  return;
@@ -26675,8 +26819,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
26675
26819
  if (hasGit) {
26676
26820
  out2.push({
26677
26821
  repoRoot: dir,
26678
- repoPath: path61.relative(workingDir, dir),
26679
- repoName: path61.basename(dir)
26822
+ repoPath: path62.relative(workingDir, dir),
26823
+ repoName: path62.basename(dir)
26680
26824
  });
26681
26825
  return;
26682
26826
  }
@@ -26684,14 +26828,14 @@ async function discoverRepos(workingDir, maxDepth = 4) {
26684
26828
  if (!entry.isDirectory) continue;
26685
26829
  if (entry.name === "node_modules") continue;
26686
26830
  if (entry.name === "dist" || entry.name === "build") continue;
26687
- await walk(path61.join(dir, entry.name), depth + 1);
26831
+ await walk(path62.join(dir, entry.name), depth + 1);
26688
26832
  }
26689
26833
  }
26690
26834
  }
26691
26835
 
26692
26836
  // src/services/turn-files/files-outbox.ts
26693
- var fs58 = __toESM(require("fs/promises"));
26694
- var path62 = __toESM(require("path"));
26837
+ var fs59 = __toESM(require("fs/promises"));
26838
+ var path63 = __toESM(require("path"));
26695
26839
  var import_os9 = require("os");
26696
26840
  var HOME_OUTBOX_DIR = ".codeam/outbox";
26697
26841
  var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
@@ -26724,16 +26868,16 @@ var FilesOutbox = class {
26724
26868
  backoffIndex = 0;
26725
26869
  stopped = false;
26726
26870
  constructor(opts) {
26727
- const base = opts.baseDir ?? path62.join(homeDir(), HOME_OUTBOX_DIR);
26728
- this.filePath = path62.join(base, `${opts.sessionId}.jsonl`);
26871
+ const base = opts.baseDir ?? path63.join(homeDir(), HOME_OUTBOX_DIR);
26872
+ this.filePath = path63.join(base, `${opts.sessionId}.jsonl`);
26729
26873
  this.post = opts.post;
26730
26874
  this.autoSchedule = opts.autoSchedule !== false;
26731
26875
  }
26732
26876
  /** Persist the entry to disk and trigger a flush. Returns once the
26733
26877
  * line is durable on disk (not once the POST succeeds). */
26734
26878
  async enqueue(entry) {
26735
- await fs58.mkdir(path62.dirname(this.filePath), { recursive: true });
26736
- await fs58.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
26879
+ await fs59.mkdir(path63.dirname(this.filePath), { recursive: true });
26880
+ await fs59.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
26737
26881
  this.backoffIndex = 0;
26738
26882
  if (this.autoSchedule) this.scheduleFlush(0);
26739
26883
  }
@@ -26822,7 +26966,7 @@ var FilesOutbox = class {
26822
26966
  async readAll() {
26823
26967
  let raw = "";
26824
26968
  try {
26825
- raw = await fs58.readFile(this.filePath, "utf8");
26969
+ raw = await fs59.readFile(this.filePath, "utf8");
26826
26970
  } catch {
26827
26971
  return [];
26828
26972
  }
@@ -26846,12 +26990,12 @@ var FilesOutbox = class {
26846
26990
  async rewrite(entries) {
26847
26991
  const tmpPath = `${this.filePath}.${process.pid}.tmp`;
26848
26992
  if (entries.length === 0) {
26849
- await fs58.unlink(this.filePath).catch(() => void 0);
26993
+ await fs59.unlink(this.filePath).catch(() => void 0);
26850
26994
  return;
26851
26995
  }
26852
26996
  const payload = entries.map((e) => JSON.stringify(e)).join("\n") + "\n";
26853
- await fs58.writeFile(tmpPath, payload, "utf8");
26854
- await fs58.rename(tmpPath, this.filePath);
26997
+ await fs59.writeFile(tmpPath, payload, "utf8");
26998
+ await fs59.rename(tmpPath, this.filePath);
26855
26999
  }
26856
27000
  };
26857
27001
  function applyJitter(ms) {
@@ -28211,7 +28355,7 @@ var AcpHistory = class {
28211
28355
  this.summary = trimmed.length > 120 ? trimmed.slice(0, 117) + "\u2026" : trimmed;
28212
28356
  }
28213
28357
  this.messages.push({
28214
- id: (0, import_node_crypto8.randomUUID)(),
28358
+ id: (0, import_node_crypto9.randomUUID)(),
28215
28359
  role: "user",
28216
28360
  text,
28217
28361
  timestamp: Date.now()
@@ -28220,7 +28364,7 @@ var AcpHistory = class {
28220
28364
  appendAgentReply(text) {
28221
28365
  if (text.length === 0) return;
28222
28366
  this.messages.push({
28223
- id: (0, import_node_crypto8.randomUUID)(),
28367
+ id: (0, import_node_crypto9.randomUUID)(),
28224
28368
  role: "agent",
28225
28369
  text,
28226
28370
  timestamp: Date.now()
@@ -28426,7 +28570,7 @@ async function runAcpSession(opts) {
28426
28570
  currentIndex: 0,
28427
28571
  done: true
28428
28572
  }),
28429
- publishAwaitingAnswer: (prompt, options) => publisher.publishAwaitingAnswer({ questionId: (0, import_node_crypto8.randomUUID)(), prompt, options }),
28573
+ publishAwaitingAnswer: (prompt, options) => publisher.publishAwaitingAnswer({ questionId: (0, import_node_crypto9.randomUUID)(), prompt, options }),
28430
28574
  publishRawChunk: (chunk) => publisher.publishOutput(chunk),
28431
28575
  sendResult: (commandId, status2, result) => relay.sendResult(commandId, status2, result),
28432
28576
  appendAgentReply: (text) => history.appendAgentReply(text),
@@ -29795,7 +29939,7 @@ var NativeTuiDriver = class {
29795
29939
  };
29796
29940
 
29797
29941
  // src/baton/acp-driver.ts
29798
- var import_node_crypto9 = require("crypto");
29942
+ var import_node_crypto10 = require("crypto");
29799
29943
  var AcpDriver = class {
29800
29944
  constructor(deps) {
29801
29945
  this.deps = deps;
@@ -29888,7 +30032,7 @@ var AcpDriver = class {
29888
30032
  currentIndex: 0,
29889
30033
  done: true
29890
30034
  }),
29891
- publishAwaitingAnswer: (prompt, options) => publisher.publishAwaitingAnswer({ questionId: (0, import_node_crypto9.randomUUID)(), prompt, options }),
30035
+ publishAwaitingAnswer: (prompt, options) => publisher.publishAwaitingAnswer({ questionId: (0, import_node_crypto10.randomUUID)(), prompt, options }),
29892
30036
  publishRawChunk: (chunk) => publisher.publishOutput(chunk),
29893
30037
  sendResult: (commandId, status2, result) => relay.sendResult(commandId, status2, result),
29894
30038
  appendAgentReply: (text) => history.appendAgentReply(text),
@@ -29931,7 +30075,7 @@ var AcpDriver = class {
29931
30075
  };
29932
30076
 
29933
30077
  // src/baton/transcript-mirror.ts
29934
- var fs59 = __toESM(require("fs"));
30078
+ var fs60 = __toESM(require("fs"));
29935
30079
  var TranscriptMirror = class {
29936
30080
  constructor(deps) {
29937
30081
  this.deps = deps;
@@ -29998,7 +30142,7 @@ var TranscriptMirror = class {
29998
30142
  }
29999
30143
  };
30000
30144
  function defaultWatch(file, onChange) {
30001
- const w3 = fs59.watch(file, { persistent: false }, () => onChange());
30145
+ const w3 = fs60.watch(file, { persistent: false }, () => onChange());
30002
30146
  return () => w3.close();
30003
30147
  }
30004
30148
 
@@ -30245,15 +30389,15 @@ function toEpochMs(ts) {
30245
30389
  }
30246
30390
 
30247
30391
  // src/agents/claude/onboarding.ts
30248
- var fs60 = __toESM(require("fs"));
30249
- var os46 = __toESM(require("os"));
30250
- var path63 = __toESM(require("path"));
30392
+ var fs61 = __toESM(require("fs"));
30393
+ var os47 = __toESM(require("os"));
30394
+ var path64 = __toESM(require("path"));
30251
30395
  function ensureClaudeOnboarded() {
30252
30396
  try {
30253
- const file = path63.join(os46.homedir(), ".claude.json");
30397
+ const file = path64.join(os47.homedir(), ".claude.json");
30254
30398
  let config = {};
30255
30399
  try {
30256
- config = JSON.parse(fs60.readFileSync(file, "utf8"));
30400
+ config = JSON.parse(fs61.readFileSync(file, "utf8"));
30257
30401
  } catch {
30258
30402
  }
30259
30403
  if (config.hasCompletedOnboarding === true && typeof config.theme === "string") {
@@ -30264,8 +30408,8 @@ function ensureClaudeOnboarded() {
30264
30408
  if (typeof config.lastOnboardingVersion !== "string") {
30265
30409
  config.lastOnboardingVersion = "2.1.177";
30266
30410
  }
30267
- fs60.mkdirSync(path63.dirname(file), { recursive: true });
30268
- fs60.writeFileSync(file, JSON.stringify(config, null, 2));
30411
+ fs61.mkdirSync(path64.dirname(file), { recursive: true });
30412
+ fs61.writeFileSync(file, JSON.stringify(config, null, 2));
30269
30413
  log.info("claude", "pre-completed Claude onboarding (skip first-run theme picker)");
30270
30414
  } catch (err) {
30271
30415
  log.warn("claude", `ensureClaudeOnboarded failed (non-fatal): ${err.message}`);
@@ -30939,7 +31083,7 @@ var import_picocolors11 = __toESM(require("picocolors"));
30939
31083
  var import_child_process28 = require("child_process");
30940
31084
  var import_util4 = require("util");
30941
31085
  var import_picocolors9 = __toESM(require("picocolors"));
30942
- var path64 = __toESM(require("path"));
31086
+ var path65 = __toESM(require("path"));
30943
31087
  var execFileP6 = (0, import_util4.promisify)(import_child_process28.execFile);
30944
31088
  var MAX_BUFFER = 8 * 1024 * 1024;
30945
31089
  function resetStdinForChild() {
@@ -31428,7 +31572,7 @@ var GitHubCodespacesProvider = class {
31428
31572
  });
31429
31573
  }
31430
31574
  async uploadFile(workspaceId, remotePath, contents, options = {}) {
31431
- const remoteDir = path64.posix.dirname(remotePath);
31575
+ const remoteDir = path65.posix.dirname(remotePath);
31432
31576
  const parts = [
31433
31577
  `mkdir -p ${shellQuote(remoteDir)}`,
31434
31578
  `cat > ${shellQuote(remotePath)}`
@@ -31498,7 +31642,7 @@ function shellQuote(s) {
31498
31642
  // src/services/providers/gitpod.ts
31499
31643
  var import_child_process29 = require("child_process");
31500
31644
  var import_util5 = require("util");
31501
- var path65 = __toESM(require("path"));
31645
+ var path66 = __toESM(require("path"));
31502
31646
  var import_picocolors10 = __toESM(require("picocolors"));
31503
31647
  var execFileP7 = (0, import_util5.promisify)(import_child_process29.execFile);
31504
31648
  var MAX_BUFFER2 = 8 * 1024 * 1024;
@@ -31738,7 +31882,7 @@ var GitpodProvider = class {
31738
31882
  });
31739
31883
  }
31740
31884
  async uploadFile(workspaceId, remotePath, contents, options = {}) {
31741
- const remoteDir = path65.posix.dirname(remotePath);
31885
+ const remoteDir = path66.posix.dirname(remotePath);
31742
31886
  const parts = [
31743
31887
  `mkdir -p ${shellQuote2(remoteDir)}`,
31744
31888
  `cat > ${shellQuote2(remotePath)}`
@@ -31774,7 +31918,7 @@ function shellQuote2(s) {
31774
31918
  // src/services/providers/gitlab-workspaces.ts
31775
31919
  var import_child_process30 = require("child_process");
31776
31920
  var import_util6 = require("util");
31777
- var path66 = __toESM(require("path"));
31921
+ var path67 = __toESM(require("path"));
31778
31922
  var execFileP8 = (0, import_util6.promisify)(import_child_process30.execFile);
31779
31923
  var MAX_BUFFER3 = 8 * 1024 * 1024;
31780
31924
  var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
@@ -32034,7 +32178,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
32034
32178
  }
32035
32179
  async uploadFile(workspaceId, remotePath, contents, options = {}) {
32036
32180
  const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
32037
- const remoteDir = path66.posix.dirname(remotePath);
32181
+ const remoteDir = path67.posix.dirname(remotePath);
32038
32182
  const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
32039
32183
  if (options.mode != null) {
32040
32184
  parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
@@ -32102,7 +32246,7 @@ function shellQuote3(s) {
32102
32246
  // src/services/providers/railway.ts
32103
32247
  var import_child_process31 = require("child_process");
32104
32248
  var import_util7 = require("util");
32105
- var path67 = __toESM(require("path"));
32249
+ var path68 = __toESM(require("path"));
32106
32250
  var execFileP9 = (0, import_util7.promisify)(import_child_process31.execFile);
32107
32251
  var MAX_BUFFER4 = 8 * 1024 * 1024;
32108
32252
  function resetStdinForChild4() {
@@ -32338,7 +32482,7 @@ var RailwayProvider = class {
32338
32482
  if (!projectId || !serviceId) {
32339
32483
  throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
32340
32484
  }
32341
- const remoteDir = path67.posix.dirname(remotePath);
32485
+ const remoteDir = path68.posix.dirname(remotePath);
32342
32486
  const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
32343
32487
  if (options.mode != null) {
32344
32488
  parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
@@ -32983,9 +33127,9 @@ async function invite() {
32983
33127
  // src/commands/doctor.ts
32984
33128
  var import_node_dns = require("dns");
32985
33129
  var import_node_util5 = require("util");
32986
- var import_node_crypto10 = require("crypto");
32987
- var fs61 = __toESM(require("fs"));
32988
- var path68 = __toESM(require("path"));
33130
+ var import_node_crypto11 = require("crypto");
33131
+ var fs62 = __toESM(require("fs"));
33132
+ var path69 = __toESM(require("path"));
32989
33133
  var import_picocolors14 = __toESM(require("picocolors"));
32990
33134
  var dnsResolveP = (0, import_node_util5.promisify)(import_node_dns.resolve);
32991
33135
  async function checkDns(apiBase2) {
@@ -33041,13 +33185,13 @@ async function checkHealth(apiBase2) {
33041
33185
  }
33042
33186
  }
33043
33187
  function checkConfigDir() {
33044
- const dir = path68.join(require("os").homedir(), ".codeam");
33188
+ const dir = path69.join(require("os").homedir(), ".codeam");
33045
33189
  try {
33046
- fs61.mkdirSync(dir, { recursive: true, mode: 448 });
33047
- const probe = path68.join(dir, ".doctor-probe");
33048
- fs61.writeFileSync(probe, "ok", { mode: 384 });
33049
- const read2 = fs61.readFileSync(probe, "utf8");
33050
- fs61.unlinkSync(probe);
33190
+ fs62.mkdirSync(dir, { recursive: true, mode: 448 });
33191
+ const probe = path69.join(dir, ".doctor-probe");
33192
+ fs62.writeFileSync(probe, "ok", { mode: 384 });
33193
+ const read2 = fs62.readFileSync(probe, "utf8");
33194
+ fs62.unlinkSync(probe);
33051
33195
  if (read2 !== "ok") throw new Error("write/read round-trip mismatch");
33052
33196
  return {
33053
33197
  id: "config-dir",
@@ -33087,9 +33231,9 @@ function checkSessions() {
33087
33231
  }
33088
33232
  }
33089
33233
  function checkAgentBinaries() {
33090
- const os48 = createOsStrategy();
33234
+ const os49 = createOsStrategy();
33091
33235
  return getEnabledAgents().map((meta) => {
33092
- const found = os48.findInPath(meta.binaryName);
33236
+ const found = os49.findInPath(meta.binaryName);
33093
33237
  return {
33094
33238
  id: `agent-${meta.id}`,
33095
33239
  label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
@@ -33111,7 +33255,7 @@ function checkNodePty() {
33111
33255
  detail: "not required on this platform"
33112
33256
  };
33113
33257
  }
33114
- const vendoredPath = path68.join(__dirname, "vendor", "node-pty");
33258
+ const vendoredPath = path69.join(__dirname, "vendor", "node-pty");
33115
33259
  for (const target of [vendoredPath, "node-pty"]) {
33116
33260
  try {
33117
33261
  require(target);
@@ -33153,9 +33297,9 @@ function checkChokidar() {
33153
33297
  }
33154
33298
  async function doctor(args2 = []) {
33155
33299
  const json = args2.includes("--json");
33156
- const cliVersion = true ? "2.60.14" : "0.0.0-dev";
33300
+ const cliVersion = true ? "2.60.16" : "0.0.0-dev";
33157
33301
  const apiBase2 = resolveApiBaseUrl();
33158
- const diagnosticId = (0, import_node_crypto10.randomUUID)();
33302
+ const diagnosticId = (0, import_node_crypto11.randomUUID)();
33159
33303
  log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
33160
33304
  const [dns, health] = await Promise.all([
33161
33305
  checkDns(apiBase2),
@@ -33352,7 +33496,7 @@ async function completion(args2) {
33352
33496
  // src/commands/version.ts
33353
33497
  var import_picocolors15 = __toESM(require("picocolors"));
33354
33498
  function version2() {
33355
- const v = true ? "2.60.14" : "unknown";
33499
+ const v = true ? "2.60.16" : "unknown";
33356
33500
  console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
33357
33501
  }
33358
33502
 
@@ -33501,10 +33645,10 @@ var EXIT_CODE_NAMES = {
33501
33645
  };
33502
33646
 
33503
33647
  // src/index.ts
33504
- var os47 = __toESM(require("os"));
33648
+ var os48 = __toESM(require("os"));
33505
33649
  if (!process.env.HOME) {
33506
33650
  try {
33507
- const home = os47.homedir();
33651
+ const home = os48.homedir();
33508
33652
  if (home) process.env.HOME = home;
33509
33653
  } catch {
33510
33654
  }