codeam-cli 2.76.12 → 2.76.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.js +760 -543
  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 (fs99.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, fs99, 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
+ fs99 = __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 fs66 = __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.12" : "0.0.0-dev",
10582
+ cliVersion: true ? "2.76.14" : "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.12",
10827
+ version: "2.76.14",
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.12" ? { ideVersion: "2.76.12" } : {}
12163
+ ..."2.76.14" ? { ideVersion: "2.76.14" } : {}
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 fs65 = __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,108 @@ function persistBeadsConfig(cfg) {
28285
28294
  restrictToOwner(file);
28286
28295
  }
28287
28296
 
28297
+ // src/beads/provision-lock.ts
28298
+ var import_fs8 = __toESM(require("fs"));
28299
+ var import_os11 = __toESM(require("os"));
28300
+ var import_path9 = __toESM(require("path"));
28301
+
28302
+ // src/lib/process-identity.ts
28303
+ var import_fs7 = __toESM(require("fs"));
28304
+ function pidIsAlive(pid) {
28305
+ try {
28306
+ process.kill(pid, 0);
28307
+ return true;
28308
+ } catch (err) {
28309
+ return err.code === "EPERM";
28310
+ }
28311
+ }
28312
+ function procStartTime(pid) {
28313
+ try {
28314
+ const stat3 = import_fs7.default.readFileSync(`/proc/${pid}/stat`, "utf8");
28315
+ const rest = stat3.slice(stat3.lastIndexOf(")") + 2).split(" ");
28316
+ return rest[19] ?? "";
28317
+ } catch {
28318
+ return "";
28319
+ }
28320
+ }
28321
+ function ownerRecord(pid, deps = {}) {
28322
+ return `${pid} ${(deps.startTimeOf ?? procStartTime)(pid)}`.trim();
28323
+ }
28324
+ function ownerIsAlive(record2, deps = {}) {
28325
+ const [pidText, recordedStart = ""] = record2.trim().split(/\s+/);
28326
+ const pid = Number(pidText);
28327
+ if (!Number.isInteger(pid) || pid <= 0) return false;
28328
+ if (!(deps.isAlive ?? pidIsAlive)(pid)) return false;
28329
+ if (!recordedStart) return true;
28330
+ const now = (deps.startTimeOf ?? procStartTime)(pid);
28331
+ return now === "" || now === recordedStart;
28332
+ }
28333
+
28334
+ // src/beads/provision-lock.ts
28335
+ var STALE_LOCK_MS = 5 * 6e4;
28336
+ function tryAcquire(lockDir, deps) {
28337
+ const pid = deps.pid ?? process.pid;
28338
+ try {
28339
+ import_fs8.default.mkdirSync(import_path9.default.dirname(lockDir), { recursive: true });
28340
+ import_fs8.default.mkdirSync(lockDir);
28341
+ import_fs8.default.writeFileSync(import_path9.default.join(lockDir, "pid"), ownerRecord(pid, deps));
28342
+ return true;
28343
+ } catch (err) {
28344
+ if (err.code !== "EEXIST") return true;
28345
+ }
28346
+ let age;
28347
+ try {
28348
+ age = (deps.now ?? Date.now)() - import_fs8.default.statSync(lockDir).mtimeMs;
28349
+ } catch {
28350
+ return tryAcquireOnce(lockDir, deps);
28351
+ }
28352
+ let holder = "";
28353
+ try {
28354
+ holder = import_fs8.default.readFileSync(import_path9.default.join(lockDir, "pid"), "utf8");
28355
+ } catch {
28356
+ if (age <= 1e4) return false;
28357
+ }
28358
+ const alive = holder !== "" && ownerIsAlive(holder, deps);
28359
+ if (alive && age <= STALE_LOCK_MS) return false;
28360
+ try {
28361
+ import_fs8.default.rmSync(lockDir, { recursive: true, force: true });
28362
+ } catch {
28363
+ return false;
28364
+ }
28365
+ return tryAcquireOnce(lockDir, deps);
28366
+ }
28367
+ function tryAcquireOnce(lockDir, deps) {
28368
+ try {
28369
+ import_fs8.default.mkdirSync(lockDir);
28370
+ import_fs8.default.writeFileSync(import_path9.default.join(lockDir, "pid"), ownerRecord(deps.pid ?? process.pid, deps));
28371
+ return true;
28372
+ } catch {
28373
+ return false;
28374
+ }
28375
+ }
28376
+ async function withBeadsProvisionLock(fn, deps = {}) {
28377
+ const lockDir = import_path9.default.join(deps.dir ?? import_path9.default.join(import_os11.default.homedir(), ".codeam"), "beads-provision.lock");
28378
+ const now = deps.now ?? Date.now;
28379
+ const sleep5 = deps.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
28380
+ const deadline = now() + (deps.timeoutMs ?? 18e4);
28381
+ let held = tryAcquire(lockDir, deps);
28382
+ while (!held && now() < deadline) {
28383
+ await sleep5(500);
28384
+ held = tryAcquire(lockDir, deps);
28385
+ }
28386
+ try {
28387
+ return await fn();
28388
+ } finally {
28389
+ if (held) {
28390
+ try {
28391
+ const owner = Number(import_fs8.default.readFileSync(import_path9.default.join(lockDir, "pid"), "utf8").trim().split(/\s+/)[0]);
28392
+ if (owner === (deps.pid ?? process.pid)) import_fs8.default.rmSync(lockDir, { recursive: true, force: true });
28393
+ } catch {
28394
+ }
28395
+ }
28396
+ }
28397
+ }
28398
+
28288
28399
  // src/beads/wiring.ts
28289
28400
  function beadsKilled() {
28290
28401
  const v = process.env.CODEAM_BEADS_DISABLED;
@@ -28306,15 +28417,18 @@ async function provisionBeadsForStart(ctx) {
28306
28417
  return null;
28307
28418
  }
28308
28419
  const pluginAuthToken = ctx.pluginAuthToken;
28420
+ if (ctx.deferUntil) await ctx.deferUntil.catch(() => void 0);
28309
28421
  let started = null;
28310
28422
  try {
28311
- started = await startBeads({
28312
- sessionId: ctx.sessionId,
28313
- pluginId: ctx.pluginId,
28314
- pluginAuthToken,
28315
- cwd: ctx.cwd,
28316
- agents: ctx.agents
28317
- });
28423
+ started = await withBeadsProvisionLock(
28424
+ () => startBeads({
28425
+ sessionId: ctx.sessionId,
28426
+ pluginId: ctx.pluginId,
28427
+ pluginAuthToken,
28428
+ cwd: ctx.cwd,
28429
+ agents: ctx.agents
28430
+ })
28431
+ );
28318
28432
  } catch (err) {
28319
28433
  log.warn("beads", "provisionBeadsForStart failed (non-fatal)", err);
28320
28434
  started = null;
@@ -28550,8 +28664,8 @@ function cleanupAttachmentTempFiles() {
28550
28664
  function saveFilesTemp(files) {
28551
28665
  return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
28552
28666
  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"));
28667
+ const tmpPath = path73.join(os47.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
28668
+ fs65.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
28555
28669
  pendingAttachmentFiles.add(tmpPath);
28556
28670
  return tmpPath;
28557
28671
  });
@@ -28796,10 +28910,10 @@ var listFiles = async (ctx, cmd, parsed) => {
28796
28910
  await ctx.relay.sendResult(cmd.id, "completed", result);
28797
28911
  };
28798
28912
  var envReadH = async (ctx, cmd) => {
28799
- const envPath = path72.join(process.cwd(), ".env");
28913
+ const envPath = path73.join(process.cwd(), ".env");
28800
28914
  await restoreProjectEnvIfMissing(process.cwd(), ctx);
28801
28915
  try {
28802
- const raw = await fs63.promises.readFile(envPath, "utf8");
28916
+ const raw = await fs65.promises.readFile(envPath, "utf8");
28803
28917
  await ctx.relay.sendResult(cmd.id, "completed", {
28804
28918
  exists: true,
28805
28919
  vars: parseDotenv(raw)
@@ -28828,7 +28942,7 @@ var envParseH = async (ctx, cmd, parsed) => {
28828
28942
  const existing = /* @__PURE__ */ new Map();
28829
28943
  if (!replace) {
28830
28944
  try {
28831
- const raw = await fs63.promises.readFile(path72.join(process.cwd(), ".env"), "utf8");
28945
+ const raw = await fs65.promises.readFile(path73.join(process.cwd(), ".env"), "utf8");
28832
28946
  for (const v of parseDotenv(raw)) existing.set(v.key, v.value);
28833
28947
  } catch {
28834
28948
  }
@@ -28868,15 +28982,15 @@ var envWriteH = async (ctx, cmd, parsed) => {
28868
28982
  }
28869
28983
  seen2.add(v.key);
28870
28984
  }
28871
- const envPath = path72.join(process.cwd(), ".env");
28872
- const tmpPath = path72.join(process.cwd(), ".env.codeam.tmp");
28985
+ const envPath = path73.join(process.cwd(), ".env");
28986
+ const tmpPath = path73.join(process.cwd(), ".env.codeam.tmp");
28873
28987
  try {
28874
- await fs63.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
28875
- await fs63.promises.rename(tmpPath, envPath);
28988
+ await fs65.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
28989
+ await fs65.promises.rename(tmpPath, envPath);
28876
28990
  await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
28877
28991
  void syncProjectEnvUp(process.cwd(), ctx);
28878
28992
  } catch (err) {
28879
- await fs63.promises.rm(tmpPath, { force: true }).catch(() => void 0);
28993
+ await fs65.promises.rm(tmpPath, { force: true }).catch(() => void 0);
28880
28994
  await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
28881
28995
  }
28882
28996
  };
@@ -29102,7 +29216,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
29102
29216
  });
29103
29217
  const token = ctx.pluginAuthToken;
29104
29218
  void (async () => {
29105
- const os72 = createOsStrategy();
29219
+ const os74 = createOsStrategy();
29106
29220
  try {
29107
29221
  const report = await reviewPullRequest(
29108
29222
  {
@@ -29111,7 +29225,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
29111
29225
  baseBranch: parsed.baseBranch
29112
29226
  },
29113
29227
  {
29114
- runReview: (input) => new CoderabbitRuntimeStrategy(os72).runOneShot(input),
29228
+ runReview: (input) => new CoderabbitRuntimeStrategy(os74).runOneShot(input),
29115
29229
  runGh: (args2) => defaultRunGh(args2),
29116
29230
  postReport: async (r) => {
29117
29231
  if (!token) return;
@@ -29225,9 +29339,9 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
29225
29339
  function buildNpmInstallInvocation(opts) {
29226
29340
  const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
29227
29341
  const execPath = opts?.execPath ?? process.execPath;
29228
- const exists2 = opts?.existsSync ?? fs63.existsSync;
29342
+ const exists2 = opts?.existsSync ?? fs65.existsSync;
29229
29343
  const platform3 = opts?.platform ?? process.platform;
29230
- const p2 = platform3 === "win32" ? path72.win32 : path72.posix;
29344
+ const p2 = platform3 === "win32" ? path73.win32 : path73.posix;
29231
29345
  const normalized = entryScript.split(/[\\/]/).join("/");
29232
29346
  const marker = "/lib/node_modules/codeam-cli/";
29233
29347
  const markerIdx = normalized.indexOf(marker);
@@ -29246,7 +29360,7 @@ function isPermissionError(stderr) {
29246
29360
  function resolveGlobalNodeModulesDir(opts) {
29247
29361
  const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
29248
29362
  const platform3 = opts?.platform ?? process.platform;
29249
- const p2 = platform3 === "win32" ? path72.win32 : path72.posix;
29363
+ const p2 = platform3 === "win32" ? path73.win32 : path73.posix;
29250
29364
  const marker = "/lib/node_modules/codeam-cli/";
29251
29365
  const markerIdx = entryScript.split(/[\\/]/).join("/").indexOf(marker);
29252
29366
  if (markerIdx <= 0) return null;
@@ -29256,9 +29370,9 @@ function resolveGlobalNodeModulesDir(opts) {
29256
29370
  var STALE_STAGING_AGE_MS = CLI_UPDATE_INSTALL_TIMEOUT_MS;
29257
29371
  function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
29258
29372
  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;
29373
+ const readdirSync18 = deps?.readdirSync ?? fs65.readdirSync;
29374
+ const statSync17 = deps?.statSync ?? fs65.statSync;
29375
+ const rmSync14 = deps?.rmSync ?? fs65.rmSync;
29262
29376
  let removed = 0;
29263
29377
  let entries2;
29264
29378
  try {
@@ -29268,7 +29382,7 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
29268
29382
  }
29269
29383
  for (const name of entries2) {
29270
29384
  if (!/^\.codeam-cli-/.test(name)) continue;
29271
- const full = path72.join(nodeModulesDir, name);
29385
+ const full = path73.join(nodeModulesDir, name);
29272
29386
  try {
29273
29387
  const st3 = statSync17(full);
29274
29388
  if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
@@ -30391,11 +30505,11 @@ function resolveTokenValue(args2) {
30391
30505
  }
30392
30506
  const fileFlag = args2.find((a) => a.startsWith("--token-file="));
30393
30507
  if (fileFlag) {
30394
- const path112 = fileFlag.slice("--token-file=".length);
30508
+ const path114 = fileFlag.slice("--token-file=".length);
30395
30509
  try {
30396
- const content = fs64.readFileSync(path112, "utf8").trim();
30397
- if (content.length === 0) fail(`--token-file ${path112} is empty`);
30398
- rmIfExistsQuiet(path112);
30510
+ const content = fs66.readFileSync(path114, "utf8").trim();
30511
+ if (content.length === 0) fail(`--token-file ${path114} is empty`);
30512
+ rmIfExistsQuiet(path114);
30399
30513
  return content;
30400
30514
  } catch (err) {
30401
30515
  fail(`Could not read --token-file: ${err.message}`);
@@ -30487,12 +30601,12 @@ async function claim(token, pluginId, pluginSecretHash) {
30487
30601
  }
30488
30602
  }
30489
30603
  function pairAutoLockPath() {
30490
- return path73.join(os47.homedir(), ".codeam", "pair-auto.lock");
30604
+ return path74.join(os48.homedir(), ".codeam", "pair-auto.lock");
30491
30605
  }
30492
30606
  var procRoot = "/proc";
30493
30607
  function readProcFile(rel) {
30494
30608
  try {
30495
- return fs64.readFileSync(path73.join(procRoot, rel), "utf8");
30609
+ return fs66.readFileSync(path74.join(procRoot, rel), "utf8");
30496
30610
  } catch {
30497
30611
  return void 0;
30498
30612
  }
@@ -30513,7 +30627,7 @@ function currentBootId() {
30513
30627
  function readLockRecord(lockPath) {
30514
30628
  let raw;
30515
30629
  try {
30516
- raw = fs64.readFileSync(lockPath, "utf8");
30630
+ raw = fs66.readFileSync(lockPath, "utf8");
30517
30631
  } catch {
30518
30632
  return void 0;
30519
30633
  }
@@ -30562,7 +30676,7 @@ function isLiveLockHolder(rec) {
30562
30676
  }
30563
30677
  function releaseOwnLock(lockPath) {
30564
30678
  try {
30565
- if (readLockRecord(lockPath)?.pid === process.pid) fs64.unlinkSync(lockPath);
30679
+ if (readLockRecord(lockPath)?.pid === process.pid) fs66.unlinkSync(lockPath);
30566
30680
  } catch {
30567
30681
  }
30568
30682
  }
@@ -30586,7 +30700,7 @@ function snapshotProcessTree(root) {
30586
30700
  const children = /* @__PURE__ */ new Map();
30587
30701
  let entries2 = [];
30588
30702
  try {
30589
- entries2 = fs64.readdirSync(procRoot).filter((e) => /^\d+$/.test(e));
30703
+ entries2 = fs66.readdirSync(procRoot).filter((e) => /^\d+$/.test(e));
30590
30704
  } catch {
30591
30705
  }
30592
30706
  for (const e of entries2) {
@@ -30621,18 +30735,18 @@ function signalProcessTree(refs, signal) {
30621
30735
  }
30622
30736
  function daemonLockPath(sessionId) {
30623
30737
  const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
30624
- return path73.join(os47.homedir(), ".codeam", `daemon-${safe}.lock`);
30738
+ return path74.join(os48.homedir(), ".codeam", `daemon-${safe}.lock`);
30625
30739
  }
30626
30740
  function acquireDaemonLock(sessionId) {
30627
30741
  const lockPath = daemonLockPath(sessionId);
30628
30742
  try {
30629
- fs64.mkdirSync(path73.dirname(lockPath), { recursive: true });
30743
+ fs66.mkdirSync(path74.dirname(lockPath), { recursive: true });
30630
30744
  try {
30631
- fs64.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
30745
+ fs66.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
30632
30746
  } catch (e) {
30633
30747
  if (e.code !== "EEXIST") throw e;
30634
30748
  if (isLiveLockHolder(readLockRecord(lockPath))) return false;
30635
- fs64.writeFileSync(lockPath, ownLockBody());
30749
+ fs66.writeFileSync(lockPath, ownLockBody());
30636
30750
  }
30637
30751
  const release3 = () => releaseOwnLock(lockPath);
30638
30752
  process.once("exit", release3);
@@ -30652,13 +30766,13 @@ function acquireDaemonLock(sessionId) {
30652
30766
  function acquireSingletonLock() {
30653
30767
  const lockPath = pairAutoLockPath();
30654
30768
  try {
30655
- fs64.mkdirSync(path73.dirname(lockPath), { recursive: true });
30769
+ fs66.mkdirSync(path74.dirname(lockPath), { recursive: true });
30656
30770
  try {
30657
- fs64.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
30771
+ fs66.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
30658
30772
  } catch (e) {
30659
30773
  if (e.code !== "EEXIST") throw e;
30660
30774
  if (isLiveLockHolder(readLockRecord(lockPath))) return false;
30661
- fs64.writeFileSync(lockPath, ownLockBody());
30775
+ fs66.writeFileSync(lockPath, ownLockBody());
30662
30776
  }
30663
30777
  process.once("exit", () => releaseOwnLock(lockPath));
30664
30778
  return true;
@@ -31075,7 +31189,7 @@ var AgentService = class _AgentService {
31075
31189
  };
31076
31190
 
31077
31191
  // src/agents/acp/adapters.ts
31078
- var path74 = __toESM(require("path"));
31192
+ var path75 = __toESM(require("path"));
31079
31193
 
31080
31194
  // src/agents/kimi/installer.ts
31081
31195
  var import_node_child_process25 = require("child_process");
@@ -31195,13 +31309,13 @@ function resolveBin(pkgName, binName) {
31195
31309
  try {
31196
31310
  const manifestPath = require_.resolve(`${pkgName}/package.json`);
31197
31311
  const manifest = require_(`${pkgName}/package.json`);
31198
- const pkgDir = path74.dirname(manifestPath);
31312
+ const pkgDir = path75.dirname(manifestPath);
31199
31313
  const bin = manifest.bin;
31200
31314
  if (!bin) return null;
31201
- if (typeof bin === "string") return path74.resolve(pkgDir, bin);
31315
+ if (typeof bin === "string") return path75.resolve(pkgDir, bin);
31202
31316
  const target = binName ?? Object.keys(bin)[0];
31203
31317
  if (!target || !bin[target]) return null;
31204
- return path74.resolve(pkgDir, bin[target]);
31318
+ return path75.resolve(pkgDir, bin[target]);
31205
31319
  } catch {
31206
31320
  return null;
31207
31321
  }
@@ -31380,11 +31494,87 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
31380
31494
  return null;
31381
31495
  }
31382
31496
 
31497
+ // src/commands/start/agent-startup-marks.ts
31498
+ var import_fs9 = __toESM(require("fs"));
31499
+ var import_os13 = __toESM(require("os"));
31500
+ var import_path10 = __toESM(require("path"));
31501
+ var STALE_MARK_MS = 18e4;
31502
+ function marksDir(deps) {
31503
+ return deps.dir ?? import_path10.default.join(import_os13.default.homedir(), ".codeam", "agent-startups");
31504
+ }
31505
+ function markAgentStarting(deps = {}) {
31506
+ const pid = deps.pid ?? process.pid;
31507
+ const file = import_path10.default.join(marksDir(deps), String(pid));
31508
+ try {
31509
+ import_fs9.default.mkdirSync(import_path10.default.dirname(file), { recursive: true });
31510
+ import_fs9.default.writeFileSync(file, ownerRecord(pid, deps));
31511
+ } catch {
31512
+ return () => void 0;
31513
+ }
31514
+ let released = false;
31515
+ return () => {
31516
+ if (released) return;
31517
+ released = true;
31518
+ try {
31519
+ import_fs9.default.rmSync(file, { force: true });
31520
+ } catch {
31521
+ }
31522
+ };
31523
+ }
31524
+ function otherAgentsStarting(deps = {}) {
31525
+ const dir = marksDir(deps);
31526
+ const self = deps.pid ?? process.pid;
31527
+ const now = (deps.now ?? Date.now)();
31528
+ let names;
31529
+ try {
31530
+ names = import_fs9.default.readdirSync(dir);
31531
+ } catch {
31532
+ return [];
31533
+ }
31534
+ const live = [];
31535
+ for (const name of names) {
31536
+ const pid = Number(name);
31537
+ if (!Number.isInteger(pid) || pid <= 0 || pid === self) continue;
31538
+ const file = import_path10.default.join(dir, name);
31539
+ let record2 = "";
31540
+ try {
31541
+ record2 = import_fs9.default.readFileSync(file, "utf8");
31542
+ } catch {
31543
+ continue;
31544
+ }
31545
+ let stale = !ownerIsAlive(record2.trim() || String(pid), deps);
31546
+ if (!stale) {
31547
+ try {
31548
+ stale = now - import_fs9.default.statSync(file).mtimeMs > STALE_MARK_MS;
31549
+ } catch {
31550
+ continue;
31551
+ }
31552
+ }
31553
+ if (stale) {
31554
+ try {
31555
+ import_fs9.default.rmSync(file, { force: true });
31556
+ } catch {
31557
+ }
31558
+ continue;
31559
+ }
31560
+ live.push(pid);
31561
+ }
31562
+ return live;
31563
+ }
31564
+ async function waitForNoAgentStarting(opts) {
31565
+ const now = opts.now ?? Date.now;
31566
+ const sleep5 = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
31567
+ const deadline = now() + opts.timeoutMs;
31568
+ while (otherAgentsStarting(opts).length > 0 && now() < deadline) {
31569
+ await sleep5(opts.pollMs ?? 500);
31570
+ }
31571
+ }
31572
+
31383
31573
  // src/agents/acp/runner.ts
31384
31574
  var import_node_crypto15 = require("crypto");
31385
- var fs83 = __toESM(require("fs"));
31386
- var os59 = __toESM(require("os"));
31387
- var path94 = __toESM(require("path"));
31575
+ var fs86 = __toESM(require("fs"));
31576
+ var os61 = __toESM(require("os"));
31577
+ var path96 = __toESM(require("path"));
31388
31578
 
31389
31579
  // src/agents/acp/provider-billing-signal.ts
31390
31580
  var seen = /* @__PURE__ */ new Set();
@@ -31416,8 +31606,8 @@ function noteProviderBillingSignal(opts) {
31416
31606
  }
31417
31607
 
31418
31608
  // src/services/history.service.ts
31419
- var fs65 = __toESM(require("fs"));
31420
- var path75 = __toESM(require("path"));
31609
+ var fs68 = __toESM(require("fs"));
31610
+ var path77 = __toESM(require("path"));
31421
31611
  var https6 = __toESM(require("https"));
31422
31612
  var http10 = __toESM(require("http"));
31423
31613
  var import_zod2 = require("zod");
@@ -31478,7 +31668,7 @@ function parseJsonl(filePath) {
31478
31668
  const messages = [];
31479
31669
  let raw;
31480
31670
  try {
31481
- raw = fs65.readFileSync(filePath, "utf8");
31671
+ raw = fs68.readFileSync(filePath, "utf8");
31482
31672
  } catch (err) {
31483
31673
  if (err.code !== "ENOENT") {
31484
31674
  log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
@@ -31638,7 +31828,7 @@ var HistoryService = class _HistoryService {
31638
31828
  // session-start upload answered false, the active-conversation pointer was
31639
31829
  // never re-pointed after a Box wake, and the app opened an empty "New
31640
31830
  // conversation" over the resumed one (QA box, 2026-09-29).
31641
- path75.join(claudeConfigDir(), "projects", encodeCwd(this.cwd));
31831
+ path77.join(claudeConfigDir(), "projects", encodeCwd(this.cwd));
31642
31832
  }
31643
31833
  /** Set the current Claude conversation ID (extracted from /cost command or session start) */
31644
31834
  setCurrentConversationId(id) {
@@ -31650,7 +31840,7 @@ var HistoryService = class _HistoryService {
31650
31840
  /** Return the current message count in the active conversation. */
31651
31841
  getCurrentMessageCount() {
31652
31842
  if (!this.currentConversationId) return 0;
31653
- const filePath = path75.join(this.projectDir, `${this.currentConversationId}.jsonl`);
31843
+ const filePath = path77.join(this.projectDir, `${this.currentConversationId}.jsonl`);
31654
31844
  return parseJsonl(filePath).length;
31655
31845
  }
31656
31846
  /**
@@ -31661,7 +31851,7 @@ var HistoryService = class _HistoryService {
31661
31851
  const deadline = Date.now() + timeoutMs;
31662
31852
  while (Date.now() < deadline) {
31663
31853
  if (!this.currentConversationId) return null;
31664
- const filePath = path75.join(this.projectDir, `${this.currentConversationId}.jsonl`);
31854
+ const filePath = path77.join(this.projectDir, `${this.currentConversationId}.jsonl`);
31665
31855
  const messages = parseJsonl(filePath);
31666
31856
  if (messages.length > previousCount) {
31667
31857
  for (let i = messages.length - 1; i >= previousCount; i--) {
@@ -31688,18 +31878,18 @@ var HistoryService = class _HistoryService {
31688
31878
  const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
31689
31879
  const oneShots = readOneShotConversations(this.cwd);
31690
31880
  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"))
31881
+ const files = fs68.readdirSync(dir, { withFileTypes: true }).filter(
31882
+ (e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(path77.basename(e.name, ".jsonl"))
31693
31883
  ).map((e) => {
31694
31884
  try {
31695
- const stat3 = fs65.statSync(path75.join(dir, e.name));
31885
+ const stat3 = fs68.statSync(path77.join(dir, e.name));
31696
31886
  return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
31697
31887
  } catch {
31698
31888
  return { name: e.name, mtime: 0, birthtime: 0 };
31699
31889
  }
31700
31890
  }).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
31701
31891
  if (files.length > 0) {
31702
- this.currentConversationId = path75.basename(files[0].name, ".jsonl");
31892
+ this.currentConversationId = path77.basename(files[0].name, ".jsonl");
31703
31893
  }
31704
31894
  } catch {
31705
31895
  }
@@ -31733,13 +31923,13 @@ var HistoryService = class _HistoryService {
31733
31923
  const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
31734
31924
  let entries2;
31735
31925
  try {
31736
- entries2 = fs65.readdirSync(dir, { withFileTypes: true });
31926
+ entries2 = fs68.readdirSync(dir, { withFileTypes: true });
31737
31927
  } catch {
31738
31928
  return null;
31739
31929
  }
31740
31930
  const files = entries2.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
31741
31931
  try {
31742
- const stat3 = fs65.statSync(path75.join(dir, e.name));
31932
+ const stat3 = fs68.statSync(path77.join(dir, e.name));
31743
31933
  return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
31744
31934
  } catch {
31745
31935
  return { name: e.name, mtime: 0, birthtime: 0 };
@@ -31748,12 +31938,12 @@ var HistoryService = class _HistoryService {
31748
31938
  if (files.length === 0) return null;
31749
31939
  const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
31750
31940
  if (!files.some((f) => f.name === targetFile)) return null;
31751
- return this.extractUsageFromFile(path75.join(dir, targetFile));
31941
+ return this.extractUsageFromFile(path77.join(dir, targetFile));
31752
31942
  }
31753
31943
  extractUsageFromFile(filePath) {
31754
31944
  let raw;
31755
31945
  try {
31756
- raw = fs65.readFileSync(filePath, "utf8");
31946
+ raw = fs68.readFileSync(filePath, "utf8");
31757
31947
  } catch {
31758
31948
  return null;
31759
31949
  }
@@ -31805,9 +31995,9 @@ var HistoryService = class _HistoryService {
31805
31995
  let totalCost = 0;
31806
31996
  let files;
31807
31997
  try {
31808
- files = fs65.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
31998
+ files = fs68.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
31809
31999
  try {
31810
- return fs65.statSync(path75.join(projectDir, f)).mtimeMs >= monthStartMs;
32000
+ return fs68.statSync(path77.join(projectDir, f)).mtimeMs >= monthStartMs;
31811
32001
  } catch {
31812
32002
  return false;
31813
32003
  }
@@ -31818,7 +32008,7 @@ var HistoryService = class _HistoryService {
31818
32008
  for (const file of files) {
31819
32009
  let raw;
31820
32010
  try {
31821
- raw = fs65.readFileSync(path75.join(projectDir, file), "utf8");
32011
+ raw = fs68.readFileSync(path77.join(projectDir, file), "utf8");
31822
32012
  } catch {
31823
32013
  continue;
31824
32014
  }
@@ -31897,7 +32087,7 @@ var HistoryService = class _HistoryService {
31897
32087
  if (this.runtime.resolveHistoryFile) {
31898
32088
  return this.runtime.resolveHistoryFile(this.cwd, sessionId);
31899
32089
  }
31900
- return path75.join(this.projectDir, `${sessionId}.jsonl`);
32090
+ return path77.join(this.projectDir, `${sessionId}.jsonl`);
31901
32091
  }
31902
32092
  /**
31903
32093
  * Parse a conversation's messages from disk, agent-aware. Claude uses the
@@ -31935,7 +32125,7 @@ var HistoryService = class _HistoryService {
31935
32125
  };
31936
32126
  });
31937
32127
  }
31938
- return parseJsonl(path75.join(this.projectDir, `${sessionId}.jsonl`));
32128
+ return parseJsonl(path77.join(this.projectDir, `${sessionId}.jsonl`));
31939
32129
  }
31940
32130
  /** One in-flight full upload per conversation — the baton mirror and a
31941
32131
  * `get_conversation` used to upload the same transcript concurrently. */
@@ -32017,7 +32207,7 @@ var HistoryService = class _HistoryService {
32017
32207
  if (!filePath) return false;
32018
32208
  let mtimeMs;
32019
32209
  try {
32020
- mtimeMs = fs65.statSync(filePath).mtimeMs;
32210
+ mtimeMs = fs68.statSync(filePath).mtimeMs;
32021
32211
  } catch {
32022
32212
  return false;
32023
32213
  }
@@ -32092,10 +32282,10 @@ var HistoryService = class _HistoryService {
32092
32282
 
32093
32283
  // src/agents/acp/client.ts
32094
32284
  var import_node_child_process27 = require("child_process");
32095
- var fs66 = __toESM(require("fs/promises"));
32285
+ var fs69 = __toESM(require("fs/promises"));
32096
32286
  var fsSync = __toESM(require("fs"));
32097
- var os49 = __toESM(require("os"));
32098
- var path77 = __toESM(require("path"));
32287
+ var os51 = __toESM(require("os"));
32288
+ var path79 = __toESM(require("path"));
32099
32289
  var import_node_stream = require("stream");
32100
32290
 
32101
32291
  // ../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
@@ -36121,8 +36311,8 @@ function createIdleTimeout(idleMs, makeError, activeIdleMs = idleMs) {
36121
36311
  }
36122
36312
 
36123
36313
  // src/agents/acp/internal-paths.ts
36124
- var path76 = __toESM(require("path"));
36125
- var os48 = __toESM(require("os"));
36314
+ var path78 = __toESM(require("path"));
36315
+ var os50 = __toESM(require("os"));
36126
36316
  var INTERNAL_TOKENS = [".codeam", "house-claude"];
36127
36317
  var PROSE_ONLY_TOOL_KINDS = /* @__PURE__ */ new Set(["think", "switch_mode"]);
36128
36318
  function isProseOnlyToolKind(kind) {
@@ -36134,13 +36324,13 @@ function textReferencesInternal(text) {
36134
36324
  const scrubbed = text.replace(SELF_HOSTED_WORKSPACE_RE, " ");
36135
36325
  return INTERNAL_TOKENS.some((t2) => scrubbed.includes(t2));
36136
36326
  }
36137
- function pathIsInternal(p2, homeDir2 = os48.homedir()) {
36327
+ function pathIsInternal(p2, homeDir2 = os50.homedir()) {
36138
36328
  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`);
36329
+ const abs = path78.resolve(p2);
36330
+ const home = path78.resolve(homeDir2);
36331
+ const within = (root) => abs === root || abs.startsWith(root + path78.sep);
36332
+ if (within(path78.join(home, ".codeam", "self-hosted"))) return false;
36333
+ 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
36334
  }
36145
36335
  function toolCallReferencesInternal(call, homeDir2) {
36146
36336
  if (call.locations?.some((l) => pathIsInternal(l.path, homeDir2))) return true;
@@ -37236,7 +37426,7 @@ var AcpClient = class {
37236
37426
  throw new RequestError(-32002, GUARDRAIL_SECRET_READ_BLOCK_REASON, { uri: params.path });
37237
37427
  }
37238
37428
  try {
37239
- const content = await fs66.readFile(params.path, "utf8");
37429
+ const content = await fs69.readFile(params.path, "utf8");
37240
37430
  return applyLineRange(content, params.line ?? null, params.limit ?? null);
37241
37431
  } catch (err) {
37242
37432
  const code = err.code;
@@ -37257,7 +37447,7 @@ var AcpClient = class {
37257
37447
  throw new RequestError(-32002, INTERNAL_BLOCK_REASON, { uri: params.path });
37258
37448
  }
37259
37449
  try {
37260
- await fs66.writeFile(params.path, params.content, "utf8");
37450
+ await fs69.writeFile(params.path, params.content, "utf8");
37261
37451
  return {};
37262
37452
  } catch (err) {
37263
37453
  const code = err.code;
@@ -37345,30 +37535,30 @@ function applyLineRange(content, line, limit) {
37345
37535
  return { content: lines.slice(start2, end).join("\n") };
37346
37536
  }
37347
37537
  function knownAgentBinaryDirs() {
37348
- const home = os49.homedir();
37538
+ const home = os51.homedir();
37349
37539
  const out2 = [];
37350
37540
  out2.push("/tmp/codeam-node20/bin");
37351
37541
  for (const root of [
37352
37542
  "/usr/local/share/nvm/versions/node",
37353
- path77.join(home, ".nvm/versions/node")
37543
+ path79.join(home, ".nvm/versions/node")
37354
37544
  ]) {
37355
37545
  try {
37356
37546
  for (const child of fsSync.readdirSync(root)) {
37357
- out2.push(path77.join(root, child, "bin"));
37547
+ out2.push(path79.join(root, child, "bin"));
37358
37548
  }
37359
37549
  } catch {
37360
37550
  }
37361
37551
  }
37362
- out2.push(path77.join(home, ".volta/bin"));
37552
+ out2.push(path79.join(home, ".volta/bin"));
37363
37553
  out2.push("/usr/local/bin");
37364
37554
  out2.push("/usr/bin");
37365
- out2.push(path77.join(home, ".local/bin"));
37366
- out2.push(path77.join(home, "bin"));
37555
+ out2.push(path79.join(home, ".local/bin"));
37556
+ out2.push(path79.join(home, "bin"));
37367
37557
  out2.push(...agentInstallBinDirs());
37368
37558
  if (process.platform === "win32") {
37369
37559
  const { LOCALAPPDATA, APPDATA } = process.env;
37370
- if (LOCALAPPDATA) out2.push(path77.join(LOCALAPPDATA, "cursor-agent"));
37371
- if (APPDATA) out2.push(path77.join(APPDATA, "npm"));
37560
+ if (LOCALAPPDATA) out2.push(path79.join(LOCALAPPDATA, "cursor-agent"));
37561
+ if (APPDATA) out2.push(path79.join(APPDATA, "npm"));
37372
37562
  }
37373
37563
  return out2.filter((p2) => {
37374
37564
  try {
@@ -37379,7 +37569,7 @@ function knownAgentBinaryDirs() {
37379
37569
  });
37380
37570
  }
37381
37571
  function expandPathForAgentBinaries(existingPath) {
37382
- const existing = new Set(existingPath.split(path77.delimiter).filter((p2) => p2.length > 0));
37572
+ const existing = new Set(existingPath.split(path79.delimiter).filter((p2) => p2.length > 0));
37383
37573
  const additions = [];
37384
37574
  for (const dir of knownAgentBinaryDirs()) {
37385
37575
  if (!existing.has(dir)) {
@@ -37388,17 +37578,17 @@ function expandPathForAgentBinaries(existingPath) {
37388
37578
  }
37389
37579
  }
37390
37580
  if (additions.length === 0) return existingPath;
37391
- return [...additions, existingPath].filter((p2) => p2.length > 0).join(path77.delimiter);
37581
+ return [...additions, existingPath].filter((p2) => p2.length > 0).join(path79.delimiter);
37392
37582
  }
37393
37583
 
37394
37584
  // src/commands/host/agent-install.ts
37395
37585
  var import_child_process27 = require("child_process");
37396
- var os50 = __toESM(require("os"));
37586
+ var os52 = __toESM(require("os"));
37397
37587
  function runAgentInstallScript(script, opts = {}) {
37398
37588
  const timeoutMs = opts.timeoutMs ?? 18e4;
37399
37589
  const scope = opts.logScope ?? "agent-install";
37400
37590
  return new Promise((resolve14) => {
37401
- const home = process.env.HOME || os50.homedir();
37591
+ const home = process.env.HOME || os52.homedir();
37402
37592
  const child = (0, import_child_process27.spawn)("sh", ["-c", script], {
37403
37593
  env: { ...process.env, HOME: home },
37404
37594
  stdio: ["ignore", "pipe", "pipe"]
@@ -37660,9 +37850,9 @@ async function performAgentSwitch(deps, rawAgentId, fastPath = {}) {
37660
37850
  }
37661
37851
 
37662
37852
  // src/commands/host/agent-provisioning.ts
37663
- var fs67 = __toESM(require("fs"));
37664
- var os51 = __toESM(require("os"));
37665
- var path78 = __toESM(require("path"));
37853
+ var fs70 = __toESM(require("fs"));
37854
+ var os53 = __toESM(require("os"));
37855
+ var path80 = __toESM(require("path"));
37666
37856
  var PUBLIC_TO_INTERNAL_AGENT = {
37667
37857
  claude_code: "claude",
37668
37858
  claude: "claude",
@@ -37679,22 +37869,22 @@ function toInternalAgentId(publicAgentId) {
37679
37869
  return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
37680
37870
  }
37681
37871
  function ensureDir(dir) {
37682
- fs67.mkdirSync(dir, { recursive: true, mode: 448 });
37872
+ fs70.mkdirSync(dir, { recursive: true, mode: 448 });
37683
37873
  }
37684
37874
  function writeFile0600(filePath, contents) {
37685
- ensureDir(path78.dirname(filePath));
37686
- fs67.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
37875
+ ensureDir(path80.dirname(filePath));
37876
+ fs70.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
37687
37877
  restrictToOwner(filePath);
37688
37878
  }
37689
37879
  function rmIfExists(filePath) {
37690
37880
  try {
37691
- fs67.rmSync(filePath, { force: true });
37881
+ fs70.rmSync(filePath, { force: true });
37692
37882
  } catch {
37693
37883
  }
37694
37884
  }
37695
37885
  var claudeProvisioner = {
37696
37886
  write(auth, home) {
37697
- const credentialsJson = path78.join(home, ".claude", ".credentials.json");
37887
+ const credentialsJson = path80.join(home, ".claude", ".credentials.json");
37698
37888
  if (auth.kind === "api_key") {
37699
37889
  rmIfExists(credentialsJson);
37700
37890
  return { ANTHROPIC_API_KEY: auth.value };
@@ -37706,8 +37896,8 @@ var claudeProvisioner = {
37706
37896
  } else {
37707
37897
  rmIfExists(credentialsJson);
37708
37898
  }
37709
- const claudeJson = path78.join(home, ".claude.json");
37710
- if (!fs67.existsSync(claudeJson)) {
37899
+ const claudeJson = path80.join(home, ".claude.json");
37900
+ if (!fs70.existsSync(claudeJson)) {
37711
37901
  writeFile0600(
37712
37902
  claudeJson,
37713
37903
  JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
@@ -37718,7 +37908,7 @@ var claudeProvisioner = {
37718
37908
  };
37719
37909
  var codexProvisioner = {
37720
37910
  write(auth, home) {
37721
- const authJson = path78.join(home, ".codex", "auth.json");
37911
+ const authJson = path80.join(home, ".codex", "auth.json");
37722
37912
  if (auth.kind === "api_key") {
37723
37913
  writeFile0600(authJson, JSON.stringify({ auth_mode: "apikey", OPENAI_API_KEY: auth.value }));
37724
37914
  return { OPENAI_API_KEY: auth.value };
@@ -37741,7 +37931,7 @@ function codexLoginStamp(raw) {
37741
37931
  function keepsFresherCodexLogin(authJsonPath, incoming) {
37742
37932
  let onDisk;
37743
37933
  try {
37744
- onDisk = fs67.readFileSync(authJsonPath, "utf8");
37934
+ onDisk = fs70.readFileSync(authJsonPath, "utf8");
37745
37935
  } catch {
37746
37936
  return false;
37747
37937
  }
@@ -37752,8 +37942,8 @@ function keepsFresherCodexLogin(authJsonPath, incoming) {
37752
37942
  }
37753
37943
  var geminiProvisioner = {
37754
37944
  write(auth, home) {
37755
- const settingsJson = path78.join(home, ".gemini", "settings.json");
37756
- const oauthCreds = path78.join(home, ".gemini", "oauth_creds.json");
37945
+ const settingsJson = path80.join(home, ".gemini", "settings.json");
37946
+ const oauthCreds = path80.join(home, ".gemini", "oauth_creds.json");
37757
37947
  if (auth.kind === "api_key") {
37758
37948
  rmIfExists(oauthCreds);
37759
37949
  writeFile0600(settingsJson, '{"security":{"auth":{"selectedType":"gemini-api-key"}}}');
@@ -37766,7 +37956,7 @@ var geminiProvisioner = {
37766
37956
  };
37767
37957
  var cursorProvisioner = {
37768
37958
  write(auth, home) {
37769
- const authJson = path78.join(home, ".config", "cursor", "auth.json");
37959
+ const authJson = path80.join(home, ".config", "cursor", "auth.json");
37770
37960
  if (auth.kind === "api_key") {
37771
37961
  rmIfExists(authJson);
37772
37962
  return { CURSOR_API_KEY: auth.value };
@@ -37808,22 +37998,22 @@ max_context_size = 262144
37808
37998
  var kimiProvisioner = {
37809
37999
  write(auth, home) {
37810
38000
  const credentialsFiles = [
37811
- path78.join(home, ".kimi", "credentials", "kimi-code.json"),
37812
- path78.join(home, ".kimi-code", "credentials", "kimi-code.json")
38001
+ path80.join(home, ".kimi", "credentials", "kimi-code.json"),
38002
+ path80.join(home, ".kimi-code", "credentials", "kimi-code.json")
37813
38003
  ];
37814
38004
  if (auth.kind === "api_key") {
37815
38005
  credentialsFiles.forEach(rmIfExists);
37816
38006
  return { KIMI_API_KEY: auth.value };
37817
38007
  }
37818
38008
  credentialsFiles.forEach((f) => writeFile0600(f, auth.value));
37819
- writeFile0600(path78.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
38009
+ writeFile0600(path80.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
37820
38010
  return {};
37821
38011
  }
37822
38012
  };
37823
38013
  var coderabbitProvisioner = {
37824
38014
  write(auth, home) {
37825
- const dir = path78.join(home, ".coderabbit");
37826
- const authJson = path78.join(dir, "auth.json");
38015
+ const dir = path80.join(home, ".coderabbit");
38016
+ const authJson = path80.join(dir, "auth.json");
37827
38017
  if (auth.kind === "api_key") {
37828
38018
  rmIfExists(authJson);
37829
38019
  return { CODERABBIT_API_KEY: auth.value };
@@ -37835,13 +38025,13 @@ var coderabbitProvisioner = {
37835
38025
  try {
37836
38026
  const parsed = JSON.parse(value);
37837
38027
  if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
37838
- file = path78.basename(parsed.file);
38028
+ file = path80.basename(parsed.file);
37839
38029
  contents = parsed.contents;
37840
38030
  }
37841
38031
  } catch {
37842
38032
  }
37843
38033
  }
37844
- writeFile0600(path78.join(dir, file), contents);
38034
+ writeFile0600(path80.join(dir, file), contents);
37845
38035
  return {};
37846
38036
  }
37847
38037
  };
@@ -37869,7 +38059,7 @@ var UnsupportedAgentError = class extends Error {
37869
38059
  this.agentId = agentId;
37870
38060
  }
37871
38061
  };
37872
- function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os51.homedir()) {
38062
+ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os53.homedir()) {
37873
38063
  const internal = toInternalAgentId(publicAgentId);
37874
38064
  if (!internal) throw new UnsupportedAgentError(publicAgentId);
37875
38065
  const provisioner = PROVISIONERS[internal];
@@ -37878,8 +38068,8 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os51.homedir(
37878
38068
  }
37879
38069
 
37880
38070
  // src/beads/workflow-hint.ts
37881
- var fs68 = __toESM(require("fs"));
37882
- var path79 = __toESM(require("path"));
38071
+ var fs71 = __toESM(require("fs"));
38072
+ var path81 = __toESM(require("path"));
37883
38073
  var BEADS_HINT_MARKER = "<!-- codeam:beads-workflow -->";
37884
38074
  var BEADS_HINT = `${BEADS_HINT_MARKER}
37885
38075
  # Beads (bd) \u2014 task tracking + persistent memory (ALWAYS use it)
@@ -37906,11 +38096,11 @@ function ensureBeadsWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2)) {
37906
38096
  try {
37907
38097
  let existing = "";
37908
38098
  try {
37909
- existing = fs68.readFileSync(file, "utf8");
38099
+ existing = fs71.readFileSync(file, "utf8");
37910
38100
  } catch {
37911
38101
  }
37912
38102
  if (existing.includes(BEADS_HINT)) return;
37913
- fs68.mkdirSync(path79.dirname(file), { recursive: true });
38103
+ fs71.mkdirSync(path81.dirname(file), { recursive: true });
37914
38104
  let next;
37915
38105
  const open = existing.indexOf(BEADS_HINT_MARKER);
37916
38106
  const close = open === -1 ? -1 : existing.indexOf(BEADS_HINT_MARKER, open + BEADS_HINT_MARKER.length);
@@ -37923,40 +38113,40 @@ ${BEADS_HINT}
37923
38113
  ` : `${BEADS_HINT}
37924
38114
  `;
37925
38115
  }
37926
- fs68.writeFileSync(file, next);
38116
+ fs71.writeFileSync(file, next);
37927
38117
  } catch {
37928
38118
  }
37929
38119
  }
37930
38120
 
37931
38121
  // src/agents/agent-standard.ts
37932
- var fs69 = __toESM(require("fs"));
37933
- var path80 = __toESM(require("path"));
37934
- var os52 = __toESM(require("os"));
38122
+ var fs72 = __toESM(require("fs"));
38123
+ var path82 = __toESM(require("path"));
38124
+ var os54 = __toESM(require("os"));
37935
38125
  function ensureAgentStandard(homeDir2, file = claudeMemoryFile(homeDir2)) {
37936
38126
  try {
37937
38127
  let existing = "";
37938
38128
  try {
37939
- existing = fs69.readFileSync(file, "utf8");
38129
+ existing = fs72.readFileSync(file, "utf8");
37940
38130
  } catch {
37941
38131
  }
37942
38132
  if (existing.includes(AGENT_STANDARD_MARKER)) return;
37943
- fs69.mkdirSync(path80.dirname(file), { recursive: true });
38133
+ fs72.mkdirSync(path82.dirname(file), { recursive: true });
37944
38134
  const next = existing.trim() ? `${existing.trimEnd()}
37945
38135
 
37946
38136
  ${AGENT_STANDARD_BLOCK}
37947
38137
  ` : `${AGENT_STANDARD_BLOCK}
37948
38138
  `;
37949
- fs69.writeFileSync(file, next);
38139
+ fs72.writeFileSync(file, next);
37950
38140
  } catch {
37951
38141
  }
37952
38142
  }
37953
38143
  var _agentStandardSeam = {
37954
38144
  isLocalSession: () => isLocalSession(),
37955
- markerPath: (sessionId) => path80.join(os52.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
37956
- exists: (p2) => fs69.existsSync(p2),
38145
+ markerPath: (sessionId) => path82.join(os54.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
38146
+ exists: (p2) => fs72.existsSync(p2),
37957
38147
  write: (p2) => {
37958
- fs69.mkdirSync(path80.dirname(p2), { recursive: true });
37959
- fs69.writeFileSync(p2, "");
38148
+ fs72.mkdirSync(path82.dirname(p2), { recursive: true });
38149
+ fs72.writeFileSync(p2, "");
37960
38150
  }
37961
38151
  };
37962
38152
  function isClaude(agent) {
@@ -38691,15 +38881,15 @@ function withholdTrailingPartialFenceMarker(text) {
38691
38881
 
38692
38882
  // src/agents/acp/onboarding.ts
38693
38883
  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"));
38884
+ var fs74 = __toESM(require("fs"));
38885
+ var os55 = __toESM(require("os"));
38886
+ var path84 = __toESM(require("path"));
38697
38887
  var _onboardingSeam = {
38698
- markerPath: (sessionId) => path82.join(os53.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
38699
- exists: (p2) => fs71.existsSync(p2),
38888
+ markerPath: (sessionId) => path84.join(os55.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
38889
+ exists: (p2) => fs74.existsSync(p2),
38700
38890
  write: (p2) => {
38701
- fs71.mkdirSync(path82.dirname(p2), { recursive: true });
38702
- fs71.writeFileSync(p2, "");
38891
+ fs74.mkdirSync(path84.dirname(p2), { recursive: true });
38892
+ fs74.writeFileSync(p2, "");
38703
38893
  },
38704
38894
  disabled: () => {
38705
38895
  const v = process.env.CODEAM_ONBOARDING_DISABLED;
@@ -38736,7 +38926,7 @@ function resolveRepoName(cwd) {
38736
38926
  if (name) return name;
38737
38927
  }
38738
38928
  }
38739
- const base = path82.basename(cwd || "");
38929
+ const base = path84.basename(cwd || "");
38740
38930
  if (base && !isUuid(base)) return base;
38741
38931
  return "this project";
38742
38932
  }
@@ -39128,14 +39318,14 @@ var import_crypto5 = require("crypto");
39128
39318
 
39129
39319
  // src/services/turn-files/git-changeset.ts
39130
39320
  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"));
39321
+ var fs76 = __toESM(require("fs/promises"));
39322
+ var import_fs10 = require("fs");
39323
+ var path86 = __toESM(require("path"));
39134
39324
 
39135
39325
  // src/services/turn-files/review-ignore.ts
39136
39326
  var import_ignore2 = __toESM(require("ignore"));
39137
- var fs72 = __toESM(require("fs"));
39138
- var path83 = __toESM(require("path"));
39327
+ var fs75 = __toESM(require("fs"));
39328
+ var path85 = __toESM(require("path"));
39139
39329
  var CURATED_REVIEW_IGNORE = [
39140
39330
  // Google Cloud SDK (the incident) — installs a huge python tree.
39141
39331
  "google-cloud-sdk/",
@@ -39179,7 +39369,7 @@ var CURATED_REVIEW_IGNORE = [
39179
39369
  function makeReviewIgnore(repoRoot) {
39180
39370
  const ig = (0, import_ignore2.default)().add(CURATED_REVIEW_IGNORE);
39181
39371
  try {
39182
- const custom = fs72.readFileSync(path83.join(repoRoot, ".codeam", "reviewignore"), "utf8");
39372
+ const custom = fs75.readFileSync(path85.join(repoRoot, ".codeam", "reviewignore"), "utf8");
39183
39373
  ig.add(custom);
39184
39374
  } catch {
39185
39375
  }
@@ -39214,7 +39404,7 @@ async function collectRepoChangeset(opts) {
39214
39404
  const rows = parseStatus(status2).filter(
39215
39405
  (row) => !isIgnoredFilePath(row.filePath) && !reviewIgnore(row.filePath) && // A socket, FIFO or device node is never a change to review (a
39216
39406
  // `cc-socks/1522.sock` reached the Files tab).
39217
- isReviewablePath(path84.join(opts.repoRoot, row.filePath))
39407
+ isReviewablePath(path86.join(opts.repoRoot, row.filePath))
39218
39408
  );
39219
39409
  const MAX_CHANGESET_FILES = Math.max(1, Number(process.env.CODEAM_MAX_CHANGESET_FILES ?? 500));
39220
39410
  const truncated = rows.length > MAX_CHANGESET_FILES;
@@ -39231,7 +39421,7 @@ async function collectRepoChangeset(opts) {
39231
39421
  let stats;
39232
39422
  if (!truncated && row.fileStatus === "added" && numstatEntry === void 0) {
39233
39423
  const lineCount = await readUntrackedLineCount(
39234
- path84.join(opts.repoRoot, row.filePath)
39424
+ path86.join(opts.repoRoot, row.filePath)
39235
39425
  );
39236
39426
  stats = { added: lineCount, removed: 0 };
39237
39427
  } else {
@@ -39262,7 +39452,7 @@ function readUntrackedLineCount(absPath) {
39262
39452
  }
39263
39453
  async function defaultReadUntrackedLineCount(absPath) {
39264
39454
  try {
39265
- const content = await fs73.readFile(absPath, "utf8");
39455
+ const content = await fs76.readFile(absPath, "utf8");
39266
39456
  let count = 0;
39267
39457
  let pos = -1;
39268
39458
  while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
@@ -39354,7 +39544,7 @@ function defaultRunGit(cwd, args2) {
39354
39544
  });
39355
39545
  }
39356
39546
  async function discoverRepos(workingDir, maxDepth = 4) {
39357
- const fs97 = await import("fs/promises");
39547
+ const fs100 = await import("fs/promises");
39358
39548
  const out2 = [];
39359
39549
  await walk2(workingDir, 0);
39360
39550
  return out2;
@@ -39362,7 +39552,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
39362
39552
  if (depth2 > maxDepth) return;
39363
39553
  let entries2 = [];
39364
39554
  try {
39365
- const dirents = await fs97.readdir(dir, { withFileTypes: true });
39555
+ const dirents = await fs100.readdir(dir, { withFileTypes: true });
39366
39556
  entries2 = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
39367
39557
  } catch {
39368
39558
  return;
@@ -39373,8 +39563,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
39373
39563
  if (hasGit) {
39374
39564
  out2.push({
39375
39565
  repoRoot: dir,
39376
- repoPath: path84.relative(workingDir, dir),
39377
- repoName: path84.basename(dir)
39566
+ repoPath: path86.relative(workingDir, dir),
39567
+ repoName: path86.basename(dir)
39378
39568
  });
39379
39569
  return;
39380
39570
  }
@@ -39382,13 +39572,13 @@ async function discoverRepos(workingDir, maxDepth = 4) {
39382
39572
  if (!entry.isDirectory) continue;
39383
39573
  if (entry.name === "node_modules") continue;
39384
39574
  if (entry.name === "dist" || entry.name === "build") continue;
39385
- await walk2(path84.join(dir, entry.name), depth2 + 1);
39575
+ await walk2(path86.join(dir, entry.name), depth2 + 1);
39386
39576
  }
39387
39577
  }
39388
39578
  }
39389
39579
  function isReviewablePath(absPath) {
39390
39580
  try {
39391
- const st3 = (0, import_fs7.lstatSync)(absPath);
39581
+ const st3 = (0, import_fs10.lstatSync)(absPath);
39392
39582
  return st3.isFile() || st3.isSymbolicLink();
39393
39583
  } catch {
39394
39584
  return true;
@@ -39396,9 +39586,9 @@ function isReviewablePath(absPath) {
39396
39586
  }
39397
39587
 
39398
39588
  // 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");
39589
+ var fs77 = __toESM(require("fs/promises"));
39590
+ var path87 = __toESM(require("path"));
39591
+ var import_os14 = require("os");
39402
39592
  var HOME_OUTBOX_DIR = ".codeam/outbox";
39403
39593
  var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
39404
39594
  var BACKOFF_STEPS_MS = [
@@ -39430,16 +39620,16 @@ var FilesOutbox = class {
39430
39620
  backoffIndex = 0;
39431
39621
  stopped = false;
39432
39622
  constructor(opts) {
39433
- const base = opts.baseDir ?? path85.join(homeDir(), HOME_OUTBOX_DIR);
39434
- this.filePath = path85.join(base, `${opts.sessionId}.jsonl`);
39623
+ const base = opts.baseDir ?? path87.join(homeDir(), HOME_OUTBOX_DIR);
39624
+ this.filePath = path87.join(base, `${opts.sessionId}.jsonl`);
39435
39625
  this.post = opts.post;
39436
39626
  this.autoSchedule = opts.autoSchedule !== false;
39437
39627
  }
39438
39628
  /** Persist the entry to disk and trigger a flush. Returns once the
39439
39629
  * line is durable on disk (not once the POST succeeds). */
39440
39630
  async enqueue(entry) {
39441
- await fs74.mkdir(path85.dirname(this.filePath), { recursive: true });
39442
- await fs74.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
39631
+ await fs77.mkdir(path87.dirname(this.filePath), { recursive: true });
39632
+ await fs77.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
39443
39633
  this.backoffIndex = 0;
39444
39634
  if (this.autoSchedule) this.scheduleFlush(0);
39445
39635
  }
@@ -39530,7 +39720,7 @@ var FilesOutbox = class {
39530
39720
  async readAll() {
39531
39721
  let raw = "";
39532
39722
  try {
39533
- raw = await fs74.readFile(this.filePath, "utf8");
39723
+ raw = await fs77.readFile(this.filePath, "utf8");
39534
39724
  } catch {
39535
39725
  return [];
39536
39726
  }
@@ -39554,12 +39744,12 @@ var FilesOutbox = class {
39554
39744
  async rewrite(entries2) {
39555
39745
  const tmpPath = `${this.filePath}.${process.pid}.tmp`;
39556
39746
  if (entries2.length === 0) {
39557
- await fs74.unlink(this.filePath).catch(() => void 0);
39747
+ await fs77.unlink(this.filePath).catch(() => void 0);
39558
39748
  return;
39559
39749
  }
39560
39750
  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);
39751
+ await fs77.writeFile(tmpPath, payload, "utf8");
39752
+ await fs77.rename(tmpPath, this.filePath);
39563
39753
  }
39564
39754
  };
39565
39755
  function applyJitter(ms) {
@@ -39567,7 +39757,7 @@ function applyJitter(ms) {
39567
39757
  return Math.round(ms * factor);
39568
39758
  }
39569
39759
  function homeDir() {
39570
- return process.env.HOME ?? process.env.USERPROFILE ?? (0, import_os12.tmpdir)();
39760
+ return process.env.HOME ?? process.env.USERPROFILE ?? (0, import_os14.tmpdir)();
39571
39761
  }
39572
39762
 
39573
39763
  // src/services/turn-files/turn-file-aggregator.ts
@@ -39907,27 +40097,27 @@ async function readActiveConversationMarker(cwd, homeDir2) {
39907
40097
  }
39908
40098
 
39909
40099
  // src/services/turn-marker.ts
39910
- var fs76 = __toESM(require("fs"));
39911
- var os55 = __toESM(require("os"));
39912
- var path87 = __toESM(require("path"));
40100
+ var fs79 = __toESM(require("fs"));
40101
+ var os57 = __toESM(require("os"));
40102
+ var path89 = __toESM(require("path"));
39913
40103
  var depth = 0;
39914
40104
  function codeamHome() {
39915
- return path87.join(os55.homedir(), ".codeam");
40105
+ return path89.join(os57.homedir(), ".codeam");
39916
40106
  }
39917
40107
  function turnMarkerPath(pid = process.pid, home = codeamHome()) {
39918
- return path87.join(home, "turns", String(pid));
40108
+ return path89.join(home, "turns", String(pid));
39919
40109
  }
39920
40110
  function mark() {
39921
40111
  try {
39922
40112
  const file = turnMarkerPath();
39923
- fs76.mkdirSync(path87.dirname(file), { recursive: true });
39924
- fs76.writeFileSync(file, String(Date.now()));
40113
+ fs79.mkdirSync(path89.dirname(file), { recursive: true });
40114
+ fs79.writeFileSync(file, String(Date.now()));
39925
40115
  } catch {
39926
40116
  }
39927
40117
  }
39928
40118
  function clear() {
39929
40119
  try {
39930
- fs76.rmSync(turnMarkerPath(), { force: true });
40120
+ fs79.rmSync(turnMarkerPath(), { force: true });
39931
40121
  } catch {
39932
40122
  }
39933
40123
  }
@@ -39942,7 +40132,7 @@ async function withTurnMarker(fn) {
39942
40132
  function isProcessMidTurn(pid, home) {
39943
40133
  if (!pid) return false;
39944
40134
  try {
39945
- return fs76.existsSync(turnMarkerPath(pid, home));
40135
+ return fs79.existsSync(turnMarkerPath(pid, home));
39946
40136
  } catch {
39947
40137
  return false;
39948
40138
  }
@@ -39950,8 +40140,8 @@ function isProcessMidTurn(pid, home) {
39950
40140
 
39951
40141
  // src/packs/gates.ts
39952
40142
  var import_node_child_process28 = require("child_process");
39953
- var fs77 = __toESM(require("fs"));
39954
- var path88 = __toESM(require("path"));
40143
+ var fs80 = __toESM(require("fs"));
40144
+ var path90 = __toESM(require("path"));
39955
40145
  var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((resolve14) => {
39956
40146
  (0, import_node_child_process28.execFile)(
39957
40147
  file,
@@ -40001,7 +40191,7 @@ async function changedFiles(run3, cwd, from, to) {
40001
40191
  }
40002
40192
  function readWorkspaceFile(cwd, relPath) {
40003
40193
  try {
40004
- return fs77.readFileSync(path88.join(cwd, relPath), "utf8");
40194
+ return fs80.readFileSync(path90.join(cwd, relPath), "utf8");
40005
40195
  } catch {
40006
40196
  return null;
40007
40197
  }
@@ -40010,14 +40200,14 @@ var NO_TEST_PLACEHOLDER = 'echo "Error: no test specified"';
40010
40200
  var CHECKS_TIMEOUT_MS = 5 * 6e4;
40011
40201
  function detectChecksCommand(cwd) {
40012
40202
  try {
40013
- const cfg = JSON.parse(fs77.readFileSync(path88.join(cwd, ".codeam", "pack.json"), "utf8"));
40203
+ const cfg = JSON.parse(fs80.readFileSync(path90.join(cwd, ".codeam", "pack.json"), "utf8"));
40014
40204
  if (typeof cfg.checksCommand === "string" && cfg.checksCommand.trim().length > 0) {
40015
40205
  return cfg.checksCommand.trim();
40016
40206
  }
40017
40207
  } catch {
40018
40208
  }
40019
40209
  try {
40020
- const pkg = JSON.parse(fs77.readFileSync(path88.join(cwd, "package.json"), "utf8"));
40210
+ const pkg = JSON.parse(fs80.readFileSync(path90.join(cwd, "package.json"), "utf8"));
40021
40211
  const test = pkg.scripts?.test;
40022
40212
  if (typeof test === "string" && test.trim().length > 0 && !test.includes(NO_TEST_PLACEHOLDER)) {
40023
40213
  return "npm test";
@@ -40035,39 +40225,39 @@ ${res.stderr}`.trim();
40035
40225
  }
40036
40226
 
40037
40227
  // src/packs/run-store.ts
40038
- var fs78 = __toESM(require("fs"));
40039
- var path89 = __toESM(require("path"));
40228
+ var fs81 = __toESM(require("fs"));
40229
+ var path91 = __toESM(require("path"));
40040
40230
  var crypto5 = __toESM(require("crypto"));
40041
40231
  function packsDir(cwd) {
40042
- return path89.join(cwd, ".codeam", "packs");
40232
+ return path91.join(cwd, ".codeam", "packs");
40043
40233
  }
40044
40234
  function runDir(cwd, runId) {
40045
- return path89.join(packsDir(cwd), runId);
40235
+ return path91.join(packsDir(cwd), runId);
40046
40236
  }
40047
40237
  function newRunId() {
40048
40238
  return `pk_${Date.now().toString(36)}_${crypto5.randomBytes(4).toString("hex")}`;
40049
40239
  }
40050
40240
  function writeJsonAtomic(file, value) {
40051
- fs78.mkdirSync(path89.dirname(file), { recursive: true });
40241
+ fs81.mkdirSync(path91.dirname(file), { recursive: true });
40052
40242
  const tmp = `${file}.tmp`;
40053
- fs78.writeFileSync(tmp, JSON.stringify(value, null, 2));
40054
- fs78.renameSync(tmp, file);
40243
+ fs81.writeFileSync(tmp, JSON.stringify(value, null, 2));
40244
+ fs81.renameSync(tmp, file);
40055
40245
  }
40056
40246
  function saveRun(cwd, state) {
40057
- writeJsonAtomic(path89.join(runDir(cwd, state.runId), "run.json"), state);
40247
+ writeJsonAtomic(path91.join(runDir(cwd, state.runId), "run.json"), state);
40058
40248
  }
40059
40249
  function saveStageHandoff(cwd, runId, stageIndex, role, handoff) {
40060
40250
  const name = `${String(stageIndex + 1).padStart(2, "0")}-${role}.json`;
40061
- writeJsonAtomic(path89.join(runDir(cwd, runId), name), handoff);
40251
+ writeJsonAtomic(path91.join(runDir(cwd, runId), name), handoff);
40062
40252
  }
40063
40253
  function loadLatestRun(cwd) {
40064
40254
  try {
40065
40255
  const dir = packsDir(cwd);
40066
- const entries2 = fs78.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
40256
+ const entries2 = fs81.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
40067
40257
  for (let i = entries2.length - 1; i >= 0; i--) {
40068
- const file = path89.join(dir, entries2[i], "run.json");
40258
+ const file = path91.join(dir, entries2[i], "run.json");
40069
40259
  try {
40070
- const parsed = JSON.parse(fs78.readFileSync(file, "utf8"));
40260
+ const parsed = JSON.parse(fs81.readFileSync(file, "utf8"));
40071
40261
  if (parsed && typeof parsed.runId === "string") return parsed;
40072
40262
  } catch {
40073
40263
  }
@@ -40078,17 +40268,17 @@ function loadLatestRun(cwd) {
40078
40268
  }
40079
40269
  function ensureLedgerIgnored(cwd) {
40080
40270
  try {
40081
- const gitDir = path89.join(cwd, ".git");
40082
- if (!fs78.existsSync(gitDir)) return;
40083
- const exclude = path89.join(gitDir, "info", "exclude");
40271
+ const gitDir = path91.join(cwd, ".git");
40272
+ if (!fs81.existsSync(gitDir)) return;
40273
+ const exclude = path91.join(gitDir, "info", "exclude");
40084
40274
  let existing = "";
40085
40275
  try {
40086
- existing = fs78.readFileSync(exclude, "utf8");
40276
+ existing = fs81.readFileSync(exclude, "utf8");
40087
40277
  } catch {
40088
40278
  }
40089
40279
  if (existing.includes(".codeam/packs/")) return;
40090
- fs78.mkdirSync(path89.dirname(exclude), { recursive: true });
40091
- fs78.writeFileSync(exclude, `${existing.trimEnd()}
40280
+ fs81.mkdirSync(path91.dirname(exclude), { recursive: true });
40281
+ fs81.writeFileSync(exclude, `${existing.trimEnd()}
40092
40282
  .codeam/packs/
40093
40283
  `.trimStart());
40094
40284
  } catch {
@@ -41069,20 +41259,20 @@ async function mcpRouter() {
41069
41259
  }
41070
41260
 
41071
41261
  // src/integrations/mcp-secrets.ts
41072
- var fs80 = __toESM(require("fs"));
41073
- var os57 = __toESM(require("os"));
41074
- var path91 = __toESM(require("path"));
41262
+ var fs83 = __toESM(require("fs"));
41263
+ var os59 = __toESM(require("os"));
41264
+ var path93 = __toESM(require("path"));
41075
41265
  var MCP_SECRETS_FILE_ENV = "CODEAM_MCP_SECRETS_FILE";
41076
41266
  function mcpSecretsDir() {
41077
- return path91.join(os57.homedir(), ".codeam", "mcp-secrets");
41267
+ return path93.join(os59.homedir(), ".codeam", "mcp-secrets");
41078
41268
  }
41079
41269
  function mcpSecretsPath(scope, pid = process.pid) {
41080
- return path91.join(mcpSecretsDir(), `${pid}-${scope}.json`);
41270
+ return path93.join(mcpSecretsDir(), `${pid}-${scope}.json`);
41081
41271
  }
41082
41272
  var registeredForCleanup = /* @__PURE__ */ new Set();
41083
41273
  function readFileVars(file) {
41084
41274
  try {
41085
- const parsed = JSON.parse(fs80.readFileSync(file, "utf8"));
41275
+ const parsed = JSON.parse(fs83.readFileSync(file, "utf8"));
41086
41276
  if (!parsed || typeof parsed !== "object") return {};
41087
41277
  const out2 = {};
41088
41278
  for (const [k2, v] of Object.entries(parsed)) {
@@ -41104,7 +41294,7 @@ function pidAlive2(pid) {
41104
41294
  function pruneStale(dir) {
41105
41295
  let names = [];
41106
41296
  try {
41107
- names = fs80.readdirSync(dir);
41297
+ names = fs83.readdirSync(dir);
41108
41298
  } catch {
41109
41299
  return;
41110
41300
  }
@@ -41114,25 +41304,25 @@ function pruneStale(dir) {
41114
41304
  const pid = Number(m[1]);
41115
41305
  if (pid === process.pid || pidAlive2(pid)) continue;
41116
41306
  try {
41117
- fs80.unlinkSync(path91.join(dir, name));
41307
+ fs83.unlinkSync(path93.join(dir, name));
41118
41308
  } catch {
41119
41309
  }
41120
41310
  }
41121
41311
  }
41122
41312
  function writeMcpSecrets(vars, file) {
41123
41313
  try {
41124
- const dir = path91.dirname(file);
41125
- fs80.mkdirSync(dir, { recursive: true, mode: 448 });
41314
+ const dir = path93.dirname(file);
41315
+ fs83.mkdirSync(dir, { recursive: true, mode: 448 });
41126
41316
  pruneStale(dir);
41127
41317
  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);
41318
+ fs83.writeFileSync(tmp, JSON.stringify(vars), { mode: 384 });
41319
+ fs83.renameSync(tmp, file);
41320
+ fs83.chmodSync(file, 384);
41131
41321
  if (!registeredForCleanup.has(file)) {
41132
41322
  registeredForCleanup.add(file);
41133
41323
  process.once("exit", () => {
41134
41324
  try {
41135
- fs80.unlinkSync(file);
41325
+ fs83.unlinkSync(file);
41136
41326
  } catch {
41137
41327
  }
41138
41328
  });
@@ -41218,11 +41408,11 @@ function previewMcpServer(bridge) {
41218
41408
  };
41219
41409
  }
41220
41410
  function httpCall(baseUrl, token) {
41221
- return async (path112, method, body, timeoutMs) => {
41411
+ return async (path114, method, body, timeoutMs) => {
41222
41412
  const ac = new AbortController();
41223
41413
  const timer = setTimeout(() => ac.abort(), timeoutMs);
41224
41414
  try {
41225
- const res = await fetch(`${baseUrl}${path112}`, {
41415
+ const res = await fetch(`${baseUrl}${path114}`, {
41226
41416
  method,
41227
41417
  headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
41228
41418
  ...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
@@ -41350,11 +41540,11 @@ function scratchMcpServer(bridge) {
41350
41540
  };
41351
41541
  }
41352
41542
  function httpCall2(baseUrl, token) {
41353
- return async (path112, method, body, timeoutMs) => {
41543
+ return async (path114, method, body, timeoutMs) => {
41354
41544
  const ac = new AbortController();
41355
41545
  const timer = setTimeout(() => ac.abort(), timeoutMs);
41356
41546
  try {
41357
- const res = await fetch(`${baseUrl}${path112}`, {
41547
+ const res = await fetch(`${baseUrl}${path114}`, {
41358
41548
  method,
41359
41549
  headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
41360
41550
  ...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
@@ -43939,6 +44129,7 @@ async function runAcpSession(opts) {
43939
44129
  try {
43940
44130
  handshake = await client3.start();
43941
44131
  } catch (startErr) {
44132
+ opts.onHandshakeSettled?.();
43942
44133
  const detail = describeError(startErr);
43943
44134
  log.warn("acpRunner", `ACP start failed for ${opts.agent}: ${detail}`);
43944
44135
  await surfaceStartupFailure({
@@ -43953,6 +44144,7 @@ async function runAcpSession(opts) {
43953
44144
  });
43954
44145
  return;
43955
44146
  }
44147
+ opts.onHandshakeSettled?.();
43956
44148
  let acpSessionId = handshake.sessionId;
43957
44149
  const { initialize, model: handshakeModel, tier: handshakeTier } = handshake;
43958
44150
  let agentCaps = initialize.agentCapabilities;
@@ -44257,17 +44449,17 @@ async function runAcpSession(opts) {
44257
44449
  switchCredentialEnv = provisionAgentCredentials(agentId, auth);
44258
44450
  },
44259
44451
  provisionHouseProxy: ({ baseUrl, token, model, managedAgentId }) => {
44260
- const claudeConfigDir2 = path94.join(
44261
- os59.homedir(),
44452
+ const claudeConfigDir2 = path96.join(
44453
+ os61.homedir(),
44262
44454
  ".codeam",
44263
44455
  "house-claude",
44264
44456
  `switch-${opts.pluginId}`
44265
44457
  );
44266
44458
  try {
44267
- fs83.mkdirSync(claudeConfigDir2, { recursive: true, mode: 448 });
44459
+ fs86.mkdirSync(claudeConfigDir2, { recursive: true, mode: 448 });
44268
44460
  } catch {
44269
44461
  }
44270
- const memoryFile = path94.join(claudeConfigDir2, "CLAUDE.md");
44462
+ const memoryFile = path96.join(claudeConfigDir2, "CLAUDE.md");
44271
44463
  ensureBeadsWorkflowHint(void 0, memoryFile);
44272
44464
  ensureAgentStandard(void 0, memoryFile);
44273
44465
  if (isScratchWorkspace(process.cwd())) ensureScratchWorkflowHint(void 0, memoryFile);
@@ -45498,9 +45690,9 @@ function pickPinnedSession(pinnedId, listSessions2) {
45498
45690
  }
45499
45691
 
45500
45692
  // src/agents/retired-proxy-cleanup.ts
45501
- var fs84 = __toESM(require("fs"));
45502
- var path95 = __toESM(require("path"));
45503
- var os60 = __toESM(require("os"));
45693
+ var fs87 = __toESM(require("fs"));
45694
+ var path97 = __toESM(require("path"));
45695
+ var os62 = __toESM(require("os"));
45504
45696
  var RETIRED_PROXY_RE = /^https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):8787(?:[/?#]|$)/i;
45505
45697
  var HEADROOM_CMD_RE = /(^|[\s/"'])headroom(\s|$)/i;
45506
45698
  var MARKETPLACE_KEY = "headroom-marketplace";
@@ -45509,12 +45701,12 @@ function isHeadroomHook(group) {
45509
45701
  (h) => typeof h?.command === "string" && HEADROOM_CMD_RE.test(h.command)
45510
45702
  );
45511
45703
  }
45512
- function sanitizeRetiredProxyConfig(homeDir2 = os60.homedir()) {
45704
+ function sanitizeRetiredProxyConfig(homeDir2 = os62.homedir()) {
45513
45705
  const out2 = { inspected: false, changed: false, removed: [] };
45514
- const file = path95.join(homeDir2, ".claude", "settings.json");
45706
+ const file = path97.join(homeDir2, ".claude", "settings.json");
45515
45707
  let parsed;
45516
45708
  try {
45517
- parsed = JSON.parse(fs84.readFileSync(file, "utf8"));
45709
+ parsed = JSON.parse(fs87.readFileSync(file, "utf8"));
45518
45710
  } catch {
45519
45711
  return out2;
45520
45712
  }
@@ -45556,9 +45748,9 @@ function sanitizeRetiredProxyConfig(homeDir2 = os60.homedir()) {
45556
45748
  if (!out2.changed) return out2;
45557
45749
  try {
45558
45750
  const tmp = `${file}.codeam.tmp`;
45559
- fs84.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
45751
+ fs87.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
45560
45752
  `, { mode: 384 });
45561
- fs84.renameSync(tmp, file);
45753
+ fs87.renameSync(tmp, file);
45562
45754
  } catch {
45563
45755
  out2.changed = false;
45564
45756
  }
@@ -46090,7 +46282,7 @@ var AcpDriver = class {
46090
46282
  };
46091
46283
 
46092
46284
  // src/baton/transcript-mirror.ts
46093
- var fs85 = __toESM(require("fs"));
46285
+ var fs88 = __toESM(require("fs"));
46094
46286
  var TranscriptMirror = class {
46095
46287
  constructor(deps) {
46096
46288
  this.deps = deps;
@@ -46184,7 +46376,7 @@ var TranscriptMirror = class {
46184
46376
  }
46185
46377
  };
46186
46378
  function defaultWatch(file, onChange) {
46187
- const w3 = fs85.watch(file, { persistent: false }, () => onChange());
46379
+ const w3 = fs88.watch(file, { persistent: false }, () => onChange());
46188
46380
  return () => w3.close();
46189
46381
  }
46190
46382
 
@@ -46530,16 +46722,16 @@ function keepDeviceAwake(deps = {}) {
46530
46722
  }
46531
46723
 
46532
46724
  // src/agents/claude/onboarding.ts
46533
- var fs86 = __toESM(require("fs"));
46534
- var os62 = __toESM(require("os"));
46535
- var path96 = __toESM(require("path"));
46725
+ var fs89 = __toESM(require("fs"));
46726
+ var os64 = __toESM(require("os"));
46727
+ var path98 = __toESM(require("path"));
46536
46728
  var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
46537
46729
  function ensureClaudeOnboarded(cwd) {
46538
46730
  try {
46539
- const file = path96.join(os62.homedir(), ".claude.json");
46731
+ const file = path98.join(os64.homedir(), ".claude.json");
46540
46732
  let config = {};
46541
46733
  try {
46542
- config = JSON.parse(fs86.readFileSync(file, "utf8"));
46734
+ config = JSON.parse(fs89.readFileSync(file, "utf8"));
46543
46735
  } catch {
46544
46736
  }
46545
46737
  let changed = false;
@@ -46564,8 +46756,8 @@ function ensureClaudeOnboarded(cwd) {
46564
46756
  }
46565
46757
  }
46566
46758
  if (!changed) return;
46567
- fs86.mkdirSync(path96.dirname(file), { recursive: true });
46568
- fs86.writeFileSync(file, JSON.stringify(config, null, 2));
46759
+ fs89.mkdirSync(path98.dirname(file), { recursive: true });
46760
+ fs89.writeFileSync(file, JSON.stringify(config, null, 2));
46569
46761
  log.info(
46570
46762
  "claude",
46571
46763
  `pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
@@ -46576,6 +46768,7 @@ function ensureClaudeOnboarded(cwd) {
46576
46768
  }
46577
46769
 
46578
46770
  // src/commands/start.ts
46771
+ var BEADS_AFTER_HANDSHAKE_CAP_MS = 6e4;
46579
46772
  async function start(requestedAgent, presetSession) {
46580
46773
  installRelayCrashGuards();
46581
46774
  showIntro();
@@ -46614,6 +46807,10 @@ async function start(requestedAgent, presetSession) {
46614
46807
  if (!session.agent) {
46615
46808
  throw new Error("Active session has no agent \u2014 re-pair with `codeam pair`.");
46616
46809
  }
46810
+ if (!isLocalSession() && session.agent === "claude") {
46811
+ const claudeBinary = resolveClaudeNativeBinary();
46812
+ if (claudeBinary) prefetchIntoPageCache(claudeBinary);
46813
+ }
46617
46814
  const pluginId = session.pluginId ?? ensurePluginId();
46618
46815
  showInfo(`${session.userName} \xB7 ${import_picocolors3.default.cyan(session.plan)}`);
46619
46816
  showInfo(`Launching ${AGENT_REGISTRY[session.agent].displayName}...
@@ -46670,6 +46867,22 @@ async function start(requestedAgent, presetSession) {
46670
46867
  }
46671
46868
  }
46672
46869
  purgeExports();
46870
+ const releaseStartupMark = markAgentStarting();
46871
+ process.once("exit", releaseStartupMark);
46872
+ let settleOwnHandshake = () => void 0;
46873
+ const ownHandshakeSettled = new Promise((resolve14) => {
46874
+ settleOwnHandshake = resolve14;
46875
+ });
46876
+ const releaseBeads = () => {
46877
+ releaseStartupMark();
46878
+ settleOwnHandshake();
46879
+ };
46880
+ const agentHandshakeSettled = Promise.race([
46881
+ ownHandshakeSettled.then(
46882
+ () => waitForNoAgentStarting({ timeoutMs: BEADS_AFTER_HANDSHAKE_CAP_MS })
46883
+ ),
46884
+ new Promise((resolve14) => setTimeout(resolve14, BEADS_AFTER_HANDSHAKE_CAP_MS).unref())
46885
+ ]);
46673
46886
  const beadsReady = provisionBeadsForStart({
46674
46887
  sessionId: session.id,
46675
46888
  pluginId,
@@ -46677,7 +46890,8 @@ async function start(requestedAgent, presetSession) {
46677
46890
  cwd,
46678
46891
  // Wire this session's agent natively via `bd setup <recipe> --global` so
46679
46892
  // the agent actually uses bd (D12 — REVISED). Covers BOTH ACP and PTY.
46680
- agents: [session.agent]
46893
+ agents: [session.agent],
46894
+ deferUntil: agentHandshakeSettled
46681
46895
  }).then((started) => {
46682
46896
  beads = started;
46683
46897
  return started;
@@ -46746,12 +46960,13 @@ async function start(requestedAgent, presetSession) {
46746
46960
  if (gateTimer) clearTimeout(gateTimer);
46747
46961
  log.info(
46748
46962
  "beads",
46749
- `agent-spawn gate released (beads ungated, ${beads ? "already ready" : "still provisioning in background"}); project deps provisioned`
46963
+ "agent-spawn gate released (beads waits for the agent handshake); project deps provisioned"
46750
46964
  );
46751
46965
  }
46752
46966
  const releaseKeepAwake = keepDeviceAwake();
46753
46967
  process.once("exit", releaseKeepAwake);
46754
46968
  if (isLocalSession() && requiresAcp(session.agent)) {
46969
+ releaseBeads();
46755
46970
  const adapter = await resolveAcpAdapterWithRetry(session.agent);
46756
46971
  const batonCapable = runtimeSupportsBaton(createRuntimeStrategy(session.agent));
46757
46972
  if (batonCapable && adapter && session.pluginAuthToken) {
@@ -46815,6 +47030,7 @@ async function start(requestedAgent, presetSession) {
46815
47030
  adapter,
46816
47031
  cwd,
46817
47032
  getBeads,
47033
+ onHandshakeSettled: releaseBeads,
46818
47034
  pollSecret: session.pollSecret,
46819
47035
  mcpServers,
46820
47036
  // AUTO mode for headless, mobile-driven sessions: no human at the box
@@ -46830,6 +47046,7 @@ async function start(requestedAgent, presetSession) {
46830
47046
  if (requiresAcp(session.agent)) {
46831
47047
  log.error("acp", `[anomaly] acp-required agent on PTY runtime (agent=${session.agent})`);
46832
47048
  }
47049
+ releaseBeads();
46833
47050
  const runtime = createRuntimeStrategy(session.agent);
46834
47051
  const historySvc = new HistoryService(runtime, pluginId, cwd, {
46835
47052
  pluginAuthToken: session.pluginAuthToken
@@ -47357,7 +47574,7 @@ var import_picocolors10 = __toESM(require("picocolors"));
47357
47574
  var import_child_process30 = require("child_process");
47358
47575
  var import_util4 = require("util");
47359
47576
  var import_picocolors8 = __toESM(require("picocolors"));
47360
- var path97 = __toESM(require("path"));
47577
+ var path99 = __toESM(require("path"));
47361
47578
  var execFileP6 = (0, import_util4.promisify)(import_child_process30.execFile);
47362
47579
  var MAX_BUFFER = 8 * 1024 * 1024;
47363
47580
  function resetStdinForChild() {
@@ -47846,7 +48063,7 @@ var GitHubCodespacesProvider = class {
47846
48063
  });
47847
48064
  }
47848
48065
  async uploadFile(workspaceId, remotePath, contents, options = {}) {
47849
- const remoteDir = path97.posix.dirname(remotePath);
48066
+ const remoteDir = path99.posix.dirname(remotePath);
47850
48067
  const parts = [
47851
48068
  `mkdir -p ${shellQuote(remoteDir)}`,
47852
48069
  `cat > ${shellQuote(remotePath)}`
@@ -47916,7 +48133,7 @@ function shellQuote(s) {
47916
48133
  // src/services/providers/gitpod.ts
47917
48134
  var import_child_process31 = require("child_process");
47918
48135
  var import_util5 = require("util");
47919
- var path98 = __toESM(require("path"));
48136
+ var path100 = __toESM(require("path"));
47920
48137
  var import_picocolors9 = __toESM(require("picocolors"));
47921
48138
  var execFileP7 = (0, import_util5.promisify)(import_child_process31.execFile);
47922
48139
  var MAX_BUFFER2 = 8 * 1024 * 1024;
@@ -48156,7 +48373,7 @@ var GitpodProvider = class {
48156
48373
  });
48157
48374
  }
48158
48375
  async uploadFile(workspaceId, remotePath, contents, options = {}) {
48159
- const remoteDir = path98.posix.dirname(remotePath);
48376
+ const remoteDir = path100.posix.dirname(remotePath);
48160
48377
  const parts = [
48161
48378
  `mkdir -p ${shellQuote2(remoteDir)}`,
48162
48379
  `cat > ${shellQuote2(remotePath)}`
@@ -48192,7 +48409,7 @@ function shellQuote2(s) {
48192
48409
  // src/services/providers/gitlab-workspaces.ts
48193
48410
  var import_child_process32 = require("child_process");
48194
48411
  var import_util6 = require("util");
48195
- var path99 = __toESM(require("path"));
48412
+ var path101 = __toESM(require("path"));
48196
48413
  var execFileP8 = (0, import_util6.promisify)(import_child_process32.execFile);
48197
48414
  var MAX_BUFFER3 = 8 * 1024 * 1024;
48198
48415
  var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
@@ -48452,7 +48669,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
48452
48669
  }
48453
48670
  async uploadFile(workspaceId, remotePath, contents, options = {}) {
48454
48671
  const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
48455
- const remoteDir = path99.posix.dirname(remotePath);
48672
+ const remoteDir = path101.posix.dirname(remotePath);
48456
48673
  const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
48457
48674
  if (options.mode != null) {
48458
48675
  parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
@@ -48520,7 +48737,7 @@ function shellQuote3(s) {
48520
48737
  // src/services/providers/railway.ts
48521
48738
  var import_child_process33 = require("child_process");
48522
48739
  var import_util7 = require("util");
48523
- var path100 = __toESM(require("path"));
48740
+ var path102 = __toESM(require("path"));
48524
48741
  var execFileP9 = (0, import_util7.promisify)(import_child_process33.execFile);
48525
48742
  var MAX_BUFFER4 = 8 * 1024 * 1024;
48526
48743
  function resetStdinForChild4() {
@@ -48756,7 +48973,7 @@ var RailwayProvider = class {
48756
48973
  if (!projectId || !serviceId) {
48757
48974
  throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
48758
48975
  }
48759
- const remoteDir = path100.posix.dirname(remotePath);
48976
+ const remoteDir = path102.posix.dirname(remotePath);
48760
48977
  const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
48761
48978
  if (options.mode != null) {
48762
48979
  parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
@@ -49296,14 +49513,14 @@ async function stopWorkspaceFromLocal(target) {
49296
49513
  }
49297
49514
 
49298
49515
  // src/commands/host/host-client.ts
49299
- var fs87 = __toESM(require("fs"));
49300
- var os63 = __toESM(require("os"));
49301
- var path101 = __toESM(require("path"));
49516
+ var fs90 = __toESM(require("fs"));
49517
+ var os65 = __toESM(require("os"));
49518
+ var path103 = __toESM(require("path"));
49302
49519
  var import_node_crypto16 = require("crypto");
49303
49520
  function sampleCpuTimes() {
49304
49521
  let idle = 0;
49305
49522
  let total = 0;
49306
- for (const cpu of os63.cpus()) {
49523
+ for (const cpu of os65.cpus()) {
49307
49524
  const t2 = cpu.times;
49308
49525
  idle += t2.idle;
49309
49526
  total += t2.user + t2.nice + t2.sys + t2.idle + t2.irq;
@@ -49323,8 +49540,8 @@ var MetricsCollector = class {
49323
49540
  const prev = this.prevCpu;
49324
49541
  this.prevCpu = current2;
49325
49542
  if (!prev) {
49326
- const cores = os63.cpus().length || 1;
49327
- const proxy = os63.loadavg()[0] / cores * 100;
49543
+ const cores = os65.cpus().length || 1;
49544
+ const proxy = os65.loadavg()[0] / cores * 100;
49328
49545
  return Math.min(100, Math.max(0, Math.round(proxy)));
49329
49546
  }
49330
49547
  const idleDelta = current2.idle - prev.idle;
@@ -49337,8 +49554,8 @@ var MetricsCollector = class {
49337
49554
  collect() {
49338
49555
  return {
49339
49556
  cpuPct: this.cpuPct(),
49340
- ramUsedMb: Math.round((os63.totalmem() - os63.freemem()) / 1048576),
49341
- ramTotalMb: Math.round(os63.totalmem() / 1048576),
49557
+ ramUsedMb: Math.round((os65.totalmem() - os65.freemem()) / 1048576),
49558
+ ramTotalMb: Math.round(os65.totalmem() / 1048576),
49342
49559
  latencyMs: this.lastLatencyMs
49343
49560
  };
49344
49561
  }
@@ -49347,19 +49564,19 @@ function apiBase() {
49347
49564
  return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
49348
49565
  }
49349
49566
  function hostIdentityPath() {
49350
- return path101.join(os63.homedir(), ".codeam", "host-agent.json");
49567
+ return path103.join(os65.homedir(), ".codeam", "host-agent.json");
49351
49568
  }
49352
49569
  function collectOsInfo() {
49353
49570
  return {
49354
- distro: os63.platform(),
49355
- arch: os63.arch(),
49356
- kernel: os63.release(),
49571
+ distro: os65.platform(),
49572
+ arch: os65.arch(),
49573
+ kernel: os65.release(),
49357
49574
  nodeVersion: process.versions.node
49358
49575
  };
49359
49576
  }
49360
49577
  function loadHostIdentity() {
49361
49578
  try {
49362
- const raw = fs87.readFileSync(hostIdentityPath(), "utf8");
49579
+ const raw = fs90.readFileSync(hostIdentityPath(), "utf8");
49363
49580
  const parsed = JSON.parse(raw);
49364
49581
  if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
49365
49582
  const p2 = parsed;
@@ -49387,8 +49604,8 @@ function ensureControlPollSecret(identity, save = saveHostIdentity) {
49387
49604
  }
49388
49605
  function saveHostIdentity(identity) {
49389
49606
  const file = hostIdentityPath();
49390
- fs87.mkdirSync(path101.dirname(file), { recursive: true, mode: 448 });
49391
- fs87.writeFileSync(file, JSON.stringify(identity, null, 2), {
49607
+ fs90.mkdirSync(path103.dirname(file), { recursive: true, mode: 448 });
49608
+ fs90.writeFileSync(file, JSON.stringify(identity, null, 2), {
49392
49609
  encoding: "utf8",
49393
49610
  mode: 384
49394
49611
  });
@@ -49433,7 +49650,7 @@ function isTerminalEnrollError(err) {
49433
49650
  }
49434
49651
  function deleteHostIdentity() {
49435
49652
  try {
49436
- fs87.rmSync(hostIdentityPath(), { force: true });
49653
+ fs90.rmSync(hostIdentityPath(), { force: true });
49437
49654
  } catch {
49438
49655
  }
49439
49656
  }
@@ -49457,7 +49674,7 @@ async function postJson(pathname, body) {
49457
49674
  function resolveHostLabel(label) {
49458
49675
  const explicit = label?.trim();
49459
49676
  const envLabel = process.env.CODEAM_HOST_LABEL?.trim();
49460
- const resolved = explicit || envLabel || os63.hostname();
49677
+ const resolved = explicit || envLabel || os65.hostname();
49461
49678
  return resolved.slice(0, 80);
49462
49679
  }
49463
49680
  async function redeemEnrollToken(token, label) {
@@ -49650,9 +49867,9 @@ async function host(args2) {
49650
49867
 
49651
49868
  // src/commands/host-agent.ts
49652
49869
  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"));
49870
+ var os71 = __toESM(require("os"));
49871
+ var fs97 = __toESM(require("fs"));
49872
+ var path110 = __toESM(require("path"));
49656
49873
 
49657
49874
  // src/skills/persist-from-payload.ts
49658
49875
  function persistOrClearSkillsFromPayload(skills) {
@@ -49661,13 +49878,13 @@ function persistOrClearSkillsFromPayload(skills) {
49661
49878
  }
49662
49879
 
49663
49880
  // src/commands/host/session-state.ts
49664
- var fs88 = __toESM(require("fs"));
49665
- var os64 = __toESM(require("os"));
49666
- var path102 = __toESM(require("path"));
49881
+ var fs91 = __toESM(require("fs"));
49882
+ var os66 = __toESM(require("os"));
49883
+ var path104 = __toESM(require("path"));
49667
49884
  function hostSessionStatePath(env = process.env) {
49668
49885
  const override = env.CODEAM_HOST_SESSION_STATE_FILE;
49669
49886
  if (override && override.trim()) return override.trim();
49670
- return path102.join(os64.homedir(), ".codeam", "host-agent-sessions.json");
49887
+ return path104.join(os66.homedir(), ".codeam", "host-agent-sessions.json");
49671
49888
  }
49672
49889
  function isRecord5(v) {
49673
49890
  if (typeof v !== "object" || v === null) return false;
@@ -49678,7 +49895,7 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
49678
49895
  return {
49679
49896
  load() {
49680
49897
  try {
49681
- const raw = JSON.parse(fs88.readFileSync(file, "utf8"));
49898
+ const raw = JSON.parse(fs91.readFileSync(file, "utf8"));
49682
49899
  return Array.isArray(raw?.sessions) ? raw.sessions.filter(isRecord5) : null;
49683
49900
  } catch {
49684
49901
  return null;
@@ -49686,18 +49903,18 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
49686
49903
  },
49687
49904
  save(list) {
49688
49905
  try {
49689
- fs88.mkdirSync(path102.dirname(file), { recursive: true, mode: 448 });
49906
+ fs91.mkdirSync(path104.dirname(file), { recursive: true, mode: 448 });
49690
49907
  const tmp = `${file}.${process.pid}.tmp`;
49691
- fs88.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
49908
+ fs91.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
49692
49909
  mode: 384
49693
49910
  });
49694
- fs88.renameSync(tmp, file);
49911
+ fs91.renameSync(tmp, file);
49695
49912
  } catch {
49696
49913
  }
49697
49914
  },
49698
49915
  clear() {
49699
49916
  try {
49700
- fs88.rmSync(file, { force: true });
49917
+ fs91.rmSync(file, { force: true });
49701
49918
  } catch {
49702
49919
  }
49703
49920
  }
@@ -49720,10 +49937,10 @@ function planSessionResume(records, max) {
49720
49937
  return { resume: ordered.slice(0, bound), dropped: ordered.slice(bound) };
49721
49938
  }
49722
49939
  function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
49723
- const target = path102.resolve(cwd);
49940
+ const target = path104.resolve(cwd);
49724
49941
  const reconnectable = (s) => !!s.pluginId && !!s.pollSecret && !!s.agent;
49725
49942
  const matches = sessions3.filter(
49726
- (s) => !!s.cwd && path102.resolve(s.cwd) === target && reconnectable(s)
49943
+ (s) => !!s.cwd && path104.resolve(s.cwd) === target && reconnectable(s)
49727
49944
  );
49728
49945
  if (matches.length > 0) {
49729
49946
  matches.sort((a, b) => b.pairedAt - a.pairedAt);
@@ -49735,11 +49952,11 @@ function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
49735
49952
 
49736
49953
  // src/commands/host/git-tooling.ts
49737
49954
  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"));
49955
+ var fs92 = __toESM(require("fs"));
49956
+ var os67 = __toESM(require("os"));
49957
+ var path105 = __toESM(require("path"));
49741
49958
  function codeamBinDir() {
49742
- return process.env.CODEAM_BIN_DIR ?? path103.join(os65.homedir(), ".codeam", "bin");
49959
+ return process.env.CODEAM_BIN_DIR ?? path105.join(os67.homedir(), ".codeam", "bin");
49743
49960
  }
49744
49961
  var FALLBACK_GH_VERSION = "2.62.0";
49745
49962
  var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
@@ -49771,7 +49988,7 @@ async function download(url2, dest) {
49771
49988
  const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
49772
49989
  if (!res.ok || !res.body) return false;
49773
49990
  const buf = Buffer.from(await res.arrayBuffer());
49774
- fs89.writeFileSync(dest, buf);
49991
+ fs92.writeFileSync(dest, buf);
49775
49992
  return true;
49776
49993
  } catch {
49777
49994
  return false;
@@ -49794,8 +50011,8 @@ async function ensureGhCli(runner, token, deps = {}) {
49794
50011
  const version3 = await resolveVersionFn(token);
49795
50012
  const asset = `gh_${version3}_${osToken}_${arch2}`;
49796
50013
  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}`);
50014
+ const tmpRoot = fs92.mkdtempSync(path105.join(os67.tmpdir(), "codeam-gh-"));
50015
+ const archive = path105.join(tmpRoot, `${asset}.${ext}`);
49799
50016
  if (!await downloadFn(url2, archive)) {
49800
50017
  log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
49801
50018
  return null;
@@ -49805,16 +50022,16 @@ async function ensureGhCli(runner, token, deps = {}) {
49805
50022
  log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
49806
50023
  return null;
49807
50024
  }
49808
- const extractedBin = path103.join(tmpRoot, asset, "bin", binaryName);
49809
- if (!fs89.existsSync(extractedBin)) {
50025
+ const extractedBin = path105.join(tmpRoot, asset, "bin", binaryName);
50026
+ if (!fs92.existsSync(extractedBin)) {
49810
50027
  log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
49811
50028
  return null;
49812
50029
  }
49813
50030
  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);
50031
+ fs92.mkdirSync(binDir, { recursive: true });
50032
+ const target = path105.join(binDir, binaryName);
50033
+ fs92.copyFileSync(extractedBin, target);
50034
+ fs92.chmodSync(target, 493);
49818
50035
  log.info("host-agent", `gh installed to ${target} (v${version3})`);
49819
50036
  return target;
49820
50037
  } catch (e) {
@@ -49851,19 +50068,19 @@ async function ensureGhAuth(runner, ghCmd, token) {
49851
50068
  }
49852
50069
  function ghConfigDir() {
49853
50070
  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");
50071
+ if (process.env.XDG_CONFIG_HOME) return path105.join(process.env.XDG_CONFIG_HOME, "gh");
49855
50072
  if (process.platform === "win32" && process.env.APPDATA) {
49856
- return path103.join(process.env.APPDATA, "GitHub CLI");
50073
+ return path105.join(process.env.APPDATA, "GitHub CLI");
49857
50074
  }
49858
- return path103.join(os65.homedir(), ".config", "gh");
50075
+ return path105.join(os67.homedir(), ".config", "gh");
49859
50076
  }
49860
50077
  function writeGhHostsToken(token) {
49861
50078
  try {
49862
50079
  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(
50080
+ const file = path105.join(dir, "hosts.yml");
50081
+ if (fs92.existsSync(file)) return false;
50082
+ fs92.mkdirSync(dir, { recursive: true, mode: 448 });
50083
+ fs92.writeFileSync(
49867
50084
  file,
49868
50085
  `github.com:
49869
50086
  oauth_token: ${token}
@@ -49906,8 +50123,8 @@ async function ensureGlabCli(runner, deps = {}) {
49906
50123
  const version3 = await resolveLatestGlabVersion();
49907
50124
  const asset = `glab_${version3}_${osToken}_${arch2}`;
49908
50125
  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}`);
50126
+ const tmpRoot = fs92.mkdtempSync(path105.join(os67.tmpdir(), "codeam-glab-"));
50127
+ const archive = path105.join(tmpRoot, `${asset}.${ext}`);
49911
50128
  if (!await downloadFn(url2, archive)) {
49912
50129
  log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
49913
50130
  return null;
@@ -49918,20 +50135,20 @@ async function ensureGlabCli(runner, deps = {}) {
49918
50135
  return null;
49919
50136
  }
49920
50137
  const candidates = [
49921
- path103.join(tmpRoot, "bin", binaryName),
49922
- path103.join(tmpRoot, asset, "bin", binaryName),
49923
- path103.join(tmpRoot, binaryName)
50138
+ path105.join(tmpRoot, "bin", binaryName),
50139
+ path105.join(tmpRoot, asset, "bin", binaryName),
50140
+ path105.join(tmpRoot, binaryName)
49924
50141
  ];
49925
- const extractedBin = candidates.find((c2) => fs89.existsSync(c2));
50142
+ const extractedBin = candidates.find((c2) => fs92.existsSync(c2));
49926
50143
  if (!extractedBin) {
49927
50144
  log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
49928
50145
  return null;
49929
50146
  }
49930
50147
  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);
50148
+ fs92.mkdirSync(binDir, { recursive: true });
50149
+ const target = path105.join(binDir, binaryName);
50150
+ fs92.copyFileSync(extractedBin, target);
50151
+ fs92.chmodSync(target, 493);
49935
50152
  log.info("host-agent", `glab installed to ${target} (v${version3})`);
49936
50153
  return target;
49937
50154
  } catch (e) {
@@ -50010,14 +50227,14 @@ var defaultGitToolingRunner = {
50010
50227
  };
50011
50228
 
50012
50229
  // src/lib/cli-versions.ts
50013
- var fs91 = __toESM(require("fs"));
50014
- var os67 = __toESM(require("os"));
50015
- var path105 = __toESM(require("path"));
50230
+ var fs94 = __toESM(require("fs"));
50231
+ var os69 = __toESM(require("os"));
50232
+ var path107 = __toESM(require("path"));
50016
50233
 
50017
50234
  // src/lib/updateNotifier.ts
50018
- var fs90 = __toESM(require("fs"));
50019
- var os66 = __toESM(require("os"));
50020
- var path104 = __toESM(require("path"));
50235
+ var fs93 = __toESM(require("fs"));
50236
+ var os68 = __toESM(require("os"));
50237
+ var path106 = __toESM(require("path"));
50021
50238
  var https8 = __toESM(require("https"));
50022
50239
  var import_node_child_process32 = require("child_process");
50023
50240
  var import_picocolors12 = __toESM(require("picocolors"));
@@ -50026,12 +50243,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
50026
50243
  var TTL_MS = 24 * 60 * 60 * 1e3;
50027
50244
  var REQUEST_TIMEOUT_MS = 1500;
50028
50245
  function cachePath() {
50029
- const dir = path104.join(os66.homedir(), ".codeam");
50030
- return path104.join(dir, "update-check.json");
50246
+ const dir = path106.join(os68.homedir(), ".codeam");
50247
+ return path106.join(dir, "update-check.json");
50031
50248
  }
50032
50249
  function readCache() {
50033
50250
  try {
50034
- const raw = fs90.readFileSync(cachePath(), "utf8");
50251
+ const raw = fs93.readFileSync(cachePath(), "utf8");
50035
50252
  const parsed = JSON.parse(raw);
50036
50253
  if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
50037
50254
  return parsed;
@@ -50042,10 +50259,10 @@ function readCache() {
50042
50259
  function writeCache(cache) {
50043
50260
  try {
50044
50261
  const file = cachePath();
50045
- fs90.mkdirSync(path104.dirname(file), { recursive: true });
50262
+ fs93.mkdirSync(path106.dirname(file), { recursive: true });
50046
50263
  const tmp = `${file}.${process.pid}.tmp`;
50047
- fs90.writeFileSync(tmp, JSON.stringify(cache));
50048
- fs90.renameSync(tmp, file);
50264
+ fs93.writeFileSync(tmp, JSON.stringify(cache));
50265
+ fs93.renameSync(tmp, file);
50049
50266
  } catch {
50050
50267
  }
50051
50268
  }
@@ -50119,8 +50336,8 @@ function isLinkedInstall() {
50119
50336
  timeout: 2e3
50120
50337
  }).trim();
50121
50338
  if (!root) return false;
50122
- const pkgPath = path104.join(root, PKG_NAME);
50123
- return fs90.lstatSync(pkgPath).isSymbolicLink();
50339
+ const pkgPath = path106.join(root, PKG_NAME);
50340
+ return fs93.lstatSync(pkgPath).isSymbolicLink();
50124
50341
  } catch {
50125
50342
  return false;
50126
50343
  }
@@ -50156,7 +50373,7 @@ function maybeAutoUpdate(currentVersion, latest) {
50156
50373
  return;
50157
50374
  }
50158
50375
  try {
50159
- fs90.unlinkSync(cachePath());
50376
+ fs93.unlinkSync(cachePath());
50160
50377
  } catch {
50161
50378
  }
50162
50379
  process.stderr.write(` ${import_picocolors12.default.green("\u2713")} Updated. Resuming session...
@@ -50172,7 +50389,7 @@ async function autoUpgradeBeforeCriticalCommand() {
50172
50389
  if (process.env.NODE_ENV === "test") return;
50173
50390
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
50174
50391
  if (process.env.CI) return;
50175
- const current2 = true ? "2.76.12" : null;
50392
+ const current2 = true ? "2.76.14" : null;
50176
50393
  if (!current2) return;
50177
50394
  const cache = readCache();
50178
50395
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -50189,7 +50406,7 @@ function checkForUpdates() {
50189
50406
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
50190
50407
  if (process.env.CI) return;
50191
50408
  if (!process.stdout.isTTY) return;
50192
- const current2 = true ? "2.76.12" : null;
50409
+ const current2 = true ? "2.76.14" : null;
50193
50410
  if (!current2) return;
50194
50411
  const cache = readCache();
50195
50412
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -50212,10 +50429,10 @@ function versionedModeSupported(platform3 = process.platform) {
50212
50429
  return platform3 !== "win32";
50213
50430
  }
50214
50431
  function cliVersionsRoot(env = process.env) {
50215
- return env.CODEAM_CLI_VERSIONS_DIR || path105.join(os67.homedir(), ".codeam", "cli");
50432
+ return env.CODEAM_CLI_VERSIONS_DIR || path107.join(os69.homedir(), ".codeam", "cli");
50216
50433
  }
50217
50434
  function packageDirOf(versionDir) {
50218
- return path105.join(versionDir, "node_modules", CLI_PKG);
50435
+ return path107.join(versionDir, "node_modules", CLI_PKG);
50219
50436
  }
50220
50437
  function isRecord6(v) {
50221
50438
  return typeof v === "object" && v !== null;
@@ -50223,7 +50440,7 @@ function isRecord6(v) {
50223
50440
  function readPkg2(versionDir) {
50224
50441
  try {
50225
50442
  const raw = JSON.parse(
50226
- fs91.readFileSync(path105.join(packageDirOf(versionDir), "package.json"), "utf8")
50443
+ fs94.readFileSync(path107.join(packageDirOf(versionDir), "package.json"), "utf8")
50227
50444
  );
50228
50445
  return isRecord6(raw) ? raw : null;
50229
50446
  } catch {
@@ -50236,15 +50453,15 @@ function entryOf(versionDir) {
50236
50453
  const bin = pkg.bin;
50237
50454
  const named = isRecord6(bin) ? bin.codeam : void 0;
50238
50455
  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;
50456
+ const entry = path107.join(packageDirOf(versionDir), rel);
50457
+ return fs94.existsSync(entry) ? entry : null;
50241
50458
  }
50242
50459
  function launcherOf(versionDir) {
50243
50460
  const entry = entryOf(versionDir);
50244
50461
  if (!entry) return null;
50245
- const bin = path105.join(versionDir, "node_modules", ".bin", "codeam");
50462
+ const bin = path107.join(versionDir, "node_modules", ".bin", "codeam");
50246
50463
  try {
50247
- return fs91.realpathSync(bin) === fs91.realpathSync(entry) ? bin : entry;
50464
+ return fs94.realpathSync(bin) === fs94.realpathSync(entry) ? bin : entry;
50248
50465
  } catch {
50249
50466
  return entry;
50250
50467
  }
@@ -50257,16 +50474,16 @@ var BAD_MARKER_TTL_MS = 24 * 60 * 6e4;
50257
50474
  var PRE_READY_WINDOW_MS = 60 * 6e4;
50258
50475
  function isBad(versionDir, now = Date.now()) {
50259
50476
  try {
50260
- return now - fs91.statSync(path105.join(versionDir, ".bad")).mtimeMs < BAD_MARKER_TTL_MS;
50477
+ return now - fs94.statSync(path107.join(versionDir, ".bad")).mtimeMs < BAD_MARKER_TTL_MS;
50261
50478
  } catch {
50262
50479
  return false;
50263
50480
  }
50264
50481
  }
50265
50482
  function recordPreReadyFailure(versionDir, now = Date.now()) {
50266
- const file = path105.join(versionDir, ".prefail");
50483
+ const file = path107.join(versionDir, ".prefail");
50267
50484
  let count = 0;
50268
50485
  try {
50269
- const [n, at3] = fs91.readFileSync(file, "utf8").trim().split(" ").map(Number);
50486
+ const [n, at3] = fs94.readFileSync(file, "utf8").trim().split(" ").map(Number);
50270
50487
  if (Number.isFinite(n) && Number.isFinite(at3) && now - at3 < PRE_READY_WINDOW_MS) {
50271
50488
  count = n;
50272
50489
  }
@@ -50274,41 +50491,41 @@ function recordPreReadyFailure(versionDir, now = Date.now()) {
50274
50491
  }
50275
50492
  count += 1;
50276
50493
  try {
50277
- fs91.writeFileSync(file, `${count} ${now}`);
50494
+ fs94.writeFileSync(file, `${count} ${now}`);
50278
50495
  } catch {
50279
50496
  }
50280
50497
  return count;
50281
50498
  }
50282
50499
  function clearPreReadyFailures(versionDir) {
50283
- fs91.rmSync(path105.join(versionDir, ".prefail"), { force: true });
50500
+ fs94.rmSync(path107.join(versionDir, ".prefail"), { force: true });
50284
50501
  }
50285
50502
  function markBad(versionDir, reason) {
50286
50503
  try {
50287
- fs91.writeFileSync(path105.join(versionDir, ".bad"), `${(/* @__PURE__ */ new Date()).toISOString()} ${reason}
50504
+ fs94.writeFileSync(path107.join(versionDir, ".bad"), `${(/* @__PURE__ */ new Date()).toISOString()} ${reason}
50288
50505
  `);
50289
50506
  } catch {
50290
50507
  }
50291
50508
  }
50292
50509
  function pointerTarget(root, name) {
50293
50510
  try {
50294
- return fs91.realpathSync(path105.join(root, name));
50511
+ return fs94.realpathSync(path107.join(root, name));
50295
50512
  } catch {
50296
50513
  return null;
50297
50514
  }
50298
50515
  }
50299
50516
  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");
50517
+ const tmp = path107.join(root, `.${name}.tmp-${process.pid}-${Date.now()}`);
50518
+ fs94.symlinkSync(path107.relative(root, targetDir), tmp, "dir");
50302
50519
  try {
50303
- fs91.renameSync(tmp, path105.join(root, name));
50520
+ fs94.renameSync(tmp, path107.join(root, name));
50304
50521
  } catch (err) {
50305
- fs91.rmSync(tmp, { force: true });
50522
+ fs94.rmSync(tmp, { force: true });
50306
50523
  throw err;
50307
50524
  }
50308
50525
  }
50309
50526
  function switchCurrent(root, versionDir) {
50310
50527
  const old = pointerTarget(root, "current");
50311
- if (old && path105.resolve(old) !== path105.resolve(versionDir)) atomicPoint(root, "previous", old);
50528
+ if (old && path107.resolve(old) !== path107.resolve(versionDir)) atomicPoint(root, "previous", old);
50312
50529
  atomicPoint(root, "current", versionDir);
50313
50530
  }
50314
50531
  function validCurrent(root) {
@@ -50322,7 +50539,7 @@ function rollbackCurrent(root) {
50322
50539
  const prev = pointerTarget(root, "previous");
50323
50540
  if (!prev || isBad(prev) || !entryOf(prev)) return null;
50324
50541
  const cur = pointerTarget(root, "current");
50325
- if (cur && path105.resolve(cur) !== path105.resolve(prev)) atomicPoint(root, "previous", cur);
50542
+ if (cur && path107.resolve(cur) !== path107.resolve(prev)) atomicPoint(root, "previous", cur);
50326
50543
  atomicPoint(root, "current", prev);
50327
50544
  return versionOf(prev);
50328
50545
  }
@@ -50336,15 +50553,15 @@ function versionDirContaining(root, file) {
50336
50553
  let real;
50337
50554
  let realRoot;
50338
50555
  try {
50339
- real = fs91.realpathSync(file);
50340
- realRoot = fs91.realpathSync(root);
50556
+ real = fs94.realpathSync(file);
50557
+ realRoot = fs94.realpathSync(root);
50341
50558
  } catch {
50342
50559
  return null;
50343
50560
  }
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;
50561
+ const rel = path107.relative(realRoot, real);
50562
+ if (rel.startsWith("..") || path107.isAbsolute(rel)) return null;
50563
+ const first = rel.split(path107.sep)[0];
50564
+ return first && SEMVER_DIR.test(first) ? path107.join(realRoot, first) : null;
50348
50565
  }
50349
50566
  function pidAlive3(pid) {
50350
50567
  try {
@@ -50357,7 +50574,7 @@ function pidAlive3(pid) {
50357
50574
  function livePids(versionDir) {
50358
50575
  let names;
50359
50576
  try {
50360
- names = fs91.readdirSync(path105.join(versionDir, ".pids"));
50577
+ names = fs94.readdirSync(path107.join(versionDir, ".pids"));
50361
50578
  } catch {
50362
50579
  return [];
50363
50580
  }
@@ -50366,11 +50583,11 @@ function livePids(versionDir) {
50366
50583
  function registerRunningVersion(root = cliVersionsRoot(), entry = process.argv[1]) {
50367
50584
  const dir = versionDirContaining(root, entry);
50368
50585
  if (!dir) return;
50369
- const file = path105.join(dir, ".pids", String(process.pid));
50586
+ const file = path107.join(dir, ".pids", String(process.pid));
50370
50587
  try {
50371
- fs91.mkdirSync(path105.dirname(file), { recursive: true });
50372
- fs91.writeFileSync(file, "");
50373
- process.once("exit", () => fs91.rmSync(file, { force: true }));
50588
+ fs94.mkdirSync(path107.dirname(file), { recursive: true });
50589
+ fs94.writeFileSync(file, "");
50590
+ process.once("exit", () => fs94.rmSync(file, { force: true }));
50374
50591
  } catch {
50375
50592
  }
50376
50593
  }
@@ -50378,7 +50595,7 @@ function gcVersions(root) {
50378
50595
  const removed = [];
50379
50596
  let names;
50380
50597
  try {
50381
- names = fs91.readdirSync(root).filter((n) => SEMVER_DIR.test(n));
50598
+ names = fs94.readdirSync(root).filter((n) => SEMVER_DIR.test(n));
50382
50599
  } catch {
50383
50600
  return removed;
50384
50601
  }
@@ -50386,13 +50603,13 @@ function gcVersions(root) {
50386
50603
  [...names].sort((a, b) => compareSemver(b, a)).slice(0, GC_KEEP_NEWEST)
50387
50604
  );
50388
50605
  for (const p2 of [pointerTarget(root, "current"), pointerTarget(root, "previous")]) {
50389
- if (p2) keep.add(path105.basename(p2));
50606
+ if (p2) keep.add(path107.basename(p2));
50390
50607
  }
50391
50608
  for (const name of names) {
50392
- const dir = path105.join(root, name);
50609
+ const dir = path107.join(root, name);
50393
50610
  if (keep.has(name) || livePids(dir).length > 0) continue;
50394
50611
  try {
50395
- fs91.rmSync(dir, { recursive: true, force: true });
50612
+ fs94.rmSync(dir, { recursive: true, force: true });
50396
50613
  removed.push(name);
50397
50614
  } catch {
50398
50615
  }
@@ -50400,25 +50617,25 @@ function gcVersions(root) {
50400
50617
  return removed;
50401
50618
  }
50402
50619
  function acquireInstallLock(root) {
50403
- const lock = path105.join(root, ".install.lock");
50620
+ const lock = path107.join(root, ".install.lock");
50404
50621
  for (let attempt = 0; attempt < 2; attempt++) {
50405
50622
  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 });
50623
+ const fd = fs94.openSync(lock, "wx");
50624
+ fs94.writeSync(fd, String(process.pid));
50625
+ fs94.closeSync(fd);
50626
+ return () => fs94.rmSync(lock, { force: true });
50410
50627
  } catch (err) {
50411
50628
  if (err.code !== "EEXIST") return null;
50412
50629
  let stale = false;
50413
50630
  try {
50414
- const owner = Number(fs91.readFileSync(lock, "utf8"));
50415
- const age = Date.now() - fs91.statSync(lock).mtimeMs;
50631
+ const owner = Number(fs94.readFileSync(lock, "utf8"));
50632
+ const age = Date.now() - fs94.statSync(lock).mtimeMs;
50416
50633
  stale = !Number.isInteger(owner) || !pidAlive3(owner) || age > LOCK_STALE_MS;
50417
50634
  } catch {
50418
50635
  stale = true;
50419
50636
  }
50420
50637
  if (!stale) return null;
50421
- fs91.rmSync(lock, { force: true });
50638
+ fs94.rmSync(lock, { force: true });
50422
50639
  }
50423
50640
  }
50424
50641
  return null;
@@ -50426,9 +50643,9 @@ function acquireInstallLock(root) {
50426
50643
 
50427
50644
  // src/commands/host/host-launch.ts
50428
50645
  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"));
50646
+ var fs96 = __toESM(require("fs"));
50647
+ var os70 = __toESM(require("os"));
50648
+ var path109 = __toESM(require("path"));
50432
50649
 
50433
50650
  // src/exit-codes.ts
50434
50651
  var EXIT_OK = 0;
@@ -50450,8 +50667,8 @@ var EXIT_CODE_NAMES = {
50450
50667
 
50451
50668
  // src/commands/host/self-update.ts
50452
50669
  var import_node_child_process33 = require("child_process");
50453
- var fs92 = __toESM(require("fs"));
50454
- var path106 = __toESM(require("path"));
50670
+ var fs95 = __toESM(require("fs"));
50671
+ var path108 = __toESM(require("path"));
50455
50672
  var SELF_UPDATE_PKG = "codeam-cli";
50456
50673
  var SELF_UPDATE_INTERVAL_MS = 60 * 60 * 1e3;
50457
50674
  var SELF_UPDATE_STARTUP_DELAY_MS = 5e3;
@@ -50460,7 +50677,7 @@ var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
50460
50677
  var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
50461
50678
  var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
50462
50679
  function currentCliVersion() {
50463
- return true ? "2.76.12" : null;
50680
+ return true ? "2.76.14" : null;
50464
50681
  }
50465
50682
  async function installedVersion(deps) {
50466
50683
  const ls = await deps.run(
@@ -50552,9 +50769,9 @@ async function runSelfUpdateWith(deps) {
50552
50769
  var VERIFY_TIMEOUT_MS = 3e4;
50553
50770
  async function installVersioned(deps, root, latest, running2) {
50554
50771
  const node = deps.nodePath ?? process.execPath;
50555
- const target = path106.join(root, latest);
50772
+ const target = path108.join(root, latest);
50556
50773
  try {
50557
- fs92.mkdirSync(root, { recursive: true });
50774
+ fs95.mkdirSync(root, { recursive: true });
50558
50775
  } catch {
50559
50776
  return { status: "skipped" };
50560
50777
  }
@@ -50571,10 +50788,10 @@ async function installVersioned(deps, root, latest, running2) {
50571
50788
  const runningDir = versionDirContaining(root, deps.runningEntry);
50572
50789
  const reusable = entryOf(target) && versionOf(target) === latest;
50573
50790
  if (!reusable) {
50574
- if (runningDir && path106.resolve(runningDir) === path106.resolve(target)) {
50791
+ if (runningDir && path108.resolve(runningDir) === path108.resolve(target)) {
50575
50792
  return { status: "skipped" };
50576
50793
  }
50577
- fs92.rmSync(target, { recursive: true, force: true });
50794
+ fs95.rmSync(target, { recursive: true, force: true });
50578
50795
  const install = await deps.run(
50579
50796
  "npm",
50580
50797
  [
@@ -50589,7 +50806,7 @@ async function installVersioned(deps, root, latest, running2) {
50589
50806
  SELF_UPDATE_INSTALL_TIMEOUT_MS
50590
50807
  );
50591
50808
  if (install.code !== 0) {
50592
- fs92.rmSync(target, { recursive: true, force: true });
50809
+ fs95.rmSync(target, { recursive: true, force: true });
50593
50810
  log.warn(
50594
50811
  "host-agent",
50595
50812
  `self-update: versioned install exited ${String(install.code)} \u2014 staying on ${running2}: ` + install.stderr.slice(-300)
@@ -50600,7 +50817,7 @@ async function installVersioned(deps, root, latest, running2) {
50600
50817
  const entry = entryOf(target);
50601
50818
  const check = entry ? await deps.run(node, [entry, "--version"], VERIFY_TIMEOUT_MS) : { code: null, stdout: "", stderr: "no entry point" };
50602
50819
  if (check.code !== 0 || !check.stdout.includes(latest)) {
50603
- fs92.rmSync(target, { recursive: true, force: true });
50820
+ fs95.rmSync(target, { recursive: true, force: true });
50604
50821
  log.warn(
50605
50822
  "host-agent",
50606
50823
  `self-update: ${latest} failed verification (exit ${String(check.code)}: ${(check.stdout + check.stderr).trim().slice(-200)}) \u2014 staying on ${running2}`
@@ -50616,7 +50833,7 @@ async function installVersioned(deps, root, latest, running2) {
50616
50833
  return { status: "updated", version: latest };
50617
50834
  } catch (err) {
50618
50835
  const cur = pointerTarget(root, "current");
50619
- if (!cur || path106.basename(cur) !== latest) fs92.rmSync(target, { recursive: true, force: true });
50836
+ if (!cur || path108.basename(cur) !== latest) fs95.rmSync(target, { recursive: true, force: true });
50620
50837
  log.warn(
50621
50838
  "host-agent",
50622
50839
  `self-update: versioned install failed: ${err instanceof Error ? err.message : String(err)}`
@@ -50655,7 +50872,7 @@ function signalHostReady(send = process.send?.bind(process)) {
50655
50872
  }
50656
50873
  function defaultDeps() {
50657
50874
  return {
50658
- ownVersion: true ? "2.76.12" : null,
50875
+ ownVersion: true ? "2.76.14" : null,
50659
50876
  root: cliVersionsRoot(),
50660
50877
  args: process.argv.slice(3),
50661
50878
  execPath: process.execPath,
@@ -50752,13 +50969,13 @@ function needsSelfRelaunch(env = process.env, pid = process.pid, ctx = {}) {
50752
50969
  }
50753
50970
  function readPid1Cmdline() {
50754
50971
  try {
50755
- return fs93.readFileSync("/proc/1/cmdline", "utf8").split("\0").filter(Boolean);
50972
+ return fs96.readFileSync("/proc/1/cmdline", "utf8").split("\0").filter(Boolean);
50756
50973
  } catch {
50757
50974
  return [];
50758
50975
  }
50759
50976
  }
50760
50977
  function isOurTiniEntrypoint(argv) {
50761
- return argv.some((a) => path107.basename(a) === "tini") && argv.includes("host-agent");
50978
+ return argv.some((a) => path109.basename(a) === "tini") && argv.includes("host-agent");
50762
50979
  }
50763
50980
  function relaunchArgv(execPath, argv) {
50764
50981
  return ["-c", 'sleep 2; exec "$0" "$@"', execPath, ...argv.slice(1)];
@@ -50791,7 +51008,7 @@ function defaultRestartForUpdate(version3, supervised, io = {}) {
50791
51008
  }
50792
51009
  exit(0);
50793
51010
  }
50794
- function isContainerEnvironment(existsSyncFn = fs93.existsSync, readFileSyncFn = (p2) => fs93.readFileSync(p2, "utf8")) {
51011
+ function isContainerEnvironment(existsSyncFn = fs96.existsSync, readFileSyncFn = (p2) => fs96.readFileSync(p2, "utf8")) {
50795
51012
  try {
50796
51013
  if (existsSyncFn("/.dockerenv")) return true;
50797
51014
  } catch {
@@ -50803,16 +51020,16 @@ function isContainerEnvironment(existsSyncFn = fs93.existsSync, readFileSyncFn =
50803
51020
  }
50804
51021
  return false;
50805
51022
  }
50806
- function hostAgentPidFile(home = os68.homedir()) {
50807
- return path107.join(home, ".codeam", "host-agent.pid");
51023
+ function hostAgentPidFile(home = os70.homedir()) {
51024
+ return path109.join(home, ".codeam", "host-agent.pid");
50808
51025
  }
50809
51026
  function writeHostAgentPidFile(file = hostAgentPidFile(), pid = process.pid) {
50810
51027
  try {
50811
- fs93.mkdirSync(path107.dirname(file), { recursive: true });
50812
- fs93.writeFileSync(file, String(pid));
51028
+ fs96.mkdirSync(path109.dirname(file), { recursive: true });
51029
+ fs96.writeFileSync(file, String(pid));
50813
51030
  process.once("exit", () => {
50814
51031
  try {
50815
- if (fs93.readFileSync(file, "utf8").trim() === String(pid)) fs93.rmSync(file, { force: true });
51032
+ if (fs96.readFileSync(file, "utf8").trim() === String(pid)) fs96.rmSync(file, { force: true });
50816
51033
  } catch {
50817
51034
  }
50818
51035
  });
@@ -51570,13 +51787,13 @@ var HostAgentSupervisor = class {
51570
51787
  const relay = this.relay;
51571
51788
  if (!relay) return;
51572
51789
  const raw = cmd.payload?.path;
51573
- const target = typeof raw === "string" && raw.trim() ? path108.resolve(raw.trim()) : os69.homedir();
51790
+ const target = typeof raw === "string" && raw.trim() ? path110.resolve(raw.trim()) : os71.homedir();
51574
51791
  try {
51575
- const dirents = await fs94.promises.readdir(target, { withFileTypes: true });
51792
+ const dirents = await fs97.promises.readdir(target, { withFileTypes: true });
51576
51793
  const entries2 = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
51577
51794
  (a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
51578
51795
  );
51579
- const parent = path108.dirname(target);
51796
+ const parent = path110.dirname(target);
51580
51797
  await relay.sendResult(cmd.id, "completed", {
51581
51798
  path: target,
51582
51799
  // null at the filesystem root so the UI can hide the ".." affordance.
@@ -52047,14 +52264,14 @@ var HostAgentSupervisor = class {
52047
52264
  }),
52048
52265
  CODEAM_AUTO_TOKEN: payload.autoPairToken
52049
52266
  };
52050
- const houseConfigDir = path108.join(
52051
- os69.homedir(),
52267
+ const houseConfigDir = path110.join(
52268
+ os71.homedir(),
52052
52269
  ".codeam",
52053
52270
  "house-claude",
52054
52271
  payload.deployId
52055
52272
  );
52056
52273
  try {
52057
- fs94.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
52274
+ fs97.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
52058
52275
  } catch {
52059
52276
  }
52060
52277
  childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
@@ -52081,7 +52298,7 @@ var HostAgentSupervisor = class {
52081
52298
  report("installing", "installing agent CLI");
52082
52299
  await this.runAgentInstall(payload.agentInstallScript);
52083
52300
  }
52084
- const home = process.env.HOME || os69.homedir();
52301
+ const home = process.env.HOME || os71.homedir();
52085
52302
  childEnv.PATH = `${home}/.local/bin:${process.env.PATH ?? ""}`;
52086
52303
  if (payload.cloneToken) {
52087
52304
  try {
@@ -52089,13 +52306,13 @@ var HostAgentSupervisor = class {
52089
52306
  if ((payload.repoProvider ?? "github") === "gitlab") {
52090
52307
  const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
52091
52308
  if (glabCmd) {
52092
- childEnv.PATH = `${codeamBinDir()}${path108.delimiter}${childEnv.PATH}`;
52309
+ childEnv.PATH = `${codeamBinDir()}${path110.delimiter}${childEnv.PATH}`;
52093
52310
  await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
52094
52311
  }
52095
52312
  } else {
52096
52313
  const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
52097
52314
  if (ghCmd) {
52098
- childEnv.PATH = `${codeamBinDir()}${path108.delimiter}${childEnv.PATH}`;
52315
+ childEnv.PATH = `${codeamBinDir()}${path110.delimiter}${childEnv.PATH}`;
52099
52316
  await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
52100
52317
  }
52101
52318
  }
@@ -52123,9 +52340,9 @@ var HostAgentSupervisor = class {
52123
52340
  );
52124
52341
  if (!payload.suppressOnboardingWelcome) {
52125
52342
  try {
52126
- const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path108.join(os69.homedir(), ".claude");
52127
- const projectDir = path108.join(cfgDir, "projects", encodeCwd(cwd));
52128
- const hasPriorConversation = fs94.existsSync(projectDir) && fs94.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
52343
+ const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path110.join(os71.homedir(), ".claude");
52344
+ const projectDir = path110.join(cfgDir, "projects", encodeCwd(cwd));
52345
+ const hasPriorConversation = fs97.existsSync(projectDir) && fs97.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
52129
52346
  if (hasPriorConversation) {
52130
52347
  childEnv.CODEAM_RESUME_LATEST = "1";
52131
52348
  log.info(
@@ -52279,7 +52496,7 @@ var HostAgentSupervisor = class {
52279
52496
  fallbackResumeTarget() {
52280
52497
  const session = getActiveSession();
52281
52498
  if (!session || !session.pluginId || !session.pollSecret || !session.agent) return null;
52282
- const cwd = session.cwd && fs94.existsSync(session.cwd) ? session.cwd : process.cwd();
52499
+ const cwd = session.cwd && fs97.existsSync(session.cwd) ? session.cwd : process.cwd();
52283
52500
  if (isFilesystemRoot(cwd)) {
52284
52501
  log.warn(
52285
52502
  "host-agent",
@@ -52319,7 +52536,7 @@ var HostAgentSupervisor = class {
52319
52536
  log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: no saved pairing on this box`);
52320
52537
  return;
52321
52538
  }
52322
- if (!session.cwd || !fs94.existsSync(session.cwd)) {
52539
+ if (!session.cwd || !fs97.existsSync(session.cwd)) {
52323
52540
  log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: workspace is gone`);
52324
52541
  return;
52325
52542
  }
@@ -52361,7 +52578,7 @@ var HostAgentSupervisor = class {
52361
52578
  const persisted = new Map((this.sessionStore.load() ?? []).map((r) => [r.deployId, r.agent]));
52362
52579
  for (const c2 of this.children.values()) persisted.set(c2.deployId, c2.agent);
52363
52580
  return this.listSavedSessions().map((s) => ({ s, deployId: deployIdFromWorkspace(s.cwd) })).filter(
52364
- (x) => x.deployId !== null && !!x.s.cwd && fs94.existsSync(x.s.cwd)
52581
+ (x) => x.deployId !== null && !!x.s.cwd && fs97.existsSync(x.s.cwd)
52365
52582
  ).map(({ s, deployId }) => {
52366
52583
  const agent = persisted.get(deployId);
52367
52584
  return { deployId, sessionId: s.id, ...agent ? { agent } : {} };
@@ -52413,7 +52630,7 @@ var HostAgentSupervisor = class {
52413
52630
  if (this.children.has(deployId)) return;
52414
52631
  const st3 = this.resumeStateFor(target);
52415
52632
  try {
52416
- const cwd = fs94.existsSync(target.cwd) ? target.cwd : process.cwd();
52633
+ const cwd = fs97.existsSync(target.cwd) ? target.cwd : process.cwd();
52417
52634
  const proc = this.resumeSpawner(
52418
52635
  { ...readHouseProxyChildEnv(deployId), CODEAM_RESUME_SESSION_ID: session.id },
52419
52636
  cwd
@@ -52440,7 +52657,7 @@ var HostAgentSupervisor = class {
52440
52657
  return;
52441
52658
  }
52442
52659
  if (tracked && signal) {
52443
- this.onResumeChildExit(target, 128 + (os69.constants.signals[signal] ?? 9), `signal ${signal}`);
52660
+ this.onResumeChildExit(target, 128 + (os71.constants.signals[signal] ?? 9), `signal ${signal}`);
52444
52661
  return;
52445
52662
  }
52446
52663
  log.warn(
@@ -52483,7 +52700,7 @@ var HostAgentSupervisor = class {
52483
52700
  if (Date.now() - child.startedAt < CRASH_RESPAWN_MIN_UPTIME_MS) return false;
52484
52701
  const session = pickSavedSessionForWorkspace(this.listSavedSessions(), child.cwd);
52485
52702
  if (!session) return false;
52486
- const exitCode = typeof code === "number" ? code : 128 + (signal ? os69.constants.signals[signal] ?? 9 : 9);
52703
+ const exitCode = typeof code === "number" ? code : 128 + (signal ? os71.constants.signals[signal] ?? 9 : 9);
52487
52704
  log.warn(
52488
52705
  "host-agent",
52489
52706
  `session deploy=${child.deployId.slice(0, 8)} died (${signal ?? code}) after ${Math.round((Date.now() - child.startedAt) / 1e3)}s \u2014 respawning it (resume)`
@@ -52632,12 +52849,12 @@ var HostAgentSupervisor = class {
52632
52849
  this.untrackChild(deployId);
52633
52850
  }
52634
52851
  const dirs = [
52635
- path108.join(selfHostedWorkspaceRoot(), deployId),
52636
- path108.join(os69.homedir(), ".codeam", "house-claude", deployId)
52852
+ path110.join(selfHostedWorkspaceRoot(), deployId),
52853
+ path110.join(os71.homedir(), ".codeam", "house-claude", deployId)
52637
52854
  ];
52638
52855
  for (const dir of dirs) {
52639
52856
  try {
52640
- fs94.rmSync(dir, { recursive: true, force: true });
52857
+ fs97.rmSync(dir, { recursive: true, force: true });
52641
52858
  } catch (err) {
52642
52859
  log.warn(
52643
52860
  "host-agent",
@@ -52804,8 +53021,8 @@ async function invite() {
52804
53021
  var import_node_dns = require("dns");
52805
53022
  var import_node_util11 = require("util");
52806
53023
  var import_node_crypto17 = require("crypto");
52807
- var fs95 = __toESM(require("fs"));
52808
- var path109 = __toESM(require("path"));
53024
+ var fs98 = __toESM(require("fs"));
53025
+ var path111 = __toESM(require("path"));
52809
53026
  var import_picocolors14 = __toESM(require("picocolors"));
52810
53027
  var dnsResolveP = (0, import_node_util11.promisify)(import_node_dns.resolve);
52811
53028
  async function checkDns(apiBase2) {
@@ -52861,13 +53078,13 @@ async function checkHealth(apiBase2) {
52861
53078
  }
52862
53079
  }
52863
53080
  function checkConfigDir() {
52864
- const dir = path109.join(require("os").homedir(), ".codeam");
53081
+ const dir = path111.join(require("os").homedir(), ".codeam");
52865
53082
  try {
52866
- fs95.mkdirSync(dir, { recursive: true, mode: 448 });
52867
- const probe = path109.join(dir, ".doctor-probe");
52868
- fs95.writeFileSync(probe, "ok", { mode: 384 });
52869
- const read = fs95.readFileSync(probe, "utf8");
52870
- fs95.unlinkSync(probe);
53083
+ fs98.mkdirSync(dir, { recursive: true, mode: 448 });
53084
+ const probe = path111.join(dir, ".doctor-probe");
53085
+ fs98.writeFileSync(probe, "ok", { mode: 384 });
53086
+ const read = fs98.readFileSync(probe, "utf8");
53087
+ fs98.unlinkSync(probe);
52871
53088
  if (read !== "ok") throw new Error("write/read round-trip mismatch");
52872
53089
  return {
52873
53090
  id: "config-dir",
@@ -52907,9 +53124,9 @@ function checkSessions() {
52907
53124
  }
52908
53125
  }
52909
53126
  function checkAgentBinaries() {
52910
- const os72 = createOsStrategy();
53127
+ const os74 = createOsStrategy();
52911
53128
  return getEnabledAgents().map((meta) => {
52912
- const found = os72.findInPath(meta.binaryName);
53129
+ const found = os74.findInPath(meta.binaryName);
52913
53130
  return {
52914
53131
  id: `agent-${meta.id}`,
52915
53132
  label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
@@ -52931,7 +53148,7 @@ function checkNodePty() {
52931
53148
  detail: "not required on this platform"
52932
53149
  };
52933
53150
  }
52934
- const vendoredPath = path109.join(__dirname, "vendor", "node-pty");
53151
+ const vendoredPath = path111.join(__dirname, "vendor", "node-pty");
52935
53152
  for (const target of [vendoredPath, "node-pty"]) {
52936
53153
  try {
52937
53154
  require(target);
@@ -52973,7 +53190,7 @@ function checkChokidar() {
52973
53190
  }
52974
53191
  async function doctor(args2 = []) {
52975
53192
  const json = args2.includes("--json");
52976
- const cliVersion = true ? "2.76.12" : "0.0.0-dev";
53193
+ const cliVersion = true ? "2.76.14" : "0.0.0-dev";
52977
53194
  const apiBase2 = resolveApiBaseUrl();
52978
53195
  const diagnosticId = (0, import_node_crypto17.randomUUID)();
52979
53196
  log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
@@ -53497,7 +53714,7 @@ async function mcpWarm(argv = [], opts = {}) {
53497
53714
  // src/commands/version.ts
53498
53715
  var import_picocolors15 = __toESM(require("picocolors"));
53499
53716
  function version2() {
53500
- const v = true ? "2.76.12" : "unknown";
53717
+ const v = true ? "2.76.14" : "unknown";
53501
53718
  console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
53502
53719
  }
53503
53720
 
@@ -53630,10 +53847,10 @@ function tryShowSubcommandHelp(cmd, args2) {
53630
53847
  var _subcommandHelpKeys = Object.keys(HELPS);
53631
53848
 
53632
53849
  // src/index.ts
53633
- var os71 = __toESM(require("os"));
53850
+ var os73 = __toESM(require("os"));
53634
53851
  if (!process.env.HOME) {
53635
53852
  try {
53636
- const home = os71.homedir();
53853
+ const home = os73.homedir();
53637
53854
  if (home) process.env.HOME = home;
53638
53855
  } catch {
53639
53856
  }