codeam-cli 2.76.3 → 2.76.5
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 +12 -0
- package/dist/index.js +409 -356
- 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 = path105.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "convex.cmd" : "convex");
|
|
361
|
+
if (fs91.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_process37,
|
|
492
|
+
var import_node_child_process37, fs91, path105, 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_process37 = require("child_process");
|
|
497
|
-
|
|
498
|
-
|
|
497
|
+
fs91 = __toESM(require("fs"));
|
|
498
|
+
path105 = __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(path107) {
|
|
3599
3599
|
try {
|
|
3600
|
-
fs2.rmSync(
|
|
3600
|
+
fs2.rmSync(path107, { force: true });
|
|
3601
3601
|
} catch (err) {
|
|
3602
|
-
log.debug(TAG, `rmIfExists failed for ${
|
|
3602
|
+
log.debug(TAG, `rmIfExists failed for ${path107}`, err);
|
|
3603
3603
|
}
|
|
3604
3604
|
}
|
|
3605
3605
|
function killQuiet(target, signal = "SIGTERM") {
|
|
@@ -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(path107) {
|
|
3807
|
+
return path107.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: path107, 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/${path107}?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(path107, openSourceFile, logger) {
|
|
7787
7787
|
let fileHandle;
|
|
7788
7788
|
let isValid = false;
|
|
7789
7789
|
try {
|
|
7790
|
-
fileHandle = await openSourceFile(
|
|
7790
|
+
fileHandle = await openSourceFile(path107, 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 ${path107}: ${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(path106, openSourceFile, logger) {
|
|
|
7800
7800
|
});
|
|
7801
7801
|
}
|
|
7802
7802
|
}
|
|
7803
|
-
async function getContextLinesFromFile(
|
|
7804
|
-
const fileHandle = await openRegularSourceFile(
|
|
7803
|
+
async function getContextLinesFromFile(path107, ranges, output, cacheKey, openSourceFile, logger) {
|
|
7804
|
+
const fileHandle = await openRegularSourceFile(path107, 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((resolve12) => {
|
|
@@ -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(path107) {
|
|
7907
|
+
return path107.startsWith("node:") || path107.endsWith(".min.js") || path107.endsWith(".min.cjs") || path107.endsWith(".min.mjs") || path107.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(path107, basePath) {
|
|
7915
|
+
if ((0, import_node_path.isAbsolute)(path107)) return JSON.stringify([
|
|
7916
7916
|
null,
|
|
7917
|
-
|
|
7917
|
+
path107
|
|
7918
7918
|
]);
|
|
7919
7919
|
return void 0 === basePath ? void 0 : JSON.stringify([
|
|
7920
7920
|
basePath,
|
|
7921
|
-
|
|
7921
|
+
path107
|
|
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.5" : "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.5",
|
|
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.5" ? { ideVersion: "2.76.5" } : {}
|
|
12164
12164
|
};
|
|
12165
12165
|
try {
|
|
12166
12166
|
const res = await _postJson(`${API_BASE2}/api/plugin/heartbeat`, body);
|
|
@@ -17237,10 +17237,10 @@ function buildForPlatform(platform3) {
|
|
|
17237
17237
|
var import_node_crypto4 = require("crypto");
|
|
17238
17238
|
|
|
17239
17239
|
// src/agents/claude/resolver.ts
|
|
17240
|
-
function buildClaudeLaunch(extraArgs = [],
|
|
17241
|
-
const found =
|
|
17240
|
+
function buildClaudeLaunch(extraArgs = [], os69 = createOsStrategy()) {
|
|
17241
|
+
const found = os69.findInPath("claude") ?? os69.findInPath("claude-code");
|
|
17242
17242
|
if (!found) return null;
|
|
17243
|
-
return
|
|
17243
|
+
return os69.buildLaunch(found, extraArgs);
|
|
17244
17244
|
}
|
|
17245
17245
|
|
|
17246
17246
|
// src/agents/claude/installer.ts
|
|
@@ -17680,7 +17680,7 @@ function claudeConfigDir(env = process.env) {
|
|
|
17680
17680
|
// src/agents/claude/history.ts
|
|
17681
17681
|
var path19 = __toESM(require("path"));
|
|
17682
17682
|
function encodeCwd(cwd) {
|
|
17683
|
-
return cwd.replace(/[\\/:_]/g, "-");
|
|
17683
|
+
return cwd.replace(/[\\/:_.]/g, "-");
|
|
17684
17684
|
}
|
|
17685
17685
|
function resolveHistoryDir(cwd, projectsRoot) {
|
|
17686
17686
|
const root = projectsRoot ?? path19.join(claudeConfigDir(), "projects");
|
|
@@ -18033,8 +18033,8 @@ var ClaudeRuntimeStrategy = class {
|
|
|
18033
18033
|
meta = getAgent("claude");
|
|
18034
18034
|
mode = "interactive";
|
|
18035
18035
|
os;
|
|
18036
|
-
constructor(
|
|
18037
|
-
this.os =
|
|
18036
|
+
constructor(os69) {
|
|
18037
|
+
this.os = os69;
|
|
18038
18038
|
}
|
|
18039
18039
|
/**
|
|
18040
18040
|
* Claude Code's react-ink TUI enables bracketed-paste mode at
|
|
@@ -19129,8 +19129,8 @@ function codexCredentialLocator() {
|
|
|
19129
19129
|
function codexLoginLauncher() {
|
|
19130
19130
|
return {
|
|
19131
19131
|
async ensureInstalled() {
|
|
19132
|
-
const
|
|
19133
|
-
return
|
|
19132
|
+
const os69 = createOsStrategy();
|
|
19133
|
+
return os69.findInPath("codex") !== null;
|
|
19134
19134
|
},
|
|
19135
19135
|
launch() {
|
|
19136
19136
|
return (0, import_node_child_process3.spawn)("codex", ["login"], { stdio: "inherit" });
|
|
@@ -19153,8 +19153,8 @@ var CodexRuntimeStrategy = class {
|
|
|
19153
19153
|
meta = getAgent("codex");
|
|
19154
19154
|
mode = "interactive";
|
|
19155
19155
|
os;
|
|
19156
|
-
constructor(
|
|
19157
|
-
this.os =
|
|
19156
|
+
constructor(os69) {
|
|
19157
|
+
this.os = os69;
|
|
19158
19158
|
}
|
|
19159
19159
|
async prepareLaunch() {
|
|
19160
19160
|
let binary = this.os.findInPath("codex");
|
|
@@ -19265,12 +19265,12 @@ var CodexRuntimeStrategy = class {
|
|
|
19265
19265
|
});
|
|
19266
19266
|
}
|
|
19267
19267
|
};
|
|
19268
|
-
function resolveNpm(
|
|
19269
|
-
return
|
|
19268
|
+
function resolveNpm(os69) {
|
|
19269
|
+
return os69.id === "win32" ? "npm.cmd" : "npm";
|
|
19270
19270
|
}
|
|
19271
|
-
async function installCodexViaNpm(
|
|
19271
|
+
async function installCodexViaNpm(os69) {
|
|
19272
19272
|
return new Promise((resolve12, reject) => {
|
|
19273
|
-
const proc = (0, import_node_child_process4.spawn)(resolveNpm(
|
|
19273
|
+
const proc = (0, import_node_child_process4.spawn)(resolveNpm(os69), ["install", "-g", "@openai/codex"], {
|
|
19274
19274
|
stdio: "inherit"
|
|
19275
19275
|
});
|
|
19276
19276
|
proc.on("close", (code) => {
|
|
@@ -19287,16 +19287,16 @@ async function installCodexViaNpm(os68) {
|
|
|
19287
19287
|
});
|
|
19288
19288
|
});
|
|
19289
19289
|
}
|
|
19290
|
-
function augmentNpmGlobalBin(
|
|
19290
|
+
function augmentNpmGlobalBin(os69) {
|
|
19291
19291
|
try {
|
|
19292
|
-
const result = (0, import_node_child_process4.spawnSync)(resolveNpm(
|
|
19292
|
+
const result = (0, import_node_child_process4.spawnSync)(resolveNpm(os69), ["prefix", "-g"], {
|
|
19293
19293
|
stdio: ["ignore", "pipe", "ignore"]
|
|
19294
19294
|
});
|
|
19295
19295
|
if (result.status !== 0) return;
|
|
19296
19296
|
const prefix = result.stdout.toString().trim();
|
|
19297
19297
|
if (!prefix) return;
|
|
19298
|
-
const binDir =
|
|
19299
|
-
|
|
19298
|
+
const binDir = os69.id === "win32" ? prefix : path25.join(prefix, "bin");
|
|
19299
|
+
os69.augmentPath([binDir]);
|
|
19300
19300
|
} catch {
|
|
19301
19301
|
}
|
|
19302
19302
|
}
|
|
@@ -19490,10 +19490,10 @@ function manualInstallHint(runner, tools) {
|
|
|
19490
19490
|
const argv = osPackageInstallArgv(detectPackageManager(runner), [...tools]);
|
|
19491
19491
|
return argv ? `\`sudo ${argv.join(" ")}\`` : `your package manager (e.g. \`${pkgs}\`)`;
|
|
19492
19492
|
}
|
|
19493
|
-
function writeUnzipShim(
|
|
19493
|
+
function writeUnzipShim(os69, runner) {
|
|
19494
19494
|
const python = ["python3", "python"].find((p2) => runner.which(p2));
|
|
19495
19495
|
if (!python) return null;
|
|
19496
|
-
const dir =
|
|
19496
|
+
const dir = os69.scratchPath("codeam-cr-prereq");
|
|
19497
19497
|
const shim = path27.join(dir, "unzip");
|
|
19498
19498
|
const script = `#!/bin/sh
|
|
19499
19499
|
set -e
|
|
@@ -19515,9 +19515,9 @@ exec ${python} -m zipfile -e "$archive" "$dest"
|
|
|
19515
19515
|
(0, import_node_fs5.chmodSync)(shim, 448);
|
|
19516
19516
|
return dir;
|
|
19517
19517
|
}
|
|
19518
|
-
async function ensureInstallPrerequisites(
|
|
19518
|
+
async function ensureInstallPrerequisites(os69, deps = {}) {
|
|
19519
19519
|
const runner = deps.runner ?? defaultOsRunner;
|
|
19520
|
-
const missing = REQUIRED_TOOLS.filter((t2) =>
|
|
19520
|
+
const missing = REQUIRED_TOOLS.filter((t2) => os69.findInPath(t2) === null);
|
|
19521
19521
|
if (missing.length === 0) return { ok: true, extraPath: [] };
|
|
19522
19522
|
log.info(
|
|
19523
19523
|
"coderabbit",
|
|
@@ -19536,10 +19536,10 @@ async function ensureInstallPrerequisites(os68, deps = {}) {
|
|
|
19536
19536
|
);
|
|
19537
19537
|
}
|
|
19538
19538
|
}
|
|
19539
|
-
const stillMissing = REQUIRED_TOOLS.filter((t2) =>
|
|
19539
|
+
const stillMissing = REQUIRED_TOOLS.filter((t2) => os69.findInPath(t2) === null);
|
|
19540
19540
|
if (stillMissing.length === 0) return { ok: true, extraPath: [] };
|
|
19541
19541
|
if (stillMissing.length === 1 && stillMissing[0] === "unzip") {
|
|
19542
|
-
const shimDir = writeUnzipShim(
|
|
19542
|
+
const shimDir = writeUnzipShim(os69, runner);
|
|
19543
19543
|
if (shimDir) {
|
|
19544
19544
|
log.info("coderabbit", "unzip is unavailable \u2014 using a scoped python zipfile shim");
|
|
19545
19545
|
return { ok: true, extraPath: [shimDir] };
|
|
@@ -19602,15 +19602,15 @@ function summarizeInstallFailure(output) {
|
|
|
19602
19602
|
}
|
|
19603
19603
|
return lines.length > 0 ? lines[lines.length - 1] : null;
|
|
19604
19604
|
}
|
|
19605
|
-
async function ensureCoderabbitInstalled(
|
|
19606
|
-
if (
|
|
19607
|
-
if (
|
|
19605
|
+
async function ensureCoderabbitInstalled(os69, deps = {}) {
|
|
19606
|
+
if (os69.findInPath("coderabbit")) return { ok: true };
|
|
19607
|
+
if (os69.id === "win32") {
|
|
19608
19608
|
return {
|
|
19609
19609
|
ok: false,
|
|
19610
19610
|
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."
|
|
19611
19611
|
};
|
|
19612
19612
|
}
|
|
19613
|
-
const prereq = await ensureInstallPrerequisites(
|
|
19613
|
+
const prereq = await ensureInstallPrerequisites(os69, deps);
|
|
19614
19614
|
if (!prereq.ok) return { ok: false, error: prereq.error };
|
|
19615
19615
|
const env = { ...process.env };
|
|
19616
19616
|
if (prereq.extraPath.length > 0) {
|
|
@@ -19619,8 +19619,8 @@ async function ensureCoderabbitInstalled(os68, deps = {}) {
|
|
|
19619
19619
|
log.info("coderabbit", "CodeRabbit CLI not found \u2014 installing via the official script");
|
|
19620
19620
|
const run3 = deps.runInstallScript ?? defaultRunInstallScript;
|
|
19621
19621
|
const { code, output } = await run3(env);
|
|
19622
|
-
|
|
19623
|
-
const binary =
|
|
19622
|
+
os69.augmentPath([`${os69.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
|
|
19623
|
+
const binary = os69.findInPath("coderabbit");
|
|
19624
19624
|
const detail = summarizeInstallFailure(output);
|
|
19625
19625
|
if (binary !== null) {
|
|
19626
19626
|
if (code === 0) return { ok: true };
|
|
@@ -19674,10 +19674,10 @@ function coderabbitCredentialLocator() {
|
|
|
19674
19674
|
validate: validateNonEmptyCredential
|
|
19675
19675
|
};
|
|
19676
19676
|
}
|
|
19677
|
-
function coderabbitLoginLauncher(
|
|
19677
|
+
function coderabbitLoginLauncher(os69) {
|
|
19678
19678
|
return {
|
|
19679
19679
|
async ensureInstalled() {
|
|
19680
|
-
const result = await ensureCoderabbitInstalled(
|
|
19680
|
+
const result = await ensureCoderabbitInstalled(os69);
|
|
19681
19681
|
if (!result.ok && result.error) console.error(`
|
|
19682
19682
|
\u2717 ${result.error}
|
|
19683
19683
|
`);
|
|
@@ -19737,8 +19737,8 @@ function pickLine(obj) {
|
|
|
19737
19737
|
function toHunk(raw, groupSeverity) {
|
|
19738
19738
|
if (!raw || typeof raw !== "object") return null;
|
|
19739
19739
|
const o = raw;
|
|
19740
|
-
const
|
|
19741
|
-
if (!
|
|
19740
|
+
const path107 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
|
|
19741
|
+
if (!path107) return null;
|
|
19742
19742
|
const message = asString(
|
|
19743
19743
|
pick(o, [
|
|
19744
19744
|
"comment",
|
|
@@ -19755,7 +19755,7 @@ function toHunk(raw, groupSeverity) {
|
|
|
19755
19755
|
const severity = normSeverity(pick(o, ["severity", "level", "priority", "impact"])) ?? normSeverity(groupSeverity);
|
|
19756
19756
|
const locObj = pick(o, ["location"]) ?? o;
|
|
19757
19757
|
return {
|
|
19758
|
-
path:
|
|
19758
|
+
path: path107.trim(),
|
|
19759
19759
|
line: pickLine(o) ?? pickLine(locObj),
|
|
19760
19760
|
severity,
|
|
19761
19761
|
message: (title && message ? `${title}: ${message}` : title || message).trim() || "(no message)"
|
|
@@ -19838,10 +19838,10 @@ function parsePlain(stdout) {
|
|
|
19838
19838
|
for (const line of stdout.split(/\r?\n/)) {
|
|
19839
19839
|
const m = line.match(HUNK_LINE_RE);
|
|
19840
19840
|
if (!m) continue;
|
|
19841
|
-
const [,
|
|
19842
|
-
if (!
|
|
19841
|
+
const [, path107, lineNo, sevToken, message] = m;
|
|
19842
|
+
if (!path107 || !lineNo || !message) continue;
|
|
19843
19843
|
hunks.push({
|
|
19844
|
-
path:
|
|
19844
|
+
path: path107.trim(),
|
|
19845
19845
|
line: Number(lineNo),
|
|
19846
19846
|
severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
|
|
19847
19847
|
message: message.trim().replace(/^[*-]\s+/, "")
|
|
@@ -19901,8 +19901,8 @@ var CoderabbitRuntimeStrategy = class {
|
|
|
19901
19901
|
meta = getAgent("coderabbit");
|
|
19902
19902
|
mode = "batch";
|
|
19903
19903
|
os;
|
|
19904
|
-
constructor(
|
|
19905
|
-
this.os =
|
|
19904
|
+
constructor(os69) {
|
|
19905
|
+
this.os = os69;
|
|
19906
19906
|
}
|
|
19907
19907
|
getDefaultArgs() {
|
|
19908
19908
|
return ["review", "--agent"];
|
|
@@ -20173,10 +20173,10 @@ function cursorCredentialLocator() {
|
|
|
20173
20173
|
validate: validateNonEmptyCredential
|
|
20174
20174
|
};
|
|
20175
20175
|
}
|
|
20176
|
-
function cursorLoginLauncher(
|
|
20176
|
+
function cursorLoginLauncher(os69) {
|
|
20177
20177
|
return {
|
|
20178
20178
|
async ensureInstalled() {
|
|
20179
|
-
if (
|
|
20179
|
+
if (os69.findInPath("cursor-agent")) return true;
|
|
20180
20180
|
console.error(
|
|
20181
20181
|
"\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"
|
|
20182
20182
|
);
|
|
@@ -20240,8 +20240,8 @@ var CursorRuntimeStrategy = class {
|
|
|
20240
20240
|
meta = getAgent("cursor");
|
|
20241
20241
|
mode = "interactive";
|
|
20242
20242
|
os;
|
|
20243
|
-
constructor(
|
|
20244
|
-
this.os =
|
|
20243
|
+
constructor(os69) {
|
|
20244
|
+
this.os = os69;
|
|
20245
20245
|
}
|
|
20246
20246
|
async prepareLaunch() {
|
|
20247
20247
|
const binary = this.os.findInPath("cursor-agent");
|
|
@@ -20459,10 +20459,10 @@ function aiderCredentialLocator() {
|
|
|
20459
20459
|
validate: validateNonEmptyCredential
|
|
20460
20460
|
};
|
|
20461
20461
|
}
|
|
20462
|
-
function aiderLoginLauncher(
|
|
20462
|
+
function aiderLoginLauncher(os69) {
|
|
20463
20463
|
return {
|
|
20464
20464
|
async ensureInstalled() {
|
|
20465
|
-
if (
|
|
20465
|
+
if (os69.findInPath("aider")) return true;
|
|
20466
20466
|
console.error(
|
|
20467
20467
|
"\n \u2717 aider binary not on PATH.\n Install Aider:\n pip install aider-chat\n then re-run `codeam link aider`.\n"
|
|
20468
20468
|
);
|
|
@@ -20472,7 +20472,7 @@ function aiderLoginLauncher(os68) {
|
|
|
20472
20472
|
console.error(
|
|
20473
20473
|
"\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"
|
|
20474
20474
|
);
|
|
20475
|
-
return (0, import_node_child_process11.spawn)(
|
|
20475
|
+
return (0, import_node_child_process11.spawn)(os69.id === "win32" ? "cmd.exe" : "sh", os69.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
|
|
20476
20476
|
stdio: "ignore"
|
|
20477
20477
|
});
|
|
20478
20478
|
}
|
|
@@ -20747,8 +20747,8 @@ var AiderRuntimeStrategy = class {
|
|
|
20747
20747
|
meta = getAgent("aider");
|
|
20748
20748
|
mode = "interactive";
|
|
20749
20749
|
os;
|
|
20750
|
-
constructor(
|
|
20751
|
-
this.os =
|
|
20750
|
+
constructor(os69) {
|
|
20751
|
+
this.os = os69;
|
|
20752
20752
|
}
|
|
20753
20753
|
async prepareLaunch() {
|
|
20754
20754
|
augmentUserLocalBinPaths();
|
|
@@ -20881,8 +20881,8 @@ function geminiCredentialLocator() {
|
|
|
20881
20881
|
function geminiLoginLauncher() {
|
|
20882
20882
|
return {
|
|
20883
20883
|
async ensureInstalled() {
|
|
20884
|
-
const
|
|
20885
|
-
return
|
|
20884
|
+
const os69 = createOsStrategy();
|
|
20885
|
+
return os69.findInPath("gemini") !== null;
|
|
20886
20886
|
},
|
|
20887
20887
|
launch() {
|
|
20888
20888
|
return (0, import_node_child_process12.spawn)("gemini", ["auth", "login"], { stdio: "inherit" });
|
|
@@ -21072,8 +21072,8 @@ var GeminiRuntimeStrategy = class {
|
|
|
21072
21072
|
meta = getAgent("gemini");
|
|
21073
21073
|
mode = "interactive";
|
|
21074
21074
|
os;
|
|
21075
|
-
constructor(
|
|
21076
|
-
this.os =
|
|
21075
|
+
constructor(os69) {
|
|
21076
|
+
this.os = os69;
|
|
21077
21077
|
}
|
|
21078
21078
|
async prepareLaunch() {
|
|
21079
21079
|
const binary = this.os.findInPath("gemini");
|
|
@@ -21366,8 +21366,8 @@ var KimiRuntimeStrategy = class {
|
|
|
21366
21366
|
meta = getAgent("kimi");
|
|
21367
21367
|
mode = "interactive";
|
|
21368
21368
|
os;
|
|
21369
|
-
constructor(
|
|
21370
|
-
this.os =
|
|
21369
|
+
constructor(os69) {
|
|
21370
|
+
this.os = os69;
|
|
21371
21371
|
}
|
|
21372
21372
|
async prepareLaunch() {
|
|
21373
21373
|
const binary = this.os.findInPath("kimi");
|
|
@@ -21511,8 +21511,8 @@ var OpencodeRuntimeStrategy = class {
|
|
|
21511
21511
|
meta = getAgent("opencode");
|
|
21512
21512
|
mode = "interactive";
|
|
21513
21513
|
os;
|
|
21514
|
-
constructor(
|
|
21515
|
-
this.os =
|
|
21514
|
+
constructor(os69) {
|
|
21515
|
+
this.os = os69;
|
|
21516
21516
|
}
|
|
21517
21517
|
async prepareLaunch() {
|
|
21518
21518
|
const binary = this.os.findInPath("opencode");
|
|
@@ -21598,20 +21598,20 @@ var OpencodeRuntimeStrategy = class {
|
|
|
21598
21598
|
|
|
21599
21599
|
// src/agents/registry.ts
|
|
21600
21600
|
var runtimeBuilders = {
|
|
21601
|
-
claude: (
|
|
21602
|
-
codex: (
|
|
21603
|
-
coderabbit: (
|
|
21604
|
-
cursor: (
|
|
21605
|
-
aider: (
|
|
21606
|
-
gemini: (
|
|
21607
|
-
kimi: (
|
|
21608
|
-
opencode: (
|
|
21601
|
+
claude: (os69) => new ClaudeRuntimeStrategy(os69),
|
|
21602
|
+
codex: (os69) => new CodexRuntimeStrategy(os69),
|
|
21603
|
+
coderabbit: (os69) => new CoderabbitRuntimeStrategy(os69),
|
|
21604
|
+
cursor: (os69) => new CursorRuntimeStrategy(os69),
|
|
21605
|
+
aider: (os69) => new AiderRuntimeStrategy(os69),
|
|
21606
|
+
gemini: (os69) => new GeminiRuntimeStrategy(os69),
|
|
21607
|
+
kimi: (os69) => new KimiRuntimeStrategy(os69),
|
|
21608
|
+
opencode: (os69) => new OpencodeRuntimeStrategy(os69)
|
|
21609
21609
|
};
|
|
21610
21610
|
var deployBuilders = {
|
|
21611
21611
|
claude: () => new ClaudeDeployStrategy(),
|
|
21612
21612
|
codex: () => new CodexDeployStrategy()
|
|
21613
21613
|
};
|
|
21614
|
-
function createAgentStrategy(agent,
|
|
21614
|
+
function createAgentStrategy(agent, os69 = createOsStrategy()) {
|
|
21615
21615
|
if (!AGENT_REGISTRY[agent]?.enabled) {
|
|
21616
21616
|
throw new Error(
|
|
21617
21617
|
`Agent "${agent}" is not supported in this codeam-cli version. Upgrade with 'npm i -g codeam-cli@latest'.`
|
|
@@ -21621,10 +21621,10 @@ function createAgentStrategy(agent, os68 = createOsStrategy()) {
|
|
|
21621
21621
|
if (!build) {
|
|
21622
21622
|
throw new Error(`No runtime strategy registered for agent "${agent}"`);
|
|
21623
21623
|
}
|
|
21624
|
-
return build(
|
|
21624
|
+
return build(os69);
|
|
21625
21625
|
}
|
|
21626
|
-
function createInteractiveAgentStrategy(agent,
|
|
21627
|
-
const s = createAgentStrategy(agent,
|
|
21626
|
+
function createInteractiveAgentStrategy(agent, os69 = createOsStrategy()) {
|
|
21627
|
+
const s = createAgentStrategy(agent, os69);
|
|
21628
21628
|
if (s.mode !== "interactive") {
|
|
21629
21629
|
throw new Error(
|
|
21630
21630
|
`Agent "${agent}" is a batch agent; use createAgentStrategy + .runOneShot for one-shot reviews.`
|
|
@@ -22338,8 +22338,8 @@ function collectChangedFiles(cwd) {
|
|
|
22338
22338
|
}
|
|
22339
22339
|
return [...byPath.values()];
|
|
22340
22340
|
}
|
|
22341
|
-
function restoreCoderabbitOauthBlob(
|
|
22342
|
-
const dir = path39.join(
|
|
22341
|
+
function restoreCoderabbitOauthBlob(os69, value) {
|
|
22342
|
+
const dir = path39.join(os69.homeDir(), ".coderabbit");
|
|
22343
22343
|
(0, import_node_fs6.mkdirSync)(dir, { recursive: true });
|
|
22344
22344
|
let file = "auth.json";
|
|
22345
22345
|
let contents = value.trim();
|
|
@@ -22359,26 +22359,26 @@ function installFailureMessage(result) {
|
|
|
22359
22359
|
return result.error ?? "CodeRabbit CLI could not be installed";
|
|
22360
22360
|
}
|
|
22361
22361
|
async function configureCoderabbit(input, deps = {}) {
|
|
22362
|
-
const
|
|
22362
|
+
const os69 = deps.os ?? createOsStrategy();
|
|
22363
22363
|
const ensureInstalled = deps.ensureInstalled ?? ensureCoderabbitInstalled;
|
|
22364
22364
|
const isLoggedIn = deps.isLoggedIn ?? defaultIsLoggedIn;
|
|
22365
22365
|
const runOAuth = deps.runOAuthLogin ?? runCoderabbitOAuthLogin;
|
|
22366
22366
|
const snapshot = deps.snapshotDir ?? (() => snapshotCredentialDir());
|
|
22367
22367
|
const capture2 = deps.captureCredential ?? ((b) => diffCapturedCredential(b));
|
|
22368
22368
|
const loginWithApiKey = deps.loginWithApiKey ?? defaultLoginWithApiKey;
|
|
22369
|
-
const home =
|
|
22370
|
-
|
|
22371
|
-
|
|
22369
|
+
const home = os69.homeDir();
|
|
22370
|
+
os69.augmentPath(
|
|
22371
|
+
os69.id === "win32" ? [
|
|
22372
22372
|
path39.join(home, ".local", "bin"),
|
|
22373
22373
|
path39.join(process.env.APPDATA ?? path39.join(home, "AppData", "Roaming"), "npm"),
|
|
22374
22374
|
path39.join(home, "scoop", "shims")
|
|
22375
22375
|
] : [path39.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"]
|
|
22376
22376
|
);
|
|
22377
|
-
const installed2 =
|
|
22377
|
+
const installed2 = os69.findInPath("coderabbit") !== null;
|
|
22378
22378
|
const base = () => ({
|
|
22379
22379
|
action: input.action,
|
|
22380
22380
|
supported: true,
|
|
22381
|
-
installed:
|
|
22381
|
+
installed: os69.findInPath("coderabbit") !== null,
|
|
22382
22382
|
loggedIn: false
|
|
22383
22383
|
});
|
|
22384
22384
|
if (input.action === "status") {
|
|
@@ -22392,7 +22392,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22392
22392
|
const key = (input.apiKey ?? "").trim();
|
|
22393
22393
|
if (!key) return { ...res2, error: "No API key provided" };
|
|
22394
22394
|
if (!res2.installed) {
|
|
22395
|
-
const inst = await ensureInstalled(
|
|
22395
|
+
const inst = await ensureInstalled(os69);
|
|
22396
22396
|
res2.installed = inst.ok;
|
|
22397
22397
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
22398
22398
|
}
|
|
@@ -22416,7 +22416,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22416
22416
|
}
|
|
22417
22417
|
if (!res2.installed) {
|
|
22418
22418
|
deps.onEvent?.({ kind: "installing" });
|
|
22419
|
-
const inst = await ensureInstalled(
|
|
22419
|
+
const inst = await ensureInstalled(os69);
|
|
22420
22420
|
res2.installed = inst.ok;
|
|
22421
22421
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
22422
22422
|
}
|
|
@@ -22433,7 +22433,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22433
22433
|
return { ...res2, loggedIn: true, linked: true };
|
|
22434
22434
|
}
|
|
22435
22435
|
try {
|
|
22436
|
-
restoreCoderabbitOauthBlob(
|
|
22436
|
+
restoreCoderabbitOauthBlob(os69, cred.credential);
|
|
22437
22437
|
} catch (err) {
|
|
22438
22438
|
return {
|
|
22439
22439
|
...res2,
|
|
@@ -22457,7 +22457,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22457
22457
|
const res2 = base();
|
|
22458
22458
|
if (!installed2) {
|
|
22459
22459
|
deps.onEvent?.({ kind: "installing" });
|
|
22460
|
-
const inst = await ensureInstalled(
|
|
22460
|
+
const inst = await ensureInstalled(os69);
|
|
22461
22461
|
res2.installed = inst.ok;
|
|
22462
22462
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
22463
22463
|
}
|
|
@@ -22497,7 +22497,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22497
22497
|
}
|
|
22498
22498
|
const res = base();
|
|
22499
22499
|
if (!res.installed) {
|
|
22500
|
-
const inst = await ensureInstalled(
|
|
22500
|
+
const inst = await ensureInstalled(os69);
|
|
22501
22501
|
res.installed = inst.ok;
|
|
22502
22502
|
if (!inst.ok) return { ...res, error: installFailureMessage(inst) };
|
|
22503
22503
|
}
|
|
@@ -23583,9 +23583,9 @@ var healRestartCounts = /* @__PURE__ */ new Map();
|
|
|
23583
23583
|
function resetBuildHealState(sessionId) {
|
|
23584
23584
|
healRestartCounts.delete(sessionId);
|
|
23585
23585
|
}
|
|
23586
|
-
function readMarker2(
|
|
23586
|
+
function readMarker2(markerPath4) {
|
|
23587
23587
|
try {
|
|
23588
|
-
return fs41.readFileSync(
|
|
23588
|
+
return fs41.readFileSync(markerPath4, "utf8").trim();
|
|
23589
23589
|
} catch {
|
|
23590
23590
|
return null;
|
|
23591
23591
|
}
|
|
@@ -23595,12 +23595,12 @@ function watchForBuildClobber(deps) {
|
|
|
23595
23595
|
const debounceMs = deps.debounceMs ?? DEFAULT_DEBOUNCE_MS;
|
|
23596
23596
|
const maxRestarts = deps.maxRestarts ?? DEFAULT_MAX_RESTARTS;
|
|
23597
23597
|
const nextDir = path48.join(deps.cwd, ".next");
|
|
23598
|
-
const
|
|
23598
|
+
const markerPath4 = path48.join(nextDir, BUILD_MARKER_NAME);
|
|
23599
23599
|
let stopped = false;
|
|
23600
23600
|
let debounceTimer = null;
|
|
23601
23601
|
let dirUnwatch = null;
|
|
23602
23602
|
let cwdUnwatch = null;
|
|
23603
|
-
let lastKnownMarker = readMarker2(
|
|
23603
|
+
let lastKnownMarker = readMarker2(markerPath4);
|
|
23604
23604
|
const stop = () => {
|
|
23605
23605
|
if (stopped) return;
|
|
23606
23606
|
stopped = true;
|
|
@@ -23615,7 +23615,7 @@ function watchForBuildClobber(deps) {
|
|
|
23615
23615
|
};
|
|
23616
23616
|
const onDebouncedClobber = () => {
|
|
23617
23617
|
if (stopped) return;
|
|
23618
|
-
const current2 = readMarker2(
|
|
23618
|
+
const current2 = readMarker2(markerPath4);
|
|
23619
23619
|
if (current2 === lastKnownMarker) return;
|
|
23620
23620
|
lastKnownMarker = current2;
|
|
23621
23621
|
const count = (healRestartCounts.get(deps.sessionId) ?? 0) + 1;
|
|
@@ -23633,7 +23633,7 @@ function watchForBuildClobber(deps) {
|
|
|
23633
23633
|
}
|
|
23634
23634
|
log.info(
|
|
23635
23635
|
"preview",
|
|
23636
|
-
`build-heal: ${
|
|
23636
|
+
`build-heal: ${markerPath4} changed (a build likely ran) \u2014 restarting the dev server (${count}/${maxRestarts})`
|
|
23637
23637
|
);
|
|
23638
23638
|
deps.notify("Rebuilt \u2014 restarting preview");
|
|
23639
23639
|
deps.restart();
|
|
@@ -23648,7 +23648,7 @@ function watchForBuildClobber(deps) {
|
|
|
23648
23648
|
};
|
|
23649
23649
|
const attachDirWatch = () => {
|
|
23650
23650
|
if (dirUnwatch) return;
|
|
23651
|
-
lastKnownMarker = readMarker2(
|
|
23651
|
+
lastKnownMarker = readMarker2(markerPath4);
|
|
23652
23652
|
dirUnwatch = watchDir(nextDir, (filename) => {
|
|
23653
23653
|
if (filename === null || filename === BUILD_MARKER_NAME) onMarkerTouched();
|
|
23654
23654
|
});
|
|
@@ -27287,11 +27287,11 @@ function resolveDoltInstallStrategy(platform3) {
|
|
|
27287
27287
|
}
|
|
27288
27288
|
var DOLT_RELEASE_BASE = "https://github.com/dolthub/dolt/releases/latest/download";
|
|
27289
27289
|
function doltPlatformTuple(platform3, arch2) {
|
|
27290
|
-
const
|
|
27290
|
+
const os69 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
|
|
27291
27291
|
const a = arch2 === "x64" ? "amd64" : arch2 === "arm64" ? "arm64" : null;
|
|
27292
27292
|
if (!a) return null;
|
|
27293
|
-
if (
|
|
27294
|
-
return `${
|
|
27293
|
+
if (os69 === "windows" && a !== "amd64") return null;
|
|
27294
|
+
return `${os69}-${a}`;
|
|
27295
27295
|
}
|
|
27296
27296
|
function resolveDoltTarballStrategy(targetDir, platform3, arch2) {
|
|
27297
27297
|
const tuple = doltPlatformTuple(platform3, arch2);
|
|
@@ -28989,7 +28989,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
28989
28989
|
});
|
|
28990
28990
|
const token = ctx.pluginAuthToken;
|
|
28991
28991
|
void (async () => {
|
|
28992
|
-
const
|
|
28992
|
+
const os69 = createOsStrategy();
|
|
28993
28993
|
try {
|
|
28994
28994
|
const report = await reviewPullRequest(
|
|
28995
28995
|
{
|
|
@@ -28998,7 +28998,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
28998
28998
|
baseBranch: parsed.baseBranch
|
|
28999
28999
|
},
|
|
29000
29000
|
{
|
|
29001
|
-
runReview: (input) => new CoderabbitRuntimeStrategy(
|
|
29001
|
+
runReview: (input) => new CoderabbitRuntimeStrategy(os69).runOneShot(input),
|
|
29002
29002
|
runGh: (args2) => defaultRunGh(args2),
|
|
29003
29003
|
postReport: async (r) => {
|
|
29004
29004
|
if (!token) return;
|
|
@@ -30269,11 +30269,11 @@ function resolveTokenValue(args2) {
|
|
|
30269
30269
|
}
|
|
30270
30270
|
const fileFlag = args2.find((a) => a.startsWith("--token-file="));
|
|
30271
30271
|
if (fileFlag) {
|
|
30272
|
-
const
|
|
30272
|
+
const path107 = fileFlag.slice("--token-file=".length);
|
|
30273
30273
|
try {
|
|
30274
|
-
const content = fs62.readFileSync(
|
|
30275
|
-
if (content.length === 0) fail(`--token-file ${
|
|
30276
|
-
rmIfExistsQuiet(
|
|
30274
|
+
const content = fs62.readFileSync(path107, "utf8").trim();
|
|
30275
|
+
if (content.length === 0) fail(`--token-file ${path107} is empty`);
|
|
30276
|
+
rmIfExistsQuiet(path107);
|
|
30277
30277
|
return content;
|
|
30278
30278
|
} catch (err) {
|
|
30279
30279
|
fail(`Could not read --token-file: ${err.message}`);
|
|
@@ -31259,10 +31259,10 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
|
|
|
31259
31259
|
}
|
|
31260
31260
|
|
|
31261
31261
|
// src/agents/acp/runner.ts
|
|
31262
|
-
var
|
|
31263
|
-
var
|
|
31264
|
-
var
|
|
31265
|
-
var
|
|
31262
|
+
var import_node_crypto14 = require("crypto");
|
|
31263
|
+
var fs80 = __toESM(require("fs"));
|
|
31264
|
+
var os58 = __toESM(require("os"));
|
|
31265
|
+
var path91 = __toESM(require("path"));
|
|
31266
31266
|
|
|
31267
31267
|
// src/agents/acp/provider-billing-signal.ts
|
|
31268
31268
|
var seen = /* @__PURE__ */ new Set();
|
|
@@ -39186,7 +39186,7 @@ function defaultRunGit(cwd, args2) {
|
|
|
39186
39186
|
});
|
|
39187
39187
|
}
|
|
39188
39188
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
39189
|
-
const
|
|
39189
|
+
const fs92 = await import("fs/promises");
|
|
39190
39190
|
const out2 = [];
|
|
39191
39191
|
await walk2(workingDir, 0);
|
|
39192
39192
|
return out2;
|
|
@@ -39194,7 +39194,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
39194
39194
|
if (depth2 > maxDepth) return;
|
|
39195
39195
|
let entries2 = [];
|
|
39196
39196
|
try {
|
|
39197
|
-
const dirents = await
|
|
39197
|
+
const dirents = await fs92.readdir(dir, { withFileTypes: true });
|
|
39198
39198
|
entries2 = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
39199
39199
|
} catch {
|
|
39200
39200
|
return;
|
|
@@ -39707,28 +39707,59 @@ async function postCredentialSync(opts, fetchImpl = fetch) {
|
|
|
39707
39707
|
}
|
|
39708
39708
|
}
|
|
39709
39709
|
|
|
39710
|
+
// src/services/active-conversation-marker.ts
|
|
39711
|
+
var import_node_crypto12 = require("crypto");
|
|
39712
|
+
var import_promises6 = __toESM(require("fs/promises"));
|
|
39713
|
+
var import_node_os13 = __toESM(require("os"));
|
|
39714
|
+
var import_node_path17 = __toESM(require("path"));
|
|
39715
|
+
function markerPath3(cwd, homeDir2 = import_node_os13.default.homedir()) {
|
|
39716
|
+
const key = (0, import_node_crypto12.createHash)("sha256").update(import_node_path17.default.resolve(cwd)).digest("hex").slice(0, 16);
|
|
39717
|
+
return import_node_path17.default.join(homeDir2, ".codeam", "conversation-active", `${key}.json`);
|
|
39718
|
+
}
|
|
39719
|
+
async function writeActiveConversationMarker(cwd, conversationId, homeDir2) {
|
|
39720
|
+
try {
|
|
39721
|
+
const file = markerPath3(cwd, homeDir2);
|
|
39722
|
+
await import_promises6.default.mkdir(import_node_path17.default.dirname(file), { recursive: true });
|
|
39723
|
+
await import_promises6.default.writeFile(
|
|
39724
|
+
file,
|
|
39725
|
+
JSON.stringify({ conversationId, at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2) + "\n",
|
|
39726
|
+
"utf8"
|
|
39727
|
+
);
|
|
39728
|
+
} catch {
|
|
39729
|
+
}
|
|
39730
|
+
}
|
|
39731
|
+
async function readActiveConversationMarker(cwd, homeDir2) {
|
|
39732
|
+
try {
|
|
39733
|
+
const raw = await import_promises6.default.readFile(markerPath3(cwd, homeDir2), "utf8");
|
|
39734
|
+
const parsed = JSON.parse(raw);
|
|
39735
|
+
return typeof parsed.conversationId === "string" && parsed.conversationId ? parsed.conversationId : null;
|
|
39736
|
+
} catch {
|
|
39737
|
+
return null;
|
|
39738
|
+
}
|
|
39739
|
+
}
|
|
39740
|
+
|
|
39710
39741
|
// src/services/turn-marker.ts
|
|
39711
|
-
var
|
|
39712
|
-
var
|
|
39713
|
-
var
|
|
39742
|
+
var fs73 = __toESM(require("fs"));
|
|
39743
|
+
var os54 = __toESM(require("os"));
|
|
39744
|
+
var path84 = __toESM(require("path"));
|
|
39714
39745
|
var depth = 0;
|
|
39715
39746
|
function codeamHome() {
|
|
39716
|
-
return
|
|
39747
|
+
return path84.join(os54.homedir(), ".codeam");
|
|
39717
39748
|
}
|
|
39718
39749
|
function turnMarkerPath(pid = process.pid, home = codeamHome()) {
|
|
39719
|
-
return
|
|
39750
|
+
return path84.join(home, "turns", String(pid));
|
|
39720
39751
|
}
|
|
39721
39752
|
function mark() {
|
|
39722
39753
|
try {
|
|
39723
39754
|
const file = turnMarkerPath();
|
|
39724
|
-
|
|
39725
|
-
|
|
39755
|
+
fs73.mkdirSync(path84.dirname(file), { recursive: true });
|
|
39756
|
+
fs73.writeFileSync(file, String(Date.now()));
|
|
39726
39757
|
} catch {
|
|
39727
39758
|
}
|
|
39728
39759
|
}
|
|
39729
39760
|
function clear() {
|
|
39730
39761
|
try {
|
|
39731
|
-
|
|
39762
|
+
fs73.rmSync(turnMarkerPath(), { force: true });
|
|
39732
39763
|
} catch {
|
|
39733
39764
|
}
|
|
39734
39765
|
}
|
|
@@ -39743,7 +39774,7 @@ async function withTurnMarker(fn) {
|
|
|
39743
39774
|
function isProcessMidTurn(pid, home) {
|
|
39744
39775
|
if (!pid) return false;
|
|
39745
39776
|
try {
|
|
39746
|
-
return
|
|
39777
|
+
return fs73.existsSync(turnMarkerPath(pid, home));
|
|
39747
39778
|
} catch {
|
|
39748
39779
|
return false;
|
|
39749
39780
|
}
|
|
@@ -39751,8 +39782,8 @@ function isProcessMidTurn(pid, home) {
|
|
|
39751
39782
|
|
|
39752
39783
|
// src/packs/gates.ts
|
|
39753
39784
|
var import_node_child_process28 = require("child_process");
|
|
39754
|
-
var
|
|
39755
|
-
var
|
|
39785
|
+
var fs74 = __toESM(require("fs"));
|
|
39786
|
+
var path85 = __toESM(require("path"));
|
|
39756
39787
|
var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((resolve12) => {
|
|
39757
39788
|
(0, import_node_child_process28.execFile)(
|
|
39758
39789
|
file,
|
|
@@ -39802,7 +39833,7 @@ async function changedFiles(run3, cwd, from, to) {
|
|
|
39802
39833
|
}
|
|
39803
39834
|
function readWorkspaceFile(cwd, relPath) {
|
|
39804
39835
|
try {
|
|
39805
|
-
return
|
|
39836
|
+
return fs74.readFileSync(path85.join(cwd, relPath), "utf8");
|
|
39806
39837
|
} catch {
|
|
39807
39838
|
return null;
|
|
39808
39839
|
}
|
|
@@ -39811,14 +39842,14 @@ var NO_TEST_PLACEHOLDER = 'echo "Error: no test specified"';
|
|
|
39811
39842
|
var CHECKS_TIMEOUT_MS = 5 * 6e4;
|
|
39812
39843
|
function detectChecksCommand(cwd) {
|
|
39813
39844
|
try {
|
|
39814
|
-
const cfg = JSON.parse(
|
|
39845
|
+
const cfg = JSON.parse(fs74.readFileSync(path85.join(cwd, ".codeam", "pack.json"), "utf8"));
|
|
39815
39846
|
if (typeof cfg.checksCommand === "string" && cfg.checksCommand.trim().length > 0) {
|
|
39816
39847
|
return cfg.checksCommand.trim();
|
|
39817
39848
|
}
|
|
39818
39849
|
} catch {
|
|
39819
39850
|
}
|
|
39820
39851
|
try {
|
|
39821
|
-
const pkg = JSON.parse(
|
|
39852
|
+
const pkg = JSON.parse(fs74.readFileSync(path85.join(cwd, "package.json"), "utf8"));
|
|
39822
39853
|
const test = pkg.scripts?.test;
|
|
39823
39854
|
if (typeof test === "string" && test.trim().length > 0 && !test.includes(NO_TEST_PLACEHOLDER)) {
|
|
39824
39855
|
return "npm test";
|
|
@@ -39836,39 +39867,39 @@ ${res.stderr}`.trim();
|
|
|
39836
39867
|
}
|
|
39837
39868
|
|
|
39838
39869
|
// src/packs/run-store.ts
|
|
39839
|
-
var
|
|
39840
|
-
var
|
|
39870
|
+
var fs75 = __toESM(require("fs"));
|
|
39871
|
+
var path86 = __toESM(require("path"));
|
|
39841
39872
|
var crypto5 = __toESM(require("crypto"));
|
|
39842
39873
|
function packsDir(cwd) {
|
|
39843
|
-
return
|
|
39874
|
+
return path86.join(cwd, ".codeam", "packs");
|
|
39844
39875
|
}
|
|
39845
39876
|
function runDir(cwd, runId) {
|
|
39846
|
-
return
|
|
39877
|
+
return path86.join(packsDir(cwd), runId);
|
|
39847
39878
|
}
|
|
39848
39879
|
function newRunId() {
|
|
39849
39880
|
return `pk_${Date.now().toString(36)}_${crypto5.randomBytes(4).toString("hex")}`;
|
|
39850
39881
|
}
|
|
39851
39882
|
function writeJsonAtomic(file, value) {
|
|
39852
|
-
|
|
39883
|
+
fs75.mkdirSync(path86.dirname(file), { recursive: true });
|
|
39853
39884
|
const tmp = `${file}.tmp`;
|
|
39854
|
-
|
|
39855
|
-
|
|
39885
|
+
fs75.writeFileSync(tmp, JSON.stringify(value, null, 2));
|
|
39886
|
+
fs75.renameSync(tmp, file);
|
|
39856
39887
|
}
|
|
39857
39888
|
function saveRun(cwd, state) {
|
|
39858
|
-
writeJsonAtomic(
|
|
39889
|
+
writeJsonAtomic(path86.join(runDir(cwd, state.runId), "run.json"), state);
|
|
39859
39890
|
}
|
|
39860
39891
|
function saveStageHandoff(cwd, runId, stageIndex, role, handoff) {
|
|
39861
39892
|
const name = `${String(stageIndex + 1).padStart(2, "0")}-${role}.json`;
|
|
39862
|
-
writeJsonAtomic(
|
|
39893
|
+
writeJsonAtomic(path86.join(runDir(cwd, runId), name), handoff);
|
|
39863
39894
|
}
|
|
39864
39895
|
function loadLatestRun(cwd) {
|
|
39865
39896
|
try {
|
|
39866
39897
|
const dir = packsDir(cwd);
|
|
39867
|
-
const entries2 =
|
|
39898
|
+
const entries2 = fs75.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
39868
39899
|
for (let i = entries2.length - 1; i >= 0; i--) {
|
|
39869
|
-
const file =
|
|
39900
|
+
const file = path86.join(dir, entries2[i], "run.json");
|
|
39870
39901
|
try {
|
|
39871
|
-
const parsed = JSON.parse(
|
|
39902
|
+
const parsed = JSON.parse(fs75.readFileSync(file, "utf8"));
|
|
39872
39903
|
if (parsed && typeof parsed.runId === "string") return parsed;
|
|
39873
39904
|
} catch {
|
|
39874
39905
|
}
|
|
@@ -39879,17 +39910,17 @@ function loadLatestRun(cwd) {
|
|
|
39879
39910
|
}
|
|
39880
39911
|
function ensureLedgerIgnored(cwd) {
|
|
39881
39912
|
try {
|
|
39882
|
-
const gitDir =
|
|
39883
|
-
if (!
|
|
39884
|
-
const exclude =
|
|
39913
|
+
const gitDir = path86.join(cwd, ".git");
|
|
39914
|
+
if (!fs75.existsSync(gitDir)) return;
|
|
39915
|
+
const exclude = path86.join(gitDir, "info", "exclude");
|
|
39885
39916
|
let existing = "";
|
|
39886
39917
|
try {
|
|
39887
|
-
existing =
|
|
39918
|
+
existing = fs75.readFileSync(exclude, "utf8");
|
|
39888
39919
|
} catch {
|
|
39889
39920
|
}
|
|
39890
39921
|
if (existing.includes(".codeam/packs/")) return;
|
|
39891
|
-
|
|
39892
|
-
|
|
39922
|
+
fs75.mkdirSync(path86.dirname(exclude), { recursive: true });
|
|
39923
|
+
fs75.writeFileSync(exclude, `${existing.trimEnd()}
|
|
39893
39924
|
.codeam/packs/
|
|
39894
39925
|
`.trimStart());
|
|
39895
39926
|
} catch {
|
|
@@ -40667,10 +40698,10 @@ var packStatusH = async (ctx) => {
|
|
|
40667
40698
|
|
|
40668
40699
|
// src/integrations/manifest.ts
|
|
40669
40700
|
var import_node_fs16 = __toESM(require("fs"));
|
|
40670
|
-
var
|
|
40671
|
-
var
|
|
40701
|
+
var import_node_os14 = __toESM(require("os"));
|
|
40702
|
+
var import_node_path18 = __toESM(require("path"));
|
|
40672
40703
|
function integrationsManifestPath() {
|
|
40673
|
-
return
|
|
40704
|
+
return import_node_path18.default.join(import_node_os14.default.homedir(), ".codeam", "integrations.json");
|
|
40674
40705
|
}
|
|
40675
40706
|
function readIntegrationsManifest() {
|
|
40676
40707
|
try {
|
|
@@ -40684,7 +40715,7 @@ function readIntegrationsManifest() {
|
|
|
40684
40715
|
function persistIntegrationsManifest(m) {
|
|
40685
40716
|
try {
|
|
40686
40717
|
const file = integrationsManifestPath();
|
|
40687
|
-
import_node_fs16.default.mkdirSync(
|
|
40718
|
+
import_node_fs16.default.mkdirSync(import_node_path18.default.dirname(file), { recursive: true, mode: 448 });
|
|
40688
40719
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
40689
40720
|
import_node_fs16.default.writeFileSync(tmp, JSON.stringify(m, null, 2), { encoding: "utf8", mode: 384 });
|
|
40690
40721
|
import_node_fs16.default.renameSync(tmp, file);
|
|
@@ -40870,20 +40901,20 @@ async function mcpRouter() {
|
|
|
40870
40901
|
}
|
|
40871
40902
|
|
|
40872
40903
|
// src/integrations/mcp-secrets.ts
|
|
40873
|
-
var
|
|
40874
|
-
var
|
|
40875
|
-
var
|
|
40904
|
+
var fs77 = __toESM(require("fs"));
|
|
40905
|
+
var os56 = __toESM(require("os"));
|
|
40906
|
+
var path88 = __toESM(require("path"));
|
|
40876
40907
|
var MCP_SECRETS_FILE_ENV = "CODEAM_MCP_SECRETS_FILE";
|
|
40877
40908
|
function mcpSecretsDir() {
|
|
40878
|
-
return
|
|
40909
|
+
return path88.join(os56.homedir(), ".codeam", "mcp-secrets");
|
|
40879
40910
|
}
|
|
40880
40911
|
function mcpSecretsPath(scope, pid = process.pid) {
|
|
40881
|
-
return
|
|
40912
|
+
return path88.join(mcpSecretsDir(), `${pid}-${scope}.json`);
|
|
40882
40913
|
}
|
|
40883
40914
|
var registeredForCleanup = /* @__PURE__ */ new Set();
|
|
40884
40915
|
function readFileVars(file) {
|
|
40885
40916
|
try {
|
|
40886
|
-
const parsed = JSON.parse(
|
|
40917
|
+
const parsed = JSON.parse(fs77.readFileSync(file, "utf8"));
|
|
40887
40918
|
if (!parsed || typeof parsed !== "object") return {};
|
|
40888
40919
|
const out2 = {};
|
|
40889
40920
|
for (const [k2, v] of Object.entries(parsed)) {
|
|
@@ -40905,7 +40936,7 @@ function pidAlive2(pid) {
|
|
|
40905
40936
|
function pruneStale(dir) {
|
|
40906
40937
|
let names = [];
|
|
40907
40938
|
try {
|
|
40908
|
-
names =
|
|
40939
|
+
names = fs77.readdirSync(dir);
|
|
40909
40940
|
} catch {
|
|
40910
40941
|
return;
|
|
40911
40942
|
}
|
|
@@ -40915,25 +40946,25 @@ function pruneStale(dir) {
|
|
|
40915
40946
|
const pid = Number(m[1]);
|
|
40916
40947
|
if (pid === process.pid || pidAlive2(pid)) continue;
|
|
40917
40948
|
try {
|
|
40918
|
-
|
|
40949
|
+
fs77.unlinkSync(path88.join(dir, name));
|
|
40919
40950
|
} catch {
|
|
40920
40951
|
}
|
|
40921
40952
|
}
|
|
40922
40953
|
}
|
|
40923
40954
|
function writeMcpSecrets(vars, file) {
|
|
40924
40955
|
try {
|
|
40925
|
-
const dir =
|
|
40926
|
-
|
|
40956
|
+
const dir = path88.dirname(file);
|
|
40957
|
+
fs77.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
40927
40958
|
pruneStale(dir);
|
|
40928
40959
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
40929
|
-
|
|
40930
|
-
|
|
40931
|
-
|
|
40960
|
+
fs77.writeFileSync(tmp, JSON.stringify(vars), { mode: 384 });
|
|
40961
|
+
fs77.renameSync(tmp, file);
|
|
40962
|
+
fs77.chmodSync(file, 384);
|
|
40932
40963
|
if (!registeredForCleanup.has(file)) {
|
|
40933
40964
|
registeredForCleanup.add(file);
|
|
40934
40965
|
process.once("exit", () => {
|
|
40935
40966
|
try {
|
|
40936
|
-
|
|
40967
|
+
fs77.unlinkSync(file);
|
|
40937
40968
|
} catch {
|
|
40938
40969
|
}
|
|
40939
40970
|
});
|
|
@@ -41019,11 +41050,11 @@ function previewMcpServer(bridge) {
|
|
|
41019
41050
|
};
|
|
41020
41051
|
}
|
|
41021
41052
|
function httpCall(baseUrl, token) {
|
|
41022
|
-
return async (
|
|
41053
|
+
return async (path107, method, body, timeoutMs) => {
|
|
41023
41054
|
const ac = new AbortController();
|
|
41024
41055
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
41025
41056
|
try {
|
|
41026
|
-
const res = await fetch(`${baseUrl}${
|
|
41057
|
+
const res = await fetch(`${baseUrl}${path107}`, {
|
|
41027
41058
|
method,
|
|
41028
41059
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
41029
41060
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -41150,11 +41181,11 @@ function scratchMcpServer(bridge) {
|
|
|
41150
41181
|
};
|
|
41151
41182
|
}
|
|
41152
41183
|
function httpCall2(baseUrl, token) {
|
|
41153
|
-
return async (
|
|
41184
|
+
return async (path107, method, body, timeoutMs) => {
|
|
41154
41185
|
const ac = new AbortController();
|
|
41155
41186
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
41156
41187
|
try {
|
|
41157
|
-
const res = await fetch(`${baseUrl}${
|
|
41188
|
+
const res = await fetch(`${baseUrl}${path107}`, {
|
|
41158
41189
|
method,
|
|
41159
41190
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
41160
41191
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -41281,11 +41312,11 @@ function buildIntegrationMcpServers(ctx) {
|
|
|
41281
41312
|
|
|
41282
41313
|
// src/services/local-mcp-servers.ts
|
|
41283
41314
|
var import_node_fs17 = __toESM(require("fs"));
|
|
41284
|
-
var
|
|
41285
|
-
var
|
|
41315
|
+
var import_node_os15 = __toESM(require("os"));
|
|
41316
|
+
var import_node_path19 = __toESM(require("path"));
|
|
41286
41317
|
var MAX_LOCAL_MCP_SERVERS = 10;
|
|
41287
41318
|
function localMcpServersPath() {
|
|
41288
|
-
return
|
|
41319
|
+
return import_node_path19.default.join(import_node_os15.default.homedir(), ".codeam", "mcp-servers.json");
|
|
41289
41320
|
}
|
|
41290
41321
|
function isStringArray(v) {
|
|
41291
41322
|
return Array.isArray(v) && v.every((item) => typeof item === "string");
|
|
@@ -41393,14 +41424,14 @@ function mergeWithLocalMcpServers(integrationServers) {
|
|
|
41393
41424
|
|
|
41394
41425
|
// src/commands/start/agent-preview-bridge.ts
|
|
41395
41426
|
var http12 = __toESM(require("http"));
|
|
41396
|
-
var
|
|
41427
|
+
var import_node_crypto13 = require("crypto");
|
|
41397
41428
|
var START_WAIT_MS = 24e4;
|
|
41398
41429
|
var MAX_SELECTOR = 500;
|
|
41399
41430
|
var MAX_LABEL = 80;
|
|
41400
41431
|
var AgentPreviewBridge = class {
|
|
41401
41432
|
server = null;
|
|
41402
41433
|
listening = null;
|
|
41403
|
-
token = (0,
|
|
41434
|
+
token = (0, import_node_crypto13.randomBytes)(24).toString("hex");
|
|
41404
41435
|
ctx = null;
|
|
41405
41436
|
/** The bring-up in flight, so two tool calls never start two dev servers. */
|
|
41406
41437
|
inflight = null;
|
|
@@ -41666,7 +41697,7 @@ function overrideFrom(body) {
|
|
|
41666
41697
|
function authorized(header, token) {
|
|
41667
41698
|
const presented = Buffer.from((header ?? "").replace(/^Bearer\s+/i, ""));
|
|
41668
41699
|
const expected = Buffer.from(token);
|
|
41669
|
-
return presented.length === expected.length && (0,
|
|
41700
|
+
return presented.length === expected.length && (0, import_node_crypto13.timingSafeEqual)(presented, expected);
|
|
41670
41701
|
}
|
|
41671
41702
|
function readJson(req) {
|
|
41672
41703
|
return new Promise((resolve12, reject) => {
|
|
@@ -41695,10 +41726,10 @@ var agentPreviewBridge = new AgentPreviewBridge();
|
|
|
41695
41726
|
|
|
41696
41727
|
// src/integrations/detect-stack.ts
|
|
41697
41728
|
var import_node_fs18 = __toESM(require("fs"));
|
|
41698
|
-
var
|
|
41729
|
+
var import_node_path20 = __toESM(require("path"));
|
|
41699
41730
|
function readSafe(cwd, rel) {
|
|
41700
41731
|
try {
|
|
41701
|
-
return import_node_fs18.default.readFileSync(
|
|
41732
|
+
return import_node_fs18.default.readFileSync(import_node_path20.default.join(cwd, rel), "utf8");
|
|
41702
41733
|
} catch {
|
|
41703
41734
|
return "";
|
|
41704
41735
|
}
|
|
@@ -43478,7 +43509,7 @@ var AcpHistory = class {
|
|
|
43478
43509
|
this.summary = trimmed.length > 120 ? trimmed.slice(0, 117) + "\u2026" : trimmed;
|
|
43479
43510
|
}
|
|
43480
43511
|
this.messages.push({
|
|
43481
|
-
id: (0,
|
|
43512
|
+
id: (0, import_node_crypto14.randomUUID)(),
|
|
43482
43513
|
role: "user",
|
|
43483
43514
|
text,
|
|
43484
43515
|
timestamp: Date.now(),
|
|
@@ -43494,7 +43525,7 @@ var AcpHistory = class {
|
|
|
43494
43525
|
appendAgentReply(text, agentId = this.opts.agent) {
|
|
43495
43526
|
if (text.length === 0) return;
|
|
43496
43527
|
this.messages.push({
|
|
43497
|
-
id: (0,
|
|
43528
|
+
id: (0, import_node_crypto14.randomUUID)(),
|
|
43498
43529
|
role: "agent",
|
|
43499
43530
|
text,
|
|
43500
43531
|
timestamp: Date.now(),
|
|
@@ -43604,8 +43635,10 @@ function computeAdapterExtraEnv(params) {
|
|
|
43604
43635
|
);
|
|
43605
43636
|
return env;
|
|
43606
43637
|
}
|
|
43607
|
-
function pickLatestResumableConversation(sessions3, currentId) {
|
|
43608
|
-
const
|
|
43638
|
+
function pickLatestResumableConversation(sessions3, currentId, marked) {
|
|
43639
|
+
const listed = (sessions3 ?? []).filter((s) => s.id !== currentId);
|
|
43640
|
+
if (marked) return listed.some((s) => s.id === marked) ? marked : null;
|
|
43641
|
+
const prior = listed.sort((a, b) => b.timestamp - a.timestamp)[0];
|
|
43609
43642
|
return prior?.id ?? null;
|
|
43610
43643
|
}
|
|
43611
43644
|
async function runAcpSession(opts) {
|
|
@@ -43755,17 +43788,31 @@ async function runAcpSession(opts) {
|
|
|
43755
43788
|
let resumedPriorConversation = false;
|
|
43756
43789
|
if (process.env.CODEAM_RESUME_LATEST === "1") {
|
|
43757
43790
|
try {
|
|
43758
|
-
const
|
|
43791
|
+
const marked = await readActiveConversationMarker(opts.cwd);
|
|
43792
|
+
const priorId = pickLatestResumableConversation(
|
|
43793
|
+
await client3.listSessions(),
|
|
43794
|
+
acpSessionId,
|
|
43795
|
+
marked
|
|
43796
|
+
);
|
|
43759
43797
|
if (priorId) {
|
|
43760
43798
|
await client3.loadSession(priorId);
|
|
43761
43799
|
acpSessionId = priorId;
|
|
43762
43800
|
resumedPriorConversation = true;
|
|
43763
|
-
log.info(
|
|
43801
|
+
log.info(
|
|
43802
|
+
"acpRunner",
|
|
43803
|
+
`auto-resumed ${marked === priorId ? "marked" : "latest"} conversation ${priorId.slice(0, 8)}`
|
|
43804
|
+
);
|
|
43805
|
+
} else if (marked) {
|
|
43806
|
+
log.info(
|
|
43807
|
+
"acpRunner",
|
|
43808
|
+
`marked conversation ${marked.slice(0, 8)} has no transcript \u2014 fresh session`
|
|
43809
|
+
);
|
|
43764
43810
|
}
|
|
43765
43811
|
} catch (err) {
|
|
43766
43812
|
log.trace("acpRunner", "auto-resume-latest failed (best-effort)", err);
|
|
43767
43813
|
}
|
|
43768
43814
|
}
|
|
43815
|
+
void writeActiveConversationMarker(opts.cwd, acpSessionId);
|
|
43769
43816
|
showSuccess(`${opts.agent} online (ACP) \u2014 awaiting prompts from mobile.`);
|
|
43770
43817
|
showRelayNotice();
|
|
43771
43818
|
void publisher.publishOutput({
|
|
@@ -43880,6 +43927,7 @@ async function runAcpSession(opts) {
|
|
|
43880
43927
|
// conversation" fix).
|
|
43881
43928
|
(id) => {
|
|
43882
43929
|
acpSessionId = id;
|
|
43930
|
+
void writeActiveConversationMarker(opts.cwd, id);
|
|
43883
43931
|
},
|
|
43884
43932
|
switchAgentForSession,
|
|
43885
43933
|
pendingHandoff,
|
|
@@ -43967,6 +44015,7 @@ async function runAcpSession(opts) {
|
|
|
43967
44015
|
opts.agent = nextAgent;
|
|
43968
44016
|
opts.adapter = adapter;
|
|
43969
44017
|
acpSessionId = hs.sessionId;
|
|
44018
|
+
void writeActiveConversationMarker(opts.cwd, acpSessionId);
|
|
43970
44019
|
agentCaps = hs.initialize.agentCapabilities;
|
|
43971
44020
|
runtime = createInteractiveAgentStrategy(nextAgent, createOsStrategy());
|
|
43972
44021
|
history = new AcpHistory(publisher, {
|
|
@@ -43983,7 +44032,10 @@ async function runAcpSession(opts) {
|
|
|
43983
44032
|
if (swapOpts.house) {
|
|
43984
44033
|
houseWireId = swapOpts.wireId ?? HOUSE_AGENT_ID;
|
|
43985
44034
|
if (pendingHouseConfig) {
|
|
43986
|
-
persistHouseProxyConfig(
|
|
44035
|
+
persistHouseProxyConfig(
|
|
44036
|
+
pendingHouseConfig,
|
|
44037
|
+
deployIdFromWorkspace(process.cwd()) ?? void 0
|
|
44038
|
+
);
|
|
43987
44039
|
pendingHouseConfig = null;
|
|
43988
44040
|
}
|
|
43989
44041
|
} else if (wasHouse) {
|
|
@@ -44026,17 +44078,17 @@ async function runAcpSession(opts) {
|
|
|
44026
44078
|
switchCredentialEnv = provisionAgentCredentials(agentId, auth);
|
|
44027
44079
|
},
|
|
44028
44080
|
provisionHouseProxy: ({ baseUrl, token, model, managedAgentId }) => {
|
|
44029
|
-
const claudeConfigDir2 =
|
|
44030
|
-
|
|
44081
|
+
const claudeConfigDir2 = path91.join(
|
|
44082
|
+
os58.homedir(),
|
|
44031
44083
|
".codeam",
|
|
44032
44084
|
"house-claude",
|
|
44033
44085
|
`switch-${opts.pluginId}`
|
|
44034
44086
|
);
|
|
44035
44087
|
try {
|
|
44036
|
-
|
|
44088
|
+
fs80.mkdirSync(claudeConfigDir2, { recursive: true, mode: 448 });
|
|
44037
44089
|
} catch {
|
|
44038
44090
|
}
|
|
44039
|
-
const memoryFile =
|
|
44091
|
+
const memoryFile = path91.join(claudeConfigDir2, "CLAUDE.md");
|
|
44040
44092
|
ensureBeadsWorkflowHint(void 0, memoryFile);
|
|
44041
44093
|
ensureAgentStandard(void 0, memoryFile);
|
|
44042
44094
|
const cfg = {
|
|
@@ -44096,6 +44148,7 @@ async function runAcpSession(opts) {
|
|
|
44096
44148
|
try {
|
|
44097
44149
|
await client3.loadSession(m.acpSessionId);
|
|
44098
44150
|
acpSessionId = m.acpSessionId;
|
|
44151
|
+
void writeActiveConversationMarker(opts.cwd, acpSessionId);
|
|
44099
44152
|
history.switchActiveSession(m.acpSessionId);
|
|
44100
44153
|
pendingHandoff.current = null;
|
|
44101
44154
|
log.info(
|
|
@@ -45252,7 +45305,7 @@ function startClaudeCredentialSync(opts) {
|
|
|
45252
45305
|
|
|
45253
45306
|
// src/scratch/workflow-hint.ts
|
|
45254
45307
|
var import_node_fs19 = __toESM(require("fs"));
|
|
45255
|
-
var
|
|
45308
|
+
var import_node_path21 = __toESM(require("path"));
|
|
45256
45309
|
var SCRATCH_HINT_MARKER = "<!-- codeam:scratch-workflow -->";
|
|
45257
45310
|
var SCRATCH_HINT = `${SCRATCH_HINT_MARKER}
|
|
45258
45311
|
# From-scratch projects (CodeAgent Box)
|
|
@@ -45276,7 +45329,7 @@ function ensureScratchWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2))
|
|
|
45276
45329
|
} catch {
|
|
45277
45330
|
}
|
|
45278
45331
|
if (existing.includes(SCRATCH_HINT)) return;
|
|
45279
|
-
import_node_fs19.default.mkdirSync(
|
|
45332
|
+
import_node_fs19.default.mkdirSync(import_node_path21.default.dirname(file), { recursive: true });
|
|
45280
45333
|
const open = existing.indexOf(SCRATCH_HINT_MARKER);
|
|
45281
45334
|
const close = open === -1 ? -1 : existing.indexOf(SCRATCH_HINT_MARKER, open + SCRATCH_HINT_MARKER.length);
|
|
45282
45335
|
const next = open !== -1 && close !== -1 ? existing.slice(0, open) + SCRATCH_HINT + existing.slice(close + SCRATCH_HINT_MARKER.length) : existing.trim() ? `${existing.trimEnd()}
|
|
@@ -45304,9 +45357,9 @@ function pickPinnedSession(pinnedId, listSessions2) {
|
|
|
45304
45357
|
}
|
|
45305
45358
|
|
|
45306
45359
|
// src/agents/retired-proxy-cleanup.ts
|
|
45307
|
-
var
|
|
45308
|
-
var
|
|
45309
|
-
var
|
|
45360
|
+
var fs82 = __toESM(require("fs"));
|
|
45361
|
+
var path93 = __toESM(require("path"));
|
|
45362
|
+
var os59 = __toESM(require("os"));
|
|
45310
45363
|
var RETIRED_PROXY_RE = /^https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):8787(?:[/?#]|$)/i;
|
|
45311
45364
|
var HEADROOM_CMD_RE = /(^|[\s/"'])headroom(\s|$)/i;
|
|
45312
45365
|
var MARKETPLACE_KEY = "headroom-marketplace";
|
|
@@ -45315,12 +45368,12 @@ function isHeadroomHook(group) {
|
|
|
45315
45368
|
(h) => typeof h?.command === "string" && HEADROOM_CMD_RE.test(h.command)
|
|
45316
45369
|
);
|
|
45317
45370
|
}
|
|
45318
|
-
function sanitizeRetiredProxyConfig(homeDir2 =
|
|
45371
|
+
function sanitizeRetiredProxyConfig(homeDir2 = os59.homedir()) {
|
|
45319
45372
|
const out2 = { inspected: false, changed: false, removed: [] };
|
|
45320
|
-
const file =
|
|
45373
|
+
const file = path93.join(homeDir2, ".claude", "settings.json");
|
|
45321
45374
|
let parsed;
|
|
45322
45375
|
try {
|
|
45323
|
-
parsed = JSON.parse(
|
|
45376
|
+
parsed = JSON.parse(fs82.readFileSync(file, "utf8"));
|
|
45324
45377
|
} catch {
|
|
45325
45378
|
return out2;
|
|
45326
45379
|
}
|
|
@@ -45362,9 +45415,9 @@ function sanitizeRetiredProxyConfig(homeDir2 = os58.homedir()) {
|
|
|
45362
45415
|
if (!out2.changed) return out2;
|
|
45363
45416
|
try {
|
|
45364
45417
|
const tmp = `${file}.codeam.tmp`;
|
|
45365
|
-
|
|
45418
|
+
fs82.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
|
|
45366
45419
|
`, { mode: 384 });
|
|
45367
|
-
|
|
45420
|
+
fs82.renameSync(tmp, file);
|
|
45368
45421
|
} catch {
|
|
45369
45422
|
out2.changed = false;
|
|
45370
45423
|
}
|
|
@@ -45420,8 +45473,8 @@ async function refreshIntegrationsManifest(ctx, fetchImpl = fetch, timeoutMs = 8
|
|
|
45420
45473
|
}
|
|
45421
45474
|
|
|
45422
45475
|
// src/skills/provision.ts
|
|
45423
|
-
var
|
|
45424
|
-
function provisionSkillsForStart(home =
|
|
45476
|
+
var import_node_os16 = __toESM(require("os"));
|
|
45477
|
+
function provisionSkillsForStart(home = import_node_os16.default.homedir()) {
|
|
45425
45478
|
const materialized = [];
|
|
45426
45479
|
try {
|
|
45427
45480
|
const manifest = readSkillsManifest();
|
|
@@ -45896,7 +45949,7 @@ var AcpDriver = class {
|
|
|
45896
45949
|
};
|
|
45897
45950
|
|
|
45898
45951
|
// src/baton/transcript-mirror.ts
|
|
45899
|
-
var
|
|
45952
|
+
var fs83 = __toESM(require("fs"));
|
|
45900
45953
|
var TranscriptMirror = class {
|
|
45901
45954
|
constructor(deps) {
|
|
45902
45955
|
this.deps = deps;
|
|
@@ -45990,7 +46043,7 @@ var TranscriptMirror = class {
|
|
|
45990
46043
|
}
|
|
45991
46044
|
};
|
|
45992
46045
|
function defaultWatch(file, onChange) {
|
|
45993
|
-
const w3 =
|
|
46046
|
+
const w3 = fs83.watch(file, { persistent: false }, () => onChange());
|
|
45994
46047
|
return () => w3.close();
|
|
45995
46048
|
}
|
|
45996
46049
|
|
|
@@ -46336,16 +46389,16 @@ function keepDeviceAwake(deps = {}) {
|
|
|
46336
46389
|
}
|
|
46337
46390
|
|
|
46338
46391
|
// src/agents/claude/onboarding.ts
|
|
46339
|
-
var
|
|
46340
|
-
var
|
|
46341
|
-
var
|
|
46392
|
+
var fs84 = __toESM(require("fs"));
|
|
46393
|
+
var os61 = __toESM(require("os"));
|
|
46394
|
+
var path94 = __toESM(require("path"));
|
|
46342
46395
|
var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
|
|
46343
46396
|
function ensureClaudeOnboarded(cwd) {
|
|
46344
46397
|
try {
|
|
46345
|
-
const file =
|
|
46398
|
+
const file = path94.join(os61.homedir(), ".claude.json");
|
|
46346
46399
|
let config = {};
|
|
46347
46400
|
try {
|
|
46348
|
-
config = JSON.parse(
|
|
46401
|
+
config = JSON.parse(fs84.readFileSync(file, "utf8"));
|
|
46349
46402
|
} catch {
|
|
46350
46403
|
}
|
|
46351
46404
|
let changed = false;
|
|
@@ -46370,8 +46423,8 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
46370
46423
|
}
|
|
46371
46424
|
}
|
|
46372
46425
|
if (!changed) return;
|
|
46373
|
-
|
|
46374
|
-
|
|
46426
|
+
fs84.mkdirSync(path94.dirname(file), { recursive: true });
|
|
46427
|
+
fs84.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
46375
46428
|
log.info(
|
|
46376
46429
|
"claude",
|
|
46377
46430
|
`pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
|
|
@@ -47163,7 +47216,7 @@ var import_picocolors10 = __toESM(require("picocolors"));
|
|
|
47163
47216
|
var import_child_process30 = require("child_process");
|
|
47164
47217
|
var import_util4 = require("util");
|
|
47165
47218
|
var import_picocolors8 = __toESM(require("picocolors"));
|
|
47166
|
-
var
|
|
47219
|
+
var path95 = __toESM(require("path"));
|
|
47167
47220
|
var execFileP6 = (0, import_util4.promisify)(import_child_process30.execFile);
|
|
47168
47221
|
var MAX_BUFFER = 8 * 1024 * 1024;
|
|
47169
47222
|
function resetStdinForChild() {
|
|
@@ -47652,7 +47705,7 @@ var GitHubCodespacesProvider = class {
|
|
|
47652
47705
|
});
|
|
47653
47706
|
}
|
|
47654
47707
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
47655
|
-
const remoteDir =
|
|
47708
|
+
const remoteDir = path95.posix.dirname(remotePath);
|
|
47656
47709
|
const parts = [
|
|
47657
47710
|
`mkdir -p ${shellQuote(remoteDir)}`,
|
|
47658
47711
|
`cat > ${shellQuote(remotePath)}`
|
|
@@ -47722,7 +47775,7 @@ function shellQuote(s) {
|
|
|
47722
47775
|
// src/services/providers/gitpod.ts
|
|
47723
47776
|
var import_child_process31 = require("child_process");
|
|
47724
47777
|
var import_util5 = require("util");
|
|
47725
|
-
var
|
|
47778
|
+
var path96 = __toESM(require("path"));
|
|
47726
47779
|
var import_picocolors9 = __toESM(require("picocolors"));
|
|
47727
47780
|
var execFileP7 = (0, import_util5.promisify)(import_child_process31.execFile);
|
|
47728
47781
|
var MAX_BUFFER2 = 8 * 1024 * 1024;
|
|
@@ -47962,7 +48015,7 @@ var GitpodProvider = class {
|
|
|
47962
48015
|
});
|
|
47963
48016
|
}
|
|
47964
48017
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
47965
|
-
const remoteDir =
|
|
48018
|
+
const remoteDir = path96.posix.dirname(remotePath);
|
|
47966
48019
|
const parts = [
|
|
47967
48020
|
`mkdir -p ${shellQuote2(remoteDir)}`,
|
|
47968
48021
|
`cat > ${shellQuote2(remotePath)}`
|
|
@@ -47998,7 +48051,7 @@ function shellQuote2(s) {
|
|
|
47998
48051
|
// src/services/providers/gitlab-workspaces.ts
|
|
47999
48052
|
var import_child_process32 = require("child_process");
|
|
48000
48053
|
var import_util6 = require("util");
|
|
48001
|
-
var
|
|
48054
|
+
var path97 = __toESM(require("path"));
|
|
48002
48055
|
var execFileP8 = (0, import_util6.promisify)(import_child_process32.execFile);
|
|
48003
48056
|
var MAX_BUFFER3 = 8 * 1024 * 1024;
|
|
48004
48057
|
var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
|
|
@@ -48258,7 +48311,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48258
48311
|
}
|
|
48259
48312
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
48260
48313
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
48261
|
-
const remoteDir =
|
|
48314
|
+
const remoteDir = path97.posix.dirname(remotePath);
|
|
48262
48315
|
const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
|
|
48263
48316
|
if (options.mode != null) {
|
|
48264
48317
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
@@ -48326,7 +48379,7 @@ function shellQuote3(s) {
|
|
|
48326
48379
|
// src/services/providers/railway.ts
|
|
48327
48380
|
var import_child_process33 = require("child_process");
|
|
48328
48381
|
var import_util7 = require("util");
|
|
48329
|
-
var
|
|
48382
|
+
var path98 = __toESM(require("path"));
|
|
48330
48383
|
var execFileP9 = (0, import_util7.promisify)(import_child_process33.execFile);
|
|
48331
48384
|
var MAX_BUFFER4 = 8 * 1024 * 1024;
|
|
48332
48385
|
function resetStdinForChild4() {
|
|
@@ -48562,7 +48615,7 @@ var RailwayProvider = class {
|
|
|
48562
48615
|
if (!projectId || !serviceId) {
|
|
48563
48616
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
48564
48617
|
}
|
|
48565
|
-
const remoteDir =
|
|
48618
|
+
const remoteDir = path98.posix.dirname(remotePath);
|
|
48566
48619
|
const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
|
|
48567
48620
|
if (options.mode != null) {
|
|
48568
48621
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
@@ -49102,14 +49155,14 @@ async function stopWorkspaceFromLocal(target) {
|
|
|
49102
49155
|
}
|
|
49103
49156
|
|
|
49104
49157
|
// src/commands/host/host-client.ts
|
|
49105
|
-
var
|
|
49106
|
-
var
|
|
49107
|
-
var
|
|
49108
|
-
var
|
|
49158
|
+
var fs85 = __toESM(require("fs"));
|
|
49159
|
+
var os62 = __toESM(require("os"));
|
|
49160
|
+
var path99 = __toESM(require("path"));
|
|
49161
|
+
var import_node_crypto15 = require("crypto");
|
|
49109
49162
|
function sampleCpuTimes() {
|
|
49110
49163
|
let idle = 0;
|
|
49111
49164
|
let total = 0;
|
|
49112
|
-
for (const cpu of
|
|
49165
|
+
for (const cpu of os62.cpus()) {
|
|
49113
49166
|
const t2 = cpu.times;
|
|
49114
49167
|
idle += t2.idle;
|
|
49115
49168
|
total += t2.user + t2.nice + t2.sys + t2.idle + t2.irq;
|
|
@@ -49129,8 +49182,8 @@ var MetricsCollector = class {
|
|
|
49129
49182
|
const prev = this.prevCpu;
|
|
49130
49183
|
this.prevCpu = current2;
|
|
49131
49184
|
if (!prev) {
|
|
49132
|
-
const cores =
|
|
49133
|
-
const proxy =
|
|
49185
|
+
const cores = os62.cpus().length || 1;
|
|
49186
|
+
const proxy = os62.loadavg()[0] / cores * 100;
|
|
49134
49187
|
return Math.min(100, Math.max(0, Math.round(proxy)));
|
|
49135
49188
|
}
|
|
49136
49189
|
const idleDelta = current2.idle - prev.idle;
|
|
@@ -49143,8 +49196,8 @@ var MetricsCollector = class {
|
|
|
49143
49196
|
collect() {
|
|
49144
49197
|
return {
|
|
49145
49198
|
cpuPct: this.cpuPct(),
|
|
49146
|
-
ramUsedMb: Math.round((
|
|
49147
|
-
ramTotalMb: Math.round(
|
|
49199
|
+
ramUsedMb: Math.round((os62.totalmem() - os62.freemem()) / 1048576),
|
|
49200
|
+
ramTotalMb: Math.round(os62.totalmem() / 1048576),
|
|
49148
49201
|
latencyMs: this.lastLatencyMs
|
|
49149
49202
|
};
|
|
49150
49203
|
}
|
|
@@ -49153,19 +49206,19 @@ function apiBase() {
|
|
|
49153
49206
|
return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
|
|
49154
49207
|
}
|
|
49155
49208
|
function hostIdentityPath() {
|
|
49156
|
-
return
|
|
49209
|
+
return path99.join(os62.homedir(), ".codeam", "host-agent.json");
|
|
49157
49210
|
}
|
|
49158
49211
|
function collectOsInfo() {
|
|
49159
49212
|
return {
|
|
49160
|
-
distro:
|
|
49161
|
-
arch:
|
|
49162
|
-
kernel:
|
|
49213
|
+
distro: os62.platform(),
|
|
49214
|
+
arch: os62.arch(),
|
|
49215
|
+
kernel: os62.release(),
|
|
49163
49216
|
nodeVersion: process.versions.node
|
|
49164
49217
|
};
|
|
49165
49218
|
}
|
|
49166
49219
|
function loadHostIdentity() {
|
|
49167
49220
|
try {
|
|
49168
|
-
const raw =
|
|
49221
|
+
const raw = fs85.readFileSync(hostIdentityPath(), "utf8");
|
|
49169
49222
|
const parsed = JSON.parse(raw);
|
|
49170
49223
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
|
|
49171
49224
|
const p2 = parsed;
|
|
@@ -49183,18 +49236,18 @@ function loadHostIdentity() {
|
|
|
49183
49236
|
}
|
|
49184
49237
|
}
|
|
49185
49238
|
function pollSecretHash(secret) {
|
|
49186
|
-
return (0,
|
|
49239
|
+
return (0, import_node_crypto15.createHash)("sha256").update(secret).digest("hex");
|
|
49187
49240
|
}
|
|
49188
49241
|
function ensureControlPollSecret(identity, save = saveHostIdentity) {
|
|
49189
49242
|
if (!identity || identity.controlPollSecret) return identity;
|
|
49190
|
-
const upgraded = { ...identity, controlPollSecret: (0,
|
|
49243
|
+
const upgraded = { ...identity, controlPollSecret: (0, import_node_crypto15.randomBytes)(32).toString("base64url") };
|
|
49191
49244
|
save(upgraded);
|
|
49192
49245
|
return upgraded;
|
|
49193
49246
|
}
|
|
49194
49247
|
function saveHostIdentity(identity) {
|
|
49195
49248
|
const file = hostIdentityPath();
|
|
49196
|
-
|
|
49197
|
-
|
|
49249
|
+
fs85.mkdirSync(path99.dirname(file), { recursive: true, mode: 448 });
|
|
49250
|
+
fs85.writeFileSync(file, JSON.stringify(identity, null, 2), {
|
|
49198
49251
|
encoding: "utf8",
|
|
49199
49252
|
mode: 384
|
|
49200
49253
|
});
|
|
@@ -49239,7 +49292,7 @@ function isTerminalEnrollError(err) {
|
|
|
49239
49292
|
}
|
|
49240
49293
|
function deleteHostIdentity() {
|
|
49241
49294
|
try {
|
|
49242
|
-
|
|
49295
|
+
fs85.rmSync(hostIdentityPath(), { force: true });
|
|
49243
49296
|
} catch {
|
|
49244
49297
|
}
|
|
49245
49298
|
}
|
|
@@ -49263,12 +49316,12 @@ async function postJson(pathname, body) {
|
|
|
49263
49316
|
function resolveHostLabel(label) {
|
|
49264
49317
|
const explicit = label?.trim();
|
|
49265
49318
|
const envLabel = process.env.CODEAM_HOST_LABEL?.trim();
|
|
49266
|
-
const resolved = explicit || envLabel ||
|
|
49319
|
+
const resolved = explicit || envLabel || os62.hostname();
|
|
49267
49320
|
return resolved.slice(0, 80);
|
|
49268
49321
|
}
|
|
49269
49322
|
async function redeemEnrollToken(token, label) {
|
|
49270
|
-
const controlPollSecret = (0,
|
|
49271
|
-
const pluginSecretHash = (0,
|
|
49323
|
+
const controlPollSecret = (0, import_node_crypto15.randomBytes)(32).toString("base64url");
|
|
49324
|
+
const pluginSecretHash = (0, import_node_crypto15.createHash)("sha256").update(controlPollSecret).digest("hex");
|
|
49272
49325
|
const data = await postJson("/api/self-hosted/redeem", {
|
|
49273
49326
|
token,
|
|
49274
49327
|
label: resolveHostLabel(label),
|
|
@@ -49456,9 +49509,9 @@ async function host(args2) {
|
|
|
49456
49509
|
|
|
49457
49510
|
// src/commands/host-agent.ts
|
|
49458
49511
|
var import_node_child_process35 = require("child_process");
|
|
49459
|
-
var
|
|
49460
|
-
var
|
|
49461
|
-
var
|
|
49512
|
+
var os66 = __toESM(require("os"));
|
|
49513
|
+
var fs89 = __toESM(require("fs"));
|
|
49514
|
+
var path103 = __toESM(require("path"));
|
|
49462
49515
|
|
|
49463
49516
|
// src/skills/persist-from-payload.ts
|
|
49464
49517
|
function persistOrClearSkillsFromPayload(skills) {
|
|
@@ -49467,13 +49520,13 @@ function persistOrClearSkillsFromPayload(skills) {
|
|
|
49467
49520
|
}
|
|
49468
49521
|
|
|
49469
49522
|
// src/commands/host/session-state.ts
|
|
49470
|
-
var
|
|
49471
|
-
var
|
|
49472
|
-
var
|
|
49523
|
+
var fs86 = __toESM(require("fs"));
|
|
49524
|
+
var os63 = __toESM(require("os"));
|
|
49525
|
+
var path100 = __toESM(require("path"));
|
|
49473
49526
|
function hostSessionStatePath(env = process.env) {
|
|
49474
49527
|
const override = env.CODEAM_HOST_SESSION_STATE_FILE;
|
|
49475
49528
|
if (override && override.trim()) return override.trim();
|
|
49476
|
-
return
|
|
49529
|
+
return path100.join(os63.homedir(), ".codeam", "host-agent-sessions.json");
|
|
49477
49530
|
}
|
|
49478
49531
|
function isRecord5(v) {
|
|
49479
49532
|
if (typeof v !== "object" || v === null) return false;
|
|
@@ -49484,7 +49537,7 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
49484
49537
|
return {
|
|
49485
49538
|
load() {
|
|
49486
49539
|
try {
|
|
49487
|
-
const raw = JSON.parse(
|
|
49540
|
+
const raw = JSON.parse(fs86.readFileSync(file, "utf8"));
|
|
49488
49541
|
return Array.isArray(raw?.sessions) ? raw.sessions.filter(isRecord5) : null;
|
|
49489
49542
|
} catch {
|
|
49490
49543
|
return null;
|
|
@@ -49492,18 +49545,18 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
49492
49545
|
},
|
|
49493
49546
|
save(list) {
|
|
49494
49547
|
try {
|
|
49495
|
-
|
|
49548
|
+
fs86.mkdirSync(path100.dirname(file), { recursive: true, mode: 448 });
|
|
49496
49549
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
49497
|
-
|
|
49550
|
+
fs86.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
|
|
49498
49551
|
mode: 384
|
|
49499
49552
|
});
|
|
49500
|
-
|
|
49553
|
+
fs86.renameSync(tmp, file);
|
|
49501
49554
|
} catch {
|
|
49502
49555
|
}
|
|
49503
49556
|
},
|
|
49504
49557
|
clear() {
|
|
49505
49558
|
try {
|
|
49506
|
-
|
|
49559
|
+
fs86.rmSync(file, { force: true });
|
|
49507
49560
|
} catch {
|
|
49508
49561
|
}
|
|
49509
49562
|
}
|
|
@@ -49526,10 +49579,10 @@ function planSessionResume(records, max) {
|
|
|
49526
49579
|
return { resume: ordered.slice(0, bound), dropped: ordered.slice(bound) };
|
|
49527
49580
|
}
|
|
49528
49581
|
function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
49529
|
-
const target =
|
|
49582
|
+
const target = path100.resolve(cwd);
|
|
49530
49583
|
const reconnectable = (s) => !!s.pluginId && !!s.pollSecret && !!s.agent;
|
|
49531
49584
|
const matches = sessions3.filter(
|
|
49532
|
-
(s) => !!s.cwd &&
|
|
49585
|
+
(s) => !!s.cwd && path100.resolve(s.cwd) === target && reconnectable(s)
|
|
49533
49586
|
);
|
|
49534
49587
|
if (matches.length > 0) {
|
|
49535
49588
|
matches.sort((a, b) => b.pairedAt - a.pairedAt);
|
|
@@ -49541,11 +49594,11 @@ function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
|
49541
49594
|
|
|
49542
49595
|
// src/commands/host/git-tooling.ts
|
|
49543
49596
|
var import_node_child_process31 = require("child_process");
|
|
49544
|
-
var
|
|
49545
|
-
var
|
|
49546
|
-
var
|
|
49597
|
+
var fs87 = __toESM(require("fs"));
|
|
49598
|
+
var os64 = __toESM(require("os"));
|
|
49599
|
+
var path101 = __toESM(require("path"));
|
|
49547
49600
|
function codeamBinDir() {
|
|
49548
|
-
return process.env.CODEAM_BIN_DIR ??
|
|
49601
|
+
return process.env.CODEAM_BIN_DIR ?? path101.join(os64.homedir(), ".codeam", "bin");
|
|
49549
49602
|
}
|
|
49550
49603
|
var FALLBACK_GH_VERSION = "2.62.0";
|
|
49551
49604
|
var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
|
|
@@ -49577,7 +49630,7 @@ async function download(url2, dest) {
|
|
|
49577
49630
|
const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
|
|
49578
49631
|
if (!res.ok || !res.body) return false;
|
|
49579
49632
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
49580
|
-
|
|
49633
|
+
fs87.writeFileSync(dest, buf);
|
|
49581
49634
|
return true;
|
|
49582
49635
|
} catch {
|
|
49583
49636
|
return false;
|
|
@@ -49600,8 +49653,8 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
49600
49653
|
const version3 = await resolveVersionFn(token);
|
|
49601
49654
|
const asset = `gh_${version3}_${osToken}_${arch2}`;
|
|
49602
49655
|
const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
|
|
49603
|
-
const tmpRoot =
|
|
49604
|
-
const archive =
|
|
49656
|
+
const tmpRoot = fs87.mkdtempSync(path101.join(os64.tmpdir(), "codeam-gh-"));
|
|
49657
|
+
const archive = path101.join(tmpRoot, `${asset}.${ext}`);
|
|
49605
49658
|
if (!await downloadFn(url2, archive)) {
|
|
49606
49659
|
log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
|
|
49607
49660
|
return null;
|
|
@@ -49611,16 +49664,16 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
49611
49664
|
log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
|
|
49612
49665
|
return null;
|
|
49613
49666
|
}
|
|
49614
|
-
const extractedBin =
|
|
49615
|
-
if (!
|
|
49667
|
+
const extractedBin = path101.join(tmpRoot, asset, "bin", binaryName);
|
|
49668
|
+
if (!fs87.existsSync(extractedBin)) {
|
|
49616
49669
|
log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
|
|
49617
49670
|
return null;
|
|
49618
49671
|
}
|
|
49619
49672
|
const binDir = codeamBinDir();
|
|
49620
|
-
|
|
49621
|
-
const target =
|
|
49622
|
-
|
|
49623
|
-
|
|
49673
|
+
fs87.mkdirSync(binDir, { recursive: true });
|
|
49674
|
+
const target = path101.join(binDir, binaryName);
|
|
49675
|
+
fs87.copyFileSync(extractedBin, target);
|
|
49676
|
+
fs87.chmodSync(target, 493);
|
|
49624
49677
|
log.info("host-agent", `gh installed to ${target} (v${version3})`);
|
|
49625
49678
|
return target;
|
|
49626
49679
|
} catch (e) {
|
|
@@ -49657,19 +49710,19 @@ async function ensureGhAuth(runner, ghCmd, token) {
|
|
|
49657
49710
|
}
|
|
49658
49711
|
function ghConfigDir() {
|
|
49659
49712
|
if (process.env.GH_CONFIG_DIR) return process.env.GH_CONFIG_DIR;
|
|
49660
|
-
if (process.env.XDG_CONFIG_HOME) return
|
|
49713
|
+
if (process.env.XDG_CONFIG_HOME) return path101.join(process.env.XDG_CONFIG_HOME, "gh");
|
|
49661
49714
|
if (process.platform === "win32" && process.env.APPDATA) {
|
|
49662
|
-
return
|
|
49715
|
+
return path101.join(process.env.APPDATA, "GitHub CLI");
|
|
49663
49716
|
}
|
|
49664
|
-
return
|
|
49717
|
+
return path101.join(os64.homedir(), ".config", "gh");
|
|
49665
49718
|
}
|
|
49666
49719
|
function writeGhHostsToken(token) {
|
|
49667
49720
|
try {
|
|
49668
49721
|
const dir = ghConfigDir();
|
|
49669
|
-
const file =
|
|
49670
|
-
if (
|
|
49671
|
-
|
|
49672
|
-
|
|
49722
|
+
const file = path101.join(dir, "hosts.yml");
|
|
49723
|
+
if (fs87.existsSync(file)) return false;
|
|
49724
|
+
fs87.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
49725
|
+
fs87.writeFileSync(
|
|
49673
49726
|
file,
|
|
49674
49727
|
`github.com:
|
|
49675
49728
|
oauth_token: ${token}
|
|
@@ -49712,8 +49765,8 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
49712
49765
|
const version3 = await resolveLatestGlabVersion();
|
|
49713
49766
|
const asset = `glab_${version3}_${osToken}_${arch2}`;
|
|
49714
49767
|
const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
|
|
49715
|
-
const tmpRoot =
|
|
49716
|
-
const archive =
|
|
49768
|
+
const tmpRoot = fs87.mkdtempSync(path101.join(os64.tmpdir(), "codeam-glab-"));
|
|
49769
|
+
const archive = path101.join(tmpRoot, `${asset}.${ext}`);
|
|
49717
49770
|
if (!await downloadFn(url2, archive)) {
|
|
49718
49771
|
log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
|
|
49719
49772
|
return null;
|
|
@@ -49724,20 +49777,20 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
49724
49777
|
return null;
|
|
49725
49778
|
}
|
|
49726
49779
|
const candidates = [
|
|
49727
|
-
|
|
49728
|
-
|
|
49729
|
-
|
|
49780
|
+
path101.join(tmpRoot, "bin", binaryName),
|
|
49781
|
+
path101.join(tmpRoot, asset, "bin", binaryName),
|
|
49782
|
+
path101.join(tmpRoot, binaryName)
|
|
49730
49783
|
];
|
|
49731
|
-
const extractedBin = candidates.find((c2) =>
|
|
49784
|
+
const extractedBin = candidates.find((c2) => fs87.existsSync(c2));
|
|
49732
49785
|
if (!extractedBin) {
|
|
49733
49786
|
log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
|
|
49734
49787
|
return null;
|
|
49735
49788
|
}
|
|
49736
49789
|
const binDir = codeamBinDir();
|
|
49737
|
-
|
|
49738
|
-
const target =
|
|
49739
|
-
|
|
49740
|
-
|
|
49790
|
+
fs87.mkdirSync(binDir, { recursive: true });
|
|
49791
|
+
const target = path101.join(binDir, binaryName);
|
|
49792
|
+
fs87.copyFileSync(extractedBin, target);
|
|
49793
|
+
fs87.chmodSync(target, 493);
|
|
49741
49794
|
log.info("host-agent", `glab installed to ${target} (v${version3})`);
|
|
49742
49795
|
return target;
|
|
49743
49796
|
} catch (e) {
|
|
@@ -49819,9 +49872,9 @@ var defaultGitToolingRunner = {
|
|
|
49819
49872
|
var import_node_child_process33 = require("child_process");
|
|
49820
49873
|
|
|
49821
49874
|
// src/lib/updateNotifier.ts
|
|
49822
|
-
var
|
|
49823
|
-
var
|
|
49824
|
-
var
|
|
49875
|
+
var fs88 = __toESM(require("fs"));
|
|
49876
|
+
var os65 = __toESM(require("os"));
|
|
49877
|
+
var path102 = __toESM(require("path"));
|
|
49825
49878
|
var https8 = __toESM(require("https"));
|
|
49826
49879
|
var import_node_child_process32 = require("child_process");
|
|
49827
49880
|
var import_picocolors12 = __toESM(require("picocolors"));
|
|
@@ -49830,12 +49883,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
|
|
|
49830
49883
|
var TTL_MS = 24 * 60 * 60 * 1e3;
|
|
49831
49884
|
var REQUEST_TIMEOUT_MS = 1500;
|
|
49832
49885
|
function cachePath() {
|
|
49833
|
-
const dir =
|
|
49834
|
-
return
|
|
49886
|
+
const dir = path102.join(os65.homedir(), ".codeam");
|
|
49887
|
+
return path102.join(dir, "update-check.json");
|
|
49835
49888
|
}
|
|
49836
49889
|
function readCache() {
|
|
49837
49890
|
try {
|
|
49838
|
-
const raw =
|
|
49891
|
+
const raw = fs88.readFileSync(cachePath(), "utf8");
|
|
49839
49892
|
const parsed = JSON.parse(raw);
|
|
49840
49893
|
if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
|
|
49841
49894
|
return parsed;
|
|
@@ -49846,10 +49899,10 @@ function readCache() {
|
|
|
49846
49899
|
function writeCache(cache) {
|
|
49847
49900
|
try {
|
|
49848
49901
|
const file = cachePath();
|
|
49849
|
-
|
|
49902
|
+
fs88.mkdirSync(path102.dirname(file), { recursive: true });
|
|
49850
49903
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
49851
|
-
|
|
49852
|
-
|
|
49904
|
+
fs88.writeFileSync(tmp, JSON.stringify(cache));
|
|
49905
|
+
fs88.renameSync(tmp, file);
|
|
49853
49906
|
} catch {
|
|
49854
49907
|
}
|
|
49855
49908
|
}
|
|
@@ -49923,8 +49976,8 @@ function isLinkedInstall() {
|
|
|
49923
49976
|
timeout: 2e3
|
|
49924
49977
|
}).trim();
|
|
49925
49978
|
if (!root) return false;
|
|
49926
|
-
const pkgPath =
|
|
49927
|
-
return
|
|
49979
|
+
const pkgPath = path102.join(root, PKG_NAME);
|
|
49980
|
+
return fs88.lstatSync(pkgPath).isSymbolicLink();
|
|
49928
49981
|
} catch {
|
|
49929
49982
|
return false;
|
|
49930
49983
|
}
|
|
@@ -49960,7 +50013,7 @@ function maybeAutoUpdate(currentVersion, latest) {
|
|
|
49960
50013
|
return;
|
|
49961
50014
|
}
|
|
49962
50015
|
try {
|
|
49963
|
-
|
|
50016
|
+
fs88.unlinkSync(cachePath());
|
|
49964
50017
|
} catch {
|
|
49965
50018
|
}
|
|
49966
50019
|
process.stderr.write(` ${import_picocolors12.default.green("\u2713")} Updated. Resuming session...
|
|
@@ -49976,7 +50029,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
49976
50029
|
if (process.env.NODE_ENV === "test") return;
|
|
49977
50030
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
49978
50031
|
if (process.env.CI) return;
|
|
49979
|
-
const current2 = true ? "2.76.
|
|
50032
|
+
const current2 = true ? "2.76.5" : null;
|
|
49980
50033
|
if (!current2) return;
|
|
49981
50034
|
const cache = readCache();
|
|
49982
50035
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -49993,7 +50046,7 @@ function checkForUpdates() {
|
|
|
49993
50046
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
49994
50047
|
if (process.env.CI) return;
|
|
49995
50048
|
if (!process.stdout.isTTY) return;
|
|
49996
|
-
const current2 = true ? "2.76.
|
|
50049
|
+
const current2 = true ? "2.76.5" : null;
|
|
49997
50050
|
if (!current2) return;
|
|
49998
50051
|
const cache = readCache();
|
|
49999
50052
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -50016,7 +50069,7 @@ var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
|
50016
50069
|
var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
|
|
50017
50070
|
var SUDO_PREFLIGHT_TIMEOUT_MS = 5e3;
|
|
50018
50071
|
function currentCliVersion() {
|
|
50019
|
-
return true ? "2.76.
|
|
50072
|
+
return true ? "2.76.5" : null;
|
|
50020
50073
|
}
|
|
50021
50074
|
async function installedVersion(deps) {
|
|
50022
50075
|
const ls = await deps.run(
|
|
@@ -50369,7 +50422,7 @@ var ORPHAN_KILL_SETTLE_MS = 500;
|
|
|
50369
50422
|
function needsSelfRelaunch(env = process.env, pid = process.pid) {
|
|
50370
50423
|
return !env.INVOCATION_ID && pid !== 1;
|
|
50371
50424
|
}
|
|
50372
|
-
function isContainerEnvironment(existsSyncFn =
|
|
50425
|
+
function isContainerEnvironment(existsSyncFn = fs89.existsSync, readFileSyncFn = (p2) => fs89.readFileSync(p2, "utf8")) {
|
|
50373
50426
|
try {
|
|
50374
50427
|
if (existsSyncFn("/.dockerenv")) return true;
|
|
50375
50428
|
} catch {
|
|
@@ -50834,13 +50887,13 @@ var HostAgentSupervisor = class {
|
|
|
50834
50887
|
const relay = this.relay;
|
|
50835
50888
|
if (!relay) return;
|
|
50836
50889
|
const raw = cmd.payload?.path;
|
|
50837
|
-
const target = typeof raw === "string" && raw.trim() ?
|
|
50890
|
+
const target = typeof raw === "string" && raw.trim() ? path103.resolve(raw.trim()) : os66.homedir();
|
|
50838
50891
|
try {
|
|
50839
|
-
const dirents = await
|
|
50892
|
+
const dirents = await fs89.promises.readdir(target, { withFileTypes: true });
|
|
50840
50893
|
const entries2 = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
|
|
50841
50894
|
(a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
|
|
50842
50895
|
);
|
|
50843
|
-
const parent =
|
|
50896
|
+
const parent = path103.dirname(target);
|
|
50844
50897
|
await relay.sendResult(cmd.id, "completed", {
|
|
50845
50898
|
path: target,
|
|
50846
50899
|
// null at the filesystem root so the UI can hide the ".." affordance.
|
|
@@ -51188,14 +51241,14 @@ var HostAgentSupervisor = class {
|
|
|
51188
51241
|
...buildHouseProxyChildEnv({ baseUrl, token, openRouter: openRouter === true }),
|
|
51189
51242
|
CODEAM_AUTO_TOKEN: payload.autoPairToken
|
|
51190
51243
|
};
|
|
51191
|
-
const houseConfigDir =
|
|
51192
|
-
|
|
51244
|
+
const houseConfigDir = path103.join(
|
|
51245
|
+
os66.homedir(),
|
|
51193
51246
|
".codeam",
|
|
51194
51247
|
"house-claude",
|
|
51195
51248
|
payload.deployId
|
|
51196
51249
|
);
|
|
51197
51250
|
try {
|
|
51198
|
-
|
|
51251
|
+
fs89.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
|
|
51199
51252
|
} catch {
|
|
51200
51253
|
}
|
|
51201
51254
|
childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
|
|
@@ -51221,7 +51274,7 @@ var HostAgentSupervisor = class {
|
|
|
51221
51274
|
report("installing", "installing agent CLI");
|
|
51222
51275
|
await this.runAgentInstall(payload.agentInstallScript);
|
|
51223
51276
|
}
|
|
51224
|
-
const home = process.env.HOME ||
|
|
51277
|
+
const home = process.env.HOME || os66.homedir();
|
|
51225
51278
|
childEnv.PATH = `${home}/.local/bin:${process.env.PATH ?? ""}`;
|
|
51226
51279
|
if (payload.cloneToken) {
|
|
51227
51280
|
try {
|
|
@@ -51229,13 +51282,13 @@ var HostAgentSupervisor = class {
|
|
|
51229
51282
|
if ((payload.repoProvider ?? "github") === "gitlab") {
|
|
51230
51283
|
const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
|
|
51231
51284
|
if (glabCmd) {
|
|
51232
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
51285
|
+
childEnv.PATH = `${codeamBinDir()}${path103.delimiter}${childEnv.PATH}`;
|
|
51233
51286
|
await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
|
|
51234
51287
|
}
|
|
51235
51288
|
} else {
|
|
51236
51289
|
const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
|
|
51237
51290
|
if (ghCmd) {
|
|
51238
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
51291
|
+
childEnv.PATH = `${codeamBinDir()}${path103.delimiter}${childEnv.PATH}`;
|
|
51239
51292
|
await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
|
|
51240
51293
|
}
|
|
51241
51294
|
}
|
|
@@ -51263,9 +51316,9 @@ var HostAgentSupervisor = class {
|
|
|
51263
51316
|
);
|
|
51264
51317
|
if (!payload.suppressOnboardingWelcome) {
|
|
51265
51318
|
try {
|
|
51266
|
-
const cfgDir = childEnv.CLAUDE_CONFIG_DIR ||
|
|
51267
|
-
const projectDir =
|
|
51268
|
-
const hasPriorConversation =
|
|
51319
|
+
const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path103.join(os66.homedir(), ".claude");
|
|
51320
|
+
const projectDir = path103.join(cfgDir, "projects", encodeCwd(cwd));
|
|
51321
|
+
const hasPriorConversation = fs89.existsSync(projectDir) && fs89.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
|
|
51269
51322
|
if (hasPriorConversation) {
|
|
51270
51323
|
childEnv.CODEAM_RESUME_LATEST = "1";
|
|
51271
51324
|
log.info(
|
|
@@ -51419,7 +51472,7 @@ var HostAgentSupervisor = class {
|
|
|
51419
51472
|
fallbackResumeTarget() {
|
|
51420
51473
|
const session = getActiveSession();
|
|
51421
51474
|
if (!session || !session.pluginId || !session.pollSecret || !session.agent) return null;
|
|
51422
|
-
const cwd = session.cwd &&
|
|
51475
|
+
const cwd = session.cwd && fs89.existsSync(session.cwd) ? session.cwd : process.cwd();
|
|
51423
51476
|
if (isFilesystemRoot(cwd)) {
|
|
51424
51477
|
log.warn(
|
|
51425
51478
|
"host-agent",
|
|
@@ -51459,7 +51512,7 @@ var HostAgentSupervisor = class {
|
|
|
51459
51512
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: no saved pairing on this box`);
|
|
51460
51513
|
return;
|
|
51461
51514
|
}
|
|
51462
|
-
if (!session.cwd || !
|
|
51515
|
+
if (!session.cwd || !fs89.existsSync(session.cwd)) {
|
|
51463
51516
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: workspace is gone`);
|
|
51464
51517
|
return;
|
|
51465
51518
|
}
|
|
@@ -51501,7 +51554,7 @@ var HostAgentSupervisor = class {
|
|
|
51501
51554
|
const persisted = new Map((this.sessionStore.load() ?? []).map((r) => [r.deployId, r.agent]));
|
|
51502
51555
|
for (const c2 of this.children.values()) persisted.set(c2.deployId, c2.agent);
|
|
51503
51556
|
return this.listSavedSessions().map((s) => ({ s, deployId: deployIdFromWorkspace(s.cwd) })).filter(
|
|
51504
|
-
(x) => x.deployId !== null && !!x.s.cwd &&
|
|
51557
|
+
(x) => x.deployId !== null && !!x.s.cwd && fs89.existsSync(x.s.cwd)
|
|
51505
51558
|
).map(({ s, deployId }) => {
|
|
51506
51559
|
const agent = persisted.get(deployId);
|
|
51507
51560
|
return { deployId, sessionId: s.id, ...agent ? { agent } : {} };
|
|
@@ -51553,7 +51606,7 @@ var HostAgentSupervisor = class {
|
|
|
51553
51606
|
if (this.children.has(deployId)) return;
|
|
51554
51607
|
const st3 = this.resumeStateFor(target);
|
|
51555
51608
|
try {
|
|
51556
|
-
const cwd =
|
|
51609
|
+
const cwd = fs89.existsSync(target.cwd) ? target.cwd : process.cwd();
|
|
51557
51610
|
const proc = this.resumeSpawner(
|
|
51558
51611
|
{ ...readHouseProxyChildEnv(deployId), CODEAM_RESUME_SESSION_ID: session.id },
|
|
51559
51612
|
cwd
|
|
@@ -51580,7 +51633,7 @@ var HostAgentSupervisor = class {
|
|
|
51580
51633
|
return;
|
|
51581
51634
|
}
|
|
51582
51635
|
if (tracked && signal) {
|
|
51583
|
-
this.onResumeChildExit(target, 128 + (
|
|
51636
|
+
this.onResumeChildExit(target, 128 + (os66.constants.signals[signal] ?? 9), `signal ${signal}`);
|
|
51584
51637
|
return;
|
|
51585
51638
|
}
|
|
51586
51639
|
log.warn(
|
|
@@ -51623,7 +51676,7 @@ var HostAgentSupervisor = class {
|
|
|
51623
51676
|
if (Date.now() - child.startedAt < CRASH_RESPAWN_MIN_UPTIME_MS) return false;
|
|
51624
51677
|
const session = pickSavedSessionForWorkspace(this.listSavedSessions(), child.cwd);
|
|
51625
51678
|
if (!session) return false;
|
|
51626
|
-
const exitCode = typeof code === "number" ? code : 128 + (signal ?
|
|
51679
|
+
const exitCode = typeof code === "number" ? code : 128 + (signal ? os66.constants.signals[signal] ?? 9 : 9);
|
|
51627
51680
|
log.warn(
|
|
51628
51681
|
"host-agent",
|
|
51629
51682
|
`session deploy=${child.deployId.slice(0, 8)} died (${signal ?? code}) after ${Math.round((Date.now() - child.startedAt) / 1e3)}s \u2014 respawning it (resume)`
|
|
@@ -51772,12 +51825,12 @@ var HostAgentSupervisor = class {
|
|
|
51772
51825
|
this.untrackChild(deployId);
|
|
51773
51826
|
}
|
|
51774
51827
|
const dirs = [
|
|
51775
|
-
|
|
51776
|
-
|
|
51828
|
+
path103.join(selfHostedWorkspaceRoot(), deployId),
|
|
51829
|
+
path103.join(os66.homedir(), ".codeam", "house-claude", deployId)
|
|
51777
51830
|
];
|
|
51778
51831
|
for (const dir of dirs) {
|
|
51779
51832
|
try {
|
|
51780
|
-
|
|
51833
|
+
fs89.rmSync(dir, { recursive: true, force: true });
|
|
51781
51834
|
} catch (err) {
|
|
51782
51835
|
log.warn(
|
|
51783
51836
|
"host-agent",
|
|
@@ -51936,9 +51989,9 @@ async function invite() {
|
|
|
51936
51989
|
// src/commands/doctor.ts
|
|
51937
51990
|
var import_node_dns = require("dns");
|
|
51938
51991
|
var import_node_util11 = require("util");
|
|
51939
|
-
var
|
|
51940
|
-
var
|
|
51941
|
-
var
|
|
51992
|
+
var import_node_crypto16 = require("crypto");
|
|
51993
|
+
var fs90 = __toESM(require("fs"));
|
|
51994
|
+
var path104 = __toESM(require("path"));
|
|
51942
51995
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
51943
51996
|
var dnsResolveP = (0, import_node_util11.promisify)(import_node_dns.resolve);
|
|
51944
51997
|
async function checkDns(apiBase2) {
|
|
@@ -51994,13 +52047,13 @@ async function checkHealth(apiBase2) {
|
|
|
51994
52047
|
}
|
|
51995
52048
|
}
|
|
51996
52049
|
function checkConfigDir() {
|
|
51997
|
-
const dir =
|
|
52050
|
+
const dir = path104.join(require("os").homedir(), ".codeam");
|
|
51998
52051
|
try {
|
|
51999
|
-
|
|
52000
|
-
const probe =
|
|
52001
|
-
|
|
52002
|
-
const read =
|
|
52003
|
-
|
|
52052
|
+
fs90.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
52053
|
+
const probe = path104.join(dir, ".doctor-probe");
|
|
52054
|
+
fs90.writeFileSync(probe, "ok", { mode: 384 });
|
|
52055
|
+
const read = fs90.readFileSync(probe, "utf8");
|
|
52056
|
+
fs90.unlinkSync(probe);
|
|
52004
52057
|
if (read !== "ok") throw new Error("write/read round-trip mismatch");
|
|
52005
52058
|
return {
|
|
52006
52059
|
id: "config-dir",
|
|
@@ -52040,9 +52093,9 @@ function checkSessions() {
|
|
|
52040
52093
|
}
|
|
52041
52094
|
}
|
|
52042
52095
|
function checkAgentBinaries() {
|
|
52043
|
-
const
|
|
52096
|
+
const os69 = createOsStrategy();
|
|
52044
52097
|
return getEnabledAgents().map((meta) => {
|
|
52045
|
-
const found =
|
|
52098
|
+
const found = os69.findInPath(meta.binaryName);
|
|
52046
52099
|
return {
|
|
52047
52100
|
id: `agent-${meta.id}`,
|
|
52048
52101
|
label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
|
|
@@ -52064,7 +52117,7 @@ function checkNodePty() {
|
|
|
52064
52117
|
detail: "not required on this platform"
|
|
52065
52118
|
};
|
|
52066
52119
|
}
|
|
52067
|
-
const vendoredPath =
|
|
52120
|
+
const vendoredPath = path104.join(__dirname, "vendor", "node-pty");
|
|
52068
52121
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
52069
52122
|
try {
|
|
52070
52123
|
require(target);
|
|
@@ -52106,9 +52159,9 @@ function checkChokidar() {
|
|
|
52106
52159
|
}
|
|
52107
52160
|
async function doctor(args2 = []) {
|
|
52108
52161
|
const json = args2.includes("--json");
|
|
52109
|
-
const cliVersion = true ? "2.76.
|
|
52162
|
+
const cliVersion = true ? "2.76.5" : "0.0.0-dev";
|
|
52110
52163
|
const apiBase2 = resolveApiBaseUrl();
|
|
52111
|
-
const diagnosticId = (0,
|
|
52164
|
+
const diagnosticId = (0, import_node_crypto16.randomUUID)();
|
|
52112
52165
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
52113
52166
|
const [dns, health] = await Promise.all([
|
|
52114
52167
|
checkDns(apiBase2),
|
|
@@ -52314,8 +52367,8 @@ var LAUNCHER_ENV = Object.freeze({
|
|
|
52314
52367
|
|
|
52315
52368
|
// src/integrations/mcp-run.ts
|
|
52316
52369
|
var import_node_fs20 = require("fs");
|
|
52317
|
-
var
|
|
52318
|
-
var
|
|
52370
|
+
var import_node_os17 = __toESM(require("os"));
|
|
52371
|
+
var import_node_path22 = __toESM(require("path"));
|
|
52319
52372
|
|
|
52320
52373
|
// src/integrations/token-client.ts
|
|
52321
52374
|
var REFRESH_AHEAD_MS = 5 * 60 * 1e3;
|
|
@@ -52395,8 +52448,8 @@ function commandExists(command2) {
|
|
|
52395
52448
|
}
|
|
52396
52449
|
function localBinCandidates(command2) {
|
|
52397
52450
|
return [
|
|
52398
|
-
|
|
52399
|
-
|
|
52451
|
+
import_node_path22.default.join(import_node_os17.default.homedir(), ".local", "bin", command2),
|
|
52452
|
+
import_node_path22.default.join(import_node_os17.default.homedir(), ".cargo", "bin", command2)
|
|
52400
52453
|
];
|
|
52401
52454
|
}
|
|
52402
52455
|
function resolveLauncherPath(command2, deps = {
|
|
@@ -52630,7 +52683,7 @@ async function mcpWarm(argv = [], opts = {}) {
|
|
|
52630
52683
|
// src/commands/version.ts
|
|
52631
52684
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
52632
52685
|
function version2() {
|
|
52633
|
-
const v = true ? "2.76.
|
|
52686
|
+
const v = true ? "2.76.5" : "unknown";
|
|
52634
52687
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
52635
52688
|
}
|
|
52636
52689
|
|
|
@@ -52779,10 +52832,10 @@ var EXIT_CODE_NAMES = {
|
|
|
52779
52832
|
};
|
|
52780
52833
|
|
|
52781
52834
|
// src/index.ts
|
|
52782
|
-
var
|
|
52835
|
+
var os68 = __toESM(require("os"));
|
|
52783
52836
|
if (!process.env.HOME) {
|
|
52784
52837
|
try {
|
|
52785
|
-
const home =
|
|
52838
|
+
const home = os68.homedir();
|
|
52786
52839
|
if (home) process.env.HOME = home;
|
|
52787
52840
|
} catch {
|
|
52788
52841
|
}
|