codeam-cli 2.61.50 → 2.61.52
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 +13 -0
- package/dist/index.js +532 -499
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -489,13 +489,12 @@ var AGENT_REGISTRY = {
|
|
|
489
489
|
displayName: "opencode",
|
|
490
490
|
binaryName: "opencode",
|
|
491
491
|
enabled: true,
|
|
492
|
-
// opencode
|
|
493
|
-
//
|
|
494
|
-
//
|
|
495
|
-
//
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
preferredAuthKind: "oauth_token",
|
|
492
|
+
// opencode is model-AGNOSTIC and AUTO-DETECTS provider API keys from env
|
|
493
|
+
// vars (ANTHROPIC_API_KEY / OPENAI_API_KEY / GEMINI_API_KEY / …) — same
|
|
494
|
+
// model as aider. So the credential is the user's OWN provider key; we set
|
|
495
|
+
// the matching env var (detected by prefix) at deploy. api_key only.
|
|
496
|
+
supportedAuthKinds: ["api_key"],
|
|
497
|
+
preferredAuthKind: "api_key",
|
|
499
498
|
// Not listed by `headroom init --global` (claude/codex/copilot only) — native.
|
|
500
499
|
headroomWrappable: false,
|
|
501
500
|
// Native ACP server: `opencode acp` (stdio JSON-RPC).
|
|
@@ -1199,6 +1198,37 @@ var INTEGRATION_REGISTRY = {
|
|
|
1199
1198
|
httpHeaders: { "X-Goog-Api-Key": "{accessToken}" }
|
|
1200
1199
|
}
|
|
1201
1200
|
}
|
|
1201
|
+
},
|
|
1202
|
+
vercel: {
|
|
1203
|
+
id: "vercel",
|
|
1204
|
+
name: "Vercel",
|
|
1205
|
+
icon: "vercel",
|
|
1206
|
+
category: "deployment",
|
|
1207
|
+
// DARK — OAuth (PKCE public client). The user authorizes our registered
|
|
1208
|
+
// Vercel OAuth app; the access token calls Vercel's OFFICIAL hosted remote
|
|
1209
|
+
// MCP (mcp.vercel.com, Streamable HTTP) as a Bearer header — the SAME shim
|
|
1210
|
+
// HTTP transport as PostHog/Datadog. Vercel MCP is approved-clients + per-
|
|
1211
|
+
// connection OAuth consent, but that consent is the ONE-TIME authorize (not
|
|
1212
|
+
// per MCP request), so a backend-brokered access token works headless.
|
|
1213
|
+
// Endpoints (from mcp.vercel.com/.well-known/oauth-protected-resource →
|
|
1214
|
+
// vercel.com/.well-known/oauth-authorization-server): authorize
|
|
1215
|
+
// https://vercel.com/oauth/authorize, token
|
|
1216
|
+
// https://vercel.com/api/login/oauth/token, PKCE S256, token-endpoint auth
|
|
1217
|
+
// 'none' (public). enabled:false until Step-8 live-verify of the Bearer.
|
|
1218
|
+
enabled: false,
|
|
1219
|
+
auth: {
|
|
1220
|
+
kind: "oauth_redirect",
|
|
1221
|
+
scopes: ["openid", "offline_access"]
|
|
1222
|
+
},
|
|
1223
|
+
delivery: {
|
|
1224
|
+
mcp: {
|
|
1225
|
+
command: "",
|
|
1226
|
+
args: [],
|
|
1227
|
+
envMapping: {},
|
|
1228
|
+
httpUrl: "https://mcp.vercel.com",
|
|
1229
|
+
httpHeaders: { Authorization: "Bearer {accessToken}" }
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1202
1232
|
}
|
|
1203
1233
|
};
|
|
1204
1234
|
function getIntegration(id) {
|
|
@@ -1742,11 +1772,11 @@ function quiet(fn) {
|
|
|
1742
1772
|
log.debug(TAG, "ignored sync error", err);
|
|
1743
1773
|
}
|
|
1744
1774
|
}
|
|
1745
|
-
function rmIfExistsQuiet(
|
|
1775
|
+
function rmIfExistsQuiet(path79) {
|
|
1746
1776
|
try {
|
|
1747
|
-
fs2.rmSync(
|
|
1777
|
+
fs2.rmSync(path79, { force: true });
|
|
1748
1778
|
} catch (err) {
|
|
1749
|
-
log.debug(TAG, `rmIfExists failed for ${
|
|
1779
|
+
log.debug(TAG, `rmIfExists failed for ${path79}`, err);
|
|
1750
1780
|
}
|
|
1751
1781
|
}
|
|
1752
1782
|
function killQuiet(target, signal = "SIGTERM") {
|
|
@@ -1892,9 +1922,9 @@ var _default = makeConfig();
|
|
|
1892
1922
|
var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, clearAll, saveCliConfig, loadCliConfig } = _default;
|
|
1893
1923
|
|
|
1894
1924
|
// src/commands/pair-auto.ts
|
|
1895
|
-
var
|
|
1896
|
-
var
|
|
1897
|
-
var
|
|
1925
|
+
var fs58 = __toESM(require("fs"));
|
|
1926
|
+
var os49 = __toESM(require("os"));
|
|
1927
|
+
var path62 = __toESM(require("path"));
|
|
1898
1928
|
var import_crypto4 = require("crypto");
|
|
1899
1929
|
|
|
1900
1930
|
// src/services/telemetry.service.ts
|
|
@@ -1930,8 +1960,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
|
|
|
1930
1960
|
return decodedFile;
|
|
1931
1961
|
};
|
|
1932
1962
|
}
|
|
1933
|
-
function normalizeWindowsPath(
|
|
1934
|
-
return
|
|
1963
|
+
function normalizeWindowsPath(path79) {
|
|
1964
|
+
return path79.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
1935
1965
|
}
|
|
1936
1966
|
|
|
1937
1967
|
// ../../node_modules/@posthog/core/dist/featureFlagUtils.mjs
|
|
@@ -4411,9 +4441,9 @@ async function addSourceContext(frames) {
|
|
|
4411
4441
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
4412
4442
|
return frames;
|
|
4413
4443
|
}
|
|
4414
|
-
function getContextLinesFromFile(
|
|
4444
|
+
function getContextLinesFromFile(path79, ranges, output) {
|
|
4415
4445
|
return new Promise((resolve8) => {
|
|
4416
|
-
const stream = (0, import_node_fs.createReadStream)(
|
|
4446
|
+
const stream = (0, import_node_fs.createReadStream)(path79);
|
|
4417
4447
|
const lineReaded = (0, import_node_readline.createInterface)({
|
|
4418
4448
|
input: stream
|
|
4419
4449
|
});
|
|
@@ -4428,7 +4458,7 @@ function getContextLinesFromFile(path80, ranges, output) {
|
|
|
4428
4458
|
let rangeStart = range[0];
|
|
4429
4459
|
let rangeEnd = range[1];
|
|
4430
4460
|
function onStreamError() {
|
|
4431
|
-
LRU_FILE_CONTENTS_FS_READ_FAILED.set(
|
|
4461
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(path79, 1);
|
|
4432
4462
|
lineReaded.close();
|
|
4433
4463
|
lineReaded.removeAllListeners();
|
|
4434
4464
|
destroyStreamAndResolve();
|
|
@@ -4489,8 +4519,8 @@ function clearLineContext(frame) {
|
|
|
4489
4519
|
delete frame.context_line;
|
|
4490
4520
|
delete frame.post_context;
|
|
4491
4521
|
}
|
|
4492
|
-
function shouldSkipContextLinesForFile(
|
|
4493
|
-
return
|
|
4522
|
+
function shouldSkipContextLinesForFile(path79) {
|
|
4523
|
+
return path79.startsWith("node:") || path79.endsWith(".min.js") || path79.endsWith(".min.cjs") || path79.endsWith(".min.mjs") || path79.startsWith("data:");
|
|
4494
4524
|
}
|
|
4495
4525
|
function shouldSkipContextLinesForFrame(frame) {
|
|
4496
4526
|
if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
|
|
@@ -6644,7 +6674,7 @@ function readAnonId() {
|
|
|
6644
6674
|
}
|
|
6645
6675
|
function superProperties() {
|
|
6646
6676
|
return {
|
|
6647
|
-
cliVersion: true ? "2.61.
|
|
6677
|
+
cliVersion: true ? "2.61.52" : "0.0.0-dev",
|
|
6648
6678
|
nodeVersion: process.version,
|
|
6649
6679
|
platform: process.platform,
|
|
6650
6680
|
arch: process.arch,
|
|
@@ -6825,7 +6855,7 @@ var os4 = __toESM(require("os"));
|
|
|
6825
6855
|
// package.json
|
|
6826
6856
|
var package_default = {
|
|
6827
6857
|
name: "codeam-cli",
|
|
6828
|
-
version: "2.61.
|
|
6858
|
+
version: "2.61.52",
|
|
6829
6859
|
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.",
|
|
6830
6860
|
type: "commonjs",
|
|
6831
6861
|
main: "dist/index.js",
|
|
@@ -7997,7 +8027,7 @@ var CommandRelayService = class _CommandRelayService {
|
|
|
7997
8027
|
// fresh + clear the "CLI update available" banner after a self-update
|
|
7998
8028
|
// (a codespace that reinstalls @latest reconnects via heartbeat, not
|
|
7999
8029
|
// pair/reconnect). Older backends ignore the extra field.
|
|
8000
|
-
..."2.61.
|
|
8030
|
+
..."2.61.52" ? { ideVersion: "2.61.52" } : {}
|
|
8001
8031
|
}).then(() => log.trace("relay", `heartbeat ok online=${online}`)).catch((err) => log.trace("relay", `heartbeat failed online=${online}`, err));
|
|
8002
8032
|
}
|
|
8003
8033
|
/**
|
|
@@ -8224,10 +8254,10 @@ var WINDOWS_LEGACY_JUNCTIONS = [
|
|
|
8224
8254
|
/[\\/]Start Menu([\\/]|$)/i,
|
|
8225
8255
|
/[\\/]Templates([\\/]|$)/i
|
|
8226
8256
|
];
|
|
8227
|
-
function isUnsafeWindowsWatchRoot(dir,
|
|
8257
|
+
function isUnsafeWindowsWatchRoot(dir, homedir47) {
|
|
8228
8258
|
const norm = (p2) => p2.replace(/\//g, "\\").replace(/\\+$/, "").toLowerCase();
|
|
8229
8259
|
const cwd = norm(dir);
|
|
8230
|
-
const home = norm(
|
|
8260
|
+
const home = norm(homedir47);
|
|
8231
8261
|
if (cwd === home) return true;
|
|
8232
8262
|
if (/^[a-z]:$/.test(cwd)) return true;
|
|
8233
8263
|
const sysRoots = [
|
|
@@ -9371,9 +9401,9 @@ function closeAllTerminals() {
|
|
|
9371
9401
|
}
|
|
9372
9402
|
|
|
9373
9403
|
// src/commands/start/handlers.ts
|
|
9374
|
-
var
|
|
9375
|
-
var
|
|
9376
|
-
var
|
|
9404
|
+
var fs57 = __toESM(require("fs"));
|
|
9405
|
+
var os48 = __toESM(require("os"));
|
|
9406
|
+
var path61 = __toESM(require("path"));
|
|
9377
9407
|
var import_crypto3 = require("crypto");
|
|
9378
9408
|
var import_child_process24 = require("child_process");
|
|
9379
9409
|
|
|
@@ -10205,8 +10235,8 @@ function findGitRoot2(startDir) {
|
|
|
10205
10235
|
|
|
10206
10236
|
// src/commands/link.ts
|
|
10207
10237
|
var import_node_crypto8 = require("crypto");
|
|
10208
|
-
var
|
|
10209
|
-
var
|
|
10238
|
+
var fs30 = __toESM(require("fs"));
|
|
10239
|
+
var path34 = __toESM(require("path"));
|
|
10210
10240
|
var import_chokidar = __toESM(require("chokidar"));
|
|
10211
10241
|
var import_picocolors2 = __toESM(require("picocolors"));
|
|
10212
10242
|
|
|
@@ -12853,10 +12883,10 @@ function buildForPlatform(platform3) {
|
|
|
12853
12883
|
var import_node_crypto4 = require("crypto");
|
|
12854
12884
|
|
|
12855
12885
|
// src/agents/claude/resolver.ts
|
|
12856
|
-
function buildClaudeLaunch(extraArgs = [],
|
|
12857
|
-
const found =
|
|
12886
|
+
function buildClaudeLaunch(extraArgs = [], os59 = createOsStrategy()) {
|
|
12887
|
+
const found = os59.findInPath("claude") ?? os59.findInPath("claude-code");
|
|
12858
12888
|
if (!found) return null;
|
|
12859
|
-
return
|
|
12889
|
+
return os59.buildLaunch(found, extraArgs);
|
|
12860
12890
|
}
|
|
12861
12891
|
|
|
12862
12892
|
// src/agents/claude/installer.ts
|
|
@@ -13446,8 +13476,8 @@ var ClaudeRuntimeStrategy = class {
|
|
|
13446
13476
|
meta = getAgent("claude");
|
|
13447
13477
|
mode = "interactive";
|
|
13448
13478
|
os;
|
|
13449
|
-
constructor(
|
|
13450
|
-
this.os =
|
|
13479
|
+
constructor(os59) {
|
|
13480
|
+
this.os = os59;
|
|
13451
13481
|
}
|
|
13452
13482
|
/**
|
|
13453
13483
|
* Claude Code's react-ink TUI enables bracketed-paste mode at
|
|
@@ -14227,8 +14257,8 @@ function codexCredentialLocator() {
|
|
|
14227
14257
|
function codexLoginLauncher() {
|
|
14228
14258
|
return {
|
|
14229
14259
|
async ensureInstalled() {
|
|
14230
|
-
const
|
|
14231
|
-
return
|
|
14260
|
+
const os59 = createOsStrategy();
|
|
14261
|
+
return os59.findInPath("codex") !== null;
|
|
14232
14262
|
},
|
|
14233
14263
|
launch() {
|
|
14234
14264
|
return (0, import_node_child_process4.spawn)("codex", ["login"], { stdio: "inherit" });
|
|
@@ -14251,8 +14281,8 @@ var CodexRuntimeStrategy = class {
|
|
|
14251
14281
|
meta = getAgent("codex");
|
|
14252
14282
|
mode = "interactive";
|
|
14253
14283
|
os;
|
|
14254
|
-
constructor(
|
|
14255
|
-
this.os =
|
|
14284
|
+
constructor(os59) {
|
|
14285
|
+
this.os = os59;
|
|
14256
14286
|
}
|
|
14257
14287
|
async prepareLaunch() {
|
|
14258
14288
|
let binary = this.os.findInPath("codex");
|
|
@@ -14361,12 +14391,12 @@ var CodexRuntimeStrategy = class {
|
|
|
14361
14391
|
});
|
|
14362
14392
|
}
|
|
14363
14393
|
};
|
|
14364
|
-
function resolveNpm(
|
|
14365
|
-
return
|
|
14394
|
+
function resolveNpm(os59) {
|
|
14395
|
+
return os59.id === "win32" ? "npm.cmd" : "npm";
|
|
14366
14396
|
}
|
|
14367
|
-
async function installCodexViaNpm(
|
|
14397
|
+
async function installCodexViaNpm(os59) {
|
|
14368
14398
|
return new Promise((resolve8, reject) => {
|
|
14369
|
-
const proc = (0, import_node_child_process5.spawn)(resolveNpm(
|
|
14399
|
+
const proc = (0, import_node_child_process5.spawn)(resolveNpm(os59), ["install", "-g", "@openai/codex"], {
|
|
14370
14400
|
stdio: "inherit"
|
|
14371
14401
|
});
|
|
14372
14402
|
proc.on("close", (code) => {
|
|
@@ -14383,16 +14413,16 @@ async function installCodexViaNpm(os60) {
|
|
|
14383
14413
|
});
|
|
14384
14414
|
});
|
|
14385
14415
|
}
|
|
14386
|
-
function augmentNpmGlobalBin(
|
|
14416
|
+
function augmentNpmGlobalBin(os59) {
|
|
14387
14417
|
try {
|
|
14388
|
-
const result = (0, import_node_child_process5.spawnSync)(resolveNpm(
|
|
14418
|
+
const result = (0, import_node_child_process5.spawnSync)(resolveNpm(os59), ["prefix", "-g"], {
|
|
14389
14419
|
stdio: ["ignore", "pipe", "ignore"]
|
|
14390
14420
|
});
|
|
14391
14421
|
if (result.status !== 0) return;
|
|
14392
14422
|
const prefix = result.stdout.toString().trim();
|
|
14393
14423
|
if (!prefix) return;
|
|
14394
|
-
const binDir =
|
|
14395
|
-
|
|
14424
|
+
const binDir = os59.id === "win32" ? prefix : path24.join(prefix, "bin");
|
|
14425
|
+
os59.augmentPath([binDir]);
|
|
14396
14426
|
} catch {
|
|
14397
14427
|
}
|
|
14398
14428
|
}
|
|
@@ -14476,9 +14506,9 @@ var import_node_child_process8 = require("child_process");
|
|
|
14476
14506
|
// src/agents/coderabbit/installer.ts
|
|
14477
14507
|
var import_node_child_process6 = require("child_process");
|
|
14478
14508
|
var INSTALL_URL = "https://cli.coderabbit.ai/install.sh";
|
|
14479
|
-
async function ensureCoderabbitInstalled(
|
|
14480
|
-
if (
|
|
14481
|
-
if (
|
|
14509
|
+
async function ensureCoderabbitInstalled(os59) {
|
|
14510
|
+
if (os59.findInPath("coderabbit")) return true;
|
|
14511
|
+
if (os59.id === "win32") {
|
|
14482
14512
|
console.error(
|
|
14483
14513
|
"\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"
|
|
14484
14514
|
);
|
|
@@ -14511,8 +14541,8 @@ async function ensureCoderabbitInstalled(os60) {
|
|
|
14511
14541
|
proc.on("error", () => finish(false));
|
|
14512
14542
|
});
|
|
14513
14543
|
if (!ok) return false;
|
|
14514
|
-
|
|
14515
|
-
return
|
|
14544
|
+
os59.augmentPath([`${os59.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
|
|
14545
|
+
return os59.findInPath("coderabbit") !== null;
|
|
14516
14546
|
}
|
|
14517
14547
|
|
|
14518
14548
|
// src/agents/coderabbit/link.ts
|
|
@@ -14547,10 +14577,10 @@ function coderabbitCredentialLocator() {
|
|
|
14547
14577
|
validate: validateNonEmptyCredential
|
|
14548
14578
|
};
|
|
14549
14579
|
}
|
|
14550
|
-
function coderabbitLoginLauncher(
|
|
14580
|
+
function coderabbitLoginLauncher(os59) {
|
|
14551
14581
|
return {
|
|
14552
14582
|
async ensureInstalled() {
|
|
14553
|
-
return ensureCoderabbitInstalled(
|
|
14583
|
+
return ensureCoderabbitInstalled(os59);
|
|
14554
14584
|
},
|
|
14555
14585
|
launch() {
|
|
14556
14586
|
return (0, import_node_child_process7.spawn)("coderabbit", ["auth", "login"], { stdio: "inherit" });
|
|
@@ -14606,8 +14636,8 @@ function pickLine(obj) {
|
|
|
14606
14636
|
function toHunk(raw, groupSeverity) {
|
|
14607
14637
|
if (!raw || typeof raw !== "object") return null;
|
|
14608
14638
|
const o = raw;
|
|
14609
|
-
const
|
|
14610
|
-
if (!
|
|
14639
|
+
const path79 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
|
|
14640
|
+
if (!path79) return null;
|
|
14611
14641
|
const message = asString(
|
|
14612
14642
|
pick(o, [
|
|
14613
14643
|
"comment",
|
|
@@ -14624,7 +14654,7 @@ function toHunk(raw, groupSeverity) {
|
|
|
14624
14654
|
const severity = normSeverity(pick(o, ["severity", "level", "priority", "impact"])) ?? normSeverity(groupSeverity);
|
|
14625
14655
|
const locObj = pick(o, ["location"]) ?? o;
|
|
14626
14656
|
return {
|
|
14627
|
-
path:
|
|
14657
|
+
path: path79.trim(),
|
|
14628
14658
|
line: pickLine(o) ?? pickLine(locObj),
|
|
14629
14659
|
severity,
|
|
14630
14660
|
message: (title && message ? `${title}: ${message}` : title || message).trim() || "(no message)"
|
|
@@ -14707,10 +14737,10 @@ function parsePlain(stdout) {
|
|
|
14707
14737
|
for (const line of stdout.split(/\r?\n/)) {
|
|
14708
14738
|
const m = line.match(HUNK_LINE_RE);
|
|
14709
14739
|
if (!m) continue;
|
|
14710
|
-
const [,
|
|
14711
|
-
if (!
|
|
14740
|
+
const [, path79, lineNo, sevToken, message] = m;
|
|
14741
|
+
if (!path79 || !lineNo || !message) continue;
|
|
14712
14742
|
hunks.push({
|
|
14713
|
-
path:
|
|
14743
|
+
path: path79.trim(),
|
|
14714
14744
|
line: Number(lineNo),
|
|
14715
14745
|
severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
|
|
14716
14746
|
message: message.trim().replace(/^[*-]\s+/, "")
|
|
@@ -14770,8 +14800,8 @@ var CoderabbitRuntimeStrategy = class {
|
|
|
14770
14800
|
meta = getAgent("coderabbit");
|
|
14771
14801
|
mode = "batch";
|
|
14772
14802
|
os;
|
|
14773
|
-
constructor(
|
|
14774
|
-
this.os =
|
|
14803
|
+
constructor(os59) {
|
|
14804
|
+
this.os = os59;
|
|
14775
14805
|
}
|
|
14776
14806
|
getDefaultArgs() {
|
|
14777
14807
|
return ["review", "--agent"];
|
|
@@ -15042,10 +15072,10 @@ function cursorCredentialLocator() {
|
|
|
15042
15072
|
validate: validateNonEmptyCredential
|
|
15043
15073
|
};
|
|
15044
15074
|
}
|
|
15045
|
-
function cursorLoginLauncher(
|
|
15075
|
+
function cursorLoginLauncher(os59) {
|
|
15046
15076
|
return {
|
|
15047
15077
|
async ensureInstalled() {
|
|
15048
|
-
if (
|
|
15078
|
+
if (os59.findInPath("cursor-agent")) return true;
|
|
15049
15079
|
console.error(
|
|
15050
15080
|
"\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"
|
|
15051
15081
|
);
|
|
@@ -15109,8 +15139,8 @@ var CursorRuntimeStrategy = class {
|
|
|
15109
15139
|
meta = getAgent("cursor");
|
|
15110
15140
|
mode = "interactive";
|
|
15111
15141
|
os;
|
|
15112
|
-
constructor(
|
|
15113
|
-
this.os =
|
|
15142
|
+
constructor(os59) {
|
|
15143
|
+
this.os = os59;
|
|
15114
15144
|
}
|
|
15115
15145
|
async prepareLaunch() {
|
|
15116
15146
|
const binary = this.os.findInPath("cursor-agent");
|
|
@@ -15326,10 +15356,10 @@ function aiderCredentialLocator() {
|
|
|
15326
15356
|
validate: validateNonEmptyCredential
|
|
15327
15357
|
};
|
|
15328
15358
|
}
|
|
15329
|
-
function aiderLoginLauncher(
|
|
15359
|
+
function aiderLoginLauncher(os59) {
|
|
15330
15360
|
return {
|
|
15331
15361
|
async ensureInstalled() {
|
|
15332
|
-
if (
|
|
15362
|
+
if (os59.findInPath("aider")) return true;
|
|
15333
15363
|
console.error(
|
|
15334
15364
|
"\n \u2717 aider binary not on PATH.\n Install Aider:\n pip install aider-chat\n then re-run `codeam link aider`.\n"
|
|
15335
15365
|
);
|
|
@@ -15339,7 +15369,7 @@ function aiderLoginLauncher(os60) {
|
|
|
15339
15369
|
console.error(
|
|
15340
15370
|
"\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"
|
|
15341
15371
|
);
|
|
15342
|
-
return (0, import_node_child_process11.spawn)(
|
|
15372
|
+
return (0, import_node_child_process11.spawn)(os59.id === "win32" ? "cmd.exe" : "sh", os59.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
|
|
15343
15373
|
stdio: "ignore"
|
|
15344
15374
|
});
|
|
15345
15375
|
}
|
|
@@ -15411,8 +15441,8 @@ var AiderRuntimeStrategy = class {
|
|
|
15411
15441
|
meta = getAgent("aider");
|
|
15412
15442
|
mode = "interactive";
|
|
15413
15443
|
os;
|
|
15414
|
-
constructor(
|
|
15415
|
-
this.os =
|
|
15444
|
+
constructor(os59) {
|
|
15445
|
+
this.os = os59;
|
|
15416
15446
|
}
|
|
15417
15447
|
async prepareLaunch() {
|
|
15418
15448
|
const binary = this.os.findInPath("aider");
|
|
@@ -15544,8 +15574,8 @@ function geminiCredentialLocator() {
|
|
|
15544
15574
|
function geminiLoginLauncher() {
|
|
15545
15575
|
return {
|
|
15546
15576
|
async ensureInstalled() {
|
|
15547
|
-
const
|
|
15548
|
-
return
|
|
15577
|
+
const os59 = createOsStrategy();
|
|
15578
|
+
return os59.findInPath("gemini") !== null;
|
|
15549
15579
|
},
|
|
15550
15580
|
launch() {
|
|
15551
15581
|
return (0, import_node_child_process12.spawn)("gemini", ["auth", "login"], { stdio: "inherit" });
|
|
@@ -15735,8 +15765,8 @@ var GeminiRuntimeStrategy = class {
|
|
|
15735
15765
|
meta = getAgent("gemini");
|
|
15736
15766
|
mode = "interactive";
|
|
15737
15767
|
os;
|
|
15738
|
-
constructor(
|
|
15739
|
-
this.os =
|
|
15768
|
+
constructor(os59) {
|
|
15769
|
+
this.os = os59;
|
|
15740
15770
|
}
|
|
15741
15771
|
async prepareLaunch() {
|
|
15742
15772
|
const binary = this.os.findInPath("gemini");
|
|
@@ -16027,8 +16057,8 @@ var KimiRuntimeStrategy = class {
|
|
|
16027
16057
|
meta = getAgent("kimi");
|
|
16028
16058
|
mode = "interactive";
|
|
16029
16059
|
os;
|
|
16030
|
-
constructor(
|
|
16031
|
-
this.os =
|
|
16060
|
+
constructor(os59) {
|
|
16061
|
+
this.os = os59;
|
|
16032
16062
|
}
|
|
16033
16063
|
async prepareLaunch() {
|
|
16034
16064
|
const binary = this.os.findInPath("kimi");
|
|
@@ -16143,22 +16173,25 @@ var KimiRuntimeStrategy = class {
|
|
|
16143
16173
|
var import_node_child_process14 = require("child_process");
|
|
16144
16174
|
|
|
16145
16175
|
// src/agents/opencode/local-token.ts
|
|
16146
|
-
var
|
|
16147
|
-
|
|
16148
|
-
|
|
16149
|
-
|
|
16150
|
-
|
|
16151
|
-
|
|
16152
|
-
|
|
16176
|
+
var API_KEY_ENV_VARS2 = [
|
|
16177
|
+
"ANTHROPIC_API_KEY",
|
|
16178
|
+
"OPENAI_API_KEY",
|
|
16179
|
+
"GEMINI_API_KEY",
|
|
16180
|
+
"GROQ_API_KEY",
|
|
16181
|
+
"OPENROUTER_API_KEY",
|
|
16182
|
+
"DEEPSEEK_API_KEY"
|
|
16183
|
+
];
|
|
16153
16184
|
async function extractLocalOpencodeToken() {
|
|
16154
|
-
const
|
|
16155
|
-
|
|
16156
|
-
|
|
16157
|
-
|
|
16158
|
-
|
|
16185
|
+
for (const name of API_KEY_ENV_VARS2) {
|
|
16186
|
+
const value = process.env[name];
|
|
16187
|
+
if (value && value.trim().length > 0) {
|
|
16188
|
+
return { method: "api_key", credential: value.trim(), source: "flat-file" };
|
|
16189
|
+
}
|
|
16190
|
+
}
|
|
16191
|
+
return null;
|
|
16159
16192
|
}
|
|
16160
16193
|
function opencodeCredentialsPaths() {
|
|
16161
|
-
return [
|
|
16194
|
+
return [];
|
|
16162
16195
|
}
|
|
16163
16196
|
|
|
16164
16197
|
// src/agents/opencode/runtime.ts
|
|
@@ -16167,8 +16200,8 @@ var OpencodeRuntimeStrategy = class {
|
|
|
16167
16200
|
meta = getAgent("opencode");
|
|
16168
16201
|
mode = "interactive";
|
|
16169
16202
|
os;
|
|
16170
|
-
constructor(
|
|
16171
|
-
this.os =
|
|
16203
|
+
constructor(os59) {
|
|
16204
|
+
this.os = os59;
|
|
16172
16205
|
}
|
|
16173
16206
|
async prepareLaunch() {
|
|
16174
16207
|
const binary = this.os.findInPath("opencode");
|
|
@@ -16232,7 +16265,7 @@ var OpencodeRuntimeStrategy = class {
|
|
|
16232
16265
|
return {
|
|
16233
16266
|
publicId: "opencode",
|
|
16234
16267
|
vendor: "opencode",
|
|
16235
|
-
hint: "
|
|
16268
|
+
hint: "ANTHROPIC_API_KEY / OPENAI_API_KEY / \u2026 env var (opencode auto-detects)",
|
|
16236
16269
|
watchPaths: opencodeCredentialsPaths,
|
|
16237
16270
|
extract: extractLocalOpencodeToken,
|
|
16238
16271
|
validate: validateNonEmptyCredential
|
|
@@ -16252,20 +16285,20 @@ var OpencodeRuntimeStrategy = class {
|
|
|
16252
16285
|
|
|
16253
16286
|
// src/agents/registry.ts
|
|
16254
16287
|
var runtimeBuilders = {
|
|
16255
|
-
claude: (
|
|
16256
|
-
codex: (
|
|
16257
|
-
coderabbit: (
|
|
16258
|
-
cursor: (
|
|
16259
|
-
aider: (
|
|
16260
|
-
gemini: (
|
|
16261
|
-
kimi: (
|
|
16262
|
-
opencode: (
|
|
16288
|
+
claude: (os59) => new ClaudeRuntimeStrategy(os59),
|
|
16289
|
+
codex: (os59) => new CodexRuntimeStrategy(os59),
|
|
16290
|
+
coderabbit: (os59) => new CoderabbitRuntimeStrategy(os59),
|
|
16291
|
+
cursor: (os59) => new CursorRuntimeStrategy(os59),
|
|
16292
|
+
aider: (os59) => new AiderRuntimeStrategy(os59),
|
|
16293
|
+
gemini: (os59) => new GeminiRuntimeStrategy(os59),
|
|
16294
|
+
kimi: (os59) => new KimiRuntimeStrategy(os59),
|
|
16295
|
+
opencode: (os59) => new OpencodeRuntimeStrategy(os59)
|
|
16263
16296
|
};
|
|
16264
16297
|
var deployBuilders = {
|
|
16265
16298
|
claude: () => new ClaudeDeployStrategy(),
|
|
16266
16299
|
codex: () => new CodexDeployStrategy()
|
|
16267
16300
|
};
|
|
16268
|
-
function createAgentStrategy(agent,
|
|
16301
|
+
function createAgentStrategy(agent, os59 = createOsStrategy()) {
|
|
16269
16302
|
if (!AGENT_REGISTRY[agent]?.enabled) {
|
|
16270
16303
|
throw new Error(
|
|
16271
16304
|
`Agent "${agent}" is not supported in this codeam-cli version. Upgrade with 'npm i -g codeam-cli@latest'.`
|
|
@@ -16275,10 +16308,10 @@ function createAgentStrategy(agent, os60 = createOsStrategy()) {
|
|
|
16275
16308
|
if (!build) {
|
|
16276
16309
|
throw new Error(`No runtime strategy registered for agent "${agent}"`);
|
|
16277
16310
|
}
|
|
16278
|
-
return build(
|
|
16311
|
+
return build(os59);
|
|
16279
16312
|
}
|
|
16280
|
-
function createInteractiveAgentStrategy(agent,
|
|
16281
|
-
const s = createAgentStrategy(agent,
|
|
16313
|
+
function createInteractiveAgentStrategy(agent, os59 = createOsStrategy()) {
|
|
16314
|
+
const s = createAgentStrategy(agent, os59);
|
|
16282
16315
|
if (s.mode !== "interactive") {
|
|
16283
16316
|
throw new Error(
|
|
16284
16317
|
`Agent "${agent}" is a batch agent; use createAgentStrategy + .runOneShot for one-shot reviews.`
|
|
@@ -16334,7 +16367,7 @@ function parseLinkArgs(args2) {
|
|
|
16334
16367
|
if (apiKeyFileArg) {
|
|
16335
16368
|
const filePath = apiKeyFileArg.slice("--api-key-file=".length);
|
|
16336
16369
|
try {
|
|
16337
|
-
apiKey =
|
|
16370
|
+
apiKey = fs30.readFileSync(path34.resolve(filePath), "utf8").trim();
|
|
16338
16371
|
} catch (err) {
|
|
16339
16372
|
throw new Error(`Could not read --api-key-file ${filePath}: ${err.message}`);
|
|
16340
16373
|
}
|
|
@@ -16461,7 +16494,7 @@ async function link(args2 = []) {
|
|
|
16461
16494
|
return;
|
|
16462
16495
|
}
|
|
16463
16496
|
if (parsed.tokenFile) {
|
|
16464
|
-
const credential =
|
|
16497
|
+
const credential = fs30.readFileSync(path34.resolve(parsed.tokenFile), "utf8").trim();
|
|
16465
16498
|
if (!credential) {
|
|
16466
16499
|
showError(`--token-file ${parsed.tokenFile} is empty.`);
|
|
16467
16500
|
process.exit(1);
|
|
@@ -16681,13 +16714,13 @@ async function linkDryRunPreflight(ctx) {
|
|
|
16681
16714
|
var import_node_child_process16 = require("child_process");
|
|
16682
16715
|
var import_node_os4 = require("os");
|
|
16683
16716
|
var import_node_fs5 = require("fs");
|
|
16684
|
-
var
|
|
16717
|
+
var path36 = __toESM(require("path"));
|
|
16685
16718
|
|
|
16686
16719
|
// src/agents/coderabbit/oauth.ts
|
|
16687
16720
|
var import_node_child_process15 = require("child_process");
|
|
16688
|
-
var
|
|
16689
|
-
var
|
|
16690
|
-
var
|
|
16721
|
+
var fs31 = __toESM(require("fs"));
|
|
16722
|
+
var os27 = __toESM(require("os"));
|
|
16723
|
+
var path35 = __toESM(require("path"));
|
|
16691
16724
|
function parseCoderabbitAuthEvent(line) {
|
|
16692
16725
|
const l = line.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "").trim();
|
|
16693
16726
|
if (!l || l[0] !== "{") return null;
|
|
@@ -16736,8 +16769,8 @@ function resolvePython() {
|
|
|
16736
16769
|
function spawnCoderabbitLoginProc(cmd, args2) {
|
|
16737
16770
|
const python = resolvePython();
|
|
16738
16771
|
if (python) {
|
|
16739
|
-
const helper =
|
|
16740
|
-
|
|
16772
|
+
const helper = path35.join(os27.tmpdir(), "codeam-cr-pty.py");
|
|
16773
|
+
fs31.writeFileSync(helper, PYTHON_PTY_HELPER, { mode: 420 });
|
|
16741
16774
|
return (0, import_node_child_process15.spawn)(python, [helper, cmd, ...args2], {
|
|
16742
16775
|
stdio: ["pipe", "pipe", "pipe"],
|
|
16743
16776
|
env: { ...process.env, TERM: "xterm-256color", COLUMNS: "220", LINES: "50" },
|
|
@@ -16848,7 +16881,7 @@ function runCoderabbitOAuthLogin(deps) {
|
|
|
16848
16881
|
});
|
|
16849
16882
|
}
|
|
16850
16883
|
function coderabbitDir(home) {
|
|
16851
|
-
return
|
|
16884
|
+
return path35.join(home ?? os27.homedir(), ".coderabbit");
|
|
16852
16885
|
}
|
|
16853
16886
|
var NON_CREDENTIAL = /* @__PURE__ */ new Set(["doctor.json", "machine-id"]);
|
|
16854
16887
|
function snapshotCredentialDir(home) {
|
|
@@ -16856,14 +16889,14 @@ function snapshotCredentialDir(home) {
|
|
|
16856
16889
|
const snap = {};
|
|
16857
16890
|
let entries;
|
|
16858
16891
|
try {
|
|
16859
|
-
entries =
|
|
16892
|
+
entries = fs31.readdirSync(dir, { withFileTypes: true });
|
|
16860
16893
|
} catch {
|
|
16861
16894
|
return snap;
|
|
16862
16895
|
}
|
|
16863
16896
|
for (const e of entries) {
|
|
16864
16897
|
if (!e.isFile() || NON_CREDENTIAL.has(e.name)) continue;
|
|
16865
16898
|
try {
|
|
16866
|
-
const st3 =
|
|
16899
|
+
const st3 = fs31.statSync(path35.join(dir, e.name));
|
|
16867
16900
|
snap[e.name] = `${st3.mtimeMs}:${st3.size}`;
|
|
16868
16901
|
} catch {
|
|
16869
16902
|
}
|
|
@@ -16881,7 +16914,7 @@ function diffCapturedCredential(before, home) {
|
|
|
16881
16914
|
}
|
|
16882
16915
|
if (!best) return null;
|
|
16883
16916
|
try {
|
|
16884
|
-
return { file: best.file, contents:
|
|
16917
|
+
return { file: best.file, contents: fs31.readFileSync(path35.join(dir, best.file), "utf8") };
|
|
16885
16918
|
} catch {
|
|
16886
16919
|
return null;
|
|
16887
16920
|
}
|
|
@@ -16958,7 +16991,7 @@ function collectChangedFiles(cwd) {
|
|
|
16958
16991
|
return [...byPath.values()];
|
|
16959
16992
|
}
|
|
16960
16993
|
function restoreCoderabbitOauthBlob(value) {
|
|
16961
|
-
const dir =
|
|
16994
|
+
const dir = path36.join((0, import_node_os4.homedir)(), ".coderabbit");
|
|
16962
16995
|
(0, import_node_fs5.mkdirSync)(dir, { recursive: true });
|
|
16963
16996
|
let file = "auth.json";
|
|
16964
16997
|
let contents = value.trim();
|
|
@@ -16966,35 +16999,35 @@ function restoreCoderabbitOauthBlob(value) {
|
|
|
16966
16999
|
try {
|
|
16967
17000
|
const parsed = JSON.parse(contents);
|
|
16968
17001
|
if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
|
|
16969
|
-
file =
|
|
17002
|
+
file = path36.basename(parsed.file);
|
|
16970
17003
|
contents = parsed.contents;
|
|
16971
17004
|
}
|
|
16972
17005
|
} catch {
|
|
16973
17006
|
}
|
|
16974
17007
|
}
|
|
16975
|
-
(0, import_node_fs5.writeFileSync)(
|
|
17008
|
+
(0, import_node_fs5.writeFileSync)(path36.join(dir, file), contents, { mode: 384 });
|
|
16976
17009
|
}
|
|
16977
17010
|
async function configureCoderabbit(input, deps = {}) {
|
|
16978
|
-
const
|
|
17011
|
+
const os59 = deps.os ?? createOsStrategy();
|
|
16979
17012
|
const ensureInstalled = deps.ensureInstalled ?? ensureCoderabbitInstalled;
|
|
16980
17013
|
const isLoggedIn = deps.isLoggedIn ?? defaultIsLoggedIn;
|
|
16981
17014
|
const runOAuth = deps.runOAuthLogin ?? runCoderabbitOAuthLogin;
|
|
16982
17015
|
const snapshot = deps.snapshotDir ?? (() => snapshotCredentialDir());
|
|
16983
17016
|
const capture2 = deps.captureCredential ?? ((b) => diffCapturedCredential(b));
|
|
16984
17017
|
const loginWithApiKey = deps.loginWithApiKey ?? defaultLoginWithApiKey;
|
|
16985
|
-
const home =
|
|
16986
|
-
|
|
16987
|
-
|
|
16988
|
-
|
|
16989
|
-
|
|
16990
|
-
|
|
16991
|
-
] : [
|
|
17018
|
+
const home = os59.homeDir();
|
|
17019
|
+
os59.augmentPath(
|
|
17020
|
+
os59.id === "win32" ? [
|
|
17021
|
+
path36.join(home, ".local", "bin"),
|
|
17022
|
+
path36.join(process.env.APPDATA ?? path36.join(home, "AppData", "Roaming"), "npm"),
|
|
17023
|
+
path36.join(home, "scoop", "shims")
|
|
17024
|
+
] : [path36.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"]
|
|
16992
17025
|
);
|
|
16993
|
-
const installed2 =
|
|
17026
|
+
const installed2 = os59.findInPath("coderabbit") !== null;
|
|
16994
17027
|
const base = () => ({
|
|
16995
17028
|
action: input.action,
|
|
16996
17029
|
supported: true,
|
|
16997
|
-
installed:
|
|
17030
|
+
installed: os59.findInPath("coderabbit") !== null,
|
|
16998
17031
|
loggedIn: false
|
|
16999
17032
|
});
|
|
17000
17033
|
if (input.action === "status") {
|
|
@@ -17008,7 +17041,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
17008
17041
|
const key = (input.apiKey ?? "").trim();
|
|
17009
17042
|
if (!key) return { ...res2, error: "No API key provided" };
|
|
17010
17043
|
if (!res2.installed) {
|
|
17011
|
-
const ok = await ensureInstalled(
|
|
17044
|
+
const ok = await ensureInstalled(os59);
|
|
17012
17045
|
res2.installed = ok;
|
|
17013
17046
|
if (!ok) return { ...res2, error: "CodeRabbit CLI could not be installed" };
|
|
17014
17047
|
}
|
|
@@ -17032,7 +17065,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
17032
17065
|
}
|
|
17033
17066
|
if (!res2.installed) {
|
|
17034
17067
|
deps.onEvent?.({ kind: "installing" });
|
|
17035
|
-
const ok = await ensureInstalled(
|
|
17068
|
+
const ok = await ensureInstalled(os59);
|
|
17036
17069
|
res2.installed = ok;
|
|
17037
17070
|
if (!ok) return { ...res2, error: "CodeRabbit CLI could not be installed" };
|
|
17038
17071
|
}
|
|
@@ -17062,7 +17095,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
17062
17095
|
const res2 = base();
|
|
17063
17096
|
if (!installed2) {
|
|
17064
17097
|
deps.onEvent?.({ kind: "installing" });
|
|
17065
|
-
const ok = await ensureInstalled(
|
|
17098
|
+
const ok = await ensureInstalled(os59);
|
|
17066
17099
|
res2.installed = ok;
|
|
17067
17100
|
if (!ok) return { ...res2, error: "CodeRabbit CLI could not be installed" };
|
|
17068
17101
|
}
|
|
@@ -17102,7 +17135,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
17102
17135
|
}
|
|
17103
17136
|
const res = base();
|
|
17104
17137
|
if (!res.installed) {
|
|
17105
|
-
const ok = await ensureInstalled(
|
|
17138
|
+
const ok = await ensureInstalled(os59);
|
|
17106
17139
|
res.installed = ok;
|
|
17107
17140
|
if (!ok) return { ...res, error: "CodeRabbit CLI is not installed" };
|
|
17108
17141
|
}
|
|
@@ -17286,9 +17319,9 @@ function defaultRunGh(args2) {
|
|
|
17286
17319
|
|
|
17287
17320
|
// src/commands/host-agent.ts
|
|
17288
17321
|
var import_node_child_process25 = require("child_process");
|
|
17289
|
-
var
|
|
17290
|
-
var
|
|
17291
|
-
var
|
|
17322
|
+
var os38 = __toESM(require("os"));
|
|
17323
|
+
var fs43 = __toESM(require("fs"));
|
|
17324
|
+
var path46 = __toESM(require("path"));
|
|
17292
17325
|
|
|
17293
17326
|
// src/integrations/manifest.ts
|
|
17294
17327
|
var import_node_fs7 = __toESM(require("fs"));
|
|
@@ -17434,14 +17467,14 @@ function describeReason(reason) {
|
|
|
17434
17467
|
}
|
|
17435
17468
|
|
|
17436
17469
|
// src/commands/host/host-client.ts
|
|
17437
|
-
var
|
|
17438
|
-
var
|
|
17439
|
-
var
|
|
17470
|
+
var fs35 = __toESM(require("fs"));
|
|
17471
|
+
var os31 = __toESM(require("os"));
|
|
17472
|
+
var path39 = __toESM(require("path"));
|
|
17440
17473
|
var import_node_crypto9 = require("crypto");
|
|
17441
17474
|
function sampleCpuTimes() {
|
|
17442
17475
|
let idle = 0;
|
|
17443
17476
|
let total = 0;
|
|
17444
|
-
for (const cpu of
|
|
17477
|
+
for (const cpu of os31.cpus()) {
|
|
17445
17478
|
const t2 = cpu.times;
|
|
17446
17479
|
idle += t2.idle;
|
|
17447
17480
|
total += t2.user + t2.nice + t2.sys + t2.idle + t2.irq;
|
|
@@ -17460,8 +17493,8 @@ var MetricsCollector = class {
|
|
|
17460
17493
|
const prev = this.prevCpu;
|
|
17461
17494
|
this.prevCpu = current;
|
|
17462
17495
|
if (!prev) {
|
|
17463
|
-
const cores =
|
|
17464
|
-
const proxy =
|
|
17496
|
+
const cores = os31.cpus().length || 1;
|
|
17497
|
+
const proxy = os31.loadavg()[0] / cores * 100;
|
|
17465
17498
|
return Math.min(100, Math.max(0, Math.round(proxy)));
|
|
17466
17499
|
}
|
|
17467
17500
|
const idleDelta = current.idle - prev.idle;
|
|
@@ -17474,8 +17507,8 @@ var MetricsCollector = class {
|
|
|
17474
17507
|
collect() {
|
|
17475
17508
|
return {
|
|
17476
17509
|
cpuPct: this.cpuPct(),
|
|
17477
|
-
ramUsedMb: Math.round((
|
|
17478
|
-
ramTotalMb: Math.round(
|
|
17510
|
+
ramUsedMb: Math.round((os31.totalmem() - os31.freemem()) / 1048576),
|
|
17511
|
+
ramTotalMb: Math.round(os31.totalmem() / 1048576),
|
|
17479
17512
|
latencyMs: this.lastLatencyMs
|
|
17480
17513
|
};
|
|
17481
17514
|
}
|
|
@@ -17484,19 +17517,19 @@ function apiBase() {
|
|
|
17484
17517
|
return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
|
|
17485
17518
|
}
|
|
17486
17519
|
function hostIdentityPath() {
|
|
17487
|
-
return
|
|
17520
|
+
return path39.join(os31.homedir(), ".codeam", "host-agent.json");
|
|
17488
17521
|
}
|
|
17489
17522
|
function collectOsInfo() {
|
|
17490
17523
|
return {
|
|
17491
|
-
distro:
|
|
17492
|
-
arch:
|
|
17493
|
-
kernel:
|
|
17524
|
+
distro: os31.platform(),
|
|
17525
|
+
arch: os31.arch(),
|
|
17526
|
+
kernel: os31.release(),
|
|
17494
17527
|
nodeVersion: process.versions.node
|
|
17495
17528
|
};
|
|
17496
17529
|
}
|
|
17497
17530
|
function loadHostIdentity() {
|
|
17498
17531
|
try {
|
|
17499
|
-
const raw =
|
|
17532
|
+
const raw = fs35.readFileSync(hostIdentityPath(), "utf8");
|
|
17500
17533
|
const parsed = JSON.parse(raw);
|
|
17501
17534
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
|
|
17502
17535
|
const p2 = parsed;
|
|
@@ -17515,8 +17548,8 @@ function loadHostIdentity() {
|
|
|
17515
17548
|
}
|
|
17516
17549
|
function saveHostIdentity(identity) {
|
|
17517
17550
|
const file = hostIdentityPath();
|
|
17518
|
-
|
|
17519
|
-
|
|
17551
|
+
fs35.mkdirSync(path39.dirname(file), { recursive: true, mode: 448 });
|
|
17552
|
+
fs35.writeFileSync(file, JSON.stringify(identity, null, 2), {
|
|
17520
17553
|
encoding: "utf8",
|
|
17521
17554
|
mode: 384
|
|
17522
17555
|
});
|
|
@@ -17561,7 +17594,7 @@ function isTerminalEnrollError(err) {
|
|
|
17561
17594
|
}
|
|
17562
17595
|
function deleteHostIdentity() {
|
|
17563
17596
|
try {
|
|
17564
|
-
|
|
17597
|
+
fs35.rmSync(hostIdentityPath(), { force: true });
|
|
17565
17598
|
} catch {
|
|
17566
17599
|
}
|
|
17567
17600
|
}
|
|
@@ -17585,7 +17618,7 @@ async function postJson(pathname, body) {
|
|
|
17585
17618
|
function resolveHostLabel(label) {
|
|
17586
17619
|
const explicit = label?.trim();
|
|
17587
17620
|
const envLabel = process.env.CODEAM_HOST_LABEL?.trim();
|
|
17588
|
-
const resolved = explicit || envLabel ||
|
|
17621
|
+
const resolved = explicit || envLabel || os31.hostname();
|
|
17589
17622
|
return resolved.slice(0, 80);
|
|
17590
17623
|
}
|
|
17591
17624
|
async function redeemEnrollToken(token, label) {
|
|
@@ -17696,17 +17729,17 @@ async function reportDeployProgress(auth, deployId, step, message, sessionId) {
|
|
|
17696
17729
|
}
|
|
17697
17730
|
|
|
17698
17731
|
// src/commands/host/workspace.ts
|
|
17699
|
-
var
|
|
17700
|
-
var
|
|
17701
|
-
var
|
|
17732
|
+
var fs36 = __toESM(require("fs"));
|
|
17733
|
+
var os32 = __toESM(require("os"));
|
|
17734
|
+
var path40 = __toESM(require("path"));
|
|
17702
17735
|
var import_node_child_process19 = require("child_process");
|
|
17703
17736
|
var import_node_util4 = require("util");
|
|
17704
17737
|
var execFileP4 = (0, import_node_util4.promisify)(import_node_child_process19.execFile);
|
|
17705
17738
|
function isAbsolutePathTarget(target) {
|
|
17706
|
-
return
|
|
17739
|
+
return path40.isAbsolute(target);
|
|
17707
17740
|
}
|
|
17708
17741
|
function selfHostedWorkspaceRoot() {
|
|
17709
|
-
return
|
|
17742
|
+
return path40.join(os32.homedir(), ".codeam", "self-hosted");
|
|
17710
17743
|
}
|
|
17711
17744
|
function nonInteractiveGitEnv() {
|
|
17712
17745
|
return {
|
|
@@ -17776,15 +17809,15 @@ async function configureGitCredentials(dest, repoRef, cloneToken, provider = "gi
|
|
|
17776
17809
|
const isGitlab = provider === "gitlab";
|
|
17777
17810
|
if (isGitlab ? !gitlabProjectPath(repoRef.trim()) : !githubOwnerRepo(repoRef.trim())) return;
|
|
17778
17811
|
if (!cloneToken) return;
|
|
17779
|
-
const credFile =
|
|
17812
|
+
const credFile = path40.join(dest, ".git", "codeam-credentials");
|
|
17780
17813
|
const credLine = isGitlab ? `https://oauth2:${cloneToken}@gitlab.com
|
|
17781
17814
|
` : `https://x-access-token:${cloneToken}@github.com
|
|
17782
17815
|
`;
|
|
17783
|
-
|
|
17816
|
+
fs36.writeFileSync(credFile, credLine, { mode: 384 });
|
|
17784
17817
|
restrictToOwner(credFile);
|
|
17785
17818
|
const env = nonInteractiveGitEnv();
|
|
17786
17819
|
const git2 = (args2) => execFileP4("git", ["-C", dest, ...args2], { timeout: 3e4, env });
|
|
17787
|
-
const credFilePosix = credFile.split(
|
|
17820
|
+
const credFilePosix = credFile.split(path40.sep).join("/");
|
|
17788
17821
|
await git2(["config", "--local", "--replace-all", "credential.helper", ""]).catch(() => {
|
|
17789
17822
|
});
|
|
17790
17823
|
await git2([
|
|
@@ -17817,17 +17850,17 @@ function maskToken(text, cloneToken) {
|
|
|
17817
17850
|
}
|
|
17818
17851
|
async function prepareWorkspace(repoOrPath, deployId, cloneToken, provider = "github", branch) {
|
|
17819
17852
|
if (isAbsolutePathTarget(repoOrPath)) {
|
|
17820
|
-
if (!
|
|
17853
|
+
if (!fs36.existsSync(repoOrPath)) {
|
|
17821
17854
|
throw new Error(`deploy target path does not exist: ${repoOrPath}`);
|
|
17822
17855
|
}
|
|
17823
17856
|
return repoOrPath;
|
|
17824
17857
|
}
|
|
17825
|
-
const dest =
|
|
17826
|
-
if (
|
|
17858
|
+
const dest = path40.join(selfHostedWorkspaceRoot(), deployId);
|
|
17859
|
+
if (fs36.existsSync(path40.join(dest, ".git"))) {
|
|
17827
17860
|
if (cloneToken) await configureGitCredentials(dest, repoOrPath, cloneToken, provider);
|
|
17828
17861
|
return dest;
|
|
17829
17862
|
}
|
|
17830
|
-
|
|
17863
|
+
fs36.mkdirSync(selfHostedWorkspaceRoot(), { recursive: true, mode: 448 });
|
|
17831
17864
|
const cloneUrl = repoCloneUrl(repoOrPath, cloneToken, provider);
|
|
17832
17865
|
const cloneArgs = branch ? ["clone", "--depth", "1", "--branch", branch, cloneUrl, dest] : ["clone", "--depth", "1", cloneUrl, dest];
|
|
17833
17866
|
try {
|
|
@@ -17845,9 +17878,9 @@ async function prepareWorkspace(repoOrPath, deployId, cloneToken, provider = "gi
|
|
|
17845
17878
|
}
|
|
17846
17879
|
|
|
17847
17880
|
// src/commands/host/agent-provisioning.ts
|
|
17848
|
-
var
|
|
17849
|
-
var
|
|
17850
|
-
var
|
|
17881
|
+
var fs37 = __toESM(require("fs"));
|
|
17882
|
+
var os33 = __toESM(require("os"));
|
|
17883
|
+
var path41 = __toESM(require("path"));
|
|
17851
17884
|
var PUBLIC_TO_INTERNAL_AGENT = {
|
|
17852
17885
|
claude_code: "claude",
|
|
17853
17886
|
claude: "claude",
|
|
@@ -17864,22 +17897,22 @@ function toInternalAgentId(publicAgentId) {
|
|
|
17864
17897
|
return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
|
|
17865
17898
|
}
|
|
17866
17899
|
function ensureDir(dir) {
|
|
17867
|
-
|
|
17900
|
+
fs37.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
17868
17901
|
}
|
|
17869
17902
|
function writeFile0600(filePath, contents) {
|
|
17870
|
-
ensureDir(
|
|
17871
|
-
|
|
17903
|
+
ensureDir(path41.dirname(filePath));
|
|
17904
|
+
fs37.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
|
|
17872
17905
|
restrictToOwner(filePath);
|
|
17873
17906
|
}
|
|
17874
17907
|
function rmIfExists(filePath) {
|
|
17875
17908
|
try {
|
|
17876
|
-
|
|
17909
|
+
fs37.rmSync(filePath, { force: true });
|
|
17877
17910
|
} catch {
|
|
17878
17911
|
}
|
|
17879
17912
|
}
|
|
17880
17913
|
var claudeProvisioner = {
|
|
17881
17914
|
write(auth, home) {
|
|
17882
|
-
const credentialsJson =
|
|
17915
|
+
const credentialsJson = path41.join(home, ".claude", ".credentials.json");
|
|
17883
17916
|
if (auth.kind === "api_key") {
|
|
17884
17917
|
rmIfExists(credentialsJson);
|
|
17885
17918
|
return { ANTHROPIC_API_KEY: auth.value };
|
|
@@ -17891,8 +17924,8 @@ var claudeProvisioner = {
|
|
|
17891
17924
|
} else {
|
|
17892
17925
|
rmIfExists(credentialsJson);
|
|
17893
17926
|
}
|
|
17894
|
-
const claudeJson =
|
|
17895
|
-
if (!
|
|
17927
|
+
const claudeJson = path41.join(home, ".claude.json");
|
|
17928
|
+
if (!fs37.existsSync(claudeJson)) {
|
|
17896
17929
|
writeFile0600(
|
|
17897
17930
|
claudeJson,
|
|
17898
17931
|
JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
|
|
@@ -17903,7 +17936,7 @@ var claudeProvisioner = {
|
|
|
17903
17936
|
};
|
|
17904
17937
|
var codexProvisioner = {
|
|
17905
17938
|
write(auth, home) {
|
|
17906
|
-
const authJson =
|
|
17939
|
+
const authJson = path41.join(home, ".codex", "auth.json");
|
|
17907
17940
|
if (auth.kind === "api_key") {
|
|
17908
17941
|
rmIfExists(authJson);
|
|
17909
17942
|
return { OPENAI_API_KEY: auth.value };
|
|
@@ -17914,8 +17947,8 @@ var codexProvisioner = {
|
|
|
17914
17947
|
};
|
|
17915
17948
|
var geminiProvisioner = {
|
|
17916
17949
|
write(auth, home) {
|
|
17917
|
-
const settingsJson =
|
|
17918
|
-
const oauthCreds =
|
|
17950
|
+
const settingsJson = path41.join(home, ".gemini", "settings.json");
|
|
17951
|
+
const oauthCreds = path41.join(home, ".gemini", "oauth_creds.json");
|
|
17919
17952
|
if (auth.kind === "api_key") {
|
|
17920
17953
|
rmIfExists(oauthCreds);
|
|
17921
17954
|
writeFile0600(settingsJson, '{"security":{"auth":{"selectedType":"gemini-api-key"}}}');
|
|
@@ -17928,7 +17961,7 @@ var geminiProvisioner = {
|
|
|
17928
17961
|
};
|
|
17929
17962
|
var cursorProvisioner = {
|
|
17930
17963
|
write(auth, home) {
|
|
17931
|
-
const authJson =
|
|
17964
|
+
const authJson = path41.join(home, ".config", "cursor", "auth.json");
|
|
17932
17965
|
if (auth.kind === "api_key") {
|
|
17933
17966
|
rmIfExists(authJson);
|
|
17934
17967
|
return { CURSOR_API_KEY: auth.value };
|
|
@@ -17970,22 +18003,22 @@ max_context_size = 262144
|
|
|
17970
18003
|
var kimiProvisioner = {
|
|
17971
18004
|
write(auth, home) {
|
|
17972
18005
|
const credentialsFiles = [
|
|
17973
|
-
|
|
17974
|
-
|
|
18006
|
+
path41.join(home, ".kimi", "credentials", "kimi-code.json"),
|
|
18007
|
+
path41.join(home, ".kimi-code", "credentials", "kimi-code.json")
|
|
17975
18008
|
];
|
|
17976
18009
|
if (auth.kind === "api_key") {
|
|
17977
18010
|
credentialsFiles.forEach(rmIfExists);
|
|
17978
18011
|
return { KIMI_API_KEY: auth.value };
|
|
17979
18012
|
}
|
|
17980
18013
|
credentialsFiles.forEach((f) => writeFile0600(f, auth.value));
|
|
17981
|
-
writeFile0600(
|
|
18014
|
+
writeFile0600(path41.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
|
|
17982
18015
|
return {};
|
|
17983
18016
|
}
|
|
17984
18017
|
};
|
|
17985
18018
|
var coderabbitProvisioner = {
|
|
17986
18019
|
write(auth, home) {
|
|
17987
|
-
const dir =
|
|
17988
|
-
const authJson =
|
|
18020
|
+
const dir = path41.join(home, ".coderabbit");
|
|
18021
|
+
const authJson = path41.join(dir, "auth.json");
|
|
17989
18022
|
if (auth.kind === "api_key") {
|
|
17990
18023
|
rmIfExists(authJson);
|
|
17991
18024
|
return { CODERABBIT_API_KEY: auth.value };
|
|
@@ -17997,21 +18030,21 @@ var coderabbitProvisioner = {
|
|
|
17997
18030
|
try {
|
|
17998
18031
|
const parsed = JSON.parse(value);
|
|
17999
18032
|
if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
|
|
18000
|
-
file =
|
|
18033
|
+
file = path41.basename(parsed.file);
|
|
18001
18034
|
contents = parsed.contents;
|
|
18002
18035
|
}
|
|
18003
18036
|
} catch {
|
|
18004
18037
|
}
|
|
18005
18038
|
}
|
|
18006
|
-
writeFile0600(
|
|
18039
|
+
writeFile0600(path41.join(dir, file), contents);
|
|
18007
18040
|
return {};
|
|
18008
18041
|
}
|
|
18009
18042
|
};
|
|
18010
18043
|
var opencodeProvisioner = {
|
|
18011
|
-
write(auth
|
|
18012
|
-
const
|
|
18013
|
-
|
|
18014
|
-
return {};
|
|
18044
|
+
write(auth) {
|
|
18045
|
+
const key = auth.value.trim();
|
|
18046
|
+
const envName = key.startsWith("sk-ant-") ? "ANTHROPIC_API_KEY" : key.startsWith("AIza") ? "GEMINI_API_KEY" : "OPENAI_API_KEY";
|
|
18047
|
+
return { [envName]: key };
|
|
18015
18048
|
}
|
|
18016
18049
|
};
|
|
18017
18050
|
var PROVISIONERS = {
|
|
@@ -18031,7 +18064,7 @@ var UnsupportedAgentError = class extends Error {
|
|
|
18031
18064
|
this.agentId = agentId;
|
|
18032
18065
|
}
|
|
18033
18066
|
};
|
|
18034
|
-
function provisionAgentCredentials(publicAgentId, auth, homeDir2 =
|
|
18067
|
+
function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os33.homedir()) {
|
|
18035
18068
|
const internal = toInternalAgentId(publicAgentId);
|
|
18036
18069
|
if (!internal) throw new UnsupportedAgentError(publicAgentId);
|
|
18037
18070
|
const provisioner = PROVISIONERS[internal];
|
|
@@ -18041,11 +18074,11 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os34.homedir(
|
|
|
18041
18074
|
|
|
18042
18075
|
// src/commands/host/git-tooling.ts
|
|
18043
18076
|
var import_node_child_process20 = require("child_process");
|
|
18044
|
-
var
|
|
18045
|
-
var
|
|
18046
|
-
var
|
|
18077
|
+
var fs38 = __toESM(require("fs"));
|
|
18078
|
+
var os34 = __toESM(require("os"));
|
|
18079
|
+
var path42 = __toESM(require("path"));
|
|
18047
18080
|
function codeamBinDir() {
|
|
18048
|
-
return process.env.CODEAM_BIN_DIR ??
|
|
18081
|
+
return process.env.CODEAM_BIN_DIR ?? path42.join(os34.homedir(), ".codeam", "bin");
|
|
18049
18082
|
}
|
|
18050
18083
|
var FALLBACK_GH_VERSION = "2.62.0";
|
|
18051
18084
|
var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
|
|
@@ -18077,7 +18110,7 @@ async function download(url2, dest) {
|
|
|
18077
18110
|
const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
|
|
18078
18111
|
if (!res.ok || !res.body) return false;
|
|
18079
18112
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
18080
|
-
|
|
18113
|
+
fs38.writeFileSync(dest, buf);
|
|
18081
18114
|
return true;
|
|
18082
18115
|
} catch {
|
|
18083
18116
|
return false;
|
|
@@ -18100,8 +18133,8 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
18100
18133
|
const version3 = await resolveVersionFn(token);
|
|
18101
18134
|
const asset = `gh_${version3}_${osToken}_${arch2}`;
|
|
18102
18135
|
const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
|
|
18103
|
-
const tmpRoot =
|
|
18104
|
-
const archive =
|
|
18136
|
+
const tmpRoot = fs38.mkdtempSync(path42.join(os34.tmpdir(), "codeam-gh-"));
|
|
18137
|
+
const archive = path42.join(tmpRoot, `${asset}.${ext}`);
|
|
18105
18138
|
if (!await downloadFn(url2, archive)) {
|
|
18106
18139
|
log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
|
|
18107
18140
|
return null;
|
|
@@ -18111,16 +18144,16 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
18111
18144
|
log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
|
|
18112
18145
|
return null;
|
|
18113
18146
|
}
|
|
18114
|
-
const extractedBin =
|
|
18115
|
-
if (!
|
|
18147
|
+
const extractedBin = path42.join(tmpRoot, asset, "bin", binaryName);
|
|
18148
|
+
if (!fs38.existsSync(extractedBin)) {
|
|
18116
18149
|
log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
|
|
18117
18150
|
return null;
|
|
18118
18151
|
}
|
|
18119
18152
|
const binDir = codeamBinDir();
|
|
18120
|
-
|
|
18121
|
-
const target =
|
|
18122
|
-
|
|
18123
|
-
|
|
18153
|
+
fs38.mkdirSync(binDir, { recursive: true });
|
|
18154
|
+
const target = path42.join(binDir, binaryName);
|
|
18155
|
+
fs38.copyFileSync(extractedBin, target);
|
|
18156
|
+
fs38.chmodSync(target, 493);
|
|
18124
18157
|
log.info("host-agent", `gh installed to ${target} (v${version3})`);
|
|
18125
18158
|
return target;
|
|
18126
18159
|
} catch (e) {
|
|
@@ -18180,8 +18213,8 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
18180
18213
|
const version3 = await resolveLatestGlabVersion();
|
|
18181
18214
|
const asset = `glab_${version3}_${osToken}_${arch2}`;
|
|
18182
18215
|
const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
|
|
18183
|
-
const tmpRoot =
|
|
18184
|
-
const archive =
|
|
18216
|
+
const tmpRoot = fs38.mkdtempSync(path42.join(os34.tmpdir(), "codeam-glab-"));
|
|
18217
|
+
const archive = path42.join(tmpRoot, `${asset}.${ext}`);
|
|
18185
18218
|
if (!await downloadFn(url2, archive)) {
|
|
18186
18219
|
log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
|
|
18187
18220
|
return null;
|
|
@@ -18192,20 +18225,20 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
18192
18225
|
return null;
|
|
18193
18226
|
}
|
|
18194
18227
|
const candidates = [
|
|
18195
|
-
|
|
18196
|
-
|
|
18197
|
-
|
|
18228
|
+
path42.join(tmpRoot, "bin", binaryName),
|
|
18229
|
+
path42.join(tmpRoot, asset, "bin", binaryName),
|
|
18230
|
+
path42.join(tmpRoot, binaryName)
|
|
18198
18231
|
];
|
|
18199
|
-
const extractedBin = candidates.find((c2) =>
|
|
18232
|
+
const extractedBin = candidates.find((c2) => fs38.existsSync(c2));
|
|
18200
18233
|
if (!extractedBin) {
|
|
18201
18234
|
log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
|
|
18202
18235
|
return null;
|
|
18203
18236
|
}
|
|
18204
18237
|
const binDir = codeamBinDir();
|
|
18205
|
-
|
|
18206
|
-
const target =
|
|
18207
|
-
|
|
18208
|
-
|
|
18238
|
+
fs38.mkdirSync(binDir, { recursive: true });
|
|
18239
|
+
const target = path42.join(binDir, binaryName);
|
|
18240
|
+
fs38.copyFileSync(extractedBin, target);
|
|
18241
|
+
fs38.chmodSync(target, 493);
|
|
18209
18242
|
log.info("host-agent", `glab installed to ${target} (v${version3})`);
|
|
18210
18243
|
return target;
|
|
18211
18244
|
} catch (e) {
|
|
@@ -18693,24 +18726,24 @@ async function ensureModernPython(runner) {
|
|
|
18693
18726
|
}
|
|
18694
18727
|
|
|
18695
18728
|
// src/commands/host/headroom-bootstrap.ts
|
|
18696
|
-
var fs41 = __toESM(require("fs"));
|
|
18697
|
-
var path45 = __toESM(require("path"));
|
|
18698
|
-
var os37 = __toESM(require("os"));
|
|
18699
|
-
|
|
18700
|
-
// src/commands/host/headroom-config.ts
|
|
18701
18729
|
var fs40 = __toESM(require("fs"));
|
|
18702
|
-
var os36 = __toESM(require("os"));
|
|
18703
18730
|
var path44 = __toESM(require("path"));
|
|
18731
|
+
var os36 = __toESM(require("os"));
|
|
18732
|
+
|
|
18733
|
+
// src/commands/host/headroom-config.ts
|
|
18734
|
+
var fs39 = __toESM(require("fs"));
|
|
18735
|
+
var os35 = __toESM(require("os"));
|
|
18736
|
+
var path43 = __toESM(require("path"));
|
|
18704
18737
|
function headroomConfigPath() {
|
|
18705
|
-
return
|
|
18738
|
+
return path43.join(os35.homedir(), ".codeam", "headroom-config.json");
|
|
18706
18739
|
}
|
|
18707
18740
|
function persistHeadroomConfig(config) {
|
|
18708
18741
|
try {
|
|
18709
18742
|
const file = headroomConfigPath();
|
|
18710
|
-
|
|
18743
|
+
fs39.mkdirSync(path43.dirname(file), { recursive: true, mode: 448 });
|
|
18711
18744
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
18712
|
-
|
|
18713
|
-
|
|
18745
|
+
fs39.writeFileSync(tmp, JSON.stringify(config, null, 2), { encoding: "utf8", mode: 384 });
|
|
18746
|
+
fs39.renameSync(tmp, file);
|
|
18714
18747
|
restrictToOwner(file);
|
|
18715
18748
|
} catch (err) {
|
|
18716
18749
|
log.warn(
|
|
@@ -18720,21 +18753,21 @@ function persistHeadroomConfig(config) {
|
|
|
18720
18753
|
}
|
|
18721
18754
|
}
|
|
18722
18755
|
function agentSettingsPath(kind) {
|
|
18723
|
-
const home =
|
|
18724
|
-
if (kind === "claude") return
|
|
18725
|
-
if (kind === "codex") return
|
|
18726
|
-
if (kind === "copilot") return
|
|
18756
|
+
const home = os35.homedir();
|
|
18757
|
+
if (kind === "claude") return path43.join(home, ".claude", "settings.json");
|
|
18758
|
+
if (kind === "codex") return path43.join(home, ".codex", "auth.json");
|
|
18759
|
+
if (kind === "copilot") return path43.join(home, ".config", "github-copilot", "hosts.json");
|
|
18727
18760
|
return null;
|
|
18728
18761
|
}
|
|
18729
18762
|
function backupAgentHeadroomConfig(kind) {
|
|
18730
18763
|
const src = agentSettingsPath(kind);
|
|
18731
18764
|
if (!src) return;
|
|
18732
18765
|
try {
|
|
18733
|
-
if (!
|
|
18734
|
-
const dest =
|
|
18735
|
-
|
|
18736
|
-
|
|
18737
|
-
|
|
18766
|
+
if (!fs39.existsSync(src)) return;
|
|
18767
|
+
const dest = path43.join(os35.homedir(), ".codeam", `headroom-backup-${kind}.json`);
|
|
18768
|
+
fs39.mkdirSync(path43.dirname(dest), { recursive: true, mode: 448 });
|
|
18769
|
+
fs39.copyFileSync(src, dest);
|
|
18770
|
+
fs39.chmodSync(dest, 384);
|
|
18738
18771
|
log.info("host-agent", `headroom config backup: ${src} \u2192 ${dest}`);
|
|
18739
18772
|
} catch (err) {
|
|
18740
18773
|
log.warn(
|
|
@@ -18746,12 +18779,12 @@ function backupAgentHeadroomConfig(kind) {
|
|
|
18746
18779
|
function restoreAgentHeadroomConfig(kind) {
|
|
18747
18780
|
const dest = agentSettingsPath(kind);
|
|
18748
18781
|
if (!dest) return false;
|
|
18749
|
-
const src =
|
|
18750
|
-
if (!
|
|
18782
|
+
const src = path43.join(os35.homedir(), ".codeam", `headroom-backup-${kind}.json`);
|
|
18783
|
+
if (!fs39.existsSync(src)) return false;
|
|
18751
18784
|
try {
|
|
18752
|
-
|
|
18753
|
-
|
|
18754
|
-
|
|
18785
|
+
fs39.mkdirSync(path43.dirname(dest), { recursive: true, mode: 448 });
|
|
18786
|
+
fs39.copyFileSync(src, dest);
|
|
18787
|
+
fs39.chmodSync(dest, 384);
|
|
18755
18788
|
log.info("host-agent", `headroom config restored: ${src} \u2192 ${dest}`);
|
|
18756
18789
|
return true;
|
|
18757
18790
|
} catch (err) {
|
|
@@ -18764,7 +18797,7 @@ function restoreAgentHeadroomConfig(kind) {
|
|
|
18764
18797
|
}
|
|
18765
18798
|
function readHeadroomChildEnv() {
|
|
18766
18799
|
try {
|
|
18767
|
-
const raw =
|
|
18800
|
+
const raw = fs39.readFileSync(headroomConfigPath(), "utf8");
|
|
18768
18801
|
const parsed = JSON.parse(raw);
|
|
18769
18802
|
if (typeof parsed !== "object" || parsed === null) return {};
|
|
18770
18803
|
const o = parsed;
|
|
@@ -18800,49 +18833,49 @@ function bundledClaudeBinDir() {
|
|
|
18800
18833
|
const roots = /* @__PURE__ */ new Set();
|
|
18801
18834
|
let dir = __dirname;
|
|
18802
18835
|
for (let i = 0; i < 6; i++) {
|
|
18803
|
-
roots.add(
|
|
18804
|
-
const parent =
|
|
18836
|
+
roots.add(path44.join(dir, "node_modules"));
|
|
18837
|
+
const parent = path44.dirname(dir);
|
|
18805
18838
|
if (parent === dir) break;
|
|
18806
18839
|
dir = parent;
|
|
18807
18840
|
}
|
|
18808
18841
|
try {
|
|
18809
18842
|
const main2 = require.resolve("@anthropic-ai/claude-agent-sdk");
|
|
18810
|
-
const marker = `${
|
|
18843
|
+
const marker = `${path44.sep}@anthropic-ai${path44.sep}`;
|
|
18811
18844
|
const idx = main2.lastIndexOf(marker);
|
|
18812
18845
|
if (idx !== -1) roots.add(main2.slice(0, idx));
|
|
18813
18846
|
} catch {
|
|
18814
18847
|
}
|
|
18815
18848
|
for (const nm of roots) {
|
|
18816
|
-
const atAnthropic =
|
|
18849
|
+
const atAnthropic = path44.join(nm, "@anthropic-ai");
|
|
18817
18850
|
let entries;
|
|
18818
18851
|
try {
|
|
18819
|
-
entries =
|
|
18852
|
+
entries = fs40.readdirSync(atAnthropic);
|
|
18820
18853
|
} catch {
|
|
18821
18854
|
continue;
|
|
18822
18855
|
}
|
|
18823
18856
|
for (const entry of entries) {
|
|
18824
18857
|
if (!entry.startsWith("claude-agent-sdk-")) continue;
|
|
18825
|
-
const bin =
|
|
18826
|
-
if (
|
|
18858
|
+
const bin = path44.join(atAnthropic, entry, "claude");
|
|
18859
|
+
if (fs40.existsSync(bin)) return path44.dirname(bin);
|
|
18827
18860
|
}
|
|
18828
18861
|
}
|
|
18829
18862
|
return null;
|
|
18830
18863
|
}
|
|
18831
18864
|
async function getFreeDiskBytes(dir) {
|
|
18832
18865
|
try {
|
|
18833
|
-
const s = await
|
|
18866
|
+
const s = await fs40.promises.statfs(dir);
|
|
18834
18867
|
return s.bsize * s.bavail;
|
|
18835
18868
|
} catch {
|
|
18836
18869
|
return null;
|
|
18837
18870
|
}
|
|
18838
18871
|
}
|
|
18839
18872
|
function headroomModelsCached() {
|
|
18840
|
-
const hubDir = process.env.HUGGINGFACE_HUB_CACHE ||
|
|
18841
|
-
process.env.HF_HOME ||
|
|
18873
|
+
const hubDir = process.env.HUGGINGFACE_HUB_CACHE || path44.join(
|
|
18874
|
+
process.env.HF_HOME || path44.join(os36.homedir(), ".cache", "huggingface"),
|
|
18842
18875
|
"hub"
|
|
18843
18876
|
);
|
|
18844
18877
|
return HEADROOM_MODELS.every(
|
|
18845
|
-
(m) =>
|
|
18878
|
+
(m) => fs40.existsSync(path44.join(hubDir, `models--${m.repo.replace("/", "--")}`))
|
|
18846
18879
|
);
|
|
18847
18880
|
}
|
|
18848
18881
|
async function setupHeadroomForSelfHosted(agent, runner = defaultHeadroomRunner, opts = {}) {
|
|
@@ -18911,7 +18944,7 @@ async function setupHeadroomForSelfHosted(agent, runner = defaultHeadroomRunner,
|
|
|
18911
18944
|
if (initKind === "claude") {
|
|
18912
18945
|
const claudeDir = bundledClaudeBinDir();
|
|
18913
18946
|
if (claudeDir) {
|
|
18914
|
-
initEnv.PATH = `${claudeDir}${
|
|
18947
|
+
initEnv.PATH = `${claudeDir}${path44.delimiter}${process.env["PATH"] ?? ""}`;
|
|
18915
18948
|
log.info("host-agent", `headroom init: bundled claude on PATH (${claudeDir})`);
|
|
18916
18949
|
} else {
|
|
18917
18950
|
log.warn("host-agent", "headroom init: bundled claude binary not found \u2014 init may fail");
|
|
@@ -18946,9 +18979,9 @@ async function setupHeadroomForSelfHosted(agent, runner = defaultHeadroomRunner,
|
|
|
18946
18979
|
var import_node_child_process23 = require("child_process");
|
|
18947
18980
|
|
|
18948
18981
|
// src/lib/updateNotifier.ts
|
|
18949
|
-
var
|
|
18950
|
-
var
|
|
18951
|
-
var
|
|
18982
|
+
var fs41 = __toESM(require("fs"));
|
|
18983
|
+
var os37 = __toESM(require("os"));
|
|
18984
|
+
var path45 = __toESM(require("path"));
|
|
18952
18985
|
var https6 = __toESM(require("https"));
|
|
18953
18986
|
var import_node_child_process22 = require("child_process");
|
|
18954
18987
|
var import_picocolors3 = __toESM(require("picocolors"));
|
|
@@ -18957,12 +18990,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
|
|
|
18957
18990
|
var TTL_MS = 24 * 60 * 60 * 1e3;
|
|
18958
18991
|
var REQUEST_TIMEOUT_MS = 1500;
|
|
18959
18992
|
function cachePath() {
|
|
18960
|
-
const dir =
|
|
18961
|
-
return
|
|
18993
|
+
const dir = path45.join(os37.homedir(), ".codeam");
|
|
18994
|
+
return path45.join(dir, "update-check.json");
|
|
18962
18995
|
}
|
|
18963
18996
|
function readCache() {
|
|
18964
18997
|
try {
|
|
18965
|
-
const raw =
|
|
18998
|
+
const raw = fs41.readFileSync(cachePath(), "utf8");
|
|
18966
18999
|
const parsed = JSON.parse(raw);
|
|
18967
19000
|
if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
|
|
18968
19001
|
return parsed;
|
|
@@ -18973,10 +19006,10 @@ function readCache() {
|
|
|
18973
19006
|
function writeCache(cache) {
|
|
18974
19007
|
try {
|
|
18975
19008
|
const file = cachePath();
|
|
18976
|
-
|
|
19009
|
+
fs41.mkdirSync(path45.dirname(file), { recursive: true });
|
|
18977
19010
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
18978
|
-
|
|
18979
|
-
|
|
19011
|
+
fs41.writeFileSync(tmp, JSON.stringify(cache));
|
|
19012
|
+
fs41.renameSync(tmp, file);
|
|
18980
19013
|
} catch {
|
|
18981
19014
|
}
|
|
18982
19015
|
}
|
|
@@ -19050,8 +19083,8 @@ function isLinkedInstall() {
|
|
|
19050
19083
|
timeout: 2e3
|
|
19051
19084
|
}).trim();
|
|
19052
19085
|
if (!root) return false;
|
|
19053
|
-
const pkgPath =
|
|
19054
|
-
return
|
|
19086
|
+
const pkgPath = path45.join(root, PKG_NAME);
|
|
19087
|
+
return fs41.lstatSync(pkgPath).isSymbolicLink();
|
|
19055
19088
|
} catch {
|
|
19056
19089
|
return false;
|
|
19057
19090
|
}
|
|
@@ -19087,7 +19120,7 @@ function maybeAutoUpdate(currentVersion, latest) {
|
|
|
19087
19120
|
return;
|
|
19088
19121
|
}
|
|
19089
19122
|
try {
|
|
19090
|
-
|
|
19123
|
+
fs41.unlinkSync(cachePath());
|
|
19091
19124
|
} catch {
|
|
19092
19125
|
}
|
|
19093
19126
|
process.stderr.write(` ${import_picocolors3.default.green("\u2713")} Updated. Resuming session...
|
|
@@ -19103,7 +19136,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
19103
19136
|
if (process.env.NODE_ENV === "test") return;
|
|
19104
19137
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
19105
19138
|
if (process.env.CI) return;
|
|
19106
|
-
const current = true ? "2.61.
|
|
19139
|
+
const current = true ? "2.61.52" : null;
|
|
19107
19140
|
if (!current) return;
|
|
19108
19141
|
const cache = readCache();
|
|
19109
19142
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -19120,7 +19153,7 @@ function checkForUpdates() {
|
|
|
19120
19153
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
19121
19154
|
if (process.env.CI) return;
|
|
19122
19155
|
if (!process.stdout.isTTY) return;
|
|
19123
|
-
const current = true ? "2.61.
|
|
19156
|
+
const current = true ? "2.61.52" : null;
|
|
19124
19157
|
if (!current) return;
|
|
19125
19158
|
const cache = readCache();
|
|
19126
19159
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -19140,7 +19173,7 @@ var SELF_UPDATE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
|
19140
19173
|
var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
|
|
19141
19174
|
var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
19142
19175
|
function currentCliVersion() {
|
|
19143
|
-
return true ? "2.61.
|
|
19176
|
+
return true ? "2.61.52" : null;
|
|
19144
19177
|
}
|
|
19145
19178
|
function runCmd(cmd, args2, timeoutMs) {
|
|
19146
19179
|
return new Promise((resolve8) => {
|
|
@@ -19207,7 +19240,7 @@ async function runSelfUpdate() {
|
|
|
19207
19240
|
|
|
19208
19241
|
// src/commands/host/teardown.ts
|
|
19209
19242
|
var import_node_child_process24 = require("child_process");
|
|
19210
|
-
var
|
|
19243
|
+
var fs42 = __toESM(require("fs"));
|
|
19211
19244
|
var defaultDisableService = () => {
|
|
19212
19245
|
try {
|
|
19213
19246
|
(0, import_node_child_process24.execFileSync)("systemctl", ["disable", "--now", "codeam-host-agent"], { stdio: "ignore" });
|
|
@@ -19216,7 +19249,7 @@ var defaultDisableService = () => {
|
|
|
19216
19249
|
};
|
|
19217
19250
|
var defaultTeardownHeadroom = () => {
|
|
19218
19251
|
try {
|
|
19219
|
-
const kind = JSON.parse(
|
|
19252
|
+
const kind = JSON.parse(fs42.readFileSync(headroomConfigPath(), "utf8")).agent;
|
|
19220
19253
|
if (kind) {
|
|
19221
19254
|
(0, import_node_child_process24.execFileSync)("headroom", ["unwrap", kind], { stdio: "ignore", timeout: 15e3 });
|
|
19222
19255
|
}
|
|
@@ -19284,8 +19317,8 @@ function maybeResumeLocalHeadroomReporter(ctx) {
|
|
|
19284
19317
|
if (process.env["HEADROOM_ENABLED"] === "1") return null;
|
|
19285
19318
|
try {
|
|
19286
19319
|
const file = headroomConfigPath();
|
|
19287
|
-
if (!
|
|
19288
|
-
const cfg = JSON.parse(
|
|
19320
|
+
if (!fs43.existsSync(file)) return null;
|
|
19321
|
+
const cfg = JSON.parse(fs43.readFileSync(file, "utf8"));
|
|
19289
19322
|
if (!cfg?.enabled) return null;
|
|
19290
19323
|
const agent = cfg.agent ?? "claude";
|
|
19291
19324
|
const ingestUrl = `${resolveApiBaseUrl()}/api/sessions/${ctx.sessionId}/headroom-savings`;
|
|
@@ -19856,13 +19889,13 @@ var HostAgentSupervisor = class {
|
|
|
19856
19889
|
const relay = this.relay;
|
|
19857
19890
|
if (!relay) return;
|
|
19858
19891
|
const raw = cmd.payload?.path;
|
|
19859
|
-
const target = typeof raw === "string" && raw.trim() ?
|
|
19892
|
+
const target = typeof raw === "string" && raw.trim() ? path46.resolve(raw.trim()) : os38.homedir();
|
|
19860
19893
|
try {
|
|
19861
|
-
const dirents = await
|
|
19894
|
+
const dirents = await fs43.promises.readdir(target, { withFileTypes: true });
|
|
19862
19895
|
const entries = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
|
|
19863
19896
|
(a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
|
|
19864
19897
|
);
|
|
19865
|
-
const parent =
|
|
19898
|
+
const parent = path46.dirname(target);
|
|
19866
19899
|
await relay.sendResult(cmd.id, "completed", {
|
|
19867
19900
|
path: target,
|
|
19868
19901
|
// null at the filesystem root so the UI can hide the ".." affordance.
|
|
@@ -20090,14 +20123,14 @@ var HostAgentSupervisor = class {
|
|
|
20090
20123
|
API_TIMEOUT_MS: "3000000",
|
|
20091
20124
|
CODEAM_AUTO_TOKEN: payload.autoPairToken
|
|
20092
20125
|
};
|
|
20093
|
-
const houseConfigDir =
|
|
20094
|
-
|
|
20126
|
+
const houseConfigDir = path46.join(
|
|
20127
|
+
os38.homedir(),
|
|
20095
20128
|
".codeam",
|
|
20096
20129
|
"house-claude",
|
|
20097
20130
|
payload.deployId
|
|
20098
20131
|
);
|
|
20099
20132
|
try {
|
|
20100
|
-
|
|
20133
|
+
fs43.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
|
|
20101
20134
|
} catch {
|
|
20102
20135
|
}
|
|
20103
20136
|
childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
|
|
@@ -20116,7 +20149,7 @@ var HostAgentSupervisor = class {
|
|
|
20116
20149
|
report("installing", "installing agent CLI");
|
|
20117
20150
|
await this.runAgentInstall(payload.agentInstallScript);
|
|
20118
20151
|
}
|
|
20119
|
-
const home = process.env.HOME ||
|
|
20152
|
+
const home = process.env.HOME || os38.homedir();
|
|
20120
20153
|
childEnv.PATH = `${home}/.local/bin:${process.env.PATH ?? ""}`;
|
|
20121
20154
|
if (payload.cloneToken) {
|
|
20122
20155
|
try {
|
|
@@ -20124,13 +20157,13 @@ var HostAgentSupervisor = class {
|
|
|
20124
20157
|
if ((payload.repoProvider ?? "github") === "gitlab") {
|
|
20125
20158
|
const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
|
|
20126
20159
|
if (glabCmd) {
|
|
20127
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
20160
|
+
childEnv.PATH = `${codeamBinDir()}${path46.delimiter}${childEnv.PATH}`;
|
|
20128
20161
|
await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
|
|
20129
20162
|
}
|
|
20130
20163
|
} else {
|
|
20131
20164
|
const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
|
|
20132
20165
|
if (ghCmd) {
|
|
20133
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
20166
|
+
childEnv.PATH = `${codeamBinDir()}${path46.delimiter}${childEnv.PATH}`;
|
|
20134
20167
|
await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
|
|
20135
20168
|
}
|
|
20136
20169
|
}
|
|
@@ -20147,7 +20180,7 @@ var HostAgentSupervisor = class {
|
|
|
20147
20180
|
}
|
|
20148
20181
|
if (payload.headroomEnabled && payload.headroomAgent && payload.headroomSavingsIngestUrl && isHeadroomSupportedAgent(payload.headroomAgent)) {
|
|
20149
20182
|
report("headroom", "setting up Headroom proxy");
|
|
20150
|
-
const freeBytes = await this.getFreeDisk(
|
|
20183
|
+
const freeBytes = await this.getFreeDisk(os38.homedir());
|
|
20151
20184
|
const alreadyInstalled = this.isHeadroomInstalled();
|
|
20152
20185
|
if (!alreadyInstalled && freeBytes !== null && freeBytes < HEADROOM_MIN_FREE_DISK_BYTES) {
|
|
20153
20186
|
const freeGb = (freeBytes / 1e9).toFixed(1);
|
|
@@ -20338,7 +20371,7 @@ var HostAgentSupervisor = class {
|
|
|
20338
20371
|
*/
|
|
20339
20372
|
runAgentInstall(script) {
|
|
20340
20373
|
return new Promise((resolve8) => {
|
|
20341
|
-
const home = process.env.HOME ||
|
|
20374
|
+
const home = process.env.HOME || os38.homedir();
|
|
20342
20375
|
const child = (0, import_node_child_process25.spawn)("sh", ["-c", script], {
|
|
20343
20376
|
env: { ...process.env, HOME: home },
|
|
20344
20377
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -20530,9 +20563,9 @@ async function configureHeadroom(action, ctx, deps) {
|
|
|
20530
20563
|
}
|
|
20531
20564
|
|
|
20532
20565
|
// src/services/headroom/budget-relaunch.ts
|
|
20533
|
-
var
|
|
20534
|
-
var
|
|
20535
|
-
var
|
|
20566
|
+
var fs44 = __toESM(require("fs"));
|
|
20567
|
+
var os39 = __toESM(require("os"));
|
|
20568
|
+
var path47 = __toESM(require("path"));
|
|
20536
20569
|
var import_child_process13 = require("child_process");
|
|
20537
20570
|
function amendDeploymentManifestBudget(manifest, budget) {
|
|
20538
20571
|
const rawArgs = manifest.proxy_args ?? [];
|
|
@@ -20566,7 +20599,7 @@ function amendDeploymentManifestBudget(manifest, budget) {
|
|
|
20566
20599
|
return { ...manifest, proxy_args: newArgs, base_env: newEnv };
|
|
20567
20600
|
}
|
|
20568
20601
|
function findHeadroomDeployments(homeDir2, deps) {
|
|
20569
|
-
const deployDir =
|
|
20602
|
+
const deployDir = path47.join(homeDir2, ".headroom", "deploy");
|
|
20570
20603
|
let profiles;
|
|
20571
20604
|
try {
|
|
20572
20605
|
profiles = deps.readDir(deployDir);
|
|
@@ -20575,7 +20608,7 @@ function findHeadroomDeployments(homeDir2, deps) {
|
|
|
20575
20608
|
}
|
|
20576
20609
|
const results = [];
|
|
20577
20610
|
for (const profile of profiles) {
|
|
20578
|
-
const manifestPath =
|
|
20611
|
+
const manifestPath = path47.join(deployDir, profile, "manifest.json");
|
|
20579
20612
|
let raw;
|
|
20580
20613
|
try {
|
|
20581
20614
|
raw = deps.readJson(manifestPath);
|
|
@@ -20607,8 +20640,8 @@ async function applyBudgetToHeadroom(budget, deps) {
|
|
|
20607
20640
|
}
|
|
20608
20641
|
function writeManifestReal(manifestPath, manifest) {
|
|
20609
20642
|
const tmp = manifestPath + ".codeam.tmp";
|
|
20610
|
-
|
|
20611
|
-
|
|
20643
|
+
fs44.writeFileSync(tmp, JSON.stringify(manifest, null, 2) + "\n", { mode: 384 });
|
|
20644
|
+
fs44.renameSync(tmp, manifestPath);
|
|
20612
20645
|
}
|
|
20613
20646
|
function restartDeploymentReal(profile) {
|
|
20614
20647
|
try {
|
|
@@ -20638,11 +20671,11 @@ function spawnProxyReal2(_budget) {
|
|
|
20638
20671
|
});
|
|
20639
20672
|
}
|
|
20640
20673
|
function makeRealApplyBudgetDeps() {
|
|
20641
|
-
const homeDir2 =
|
|
20674
|
+
const homeDir2 = os39.homedir();
|
|
20642
20675
|
return {
|
|
20643
20676
|
findDeployments: () => findHeadroomDeployments(homeDir2, {
|
|
20644
|
-
readDir: (dir) =>
|
|
20645
|
-
readJson: (filePath) => JSON.parse(
|
|
20677
|
+
readDir: (dir) => fs44.readdirSync(dir),
|
|
20678
|
+
readJson: (filePath) => JSON.parse(fs44.readFileSync(filePath, "utf8"))
|
|
20646
20679
|
}),
|
|
20647
20680
|
writeManifest: writeManifestReal,
|
|
20648
20681
|
restartDeployment: restartDeploymentReal,
|
|
@@ -20652,16 +20685,16 @@ function makeRealApplyBudgetDeps() {
|
|
|
20652
20685
|
}
|
|
20653
20686
|
|
|
20654
20687
|
// src/services/preview/port-registry.ts
|
|
20655
|
-
var
|
|
20656
|
-
var
|
|
20657
|
-
var
|
|
20688
|
+
var fs45 = __toESM(require("fs"));
|
|
20689
|
+
var os40 = __toESM(require("os"));
|
|
20690
|
+
var path48 = __toESM(require("path"));
|
|
20658
20691
|
var import_child_process14 = require("child_process");
|
|
20659
20692
|
function registryPath() {
|
|
20660
|
-
return
|
|
20693
|
+
return path48.join(os40.homedir(), ".codeam", "preview-ports.json");
|
|
20661
20694
|
}
|
|
20662
20695
|
function readRegistry() {
|
|
20663
20696
|
try {
|
|
20664
|
-
const raw =
|
|
20697
|
+
const raw = fs45.readFileSync(registryPath(), "utf8");
|
|
20665
20698
|
const parsed = JSON.parse(raw);
|
|
20666
20699
|
if (parsed && typeof parsed === "object") return parsed;
|
|
20667
20700
|
} catch {
|
|
@@ -20671,10 +20704,10 @@ function readRegistry() {
|
|
|
20671
20704
|
function writeRegistry(reg) {
|
|
20672
20705
|
try {
|
|
20673
20706
|
const file = registryPath();
|
|
20674
|
-
|
|
20707
|
+
fs45.mkdirSync(path48.dirname(file), { recursive: true });
|
|
20675
20708
|
const tmp = `${file}.tmp`;
|
|
20676
|
-
|
|
20677
|
-
|
|
20709
|
+
fs45.writeFileSync(tmp, JSON.stringify(reg), "utf8");
|
|
20710
|
+
fs45.renameSync(tmp, file);
|
|
20678
20711
|
} catch (err) {
|
|
20679
20712
|
log.warn("preview", `port-registry write failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
20680
20713
|
}
|
|
@@ -21410,8 +21443,8 @@ function activePreviewSessionIds() {
|
|
|
21410
21443
|
|
|
21411
21444
|
// src/services/preview/start-orchestrator.ts
|
|
21412
21445
|
var import_child_process18 = require("child_process");
|
|
21413
|
-
var
|
|
21414
|
-
var
|
|
21446
|
+
var fs50 = __toESM(require("fs"));
|
|
21447
|
+
var path53 = __toESM(require("path"));
|
|
21415
21448
|
var import_which2 = __toESM(require("which"));
|
|
21416
21449
|
var INSTALL_TIMEOUT_MS = 5 * 6e4;
|
|
21417
21450
|
var SETUP_TIMEOUT_MS = 2 * 6e4;
|
|
@@ -21478,8 +21511,8 @@ function normalizeDetectionForSpawn(detection, cwd) {
|
|
|
21478
21511
|
if (args2.length === 0) return detection;
|
|
21479
21512
|
const binName = args2[0];
|
|
21480
21513
|
if (binName.startsWith("-")) return detection;
|
|
21481
|
-
const binPath =
|
|
21482
|
-
if (!
|
|
21514
|
+
const binPath = path53.join(cwd, "node_modules", ".bin", binName);
|
|
21515
|
+
if (!fs50.existsSync(binPath)) return detection;
|
|
21483
21516
|
return {
|
|
21484
21517
|
...detection,
|
|
21485
21518
|
command: binPath,
|
|
@@ -21843,9 +21876,9 @@ async function establishTunnel(ctx, dev) {
|
|
|
21843
21876
|
|
|
21844
21877
|
// src/beads/bd-adapter.ts
|
|
21845
21878
|
var import_child_process19 = require("child_process");
|
|
21846
|
-
var
|
|
21847
|
-
var
|
|
21848
|
-
var
|
|
21879
|
+
var fs51 = __toESM(require("fs"));
|
|
21880
|
+
var os42 = __toESM(require("os"));
|
|
21881
|
+
var path54 = __toESM(require("path"));
|
|
21849
21882
|
var BD_PACKAGE = "@beads/bd";
|
|
21850
21883
|
function resolveBundledBdBinary() {
|
|
21851
21884
|
return _resolveSeam.resolveBundled();
|
|
@@ -21857,11 +21890,11 @@ function _defaultResolveBundled() {
|
|
|
21857
21890
|
} catch {
|
|
21858
21891
|
return null;
|
|
21859
21892
|
}
|
|
21860
|
-
const binDir =
|
|
21893
|
+
const binDir = path54.join(path54.dirname(pkgJsonPath), "bin");
|
|
21861
21894
|
const binaryName = process.platform === "win32" ? "bd.exe" : "bd";
|
|
21862
|
-
const binaryPath =
|
|
21895
|
+
const binaryPath = path54.join(binDir, binaryName);
|
|
21863
21896
|
try {
|
|
21864
|
-
|
|
21897
|
+
fs51.accessSync(binaryPath, fs51.constants.F_OK);
|
|
21865
21898
|
return binaryPath;
|
|
21866
21899
|
} catch {
|
|
21867
21900
|
return null;
|
|
@@ -21871,13 +21904,13 @@ function resolveBdOnPath() {
|
|
|
21871
21904
|
return _resolveSeam.resolveOnPath();
|
|
21872
21905
|
}
|
|
21873
21906
|
function _defaultResolveOnPath() {
|
|
21874
|
-
const dirs = (process.env.PATH ?? "").split(
|
|
21907
|
+
const dirs = (process.env.PATH ?? "").split(path54.delimiter).filter(Boolean);
|
|
21875
21908
|
const candidates = process.platform === "win32" ? ["bd.exe", "bd.cmd", "bd"] : ["bd"];
|
|
21876
21909
|
for (const dir of dirs) {
|
|
21877
21910
|
for (const candidate of candidates) {
|
|
21878
|
-
const full =
|
|
21911
|
+
const full = path54.join(dir, candidate);
|
|
21879
21912
|
try {
|
|
21880
|
-
|
|
21913
|
+
fs51.accessSync(full, fs51.constants.F_OK);
|
|
21881
21914
|
return full;
|
|
21882
21915
|
} catch {
|
|
21883
21916
|
}
|
|
@@ -21962,7 +21995,7 @@ var BdAdapter = class {
|
|
|
21962
21995
|
const env = { ...process.env };
|
|
21963
21996
|
if (!env.HOME) {
|
|
21964
21997
|
try {
|
|
21965
|
-
const home =
|
|
21998
|
+
const home = os42.homedir();
|
|
21966
21999
|
if (home) env.HOME = home;
|
|
21967
22000
|
} catch {
|
|
21968
22001
|
}
|
|
@@ -22054,9 +22087,9 @@ function coerceIssue(row, projectKey) {
|
|
|
22054
22087
|
|
|
22055
22088
|
// src/beads/provisioner.ts
|
|
22056
22089
|
var import_child_process23 = require("child_process");
|
|
22057
|
-
var
|
|
22058
|
-
var
|
|
22059
|
-
var
|
|
22090
|
+
var fs54 = __toESM(require("fs"));
|
|
22091
|
+
var os44 = __toESM(require("os"));
|
|
22092
|
+
var path57 = __toESM(require("path"));
|
|
22060
22093
|
|
|
22061
22094
|
// src/beads/install-bd.ts
|
|
22062
22095
|
var import_child_process20 = require("child_process");
|
|
@@ -22121,9 +22154,9 @@ async function installBd(platform3 = process.platform) {
|
|
|
22121
22154
|
|
|
22122
22155
|
// src/beads/install-dolt.ts
|
|
22123
22156
|
var import_child_process21 = require("child_process");
|
|
22124
|
-
var
|
|
22125
|
-
var
|
|
22126
|
-
var
|
|
22157
|
+
var fs52 = __toESM(require("fs"));
|
|
22158
|
+
var os43 = __toESM(require("os"));
|
|
22159
|
+
var path55 = __toESM(require("path"));
|
|
22127
22160
|
var DOLT_INSTALL_SH_URL = "https://github.com/dolthub/dolt/releases/latest/download/install.sh";
|
|
22128
22161
|
var DOLT_MSI_URL = "https://github.com/dolthub/dolt/releases/latest/download/dolt-windows-amd64.msi";
|
|
22129
22162
|
function resolveDoltInstallStrategy(platform3) {
|
|
@@ -22163,11 +22196,11 @@ function resolveDoltInstallStrategy(platform3) {
|
|
|
22163
22196
|
}
|
|
22164
22197
|
var DOLT_RELEASE_BASE = "https://github.com/dolthub/dolt/releases/latest/download";
|
|
22165
22198
|
function doltPlatformTuple(platform3, arch2) {
|
|
22166
|
-
const
|
|
22199
|
+
const os59 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
|
|
22167
22200
|
const a = arch2 === "x64" ? "amd64" : arch2 === "arm64" ? "arm64" : null;
|
|
22168
22201
|
if (!a) return null;
|
|
22169
|
-
if (
|
|
22170
|
-
return `${
|
|
22202
|
+
if (os59 === "windows" && a !== "amd64") return null;
|
|
22203
|
+
return `${os59}-${a}`;
|
|
22171
22204
|
}
|
|
22172
22205
|
function resolveDoltTarballStrategy(targetDir, platform3, arch2) {
|
|
22173
22206
|
const tuple = doltPlatformTuple(platform3, arch2);
|
|
@@ -22212,14 +22245,14 @@ async function installDoltToDir(targetDir, platform3 = process.platform, arch2 =
|
|
|
22212
22245
|
return result;
|
|
22213
22246
|
}
|
|
22214
22247
|
var _doltPathSeam = {
|
|
22215
|
-
homedir: () =>
|
|
22248
|
+
homedir: () => os43.homedir(),
|
|
22216
22249
|
getPath: () => process.env.PATH ?? "",
|
|
22217
22250
|
setPath: (p2) => {
|
|
22218
22251
|
process.env.PATH = p2;
|
|
22219
22252
|
},
|
|
22220
22253
|
exists: (p2) => {
|
|
22221
22254
|
try {
|
|
22222
|
-
|
|
22255
|
+
fs52.accessSync(p2, fs52.constants.F_OK);
|
|
22223
22256
|
return true;
|
|
22224
22257
|
} catch {
|
|
22225
22258
|
return false;
|
|
@@ -22230,7 +22263,7 @@ function doltBinaryNames(platform3) {
|
|
|
22230
22263
|
return platform3 === "win32" ? ["dolt.exe", "dolt.cmd", "dolt"] : ["dolt"];
|
|
22231
22264
|
}
|
|
22232
22265
|
function knownDoltDirs(platform3) {
|
|
22233
|
-
const P3 = platform3 === "win32" ?
|
|
22266
|
+
const P3 = platform3 === "win32" ? path55.win32 : path55.posix;
|
|
22234
22267
|
const home = _doltPathSeam.homedir();
|
|
22235
22268
|
if (platform3 === "win32") {
|
|
22236
22269
|
return [
|
|
@@ -22246,7 +22279,7 @@ function knownDoltDirs(platform3) {
|
|
|
22246
22279
|
].filter(Boolean);
|
|
22247
22280
|
}
|
|
22248
22281
|
function ensureDoltResolvable(platform3 = process.platform) {
|
|
22249
|
-
const P3 = platform3 === "win32" ?
|
|
22282
|
+
const P3 = platform3 === "win32" ? path55.win32 : path55.posix;
|
|
22250
22283
|
const delim = platform3 === "win32" ? ";" : ":";
|
|
22251
22284
|
const names = doltBinaryNames(platform3);
|
|
22252
22285
|
const pathDirs = _doltPathSeam.getPath().split(delim).filter(Boolean);
|
|
@@ -22382,8 +22415,8 @@ async function ensureSharedServer(adapter, options = {}) {
|
|
|
22382
22415
|
// src/beads/project-key.ts
|
|
22383
22416
|
var import_child_process22 = require("child_process");
|
|
22384
22417
|
var crypto2 = __toESM(require("crypto"));
|
|
22385
|
-
var
|
|
22386
|
-
var
|
|
22418
|
+
var fs53 = __toESM(require("fs"));
|
|
22419
|
+
var path56 = __toESM(require("path"));
|
|
22387
22420
|
function normalizeOrigin(raw) {
|
|
22388
22421
|
const trimmed = raw.trim();
|
|
22389
22422
|
if (!trimmed) return null;
|
|
@@ -22409,17 +22442,17 @@ function normalizeOrigin(raw) {
|
|
|
22409
22442
|
return `${host2}/${pathPart}`;
|
|
22410
22443
|
}
|
|
22411
22444
|
function findRepoRoot(cwd) {
|
|
22412
|
-
let dir =
|
|
22445
|
+
let dir = path56.resolve(cwd);
|
|
22413
22446
|
const seen = /* @__PURE__ */ new Set();
|
|
22414
22447
|
for (let i = 0; i < 256; i++) {
|
|
22415
22448
|
if (seen.has(dir)) return null;
|
|
22416
22449
|
seen.add(dir);
|
|
22417
22450
|
try {
|
|
22418
|
-
const stat3 =
|
|
22451
|
+
const stat3 = fs53.statSync(path56.join(dir, ".git"), { throwIfNoEntry: false });
|
|
22419
22452
|
if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
|
|
22420
22453
|
} catch {
|
|
22421
22454
|
}
|
|
22422
|
-
const parent =
|
|
22455
|
+
const parent = path56.dirname(dir);
|
|
22423
22456
|
if (parent === dir) return null;
|
|
22424
22457
|
dir = parent;
|
|
22425
22458
|
}
|
|
@@ -22430,7 +22463,7 @@ var _execSeam2 = {
|
|
|
22430
22463
|
const out2 = (0, import_child_process22.execFileSync)(file, args2, opts);
|
|
22431
22464
|
return typeof out2 === "string" ? out2 : out2.toString("utf8");
|
|
22432
22465
|
},
|
|
22433
|
-
realpath: (p2) =>
|
|
22466
|
+
realpath: (p2) => fs53.realpathSync(p2)
|
|
22434
22467
|
};
|
|
22435
22468
|
function readOrigin(cwd) {
|
|
22436
22469
|
try {
|
|
@@ -22459,7 +22492,7 @@ function deriveProjectIdentity(cwd = process.cwd()) {
|
|
|
22459
22492
|
} catch {
|
|
22460
22493
|
}
|
|
22461
22494
|
const hash = crypto2.createHash("sha256").update(real).digest("hex");
|
|
22462
|
-
return { projectKey: `path:${hash}`, projectLabel:
|
|
22495
|
+
return { projectKey: `path:${hash}`, projectLabel: path56.basename(real) || "project" };
|
|
22463
22496
|
}
|
|
22464
22497
|
|
|
22465
22498
|
// src/beads/project-prefix.ts
|
|
@@ -22506,17 +22539,17 @@ var _provisionSeam = {
|
|
|
22506
22539
|
};
|
|
22507
22540
|
var _linkSeam = {
|
|
22508
22541
|
platform: () => process.platform,
|
|
22509
|
-
homedir: () =>
|
|
22542
|
+
homedir: () => os44.homedir(),
|
|
22510
22543
|
isWritableDir: (dir) => {
|
|
22511
22544
|
try {
|
|
22512
|
-
|
|
22545
|
+
fs54.accessSync(dir, fs54.constants.W_OK);
|
|
22513
22546
|
return true;
|
|
22514
22547
|
} catch {
|
|
22515
22548
|
return false;
|
|
22516
22549
|
}
|
|
22517
22550
|
},
|
|
22518
22551
|
ensureDir: (dir) => {
|
|
22519
|
-
|
|
22552
|
+
fs54.mkdirSync(dir, { recursive: true });
|
|
22520
22553
|
},
|
|
22521
22554
|
/**
|
|
22522
22555
|
* A directory to symlink `bd` into so the AGENT's shell + Claude Code's
|
|
@@ -22537,9 +22570,9 @@ var _linkSeam = {
|
|
|
22537
22570
|
* which `linkBdOntoPath` creates if missing.
|
|
22538
22571
|
*/
|
|
22539
22572
|
cliBinDir: () => {
|
|
22540
|
-
const pathDirs = (process.env.PATH ?? "").split(
|
|
22573
|
+
const pathDirs = (process.env.PATH ?? "").split(path57.delimiter).filter(Boolean);
|
|
22541
22574
|
const home = _linkSeam.homedir();
|
|
22542
|
-
const localBin = home ?
|
|
22575
|
+
const localBin = home ? path57.join(home, ".local", "bin") : null;
|
|
22543
22576
|
if (localBin) {
|
|
22544
22577
|
try {
|
|
22545
22578
|
_linkSeam.ensureDir(localBin);
|
|
@@ -22549,16 +22582,16 @@ var _linkSeam = {
|
|
|
22549
22582
|
const candidates = [];
|
|
22550
22583
|
if (localBin) candidates.push(localBin);
|
|
22551
22584
|
try {
|
|
22552
|
-
candidates.push(
|
|
22585
|
+
candidates.push(path57.dirname(process.execPath));
|
|
22553
22586
|
} catch {
|
|
22554
22587
|
}
|
|
22555
22588
|
candidates.push("/usr/local/bin");
|
|
22556
22589
|
const entry = process.argv[1];
|
|
22557
22590
|
if (entry) {
|
|
22558
22591
|
try {
|
|
22559
|
-
candidates.push(
|
|
22592
|
+
candidates.push(path57.dirname(fs54.realpathSync(entry)));
|
|
22560
22593
|
} catch {
|
|
22561
|
-
candidates.push(
|
|
22594
|
+
candidates.push(path57.dirname(entry));
|
|
22562
22595
|
}
|
|
22563
22596
|
}
|
|
22564
22597
|
const onPathWritable = candidates.find(
|
|
@@ -22570,20 +22603,20 @@ var _linkSeam = {
|
|
|
22570
22603
|
/** Current symlink target at `linkPath`, or null when absent / not a link. */
|
|
22571
22604
|
readlink: (linkPath) => {
|
|
22572
22605
|
try {
|
|
22573
|
-
return
|
|
22606
|
+
return fs54.readlinkSync(linkPath);
|
|
22574
22607
|
} catch {
|
|
22575
22608
|
return null;
|
|
22576
22609
|
}
|
|
22577
22610
|
},
|
|
22578
|
-
unlink: (linkPath) =>
|
|
22579
|
-
symlink: (target, linkPath) =>
|
|
22611
|
+
unlink: (linkPath) => fs54.unlinkSync(linkPath),
|
|
22612
|
+
symlink: (target, linkPath) => fs54.symlinkSync(target, linkPath)
|
|
22580
22613
|
};
|
|
22581
22614
|
function linkBdOntoPath(binaryPath) {
|
|
22582
22615
|
if (_linkSeam.platform() === "win32") return;
|
|
22583
22616
|
const binDir = _linkSeam.cliBinDir();
|
|
22584
22617
|
if (!binDir) return;
|
|
22585
22618
|
_linkSeam.ensureDir(binDir);
|
|
22586
|
-
const linkPath =
|
|
22619
|
+
const linkPath = path57.join(binDir, "bd");
|
|
22587
22620
|
if (linkPath === binaryPath) return;
|
|
22588
22621
|
const current = _linkSeam.readlink(linkPath);
|
|
22589
22622
|
if (current === binaryPath) return;
|
|
@@ -22778,7 +22811,7 @@ function dedupeRecipes(agents) {
|
|
|
22778
22811
|
|
|
22779
22812
|
// src/beads/watcher.ts
|
|
22780
22813
|
var crypto4 = __toESM(require("crypto"));
|
|
22781
|
-
var
|
|
22814
|
+
var path58 = __toESM(require("path"));
|
|
22782
22815
|
var API_BASE6 = resolveApiBaseUrl();
|
|
22783
22816
|
var DEBOUNCE_MS2 = 400;
|
|
22784
22817
|
var ZERO_SUMMARY = {
|
|
@@ -22802,7 +22835,7 @@ var BeadsWatcher = class {
|
|
|
22802
22835
|
constructor(opts) {
|
|
22803
22836
|
this.opts = opts;
|
|
22804
22837
|
this.bd = opts.adapter ?? new BdAdapter({ cwd: opts.cwd, beadsDir: opts.beadsDir });
|
|
22805
|
-
this.feedPath = opts.feedPath ??
|
|
22838
|
+
this.feedPath = opts.feedPath ?? path58.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
|
|
22806
22839
|
this.apiBase = opts.apiBaseUrl ?? API_BASE6;
|
|
22807
22840
|
}
|
|
22808
22841
|
opts;
|
|
@@ -23301,8 +23334,8 @@ function cleanupAttachmentTempFiles() {
|
|
|
23301
23334
|
function saveFilesTemp(files) {
|
|
23302
23335
|
return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
|
|
23303
23336
|
const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
|
|
23304
|
-
const tmpPath =
|
|
23305
|
-
|
|
23337
|
+
const tmpPath = path61.join(os48.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
|
|
23338
|
+
fs57.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
|
|
23306
23339
|
pendingAttachmentFiles.add(tmpPath);
|
|
23307
23340
|
return tmpPath;
|
|
23308
23341
|
});
|
|
@@ -23514,9 +23547,9 @@ var listFiles = async (ctx, cmd, parsed) => {
|
|
|
23514
23547
|
await ctx.relay.sendResult(cmd.id, "completed", result);
|
|
23515
23548
|
};
|
|
23516
23549
|
var envReadH = async (ctx, cmd) => {
|
|
23517
|
-
const envPath =
|
|
23550
|
+
const envPath = path61.join(process.cwd(), ".env");
|
|
23518
23551
|
try {
|
|
23519
|
-
const raw = await
|
|
23552
|
+
const raw = await fs57.promises.readFile(envPath, "utf8");
|
|
23520
23553
|
await ctx.relay.sendResult(cmd.id, "completed", {
|
|
23521
23554
|
exists: true,
|
|
23522
23555
|
vars: parseDotenv(raw)
|
|
@@ -23547,14 +23580,14 @@ var envWriteH = async (ctx, cmd, parsed) => {
|
|
|
23547
23580
|
}
|
|
23548
23581
|
seen.add(v.key);
|
|
23549
23582
|
}
|
|
23550
|
-
const envPath =
|
|
23551
|
-
const tmpPath =
|
|
23583
|
+
const envPath = path61.join(process.cwd(), ".env");
|
|
23584
|
+
const tmpPath = path61.join(process.cwd(), ".env.codeam.tmp");
|
|
23552
23585
|
try {
|
|
23553
|
-
await
|
|
23554
|
-
await
|
|
23586
|
+
await fs57.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
|
|
23587
|
+
await fs57.promises.rename(tmpPath, envPath);
|
|
23555
23588
|
await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
|
|
23556
23589
|
} catch (err) {
|
|
23557
|
-
await
|
|
23590
|
+
await fs57.promises.rm(tmpPath, { force: true }).catch(() => void 0);
|
|
23558
23591
|
await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
|
|
23559
23592
|
}
|
|
23560
23593
|
};
|
|
@@ -23603,7 +23636,7 @@ var headroomConfigureH = async (ctx, cmd, parsed) => {
|
|
|
23603
23636
|
let configuredAgent = rawAgentId;
|
|
23604
23637
|
if (!configuredAgent) {
|
|
23605
23638
|
try {
|
|
23606
|
-
const raw = JSON.parse(
|
|
23639
|
+
const raw = JSON.parse(fs57.readFileSync(headroomConfigPath(), "utf8"));
|
|
23607
23640
|
configuredAgent = raw.agent ?? "";
|
|
23608
23641
|
} catch {
|
|
23609
23642
|
}
|
|
@@ -23637,7 +23670,7 @@ var headroomConfigureH = async (ctx, cmd, parsed) => {
|
|
|
23637
23670
|
persist: persistHeadroomConfig,
|
|
23638
23671
|
readEnabled: () => {
|
|
23639
23672
|
try {
|
|
23640
|
-
const raw = JSON.parse(
|
|
23673
|
+
const raw = JSON.parse(fs57.readFileSync(headroomConfigPath(), "utf8"));
|
|
23641
23674
|
return raw.enabled === true;
|
|
23642
23675
|
} catch {
|
|
23643
23676
|
return false;
|
|
@@ -23894,7 +23927,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
23894
23927
|
});
|
|
23895
23928
|
const token = ctx.pluginAuthToken;
|
|
23896
23929
|
void (async () => {
|
|
23897
|
-
const
|
|
23930
|
+
const os59 = createOsStrategy();
|
|
23898
23931
|
try {
|
|
23899
23932
|
const report = await reviewPullRequest(
|
|
23900
23933
|
{
|
|
@@ -23903,7 +23936,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
23903
23936
|
baseBranch: parsed.baseBranch
|
|
23904
23937
|
},
|
|
23905
23938
|
{
|
|
23906
|
-
runReview: (input) => new CoderabbitRuntimeStrategy(
|
|
23939
|
+
runReview: (input) => new CoderabbitRuntimeStrategy(os59).runOneShot(input),
|
|
23907
23940
|
runGh: (args2) => defaultRunGh(args2),
|
|
23908
23941
|
postReport: async (r) => {
|
|
23909
23942
|
if (!token) return;
|
|
@@ -23941,7 +23974,7 @@ var headroomBudgetH = async (ctx, cmd) => {
|
|
|
23941
23974
|
}
|
|
23942
23975
|
let headroomActive = false;
|
|
23943
23976
|
try {
|
|
23944
|
-
const raw = JSON.parse(
|
|
23977
|
+
const raw = JSON.parse(fs57.readFileSync(headroomConfigPath(), "utf8"));
|
|
23945
23978
|
headroomActive = raw.enabled === true;
|
|
23946
23979
|
} catch {
|
|
23947
23980
|
}
|
|
@@ -23951,7 +23984,7 @@ var headroomBudgetH = async (ctx, cmd) => {
|
|
|
23951
23984
|
}
|
|
23952
23985
|
let existingConfig = { enabled: true };
|
|
23953
23986
|
try {
|
|
23954
|
-
existingConfig = JSON.parse(
|
|
23987
|
+
existingConfig = JSON.parse(fs57.readFileSync(headroomConfigPath(), "utf8"));
|
|
23955
23988
|
} catch {
|
|
23956
23989
|
}
|
|
23957
23990
|
if (payload.budgetEnabled && payload.budgetUsd != null) {
|
|
@@ -24064,9 +24097,9 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
|
|
|
24064
24097
|
function buildNpmInstallInvocation(opts) {
|
|
24065
24098
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
24066
24099
|
const execPath = opts?.execPath ?? process.execPath;
|
|
24067
|
-
const exists2 = opts?.existsSync ??
|
|
24100
|
+
const exists2 = opts?.existsSync ?? fs57.existsSync;
|
|
24068
24101
|
const platform3 = opts?.platform ?? process.platform;
|
|
24069
|
-
const p2 = platform3 === "win32" ?
|
|
24102
|
+
const p2 = platform3 === "win32" ? path61.win32 : path61.posix;
|
|
24070
24103
|
const normalized = entryScript.split(/[\\/]/).join("/");
|
|
24071
24104
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
24072
24105
|
const markerIdx = normalized.indexOf(marker);
|
|
@@ -24929,11 +24962,11 @@ function resolveTokenValue(args2) {
|
|
|
24929
24962
|
}
|
|
24930
24963
|
const fileFlag = args2.find((a) => a.startsWith("--token-file="));
|
|
24931
24964
|
if (fileFlag) {
|
|
24932
|
-
const
|
|
24965
|
+
const path79 = fileFlag.slice("--token-file=".length);
|
|
24933
24966
|
try {
|
|
24934
|
-
const content =
|
|
24935
|
-
if (content.length === 0) fail(`--token-file ${
|
|
24936
|
-
rmIfExistsQuiet(
|
|
24967
|
+
const content = fs58.readFileSync(path79, "utf8").trim();
|
|
24968
|
+
if (content.length === 0) fail(`--token-file ${path79} is empty`);
|
|
24969
|
+
rmIfExistsQuiet(path79);
|
|
24937
24970
|
return content;
|
|
24938
24971
|
} catch (err) {
|
|
24939
24972
|
fail(`Could not read --token-file: ${err.message}`);
|
|
@@ -24962,7 +24995,7 @@ async function claimOnce(token, pluginId, pluginSecretHash) {
|
|
|
24962
24995
|
pluginId,
|
|
24963
24996
|
ideName: "codeam-cli (codespace)",
|
|
24964
24997
|
ideVersion: process.env.npm_package_version ?? "unknown",
|
|
24965
|
-
hostname:
|
|
24998
|
+
hostname: os49.hostname(),
|
|
24966
24999
|
codespaceName: process.env.CODESPACE_NAME ?? "",
|
|
24967
25000
|
// Current git branch of the codespace's working directory, so the
|
|
24968
25001
|
// backend can populate `PairedSession.branch` for the codespace pair.
|
|
@@ -25023,7 +25056,7 @@ async function claim(token, pluginId, pluginSecretHash) {
|
|
|
25023
25056
|
}
|
|
25024
25057
|
}
|
|
25025
25058
|
function pairAutoLockPath() {
|
|
25026
|
-
return
|
|
25059
|
+
return path62.join(os49.homedir(), ".codeam", "pair-auto.lock");
|
|
25027
25060
|
}
|
|
25028
25061
|
function isLivePairAuto(pid) {
|
|
25029
25062
|
if (!Number.isInteger(pid) || pid <= 0 || pid === process.pid) return false;
|
|
@@ -25033,7 +25066,7 @@ function isLivePairAuto(pid) {
|
|
|
25033
25066
|
if (e.code !== "EPERM") return false;
|
|
25034
25067
|
}
|
|
25035
25068
|
try {
|
|
25036
|
-
return
|
|
25069
|
+
return fs58.readFileSync(`/proc/${pid}/cmdline`, "utf8").includes("codeam");
|
|
25037
25070
|
} catch {
|
|
25038
25071
|
return true;
|
|
25039
25072
|
}
|
|
@@ -25043,24 +25076,24 @@ function isLiveCodeam(pid) {
|
|
|
25043
25076
|
}
|
|
25044
25077
|
function daemonLockPath(sessionId) {
|
|
25045
25078
|
const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
25046
|
-
return
|
|
25079
|
+
return path62.join(os49.homedir(), ".codeam", `daemon-${safe}.lock`);
|
|
25047
25080
|
}
|
|
25048
25081
|
function acquireDaemonLock(sessionId) {
|
|
25049
25082
|
const lockPath = daemonLockPath(sessionId);
|
|
25050
25083
|
try {
|
|
25051
|
-
|
|
25084
|
+
fs58.mkdirSync(path62.dirname(lockPath), { recursive: true });
|
|
25052
25085
|
try {
|
|
25053
|
-
|
|
25086
|
+
fs58.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
|
|
25054
25087
|
} catch (e) {
|
|
25055
25088
|
if (e.code !== "EEXIST") throw e;
|
|
25056
|
-
const holder = Number(
|
|
25089
|
+
const holder = Number(fs58.readFileSync(lockPath, "utf8").trim());
|
|
25057
25090
|
if (holder && holder !== process.pid && isLiveCodeam(holder)) return false;
|
|
25058
|
-
|
|
25091
|
+
fs58.writeFileSync(lockPath, String(process.pid));
|
|
25059
25092
|
}
|
|
25060
25093
|
const release3 = () => {
|
|
25061
25094
|
try {
|
|
25062
|
-
if (
|
|
25063
|
-
|
|
25095
|
+
if (fs58.existsSync(lockPath) && Number(fs58.readFileSync(lockPath, "utf8").trim()) === process.pid) {
|
|
25096
|
+
fs58.unlinkSync(lockPath);
|
|
25064
25097
|
}
|
|
25065
25098
|
} catch {
|
|
25066
25099
|
}
|
|
@@ -25082,19 +25115,19 @@ function acquireDaemonLock(sessionId) {
|
|
|
25082
25115
|
function acquireSingletonLock() {
|
|
25083
25116
|
const lockPath = pairAutoLockPath();
|
|
25084
25117
|
try {
|
|
25085
|
-
|
|
25118
|
+
fs58.mkdirSync(path62.dirname(lockPath), { recursive: true });
|
|
25086
25119
|
try {
|
|
25087
|
-
|
|
25120
|
+
fs58.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
|
|
25088
25121
|
} catch (e) {
|
|
25089
25122
|
if (e.code !== "EEXIST") throw e;
|
|
25090
|
-
const holder = Number(
|
|
25123
|
+
const holder = Number(fs58.readFileSync(lockPath, "utf8").trim());
|
|
25091
25124
|
if (isLivePairAuto(holder)) return false;
|
|
25092
|
-
|
|
25125
|
+
fs58.writeFileSync(lockPath, String(process.pid));
|
|
25093
25126
|
}
|
|
25094
25127
|
process.once("exit", () => {
|
|
25095
25128
|
try {
|
|
25096
|
-
if (
|
|
25097
|
-
|
|
25129
|
+
if (fs58.existsSync(lockPath) && Number(fs58.readFileSync(lockPath, "utf8").trim()) === process.pid) {
|
|
25130
|
+
fs58.unlinkSync(lockPath);
|
|
25098
25131
|
}
|
|
25099
25132
|
} catch {
|
|
25100
25133
|
}
|
|
@@ -25541,7 +25574,7 @@ var AgentService = class _AgentService {
|
|
|
25541
25574
|
};
|
|
25542
25575
|
|
|
25543
25576
|
// src/agents/acp/adapters.ts
|
|
25544
|
-
var
|
|
25577
|
+
var path64 = __toESM(require("path"));
|
|
25545
25578
|
|
|
25546
25579
|
// src/agents/acp/agent-binary.ts
|
|
25547
25580
|
var import_fs4 = __toESM(require("fs"));
|
|
@@ -25574,14 +25607,14 @@ function defaultSdkDir() {
|
|
|
25574
25607
|
return resolveSdkDirViaRequire();
|
|
25575
25608
|
}
|
|
25576
25609
|
function resolveClaudeNativeBinary(deps = {}) {
|
|
25577
|
-
const
|
|
25610
|
+
const existsSync27 = deps.existsSync ?? import_fs4.default.existsSync;
|
|
25578
25611
|
const platformKey = deps.platformKey ?? currentPlatformKey();
|
|
25579
25612
|
const sdkDir = deps.sdkDir !== void 0 ? deps.sdkDir : defaultSdkDir();
|
|
25580
25613
|
if (!sdkDir) return null;
|
|
25581
25614
|
const scopeDir = import_path8.default.dirname(sdkDir);
|
|
25582
25615
|
const binName = platformKey.startsWith("win32-") ? "claude.exe" : "claude";
|
|
25583
25616
|
const candidate = import_path8.default.join(scopeDir, `claude-agent-sdk-${platformKey}`, binName);
|
|
25584
|
-
return
|
|
25617
|
+
return existsSync27(candidate) ? candidate : null;
|
|
25585
25618
|
}
|
|
25586
25619
|
var realSleep = (ms) => new Promise((resolve8) => setTimeout(resolve8, ms));
|
|
25587
25620
|
async function waitForClaudeNativeBinary(opts = {}) {
|
|
@@ -25632,18 +25665,18 @@ async function waitForCommandOnPath(cmd, opts = {}) {
|
|
|
25632
25665
|
return check();
|
|
25633
25666
|
}
|
|
25634
25667
|
function resolveCursorAgentBinary(deps = {}) {
|
|
25635
|
-
const
|
|
25668
|
+
const existsSync27 = deps.existsSync ?? import_fs4.default.existsSync;
|
|
25636
25669
|
const platform3 = deps.platform ?? process.platform;
|
|
25637
25670
|
const env = deps.env ?? process.env;
|
|
25638
25671
|
if (platform3 === "win32") {
|
|
25639
25672
|
const localAppData = env.LOCALAPPDATA;
|
|
25640
25673
|
if (!localAppData) return null;
|
|
25641
25674
|
const exe = import_path8.default.win32.join(localAppData, "cursor-agent", "cursor-agent.exe");
|
|
25642
|
-
return
|
|
25675
|
+
return existsSync27(exe) ? exe : null;
|
|
25643
25676
|
}
|
|
25644
25677
|
const home = deps.homedir ?? import_os11.default.homedir();
|
|
25645
25678
|
const unix = import_path8.default.posix.join(home, ".local", "bin", "cursor-agent");
|
|
25646
|
-
return
|
|
25679
|
+
return existsSync27(unix) ? unix : null;
|
|
25647
25680
|
}
|
|
25648
25681
|
async function waitForCursorAgent(opts = {}) {
|
|
25649
25682
|
const timeoutMs = opts.timeoutMs ?? 18e4;
|
|
@@ -25831,13 +25864,13 @@ function resolveBin(pkgName, binName) {
|
|
|
25831
25864
|
try {
|
|
25832
25865
|
const manifestPath = require_.resolve(`${pkgName}/package.json`);
|
|
25833
25866
|
const manifest = require_(`${pkgName}/package.json`);
|
|
25834
|
-
const pkgDir =
|
|
25867
|
+
const pkgDir = path64.dirname(manifestPath);
|
|
25835
25868
|
const bin = manifest.bin;
|
|
25836
25869
|
if (!bin) return null;
|
|
25837
|
-
if (typeof bin === "string") return
|
|
25870
|
+
if (typeof bin === "string") return path64.resolve(pkgDir, bin);
|
|
25838
25871
|
const target = binName ?? Object.keys(bin)[0];
|
|
25839
25872
|
if (!target || !bin[target]) return null;
|
|
25840
|
-
return
|
|
25873
|
+
return path64.resolve(pkgDir, bin[target]);
|
|
25841
25874
|
} catch {
|
|
25842
25875
|
return null;
|
|
25843
25876
|
}
|
|
@@ -25987,9 +26020,9 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
|
|
|
25987
26020
|
var import_node_crypto11 = require("crypto");
|
|
25988
26021
|
|
|
25989
26022
|
// src/services/history.service.ts
|
|
25990
|
-
var
|
|
25991
|
-
var
|
|
25992
|
-
var
|
|
26023
|
+
var fs60 = __toESM(require("fs"));
|
|
26024
|
+
var path65 = __toESM(require("path"));
|
|
26025
|
+
var os51 = __toESM(require("os"));
|
|
25993
26026
|
var https7 = __toESM(require("https"));
|
|
25994
26027
|
var http6 = __toESM(require("http"));
|
|
25995
26028
|
var import_zod2 = require("zod");
|
|
@@ -26016,7 +26049,7 @@ function parseJsonl(filePath) {
|
|
|
26016
26049
|
const messages = [];
|
|
26017
26050
|
let raw;
|
|
26018
26051
|
try {
|
|
26019
|
-
raw =
|
|
26052
|
+
raw = fs60.readFileSync(filePath, "utf8");
|
|
26020
26053
|
} catch (err) {
|
|
26021
26054
|
if (err.code !== "ENOENT") {
|
|
26022
26055
|
log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
|
|
@@ -26157,7 +26190,7 @@ var HistoryService = class _HistoryService {
|
|
|
26157
26190
|
return this._quotaPercent === null || Date.now() - this._quotaFetchedAt > ttlMs;
|
|
26158
26191
|
}
|
|
26159
26192
|
get projectDir() {
|
|
26160
|
-
return this.runtime.resolveHistoryDir(this.cwd) ??
|
|
26193
|
+
return this.runtime.resolveHistoryDir(this.cwd) ?? path65.join(os51.homedir(), ".claude", "projects", encodeCwd(this.cwd));
|
|
26161
26194
|
}
|
|
26162
26195
|
/** Set the current Claude conversation ID (extracted from /cost command or session start) */
|
|
26163
26196
|
setCurrentConversationId(id) {
|
|
@@ -26169,7 +26202,7 @@ var HistoryService = class _HistoryService {
|
|
|
26169
26202
|
/** Return the current message count in the active conversation. */
|
|
26170
26203
|
getCurrentMessageCount() {
|
|
26171
26204
|
if (!this.currentConversationId) return 0;
|
|
26172
|
-
const filePath =
|
|
26205
|
+
const filePath = path65.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
26173
26206
|
return parseJsonl(filePath).length;
|
|
26174
26207
|
}
|
|
26175
26208
|
/**
|
|
@@ -26180,7 +26213,7 @@ var HistoryService = class _HistoryService {
|
|
|
26180
26213
|
const deadline = Date.now() + timeoutMs;
|
|
26181
26214
|
while (Date.now() < deadline) {
|
|
26182
26215
|
if (!this.currentConversationId) return null;
|
|
26183
|
-
const filePath =
|
|
26216
|
+
const filePath = path65.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
26184
26217
|
const messages = parseJsonl(filePath);
|
|
26185
26218
|
if (messages.length > previousCount) {
|
|
26186
26219
|
for (let i = messages.length - 1; i >= previousCount; i--) {
|
|
@@ -26206,16 +26239,16 @@ var HistoryService = class _HistoryService {
|
|
|
26206
26239
|
const dir = this.projectDir;
|
|
26207
26240
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
26208
26241
|
try {
|
|
26209
|
-
const files =
|
|
26242
|
+
const files = fs60.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
26210
26243
|
try {
|
|
26211
|
-
const stat3 =
|
|
26244
|
+
const stat3 = fs60.statSync(path65.join(dir, e.name));
|
|
26212
26245
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
26213
26246
|
} catch {
|
|
26214
26247
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
26215
26248
|
}
|
|
26216
26249
|
}).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
26217
26250
|
if (files.length > 0) {
|
|
26218
|
-
this.currentConversationId =
|
|
26251
|
+
this.currentConversationId = path65.basename(files[0].name, ".jsonl");
|
|
26219
26252
|
}
|
|
26220
26253
|
} catch {
|
|
26221
26254
|
}
|
|
@@ -26249,13 +26282,13 @@ var HistoryService = class _HistoryService {
|
|
|
26249
26282
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
26250
26283
|
let entries;
|
|
26251
26284
|
try {
|
|
26252
|
-
entries =
|
|
26285
|
+
entries = fs60.readdirSync(dir, { withFileTypes: true });
|
|
26253
26286
|
} catch {
|
|
26254
26287
|
return null;
|
|
26255
26288
|
}
|
|
26256
26289
|
const files = entries.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
26257
26290
|
try {
|
|
26258
|
-
const stat3 =
|
|
26291
|
+
const stat3 = fs60.statSync(path65.join(dir, e.name));
|
|
26259
26292
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
26260
26293
|
} catch {
|
|
26261
26294
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
@@ -26264,12 +26297,12 @@ var HistoryService = class _HistoryService {
|
|
|
26264
26297
|
if (files.length === 0) return null;
|
|
26265
26298
|
const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
|
|
26266
26299
|
if (!files.some((f) => f.name === targetFile)) return null;
|
|
26267
|
-
return this.extractUsageFromFile(
|
|
26300
|
+
return this.extractUsageFromFile(path65.join(dir, targetFile));
|
|
26268
26301
|
}
|
|
26269
26302
|
extractUsageFromFile(filePath) {
|
|
26270
26303
|
let raw;
|
|
26271
26304
|
try {
|
|
26272
|
-
raw =
|
|
26305
|
+
raw = fs60.readFileSync(filePath, "utf8");
|
|
26273
26306
|
} catch {
|
|
26274
26307
|
return null;
|
|
26275
26308
|
}
|
|
@@ -26314,9 +26347,9 @@ var HistoryService = class _HistoryService {
|
|
|
26314
26347
|
let totalCost = 0;
|
|
26315
26348
|
let files;
|
|
26316
26349
|
try {
|
|
26317
|
-
files =
|
|
26350
|
+
files = fs60.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
|
|
26318
26351
|
try {
|
|
26319
|
-
return
|
|
26352
|
+
return fs60.statSync(path65.join(projectDir, f)).mtimeMs >= monthStartMs;
|
|
26320
26353
|
} catch {
|
|
26321
26354
|
return false;
|
|
26322
26355
|
}
|
|
@@ -26327,7 +26360,7 @@ var HistoryService = class _HistoryService {
|
|
|
26327
26360
|
for (const file of files) {
|
|
26328
26361
|
let raw;
|
|
26329
26362
|
try {
|
|
26330
|
-
raw =
|
|
26363
|
+
raw = fs60.readFileSync(path65.join(projectDir, file), "utf8");
|
|
26331
26364
|
} catch {
|
|
26332
26365
|
continue;
|
|
26333
26366
|
}
|
|
@@ -26406,7 +26439,7 @@ var HistoryService = class _HistoryService {
|
|
|
26406
26439
|
if (this.runtime.resolveHistoryFile) {
|
|
26407
26440
|
return this.runtime.resolveHistoryFile(this.cwd, sessionId);
|
|
26408
26441
|
}
|
|
26409
|
-
return
|
|
26442
|
+
return path65.join(this.projectDir, `${sessionId}.jsonl`);
|
|
26410
26443
|
}
|
|
26411
26444
|
/**
|
|
26412
26445
|
* Parse a conversation's messages from disk, agent-aware. Claude uses the
|
|
@@ -26440,7 +26473,7 @@ var HistoryService = class _HistoryService {
|
|
|
26440
26473
|
};
|
|
26441
26474
|
});
|
|
26442
26475
|
}
|
|
26443
|
-
return parseJsonl(
|
|
26476
|
+
return parseJsonl(path65.join(this.projectDir, `${sessionId}.jsonl`));
|
|
26444
26477
|
}
|
|
26445
26478
|
async loadConversation(sessionId) {
|
|
26446
26479
|
const messages = this.readConversation(sessionId);
|
|
@@ -26508,7 +26541,7 @@ var HistoryService = class _HistoryService {
|
|
|
26508
26541
|
if (!filePath) return false;
|
|
26509
26542
|
let mtimeMs;
|
|
26510
26543
|
try {
|
|
26511
|
-
mtimeMs =
|
|
26544
|
+
mtimeMs = fs60.statSync(filePath).mtimeMs;
|
|
26512
26545
|
} catch {
|
|
26513
26546
|
return false;
|
|
26514
26547
|
}
|
|
@@ -26583,10 +26616,10 @@ var HistoryService = class _HistoryService {
|
|
|
26583
26616
|
|
|
26584
26617
|
// src/agents/acp/client.ts
|
|
26585
26618
|
var import_node_child_process29 = require("child_process");
|
|
26586
|
-
var
|
|
26619
|
+
var fs61 = __toESM(require("fs/promises"));
|
|
26587
26620
|
var fsSync = __toESM(require("fs"));
|
|
26588
|
-
var
|
|
26589
|
-
var
|
|
26621
|
+
var os52 = __toESM(require("os"));
|
|
26622
|
+
var path66 = __toESM(require("path"));
|
|
26590
26623
|
var import_node_stream = require("stream");
|
|
26591
26624
|
|
|
26592
26625
|
// ../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
@@ -31371,7 +31404,7 @@ var AcpClient = class {
|
|
|
31371
31404
|
},
|
|
31372
31405
|
readTextFile: async (params) => {
|
|
31373
31406
|
try {
|
|
31374
|
-
const content = await
|
|
31407
|
+
const content = await fs61.readFile(params.path, "utf8");
|
|
31375
31408
|
return applyLineRange(content, params.line ?? null, params.limit ?? null);
|
|
31376
31409
|
} catch (err) {
|
|
31377
31410
|
const code = err.code;
|
|
@@ -31391,7 +31424,7 @@ var AcpClient = class {
|
|
|
31391
31424
|
},
|
|
31392
31425
|
writeTextFile: async (params) => {
|
|
31393
31426
|
try {
|
|
31394
|
-
await
|
|
31427
|
+
await fs61.writeFile(params.path, params.content, "utf8");
|
|
31395
31428
|
return {};
|
|
31396
31429
|
} catch (err) {
|
|
31397
31430
|
const code = err.code;
|
|
@@ -31451,29 +31484,29 @@ function applyLineRange(content, line, limit) {
|
|
|
31451
31484
|
return { content: lines.slice(start2, end).join("\n") };
|
|
31452
31485
|
}
|
|
31453
31486
|
function knownAgentBinaryDirs() {
|
|
31454
|
-
const home =
|
|
31487
|
+
const home = os52.homedir();
|
|
31455
31488
|
const out2 = [];
|
|
31456
31489
|
out2.push("/tmp/codeam-node20/bin");
|
|
31457
31490
|
for (const root of [
|
|
31458
31491
|
"/usr/local/share/nvm/versions/node",
|
|
31459
|
-
|
|
31492
|
+
path66.join(home, ".nvm/versions/node")
|
|
31460
31493
|
]) {
|
|
31461
31494
|
try {
|
|
31462
31495
|
for (const child of fsSync.readdirSync(root)) {
|
|
31463
|
-
out2.push(
|
|
31496
|
+
out2.push(path66.join(root, child, "bin"));
|
|
31464
31497
|
}
|
|
31465
31498
|
} catch {
|
|
31466
31499
|
}
|
|
31467
31500
|
}
|
|
31468
|
-
out2.push(
|
|
31501
|
+
out2.push(path66.join(home, ".volta/bin"));
|
|
31469
31502
|
out2.push("/usr/local/bin");
|
|
31470
31503
|
out2.push("/usr/bin");
|
|
31471
|
-
out2.push(
|
|
31472
|
-
out2.push(
|
|
31504
|
+
out2.push(path66.join(home, ".local/bin"));
|
|
31505
|
+
out2.push(path66.join(home, "bin"));
|
|
31473
31506
|
if (process.platform === "win32") {
|
|
31474
31507
|
const { LOCALAPPDATA, APPDATA } = process.env;
|
|
31475
|
-
if (LOCALAPPDATA) out2.push(
|
|
31476
|
-
if (APPDATA) out2.push(
|
|
31508
|
+
if (LOCALAPPDATA) out2.push(path66.join(LOCALAPPDATA, "cursor-agent"));
|
|
31509
|
+
if (APPDATA) out2.push(path66.join(APPDATA, "npm"));
|
|
31477
31510
|
}
|
|
31478
31511
|
return out2.filter((p2) => {
|
|
31479
31512
|
try {
|
|
@@ -31485,7 +31518,7 @@ function knownAgentBinaryDirs() {
|
|
|
31485
31518
|
}
|
|
31486
31519
|
function expandPathForAgentBinaries(existingPath) {
|
|
31487
31520
|
const existing = new Set(
|
|
31488
|
-
existingPath.split(
|
|
31521
|
+
existingPath.split(path66.delimiter).filter((p2) => p2.length > 0)
|
|
31489
31522
|
);
|
|
31490
31523
|
const additions = [];
|
|
31491
31524
|
for (const dir of knownAgentBinaryDirs()) {
|
|
@@ -31495,7 +31528,7 @@ function expandPathForAgentBinaries(existingPath) {
|
|
|
31495
31528
|
}
|
|
31496
31529
|
}
|
|
31497
31530
|
if (additions.length === 0) return existingPath;
|
|
31498
|
-
return [...additions, existingPath].filter((p2) => p2.length > 0).join(
|
|
31531
|
+
return [...additions, existingPath].filter((p2) => p2.length > 0).join(path66.delimiter);
|
|
31499
31532
|
}
|
|
31500
31533
|
|
|
31501
31534
|
// src/agents/acp/headroom-budget-proxy.ts
|
|
@@ -31977,15 +32010,15 @@ function commonPrefixLength(a, b) {
|
|
|
31977
32010
|
|
|
31978
32011
|
// src/agents/acp/onboarding.ts
|
|
31979
32012
|
var import_child_process27 = require("child_process");
|
|
31980
|
-
var
|
|
31981
|
-
var
|
|
31982
|
-
var
|
|
32013
|
+
var fs62 = __toESM(require("fs"));
|
|
32014
|
+
var os53 = __toESM(require("os"));
|
|
32015
|
+
var path67 = __toESM(require("path"));
|
|
31983
32016
|
var _onboardingSeam = {
|
|
31984
|
-
markerPath: (sessionId) =>
|
|
31985
|
-
exists: (p2) =>
|
|
32017
|
+
markerPath: (sessionId) => path67.join(os53.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
|
|
32018
|
+
exists: (p2) => fs62.existsSync(p2),
|
|
31986
32019
|
write: (p2) => {
|
|
31987
|
-
|
|
31988
|
-
|
|
32020
|
+
fs62.mkdirSync(path67.dirname(p2), { recursive: true });
|
|
32021
|
+
fs62.writeFileSync(p2, "");
|
|
31989
32022
|
},
|
|
31990
32023
|
disabled: () => {
|
|
31991
32024
|
const v = process.env.CODEAM_ONBOARDING_DISABLED;
|
|
@@ -32022,7 +32055,7 @@ function resolveRepoName(cwd) {
|
|
|
32022
32055
|
if (name) return name;
|
|
32023
32056
|
}
|
|
32024
32057
|
}
|
|
32025
|
-
const base =
|
|
32058
|
+
const base = path67.basename(cwd || "");
|
|
32026
32059
|
if (base && !isUuid(base)) return base;
|
|
32027
32060
|
return "this project";
|
|
32028
32061
|
}
|
|
@@ -32274,13 +32307,13 @@ var import_crypto5 = require("crypto");
|
|
|
32274
32307
|
|
|
32275
32308
|
// src/services/turn-files/git-changeset.ts
|
|
32276
32309
|
var import_child_process28 = require("child_process");
|
|
32277
|
-
var
|
|
32278
|
-
var
|
|
32310
|
+
var fs64 = __toESM(require("fs/promises"));
|
|
32311
|
+
var path69 = __toESM(require("path"));
|
|
32279
32312
|
|
|
32280
32313
|
// src/services/turn-files/review-ignore.ts
|
|
32281
32314
|
var import_ignore2 = __toESM(require("ignore"));
|
|
32282
|
-
var
|
|
32283
|
-
var
|
|
32315
|
+
var fs63 = __toESM(require("fs"));
|
|
32316
|
+
var path68 = __toESM(require("path"));
|
|
32284
32317
|
var CURATED_REVIEW_IGNORE = [
|
|
32285
32318
|
// Google Cloud SDK (the incident) — installs a huge python tree.
|
|
32286
32319
|
"google-cloud-sdk/",
|
|
@@ -32319,7 +32352,7 @@ var CURATED_REVIEW_IGNORE = [
|
|
|
32319
32352
|
function makeReviewIgnore(repoRoot) {
|
|
32320
32353
|
const ig = (0, import_ignore2.default)().add(CURATED_REVIEW_IGNORE);
|
|
32321
32354
|
try {
|
|
32322
|
-
const custom =
|
|
32355
|
+
const custom = fs63.readFileSync(path68.join(repoRoot, ".codeam", "reviewignore"), "utf8");
|
|
32323
32356
|
ig.add(custom);
|
|
32324
32357
|
} catch {
|
|
32325
32358
|
}
|
|
@@ -32364,7 +32397,7 @@ async function collectRepoChangeset(opts) {
|
|
|
32364
32397
|
let stats;
|
|
32365
32398
|
if (!truncated && row.fileStatus === "added" && numstatEntry === void 0) {
|
|
32366
32399
|
const lineCount = await readUntrackedLineCount(
|
|
32367
|
-
|
|
32400
|
+
path69.join(opts.repoRoot, row.filePath)
|
|
32368
32401
|
);
|
|
32369
32402
|
stats = { added: lineCount, removed: 0 };
|
|
32370
32403
|
} else {
|
|
@@ -32395,7 +32428,7 @@ function readUntrackedLineCount(absPath) {
|
|
|
32395
32428
|
}
|
|
32396
32429
|
async function defaultReadUntrackedLineCount(absPath) {
|
|
32397
32430
|
try {
|
|
32398
|
-
const content = await
|
|
32431
|
+
const content = await fs64.readFile(absPath, "utf8");
|
|
32399
32432
|
let count = 0;
|
|
32400
32433
|
let pos = -1;
|
|
32401
32434
|
while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
|
|
@@ -32487,7 +32520,7 @@ function defaultRunGit(cwd, args2) {
|
|
|
32487
32520
|
});
|
|
32488
32521
|
}
|
|
32489
32522
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
32490
|
-
const
|
|
32523
|
+
const fs70 = await import("fs/promises");
|
|
32491
32524
|
const out2 = [];
|
|
32492
32525
|
await walk(workingDir, 0);
|
|
32493
32526
|
return out2;
|
|
@@ -32495,7 +32528,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
32495
32528
|
if (depth > maxDepth) return;
|
|
32496
32529
|
let entries = [];
|
|
32497
32530
|
try {
|
|
32498
|
-
const dirents = await
|
|
32531
|
+
const dirents = await fs70.readdir(dir, { withFileTypes: true });
|
|
32499
32532
|
entries = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
32500
32533
|
} catch {
|
|
32501
32534
|
return;
|
|
@@ -32506,8 +32539,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
32506
32539
|
if (hasGit) {
|
|
32507
32540
|
out2.push({
|
|
32508
32541
|
repoRoot: dir,
|
|
32509
|
-
repoPath:
|
|
32510
|
-
repoName:
|
|
32542
|
+
repoPath: path69.relative(workingDir, dir),
|
|
32543
|
+
repoName: path69.basename(dir)
|
|
32511
32544
|
});
|
|
32512
32545
|
return;
|
|
32513
32546
|
}
|
|
@@ -32515,14 +32548,14 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
32515
32548
|
if (!entry.isDirectory) continue;
|
|
32516
32549
|
if (entry.name === "node_modules") continue;
|
|
32517
32550
|
if (entry.name === "dist" || entry.name === "build") continue;
|
|
32518
|
-
await walk(
|
|
32551
|
+
await walk(path69.join(dir, entry.name), depth + 1);
|
|
32519
32552
|
}
|
|
32520
32553
|
}
|
|
32521
32554
|
}
|
|
32522
32555
|
|
|
32523
32556
|
// src/services/turn-files/files-outbox.ts
|
|
32524
|
-
var
|
|
32525
|
-
var
|
|
32557
|
+
var fs65 = __toESM(require("fs/promises"));
|
|
32558
|
+
var path70 = __toESM(require("path"));
|
|
32526
32559
|
var import_os12 = require("os");
|
|
32527
32560
|
var HOME_OUTBOX_DIR = ".codeam/outbox";
|
|
32528
32561
|
var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -32555,16 +32588,16 @@ var FilesOutbox = class {
|
|
|
32555
32588
|
backoffIndex = 0;
|
|
32556
32589
|
stopped = false;
|
|
32557
32590
|
constructor(opts) {
|
|
32558
|
-
const base = opts.baseDir ??
|
|
32559
|
-
this.filePath =
|
|
32591
|
+
const base = opts.baseDir ?? path70.join(homeDir(), HOME_OUTBOX_DIR);
|
|
32592
|
+
this.filePath = path70.join(base, `${opts.sessionId}.jsonl`);
|
|
32560
32593
|
this.post = opts.post;
|
|
32561
32594
|
this.autoSchedule = opts.autoSchedule !== false;
|
|
32562
32595
|
}
|
|
32563
32596
|
/** Persist the entry to disk and trigger a flush. Returns once the
|
|
32564
32597
|
* line is durable on disk (not once the POST succeeds). */
|
|
32565
32598
|
async enqueue(entry) {
|
|
32566
|
-
await
|
|
32567
|
-
await
|
|
32599
|
+
await fs65.mkdir(path70.dirname(this.filePath), { recursive: true });
|
|
32600
|
+
await fs65.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
|
|
32568
32601
|
this.backoffIndex = 0;
|
|
32569
32602
|
if (this.autoSchedule) this.scheduleFlush(0);
|
|
32570
32603
|
}
|
|
@@ -32655,7 +32688,7 @@ var FilesOutbox = class {
|
|
|
32655
32688
|
async readAll() {
|
|
32656
32689
|
let raw = "";
|
|
32657
32690
|
try {
|
|
32658
|
-
raw = await
|
|
32691
|
+
raw = await fs65.readFile(this.filePath, "utf8");
|
|
32659
32692
|
} catch {
|
|
32660
32693
|
return [];
|
|
32661
32694
|
}
|
|
@@ -32679,12 +32712,12 @@ var FilesOutbox = class {
|
|
|
32679
32712
|
async rewrite(entries) {
|
|
32680
32713
|
const tmpPath = `${this.filePath}.${process.pid}.tmp`;
|
|
32681
32714
|
if (entries.length === 0) {
|
|
32682
|
-
await
|
|
32715
|
+
await fs65.unlink(this.filePath).catch(() => void 0);
|
|
32683
32716
|
return;
|
|
32684
32717
|
}
|
|
32685
32718
|
const payload = entries.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
32686
|
-
await
|
|
32687
|
-
await
|
|
32719
|
+
await fs65.writeFile(tmpPath, payload, "utf8");
|
|
32720
|
+
await fs65.rename(tmpPath, this.filePath);
|
|
32688
32721
|
}
|
|
32689
32722
|
};
|
|
32690
32723
|
function applyJitter(ms) {
|
|
@@ -35598,9 +35631,9 @@ function fetchQuotaUsage(runtime, historySvc) {
|
|
|
35598
35631
|
}
|
|
35599
35632
|
|
|
35600
35633
|
// src/beads/workflow-hint.ts
|
|
35601
|
-
var
|
|
35602
|
-
var
|
|
35603
|
-
var
|
|
35634
|
+
var fs66 = __toESM(require("fs"));
|
|
35635
|
+
var path71 = __toESM(require("path"));
|
|
35636
|
+
var os54 = __toESM(require("os"));
|
|
35604
35637
|
var BEADS_HINT_MARKER = "<!-- codeam:beads-workflow -->";
|
|
35605
35638
|
var BEADS_HINT = `${BEADS_HINT_MARKER}
|
|
35606
35639
|
# Beads (bd) \u2014 task tracking + persistent memory (ALWAYS use it)
|
|
@@ -35614,22 +35647,22 @@ This environment uses **bd (beads)** for issue/task tracking and persistent memo
|
|
|
35614
35647
|
- \`bd ready\` (available work) \xB7 \`bd show <id>\` \xB7 \`bd update <id> --claim\` \xB7 \`bd close <id>\`.
|
|
35615
35648
|
- Use \`bd remember "..."\` for persistent knowledge \u2014 do NOT use MEMORY.md files.
|
|
35616
35649
|
${BEADS_HINT_MARKER}`;
|
|
35617
|
-
function ensureBeadsWorkflowHint(homeDir2 =
|
|
35650
|
+
function ensureBeadsWorkflowHint(homeDir2 = os54.homedir()) {
|
|
35618
35651
|
try {
|
|
35619
|
-
const file =
|
|
35652
|
+
const file = path71.join(homeDir2, ".claude", "CLAUDE.md");
|
|
35620
35653
|
let existing = "";
|
|
35621
35654
|
try {
|
|
35622
|
-
existing =
|
|
35655
|
+
existing = fs66.readFileSync(file, "utf8");
|
|
35623
35656
|
} catch {
|
|
35624
35657
|
}
|
|
35625
35658
|
if (existing.includes(BEADS_HINT_MARKER)) return;
|
|
35626
|
-
|
|
35659
|
+
fs66.mkdirSync(path71.dirname(file), { recursive: true });
|
|
35627
35660
|
const next = existing.trim() ? `${existing.trimEnd()}
|
|
35628
35661
|
|
|
35629
35662
|
${BEADS_HINT}
|
|
35630
35663
|
` : `${BEADS_HINT}
|
|
35631
35664
|
`;
|
|
35632
|
-
|
|
35665
|
+
fs66.writeFileSync(file, next);
|
|
35633
35666
|
} catch {
|
|
35634
35667
|
}
|
|
35635
35668
|
}
|
|
@@ -36038,7 +36071,7 @@ var AcpDriver = class {
|
|
|
36038
36071
|
};
|
|
36039
36072
|
|
|
36040
36073
|
// src/baton/transcript-mirror.ts
|
|
36041
|
-
var
|
|
36074
|
+
var fs67 = __toESM(require("fs"));
|
|
36042
36075
|
var TranscriptMirror = class {
|
|
36043
36076
|
constructor(deps) {
|
|
36044
36077
|
this.deps = deps;
|
|
@@ -36105,7 +36138,7 @@ var TranscriptMirror = class {
|
|
|
36105
36138
|
}
|
|
36106
36139
|
};
|
|
36107
36140
|
function defaultWatch(file, onChange) {
|
|
36108
|
-
const w3 =
|
|
36141
|
+
const w3 = fs67.watch(file, { persistent: false }, () => onChange());
|
|
36109
36142
|
return () => w3.close();
|
|
36110
36143
|
}
|
|
36111
36144
|
|
|
@@ -36367,16 +36400,16 @@ function toEpochMs(ts) {
|
|
|
36367
36400
|
}
|
|
36368
36401
|
|
|
36369
36402
|
// src/agents/claude/onboarding.ts
|
|
36370
|
-
var
|
|
36371
|
-
var
|
|
36372
|
-
var
|
|
36403
|
+
var fs68 = __toESM(require("fs"));
|
|
36404
|
+
var os56 = __toESM(require("os"));
|
|
36405
|
+
var path72 = __toESM(require("path"));
|
|
36373
36406
|
var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
|
|
36374
36407
|
function ensureClaudeOnboarded(cwd) {
|
|
36375
36408
|
try {
|
|
36376
|
-
const file =
|
|
36409
|
+
const file = path72.join(os56.homedir(), ".claude.json");
|
|
36377
36410
|
let config = {};
|
|
36378
36411
|
try {
|
|
36379
|
-
config = JSON.parse(
|
|
36412
|
+
config = JSON.parse(fs68.readFileSync(file, "utf8"));
|
|
36380
36413
|
} catch {
|
|
36381
36414
|
}
|
|
36382
36415
|
let changed = false;
|
|
@@ -36401,8 +36434,8 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
36401
36434
|
}
|
|
36402
36435
|
}
|
|
36403
36436
|
if (!changed) return;
|
|
36404
|
-
|
|
36405
|
-
|
|
36437
|
+
fs68.mkdirSync(path72.dirname(file), { recursive: true });
|
|
36438
|
+
fs68.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
36406
36439
|
log.info(
|
|
36407
36440
|
"claude",
|
|
36408
36441
|
`pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
|
|
@@ -37120,7 +37153,7 @@ var import_picocolors11 = __toESM(require("picocolors"));
|
|
|
37120
37153
|
var import_child_process29 = require("child_process");
|
|
37121
37154
|
var import_util4 = require("util");
|
|
37122
37155
|
var import_picocolors9 = __toESM(require("picocolors"));
|
|
37123
|
-
var
|
|
37156
|
+
var path73 = __toESM(require("path"));
|
|
37124
37157
|
var execFileP6 = (0, import_util4.promisify)(import_child_process29.execFile);
|
|
37125
37158
|
var MAX_BUFFER = 8 * 1024 * 1024;
|
|
37126
37159
|
function resetStdinForChild() {
|
|
@@ -37609,7 +37642,7 @@ var GitHubCodespacesProvider = class {
|
|
|
37609
37642
|
});
|
|
37610
37643
|
}
|
|
37611
37644
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
37612
|
-
const remoteDir =
|
|
37645
|
+
const remoteDir = path73.posix.dirname(remotePath);
|
|
37613
37646
|
const parts = [
|
|
37614
37647
|
`mkdir -p ${shellQuote(remoteDir)}`,
|
|
37615
37648
|
`cat > ${shellQuote(remotePath)}`
|
|
@@ -37679,7 +37712,7 @@ function shellQuote(s) {
|
|
|
37679
37712
|
// src/services/providers/gitpod.ts
|
|
37680
37713
|
var import_child_process30 = require("child_process");
|
|
37681
37714
|
var import_util5 = require("util");
|
|
37682
|
-
var
|
|
37715
|
+
var path74 = __toESM(require("path"));
|
|
37683
37716
|
var import_picocolors10 = __toESM(require("picocolors"));
|
|
37684
37717
|
var execFileP7 = (0, import_util5.promisify)(import_child_process30.execFile);
|
|
37685
37718
|
var MAX_BUFFER2 = 8 * 1024 * 1024;
|
|
@@ -37919,7 +37952,7 @@ var GitpodProvider = class {
|
|
|
37919
37952
|
});
|
|
37920
37953
|
}
|
|
37921
37954
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
37922
|
-
const remoteDir =
|
|
37955
|
+
const remoteDir = path74.posix.dirname(remotePath);
|
|
37923
37956
|
const parts = [
|
|
37924
37957
|
`mkdir -p ${shellQuote2(remoteDir)}`,
|
|
37925
37958
|
`cat > ${shellQuote2(remotePath)}`
|
|
@@ -37955,7 +37988,7 @@ function shellQuote2(s) {
|
|
|
37955
37988
|
// src/services/providers/gitlab-workspaces.ts
|
|
37956
37989
|
var import_child_process31 = require("child_process");
|
|
37957
37990
|
var import_util6 = require("util");
|
|
37958
|
-
var
|
|
37991
|
+
var path75 = __toESM(require("path"));
|
|
37959
37992
|
var execFileP8 = (0, import_util6.promisify)(import_child_process31.execFile);
|
|
37960
37993
|
var MAX_BUFFER3 = 8 * 1024 * 1024;
|
|
37961
37994
|
var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
|
|
@@ -38215,7 +38248,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
38215
38248
|
}
|
|
38216
38249
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
38217
38250
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
38218
|
-
const remoteDir =
|
|
38251
|
+
const remoteDir = path75.posix.dirname(remotePath);
|
|
38219
38252
|
const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
|
|
38220
38253
|
if (options.mode != null) {
|
|
38221
38254
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
@@ -38283,7 +38316,7 @@ function shellQuote3(s) {
|
|
|
38283
38316
|
// src/services/providers/railway.ts
|
|
38284
38317
|
var import_child_process32 = require("child_process");
|
|
38285
38318
|
var import_util7 = require("util");
|
|
38286
|
-
var
|
|
38319
|
+
var path76 = __toESM(require("path"));
|
|
38287
38320
|
var execFileP9 = (0, import_util7.promisify)(import_child_process32.execFile);
|
|
38288
38321
|
var MAX_BUFFER4 = 8 * 1024 * 1024;
|
|
38289
38322
|
function resetStdinForChild4() {
|
|
@@ -38519,7 +38552,7 @@ var RailwayProvider = class {
|
|
|
38519
38552
|
if (!projectId || !serviceId) {
|
|
38520
38553
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
38521
38554
|
}
|
|
38522
|
-
const remoteDir =
|
|
38555
|
+
const remoteDir = path76.posix.dirname(remotePath);
|
|
38523
38556
|
const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
|
|
38524
38557
|
if (options.mode != null) {
|
|
38525
38558
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
@@ -39165,8 +39198,8 @@ async function invite() {
|
|
|
39165
39198
|
var import_node_dns = require("dns");
|
|
39166
39199
|
var import_node_util5 = require("util");
|
|
39167
39200
|
var import_node_crypto13 = require("crypto");
|
|
39168
|
-
var
|
|
39169
|
-
var
|
|
39201
|
+
var fs69 = __toESM(require("fs"));
|
|
39202
|
+
var path77 = __toESM(require("path"));
|
|
39170
39203
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
39171
39204
|
var dnsResolveP = (0, import_node_util5.promisify)(import_node_dns.resolve);
|
|
39172
39205
|
async function checkDns(apiBase2) {
|
|
@@ -39222,13 +39255,13 @@ async function checkHealth(apiBase2) {
|
|
|
39222
39255
|
}
|
|
39223
39256
|
}
|
|
39224
39257
|
function checkConfigDir() {
|
|
39225
|
-
const dir =
|
|
39258
|
+
const dir = path77.join(require("os").homedir(), ".codeam");
|
|
39226
39259
|
try {
|
|
39227
|
-
|
|
39228
|
-
const probe =
|
|
39229
|
-
|
|
39230
|
-
const read2 =
|
|
39231
|
-
|
|
39260
|
+
fs69.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
39261
|
+
const probe = path77.join(dir, ".doctor-probe");
|
|
39262
|
+
fs69.writeFileSync(probe, "ok", { mode: 384 });
|
|
39263
|
+
const read2 = fs69.readFileSync(probe, "utf8");
|
|
39264
|
+
fs69.unlinkSync(probe);
|
|
39232
39265
|
if (read2 !== "ok") throw new Error("write/read round-trip mismatch");
|
|
39233
39266
|
return {
|
|
39234
39267
|
id: "config-dir",
|
|
@@ -39268,9 +39301,9 @@ function checkSessions() {
|
|
|
39268
39301
|
}
|
|
39269
39302
|
}
|
|
39270
39303
|
function checkAgentBinaries() {
|
|
39271
|
-
const
|
|
39304
|
+
const os59 = createOsStrategy();
|
|
39272
39305
|
return getEnabledAgents().map((meta) => {
|
|
39273
|
-
const found =
|
|
39306
|
+
const found = os59.findInPath(meta.binaryName);
|
|
39274
39307
|
return {
|
|
39275
39308
|
id: `agent-${meta.id}`,
|
|
39276
39309
|
label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
|
|
@@ -39292,7 +39325,7 @@ function checkNodePty() {
|
|
|
39292
39325
|
detail: "not required on this platform"
|
|
39293
39326
|
};
|
|
39294
39327
|
}
|
|
39295
|
-
const vendoredPath =
|
|
39328
|
+
const vendoredPath = path77.join(__dirname, "vendor", "node-pty");
|
|
39296
39329
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
39297
39330
|
try {
|
|
39298
39331
|
require(target);
|
|
@@ -39334,7 +39367,7 @@ function checkChokidar() {
|
|
|
39334
39367
|
}
|
|
39335
39368
|
async function doctor(args2 = []) {
|
|
39336
39369
|
const json = args2.includes("--json");
|
|
39337
|
-
const cliVersion = true ? "2.61.
|
|
39370
|
+
const cliVersion = true ? "2.61.52" : "0.0.0-dev";
|
|
39338
39371
|
const apiBase2 = resolveApiBaseUrl();
|
|
39339
39372
|
const diagnosticId = (0, import_node_crypto13.randomUUID)();
|
|
39340
39373
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
@@ -39856,7 +39889,7 @@ async function mcpRun(args2) {
|
|
|
39856
39889
|
// src/commands/version.ts
|
|
39857
39890
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
39858
39891
|
function version2() {
|
|
39859
|
-
const v = true ? "2.61.
|
|
39892
|
+
const v = true ? "2.61.52" : "unknown";
|
|
39860
39893
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
39861
39894
|
}
|
|
39862
39895
|
|
|
@@ -40005,10 +40038,10 @@ var EXIT_CODE_NAMES = {
|
|
|
40005
40038
|
};
|
|
40006
40039
|
|
|
40007
40040
|
// src/index.ts
|
|
40008
|
-
var
|
|
40041
|
+
var os58 = __toESM(require("os"));
|
|
40009
40042
|
if (!process.env.HOME) {
|
|
40010
40043
|
try {
|
|
40011
|
-
const home =
|
|
40044
|
+
const home = os58.homedir();
|
|
40012
40045
|
if (home) process.env.HOME = home;
|
|
40013
40046
|
} catch {
|
|
40014
40047
|
}
|