codeam-cli 2.76.12 → 2.76.13
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 +6 -0
- package/dist/index.js +736 -543
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -357,8 +357,8 @@ function defaultSpawn(timeoutMs) {
|
|
|
357
357
|
});
|
|
358
358
|
}
|
|
359
359
|
function resolveConvexBin(cwd) {
|
|
360
|
-
const local =
|
|
361
|
-
if (
|
|
360
|
+
const local = path112.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "convex.cmd" : "convex");
|
|
361
|
+
if (fs98.existsSync(local)) return { cmd: local, args: [] };
|
|
362
362
|
return { cmd: "npx", args: ["--yes", "convex"] };
|
|
363
363
|
}
|
|
364
364
|
function redact(text, key) {
|
|
@@ -489,13 +489,13 @@ async function runConvexAdminMcp(client3, id) {
|
|
|
489
489
|
});
|
|
490
490
|
await server.connect(new StdioServerTransport());
|
|
491
491
|
}
|
|
492
|
-
var import_node_child_process38,
|
|
492
|
+
var import_node_child_process38, fs98, path112, TOOLS;
|
|
493
493
|
var init_convex_admin_mcp = __esm({
|
|
494
494
|
"src/integrations/convex-admin-mcp.ts"() {
|
|
495
495
|
"use strict";
|
|
496
496
|
import_node_child_process38 = require("child_process");
|
|
497
|
-
|
|
498
|
-
|
|
497
|
+
fs98 = __toESM(require("fs"));
|
|
498
|
+
path112 = __toESM(require("path"));
|
|
499
499
|
TOOLS = [
|
|
500
500
|
{
|
|
501
501
|
name: "tables",
|
|
@@ -3595,11 +3595,11 @@ function quiet(fn) {
|
|
|
3595
3595
|
log.debug(TAG, "ignored sync error", err);
|
|
3596
3596
|
}
|
|
3597
3597
|
}
|
|
3598
|
-
function rmIfExistsQuiet(
|
|
3598
|
+
function rmIfExistsQuiet(path114) {
|
|
3599
3599
|
try {
|
|
3600
|
-
fs2.rmSync(
|
|
3600
|
+
fs2.rmSync(path114, { force: true });
|
|
3601
3601
|
} catch (err) {
|
|
3602
|
-
log.debug(TAG, `rmIfExists failed for ${
|
|
3602
|
+
log.debug(TAG, `rmIfExists failed for ${path114}`, err);
|
|
3603
3603
|
}
|
|
3604
3604
|
}
|
|
3605
3605
|
function killQuiet(target, signal = "SIGTERM") {
|
|
@@ -3765,9 +3765,9 @@ var _default = makeConfig();
|
|
|
3765
3765
|
var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, setSessionAgent, setSquadAuto, getSquadAuto, clearAll, saveCliConfig, loadCliConfig } = _default;
|
|
3766
3766
|
|
|
3767
3767
|
// src/commands/pair-auto.ts
|
|
3768
|
-
var
|
|
3769
|
-
var
|
|
3770
|
-
var
|
|
3768
|
+
var fs65 = __toESM(require("fs"));
|
|
3769
|
+
var os48 = __toESM(require("os"));
|
|
3770
|
+
var path74 = __toESM(require("path"));
|
|
3771
3771
|
var import_crypto4 = require("crypto");
|
|
3772
3772
|
|
|
3773
3773
|
// src/services/telemetry.service.ts
|
|
@@ -3803,8 +3803,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
|
|
|
3803
3803
|
return decodedFile;
|
|
3804
3804
|
};
|
|
3805
3805
|
}
|
|
3806
|
-
function normalizeWindowsPath(
|
|
3807
|
-
return
|
|
3806
|
+
function normalizeWindowsPath(path114) {
|
|
3807
|
+
return path114.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
3808
3808
|
}
|
|
3809
3809
|
|
|
3810
3810
|
// ../../node_modules/@posthog/core/dist/error-tracking/index.mjs
|
|
@@ -6537,13 +6537,13 @@ var PostHogCoreStateless = class {
|
|
|
6537
6537
|
sentFromRoute += batchMessages.length;
|
|
6538
6538
|
}
|
|
6539
6539
|
}
|
|
6540
|
-
async _sendOtlpBatch({ path:
|
|
6540
|
+
async _sendOtlpBatch({ path: path114, payload }) {
|
|
6541
6541
|
if (this.disabled) return {
|
|
6542
6542
|
kind: "fatal",
|
|
6543
6543
|
error: new Error("The client is disabled")
|
|
6544
6544
|
};
|
|
6545
6545
|
const serialized = JSON.stringify(payload);
|
|
6546
|
-
const url2 = `${this.host}/i/v1/${
|
|
6546
|
+
const url2 = `${this.host}/i/v1/${path114}?token=${encodeURIComponent(this.apiKey)}`;
|
|
6547
6547
|
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
|
|
6548
6548
|
const fetchOptions = {
|
|
6549
6549
|
method: "POST",
|
|
@@ -7783,14 +7783,14 @@ async function addSourceContext(frames, openSourceFile = import_promises.open, l
|
|
|
7783
7783
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
7784
7784
|
return frames;
|
|
7785
7785
|
}
|
|
7786
|
-
async function openRegularSourceFile(
|
|
7786
|
+
async function openRegularSourceFile(path114, openSourceFile, logger) {
|
|
7787
7787
|
let fileHandle;
|
|
7788
7788
|
let isValid = false;
|
|
7789
7789
|
try {
|
|
7790
|
-
fileHandle = await openSourceFile(
|
|
7790
|
+
fileHandle = await openSourceFile(path114, import_node_fs.constants.O_RDONLY | import_node_fs.constants.O_NONBLOCK);
|
|
7791
7791
|
const fileStat = await fileHandle.stat();
|
|
7792
7792
|
if (!fileStat.isFile()) return;
|
|
7793
|
-
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${
|
|
7793
|
+
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${path114}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
|
|
7794
7794
|
isValid = true;
|
|
7795
7795
|
return fileHandle;
|
|
7796
7796
|
} catch {
|
|
@@ -7800,8 +7800,8 @@ async function openRegularSourceFile(path112, openSourceFile, logger) {
|
|
|
7800
7800
|
});
|
|
7801
7801
|
}
|
|
7802
7802
|
}
|
|
7803
|
-
async function getContextLinesFromFile(
|
|
7804
|
-
const fileHandle = await openRegularSourceFile(
|
|
7803
|
+
async function getContextLinesFromFile(path114, ranges, output, cacheKey, openSourceFile, logger) {
|
|
7804
|
+
const fileHandle = await openRegularSourceFile(path114, openSourceFile, logger);
|
|
7805
7805
|
if (void 0 === fileHandle) return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
7806
7806
|
const openedFileHandle = fileHandle;
|
|
7807
7807
|
return new Promise((resolve14) => {
|
|
@@ -7903,22 +7903,22 @@ function clearLineContext(frame) {
|
|
|
7903
7903
|
delete frame.context_line;
|
|
7904
7904
|
delete frame.post_context;
|
|
7905
7905
|
}
|
|
7906
|
-
function shouldSkipContextLinesForFile(
|
|
7907
|
-
return
|
|
7906
|
+
function shouldSkipContextLinesForFile(path114) {
|
|
7907
|
+
return path114.startsWith("node:") || path114.endsWith(".min.js") || path114.endsWith(".min.cjs") || path114.endsWith(".min.mjs") || path114.startsWith("data:");
|
|
7908
7908
|
}
|
|
7909
7909
|
function shouldSkipContextLinesForFrame(frame) {
|
|
7910
7910
|
if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
|
|
7911
7911
|
if (void 0 !== frame.colno && frame.colno > MAX_CONTEXTLINES_COLNO) return true;
|
|
7912
7912
|
return false;
|
|
7913
7913
|
}
|
|
7914
|
-
function makeSourceCacheKey(
|
|
7915
|
-
if ((0, import_node_path.isAbsolute)(
|
|
7914
|
+
function makeSourceCacheKey(path114, basePath) {
|
|
7915
|
+
if ((0, import_node_path.isAbsolute)(path114)) return JSON.stringify([
|
|
7916
7916
|
null,
|
|
7917
|
-
|
|
7917
|
+
path114
|
|
7918
7918
|
]);
|
|
7919
7919
|
return void 0 === basePath ? void 0 : JSON.stringify([
|
|
7920
7920
|
basePath,
|
|
7921
|
-
|
|
7921
|
+
path114
|
|
7922
7922
|
]);
|
|
7923
7923
|
}
|
|
7924
7924
|
function rangeExistsInContentCache(cacheKey, range) {
|
|
@@ -10579,7 +10579,7 @@ function readAnonId() {
|
|
|
10579
10579
|
}
|
|
10580
10580
|
function superProperties() {
|
|
10581
10581
|
return {
|
|
10582
|
-
cliVersion: true ? "2.76.
|
|
10582
|
+
cliVersion: true ? "2.76.13" : "0.0.0-dev",
|
|
10583
10583
|
nodeVersion: process.version,
|
|
10584
10584
|
platform: process.platform,
|
|
10585
10585
|
arch: process.arch,
|
|
@@ -10824,7 +10824,7 @@ var http = __toESM(require("http"));
|
|
|
10824
10824
|
// package.json
|
|
10825
10825
|
var package_default = {
|
|
10826
10826
|
name: "codeam-cli",
|
|
10827
|
-
version: "2.76.
|
|
10827
|
+
version: "2.76.13",
|
|
10828
10828
|
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.",
|
|
10829
10829
|
type: "commonjs",
|
|
10830
10830
|
main: "dist/index.js",
|
|
@@ -12160,7 +12160,7 @@ var CommandRelayService = class _CommandRelayService {
|
|
|
12160
12160
|
// fresh + clear the "CLI update available" banner after a self-update
|
|
12161
12161
|
// (a codespace that reinstalls @latest reconnects via heartbeat, not
|
|
12162
12162
|
// pair/reconnect). Older backends ignore the extra field.
|
|
12163
|
-
..."2.76.
|
|
12163
|
+
..."2.76.13" ? { ideVersion: "2.76.13" } : {}
|
|
12164
12164
|
};
|
|
12165
12165
|
try {
|
|
12166
12166
|
const res = await _postJson(`${API_BASE2}/api/plugin/heartbeat`, body);
|
|
@@ -13636,9 +13636,9 @@ function closeAllTerminals() {
|
|
|
13636
13636
|
}
|
|
13637
13637
|
|
|
13638
13638
|
// src/commands/start/handlers.ts
|
|
13639
|
-
var
|
|
13640
|
-
var
|
|
13641
|
-
var
|
|
13639
|
+
var fs64 = __toESM(require("fs"));
|
|
13640
|
+
var os47 = __toESM(require("os"));
|
|
13641
|
+
var path73 = __toESM(require("path"));
|
|
13642
13642
|
var import_crypto3 = require("crypto");
|
|
13643
13643
|
var import_child_process25 = require("child_process");
|
|
13644
13644
|
|
|
@@ -17237,10 +17237,10 @@ function buildForPlatform(platform3) {
|
|
|
17237
17237
|
var import_node_crypto5 = require("crypto");
|
|
17238
17238
|
|
|
17239
17239
|
// src/agents/claude/resolver.ts
|
|
17240
|
-
function buildClaudeLaunch(extraArgs = [],
|
|
17241
|
-
const found =
|
|
17240
|
+
function buildClaudeLaunch(extraArgs = [], os74 = createOsStrategy()) {
|
|
17241
|
+
const found = os74.findInPath("claude") ?? os74.findInPath("claude-code");
|
|
17242
17242
|
if (!found) return null;
|
|
17243
|
-
return
|
|
17243
|
+
return os74.buildLaunch(found, extraArgs);
|
|
17244
17244
|
}
|
|
17245
17245
|
|
|
17246
17246
|
// src/agents/claude/installer.ts
|
|
@@ -18066,8 +18066,8 @@ var ClaudeRuntimeStrategy = class {
|
|
|
18066
18066
|
meta = getAgent("claude");
|
|
18067
18067
|
mode = "interactive";
|
|
18068
18068
|
os;
|
|
18069
|
-
constructor(
|
|
18070
|
-
this.os =
|
|
18069
|
+
constructor(os74) {
|
|
18070
|
+
this.os = os74;
|
|
18071
18071
|
}
|
|
18072
18072
|
/**
|
|
18073
18073
|
* Claude Code's react-ink TUI enables bracketed-paste mode at
|
|
@@ -19167,8 +19167,8 @@ function codexCredentialLocator() {
|
|
|
19167
19167
|
function codexLoginLauncher() {
|
|
19168
19168
|
return {
|
|
19169
19169
|
async ensureInstalled() {
|
|
19170
|
-
const
|
|
19171
|
-
return
|
|
19170
|
+
const os74 = createOsStrategy();
|
|
19171
|
+
return os74.findInPath("codex") !== null;
|
|
19172
19172
|
},
|
|
19173
19173
|
launch() {
|
|
19174
19174
|
return (0, import_node_child_process3.spawn)("codex", ["login"], { stdio: "inherit" });
|
|
@@ -19191,8 +19191,8 @@ var CodexRuntimeStrategy = class {
|
|
|
19191
19191
|
meta = getAgent("codex");
|
|
19192
19192
|
mode = "interactive";
|
|
19193
19193
|
os;
|
|
19194
|
-
constructor(
|
|
19195
|
-
this.os =
|
|
19194
|
+
constructor(os74) {
|
|
19195
|
+
this.os = os74;
|
|
19196
19196
|
}
|
|
19197
19197
|
async prepareLaunch() {
|
|
19198
19198
|
let binary = this.os.findInPath("codex");
|
|
@@ -19303,12 +19303,12 @@ var CodexRuntimeStrategy = class {
|
|
|
19303
19303
|
});
|
|
19304
19304
|
}
|
|
19305
19305
|
};
|
|
19306
|
-
function resolveNpm(
|
|
19307
|
-
return
|
|
19306
|
+
function resolveNpm(os74) {
|
|
19307
|
+
return os74.id === "win32" ? "npm.cmd" : "npm";
|
|
19308
19308
|
}
|
|
19309
|
-
async function installCodexViaNpm(
|
|
19309
|
+
async function installCodexViaNpm(os74) {
|
|
19310
19310
|
return new Promise((resolve14, reject) => {
|
|
19311
|
-
const proc = (0, import_node_child_process4.spawn)(resolveNpm(
|
|
19311
|
+
const proc = (0, import_node_child_process4.spawn)(resolveNpm(os74), ["install", "-g", "@openai/codex"], {
|
|
19312
19312
|
stdio: "inherit"
|
|
19313
19313
|
});
|
|
19314
19314
|
proc.on("close", (code) => {
|
|
@@ -19325,16 +19325,16 @@ async function installCodexViaNpm(os72) {
|
|
|
19325
19325
|
});
|
|
19326
19326
|
});
|
|
19327
19327
|
}
|
|
19328
|
-
function augmentNpmGlobalBin(
|
|
19328
|
+
function augmentNpmGlobalBin(os74) {
|
|
19329
19329
|
try {
|
|
19330
|
-
const result = (0, import_node_child_process4.spawnSync)(resolveNpm(
|
|
19330
|
+
const result = (0, import_node_child_process4.spawnSync)(resolveNpm(os74), ["prefix", "-g"], {
|
|
19331
19331
|
stdio: ["ignore", "pipe", "ignore"]
|
|
19332
19332
|
});
|
|
19333
19333
|
if (result.status !== 0) return;
|
|
19334
19334
|
const prefix = result.stdout.toString().trim();
|
|
19335
19335
|
if (!prefix) return;
|
|
19336
|
-
const binDir =
|
|
19337
|
-
|
|
19336
|
+
const binDir = os74.id === "win32" ? prefix : path26.join(prefix, "bin");
|
|
19337
|
+
os74.augmentPath([binDir]);
|
|
19338
19338
|
} catch {
|
|
19339
19339
|
}
|
|
19340
19340
|
}
|
|
@@ -19528,10 +19528,10 @@ function manualInstallHint(runner, tools) {
|
|
|
19528
19528
|
const argv = osPackageInstallArgv(detectPackageManager(runner), [...tools]);
|
|
19529
19529
|
return argv ? `\`sudo ${argv.join(" ")}\`` : `your package manager (e.g. \`${pkgs}\`)`;
|
|
19530
19530
|
}
|
|
19531
|
-
function writeUnzipShim(
|
|
19531
|
+
function writeUnzipShim(os74, runner) {
|
|
19532
19532
|
const python = ["python3", "python"].find((p2) => runner.which(p2));
|
|
19533
19533
|
if (!python) return null;
|
|
19534
|
-
const dir =
|
|
19534
|
+
const dir = os74.scratchPath("codeam-cr-prereq");
|
|
19535
19535
|
const shim = path28.join(dir, "unzip");
|
|
19536
19536
|
const script = `#!/bin/sh
|
|
19537
19537
|
set -e
|
|
@@ -19553,9 +19553,9 @@ exec ${python} -m zipfile -e "$archive" "$dest"
|
|
|
19553
19553
|
(0, import_node_fs6.chmodSync)(shim, 448);
|
|
19554
19554
|
return dir;
|
|
19555
19555
|
}
|
|
19556
|
-
async function ensureInstallPrerequisites(
|
|
19556
|
+
async function ensureInstallPrerequisites(os74, deps = {}) {
|
|
19557
19557
|
const runner = deps.runner ?? defaultOsRunner;
|
|
19558
|
-
const missing = REQUIRED_TOOLS.filter((t2) =>
|
|
19558
|
+
const missing = REQUIRED_TOOLS.filter((t2) => os74.findInPath(t2) === null);
|
|
19559
19559
|
if (missing.length === 0) return { ok: true, extraPath: [] };
|
|
19560
19560
|
log.info(
|
|
19561
19561
|
"coderabbit",
|
|
@@ -19574,10 +19574,10 @@ async function ensureInstallPrerequisites(os72, deps = {}) {
|
|
|
19574
19574
|
);
|
|
19575
19575
|
}
|
|
19576
19576
|
}
|
|
19577
|
-
const stillMissing = REQUIRED_TOOLS.filter((t2) =>
|
|
19577
|
+
const stillMissing = REQUIRED_TOOLS.filter((t2) => os74.findInPath(t2) === null);
|
|
19578
19578
|
if (stillMissing.length === 0) return { ok: true, extraPath: [] };
|
|
19579
19579
|
if (stillMissing.length === 1 && stillMissing[0] === "unzip") {
|
|
19580
|
-
const shimDir = writeUnzipShim(
|
|
19580
|
+
const shimDir = writeUnzipShim(os74, runner);
|
|
19581
19581
|
if (shimDir) {
|
|
19582
19582
|
log.info("coderabbit", "unzip is unavailable \u2014 using a scoped python zipfile shim");
|
|
19583
19583
|
return { ok: true, extraPath: [shimDir] };
|
|
@@ -19640,15 +19640,15 @@ function summarizeInstallFailure(output) {
|
|
|
19640
19640
|
}
|
|
19641
19641
|
return lines.length > 0 ? lines[lines.length - 1] : null;
|
|
19642
19642
|
}
|
|
19643
|
-
async function ensureCoderabbitInstalled(
|
|
19644
|
-
if (
|
|
19645
|
-
if (
|
|
19643
|
+
async function ensureCoderabbitInstalled(os74, deps = {}) {
|
|
19644
|
+
if (os74.findInPath("coderabbit")) return { ok: true };
|
|
19645
|
+
if (os74.id === "win32") {
|
|
19646
19646
|
return {
|
|
19647
19647
|
ok: false,
|
|
19648
19648
|
error: "CodeRabbit on Windows requires WSL. Install the CLI inside your WSL distribution (curl -fsSL https://cli.coderabbit.ai/install.sh | sh), then try again."
|
|
19649
19649
|
};
|
|
19650
19650
|
}
|
|
19651
|
-
const prereq = await ensureInstallPrerequisites(
|
|
19651
|
+
const prereq = await ensureInstallPrerequisites(os74, deps);
|
|
19652
19652
|
if (!prereq.ok) return { ok: false, error: prereq.error };
|
|
19653
19653
|
const env = { ...process.env };
|
|
19654
19654
|
if (prereq.extraPath.length > 0) {
|
|
@@ -19657,8 +19657,8 @@ async function ensureCoderabbitInstalled(os72, deps = {}) {
|
|
|
19657
19657
|
log.info("coderabbit", "CodeRabbit CLI not found \u2014 installing via the official script");
|
|
19658
19658
|
const run3 = deps.runInstallScript ?? defaultRunInstallScript;
|
|
19659
19659
|
const { code, output } = await run3(env);
|
|
19660
|
-
|
|
19661
|
-
const binary =
|
|
19660
|
+
os74.augmentPath([`${os74.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
|
|
19661
|
+
const binary = os74.findInPath("coderabbit");
|
|
19662
19662
|
const detail = summarizeInstallFailure(output);
|
|
19663
19663
|
if (binary !== null) {
|
|
19664
19664
|
if (code === 0) return { ok: true };
|
|
@@ -19712,10 +19712,10 @@ function coderabbitCredentialLocator() {
|
|
|
19712
19712
|
validate: validateNonEmptyCredential
|
|
19713
19713
|
};
|
|
19714
19714
|
}
|
|
19715
|
-
function coderabbitLoginLauncher(
|
|
19715
|
+
function coderabbitLoginLauncher(os74) {
|
|
19716
19716
|
return {
|
|
19717
19717
|
async ensureInstalled() {
|
|
19718
|
-
const result = await ensureCoderabbitInstalled(
|
|
19718
|
+
const result = await ensureCoderabbitInstalled(os74);
|
|
19719
19719
|
if (!result.ok && result.error) console.error(`
|
|
19720
19720
|
\u2717 ${result.error}
|
|
19721
19721
|
`);
|
|
@@ -19775,8 +19775,8 @@ function pickLine(obj) {
|
|
|
19775
19775
|
function toHunk(raw, groupSeverity) {
|
|
19776
19776
|
if (!raw || typeof raw !== "object") return null;
|
|
19777
19777
|
const o = raw;
|
|
19778
|
-
const
|
|
19779
|
-
if (!
|
|
19778
|
+
const path114 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
|
|
19779
|
+
if (!path114) return null;
|
|
19780
19780
|
const message = asString(
|
|
19781
19781
|
pick(o, [
|
|
19782
19782
|
"comment",
|
|
@@ -19793,7 +19793,7 @@ function toHunk(raw, groupSeverity) {
|
|
|
19793
19793
|
const severity = normSeverity(pick(o, ["severity", "level", "priority", "impact"])) ?? normSeverity(groupSeverity);
|
|
19794
19794
|
const locObj = pick(o, ["location"]) ?? o;
|
|
19795
19795
|
return {
|
|
19796
|
-
path:
|
|
19796
|
+
path: path114.trim(),
|
|
19797
19797
|
line: pickLine(o) ?? pickLine(locObj),
|
|
19798
19798
|
severity,
|
|
19799
19799
|
message: (title && message ? `${title}: ${message}` : title || message).trim() || "(no message)"
|
|
@@ -19876,10 +19876,10 @@ function parsePlain(stdout) {
|
|
|
19876
19876
|
for (const line of stdout.split(/\r?\n/)) {
|
|
19877
19877
|
const m = line.match(HUNK_LINE_RE);
|
|
19878
19878
|
if (!m) continue;
|
|
19879
|
-
const [,
|
|
19880
|
-
if (!
|
|
19879
|
+
const [, path114, lineNo, sevToken, message] = m;
|
|
19880
|
+
if (!path114 || !lineNo || !message) continue;
|
|
19881
19881
|
hunks.push({
|
|
19882
|
-
path:
|
|
19882
|
+
path: path114.trim(),
|
|
19883
19883
|
line: Number(lineNo),
|
|
19884
19884
|
severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
|
|
19885
19885
|
message: message.trim().replace(/^[*-]\s+/, "")
|
|
@@ -19939,8 +19939,8 @@ var CoderabbitRuntimeStrategy = class {
|
|
|
19939
19939
|
meta = getAgent("coderabbit");
|
|
19940
19940
|
mode = "batch";
|
|
19941
19941
|
os;
|
|
19942
|
-
constructor(
|
|
19943
|
-
this.os =
|
|
19942
|
+
constructor(os74) {
|
|
19943
|
+
this.os = os74;
|
|
19944
19944
|
}
|
|
19945
19945
|
getDefaultArgs() {
|
|
19946
19946
|
return ["review", "--agent"];
|
|
@@ -20211,10 +20211,10 @@ function cursorCredentialLocator() {
|
|
|
20211
20211
|
validate: validateNonEmptyCredential
|
|
20212
20212
|
};
|
|
20213
20213
|
}
|
|
20214
|
-
function cursorLoginLauncher(
|
|
20214
|
+
function cursorLoginLauncher(os74) {
|
|
20215
20215
|
return {
|
|
20216
20216
|
async ensureInstalled() {
|
|
20217
|
-
if (
|
|
20217
|
+
if (os74.findInPath("cursor-agent")) return true;
|
|
20218
20218
|
console.error(
|
|
20219
20219
|
"\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"
|
|
20220
20220
|
);
|
|
@@ -20278,8 +20278,8 @@ var CursorRuntimeStrategy = class {
|
|
|
20278
20278
|
meta = getAgent("cursor");
|
|
20279
20279
|
mode = "interactive";
|
|
20280
20280
|
os;
|
|
20281
|
-
constructor(
|
|
20282
|
-
this.os =
|
|
20281
|
+
constructor(os74) {
|
|
20282
|
+
this.os = os74;
|
|
20283
20283
|
}
|
|
20284
20284
|
async prepareLaunch() {
|
|
20285
20285
|
const binary = this.os.findInPath("cursor-agent");
|
|
@@ -20497,10 +20497,10 @@ function aiderCredentialLocator() {
|
|
|
20497
20497
|
validate: validateNonEmptyCredential
|
|
20498
20498
|
};
|
|
20499
20499
|
}
|
|
20500
|
-
function aiderLoginLauncher(
|
|
20500
|
+
function aiderLoginLauncher(os74) {
|
|
20501
20501
|
return {
|
|
20502
20502
|
async ensureInstalled() {
|
|
20503
|
-
if (
|
|
20503
|
+
if (os74.findInPath("aider")) return true;
|
|
20504
20504
|
console.error(
|
|
20505
20505
|
"\n \u2717 aider binary not on PATH.\n Install Aider:\n pip install aider-chat\n then re-run `codeam link aider`.\n"
|
|
20506
20506
|
);
|
|
@@ -20510,7 +20510,7 @@ function aiderLoginLauncher(os72) {
|
|
|
20510
20510
|
console.error(
|
|
20511
20511
|
"\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"
|
|
20512
20512
|
);
|
|
20513
|
-
return (0, import_node_child_process11.spawn)(
|
|
20513
|
+
return (0, import_node_child_process11.spawn)(os74.id === "win32" ? "cmd.exe" : "sh", os74.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
|
|
20514
20514
|
stdio: "ignore"
|
|
20515
20515
|
});
|
|
20516
20516
|
}
|
|
@@ -20629,6 +20629,15 @@ async function waitForClaudeNativeBinary(opts = {}) {
|
|
|
20629
20629
|
}
|
|
20630
20630
|
return resolveClaudeNativeBinary(deps);
|
|
20631
20631
|
}
|
|
20632
|
+
function prefetchIntoPageCache(file, deps = {}) {
|
|
20633
|
+
const createReadStream2 = deps.createReadStream ?? import_fs.default.createReadStream;
|
|
20634
|
+
try {
|
|
20635
|
+
const stream = createReadStream2(file, { highWaterMark: 4 * 1024 * 1024 });
|
|
20636
|
+
stream.on("error", () => void 0);
|
|
20637
|
+
stream.resume();
|
|
20638
|
+
} catch {
|
|
20639
|
+
}
|
|
20640
|
+
}
|
|
20632
20641
|
function isCommandOnPath(cmd, probe = defaultWhich) {
|
|
20633
20642
|
return probe(cmd);
|
|
20634
20643
|
}
|
|
@@ -20785,8 +20794,8 @@ var AiderRuntimeStrategy = class {
|
|
|
20785
20794
|
meta = getAgent("aider");
|
|
20786
20795
|
mode = "interactive";
|
|
20787
20796
|
os;
|
|
20788
|
-
constructor(
|
|
20789
|
-
this.os =
|
|
20797
|
+
constructor(os74) {
|
|
20798
|
+
this.os = os74;
|
|
20790
20799
|
}
|
|
20791
20800
|
async prepareLaunch() {
|
|
20792
20801
|
augmentUserLocalBinPaths();
|
|
@@ -20919,8 +20928,8 @@ function geminiCredentialLocator() {
|
|
|
20919
20928
|
function geminiLoginLauncher() {
|
|
20920
20929
|
return {
|
|
20921
20930
|
async ensureInstalled() {
|
|
20922
|
-
const
|
|
20923
|
-
return
|
|
20931
|
+
const os74 = createOsStrategy();
|
|
20932
|
+
return os74.findInPath("gemini") !== null;
|
|
20924
20933
|
},
|
|
20925
20934
|
launch() {
|
|
20926
20935
|
return (0, import_node_child_process12.spawn)("gemini", ["auth", "login"], { stdio: "inherit" });
|
|
@@ -21110,8 +21119,8 @@ var GeminiRuntimeStrategy = class {
|
|
|
21110
21119
|
meta = getAgent("gemini");
|
|
21111
21120
|
mode = "interactive";
|
|
21112
21121
|
os;
|
|
21113
|
-
constructor(
|
|
21114
|
-
this.os =
|
|
21122
|
+
constructor(os74) {
|
|
21123
|
+
this.os = os74;
|
|
21115
21124
|
}
|
|
21116
21125
|
async prepareLaunch() {
|
|
21117
21126
|
const binary = this.os.findInPath("gemini");
|
|
@@ -21404,8 +21413,8 @@ var KimiRuntimeStrategy = class {
|
|
|
21404
21413
|
meta = getAgent("kimi");
|
|
21405
21414
|
mode = "interactive";
|
|
21406
21415
|
os;
|
|
21407
|
-
constructor(
|
|
21408
|
-
this.os =
|
|
21416
|
+
constructor(os74) {
|
|
21417
|
+
this.os = os74;
|
|
21409
21418
|
}
|
|
21410
21419
|
async prepareLaunch() {
|
|
21411
21420
|
const binary = this.os.findInPath("kimi");
|
|
@@ -21549,8 +21558,8 @@ var OpencodeRuntimeStrategy = class {
|
|
|
21549
21558
|
meta = getAgent("opencode");
|
|
21550
21559
|
mode = "interactive";
|
|
21551
21560
|
os;
|
|
21552
|
-
constructor(
|
|
21553
|
-
this.os =
|
|
21561
|
+
constructor(os74) {
|
|
21562
|
+
this.os = os74;
|
|
21554
21563
|
}
|
|
21555
21564
|
async prepareLaunch() {
|
|
21556
21565
|
const binary = this.os.findInPath("opencode");
|
|
@@ -21636,20 +21645,20 @@ var OpencodeRuntimeStrategy = class {
|
|
|
21636
21645
|
|
|
21637
21646
|
// src/agents/registry.ts
|
|
21638
21647
|
var runtimeBuilders = {
|
|
21639
|
-
claude: (
|
|
21640
|
-
codex: (
|
|
21641
|
-
coderabbit: (
|
|
21642
|
-
cursor: (
|
|
21643
|
-
aider: (
|
|
21644
|
-
gemini: (
|
|
21645
|
-
kimi: (
|
|
21646
|
-
opencode: (
|
|
21648
|
+
claude: (os74) => new ClaudeRuntimeStrategy(os74),
|
|
21649
|
+
codex: (os74) => new CodexRuntimeStrategy(os74),
|
|
21650
|
+
coderabbit: (os74) => new CoderabbitRuntimeStrategy(os74),
|
|
21651
|
+
cursor: (os74) => new CursorRuntimeStrategy(os74),
|
|
21652
|
+
aider: (os74) => new AiderRuntimeStrategy(os74),
|
|
21653
|
+
gemini: (os74) => new GeminiRuntimeStrategy(os74),
|
|
21654
|
+
kimi: (os74) => new KimiRuntimeStrategy(os74),
|
|
21655
|
+
opencode: (os74) => new OpencodeRuntimeStrategy(os74)
|
|
21647
21656
|
};
|
|
21648
21657
|
var deployBuilders = {
|
|
21649
21658
|
claude: () => new ClaudeDeployStrategy(),
|
|
21650
21659
|
codex: () => new CodexDeployStrategy()
|
|
21651
21660
|
};
|
|
21652
|
-
function createAgentStrategy(agent,
|
|
21661
|
+
function createAgentStrategy(agent, os74 = createOsStrategy()) {
|
|
21653
21662
|
if (!AGENT_REGISTRY[agent]?.enabled) {
|
|
21654
21663
|
throw new Error(
|
|
21655
21664
|
`Agent "${agent}" is not supported in this codeam-cli version. Upgrade with 'npm i -g codeam-cli@latest'.`
|
|
@@ -21659,10 +21668,10 @@ function createAgentStrategy(agent, os72 = createOsStrategy()) {
|
|
|
21659
21668
|
if (!build) {
|
|
21660
21669
|
throw new Error(`No runtime strategy registered for agent "${agent}"`);
|
|
21661
21670
|
}
|
|
21662
|
-
return build(
|
|
21671
|
+
return build(os74);
|
|
21663
21672
|
}
|
|
21664
|
-
function createInteractiveAgentStrategy(agent,
|
|
21665
|
-
const s = createAgentStrategy(agent,
|
|
21673
|
+
function createInteractiveAgentStrategy(agent, os74 = createOsStrategy()) {
|
|
21674
|
+
const s = createAgentStrategy(agent, os74);
|
|
21666
21675
|
if (s.mode !== "interactive") {
|
|
21667
21676
|
throw new Error(
|
|
21668
21677
|
`Agent "${agent}" is a batch agent; use createAgentStrategy + .runOneShot for one-shot reviews.`
|
|
@@ -22376,8 +22385,8 @@ function collectChangedFiles(cwd) {
|
|
|
22376
22385
|
}
|
|
22377
22386
|
return [...byPath.values()];
|
|
22378
22387
|
}
|
|
22379
|
-
function restoreCoderabbitOauthBlob(
|
|
22380
|
-
const dir = path40.join(
|
|
22388
|
+
function restoreCoderabbitOauthBlob(os74, value) {
|
|
22389
|
+
const dir = path40.join(os74.homeDir(), ".coderabbit");
|
|
22381
22390
|
(0, import_node_fs7.mkdirSync)(dir, { recursive: true });
|
|
22382
22391
|
let file = "auth.json";
|
|
22383
22392
|
let contents = value.trim();
|
|
@@ -22397,26 +22406,26 @@ function installFailureMessage(result) {
|
|
|
22397
22406
|
return result.error ?? "CodeRabbit CLI could not be installed";
|
|
22398
22407
|
}
|
|
22399
22408
|
async function configureCoderabbit(input, deps = {}) {
|
|
22400
|
-
const
|
|
22409
|
+
const os74 = deps.os ?? createOsStrategy();
|
|
22401
22410
|
const ensureInstalled = deps.ensureInstalled ?? ensureCoderabbitInstalled;
|
|
22402
22411
|
const isLoggedIn = deps.isLoggedIn ?? defaultIsLoggedIn;
|
|
22403
22412
|
const runOAuth = deps.runOAuthLogin ?? runCoderabbitOAuthLogin;
|
|
22404
22413
|
const snapshot = deps.snapshotDir ?? (() => snapshotCredentialDir());
|
|
22405
22414
|
const capture2 = deps.captureCredential ?? ((b) => diffCapturedCredential(b));
|
|
22406
22415
|
const loginWithApiKey = deps.loginWithApiKey ?? defaultLoginWithApiKey;
|
|
22407
|
-
const home =
|
|
22408
|
-
|
|
22409
|
-
|
|
22416
|
+
const home = os74.homeDir();
|
|
22417
|
+
os74.augmentPath(
|
|
22418
|
+
os74.id === "win32" ? [
|
|
22410
22419
|
path40.join(home, ".local", "bin"),
|
|
22411
22420
|
path40.join(process.env.APPDATA ?? path40.join(home, "AppData", "Roaming"), "npm"),
|
|
22412
22421
|
path40.join(home, "scoop", "shims")
|
|
22413
22422
|
] : [path40.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"]
|
|
22414
22423
|
);
|
|
22415
|
-
const installed2 =
|
|
22424
|
+
const installed2 = os74.findInPath("coderabbit") !== null;
|
|
22416
22425
|
const base = () => ({
|
|
22417
22426
|
action: input.action,
|
|
22418
22427
|
supported: true,
|
|
22419
|
-
installed:
|
|
22428
|
+
installed: os74.findInPath("coderabbit") !== null,
|
|
22420
22429
|
loggedIn: false
|
|
22421
22430
|
});
|
|
22422
22431
|
if (input.action === "status") {
|
|
@@ -22430,7 +22439,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22430
22439
|
const key = (input.apiKey ?? "").trim();
|
|
22431
22440
|
if (!key) return { ...res2, error: "No API key provided" };
|
|
22432
22441
|
if (!res2.installed) {
|
|
22433
|
-
const inst = await ensureInstalled(
|
|
22442
|
+
const inst = await ensureInstalled(os74);
|
|
22434
22443
|
res2.installed = inst.ok;
|
|
22435
22444
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
22436
22445
|
}
|
|
@@ -22454,7 +22463,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22454
22463
|
}
|
|
22455
22464
|
if (!res2.installed) {
|
|
22456
22465
|
deps.onEvent?.({ kind: "installing" });
|
|
22457
|
-
const inst = await ensureInstalled(
|
|
22466
|
+
const inst = await ensureInstalled(os74);
|
|
22458
22467
|
res2.installed = inst.ok;
|
|
22459
22468
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
22460
22469
|
}
|
|
@@ -22471,7 +22480,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22471
22480
|
return { ...res2, loggedIn: true, linked: true };
|
|
22472
22481
|
}
|
|
22473
22482
|
try {
|
|
22474
|
-
restoreCoderabbitOauthBlob(
|
|
22483
|
+
restoreCoderabbitOauthBlob(os74, cred.credential);
|
|
22475
22484
|
} catch (err) {
|
|
22476
22485
|
return {
|
|
22477
22486
|
...res2,
|
|
@@ -22495,7 +22504,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22495
22504
|
const res2 = base();
|
|
22496
22505
|
if (!installed2) {
|
|
22497
22506
|
deps.onEvent?.({ kind: "installing" });
|
|
22498
|
-
const inst = await ensureInstalled(
|
|
22507
|
+
const inst = await ensureInstalled(os74);
|
|
22499
22508
|
res2.installed = inst.ok;
|
|
22500
22509
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
22501
22510
|
}
|
|
@@ -22535,7 +22544,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22535
22544
|
}
|
|
22536
22545
|
const res = base();
|
|
22537
22546
|
if (!res.installed) {
|
|
22538
|
-
const inst = await ensureInstalled(
|
|
22547
|
+
const inst = await ensureInstalled(os74);
|
|
22539
22548
|
res.installed = inst.ok;
|
|
22540
22549
|
if (!inst.ok) return { ...res, error: installFailureMessage(inst) };
|
|
22541
22550
|
}
|
|
@@ -27400,11 +27409,11 @@ function resolveDoltInstallStrategy(platform3) {
|
|
|
27400
27409
|
}
|
|
27401
27410
|
var DOLT_RELEASE_BASE = "https://github.com/dolthub/dolt/releases/latest/download";
|
|
27402
27411
|
function doltPlatformTuple(platform3, arch2) {
|
|
27403
|
-
const
|
|
27412
|
+
const os74 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
|
|
27404
27413
|
const a = arch2 === "x64" ? "amd64" : arch2 === "arm64" ? "arm64" : null;
|
|
27405
27414
|
if (!a) return null;
|
|
27406
|
-
if (
|
|
27407
|
-
return `${
|
|
27415
|
+
if (os74 === "windows" && a !== "amd64") return null;
|
|
27416
|
+
return `${os74}-${a}`;
|
|
27408
27417
|
}
|
|
27409
27418
|
function resolveDoltTarballStrategy(targetDir, platform3, arch2) {
|
|
27410
27419
|
const tuple = doltPlatformTuple(platform3, arch2);
|
|
@@ -28285,6 +28294,82 @@ function persistBeadsConfig(cfg) {
|
|
|
28285
28294
|
restrictToOwner(file);
|
|
28286
28295
|
}
|
|
28287
28296
|
|
|
28297
|
+
// src/beads/provision-lock.ts
|
|
28298
|
+
var import_fs7 = __toESM(require("fs"));
|
|
28299
|
+
var import_os11 = __toESM(require("os"));
|
|
28300
|
+
var import_path9 = __toESM(require("path"));
|
|
28301
|
+
var STALE_LOCK_MS = 5 * 6e4;
|
|
28302
|
+
function pidIsAlive(pid) {
|
|
28303
|
+
try {
|
|
28304
|
+
process.kill(pid, 0);
|
|
28305
|
+
return true;
|
|
28306
|
+
} catch (err) {
|
|
28307
|
+
return err.code === "EPERM";
|
|
28308
|
+
}
|
|
28309
|
+
}
|
|
28310
|
+
function tryAcquire(lockDir, deps) {
|
|
28311
|
+
const pid = deps.pid ?? process.pid;
|
|
28312
|
+
try {
|
|
28313
|
+
import_fs7.default.mkdirSync(import_path9.default.dirname(lockDir), { recursive: true });
|
|
28314
|
+
import_fs7.default.mkdirSync(lockDir);
|
|
28315
|
+
import_fs7.default.writeFileSync(import_path9.default.join(lockDir, "pid"), String(pid));
|
|
28316
|
+
return true;
|
|
28317
|
+
} catch (err) {
|
|
28318
|
+
if (err.code !== "EEXIST") return true;
|
|
28319
|
+
}
|
|
28320
|
+
let age;
|
|
28321
|
+
try {
|
|
28322
|
+
age = (deps.now ?? Date.now)() - import_fs7.default.statSync(lockDir).mtimeMs;
|
|
28323
|
+
} catch {
|
|
28324
|
+
return tryAcquireOnce(lockDir, deps);
|
|
28325
|
+
}
|
|
28326
|
+
let holder = NaN;
|
|
28327
|
+
try {
|
|
28328
|
+
holder = Number(import_fs7.default.readFileSync(import_path9.default.join(lockDir, "pid"), "utf8"));
|
|
28329
|
+
} catch {
|
|
28330
|
+
if (age <= 1e4) return false;
|
|
28331
|
+
}
|
|
28332
|
+
const alive = Number.isInteger(holder) && (deps.isAlive ?? pidIsAlive)(holder);
|
|
28333
|
+
if (alive && age <= STALE_LOCK_MS) return false;
|
|
28334
|
+
try {
|
|
28335
|
+
import_fs7.default.rmSync(lockDir, { recursive: true, force: true });
|
|
28336
|
+
} catch {
|
|
28337
|
+
return false;
|
|
28338
|
+
}
|
|
28339
|
+
return tryAcquireOnce(lockDir, deps);
|
|
28340
|
+
}
|
|
28341
|
+
function tryAcquireOnce(lockDir, deps) {
|
|
28342
|
+
try {
|
|
28343
|
+
import_fs7.default.mkdirSync(lockDir);
|
|
28344
|
+
import_fs7.default.writeFileSync(import_path9.default.join(lockDir, "pid"), String(deps.pid ?? process.pid));
|
|
28345
|
+
return true;
|
|
28346
|
+
} catch {
|
|
28347
|
+
return false;
|
|
28348
|
+
}
|
|
28349
|
+
}
|
|
28350
|
+
async function withBeadsProvisionLock(fn, deps = {}) {
|
|
28351
|
+
const lockDir = import_path9.default.join(deps.dir ?? import_path9.default.join(import_os11.default.homedir(), ".codeam"), "beads-provision.lock");
|
|
28352
|
+
const now = deps.now ?? Date.now;
|
|
28353
|
+
const sleep5 = deps.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
28354
|
+
const deadline = now() + (deps.timeoutMs ?? 18e4);
|
|
28355
|
+
let held = tryAcquire(lockDir, deps);
|
|
28356
|
+
while (!held && now() < deadline) {
|
|
28357
|
+
await sleep5(500);
|
|
28358
|
+
held = tryAcquire(lockDir, deps);
|
|
28359
|
+
}
|
|
28360
|
+
try {
|
|
28361
|
+
return await fn();
|
|
28362
|
+
} finally {
|
|
28363
|
+
if (held) {
|
|
28364
|
+
try {
|
|
28365
|
+
const owner = Number(import_fs7.default.readFileSync(import_path9.default.join(lockDir, "pid"), "utf8"));
|
|
28366
|
+
if (owner === (deps.pid ?? process.pid)) import_fs7.default.rmSync(lockDir, { recursive: true, force: true });
|
|
28367
|
+
} catch {
|
|
28368
|
+
}
|
|
28369
|
+
}
|
|
28370
|
+
}
|
|
28371
|
+
}
|
|
28372
|
+
|
|
28288
28373
|
// src/beads/wiring.ts
|
|
28289
28374
|
function beadsKilled() {
|
|
28290
28375
|
const v = process.env.CODEAM_BEADS_DISABLED;
|
|
@@ -28306,15 +28391,18 @@ async function provisionBeadsForStart(ctx) {
|
|
|
28306
28391
|
return null;
|
|
28307
28392
|
}
|
|
28308
28393
|
const pluginAuthToken = ctx.pluginAuthToken;
|
|
28394
|
+
if (ctx.deferUntil) await ctx.deferUntil.catch(() => void 0);
|
|
28309
28395
|
let started = null;
|
|
28310
28396
|
try {
|
|
28311
|
-
started = await
|
|
28312
|
-
|
|
28313
|
-
|
|
28314
|
-
|
|
28315
|
-
|
|
28316
|
-
|
|
28317
|
-
|
|
28397
|
+
started = await withBeadsProvisionLock(
|
|
28398
|
+
() => startBeads({
|
|
28399
|
+
sessionId: ctx.sessionId,
|
|
28400
|
+
pluginId: ctx.pluginId,
|
|
28401
|
+
pluginAuthToken,
|
|
28402
|
+
cwd: ctx.cwd,
|
|
28403
|
+
agents: ctx.agents
|
|
28404
|
+
})
|
|
28405
|
+
);
|
|
28318
28406
|
} catch (err) {
|
|
28319
28407
|
log.warn("beads", "provisionBeadsForStart failed (non-fatal)", err);
|
|
28320
28408
|
started = null;
|
|
@@ -28550,8 +28638,8 @@ function cleanupAttachmentTempFiles() {
|
|
|
28550
28638
|
function saveFilesTemp(files) {
|
|
28551
28639
|
return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
|
|
28552
28640
|
const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
|
|
28553
|
-
const tmpPath =
|
|
28554
|
-
|
|
28641
|
+
const tmpPath = path73.join(os47.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
|
|
28642
|
+
fs64.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
|
|
28555
28643
|
pendingAttachmentFiles.add(tmpPath);
|
|
28556
28644
|
return tmpPath;
|
|
28557
28645
|
});
|
|
@@ -28796,10 +28884,10 @@ var listFiles = async (ctx, cmd, parsed) => {
|
|
|
28796
28884
|
await ctx.relay.sendResult(cmd.id, "completed", result);
|
|
28797
28885
|
};
|
|
28798
28886
|
var envReadH = async (ctx, cmd) => {
|
|
28799
|
-
const envPath =
|
|
28887
|
+
const envPath = path73.join(process.cwd(), ".env");
|
|
28800
28888
|
await restoreProjectEnvIfMissing(process.cwd(), ctx);
|
|
28801
28889
|
try {
|
|
28802
|
-
const raw = await
|
|
28890
|
+
const raw = await fs64.promises.readFile(envPath, "utf8");
|
|
28803
28891
|
await ctx.relay.sendResult(cmd.id, "completed", {
|
|
28804
28892
|
exists: true,
|
|
28805
28893
|
vars: parseDotenv(raw)
|
|
@@ -28828,7 +28916,7 @@ var envParseH = async (ctx, cmd, parsed) => {
|
|
|
28828
28916
|
const existing = /* @__PURE__ */ new Map();
|
|
28829
28917
|
if (!replace) {
|
|
28830
28918
|
try {
|
|
28831
|
-
const raw = await
|
|
28919
|
+
const raw = await fs64.promises.readFile(path73.join(process.cwd(), ".env"), "utf8");
|
|
28832
28920
|
for (const v of parseDotenv(raw)) existing.set(v.key, v.value);
|
|
28833
28921
|
} catch {
|
|
28834
28922
|
}
|
|
@@ -28868,15 +28956,15 @@ var envWriteH = async (ctx, cmd, parsed) => {
|
|
|
28868
28956
|
}
|
|
28869
28957
|
seen2.add(v.key);
|
|
28870
28958
|
}
|
|
28871
|
-
const envPath =
|
|
28872
|
-
const tmpPath =
|
|
28959
|
+
const envPath = path73.join(process.cwd(), ".env");
|
|
28960
|
+
const tmpPath = path73.join(process.cwd(), ".env.codeam.tmp");
|
|
28873
28961
|
try {
|
|
28874
|
-
await
|
|
28875
|
-
await
|
|
28962
|
+
await fs64.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
|
|
28963
|
+
await fs64.promises.rename(tmpPath, envPath);
|
|
28876
28964
|
await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
|
|
28877
28965
|
void syncProjectEnvUp(process.cwd(), ctx);
|
|
28878
28966
|
} catch (err) {
|
|
28879
|
-
await
|
|
28967
|
+
await fs64.promises.rm(tmpPath, { force: true }).catch(() => void 0);
|
|
28880
28968
|
await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
|
|
28881
28969
|
}
|
|
28882
28970
|
};
|
|
@@ -29102,7 +29190,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
29102
29190
|
});
|
|
29103
29191
|
const token = ctx.pluginAuthToken;
|
|
29104
29192
|
void (async () => {
|
|
29105
|
-
const
|
|
29193
|
+
const os74 = createOsStrategy();
|
|
29106
29194
|
try {
|
|
29107
29195
|
const report = await reviewPullRequest(
|
|
29108
29196
|
{
|
|
@@ -29111,7 +29199,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
29111
29199
|
baseBranch: parsed.baseBranch
|
|
29112
29200
|
},
|
|
29113
29201
|
{
|
|
29114
|
-
runReview: (input) => new CoderabbitRuntimeStrategy(
|
|
29202
|
+
runReview: (input) => new CoderabbitRuntimeStrategy(os74).runOneShot(input),
|
|
29115
29203
|
runGh: (args2) => defaultRunGh(args2),
|
|
29116
29204
|
postReport: async (r) => {
|
|
29117
29205
|
if (!token) return;
|
|
@@ -29225,9 +29313,9 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
|
|
|
29225
29313
|
function buildNpmInstallInvocation(opts) {
|
|
29226
29314
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
29227
29315
|
const execPath = opts?.execPath ?? process.execPath;
|
|
29228
|
-
const exists2 = opts?.existsSync ??
|
|
29316
|
+
const exists2 = opts?.existsSync ?? fs64.existsSync;
|
|
29229
29317
|
const platform3 = opts?.platform ?? process.platform;
|
|
29230
|
-
const p2 = platform3 === "win32" ?
|
|
29318
|
+
const p2 = platform3 === "win32" ? path73.win32 : path73.posix;
|
|
29231
29319
|
const normalized = entryScript.split(/[\\/]/).join("/");
|
|
29232
29320
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
29233
29321
|
const markerIdx = normalized.indexOf(marker);
|
|
@@ -29246,7 +29334,7 @@ function isPermissionError(stderr) {
|
|
|
29246
29334
|
function resolveGlobalNodeModulesDir(opts) {
|
|
29247
29335
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
29248
29336
|
const platform3 = opts?.platform ?? process.platform;
|
|
29249
|
-
const p2 = platform3 === "win32" ?
|
|
29337
|
+
const p2 = platform3 === "win32" ? path73.win32 : path73.posix;
|
|
29250
29338
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
29251
29339
|
const markerIdx = entryScript.split(/[\\/]/).join("/").indexOf(marker);
|
|
29252
29340
|
if (markerIdx <= 0) return null;
|
|
@@ -29256,9 +29344,9 @@ function resolveGlobalNodeModulesDir(opts) {
|
|
|
29256
29344
|
var STALE_STAGING_AGE_MS = CLI_UPDATE_INSTALL_TIMEOUT_MS;
|
|
29257
29345
|
function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
29258
29346
|
if (!nodeModulesDir) return 0;
|
|
29259
|
-
const readdirSync18 = deps?.readdirSync ??
|
|
29260
|
-
const statSync17 = deps?.statSync ??
|
|
29261
|
-
const rmSync14 = deps?.rmSync ??
|
|
29347
|
+
const readdirSync18 = deps?.readdirSync ?? fs64.readdirSync;
|
|
29348
|
+
const statSync17 = deps?.statSync ?? fs64.statSync;
|
|
29349
|
+
const rmSync14 = deps?.rmSync ?? fs64.rmSync;
|
|
29262
29350
|
let removed = 0;
|
|
29263
29351
|
let entries2;
|
|
29264
29352
|
try {
|
|
@@ -29268,7 +29356,7 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
|
29268
29356
|
}
|
|
29269
29357
|
for (const name of entries2) {
|
|
29270
29358
|
if (!/^\.codeam-cli-/.test(name)) continue;
|
|
29271
|
-
const full =
|
|
29359
|
+
const full = path73.join(nodeModulesDir, name);
|
|
29272
29360
|
try {
|
|
29273
29361
|
const st3 = statSync17(full);
|
|
29274
29362
|
if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
|
|
@@ -30391,11 +30479,11 @@ function resolveTokenValue(args2) {
|
|
|
30391
30479
|
}
|
|
30392
30480
|
const fileFlag = args2.find((a) => a.startsWith("--token-file="));
|
|
30393
30481
|
if (fileFlag) {
|
|
30394
|
-
const
|
|
30482
|
+
const path114 = fileFlag.slice("--token-file=".length);
|
|
30395
30483
|
try {
|
|
30396
|
-
const content =
|
|
30397
|
-
if (content.length === 0) fail(`--token-file ${
|
|
30398
|
-
rmIfExistsQuiet(
|
|
30484
|
+
const content = fs65.readFileSync(path114, "utf8").trim();
|
|
30485
|
+
if (content.length === 0) fail(`--token-file ${path114} is empty`);
|
|
30486
|
+
rmIfExistsQuiet(path114);
|
|
30399
30487
|
return content;
|
|
30400
30488
|
} catch (err) {
|
|
30401
30489
|
fail(`Could not read --token-file: ${err.message}`);
|
|
@@ -30487,12 +30575,12 @@ async function claim(token, pluginId, pluginSecretHash) {
|
|
|
30487
30575
|
}
|
|
30488
30576
|
}
|
|
30489
30577
|
function pairAutoLockPath() {
|
|
30490
|
-
return
|
|
30578
|
+
return path74.join(os48.homedir(), ".codeam", "pair-auto.lock");
|
|
30491
30579
|
}
|
|
30492
30580
|
var procRoot = "/proc";
|
|
30493
30581
|
function readProcFile(rel) {
|
|
30494
30582
|
try {
|
|
30495
|
-
return
|
|
30583
|
+
return fs65.readFileSync(path74.join(procRoot, rel), "utf8");
|
|
30496
30584
|
} catch {
|
|
30497
30585
|
return void 0;
|
|
30498
30586
|
}
|
|
@@ -30513,7 +30601,7 @@ function currentBootId() {
|
|
|
30513
30601
|
function readLockRecord(lockPath) {
|
|
30514
30602
|
let raw;
|
|
30515
30603
|
try {
|
|
30516
|
-
raw =
|
|
30604
|
+
raw = fs65.readFileSync(lockPath, "utf8");
|
|
30517
30605
|
} catch {
|
|
30518
30606
|
return void 0;
|
|
30519
30607
|
}
|
|
@@ -30562,7 +30650,7 @@ function isLiveLockHolder(rec) {
|
|
|
30562
30650
|
}
|
|
30563
30651
|
function releaseOwnLock(lockPath) {
|
|
30564
30652
|
try {
|
|
30565
|
-
if (readLockRecord(lockPath)?.pid === process.pid)
|
|
30653
|
+
if (readLockRecord(lockPath)?.pid === process.pid) fs65.unlinkSync(lockPath);
|
|
30566
30654
|
} catch {
|
|
30567
30655
|
}
|
|
30568
30656
|
}
|
|
@@ -30586,7 +30674,7 @@ function snapshotProcessTree(root) {
|
|
|
30586
30674
|
const children = /* @__PURE__ */ new Map();
|
|
30587
30675
|
let entries2 = [];
|
|
30588
30676
|
try {
|
|
30589
|
-
entries2 =
|
|
30677
|
+
entries2 = fs65.readdirSync(procRoot).filter((e) => /^\d+$/.test(e));
|
|
30590
30678
|
} catch {
|
|
30591
30679
|
}
|
|
30592
30680
|
for (const e of entries2) {
|
|
@@ -30621,18 +30709,18 @@ function signalProcessTree(refs, signal) {
|
|
|
30621
30709
|
}
|
|
30622
30710
|
function daemonLockPath(sessionId) {
|
|
30623
30711
|
const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
30624
|
-
return
|
|
30712
|
+
return path74.join(os48.homedir(), ".codeam", `daemon-${safe}.lock`);
|
|
30625
30713
|
}
|
|
30626
30714
|
function acquireDaemonLock(sessionId) {
|
|
30627
30715
|
const lockPath = daemonLockPath(sessionId);
|
|
30628
30716
|
try {
|
|
30629
|
-
|
|
30717
|
+
fs65.mkdirSync(path74.dirname(lockPath), { recursive: true });
|
|
30630
30718
|
try {
|
|
30631
|
-
|
|
30719
|
+
fs65.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
30632
30720
|
} catch (e) {
|
|
30633
30721
|
if (e.code !== "EEXIST") throw e;
|
|
30634
30722
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
30635
|
-
|
|
30723
|
+
fs65.writeFileSync(lockPath, ownLockBody());
|
|
30636
30724
|
}
|
|
30637
30725
|
const release3 = () => releaseOwnLock(lockPath);
|
|
30638
30726
|
process.once("exit", release3);
|
|
@@ -30652,13 +30740,13 @@ function acquireDaemonLock(sessionId) {
|
|
|
30652
30740
|
function acquireSingletonLock() {
|
|
30653
30741
|
const lockPath = pairAutoLockPath();
|
|
30654
30742
|
try {
|
|
30655
|
-
|
|
30743
|
+
fs65.mkdirSync(path74.dirname(lockPath), { recursive: true });
|
|
30656
30744
|
try {
|
|
30657
|
-
|
|
30745
|
+
fs65.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
30658
30746
|
} catch (e) {
|
|
30659
30747
|
if (e.code !== "EEXIST") throw e;
|
|
30660
30748
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
30661
|
-
|
|
30749
|
+
fs65.writeFileSync(lockPath, ownLockBody());
|
|
30662
30750
|
}
|
|
30663
30751
|
process.once("exit", () => releaseOwnLock(lockPath));
|
|
30664
30752
|
return true;
|
|
@@ -31075,7 +31163,7 @@ var AgentService = class _AgentService {
|
|
|
31075
31163
|
};
|
|
31076
31164
|
|
|
31077
31165
|
// src/agents/acp/adapters.ts
|
|
31078
|
-
var
|
|
31166
|
+
var path75 = __toESM(require("path"));
|
|
31079
31167
|
|
|
31080
31168
|
// src/agents/kimi/installer.ts
|
|
31081
31169
|
var import_node_child_process25 = require("child_process");
|
|
@@ -31195,13 +31283,13 @@ function resolveBin(pkgName, binName) {
|
|
|
31195
31283
|
try {
|
|
31196
31284
|
const manifestPath = require_.resolve(`${pkgName}/package.json`);
|
|
31197
31285
|
const manifest = require_(`${pkgName}/package.json`);
|
|
31198
|
-
const pkgDir =
|
|
31286
|
+
const pkgDir = path75.dirname(manifestPath);
|
|
31199
31287
|
const bin = manifest.bin;
|
|
31200
31288
|
if (!bin) return null;
|
|
31201
|
-
if (typeof bin === "string") return
|
|
31289
|
+
if (typeof bin === "string") return path75.resolve(pkgDir, bin);
|
|
31202
31290
|
const target = binName ?? Object.keys(bin)[0];
|
|
31203
31291
|
if (!target || !bin[target]) return null;
|
|
31204
|
-
return
|
|
31292
|
+
return path75.resolve(pkgDir, bin[target]);
|
|
31205
31293
|
} catch {
|
|
31206
31294
|
return null;
|
|
31207
31295
|
}
|
|
@@ -31380,11 +31468,89 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
|
|
|
31380
31468
|
return null;
|
|
31381
31469
|
}
|
|
31382
31470
|
|
|
31471
|
+
// src/commands/start/agent-startup-marks.ts
|
|
31472
|
+
var import_fs8 = __toESM(require("fs"));
|
|
31473
|
+
var import_os13 = __toESM(require("os"));
|
|
31474
|
+
var import_path10 = __toESM(require("path"));
|
|
31475
|
+
var STALE_MARK_MS = 18e4;
|
|
31476
|
+
function marksDir(deps) {
|
|
31477
|
+
return deps.dir ?? import_path10.default.join(import_os13.default.homedir(), ".codeam", "agent-startups");
|
|
31478
|
+
}
|
|
31479
|
+
function pidIsAlive2(pid) {
|
|
31480
|
+
try {
|
|
31481
|
+
process.kill(pid, 0);
|
|
31482
|
+
return true;
|
|
31483
|
+
} catch (err) {
|
|
31484
|
+
return err.code === "EPERM";
|
|
31485
|
+
}
|
|
31486
|
+
}
|
|
31487
|
+
function markAgentStarting(deps = {}) {
|
|
31488
|
+
const file = import_path10.default.join(marksDir(deps), String(deps.pid ?? process.pid));
|
|
31489
|
+
try {
|
|
31490
|
+
import_fs8.default.mkdirSync(import_path10.default.dirname(file), { recursive: true });
|
|
31491
|
+
import_fs8.default.writeFileSync(file, "");
|
|
31492
|
+
} catch {
|
|
31493
|
+
return () => void 0;
|
|
31494
|
+
}
|
|
31495
|
+
let released = false;
|
|
31496
|
+
return () => {
|
|
31497
|
+
if (released) return;
|
|
31498
|
+
released = true;
|
|
31499
|
+
try {
|
|
31500
|
+
import_fs8.default.rmSync(file, { force: true });
|
|
31501
|
+
} catch {
|
|
31502
|
+
}
|
|
31503
|
+
};
|
|
31504
|
+
}
|
|
31505
|
+
function otherAgentsStarting(deps = {}) {
|
|
31506
|
+
const dir = marksDir(deps);
|
|
31507
|
+
const self = deps.pid ?? process.pid;
|
|
31508
|
+
const now = (deps.now ?? Date.now)();
|
|
31509
|
+
const isAlive = deps.isAlive ?? pidIsAlive2;
|
|
31510
|
+
let names;
|
|
31511
|
+
try {
|
|
31512
|
+
names = import_fs8.default.readdirSync(dir);
|
|
31513
|
+
} catch {
|
|
31514
|
+
return [];
|
|
31515
|
+
}
|
|
31516
|
+
const live = [];
|
|
31517
|
+
for (const name of names) {
|
|
31518
|
+
const pid = Number(name);
|
|
31519
|
+
if (!Number.isInteger(pid) || pid <= 0 || pid === self) continue;
|
|
31520
|
+
const file = import_path10.default.join(dir, name);
|
|
31521
|
+
let stale = !isAlive(pid);
|
|
31522
|
+
if (!stale) {
|
|
31523
|
+
try {
|
|
31524
|
+
stale = now - import_fs8.default.statSync(file).mtimeMs > STALE_MARK_MS;
|
|
31525
|
+
} catch {
|
|
31526
|
+
continue;
|
|
31527
|
+
}
|
|
31528
|
+
}
|
|
31529
|
+
if (stale) {
|
|
31530
|
+
try {
|
|
31531
|
+
import_fs8.default.rmSync(file, { force: true });
|
|
31532
|
+
} catch {
|
|
31533
|
+
}
|
|
31534
|
+
continue;
|
|
31535
|
+
}
|
|
31536
|
+
live.push(pid);
|
|
31537
|
+
}
|
|
31538
|
+
return live;
|
|
31539
|
+
}
|
|
31540
|
+
async function waitForNoAgentStarting(opts) {
|
|
31541
|
+
const now = opts.now ?? Date.now;
|
|
31542
|
+
const sleep5 = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
31543
|
+
const deadline = now() + opts.timeoutMs;
|
|
31544
|
+
while (otherAgentsStarting(opts).length > 0 && now() < deadline) {
|
|
31545
|
+
await sleep5(opts.pollMs ?? 500);
|
|
31546
|
+
}
|
|
31547
|
+
}
|
|
31548
|
+
|
|
31383
31549
|
// src/agents/acp/runner.ts
|
|
31384
31550
|
var import_node_crypto15 = require("crypto");
|
|
31385
|
-
var
|
|
31386
|
-
var
|
|
31387
|
-
var
|
|
31551
|
+
var fs85 = __toESM(require("fs"));
|
|
31552
|
+
var os61 = __toESM(require("os"));
|
|
31553
|
+
var path96 = __toESM(require("path"));
|
|
31388
31554
|
|
|
31389
31555
|
// src/agents/acp/provider-billing-signal.ts
|
|
31390
31556
|
var seen = /* @__PURE__ */ new Set();
|
|
@@ -31416,8 +31582,8 @@ function noteProviderBillingSignal(opts) {
|
|
|
31416
31582
|
}
|
|
31417
31583
|
|
|
31418
31584
|
// src/services/history.service.ts
|
|
31419
|
-
var
|
|
31420
|
-
var
|
|
31585
|
+
var fs67 = __toESM(require("fs"));
|
|
31586
|
+
var path77 = __toESM(require("path"));
|
|
31421
31587
|
var https6 = __toESM(require("https"));
|
|
31422
31588
|
var http10 = __toESM(require("http"));
|
|
31423
31589
|
var import_zod2 = require("zod");
|
|
@@ -31478,7 +31644,7 @@ function parseJsonl(filePath) {
|
|
|
31478
31644
|
const messages = [];
|
|
31479
31645
|
let raw;
|
|
31480
31646
|
try {
|
|
31481
|
-
raw =
|
|
31647
|
+
raw = fs67.readFileSync(filePath, "utf8");
|
|
31482
31648
|
} catch (err) {
|
|
31483
31649
|
if (err.code !== "ENOENT") {
|
|
31484
31650
|
log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
|
|
@@ -31638,7 +31804,7 @@ var HistoryService = class _HistoryService {
|
|
|
31638
31804
|
// session-start upload answered false, the active-conversation pointer was
|
|
31639
31805
|
// never re-pointed after a Box wake, and the app opened an empty "New
|
|
31640
31806
|
// conversation" over the resumed one (QA box, 2026-09-29).
|
|
31641
|
-
|
|
31807
|
+
path77.join(claudeConfigDir(), "projects", encodeCwd(this.cwd));
|
|
31642
31808
|
}
|
|
31643
31809
|
/** Set the current Claude conversation ID (extracted from /cost command or session start) */
|
|
31644
31810
|
setCurrentConversationId(id) {
|
|
@@ -31650,7 +31816,7 @@ var HistoryService = class _HistoryService {
|
|
|
31650
31816
|
/** Return the current message count in the active conversation. */
|
|
31651
31817
|
getCurrentMessageCount() {
|
|
31652
31818
|
if (!this.currentConversationId) return 0;
|
|
31653
|
-
const filePath =
|
|
31819
|
+
const filePath = path77.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
31654
31820
|
return parseJsonl(filePath).length;
|
|
31655
31821
|
}
|
|
31656
31822
|
/**
|
|
@@ -31661,7 +31827,7 @@ var HistoryService = class _HistoryService {
|
|
|
31661
31827
|
const deadline = Date.now() + timeoutMs;
|
|
31662
31828
|
while (Date.now() < deadline) {
|
|
31663
31829
|
if (!this.currentConversationId) return null;
|
|
31664
|
-
const filePath =
|
|
31830
|
+
const filePath = path77.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
31665
31831
|
const messages = parseJsonl(filePath);
|
|
31666
31832
|
if (messages.length > previousCount) {
|
|
31667
31833
|
for (let i = messages.length - 1; i >= previousCount; i--) {
|
|
@@ -31688,18 +31854,18 @@ var HistoryService = class _HistoryService {
|
|
|
31688
31854
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
31689
31855
|
const oneShots = readOneShotConversations(this.cwd);
|
|
31690
31856
|
try {
|
|
31691
|
-
const files =
|
|
31692
|
-
(e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(
|
|
31857
|
+
const files = fs67.readdirSync(dir, { withFileTypes: true }).filter(
|
|
31858
|
+
(e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(path77.basename(e.name, ".jsonl"))
|
|
31693
31859
|
).map((e) => {
|
|
31694
31860
|
try {
|
|
31695
|
-
const stat3 =
|
|
31861
|
+
const stat3 = fs67.statSync(path77.join(dir, e.name));
|
|
31696
31862
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
31697
31863
|
} catch {
|
|
31698
31864
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
31699
31865
|
}
|
|
31700
31866
|
}).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
31701
31867
|
if (files.length > 0) {
|
|
31702
|
-
this.currentConversationId =
|
|
31868
|
+
this.currentConversationId = path77.basename(files[0].name, ".jsonl");
|
|
31703
31869
|
}
|
|
31704
31870
|
} catch {
|
|
31705
31871
|
}
|
|
@@ -31733,13 +31899,13 @@ var HistoryService = class _HistoryService {
|
|
|
31733
31899
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
31734
31900
|
let entries2;
|
|
31735
31901
|
try {
|
|
31736
|
-
entries2 =
|
|
31902
|
+
entries2 = fs67.readdirSync(dir, { withFileTypes: true });
|
|
31737
31903
|
} catch {
|
|
31738
31904
|
return null;
|
|
31739
31905
|
}
|
|
31740
31906
|
const files = entries2.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
31741
31907
|
try {
|
|
31742
|
-
const stat3 =
|
|
31908
|
+
const stat3 = fs67.statSync(path77.join(dir, e.name));
|
|
31743
31909
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
31744
31910
|
} catch {
|
|
31745
31911
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
@@ -31748,12 +31914,12 @@ var HistoryService = class _HistoryService {
|
|
|
31748
31914
|
if (files.length === 0) return null;
|
|
31749
31915
|
const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
|
|
31750
31916
|
if (!files.some((f) => f.name === targetFile)) return null;
|
|
31751
|
-
return this.extractUsageFromFile(
|
|
31917
|
+
return this.extractUsageFromFile(path77.join(dir, targetFile));
|
|
31752
31918
|
}
|
|
31753
31919
|
extractUsageFromFile(filePath) {
|
|
31754
31920
|
let raw;
|
|
31755
31921
|
try {
|
|
31756
|
-
raw =
|
|
31922
|
+
raw = fs67.readFileSync(filePath, "utf8");
|
|
31757
31923
|
} catch {
|
|
31758
31924
|
return null;
|
|
31759
31925
|
}
|
|
@@ -31805,9 +31971,9 @@ var HistoryService = class _HistoryService {
|
|
|
31805
31971
|
let totalCost = 0;
|
|
31806
31972
|
let files;
|
|
31807
31973
|
try {
|
|
31808
|
-
files =
|
|
31974
|
+
files = fs67.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
|
|
31809
31975
|
try {
|
|
31810
|
-
return
|
|
31976
|
+
return fs67.statSync(path77.join(projectDir, f)).mtimeMs >= monthStartMs;
|
|
31811
31977
|
} catch {
|
|
31812
31978
|
return false;
|
|
31813
31979
|
}
|
|
@@ -31818,7 +31984,7 @@ var HistoryService = class _HistoryService {
|
|
|
31818
31984
|
for (const file of files) {
|
|
31819
31985
|
let raw;
|
|
31820
31986
|
try {
|
|
31821
|
-
raw =
|
|
31987
|
+
raw = fs67.readFileSync(path77.join(projectDir, file), "utf8");
|
|
31822
31988
|
} catch {
|
|
31823
31989
|
continue;
|
|
31824
31990
|
}
|
|
@@ -31897,7 +32063,7 @@ var HistoryService = class _HistoryService {
|
|
|
31897
32063
|
if (this.runtime.resolveHistoryFile) {
|
|
31898
32064
|
return this.runtime.resolveHistoryFile(this.cwd, sessionId);
|
|
31899
32065
|
}
|
|
31900
|
-
return
|
|
32066
|
+
return path77.join(this.projectDir, `${sessionId}.jsonl`);
|
|
31901
32067
|
}
|
|
31902
32068
|
/**
|
|
31903
32069
|
* Parse a conversation's messages from disk, agent-aware. Claude uses the
|
|
@@ -31935,7 +32101,7 @@ var HistoryService = class _HistoryService {
|
|
|
31935
32101
|
};
|
|
31936
32102
|
});
|
|
31937
32103
|
}
|
|
31938
|
-
return parseJsonl(
|
|
32104
|
+
return parseJsonl(path77.join(this.projectDir, `${sessionId}.jsonl`));
|
|
31939
32105
|
}
|
|
31940
32106
|
/** One in-flight full upload per conversation — the baton mirror and a
|
|
31941
32107
|
* `get_conversation` used to upload the same transcript concurrently. */
|
|
@@ -32017,7 +32183,7 @@ var HistoryService = class _HistoryService {
|
|
|
32017
32183
|
if (!filePath) return false;
|
|
32018
32184
|
let mtimeMs;
|
|
32019
32185
|
try {
|
|
32020
|
-
mtimeMs =
|
|
32186
|
+
mtimeMs = fs67.statSync(filePath).mtimeMs;
|
|
32021
32187
|
} catch {
|
|
32022
32188
|
return false;
|
|
32023
32189
|
}
|
|
@@ -32092,10 +32258,10 @@ var HistoryService = class _HistoryService {
|
|
|
32092
32258
|
|
|
32093
32259
|
// src/agents/acp/client.ts
|
|
32094
32260
|
var import_node_child_process27 = require("child_process");
|
|
32095
|
-
var
|
|
32261
|
+
var fs68 = __toESM(require("fs/promises"));
|
|
32096
32262
|
var fsSync = __toESM(require("fs"));
|
|
32097
|
-
var
|
|
32098
|
-
var
|
|
32263
|
+
var os51 = __toESM(require("os"));
|
|
32264
|
+
var path79 = __toESM(require("path"));
|
|
32099
32265
|
var import_node_stream = require("stream");
|
|
32100
32266
|
|
|
32101
32267
|
// ../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
@@ -36121,8 +36287,8 @@ function createIdleTimeout(idleMs, makeError, activeIdleMs = idleMs) {
|
|
|
36121
36287
|
}
|
|
36122
36288
|
|
|
36123
36289
|
// src/agents/acp/internal-paths.ts
|
|
36124
|
-
var
|
|
36125
|
-
var
|
|
36290
|
+
var path78 = __toESM(require("path"));
|
|
36291
|
+
var os50 = __toESM(require("os"));
|
|
36126
36292
|
var INTERNAL_TOKENS = [".codeam", "house-claude"];
|
|
36127
36293
|
var PROSE_ONLY_TOOL_KINDS = /* @__PURE__ */ new Set(["think", "switch_mode"]);
|
|
36128
36294
|
function isProseOnlyToolKind(kind) {
|
|
@@ -36134,13 +36300,13 @@ function textReferencesInternal(text) {
|
|
|
36134
36300
|
const scrubbed = text.replace(SELF_HOSTED_WORKSPACE_RE, " ");
|
|
36135
36301
|
return INTERNAL_TOKENS.some((t2) => scrubbed.includes(t2));
|
|
36136
36302
|
}
|
|
36137
|
-
function pathIsInternal(p2, homeDir2 =
|
|
36303
|
+
function pathIsInternal(p2, homeDir2 = os50.homedir()) {
|
|
36138
36304
|
if (!p2) return false;
|
|
36139
|
-
const abs =
|
|
36140
|
-
const home =
|
|
36141
|
-
const within = (root) => abs === root || abs.startsWith(root +
|
|
36142
|
-
if (within(
|
|
36143
|
-
return within(
|
|
36305
|
+
const abs = path78.resolve(p2);
|
|
36306
|
+
const home = path78.resolve(homeDir2);
|
|
36307
|
+
const within = (root) => abs === root || abs.startsWith(root + path78.sep);
|
|
36308
|
+
if (within(path78.join(home, ".codeam", "self-hosted"))) return false;
|
|
36309
|
+
return within(path78.join(home, ".codeam")) || within(path78.join(home, ".beads")) || abs === path78.join(home, ".codeam-host.log") || abs.includes(`${path78.sep}house-claude${path78.sep}`) || abs.endsWith(`${path78.sep}house-claude`);
|
|
36144
36310
|
}
|
|
36145
36311
|
function toolCallReferencesInternal(call, homeDir2) {
|
|
36146
36312
|
if (call.locations?.some((l) => pathIsInternal(l.path, homeDir2))) return true;
|
|
@@ -37236,7 +37402,7 @@ var AcpClient = class {
|
|
|
37236
37402
|
throw new RequestError(-32002, GUARDRAIL_SECRET_READ_BLOCK_REASON, { uri: params.path });
|
|
37237
37403
|
}
|
|
37238
37404
|
try {
|
|
37239
|
-
const content = await
|
|
37405
|
+
const content = await fs68.readFile(params.path, "utf8");
|
|
37240
37406
|
return applyLineRange(content, params.line ?? null, params.limit ?? null);
|
|
37241
37407
|
} catch (err) {
|
|
37242
37408
|
const code = err.code;
|
|
@@ -37257,7 +37423,7 @@ var AcpClient = class {
|
|
|
37257
37423
|
throw new RequestError(-32002, INTERNAL_BLOCK_REASON, { uri: params.path });
|
|
37258
37424
|
}
|
|
37259
37425
|
try {
|
|
37260
|
-
await
|
|
37426
|
+
await fs68.writeFile(params.path, params.content, "utf8");
|
|
37261
37427
|
return {};
|
|
37262
37428
|
} catch (err) {
|
|
37263
37429
|
const code = err.code;
|
|
@@ -37345,30 +37511,30 @@ function applyLineRange(content, line, limit) {
|
|
|
37345
37511
|
return { content: lines.slice(start2, end).join("\n") };
|
|
37346
37512
|
}
|
|
37347
37513
|
function knownAgentBinaryDirs() {
|
|
37348
|
-
const home =
|
|
37514
|
+
const home = os51.homedir();
|
|
37349
37515
|
const out2 = [];
|
|
37350
37516
|
out2.push("/tmp/codeam-node20/bin");
|
|
37351
37517
|
for (const root of [
|
|
37352
37518
|
"/usr/local/share/nvm/versions/node",
|
|
37353
|
-
|
|
37519
|
+
path79.join(home, ".nvm/versions/node")
|
|
37354
37520
|
]) {
|
|
37355
37521
|
try {
|
|
37356
37522
|
for (const child of fsSync.readdirSync(root)) {
|
|
37357
|
-
out2.push(
|
|
37523
|
+
out2.push(path79.join(root, child, "bin"));
|
|
37358
37524
|
}
|
|
37359
37525
|
} catch {
|
|
37360
37526
|
}
|
|
37361
37527
|
}
|
|
37362
|
-
out2.push(
|
|
37528
|
+
out2.push(path79.join(home, ".volta/bin"));
|
|
37363
37529
|
out2.push("/usr/local/bin");
|
|
37364
37530
|
out2.push("/usr/bin");
|
|
37365
|
-
out2.push(
|
|
37366
|
-
out2.push(
|
|
37531
|
+
out2.push(path79.join(home, ".local/bin"));
|
|
37532
|
+
out2.push(path79.join(home, "bin"));
|
|
37367
37533
|
out2.push(...agentInstallBinDirs());
|
|
37368
37534
|
if (process.platform === "win32") {
|
|
37369
37535
|
const { LOCALAPPDATA, APPDATA } = process.env;
|
|
37370
|
-
if (LOCALAPPDATA) out2.push(
|
|
37371
|
-
if (APPDATA) out2.push(
|
|
37536
|
+
if (LOCALAPPDATA) out2.push(path79.join(LOCALAPPDATA, "cursor-agent"));
|
|
37537
|
+
if (APPDATA) out2.push(path79.join(APPDATA, "npm"));
|
|
37372
37538
|
}
|
|
37373
37539
|
return out2.filter((p2) => {
|
|
37374
37540
|
try {
|
|
@@ -37379,7 +37545,7 @@ function knownAgentBinaryDirs() {
|
|
|
37379
37545
|
});
|
|
37380
37546
|
}
|
|
37381
37547
|
function expandPathForAgentBinaries(existingPath) {
|
|
37382
|
-
const existing = new Set(existingPath.split(
|
|
37548
|
+
const existing = new Set(existingPath.split(path79.delimiter).filter((p2) => p2.length > 0));
|
|
37383
37549
|
const additions = [];
|
|
37384
37550
|
for (const dir of knownAgentBinaryDirs()) {
|
|
37385
37551
|
if (!existing.has(dir)) {
|
|
@@ -37388,17 +37554,17 @@ function expandPathForAgentBinaries(existingPath) {
|
|
|
37388
37554
|
}
|
|
37389
37555
|
}
|
|
37390
37556
|
if (additions.length === 0) return existingPath;
|
|
37391
|
-
return [...additions, existingPath].filter((p2) => p2.length > 0).join(
|
|
37557
|
+
return [...additions, existingPath].filter((p2) => p2.length > 0).join(path79.delimiter);
|
|
37392
37558
|
}
|
|
37393
37559
|
|
|
37394
37560
|
// src/commands/host/agent-install.ts
|
|
37395
37561
|
var import_child_process27 = require("child_process");
|
|
37396
|
-
var
|
|
37562
|
+
var os52 = __toESM(require("os"));
|
|
37397
37563
|
function runAgentInstallScript(script, opts = {}) {
|
|
37398
37564
|
const timeoutMs = opts.timeoutMs ?? 18e4;
|
|
37399
37565
|
const scope = opts.logScope ?? "agent-install";
|
|
37400
37566
|
return new Promise((resolve14) => {
|
|
37401
|
-
const home = process.env.HOME ||
|
|
37567
|
+
const home = process.env.HOME || os52.homedir();
|
|
37402
37568
|
const child = (0, import_child_process27.spawn)("sh", ["-c", script], {
|
|
37403
37569
|
env: { ...process.env, HOME: home },
|
|
37404
37570
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -37660,9 +37826,9 @@ async function performAgentSwitch(deps, rawAgentId, fastPath = {}) {
|
|
|
37660
37826
|
}
|
|
37661
37827
|
|
|
37662
37828
|
// src/commands/host/agent-provisioning.ts
|
|
37663
|
-
var
|
|
37664
|
-
var
|
|
37665
|
-
var
|
|
37829
|
+
var fs69 = __toESM(require("fs"));
|
|
37830
|
+
var os53 = __toESM(require("os"));
|
|
37831
|
+
var path80 = __toESM(require("path"));
|
|
37666
37832
|
var PUBLIC_TO_INTERNAL_AGENT = {
|
|
37667
37833
|
claude_code: "claude",
|
|
37668
37834
|
claude: "claude",
|
|
@@ -37679,22 +37845,22 @@ function toInternalAgentId(publicAgentId) {
|
|
|
37679
37845
|
return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
|
|
37680
37846
|
}
|
|
37681
37847
|
function ensureDir(dir) {
|
|
37682
|
-
|
|
37848
|
+
fs69.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
37683
37849
|
}
|
|
37684
37850
|
function writeFile0600(filePath, contents) {
|
|
37685
|
-
ensureDir(
|
|
37686
|
-
|
|
37851
|
+
ensureDir(path80.dirname(filePath));
|
|
37852
|
+
fs69.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
|
|
37687
37853
|
restrictToOwner(filePath);
|
|
37688
37854
|
}
|
|
37689
37855
|
function rmIfExists(filePath) {
|
|
37690
37856
|
try {
|
|
37691
|
-
|
|
37857
|
+
fs69.rmSync(filePath, { force: true });
|
|
37692
37858
|
} catch {
|
|
37693
37859
|
}
|
|
37694
37860
|
}
|
|
37695
37861
|
var claudeProvisioner = {
|
|
37696
37862
|
write(auth, home) {
|
|
37697
|
-
const credentialsJson =
|
|
37863
|
+
const credentialsJson = path80.join(home, ".claude", ".credentials.json");
|
|
37698
37864
|
if (auth.kind === "api_key") {
|
|
37699
37865
|
rmIfExists(credentialsJson);
|
|
37700
37866
|
return { ANTHROPIC_API_KEY: auth.value };
|
|
@@ -37706,8 +37872,8 @@ var claudeProvisioner = {
|
|
|
37706
37872
|
} else {
|
|
37707
37873
|
rmIfExists(credentialsJson);
|
|
37708
37874
|
}
|
|
37709
|
-
const claudeJson =
|
|
37710
|
-
if (!
|
|
37875
|
+
const claudeJson = path80.join(home, ".claude.json");
|
|
37876
|
+
if (!fs69.existsSync(claudeJson)) {
|
|
37711
37877
|
writeFile0600(
|
|
37712
37878
|
claudeJson,
|
|
37713
37879
|
JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
|
|
@@ -37718,7 +37884,7 @@ var claudeProvisioner = {
|
|
|
37718
37884
|
};
|
|
37719
37885
|
var codexProvisioner = {
|
|
37720
37886
|
write(auth, home) {
|
|
37721
|
-
const authJson =
|
|
37887
|
+
const authJson = path80.join(home, ".codex", "auth.json");
|
|
37722
37888
|
if (auth.kind === "api_key") {
|
|
37723
37889
|
writeFile0600(authJson, JSON.stringify({ auth_mode: "apikey", OPENAI_API_KEY: auth.value }));
|
|
37724
37890
|
return { OPENAI_API_KEY: auth.value };
|
|
@@ -37741,7 +37907,7 @@ function codexLoginStamp(raw) {
|
|
|
37741
37907
|
function keepsFresherCodexLogin(authJsonPath, incoming) {
|
|
37742
37908
|
let onDisk;
|
|
37743
37909
|
try {
|
|
37744
|
-
onDisk =
|
|
37910
|
+
onDisk = fs69.readFileSync(authJsonPath, "utf8");
|
|
37745
37911
|
} catch {
|
|
37746
37912
|
return false;
|
|
37747
37913
|
}
|
|
@@ -37752,8 +37918,8 @@ function keepsFresherCodexLogin(authJsonPath, incoming) {
|
|
|
37752
37918
|
}
|
|
37753
37919
|
var geminiProvisioner = {
|
|
37754
37920
|
write(auth, home) {
|
|
37755
|
-
const settingsJson =
|
|
37756
|
-
const oauthCreds =
|
|
37921
|
+
const settingsJson = path80.join(home, ".gemini", "settings.json");
|
|
37922
|
+
const oauthCreds = path80.join(home, ".gemini", "oauth_creds.json");
|
|
37757
37923
|
if (auth.kind === "api_key") {
|
|
37758
37924
|
rmIfExists(oauthCreds);
|
|
37759
37925
|
writeFile0600(settingsJson, '{"security":{"auth":{"selectedType":"gemini-api-key"}}}');
|
|
@@ -37766,7 +37932,7 @@ var geminiProvisioner = {
|
|
|
37766
37932
|
};
|
|
37767
37933
|
var cursorProvisioner = {
|
|
37768
37934
|
write(auth, home) {
|
|
37769
|
-
const authJson =
|
|
37935
|
+
const authJson = path80.join(home, ".config", "cursor", "auth.json");
|
|
37770
37936
|
if (auth.kind === "api_key") {
|
|
37771
37937
|
rmIfExists(authJson);
|
|
37772
37938
|
return { CURSOR_API_KEY: auth.value };
|
|
@@ -37808,22 +37974,22 @@ max_context_size = 262144
|
|
|
37808
37974
|
var kimiProvisioner = {
|
|
37809
37975
|
write(auth, home) {
|
|
37810
37976
|
const credentialsFiles = [
|
|
37811
|
-
|
|
37812
|
-
|
|
37977
|
+
path80.join(home, ".kimi", "credentials", "kimi-code.json"),
|
|
37978
|
+
path80.join(home, ".kimi-code", "credentials", "kimi-code.json")
|
|
37813
37979
|
];
|
|
37814
37980
|
if (auth.kind === "api_key") {
|
|
37815
37981
|
credentialsFiles.forEach(rmIfExists);
|
|
37816
37982
|
return { KIMI_API_KEY: auth.value };
|
|
37817
37983
|
}
|
|
37818
37984
|
credentialsFiles.forEach((f) => writeFile0600(f, auth.value));
|
|
37819
|
-
writeFile0600(
|
|
37985
|
+
writeFile0600(path80.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
|
|
37820
37986
|
return {};
|
|
37821
37987
|
}
|
|
37822
37988
|
};
|
|
37823
37989
|
var coderabbitProvisioner = {
|
|
37824
37990
|
write(auth, home) {
|
|
37825
|
-
const dir =
|
|
37826
|
-
const authJson =
|
|
37991
|
+
const dir = path80.join(home, ".coderabbit");
|
|
37992
|
+
const authJson = path80.join(dir, "auth.json");
|
|
37827
37993
|
if (auth.kind === "api_key") {
|
|
37828
37994
|
rmIfExists(authJson);
|
|
37829
37995
|
return { CODERABBIT_API_KEY: auth.value };
|
|
@@ -37835,13 +38001,13 @@ var coderabbitProvisioner = {
|
|
|
37835
38001
|
try {
|
|
37836
38002
|
const parsed = JSON.parse(value);
|
|
37837
38003
|
if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
|
|
37838
|
-
file =
|
|
38004
|
+
file = path80.basename(parsed.file);
|
|
37839
38005
|
contents = parsed.contents;
|
|
37840
38006
|
}
|
|
37841
38007
|
} catch {
|
|
37842
38008
|
}
|
|
37843
38009
|
}
|
|
37844
|
-
writeFile0600(
|
|
38010
|
+
writeFile0600(path80.join(dir, file), contents);
|
|
37845
38011
|
return {};
|
|
37846
38012
|
}
|
|
37847
38013
|
};
|
|
@@ -37869,7 +38035,7 @@ var UnsupportedAgentError = class extends Error {
|
|
|
37869
38035
|
this.agentId = agentId;
|
|
37870
38036
|
}
|
|
37871
38037
|
};
|
|
37872
|
-
function provisionAgentCredentials(publicAgentId, auth, homeDir2 =
|
|
38038
|
+
function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os53.homedir()) {
|
|
37873
38039
|
const internal = toInternalAgentId(publicAgentId);
|
|
37874
38040
|
if (!internal) throw new UnsupportedAgentError(publicAgentId);
|
|
37875
38041
|
const provisioner = PROVISIONERS[internal];
|
|
@@ -37878,8 +38044,8 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os51.homedir(
|
|
|
37878
38044
|
}
|
|
37879
38045
|
|
|
37880
38046
|
// src/beads/workflow-hint.ts
|
|
37881
|
-
var
|
|
37882
|
-
var
|
|
38047
|
+
var fs70 = __toESM(require("fs"));
|
|
38048
|
+
var path81 = __toESM(require("path"));
|
|
37883
38049
|
var BEADS_HINT_MARKER = "<!-- codeam:beads-workflow -->";
|
|
37884
38050
|
var BEADS_HINT = `${BEADS_HINT_MARKER}
|
|
37885
38051
|
# Beads (bd) \u2014 task tracking + persistent memory (ALWAYS use it)
|
|
@@ -37906,11 +38072,11 @@ function ensureBeadsWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
|
37906
38072
|
try {
|
|
37907
38073
|
let existing = "";
|
|
37908
38074
|
try {
|
|
37909
|
-
existing =
|
|
38075
|
+
existing = fs70.readFileSync(file, "utf8");
|
|
37910
38076
|
} catch {
|
|
37911
38077
|
}
|
|
37912
38078
|
if (existing.includes(BEADS_HINT)) return;
|
|
37913
|
-
|
|
38079
|
+
fs70.mkdirSync(path81.dirname(file), { recursive: true });
|
|
37914
38080
|
let next;
|
|
37915
38081
|
const open = existing.indexOf(BEADS_HINT_MARKER);
|
|
37916
38082
|
const close = open === -1 ? -1 : existing.indexOf(BEADS_HINT_MARKER, open + BEADS_HINT_MARKER.length);
|
|
@@ -37923,40 +38089,40 @@ ${BEADS_HINT}
|
|
|
37923
38089
|
` : `${BEADS_HINT}
|
|
37924
38090
|
`;
|
|
37925
38091
|
}
|
|
37926
|
-
|
|
38092
|
+
fs70.writeFileSync(file, next);
|
|
37927
38093
|
} catch {
|
|
37928
38094
|
}
|
|
37929
38095
|
}
|
|
37930
38096
|
|
|
37931
38097
|
// src/agents/agent-standard.ts
|
|
37932
|
-
var
|
|
37933
|
-
var
|
|
37934
|
-
var
|
|
38098
|
+
var fs71 = __toESM(require("fs"));
|
|
38099
|
+
var path82 = __toESM(require("path"));
|
|
38100
|
+
var os54 = __toESM(require("os"));
|
|
37935
38101
|
function ensureAgentStandard(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
37936
38102
|
try {
|
|
37937
38103
|
let existing = "";
|
|
37938
38104
|
try {
|
|
37939
|
-
existing =
|
|
38105
|
+
existing = fs71.readFileSync(file, "utf8");
|
|
37940
38106
|
} catch {
|
|
37941
38107
|
}
|
|
37942
38108
|
if (existing.includes(AGENT_STANDARD_MARKER)) return;
|
|
37943
|
-
|
|
38109
|
+
fs71.mkdirSync(path82.dirname(file), { recursive: true });
|
|
37944
38110
|
const next = existing.trim() ? `${existing.trimEnd()}
|
|
37945
38111
|
|
|
37946
38112
|
${AGENT_STANDARD_BLOCK}
|
|
37947
38113
|
` : `${AGENT_STANDARD_BLOCK}
|
|
37948
38114
|
`;
|
|
37949
|
-
|
|
38115
|
+
fs71.writeFileSync(file, next);
|
|
37950
38116
|
} catch {
|
|
37951
38117
|
}
|
|
37952
38118
|
}
|
|
37953
38119
|
var _agentStandardSeam = {
|
|
37954
38120
|
isLocalSession: () => isLocalSession(),
|
|
37955
|
-
markerPath: (sessionId) =>
|
|
37956
|
-
exists: (p2) =>
|
|
38121
|
+
markerPath: (sessionId) => path82.join(os54.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
|
|
38122
|
+
exists: (p2) => fs71.existsSync(p2),
|
|
37957
38123
|
write: (p2) => {
|
|
37958
|
-
|
|
37959
|
-
|
|
38124
|
+
fs71.mkdirSync(path82.dirname(p2), { recursive: true });
|
|
38125
|
+
fs71.writeFileSync(p2, "");
|
|
37960
38126
|
}
|
|
37961
38127
|
};
|
|
37962
38128
|
function isClaude(agent) {
|
|
@@ -38691,15 +38857,15 @@ function withholdTrailingPartialFenceMarker(text) {
|
|
|
38691
38857
|
|
|
38692
38858
|
// src/agents/acp/onboarding.ts
|
|
38693
38859
|
var import_child_process28 = require("child_process");
|
|
38694
|
-
var
|
|
38695
|
-
var
|
|
38696
|
-
var
|
|
38860
|
+
var fs73 = __toESM(require("fs"));
|
|
38861
|
+
var os55 = __toESM(require("os"));
|
|
38862
|
+
var path84 = __toESM(require("path"));
|
|
38697
38863
|
var _onboardingSeam = {
|
|
38698
|
-
markerPath: (sessionId) =>
|
|
38699
|
-
exists: (p2) =>
|
|
38864
|
+
markerPath: (sessionId) => path84.join(os55.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
|
|
38865
|
+
exists: (p2) => fs73.existsSync(p2),
|
|
38700
38866
|
write: (p2) => {
|
|
38701
|
-
|
|
38702
|
-
|
|
38867
|
+
fs73.mkdirSync(path84.dirname(p2), { recursive: true });
|
|
38868
|
+
fs73.writeFileSync(p2, "");
|
|
38703
38869
|
},
|
|
38704
38870
|
disabled: () => {
|
|
38705
38871
|
const v = process.env.CODEAM_ONBOARDING_DISABLED;
|
|
@@ -38736,7 +38902,7 @@ function resolveRepoName(cwd) {
|
|
|
38736
38902
|
if (name) return name;
|
|
38737
38903
|
}
|
|
38738
38904
|
}
|
|
38739
|
-
const base =
|
|
38905
|
+
const base = path84.basename(cwd || "");
|
|
38740
38906
|
if (base && !isUuid(base)) return base;
|
|
38741
38907
|
return "this project";
|
|
38742
38908
|
}
|
|
@@ -39128,14 +39294,14 @@ var import_crypto5 = require("crypto");
|
|
|
39128
39294
|
|
|
39129
39295
|
// src/services/turn-files/git-changeset.ts
|
|
39130
39296
|
var import_child_process29 = require("child_process");
|
|
39131
|
-
var
|
|
39132
|
-
var
|
|
39133
|
-
var
|
|
39297
|
+
var fs75 = __toESM(require("fs/promises"));
|
|
39298
|
+
var import_fs9 = require("fs");
|
|
39299
|
+
var path86 = __toESM(require("path"));
|
|
39134
39300
|
|
|
39135
39301
|
// src/services/turn-files/review-ignore.ts
|
|
39136
39302
|
var import_ignore2 = __toESM(require("ignore"));
|
|
39137
|
-
var
|
|
39138
|
-
var
|
|
39303
|
+
var fs74 = __toESM(require("fs"));
|
|
39304
|
+
var path85 = __toESM(require("path"));
|
|
39139
39305
|
var CURATED_REVIEW_IGNORE = [
|
|
39140
39306
|
// Google Cloud SDK (the incident) — installs a huge python tree.
|
|
39141
39307
|
"google-cloud-sdk/",
|
|
@@ -39179,7 +39345,7 @@ var CURATED_REVIEW_IGNORE = [
|
|
|
39179
39345
|
function makeReviewIgnore(repoRoot) {
|
|
39180
39346
|
const ig = (0, import_ignore2.default)().add(CURATED_REVIEW_IGNORE);
|
|
39181
39347
|
try {
|
|
39182
|
-
const custom =
|
|
39348
|
+
const custom = fs74.readFileSync(path85.join(repoRoot, ".codeam", "reviewignore"), "utf8");
|
|
39183
39349
|
ig.add(custom);
|
|
39184
39350
|
} catch {
|
|
39185
39351
|
}
|
|
@@ -39214,7 +39380,7 @@ async function collectRepoChangeset(opts) {
|
|
|
39214
39380
|
const rows = parseStatus(status2).filter(
|
|
39215
39381
|
(row) => !isIgnoredFilePath(row.filePath) && !reviewIgnore(row.filePath) && // A socket, FIFO or device node is never a change to review (a
|
|
39216
39382
|
// `cc-socks/1522.sock` reached the Files tab).
|
|
39217
|
-
isReviewablePath(
|
|
39383
|
+
isReviewablePath(path86.join(opts.repoRoot, row.filePath))
|
|
39218
39384
|
);
|
|
39219
39385
|
const MAX_CHANGESET_FILES = Math.max(1, Number(process.env.CODEAM_MAX_CHANGESET_FILES ?? 500));
|
|
39220
39386
|
const truncated = rows.length > MAX_CHANGESET_FILES;
|
|
@@ -39231,7 +39397,7 @@ async function collectRepoChangeset(opts) {
|
|
|
39231
39397
|
let stats;
|
|
39232
39398
|
if (!truncated && row.fileStatus === "added" && numstatEntry === void 0) {
|
|
39233
39399
|
const lineCount = await readUntrackedLineCount(
|
|
39234
|
-
|
|
39400
|
+
path86.join(opts.repoRoot, row.filePath)
|
|
39235
39401
|
);
|
|
39236
39402
|
stats = { added: lineCount, removed: 0 };
|
|
39237
39403
|
} else {
|
|
@@ -39262,7 +39428,7 @@ function readUntrackedLineCount(absPath) {
|
|
|
39262
39428
|
}
|
|
39263
39429
|
async function defaultReadUntrackedLineCount(absPath) {
|
|
39264
39430
|
try {
|
|
39265
|
-
const content = await
|
|
39431
|
+
const content = await fs75.readFile(absPath, "utf8");
|
|
39266
39432
|
let count = 0;
|
|
39267
39433
|
let pos = -1;
|
|
39268
39434
|
while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
|
|
@@ -39354,7 +39520,7 @@ function defaultRunGit(cwd, args2) {
|
|
|
39354
39520
|
});
|
|
39355
39521
|
}
|
|
39356
39522
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
39357
|
-
const
|
|
39523
|
+
const fs99 = await import("fs/promises");
|
|
39358
39524
|
const out2 = [];
|
|
39359
39525
|
await walk2(workingDir, 0);
|
|
39360
39526
|
return out2;
|
|
@@ -39362,7 +39528,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
39362
39528
|
if (depth2 > maxDepth) return;
|
|
39363
39529
|
let entries2 = [];
|
|
39364
39530
|
try {
|
|
39365
|
-
const dirents = await
|
|
39531
|
+
const dirents = await fs99.readdir(dir, { withFileTypes: true });
|
|
39366
39532
|
entries2 = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
39367
39533
|
} catch {
|
|
39368
39534
|
return;
|
|
@@ -39373,8 +39539,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
39373
39539
|
if (hasGit) {
|
|
39374
39540
|
out2.push({
|
|
39375
39541
|
repoRoot: dir,
|
|
39376
|
-
repoPath:
|
|
39377
|
-
repoName:
|
|
39542
|
+
repoPath: path86.relative(workingDir, dir),
|
|
39543
|
+
repoName: path86.basename(dir)
|
|
39378
39544
|
});
|
|
39379
39545
|
return;
|
|
39380
39546
|
}
|
|
@@ -39382,13 +39548,13 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
39382
39548
|
if (!entry.isDirectory) continue;
|
|
39383
39549
|
if (entry.name === "node_modules") continue;
|
|
39384
39550
|
if (entry.name === "dist" || entry.name === "build") continue;
|
|
39385
|
-
await walk2(
|
|
39551
|
+
await walk2(path86.join(dir, entry.name), depth2 + 1);
|
|
39386
39552
|
}
|
|
39387
39553
|
}
|
|
39388
39554
|
}
|
|
39389
39555
|
function isReviewablePath(absPath) {
|
|
39390
39556
|
try {
|
|
39391
|
-
const st3 = (0,
|
|
39557
|
+
const st3 = (0, import_fs9.lstatSync)(absPath);
|
|
39392
39558
|
return st3.isFile() || st3.isSymbolicLink();
|
|
39393
39559
|
} catch {
|
|
39394
39560
|
return true;
|
|
@@ -39396,9 +39562,9 @@ function isReviewablePath(absPath) {
|
|
|
39396
39562
|
}
|
|
39397
39563
|
|
|
39398
39564
|
// src/services/turn-files/files-outbox.ts
|
|
39399
|
-
var
|
|
39400
|
-
var
|
|
39401
|
-
var
|
|
39565
|
+
var fs76 = __toESM(require("fs/promises"));
|
|
39566
|
+
var path87 = __toESM(require("path"));
|
|
39567
|
+
var import_os14 = require("os");
|
|
39402
39568
|
var HOME_OUTBOX_DIR = ".codeam/outbox";
|
|
39403
39569
|
var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
39404
39570
|
var BACKOFF_STEPS_MS = [
|
|
@@ -39430,16 +39596,16 @@ var FilesOutbox = class {
|
|
|
39430
39596
|
backoffIndex = 0;
|
|
39431
39597
|
stopped = false;
|
|
39432
39598
|
constructor(opts) {
|
|
39433
|
-
const base = opts.baseDir ??
|
|
39434
|
-
this.filePath =
|
|
39599
|
+
const base = opts.baseDir ?? path87.join(homeDir(), HOME_OUTBOX_DIR);
|
|
39600
|
+
this.filePath = path87.join(base, `${opts.sessionId}.jsonl`);
|
|
39435
39601
|
this.post = opts.post;
|
|
39436
39602
|
this.autoSchedule = opts.autoSchedule !== false;
|
|
39437
39603
|
}
|
|
39438
39604
|
/** Persist the entry to disk and trigger a flush. Returns once the
|
|
39439
39605
|
* line is durable on disk (not once the POST succeeds). */
|
|
39440
39606
|
async enqueue(entry) {
|
|
39441
|
-
await
|
|
39442
|
-
await
|
|
39607
|
+
await fs76.mkdir(path87.dirname(this.filePath), { recursive: true });
|
|
39608
|
+
await fs76.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
|
|
39443
39609
|
this.backoffIndex = 0;
|
|
39444
39610
|
if (this.autoSchedule) this.scheduleFlush(0);
|
|
39445
39611
|
}
|
|
@@ -39530,7 +39696,7 @@ var FilesOutbox = class {
|
|
|
39530
39696
|
async readAll() {
|
|
39531
39697
|
let raw = "";
|
|
39532
39698
|
try {
|
|
39533
|
-
raw = await
|
|
39699
|
+
raw = await fs76.readFile(this.filePath, "utf8");
|
|
39534
39700
|
} catch {
|
|
39535
39701
|
return [];
|
|
39536
39702
|
}
|
|
@@ -39554,12 +39720,12 @@ var FilesOutbox = class {
|
|
|
39554
39720
|
async rewrite(entries2) {
|
|
39555
39721
|
const tmpPath = `${this.filePath}.${process.pid}.tmp`;
|
|
39556
39722
|
if (entries2.length === 0) {
|
|
39557
|
-
await
|
|
39723
|
+
await fs76.unlink(this.filePath).catch(() => void 0);
|
|
39558
39724
|
return;
|
|
39559
39725
|
}
|
|
39560
39726
|
const payload = entries2.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
39561
|
-
await
|
|
39562
|
-
await
|
|
39727
|
+
await fs76.writeFile(tmpPath, payload, "utf8");
|
|
39728
|
+
await fs76.rename(tmpPath, this.filePath);
|
|
39563
39729
|
}
|
|
39564
39730
|
};
|
|
39565
39731
|
function applyJitter(ms) {
|
|
@@ -39567,7 +39733,7 @@ function applyJitter(ms) {
|
|
|
39567
39733
|
return Math.round(ms * factor);
|
|
39568
39734
|
}
|
|
39569
39735
|
function homeDir() {
|
|
39570
|
-
return process.env.HOME ?? process.env.USERPROFILE ?? (0,
|
|
39736
|
+
return process.env.HOME ?? process.env.USERPROFILE ?? (0, import_os14.tmpdir)();
|
|
39571
39737
|
}
|
|
39572
39738
|
|
|
39573
39739
|
// src/services/turn-files/turn-file-aggregator.ts
|
|
@@ -39907,27 +40073,27 @@ async function readActiveConversationMarker(cwd, homeDir2) {
|
|
|
39907
40073
|
}
|
|
39908
40074
|
|
|
39909
40075
|
// src/services/turn-marker.ts
|
|
39910
|
-
var
|
|
39911
|
-
var
|
|
39912
|
-
var
|
|
40076
|
+
var fs78 = __toESM(require("fs"));
|
|
40077
|
+
var os57 = __toESM(require("os"));
|
|
40078
|
+
var path89 = __toESM(require("path"));
|
|
39913
40079
|
var depth = 0;
|
|
39914
40080
|
function codeamHome() {
|
|
39915
|
-
return
|
|
40081
|
+
return path89.join(os57.homedir(), ".codeam");
|
|
39916
40082
|
}
|
|
39917
40083
|
function turnMarkerPath(pid = process.pid, home = codeamHome()) {
|
|
39918
|
-
return
|
|
40084
|
+
return path89.join(home, "turns", String(pid));
|
|
39919
40085
|
}
|
|
39920
40086
|
function mark() {
|
|
39921
40087
|
try {
|
|
39922
40088
|
const file = turnMarkerPath();
|
|
39923
|
-
|
|
39924
|
-
|
|
40089
|
+
fs78.mkdirSync(path89.dirname(file), { recursive: true });
|
|
40090
|
+
fs78.writeFileSync(file, String(Date.now()));
|
|
39925
40091
|
} catch {
|
|
39926
40092
|
}
|
|
39927
40093
|
}
|
|
39928
40094
|
function clear() {
|
|
39929
40095
|
try {
|
|
39930
|
-
|
|
40096
|
+
fs78.rmSync(turnMarkerPath(), { force: true });
|
|
39931
40097
|
} catch {
|
|
39932
40098
|
}
|
|
39933
40099
|
}
|
|
@@ -39942,7 +40108,7 @@ async function withTurnMarker(fn) {
|
|
|
39942
40108
|
function isProcessMidTurn(pid, home) {
|
|
39943
40109
|
if (!pid) return false;
|
|
39944
40110
|
try {
|
|
39945
|
-
return
|
|
40111
|
+
return fs78.existsSync(turnMarkerPath(pid, home));
|
|
39946
40112
|
} catch {
|
|
39947
40113
|
return false;
|
|
39948
40114
|
}
|
|
@@ -39950,8 +40116,8 @@ function isProcessMidTurn(pid, home) {
|
|
|
39950
40116
|
|
|
39951
40117
|
// src/packs/gates.ts
|
|
39952
40118
|
var import_node_child_process28 = require("child_process");
|
|
39953
|
-
var
|
|
39954
|
-
var
|
|
40119
|
+
var fs79 = __toESM(require("fs"));
|
|
40120
|
+
var path90 = __toESM(require("path"));
|
|
39955
40121
|
var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((resolve14) => {
|
|
39956
40122
|
(0, import_node_child_process28.execFile)(
|
|
39957
40123
|
file,
|
|
@@ -40001,7 +40167,7 @@ async function changedFiles(run3, cwd, from, to) {
|
|
|
40001
40167
|
}
|
|
40002
40168
|
function readWorkspaceFile(cwd, relPath) {
|
|
40003
40169
|
try {
|
|
40004
|
-
return
|
|
40170
|
+
return fs79.readFileSync(path90.join(cwd, relPath), "utf8");
|
|
40005
40171
|
} catch {
|
|
40006
40172
|
return null;
|
|
40007
40173
|
}
|
|
@@ -40010,14 +40176,14 @@ var NO_TEST_PLACEHOLDER = 'echo "Error: no test specified"';
|
|
|
40010
40176
|
var CHECKS_TIMEOUT_MS = 5 * 6e4;
|
|
40011
40177
|
function detectChecksCommand(cwd) {
|
|
40012
40178
|
try {
|
|
40013
|
-
const cfg = JSON.parse(
|
|
40179
|
+
const cfg = JSON.parse(fs79.readFileSync(path90.join(cwd, ".codeam", "pack.json"), "utf8"));
|
|
40014
40180
|
if (typeof cfg.checksCommand === "string" && cfg.checksCommand.trim().length > 0) {
|
|
40015
40181
|
return cfg.checksCommand.trim();
|
|
40016
40182
|
}
|
|
40017
40183
|
} catch {
|
|
40018
40184
|
}
|
|
40019
40185
|
try {
|
|
40020
|
-
const pkg = JSON.parse(
|
|
40186
|
+
const pkg = JSON.parse(fs79.readFileSync(path90.join(cwd, "package.json"), "utf8"));
|
|
40021
40187
|
const test = pkg.scripts?.test;
|
|
40022
40188
|
if (typeof test === "string" && test.trim().length > 0 && !test.includes(NO_TEST_PLACEHOLDER)) {
|
|
40023
40189
|
return "npm test";
|
|
@@ -40035,39 +40201,39 @@ ${res.stderr}`.trim();
|
|
|
40035
40201
|
}
|
|
40036
40202
|
|
|
40037
40203
|
// src/packs/run-store.ts
|
|
40038
|
-
var
|
|
40039
|
-
var
|
|
40204
|
+
var fs80 = __toESM(require("fs"));
|
|
40205
|
+
var path91 = __toESM(require("path"));
|
|
40040
40206
|
var crypto5 = __toESM(require("crypto"));
|
|
40041
40207
|
function packsDir(cwd) {
|
|
40042
|
-
return
|
|
40208
|
+
return path91.join(cwd, ".codeam", "packs");
|
|
40043
40209
|
}
|
|
40044
40210
|
function runDir(cwd, runId) {
|
|
40045
|
-
return
|
|
40211
|
+
return path91.join(packsDir(cwd), runId);
|
|
40046
40212
|
}
|
|
40047
40213
|
function newRunId() {
|
|
40048
40214
|
return `pk_${Date.now().toString(36)}_${crypto5.randomBytes(4).toString("hex")}`;
|
|
40049
40215
|
}
|
|
40050
40216
|
function writeJsonAtomic(file, value) {
|
|
40051
|
-
|
|
40217
|
+
fs80.mkdirSync(path91.dirname(file), { recursive: true });
|
|
40052
40218
|
const tmp = `${file}.tmp`;
|
|
40053
|
-
|
|
40054
|
-
|
|
40219
|
+
fs80.writeFileSync(tmp, JSON.stringify(value, null, 2));
|
|
40220
|
+
fs80.renameSync(tmp, file);
|
|
40055
40221
|
}
|
|
40056
40222
|
function saveRun(cwd, state) {
|
|
40057
|
-
writeJsonAtomic(
|
|
40223
|
+
writeJsonAtomic(path91.join(runDir(cwd, state.runId), "run.json"), state);
|
|
40058
40224
|
}
|
|
40059
40225
|
function saveStageHandoff(cwd, runId, stageIndex, role, handoff) {
|
|
40060
40226
|
const name = `${String(stageIndex + 1).padStart(2, "0")}-${role}.json`;
|
|
40061
|
-
writeJsonAtomic(
|
|
40227
|
+
writeJsonAtomic(path91.join(runDir(cwd, runId), name), handoff);
|
|
40062
40228
|
}
|
|
40063
40229
|
function loadLatestRun(cwd) {
|
|
40064
40230
|
try {
|
|
40065
40231
|
const dir = packsDir(cwd);
|
|
40066
|
-
const entries2 =
|
|
40232
|
+
const entries2 = fs80.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
40067
40233
|
for (let i = entries2.length - 1; i >= 0; i--) {
|
|
40068
|
-
const file =
|
|
40234
|
+
const file = path91.join(dir, entries2[i], "run.json");
|
|
40069
40235
|
try {
|
|
40070
|
-
const parsed = JSON.parse(
|
|
40236
|
+
const parsed = JSON.parse(fs80.readFileSync(file, "utf8"));
|
|
40071
40237
|
if (parsed && typeof parsed.runId === "string") return parsed;
|
|
40072
40238
|
} catch {
|
|
40073
40239
|
}
|
|
@@ -40078,17 +40244,17 @@ function loadLatestRun(cwd) {
|
|
|
40078
40244
|
}
|
|
40079
40245
|
function ensureLedgerIgnored(cwd) {
|
|
40080
40246
|
try {
|
|
40081
|
-
const gitDir =
|
|
40082
|
-
if (!
|
|
40083
|
-
const exclude =
|
|
40247
|
+
const gitDir = path91.join(cwd, ".git");
|
|
40248
|
+
if (!fs80.existsSync(gitDir)) return;
|
|
40249
|
+
const exclude = path91.join(gitDir, "info", "exclude");
|
|
40084
40250
|
let existing = "";
|
|
40085
40251
|
try {
|
|
40086
|
-
existing =
|
|
40252
|
+
existing = fs80.readFileSync(exclude, "utf8");
|
|
40087
40253
|
} catch {
|
|
40088
40254
|
}
|
|
40089
40255
|
if (existing.includes(".codeam/packs/")) return;
|
|
40090
|
-
|
|
40091
|
-
|
|
40256
|
+
fs80.mkdirSync(path91.dirname(exclude), { recursive: true });
|
|
40257
|
+
fs80.writeFileSync(exclude, `${existing.trimEnd()}
|
|
40092
40258
|
.codeam/packs/
|
|
40093
40259
|
`.trimStart());
|
|
40094
40260
|
} catch {
|
|
@@ -41069,20 +41235,20 @@ async function mcpRouter() {
|
|
|
41069
41235
|
}
|
|
41070
41236
|
|
|
41071
41237
|
// src/integrations/mcp-secrets.ts
|
|
41072
|
-
var
|
|
41073
|
-
var
|
|
41074
|
-
var
|
|
41238
|
+
var fs82 = __toESM(require("fs"));
|
|
41239
|
+
var os59 = __toESM(require("os"));
|
|
41240
|
+
var path93 = __toESM(require("path"));
|
|
41075
41241
|
var MCP_SECRETS_FILE_ENV = "CODEAM_MCP_SECRETS_FILE";
|
|
41076
41242
|
function mcpSecretsDir() {
|
|
41077
|
-
return
|
|
41243
|
+
return path93.join(os59.homedir(), ".codeam", "mcp-secrets");
|
|
41078
41244
|
}
|
|
41079
41245
|
function mcpSecretsPath(scope, pid = process.pid) {
|
|
41080
|
-
return
|
|
41246
|
+
return path93.join(mcpSecretsDir(), `${pid}-${scope}.json`);
|
|
41081
41247
|
}
|
|
41082
41248
|
var registeredForCleanup = /* @__PURE__ */ new Set();
|
|
41083
41249
|
function readFileVars(file) {
|
|
41084
41250
|
try {
|
|
41085
|
-
const parsed = JSON.parse(
|
|
41251
|
+
const parsed = JSON.parse(fs82.readFileSync(file, "utf8"));
|
|
41086
41252
|
if (!parsed || typeof parsed !== "object") return {};
|
|
41087
41253
|
const out2 = {};
|
|
41088
41254
|
for (const [k2, v] of Object.entries(parsed)) {
|
|
@@ -41104,7 +41270,7 @@ function pidAlive2(pid) {
|
|
|
41104
41270
|
function pruneStale(dir) {
|
|
41105
41271
|
let names = [];
|
|
41106
41272
|
try {
|
|
41107
|
-
names =
|
|
41273
|
+
names = fs82.readdirSync(dir);
|
|
41108
41274
|
} catch {
|
|
41109
41275
|
return;
|
|
41110
41276
|
}
|
|
@@ -41114,25 +41280,25 @@ function pruneStale(dir) {
|
|
|
41114
41280
|
const pid = Number(m[1]);
|
|
41115
41281
|
if (pid === process.pid || pidAlive2(pid)) continue;
|
|
41116
41282
|
try {
|
|
41117
|
-
|
|
41283
|
+
fs82.unlinkSync(path93.join(dir, name));
|
|
41118
41284
|
} catch {
|
|
41119
41285
|
}
|
|
41120
41286
|
}
|
|
41121
41287
|
}
|
|
41122
41288
|
function writeMcpSecrets(vars, file) {
|
|
41123
41289
|
try {
|
|
41124
|
-
const dir =
|
|
41125
|
-
|
|
41290
|
+
const dir = path93.dirname(file);
|
|
41291
|
+
fs82.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
41126
41292
|
pruneStale(dir);
|
|
41127
41293
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
41128
|
-
|
|
41129
|
-
|
|
41130
|
-
|
|
41294
|
+
fs82.writeFileSync(tmp, JSON.stringify(vars), { mode: 384 });
|
|
41295
|
+
fs82.renameSync(tmp, file);
|
|
41296
|
+
fs82.chmodSync(file, 384);
|
|
41131
41297
|
if (!registeredForCleanup.has(file)) {
|
|
41132
41298
|
registeredForCleanup.add(file);
|
|
41133
41299
|
process.once("exit", () => {
|
|
41134
41300
|
try {
|
|
41135
|
-
|
|
41301
|
+
fs82.unlinkSync(file);
|
|
41136
41302
|
} catch {
|
|
41137
41303
|
}
|
|
41138
41304
|
});
|
|
@@ -41218,11 +41384,11 @@ function previewMcpServer(bridge) {
|
|
|
41218
41384
|
};
|
|
41219
41385
|
}
|
|
41220
41386
|
function httpCall(baseUrl, token) {
|
|
41221
|
-
return async (
|
|
41387
|
+
return async (path114, method, body, timeoutMs) => {
|
|
41222
41388
|
const ac = new AbortController();
|
|
41223
41389
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
41224
41390
|
try {
|
|
41225
|
-
const res = await fetch(`${baseUrl}${
|
|
41391
|
+
const res = await fetch(`${baseUrl}${path114}`, {
|
|
41226
41392
|
method,
|
|
41227
41393
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
41228
41394
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -41350,11 +41516,11 @@ function scratchMcpServer(bridge) {
|
|
|
41350
41516
|
};
|
|
41351
41517
|
}
|
|
41352
41518
|
function httpCall2(baseUrl, token) {
|
|
41353
|
-
return async (
|
|
41519
|
+
return async (path114, method, body, timeoutMs) => {
|
|
41354
41520
|
const ac = new AbortController();
|
|
41355
41521
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
41356
41522
|
try {
|
|
41357
|
-
const res = await fetch(`${baseUrl}${
|
|
41523
|
+
const res = await fetch(`${baseUrl}${path114}`, {
|
|
41358
41524
|
method,
|
|
41359
41525
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
41360
41526
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -43939,6 +44105,7 @@ async function runAcpSession(opts) {
|
|
|
43939
44105
|
try {
|
|
43940
44106
|
handshake = await client3.start();
|
|
43941
44107
|
} catch (startErr) {
|
|
44108
|
+
opts.onHandshakeSettled?.();
|
|
43942
44109
|
const detail = describeError(startErr);
|
|
43943
44110
|
log.warn("acpRunner", `ACP start failed for ${opts.agent}: ${detail}`);
|
|
43944
44111
|
await surfaceStartupFailure({
|
|
@@ -43953,6 +44120,7 @@ async function runAcpSession(opts) {
|
|
|
43953
44120
|
});
|
|
43954
44121
|
return;
|
|
43955
44122
|
}
|
|
44123
|
+
opts.onHandshakeSettled?.();
|
|
43956
44124
|
let acpSessionId = handshake.sessionId;
|
|
43957
44125
|
const { initialize, model: handshakeModel, tier: handshakeTier } = handshake;
|
|
43958
44126
|
let agentCaps = initialize.agentCapabilities;
|
|
@@ -44257,17 +44425,17 @@ async function runAcpSession(opts) {
|
|
|
44257
44425
|
switchCredentialEnv = provisionAgentCredentials(agentId, auth);
|
|
44258
44426
|
},
|
|
44259
44427
|
provisionHouseProxy: ({ baseUrl, token, model, managedAgentId }) => {
|
|
44260
|
-
const claudeConfigDir2 =
|
|
44261
|
-
|
|
44428
|
+
const claudeConfigDir2 = path96.join(
|
|
44429
|
+
os61.homedir(),
|
|
44262
44430
|
".codeam",
|
|
44263
44431
|
"house-claude",
|
|
44264
44432
|
`switch-${opts.pluginId}`
|
|
44265
44433
|
);
|
|
44266
44434
|
try {
|
|
44267
|
-
|
|
44435
|
+
fs85.mkdirSync(claudeConfigDir2, { recursive: true, mode: 448 });
|
|
44268
44436
|
} catch {
|
|
44269
44437
|
}
|
|
44270
|
-
const memoryFile =
|
|
44438
|
+
const memoryFile = path96.join(claudeConfigDir2, "CLAUDE.md");
|
|
44271
44439
|
ensureBeadsWorkflowHint(void 0, memoryFile);
|
|
44272
44440
|
ensureAgentStandard(void 0, memoryFile);
|
|
44273
44441
|
if (isScratchWorkspace(process.cwd())) ensureScratchWorkflowHint(void 0, memoryFile);
|
|
@@ -45498,9 +45666,9 @@ function pickPinnedSession(pinnedId, listSessions2) {
|
|
|
45498
45666
|
}
|
|
45499
45667
|
|
|
45500
45668
|
// src/agents/retired-proxy-cleanup.ts
|
|
45501
|
-
var
|
|
45502
|
-
var
|
|
45503
|
-
var
|
|
45669
|
+
var fs86 = __toESM(require("fs"));
|
|
45670
|
+
var path97 = __toESM(require("path"));
|
|
45671
|
+
var os62 = __toESM(require("os"));
|
|
45504
45672
|
var RETIRED_PROXY_RE = /^https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):8787(?:[/?#]|$)/i;
|
|
45505
45673
|
var HEADROOM_CMD_RE = /(^|[\s/"'])headroom(\s|$)/i;
|
|
45506
45674
|
var MARKETPLACE_KEY = "headroom-marketplace";
|
|
@@ -45509,12 +45677,12 @@ function isHeadroomHook(group) {
|
|
|
45509
45677
|
(h) => typeof h?.command === "string" && HEADROOM_CMD_RE.test(h.command)
|
|
45510
45678
|
);
|
|
45511
45679
|
}
|
|
45512
|
-
function sanitizeRetiredProxyConfig(homeDir2 =
|
|
45680
|
+
function sanitizeRetiredProxyConfig(homeDir2 = os62.homedir()) {
|
|
45513
45681
|
const out2 = { inspected: false, changed: false, removed: [] };
|
|
45514
|
-
const file =
|
|
45682
|
+
const file = path97.join(homeDir2, ".claude", "settings.json");
|
|
45515
45683
|
let parsed;
|
|
45516
45684
|
try {
|
|
45517
|
-
parsed = JSON.parse(
|
|
45685
|
+
parsed = JSON.parse(fs86.readFileSync(file, "utf8"));
|
|
45518
45686
|
} catch {
|
|
45519
45687
|
return out2;
|
|
45520
45688
|
}
|
|
@@ -45556,9 +45724,9 @@ function sanitizeRetiredProxyConfig(homeDir2 = os60.homedir()) {
|
|
|
45556
45724
|
if (!out2.changed) return out2;
|
|
45557
45725
|
try {
|
|
45558
45726
|
const tmp = `${file}.codeam.tmp`;
|
|
45559
|
-
|
|
45727
|
+
fs86.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
|
|
45560
45728
|
`, { mode: 384 });
|
|
45561
|
-
|
|
45729
|
+
fs86.renameSync(tmp, file);
|
|
45562
45730
|
} catch {
|
|
45563
45731
|
out2.changed = false;
|
|
45564
45732
|
}
|
|
@@ -46090,7 +46258,7 @@ var AcpDriver = class {
|
|
|
46090
46258
|
};
|
|
46091
46259
|
|
|
46092
46260
|
// src/baton/transcript-mirror.ts
|
|
46093
|
-
var
|
|
46261
|
+
var fs87 = __toESM(require("fs"));
|
|
46094
46262
|
var TranscriptMirror = class {
|
|
46095
46263
|
constructor(deps) {
|
|
46096
46264
|
this.deps = deps;
|
|
@@ -46184,7 +46352,7 @@ var TranscriptMirror = class {
|
|
|
46184
46352
|
}
|
|
46185
46353
|
};
|
|
46186
46354
|
function defaultWatch(file, onChange) {
|
|
46187
|
-
const w3 =
|
|
46355
|
+
const w3 = fs87.watch(file, { persistent: false }, () => onChange());
|
|
46188
46356
|
return () => w3.close();
|
|
46189
46357
|
}
|
|
46190
46358
|
|
|
@@ -46530,16 +46698,16 @@ function keepDeviceAwake(deps = {}) {
|
|
|
46530
46698
|
}
|
|
46531
46699
|
|
|
46532
46700
|
// src/agents/claude/onboarding.ts
|
|
46533
|
-
var
|
|
46534
|
-
var
|
|
46535
|
-
var
|
|
46701
|
+
var fs88 = __toESM(require("fs"));
|
|
46702
|
+
var os64 = __toESM(require("os"));
|
|
46703
|
+
var path98 = __toESM(require("path"));
|
|
46536
46704
|
var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
|
|
46537
46705
|
function ensureClaudeOnboarded(cwd) {
|
|
46538
46706
|
try {
|
|
46539
|
-
const file =
|
|
46707
|
+
const file = path98.join(os64.homedir(), ".claude.json");
|
|
46540
46708
|
let config = {};
|
|
46541
46709
|
try {
|
|
46542
|
-
config = JSON.parse(
|
|
46710
|
+
config = JSON.parse(fs88.readFileSync(file, "utf8"));
|
|
46543
46711
|
} catch {
|
|
46544
46712
|
}
|
|
46545
46713
|
let changed = false;
|
|
@@ -46564,8 +46732,8 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
46564
46732
|
}
|
|
46565
46733
|
}
|
|
46566
46734
|
if (!changed) return;
|
|
46567
|
-
|
|
46568
|
-
|
|
46735
|
+
fs88.mkdirSync(path98.dirname(file), { recursive: true });
|
|
46736
|
+
fs88.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
46569
46737
|
log.info(
|
|
46570
46738
|
"claude",
|
|
46571
46739
|
`pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
|
|
@@ -46576,6 +46744,7 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
46576
46744
|
}
|
|
46577
46745
|
|
|
46578
46746
|
// src/commands/start.ts
|
|
46747
|
+
var BEADS_AFTER_HANDSHAKE_CAP_MS = 6e4;
|
|
46579
46748
|
async function start(requestedAgent, presetSession) {
|
|
46580
46749
|
installRelayCrashGuards();
|
|
46581
46750
|
showIntro();
|
|
@@ -46614,6 +46783,10 @@ async function start(requestedAgent, presetSession) {
|
|
|
46614
46783
|
if (!session.agent) {
|
|
46615
46784
|
throw new Error("Active session has no agent \u2014 re-pair with `codeam pair`.");
|
|
46616
46785
|
}
|
|
46786
|
+
if (!isLocalSession() && session.agent === "claude") {
|
|
46787
|
+
const claudeBinary = resolveClaudeNativeBinary();
|
|
46788
|
+
if (claudeBinary) prefetchIntoPageCache(claudeBinary);
|
|
46789
|
+
}
|
|
46617
46790
|
const pluginId = session.pluginId ?? ensurePluginId();
|
|
46618
46791
|
showInfo(`${session.userName} \xB7 ${import_picocolors3.default.cyan(session.plan)}`);
|
|
46619
46792
|
showInfo(`Launching ${AGENT_REGISTRY[session.agent].displayName}...
|
|
@@ -46670,6 +46843,22 @@ async function start(requestedAgent, presetSession) {
|
|
|
46670
46843
|
}
|
|
46671
46844
|
}
|
|
46672
46845
|
purgeExports();
|
|
46846
|
+
const releaseStartupMark = markAgentStarting();
|
|
46847
|
+
process.once("exit", releaseStartupMark);
|
|
46848
|
+
let settleOwnHandshake = () => void 0;
|
|
46849
|
+
const ownHandshakeSettled = new Promise((resolve14) => {
|
|
46850
|
+
settleOwnHandshake = resolve14;
|
|
46851
|
+
});
|
|
46852
|
+
const releaseBeads = () => {
|
|
46853
|
+
releaseStartupMark();
|
|
46854
|
+
settleOwnHandshake();
|
|
46855
|
+
};
|
|
46856
|
+
const agentHandshakeSettled = Promise.race([
|
|
46857
|
+
ownHandshakeSettled.then(
|
|
46858
|
+
() => waitForNoAgentStarting({ timeoutMs: BEADS_AFTER_HANDSHAKE_CAP_MS })
|
|
46859
|
+
),
|
|
46860
|
+
new Promise((resolve14) => setTimeout(resolve14, BEADS_AFTER_HANDSHAKE_CAP_MS).unref())
|
|
46861
|
+
]);
|
|
46673
46862
|
const beadsReady = provisionBeadsForStart({
|
|
46674
46863
|
sessionId: session.id,
|
|
46675
46864
|
pluginId,
|
|
@@ -46677,7 +46866,8 @@ async function start(requestedAgent, presetSession) {
|
|
|
46677
46866
|
cwd,
|
|
46678
46867
|
// Wire this session's agent natively via `bd setup <recipe> --global` so
|
|
46679
46868
|
// the agent actually uses bd (D12 — REVISED). Covers BOTH ACP and PTY.
|
|
46680
|
-
agents: [session.agent]
|
|
46869
|
+
agents: [session.agent],
|
|
46870
|
+
deferUntil: agentHandshakeSettled
|
|
46681
46871
|
}).then((started) => {
|
|
46682
46872
|
beads = started;
|
|
46683
46873
|
return started;
|
|
@@ -46746,12 +46936,13 @@ async function start(requestedAgent, presetSession) {
|
|
|
46746
46936
|
if (gateTimer) clearTimeout(gateTimer);
|
|
46747
46937
|
log.info(
|
|
46748
46938
|
"beads",
|
|
46749
|
-
|
|
46939
|
+
"agent-spawn gate released (beads waits for the agent handshake); project deps provisioned"
|
|
46750
46940
|
);
|
|
46751
46941
|
}
|
|
46752
46942
|
const releaseKeepAwake = keepDeviceAwake();
|
|
46753
46943
|
process.once("exit", releaseKeepAwake);
|
|
46754
46944
|
if (isLocalSession() && requiresAcp(session.agent)) {
|
|
46945
|
+
releaseBeads();
|
|
46755
46946
|
const adapter = await resolveAcpAdapterWithRetry(session.agent);
|
|
46756
46947
|
const batonCapable = runtimeSupportsBaton(createRuntimeStrategy(session.agent));
|
|
46757
46948
|
if (batonCapable && adapter && session.pluginAuthToken) {
|
|
@@ -46815,6 +47006,7 @@ async function start(requestedAgent, presetSession) {
|
|
|
46815
47006
|
adapter,
|
|
46816
47007
|
cwd,
|
|
46817
47008
|
getBeads,
|
|
47009
|
+
onHandshakeSettled: releaseBeads,
|
|
46818
47010
|
pollSecret: session.pollSecret,
|
|
46819
47011
|
mcpServers,
|
|
46820
47012
|
// AUTO mode for headless, mobile-driven sessions: no human at the box
|
|
@@ -46830,6 +47022,7 @@ async function start(requestedAgent, presetSession) {
|
|
|
46830
47022
|
if (requiresAcp(session.agent)) {
|
|
46831
47023
|
log.error("acp", `[anomaly] acp-required agent on PTY runtime (agent=${session.agent})`);
|
|
46832
47024
|
}
|
|
47025
|
+
releaseBeads();
|
|
46833
47026
|
const runtime = createRuntimeStrategy(session.agent);
|
|
46834
47027
|
const historySvc = new HistoryService(runtime, pluginId, cwd, {
|
|
46835
47028
|
pluginAuthToken: session.pluginAuthToken
|
|
@@ -47357,7 +47550,7 @@ var import_picocolors10 = __toESM(require("picocolors"));
|
|
|
47357
47550
|
var import_child_process30 = require("child_process");
|
|
47358
47551
|
var import_util4 = require("util");
|
|
47359
47552
|
var import_picocolors8 = __toESM(require("picocolors"));
|
|
47360
|
-
var
|
|
47553
|
+
var path99 = __toESM(require("path"));
|
|
47361
47554
|
var execFileP6 = (0, import_util4.promisify)(import_child_process30.execFile);
|
|
47362
47555
|
var MAX_BUFFER = 8 * 1024 * 1024;
|
|
47363
47556
|
function resetStdinForChild() {
|
|
@@ -47846,7 +48039,7 @@ var GitHubCodespacesProvider = class {
|
|
|
47846
48039
|
});
|
|
47847
48040
|
}
|
|
47848
48041
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
47849
|
-
const remoteDir =
|
|
48042
|
+
const remoteDir = path99.posix.dirname(remotePath);
|
|
47850
48043
|
const parts = [
|
|
47851
48044
|
`mkdir -p ${shellQuote(remoteDir)}`,
|
|
47852
48045
|
`cat > ${shellQuote(remotePath)}`
|
|
@@ -47916,7 +48109,7 @@ function shellQuote(s) {
|
|
|
47916
48109
|
// src/services/providers/gitpod.ts
|
|
47917
48110
|
var import_child_process31 = require("child_process");
|
|
47918
48111
|
var import_util5 = require("util");
|
|
47919
|
-
var
|
|
48112
|
+
var path100 = __toESM(require("path"));
|
|
47920
48113
|
var import_picocolors9 = __toESM(require("picocolors"));
|
|
47921
48114
|
var execFileP7 = (0, import_util5.promisify)(import_child_process31.execFile);
|
|
47922
48115
|
var MAX_BUFFER2 = 8 * 1024 * 1024;
|
|
@@ -48156,7 +48349,7 @@ var GitpodProvider = class {
|
|
|
48156
48349
|
});
|
|
48157
48350
|
}
|
|
48158
48351
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
48159
|
-
const remoteDir =
|
|
48352
|
+
const remoteDir = path100.posix.dirname(remotePath);
|
|
48160
48353
|
const parts = [
|
|
48161
48354
|
`mkdir -p ${shellQuote2(remoteDir)}`,
|
|
48162
48355
|
`cat > ${shellQuote2(remotePath)}`
|
|
@@ -48192,7 +48385,7 @@ function shellQuote2(s) {
|
|
|
48192
48385
|
// src/services/providers/gitlab-workspaces.ts
|
|
48193
48386
|
var import_child_process32 = require("child_process");
|
|
48194
48387
|
var import_util6 = require("util");
|
|
48195
|
-
var
|
|
48388
|
+
var path101 = __toESM(require("path"));
|
|
48196
48389
|
var execFileP8 = (0, import_util6.promisify)(import_child_process32.execFile);
|
|
48197
48390
|
var MAX_BUFFER3 = 8 * 1024 * 1024;
|
|
48198
48391
|
var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
|
|
@@ -48452,7 +48645,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48452
48645
|
}
|
|
48453
48646
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
48454
48647
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
48455
|
-
const remoteDir =
|
|
48648
|
+
const remoteDir = path101.posix.dirname(remotePath);
|
|
48456
48649
|
const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
|
|
48457
48650
|
if (options.mode != null) {
|
|
48458
48651
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
@@ -48520,7 +48713,7 @@ function shellQuote3(s) {
|
|
|
48520
48713
|
// src/services/providers/railway.ts
|
|
48521
48714
|
var import_child_process33 = require("child_process");
|
|
48522
48715
|
var import_util7 = require("util");
|
|
48523
|
-
var
|
|
48716
|
+
var path102 = __toESM(require("path"));
|
|
48524
48717
|
var execFileP9 = (0, import_util7.promisify)(import_child_process33.execFile);
|
|
48525
48718
|
var MAX_BUFFER4 = 8 * 1024 * 1024;
|
|
48526
48719
|
function resetStdinForChild4() {
|
|
@@ -48756,7 +48949,7 @@ var RailwayProvider = class {
|
|
|
48756
48949
|
if (!projectId || !serviceId) {
|
|
48757
48950
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
48758
48951
|
}
|
|
48759
|
-
const remoteDir =
|
|
48952
|
+
const remoteDir = path102.posix.dirname(remotePath);
|
|
48760
48953
|
const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
|
|
48761
48954
|
if (options.mode != null) {
|
|
48762
48955
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
@@ -49296,14 +49489,14 @@ async function stopWorkspaceFromLocal(target) {
|
|
|
49296
49489
|
}
|
|
49297
49490
|
|
|
49298
49491
|
// src/commands/host/host-client.ts
|
|
49299
|
-
var
|
|
49300
|
-
var
|
|
49301
|
-
var
|
|
49492
|
+
var fs89 = __toESM(require("fs"));
|
|
49493
|
+
var os65 = __toESM(require("os"));
|
|
49494
|
+
var path103 = __toESM(require("path"));
|
|
49302
49495
|
var import_node_crypto16 = require("crypto");
|
|
49303
49496
|
function sampleCpuTimes() {
|
|
49304
49497
|
let idle = 0;
|
|
49305
49498
|
let total = 0;
|
|
49306
|
-
for (const cpu of
|
|
49499
|
+
for (const cpu of os65.cpus()) {
|
|
49307
49500
|
const t2 = cpu.times;
|
|
49308
49501
|
idle += t2.idle;
|
|
49309
49502
|
total += t2.user + t2.nice + t2.sys + t2.idle + t2.irq;
|
|
@@ -49323,8 +49516,8 @@ var MetricsCollector = class {
|
|
|
49323
49516
|
const prev = this.prevCpu;
|
|
49324
49517
|
this.prevCpu = current2;
|
|
49325
49518
|
if (!prev) {
|
|
49326
|
-
const cores =
|
|
49327
|
-
const proxy =
|
|
49519
|
+
const cores = os65.cpus().length || 1;
|
|
49520
|
+
const proxy = os65.loadavg()[0] / cores * 100;
|
|
49328
49521
|
return Math.min(100, Math.max(0, Math.round(proxy)));
|
|
49329
49522
|
}
|
|
49330
49523
|
const idleDelta = current2.idle - prev.idle;
|
|
@@ -49337,8 +49530,8 @@ var MetricsCollector = class {
|
|
|
49337
49530
|
collect() {
|
|
49338
49531
|
return {
|
|
49339
49532
|
cpuPct: this.cpuPct(),
|
|
49340
|
-
ramUsedMb: Math.round((
|
|
49341
|
-
ramTotalMb: Math.round(
|
|
49533
|
+
ramUsedMb: Math.round((os65.totalmem() - os65.freemem()) / 1048576),
|
|
49534
|
+
ramTotalMb: Math.round(os65.totalmem() / 1048576),
|
|
49342
49535
|
latencyMs: this.lastLatencyMs
|
|
49343
49536
|
};
|
|
49344
49537
|
}
|
|
@@ -49347,19 +49540,19 @@ function apiBase() {
|
|
|
49347
49540
|
return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
|
|
49348
49541
|
}
|
|
49349
49542
|
function hostIdentityPath() {
|
|
49350
|
-
return
|
|
49543
|
+
return path103.join(os65.homedir(), ".codeam", "host-agent.json");
|
|
49351
49544
|
}
|
|
49352
49545
|
function collectOsInfo() {
|
|
49353
49546
|
return {
|
|
49354
|
-
distro:
|
|
49355
|
-
arch:
|
|
49356
|
-
kernel:
|
|
49547
|
+
distro: os65.platform(),
|
|
49548
|
+
arch: os65.arch(),
|
|
49549
|
+
kernel: os65.release(),
|
|
49357
49550
|
nodeVersion: process.versions.node
|
|
49358
49551
|
};
|
|
49359
49552
|
}
|
|
49360
49553
|
function loadHostIdentity() {
|
|
49361
49554
|
try {
|
|
49362
|
-
const raw =
|
|
49555
|
+
const raw = fs89.readFileSync(hostIdentityPath(), "utf8");
|
|
49363
49556
|
const parsed = JSON.parse(raw);
|
|
49364
49557
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
|
|
49365
49558
|
const p2 = parsed;
|
|
@@ -49387,8 +49580,8 @@ function ensureControlPollSecret(identity, save = saveHostIdentity) {
|
|
|
49387
49580
|
}
|
|
49388
49581
|
function saveHostIdentity(identity) {
|
|
49389
49582
|
const file = hostIdentityPath();
|
|
49390
|
-
|
|
49391
|
-
|
|
49583
|
+
fs89.mkdirSync(path103.dirname(file), { recursive: true, mode: 448 });
|
|
49584
|
+
fs89.writeFileSync(file, JSON.stringify(identity, null, 2), {
|
|
49392
49585
|
encoding: "utf8",
|
|
49393
49586
|
mode: 384
|
|
49394
49587
|
});
|
|
@@ -49433,7 +49626,7 @@ function isTerminalEnrollError(err) {
|
|
|
49433
49626
|
}
|
|
49434
49627
|
function deleteHostIdentity() {
|
|
49435
49628
|
try {
|
|
49436
|
-
|
|
49629
|
+
fs89.rmSync(hostIdentityPath(), { force: true });
|
|
49437
49630
|
} catch {
|
|
49438
49631
|
}
|
|
49439
49632
|
}
|
|
@@ -49457,7 +49650,7 @@ async function postJson(pathname, body) {
|
|
|
49457
49650
|
function resolveHostLabel(label) {
|
|
49458
49651
|
const explicit = label?.trim();
|
|
49459
49652
|
const envLabel = process.env.CODEAM_HOST_LABEL?.trim();
|
|
49460
|
-
const resolved = explicit || envLabel ||
|
|
49653
|
+
const resolved = explicit || envLabel || os65.hostname();
|
|
49461
49654
|
return resolved.slice(0, 80);
|
|
49462
49655
|
}
|
|
49463
49656
|
async function redeemEnrollToken(token, label) {
|
|
@@ -49650,9 +49843,9 @@ async function host(args2) {
|
|
|
49650
49843
|
|
|
49651
49844
|
// src/commands/host-agent.ts
|
|
49652
49845
|
var import_node_child_process36 = require("child_process");
|
|
49653
|
-
var
|
|
49654
|
-
var
|
|
49655
|
-
var
|
|
49846
|
+
var os71 = __toESM(require("os"));
|
|
49847
|
+
var fs96 = __toESM(require("fs"));
|
|
49848
|
+
var path110 = __toESM(require("path"));
|
|
49656
49849
|
|
|
49657
49850
|
// src/skills/persist-from-payload.ts
|
|
49658
49851
|
function persistOrClearSkillsFromPayload(skills) {
|
|
@@ -49661,13 +49854,13 @@ function persistOrClearSkillsFromPayload(skills) {
|
|
|
49661
49854
|
}
|
|
49662
49855
|
|
|
49663
49856
|
// src/commands/host/session-state.ts
|
|
49664
|
-
var
|
|
49665
|
-
var
|
|
49666
|
-
var
|
|
49857
|
+
var fs90 = __toESM(require("fs"));
|
|
49858
|
+
var os66 = __toESM(require("os"));
|
|
49859
|
+
var path104 = __toESM(require("path"));
|
|
49667
49860
|
function hostSessionStatePath(env = process.env) {
|
|
49668
49861
|
const override = env.CODEAM_HOST_SESSION_STATE_FILE;
|
|
49669
49862
|
if (override && override.trim()) return override.trim();
|
|
49670
|
-
return
|
|
49863
|
+
return path104.join(os66.homedir(), ".codeam", "host-agent-sessions.json");
|
|
49671
49864
|
}
|
|
49672
49865
|
function isRecord5(v) {
|
|
49673
49866
|
if (typeof v !== "object" || v === null) return false;
|
|
@@ -49678,7 +49871,7 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
49678
49871
|
return {
|
|
49679
49872
|
load() {
|
|
49680
49873
|
try {
|
|
49681
|
-
const raw = JSON.parse(
|
|
49874
|
+
const raw = JSON.parse(fs90.readFileSync(file, "utf8"));
|
|
49682
49875
|
return Array.isArray(raw?.sessions) ? raw.sessions.filter(isRecord5) : null;
|
|
49683
49876
|
} catch {
|
|
49684
49877
|
return null;
|
|
@@ -49686,18 +49879,18 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
49686
49879
|
},
|
|
49687
49880
|
save(list) {
|
|
49688
49881
|
try {
|
|
49689
|
-
|
|
49882
|
+
fs90.mkdirSync(path104.dirname(file), { recursive: true, mode: 448 });
|
|
49690
49883
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
49691
|
-
|
|
49884
|
+
fs90.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
|
|
49692
49885
|
mode: 384
|
|
49693
49886
|
});
|
|
49694
|
-
|
|
49887
|
+
fs90.renameSync(tmp, file);
|
|
49695
49888
|
} catch {
|
|
49696
49889
|
}
|
|
49697
49890
|
},
|
|
49698
49891
|
clear() {
|
|
49699
49892
|
try {
|
|
49700
|
-
|
|
49893
|
+
fs90.rmSync(file, { force: true });
|
|
49701
49894
|
} catch {
|
|
49702
49895
|
}
|
|
49703
49896
|
}
|
|
@@ -49720,10 +49913,10 @@ function planSessionResume(records, max) {
|
|
|
49720
49913
|
return { resume: ordered.slice(0, bound), dropped: ordered.slice(bound) };
|
|
49721
49914
|
}
|
|
49722
49915
|
function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
49723
|
-
const target =
|
|
49916
|
+
const target = path104.resolve(cwd);
|
|
49724
49917
|
const reconnectable = (s) => !!s.pluginId && !!s.pollSecret && !!s.agent;
|
|
49725
49918
|
const matches = sessions3.filter(
|
|
49726
|
-
(s) => !!s.cwd &&
|
|
49919
|
+
(s) => !!s.cwd && path104.resolve(s.cwd) === target && reconnectable(s)
|
|
49727
49920
|
);
|
|
49728
49921
|
if (matches.length > 0) {
|
|
49729
49922
|
matches.sort((a, b) => b.pairedAt - a.pairedAt);
|
|
@@ -49735,11 +49928,11 @@ function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
|
49735
49928
|
|
|
49736
49929
|
// src/commands/host/git-tooling.ts
|
|
49737
49930
|
var import_node_child_process31 = require("child_process");
|
|
49738
|
-
var
|
|
49739
|
-
var
|
|
49740
|
-
var
|
|
49931
|
+
var fs91 = __toESM(require("fs"));
|
|
49932
|
+
var os67 = __toESM(require("os"));
|
|
49933
|
+
var path105 = __toESM(require("path"));
|
|
49741
49934
|
function codeamBinDir() {
|
|
49742
|
-
return process.env.CODEAM_BIN_DIR ??
|
|
49935
|
+
return process.env.CODEAM_BIN_DIR ?? path105.join(os67.homedir(), ".codeam", "bin");
|
|
49743
49936
|
}
|
|
49744
49937
|
var FALLBACK_GH_VERSION = "2.62.0";
|
|
49745
49938
|
var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
|
|
@@ -49771,7 +49964,7 @@ async function download(url2, dest) {
|
|
|
49771
49964
|
const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
|
|
49772
49965
|
if (!res.ok || !res.body) return false;
|
|
49773
49966
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
49774
|
-
|
|
49967
|
+
fs91.writeFileSync(dest, buf);
|
|
49775
49968
|
return true;
|
|
49776
49969
|
} catch {
|
|
49777
49970
|
return false;
|
|
@@ -49794,8 +49987,8 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
49794
49987
|
const version3 = await resolveVersionFn(token);
|
|
49795
49988
|
const asset = `gh_${version3}_${osToken}_${arch2}`;
|
|
49796
49989
|
const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
|
|
49797
|
-
const tmpRoot =
|
|
49798
|
-
const archive =
|
|
49990
|
+
const tmpRoot = fs91.mkdtempSync(path105.join(os67.tmpdir(), "codeam-gh-"));
|
|
49991
|
+
const archive = path105.join(tmpRoot, `${asset}.${ext}`);
|
|
49799
49992
|
if (!await downloadFn(url2, archive)) {
|
|
49800
49993
|
log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
|
|
49801
49994
|
return null;
|
|
@@ -49805,16 +49998,16 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
49805
49998
|
log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
|
|
49806
49999
|
return null;
|
|
49807
50000
|
}
|
|
49808
|
-
const extractedBin =
|
|
49809
|
-
if (!
|
|
50001
|
+
const extractedBin = path105.join(tmpRoot, asset, "bin", binaryName);
|
|
50002
|
+
if (!fs91.existsSync(extractedBin)) {
|
|
49810
50003
|
log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
|
|
49811
50004
|
return null;
|
|
49812
50005
|
}
|
|
49813
50006
|
const binDir = codeamBinDir();
|
|
49814
|
-
|
|
49815
|
-
const target =
|
|
49816
|
-
|
|
49817
|
-
|
|
50007
|
+
fs91.mkdirSync(binDir, { recursive: true });
|
|
50008
|
+
const target = path105.join(binDir, binaryName);
|
|
50009
|
+
fs91.copyFileSync(extractedBin, target);
|
|
50010
|
+
fs91.chmodSync(target, 493);
|
|
49818
50011
|
log.info("host-agent", `gh installed to ${target} (v${version3})`);
|
|
49819
50012
|
return target;
|
|
49820
50013
|
} catch (e) {
|
|
@@ -49851,19 +50044,19 @@ async function ensureGhAuth(runner, ghCmd, token) {
|
|
|
49851
50044
|
}
|
|
49852
50045
|
function ghConfigDir() {
|
|
49853
50046
|
if (process.env.GH_CONFIG_DIR) return process.env.GH_CONFIG_DIR;
|
|
49854
|
-
if (process.env.XDG_CONFIG_HOME) return
|
|
50047
|
+
if (process.env.XDG_CONFIG_HOME) return path105.join(process.env.XDG_CONFIG_HOME, "gh");
|
|
49855
50048
|
if (process.platform === "win32" && process.env.APPDATA) {
|
|
49856
|
-
return
|
|
50049
|
+
return path105.join(process.env.APPDATA, "GitHub CLI");
|
|
49857
50050
|
}
|
|
49858
|
-
return
|
|
50051
|
+
return path105.join(os67.homedir(), ".config", "gh");
|
|
49859
50052
|
}
|
|
49860
50053
|
function writeGhHostsToken(token) {
|
|
49861
50054
|
try {
|
|
49862
50055
|
const dir = ghConfigDir();
|
|
49863
|
-
const file =
|
|
49864
|
-
if (
|
|
49865
|
-
|
|
49866
|
-
|
|
50056
|
+
const file = path105.join(dir, "hosts.yml");
|
|
50057
|
+
if (fs91.existsSync(file)) return false;
|
|
50058
|
+
fs91.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
50059
|
+
fs91.writeFileSync(
|
|
49867
50060
|
file,
|
|
49868
50061
|
`github.com:
|
|
49869
50062
|
oauth_token: ${token}
|
|
@@ -49906,8 +50099,8 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
49906
50099
|
const version3 = await resolveLatestGlabVersion();
|
|
49907
50100
|
const asset = `glab_${version3}_${osToken}_${arch2}`;
|
|
49908
50101
|
const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
|
|
49909
|
-
const tmpRoot =
|
|
49910
|
-
const archive =
|
|
50102
|
+
const tmpRoot = fs91.mkdtempSync(path105.join(os67.tmpdir(), "codeam-glab-"));
|
|
50103
|
+
const archive = path105.join(tmpRoot, `${asset}.${ext}`);
|
|
49911
50104
|
if (!await downloadFn(url2, archive)) {
|
|
49912
50105
|
log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
|
|
49913
50106
|
return null;
|
|
@@ -49918,20 +50111,20 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
49918
50111
|
return null;
|
|
49919
50112
|
}
|
|
49920
50113
|
const candidates = [
|
|
49921
|
-
|
|
49922
|
-
|
|
49923
|
-
|
|
50114
|
+
path105.join(tmpRoot, "bin", binaryName),
|
|
50115
|
+
path105.join(tmpRoot, asset, "bin", binaryName),
|
|
50116
|
+
path105.join(tmpRoot, binaryName)
|
|
49924
50117
|
];
|
|
49925
|
-
const extractedBin = candidates.find((c2) =>
|
|
50118
|
+
const extractedBin = candidates.find((c2) => fs91.existsSync(c2));
|
|
49926
50119
|
if (!extractedBin) {
|
|
49927
50120
|
log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
|
|
49928
50121
|
return null;
|
|
49929
50122
|
}
|
|
49930
50123
|
const binDir = codeamBinDir();
|
|
49931
|
-
|
|
49932
|
-
const target =
|
|
49933
|
-
|
|
49934
|
-
|
|
50124
|
+
fs91.mkdirSync(binDir, { recursive: true });
|
|
50125
|
+
const target = path105.join(binDir, binaryName);
|
|
50126
|
+
fs91.copyFileSync(extractedBin, target);
|
|
50127
|
+
fs91.chmodSync(target, 493);
|
|
49935
50128
|
log.info("host-agent", `glab installed to ${target} (v${version3})`);
|
|
49936
50129
|
return target;
|
|
49937
50130
|
} catch (e) {
|
|
@@ -50010,14 +50203,14 @@ var defaultGitToolingRunner = {
|
|
|
50010
50203
|
};
|
|
50011
50204
|
|
|
50012
50205
|
// src/lib/cli-versions.ts
|
|
50013
|
-
var
|
|
50014
|
-
var
|
|
50015
|
-
var
|
|
50206
|
+
var fs93 = __toESM(require("fs"));
|
|
50207
|
+
var os69 = __toESM(require("os"));
|
|
50208
|
+
var path107 = __toESM(require("path"));
|
|
50016
50209
|
|
|
50017
50210
|
// src/lib/updateNotifier.ts
|
|
50018
|
-
var
|
|
50019
|
-
var
|
|
50020
|
-
var
|
|
50211
|
+
var fs92 = __toESM(require("fs"));
|
|
50212
|
+
var os68 = __toESM(require("os"));
|
|
50213
|
+
var path106 = __toESM(require("path"));
|
|
50021
50214
|
var https8 = __toESM(require("https"));
|
|
50022
50215
|
var import_node_child_process32 = require("child_process");
|
|
50023
50216
|
var import_picocolors12 = __toESM(require("picocolors"));
|
|
@@ -50026,12 +50219,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
|
|
|
50026
50219
|
var TTL_MS = 24 * 60 * 60 * 1e3;
|
|
50027
50220
|
var REQUEST_TIMEOUT_MS = 1500;
|
|
50028
50221
|
function cachePath() {
|
|
50029
|
-
const dir =
|
|
50030
|
-
return
|
|
50222
|
+
const dir = path106.join(os68.homedir(), ".codeam");
|
|
50223
|
+
return path106.join(dir, "update-check.json");
|
|
50031
50224
|
}
|
|
50032
50225
|
function readCache() {
|
|
50033
50226
|
try {
|
|
50034
|
-
const raw =
|
|
50227
|
+
const raw = fs92.readFileSync(cachePath(), "utf8");
|
|
50035
50228
|
const parsed = JSON.parse(raw);
|
|
50036
50229
|
if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
|
|
50037
50230
|
return parsed;
|
|
@@ -50042,10 +50235,10 @@ function readCache() {
|
|
|
50042
50235
|
function writeCache(cache) {
|
|
50043
50236
|
try {
|
|
50044
50237
|
const file = cachePath();
|
|
50045
|
-
|
|
50238
|
+
fs92.mkdirSync(path106.dirname(file), { recursive: true });
|
|
50046
50239
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
50047
|
-
|
|
50048
|
-
|
|
50240
|
+
fs92.writeFileSync(tmp, JSON.stringify(cache));
|
|
50241
|
+
fs92.renameSync(tmp, file);
|
|
50049
50242
|
} catch {
|
|
50050
50243
|
}
|
|
50051
50244
|
}
|
|
@@ -50119,8 +50312,8 @@ function isLinkedInstall() {
|
|
|
50119
50312
|
timeout: 2e3
|
|
50120
50313
|
}).trim();
|
|
50121
50314
|
if (!root) return false;
|
|
50122
|
-
const pkgPath =
|
|
50123
|
-
return
|
|
50315
|
+
const pkgPath = path106.join(root, PKG_NAME);
|
|
50316
|
+
return fs92.lstatSync(pkgPath).isSymbolicLink();
|
|
50124
50317
|
} catch {
|
|
50125
50318
|
return false;
|
|
50126
50319
|
}
|
|
@@ -50156,7 +50349,7 @@ function maybeAutoUpdate(currentVersion, latest) {
|
|
|
50156
50349
|
return;
|
|
50157
50350
|
}
|
|
50158
50351
|
try {
|
|
50159
|
-
|
|
50352
|
+
fs92.unlinkSync(cachePath());
|
|
50160
50353
|
} catch {
|
|
50161
50354
|
}
|
|
50162
50355
|
process.stderr.write(` ${import_picocolors12.default.green("\u2713")} Updated. Resuming session...
|
|
@@ -50172,7 +50365,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
50172
50365
|
if (process.env.NODE_ENV === "test") return;
|
|
50173
50366
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
50174
50367
|
if (process.env.CI) return;
|
|
50175
|
-
const current2 = true ? "2.76.
|
|
50368
|
+
const current2 = true ? "2.76.13" : null;
|
|
50176
50369
|
if (!current2) return;
|
|
50177
50370
|
const cache = readCache();
|
|
50178
50371
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -50189,7 +50382,7 @@ function checkForUpdates() {
|
|
|
50189
50382
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
50190
50383
|
if (process.env.CI) return;
|
|
50191
50384
|
if (!process.stdout.isTTY) return;
|
|
50192
|
-
const current2 = true ? "2.76.
|
|
50385
|
+
const current2 = true ? "2.76.13" : null;
|
|
50193
50386
|
if (!current2) return;
|
|
50194
50387
|
const cache = readCache();
|
|
50195
50388
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -50212,10 +50405,10 @@ function versionedModeSupported(platform3 = process.platform) {
|
|
|
50212
50405
|
return platform3 !== "win32";
|
|
50213
50406
|
}
|
|
50214
50407
|
function cliVersionsRoot(env = process.env) {
|
|
50215
|
-
return env.CODEAM_CLI_VERSIONS_DIR ||
|
|
50408
|
+
return env.CODEAM_CLI_VERSIONS_DIR || path107.join(os69.homedir(), ".codeam", "cli");
|
|
50216
50409
|
}
|
|
50217
50410
|
function packageDirOf(versionDir) {
|
|
50218
|
-
return
|
|
50411
|
+
return path107.join(versionDir, "node_modules", CLI_PKG);
|
|
50219
50412
|
}
|
|
50220
50413
|
function isRecord6(v) {
|
|
50221
50414
|
return typeof v === "object" && v !== null;
|
|
@@ -50223,7 +50416,7 @@ function isRecord6(v) {
|
|
|
50223
50416
|
function readPkg2(versionDir) {
|
|
50224
50417
|
try {
|
|
50225
50418
|
const raw = JSON.parse(
|
|
50226
|
-
|
|
50419
|
+
fs93.readFileSync(path107.join(packageDirOf(versionDir), "package.json"), "utf8")
|
|
50227
50420
|
);
|
|
50228
50421
|
return isRecord6(raw) ? raw : null;
|
|
50229
50422
|
} catch {
|
|
@@ -50236,15 +50429,15 @@ function entryOf(versionDir) {
|
|
|
50236
50429
|
const bin = pkg.bin;
|
|
50237
50430
|
const named = isRecord6(bin) ? bin.codeam : void 0;
|
|
50238
50431
|
const rel = typeof bin === "string" ? bin : typeof named === "string" ? named : "dist/index.js";
|
|
50239
|
-
const entry =
|
|
50240
|
-
return
|
|
50432
|
+
const entry = path107.join(packageDirOf(versionDir), rel);
|
|
50433
|
+
return fs93.existsSync(entry) ? entry : null;
|
|
50241
50434
|
}
|
|
50242
50435
|
function launcherOf(versionDir) {
|
|
50243
50436
|
const entry = entryOf(versionDir);
|
|
50244
50437
|
if (!entry) return null;
|
|
50245
|
-
const bin =
|
|
50438
|
+
const bin = path107.join(versionDir, "node_modules", ".bin", "codeam");
|
|
50246
50439
|
try {
|
|
50247
|
-
return
|
|
50440
|
+
return fs93.realpathSync(bin) === fs93.realpathSync(entry) ? bin : entry;
|
|
50248
50441
|
} catch {
|
|
50249
50442
|
return entry;
|
|
50250
50443
|
}
|
|
@@ -50257,16 +50450,16 @@ var BAD_MARKER_TTL_MS = 24 * 60 * 6e4;
|
|
|
50257
50450
|
var PRE_READY_WINDOW_MS = 60 * 6e4;
|
|
50258
50451
|
function isBad(versionDir, now = Date.now()) {
|
|
50259
50452
|
try {
|
|
50260
|
-
return now -
|
|
50453
|
+
return now - fs93.statSync(path107.join(versionDir, ".bad")).mtimeMs < BAD_MARKER_TTL_MS;
|
|
50261
50454
|
} catch {
|
|
50262
50455
|
return false;
|
|
50263
50456
|
}
|
|
50264
50457
|
}
|
|
50265
50458
|
function recordPreReadyFailure(versionDir, now = Date.now()) {
|
|
50266
|
-
const file =
|
|
50459
|
+
const file = path107.join(versionDir, ".prefail");
|
|
50267
50460
|
let count = 0;
|
|
50268
50461
|
try {
|
|
50269
|
-
const [n, at3] =
|
|
50462
|
+
const [n, at3] = fs93.readFileSync(file, "utf8").trim().split(" ").map(Number);
|
|
50270
50463
|
if (Number.isFinite(n) && Number.isFinite(at3) && now - at3 < PRE_READY_WINDOW_MS) {
|
|
50271
50464
|
count = n;
|
|
50272
50465
|
}
|
|
@@ -50274,41 +50467,41 @@ function recordPreReadyFailure(versionDir, now = Date.now()) {
|
|
|
50274
50467
|
}
|
|
50275
50468
|
count += 1;
|
|
50276
50469
|
try {
|
|
50277
|
-
|
|
50470
|
+
fs93.writeFileSync(file, `${count} ${now}`);
|
|
50278
50471
|
} catch {
|
|
50279
50472
|
}
|
|
50280
50473
|
return count;
|
|
50281
50474
|
}
|
|
50282
50475
|
function clearPreReadyFailures(versionDir) {
|
|
50283
|
-
|
|
50476
|
+
fs93.rmSync(path107.join(versionDir, ".prefail"), { force: true });
|
|
50284
50477
|
}
|
|
50285
50478
|
function markBad(versionDir, reason) {
|
|
50286
50479
|
try {
|
|
50287
|
-
|
|
50480
|
+
fs93.writeFileSync(path107.join(versionDir, ".bad"), `${(/* @__PURE__ */ new Date()).toISOString()} ${reason}
|
|
50288
50481
|
`);
|
|
50289
50482
|
} catch {
|
|
50290
50483
|
}
|
|
50291
50484
|
}
|
|
50292
50485
|
function pointerTarget(root, name) {
|
|
50293
50486
|
try {
|
|
50294
|
-
return
|
|
50487
|
+
return fs93.realpathSync(path107.join(root, name));
|
|
50295
50488
|
} catch {
|
|
50296
50489
|
return null;
|
|
50297
50490
|
}
|
|
50298
50491
|
}
|
|
50299
50492
|
function atomicPoint(root, name, targetDir) {
|
|
50300
|
-
const tmp =
|
|
50301
|
-
|
|
50493
|
+
const tmp = path107.join(root, `.${name}.tmp-${process.pid}-${Date.now()}`);
|
|
50494
|
+
fs93.symlinkSync(path107.relative(root, targetDir), tmp, "dir");
|
|
50302
50495
|
try {
|
|
50303
|
-
|
|
50496
|
+
fs93.renameSync(tmp, path107.join(root, name));
|
|
50304
50497
|
} catch (err) {
|
|
50305
|
-
|
|
50498
|
+
fs93.rmSync(tmp, { force: true });
|
|
50306
50499
|
throw err;
|
|
50307
50500
|
}
|
|
50308
50501
|
}
|
|
50309
50502
|
function switchCurrent(root, versionDir) {
|
|
50310
50503
|
const old = pointerTarget(root, "current");
|
|
50311
|
-
if (old &&
|
|
50504
|
+
if (old && path107.resolve(old) !== path107.resolve(versionDir)) atomicPoint(root, "previous", old);
|
|
50312
50505
|
atomicPoint(root, "current", versionDir);
|
|
50313
50506
|
}
|
|
50314
50507
|
function validCurrent(root) {
|
|
@@ -50322,7 +50515,7 @@ function rollbackCurrent(root) {
|
|
|
50322
50515
|
const prev = pointerTarget(root, "previous");
|
|
50323
50516
|
if (!prev || isBad(prev) || !entryOf(prev)) return null;
|
|
50324
50517
|
const cur = pointerTarget(root, "current");
|
|
50325
|
-
if (cur &&
|
|
50518
|
+
if (cur && path107.resolve(cur) !== path107.resolve(prev)) atomicPoint(root, "previous", cur);
|
|
50326
50519
|
atomicPoint(root, "current", prev);
|
|
50327
50520
|
return versionOf(prev);
|
|
50328
50521
|
}
|
|
@@ -50336,15 +50529,15 @@ function versionDirContaining(root, file) {
|
|
|
50336
50529
|
let real;
|
|
50337
50530
|
let realRoot;
|
|
50338
50531
|
try {
|
|
50339
|
-
real =
|
|
50340
|
-
realRoot =
|
|
50532
|
+
real = fs93.realpathSync(file);
|
|
50533
|
+
realRoot = fs93.realpathSync(root);
|
|
50341
50534
|
} catch {
|
|
50342
50535
|
return null;
|
|
50343
50536
|
}
|
|
50344
|
-
const rel =
|
|
50345
|
-
if (rel.startsWith("..") ||
|
|
50346
|
-
const first = rel.split(
|
|
50347
|
-
return first && SEMVER_DIR.test(first) ?
|
|
50537
|
+
const rel = path107.relative(realRoot, real);
|
|
50538
|
+
if (rel.startsWith("..") || path107.isAbsolute(rel)) return null;
|
|
50539
|
+
const first = rel.split(path107.sep)[0];
|
|
50540
|
+
return first && SEMVER_DIR.test(first) ? path107.join(realRoot, first) : null;
|
|
50348
50541
|
}
|
|
50349
50542
|
function pidAlive3(pid) {
|
|
50350
50543
|
try {
|
|
@@ -50357,7 +50550,7 @@ function pidAlive3(pid) {
|
|
|
50357
50550
|
function livePids(versionDir) {
|
|
50358
50551
|
let names;
|
|
50359
50552
|
try {
|
|
50360
|
-
names =
|
|
50553
|
+
names = fs93.readdirSync(path107.join(versionDir, ".pids"));
|
|
50361
50554
|
} catch {
|
|
50362
50555
|
return [];
|
|
50363
50556
|
}
|
|
@@ -50366,11 +50559,11 @@ function livePids(versionDir) {
|
|
|
50366
50559
|
function registerRunningVersion(root = cliVersionsRoot(), entry = process.argv[1]) {
|
|
50367
50560
|
const dir = versionDirContaining(root, entry);
|
|
50368
50561
|
if (!dir) return;
|
|
50369
|
-
const file =
|
|
50562
|
+
const file = path107.join(dir, ".pids", String(process.pid));
|
|
50370
50563
|
try {
|
|
50371
|
-
|
|
50372
|
-
|
|
50373
|
-
process.once("exit", () =>
|
|
50564
|
+
fs93.mkdirSync(path107.dirname(file), { recursive: true });
|
|
50565
|
+
fs93.writeFileSync(file, "");
|
|
50566
|
+
process.once("exit", () => fs93.rmSync(file, { force: true }));
|
|
50374
50567
|
} catch {
|
|
50375
50568
|
}
|
|
50376
50569
|
}
|
|
@@ -50378,7 +50571,7 @@ function gcVersions(root) {
|
|
|
50378
50571
|
const removed = [];
|
|
50379
50572
|
let names;
|
|
50380
50573
|
try {
|
|
50381
|
-
names =
|
|
50574
|
+
names = fs93.readdirSync(root).filter((n) => SEMVER_DIR.test(n));
|
|
50382
50575
|
} catch {
|
|
50383
50576
|
return removed;
|
|
50384
50577
|
}
|
|
@@ -50386,13 +50579,13 @@ function gcVersions(root) {
|
|
|
50386
50579
|
[...names].sort((a, b) => compareSemver(b, a)).slice(0, GC_KEEP_NEWEST)
|
|
50387
50580
|
);
|
|
50388
50581
|
for (const p2 of [pointerTarget(root, "current"), pointerTarget(root, "previous")]) {
|
|
50389
|
-
if (p2) keep.add(
|
|
50582
|
+
if (p2) keep.add(path107.basename(p2));
|
|
50390
50583
|
}
|
|
50391
50584
|
for (const name of names) {
|
|
50392
|
-
const dir =
|
|
50585
|
+
const dir = path107.join(root, name);
|
|
50393
50586
|
if (keep.has(name) || livePids(dir).length > 0) continue;
|
|
50394
50587
|
try {
|
|
50395
|
-
|
|
50588
|
+
fs93.rmSync(dir, { recursive: true, force: true });
|
|
50396
50589
|
removed.push(name);
|
|
50397
50590
|
} catch {
|
|
50398
50591
|
}
|
|
@@ -50400,25 +50593,25 @@ function gcVersions(root) {
|
|
|
50400
50593
|
return removed;
|
|
50401
50594
|
}
|
|
50402
50595
|
function acquireInstallLock(root) {
|
|
50403
|
-
const lock =
|
|
50596
|
+
const lock = path107.join(root, ".install.lock");
|
|
50404
50597
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
50405
50598
|
try {
|
|
50406
|
-
const fd =
|
|
50407
|
-
|
|
50408
|
-
|
|
50409
|
-
return () =>
|
|
50599
|
+
const fd = fs93.openSync(lock, "wx");
|
|
50600
|
+
fs93.writeSync(fd, String(process.pid));
|
|
50601
|
+
fs93.closeSync(fd);
|
|
50602
|
+
return () => fs93.rmSync(lock, { force: true });
|
|
50410
50603
|
} catch (err) {
|
|
50411
50604
|
if (err.code !== "EEXIST") return null;
|
|
50412
50605
|
let stale = false;
|
|
50413
50606
|
try {
|
|
50414
|
-
const owner = Number(
|
|
50415
|
-
const age = Date.now() -
|
|
50607
|
+
const owner = Number(fs93.readFileSync(lock, "utf8"));
|
|
50608
|
+
const age = Date.now() - fs93.statSync(lock).mtimeMs;
|
|
50416
50609
|
stale = !Number.isInteger(owner) || !pidAlive3(owner) || age > LOCK_STALE_MS;
|
|
50417
50610
|
} catch {
|
|
50418
50611
|
stale = true;
|
|
50419
50612
|
}
|
|
50420
50613
|
if (!stale) return null;
|
|
50421
|
-
|
|
50614
|
+
fs93.rmSync(lock, { force: true });
|
|
50422
50615
|
}
|
|
50423
50616
|
}
|
|
50424
50617
|
return null;
|
|
@@ -50426,9 +50619,9 @@ function acquireInstallLock(root) {
|
|
|
50426
50619
|
|
|
50427
50620
|
// src/commands/host/host-launch.ts
|
|
50428
50621
|
var import_node_child_process34 = require("child_process");
|
|
50429
|
-
var
|
|
50430
|
-
var
|
|
50431
|
-
var
|
|
50622
|
+
var fs95 = __toESM(require("fs"));
|
|
50623
|
+
var os70 = __toESM(require("os"));
|
|
50624
|
+
var path109 = __toESM(require("path"));
|
|
50432
50625
|
|
|
50433
50626
|
// src/exit-codes.ts
|
|
50434
50627
|
var EXIT_OK = 0;
|
|
@@ -50450,8 +50643,8 @@ var EXIT_CODE_NAMES = {
|
|
|
50450
50643
|
|
|
50451
50644
|
// src/commands/host/self-update.ts
|
|
50452
50645
|
var import_node_child_process33 = require("child_process");
|
|
50453
|
-
var
|
|
50454
|
-
var
|
|
50646
|
+
var fs94 = __toESM(require("fs"));
|
|
50647
|
+
var path108 = __toESM(require("path"));
|
|
50455
50648
|
var SELF_UPDATE_PKG = "codeam-cli";
|
|
50456
50649
|
var SELF_UPDATE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
50457
50650
|
var SELF_UPDATE_STARTUP_DELAY_MS = 5e3;
|
|
@@ -50460,7 +50653,7 @@ var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
|
|
|
50460
50653
|
var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
50461
50654
|
var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
|
|
50462
50655
|
function currentCliVersion() {
|
|
50463
|
-
return true ? "2.76.
|
|
50656
|
+
return true ? "2.76.13" : null;
|
|
50464
50657
|
}
|
|
50465
50658
|
async function installedVersion(deps) {
|
|
50466
50659
|
const ls = await deps.run(
|
|
@@ -50552,9 +50745,9 @@ async function runSelfUpdateWith(deps) {
|
|
|
50552
50745
|
var VERIFY_TIMEOUT_MS = 3e4;
|
|
50553
50746
|
async function installVersioned(deps, root, latest, running2) {
|
|
50554
50747
|
const node = deps.nodePath ?? process.execPath;
|
|
50555
|
-
const target =
|
|
50748
|
+
const target = path108.join(root, latest);
|
|
50556
50749
|
try {
|
|
50557
|
-
|
|
50750
|
+
fs94.mkdirSync(root, { recursive: true });
|
|
50558
50751
|
} catch {
|
|
50559
50752
|
return { status: "skipped" };
|
|
50560
50753
|
}
|
|
@@ -50571,10 +50764,10 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
50571
50764
|
const runningDir = versionDirContaining(root, deps.runningEntry);
|
|
50572
50765
|
const reusable = entryOf(target) && versionOf(target) === latest;
|
|
50573
50766
|
if (!reusable) {
|
|
50574
|
-
if (runningDir &&
|
|
50767
|
+
if (runningDir && path108.resolve(runningDir) === path108.resolve(target)) {
|
|
50575
50768
|
return { status: "skipped" };
|
|
50576
50769
|
}
|
|
50577
|
-
|
|
50770
|
+
fs94.rmSync(target, { recursive: true, force: true });
|
|
50578
50771
|
const install = await deps.run(
|
|
50579
50772
|
"npm",
|
|
50580
50773
|
[
|
|
@@ -50589,7 +50782,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
50589
50782
|
SELF_UPDATE_INSTALL_TIMEOUT_MS
|
|
50590
50783
|
);
|
|
50591
50784
|
if (install.code !== 0) {
|
|
50592
|
-
|
|
50785
|
+
fs94.rmSync(target, { recursive: true, force: true });
|
|
50593
50786
|
log.warn(
|
|
50594
50787
|
"host-agent",
|
|
50595
50788
|
`self-update: versioned install exited ${String(install.code)} \u2014 staying on ${running2}: ` + install.stderr.slice(-300)
|
|
@@ -50600,7 +50793,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
50600
50793
|
const entry = entryOf(target);
|
|
50601
50794
|
const check = entry ? await deps.run(node, [entry, "--version"], VERIFY_TIMEOUT_MS) : { code: null, stdout: "", stderr: "no entry point" };
|
|
50602
50795
|
if (check.code !== 0 || !check.stdout.includes(latest)) {
|
|
50603
|
-
|
|
50796
|
+
fs94.rmSync(target, { recursive: true, force: true });
|
|
50604
50797
|
log.warn(
|
|
50605
50798
|
"host-agent",
|
|
50606
50799
|
`self-update: ${latest} failed verification (exit ${String(check.code)}: ${(check.stdout + check.stderr).trim().slice(-200)}) \u2014 staying on ${running2}`
|
|
@@ -50616,7 +50809,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
50616
50809
|
return { status: "updated", version: latest };
|
|
50617
50810
|
} catch (err) {
|
|
50618
50811
|
const cur = pointerTarget(root, "current");
|
|
50619
|
-
if (!cur ||
|
|
50812
|
+
if (!cur || path108.basename(cur) !== latest) fs94.rmSync(target, { recursive: true, force: true });
|
|
50620
50813
|
log.warn(
|
|
50621
50814
|
"host-agent",
|
|
50622
50815
|
`self-update: versioned install failed: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -50655,7 +50848,7 @@ function signalHostReady(send = process.send?.bind(process)) {
|
|
|
50655
50848
|
}
|
|
50656
50849
|
function defaultDeps() {
|
|
50657
50850
|
return {
|
|
50658
|
-
ownVersion: true ? "2.76.
|
|
50851
|
+
ownVersion: true ? "2.76.13" : null,
|
|
50659
50852
|
root: cliVersionsRoot(),
|
|
50660
50853
|
args: process.argv.slice(3),
|
|
50661
50854
|
execPath: process.execPath,
|
|
@@ -50752,13 +50945,13 @@ function needsSelfRelaunch(env = process.env, pid = process.pid, ctx = {}) {
|
|
|
50752
50945
|
}
|
|
50753
50946
|
function readPid1Cmdline() {
|
|
50754
50947
|
try {
|
|
50755
|
-
return
|
|
50948
|
+
return fs95.readFileSync("/proc/1/cmdline", "utf8").split("\0").filter(Boolean);
|
|
50756
50949
|
} catch {
|
|
50757
50950
|
return [];
|
|
50758
50951
|
}
|
|
50759
50952
|
}
|
|
50760
50953
|
function isOurTiniEntrypoint(argv) {
|
|
50761
|
-
return argv.some((a) =>
|
|
50954
|
+
return argv.some((a) => path109.basename(a) === "tini") && argv.includes("host-agent");
|
|
50762
50955
|
}
|
|
50763
50956
|
function relaunchArgv(execPath, argv) {
|
|
50764
50957
|
return ["-c", 'sleep 2; exec "$0" "$@"', execPath, ...argv.slice(1)];
|
|
@@ -50791,7 +50984,7 @@ function defaultRestartForUpdate(version3, supervised, io = {}) {
|
|
|
50791
50984
|
}
|
|
50792
50985
|
exit(0);
|
|
50793
50986
|
}
|
|
50794
|
-
function isContainerEnvironment(existsSyncFn =
|
|
50987
|
+
function isContainerEnvironment(existsSyncFn = fs95.existsSync, readFileSyncFn = (p2) => fs95.readFileSync(p2, "utf8")) {
|
|
50795
50988
|
try {
|
|
50796
50989
|
if (existsSyncFn("/.dockerenv")) return true;
|
|
50797
50990
|
} catch {
|
|
@@ -50803,16 +50996,16 @@ function isContainerEnvironment(existsSyncFn = fs93.existsSync, readFileSyncFn =
|
|
|
50803
50996
|
}
|
|
50804
50997
|
return false;
|
|
50805
50998
|
}
|
|
50806
|
-
function hostAgentPidFile(home =
|
|
50807
|
-
return
|
|
50999
|
+
function hostAgentPidFile(home = os70.homedir()) {
|
|
51000
|
+
return path109.join(home, ".codeam", "host-agent.pid");
|
|
50808
51001
|
}
|
|
50809
51002
|
function writeHostAgentPidFile(file = hostAgentPidFile(), pid = process.pid) {
|
|
50810
51003
|
try {
|
|
50811
|
-
|
|
50812
|
-
|
|
51004
|
+
fs95.mkdirSync(path109.dirname(file), { recursive: true });
|
|
51005
|
+
fs95.writeFileSync(file, String(pid));
|
|
50813
51006
|
process.once("exit", () => {
|
|
50814
51007
|
try {
|
|
50815
|
-
if (
|
|
51008
|
+
if (fs95.readFileSync(file, "utf8").trim() === String(pid)) fs95.rmSync(file, { force: true });
|
|
50816
51009
|
} catch {
|
|
50817
51010
|
}
|
|
50818
51011
|
});
|
|
@@ -51570,13 +51763,13 @@ var HostAgentSupervisor = class {
|
|
|
51570
51763
|
const relay = this.relay;
|
|
51571
51764
|
if (!relay) return;
|
|
51572
51765
|
const raw = cmd.payload?.path;
|
|
51573
|
-
const target = typeof raw === "string" && raw.trim() ?
|
|
51766
|
+
const target = typeof raw === "string" && raw.trim() ? path110.resolve(raw.trim()) : os71.homedir();
|
|
51574
51767
|
try {
|
|
51575
|
-
const dirents = await
|
|
51768
|
+
const dirents = await fs96.promises.readdir(target, { withFileTypes: true });
|
|
51576
51769
|
const entries2 = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
|
|
51577
51770
|
(a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
|
|
51578
51771
|
);
|
|
51579
|
-
const parent =
|
|
51772
|
+
const parent = path110.dirname(target);
|
|
51580
51773
|
await relay.sendResult(cmd.id, "completed", {
|
|
51581
51774
|
path: target,
|
|
51582
51775
|
// null at the filesystem root so the UI can hide the ".." affordance.
|
|
@@ -52047,14 +52240,14 @@ var HostAgentSupervisor = class {
|
|
|
52047
52240
|
}),
|
|
52048
52241
|
CODEAM_AUTO_TOKEN: payload.autoPairToken
|
|
52049
52242
|
};
|
|
52050
|
-
const houseConfigDir =
|
|
52051
|
-
|
|
52243
|
+
const houseConfigDir = path110.join(
|
|
52244
|
+
os71.homedir(),
|
|
52052
52245
|
".codeam",
|
|
52053
52246
|
"house-claude",
|
|
52054
52247
|
payload.deployId
|
|
52055
52248
|
);
|
|
52056
52249
|
try {
|
|
52057
|
-
|
|
52250
|
+
fs96.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
|
|
52058
52251
|
} catch {
|
|
52059
52252
|
}
|
|
52060
52253
|
childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
|
|
@@ -52081,7 +52274,7 @@ var HostAgentSupervisor = class {
|
|
|
52081
52274
|
report("installing", "installing agent CLI");
|
|
52082
52275
|
await this.runAgentInstall(payload.agentInstallScript);
|
|
52083
52276
|
}
|
|
52084
|
-
const home = process.env.HOME ||
|
|
52277
|
+
const home = process.env.HOME || os71.homedir();
|
|
52085
52278
|
childEnv.PATH = `${home}/.local/bin:${process.env.PATH ?? ""}`;
|
|
52086
52279
|
if (payload.cloneToken) {
|
|
52087
52280
|
try {
|
|
@@ -52089,13 +52282,13 @@ var HostAgentSupervisor = class {
|
|
|
52089
52282
|
if ((payload.repoProvider ?? "github") === "gitlab") {
|
|
52090
52283
|
const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
|
|
52091
52284
|
if (glabCmd) {
|
|
52092
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
52285
|
+
childEnv.PATH = `${codeamBinDir()}${path110.delimiter}${childEnv.PATH}`;
|
|
52093
52286
|
await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
|
|
52094
52287
|
}
|
|
52095
52288
|
} else {
|
|
52096
52289
|
const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
|
|
52097
52290
|
if (ghCmd) {
|
|
52098
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
52291
|
+
childEnv.PATH = `${codeamBinDir()}${path110.delimiter}${childEnv.PATH}`;
|
|
52099
52292
|
await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
|
|
52100
52293
|
}
|
|
52101
52294
|
}
|
|
@@ -52123,9 +52316,9 @@ var HostAgentSupervisor = class {
|
|
|
52123
52316
|
);
|
|
52124
52317
|
if (!payload.suppressOnboardingWelcome) {
|
|
52125
52318
|
try {
|
|
52126
|
-
const cfgDir = childEnv.CLAUDE_CONFIG_DIR ||
|
|
52127
|
-
const projectDir =
|
|
52128
|
-
const hasPriorConversation =
|
|
52319
|
+
const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path110.join(os71.homedir(), ".claude");
|
|
52320
|
+
const projectDir = path110.join(cfgDir, "projects", encodeCwd(cwd));
|
|
52321
|
+
const hasPriorConversation = fs96.existsSync(projectDir) && fs96.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
|
|
52129
52322
|
if (hasPriorConversation) {
|
|
52130
52323
|
childEnv.CODEAM_RESUME_LATEST = "1";
|
|
52131
52324
|
log.info(
|
|
@@ -52279,7 +52472,7 @@ var HostAgentSupervisor = class {
|
|
|
52279
52472
|
fallbackResumeTarget() {
|
|
52280
52473
|
const session = getActiveSession();
|
|
52281
52474
|
if (!session || !session.pluginId || !session.pollSecret || !session.agent) return null;
|
|
52282
|
-
const cwd = session.cwd &&
|
|
52475
|
+
const cwd = session.cwd && fs96.existsSync(session.cwd) ? session.cwd : process.cwd();
|
|
52283
52476
|
if (isFilesystemRoot(cwd)) {
|
|
52284
52477
|
log.warn(
|
|
52285
52478
|
"host-agent",
|
|
@@ -52319,7 +52512,7 @@ var HostAgentSupervisor = class {
|
|
|
52319
52512
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: no saved pairing on this box`);
|
|
52320
52513
|
return;
|
|
52321
52514
|
}
|
|
52322
|
-
if (!session.cwd || !
|
|
52515
|
+
if (!session.cwd || !fs96.existsSync(session.cwd)) {
|
|
52323
52516
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: workspace is gone`);
|
|
52324
52517
|
return;
|
|
52325
52518
|
}
|
|
@@ -52361,7 +52554,7 @@ var HostAgentSupervisor = class {
|
|
|
52361
52554
|
const persisted = new Map((this.sessionStore.load() ?? []).map((r) => [r.deployId, r.agent]));
|
|
52362
52555
|
for (const c2 of this.children.values()) persisted.set(c2.deployId, c2.agent);
|
|
52363
52556
|
return this.listSavedSessions().map((s) => ({ s, deployId: deployIdFromWorkspace(s.cwd) })).filter(
|
|
52364
|
-
(x) => x.deployId !== null && !!x.s.cwd &&
|
|
52557
|
+
(x) => x.deployId !== null && !!x.s.cwd && fs96.existsSync(x.s.cwd)
|
|
52365
52558
|
).map(({ s, deployId }) => {
|
|
52366
52559
|
const agent = persisted.get(deployId);
|
|
52367
52560
|
return { deployId, sessionId: s.id, ...agent ? { agent } : {} };
|
|
@@ -52413,7 +52606,7 @@ var HostAgentSupervisor = class {
|
|
|
52413
52606
|
if (this.children.has(deployId)) return;
|
|
52414
52607
|
const st3 = this.resumeStateFor(target);
|
|
52415
52608
|
try {
|
|
52416
|
-
const cwd =
|
|
52609
|
+
const cwd = fs96.existsSync(target.cwd) ? target.cwd : process.cwd();
|
|
52417
52610
|
const proc = this.resumeSpawner(
|
|
52418
52611
|
{ ...readHouseProxyChildEnv(deployId), CODEAM_RESUME_SESSION_ID: session.id },
|
|
52419
52612
|
cwd
|
|
@@ -52440,7 +52633,7 @@ var HostAgentSupervisor = class {
|
|
|
52440
52633
|
return;
|
|
52441
52634
|
}
|
|
52442
52635
|
if (tracked && signal) {
|
|
52443
|
-
this.onResumeChildExit(target, 128 + (
|
|
52636
|
+
this.onResumeChildExit(target, 128 + (os71.constants.signals[signal] ?? 9), `signal ${signal}`);
|
|
52444
52637
|
return;
|
|
52445
52638
|
}
|
|
52446
52639
|
log.warn(
|
|
@@ -52483,7 +52676,7 @@ var HostAgentSupervisor = class {
|
|
|
52483
52676
|
if (Date.now() - child.startedAt < CRASH_RESPAWN_MIN_UPTIME_MS) return false;
|
|
52484
52677
|
const session = pickSavedSessionForWorkspace(this.listSavedSessions(), child.cwd);
|
|
52485
52678
|
if (!session) return false;
|
|
52486
|
-
const exitCode = typeof code === "number" ? code : 128 + (signal ?
|
|
52679
|
+
const exitCode = typeof code === "number" ? code : 128 + (signal ? os71.constants.signals[signal] ?? 9 : 9);
|
|
52487
52680
|
log.warn(
|
|
52488
52681
|
"host-agent",
|
|
52489
52682
|
`session deploy=${child.deployId.slice(0, 8)} died (${signal ?? code}) after ${Math.round((Date.now() - child.startedAt) / 1e3)}s \u2014 respawning it (resume)`
|
|
@@ -52632,12 +52825,12 @@ var HostAgentSupervisor = class {
|
|
|
52632
52825
|
this.untrackChild(deployId);
|
|
52633
52826
|
}
|
|
52634
52827
|
const dirs = [
|
|
52635
|
-
|
|
52636
|
-
|
|
52828
|
+
path110.join(selfHostedWorkspaceRoot(), deployId),
|
|
52829
|
+
path110.join(os71.homedir(), ".codeam", "house-claude", deployId)
|
|
52637
52830
|
];
|
|
52638
52831
|
for (const dir of dirs) {
|
|
52639
52832
|
try {
|
|
52640
|
-
|
|
52833
|
+
fs96.rmSync(dir, { recursive: true, force: true });
|
|
52641
52834
|
} catch (err) {
|
|
52642
52835
|
log.warn(
|
|
52643
52836
|
"host-agent",
|
|
@@ -52804,8 +52997,8 @@ async function invite() {
|
|
|
52804
52997
|
var import_node_dns = require("dns");
|
|
52805
52998
|
var import_node_util11 = require("util");
|
|
52806
52999
|
var import_node_crypto17 = require("crypto");
|
|
52807
|
-
var
|
|
52808
|
-
var
|
|
53000
|
+
var fs97 = __toESM(require("fs"));
|
|
53001
|
+
var path111 = __toESM(require("path"));
|
|
52809
53002
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
52810
53003
|
var dnsResolveP = (0, import_node_util11.promisify)(import_node_dns.resolve);
|
|
52811
53004
|
async function checkDns(apiBase2) {
|
|
@@ -52861,13 +53054,13 @@ async function checkHealth(apiBase2) {
|
|
|
52861
53054
|
}
|
|
52862
53055
|
}
|
|
52863
53056
|
function checkConfigDir() {
|
|
52864
|
-
const dir =
|
|
53057
|
+
const dir = path111.join(require("os").homedir(), ".codeam");
|
|
52865
53058
|
try {
|
|
52866
|
-
|
|
52867
|
-
const probe =
|
|
52868
|
-
|
|
52869
|
-
const read =
|
|
52870
|
-
|
|
53059
|
+
fs97.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
53060
|
+
const probe = path111.join(dir, ".doctor-probe");
|
|
53061
|
+
fs97.writeFileSync(probe, "ok", { mode: 384 });
|
|
53062
|
+
const read = fs97.readFileSync(probe, "utf8");
|
|
53063
|
+
fs97.unlinkSync(probe);
|
|
52871
53064
|
if (read !== "ok") throw new Error("write/read round-trip mismatch");
|
|
52872
53065
|
return {
|
|
52873
53066
|
id: "config-dir",
|
|
@@ -52907,9 +53100,9 @@ function checkSessions() {
|
|
|
52907
53100
|
}
|
|
52908
53101
|
}
|
|
52909
53102
|
function checkAgentBinaries() {
|
|
52910
|
-
const
|
|
53103
|
+
const os74 = createOsStrategy();
|
|
52911
53104
|
return getEnabledAgents().map((meta) => {
|
|
52912
|
-
const found =
|
|
53105
|
+
const found = os74.findInPath(meta.binaryName);
|
|
52913
53106
|
return {
|
|
52914
53107
|
id: `agent-${meta.id}`,
|
|
52915
53108
|
label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
|
|
@@ -52931,7 +53124,7 @@ function checkNodePty() {
|
|
|
52931
53124
|
detail: "not required on this platform"
|
|
52932
53125
|
};
|
|
52933
53126
|
}
|
|
52934
|
-
const vendoredPath =
|
|
53127
|
+
const vendoredPath = path111.join(__dirname, "vendor", "node-pty");
|
|
52935
53128
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
52936
53129
|
try {
|
|
52937
53130
|
require(target);
|
|
@@ -52973,7 +53166,7 @@ function checkChokidar() {
|
|
|
52973
53166
|
}
|
|
52974
53167
|
async function doctor(args2 = []) {
|
|
52975
53168
|
const json = args2.includes("--json");
|
|
52976
|
-
const cliVersion = true ? "2.76.
|
|
53169
|
+
const cliVersion = true ? "2.76.13" : "0.0.0-dev";
|
|
52977
53170
|
const apiBase2 = resolveApiBaseUrl();
|
|
52978
53171
|
const diagnosticId = (0, import_node_crypto17.randomUUID)();
|
|
52979
53172
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
@@ -53497,7 +53690,7 @@ async function mcpWarm(argv = [], opts = {}) {
|
|
|
53497
53690
|
// src/commands/version.ts
|
|
53498
53691
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
53499
53692
|
function version2() {
|
|
53500
|
-
const v = true ? "2.76.
|
|
53693
|
+
const v = true ? "2.76.13" : "unknown";
|
|
53501
53694
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
53502
53695
|
}
|
|
53503
53696
|
|
|
@@ -53630,10 +53823,10 @@ function tryShowSubcommandHelp(cmd, args2) {
|
|
|
53630
53823
|
var _subcommandHelpKeys = Object.keys(HELPS);
|
|
53631
53824
|
|
|
53632
53825
|
// src/index.ts
|
|
53633
|
-
var
|
|
53826
|
+
var os73 = __toESM(require("os"));
|
|
53634
53827
|
if (!process.env.HOME) {
|
|
53635
53828
|
try {
|
|
53636
|
-
const home =
|
|
53829
|
+
const home = os73.homedir();
|
|
53637
53830
|
if (home) process.env.HOME = home;
|
|
53638
53831
|
} catch {
|
|
53639
53832
|
}
|