codeam-cli 2.65.1 → 2.65.3

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 +31 -0
  2. package/dist/index.js +1030 -888
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3148,11 +3148,11 @@ function quiet(fn) {
3148
3148
  log.debug(TAG, "ignored sync error", err);
3149
3149
  }
3150
3150
  }
3151
- function rmIfExistsQuiet(path91) {
3151
+ function rmIfExistsQuiet(path92) {
3152
3152
  try {
3153
- fs2.rmSync(path91, { force: true });
3153
+ fs2.rmSync(path92, { force: true });
3154
3154
  } catch (err) {
3155
- log.debug(TAG, `rmIfExists failed for ${path91}`, err);
3155
+ log.debug(TAG, `rmIfExists failed for ${path92}`, err);
3156
3156
  }
3157
3157
  }
3158
3158
  function killQuiet(target, signal = "SIGTERM") {
@@ -3321,9 +3321,9 @@ var _default = makeConfig();
3321
3321
  var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, setSessionAgent, setSquadAuto, getSquadAuto, clearAll, saveCliConfig, loadCliConfig } = _default;
3322
3322
 
3323
3323
  // src/commands/pair-auto.ts
3324
- var fs64 = __toESM(require("fs"));
3325
- var os54 = __toESM(require("os"));
3326
- var path69 = __toESM(require("path"));
3324
+ var fs65 = __toESM(require("fs"));
3325
+ var os55 = __toESM(require("os"));
3326
+ var path70 = __toESM(require("path"));
3327
3327
  var import_crypto4 = require("crypto");
3328
3328
 
3329
3329
  // src/services/telemetry.service.ts
@@ -3359,8 +3359,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
3359
3359
  return decodedFile;
3360
3360
  };
3361
3361
  }
3362
- function normalizeWindowsPath(path91) {
3363
- return path91.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
3362
+ function normalizeWindowsPath(path92) {
3363
+ return path92.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
3364
3364
  }
3365
3365
 
3366
3366
  // ../../node_modules/@posthog/core/dist/featureFlagUtils.mjs
@@ -5840,9 +5840,9 @@ async function addSourceContext(frames) {
5840
5840
  LRU_FILE_CONTENTS_CACHE.reduce();
5841
5841
  return frames;
5842
5842
  }
5843
- function getContextLinesFromFile(path91, ranges, output) {
5843
+ function getContextLinesFromFile(path92, ranges, output) {
5844
5844
  return new Promise((resolve9) => {
5845
- const stream = (0, import_node_fs.createReadStream)(path91);
5845
+ const stream = (0, import_node_fs.createReadStream)(path92);
5846
5846
  const lineReaded = (0, import_node_readline.createInterface)({
5847
5847
  input: stream
5848
5848
  });
@@ -5857,7 +5857,7 @@ function getContextLinesFromFile(path91, ranges, output) {
5857
5857
  let rangeStart = range[0];
5858
5858
  let rangeEnd = range[1];
5859
5859
  function onStreamError() {
5860
- LRU_FILE_CONTENTS_FS_READ_FAILED.set(path91, 1);
5860
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(path92, 1);
5861
5861
  lineReaded.close();
5862
5862
  lineReaded.removeAllListeners();
5863
5863
  destroyStreamAndResolve();
@@ -5918,8 +5918,8 @@ function clearLineContext(frame) {
5918
5918
  delete frame.context_line;
5919
5919
  delete frame.post_context;
5920
5920
  }
5921
- function shouldSkipContextLinesForFile(path91) {
5922
- return path91.startsWith("node:") || path91.endsWith(".min.js") || path91.endsWith(".min.cjs") || path91.endsWith(".min.mjs") || path91.startsWith("data:");
5921
+ function shouldSkipContextLinesForFile(path92) {
5922
+ return path92.startsWith("node:") || path92.endsWith(".min.js") || path92.endsWith(".min.cjs") || path92.endsWith(".min.mjs") || path92.startsWith("data:");
5923
5923
  }
5924
5924
  function shouldSkipContextLinesForFrame(frame) {
5925
5925
  if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
@@ -8073,7 +8073,7 @@ function readAnonId() {
8073
8073
  }
8074
8074
  function superProperties() {
8075
8075
  return {
8076
- cliVersion: true ? "2.65.1" : "0.0.0-dev",
8076
+ cliVersion: true ? "2.65.3" : "0.0.0-dev",
8077
8077
  nodeVersion: process.version,
8078
8078
  platform: process.platform,
8079
8079
  arch: process.arch,
@@ -8254,7 +8254,7 @@ var os4 = __toESM(require("os"));
8254
8254
  // package.json
8255
8255
  var package_default = {
8256
8256
  name: "codeam-cli",
8257
- version: "2.65.1",
8257
+ version: "2.65.3",
8258
8258
  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.",
8259
8259
  type: "commonjs",
8260
8260
  main: "dist/index.js",
@@ -9706,7 +9706,7 @@ var CommandRelayService = class _CommandRelayService {
9706
9706
  // fresh + clear the "CLI update available" banner after a self-update
9707
9707
  // (a codespace that reinstalls @latest reconnects via heartbeat, not
9708
9708
  // pair/reconnect). Older backends ignore the extra field.
9709
- ..."2.65.1" ? { ideVersion: "2.65.1" } : {}
9709
+ ..."2.65.3" ? { ideVersion: "2.65.3" } : {}
9710
9710
  }).then(() => log.trace("relay", `heartbeat ok online=${online}`)).catch((err) => log.trace("relay", `heartbeat failed online=${online}`, err));
9711
9711
  }
9712
9712
  /**
@@ -11098,9 +11098,9 @@ function closeAllTerminals() {
11098
11098
  }
11099
11099
 
11100
11100
  // src/commands/start/handlers.ts
11101
- var fs63 = __toESM(require("fs"));
11102
- var os53 = __toESM(require("os"));
11103
- var path68 = __toESM(require("path"));
11101
+ var fs64 = __toESM(require("fs"));
11102
+ var os54 = __toESM(require("os"));
11103
+ var path69 = __toESM(require("path"));
11104
11104
  var import_crypto3 = require("crypto");
11105
11105
  var import_child_process26 = require("child_process");
11106
11106
 
@@ -11932,8 +11932,8 @@ function findGitRoot2(startDir) {
11932
11932
 
11933
11933
  // src/commands/link.ts
11934
11934
  var import_node_crypto8 = require("crypto");
11935
- var fs32 = __toESM(require("fs"));
11936
- var path37 = __toESM(require("path"));
11935
+ var fs33 = __toESM(require("fs"));
11936
+ var path38 = __toESM(require("path"));
11937
11937
  var import_chokidar = __toESM(require("chokidar"));
11938
11938
  var import_picocolors2 = __toESM(require("picocolors"));
11939
11939
 
@@ -14610,10 +14610,10 @@ function buildForPlatform(platform3) {
14610
14610
  var import_node_crypto4 = require("crypto");
14611
14611
 
14612
14612
  // src/agents/claude/resolver.ts
14613
- function buildClaudeLaunch(extraArgs = [], os66 = createOsStrategy()) {
14614
- const found = os66.findInPath("claude") ?? os66.findInPath("claude-code");
14613
+ function buildClaudeLaunch(extraArgs = [], os67 = createOsStrategy()) {
14614
+ const found = os67.findInPath("claude") ?? os67.findInPath("claude-code");
14615
14615
  if (!found) return null;
14616
- return os66.buildLaunch(found, extraArgs);
14616
+ return os67.buildLaunch(found, extraArgs);
14617
14617
  }
14618
14618
 
14619
14619
  // src/agents/claude/installer.ts
@@ -15203,8 +15203,8 @@ var ClaudeRuntimeStrategy = class {
15203
15203
  meta = getAgent("claude");
15204
15204
  mode = "interactive";
15205
15205
  os;
15206
- constructor(os66) {
15207
- this.os = os66;
15206
+ constructor(os67) {
15207
+ this.os = os67;
15208
15208
  }
15209
15209
  /**
15210
15210
  * Claude Code's react-ink TUI enables bracketed-paste mode at
@@ -15556,12 +15556,302 @@ var ClaudeDeployStrategy = class {
15556
15556
 
15557
15557
  // src/agents/codex/runtime.ts
15558
15558
  var import_node_child_process5 = require("child_process");
15559
- var path25 = __toESM(require("path"));
15559
+ var path26 = __toESM(require("path"));
15560
15560
 
15561
15561
  // src/agents/codex/history.ts
15562
15562
  var import_node_fs3 = __toESM(require("fs"));
15563
15563
  var import_node_path2 = __toESM(require("path"));
15564
15564
  var import_node_os = __toESM(require("os"));
15565
+
15566
+ // src/agents/acp/squad-roster.ts
15567
+ var fs20 = __toESM(require("fs"));
15568
+ var os18 = __toESM(require("os"));
15569
+ var path23 = __toESM(require("path"));
15570
+ var PROMPT_MAX = 500;
15571
+ var REPLY_SUMMARY_MAX = 1e3;
15572
+ var PREAMBLE_MAX = 2e3;
15573
+ var BRIEFING_DEFAULT_MAX = 8e3;
15574
+ var GENERIC_SPECIALTY = "general implementation tasks";
15575
+ function clip(s, max) {
15576
+ return s.length > max ? s.slice(0, max) : s;
15577
+ }
15578
+ function defaultMember() {
15579
+ return {
15580
+ acpSessionId: null,
15581
+ provisioned: false,
15582
+ binaryVerified: false,
15583
+ lastTurnIndex: 0,
15584
+ contextTextFallback: false
15585
+ };
15586
+ }
15587
+ function journalPathFor(homeDir2, sessionId) {
15588
+ return path23.join(homeDir2, ".codeam", `squad-journal-${sessionId}.json`);
15589
+ }
15590
+ function loadJournal(journalPath) {
15591
+ try {
15592
+ const raw = JSON.parse(fs20.readFileSync(journalPath, "utf-8"));
15593
+ return Array.isArray(raw.turns) ? raw.turns : [];
15594
+ } catch {
15595
+ return [];
15596
+ }
15597
+ }
15598
+ var SquadState = class {
15599
+ /** Set by the caller after fetchSquadRoster; null until then. */
15600
+ roster = null;
15601
+ /**
15602
+ * Autonomous chained handoffs (P2-2, PRO). Seeded from the persisted
15603
+ * `SavedSession.squadAuto` at session start and rewritten by
15604
+ * `squad_configure`. Read-only to callers — mutate via {@link setAuto}, which
15605
+ * clamps the budget and re-arms the chain.
15606
+ */
15607
+ autoConfig = { enabled: false, hopBudget: SQUAD_HOP_BUDGET_DEFAULT };
15608
+ /**
15609
+ * Hops left in the CURRENT chain. Reset to the budget on every USER-initiated
15610
+ * prompt (so a user turn always interrupts and re-arms) and decremented by
15611
+ * each self-accepted handoff.
15612
+ */
15613
+ hopsLeft = 0;
15614
+ /** Lifetime handoff counters for `squad_stats` (in-memory, this process). */
15615
+ handoffCounters = { proposed: 0, accepted: 0, auto: 0 };
15616
+ journalPath;
15617
+ turns;
15618
+ members = /* @__PURE__ */ new Map();
15619
+ constructor(opts) {
15620
+ this.journalPath = journalPathFor(opts.homeDir ?? os18.homedir(), opts.sessionId);
15621
+ this.turns = loadJournal(this.journalPath);
15622
+ if (opts.auto) this.setAuto(opts.auto);
15623
+ }
15624
+ get auto() {
15625
+ return this.autoConfig;
15626
+ }
15627
+ /** Apply a new mode (clamping the budget) and re-arm the chain. */
15628
+ setAuto(value) {
15629
+ this.autoConfig = {
15630
+ enabled: value.enabled === true,
15631
+ hopBudget: clampHopBudget(value.hopBudget)
15632
+ };
15633
+ this.resetHops();
15634
+ return this.autoConfig;
15635
+ }
15636
+ hopsRemaining() {
15637
+ return this.hopsLeft;
15638
+ }
15639
+ /** Re-arm the chain — called at the start of every USER-initiated turn. */
15640
+ resetHops() {
15641
+ this.hopsLeft = this.autoConfig.enabled ? this.autoConfig.hopBudget : 0;
15642
+ }
15643
+ /** Spend one hop on a self-accepted handoff. */
15644
+ consumeHop() {
15645
+ if (this.hopsLeft > 0) this.hopsLeft -= 1;
15646
+ }
15647
+ countProposal(opts) {
15648
+ this.handoffCounters.proposed += 1;
15649
+ if (opts.auto) this.handoffCounters.auto += 1;
15650
+ }
15651
+ countAccepted() {
15652
+ this.handoffCounters.accepted += 1;
15653
+ }
15654
+ /**
15655
+ * Per-member activity for the `squad_stats` relay command, derived from the
15656
+ * journal (the same shared history the delta briefing reads) plus the
15657
+ * in-memory handoff counters. `filesTouched` counts DISTINCT paths — a member
15658
+ * that edited the same file across three turns touched ONE file.
15659
+ */
15660
+ stats() {
15661
+ const byAgent = /* @__PURE__ */ new Map();
15662
+ for (const t2 of this.turns) {
15663
+ let row = byAgent.get(t2.agentId);
15664
+ if (!row) {
15665
+ row = { turns: 0, files: /* @__PURE__ */ new Set() };
15666
+ byAgent.set(t2.agentId, row);
15667
+ }
15668
+ row.turns += 1;
15669
+ for (const f of t2.filesTouched) row.files.add(f);
15670
+ }
15671
+ const members = [...byAgent.entries()].map(([agentId, row]) => ({
15672
+ agentId,
15673
+ turns: row.turns,
15674
+ filesTouched: row.files.size
15675
+ }));
15676
+ return { members, handoffs: { ...this.handoffCounters }, sinceTurn: 1 };
15677
+ }
15678
+ /** Returns (creating on first access) the mutable per-agent state. */
15679
+ member(agentId) {
15680
+ let m = this.members.get(agentId);
15681
+ if (!m) {
15682
+ m = defaultMember();
15683
+ this.members.set(agentId, m);
15684
+ }
15685
+ return m;
15686
+ }
15687
+ /** Appends a journal entry and persists (fire-and-forget durability). */
15688
+ recordTurn(entry) {
15689
+ const turn = {
15690
+ turn: this.turns.length + 1,
15691
+ agentId: entry.agentId,
15692
+ prompt: clip(entry.prompt, PROMPT_MAX),
15693
+ replySummary: clip(entry.replySummary, REPLY_SUMMARY_MAX),
15694
+ filesTouched: entry.filesTouched
15695
+ };
15696
+ this.turns.push(turn);
15697
+ this.persist();
15698
+ }
15699
+ turnCount() {
15700
+ return this.turns.length;
15701
+ }
15702
+ entriesSince(turnIndex) {
15703
+ return this.turns.filter((t2) => t2.turn > turnIndex);
15704
+ }
15705
+ persist() {
15706
+ try {
15707
+ fs20.mkdirSync(path23.dirname(this.journalPath), { recursive: true, mode: 448 });
15708
+ fs20.writeFileSync(this.journalPath, JSON.stringify({ turns: this.turns }), { mode: 384 });
15709
+ } catch {
15710
+ }
15711
+ }
15712
+ };
15713
+ function specialtyFor(agentId) {
15714
+ return SQUAD_SPECIALTIES[agentId] ?? GENERIC_SPECIALTY;
15715
+ }
15716
+ var TEAM_PREAMBLE_MARKER = "[Team context]";
15717
+ var TEAM_PREAMBLE_LINES = [
15718
+ "[Team context] You are the active agent in a CodeAgent Mobile session where the user",
15719
+ "has a squad of agents and can pass work between them. Your available teammates:",
15720
+ "If a task clearly fits a teammate better than you, you MAY propose a handoff by ending",
15721
+ `your reply with a fenced code block tagged ${HANDOFF_FENCE_TAG} containing ONE JSON object:`,
15722
+ '{"to":"<teammate id>","reason":"<one sentence>","prompt":"<the prompt they should run>"}',
15723
+ "Propose at most one handoff per reply, only when genuinely better, and never announce",
15724
+ "the block in prose \u2014 the app renders it as a card the user can accept."
15725
+ ];
15726
+ var TEAM_PREAMBLE_BULLET_RE = /^- .+ — best at: /;
15727
+ var BRIEFING_MARKER = "[Team update]";
15728
+ var BRIEFING_HEADER = "[Team update] While you were away, other agents worked on this session:";
15729
+ var BRIEFING_FOOTER = "Continue from the CURRENT state of the working tree.";
15730
+ function buildTeamPreamble(roster, currentAgent, opts) {
15731
+ const others = roster.agents.filter((a) => a.agentId !== currentAgent);
15732
+ if (others.length === 0) return null;
15733
+ const lines = [
15734
+ TEAM_PREAMBLE_LINES[0],
15735
+ TEAM_PREAMBLE_LINES[1],
15736
+ ...others.map((a) => `- ${a.displayName} \u2014 best at: ${specialtyFor(a.agentId)}`)
15737
+ ];
15738
+ if (opts.handoffInstructions) {
15739
+ lines.push(...TEAM_PREAMBLE_LINES.slice(2));
15740
+ }
15741
+ return clip(lines.join("\n"), PREAMBLE_MAX);
15742
+ }
15743
+ function renderJournalEntry(e) {
15744
+ const filesClause = e.filesTouched.length > 0 ? ` (files: ${e.filesTouched.join(", ")})` : "";
15745
+ return `- turn ${e.turn} (${e.agentId}): ${e.prompt} \u2192 ${e.replySummary}${filesClause}`;
15746
+ }
15747
+ function buildDeltaBriefing(entries, maxChars = BRIEFING_DEFAULT_MAX) {
15748
+ if (entries.length === 0) return null;
15749
+ const header = BRIEFING_HEADER;
15750
+ const footer = BRIEFING_FOOTER;
15751
+ const envelope = header.length + 1 + footer.length + 1;
15752
+ const sorted = [...entries].sort((a, b) => a.turn - b.turn);
15753
+ const lines = [];
15754
+ let bodyLen = 0;
15755
+ for (let i = sorted.length - 1; i >= 0; i--) {
15756
+ const line = renderJournalEntry(sorted[i]);
15757
+ const addedLen = line.length + (lines.length > 0 ? 1 : 0);
15758
+ if (lines.length > 0 && envelope + bodyLen + addedLen > maxChars) break;
15759
+ lines.unshift(line);
15760
+ bodyLen += addedLen;
15761
+ }
15762
+ return [header, lines.join("\n"), footer].join("\n");
15763
+ }
15764
+
15765
+ // src/agents/acp/squad-context.ts
15766
+ var SQUAD_CONTEXT_URI = "codeam://squad-context";
15767
+ var HANDOFF_MARKER = "[Session handoff]";
15768
+ var HANDOFF_TERMINATOR = "--- End of handoff context ---";
15769
+ function buildSquadContextBlock(text) {
15770
+ return {
15771
+ type: "resource",
15772
+ resource: { uri: SQUAD_CONTEXT_URI, mimeType: "text/plain", text }
15773
+ };
15774
+ }
15775
+ function isSquadContextBlock(block) {
15776
+ return block.type === "resource" && block.resource.uri === SQUAD_CONTEXT_URI;
15777
+ }
15778
+ function isLeakedSquadContextText(text) {
15779
+ return text.trim().startsWith(SQUAD_CONTEXT_URI);
15780
+ }
15781
+ function looksLikeUnsupportedPromptShape(err) {
15782
+ const code = err?.code;
15783
+ if (code === -32602) return true;
15784
+ const message = err instanceof Error ? err.message : String(err ?? "");
15785
+ if (/invalid[ _]params|-32602/i.test(message)) return true;
15786
+ return /\bresource\b/i.test(message) && /unsupported|not supported/i.test(message);
15787
+ }
15788
+ function skipWhile(lines, start2, keepGoing) {
15789
+ let i = start2;
15790
+ while (i < lines.length && keepGoing(lines[i])) i++;
15791
+ return i;
15792
+ }
15793
+ function endOfTeamPreamble(lines, start2) {
15794
+ if (lines[start2] !== TEAM_PREAMBLE_LINES[0]) return -1;
15795
+ if (lines[start2 + 1] !== TEAM_PREAMBLE_LINES[1]) return -1;
15796
+ return skipWhile(
15797
+ lines,
15798
+ start2 + 2,
15799
+ (line) => TEAM_PREAMBLE_BULLET_RE.test(line) || TEAM_PREAMBLE_LINES.includes(line)
15800
+ );
15801
+ }
15802
+ function endOfTerminatedBlock(lines, start2, terminator) {
15803
+ for (let i = start2; i < lines.length; i++) {
15804
+ if (lines[i].trimEnd() === terminator) return i + 1;
15805
+ }
15806
+ return -1;
15807
+ }
15808
+ function stripSquadContext(text) {
15809
+ if (!text.includes(HANDOFF_MARKER) && !text.includes(BRIEFING_MARKER) && !text.includes(TEAM_PREAMBLE_MARKER)) {
15810
+ return text;
15811
+ }
15812
+ const lines = text.split("\n");
15813
+ const kept = [];
15814
+ let i = 0;
15815
+ let stripped = false;
15816
+ while (i < lines.length) {
15817
+ const line = lines[i];
15818
+ if (line.startsWith(HANDOFF_MARKER)) {
15819
+ const end = endOfTerminatedBlock(lines, i, HANDOFF_TERMINATOR);
15820
+ if (end !== -1) {
15821
+ i = end;
15822
+ stripped = true;
15823
+ continue;
15824
+ }
15825
+ } else if (line.startsWith(BRIEFING_MARKER)) {
15826
+ const end = endOfTerminatedBlock(lines, i, BRIEFING_FOOTER);
15827
+ if (end !== -1) {
15828
+ i = end;
15829
+ stripped = true;
15830
+ continue;
15831
+ }
15832
+ } else if (line.startsWith(TEAM_PREAMBLE_MARKER)) {
15833
+ const end = endOfTeamPreamble(lines, i);
15834
+ if (end !== -1) {
15835
+ i = end;
15836
+ stripped = true;
15837
+ continue;
15838
+ }
15839
+ }
15840
+ kept.push(line);
15841
+ i++;
15842
+ }
15843
+ if (!stripped) return text;
15844
+ return kept.join("\n").trim();
15845
+ }
15846
+
15847
+ // src/agents/acp/agent-meta-blocks.ts
15848
+ var AGENT_META_BLOCK_MARKERS = ["<recommended_plugins>"];
15849
+ function isAgentMetaBlock(text) {
15850
+ const trimmed = text.trim();
15851
+ return AGENT_META_BLOCK_MARKERS.some((marker) => trimmed.startsWith(marker));
15852
+ }
15853
+
15854
+ // src/agents/codex/history.ts
15565
15855
  function resolveHistoryDir2(_cwd, homeOverride) {
15566
15856
  const home = homeOverride ?? import_node_os.default.homedir();
15567
15857
  const sessionsRoot = import_node_path2.default.join(home, ".codex", "sessions");
@@ -15620,6 +15910,8 @@ function isSyntheticCodexTurn(role, text) {
15620
15910
  if (trimmed.startsWith("<environment_context>")) return true;
15621
15911
  if (trimmed.startsWith("<turn_aborted>")) return true;
15622
15912
  if (/^(<<ccr:[^>]*>>\s*)+$/.test(trimmed)) return true;
15913
+ if (isLeakedSquadContextText(trimmed)) return true;
15914
+ if (isAgentMetaBlock(trimmed)) return true;
15623
15915
  return false;
15624
15916
  }
15625
15917
  function parseHistoryFile2(filePath) {
@@ -15916,16 +16208,16 @@ function getCurrentUsage2(historyDir) {
15916
16208
  var import_node_child_process4 = require("child_process");
15917
16209
 
15918
16210
  // src/agents/codex/local-token.ts
15919
- var fs21 = __toESM(require("fs"));
15920
- var os19 = __toESM(require("os"));
15921
- var path24 = __toESM(require("path"));
16211
+ var fs22 = __toESM(require("fs"));
16212
+ var os20 = __toESM(require("os"));
16213
+ var path25 = __toESM(require("path"));
15922
16214
  function codexCredentialsPath() {
15923
- return path24.join(os19.homedir(), ".codex", "auth.json");
16215
+ return path25.join(os20.homedir(), ".codex", "auth.json");
15924
16216
  }
15925
16217
  async function extractLocalCodexToken() {
15926
16218
  const file = codexCredentialsPath();
15927
- if (!fs21.existsSync(file)) return null;
15928
- const credential = fs21.readFileSync(file, "utf8").trim();
16219
+ if (!fs22.existsSync(file)) return null;
16220
+ const credential = fs22.readFileSync(file, "utf8").trim();
15929
16221
  if (credential.length === 0) return null;
15930
16222
  return { method: "oauth", credential, source: "flat-file" };
15931
16223
  }
@@ -15984,8 +16276,8 @@ function codexCredentialLocator() {
15984
16276
  function codexLoginLauncher() {
15985
16277
  return {
15986
16278
  async ensureInstalled() {
15987
- const os66 = createOsStrategy();
15988
- return os66.findInPath("codex") !== null;
16279
+ const os67 = createOsStrategy();
16280
+ return os67.findInPath("codex") !== null;
15989
16281
  },
15990
16282
  launch() {
15991
16283
  return (0, import_node_child_process4.spawn)("codex", ["login"], { stdio: "inherit" });
@@ -16008,8 +16300,8 @@ var CodexRuntimeStrategy = class {
16008
16300
  meta = getAgent("codex");
16009
16301
  mode = "interactive";
16010
16302
  os;
16011
- constructor(os66) {
16012
- this.os = os66;
16303
+ constructor(os67) {
16304
+ this.os = os67;
16013
16305
  }
16014
16306
  async prepareLaunch() {
16015
16307
  let binary = this.os.findInPath("codex");
@@ -16118,12 +16410,12 @@ var CodexRuntimeStrategy = class {
16118
16410
  });
16119
16411
  }
16120
16412
  };
16121
- function resolveNpm(os66) {
16122
- return os66.id === "win32" ? "npm.cmd" : "npm";
16413
+ function resolveNpm(os67) {
16414
+ return os67.id === "win32" ? "npm.cmd" : "npm";
16123
16415
  }
16124
- async function installCodexViaNpm(os66) {
16416
+ async function installCodexViaNpm(os67) {
16125
16417
  return new Promise((resolve9, reject) => {
16126
- const proc = (0, import_node_child_process5.spawn)(resolveNpm(os66), ["install", "-g", "@openai/codex"], {
16418
+ const proc = (0, import_node_child_process5.spawn)(resolveNpm(os67), ["install", "-g", "@openai/codex"], {
16127
16419
  stdio: "inherit"
16128
16420
  });
16129
16421
  proc.on("close", (code) => {
@@ -16140,16 +16432,16 @@ async function installCodexViaNpm(os66) {
16140
16432
  });
16141
16433
  });
16142
16434
  }
16143
- function augmentNpmGlobalBin(os66) {
16435
+ function augmentNpmGlobalBin(os67) {
16144
16436
  try {
16145
- const result = (0, import_node_child_process5.spawnSync)(resolveNpm(os66), ["prefix", "-g"], {
16437
+ const result = (0, import_node_child_process5.spawnSync)(resolveNpm(os67), ["prefix", "-g"], {
16146
16438
  stdio: ["ignore", "pipe", "ignore"]
16147
16439
  });
16148
16440
  if (result.status !== 0) return;
16149
16441
  const prefix = result.stdout.toString().trim();
16150
16442
  if (!prefix) return;
16151
- const binDir = os66.id === "win32" ? prefix : path25.join(prefix, "bin");
16152
- os66.augmentPath([binDir]);
16443
+ const binDir = os67.id === "win32" ? prefix : path26.join(prefix, "bin");
16444
+ os67.augmentPath([binDir]);
16153
16445
  } catch {
16154
16446
  }
16155
16447
  }
@@ -16233,7 +16525,7 @@ var import_node_child_process9 = require("child_process");
16233
16525
  // src/agents/coderabbit/installer.ts
16234
16526
  var import_node_child_process7 = require("child_process");
16235
16527
  var import_node_fs5 = require("fs");
16236
- var path27 = __toESM(require("path"));
16528
+ var path28 = __toESM(require("path"));
16237
16529
 
16238
16530
  // src/commands/host/os-packages.ts
16239
16531
  var import_node_child_process6 = require("child_process");
@@ -16560,11 +16852,11 @@ function manualInstallHint(runner, tools) {
16560
16852
  const argv = osPackageInstallArgv(detectPackageManager(runner), [...tools]);
16561
16853
  return argv ? `\`sudo ${argv.join(" ")}\`` : `your package manager (e.g. \`${pkgs}\`)`;
16562
16854
  }
16563
- function writeUnzipShim(os66, runner) {
16855
+ function writeUnzipShim(os67, runner) {
16564
16856
  const python = ["python3", "python"].find((p2) => runner.which(p2));
16565
16857
  if (!python) return null;
16566
- const dir = os66.scratchPath("codeam-cr-prereq");
16567
- const shim = path27.join(dir, "unzip");
16858
+ const dir = os67.scratchPath("codeam-cr-prereq");
16859
+ const shim = path28.join(dir, "unzip");
16568
16860
  const script = `#!/bin/sh
16569
16861
  set -e
16570
16862
  archive=""
@@ -16585,9 +16877,9 @@ exec ${python} -m zipfile -e "$archive" "$dest"
16585
16877
  (0, import_node_fs5.chmodSync)(shim, 448);
16586
16878
  return dir;
16587
16879
  }
16588
- async function ensureInstallPrerequisites(os66, deps = {}) {
16880
+ async function ensureInstallPrerequisites(os67, deps = {}) {
16589
16881
  const runner = deps.runner ?? defaultHeadroomRunner;
16590
- const missing = REQUIRED_TOOLS.filter((t2) => os66.findInPath(t2) === null);
16882
+ const missing = REQUIRED_TOOLS.filter((t2) => os67.findInPath(t2) === null);
16591
16883
  if (missing.length === 0) return { ok: true, extraPath: [] };
16592
16884
  log.info(
16593
16885
  "coderabbit",
@@ -16606,10 +16898,10 @@ async function ensureInstallPrerequisites(os66, deps = {}) {
16606
16898
  );
16607
16899
  }
16608
16900
  }
16609
- const stillMissing = REQUIRED_TOOLS.filter((t2) => os66.findInPath(t2) === null);
16901
+ const stillMissing = REQUIRED_TOOLS.filter((t2) => os67.findInPath(t2) === null);
16610
16902
  if (stillMissing.length === 0) return { ok: true, extraPath: [] };
16611
16903
  if (stillMissing.length === 1 && stillMissing[0] === "unzip") {
16612
- const shimDir = writeUnzipShim(os66, runner);
16904
+ const shimDir = writeUnzipShim(os67, runner);
16613
16905
  if (shimDir) {
16614
16906
  log.info("coderabbit", "unzip is unavailable \u2014 using a scoped python zipfile shim");
16615
16907
  return { ok: true, extraPath: [shimDir] };
@@ -16672,15 +16964,15 @@ function summarizeInstallFailure(output) {
16672
16964
  }
16673
16965
  return lines.length > 0 ? lines[lines.length - 1] : null;
16674
16966
  }
16675
- async function ensureCoderabbitInstalled(os66, deps = {}) {
16676
- if (os66.findInPath("coderabbit")) return { ok: true };
16677
- if (os66.id === "win32") {
16967
+ async function ensureCoderabbitInstalled(os67, deps = {}) {
16968
+ if (os67.findInPath("coderabbit")) return { ok: true };
16969
+ if (os67.id === "win32") {
16678
16970
  return {
16679
16971
  ok: false,
16680
16972
  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."
16681
16973
  };
16682
16974
  }
16683
- const prereq = await ensureInstallPrerequisites(os66, deps);
16975
+ const prereq = await ensureInstallPrerequisites(os67, deps);
16684
16976
  if (!prereq.ok) return { ok: false, error: prereq.error };
16685
16977
  const env = { ...process.env };
16686
16978
  if (prereq.extraPath.length > 0) {
@@ -16689,8 +16981,8 @@ async function ensureCoderabbitInstalled(os66, deps = {}) {
16689
16981
  log.info("coderabbit", "CodeRabbit CLI not found \u2014 installing via the official script");
16690
16982
  const run = deps.runInstallScript ?? defaultRunInstallScript;
16691
16983
  const { code, output } = await run(env);
16692
- os66.augmentPath([`${os66.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
16693
- const binary = os66.findInPath("coderabbit");
16984
+ os67.augmentPath([`${os67.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
16985
+ const binary = os67.findInPath("coderabbit");
16694
16986
  const detail = summarizeInstallFailure(output);
16695
16987
  if (binary !== null) {
16696
16988
  if (code === 0) return { ok: true };
@@ -16714,9 +17006,9 @@ async function ensureCoderabbitInstalled(os66, deps = {}) {
16714
17006
 
16715
17007
  // src/agents/coderabbit/link.ts
16716
17008
  var import_node_child_process8 = require("child_process");
16717
- var fs23 = __toESM(require("fs"));
16718
- var os21 = __toESM(require("os"));
16719
- var path28 = __toESM(require("path"));
17009
+ var fs24 = __toESM(require("fs"));
17010
+ var os22 = __toESM(require("os"));
17011
+ var path29 = __toESM(require("path"));
16720
17012
 
16721
17013
  // src/agents/strategy.ts
16722
17014
  function validateNonEmptyCredential(token) {
@@ -16725,12 +17017,12 @@ function validateNonEmptyCredential(token) {
16725
17017
 
16726
17018
  // src/agents/coderabbit/link.ts
16727
17019
  function authPath() {
16728
- return path28.join(os21.homedir(), ".coderabbit", "auth.json");
17020
+ return path29.join(os22.homedir(), ".coderabbit", "auth.json");
16729
17021
  }
16730
17022
  async function extractLocalCoderabbitToken() {
16731
17023
  const file = authPath();
16732
- if (!fs23.existsSync(file)) return null;
16733
- const credential = fs23.readFileSync(file, "utf8").trim();
17024
+ if (!fs24.existsSync(file)) return null;
17025
+ const credential = fs24.readFileSync(file, "utf8").trim();
16734
17026
  if (credential.length === 0) return null;
16735
17027
  return { method: "oauth", credential, source: "flat-file" };
16736
17028
  }
@@ -16744,10 +17036,10 @@ function coderabbitCredentialLocator() {
16744
17036
  validate: validateNonEmptyCredential
16745
17037
  };
16746
17038
  }
16747
- function coderabbitLoginLauncher(os66) {
17039
+ function coderabbitLoginLauncher(os67) {
16748
17040
  return {
16749
17041
  async ensureInstalled() {
16750
- const result = await ensureCoderabbitInstalled(os66);
17042
+ const result = await ensureCoderabbitInstalled(os67);
16751
17043
  if (!result.ok && result.error) console.error(`
16752
17044
  \u2717 ${result.error}
16753
17045
  `);
@@ -16807,8 +17099,8 @@ function pickLine(obj) {
16807
17099
  function toHunk(raw, groupSeverity) {
16808
17100
  if (!raw || typeof raw !== "object") return null;
16809
17101
  const o = raw;
16810
- const path91 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
16811
- if (!path91) return null;
17102
+ const path92 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
17103
+ if (!path92) return null;
16812
17104
  const message = asString(
16813
17105
  pick(o, [
16814
17106
  "comment",
@@ -16825,7 +17117,7 @@ function toHunk(raw, groupSeverity) {
16825
17117
  const severity = normSeverity(pick(o, ["severity", "level", "priority", "impact"])) ?? normSeverity(groupSeverity);
16826
17118
  const locObj = pick(o, ["location"]) ?? o;
16827
17119
  return {
16828
- path: path91.trim(),
17120
+ path: path92.trim(),
16829
17121
  line: pickLine(o) ?? pickLine(locObj),
16830
17122
  severity,
16831
17123
  message: (title && message ? `${title}: ${message}` : title || message).trim() || "(no message)"
@@ -16908,10 +17200,10 @@ function parsePlain(stdout) {
16908
17200
  for (const line of stdout.split(/\r?\n/)) {
16909
17201
  const m = line.match(HUNK_LINE_RE);
16910
17202
  if (!m) continue;
16911
- const [, path91, lineNo, sevToken, message] = m;
16912
- if (!path91 || !lineNo || !message) continue;
17203
+ const [, path92, lineNo, sevToken, message] = m;
17204
+ if (!path92 || !lineNo || !message) continue;
16913
17205
  hunks.push({
16914
- path: path91.trim(),
17206
+ path: path92.trim(),
16915
17207
  line: Number(lineNo),
16916
17208
  severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
16917
17209
  message: message.trim().replace(/^[*-]\s+/, "")
@@ -16971,8 +17263,8 @@ var CoderabbitRuntimeStrategy = class {
16971
17263
  meta = getAgent("coderabbit");
16972
17264
  mode = "batch";
16973
17265
  os;
16974
- constructor(os66) {
16975
- this.os = os66;
17266
+ constructor(os67) {
17267
+ this.os = os67;
16976
17268
  }
16977
17269
  getDefaultArgs() {
16978
17270
  return ["review", "--agent"];
@@ -17074,39 +17366,39 @@ CodeRabbit review timed out after ${Math.round(
17074
17366
  };
17075
17367
 
17076
17368
  // src/agents/cursor/history.ts
17077
- var fs24 = __toESM(require("fs"));
17078
- var os22 = __toESM(require("os"));
17079
- var path29 = __toESM(require("path"));
17369
+ var fs25 = __toESM(require("fs"));
17370
+ var os23 = __toESM(require("os"));
17371
+ var path30 = __toESM(require("path"));
17080
17372
  var import_node_crypto5 = require("crypto");
17081
- var HISTORY_ROOT = path29.join(os22.homedir(), ".cursor", "projects");
17082
- var CURSOR_HOME = path29.join(os22.homedir(), ".cursor");
17373
+ var HISTORY_ROOT = path30.join(os23.homedir(), ".cursor", "projects");
17374
+ var CURSOR_HOME = path30.join(os23.homedir(), ".cursor");
17083
17375
  var STORE_FILES = ["store.db", "store.db-wal", "store.db-shm"];
17084
17376
  function acpSessionDir(sessionId) {
17085
- return path29.join(CURSOR_HOME, "acp-sessions", sessionId);
17377
+ return path30.join(CURSOR_HOME, "acp-sessions", sessionId);
17086
17378
  }
17087
17379
  function nativeStoreDir(cwd, sessionId) {
17088
- const chatsRoot = path29.join(CURSOR_HOME, "chats");
17380
+ const chatsRoot = path30.join(CURSOR_HOME, "chats");
17089
17381
  let buckets = [];
17090
17382
  try {
17091
- buckets = fs24.readdirSync(chatsRoot);
17383
+ buckets = fs25.readdirSync(chatsRoot);
17092
17384
  } catch {
17093
17385
  }
17094
17386
  for (const b of buckets) {
17095
- const candidate = path29.join(chatsRoot, b, sessionId);
17096
- if (fs24.existsSync(path29.join(candidate, "store.db"))) return candidate;
17387
+ const candidate = path30.join(chatsRoot, b, sessionId);
17388
+ if (fs25.existsSync(path30.join(candidate, "store.db"))) return candidate;
17097
17389
  }
17098
- const computed = path29.join(chatsRoot, (0, import_node_crypto5.createHash)("md5").update(cwd).digest("hex"), sessionId);
17099
- return fs24.existsSync(computed) ? computed : null;
17390
+ const computed = path30.join(chatsRoot, (0, import_node_crypto5.createHash)("md5").update(cwd).digest("hex"), sessionId);
17391
+ return fs25.existsSync(computed) ? computed : null;
17100
17392
  }
17101
17393
  function copyStoreFiles(srcDir, dstDir) {
17102
- fs24.mkdirSync(dstDir, { recursive: true });
17394
+ fs25.mkdirSync(dstDir, { recursive: true });
17103
17395
  for (const f of STORE_FILES) {
17104
- const dst = path29.join(dstDir, f);
17105
- if (fs24.existsSync(dst)) fs24.rmSync(dst, { force: true });
17396
+ const dst = path30.join(dstDir, f);
17397
+ if (fs25.existsSync(dst)) fs25.rmSync(dst, { force: true });
17106
17398
  }
17107
17399
  for (const f of STORE_FILES) {
17108
- const src = path29.join(srcDir, f);
17109
- if (fs24.existsSync(src)) fs24.copyFileSync(src, path29.join(dstDir, f));
17400
+ const src = path30.join(srcDir, f);
17401
+ if (fs25.existsSync(src)) fs25.copyFileSync(src, path30.join(dstDir, f));
17110
17402
  }
17111
17403
  }
17112
17404
  function bridgeNativeToAcp(cwd, sessionId) {
@@ -17118,8 +17410,8 @@ function bridgeNativeToAcp(cwd, sessionId) {
17118
17410
  }
17119
17411
  const dst = acpSessionDir(sessionId);
17120
17412
  copyStoreFiles(src, dst);
17121
- fs24.writeFileSync(
17122
- path29.join(dst, "meta.json"),
17413
+ fs25.writeFileSync(
17414
+ path30.join(dst, "meta.json"),
17123
17415
  JSON.stringify({ schemaVersion: 1, cwd })
17124
17416
  );
17125
17417
  log.info("cursor", `baton bridge native\u2192acp ok (${sessionId.slice(0, 8)})`);
@@ -17130,11 +17422,11 @@ function bridgeNativeToAcp(cwd, sessionId) {
17130
17422
  function bridgeAcpToNative(cwd, sessionId) {
17131
17423
  try {
17132
17424
  const src = acpSessionDir(sessionId);
17133
- if (!fs24.existsSync(path29.join(src, "store.db"))) {
17425
+ if (!fs25.existsSync(path30.join(src, "store.db"))) {
17134
17426
  log.warn("cursor", `baton bridge: no acp store for ${sessionId.slice(0, 8)} \u2014 skip`);
17135
17427
  return;
17136
17428
  }
17137
- const dst = nativeStoreDir(cwd, sessionId) ?? path29.join(CURSOR_HOME, "chats", (0, import_node_crypto5.createHash)("md5").update(cwd).digest("hex"), sessionId);
17429
+ const dst = nativeStoreDir(cwd, sessionId) ?? path30.join(CURSOR_HOME, "chats", (0, import_node_crypto5.createHash)("md5").update(cwd).digest("hex"), sessionId);
17138
17430
  copyStoreFiles(src, dst);
17139
17431
  log.info("cursor", `baton bridge acp\u2192native ok (${sessionId.slice(0, 8)})`);
17140
17432
  } catch (err) {
@@ -17145,26 +17437,26 @@ function encodeCursorCwd(cwd) {
17145
17437
  return cwd.replace(/^[/\\]+/, "").replace(/[/\\:]/g, "-");
17146
17438
  }
17147
17439
  function resolveHistoryFile3(cwd, sessionId, root = HISTORY_ROOT) {
17148
- const rel = path29.join("agent-transcripts", sessionId, `${sessionId}.jsonl`);
17149
- const primary = path29.join(root, encodeCursorCwd(cwd), rel);
17150
- if (fs24.existsSync(primary)) return primary;
17440
+ const rel = path30.join("agent-transcripts", sessionId, `${sessionId}.jsonl`);
17441
+ const primary = path30.join(root, encodeCursorCwd(cwd), rel);
17442
+ if (fs25.existsSync(primary)) return primary;
17151
17443
  let entries;
17152
17444
  try {
17153
- entries = fs24.readdirSync(root, { withFileTypes: true });
17445
+ entries = fs25.readdirSync(root, { withFileTypes: true });
17154
17446
  } catch {
17155
17447
  return null;
17156
17448
  }
17157
17449
  for (const e of entries) {
17158
17450
  if (!e.isDirectory()) continue;
17159
- const candidate = path29.join(root, e.name, rel);
17160
- if (fs24.existsSync(candidate)) return candidate;
17451
+ const candidate = path30.join(root, e.name, rel);
17452
+ if (fs25.existsSync(candidate)) return candidate;
17161
17453
  }
17162
17454
  return null;
17163
17455
  }
17164
17456
  function resolveHistoryDir3(cwd) {
17165
- if (!fs24.existsSync(HISTORY_ROOT)) return null;
17166
- const dir = path29.join(HISTORY_ROOT, encodeCursorCwd(cwd));
17167
- return fs24.existsSync(dir) ? dir : null;
17457
+ if (!fs25.existsSync(HISTORY_ROOT)) return null;
17458
+ const dir = path30.join(HISTORY_ROOT, encodeCursorCwd(cwd));
17459
+ return fs25.existsSync(dir) ? dir : null;
17168
17460
  }
17169
17461
  function extractText2(content) {
17170
17462
  if (!Array.isArray(content)) return "";
@@ -17177,7 +17469,7 @@ function unwrapUserQuery(text) {
17177
17469
  function parseHistoryFile3(filePath) {
17178
17470
  let raw;
17179
17471
  try {
17180
- raw = fs24.readFileSync(filePath, "utf8");
17472
+ raw = fs25.readFileSync(filePath, "utf8");
17181
17473
  } catch {
17182
17474
  return [];
17183
17475
  }
@@ -17215,16 +17507,16 @@ function getCurrentUsage3(_historyDir) {
17215
17507
  var import_node_child_process10 = require("child_process");
17216
17508
 
17217
17509
  // src/agents/cursor/local-token.ts
17218
- var fs25 = __toESM(require("fs"));
17219
- var os23 = __toESM(require("os"));
17220
- var path30 = __toESM(require("path"));
17510
+ var fs26 = __toESM(require("fs"));
17511
+ var os24 = __toESM(require("os"));
17512
+ var path31 = __toESM(require("path"));
17221
17513
  function cursorCredentialsPath() {
17222
- return path30.join(os23.homedir(), ".cursor", "auth.json");
17514
+ return path31.join(os24.homedir(), ".cursor", "auth.json");
17223
17515
  }
17224
17516
  async function extractLocalCursorToken() {
17225
17517
  const file = cursorCredentialsPath();
17226
- if (!fs25.existsSync(file)) return null;
17227
- const credential = fs25.readFileSync(file, "utf8").trim();
17518
+ if (!fs26.existsSync(file)) return null;
17519
+ const credential = fs26.readFileSync(file, "utf8").trim();
17228
17520
  if (credential.length === 0) return null;
17229
17521
  return { method: "oauth", credential, source: "flat-file" };
17230
17522
  }
@@ -17243,10 +17535,10 @@ function cursorCredentialLocator() {
17243
17535
  validate: validateNonEmptyCredential
17244
17536
  };
17245
17537
  }
17246
- function cursorLoginLauncher(os66) {
17538
+ function cursorLoginLauncher(os67) {
17247
17539
  return {
17248
17540
  async ensureInstalled() {
17249
- if (os66.findInPath("cursor-agent")) return true;
17541
+ if (os67.findInPath("cursor-agent")) return true;
17250
17542
  console.error(
17251
17543
  "\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"
17252
17544
  );
@@ -17310,8 +17602,8 @@ var CursorRuntimeStrategy = class {
17310
17602
  meta = getAgent("cursor");
17311
17603
  mode = "interactive";
17312
17604
  os;
17313
- constructor(os66) {
17314
- this.os = os66;
17605
+ constructor(os67) {
17606
+ this.os = os67;
17315
17607
  }
17316
17608
  async prepareLaunch() {
17317
17609
  const binary = this.os.findInPath("cursor-agent");
@@ -17467,12 +17759,12 @@ var CursorRuntimeStrategy = class {
17467
17759
  };
17468
17760
 
17469
17761
  // src/agents/aider/history.ts
17470
- var fs26 = __toESM(require("fs"));
17471
- var path31 = __toESM(require("path"));
17762
+ var fs27 = __toESM(require("fs"));
17763
+ var path32 = __toESM(require("path"));
17472
17764
  var AIDER_HISTORY_FILE = ".aider.chat.history.md";
17473
17765
  function resolveHistoryDir4(cwd) {
17474
- const candidate = path31.join(cwd, AIDER_HISTORY_FILE);
17475
- return fs26.existsSync(candidate) ? cwd : null;
17766
+ const candidate = path32.join(cwd, AIDER_HISTORY_FILE);
17767
+ return fs27.existsSync(candidate) ? cwd : null;
17476
17768
  }
17477
17769
  function parseHistoryFile4(_filePath) {
17478
17770
  return [];
@@ -17485,10 +17777,10 @@ function getCurrentUsage4(_historyDir) {
17485
17777
  var import_node_child_process12 = require("child_process");
17486
17778
 
17487
17779
  // src/agents/aider/local-token.ts
17488
- var fs27 = __toESM(require("fs"));
17489
- var os24 = __toESM(require("os"));
17490
- var path32 = __toESM(require("path"));
17491
- var AIDER_CONF_FILE = path32.join(os24.homedir(), ".aider.conf.yml");
17780
+ var fs28 = __toESM(require("fs"));
17781
+ var os25 = __toESM(require("os"));
17782
+ var path33 = __toESM(require("path"));
17783
+ var AIDER_CONF_FILE = path33.join(os25.homedir(), ".aider.conf.yml");
17492
17784
  var API_KEY_ENV_VARS = [
17493
17785
  "ANTHROPIC_API_KEY",
17494
17786
  "OPENAI_API_KEY",
@@ -17503,8 +17795,8 @@ async function extractLocalAiderToken() {
17503
17795
  return { method: "api_key", credential: value.trim(), source: "flat-file" };
17504
17796
  }
17505
17797
  }
17506
- if (fs27.existsSync(AIDER_CONF_FILE)) {
17507
- const conf = fs27.readFileSync(AIDER_CONF_FILE, "utf8");
17798
+ if (fs28.existsSync(AIDER_CONF_FILE)) {
17799
+ const conf = fs28.readFileSync(AIDER_CONF_FILE, "utf8");
17508
17800
  const match = conf.match(/^api-key:\s*['"]?([^'"\n]+)['"]?\s*$/m);
17509
17801
  if (match) {
17510
17802
  return { method: "api_key", credential: match[1].trim(), source: "flat-file" };
@@ -17527,10 +17819,10 @@ function aiderCredentialLocator() {
17527
17819
  validate: validateNonEmptyCredential
17528
17820
  };
17529
17821
  }
17530
- function aiderLoginLauncher(os66) {
17822
+ function aiderLoginLauncher(os67) {
17531
17823
  return {
17532
17824
  async ensureInstalled() {
17533
- if (os66.findInPath("aider")) return true;
17825
+ if (os67.findInPath("aider")) return true;
17534
17826
  console.error(
17535
17827
  "\n \u2717 aider binary not on PATH.\n Install Aider:\n pip install aider-chat\n then re-run `codeam link aider`.\n"
17536
17828
  );
@@ -17540,7 +17832,7 @@ function aiderLoginLauncher(os66) {
17540
17832
  console.error(
17541
17833
  "\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"
17542
17834
  );
17543
- return (0, import_node_child_process12.spawn)(os66.id === "win32" ? "cmd.exe" : "sh", os66.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
17835
+ return (0, import_node_child_process12.spawn)(os67.id === "win32" ? "cmd.exe" : "sh", os67.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
17544
17836
  stdio: "ignore"
17545
17837
  });
17546
17838
  }
@@ -17804,8 +18096,8 @@ var AiderRuntimeStrategy = class {
17804
18096
  meta = getAgent("aider");
17805
18097
  mode = "interactive";
17806
18098
  os;
17807
- constructor(os66) {
17808
- this.os = os66;
18099
+ constructor(os67) {
18100
+ this.os = os67;
17809
18101
  }
17810
18102
  async prepareLaunch() {
17811
18103
  augmentUserLocalBinPaths();
@@ -17880,19 +18172,19 @@ var import_node_crypto6 = require("crypto");
17880
18172
  var import_node_child_process13 = require("child_process");
17881
18173
 
17882
18174
  // src/agents/gemini/local-token.ts
17883
- var fs29 = __toESM(require("fs"));
17884
- var os26 = __toESM(require("os"));
17885
- var path34 = __toESM(require("path"));
18175
+ var fs30 = __toESM(require("fs"));
18176
+ var os27 = __toESM(require("os"));
18177
+ var path35 = __toESM(require("path"));
17886
18178
  function geminiCredentialsPath() {
17887
- return path34.join(os26.homedir(), ".gemini", "oauth_creds.json");
18179
+ return path35.join(os27.homedir(), ".gemini", "oauth_creds.json");
17888
18180
  }
17889
18181
  function geminiCredentialsPaths() {
17890
18182
  return [geminiCredentialsPath()];
17891
18183
  }
17892
18184
  async function extractLocalGeminiToken() {
17893
18185
  const file = geminiCredentialsPath();
17894
- if (!fs29.existsSync(file)) return null;
17895
- const credential = fs29.readFileSync(file, "utf8").trim();
18186
+ if (!fs30.existsSync(file)) return null;
18187
+ const credential = fs30.readFileSync(file, "utf8").trim();
17896
18188
  if (credential.length === 0) return null;
17897
18189
  return { method: "oauth", credential, source: "flat-file" };
17898
18190
  }
@@ -17938,8 +18230,8 @@ function geminiCredentialLocator() {
17938
18230
  function geminiLoginLauncher() {
17939
18231
  return {
17940
18232
  async ensureInstalled() {
17941
- const os66 = createOsStrategy();
17942
- return os66.findInPath("gemini") !== null;
18233
+ const os67 = createOsStrategy();
18234
+ return os67.findInPath("gemini") !== null;
17943
18235
  },
17944
18236
  launch() {
17945
18237
  return (0, import_node_child_process13.spawn)("gemini", ["auth", "login"], { stdio: "inherit" });
@@ -17948,20 +18240,20 @@ function geminiLoginLauncher() {
17948
18240
  }
17949
18241
 
17950
18242
  // src/agents/gemini/history.ts
17951
- var fs30 = __toESM(require("fs"));
17952
- var os27 = __toESM(require("os"));
17953
- var path35 = __toESM(require("path"));
17954
- var GEMINI_ROOT = path35.join(os27.homedir(), ".gemini");
18243
+ var fs31 = __toESM(require("fs"));
18244
+ var os28 = __toESM(require("os"));
18245
+ var path36 = __toESM(require("path"));
18246
+ var GEMINI_ROOT = path36.join(os28.homedir(), ".gemini");
17955
18247
  function projectNameForCwd(cwd, root) {
17956
18248
  try {
17957
18249
  const parsed = JSON.parse(
17958
- fs30.readFileSync(path35.join(root, "projects.json"), "utf8")
18250
+ fs31.readFileSync(path36.join(root, "projects.json"), "utf8")
17959
18251
  );
17960
18252
  const map = parsed.projects;
17961
18253
  if (map && typeof map === "object") {
17962
18254
  if (typeof map[cwd] === "string") return map[cwd];
17963
18255
  try {
17964
- const rp = fs30.realpathSync(cwd);
18256
+ const rp = fs31.realpathSync(cwd);
17965
18257
  if (typeof map[rp] === "string") return map[rp];
17966
18258
  } catch {
17967
18259
  }
@@ -17970,7 +18262,7 @@ function projectNameForCwd(cwd, root) {
17970
18262
  } catch (err) {
17971
18263
  log.debug("gemini", `projects.json unreadable at ${root} \u2014 using basename fallback`, err);
17972
18264
  }
17973
- return path35.basename(cwd) || null;
18265
+ return path36.basename(cwd) || null;
17974
18266
  }
17975
18267
  function resolveHistoryDir5(cwd, root = GEMINI_ROOT) {
17976
18268
  const name = projectNameForCwd(cwd, root);
@@ -17978,8 +18270,8 @@ function resolveHistoryDir5(cwd, root = GEMINI_ROOT) {
17978
18270
  log.warn("gemini", `resolveHistoryDir \u2014 could not derive a project name for cwd=${cwd}`);
17979
18271
  return null;
17980
18272
  }
17981
- const dir = path35.join(root, "tmp", name, "chats");
17982
- if (!fs30.existsSync(dir)) {
18273
+ const dir = path36.join(root, "tmp", name, "chats");
18274
+ if (!fs31.existsSync(dir)) {
17983
18275
  log.debug("gemini", `resolveHistoryDir \u2014 chats dir not present yet: ${dir} (project=${name})`);
17984
18276
  return null;
17985
18277
  }
@@ -17991,7 +18283,7 @@ function resolveHistoryFile4(cwd, sessionId, root = GEMINI_ROOT) {
17991
18283
  if (!dir) return null;
17992
18284
  let files;
17993
18285
  try {
17994
- files = fs30.readdirSync(dir).filter((f) => f.startsWith("session-") && f.endsWith(".jsonl"));
18286
+ files = fs31.readdirSync(dir).filter((f) => f.startsWith("session-") && f.endsWith(".jsonl"));
17995
18287
  } catch (err) {
17996
18288
  log.warn("gemini", `resolveHistoryFile \u2014 cannot read chats dir ${dir} (id8=${id8})`, err);
17997
18289
  return null;
@@ -18003,12 +18295,12 @@ function resolveHistoryFile4(cwd, sessionId, root = GEMINI_ROOT) {
18003
18295
  const byName = files.find((f) => id8.length > 0 && f.includes(id8));
18004
18296
  if (byName) {
18005
18297
  log.info("gemini", `resolveHistoryFile \u2014 matched by filename id8=${id8}: ${byName}`);
18006
- return path35.join(dir, byName);
18298
+ return path36.join(dir, byName);
18007
18299
  }
18008
18300
  for (const f of files) {
18009
- const full = path35.join(dir, f);
18301
+ const full = path36.join(dir, f);
18010
18302
  try {
18011
- const firstLine = fs30.readFileSync(full, "utf8").split("\n", 1)[0] ?? "";
18303
+ const firstLine = fs31.readFileSync(full, "utf8").split("\n", 1)[0] ?? "";
18012
18304
  const hdr = JSON.parse(firstLine);
18013
18305
  if (hdr.sessionId === sessionId) {
18014
18306
  log.info("gemini", `resolveHistoryFile \u2014 matched by header sessionId: ${f}`);
@@ -18021,7 +18313,7 @@ function resolveHistoryFile4(cwd, sessionId, root = GEMINI_ROOT) {
18021
18313
  let newest = null;
18022
18314
  for (const f of files) {
18023
18315
  try {
18024
- const mtime = fs30.statSync(path35.join(dir, f)).mtimeMs;
18316
+ const mtime = fs31.statSync(path36.join(dir, f)).mtimeMs;
18025
18317
  if (!newest || mtime > newest.mtime) newest = { file: f, mtime };
18026
18318
  } catch {
18027
18319
  }
@@ -18030,7 +18322,7 @@ function resolveHistoryFile4(cwd, sessionId, root = GEMINI_ROOT) {
18030
18322
  "gemini",
18031
18323
  `resolveHistoryFile \u2014 no id8=${id8} match among ${files.length} file(s) in ${dir}; falling back to newest=${newest?.file ?? "none"}`
18032
18324
  );
18033
- return newest ? path35.join(dir, newest.file) : null;
18325
+ return newest ? path36.join(dir, newest.file) : null;
18034
18326
  }
18035
18327
  function extractGeminiText(content) {
18036
18328
  const fromParts = (arr) => Array.isArray(arr) ? arr.map((p2) => {
@@ -18058,7 +18350,7 @@ function isSyntheticGeminiTurn(text) {
18058
18350
  function parseHistoryFile5(filePath) {
18059
18351
  let raw;
18060
18352
  try {
18061
- raw = fs30.readFileSync(filePath, "utf8");
18353
+ raw = fs31.readFileSync(filePath, "utf8");
18062
18354
  } catch (err) {
18063
18355
  log.warn("gemini", `parseHistoryFile \u2014 cannot read ${filePath}`, err);
18064
18356
  return [];
@@ -18099,7 +18391,7 @@ function parseHistoryFile5(filePath) {
18099
18391
  }
18100
18392
  log.trace(
18101
18393
  "gemini",
18102
- `parseHistoryFile \u2014 ${out2.length} turn(s) from ${path35.basename(filePath)}` + (malformed > 0 ? ` (${malformed} malformed line(s) skipped)` : "")
18394
+ `parseHistoryFile \u2014 ${out2.length} turn(s) from ${path36.basename(filePath)}` + (malformed > 0 ? ` (${malformed} malformed line(s) skipped)` : "")
18103
18395
  );
18104
18396
  return out2;
18105
18397
  }
@@ -18129,8 +18421,8 @@ var GeminiRuntimeStrategy = class {
18129
18421
  meta = getAgent("gemini");
18130
18422
  mode = "interactive";
18131
18423
  os;
18132
- constructor(os66) {
18133
- this.os = os66;
18424
+ constructor(os67) {
18425
+ this.os = os67;
18134
18426
  }
18135
18427
  async prepareLaunch() {
18136
18428
  const binary = this.os.findInPath("gemini");
@@ -18243,42 +18535,42 @@ var import_node_os3 = require("os");
18243
18535
  var import_node_path4 = require("path");
18244
18536
 
18245
18537
  // src/agents/kimi/history.ts
18246
- var fs31 = __toESM(require("fs"));
18247
- var os28 = __toESM(require("os"));
18248
- var path36 = __toESM(require("path"));
18538
+ var fs32 = __toESM(require("fs"));
18539
+ var os29 = __toESM(require("os"));
18540
+ var path37 = __toESM(require("path"));
18249
18541
  var import_node_crypto7 = require("crypto");
18250
18542
  function kimiHome() {
18251
- return process.env.KIMI_CODE_HOME || path36.join(os28.homedir(), ".kimi-code");
18543
+ return process.env.KIMI_CODE_HOME || path37.join(os29.homedir(), ".kimi-code");
18252
18544
  }
18253
18545
  function workDirKey(cwd) {
18254
18546
  const hash = (0, import_node_crypto7.createHash)("sha256").update(cwd).digest("hex").slice(0, 12);
18255
- return `wd_${path36.basename(cwd)}_${hash}`;
18547
+ return `wd_${path37.basename(cwd)}_${hash}`;
18256
18548
  }
18257
18549
  function resolveHistoryDir6(cwd) {
18258
- const dir = path36.join(kimiHome(), "sessions", workDirKey(cwd));
18259
- if (!fs31.existsSync(dir)) {
18550
+ const dir = path37.join(kimiHome(), "sessions", workDirKey(cwd));
18551
+ if (!fs32.existsSync(dir)) {
18260
18552
  log.debug("kimi", `resolveHistoryDir \u2014 session bucket not present yet: ${dir}`);
18261
18553
  return null;
18262
18554
  }
18263
18555
  return dir;
18264
18556
  }
18265
- var WIRE_REL = path36.join("agents", "main", "wire.jsonl");
18557
+ var WIRE_REL = path37.join("agents", "main", "wire.jsonl");
18266
18558
  function resolveHistoryFile5(cwd, sessionId) {
18267
18559
  const fromIndex = sessionDirFromIndex(sessionId);
18268
18560
  if (fromIndex) {
18269
- const p2 = path36.join(fromIndex, WIRE_REL);
18270
- if (fs31.existsSync(p2)) return p2;
18561
+ const p2 = path37.join(fromIndex, WIRE_REL);
18562
+ if (fs32.existsSync(p2)) return p2;
18271
18563
  }
18272
- const bucket2 = path36.join(kimiHome(), "sessions", workDirKey(cwd));
18273
- const computed = path36.join(bucket2, sessionId, WIRE_REL);
18274
- if (fs31.existsSync(computed)) return computed;
18564
+ const bucket2 = path37.join(kimiHome(), "sessions", workDirKey(cwd));
18565
+ const computed = path37.join(bucket2, sessionId, WIRE_REL);
18566
+ if (fs32.existsSync(computed)) return computed;
18275
18567
  const scanned = scanBucketsForSession(sessionId);
18276
18568
  if (scanned) return scanned;
18277
18569
  return null;
18278
18570
  }
18279
18571
  function sessionDirFromIndex(sessionId) {
18280
18572
  try {
18281
- const raw = fs31.readFileSync(path36.join(kimiHome(), "session_index.jsonl"), "utf8");
18573
+ const raw = fs32.readFileSync(path37.join(kimiHome(), "session_index.jsonl"), "utf8");
18282
18574
  for (const line of raw.split("\n")) {
18283
18575
  if (!line.includes(sessionId)) continue;
18284
18576
  try {
@@ -18294,22 +18586,22 @@ function sessionDirFromIndex(sessionId) {
18294
18586
  return null;
18295
18587
  }
18296
18588
  function scanBucketsForSession(sessionId) {
18297
- const sessionsRoot = path36.join(kimiHome(), "sessions");
18589
+ const sessionsRoot = path37.join(kimiHome(), "sessions");
18298
18590
  let buckets;
18299
18591
  try {
18300
- buckets = fs31.readdirSync(sessionsRoot, { withFileTypes: true });
18592
+ buckets = fs32.readdirSync(sessionsRoot, { withFileTypes: true });
18301
18593
  } catch {
18302
18594
  return null;
18303
18595
  }
18304
18596
  for (const b of buckets) {
18305
18597
  if (!b.isDirectory()) continue;
18306
- const candidate = path36.join(sessionsRoot, b.name, sessionId, WIRE_REL);
18307
- if (fs31.existsSync(candidate)) return candidate;
18598
+ const candidate = path37.join(sessionsRoot, b.name, sessionId, WIRE_REL);
18599
+ if (fs32.existsSync(candidate)) return candidate;
18308
18600
  }
18309
18601
  return null;
18310
18602
  }
18311
18603
  async function discoverSessionId2(cwd, opts) {
18312
- const bucket2 = path36.join(kimiHome(), "sessions", workDirKey(cwd));
18604
+ const bucket2 = path37.join(kimiHome(), "sessions", workDirKey(cwd));
18313
18605
  const floor = opts.sinceMs - 2e3;
18314
18606
  const deadline = Date.now() + (opts.timeoutMs ?? 15e3);
18315
18607
  for (; ; ) {
@@ -18322,7 +18614,7 @@ async function discoverSessionId2(cwd, opts) {
18322
18614
  function newestSessionSince(bucket2, floorMs) {
18323
18615
  let entries;
18324
18616
  try {
18325
- entries = fs31.readdirSync(bucket2, { withFileTypes: true });
18617
+ entries = fs32.readdirSync(bucket2, { withFileTypes: true });
18326
18618
  } catch {
18327
18619
  return null;
18328
18620
  }
@@ -18332,7 +18624,7 @@ function newestSessionSince(bucket2, floorMs) {
18332
18624
  if (!e.isDirectory() || !e.name.startsWith("session_")) continue;
18333
18625
  let mtime;
18334
18626
  try {
18335
- mtime = fs31.statSync(path36.join(bucket2, e.name)).mtimeMs;
18627
+ mtime = fs32.statSync(path37.join(bucket2, e.name)).mtimeMs;
18336
18628
  } catch {
18337
18629
  continue;
18338
18630
  }
@@ -18353,7 +18645,7 @@ function joinTextParts(parts) {
18353
18645
  function parseHistoryFile6(filePath) {
18354
18646
  let raw;
18355
18647
  try {
18356
- raw = fs31.readFileSync(filePath, "utf8");
18648
+ raw = fs32.readFileSync(filePath, "utf8");
18357
18649
  } catch {
18358
18650
  return [];
18359
18651
  }
@@ -18421,8 +18713,8 @@ var KimiRuntimeStrategy = class {
18421
18713
  meta = getAgent("kimi");
18422
18714
  mode = "interactive";
18423
18715
  os;
18424
- constructor(os66) {
18425
- this.os = os66;
18716
+ constructor(os67) {
18717
+ this.os = os67;
18426
18718
  }
18427
18719
  async prepareLaunch() {
18428
18720
  const binary = this.os.findInPath("kimi");
@@ -18564,8 +18856,8 @@ var OpencodeRuntimeStrategy = class {
18564
18856
  meta = getAgent("opencode");
18565
18857
  mode = "interactive";
18566
18858
  os;
18567
- constructor(os66) {
18568
- this.os = os66;
18859
+ constructor(os67) {
18860
+ this.os = os67;
18569
18861
  }
18570
18862
  async prepareLaunch() {
18571
18863
  const binary = this.os.findInPath("opencode");
@@ -18649,20 +18941,20 @@ var OpencodeRuntimeStrategy = class {
18649
18941
 
18650
18942
  // src/agents/registry.ts
18651
18943
  var runtimeBuilders = {
18652
- claude: (os66) => new ClaudeRuntimeStrategy(os66),
18653
- codex: (os66) => new CodexRuntimeStrategy(os66),
18654
- coderabbit: (os66) => new CoderabbitRuntimeStrategy(os66),
18655
- cursor: (os66) => new CursorRuntimeStrategy(os66),
18656
- aider: (os66) => new AiderRuntimeStrategy(os66),
18657
- gemini: (os66) => new GeminiRuntimeStrategy(os66),
18658
- kimi: (os66) => new KimiRuntimeStrategy(os66),
18659
- opencode: (os66) => new OpencodeRuntimeStrategy(os66)
18944
+ claude: (os67) => new ClaudeRuntimeStrategy(os67),
18945
+ codex: (os67) => new CodexRuntimeStrategy(os67),
18946
+ coderabbit: (os67) => new CoderabbitRuntimeStrategy(os67),
18947
+ cursor: (os67) => new CursorRuntimeStrategy(os67),
18948
+ aider: (os67) => new AiderRuntimeStrategy(os67),
18949
+ gemini: (os67) => new GeminiRuntimeStrategy(os67),
18950
+ kimi: (os67) => new KimiRuntimeStrategy(os67),
18951
+ opencode: (os67) => new OpencodeRuntimeStrategy(os67)
18660
18952
  };
18661
18953
  var deployBuilders = {
18662
18954
  claude: () => new ClaudeDeployStrategy(),
18663
18955
  codex: () => new CodexDeployStrategy()
18664
18956
  };
18665
- function createAgentStrategy(agent, os66 = createOsStrategy()) {
18957
+ function createAgentStrategy(agent, os67 = createOsStrategy()) {
18666
18958
  if (!AGENT_REGISTRY[agent]?.enabled) {
18667
18959
  throw new Error(
18668
18960
  `Agent "${agent}" is not supported in this codeam-cli version. Upgrade with 'npm i -g codeam-cli@latest'.`
@@ -18672,10 +18964,10 @@ function createAgentStrategy(agent, os66 = createOsStrategy()) {
18672
18964
  if (!build) {
18673
18965
  throw new Error(`No runtime strategy registered for agent "${agent}"`);
18674
18966
  }
18675
- return build(os66);
18967
+ return build(os67);
18676
18968
  }
18677
- function createInteractiveAgentStrategy(agent, os66 = createOsStrategy()) {
18678
- const s = createAgentStrategy(agent, os66);
18969
+ function createInteractiveAgentStrategy(agent, os67 = createOsStrategy()) {
18970
+ const s = createAgentStrategy(agent, os67);
18679
18971
  if (s.mode !== "interactive") {
18680
18972
  throw new Error(
18681
18973
  `Agent "${agent}" is a batch agent; use createAgentStrategy + .runOneShot for one-shot reviews.`
@@ -18731,7 +19023,7 @@ function parseLinkArgs(args2) {
18731
19023
  if (apiKeyFileArg) {
18732
19024
  const filePath = apiKeyFileArg.slice("--api-key-file=".length);
18733
19025
  try {
18734
- apiKey = fs32.readFileSync(path37.resolve(filePath), "utf8").trim();
19026
+ apiKey = fs33.readFileSync(path38.resolve(filePath), "utf8").trim();
18735
19027
  } catch (err) {
18736
19028
  throw new Error(`Could not read --api-key-file ${filePath}: ${err.message}`);
18737
19029
  }
@@ -18858,7 +19150,7 @@ async function link(args2 = []) {
18858
19150
  return;
18859
19151
  }
18860
19152
  if (parsed.tokenFile) {
18861
- const credential = fs32.readFileSync(path37.resolve(parsed.tokenFile), "utf8").trim();
19153
+ const credential = fs33.readFileSync(path38.resolve(parsed.tokenFile), "utf8").trim();
18862
19154
  if (!credential) {
18863
19155
  showError(`--token-file ${parsed.tokenFile} is empty.`);
18864
19156
  process.exit(1);
@@ -19077,13 +19369,13 @@ async function linkDryRunPreflight(ctx) {
19077
19369
  // src/agents/coderabbit/configure.ts
19078
19370
  var import_node_child_process17 = require("child_process");
19079
19371
  var import_node_fs6 = require("fs");
19080
- var path39 = __toESM(require("path"));
19372
+ var path40 = __toESM(require("path"));
19081
19373
 
19082
19374
  // src/agents/coderabbit/oauth.ts
19083
19375
  var import_node_child_process16 = require("child_process");
19084
- var fs33 = __toESM(require("fs"));
19085
- var os29 = __toESM(require("os"));
19086
- var path38 = __toESM(require("path"));
19376
+ var fs34 = __toESM(require("fs"));
19377
+ var os30 = __toESM(require("os"));
19378
+ var path39 = __toESM(require("path"));
19087
19379
  function parseCoderabbitAuthEvent(line) {
19088
19380
  const l = line.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "").trim();
19089
19381
  if (!l || l[0] !== "{") return null;
@@ -19132,8 +19424,8 @@ function resolvePython() {
19132
19424
  function spawnCoderabbitLoginProc(cmd, args2) {
19133
19425
  const python = resolvePython();
19134
19426
  if (python) {
19135
- const helper = path38.join(os29.tmpdir(), "codeam-cr-pty.py");
19136
- fs33.writeFileSync(helper, PYTHON_PTY_HELPER, { mode: 420 });
19427
+ const helper = path39.join(os30.tmpdir(), "codeam-cr-pty.py");
19428
+ fs34.writeFileSync(helper, PYTHON_PTY_HELPER, { mode: 420 });
19137
19429
  return (0, import_node_child_process16.spawn)(python, [helper, cmd, ...args2], {
19138
19430
  stdio: ["pipe", "pipe", "pipe"],
19139
19431
  env: { ...process.env, TERM: "xterm-256color", COLUMNS: "220", LINES: "50" },
@@ -19244,7 +19536,7 @@ function runCoderabbitOAuthLogin(deps) {
19244
19536
  });
19245
19537
  }
19246
19538
  function coderabbitDir(home) {
19247
- return path38.join(home ?? os29.homedir(), ".coderabbit");
19539
+ return path39.join(home ?? os30.homedir(), ".coderabbit");
19248
19540
  }
19249
19541
  var NON_CREDENTIAL = /* @__PURE__ */ new Set(["doctor.json", "machine-id"]);
19250
19542
  function snapshotCredentialDir(home) {
@@ -19252,14 +19544,14 @@ function snapshotCredentialDir(home) {
19252
19544
  const snap = {};
19253
19545
  let entries;
19254
19546
  try {
19255
- entries = fs33.readdirSync(dir, { withFileTypes: true });
19547
+ entries = fs34.readdirSync(dir, { withFileTypes: true });
19256
19548
  } catch {
19257
19549
  return snap;
19258
19550
  }
19259
19551
  for (const e of entries) {
19260
19552
  if (!e.isFile() || NON_CREDENTIAL.has(e.name)) continue;
19261
19553
  try {
19262
- const st3 = fs33.statSync(path38.join(dir, e.name));
19554
+ const st3 = fs34.statSync(path39.join(dir, e.name));
19263
19555
  snap[e.name] = `${st3.mtimeMs}:${st3.size}`;
19264
19556
  } catch {
19265
19557
  }
@@ -19277,7 +19569,7 @@ function diffCapturedCredential(before, home) {
19277
19569
  }
19278
19570
  if (!best) return null;
19279
19571
  try {
19280
- return { file: best.file, contents: fs33.readFileSync(path38.join(dir, best.file), "utf8") };
19572
+ return { file: best.file, contents: fs34.readFileSync(path39.join(dir, best.file), "utf8") };
19281
19573
  } catch {
19282
19574
  return null;
19283
19575
  }
@@ -19353,8 +19645,8 @@ function collectChangedFiles(cwd) {
19353
19645
  }
19354
19646
  return [...byPath.values()];
19355
19647
  }
19356
- function restoreCoderabbitOauthBlob(os66, value) {
19357
- const dir = path39.join(os66.homeDir(), ".coderabbit");
19648
+ function restoreCoderabbitOauthBlob(os67, value) {
19649
+ const dir = path40.join(os67.homeDir(), ".coderabbit");
19358
19650
  (0, import_node_fs6.mkdirSync)(dir, { recursive: true });
19359
19651
  let file = "auth.json";
19360
19652
  let contents = value.trim();
@@ -19362,38 +19654,38 @@ function restoreCoderabbitOauthBlob(os66, value) {
19362
19654
  try {
19363
19655
  const parsed = JSON.parse(contents);
19364
19656
  if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
19365
- file = path39.basename(parsed.file);
19657
+ file = path40.basename(parsed.file);
19366
19658
  contents = parsed.contents;
19367
19659
  }
19368
19660
  } catch {
19369
19661
  }
19370
19662
  }
19371
- (0, import_node_fs6.writeFileSync)(path39.join(dir, file), contents, { mode: 384 });
19663
+ (0, import_node_fs6.writeFileSync)(path40.join(dir, file), contents, { mode: 384 });
19372
19664
  }
19373
19665
  function installFailureMessage(result) {
19374
19666
  return result.error ?? "CodeRabbit CLI could not be installed";
19375
19667
  }
19376
19668
  async function configureCoderabbit(input, deps = {}) {
19377
- const os66 = deps.os ?? createOsStrategy();
19669
+ const os67 = deps.os ?? createOsStrategy();
19378
19670
  const ensureInstalled = deps.ensureInstalled ?? ensureCoderabbitInstalled;
19379
19671
  const isLoggedIn = deps.isLoggedIn ?? defaultIsLoggedIn;
19380
19672
  const runOAuth = deps.runOAuthLogin ?? runCoderabbitOAuthLogin;
19381
19673
  const snapshot = deps.snapshotDir ?? (() => snapshotCredentialDir());
19382
19674
  const capture2 = deps.captureCredential ?? ((b) => diffCapturedCredential(b));
19383
19675
  const loginWithApiKey = deps.loginWithApiKey ?? defaultLoginWithApiKey;
19384
- const home = os66.homeDir();
19385
- os66.augmentPath(
19386
- os66.id === "win32" ? [
19387
- path39.join(home, ".local", "bin"),
19388
- path39.join(process.env.APPDATA ?? path39.join(home, "AppData", "Roaming"), "npm"),
19389
- path39.join(home, "scoop", "shims")
19390
- ] : [path39.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"]
19676
+ const home = os67.homeDir();
19677
+ os67.augmentPath(
19678
+ os67.id === "win32" ? [
19679
+ path40.join(home, ".local", "bin"),
19680
+ path40.join(process.env.APPDATA ?? path40.join(home, "AppData", "Roaming"), "npm"),
19681
+ path40.join(home, "scoop", "shims")
19682
+ ] : [path40.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"]
19391
19683
  );
19392
- const installed2 = os66.findInPath("coderabbit") !== null;
19684
+ const installed2 = os67.findInPath("coderabbit") !== null;
19393
19685
  const base = () => ({
19394
19686
  action: input.action,
19395
19687
  supported: true,
19396
- installed: os66.findInPath("coderabbit") !== null,
19688
+ installed: os67.findInPath("coderabbit") !== null,
19397
19689
  loggedIn: false
19398
19690
  });
19399
19691
  if (input.action === "status") {
@@ -19407,7 +19699,7 @@ async function configureCoderabbit(input, deps = {}) {
19407
19699
  const key = (input.apiKey ?? "").trim();
19408
19700
  if (!key) return { ...res2, error: "No API key provided" };
19409
19701
  if (!res2.installed) {
19410
- const inst = await ensureInstalled(os66);
19702
+ const inst = await ensureInstalled(os67);
19411
19703
  res2.installed = inst.ok;
19412
19704
  if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
19413
19705
  }
@@ -19431,7 +19723,7 @@ async function configureCoderabbit(input, deps = {}) {
19431
19723
  }
19432
19724
  if (!res2.installed) {
19433
19725
  deps.onEvent?.({ kind: "installing" });
19434
- const inst = await ensureInstalled(os66);
19726
+ const inst = await ensureInstalled(os67);
19435
19727
  res2.installed = inst.ok;
19436
19728
  if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
19437
19729
  }
@@ -19448,7 +19740,7 @@ async function configureCoderabbit(input, deps = {}) {
19448
19740
  return { ...res2, loggedIn: true, linked: true };
19449
19741
  }
19450
19742
  try {
19451
- restoreCoderabbitOauthBlob(os66, cred.credential);
19743
+ restoreCoderabbitOauthBlob(os67, cred.credential);
19452
19744
  } catch (err) {
19453
19745
  return {
19454
19746
  ...res2,
@@ -19472,7 +19764,7 @@ async function configureCoderabbit(input, deps = {}) {
19472
19764
  const res2 = base();
19473
19765
  if (!installed2) {
19474
19766
  deps.onEvent?.({ kind: "installing" });
19475
- const inst = await ensureInstalled(os66);
19767
+ const inst = await ensureInstalled(os67);
19476
19768
  res2.installed = inst.ok;
19477
19769
  if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
19478
19770
  }
@@ -19512,7 +19804,7 @@ async function configureCoderabbit(input, deps = {}) {
19512
19804
  }
19513
19805
  const res = base();
19514
19806
  if (!res.installed) {
19515
- const inst = await ensureInstalled(os66);
19807
+ const inst = await ensureInstalled(os67);
19516
19808
  res.installed = inst.ok;
19517
19809
  if (!inst.ok) return { ...res, error: installFailureMessage(inst) };
19518
19810
  }
@@ -19696,9 +19988,9 @@ function defaultRunGh(args2) {
19696
19988
 
19697
19989
  // src/commands/host-agent.ts
19698
19990
  var import_node_child_process25 = require("child_process");
19699
- var os42 = __toESM(require("os"));
19700
- var fs46 = __toESM(require("fs"));
19701
- var path50 = __toESM(require("path"));
19991
+ var os43 = __toESM(require("os"));
19992
+ var fs47 = __toESM(require("fs"));
19993
+ var path51 = __toESM(require("path"));
19702
19994
 
19703
19995
  // src/integrations/manifest.ts
19704
19996
  var import_node_fs8 = __toESM(require("fs"));
@@ -19822,12 +20114,12 @@ function persistOrClearSkillsFromPayload(skills) {
19822
20114
 
19823
20115
  // src/commands/host/agent-install.ts
19824
20116
  var import_child_process14 = require("child_process");
19825
- var os33 = __toESM(require("os"));
20117
+ var os34 = __toESM(require("os"));
19826
20118
  function runAgentInstallScript(script, opts = {}) {
19827
20119
  const timeoutMs = opts.timeoutMs ?? 18e4;
19828
20120
  const scope = opts.logScope ?? "agent-install";
19829
20121
  return new Promise((resolve9) => {
19830
- const home = process.env.HOME || os33.homedir();
20122
+ const home = process.env.HOME || os34.homedir();
19831
20123
  const child = (0, import_child_process14.spawn)("sh", ["-c", script], {
19832
20124
  env: { ...process.env, HOME: home },
19833
20125
  stdio: ["ignore", "pipe", "pipe"]
@@ -19893,14 +20185,14 @@ function describeReason(reason) {
19893
20185
  }
19894
20186
 
19895
20187
  // src/commands/host/host-client.ts
19896
- var fs37 = __toESM(require("fs"));
19897
- var os34 = __toESM(require("os"));
19898
- var path42 = __toESM(require("path"));
20188
+ var fs38 = __toESM(require("fs"));
20189
+ var os35 = __toESM(require("os"));
20190
+ var path43 = __toESM(require("path"));
19899
20191
  var import_node_crypto9 = require("crypto");
19900
20192
  function sampleCpuTimes() {
19901
20193
  let idle = 0;
19902
20194
  let total = 0;
19903
- for (const cpu of os34.cpus()) {
20195
+ for (const cpu of os35.cpus()) {
19904
20196
  const t2 = cpu.times;
19905
20197
  idle += t2.idle;
19906
20198
  total += t2.user + t2.nice + t2.sys + t2.idle + t2.irq;
@@ -19919,8 +20211,8 @@ var MetricsCollector = class {
19919
20211
  const prev = this.prevCpu;
19920
20212
  this.prevCpu = current2;
19921
20213
  if (!prev) {
19922
- const cores = os34.cpus().length || 1;
19923
- const proxy = os34.loadavg()[0] / cores * 100;
20214
+ const cores = os35.cpus().length || 1;
20215
+ const proxy = os35.loadavg()[0] / cores * 100;
19924
20216
  return Math.min(100, Math.max(0, Math.round(proxy)));
19925
20217
  }
19926
20218
  const idleDelta = current2.idle - prev.idle;
@@ -19933,8 +20225,8 @@ var MetricsCollector = class {
19933
20225
  collect() {
19934
20226
  return {
19935
20227
  cpuPct: this.cpuPct(),
19936
- ramUsedMb: Math.round((os34.totalmem() - os34.freemem()) / 1048576),
19937
- ramTotalMb: Math.round(os34.totalmem() / 1048576),
20228
+ ramUsedMb: Math.round((os35.totalmem() - os35.freemem()) / 1048576),
20229
+ ramTotalMb: Math.round(os35.totalmem() / 1048576),
19938
20230
  latencyMs: this.lastLatencyMs
19939
20231
  };
19940
20232
  }
@@ -19943,19 +20235,19 @@ function apiBase() {
19943
20235
  return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
19944
20236
  }
19945
20237
  function hostIdentityPath() {
19946
- return path42.join(os34.homedir(), ".codeam", "host-agent.json");
20238
+ return path43.join(os35.homedir(), ".codeam", "host-agent.json");
19947
20239
  }
19948
20240
  function collectOsInfo() {
19949
20241
  return {
19950
- distro: os34.platform(),
19951
- arch: os34.arch(),
19952
- kernel: os34.release(),
20242
+ distro: os35.platform(),
20243
+ arch: os35.arch(),
20244
+ kernel: os35.release(),
19953
20245
  nodeVersion: process.versions.node
19954
20246
  };
19955
20247
  }
19956
20248
  function loadHostIdentity() {
19957
20249
  try {
19958
- const raw = fs37.readFileSync(hostIdentityPath(), "utf8");
20250
+ const raw = fs38.readFileSync(hostIdentityPath(), "utf8");
19959
20251
  const parsed = JSON.parse(raw);
19960
20252
  if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
19961
20253
  const p2 = parsed;
@@ -19974,8 +20266,8 @@ function loadHostIdentity() {
19974
20266
  }
19975
20267
  function saveHostIdentity(identity) {
19976
20268
  const file = hostIdentityPath();
19977
- fs37.mkdirSync(path42.dirname(file), { recursive: true, mode: 448 });
19978
- fs37.writeFileSync(file, JSON.stringify(identity, null, 2), {
20269
+ fs38.mkdirSync(path43.dirname(file), { recursive: true, mode: 448 });
20270
+ fs38.writeFileSync(file, JSON.stringify(identity, null, 2), {
19979
20271
  encoding: "utf8",
19980
20272
  mode: 384
19981
20273
  });
@@ -20020,7 +20312,7 @@ function isTerminalEnrollError(err) {
20020
20312
  }
20021
20313
  function deleteHostIdentity() {
20022
20314
  try {
20023
- fs37.rmSync(hostIdentityPath(), { force: true });
20315
+ fs38.rmSync(hostIdentityPath(), { force: true });
20024
20316
  } catch {
20025
20317
  }
20026
20318
  }
@@ -20044,7 +20336,7 @@ async function postJson(pathname, body) {
20044
20336
  function resolveHostLabel(label) {
20045
20337
  const explicit = label?.trim();
20046
20338
  const envLabel = process.env.CODEAM_HOST_LABEL?.trim();
20047
- const resolved = explicit || envLabel || os34.hostname();
20339
+ const resolved = explicit || envLabel || os35.hostname();
20048
20340
  return resolved.slice(0, 80);
20049
20341
  }
20050
20342
  async function redeemEnrollToken(token, label) {
@@ -20155,17 +20447,17 @@ async function reportDeployProgress(auth, deployId, step, message, sessionId) {
20155
20447
  }
20156
20448
 
20157
20449
  // src/commands/host/workspace.ts
20158
- var fs38 = __toESM(require("fs"));
20159
- var os35 = __toESM(require("os"));
20160
- var path43 = __toESM(require("path"));
20450
+ var fs39 = __toESM(require("fs"));
20451
+ var os36 = __toESM(require("os"));
20452
+ var path44 = __toESM(require("path"));
20161
20453
  var import_node_child_process20 = require("child_process");
20162
20454
  var import_node_util4 = require("util");
20163
20455
  var execFileP4 = (0, import_node_util4.promisify)(import_node_child_process20.execFile);
20164
20456
  function isAbsolutePathTarget(target) {
20165
- return path43.isAbsolute(target);
20457
+ return path44.isAbsolute(target);
20166
20458
  }
20167
20459
  function selfHostedWorkspaceRoot() {
20168
- return path43.join(os35.homedir(), ".codeam", "self-hosted");
20460
+ return path44.join(os36.homedir(), ".codeam", "self-hosted");
20169
20461
  }
20170
20462
  function nonInteractiveGitEnv() {
20171
20463
  return {
@@ -20235,15 +20527,15 @@ async function configureGitCredentials(dest, repoRef, cloneToken, provider = "gi
20235
20527
  const isGitlab = provider === "gitlab";
20236
20528
  if (isGitlab ? !gitlabProjectPath(repoRef.trim()) : !githubOwnerRepo(repoRef.trim())) return;
20237
20529
  if (!cloneToken) return;
20238
- const credFile = path43.join(dest, ".git", "codeam-credentials");
20530
+ const credFile = path44.join(dest, ".git", "codeam-credentials");
20239
20531
  const credLine = isGitlab ? `https://oauth2:${cloneToken}@gitlab.com
20240
20532
  ` : `https://x-access-token:${cloneToken}@github.com
20241
20533
  `;
20242
- fs38.writeFileSync(credFile, credLine, { mode: 384 });
20534
+ fs39.writeFileSync(credFile, credLine, { mode: 384 });
20243
20535
  restrictToOwner(credFile);
20244
20536
  const env = nonInteractiveGitEnv();
20245
20537
  const git2 = (args2) => execFileP4("git", ["-C", dest, ...args2], { timeout: 3e4, env });
20246
- const credFilePosix = credFile.split(path43.sep).join("/");
20538
+ const credFilePosix = credFile.split(path44.sep).join("/");
20247
20539
  await git2(["config", "--local", "--replace-all", "credential.helper", ""]).catch(() => {
20248
20540
  });
20249
20541
  await git2([
@@ -20276,17 +20568,17 @@ function maskToken(text, cloneToken) {
20276
20568
  }
20277
20569
  async function prepareWorkspace(repoOrPath, deployId, cloneToken, provider = "github", branch) {
20278
20570
  if (isAbsolutePathTarget(repoOrPath)) {
20279
- if (!fs38.existsSync(repoOrPath)) {
20571
+ if (!fs39.existsSync(repoOrPath)) {
20280
20572
  throw new Error(`deploy target path does not exist: ${repoOrPath}`);
20281
20573
  }
20282
20574
  return repoOrPath;
20283
20575
  }
20284
- const dest = path43.join(selfHostedWorkspaceRoot(), deployId);
20285
- if (fs38.existsSync(path43.join(dest, ".git"))) {
20576
+ const dest = path44.join(selfHostedWorkspaceRoot(), deployId);
20577
+ if (fs39.existsSync(path44.join(dest, ".git"))) {
20286
20578
  if (cloneToken) await configureGitCredentials(dest, repoOrPath, cloneToken, provider);
20287
20579
  return dest;
20288
20580
  }
20289
- fs38.mkdirSync(selfHostedWorkspaceRoot(), { recursive: true, mode: 448 });
20581
+ fs39.mkdirSync(selfHostedWorkspaceRoot(), { recursive: true, mode: 448 });
20290
20582
  const cloneUrl = repoCloneUrl(repoOrPath, cloneToken, provider);
20291
20583
  const cloneArgs = branch ? ["clone", "--depth", "1", "--branch", branch, cloneUrl, dest] : ["clone", "--depth", "1", cloneUrl, dest];
20292
20584
  try {
@@ -20304,9 +20596,9 @@ async function prepareWorkspace(repoOrPath, deployId, cloneToken, provider = "gi
20304
20596
  }
20305
20597
 
20306
20598
  // src/commands/host/agent-provisioning.ts
20307
- var fs39 = __toESM(require("fs"));
20308
- var os36 = __toESM(require("os"));
20309
- var path44 = __toESM(require("path"));
20599
+ var fs40 = __toESM(require("fs"));
20600
+ var os37 = __toESM(require("os"));
20601
+ var path45 = __toESM(require("path"));
20310
20602
  var PUBLIC_TO_INTERNAL_AGENT = {
20311
20603
  claude_code: "claude",
20312
20604
  claude: "claude",
@@ -20323,22 +20615,22 @@ function toInternalAgentId(publicAgentId) {
20323
20615
  return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
20324
20616
  }
20325
20617
  function ensureDir(dir) {
20326
- fs39.mkdirSync(dir, { recursive: true, mode: 448 });
20618
+ fs40.mkdirSync(dir, { recursive: true, mode: 448 });
20327
20619
  }
20328
20620
  function writeFile0600(filePath, contents) {
20329
- ensureDir(path44.dirname(filePath));
20330
- fs39.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
20621
+ ensureDir(path45.dirname(filePath));
20622
+ fs40.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
20331
20623
  restrictToOwner(filePath);
20332
20624
  }
20333
20625
  function rmIfExists(filePath) {
20334
20626
  try {
20335
- fs39.rmSync(filePath, { force: true });
20627
+ fs40.rmSync(filePath, { force: true });
20336
20628
  } catch {
20337
20629
  }
20338
20630
  }
20339
20631
  var claudeProvisioner = {
20340
20632
  write(auth, home) {
20341
- const credentialsJson = path44.join(home, ".claude", ".credentials.json");
20633
+ const credentialsJson = path45.join(home, ".claude", ".credentials.json");
20342
20634
  if (auth.kind === "api_key") {
20343
20635
  rmIfExists(credentialsJson);
20344
20636
  return { ANTHROPIC_API_KEY: auth.value };
@@ -20350,8 +20642,8 @@ var claudeProvisioner = {
20350
20642
  } else {
20351
20643
  rmIfExists(credentialsJson);
20352
20644
  }
20353
- const claudeJson = path44.join(home, ".claude.json");
20354
- if (!fs39.existsSync(claudeJson)) {
20645
+ const claudeJson = path45.join(home, ".claude.json");
20646
+ if (!fs40.existsSync(claudeJson)) {
20355
20647
  writeFile0600(
20356
20648
  claudeJson,
20357
20649
  JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
@@ -20362,7 +20654,7 @@ var claudeProvisioner = {
20362
20654
  };
20363
20655
  var codexProvisioner = {
20364
20656
  write(auth, home) {
20365
- const authJson = path44.join(home, ".codex", "auth.json");
20657
+ const authJson = path45.join(home, ".codex", "auth.json");
20366
20658
  if (auth.kind === "api_key") {
20367
20659
  rmIfExists(authJson);
20368
20660
  return { OPENAI_API_KEY: auth.value };
@@ -20373,8 +20665,8 @@ var codexProvisioner = {
20373
20665
  };
20374
20666
  var geminiProvisioner = {
20375
20667
  write(auth, home) {
20376
- const settingsJson = path44.join(home, ".gemini", "settings.json");
20377
- const oauthCreds = path44.join(home, ".gemini", "oauth_creds.json");
20668
+ const settingsJson = path45.join(home, ".gemini", "settings.json");
20669
+ const oauthCreds = path45.join(home, ".gemini", "oauth_creds.json");
20378
20670
  if (auth.kind === "api_key") {
20379
20671
  rmIfExists(oauthCreds);
20380
20672
  writeFile0600(settingsJson, '{"security":{"auth":{"selectedType":"gemini-api-key"}}}');
@@ -20387,7 +20679,7 @@ var geminiProvisioner = {
20387
20679
  };
20388
20680
  var cursorProvisioner = {
20389
20681
  write(auth, home) {
20390
- const authJson = path44.join(home, ".config", "cursor", "auth.json");
20682
+ const authJson = path45.join(home, ".config", "cursor", "auth.json");
20391
20683
  if (auth.kind === "api_key") {
20392
20684
  rmIfExists(authJson);
20393
20685
  return { CURSOR_API_KEY: auth.value };
@@ -20429,22 +20721,22 @@ max_context_size = 262144
20429
20721
  var kimiProvisioner = {
20430
20722
  write(auth, home) {
20431
20723
  const credentialsFiles = [
20432
- path44.join(home, ".kimi", "credentials", "kimi-code.json"),
20433
- path44.join(home, ".kimi-code", "credentials", "kimi-code.json")
20724
+ path45.join(home, ".kimi", "credentials", "kimi-code.json"),
20725
+ path45.join(home, ".kimi-code", "credentials", "kimi-code.json")
20434
20726
  ];
20435
20727
  if (auth.kind === "api_key") {
20436
20728
  credentialsFiles.forEach(rmIfExists);
20437
20729
  return { KIMI_API_KEY: auth.value };
20438
20730
  }
20439
20731
  credentialsFiles.forEach((f) => writeFile0600(f, auth.value));
20440
- writeFile0600(path44.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
20732
+ writeFile0600(path45.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
20441
20733
  return {};
20442
20734
  }
20443
20735
  };
20444
20736
  var coderabbitProvisioner = {
20445
20737
  write(auth, home) {
20446
- const dir = path44.join(home, ".coderabbit");
20447
- const authJson = path44.join(dir, "auth.json");
20738
+ const dir = path45.join(home, ".coderabbit");
20739
+ const authJson = path45.join(dir, "auth.json");
20448
20740
  if (auth.kind === "api_key") {
20449
20741
  rmIfExists(authJson);
20450
20742
  return { CODERABBIT_API_KEY: auth.value };
@@ -20456,13 +20748,13 @@ var coderabbitProvisioner = {
20456
20748
  try {
20457
20749
  const parsed = JSON.parse(value);
20458
20750
  if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
20459
- file = path44.basename(parsed.file);
20751
+ file = path45.basename(parsed.file);
20460
20752
  contents = parsed.contents;
20461
20753
  }
20462
20754
  } catch {
20463
20755
  }
20464
20756
  }
20465
- writeFile0600(path44.join(dir, file), contents);
20757
+ writeFile0600(path45.join(dir, file), contents);
20466
20758
  return {};
20467
20759
  }
20468
20760
  };
@@ -20490,7 +20782,7 @@ var UnsupportedAgentError = class extends Error {
20490
20782
  this.agentId = agentId;
20491
20783
  }
20492
20784
  };
20493
- function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os36.homedir()) {
20785
+ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os37.homedir()) {
20494
20786
  const internal = toInternalAgentId(publicAgentId);
20495
20787
  if (!internal) throw new UnsupportedAgentError(publicAgentId);
20496
20788
  const provisioner = PROVISIONERS[internal];
@@ -20500,11 +20792,11 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os36.homedir(
20500
20792
 
20501
20793
  // src/commands/host/git-tooling.ts
20502
20794
  var import_node_child_process21 = require("child_process");
20503
- var fs40 = __toESM(require("fs"));
20504
- var os37 = __toESM(require("os"));
20505
- var path45 = __toESM(require("path"));
20795
+ var fs41 = __toESM(require("fs"));
20796
+ var os38 = __toESM(require("os"));
20797
+ var path46 = __toESM(require("path"));
20506
20798
  function codeamBinDir() {
20507
- return process.env.CODEAM_BIN_DIR ?? path45.join(os37.homedir(), ".codeam", "bin");
20799
+ return process.env.CODEAM_BIN_DIR ?? path46.join(os38.homedir(), ".codeam", "bin");
20508
20800
  }
20509
20801
  var FALLBACK_GH_VERSION = "2.62.0";
20510
20802
  var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
@@ -20536,7 +20828,7 @@ async function download(url2, dest) {
20536
20828
  const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
20537
20829
  if (!res.ok || !res.body) return false;
20538
20830
  const buf = Buffer.from(await res.arrayBuffer());
20539
- fs40.writeFileSync(dest, buf);
20831
+ fs41.writeFileSync(dest, buf);
20540
20832
  return true;
20541
20833
  } catch {
20542
20834
  return false;
@@ -20559,8 +20851,8 @@ async function ensureGhCli(runner, token, deps = {}) {
20559
20851
  const version3 = await resolveVersionFn(token);
20560
20852
  const asset = `gh_${version3}_${osToken}_${arch2}`;
20561
20853
  const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
20562
- const tmpRoot = fs40.mkdtempSync(path45.join(os37.tmpdir(), "codeam-gh-"));
20563
- const archive = path45.join(tmpRoot, `${asset}.${ext}`);
20854
+ const tmpRoot = fs41.mkdtempSync(path46.join(os38.tmpdir(), "codeam-gh-"));
20855
+ const archive = path46.join(tmpRoot, `${asset}.${ext}`);
20564
20856
  if (!await downloadFn(url2, archive)) {
20565
20857
  log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
20566
20858
  return null;
@@ -20570,16 +20862,16 @@ async function ensureGhCli(runner, token, deps = {}) {
20570
20862
  log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
20571
20863
  return null;
20572
20864
  }
20573
- const extractedBin = path45.join(tmpRoot, asset, "bin", binaryName);
20574
- if (!fs40.existsSync(extractedBin)) {
20865
+ const extractedBin = path46.join(tmpRoot, asset, "bin", binaryName);
20866
+ if (!fs41.existsSync(extractedBin)) {
20575
20867
  log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
20576
20868
  return null;
20577
20869
  }
20578
20870
  const binDir = codeamBinDir();
20579
- fs40.mkdirSync(binDir, { recursive: true });
20580
- const target = path45.join(binDir, binaryName);
20581
- fs40.copyFileSync(extractedBin, target);
20582
- fs40.chmodSync(target, 493);
20871
+ fs41.mkdirSync(binDir, { recursive: true });
20872
+ const target = path46.join(binDir, binaryName);
20873
+ fs41.copyFileSync(extractedBin, target);
20874
+ fs41.chmodSync(target, 493);
20583
20875
  log.info("host-agent", `gh installed to ${target} (v${version3})`);
20584
20876
  return target;
20585
20877
  } catch (e) {
@@ -20639,8 +20931,8 @@ async function ensureGlabCli(runner, deps = {}) {
20639
20931
  const version3 = await resolveLatestGlabVersion();
20640
20932
  const asset = `glab_${version3}_${osToken}_${arch2}`;
20641
20933
  const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
20642
- const tmpRoot = fs40.mkdtempSync(path45.join(os37.tmpdir(), "codeam-glab-"));
20643
- const archive = path45.join(tmpRoot, `${asset}.${ext}`);
20934
+ const tmpRoot = fs41.mkdtempSync(path46.join(os38.tmpdir(), "codeam-glab-"));
20935
+ const archive = path46.join(tmpRoot, `${asset}.${ext}`);
20644
20936
  if (!await downloadFn(url2, archive)) {
20645
20937
  log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
20646
20938
  return null;
@@ -20651,20 +20943,20 @@ async function ensureGlabCli(runner, deps = {}) {
20651
20943
  return null;
20652
20944
  }
20653
20945
  const candidates = [
20654
- path45.join(tmpRoot, "bin", binaryName),
20655
- path45.join(tmpRoot, asset, "bin", binaryName),
20656
- path45.join(tmpRoot, binaryName)
20946
+ path46.join(tmpRoot, "bin", binaryName),
20947
+ path46.join(tmpRoot, asset, "bin", binaryName),
20948
+ path46.join(tmpRoot, binaryName)
20657
20949
  ];
20658
- const extractedBin = candidates.find((c2) => fs40.existsSync(c2));
20950
+ const extractedBin = candidates.find((c2) => fs41.existsSync(c2));
20659
20951
  if (!extractedBin) {
20660
20952
  log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
20661
20953
  return null;
20662
20954
  }
20663
20955
  const binDir = codeamBinDir();
20664
- fs40.mkdirSync(binDir, { recursive: true });
20665
- const target = path45.join(binDir, binaryName);
20666
- fs40.copyFileSync(extractedBin, target);
20667
- fs40.chmodSync(target, 493);
20956
+ fs41.mkdirSync(binDir, { recursive: true });
20957
+ const target = path46.join(binDir, binaryName);
20958
+ fs41.copyFileSync(extractedBin, target);
20959
+ fs41.chmodSync(target, 493);
20668
20960
  log.info("host-agent", `glab installed to ${target} (v${version3})`);
20669
20961
  return target;
20670
20962
  } catch (e) {
@@ -20861,24 +21153,24 @@ var HeadroomStatsReporter = class {
20861
21153
  };
20862
21154
 
20863
21155
  // src/commands/host/headroom-bootstrap.ts
20864
- var fs42 = __toESM(require("fs"));
20865
- var path47 = __toESM(require("path"));
20866
- var os39 = __toESM(require("os"));
21156
+ var fs43 = __toESM(require("fs"));
21157
+ var path48 = __toESM(require("path"));
21158
+ var os40 = __toESM(require("os"));
20867
21159
 
20868
21160
  // src/commands/host/headroom-config.ts
20869
- var fs41 = __toESM(require("fs"));
20870
- var os38 = __toESM(require("os"));
20871
- var path46 = __toESM(require("path"));
21161
+ var fs42 = __toESM(require("fs"));
21162
+ var os39 = __toESM(require("os"));
21163
+ var path47 = __toESM(require("path"));
20872
21164
  function headroomConfigPath() {
20873
- return path46.join(os38.homedir(), ".codeam", "headroom-config.json");
21165
+ return path47.join(os39.homedir(), ".codeam", "headroom-config.json");
20874
21166
  }
20875
21167
  function persistHeadroomConfig(config) {
20876
21168
  try {
20877
21169
  const file = headroomConfigPath();
20878
- fs41.mkdirSync(path46.dirname(file), { recursive: true, mode: 448 });
21170
+ fs42.mkdirSync(path47.dirname(file), { recursive: true, mode: 448 });
20879
21171
  const tmp = `${file}.tmp-${process.pid}`;
20880
- fs41.writeFileSync(tmp, JSON.stringify(config, null, 2), { encoding: "utf8", mode: 384 });
20881
- fs41.renameSync(tmp, file);
21172
+ fs42.writeFileSync(tmp, JSON.stringify(config, null, 2), { encoding: "utf8", mode: 384 });
21173
+ fs42.renameSync(tmp, file);
20882
21174
  restrictToOwner(file);
20883
21175
  } catch (err) {
20884
21176
  log.warn(
@@ -20888,21 +21180,21 @@ function persistHeadroomConfig(config) {
20888
21180
  }
20889
21181
  }
20890
21182
  function agentSettingsPath(kind) {
20891
- const home = os38.homedir();
20892
- if (kind === "claude") return path46.join(home, ".claude", "settings.json");
20893
- if (kind === "codex") return path46.join(home, ".codex", "auth.json");
20894
- if (kind === "copilot") return path46.join(home, ".config", "github-copilot", "hosts.json");
21183
+ const home = os39.homedir();
21184
+ if (kind === "claude") return path47.join(home, ".claude", "settings.json");
21185
+ if (kind === "codex") return path47.join(home, ".codex", "auth.json");
21186
+ if (kind === "copilot") return path47.join(home, ".config", "github-copilot", "hosts.json");
20895
21187
  return null;
20896
21188
  }
20897
21189
  function backupAgentHeadroomConfig(kind) {
20898
21190
  const src = agentSettingsPath(kind);
20899
21191
  if (!src) return;
20900
21192
  try {
20901
- if (!fs41.existsSync(src)) return;
20902
- const dest = path46.join(os38.homedir(), ".codeam", `headroom-backup-${kind}.json`);
20903
- fs41.mkdirSync(path46.dirname(dest), { recursive: true, mode: 448 });
20904
- fs41.copyFileSync(src, dest);
20905
- fs41.chmodSync(dest, 384);
21193
+ if (!fs42.existsSync(src)) return;
21194
+ const dest = path47.join(os39.homedir(), ".codeam", `headroom-backup-${kind}.json`);
21195
+ fs42.mkdirSync(path47.dirname(dest), { recursive: true, mode: 448 });
21196
+ fs42.copyFileSync(src, dest);
21197
+ fs42.chmodSync(dest, 384);
20906
21198
  log.info("host-agent", `headroom config backup: ${src} \u2192 ${dest}`);
20907
21199
  } catch (err) {
20908
21200
  log.warn(
@@ -20914,12 +21206,12 @@ function backupAgentHeadroomConfig(kind) {
20914
21206
  function restoreAgentHeadroomConfig(kind) {
20915
21207
  const dest = agentSettingsPath(kind);
20916
21208
  if (!dest) return false;
20917
- const src = path46.join(os38.homedir(), ".codeam", `headroom-backup-${kind}.json`);
20918
- if (!fs41.existsSync(src)) return false;
21209
+ const src = path47.join(os39.homedir(), ".codeam", `headroom-backup-${kind}.json`);
21210
+ if (!fs42.existsSync(src)) return false;
20919
21211
  try {
20920
- fs41.mkdirSync(path46.dirname(dest), { recursive: true, mode: 448 });
20921
- fs41.copyFileSync(src, dest);
20922
- fs41.chmodSync(dest, 384);
21212
+ fs42.mkdirSync(path47.dirname(dest), { recursive: true, mode: 448 });
21213
+ fs42.copyFileSync(src, dest);
21214
+ fs42.chmodSync(dest, 384);
20923
21215
  log.info("host-agent", `headroom config restored: ${src} \u2192 ${dest}`);
20924
21216
  return true;
20925
21217
  } catch (err) {
@@ -20932,7 +21224,7 @@ function restoreAgentHeadroomConfig(kind) {
20932
21224
  }
20933
21225
  function readHeadroomChildEnv() {
20934
21226
  try {
20935
- const raw = fs41.readFileSync(headroomConfigPath(), "utf8");
21227
+ const raw = fs42.readFileSync(headroomConfigPath(), "utf8");
20936
21228
  const parsed = JSON.parse(raw);
20937
21229
  if (typeof parsed !== "object" || parsed === null) return {};
20938
21230
  const o = parsed;
@@ -20968,49 +21260,49 @@ function bundledClaudeBinDir() {
20968
21260
  const roots = /* @__PURE__ */ new Set();
20969
21261
  let dir = __dirname;
20970
21262
  for (let i = 0; i < 6; i++) {
20971
- roots.add(path47.join(dir, "node_modules"));
20972
- const parent = path47.dirname(dir);
21263
+ roots.add(path48.join(dir, "node_modules"));
21264
+ const parent = path48.dirname(dir);
20973
21265
  if (parent === dir) break;
20974
21266
  dir = parent;
20975
21267
  }
20976
21268
  try {
20977
21269
  const main2 = require.resolve("@anthropic-ai/claude-agent-sdk");
20978
- const marker = `${path47.sep}@anthropic-ai${path47.sep}`;
21270
+ const marker = `${path48.sep}@anthropic-ai${path48.sep}`;
20979
21271
  const idx = main2.lastIndexOf(marker);
20980
21272
  if (idx !== -1) roots.add(main2.slice(0, idx));
20981
21273
  } catch {
20982
21274
  }
20983
21275
  for (const nm of roots) {
20984
- const atAnthropic = path47.join(nm, "@anthropic-ai");
21276
+ const atAnthropic = path48.join(nm, "@anthropic-ai");
20985
21277
  let entries;
20986
21278
  try {
20987
- entries = fs42.readdirSync(atAnthropic);
21279
+ entries = fs43.readdirSync(atAnthropic);
20988
21280
  } catch {
20989
21281
  continue;
20990
21282
  }
20991
21283
  for (const entry of entries) {
20992
21284
  if (!entry.startsWith("claude-agent-sdk-")) continue;
20993
- const bin = path47.join(atAnthropic, entry, "claude");
20994
- if (fs42.existsSync(bin)) return path47.dirname(bin);
21285
+ const bin = path48.join(atAnthropic, entry, "claude");
21286
+ if (fs43.existsSync(bin)) return path48.dirname(bin);
20995
21287
  }
20996
21288
  }
20997
21289
  return null;
20998
21290
  }
20999
21291
  async function getFreeDiskBytes(dir) {
21000
21292
  try {
21001
- const s = await fs42.promises.statfs(dir);
21293
+ const s = await fs43.promises.statfs(dir);
21002
21294
  return s.bsize * s.bavail;
21003
21295
  } catch {
21004
21296
  return null;
21005
21297
  }
21006
21298
  }
21007
21299
  function headroomModelsCached() {
21008
- const hubDir = process.env.HUGGINGFACE_HUB_CACHE || path47.join(
21009
- process.env.HF_HOME || path47.join(os39.homedir(), ".cache", "huggingface"),
21300
+ const hubDir = process.env.HUGGINGFACE_HUB_CACHE || path48.join(
21301
+ process.env.HF_HOME || path48.join(os40.homedir(), ".cache", "huggingface"),
21010
21302
  "hub"
21011
21303
  );
21012
21304
  return HEADROOM_MODELS.every(
21013
- (m) => fs42.existsSync(path47.join(hubDir, `models--${m.repo.replace("/", "--")}`))
21305
+ (m) => fs43.existsSync(path48.join(hubDir, `models--${m.repo.replace("/", "--")}`))
21014
21306
  );
21015
21307
  }
21016
21308
  async function setupHeadroomForSelfHosted(agent, runner = defaultHeadroomRunner, opts = {}) {
@@ -21079,7 +21371,7 @@ async function setupHeadroomForSelfHosted(agent, runner = defaultHeadroomRunner,
21079
21371
  if (initKind === "claude") {
21080
21372
  const claudeDir = bundledClaudeBinDir();
21081
21373
  if (claudeDir) {
21082
- initEnv.PATH = `${claudeDir}${path47.delimiter}${process.env["PATH"] ?? ""}`;
21374
+ initEnv.PATH = `${claudeDir}${path48.delimiter}${process.env["PATH"] ?? ""}`;
21083
21375
  log.info("host-agent", `headroom init: bundled claude on PATH (${claudeDir})`);
21084
21376
  } else {
21085
21377
  log.warn("host-agent", "headroom init: bundled claude binary not found \u2014 init may fail");
@@ -21116,19 +21408,19 @@ async function setupHeadroomForSelfHosted(agent, runner = defaultHeadroomRunner,
21116
21408
  }
21117
21409
 
21118
21410
  // src/commands/host/house-proxy-config.ts
21119
- var fs43 = __toESM(require("fs"));
21120
- var os40 = __toESM(require("os"));
21121
- var path48 = __toESM(require("path"));
21411
+ var fs44 = __toESM(require("fs"));
21412
+ var os41 = __toESM(require("os"));
21413
+ var path49 = __toESM(require("path"));
21122
21414
  function houseProxyConfigPath() {
21123
- return path48.join(os40.homedir(), ".codeam", "house-proxy.json");
21415
+ return path49.join(os41.homedir(), ".codeam", "house-proxy.json");
21124
21416
  }
21125
21417
  function persistHouseProxyConfig(config) {
21126
21418
  try {
21127
21419
  const file = houseProxyConfigPath();
21128
- fs43.mkdirSync(path48.dirname(file), { recursive: true, mode: 448 });
21420
+ fs44.mkdirSync(path49.dirname(file), { recursive: true, mode: 448 });
21129
21421
  const tmp = `${file}.tmp-${process.pid}`;
21130
- fs43.writeFileSync(tmp, JSON.stringify(config, null, 2), { encoding: "utf8", mode: 384 });
21131
- fs43.renameSync(tmp, file);
21422
+ fs44.writeFileSync(tmp, JSON.stringify(config, null, 2), { encoding: "utf8", mode: 384 });
21423
+ fs44.renameSync(tmp, file);
21132
21424
  restrictToOwner(file);
21133
21425
  } catch (err) {
21134
21426
  log.warn(
@@ -21139,13 +21431,13 @@ function persistHouseProxyConfig(config) {
21139
21431
  }
21140
21432
  function clearHouseProxyConfig() {
21141
21433
  try {
21142
- fs43.rmSync(houseProxyConfigPath(), { force: true });
21434
+ fs44.rmSync(houseProxyConfigPath(), { force: true });
21143
21435
  } catch {
21144
21436
  }
21145
21437
  }
21146
21438
  function readHouseProxyChildEnv() {
21147
21439
  try {
21148
- const raw = fs43.readFileSync(houseProxyConfigPath(), "utf8");
21440
+ const raw = fs44.readFileSync(houseProxyConfigPath(), "utf8");
21149
21441
  const parsed = JSON.parse(raw);
21150
21442
  if (typeof parsed !== "object" || parsed === null) return {};
21151
21443
  const o = parsed;
@@ -21178,9 +21470,9 @@ function readHouseProxyChildEnv() {
21178
21470
  var import_node_child_process23 = require("child_process");
21179
21471
 
21180
21472
  // src/lib/updateNotifier.ts
21181
- var fs44 = __toESM(require("fs"));
21182
- var os41 = __toESM(require("os"));
21183
- var path49 = __toESM(require("path"));
21473
+ var fs45 = __toESM(require("fs"));
21474
+ var os42 = __toESM(require("os"));
21475
+ var path50 = __toESM(require("path"));
21184
21476
  var https6 = __toESM(require("https"));
21185
21477
  var import_node_child_process22 = require("child_process");
21186
21478
  var import_picocolors3 = __toESM(require("picocolors"));
@@ -21189,12 +21481,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
21189
21481
  var TTL_MS = 24 * 60 * 60 * 1e3;
21190
21482
  var REQUEST_TIMEOUT_MS = 1500;
21191
21483
  function cachePath() {
21192
- const dir = path49.join(os41.homedir(), ".codeam");
21193
- return path49.join(dir, "update-check.json");
21484
+ const dir = path50.join(os42.homedir(), ".codeam");
21485
+ return path50.join(dir, "update-check.json");
21194
21486
  }
21195
21487
  function readCache() {
21196
21488
  try {
21197
- const raw = fs44.readFileSync(cachePath(), "utf8");
21489
+ const raw = fs45.readFileSync(cachePath(), "utf8");
21198
21490
  const parsed = JSON.parse(raw);
21199
21491
  if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
21200
21492
  return parsed;
@@ -21205,10 +21497,10 @@ function readCache() {
21205
21497
  function writeCache(cache) {
21206
21498
  try {
21207
21499
  const file = cachePath();
21208
- fs44.mkdirSync(path49.dirname(file), { recursive: true });
21500
+ fs45.mkdirSync(path50.dirname(file), { recursive: true });
21209
21501
  const tmp = `${file}.${process.pid}.tmp`;
21210
- fs44.writeFileSync(tmp, JSON.stringify(cache));
21211
- fs44.renameSync(tmp, file);
21502
+ fs45.writeFileSync(tmp, JSON.stringify(cache));
21503
+ fs45.renameSync(tmp, file);
21212
21504
  } catch {
21213
21505
  }
21214
21506
  }
@@ -21282,8 +21574,8 @@ function isLinkedInstall() {
21282
21574
  timeout: 2e3
21283
21575
  }).trim();
21284
21576
  if (!root) return false;
21285
- const pkgPath = path49.join(root, PKG_NAME);
21286
- return fs44.lstatSync(pkgPath).isSymbolicLink();
21577
+ const pkgPath = path50.join(root, PKG_NAME);
21578
+ return fs45.lstatSync(pkgPath).isSymbolicLink();
21287
21579
  } catch {
21288
21580
  return false;
21289
21581
  }
@@ -21319,7 +21611,7 @@ function maybeAutoUpdate(currentVersion, latest) {
21319
21611
  return;
21320
21612
  }
21321
21613
  try {
21322
- fs44.unlinkSync(cachePath());
21614
+ fs45.unlinkSync(cachePath());
21323
21615
  } catch {
21324
21616
  }
21325
21617
  process.stderr.write(` ${import_picocolors3.default.green("\u2713")} Updated. Resuming session...
@@ -21335,7 +21627,7 @@ async function autoUpgradeBeforeCriticalCommand() {
21335
21627
  if (process.env.NODE_ENV === "test") return;
21336
21628
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
21337
21629
  if (process.env.CI) return;
21338
- const current2 = true ? "2.65.1" : null;
21630
+ const current2 = true ? "2.65.3" : null;
21339
21631
  if (!current2) return;
21340
21632
  const cache = readCache();
21341
21633
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -21352,7 +21644,7 @@ function checkForUpdates() {
21352
21644
  if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
21353
21645
  if (process.env.CI) return;
21354
21646
  if (!process.stdout.isTTY) return;
21355
- const current2 = true ? "2.65.1" : null;
21647
+ const current2 = true ? "2.65.3" : null;
21356
21648
  if (!current2) return;
21357
21649
  const cache = readCache();
21358
21650
  const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
@@ -21372,7 +21664,7 @@ var SELF_UPDATE_INTERVAL_MS = 60 * 60 * 1e3;
21372
21664
  var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
21373
21665
  var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
21374
21666
  function currentCliVersion() {
21375
- return true ? "2.65.1" : null;
21667
+ return true ? "2.65.3" : null;
21376
21668
  }
21377
21669
  function runCmd(cmd, args2, timeoutMs) {
21378
21670
  return new Promise((resolve9) => {
@@ -21439,7 +21731,7 @@ async function runSelfUpdate() {
21439
21731
 
21440
21732
  // src/commands/host/teardown.ts
21441
21733
  var import_node_child_process24 = require("child_process");
21442
- var fs45 = __toESM(require("fs"));
21734
+ var fs46 = __toESM(require("fs"));
21443
21735
  var defaultDisableService = () => {
21444
21736
  try {
21445
21737
  (0, import_node_child_process24.execFileSync)("systemctl", ["disable", "--now", "codeam-host-agent"], { stdio: "ignore" });
@@ -21448,7 +21740,7 @@ var defaultDisableService = () => {
21448
21740
  };
21449
21741
  var defaultTeardownHeadroom = () => {
21450
21742
  try {
21451
- const kind = JSON.parse(fs45.readFileSync(headroomConfigPath(), "utf8")).agent;
21743
+ const kind = JSON.parse(fs46.readFileSync(headroomConfigPath(), "utf8")).agent;
21452
21744
  if (kind) {
21453
21745
  (0, import_node_child_process24.execFileSync)("headroom", ["unwrap", kind], { stdio: "ignore", timeout: 15e3 });
21454
21746
  }
@@ -21516,8 +21808,8 @@ function maybeResumeLocalHeadroomReporter(ctx) {
21516
21808
  if (process.env["HEADROOM_ENABLED"] === "1") return null;
21517
21809
  try {
21518
21810
  const file = headroomConfigPath();
21519
- if (!fs46.existsSync(file)) return null;
21520
- const cfg = JSON.parse(fs46.readFileSync(file, "utf8"));
21811
+ if (!fs47.existsSync(file)) return null;
21812
+ const cfg = JSON.parse(fs47.readFileSync(file, "utf8"));
21521
21813
  if (!cfg?.enabled) return null;
21522
21814
  const agent = cfg.agent ?? "claude";
21523
21815
  const ingestUrl = `${resolveApiBaseUrl()}/api/sessions/${ctx.sessionId}/headroom-savings`;
@@ -22104,13 +22396,13 @@ var HostAgentSupervisor = class {
22104
22396
  const relay = this.relay;
22105
22397
  if (!relay) return;
22106
22398
  const raw = cmd.payload?.path;
22107
- const target = typeof raw === "string" && raw.trim() ? path50.resolve(raw.trim()) : os42.homedir();
22399
+ const target = typeof raw === "string" && raw.trim() ? path51.resolve(raw.trim()) : os43.homedir();
22108
22400
  try {
22109
- const dirents = await fs46.promises.readdir(target, { withFileTypes: true });
22401
+ const dirents = await fs47.promises.readdir(target, { withFileTypes: true });
22110
22402
  const entries = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
22111
22403
  (a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
22112
22404
  );
22113
- const parent = path50.dirname(target);
22405
+ const parent = path51.dirname(target);
22114
22406
  await relay.sendResult(cmd.id, "completed", {
22115
22407
  path: target,
22116
22408
  // null at the filesystem root so the UI can hide the ".." affordance.
@@ -22343,14 +22635,14 @@ var HostAgentSupervisor = class {
22343
22635
  API_TIMEOUT_MS: "3000000",
22344
22636
  CODEAM_AUTO_TOKEN: payload.autoPairToken
22345
22637
  };
22346
- const houseConfigDir = path50.join(
22347
- os42.homedir(),
22638
+ const houseConfigDir = path51.join(
22639
+ os43.homedir(),
22348
22640
  ".codeam",
22349
22641
  "house-claude",
22350
22642
  payload.deployId
22351
22643
  );
22352
22644
  try {
22353
- fs46.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
22645
+ fs47.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
22354
22646
  } catch {
22355
22647
  }
22356
22648
  childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
@@ -22376,7 +22668,7 @@ var HostAgentSupervisor = class {
22376
22668
  report("installing", "installing agent CLI");
22377
22669
  await this.runAgentInstall(payload.agentInstallScript);
22378
22670
  }
22379
- const home = process.env.HOME || os42.homedir();
22671
+ const home = process.env.HOME || os43.homedir();
22380
22672
  childEnv.PATH = `${home}/.local/bin:${process.env.PATH ?? ""}`;
22381
22673
  if (payload.cloneToken) {
22382
22674
  try {
@@ -22384,13 +22676,13 @@ var HostAgentSupervisor = class {
22384
22676
  if ((payload.repoProvider ?? "github") === "gitlab") {
22385
22677
  const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
22386
22678
  if (glabCmd) {
22387
- childEnv.PATH = `${codeamBinDir()}${path50.delimiter}${childEnv.PATH}`;
22679
+ childEnv.PATH = `${codeamBinDir()}${path51.delimiter}${childEnv.PATH}`;
22388
22680
  await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
22389
22681
  }
22390
22682
  } else {
22391
22683
  const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
22392
22684
  if (ghCmd) {
22393
- childEnv.PATH = `${codeamBinDir()}${path50.delimiter}${childEnv.PATH}`;
22685
+ childEnv.PATH = `${codeamBinDir()}${path51.delimiter}${childEnv.PATH}`;
22394
22686
  await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
22395
22687
  }
22396
22688
  }
@@ -22410,7 +22702,7 @@ var HostAgentSupervisor = class {
22410
22702
  }
22411
22703
  if (payload.headroomEnabled && payload.headroomAgent && payload.headroomSavingsIngestUrl && isHeadroomSupportedAgent(payload.headroomAgent)) {
22412
22704
  report("headroom", "setting up Headroom proxy");
22413
- const freeBytes = await this.getFreeDisk(os42.homedir());
22705
+ const freeBytes = await this.getFreeDisk(os43.homedir());
22414
22706
  const alreadyInstalled = this.isHeadroomInstalled();
22415
22707
  if (!alreadyInstalled && freeBytes !== null && freeBytes < HEADROOM_MIN_FREE_DISK_BYTES) {
22416
22708
  const freeGb = (freeBytes / 1e9).toFixed(1);
@@ -22469,9 +22761,9 @@ var HostAgentSupervisor = class {
22469
22761
  );
22470
22762
  if (!payload.suppressOnboardingWelcome) {
22471
22763
  try {
22472
- const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path50.join(os42.homedir(), ".claude");
22473
- const projectDir = path50.join(cfgDir, "projects", encodeCwd(cwd));
22474
- const hasPriorConversation = fs46.existsSync(projectDir) && fs46.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
22764
+ const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path51.join(os43.homedir(), ".claude");
22765
+ const projectDir = path51.join(cfgDir, "projects", encodeCwd(cwd));
22766
+ const hasPriorConversation = fs47.existsSync(projectDir) && fs47.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
22475
22767
  if (hasPriorConversation) {
22476
22768
  childEnv.CODEAM_RESUME_LATEST = "1";
22477
22769
  log.info(
@@ -22570,7 +22862,7 @@ var HostAgentSupervisor = class {
22570
22862
  if (this.children.size > 0) return;
22571
22863
  const session = getActiveSession();
22572
22864
  if (!session || !session.pluginId || !session.pollSecret || !session.agent) return;
22573
- const cwd = session.cwd && fs46.existsSync(session.cwd) ? session.cwd : process.cwd();
22865
+ const cwd = session.cwd && fs47.existsSync(session.cwd) ? session.cwd : process.cwd();
22574
22866
  const proc = this.resumeSpawner(
22575
22867
  { ...readHeadroomChildEnv(), ...readHouseProxyChildEnv() },
22576
22868
  cwd
@@ -22667,12 +22959,12 @@ var HostAgentSupervisor = class {
22667
22959
  this.children.delete(deployId);
22668
22960
  }
22669
22961
  const dirs = [
22670
- path50.join(selfHostedWorkspaceRoot(), deployId),
22671
- path50.join(os42.homedir(), ".codeam", "house-claude", deployId)
22962
+ path51.join(selfHostedWorkspaceRoot(), deployId),
22963
+ path51.join(os43.homedir(), ".codeam", "house-claude", deployId)
22672
22964
  ];
22673
22965
  for (const dir of dirs) {
22674
22966
  try {
22675
- fs46.rmSync(dir, { recursive: true, force: true });
22967
+ fs47.rmSync(dir, { recursive: true, force: true });
22676
22968
  } catch (err) {
22677
22969
  log.warn(
22678
22970
  "host-agent",
@@ -22809,9 +23101,9 @@ async function configureHeadroom(action, ctx, deps) {
22809
23101
  }
22810
23102
 
22811
23103
  // src/services/headroom/budget-relaunch.ts
22812
- var fs47 = __toESM(require("fs"));
22813
- var os43 = __toESM(require("os"));
22814
- var path51 = __toESM(require("path"));
23104
+ var fs48 = __toESM(require("fs"));
23105
+ var os44 = __toESM(require("os"));
23106
+ var path52 = __toESM(require("path"));
22815
23107
  var import_child_process15 = require("child_process");
22816
23108
  function amendDeploymentManifestBudget(manifest, budget) {
22817
23109
  const rawArgs = manifest.proxy_args ?? [];
@@ -22845,7 +23137,7 @@ function amendDeploymentManifestBudget(manifest, budget) {
22845
23137
  return { ...manifest, proxy_args: newArgs, base_env: newEnv };
22846
23138
  }
22847
23139
  function findHeadroomDeployments(homeDir2, deps) {
22848
- const deployDir = path51.join(homeDir2, ".headroom", "deploy");
23140
+ const deployDir = path52.join(homeDir2, ".headroom", "deploy");
22849
23141
  let profiles;
22850
23142
  try {
22851
23143
  profiles = deps.readDir(deployDir);
@@ -22854,7 +23146,7 @@ function findHeadroomDeployments(homeDir2, deps) {
22854
23146
  }
22855
23147
  const results = [];
22856
23148
  for (const profile of profiles) {
22857
- const manifestPath = path51.join(deployDir, profile, "manifest.json");
23149
+ const manifestPath = path52.join(deployDir, profile, "manifest.json");
22858
23150
  let raw;
22859
23151
  try {
22860
23152
  raw = deps.readJson(manifestPath);
@@ -22886,8 +23178,8 @@ async function applyBudgetToHeadroom(budget, deps) {
22886
23178
  }
22887
23179
  function writeManifestReal(manifestPath, manifest) {
22888
23180
  const tmp = manifestPath + ".codeam.tmp";
22889
- fs47.writeFileSync(tmp, JSON.stringify(manifest, null, 2) + "\n", { mode: 384 });
22890
- fs47.renameSync(tmp, manifestPath);
23181
+ fs48.writeFileSync(tmp, JSON.stringify(manifest, null, 2) + "\n", { mode: 384 });
23182
+ fs48.renameSync(tmp, manifestPath);
22891
23183
  }
22892
23184
  function restartDeploymentReal(profile) {
22893
23185
  try {
@@ -22922,11 +23214,11 @@ function spawnProxyReal2(_budget) {
22922
23214
  );
22923
23215
  }
22924
23216
  function makeRealApplyBudgetDeps() {
22925
- const homeDir2 = os43.homedir();
23217
+ const homeDir2 = os44.homedir();
22926
23218
  return {
22927
23219
  findDeployments: () => findHeadroomDeployments(homeDir2, {
22928
- readDir: (dir) => fs47.readdirSync(dir),
22929
- readJson: (filePath) => JSON.parse(fs47.readFileSync(filePath, "utf8"))
23220
+ readDir: (dir) => fs48.readdirSync(dir),
23221
+ readJson: (filePath) => JSON.parse(fs48.readFileSync(filePath, "utf8"))
22930
23222
  }),
22931
23223
  writeManifest: writeManifestReal,
22932
23224
  restartDeployment: restartDeploymentReal,
@@ -23041,7 +23333,7 @@ async function defaultFetchJson(url2) {
23041
23333
  async function readUsageReport(deps = {}) {
23042
23334
  const port = deps.port ?? HEADROOM_PROXY_PORT;
23043
23335
  const base = `http://127.0.0.1:${port}`;
23044
- const get2 = deps.fetchJson ?? ((path91) => defaultFetchJson(`${base}${path91}`));
23336
+ const get2 = deps.fetchJson ?? ((path92) => defaultFetchJson(`${base}${path92}`));
23045
23337
  let history;
23046
23338
  try {
23047
23339
  history = await get2("/stats-history");
@@ -23059,47 +23351,47 @@ async function readUsageReport(deps = {}) {
23059
23351
  }
23060
23352
 
23061
23353
  // src/agents/acp/guardrail-config.ts
23062
- var fs48 = __toESM(require("fs"));
23063
- var path52 = __toESM(require("path"));
23064
- var os44 = __toESM(require("os"));
23354
+ var fs49 = __toESM(require("fs"));
23355
+ var path53 = __toESM(require("path"));
23356
+ var os45 = __toESM(require("os"));
23065
23357
  var current = null;
23066
- function guardrailConfigPath(homeDir2 = os44.homedir()) {
23067
- return path52.join(homeDir2, ".codeam", "guardrails.json");
23358
+ function guardrailConfigPath(homeDir2 = os45.homedir()) {
23359
+ return path53.join(homeDir2, ".codeam", "guardrails.json");
23068
23360
  }
23069
- function loadGuardrailPolicy(homeDir2 = os44.homedir()) {
23361
+ function loadGuardrailPolicy(homeDir2 = os45.homedir()) {
23070
23362
  try {
23071
- current = normalizeGuardrailPolicy(JSON.parse(fs48.readFileSync(guardrailConfigPath(homeDir2), "utf8")));
23363
+ current = normalizeGuardrailPolicy(JSON.parse(fs49.readFileSync(guardrailConfigPath(homeDir2), "utf8")));
23072
23364
  } catch {
23073
23365
  current = { ...DEFAULT_GUARDRAIL_POLICY };
23074
23366
  }
23075
23367
  return current;
23076
23368
  }
23077
- function getGuardrailPolicy(homeDir2 = os44.homedir()) {
23369
+ function getGuardrailPolicy(homeDir2 = os45.homedir()) {
23078
23370
  return current ?? loadGuardrailPolicy(homeDir2);
23079
23371
  }
23080
- function setGuardrailPolicy(raw, homeDir2 = os44.homedir()) {
23372
+ function setGuardrailPolicy(raw, homeDir2 = os45.homedir()) {
23081
23373
  const next = normalizeGuardrailPolicy(raw);
23082
23374
  current = next;
23083
23375
  try {
23084
23376
  const p2 = guardrailConfigPath(homeDir2);
23085
- fs48.mkdirSync(path52.dirname(p2), { recursive: true });
23086
- fs48.writeFileSync(p2, JSON.stringify(next, null, 2));
23377
+ fs49.mkdirSync(path53.dirname(p2), { recursive: true });
23378
+ fs49.writeFileSync(p2, JSON.stringify(next, null, 2));
23087
23379
  } catch {
23088
23380
  }
23089
23381
  return next;
23090
23382
  }
23091
23383
 
23092
23384
  // src/services/preview/port-registry.ts
23093
- var fs49 = __toESM(require("fs"));
23094
- var os45 = __toESM(require("os"));
23095
- var path53 = __toESM(require("path"));
23385
+ var fs50 = __toESM(require("fs"));
23386
+ var os46 = __toESM(require("os"));
23387
+ var path54 = __toESM(require("path"));
23096
23388
  var import_child_process16 = require("child_process");
23097
23389
  function registryPath() {
23098
- return path53.join(os45.homedir(), ".codeam", "preview-ports.json");
23390
+ return path54.join(os46.homedir(), ".codeam", "preview-ports.json");
23099
23391
  }
23100
23392
  function readRegistry() {
23101
23393
  try {
23102
- const raw = fs49.readFileSync(registryPath(), "utf8");
23394
+ const raw = fs50.readFileSync(registryPath(), "utf8");
23103
23395
  const parsed = JSON.parse(raw);
23104
23396
  if (parsed && typeof parsed === "object") return parsed;
23105
23397
  } catch {
@@ -23109,10 +23401,10 @@ function readRegistry() {
23109
23401
  function writeRegistry(reg) {
23110
23402
  try {
23111
23403
  const file = registryPath();
23112
- fs49.mkdirSync(path53.dirname(file), { recursive: true });
23404
+ fs50.mkdirSync(path54.dirname(file), { recursive: true });
23113
23405
  const tmp = `${file}.tmp`;
23114
- fs49.writeFileSync(tmp, JSON.stringify(reg), "utf8");
23115
- fs49.renameSync(tmp, file);
23406
+ fs50.writeFileSync(tmp, JSON.stringify(reg), "utf8");
23407
+ fs50.renameSync(tmp, file);
23116
23408
  } catch (err) {
23117
23409
  log.warn("preview", `port-registry write failed: ${err instanceof Error ? err.message : String(err)}`);
23118
23410
  }
@@ -23178,7 +23470,7 @@ function reclaimOwnOrphanPort(port) {
23178
23470
 
23179
23471
  // src/services/preview/host-allow.ts
23180
23472
  var import_fs2 = require("fs");
23181
- var path54 = __toESM(require("path"));
23473
+ var path55 = __toESM(require("path"));
23182
23474
  var NEXT_ALLOWED_ORIGINS = [
23183
23475
  "*.trycloudflare.com",
23184
23476
  "*.preview.codeagent-mobile.com",
@@ -23198,7 +23490,7 @@ var MARKER_DIR = ".codeam";
23198
23490
  var MARKER_FILE = "preview-host-allow.json";
23199
23491
  var ORIG_INFIX = ".codeam-orig";
23200
23492
  function markerPath(cwd) {
23201
- return path54.join(cwd, MARKER_DIR, MARKER_FILE);
23493
+ return path55.join(cwd, MARKER_DIR, MARKER_FILE);
23202
23494
  }
23203
23495
  async function fileExists(p2) {
23204
23496
  try {
@@ -23211,13 +23503,13 @@ async function fileExists(p2) {
23211
23503
  async function findConfigFile(cwd, framework) {
23212
23504
  const base = CONFIG_BASENAMES[framework];
23213
23505
  for (const ext of CONFIG_EXTS) {
23214
- if (await fileExists(path54.join(cwd, `${base}${ext}`))) return `${base}${ext}`;
23506
+ if (await fileExists(path55.join(cwd, `${base}${ext}`))) return `${base}${ext}`;
23215
23507
  }
23216
23508
  return null;
23217
23509
  }
23218
23510
  async function dependsOn(cwd, pkgName) {
23219
23511
  try {
23220
- const raw = await import_fs2.promises.readFile(path54.join(cwd, "package.json"), "utf8");
23512
+ const raw = await import_fs2.promises.readFile(path55.join(cwd, "package.json"), "utf8");
23221
23513
  const pkg = JSON.parse(raw);
23222
23514
  return !!(pkg.dependencies?.[pkgName] ?? pkg.devDependencies?.[pkgName]);
23223
23515
  } catch {
@@ -23225,11 +23517,11 @@ async function dependsOn(cwd, pkgName) {
23225
23517
  }
23226
23518
  }
23227
23519
  async function isEsmConfig(cwd, configFile) {
23228
- const ext = path54.extname(configFile);
23520
+ const ext = path55.extname(configFile);
23229
23521
  if (ext === ".mjs" || ext === ".mts" || ext === ".ts") return true;
23230
23522
  if (ext === ".cjs") return false;
23231
23523
  try {
23232
- const raw = await import_fs2.promises.readFile(path54.join(cwd, "package.json"), "utf8");
23524
+ const raw = await import_fs2.promises.readFile(path55.join(cwd, "package.json"), "utf8");
23233
23525
  return JSON.parse(raw).type === "module";
23234
23526
  } catch {
23235
23527
  return false;
@@ -23312,7 +23604,7 @@ function shimFor(framework, origBasename, esm) {
23312
23604
  return framework === "next" ? nextShim(origBasename, esm) : viteShim(origBasename, esm);
23313
23605
  }
23314
23606
  async function writeMarker(cwd, marker) {
23315
- await import_fs2.promises.mkdir(path54.join(cwd, MARKER_DIR), { recursive: true });
23607
+ await import_fs2.promises.mkdir(path55.join(cwd, MARKER_DIR), { recursive: true });
23316
23608
  await import_fs2.promises.writeFile(markerPath(cwd), JSON.stringify(marker, null, 2), "utf8");
23317
23609
  }
23318
23610
  async function readMarker(cwd) {
@@ -23327,9 +23619,9 @@ async function restorePreviewHostAllow(cwd) {
23327
23619
  const marker = await readMarker(cwd);
23328
23620
  if (!marker) return;
23329
23621
  try {
23330
- const configAbs = path54.join(cwd, marker.configFile);
23622
+ const configAbs = path55.join(cwd, marker.configFile);
23331
23623
  if (marker.backupFile) {
23332
- const backupAbs = path54.join(cwd, marker.backupFile);
23624
+ const backupAbs = path55.join(cwd, marker.backupFile);
23333
23625
  if (await fileExists(backupAbs)) {
23334
23626
  await import_fs2.promises.rm(configAbs, { force: true });
23335
23627
  await import_fs2.promises.rename(backupAbs, configAbs);
@@ -23362,16 +23654,16 @@ async function applyPreviewHostAllow(cwd) {
23362
23654
  }
23363
23655
  if (!framework) return;
23364
23656
  if (existing) {
23365
- const ext = path54.extname(existing);
23657
+ const ext = path55.extname(existing);
23366
23658
  const origBasename = `${CONFIG_BASENAMES[framework]}${ORIG_INFIX}${ext}`;
23367
23659
  const esm = await isEsmConfig(cwd, existing);
23368
- await import_fs2.promises.rename(path54.join(cwd, existing), path54.join(cwd, origBasename));
23369
- await import_fs2.promises.writeFile(path54.join(cwd, existing), shimFor(framework, origBasename, esm), "utf8");
23660
+ await import_fs2.promises.rename(path55.join(cwd, existing), path55.join(cwd, origBasename));
23661
+ await import_fs2.promises.writeFile(path55.join(cwd, existing), shimFor(framework, origBasename, esm), "utf8");
23370
23662
  await writeMarker(cwd, { framework, configFile: existing, backupFile: origBasename });
23371
23663
  log.info("preview", `host-allow: wrapped ${existing} (${framework}) for tunnel access`);
23372
23664
  } else {
23373
23665
  const configFile = `${CONFIG_BASENAMES[framework]}.mjs`;
23374
- await import_fs2.promises.writeFile(path54.join(cwd, configFile), shimFor(framework, null, true), "utf8");
23666
+ await import_fs2.promises.writeFile(path55.join(cwd, configFile), shimFor(framework, null, true), "utf8");
23375
23667
  await writeMarker(cwd, { framework, configFile, backupFile: null });
23376
23668
  log.info("preview", `host-allow: created ${configFile} (${framework}) for tunnel access`);
23377
23669
  }
@@ -24053,19 +24345,19 @@ function activePreviewSessionIds() {
24053
24345
 
24054
24346
  // src/services/preview/start-orchestrator.ts
24055
24347
  var import_child_process21 = require("child_process");
24056
- var fs57 = __toESM(require("fs"));
24057
- var path61 = __toESM(require("path"));
24348
+ var fs58 = __toESM(require("fs"));
24349
+ var path62 = __toESM(require("path"));
24058
24350
  var import_which2 = __toESM(require("which"));
24059
24351
 
24060
24352
  // src/services/project-env/index.ts
24061
24353
  var import_fs6 = require("fs");
24062
- var path60 = __toESM(require("path"));
24354
+ var path61 = __toESM(require("path"));
24063
24355
 
24064
24356
  // src/beads/project-key.ts
24065
24357
  var import_child_process20 = require("child_process");
24066
24358
  var crypto2 = __toESM(require("crypto"));
24067
- var fs55 = __toESM(require("fs"));
24068
- var path59 = __toESM(require("path"));
24359
+ var fs56 = __toESM(require("fs"));
24360
+ var path60 = __toESM(require("path"));
24069
24361
  function normalizeOrigin(raw) {
24070
24362
  const trimmed = raw.trim();
24071
24363
  if (!trimmed) return null;
@@ -24091,17 +24383,17 @@ function normalizeOrigin(raw) {
24091
24383
  return `${host2}/${pathPart}`;
24092
24384
  }
24093
24385
  function findRepoRoot(cwd) {
24094
- let dir = path59.resolve(cwd);
24386
+ let dir = path60.resolve(cwd);
24095
24387
  const seen = /* @__PURE__ */ new Set();
24096
24388
  for (let i = 0; i < 256; i++) {
24097
24389
  if (seen.has(dir)) return null;
24098
24390
  seen.add(dir);
24099
24391
  try {
24100
- const stat3 = fs55.statSync(path59.join(dir, ".git"), { throwIfNoEntry: false });
24392
+ const stat3 = fs56.statSync(path60.join(dir, ".git"), { throwIfNoEntry: false });
24101
24393
  if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
24102
24394
  } catch {
24103
24395
  }
24104
- const parent = path59.dirname(dir);
24396
+ const parent = path60.dirname(dir);
24105
24397
  if (parent === dir) return null;
24106
24398
  dir = parent;
24107
24399
  }
@@ -24112,7 +24404,7 @@ var _execSeam2 = {
24112
24404
  const out2 = (0, import_child_process20.execFileSync)(file, args2, opts);
24113
24405
  return typeof out2 === "string" ? out2 : out2.toString("utf8");
24114
24406
  },
24115
- realpath: (p2) => fs55.realpathSync(p2)
24407
+ realpath: (p2) => fs56.realpathSync(p2)
24116
24408
  };
24117
24409
  function readOrigin(cwd) {
24118
24410
  try {
@@ -24141,7 +24433,7 @@ function deriveProjectIdentity(cwd = process.cwd()) {
24141
24433
  } catch {
24142
24434
  }
24143
24435
  const hash = crypto2.createHash("sha256").update(real).digest("hex");
24144
- return { projectKey: `path:${hash}`, projectLabel: path59.basename(real) || "project" };
24436
+ return { projectKey: `path:${hash}`, projectLabel: path60.basename(real) || "project" };
24145
24437
  }
24146
24438
 
24147
24439
  // src/services/project-env/index.ts
@@ -24154,7 +24446,7 @@ async function readIfExists(p2) {
24154
24446
  }
24155
24447
  async function syncProjectEnvUp(cwd, ctx) {
24156
24448
  if (!ctx.pluginAuthToken) return;
24157
- const content = await readIfExists(path60.join(cwd, ".env"));
24449
+ const content = await readIfExists(path61.join(cwd, ".env"));
24158
24450
  if (content == null) return;
24159
24451
  try {
24160
24452
  const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
@@ -24176,7 +24468,7 @@ async function syncProjectEnvUp(cwd, ctx) {
24176
24468
  }
24177
24469
  async function restoreProjectEnvIfMissing(cwd, ctx) {
24178
24470
  if (!ctx.pluginAuthToken) return false;
24179
- const envPath = path60.join(cwd, ".env");
24471
+ const envPath = path61.join(cwd, ".env");
24180
24472
  if (await readIfExists(envPath) != null) return false;
24181
24473
  try {
24182
24474
  const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
@@ -24187,7 +24479,7 @@ async function restoreProjectEnvIfMissing(cwd, ctx) {
24187
24479
  projectKey
24188
24480
  });
24189
24481
  if (!stored) return false;
24190
- const tmp = path60.join(cwd, ".env.codeam-restore.tmp");
24482
+ const tmp = path61.join(cwd, ".env.codeam-restore.tmp");
24191
24483
  await import_fs6.promises.writeFile(tmp, stored.content, { encoding: "utf8", mode: 384 });
24192
24484
  await import_fs6.promises.rename(tmp, envPath);
24193
24485
  log.info("project-env", `restored .env (${stored.keyCount} vars) for ${projectLabel}`);
@@ -24264,8 +24556,8 @@ function normalizeDetectionForSpawn(detection, cwd) {
24264
24556
  if (args2.length === 0) return detection;
24265
24557
  const binName = args2[0];
24266
24558
  if (binName.startsWith("-")) return detection;
24267
- const binPath = path61.join(cwd, "node_modules", ".bin", binName);
24268
- if (!fs57.existsSync(binPath)) return detection;
24559
+ const binPath = path62.join(cwd, "node_modules", ".bin", binName);
24560
+ if (!fs58.existsSync(binPath)) return detection;
24269
24561
  return {
24270
24562
  ...detection,
24271
24563
  command: binPath,
@@ -24638,9 +24930,9 @@ async function establishTunnel(ctx, dev) {
24638
24930
 
24639
24931
  // src/beads/bd-adapter.ts
24640
24932
  var import_child_process22 = require("child_process");
24641
- var fs58 = __toESM(require("fs"));
24642
- var os47 = __toESM(require("os"));
24643
- var path62 = __toESM(require("path"));
24933
+ var fs59 = __toESM(require("fs"));
24934
+ var os48 = __toESM(require("os"));
24935
+ var path63 = __toESM(require("path"));
24644
24936
  var BD_PACKAGE = "@beads/bd";
24645
24937
  function resolveBundledBdBinary() {
24646
24938
  return _resolveSeam.resolveBundled();
@@ -24652,11 +24944,11 @@ function _defaultResolveBundled() {
24652
24944
  } catch {
24653
24945
  return null;
24654
24946
  }
24655
- const binDir = path62.join(path62.dirname(pkgJsonPath), "bin");
24947
+ const binDir = path63.join(path63.dirname(pkgJsonPath), "bin");
24656
24948
  const binaryName = process.platform === "win32" ? "bd.exe" : "bd";
24657
- const binaryPath = path62.join(binDir, binaryName);
24949
+ const binaryPath = path63.join(binDir, binaryName);
24658
24950
  try {
24659
- fs58.accessSync(binaryPath, fs58.constants.F_OK);
24951
+ fs59.accessSync(binaryPath, fs59.constants.F_OK);
24660
24952
  return binaryPath;
24661
24953
  } catch {
24662
24954
  return null;
@@ -24666,13 +24958,13 @@ function resolveBdOnPath() {
24666
24958
  return _resolveSeam.resolveOnPath();
24667
24959
  }
24668
24960
  function _defaultResolveOnPath() {
24669
- const dirs = (process.env.PATH ?? "").split(path62.delimiter).filter(Boolean);
24961
+ const dirs = (process.env.PATH ?? "").split(path63.delimiter).filter(Boolean);
24670
24962
  const candidates = process.platform === "win32" ? ["bd.exe", "bd.cmd", "bd"] : ["bd"];
24671
24963
  for (const dir of dirs) {
24672
24964
  for (const candidate of candidates) {
24673
- const full = path62.join(dir, candidate);
24965
+ const full = path63.join(dir, candidate);
24674
24966
  try {
24675
- fs58.accessSync(full, fs58.constants.F_OK);
24967
+ fs59.accessSync(full, fs59.constants.F_OK);
24676
24968
  return full;
24677
24969
  } catch {
24678
24970
  }
@@ -24757,7 +25049,7 @@ var BdAdapter = class {
24757
25049
  const env = { ...process.env };
24758
25050
  if (!env.HOME) {
24759
25051
  try {
24760
- const home = os47.homedir();
25052
+ const home = os48.homedir();
24761
25053
  if (home) env.HOME = home;
24762
25054
  } catch {
24763
25055
  }
@@ -24849,9 +25141,9 @@ function coerceIssue(row, projectKey) {
24849
25141
 
24850
25142
  // src/beads/provisioner.ts
24851
25143
  var import_child_process25 = require("child_process");
24852
- var fs60 = __toESM(require("fs"));
24853
- var os49 = __toESM(require("os"));
24854
- var path64 = __toESM(require("path"));
25144
+ var fs61 = __toESM(require("fs"));
25145
+ var os50 = __toESM(require("os"));
25146
+ var path65 = __toESM(require("path"));
24855
25147
 
24856
25148
  // src/beads/install-bd.ts
24857
25149
  var import_child_process23 = require("child_process");
@@ -24916,9 +25208,9 @@ async function installBd(platform3 = process.platform) {
24916
25208
 
24917
25209
  // src/beads/install-dolt.ts
24918
25210
  var import_child_process24 = require("child_process");
24919
- var fs59 = __toESM(require("fs"));
24920
- var os48 = __toESM(require("os"));
24921
- var path63 = __toESM(require("path"));
25211
+ var fs60 = __toESM(require("fs"));
25212
+ var os49 = __toESM(require("os"));
25213
+ var path64 = __toESM(require("path"));
24922
25214
  var DOLT_INSTALL_SH_URL = "https://github.com/dolthub/dolt/releases/latest/download/install.sh";
24923
25215
  var DOLT_MSI_URL = "https://github.com/dolthub/dolt/releases/latest/download/dolt-windows-amd64.msi";
24924
25216
  function resolveDoltInstallStrategy(platform3) {
@@ -24958,11 +25250,11 @@ function resolveDoltInstallStrategy(platform3) {
24958
25250
  }
24959
25251
  var DOLT_RELEASE_BASE = "https://github.com/dolthub/dolt/releases/latest/download";
24960
25252
  function doltPlatformTuple(platform3, arch2) {
24961
- const os66 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
25253
+ const os67 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
24962
25254
  const a = arch2 === "x64" ? "amd64" : arch2 === "arm64" ? "arm64" : null;
24963
25255
  if (!a) return null;
24964
- if (os66 === "windows" && a !== "amd64") return null;
24965
- return `${os66}-${a}`;
25256
+ if (os67 === "windows" && a !== "amd64") return null;
25257
+ return `${os67}-${a}`;
24966
25258
  }
24967
25259
  function resolveDoltTarballStrategy(targetDir, platform3, arch2) {
24968
25260
  const tuple = doltPlatformTuple(platform3, arch2);
@@ -25007,14 +25299,14 @@ async function installDoltToDir(targetDir, platform3 = process.platform, arch2 =
25007
25299
  return result;
25008
25300
  }
25009
25301
  var _doltPathSeam = {
25010
- homedir: () => os48.homedir(),
25302
+ homedir: () => os49.homedir(),
25011
25303
  getPath: () => process.env.PATH ?? "",
25012
25304
  setPath: (p2) => {
25013
25305
  process.env.PATH = p2;
25014
25306
  },
25015
25307
  exists: (p2) => {
25016
25308
  try {
25017
- fs59.accessSync(p2, fs59.constants.F_OK);
25309
+ fs60.accessSync(p2, fs60.constants.F_OK);
25018
25310
  return true;
25019
25311
  } catch {
25020
25312
  return false;
@@ -25025,7 +25317,7 @@ function doltBinaryNames(platform3) {
25025
25317
  return platform3 === "win32" ? ["dolt.exe", "dolt.cmd", "dolt"] : ["dolt"];
25026
25318
  }
25027
25319
  function knownDoltDirs(platform3) {
25028
- const P3 = platform3 === "win32" ? path63.win32 : path63.posix;
25320
+ const P3 = platform3 === "win32" ? path64.win32 : path64.posix;
25029
25321
  const home = _doltPathSeam.homedir();
25030
25322
  if (platform3 === "win32") {
25031
25323
  return [
@@ -25041,7 +25333,7 @@ function knownDoltDirs(platform3) {
25041
25333
  ].filter(Boolean);
25042
25334
  }
25043
25335
  function ensureDoltResolvable(platform3 = process.platform) {
25044
- const P3 = platform3 === "win32" ? path63.win32 : path63.posix;
25336
+ const P3 = platform3 === "win32" ? path64.win32 : path64.posix;
25045
25337
  const delim = platform3 === "win32" ? ";" : ":";
25046
25338
  const names = doltBinaryNames(platform3);
25047
25339
  const pathDirs = _doltPathSeam.getPath().split(delim).filter(Boolean);
@@ -25218,17 +25510,17 @@ var _provisionSeam = {
25218
25510
  };
25219
25511
  var _linkSeam = {
25220
25512
  platform: () => process.platform,
25221
- homedir: () => os49.homedir(),
25513
+ homedir: () => os50.homedir(),
25222
25514
  isWritableDir: (dir) => {
25223
25515
  try {
25224
- fs60.accessSync(dir, fs60.constants.W_OK);
25516
+ fs61.accessSync(dir, fs61.constants.W_OK);
25225
25517
  return true;
25226
25518
  } catch {
25227
25519
  return false;
25228
25520
  }
25229
25521
  },
25230
25522
  ensureDir: (dir) => {
25231
- fs60.mkdirSync(dir, { recursive: true });
25523
+ fs61.mkdirSync(dir, { recursive: true });
25232
25524
  },
25233
25525
  /**
25234
25526
  * A directory to symlink `bd` into so the AGENT's shell + Claude Code's
@@ -25249,9 +25541,9 @@ var _linkSeam = {
25249
25541
  * which `linkBdOntoPath` creates if missing.
25250
25542
  */
25251
25543
  cliBinDir: () => {
25252
- const pathDirs = (process.env.PATH ?? "").split(path64.delimiter).filter(Boolean);
25544
+ const pathDirs = (process.env.PATH ?? "").split(path65.delimiter).filter(Boolean);
25253
25545
  const home = _linkSeam.homedir();
25254
- const localBin = home ? path64.join(home, ".local", "bin") : null;
25546
+ const localBin = home ? path65.join(home, ".local", "bin") : null;
25255
25547
  if (localBin) {
25256
25548
  try {
25257
25549
  _linkSeam.ensureDir(localBin);
@@ -25261,16 +25553,16 @@ var _linkSeam = {
25261
25553
  const candidates = [];
25262
25554
  if (localBin) candidates.push(localBin);
25263
25555
  try {
25264
- candidates.push(path64.dirname(process.execPath));
25556
+ candidates.push(path65.dirname(process.execPath));
25265
25557
  } catch {
25266
25558
  }
25267
25559
  candidates.push("/usr/local/bin");
25268
25560
  const entry = process.argv[1];
25269
25561
  if (entry) {
25270
25562
  try {
25271
- candidates.push(path64.dirname(fs60.realpathSync(entry)));
25563
+ candidates.push(path65.dirname(fs61.realpathSync(entry)));
25272
25564
  } catch {
25273
- candidates.push(path64.dirname(entry));
25565
+ candidates.push(path65.dirname(entry));
25274
25566
  }
25275
25567
  }
25276
25568
  const onPathWritable = candidates.find(
@@ -25282,20 +25574,20 @@ var _linkSeam = {
25282
25574
  /** Current symlink target at `linkPath`, or null when absent / not a link. */
25283
25575
  readlink: (linkPath) => {
25284
25576
  try {
25285
- return fs60.readlinkSync(linkPath);
25577
+ return fs61.readlinkSync(linkPath);
25286
25578
  } catch {
25287
25579
  return null;
25288
25580
  }
25289
25581
  },
25290
- unlink: (linkPath) => fs60.unlinkSync(linkPath),
25291
- symlink: (target, linkPath) => fs60.symlinkSync(target, linkPath)
25582
+ unlink: (linkPath) => fs61.unlinkSync(linkPath),
25583
+ symlink: (target, linkPath) => fs61.symlinkSync(target, linkPath)
25292
25584
  };
25293
25585
  function linkBdOntoPath(binaryPath) {
25294
25586
  if (_linkSeam.platform() === "win32") return;
25295
25587
  const binDir = _linkSeam.cliBinDir();
25296
25588
  if (!binDir) return;
25297
25589
  _linkSeam.ensureDir(binDir);
25298
- const linkPath = path64.join(binDir, "bd");
25590
+ const linkPath = path65.join(binDir, "bd");
25299
25591
  if (linkPath === binaryPath) return;
25300
25592
  const current2 = _linkSeam.readlink(linkPath);
25301
25593
  if (current2 === binaryPath) return;
@@ -25490,7 +25782,7 @@ function dedupeRecipes(agents) {
25490
25782
 
25491
25783
  // src/beads/watcher.ts
25492
25784
  var crypto4 = __toESM(require("crypto"));
25493
- var path65 = __toESM(require("path"));
25785
+ var path66 = __toESM(require("path"));
25494
25786
  var API_BASE6 = resolveApiBaseUrl();
25495
25787
  var DEBOUNCE_MS2 = 400;
25496
25788
  var ZERO_SUMMARY = {
@@ -25514,7 +25806,7 @@ var BeadsWatcher = class {
25514
25806
  constructor(opts) {
25515
25807
  this.opts = opts;
25516
25808
  this.bd = opts.adapter ?? new BdAdapter({ cwd: opts.cwd, beadsDir: opts.beadsDir });
25517
- this.feedPath = opts.feedPath ?? path65.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
25809
+ this.feedPath = opts.feedPath ?? path66.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
25518
25810
  this.apiBase = opts.apiBaseUrl ?? API_BASE6;
25519
25811
  }
25520
25812
  opts;
@@ -26013,8 +26305,8 @@ function cleanupAttachmentTempFiles() {
26013
26305
  function saveFilesTemp(files) {
26014
26306
  return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
26015
26307
  const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
26016
- const tmpPath = path68.join(os53.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
26017
- fs63.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
26308
+ const tmpPath = path69.join(os54.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
26309
+ fs64.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
26018
26310
  pendingAttachmentFiles.add(tmpPath);
26019
26311
  return tmpPath;
26020
26312
  });
@@ -26232,10 +26524,10 @@ var listFiles = async (ctx, cmd, parsed) => {
26232
26524
  await ctx.relay.sendResult(cmd.id, "completed", result);
26233
26525
  };
26234
26526
  var envReadH = async (ctx, cmd) => {
26235
- const envPath = path68.join(process.cwd(), ".env");
26527
+ const envPath = path69.join(process.cwd(), ".env");
26236
26528
  await restoreProjectEnvIfMissing(process.cwd(), ctx);
26237
26529
  try {
26238
- const raw = await fs63.promises.readFile(envPath, "utf8");
26530
+ const raw = await fs64.promises.readFile(envPath, "utf8");
26239
26531
  await ctx.relay.sendResult(cmd.id, "completed", {
26240
26532
  exists: true,
26241
26533
  vars: parseDotenv(raw)
@@ -26266,15 +26558,15 @@ var envWriteH = async (ctx, cmd, parsed) => {
26266
26558
  }
26267
26559
  seen.add(v.key);
26268
26560
  }
26269
- const envPath = path68.join(process.cwd(), ".env");
26270
- const tmpPath = path68.join(process.cwd(), ".env.codeam.tmp");
26561
+ const envPath = path69.join(process.cwd(), ".env");
26562
+ const tmpPath = path69.join(process.cwd(), ".env.codeam.tmp");
26271
26563
  try {
26272
- await fs63.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
26273
- await fs63.promises.rename(tmpPath, envPath);
26564
+ await fs64.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
26565
+ await fs64.promises.rename(tmpPath, envPath);
26274
26566
  await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
26275
26567
  void syncProjectEnvUp(process.cwd(), ctx);
26276
26568
  } catch (err) {
26277
- await fs63.promises.rm(tmpPath, { force: true }).catch(() => void 0);
26569
+ await fs64.promises.rm(tmpPath, { force: true }).catch(() => void 0);
26278
26570
  await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
26279
26571
  }
26280
26572
  };
@@ -26323,7 +26615,7 @@ var headroomConfigureH = async (ctx, cmd, parsed) => {
26323
26615
  let configuredAgent = rawAgentId;
26324
26616
  if (!configuredAgent) {
26325
26617
  try {
26326
- const raw = JSON.parse(fs63.readFileSync(headroomConfigPath(), "utf8"));
26618
+ const raw = JSON.parse(fs64.readFileSync(headroomConfigPath(), "utf8"));
26327
26619
  configuredAgent = raw.agent ?? "";
26328
26620
  } catch {
26329
26621
  }
@@ -26357,7 +26649,7 @@ var headroomConfigureH = async (ctx, cmd, parsed) => {
26357
26649
  persist: persistHeadroomConfig,
26358
26650
  readEnabled: () => {
26359
26651
  try {
26360
- const raw = JSON.parse(fs63.readFileSync(headroomConfigPath(), "utf8"));
26652
+ const raw = JSON.parse(fs64.readFileSync(headroomConfigPath(), "utf8"));
26361
26653
  return raw.enabled === true;
26362
26654
  } catch {
26363
26655
  return false;
@@ -26614,7 +26906,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
26614
26906
  });
26615
26907
  const token = ctx.pluginAuthToken;
26616
26908
  void (async () => {
26617
- const os66 = createOsStrategy();
26909
+ const os67 = createOsStrategy();
26618
26910
  try {
26619
26911
  const report = await reviewPullRequest(
26620
26912
  {
@@ -26623,7 +26915,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
26623
26915
  baseBranch: parsed.baseBranch
26624
26916
  },
26625
26917
  {
26626
- runReview: (input) => new CoderabbitRuntimeStrategy(os66).runOneShot(input),
26918
+ runReview: (input) => new CoderabbitRuntimeStrategy(os67).runOneShot(input),
26627
26919
  runGh: (args2) => defaultRunGh(args2),
26628
26920
  postReport: async (r) => {
26629
26921
  if (!token) return;
@@ -26679,7 +26971,7 @@ var headroomBudgetH = async (ctx, cmd) => {
26679
26971
  }
26680
26972
  let headroomActive = false;
26681
26973
  try {
26682
- const raw = JSON.parse(fs63.readFileSync(headroomConfigPath(), "utf8"));
26974
+ const raw = JSON.parse(fs64.readFileSync(headroomConfigPath(), "utf8"));
26683
26975
  headroomActive = raw.enabled === true;
26684
26976
  } catch {
26685
26977
  }
@@ -26689,7 +26981,7 @@ var headroomBudgetH = async (ctx, cmd) => {
26689
26981
  }
26690
26982
  let existingConfig = { enabled: true };
26691
26983
  try {
26692
- existingConfig = JSON.parse(fs63.readFileSync(headroomConfigPath(), "utf8"));
26984
+ existingConfig = JSON.parse(fs64.readFileSync(headroomConfigPath(), "utf8"));
26693
26985
  } catch {
26694
26986
  }
26695
26987
  if (payload.budgetEnabled && payload.budgetUsd != null) {
@@ -26802,9 +27094,9 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
26802
27094
  function buildNpmInstallInvocation(opts) {
26803
27095
  const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
26804
27096
  const execPath = opts?.execPath ?? process.execPath;
26805
- const exists2 = opts?.existsSync ?? fs63.existsSync;
27097
+ const exists2 = opts?.existsSync ?? fs64.existsSync;
26806
27098
  const platform3 = opts?.platform ?? process.platform;
26807
- const p2 = platform3 === "win32" ? path68.win32 : path68.posix;
27099
+ const p2 = platform3 === "win32" ? path69.win32 : path69.posix;
26808
27100
  const normalized = entryScript.split(/[\\/]/).join("/");
26809
27101
  const marker = "/lib/node_modules/codeam-cli/";
26810
27102
  const markerIdx = normalized.indexOf(marker);
@@ -26826,7 +27118,7 @@ function isPermissionError(stderr) {
26826
27118
  function resolveGlobalNodeModulesDir(opts) {
26827
27119
  const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
26828
27120
  const platform3 = opts?.platform ?? process.platform;
26829
- const p2 = platform3 === "win32" ? path68.win32 : path68.posix;
27121
+ const p2 = platform3 === "win32" ? path69.win32 : path69.posix;
26830
27122
  const marker = "/lib/node_modules/codeam-cli/";
26831
27123
  const markerIdx = entryScript.split(/[\\/]/).join("/").indexOf(marker);
26832
27124
  if (markerIdx <= 0) return null;
@@ -26836,9 +27128,9 @@ function resolveGlobalNodeModulesDir(opts) {
26836
27128
  var STALE_STAGING_AGE_MS = CLI_UPDATE_INSTALL_TIMEOUT_MS;
26837
27129
  function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
26838
27130
  if (!nodeModulesDir) return 0;
26839
- const readdirSync15 = deps?.readdirSync ?? fs63.readdirSync;
26840
- const statSync17 = deps?.statSync ?? fs63.statSync;
26841
- const rmSync9 = deps?.rmSync ?? fs63.rmSync;
27131
+ const readdirSync15 = deps?.readdirSync ?? fs64.readdirSync;
27132
+ const statSync17 = deps?.statSync ?? fs64.statSync;
27133
+ const rmSync9 = deps?.rmSync ?? fs64.rmSync;
26842
27134
  let removed = 0;
26843
27135
  let entries;
26844
27136
  try {
@@ -26848,7 +27140,7 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
26848
27140
  }
26849
27141
  for (const name of entries) {
26850
27142
  if (!/^\.codeam-cli-/.test(name)) continue;
26851
- const full = path68.join(nodeModulesDir, name);
27143
+ const full = path69.join(nodeModulesDir, name);
26852
27144
  try {
26853
27145
  const st3 = statSync17(full);
26854
27146
  if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
@@ -27726,11 +28018,11 @@ function resolveTokenValue(args2) {
27726
28018
  }
27727
28019
  const fileFlag = args2.find((a) => a.startsWith("--token-file="));
27728
28020
  if (fileFlag) {
27729
- const path91 = fileFlag.slice("--token-file=".length);
28021
+ const path92 = fileFlag.slice("--token-file=".length);
27730
28022
  try {
27731
- const content = fs64.readFileSync(path91, "utf8").trim();
27732
- if (content.length === 0) fail(`--token-file ${path91} is empty`);
27733
- rmIfExistsQuiet(path91);
28023
+ const content = fs65.readFileSync(path92, "utf8").trim();
28024
+ if (content.length === 0) fail(`--token-file ${path92} is empty`);
28025
+ rmIfExistsQuiet(path92);
27734
28026
  return content;
27735
28027
  } catch (err) {
27736
28028
  fail(`Could not read --token-file: ${err.message}`);
@@ -27759,7 +28051,7 @@ async function claimOnce(token, pluginId, pluginSecretHash) {
27759
28051
  pluginId,
27760
28052
  ideName: "codeam-cli (codespace)",
27761
28053
  ideVersion: process.env.npm_package_version ?? "unknown",
27762
- hostname: os54.hostname(),
28054
+ hostname: os55.hostname(),
27763
28055
  codespaceName: process.env.CODESPACE_NAME ?? "",
27764
28056
  // Current git branch of the codespace's working directory, so the
27765
28057
  // backend can populate `PairedSession.branch` for the codespace pair.
@@ -27820,7 +28112,7 @@ async function claim(token, pluginId, pluginSecretHash) {
27820
28112
  }
27821
28113
  }
27822
28114
  function pairAutoLockPath() {
27823
- return path69.join(os54.homedir(), ".codeam", "pair-auto.lock");
28115
+ return path70.join(os55.homedir(), ".codeam", "pair-auto.lock");
27824
28116
  }
27825
28117
  function isLivePairAuto(pid) {
27826
28118
  if (!Number.isInteger(pid) || pid <= 0 || pid === process.pid) return false;
@@ -27830,7 +28122,7 @@ function isLivePairAuto(pid) {
27830
28122
  if (e.code !== "EPERM") return false;
27831
28123
  }
27832
28124
  try {
27833
- return fs64.readFileSync(`/proc/${pid}/cmdline`, "utf8").includes("codeam");
28125
+ return fs65.readFileSync(`/proc/${pid}/cmdline`, "utf8").includes("codeam");
27834
28126
  } catch {
27835
28127
  return true;
27836
28128
  }
@@ -27840,24 +28132,24 @@ function isLiveCodeam(pid) {
27840
28132
  }
27841
28133
  function daemonLockPath(sessionId) {
27842
28134
  const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
27843
- return path69.join(os54.homedir(), ".codeam", `daemon-${safe}.lock`);
28135
+ return path70.join(os55.homedir(), ".codeam", `daemon-${safe}.lock`);
27844
28136
  }
27845
28137
  function acquireDaemonLock(sessionId) {
27846
28138
  const lockPath = daemonLockPath(sessionId);
27847
28139
  try {
27848
- fs64.mkdirSync(path69.dirname(lockPath), { recursive: true });
28140
+ fs65.mkdirSync(path70.dirname(lockPath), { recursive: true });
27849
28141
  try {
27850
- fs64.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
28142
+ fs65.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
27851
28143
  } catch (e) {
27852
28144
  if (e.code !== "EEXIST") throw e;
27853
- const holder = Number(fs64.readFileSync(lockPath, "utf8").trim());
28145
+ const holder = Number(fs65.readFileSync(lockPath, "utf8").trim());
27854
28146
  if (holder && holder !== process.pid && isLiveCodeam(holder)) return false;
27855
- fs64.writeFileSync(lockPath, String(process.pid));
28147
+ fs65.writeFileSync(lockPath, String(process.pid));
27856
28148
  }
27857
28149
  const release3 = () => {
27858
28150
  try {
27859
- if (fs64.existsSync(lockPath) && Number(fs64.readFileSync(lockPath, "utf8").trim()) === process.pid) {
27860
- fs64.unlinkSync(lockPath);
28151
+ if (fs65.existsSync(lockPath) && Number(fs65.readFileSync(lockPath, "utf8").trim()) === process.pid) {
28152
+ fs65.unlinkSync(lockPath);
27861
28153
  }
27862
28154
  } catch {
27863
28155
  }
@@ -27879,19 +28171,19 @@ function acquireDaemonLock(sessionId) {
27879
28171
  function acquireSingletonLock() {
27880
28172
  const lockPath = pairAutoLockPath();
27881
28173
  try {
27882
- fs64.mkdirSync(path69.dirname(lockPath), { recursive: true });
28174
+ fs65.mkdirSync(path70.dirname(lockPath), { recursive: true });
27883
28175
  try {
27884
- fs64.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
28176
+ fs65.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
27885
28177
  } catch (e) {
27886
28178
  if (e.code !== "EEXIST") throw e;
27887
- const holder = Number(fs64.readFileSync(lockPath, "utf8").trim());
28179
+ const holder = Number(fs65.readFileSync(lockPath, "utf8").trim());
27888
28180
  if (isLivePairAuto(holder)) return false;
27889
- fs64.writeFileSync(lockPath, String(process.pid));
28181
+ fs65.writeFileSync(lockPath, String(process.pid));
27890
28182
  }
27891
28183
  process.once("exit", () => {
27892
28184
  try {
27893
- if (fs64.existsSync(lockPath) && Number(fs64.readFileSync(lockPath, "utf8").trim()) === process.pid) {
27894
- fs64.unlinkSync(lockPath);
28185
+ if (fs65.existsSync(lockPath) && Number(fs65.readFileSync(lockPath, "utf8").trim()) === process.pid) {
28186
+ fs65.unlinkSync(lockPath);
27895
28187
  }
27896
28188
  } catch {
27897
28189
  }
@@ -28343,7 +28635,7 @@ var AgentService = class _AgentService {
28343
28635
  };
28344
28636
 
28345
28637
  // src/agents/acp/adapters.ts
28346
- var path70 = __toESM(require("path"));
28638
+ var path71 = __toESM(require("path"));
28347
28639
 
28348
28640
  // src/agents/kimi/installer.ts
28349
28641
  var import_node_child_process27 = require("child_process");
@@ -28463,13 +28755,13 @@ function resolveBin(pkgName, binName) {
28463
28755
  try {
28464
28756
  const manifestPath = require_.resolve(`${pkgName}/package.json`);
28465
28757
  const manifest = require_(`${pkgName}/package.json`);
28466
- const pkgDir = path70.dirname(manifestPath);
28758
+ const pkgDir = path71.dirname(manifestPath);
28467
28759
  const bin = manifest.bin;
28468
28760
  if (!bin) return null;
28469
- if (typeof bin === "string") return path70.resolve(pkgDir, bin);
28761
+ if (typeof bin === "string") return path71.resolve(pkgDir, bin);
28470
28762
  const target = binName ?? Object.keys(bin)[0];
28471
28763
  if (!target || !bin[target]) return null;
28472
- return path70.resolve(pkgDir, bin[target]);
28764
+ return path71.resolve(pkgDir, bin[target]);
28473
28765
  } catch {
28474
28766
  return null;
28475
28767
  }
@@ -28658,286 +28950,6 @@ var os56 = __toESM(require("os"));
28658
28950
  var https7 = __toESM(require("https"));
28659
28951
  var http6 = __toESM(require("http"));
28660
28952
  var import_zod2 = require("zod");
28661
-
28662
- // src/agents/acp/squad-roster.ts
28663
- var fs65 = __toESM(require("fs"));
28664
- var os55 = __toESM(require("os"));
28665
- var path71 = __toESM(require("path"));
28666
- var PROMPT_MAX = 500;
28667
- var REPLY_SUMMARY_MAX = 1e3;
28668
- var PREAMBLE_MAX = 2e3;
28669
- var BRIEFING_DEFAULT_MAX = 8e3;
28670
- var GENERIC_SPECIALTY = "general implementation tasks";
28671
- function clip(s, max) {
28672
- return s.length > max ? s.slice(0, max) : s;
28673
- }
28674
- function defaultMember() {
28675
- return {
28676
- acpSessionId: null,
28677
- provisioned: false,
28678
- binaryVerified: false,
28679
- lastTurnIndex: 0,
28680
- contextTextFallback: false
28681
- };
28682
- }
28683
- function journalPathFor(homeDir2, sessionId) {
28684
- return path71.join(homeDir2, ".codeam", `squad-journal-${sessionId}.json`);
28685
- }
28686
- function loadJournal(journalPath) {
28687
- try {
28688
- const raw = JSON.parse(fs65.readFileSync(journalPath, "utf-8"));
28689
- return Array.isArray(raw.turns) ? raw.turns : [];
28690
- } catch {
28691
- return [];
28692
- }
28693
- }
28694
- var SquadState = class {
28695
- /** Set by the caller after fetchSquadRoster; null until then. */
28696
- roster = null;
28697
- /**
28698
- * Autonomous chained handoffs (P2-2, PRO). Seeded from the persisted
28699
- * `SavedSession.squadAuto` at session start and rewritten by
28700
- * `squad_configure`. Read-only to callers — mutate via {@link setAuto}, which
28701
- * clamps the budget and re-arms the chain.
28702
- */
28703
- autoConfig = { enabled: false, hopBudget: SQUAD_HOP_BUDGET_DEFAULT };
28704
- /**
28705
- * Hops left in the CURRENT chain. Reset to the budget on every USER-initiated
28706
- * prompt (so a user turn always interrupts and re-arms) and decremented by
28707
- * each self-accepted handoff.
28708
- */
28709
- hopsLeft = 0;
28710
- /** Lifetime handoff counters for `squad_stats` (in-memory, this process). */
28711
- handoffCounters = { proposed: 0, accepted: 0, auto: 0 };
28712
- journalPath;
28713
- turns;
28714
- members = /* @__PURE__ */ new Map();
28715
- constructor(opts) {
28716
- this.journalPath = journalPathFor(opts.homeDir ?? os55.homedir(), opts.sessionId);
28717
- this.turns = loadJournal(this.journalPath);
28718
- if (opts.auto) this.setAuto(opts.auto);
28719
- }
28720
- get auto() {
28721
- return this.autoConfig;
28722
- }
28723
- /** Apply a new mode (clamping the budget) and re-arm the chain. */
28724
- setAuto(value) {
28725
- this.autoConfig = {
28726
- enabled: value.enabled === true,
28727
- hopBudget: clampHopBudget(value.hopBudget)
28728
- };
28729
- this.resetHops();
28730
- return this.autoConfig;
28731
- }
28732
- hopsRemaining() {
28733
- return this.hopsLeft;
28734
- }
28735
- /** Re-arm the chain — called at the start of every USER-initiated turn. */
28736
- resetHops() {
28737
- this.hopsLeft = this.autoConfig.enabled ? this.autoConfig.hopBudget : 0;
28738
- }
28739
- /** Spend one hop on a self-accepted handoff. */
28740
- consumeHop() {
28741
- if (this.hopsLeft > 0) this.hopsLeft -= 1;
28742
- }
28743
- countProposal(opts) {
28744
- this.handoffCounters.proposed += 1;
28745
- if (opts.auto) this.handoffCounters.auto += 1;
28746
- }
28747
- countAccepted() {
28748
- this.handoffCounters.accepted += 1;
28749
- }
28750
- /**
28751
- * Per-member activity for the `squad_stats` relay command, derived from the
28752
- * journal (the same shared history the delta briefing reads) plus the
28753
- * in-memory handoff counters. `filesTouched` counts DISTINCT paths — a member
28754
- * that edited the same file across three turns touched ONE file.
28755
- */
28756
- stats() {
28757
- const byAgent = /* @__PURE__ */ new Map();
28758
- for (const t2 of this.turns) {
28759
- let row = byAgent.get(t2.agentId);
28760
- if (!row) {
28761
- row = { turns: 0, files: /* @__PURE__ */ new Set() };
28762
- byAgent.set(t2.agentId, row);
28763
- }
28764
- row.turns += 1;
28765
- for (const f of t2.filesTouched) row.files.add(f);
28766
- }
28767
- const members = [...byAgent.entries()].map(([agentId, row]) => ({
28768
- agentId,
28769
- turns: row.turns,
28770
- filesTouched: row.files.size
28771
- }));
28772
- return { members, handoffs: { ...this.handoffCounters }, sinceTurn: 1 };
28773
- }
28774
- /** Returns (creating on first access) the mutable per-agent state. */
28775
- member(agentId) {
28776
- let m = this.members.get(agentId);
28777
- if (!m) {
28778
- m = defaultMember();
28779
- this.members.set(agentId, m);
28780
- }
28781
- return m;
28782
- }
28783
- /** Appends a journal entry and persists (fire-and-forget durability). */
28784
- recordTurn(entry) {
28785
- const turn = {
28786
- turn: this.turns.length + 1,
28787
- agentId: entry.agentId,
28788
- prompt: clip(entry.prompt, PROMPT_MAX),
28789
- replySummary: clip(entry.replySummary, REPLY_SUMMARY_MAX),
28790
- filesTouched: entry.filesTouched
28791
- };
28792
- this.turns.push(turn);
28793
- this.persist();
28794
- }
28795
- turnCount() {
28796
- return this.turns.length;
28797
- }
28798
- entriesSince(turnIndex) {
28799
- return this.turns.filter((t2) => t2.turn > turnIndex);
28800
- }
28801
- persist() {
28802
- try {
28803
- fs65.mkdirSync(path71.dirname(this.journalPath), { recursive: true, mode: 448 });
28804
- fs65.writeFileSync(this.journalPath, JSON.stringify({ turns: this.turns }), { mode: 384 });
28805
- } catch {
28806
- }
28807
- }
28808
- };
28809
- function specialtyFor(agentId) {
28810
- return SQUAD_SPECIALTIES[agentId] ?? GENERIC_SPECIALTY;
28811
- }
28812
- var TEAM_PREAMBLE_MARKER = "[Team context]";
28813
- var TEAM_PREAMBLE_LINES = [
28814
- "[Team context] You are the active agent in a CodeAgent Mobile session where the user",
28815
- "has a squad of agents and can pass work between them. Your available teammates:",
28816
- "If a task clearly fits a teammate better than you, you MAY propose a handoff by ending",
28817
- `your reply with a fenced code block tagged ${HANDOFF_FENCE_TAG} containing ONE JSON object:`,
28818
- '{"to":"<teammate id>","reason":"<one sentence>","prompt":"<the prompt they should run>"}',
28819
- "Propose at most one handoff per reply, only when genuinely better, and never announce",
28820
- "the block in prose \u2014 the app renders it as a card the user can accept."
28821
- ];
28822
- var TEAM_PREAMBLE_BULLET_RE = /^- .+ — best at: /;
28823
- var BRIEFING_MARKER = "[Team update]";
28824
- var BRIEFING_HEADER = "[Team update] While you were away, other agents worked on this session:";
28825
- var BRIEFING_FOOTER = "Continue from the CURRENT state of the working tree.";
28826
- function buildTeamPreamble(roster, currentAgent, opts) {
28827
- const others = roster.agents.filter((a) => a.agentId !== currentAgent);
28828
- if (others.length === 0) return null;
28829
- const lines = [
28830
- TEAM_PREAMBLE_LINES[0],
28831
- TEAM_PREAMBLE_LINES[1],
28832
- ...others.map((a) => `- ${a.displayName} \u2014 best at: ${specialtyFor(a.agentId)}`)
28833
- ];
28834
- if (opts.handoffInstructions) {
28835
- lines.push(...TEAM_PREAMBLE_LINES.slice(2));
28836
- }
28837
- return clip(lines.join("\n"), PREAMBLE_MAX);
28838
- }
28839
- function renderJournalEntry(e) {
28840
- const filesClause = e.filesTouched.length > 0 ? ` (files: ${e.filesTouched.join(", ")})` : "";
28841
- return `- turn ${e.turn} (${e.agentId}): ${e.prompt} \u2192 ${e.replySummary}${filesClause}`;
28842
- }
28843
- function buildDeltaBriefing(entries, maxChars = BRIEFING_DEFAULT_MAX) {
28844
- if (entries.length === 0) return null;
28845
- const header = BRIEFING_HEADER;
28846
- const footer = BRIEFING_FOOTER;
28847
- const envelope = header.length + 1 + footer.length + 1;
28848
- const sorted = [...entries].sort((a, b) => a.turn - b.turn);
28849
- const lines = [];
28850
- let bodyLen = 0;
28851
- for (let i = sorted.length - 1; i >= 0; i--) {
28852
- const line = renderJournalEntry(sorted[i]);
28853
- const addedLen = line.length + (lines.length > 0 ? 1 : 0);
28854
- if (lines.length > 0 && envelope + bodyLen + addedLen > maxChars) break;
28855
- lines.unshift(line);
28856
- bodyLen += addedLen;
28857
- }
28858
- return [header, lines.join("\n"), footer].join("\n");
28859
- }
28860
-
28861
- // src/agents/acp/squad-context.ts
28862
- var SQUAD_CONTEXT_URI = "codeam://squad-context";
28863
- var HANDOFF_MARKER = "[Session handoff]";
28864
- var HANDOFF_TERMINATOR = "--- End of handoff context ---";
28865
- function buildSquadContextBlock(text) {
28866
- return {
28867
- type: "resource",
28868
- resource: { uri: SQUAD_CONTEXT_URI, mimeType: "text/plain", text }
28869
- };
28870
- }
28871
- function isSquadContextBlock(block) {
28872
- return block.type === "resource" && block.resource.uri === SQUAD_CONTEXT_URI;
28873
- }
28874
- function looksLikeUnsupportedPromptShape(err) {
28875
- const code = err?.code;
28876
- if (code === -32602) return true;
28877
- const message = err instanceof Error ? err.message : String(err ?? "");
28878
- if (/invalid[ _]params|-32602/i.test(message)) return true;
28879
- return /\bresource\b/i.test(message) && /unsupported|not supported/i.test(message);
28880
- }
28881
- function skipWhile(lines, start2, keepGoing) {
28882
- let i = start2;
28883
- while (i < lines.length && keepGoing(lines[i])) i++;
28884
- return i;
28885
- }
28886
- function endOfTeamPreamble(lines, start2) {
28887
- if (lines[start2] !== TEAM_PREAMBLE_LINES[0]) return -1;
28888
- if (lines[start2 + 1] !== TEAM_PREAMBLE_LINES[1]) return -1;
28889
- return skipWhile(
28890
- lines,
28891
- start2 + 2,
28892
- (line) => TEAM_PREAMBLE_BULLET_RE.test(line) || TEAM_PREAMBLE_LINES.includes(line)
28893
- );
28894
- }
28895
- function endOfTerminatedBlock(lines, start2, terminator) {
28896
- for (let i = start2; i < lines.length; i++) {
28897
- if (lines[i].trimEnd() === terminator) return i + 1;
28898
- }
28899
- return -1;
28900
- }
28901
- function stripSquadContext(text) {
28902
- if (!text.includes(HANDOFF_MARKER) && !text.includes(BRIEFING_MARKER) && !text.includes(TEAM_PREAMBLE_MARKER)) {
28903
- return text;
28904
- }
28905
- const lines = text.split("\n");
28906
- const kept = [];
28907
- let i = 0;
28908
- let stripped = false;
28909
- while (i < lines.length) {
28910
- const line = lines[i];
28911
- if (line.startsWith(HANDOFF_MARKER)) {
28912
- const end = endOfTerminatedBlock(lines, i, HANDOFF_TERMINATOR);
28913
- if (end !== -1) {
28914
- i = end;
28915
- stripped = true;
28916
- continue;
28917
- }
28918
- } else if (line.startsWith(BRIEFING_MARKER)) {
28919
- const end = endOfTerminatedBlock(lines, i, BRIEFING_FOOTER);
28920
- if (end !== -1) {
28921
- i = end;
28922
- stripped = true;
28923
- continue;
28924
- }
28925
- } else if (line.startsWith(TEAM_PREAMBLE_MARKER)) {
28926
- const end = endOfTeamPreamble(lines, i);
28927
- if (end !== -1) {
28928
- i = end;
28929
- stripped = true;
28930
- continue;
28931
- }
28932
- }
28933
- kept.push(line);
28934
- i++;
28935
- }
28936
- if (!stripped) return text;
28937
- return kept.join("\n").trim();
28938
- }
28939
-
28940
- // src/services/history.service.ts
28941
28953
  var historyRecordSchema = import_zod2.z.object({
28942
28954
  type: import_zod2.z.string().optional(),
28943
28955
  timestamp: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.number()]).optional(),
@@ -28960,6 +28972,7 @@ var CONVERSATION_BATCH_SIZE = 30;
28960
28972
  function scrubSquadContext(messages) {
28961
28973
  const out2 = [];
28962
28974
  for (const m of messages) {
28975
+ if (isLeakedSquadContextText(m.text) || isAgentMetaBlock(m.text)) continue;
28963
28976
  const text = stripSquadContext(m.text);
28964
28977
  if (text === m.text) {
28965
28978
  out2.push(m);
@@ -28991,7 +29004,11 @@ function parseJsonl(filePath) {
28991
29004
  }
28992
29005
  const result = historyRecordSchema.safeParse(parsedJson);
28993
29006
  if (!result.success) {
28994
- log.warn("history:parseJsonl", `record failed schema validation in ${filePath}`, result.error.issues);
29007
+ log.warn(
29008
+ "history:parseJsonl",
29009
+ `record failed schema validation in ${filePath}`,
29010
+ result.error.issues
29011
+ );
28995
29012
  continue;
28996
29013
  }
28997
29014
  const record2 = result.data;
@@ -29256,7 +29273,14 @@ var HistoryService = class _HistoryService {
29256
29273
  const inputTokens = (lastUsage["input_tokens"] ?? lastUsage["prompt_tokens"] ?? 0) + (lastUsage["cache_read_input_tokens"] ?? 0) + (lastUsage["cache_creation_input_tokens"] ?? 0);
29257
29274
  const outputTokens = lastUsage["output_tokens"] ?? lastUsage["completion_tokens"] ?? 0;
29258
29275
  const percent = Math.min(100, Math.round(inputTokens / total * 100));
29259
- return { used: inputTokens, total, percent, model: lastModel, outputTokens, cacheReadTokens: lastUsage["cache_read_input_tokens"] ?? 0 };
29276
+ return {
29277
+ used: inputTokens,
29278
+ total,
29279
+ percent,
29280
+ model: lastModel,
29281
+ outputTokens,
29282
+ cacheReadTokens: lastUsage["cache_read_input_tokens"] ?? 0
29283
+ };
29260
29284
  }
29261
29285
  /**
29262
29286
  * Estimate the API cost for the current month in the current project directory.
@@ -29429,7 +29453,9 @@ var HistoryService = class _HistoryService {
29429
29453
  ok = await post("/api/sessions/conversation", body, this.pluginAuthToken);
29430
29454
  }
29431
29455
  if (!ok) {
29432
- throw new Error(`Failed to upload conversation batch ${i + 1}/${totalBatches} after all retries`);
29456
+ throw new Error(
29457
+ `Failed to upload conversation batch ${i + 1}/${totalBatches} after all retries`
29458
+ );
29433
29459
  }
29434
29460
  }
29435
29461
  const last = messages[messages.length - 1];
@@ -35941,7 +35967,7 @@ function defaultRunGit(cwd, args2) {
35941
35967
  });
35942
35968
  }
35943
35969
  async function discoverRepos(workingDir, maxDepth = 4) {
35944
- const fs80 = await import("fs/promises");
35970
+ const fs81 = await import("fs/promises");
35945
35971
  const out2 = [];
35946
35972
  await walk(workingDir, 0);
35947
35973
  return out2;
@@ -35949,7 +35975,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
35949
35975
  if (depth > maxDepth) return;
35950
35976
  let entries = [];
35951
35977
  try {
35952
- const dirents = await fs80.readdir(dir, { withFileTypes: true });
35978
+ const dirents = await fs81.readdir(dir, { withFileTypes: true });
35953
35979
  entries = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
35954
35980
  } catch {
35955
35981
  return;
@@ -37184,12 +37210,124 @@ function buildMcpServersForStart(ctx) {
37184
37210
  return servers;
37185
37211
  }
37186
37212
 
37187
- // src/integrations/detect-stack.ts
37213
+ // src/services/local-mcp-servers.ts
37188
37214
  var import_node_fs12 = __toESM(require("fs"));
37215
+ var import_node_os12 = __toESM(require("os"));
37189
37216
  var import_node_path11 = __toESM(require("path"));
37217
+ var MAX_LOCAL_MCP_SERVERS = 10;
37218
+ function localMcpServersPath() {
37219
+ return import_node_path11.default.join(import_node_os12.default.homedir(), ".codeam", "mcp-servers.json");
37220
+ }
37221
+ function isStringArray(v) {
37222
+ return Array.isArray(v) && v.every((item) => typeof item === "string");
37223
+ }
37224
+ function toEnvVariables(v) {
37225
+ if (v === void 0) return [];
37226
+ if (v === null || typeof v !== "object" || Array.isArray(v)) return null;
37227
+ const entries = Object.entries(v);
37228
+ if (entries.some(([, value]) => typeof value !== "string")) return null;
37229
+ return entries.map(([name, value]) => ({ name, value }));
37230
+ }
37231
+ function isValidEntry(entry) {
37232
+ return typeof entry.name === "string" && entry.name.length > 0 && typeof entry.command === "string" && entry.command.length > 0 && isStringArray(entry.args);
37233
+ }
37234
+ function readLocalMcpServers() {
37235
+ let raw;
37236
+ try {
37237
+ raw = import_node_fs12.default.readFileSync(localMcpServersPath(), "utf8");
37238
+ } catch {
37239
+ return [];
37240
+ }
37241
+ let parsed;
37242
+ try {
37243
+ parsed = JSON.parse(raw);
37244
+ } catch (err) {
37245
+ log.warn(
37246
+ "localMcp",
37247
+ `~/.codeam/mcp-servers.json is not valid JSON \u2014 ignoring (${err instanceof Error ? err.message : String(err)})`
37248
+ );
37249
+ return [];
37250
+ }
37251
+ if (!Array.isArray(parsed)) {
37252
+ log.warn("localMcp", "~/.codeam/mcp-servers.json must be a JSON array \u2014 ignoring");
37253
+ return [];
37254
+ }
37255
+ const servers = [];
37256
+ let sawInvalid = false;
37257
+ let sawTruncated = false;
37258
+ let sawDuplicate = false;
37259
+ const seenNames = /* @__PURE__ */ new Set();
37260
+ for (const entry of parsed) {
37261
+ if (servers.length >= MAX_LOCAL_MCP_SERVERS) {
37262
+ sawTruncated = true;
37263
+ continue;
37264
+ }
37265
+ if (entry === null || typeof entry !== "object" || !isValidEntry(entry)) {
37266
+ sawInvalid = true;
37267
+ continue;
37268
+ }
37269
+ const env = toEnvVariables(entry.env);
37270
+ if (env === null) {
37271
+ sawInvalid = true;
37272
+ continue;
37273
+ }
37274
+ if (seenNames.has(entry.name)) {
37275
+ sawDuplicate = true;
37276
+ continue;
37277
+ }
37278
+ seenNames.add(entry.name);
37279
+ servers.push({ name: entry.name, command: entry.command, args: entry.args, env });
37280
+ }
37281
+ if (sawDuplicate) {
37282
+ log.warn(
37283
+ "localMcp",
37284
+ "~/.codeam/mcp-servers.json has duplicate server names \u2014 kept the first of each"
37285
+ );
37286
+ }
37287
+ if (sawInvalid) {
37288
+ log.warn(
37289
+ "localMcp",
37290
+ '~/.codeam/mcp-servers.json contains one or more invalid entries \u2014 skipped (each needs a non-empty "name", non-empty "command", "args" as a string array, and "env" as an object of string values)'
37291
+ );
37292
+ }
37293
+ if (sawTruncated) {
37294
+ log.warn(
37295
+ "localMcp",
37296
+ `~/.codeam/mcp-servers.json has more than ${MAX_LOCAL_MCP_SERVERS} entries \u2014 only the first ${MAX_LOCAL_MCP_SERVERS} were loaded`
37297
+ );
37298
+ }
37299
+ if (servers.length) {
37300
+ log.info(
37301
+ "localMcp",
37302
+ `loaded ${servers.length} local MCP server(s): ${servers.map((s) => s.name).join(", ")}`
37303
+ );
37304
+ }
37305
+ return servers;
37306
+ }
37307
+ function mergeWithLocalMcpServers(integrationServers) {
37308
+ const localServers = readLocalMcpServers();
37309
+ if (localServers.length === 0) return integrationServers;
37310
+ const integrationNames = new Set(integrationServers.map((s) => s.name));
37311
+ const merged = [...integrationServers];
37312
+ for (const local of localServers) {
37313
+ if (integrationNames.has(local.name)) {
37314
+ log.warn(
37315
+ "localMcp",
37316
+ `local MCP server "${local.name}" collides with an Agent Toolkit integration of the same name \u2014 the integration wins, skipping the local entry`
37317
+ );
37318
+ continue;
37319
+ }
37320
+ merged.push(local);
37321
+ }
37322
+ return merged;
37323
+ }
37324
+
37325
+ // src/integrations/detect-stack.ts
37326
+ var import_node_fs13 = __toESM(require("fs"));
37327
+ var import_node_path12 = __toESM(require("path"));
37190
37328
  function readSafe(cwd, rel) {
37191
37329
  try {
37192
- return import_node_fs12.default.readFileSync(import_node_path11.default.join(cwd, rel), "utf8");
37330
+ return import_node_fs13.default.readFileSync(import_node_path12.default.join(cwd, rel), "utf8");
37193
37331
  } catch {
37194
37332
  return "";
37195
37333
  }
@@ -37372,35 +37510,35 @@ function buildAcpPromptBlocks(payload) {
37372
37510
  }
37373
37511
 
37374
37512
  // src/agents/agent-standard.ts
37375
- var fs75 = __toESM(require("fs"));
37376
- var path82 = __toESM(require("path"));
37377
- var os60 = __toESM(require("os"));
37378
- function ensureAgentStandard(homeDir2 = os60.homedir()) {
37513
+ var fs76 = __toESM(require("fs"));
37514
+ var path83 = __toESM(require("path"));
37515
+ var os61 = __toESM(require("os"));
37516
+ function ensureAgentStandard(homeDir2 = os61.homedir()) {
37379
37517
  try {
37380
- const file = path82.join(homeDir2, ".claude", "CLAUDE.md");
37518
+ const file = path83.join(homeDir2, ".claude", "CLAUDE.md");
37381
37519
  let existing = "";
37382
37520
  try {
37383
- existing = fs75.readFileSync(file, "utf8");
37521
+ existing = fs76.readFileSync(file, "utf8");
37384
37522
  } catch {
37385
37523
  }
37386
37524
  if (existing.includes(AGENT_STANDARD_MARKER)) return;
37387
- fs75.mkdirSync(path82.dirname(file), { recursive: true });
37525
+ fs76.mkdirSync(path83.dirname(file), { recursive: true });
37388
37526
  const next = existing.trim() ? `${existing.trimEnd()}
37389
37527
 
37390
37528
  ${AGENT_STANDARD_BLOCK}
37391
37529
  ` : `${AGENT_STANDARD_BLOCK}
37392
37530
  `;
37393
- fs75.writeFileSync(file, next);
37531
+ fs76.writeFileSync(file, next);
37394
37532
  } catch {
37395
37533
  }
37396
37534
  }
37397
37535
  var _agentStandardSeam = {
37398
37536
  isLocalSession: () => isLocalSession(),
37399
- markerPath: (sessionId) => path82.join(os60.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
37400
- exists: (p2) => fs75.existsSync(p2),
37537
+ markerPath: (sessionId) => path83.join(os61.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
37538
+ exists: (p2) => fs76.existsSync(p2),
37401
37539
  write: (p2) => {
37402
- fs75.mkdirSync(path82.dirname(p2), { recursive: true });
37403
- fs75.writeFileSync(p2, "");
37540
+ fs76.mkdirSync(path83.dirname(p2), { recursive: true });
37541
+ fs76.writeFileSync(p2, "");
37404
37542
  }
37405
37543
  };
37406
37544
  function isClaude(agent) {
@@ -38338,12 +38476,14 @@ async function integrationsSyncH(ctx) {
38338
38476
  const previousIds = new Set((readIntegrationsManifest()?.integrations ?? []).map((e) => e.id));
38339
38477
  persistIntegrationsManifest(manifest);
38340
38478
  await prewarmNewMcpEntries(manifest, previousIds);
38341
- const servers = buildMcpServersForStart({
38342
- sessionId: opts.sessionId,
38343
- pluginId: opts.pluginId,
38344
- pluginAuthToken: opts.pluginAuthToken,
38345
- pollSecret: opts.pollSecret
38346
- });
38479
+ const servers = mergeWithLocalMcpServers(
38480
+ buildMcpServersForStart({
38481
+ sessionId: opts.sessionId,
38482
+ pluginId: opts.pluginId,
38483
+ pluginAuthToken: opts.pluginAuthToken,
38484
+ pollSecret: opts.pollSecret
38485
+ })
38486
+ );
38347
38487
  const applied = await client3.reprovisionMcp(servers);
38348
38488
  await relay.sendResult(cmd.id, "completed", {
38349
38489
  synced: true,
@@ -40608,9 +40748,9 @@ function startClaudeCredentialSync(opts) {
40608
40748
  }
40609
40749
 
40610
40750
  // src/beads/workflow-hint.ts
40611
- var fs76 = __toESM(require("fs"));
40612
- var path83 = __toESM(require("path"));
40613
- var os61 = __toESM(require("os"));
40751
+ var fs77 = __toESM(require("fs"));
40752
+ var path84 = __toESM(require("path"));
40753
+ var os62 = __toESM(require("os"));
40614
40754
  var BEADS_HINT_MARKER = "<!-- codeam:beads-workflow -->";
40615
40755
  var BEADS_HINT = `${BEADS_HINT_MARKER}
40616
40756
  # Beads (bd) \u2014 task tracking + persistent memory (ALWAYS use it)
@@ -40624,29 +40764,29 @@ This environment uses **bd (beads)** for issue/task tracking and persistent memo
40624
40764
  - \`bd ready\` (available work) \xB7 \`bd show <id>\` \xB7 \`bd update <id> --claim\` \xB7 \`bd close <id>\`.
40625
40765
  - Use \`bd remember "..."\` for persistent knowledge \u2014 do NOT use MEMORY.md files.
40626
40766
  ${BEADS_HINT_MARKER}`;
40627
- function ensureBeadsWorkflowHint(homeDir2 = os61.homedir()) {
40767
+ function ensureBeadsWorkflowHint(homeDir2 = os62.homedir()) {
40628
40768
  try {
40629
- const file = path83.join(homeDir2, ".claude", "CLAUDE.md");
40769
+ const file = path84.join(homeDir2, ".claude", "CLAUDE.md");
40630
40770
  let existing = "";
40631
40771
  try {
40632
- existing = fs76.readFileSync(file, "utf8");
40772
+ existing = fs77.readFileSync(file, "utf8");
40633
40773
  } catch {
40634
40774
  }
40635
40775
  if (existing.includes(BEADS_HINT_MARKER)) return;
40636
- fs76.mkdirSync(path83.dirname(file), { recursive: true });
40776
+ fs77.mkdirSync(path84.dirname(file), { recursive: true });
40637
40777
  const next = existing.trim() ? `${existing.trimEnd()}
40638
40778
 
40639
40779
  ${BEADS_HINT}
40640
40780
  ` : `${BEADS_HINT}
40641
40781
  `;
40642
- fs76.writeFileSync(file, next);
40782
+ fs77.writeFileSync(file, next);
40643
40783
  } catch {
40644
40784
  }
40645
40785
  }
40646
40786
 
40647
40787
  // src/skills/provision.ts
40648
- var import_node_os12 = __toESM(require("os"));
40649
- function provisionSkillsForStart(home = import_node_os12.default.homedir()) {
40788
+ var import_node_os13 = __toESM(require("os"));
40789
+ function provisionSkillsForStart(home = import_node_os13.default.homedir()) {
40650
40790
  const materialized = [];
40651
40791
  try {
40652
40792
  const manifest = readSkillsManifest();
@@ -41011,7 +41151,7 @@ var AcpDriver = class {
41011
41151
  };
41012
41152
 
41013
41153
  // src/baton/transcript-mirror.ts
41014
- var fs77 = __toESM(require("fs"));
41154
+ var fs78 = __toESM(require("fs"));
41015
41155
  var TranscriptMirror = class {
41016
41156
  constructor(deps) {
41017
41157
  this.deps = deps;
@@ -41078,7 +41218,7 @@ var TranscriptMirror = class {
41078
41218
  }
41079
41219
  };
41080
41220
  function defaultWatch(file, onChange) {
41081
- const w3 = fs77.watch(file, { persistent: false }, () => onChange());
41221
+ const w3 = fs78.watch(file, { persistent: false }, () => onChange());
41082
41222
  return () => w3.close();
41083
41223
  }
41084
41224
 
@@ -41376,16 +41516,16 @@ function keepDeviceAwake(deps = {}) {
41376
41516
  }
41377
41517
 
41378
41518
  // src/agents/claude/onboarding.ts
41379
- var fs78 = __toESM(require("fs"));
41380
- var os63 = __toESM(require("os"));
41381
- var path84 = __toESM(require("path"));
41519
+ var fs79 = __toESM(require("fs"));
41520
+ var os64 = __toESM(require("os"));
41521
+ var path85 = __toESM(require("path"));
41382
41522
  var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
41383
41523
  function ensureClaudeOnboarded(cwd) {
41384
41524
  try {
41385
- const file = path84.join(os63.homedir(), ".claude.json");
41525
+ const file = path85.join(os64.homedir(), ".claude.json");
41386
41526
  let config = {};
41387
41527
  try {
41388
- config = JSON.parse(fs78.readFileSync(file, "utf8"));
41528
+ config = JSON.parse(fs79.readFileSync(file, "utf8"));
41389
41529
  } catch {
41390
41530
  }
41391
41531
  let changed = false;
@@ -41410,8 +41550,8 @@ function ensureClaudeOnboarded(cwd) {
41410
41550
  }
41411
41551
  }
41412
41552
  if (!changed) return;
41413
- fs78.mkdirSync(path84.dirname(file), { recursive: true });
41414
- fs78.writeFileSync(file, JSON.stringify(config, null, 2));
41553
+ fs79.mkdirSync(path85.dirname(file), { recursive: true });
41554
+ fs79.writeFileSync(file, JSON.stringify(config, null, 2));
41415
41555
  log.info(
41416
41556
  "claude",
41417
41557
  `pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
@@ -41529,12 +41669,14 @@ async function start(requestedAgent, presetSession) {
41529
41669
  beads = started;
41530
41670
  return started;
41531
41671
  });
41532
- const mcpServers = buildMcpServersForStart({
41533
- sessionId: session.id,
41534
- pluginId,
41535
- pluginAuthToken: session.pluginAuthToken ?? void 0,
41536
- pollSecret: session.pollSecret
41537
- });
41672
+ const mcpServers = mergeWithLocalMcpServers(
41673
+ buildMcpServersForStart({
41674
+ sessionId: session.id,
41675
+ pluginId,
41676
+ pluginAuthToken: session.pluginAuthToken ?? void 0,
41677
+ pollSecret: session.pollSecret
41678
+ })
41679
+ );
41538
41680
  provisionSkillsForStart();
41539
41681
  const depsReady = process.env.CODESPACES === "true" ? provisionProjectDependencies(cwd).catch(() => void 0) : Promise.resolve();
41540
41682
  if (process.env.CODESPACES === "true") {
@@ -42143,7 +42285,7 @@ var import_picocolors11 = __toESM(require("picocolors"));
42143
42285
  var import_child_process30 = require("child_process");
42144
42286
  var import_util4 = require("util");
42145
42287
  var import_picocolors9 = __toESM(require("picocolors"));
42146
- var path85 = __toESM(require("path"));
42288
+ var path86 = __toESM(require("path"));
42147
42289
  var execFileP6 = (0, import_util4.promisify)(import_child_process30.execFile);
42148
42290
  var MAX_BUFFER = 8 * 1024 * 1024;
42149
42291
  function resetStdinForChild() {
@@ -42632,7 +42774,7 @@ var GitHubCodespacesProvider = class {
42632
42774
  });
42633
42775
  }
42634
42776
  async uploadFile(workspaceId, remotePath, contents, options = {}) {
42635
- const remoteDir = path85.posix.dirname(remotePath);
42777
+ const remoteDir = path86.posix.dirname(remotePath);
42636
42778
  const parts = [
42637
42779
  `mkdir -p ${shellQuote(remoteDir)}`,
42638
42780
  `cat > ${shellQuote(remotePath)}`
@@ -42702,7 +42844,7 @@ function shellQuote(s) {
42702
42844
  // src/services/providers/gitpod.ts
42703
42845
  var import_child_process31 = require("child_process");
42704
42846
  var import_util5 = require("util");
42705
- var path86 = __toESM(require("path"));
42847
+ var path87 = __toESM(require("path"));
42706
42848
  var import_picocolors10 = __toESM(require("picocolors"));
42707
42849
  var execFileP7 = (0, import_util5.promisify)(import_child_process31.execFile);
42708
42850
  var MAX_BUFFER2 = 8 * 1024 * 1024;
@@ -42942,7 +43084,7 @@ var GitpodProvider = class {
42942
43084
  });
42943
43085
  }
42944
43086
  async uploadFile(workspaceId, remotePath, contents, options = {}) {
42945
- const remoteDir = path86.posix.dirname(remotePath);
43087
+ const remoteDir = path87.posix.dirname(remotePath);
42946
43088
  const parts = [
42947
43089
  `mkdir -p ${shellQuote2(remoteDir)}`,
42948
43090
  `cat > ${shellQuote2(remotePath)}`
@@ -42978,7 +43120,7 @@ function shellQuote2(s) {
42978
43120
  // src/services/providers/gitlab-workspaces.ts
42979
43121
  var import_child_process32 = require("child_process");
42980
43122
  var import_util6 = require("util");
42981
- var path87 = __toESM(require("path"));
43123
+ var path88 = __toESM(require("path"));
42982
43124
  var execFileP8 = (0, import_util6.promisify)(import_child_process32.execFile);
42983
43125
  var MAX_BUFFER3 = 8 * 1024 * 1024;
42984
43126
  var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
@@ -43238,7 +43380,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
43238
43380
  }
43239
43381
  async uploadFile(workspaceId, remotePath, contents, options = {}) {
43240
43382
  const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
43241
- const remoteDir = path87.posix.dirname(remotePath);
43383
+ const remoteDir = path88.posix.dirname(remotePath);
43242
43384
  const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
43243
43385
  if (options.mode != null) {
43244
43386
  parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
@@ -43306,7 +43448,7 @@ function shellQuote3(s) {
43306
43448
  // src/services/providers/railway.ts
43307
43449
  var import_child_process33 = require("child_process");
43308
43450
  var import_util7 = require("util");
43309
- var path88 = __toESM(require("path"));
43451
+ var path89 = __toESM(require("path"));
43310
43452
  var execFileP9 = (0, import_util7.promisify)(import_child_process33.execFile);
43311
43453
  var MAX_BUFFER4 = 8 * 1024 * 1024;
43312
43454
  function resetStdinForChild4() {
@@ -43542,7 +43684,7 @@ var RailwayProvider = class {
43542
43684
  if (!projectId || !serviceId) {
43543
43685
  throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
43544
43686
  }
43545
- const remoteDir = path88.posix.dirname(remotePath);
43687
+ const remoteDir = path89.posix.dirname(remotePath);
43546
43688
  const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
43547
43689
  if (options.mode != null) {
43548
43690
  parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
@@ -44188,8 +44330,8 @@ async function invite() {
44188
44330
  var import_node_dns = require("dns");
44189
44331
  var import_node_util5 = require("util");
44190
44332
  var import_node_crypto13 = require("crypto");
44191
- var fs79 = __toESM(require("fs"));
44192
- var path89 = __toESM(require("path"));
44333
+ var fs80 = __toESM(require("fs"));
44334
+ var path90 = __toESM(require("path"));
44193
44335
  var import_picocolors14 = __toESM(require("picocolors"));
44194
44336
  var dnsResolveP = (0, import_node_util5.promisify)(import_node_dns.resolve);
44195
44337
  async function checkDns(apiBase2) {
@@ -44245,13 +44387,13 @@ async function checkHealth(apiBase2) {
44245
44387
  }
44246
44388
  }
44247
44389
  function checkConfigDir() {
44248
- const dir = path89.join(require("os").homedir(), ".codeam");
44390
+ const dir = path90.join(require("os").homedir(), ".codeam");
44249
44391
  try {
44250
- fs79.mkdirSync(dir, { recursive: true, mode: 448 });
44251
- const probe = path89.join(dir, ".doctor-probe");
44252
- fs79.writeFileSync(probe, "ok", { mode: 384 });
44253
- const read2 = fs79.readFileSync(probe, "utf8");
44254
- fs79.unlinkSync(probe);
44392
+ fs80.mkdirSync(dir, { recursive: true, mode: 448 });
44393
+ const probe = path90.join(dir, ".doctor-probe");
44394
+ fs80.writeFileSync(probe, "ok", { mode: 384 });
44395
+ const read2 = fs80.readFileSync(probe, "utf8");
44396
+ fs80.unlinkSync(probe);
44255
44397
  if (read2 !== "ok") throw new Error("write/read round-trip mismatch");
44256
44398
  return {
44257
44399
  id: "config-dir",
@@ -44291,9 +44433,9 @@ function checkSessions() {
44291
44433
  }
44292
44434
  }
44293
44435
  function checkAgentBinaries() {
44294
- const os66 = createOsStrategy();
44436
+ const os67 = createOsStrategy();
44295
44437
  return getEnabledAgents().map((meta) => {
44296
- const found = os66.findInPath(meta.binaryName);
44438
+ const found = os67.findInPath(meta.binaryName);
44297
44439
  return {
44298
44440
  id: `agent-${meta.id}`,
44299
44441
  label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
@@ -44315,7 +44457,7 @@ function checkNodePty() {
44315
44457
  detail: "not required on this platform"
44316
44458
  };
44317
44459
  }
44318
- const vendoredPath = path89.join(__dirname, "vendor", "node-pty");
44460
+ const vendoredPath = path90.join(__dirname, "vendor", "node-pty");
44319
44461
  for (const target of [vendoredPath, "node-pty"]) {
44320
44462
  try {
44321
44463
  require(target);
@@ -44357,7 +44499,7 @@ function checkChokidar() {
44357
44499
  }
44358
44500
  async function doctor(args2 = []) {
44359
44501
  const json = args2.includes("--json");
44360
- const cliVersion = true ? "2.65.1" : "0.0.0-dev";
44502
+ const cliVersion = true ? "2.65.3" : "0.0.0-dev";
44361
44503
  const apiBase2 = resolveApiBaseUrl();
44362
44504
  const diagnosticId = (0, import_node_crypto13.randomUUID)();
44363
44505
  log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
@@ -44555,9 +44697,9 @@ async function completion(args2) {
44555
44697
 
44556
44698
  // src/integrations/mcp-run.ts
44557
44699
  var import_node_child_process34 = require("child_process");
44558
- var import_node_fs13 = require("fs");
44559
- var import_node_os13 = __toESM(require("os"));
44560
- var import_node_path12 = __toESM(require("path"));
44700
+ var import_node_fs14 = require("fs");
44701
+ var import_node_os14 = __toESM(require("os"));
44702
+ var import_node_path13 = __toESM(require("path"));
44561
44703
 
44562
44704
  // src/integrations/token-client.ts
44563
44705
  var REFRESH_AHEAD_MS = 5 * 60 * 1e3;
@@ -44637,13 +44779,13 @@ function commandExists(command2) {
44637
44779
  }
44638
44780
  function localBinCandidates(command2) {
44639
44781
  return [
44640
- import_node_path12.default.join(import_node_os13.default.homedir(), ".local", "bin", command2),
44641
- import_node_path12.default.join(import_node_os13.default.homedir(), ".cargo", "bin", command2)
44782
+ import_node_path13.default.join(import_node_os14.default.homedir(), ".local", "bin", command2),
44783
+ import_node_path13.default.join(import_node_os14.default.homedir(), ".cargo", "bin", command2)
44642
44784
  ];
44643
44785
  }
44644
44786
  function resolveLauncherPath(command2, deps = {
44645
44787
  commandExists,
44646
- existsSync: import_node_fs13.existsSync
44788
+ existsSync: import_node_fs14.existsSync
44647
44789
  }) {
44648
44790
  if (deps.commandExists(command2)) return command2;
44649
44791
  for (const candidate of localBinCandidates(command2)) {
@@ -44748,7 +44890,7 @@ async function mcpRun(args2) {
44748
44890
  // src/commands/version.ts
44749
44891
  var import_picocolors15 = __toESM(require("picocolors"));
44750
44892
  function version2() {
44751
- const v = true ? "2.65.1" : "unknown";
44893
+ const v = true ? "2.65.3" : "unknown";
44752
44894
  console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
44753
44895
  }
44754
44896
 
@@ -44897,10 +45039,10 @@ var EXIT_CODE_NAMES = {
44897
45039
  };
44898
45040
 
44899
45041
  // src/index.ts
44900
- var os65 = __toESM(require("os"));
45042
+ var os66 = __toESM(require("os"));
44901
45043
  if (!process.env.HOME) {
44902
45044
  try {
44903
- const home = os65.homedir();
45045
+ const home = os66.homedir();
44904
45046
  if (home) process.env.HOME = home;
44905
45047
  } catch {
44906
45048
  }