codeam-cli 2.51.0 → 2.51.2
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.
- package/CHANGELOG.md +31 -0
- package/dist/index.js +597 -454
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -522,9 +522,9 @@ var _default = makeConfig();
|
|
|
522
522
|
var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, clearAll, saveCliConfig, loadCliConfig } = _default;
|
|
523
523
|
|
|
524
524
|
// src/commands/pair-auto.ts
|
|
525
|
-
var
|
|
526
|
-
var
|
|
527
|
-
var
|
|
525
|
+
var fs44 = __toESM(require("fs"));
|
|
526
|
+
var os37 = __toESM(require("os"));
|
|
527
|
+
var path49 = __toESM(require("path"));
|
|
528
528
|
var import_crypto4 = require("crypto");
|
|
529
529
|
|
|
530
530
|
// src/services/telemetry.service.ts
|
|
@@ -560,8 +560,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
|
|
|
560
560
|
return decodedFile;
|
|
561
561
|
};
|
|
562
562
|
}
|
|
563
|
-
function normalizeWindowsPath(
|
|
564
|
-
return
|
|
563
|
+
function normalizeWindowsPath(path62) {
|
|
564
|
+
return path62.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
565
565
|
}
|
|
566
566
|
|
|
567
567
|
// ../../node_modules/@posthog/core/dist/featureFlagUtils.mjs
|
|
@@ -3041,9 +3041,9 @@ async function addSourceContext(frames) {
|
|
|
3041
3041
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
3042
3042
|
return frames;
|
|
3043
3043
|
}
|
|
3044
|
-
function getContextLinesFromFile(
|
|
3044
|
+
function getContextLinesFromFile(path62, ranges, output) {
|
|
3045
3045
|
return new Promise((resolve7) => {
|
|
3046
|
-
const stream = (0, import_node_fs.createReadStream)(
|
|
3046
|
+
const stream = (0, import_node_fs.createReadStream)(path62);
|
|
3047
3047
|
const lineReaded = (0, import_node_readline.createInterface)({
|
|
3048
3048
|
input: stream
|
|
3049
3049
|
});
|
|
@@ -3058,7 +3058,7 @@ function getContextLinesFromFile(path61, ranges, output) {
|
|
|
3058
3058
|
let rangeStart = range[0];
|
|
3059
3059
|
let rangeEnd = range[1];
|
|
3060
3060
|
function onStreamError() {
|
|
3061
|
-
LRU_FILE_CONTENTS_FS_READ_FAILED.set(
|
|
3061
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(path62, 1);
|
|
3062
3062
|
lineReaded.close();
|
|
3063
3063
|
lineReaded.removeAllListeners();
|
|
3064
3064
|
destroyStreamAndResolve();
|
|
@@ -3119,8 +3119,8 @@ function clearLineContext(frame) {
|
|
|
3119
3119
|
delete frame.context_line;
|
|
3120
3120
|
delete frame.post_context;
|
|
3121
3121
|
}
|
|
3122
|
-
function shouldSkipContextLinesForFile(
|
|
3123
|
-
return
|
|
3122
|
+
function shouldSkipContextLinesForFile(path62) {
|
|
3123
|
+
return path62.startsWith("node:") || path62.endsWith(".min.js") || path62.endsWith(".min.cjs") || path62.endsWith(".min.mjs") || path62.startsWith("data:");
|
|
3124
3124
|
}
|
|
3125
3125
|
function shouldSkipContextLinesForFrame(frame) {
|
|
3126
3126
|
if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
|
|
@@ -5397,7 +5397,7 @@ function readAnonId() {
|
|
|
5397
5397
|
}
|
|
5398
5398
|
function superProperties() {
|
|
5399
5399
|
return {
|
|
5400
|
-
cliVersion: true ? "2.51.
|
|
5400
|
+
cliVersion: true ? "2.51.2" : "0.0.0-dev",
|
|
5401
5401
|
nodeVersion: process.version,
|
|
5402
5402
|
platform: process.platform,
|
|
5403
5403
|
arch: process.arch,
|
|
@@ -5578,7 +5578,7 @@ var os4 = __toESM(require("os"));
|
|
|
5578
5578
|
// package.json
|
|
5579
5579
|
var package_default = {
|
|
5580
5580
|
name: "codeam-cli",
|
|
5581
|
-
version: "2.51.
|
|
5581
|
+
version: "2.51.2",
|
|
5582
5582
|
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.",
|
|
5583
5583
|
type: "commonjs",
|
|
5584
5584
|
main: "dist/index.js",
|
|
@@ -6610,10 +6610,10 @@ var WINDOWS_LEGACY_JUNCTIONS = [
|
|
|
6610
6610
|
/[\\/]Start Menu([\\/]|$)/i,
|
|
6611
6611
|
/[\\/]Templates([\\/]|$)/i
|
|
6612
6612
|
];
|
|
6613
|
-
function isUnsafeWindowsWatchRoot(dir,
|
|
6613
|
+
function isUnsafeWindowsWatchRoot(dir, homedir34) {
|
|
6614
6614
|
const norm = (p2) => p2.replace(/\//g, "\\").replace(/\\+$/, "").toLowerCase();
|
|
6615
6615
|
const cwd = norm(dir);
|
|
6616
|
-
const home = norm(
|
|
6616
|
+
const home = norm(homedir34);
|
|
6617
6617
|
if (cwd === home) return true;
|
|
6618
6618
|
if (/^[a-z]:$/.test(cwd)) return true;
|
|
6619
6619
|
const sysRoots = [
|
|
@@ -7728,11 +7728,11 @@ function closeAllTerminals() {
|
|
|
7728
7728
|
}
|
|
7729
7729
|
|
|
7730
7730
|
// src/commands/start/handlers.ts
|
|
7731
|
-
var
|
|
7732
|
-
var
|
|
7733
|
-
var
|
|
7731
|
+
var fs43 = __toESM(require("fs"));
|
|
7732
|
+
var os36 = __toESM(require("os"));
|
|
7733
|
+
var path48 = __toESM(require("path"));
|
|
7734
7734
|
var import_crypto3 = require("crypto");
|
|
7735
|
-
var
|
|
7735
|
+
var import_child_process21 = require("child_process");
|
|
7736
7736
|
var import_which2 = __toESM(require("which"));
|
|
7737
7737
|
|
|
7738
7738
|
// src/lib/payload.ts
|
|
@@ -11164,10 +11164,10 @@ function buildForPlatform(platform3) {
|
|
|
11164
11164
|
var import_node_crypto4 = require("crypto");
|
|
11165
11165
|
|
|
11166
11166
|
// src/agents/claude/resolver.ts
|
|
11167
|
-
function buildClaudeLaunch(extraArgs = [],
|
|
11168
|
-
const found =
|
|
11167
|
+
function buildClaudeLaunch(extraArgs = [], os43 = createOsStrategy()) {
|
|
11168
|
+
const found = os43.findInPath("claude") ?? os43.findInPath("claude-code");
|
|
11169
11169
|
if (!found) return null;
|
|
11170
|
-
return
|
|
11170
|
+
return os43.buildLaunch(found, extraArgs);
|
|
11171
11171
|
}
|
|
11172
11172
|
|
|
11173
11173
|
// src/agents/claude/installer.ts
|
|
@@ -11760,8 +11760,8 @@ var ClaudeRuntimeStrategy = class {
|
|
|
11760
11760
|
meta = getAgent("claude");
|
|
11761
11761
|
mode = "interactive";
|
|
11762
11762
|
os;
|
|
11763
|
-
constructor(
|
|
11764
|
-
this.os =
|
|
11763
|
+
constructor(os43) {
|
|
11764
|
+
this.os = os43;
|
|
11765
11765
|
}
|
|
11766
11766
|
/**
|
|
11767
11767
|
* Claude Code's react-ink TUI enables bracketed-paste mode at
|
|
@@ -12438,8 +12438,8 @@ function codexCredentialLocator() {
|
|
|
12438
12438
|
function codexLoginLauncher() {
|
|
12439
12439
|
return {
|
|
12440
12440
|
async ensureInstalled() {
|
|
12441
|
-
const
|
|
12442
|
-
return
|
|
12441
|
+
const os43 = createOsStrategy();
|
|
12442
|
+
return os43.findInPath("codex") !== null;
|
|
12443
12443
|
},
|
|
12444
12444
|
launch() {
|
|
12445
12445
|
return (0, import_node_child_process3.spawn)("codex", ["login"], { stdio: "inherit" });
|
|
@@ -12462,8 +12462,8 @@ var CodexRuntimeStrategy = class {
|
|
|
12462
12462
|
meta = getAgent("codex");
|
|
12463
12463
|
mode = "interactive";
|
|
12464
12464
|
os;
|
|
12465
|
-
constructor(
|
|
12466
|
-
this.os =
|
|
12465
|
+
constructor(os43) {
|
|
12466
|
+
this.os = os43;
|
|
12467
12467
|
}
|
|
12468
12468
|
async prepareLaunch() {
|
|
12469
12469
|
let binary = this.os.findInPath("codex");
|
|
@@ -12562,12 +12562,12 @@ var CodexRuntimeStrategy = class {
|
|
|
12562
12562
|
});
|
|
12563
12563
|
}
|
|
12564
12564
|
};
|
|
12565
|
-
function resolveNpm(
|
|
12566
|
-
return
|
|
12565
|
+
function resolveNpm(os43) {
|
|
12566
|
+
return os43.id === "win32" ? "npm.cmd" : "npm";
|
|
12567
12567
|
}
|
|
12568
|
-
async function installCodexViaNpm(
|
|
12568
|
+
async function installCodexViaNpm(os43) {
|
|
12569
12569
|
return new Promise((resolve7, reject) => {
|
|
12570
|
-
const proc = (0, import_node_child_process4.spawn)(resolveNpm(
|
|
12570
|
+
const proc = (0, import_node_child_process4.spawn)(resolveNpm(os43), ["install", "-g", "@openai/codex"], {
|
|
12571
12571
|
stdio: "inherit"
|
|
12572
12572
|
});
|
|
12573
12573
|
proc.on("close", (code) => {
|
|
@@ -12584,16 +12584,16 @@ async function installCodexViaNpm(os41) {
|
|
|
12584
12584
|
});
|
|
12585
12585
|
});
|
|
12586
12586
|
}
|
|
12587
|
-
function augmentNpmGlobalBin(
|
|
12587
|
+
function augmentNpmGlobalBin(os43) {
|
|
12588
12588
|
try {
|
|
12589
|
-
const result = (0, import_node_child_process4.spawnSync)(resolveNpm(
|
|
12589
|
+
const result = (0, import_node_child_process4.spawnSync)(resolveNpm(os43), ["prefix", "-g"], {
|
|
12590
12590
|
stdio: ["ignore", "pipe", "ignore"]
|
|
12591
12591
|
});
|
|
12592
12592
|
if (result.status !== 0) return;
|
|
12593
12593
|
const prefix = result.stdout.toString().trim();
|
|
12594
12594
|
if (!prefix) return;
|
|
12595
|
-
const binDir =
|
|
12596
|
-
|
|
12595
|
+
const binDir = os43.id === "win32" ? prefix : path22.join(prefix, "bin");
|
|
12596
|
+
os43.augmentPath([binDir]);
|
|
12597
12597
|
} catch {
|
|
12598
12598
|
}
|
|
12599
12599
|
}
|
|
@@ -12677,9 +12677,9 @@ var import_node_child_process7 = require("child_process");
|
|
|
12677
12677
|
// src/agents/coderabbit/installer.ts
|
|
12678
12678
|
var import_node_child_process5 = require("child_process");
|
|
12679
12679
|
var INSTALL_URL = "https://cli.coderabbit.ai/install.sh";
|
|
12680
|
-
async function ensureCoderabbitInstalled(
|
|
12681
|
-
if (
|
|
12682
|
-
if (
|
|
12680
|
+
async function ensureCoderabbitInstalled(os43) {
|
|
12681
|
+
if (os43.findInPath("coderabbit")) return true;
|
|
12682
|
+
if (os43.id === "win32") {
|
|
12683
12683
|
console.error(
|
|
12684
12684
|
"\n \u2717 CodeRabbit on Windows requires WSL.\n Install the CLI inside your WSL distribution\n (curl -fsSL https://cli.coderabbit.ai/install.sh | sh)\n then re-run `codeam link coderabbit` from WSL.\n"
|
|
12685
12685
|
);
|
|
@@ -12694,8 +12694,8 @@ async function ensureCoderabbitInstalled(os41) {
|
|
|
12694
12694
|
proc.on("error", () => resolve7(false));
|
|
12695
12695
|
});
|
|
12696
12696
|
if (!ok) return false;
|
|
12697
|
-
|
|
12698
|
-
return
|
|
12697
|
+
os43.augmentPath([`${os43.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
|
|
12698
|
+
return os43.findInPath("coderabbit") !== null;
|
|
12699
12699
|
}
|
|
12700
12700
|
|
|
12701
12701
|
// src/agents/coderabbit/link.ts
|
|
@@ -12730,10 +12730,10 @@ function coderabbitCredentialLocator() {
|
|
|
12730
12730
|
validate: validateNonEmptyCredential
|
|
12731
12731
|
};
|
|
12732
12732
|
}
|
|
12733
|
-
function coderabbitLoginLauncher(
|
|
12733
|
+
function coderabbitLoginLauncher(os43) {
|
|
12734
12734
|
return {
|
|
12735
12735
|
async ensureInstalled() {
|
|
12736
|
-
return ensureCoderabbitInstalled(
|
|
12736
|
+
return ensureCoderabbitInstalled(os43);
|
|
12737
12737
|
},
|
|
12738
12738
|
launch() {
|
|
12739
12739
|
return (0, import_node_child_process6.spawn)("coderabbit", ["login"], { stdio: "inherit" });
|
|
@@ -12756,11 +12756,11 @@ function parseReview(stdout) {
|
|
|
12756
12756
|
for (const line of lines) {
|
|
12757
12757
|
const m = line.match(HUNK_LINE_RE);
|
|
12758
12758
|
if (!m) continue;
|
|
12759
|
-
const [,
|
|
12760
|
-
if (!
|
|
12759
|
+
const [, path62, lineNo, sevToken, message] = m;
|
|
12760
|
+
if (!path62 || !lineNo || !message) continue;
|
|
12761
12761
|
const cleanedMessage = message.trim().replace(/^[*-]\s+/, "");
|
|
12762
12762
|
hunks.push({
|
|
12763
|
-
path:
|
|
12763
|
+
path: path62.trim(),
|
|
12764
12764
|
line: Number(lineNo),
|
|
12765
12765
|
severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
|
|
12766
12766
|
message: cleanedMessage
|
|
@@ -12779,8 +12779,8 @@ var CoderabbitRuntimeStrategy = class {
|
|
|
12779
12779
|
meta = getAgent("coderabbit");
|
|
12780
12780
|
mode = "batch";
|
|
12781
12781
|
os;
|
|
12782
|
-
constructor(
|
|
12783
|
-
this.os =
|
|
12782
|
+
constructor(os43) {
|
|
12783
|
+
this.os = os43;
|
|
12784
12784
|
}
|
|
12785
12785
|
getDefaultArgs() {
|
|
12786
12786
|
return ["review"];
|
|
@@ -12896,10 +12896,10 @@ function cursorCredentialLocator() {
|
|
|
12896
12896
|
validate: validateNonEmptyCredential
|
|
12897
12897
|
};
|
|
12898
12898
|
}
|
|
12899
|
-
function cursorLoginLauncher(
|
|
12899
|
+
function cursorLoginLauncher(os43) {
|
|
12900
12900
|
return {
|
|
12901
12901
|
async ensureInstalled() {
|
|
12902
|
-
if (
|
|
12902
|
+
if (os43.findInPath("cursor-agent")) return true;
|
|
12903
12903
|
console.error(
|
|
12904
12904
|
"\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"
|
|
12905
12905
|
);
|
|
@@ -12961,8 +12961,8 @@ var CursorRuntimeStrategy = class {
|
|
|
12961
12961
|
meta = getAgent("cursor");
|
|
12962
12962
|
mode = "interactive";
|
|
12963
12963
|
os;
|
|
12964
|
-
constructor(
|
|
12965
|
-
this.os =
|
|
12964
|
+
constructor(os43) {
|
|
12965
|
+
this.os = os43;
|
|
12966
12966
|
}
|
|
12967
12967
|
async prepareLaunch() {
|
|
12968
12968
|
const binary = this.os.findInPath("cursor-agent");
|
|
@@ -13101,10 +13101,10 @@ function aiderCredentialLocator() {
|
|
|
13101
13101
|
validate: validateNonEmptyCredential
|
|
13102
13102
|
};
|
|
13103
13103
|
}
|
|
13104
|
-
function aiderLoginLauncher(
|
|
13104
|
+
function aiderLoginLauncher(os43) {
|
|
13105
13105
|
return {
|
|
13106
13106
|
async ensureInstalled() {
|
|
13107
|
-
if (
|
|
13107
|
+
if (os43.findInPath("aider")) return true;
|
|
13108
13108
|
console.error(
|
|
13109
13109
|
"\n \u2717 aider binary not on PATH.\n Install Aider:\n pip install aider-chat\n then re-run `codeam link aider`.\n"
|
|
13110
13110
|
);
|
|
@@ -13114,7 +13114,7 @@ function aiderLoginLauncher(os41) {
|
|
|
13114
13114
|
console.error(
|
|
13115
13115
|
"\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"
|
|
13116
13116
|
);
|
|
13117
|
-
return (0, import_node_child_process9.spawn)(
|
|
13117
|
+
return (0, import_node_child_process9.spawn)(os43.id === "win32" ? "cmd.exe" : "sh", os43.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
|
|
13118
13118
|
stdio: "ignore"
|
|
13119
13119
|
});
|
|
13120
13120
|
}
|
|
@@ -13186,8 +13186,8 @@ var AiderRuntimeStrategy = class {
|
|
|
13186
13186
|
meta = getAgent("aider");
|
|
13187
13187
|
mode = "interactive";
|
|
13188
13188
|
os;
|
|
13189
|
-
constructor(
|
|
13190
|
-
this.os =
|
|
13189
|
+
constructor(os43) {
|
|
13190
|
+
this.os = os43;
|
|
13191
13191
|
}
|
|
13192
13192
|
async prepareLaunch() {
|
|
13193
13193
|
const binary = this.os.findInPath("aider");
|
|
@@ -13316,8 +13316,8 @@ function geminiCredentialLocator() {
|
|
|
13316
13316
|
function geminiLoginLauncher() {
|
|
13317
13317
|
return {
|
|
13318
13318
|
async ensureInstalled() {
|
|
13319
|
-
const
|
|
13320
|
-
return
|
|
13319
|
+
const os43 = createOsStrategy();
|
|
13320
|
+
return os43.findInPath("gemini") !== null;
|
|
13321
13321
|
},
|
|
13322
13322
|
launch() {
|
|
13323
13323
|
return (0, import_node_child_process10.spawn)("gemini", ["auth", "login"], { stdio: "inherit" });
|
|
@@ -13350,8 +13350,8 @@ var GeminiRuntimeStrategy = class {
|
|
|
13350
13350
|
meta = getAgent("gemini");
|
|
13351
13351
|
mode = "interactive";
|
|
13352
13352
|
os;
|
|
13353
|
-
constructor(
|
|
13354
|
-
this.os =
|
|
13353
|
+
constructor(os43) {
|
|
13354
|
+
this.os = os43;
|
|
13355
13355
|
}
|
|
13356
13356
|
async prepareLaunch() {
|
|
13357
13357
|
const binary = this.os.findInPath("gemini");
|
|
@@ -13450,18 +13450,18 @@ var GeminiRuntimeStrategy = class {
|
|
|
13450
13450
|
|
|
13451
13451
|
// src/agents/registry.ts
|
|
13452
13452
|
var runtimeBuilders = {
|
|
13453
|
-
claude: (
|
|
13454
|
-
codex: (
|
|
13455
|
-
coderabbit: (
|
|
13456
|
-
cursor: (
|
|
13457
|
-
aider: (
|
|
13458
|
-
gemini: (
|
|
13453
|
+
claude: (os43) => new ClaudeRuntimeStrategy(os43),
|
|
13454
|
+
codex: (os43) => new CodexRuntimeStrategy(os43),
|
|
13455
|
+
coderabbit: (os43) => new CoderabbitRuntimeStrategy(os43),
|
|
13456
|
+
cursor: (os43) => new CursorRuntimeStrategy(os43),
|
|
13457
|
+
aider: (os43) => new AiderRuntimeStrategy(os43),
|
|
13458
|
+
gemini: (os43) => new GeminiRuntimeStrategy(os43)
|
|
13459
13459
|
};
|
|
13460
13460
|
var deployBuilders = {
|
|
13461
13461
|
claude: () => new ClaudeDeployStrategy(),
|
|
13462
13462
|
codex: () => new CodexDeployStrategy()
|
|
13463
13463
|
};
|
|
13464
|
-
function createAgentStrategy(agent,
|
|
13464
|
+
function createAgentStrategy(agent, os43 = createOsStrategy()) {
|
|
13465
13465
|
if (!AGENT_REGISTRY[agent]?.enabled) {
|
|
13466
13466
|
throw new Error(
|
|
13467
13467
|
`Agent "${agent}" is not supported in this codeam-cli version. Upgrade with 'npm i -g codeam-cli@latest'.`
|
|
@@ -13471,10 +13471,10 @@ function createAgentStrategy(agent, os41 = createOsStrategy()) {
|
|
|
13471
13471
|
if (!build) {
|
|
13472
13472
|
throw new Error(`No runtime strategy registered for agent "${agent}"`);
|
|
13473
13473
|
}
|
|
13474
|
-
return build(
|
|
13474
|
+
return build(os43);
|
|
13475
13475
|
}
|
|
13476
|
-
function createInteractiveAgentStrategy(agent,
|
|
13477
|
-
const s = createAgentStrategy(agent,
|
|
13476
|
+
function createInteractiveAgentStrategy(agent, os43 = createOsStrategy()) {
|
|
13477
|
+
const s = createAgentStrategy(agent, os43);
|
|
13478
13478
|
if (s.mode !== "interactive") {
|
|
13479
13479
|
throw new Error(
|
|
13480
13480
|
`Agent "${agent}" is a batch agent; use createAgentStrategy + .runOneShot for one-shot reviews.`
|
|
@@ -13877,19 +13877,39 @@ async function linkDryRunPreflight(ctx) {
|
|
|
13877
13877
|
}
|
|
13878
13878
|
|
|
13879
13879
|
// src/commands/host-agent.ts
|
|
13880
|
-
var
|
|
13881
|
-
var
|
|
13882
|
-
var
|
|
13880
|
+
var import_node_child_process15 = require("child_process");
|
|
13881
|
+
var os29 = __toESM(require("os"));
|
|
13882
|
+
var fs32 = __toESM(require("fs"));
|
|
13883
13883
|
var path36 = __toESM(require("path"));
|
|
13884
13884
|
|
|
13885
|
+
// src/util/restrict-to-owner.ts
|
|
13886
|
+
var import_node_fs5 = __toESM(require("fs"));
|
|
13887
|
+
var import_node_os3 = __toESM(require("os"));
|
|
13888
|
+
var import_node_child_process11 = require("child_process");
|
|
13889
|
+
function restrictToOwner(filePath) {
|
|
13890
|
+
try {
|
|
13891
|
+
if (process.platform === "win32") {
|
|
13892
|
+
const username = import_node_os3.default.userInfo().username;
|
|
13893
|
+
(0, import_node_child_process11.execFileSync)(
|
|
13894
|
+
"icacls",
|
|
13895
|
+
[filePath, "/inheritance:r", "/grant:r", `${username}:F`],
|
|
13896
|
+
{ stdio: "ignore" }
|
|
13897
|
+
);
|
|
13898
|
+
} else {
|
|
13899
|
+
import_node_fs5.default.chmodSync(filePath, 384);
|
|
13900
|
+
}
|
|
13901
|
+
} catch {
|
|
13902
|
+
}
|
|
13903
|
+
}
|
|
13904
|
+
|
|
13885
13905
|
// src/commands/host/host-client.ts
|
|
13886
|
-
var
|
|
13887
|
-
var
|
|
13906
|
+
var fs27 = __toESM(require("fs"));
|
|
13907
|
+
var os24 = __toESM(require("os"));
|
|
13888
13908
|
var path31 = __toESM(require("path"));
|
|
13889
13909
|
function sampleCpuTimes() {
|
|
13890
13910
|
let idle = 0;
|
|
13891
13911
|
let total = 0;
|
|
13892
|
-
for (const cpu of
|
|
13912
|
+
for (const cpu of os24.cpus()) {
|
|
13893
13913
|
const t2 = cpu.times;
|
|
13894
13914
|
idle += t2.idle;
|
|
13895
13915
|
total += t2.user + t2.nice + t2.sys + t2.idle + t2.irq;
|
|
@@ -13908,8 +13928,8 @@ var MetricsCollector = class {
|
|
|
13908
13928
|
const prev = this.prevCpu;
|
|
13909
13929
|
this.prevCpu = current;
|
|
13910
13930
|
if (!prev) {
|
|
13911
|
-
const cores =
|
|
13912
|
-
const proxy =
|
|
13931
|
+
const cores = os24.cpus().length || 1;
|
|
13932
|
+
const proxy = os24.loadavg()[0] / cores * 100;
|
|
13913
13933
|
return Math.min(100, Math.max(0, Math.round(proxy)));
|
|
13914
13934
|
}
|
|
13915
13935
|
const idleDelta = current.idle - prev.idle;
|
|
@@ -13922,8 +13942,8 @@ var MetricsCollector = class {
|
|
|
13922
13942
|
collect() {
|
|
13923
13943
|
return {
|
|
13924
13944
|
cpuPct: this.cpuPct(),
|
|
13925
|
-
ramUsedMb: Math.round((
|
|
13926
|
-
ramTotalMb: Math.round(
|
|
13945
|
+
ramUsedMb: Math.round((os24.totalmem() - os24.freemem()) / 1048576),
|
|
13946
|
+
ramTotalMb: Math.round(os24.totalmem() / 1048576),
|
|
13927
13947
|
latencyMs: this.lastLatencyMs
|
|
13928
13948
|
};
|
|
13929
13949
|
}
|
|
@@ -13932,19 +13952,19 @@ function apiBase() {
|
|
|
13932
13952
|
return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
|
|
13933
13953
|
}
|
|
13934
13954
|
function hostIdentityPath() {
|
|
13935
|
-
return path31.join(
|
|
13955
|
+
return path31.join(os24.homedir(), ".codeam", "host-agent.json");
|
|
13936
13956
|
}
|
|
13937
13957
|
function collectOsInfo() {
|
|
13938
13958
|
return {
|
|
13939
|
-
distro:
|
|
13940
|
-
arch:
|
|
13941
|
-
kernel:
|
|
13959
|
+
distro: os24.platform(),
|
|
13960
|
+
arch: os24.arch(),
|
|
13961
|
+
kernel: os24.release(),
|
|
13942
13962
|
nodeVersion: process.versions.node
|
|
13943
13963
|
};
|
|
13944
13964
|
}
|
|
13945
13965
|
function loadHostIdentity() {
|
|
13946
13966
|
try {
|
|
13947
|
-
const raw =
|
|
13967
|
+
const raw = fs27.readFileSync(hostIdentityPath(), "utf8");
|
|
13948
13968
|
const parsed = JSON.parse(raw);
|
|
13949
13969
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
|
|
13950
13970
|
const p2 = parsed;
|
|
@@ -13957,12 +13977,12 @@ function loadHostIdentity() {
|
|
|
13957
13977
|
}
|
|
13958
13978
|
function saveHostIdentity(identity) {
|
|
13959
13979
|
const file = hostIdentityPath();
|
|
13960
|
-
|
|
13961
|
-
|
|
13980
|
+
fs27.mkdirSync(path31.dirname(file), { recursive: true, mode: 448 });
|
|
13981
|
+
fs27.writeFileSync(file, JSON.stringify(identity, null, 2), {
|
|
13962
13982
|
encoding: "utf8",
|
|
13963
13983
|
mode: 384
|
|
13964
13984
|
});
|
|
13965
|
-
|
|
13985
|
+
fs27.chmodSync(file, 384);
|
|
13966
13986
|
}
|
|
13967
13987
|
var HostHttpError = class extends Error {
|
|
13968
13988
|
constructor(message, status2) {
|
|
@@ -13985,7 +14005,7 @@ function isHostAuthRejection(err) {
|
|
|
13985
14005
|
}
|
|
13986
14006
|
function deleteHostIdentity() {
|
|
13987
14007
|
try {
|
|
13988
|
-
|
|
14008
|
+
fs27.rmSync(hostIdentityPath(), { force: true });
|
|
13989
14009
|
} catch {
|
|
13990
14010
|
}
|
|
13991
14011
|
}
|
|
@@ -14107,17 +14127,17 @@ async function reportDeployProgress(auth, deployId, step, message, sessionId) {
|
|
|
14107
14127
|
}
|
|
14108
14128
|
|
|
14109
14129
|
// src/commands/host/workspace.ts
|
|
14110
|
-
var
|
|
14111
|
-
var
|
|
14130
|
+
var fs28 = __toESM(require("fs"));
|
|
14131
|
+
var os25 = __toESM(require("os"));
|
|
14112
14132
|
var path32 = __toESM(require("path"));
|
|
14113
|
-
var
|
|
14133
|
+
var import_node_child_process12 = require("child_process");
|
|
14114
14134
|
var import_node_util4 = require("util");
|
|
14115
|
-
var execFileP4 = (0, import_node_util4.promisify)(
|
|
14135
|
+
var execFileP4 = (0, import_node_util4.promisify)(import_node_child_process12.execFile);
|
|
14116
14136
|
function isAbsolutePathTarget(target) {
|
|
14117
14137
|
return path32.isAbsolute(target);
|
|
14118
14138
|
}
|
|
14119
14139
|
function selfHostedWorkspaceRoot() {
|
|
14120
|
-
return path32.join(
|
|
14140
|
+
return path32.join(os25.homedir(), ".codeam", "self-hosted");
|
|
14121
14141
|
}
|
|
14122
14142
|
function nonInteractiveGitEnv() {
|
|
14123
14143
|
return {
|
|
@@ -14171,12 +14191,9 @@ async function configureGitCredentials(dest, repoRef, cloneToken) {
|
|
|
14171
14191
|
const gh = githubOwnerRepo(repoRef.trim());
|
|
14172
14192
|
if (!gh || !cloneToken) return;
|
|
14173
14193
|
const credFile = path32.join(dest, ".git", "codeam-credentials");
|
|
14174
|
-
|
|
14194
|
+
fs28.writeFileSync(credFile, `https://x-access-token:${cloneToken}@github.com
|
|
14175
14195
|
`, { mode: 384 });
|
|
14176
|
-
|
|
14177
|
-
fs27.chmodSync(credFile, 384);
|
|
14178
|
-
} catch {
|
|
14179
|
-
}
|
|
14196
|
+
restrictToOwner(credFile);
|
|
14180
14197
|
const env = nonInteractiveGitEnv();
|
|
14181
14198
|
const git2 = (args2) => execFileP4("git", ["-C", dest, ...args2], { timeout: 3e4, env });
|
|
14182
14199
|
const credFilePosix = credFile.split(path32.sep).join("/");
|
|
@@ -14215,17 +14232,17 @@ function maskToken(text, cloneToken) {
|
|
|
14215
14232
|
}
|
|
14216
14233
|
async function prepareWorkspace(repoOrPath, deployId, cloneToken) {
|
|
14217
14234
|
if (isAbsolutePathTarget(repoOrPath)) {
|
|
14218
|
-
if (!
|
|
14235
|
+
if (!fs28.existsSync(repoOrPath)) {
|
|
14219
14236
|
throw new Error(`deploy target path does not exist: ${repoOrPath}`);
|
|
14220
14237
|
}
|
|
14221
14238
|
return repoOrPath;
|
|
14222
14239
|
}
|
|
14223
14240
|
const dest = path32.join(selfHostedWorkspaceRoot(), deployId);
|
|
14224
|
-
if (
|
|
14241
|
+
if (fs28.existsSync(path32.join(dest, ".git"))) {
|
|
14225
14242
|
if (cloneToken) await configureGitCredentials(dest, repoOrPath, cloneToken);
|
|
14226
14243
|
return dest;
|
|
14227
14244
|
}
|
|
14228
|
-
|
|
14245
|
+
fs28.mkdirSync(selfHostedWorkspaceRoot(), { recursive: true, mode: 448 });
|
|
14229
14246
|
const cloneUrl = repoCloneUrl(repoOrPath, cloneToken);
|
|
14230
14247
|
try {
|
|
14231
14248
|
await execFileP4("git", ["clone", "--depth", "1", cloneUrl, dest], {
|
|
@@ -14242,8 +14259,8 @@ async function prepareWorkspace(repoOrPath, deployId, cloneToken) {
|
|
|
14242
14259
|
}
|
|
14243
14260
|
|
|
14244
14261
|
// src/commands/host/agent-provisioning.ts
|
|
14245
|
-
var
|
|
14246
|
-
var
|
|
14262
|
+
var fs29 = __toESM(require("fs"));
|
|
14263
|
+
var os26 = __toESM(require("os"));
|
|
14247
14264
|
var path33 = __toESM(require("path"));
|
|
14248
14265
|
var PUBLIC_TO_INTERNAL_AGENT = {
|
|
14249
14266
|
claude_code: "claude",
|
|
@@ -14259,16 +14276,16 @@ function toInternalAgentId(publicAgentId) {
|
|
|
14259
14276
|
return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
|
|
14260
14277
|
}
|
|
14261
14278
|
function ensureDir(dir) {
|
|
14262
|
-
|
|
14279
|
+
fs29.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
14263
14280
|
}
|
|
14264
14281
|
function writeFile0600(filePath, contents) {
|
|
14265
14282
|
ensureDir(path33.dirname(filePath));
|
|
14266
|
-
|
|
14267
|
-
|
|
14283
|
+
fs29.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
|
|
14284
|
+
restrictToOwner(filePath);
|
|
14268
14285
|
}
|
|
14269
14286
|
function rmIfExists(filePath) {
|
|
14270
14287
|
try {
|
|
14271
|
-
|
|
14288
|
+
fs29.rmSync(filePath, { force: true });
|
|
14272
14289
|
} catch {
|
|
14273
14290
|
}
|
|
14274
14291
|
}
|
|
@@ -14287,7 +14304,7 @@ var claudeProvisioner = {
|
|
|
14287
14304
|
rmIfExists(credentialsJson);
|
|
14288
14305
|
}
|
|
14289
14306
|
const claudeJson = path33.join(home, ".claude.json");
|
|
14290
|
-
if (!
|
|
14307
|
+
if (!fs29.existsSync(claudeJson)) {
|
|
14291
14308
|
writeFile0600(
|
|
14292
14309
|
claudeJson,
|
|
14293
14310
|
JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
|
|
@@ -14360,7 +14377,7 @@ var UnsupportedAgentError = class extends Error {
|
|
|
14360
14377
|
this.agentId = agentId;
|
|
14361
14378
|
}
|
|
14362
14379
|
};
|
|
14363
|
-
function provisionAgentCredentials(publicAgentId, auth, homeDir2 =
|
|
14380
|
+
function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os26.homedir()) {
|
|
14364
14381
|
const internal = toInternalAgentId(publicAgentId);
|
|
14365
14382
|
if (!internal) throw new UnsupportedAgentError(publicAgentId);
|
|
14366
14383
|
const provisioner = PROVISIONERS[internal];
|
|
@@ -14369,12 +14386,12 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os25.homedir(
|
|
|
14369
14386
|
}
|
|
14370
14387
|
|
|
14371
14388
|
// src/commands/host/git-tooling.ts
|
|
14372
|
-
var
|
|
14373
|
-
var
|
|
14374
|
-
var
|
|
14389
|
+
var import_node_child_process13 = require("child_process");
|
|
14390
|
+
var fs30 = __toESM(require("fs"));
|
|
14391
|
+
var os27 = __toESM(require("os"));
|
|
14375
14392
|
var path34 = __toESM(require("path"));
|
|
14376
14393
|
function codeamBinDir() {
|
|
14377
|
-
return process.env.CODEAM_BIN_DIR ?? path34.join(
|
|
14394
|
+
return process.env.CODEAM_BIN_DIR ?? path34.join(os27.homedir(), ".codeam", "bin");
|
|
14378
14395
|
}
|
|
14379
14396
|
var FALLBACK_GH_VERSION = "2.62.0";
|
|
14380
14397
|
var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
|
|
@@ -14406,7 +14423,7 @@ async function download(url, dest) {
|
|
|
14406
14423
|
const res = await fetch(url, { headers: { "User-Agent": "codeam-cli" } });
|
|
14407
14424
|
if (!res.ok || !res.body) return false;
|
|
14408
14425
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
14409
|
-
|
|
14426
|
+
fs30.writeFileSync(dest, buf);
|
|
14410
14427
|
return true;
|
|
14411
14428
|
} catch {
|
|
14412
14429
|
return false;
|
|
@@ -14429,7 +14446,7 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
14429
14446
|
const version3 = await resolveVersionFn(token);
|
|
14430
14447
|
const asset = `gh_${version3}_${osToken}_${arch2}`;
|
|
14431
14448
|
const url = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
|
|
14432
|
-
const tmpRoot =
|
|
14449
|
+
const tmpRoot = fs30.mkdtempSync(path34.join(os27.tmpdir(), "codeam-gh-"));
|
|
14433
14450
|
const archive = path34.join(tmpRoot, `${asset}.${ext}`);
|
|
14434
14451
|
if (!await downloadFn(url, archive)) {
|
|
14435
14452
|
log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
|
|
@@ -14441,15 +14458,15 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
14441
14458
|
return null;
|
|
14442
14459
|
}
|
|
14443
14460
|
const extractedBin = path34.join(tmpRoot, asset, "bin", binaryName);
|
|
14444
|
-
if (!
|
|
14461
|
+
if (!fs30.existsSync(extractedBin)) {
|
|
14445
14462
|
log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
|
|
14446
14463
|
return null;
|
|
14447
14464
|
}
|
|
14448
14465
|
const binDir = codeamBinDir();
|
|
14449
|
-
|
|
14466
|
+
fs30.mkdirSync(binDir, { recursive: true });
|
|
14450
14467
|
const target = path34.join(binDir, binaryName);
|
|
14451
|
-
|
|
14452
|
-
|
|
14468
|
+
fs30.copyFileSync(extractedBin, target);
|
|
14469
|
+
fs30.chmodSync(target, 493);
|
|
14453
14470
|
log.info("host-agent", `gh installed to ${target} (v${version3})`);
|
|
14454
14471
|
return target;
|
|
14455
14472
|
} catch (e) {
|
|
@@ -14483,7 +14500,7 @@ var defaultGitToolingRunner = {
|
|
|
14483
14500
|
which(cmd) {
|
|
14484
14501
|
try {
|
|
14485
14502
|
const probe = process.platform === "win32" ? "where" : "which";
|
|
14486
|
-
(0,
|
|
14503
|
+
(0, import_node_child_process13.execFileSync)(probe, [cmd], { stdio: "ignore" });
|
|
14487
14504
|
return true;
|
|
14488
14505
|
} catch {
|
|
14489
14506
|
return false;
|
|
@@ -14491,7 +14508,7 @@ var defaultGitToolingRunner = {
|
|
|
14491
14508
|
},
|
|
14492
14509
|
run(cmd, args2, opts = {}) {
|
|
14493
14510
|
return new Promise((resolve7) => {
|
|
14494
|
-
const child = (0,
|
|
14511
|
+
const child = (0, import_node_child_process13.spawn)(cmd, args2, {
|
|
14495
14512
|
stdio: [opts.input !== void 0 ? "pipe" : "ignore", "ignore", "pipe"]
|
|
14496
14513
|
});
|
|
14497
14514
|
let stderr = "";
|
|
@@ -14636,23 +14653,23 @@ function buildBudgetProxyArgs(env) {
|
|
|
14636
14653
|
}
|
|
14637
14654
|
|
|
14638
14655
|
// src/lib/updateNotifier.ts
|
|
14639
|
-
var
|
|
14640
|
-
var
|
|
14656
|
+
var fs31 = __toESM(require("fs"));
|
|
14657
|
+
var os28 = __toESM(require("os"));
|
|
14641
14658
|
var path35 = __toESM(require("path"));
|
|
14642
14659
|
var https6 = __toESM(require("https"));
|
|
14643
|
-
var
|
|
14660
|
+
var import_node_child_process14 = require("child_process");
|
|
14644
14661
|
var import_picocolors3 = __toESM(require("picocolors"));
|
|
14645
14662
|
var PKG_NAME = "codeam-cli";
|
|
14646
14663
|
var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
|
|
14647
14664
|
var TTL_MS = 24 * 60 * 60 * 1e3;
|
|
14648
14665
|
var REQUEST_TIMEOUT_MS = 1500;
|
|
14649
14666
|
function cachePath() {
|
|
14650
|
-
const dir = path35.join(
|
|
14667
|
+
const dir = path35.join(os28.homedir(), ".codeam");
|
|
14651
14668
|
return path35.join(dir, "update-check.json");
|
|
14652
14669
|
}
|
|
14653
14670
|
function readCache() {
|
|
14654
14671
|
try {
|
|
14655
|
-
const raw =
|
|
14672
|
+
const raw = fs31.readFileSync(cachePath(), "utf8");
|
|
14656
14673
|
const parsed = JSON.parse(raw);
|
|
14657
14674
|
if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
|
|
14658
14675
|
return parsed;
|
|
@@ -14663,10 +14680,10 @@ function readCache() {
|
|
|
14663
14680
|
function writeCache(cache) {
|
|
14664
14681
|
try {
|
|
14665
14682
|
const file = cachePath();
|
|
14666
|
-
|
|
14683
|
+
fs31.mkdirSync(path35.dirname(file), { recursive: true });
|
|
14667
14684
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
14668
|
-
|
|
14669
|
-
|
|
14685
|
+
fs31.writeFileSync(tmp, JSON.stringify(cache));
|
|
14686
|
+
fs31.renameSync(tmp, file);
|
|
14670
14687
|
} catch {
|
|
14671
14688
|
}
|
|
14672
14689
|
}
|
|
@@ -14734,14 +14751,14 @@ function notifyIfStale(currentVersion, latest) {
|
|
|
14734
14751
|
}
|
|
14735
14752
|
function isLinkedInstall() {
|
|
14736
14753
|
try {
|
|
14737
|
-
const root = (0,
|
|
14754
|
+
const root = (0, import_node_child_process14.execSync)("npm root -g", {
|
|
14738
14755
|
encoding: "utf8",
|
|
14739
14756
|
stdio: ["ignore", "pipe", "ignore"],
|
|
14740
14757
|
timeout: 2e3
|
|
14741
14758
|
}).trim();
|
|
14742
14759
|
if (!root) return false;
|
|
14743
14760
|
const pkgPath = path35.join(root, PKG_NAME);
|
|
14744
|
-
return
|
|
14761
|
+
return fs31.lstatSync(pkgPath).isSymbolicLink();
|
|
14745
14762
|
} catch {
|
|
14746
14763
|
return false;
|
|
14747
14764
|
}
|
|
@@ -14762,7 +14779,7 @@ function maybeAutoUpdate(currentVersion, latest) {
|
|
|
14762
14779
|
|
|
14763
14780
|
`
|
|
14764
14781
|
);
|
|
14765
|
-
const install = (0,
|
|
14782
|
+
const install = (0, import_node_child_process14.spawnSync)("npm", ["install", "-g", `${PKG_NAME}@latest`], {
|
|
14766
14783
|
stdio: "inherit",
|
|
14767
14784
|
env: process.env
|
|
14768
14785
|
});
|
|
@@ -14777,13 +14794,13 @@ function maybeAutoUpdate(currentVersion, latest) {
|
|
|
14777
14794
|
return;
|
|
14778
14795
|
}
|
|
14779
14796
|
try {
|
|
14780
|
-
|
|
14797
|
+
fs31.unlinkSync(cachePath());
|
|
14781
14798
|
} catch {
|
|
14782
14799
|
}
|
|
14783
14800
|
process.stderr.write(` ${import_picocolors3.default.green("\u2713")} Updated. Resuming session...
|
|
14784
14801
|
|
|
14785
14802
|
`);
|
|
14786
|
-
const child = (0,
|
|
14803
|
+
const child = (0, import_node_child_process14.spawnSync)("codeam", process.argv.slice(2), {
|
|
14787
14804
|
stdio: "inherit",
|
|
14788
14805
|
env: process.env
|
|
14789
14806
|
});
|
|
@@ -14793,7 +14810,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
14793
14810
|
if (process.env.NODE_ENV === "test") return;
|
|
14794
14811
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
14795
14812
|
if (process.env.CI) return;
|
|
14796
|
-
const current = true ? "2.51.
|
|
14813
|
+
const current = true ? "2.51.2" : null;
|
|
14797
14814
|
if (!current) return;
|
|
14798
14815
|
const cache = readCache();
|
|
14799
14816
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -14810,7 +14827,7 @@ function checkForUpdates() {
|
|
|
14810
14827
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
14811
14828
|
if (process.env.CI) return;
|
|
14812
14829
|
if (!process.stdout.isTTY) return;
|
|
14813
|
-
const current = true ? "2.51.
|
|
14830
|
+
const current = true ? "2.51.2" : null;
|
|
14814
14831
|
if (!current) return;
|
|
14815
14832
|
const cache = readCache();
|
|
14816
14833
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -14882,8 +14899,8 @@ function maybeResumeLocalHeadroomReporter(ctx) {
|
|
|
14882
14899
|
if (process.env["HEADROOM_ENABLED"] === "1") return null;
|
|
14883
14900
|
try {
|
|
14884
14901
|
const file = headroomConfigPath();
|
|
14885
|
-
if (!
|
|
14886
|
-
const cfg = JSON.parse(
|
|
14902
|
+
if (!fs32.existsSync(file)) return null;
|
|
14903
|
+
const cfg = JSON.parse(fs32.readFileSync(file, "utf8"));
|
|
14887
14904
|
if (!cfg?.enabled) return null;
|
|
14888
14905
|
const agent = cfg.agent ?? "claude";
|
|
14889
14906
|
const ingestUrl = `${resolveApiBaseUrl()}/api/sessions/${ctx.sessionId}/headroom-savings`;
|
|
@@ -14974,7 +14991,7 @@ var HEADROOM_MIN_FREE_DISK_BYTES = 2 * 1024 * 1024 * 1024;
|
|
|
14974
14991
|
var defaultHeadroomRunner = {
|
|
14975
14992
|
which(cmd) {
|
|
14976
14993
|
try {
|
|
14977
|
-
(0,
|
|
14994
|
+
(0, import_node_child_process15.execFileSync)("which", [cmd], { stdio: "ignore" });
|
|
14978
14995
|
return true;
|
|
14979
14996
|
} catch {
|
|
14980
14997
|
return false;
|
|
@@ -14983,7 +15000,7 @@ var defaultHeadroomRunner = {
|
|
|
14983
15000
|
run(cmd, args2, opts = {}) {
|
|
14984
15001
|
return new Promise((resolve7) => {
|
|
14985
15002
|
const spawnEnv = opts.env ?? process.env;
|
|
14986
|
-
const child = (0,
|
|
15003
|
+
const child = (0, import_node_child_process15.spawn)(cmd, args2, { stdio: ["ignore", "pipe", "pipe"], env: spawnEnv });
|
|
14987
15004
|
let stderrBuf = "";
|
|
14988
15005
|
let stdoutBuf = "";
|
|
14989
15006
|
let settled = false;
|
|
@@ -15147,15 +15164,16 @@ function isHeadroomSupportedAgent(agentId) {
|
|
|
15147
15164
|
return n.startsWith("claude") || n.startsWith("codex") || n.startsWith("copilot");
|
|
15148
15165
|
}
|
|
15149
15166
|
function headroomConfigPath() {
|
|
15150
|
-
return path36.join(
|
|
15167
|
+
return path36.join(os29.homedir(), ".codeam", "headroom-config.json");
|
|
15151
15168
|
}
|
|
15152
15169
|
function persistHeadroomConfig(config) {
|
|
15153
15170
|
try {
|
|
15154
15171
|
const file = headroomConfigPath();
|
|
15155
|
-
|
|
15172
|
+
fs32.mkdirSync(path36.dirname(file), { recursive: true, mode: 448 });
|
|
15156
15173
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
15157
|
-
|
|
15158
|
-
|
|
15174
|
+
fs32.writeFileSync(tmp, JSON.stringify(config, null, 2), { encoding: "utf8", mode: 384 });
|
|
15175
|
+
fs32.renameSync(tmp, file);
|
|
15176
|
+
restrictToOwner(file);
|
|
15159
15177
|
} catch (err) {
|
|
15160
15178
|
log.warn(
|
|
15161
15179
|
"host-agent",
|
|
@@ -15164,7 +15182,7 @@ function persistHeadroomConfig(config) {
|
|
|
15164
15182
|
}
|
|
15165
15183
|
}
|
|
15166
15184
|
function agentSettingsPath(kind) {
|
|
15167
|
-
const home =
|
|
15185
|
+
const home = os29.homedir();
|
|
15168
15186
|
if (kind === "claude") return path36.join(home, ".claude", "settings.json");
|
|
15169
15187
|
if (kind === "codex") return path36.join(home, ".codex", "auth.json");
|
|
15170
15188
|
if (kind === "copilot") return path36.join(home, ".config", "github-copilot", "hosts.json");
|
|
@@ -15174,11 +15192,11 @@ function backupAgentHeadroomConfig(kind) {
|
|
|
15174
15192
|
const src = agentSettingsPath(kind);
|
|
15175
15193
|
if (!src) return;
|
|
15176
15194
|
try {
|
|
15177
|
-
if (!
|
|
15178
|
-
const dest = path36.join(
|
|
15179
|
-
|
|
15180
|
-
|
|
15181
|
-
|
|
15195
|
+
if (!fs32.existsSync(src)) return;
|
|
15196
|
+
const dest = path36.join(os29.homedir(), ".codeam", `headroom-backup-${kind}.json`);
|
|
15197
|
+
fs32.mkdirSync(path36.dirname(dest), { recursive: true, mode: 448 });
|
|
15198
|
+
fs32.copyFileSync(src, dest);
|
|
15199
|
+
fs32.chmodSync(dest, 384);
|
|
15182
15200
|
log.info("host-agent", `headroom config backup: ${src} \u2192 ${dest}`);
|
|
15183
15201
|
} catch (err) {
|
|
15184
15202
|
log.warn(
|
|
@@ -15190,12 +15208,12 @@ function backupAgentHeadroomConfig(kind) {
|
|
|
15190
15208
|
function restoreAgentHeadroomConfig(kind) {
|
|
15191
15209
|
const dest = agentSettingsPath(kind);
|
|
15192
15210
|
if (!dest) return false;
|
|
15193
|
-
const src = path36.join(
|
|
15194
|
-
if (!
|
|
15211
|
+
const src = path36.join(os29.homedir(), ".codeam", `headroom-backup-${kind}.json`);
|
|
15212
|
+
if (!fs32.existsSync(src)) return false;
|
|
15195
15213
|
try {
|
|
15196
|
-
|
|
15197
|
-
|
|
15198
|
-
|
|
15214
|
+
fs32.mkdirSync(path36.dirname(dest), { recursive: true, mode: 448 });
|
|
15215
|
+
fs32.copyFileSync(src, dest);
|
|
15216
|
+
fs32.chmodSync(dest, 384);
|
|
15199
15217
|
log.info("host-agent", `headroom config restored: ${src} \u2192 ${dest}`);
|
|
15200
15218
|
return true;
|
|
15201
15219
|
} catch (err) {
|
|
@@ -15208,7 +15226,7 @@ function restoreAgentHeadroomConfig(kind) {
|
|
|
15208
15226
|
}
|
|
15209
15227
|
function readHeadroomChildEnv() {
|
|
15210
15228
|
try {
|
|
15211
|
-
const raw =
|
|
15229
|
+
const raw = fs32.readFileSync(headroomConfigPath(), "utf8");
|
|
15212
15230
|
const parsed = JSON.parse(raw);
|
|
15213
15231
|
if (typeof parsed !== "object" || parsed === null) return {};
|
|
15214
15232
|
const o = parsed;
|
|
@@ -15249,21 +15267,21 @@ function bundledClaudeBinDir() {
|
|
|
15249
15267
|
const atAnthropic = path36.join(nm, "@anthropic-ai");
|
|
15250
15268
|
let entries;
|
|
15251
15269
|
try {
|
|
15252
|
-
entries =
|
|
15270
|
+
entries = fs32.readdirSync(atAnthropic);
|
|
15253
15271
|
} catch {
|
|
15254
15272
|
continue;
|
|
15255
15273
|
}
|
|
15256
15274
|
for (const entry of entries) {
|
|
15257
15275
|
if (!entry.startsWith("claude-agent-sdk-")) continue;
|
|
15258
15276
|
const bin = path36.join(atAnthropic, entry, "claude");
|
|
15259
|
-
if (
|
|
15277
|
+
if (fs32.existsSync(bin)) return path36.dirname(bin);
|
|
15260
15278
|
}
|
|
15261
15279
|
}
|
|
15262
15280
|
return null;
|
|
15263
15281
|
}
|
|
15264
15282
|
async function getFreeDiskBytes(dir) {
|
|
15265
15283
|
try {
|
|
15266
|
-
const s = await
|
|
15284
|
+
const s = await fs32.promises.statfs(dir);
|
|
15267
15285
|
return s.bsize * s.bavail;
|
|
15268
15286
|
} catch {
|
|
15269
15287
|
return null;
|
|
@@ -15479,7 +15497,7 @@ async function setupHeadroomForSelfHosted(agent, runner = defaultHeadroomRunner,
|
|
|
15479
15497
|
onProgress("proxy");
|
|
15480
15498
|
try {
|
|
15481
15499
|
const proxyEnv = { ...process.env, HEADROOM_KOMPRESS_BACKEND: "onnx_cpu" };
|
|
15482
|
-
const proxy = (0,
|
|
15500
|
+
const proxy = (0, import_node_child_process15.spawn)(
|
|
15483
15501
|
"headroom",
|
|
15484
15502
|
["proxy", "--port", "8787", ...buildBudgetProxyArgs(proxyEnv)],
|
|
15485
15503
|
{
|
|
@@ -15504,18 +15522,18 @@ async function setupHeadroomForSelfHosted(agent, runner = defaultHeadroomRunner,
|
|
|
15504
15522
|
onProgress("ready");
|
|
15505
15523
|
return true;
|
|
15506
15524
|
}
|
|
15507
|
-
var defaultSpawner = (env, cwd, args2 = []) => (0,
|
|
15525
|
+
var defaultSpawner = (env, cwd, args2 = []) => (0, import_node_child_process15.spawn)(process.execPath, [process.argv[1], "pair-auto", ...args2], {
|
|
15508
15526
|
cwd,
|
|
15509
15527
|
env: { ...process.env, ...env },
|
|
15510
15528
|
stdio: ["ignore", "pipe", "pipe"],
|
|
15511
15529
|
detached: false
|
|
15512
15530
|
});
|
|
15513
15531
|
function currentCliVersion() {
|
|
15514
|
-
return true ? "2.51.
|
|
15532
|
+
return true ? "2.51.2" : null;
|
|
15515
15533
|
}
|
|
15516
15534
|
function runCmd(cmd, args2, timeoutMs) {
|
|
15517
15535
|
return new Promise((resolve7) => {
|
|
15518
|
-
(0,
|
|
15536
|
+
(0, import_node_child_process15.execFile)(cmd, args2, { timeout: timeoutMs }, (err, stdout, stderr) => {
|
|
15519
15537
|
const code = err && typeof err.code === "number" ? err.code : err ? null : 0;
|
|
15520
15538
|
resolve7({ code, stdout: stdout ?? "", stderr: stderr ?? "" });
|
|
15521
15539
|
});
|
|
@@ -15586,20 +15604,20 @@ var defaultOnUpdated = (version3) => {
|
|
|
15586
15604
|
};
|
|
15587
15605
|
var defaultDisableService = () => {
|
|
15588
15606
|
try {
|
|
15589
|
-
(0,
|
|
15607
|
+
(0, import_node_child_process15.execFileSync)("systemctl", ["disable", "--now", "codeam-host-agent"], { stdio: "ignore" });
|
|
15590
15608
|
} catch {
|
|
15591
15609
|
}
|
|
15592
15610
|
};
|
|
15593
15611
|
var defaultTeardownHeadroom = () => {
|
|
15594
15612
|
try {
|
|
15595
|
-
const kind = JSON.parse(
|
|
15613
|
+
const kind = JSON.parse(fs32.readFileSync(headroomConfigPath(), "utf8")).agent;
|
|
15596
15614
|
if (kind) {
|
|
15597
|
-
(0,
|
|
15615
|
+
(0, import_node_child_process15.execFileSync)("headroom", ["unwrap", kind], { stdio: "ignore", timeout: 15e3 });
|
|
15598
15616
|
}
|
|
15599
15617
|
} catch {
|
|
15600
15618
|
}
|
|
15601
15619
|
try {
|
|
15602
|
-
(0,
|
|
15620
|
+
(0, import_node_child_process15.execFileSync)("pkill", ["-TERM", "-f", "headroom.*proxy"], { stdio: "ignore" });
|
|
15603
15621
|
} catch {
|
|
15604
15622
|
}
|
|
15605
15623
|
persistHeadroomConfig({ enabled: false });
|
|
@@ -15906,9 +15924,9 @@ var HostAgentSupervisor = class {
|
|
|
15906
15924
|
API_TIMEOUT_MS: "3000000",
|
|
15907
15925
|
CODEAM_AUTO_TOKEN: payload.autoPairToken
|
|
15908
15926
|
};
|
|
15909
|
-
const houseConfigDir = path36.join(
|
|
15927
|
+
const houseConfigDir = path36.join(os29.homedir(), ".codeam", "house-claude");
|
|
15910
15928
|
try {
|
|
15911
|
-
|
|
15929
|
+
fs32.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
|
|
15912
15930
|
} catch {
|
|
15913
15931
|
}
|
|
15914
15932
|
childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
|
|
@@ -15926,7 +15944,7 @@ var HostAgentSupervisor = class {
|
|
|
15926
15944
|
report("installing", "installing agent CLI");
|
|
15927
15945
|
await this.runAgentInstall(payload.agentInstallScript);
|
|
15928
15946
|
}
|
|
15929
|
-
const home = process.env.HOME ||
|
|
15947
|
+
const home = process.env.HOME || os29.homedir();
|
|
15930
15948
|
childEnv.PATH = `${home}/.local/bin:${process.env.PATH ?? ""}`;
|
|
15931
15949
|
if (payload.cloneToken) {
|
|
15932
15950
|
try {
|
|
@@ -15949,7 +15967,7 @@ var HostAgentSupervisor = class {
|
|
|
15949
15967
|
}
|
|
15950
15968
|
if (payload.headroomEnabled && payload.headroomAgent && payload.headroomSavingsIngestUrl && isHeadroomSupportedAgent(payload.headroomAgent)) {
|
|
15951
15969
|
report("headroom", "setting up Headroom proxy");
|
|
15952
|
-
const freeBytes = await this.getFreeDisk(
|
|
15970
|
+
const freeBytes = await this.getFreeDisk(os29.homedir());
|
|
15953
15971
|
const alreadyInstalled = this.isHeadroomInstalled();
|
|
15954
15972
|
if (!alreadyInstalled && freeBytes !== null && freeBytes < HEADROOM_MIN_FREE_DISK_BYTES) {
|
|
15955
15973
|
const freeGb = (freeBytes / 1e9).toFixed(1);
|
|
@@ -16071,8 +16089,8 @@ var HostAgentSupervisor = class {
|
|
|
16071
16089
|
*/
|
|
16072
16090
|
runAgentInstall(script) {
|
|
16073
16091
|
return new Promise((resolve7) => {
|
|
16074
|
-
const home = process.env.HOME ||
|
|
16075
|
-
const child = (0,
|
|
16092
|
+
const home = process.env.HOME || os29.homedir();
|
|
16093
|
+
const child = (0, import_node_child_process15.spawn)("sh", ["-c", script], {
|
|
16076
16094
|
env: { ...process.env, HOME: home },
|
|
16077
16095
|
stdio: ["ignore", "pipe", "pipe"]
|
|
16078
16096
|
});
|
|
@@ -16240,8 +16258,158 @@ async function configureHeadroom(action, ctx, deps) {
|
|
|
16240
16258
|
return { enabled: false };
|
|
16241
16259
|
}
|
|
16242
16260
|
|
|
16243
|
-
// src/services/
|
|
16261
|
+
// src/services/headroom/budget-relaunch.ts
|
|
16262
|
+
var fs33 = __toESM(require("fs"));
|
|
16263
|
+
var os30 = __toESM(require("os"));
|
|
16264
|
+
var path37 = __toESM(require("path"));
|
|
16244
16265
|
var import_child_process12 = require("child_process");
|
|
16266
|
+
function amendDeploymentManifestBudget(manifest, budget) {
|
|
16267
|
+
const rawArgs = manifest.proxy_args ?? [];
|
|
16268
|
+
const strippedArgs = [];
|
|
16269
|
+
for (let i = 0; i < rawArgs.length; i++) {
|
|
16270
|
+
if (rawArgs[i] === "--budget" || rawArgs[i] === "--budget-period") {
|
|
16271
|
+
i++;
|
|
16272
|
+
continue;
|
|
16273
|
+
}
|
|
16274
|
+
strippedArgs.push(rawArgs[i]);
|
|
16275
|
+
}
|
|
16276
|
+
const rawEnv = manifest.base_env ?? {};
|
|
16277
|
+
const strippedEnv = { ...rawEnv };
|
|
16278
|
+
delete strippedEnv["HEADROOM_BUDGET"];
|
|
16279
|
+
delete strippedEnv["HEADROOM_BUDGET_PERIOD"];
|
|
16280
|
+
if (!budget) {
|
|
16281
|
+
return { ...manifest, proxy_args: strippedArgs, base_env: strippedEnv };
|
|
16282
|
+
}
|
|
16283
|
+
const newArgs = [
|
|
16284
|
+
...strippedArgs,
|
|
16285
|
+
"--budget",
|
|
16286
|
+
String(budget.budgetUsd),
|
|
16287
|
+
"--budget-period",
|
|
16288
|
+
budget.budgetPeriod
|
|
16289
|
+
];
|
|
16290
|
+
const newEnv = {
|
|
16291
|
+
...strippedEnv,
|
|
16292
|
+
HEADROOM_BUDGET: String(budget.budgetUsd),
|
|
16293
|
+
HEADROOM_BUDGET_PERIOD: budget.budgetPeriod
|
|
16294
|
+
};
|
|
16295
|
+
return { ...manifest, proxy_args: newArgs, base_env: newEnv };
|
|
16296
|
+
}
|
|
16297
|
+
function findHeadroomDeployments(homeDir2, deps) {
|
|
16298
|
+
const deployDir = path37.join(homeDir2, ".headroom", "deploy");
|
|
16299
|
+
let profiles;
|
|
16300
|
+
try {
|
|
16301
|
+
profiles = deps.readDir(deployDir);
|
|
16302
|
+
} catch {
|
|
16303
|
+
return [];
|
|
16304
|
+
}
|
|
16305
|
+
const results = [];
|
|
16306
|
+
for (const profile of profiles) {
|
|
16307
|
+
const manifestPath = path37.join(deployDir, profile, "manifest.json");
|
|
16308
|
+
let raw;
|
|
16309
|
+
try {
|
|
16310
|
+
raw = deps.readJson(manifestPath);
|
|
16311
|
+
} catch {
|
|
16312
|
+
continue;
|
|
16313
|
+
}
|
|
16314
|
+
if (!raw || typeof raw !== "object") continue;
|
|
16315
|
+
const manifest = raw;
|
|
16316
|
+
const port = typeof manifest.port === "number" ? manifest.port : 0;
|
|
16317
|
+
results.push({ profile, manifestPath, port, manifest });
|
|
16318
|
+
}
|
|
16319
|
+
return results;
|
|
16320
|
+
}
|
|
16321
|
+
async function applyBudgetToHeadroom(budget, deps) {
|
|
16322
|
+
const supervised = deps.findDeployments().filter((d3) => d3.port === 8787);
|
|
16323
|
+
if (supervised.length > 0) {
|
|
16324
|
+
log.info("headroom-budget", `supervised path \u2014 amending ${supervised.length} deployment(s)`);
|
|
16325
|
+
for (const d3 of supervised) {
|
|
16326
|
+
const amended = amendDeploymentManifestBudget(d3.manifest, budget);
|
|
16327
|
+
deps.writeManifest(d3.manifestPath, amended);
|
|
16328
|
+
deps.restartDeployment(d3.profile);
|
|
16329
|
+
}
|
|
16330
|
+
return { path: "supervised", profiles: supervised.map((d3) => d3.profile) };
|
|
16331
|
+
}
|
|
16332
|
+
log.info("headroom-budget", "direct path \u2014 kill + respawn proxy");
|
|
16333
|
+
deps.killProxy();
|
|
16334
|
+
deps.spawnProxy(budget);
|
|
16335
|
+
return { path: "direct" };
|
|
16336
|
+
}
|
|
16337
|
+
function writeManifestReal(manifestPath, manifest) {
|
|
16338
|
+
const tmp = manifestPath + ".codeam.tmp";
|
|
16339
|
+
fs33.writeFileSync(tmp, JSON.stringify(manifest, null, 2) + "\n", { mode: 384 });
|
|
16340
|
+
fs33.renameSync(tmp, manifestPath);
|
|
16341
|
+
}
|
|
16342
|
+
function restartDeploymentReal(profile) {
|
|
16343
|
+
try {
|
|
16344
|
+
const proc = (0, import_child_process12.spawn)("headroom", ["install", "restart", "--profile", profile], {
|
|
16345
|
+
detached: true,
|
|
16346
|
+
stdio: "ignore"
|
|
16347
|
+
});
|
|
16348
|
+
proc.once("error", (e) => {
|
|
16349
|
+
log.warn("headroom-budget", `restart deployment '${profile}' error (best-effort): ${e.message}`);
|
|
16350
|
+
});
|
|
16351
|
+
proc.unref();
|
|
16352
|
+
} catch (e) {
|
|
16353
|
+
log.warn(
|
|
16354
|
+
"headroom-budget",
|
|
16355
|
+
`restart deployment '${profile}' failed (best-effort): ${e instanceof Error ? e.message : String(e)}`
|
|
16356
|
+
);
|
|
16357
|
+
}
|
|
16358
|
+
}
|
|
16359
|
+
function killProxyReal() {
|
|
16360
|
+
try {
|
|
16361
|
+
const killer = (0, import_child_process12.spawn)("pkill", ["-TERM", "-f", "headroom.*proxy"], {
|
|
16362
|
+
detached: true,
|
|
16363
|
+
stdio: "ignore"
|
|
16364
|
+
});
|
|
16365
|
+
killer.once("error", () => {
|
|
16366
|
+
});
|
|
16367
|
+
killer.unref();
|
|
16368
|
+
} catch {
|
|
16369
|
+
}
|
|
16370
|
+
}
|
|
16371
|
+
function spawnProxyReal(budget) {
|
|
16372
|
+
try {
|
|
16373
|
+
const proxyEnv = {
|
|
16374
|
+
...process.env,
|
|
16375
|
+
HEADROOM_KOMPRESS_BACKEND: "onnx_cpu"
|
|
16376
|
+
};
|
|
16377
|
+
const proxy = (0, import_child_process12.spawn)(
|
|
16378
|
+
"headroom",
|
|
16379
|
+
["proxy", "--port", "8787", ...buildBudgetProxyArgs(proxyEnv)],
|
|
16380
|
+
{
|
|
16381
|
+
stdio: "ignore",
|
|
16382
|
+
detached: true,
|
|
16383
|
+
env: proxyEnv
|
|
16384
|
+
}
|
|
16385
|
+
);
|
|
16386
|
+
proxy.once("error", (e) => {
|
|
16387
|
+
log.warn("headroom-budget", `proxy relaunch error (best-effort): ${e.message}`);
|
|
16388
|
+
});
|
|
16389
|
+
proxy.unref();
|
|
16390
|
+
} catch (e) {
|
|
16391
|
+
log.warn(
|
|
16392
|
+
"headroom-budget",
|
|
16393
|
+
`proxy relaunch failed (best-effort): ${e instanceof Error ? e.message : String(e)}`
|
|
16394
|
+
);
|
|
16395
|
+
}
|
|
16396
|
+
}
|
|
16397
|
+
function makeRealApplyBudgetDeps() {
|
|
16398
|
+
const homeDir2 = os30.homedir();
|
|
16399
|
+
return {
|
|
16400
|
+
findDeployments: () => findHeadroomDeployments(homeDir2, {
|
|
16401
|
+
readDir: (dir) => fs33.readdirSync(dir),
|
|
16402
|
+
readJson: (filePath) => JSON.parse(fs33.readFileSync(filePath, "utf8"))
|
|
16403
|
+
}),
|
|
16404
|
+
writeManifest: writeManifestReal,
|
|
16405
|
+
restartDeployment: restartDeploymentReal,
|
|
16406
|
+
killProxy: killProxyReal,
|
|
16407
|
+
spawnProxy: spawnProxyReal
|
|
16408
|
+
};
|
|
16409
|
+
}
|
|
16410
|
+
|
|
16411
|
+
// src/services/preview/cloudflared.ts
|
|
16412
|
+
var import_child_process13 = require("child_process");
|
|
16245
16413
|
var import_fs = require("fs");
|
|
16246
16414
|
var import_promises = __toESM(require("fs/promises"));
|
|
16247
16415
|
var import_os6 = __toESM(require("os"));
|
|
@@ -16318,7 +16486,7 @@ async function isExecutableBinary(p2) {
|
|
|
16318
16486
|
}
|
|
16319
16487
|
function extractTgz(tgzPath, destDir) {
|
|
16320
16488
|
return new Promise((resolve7, reject) => {
|
|
16321
|
-
const child = (0,
|
|
16489
|
+
const child = (0, import_child_process13.spawn)("tar", ["-xzf", tgzPath, "-C", destDir], { stdio: "ignore" });
|
|
16322
16490
|
child.on("error", (err) => reject(err));
|
|
16323
16491
|
child.on(
|
|
16324
16492
|
"exit",
|
|
@@ -16352,7 +16520,7 @@ async function spawnNamedTunnel(bin, token, port) {
|
|
|
16352
16520
|
await import_promises.default.mkdir(credDir, { recursive: true });
|
|
16353
16521
|
const credFile = import_path4.default.join(credDir, `tunnel-${creds.TunnelID}.json`);
|
|
16354
16522
|
await import_promises.default.writeFile(credFile, JSON.stringify(creds), { mode: 384 });
|
|
16355
|
-
return (0,
|
|
16523
|
+
return (0, import_child_process13.spawn)(
|
|
16356
16524
|
bin,
|
|
16357
16525
|
[
|
|
16358
16526
|
"tunnel",
|
|
@@ -16368,9 +16536,9 @@ async function spawnNamedTunnel(bin, token, port) {
|
|
|
16368
16536
|
}
|
|
16369
16537
|
|
|
16370
16538
|
// src/services/preview/codespace.ts
|
|
16371
|
-
var
|
|
16539
|
+
var import_child_process14 = require("child_process");
|
|
16372
16540
|
var import_util3 = require("util");
|
|
16373
|
-
var execFileP5 = (0, import_util3.promisify)(
|
|
16541
|
+
var execFileP5 = (0, import_util3.promisify)(import_child_process14.execFile);
|
|
16374
16542
|
|
|
16375
16543
|
// src/services/preview/config-file.ts
|
|
16376
16544
|
var import_promises3 = __toESM(require("fs/promises"));
|
|
@@ -16565,10 +16733,10 @@ var import_fs2 = require("fs");
|
|
|
16565
16733
|
var import_path6 = __toESM(require("path"));
|
|
16566
16734
|
|
|
16567
16735
|
// src/services/preview/run-setup.ts
|
|
16568
|
-
var
|
|
16736
|
+
var import_child_process15 = require("child_process");
|
|
16569
16737
|
function runSetupCommand(cmd, args2, cwd, env, opts) {
|
|
16570
16738
|
return new Promise((resolve7) => {
|
|
16571
|
-
const child = (0,
|
|
16739
|
+
const child = (0, import_child_process15.spawn)(cmd, args2, {
|
|
16572
16740
|
cwd,
|
|
16573
16741
|
env: { ...process.env, ...env ?? {} },
|
|
16574
16742
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -16874,10 +17042,10 @@ function activePreviewSessionIds() {
|
|
|
16874
17042
|
}
|
|
16875
17043
|
|
|
16876
17044
|
// src/beads/bd-adapter.ts
|
|
16877
|
-
var
|
|
16878
|
-
var
|
|
16879
|
-
var
|
|
16880
|
-
var
|
|
17045
|
+
var import_child_process16 = require("child_process");
|
|
17046
|
+
var fs38 = __toESM(require("fs"));
|
|
17047
|
+
var os32 = __toESM(require("os"));
|
|
17048
|
+
var path42 = __toESM(require("path"));
|
|
16881
17049
|
var BD_PACKAGE = "@beads/bd";
|
|
16882
17050
|
function resolveBundledBdBinary() {
|
|
16883
17051
|
return _resolveSeam.resolveBundled();
|
|
@@ -16889,11 +17057,11 @@ function _defaultResolveBundled() {
|
|
|
16889
17057
|
} catch {
|
|
16890
17058
|
return null;
|
|
16891
17059
|
}
|
|
16892
|
-
const binDir =
|
|
17060
|
+
const binDir = path42.join(path42.dirname(pkgJsonPath), "bin");
|
|
16893
17061
|
const binaryName = process.platform === "win32" ? "bd.exe" : "bd";
|
|
16894
|
-
const binaryPath =
|
|
17062
|
+
const binaryPath = path42.join(binDir, binaryName);
|
|
16895
17063
|
try {
|
|
16896
|
-
|
|
17064
|
+
fs38.accessSync(binaryPath, fs38.constants.F_OK);
|
|
16897
17065
|
return binaryPath;
|
|
16898
17066
|
} catch {
|
|
16899
17067
|
return null;
|
|
@@ -16903,13 +17071,13 @@ function resolveBdOnPath() {
|
|
|
16903
17071
|
return _resolveSeam.resolveOnPath();
|
|
16904
17072
|
}
|
|
16905
17073
|
function _defaultResolveOnPath() {
|
|
16906
|
-
const dirs = (process.env.PATH ?? "").split(
|
|
17074
|
+
const dirs = (process.env.PATH ?? "").split(path42.delimiter).filter(Boolean);
|
|
16907
17075
|
const candidates = process.platform === "win32" ? ["bd.exe", "bd.cmd", "bd"] : ["bd"];
|
|
16908
17076
|
for (const dir of dirs) {
|
|
16909
17077
|
for (const candidate of candidates) {
|
|
16910
|
-
const full =
|
|
17078
|
+
const full = path42.join(dir, candidate);
|
|
16911
17079
|
try {
|
|
16912
|
-
|
|
17080
|
+
fs38.accessSync(full, fs38.constants.F_OK);
|
|
16913
17081
|
return full;
|
|
16914
17082
|
} catch {
|
|
16915
17083
|
}
|
|
@@ -16928,7 +17096,7 @@ function _defaultSpawn(binaryPath, args2, opts) {
|
|
|
16928
17096
|
return new Promise((resolve7) => {
|
|
16929
17097
|
let proc;
|
|
16930
17098
|
try {
|
|
16931
|
-
proc = (0,
|
|
17099
|
+
proc = (0, import_child_process16.spawn)(binaryPath, args2, { cwd: opts.cwd, env: opts.env });
|
|
16932
17100
|
} catch (err) {
|
|
16933
17101
|
resolve7({ code: -1, stdout: "", stderr: err.message });
|
|
16934
17102
|
return;
|
|
@@ -16994,7 +17162,7 @@ var BdAdapter = class {
|
|
|
16994
17162
|
const env = { ...process.env };
|
|
16995
17163
|
if (!env.HOME) {
|
|
16996
17164
|
try {
|
|
16997
|
-
const home =
|
|
17165
|
+
const home = os32.homedir();
|
|
16998
17166
|
if (home) env.HOME = home;
|
|
16999
17167
|
} catch {
|
|
17000
17168
|
}
|
|
@@ -17082,13 +17250,13 @@ function coerceIssue(row, projectKey) {
|
|
|
17082
17250
|
}
|
|
17083
17251
|
|
|
17084
17252
|
// src/beads/provisioner.ts
|
|
17085
|
-
var
|
|
17086
|
-
var
|
|
17087
|
-
var
|
|
17088
|
-
var
|
|
17253
|
+
var import_child_process20 = require("child_process");
|
|
17254
|
+
var fs41 = __toESM(require("fs"));
|
|
17255
|
+
var os34 = __toESM(require("os"));
|
|
17256
|
+
var path45 = __toESM(require("path"));
|
|
17089
17257
|
|
|
17090
17258
|
// src/beads/install-bd.ts
|
|
17091
|
-
var
|
|
17259
|
+
var import_child_process17 = require("child_process");
|
|
17092
17260
|
var INSTALL_SH_URL = "https://raw.githubusercontent.com/gastownhall/beads/main/scripts/install.sh";
|
|
17093
17261
|
var INSTALL_PS1_URL = "https://raw.githubusercontent.com/gastownhall/beads/main/install.ps1";
|
|
17094
17262
|
function resolveInstallStrategy(platform3) {
|
|
@@ -17119,7 +17287,7 @@ function _defaultInstallSpawn(strategy) {
|
|
|
17119
17287
|
return new Promise((resolve7) => {
|
|
17120
17288
|
let proc;
|
|
17121
17289
|
try {
|
|
17122
|
-
proc = (0,
|
|
17290
|
+
proc = (0, import_child_process17.spawn)(strategy.command, strategy.args, { env: process.env });
|
|
17123
17291
|
} catch (err) {
|
|
17124
17292
|
resolve7({ ok: false, code: -1, stderr: err.message });
|
|
17125
17293
|
return;
|
|
@@ -17149,10 +17317,10 @@ async function installBd(platform3 = process.platform) {
|
|
|
17149
17317
|
}
|
|
17150
17318
|
|
|
17151
17319
|
// src/beads/install-dolt.ts
|
|
17152
|
-
var
|
|
17153
|
-
var
|
|
17154
|
-
var
|
|
17155
|
-
var
|
|
17320
|
+
var import_child_process18 = require("child_process");
|
|
17321
|
+
var fs39 = __toESM(require("fs"));
|
|
17322
|
+
var os33 = __toESM(require("os"));
|
|
17323
|
+
var path43 = __toESM(require("path"));
|
|
17156
17324
|
var DOLT_INSTALL_SH_URL = "https://github.com/dolthub/dolt/releases/latest/download/install.sh";
|
|
17157
17325
|
var DOLT_MSI_URL = "https://github.com/dolthub/dolt/releases/latest/download/dolt-windows-amd64.msi";
|
|
17158
17326
|
function resolveDoltInstallStrategy(platform3) {
|
|
@@ -17192,11 +17360,11 @@ function resolveDoltInstallStrategy(platform3) {
|
|
|
17192
17360
|
}
|
|
17193
17361
|
var DOLT_RELEASE_BASE = "https://github.com/dolthub/dolt/releases/latest/download";
|
|
17194
17362
|
function doltPlatformTuple(platform3, arch2) {
|
|
17195
|
-
const
|
|
17363
|
+
const os43 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
|
|
17196
17364
|
const a = arch2 === "x64" ? "amd64" : arch2 === "arm64" ? "arm64" : null;
|
|
17197
17365
|
if (!a) return null;
|
|
17198
|
-
if (
|
|
17199
|
-
return `${
|
|
17366
|
+
if (os43 === "windows" && a !== "amd64") return null;
|
|
17367
|
+
return `${os43}-${a}`;
|
|
17200
17368
|
}
|
|
17201
17369
|
function resolveDoltTarballStrategy(targetDir, platform3, arch2) {
|
|
17202
17370
|
const tuple = doltPlatformTuple(platform3, arch2);
|
|
@@ -17241,14 +17409,14 @@ async function installDoltToDir(targetDir, platform3 = process.platform, arch2 =
|
|
|
17241
17409
|
return result;
|
|
17242
17410
|
}
|
|
17243
17411
|
var _doltPathSeam = {
|
|
17244
|
-
homedir: () =>
|
|
17412
|
+
homedir: () => os33.homedir(),
|
|
17245
17413
|
getPath: () => process.env.PATH ?? "",
|
|
17246
17414
|
setPath: (p2) => {
|
|
17247
17415
|
process.env.PATH = p2;
|
|
17248
17416
|
},
|
|
17249
17417
|
exists: (p2) => {
|
|
17250
17418
|
try {
|
|
17251
|
-
|
|
17419
|
+
fs39.accessSync(p2, fs39.constants.F_OK);
|
|
17252
17420
|
return true;
|
|
17253
17421
|
} catch {
|
|
17254
17422
|
return false;
|
|
@@ -17259,7 +17427,7 @@ function doltBinaryNames(platform3) {
|
|
|
17259
17427
|
return platform3 === "win32" ? ["dolt.exe", "dolt.cmd", "dolt"] : ["dolt"];
|
|
17260
17428
|
}
|
|
17261
17429
|
function knownDoltDirs(platform3) {
|
|
17262
|
-
const P3 = platform3 === "win32" ?
|
|
17430
|
+
const P3 = platform3 === "win32" ? path43.win32 : path43.posix;
|
|
17263
17431
|
const home = _doltPathSeam.homedir();
|
|
17264
17432
|
if (platform3 === "win32") {
|
|
17265
17433
|
return [
|
|
@@ -17275,7 +17443,7 @@ function knownDoltDirs(platform3) {
|
|
|
17275
17443
|
].filter(Boolean);
|
|
17276
17444
|
}
|
|
17277
17445
|
function ensureDoltResolvable(platform3 = process.platform) {
|
|
17278
|
-
const P3 = platform3 === "win32" ?
|
|
17446
|
+
const P3 = platform3 === "win32" ? path43.win32 : path43.posix;
|
|
17279
17447
|
const delim = platform3 === "win32" ? ";" : ":";
|
|
17280
17448
|
const names = doltBinaryNames(platform3);
|
|
17281
17449
|
const pathDirs = _doltPathSeam.getPath().split(delim).filter(Boolean);
|
|
@@ -17311,7 +17479,7 @@ function _defaultDoltInstallSpawn(strategy) {
|
|
|
17311
17479
|
};
|
|
17312
17480
|
let proc;
|
|
17313
17481
|
try {
|
|
17314
|
-
proc = (0,
|
|
17482
|
+
proc = (0, import_child_process18.spawn)(strategy.command, strategy.args, {
|
|
17315
17483
|
env: process.env,
|
|
17316
17484
|
stdio: ["ignore", "pipe", "pipe"]
|
|
17317
17485
|
});
|
|
@@ -17409,10 +17577,10 @@ async function ensureSharedServer(adapter, options = {}) {
|
|
|
17409
17577
|
}
|
|
17410
17578
|
|
|
17411
17579
|
// src/beads/project-key.ts
|
|
17412
|
-
var
|
|
17580
|
+
var import_child_process19 = require("child_process");
|
|
17413
17581
|
var crypto2 = __toESM(require("crypto"));
|
|
17414
|
-
var
|
|
17415
|
-
var
|
|
17582
|
+
var fs40 = __toESM(require("fs"));
|
|
17583
|
+
var path44 = __toESM(require("path"));
|
|
17416
17584
|
function normalizeOrigin(raw) {
|
|
17417
17585
|
const trimmed = raw.trim();
|
|
17418
17586
|
if (!trimmed) return null;
|
|
@@ -17438,17 +17606,17 @@ function normalizeOrigin(raw) {
|
|
|
17438
17606
|
return `${host2}/${pathPart}`;
|
|
17439
17607
|
}
|
|
17440
17608
|
function findRepoRoot(cwd) {
|
|
17441
|
-
let dir =
|
|
17609
|
+
let dir = path44.resolve(cwd);
|
|
17442
17610
|
const seen = /* @__PURE__ */ new Set();
|
|
17443
17611
|
for (let i = 0; i < 256; i++) {
|
|
17444
17612
|
if (seen.has(dir)) return null;
|
|
17445
17613
|
seen.add(dir);
|
|
17446
17614
|
try {
|
|
17447
|
-
const stat3 =
|
|
17615
|
+
const stat3 = fs40.statSync(path44.join(dir, ".git"), { throwIfNoEntry: false });
|
|
17448
17616
|
if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
|
|
17449
17617
|
} catch {
|
|
17450
17618
|
}
|
|
17451
|
-
const parent =
|
|
17619
|
+
const parent = path44.dirname(dir);
|
|
17452
17620
|
if (parent === dir) return null;
|
|
17453
17621
|
dir = parent;
|
|
17454
17622
|
}
|
|
@@ -17456,10 +17624,10 @@ function findRepoRoot(cwd) {
|
|
|
17456
17624
|
}
|
|
17457
17625
|
var _execSeam2 = {
|
|
17458
17626
|
exec: (file, args2, opts) => {
|
|
17459
|
-
const out2 = (0,
|
|
17627
|
+
const out2 = (0, import_child_process19.execFileSync)(file, args2, opts);
|
|
17460
17628
|
return typeof out2 === "string" ? out2 : out2.toString("utf8");
|
|
17461
17629
|
},
|
|
17462
|
-
realpath: (p2) =>
|
|
17630
|
+
realpath: (p2) => fs40.realpathSync(p2)
|
|
17463
17631
|
};
|
|
17464
17632
|
function readOrigin(cwd) {
|
|
17465
17633
|
try {
|
|
@@ -17488,7 +17656,7 @@ function deriveProjectIdentity(cwd = process.cwd()) {
|
|
|
17488
17656
|
} catch {
|
|
17489
17657
|
}
|
|
17490
17658
|
const hash = crypto2.createHash("sha256").update(real).digest("hex");
|
|
17491
|
-
return { projectKey: `path:${hash}`, projectLabel:
|
|
17659
|
+
return { projectKey: `path:${hash}`, projectLabel: path44.basename(real) || "project" };
|
|
17492
17660
|
}
|
|
17493
17661
|
|
|
17494
17662
|
// src/beads/project-prefix.ts
|
|
@@ -17530,17 +17698,17 @@ var _provisionSeam = {
|
|
|
17530
17698
|
};
|
|
17531
17699
|
var _linkSeam = {
|
|
17532
17700
|
platform: () => process.platform,
|
|
17533
|
-
homedir: () =>
|
|
17701
|
+
homedir: () => os34.homedir(),
|
|
17534
17702
|
isWritableDir: (dir) => {
|
|
17535
17703
|
try {
|
|
17536
|
-
|
|
17704
|
+
fs41.accessSync(dir, fs41.constants.W_OK);
|
|
17537
17705
|
return true;
|
|
17538
17706
|
} catch {
|
|
17539
17707
|
return false;
|
|
17540
17708
|
}
|
|
17541
17709
|
},
|
|
17542
17710
|
ensureDir: (dir) => {
|
|
17543
|
-
|
|
17711
|
+
fs41.mkdirSync(dir, { recursive: true });
|
|
17544
17712
|
},
|
|
17545
17713
|
/**
|
|
17546
17714
|
* A directory to symlink `bd` into so the AGENT's shell + Claude Code's
|
|
@@ -17561,9 +17729,9 @@ var _linkSeam = {
|
|
|
17561
17729
|
* which `linkBdOntoPath` creates if missing.
|
|
17562
17730
|
*/
|
|
17563
17731
|
cliBinDir: () => {
|
|
17564
|
-
const pathDirs = (process.env.PATH ?? "").split(
|
|
17732
|
+
const pathDirs = (process.env.PATH ?? "").split(path45.delimiter).filter(Boolean);
|
|
17565
17733
|
const home = _linkSeam.homedir();
|
|
17566
|
-
const localBin = home ?
|
|
17734
|
+
const localBin = home ? path45.join(home, ".local", "bin") : null;
|
|
17567
17735
|
if (localBin) {
|
|
17568
17736
|
try {
|
|
17569
17737
|
_linkSeam.ensureDir(localBin);
|
|
@@ -17573,16 +17741,16 @@ var _linkSeam = {
|
|
|
17573
17741
|
const candidates = [];
|
|
17574
17742
|
if (localBin) candidates.push(localBin);
|
|
17575
17743
|
try {
|
|
17576
|
-
candidates.push(
|
|
17744
|
+
candidates.push(path45.dirname(process.execPath));
|
|
17577
17745
|
} catch {
|
|
17578
17746
|
}
|
|
17579
17747
|
candidates.push("/usr/local/bin");
|
|
17580
17748
|
const entry = process.argv[1];
|
|
17581
17749
|
if (entry) {
|
|
17582
17750
|
try {
|
|
17583
|
-
candidates.push(
|
|
17751
|
+
candidates.push(path45.dirname(fs41.realpathSync(entry)));
|
|
17584
17752
|
} catch {
|
|
17585
|
-
candidates.push(
|
|
17753
|
+
candidates.push(path45.dirname(entry));
|
|
17586
17754
|
}
|
|
17587
17755
|
}
|
|
17588
17756
|
const onPathWritable = candidates.find(
|
|
@@ -17594,20 +17762,20 @@ var _linkSeam = {
|
|
|
17594
17762
|
/** Current symlink target at `linkPath`, or null when absent / not a link. */
|
|
17595
17763
|
readlink: (linkPath) => {
|
|
17596
17764
|
try {
|
|
17597
|
-
return
|
|
17765
|
+
return fs41.readlinkSync(linkPath);
|
|
17598
17766
|
} catch {
|
|
17599
17767
|
return null;
|
|
17600
17768
|
}
|
|
17601
17769
|
},
|
|
17602
|
-
unlink: (linkPath) =>
|
|
17603
|
-
symlink: (target, linkPath) =>
|
|
17770
|
+
unlink: (linkPath) => fs41.unlinkSync(linkPath),
|
|
17771
|
+
symlink: (target, linkPath) => fs41.symlinkSync(target, linkPath)
|
|
17604
17772
|
};
|
|
17605
17773
|
function linkBdOntoPath(binaryPath) {
|
|
17606
17774
|
if (_linkSeam.platform() === "win32") return;
|
|
17607
17775
|
const binDir = _linkSeam.cliBinDir();
|
|
17608
17776
|
if (!binDir) return;
|
|
17609
17777
|
_linkSeam.ensureDir(binDir);
|
|
17610
|
-
const linkPath =
|
|
17778
|
+
const linkPath = path45.join(binDir, "bd");
|
|
17611
17779
|
if (linkPath === binaryPath) return;
|
|
17612
17780
|
const current = _linkSeam.readlink(linkPath);
|
|
17613
17781
|
if (current === binaryPath) return;
|
|
@@ -17616,7 +17784,7 @@ function linkBdOntoPath(binaryPath) {
|
|
|
17616
17784
|
log.info("beads", `linked bd onto PATH: ${linkPath} -> ${binaryPath}`);
|
|
17617
17785
|
}
|
|
17618
17786
|
function setGitBeadsRole() {
|
|
17619
|
-
(0,
|
|
17787
|
+
(0, import_child_process20.execFileSync)("git", ["config", "--global", "beads.role", "contributor"], {
|
|
17620
17788
|
stdio: "ignore"
|
|
17621
17789
|
});
|
|
17622
17790
|
}
|
|
@@ -17802,7 +17970,7 @@ function dedupeRecipes(agents) {
|
|
|
17802
17970
|
|
|
17803
17971
|
// src/beads/watcher.ts
|
|
17804
17972
|
var crypto4 = __toESM(require("crypto"));
|
|
17805
|
-
var
|
|
17973
|
+
var path46 = __toESM(require("path"));
|
|
17806
17974
|
var API_BASE6 = resolveApiBaseUrl();
|
|
17807
17975
|
var DEBOUNCE_MS2 = 400;
|
|
17808
17976
|
var ZERO_SUMMARY = {
|
|
@@ -17826,7 +17994,7 @@ var BeadsWatcher = class {
|
|
|
17826
17994
|
constructor(opts) {
|
|
17827
17995
|
this.opts = opts;
|
|
17828
17996
|
this.bd = opts.adapter ?? new BdAdapter({ cwd: opts.cwd, beadsDir: opts.beadsDir });
|
|
17829
|
-
this.feedPath = opts.feedPath ??
|
|
17997
|
+
this.feedPath = opts.feedPath ?? path46.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
|
|
17830
17998
|
this.apiBase = opts.apiBaseUrl ?? API_BASE6;
|
|
17831
17999
|
}
|
|
17832
18000
|
opts;
|
|
@@ -18076,15 +18244,15 @@ async function handleBeadsActionCommand(action, started) {
|
|
|
18076
18244
|
}
|
|
18077
18245
|
|
|
18078
18246
|
// src/beads/config-store.ts
|
|
18079
|
-
var
|
|
18080
|
-
var
|
|
18247
|
+
var import_node_fs6 = __toESM(require("fs"));
|
|
18248
|
+
var import_node_os4 = __toESM(require("os"));
|
|
18081
18249
|
var import_node_path4 = __toESM(require("path"));
|
|
18082
18250
|
function beadsConfigPath() {
|
|
18083
|
-
return import_node_path4.default.join(
|
|
18251
|
+
return import_node_path4.default.join(import_node_os4.default.homedir(), ".codeam", "beads-config.json");
|
|
18084
18252
|
}
|
|
18085
18253
|
function readBeadsEnabled() {
|
|
18086
18254
|
try {
|
|
18087
|
-
const raw =
|
|
18255
|
+
const raw = import_node_fs6.default.readFileSync(beadsConfigPath(), "utf8");
|
|
18088
18256
|
const cfg = JSON.parse(raw);
|
|
18089
18257
|
return cfg.enabled !== false;
|
|
18090
18258
|
} catch {
|
|
@@ -18093,10 +18261,11 @@ function readBeadsEnabled() {
|
|
|
18093
18261
|
}
|
|
18094
18262
|
function persistBeadsConfig(cfg) {
|
|
18095
18263
|
const file = beadsConfigPath();
|
|
18096
|
-
|
|
18264
|
+
import_node_fs6.default.mkdirSync(import_node_path4.default.dirname(file), { recursive: true });
|
|
18097
18265
|
const tmp = `${file}.tmp`;
|
|
18098
|
-
|
|
18099
|
-
|
|
18266
|
+
import_node_fs6.default.writeFileSync(tmp, JSON.stringify(cfg), { mode: 384 });
|
|
18267
|
+
import_node_fs6.default.renameSync(tmp, file);
|
|
18268
|
+
restrictToOwner(file);
|
|
18100
18269
|
}
|
|
18101
18270
|
|
|
18102
18271
|
// src/beads/wiring.ts
|
|
@@ -18235,7 +18404,7 @@ var pendingAttachmentFiles = /* @__PURE__ */ new Set();
|
|
|
18235
18404
|
function cleanupAttachmentTempFiles() {
|
|
18236
18405
|
for (const p2 of pendingAttachmentFiles) {
|
|
18237
18406
|
try {
|
|
18238
|
-
|
|
18407
|
+
fs43.unlinkSync(p2);
|
|
18239
18408
|
} catch {
|
|
18240
18409
|
}
|
|
18241
18410
|
}
|
|
@@ -18244,8 +18413,8 @@ function cleanupAttachmentTempFiles() {
|
|
|
18244
18413
|
function saveFilesTemp(files) {
|
|
18245
18414
|
return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
|
|
18246
18415
|
const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
|
|
18247
|
-
const tmpPath =
|
|
18248
|
-
|
|
18416
|
+
const tmpPath = path48.join(os36.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
|
|
18417
|
+
fs43.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
|
|
18249
18418
|
pendingAttachmentFiles.add(tmpPath);
|
|
18250
18419
|
return tmpPath;
|
|
18251
18420
|
});
|
|
@@ -18265,7 +18434,7 @@ var startTask = (ctx, _cmd, parsed) => {
|
|
|
18265
18434
|
setTimeout(() => {
|
|
18266
18435
|
for (const p2 of paths) {
|
|
18267
18436
|
try {
|
|
18268
|
-
|
|
18437
|
+
fs43.unlinkSync(p2);
|
|
18269
18438
|
} catch {
|
|
18270
18439
|
}
|
|
18271
18440
|
pendingAttachmentFiles.delete(p2);
|
|
@@ -18390,7 +18559,7 @@ var sessionTerminated = async (ctx, cmd) => {
|
|
|
18390
18559
|
} catch {
|
|
18391
18560
|
}
|
|
18392
18561
|
try {
|
|
18393
|
-
const proc = (0,
|
|
18562
|
+
const proc = (0, import_child_process21.spawn)("bash", ["-lc", "pm2 delete codeam-pair >/dev/null 2>&1 || true"], {
|
|
18394
18563
|
detached: true,
|
|
18395
18564
|
stdio: "ignore"
|
|
18396
18565
|
});
|
|
@@ -18412,7 +18581,7 @@ var shutdownSession = async (ctx, cmd) => {
|
|
|
18412
18581
|
}
|
|
18413
18582
|
if (ctx.keepAliveCtx.inCodespace && ctx.keepAliveCtx.codespaceName) {
|
|
18414
18583
|
try {
|
|
18415
|
-
const stopProc = (0,
|
|
18584
|
+
const stopProc = (0, import_child_process21.spawn)(
|
|
18416
18585
|
"bash",
|
|
18417
18586
|
["-lc", `sleep 1; gh codespace stop -c ${JSON.stringify(ctx.keepAliveCtx.codespaceName)} >/dev/null 2>&1 || true`],
|
|
18418
18587
|
{ detached: true, stdio: "ignore" }
|
|
@@ -18422,7 +18591,7 @@ var shutdownSession = async (ctx, cmd) => {
|
|
|
18422
18591
|
}
|
|
18423
18592
|
}
|
|
18424
18593
|
try {
|
|
18425
|
-
const proc = (0,
|
|
18594
|
+
const proc = (0, import_child_process21.spawn)("bash", ["-lc", "pm2 delete codeam-pair >/dev/null 2>&1 || true"], {
|
|
18426
18595
|
detached: true,
|
|
18427
18596
|
stdio: "ignore"
|
|
18428
18597
|
});
|
|
@@ -18466,9 +18635,9 @@ var listFiles = async (ctx, cmd, parsed) => {
|
|
|
18466
18635
|
await ctx.relay.sendResult(cmd.id, "completed", result);
|
|
18467
18636
|
};
|
|
18468
18637
|
var envReadH = async (ctx, cmd) => {
|
|
18469
|
-
const envPath =
|
|
18638
|
+
const envPath = path48.join(process.cwd(), ".env");
|
|
18470
18639
|
try {
|
|
18471
|
-
const raw = await
|
|
18640
|
+
const raw = await fs43.promises.readFile(envPath, "utf8");
|
|
18472
18641
|
await ctx.relay.sendResult(cmd.id, "completed", {
|
|
18473
18642
|
exists: true,
|
|
18474
18643
|
vars: parseDotenv(raw)
|
|
@@ -18499,14 +18668,14 @@ var envWriteH = async (ctx, cmd, parsed) => {
|
|
|
18499
18668
|
}
|
|
18500
18669
|
seen.add(v.key);
|
|
18501
18670
|
}
|
|
18502
|
-
const envPath =
|
|
18503
|
-
const tmpPath =
|
|
18671
|
+
const envPath = path48.join(process.cwd(), ".env");
|
|
18672
|
+
const tmpPath = path48.join(process.cwd(), ".env.codeam.tmp");
|
|
18504
18673
|
try {
|
|
18505
|
-
await
|
|
18506
|
-
await
|
|
18674
|
+
await fs43.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
|
|
18675
|
+
await fs43.promises.rename(tmpPath, envPath);
|
|
18507
18676
|
await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
|
|
18508
18677
|
} catch (err) {
|
|
18509
|
-
await
|
|
18678
|
+
await fs43.promises.rm(tmpPath, { force: true }).catch(() => void 0);
|
|
18510
18679
|
await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
|
|
18511
18680
|
}
|
|
18512
18681
|
};
|
|
@@ -18524,7 +18693,7 @@ var headroomConfigureH = async (ctx, cmd, parsed) => {
|
|
|
18524
18693
|
let configuredAgent = rawAgentId;
|
|
18525
18694
|
if (!configuredAgent) {
|
|
18526
18695
|
try {
|
|
18527
|
-
const raw = JSON.parse(
|
|
18696
|
+
const raw = JSON.parse(fs43.readFileSync(headroomConfigPath(), "utf8"));
|
|
18528
18697
|
configuredAgent = raw.agent ?? "";
|
|
18529
18698
|
} catch {
|
|
18530
18699
|
}
|
|
@@ -18558,7 +18727,7 @@ var headroomConfigureH = async (ctx, cmd, parsed) => {
|
|
|
18558
18727
|
persist: persistHeadroomConfig,
|
|
18559
18728
|
readEnabled: () => {
|
|
18560
18729
|
try {
|
|
18561
|
-
const raw = JSON.parse(
|
|
18730
|
+
const raw = JSON.parse(fs43.readFileSync(headroomConfigPath(), "utf8"));
|
|
18562
18731
|
return raw.enabled === true;
|
|
18563
18732
|
} catch {
|
|
18564
18733
|
return false;
|
|
@@ -18610,7 +18779,7 @@ var headroomConfigureH = async (ctx, cmd, parsed) => {
|
|
|
18610
18779
|
restoreAgentHeadroomConfig: (kind) => restoreAgentHeadroomConfig(kind),
|
|
18611
18780
|
stopProxy: () => {
|
|
18612
18781
|
try {
|
|
18613
|
-
const p2 = (0,
|
|
18782
|
+
const p2 = (0, import_child_process21.spawn)("pkill", ["-TERM", "-f", "headroom.*proxy"], {
|
|
18614
18783
|
detached: true,
|
|
18615
18784
|
stdio: "ignore"
|
|
18616
18785
|
});
|
|
@@ -18652,7 +18821,7 @@ var headroomBudgetH = async (ctx, cmd) => {
|
|
|
18652
18821
|
}
|
|
18653
18822
|
let headroomActive = false;
|
|
18654
18823
|
try {
|
|
18655
|
-
const raw = JSON.parse(
|
|
18824
|
+
const raw = JSON.parse(fs43.readFileSync(headroomConfigPath(), "utf8"));
|
|
18656
18825
|
headroomActive = raw.enabled === true;
|
|
18657
18826
|
} catch {
|
|
18658
18827
|
}
|
|
@@ -18662,7 +18831,7 @@ var headroomBudgetH = async (ctx, cmd) => {
|
|
|
18662
18831
|
}
|
|
18663
18832
|
let existingConfig = { enabled: true };
|
|
18664
18833
|
try {
|
|
18665
|
-
existingConfig = JSON.parse(
|
|
18834
|
+
existingConfig = JSON.parse(fs43.readFileSync(headroomConfigPath(), "utf8"));
|
|
18666
18835
|
} catch {
|
|
18667
18836
|
}
|
|
18668
18837
|
if (payload.budgetEnabled && payload.budgetUsd != null) {
|
|
@@ -18686,37 +18855,11 @@ var headroomBudgetH = async (ctx, cmd) => {
|
|
|
18686
18855
|
delete process.env["HEADROOM_BUDGET"];
|
|
18687
18856
|
delete process.env["HEADROOM_BUDGET_PERIOD"];
|
|
18688
18857
|
}
|
|
18689
|
-
|
|
18690
|
-
|
|
18691
|
-
|
|
18692
|
-
|
|
18693
|
-
|
|
18694
|
-
killer.once("error", () => {
|
|
18695
|
-
});
|
|
18696
|
-
killer.unref();
|
|
18697
|
-
} catch {
|
|
18698
|
-
}
|
|
18699
|
-
try {
|
|
18700
|
-
const proxyEnv = { ...process.env, HEADROOM_KOMPRESS_BACKEND: "onnx_cpu" };
|
|
18701
|
-
const proxy = (0, import_child_process20.spawn)(
|
|
18702
|
-
"headroom",
|
|
18703
|
-
["proxy", "--port", "8787", ...buildBudgetProxyArgs(proxyEnv)],
|
|
18704
|
-
{
|
|
18705
|
-
stdio: "ignore",
|
|
18706
|
-
detached: true,
|
|
18707
|
-
env: proxyEnv
|
|
18708
|
-
}
|
|
18709
|
-
);
|
|
18710
|
-
proxy.once("error", (e) => {
|
|
18711
|
-
log.warn("headroom-budget", `proxy relaunch error (best-effort): ${e.message}`);
|
|
18712
|
-
});
|
|
18713
|
-
proxy.unref();
|
|
18714
|
-
} catch (e) {
|
|
18715
|
-
log.warn(
|
|
18716
|
-
"headroom-budget",
|
|
18717
|
-
`proxy relaunch failed (best-effort): ${e instanceof Error ? e.message : String(e)}`
|
|
18718
|
-
);
|
|
18719
|
-
}
|
|
18858
|
+
const budgetSpec = payload.budgetEnabled && payload.budgetUsd != null ? {
|
|
18859
|
+
budgetUsd: payload.budgetUsd,
|
|
18860
|
+
budgetPeriod: payload.budgetPeriod ?? "daily"
|
|
18861
|
+
} : null;
|
|
18862
|
+
await applyBudgetToHeadroom(budgetSpec, makeRealApplyBudgetDeps());
|
|
18720
18863
|
await ctx.relay.sendResult(cmd.id, "completed", { applied: true });
|
|
18721
18864
|
};
|
|
18722
18865
|
var _beadsEmitChain = Promise.resolve();
|
|
@@ -19214,8 +19357,8 @@ function normalizeDetectionForSpawn(detection, cwd) {
|
|
|
19214
19357
|
if (args2.length === 0) return detection;
|
|
19215
19358
|
const binName = args2[0];
|
|
19216
19359
|
if (binName.startsWith("-")) return detection;
|
|
19217
|
-
const binPath =
|
|
19218
|
-
if (!
|
|
19360
|
+
const binPath = path48.join(cwd, "node_modules", ".bin", binName);
|
|
19361
|
+
if (!fs43.existsSync(binPath)) return detection;
|
|
19219
19362
|
return {
|
|
19220
19363
|
...detection,
|
|
19221
19364
|
command: binPath,
|
|
@@ -19450,7 +19593,7 @@ function startPreviewFromDetection(ctx, detection, pluginAuthToken) {
|
|
|
19450
19593
|
"BOOT_SEQUENCE",
|
|
19451
19594
|
`${spawnable.command} ${spawnable.args.join(" ")}`
|
|
19452
19595
|
);
|
|
19453
|
-
const devServer = (0,
|
|
19596
|
+
const devServer = (0, import_child_process21.spawn)(spawnable.command, spawnable.args, {
|
|
19454
19597
|
cwd: process.cwd(),
|
|
19455
19598
|
env: { ...process.env, ...spawnable.env ?? {} },
|
|
19456
19599
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -19600,7 +19743,7 @@ function startPreviewFromDetection(ctx, detection, pluginAuthToken) {
|
|
|
19600
19743
|
`cloudflared quick tunnel (retry ${attempt}/${MAX_TUNNEL_ATTEMPTS})`
|
|
19601
19744
|
);
|
|
19602
19745
|
}
|
|
19603
|
-
const candidate = (0,
|
|
19746
|
+
const candidate = (0, import_child_process21.spawn)(
|
|
19604
19747
|
bin,
|
|
19605
19748
|
["tunnel", "--url", `http://localhost:${detection.port}`],
|
|
19606
19749
|
{ stdio: ["ignore", "pipe", "pipe"] }
|
|
@@ -19796,13 +19939,13 @@ async function dispatchCommand(ctx, cmd) {
|
|
|
19796
19939
|
}
|
|
19797
19940
|
|
|
19798
19941
|
// src/commands/start/keep-alive.ts
|
|
19799
|
-
var
|
|
19942
|
+
var import_child_process22 = require("child_process");
|
|
19800
19943
|
function buildKeepAlive(ctx) {
|
|
19801
19944
|
let timer = null;
|
|
19802
19945
|
async function setIdleTimeout(minutes) {
|
|
19803
19946
|
if (!ctx.inCodespace || !ctx.codespaceName) return;
|
|
19804
19947
|
await new Promise((resolve7) => {
|
|
19805
|
-
const proc = (0,
|
|
19948
|
+
const proc = (0, import_child_process22.spawn)(
|
|
19806
19949
|
"gh",
|
|
19807
19950
|
[
|
|
19808
19951
|
"api",
|
|
@@ -20033,12 +20176,12 @@ function readTokenFromArgs(args2) {
|
|
|
20033
20176
|
}
|
|
20034
20177
|
const fileFlag = args2.find((a) => a.startsWith("--token-file="));
|
|
20035
20178
|
if (fileFlag) {
|
|
20036
|
-
const
|
|
20179
|
+
const path62 = fileFlag.slice("--token-file=".length);
|
|
20037
20180
|
try {
|
|
20038
|
-
const content =
|
|
20039
|
-
if (content.length === 0) fail(`--token-file ${
|
|
20181
|
+
const content = fs44.readFileSync(path62, "utf8").trim();
|
|
20182
|
+
if (content.length === 0) fail(`--token-file ${path62} is empty`);
|
|
20040
20183
|
try {
|
|
20041
|
-
|
|
20184
|
+
fs44.unlinkSync(path62);
|
|
20042
20185
|
} catch {
|
|
20043
20186
|
}
|
|
20044
20187
|
return content;
|
|
@@ -20064,7 +20207,7 @@ async function claimOnce(token, pluginId, pluginSecretHash) {
|
|
|
20064
20207
|
pluginId,
|
|
20065
20208
|
ideName: "codeam-cli (codespace)",
|
|
20066
20209
|
ideVersion: process.env.npm_package_version ?? "unknown",
|
|
20067
|
-
hostname:
|
|
20210
|
+
hostname: os37.hostname(),
|
|
20068
20211
|
codespaceName: process.env.CODESPACE_NAME ?? "",
|
|
20069
20212
|
// Current git branch of the codespace's working directory, so the
|
|
20070
20213
|
// backend can populate `PairedSession.branch` for the codespace pair.
|
|
@@ -20125,7 +20268,7 @@ async function claim(token, pluginId, pluginSecretHash) {
|
|
|
20125
20268
|
}
|
|
20126
20269
|
}
|
|
20127
20270
|
function pairAutoLockPath() {
|
|
20128
|
-
return
|
|
20271
|
+
return path49.join(os37.homedir(), ".codeam", "pair-auto.lock");
|
|
20129
20272
|
}
|
|
20130
20273
|
function isLivePairAuto(pid) {
|
|
20131
20274
|
if (!Number.isInteger(pid) || pid <= 0 || pid === process.pid) return false;
|
|
@@ -20135,7 +20278,7 @@ function isLivePairAuto(pid) {
|
|
|
20135
20278
|
if (e.code !== "EPERM") return false;
|
|
20136
20279
|
}
|
|
20137
20280
|
try {
|
|
20138
|
-
return
|
|
20281
|
+
return fs44.readFileSync(`/proc/${pid}/cmdline`, "utf8").includes("codeam");
|
|
20139
20282
|
} catch {
|
|
20140
20283
|
return true;
|
|
20141
20284
|
}
|
|
@@ -20145,24 +20288,24 @@ function isLiveCodeam(pid) {
|
|
|
20145
20288
|
}
|
|
20146
20289
|
function daemonLockPath(sessionId) {
|
|
20147
20290
|
const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
20148
|
-
return
|
|
20291
|
+
return path49.join(os37.homedir(), ".codeam", `daemon-${safe}.lock`);
|
|
20149
20292
|
}
|
|
20150
20293
|
function acquireDaemonLock(sessionId) {
|
|
20151
20294
|
const lockPath = daemonLockPath(sessionId);
|
|
20152
20295
|
try {
|
|
20153
|
-
|
|
20296
|
+
fs44.mkdirSync(path49.dirname(lockPath), { recursive: true });
|
|
20154
20297
|
try {
|
|
20155
|
-
|
|
20298
|
+
fs44.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
|
|
20156
20299
|
} catch (e) {
|
|
20157
20300
|
if (e.code !== "EEXIST") throw e;
|
|
20158
|
-
const holder = Number(
|
|
20301
|
+
const holder = Number(fs44.readFileSync(lockPath, "utf8").trim());
|
|
20159
20302
|
if (holder && holder !== process.pid && isLiveCodeam(holder)) return false;
|
|
20160
|
-
|
|
20303
|
+
fs44.writeFileSync(lockPath, String(process.pid));
|
|
20161
20304
|
}
|
|
20162
20305
|
const release3 = () => {
|
|
20163
20306
|
try {
|
|
20164
|
-
if (
|
|
20165
|
-
|
|
20307
|
+
if (fs44.existsSync(lockPath) && Number(fs44.readFileSync(lockPath, "utf8").trim()) === process.pid) {
|
|
20308
|
+
fs44.unlinkSync(lockPath);
|
|
20166
20309
|
}
|
|
20167
20310
|
} catch {
|
|
20168
20311
|
}
|
|
@@ -20184,19 +20327,19 @@ function acquireDaemonLock(sessionId) {
|
|
|
20184
20327
|
function acquireSingletonLock() {
|
|
20185
20328
|
const lockPath = pairAutoLockPath();
|
|
20186
20329
|
try {
|
|
20187
|
-
|
|
20330
|
+
fs44.mkdirSync(path49.dirname(lockPath), { recursive: true });
|
|
20188
20331
|
try {
|
|
20189
|
-
|
|
20332
|
+
fs44.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
|
|
20190
20333
|
} catch (e) {
|
|
20191
20334
|
if (e.code !== "EEXIST") throw e;
|
|
20192
|
-
const holder = Number(
|
|
20335
|
+
const holder = Number(fs44.readFileSync(lockPath, "utf8").trim());
|
|
20193
20336
|
if (isLivePairAuto(holder)) return false;
|
|
20194
|
-
|
|
20337
|
+
fs44.writeFileSync(lockPath, String(process.pid));
|
|
20195
20338
|
}
|
|
20196
20339
|
process.once("exit", () => {
|
|
20197
20340
|
try {
|
|
20198
|
-
if (
|
|
20199
|
-
|
|
20341
|
+
if (fs44.existsSync(lockPath) && Number(fs44.readFileSync(lockPath, "utf8").trim()) === process.pid) {
|
|
20342
|
+
fs44.unlinkSync(lockPath);
|
|
20200
20343
|
}
|
|
20201
20344
|
} catch {
|
|
20202
20345
|
}
|
|
@@ -20278,7 +20421,7 @@ async function pairAuto(args2) {
|
|
|
20278
20421
|
}
|
|
20279
20422
|
|
|
20280
20423
|
// src/services/headroom/wrap-launch.ts
|
|
20281
|
-
var
|
|
20424
|
+
var import_node_child_process16 = require("child_process");
|
|
20282
20425
|
function wrapWithHeadroom(launch, opts) {
|
|
20283
20426
|
if (!opts.enabled || !opts.headroomPresent) return launch;
|
|
20284
20427
|
return {
|
|
@@ -20291,7 +20434,7 @@ var _present;
|
|
|
20291
20434
|
function headroomPresent() {
|
|
20292
20435
|
if (_present !== void 0) return Promise.resolve(_present);
|
|
20293
20436
|
return new Promise((resolve7) => {
|
|
20294
|
-
(0,
|
|
20437
|
+
(0, import_node_child_process16.execFile)("headroom", ["--version"], (err) => {
|
|
20295
20438
|
_present = !err;
|
|
20296
20439
|
resolve7(_present);
|
|
20297
20440
|
});
|
|
@@ -20641,19 +20784,19 @@ var AgentService = class _AgentService {
|
|
|
20641
20784
|
};
|
|
20642
20785
|
|
|
20643
20786
|
// src/agents/acp/adapters.ts
|
|
20644
|
-
var
|
|
20787
|
+
var path50 = __toESM(require("path"));
|
|
20645
20788
|
var require_ = require;
|
|
20646
20789
|
function resolveBin(pkgName, binName) {
|
|
20647
20790
|
try {
|
|
20648
20791
|
const manifestPath = require_.resolve(`${pkgName}/package.json`);
|
|
20649
20792
|
const manifest = require_(`${pkgName}/package.json`);
|
|
20650
|
-
const pkgDir =
|
|
20793
|
+
const pkgDir = path50.dirname(manifestPath);
|
|
20651
20794
|
const bin = manifest.bin;
|
|
20652
20795
|
if (!bin) return null;
|
|
20653
|
-
if (typeof bin === "string") return
|
|
20796
|
+
if (typeof bin === "string") return path50.resolve(pkgDir, bin);
|
|
20654
20797
|
const target = binName ?? Object.keys(bin)[0];
|
|
20655
20798
|
if (!target || !bin[target]) return null;
|
|
20656
|
-
return
|
|
20799
|
+
return path50.resolve(pkgDir, bin[target]);
|
|
20657
20800
|
} catch {
|
|
20658
20801
|
return null;
|
|
20659
20802
|
}
|
|
@@ -20723,9 +20866,9 @@ function requiresAcp(agent) {
|
|
|
20723
20866
|
var import_node_crypto7 = require("crypto");
|
|
20724
20867
|
|
|
20725
20868
|
// src/services/history.service.ts
|
|
20726
|
-
var
|
|
20727
|
-
var
|
|
20728
|
-
var
|
|
20869
|
+
var fs45 = __toESM(require("fs"));
|
|
20870
|
+
var path51 = __toESM(require("path"));
|
|
20871
|
+
var os38 = __toESM(require("os"));
|
|
20729
20872
|
var https7 = __toESM(require("https"));
|
|
20730
20873
|
var http6 = __toESM(require("http"));
|
|
20731
20874
|
var import_zod2 = require("zod");
|
|
@@ -20752,7 +20895,7 @@ function parseJsonl(filePath) {
|
|
|
20752
20895
|
const messages = [];
|
|
20753
20896
|
let raw;
|
|
20754
20897
|
try {
|
|
20755
|
-
raw =
|
|
20898
|
+
raw = fs45.readFileSync(filePath, "utf8");
|
|
20756
20899
|
} catch (err) {
|
|
20757
20900
|
if (err.code !== "ENOENT") {
|
|
20758
20901
|
log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
|
|
@@ -20893,7 +21036,7 @@ var HistoryService = class _HistoryService {
|
|
|
20893
21036
|
return this._quotaPercent === null || Date.now() - this._quotaFetchedAt > ttlMs;
|
|
20894
21037
|
}
|
|
20895
21038
|
get projectDir() {
|
|
20896
|
-
return this.runtime.resolveHistoryDir(this.cwd) ??
|
|
21039
|
+
return this.runtime.resolveHistoryDir(this.cwd) ?? path51.join(os38.homedir(), ".claude", "projects", encodeCwd(this.cwd));
|
|
20897
21040
|
}
|
|
20898
21041
|
/** Set the current Claude conversation ID (extracted from /cost command or session start) */
|
|
20899
21042
|
setCurrentConversationId(id) {
|
|
@@ -20905,7 +21048,7 @@ var HistoryService = class _HistoryService {
|
|
|
20905
21048
|
/** Return the current message count in the active conversation. */
|
|
20906
21049
|
getCurrentMessageCount() {
|
|
20907
21050
|
if (!this.currentConversationId) return 0;
|
|
20908
|
-
const filePath =
|
|
21051
|
+
const filePath = path51.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
20909
21052
|
return parseJsonl(filePath).length;
|
|
20910
21053
|
}
|
|
20911
21054
|
/**
|
|
@@ -20916,7 +21059,7 @@ var HistoryService = class _HistoryService {
|
|
|
20916
21059
|
const deadline = Date.now() + timeoutMs;
|
|
20917
21060
|
while (Date.now() < deadline) {
|
|
20918
21061
|
if (!this.currentConversationId) return null;
|
|
20919
|
-
const filePath =
|
|
21062
|
+
const filePath = path51.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
20920
21063
|
const messages = parseJsonl(filePath);
|
|
20921
21064
|
if (messages.length > previousCount) {
|
|
20922
21065
|
for (let i = messages.length - 1; i >= previousCount; i--) {
|
|
@@ -20942,16 +21085,16 @@ var HistoryService = class _HistoryService {
|
|
|
20942
21085
|
const dir = this.projectDir;
|
|
20943
21086
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
20944
21087
|
try {
|
|
20945
|
-
const files =
|
|
21088
|
+
const files = fs45.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
20946
21089
|
try {
|
|
20947
|
-
const stat3 =
|
|
21090
|
+
const stat3 = fs45.statSync(path51.join(dir, e.name));
|
|
20948
21091
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
20949
21092
|
} catch {
|
|
20950
21093
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
20951
21094
|
}
|
|
20952
21095
|
}).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
20953
21096
|
if (files.length > 0) {
|
|
20954
|
-
this.currentConversationId =
|
|
21097
|
+
this.currentConversationId = path51.basename(files[0].name, ".jsonl");
|
|
20955
21098
|
}
|
|
20956
21099
|
} catch {
|
|
20957
21100
|
}
|
|
@@ -20985,13 +21128,13 @@ var HistoryService = class _HistoryService {
|
|
|
20985
21128
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
20986
21129
|
let entries;
|
|
20987
21130
|
try {
|
|
20988
|
-
entries =
|
|
21131
|
+
entries = fs45.readdirSync(dir, { withFileTypes: true });
|
|
20989
21132
|
} catch {
|
|
20990
21133
|
return null;
|
|
20991
21134
|
}
|
|
20992
21135
|
const files = entries.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
20993
21136
|
try {
|
|
20994
|
-
const stat3 =
|
|
21137
|
+
const stat3 = fs45.statSync(path51.join(dir, e.name));
|
|
20995
21138
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
20996
21139
|
} catch {
|
|
20997
21140
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
@@ -21000,12 +21143,12 @@ var HistoryService = class _HistoryService {
|
|
|
21000
21143
|
if (files.length === 0) return null;
|
|
21001
21144
|
const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
|
|
21002
21145
|
if (!files.some((f) => f.name === targetFile)) return null;
|
|
21003
|
-
return this.extractUsageFromFile(
|
|
21146
|
+
return this.extractUsageFromFile(path51.join(dir, targetFile));
|
|
21004
21147
|
}
|
|
21005
21148
|
extractUsageFromFile(filePath) {
|
|
21006
21149
|
let raw;
|
|
21007
21150
|
try {
|
|
21008
|
-
raw =
|
|
21151
|
+
raw = fs45.readFileSync(filePath, "utf8");
|
|
21009
21152
|
} catch {
|
|
21010
21153
|
return null;
|
|
21011
21154
|
}
|
|
@@ -21050,9 +21193,9 @@ var HistoryService = class _HistoryService {
|
|
|
21050
21193
|
let totalCost = 0;
|
|
21051
21194
|
let files;
|
|
21052
21195
|
try {
|
|
21053
|
-
files =
|
|
21196
|
+
files = fs45.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
|
|
21054
21197
|
try {
|
|
21055
|
-
return
|
|
21198
|
+
return fs45.statSync(path51.join(projectDir, f)).mtimeMs >= monthStartMs;
|
|
21056
21199
|
} catch {
|
|
21057
21200
|
return false;
|
|
21058
21201
|
}
|
|
@@ -21063,7 +21206,7 @@ var HistoryService = class _HistoryService {
|
|
|
21063
21206
|
for (const file of files) {
|
|
21064
21207
|
let raw;
|
|
21065
21208
|
try {
|
|
21066
|
-
raw =
|
|
21209
|
+
raw = fs45.readFileSync(path51.join(projectDir, file), "utf8");
|
|
21067
21210
|
} catch {
|
|
21068
21211
|
continue;
|
|
21069
21212
|
}
|
|
@@ -21142,7 +21285,7 @@ var HistoryService = class _HistoryService {
|
|
|
21142
21285
|
if (this.runtime.resolveHistoryFile) {
|
|
21143
21286
|
return this.runtime.resolveHistoryFile(this.cwd, sessionId);
|
|
21144
21287
|
}
|
|
21145
|
-
return
|
|
21288
|
+
return path51.join(this.projectDir, `${sessionId}.jsonl`);
|
|
21146
21289
|
}
|
|
21147
21290
|
/**
|
|
21148
21291
|
* Parse a conversation's messages from disk, agent-aware. Claude uses the
|
|
@@ -21176,7 +21319,7 @@ var HistoryService = class _HistoryService {
|
|
|
21176
21319
|
};
|
|
21177
21320
|
});
|
|
21178
21321
|
}
|
|
21179
|
-
return parseJsonl(
|
|
21322
|
+
return parseJsonl(path51.join(this.projectDir, `${sessionId}.jsonl`));
|
|
21180
21323
|
}
|
|
21181
21324
|
async loadConversation(sessionId) {
|
|
21182
21325
|
const messages = this.readConversation(sessionId);
|
|
@@ -21232,7 +21375,7 @@ var HistoryService = class _HistoryService {
|
|
|
21232
21375
|
if (!filePath) return false;
|
|
21233
21376
|
let mtimeMs;
|
|
21234
21377
|
try {
|
|
21235
|
-
mtimeMs =
|
|
21378
|
+
mtimeMs = fs45.statSync(filePath).mtimeMs;
|
|
21236
21379
|
} catch {
|
|
21237
21380
|
return false;
|
|
21238
21381
|
}
|
|
@@ -21300,11 +21443,11 @@ var HistoryService = class _HistoryService {
|
|
|
21300
21443
|
};
|
|
21301
21444
|
|
|
21302
21445
|
// src/agents/acp/client.ts
|
|
21303
|
-
var
|
|
21304
|
-
var
|
|
21446
|
+
var import_node_child_process17 = require("child_process");
|
|
21447
|
+
var fs46 = __toESM(require("fs/promises"));
|
|
21305
21448
|
var fsSync = __toESM(require("fs"));
|
|
21306
|
-
var
|
|
21307
|
-
var
|
|
21449
|
+
var os39 = __toESM(require("os"));
|
|
21450
|
+
var path52 = __toESM(require("path"));
|
|
21308
21451
|
var import_node_stream = require("stream");
|
|
21309
21452
|
|
|
21310
21453
|
// ../../node_modules/@agentclientprotocol/sdk/dist/acp.js
|
|
@@ -23851,7 +23994,7 @@ var AcpClient = class {
|
|
|
23851
23994
|
"acpClient",
|
|
23852
23995
|
`spawn cmd=${adapter.command} args=[${adapter.args.join(",")}] cwd=${cwd}`
|
|
23853
23996
|
);
|
|
23854
|
-
const child = (0,
|
|
23997
|
+
const child = (0, import_node_child_process17.spawn)(adapter.command, adapter.args, {
|
|
23855
23998
|
cwd,
|
|
23856
23999
|
// extraEnv (e.g. CLAUDE_CODE_DISABLE_1M_CONTEXT=1 on an on-demand
|
|
23857
24000
|
// re-spawn) layers over process.env; PATH stays last so the augmented
|
|
@@ -24137,7 +24280,7 @@ var AcpClient = class {
|
|
|
24137
24280
|
},
|
|
24138
24281
|
readTextFile: async (params) => {
|
|
24139
24282
|
try {
|
|
24140
|
-
const content = await
|
|
24283
|
+
const content = await fs46.readFile(params.path, "utf8");
|
|
24141
24284
|
return applyLineRange(content, params.line ?? null, params.limit ?? null);
|
|
24142
24285
|
} catch (err) {
|
|
24143
24286
|
const code = err.code;
|
|
@@ -24157,7 +24300,7 @@ var AcpClient = class {
|
|
|
24157
24300
|
},
|
|
24158
24301
|
writeTextFile: async (params) => {
|
|
24159
24302
|
try {
|
|
24160
|
-
await
|
|
24303
|
+
await fs46.writeFile(params.path, params.content, "utf8");
|
|
24161
24304
|
return {};
|
|
24162
24305
|
} catch (err) {
|
|
24163
24306
|
const code = err.code;
|
|
@@ -24206,25 +24349,25 @@ function applyLineRange(content, line, limit) {
|
|
|
24206
24349
|
return { content: lines.slice(start2, end).join("\n") };
|
|
24207
24350
|
}
|
|
24208
24351
|
function knownAgentBinaryDirs() {
|
|
24209
|
-
const home =
|
|
24352
|
+
const home = os39.homedir();
|
|
24210
24353
|
const out2 = [];
|
|
24211
24354
|
out2.push("/tmp/codeam-node20/bin");
|
|
24212
24355
|
for (const root of [
|
|
24213
24356
|
"/usr/local/share/nvm/versions/node",
|
|
24214
|
-
|
|
24357
|
+
path52.join(home, ".nvm/versions/node")
|
|
24215
24358
|
]) {
|
|
24216
24359
|
try {
|
|
24217
24360
|
for (const child of fsSync.readdirSync(root)) {
|
|
24218
|
-
out2.push(
|
|
24361
|
+
out2.push(path52.join(root, child, "bin"));
|
|
24219
24362
|
}
|
|
24220
24363
|
} catch {
|
|
24221
24364
|
}
|
|
24222
24365
|
}
|
|
24223
|
-
out2.push(
|
|
24366
|
+
out2.push(path52.join(home, ".volta/bin"));
|
|
24224
24367
|
out2.push("/usr/local/bin");
|
|
24225
24368
|
out2.push("/usr/bin");
|
|
24226
|
-
out2.push(
|
|
24227
|
-
out2.push(
|
|
24369
|
+
out2.push(path52.join(home, ".local/bin"));
|
|
24370
|
+
out2.push(path52.join(home, "bin"));
|
|
24228
24371
|
return out2.filter((p2) => {
|
|
24229
24372
|
try {
|
|
24230
24373
|
return fsSync.statSync(p2).isDirectory();
|
|
@@ -24235,7 +24378,7 @@ function knownAgentBinaryDirs() {
|
|
|
24235
24378
|
}
|
|
24236
24379
|
function expandPathForAgentBinaries(existingPath) {
|
|
24237
24380
|
const existing = new Set(
|
|
24238
|
-
existingPath.split(
|
|
24381
|
+
existingPath.split(path52.delimiter).filter((p2) => p2.length > 0)
|
|
24239
24382
|
);
|
|
24240
24383
|
const additions = [];
|
|
24241
24384
|
for (const dir of knownAgentBinaryDirs()) {
|
|
@@ -24245,7 +24388,7 @@ function expandPathForAgentBinaries(existingPath) {
|
|
|
24245
24388
|
}
|
|
24246
24389
|
}
|
|
24247
24390
|
if (additions.length === 0) return existingPath;
|
|
24248
|
-
return [...additions, existingPath].filter((p2) => p2.length > 0).join(
|
|
24391
|
+
return [...additions, existingPath].filter((p2) => p2.length > 0).join(path52.delimiter);
|
|
24249
24392
|
}
|
|
24250
24393
|
|
|
24251
24394
|
// src/services/streaming/transport.ts
|
|
@@ -24729,16 +24872,16 @@ function commonPrefixLength(a, b) {
|
|
|
24729
24872
|
}
|
|
24730
24873
|
|
|
24731
24874
|
// src/agents/acp/onboarding.ts
|
|
24732
|
-
var
|
|
24733
|
-
var
|
|
24734
|
-
var
|
|
24735
|
-
var
|
|
24875
|
+
var import_child_process23 = require("child_process");
|
|
24876
|
+
var fs47 = __toESM(require("fs"));
|
|
24877
|
+
var os40 = __toESM(require("os"));
|
|
24878
|
+
var path53 = __toESM(require("path"));
|
|
24736
24879
|
var _onboardingSeam = {
|
|
24737
|
-
markerPath: (sessionId) =>
|
|
24738
|
-
exists: (p2) =>
|
|
24880
|
+
markerPath: (sessionId) => path53.join(os40.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
|
|
24881
|
+
exists: (p2) => fs47.existsSync(p2),
|
|
24739
24882
|
write: (p2) => {
|
|
24740
|
-
|
|
24741
|
-
|
|
24883
|
+
fs47.mkdirSync(path53.dirname(p2), { recursive: true });
|
|
24884
|
+
fs47.writeFileSync(p2, "");
|
|
24742
24885
|
},
|
|
24743
24886
|
disabled: () => {
|
|
24744
24887
|
const v = process.env.CODEAM_ONBOARDING_DISABLED;
|
|
@@ -24750,7 +24893,7 @@ var _onboardingSeam = {
|
|
|
24750
24893
|
*/
|
|
24751
24894
|
gitRemoteUrl: (cwd) => {
|
|
24752
24895
|
try {
|
|
24753
|
-
return (0,
|
|
24896
|
+
return (0, import_child_process23.execFileSync)("git", ["-C", cwd, "remote", "get-url", "origin"], {
|
|
24754
24897
|
encoding: "utf8",
|
|
24755
24898
|
stdio: ["ignore", "pipe", "ignore"],
|
|
24756
24899
|
timeout: 2e3
|
|
@@ -24775,7 +24918,7 @@ function resolveRepoName(cwd) {
|
|
|
24775
24918
|
if (name) return name;
|
|
24776
24919
|
}
|
|
24777
24920
|
}
|
|
24778
|
-
const base =
|
|
24921
|
+
const base = path53.basename(cwd || "");
|
|
24779
24922
|
if (base && !isUuid(base)) return base;
|
|
24780
24923
|
return "this project";
|
|
24781
24924
|
}
|
|
@@ -25067,9 +25210,9 @@ function deriveInputSuggestion(finalText) {
|
|
|
25067
25210
|
var import_crypto5 = require("crypto");
|
|
25068
25211
|
|
|
25069
25212
|
// src/services/turn-files/git-changeset.ts
|
|
25070
|
-
var
|
|
25071
|
-
var
|
|
25072
|
-
var
|
|
25213
|
+
var import_child_process24 = require("child_process");
|
|
25214
|
+
var fs48 = __toESM(require("fs/promises"));
|
|
25215
|
+
var path54 = __toESM(require("path"));
|
|
25073
25216
|
async function collectRepoChangeset(opts) {
|
|
25074
25217
|
const status2 = await runGit3(opts.repoRoot, ["status", "--porcelain=v1", "-z"]);
|
|
25075
25218
|
if (status2 === null) return null;
|
|
@@ -25087,7 +25230,7 @@ async function collectRepoChangeset(opts) {
|
|
|
25087
25230
|
let stats;
|
|
25088
25231
|
if (row.fileStatus === "added" && numstatEntry === void 0) {
|
|
25089
25232
|
const lineCount = await readUntrackedLineCount(
|
|
25090
|
-
|
|
25233
|
+
path54.join(opts.repoRoot, row.filePath)
|
|
25091
25234
|
);
|
|
25092
25235
|
stats = { added: lineCount, removed: 0 };
|
|
25093
25236
|
} else {
|
|
@@ -25118,7 +25261,7 @@ function readUntrackedLineCount(absPath) {
|
|
|
25118
25261
|
}
|
|
25119
25262
|
async function defaultReadUntrackedLineCount(absPath) {
|
|
25120
25263
|
try {
|
|
25121
|
-
const content = await
|
|
25264
|
+
const content = await fs48.readFile(absPath, "utf8");
|
|
25122
25265
|
let count = 0;
|
|
25123
25266
|
let pos = -1;
|
|
25124
25267
|
while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
|
|
@@ -25182,7 +25325,7 @@ function defaultRunGit(cwd, args2) {
|
|
|
25182
25325
|
return new Promise((resolve7) => {
|
|
25183
25326
|
let proc;
|
|
25184
25327
|
try {
|
|
25185
|
-
proc = (0,
|
|
25328
|
+
proc = (0, import_child_process24.spawn)("git", args2, { cwd, env: process.env });
|
|
25186
25329
|
} catch {
|
|
25187
25330
|
resolve7(null);
|
|
25188
25331
|
return;
|
|
@@ -25210,7 +25353,7 @@ function defaultRunGit(cwd, args2) {
|
|
|
25210
25353
|
});
|
|
25211
25354
|
}
|
|
25212
25355
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
25213
|
-
const
|
|
25356
|
+
const fs52 = await import("fs/promises");
|
|
25214
25357
|
const out2 = [];
|
|
25215
25358
|
await walk(workingDir, 0);
|
|
25216
25359
|
return out2;
|
|
@@ -25218,7 +25361,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
25218
25361
|
if (depth > maxDepth) return;
|
|
25219
25362
|
let entries = [];
|
|
25220
25363
|
try {
|
|
25221
|
-
const dirents = await
|
|
25364
|
+
const dirents = await fs52.readdir(dir, { withFileTypes: true });
|
|
25222
25365
|
entries = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
25223
25366
|
} catch {
|
|
25224
25367
|
return;
|
|
@@ -25229,8 +25372,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
25229
25372
|
if (hasGit) {
|
|
25230
25373
|
out2.push({
|
|
25231
25374
|
repoRoot: dir,
|
|
25232
|
-
repoPath:
|
|
25233
|
-
repoName:
|
|
25375
|
+
repoPath: path54.relative(workingDir, dir),
|
|
25376
|
+
repoName: path54.basename(dir)
|
|
25234
25377
|
});
|
|
25235
25378
|
return;
|
|
25236
25379
|
}
|
|
@@ -25238,14 +25381,14 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
25238
25381
|
if (!entry.isDirectory) continue;
|
|
25239
25382
|
if (entry.name === "node_modules") continue;
|
|
25240
25383
|
if (entry.name === "dist" || entry.name === "build") continue;
|
|
25241
|
-
await walk(
|
|
25384
|
+
await walk(path54.join(dir, entry.name), depth + 1);
|
|
25242
25385
|
}
|
|
25243
25386
|
}
|
|
25244
25387
|
}
|
|
25245
25388
|
|
|
25246
25389
|
// src/services/turn-files/files-outbox.ts
|
|
25247
|
-
var
|
|
25248
|
-
var
|
|
25390
|
+
var fs49 = __toESM(require("fs/promises"));
|
|
25391
|
+
var path55 = __toESM(require("path"));
|
|
25249
25392
|
var import_os7 = require("os");
|
|
25250
25393
|
var HOME_OUTBOX_DIR = ".codeam/outbox";
|
|
25251
25394
|
var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -25278,16 +25421,16 @@ var FilesOutbox = class {
|
|
|
25278
25421
|
backoffIndex = 0;
|
|
25279
25422
|
stopped = false;
|
|
25280
25423
|
constructor(opts) {
|
|
25281
|
-
const base = opts.baseDir ??
|
|
25282
|
-
this.filePath =
|
|
25424
|
+
const base = opts.baseDir ?? path55.join(homeDir(), HOME_OUTBOX_DIR);
|
|
25425
|
+
this.filePath = path55.join(base, `${opts.sessionId}.jsonl`);
|
|
25283
25426
|
this.post = opts.post;
|
|
25284
25427
|
this.autoSchedule = opts.autoSchedule !== false;
|
|
25285
25428
|
}
|
|
25286
25429
|
/** Persist the entry to disk and trigger a flush. Returns once the
|
|
25287
25430
|
* line is durable on disk (not once the POST succeeds). */
|
|
25288
25431
|
async enqueue(entry) {
|
|
25289
|
-
await
|
|
25290
|
-
await
|
|
25432
|
+
await fs49.mkdir(path55.dirname(this.filePath), { recursive: true });
|
|
25433
|
+
await fs49.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
|
|
25291
25434
|
this.backoffIndex = 0;
|
|
25292
25435
|
if (this.autoSchedule) this.scheduleFlush(0);
|
|
25293
25436
|
}
|
|
@@ -25376,7 +25519,7 @@ var FilesOutbox = class {
|
|
|
25376
25519
|
async readAll() {
|
|
25377
25520
|
let raw = "";
|
|
25378
25521
|
try {
|
|
25379
|
-
raw = await
|
|
25522
|
+
raw = await fs49.readFile(this.filePath, "utf8");
|
|
25380
25523
|
} catch {
|
|
25381
25524
|
return [];
|
|
25382
25525
|
}
|
|
@@ -25400,12 +25543,12 @@ var FilesOutbox = class {
|
|
|
25400
25543
|
async rewrite(entries) {
|
|
25401
25544
|
const tmpPath = `${this.filePath}.${process.pid}.tmp`;
|
|
25402
25545
|
if (entries.length === 0) {
|
|
25403
|
-
await
|
|
25546
|
+
await fs49.unlink(this.filePath).catch(() => void 0);
|
|
25404
25547
|
return;
|
|
25405
25548
|
}
|
|
25406
25549
|
const payload = entries.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
25407
|
-
await
|
|
25408
|
-
await
|
|
25550
|
+
await fs49.writeFile(tmpPath, payload, "utf8");
|
|
25551
|
+
await fs49.rename(tmpPath, this.filePath);
|
|
25409
25552
|
}
|
|
25410
25553
|
};
|
|
25411
25554
|
function applyJitter(ms) {
|
|
@@ -26382,9 +26525,9 @@ async function runAcpSession(opts) {
|
|
|
26382
26525
|
});
|
|
26383
26526
|
let _budgetReachedPosted = false;
|
|
26384
26527
|
const relaunchProxyWithoutBudget = async () => {
|
|
26385
|
-
const { spawn:
|
|
26528
|
+
const { spawn: spawn33 } = await import("child_process");
|
|
26386
26529
|
try {
|
|
26387
|
-
const killer =
|
|
26530
|
+
const killer = spawn33("pkill", ["-TERM", "-f", "headroom.*proxy"], {
|
|
26388
26531
|
detached: true,
|
|
26389
26532
|
stdio: "ignore"
|
|
26390
26533
|
});
|
|
@@ -26396,7 +26539,7 @@ async function runAcpSession(opts) {
|
|
|
26396
26539
|
await new Promise((r) => setTimeout(r, 500));
|
|
26397
26540
|
const proxyEnv = buildRelaunchProxyEnv(process.env);
|
|
26398
26541
|
try {
|
|
26399
|
-
const proxy =
|
|
26542
|
+
const proxy = spawn33(
|
|
26400
26543
|
"headroom",
|
|
26401
26544
|
["proxy", "--port", "8787"],
|
|
26402
26545
|
{ stdio: "ignore", detached: true, env: proxyEnv }
|
|
@@ -28034,15 +28177,15 @@ function fetchQuotaUsage(runtime, historySvc) {
|
|
|
28034
28177
|
}
|
|
28035
28178
|
|
|
28036
28179
|
// src/agents/claude/onboarding.ts
|
|
28037
|
-
var
|
|
28038
|
-
var
|
|
28039
|
-
var
|
|
28180
|
+
var fs50 = __toESM(require("fs"));
|
|
28181
|
+
var os41 = __toESM(require("os"));
|
|
28182
|
+
var path56 = __toESM(require("path"));
|
|
28040
28183
|
function ensureClaudeOnboarded() {
|
|
28041
28184
|
try {
|
|
28042
|
-
const file =
|
|
28185
|
+
const file = path56.join(os41.homedir(), ".claude.json");
|
|
28043
28186
|
let config = {};
|
|
28044
28187
|
try {
|
|
28045
|
-
config = JSON.parse(
|
|
28188
|
+
config = JSON.parse(fs50.readFileSync(file, "utf8"));
|
|
28046
28189
|
} catch {
|
|
28047
28190
|
}
|
|
28048
28191
|
if (config.hasCompletedOnboarding === true && typeof config.theme === "string") {
|
|
@@ -28053,8 +28196,8 @@ function ensureClaudeOnboarded() {
|
|
|
28053
28196
|
if (typeof config.lastOnboardingVersion !== "string") {
|
|
28054
28197
|
config.lastOnboardingVersion = "2.1.177";
|
|
28055
28198
|
}
|
|
28056
|
-
|
|
28057
|
-
|
|
28199
|
+
fs50.mkdirSync(path56.dirname(file), { recursive: true });
|
|
28200
|
+
fs50.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
28058
28201
|
log.info("claude", "pre-completed Claude onboarding (skip first-run theme picker)");
|
|
28059
28202
|
} catch (err) {
|
|
28060
28203
|
log.warn("claude", `ensureClaudeOnboarded failed (non-fatal): ${err.message}`);
|
|
@@ -28701,11 +28844,11 @@ async function logout() {
|
|
|
28701
28844
|
var import_picocolors11 = __toESM(require("picocolors"));
|
|
28702
28845
|
|
|
28703
28846
|
// src/services/providers/github-codespaces.ts
|
|
28704
|
-
var
|
|
28847
|
+
var import_child_process25 = require("child_process");
|
|
28705
28848
|
var import_util4 = require("util");
|
|
28706
28849
|
var import_picocolors9 = __toESM(require("picocolors"));
|
|
28707
|
-
var
|
|
28708
|
-
var execFileP6 = (0, import_util4.promisify)(
|
|
28850
|
+
var path57 = __toESM(require("path"));
|
|
28851
|
+
var execFileP6 = (0, import_util4.promisify)(import_child_process25.execFile);
|
|
28709
28852
|
var MAX_BUFFER = 8 * 1024 * 1024;
|
|
28710
28853
|
function resetStdinForChild() {
|
|
28711
28854
|
if (process.stdin.isTTY) {
|
|
@@ -28749,7 +28892,7 @@ var GitHubCodespacesProvider = class {
|
|
|
28749
28892
|
if (!isAuthed) {
|
|
28750
28893
|
resetStdinForChild();
|
|
28751
28894
|
await new Promise((resolve7, reject) => {
|
|
28752
|
-
const proc = (0,
|
|
28895
|
+
const proc = (0, import_child_process25.spawn)("gh", ["auth", "login", "-s", "codespace,repo,read:user"], {
|
|
28753
28896
|
stdio: "inherit"
|
|
28754
28897
|
});
|
|
28755
28898
|
proc.on("exit", (code) => {
|
|
@@ -28783,7 +28926,7 @@ var GitHubCodespacesProvider = class {
|
|
|
28783
28926
|
wt(noteLines.join("\n"), "One more permission needed");
|
|
28784
28927
|
resetStdinForChild();
|
|
28785
28928
|
const refreshCode = await new Promise((resolve7, reject) => {
|
|
28786
|
-
const proc = (0,
|
|
28929
|
+
const proc = (0, import_child_process25.spawn)(
|
|
28787
28930
|
"gh",
|
|
28788
28931
|
["auth", "refresh", "-h", "github.com", "-s", "codespace"],
|
|
28789
28932
|
{ stdio: "inherit" }
|
|
@@ -28933,7 +29076,7 @@ var GitHubCodespacesProvider = class {
|
|
|
28933
29076
|
O2.step(`Installing gh via ${installCmd.describe}\u2026`);
|
|
28934
29077
|
resetStdinForChild();
|
|
28935
29078
|
const ok = await new Promise((resolve7) => {
|
|
28936
|
-
const proc = (0,
|
|
29079
|
+
const proc = (0, import_child_process25.spawn)(installCmd.exe, installCmd.args, { stdio: "inherit" });
|
|
28937
29080
|
proc.on("exit", (code) => resolve7(code === 0));
|
|
28938
29081
|
proc.on("error", () => resolve7(false));
|
|
28939
29082
|
});
|
|
@@ -28960,7 +29103,7 @@ var GitHubCodespacesProvider = class {
|
|
|
28960
29103
|
);
|
|
28961
29104
|
resetStdinForChild();
|
|
28962
29105
|
await new Promise((resolve7, reject) => {
|
|
28963
|
-
const proc = (0,
|
|
29106
|
+
const proc = (0, import_child_process25.spawn)(
|
|
28964
29107
|
"gh",
|
|
28965
29108
|
["auth", "refresh", "-h", "github.com", "-s", "repo,read:org"],
|
|
28966
29109
|
{ stdio: "inherit" }
|
|
@@ -29138,7 +29281,7 @@ var GitHubCodespacesProvider = class {
|
|
|
29138
29281
|
async streamCommand(workspaceId, command2) {
|
|
29139
29282
|
resetStdinForChild();
|
|
29140
29283
|
return new Promise((resolve7, reject) => {
|
|
29141
|
-
const proc = (0,
|
|
29284
|
+
const proc = (0, import_child_process25.spawn)(
|
|
29142
29285
|
"gh",
|
|
29143
29286
|
["codespace", "ssh", "-c", workspaceId, "--", "-tt", command2],
|
|
29144
29287
|
{ stdio: "inherit" }
|
|
@@ -29165,11 +29308,11 @@ var GitHubCodespacesProvider = class {
|
|
|
29165
29308
|
`mkdir -p ${shellQuote(remoteDir)} && tar -xzf - -C ${shellQuote(remoteDir)}`
|
|
29166
29309
|
];
|
|
29167
29310
|
await new Promise((resolve7, reject) => {
|
|
29168
|
-
const tar = (0,
|
|
29311
|
+
const tar = (0, import_child_process25.spawn)("tar", tarArgs, {
|
|
29169
29312
|
stdio: ["ignore", "pipe", "pipe"],
|
|
29170
29313
|
env: tarEnv
|
|
29171
29314
|
});
|
|
29172
|
-
const ssh = (0,
|
|
29315
|
+
const ssh = (0, import_child_process25.spawn)("gh", sshArgs, {
|
|
29173
29316
|
stdio: [tar.stdout, "pipe", "pipe"]
|
|
29174
29317
|
});
|
|
29175
29318
|
let tarErr = "";
|
|
@@ -29193,7 +29336,7 @@ var GitHubCodespacesProvider = class {
|
|
|
29193
29336
|
});
|
|
29194
29337
|
}
|
|
29195
29338
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
29196
|
-
const remoteDir =
|
|
29339
|
+
const remoteDir = path57.posix.dirname(remotePath);
|
|
29197
29340
|
const parts = [
|
|
29198
29341
|
`mkdir -p ${shellQuote(remoteDir)}`,
|
|
29199
29342
|
`cat > ${shellQuote(remotePath)}`
|
|
@@ -29203,7 +29346,7 @@ var GitHubCodespacesProvider = class {
|
|
|
29203
29346
|
}
|
|
29204
29347
|
const cmd = parts.join(" && ");
|
|
29205
29348
|
await new Promise((resolve7, reject) => {
|
|
29206
|
-
const proc = (0,
|
|
29349
|
+
const proc = (0, import_child_process25.spawn)(
|
|
29207
29350
|
"gh",
|
|
29208
29351
|
["codespace", "ssh", "-c", workspaceId, "--", cmd],
|
|
29209
29352
|
{ stdio: ["pipe", "pipe", "pipe"] }
|
|
@@ -29261,11 +29404,11 @@ function shellQuote(s) {
|
|
|
29261
29404
|
}
|
|
29262
29405
|
|
|
29263
29406
|
// src/services/providers/gitpod.ts
|
|
29264
|
-
var
|
|
29407
|
+
var import_child_process26 = require("child_process");
|
|
29265
29408
|
var import_util5 = require("util");
|
|
29266
|
-
var
|
|
29409
|
+
var path58 = __toESM(require("path"));
|
|
29267
29410
|
var import_picocolors10 = __toESM(require("picocolors"));
|
|
29268
|
-
var execFileP7 = (0, import_util5.promisify)(
|
|
29411
|
+
var execFileP7 = (0, import_util5.promisify)(import_child_process26.execFile);
|
|
29269
29412
|
var MAX_BUFFER2 = 8 * 1024 * 1024;
|
|
29270
29413
|
function resetStdinForChild2() {
|
|
29271
29414
|
if (process.stdin.isTTY) {
|
|
@@ -29305,7 +29448,7 @@ var GitpodProvider = class {
|
|
|
29305
29448
|
);
|
|
29306
29449
|
resetStdinForChild2();
|
|
29307
29450
|
await new Promise((resolve7, reject) => {
|
|
29308
|
-
const proc = (0,
|
|
29451
|
+
const proc = (0, import_child_process26.spawn)("gitpod", ["login"], { stdio: "inherit" });
|
|
29309
29452
|
proc.on("exit", (code) => {
|
|
29310
29453
|
if (code === 0) resolve7();
|
|
29311
29454
|
else reject(new Error("gitpod login failed."));
|
|
@@ -29457,7 +29600,7 @@ var GitpodProvider = class {
|
|
|
29457
29600
|
async streamCommand(workspaceId, command2) {
|
|
29458
29601
|
resetStdinForChild2();
|
|
29459
29602
|
return new Promise((resolve7, reject) => {
|
|
29460
|
-
const proc = (0,
|
|
29603
|
+
const proc = (0, import_child_process26.spawn)(
|
|
29461
29604
|
"gitpod",
|
|
29462
29605
|
["workspace", "ssh", workspaceId, "--", "-tt", command2],
|
|
29463
29606
|
{ stdio: "inherit" }
|
|
@@ -29477,11 +29620,11 @@ var GitpodProvider = class {
|
|
|
29477
29620
|
const tarEnv = { ...process.env, COPYFILE_DISABLE: "1" };
|
|
29478
29621
|
const remoteCmd = `mkdir -p ${shellQuote2(remoteDir)} && tar -xzf - -C ${shellQuote2(remoteDir)}`;
|
|
29479
29622
|
await new Promise((resolve7, reject) => {
|
|
29480
|
-
const tar = (0,
|
|
29623
|
+
const tar = (0, import_child_process26.spawn)("tar", tarArgs, {
|
|
29481
29624
|
stdio: ["ignore", "pipe", "pipe"],
|
|
29482
29625
|
env: tarEnv
|
|
29483
29626
|
});
|
|
29484
|
-
const ssh = (0,
|
|
29627
|
+
const ssh = (0, import_child_process26.spawn)(
|
|
29485
29628
|
"gitpod",
|
|
29486
29629
|
["workspace", "ssh", workspaceId, "--", remoteCmd],
|
|
29487
29630
|
{ stdio: [tar.stdout, "pipe", "pipe"] }
|
|
@@ -29503,7 +29646,7 @@ var GitpodProvider = class {
|
|
|
29503
29646
|
});
|
|
29504
29647
|
}
|
|
29505
29648
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
29506
|
-
const remoteDir =
|
|
29649
|
+
const remoteDir = path58.posix.dirname(remotePath);
|
|
29507
29650
|
const parts = [
|
|
29508
29651
|
`mkdir -p ${shellQuote2(remoteDir)}`,
|
|
29509
29652
|
`cat > ${shellQuote2(remotePath)}`
|
|
@@ -29513,7 +29656,7 @@ var GitpodProvider = class {
|
|
|
29513
29656
|
}
|
|
29514
29657
|
const cmd = parts.join(" && ");
|
|
29515
29658
|
await new Promise((resolve7, reject) => {
|
|
29516
|
-
const proc = (0,
|
|
29659
|
+
const proc = (0, import_child_process26.spawn)(
|
|
29517
29660
|
"gitpod",
|
|
29518
29661
|
["workspace", "ssh", workspaceId, "--", cmd],
|
|
29519
29662
|
{ stdio: ["pipe", "pipe", "pipe"] }
|
|
@@ -29537,10 +29680,10 @@ function shellQuote2(s) {
|
|
|
29537
29680
|
}
|
|
29538
29681
|
|
|
29539
29682
|
// src/services/providers/gitlab-workspaces.ts
|
|
29540
|
-
var
|
|
29683
|
+
var import_child_process27 = require("child_process");
|
|
29541
29684
|
var import_util6 = require("util");
|
|
29542
|
-
var
|
|
29543
|
-
var execFileP8 = (0, import_util6.promisify)(
|
|
29685
|
+
var path59 = __toESM(require("path"));
|
|
29686
|
+
var execFileP8 = (0, import_util6.promisify)(import_child_process27.execFile);
|
|
29544
29687
|
var MAX_BUFFER3 = 8 * 1024 * 1024;
|
|
29545
29688
|
var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
|
|
29546
29689
|
function resetStdinForChild3() {
|
|
@@ -29582,7 +29725,7 @@ var GitLabWorkspacesProvider = class {
|
|
|
29582
29725
|
);
|
|
29583
29726
|
resetStdinForChild3();
|
|
29584
29727
|
await new Promise((resolve7, reject) => {
|
|
29585
|
-
const proc = (0,
|
|
29728
|
+
const proc = (0, import_child_process27.spawn)(
|
|
29586
29729
|
"glab",
|
|
29587
29730
|
["auth", "login", "--scopes", "api,read_user,read_repository"],
|
|
29588
29731
|
{ stdio: "inherit" }
|
|
@@ -29754,7 +29897,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
29754
29897
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
29755
29898
|
resetStdinForChild3();
|
|
29756
29899
|
return new Promise((resolve7, reject) => {
|
|
29757
|
-
const proc = (0,
|
|
29900
|
+
const proc = (0, import_child_process27.spawn)(
|
|
29758
29901
|
"ssh",
|
|
29759
29902
|
["-tt", "-o", "StrictHostKeyChecking=accept-new", `${workspaceId}@${sshHost}`, command2],
|
|
29760
29903
|
{ stdio: "inherit" }
|
|
@@ -29775,8 +29918,8 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
29775
29918
|
const tarEnv = { ...process.env, COPYFILE_DISABLE: "1" };
|
|
29776
29919
|
const remoteCmd = `mkdir -p ${shellQuote3(remoteDir)} && tar -xzf - -C ${shellQuote3(remoteDir)}`;
|
|
29777
29920
|
await new Promise((resolve7, reject) => {
|
|
29778
|
-
const tar = (0,
|
|
29779
|
-
const ssh = (0,
|
|
29921
|
+
const tar = (0, import_child_process27.spawn)("tar", tarArgs, { stdio: ["ignore", "pipe", "pipe"], env: tarEnv });
|
|
29922
|
+
const ssh = (0, import_child_process27.spawn)(
|
|
29780
29923
|
"ssh",
|
|
29781
29924
|
["-o", "StrictHostKeyChecking=accept-new", `${workspaceId}@${sshHost}`, remoteCmd],
|
|
29782
29925
|
{ stdio: [tar.stdout, "pipe", "pipe"] }
|
|
@@ -29799,14 +29942,14 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
29799
29942
|
}
|
|
29800
29943
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
29801
29944
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
29802
|
-
const remoteDir =
|
|
29945
|
+
const remoteDir = path59.posix.dirname(remotePath);
|
|
29803
29946
|
const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
|
|
29804
29947
|
if (options.mode != null) {
|
|
29805
29948
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
29806
29949
|
}
|
|
29807
29950
|
const cmd = parts.join(" && ");
|
|
29808
29951
|
await new Promise((resolve7, reject) => {
|
|
29809
|
-
const proc = (0,
|
|
29952
|
+
const proc = (0, import_child_process27.spawn)(
|
|
29810
29953
|
"ssh",
|
|
29811
29954
|
["-o", "StrictHostKeyChecking=accept-new", `${workspaceId}@${sshHost}`, cmd],
|
|
29812
29955
|
{ stdio: ["pipe", "pipe", "pipe"] }
|
|
@@ -29865,10 +30008,10 @@ function shellQuote3(s) {
|
|
|
29865
30008
|
}
|
|
29866
30009
|
|
|
29867
30010
|
// src/services/providers/railway.ts
|
|
29868
|
-
var
|
|
30011
|
+
var import_child_process28 = require("child_process");
|
|
29869
30012
|
var import_util7 = require("util");
|
|
29870
|
-
var
|
|
29871
|
-
var execFileP9 = (0, import_util7.promisify)(
|
|
30013
|
+
var path60 = __toESM(require("path"));
|
|
30014
|
+
var execFileP9 = (0, import_util7.promisify)(import_child_process28.execFile);
|
|
29872
30015
|
var MAX_BUFFER4 = 8 * 1024 * 1024;
|
|
29873
30016
|
function resetStdinForChild4() {
|
|
29874
30017
|
if (process.stdin.isTTY) {
|
|
@@ -29909,7 +30052,7 @@ var RailwayProvider = class {
|
|
|
29909
30052
|
);
|
|
29910
30053
|
resetStdinForChild4();
|
|
29911
30054
|
await new Promise((resolve7, reject) => {
|
|
29912
|
-
const proc = (0,
|
|
30055
|
+
const proc = (0, import_child_process28.spawn)("railway", ["login"], { stdio: "inherit" });
|
|
29913
30056
|
proc.on("exit", (code) => {
|
|
29914
30057
|
if (code === 0) resolve7();
|
|
29915
30058
|
else reject(new Error("railway login failed."));
|
|
@@ -30052,7 +30195,7 @@ var RailwayProvider = class {
|
|
|
30052
30195
|
}
|
|
30053
30196
|
resetStdinForChild4();
|
|
30054
30197
|
return new Promise((resolve7, reject) => {
|
|
30055
|
-
const proc = (0,
|
|
30198
|
+
const proc = (0, import_child_process28.spawn)(
|
|
30056
30199
|
"railway",
|
|
30057
30200
|
["shell", "--project", projectId, "--service", serviceId, "--command", command2],
|
|
30058
30201
|
{ stdio: "inherit" }
|
|
@@ -30076,8 +30219,8 @@ var RailwayProvider = class {
|
|
|
30076
30219
|
const tarEnv = { ...process.env, COPYFILE_DISABLE: "1" };
|
|
30077
30220
|
const remoteCmd = `mkdir -p ${shellQuote4(remoteDir)} && tar -xzf - -C ${shellQuote4(remoteDir)}`;
|
|
30078
30221
|
await new Promise((resolve7, reject) => {
|
|
30079
|
-
const tar = (0,
|
|
30080
|
-
const sh = (0,
|
|
30222
|
+
const tar = (0, import_child_process28.spawn)("tar", tarArgs, { stdio: ["ignore", "pipe", "pipe"], env: tarEnv });
|
|
30223
|
+
const sh = (0, import_child_process28.spawn)(
|
|
30081
30224
|
"railway",
|
|
30082
30225
|
["shell", "--project", projectId, "--service", serviceId, "--command", remoteCmd],
|
|
30083
30226
|
{ stdio: [tar.stdout, "pipe", "pipe"] }
|
|
@@ -30103,14 +30246,14 @@ var RailwayProvider = class {
|
|
|
30103
30246
|
if (!projectId || !serviceId) {
|
|
30104
30247
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
30105
30248
|
}
|
|
30106
|
-
const remoteDir =
|
|
30249
|
+
const remoteDir = path60.posix.dirname(remotePath);
|
|
30107
30250
|
const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
|
|
30108
30251
|
if (options.mode != null) {
|
|
30109
30252
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
30110
30253
|
}
|
|
30111
30254
|
const cmd = parts.join(" && ");
|
|
30112
30255
|
await new Promise((resolve7, reject) => {
|
|
30113
|
-
const proc = (0,
|
|
30256
|
+
const proc = (0, import_child_process28.spawn)(
|
|
30114
30257
|
"railway",
|
|
30115
30258
|
["shell", "--project", projectId, "--service", serviceId, "--command", cmd],
|
|
30116
30259
|
{ stdio: ["pipe", "pipe", "pipe"] }
|
|
@@ -30749,8 +30892,8 @@ async function invite() {
|
|
|
30749
30892
|
var import_node_dns = require("dns");
|
|
30750
30893
|
var import_node_util5 = require("util");
|
|
30751
30894
|
var import_node_crypto8 = require("crypto");
|
|
30752
|
-
var
|
|
30753
|
-
var
|
|
30895
|
+
var fs51 = __toESM(require("fs"));
|
|
30896
|
+
var path61 = __toESM(require("path"));
|
|
30754
30897
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
30755
30898
|
var dnsResolveP = (0, import_node_util5.promisify)(import_node_dns.resolve);
|
|
30756
30899
|
async function checkDns(apiBase2) {
|
|
@@ -30806,13 +30949,13 @@ async function checkHealth(apiBase2) {
|
|
|
30806
30949
|
}
|
|
30807
30950
|
}
|
|
30808
30951
|
function checkConfigDir() {
|
|
30809
|
-
const dir =
|
|
30952
|
+
const dir = path61.join(require("os").homedir(), ".codeam");
|
|
30810
30953
|
try {
|
|
30811
|
-
|
|
30812
|
-
const probe =
|
|
30813
|
-
|
|
30814
|
-
const read2 =
|
|
30815
|
-
|
|
30954
|
+
fs51.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
30955
|
+
const probe = path61.join(dir, ".doctor-probe");
|
|
30956
|
+
fs51.writeFileSync(probe, "ok", { mode: 384 });
|
|
30957
|
+
const read2 = fs51.readFileSync(probe, "utf8");
|
|
30958
|
+
fs51.unlinkSync(probe);
|
|
30816
30959
|
if (read2 !== "ok") throw new Error("write/read round-trip mismatch");
|
|
30817
30960
|
return {
|
|
30818
30961
|
id: "config-dir",
|
|
@@ -30852,9 +30995,9 @@ function checkSessions() {
|
|
|
30852
30995
|
}
|
|
30853
30996
|
}
|
|
30854
30997
|
function checkAgentBinaries() {
|
|
30855
|
-
const
|
|
30998
|
+
const os43 = createOsStrategy();
|
|
30856
30999
|
return getEnabledAgents().map((meta) => {
|
|
30857
|
-
const found =
|
|
31000
|
+
const found = os43.findInPath(meta.binaryName);
|
|
30858
31001
|
return {
|
|
30859
31002
|
id: `agent-${meta.id}`,
|
|
30860
31003
|
label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
|
|
@@ -30876,7 +31019,7 @@ function checkNodePty() {
|
|
|
30876
31019
|
detail: "not required on this platform"
|
|
30877
31020
|
};
|
|
30878
31021
|
}
|
|
30879
|
-
const vendoredPath =
|
|
31022
|
+
const vendoredPath = path61.join(__dirname, "vendor", "node-pty");
|
|
30880
31023
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
30881
31024
|
try {
|
|
30882
31025
|
require(target);
|
|
@@ -30918,7 +31061,7 @@ function checkChokidar() {
|
|
|
30918
31061
|
}
|
|
30919
31062
|
async function doctor(args2 = []) {
|
|
30920
31063
|
const json = args2.includes("--json");
|
|
30921
|
-
const cliVersion = true ? "2.51.
|
|
31064
|
+
const cliVersion = true ? "2.51.2" : "0.0.0-dev";
|
|
30922
31065
|
const apiBase2 = resolveApiBaseUrl();
|
|
30923
31066
|
const diagnosticId = (0, import_node_crypto8.randomUUID)();
|
|
30924
31067
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
@@ -31117,7 +31260,7 @@ async function completion(args2) {
|
|
|
31117
31260
|
// src/commands/version.ts
|
|
31118
31261
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
31119
31262
|
function version2() {
|
|
31120
|
-
const v = true ? "2.51.
|
|
31263
|
+
const v = true ? "2.51.2" : "unknown";
|
|
31121
31264
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
31122
31265
|
}
|
|
31123
31266
|
|
|
@@ -31266,10 +31409,10 @@ var EXIT_CODE_NAMES = {
|
|
|
31266
31409
|
};
|
|
31267
31410
|
|
|
31268
31411
|
// src/index.ts
|
|
31269
|
-
var
|
|
31412
|
+
var os42 = __toESM(require("os"));
|
|
31270
31413
|
if (!process.env.HOME) {
|
|
31271
31414
|
try {
|
|
31272
|
-
const home =
|
|
31415
|
+
const home = os42.homedir();
|
|
31273
31416
|
if (home) process.env.HOME = home;
|
|
31274
31417
|
} catch {
|
|
31275
31418
|
}
|