codeam-cli 2.75.35 → 2.75.36

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 +7 -0
  2. package/dist/index.js +399 -354
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -77,12 +77,12 @@ var require_src = __commonJS({
77
77
  lineEnd: `${CSI2}K`,
78
78
  lineStart: `${CSI2}1K`,
79
79
  lines(count) {
80
- let clear = "";
80
+ let clear2 = "";
81
81
  for (let i = 0; i < count; i++)
82
- clear += this.line + (i < count - 1 ? cursor.up() : "");
82
+ clear2 += this.line + (i < count - 1 ? cursor.up() : "");
83
83
  if (count)
84
- clear += cursor.left;
85
- return clear;
84
+ clear2 += cursor.left;
85
+ return clear2;
86
86
  }
87
87
  };
88
88
  module2.exports = { cursor, scroll, erase, beep };
@@ -357,8 +357,8 @@ function defaultSpawn(timeoutMs) {
357
357
  });
358
358
  }
359
359
  function resolveConvexBin(cwd) {
360
- const local = path95.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "convex.cmd" : "convex");
361
- if (fs81.existsSync(local)) return { cmd: local, args: [] };
360
+ const local = path96.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "convex.cmd" : "convex");
361
+ if (fs82.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_process32, fs81, path95, TOOLS;
492
+ var import_node_child_process32, fs82, path96, 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_process32 = require("child_process");
497
- fs81 = __toESM(require("fs"));
498
- path95 = __toESM(require("path"));
497
+ fs82 = __toESM(require("fs"));
498
+ path96 = __toESM(require("path"));
499
499
  TOOLS = [
500
500
  {
501
501
  name: "tables",
@@ -578,7 +578,7 @@ function createToolCallWatchdog(deps) {
578
578
  const clearTimer = deps.clearTimer ?? ((t2) => clearTimeout(t2));
579
579
  const timers = /* @__PURE__ */ new Map();
580
580
  const answered = /* @__PURE__ */ new Set();
581
- const clear = (id) => {
581
+ const clear2 = (id) => {
582
582
  const t2 = timers.get(id);
583
583
  if (t2) {
584
584
  clearTimer(t2);
@@ -590,7 +590,7 @@ function createToolCallWatchdog(deps) {
590
590
  const m = msg;
591
591
  if (m.method !== "tools/call" || m.id === void 0) return;
592
592
  const id = m.id;
593
- clear(id);
593
+ clear2(id);
594
594
  const timer = setTimer(() => {
595
595
  timers.delete(id);
596
596
  answered.add(id);
@@ -610,7 +610,7 @@ function createToolCallWatchdog(deps) {
610
610
  onServerMessage(msg) {
611
611
  const m = msg;
612
612
  if (m.id === void 0 || m.method !== void 0) return false;
613
- clear(m.id);
613
+ clear2(m.id);
614
614
  return answered.delete(m.id);
615
615
  },
616
616
  dispose() {
@@ -3545,11 +3545,11 @@ function quiet(fn) {
3545
3545
  log.debug(TAG, "ignored sync error", err);
3546
3546
  }
3547
3547
  }
3548
- function rmIfExistsQuiet(path97) {
3548
+ function rmIfExistsQuiet(path98) {
3549
3549
  try {
3550
- fs2.rmSync(path97, { force: true });
3550
+ fs2.rmSync(path98, { force: true });
3551
3551
  } catch (err) {
3552
- log.debug(TAG, `rmIfExists failed for ${path97}`, err);
3552
+ log.debug(TAG, `rmIfExists failed for ${path98}`, err);
3553
3553
  }
3554
3554
  }
3555
3555
  function killQuiet(target, signal = "SIGTERM") {
@@ -3753,8 +3753,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
3753
3753
  return decodedFile;
3754
3754
  };
3755
3755
  }
3756
- function normalizeWindowsPath(path97) {
3757
- return path97.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
3756
+ function normalizeWindowsPath(path98) {
3757
+ return path98.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
3758
3758
  }
3759
3759
 
3760
3760
  // ../../node_modules/@posthog/core/dist/error-tracking/index.mjs
@@ -4828,20 +4828,20 @@ var ErrorPropertiesBuilder = class {
4828
4828
  };
4829
4829
  return context;
4830
4830
  }
4831
- buildCoercingContext(mechanism, hint, depth = 0) {
4832
- const coerce = (input, depth2) => {
4833
- if (!(depth2 <= MAX_CAUSE_RECURSION)) return;
4831
+ buildCoercingContext(mechanism, hint, depth2 = 0) {
4832
+ const coerce = (input, depth3) => {
4833
+ if (!(depth3 <= MAX_CAUSE_RECURSION)) return;
4834
4834
  {
4835
- const ctx = this.buildCoercingContext(mechanism, hint, depth2);
4835
+ const ctx = this.buildCoercingContext(mechanism, hint, depth3);
4836
4836
  return this.applyCoercers(input, ctx);
4837
4837
  }
4838
4838
  };
4839
4839
  const context = {
4840
4840
  ...hint,
4841
- syntheticException: 0 == depth ? hint.syntheticException : void 0,
4841
+ syntheticException: 0 == depth2 ? hint.syntheticException : void 0,
4842
4842
  mechanism,
4843
- apply: (input) => coerce(input, depth),
4844
- next: (input) => coerce(input, depth + 1)
4843
+ apply: (input) => coerce(input, depth2),
4844
+ next: (input) => coerce(input, depth2 + 1)
4845
4845
  };
4846
4846
  return context;
4847
4847
  }
@@ -6487,13 +6487,13 @@ var PostHogCoreStateless = class {
6487
6487
  sentFromRoute += batchMessages.length;
6488
6488
  }
6489
6489
  }
6490
- async _sendOtlpBatch({ path: path97, payload }) {
6490
+ async _sendOtlpBatch({ path: path98, payload }) {
6491
6491
  if (this.disabled) return {
6492
6492
  kind: "fatal",
6493
6493
  error: new Error("The client is disabled")
6494
6494
  };
6495
6495
  const serialized = JSON.stringify(payload);
6496
- const url2 = `${this.host}/i/v1/${path97}?token=${encodeURIComponent(this.apiKey)}`;
6496
+ const url2 = `${this.host}/i/v1/${path98}?token=${encodeURIComponent(this.apiKey)}`;
6497
6497
  const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
6498
6498
  const fetchOptions = {
6499
6499
  method: "POST",
@@ -7139,7 +7139,7 @@ function encodeBigInt(value, logger) {
7139
7139
  intValue: decimal
7140
7140
  };
7141
7141
  }
7142
- function encodeAnyValue(value, logger, state, depth) {
7142
+ function encodeAnyValue(value, logger, state, depth2) {
7143
7143
  if (state.remainingNodes <= 0) return {
7144
7144
  stringValue: TRUNCATED_VALUE
7145
7145
  };
@@ -7187,7 +7187,7 @@ function encodeAnyValue(value, logger, state, depth) {
7187
7187
  if (state.ancestors.has(value)) return {
7188
7188
  stringValue: CIRCULAR_VALUE
7189
7189
  };
7190
- if (depth >= MAX_JSON_SAFE_VALUE_DEPTH) return {
7190
+ if (depth2 >= MAX_JSON_SAFE_VALUE_DEPTH) return {
7191
7191
  stringValue: TRUNCATED_VALUE
7192
7192
  };
7193
7193
  if (value instanceof Date) {
@@ -7201,17 +7201,17 @@ function encodeAnyValue(value, logger, state, depth) {
7201
7201
  try {
7202
7202
  try {
7203
7203
  const toJSON = value.toJSON;
7204
- if ("function" == typeof toJSON) return encodeAnyValue(toJSON.call(value), logger, state, depth + 1);
7204
+ if ("function" == typeof toJSON) return encodeAnyValue(toJSON.call(value), logger, state, depth2 + 1);
7205
7205
  } catch {
7206
7206
  }
7207
7207
  if (isArray(value)) return {
7208
7208
  arrayValue: {
7209
- values: encodeArrayValues(value, logger, state, depth + 1)
7209
+ values: encodeArrayValues(value, logger, state, depth2 + 1)
7210
7210
  }
7211
7211
  };
7212
7212
  return {
7213
7213
  kvlistValue: {
7214
- values: encodeKeyValueList(value, logger, state, depth + 1)
7214
+ values: encodeKeyValueList(value, logger, state, depth2 + 1)
7215
7215
  }
7216
7216
  };
7217
7217
  } finally {
@@ -7222,14 +7222,14 @@ function encodeAnyValue(value, logger, state, depth) {
7222
7222
  stringValue: sanitizeString(String(value))
7223
7223
  };
7224
7224
  }
7225
- function encodeArrayValues(values, logger, state, depth) {
7225
+ function encodeArrayValues(values, logger, state, depth2) {
7226
7226
  const result = [];
7227
7227
  const itemCount = Math.min(values.length, MAX_JSON_SAFE_VALUE_ITEMS);
7228
7228
  let index = 0;
7229
7229
  for (; index < itemCount && state.remainingNodes > 0; index++) try {
7230
7230
  const element = index in values ? values[index] : void 0;
7231
7231
  if (isNullish(element)) continue;
7232
- result.push(encodeAnyValue(element, logger, state, depth));
7232
+ result.push(encodeAnyValue(element, logger, state, depth2));
7233
7233
  } catch {
7234
7234
  result.push({
7235
7235
  stringValue: UNSERIALIZABLE_VALUE
@@ -7240,7 +7240,7 @@ function encodeArrayValues(values, logger, state, depth) {
7240
7240
  });
7241
7241
  return result;
7242
7242
  }
7243
- function encodeKeyValueList(attrs, logger, state, depth) {
7243
+ function encodeKeyValueList(attrs, logger, state, depth2) {
7244
7244
  const result = [];
7245
7245
  for (const key in attrs) if (propertyIsEnumerable.call(attrs, key)) {
7246
7246
  if (!key) {
@@ -7256,7 +7256,7 @@ function encodeKeyValueList(attrs, logger, state, depth) {
7256
7256
  if (isNull(value) || isUndefined(value)) continue;
7257
7257
  result.push({
7258
7258
  key: sanitizeString(key),
7259
- value: encodeAnyValue(value, logger, state, depth)
7259
+ value: encodeAnyValue(value, logger, state, depth2)
7260
7260
  });
7261
7261
  } catch {
7262
7262
  result.push({
@@ -7733,14 +7733,14 @@ async function addSourceContext(frames, openSourceFile = import_promises.open, l
7733
7733
  LRU_FILE_CONTENTS_CACHE.reduce();
7734
7734
  return frames;
7735
7735
  }
7736
- async function openRegularSourceFile(path97, openSourceFile, logger) {
7736
+ async function openRegularSourceFile(path98, openSourceFile, logger) {
7737
7737
  let fileHandle;
7738
7738
  let isValid = false;
7739
7739
  try {
7740
- fileHandle = await openSourceFile(path97, import_node_fs.constants.O_RDONLY | import_node_fs.constants.O_NONBLOCK);
7740
+ fileHandle = await openSourceFile(path98, import_node_fs.constants.O_RDONLY | import_node_fs.constants.O_NONBLOCK);
7741
7741
  const fileStat = await fileHandle.stat();
7742
7742
  if (!fileStat.isFile()) return;
7743
- if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${path97}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
7743
+ if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${path98}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
7744
7744
  isValid = true;
7745
7745
  return fileHandle;
7746
7746
  } catch {
@@ -7750,8 +7750,8 @@ async function openRegularSourceFile(path97, openSourceFile, logger) {
7750
7750
  });
7751
7751
  }
7752
7752
  }
7753
- async function getContextLinesFromFile(path97, ranges, output, cacheKey, openSourceFile, logger) {
7754
- const fileHandle = await openRegularSourceFile(path97, openSourceFile, logger);
7753
+ async function getContextLinesFromFile(path98, ranges, output, cacheKey, openSourceFile, logger) {
7754
+ const fileHandle = await openRegularSourceFile(path98, openSourceFile, logger);
7755
7755
  if (void 0 === fileHandle) return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
7756
7756
  const openedFileHandle = fileHandle;
7757
7757
  return new Promise((resolve12) => {
@@ -7853,22 +7853,22 @@ function clearLineContext(frame) {
7853
7853
  delete frame.context_line;
7854
7854
  delete frame.post_context;
7855
7855
  }
7856
- function shouldSkipContextLinesForFile(path97) {
7857
- return path97.startsWith("node:") || path97.endsWith(".min.js") || path97.endsWith(".min.cjs") || path97.endsWith(".min.mjs") || path97.startsWith("data:");
7856
+ function shouldSkipContextLinesForFile(path98) {
7857
+ return path98.startsWith("node:") || path98.endsWith(".min.js") || path98.endsWith(".min.cjs") || path98.endsWith(".min.mjs") || path98.startsWith("data:");
7858
7858
  }
7859
7859
  function shouldSkipContextLinesForFrame(frame) {
7860
7860
  if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
7861
7861
  if (void 0 !== frame.colno && frame.colno > MAX_CONTEXTLINES_COLNO) return true;
7862
7862
  return false;
7863
7863
  }
7864
- function makeSourceCacheKey(path97, basePath) {
7865
- if ((0, import_node_path.isAbsolute)(path97)) return JSON.stringify([
7864
+ function makeSourceCacheKey(path98, basePath) {
7865
+ if ((0, import_node_path.isAbsolute)(path98)) return JSON.stringify([
7866
7866
  null,
7867
- path97
7867
+ path98
7868
7868
  ]);
7869
7869
  return void 0 === basePath ? void 0 : JSON.stringify([
7870
7870
  basePath,
7871
- path97
7871
+ path98
7872
7872
  ]);
7873
7873
  }
7874
7874
  function rangeExistsInContentCache(cacheKey, range) {
@@ -10529,7 +10529,7 @@ function readAnonId() {
10529
10529
  }
10530
10530
  function superProperties() {
10531
10531
  return {
10532
- cliVersion: true ? "2.75.35" : "0.0.0-dev",
10532
+ cliVersion: true ? "2.75.36" : "0.0.0-dev",
10533
10533
  nodeVersion: process.version,
10534
10534
  platform: process.platform,
10535
10535
  arch: process.arch,
@@ -10771,7 +10771,7 @@ var http = __toESM(require("http"));
10771
10771
  // package.json
10772
10772
  var package_default = {
10773
10773
  name: "codeam-cli",
10774
- version: "2.75.35",
10774
+ version: "2.75.36",
10775
10775
  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.",
10776
10776
  type: "commonjs",
10777
10777
  main: "dist/index.js",
@@ -12101,7 +12101,7 @@ var CommandRelayService = class _CommandRelayService {
12101
12101
  // fresh + clear the "CLI update available" banner after a self-update
12102
12102
  // (a codespace that reinstalls @latest reconnects via heartbeat, not
12103
12103
  // pair/reconnect). Older backends ignore the extra field.
12104
- ..."2.75.35" ? { ideVersion: "2.75.35" } : {}
12104
+ ..."2.75.36" ? { ideVersion: "2.75.36" } : {}
12105
12105
  };
12106
12106
  try {
12107
12107
  const res = await _postJson(`${API_BASE2}/api/plugin/heartbeat`, body);
@@ -12419,10 +12419,10 @@ var WINDOWS_LEGACY_JUNCTIONS = [
12419
12419
  /[\\/]Start Menu([\\/]|$)/i,
12420
12420
  /[\\/]Templates([\\/]|$)/i
12421
12421
  ];
12422
- function isUnsafeWindowsWatchRoot(dir, homedir52) {
12422
+ function isUnsafeWindowsWatchRoot(dir, homedir53) {
12423
12423
  const norm = (p2) => p2.replace(/\//g, "\\").replace(/\\+$/, "").toLowerCase();
12424
12424
  const cwd = norm(dir);
12425
- const home = norm(homedir52);
12425
+ const home = norm(homedir53);
12426
12426
  if (cwd === home) return true;
12427
12427
  if (/^[a-z]:$/.test(cwd)) return true;
12428
12428
  const sysRoots = [
@@ -13821,8 +13821,8 @@ async function isExistingFile(absPath) {
13821
13821
  return false;
13822
13822
  }
13823
13823
  }
13824
- async function walkForSuffix(dir, needleVariants, depth, ctx) {
13825
- if (depth > MAX_WALK_DEPTH) return;
13824
+ async function walkForSuffix(dir, needleVariants, depth2, ctx) {
13825
+ if (depth2 > MAX_WALK_DEPTH) return;
13826
13826
  if (ctx.visited > MAX_VISITED_DIRS) return;
13827
13827
  if (ctx.matches.length >= ctx.cap) return;
13828
13828
  ctx.visited++;
@@ -13844,7 +13844,7 @@ async function walkForSuffix(dir, needleVariants, depth, ctx) {
13844
13844
  if (!e.isDirectory()) continue;
13845
13845
  if (SUBDIR_IGNORE.has(e.name)) continue;
13846
13846
  if (e.name.startsWith(".") && SUBDIR_IGNORE.has(e.name)) continue;
13847
- await walkForSuffix(path7.join(dir, e.name), needleVariants, depth + 1, ctx);
13847
+ await walkForSuffix(path7.join(dir, e.name), needleVariants, depth2 + 1, ctx);
13848
13848
  if (ctx.matches.length >= ctx.cap) return;
13849
13849
  }
13850
13850
  }
@@ -13966,7 +13966,7 @@ async function listProjectFiles(opts = {}) {
13966
13966
  const q2 = (opts.query ?? "").trim().toLowerCase();
13967
13967
  const out2 = [];
13968
13968
  let truncated = false;
13969
- async function walk(dir, depth) {
13969
+ async function walk(dir, depth2) {
13970
13970
  if (out2.length >= cap) {
13971
13971
  truncated = true;
13972
13972
  return;
@@ -13985,8 +13985,8 @@ async function listProjectFiles(opts = {}) {
13985
13985
  if (PROJECT_IGNORE.has(e.name)) continue;
13986
13986
  const full = path8.join(dir, e.name);
13987
13987
  if (e.isDirectory()) {
13988
- if (depth >= 12) continue;
13989
- await walk(full, depth + 1);
13988
+ if (depth2 >= 12) continue;
13989
+ await walk(full, depth2 + 1);
13990
13990
  } else if (e.isFile()) {
13991
13991
  const rel = path8.relative(root, full);
13992
13992
  if (q2 && !rel.toLowerCase().includes(q2) && !e.name.toLowerCase().includes(q2)) {
@@ -17152,10 +17152,10 @@ function buildForPlatform(platform3) {
17152
17152
  var import_node_crypto4 = require("crypto");
17153
17153
 
17154
17154
  // src/agents/claude/resolver.ts
17155
- function buildClaudeLaunch(extraArgs = [], os66 = createOsStrategy()) {
17156
- const found = os66.findInPath("claude") ?? os66.findInPath("claude-code");
17155
+ function buildClaudeLaunch(extraArgs = [], os67 = createOsStrategy()) {
17156
+ const found = os67.findInPath("claude") ?? os67.findInPath("claude-code");
17157
17157
  if (!found) return null;
17158
- return os66.buildLaunch(found, extraArgs);
17158
+ return os67.buildLaunch(found, extraArgs);
17159
17159
  }
17160
17160
 
17161
17161
  // src/agents/claude/installer.ts
@@ -17933,8 +17933,8 @@ var ClaudeRuntimeStrategy = class {
17933
17933
  meta = getAgent("claude");
17934
17934
  mode = "interactive";
17935
17935
  os;
17936
- constructor(os66) {
17937
- this.os = os66;
17936
+ constructor(os67) {
17937
+ this.os = os67;
17938
17938
  }
17939
17939
  /**
17940
17940
  * Claude Code's react-ink TUI enables bracketed-paste mode at
@@ -19028,8 +19028,8 @@ function codexCredentialLocator() {
19028
19028
  function codexLoginLauncher() {
19029
19029
  return {
19030
19030
  async ensureInstalled() {
19031
- const os66 = createOsStrategy();
19032
- return os66.findInPath("codex") !== null;
19031
+ const os67 = createOsStrategy();
19032
+ return os67.findInPath("codex") !== null;
19033
19033
  },
19034
19034
  launch() {
19035
19035
  return (0, import_node_child_process3.spawn)("codex", ["login"], { stdio: "inherit" });
@@ -19052,8 +19052,8 @@ var CodexRuntimeStrategy = class {
19052
19052
  meta = getAgent("codex");
19053
19053
  mode = "interactive";
19054
19054
  os;
19055
- constructor(os66) {
19056
- this.os = os66;
19055
+ constructor(os67) {
19056
+ this.os = os67;
19057
19057
  }
19058
19058
  async prepareLaunch() {
19059
19059
  let binary = this.os.findInPath("codex");
@@ -19163,12 +19163,12 @@ var CodexRuntimeStrategy = class {
19163
19163
  });
19164
19164
  }
19165
19165
  };
19166
- function resolveNpm(os66) {
19167
- return os66.id === "win32" ? "npm.cmd" : "npm";
19166
+ function resolveNpm(os67) {
19167
+ return os67.id === "win32" ? "npm.cmd" : "npm";
19168
19168
  }
19169
- async function installCodexViaNpm(os66) {
19169
+ async function installCodexViaNpm(os67) {
19170
19170
  return new Promise((resolve12, reject) => {
19171
- const proc = (0, import_node_child_process4.spawn)(resolveNpm(os66), ["install", "-g", "@openai/codex"], {
19171
+ const proc = (0, import_node_child_process4.spawn)(resolveNpm(os67), ["install", "-g", "@openai/codex"], {
19172
19172
  stdio: "inherit"
19173
19173
  });
19174
19174
  proc.on("close", (code) => {
@@ -19185,16 +19185,16 @@ async function installCodexViaNpm(os66) {
19185
19185
  });
19186
19186
  });
19187
19187
  }
19188
- function augmentNpmGlobalBin(os66) {
19188
+ function augmentNpmGlobalBin(os67) {
19189
19189
  try {
19190
- const result = (0, import_node_child_process4.spawnSync)(resolveNpm(os66), ["prefix", "-g"], {
19190
+ const result = (0, import_node_child_process4.spawnSync)(resolveNpm(os67), ["prefix", "-g"], {
19191
19191
  stdio: ["ignore", "pipe", "ignore"]
19192
19192
  });
19193
19193
  if (result.status !== 0) return;
19194
19194
  const prefix = result.stdout.toString().trim();
19195
19195
  if (!prefix) return;
19196
- const binDir = os66.id === "win32" ? prefix : path24.join(prefix, "bin");
19197
- os66.augmentPath([binDir]);
19196
+ const binDir = os67.id === "win32" ? prefix : path24.join(prefix, "bin");
19197
+ os67.augmentPath([binDir]);
19198
19198
  } catch {
19199
19199
  }
19200
19200
  }
@@ -19388,10 +19388,10 @@ function manualInstallHint(runner, tools) {
19388
19388
  const argv = osPackageInstallArgv(detectPackageManager(runner), [...tools]);
19389
19389
  return argv ? `\`sudo ${argv.join(" ")}\`` : `your package manager (e.g. \`${pkgs}\`)`;
19390
19390
  }
19391
- function writeUnzipShim(os66, runner) {
19391
+ function writeUnzipShim(os67, runner) {
19392
19392
  const python = ["python3", "python"].find((p2) => runner.which(p2));
19393
19393
  if (!python) return null;
19394
- const dir = os66.scratchPath("codeam-cr-prereq");
19394
+ const dir = os67.scratchPath("codeam-cr-prereq");
19395
19395
  const shim = path26.join(dir, "unzip");
19396
19396
  const script = `#!/bin/sh
19397
19397
  set -e
@@ -19413,9 +19413,9 @@ exec ${python} -m zipfile -e "$archive" "$dest"
19413
19413
  (0, import_node_fs5.chmodSync)(shim, 448);
19414
19414
  return dir;
19415
19415
  }
19416
- async function ensureInstallPrerequisites(os66, deps = {}) {
19416
+ async function ensureInstallPrerequisites(os67, deps = {}) {
19417
19417
  const runner = deps.runner ?? defaultOsRunner;
19418
- const missing = REQUIRED_TOOLS.filter((t2) => os66.findInPath(t2) === null);
19418
+ const missing = REQUIRED_TOOLS.filter((t2) => os67.findInPath(t2) === null);
19419
19419
  if (missing.length === 0) return { ok: true, extraPath: [] };
19420
19420
  log.info(
19421
19421
  "coderabbit",
@@ -19434,10 +19434,10 @@ async function ensureInstallPrerequisites(os66, deps = {}) {
19434
19434
  );
19435
19435
  }
19436
19436
  }
19437
- const stillMissing = REQUIRED_TOOLS.filter((t2) => os66.findInPath(t2) === null);
19437
+ const stillMissing = REQUIRED_TOOLS.filter((t2) => os67.findInPath(t2) === null);
19438
19438
  if (stillMissing.length === 0) return { ok: true, extraPath: [] };
19439
19439
  if (stillMissing.length === 1 && stillMissing[0] === "unzip") {
19440
- const shimDir = writeUnzipShim(os66, runner);
19440
+ const shimDir = writeUnzipShim(os67, runner);
19441
19441
  if (shimDir) {
19442
19442
  log.info("coderabbit", "unzip is unavailable \u2014 using a scoped python zipfile shim");
19443
19443
  return { ok: true, extraPath: [shimDir] };
@@ -19500,15 +19500,15 @@ function summarizeInstallFailure(output) {
19500
19500
  }
19501
19501
  return lines.length > 0 ? lines[lines.length - 1] : null;
19502
19502
  }
19503
- async function ensureCoderabbitInstalled(os66, deps = {}) {
19504
- if (os66.findInPath("coderabbit")) return { ok: true };
19505
- if (os66.id === "win32") {
19503
+ async function ensureCoderabbitInstalled(os67, deps = {}) {
19504
+ if (os67.findInPath("coderabbit")) return { ok: true };
19505
+ if (os67.id === "win32") {
19506
19506
  return {
19507
19507
  ok: false,
19508
19508
  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."
19509
19509
  };
19510
19510
  }
19511
- const prereq = await ensureInstallPrerequisites(os66, deps);
19511
+ const prereq = await ensureInstallPrerequisites(os67, deps);
19512
19512
  if (!prereq.ok) return { ok: false, error: prereq.error };
19513
19513
  const env = { ...process.env };
19514
19514
  if (prereq.extraPath.length > 0) {
@@ -19517,8 +19517,8 @@ async function ensureCoderabbitInstalled(os66, deps = {}) {
19517
19517
  log.info("coderabbit", "CodeRabbit CLI not found \u2014 installing via the official script");
19518
19518
  const run = deps.runInstallScript ?? defaultRunInstallScript;
19519
19519
  const { code, output } = await run(env);
19520
- os66.augmentPath([`${os66.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
19521
- const binary = os66.findInPath("coderabbit");
19520
+ os67.augmentPath([`${os67.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
19521
+ const binary = os67.findInPath("coderabbit");
19522
19522
  const detail = summarizeInstallFailure(output);
19523
19523
  if (binary !== null) {
19524
19524
  if (code === 0) return { ok: true };
@@ -19572,10 +19572,10 @@ function coderabbitCredentialLocator() {
19572
19572
  validate: validateNonEmptyCredential
19573
19573
  };
19574
19574
  }
19575
- function coderabbitLoginLauncher(os66) {
19575
+ function coderabbitLoginLauncher(os67) {
19576
19576
  return {
19577
19577
  async ensureInstalled() {
19578
- const result = await ensureCoderabbitInstalled(os66);
19578
+ const result = await ensureCoderabbitInstalled(os67);
19579
19579
  if (!result.ok && result.error) console.error(`
19580
19580
  \u2717 ${result.error}
19581
19581
  `);
@@ -19635,8 +19635,8 @@ function pickLine(obj) {
19635
19635
  function toHunk(raw, groupSeverity) {
19636
19636
  if (!raw || typeof raw !== "object") return null;
19637
19637
  const o = raw;
19638
- const path97 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
19639
- if (!path97) return null;
19638
+ const path98 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
19639
+ if (!path98) return null;
19640
19640
  const message = asString(
19641
19641
  pick(o, [
19642
19642
  "comment",
@@ -19653,7 +19653,7 @@ function toHunk(raw, groupSeverity) {
19653
19653
  const severity = normSeverity(pick(o, ["severity", "level", "priority", "impact"])) ?? normSeverity(groupSeverity);
19654
19654
  const locObj = pick(o, ["location"]) ?? o;
19655
19655
  return {
19656
- path: path97.trim(),
19656
+ path: path98.trim(),
19657
19657
  line: pickLine(o) ?? pickLine(locObj),
19658
19658
  severity,
19659
19659
  message: (title && message ? `${title}: ${message}` : title || message).trim() || "(no message)"
@@ -19736,10 +19736,10 @@ function parsePlain(stdout) {
19736
19736
  for (const line of stdout.split(/\r?\n/)) {
19737
19737
  const m = line.match(HUNK_LINE_RE);
19738
19738
  if (!m) continue;
19739
- const [, path97, lineNo, sevToken, message] = m;
19740
- if (!path97 || !lineNo || !message) continue;
19739
+ const [, path98, lineNo, sevToken, message] = m;
19740
+ if (!path98 || !lineNo || !message) continue;
19741
19741
  hunks.push({
19742
- path: path97.trim(),
19742
+ path: path98.trim(),
19743
19743
  line: Number(lineNo),
19744
19744
  severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
19745
19745
  message: message.trim().replace(/^[*-]\s+/, "")
@@ -19799,8 +19799,8 @@ var CoderabbitRuntimeStrategy = class {
19799
19799
  meta = getAgent("coderabbit");
19800
19800
  mode = "batch";
19801
19801
  os;
19802
- constructor(os66) {
19803
- this.os = os66;
19802
+ constructor(os67) {
19803
+ this.os = os67;
19804
19804
  }
19805
19805
  getDefaultArgs() {
19806
19806
  return ["review", "--agent"];
@@ -20071,10 +20071,10 @@ function cursorCredentialLocator() {
20071
20071
  validate: validateNonEmptyCredential
20072
20072
  };
20073
20073
  }
20074
- function cursorLoginLauncher(os66) {
20074
+ function cursorLoginLauncher(os67) {
20075
20075
  return {
20076
20076
  async ensureInstalled() {
20077
- if (os66.findInPath("cursor-agent")) return true;
20077
+ if (os67.findInPath("cursor-agent")) return true;
20078
20078
  console.error(
20079
20079
  "\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"
20080
20080
  );
@@ -20138,8 +20138,8 @@ var CursorRuntimeStrategy = class {
20138
20138
  meta = getAgent("cursor");
20139
20139
  mode = "interactive";
20140
20140
  os;
20141
- constructor(os66) {
20142
- this.os = os66;
20141
+ constructor(os67) {
20142
+ this.os = os67;
20143
20143
  }
20144
20144
  async prepareLaunch() {
20145
20145
  const binary = this.os.findInPath("cursor-agent");
@@ -20356,10 +20356,10 @@ function aiderCredentialLocator() {
20356
20356
  validate: validateNonEmptyCredential
20357
20357
  };
20358
20358
  }
20359
- function aiderLoginLauncher(os66) {
20359
+ function aiderLoginLauncher(os67) {
20360
20360
  return {
20361
20361
  async ensureInstalled() {
20362
- if (os66.findInPath("aider")) return true;
20362
+ if (os67.findInPath("aider")) return true;
20363
20363
  console.error(
20364
20364
  "\n \u2717 aider binary not on PATH.\n Install Aider:\n pip install aider-chat\n then re-run `codeam link aider`.\n"
20365
20365
  );
@@ -20369,7 +20369,7 @@ function aiderLoginLauncher(os66) {
20369
20369
  console.error(
20370
20370
  "\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"
20371
20371
  );
20372
- return (0, import_node_child_process11.spawn)(os66.id === "win32" ? "cmd.exe" : "sh", os66.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
20372
+ return (0, import_node_child_process11.spawn)(os67.id === "win32" ? "cmd.exe" : "sh", os67.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
20373
20373
  stdio: "ignore"
20374
20374
  });
20375
20375
  }
@@ -20458,14 +20458,14 @@ function defaultSdkDir() {
20458
20458
  return resolveSdkDirViaRequire();
20459
20459
  }
20460
20460
  function resolveClaudeNativeBinary(deps = {}) {
20461
- const existsSync30 = deps.existsSync ?? import_fs.default.existsSync;
20461
+ const existsSync31 = deps.existsSync ?? import_fs.default.existsSync;
20462
20462
  const platformKey = deps.platformKey ?? currentPlatformKey();
20463
20463
  const sdkDir = deps.sdkDir !== void 0 ? deps.sdkDir : defaultSdkDir();
20464
20464
  if (!sdkDir) return null;
20465
20465
  const scopeDir = import_path4.default.dirname(sdkDir);
20466
20466
  const binName = platformKey.startsWith("win32-") ? "claude.exe" : "claude";
20467
20467
  const candidate = import_path4.default.join(scopeDir, `claude-agent-sdk-${platformKey}`, binName);
20468
- return existsSync30(candidate) ? candidate : null;
20468
+ return existsSync31(candidate) ? candidate : null;
20469
20469
  }
20470
20470
  var realSleep = (ms) => new Promise((resolve12) => setTimeout(resolve12, ms));
20471
20471
  async function waitForClaudeNativeBinary(opts = {}) {
@@ -20547,18 +20547,18 @@ function augmentUserLocalBinPaths(deps = {}) {
20547
20547
  env.PATH = [...additions, ...parts].join(p2.delimiter);
20548
20548
  }
20549
20549
  function resolveCursorAgentBinary(deps = {}) {
20550
- const existsSync30 = deps.existsSync ?? import_fs.default.existsSync;
20550
+ const existsSync31 = deps.existsSync ?? import_fs.default.existsSync;
20551
20551
  const platform3 = deps.platform ?? process.platform;
20552
20552
  const env = deps.env ?? process.env;
20553
20553
  if (platform3 === "win32") {
20554
20554
  const localAppData = env.LOCALAPPDATA;
20555
20555
  if (!localAppData) return null;
20556
20556
  const exe = import_path4.default.win32.join(localAppData, "cursor-agent", "cursor-agent.exe");
20557
- return existsSync30(exe) ? exe : null;
20557
+ return existsSync31(exe) ? exe : null;
20558
20558
  }
20559
20559
  const home = deps.homedir ?? import_os4.default.homedir();
20560
20560
  const unix = import_path4.default.posix.join(home, ".local", "bin", "cursor-agent");
20561
- return existsSync30(unix) ? unix : null;
20561
+ return existsSync31(unix) ? unix : null;
20562
20562
  }
20563
20563
  async function waitForCursorAgent(opts = {}) {
20564
20564
  const timeoutMs = opts.timeoutMs ?? 18e4;
@@ -20644,8 +20644,8 @@ var AiderRuntimeStrategy = class {
20644
20644
  meta = getAgent("aider");
20645
20645
  mode = "interactive";
20646
20646
  os;
20647
- constructor(os66) {
20648
- this.os = os66;
20647
+ constructor(os67) {
20648
+ this.os = os67;
20649
20649
  }
20650
20650
  async prepareLaunch() {
20651
20651
  augmentUserLocalBinPaths();
@@ -20778,8 +20778,8 @@ function geminiCredentialLocator() {
20778
20778
  function geminiLoginLauncher() {
20779
20779
  return {
20780
20780
  async ensureInstalled() {
20781
- const os66 = createOsStrategy();
20782
- return os66.findInPath("gemini") !== null;
20781
+ const os67 = createOsStrategy();
20782
+ return os67.findInPath("gemini") !== null;
20783
20783
  },
20784
20784
  launch() {
20785
20785
  return (0, import_node_child_process12.spawn)("gemini", ["auth", "login"], { stdio: "inherit" });
@@ -20969,8 +20969,8 @@ var GeminiRuntimeStrategy = class {
20969
20969
  meta = getAgent("gemini");
20970
20970
  mode = "interactive";
20971
20971
  os;
20972
- constructor(os66) {
20973
- this.os = os66;
20972
+ constructor(os67) {
20973
+ this.os = os67;
20974
20974
  }
20975
20975
  async prepareLaunch() {
20976
20976
  const binary = this.os.findInPath("gemini");
@@ -21262,8 +21262,8 @@ var KimiRuntimeStrategy = class {
21262
21262
  meta = getAgent("kimi");
21263
21263
  mode = "interactive";
21264
21264
  os;
21265
- constructor(os66) {
21266
- this.os = os66;
21265
+ constructor(os67) {
21266
+ this.os = os67;
21267
21267
  }
21268
21268
  async prepareLaunch() {
21269
21269
  const binary = this.os.findInPath("kimi");
@@ -21406,8 +21406,8 @@ var OpencodeRuntimeStrategy = class {
21406
21406
  meta = getAgent("opencode");
21407
21407
  mode = "interactive";
21408
21408
  os;
21409
- constructor(os66) {
21410
- this.os = os66;
21409
+ constructor(os67) {
21410
+ this.os = os67;
21411
21411
  }
21412
21412
  async prepareLaunch() {
21413
21413
  const binary = this.os.findInPath("opencode");
@@ -21492,20 +21492,20 @@ var OpencodeRuntimeStrategy = class {
21492
21492
 
21493
21493
  // src/agents/registry.ts
21494
21494
  var runtimeBuilders = {
21495
- claude: (os66) => new ClaudeRuntimeStrategy(os66),
21496
- codex: (os66) => new CodexRuntimeStrategy(os66),
21497
- coderabbit: (os66) => new CoderabbitRuntimeStrategy(os66),
21498
- cursor: (os66) => new CursorRuntimeStrategy(os66),
21499
- aider: (os66) => new AiderRuntimeStrategy(os66),
21500
- gemini: (os66) => new GeminiRuntimeStrategy(os66),
21501
- kimi: (os66) => new KimiRuntimeStrategy(os66),
21502
- opencode: (os66) => new OpencodeRuntimeStrategy(os66)
21495
+ claude: (os67) => new ClaudeRuntimeStrategy(os67),
21496
+ codex: (os67) => new CodexRuntimeStrategy(os67),
21497
+ coderabbit: (os67) => new CoderabbitRuntimeStrategy(os67),
21498
+ cursor: (os67) => new CursorRuntimeStrategy(os67),
21499
+ aider: (os67) => new AiderRuntimeStrategy(os67),
21500
+ gemini: (os67) => new GeminiRuntimeStrategy(os67),
21501
+ kimi: (os67) => new KimiRuntimeStrategy(os67),
21502
+ opencode: (os67) => new OpencodeRuntimeStrategy(os67)
21503
21503
  };
21504
21504
  var deployBuilders = {
21505
21505
  claude: () => new ClaudeDeployStrategy(),
21506
21506
  codex: () => new CodexDeployStrategy()
21507
21507
  };
21508
- function createAgentStrategy(agent, os66 = createOsStrategy()) {
21508
+ function createAgentStrategy(agent, os67 = createOsStrategy()) {
21509
21509
  if (!AGENT_REGISTRY[agent]?.enabled) {
21510
21510
  throw new Error(
21511
21511
  `Agent "${agent}" is not supported in this codeam-cli version. Upgrade with 'npm i -g codeam-cli@latest'.`
@@ -21515,10 +21515,10 @@ function createAgentStrategy(agent, os66 = createOsStrategy()) {
21515
21515
  if (!build) {
21516
21516
  throw new Error(`No runtime strategy registered for agent "${agent}"`);
21517
21517
  }
21518
- return build(os66);
21518
+ return build(os67);
21519
21519
  }
21520
- function createInteractiveAgentStrategy(agent, os66 = createOsStrategy()) {
21521
- const s = createAgentStrategy(agent, os66);
21520
+ function createInteractiveAgentStrategy(agent, os67 = createOsStrategy()) {
21521
+ const s = createAgentStrategy(agent, os67);
21522
21522
  if (s.mode !== "interactive") {
21523
21523
  throw new Error(
21524
21524
  `Agent "${agent}" is a batch agent; use createAgentStrategy + .runOneShot for one-shot reviews.`
@@ -22232,8 +22232,8 @@ function collectChangedFiles(cwd) {
22232
22232
  }
22233
22233
  return [...byPath.values()];
22234
22234
  }
22235
- function restoreCoderabbitOauthBlob(os66, value) {
22236
- const dir = path38.join(os66.homeDir(), ".coderabbit");
22235
+ function restoreCoderabbitOauthBlob(os67, value) {
22236
+ const dir = path38.join(os67.homeDir(), ".coderabbit");
22237
22237
  (0, import_node_fs6.mkdirSync)(dir, { recursive: true });
22238
22238
  let file = "auth.json";
22239
22239
  let contents = value.trim();
@@ -22253,26 +22253,26 @@ function installFailureMessage(result) {
22253
22253
  return result.error ?? "CodeRabbit CLI could not be installed";
22254
22254
  }
22255
22255
  async function configureCoderabbit(input, deps = {}) {
22256
- const os66 = deps.os ?? createOsStrategy();
22256
+ const os67 = deps.os ?? createOsStrategy();
22257
22257
  const ensureInstalled = deps.ensureInstalled ?? ensureCoderabbitInstalled;
22258
22258
  const isLoggedIn = deps.isLoggedIn ?? defaultIsLoggedIn;
22259
22259
  const runOAuth = deps.runOAuthLogin ?? runCoderabbitOAuthLogin;
22260
22260
  const snapshot = deps.snapshotDir ?? (() => snapshotCredentialDir());
22261
22261
  const capture2 = deps.captureCredential ?? ((b) => diffCapturedCredential(b));
22262
22262
  const loginWithApiKey = deps.loginWithApiKey ?? defaultLoginWithApiKey;
22263
- const home = os66.homeDir();
22264
- os66.augmentPath(
22265
- os66.id === "win32" ? [
22263
+ const home = os67.homeDir();
22264
+ os67.augmentPath(
22265
+ os67.id === "win32" ? [
22266
22266
  path38.join(home, ".local", "bin"),
22267
22267
  path38.join(process.env.APPDATA ?? path38.join(home, "AppData", "Roaming"), "npm"),
22268
22268
  path38.join(home, "scoop", "shims")
22269
22269
  ] : [path38.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"]
22270
22270
  );
22271
- const installed2 = os66.findInPath("coderabbit") !== null;
22271
+ const installed2 = os67.findInPath("coderabbit") !== null;
22272
22272
  const base = () => ({
22273
22273
  action: input.action,
22274
22274
  supported: true,
22275
- installed: os66.findInPath("coderabbit") !== null,
22275
+ installed: os67.findInPath("coderabbit") !== null,
22276
22276
  loggedIn: false
22277
22277
  });
22278
22278
  if (input.action === "status") {
@@ -22286,7 +22286,7 @@ async function configureCoderabbit(input, deps = {}) {
22286
22286
  const key = (input.apiKey ?? "").trim();
22287
22287
  if (!key) return { ...res2, error: "No API key provided" };
22288
22288
  if (!res2.installed) {
22289
- const inst = await ensureInstalled(os66);
22289
+ const inst = await ensureInstalled(os67);
22290
22290
  res2.installed = inst.ok;
22291
22291
  if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
22292
22292
  }
@@ -22310,7 +22310,7 @@ async function configureCoderabbit(input, deps = {}) {
22310
22310
  }
22311
22311
  if (!res2.installed) {
22312
22312
  deps.onEvent?.({ kind: "installing" });
22313
- const inst = await ensureInstalled(os66);
22313
+ const inst = await ensureInstalled(os67);
22314
22314
  res2.installed = inst.ok;
22315
22315
  if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
22316
22316
  }
@@ -22327,7 +22327,7 @@ async function configureCoderabbit(input, deps = {}) {
22327
22327
  return { ...res2, loggedIn: true, linked: true };
22328
22328
  }
22329
22329
  try {
22330
- restoreCoderabbitOauthBlob(os66, cred.credential);
22330
+ restoreCoderabbitOauthBlob(os67, cred.credential);
22331
22331
  } catch (err) {
22332
22332
  return {
22333
22333
  ...res2,
@@ -22351,7 +22351,7 @@ async function configureCoderabbit(input, deps = {}) {
22351
22351
  const res2 = base();
22352
22352
  if (!installed2) {
22353
22353
  deps.onEvent?.({ kind: "installing" });
22354
- const inst = await ensureInstalled(os66);
22354
+ const inst = await ensureInstalled(os67);
22355
22355
  res2.installed = inst.ok;
22356
22356
  if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
22357
22357
  }
@@ -22391,7 +22391,7 @@ async function configureCoderabbit(input, deps = {}) {
22391
22391
  }
22392
22392
  const res = base();
22393
22393
  if (!res.installed) {
22394
- const inst = await ensureInstalled(os66);
22394
+ const inst = await ensureInstalled(os67);
22395
22395
  res.installed = inst.ok;
22396
22396
  if (!inst.ok) return { ...res, error: installFailureMessage(inst) };
22397
22397
  }
@@ -23344,7 +23344,7 @@ function tryParseObject(s) {
23344
23344
  function extractFirstJsonObject(s) {
23345
23345
  const start2 = s.indexOf("{");
23346
23346
  if (start2 < 0) return null;
23347
- let depth = 0;
23347
+ let depth2 = 0;
23348
23348
  let inString = false;
23349
23349
  let escaped = false;
23350
23350
  for (let i = start2; i < s.length; i += 1) {
@@ -23365,10 +23365,10 @@ function extractFirstJsonObject(s) {
23365
23365
  inString = true;
23366
23366
  continue;
23367
23367
  }
23368
- if (c2 === "{") depth += 1;
23368
+ if (c2 === "{") depth2 += 1;
23369
23369
  else if (c2 === "}") {
23370
- depth -= 1;
23371
- if (depth === 0) return s.slice(start2, i + 1);
23370
+ depth2 -= 1;
23371
+ if (depth2 === 0) return s.slice(start2, i + 1);
23372
23372
  }
23373
23373
  }
23374
23374
  return null;
@@ -25779,11 +25779,11 @@ function resolveDoltInstallStrategy(platform3) {
25779
25779
  }
25780
25780
  var DOLT_RELEASE_BASE = "https://github.com/dolthub/dolt/releases/latest/download";
25781
25781
  function doltPlatformTuple(platform3, arch2) {
25782
- const os66 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
25782
+ const os67 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
25783
25783
  const a = arch2 === "x64" ? "amd64" : arch2 === "arm64" ? "arm64" : null;
25784
25784
  if (!a) return null;
25785
- if (os66 === "windows" && a !== "amd64") return null;
25786
- return `${os66}-${a}`;
25785
+ if (os67 === "windows" && a !== "amd64") return null;
25786
+ return `${os67}-${a}`;
25787
25787
  }
25788
25788
  function resolveDoltTarballStrategy(targetDir, platform3, arch2) {
25789
25789
  const tuple = doltPlatformTuple(platform3, arch2);
@@ -27472,7 +27472,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
27472
27472
  });
27473
27473
  const token = ctx.pluginAuthToken;
27474
27474
  void (async () => {
27475
- const os66 = createOsStrategy();
27475
+ const os67 = createOsStrategy();
27476
27476
  try {
27477
27477
  const report = await reviewPullRequest(
27478
27478
  {
@@ -27481,7 +27481,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
27481
27481
  baseBranch: parsed.baseBranch
27482
27482
  },
27483
27483
  {
27484
- runReview: (input) => new CoderabbitRuntimeStrategy(os66).runOneShot(input),
27484
+ runReview: (input) => new CoderabbitRuntimeStrategy(os67).runOneShot(input),
27485
27485
  runGh: (args2) => defaultRunGh(args2),
27486
27486
  postReport: async (r) => {
27487
27487
  if (!token) return;
@@ -27621,7 +27621,7 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
27621
27621
  if (!nodeModulesDir) return 0;
27622
27622
  const readdirSync14 = deps?.readdirSync ?? fs51.readdirSync;
27623
27623
  const statSync15 = deps?.statSync ?? fs51.statSync;
27624
- const rmSync9 = deps?.rmSync ?? fs51.rmSync;
27624
+ const rmSync10 = deps?.rmSync ?? fs51.rmSync;
27625
27625
  let removed = 0;
27626
27626
  let entries;
27627
27627
  try {
@@ -27635,7 +27635,7 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
27635
27635
  try {
27636
27636
  const st3 = statSync15(full);
27637
27637
  if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
27638
- rmSync9(full, { recursive: true, force: true });
27638
+ rmSync10(full, { recursive: true, force: true });
27639
27639
  removed++;
27640
27640
  } catch {
27641
27641
  }
@@ -28661,11 +28661,11 @@ function resolveTokenValue(args2) {
28661
28661
  }
28662
28662
  const fileFlag = args2.find((a) => a.startsWith("--token-file="));
28663
28663
  if (fileFlag) {
28664
- const path97 = fileFlag.slice("--token-file=".length);
28664
+ const path98 = fileFlag.slice("--token-file=".length);
28665
28665
  try {
28666
- const content = fs52.readFileSync(path97, "utf8").trim();
28667
- if (content.length === 0) fail(`--token-file ${path97} is empty`);
28668
- rmIfExistsQuiet(path97);
28666
+ const content = fs52.readFileSync(path98, "utf8").trim();
28667
+ if (content.length === 0) fail(`--token-file ${path98} is empty`);
28668
+ rmIfExistsQuiet(path98);
28669
28669
  return content;
28670
28670
  } catch (err) {
28671
28671
  fail(`Could not read --token-file: ${err.message}`);
@@ -29758,9 +29758,9 @@ async function prepareWorkspace(repoOrPath, deployId, cloneToken, provider = "gi
29758
29758
 
29759
29759
  // src/agents/acp/runner.ts
29760
29760
  var import_node_crypto11 = require("crypto");
29761
- var fs71 = __toESM(require("fs"));
29762
- var os55 = __toESM(require("os"));
29763
- var path82 = __toESM(require("path"));
29761
+ var fs72 = __toESM(require("fs"));
29762
+ var os56 = __toESM(require("os"));
29763
+ var path83 = __toESM(require("path"));
29764
29764
 
29765
29765
  // src/lib/provider-routing.ts
29766
29766
  var fs55 = __toESM(require("fs"));
@@ -37937,15 +37937,15 @@ function defaultRunGit(cwd, args2) {
37937
37937
  });
37938
37938
  }
37939
37939
  async function discoverRepos(workingDir, maxDepth = 4) {
37940
- const fs82 = await import("fs/promises");
37940
+ const fs83 = await import("fs/promises");
37941
37941
  const out2 = [];
37942
37942
  await walk(workingDir, 0);
37943
37943
  return out2;
37944
- async function walk(dir, depth) {
37945
- if (depth > maxDepth) return;
37944
+ async function walk(dir, depth2) {
37945
+ if (depth2 > maxDepth) return;
37946
37946
  let entries = [];
37947
37947
  try {
37948
- const dirents = await fs82.readdir(dir, { withFileTypes: true });
37948
+ const dirents = await fs83.readdir(dir, { withFileTypes: true });
37949
37949
  entries = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
37950
37950
  } catch {
37951
37951
  return;
@@ -37965,7 +37965,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
37965
37965
  if (!entry.isDirectory) continue;
37966
37966
  if (entry.name === "node_modules") continue;
37967
37967
  if (entry.name === "dist" || entry.name === "build") continue;
37968
- await walk(path74.join(dir, entry.name), depth + 1);
37968
+ await walk(path74.join(dir, entry.name), depth2 + 1);
37969
37969
  }
37970
37970
  }
37971
37971
  }
@@ -38680,10 +38680,52 @@ async function postCredentialSync(opts, fetchImpl = fetch) {
38680
38680
  }
38681
38681
  }
38682
38682
 
38683
- // src/packs/gates.ts
38684
- var import_node_child_process23 = require("child_process");
38683
+ // src/services/turn-marker.ts
38685
38684
  var fs65 = __toESM(require("fs"));
38685
+ var os52 = __toESM(require("os"));
38686
38686
  var path76 = __toESM(require("path"));
38687
+ var depth = 0;
38688
+ function codeamHome() {
38689
+ return path76.join(os52.homedir(), ".codeam");
38690
+ }
38691
+ function turnMarkerPath(pid = process.pid, home = codeamHome()) {
38692
+ return path76.join(home, "turns", String(pid));
38693
+ }
38694
+ function mark() {
38695
+ try {
38696
+ const file = turnMarkerPath();
38697
+ fs65.mkdirSync(path76.dirname(file), { recursive: true });
38698
+ fs65.writeFileSync(file, String(Date.now()));
38699
+ } catch {
38700
+ }
38701
+ }
38702
+ function clear() {
38703
+ try {
38704
+ fs65.rmSync(turnMarkerPath(), { force: true });
38705
+ } catch {
38706
+ }
38707
+ }
38708
+ async function withTurnMarker(fn) {
38709
+ if (depth++ === 0) mark();
38710
+ try {
38711
+ return await fn();
38712
+ } finally {
38713
+ if (--depth === 0) clear();
38714
+ }
38715
+ }
38716
+ function isProcessMidTurn(pid, home) {
38717
+ if (!pid) return false;
38718
+ try {
38719
+ return fs65.existsSync(turnMarkerPath(pid, home));
38720
+ } catch {
38721
+ return false;
38722
+ }
38723
+ }
38724
+
38725
+ // src/packs/gates.ts
38726
+ var import_node_child_process23 = require("child_process");
38727
+ var fs66 = __toESM(require("fs"));
38728
+ var path77 = __toESM(require("path"));
38687
38729
  var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((resolve12) => {
38688
38730
  (0, import_node_child_process23.execFile)(
38689
38731
  file,
@@ -38733,7 +38775,7 @@ async function changedFiles(run, cwd, from, to) {
38733
38775
  }
38734
38776
  function readWorkspaceFile(cwd, relPath) {
38735
38777
  try {
38736
- return fs65.readFileSync(path76.join(cwd, relPath), "utf8");
38778
+ return fs66.readFileSync(path77.join(cwd, relPath), "utf8");
38737
38779
  } catch {
38738
38780
  return null;
38739
38781
  }
@@ -38742,14 +38784,14 @@ var NO_TEST_PLACEHOLDER = 'echo "Error: no test specified"';
38742
38784
  var CHECKS_TIMEOUT_MS = 5 * 6e4;
38743
38785
  function detectChecksCommand(cwd) {
38744
38786
  try {
38745
- const cfg = JSON.parse(fs65.readFileSync(path76.join(cwd, ".codeam", "pack.json"), "utf8"));
38787
+ const cfg = JSON.parse(fs66.readFileSync(path77.join(cwd, ".codeam", "pack.json"), "utf8"));
38746
38788
  if (typeof cfg.checksCommand === "string" && cfg.checksCommand.trim().length > 0) {
38747
38789
  return cfg.checksCommand.trim();
38748
38790
  }
38749
38791
  } catch {
38750
38792
  }
38751
38793
  try {
38752
- const pkg = JSON.parse(fs65.readFileSync(path76.join(cwd, "package.json"), "utf8"));
38794
+ const pkg = JSON.parse(fs66.readFileSync(path77.join(cwd, "package.json"), "utf8"));
38753
38795
  const test = pkg.scripts?.test;
38754
38796
  if (typeof test === "string" && test.trim().length > 0 && !test.includes(NO_TEST_PLACEHOLDER)) {
38755
38797
  return "npm test";
@@ -38767,39 +38809,39 @@ ${res.stderr}`.trim();
38767
38809
  }
38768
38810
 
38769
38811
  // src/packs/run-store.ts
38770
- var fs66 = __toESM(require("fs"));
38771
- var path77 = __toESM(require("path"));
38812
+ var fs67 = __toESM(require("fs"));
38813
+ var path78 = __toESM(require("path"));
38772
38814
  var crypto5 = __toESM(require("crypto"));
38773
38815
  function packsDir(cwd) {
38774
- return path77.join(cwd, ".codeam", "packs");
38816
+ return path78.join(cwd, ".codeam", "packs");
38775
38817
  }
38776
38818
  function runDir(cwd, runId) {
38777
- return path77.join(packsDir(cwd), runId);
38819
+ return path78.join(packsDir(cwd), runId);
38778
38820
  }
38779
38821
  function newRunId() {
38780
38822
  return `pk_${Date.now().toString(36)}_${crypto5.randomBytes(4).toString("hex")}`;
38781
38823
  }
38782
38824
  function writeJsonAtomic(file, value) {
38783
- fs66.mkdirSync(path77.dirname(file), { recursive: true });
38825
+ fs67.mkdirSync(path78.dirname(file), { recursive: true });
38784
38826
  const tmp = `${file}.tmp`;
38785
- fs66.writeFileSync(tmp, JSON.stringify(value, null, 2));
38786
- fs66.renameSync(tmp, file);
38827
+ fs67.writeFileSync(tmp, JSON.stringify(value, null, 2));
38828
+ fs67.renameSync(tmp, file);
38787
38829
  }
38788
38830
  function saveRun(cwd, state) {
38789
- writeJsonAtomic(path77.join(runDir(cwd, state.runId), "run.json"), state);
38831
+ writeJsonAtomic(path78.join(runDir(cwd, state.runId), "run.json"), state);
38790
38832
  }
38791
38833
  function saveStageHandoff(cwd, runId, stageIndex, role, handoff) {
38792
38834
  const name = `${String(stageIndex + 1).padStart(2, "0")}-${role}.json`;
38793
- writeJsonAtomic(path77.join(runDir(cwd, runId), name), handoff);
38835
+ writeJsonAtomic(path78.join(runDir(cwd, runId), name), handoff);
38794
38836
  }
38795
38837
  function loadLatestRun(cwd) {
38796
38838
  try {
38797
38839
  const dir = packsDir(cwd);
38798
- const entries = fs66.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
38840
+ const entries = fs67.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
38799
38841
  for (let i = entries.length - 1; i >= 0; i--) {
38800
- const file = path77.join(dir, entries[i], "run.json");
38842
+ const file = path78.join(dir, entries[i], "run.json");
38801
38843
  try {
38802
- const parsed = JSON.parse(fs66.readFileSync(file, "utf8"));
38844
+ const parsed = JSON.parse(fs67.readFileSync(file, "utf8"));
38803
38845
  if (parsed && typeof parsed.runId === "string") return parsed;
38804
38846
  } catch {
38805
38847
  }
@@ -38810,17 +38852,17 @@ function loadLatestRun(cwd) {
38810
38852
  }
38811
38853
  function ensureLedgerIgnored(cwd) {
38812
38854
  try {
38813
- const gitDir = path77.join(cwd, ".git");
38814
- if (!fs66.existsSync(gitDir)) return;
38815
- const exclude = path77.join(gitDir, "info", "exclude");
38855
+ const gitDir = path78.join(cwd, ".git");
38856
+ if (!fs67.existsSync(gitDir)) return;
38857
+ const exclude = path78.join(gitDir, "info", "exclude");
38816
38858
  let existing = "";
38817
38859
  try {
38818
- existing = fs66.readFileSync(exclude, "utf8");
38860
+ existing = fs67.readFileSync(exclude, "utf8");
38819
38861
  } catch {
38820
38862
  }
38821
38863
  if (existing.includes(".codeam/packs/")) return;
38822
- fs66.mkdirSync(path77.dirname(exclude), { recursive: true });
38823
- fs66.writeFileSync(exclude, `${existing.trimEnd()}
38864
+ fs67.mkdirSync(path78.dirname(exclude), { recursive: true });
38865
+ fs67.writeFileSync(exclude, `${existing.trimEnd()}
38824
38866
  .codeam/packs/
38825
38867
  `.trimStart());
38826
38868
  } catch {
@@ -39801,20 +39843,20 @@ async function mcpRouter() {
39801
39843
  }
39802
39844
 
39803
39845
  // src/integrations/mcp-secrets.ts
39804
- var fs68 = __toESM(require("fs"));
39805
- var os53 = __toESM(require("os"));
39806
- var path79 = __toESM(require("path"));
39846
+ var fs69 = __toESM(require("fs"));
39847
+ var os54 = __toESM(require("os"));
39848
+ var path80 = __toESM(require("path"));
39807
39849
  var MCP_SECRETS_FILE_ENV = "CODEAM_MCP_SECRETS_FILE";
39808
39850
  function mcpSecretsDir() {
39809
- return path79.join(os53.homedir(), ".codeam", "mcp-secrets");
39851
+ return path80.join(os54.homedir(), ".codeam", "mcp-secrets");
39810
39852
  }
39811
39853
  function mcpSecretsPath(scope, pid = process.pid) {
39812
- return path79.join(mcpSecretsDir(), `${pid}-${scope}.json`);
39854
+ return path80.join(mcpSecretsDir(), `${pid}-${scope}.json`);
39813
39855
  }
39814
39856
  var registeredForCleanup = /* @__PURE__ */ new Set();
39815
39857
  function readFileVars(file) {
39816
39858
  try {
39817
- const parsed = JSON.parse(fs68.readFileSync(file, "utf8"));
39859
+ const parsed = JSON.parse(fs69.readFileSync(file, "utf8"));
39818
39860
  if (!parsed || typeof parsed !== "object") return {};
39819
39861
  const out2 = {};
39820
39862
  for (const [k2, v] of Object.entries(parsed)) {
@@ -39836,7 +39878,7 @@ function pidAlive(pid) {
39836
39878
  function pruneStale(dir) {
39837
39879
  let names = [];
39838
39880
  try {
39839
- names = fs68.readdirSync(dir);
39881
+ names = fs69.readdirSync(dir);
39840
39882
  } catch {
39841
39883
  return;
39842
39884
  }
@@ -39846,25 +39888,25 @@ function pruneStale(dir) {
39846
39888
  const pid = Number(m[1]);
39847
39889
  if (pid === process.pid || pidAlive(pid)) continue;
39848
39890
  try {
39849
- fs68.unlinkSync(path79.join(dir, name));
39891
+ fs69.unlinkSync(path80.join(dir, name));
39850
39892
  } catch {
39851
39893
  }
39852
39894
  }
39853
39895
  }
39854
39896
  function writeMcpSecrets(vars, file) {
39855
39897
  try {
39856
- const dir = path79.dirname(file);
39857
- fs68.mkdirSync(dir, { recursive: true, mode: 448 });
39898
+ const dir = path80.dirname(file);
39899
+ fs69.mkdirSync(dir, { recursive: true, mode: 448 });
39858
39900
  pruneStale(dir);
39859
39901
  const tmp = `${file}.${process.pid}.tmp`;
39860
- fs68.writeFileSync(tmp, JSON.stringify(vars), { mode: 384 });
39861
- fs68.renameSync(tmp, file);
39862
- fs68.chmodSync(file, 384);
39902
+ fs69.writeFileSync(tmp, JSON.stringify(vars), { mode: 384 });
39903
+ fs69.renameSync(tmp, file);
39904
+ fs69.chmodSync(file, 384);
39863
39905
  if (!registeredForCleanup.has(file)) {
39864
39906
  registeredForCleanup.add(file);
39865
39907
  process.once("exit", () => {
39866
39908
  try {
39867
- fs68.unlinkSync(file);
39909
+ fs69.unlinkSync(file);
39868
39910
  } catch {
39869
39911
  }
39870
39912
  });
@@ -39950,11 +39992,11 @@ function previewMcpServer(bridge) {
39950
39992
  };
39951
39993
  }
39952
39994
  function httpCall(baseUrl, token) {
39953
- return async (path97, method, body, timeoutMs) => {
39995
+ return async (path98, method, body, timeoutMs) => {
39954
39996
  const ac = new AbortController();
39955
39997
  const timer = setTimeout(() => ac.abort(), timeoutMs);
39956
39998
  try {
39957
- const res = await fetch(`${baseUrl}${path97}`, {
39999
+ const res = await fetch(`${baseUrl}${path98}`, {
39958
40000
  method,
39959
40001
  headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
39960
40002
  ...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
@@ -41725,8 +41767,8 @@ var ACP_COMMAND_HANDLERS = {
41725
41767
  integrations_sync: integrationsSyncH,
41726
41768
  integrations_detect: integrationsDetectH,
41727
41769
  beads_action: beadsActionH,
41728
- start_task: startTaskH,
41729
- group_mention_task: groupMentionTaskH,
41770
+ start_task: (ctx) => withTurnMarker(() => startTaskH(ctx)),
41771
+ group_mention_task: (ctx) => withTurnMarker(() => groupMentionTaskH(ctx)),
41730
41772
  stop_task: stopTaskH,
41731
41773
  escape_key: stopTaskH,
41732
41774
  get_conversation: getConversationH,
@@ -41738,7 +41780,7 @@ var ACP_COMMAND_HANDLERS = {
41738
41780
  select_option: selectOptionH,
41739
41781
  provide_input: provideInputH,
41740
41782
  resume_session: resumeSessionH,
41741
- switch_agent: switchAgentH,
41783
+ switch_agent: (ctx) => withTurnMarker(() => switchAgentH(ctx)),
41742
41784
  change_model: changeModelH,
41743
41785
  summarize: summarizeH,
41744
41786
  session_terminated: sessionShutdownH,
@@ -42850,17 +42892,17 @@ async function runAcpSession(opts) {
42850
42892
  switchCredentialEnv = provisionAgentCredentials(agentId, auth);
42851
42893
  },
42852
42894
  provisionHouseProxy: ({ baseUrl, token, model, managedAgentId }) => {
42853
- const claudeConfigDir = path82.join(
42854
- os55.homedir(),
42895
+ const claudeConfigDir = path83.join(
42896
+ os56.homedir(),
42855
42897
  ".codeam",
42856
42898
  "house-claude",
42857
42899
  `switch-${opts.pluginId}`
42858
42900
  );
42859
42901
  try {
42860
- fs71.mkdirSync(claudeConfigDir, { recursive: true, mode: 448 });
42902
+ fs72.mkdirSync(claudeConfigDir, { recursive: true, mode: 448 });
42861
42903
  } catch {
42862
42904
  }
42863
- const memoryFile = path82.join(claudeConfigDir, "CLAUDE.md");
42905
+ const memoryFile = path83.join(claudeConfigDir, "CLAUDE.md");
42864
42906
  ensureBeadsWorkflowHint(void 0, memoryFile);
42865
42907
  ensureAgentStandard(void 0, memoryFile);
42866
42908
  const cfg = {
@@ -44088,9 +44130,9 @@ function pickPinnedSession(pinnedId, listSessions2) {
44088
44130
  }
44089
44131
 
44090
44132
  // src/agents/retired-proxy-cleanup.ts
44091
- var fs72 = __toESM(require("fs"));
44092
- var path83 = __toESM(require("path"));
44093
- var os56 = __toESM(require("os"));
44133
+ var fs73 = __toESM(require("fs"));
44134
+ var path84 = __toESM(require("path"));
44135
+ var os57 = __toESM(require("os"));
44094
44136
  var RETIRED_PROXY_RE = /^https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):8787(?:[/?#]|$)/i;
44095
44137
  var HEADROOM_CMD_RE = /(^|[\s/"'])headroom(\s|$)/i;
44096
44138
  var MARKETPLACE_KEY = "headroom-marketplace";
@@ -44099,12 +44141,12 @@ function isHeadroomHook(group) {
44099
44141
  (h) => typeof h?.command === "string" && HEADROOM_CMD_RE.test(h.command)
44100
44142
  );
44101
44143
  }
44102
- function sanitizeRetiredProxyConfig(homeDir2 = os56.homedir()) {
44144
+ function sanitizeRetiredProxyConfig(homeDir2 = os57.homedir()) {
44103
44145
  const out2 = { inspected: false, changed: false, removed: [] };
44104
- const file = path83.join(homeDir2, ".claude", "settings.json");
44146
+ const file = path84.join(homeDir2, ".claude", "settings.json");
44105
44147
  let parsed;
44106
44148
  try {
44107
- parsed = JSON.parse(fs72.readFileSync(file, "utf8"));
44149
+ parsed = JSON.parse(fs73.readFileSync(file, "utf8"));
44108
44150
  } catch {
44109
44151
  return out2;
44110
44152
  }
@@ -44146,9 +44188,9 @@ function sanitizeRetiredProxyConfig(homeDir2 = os56.homedir()) {
44146
44188
  if (!out2.changed) return out2;
44147
44189
  try {
44148
44190
  const tmp = `${file}.codeam.tmp`;
44149
- fs72.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
44191
+ fs73.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
44150
44192
  `, { mode: 384 });
44151
- fs72.renameSync(tmp, file);
44193
+ fs73.renameSync(tmp, file);
44152
44194
  } catch {
44153
44195
  out2.changed = false;
44154
44196
  }
@@ -44680,7 +44722,7 @@ var AcpDriver = class {
44680
44722
  };
44681
44723
 
44682
44724
  // src/baton/transcript-mirror.ts
44683
- var fs73 = __toESM(require("fs"));
44725
+ var fs74 = __toESM(require("fs"));
44684
44726
  var TranscriptMirror = class {
44685
44727
  constructor(deps) {
44686
44728
  this.deps = deps;
@@ -44774,7 +44816,7 @@ var TranscriptMirror = class {
44774
44816
  }
44775
44817
  };
44776
44818
  function defaultWatch(file, onChange) {
44777
- const w3 = fs73.watch(file, { persistent: false }, () => onChange());
44819
+ const w3 = fs74.watch(file, { persistent: false }, () => onChange());
44778
44820
  return () => w3.close();
44779
44821
  }
44780
44822
 
@@ -45120,16 +45162,16 @@ function keepDeviceAwake(deps = {}) {
45120
45162
  }
45121
45163
 
45122
45164
  // src/agents/claude/onboarding.ts
45123
- var fs74 = __toESM(require("fs"));
45124
- var os58 = __toESM(require("os"));
45125
- var path84 = __toESM(require("path"));
45165
+ var fs75 = __toESM(require("fs"));
45166
+ var os59 = __toESM(require("os"));
45167
+ var path85 = __toESM(require("path"));
45126
45168
  var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
45127
45169
  function ensureClaudeOnboarded(cwd) {
45128
45170
  try {
45129
- const file = path84.join(os58.homedir(), ".claude.json");
45171
+ const file = path85.join(os59.homedir(), ".claude.json");
45130
45172
  let config = {};
45131
45173
  try {
45132
- config = JSON.parse(fs74.readFileSync(file, "utf8"));
45174
+ config = JSON.parse(fs75.readFileSync(file, "utf8"));
45133
45175
  } catch {
45134
45176
  }
45135
45177
  let changed = false;
@@ -45154,8 +45196,8 @@ function ensureClaudeOnboarded(cwd) {
45154
45196
  }
45155
45197
  }
45156
45198
  if (!changed) return;
45157
- fs74.mkdirSync(path84.dirname(file), { recursive: true });
45158
- fs74.writeFileSync(file, JSON.stringify(config, null, 2));
45199
+ fs75.mkdirSync(path85.dirname(file), { recursive: true });
45200
+ fs75.writeFileSync(file, JSON.stringify(config, null, 2));
45159
45201
  log.info(
45160
45202
  "claude",
45161
45203
  `pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
@@ -45932,7 +45974,7 @@ var import_picocolors10 = __toESM(require("picocolors"));
45932
45974
  var import_child_process30 = require("child_process");
45933
45975
  var import_util4 = require("util");
45934
45976
  var import_picocolors8 = __toESM(require("picocolors"));
45935
- var path85 = __toESM(require("path"));
45977
+ var path86 = __toESM(require("path"));
45936
45978
  var execFileP6 = (0, import_util4.promisify)(import_child_process30.execFile);
45937
45979
  var MAX_BUFFER = 8 * 1024 * 1024;
45938
45980
  function resetStdinForChild() {
@@ -46421,7 +46463,7 @@ var GitHubCodespacesProvider = class {
46421
46463
  });
46422
46464
  }
46423
46465
  async uploadFile(workspaceId, remotePath, contents, options = {}) {
46424
- const remoteDir = path85.posix.dirname(remotePath);
46466
+ const remoteDir = path86.posix.dirname(remotePath);
46425
46467
  const parts = [
46426
46468
  `mkdir -p ${shellQuote(remoteDir)}`,
46427
46469
  `cat > ${shellQuote(remotePath)}`
@@ -46491,7 +46533,7 @@ function shellQuote(s) {
46491
46533
  // src/services/providers/gitpod.ts
46492
46534
  var import_child_process31 = require("child_process");
46493
46535
  var import_util5 = require("util");
46494
- var path86 = __toESM(require("path"));
46536
+ var path87 = __toESM(require("path"));
46495
46537
  var import_picocolors9 = __toESM(require("picocolors"));
46496
46538
  var execFileP7 = (0, import_util5.promisify)(import_child_process31.execFile);
46497
46539
  var MAX_BUFFER2 = 8 * 1024 * 1024;
@@ -46731,7 +46773,7 @@ var GitpodProvider = class {
46731
46773
  });
46732
46774
  }
46733
46775
  async uploadFile(workspaceId, remotePath, contents, options = {}) {
46734
- const remoteDir = path86.posix.dirname(remotePath);
46776
+ const remoteDir = path87.posix.dirname(remotePath);
46735
46777
  const parts = [
46736
46778
  `mkdir -p ${shellQuote2(remoteDir)}`,
46737
46779
  `cat > ${shellQuote2(remotePath)}`
@@ -46767,7 +46809,7 @@ function shellQuote2(s) {
46767
46809
  // src/services/providers/gitlab-workspaces.ts
46768
46810
  var import_child_process32 = require("child_process");
46769
46811
  var import_util6 = require("util");
46770
- var path87 = __toESM(require("path"));
46812
+ var path88 = __toESM(require("path"));
46771
46813
  var execFileP8 = (0, import_util6.promisify)(import_child_process32.execFile);
46772
46814
  var MAX_BUFFER3 = 8 * 1024 * 1024;
46773
46815
  var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
@@ -47027,7 +47069,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
47027
47069
  }
47028
47070
  async uploadFile(workspaceId, remotePath, contents, options = {}) {
47029
47071
  const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
47030
- const remoteDir = path87.posix.dirname(remotePath);
47072
+ const remoteDir = path88.posix.dirname(remotePath);
47031
47073
  const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
47032
47074
  if (options.mode != null) {
47033
47075
  parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
@@ -47095,7 +47137,7 @@ function shellQuote3(s) {
47095
47137
  // src/services/providers/railway.ts
47096
47138
  var import_child_process33 = require("child_process");
47097
47139
  var import_util7 = require("util");
47098
- var path88 = __toESM(require("path"));
47140
+ var path89 = __toESM(require("path"));
47099
47141
  var execFileP9 = (0, import_util7.promisify)(import_child_process33.execFile);
47100
47142
  var MAX_BUFFER4 = 8 * 1024 * 1024;
47101
47143
  function resetStdinForChild4() {
@@ -47331,7 +47373,7 @@ var RailwayProvider = class {
47331
47373
  if (!projectId || !serviceId) {
47332
47374
  throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
47333
47375
  }
47334
- const remoteDir = path88.posix.dirname(remotePath);
47376
+ const remoteDir = path89.posix.dirname(remotePath);
47335
47377
  const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
47336
47378
  if (options.mode != null) {
47337
47379
  parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
@@ -47871,14 +47913,14 @@ async function stopWorkspaceFromLocal(target) {
47871
47913
  }
47872
47914
 
47873
47915
  // src/commands/host/host-client.ts
47874
- var fs75 = __toESM(require("fs"));
47875
- var os59 = __toESM(require("os"));
47876
- var path89 = __toESM(require("path"));
47916
+ var fs76 = __toESM(require("fs"));
47917
+ var os60 = __toESM(require("os"));
47918
+ var path90 = __toESM(require("path"));
47877
47919
  var import_node_crypto12 = require("crypto");
47878
47920
  function sampleCpuTimes() {
47879
47921
  let idle = 0;
47880
47922
  let total = 0;
47881
- for (const cpu of os59.cpus()) {
47923
+ for (const cpu of os60.cpus()) {
47882
47924
  const t2 = cpu.times;
47883
47925
  idle += t2.idle;
47884
47926
  total += t2.user + t2.nice + t2.sys + t2.idle + t2.irq;
@@ -47898,8 +47940,8 @@ var MetricsCollector = class {
47898
47940
  const prev = this.prevCpu;
47899
47941
  this.prevCpu = current2;
47900
47942
  if (!prev) {
47901
- const cores = os59.cpus().length || 1;
47902
- const proxy = os59.loadavg()[0] / cores * 100;
47943
+ const cores = os60.cpus().length || 1;
47944
+ const proxy = os60.loadavg()[0] / cores * 100;
47903
47945
  return Math.min(100, Math.max(0, Math.round(proxy)));
47904
47946
  }
47905
47947
  const idleDelta = current2.idle - prev.idle;
@@ -47912,8 +47954,8 @@ var MetricsCollector = class {
47912
47954
  collect() {
47913
47955
  return {
47914
47956
  cpuPct: this.cpuPct(),
47915
- ramUsedMb: Math.round((os59.totalmem() - os59.freemem()) / 1048576),
47916
- ramTotalMb: Math.round(os59.totalmem() / 1048576),
47957
+ ramUsedMb: Math.round((os60.totalmem() - os60.freemem()) / 1048576),
47958
+ ramTotalMb: Math.round(os60.totalmem() / 1048576),
47917
47959
  latencyMs: this.lastLatencyMs
47918
47960
  };
47919
47961
  }
@@ -47922,19 +47964,19 @@ function apiBase() {
47922
47964
  return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
47923
47965
  }
47924
47966
  function hostIdentityPath() {
47925
- return path89.join(os59.homedir(), ".codeam", "host-agent.json");
47967
+ return path90.join(os60.homedir(), ".codeam", "host-agent.json");
47926
47968
  }
47927
47969
  function collectOsInfo() {
47928
47970
  return {
47929
- distro: os59.platform(),
47930
- arch: os59.arch(),
47931
- kernel: os59.release(),
47971
+ distro: os60.platform(),
47972
+ arch: os60.arch(),
47973
+ kernel: os60.release(),
47932
47974
  nodeVersion: process.versions.node
47933
47975
  };
47934
47976
  }
47935
47977
  function loadHostIdentity() {
47936
47978
  try {
47937
- const raw = fs75.readFileSync(hostIdentityPath(), "utf8");
47979
+ const raw = fs76.readFileSync(hostIdentityPath(), "utf8");
47938
47980
  const parsed = JSON.parse(raw);
47939
47981
  if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
47940
47982
  const p2 = parsed;
@@ -47962,8 +48004,8 @@ function ensureControlPollSecret(identity, save = saveHostIdentity) {
47962
48004
  }
47963
48005
  function saveHostIdentity(identity) {
47964
48006
  const file = hostIdentityPath();
47965
- fs75.mkdirSync(path89.dirname(file), { recursive: true, mode: 448 });
47966
- fs75.writeFileSync(file, JSON.stringify(identity, null, 2), {
48007
+ fs76.mkdirSync(path90.dirname(file), { recursive: true, mode: 448 });
48008
+ fs76.writeFileSync(file, JSON.stringify(identity, null, 2), {
47967
48009
  encoding: "utf8",
47968
48010
  mode: 384
47969
48011
  });
@@ -48008,7 +48050,7 @@ function isTerminalEnrollError(err) {
48008
48050
  }
48009
48051
  function deleteHostIdentity() {
48010
48052
  try {
48011
- fs75.rmSync(hostIdentityPath(), { force: true });
48053
+ fs76.rmSync(hostIdentityPath(), { force: true });
48012
48054
  } catch {
48013
48055
  }
48014
48056
  }
@@ -48032,7 +48074,7 @@ async function postJson(pathname, body) {
48032
48074
  function resolveHostLabel(label) {
48033
48075
  const explicit = label?.trim();
48034
48076
  const envLabel = process.env.CODEAM_HOST_LABEL?.trim();
48035
- const resolved = explicit || envLabel || os59.hostname();
48077
+ const resolved = explicit || envLabel || os60.hostname();
48036
48078
  return resolved.slice(0, 80);
48037
48079
  }
48038
48080
  async function redeemEnrollToken(token, label) {
@@ -48225,9 +48267,9 @@ async function host(args2) {
48225
48267
 
48226
48268
  // src/commands/host-agent.ts
48227
48269
  var import_node_child_process30 = require("child_process");
48228
- var os63 = __toESM(require("os"));
48229
- var fs79 = __toESM(require("fs"));
48230
- var path93 = __toESM(require("path"));
48270
+ var os64 = __toESM(require("os"));
48271
+ var fs80 = __toESM(require("fs"));
48272
+ var path94 = __toESM(require("path"));
48231
48273
 
48232
48274
  // src/skills/persist-from-payload.ts
48233
48275
  function persistOrClearSkillsFromPayload(skills) {
@@ -48236,13 +48278,13 @@ function persistOrClearSkillsFromPayload(skills) {
48236
48278
  }
48237
48279
 
48238
48280
  // src/commands/host/session-state.ts
48239
- var fs76 = __toESM(require("fs"));
48240
- var os60 = __toESM(require("os"));
48241
- var path90 = __toESM(require("path"));
48281
+ var fs77 = __toESM(require("fs"));
48282
+ var os61 = __toESM(require("os"));
48283
+ var path91 = __toESM(require("path"));
48242
48284
  function hostSessionStatePath(env = process.env) {
48243
48285
  const override = env.CODEAM_HOST_SESSION_STATE_FILE;
48244
48286
  if (override && override.trim()) return override.trim();
48245
- return path90.join(os60.homedir(), ".codeam", "host-agent-sessions.json");
48287
+ return path91.join(os61.homedir(), ".codeam", "host-agent-sessions.json");
48246
48288
  }
48247
48289
  function isRecord5(v) {
48248
48290
  if (typeof v !== "object" || v === null) return false;
@@ -48253,7 +48295,7 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
48253
48295
  return {
48254
48296
  load() {
48255
48297
  try {
48256
- const raw = JSON.parse(fs76.readFileSync(file, "utf8"));
48298
+ const raw = JSON.parse(fs77.readFileSync(file, "utf8"));
48257
48299
  return Array.isArray(raw?.sessions) ? raw.sessions.filter(isRecord5) : [];
48258
48300
  } catch {
48259
48301
  return [];
@@ -48261,18 +48303,18 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
48261
48303
  },
48262
48304
  save(list) {
48263
48305
  try {
48264
- fs76.mkdirSync(path90.dirname(file), { recursive: true, mode: 448 });
48306
+ fs77.mkdirSync(path91.dirname(file), { recursive: true, mode: 448 });
48265
48307
  const tmp = `${file}.${process.pid}.tmp`;
48266
- fs76.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
48308
+ fs77.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
48267
48309
  mode: 384
48268
48310
  });
48269
- fs76.renameSync(tmp, file);
48311
+ fs77.renameSync(tmp, file);
48270
48312
  } catch {
48271
48313
  }
48272
48314
  },
48273
48315
  clear() {
48274
48316
  try {
48275
- fs76.rmSync(file, { force: true });
48317
+ fs77.rmSync(file, { force: true });
48276
48318
  } catch {
48277
48319
  }
48278
48320
  }
@@ -48295,10 +48337,10 @@ function planSessionResume(records, max) {
48295
48337
  return { resume: ordered.slice(0, bound), dropped: ordered.slice(bound) };
48296
48338
  }
48297
48339
  function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
48298
- const target = path90.resolve(cwd);
48340
+ const target = path91.resolve(cwd);
48299
48341
  const reconnectable = (s) => !!s.pluginId && !!s.pollSecret && !!s.agent;
48300
48342
  const matches = sessions3.filter(
48301
- (s) => !!s.cwd && path90.resolve(s.cwd) === target && reconnectable(s)
48343
+ (s) => !!s.cwd && path91.resolve(s.cwd) === target && reconnectable(s)
48302
48344
  );
48303
48345
  if (matches.length > 0) {
48304
48346
  matches.sort((a, b) => b.pairedAt - a.pairedAt);
@@ -48310,11 +48352,11 @@ function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
48310
48352
 
48311
48353
  // src/commands/host/git-tooling.ts
48312
48354
  var import_node_child_process26 = require("child_process");
48313
- var fs77 = __toESM(require("fs"));
48314
- var os61 = __toESM(require("os"));
48315
- var path91 = __toESM(require("path"));
48355
+ var fs78 = __toESM(require("fs"));
48356
+ var os62 = __toESM(require("os"));
48357
+ var path92 = __toESM(require("path"));
48316
48358
  function codeamBinDir() {
48317
- return process.env.CODEAM_BIN_DIR ?? path91.join(os61.homedir(), ".codeam", "bin");
48359
+ return process.env.CODEAM_BIN_DIR ?? path92.join(os62.homedir(), ".codeam", "bin");
48318
48360
  }
48319
48361
  var FALLBACK_GH_VERSION = "2.62.0";
48320
48362
  var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
@@ -48346,7 +48388,7 @@ async function download(url2, dest) {
48346
48388
  const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
48347
48389
  if (!res.ok || !res.body) return false;
48348
48390
  const buf = Buffer.from(await res.arrayBuffer());
48349
- fs77.writeFileSync(dest, buf);
48391
+ fs78.writeFileSync(dest, buf);
48350
48392
  return true;
48351
48393
  } catch {
48352
48394
  return false;
@@ -48369,8 +48411,8 @@ async function ensureGhCli(runner, token, deps = {}) {
48369
48411
  const version3 = await resolveVersionFn(token);
48370
48412
  const asset = `gh_${version3}_${osToken}_${arch2}`;
48371
48413
  const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
48372
- const tmpRoot = fs77.mkdtempSync(path91.join(os61.tmpdir(), "codeam-gh-"));
48373
- const archive = path91.join(tmpRoot, `${asset}.${ext}`);
48414
+ const tmpRoot = fs78.mkdtempSync(path92.join(os62.tmpdir(), "codeam-gh-"));
48415
+ const archive = path92.join(tmpRoot, `${asset}.${ext}`);
48374
48416
  if (!await downloadFn(url2, archive)) {
48375
48417
  log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
48376
48418
  return null;
@@ -48380,16 +48422,16 @@ async function ensureGhCli(runner, token, deps = {}) {
48380
48422
  log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
48381
48423
  return null;
48382
48424
  }
48383
- const extractedBin = path91.join(tmpRoot, asset, "bin", binaryName);
48384
- if (!fs77.existsSync(extractedBin)) {
48425
+ const extractedBin = path92.join(tmpRoot, asset, "bin", binaryName);
48426
+ if (!fs78.existsSync(extractedBin)) {
48385
48427
  log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
48386
48428
  return null;
48387
48429
  }
48388
48430
  const binDir = codeamBinDir();
48389
- fs77.mkdirSync(binDir, { recursive: true });
48390
- const target = path91.join(binDir, binaryName);
48391
- fs77.copyFileSync(extractedBin, target);
48392
- fs77.chmodSync(target, 493);
48431
+ fs78.mkdirSync(binDir, { recursive: true });
48432
+ const target = path92.join(binDir, binaryName);
48433
+ fs78.copyFileSync(extractedBin, target);
48434
+ fs78.chmodSync(target, 493);
48393
48435
  log.info("host-agent", `gh installed to ${target} (v${version3})`);
48394
48436
  return target;
48395
48437
  } catch (e) {
@@ -48426,19 +48468,19 @@ async function ensureGhAuth(runner, ghCmd, token) {
48426
48468
  }
48427
48469
  function ghConfigDir() {
48428
48470
  if (process.env.GH_CONFIG_DIR) return process.env.GH_CONFIG_DIR;
48429
- if (process.env.XDG_CONFIG_HOME) return path91.join(process.env.XDG_CONFIG_HOME, "gh");
48471
+ if (process.env.XDG_CONFIG_HOME) return path92.join(process.env.XDG_CONFIG_HOME, "gh");
48430
48472
  if (process.platform === "win32" && process.env.APPDATA) {
48431
- return path91.join(process.env.APPDATA, "GitHub CLI");
48473
+ return path92.join(process.env.APPDATA, "GitHub CLI");
48432
48474
  }
48433
- return path91.join(os61.homedir(), ".config", "gh");
48475
+ return path92.join(os62.homedir(), ".config", "gh");
48434
48476
  }
48435
48477
  function writeGhHostsToken(token) {
48436
48478
  try {
48437
48479
  const dir = ghConfigDir();
48438
- const file = path91.join(dir, "hosts.yml");
48439
- if (fs77.existsSync(file)) return false;
48440
- fs77.mkdirSync(dir, { recursive: true, mode: 448 });
48441
- fs77.writeFileSync(
48480
+ const file = path92.join(dir, "hosts.yml");
48481
+ if (fs78.existsSync(file)) return false;
48482
+ fs78.mkdirSync(dir, { recursive: true, mode: 448 });
48483
+ fs78.writeFileSync(
48442
48484
  file,
48443
48485
  `github.com:
48444
48486
  oauth_token: ${token}
@@ -48481,8 +48523,8 @@ async function ensureGlabCli(runner, deps = {}) {
48481
48523
  const version3 = await resolveLatestGlabVersion();
48482
48524
  const asset = `glab_${version3}_${osToken}_${arch2}`;
48483
48525
  const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
48484
- const tmpRoot = fs77.mkdtempSync(path91.join(os61.tmpdir(), "codeam-glab-"));
48485
- const archive = path91.join(tmpRoot, `${asset}.${ext}`);
48526
+ const tmpRoot = fs78.mkdtempSync(path92.join(os62.tmpdir(), "codeam-glab-"));
48527
+ const archive = path92.join(tmpRoot, `${asset}.${ext}`);
48486
48528
  if (!await downloadFn(url2, archive)) {
48487
48529
  log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
48488
48530
  return null;
@@ -48493,20 +48535,20 @@ async function ensureGlabCli(runner, deps = {}) {
48493
48535
  return null;
48494
48536
  }
48495
48537
  const candidates = [
48496
- path91.join(tmpRoot, "bin", binaryName),
48497
- path91.join(tmpRoot, asset, "bin", binaryName),
48498
- path91.join(tmpRoot, binaryName)
48538
+ path92.join(tmpRoot, "bin", binaryName),
48539
+ path92.join(tmpRoot, asset, "bin", binaryName),
48540
+ path92.join(tmpRoot, binaryName)
48499
48541
  ];
48500
- const extractedBin = candidates.find((c2) => fs77.existsSync(c2));
48542
+ const extractedBin = candidates.find((c2) => fs78.existsSync(c2));
48501
48543
  if (!extractedBin) {
48502
48544
  log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
48503
48545
  return null;
48504
48546
  }
48505
48547
  const binDir = codeamBinDir();
48506
- fs77.mkdirSync(binDir, { recursive: true });
48507
- const target = path91.join(binDir, binaryName);
48508
- fs77.copyFileSync(extractedBin, target);
48509
- fs77.chmodSync(target, 493);
48548
+ fs78.mkdirSync(binDir, { recursive: true });
48549
+ const target = path92.join(binDir, binaryName);
48550
+ fs78.copyFileSync(extractedBin, target);
48551
+ fs78.chmodSync(target, 493);
48510
48552
  log.info("host-agent", `glab installed to ${target} (v${version3})`);
48511
48553
  return target;
48512
48554
  } catch (e) {
@@ -48588,9 +48630,9 @@ var defaultGitToolingRunner = {
48588
48630
  var import_node_child_process28 = require("child_process");
48589
48631
 
48590
48632
  // src/lib/updateNotifier.ts
48591
- var fs78 = __toESM(require("fs"));
48592
- var os62 = __toESM(require("os"));
48593
- var path92 = __toESM(require("path"));
48633
+ var fs79 = __toESM(require("fs"));
48634
+ var os63 = __toESM(require("os"));
48635
+ var path93 = __toESM(require("path"));
48594
48636
  var https8 = __toESM(require("https"));
48595
48637
  var import_node_child_process27 = require("child_process");
48596
48638
  var import_picocolors12 = __toESM(require("picocolors"));
@@ -48599,12 +48641,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
48599
48641
  var TTL_MS = 24 * 60 * 60 * 1e3;
48600
48642
  var REQUEST_TIMEOUT_MS = 1500;
48601
48643
  function cachePath() {
48602
- const dir = path92.join(os62.homedir(), ".codeam");
48603
- return path92.join(dir, "update-check.json");
48644
+ const dir = path93.join(os63.homedir(), ".codeam");
48645
+ return path93.join(dir, "update-check.json");
48604
48646
  }
48605
48647
  function readCache() {
48606
48648
  try {
48607
- const raw = fs78.readFileSync(cachePath(), "utf8");
48649
+ const raw = fs79.readFileSync(cachePath(), "utf8");
48608
48650
  const parsed = JSON.parse(raw);
48609
48651
  if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
48610
48652
  return parsed;
@@ -48615,10 +48657,10 @@ function readCache() {
48615
48657
  function writeCache(cache) {
48616
48658
  try {
48617
48659
  const file = cachePath();
48618
- fs78.mkdirSync(path92.dirname(file), { recursive: true });
48660
+ fs79.mkdirSync(path93.dirname(file), { recursive: true });
48619
48661
  const tmp = `${file}.${process.pid}.tmp`;
48620
- fs78.writeFileSync(tmp, JSON.stringify(cache));
48621
- fs78.renameSync(tmp, file);
48662
+ fs79.writeFileSync(tmp, JSON.stringify(cache));
48663
+ fs79.renameSync(tmp, file);
48622
48664
  } catch {
48623
48665
  }
48624
48666
  }
@@ -48692,8 +48734,8 @@ function isLinkedInstall() {
48692
48734
  timeout: 2e3
48693
48735
  }).trim();
48694
48736
  if (!root) return false;
48695
- const pkgPath = path92.join(root, PKG_NAME);
48696
- return fs78.lstatSync(pkgPath).isSymbolicLink();
48737
+ const pkgPath = path93.join(root, PKG_NAME);
48738
+ return fs79.lstatSync(pkgPath).isSymbolicLink();
48697
48739
  } catch {
48698
48740
  return false;
48699
48741
  }
@@ -48729,7 +48771,7 @@ function maybeAutoUpdate(currentVersion, latest) {
48729
48771
  return;
48730
48772
  }
48731
48773
  try {
48732
- fs78.unlinkSync(cachePath());
48774
+ fs79.unlinkSync(cachePath());
48733
48775
  } catch {
48734
48776
  }
48735
48777
  process.stderr.write(` ${import_picocolors12.default.green("\u2713")} Updated. Resuming session...
@@ -48745,7 +48787,7 @@ async function autoUpgradeBeforeCriticalCommand() {
48745
48787
  if (process.env.NODE_ENV === "test") return;
48746
48788
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
48747
48789
  if (process.env.CI) return;
48748
- const current2 = true ? "2.75.35" : null;
48790
+ const current2 = true ? "2.75.36" : null;
48749
48791
  if (!current2) return;
48750
48792
  const cache = readCache();
48751
48793
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -48762,7 +48804,7 @@ function checkForUpdates() {
48762
48804
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
48763
48805
  if (process.env.CI) return;
48764
48806
  if (!process.stdout.isTTY) return;
48765
- const current2 = true ? "2.75.35" : null;
48807
+ const current2 = true ? "2.75.36" : null;
48766
48808
  if (!current2) return;
48767
48809
  const cache = readCache();
48768
48810
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -48785,7 +48827,7 @@ var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
48785
48827
  var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
48786
48828
  var SUDO_PREFLIGHT_TIMEOUT_MS = 5e3;
48787
48829
  function currentCliVersion() {
48788
- return true ? "2.75.35" : null;
48830
+ return true ? "2.75.36" : null;
48789
48831
  }
48790
48832
  async function installedVersion(deps) {
48791
48833
  const ls = await deps.run(
@@ -49144,6 +49186,7 @@ var HostAgentSupervisor = class {
49144
49186
  this.selfUpdate = deps.selfUpdate ?? runSelfUpdate;
49145
49187
  this.now = deps.now ?? (() => Date.now());
49146
49188
  this.onUpdated = deps.onUpdated ?? defaultOnUpdated;
49189
+ this.isChildMidTurn = deps.isChildMidTurn ?? ((pid) => isProcessMidTurn(pid));
49147
49190
  this.docker = deps.docker ?? defaultDockerRunner;
49148
49191
  this.postResumeFailure = deps.postResumeFailure ?? postSessionErrorBubble;
49149
49192
  }
@@ -49160,6 +49203,7 @@ var HostAgentSupervisor = class {
49160
49203
  /** Self-update check + install (injectable; defaults to runSelfUpdate). */
49161
49204
  selfUpdate;
49162
49205
  now;
49206
+ isChildMidTurn;
49163
49207
  /** Restart action after a successful self-update (defaults to process.exit). */
49164
49208
  onUpdated;
49165
49209
  /** Guards against overlapping self-update ticks (a slow npm install). */
@@ -49363,19 +49407,20 @@ var HostAgentSupervisor = class {
49363
49407
  * idle tick) rather than yank an active turn.
49364
49408
  */
49365
49409
  maybeRestartForUpdate(version3) {
49366
- if (this.children.size > 0) {
49410
+ const midTurn = [...this.children.values()].some((c2) => this.isChildMidTurn(c2.proc.pid));
49411
+ if (midTurn) {
49367
49412
  const since = this.pendingRestartSince ?? this.now();
49368
49413
  const waited = this.now() - since;
49369
49414
  if (waited < SELF_UPDATE_DEFER_MAX_MS) {
49370
49415
  log.info(
49371
49416
  "host-agent",
49372
- `self-update: ${version3} installed but ${this.children.size} child(ren) busy \u2014 deferring restart`
49417
+ `self-update: ${version3} installed but a session is mid-turn \u2014 deferring restart`
49373
49418
  );
49374
49419
  return false;
49375
49420
  }
49376
49421
  log.warn(
49377
49422
  "host-agent",
49378
- `self-update: ${version3} has been owed for ${Math.round(waited / 36e5)}h with ${this.children.size} child(ren) still running \u2014 restarting anyway rather than staying on old code`
49423
+ `self-update: ${version3} has been owed for ${Math.round(waited / 36e5)}h with a session still mid-turn \u2014 restarting anyway rather than staying on old code`
49379
49424
  );
49380
49425
  }
49381
49426
  this.onUpdated(version3);
@@ -49526,13 +49571,13 @@ var HostAgentSupervisor = class {
49526
49571
  const relay = this.relay;
49527
49572
  if (!relay) return;
49528
49573
  const raw = cmd.payload?.path;
49529
- const target = typeof raw === "string" && raw.trim() ? path93.resolve(raw.trim()) : os63.homedir();
49574
+ const target = typeof raw === "string" && raw.trim() ? path94.resolve(raw.trim()) : os64.homedir();
49530
49575
  try {
49531
- const dirents = await fs79.promises.readdir(target, { withFileTypes: true });
49576
+ const dirents = await fs80.promises.readdir(target, { withFileTypes: true });
49532
49577
  const entries = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
49533
49578
  (a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
49534
49579
  );
49535
- const parent = path93.dirname(target);
49580
+ const parent = path94.dirname(target);
49536
49581
  await relay.sendResult(cmd.id, "completed", {
49537
49582
  path: target,
49538
49583
  // null at the filesystem root so the UI can hide the ".." affordance.
@@ -49879,14 +49924,14 @@ var HostAgentSupervisor = class {
49879
49924
  ...buildHouseProxyChildEnv({ baseUrl, token, openRouter: openRouter === true }),
49880
49925
  CODEAM_AUTO_TOKEN: payload.autoPairToken
49881
49926
  };
49882
- const houseConfigDir = path93.join(
49883
- os63.homedir(),
49927
+ const houseConfigDir = path94.join(
49928
+ os64.homedir(),
49884
49929
  ".codeam",
49885
49930
  "house-claude",
49886
49931
  payload.deployId
49887
49932
  );
49888
49933
  try {
49889
- fs79.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
49934
+ fs80.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
49890
49935
  } catch {
49891
49936
  }
49892
49937
  childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
@@ -49912,7 +49957,7 @@ var HostAgentSupervisor = class {
49912
49957
  report("installing", "installing agent CLI");
49913
49958
  await this.runAgentInstall(payload.agentInstallScript);
49914
49959
  }
49915
- const home = process.env.HOME || os63.homedir();
49960
+ const home = process.env.HOME || os64.homedir();
49916
49961
  childEnv.PATH = `${home}/.local/bin:${process.env.PATH ?? ""}`;
49917
49962
  if (payload.cloneToken) {
49918
49963
  try {
@@ -49920,13 +49965,13 @@ var HostAgentSupervisor = class {
49920
49965
  if ((payload.repoProvider ?? "github") === "gitlab") {
49921
49966
  const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
49922
49967
  if (glabCmd) {
49923
- childEnv.PATH = `${codeamBinDir()}${path93.delimiter}${childEnv.PATH}`;
49968
+ childEnv.PATH = `${codeamBinDir()}${path94.delimiter}${childEnv.PATH}`;
49924
49969
  await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
49925
49970
  }
49926
49971
  } else {
49927
49972
  const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
49928
49973
  if (ghCmd) {
49929
- childEnv.PATH = `${codeamBinDir()}${path93.delimiter}${childEnv.PATH}`;
49974
+ childEnv.PATH = `${codeamBinDir()}${path94.delimiter}${childEnv.PATH}`;
49930
49975
  await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
49931
49976
  }
49932
49977
  }
@@ -49954,9 +49999,9 @@ var HostAgentSupervisor = class {
49954
49999
  );
49955
50000
  if (!payload.suppressOnboardingWelcome) {
49956
50001
  try {
49957
- const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path93.join(os63.homedir(), ".claude");
49958
- const projectDir = path93.join(cfgDir, "projects", encodeCwd(cwd));
49959
- const hasPriorConversation = fs79.existsSync(projectDir) && fs79.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
50002
+ const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path94.join(os64.homedir(), ".claude");
50003
+ const projectDir = path94.join(cfgDir, "projects", encodeCwd(cwd));
50004
+ const hasPriorConversation = fs80.existsSync(projectDir) && fs80.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
49960
50005
  if (hasPriorConversation) {
49961
50006
  childEnv.CODEAM_RESUME_LATEST = "1";
49962
50007
  log.info(
@@ -50107,7 +50152,7 @@ var HostAgentSupervisor = class {
50107
50152
  fallbackResumeTarget() {
50108
50153
  const session = getActiveSession();
50109
50154
  if (!session || !session.pluginId || !session.pollSecret || !session.agent) return null;
50110
- const cwd = session.cwd && fs79.existsSync(session.cwd) ? session.cwd : process.cwd();
50155
+ const cwd = session.cwd && fs80.existsSync(session.cwd) ? session.cwd : process.cwd();
50111
50156
  const deployId = deployIdFromWorkspace(session.cwd) ?? session.id;
50112
50157
  return { deployId, cwd, session };
50113
50158
  }
@@ -50140,7 +50185,7 @@ var HostAgentSupervisor = class {
50140
50185
  log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: no saved pairing on this box`);
50141
50186
  return;
50142
50187
  }
50143
- if (!session.cwd || !fs79.existsSync(session.cwd)) {
50188
+ if (!session.cwd || !fs80.existsSync(session.cwd)) {
50144
50189
  log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: workspace is gone`);
50145
50190
  return;
50146
50191
  }
@@ -50182,7 +50227,7 @@ var HostAgentSupervisor = class {
50182
50227
  const persisted = new Map(this.sessionStore.load().map((r) => [r.deployId, r.agent]));
50183
50228
  for (const c2 of this.children.values()) persisted.set(c2.deployId, c2.agent);
50184
50229
  return this.listSavedSessions().map((s) => ({ s, deployId: deployIdFromWorkspace(s.cwd) })).filter(
50185
- (x) => x.deployId !== null && !!x.s.cwd && fs79.existsSync(x.s.cwd)
50230
+ (x) => x.deployId !== null && !!x.s.cwd && fs80.existsSync(x.s.cwd)
50186
50231
  ).map(({ s, deployId }) => {
50187
50232
  const agent = persisted.get(deployId);
50188
50233
  return { deployId, sessionId: s.id, ...agent ? { agent } : {} };
@@ -50197,7 +50242,7 @@ var HostAgentSupervisor = class {
50197
50242
  if (this.children.has(deployId)) return;
50198
50243
  const st3 = this.resumeStateFor(target);
50199
50244
  try {
50200
- const cwd = fs79.existsSync(target.cwd) ? target.cwd : process.cwd();
50245
+ const cwd = fs80.existsSync(target.cwd) ? target.cwd : process.cwd();
50201
50246
  const proc = this.resumeSpawner(
50202
50247
  { ...readHouseProxyChildEnv(deployId), CODEAM_RESUME_SESSION_ID: session.id },
50203
50248
  cwd
@@ -50224,7 +50269,7 @@ var HostAgentSupervisor = class {
50224
50269
  return;
50225
50270
  }
50226
50271
  if (tracked && signal) {
50227
- this.onResumeChildExit(target, 128 + (os63.constants.signals[signal] ?? 9), `signal ${signal}`);
50272
+ this.onResumeChildExit(target, 128 + (os64.constants.signals[signal] ?? 9), `signal ${signal}`);
50228
50273
  return;
50229
50274
  }
50230
50275
  log.warn(
@@ -50267,7 +50312,7 @@ var HostAgentSupervisor = class {
50267
50312
  if (Date.now() - child.startedAt < CRASH_RESPAWN_MIN_UPTIME_MS) return false;
50268
50313
  const session = pickSavedSessionForWorkspace(this.listSavedSessions(), child.cwd);
50269
50314
  if (!session) return false;
50270
- const exitCode = typeof code === "number" ? code : 128 + (signal ? os63.constants.signals[signal] ?? 9 : 9);
50315
+ const exitCode = typeof code === "number" ? code : 128 + (signal ? os64.constants.signals[signal] ?? 9 : 9);
50271
50316
  log.warn(
50272
50317
  "host-agent",
50273
50318
  `session deploy=${child.deployId.slice(0, 8)} died (${signal ?? code}) after ${Math.round((Date.now() - child.startedAt) / 1e3)}s \u2014 respawning it (resume)`
@@ -50416,12 +50461,12 @@ var HostAgentSupervisor = class {
50416
50461
  this.untrackChild(deployId);
50417
50462
  }
50418
50463
  const dirs = [
50419
- path93.join(selfHostedWorkspaceRoot(), deployId),
50420
- path93.join(os63.homedir(), ".codeam", "house-claude", deployId)
50464
+ path94.join(selfHostedWorkspaceRoot(), deployId),
50465
+ path94.join(os64.homedir(), ".codeam", "house-claude", deployId)
50421
50466
  ];
50422
50467
  for (const dir of dirs) {
50423
50468
  try {
50424
- fs79.rmSync(dir, { recursive: true, force: true });
50469
+ fs80.rmSync(dir, { recursive: true, force: true });
50425
50470
  } catch (err) {
50426
50471
  log.warn(
50427
50472
  "host-agent",
@@ -50581,8 +50626,8 @@ async function invite() {
50581
50626
  var import_node_dns = require("dns");
50582
50627
  var import_node_util6 = require("util");
50583
50628
  var import_node_crypto13 = require("crypto");
50584
- var fs80 = __toESM(require("fs"));
50585
- var path94 = __toESM(require("path"));
50629
+ var fs81 = __toESM(require("fs"));
50630
+ var path95 = __toESM(require("path"));
50586
50631
  var import_picocolors14 = __toESM(require("picocolors"));
50587
50632
  var dnsResolveP = (0, import_node_util6.promisify)(import_node_dns.resolve);
50588
50633
  async function checkDns(apiBase2) {
@@ -50638,13 +50683,13 @@ async function checkHealth(apiBase2) {
50638
50683
  }
50639
50684
  }
50640
50685
  function checkConfigDir() {
50641
- const dir = path94.join(require("os").homedir(), ".codeam");
50686
+ const dir = path95.join(require("os").homedir(), ".codeam");
50642
50687
  try {
50643
- fs80.mkdirSync(dir, { recursive: true, mode: 448 });
50644
- const probe = path94.join(dir, ".doctor-probe");
50645
- fs80.writeFileSync(probe, "ok", { mode: 384 });
50646
- const read = fs80.readFileSync(probe, "utf8");
50647
- fs80.unlinkSync(probe);
50688
+ fs81.mkdirSync(dir, { recursive: true, mode: 448 });
50689
+ const probe = path95.join(dir, ".doctor-probe");
50690
+ fs81.writeFileSync(probe, "ok", { mode: 384 });
50691
+ const read = fs81.readFileSync(probe, "utf8");
50692
+ fs81.unlinkSync(probe);
50648
50693
  if (read !== "ok") throw new Error("write/read round-trip mismatch");
50649
50694
  return {
50650
50695
  id: "config-dir",
@@ -50684,9 +50729,9 @@ function checkSessions() {
50684
50729
  }
50685
50730
  }
50686
50731
  function checkAgentBinaries() {
50687
- const os66 = createOsStrategy();
50732
+ const os67 = createOsStrategy();
50688
50733
  return getEnabledAgents().map((meta) => {
50689
- const found = os66.findInPath(meta.binaryName);
50734
+ const found = os67.findInPath(meta.binaryName);
50690
50735
  return {
50691
50736
  id: `agent-${meta.id}`,
50692
50737
  label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
@@ -50708,7 +50753,7 @@ function checkNodePty() {
50708
50753
  detail: "not required on this platform"
50709
50754
  };
50710
50755
  }
50711
- const vendoredPath = path94.join(__dirname, "vendor", "node-pty");
50756
+ const vendoredPath = path95.join(__dirname, "vendor", "node-pty");
50712
50757
  for (const target of [vendoredPath, "node-pty"]) {
50713
50758
  try {
50714
50759
  require(target);
@@ -50750,7 +50795,7 @@ function checkChokidar() {
50750
50795
  }
50751
50796
  async function doctor(args2 = []) {
50752
50797
  const json = args2.includes("--json");
50753
- const cliVersion = true ? "2.75.35" : "0.0.0-dev";
50798
+ const cliVersion = true ? "2.75.36" : "0.0.0-dev";
50754
50799
  const apiBase2 = resolveApiBaseUrl();
50755
50800
  const diagnosticId = (0, import_node_crypto13.randomUUID)();
50756
50801
  log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
@@ -50812,8 +50857,8 @@ ${import_picocolors14.default.bold(" codeam doctor")}
50812
50857
  `);
50813
50858
  out2.write("\n");
50814
50859
  for (const c2 of r.checks) {
50815
- const mark = c2.ok ? import_picocolors14.default.green("\u2713") : c2.optional ? import_picocolors14.default.yellow("!") : import_picocolors14.default.red("\u2717");
50816
- out2.write(` ${mark} ${c2.label}${import_picocolors14.default.dim(` \u2014 ${c2.detail}`)}
50860
+ const mark2 = c2.ok ? import_picocolors14.default.green("\u2713") : c2.optional ? import_picocolors14.default.yellow("!") : import_picocolors14.default.red("\u2717");
50861
+ out2.write(` ${mark2} ${c2.label}${import_picocolors14.default.dim(` \u2014 ${c2.detail}`)}
50817
50862
  `);
50818
50863
  if (!c2.ok && c2.hint) {
50819
50864
  for (const line of c2.hint.split("\n")) {
@@ -51274,7 +51319,7 @@ async function mcpWarm(argv = [], opts = {}) {
51274
51319
  // src/commands/version.ts
51275
51320
  var import_picocolors15 = __toESM(require("picocolors"));
51276
51321
  function version2() {
51277
- const v = true ? "2.75.35" : "unknown";
51322
+ const v = true ? "2.75.36" : "unknown";
51278
51323
  console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
51279
51324
  }
51280
51325
 
@@ -51423,10 +51468,10 @@ var EXIT_CODE_NAMES = {
51423
51468
  };
51424
51469
 
51425
51470
  // src/index.ts
51426
- var os65 = __toESM(require("os"));
51471
+ var os66 = __toESM(require("os"));
51427
51472
  if (!process.env.HOME) {
51428
51473
  try {
51429
- const home = os65.homedir();
51474
+ const home = os66.homedir();
51430
51475
  if (home) process.env.HOME = home;
51431
51476
  } catch {
51432
51477
  }