codeam-cli 2.76.46 → 2.76.47
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/dist/index.js +354 -298
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -374,8 +374,8 @@ function defaultSpawn(timeoutMs) {
|
|
|
374
374
|
});
|
|
375
375
|
}
|
|
376
376
|
function resolveConvexBin(cwd) {
|
|
377
|
-
const local =
|
|
378
|
-
if (
|
|
377
|
+
const local = path118.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "convex.cmd" : "convex");
|
|
378
|
+
if (fs106.existsSync(local)) return { cmd: local, args: [] };
|
|
379
379
|
return { cmd: "npx", args: ["--yes", "convex"] };
|
|
380
380
|
}
|
|
381
381
|
function redact(text, key) {
|
|
@@ -506,13 +506,13 @@ async function runConvexAdminMcp(client3, id) {
|
|
|
506
506
|
});
|
|
507
507
|
await server.connect(new StdioServerTransport());
|
|
508
508
|
}
|
|
509
|
-
var import_node_child_process42,
|
|
509
|
+
var import_node_child_process42, fs106, path118, TOOLS;
|
|
510
510
|
var init_convex_admin_mcp = __esm({
|
|
511
511
|
"src/integrations/convex-admin-mcp.ts"() {
|
|
512
512
|
"use strict";
|
|
513
513
|
import_node_child_process42 = require("child_process");
|
|
514
|
-
|
|
515
|
-
|
|
514
|
+
fs106 = __toESM(require("fs"));
|
|
515
|
+
path118 = __toESM(require("path"));
|
|
516
516
|
TOOLS = [
|
|
517
517
|
{
|
|
518
518
|
name: "tables",
|
|
@@ -4393,11 +4393,11 @@ function quiet(fn) {
|
|
|
4393
4393
|
log.debug(TAG, "ignored sync error", err);
|
|
4394
4394
|
}
|
|
4395
4395
|
}
|
|
4396
|
-
function rmIfExistsQuiet(
|
|
4396
|
+
function rmIfExistsQuiet(path120) {
|
|
4397
4397
|
try {
|
|
4398
|
-
fs2.rmSync(
|
|
4398
|
+
fs2.rmSync(path120, { force: true });
|
|
4399
4399
|
} catch (err) {
|
|
4400
|
-
log.debug(TAG, `rmIfExists failed for ${
|
|
4400
|
+
log.debug(TAG, `rmIfExists failed for ${path120}`, err);
|
|
4401
4401
|
}
|
|
4402
4402
|
}
|
|
4403
4403
|
function killQuiet(target, signal = "SIGTERM") {
|
|
@@ -4601,8 +4601,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
|
|
|
4601
4601
|
return decodedFile;
|
|
4602
4602
|
};
|
|
4603
4603
|
}
|
|
4604
|
-
function normalizeWindowsPath(
|
|
4605
|
-
return
|
|
4604
|
+
function normalizeWindowsPath(path120) {
|
|
4605
|
+
return path120.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
4606
4606
|
}
|
|
4607
4607
|
|
|
4608
4608
|
// ../../node_modules/@posthog/core/dist/error-tracking/index.mjs
|
|
@@ -7335,13 +7335,13 @@ var PostHogCoreStateless = class {
|
|
|
7335
7335
|
sentFromRoute += batchMessages.length;
|
|
7336
7336
|
}
|
|
7337
7337
|
}
|
|
7338
|
-
async _sendOtlpBatch({ path:
|
|
7338
|
+
async _sendOtlpBatch({ path: path120, payload }) {
|
|
7339
7339
|
if (this.disabled) return {
|
|
7340
7340
|
kind: "fatal",
|
|
7341
7341
|
error: new Error("The client is disabled")
|
|
7342
7342
|
};
|
|
7343
7343
|
const serialized = JSON.stringify(payload);
|
|
7344
|
-
const url2 = `${this.host}/i/v1/${
|
|
7344
|
+
const url2 = `${this.host}/i/v1/${path120}?token=${encodeURIComponent(this.apiKey)}`;
|
|
7345
7345
|
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
|
|
7346
7346
|
const fetchOptions = {
|
|
7347
7347
|
method: "POST",
|
|
@@ -8581,14 +8581,14 @@ async function addSourceContext(frames, openSourceFile = import_promises.open, l
|
|
|
8581
8581
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
8582
8582
|
return frames;
|
|
8583
8583
|
}
|
|
8584
|
-
async function openRegularSourceFile(
|
|
8584
|
+
async function openRegularSourceFile(path120, openSourceFile, logger) {
|
|
8585
8585
|
let fileHandle;
|
|
8586
8586
|
let isValid = false;
|
|
8587
8587
|
try {
|
|
8588
|
-
fileHandle = await openSourceFile(
|
|
8588
|
+
fileHandle = await openSourceFile(path120, import_node_fs.constants.O_RDONLY | import_node_fs.constants.O_NONBLOCK);
|
|
8589
8589
|
const fileStat = await fileHandle.stat();
|
|
8590
8590
|
if (!fileStat.isFile()) return;
|
|
8591
|
-
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${
|
|
8591
|
+
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${path120}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
|
|
8592
8592
|
isValid = true;
|
|
8593
8593
|
return fileHandle;
|
|
8594
8594
|
} catch {
|
|
@@ -8598,8 +8598,8 @@ async function openRegularSourceFile(path119, openSourceFile, logger) {
|
|
|
8598
8598
|
});
|
|
8599
8599
|
}
|
|
8600
8600
|
}
|
|
8601
|
-
async function getContextLinesFromFile(
|
|
8602
|
-
const fileHandle = await openRegularSourceFile(
|
|
8601
|
+
async function getContextLinesFromFile(path120, ranges, output, cacheKey, openSourceFile, logger) {
|
|
8602
|
+
const fileHandle = await openRegularSourceFile(path120, openSourceFile, logger);
|
|
8603
8603
|
if (void 0 === fileHandle) return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
8604
8604
|
const openedFileHandle = fileHandle;
|
|
8605
8605
|
return new Promise((resolve13) => {
|
|
@@ -8701,22 +8701,22 @@ function clearLineContext(frame) {
|
|
|
8701
8701
|
delete frame.context_line;
|
|
8702
8702
|
delete frame.post_context;
|
|
8703
8703
|
}
|
|
8704
|
-
function shouldSkipContextLinesForFile(
|
|
8705
|
-
return
|
|
8704
|
+
function shouldSkipContextLinesForFile(path120) {
|
|
8705
|
+
return path120.startsWith("node:") || path120.endsWith(".min.js") || path120.endsWith(".min.cjs") || path120.endsWith(".min.mjs") || path120.startsWith("data:");
|
|
8706
8706
|
}
|
|
8707
8707
|
function shouldSkipContextLinesForFrame(frame) {
|
|
8708
8708
|
if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
|
|
8709
8709
|
if (void 0 !== frame.colno && frame.colno > MAX_CONTEXTLINES_COLNO) return true;
|
|
8710
8710
|
return false;
|
|
8711
8711
|
}
|
|
8712
|
-
function makeSourceCacheKey(
|
|
8713
|
-
if ((0, import_node_path.isAbsolute)(
|
|
8712
|
+
function makeSourceCacheKey(path120, basePath) {
|
|
8713
|
+
if ((0, import_node_path.isAbsolute)(path120)) return JSON.stringify([
|
|
8714
8714
|
null,
|
|
8715
|
-
|
|
8715
|
+
path120
|
|
8716
8716
|
]);
|
|
8717
8717
|
return void 0 === basePath ? void 0 : JSON.stringify([
|
|
8718
8718
|
basePath,
|
|
8719
|
-
|
|
8719
|
+
path120
|
|
8720
8720
|
]);
|
|
8721
8721
|
}
|
|
8722
8722
|
function rangeExistsInContentCache(cacheKey, range) {
|
|
@@ -11378,7 +11378,7 @@ function readAnonId() {
|
|
|
11378
11378
|
}
|
|
11379
11379
|
function superProperties() {
|
|
11380
11380
|
return {
|
|
11381
|
-
cliVersion: true ? "2.76.
|
|
11381
|
+
cliVersion: true ? "2.76.47" : "0.0.0-dev",
|
|
11382
11382
|
nodeVersion: process.version,
|
|
11383
11383
|
platform: process.platform,
|
|
11384
11384
|
arch: process.arch,
|
|
@@ -11627,7 +11627,7 @@ var http = __toESM(require("http"));
|
|
|
11627
11627
|
// package.json
|
|
11628
11628
|
var package_default = {
|
|
11629
11629
|
name: "codeam-cli",
|
|
11630
|
-
version: "2.76.
|
|
11630
|
+
version: "2.76.47",
|
|
11631
11631
|
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.",
|
|
11632
11632
|
type: "commonjs",
|
|
11633
11633
|
main: "dist/index.js",
|
|
@@ -13003,7 +13003,7 @@ var CommandRelayService = class _CommandRelayService {
|
|
|
13003
13003
|
// fresh + clear the "CLI update available" banner after a self-update
|
|
13004
13004
|
// (a codespace that reinstalls @latest reconnects via heartbeat, not
|
|
13005
13005
|
// pair/reconnect). Older backends ignore the extra field.
|
|
13006
|
-
..."2.76.
|
|
13006
|
+
..."2.76.47" ? { ideVersion: "2.76.47" } : {}
|
|
13007
13007
|
};
|
|
13008
13008
|
try {
|
|
13009
13009
|
const res = await _postJson(`${API_BASE2}/api/plugin/heartbeat`, body, this.pollSecretHeader());
|
|
@@ -13326,10 +13326,10 @@ var WINDOWS_LEGACY_JUNCTIONS = [
|
|
|
13326
13326
|
/[\\/]Start Menu([\\/]|$)/i,
|
|
13327
13327
|
/[\\/]Templates([\\/]|$)/i
|
|
13328
13328
|
];
|
|
13329
|
-
function isUnsafeWindowsWatchRoot(dir,
|
|
13329
|
+
function isUnsafeWindowsWatchRoot(dir, homedir58) {
|
|
13330
13330
|
const norm = (p2) => p2.replace(/\//g, "\\").replace(/\\+$/, "").toLowerCase();
|
|
13331
13331
|
const cwd = norm(dir);
|
|
13332
|
-
const home = norm(
|
|
13332
|
+
const home = norm(homedir58);
|
|
13333
13333
|
if (cwd === home) return true;
|
|
13334
13334
|
if (/^[a-z]:$/.test(cwd)) return true;
|
|
13335
13335
|
const sysRoots = [
|
|
@@ -18133,10 +18133,10 @@ function buildForPlatform(platform3) {
|
|
|
18133
18133
|
var import_node_crypto5 = require("crypto");
|
|
18134
18134
|
|
|
18135
18135
|
// src/agents/claude/resolver.ts
|
|
18136
|
-
function buildClaudeLaunch(extraArgs = [],
|
|
18137
|
-
const found =
|
|
18136
|
+
function buildClaudeLaunch(extraArgs = [], os78 = createOsStrategy()) {
|
|
18137
|
+
const found = os78.findInPath("claude") ?? os78.findInPath("claude-code");
|
|
18138
18138
|
if (!found) return null;
|
|
18139
|
-
return
|
|
18139
|
+
return os78.buildLaunch(found, extraArgs);
|
|
18140
18140
|
}
|
|
18141
18141
|
|
|
18142
18142
|
// src/agents/claude/installer.ts
|
|
@@ -18235,8 +18235,8 @@ function parseClaudeAuthStatus(stdout) {
|
|
|
18235
18235
|
return "unknown";
|
|
18236
18236
|
}
|
|
18237
18237
|
}
|
|
18238
|
-
function probeClaudeLocalAuth(
|
|
18239
|
-
const bin =
|
|
18238
|
+
function probeClaudeLocalAuth(os78, timeoutMs = 1e4) {
|
|
18239
|
+
const bin = os78.findInPath("claude") ?? os78.findInPath("claude-code");
|
|
18240
18240
|
if (!bin) return Promise.resolve("unknown");
|
|
18241
18241
|
return new Promise((resolve13) => {
|
|
18242
18242
|
try {
|
|
@@ -19014,8 +19014,8 @@ var ClaudeRuntimeStrategy = class {
|
|
|
19014
19014
|
meta = getAgent("claude");
|
|
19015
19015
|
mode = "interactive";
|
|
19016
19016
|
os;
|
|
19017
|
-
constructor(
|
|
19018
|
-
this.os =
|
|
19017
|
+
constructor(os78) {
|
|
19018
|
+
this.os = os78;
|
|
19019
19019
|
}
|
|
19020
19020
|
probeLocalAuth() {
|
|
19021
19021
|
return probeClaudeLocalAuth(this.os);
|
|
@@ -20132,8 +20132,8 @@ function codexCredentialLocator() {
|
|
|
20132
20132
|
function codexLoginLauncher() {
|
|
20133
20133
|
return {
|
|
20134
20134
|
async ensureInstalled() {
|
|
20135
|
-
const
|
|
20136
|
-
return
|
|
20135
|
+
const os78 = createOsStrategy();
|
|
20136
|
+
return os78.findInPath("codex") !== null;
|
|
20137
20137
|
},
|
|
20138
20138
|
launch() {
|
|
20139
20139
|
return (0, import_node_child_process4.spawn)("codex", ["login"], { stdio: "inherit" });
|
|
@@ -20162,8 +20162,8 @@ var CodexRuntimeStrategy = class {
|
|
|
20162
20162
|
meta = getAgent("codex");
|
|
20163
20163
|
mode = "interactive";
|
|
20164
20164
|
os;
|
|
20165
|
-
constructor(
|
|
20166
|
-
this.os =
|
|
20165
|
+
constructor(os78) {
|
|
20166
|
+
this.os = os78;
|
|
20167
20167
|
}
|
|
20168
20168
|
async prepareLaunch() {
|
|
20169
20169
|
let binary = this.os.findInPath("codex");
|
|
@@ -20284,12 +20284,12 @@ var CodexRuntimeStrategy = class {
|
|
|
20284
20284
|
return (await runOnce()).text;
|
|
20285
20285
|
}
|
|
20286
20286
|
};
|
|
20287
|
-
function resolveNpm(
|
|
20288
|
-
return
|
|
20287
|
+
function resolveNpm(os78) {
|
|
20288
|
+
return os78.id === "win32" ? "npm.cmd" : "npm";
|
|
20289
20289
|
}
|
|
20290
|
-
async function installCodexViaNpm(
|
|
20290
|
+
async function installCodexViaNpm(os78) {
|
|
20291
20291
|
return new Promise((resolve13, reject) => {
|
|
20292
|
-
const proc = (0, import_node_child_process5.spawn)(resolveNpm(
|
|
20292
|
+
const proc = (0, import_node_child_process5.spawn)(resolveNpm(os78), ["install", "-g", "--no-audit", "--no-fund", "@openai/codex"], {
|
|
20293
20293
|
stdio: "inherit"
|
|
20294
20294
|
});
|
|
20295
20295
|
proc.on("close", (code) => {
|
|
@@ -20306,16 +20306,16 @@ async function installCodexViaNpm(os77) {
|
|
|
20306
20306
|
});
|
|
20307
20307
|
});
|
|
20308
20308
|
}
|
|
20309
|
-
function augmentNpmGlobalBin(
|
|
20309
|
+
function augmentNpmGlobalBin(os78) {
|
|
20310
20310
|
try {
|
|
20311
|
-
const result = (0, import_node_child_process5.spawnSync)(resolveNpm(
|
|
20311
|
+
const result = (0, import_node_child_process5.spawnSync)(resolveNpm(os78), ["prefix", "-g"], {
|
|
20312
20312
|
stdio: ["ignore", "pipe", "ignore"]
|
|
20313
20313
|
});
|
|
20314
20314
|
if (result.status !== 0) return;
|
|
20315
20315
|
const prefix = result.stdout.toString().trim();
|
|
20316
20316
|
if (!prefix) return;
|
|
20317
|
-
const binDir =
|
|
20318
|
-
|
|
20317
|
+
const binDir = os78.id === "win32" ? prefix : path27.join(prefix, "bin");
|
|
20318
|
+
os78.augmentPath([binDir]);
|
|
20319
20319
|
} catch {
|
|
20320
20320
|
}
|
|
20321
20321
|
}
|
|
@@ -20509,10 +20509,10 @@ function manualInstallHint(runner, tools) {
|
|
|
20509
20509
|
const argv = osPackageInstallArgv(detectPackageManager(runner), [...tools]);
|
|
20510
20510
|
return argv ? `\`sudo ${argv.join(" ")}\`` : `your package manager (e.g. \`${pkgs}\`)`;
|
|
20511
20511
|
}
|
|
20512
|
-
function writeUnzipShim(
|
|
20512
|
+
function writeUnzipShim(os78, runner) {
|
|
20513
20513
|
const python = ["python3", "python"].find((p2) => runner.which(p2));
|
|
20514
20514
|
if (!python) return null;
|
|
20515
|
-
const dir =
|
|
20515
|
+
const dir = os78.scratchPath("codeam-cr-prereq");
|
|
20516
20516
|
const shim = path29.join(dir, "unzip");
|
|
20517
20517
|
const script = `#!/bin/sh
|
|
20518
20518
|
set -e
|
|
@@ -20534,9 +20534,9 @@ exec ${python} -m zipfile -e "$archive" "$dest"
|
|
|
20534
20534
|
(0, import_node_fs6.chmodSync)(shim, 448);
|
|
20535
20535
|
return dir;
|
|
20536
20536
|
}
|
|
20537
|
-
async function ensureInstallPrerequisites(
|
|
20537
|
+
async function ensureInstallPrerequisites(os78, deps = {}) {
|
|
20538
20538
|
const runner = deps.runner ?? defaultOsRunner;
|
|
20539
|
-
const missing = REQUIRED_TOOLS.filter((t2) =>
|
|
20539
|
+
const missing = REQUIRED_TOOLS.filter((t2) => os78.findInPath(t2) === null);
|
|
20540
20540
|
if (missing.length === 0) return { ok: true, extraPath: [] };
|
|
20541
20541
|
log.info(
|
|
20542
20542
|
"coderabbit",
|
|
@@ -20555,10 +20555,10 @@ async function ensureInstallPrerequisites(os77, deps = {}) {
|
|
|
20555
20555
|
);
|
|
20556
20556
|
}
|
|
20557
20557
|
}
|
|
20558
|
-
const stillMissing = REQUIRED_TOOLS.filter((t2) =>
|
|
20558
|
+
const stillMissing = REQUIRED_TOOLS.filter((t2) => os78.findInPath(t2) === null);
|
|
20559
20559
|
if (stillMissing.length === 0) return { ok: true, extraPath: [] };
|
|
20560
20560
|
if (stillMissing.length === 1 && stillMissing[0] === "unzip") {
|
|
20561
|
-
const shimDir = writeUnzipShim(
|
|
20561
|
+
const shimDir = writeUnzipShim(os78, runner);
|
|
20562
20562
|
if (shimDir) {
|
|
20563
20563
|
log.info("coderabbit", "unzip is unavailable \u2014 using a scoped python zipfile shim");
|
|
20564
20564
|
return { ok: true, extraPath: [shimDir] };
|
|
@@ -20621,15 +20621,15 @@ function summarizeInstallFailure(output) {
|
|
|
20621
20621
|
}
|
|
20622
20622
|
return lines.length > 0 ? lines[lines.length - 1] : null;
|
|
20623
20623
|
}
|
|
20624
|
-
async function ensureCoderabbitInstalled(
|
|
20625
|
-
if (
|
|
20626
|
-
if (
|
|
20624
|
+
async function ensureCoderabbitInstalled(os78, deps = {}) {
|
|
20625
|
+
if (os78.findInPath("coderabbit")) return { ok: true };
|
|
20626
|
+
if (os78.id === "win32") {
|
|
20627
20627
|
return {
|
|
20628
20628
|
ok: false,
|
|
20629
20629
|
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."
|
|
20630
20630
|
};
|
|
20631
20631
|
}
|
|
20632
|
-
const prereq = await ensureInstallPrerequisites(
|
|
20632
|
+
const prereq = await ensureInstallPrerequisites(os78, deps);
|
|
20633
20633
|
if (!prereq.ok) return { ok: false, error: prereq.error };
|
|
20634
20634
|
const env = { ...process.env };
|
|
20635
20635
|
if (prereq.extraPath.length > 0) {
|
|
@@ -20638,8 +20638,8 @@ async function ensureCoderabbitInstalled(os77, deps = {}) {
|
|
|
20638
20638
|
log.info("coderabbit", "CodeRabbit CLI not found \u2014 installing via the official script");
|
|
20639
20639
|
const run3 = deps.runInstallScript ?? defaultRunInstallScript;
|
|
20640
20640
|
const { code, output } = await run3(env);
|
|
20641
|
-
|
|
20642
|
-
const binary =
|
|
20641
|
+
os78.augmentPath([`${os78.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
|
|
20642
|
+
const binary = os78.findInPath("coderabbit");
|
|
20643
20643
|
const detail = summarizeInstallFailure(output);
|
|
20644
20644
|
if (binary !== null) {
|
|
20645
20645
|
if (code === 0) return { ok: true };
|
|
@@ -20693,10 +20693,10 @@ function coderabbitCredentialLocator() {
|
|
|
20693
20693
|
validate: validateNonEmptyCredential
|
|
20694
20694
|
};
|
|
20695
20695
|
}
|
|
20696
|
-
function coderabbitLoginLauncher(
|
|
20696
|
+
function coderabbitLoginLauncher(os78) {
|
|
20697
20697
|
return {
|
|
20698
20698
|
async ensureInstalled() {
|
|
20699
|
-
const result = await ensureCoderabbitInstalled(
|
|
20699
|
+
const result = await ensureCoderabbitInstalled(os78);
|
|
20700
20700
|
if (!result.ok && result.error) console.error(`
|
|
20701
20701
|
\u2717 ${result.error}
|
|
20702
20702
|
`);
|
|
@@ -20756,8 +20756,8 @@ function pickLine(obj) {
|
|
|
20756
20756
|
function toHunk(raw, groupSeverity) {
|
|
20757
20757
|
if (!raw || typeof raw !== "object") return null;
|
|
20758
20758
|
const o = raw;
|
|
20759
|
-
const
|
|
20760
|
-
if (!
|
|
20759
|
+
const path120 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
|
|
20760
|
+
if (!path120) return null;
|
|
20761
20761
|
const message = asString(
|
|
20762
20762
|
pick(o, [
|
|
20763
20763
|
"comment",
|
|
@@ -20774,7 +20774,7 @@ function toHunk(raw, groupSeverity) {
|
|
|
20774
20774
|
const severity = normSeverity(pick(o, ["severity", "level", "priority", "impact"])) ?? normSeverity(groupSeverity);
|
|
20775
20775
|
const locObj = pick(o, ["location"]) ?? o;
|
|
20776
20776
|
return {
|
|
20777
|
-
path:
|
|
20777
|
+
path: path120.trim(),
|
|
20778
20778
|
line: pickLine(o) ?? pickLine(locObj),
|
|
20779
20779
|
severity,
|
|
20780
20780
|
message: (title && message ? `${title}: ${message}` : title || message).trim() || "(no message)"
|
|
@@ -20857,10 +20857,10 @@ function parsePlain(stdout) {
|
|
|
20857
20857
|
for (const line of stdout.split(/\r?\n/)) {
|
|
20858
20858
|
const m = line.match(HUNK_LINE_RE);
|
|
20859
20859
|
if (!m) continue;
|
|
20860
|
-
const [,
|
|
20861
|
-
if (!
|
|
20860
|
+
const [, path120, lineNo, sevToken, message] = m;
|
|
20861
|
+
if (!path120 || !lineNo || !message) continue;
|
|
20862
20862
|
hunks.push({
|
|
20863
|
-
path:
|
|
20863
|
+
path: path120.trim(),
|
|
20864
20864
|
line: Number(lineNo),
|
|
20865
20865
|
severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
|
|
20866
20866
|
message: message.trim().replace(/^[*-]\s+/, "")
|
|
@@ -20920,8 +20920,8 @@ var CoderabbitRuntimeStrategy = class {
|
|
|
20920
20920
|
meta = getAgent("coderabbit");
|
|
20921
20921
|
mode = "batch";
|
|
20922
20922
|
os;
|
|
20923
|
-
constructor(
|
|
20924
|
-
this.os =
|
|
20923
|
+
constructor(os78) {
|
|
20924
|
+
this.os = os78;
|
|
20925
20925
|
}
|
|
20926
20926
|
getDefaultArgs() {
|
|
20927
20927
|
return ["review", "--agent"];
|
|
@@ -21192,10 +21192,10 @@ function cursorCredentialLocator() {
|
|
|
21192
21192
|
validate: validateNonEmptyCredential
|
|
21193
21193
|
};
|
|
21194
21194
|
}
|
|
21195
|
-
function cursorLoginLauncher(
|
|
21195
|
+
function cursorLoginLauncher(os78) {
|
|
21196
21196
|
return {
|
|
21197
21197
|
async ensureInstalled() {
|
|
21198
|
-
if (
|
|
21198
|
+
if (os78.findInPath("cursor-agent")) return true;
|
|
21199
21199
|
console.error(
|
|
21200
21200
|
"\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"
|
|
21201
21201
|
);
|
|
@@ -21259,8 +21259,8 @@ var CursorRuntimeStrategy = class {
|
|
|
21259
21259
|
meta = getAgent("cursor");
|
|
21260
21260
|
mode = "interactive";
|
|
21261
21261
|
os;
|
|
21262
|
-
constructor(
|
|
21263
|
-
this.os =
|
|
21262
|
+
constructor(os78) {
|
|
21263
|
+
this.os = os78;
|
|
21264
21264
|
}
|
|
21265
21265
|
async prepareLaunch() {
|
|
21266
21266
|
const binary = this.os.findInPath("cursor-agent");
|
|
@@ -21478,10 +21478,10 @@ function aiderCredentialLocator() {
|
|
|
21478
21478
|
validate: validateNonEmptyCredential
|
|
21479
21479
|
};
|
|
21480
21480
|
}
|
|
21481
|
-
function aiderLoginLauncher(
|
|
21481
|
+
function aiderLoginLauncher(os78) {
|
|
21482
21482
|
return {
|
|
21483
21483
|
async ensureInstalled() {
|
|
21484
|
-
if (
|
|
21484
|
+
if (os78.findInPath("aider")) return true;
|
|
21485
21485
|
console.error(
|
|
21486
21486
|
"\n \u2717 aider binary not on PATH.\n Install Aider:\n pip install aider-chat\n then re-run `codeam link aider`.\n"
|
|
21487
21487
|
);
|
|
@@ -21491,7 +21491,7 @@ function aiderLoginLauncher(os77) {
|
|
|
21491
21491
|
console.error(
|
|
21492
21492
|
"\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"
|
|
21493
21493
|
);
|
|
21494
|
-
return (0, import_node_child_process12.spawn)(
|
|
21494
|
+
return (0, import_node_child_process12.spawn)(os78.id === "win32" ? "cmd.exe" : "sh", os78.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
|
|
21495
21495
|
stdio: "ignore"
|
|
21496
21496
|
});
|
|
21497
21497
|
}
|
|
@@ -21775,8 +21775,8 @@ var AiderRuntimeStrategy = class {
|
|
|
21775
21775
|
meta = getAgent("aider");
|
|
21776
21776
|
mode = "interactive";
|
|
21777
21777
|
os;
|
|
21778
|
-
constructor(
|
|
21779
|
-
this.os =
|
|
21778
|
+
constructor(os78) {
|
|
21779
|
+
this.os = os78;
|
|
21780
21780
|
}
|
|
21781
21781
|
async prepareLaunch() {
|
|
21782
21782
|
augmentUserLocalBinPaths();
|
|
@@ -21909,8 +21909,8 @@ function geminiCredentialLocator() {
|
|
|
21909
21909
|
function geminiLoginLauncher() {
|
|
21910
21910
|
return {
|
|
21911
21911
|
async ensureInstalled() {
|
|
21912
|
-
const
|
|
21913
|
-
return
|
|
21912
|
+
const os78 = createOsStrategy();
|
|
21913
|
+
return os78.findInPath("gemini") !== null;
|
|
21914
21914
|
},
|
|
21915
21915
|
launch() {
|
|
21916
21916
|
return (0, import_node_child_process13.spawn)("gemini", ["auth", "login"], { stdio: "inherit" });
|
|
@@ -22100,8 +22100,8 @@ var GeminiRuntimeStrategy = class {
|
|
|
22100
22100
|
meta = getAgent("gemini");
|
|
22101
22101
|
mode = "interactive";
|
|
22102
22102
|
os;
|
|
22103
|
-
constructor(
|
|
22104
|
-
this.os =
|
|
22103
|
+
constructor(os78) {
|
|
22104
|
+
this.os = os78;
|
|
22105
22105
|
}
|
|
22106
22106
|
async prepareLaunch() {
|
|
22107
22107
|
const binary = this.os.findInPath("gemini");
|
|
@@ -22394,8 +22394,8 @@ var KimiRuntimeStrategy = class {
|
|
|
22394
22394
|
meta = getAgent("kimi");
|
|
22395
22395
|
mode = "interactive";
|
|
22396
22396
|
os;
|
|
22397
|
-
constructor(
|
|
22398
|
-
this.os =
|
|
22397
|
+
constructor(os78) {
|
|
22398
|
+
this.os = os78;
|
|
22399
22399
|
}
|
|
22400
22400
|
async prepareLaunch() {
|
|
22401
22401
|
const binary = this.os.findInPath("kimi");
|
|
@@ -22539,8 +22539,8 @@ var OpencodeRuntimeStrategy = class {
|
|
|
22539
22539
|
meta = getAgent("opencode");
|
|
22540
22540
|
mode = "interactive";
|
|
22541
22541
|
os;
|
|
22542
|
-
constructor(
|
|
22543
|
-
this.os =
|
|
22542
|
+
constructor(os78) {
|
|
22543
|
+
this.os = os78;
|
|
22544
22544
|
}
|
|
22545
22545
|
async prepareLaunch() {
|
|
22546
22546
|
const binary = this.os.findInPath("opencode");
|
|
@@ -22723,8 +22723,8 @@ var AntigravityRuntimeStrategy = class {
|
|
|
22723
22723
|
meta = getAgent("antigravity");
|
|
22724
22724
|
mode = "interactive";
|
|
22725
22725
|
os;
|
|
22726
|
-
constructor(
|
|
22727
|
-
this.os =
|
|
22726
|
+
constructor(os78) {
|
|
22727
|
+
this.os = os78;
|
|
22728
22728
|
}
|
|
22729
22729
|
async prepareLaunch() {
|
|
22730
22730
|
const binary = this.os.findInPath("agy");
|
|
@@ -22821,21 +22821,21 @@ var AntigravityRuntimeStrategy = class {
|
|
|
22821
22821
|
|
|
22822
22822
|
// src/agents/registry.ts
|
|
22823
22823
|
var runtimeBuilders = {
|
|
22824
|
-
claude: (
|
|
22825
|
-
codex: (
|
|
22826
|
-
coderabbit: (
|
|
22827
|
-
cursor: (
|
|
22828
|
-
aider: (
|
|
22829
|
-
gemini: (
|
|
22830
|
-
kimi: (
|
|
22831
|
-
opencode: (
|
|
22832
|
-
antigravity: (
|
|
22824
|
+
claude: (os78) => new ClaudeRuntimeStrategy(os78),
|
|
22825
|
+
codex: (os78) => new CodexRuntimeStrategy(os78),
|
|
22826
|
+
coderabbit: (os78) => new CoderabbitRuntimeStrategy(os78),
|
|
22827
|
+
cursor: (os78) => new CursorRuntimeStrategy(os78),
|
|
22828
|
+
aider: (os78) => new AiderRuntimeStrategy(os78),
|
|
22829
|
+
gemini: (os78) => new GeminiRuntimeStrategy(os78),
|
|
22830
|
+
kimi: (os78) => new KimiRuntimeStrategy(os78),
|
|
22831
|
+
opencode: (os78) => new OpencodeRuntimeStrategy(os78),
|
|
22832
|
+
antigravity: (os78) => new AntigravityRuntimeStrategy(os78)
|
|
22833
22833
|
};
|
|
22834
22834
|
var deployBuilders = {
|
|
22835
22835
|
claude: () => new ClaudeDeployStrategy(),
|
|
22836
22836
|
codex: () => new CodexDeployStrategy()
|
|
22837
22837
|
};
|
|
22838
|
-
function createAgentStrategy(agent,
|
|
22838
|
+
function createAgentStrategy(agent, os78 = createOsStrategy()) {
|
|
22839
22839
|
if (!AGENT_REGISTRY[agent]?.enabled) {
|
|
22840
22840
|
throw new Error(
|
|
22841
22841
|
`Agent "${agent}" is not supported in this codeam-cli version. Upgrade with 'npm i -g codeam-cli@latest'.`
|
|
@@ -22845,10 +22845,10 @@ function createAgentStrategy(agent, os77 = createOsStrategy()) {
|
|
|
22845
22845
|
if (!build) {
|
|
22846
22846
|
throw new Error(`No runtime strategy registered for agent "${agent}"`);
|
|
22847
22847
|
}
|
|
22848
|
-
return build(
|
|
22848
|
+
return build(os78);
|
|
22849
22849
|
}
|
|
22850
|
-
function createInteractiveAgentStrategy(agent,
|
|
22851
|
-
const s = createAgentStrategy(agent,
|
|
22850
|
+
function createInteractiveAgentStrategy(agent, os78 = createOsStrategy()) {
|
|
22851
|
+
const s = createAgentStrategy(agent, os78);
|
|
22852
22852
|
if (s.mode !== "interactive") {
|
|
22853
22853
|
throw new Error(
|
|
22854
22854
|
`Agent "${agent}" is a batch agent; use createAgentStrategy + .runOneShot for one-shot reviews.`
|
|
@@ -23562,8 +23562,8 @@ function collectChangedFiles(cwd) {
|
|
|
23562
23562
|
}
|
|
23563
23563
|
return [...byPath.values()];
|
|
23564
23564
|
}
|
|
23565
|
-
function restoreCoderabbitOauthBlob(
|
|
23566
|
-
const dir = path42.join(
|
|
23565
|
+
function restoreCoderabbitOauthBlob(os78, value) {
|
|
23566
|
+
const dir = path42.join(os78.homeDir(), ".coderabbit");
|
|
23567
23567
|
(0, import_node_fs7.mkdirSync)(dir, { recursive: true });
|
|
23568
23568
|
let file = "auth.json";
|
|
23569
23569
|
let contents = value.trim();
|
|
@@ -23583,26 +23583,26 @@ function installFailureMessage(result) {
|
|
|
23583
23583
|
return result.error ?? "CodeRabbit CLI could not be installed";
|
|
23584
23584
|
}
|
|
23585
23585
|
async function configureCoderabbit(input, deps = {}) {
|
|
23586
|
-
const
|
|
23586
|
+
const os78 = deps.os ?? createOsStrategy();
|
|
23587
23587
|
const ensureInstalled = deps.ensureInstalled ?? ensureCoderabbitInstalled;
|
|
23588
23588
|
const isLoggedIn = deps.isLoggedIn ?? defaultIsLoggedIn;
|
|
23589
23589
|
const runOAuth = deps.runOAuthLogin ?? runCoderabbitOAuthLogin;
|
|
23590
23590
|
const snapshot = deps.snapshotDir ?? (() => snapshotCredentialDir());
|
|
23591
23591
|
const capture2 = deps.captureCredential ?? ((b) => diffCapturedCredential(b));
|
|
23592
23592
|
const loginWithApiKey = deps.loginWithApiKey ?? defaultLoginWithApiKey;
|
|
23593
|
-
const home =
|
|
23594
|
-
|
|
23595
|
-
|
|
23593
|
+
const home = os78.homeDir();
|
|
23594
|
+
os78.augmentPath(
|
|
23595
|
+
os78.id === "win32" ? [
|
|
23596
23596
|
path42.join(home, ".local", "bin"),
|
|
23597
23597
|
path42.join(process.env.APPDATA ?? path42.join(home, "AppData", "Roaming"), "npm"),
|
|
23598
23598
|
path42.join(home, "scoop", "shims")
|
|
23599
23599
|
] : [path42.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"]
|
|
23600
23600
|
);
|
|
23601
|
-
const installed2 =
|
|
23601
|
+
const installed2 = os78.findInPath("coderabbit") !== null;
|
|
23602
23602
|
const base = () => ({
|
|
23603
23603
|
action: input.action,
|
|
23604
23604
|
supported: true,
|
|
23605
|
-
installed:
|
|
23605
|
+
installed: os78.findInPath("coderabbit") !== null,
|
|
23606
23606
|
loggedIn: false
|
|
23607
23607
|
});
|
|
23608
23608
|
if (input.action === "status") {
|
|
@@ -23616,7 +23616,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
23616
23616
|
const key = (input.apiKey ?? "").trim();
|
|
23617
23617
|
if (!key) return { ...res2, error: "No API key provided" };
|
|
23618
23618
|
if (!res2.installed) {
|
|
23619
|
-
const inst = await ensureInstalled(
|
|
23619
|
+
const inst = await ensureInstalled(os78);
|
|
23620
23620
|
res2.installed = inst.ok;
|
|
23621
23621
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
23622
23622
|
}
|
|
@@ -23640,7 +23640,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
23640
23640
|
}
|
|
23641
23641
|
if (!res2.installed) {
|
|
23642
23642
|
deps.onEvent?.({ kind: "installing" });
|
|
23643
|
-
const inst = await ensureInstalled(
|
|
23643
|
+
const inst = await ensureInstalled(os78);
|
|
23644
23644
|
res2.installed = inst.ok;
|
|
23645
23645
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
23646
23646
|
}
|
|
@@ -23657,7 +23657,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
23657
23657
|
return { ...res2, loggedIn: true, linked: true };
|
|
23658
23658
|
}
|
|
23659
23659
|
try {
|
|
23660
|
-
restoreCoderabbitOauthBlob(
|
|
23660
|
+
restoreCoderabbitOauthBlob(os78, cred.credential);
|
|
23661
23661
|
} catch (err) {
|
|
23662
23662
|
return {
|
|
23663
23663
|
...res2,
|
|
@@ -23681,7 +23681,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
23681
23681
|
const res2 = base();
|
|
23682
23682
|
if (!installed2) {
|
|
23683
23683
|
deps.onEvent?.({ kind: "installing" });
|
|
23684
|
-
const inst = await ensureInstalled(
|
|
23684
|
+
const inst = await ensureInstalled(os78);
|
|
23685
23685
|
res2.installed = inst.ok;
|
|
23686
23686
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
23687
23687
|
}
|
|
@@ -23721,7 +23721,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
23721
23721
|
}
|
|
23722
23722
|
const res = base();
|
|
23723
23723
|
if (!res.installed) {
|
|
23724
|
-
const inst = await ensureInstalled(
|
|
23724
|
+
const inst = await ensureInstalled(os78);
|
|
23725
23725
|
res.installed = inst.ok;
|
|
23726
23726
|
if (!inst.ok) return { ...res, error: installFailureMessage(inst) };
|
|
23727
23727
|
}
|
|
@@ -28766,11 +28766,11 @@ function resolveDoltInstallStrategy(platform3) {
|
|
|
28766
28766
|
}
|
|
28767
28767
|
var DOLT_RELEASE_BASE = "https://github.com/dolthub/dolt/releases/latest/download";
|
|
28768
28768
|
function doltPlatformTuple(platform3, arch2) {
|
|
28769
|
-
const
|
|
28769
|
+
const os78 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
|
|
28770
28770
|
const a = arch2 === "x64" ? "amd64" : arch2 === "arm64" ? "arm64" : null;
|
|
28771
28771
|
if (!a) return null;
|
|
28772
|
-
if (
|
|
28773
|
-
return `${
|
|
28772
|
+
if (os78 === "windows" && a !== "amd64") return null;
|
|
28773
|
+
return `${os78}-${a}`;
|
|
28774
28774
|
}
|
|
28775
28775
|
function resolveDoltTarballStrategy(targetDir, platform3, arch2) {
|
|
28776
28776
|
const tuple = doltPlatformTuple(platform3, arch2);
|
|
@@ -30618,7 +30618,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
30618
30618
|
});
|
|
30619
30619
|
const token = ctx.pluginAuthToken;
|
|
30620
30620
|
void (async () => {
|
|
30621
|
-
const
|
|
30621
|
+
const os78 = createOsStrategy();
|
|
30622
30622
|
try {
|
|
30623
30623
|
const report = await reviewPullRequest(
|
|
30624
30624
|
{
|
|
@@ -30627,7 +30627,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
30627
30627
|
baseBranch: parsed.baseBranch
|
|
30628
30628
|
},
|
|
30629
30629
|
{
|
|
30630
|
-
runReview: (input) => new CoderabbitRuntimeStrategy(
|
|
30630
|
+
runReview: (input) => new CoderabbitRuntimeStrategy(os78).runOneShot(input),
|
|
30631
30631
|
runGh: (args2) => defaultRunGh(args2),
|
|
30632
30632
|
postReport: async (r) => {
|
|
30633
30633
|
if (!token) return;
|
|
@@ -30774,7 +30774,7 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
|
30774
30774
|
if (!nodeModulesDir) return 0;
|
|
30775
30775
|
const readdirSync20 = deps?.readdirSync ?? fs71.readdirSync;
|
|
30776
30776
|
const statSync19 = deps?.statSync ?? fs71.statSync;
|
|
30777
|
-
const
|
|
30777
|
+
const rmSync16 = deps?.rmSync ?? fs71.rmSync;
|
|
30778
30778
|
let removed = 0;
|
|
30779
30779
|
let entries2;
|
|
30780
30780
|
try {
|
|
@@ -30788,7 +30788,7 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
|
30788
30788
|
try {
|
|
30789
30789
|
const st3 = statSync19(full);
|
|
30790
30790
|
if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
|
|
30791
|
-
|
|
30791
|
+
rmSync16(full, { recursive: true, force: true });
|
|
30792
30792
|
removed++;
|
|
30793
30793
|
} catch {
|
|
30794
30794
|
}
|
|
@@ -31933,11 +31933,11 @@ function resolveTokenValue(args2) {
|
|
|
31933
31933
|
}
|
|
31934
31934
|
const fileFlag = args2.find((a) => a.startsWith("--token-file="));
|
|
31935
31935
|
if (fileFlag) {
|
|
31936
|
-
const
|
|
31936
|
+
const path120 = fileFlag.slice("--token-file=".length);
|
|
31937
31937
|
try {
|
|
31938
|
-
const content = fs72.readFileSync(
|
|
31939
|
-
if (content.length === 0) fail(`--token-file ${
|
|
31940
|
-
rmIfExistsQuiet(
|
|
31938
|
+
const content = fs72.readFileSync(path120, "utf8").trim();
|
|
31939
|
+
if (content.length === 0) fail(`--token-file ${path120} is empty`);
|
|
31940
|
+
rmIfExistsQuiet(path120);
|
|
31941
31941
|
return content;
|
|
31942
31942
|
} catch (err) {
|
|
31943
31943
|
fail(`Could not read --token-file: ${err.message}`);
|
|
@@ -41394,7 +41394,7 @@ function defaultRunGit(cwd, args2) {
|
|
|
41394
41394
|
});
|
|
41395
41395
|
}
|
|
41396
41396
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
41397
|
-
const
|
|
41397
|
+
const fs107 = await import("fs/promises");
|
|
41398
41398
|
const out2 = [];
|
|
41399
41399
|
await walk2(workingDir, 0);
|
|
41400
41400
|
return out2;
|
|
@@ -41402,7 +41402,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
41402
41402
|
if (depth2 > maxDepth) return;
|
|
41403
41403
|
let entries2 = [];
|
|
41404
41404
|
try {
|
|
41405
|
-
const dirents = await
|
|
41405
|
+
const dirents = await fs107.readdir(dir, { withFileTypes: true });
|
|
41406
41406
|
entries2 = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
41407
41407
|
} catch {
|
|
41408
41408
|
return;
|
|
@@ -43255,11 +43255,11 @@ function previewMcpServer(bridge) {
|
|
|
43255
43255
|
};
|
|
43256
43256
|
}
|
|
43257
43257
|
function httpCall(baseUrl, token) {
|
|
43258
|
-
return async (
|
|
43258
|
+
return async (path120, method, body, timeoutMs) => {
|
|
43259
43259
|
const ac = new AbortController();
|
|
43260
43260
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
43261
43261
|
try {
|
|
43262
|
-
const res = await fetch(`${baseUrl}${
|
|
43262
|
+
const res = await fetch(`${baseUrl}${path120}`, {
|
|
43263
43263
|
method,
|
|
43264
43264
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
43265
43265
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -43396,11 +43396,11 @@ function scratchMcpServer(bridge) {
|
|
|
43396
43396
|
};
|
|
43397
43397
|
}
|
|
43398
43398
|
function httpCall2(baseUrl, token) {
|
|
43399
|
-
return async (
|
|
43399
|
+
return async (path120, method, body, timeoutMs) => {
|
|
43400
43400
|
const ac = new AbortController();
|
|
43401
43401
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
43402
43402
|
try {
|
|
43403
|
-
const res = await fetch(`${baseUrl}${
|
|
43403
|
+
const res = await fetch(`${baseUrl}${path120}`, {
|
|
43404
43404
|
method,
|
|
43405
43405
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
43406
43406
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -52191,11 +52191,49 @@ async function host(args2) {
|
|
|
52191
52191
|
);
|
|
52192
52192
|
}
|
|
52193
52193
|
|
|
52194
|
+
// src/commands/host/credential-env-store.ts
|
|
52195
|
+
var fs97 = __toESM(require("fs"));
|
|
52196
|
+
var os69 = __toESM(require("os"));
|
|
52197
|
+
var path109 = __toESM(require("path"));
|
|
52198
|
+
function credentialEnvPath(deployId) {
|
|
52199
|
+
if (!DEPLOY_ID_RE.test(deployId) || deployId.includes("..")) return null;
|
|
52200
|
+
return path109.join(os69.homedir(), ".codeam", "credential-env", `${deployId}.json`);
|
|
52201
|
+
}
|
|
52202
|
+
function persistCredentialEnv(deployId, env) {
|
|
52203
|
+
const file = credentialEnvPath(deployId);
|
|
52204
|
+
if (!file) return;
|
|
52205
|
+
try {
|
|
52206
|
+
if (Object.keys(env).length === 0) fs97.rmSync(file, { force: true });
|
|
52207
|
+
else writeJson0600(file, env);
|
|
52208
|
+
} catch (err) {
|
|
52209
|
+
log.warn(
|
|
52210
|
+
"host-agent",
|
|
52211
|
+
`failed to persist the credential env of deploy=${deployId.slice(0, 8)} (best-effort): ${err instanceof Error ? err.message : String(err)}`
|
|
52212
|
+
);
|
|
52213
|
+
}
|
|
52214
|
+
}
|
|
52215
|
+
function readCredentialEnv(deployId) {
|
|
52216
|
+
const file = credentialEnvPath(deployId);
|
|
52217
|
+
if (!file) return {};
|
|
52218
|
+
try {
|
|
52219
|
+
const parsed = JSON.parse(fs97.readFileSync(file, "utf8"));
|
|
52220
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
|
|
52221
|
+
const out2 = {};
|
|
52222
|
+
for (const [k2, v] of Object.entries(parsed)) if (typeof v === "string") out2[k2] = v;
|
|
52223
|
+
return out2;
|
|
52224
|
+
} catch {
|
|
52225
|
+
return {};
|
|
52226
|
+
}
|
|
52227
|
+
}
|
|
52228
|
+
function clearCredentialEnv(deployId) {
|
|
52229
|
+
persistCredentialEnv(deployId, {});
|
|
52230
|
+
}
|
|
52231
|
+
|
|
52194
52232
|
// src/commands/host-agent.ts
|
|
52195
52233
|
var import_node_child_process40 = require("child_process");
|
|
52196
|
-
var
|
|
52197
|
-
var
|
|
52198
|
-
var
|
|
52234
|
+
var os75 = __toESM(require("os"));
|
|
52235
|
+
var fs104 = __toESM(require("fs"));
|
|
52236
|
+
var path116 = __toESM(require("path"));
|
|
52199
52237
|
|
|
52200
52238
|
// src/skills/persist-from-payload.ts
|
|
52201
52239
|
function persistOrClearSkillsFromPayload(skills) {
|
|
@@ -52204,13 +52242,13 @@ function persistOrClearSkillsFromPayload(skills) {
|
|
|
52204
52242
|
}
|
|
52205
52243
|
|
|
52206
52244
|
// src/commands/host/session-state.ts
|
|
52207
|
-
var
|
|
52208
|
-
var
|
|
52209
|
-
var
|
|
52245
|
+
var fs98 = __toESM(require("fs"));
|
|
52246
|
+
var os70 = __toESM(require("os"));
|
|
52247
|
+
var path110 = __toESM(require("path"));
|
|
52210
52248
|
function hostSessionStatePath(env = process.env) {
|
|
52211
52249
|
const override = env.CODEAM_HOST_SESSION_STATE_FILE;
|
|
52212
52250
|
if (override && override.trim()) return override.trim();
|
|
52213
|
-
return
|
|
52251
|
+
return path110.join(os70.homedir(), ".codeam", "host-agent-sessions.json");
|
|
52214
52252
|
}
|
|
52215
52253
|
function isRecord6(v) {
|
|
52216
52254
|
if (typeof v !== "object" || v === null) return false;
|
|
@@ -52221,7 +52259,7 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
52221
52259
|
return {
|
|
52222
52260
|
load() {
|
|
52223
52261
|
try {
|
|
52224
|
-
const raw = JSON.parse(
|
|
52262
|
+
const raw = JSON.parse(fs98.readFileSync(file, "utf8"));
|
|
52225
52263
|
return Array.isArray(raw?.sessions) ? raw.sessions.filter(isRecord6) : null;
|
|
52226
52264
|
} catch {
|
|
52227
52265
|
return null;
|
|
@@ -52229,18 +52267,18 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
52229
52267
|
},
|
|
52230
52268
|
save(list) {
|
|
52231
52269
|
try {
|
|
52232
|
-
|
|
52270
|
+
fs98.mkdirSync(path110.dirname(file), { recursive: true, mode: 448 });
|
|
52233
52271
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
52234
|
-
|
|
52272
|
+
fs98.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
|
|
52235
52273
|
mode: 384
|
|
52236
52274
|
});
|
|
52237
|
-
|
|
52275
|
+
fs98.renameSync(tmp, file);
|
|
52238
52276
|
} catch {
|
|
52239
52277
|
}
|
|
52240
52278
|
},
|
|
52241
52279
|
clear() {
|
|
52242
52280
|
try {
|
|
52243
|
-
|
|
52281
|
+
fs98.rmSync(file, { force: true });
|
|
52244
52282
|
} catch {
|
|
52245
52283
|
}
|
|
52246
52284
|
}
|
|
@@ -52263,10 +52301,10 @@ function planSessionResume(records, max) {
|
|
|
52263
52301
|
return { resume: ordered.slice(0, bound), dropped: ordered.slice(bound) };
|
|
52264
52302
|
}
|
|
52265
52303
|
function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
52266
|
-
const target =
|
|
52304
|
+
const target = path110.resolve(cwd);
|
|
52267
52305
|
const reconnectable = (s) => !!s.pluginId && !!s.pollSecret && !!s.agent;
|
|
52268
52306
|
const matches = sessions3.filter(
|
|
52269
|
-
(s) => !!s.cwd &&
|
|
52307
|
+
(s) => !!s.cwd && path110.resolve(s.cwd) === target && reconnectable(s)
|
|
52270
52308
|
);
|
|
52271
52309
|
if (matches.length > 0) {
|
|
52272
52310
|
matches.sort((a, b) => b.pairedAt - a.pairedAt);
|
|
@@ -52278,11 +52316,11 @@ function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
|
52278
52316
|
|
|
52279
52317
|
// src/commands/host/git-tooling.ts
|
|
52280
52318
|
var import_node_child_process34 = require("child_process");
|
|
52281
|
-
var
|
|
52282
|
-
var
|
|
52283
|
-
var
|
|
52319
|
+
var fs99 = __toESM(require("fs"));
|
|
52320
|
+
var os71 = __toESM(require("os"));
|
|
52321
|
+
var path111 = __toESM(require("path"));
|
|
52284
52322
|
function codeamBinDir() {
|
|
52285
|
-
return process.env.CODEAM_BIN_DIR ??
|
|
52323
|
+
return process.env.CODEAM_BIN_DIR ?? path111.join(os71.homedir(), ".codeam", "bin");
|
|
52286
52324
|
}
|
|
52287
52325
|
var FALLBACK_GH_VERSION = "2.62.0";
|
|
52288
52326
|
var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
|
|
@@ -52314,7 +52352,7 @@ async function download(url2, dest) {
|
|
|
52314
52352
|
const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
|
|
52315
52353
|
if (!res.ok || !res.body) return false;
|
|
52316
52354
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
52317
|
-
|
|
52355
|
+
fs99.writeFileSync(dest, buf);
|
|
52318
52356
|
return true;
|
|
52319
52357
|
} catch {
|
|
52320
52358
|
return false;
|
|
@@ -52337,8 +52375,8 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
52337
52375
|
const version3 = await resolveVersionFn(token);
|
|
52338
52376
|
const asset = `gh_${version3}_${osToken}_${arch2}`;
|
|
52339
52377
|
const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
|
|
52340
|
-
const tmpRoot =
|
|
52341
|
-
const archive =
|
|
52378
|
+
const tmpRoot = fs99.mkdtempSync(path111.join(os71.tmpdir(), "codeam-gh-"));
|
|
52379
|
+
const archive = path111.join(tmpRoot, `${asset}.${ext}`);
|
|
52342
52380
|
if (!await downloadFn(url2, archive)) {
|
|
52343
52381
|
log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
|
|
52344
52382
|
return null;
|
|
@@ -52348,16 +52386,16 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
52348
52386
|
log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
|
|
52349
52387
|
return null;
|
|
52350
52388
|
}
|
|
52351
|
-
const extractedBin =
|
|
52352
|
-
if (!
|
|
52389
|
+
const extractedBin = path111.join(tmpRoot, asset, "bin", binaryName);
|
|
52390
|
+
if (!fs99.existsSync(extractedBin)) {
|
|
52353
52391
|
log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
|
|
52354
52392
|
return null;
|
|
52355
52393
|
}
|
|
52356
52394
|
const binDir = codeamBinDir();
|
|
52357
|
-
|
|
52358
|
-
const target =
|
|
52359
|
-
|
|
52360
|
-
|
|
52395
|
+
fs99.mkdirSync(binDir, { recursive: true });
|
|
52396
|
+
const target = path111.join(binDir, binaryName);
|
|
52397
|
+
fs99.copyFileSync(extractedBin, target);
|
|
52398
|
+
fs99.chmodSync(target, 493);
|
|
52361
52399
|
log.info("host-agent", `gh installed to ${target} (v${version3})`);
|
|
52362
52400
|
return target;
|
|
52363
52401
|
} catch (e) {
|
|
@@ -52394,19 +52432,19 @@ async function ensureGhAuth(runner, ghCmd, token) {
|
|
|
52394
52432
|
}
|
|
52395
52433
|
function ghConfigDir() {
|
|
52396
52434
|
if (process.env.GH_CONFIG_DIR) return process.env.GH_CONFIG_DIR;
|
|
52397
|
-
if (process.env.XDG_CONFIG_HOME) return
|
|
52435
|
+
if (process.env.XDG_CONFIG_HOME) return path111.join(process.env.XDG_CONFIG_HOME, "gh");
|
|
52398
52436
|
if (process.platform === "win32" && process.env.APPDATA) {
|
|
52399
|
-
return
|
|
52437
|
+
return path111.join(process.env.APPDATA, "GitHub CLI");
|
|
52400
52438
|
}
|
|
52401
|
-
return
|
|
52439
|
+
return path111.join(os71.homedir(), ".config", "gh");
|
|
52402
52440
|
}
|
|
52403
52441
|
function writeGhHostsToken(token) {
|
|
52404
52442
|
try {
|
|
52405
52443
|
const dir = ghConfigDir();
|
|
52406
|
-
const file =
|
|
52407
|
-
if (
|
|
52408
|
-
|
|
52409
|
-
|
|
52444
|
+
const file = path111.join(dir, "hosts.yml");
|
|
52445
|
+
if (fs99.existsSync(file)) return false;
|
|
52446
|
+
fs99.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
52447
|
+
fs99.writeFileSync(
|
|
52410
52448
|
file,
|
|
52411
52449
|
`github.com:
|
|
52412
52450
|
oauth_token: ${token}
|
|
@@ -52449,8 +52487,8 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
52449
52487
|
const version3 = await resolveLatestGlabVersion();
|
|
52450
52488
|
const asset = `glab_${version3}_${osToken}_${arch2}`;
|
|
52451
52489
|
const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
|
|
52452
|
-
const tmpRoot =
|
|
52453
|
-
const archive =
|
|
52490
|
+
const tmpRoot = fs99.mkdtempSync(path111.join(os71.tmpdir(), "codeam-glab-"));
|
|
52491
|
+
const archive = path111.join(tmpRoot, `${asset}.${ext}`);
|
|
52454
52492
|
if (!await downloadFn(url2, archive)) {
|
|
52455
52493
|
log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
|
|
52456
52494
|
return null;
|
|
@@ -52461,20 +52499,20 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
52461
52499
|
return null;
|
|
52462
52500
|
}
|
|
52463
52501
|
const candidates = [
|
|
52464
|
-
|
|
52465
|
-
|
|
52466
|
-
|
|
52502
|
+
path111.join(tmpRoot, "bin", binaryName),
|
|
52503
|
+
path111.join(tmpRoot, asset, "bin", binaryName),
|
|
52504
|
+
path111.join(tmpRoot, binaryName)
|
|
52467
52505
|
];
|
|
52468
|
-
const extractedBin = candidates.find((c2) =>
|
|
52506
|
+
const extractedBin = candidates.find((c2) => fs99.existsSync(c2));
|
|
52469
52507
|
if (!extractedBin) {
|
|
52470
52508
|
log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
|
|
52471
52509
|
return null;
|
|
52472
52510
|
}
|
|
52473
52511
|
const binDir = codeamBinDir();
|
|
52474
|
-
|
|
52475
|
-
const target =
|
|
52476
|
-
|
|
52477
|
-
|
|
52512
|
+
fs99.mkdirSync(binDir, { recursive: true });
|
|
52513
|
+
const target = path111.join(binDir, binaryName);
|
|
52514
|
+
fs99.copyFileSync(extractedBin, target);
|
|
52515
|
+
fs99.chmodSync(target, 493);
|
|
52478
52516
|
log.info("host-agent", `glab installed to ${target} (v${version3})`);
|
|
52479
52517
|
return target;
|
|
52480
52518
|
} catch (e) {
|
|
@@ -52553,14 +52591,14 @@ var defaultGitToolingRunner = {
|
|
|
52553
52591
|
};
|
|
52554
52592
|
|
|
52555
52593
|
// src/lib/cli-versions.ts
|
|
52594
|
+
var fs101 = __toESM(require("fs"));
|
|
52595
|
+
var os73 = __toESM(require("os"));
|
|
52596
|
+
var path113 = __toESM(require("path"));
|
|
52597
|
+
|
|
52598
|
+
// src/lib/updateNotifier.ts
|
|
52556
52599
|
var fs100 = __toESM(require("fs"));
|
|
52557
52600
|
var os72 = __toESM(require("os"));
|
|
52558
52601
|
var path112 = __toESM(require("path"));
|
|
52559
|
-
|
|
52560
|
-
// src/lib/updateNotifier.ts
|
|
52561
|
-
var fs99 = __toESM(require("fs"));
|
|
52562
|
-
var os71 = __toESM(require("os"));
|
|
52563
|
-
var path111 = __toESM(require("path"));
|
|
52564
52602
|
var https8 = __toESM(require("https"));
|
|
52565
52603
|
var import_node_child_process35 = require("child_process");
|
|
52566
52604
|
var import_picocolors12 = __toESM(require("picocolors"));
|
|
@@ -52569,12 +52607,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
|
|
|
52569
52607
|
var TTL_MS = 24 * 60 * 60 * 1e3;
|
|
52570
52608
|
var REQUEST_TIMEOUT_MS = 1500;
|
|
52571
52609
|
function cachePath() {
|
|
52572
|
-
const dir =
|
|
52573
|
-
return
|
|
52610
|
+
const dir = path112.join(os72.homedir(), ".codeam");
|
|
52611
|
+
return path112.join(dir, "update-check.json");
|
|
52574
52612
|
}
|
|
52575
52613
|
function readCache() {
|
|
52576
52614
|
try {
|
|
52577
|
-
const raw =
|
|
52615
|
+
const raw = fs100.readFileSync(cachePath(), "utf8");
|
|
52578
52616
|
const parsed = JSON.parse(raw);
|
|
52579
52617
|
if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
|
|
52580
52618
|
return parsed;
|
|
@@ -52585,10 +52623,10 @@ function readCache() {
|
|
|
52585
52623
|
function writeCache(cache) {
|
|
52586
52624
|
try {
|
|
52587
52625
|
const file = cachePath();
|
|
52588
|
-
|
|
52626
|
+
fs100.mkdirSync(path112.dirname(file), { recursive: true });
|
|
52589
52627
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
52590
|
-
|
|
52591
|
-
|
|
52628
|
+
fs100.writeFileSync(tmp, JSON.stringify(cache));
|
|
52629
|
+
fs100.renameSync(tmp, file);
|
|
52592
52630
|
} catch {
|
|
52593
52631
|
}
|
|
52594
52632
|
}
|
|
@@ -52662,8 +52700,8 @@ function isLinkedInstall() {
|
|
|
52662
52700
|
timeout: 2e3
|
|
52663
52701
|
}).trim();
|
|
52664
52702
|
if (!root) return false;
|
|
52665
|
-
const pkgPath =
|
|
52666
|
-
return
|
|
52703
|
+
const pkgPath = path112.join(root, PKG_NAME);
|
|
52704
|
+
return fs100.lstatSync(pkgPath).isSymbolicLink();
|
|
52667
52705
|
} catch {
|
|
52668
52706
|
return false;
|
|
52669
52707
|
}
|
|
@@ -52699,7 +52737,7 @@ function maybeAutoUpdate(currentVersion, latest) {
|
|
|
52699
52737
|
return;
|
|
52700
52738
|
}
|
|
52701
52739
|
try {
|
|
52702
|
-
|
|
52740
|
+
fs100.unlinkSync(cachePath());
|
|
52703
52741
|
} catch {
|
|
52704
52742
|
}
|
|
52705
52743
|
process.stderr.write(` ${import_picocolors12.default.green("\u2713")} Updated. Resuming session...
|
|
@@ -52715,7 +52753,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
52715
52753
|
if (process.env.NODE_ENV === "test") return;
|
|
52716
52754
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
52717
52755
|
if (process.env.CI) return;
|
|
52718
|
-
const current2 = true ? "2.76.
|
|
52756
|
+
const current2 = true ? "2.76.47" : null;
|
|
52719
52757
|
if (!current2) return;
|
|
52720
52758
|
const cache = readCache();
|
|
52721
52759
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -52732,7 +52770,7 @@ function checkForUpdates() {
|
|
|
52732
52770
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
52733
52771
|
if (process.env.CI) return;
|
|
52734
52772
|
if (!process.stdout.isTTY) return;
|
|
52735
|
-
const current2 = true ? "2.76.
|
|
52773
|
+
const current2 = true ? "2.76.47" : null;
|
|
52736
52774
|
if (!current2) return;
|
|
52737
52775
|
const cache = readCache();
|
|
52738
52776
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -52755,10 +52793,10 @@ function versionedModeSupported(platform3 = process.platform) {
|
|
|
52755
52793
|
return platform3 !== "win32";
|
|
52756
52794
|
}
|
|
52757
52795
|
function cliVersionsRoot(env = process.env) {
|
|
52758
|
-
return env.CODEAM_CLI_VERSIONS_DIR ||
|
|
52796
|
+
return env.CODEAM_CLI_VERSIONS_DIR || path113.join(os73.homedir(), ".codeam", "cli");
|
|
52759
52797
|
}
|
|
52760
52798
|
function packageDirOf(versionDir) {
|
|
52761
|
-
return
|
|
52799
|
+
return path113.join(versionDir, "node_modules", CLI_PKG);
|
|
52762
52800
|
}
|
|
52763
52801
|
function isRecord7(v) {
|
|
52764
52802
|
return typeof v === "object" && v !== null;
|
|
@@ -52766,7 +52804,7 @@ function isRecord7(v) {
|
|
|
52766
52804
|
function readPkg2(versionDir) {
|
|
52767
52805
|
try {
|
|
52768
52806
|
const raw = JSON.parse(
|
|
52769
|
-
|
|
52807
|
+
fs101.readFileSync(path113.join(packageDirOf(versionDir), "package.json"), "utf8")
|
|
52770
52808
|
);
|
|
52771
52809
|
return isRecord7(raw) ? raw : null;
|
|
52772
52810
|
} catch {
|
|
@@ -52779,15 +52817,15 @@ function entryOf(versionDir) {
|
|
|
52779
52817
|
const bin = pkg.bin;
|
|
52780
52818
|
const named = isRecord7(bin) ? bin.codeam : void 0;
|
|
52781
52819
|
const rel = typeof bin === "string" ? bin : typeof named === "string" ? named : "dist/index.js";
|
|
52782
|
-
const entry =
|
|
52783
|
-
return
|
|
52820
|
+
const entry = path113.join(packageDirOf(versionDir), rel);
|
|
52821
|
+
return fs101.existsSync(entry) ? entry : null;
|
|
52784
52822
|
}
|
|
52785
52823
|
function launcherOf(versionDir) {
|
|
52786
52824
|
const entry = entryOf(versionDir);
|
|
52787
52825
|
if (!entry) return null;
|
|
52788
|
-
const bin =
|
|
52826
|
+
const bin = path113.join(versionDir, "node_modules", ".bin", "codeam");
|
|
52789
52827
|
try {
|
|
52790
|
-
return
|
|
52828
|
+
return fs101.realpathSync(bin) === fs101.realpathSync(entry) ? bin : entry;
|
|
52791
52829
|
} catch {
|
|
52792
52830
|
return entry;
|
|
52793
52831
|
}
|
|
@@ -52800,16 +52838,16 @@ var BAD_MARKER_TTL_MS = 24 * 60 * 6e4;
|
|
|
52800
52838
|
var PRE_READY_WINDOW_MS = 60 * 6e4;
|
|
52801
52839
|
function isBad(versionDir, now = Date.now()) {
|
|
52802
52840
|
try {
|
|
52803
|
-
return now -
|
|
52841
|
+
return now - fs101.statSync(path113.join(versionDir, ".bad")).mtimeMs < BAD_MARKER_TTL_MS;
|
|
52804
52842
|
} catch {
|
|
52805
52843
|
return false;
|
|
52806
52844
|
}
|
|
52807
52845
|
}
|
|
52808
52846
|
function recordPreReadyFailure(versionDir, now = Date.now()) {
|
|
52809
|
-
const file =
|
|
52847
|
+
const file = path113.join(versionDir, ".prefail");
|
|
52810
52848
|
let count = 0;
|
|
52811
52849
|
try {
|
|
52812
|
-
const [n, at3] =
|
|
52850
|
+
const [n, at3] = fs101.readFileSync(file, "utf8").trim().split(" ").map(Number);
|
|
52813
52851
|
if (Number.isFinite(n) && Number.isFinite(at3) && now - at3 < PRE_READY_WINDOW_MS) {
|
|
52814
52852
|
count = n;
|
|
52815
52853
|
}
|
|
@@ -52817,45 +52855,45 @@ function recordPreReadyFailure(versionDir, now = Date.now()) {
|
|
|
52817
52855
|
}
|
|
52818
52856
|
count += 1;
|
|
52819
52857
|
try {
|
|
52820
|
-
|
|
52858
|
+
fs101.writeFileSync(file, `${count} ${now}`);
|
|
52821
52859
|
} catch {
|
|
52822
52860
|
}
|
|
52823
52861
|
return count;
|
|
52824
52862
|
}
|
|
52825
52863
|
function clearPreReadyFailures(versionDir) {
|
|
52826
|
-
|
|
52864
|
+
fs101.rmSync(path113.join(versionDir, ".prefail"), { force: true });
|
|
52827
52865
|
}
|
|
52828
52866
|
function markBad(versionDir, reason) {
|
|
52829
52867
|
try {
|
|
52830
|
-
|
|
52868
|
+
fs101.writeFileSync(path113.join(versionDir, ".bad"), `${(/* @__PURE__ */ new Date()).toISOString()} ${reason}
|
|
52831
52869
|
`);
|
|
52832
52870
|
} catch {
|
|
52833
52871
|
}
|
|
52834
52872
|
}
|
|
52835
52873
|
function pointerTarget(root, name) {
|
|
52836
52874
|
try {
|
|
52837
|
-
return
|
|
52875
|
+
return fs101.realpathSync(path113.join(root, name));
|
|
52838
52876
|
} catch {
|
|
52839
52877
|
return null;
|
|
52840
52878
|
}
|
|
52841
52879
|
}
|
|
52842
52880
|
function atomicPoint(root, name, targetDir) {
|
|
52843
|
-
const realRoot =
|
|
52844
|
-
const tmp =
|
|
52845
|
-
|
|
52881
|
+
const realRoot = fs101.realpathSync(root);
|
|
52882
|
+
const tmp = path113.join(realRoot, `.${name}.tmp-${process.pid}-${Date.now()}`);
|
|
52883
|
+
fs101.symlinkSync(path113.relative(realRoot, fs101.realpathSync(targetDir)), tmp, "dir");
|
|
52846
52884
|
try {
|
|
52847
|
-
|
|
52885
|
+
fs101.renameSync(tmp, path113.join(realRoot, name));
|
|
52848
52886
|
} catch (err) {
|
|
52849
|
-
|
|
52887
|
+
fs101.rmSync(tmp, { force: true });
|
|
52850
52888
|
throw err;
|
|
52851
52889
|
}
|
|
52852
52890
|
}
|
|
52853
52891
|
function samePath(a, b) {
|
|
52854
52892
|
const canon = (p2) => {
|
|
52855
52893
|
try {
|
|
52856
|
-
return
|
|
52894
|
+
return fs101.realpathSync(p2);
|
|
52857
52895
|
} catch {
|
|
52858
|
-
return
|
|
52896
|
+
return path113.resolve(p2);
|
|
52859
52897
|
}
|
|
52860
52898
|
};
|
|
52861
52899
|
return canon(a) === canon(b);
|
|
@@ -52890,15 +52928,15 @@ function versionDirContaining(root, file) {
|
|
|
52890
52928
|
let real;
|
|
52891
52929
|
let realRoot;
|
|
52892
52930
|
try {
|
|
52893
|
-
real =
|
|
52894
|
-
realRoot =
|
|
52931
|
+
real = fs101.realpathSync(file);
|
|
52932
|
+
realRoot = fs101.realpathSync(root);
|
|
52895
52933
|
} catch {
|
|
52896
52934
|
return null;
|
|
52897
52935
|
}
|
|
52898
|
-
const rel =
|
|
52899
|
-
if (rel.startsWith("..") ||
|
|
52900
|
-
const first = rel.split(
|
|
52901
|
-
return first && SEMVER_DIR.test(first) ?
|
|
52936
|
+
const rel = path113.relative(realRoot, real);
|
|
52937
|
+
if (rel.startsWith("..") || path113.isAbsolute(rel)) return null;
|
|
52938
|
+
const first = rel.split(path113.sep)[0];
|
|
52939
|
+
return first && SEMVER_DIR.test(first) ? path113.join(realRoot, first) : null;
|
|
52902
52940
|
}
|
|
52903
52941
|
function pidAlive3(pid) {
|
|
52904
52942
|
try {
|
|
@@ -52911,9 +52949,9 @@ function pidAlive3(pid) {
|
|
|
52911
52949
|
var CLK_TCK = 100;
|
|
52912
52950
|
function processStartMs(pid) {
|
|
52913
52951
|
try {
|
|
52914
|
-
const stat3 =
|
|
52952
|
+
const stat3 = fs101.readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
52915
52953
|
const ticks = Number(stat3.slice(stat3.lastIndexOf(")") + 2).split(" ")[19]);
|
|
52916
|
-
const btime = /^btime (\d+)$/m.exec(
|
|
52954
|
+
const btime = /^btime (\d+)$/m.exec(fs101.readFileSync("/proc/stat", "utf8"))?.[1];
|
|
52917
52955
|
if (!Number.isFinite(ticks) || !btime) return null;
|
|
52918
52956
|
return Number(btime) * 1e3 + ticks * 1e3 / CLK_TCK;
|
|
52919
52957
|
} catch {
|
|
@@ -52922,10 +52960,10 @@ function processStartMs(pid) {
|
|
|
52922
52960
|
}
|
|
52923
52961
|
var PID_REUSE_SLACK_MS = 2e3;
|
|
52924
52962
|
function livePids(versionDir) {
|
|
52925
|
-
const dir =
|
|
52963
|
+
const dir = path113.join(versionDir, ".pids");
|
|
52926
52964
|
let names;
|
|
52927
52965
|
try {
|
|
52928
|
-
names =
|
|
52966
|
+
names = fs101.readdirSync(dir);
|
|
52929
52967
|
} catch {
|
|
52930
52968
|
return [];
|
|
52931
52969
|
}
|
|
@@ -52934,7 +52972,7 @@ function livePids(versionDir) {
|
|
|
52934
52972
|
const started = processStartMs(pid);
|
|
52935
52973
|
if (started === null) return true;
|
|
52936
52974
|
try {
|
|
52937
|
-
return started <=
|
|
52975
|
+
return started <= fs101.statSync(path113.join(dir, String(pid))).mtimeMs + PID_REUSE_SLACK_MS;
|
|
52938
52976
|
} catch {
|
|
52939
52977
|
return true;
|
|
52940
52978
|
}
|
|
@@ -52943,11 +52981,11 @@ function livePids(versionDir) {
|
|
|
52943
52981
|
function registerRunningVersion(root = cliVersionsRoot(), entry = process.argv[1]) {
|
|
52944
52982
|
const dir = versionDirContaining(root, entry);
|
|
52945
52983
|
if (!dir) return;
|
|
52946
|
-
const file =
|
|
52984
|
+
const file = path113.join(dir, ".pids", String(process.pid));
|
|
52947
52985
|
try {
|
|
52948
|
-
|
|
52949
|
-
|
|
52950
|
-
process.once("exit", () =>
|
|
52986
|
+
fs101.mkdirSync(path113.dirname(file), { recursive: true });
|
|
52987
|
+
fs101.writeFileSync(file, "");
|
|
52988
|
+
process.once("exit", () => fs101.rmSync(file, { force: true }));
|
|
52951
52989
|
} catch {
|
|
52952
52990
|
}
|
|
52953
52991
|
}
|
|
@@ -52955,7 +52993,7 @@ function gcVersions(root) {
|
|
|
52955
52993
|
const removed = [];
|
|
52956
52994
|
let names;
|
|
52957
52995
|
try {
|
|
52958
|
-
names =
|
|
52996
|
+
names = fs101.readdirSync(root).filter((n) => SEMVER_DIR.test(n));
|
|
52959
52997
|
} catch {
|
|
52960
52998
|
return removed;
|
|
52961
52999
|
}
|
|
@@ -52963,13 +53001,13 @@ function gcVersions(root) {
|
|
|
52963
53001
|
[...names].sort((a, b) => compareSemver(b, a)).slice(0, GC_KEEP_NEWEST)
|
|
52964
53002
|
);
|
|
52965
53003
|
for (const p2 of [pointerTarget(root, "current"), pointerTarget(root, "previous")]) {
|
|
52966
|
-
if (p2) keep.add(
|
|
53004
|
+
if (p2) keep.add(path113.basename(p2));
|
|
52967
53005
|
}
|
|
52968
53006
|
for (const name of names) {
|
|
52969
|
-
const dir =
|
|
53007
|
+
const dir = path113.join(root, name);
|
|
52970
53008
|
if (keep.has(name) || livePids(dir).length > 0) continue;
|
|
52971
53009
|
try {
|
|
52972
|
-
|
|
53010
|
+
fs101.rmSync(dir, { recursive: true, force: true });
|
|
52973
53011
|
removed.push(name);
|
|
52974
53012
|
} catch {
|
|
52975
53013
|
}
|
|
@@ -52977,25 +53015,25 @@ function gcVersions(root) {
|
|
|
52977
53015
|
return removed;
|
|
52978
53016
|
}
|
|
52979
53017
|
function acquireInstallLock(root) {
|
|
52980
|
-
const lock =
|
|
53018
|
+
const lock = path113.join(root, ".install.lock");
|
|
52981
53019
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
52982
53020
|
try {
|
|
52983
|
-
const fd =
|
|
52984
|
-
|
|
52985
|
-
|
|
52986
|
-
return () =>
|
|
53021
|
+
const fd = fs101.openSync(lock, "wx");
|
|
53022
|
+
fs101.writeSync(fd, String(process.pid));
|
|
53023
|
+
fs101.closeSync(fd);
|
|
53024
|
+
return () => fs101.rmSync(lock, { force: true });
|
|
52987
53025
|
} catch (err) {
|
|
52988
53026
|
if (err.code !== "EEXIST") return null;
|
|
52989
53027
|
let stale = false;
|
|
52990
53028
|
try {
|
|
52991
|
-
const owner = Number(
|
|
52992
|
-
const age = Date.now() -
|
|
53029
|
+
const owner = Number(fs101.readFileSync(lock, "utf8"));
|
|
53030
|
+
const age = Date.now() - fs101.statSync(lock).mtimeMs;
|
|
52993
53031
|
stale = !Number.isInteger(owner) || !pidAlive3(owner) || age > LOCK_STALE_MS;
|
|
52994
53032
|
} catch {
|
|
52995
53033
|
stale = true;
|
|
52996
53034
|
}
|
|
52997
53035
|
if (!stale) return null;
|
|
52998
|
-
|
|
53036
|
+
fs101.rmSync(lock, { force: true });
|
|
52999
53037
|
}
|
|
53000
53038
|
}
|
|
53001
53039
|
return null;
|
|
@@ -53003,9 +53041,9 @@ function acquireInstallLock(root) {
|
|
|
53003
53041
|
|
|
53004
53042
|
// src/commands/host/host-launch.ts
|
|
53005
53043
|
var import_node_child_process37 = require("child_process");
|
|
53006
|
-
var
|
|
53007
|
-
var
|
|
53008
|
-
var
|
|
53044
|
+
var fs103 = __toESM(require("fs"));
|
|
53045
|
+
var os74 = __toESM(require("os"));
|
|
53046
|
+
var path115 = __toESM(require("path"));
|
|
53009
53047
|
|
|
53010
53048
|
// src/exit-codes.ts
|
|
53011
53049
|
var EXIT_OK = 0;
|
|
@@ -53027,8 +53065,8 @@ var EXIT_CODE_NAMES = {
|
|
|
53027
53065
|
|
|
53028
53066
|
// src/commands/host/self-update.ts
|
|
53029
53067
|
var import_node_child_process36 = require("child_process");
|
|
53030
|
-
var
|
|
53031
|
-
var
|
|
53068
|
+
var fs102 = __toESM(require("fs"));
|
|
53069
|
+
var path114 = __toESM(require("path"));
|
|
53032
53070
|
var SELF_UPDATE_PKG = "codeam-cli";
|
|
53033
53071
|
var SELF_UPDATE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
53034
53072
|
var SELF_UPDATE_STARTUP_DELAY_MS = 5e3;
|
|
@@ -53038,7 +53076,7 @@ var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
|
|
|
53038
53076
|
var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
53039
53077
|
var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
|
|
53040
53078
|
function currentCliVersion() {
|
|
53041
|
-
return true ? "2.76.
|
|
53079
|
+
return true ? "2.76.47" : null;
|
|
53042
53080
|
}
|
|
53043
53081
|
async function installedVersion(deps) {
|
|
53044
53082
|
const ls = await deps.run(
|
|
@@ -53154,9 +53192,9 @@ function collectOldVersions(root) {
|
|
|
53154
53192
|
var VERIFY_TIMEOUT_MS = 3e4;
|
|
53155
53193
|
async function installVersioned(deps, root, latest, running2) {
|
|
53156
53194
|
const node = deps.nodePath ?? process.execPath;
|
|
53157
|
-
const target =
|
|
53195
|
+
const target = path114.join(root, latest);
|
|
53158
53196
|
try {
|
|
53159
|
-
|
|
53197
|
+
fs102.mkdirSync(root, { recursive: true });
|
|
53160
53198
|
} catch {
|
|
53161
53199
|
return { status: "skipped" };
|
|
53162
53200
|
}
|
|
@@ -53180,7 +53218,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
53180
53218
|
}
|
|
53181
53219
|
const reusable = entryOf(target) && versionOf(target) === latest;
|
|
53182
53220
|
if (!reusable) {
|
|
53183
|
-
|
|
53221
|
+
fs102.rmSync(target, { recursive: true, force: true });
|
|
53184
53222
|
const install = await deps.run(
|
|
53185
53223
|
"npm",
|
|
53186
53224
|
[
|
|
@@ -53195,7 +53233,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
53195
53233
|
SELF_UPDATE_INSTALL_TIMEOUT_MS
|
|
53196
53234
|
);
|
|
53197
53235
|
if (install.code !== 0) {
|
|
53198
|
-
|
|
53236
|
+
fs102.rmSync(target, { recursive: true, force: true });
|
|
53199
53237
|
log.warn(
|
|
53200
53238
|
"host-agent",
|
|
53201
53239
|
`self-update: versioned install exited ${String(install.code)} \u2014 staying on ${running2}: ` + install.stderr.slice(-300)
|
|
@@ -53206,7 +53244,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
53206
53244
|
const entry = entryOf(target);
|
|
53207
53245
|
const check = entry ? await deps.run(node, [entry, "--version"], VERIFY_TIMEOUT_MS) : { code: null, stdout: "", stderr: "no entry point" };
|
|
53208
53246
|
if (check.code !== 0 || !check.stdout.includes(latest)) {
|
|
53209
|
-
|
|
53247
|
+
fs102.rmSync(target, { recursive: true, force: true });
|
|
53210
53248
|
log.warn(
|
|
53211
53249
|
"host-agent",
|
|
53212
53250
|
`self-update: ${latest} failed verification (exit ${String(check.code)}: ${(check.stdout + check.stderr).trim().slice(-200)}) \u2014 staying on ${running2}`
|
|
@@ -53222,7 +53260,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
53222
53260
|
return { status: "updated", version: latest };
|
|
53223
53261
|
} catch (err) {
|
|
53224
53262
|
const cur = pointerTarget(root, "current");
|
|
53225
|
-
if (!cur ||
|
|
53263
|
+
if (!cur || path114.basename(cur) !== latest) fs102.rmSync(target, { recursive: true, force: true });
|
|
53226
53264
|
log.warn(
|
|
53227
53265
|
"host-agent",
|
|
53228
53266
|
`self-update: versioned install failed: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -53261,7 +53299,7 @@ function signalHostReady(send = process.send?.bind(process)) {
|
|
|
53261
53299
|
}
|
|
53262
53300
|
function defaultDeps() {
|
|
53263
53301
|
return {
|
|
53264
|
-
ownVersion: true ? "2.76.
|
|
53302
|
+
ownVersion: true ? "2.76.47" : null,
|
|
53265
53303
|
root: cliVersionsRoot(),
|
|
53266
53304
|
args: process.argv.slice(3),
|
|
53267
53305
|
execPath: process.execPath,
|
|
@@ -53358,13 +53396,13 @@ function needsSelfRelaunch(env = process.env, pid = process.pid, ctx = {}) {
|
|
|
53358
53396
|
}
|
|
53359
53397
|
function readPid1Cmdline() {
|
|
53360
53398
|
try {
|
|
53361
|
-
return
|
|
53399
|
+
return fs103.readFileSync("/proc/1/cmdline", "utf8").split("\0").filter(Boolean);
|
|
53362
53400
|
} catch {
|
|
53363
53401
|
return [];
|
|
53364
53402
|
}
|
|
53365
53403
|
}
|
|
53366
53404
|
function isOurTiniEntrypoint(argv) {
|
|
53367
|
-
return argv.some((a) =>
|
|
53405
|
+
return argv.some((a) => path115.basename(a) === "tini") && argv.includes("host-agent");
|
|
53368
53406
|
}
|
|
53369
53407
|
function relaunchArgv(execPath, argv) {
|
|
53370
53408
|
return ["-c", 'sleep 2; exec "$0" "$@"', execPath, ...argv.slice(1)];
|
|
@@ -53406,7 +53444,7 @@ function defaultRestartForUpdate(version3, supervised, io = {}) {
|
|
|
53406
53444
|
}
|
|
53407
53445
|
exit(0);
|
|
53408
53446
|
}
|
|
53409
|
-
function isContainerEnvironment(existsSyncFn =
|
|
53447
|
+
function isContainerEnvironment(existsSyncFn = fs103.existsSync, readFileSyncFn = (p2) => fs103.readFileSync(p2, "utf8")) {
|
|
53410
53448
|
try {
|
|
53411
53449
|
if (existsSyncFn("/.dockerenv")) return true;
|
|
53412
53450
|
} catch {
|
|
@@ -53418,16 +53456,16 @@ function isContainerEnvironment(existsSyncFn = fs102.existsSync, readFileSyncFn
|
|
|
53418
53456
|
}
|
|
53419
53457
|
return false;
|
|
53420
53458
|
}
|
|
53421
|
-
function hostAgentPidFile(home =
|
|
53422
|
-
return
|
|
53459
|
+
function hostAgentPidFile(home = os74.homedir()) {
|
|
53460
|
+
return path115.join(home, ".codeam", "host-agent.pid");
|
|
53423
53461
|
}
|
|
53424
53462
|
function writeHostAgentPidFile(file = hostAgentPidFile(), pid = process.pid) {
|
|
53425
53463
|
try {
|
|
53426
|
-
|
|
53427
|
-
|
|
53464
|
+
fs103.mkdirSync(path115.dirname(file), { recursive: true });
|
|
53465
|
+
fs103.writeFileSync(file, String(pid));
|
|
53428
53466
|
process.once("exit", () => {
|
|
53429
53467
|
try {
|
|
53430
|
-
if (
|
|
53468
|
+
if (fs103.readFileSync(file, "utf8").trim() === String(pid)) fs103.rmSync(file, { force: true });
|
|
53431
53469
|
} catch {
|
|
53432
53470
|
}
|
|
53433
53471
|
});
|
|
@@ -54280,13 +54318,13 @@ var HostAgentSupervisor = class {
|
|
|
54280
54318
|
const relay = this.relay;
|
|
54281
54319
|
if (!relay) return;
|
|
54282
54320
|
const raw = cmd.payload?.path;
|
|
54283
|
-
const target = typeof raw === "string" && raw.trim() ?
|
|
54321
|
+
const target = typeof raw === "string" && raw.trim() ? path116.resolve(raw.trim()) : os75.homedir();
|
|
54284
54322
|
try {
|
|
54285
|
-
const dirents = await
|
|
54323
|
+
const dirents = await fs104.promises.readdir(target, { withFileTypes: true });
|
|
54286
54324
|
const entries2 = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
|
|
54287
54325
|
(a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
|
|
54288
54326
|
);
|
|
54289
|
-
const parent =
|
|
54327
|
+
const parent = path116.dirname(target);
|
|
54290
54328
|
await relay.sendResult(cmd.id, "completed", {
|
|
54291
54329
|
path: target,
|
|
54292
54330
|
// null at the filesystem root so the UI can hide the ".." affordance.
|
|
@@ -54764,14 +54802,14 @@ var HostAgentSupervisor = class {
|
|
|
54764
54802
|
}),
|
|
54765
54803
|
CODEAM_AUTO_TOKEN: payload.autoPairToken
|
|
54766
54804
|
};
|
|
54767
|
-
const houseConfigDir =
|
|
54768
|
-
|
|
54805
|
+
const houseConfigDir = path116.join(
|
|
54806
|
+
os75.homedir(),
|
|
54769
54807
|
".codeam",
|
|
54770
54808
|
"house-claude",
|
|
54771
54809
|
payload.deployId
|
|
54772
54810
|
);
|
|
54773
54811
|
try {
|
|
54774
|
-
|
|
54812
|
+
fs104.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
|
|
54775
54813
|
} catch {
|
|
54776
54814
|
}
|
|
54777
54815
|
childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
|
|
@@ -54788,6 +54826,7 @@ var HostAgentSupervisor = class {
|
|
|
54788
54826
|
const credEnv = provisionAgentCredentials(payload.agentId, auth, void 0);
|
|
54789
54827
|
if (Object.keys(credEnv).length > 0) this.credentialEnvByDeploy.set(payload.deployId, credEnv);
|
|
54790
54828
|
else this.credentialEnvByDeploy.delete(payload.deployId);
|
|
54829
|
+
persistCredentialEnv(payload.deployId, credEnv);
|
|
54791
54830
|
childEnv = {
|
|
54792
54831
|
...credEnv,
|
|
54793
54832
|
CODEAM_AUTO_TOKEN: payload.autoPairToken
|
|
@@ -54800,7 +54839,7 @@ var HostAgentSupervisor = class {
|
|
|
54800
54839
|
report("installing", "installing agent CLI");
|
|
54801
54840
|
await this.runAgentInstall(payload.agentInstallScript);
|
|
54802
54841
|
}
|
|
54803
|
-
const home = process.env.HOME ||
|
|
54842
|
+
const home = process.env.HOME || os75.homedir();
|
|
54804
54843
|
childEnv.PATH = `${home}/.local/bin:${process.env.PATH ?? ""}`;
|
|
54805
54844
|
if (payload.cloneToken) {
|
|
54806
54845
|
try {
|
|
@@ -54808,13 +54847,13 @@ var HostAgentSupervisor = class {
|
|
|
54808
54847
|
if ((payload.repoProvider ?? "github") === "gitlab") {
|
|
54809
54848
|
const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
|
|
54810
54849
|
if (glabCmd) {
|
|
54811
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
54850
|
+
childEnv.PATH = `${codeamBinDir()}${path116.delimiter}${childEnv.PATH}`;
|
|
54812
54851
|
await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
|
|
54813
54852
|
}
|
|
54814
54853
|
} else {
|
|
54815
54854
|
const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
|
|
54816
54855
|
if (ghCmd) {
|
|
54817
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
54856
|
+
childEnv.PATH = `${codeamBinDir()}${path116.delimiter}${childEnv.PATH}`;
|
|
54818
54857
|
await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
|
|
54819
54858
|
}
|
|
54820
54859
|
}
|
|
@@ -54842,9 +54881,9 @@ var HostAgentSupervisor = class {
|
|
|
54842
54881
|
);
|
|
54843
54882
|
if (!payload.suppressOnboardingWelcome) {
|
|
54844
54883
|
try {
|
|
54845
|
-
const cfgDir = childEnv.CLAUDE_CONFIG_DIR ||
|
|
54846
|
-
const projectDir =
|
|
54847
|
-
const hasPriorConversation =
|
|
54884
|
+
const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path116.join(os75.homedir(), ".claude");
|
|
54885
|
+
const projectDir = path116.join(cfgDir, "projects", encodeCwd(cwd));
|
|
54886
|
+
const hasPriorConversation = fs104.existsSync(projectDir) && fs104.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
|
|
54848
54887
|
if (hasPriorConversation) {
|
|
54849
54888
|
childEnv.CODEAM_RESUME_LATEST = "1";
|
|
54850
54889
|
log.info(
|
|
@@ -54998,7 +55037,7 @@ var HostAgentSupervisor = class {
|
|
|
54998
55037
|
fallbackResumeTarget() {
|
|
54999
55038
|
const session = getActiveSession();
|
|
55000
55039
|
if (!session || !session.pluginId || !session.pollSecret || !session.agent) return null;
|
|
55001
|
-
const cwd = session.cwd &&
|
|
55040
|
+
const cwd = session.cwd && fs104.existsSync(session.cwd) ? session.cwd : process.cwd();
|
|
55002
55041
|
if (isFilesystemRoot(cwd)) {
|
|
55003
55042
|
log.warn(
|
|
55004
55043
|
"host-agent",
|
|
@@ -55045,7 +55084,7 @@ var HostAgentSupervisor = class {
|
|
|
55045
55084
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: no saved pairing on this box`);
|
|
55046
55085
|
return;
|
|
55047
55086
|
}
|
|
55048
|
-
if (!session.cwd || !
|
|
55087
|
+
if (!session.cwd || !fs104.existsSync(session.cwd)) {
|
|
55049
55088
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: workspace is gone`);
|
|
55050
55089
|
return;
|
|
55051
55090
|
}
|
|
@@ -55087,7 +55126,7 @@ var HostAgentSupervisor = class {
|
|
|
55087
55126
|
const persisted = new Map((this.sessionStore.load() ?? []).map((r) => [r.deployId, r.agent]));
|
|
55088
55127
|
for (const c2 of this.children.values()) persisted.set(c2.deployId, c2.agent);
|
|
55089
55128
|
return this.listSavedSessions().map((s) => ({ s, deployId: deployIdFromWorkspace(s.cwd) })).filter(
|
|
55090
|
-
(x) => x.deployId !== null && !!x.s.cwd &&
|
|
55129
|
+
(x) => x.deployId !== null && !!x.s.cwd && fs104.existsSync(x.s.cwd)
|
|
55091
55130
|
).map(({ s, deployId }) => {
|
|
55092
55131
|
const agent = persisted.get(deployId);
|
|
55093
55132
|
return { deployId, sessionId: s.id, ...agent ? { agent } : {} };
|
|
@@ -55172,7 +55211,7 @@ var HostAgentSupervisor = class {
|
|
|
55172
55211
|
if (this.children.has(deployId)) return;
|
|
55173
55212
|
const st3 = this.resumeStateFor(target);
|
|
55174
55213
|
try {
|
|
55175
|
-
const cwd =
|
|
55214
|
+
const cwd = fs104.existsSync(target.cwd) ? target.cwd : process.cwd();
|
|
55176
55215
|
if (isWrapperCheckout(cwd)) {
|
|
55177
55216
|
log.warn(
|
|
55178
55217
|
"host-agent",
|
|
@@ -55187,7 +55226,7 @@ var HostAgentSupervisor = class {
|
|
|
55187
55226
|
const proc = this.resumeSpawner(
|
|
55188
55227
|
{
|
|
55189
55228
|
...readHouseProxyChildEnv(deployId),
|
|
55190
|
-
...this.
|
|
55229
|
+
...this.credentialEnvFor(deployId),
|
|
55191
55230
|
CODEAM_RESUME_SESSION_ID: session.id
|
|
55192
55231
|
},
|
|
55193
55232
|
cwd
|
|
@@ -55214,7 +55253,7 @@ var HostAgentSupervisor = class {
|
|
|
55214
55253
|
return;
|
|
55215
55254
|
}
|
|
55216
55255
|
if (tracked && signal) {
|
|
55217
|
-
this.onResumeChildExit(target, 128 + (
|
|
55256
|
+
this.onResumeChildExit(target, 128 + (os75.constants.signals[signal] ?? 9), `signal ${signal}`);
|
|
55218
55257
|
return;
|
|
55219
55258
|
}
|
|
55220
55259
|
log.warn(
|
|
@@ -55257,7 +55296,7 @@ var HostAgentSupervisor = class {
|
|
|
55257
55296
|
if (Date.now() - child.startedAt < CRASH_RESPAWN_MIN_UPTIME_MS) return false;
|
|
55258
55297
|
const session = pickSavedSessionForWorkspace(this.listSavedSessions(), child.cwd);
|
|
55259
55298
|
if (!session) return false;
|
|
55260
|
-
const exitCode = typeof code === "number" ? code : 128 + (signal ?
|
|
55299
|
+
const exitCode = typeof code === "number" ? code : 128 + (signal ? os75.constants.signals[signal] ?? 9 : 9);
|
|
55261
55300
|
log.warn(
|
|
55262
55301
|
"host-agent",
|
|
55263
55302
|
`session deploy=${child.deployId.slice(0, 8)} died (${signal ?? code}) after ${Math.round((Date.now() - child.startedAt) / 1e3)}s \u2014 respawning it (resume)`
|
|
@@ -55398,6 +55437,7 @@ var HostAgentSupervisor = class {
|
|
|
55398
55437
|
cleanupWorkspace(deployId) {
|
|
55399
55438
|
const short = deployId.slice(0, 8);
|
|
55400
55439
|
this.credentialEnvByDeploy.delete(deployId);
|
|
55440
|
+
clearCredentialEnv(deployId);
|
|
55401
55441
|
const child = this.children.get(deployId);
|
|
55402
55442
|
if (child) {
|
|
55403
55443
|
try {
|
|
@@ -55407,12 +55447,12 @@ var HostAgentSupervisor = class {
|
|
|
55407
55447
|
this.untrackChild(deployId);
|
|
55408
55448
|
}
|
|
55409
55449
|
const dirs = [
|
|
55410
|
-
|
|
55411
|
-
|
|
55450
|
+
path116.join(selfHostedWorkspaceRoot(), deployId),
|
|
55451
|
+
path116.join(os75.homedir(), ".codeam", "house-claude", deployId)
|
|
55412
55452
|
];
|
|
55413
55453
|
for (const dir of dirs) {
|
|
55414
55454
|
try {
|
|
55415
|
-
|
|
55455
|
+
fs104.rmSync(dir, { recursive: true, force: true });
|
|
55416
55456
|
} catch (err) {
|
|
55417
55457
|
log.warn(
|
|
55418
55458
|
"host-agent",
|
|
@@ -55449,6 +55489,7 @@ var HostAgentSupervisor = class {
|
|
|
55449
55489
|
if (Object.keys(credEnv).length === 0 && AUTH_FILE_CACHED_IN_MEMORY.has(payload.agentId)) {
|
|
55450
55490
|
for (const child of affected) {
|
|
55451
55491
|
this.credentialEnvByDeploy.delete(child.deployId);
|
|
55492
|
+
clearCredentialEnv(child.deployId);
|
|
55452
55493
|
this.restartWithFreshCredentials(child);
|
|
55453
55494
|
}
|
|
55454
55495
|
log.info(
|
|
@@ -55458,7 +55499,10 @@ var HostAgentSupervisor = class {
|
|
|
55458
55499
|
return;
|
|
55459
55500
|
}
|
|
55460
55501
|
if (Object.keys(credEnv).length === 0) {
|
|
55461
|
-
for (const c2 of affected)
|
|
55502
|
+
for (const c2 of affected) {
|
|
55503
|
+
this.credentialEnvByDeploy.delete(c2.deployId);
|
|
55504
|
+
clearCredentialEnv(c2.deployId);
|
|
55505
|
+
}
|
|
55462
55506
|
log.info(
|
|
55463
55507
|
"host-agent",
|
|
55464
55508
|
`refreshed credentials in place for agent=${payload.agentId} (${this.children.size} active child(ren))`
|
|
@@ -55467,6 +55511,7 @@ var HostAgentSupervisor = class {
|
|
|
55467
55511
|
}
|
|
55468
55512
|
for (const child of affected) {
|
|
55469
55513
|
this.credentialEnvByDeploy.set(child.deployId, credEnv);
|
|
55514
|
+
persistCredentialEnv(child.deployId, credEnv);
|
|
55470
55515
|
this.restartWithFreshCredentials(child);
|
|
55471
55516
|
}
|
|
55472
55517
|
log.info(
|
|
@@ -55486,6 +55531,17 @@ var HostAgentSupervisor = class {
|
|
|
55486
55531
|
* reports `ended` nor crash-respawns), then resume the same conversation;
|
|
55487
55532
|
* `resumeOne` waits out the dying daemon if it still holds the session.
|
|
55488
55533
|
*/
|
|
55534
|
+
/**
|
|
55535
|
+
* The env credential of a deploy for a (re)spawn: memory first, else what an earlier host-agent
|
|
55536
|
+
* process persisted (a Box rebuilt on its volume, a wake, a self-update restart).
|
|
55537
|
+
*/
|
|
55538
|
+
credentialEnvFor(deployId) {
|
|
55539
|
+
const inMemory = this.credentialEnvByDeploy.get(deployId);
|
|
55540
|
+
if (inMemory) return inMemory;
|
|
55541
|
+
const persisted = readCredentialEnv(deployId);
|
|
55542
|
+
if (Object.keys(persisted).length > 0) this.credentialEnvByDeploy.set(deployId, persisted);
|
|
55543
|
+
return persisted;
|
|
55544
|
+
}
|
|
55489
55545
|
restartWithFreshCredentials(child) {
|
|
55490
55546
|
const session = pickSavedSessionForWorkspace(this.listSavedSessions(), child.cwd, child.deployId);
|
|
55491
55547
|
if (!session) {
|
|
@@ -55642,8 +55698,8 @@ async function invite() {
|
|
|
55642
55698
|
var import_node_dns = require("dns");
|
|
55643
55699
|
var import_node_util11 = require("util");
|
|
55644
55700
|
var import_node_crypto17 = require("crypto");
|
|
55645
|
-
var
|
|
55646
|
-
var
|
|
55701
|
+
var fs105 = __toESM(require("fs"));
|
|
55702
|
+
var path117 = __toESM(require("path"));
|
|
55647
55703
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
55648
55704
|
var dnsResolveP = (0, import_node_util11.promisify)(import_node_dns.resolve);
|
|
55649
55705
|
async function checkDns(apiBase2) {
|
|
@@ -55699,13 +55755,13 @@ async function checkHealth(apiBase2) {
|
|
|
55699
55755
|
}
|
|
55700
55756
|
}
|
|
55701
55757
|
function checkConfigDir() {
|
|
55702
|
-
const dir =
|
|
55758
|
+
const dir = path117.join(require("os").homedir(), ".codeam");
|
|
55703
55759
|
try {
|
|
55704
|
-
|
|
55705
|
-
const probe =
|
|
55706
|
-
|
|
55707
|
-
const read =
|
|
55708
|
-
|
|
55760
|
+
fs105.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
55761
|
+
const probe = path117.join(dir, ".doctor-probe");
|
|
55762
|
+
fs105.writeFileSync(probe, "ok", { mode: 384 });
|
|
55763
|
+
const read = fs105.readFileSync(probe, "utf8");
|
|
55764
|
+
fs105.unlinkSync(probe);
|
|
55709
55765
|
if (read !== "ok") throw new Error("write/read round-trip mismatch");
|
|
55710
55766
|
return {
|
|
55711
55767
|
id: "config-dir",
|
|
@@ -55745,9 +55801,9 @@ function checkSessions() {
|
|
|
55745
55801
|
}
|
|
55746
55802
|
}
|
|
55747
55803
|
function checkAgentBinaries() {
|
|
55748
|
-
const
|
|
55804
|
+
const os78 = createOsStrategy();
|
|
55749
55805
|
return getEnabledAgents().map((meta) => {
|
|
55750
|
-
const found =
|
|
55806
|
+
const found = os78.findInPath(meta.binaryName);
|
|
55751
55807
|
return {
|
|
55752
55808
|
id: `agent-${meta.id}`,
|
|
55753
55809
|
label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
|
|
@@ -55769,7 +55825,7 @@ function checkNodePty() {
|
|
|
55769
55825
|
detail: "not required on this platform"
|
|
55770
55826
|
};
|
|
55771
55827
|
}
|
|
55772
|
-
const vendoredPath =
|
|
55828
|
+
const vendoredPath = path117.join(__dirname, "vendor", "node-pty");
|
|
55773
55829
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
55774
55830
|
try {
|
|
55775
55831
|
require(target);
|
|
@@ -55811,7 +55867,7 @@ function checkChokidar() {
|
|
|
55811
55867
|
}
|
|
55812
55868
|
async function doctor(args2 = []) {
|
|
55813
55869
|
const json = args2.includes("--json");
|
|
55814
|
-
const cliVersion = true ? "2.76.
|
|
55870
|
+
const cliVersion = true ? "2.76.47" : "0.0.0-dev";
|
|
55815
55871
|
const apiBase2 = resolveApiBaseUrl();
|
|
55816
55872
|
const diagnosticId = (0, import_node_crypto17.randomUUID)();
|
|
55817
55873
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
@@ -56347,7 +56403,7 @@ async function mcpWarm(argv = [], opts = {}) {
|
|
|
56347
56403
|
// src/commands/version.ts
|
|
56348
56404
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
56349
56405
|
function version2() {
|
|
56350
|
-
const v = true ? "2.76.
|
|
56406
|
+
const v = true ? "2.76.47" : "unknown";
|
|
56351
56407
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
56352
56408
|
}
|
|
56353
56409
|
|
|
@@ -56480,10 +56536,10 @@ function tryShowSubcommandHelp(cmd, args2) {
|
|
|
56480
56536
|
var _subcommandHelpKeys = Object.keys(HELPS);
|
|
56481
56537
|
|
|
56482
56538
|
// src/index.ts
|
|
56483
|
-
var
|
|
56539
|
+
var os77 = __toESM(require("os"));
|
|
56484
56540
|
if (!process.env.HOME) {
|
|
56485
56541
|
try {
|
|
56486
|
-
const home =
|
|
56542
|
+
const home = os77.homedir();
|
|
56487
56543
|
if (home) process.env.HOME = home;
|
|
56488
56544
|
} catch {
|
|
56489
56545
|
}
|