codeam-cli 2.76.11 → 2.76.13

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 +16 -0
  2. package/dist/index.js +909 -549
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -357,8 +357,8 @@ function defaultSpawn(timeoutMs) {
357
357
  });
358
358
  }
359
359
  function resolveConvexBin(cwd) {
360
- const local = path110.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "convex.cmd" : "convex");
361
- if (fs96.existsSync(local)) return { cmd: local, args: [] };
360
+ const local = path112.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "convex.cmd" : "convex");
361
+ if (fs98.existsSync(local)) return { cmd: local, args: [] };
362
362
  return { cmd: "npx", args: ["--yes", "convex"] };
363
363
  }
364
364
  function redact(text, key) {
@@ -489,13 +489,13 @@ async function runConvexAdminMcp(client3, id) {
489
489
  });
490
490
  await server.connect(new StdioServerTransport());
491
491
  }
492
- var import_node_child_process38, fs96, path110, TOOLS;
492
+ var import_node_child_process38, fs98, path112, TOOLS;
493
493
  var init_convex_admin_mcp = __esm({
494
494
  "src/integrations/convex-admin-mcp.ts"() {
495
495
  "use strict";
496
496
  import_node_child_process38 = require("child_process");
497
- fs96 = __toESM(require("fs"));
498
- path110 = __toESM(require("path"));
497
+ fs98 = __toESM(require("fs"));
498
+ path112 = __toESM(require("path"));
499
499
  TOOLS = [
500
500
  {
501
501
  name: "tables",
@@ -3595,11 +3595,11 @@ function quiet(fn) {
3595
3595
  log.debug(TAG, "ignored sync error", err);
3596
3596
  }
3597
3597
  }
3598
- function rmIfExistsQuiet(path112) {
3598
+ function rmIfExistsQuiet(path114) {
3599
3599
  try {
3600
- fs2.rmSync(path112, { force: true });
3600
+ fs2.rmSync(path114, { force: true });
3601
3601
  } catch (err) {
3602
- log.debug(TAG, `rmIfExists failed for ${path112}`, err);
3602
+ log.debug(TAG, `rmIfExists failed for ${path114}`, err);
3603
3603
  }
3604
3604
  }
3605
3605
  function killQuiet(target, signal = "SIGTERM") {
@@ -3765,9 +3765,9 @@ var _default = makeConfig();
3765
3765
  var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, setSessionAgent, setSquadAuto, getSquadAuto, clearAll, saveCliConfig, loadCliConfig } = _default;
3766
3766
 
3767
3767
  // src/commands/pair-auto.ts
3768
- var fs64 = __toESM(require("fs"));
3769
- var os47 = __toESM(require("os"));
3770
- var path73 = __toESM(require("path"));
3768
+ var fs65 = __toESM(require("fs"));
3769
+ var os48 = __toESM(require("os"));
3770
+ var path74 = __toESM(require("path"));
3771
3771
  var import_crypto4 = require("crypto");
3772
3772
 
3773
3773
  // src/services/telemetry.service.ts
@@ -3803,8 +3803,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
3803
3803
  return decodedFile;
3804
3804
  };
3805
3805
  }
3806
- function normalizeWindowsPath(path112) {
3807
- return path112.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
3806
+ function normalizeWindowsPath(path114) {
3807
+ return path114.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
3808
3808
  }
3809
3809
 
3810
3810
  // ../../node_modules/@posthog/core/dist/error-tracking/index.mjs
@@ -6537,13 +6537,13 @@ var PostHogCoreStateless = class {
6537
6537
  sentFromRoute += batchMessages.length;
6538
6538
  }
6539
6539
  }
6540
- async _sendOtlpBatch({ path: path112, payload }) {
6540
+ async _sendOtlpBatch({ path: path114, payload }) {
6541
6541
  if (this.disabled) return {
6542
6542
  kind: "fatal",
6543
6543
  error: new Error("The client is disabled")
6544
6544
  };
6545
6545
  const serialized = JSON.stringify(payload);
6546
- const url2 = `${this.host}/i/v1/${path112}?token=${encodeURIComponent(this.apiKey)}`;
6546
+ const url2 = `${this.host}/i/v1/${path114}?token=${encodeURIComponent(this.apiKey)}`;
6547
6547
  const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
6548
6548
  const fetchOptions = {
6549
6549
  method: "POST",
@@ -7783,14 +7783,14 @@ async function addSourceContext(frames, openSourceFile = import_promises.open, l
7783
7783
  LRU_FILE_CONTENTS_CACHE.reduce();
7784
7784
  return frames;
7785
7785
  }
7786
- async function openRegularSourceFile(path112, openSourceFile, logger) {
7786
+ async function openRegularSourceFile(path114, openSourceFile, logger) {
7787
7787
  let fileHandle;
7788
7788
  let isValid = false;
7789
7789
  try {
7790
- fileHandle = await openSourceFile(path112, import_node_fs.constants.O_RDONLY | import_node_fs.constants.O_NONBLOCK);
7790
+ fileHandle = await openSourceFile(path114, import_node_fs.constants.O_RDONLY | import_node_fs.constants.O_NONBLOCK);
7791
7791
  const fileStat = await fileHandle.stat();
7792
7792
  if (!fileStat.isFile()) return;
7793
- if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${path112}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
7793
+ if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${path114}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
7794
7794
  isValid = true;
7795
7795
  return fileHandle;
7796
7796
  } catch {
@@ -7800,8 +7800,8 @@ async function openRegularSourceFile(path112, openSourceFile, logger) {
7800
7800
  });
7801
7801
  }
7802
7802
  }
7803
- async function getContextLinesFromFile(path112, ranges, output, cacheKey, openSourceFile, logger) {
7804
- const fileHandle = await openRegularSourceFile(path112, openSourceFile, logger);
7803
+ async function getContextLinesFromFile(path114, ranges, output, cacheKey, openSourceFile, logger) {
7804
+ const fileHandle = await openRegularSourceFile(path114, openSourceFile, logger);
7805
7805
  if (void 0 === fileHandle) return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
7806
7806
  const openedFileHandle = fileHandle;
7807
7807
  return new Promise((resolve14) => {
@@ -7903,22 +7903,22 @@ function clearLineContext(frame) {
7903
7903
  delete frame.context_line;
7904
7904
  delete frame.post_context;
7905
7905
  }
7906
- function shouldSkipContextLinesForFile(path112) {
7907
- return path112.startsWith("node:") || path112.endsWith(".min.js") || path112.endsWith(".min.cjs") || path112.endsWith(".min.mjs") || path112.startsWith("data:");
7906
+ function shouldSkipContextLinesForFile(path114) {
7907
+ return path114.startsWith("node:") || path114.endsWith(".min.js") || path114.endsWith(".min.cjs") || path114.endsWith(".min.mjs") || path114.startsWith("data:");
7908
7908
  }
7909
7909
  function shouldSkipContextLinesForFrame(frame) {
7910
7910
  if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
7911
7911
  if (void 0 !== frame.colno && frame.colno > MAX_CONTEXTLINES_COLNO) return true;
7912
7912
  return false;
7913
7913
  }
7914
- function makeSourceCacheKey(path112, basePath) {
7915
- if ((0, import_node_path.isAbsolute)(path112)) return JSON.stringify([
7914
+ function makeSourceCacheKey(path114, basePath) {
7915
+ if ((0, import_node_path.isAbsolute)(path114)) return JSON.stringify([
7916
7916
  null,
7917
- path112
7917
+ path114
7918
7918
  ]);
7919
7919
  return void 0 === basePath ? void 0 : JSON.stringify([
7920
7920
  basePath,
7921
- path112
7921
+ path114
7922
7922
  ]);
7923
7923
  }
7924
7924
  function rangeExistsInContentCache(cacheKey, range) {
@@ -10579,7 +10579,7 @@ function readAnonId() {
10579
10579
  }
10580
10580
  function superProperties() {
10581
10581
  return {
10582
- cliVersion: true ? "2.76.11" : "0.0.0-dev",
10582
+ cliVersion: true ? "2.76.13" : "0.0.0-dev",
10583
10583
  nodeVersion: process.version,
10584
10584
  platform: process.platform,
10585
10585
  arch: process.arch,
@@ -10824,7 +10824,7 @@ var http = __toESM(require("http"));
10824
10824
  // package.json
10825
10825
  var package_default = {
10826
10826
  name: "codeam-cli",
10827
- version: "2.76.11",
10827
+ version: "2.76.13",
10828
10828
  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.",
10829
10829
  type: "commonjs",
10830
10830
  main: "dist/index.js",
@@ -12160,7 +12160,7 @@ var CommandRelayService = class _CommandRelayService {
12160
12160
  // fresh + clear the "CLI update available" banner after a self-update
12161
12161
  // (a codespace that reinstalls @latest reconnects via heartbeat, not
12162
12162
  // pair/reconnect). Older backends ignore the extra field.
12163
- ..."2.76.11" ? { ideVersion: "2.76.11" } : {}
12163
+ ..."2.76.13" ? { ideVersion: "2.76.13" } : {}
12164
12164
  };
12165
12165
  try {
12166
12166
  const res = await _postJson(`${API_BASE2}/api/plugin/heartbeat`, body);
@@ -13636,9 +13636,9 @@ function closeAllTerminals() {
13636
13636
  }
13637
13637
 
13638
13638
  // src/commands/start/handlers.ts
13639
- var fs63 = __toESM(require("fs"));
13640
- var os46 = __toESM(require("os"));
13641
- var path72 = __toESM(require("path"));
13639
+ var fs64 = __toESM(require("fs"));
13640
+ var os47 = __toESM(require("os"));
13641
+ var path73 = __toESM(require("path"));
13642
13642
  var import_crypto3 = require("crypto");
13643
13643
  var import_child_process25 = require("child_process");
13644
13644
 
@@ -17237,10 +17237,10 @@ function buildForPlatform(platform3) {
17237
17237
  var import_node_crypto5 = require("crypto");
17238
17238
 
17239
17239
  // src/agents/claude/resolver.ts
17240
- function buildClaudeLaunch(extraArgs = [], os72 = createOsStrategy()) {
17241
- const found = os72.findInPath("claude") ?? os72.findInPath("claude-code");
17240
+ function buildClaudeLaunch(extraArgs = [], os74 = createOsStrategy()) {
17241
+ const found = os74.findInPath("claude") ?? os74.findInPath("claude-code");
17242
17242
  if (!found) return null;
17243
- return os72.buildLaunch(found, extraArgs);
17243
+ return os74.buildLaunch(found, extraArgs);
17244
17244
  }
17245
17245
 
17246
17246
  // src/agents/claude/installer.ts
@@ -18066,8 +18066,8 @@ var ClaudeRuntimeStrategy = class {
18066
18066
  meta = getAgent("claude");
18067
18067
  mode = "interactive";
18068
18068
  os;
18069
- constructor(os72) {
18070
- this.os = os72;
18069
+ constructor(os74) {
18070
+ this.os = os74;
18071
18071
  }
18072
18072
  /**
18073
18073
  * Claude Code's react-ink TUI enables bracketed-paste mode at
@@ -19167,8 +19167,8 @@ function codexCredentialLocator() {
19167
19167
  function codexLoginLauncher() {
19168
19168
  return {
19169
19169
  async ensureInstalled() {
19170
- const os72 = createOsStrategy();
19171
- return os72.findInPath("codex") !== null;
19170
+ const os74 = createOsStrategy();
19171
+ return os74.findInPath("codex") !== null;
19172
19172
  },
19173
19173
  launch() {
19174
19174
  return (0, import_node_child_process3.spawn)("codex", ["login"], { stdio: "inherit" });
@@ -19191,8 +19191,8 @@ var CodexRuntimeStrategy = class {
19191
19191
  meta = getAgent("codex");
19192
19192
  mode = "interactive";
19193
19193
  os;
19194
- constructor(os72) {
19195
- this.os = os72;
19194
+ constructor(os74) {
19195
+ this.os = os74;
19196
19196
  }
19197
19197
  async prepareLaunch() {
19198
19198
  let binary = this.os.findInPath("codex");
@@ -19303,12 +19303,12 @@ var CodexRuntimeStrategy = class {
19303
19303
  });
19304
19304
  }
19305
19305
  };
19306
- function resolveNpm(os72) {
19307
- return os72.id === "win32" ? "npm.cmd" : "npm";
19306
+ function resolveNpm(os74) {
19307
+ return os74.id === "win32" ? "npm.cmd" : "npm";
19308
19308
  }
19309
- async function installCodexViaNpm(os72) {
19309
+ async function installCodexViaNpm(os74) {
19310
19310
  return new Promise((resolve14, reject) => {
19311
- const proc = (0, import_node_child_process4.spawn)(resolveNpm(os72), ["install", "-g", "@openai/codex"], {
19311
+ const proc = (0, import_node_child_process4.spawn)(resolveNpm(os74), ["install", "-g", "@openai/codex"], {
19312
19312
  stdio: "inherit"
19313
19313
  });
19314
19314
  proc.on("close", (code) => {
@@ -19325,16 +19325,16 @@ async function installCodexViaNpm(os72) {
19325
19325
  });
19326
19326
  });
19327
19327
  }
19328
- function augmentNpmGlobalBin(os72) {
19328
+ function augmentNpmGlobalBin(os74) {
19329
19329
  try {
19330
- const result = (0, import_node_child_process4.spawnSync)(resolveNpm(os72), ["prefix", "-g"], {
19330
+ const result = (0, import_node_child_process4.spawnSync)(resolveNpm(os74), ["prefix", "-g"], {
19331
19331
  stdio: ["ignore", "pipe", "ignore"]
19332
19332
  });
19333
19333
  if (result.status !== 0) return;
19334
19334
  const prefix = result.stdout.toString().trim();
19335
19335
  if (!prefix) return;
19336
- const binDir = os72.id === "win32" ? prefix : path26.join(prefix, "bin");
19337
- os72.augmentPath([binDir]);
19336
+ const binDir = os74.id === "win32" ? prefix : path26.join(prefix, "bin");
19337
+ os74.augmentPath([binDir]);
19338
19338
  } catch {
19339
19339
  }
19340
19340
  }
@@ -19528,10 +19528,10 @@ function manualInstallHint(runner, tools) {
19528
19528
  const argv = osPackageInstallArgv(detectPackageManager(runner), [...tools]);
19529
19529
  return argv ? `\`sudo ${argv.join(" ")}\`` : `your package manager (e.g. \`${pkgs}\`)`;
19530
19530
  }
19531
- function writeUnzipShim(os72, runner) {
19531
+ function writeUnzipShim(os74, runner) {
19532
19532
  const python = ["python3", "python"].find((p2) => runner.which(p2));
19533
19533
  if (!python) return null;
19534
- const dir = os72.scratchPath("codeam-cr-prereq");
19534
+ const dir = os74.scratchPath("codeam-cr-prereq");
19535
19535
  const shim = path28.join(dir, "unzip");
19536
19536
  const script = `#!/bin/sh
19537
19537
  set -e
@@ -19553,9 +19553,9 @@ exec ${python} -m zipfile -e "$archive" "$dest"
19553
19553
  (0, import_node_fs6.chmodSync)(shim, 448);
19554
19554
  return dir;
19555
19555
  }
19556
- async function ensureInstallPrerequisites(os72, deps = {}) {
19556
+ async function ensureInstallPrerequisites(os74, deps = {}) {
19557
19557
  const runner = deps.runner ?? defaultOsRunner;
19558
- const missing = REQUIRED_TOOLS.filter((t2) => os72.findInPath(t2) === null);
19558
+ const missing = REQUIRED_TOOLS.filter((t2) => os74.findInPath(t2) === null);
19559
19559
  if (missing.length === 0) return { ok: true, extraPath: [] };
19560
19560
  log.info(
19561
19561
  "coderabbit",
@@ -19574,10 +19574,10 @@ async function ensureInstallPrerequisites(os72, deps = {}) {
19574
19574
  );
19575
19575
  }
19576
19576
  }
19577
- const stillMissing = REQUIRED_TOOLS.filter((t2) => os72.findInPath(t2) === null);
19577
+ const stillMissing = REQUIRED_TOOLS.filter((t2) => os74.findInPath(t2) === null);
19578
19578
  if (stillMissing.length === 0) return { ok: true, extraPath: [] };
19579
19579
  if (stillMissing.length === 1 && stillMissing[0] === "unzip") {
19580
- const shimDir = writeUnzipShim(os72, runner);
19580
+ const shimDir = writeUnzipShim(os74, runner);
19581
19581
  if (shimDir) {
19582
19582
  log.info("coderabbit", "unzip is unavailable \u2014 using a scoped python zipfile shim");
19583
19583
  return { ok: true, extraPath: [shimDir] };
@@ -19640,15 +19640,15 @@ function summarizeInstallFailure(output) {
19640
19640
  }
19641
19641
  return lines.length > 0 ? lines[lines.length - 1] : null;
19642
19642
  }
19643
- async function ensureCoderabbitInstalled(os72, deps = {}) {
19644
- if (os72.findInPath("coderabbit")) return { ok: true };
19645
- if (os72.id === "win32") {
19643
+ async function ensureCoderabbitInstalled(os74, deps = {}) {
19644
+ if (os74.findInPath("coderabbit")) return { ok: true };
19645
+ if (os74.id === "win32") {
19646
19646
  return {
19647
19647
  ok: false,
19648
19648
  error: "CodeRabbit on Windows requires WSL. Install the CLI inside your WSL distribution (curl -fsSL https://cli.coderabbit.ai/install.sh | sh), then try again."
19649
19649
  };
19650
19650
  }
19651
- const prereq = await ensureInstallPrerequisites(os72, deps);
19651
+ const prereq = await ensureInstallPrerequisites(os74, deps);
19652
19652
  if (!prereq.ok) return { ok: false, error: prereq.error };
19653
19653
  const env = { ...process.env };
19654
19654
  if (prereq.extraPath.length > 0) {
@@ -19657,8 +19657,8 @@ async function ensureCoderabbitInstalled(os72, deps = {}) {
19657
19657
  log.info("coderabbit", "CodeRabbit CLI not found \u2014 installing via the official script");
19658
19658
  const run3 = deps.runInstallScript ?? defaultRunInstallScript;
19659
19659
  const { code, output } = await run3(env);
19660
- os72.augmentPath([`${os72.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
19661
- const binary = os72.findInPath("coderabbit");
19660
+ os74.augmentPath([`${os74.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
19661
+ const binary = os74.findInPath("coderabbit");
19662
19662
  const detail = summarizeInstallFailure(output);
19663
19663
  if (binary !== null) {
19664
19664
  if (code === 0) return { ok: true };
@@ -19712,10 +19712,10 @@ function coderabbitCredentialLocator() {
19712
19712
  validate: validateNonEmptyCredential
19713
19713
  };
19714
19714
  }
19715
- function coderabbitLoginLauncher(os72) {
19715
+ function coderabbitLoginLauncher(os74) {
19716
19716
  return {
19717
19717
  async ensureInstalled() {
19718
- const result = await ensureCoderabbitInstalled(os72);
19718
+ const result = await ensureCoderabbitInstalled(os74);
19719
19719
  if (!result.ok && result.error) console.error(`
19720
19720
  \u2717 ${result.error}
19721
19721
  `);
@@ -19775,8 +19775,8 @@ function pickLine(obj) {
19775
19775
  function toHunk(raw, groupSeverity) {
19776
19776
  if (!raw || typeof raw !== "object") return null;
19777
19777
  const o = raw;
19778
- const path112 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
19779
- if (!path112) return null;
19778
+ const path114 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
19779
+ if (!path114) return null;
19780
19780
  const message = asString(
19781
19781
  pick(o, [
19782
19782
  "comment",
@@ -19793,7 +19793,7 @@ function toHunk(raw, groupSeverity) {
19793
19793
  const severity = normSeverity(pick(o, ["severity", "level", "priority", "impact"])) ?? normSeverity(groupSeverity);
19794
19794
  const locObj = pick(o, ["location"]) ?? o;
19795
19795
  return {
19796
- path: path112.trim(),
19796
+ path: path114.trim(),
19797
19797
  line: pickLine(o) ?? pickLine(locObj),
19798
19798
  severity,
19799
19799
  message: (title && message ? `${title}: ${message}` : title || message).trim() || "(no message)"
@@ -19876,10 +19876,10 @@ function parsePlain(stdout) {
19876
19876
  for (const line of stdout.split(/\r?\n/)) {
19877
19877
  const m = line.match(HUNK_LINE_RE);
19878
19878
  if (!m) continue;
19879
- const [, path112, lineNo, sevToken, message] = m;
19880
- if (!path112 || !lineNo || !message) continue;
19879
+ const [, path114, lineNo, sevToken, message] = m;
19880
+ if (!path114 || !lineNo || !message) continue;
19881
19881
  hunks.push({
19882
- path: path112.trim(),
19882
+ path: path114.trim(),
19883
19883
  line: Number(lineNo),
19884
19884
  severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
19885
19885
  message: message.trim().replace(/^[*-]\s+/, "")
@@ -19939,8 +19939,8 @@ var CoderabbitRuntimeStrategy = class {
19939
19939
  meta = getAgent("coderabbit");
19940
19940
  mode = "batch";
19941
19941
  os;
19942
- constructor(os72) {
19943
- this.os = os72;
19942
+ constructor(os74) {
19943
+ this.os = os74;
19944
19944
  }
19945
19945
  getDefaultArgs() {
19946
19946
  return ["review", "--agent"];
@@ -20211,10 +20211,10 @@ function cursorCredentialLocator() {
20211
20211
  validate: validateNonEmptyCredential
20212
20212
  };
20213
20213
  }
20214
- function cursorLoginLauncher(os72) {
20214
+ function cursorLoginLauncher(os74) {
20215
20215
  return {
20216
20216
  async ensureInstalled() {
20217
- if (os72.findInPath("cursor-agent")) return true;
20217
+ if (os74.findInPath("cursor-agent")) return true;
20218
20218
  console.error(
20219
20219
  "\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"
20220
20220
  );
@@ -20278,8 +20278,8 @@ var CursorRuntimeStrategy = class {
20278
20278
  meta = getAgent("cursor");
20279
20279
  mode = "interactive";
20280
20280
  os;
20281
- constructor(os72) {
20282
- this.os = os72;
20281
+ constructor(os74) {
20282
+ this.os = os74;
20283
20283
  }
20284
20284
  async prepareLaunch() {
20285
20285
  const binary = this.os.findInPath("cursor-agent");
@@ -20497,10 +20497,10 @@ function aiderCredentialLocator() {
20497
20497
  validate: validateNonEmptyCredential
20498
20498
  };
20499
20499
  }
20500
- function aiderLoginLauncher(os72) {
20500
+ function aiderLoginLauncher(os74) {
20501
20501
  return {
20502
20502
  async ensureInstalled() {
20503
- if (os72.findInPath("aider")) return true;
20503
+ if (os74.findInPath("aider")) return true;
20504
20504
  console.error(
20505
20505
  "\n \u2717 aider binary not on PATH.\n Install Aider:\n pip install aider-chat\n then re-run `codeam link aider`.\n"
20506
20506
  );
@@ -20510,7 +20510,7 @@ function aiderLoginLauncher(os72) {
20510
20510
  console.error(
20511
20511
  "\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"
20512
20512
  );
20513
- return (0, import_node_child_process11.spawn)(os72.id === "win32" ? "cmd.exe" : "sh", os72.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
20513
+ return (0, import_node_child_process11.spawn)(os74.id === "win32" ? "cmd.exe" : "sh", os74.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
20514
20514
  stdio: "ignore"
20515
20515
  });
20516
20516
  }
@@ -20629,6 +20629,15 @@ async function waitForClaudeNativeBinary(opts = {}) {
20629
20629
  }
20630
20630
  return resolveClaudeNativeBinary(deps);
20631
20631
  }
20632
+ function prefetchIntoPageCache(file, deps = {}) {
20633
+ const createReadStream2 = deps.createReadStream ?? import_fs.default.createReadStream;
20634
+ try {
20635
+ const stream = createReadStream2(file, { highWaterMark: 4 * 1024 * 1024 });
20636
+ stream.on("error", () => void 0);
20637
+ stream.resume();
20638
+ } catch {
20639
+ }
20640
+ }
20632
20641
  function isCommandOnPath(cmd, probe = defaultWhich) {
20633
20642
  return probe(cmd);
20634
20643
  }
@@ -20785,8 +20794,8 @@ var AiderRuntimeStrategy = class {
20785
20794
  meta = getAgent("aider");
20786
20795
  mode = "interactive";
20787
20796
  os;
20788
- constructor(os72) {
20789
- this.os = os72;
20797
+ constructor(os74) {
20798
+ this.os = os74;
20790
20799
  }
20791
20800
  async prepareLaunch() {
20792
20801
  augmentUserLocalBinPaths();
@@ -20919,8 +20928,8 @@ function geminiCredentialLocator() {
20919
20928
  function geminiLoginLauncher() {
20920
20929
  return {
20921
20930
  async ensureInstalled() {
20922
- const os72 = createOsStrategy();
20923
- return os72.findInPath("gemini") !== null;
20931
+ const os74 = createOsStrategy();
20932
+ return os74.findInPath("gemini") !== null;
20924
20933
  },
20925
20934
  launch() {
20926
20935
  return (0, import_node_child_process12.spawn)("gemini", ["auth", "login"], { stdio: "inherit" });
@@ -21110,8 +21119,8 @@ var GeminiRuntimeStrategy = class {
21110
21119
  meta = getAgent("gemini");
21111
21120
  mode = "interactive";
21112
21121
  os;
21113
- constructor(os72) {
21114
- this.os = os72;
21122
+ constructor(os74) {
21123
+ this.os = os74;
21115
21124
  }
21116
21125
  async prepareLaunch() {
21117
21126
  const binary = this.os.findInPath("gemini");
@@ -21404,8 +21413,8 @@ var KimiRuntimeStrategy = class {
21404
21413
  meta = getAgent("kimi");
21405
21414
  mode = "interactive";
21406
21415
  os;
21407
- constructor(os72) {
21408
- this.os = os72;
21416
+ constructor(os74) {
21417
+ this.os = os74;
21409
21418
  }
21410
21419
  async prepareLaunch() {
21411
21420
  const binary = this.os.findInPath("kimi");
@@ -21549,8 +21558,8 @@ var OpencodeRuntimeStrategy = class {
21549
21558
  meta = getAgent("opencode");
21550
21559
  mode = "interactive";
21551
21560
  os;
21552
- constructor(os72) {
21553
- this.os = os72;
21561
+ constructor(os74) {
21562
+ this.os = os74;
21554
21563
  }
21555
21564
  async prepareLaunch() {
21556
21565
  const binary = this.os.findInPath("opencode");
@@ -21636,20 +21645,20 @@ var OpencodeRuntimeStrategy = class {
21636
21645
 
21637
21646
  // src/agents/registry.ts
21638
21647
  var runtimeBuilders = {
21639
- claude: (os72) => new ClaudeRuntimeStrategy(os72),
21640
- codex: (os72) => new CodexRuntimeStrategy(os72),
21641
- coderabbit: (os72) => new CoderabbitRuntimeStrategy(os72),
21642
- cursor: (os72) => new CursorRuntimeStrategy(os72),
21643
- aider: (os72) => new AiderRuntimeStrategy(os72),
21644
- gemini: (os72) => new GeminiRuntimeStrategy(os72),
21645
- kimi: (os72) => new KimiRuntimeStrategy(os72),
21646
- opencode: (os72) => new OpencodeRuntimeStrategy(os72)
21648
+ claude: (os74) => new ClaudeRuntimeStrategy(os74),
21649
+ codex: (os74) => new CodexRuntimeStrategy(os74),
21650
+ coderabbit: (os74) => new CoderabbitRuntimeStrategy(os74),
21651
+ cursor: (os74) => new CursorRuntimeStrategy(os74),
21652
+ aider: (os74) => new AiderRuntimeStrategy(os74),
21653
+ gemini: (os74) => new GeminiRuntimeStrategy(os74),
21654
+ kimi: (os74) => new KimiRuntimeStrategy(os74),
21655
+ opencode: (os74) => new OpencodeRuntimeStrategy(os74)
21647
21656
  };
21648
21657
  var deployBuilders = {
21649
21658
  claude: () => new ClaudeDeployStrategy(),
21650
21659
  codex: () => new CodexDeployStrategy()
21651
21660
  };
21652
- function createAgentStrategy(agent, os72 = createOsStrategy()) {
21661
+ function createAgentStrategy(agent, os74 = createOsStrategy()) {
21653
21662
  if (!AGENT_REGISTRY[agent]?.enabled) {
21654
21663
  throw new Error(
21655
21664
  `Agent "${agent}" is not supported in this codeam-cli version. Upgrade with 'npm i -g codeam-cli@latest'.`
@@ -21659,10 +21668,10 @@ function createAgentStrategy(agent, os72 = createOsStrategy()) {
21659
21668
  if (!build) {
21660
21669
  throw new Error(`No runtime strategy registered for agent "${agent}"`);
21661
21670
  }
21662
- return build(os72);
21671
+ return build(os74);
21663
21672
  }
21664
- function createInteractiveAgentStrategy(agent, os72 = createOsStrategy()) {
21665
- const s = createAgentStrategy(agent, os72);
21673
+ function createInteractiveAgentStrategy(agent, os74 = createOsStrategy()) {
21674
+ const s = createAgentStrategy(agent, os74);
21666
21675
  if (s.mode !== "interactive") {
21667
21676
  throw new Error(
21668
21677
  `Agent "${agent}" is a batch agent; use createAgentStrategy + .runOneShot for one-shot reviews.`
@@ -22376,8 +22385,8 @@ function collectChangedFiles(cwd) {
22376
22385
  }
22377
22386
  return [...byPath.values()];
22378
22387
  }
22379
- function restoreCoderabbitOauthBlob(os72, value) {
22380
- const dir = path40.join(os72.homeDir(), ".coderabbit");
22388
+ function restoreCoderabbitOauthBlob(os74, value) {
22389
+ const dir = path40.join(os74.homeDir(), ".coderabbit");
22381
22390
  (0, import_node_fs7.mkdirSync)(dir, { recursive: true });
22382
22391
  let file = "auth.json";
22383
22392
  let contents = value.trim();
@@ -22397,26 +22406,26 @@ function installFailureMessage(result) {
22397
22406
  return result.error ?? "CodeRabbit CLI could not be installed";
22398
22407
  }
22399
22408
  async function configureCoderabbit(input, deps = {}) {
22400
- const os72 = deps.os ?? createOsStrategy();
22409
+ const os74 = deps.os ?? createOsStrategy();
22401
22410
  const ensureInstalled = deps.ensureInstalled ?? ensureCoderabbitInstalled;
22402
22411
  const isLoggedIn = deps.isLoggedIn ?? defaultIsLoggedIn;
22403
22412
  const runOAuth = deps.runOAuthLogin ?? runCoderabbitOAuthLogin;
22404
22413
  const snapshot = deps.snapshotDir ?? (() => snapshotCredentialDir());
22405
22414
  const capture2 = deps.captureCredential ?? ((b) => diffCapturedCredential(b));
22406
22415
  const loginWithApiKey = deps.loginWithApiKey ?? defaultLoginWithApiKey;
22407
- const home = os72.homeDir();
22408
- os72.augmentPath(
22409
- os72.id === "win32" ? [
22416
+ const home = os74.homeDir();
22417
+ os74.augmentPath(
22418
+ os74.id === "win32" ? [
22410
22419
  path40.join(home, ".local", "bin"),
22411
22420
  path40.join(process.env.APPDATA ?? path40.join(home, "AppData", "Roaming"), "npm"),
22412
22421
  path40.join(home, "scoop", "shims")
22413
22422
  ] : [path40.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"]
22414
22423
  );
22415
- const installed2 = os72.findInPath("coderabbit") !== null;
22424
+ const installed2 = os74.findInPath("coderabbit") !== null;
22416
22425
  const base = () => ({
22417
22426
  action: input.action,
22418
22427
  supported: true,
22419
- installed: os72.findInPath("coderabbit") !== null,
22428
+ installed: os74.findInPath("coderabbit") !== null,
22420
22429
  loggedIn: false
22421
22430
  });
22422
22431
  if (input.action === "status") {
@@ -22430,7 +22439,7 @@ async function configureCoderabbit(input, deps = {}) {
22430
22439
  const key = (input.apiKey ?? "").trim();
22431
22440
  if (!key) return { ...res2, error: "No API key provided" };
22432
22441
  if (!res2.installed) {
22433
- const inst = await ensureInstalled(os72);
22442
+ const inst = await ensureInstalled(os74);
22434
22443
  res2.installed = inst.ok;
22435
22444
  if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
22436
22445
  }
@@ -22454,7 +22463,7 @@ async function configureCoderabbit(input, deps = {}) {
22454
22463
  }
22455
22464
  if (!res2.installed) {
22456
22465
  deps.onEvent?.({ kind: "installing" });
22457
- const inst = await ensureInstalled(os72);
22466
+ const inst = await ensureInstalled(os74);
22458
22467
  res2.installed = inst.ok;
22459
22468
  if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
22460
22469
  }
@@ -22471,7 +22480,7 @@ async function configureCoderabbit(input, deps = {}) {
22471
22480
  return { ...res2, loggedIn: true, linked: true };
22472
22481
  }
22473
22482
  try {
22474
- restoreCoderabbitOauthBlob(os72, cred.credential);
22483
+ restoreCoderabbitOauthBlob(os74, cred.credential);
22475
22484
  } catch (err) {
22476
22485
  return {
22477
22486
  ...res2,
@@ -22495,7 +22504,7 @@ async function configureCoderabbit(input, deps = {}) {
22495
22504
  const res2 = base();
22496
22505
  if (!installed2) {
22497
22506
  deps.onEvent?.({ kind: "installing" });
22498
- const inst = await ensureInstalled(os72);
22507
+ const inst = await ensureInstalled(os74);
22499
22508
  res2.installed = inst.ok;
22500
22509
  if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
22501
22510
  }
@@ -22535,7 +22544,7 @@ async function configureCoderabbit(input, deps = {}) {
22535
22544
  }
22536
22545
  const res = base();
22537
22546
  if (!res.installed) {
22538
- const inst = await ensureInstalled(os72);
22547
+ const inst = await ensureInstalled(os74);
22539
22548
  res.installed = inst.ok;
22540
22549
  if (!inst.ok) return { ...res, error: installFailureMessage(inst) };
22541
22550
  }
@@ -27400,11 +27409,11 @@ function resolveDoltInstallStrategy(platform3) {
27400
27409
  }
27401
27410
  var DOLT_RELEASE_BASE = "https://github.com/dolthub/dolt/releases/latest/download";
27402
27411
  function doltPlatformTuple(platform3, arch2) {
27403
- const os72 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
27412
+ const os74 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
27404
27413
  const a = arch2 === "x64" ? "amd64" : arch2 === "arm64" ? "arm64" : null;
27405
27414
  if (!a) return null;
27406
- if (os72 === "windows" && a !== "amd64") return null;
27407
- return `${os72}-${a}`;
27415
+ if (os74 === "windows" && a !== "amd64") return null;
27416
+ return `${os74}-${a}`;
27408
27417
  }
27409
27418
  function resolveDoltTarballStrategy(targetDir, platform3, arch2) {
27410
27419
  const tuple = doltPlatformTuple(platform3, arch2);
@@ -28285,6 +28294,82 @@ function persistBeadsConfig(cfg) {
28285
28294
  restrictToOwner(file);
28286
28295
  }
28287
28296
 
28297
+ // src/beads/provision-lock.ts
28298
+ var import_fs7 = __toESM(require("fs"));
28299
+ var import_os11 = __toESM(require("os"));
28300
+ var import_path9 = __toESM(require("path"));
28301
+ var STALE_LOCK_MS = 5 * 6e4;
28302
+ function pidIsAlive(pid) {
28303
+ try {
28304
+ process.kill(pid, 0);
28305
+ return true;
28306
+ } catch (err) {
28307
+ return err.code === "EPERM";
28308
+ }
28309
+ }
28310
+ function tryAcquire(lockDir, deps) {
28311
+ const pid = deps.pid ?? process.pid;
28312
+ try {
28313
+ import_fs7.default.mkdirSync(import_path9.default.dirname(lockDir), { recursive: true });
28314
+ import_fs7.default.mkdirSync(lockDir);
28315
+ import_fs7.default.writeFileSync(import_path9.default.join(lockDir, "pid"), String(pid));
28316
+ return true;
28317
+ } catch (err) {
28318
+ if (err.code !== "EEXIST") return true;
28319
+ }
28320
+ let age;
28321
+ try {
28322
+ age = (deps.now ?? Date.now)() - import_fs7.default.statSync(lockDir).mtimeMs;
28323
+ } catch {
28324
+ return tryAcquireOnce(lockDir, deps);
28325
+ }
28326
+ let holder = NaN;
28327
+ try {
28328
+ holder = Number(import_fs7.default.readFileSync(import_path9.default.join(lockDir, "pid"), "utf8"));
28329
+ } catch {
28330
+ if (age <= 1e4) return false;
28331
+ }
28332
+ const alive = Number.isInteger(holder) && (deps.isAlive ?? pidIsAlive)(holder);
28333
+ if (alive && age <= STALE_LOCK_MS) return false;
28334
+ try {
28335
+ import_fs7.default.rmSync(lockDir, { recursive: true, force: true });
28336
+ } catch {
28337
+ return false;
28338
+ }
28339
+ return tryAcquireOnce(lockDir, deps);
28340
+ }
28341
+ function tryAcquireOnce(lockDir, deps) {
28342
+ try {
28343
+ import_fs7.default.mkdirSync(lockDir);
28344
+ import_fs7.default.writeFileSync(import_path9.default.join(lockDir, "pid"), String(deps.pid ?? process.pid));
28345
+ return true;
28346
+ } catch {
28347
+ return false;
28348
+ }
28349
+ }
28350
+ async function withBeadsProvisionLock(fn, deps = {}) {
28351
+ const lockDir = import_path9.default.join(deps.dir ?? import_path9.default.join(import_os11.default.homedir(), ".codeam"), "beads-provision.lock");
28352
+ const now = deps.now ?? Date.now;
28353
+ const sleep5 = deps.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
28354
+ const deadline = now() + (deps.timeoutMs ?? 18e4);
28355
+ let held = tryAcquire(lockDir, deps);
28356
+ while (!held && now() < deadline) {
28357
+ await sleep5(500);
28358
+ held = tryAcquire(lockDir, deps);
28359
+ }
28360
+ try {
28361
+ return await fn();
28362
+ } finally {
28363
+ if (held) {
28364
+ try {
28365
+ const owner = Number(import_fs7.default.readFileSync(import_path9.default.join(lockDir, "pid"), "utf8"));
28366
+ if (owner === (deps.pid ?? process.pid)) import_fs7.default.rmSync(lockDir, { recursive: true, force: true });
28367
+ } catch {
28368
+ }
28369
+ }
28370
+ }
28371
+ }
28372
+
28288
28373
  // src/beads/wiring.ts
28289
28374
  function beadsKilled() {
28290
28375
  const v = process.env.CODEAM_BEADS_DISABLED;
@@ -28306,15 +28391,18 @@ async function provisionBeadsForStart(ctx) {
28306
28391
  return null;
28307
28392
  }
28308
28393
  const pluginAuthToken = ctx.pluginAuthToken;
28394
+ if (ctx.deferUntil) await ctx.deferUntil.catch(() => void 0);
28309
28395
  let started = null;
28310
28396
  try {
28311
- started = await startBeads({
28312
- sessionId: ctx.sessionId,
28313
- pluginId: ctx.pluginId,
28314
- pluginAuthToken,
28315
- cwd: ctx.cwd,
28316
- agents: ctx.agents
28317
- });
28397
+ started = await withBeadsProvisionLock(
28398
+ () => startBeads({
28399
+ sessionId: ctx.sessionId,
28400
+ pluginId: ctx.pluginId,
28401
+ pluginAuthToken,
28402
+ cwd: ctx.cwd,
28403
+ agents: ctx.agents
28404
+ })
28405
+ );
28318
28406
  } catch (err) {
28319
28407
  log.warn("beads", "provisionBeadsForStart failed (non-fatal)", err);
28320
28408
  started = null;
@@ -28550,8 +28638,8 @@ function cleanupAttachmentTempFiles() {
28550
28638
  function saveFilesTemp(files) {
28551
28639
  return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
28552
28640
  const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
28553
- const tmpPath = path72.join(os46.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
28554
- fs63.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
28641
+ const tmpPath = path73.join(os47.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
28642
+ fs64.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
28555
28643
  pendingAttachmentFiles.add(tmpPath);
28556
28644
  return tmpPath;
28557
28645
  });
@@ -28796,10 +28884,10 @@ var listFiles = async (ctx, cmd, parsed) => {
28796
28884
  await ctx.relay.sendResult(cmd.id, "completed", result);
28797
28885
  };
28798
28886
  var envReadH = async (ctx, cmd) => {
28799
- const envPath = path72.join(process.cwd(), ".env");
28887
+ const envPath = path73.join(process.cwd(), ".env");
28800
28888
  await restoreProjectEnvIfMissing(process.cwd(), ctx);
28801
28889
  try {
28802
- const raw = await fs63.promises.readFile(envPath, "utf8");
28890
+ const raw = await fs64.promises.readFile(envPath, "utf8");
28803
28891
  await ctx.relay.sendResult(cmd.id, "completed", {
28804
28892
  exists: true,
28805
28893
  vars: parseDotenv(raw)
@@ -28828,7 +28916,7 @@ var envParseH = async (ctx, cmd, parsed) => {
28828
28916
  const existing = /* @__PURE__ */ new Map();
28829
28917
  if (!replace) {
28830
28918
  try {
28831
- const raw = await fs63.promises.readFile(path72.join(process.cwd(), ".env"), "utf8");
28919
+ const raw = await fs64.promises.readFile(path73.join(process.cwd(), ".env"), "utf8");
28832
28920
  for (const v of parseDotenv(raw)) existing.set(v.key, v.value);
28833
28921
  } catch {
28834
28922
  }
@@ -28868,15 +28956,15 @@ var envWriteH = async (ctx, cmd, parsed) => {
28868
28956
  }
28869
28957
  seen2.add(v.key);
28870
28958
  }
28871
- const envPath = path72.join(process.cwd(), ".env");
28872
- const tmpPath = path72.join(process.cwd(), ".env.codeam.tmp");
28959
+ const envPath = path73.join(process.cwd(), ".env");
28960
+ const tmpPath = path73.join(process.cwd(), ".env.codeam.tmp");
28873
28961
  try {
28874
- await fs63.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
28875
- await fs63.promises.rename(tmpPath, envPath);
28962
+ await fs64.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
28963
+ await fs64.promises.rename(tmpPath, envPath);
28876
28964
  await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
28877
28965
  void syncProjectEnvUp(process.cwd(), ctx);
28878
28966
  } catch (err) {
28879
- await fs63.promises.rm(tmpPath, { force: true }).catch(() => void 0);
28967
+ await fs64.promises.rm(tmpPath, { force: true }).catch(() => void 0);
28880
28968
  await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
28881
28969
  }
28882
28970
  };
@@ -29102,7 +29190,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
29102
29190
  });
29103
29191
  const token = ctx.pluginAuthToken;
29104
29192
  void (async () => {
29105
- const os72 = createOsStrategy();
29193
+ const os74 = createOsStrategy();
29106
29194
  try {
29107
29195
  const report = await reviewPullRequest(
29108
29196
  {
@@ -29111,7 +29199,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
29111
29199
  baseBranch: parsed.baseBranch
29112
29200
  },
29113
29201
  {
29114
- runReview: (input) => new CoderabbitRuntimeStrategy(os72).runOneShot(input),
29202
+ runReview: (input) => new CoderabbitRuntimeStrategy(os74).runOneShot(input),
29115
29203
  runGh: (args2) => defaultRunGh(args2),
29116
29204
  postReport: async (r) => {
29117
29205
  if (!token) return;
@@ -29225,9 +29313,9 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
29225
29313
  function buildNpmInstallInvocation(opts) {
29226
29314
  const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
29227
29315
  const execPath = opts?.execPath ?? process.execPath;
29228
- const exists2 = opts?.existsSync ?? fs63.existsSync;
29316
+ const exists2 = opts?.existsSync ?? fs64.existsSync;
29229
29317
  const platform3 = opts?.platform ?? process.platform;
29230
- const p2 = platform3 === "win32" ? path72.win32 : path72.posix;
29318
+ const p2 = platform3 === "win32" ? path73.win32 : path73.posix;
29231
29319
  const normalized = entryScript.split(/[\\/]/).join("/");
29232
29320
  const marker = "/lib/node_modules/codeam-cli/";
29233
29321
  const markerIdx = normalized.indexOf(marker);
@@ -29246,7 +29334,7 @@ function isPermissionError(stderr) {
29246
29334
  function resolveGlobalNodeModulesDir(opts) {
29247
29335
  const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
29248
29336
  const platform3 = opts?.platform ?? process.platform;
29249
- const p2 = platform3 === "win32" ? path72.win32 : path72.posix;
29337
+ const p2 = platform3 === "win32" ? path73.win32 : path73.posix;
29250
29338
  const marker = "/lib/node_modules/codeam-cli/";
29251
29339
  const markerIdx = entryScript.split(/[\\/]/).join("/").indexOf(marker);
29252
29340
  if (markerIdx <= 0) return null;
@@ -29256,9 +29344,9 @@ function resolveGlobalNodeModulesDir(opts) {
29256
29344
  var STALE_STAGING_AGE_MS = CLI_UPDATE_INSTALL_TIMEOUT_MS;
29257
29345
  function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
29258
29346
  if (!nodeModulesDir) return 0;
29259
- const readdirSync18 = deps?.readdirSync ?? fs63.readdirSync;
29260
- const statSync17 = deps?.statSync ?? fs63.statSync;
29261
- const rmSync14 = deps?.rmSync ?? fs63.rmSync;
29347
+ const readdirSync18 = deps?.readdirSync ?? fs64.readdirSync;
29348
+ const statSync17 = deps?.statSync ?? fs64.statSync;
29349
+ const rmSync14 = deps?.rmSync ?? fs64.rmSync;
29262
29350
  let removed = 0;
29263
29351
  let entries2;
29264
29352
  try {
@@ -29268,7 +29356,7 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
29268
29356
  }
29269
29357
  for (const name of entries2) {
29270
29358
  if (!/^\.codeam-cli-/.test(name)) continue;
29271
- const full = path72.join(nodeModulesDir, name);
29359
+ const full = path73.join(nodeModulesDir, name);
29272
29360
  try {
29273
29361
  const st3 = statSync17(full);
29274
29362
  if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
@@ -30391,11 +30479,11 @@ function resolveTokenValue(args2) {
30391
30479
  }
30392
30480
  const fileFlag = args2.find((a) => a.startsWith("--token-file="));
30393
30481
  if (fileFlag) {
30394
- const path112 = fileFlag.slice("--token-file=".length);
30482
+ const path114 = fileFlag.slice("--token-file=".length);
30395
30483
  try {
30396
- const content = fs64.readFileSync(path112, "utf8").trim();
30397
- if (content.length === 0) fail(`--token-file ${path112} is empty`);
30398
- rmIfExistsQuiet(path112);
30484
+ const content = fs65.readFileSync(path114, "utf8").trim();
30485
+ if (content.length === 0) fail(`--token-file ${path114} is empty`);
30486
+ rmIfExistsQuiet(path114);
30399
30487
  return content;
30400
30488
  } catch (err) {
30401
30489
  fail(`Could not read --token-file: ${err.message}`);
@@ -30487,12 +30575,12 @@ async function claim(token, pluginId, pluginSecretHash) {
30487
30575
  }
30488
30576
  }
30489
30577
  function pairAutoLockPath() {
30490
- return path73.join(os47.homedir(), ".codeam", "pair-auto.lock");
30578
+ return path74.join(os48.homedir(), ".codeam", "pair-auto.lock");
30491
30579
  }
30492
30580
  var procRoot = "/proc";
30493
30581
  function readProcFile(rel) {
30494
30582
  try {
30495
- return fs64.readFileSync(path73.join(procRoot, rel), "utf8");
30583
+ return fs65.readFileSync(path74.join(procRoot, rel), "utf8");
30496
30584
  } catch {
30497
30585
  return void 0;
30498
30586
  }
@@ -30513,7 +30601,7 @@ function currentBootId() {
30513
30601
  function readLockRecord(lockPath) {
30514
30602
  let raw;
30515
30603
  try {
30516
- raw = fs64.readFileSync(lockPath, "utf8");
30604
+ raw = fs65.readFileSync(lockPath, "utf8");
30517
30605
  } catch {
30518
30606
  return void 0;
30519
30607
  }
@@ -30562,7 +30650,7 @@ function isLiveLockHolder(rec) {
30562
30650
  }
30563
30651
  function releaseOwnLock(lockPath) {
30564
30652
  try {
30565
- if (readLockRecord(lockPath)?.pid === process.pid) fs64.unlinkSync(lockPath);
30653
+ if (readLockRecord(lockPath)?.pid === process.pid) fs65.unlinkSync(lockPath);
30566
30654
  } catch {
30567
30655
  }
30568
30656
  }
@@ -30586,7 +30674,7 @@ function snapshotProcessTree(root) {
30586
30674
  const children = /* @__PURE__ */ new Map();
30587
30675
  let entries2 = [];
30588
30676
  try {
30589
- entries2 = fs64.readdirSync(procRoot).filter((e) => /^\d+$/.test(e));
30677
+ entries2 = fs65.readdirSync(procRoot).filter((e) => /^\d+$/.test(e));
30590
30678
  } catch {
30591
30679
  }
30592
30680
  for (const e of entries2) {
@@ -30621,18 +30709,18 @@ function signalProcessTree(refs, signal) {
30621
30709
  }
30622
30710
  function daemonLockPath(sessionId) {
30623
30711
  const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
30624
- return path73.join(os47.homedir(), ".codeam", `daemon-${safe}.lock`);
30712
+ return path74.join(os48.homedir(), ".codeam", `daemon-${safe}.lock`);
30625
30713
  }
30626
30714
  function acquireDaemonLock(sessionId) {
30627
30715
  const lockPath = daemonLockPath(sessionId);
30628
30716
  try {
30629
- fs64.mkdirSync(path73.dirname(lockPath), { recursive: true });
30717
+ fs65.mkdirSync(path74.dirname(lockPath), { recursive: true });
30630
30718
  try {
30631
- fs64.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
30719
+ fs65.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
30632
30720
  } catch (e) {
30633
30721
  if (e.code !== "EEXIST") throw e;
30634
30722
  if (isLiveLockHolder(readLockRecord(lockPath))) return false;
30635
- fs64.writeFileSync(lockPath, ownLockBody());
30723
+ fs65.writeFileSync(lockPath, ownLockBody());
30636
30724
  }
30637
30725
  const release3 = () => releaseOwnLock(lockPath);
30638
30726
  process.once("exit", release3);
@@ -30652,13 +30740,13 @@ function acquireDaemonLock(sessionId) {
30652
30740
  function acquireSingletonLock() {
30653
30741
  const lockPath = pairAutoLockPath();
30654
30742
  try {
30655
- fs64.mkdirSync(path73.dirname(lockPath), { recursive: true });
30743
+ fs65.mkdirSync(path74.dirname(lockPath), { recursive: true });
30656
30744
  try {
30657
- fs64.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
30745
+ fs65.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
30658
30746
  } catch (e) {
30659
30747
  if (e.code !== "EEXIST") throw e;
30660
30748
  if (isLiveLockHolder(readLockRecord(lockPath))) return false;
30661
- fs64.writeFileSync(lockPath, ownLockBody());
30749
+ fs65.writeFileSync(lockPath, ownLockBody());
30662
30750
  }
30663
30751
  process.once("exit", () => releaseOwnLock(lockPath));
30664
30752
  return true;
@@ -31075,7 +31163,7 @@ var AgentService = class _AgentService {
31075
31163
  };
31076
31164
 
31077
31165
  // src/agents/acp/adapters.ts
31078
- var path74 = __toESM(require("path"));
31166
+ var path75 = __toESM(require("path"));
31079
31167
 
31080
31168
  // src/agents/kimi/installer.ts
31081
31169
  var import_node_child_process25 = require("child_process");
@@ -31195,13 +31283,13 @@ function resolveBin(pkgName, binName) {
31195
31283
  try {
31196
31284
  const manifestPath = require_.resolve(`${pkgName}/package.json`);
31197
31285
  const manifest = require_(`${pkgName}/package.json`);
31198
- const pkgDir = path74.dirname(manifestPath);
31286
+ const pkgDir = path75.dirname(manifestPath);
31199
31287
  const bin = manifest.bin;
31200
31288
  if (!bin) return null;
31201
- if (typeof bin === "string") return path74.resolve(pkgDir, bin);
31289
+ if (typeof bin === "string") return path75.resolve(pkgDir, bin);
31202
31290
  const target = binName ?? Object.keys(bin)[0];
31203
31291
  if (!target || !bin[target]) return null;
31204
- return path74.resolve(pkgDir, bin[target]);
31292
+ return path75.resolve(pkgDir, bin[target]);
31205
31293
  } catch {
31206
31294
  return null;
31207
31295
  }
@@ -31380,11 +31468,89 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
31380
31468
  return null;
31381
31469
  }
31382
31470
 
31471
+ // src/commands/start/agent-startup-marks.ts
31472
+ var import_fs8 = __toESM(require("fs"));
31473
+ var import_os13 = __toESM(require("os"));
31474
+ var import_path10 = __toESM(require("path"));
31475
+ var STALE_MARK_MS = 18e4;
31476
+ function marksDir(deps) {
31477
+ return deps.dir ?? import_path10.default.join(import_os13.default.homedir(), ".codeam", "agent-startups");
31478
+ }
31479
+ function pidIsAlive2(pid) {
31480
+ try {
31481
+ process.kill(pid, 0);
31482
+ return true;
31483
+ } catch (err) {
31484
+ return err.code === "EPERM";
31485
+ }
31486
+ }
31487
+ function markAgentStarting(deps = {}) {
31488
+ const file = import_path10.default.join(marksDir(deps), String(deps.pid ?? process.pid));
31489
+ try {
31490
+ import_fs8.default.mkdirSync(import_path10.default.dirname(file), { recursive: true });
31491
+ import_fs8.default.writeFileSync(file, "");
31492
+ } catch {
31493
+ return () => void 0;
31494
+ }
31495
+ let released = false;
31496
+ return () => {
31497
+ if (released) return;
31498
+ released = true;
31499
+ try {
31500
+ import_fs8.default.rmSync(file, { force: true });
31501
+ } catch {
31502
+ }
31503
+ };
31504
+ }
31505
+ function otherAgentsStarting(deps = {}) {
31506
+ const dir = marksDir(deps);
31507
+ const self = deps.pid ?? process.pid;
31508
+ const now = (deps.now ?? Date.now)();
31509
+ const isAlive = deps.isAlive ?? pidIsAlive2;
31510
+ let names;
31511
+ try {
31512
+ names = import_fs8.default.readdirSync(dir);
31513
+ } catch {
31514
+ return [];
31515
+ }
31516
+ const live = [];
31517
+ for (const name of names) {
31518
+ const pid = Number(name);
31519
+ if (!Number.isInteger(pid) || pid <= 0 || pid === self) continue;
31520
+ const file = import_path10.default.join(dir, name);
31521
+ let stale = !isAlive(pid);
31522
+ if (!stale) {
31523
+ try {
31524
+ stale = now - import_fs8.default.statSync(file).mtimeMs > STALE_MARK_MS;
31525
+ } catch {
31526
+ continue;
31527
+ }
31528
+ }
31529
+ if (stale) {
31530
+ try {
31531
+ import_fs8.default.rmSync(file, { force: true });
31532
+ } catch {
31533
+ }
31534
+ continue;
31535
+ }
31536
+ live.push(pid);
31537
+ }
31538
+ return live;
31539
+ }
31540
+ async function waitForNoAgentStarting(opts) {
31541
+ const now = opts.now ?? Date.now;
31542
+ const sleep5 = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
31543
+ const deadline = now() + opts.timeoutMs;
31544
+ while (otherAgentsStarting(opts).length > 0 && now() < deadline) {
31545
+ await sleep5(opts.pollMs ?? 500);
31546
+ }
31547
+ }
31548
+
31383
31549
  // src/agents/acp/runner.ts
31384
31550
  var import_node_crypto15 = require("crypto");
31385
- var fs83 = __toESM(require("fs"));
31386
- var os59 = __toESM(require("os"));
31387
- var path94 = __toESM(require("path"));
31551
+ var fs85 = __toESM(require("fs"));
31552
+ var os61 = __toESM(require("os"));
31553
+ var path96 = __toESM(require("path"));
31388
31554
 
31389
31555
  // src/agents/acp/provider-billing-signal.ts
31390
31556
  var seen = /* @__PURE__ */ new Set();
@@ -31416,8 +31582,8 @@ function noteProviderBillingSignal(opts) {
31416
31582
  }
31417
31583
 
31418
31584
  // src/services/history.service.ts
31419
- var fs65 = __toESM(require("fs"));
31420
- var path75 = __toESM(require("path"));
31585
+ var fs67 = __toESM(require("fs"));
31586
+ var path77 = __toESM(require("path"));
31421
31587
  var https6 = __toESM(require("https"));
31422
31588
  var http10 = __toESM(require("http"));
31423
31589
  var import_zod2 = require("zod");
@@ -31478,7 +31644,7 @@ function parseJsonl(filePath) {
31478
31644
  const messages = [];
31479
31645
  let raw;
31480
31646
  try {
31481
- raw = fs65.readFileSync(filePath, "utf8");
31647
+ raw = fs67.readFileSync(filePath, "utf8");
31482
31648
  } catch (err) {
31483
31649
  if (err.code !== "ENOENT") {
31484
31650
  log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
@@ -31638,7 +31804,7 @@ var HistoryService = class _HistoryService {
31638
31804
  // session-start upload answered false, the active-conversation pointer was
31639
31805
  // never re-pointed after a Box wake, and the app opened an empty "New
31640
31806
  // conversation" over the resumed one (QA box, 2026-09-29).
31641
- path75.join(claudeConfigDir(), "projects", encodeCwd(this.cwd));
31807
+ path77.join(claudeConfigDir(), "projects", encodeCwd(this.cwd));
31642
31808
  }
31643
31809
  /** Set the current Claude conversation ID (extracted from /cost command or session start) */
31644
31810
  setCurrentConversationId(id) {
@@ -31650,7 +31816,7 @@ var HistoryService = class _HistoryService {
31650
31816
  /** Return the current message count in the active conversation. */
31651
31817
  getCurrentMessageCount() {
31652
31818
  if (!this.currentConversationId) return 0;
31653
- const filePath = path75.join(this.projectDir, `${this.currentConversationId}.jsonl`);
31819
+ const filePath = path77.join(this.projectDir, `${this.currentConversationId}.jsonl`);
31654
31820
  return parseJsonl(filePath).length;
31655
31821
  }
31656
31822
  /**
@@ -31661,7 +31827,7 @@ var HistoryService = class _HistoryService {
31661
31827
  const deadline = Date.now() + timeoutMs;
31662
31828
  while (Date.now() < deadline) {
31663
31829
  if (!this.currentConversationId) return null;
31664
- const filePath = path75.join(this.projectDir, `${this.currentConversationId}.jsonl`);
31830
+ const filePath = path77.join(this.projectDir, `${this.currentConversationId}.jsonl`);
31665
31831
  const messages = parseJsonl(filePath);
31666
31832
  if (messages.length > previousCount) {
31667
31833
  for (let i = messages.length - 1; i >= previousCount; i--) {
@@ -31688,18 +31854,18 @@ var HistoryService = class _HistoryService {
31688
31854
  const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
31689
31855
  const oneShots = readOneShotConversations(this.cwd);
31690
31856
  try {
31691
- const files = fs65.readdirSync(dir, { withFileTypes: true }).filter(
31692
- (e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(path75.basename(e.name, ".jsonl"))
31857
+ const files = fs67.readdirSync(dir, { withFileTypes: true }).filter(
31858
+ (e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(path77.basename(e.name, ".jsonl"))
31693
31859
  ).map((e) => {
31694
31860
  try {
31695
- const stat3 = fs65.statSync(path75.join(dir, e.name));
31861
+ const stat3 = fs67.statSync(path77.join(dir, e.name));
31696
31862
  return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
31697
31863
  } catch {
31698
31864
  return { name: e.name, mtime: 0, birthtime: 0 };
31699
31865
  }
31700
31866
  }).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
31701
31867
  if (files.length > 0) {
31702
- this.currentConversationId = path75.basename(files[0].name, ".jsonl");
31868
+ this.currentConversationId = path77.basename(files[0].name, ".jsonl");
31703
31869
  }
31704
31870
  } catch {
31705
31871
  }
@@ -31733,13 +31899,13 @@ var HistoryService = class _HistoryService {
31733
31899
  const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
31734
31900
  let entries2;
31735
31901
  try {
31736
- entries2 = fs65.readdirSync(dir, { withFileTypes: true });
31902
+ entries2 = fs67.readdirSync(dir, { withFileTypes: true });
31737
31903
  } catch {
31738
31904
  return null;
31739
31905
  }
31740
31906
  const files = entries2.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
31741
31907
  try {
31742
- const stat3 = fs65.statSync(path75.join(dir, e.name));
31908
+ const stat3 = fs67.statSync(path77.join(dir, e.name));
31743
31909
  return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
31744
31910
  } catch {
31745
31911
  return { name: e.name, mtime: 0, birthtime: 0 };
@@ -31748,12 +31914,12 @@ var HistoryService = class _HistoryService {
31748
31914
  if (files.length === 0) return null;
31749
31915
  const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
31750
31916
  if (!files.some((f) => f.name === targetFile)) return null;
31751
- return this.extractUsageFromFile(path75.join(dir, targetFile));
31917
+ return this.extractUsageFromFile(path77.join(dir, targetFile));
31752
31918
  }
31753
31919
  extractUsageFromFile(filePath) {
31754
31920
  let raw;
31755
31921
  try {
31756
- raw = fs65.readFileSync(filePath, "utf8");
31922
+ raw = fs67.readFileSync(filePath, "utf8");
31757
31923
  } catch {
31758
31924
  return null;
31759
31925
  }
@@ -31805,9 +31971,9 @@ var HistoryService = class _HistoryService {
31805
31971
  let totalCost = 0;
31806
31972
  let files;
31807
31973
  try {
31808
- files = fs65.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
31974
+ files = fs67.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
31809
31975
  try {
31810
- return fs65.statSync(path75.join(projectDir, f)).mtimeMs >= monthStartMs;
31976
+ return fs67.statSync(path77.join(projectDir, f)).mtimeMs >= monthStartMs;
31811
31977
  } catch {
31812
31978
  return false;
31813
31979
  }
@@ -31818,7 +31984,7 @@ var HistoryService = class _HistoryService {
31818
31984
  for (const file of files) {
31819
31985
  let raw;
31820
31986
  try {
31821
- raw = fs65.readFileSync(path75.join(projectDir, file), "utf8");
31987
+ raw = fs67.readFileSync(path77.join(projectDir, file), "utf8");
31822
31988
  } catch {
31823
31989
  continue;
31824
31990
  }
@@ -31897,7 +32063,7 @@ var HistoryService = class _HistoryService {
31897
32063
  if (this.runtime.resolveHistoryFile) {
31898
32064
  return this.runtime.resolveHistoryFile(this.cwd, sessionId);
31899
32065
  }
31900
- return path75.join(this.projectDir, `${sessionId}.jsonl`);
32066
+ return path77.join(this.projectDir, `${sessionId}.jsonl`);
31901
32067
  }
31902
32068
  /**
31903
32069
  * Parse a conversation's messages from disk, agent-aware. Claude uses the
@@ -31935,7 +32101,7 @@ var HistoryService = class _HistoryService {
31935
32101
  };
31936
32102
  });
31937
32103
  }
31938
- return parseJsonl(path75.join(this.projectDir, `${sessionId}.jsonl`));
32104
+ return parseJsonl(path77.join(this.projectDir, `${sessionId}.jsonl`));
31939
32105
  }
31940
32106
  /** One in-flight full upload per conversation — the baton mirror and a
31941
32107
  * `get_conversation` used to upload the same transcript concurrently. */
@@ -32017,7 +32183,7 @@ var HistoryService = class _HistoryService {
32017
32183
  if (!filePath) return false;
32018
32184
  let mtimeMs;
32019
32185
  try {
32020
- mtimeMs = fs65.statSync(filePath).mtimeMs;
32186
+ mtimeMs = fs67.statSync(filePath).mtimeMs;
32021
32187
  } catch {
32022
32188
  return false;
32023
32189
  }
@@ -32092,10 +32258,10 @@ var HistoryService = class _HistoryService {
32092
32258
 
32093
32259
  // src/agents/acp/client.ts
32094
32260
  var import_node_child_process27 = require("child_process");
32095
- var fs66 = __toESM(require("fs/promises"));
32261
+ var fs68 = __toESM(require("fs/promises"));
32096
32262
  var fsSync = __toESM(require("fs"));
32097
- var os49 = __toESM(require("os"));
32098
- var path77 = __toESM(require("path"));
32263
+ var os51 = __toESM(require("os"));
32264
+ var path79 = __toESM(require("path"));
32099
32265
  var import_node_stream = require("stream");
32100
32266
 
32101
32267
  // ../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
@@ -36121,8 +36287,8 @@ function createIdleTimeout(idleMs, makeError, activeIdleMs = idleMs) {
36121
36287
  }
36122
36288
 
36123
36289
  // src/agents/acp/internal-paths.ts
36124
- var path76 = __toESM(require("path"));
36125
- var os48 = __toESM(require("os"));
36290
+ var path78 = __toESM(require("path"));
36291
+ var os50 = __toESM(require("os"));
36126
36292
  var INTERNAL_TOKENS = [".codeam", "house-claude"];
36127
36293
  var PROSE_ONLY_TOOL_KINDS = /* @__PURE__ */ new Set(["think", "switch_mode"]);
36128
36294
  function isProseOnlyToolKind(kind) {
@@ -36134,13 +36300,13 @@ function textReferencesInternal(text) {
36134
36300
  const scrubbed = text.replace(SELF_HOSTED_WORKSPACE_RE, " ");
36135
36301
  return INTERNAL_TOKENS.some((t2) => scrubbed.includes(t2));
36136
36302
  }
36137
- function pathIsInternal(p2, homeDir2 = os48.homedir()) {
36303
+ function pathIsInternal(p2, homeDir2 = os50.homedir()) {
36138
36304
  if (!p2) return false;
36139
- const abs = path76.resolve(p2);
36140
- const home = path76.resolve(homeDir2);
36141
- const within = (root) => abs === root || abs.startsWith(root + path76.sep);
36142
- if (within(path76.join(home, ".codeam", "self-hosted"))) return false;
36143
- return within(path76.join(home, ".codeam")) || within(path76.join(home, ".beads")) || abs === path76.join(home, ".codeam-host.log") || abs.includes(`${path76.sep}house-claude${path76.sep}`) || abs.endsWith(`${path76.sep}house-claude`);
36305
+ const abs = path78.resolve(p2);
36306
+ const home = path78.resolve(homeDir2);
36307
+ const within = (root) => abs === root || abs.startsWith(root + path78.sep);
36308
+ if (within(path78.join(home, ".codeam", "self-hosted"))) return false;
36309
+ return within(path78.join(home, ".codeam")) || within(path78.join(home, ".beads")) || abs === path78.join(home, ".codeam-host.log") || abs.includes(`${path78.sep}house-claude${path78.sep}`) || abs.endsWith(`${path78.sep}house-claude`);
36144
36310
  }
36145
36311
  function toolCallReferencesInternal(call, homeDir2) {
36146
36312
  if (call.locations?.some((l) => pathIsInternal(l.path, homeDir2))) return true;
@@ -37236,7 +37402,7 @@ var AcpClient = class {
37236
37402
  throw new RequestError(-32002, GUARDRAIL_SECRET_READ_BLOCK_REASON, { uri: params.path });
37237
37403
  }
37238
37404
  try {
37239
- const content = await fs66.readFile(params.path, "utf8");
37405
+ const content = await fs68.readFile(params.path, "utf8");
37240
37406
  return applyLineRange(content, params.line ?? null, params.limit ?? null);
37241
37407
  } catch (err) {
37242
37408
  const code = err.code;
@@ -37257,7 +37423,7 @@ var AcpClient = class {
37257
37423
  throw new RequestError(-32002, INTERNAL_BLOCK_REASON, { uri: params.path });
37258
37424
  }
37259
37425
  try {
37260
- await fs66.writeFile(params.path, params.content, "utf8");
37426
+ await fs68.writeFile(params.path, params.content, "utf8");
37261
37427
  return {};
37262
37428
  } catch (err) {
37263
37429
  const code = err.code;
@@ -37345,30 +37511,30 @@ function applyLineRange(content, line, limit) {
37345
37511
  return { content: lines.slice(start2, end).join("\n") };
37346
37512
  }
37347
37513
  function knownAgentBinaryDirs() {
37348
- const home = os49.homedir();
37514
+ const home = os51.homedir();
37349
37515
  const out2 = [];
37350
37516
  out2.push("/tmp/codeam-node20/bin");
37351
37517
  for (const root of [
37352
37518
  "/usr/local/share/nvm/versions/node",
37353
- path77.join(home, ".nvm/versions/node")
37519
+ path79.join(home, ".nvm/versions/node")
37354
37520
  ]) {
37355
37521
  try {
37356
37522
  for (const child of fsSync.readdirSync(root)) {
37357
- out2.push(path77.join(root, child, "bin"));
37523
+ out2.push(path79.join(root, child, "bin"));
37358
37524
  }
37359
37525
  } catch {
37360
37526
  }
37361
37527
  }
37362
- out2.push(path77.join(home, ".volta/bin"));
37528
+ out2.push(path79.join(home, ".volta/bin"));
37363
37529
  out2.push("/usr/local/bin");
37364
37530
  out2.push("/usr/bin");
37365
- out2.push(path77.join(home, ".local/bin"));
37366
- out2.push(path77.join(home, "bin"));
37531
+ out2.push(path79.join(home, ".local/bin"));
37532
+ out2.push(path79.join(home, "bin"));
37367
37533
  out2.push(...agentInstallBinDirs());
37368
37534
  if (process.platform === "win32") {
37369
37535
  const { LOCALAPPDATA, APPDATA } = process.env;
37370
- if (LOCALAPPDATA) out2.push(path77.join(LOCALAPPDATA, "cursor-agent"));
37371
- if (APPDATA) out2.push(path77.join(APPDATA, "npm"));
37536
+ if (LOCALAPPDATA) out2.push(path79.join(LOCALAPPDATA, "cursor-agent"));
37537
+ if (APPDATA) out2.push(path79.join(APPDATA, "npm"));
37372
37538
  }
37373
37539
  return out2.filter((p2) => {
37374
37540
  try {
@@ -37379,7 +37545,7 @@ function knownAgentBinaryDirs() {
37379
37545
  });
37380
37546
  }
37381
37547
  function expandPathForAgentBinaries(existingPath) {
37382
- const existing = new Set(existingPath.split(path77.delimiter).filter((p2) => p2.length > 0));
37548
+ const existing = new Set(existingPath.split(path79.delimiter).filter((p2) => p2.length > 0));
37383
37549
  const additions = [];
37384
37550
  for (const dir of knownAgentBinaryDirs()) {
37385
37551
  if (!existing.has(dir)) {
@@ -37388,17 +37554,17 @@ function expandPathForAgentBinaries(existingPath) {
37388
37554
  }
37389
37555
  }
37390
37556
  if (additions.length === 0) return existingPath;
37391
- return [...additions, existingPath].filter((p2) => p2.length > 0).join(path77.delimiter);
37557
+ return [...additions, existingPath].filter((p2) => p2.length > 0).join(path79.delimiter);
37392
37558
  }
37393
37559
 
37394
37560
  // src/commands/host/agent-install.ts
37395
37561
  var import_child_process27 = require("child_process");
37396
- var os50 = __toESM(require("os"));
37562
+ var os52 = __toESM(require("os"));
37397
37563
  function runAgentInstallScript(script, opts = {}) {
37398
37564
  const timeoutMs = opts.timeoutMs ?? 18e4;
37399
37565
  const scope = opts.logScope ?? "agent-install";
37400
37566
  return new Promise((resolve14) => {
37401
- const home = process.env.HOME || os50.homedir();
37567
+ const home = process.env.HOME || os52.homedir();
37402
37568
  const child = (0, import_child_process27.spawn)("sh", ["-c", script], {
37403
37569
  env: { ...process.env, HOME: home },
37404
37570
  stdio: ["ignore", "pipe", "pipe"]
@@ -37660,9 +37826,9 @@ async function performAgentSwitch(deps, rawAgentId, fastPath = {}) {
37660
37826
  }
37661
37827
 
37662
37828
  // src/commands/host/agent-provisioning.ts
37663
- var fs67 = __toESM(require("fs"));
37664
- var os51 = __toESM(require("os"));
37665
- var path78 = __toESM(require("path"));
37829
+ var fs69 = __toESM(require("fs"));
37830
+ var os53 = __toESM(require("os"));
37831
+ var path80 = __toESM(require("path"));
37666
37832
  var PUBLIC_TO_INTERNAL_AGENT = {
37667
37833
  claude_code: "claude",
37668
37834
  claude: "claude",
@@ -37679,22 +37845,22 @@ function toInternalAgentId(publicAgentId) {
37679
37845
  return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
37680
37846
  }
37681
37847
  function ensureDir(dir) {
37682
- fs67.mkdirSync(dir, { recursive: true, mode: 448 });
37848
+ fs69.mkdirSync(dir, { recursive: true, mode: 448 });
37683
37849
  }
37684
37850
  function writeFile0600(filePath, contents) {
37685
- ensureDir(path78.dirname(filePath));
37686
- fs67.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
37851
+ ensureDir(path80.dirname(filePath));
37852
+ fs69.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
37687
37853
  restrictToOwner(filePath);
37688
37854
  }
37689
37855
  function rmIfExists(filePath) {
37690
37856
  try {
37691
- fs67.rmSync(filePath, { force: true });
37857
+ fs69.rmSync(filePath, { force: true });
37692
37858
  } catch {
37693
37859
  }
37694
37860
  }
37695
37861
  var claudeProvisioner = {
37696
37862
  write(auth, home) {
37697
- const credentialsJson = path78.join(home, ".claude", ".credentials.json");
37863
+ const credentialsJson = path80.join(home, ".claude", ".credentials.json");
37698
37864
  if (auth.kind === "api_key") {
37699
37865
  rmIfExists(credentialsJson);
37700
37866
  return { ANTHROPIC_API_KEY: auth.value };
@@ -37706,8 +37872,8 @@ var claudeProvisioner = {
37706
37872
  } else {
37707
37873
  rmIfExists(credentialsJson);
37708
37874
  }
37709
- const claudeJson = path78.join(home, ".claude.json");
37710
- if (!fs67.existsSync(claudeJson)) {
37875
+ const claudeJson = path80.join(home, ".claude.json");
37876
+ if (!fs69.existsSync(claudeJson)) {
37711
37877
  writeFile0600(
37712
37878
  claudeJson,
37713
37879
  JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
@@ -37718,7 +37884,7 @@ var claudeProvisioner = {
37718
37884
  };
37719
37885
  var codexProvisioner = {
37720
37886
  write(auth, home) {
37721
- const authJson = path78.join(home, ".codex", "auth.json");
37887
+ const authJson = path80.join(home, ".codex", "auth.json");
37722
37888
  if (auth.kind === "api_key") {
37723
37889
  writeFile0600(authJson, JSON.stringify({ auth_mode: "apikey", OPENAI_API_KEY: auth.value }));
37724
37890
  return { OPENAI_API_KEY: auth.value };
@@ -37741,7 +37907,7 @@ function codexLoginStamp(raw) {
37741
37907
  function keepsFresherCodexLogin(authJsonPath, incoming) {
37742
37908
  let onDisk;
37743
37909
  try {
37744
- onDisk = fs67.readFileSync(authJsonPath, "utf8");
37910
+ onDisk = fs69.readFileSync(authJsonPath, "utf8");
37745
37911
  } catch {
37746
37912
  return false;
37747
37913
  }
@@ -37752,8 +37918,8 @@ function keepsFresherCodexLogin(authJsonPath, incoming) {
37752
37918
  }
37753
37919
  var geminiProvisioner = {
37754
37920
  write(auth, home) {
37755
- const settingsJson = path78.join(home, ".gemini", "settings.json");
37756
- const oauthCreds = path78.join(home, ".gemini", "oauth_creds.json");
37921
+ const settingsJson = path80.join(home, ".gemini", "settings.json");
37922
+ const oauthCreds = path80.join(home, ".gemini", "oauth_creds.json");
37757
37923
  if (auth.kind === "api_key") {
37758
37924
  rmIfExists(oauthCreds);
37759
37925
  writeFile0600(settingsJson, '{"security":{"auth":{"selectedType":"gemini-api-key"}}}');
@@ -37766,7 +37932,7 @@ var geminiProvisioner = {
37766
37932
  };
37767
37933
  var cursorProvisioner = {
37768
37934
  write(auth, home) {
37769
- const authJson = path78.join(home, ".config", "cursor", "auth.json");
37935
+ const authJson = path80.join(home, ".config", "cursor", "auth.json");
37770
37936
  if (auth.kind === "api_key") {
37771
37937
  rmIfExists(authJson);
37772
37938
  return { CURSOR_API_KEY: auth.value };
@@ -37808,22 +37974,22 @@ max_context_size = 262144
37808
37974
  var kimiProvisioner = {
37809
37975
  write(auth, home) {
37810
37976
  const credentialsFiles = [
37811
- path78.join(home, ".kimi", "credentials", "kimi-code.json"),
37812
- path78.join(home, ".kimi-code", "credentials", "kimi-code.json")
37977
+ path80.join(home, ".kimi", "credentials", "kimi-code.json"),
37978
+ path80.join(home, ".kimi-code", "credentials", "kimi-code.json")
37813
37979
  ];
37814
37980
  if (auth.kind === "api_key") {
37815
37981
  credentialsFiles.forEach(rmIfExists);
37816
37982
  return { KIMI_API_KEY: auth.value };
37817
37983
  }
37818
37984
  credentialsFiles.forEach((f) => writeFile0600(f, auth.value));
37819
- writeFile0600(path78.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
37985
+ writeFile0600(path80.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
37820
37986
  return {};
37821
37987
  }
37822
37988
  };
37823
37989
  var coderabbitProvisioner = {
37824
37990
  write(auth, home) {
37825
- const dir = path78.join(home, ".coderabbit");
37826
- const authJson = path78.join(dir, "auth.json");
37991
+ const dir = path80.join(home, ".coderabbit");
37992
+ const authJson = path80.join(dir, "auth.json");
37827
37993
  if (auth.kind === "api_key") {
37828
37994
  rmIfExists(authJson);
37829
37995
  return { CODERABBIT_API_KEY: auth.value };
@@ -37835,13 +38001,13 @@ var coderabbitProvisioner = {
37835
38001
  try {
37836
38002
  const parsed = JSON.parse(value);
37837
38003
  if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
37838
- file = path78.basename(parsed.file);
38004
+ file = path80.basename(parsed.file);
37839
38005
  contents = parsed.contents;
37840
38006
  }
37841
38007
  } catch {
37842
38008
  }
37843
38009
  }
37844
- writeFile0600(path78.join(dir, file), contents);
38010
+ writeFile0600(path80.join(dir, file), contents);
37845
38011
  return {};
37846
38012
  }
37847
38013
  };
@@ -37869,7 +38035,7 @@ var UnsupportedAgentError = class extends Error {
37869
38035
  this.agentId = agentId;
37870
38036
  }
37871
38037
  };
37872
- function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os51.homedir()) {
38038
+ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os53.homedir()) {
37873
38039
  const internal = toInternalAgentId(publicAgentId);
37874
38040
  if (!internal) throw new UnsupportedAgentError(publicAgentId);
37875
38041
  const provisioner = PROVISIONERS[internal];
@@ -37878,8 +38044,8 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os51.homedir(
37878
38044
  }
37879
38045
 
37880
38046
  // src/beads/workflow-hint.ts
37881
- var fs68 = __toESM(require("fs"));
37882
- var path79 = __toESM(require("path"));
38047
+ var fs70 = __toESM(require("fs"));
38048
+ var path81 = __toESM(require("path"));
37883
38049
  var BEADS_HINT_MARKER = "<!-- codeam:beads-workflow -->";
37884
38050
  var BEADS_HINT = `${BEADS_HINT_MARKER}
37885
38051
  # Beads (bd) \u2014 task tracking + persistent memory (ALWAYS use it)
@@ -37906,11 +38072,11 @@ function ensureBeadsWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2)) {
37906
38072
  try {
37907
38073
  let existing = "";
37908
38074
  try {
37909
- existing = fs68.readFileSync(file, "utf8");
38075
+ existing = fs70.readFileSync(file, "utf8");
37910
38076
  } catch {
37911
38077
  }
37912
38078
  if (existing.includes(BEADS_HINT)) return;
37913
- fs68.mkdirSync(path79.dirname(file), { recursive: true });
38079
+ fs70.mkdirSync(path81.dirname(file), { recursive: true });
37914
38080
  let next;
37915
38081
  const open = existing.indexOf(BEADS_HINT_MARKER);
37916
38082
  const close = open === -1 ? -1 : existing.indexOf(BEADS_HINT_MARKER, open + BEADS_HINT_MARKER.length);
@@ -37923,40 +38089,40 @@ ${BEADS_HINT}
37923
38089
  ` : `${BEADS_HINT}
37924
38090
  `;
37925
38091
  }
37926
- fs68.writeFileSync(file, next);
38092
+ fs70.writeFileSync(file, next);
37927
38093
  } catch {
37928
38094
  }
37929
38095
  }
37930
38096
 
37931
38097
  // src/agents/agent-standard.ts
37932
- var fs69 = __toESM(require("fs"));
37933
- var path80 = __toESM(require("path"));
37934
- var os52 = __toESM(require("os"));
38098
+ var fs71 = __toESM(require("fs"));
38099
+ var path82 = __toESM(require("path"));
38100
+ var os54 = __toESM(require("os"));
37935
38101
  function ensureAgentStandard(homeDir2, file = claudeMemoryFile(homeDir2)) {
37936
38102
  try {
37937
38103
  let existing = "";
37938
38104
  try {
37939
- existing = fs69.readFileSync(file, "utf8");
38105
+ existing = fs71.readFileSync(file, "utf8");
37940
38106
  } catch {
37941
38107
  }
37942
38108
  if (existing.includes(AGENT_STANDARD_MARKER)) return;
37943
- fs69.mkdirSync(path80.dirname(file), { recursive: true });
38109
+ fs71.mkdirSync(path82.dirname(file), { recursive: true });
37944
38110
  const next = existing.trim() ? `${existing.trimEnd()}
37945
38111
 
37946
38112
  ${AGENT_STANDARD_BLOCK}
37947
38113
  ` : `${AGENT_STANDARD_BLOCK}
37948
38114
  `;
37949
- fs69.writeFileSync(file, next);
38115
+ fs71.writeFileSync(file, next);
37950
38116
  } catch {
37951
38117
  }
37952
38118
  }
37953
38119
  var _agentStandardSeam = {
37954
38120
  isLocalSession: () => isLocalSession(),
37955
- markerPath: (sessionId) => path80.join(os52.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
37956
- exists: (p2) => fs69.existsSync(p2),
38121
+ markerPath: (sessionId) => path82.join(os54.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
38122
+ exists: (p2) => fs71.existsSync(p2),
37957
38123
  write: (p2) => {
37958
- fs69.mkdirSync(path80.dirname(p2), { recursive: true });
37959
- fs69.writeFileSync(p2, "");
38124
+ fs71.mkdirSync(path82.dirname(p2), { recursive: true });
38125
+ fs71.writeFileSync(p2, "");
37960
38126
  }
37961
38127
  };
37962
38128
  function isClaude(agent) {
@@ -38691,15 +38857,15 @@ function withholdTrailingPartialFenceMarker(text) {
38691
38857
 
38692
38858
  // src/agents/acp/onboarding.ts
38693
38859
  var import_child_process28 = require("child_process");
38694
- var fs71 = __toESM(require("fs"));
38695
- var os53 = __toESM(require("os"));
38696
- var path82 = __toESM(require("path"));
38860
+ var fs73 = __toESM(require("fs"));
38861
+ var os55 = __toESM(require("os"));
38862
+ var path84 = __toESM(require("path"));
38697
38863
  var _onboardingSeam = {
38698
- markerPath: (sessionId) => path82.join(os53.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
38699
- exists: (p2) => fs71.existsSync(p2),
38864
+ markerPath: (sessionId) => path84.join(os55.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
38865
+ exists: (p2) => fs73.existsSync(p2),
38700
38866
  write: (p2) => {
38701
- fs71.mkdirSync(path82.dirname(p2), { recursive: true });
38702
- fs71.writeFileSync(p2, "");
38867
+ fs73.mkdirSync(path84.dirname(p2), { recursive: true });
38868
+ fs73.writeFileSync(p2, "");
38703
38869
  },
38704
38870
  disabled: () => {
38705
38871
  const v = process.env.CODEAM_ONBOARDING_DISABLED;
@@ -38736,7 +38902,7 @@ function resolveRepoName(cwd) {
38736
38902
  if (name) return name;
38737
38903
  }
38738
38904
  }
38739
- const base = path82.basename(cwd || "");
38905
+ const base = path84.basename(cwd || "");
38740
38906
  if (base && !isUuid(base)) return base;
38741
38907
  return "this project";
38742
38908
  }
@@ -39128,14 +39294,14 @@ var import_crypto5 = require("crypto");
39128
39294
 
39129
39295
  // src/services/turn-files/git-changeset.ts
39130
39296
  var import_child_process29 = require("child_process");
39131
- var fs73 = __toESM(require("fs/promises"));
39132
- var import_fs7 = require("fs");
39133
- var path84 = __toESM(require("path"));
39297
+ var fs75 = __toESM(require("fs/promises"));
39298
+ var import_fs9 = require("fs");
39299
+ var path86 = __toESM(require("path"));
39134
39300
 
39135
39301
  // src/services/turn-files/review-ignore.ts
39136
39302
  var import_ignore2 = __toESM(require("ignore"));
39137
- var fs72 = __toESM(require("fs"));
39138
- var path83 = __toESM(require("path"));
39303
+ var fs74 = __toESM(require("fs"));
39304
+ var path85 = __toESM(require("path"));
39139
39305
  var CURATED_REVIEW_IGNORE = [
39140
39306
  // Google Cloud SDK (the incident) — installs a huge python tree.
39141
39307
  "google-cloud-sdk/",
@@ -39179,7 +39345,7 @@ var CURATED_REVIEW_IGNORE = [
39179
39345
  function makeReviewIgnore(repoRoot) {
39180
39346
  const ig = (0, import_ignore2.default)().add(CURATED_REVIEW_IGNORE);
39181
39347
  try {
39182
- const custom = fs72.readFileSync(path83.join(repoRoot, ".codeam", "reviewignore"), "utf8");
39348
+ const custom = fs74.readFileSync(path85.join(repoRoot, ".codeam", "reviewignore"), "utf8");
39183
39349
  ig.add(custom);
39184
39350
  } catch {
39185
39351
  }
@@ -39214,7 +39380,7 @@ async function collectRepoChangeset(opts) {
39214
39380
  const rows = parseStatus(status2).filter(
39215
39381
  (row) => !isIgnoredFilePath(row.filePath) && !reviewIgnore(row.filePath) && // A socket, FIFO or device node is never a change to review (a
39216
39382
  // `cc-socks/1522.sock` reached the Files tab).
39217
- isReviewablePath(path84.join(opts.repoRoot, row.filePath))
39383
+ isReviewablePath(path86.join(opts.repoRoot, row.filePath))
39218
39384
  );
39219
39385
  const MAX_CHANGESET_FILES = Math.max(1, Number(process.env.CODEAM_MAX_CHANGESET_FILES ?? 500));
39220
39386
  const truncated = rows.length > MAX_CHANGESET_FILES;
@@ -39231,7 +39397,7 @@ async function collectRepoChangeset(opts) {
39231
39397
  let stats;
39232
39398
  if (!truncated && row.fileStatus === "added" && numstatEntry === void 0) {
39233
39399
  const lineCount = await readUntrackedLineCount(
39234
- path84.join(opts.repoRoot, row.filePath)
39400
+ path86.join(opts.repoRoot, row.filePath)
39235
39401
  );
39236
39402
  stats = { added: lineCount, removed: 0 };
39237
39403
  } else {
@@ -39262,7 +39428,7 @@ function readUntrackedLineCount(absPath) {
39262
39428
  }
39263
39429
  async function defaultReadUntrackedLineCount(absPath) {
39264
39430
  try {
39265
- const content = await fs73.readFile(absPath, "utf8");
39431
+ const content = await fs75.readFile(absPath, "utf8");
39266
39432
  let count = 0;
39267
39433
  let pos = -1;
39268
39434
  while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
@@ -39354,7 +39520,7 @@ function defaultRunGit(cwd, args2) {
39354
39520
  });
39355
39521
  }
39356
39522
  async function discoverRepos(workingDir, maxDepth = 4) {
39357
- const fs97 = await import("fs/promises");
39523
+ const fs99 = await import("fs/promises");
39358
39524
  const out2 = [];
39359
39525
  await walk2(workingDir, 0);
39360
39526
  return out2;
@@ -39362,7 +39528,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
39362
39528
  if (depth2 > maxDepth) return;
39363
39529
  let entries2 = [];
39364
39530
  try {
39365
- const dirents = await fs97.readdir(dir, { withFileTypes: true });
39531
+ const dirents = await fs99.readdir(dir, { withFileTypes: true });
39366
39532
  entries2 = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
39367
39533
  } catch {
39368
39534
  return;
@@ -39373,8 +39539,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
39373
39539
  if (hasGit) {
39374
39540
  out2.push({
39375
39541
  repoRoot: dir,
39376
- repoPath: path84.relative(workingDir, dir),
39377
- repoName: path84.basename(dir)
39542
+ repoPath: path86.relative(workingDir, dir),
39543
+ repoName: path86.basename(dir)
39378
39544
  });
39379
39545
  return;
39380
39546
  }
@@ -39382,13 +39548,13 @@ async function discoverRepos(workingDir, maxDepth = 4) {
39382
39548
  if (!entry.isDirectory) continue;
39383
39549
  if (entry.name === "node_modules") continue;
39384
39550
  if (entry.name === "dist" || entry.name === "build") continue;
39385
- await walk2(path84.join(dir, entry.name), depth2 + 1);
39551
+ await walk2(path86.join(dir, entry.name), depth2 + 1);
39386
39552
  }
39387
39553
  }
39388
39554
  }
39389
39555
  function isReviewablePath(absPath) {
39390
39556
  try {
39391
- const st3 = (0, import_fs7.lstatSync)(absPath);
39557
+ const st3 = (0, import_fs9.lstatSync)(absPath);
39392
39558
  return st3.isFile() || st3.isSymbolicLink();
39393
39559
  } catch {
39394
39560
  return true;
@@ -39396,9 +39562,9 @@ function isReviewablePath(absPath) {
39396
39562
  }
39397
39563
 
39398
39564
  // src/services/turn-files/files-outbox.ts
39399
- var fs74 = __toESM(require("fs/promises"));
39400
- var path85 = __toESM(require("path"));
39401
- var import_os12 = require("os");
39565
+ var fs76 = __toESM(require("fs/promises"));
39566
+ var path87 = __toESM(require("path"));
39567
+ var import_os14 = require("os");
39402
39568
  var HOME_OUTBOX_DIR = ".codeam/outbox";
39403
39569
  var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
39404
39570
  var BACKOFF_STEPS_MS = [
@@ -39430,16 +39596,16 @@ var FilesOutbox = class {
39430
39596
  backoffIndex = 0;
39431
39597
  stopped = false;
39432
39598
  constructor(opts) {
39433
- const base = opts.baseDir ?? path85.join(homeDir(), HOME_OUTBOX_DIR);
39434
- this.filePath = path85.join(base, `${opts.sessionId}.jsonl`);
39599
+ const base = opts.baseDir ?? path87.join(homeDir(), HOME_OUTBOX_DIR);
39600
+ this.filePath = path87.join(base, `${opts.sessionId}.jsonl`);
39435
39601
  this.post = opts.post;
39436
39602
  this.autoSchedule = opts.autoSchedule !== false;
39437
39603
  }
39438
39604
  /** Persist the entry to disk and trigger a flush. Returns once the
39439
39605
  * line is durable on disk (not once the POST succeeds). */
39440
39606
  async enqueue(entry) {
39441
- await fs74.mkdir(path85.dirname(this.filePath), { recursive: true });
39442
- await fs74.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
39607
+ await fs76.mkdir(path87.dirname(this.filePath), { recursive: true });
39608
+ await fs76.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
39443
39609
  this.backoffIndex = 0;
39444
39610
  if (this.autoSchedule) this.scheduleFlush(0);
39445
39611
  }
@@ -39530,7 +39696,7 @@ var FilesOutbox = class {
39530
39696
  async readAll() {
39531
39697
  let raw = "";
39532
39698
  try {
39533
- raw = await fs74.readFile(this.filePath, "utf8");
39699
+ raw = await fs76.readFile(this.filePath, "utf8");
39534
39700
  } catch {
39535
39701
  return [];
39536
39702
  }
@@ -39554,12 +39720,12 @@ var FilesOutbox = class {
39554
39720
  async rewrite(entries2) {
39555
39721
  const tmpPath = `${this.filePath}.${process.pid}.tmp`;
39556
39722
  if (entries2.length === 0) {
39557
- await fs74.unlink(this.filePath).catch(() => void 0);
39723
+ await fs76.unlink(this.filePath).catch(() => void 0);
39558
39724
  return;
39559
39725
  }
39560
39726
  const payload = entries2.map((e) => JSON.stringify(e)).join("\n") + "\n";
39561
- await fs74.writeFile(tmpPath, payload, "utf8");
39562
- await fs74.rename(tmpPath, this.filePath);
39727
+ await fs76.writeFile(tmpPath, payload, "utf8");
39728
+ await fs76.rename(tmpPath, this.filePath);
39563
39729
  }
39564
39730
  };
39565
39731
  function applyJitter(ms) {
@@ -39567,7 +39733,7 @@ function applyJitter(ms) {
39567
39733
  return Math.round(ms * factor);
39568
39734
  }
39569
39735
  function homeDir() {
39570
- return process.env.HOME ?? process.env.USERPROFILE ?? (0, import_os12.tmpdir)();
39736
+ return process.env.HOME ?? process.env.USERPROFILE ?? (0, import_os14.tmpdir)();
39571
39737
  }
39572
39738
 
39573
39739
  // src/services/turn-files/turn-file-aggregator.ts
@@ -39907,27 +40073,27 @@ async function readActiveConversationMarker(cwd, homeDir2) {
39907
40073
  }
39908
40074
 
39909
40075
  // src/services/turn-marker.ts
39910
- var fs76 = __toESM(require("fs"));
39911
- var os55 = __toESM(require("os"));
39912
- var path87 = __toESM(require("path"));
40076
+ var fs78 = __toESM(require("fs"));
40077
+ var os57 = __toESM(require("os"));
40078
+ var path89 = __toESM(require("path"));
39913
40079
  var depth = 0;
39914
40080
  function codeamHome() {
39915
- return path87.join(os55.homedir(), ".codeam");
40081
+ return path89.join(os57.homedir(), ".codeam");
39916
40082
  }
39917
40083
  function turnMarkerPath(pid = process.pid, home = codeamHome()) {
39918
- return path87.join(home, "turns", String(pid));
40084
+ return path89.join(home, "turns", String(pid));
39919
40085
  }
39920
40086
  function mark() {
39921
40087
  try {
39922
40088
  const file = turnMarkerPath();
39923
- fs76.mkdirSync(path87.dirname(file), { recursive: true });
39924
- fs76.writeFileSync(file, String(Date.now()));
40089
+ fs78.mkdirSync(path89.dirname(file), { recursive: true });
40090
+ fs78.writeFileSync(file, String(Date.now()));
39925
40091
  } catch {
39926
40092
  }
39927
40093
  }
39928
40094
  function clear() {
39929
40095
  try {
39930
- fs76.rmSync(turnMarkerPath(), { force: true });
40096
+ fs78.rmSync(turnMarkerPath(), { force: true });
39931
40097
  } catch {
39932
40098
  }
39933
40099
  }
@@ -39942,7 +40108,7 @@ async function withTurnMarker(fn) {
39942
40108
  function isProcessMidTurn(pid, home) {
39943
40109
  if (!pid) return false;
39944
40110
  try {
39945
- return fs76.existsSync(turnMarkerPath(pid, home));
40111
+ return fs78.existsSync(turnMarkerPath(pid, home));
39946
40112
  } catch {
39947
40113
  return false;
39948
40114
  }
@@ -39950,8 +40116,8 @@ function isProcessMidTurn(pid, home) {
39950
40116
 
39951
40117
  // src/packs/gates.ts
39952
40118
  var import_node_child_process28 = require("child_process");
39953
- var fs77 = __toESM(require("fs"));
39954
- var path88 = __toESM(require("path"));
40119
+ var fs79 = __toESM(require("fs"));
40120
+ var path90 = __toESM(require("path"));
39955
40121
  var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((resolve14) => {
39956
40122
  (0, import_node_child_process28.execFile)(
39957
40123
  file,
@@ -40001,7 +40167,7 @@ async function changedFiles(run3, cwd, from, to) {
40001
40167
  }
40002
40168
  function readWorkspaceFile(cwd, relPath) {
40003
40169
  try {
40004
- return fs77.readFileSync(path88.join(cwd, relPath), "utf8");
40170
+ return fs79.readFileSync(path90.join(cwd, relPath), "utf8");
40005
40171
  } catch {
40006
40172
  return null;
40007
40173
  }
@@ -40010,14 +40176,14 @@ var NO_TEST_PLACEHOLDER = 'echo "Error: no test specified"';
40010
40176
  var CHECKS_TIMEOUT_MS = 5 * 6e4;
40011
40177
  function detectChecksCommand(cwd) {
40012
40178
  try {
40013
- const cfg = JSON.parse(fs77.readFileSync(path88.join(cwd, ".codeam", "pack.json"), "utf8"));
40179
+ const cfg = JSON.parse(fs79.readFileSync(path90.join(cwd, ".codeam", "pack.json"), "utf8"));
40014
40180
  if (typeof cfg.checksCommand === "string" && cfg.checksCommand.trim().length > 0) {
40015
40181
  return cfg.checksCommand.trim();
40016
40182
  }
40017
40183
  } catch {
40018
40184
  }
40019
40185
  try {
40020
- const pkg = JSON.parse(fs77.readFileSync(path88.join(cwd, "package.json"), "utf8"));
40186
+ const pkg = JSON.parse(fs79.readFileSync(path90.join(cwd, "package.json"), "utf8"));
40021
40187
  const test = pkg.scripts?.test;
40022
40188
  if (typeof test === "string" && test.trim().length > 0 && !test.includes(NO_TEST_PLACEHOLDER)) {
40023
40189
  return "npm test";
@@ -40035,39 +40201,39 @@ ${res.stderr}`.trim();
40035
40201
  }
40036
40202
 
40037
40203
  // src/packs/run-store.ts
40038
- var fs78 = __toESM(require("fs"));
40039
- var path89 = __toESM(require("path"));
40204
+ var fs80 = __toESM(require("fs"));
40205
+ var path91 = __toESM(require("path"));
40040
40206
  var crypto5 = __toESM(require("crypto"));
40041
40207
  function packsDir(cwd) {
40042
- return path89.join(cwd, ".codeam", "packs");
40208
+ return path91.join(cwd, ".codeam", "packs");
40043
40209
  }
40044
40210
  function runDir(cwd, runId) {
40045
- return path89.join(packsDir(cwd), runId);
40211
+ return path91.join(packsDir(cwd), runId);
40046
40212
  }
40047
40213
  function newRunId() {
40048
40214
  return `pk_${Date.now().toString(36)}_${crypto5.randomBytes(4).toString("hex")}`;
40049
40215
  }
40050
40216
  function writeJsonAtomic(file, value) {
40051
- fs78.mkdirSync(path89.dirname(file), { recursive: true });
40217
+ fs80.mkdirSync(path91.dirname(file), { recursive: true });
40052
40218
  const tmp = `${file}.tmp`;
40053
- fs78.writeFileSync(tmp, JSON.stringify(value, null, 2));
40054
- fs78.renameSync(tmp, file);
40219
+ fs80.writeFileSync(tmp, JSON.stringify(value, null, 2));
40220
+ fs80.renameSync(tmp, file);
40055
40221
  }
40056
40222
  function saveRun(cwd, state) {
40057
- writeJsonAtomic(path89.join(runDir(cwd, state.runId), "run.json"), state);
40223
+ writeJsonAtomic(path91.join(runDir(cwd, state.runId), "run.json"), state);
40058
40224
  }
40059
40225
  function saveStageHandoff(cwd, runId, stageIndex, role, handoff) {
40060
40226
  const name = `${String(stageIndex + 1).padStart(2, "0")}-${role}.json`;
40061
- writeJsonAtomic(path89.join(runDir(cwd, runId), name), handoff);
40227
+ writeJsonAtomic(path91.join(runDir(cwd, runId), name), handoff);
40062
40228
  }
40063
40229
  function loadLatestRun(cwd) {
40064
40230
  try {
40065
40231
  const dir = packsDir(cwd);
40066
- const entries2 = fs78.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
40232
+ const entries2 = fs80.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
40067
40233
  for (let i = entries2.length - 1; i >= 0; i--) {
40068
- const file = path89.join(dir, entries2[i], "run.json");
40234
+ const file = path91.join(dir, entries2[i], "run.json");
40069
40235
  try {
40070
- const parsed = JSON.parse(fs78.readFileSync(file, "utf8"));
40236
+ const parsed = JSON.parse(fs80.readFileSync(file, "utf8"));
40071
40237
  if (parsed && typeof parsed.runId === "string") return parsed;
40072
40238
  } catch {
40073
40239
  }
@@ -40078,17 +40244,17 @@ function loadLatestRun(cwd) {
40078
40244
  }
40079
40245
  function ensureLedgerIgnored(cwd) {
40080
40246
  try {
40081
- const gitDir = path89.join(cwd, ".git");
40082
- if (!fs78.existsSync(gitDir)) return;
40083
- const exclude = path89.join(gitDir, "info", "exclude");
40247
+ const gitDir = path91.join(cwd, ".git");
40248
+ if (!fs80.existsSync(gitDir)) return;
40249
+ const exclude = path91.join(gitDir, "info", "exclude");
40084
40250
  let existing = "";
40085
40251
  try {
40086
- existing = fs78.readFileSync(exclude, "utf8");
40252
+ existing = fs80.readFileSync(exclude, "utf8");
40087
40253
  } catch {
40088
40254
  }
40089
40255
  if (existing.includes(".codeam/packs/")) return;
40090
- fs78.mkdirSync(path89.dirname(exclude), { recursive: true });
40091
- fs78.writeFileSync(exclude, `${existing.trimEnd()}
40256
+ fs80.mkdirSync(path91.dirname(exclude), { recursive: true });
40257
+ fs80.writeFileSync(exclude, `${existing.trimEnd()}
40092
40258
  .codeam/packs/
40093
40259
  `.trimStart());
40094
40260
  } catch {
@@ -41069,20 +41235,20 @@ async function mcpRouter() {
41069
41235
  }
41070
41236
 
41071
41237
  // src/integrations/mcp-secrets.ts
41072
- var fs80 = __toESM(require("fs"));
41073
- var os57 = __toESM(require("os"));
41074
- var path91 = __toESM(require("path"));
41238
+ var fs82 = __toESM(require("fs"));
41239
+ var os59 = __toESM(require("os"));
41240
+ var path93 = __toESM(require("path"));
41075
41241
  var MCP_SECRETS_FILE_ENV = "CODEAM_MCP_SECRETS_FILE";
41076
41242
  function mcpSecretsDir() {
41077
- return path91.join(os57.homedir(), ".codeam", "mcp-secrets");
41243
+ return path93.join(os59.homedir(), ".codeam", "mcp-secrets");
41078
41244
  }
41079
41245
  function mcpSecretsPath(scope, pid = process.pid) {
41080
- return path91.join(mcpSecretsDir(), `${pid}-${scope}.json`);
41246
+ return path93.join(mcpSecretsDir(), `${pid}-${scope}.json`);
41081
41247
  }
41082
41248
  var registeredForCleanup = /* @__PURE__ */ new Set();
41083
41249
  function readFileVars(file) {
41084
41250
  try {
41085
- const parsed = JSON.parse(fs80.readFileSync(file, "utf8"));
41251
+ const parsed = JSON.parse(fs82.readFileSync(file, "utf8"));
41086
41252
  if (!parsed || typeof parsed !== "object") return {};
41087
41253
  const out2 = {};
41088
41254
  for (const [k2, v] of Object.entries(parsed)) {
@@ -41104,7 +41270,7 @@ function pidAlive2(pid) {
41104
41270
  function pruneStale(dir) {
41105
41271
  let names = [];
41106
41272
  try {
41107
- names = fs80.readdirSync(dir);
41273
+ names = fs82.readdirSync(dir);
41108
41274
  } catch {
41109
41275
  return;
41110
41276
  }
@@ -41114,25 +41280,25 @@ function pruneStale(dir) {
41114
41280
  const pid = Number(m[1]);
41115
41281
  if (pid === process.pid || pidAlive2(pid)) continue;
41116
41282
  try {
41117
- fs80.unlinkSync(path91.join(dir, name));
41283
+ fs82.unlinkSync(path93.join(dir, name));
41118
41284
  } catch {
41119
41285
  }
41120
41286
  }
41121
41287
  }
41122
41288
  function writeMcpSecrets(vars, file) {
41123
41289
  try {
41124
- const dir = path91.dirname(file);
41125
- fs80.mkdirSync(dir, { recursive: true, mode: 448 });
41290
+ const dir = path93.dirname(file);
41291
+ fs82.mkdirSync(dir, { recursive: true, mode: 448 });
41126
41292
  pruneStale(dir);
41127
41293
  const tmp = `${file}.${process.pid}.tmp`;
41128
- fs80.writeFileSync(tmp, JSON.stringify(vars), { mode: 384 });
41129
- fs80.renameSync(tmp, file);
41130
- fs80.chmodSync(file, 384);
41294
+ fs82.writeFileSync(tmp, JSON.stringify(vars), { mode: 384 });
41295
+ fs82.renameSync(tmp, file);
41296
+ fs82.chmodSync(file, 384);
41131
41297
  if (!registeredForCleanup.has(file)) {
41132
41298
  registeredForCleanup.add(file);
41133
41299
  process.once("exit", () => {
41134
41300
  try {
41135
- fs80.unlinkSync(file);
41301
+ fs82.unlinkSync(file);
41136
41302
  } catch {
41137
41303
  }
41138
41304
  });
@@ -41218,11 +41384,11 @@ function previewMcpServer(bridge) {
41218
41384
  };
41219
41385
  }
41220
41386
  function httpCall(baseUrl, token) {
41221
- return async (path112, method, body, timeoutMs) => {
41387
+ return async (path114, method, body, timeoutMs) => {
41222
41388
  const ac = new AbortController();
41223
41389
  const timer = setTimeout(() => ac.abort(), timeoutMs);
41224
41390
  try {
41225
- const res = await fetch(`${baseUrl}${path112}`, {
41391
+ const res = await fetch(`${baseUrl}${path114}`, {
41226
41392
  method,
41227
41393
  headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
41228
41394
  ...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
@@ -41350,11 +41516,11 @@ function scratchMcpServer(bridge) {
41350
41516
  };
41351
41517
  }
41352
41518
  function httpCall2(baseUrl, token) {
41353
- return async (path112, method, body, timeoutMs) => {
41519
+ return async (path114, method, body, timeoutMs) => {
41354
41520
  const ac = new AbortController();
41355
41521
  const timer = setTimeout(() => ac.abort(), timeoutMs);
41356
41522
  try {
41357
- const res = await fetch(`${baseUrl}${path112}`, {
41523
+ const res = await fetch(`${baseUrl}${path114}`, {
41358
41524
  method,
41359
41525
  headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
41360
41526
  ...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
@@ -43939,6 +44105,7 @@ async function runAcpSession(opts) {
43939
44105
  try {
43940
44106
  handshake = await client3.start();
43941
44107
  } catch (startErr) {
44108
+ opts.onHandshakeSettled?.();
43942
44109
  const detail = describeError(startErr);
43943
44110
  log.warn("acpRunner", `ACP start failed for ${opts.agent}: ${detail}`);
43944
44111
  await surfaceStartupFailure({
@@ -43953,6 +44120,7 @@ async function runAcpSession(opts) {
43953
44120
  });
43954
44121
  return;
43955
44122
  }
44123
+ opts.onHandshakeSettled?.();
43956
44124
  let acpSessionId = handshake.sessionId;
43957
44125
  const { initialize, model: handshakeModel, tier: handshakeTier } = handshake;
43958
44126
  let agentCaps = initialize.agentCapabilities;
@@ -44257,17 +44425,17 @@ async function runAcpSession(opts) {
44257
44425
  switchCredentialEnv = provisionAgentCredentials(agentId, auth);
44258
44426
  },
44259
44427
  provisionHouseProxy: ({ baseUrl, token, model, managedAgentId }) => {
44260
- const claudeConfigDir2 = path94.join(
44261
- os59.homedir(),
44428
+ const claudeConfigDir2 = path96.join(
44429
+ os61.homedir(),
44262
44430
  ".codeam",
44263
44431
  "house-claude",
44264
44432
  `switch-${opts.pluginId}`
44265
44433
  );
44266
44434
  try {
44267
- fs83.mkdirSync(claudeConfigDir2, { recursive: true, mode: 448 });
44435
+ fs85.mkdirSync(claudeConfigDir2, { recursive: true, mode: 448 });
44268
44436
  } catch {
44269
44437
  }
44270
- const memoryFile = path94.join(claudeConfigDir2, "CLAUDE.md");
44438
+ const memoryFile = path96.join(claudeConfigDir2, "CLAUDE.md");
44271
44439
  ensureBeadsWorkflowHint(void 0, memoryFile);
44272
44440
  ensureAgentStandard(void 0, memoryFile);
44273
44441
  if (isScratchWorkspace(process.cwd())) ensureScratchWorkflowHint(void 0, memoryFile);
@@ -45498,9 +45666,9 @@ function pickPinnedSession(pinnedId, listSessions2) {
45498
45666
  }
45499
45667
 
45500
45668
  // src/agents/retired-proxy-cleanup.ts
45501
- var fs84 = __toESM(require("fs"));
45502
- var path95 = __toESM(require("path"));
45503
- var os60 = __toESM(require("os"));
45669
+ var fs86 = __toESM(require("fs"));
45670
+ var path97 = __toESM(require("path"));
45671
+ var os62 = __toESM(require("os"));
45504
45672
  var RETIRED_PROXY_RE = /^https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):8787(?:[/?#]|$)/i;
45505
45673
  var HEADROOM_CMD_RE = /(^|[\s/"'])headroom(\s|$)/i;
45506
45674
  var MARKETPLACE_KEY = "headroom-marketplace";
@@ -45509,12 +45677,12 @@ function isHeadroomHook(group) {
45509
45677
  (h) => typeof h?.command === "string" && HEADROOM_CMD_RE.test(h.command)
45510
45678
  );
45511
45679
  }
45512
- function sanitizeRetiredProxyConfig(homeDir2 = os60.homedir()) {
45680
+ function sanitizeRetiredProxyConfig(homeDir2 = os62.homedir()) {
45513
45681
  const out2 = { inspected: false, changed: false, removed: [] };
45514
- const file = path95.join(homeDir2, ".claude", "settings.json");
45682
+ const file = path97.join(homeDir2, ".claude", "settings.json");
45515
45683
  let parsed;
45516
45684
  try {
45517
- parsed = JSON.parse(fs84.readFileSync(file, "utf8"));
45685
+ parsed = JSON.parse(fs86.readFileSync(file, "utf8"));
45518
45686
  } catch {
45519
45687
  return out2;
45520
45688
  }
@@ -45556,9 +45724,9 @@ function sanitizeRetiredProxyConfig(homeDir2 = os60.homedir()) {
45556
45724
  if (!out2.changed) return out2;
45557
45725
  try {
45558
45726
  const tmp = `${file}.codeam.tmp`;
45559
- fs84.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
45727
+ fs86.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
45560
45728
  `, { mode: 384 });
45561
- fs84.renameSync(tmp, file);
45729
+ fs86.renameSync(tmp, file);
45562
45730
  } catch {
45563
45731
  out2.changed = false;
45564
45732
  }
@@ -46090,7 +46258,7 @@ var AcpDriver = class {
46090
46258
  };
46091
46259
 
46092
46260
  // src/baton/transcript-mirror.ts
46093
- var fs85 = __toESM(require("fs"));
46261
+ var fs87 = __toESM(require("fs"));
46094
46262
  var TranscriptMirror = class {
46095
46263
  constructor(deps) {
46096
46264
  this.deps = deps;
@@ -46184,7 +46352,7 @@ var TranscriptMirror = class {
46184
46352
  }
46185
46353
  };
46186
46354
  function defaultWatch(file, onChange) {
46187
- const w3 = fs85.watch(file, { persistent: false }, () => onChange());
46355
+ const w3 = fs87.watch(file, { persistent: false }, () => onChange());
46188
46356
  return () => w3.close();
46189
46357
  }
46190
46358
 
@@ -46530,16 +46698,16 @@ function keepDeviceAwake(deps = {}) {
46530
46698
  }
46531
46699
 
46532
46700
  // src/agents/claude/onboarding.ts
46533
- var fs86 = __toESM(require("fs"));
46534
- var os62 = __toESM(require("os"));
46535
- var path96 = __toESM(require("path"));
46701
+ var fs88 = __toESM(require("fs"));
46702
+ var os64 = __toESM(require("os"));
46703
+ var path98 = __toESM(require("path"));
46536
46704
  var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
46537
46705
  function ensureClaudeOnboarded(cwd) {
46538
46706
  try {
46539
- const file = path96.join(os62.homedir(), ".claude.json");
46707
+ const file = path98.join(os64.homedir(), ".claude.json");
46540
46708
  let config = {};
46541
46709
  try {
46542
- config = JSON.parse(fs86.readFileSync(file, "utf8"));
46710
+ config = JSON.parse(fs88.readFileSync(file, "utf8"));
46543
46711
  } catch {
46544
46712
  }
46545
46713
  let changed = false;
@@ -46564,8 +46732,8 @@ function ensureClaudeOnboarded(cwd) {
46564
46732
  }
46565
46733
  }
46566
46734
  if (!changed) return;
46567
- fs86.mkdirSync(path96.dirname(file), { recursive: true });
46568
- fs86.writeFileSync(file, JSON.stringify(config, null, 2));
46735
+ fs88.mkdirSync(path98.dirname(file), { recursive: true });
46736
+ fs88.writeFileSync(file, JSON.stringify(config, null, 2));
46569
46737
  log.info(
46570
46738
  "claude",
46571
46739
  `pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
@@ -46576,6 +46744,7 @@ function ensureClaudeOnboarded(cwd) {
46576
46744
  }
46577
46745
 
46578
46746
  // src/commands/start.ts
46747
+ var BEADS_AFTER_HANDSHAKE_CAP_MS = 6e4;
46579
46748
  async function start(requestedAgent, presetSession) {
46580
46749
  installRelayCrashGuards();
46581
46750
  showIntro();
@@ -46614,6 +46783,10 @@ async function start(requestedAgent, presetSession) {
46614
46783
  if (!session.agent) {
46615
46784
  throw new Error("Active session has no agent \u2014 re-pair with `codeam pair`.");
46616
46785
  }
46786
+ if (!isLocalSession() && session.agent === "claude") {
46787
+ const claudeBinary = resolveClaudeNativeBinary();
46788
+ if (claudeBinary) prefetchIntoPageCache(claudeBinary);
46789
+ }
46617
46790
  const pluginId = session.pluginId ?? ensurePluginId();
46618
46791
  showInfo(`${session.userName} \xB7 ${import_picocolors3.default.cyan(session.plan)}`);
46619
46792
  showInfo(`Launching ${AGENT_REGISTRY[session.agent].displayName}...
@@ -46670,6 +46843,22 @@ async function start(requestedAgent, presetSession) {
46670
46843
  }
46671
46844
  }
46672
46845
  purgeExports();
46846
+ const releaseStartupMark = markAgentStarting();
46847
+ process.once("exit", releaseStartupMark);
46848
+ let settleOwnHandshake = () => void 0;
46849
+ const ownHandshakeSettled = new Promise((resolve14) => {
46850
+ settleOwnHandshake = resolve14;
46851
+ });
46852
+ const releaseBeads = () => {
46853
+ releaseStartupMark();
46854
+ settleOwnHandshake();
46855
+ };
46856
+ const agentHandshakeSettled = Promise.race([
46857
+ ownHandshakeSettled.then(
46858
+ () => waitForNoAgentStarting({ timeoutMs: BEADS_AFTER_HANDSHAKE_CAP_MS })
46859
+ ),
46860
+ new Promise((resolve14) => setTimeout(resolve14, BEADS_AFTER_HANDSHAKE_CAP_MS).unref())
46861
+ ]);
46673
46862
  const beadsReady = provisionBeadsForStart({
46674
46863
  sessionId: session.id,
46675
46864
  pluginId,
@@ -46677,7 +46866,8 @@ async function start(requestedAgent, presetSession) {
46677
46866
  cwd,
46678
46867
  // Wire this session's agent natively via `bd setup <recipe> --global` so
46679
46868
  // the agent actually uses bd (D12 — REVISED). Covers BOTH ACP and PTY.
46680
- agents: [session.agent]
46869
+ agents: [session.agent],
46870
+ deferUntil: agentHandshakeSettled
46681
46871
  }).then((started) => {
46682
46872
  beads = started;
46683
46873
  return started;
@@ -46746,12 +46936,13 @@ async function start(requestedAgent, presetSession) {
46746
46936
  if (gateTimer) clearTimeout(gateTimer);
46747
46937
  log.info(
46748
46938
  "beads",
46749
- `agent-spawn gate released (beads ungated, ${beads ? "already ready" : "still provisioning in background"}); project deps provisioned`
46939
+ "agent-spawn gate released (beads waits for the agent handshake); project deps provisioned"
46750
46940
  );
46751
46941
  }
46752
46942
  const releaseKeepAwake = keepDeviceAwake();
46753
46943
  process.once("exit", releaseKeepAwake);
46754
46944
  if (isLocalSession() && requiresAcp(session.agent)) {
46945
+ releaseBeads();
46755
46946
  const adapter = await resolveAcpAdapterWithRetry(session.agent);
46756
46947
  const batonCapable = runtimeSupportsBaton(createRuntimeStrategy(session.agent));
46757
46948
  if (batonCapable && adapter && session.pluginAuthToken) {
@@ -46815,6 +47006,7 @@ async function start(requestedAgent, presetSession) {
46815
47006
  adapter,
46816
47007
  cwd,
46817
47008
  getBeads,
47009
+ onHandshakeSettled: releaseBeads,
46818
47010
  pollSecret: session.pollSecret,
46819
47011
  mcpServers,
46820
47012
  // AUTO mode for headless, mobile-driven sessions: no human at the box
@@ -46830,6 +47022,7 @@ async function start(requestedAgent, presetSession) {
46830
47022
  if (requiresAcp(session.agent)) {
46831
47023
  log.error("acp", `[anomaly] acp-required agent on PTY runtime (agent=${session.agent})`);
46832
47024
  }
47025
+ releaseBeads();
46833
47026
  const runtime = createRuntimeStrategy(session.agent);
46834
47027
  const historySvc = new HistoryService(runtime, pluginId, cwd, {
46835
47028
  pluginAuthToken: session.pluginAuthToken
@@ -47357,7 +47550,7 @@ var import_picocolors10 = __toESM(require("picocolors"));
47357
47550
  var import_child_process30 = require("child_process");
47358
47551
  var import_util4 = require("util");
47359
47552
  var import_picocolors8 = __toESM(require("picocolors"));
47360
- var path97 = __toESM(require("path"));
47553
+ var path99 = __toESM(require("path"));
47361
47554
  var execFileP6 = (0, import_util4.promisify)(import_child_process30.execFile);
47362
47555
  var MAX_BUFFER = 8 * 1024 * 1024;
47363
47556
  function resetStdinForChild() {
@@ -47846,7 +48039,7 @@ var GitHubCodespacesProvider = class {
47846
48039
  });
47847
48040
  }
47848
48041
  async uploadFile(workspaceId, remotePath, contents, options = {}) {
47849
- const remoteDir = path97.posix.dirname(remotePath);
48042
+ const remoteDir = path99.posix.dirname(remotePath);
47850
48043
  const parts = [
47851
48044
  `mkdir -p ${shellQuote(remoteDir)}`,
47852
48045
  `cat > ${shellQuote(remotePath)}`
@@ -47916,7 +48109,7 @@ function shellQuote(s) {
47916
48109
  // src/services/providers/gitpod.ts
47917
48110
  var import_child_process31 = require("child_process");
47918
48111
  var import_util5 = require("util");
47919
- var path98 = __toESM(require("path"));
48112
+ var path100 = __toESM(require("path"));
47920
48113
  var import_picocolors9 = __toESM(require("picocolors"));
47921
48114
  var execFileP7 = (0, import_util5.promisify)(import_child_process31.execFile);
47922
48115
  var MAX_BUFFER2 = 8 * 1024 * 1024;
@@ -48156,7 +48349,7 @@ var GitpodProvider = class {
48156
48349
  });
48157
48350
  }
48158
48351
  async uploadFile(workspaceId, remotePath, contents, options = {}) {
48159
- const remoteDir = path98.posix.dirname(remotePath);
48352
+ const remoteDir = path100.posix.dirname(remotePath);
48160
48353
  const parts = [
48161
48354
  `mkdir -p ${shellQuote2(remoteDir)}`,
48162
48355
  `cat > ${shellQuote2(remotePath)}`
@@ -48192,7 +48385,7 @@ function shellQuote2(s) {
48192
48385
  // src/services/providers/gitlab-workspaces.ts
48193
48386
  var import_child_process32 = require("child_process");
48194
48387
  var import_util6 = require("util");
48195
- var path99 = __toESM(require("path"));
48388
+ var path101 = __toESM(require("path"));
48196
48389
  var execFileP8 = (0, import_util6.promisify)(import_child_process32.execFile);
48197
48390
  var MAX_BUFFER3 = 8 * 1024 * 1024;
48198
48391
  var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
@@ -48452,7 +48645,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
48452
48645
  }
48453
48646
  async uploadFile(workspaceId, remotePath, contents, options = {}) {
48454
48647
  const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
48455
- const remoteDir = path99.posix.dirname(remotePath);
48648
+ const remoteDir = path101.posix.dirname(remotePath);
48456
48649
  const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
48457
48650
  if (options.mode != null) {
48458
48651
  parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
@@ -48520,7 +48713,7 @@ function shellQuote3(s) {
48520
48713
  // src/services/providers/railway.ts
48521
48714
  var import_child_process33 = require("child_process");
48522
48715
  var import_util7 = require("util");
48523
- var path100 = __toESM(require("path"));
48716
+ var path102 = __toESM(require("path"));
48524
48717
  var execFileP9 = (0, import_util7.promisify)(import_child_process33.execFile);
48525
48718
  var MAX_BUFFER4 = 8 * 1024 * 1024;
48526
48719
  function resetStdinForChild4() {
@@ -48756,7 +48949,7 @@ var RailwayProvider = class {
48756
48949
  if (!projectId || !serviceId) {
48757
48950
  throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
48758
48951
  }
48759
- const remoteDir = path100.posix.dirname(remotePath);
48952
+ const remoteDir = path102.posix.dirname(remotePath);
48760
48953
  const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
48761
48954
  if (options.mode != null) {
48762
48955
  parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
@@ -49296,14 +49489,14 @@ async function stopWorkspaceFromLocal(target) {
49296
49489
  }
49297
49490
 
49298
49491
  // src/commands/host/host-client.ts
49299
- var fs87 = __toESM(require("fs"));
49300
- var os63 = __toESM(require("os"));
49301
- var path101 = __toESM(require("path"));
49492
+ var fs89 = __toESM(require("fs"));
49493
+ var os65 = __toESM(require("os"));
49494
+ var path103 = __toESM(require("path"));
49302
49495
  var import_node_crypto16 = require("crypto");
49303
49496
  function sampleCpuTimes() {
49304
49497
  let idle = 0;
49305
49498
  let total = 0;
49306
- for (const cpu of os63.cpus()) {
49499
+ for (const cpu of os65.cpus()) {
49307
49500
  const t2 = cpu.times;
49308
49501
  idle += t2.idle;
49309
49502
  total += t2.user + t2.nice + t2.sys + t2.idle + t2.irq;
@@ -49323,8 +49516,8 @@ var MetricsCollector = class {
49323
49516
  const prev = this.prevCpu;
49324
49517
  this.prevCpu = current2;
49325
49518
  if (!prev) {
49326
- const cores = os63.cpus().length || 1;
49327
- const proxy = os63.loadavg()[0] / cores * 100;
49519
+ const cores = os65.cpus().length || 1;
49520
+ const proxy = os65.loadavg()[0] / cores * 100;
49328
49521
  return Math.min(100, Math.max(0, Math.round(proxy)));
49329
49522
  }
49330
49523
  const idleDelta = current2.idle - prev.idle;
@@ -49337,8 +49530,8 @@ var MetricsCollector = class {
49337
49530
  collect() {
49338
49531
  return {
49339
49532
  cpuPct: this.cpuPct(),
49340
- ramUsedMb: Math.round((os63.totalmem() - os63.freemem()) / 1048576),
49341
- ramTotalMb: Math.round(os63.totalmem() / 1048576),
49533
+ ramUsedMb: Math.round((os65.totalmem() - os65.freemem()) / 1048576),
49534
+ ramTotalMb: Math.round(os65.totalmem() / 1048576),
49342
49535
  latencyMs: this.lastLatencyMs
49343
49536
  };
49344
49537
  }
@@ -49347,19 +49540,19 @@ function apiBase() {
49347
49540
  return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
49348
49541
  }
49349
49542
  function hostIdentityPath() {
49350
- return path101.join(os63.homedir(), ".codeam", "host-agent.json");
49543
+ return path103.join(os65.homedir(), ".codeam", "host-agent.json");
49351
49544
  }
49352
49545
  function collectOsInfo() {
49353
49546
  return {
49354
- distro: os63.platform(),
49355
- arch: os63.arch(),
49356
- kernel: os63.release(),
49547
+ distro: os65.platform(),
49548
+ arch: os65.arch(),
49549
+ kernel: os65.release(),
49357
49550
  nodeVersion: process.versions.node
49358
49551
  };
49359
49552
  }
49360
49553
  function loadHostIdentity() {
49361
49554
  try {
49362
- const raw = fs87.readFileSync(hostIdentityPath(), "utf8");
49555
+ const raw = fs89.readFileSync(hostIdentityPath(), "utf8");
49363
49556
  const parsed = JSON.parse(raw);
49364
49557
  if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
49365
49558
  const p2 = parsed;
@@ -49387,8 +49580,8 @@ function ensureControlPollSecret(identity, save = saveHostIdentity) {
49387
49580
  }
49388
49581
  function saveHostIdentity(identity) {
49389
49582
  const file = hostIdentityPath();
49390
- fs87.mkdirSync(path101.dirname(file), { recursive: true, mode: 448 });
49391
- fs87.writeFileSync(file, JSON.stringify(identity, null, 2), {
49583
+ fs89.mkdirSync(path103.dirname(file), { recursive: true, mode: 448 });
49584
+ fs89.writeFileSync(file, JSON.stringify(identity, null, 2), {
49392
49585
  encoding: "utf8",
49393
49586
  mode: 384
49394
49587
  });
@@ -49433,7 +49626,7 @@ function isTerminalEnrollError(err) {
49433
49626
  }
49434
49627
  function deleteHostIdentity() {
49435
49628
  try {
49436
- fs87.rmSync(hostIdentityPath(), { force: true });
49629
+ fs89.rmSync(hostIdentityPath(), { force: true });
49437
49630
  } catch {
49438
49631
  }
49439
49632
  }
@@ -49457,7 +49650,7 @@ async function postJson(pathname, body) {
49457
49650
  function resolveHostLabel(label) {
49458
49651
  const explicit = label?.trim();
49459
49652
  const envLabel = process.env.CODEAM_HOST_LABEL?.trim();
49460
- const resolved = explicit || envLabel || os63.hostname();
49653
+ const resolved = explicit || envLabel || os65.hostname();
49461
49654
  return resolved.slice(0, 80);
49462
49655
  }
49463
49656
  async function redeemEnrollToken(token, label) {
@@ -49650,9 +49843,9 @@ async function host(args2) {
49650
49843
 
49651
49844
  // src/commands/host-agent.ts
49652
49845
  var import_node_child_process36 = require("child_process");
49653
- var os69 = __toESM(require("os"));
49654
- var fs94 = __toESM(require("fs"));
49655
- var path108 = __toESM(require("path"));
49846
+ var os71 = __toESM(require("os"));
49847
+ var fs96 = __toESM(require("fs"));
49848
+ var path110 = __toESM(require("path"));
49656
49849
 
49657
49850
  // src/skills/persist-from-payload.ts
49658
49851
  function persistOrClearSkillsFromPayload(skills) {
@@ -49661,13 +49854,13 @@ function persistOrClearSkillsFromPayload(skills) {
49661
49854
  }
49662
49855
 
49663
49856
  // src/commands/host/session-state.ts
49664
- var fs88 = __toESM(require("fs"));
49665
- var os64 = __toESM(require("os"));
49666
- var path102 = __toESM(require("path"));
49857
+ var fs90 = __toESM(require("fs"));
49858
+ var os66 = __toESM(require("os"));
49859
+ var path104 = __toESM(require("path"));
49667
49860
  function hostSessionStatePath(env = process.env) {
49668
49861
  const override = env.CODEAM_HOST_SESSION_STATE_FILE;
49669
49862
  if (override && override.trim()) return override.trim();
49670
- return path102.join(os64.homedir(), ".codeam", "host-agent-sessions.json");
49863
+ return path104.join(os66.homedir(), ".codeam", "host-agent-sessions.json");
49671
49864
  }
49672
49865
  function isRecord5(v) {
49673
49866
  if (typeof v !== "object" || v === null) return false;
@@ -49678,7 +49871,7 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
49678
49871
  return {
49679
49872
  load() {
49680
49873
  try {
49681
- const raw = JSON.parse(fs88.readFileSync(file, "utf8"));
49874
+ const raw = JSON.parse(fs90.readFileSync(file, "utf8"));
49682
49875
  return Array.isArray(raw?.sessions) ? raw.sessions.filter(isRecord5) : null;
49683
49876
  } catch {
49684
49877
  return null;
@@ -49686,18 +49879,18 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
49686
49879
  },
49687
49880
  save(list) {
49688
49881
  try {
49689
- fs88.mkdirSync(path102.dirname(file), { recursive: true, mode: 448 });
49882
+ fs90.mkdirSync(path104.dirname(file), { recursive: true, mode: 448 });
49690
49883
  const tmp = `${file}.${process.pid}.tmp`;
49691
- fs88.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
49884
+ fs90.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
49692
49885
  mode: 384
49693
49886
  });
49694
- fs88.renameSync(tmp, file);
49887
+ fs90.renameSync(tmp, file);
49695
49888
  } catch {
49696
49889
  }
49697
49890
  },
49698
49891
  clear() {
49699
49892
  try {
49700
- fs88.rmSync(file, { force: true });
49893
+ fs90.rmSync(file, { force: true });
49701
49894
  } catch {
49702
49895
  }
49703
49896
  }
@@ -49720,10 +49913,10 @@ function planSessionResume(records, max) {
49720
49913
  return { resume: ordered.slice(0, bound), dropped: ordered.slice(bound) };
49721
49914
  }
49722
49915
  function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
49723
- const target = path102.resolve(cwd);
49916
+ const target = path104.resolve(cwd);
49724
49917
  const reconnectable = (s) => !!s.pluginId && !!s.pollSecret && !!s.agent;
49725
49918
  const matches = sessions3.filter(
49726
- (s) => !!s.cwd && path102.resolve(s.cwd) === target && reconnectable(s)
49919
+ (s) => !!s.cwd && path104.resolve(s.cwd) === target && reconnectable(s)
49727
49920
  );
49728
49921
  if (matches.length > 0) {
49729
49922
  matches.sort((a, b) => b.pairedAt - a.pairedAt);
@@ -49735,11 +49928,11 @@ function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
49735
49928
 
49736
49929
  // src/commands/host/git-tooling.ts
49737
49930
  var import_node_child_process31 = require("child_process");
49738
- var fs89 = __toESM(require("fs"));
49739
- var os65 = __toESM(require("os"));
49740
- var path103 = __toESM(require("path"));
49931
+ var fs91 = __toESM(require("fs"));
49932
+ var os67 = __toESM(require("os"));
49933
+ var path105 = __toESM(require("path"));
49741
49934
  function codeamBinDir() {
49742
- return process.env.CODEAM_BIN_DIR ?? path103.join(os65.homedir(), ".codeam", "bin");
49935
+ return process.env.CODEAM_BIN_DIR ?? path105.join(os67.homedir(), ".codeam", "bin");
49743
49936
  }
49744
49937
  var FALLBACK_GH_VERSION = "2.62.0";
49745
49938
  var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
@@ -49771,7 +49964,7 @@ async function download(url2, dest) {
49771
49964
  const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
49772
49965
  if (!res.ok || !res.body) return false;
49773
49966
  const buf = Buffer.from(await res.arrayBuffer());
49774
- fs89.writeFileSync(dest, buf);
49967
+ fs91.writeFileSync(dest, buf);
49775
49968
  return true;
49776
49969
  } catch {
49777
49970
  return false;
@@ -49794,8 +49987,8 @@ async function ensureGhCli(runner, token, deps = {}) {
49794
49987
  const version3 = await resolveVersionFn(token);
49795
49988
  const asset = `gh_${version3}_${osToken}_${arch2}`;
49796
49989
  const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
49797
- const tmpRoot = fs89.mkdtempSync(path103.join(os65.tmpdir(), "codeam-gh-"));
49798
- const archive = path103.join(tmpRoot, `${asset}.${ext}`);
49990
+ const tmpRoot = fs91.mkdtempSync(path105.join(os67.tmpdir(), "codeam-gh-"));
49991
+ const archive = path105.join(tmpRoot, `${asset}.${ext}`);
49799
49992
  if (!await downloadFn(url2, archive)) {
49800
49993
  log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
49801
49994
  return null;
@@ -49805,16 +49998,16 @@ async function ensureGhCli(runner, token, deps = {}) {
49805
49998
  log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
49806
49999
  return null;
49807
50000
  }
49808
- const extractedBin = path103.join(tmpRoot, asset, "bin", binaryName);
49809
- if (!fs89.existsSync(extractedBin)) {
50001
+ const extractedBin = path105.join(tmpRoot, asset, "bin", binaryName);
50002
+ if (!fs91.existsSync(extractedBin)) {
49810
50003
  log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
49811
50004
  return null;
49812
50005
  }
49813
50006
  const binDir = codeamBinDir();
49814
- fs89.mkdirSync(binDir, { recursive: true });
49815
- const target = path103.join(binDir, binaryName);
49816
- fs89.copyFileSync(extractedBin, target);
49817
- fs89.chmodSync(target, 493);
50007
+ fs91.mkdirSync(binDir, { recursive: true });
50008
+ const target = path105.join(binDir, binaryName);
50009
+ fs91.copyFileSync(extractedBin, target);
50010
+ fs91.chmodSync(target, 493);
49818
50011
  log.info("host-agent", `gh installed to ${target} (v${version3})`);
49819
50012
  return target;
49820
50013
  } catch (e) {
@@ -49851,19 +50044,19 @@ async function ensureGhAuth(runner, ghCmd, token) {
49851
50044
  }
49852
50045
  function ghConfigDir() {
49853
50046
  if (process.env.GH_CONFIG_DIR) return process.env.GH_CONFIG_DIR;
49854
- if (process.env.XDG_CONFIG_HOME) return path103.join(process.env.XDG_CONFIG_HOME, "gh");
50047
+ if (process.env.XDG_CONFIG_HOME) return path105.join(process.env.XDG_CONFIG_HOME, "gh");
49855
50048
  if (process.platform === "win32" && process.env.APPDATA) {
49856
- return path103.join(process.env.APPDATA, "GitHub CLI");
50049
+ return path105.join(process.env.APPDATA, "GitHub CLI");
49857
50050
  }
49858
- return path103.join(os65.homedir(), ".config", "gh");
50051
+ return path105.join(os67.homedir(), ".config", "gh");
49859
50052
  }
49860
50053
  function writeGhHostsToken(token) {
49861
50054
  try {
49862
50055
  const dir = ghConfigDir();
49863
- const file = path103.join(dir, "hosts.yml");
49864
- if (fs89.existsSync(file)) return false;
49865
- fs89.mkdirSync(dir, { recursive: true, mode: 448 });
49866
- fs89.writeFileSync(
50056
+ const file = path105.join(dir, "hosts.yml");
50057
+ if (fs91.existsSync(file)) return false;
50058
+ fs91.mkdirSync(dir, { recursive: true, mode: 448 });
50059
+ fs91.writeFileSync(
49867
50060
  file,
49868
50061
  `github.com:
49869
50062
  oauth_token: ${token}
@@ -49906,8 +50099,8 @@ async function ensureGlabCli(runner, deps = {}) {
49906
50099
  const version3 = await resolveLatestGlabVersion();
49907
50100
  const asset = `glab_${version3}_${osToken}_${arch2}`;
49908
50101
  const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
49909
- const tmpRoot = fs89.mkdtempSync(path103.join(os65.tmpdir(), "codeam-glab-"));
49910
- const archive = path103.join(tmpRoot, `${asset}.${ext}`);
50102
+ const tmpRoot = fs91.mkdtempSync(path105.join(os67.tmpdir(), "codeam-glab-"));
50103
+ const archive = path105.join(tmpRoot, `${asset}.${ext}`);
49911
50104
  if (!await downloadFn(url2, archive)) {
49912
50105
  log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
49913
50106
  return null;
@@ -49918,20 +50111,20 @@ async function ensureGlabCli(runner, deps = {}) {
49918
50111
  return null;
49919
50112
  }
49920
50113
  const candidates = [
49921
- path103.join(tmpRoot, "bin", binaryName),
49922
- path103.join(tmpRoot, asset, "bin", binaryName),
49923
- path103.join(tmpRoot, binaryName)
50114
+ path105.join(tmpRoot, "bin", binaryName),
50115
+ path105.join(tmpRoot, asset, "bin", binaryName),
50116
+ path105.join(tmpRoot, binaryName)
49924
50117
  ];
49925
- const extractedBin = candidates.find((c2) => fs89.existsSync(c2));
50118
+ const extractedBin = candidates.find((c2) => fs91.existsSync(c2));
49926
50119
  if (!extractedBin) {
49927
50120
  log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
49928
50121
  return null;
49929
50122
  }
49930
50123
  const binDir = codeamBinDir();
49931
- fs89.mkdirSync(binDir, { recursive: true });
49932
- const target = path103.join(binDir, binaryName);
49933
- fs89.copyFileSync(extractedBin, target);
49934
- fs89.chmodSync(target, 493);
50124
+ fs91.mkdirSync(binDir, { recursive: true });
50125
+ const target = path105.join(binDir, binaryName);
50126
+ fs91.copyFileSync(extractedBin, target);
50127
+ fs91.chmodSync(target, 493);
49935
50128
  log.info("host-agent", `glab installed to ${target} (v${version3})`);
49936
50129
  return target;
49937
50130
  } catch (e) {
@@ -50010,14 +50203,14 @@ var defaultGitToolingRunner = {
50010
50203
  };
50011
50204
 
50012
50205
  // src/lib/cli-versions.ts
50013
- var fs91 = __toESM(require("fs"));
50014
- var os67 = __toESM(require("os"));
50015
- var path105 = __toESM(require("path"));
50206
+ var fs93 = __toESM(require("fs"));
50207
+ var os69 = __toESM(require("os"));
50208
+ var path107 = __toESM(require("path"));
50016
50209
 
50017
50210
  // src/lib/updateNotifier.ts
50018
- var fs90 = __toESM(require("fs"));
50019
- var os66 = __toESM(require("os"));
50020
- var path104 = __toESM(require("path"));
50211
+ var fs92 = __toESM(require("fs"));
50212
+ var os68 = __toESM(require("os"));
50213
+ var path106 = __toESM(require("path"));
50021
50214
  var https8 = __toESM(require("https"));
50022
50215
  var import_node_child_process32 = require("child_process");
50023
50216
  var import_picocolors12 = __toESM(require("picocolors"));
@@ -50026,12 +50219,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
50026
50219
  var TTL_MS = 24 * 60 * 60 * 1e3;
50027
50220
  var REQUEST_TIMEOUT_MS = 1500;
50028
50221
  function cachePath() {
50029
- const dir = path104.join(os66.homedir(), ".codeam");
50030
- return path104.join(dir, "update-check.json");
50222
+ const dir = path106.join(os68.homedir(), ".codeam");
50223
+ return path106.join(dir, "update-check.json");
50031
50224
  }
50032
50225
  function readCache() {
50033
50226
  try {
50034
- const raw = fs90.readFileSync(cachePath(), "utf8");
50227
+ const raw = fs92.readFileSync(cachePath(), "utf8");
50035
50228
  const parsed = JSON.parse(raw);
50036
50229
  if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
50037
50230
  return parsed;
@@ -50042,10 +50235,10 @@ function readCache() {
50042
50235
  function writeCache(cache) {
50043
50236
  try {
50044
50237
  const file = cachePath();
50045
- fs90.mkdirSync(path104.dirname(file), { recursive: true });
50238
+ fs92.mkdirSync(path106.dirname(file), { recursive: true });
50046
50239
  const tmp = `${file}.${process.pid}.tmp`;
50047
- fs90.writeFileSync(tmp, JSON.stringify(cache));
50048
- fs90.renameSync(tmp, file);
50240
+ fs92.writeFileSync(tmp, JSON.stringify(cache));
50241
+ fs92.renameSync(tmp, file);
50049
50242
  } catch {
50050
50243
  }
50051
50244
  }
@@ -50119,8 +50312,8 @@ function isLinkedInstall() {
50119
50312
  timeout: 2e3
50120
50313
  }).trim();
50121
50314
  if (!root) return false;
50122
- const pkgPath = path104.join(root, PKG_NAME);
50123
- return fs90.lstatSync(pkgPath).isSymbolicLink();
50315
+ const pkgPath = path106.join(root, PKG_NAME);
50316
+ return fs92.lstatSync(pkgPath).isSymbolicLink();
50124
50317
  } catch {
50125
50318
  return false;
50126
50319
  }
@@ -50156,7 +50349,7 @@ function maybeAutoUpdate(currentVersion, latest) {
50156
50349
  return;
50157
50350
  }
50158
50351
  try {
50159
- fs90.unlinkSync(cachePath());
50352
+ fs92.unlinkSync(cachePath());
50160
50353
  } catch {
50161
50354
  }
50162
50355
  process.stderr.write(` ${import_picocolors12.default.green("\u2713")} Updated. Resuming session...
@@ -50172,7 +50365,7 @@ async function autoUpgradeBeforeCriticalCommand() {
50172
50365
  if (process.env.NODE_ENV === "test") return;
50173
50366
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
50174
50367
  if (process.env.CI) return;
50175
- const current2 = true ? "2.76.11" : null;
50368
+ const current2 = true ? "2.76.13" : null;
50176
50369
  if (!current2) return;
50177
50370
  const cache = readCache();
50178
50371
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -50189,7 +50382,7 @@ function checkForUpdates() {
50189
50382
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
50190
50383
  if (process.env.CI) return;
50191
50384
  if (!process.stdout.isTTY) return;
50192
- const current2 = true ? "2.76.11" : null;
50385
+ const current2 = true ? "2.76.13" : null;
50193
50386
  if (!current2) return;
50194
50387
  const cache = readCache();
50195
50388
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -50212,10 +50405,10 @@ function versionedModeSupported(platform3 = process.platform) {
50212
50405
  return platform3 !== "win32";
50213
50406
  }
50214
50407
  function cliVersionsRoot(env = process.env) {
50215
- return env.CODEAM_CLI_VERSIONS_DIR || path105.join(os67.homedir(), ".codeam", "cli");
50408
+ return env.CODEAM_CLI_VERSIONS_DIR || path107.join(os69.homedir(), ".codeam", "cli");
50216
50409
  }
50217
50410
  function packageDirOf(versionDir) {
50218
- return path105.join(versionDir, "node_modules", CLI_PKG);
50411
+ return path107.join(versionDir, "node_modules", CLI_PKG);
50219
50412
  }
50220
50413
  function isRecord6(v) {
50221
50414
  return typeof v === "object" && v !== null;
@@ -50223,7 +50416,7 @@ function isRecord6(v) {
50223
50416
  function readPkg2(versionDir) {
50224
50417
  try {
50225
50418
  const raw = JSON.parse(
50226
- fs91.readFileSync(path105.join(packageDirOf(versionDir), "package.json"), "utf8")
50419
+ fs93.readFileSync(path107.join(packageDirOf(versionDir), "package.json"), "utf8")
50227
50420
  );
50228
50421
  return isRecord6(raw) ? raw : null;
50229
50422
  } catch {
@@ -50236,15 +50429,15 @@ function entryOf(versionDir) {
50236
50429
  const bin = pkg.bin;
50237
50430
  const named = isRecord6(bin) ? bin.codeam : void 0;
50238
50431
  const rel = typeof bin === "string" ? bin : typeof named === "string" ? named : "dist/index.js";
50239
- const entry = path105.join(packageDirOf(versionDir), rel);
50240
- return fs91.existsSync(entry) ? entry : null;
50432
+ const entry = path107.join(packageDirOf(versionDir), rel);
50433
+ return fs93.existsSync(entry) ? entry : null;
50241
50434
  }
50242
50435
  function launcherOf(versionDir) {
50243
50436
  const entry = entryOf(versionDir);
50244
50437
  if (!entry) return null;
50245
- const bin = path105.join(versionDir, "node_modules", ".bin", "codeam");
50438
+ const bin = path107.join(versionDir, "node_modules", ".bin", "codeam");
50246
50439
  try {
50247
- return fs91.realpathSync(bin) === fs91.realpathSync(entry) ? bin : entry;
50440
+ return fs93.realpathSync(bin) === fs93.realpathSync(entry) ? bin : entry;
50248
50441
  } catch {
50249
50442
  return entry;
50250
50443
  }
@@ -50257,16 +50450,16 @@ var BAD_MARKER_TTL_MS = 24 * 60 * 6e4;
50257
50450
  var PRE_READY_WINDOW_MS = 60 * 6e4;
50258
50451
  function isBad(versionDir, now = Date.now()) {
50259
50452
  try {
50260
- return now - fs91.statSync(path105.join(versionDir, ".bad")).mtimeMs < BAD_MARKER_TTL_MS;
50453
+ return now - fs93.statSync(path107.join(versionDir, ".bad")).mtimeMs < BAD_MARKER_TTL_MS;
50261
50454
  } catch {
50262
50455
  return false;
50263
50456
  }
50264
50457
  }
50265
50458
  function recordPreReadyFailure(versionDir, now = Date.now()) {
50266
- const file = path105.join(versionDir, ".prefail");
50459
+ const file = path107.join(versionDir, ".prefail");
50267
50460
  let count = 0;
50268
50461
  try {
50269
- const [n, at3] = fs91.readFileSync(file, "utf8").trim().split(" ").map(Number);
50462
+ const [n, at3] = fs93.readFileSync(file, "utf8").trim().split(" ").map(Number);
50270
50463
  if (Number.isFinite(n) && Number.isFinite(at3) && now - at3 < PRE_READY_WINDOW_MS) {
50271
50464
  count = n;
50272
50465
  }
@@ -50274,41 +50467,41 @@ function recordPreReadyFailure(versionDir, now = Date.now()) {
50274
50467
  }
50275
50468
  count += 1;
50276
50469
  try {
50277
- fs91.writeFileSync(file, `${count} ${now}`);
50470
+ fs93.writeFileSync(file, `${count} ${now}`);
50278
50471
  } catch {
50279
50472
  }
50280
50473
  return count;
50281
50474
  }
50282
50475
  function clearPreReadyFailures(versionDir) {
50283
- fs91.rmSync(path105.join(versionDir, ".prefail"), { force: true });
50476
+ fs93.rmSync(path107.join(versionDir, ".prefail"), { force: true });
50284
50477
  }
50285
50478
  function markBad(versionDir, reason) {
50286
50479
  try {
50287
- fs91.writeFileSync(path105.join(versionDir, ".bad"), `${(/* @__PURE__ */ new Date()).toISOString()} ${reason}
50480
+ fs93.writeFileSync(path107.join(versionDir, ".bad"), `${(/* @__PURE__ */ new Date()).toISOString()} ${reason}
50288
50481
  `);
50289
50482
  } catch {
50290
50483
  }
50291
50484
  }
50292
50485
  function pointerTarget(root, name) {
50293
50486
  try {
50294
- return fs91.realpathSync(path105.join(root, name));
50487
+ return fs93.realpathSync(path107.join(root, name));
50295
50488
  } catch {
50296
50489
  return null;
50297
50490
  }
50298
50491
  }
50299
50492
  function atomicPoint(root, name, targetDir) {
50300
- const tmp = path105.join(root, `.${name}.tmp-${process.pid}-${Date.now()}`);
50301
- fs91.symlinkSync(path105.relative(root, targetDir), tmp, "dir");
50493
+ const tmp = path107.join(root, `.${name}.tmp-${process.pid}-${Date.now()}`);
50494
+ fs93.symlinkSync(path107.relative(root, targetDir), tmp, "dir");
50302
50495
  try {
50303
- fs91.renameSync(tmp, path105.join(root, name));
50496
+ fs93.renameSync(tmp, path107.join(root, name));
50304
50497
  } catch (err) {
50305
- fs91.rmSync(tmp, { force: true });
50498
+ fs93.rmSync(tmp, { force: true });
50306
50499
  throw err;
50307
50500
  }
50308
50501
  }
50309
50502
  function switchCurrent(root, versionDir) {
50310
50503
  const old = pointerTarget(root, "current");
50311
- if (old && path105.resolve(old) !== path105.resolve(versionDir)) atomicPoint(root, "previous", old);
50504
+ if (old && path107.resolve(old) !== path107.resolve(versionDir)) atomicPoint(root, "previous", old);
50312
50505
  atomicPoint(root, "current", versionDir);
50313
50506
  }
50314
50507
  function validCurrent(root) {
@@ -50322,7 +50515,7 @@ function rollbackCurrent(root) {
50322
50515
  const prev = pointerTarget(root, "previous");
50323
50516
  if (!prev || isBad(prev) || !entryOf(prev)) return null;
50324
50517
  const cur = pointerTarget(root, "current");
50325
- if (cur && path105.resolve(cur) !== path105.resolve(prev)) atomicPoint(root, "previous", cur);
50518
+ if (cur && path107.resolve(cur) !== path107.resolve(prev)) atomicPoint(root, "previous", cur);
50326
50519
  atomicPoint(root, "current", prev);
50327
50520
  return versionOf(prev);
50328
50521
  }
@@ -50336,15 +50529,15 @@ function versionDirContaining(root, file) {
50336
50529
  let real;
50337
50530
  let realRoot;
50338
50531
  try {
50339
- real = fs91.realpathSync(file);
50340
- realRoot = fs91.realpathSync(root);
50532
+ real = fs93.realpathSync(file);
50533
+ realRoot = fs93.realpathSync(root);
50341
50534
  } catch {
50342
50535
  return null;
50343
50536
  }
50344
- const rel = path105.relative(realRoot, real);
50345
- if (rel.startsWith("..") || path105.isAbsolute(rel)) return null;
50346
- const first = rel.split(path105.sep)[0];
50347
- return first && SEMVER_DIR.test(first) ? path105.join(realRoot, first) : null;
50537
+ const rel = path107.relative(realRoot, real);
50538
+ if (rel.startsWith("..") || path107.isAbsolute(rel)) return null;
50539
+ const first = rel.split(path107.sep)[0];
50540
+ return first && SEMVER_DIR.test(first) ? path107.join(realRoot, first) : null;
50348
50541
  }
50349
50542
  function pidAlive3(pid) {
50350
50543
  try {
@@ -50357,7 +50550,7 @@ function pidAlive3(pid) {
50357
50550
  function livePids(versionDir) {
50358
50551
  let names;
50359
50552
  try {
50360
- names = fs91.readdirSync(path105.join(versionDir, ".pids"));
50553
+ names = fs93.readdirSync(path107.join(versionDir, ".pids"));
50361
50554
  } catch {
50362
50555
  return [];
50363
50556
  }
@@ -50366,11 +50559,11 @@ function livePids(versionDir) {
50366
50559
  function registerRunningVersion(root = cliVersionsRoot(), entry = process.argv[1]) {
50367
50560
  const dir = versionDirContaining(root, entry);
50368
50561
  if (!dir) return;
50369
- const file = path105.join(dir, ".pids", String(process.pid));
50562
+ const file = path107.join(dir, ".pids", String(process.pid));
50370
50563
  try {
50371
- fs91.mkdirSync(path105.dirname(file), { recursive: true });
50372
- fs91.writeFileSync(file, "");
50373
- process.once("exit", () => fs91.rmSync(file, { force: true }));
50564
+ fs93.mkdirSync(path107.dirname(file), { recursive: true });
50565
+ fs93.writeFileSync(file, "");
50566
+ process.once("exit", () => fs93.rmSync(file, { force: true }));
50374
50567
  } catch {
50375
50568
  }
50376
50569
  }
@@ -50378,7 +50571,7 @@ function gcVersions(root) {
50378
50571
  const removed = [];
50379
50572
  let names;
50380
50573
  try {
50381
- names = fs91.readdirSync(root).filter((n) => SEMVER_DIR.test(n));
50574
+ names = fs93.readdirSync(root).filter((n) => SEMVER_DIR.test(n));
50382
50575
  } catch {
50383
50576
  return removed;
50384
50577
  }
@@ -50386,13 +50579,13 @@ function gcVersions(root) {
50386
50579
  [...names].sort((a, b) => compareSemver(b, a)).slice(0, GC_KEEP_NEWEST)
50387
50580
  );
50388
50581
  for (const p2 of [pointerTarget(root, "current"), pointerTarget(root, "previous")]) {
50389
- if (p2) keep.add(path105.basename(p2));
50582
+ if (p2) keep.add(path107.basename(p2));
50390
50583
  }
50391
50584
  for (const name of names) {
50392
- const dir = path105.join(root, name);
50585
+ const dir = path107.join(root, name);
50393
50586
  if (keep.has(name) || livePids(dir).length > 0) continue;
50394
50587
  try {
50395
- fs91.rmSync(dir, { recursive: true, force: true });
50588
+ fs93.rmSync(dir, { recursive: true, force: true });
50396
50589
  removed.push(name);
50397
50590
  } catch {
50398
50591
  }
@@ -50400,25 +50593,25 @@ function gcVersions(root) {
50400
50593
  return removed;
50401
50594
  }
50402
50595
  function acquireInstallLock(root) {
50403
- const lock = path105.join(root, ".install.lock");
50596
+ const lock = path107.join(root, ".install.lock");
50404
50597
  for (let attempt = 0; attempt < 2; attempt++) {
50405
50598
  try {
50406
- const fd = fs91.openSync(lock, "wx");
50407
- fs91.writeSync(fd, String(process.pid));
50408
- fs91.closeSync(fd);
50409
- return () => fs91.rmSync(lock, { force: true });
50599
+ const fd = fs93.openSync(lock, "wx");
50600
+ fs93.writeSync(fd, String(process.pid));
50601
+ fs93.closeSync(fd);
50602
+ return () => fs93.rmSync(lock, { force: true });
50410
50603
  } catch (err) {
50411
50604
  if (err.code !== "EEXIST") return null;
50412
50605
  let stale = false;
50413
50606
  try {
50414
- const owner = Number(fs91.readFileSync(lock, "utf8"));
50415
- const age = Date.now() - fs91.statSync(lock).mtimeMs;
50607
+ const owner = Number(fs93.readFileSync(lock, "utf8"));
50608
+ const age = Date.now() - fs93.statSync(lock).mtimeMs;
50416
50609
  stale = !Number.isInteger(owner) || !pidAlive3(owner) || age > LOCK_STALE_MS;
50417
50610
  } catch {
50418
50611
  stale = true;
50419
50612
  }
50420
50613
  if (!stale) return null;
50421
- fs91.rmSync(lock, { force: true });
50614
+ fs93.rmSync(lock, { force: true });
50422
50615
  }
50423
50616
  }
50424
50617
  return null;
@@ -50426,9 +50619,9 @@ function acquireInstallLock(root) {
50426
50619
 
50427
50620
  // src/commands/host/host-launch.ts
50428
50621
  var import_node_child_process34 = require("child_process");
50429
- var fs93 = __toESM(require("fs"));
50430
- var os68 = __toESM(require("os"));
50431
- var path107 = __toESM(require("path"));
50622
+ var fs95 = __toESM(require("fs"));
50623
+ var os70 = __toESM(require("os"));
50624
+ var path109 = __toESM(require("path"));
50432
50625
 
50433
50626
  // src/exit-codes.ts
50434
50627
  var EXIT_OK = 0;
@@ -50450,8 +50643,8 @@ var EXIT_CODE_NAMES = {
50450
50643
 
50451
50644
  // src/commands/host/self-update.ts
50452
50645
  var import_node_child_process33 = require("child_process");
50453
- var fs92 = __toESM(require("fs"));
50454
- var path106 = __toESM(require("path"));
50646
+ var fs94 = __toESM(require("fs"));
50647
+ var path108 = __toESM(require("path"));
50455
50648
  var SELF_UPDATE_PKG = "codeam-cli";
50456
50649
  var SELF_UPDATE_INTERVAL_MS = 60 * 60 * 1e3;
50457
50650
  var SELF_UPDATE_STARTUP_DELAY_MS = 5e3;
@@ -50460,7 +50653,7 @@ var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
50460
50653
  var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
50461
50654
  var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
50462
50655
  function currentCliVersion() {
50463
- return true ? "2.76.11" : null;
50656
+ return true ? "2.76.13" : null;
50464
50657
  }
50465
50658
  async function installedVersion(deps) {
50466
50659
  const ls = await deps.run(
@@ -50552,9 +50745,9 @@ async function runSelfUpdateWith(deps) {
50552
50745
  var VERIFY_TIMEOUT_MS = 3e4;
50553
50746
  async function installVersioned(deps, root, latest, running2) {
50554
50747
  const node = deps.nodePath ?? process.execPath;
50555
- const target = path106.join(root, latest);
50748
+ const target = path108.join(root, latest);
50556
50749
  try {
50557
- fs92.mkdirSync(root, { recursive: true });
50750
+ fs94.mkdirSync(root, { recursive: true });
50558
50751
  } catch {
50559
50752
  return { status: "skipped" };
50560
50753
  }
@@ -50571,10 +50764,10 @@ async function installVersioned(deps, root, latest, running2) {
50571
50764
  const runningDir = versionDirContaining(root, deps.runningEntry);
50572
50765
  const reusable = entryOf(target) && versionOf(target) === latest;
50573
50766
  if (!reusable) {
50574
- if (runningDir && path106.resolve(runningDir) === path106.resolve(target)) {
50767
+ if (runningDir && path108.resolve(runningDir) === path108.resolve(target)) {
50575
50768
  return { status: "skipped" };
50576
50769
  }
50577
- fs92.rmSync(target, { recursive: true, force: true });
50770
+ fs94.rmSync(target, { recursive: true, force: true });
50578
50771
  const install = await deps.run(
50579
50772
  "npm",
50580
50773
  [
@@ -50589,7 +50782,7 @@ async function installVersioned(deps, root, latest, running2) {
50589
50782
  SELF_UPDATE_INSTALL_TIMEOUT_MS
50590
50783
  );
50591
50784
  if (install.code !== 0) {
50592
- fs92.rmSync(target, { recursive: true, force: true });
50785
+ fs94.rmSync(target, { recursive: true, force: true });
50593
50786
  log.warn(
50594
50787
  "host-agent",
50595
50788
  `self-update: versioned install exited ${String(install.code)} \u2014 staying on ${running2}: ` + install.stderr.slice(-300)
@@ -50600,7 +50793,7 @@ async function installVersioned(deps, root, latest, running2) {
50600
50793
  const entry = entryOf(target);
50601
50794
  const check = entry ? await deps.run(node, [entry, "--version"], VERIFY_TIMEOUT_MS) : { code: null, stdout: "", stderr: "no entry point" };
50602
50795
  if (check.code !== 0 || !check.stdout.includes(latest)) {
50603
- fs92.rmSync(target, { recursive: true, force: true });
50796
+ fs94.rmSync(target, { recursive: true, force: true });
50604
50797
  log.warn(
50605
50798
  "host-agent",
50606
50799
  `self-update: ${latest} failed verification (exit ${String(check.code)}: ${(check.stdout + check.stderr).trim().slice(-200)}) \u2014 staying on ${running2}`
@@ -50616,7 +50809,7 @@ async function installVersioned(deps, root, latest, running2) {
50616
50809
  return { status: "updated", version: latest };
50617
50810
  } catch (err) {
50618
50811
  const cur = pointerTarget(root, "current");
50619
- if (!cur || path106.basename(cur) !== latest) fs92.rmSync(target, { recursive: true, force: true });
50812
+ if (!cur || path108.basename(cur) !== latest) fs94.rmSync(target, { recursive: true, force: true });
50620
50813
  log.warn(
50621
50814
  "host-agent",
50622
50815
  `self-update: versioned install failed: ${err instanceof Error ? err.message : String(err)}`
@@ -50655,7 +50848,7 @@ function signalHostReady(send = process.send?.bind(process)) {
50655
50848
  }
50656
50849
  function defaultDeps() {
50657
50850
  return {
50658
- ownVersion: true ? "2.76.11" : null,
50851
+ ownVersion: true ? "2.76.13" : null,
50659
50852
  root: cliVersionsRoot(),
50660
50853
  args: process.argv.slice(3),
50661
50854
  execPath: process.execPath,
@@ -50752,13 +50945,13 @@ function needsSelfRelaunch(env = process.env, pid = process.pid, ctx = {}) {
50752
50945
  }
50753
50946
  function readPid1Cmdline() {
50754
50947
  try {
50755
- return fs93.readFileSync("/proc/1/cmdline", "utf8").split("\0").filter(Boolean);
50948
+ return fs95.readFileSync("/proc/1/cmdline", "utf8").split("\0").filter(Boolean);
50756
50949
  } catch {
50757
50950
  return [];
50758
50951
  }
50759
50952
  }
50760
50953
  function isOurTiniEntrypoint(argv) {
50761
- return argv.some((a) => path107.basename(a) === "tini") && argv.includes("host-agent");
50954
+ return argv.some((a) => path109.basename(a) === "tini") && argv.includes("host-agent");
50762
50955
  }
50763
50956
  function relaunchArgv(execPath, argv) {
50764
50957
  return ["-c", 'sleep 2; exec "$0" "$@"', execPath, ...argv.slice(1)];
@@ -50791,7 +50984,7 @@ function defaultRestartForUpdate(version3, supervised, io = {}) {
50791
50984
  }
50792
50985
  exit(0);
50793
50986
  }
50794
- function isContainerEnvironment(existsSyncFn = fs93.existsSync, readFileSyncFn = (p2) => fs93.readFileSync(p2, "utf8")) {
50987
+ function isContainerEnvironment(existsSyncFn = fs95.existsSync, readFileSyncFn = (p2) => fs95.readFileSync(p2, "utf8")) {
50795
50988
  try {
50796
50989
  if (existsSyncFn("/.dockerenv")) return true;
50797
50990
  } catch {
@@ -50803,16 +50996,16 @@ function isContainerEnvironment(existsSyncFn = fs93.existsSync, readFileSyncFn =
50803
50996
  }
50804
50997
  return false;
50805
50998
  }
50806
- function hostAgentPidFile(home = os68.homedir()) {
50807
- return path107.join(home, ".codeam", "host-agent.pid");
50999
+ function hostAgentPidFile(home = os70.homedir()) {
51000
+ return path109.join(home, ".codeam", "host-agent.pid");
50808
51001
  }
50809
51002
  function writeHostAgentPidFile(file = hostAgentPidFile(), pid = process.pid) {
50810
51003
  try {
50811
- fs93.mkdirSync(path107.dirname(file), { recursive: true });
50812
- fs93.writeFileSync(file, String(pid));
51004
+ fs95.mkdirSync(path109.dirname(file), { recursive: true });
51005
+ fs95.writeFileSync(file, String(pid));
50813
51006
  process.once("exit", () => {
50814
51007
  try {
50815
- if (fs93.readFileSync(file, "utf8").trim() === String(pid)) fs93.rmSync(file, { force: true });
51008
+ if (fs95.readFileSync(file, "utf8").trim() === String(pid)) fs95.rmSync(file, { force: true });
50816
51009
  } catch {
50817
51010
  }
50818
51011
  });
@@ -50832,6 +51025,55 @@ var defaultDisableService = () => {
50832
51025
  }
50833
51026
  };
50834
51027
 
51028
+ // src/commands/host/fleet-image-gc.ts
51029
+ var FLEET_ROLLBACK_TAG = "rollback";
51030
+ var FLEET_IMAGE_INSPECT_FORMAT = '{{.Id}}|{{.Created}}|{{join .RepoTags ","}}|{{join .RootFS.Layers ","}}';
51031
+ function repoOfImageRef(ref) {
51032
+ const colon = ref.lastIndexOf(":");
51033
+ return colon > ref.lastIndexOf("/") ? ref.slice(0, colon) : ref;
51034
+ }
51035
+ function parseFleetImageInspect(stdout) {
51036
+ const out2 = [];
51037
+ for (const line of stdout.split("\n")) {
51038
+ const parts = line.trim().split("|");
51039
+ if (parts.length !== 4 || !parts[0].startsWith("sha256:")) continue;
51040
+ const [id, created, tags, layers] = parts;
51041
+ out2.push({
51042
+ id,
51043
+ created,
51044
+ repoTags: tags ? tags.split(",").filter((t2) => t2 && t2 !== "<none>:<none>") : [],
51045
+ layers: layers ? layers.split(",") : []
51046
+ });
51047
+ }
51048
+ return out2;
51049
+ }
51050
+ function planFleetBoxImageGc(input) {
51051
+ const { images, referenced, currentId, currentRef } = input;
51052
+ const current2 = images.find((i) => i.id === currentId);
51053
+ if (!current2) return { removeTags: [] };
51054
+ const currentRepo = repoOfImageRef(currentRef);
51055
+ const boxRepos = /* @__PURE__ */ new Set([currentRepo, "codeam-box"]);
51056
+ const boxTagsOf = (img) => img.repoTags.filter((t2) => boxRepos.has(repoOfImageRef(t2)));
51057
+ const baseLayer = current2.layers[0];
51058
+ const isBox = (img) => boxTagsOf(img).length > 0 || img.repoTags.length === 0 && !!baseLayer && img.layers[0] === baseLayer;
51059
+ const previous = images.filter((i) => i.id !== currentId && isBox(i)).sort((a, b) => Date.parse(b.created) - Date.parse(a.created));
51060
+ const rollback = previous[0];
51061
+ const rollbackTag = `${currentRepo}:${FLEET_ROLLBACK_TAG}`;
51062
+ const tagAs = rollback && boxTagsOf(rollback).length === 0 ? rollbackTag : void 0;
51063
+ const removeTags = [];
51064
+ for (const img of previous.slice(1)) {
51065
+ if (referenced.has(img.id)) continue;
51066
+ for (const tag of boxTagsOf(img)) {
51067
+ if (tagAs && tag === rollbackTag) continue;
51068
+ removeTags.push(tag);
51069
+ }
51070
+ }
51071
+ return {
51072
+ rollback: rollback ? { id: rollback.id, ...tagAs ? { tagAs } : {} } : void 0,
51073
+ removeTags
51074
+ };
51075
+ }
51076
+
50835
51077
  // src/commands/host-agent.ts
50836
51078
  var HEARTBEAT_INTERVAL_MS = 2e4;
50837
51079
  var RESUME_RETRY_BACKOFF_MS = [15e3, 3e4, 6e4, 12e4];
@@ -50996,6 +51238,7 @@ function buildFleetBoxRunArgs(p2) {
50996
51238
  }
50997
51239
  var DOCKER_RUN_TIMEOUT_MS = 12e4;
50998
51240
  var DOCKER_RUN_WITH_PULL_TIMEOUT_MS = 6e5;
51241
+ var DOCKER_PRUNE_TIMEOUT_MS = 6e5;
50999
51242
  var defaultDockerRunner = {
51000
51243
  run(args2, opts = {}) {
51001
51244
  return new Promise((resolve14) => {
@@ -51520,13 +51763,13 @@ var HostAgentSupervisor = class {
51520
51763
  const relay = this.relay;
51521
51764
  if (!relay) return;
51522
51765
  const raw = cmd.payload?.path;
51523
- const target = typeof raw === "string" && raw.trim() ? path108.resolve(raw.trim()) : os69.homedir();
51766
+ const target = typeof raw === "string" && raw.trim() ? path110.resolve(raw.trim()) : os71.homedir();
51524
51767
  try {
51525
- const dirents = await fs94.promises.readdir(target, { withFileTypes: true });
51768
+ const dirents = await fs96.promises.readdir(target, { withFileTypes: true });
51526
51769
  const entries2 = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
51527
51770
  (a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
51528
51771
  );
51529
- const parent = path108.dirname(target);
51772
+ const parent = path110.dirname(target);
51530
51773
  await relay.sendResult(cmd.id, "completed", {
51531
51774
  path: target,
51532
51775
  // null at the filesystem root so the UI can hide the ".." affordance.
@@ -51767,22 +52010,42 @@ var HostAgentSupervisor = class {
51767
52010
  * `fleet_prune_host` — reclaim Docker residue. Best-effort and idempotent: a
51768
52011
  * prune with nothing to collect exits 0 with "Total reclaimed space: 0B".
51769
52012
  *
51770
- * ⚠️ Only ever `image prune` (dangling) and `builder prune`. NEVER
51771
- * `container prune` (a stopped fleet container is a SLEEPING BOX) and NEVER
51772
- * `volume prune` (a box's volume is the user's workspace and outlives its
51773
- * container by design). See `FleetPruneHostPayload`.
52013
+ * ⚠️ Only superseded Box images, `image prune` (dangling) and `builder prune`.
52014
+ * NEVER `container prune` (a stopped fleet container is a SLEEPING BOX) and
52015
+ * NEVER `volume prune` (a box's volume is the user's workspace and outlives
52016
+ * its container by design). See `FleetPruneHostPayload`.
52017
+ *
52018
+ * ⚠️ Every step runs on the LONG docker bound. Under the 120 s one the dangling
52019
+ * prune never finished on fleet-1: the prod and dev host-agents share one
52020
+ * daemon and both get this command at 15:45 UTC; dev's prune was SIGTERM'd at
52021
+ * 120 s (code=143) and prod's was refused with "a prune operation is already
52022
+ * running" — every day, so 17 GB of dangling Box images stayed (2026-10-02).
52023
+ * That refusal now means the other agent is doing the work, not a failure.
51774
52024
  */
51775
52025
  async fleetPruneHost(payload) {
51776
52026
  log.info(
51777
52027
  "host-agent",
51778
52028
  `fleet_prune_host images=${payload.images} buildCache=${payload.buildCache}`
51779
52029
  );
52030
+ if (payload.images) await this.fleetCollectSupersededBoxImages();
51780
52031
  const steps = [];
51781
52032
  if (payload.images) steps.push({ label: "image", args: ["image", "prune", "-f"] });
51782
- if (payload.buildCache) steps.push({ label: "builder", args: ["builder", "prune", "-f"] });
52033
+ if (payload.buildCache) {
52034
+ steps.push({
52035
+ label: "builder",
52036
+ args: ["builder", "prune", "-f", "--all", "--filter", "until=72h"]
52037
+ });
52038
+ }
51783
52039
  for (const step of steps) {
51784
- const res = await this.docker.run(step.args);
52040
+ const res = await this.docker.run(step.args, { timeoutMs: DOCKER_PRUNE_TIMEOUT_MS });
51785
52041
  if (res.code !== 0) {
52042
+ if (/prune operation is already running/i.test(res.stderr)) {
52043
+ log.info(
52044
+ "host-agent",
52045
+ `fleet_prune_host ${step.label} skipped: another prune is running on this daemon`
52046
+ );
52047
+ continue;
52048
+ }
51786
52049
  log.warn(
51787
52050
  "host-agent",
51788
52051
  `fleet_prune_host ${step.label} failed (code=${res.code}): ${res.stderr.trim().slice(-300)}`
@@ -51796,6 +52059,103 @@ var HostAgentSupervisor = class {
51796
52059
  );
51797
52060
  }
51798
52061
  }
52062
+ /**
52063
+ * Remove superseded Box images by tag: everything but the current `:latest`,
52064
+ * one previous release (kept, tagged `:rollback`) and any image a container
52065
+ * uses. Fail-SAFE: if the current image, the image list or the container
52066
+ * references cannot be read, it removes nothing.
52067
+ */
52068
+ async fleetCollectSupersededBoxImages() {
52069
+ if (process.env.CODEAM_FLEET_BOX_IMAGE) return;
52070
+ const currentRef = resolveFleetBoxImage();
52071
+ const opts = { timeoutMs: DOCKER_PRUNE_TIMEOUT_MS };
52072
+ const lines = (out2) => [...new Set(out2.split("\n").map((l) => l.trim()).filter(Boolean))];
52073
+ const cur = await this.docker.run(
52074
+ ["image", "inspect", "--format", "{{.Id}}", currentRef],
52075
+ opts
52076
+ );
52077
+ const currentId = cur.stdout.trim();
52078
+ if (cur.code !== 0 || !currentId) {
52079
+ log.warn("host-agent", `fleet_prune_host box-images skipped: ${currentRef} not present`);
52080
+ return;
52081
+ }
52082
+ const ids = await this.docker.run(["image", "ls", "-aq", "--no-trunc"], opts);
52083
+ if (ids.code !== 0) {
52084
+ log.warn(
52085
+ "host-agent",
52086
+ `fleet_prune_host box-images skipped: image ls failed (code=${ids.code})`
52087
+ );
52088
+ return;
52089
+ }
52090
+ const imageIds = lines(ids.stdout);
52091
+ if (imageIds.length === 0) return;
52092
+ const inspect = await this.docker.run(
52093
+ ["image", "inspect", "--format", FLEET_IMAGE_INSPECT_FORMAT, ...imageIds],
52094
+ opts
52095
+ );
52096
+ if (inspect.code !== 0) {
52097
+ log.warn(
52098
+ "host-agent",
52099
+ `fleet_prune_host box-images skipped: image inspect failed (code=${inspect.code})`
52100
+ );
52101
+ return;
52102
+ }
52103
+ const containers = await this.docker.run(["ps", "-aq", "--no-trunc"], opts);
52104
+ if (containers.code !== 0) {
52105
+ log.warn(
52106
+ "host-agent",
52107
+ `fleet_prune_host box-images skipped: ps failed (code=${containers.code})`
52108
+ );
52109
+ return;
52110
+ }
52111
+ const containerIds = lines(containers.stdout);
52112
+ const referenced = /* @__PURE__ */ new Set();
52113
+ if (containerIds.length > 0) {
52114
+ const refs = await this.docker.run(
52115
+ ["inspect", "--format", "{{.Image}}", ...containerIds],
52116
+ opts
52117
+ );
52118
+ if (refs.code !== 0) {
52119
+ log.warn(
52120
+ "host-agent",
52121
+ `fleet_prune_host box-images skipped: container inspect failed (code=${refs.code})`
52122
+ );
52123
+ return;
52124
+ }
52125
+ for (const id of lines(refs.stdout)) referenced.add(id);
52126
+ }
52127
+ const plan = planFleetBoxImageGc({
52128
+ images: parseFleetImageInspect(inspect.stdout),
52129
+ referenced,
52130
+ currentId,
52131
+ currentRef
52132
+ });
52133
+ if (plan.rollback?.tagAs) {
52134
+ const tag = await this.docker.run(["tag", plan.rollback.id, plan.rollback.tagAs], opts);
52135
+ if (tag.code !== 0) {
52136
+ log.warn(
52137
+ "host-agent",
52138
+ `fleet_prune_host box-images: tagging rollback failed (code=${tag.code}), removing nothing`
52139
+ );
52140
+ return;
52141
+ }
52142
+ }
52143
+ for (const ref of plan.removeTags) {
52144
+ const res = await this.docker.run(["rmi", ref], opts);
52145
+ if (res.code === 0 || /no such image/i.test(res.stderr)) {
52146
+ log.info("host-agent", `fleet_prune_host box-images removed ${ref}`);
52147
+ } else {
52148
+ log.warn(
52149
+ "host-agent",
52150
+ `fleet_prune_host box-images rmi ${ref} failed (code=${res.code}): ${res.stderr.trim().slice(-300)}`
52151
+ );
52152
+ }
52153
+ }
52154
+ log.info(
52155
+ "host-agent",
52156
+ `fleet_prune_host box-images current=${currentId.slice(7, 19)} rollback=${plan.rollback ? plan.rollback.id.slice(7, 19) : "none"} removed=${plan.removeTags.length}`
52157
+ );
52158
+ }
51799
52159
  async fleetStopBox(payload) {
51800
52160
  log.info("host-agent", `fleet_stop_box id=${payload.boxId} name=${payload.containerName}`);
51801
52161
  const res = await this.docker.run(["stop", payload.containerName]);
@@ -51880,14 +52240,14 @@ var HostAgentSupervisor = class {
51880
52240
  }),
51881
52241
  CODEAM_AUTO_TOKEN: payload.autoPairToken
51882
52242
  };
51883
- const houseConfigDir = path108.join(
51884
- os69.homedir(),
52243
+ const houseConfigDir = path110.join(
52244
+ os71.homedir(),
51885
52245
  ".codeam",
51886
52246
  "house-claude",
51887
52247
  payload.deployId
51888
52248
  );
51889
52249
  try {
51890
- fs94.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
52250
+ fs96.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
51891
52251
  } catch {
51892
52252
  }
51893
52253
  childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
@@ -51914,7 +52274,7 @@ var HostAgentSupervisor = class {
51914
52274
  report("installing", "installing agent CLI");
51915
52275
  await this.runAgentInstall(payload.agentInstallScript);
51916
52276
  }
51917
- const home = process.env.HOME || os69.homedir();
52277
+ const home = process.env.HOME || os71.homedir();
51918
52278
  childEnv.PATH = `${home}/.local/bin:${process.env.PATH ?? ""}`;
51919
52279
  if (payload.cloneToken) {
51920
52280
  try {
@@ -51922,13 +52282,13 @@ var HostAgentSupervisor = class {
51922
52282
  if ((payload.repoProvider ?? "github") === "gitlab") {
51923
52283
  const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
51924
52284
  if (glabCmd) {
51925
- childEnv.PATH = `${codeamBinDir()}${path108.delimiter}${childEnv.PATH}`;
52285
+ childEnv.PATH = `${codeamBinDir()}${path110.delimiter}${childEnv.PATH}`;
51926
52286
  await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
51927
52287
  }
51928
52288
  } else {
51929
52289
  const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
51930
52290
  if (ghCmd) {
51931
- childEnv.PATH = `${codeamBinDir()}${path108.delimiter}${childEnv.PATH}`;
52291
+ childEnv.PATH = `${codeamBinDir()}${path110.delimiter}${childEnv.PATH}`;
51932
52292
  await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
51933
52293
  }
51934
52294
  }
@@ -51956,9 +52316,9 @@ var HostAgentSupervisor = class {
51956
52316
  );
51957
52317
  if (!payload.suppressOnboardingWelcome) {
51958
52318
  try {
51959
- const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path108.join(os69.homedir(), ".claude");
51960
- const projectDir = path108.join(cfgDir, "projects", encodeCwd(cwd));
51961
- const hasPriorConversation = fs94.existsSync(projectDir) && fs94.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
52319
+ const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path110.join(os71.homedir(), ".claude");
52320
+ const projectDir = path110.join(cfgDir, "projects", encodeCwd(cwd));
52321
+ const hasPriorConversation = fs96.existsSync(projectDir) && fs96.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
51962
52322
  if (hasPriorConversation) {
51963
52323
  childEnv.CODEAM_RESUME_LATEST = "1";
51964
52324
  log.info(
@@ -52112,7 +52472,7 @@ var HostAgentSupervisor = class {
52112
52472
  fallbackResumeTarget() {
52113
52473
  const session = getActiveSession();
52114
52474
  if (!session || !session.pluginId || !session.pollSecret || !session.agent) return null;
52115
- const cwd = session.cwd && fs94.existsSync(session.cwd) ? session.cwd : process.cwd();
52475
+ const cwd = session.cwd && fs96.existsSync(session.cwd) ? session.cwd : process.cwd();
52116
52476
  if (isFilesystemRoot(cwd)) {
52117
52477
  log.warn(
52118
52478
  "host-agent",
@@ -52152,7 +52512,7 @@ var HostAgentSupervisor = class {
52152
52512
  log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: no saved pairing on this box`);
52153
52513
  return;
52154
52514
  }
52155
- if (!session.cwd || !fs94.existsSync(session.cwd)) {
52515
+ if (!session.cwd || !fs96.existsSync(session.cwd)) {
52156
52516
  log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: workspace is gone`);
52157
52517
  return;
52158
52518
  }
@@ -52194,7 +52554,7 @@ var HostAgentSupervisor = class {
52194
52554
  const persisted = new Map((this.sessionStore.load() ?? []).map((r) => [r.deployId, r.agent]));
52195
52555
  for (const c2 of this.children.values()) persisted.set(c2.deployId, c2.agent);
52196
52556
  return this.listSavedSessions().map((s) => ({ s, deployId: deployIdFromWorkspace(s.cwd) })).filter(
52197
- (x) => x.deployId !== null && !!x.s.cwd && fs94.existsSync(x.s.cwd)
52557
+ (x) => x.deployId !== null && !!x.s.cwd && fs96.existsSync(x.s.cwd)
52198
52558
  ).map(({ s, deployId }) => {
52199
52559
  const agent = persisted.get(deployId);
52200
52560
  return { deployId, sessionId: s.id, ...agent ? { agent } : {} };
@@ -52246,7 +52606,7 @@ var HostAgentSupervisor = class {
52246
52606
  if (this.children.has(deployId)) return;
52247
52607
  const st3 = this.resumeStateFor(target);
52248
52608
  try {
52249
- const cwd = fs94.existsSync(target.cwd) ? target.cwd : process.cwd();
52609
+ const cwd = fs96.existsSync(target.cwd) ? target.cwd : process.cwd();
52250
52610
  const proc = this.resumeSpawner(
52251
52611
  { ...readHouseProxyChildEnv(deployId), CODEAM_RESUME_SESSION_ID: session.id },
52252
52612
  cwd
@@ -52273,7 +52633,7 @@ var HostAgentSupervisor = class {
52273
52633
  return;
52274
52634
  }
52275
52635
  if (tracked && signal) {
52276
- this.onResumeChildExit(target, 128 + (os69.constants.signals[signal] ?? 9), `signal ${signal}`);
52636
+ this.onResumeChildExit(target, 128 + (os71.constants.signals[signal] ?? 9), `signal ${signal}`);
52277
52637
  return;
52278
52638
  }
52279
52639
  log.warn(
@@ -52316,7 +52676,7 @@ var HostAgentSupervisor = class {
52316
52676
  if (Date.now() - child.startedAt < CRASH_RESPAWN_MIN_UPTIME_MS) return false;
52317
52677
  const session = pickSavedSessionForWorkspace(this.listSavedSessions(), child.cwd);
52318
52678
  if (!session) return false;
52319
- const exitCode = typeof code === "number" ? code : 128 + (signal ? os69.constants.signals[signal] ?? 9 : 9);
52679
+ const exitCode = typeof code === "number" ? code : 128 + (signal ? os71.constants.signals[signal] ?? 9 : 9);
52320
52680
  log.warn(
52321
52681
  "host-agent",
52322
52682
  `session deploy=${child.deployId.slice(0, 8)} died (${signal ?? code}) after ${Math.round((Date.now() - child.startedAt) / 1e3)}s \u2014 respawning it (resume)`
@@ -52465,12 +52825,12 @@ var HostAgentSupervisor = class {
52465
52825
  this.untrackChild(deployId);
52466
52826
  }
52467
52827
  const dirs = [
52468
- path108.join(selfHostedWorkspaceRoot(), deployId),
52469
- path108.join(os69.homedir(), ".codeam", "house-claude", deployId)
52828
+ path110.join(selfHostedWorkspaceRoot(), deployId),
52829
+ path110.join(os71.homedir(), ".codeam", "house-claude", deployId)
52470
52830
  ];
52471
52831
  for (const dir of dirs) {
52472
52832
  try {
52473
- fs94.rmSync(dir, { recursive: true, force: true });
52833
+ fs96.rmSync(dir, { recursive: true, force: true });
52474
52834
  } catch (err) {
52475
52835
  log.warn(
52476
52836
  "host-agent",
@@ -52637,8 +52997,8 @@ async function invite() {
52637
52997
  var import_node_dns = require("dns");
52638
52998
  var import_node_util11 = require("util");
52639
52999
  var import_node_crypto17 = require("crypto");
52640
- var fs95 = __toESM(require("fs"));
52641
- var path109 = __toESM(require("path"));
53000
+ var fs97 = __toESM(require("fs"));
53001
+ var path111 = __toESM(require("path"));
52642
53002
  var import_picocolors14 = __toESM(require("picocolors"));
52643
53003
  var dnsResolveP = (0, import_node_util11.promisify)(import_node_dns.resolve);
52644
53004
  async function checkDns(apiBase2) {
@@ -52694,13 +53054,13 @@ async function checkHealth(apiBase2) {
52694
53054
  }
52695
53055
  }
52696
53056
  function checkConfigDir() {
52697
- const dir = path109.join(require("os").homedir(), ".codeam");
53057
+ const dir = path111.join(require("os").homedir(), ".codeam");
52698
53058
  try {
52699
- fs95.mkdirSync(dir, { recursive: true, mode: 448 });
52700
- const probe = path109.join(dir, ".doctor-probe");
52701
- fs95.writeFileSync(probe, "ok", { mode: 384 });
52702
- const read = fs95.readFileSync(probe, "utf8");
52703
- fs95.unlinkSync(probe);
53059
+ fs97.mkdirSync(dir, { recursive: true, mode: 448 });
53060
+ const probe = path111.join(dir, ".doctor-probe");
53061
+ fs97.writeFileSync(probe, "ok", { mode: 384 });
53062
+ const read = fs97.readFileSync(probe, "utf8");
53063
+ fs97.unlinkSync(probe);
52704
53064
  if (read !== "ok") throw new Error("write/read round-trip mismatch");
52705
53065
  return {
52706
53066
  id: "config-dir",
@@ -52740,9 +53100,9 @@ function checkSessions() {
52740
53100
  }
52741
53101
  }
52742
53102
  function checkAgentBinaries() {
52743
- const os72 = createOsStrategy();
53103
+ const os74 = createOsStrategy();
52744
53104
  return getEnabledAgents().map((meta) => {
52745
- const found = os72.findInPath(meta.binaryName);
53105
+ const found = os74.findInPath(meta.binaryName);
52746
53106
  return {
52747
53107
  id: `agent-${meta.id}`,
52748
53108
  label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
@@ -52764,7 +53124,7 @@ function checkNodePty() {
52764
53124
  detail: "not required on this platform"
52765
53125
  };
52766
53126
  }
52767
- const vendoredPath = path109.join(__dirname, "vendor", "node-pty");
53127
+ const vendoredPath = path111.join(__dirname, "vendor", "node-pty");
52768
53128
  for (const target of [vendoredPath, "node-pty"]) {
52769
53129
  try {
52770
53130
  require(target);
@@ -52806,7 +53166,7 @@ function checkChokidar() {
52806
53166
  }
52807
53167
  async function doctor(args2 = []) {
52808
53168
  const json = args2.includes("--json");
52809
- const cliVersion = true ? "2.76.11" : "0.0.0-dev";
53169
+ const cliVersion = true ? "2.76.13" : "0.0.0-dev";
52810
53170
  const apiBase2 = resolveApiBaseUrl();
52811
53171
  const diagnosticId = (0, import_node_crypto17.randomUUID)();
52812
53172
  log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
@@ -53330,7 +53690,7 @@ async function mcpWarm(argv = [], opts = {}) {
53330
53690
  // src/commands/version.ts
53331
53691
  var import_picocolors15 = __toESM(require("picocolors"));
53332
53692
  function version2() {
53333
- const v = true ? "2.76.11" : "unknown";
53693
+ const v = true ? "2.76.13" : "unknown";
53334
53694
  console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
53335
53695
  }
53336
53696
 
@@ -53463,10 +53823,10 @@ function tryShowSubcommandHelp(cmd, args2) {
53463
53823
  var _subcommandHelpKeys = Object.keys(HELPS);
53464
53824
 
53465
53825
  // src/index.ts
53466
- var os71 = __toESM(require("os"));
53826
+ var os73 = __toESM(require("os"));
53467
53827
  if (!process.env.HOME) {
53468
53828
  try {
53469
- const home = os71.homedir();
53829
+ const home = os73.homedir();
53470
53830
  if (home) process.env.HOME = home;
53471
53831
  } catch {
53472
53832
  }