codeam-cli 2.51.1 → 2.51.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/index.js +495 -346
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -522,9 +522,9 @@ var _default = makeConfig();
|
|
|
522
522
|
var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, clearAll, saveCliConfig, loadCliConfig } = _default;
|
|
523
523
|
|
|
524
524
|
// src/commands/pair-auto.ts
|
|
525
|
-
var
|
|
526
|
-
var
|
|
527
|
-
var
|
|
525
|
+
var fs44 = __toESM(require("fs"));
|
|
526
|
+
var os37 = __toESM(require("os"));
|
|
527
|
+
var path49 = __toESM(require("path"));
|
|
528
528
|
var import_crypto4 = require("crypto");
|
|
529
529
|
|
|
530
530
|
// src/services/telemetry.service.ts
|
|
@@ -560,8 +560,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
|
|
|
560
560
|
return decodedFile;
|
|
561
561
|
};
|
|
562
562
|
}
|
|
563
|
-
function normalizeWindowsPath(
|
|
564
|
-
return
|
|
563
|
+
function normalizeWindowsPath(path62) {
|
|
564
|
+
return path62.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
565
565
|
}
|
|
566
566
|
|
|
567
567
|
// ../../node_modules/@posthog/core/dist/featureFlagUtils.mjs
|
|
@@ -3041,9 +3041,9 @@ async function addSourceContext(frames) {
|
|
|
3041
3041
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
3042
3042
|
return frames;
|
|
3043
3043
|
}
|
|
3044
|
-
function getContextLinesFromFile(
|
|
3044
|
+
function getContextLinesFromFile(path62, ranges, output) {
|
|
3045
3045
|
return new Promise((resolve7) => {
|
|
3046
|
-
const stream = (0, import_node_fs.createReadStream)(
|
|
3046
|
+
const stream = (0, import_node_fs.createReadStream)(path62);
|
|
3047
3047
|
const lineReaded = (0, import_node_readline.createInterface)({
|
|
3048
3048
|
input: stream
|
|
3049
3049
|
});
|
|
@@ -3058,7 +3058,7 @@ function getContextLinesFromFile(path61, ranges, output) {
|
|
|
3058
3058
|
let rangeStart = range[0];
|
|
3059
3059
|
let rangeEnd = range[1];
|
|
3060
3060
|
function onStreamError() {
|
|
3061
|
-
LRU_FILE_CONTENTS_FS_READ_FAILED.set(
|
|
3061
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(path62, 1);
|
|
3062
3062
|
lineReaded.close();
|
|
3063
3063
|
lineReaded.removeAllListeners();
|
|
3064
3064
|
destroyStreamAndResolve();
|
|
@@ -3119,8 +3119,8 @@ function clearLineContext(frame) {
|
|
|
3119
3119
|
delete frame.context_line;
|
|
3120
3120
|
delete frame.post_context;
|
|
3121
3121
|
}
|
|
3122
|
-
function shouldSkipContextLinesForFile(
|
|
3123
|
-
return
|
|
3122
|
+
function shouldSkipContextLinesForFile(path62) {
|
|
3123
|
+
return path62.startsWith("node:") || path62.endsWith(".min.js") || path62.endsWith(".min.cjs") || path62.endsWith(".min.mjs") || path62.startsWith("data:");
|
|
3124
3124
|
}
|
|
3125
3125
|
function shouldSkipContextLinesForFrame(frame) {
|
|
3126
3126
|
if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
|
|
@@ -5397,7 +5397,7 @@ function readAnonId() {
|
|
|
5397
5397
|
}
|
|
5398
5398
|
function superProperties() {
|
|
5399
5399
|
return {
|
|
5400
|
-
cliVersion: true ? "2.51.
|
|
5400
|
+
cliVersion: true ? "2.51.3" : "0.0.0-dev",
|
|
5401
5401
|
nodeVersion: process.version,
|
|
5402
5402
|
platform: process.platform,
|
|
5403
5403
|
arch: process.arch,
|
|
@@ -5578,7 +5578,7 @@ var os4 = __toESM(require("os"));
|
|
|
5578
5578
|
// package.json
|
|
5579
5579
|
var package_default = {
|
|
5580
5580
|
name: "codeam-cli",
|
|
5581
|
-
version: "2.51.
|
|
5581
|
+
version: "2.51.3",
|
|
5582
5582
|
description: "Workflow-continuity bridge for AI coding agents. Wrap Claude Code or Codex in a PTY and supervise, approve, and redirect the session from any device \u2014 async. The terminal companion for CodeAgent Mobile.",
|
|
5583
5583
|
type: "commonjs",
|
|
5584
5584
|
main: "dist/index.js",
|
|
@@ -6610,10 +6610,10 @@ var WINDOWS_LEGACY_JUNCTIONS = [
|
|
|
6610
6610
|
/[\\/]Start Menu([\\/]|$)/i,
|
|
6611
6611
|
/[\\/]Templates([\\/]|$)/i
|
|
6612
6612
|
];
|
|
6613
|
-
function isUnsafeWindowsWatchRoot(dir,
|
|
6613
|
+
function isUnsafeWindowsWatchRoot(dir, homedir34) {
|
|
6614
6614
|
const norm = (p2) => p2.replace(/\//g, "\\").replace(/\\+$/, "").toLowerCase();
|
|
6615
6615
|
const cwd = norm(dir);
|
|
6616
|
-
const home = norm(
|
|
6616
|
+
const home = norm(homedir34);
|
|
6617
6617
|
if (cwd === home) return true;
|
|
6618
6618
|
if (/^[a-z]:$/.test(cwd)) return true;
|
|
6619
6619
|
const sysRoots = [
|
|
@@ -7728,11 +7728,11 @@ function closeAllTerminals() {
|
|
|
7728
7728
|
}
|
|
7729
7729
|
|
|
7730
7730
|
// src/commands/start/handlers.ts
|
|
7731
|
-
var
|
|
7732
|
-
var
|
|
7733
|
-
var
|
|
7731
|
+
var fs43 = __toESM(require("fs"));
|
|
7732
|
+
var os36 = __toESM(require("os"));
|
|
7733
|
+
var path48 = __toESM(require("path"));
|
|
7734
7734
|
var import_crypto3 = require("crypto");
|
|
7735
|
-
var
|
|
7735
|
+
var import_child_process21 = require("child_process");
|
|
7736
7736
|
var import_which2 = __toESM(require("which"));
|
|
7737
7737
|
|
|
7738
7738
|
// src/lib/payload.ts
|
|
@@ -11164,10 +11164,10 @@ function buildForPlatform(platform3) {
|
|
|
11164
11164
|
var import_node_crypto4 = require("crypto");
|
|
11165
11165
|
|
|
11166
11166
|
// src/agents/claude/resolver.ts
|
|
11167
|
-
function buildClaudeLaunch(extraArgs = [],
|
|
11168
|
-
const found =
|
|
11167
|
+
function buildClaudeLaunch(extraArgs = [], os43 = createOsStrategy()) {
|
|
11168
|
+
const found = os43.findInPath("claude") ?? os43.findInPath("claude-code");
|
|
11169
11169
|
if (!found) return null;
|
|
11170
|
-
return
|
|
11170
|
+
return os43.buildLaunch(found, extraArgs);
|
|
11171
11171
|
}
|
|
11172
11172
|
|
|
11173
11173
|
// src/agents/claude/installer.ts
|
|
@@ -11760,8 +11760,8 @@ var ClaudeRuntimeStrategy = class {
|
|
|
11760
11760
|
meta = getAgent("claude");
|
|
11761
11761
|
mode = "interactive";
|
|
11762
11762
|
os;
|
|
11763
|
-
constructor(
|
|
11764
|
-
this.os =
|
|
11763
|
+
constructor(os43) {
|
|
11764
|
+
this.os = os43;
|
|
11765
11765
|
}
|
|
11766
11766
|
/**
|
|
11767
11767
|
* Claude Code's react-ink TUI enables bracketed-paste mode at
|
|
@@ -12438,8 +12438,8 @@ function codexCredentialLocator() {
|
|
|
12438
12438
|
function codexLoginLauncher() {
|
|
12439
12439
|
return {
|
|
12440
12440
|
async ensureInstalled() {
|
|
12441
|
-
const
|
|
12442
|
-
return
|
|
12441
|
+
const os43 = createOsStrategy();
|
|
12442
|
+
return os43.findInPath("codex") !== null;
|
|
12443
12443
|
},
|
|
12444
12444
|
launch() {
|
|
12445
12445
|
return (0, import_node_child_process3.spawn)("codex", ["login"], { stdio: "inherit" });
|
|
@@ -12462,8 +12462,8 @@ var CodexRuntimeStrategy = class {
|
|
|
12462
12462
|
meta = getAgent("codex");
|
|
12463
12463
|
mode = "interactive";
|
|
12464
12464
|
os;
|
|
12465
|
-
constructor(
|
|
12466
|
-
this.os =
|
|
12465
|
+
constructor(os43) {
|
|
12466
|
+
this.os = os43;
|
|
12467
12467
|
}
|
|
12468
12468
|
async prepareLaunch() {
|
|
12469
12469
|
let binary = this.os.findInPath("codex");
|
|
@@ -12562,12 +12562,12 @@ var CodexRuntimeStrategy = class {
|
|
|
12562
12562
|
});
|
|
12563
12563
|
}
|
|
12564
12564
|
};
|
|
12565
|
-
function resolveNpm(
|
|
12566
|
-
return
|
|
12565
|
+
function resolveNpm(os43) {
|
|
12566
|
+
return os43.id === "win32" ? "npm.cmd" : "npm";
|
|
12567
12567
|
}
|
|
12568
|
-
async function installCodexViaNpm(
|
|
12568
|
+
async function installCodexViaNpm(os43) {
|
|
12569
12569
|
return new Promise((resolve7, reject) => {
|
|
12570
|
-
const proc = (0, import_node_child_process4.spawn)(resolveNpm(
|
|
12570
|
+
const proc = (0, import_node_child_process4.spawn)(resolveNpm(os43), ["install", "-g", "@openai/codex"], {
|
|
12571
12571
|
stdio: "inherit"
|
|
12572
12572
|
});
|
|
12573
12573
|
proc.on("close", (code) => {
|
|
@@ -12584,16 +12584,16 @@ async function installCodexViaNpm(os42) {
|
|
|
12584
12584
|
});
|
|
12585
12585
|
});
|
|
12586
12586
|
}
|
|
12587
|
-
function augmentNpmGlobalBin(
|
|
12587
|
+
function augmentNpmGlobalBin(os43) {
|
|
12588
12588
|
try {
|
|
12589
|
-
const result = (0, import_node_child_process4.spawnSync)(resolveNpm(
|
|
12589
|
+
const result = (0, import_node_child_process4.spawnSync)(resolveNpm(os43), ["prefix", "-g"], {
|
|
12590
12590
|
stdio: ["ignore", "pipe", "ignore"]
|
|
12591
12591
|
});
|
|
12592
12592
|
if (result.status !== 0) return;
|
|
12593
12593
|
const prefix = result.stdout.toString().trim();
|
|
12594
12594
|
if (!prefix) return;
|
|
12595
|
-
const binDir =
|
|
12596
|
-
|
|
12595
|
+
const binDir = os43.id === "win32" ? prefix : path22.join(prefix, "bin");
|
|
12596
|
+
os43.augmentPath([binDir]);
|
|
12597
12597
|
} catch {
|
|
12598
12598
|
}
|
|
12599
12599
|
}
|
|
@@ -12677,9 +12677,9 @@ var import_node_child_process7 = require("child_process");
|
|
|
12677
12677
|
// src/agents/coderabbit/installer.ts
|
|
12678
12678
|
var import_node_child_process5 = require("child_process");
|
|
12679
12679
|
var INSTALL_URL = "https://cli.coderabbit.ai/install.sh";
|
|
12680
|
-
async function ensureCoderabbitInstalled(
|
|
12681
|
-
if (
|
|
12682
|
-
if (
|
|
12680
|
+
async function ensureCoderabbitInstalled(os43) {
|
|
12681
|
+
if (os43.findInPath("coderabbit")) return true;
|
|
12682
|
+
if (os43.id === "win32") {
|
|
12683
12683
|
console.error(
|
|
12684
12684
|
"\n \u2717 CodeRabbit on Windows requires WSL.\n Install the CLI inside your WSL distribution\n (curl -fsSL https://cli.coderabbit.ai/install.sh | sh)\n then re-run `codeam link coderabbit` from WSL.\n"
|
|
12685
12685
|
);
|
|
@@ -12694,8 +12694,8 @@ async function ensureCoderabbitInstalled(os42) {
|
|
|
12694
12694
|
proc.on("error", () => resolve7(false));
|
|
12695
12695
|
});
|
|
12696
12696
|
if (!ok) return false;
|
|
12697
|
-
|
|
12698
|
-
return
|
|
12697
|
+
os43.augmentPath([`${os43.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
|
|
12698
|
+
return os43.findInPath("coderabbit") !== null;
|
|
12699
12699
|
}
|
|
12700
12700
|
|
|
12701
12701
|
// src/agents/coderabbit/link.ts
|
|
@@ -12730,10 +12730,10 @@ function coderabbitCredentialLocator() {
|
|
|
12730
12730
|
validate: validateNonEmptyCredential
|
|
12731
12731
|
};
|
|
12732
12732
|
}
|
|
12733
|
-
function coderabbitLoginLauncher(
|
|
12733
|
+
function coderabbitLoginLauncher(os43) {
|
|
12734
12734
|
return {
|
|
12735
12735
|
async ensureInstalled() {
|
|
12736
|
-
return ensureCoderabbitInstalled(
|
|
12736
|
+
return ensureCoderabbitInstalled(os43);
|
|
12737
12737
|
},
|
|
12738
12738
|
launch() {
|
|
12739
12739
|
return (0, import_node_child_process6.spawn)("coderabbit", ["login"], { stdio: "inherit" });
|
|
@@ -12756,11 +12756,11 @@ function parseReview(stdout) {
|
|
|
12756
12756
|
for (const line of lines) {
|
|
12757
12757
|
const m = line.match(HUNK_LINE_RE);
|
|
12758
12758
|
if (!m) continue;
|
|
12759
|
-
const [,
|
|
12760
|
-
if (!
|
|
12759
|
+
const [, path62, lineNo, sevToken, message] = m;
|
|
12760
|
+
if (!path62 || !lineNo || !message) continue;
|
|
12761
12761
|
const cleanedMessage = message.trim().replace(/^[*-]\s+/, "");
|
|
12762
12762
|
hunks.push({
|
|
12763
|
-
path:
|
|
12763
|
+
path: path62.trim(),
|
|
12764
12764
|
line: Number(lineNo),
|
|
12765
12765
|
severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
|
|
12766
12766
|
message: cleanedMessage
|
|
@@ -12779,8 +12779,8 @@ var CoderabbitRuntimeStrategy = class {
|
|
|
12779
12779
|
meta = getAgent("coderabbit");
|
|
12780
12780
|
mode = "batch";
|
|
12781
12781
|
os;
|
|
12782
|
-
constructor(
|
|
12783
|
-
this.os =
|
|
12782
|
+
constructor(os43) {
|
|
12783
|
+
this.os = os43;
|
|
12784
12784
|
}
|
|
12785
12785
|
getDefaultArgs() {
|
|
12786
12786
|
return ["review"];
|
|
@@ -12896,10 +12896,10 @@ function cursorCredentialLocator() {
|
|
|
12896
12896
|
validate: validateNonEmptyCredential
|
|
12897
12897
|
};
|
|
12898
12898
|
}
|
|
12899
|
-
function cursorLoginLauncher(
|
|
12899
|
+
function cursorLoginLauncher(os43) {
|
|
12900
12900
|
return {
|
|
12901
12901
|
async ensureInstalled() {
|
|
12902
|
-
if (
|
|
12902
|
+
if (os43.findInPath("cursor-agent")) return true;
|
|
12903
12903
|
console.error(
|
|
12904
12904
|
"\n \u2717 cursor-agent binary not on PATH.\n Install Cursor (https://cursor.com/) and ensure the CLI\n plugin is enabled, then re-run `codeam link cursor`.\n"
|
|
12905
12905
|
);
|
|
@@ -12961,8 +12961,8 @@ var CursorRuntimeStrategy = class {
|
|
|
12961
12961
|
meta = getAgent("cursor");
|
|
12962
12962
|
mode = "interactive";
|
|
12963
12963
|
os;
|
|
12964
|
-
constructor(
|
|
12965
|
-
this.os =
|
|
12964
|
+
constructor(os43) {
|
|
12965
|
+
this.os = os43;
|
|
12966
12966
|
}
|
|
12967
12967
|
async prepareLaunch() {
|
|
12968
12968
|
const binary = this.os.findInPath("cursor-agent");
|
|
@@ -13101,10 +13101,10 @@ function aiderCredentialLocator() {
|
|
|
13101
13101
|
validate: validateNonEmptyCredential
|
|
13102
13102
|
};
|
|
13103
13103
|
}
|
|
13104
|
-
function aiderLoginLauncher(
|
|
13104
|
+
function aiderLoginLauncher(os43) {
|
|
13105
13105
|
return {
|
|
13106
13106
|
async ensureInstalled() {
|
|
13107
|
-
if (
|
|
13107
|
+
if (os43.findInPath("aider")) return true;
|
|
13108
13108
|
console.error(
|
|
13109
13109
|
"\n \u2717 aider binary not on PATH.\n Install Aider:\n pip install aider-chat\n then re-run `codeam link aider`.\n"
|
|
13110
13110
|
);
|
|
@@ -13114,7 +13114,7 @@ function aiderLoginLauncher(os42) {
|
|
|
13114
13114
|
console.error(
|
|
13115
13115
|
"\n Aider has no interactive login flow.\n Set ANTHROPIC_API_KEY or OPENAI_API_KEY in your shell,\n or re-run `codeam link aider --api-key=<your-key>`.\n"
|
|
13116
13116
|
);
|
|
13117
|
-
return (0, import_node_child_process9.spawn)(
|
|
13117
|
+
return (0, import_node_child_process9.spawn)(os43.id === "win32" ? "cmd.exe" : "sh", os43.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
|
|
13118
13118
|
stdio: "ignore"
|
|
13119
13119
|
});
|
|
13120
13120
|
}
|
|
@@ -13186,8 +13186,8 @@ var AiderRuntimeStrategy = class {
|
|
|
13186
13186
|
meta = getAgent("aider");
|
|
13187
13187
|
mode = "interactive";
|
|
13188
13188
|
os;
|
|
13189
|
-
constructor(
|
|
13190
|
-
this.os =
|
|
13189
|
+
constructor(os43) {
|
|
13190
|
+
this.os = os43;
|
|
13191
13191
|
}
|
|
13192
13192
|
async prepareLaunch() {
|
|
13193
13193
|
const binary = this.os.findInPath("aider");
|
|
@@ -13316,8 +13316,8 @@ function geminiCredentialLocator() {
|
|
|
13316
13316
|
function geminiLoginLauncher() {
|
|
13317
13317
|
return {
|
|
13318
13318
|
async ensureInstalled() {
|
|
13319
|
-
const
|
|
13320
|
-
return
|
|
13319
|
+
const os43 = createOsStrategy();
|
|
13320
|
+
return os43.findInPath("gemini") !== null;
|
|
13321
13321
|
},
|
|
13322
13322
|
launch() {
|
|
13323
13323
|
return (0, import_node_child_process10.spawn)("gemini", ["auth", "login"], { stdio: "inherit" });
|
|
@@ -13350,8 +13350,8 @@ var GeminiRuntimeStrategy = class {
|
|
|
13350
13350
|
meta = getAgent("gemini");
|
|
13351
13351
|
mode = "interactive";
|
|
13352
13352
|
os;
|
|
13353
|
-
constructor(
|
|
13354
|
-
this.os =
|
|
13353
|
+
constructor(os43) {
|
|
13354
|
+
this.os = os43;
|
|
13355
13355
|
}
|
|
13356
13356
|
async prepareLaunch() {
|
|
13357
13357
|
const binary = this.os.findInPath("gemini");
|
|
@@ -13450,18 +13450,18 @@ var GeminiRuntimeStrategy = class {
|
|
|
13450
13450
|
|
|
13451
13451
|
// src/agents/registry.ts
|
|
13452
13452
|
var runtimeBuilders = {
|
|
13453
|
-
claude: (
|
|
13454
|
-
codex: (
|
|
13455
|
-
coderabbit: (
|
|
13456
|
-
cursor: (
|
|
13457
|
-
aider: (
|
|
13458
|
-
gemini: (
|
|
13453
|
+
claude: (os43) => new ClaudeRuntimeStrategy(os43),
|
|
13454
|
+
codex: (os43) => new CodexRuntimeStrategy(os43),
|
|
13455
|
+
coderabbit: (os43) => new CoderabbitRuntimeStrategy(os43),
|
|
13456
|
+
cursor: (os43) => new CursorRuntimeStrategy(os43),
|
|
13457
|
+
aider: (os43) => new AiderRuntimeStrategy(os43),
|
|
13458
|
+
gemini: (os43) => new GeminiRuntimeStrategy(os43)
|
|
13459
13459
|
};
|
|
13460
13460
|
var deployBuilders = {
|
|
13461
13461
|
claude: () => new ClaudeDeployStrategy(),
|
|
13462
13462
|
codex: () => new CodexDeployStrategy()
|
|
13463
13463
|
};
|
|
13464
|
-
function createAgentStrategy(agent,
|
|
13464
|
+
function createAgentStrategy(agent, os43 = createOsStrategy()) {
|
|
13465
13465
|
if (!AGENT_REGISTRY[agent]?.enabled) {
|
|
13466
13466
|
throw new Error(
|
|
13467
13467
|
`Agent "${agent}" is not supported in this codeam-cli version. Upgrade with 'npm i -g codeam-cli@latest'.`
|
|
@@ -13471,10 +13471,10 @@ function createAgentStrategy(agent, os42 = createOsStrategy()) {
|
|
|
13471
13471
|
if (!build) {
|
|
13472
13472
|
throw new Error(`No runtime strategy registered for agent "${agent}"`);
|
|
13473
13473
|
}
|
|
13474
|
-
return build(
|
|
13474
|
+
return build(os43);
|
|
13475
13475
|
}
|
|
13476
|
-
function createInteractiveAgentStrategy(agent,
|
|
13477
|
-
const s = createAgentStrategy(agent,
|
|
13476
|
+
function createInteractiveAgentStrategy(agent, os43 = createOsStrategy()) {
|
|
13477
|
+
const s = createAgentStrategy(agent, os43);
|
|
13478
13478
|
if (s.mode !== "interactive") {
|
|
13479
13479
|
throw new Error(
|
|
13480
13480
|
`Agent "${agent}" is a batch agent; use createAgentStrategy + .runOneShot for one-shot reviews.`
|
|
@@ -13984,13 +13984,16 @@ function saveHostIdentity(identity) {
|
|
|
13984
13984
|
});
|
|
13985
13985
|
fs27.chmodSync(file, 384);
|
|
13986
13986
|
}
|
|
13987
|
+
var TERMINAL_ENROLL_CODES = /* @__PURE__ */ new Set(["ENROLL_TOKEN_EXPIRED", "ENROLL_TOKEN_INVALID"]);
|
|
13987
13988
|
var HostHttpError = class extends Error {
|
|
13988
|
-
constructor(message, status2) {
|
|
13989
|
+
constructor(message, status2, code) {
|
|
13989
13990
|
super(message);
|
|
13990
13991
|
this.status = status2;
|
|
13992
|
+
this.code = code;
|
|
13991
13993
|
this.name = "HostHttpError";
|
|
13992
13994
|
}
|
|
13993
13995
|
status;
|
|
13996
|
+
code;
|
|
13994
13997
|
/**
|
|
13995
13998
|
* True iff this is a genuine auth-rejection of the host identity:
|
|
13996
13999
|
* 401 (token invalid), 403 (forbidden), 404 (host not found / deleted).
|
|
@@ -13999,10 +14002,25 @@ var HostHttpError = class extends Error {
|
|
|
13999
14002
|
get isAuthRejection() {
|
|
14000
14003
|
return this.status === 401 || this.status === 403 || this.status === 404;
|
|
14001
14004
|
}
|
|
14005
|
+
/**
|
|
14006
|
+
* True iff the enroll token is permanently unusable: the backend returned
|
|
14007
|
+
* a terminal 4xx (410 Gone for expired/replayed, 400 Bad Request for
|
|
14008
|
+
* malformed/invalid) with a stable `ENROLL_TOKEN_*` error code.
|
|
14009
|
+
*
|
|
14010
|
+
* These failures must NOT be retried — the token will never become valid
|
|
14011
|
+
* again. The host-agent must surface a clear message and exit so the user
|
|
14012
|
+
* knows to generate a new token in the app.
|
|
14013
|
+
*/
|
|
14014
|
+
get isTerminalEnrollError() {
|
|
14015
|
+
return typeof this.code === "string" && TERMINAL_ENROLL_CODES.has(this.code);
|
|
14016
|
+
}
|
|
14002
14017
|
};
|
|
14003
14018
|
function isHostAuthRejection(err) {
|
|
14004
14019
|
return err instanceof HostHttpError && err.isAuthRejection;
|
|
14005
14020
|
}
|
|
14021
|
+
function isTerminalEnrollError(err) {
|
|
14022
|
+
return err instanceof HostHttpError && err.isTerminalEnrollError;
|
|
14023
|
+
}
|
|
14006
14024
|
function deleteHostIdentity() {
|
|
14007
14025
|
try {
|
|
14008
14026
|
fs27.rmSync(hostIdentityPath(), { force: true });
|
|
@@ -14017,10 +14035,11 @@ async function postJson(pathname, body) {
|
|
|
14017
14035
|
});
|
|
14018
14036
|
const json = await res.json();
|
|
14019
14037
|
if (!res.ok || !json.success) {
|
|
14020
|
-
const
|
|
14038
|
+
const errBody = !json.success ? json.error : void 0;
|
|
14021
14039
|
throw new HostHttpError(
|
|
14022
|
-
`${pathname} failed (${
|
|
14023
|
-
res.status
|
|
14040
|
+
`${pathname} failed (${errBody?.code ?? `HTTP_${res.status}`}): ${errBody?.message ?? res.statusText}`,
|
|
14041
|
+
res.status,
|
|
14042
|
+
errBody?.code
|
|
14024
14043
|
);
|
|
14025
14044
|
}
|
|
14026
14045
|
return json.data;
|
|
@@ -14810,7 +14829,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
14810
14829
|
if (process.env.NODE_ENV === "test") return;
|
|
14811
14830
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
14812
14831
|
if (process.env.CI) return;
|
|
14813
|
-
const current = true ? "2.51.
|
|
14832
|
+
const current = true ? "2.51.3" : null;
|
|
14814
14833
|
if (!current) return;
|
|
14815
14834
|
const cache = readCache();
|
|
14816
14835
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -14827,7 +14846,7 @@ function checkForUpdates() {
|
|
|
14827
14846
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
14828
14847
|
if (process.env.CI) return;
|
|
14829
14848
|
if (!process.stdout.isTTY) return;
|
|
14830
|
-
const current = true ? "2.51.
|
|
14849
|
+
const current = true ? "2.51.3" : null;
|
|
14831
14850
|
if (!current) return;
|
|
14832
14851
|
const cache = readCache();
|
|
14833
14852
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -15529,7 +15548,7 @@ var defaultSpawner = (env, cwd, args2 = []) => (0, import_node_child_process15.s
|
|
|
15529
15548
|
detached: false
|
|
15530
15549
|
});
|
|
15531
15550
|
function currentCliVersion() {
|
|
15532
|
-
return true ? "2.51.
|
|
15551
|
+
return true ? "2.51.3" : null;
|
|
15533
15552
|
}
|
|
15534
15553
|
function runCmd(cmd, args2, timeoutMs) {
|
|
15535
15554
|
return new Promise((resolve7) => {
|
|
@@ -16193,6 +16212,12 @@ async function resolveHostIdentity(enrollToken) {
|
|
|
16193
16212
|
);
|
|
16194
16213
|
return identity;
|
|
16195
16214
|
} catch (err) {
|
|
16215
|
+
if (isTerminalEnrollError(err)) {
|
|
16216
|
+
throw new Error(
|
|
16217
|
+
"Enrollment token expired or invalid \u2014 generate a new one in the app (Settings \u203A Servers \u203A Add server). Tokens expire after 15 minutes and are single-use.",
|
|
16218
|
+
{ cause: err }
|
|
16219
|
+
);
|
|
16220
|
+
}
|
|
16196
16221
|
if (existing) {
|
|
16197
16222
|
log.trace(
|
|
16198
16223
|
"host-agent",
|
|
@@ -16258,8 +16283,158 @@ async function configureHeadroom(action, ctx, deps) {
|
|
|
16258
16283
|
return { enabled: false };
|
|
16259
16284
|
}
|
|
16260
16285
|
|
|
16261
|
-
// src/services/
|
|
16286
|
+
// src/services/headroom/budget-relaunch.ts
|
|
16287
|
+
var fs33 = __toESM(require("fs"));
|
|
16288
|
+
var os30 = __toESM(require("os"));
|
|
16289
|
+
var path37 = __toESM(require("path"));
|
|
16262
16290
|
var import_child_process12 = require("child_process");
|
|
16291
|
+
function amendDeploymentManifestBudget(manifest, budget) {
|
|
16292
|
+
const rawArgs = manifest.proxy_args ?? [];
|
|
16293
|
+
const strippedArgs = [];
|
|
16294
|
+
for (let i = 0; i < rawArgs.length; i++) {
|
|
16295
|
+
if (rawArgs[i] === "--budget" || rawArgs[i] === "--budget-period") {
|
|
16296
|
+
i++;
|
|
16297
|
+
continue;
|
|
16298
|
+
}
|
|
16299
|
+
strippedArgs.push(rawArgs[i]);
|
|
16300
|
+
}
|
|
16301
|
+
const rawEnv = manifest.base_env ?? {};
|
|
16302
|
+
const strippedEnv = { ...rawEnv };
|
|
16303
|
+
delete strippedEnv["HEADROOM_BUDGET"];
|
|
16304
|
+
delete strippedEnv["HEADROOM_BUDGET_PERIOD"];
|
|
16305
|
+
if (!budget) {
|
|
16306
|
+
return { ...manifest, proxy_args: strippedArgs, base_env: strippedEnv };
|
|
16307
|
+
}
|
|
16308
|
+
const newArgs = [
|
|
16309
|
+
...strippedArgs,
|
|
16310
|
+
"--budget",
|
|
16311
|
+
String(budget.budgetUsd),
|
|
16312
|
+
"--budget-period",
|
|
16313
|
+
budget.budgetPeriod
|
|
16314
|
+
];
|
|
16315
|
+
const newEnv = {
|
|
16316
|
+
...strippedEnv,
|
|
16317
|
+
HEADROOM_BUDGET: String(budget.budgetUsd),
|
|
16318
|
+
HEADROOM_BUDGET_PERIOD: budget.budgetPeriod
|
|
16319
|
+
};
|
|
16320
|
+
return { ...manifest, proxy_args: newArgs, base_env: newEnv };
|
|
16321
|
+
}
|
|
16322
|
+
function findHeadroomDeployments(homeDir2, deps) {
|
|
16323
|
+
const deployDir = path37.join(homeDir2, ".headroom", "deploy");
|
|
16324
|
+
let profiles;
|
|
16325
|
+
try {
|
|
16326
|
+
profiles = deps.readDir(deployDir);
|
|
16327
|
+
} catch {
|
|
16328
|
+
return [];
|
|
16329
|
+
}
|
|
16330
|
+
const results = [];
|
|
16331
|
+
for (const profile of profiles) {
|
|
16332
|
+
const manifestPath = path37.join(deployDir, profile, "manifest.json");
|
|
16333
|
+
let raw;
|
|
16334
|
+
try {
|
|
16335
|
+
raw = deps.readJson(manifestPath);
|
|
16336
|
+
} catch {
|
|
16337
|
+
continue;
|
|
16338
|
+
}
|
|
16339
|
+
if (!raw || typeof raw !== "object") continue;
|
|
16340
|
+
const manifest = raw;
|
|
16341
|
+
const port = typeof manifest.port === "number" ? manifest.port : 0;
|
|
16342
|
+
results.push({ profile, manifestPath, port, manifest });
|
|
16343
|
+
}
|
|
16344
|
+
return results;
|
|
16345
|
+
}
|
|
16346
|
+
async function applyBudgetToHeadroom(budget, deps) {
|
|
16347
|
+
const supervised = deps.findDeployments().filter((d3) => d3.port === 8787);
|
|
16348
|
+
if (supervised.length > 0) {
|
|
16349
|
+
log.info("headroom-budget", `supervised path \u2014 amending ${supervised.length} deployment(s)`);
|
|
16350
|
+
for (const d3 of supervised) {
|
|
16351
|
+
const amended = amendDeploymentManifestBudget(d3.manifest, budget);
|
|
16352
|
+
deps.writeManifest(d3.manifestPath, amended);
|
|
16353
|
+
deps.restartDeployment(d3.profile);
|
|
16354
|
+
}
|
|
16355
|
+
return { path: "supervised", profiles: supervised.map((d3) => d3.profile) };
|
|
16356
|
+
}
|
|
16357
|
+
log.info("headroom-budget", "direct path \u2014 kill + respawn proxy");
|
|
16358
|
+
deps.killProxy();
|
|
16359
|
+
deps.spawnProxy(budget);
|
|
16360
|
+
return { path: "direct" };
|
|
16361
|
+
}
|
|
16362
|
+
function writeManifestReal(manifestPath, manifest) {
|
|
16363
|
+
const tmp = manifestPath + ".codeam.tmp";
|
|
16364
|
+
fs33.writeFileSync(tmp, JSON.stringify(manifest, null, 2) + "\n", { mode: 384 });
|
|
16365
|
+
fs33.renameSync(tmp, manifestPath);
|
|
16366
|
+
}
|
|
16367
|
+
function restartDeploymentReal(profile) {
|
|
16368
|
+
try {
|
|
16369
|
+
const proc = (0, import_child_process12.spawn)("headroom", ["install", "restart", "--profile", profile], {
|
|
16370
|
+
detached: true,
|
|
16371
|
+
stdio: "ignore"
|
|
16372
|
+
});
|
|
16373
|
+
proc.once("error", (e) => {
|
|
16374
|
+
log.warn("headroom-budget", `restart deployment '${profile}' error (best-effort): ${e.message}`);
|
|
16375
|
+
});
|
|
16376
|
+
proc.unref();
|
|
16377
|
+
} catch (e) {
|
|
16378
|
+
log.warn(
|
|
16379
|
+
"headroom-budget",
|
|
16380
|
+
`restart deployment '${profile}' failed (best-effort): ${e instanceof Error ? e.message : String(e)}`
|
|
16381
|
+
);
|
|
16382
|
+
}
|
|
16383
|
+
}
|
|
16384
|
+
function killProxyReal() {
|
|
16385
|
+
try {
|
|
16386
|
+
const killer = (0, import_child_process12.spawn)("pkill", ["-TERM", "-f", "headroom.*proxy"], {
|
|
16387
|
+
detached: true,
|
|
16388
|
+
stdio: "ignore"
|
|
16389
|
+
});
|
|
16390
|
+
killer.once("error", () => {
|
|
16391
|
+
});
|
|
16392
|
+
killer.unref();
|
|
16393
|
+
} catch {
|
|
16394
|
+
}
|
|
16395
|
+
}
|
|
16396
|
+
function spawnProxyReal(budget) {
|
|
16397
|
+
try {
|
|
16398
|
+
const proxyEnv = {
|
|
16399
|
+
...process.env,
|
|
16400
|
+
HEADROOM_KOMPRESS_BACKEND: "onnx_cpu"
|
|
16401
|
+
};
|
|
16402
|
+
const proxy = (0, import_child_process12.spawn)(
|
|
16403
|
+
"headroom",
|
|
16404
|
+
["proxy", "--port", "8787", ...buildBudgetProxyArgs(proxyEnv)],
|
|
16405
|
+
{
|
|
16406
|
+
stdio: "ignore",
|
|
16407
|
+
detached: true,
|
|
16408
|
+
env: proxyEnv
|
|
16409
|
+
}
|
|
16410
|
+
);
|
|
16411
|
+
proxy.once("error", (e) => {
|
|
16412
|
+
log.warn("headroom-budget", `proxy relaunch error (best-effort): ${e.message}`);
|
|
16413
|
+
});
|
|
16414
|
+
proxy.unref();
|
|
16415
|
+
} catch (e) {
|
|
16416
|
+
log.warn(
|
|
16417
|
+
"headroom-budget",
|
|
16418
|
+
`proxy relaunch failed (best-effort): ${e instanceof Error ? e.message : String(e)}`
|
|
16419
|
+
);
|
|
16420
|
+
}
|
|
16421
|
+
}
|
|
16422
|
+
function makeRealApplyBudgetDeps() {
|
|
16423
|
+
const homeDir2 = os30.homedir();
|
|
16424
|
+
return {
|
|
16425
|
+
findDeployments: () => findHeadroomDeployments(homeDir2, {
|
|
16426
|
+
readDir: (dir) => fs33.readdirSync(dir),
|
|
16427
|
+
readJson: (filePath) => JSON.parse(fs33.readFileSync(filePath, "utf8"))
|
|
16428
|
+
}),
|
|
16429
|
+
writeManifest: writeManifestReal,
|
|
16430
|
+
restartDeployment: restartDeploymentReal,
|
|
16431
|
+
killProxy: killProxyReal,
|
|
16432
|
+
spawnProxy: spawnProxyReal
|
|
16433
|
+
};
|
|
16434
|
+
}
|
|
16435
|
+
|
|
16436
|
+
// src/services/preview/cloudflared.ts
|
|
16437
|
+
var import_child_process13 = require("child_process");
|
|
16263
16438
|
var import_fs = require("fs");
|
|
16264
16439
|
var import_promises = __toESM(require("fs/promises"));
|
|
16265
16440
|
var import_os6 = __toESM(require("os"));
|
|
@@ -16336,7 +16511,7 @@ async function isExecutableBinary(p2) {
|
|
|
16336
16511
|
}
|
|
16337
16512
|
function extractTgz(tgzPath, destDir) {
|
|
16338
16513
|
return new Promise((resolve7, reject) => {
|
|
16339
|
-
const child = (0,
|
|
16514
|
+
const child = (0, import_child_process13.spawn)("tar", ["-xzf", tgzPath, "-C", destDir], { stdio: "ignore" });
|
|
16340
16515
|
child.on("error", (err) => reject(err));
|
|
16341
16516
|
child.on(
|
|
16342
16517
|
"exit",
|
|
@@ -16370,7 +16545,7 @@ async function spawnNamedTunnel(bin, token, port) {
|
|
|
16370
16545
|
await import_promises.default.mkdir(credDir, { recursive: true });
|
|
16371
16546
|
const credFile = import_path4.default.join(credDir, `tunnel-${creds.TunnelID}.json`);
|
|
16372
16547
|
await import_promises.default.writeFile(credFile, JSON.stringify(creds), { mode: 384 });
|
|
16373
|
-
return (0,
|
|
16548
|
+
return (0, import_child_process13.spawn)(
|
|
16374
16549
|
bin,
|
|
16375
16550
|
[
|
|
16376
16551
|
"tunnel",
|
|
@@ -16386,9 +16561,9 @@ async function spawnNamedTunnel(bin, token, port) {
|
|
|
16386
16561
|
}
|
|
16387
16562
|
|
|
16388
16563
|
// src/services/preview/codespace.ts
|
|
16389
|
-
var
|
|
16564
|
+
var import_child_process14 = require("child_process");
|
|
16390
16565
|
var import_util3 = require("util");
|
|
16391
|
-
var execFileP5 = (0, import_util3.promisify)(
|
|
16566
|
+
var execFileP5 = (0, import_util3.promisify)(import_child_process14.execFile);
|
|
16392
16567
|
|
|
16393
16568
|
// src/services/preview/config-file.ts
|
|
16394
16569
|
var import_promises3 = __toESM(require("fs/promises"));
|
|
@@ -16583,10 +16758,10 @@ var import_fs2 = require("fs");
|
|
|
16583
16758
|
var import_path6 = __toESM(require("path"));
|
|
16584
16759
|
|
|
16585
16760
|
// src/services/preview/run-setup.ts
|
|
16586
|
-
var
|
|
16761
|
+
var import_child_process15 = require("child_process");
|
|
16587
16762
|
function runSetupCommand(cmd, args2, cwd, env, opts) {
|
|
16588
16763
|
return new Promise((resolve7) => {
|
|
16589
|
-
const child = (0,
|
|
16764
|
+
const child = (0, import_child_process15.spawn)(cmd, args2, {
|
|
16590
16765
|
cwd,
|
|
16591
16766
|
env: { ...process.env, ...env ?? {} },
|
|
16592
16767
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -16892,10 +17067,10 @@ function activePreviewSessionIds() {
|
|
|
16892
17067
|
}
|
|
16893
17068
|
|
|
16894
17069
|
// src/beads/bd-adapter.ts
|
|
16895
|
-
var
|
|
16896
|
-
var
|
|
16897
|
-
var
|
|
16898
|
-
var
|
|
17070
|
+
var import_child_process16 = require("child_process");
|
|
17071
|
+
var fs38 = __toESM(require("fs"));
|
|
17072
|
+
var os32 = __toESM(require("os"));
|
|
17073
|
+
var path42 = __toESM(require("path"));
|
|
16899
17074
|
var BD_PACKAGE = "@beads/bd";
|
|
16900
17075
|
function resolveBundledBdBinary() {
|
|
16901
17076
|
return _resolveSeam.resolveBundled();
|
|
@@ -16907,11 +17082,11 @@ function _defaultResolveBundled() {
|
|
|
16907
17082
|
} catch {
|
|
16908
17083
|
return null;
|
|
16909
17084
|
}
|
|
16910
|
-
const binDir =
|
|
17085
|
+
const binDir = path42.join(path42.dirname(pkgJsonPath), "bin");
|
|
16911
17086
|
const binaryName = process.platform === "win32" ? "bd.exe" : "bd";
|
|
16912
|
-
const binaryPath =
|
|
17087
|
+
const binaryPath = path42.join(binDir, binaryName);
|
|
16913
17088
|
try {
|
|
16914
|
-
|
|
17089
|
+
fs38.accessSync(binaryPath, fs38.constants.F_OK);
|
|
16915
17090
|
return binaryPath;
|
|
16916
17091
|
} catch {
|
|
16917
17092
|
return null;
|
|
@@ -16921,13 +17096,13 @@ function resolveBdOnPath() {
|
|
|
16921
17096
|
return _resolveSeam.resolveOnPath();
|
|
16922
17097
|
}
|
|
16923
17098
|
function _defaultResolveOnPath() {
|
|
16924
|
-
const dirs = (process.env.PATH ?? "").split(
|
|
17099
|
+
const dirs = (process.env.PATH ?? "").split(path42.delimiter).filter(Boolean);
|
|
16925
17100
|
const candidates = process.platform === "win32" ? ["bd.exe", "bd.cmd", "bd"] : ["bd"];
|
|
16926
17101
|
for (const dir of dirs) {
|
|
16927
17102
|
for (const candidate of candidates) {
|
|
16928
|
-
const full =
|
|
17103
|
+
const full = path42.join(dir, candidate);
|
|
16929
17104
|
try {
|
|
16930
|
-
|
|
17105
|
+
fs38.accessSync(full, fs38.constants.F_OK);
|
|
16931
17106
|
return full;
|
|
16932
17107
|
} catch {
|
|
16933
17108
|
}
|
|
@@ -16946,7 +17121,7 @@ function _defaultSpawn(binaryPath, args2, opts) {
|
|
|
16946
17121
|
return new Promise((resolve7) => {
|
|
16947
17122
|
let proc;
|
|
16948
17123
|
try {
|
|
16949
|
-
proc = (0,
|
|
17124
|
+
proc = (0, import_child_process16.spawn)(binaryPath, args2, { cwd: opts.cwd, env: opts.env });
|
|
16950
17125
|
} catch (err) {
|
|
16951
17126
|
resolve7({ code: -1, stdout: "", stderr: err.message });
|
|
16952
17127
|
return;
|
|
@@ -17012,7 +17187,7 @@ var BdAdapter = class {
|
|
|
17012
17187
|
const env = { ...process.env };
|
|
17013
17188
|
if (!env.HOME) {
|
|
17014
17189
|
try {
|
|
17015
|
-
const home =
|
|
17190
|
+
const home = os32.homedir();
|
|
17016
17191
|
if (home) env.HOME = home;
|
|
17017
17192
|
} catch {
|
|
17018
17193
|
}
|
|
@@ -17100,13 +17275,13 @@ function coerceIssue(row, projectKey) {
|
|
|
17100
17275
|
}
|
|
17101
17276
|
|
|
17102
17277
|
// src/beads/provisioner.ts
|
|
17103
|
-
var
|
|
17104
|
-
var
|
|
17105
|
-
var
|
|
17106
|
-
var
|
|
17278
|
+
var import_child_process20 = require("child_process");
|
|
17279
|
+
var fs41 = __toESM(require("fs"));
|
|
17280
|
+
var os34 = __toESM(require("os"));
|
|
17281
|
+
var path45 = __toESM(require("path"));
|
|
17107
17282
|
|
|
17108
17283
|
// src/beads/install-bd.ts
|
|
17109
|
-
var
|
|
17284
|
+
var import_child_process17 = require("child_process");
|
|
17110
17285
|
var INSTALL_SH_URL = "https://raw.githubusercontent.com/gastownhall/beads/main/scripts/install.sh";
|
|
17111
17286
|
var INSTALL_PS1_URL = "https://raw.githubusercontent.com/gastownhall/beads/main/install.ps1";
|
|
17112
17287
|
function resolveInstallStrategy(platform3) {
|
|
@@ -17137,7 +17312,7 @@ function _defaultInstallSpawn(strategy) {
|
|
|
17137
17312
|
return new Promise((resolve7) => {
|
|
17138
17313
|
let proc;
|
|
17139
17314
|
try {
|
|
17140
|
-
proc = (0,
|
|
17315
|
+
proc = (0, import_child_process17.spawn)(strategy.command, strategy.args, { env: process.env });
|
|
17141
17316
|
} catch (err) {
|
|
17142
17317
|
resolve7({ ok: false, code: -1, stderr: err.message });
|
|
17143
17318
|
return;
|
|
@@ -17167,10 +17342,10 @@ async function installBd(platform3 = process.platform) {
|
|
|
17167
17342
|
}
|
|
17168
17343
|
|
|
17169
17344
|
// src/beads/install-dolt.ts
|
|
17170
|
-
var
|
|
17171
|
-
var
|
|
17172
|
-
var
|
|
17173
|
-
var
|
|
17345
|
+
var import_child_process18 = require("child_process");
|
|
17346
|
+
var fs39 = __toESM(require("fs"));
|
|
17347
|
+
var os33 = __toESM(require("os"));
|
|
17348
|
+
var path43 = __toESM(require("path"));
|
|
17174
17349
|
var DOLT_INSTALL_SH_URL = "https://github.com/dolthub/dolt/releases/latest/download/install.sh";
|
|
17175
17350
|
var DOLT_MSI_URL = "https://github.com/dolthub/dolt/releases/latest/download/dolt-windows-amd64.msi";
|
|
17176
17351
|
function resolveDoltInstallStrategy(platform3) {
|
|
@@ -17210,11 +17385,11 @@ function resolveDoltInstallStrategy(platform3) {
|
|
|
17210
17385
|
}
|
|
17211
17386
|
var DOLT_RELEASE_BASE = "https://github.com/dolthub/dolt/releases/latest/download";
|
|
17212
17387
|
function doltPlatformTuple(platform3, arch2) {
|
|
17213
|
-
const
|
|
17388
|
+
const os43 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
|
|
17214
17389
|
const a = arch2 === "x64" ? "amd64" : arch2 === "arm64" ? "arm64" : null;
|
|
17215
17390
|
if (!a) return null;
|
|
17216
|
-
if (
|
|
17217
|
-
return `${
|
|
17391
|
+
if (os43 === "windows" && a !== "amd64") return null;
|
|
17392
|
+
return `${os43}-${a}`;
|
|
17218
17393
|
}
|
|
17219
17394
|
function resolveDoltTarballStrategy(targetDir, platform3, arch2) {
|
|
17220
17395
|
const tuple = doltPlatformTuple(platform3, arch2);
|
|
@@ -17259,14 +17434,14 @@ async function installDoltToDir(targetDir, platform3 = process.platform, arch2 =
|
|
|
17259
17434
|
return result;
|
|
17260
17435
|
}
|
|
17261
17436
|
var _doltPathSeam = {
|
|
17262
|
-
homedir: () =>
|
|
17437
|
+
homedir: () => os33.homedir(),
|
|
17263
17438
|
getPath: () => process.env.PATH ?? "",
|
|
17264
17439
|
setPath: (p2) => {
|
|
17265
17440
|
process.env.PATH = p2;
|
|
17266
17441
|
},
|
|
17267
17442
|
exists: (p2) => {
|
|
17268
17443
|
try {
|
|
17269
|
-
|
|
17444
|
+
fs39.accessSync(p2, fs39.constants.F_OK);
|
|
17270
17445
|
return true;
|
|
17271
17446
|
} catch {
|
|
17272
17447
|
return false;
|
|
@@ -17277,7 +17452,7 @@ function doltBinaryNames(platform3) {
|
|
|
17277
17452
|
return platform3 === "win32" ? ["dolt.exe", "dolt.cmd", "dolt"] : ["dolt"];
|
|
17278
17453
|
}
|
|
17279
17454
|
function knownDoltDirs(platform3) {
|
|
17280
|
-
const P3 = platform3 === "win32" ?
|
|
17455
|
+
const P3 = platform3 === "win32" ? path43.win32 : path43.posix;
|
|
17281
17456
|
const home = _doltPathSeam.homedir();
|
|
17282
17457
|
if (platform3 === "win32") {
|
|
17283
17458
|
return [
|
|
@@ -17293,7 +17468,7 @@ function knownDoltDirs(platform3) {
|
|
|
17293
17468
|
].filter(Boolean);
|
|
17294
17469
|
}
|
|
17295
17470
|
function ensureDoltResolvable(platform3 = process.platform) {
|
|
17296
|
-
const P3 = platform3 === "win32" ?
|
|
17471
|
+
const P3 = platform3 === "win32" ? path43.win32 : path43.posix;
|
|
17297
17472
|
const delim = platform3 === "win32" ? ";" : ":";
|
|
17298
17473
|
const names = doltBinaryNames(platform3);
|
|
17299
17474
|
const pathDirs = _doltPathSeam.getPath().split(delim).filter(Boolean);
|
|
@@ -17329,7 +17504,7 @@ function _defaultDoltInstallSpawn(strategy) {
|
|
|
17329
17504
|
};
|
|
17330
17505
|
let proc;
|
|
17331
17506
|
try {
|
|
17332
|
-
proc = (0,
|
|
17507
|
+
proc = (0, import_child_process18.spawn)(strategy.command, strategy.args, {
|
|
17333
17508
|
env: process.env,
|
|
17334
17509
|
stdio: ["ignore", "pipe", "pipe"]
|
|
17335
17510
|
});
|
|
@@ -17427,10 +17602,10 @@ async function ensureSharedServer(adapter, options = {}) {
|
|
|
17427
17602
|
}
|
|
17428
17603
|
|
|
17429
17604
|
// src/beads/project-key.ts
|
|
17430
|
-
var
|
|
17605
|
+
var import_child_process19 = require("child_process");
|
|
17431
17606
|
var crypto2 = __toESM(require("crypto"));
|
|
17432
|
-
var
|
|
17433
|
-
var
|
|
17607
|
+
var fs40 = __toESM(require("fs"));
|
|
17608
|
+
var path44 = __toESM(require("path"));
|
|
17434
17609
|
function normalizeOrigin(raw) {
|
|
17435
17610
|
const trimmed = raw.trim();
|
|
17436
17611
|
if (!trimmed) return null;
|
|
@@ -17456,17 +17631,17 @@ function normalizeOrigin(raw) {
|
|
|
17456
17631
|
return `${host2}/${pathPart}`;
|
|
17457
17632
|
}
|
|
17458
17633
|
function findRepoRoot(cwd) {
|
|
17459
|
-
let dir =
|
|
17634
|
+
let dir = path44.resolve(cwd);
|
|
17460
17635
|
const seen = /* @__PURE__ */ new Set();
|
|
17461
17636
|
for (let i = 0; i < 256; i++) {
|
|
17462
17637
|
if (seen.has(dir)) return null;
|
|
17463
17638
|
seen.add(dir);
|
|
17464
17639
|
try {
|
|
17465
|
-
const stat3 =
|
|
17640
|
+
const stat3 = fs40.statSync(path44.join(dir, ".git"), { throwIfNoEntry: false });
|
|
17466
17641
|
if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
|
|
17467
17642
|
} catch {
|
|
17468
17643
|
}
|
|
17469
|
-
const parent =
|
|
17644
|
+
const parent = path44.dirname(dir);
|
|
17470
17645
|
if (parent === dir) return null;
|
|
17471
17646
|
dir = parent;
|
|
17472
17647
|
}
|
|
@@ -17474,10 +17649,10 @@ function findRepoRoot(cwd) {
|
|
|
17474
17649
|
}
|
|
17475
17650
|
var _execSeam2 = {
|
|
17476
17651
|
exec: (file, args2, opts) => {
|
|
17477
|
-
const out2 = (0,
|
|
17652
|
+
const out2 = (0, import_child_process19.execFileSync)(file, args2, opts);
|
|
17478
17653
|
return typeof out2 === "string" ? out2 : out2.toString("utf8");
|
|
17479
17654
|
},
|
|
17480
|
-
realpath: (p2) =>
|
|
17655
|
+
realpath: (p2) => fs40.realpathSync(p2)
|
|
17481
17656
|
};
|
|
17482
17657
|
function readOrigin(cwd) {
|
|
17483
17658
|
try {
|
|
@@ -17506,7 +17681,7 @@ function deriveProjectIdentity(cwd = process.cwd()) {
|
|
|
17506
17681
|
} catch {
|
|
17507
17682
|
}
|
|
17508
17683
|
const hash = crypto2.createHash("sha256").update(real).digest("hex");
|
|
17509
|
-
return { projectKey: `path:${hash}`, projectLabel:
|
|
17684
|
+
return { projectKey: `path:${hash}`, projectLabel: path44.basename(real) || "project" };
|
|
17510
17685
|
}
|
|
17511
17686
|
|
|
17512
17687
|
// src/beads/project-prefix.ts
|
|
@@ -17548,17 +17723,17 @@ var _provisionSeam = {
|
|
|
17548
17723
|
};
|
|
17549
17724
|
var _linkSeam = {
|
|
17550
17725
|
platform: () => process.platform,
|
|
17551
|
-
homedir: () =>
|
|
17726
|
+
homedir: () => os34.homedir(),
|
|
17552
17727
|
isWritableDir: (dir) => {
|
|
17553
17728
|
try {
|
|
17554
|
-
|
|
17729
|
+
fs41.accessSync(dir, fs41.constants.W_OK);
|
|
17555
17730
|
return true;
|
|
17556
17731
|
} catch {
|
|
17557
17732
|
return false;
|
|
17558
17733
|
}
|
|
17559
17734
|
},
|
|
17560
17735
|
ensureDir: (dir) => {
|
|
17561
|
-
|
|
17736
|
+
fs41.mkdirSync(dir, { recursive: true });
|
|
17562
17737
|
},
|
|
17563
17738
|
/**
|
|
17564
17739
|
* A directory to symlink `bd` into so the AGENT's shell + Claude Code's
|
|
@@ -17579,9 +17754,9 @@ var _linkSeam = {
|
|
|
17579
17754
|
* which `linkBdOntoPath` creates if missing.
|
|
17580
17755
|
*/
|
|
17581
17756
|
cliBinDir: () => {
|
|
17582
|
-
const pathDirs = (process.env.PATH ?? "").split(
|
|
17757
|
+
const pathDirs = (process.env.PATH ?? "").split(path45.delimiter).filter(Boolean);
|
|
17583
17758
|
const home = _linkSeam.homedir();
|
|
17584
|
-
const localBin = home ?
|
|
17759
|
+
const localBin = home ? path45.join(home, ".local", "bin") : null;
|
|
17585
17760
|
if (localBin) {
|
|
17586
17761
|
try {
|
|
17587
17762
|
_linkSeam.ensureDir(localBin);
|
|
@@ -17591,16 +17766,16 @@ var _linkSeam = {
|
|
|
17591
17766
|
const candidates = [];
|
|
17592
17767
|
if (localBin) candidates.push(localBin);
|
|
17593
17768
|
try {
|
|
17594
|
-
candidates.push(
|
|
17769
|
+
candidates.push(path45.dirname(process.execPath));
|
|
17595
17770
|
} catch {
|
|
17596
17771
|
}
|
|
17597
17772
|
candidates.push("/usr/local/bin");
|
|
17598
17773
|
const entry = process.argv[1];
|
|
17599
17774
|
if (entry) {
|
|
17600
17775
|
try {
|
|
17601
|
-
candidates.push(
|
|
17776
|
+
candidates.push(path45.dirname(fs41.realpathSync(entry)));
|
|
17602
17777
|
} catch {
|
|
17603
|
-
candidates.push(
|
|
17778
|
+
candidates.push(path45.dirname(entry));
|
|
17604
17779
|
}
|
|
17605
17780
|
}
|
|
17606
17781
|
const onPathWritable = candidates.find(
|
|
@@ -17612,20 +17787,20 @@ var _linkSeam = {
|
|
|
17612
17787
|
/** Current symlink target at `linkPath`, or null when absent / not a link. */
|
|
17613
17788
|
readlink: (linkPath) => {
|
|
17614
17789
|
try {
|
|
17615
|
-
return
|
|
17790
|
+
return fs41.readlinkSync(linkPath);
|
|
17616
17791
|
} catch {
|
|
17617
17792
|
return null;
|
|
17618
17793
|
}
|
|
17619
17794
|
},
|
|
17620
|
-
unlink: (linkPath) =>
|
|
17621
|
-
symlink: (target, linkPath) =>
|
|
17795
|
+
unlink: (linkPath) => fs41.unlinkSync(linkPath),
|
|
17796
|
+
symlink: (target, linkPath) => fs41.symlinkSync(target, linkPath)
|
|
17622
17797
|
};
|
|
17623
17798
|
function linkBdOntoPath(binaryPath) {
|
|
17624
17799
|
if (_linkSeam.platform() === "win32") return;
|
|
17625
17800
|
const binDir = _linkSeam.cliBinDir();
|
|
17626
17801
|
if (!binDir) return;
|
|
17627
17802
|
_linkSeam.ensureDir(binDir);
|
|
17628
|
-
const linkPath =
|
|
17803
|
+
const linkPath = path45.join(binDir, "bd");
|
|
17629
17804
|
if (linkPath === binaryPath) return;
|
|
17630
17805
|
const current = _linkSeam.readlink(linkPath);
|
|
17631
17806
|
if (current === binaryPath) return;
|
|
@@ -17634,7 +17809,7 @@ function linkBdOntoPath(binaryPath) {
|
|
|
17634
17809
|
log.info("beads", `linked bd onto PATH: ${linkPath} -> ${binaryPath}`);
|
|
17635
17810
|
}
|
|
17636
17811
|
function setGitBeadsRole() {
|
|
17637
|
-
(0,
|
|
17812
|
+
(0, import_child_process20.execFileSync)("git", ["config", "--global", "beads.role", "contributor"], {
|
|
17638
17813
|
stdio: "ignore"
|
|
17639
17814
|
});
|
|
17640
17815
|
}
|
|
@@ -17820,7 +17995,7 @@ function dedupeRecipes(agents) {
|
|
|
17820
17995
|
|
|
17821
17996
|
// src/beads/watcher.ts
|
|
17822
17997
|
var crypto4 = __toESM(require("crypto"));
|
|
17823
|
-
var
|
|
17998
|
+
var path46 = __toESM(require("path"));
|
|
17824
17999
|
var API_BASE6 = resolveApiBaseUrl();
|
|
17825
18000
|
var DEBOUNCE_MS2 = 400;
|
|
17826
18001
|
var ZERO_SUMMARY = {
|
|
@@ -17844,7 +18019,7 @@ var BeadsWatcher = class {
|
|
|
17844
18019
|
constructor(opts) {
|
|
17845
18020
|
this.opts = opts;
|
|
17846
18021
|
this.bd = opts.adapter ?? new BdAdapter({ cwd: opts.cwd, beadsDir: opts.beadsDir });
|
|
17847
|
-
this.feedPath = opts.feedPath ??
|
|
18022
|
+
this.feedPath = opts.feedPath ?? path46.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
|
|
17848
18023
|
this.apiBase = opts.apiBaseUrl ?? API_BASE6;
|
|
17849
18024
|
}
|
|
17850
18025
|
opts;
|
|
@@ -18254,7 +18429,7 @@ var pendingAttachmentFiles = /* @__PURE__ */ new Set();
|
|
|
18254
18429
|
function cleanupAttachmentTempFiles() {
|
|
18255
18430
|
for (const p2 of pendingAttachmentFiles) {
|
|
18256
18431
|
try {
|
|
18257
|
-
|
|
18432
|
+
fs43.unlinkSync(p2);
|
|
18258
18433
|
} catch {
|
|
18259
18434
|
}
|
|
18260
18435
|
}
|
|
@@ -18263,8 +18438,8 @@ function cleanupAttachmentTempFiles() {
|
|
|
18263
18438
|
function saveFilesTemp(files) {
|
|
18264
18439
|
return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
|
|
18265
18440
|
const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
|
|
18266
|
-
const tmpPath =
|
|
18267
|
-
|
|
18441
|
+
const tmpPath = path48.join(os36.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
|
|
18442
|
+
fs43.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
|
|
18268
18443
|
pendingAttachmentFiles.add(tmpPath);
|
|
18269
18444
|
return tmpPath;
|
|
18270
18445
|
});
|
|
@@ -18284,7 +18459,7 @@ var startTask = (ctx, _cmd, parsed) => {
|
|
|
18284
18459
|
setTimeout(() => {
|
|
18285
18460
|
for (const p2 of paths) {
|
|
18286
18461
|
try {
|
|
18287
|
-
|
|
18462
|
+
fs43.unlinkSync(p2);
|
|
18288
18463
|
} catch {
|
|
18289
18464
|
}
|
|
18290
18465
|
pendingAttachmentFiles.delete(p2);
|
|
@@ -18409,7 +18584,7 @@ var sessionTerminated = async (ctx, cmd) => {
|
|
|
18409
18584
|
} catch {
|
|
18410
18585
|
}
|
|
18411
18586
|
try {
|
|
18412
|
-
const proc = (0,
|
|
18587
|
+
const proc = (0, import_child_process21.spawn)("bash", ["-lc", "pm2 delete codeam-pair >/dev/null 2>&1 || true"], {
|
|
18413
18588
|
detached: true,
|
|
18414
18589
|
stdio: "ignore"
|
|
18415
18590
|
});
|
|
@@ -18431,7 +18606,7 @@ var shutdownSession = async (ctx, cmd) => {
|
|
|
18431
18606
|
}
|
|
18432
18607
|
if (ctx.keepAliveCtx.inCodespace && ctx.keepAliveCtx.codespaceName) {
|
|
18433
18608
|
try {
|
|
18434
|
-
const stopProc = (0,
|
|
18609
|
+
const stopProc = (0, import_child_process21.spawn)(
|
|
18435
18610
|
"bash",
|
|
18436
18611
|
["-lc", `sleep 1; gh codespace stop -c ${JSON.stringify(ctx.keepAliveCtx.codespaceName)} >/dev/null 2>&1 || true`],
|
|
18437
18612
|
{ detached: true, stdio: "ignore" }
|
|
@@ -18441,7 +18616,7 @@ var shutdownSession = async (ctx, cmd) => {
|
|
|
18441
18616
|
}
|
|
18442
18617
|
}
|
|
18443
18618
|
try {
|
|
18444
|
-
const proc = (0,
|
|
18619
|
+
const proc = (0, import_child_process21.spawn)("bash", ["-lc", "pm2 delete codeam-pair >/dev/null 2>&1 || true"], {
|
|
18445
18620
|
detached: true,
|
|
18446
18621
|
stdio: "ignore"
|
|
18447
18622
|
});
|
|
@@ -18485,9 +18660,9 @@ var listFiles = async (ctx, cmd, parsed) => {
|
|
|
18485
18660
|
await ctx.relay.sendResult(cmd.id, "completed", result);
|
|
18486
18661
|
};
|
|
18487
18662
|
var envReadH = async (ctx, cmd) => {
|
|
18488
|
-
const envPath =
|
|
18663
|
+
const envPath = path48.join(process.cwd(), ".env");
|
|
18489
18664
|
try {
|
|
18490
|
-
const raw = await
|
|
18665
|
+
const raw = await fs43.promises.readFile(envPath, "utf8");
|
|
18491
18666
|
await ctx.relay.sendResult(cmd.id, "completed", {
|
|
18492
18667
|
exists: true,
|
|
18493
18668
|
vars: parseDotenv(raw)
|
|
@@ -18518,14 +18693,14 @@ var envWriteH = async (ctx, cmd, parsed) => {
|
|
|
18518
18693
|
}
|
|
18519
18694
|
seen.add(v.key);
|
|
18520
18695
|
}
|
|
18521
|
-
const envPath =
|
|
18522
|
-
const tmpPath =
|
|
18696
|
+
const envPath = path48.join(process.cwd(), ".env");
|
|
18697
|
+
const tmpPath = path48.join(process.cwd(), ".env.codeam.tmp");
|
|
18523
18698
|
try {
|
|
18524
|
-
await
|
|
18525
|
-
await
|
|
18699
|
+
await fs43.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
|
|
18700
|
+
await fs43.promises.rename(tmpPath, envPath);
|
|
18526
18701
|
await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
|
|
18527
18702
|
} catch (err) {
|
|
18528
|
-
await
|
|
18703
|
+
await fs43.promises.rm(tmpPath, { force: true }).catch(() => void 0);
|
|
18529
18704
|
await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
|
|
18530
18705
|
}
|
|
18531
18706
|
};
|
|
@@ -18543,7 +18718,7 @@ var headroomConfigureH = async (ctx, cmd, parsed) => {
|
|
|
18543
18718
|
let configuredAgent = rawAgentId;
|
|
18544
18719
|
if (!configuredAgent) {
|
|
18545
18720
|
try {
|
|
18546
|
-
const raw = JSON.parse(
|
|
18721
|
+
const raw = JSON.parse(fs43.readFileSync(headroomConfigPath(), "utf8"));
|
|
18547
18722
|
configuredAgent = raw.agent ?? "";
|
|
18548
18723
|
} catch {
|
|
18549
18724
|
}
|
|
@@ -18577,7 +18752,7 @@ var headroomConfigureH = async (ctx, cmd, parsed) => {
|
|
|
18577
18752
|
persist: persistHeadroomConfig,
|
|
18578
18753
|
readEnabled: () => {
|
|
18579
18754
|
try {
|
|
18580
|
-
const raw = JSON.parse(
|
|
18755
|
+
const raw = JSON.parse(fs43.readFileSync(headroomConfigPath(), "utf8"));
|
|
18581
18756
|
return raw.enabled === true;
|
|
18582
18757
|
} catch {
|
|
18583
18758
|
return false;
|
|
@@ -18629,7 +18804,7 @@ var headroomConfigureH = async (ctx, cmd, parsed) => {
|
|
|
18629
18804
|
restoreAgentHeadroomConfig: (kind) => restoreAgentHeadroomConfig(kind),
|
|
18630
18805
|
stopProxy: () => {
|
|
18631
18806
|
try {
|
|
18632
|
-
const p2 = (0,
|
|
18807
|
+
const p2 = (0, import_child_process21.spawn)("pkill", ["-TERM", "-f", "headroom.*proxy"], {
|
|
18633
18808
|
detached: true,
|
|
18634
18809
|
stdio: "ignore"
|
|
18635
18810
|
});
|
|
@@ -18671,7 +18846,7 @@ var headroomBudgetH = async (ctx, cmd) => {
|
|
|
18671
18846
|
}
|
|
18672
18847
|
let headroomActive = false;
|
|
18673
18848
|
try {
|
|
18674
|
-
const raw = JSON.parse(
|
|
18849
|
+
const raw = JSON.parse(fs43.readFileSync(headroomConfigPath(), "utf8"));
|
|
18675
18850
|
headroomActive = raw.enabled === true;
|
|
18676
18851
|
} catch {
|
|
18677
18852
|
}
|
|
@@ -18681,7 +18856,7 @@ var headroomBudgetH = async (ctx, cmd) => {
|
|
|
18681
18856
|
}
|
|
18682
18857
|
let existingConfig = { enabled: true };
|
|
18683
18858
|
try {
|
|
18684
|
-
existingConfig = JSON.parse(
|
|
18859
|
+
existingConfig = JSON.parse(fs43.readFileSync(headroomConfigPath(), "utf8"));
|
|
18685
18860
|
} catch {
|
|
18686
18861
|
}
|
|
18687
18862
|
if (payload.budgetEnabled && payload.budgetUsd != null) {
|
|
@@ -18705,37 +18880,11 @@ var headroomBudgetH = async (ctx, cmd) => {
|
|
|
18705
18880
|
delete process.env["HEADROOM_BUDGET"];
|
|
18706
18881
|
delete process.env["HEADROOM_BUDGET_PERIOD"];
|
|
18707
18882
|
}
|
|
18708
|
-
|
|
18709
|
-
|
|
18710
|
-
|
|
18711
|
-
|
|
18712
|
-
|
|
18713
|
-
killer.once("error", () => {
|
|
18714
|
-
});
|
|
18715
|
-
killer.unref();
|
|
18716
|
-
} catch {
|
|
18717
|
-
}
|
|
18718
|
-
try {
|
|
18719
|
-
const proxyEnv = { ...process.env, HEADROOM_KOMPRESS_BACKEND: "onnx_cpu" };
|
|
18720
|
-
const proxy = (0, import_child_process20.spawn)(
|
|
18721
|
-
"headroom",
|
|
18722
|
-
["proxy", "--port", "8787", ...buildBudgetProxyArgs(proxyEnv)],
|
|
18723
|
-
{
|
|
18724
|
-
stdio: "ignore",
|
|
18725
|
-
detached: true,
|
|
18726
|
-
env: proxyEnv
|
|
18727
|
-
}
|
|
18728
|
-
);
|
|
18729
|
-
proxy.once("error", (e) => {
|
|
18730
|
-
log.warn("headroom-budget", `proxy relaunch error (best-effort): ${e.message}`);
|
|
18731
|
-
});
|
|
18732
|
-
proxy.unref();
|
|
18733
|
-
} catch (e) {
|
|
18734
|
-
log.warn(
|
|
18735
|
-
"headroom-budget",
|
|
18736
|
-
`proxy relaunch failed (best-effort): ${e instanceof Error ? e.message : String(e)}`
|
|
18737
|
-
);
|
|
18738
|
-
}
|
|
18883
|
+
const budgetSpec = payload.budgetEnabled && payload.budgetUsd != null ? {
|
|
18884
|
+
budgetUsd: payload.budgetUsd,
|
|
18885
|
+
budgetPeriod: payload.budgetPeriod ?? "daily"
|
|
18886
|
+
} : null;
|
|
18887
|
+
await applyBudgetToHeadroom(budgetSpec, makeRealApplyBudgetDeps());
|
|
18739
18888
|
await ctx.relay.sendResult(cmd.id, "completed", { applied: true });
|
|
18740
18889
|
};
|
|
18741
18890
|
var _beadsEmitChain = Promise.resolve();
|
|
@@ -19233,8 +19382,8 @@ function normalizeDetectionForSpawn(detection, cwd) {
|
|
|
19233
19382
|
if (args2.length === 0) return detection;
|
|
19234
19383
|
const binName = args2[0];
|
|
19235
19384
|
if (binName.startsWith("-")) return detection;
|
|
19236
|
-
const binPath =
|
|
19237
|
-
if (!
|
|
19385
|
+
const binPath = path48.join(cwd, "node_modules", ".bin", binName);
|
|
19386
|
+
if (!fs43.existsSync(binPath)) return detection;
|
|
19238
19387
|
return {
|
|
19239
19388
|
...detection,
|
|
19240
19389
|
command: binPath,
|
|
@@ -19469,7 +19618,7 @@ function startPreviewFromDetection(ctx, detection, pluginAuthToken) {
|
|
|
19469
19618
|
"BOOT_SEQUENCE",
|
|
19470
19619
|
`${spawnable.command} ${spawnable.args.join(" ")}`
|
|
19471
19620
|
);
|
|
19472
|
-
const devServer = (0,
|
|
19621
|
+
const devServer = (0, import_child_process21.spawn)(spawnable.command, spawnable.args, {
|
|
19473
19622
|
cwd: process.cwd(),
|
|
19474
19623
|
env: { ...process.env, ...spawnable.env ?? {} },
|
|
19475
19624
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -19619,7 +19768,7 @@ function startPreviewFromDetection(ctx, detection, pluginAuthToken) {
|
|
|
19619
19768
|
`cloudflared quick tunnel (retry ${attempt}/${MAX_TUNNEL_ATTEMPTS})`
|
|
19620
19769
|
);
|
|
19621
19770
|
}
|
|
19622
|
-
const candidate = (0,
|
|
19771
|
+
const candidate = (0, import_child_process21.spawn)(
|
|
19623
19772
|
bin,
|
|
19624
19773
|
["tunnel", "--url", `http://localhost:${detection.port}`],
|
|
19625
19774
|
{ stdio: ["ignore", "pipe", "pipe"] }
|
|
@@ -19815,13 +19964,13 @@ async function dispatchCommand(ctx, cmd) {
|
|
|
19815
19964
|
}
|
|
19816
19965
|
|
|
19817
19966
|
// src/commands/start/keep-alive.ts
|
|
19818
|
-
var
|
|
19967
|
+
var import_child_process22 = require("child_process");
|
|
19819
19968
|
function buildKeepAlive(ctx) {
|
|
19820
19969
|
let timer = null;
|
|
19821
19970
|
async function setIdleTimeout(minutes) {
|
|
19822
19971
|
if (!ctx.inCodespace || !ctx.codespaceName) return;
|
|
19823
19972
|
await new Promise((resolve7) => {
|
|
19824
|
-
const proc = (0,
|
|
19973
|
+
const proc = (0, import_child_process22.spawn)(
|
|
19825
19974
|
"gh",
|
|
19826
19975
|
[
|
|
19827
19976
|
"api",
|
|
@@ -20052,12 +20201,12 @@ function readTokenFromArgs(args2) {
|
|
|
20052
20201
|
}
|
|
20053
20202
|
const fileFlag = args2.find((a) => a.startsWith("--token-file="));
|
|
20054
20203
|
if (fileFlag) {
|
|
20055
|
-
const
|
|
20204
|
+
const path62 = fileFlag.slice("--token-file=".length);
|
|
20056
20205
|
try {
|
|
20057
|
-
const content =
|
|
20058
|
-
if (content.length === 0) fail(`--token-file ${
|
|
20206
|
+
const content = fs44.readFileSync(path62, "utf8").trim();
|
|
20207
|
+
if (content.length === 0) fail(`--token-file ${path62} is empty`);
|
|
20059
20208
|
try {
|
|
20060
|
-
|
|
20209
|
+
fs44.unlinkSync(path62);
|
|
20061
20210
|
} catch {
|
|
20062
20211
|
}
|
|
20063
20212
|
return content;
|
|
@@ -20083,7 +20232,7 @@ async function claimOnce(token, pluginId, pluginSecretHash) {
|
|
|
20083
20232
|
pluginId,
|
|
20084
20233
|
ideName: "codeam-cli (codespace)",
|
|
20085
20234
|
ideVersion: process.env.npm_package_version ?? "unknown",
|
|
20086
|
-
hostname:
|
|
20235
|
+
hostname: os37.hostname(),
|
|
20087
20236
|
codespaceName: process.env.CODESPACE_NAME ?? "",
|
|
20088
20237
|
// Current git branch of the codespace's working directory, so the
|
|
20089
20238
|
// backend can populate `PairedSession.branch` for the codespace pair.
|
|
@@ -20144,7 +20293,7 @@ async function claim(token, pluginId, pluginSecretHash) {
|
|
|
20144
20293
|
}
|
|
20145
20294
|
}
|
|
20146
20295
|
function pairAutoLockPath() {
|
|
20147
|
-
return
|
|
20296
|
+
return path49.join(os37.homedir(), ".codeam", "pair-auto.lock");
|
|
20148
20297
|
}
|
|
20149
20298
|
function isLivePairAuto(pid) {
|
|
20150
20299
|
if (!Number.isInteger(pid) || pid <= 0 || pid === process.pid) return false;
|
|
@@ -20154,7 +20303,7 @@ function isLivePairAuto(pid) {
|
|
|
20154
20303
|
if (e.code !== "EPERM") return false;
|
|
20155
20304
|
}
|
|
20156
20305
|
try {
|
|
20157
|
-
return
|
|
20306
|
+
return fs44.readFileSync(`/proc/${pid}/cmdline`, "utf8").includes("codeam");
|
|
20158
20307
|
} catch {
|
|
20159
20308
|
return true;
|
|
20160
20309
|
}
|
|
@@ -20164,24 +20313,24 @@ function isLiveCodeam(pid) {
|
|
|
20164
20313
|
}
|
|
20165
20314
|
function daemonLockPath(sessionId) {
|
|
20166
20315
|
const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
20167
|
-
return
|
|
20316
|
+
return path49.join(os37.homedir(), ".codeam", `daemon-${safe}.lock`);
|
|
20168
20317
|
}
|
|
20169
20318
|
function acquireDaemonLock(sessionId) {
|
|
20170
20319
|
const lockPath = daemonLockPath(sessionId);
|
|
20171
20320
|
try {
|
|
20172
|
-
|
|
20321
|
+
fs44.mkdirSync(path49.dirname(lockPath), { recursive: true });
|
|
20173
20322
|
try {
|
|
20174
|
-
|
|
20323
|
+
fs44.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
|
|
20175
20324
|
} catch (e) {
|
|
20176
20325
|
if (e.code !== "EEXIST") throw e;
|
|
20177
|
-
const holder = Number(
|
|
20326
|
+
const holder = Number(fs44.readFileSync(lockPath, "utf8").trim());
|
|
20178
20327
|
if (holder && holder !== process.pid && isLiveCodeam(holder)) return false;
|
|
20179
|
-
|
|
20328
|
+
fs44.writeFileSync(lockPath, String(process.pid));
|
|
20180
20329
|
}
|
|
20181
20330
|
const release3 = () => {
|
|
20182
20331
|
try {
|
|
20183
|
-
if (
|
|
20184
|
-
|
|
20332
|
+
if (fs44.existsSync(lockPath) && Number(fs44.readFileSync(lockPath, "utf8").trim()) === process.pid) {
|
|
20333
|
+
fs44.unlinkSync(lockPath);
|
|
20185
20334
|
}
|
|
20186
20335
|
} catch {
|
|
20187
20336
|
}
|
|
@@ -20203,19 +20352,19 @@ function acquireDaemonLock(sessionId) {
|
|
|
20203
20352
|
function acquireSingletonLock() {
|
|
20204
20353
|
const lockPath = pairAutoLockPath();
|
|
20205
20354
|
try {
|
|
20206
|
-
|
|
20355
|
+
fs44.mkdirSync(path49.dirname(lockPath), { recursive: true });
|
|
20207
20356
|
try {
|
|
20208
|
-
|
|
20357
|
+
fs44.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
|
|
20209
20358
|
} catch (e) {
|
|
20210
20359
|
if (e.code !== "EEXIST") throw e;
|
|
20211
|
-
const holder = Number(
|
|
20360
|
+
const holder = Number(fs44.readFileSync(lockPath, "utf8").trim());
|
|
20212
20361
|
if (isLivePairAuto(holder)) return false;
|
|
20213
|
-
|
|
20362
|
+
fs44.writeFileSync(lockPath, String(process.pid));
|
|
20214
20363
|
}
|
|
20215
20364
|
process.once("exit", () => {
|
|
20216
20365
|
try {
|
|
20217
|
-
if (
|
|
20218
|
-
|
|
20366
|
+
if (fs44.existsSync(lockPath) && Number(fs44.readFileSync(lockPath, "utf8").trim()) === process.pid) {
|
|
20367
|
+
fs44.unlinkSync(lockPath);
|
|
20219
20368
|
}
|
|
20220
20369
|
} catch {
|
|
20221
20370
|
}
|
|
@@ -20660,19 +20809,19 @@ var AgentService = class _AgentService {
|
|
|
20660
20809
|
};
|
|
20661
20810
|
|
|
20662
20811
|
// src/agents/acp/adapters.ts
|
|
20663
|
-
var
|
|
20812
|
+
var path50 = __toESM(require("path"));
|
|
20664
20813
|
var require_ = require;
|
|
20665
20814
|
function resolveBin(pkgName, binName) {
|
|
20666
20815
|
try {
|
|
20667
20816
|
const manifestPath = require_.resolve(`${pkgName}/package.json`);
|
|
20668
20817
|
const manifest = require_(`${pkgName}/package.json`);
|
|
20669
|
-
const pkgDir =
|
|
20818
|
+
const pkgDir = path50.dirname(manifestPath);
|
|
20670
20819
|
const bin = manifest.bin;
|
|
20671
20820
|
if (!bin) return null;
|
|
20672
|
-
if (typeof bin === "string") return
|
|
20821
|
+
if (typeof bin === "string") return path50.resolve(pkgDir, bin);
|
|
20673
20822
|
const target = binName ?? Object.keys(bin)[0];
|
|
20674
20823
|
if (!target || !bin[target]) return null;
|
|
20675
|
-
return
|
|
20824
|
+
return path50.resolve(pkgDir, bin[target]);
|
|
20676
20825
|
} catch {
|
|
20677
20826
|
return null;
|
|
20678
20827
|
}
|
|
@@ -20742,9 +20891,9 @@ function requiresAcp(agent) {
|
|
|
20742
20891
|
var import_node_crypto7 = require("crypto");
|
|
20743
20892
|
|
|
20744
20893
|
// src/services/history.service.ts
|
|
20745
|
-
var
|
|
20746
|
-
var
|
|
20747
|
-
var
|
|
20894
|
+
var fs45 = __toESM(require("fs"));
|
|
20895
|
+
var path51 = __toESM(require("path"));
|
|
20896
|
+
var os38 = __toESM(require("os"));
|
|
20748
20897
|
var https7 = __toESM(require("https"));
|
|
20749
20898
|
var http6 = __toESM(require("http"));
|
|
20750
20899
|
var import_zod2 = require("zod");
|
|
@@ -20771,7 +20920,7 @@ function parseJsonl(filePath) {
|
|
|
20771
20920
|
const messages = [];
|
|
20772
20921
|
let raw;
|
|
20773
20922
|
try {
|
|
20774
|
-
raw =
|
|
20923
|
+
raw = fs45.readFileSync(filePath, "utf8");
|
|
20775
20924
|
} catch (err) {
|
|
20776
20925
|
if (err.code !== "ENOENT") {
|
|
20777
20926
|
log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
|
|
@@ -20912,7 +21061,7 @@ var HistoryService = class _HistoryService {
|
|
|
20912
21061
|
return this._quotaPercent === null || Date.now() - this._quotaFetchedAt > ttlMs;
|
|
20913
21062
|
}
|
|
20914
21063
|
get projectDir() {
|
|
20915
|
-
return this.runtime.resolveHistoryDir(this.cwd) ??
|
|
21064
|
+
return this.runtime.resolveHistoryDir(this.cwd) ?? path51.join(os38.homedir(), ".claude", "projects", encodeCwd(this.cwd));
|
|
20916
21065
|
}
|
|
20917
21066
|
/** Set the current Claude conversation ID (extracted from /cost command or session start) */
|
|
20918
21067
|
setCurrentConversationId(id) {
|
|
@@ -20924,7 +21073,7 @@ var HistoryService = class _HistoryService {
|
|
|
20924
21073
|
/** Return the current message count in the active conversation. */
|
|
20925
21074
|
getCurrentMessageCount() {
|
|
20926
21075
|
if (!this.currentConversationId) return 0;
|
|
20927
|
-
const filePath =
|
|
21076
|
+
const filePath = path51.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
20928
21077
|
return parseJsonl(filePath).length;
|
|
20929
21078
|
}
|
|
20930
21079
|
/**
|
|
@@ -20935,7 +21084,7 @@ var HistoryService = class _HistoryService {
|
|
|
20935
21084
|
const deadline = Date.now() + timeoutMs;
|
|
20936
21085
|
while (Date.now() < deadline) {
|
|
20937
21086
|
if (!this.currentConversationId) return null;
|
|
20938
|
-
const filePath =
|
|
21087
|
+
const filePath = path51.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
20939
21088
|
const messages = parseJsonl(filePath);
|
|
20940
21089
|
if (messages.length > previousCount) {
|
|
20941
21090
|
for (let i = messages.length - 1; i >= previousCount; i--) {
|
|
@@ -20961,16 +21110,16 @@ var HistoryService = class _HistoryService {
|
|
|
20961
21110
|
const dir = this.projectDir;
|
|
20962
21111
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
20963
21112
|
try {
|
|
20964
|
-
const files =
|
|
21113
|
+
const files = fs45.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
20965
21114
|
try {
|
|
20966
|
-
const stat3 =
|
|
21115
|
+
const stat3 = fs45.statSync(path51.join(dir, e.name));
|
|
20967
21116
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
20968
21117
|
} catch {
|
|
20969
21118
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
20970
21119
|
}
|
|
20971
21120
|
}).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
20972
21121
|
if (files.length > 0) {
|
|
20973
|
-
this.currentConversationId =
|
|
21122
|
+
this.currentConversationId = path51.basename(files[0].name, ".jsonl");
|
|
20974
21123
|
}
|
|
20975
21124
|
} catch {
|
|
20976
21125
|
}
|
|
@@ -21004,13 +21153,13 @@ var HistoryService = class _HistoryService {
|
|
|
21004
21153
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
21005
21154
|
let entries;
|
|
21006
21155
|
try {
|
|
21007
|
-
entries =
|
|
21156
|
+
entries = fs45.readdirSync(dir, { withFileTypes: true });
|
|
21008
21157
|
} catch {
|
|
21009
21158
|
return null;
|
|
21010
21159
|
}
|
|
21011
21160
|
const files = entries.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
21012
21161
|
try {
|
|
21013
|
-
const stat3 =
|
|
21162
|
+
const stat3 = fs45.statSync(path51.join(dir, e.name));
|
|
21014
21163
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
21015
21164
|
} catch {
|
|
21016
21165
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
@@ -21019,12 +21168,12 @@ var HistoryService = class _HistoryService {
|
|
|
21019
21168
|
if (files.length === 0) return null;
|
|
21020
21169
|
const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
|
|
21021
21170
|
if (!files.some((f) => f.name === targetFile)) return null;
|
|
21022
|
-
return this.extractUsageFromFile(
|
|
21171
|
+
return this.extractUsageFromFile(path51.join(dir, targetFile));
|
|
21023
21172
|
}
|
|
21024
21173
|
extractUsageFromFile(filePath) {
|
|
21025
21174
|
let raw;
|
|
21026
21175
|
try {
|
|
21027
|
-
raw =
|
|
21176
|
+
raw = fs45.readFileSync(filePath, "utf8");
|
|
21028
21177
|
} catch {
|
|
21029
21178
|
return null;
|
|
21030
21179
|
}
|
|
@@ -21069,9 +21218,9 @@ var HistoryService = class _HistoryService {
|
|
|
21069
21218
|
let totalCost = 0;
|
|
21070
21219
|
let files;
|
|
21071
21220
|
try {
|
|
21072
|
-
files =
|
|
21221
|
+
files = fs45.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
|
|
21073
21222
|
try {
|
|
21074
|
-
return
|
|
21223
|
+
return fs45.statSync(path51.join(projectDir, f)).mtimeMs >= monthStartMs;
|
|
21075
21224
|
} catch {
|
|
21076
21225
|
return false;
|
|
21077
21226
|
}
|
|
@@ -21082,7 +21231,7 @@ var HistoryService = class _HistoryService {
|
|
|
21082
21231
|
for (const file of files) {
|
|
21083
21232
|
let raw;
|
|
21084
21233
|
try {
|
|
21085
|
-
raw =
|
|
21234
|
+
raw = fs45.readFileSync(path51.join(projectDir, file), "utf8");
|
|
21086
21235
|
} catch {
|
|
21087
21236
|
continue;
|
|
21088
21237
|
}
|
|
@@ -21161,7 +21310,7 @@ var HistoryService = class _HistoryService {
|
|
|
21161
21310
|
if (this.runtime.resolveHistoryFile) {
|
|
21162
21311
|
return this.runtime.resolveHistoryFile(this.cwd, sessionId);
|
|
21163
21312
|
}
|
|
21164
|
-
return
|
|
21313
|
+
return path51.join(this.projectDir, `${sessionId}.jsonl`);
|
|
21165
21314
|
}
|
|
21166
21315
|
/**
|
|
21167
21316
|
* Parse a conversation's messages from disk, agent-aware. Claude uses the
|
|
@@ -21195,7 +21344,7 @@ var HistoryService = class _HistoryService {
|
|
|
21195
21344
|
};
|
|
21196
21345
|
});
|
|
21197
21346
|
}
|
|
21198
|
-
return parseJsonl(
|
|
21347
|
+
return parseJsonl(path51.join(this.projectDir, `${sessionId}.jsonl`));
|
|
21199
21348
|
}
|
|
21200
21349
|
async loadConversation(sessionId) {
|
|
21201
21350
|
const messages = this.readConversation(sessionId);
|
|
@@ -21251,7 +21400,7 @@ var HistoryService = class _HistoryService {
|
|
|
21251
21400
|
if (!filePath) return false;
|
|
21252
21401
|
let mtimeMs;
|
|
21253
21402
|
try {
|
|
21254
|
-
mtimeMs =
|
|
21403
|
+
mtimeMs = fs45.statSync(filePath).mtimeMs;
|
|
21255
21404
|
} catch {
|
|
21256
21405
|
return false;
|
|
21257
21406
|
}
|
|
@@ -21320,10 +21469,10 @@ var HistoryService = class _HistoryService {
|
|
|
21320
21469
|
|
|
21321
21470
|
// src/agents/acp/client.ts
|
|
21322
21471
|
var import_node_child_process17 = require("child_process");
|
|
21323
|
-
var
|
|
21472
|
+
var fs46 = __toESM(require("fs/promises"));
|
|
21324
21473
|
var fsSync = __toESM(require("fs"));
|
|
21325
|
-
var
|
|
21326
|
-
var
|
|
21474
|
+
var os39 = __toESM(require("os"));
|
|
21475
|
+
var path52 = __toESM(require("path"));
|
|
21327
21476
|
var import_node_stream = require("stream");
|
|
21328
21477
|
|
|
21329
21478
|
// ../../node_modules/@agentclientprotocol/sdk/dist/acp.js
|
|
@@ -24156,7 +24305,7 @@ var AcpClient = class {
|
|
|
24156
24305
|
},
|
|
24157
24306
|
readTextFile: async (params) => {
|
|
24158
24307
|
try {
|
|
24159
|
-
const content = await
|
|
24308
|
+
const content = await fs46.readFile(params.path, "utf8");
|
|
24160
24309
|
return applyLineRange(content, params.line ?? null, params.limit ?? null);
|
|
24161
24310
|
} catch (err) {
|
|
24162
24311
|
const code = err.code;
|
|
@@ -24176,7 +24325,7 @@ var AcpClient = class {
|
|
|
24176
24325
|
},
|
|
24177
24326
|
writeTextFile: async (params) => {
|
|
24178
24327
|
try {
|
|
24179
|
-
await
|
|
24328
|
+
await fs46.writeFile(params.path, params.content, "utf8");
|
|
24180
24329
|
return {};
|
|
24181
24330
|
} catch (err) {
|
|
24182
24331
|
const code = err.code;
|
|
@@ -24225,25 +24374,25 @@ function applyLineRange(content, line, limit) {
|
|
|
24225
24374
|
return { content: lines.slice(start2, end).join("\n") };
|
|
24226
24375
|
}
|
|
24227
24376
|
function knownAgentBinaryDirs() {
|
|
24228
|
-
const home =
|
|
24377
|
+
const home = os39.homedir();
|
|
24229
24378
|
const out2 = [];
|
|
24230
24379
|
out2.push("/tmp/codeam-node20/bin");
|
|
24231
24380
|
for (const root of [
|
|
24232
24381
|
"/usr/local/share/nvm/versions/node",
|
|
24233
|
-
|
|
24382
|
+
path52.join(home, ".nvm/versions/node")
|
|
24234
24383
|
]) {
|
|
24235
24384
|
try {
|
|
24236
24385
|
for (const child of fsSync.readdirSync(root)) {
|
|
24237
|
-
out2.push(
|
|
24386
|
+
out2.push(path52.join(root, child, "bin"));
|
|
24238
24387
|
}
|
|
24239
24388
|
} catch {
|
|
24240
24389
|
}
|
|
24241
24390
|
}
|
|
24242
|
-
out2.push(
|
|
24391
|
+
out2.push(path52.join(home, ".volta/bin"));
|
|
24243
24392
|
out2.push("/usr/local/bin");
|
|
24244
24393
|
out2.push("/usr/bin");
|
|
24245
|
-
out2.push(
|
|
24246
|
-
out2.push(
|
|
24394
|
+
out2.push(path52.join(home, ".local/bin"));
|
|
24395
|
+
out2.push(path52.join(home, "bin"));
|
|
24247
24396
|
return out2.filter((p2) => {
|
|
24248
24397
|
try {
|
|
24249
24398
|
return fsSync.statSync(p2).isDirectory();
|
|
@@ -24254,7 +24403,7 @@ function knownAgentBinaryDirs() {
|
|
|
24254
24403
|
}
|
|
24255
24404
|
function expandPathForAgentBinaries(existingPath) {
|
|
24256
24405
|
const existing = new Set(
|
|
24257
|
-
existingPath.split(
|
|
24406
|
+
existingPath.split(path52.delimiter).filter((p2) => p2.length > 0)
|
|
24258
24407
|
);
|
|
24259
24408
|
const additions = [];
|
|
24260
24409
|
for (const dir of knownAgentBinaryDirs()) {
|
|
@@ -24264,7 +24413,7 @@ function expandPathForAgentBinaries(existingPath) {
|
|
|
24264
24413
|
}
|
|
24265
24414
|
}
|
|
24266
24415
|
if (additions.length === 0) return existingPath;
|
|
24267
|
-
return [...additions, existingPath].filter((p2) => p2.length > 0).join(
|
|
24416
|
+
return [...additions, existingPath].filter((p2) => p2.length > 0).join(path52.delimiter);
|
|
24268
24417
|
}
|
|
24269
24418
|
|
|
24270
24419
|
// src/services/streaming/transport.ts
|
|
@@ -24748,16 +24897,16 @@ function commonPrefixLength(a, b) {
|
|
|
24748
24897
|
}
|
|
24749
24898
|
|
|
24750
24899
|
// src/agents/acp/onboarding.ts
|
|
24751
|
-
var
|
|
24752
|
-
var
|
|
24753
|
-
var
|
|
24754
|
-
var
|
|
24900
|
+
var import_child_process23 = require("child_process");
|
|
24901
|
+
var fs47 = __toESM(require("fs"));
|
|
24902
|
+
var os40 = __toESM(require("os"));
|
|
24903
|
+
var path53 = __toESM(require("path"));
|
|
24755
24904
|
var _onboardingSeam = {
|
|
24756
|
-
markerPath: (sessionId) =>
|
|
24757
|
-
exists: (p2) =>
|
|
24905
|
+
markerPath: (sessionId) => path53.join(os40.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
|
|
24906
|
+
exists: (p2) => fs47.existsSync(p2),
|
|
24758
24907
|
write: (p2) => {
|
|
24759
|
-
|
|
24760
|
-
|
|
24908
|
+
fs47.mkdirSync(path53.dirname(p2), { recursive: true });
|
|
24909
|
+
fs47.writeFileSync(p2, "");
|
|
24761
24910
|
},
|
|
24762
24911
|
disabled: () => {
|
|
24763
24912
|
const v = process.env.CODEAM_ONBOARDING_DISABLED;
|
|
@@ -24769,7 +24918,7 @@ var _onboardingSeam = {
|
|
|
24769
24918
|
*/
|
|
24770
24919
|
gitRemoteUrl: (cwd) => {
|
|
24771
24920
|
try {
|
|
24772
|
-
return (0,
|
|
24921
|
+
return (0, import_child_process23.execFileSync)("git", ["-C", cwd, "remote", "get-url", "origin"], {
|
|
24773
24922
|
encoding: "utf8",
|
|
24774
24923
|
stdio: ["ignore", "pipe", "ignore"],
|
|
24775
24924
|
timeout: 2e3
|
|
@@ -24794,7 +24943,7 @@ function resolveRepoName(cwd) {
|
|
|
24794
24943
|
if (name) return name;
|
|
24795
24944
|
}
|
|
24796
24945
|
}
|
|
24797
|
-
const base =
|
|
24946
|
+
const base = path53.basename(cwd || "");
|
|
24798
24947
|
if (base && !isUuid(base)) return base;
|
|
24799
24948
|
return "this project";
|
|
24800
24949
|
}
|
|
@@ -25086,9 +25235,9 @@ function deriveInputSuggestion(finalText) {
|
|
|
25086
25235
|
var import_crypto5 = require("crypto");
|
|
25087
25236
|
|
|
25088
25237
|
// src/services/turn-files/git-changeset.ts
|
|
25089
|
-
var
|
|
25090
|
-
var
|
|
25091
|
-
var
|
|
25238
|
+
var import_child_process24 = require("child_process");
|
|
25239
|
+
var fs48 = __toESM(require("fs/promises"));
|
|
25240
|
+
var path54 = __toESM(require("path"));
|
|
25092
25241
|
async function collectRepoChangeset(opts) {
|
|
25093
25242
|
const status2 = await runGit3(opts.repoRoot, ["status", "--porcelain=v1", "-z"]);
|
|
25094
25243
|
if (status2 === null) return null;
|
|
@@ -25106,7 +25255,7 @@ async function collectRepoChangeset(opts) {
|
|
|
25106
25255
|
let stats;
|
|
25107
25256
|
if (row.fileStatus === "added" && numstatEntry === void 0) {
|
|
25108
25257
|
const lineCount = await readUntrackedLineCount(
|
|
25109
|
-
|
|
25258
|
+
path54.join(opts.repoRoot, row.filePath)
|
|
25110
25259
|
);
|
|
25111
25260
|
stats = { added: lineCount, removed: 0 };
|
|
25112
25261
|
} else {
|
|
@@ -25137,7 +25286,7 @@ function readUntrackedLineCount(absPath) {
|
|
|
25137
25286
|
}
|
|
25138
25287
|
async function defaultReadUntrackedLineCount(absPath) {
|
|
25139
25288
|
try {
|
|
25140
|
-
const content = await
|
|
25289
|
+
const content = await fs48.readFile(absPath, "utf8");
|
|
25141
25290
|
let count = 0;
|
|
25142
25291
|
let pos = -1;
|
|
25143
25292
|
while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
|
|
@@ -25201,7 +25350,7 @@ function defaultRunGit(cwd, args2) {
|
|
|
25201
25350
|
return new Promise((resolve7) => {
|
|
25202
25351
|
let proc;
|
|
25203
25352
|
try {
|
|
25204
|
-
proc = (0,
|
|
25353
|
+
proc = (0, import_child_process24.spawn)("git", args2, { cwd, env: process.env });
|
|
25205
25354
|
} catch {
|
|
25206
25355
|
resolve7(null);
|
|
25207
25356
|
return;
|
|
@@ -25229,7 +25378,7 @@ function defaultRunGit(cwd, args2) {
|
|
|
25229
25378
|
});
|
|
25230
25379
|
}
|
|
25231
25380
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
25232
|
-
const
|
|
25381
|
+
const fs52 = await import("fs/promises");
|
|
25233
25382
|
const out2 = [];
|
|
25234
25383
|
await walk(workingDir, 0);
|
|
25235
25384
|
return out2;
|
|
@@ -25237,7 +25386,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
25237
25386
|
if (depth > maxDepth) return;
|
|
25238
25387
|
let entries = [];
|
|
25239
25388
|
try {
|
|
25240
|
-
const dirents = await
|
|
25389
|
+
const dirents = await fs52.readdir(dir, { withFileTypes: true });
|
|
25241
25390
|
entries = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
25242
25391
|
} catch {
|
|
25243
25392
|
return;
|
|
@@ -25248,8 +25397,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
25248
25397
|
if (hasGit) {
|
|
25249
25398
|
out2.push({
|
|
25250
25399
|
repoRoot: dir,
|
|
25251
|
-
repoPath:
|
|
25252
|
-
repoName:
|
|
25400
|
+
repoPath: path54.relative(workingDir, dir),
|
|
25401
|
+
repoName: path54.basename(dir)
|
|
25253
25402
|
});
|
|
25254
25403
|
return;
|
|
25255
25404
|
}
|
|
@@ -25257,14 +25406,14 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
25257
25406
|
if (!entry.isDirectory) continue;
|
|
25258
25407
|
if (entry.name === "node_modules") continue;
|
|
25259
25408
|
if (entry.name === "dist" || entry.name === "build") continue;
|
|
25260
|
-
await walk(
|
|
25409
|
+
await walk(path54.join(dir, entry.name), depth + 1);
|
|
25261
25410
|
}
|
|
25262
25411
|
}
|
|
25263
25412
|
}
|
|
25264
25413
|
|
|
25265
25414
|
// src/services/turn-files/files-outbox.ts
|
|
25266
|
-
var
|
|
25267
|
-
var
|
|
25415
|
+
var fs49 = __toESM(require("fs/promises"));
|
|
25416
|
+
var path55 = __toESM(require("path"));
|
|
25268
25417
|
var import_os7 = require("os");
|
|
25269
25418
|
var HOME_OUTBOX_DIR = ".codeam/outbox";
|
|
25270
25419
|
var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -25297,16 +25446,16 @@ var FilesOutbox = class {
|
|
|
25297
25446
|
backoffIndex = 0;
|
|
25298
25447
|
stopped = false;
|
|
25299
25448
|
constructor(opts) {
|
|
25300
|
-
const base = opts.baseDir ??
|
|
25301
|
-
this.filePath =
|
|
25449
|
+
const base = opts.baseDir ?? path55.join(homeDir(), HOME_OUTBOX_DIR);
|
|
25450
|
+
this.filePath = path55.join(base, `${opts.sessionId}.jsonl`);
|
|
25302
25451
|
this.post = opts.post;
|
|
25303
25452
|
this.autoSchedule = opts.autoSchedule !== false;
|
|
25304
25453
|
}
|
|
25305
25454
|
/** Persist the entry to disk and trigger a flush. Returns once the
|
|
25306
25455
|
* line is durable on disk (not once the POST succeeds). */
|
|
25307
25456
|
async enqueue(entry) {
|
|
25308
|
-
await
|
|
25309
|
-
await
|
|
25457
|
+
await fs49.mkdir(path55.dirname(this.filePath), { recursive: true });
|
|
25458
|
+
await fs49.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
|
|
25310
25459
|
this.backoffIndex = 0;
|
|
25311
25460
|
if (this.autoSchedule) this.scheduleFlush(0);
|
|
25312
25461
|
}
|
|
@@ -25395,7 +25544,7 @@ var FilesOutbox = class {
|
|
|
25395
25544
|
async readAll() {
|
|
25396
25545
|
let raw = "";
|
|
25397
25546
|
try {
|
|
25398
|
-
raw = await
|
|
25547
|
+
raw = await fs49.readFile(this.filePath, "utf8");
|
|
25399
25548
|
} catch {
|
|
25400
25549
|
return [];
|
|
25401
25550
|
}
|
|
@@ -25419,12 +25568,12 @@ var FilesOutbox = class {
|
|
|
25419
25568
|
async rewrite(entries) {
|
|
25420
25569
|
const tmpPath = `${this.filePath}.${process.pid}.tmp`;
|
|
25421
25570
|
if (entries.length === 0) {
|
|
25422
|
-
await
|
|
25571
|
+
await fs49.unlink(this.filePath).catch(() => void 0);
|
|
25423
25572
|
return;
|
|
25424
25573
|
}
|
|
25425
25574
|
const payload = entries.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
25426
|
-
await
|
|
25427
|
-
await
|
|
25575
|
+
await fs49.writeFile(tmpPath, payload, "utf8");
|
|
25576
|
+
await fs49.rename(tmpPath, this.filePath);
|
|
25428
25577
|
}
|
|
25429
25578
|
};
|
|
25430
25579
|
function applyJitter(ms) {
|
|
@@ -26401,9 +26550,9 @@ async function runAcpSession(opts) {
|
|
|
26401
26550
|
});
|
|
26402
26551
|
let _budgetReachedPosted = false;
|
|
26403
26552
|
const relaunchProxyWithoutBudget = async () => {
|
|
26404
|
-
const { spawn:
|
|
26553
|
+
const { spawn: spawn33 } = await import("child_process");
|
|
26405
26554
|
try {
|
|
26406
|
-
const killer =
|
|
26555
|
+
const killer = spawn33("pkill", ["-TERM", "-f", "headroom.*proxy"], {
|
|
26407
26556
|
detached: true,
|
|
26408
26557
|
stdio: "ignore"
|
|
26409
26558
|
});
|
|
@@ -26415,7 +26564,7 @@ async function runAcpSession(opts) {
|
|
|
26415
26564
|
await new Promise((r) => setTimeout(r, 500));
|
|
26416
26565
|
const proxyEnv = buildRelaunchProxyEnv(process.env);
|
|
26417
26566
|
try {
|
|
26418
|
-
const proxy =
|
|
26567
|
+
const proxy = spawn33(
|
|
26419
26568
|
"headroom",
|
|
26420
26569
|
["proxy", "--port", "8787"],
|
|
26421
26570
|
{ stdio: "ignore", detached: true, env: proxyEnv }
|
|
@@ -28053,15 +28202,15 @@ function fetchQuotaUsage(runtime, historySvc) {
|
|
|
28053
28202
|
}
|
|
28054
28203
|
|
|
28055
28204
|
// src/agents/claude/onboarding.ts
|
|
28056
|
-
var
|
|
28057
|
-
var
|
|
28058
|
-
var
|
|
28205
|
+
var fs50 = __toESM(require("fs"));
|
|
28206
|
+
var os41 = __toESM(require("os"));
|
|
28207
|
+
var path56 = __toESM(require("path"));
|
|
28059
28208
|
function ensureClaudeOnboarded() {
|
|
28060
28209
|
try {
|
|
28061
|
-
const file =
|
|
28210
|
+
const file = path56.join(os41.homedir(), ".claude.json");
|
|
28062
28211
|
let config = {};
|
|
28063
28212
|
try {
|
|
28064
|
-
config = JSON.parse(
|
|
28213
|
+
config = JSON.parse(fs50.readFileSync(file, "utf8"));
|
|
28065
28214
|
} catch {
|
|
28066
28215
|
}
|
|
28067
28216
|
if (config.hasCompletedOnboarding === true && typeof config.theme === "string") {
|
|
@@ -28072,8 +28221,8 @@ function ensureClaudeOnboarded() {
|
|
|
28072
28221
|
if (typeof config.lastOnboardingVersion !== "string") {
|
|
28073
28222
|
config.lastOnboardingVersion = "2.1.177";
|
|
28074
28223
|
}
|
|
28075
|
-
|
|
28076
|
-
|
|
28224
|
+
fs50.mkdirSync(path56.dirname(file), { recursive: true });
|
|
28225
|
+
fs50.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
28077
28226
|
log.info("claude", "pre-completed Claude onboarding (skip first-run theme picker)");
|
|
28078
28227
|
} catch (err) {
|
|
28079
28228
|
log.warn("claude", `ensureClaudeOnboarded failed (non-fatal): ${err.message}`);
|
|
@@ -28720,11 +28869,11 @@ async function logout() {
|
|
|
28720
28869
|
var import_picocolors11 = __toESM(require("picocolors"));
|
|
28721
28870
|
|
|
28722
28871
|
// src/services/providers/github-codespaces.ts
|
|
28723
|
-
var
|
|
28872
|
+
var import_child_process25 = require("child_process");
|
|
28724
28873
|
var import_util4 = require("util");
|
|
28725
28874
|
var import_picocolors9 = __toESM(require("picocolors"));
|
|
28726
|
-
var
|
|
28727
|
-
var execFileP6 = (0, import_util4.promisify)(
|
|
28875
|
+
var path57 = __toESM(require("path"));
|
|
28876
|
+
var execFileP6 = (0, import_util4.promisify)(import_child_process25.execFile);
|
|
28728
28877
|
var MAX_BUFFER = 8 * 1024 * 1024;
|
|
28729
28878
|
function resetStdinForChild() {
|
|
28730
28879
|
if (process.stdin.isTTY) {
|
|
@@ -28768,7 +28917,7 @@ var GitHubCodespacesProvider = class {
|
|
|
28768
28917
|
if (!isAuthed) {
|
|
28769
28918
|
resetStdinForChild();
|
|
28770
28919
|
await new Promise((resolve7, reject) => {
|
|
28771
|
-
const proc = (0,
|
|
28920
|
+
const proc = (0, import_child_process25.spawn)("gh", ["auth", "login", "-s", "codespace,repo,read:user"], {
|
|
28772
28921
|
stdio: "inherit"
|
|
28773
28922
|
});
|
|
28774
28923
|
proc.on("exit", (code) => {
|
|
@@ -28802,7 +28951,7 @@ var GitHubCodespacesProvider = class {
|
|
|
28802
28951
|
wt(noteLines.join("\n"), "One more permission needed");
|
|
28803
28952
|
resetStdinForChild();
|
|
28804
28953
|
const refreshCode = await new Promise((resolve7, reject) => {
|
|
28805
|
-
const proc = (0,
|
|
28954
|
+
const proc = (0, import_child_process25.spawn)(
|
|
28806
28955
|
"gh",
|
|
28807
28956
|
["auth", "refresh", "-h", "github.com", "-s", "codespace"],
|
|
28808
28957
|
{ stdio: "inherit" }
|
|
@@ -28952,7 +29101,7 @@ var GitHubCodespacesProvider = class {
|
|
|
28952
29101
|
O2.step(`Installing gh via ${installCmd.describe}\u2026`);
|
|
28953
29102
|
resetStdinForChild();
|
|
28954
29103
|
const ok = await new Promise((resolve7) => {
|
|
28955
|
-
const proc = (0,
|
|
29104
|
+
const proc = (0, import_child_process25.spawn)(installCmd.exe, installCmd.args, { stdio: "inherit" });
|
|
28956
29105
|
proc.on("exit", (code) => resolve7(code === 0));
|
|
28957
29106
|
proc.on("error", () => resolve7(false));
|
|
28958
29107
|
});
|
|
@@ -28979,7 +29128,7 @@ var GitHubCodespacesProvider = class {
|
|
|
28979
29128
|
);
|
|
28980
29129
|
resetStdinForChild();
|
|
28981
29130
|
await new Promise((resolve7, reject) => {
|
|
28982
|
-
const proc = (0,
|
|
29131
|
+
const proc = (0, import_child_process25.spawn)(
|
|
28983
29132
|
"gh",
|
|
28984
29133
|
["auth", "refresh", "-h", "github.com", "-s", "repo,read:org"],
|
|
28985
29134
|
{ stdio: "inherit" }
|
|
@@ -29157,7 +29306,7 @@ var GitHubCodespacesProvider = class {
|
|
|
29157
29306
|
async streamCommand(workspaceId, command2) {
|
|
29158
29307
|
resetStdinForChild();
|
|
29159
29308
|
return new Promise((resolve7, reject) => {
|
|
29160
|
-
const proc = (0,
|
|
29309
|
+
const proc = (0, import_child_process25.spawn)(
|
|
29161
29310
|
"gh",
|
|
29162
29311
|
["codespace", "ssh", "-c", workspaceId, "--", "-tt", command2],
|
|
29163
29312
|
{ stdio: "inherit" }
|
|
@@ -29184,11 +29333,11 @@ var GitHubCodespacesProvider = class {
|
|
|
29184
29333
|
`mkdir -p ${shellQuote(remoteDir)} && tar -xzf - -C ${shellQuote(remoteDir)}`
|
|
29185
29334
|
];
|
|
29186
29335
|
await new Promise((resolve7, reject) => {
|
|
29187
|
-
const tar = (0,
|
|
29336
|
+
const tar = (0, import_child_process25.spawn)("tar", tarArgs, {
|
|
29188
29337
|
stdio: ["ignore", "pipe", "pipe"],
|
|
29189
29338
|
env: tarEnv
|
|
29190
29339
|
});
|
|
29191
|
-
const ssh = (0,
|
|
29340
|
+
const ssh = (0, import_child_process25.spawn)("gh", sshArgs, {
|
|
29192
29341
|
stdio: [tar.stdout, "pipe", "pipe"]
|
|
29193
29342
|
});
|
|
29194
29343
|
let tarErr = "";
|
|
@@ -29212,7 +29361,7 @@ var GitHubCodespacesProvider = class {
|
|
|
29212
29361
|
});
|
|
29213
29362
|
}
|
|
29214
29363
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
29215
|
-
const remoteDir =
|
|
29364
|
+
const remoteDir = path57.posix.dirname(remotePath);
|
|
29216
29365
|
const parts = [
|
|
29217
29366
|
`mkdir -p ${shellQuote(remoteDir)}`,
|
|
29218
29367
|
`cat > ${shellQuote(remotePath)}`
|
|
@@ -29222,7 +29371,7 @@ var GitHubCodespacesProvider = class {
|
|
|
29222
29371
|
}
|
|
29223
29372
|
const cmd = parts.join(" && ");
|
|
29224
29373
|
await new Promise((resolve7, reject) => {
|
|
29225
|
-
const proc = (0,
|
|
29374
|
+
const proc = (0, import_child_process25.spawn)(
|
|
29226
29375
|
"gh",
|
|
29227
29376
|
["codespace", "ssh", "-c", workspaceId, "--", cmd],
|
|
29228
29377
|
{ stdio: ["pipe", "pipe", "pipe"] }
|
|
@@ -29280,11 +29429,11 @@ function shellQuote(s) {
|
|
|
29280
29429
|
}
|
|
29281
29430
|
|
|
29282
29431
|
// src/services/providers/gitpod.ts
|
|
29283
|
-
var
|
|
29432
|
+
var import_child_process26 = require("child_process");
|
|
29284
29433
|
var import_util5 = require("util");
|
|
29285
|
-
var
|
|
29434
|
+
var path58 = __toESM(require("path"));
|
|
29286
29435
|
var import_picocolors10 = __toESM(require("picocolors"));
|
|
29287
|
-
var execFileP7 = (0, import_util5.promisify)(
|
|
29436
|
+
var execFileP7 = (0, import_util5.promisify)(import_child_process26.execFile);
|
|
29288
29437
|
var MAX_BUFFER2 = 8 * 1024 * 1024;
|
|
29289
29438
|
function resetStdinForChild2() {
|
|
29290
29439
|
if (process.stdin.isTTY) {
|
|
@@ -29324,7 +29473,7 @@ var GitpodProvider = class {
|
|
|
29324
29473
|
);
|
|
29325
29474
|
resetStdinForChild2();
|
|
29326
29475
|
await new Promise((resolve7, reject) => {
|
|
29327
|
-
const proc = (0,
|
|
29476
|
+
const proc = (0, import_child_process26.spawn)("gitpod", ["login"], { stdio: "inherit" });
|
|
29328
29477
|
proc.on("exit", (code) => {
|
|
29329
29478
|
if (code === 0) resolve7();
|
|
29330
29479
|
else reject(new Error("gitpod login failed."));
|
|
@@ -29476,7 +29625,7 @@ var GitpodProvider = class {
|
|
|
29476
29625
|
async streamCommand(workspaceId, command2) {
|
|
29477
29626
|
resetStdinForChild2();
|
|
29478
29627
|
return new Promise((resolve7, reject) => {
|
|
29479
|
-
const proc = (0,
|
|
29628
|
+
const proc = (0, import_child_process26.spawn)(
|
|
29480
29629
|
"gitpod",
|
|
29481
29630
|
["workspace", "ssh", workspaceId, "--", "-tt", command2],
|
|
29482
29631
|
{ stdio: "inherit" }
|
|
@@ -29496,11 +29645,11 @@ var GitpodProvider = class {
|
|
|
29496
29645
|
const tarEnv = { ...process.env, COPYFILE_DISABLE: "1" };
|
|
29497
29646
|
const remoteCmd = `mkdir -p ${shellQuote2(remoteDir)} && tar -xzf - -C ${shellQuote2(remoteDir)}`;
|
|
29498
29647
|
await new Promise((resolve7, reject) => {
|
|
29499
|
-
const tar = (0,
|
|
29648
|
+
const tar = (0, import_child_process26.spawn)("tar", tarArgs, {
|
|
29500
29649
|
stdio: ["ignore", "pipe", "pipe"],
|
|
29501
29650
|
env: tarEnv
|
|
29502
29651
|
});
|
|
29503
|
-
const ssh = (0,
|
|
29652
|
+
const ssh = (0, import_child_process26.spawn)(
|
|
29504
29653
|
"gitpod",
|
|
29505
29654
|
["workspace", "ssh", workspaceId, "--", remoteCmd],
|
|
29506
29655
|
{ stdio: [tar.stdout, "pipe", "pipe"] }
|
|
@@ -29522,7 +29671,7 @@ var GitpodProvider = class {
|
|
|
29522
29671
|
});
|
|
29523
29672
|
}
|
|
29524
29673
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
29525
|
-
const remoteDir =
|
|
29674
|
+
const remoteDir = path58.posix.dirname(remotePath);
|
|
29526
29675
|
const parts = [
|
|
29527
29676
|
`mkdir -p ${shellQuote2(remoteDir)}`,
|
|
29528
29677
|
`cat > ${shellQuote2(remotePath)}`
|
|
@@ -29532,7 +29681,7 @@ var GitpodProvider = class {
|
|
|
29532
29681
|
}
|
|
29533
29682
|
const cmd = parts.join(" && ");
|
|
29534
29683
|
await new Promise((resolve7, reject) => {
|
|
29535
|
-
const proc = (0,
|
|
29684
|
+
const proc = (0, import_child_process26.spawn)(
|
|
29536
29685
|
"gitpod",
|
|
29537
29686
|
["workspace", "ssh", workspaceId, "--", cmd],
|
|
29538
29687
|
{ stdio: ["pipe", "pipe", "pipe"] }
|
|
@@ -29556,10 +29705,10 @@ function shellQuote2(s) {
|
|
|
29556
29705
|
}
|
|
29557
29706
|
|
|
29558
29707
|
// src/services/providers/gitlab-workspaces.ts
|
|
29559
|
-
var
|
|
29708
|
+
var import_child_process27 = require("child_process");
|
|
29560
29709
|
var import_util6 = require("util");
|
|
29561
|
-
var
|
|
29562
|
-
var execFileP8 = (0, import_util6.promisify)(
|
|
29710
|
+
var path59 = __toESM(require("path"));
|
|
29711
|
+
var execFileP8 = (0, import_util6.promisify)(import_child_process27.execFile);
|
|
29563
29712
|
var MAX_BUFFER3 = 8 * 1024 * 1024;
|
|
29564
29713
|
var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
|
|
29565
29714
|
function resetStdinForChild3() {
|
|
@@ -29601,7 +29750,7 @@ var GitLabWorkspacesProvider = class {
|
|
|
29601
29750
|
);
|
|
29602
29751
|
resetStdinForChild3();
|
|
29603
29752
|
await new Promise((resolve7, reject) => {
|
|
29604
|
-
const proc = (0,
|
|
29753
|
+
const proc = (0, import_child_process27.spawn)(
|
|
29605
29754
|
"glab",
|
|
29606
29755
|
["auth", "login", "--scopes", "api,read_user,read_repository"],
|
|
29607
29756
|
{ stdio: "inherit" }
|
|
@@ -29773,7 +29922,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
29773
29922
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
29774
29923
|
resetStdinForChild3();
|
|
29775
29924
|
return new Promise((resolve7, reject) => {
|
|
29776
|
-
const proc = (0,
|
|
29925
|
+
const proc = (0, import_child_process27.spawn)(
|
|
29777
29926
|
"ssh",
|
|
29778
29927
|
["-tt", "-o", "StrictHostKeyChecking=accept-new", `${workspaceId}@${sshHost}`, command2],
|
|
29779
29928
|
{ stdio: "inherit" }
|
|
@@ -29794,8 +29943,8 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
29794
29943
|
const tarEnv = { ...process.env, COPYFILE_DISABLE: "1" };
|
|
29795
29944
|
const remoteCmd = `mkdir -p ${shellQuote3(remoteDir)} && tar -xzf - -C ${shellQuote3(remoteDir)}`;
|
|
29796
29945
|
await new Promise((resolve7, reject) => {
|
|
29797
|
-
const tar = (0,
|
|
29798
|
-
const ssh = (0,
|
|
29946
|
+
const tar = (0, import_child_process27.spawn)("tar", tarArgs, { stdio: ["ignore", "pipe", "pipe"], env: tarEnv });
|
|
29947
|
+
const ssh = (0, import_child_process27.spawn)(
|
|
29799
29948
|
"ssh",
|
|
29800
29949
|
["-o", "StrictHostKeyChecking=accept-new", `${workspaceId}@${sshHost}`, remoteCmd],
|
|
29801
29950
|
{ stdio: [tar.stdout, "pipe", "pipe"] }
|
|
@@ -29818,14 +29967,14 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
29818
29967
|
}
|
|
29819
29968
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
29820
29969
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
29821
|
-
const remoteDir =
|
|
29970
|
+
const remoteDir = path59.posix.dirname(remotePath);
|
|
29822
29971
|
const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
|
|
29823
29972
|
if (options.mode != null) {
|
|
29824
29973
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
29825
29974
|
}
|
|
29826
29975
|
const cmd = parts.join(" && ");
|
|
29827
29976
|
await new Promise((resolve7, reject) => {
|
|
29828
|
-
const proc = (0,
|
|
29977
|
+
const proc = (0, import_child_process27.spawn)(
|
|
29829
29978
|
"ssh",
|
|
29830
29979
|
["-o", "StrictHostKeyChecking=accept-new", `${workspaceId}@${sshHost}`, cmd],
|
|
29831
29980
|
{ stdio: ["pipe", "pipe", "pipe"] }
|
|
@@ -29884,10 +30033,10 @@ function shellQuote3(s) {
|
|
|
29884
30033
|
}
|
|
29885
30034
|
|
|
29886
30035
|
// src/services/providers/railway.ts
|
|
29887
|
-
var
|
|
30036
|
+
var import_child_process28 = require("child_process");
|
|
29888
30037
|
var import_util7 = require("util");
|
|
29889
|
-
var
|
|
29890
|
-
var execFileP9 = (0, import_util7.promisify)(
|
|
30038
|
+
var path60 = __toESM(require("path"));
|
|
30039
|
+
var execFileP9 = (0, import_util7.promisify)(import_child_process28.execFile);
|
|
29891
30040
|
var MAX_BUFFER4 = 8 * 1024 * 1024;
|
|
29892
30041
|
function resetStdinForChild4() {
|
|
29893
30042
|
if (process.stdin.isTTY) {
|
|
@@ -29928,7 +30077,7 @@ var RailwayProvider = class {
|
|
|
29928
30077
|
);
|
|
29929
30078
|
resetStdinForChild4();
|
|
29930
30079
|
await new Promise((resolve7, reject) => {
|
|
29931
|
-
const proc = (0,
|
|
30080
|
+
const proc = (0, import_child_process28.spawn)("railway", ["login"], { stdio: "inherit" });
|
|
29932
30081
|
proc.on("exit", (code) => {
|
|
29933
30082
|
if (code === 0) resolve7();
|
|
29934
30083
|
else reject(new Error("railway login failed."));
|
|
@@ -30071,7 +30220,7 @@ var RailwayProvider = class {
|
|
|
30071
30220
|
}
|
|
30072
30221
|
resetStdinForChild4();
|
|
30073
30222
|
return new Promise((resolve7, reject) => {
|
|
30074
|
-
const proc = (0,
|
|
30223
|
+
const proc = (0, import_child_process28.spawn)(
|
|
30075
30224
|
"railway",
|
|
30076
30225
|
["shell", "--project", projectId, "--service", serviceId, "--command", command2],
|
|
30077
30226
|
{ stdio: "inherit" }
|
|
@@ -30095,8 +30244,8 @@ var RailwayProvider = class {
|
|
|
30095
30244
|
const tarEnv = { ...process.env, COPYFILE_DISABLE: "1" };
|
|
30096
30245
|
const remoteCmd = `mkdir -p ${shellQuote4(remoteDir)} && tar -xzf - -C ${shellQuote4(remoteDir)}`;
|
|
30097
30246
|
await new Promise((resolve7, reject) => {
|
|
30098
|
-
const tar = (0,
|
|
30099
|
-
const sh = (0,
|
|
30247
|
+
const tar = (0, import_child_process28.spawn)("tar", tarArgs, { stdio: ["ignore", "pipe", "pipe"], env: tarEnv });
|
|
30248
|
+
const sh = (0, import_child_process28.spawn)(
|
|
30100
30249
|
"railway",
|
|
30101
30250
|
["shell", "--project", projectId, "--service", serviceId, "--command", remoteCmd],
|
|
30102
30251
|
{ stdio: [tar.stdout, "pipe", "pipe"] }
|
|
@@ -30122,14 +30271,14 @@ var RailwayProvider = class {
|
|
|
30122
30271
|
if (!projectId || !serviceId) {
|
|
30123
30272
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
30124
30273
|
}
|
|
30125
|
-
const remoteDir =
|
|
30274
|
+
const remoteDir = path60.posix.dirname(remotePath);
|
|
30126
30275
|
const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
|
|
30127
30276
|
if (options.mode != null) {
|
|
30128
30277
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
30129
30278
|
}
|
|
30130
30279
|
const cmd = parts.join(" && ");
|
|
30131
30280
|
await new Promise((resolve7, reject) => {
|
|
30132
|
-
const proc = (0,
|
|
30281
|
+
const proc = (0, import_child_process28.spawn)(
|
|
30133
30282
|
"railway",
|
|
30134
30283
|
["shell", "--project", projectId, "--service", serviceId, "--command", cmd],
|
|
30135
30284
|
{ stdio: ["pipe", "pipe", "pipe"] }
|
|
@@ -30768,8 +30917,8 @@ async function invite() {
|
|
|
30768
30917
|
var import_node_dns = require("dns");
|
|
30769
30918
|
var import_node_util5 = require("util");
|
|
30770
30919
|
var import_node_crypto8 = require("crypto");
|
|
30771
|
-
var
|
|
30772
|
-
var
|
|
30920
|
+
var fs51 = __toESM(require("fs"));
|
|
30921
|
+
var path61 = __toESM(require("path"));
|
|
30773
30922
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
30774
30923
|
var dnsResolveP = (0, import_node_util5.promisify)(import_node_dns.resolve);
|
|
30775
30924
|
async function checkDns(apiBase2) {
|
|
@@ -30825,13 +30974,13 @@ async function checkHealth(apiBase2) {
|
|
|
30825
30974
|
}
|
|
30826
30975
|
}
|
|
30827
30976
|
function checkConfigDir() {
|
|
30828
|
-
const dir =
|
|
30977
|
+
const dir = path61.join(require("os").homedir(), ".codeam");
|
|
30829
30978
|
try {
|
|
30830
|
-
|
|
30831
|
-
const probe =
|
|
30832
|
-
|
|
30833
|
-
const read2 =
|
|
30834
|
-
|
|
30979
|
+
fs51.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
30980
|
+
const probe = path61.join(dir, ".doctor-probe");
|
|
30981
|
+
fs51.writeFileSync(probe, "ok", { mode: 384 });
|
|
30982
|
+
const read2 = fs51.readFileSync(probe, "utf8");
|
|
30983
|
+
fs51.unlinkSync(probe);
|
|
30835
30984
|
if (read2 !== "ok") throw new Error("write/read round-trip mismatch");
|
|
30836
30985
|
return {
|
|
30837
30986
|
id: "config-dir",
|
|
@@ -30871,9 +31020,9 @@ function checkSessions() {
|
|
|
30871
31020
|
}
|
|
30872
31021
|
}
|
|
30873
31022
|
function checkAgentBinaries() {
|
|
30874
|
-
const
|
|
31023
|
+
const os43 = createOsStrategy();
|
|
30875
31024
|
return getEnabledAgents().map((meta) => {
|
|
30876
|
-
const found =
|
|
31025
|
+
const found = os43.findInPath(meta.binaryName);
|
|
30877
31026
|
return {
|
|
30878
31027
|
id: `agent-${meta.id}`,
|
|
30879
31028
|
label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
|
|
@@ -30895,7 +31044,7 @@ function checkNodePty() {
|
|
|
30895
31044
|
detail: "not required on this platform"
|
|
30896
31045
|
};
|
|
30897
31046
|
}
|
|
30898
|
-
const vendoredPath =
|
|
31047
|
+
const vendoredPath = path61.join(__dirname, "vendor", "node-pty");
|
|
30899
31048
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
30900
31049
|
try {
|
|
30901
31050
|
require(target);
|
|
@@ -30937,7 +31086,7 @@ function checkChokidar() {
|
|
|
30937
31086
|
}
|
|
30938
31087
|
async function doctor(args2 = []) {
|
|
30939
31088
|
const json = args2.includes("--json");
|
|
30940
|
-
const cliVersion = true ? "2.51.
|
|
31089
|
+
const cliVersion = true ? "2.51.3" : "0.0.0-dev";
|
|
30941
31090
|
const apiBase2 = resolveApiBaseUrl();
|
|
30942
31091
|
const diagnosticId = (0, import_node_crypto8.randomUUID)();
|
|
30943
31092
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
@@ -31136,7 +31285,7 @@ async function completion(args2) {
|
|
|
31136
31285
|
// src/commands/version.ts
|
|
31137
31286
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
31138
31287
|
function version2() {
|
|
31139
|
-
const v = true ? "2.51.
|
|
31288
|
+
const v = true ? "2.51.3" : "unknown";
|
|
31140
31289
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
31141
31290
|
}
|
|
31142
31291
|
|
|
@@ -31285,10 +31434,10 @@ var EXIT_CODE_NAMES = {
|
|
|
31285
31434
|
};
|
|
31286
31435
|
|
|
31287
31436
|
// src/index.ts
|
|
31288
|
-
var
|
|
31437
|
+
var os42 = __toESM(require("os"));
|
|
31289
31438
|
if (!process.env.HOME) {
|
|
31290
31439
|
try {
|
|
31291
|
-
const home =
|
|
31440
|
+
const home = os42.homedir();
|
|
31292
31441
|
if (home) process.env.HOME = home;
|
|
31293
31442
|
} catch {
|
|
31294
31443
|
}
|