codeam-cli 2.76.4 → 2.76.6
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 +415 -355
- 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.6" : "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.6",
|
|
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.6" ? { ideVersion: "2.76.6" } : {}
|
|
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
|
|
@@ -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,13 @@ function computeAdapterExtraEnv(params) {
|
|
|
43604
43635
|
);
|
|
43605
43636
|
return env;
|
|
43606
43637
|
}
|
|
43607
|
-
function
|
|
43608
|
-
|
|
43638
|
+
function shouldRecordConversationAfterBoot(params) {
|
|
43639
|
+
return !(params.resumedPriorConversation && !params.marked);
|
|
43640
|
+
}
|
|
43641
|
+
function pickLatestResumableConversation(sessions3, currentId, marked) {
|
|
43642
|
+
const listed = (sessions3 ?? []).filter((s) => s.id !== currentId);
|
|
43643
|
+
if (marked) return listed.some((s) => s.id === marked) ? marked : null;
|
|
43644
|
+
const prior = listed.sort((a, b) => b.timestamp - a.timestamp)[0];
|
|
43609
43645
|
return prior?.id ?? null;
|
|
43610
43646
|
}
|
|
43611
43647
|
async function runAcpSession(opts) {
|
|
@@ -43753,19 +43789,36 @@ async function runAcpSession(opts) {
|
|
|
43753
43789
|
`adapter handshake ok protocolVersion=${initialize.protocolVersion} sessionId=${acpSessionId.slice(0, 8)}`
|
|
43754
43790
|
);
|
|
43755
43791
|
let resumedPriorConversation = false;
|
|
43792
|
+
let marked = null;
|
|
43756
43793
|
if (process.env.CODEAM_RESUME_LATEST === "1") {
|
|
43757
43794
|
try {
|
|
43758
|
-
|
|
43795
|
+
marked = await readActiveConversationMarker(opts.cwd);
|
|
43796
|
+
const priorId = pickLatestResumableConversation(
|
|
43797
|
+
await client3.listSessions(),
|
|
43798
|
+
acpSessionId,
|
|
43799
|
+
marked
|
|
43800
|
+
);
|
|
43759
43801
|
if (priorId) {
|
|
43760
43802
|
await client3.loadSession(priorId);
|
|
43761
43803
|
acpSessionId = priorId;
|
|
43762
43804
|
resumedPriorConversation = true;
|
|
43763
|
-
log.info(
|
|
43805
|
+
log.info(
|
|
43806
|
+
"acpRunner",
|
|
43807
|
+
`auto-resumed ${marked === priorId ? "marked" : "latest"} conversation ${priorId.slice(0, 8)}`
|
|
43808
|
+
);
|
|
43809
|
+
} else if (marked) {
|
|
43810
|
+
log.info(
|
|
43811
|
+
"acpRunner",
|
|
43812
|
+
`marked conversation ${marked.slice(0, 8)} has no transcript \u2014 fresh session`
|
|
43813
|
+
);
|
|
43764
43814
|
}
|
|
43765
43815
|
} catch (err) {
|
|
43766
43816
|
log.trace("acpRunner", "auto-resume-latest failed (best-effort)", err);
|
|
43767
43817
|
}
|
|
43768
43818
|
}
|
|
43819
|
+
if (shouldRecordConversationAfterBoot({ resumedPriorConversation, marked })) {
|
|
43820
|
+
void writeActiveConversationMarker(opts.cwd, acpSessionId);
|
|
43821
|
+
}
|
|
43769
43822
|
showSuccess(`${opts.agent} online (ACP) \u2014 awaiting prompts from mobile.`);
|
|
43770
43823
|
showRelayNotice();
|
|
43771
43824
|
void publisher.publishOutput({
|
|
@@ -43859,6 +43912,7 @@ async function runAcpSession(opts) {
|
|
|
43859
43912
|
const relay = new CommandRelayService(
|
|
43860
43913
|
opts.pluginId,
|
|
43861
43914
|
async (cmd) => {
|
|
43915
|
+
if (cmd.type === "start_task") void writeActiveConversationMarker(opts.cwd, acpSessionId);
|
|
43862
43916
|
await handleCommand(
|
|
43863
43917
|
cmd,
|
|
43864
43918
|
client3,
|
|
@@ -43880,6 +43934,7 @@ async function runAcpSession(opts) {
|
|
|
43880
43934
|
// conversation" fix).
|
|
43881
43935
|
(id) => {
|
|
43882
43936
|
acpSessionId = id;
|
|
43937
|
+
void writeActiveConversationMarker(opts.cwd, id);
|
|
43883
43938
|
},
|
|
43884
43939
|
switchAgentForSession,
|
|
43885
43940
|
pendingHandoff,
|
|
@@ -43967,6 +44022,7 @@ async function runAcpSession(opts) {
|
|
|
43967
44022
|
opts.agent = nextAgent;
|
|
43968
44023
|
opts.adapter = adapter;
|
|
43969
44024
|
acpSessionId = hs.sessionId;
|
|
44025
|
+
void writeActiveConversationMarker(opts.cwd, acpSessionId);
|
|
43970
44026
|
agentCaps = hs.initialize.agentCapabilities;
|
|
43971
44027
|
runtime = createInteractiveAgentStrategy(nextAgent, createOsStrategy());
|
|
43972
44028
|
history = new AcpHistory(publisher, {
|
|
@@ -43983,7 +44039,10 @@ async function runAcpSession(opts) {
|
|
|
43983
44039
|
if (swapOpts.house) {
|
|
43984
44040
|
houseWireId = swapOpts.wireId ?? HOUSE_AGENT_ID;
|
|
43985
44041
|
if (pendingHouseConfig) {
|
|
43986
|
-
persistHouseProxyConfig(
|
|
44042
|
+
persistHouseProxyConfig(
|
|
44043
|
+
pendingHouseConfig,
|
|
44044
|
+
deployIdFromWorkspace(process.cwd()) ?? void 0
|
|
44045
|
+
);
|
|
43987
44046
|
pendingHouseConfig = null;
|
|
43988
44047
|
}
|
|
43989
44048
|
} else if (wasHouse) {
|
|
@@ -44026,17 +44085,17 @@ async function runAcpSession(opts) {
|
|
|
44026
44085
|
switchCredentialEnv = provisionAgentCredentials(agentId, auth);
|
|
44027
44086
|
},
|
|
44028
44087
|
provisionHouseProxy: ({ baseUrl, token, model, managedAgentId }) => {
|
|
44029
|
-
const claudeConfigDir2 =
|
|
44030
|
-
|
|
44088
|
+
const claudeConfigDir2 = path91.join(
|
|
44089
|
+
os58.homedir(),
|
|
44031
44090
|
".codeam",
|
|
44032
44091
|
"house-claude",
|
|
44033
44092
|
`switch-${opts.pluginId}`
|
|
44034
44093
|
);
|
|
44035
44094
|
try {
|
|
44036
|
-
|
|
44095
|
+
fs80.mkdirSync(claudeConfigDir2, { recursive: true, mode: 448 });
|
|
44037
44096
|
} catch {
|
|
44038
44097
|
}
|
|
44039
|
-
const memoryFile =
|
|
44098
|
+
const memoryFile = path91.join(claudeConfigDir2, "CLAUDE.md");
|
|
44040
44099
|
ensureBeadsWorkflowHint(void 0, memoryFile);
|
|
44041
44100
|
ensureAgentStandard(void 0, memoryFile);
|
|
44042
44101
|
const cfg = {
|
|
@@ -44096,6 +44155,7 @@ async function runAcpSession(opts) {
|
|
|
44096
44155
|
try {
|
|
44097
44156
|
await client3.loadSession(m.acpSessionId);
|
|
44098
44157
|
acpSessionId = m.acpSessionId;
|
|
44158
|
+
void writeActiveConversationMarker(opts.cwd, acpSessionId);
|
|
44099
44159
|
history.switchActiveSession(m.acpSessionId);
|
|
44100
44160
|
pendingHandoff.current = null;
|
|
44101
44161
|
log.info(
|
|
@@ -45252,7 +45312,7 @@ function startClaudeCredentialSync(opts) {
|
|
|
45252
45312
|
|
|
45253
45313
|
// src/scratch/workflow-hint.ts
|
|
45254
45314
|
var import_node_fs19 = __toESM(require("fs"));
|
|
45255
|
-
var
|
|
45315
|
+
var import_node_path21 = __toESM(require("path"));
|
|
45256
45316
|
var SCRATCH_HINT_MARKER = "<!-- codeam:scratch-workflow -->";
|
|
45257
45317
|
var SCRATCH_HINT = `${SCRATCH_HINT_MARKER}
|
|
45258
45318
|
# From-scratch projects (CodeAgent Box)
|
|
@@ -45276,7 +45336,7 @@ function ensureScratchWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2))
|
|
|
45276
45336
|
} catch {
|
|
45277
45337
|
}
|
|
45278
45338
|
if (existing.includes(SCRATCH_HINT)) return;
|
|
45279
|
-
import_node_fs19.default.mkdirSync(
|
|
45339
|
+
import_node_fs19.default.mkdirSync(import_node_path21.default.dirname(file), { recursive: true });
|
|
45280
45340
|
const open = existing.indexOf(SCRATCH_HINT_MARKER);
|
|
45281
45341
|
const close = open === -1 ? -1 : existing.indexOf(SCRATCH_HINT_MARKER, open + SCRATCH_HINT_MARKER.length);
|
|
45282
45342
|
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 +45364,9 @@ function pickPinnedSession(pinnedId, listSessions2) {
|
|
|
45304
45364
|
}
|
|
45305
45365
|
|
|
45306
45366
|
// src/agents/retired-proxy-cleanup.ts
|
|
45307
|
-
var
|
|
45308
|
-
var
|
|
45309
|
-
var
|
|
45367
|
+
var fs82 = __toESM(require("fs"));
|
|
45368
|
+
var path93 = __toESM(require("path"));
|
|
45369
|
+
var os59 = __toESM(require("os"));
|
|
45310
45370
|
var RETIRED_PROXY_RE = /^https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):8787(?:[/?#]|$)/i;
|
|
45311
45371
|
var HEADROOM_CMD_RE = /(^|[\s/"'])headroom(\s|$)/i;
|
|
45312
45372
|
var MARKETPLACE_KEY = "headroom-marketplace";
|
|
@@ -45315,12 +45375,12 @@ function isHeadroomHook(group) {
|
|
|
45315
45375
|
(h) => typeof h?.command === "string" && HEADROOM_CMD_RE.test(h.command)
|
|
45316
45376
|
);
|
|
45317
45377
|
}
|
|
45318
|
-
function sanitizeRetiredProxyConfig(homeDir2 =
|
|
45378
|
+
function sanitizeRetiredProxyConfig(homeDir2 = os59.homedir()) {
|
|
45319
45379
|
const out2 = { inspected: false, changed: false, removed: [] };
|
|
45320
|
-
const file =
|
|
45380
|
+
const file = path93.join(homeDir2, ".claude", "settings.json");
|
|
45321
45381
|
let parsed;
|
|
45322
45382
|
try {
|
|
45323
|
-
parsed = JSON.parse(
|
|
45383
|
+
parsed = JSON.parse(fs82.readFileSync(file, "utf8"));
|
|
45324
45384
|
} catch {
|
|
45325
45385
|
return out2;
|
|
45326
45386
|
}
|
|
@@ -45362,9 +45422,9 @@ function sanitizeRetiredProxyConfig(homeDir2 = os58.homedir()) {
|
|
|
45362
45422
|
if (!out2.changed) return out2;
|
|
45363
45423
|
try {
|
|
45364
45424
|
const tmp = `${file}.codeam.tmp`;
|
|
45365
|
-
|
|
45425
|
+
fs82.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
|
|
45366
45426
|
`, { mode: 384 });
|
|
45367
|
-
|
|
45427
|
+
fs82.renameSync(tmp, file);
|
|
45368
45428
|
} catch {
|
|
45369
45429
|
out2.changed = false;
|
|
45370
45430
|
}
|
|
@@ -45420,8 +45480,8 @@ async function refreshIntegrationsManifest(ctx, fetchImpl = fetch, timeoutMs = 8
|
|
|
45420
45480
|
}
|
|
45421
45481
|
|
|
45422
45482
|
// src/skills/provision.ts
|
|
45423
|
-
var
|
|
45424
|
-
function provisionSkillsForStart(home =
|
|
45483
|
+
var import_node_os16 = __toESM(require("os"));
|
|
45484
|
+
function provisionSkillsForStart(home = import_node_os16.default.homedir()) {
|
|
45425
45485
|
const materialized = [];
|
|
45426
45486
|
try {
|
|
45427
45487
|
const manifest = readSkillsManifest();
|
|
@@ -45896,7 +45956,7 @@ var AcpDriver = class {
|
|
|
45896
45956
|
};
|
|
45897
45957
|
|
|
45898
45958
|
// src/baton/transcript-mirror.ts
|
|
45899
|
-
var
|
|
45959
|
+
var fs83 = __toESM(require("fs"));
|
|
45900
45960
|
var TranscriptMirror = class {
|
|
45901
45961
|
constructor(deps) {
|
|
45902
45962
|
this.deps = deps;
|
|
@@ -45990,7 +46050,7 @@ var TranscriptMirror = class {
|
|
|
45990
46050
|
}
|
|
45991
46051
|
};
|
|
45992
46052
|
function defaultWatch(file, onChange) {
|
|
45993
|
-
const w3 =
|
|
46053
|
+
const w3 = fs83.watch(file, { persistent: false }, () => onChange());
|
|
45994
46054
|
return () => w3.close();
|
|
45995
46055
|
}
|
|
45996
46056
|
|
|
@@ -46336,16 +46396,16 @@ function keepDeviceAwake(deps = {}) {
|
|
|
46336
46396
|
}
|
|
46337
46397
|
|
|
46338
46398
|
// src/agents/claude/onboarding.ts
|
|
46339
|
-
var
|
|
46340
|
-
var
|
|
46341
|
-
var
|
|
46399
|
+
var fs84 = __toESM(require("fs"));
|
|
46400
|
+
var os61 = __toESM(require("os"));
|
|
46401
|
+
var path94 = __toESM(require("path"));
|
|
46342
46402
|
var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
|
|
46343
46403
|
function ensureClaudeOnboarded(cwd) {
|
|
46344
46404
|
try {
|
|
46345
|
-
const file =
|
|
46405
|
+
const file = path94.join(os61.homedir(), ".claude.json");
|
|
46346
46406
|
let config = {};
|
|
46347
46407
|
try {
|
|
46348
|
-
config = JSON.parse(
|
|
46408
|
+
config = JSON.parse(fs84.readFileSync(file, "utf8"));
|
|
46349
46409
|
} catch {
|
|
46350
46410
|
}
|
|
46351
46411
|
let changed = false;
|
|
@@ -46370,8 +46430,8 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
46370
46430
|
}
|
|
46371
46431
|
}
|
|
46372
46432
|
if (!changed) return;
|
|
46373
|
-
|
|
46374
|
-
|
|
46433
|
+
fs84.mkdirSync(path94.dirname(file), { recursive: true });
|
|
46434
|
+
fs84.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
46375
46435
|
log.info(
|
|
46376
46436
|
"claude",
|
|
46377
46437
|
`pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
|
|
@@ -47163,7 +47223,7 @@ var import_picocolors10 = __toESM(require("picocolors"));
|
|
|
47163
47223
|
var import_child_process30 = require("child_process");
|
|
47164
47224
|
var import_util4 = require("util");
|
|
47165
47225
|
var import_picocolors8 = __toESM(require("picocolors"));
|
|
47166
|
-
var
|
|
47226
|
+
var path95 = __toESM(require("path"));
|
|
47167
47227
|
var execFileP6 = (0, import_util4.promisify)(import_child_process30.execFile);
|
|
47168
47228
|
var MAX_BUFFER = 8 * 1024 * 1024;
|
|
47169
47229
|
function resetStdinForChild() {
|
|
@@ -47652,7 +47712,7 @@ var GitHubCodespacesProvider = class {
|
|
|
47652
47712
|
});
|
|
47653
47713
|
}
|
|
47654
47714
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
47655
|
-
const remoteDir =
|
|
47715
|
+
const remoteDir = path95.posix.dirname(remotePath);
|
|
47656
47716
|
const parts = [
|
|
47657
47717
|
`mkdir -p ${shellQuote(remoteDir)}`,
|
|
47658
47718
|
`cat > ${shellQuote(remotePath)}`
|
|
@@ -47722,7 +47782,7 @@ function shellQuote(s) {
|
|
|
47722
47782
|
// src/services/providers/gitpod.ts
|
|
47723
47783
|
var import_child_process31 = require("child_process");
|
|
47724
47784
|
var import_util5 = require("util");
|
|
47725
|
-
var
|
|
47785
|
+
var path96 = __toESM(require("path"));
|
|
47726
47786
|
var import_picocolors9 = __toESM(require("picocolors"));
|
|
47727
47787
|
var execFileP7 = (0, import_util5.promisify)(import_child_process31.execFile);
|
|
47728
47788
|
var MAX_BUFFER2 = 8 * 1024 * 1024;
|
|
@@ -47962,7 +48022,7 @@ var GitpodProvider = class {
|
|
|
47962
48022
|
});
|
|
47963
48023
|
}
|
|
47964
48024
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
47965
|
-
const remoteDir =
|
|
48025
|
+
const remoteDir = path96.posix.dirname(remotePath);
|
|
47966
48026
|
const parts = [
|
|
47967
48027
|
`mkdir -p ${shellQuote2(remoteDir)}`,
|
|
47968
48028
|
`cat > ${shellQuote2(remotePath)}`
|
|
@@ -47998,7 +48058,7 @@ function shellQuote2(s) {
|
|
|
47998
48058
|
// src/services/providers/gitlab-workspaces.ts
|
|
47999
48059
|
var import_child_process32 = require("child_process");
|
|
48000
48060
|
var import_util6 = require("util");
|
|
48001
|
-
var
|
|
48061
|
+
var path97 = __toESM(require("path"));
|
|
48002
48062
|
var execFileP8 = (0, import_util6.promisify)(import_child_process32.execFile);
|
|
48003
48063
|
var MAX_BUFFER3 = 8 * 1024 * 1024;
|
|
48004
48064
|
var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
|
|
@@ -48258,7 +48318,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48258
48318
|
}
|
|
48259
48319
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
48260
48320
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
48261
|
-
const remoteDir =
|
|
48321
|
+
const remoteDir = path97.posix.dirname(remotePath);
|
|
48262
48322
|
const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
|
|
48263
48323
|
if (options.mode != null) {
|
|
48264
48324
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
@@ -48326,7 +48386,7 @@ function shellQuote3(s) {
|
|
|
48326
48386
|
// src/services/providers/railway.ts
|
|
48327
48387
|
var import_child_process33 = require("child_process");
|
|
48328
48388
|
var import_util7 = require("util");
|
|
48329
|
-
var
|
|
48389
|
+
var path98 = __toESM(require("path"));
|
|
48330
48390
|
var execFileP9 = (0, import_util7.promisify)(import_child_process33.execFile);
|
|
48331
48391
|
var MAX_BUFFER4 = 8 * 1024 * 1024;
|
|
48332
48392
|
function resetStdinForChild4() {
|
|
@@ -48562,7 +48622,7 @@ var RailwayProvider = class {
|
|
|
48562
48622
|
if (!projectId || !serviceId) {
|
|
48563
48623
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
48564
48624
|
}
|
|
48565
|
-
const remoteDir =
|
|
48625
|
+
const remoteDir = path98.posix.dirname(remotePath);
|
|
48566
48626
|
const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
|
|
48567
48627
|
if (options.mode != null) {
|
|
48568
48628
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
@@ -49102,14 +49162,14 @@ async function stopWorkspaceFromLocal(target) {
|
|
|
49102
49162
|
}
|
|
49103
49163
|
|
|
49104
49164
|
// src/commands/host/host-client.ts
|
|
49105
|
-
var
|
|
49106
|
-
var
|
|
49107
|
-
var
|
|
49108
|
-
var
|
|
49165
|
+
var fs85 = __toESM(require("fs"));
|
|
49166
|
+
var os62 = __toESM(require("os"));
|
|
49167
|
+
var path99 = __toESM(require("path"));
|
|
49168
|
+
var import_node_crypto15 = require("crypto");
|
|
49109
49169
|
function sampleCpuTimes() {
|
|
49110
49170
|
let idle = 0;
|
|
49111
49171
|
let total = 0;
|
|
49112
|
-
for (const cpu of
|
|
49172
|
+
for (const cpu of os62.cpus()) {
|
|
49113
49173
|
const t2 = cpu.times;
|
|
49114
49174
|
idle += t2.idle;
|
|
49115
49175
|
total += t2.user + t2.nice + t2.sys + t2.idle + t2.irq;
|
|
@@ -49129,8 +49189,8 @@ var MetricsCollector = class {
|
|
|
49129
49189
|
const prev = this.prevCpu;
|
|
49130
49190
|
this.prevCpu = current2;
|
|
49131
49191
|
if (!prev) {
|
|
49132
|
-
const cores =
|
|
49133
|
-
const proxy =
|
|
49192
|
+
const cores = os62.cpus().length || 1;
|
|
49193
|
+
const proxy = os62.loadavg()[0] / cores * 100;
|
|
49134
49194
|
return Math.min(100, Math.max(0, Math.round(proxy)));
|
|
49135
49195
|
}
|
|
49136
49196
|
const idleDelta = current2.idle - prev.idle;
|
|
@@ -49143,8 +49203,8 @@ var MetricsCollector = class {
|
|
|
49143
49203
|
collect() {
|
|
49144
49204
|
return {
|
|
49145
49205
|
cpuPct: this.cpuPct(),
|
|
49146
|
-
ramUsedMb: Math.round((
|
|
49147
|
-
ramTotalMb: Math.round(
|
|
49206
|
+
ramUsedMb: Math.round((os62.totalmem() - os62.freemem()) / 1048576),
|
|
49207
|
+
ramTotalMb: Math.round(os62.totalmem() / 1048576),
|
|
49148
49208
|
latencyMs: this.lastLatencyMs
|
|
49149
49209
|
};
|
|
49150
49210
|
}
|
|
@@ -49153,19 +49213,19 @@ function apiBase() {
|
|
|
49153
49213
|
return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
|
|
49154
49214
|
}
|
|
49155
49215
|
function hostIdentityPath() {
|
|
49156
|
-
return
|
|
49216
|
+
return path99.join(os62.homedir(), ".codeam", "host-agent.json");
|
|
49157
49217
|
}
|
|
49158
49218
|
function collectOsInfo() {
|
|
49159
49219
|
return {
|
|
49160
|
-
distro:
|
|
49161
|
-
arch:
|
|
49162
|
-
kernel:
|
|
49220
|
+
distro: os62.platform(),
|
|
49221
|
+
arch: os62.arch(),
|
|
49222
|
+
kernel: os62.release(),
|
|
49163
49223
|
nodeVersion: process.versions.node
|
|
49164
49224
|
};
|
|
49165
49225
|
}
|
|
49166
49226
|
function loadHostIdentity() {
|
|
49167
49227
|
try {
|
|
49168
|
-
const raw =
|
|
49228
|
+
const raw = fs85.readFileSync(hostIdentityPath(), "utf8");
|
|
49169
49229
|
const parsed = JSON.parse(raw);
|
|
49170
49230
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
|
|
49171
49231
|
const p2 = parsed;
|
|
@@ -49183,18 +49243,18 @@ function loadHostIdentity() {
|
|
|
49183
49243
|
}
|
|
49184
49244
|
}
|
|
49185
49245
|
function pollSecretHash(secret) {
|
|
49186
|
-
return (0,
|
|
49246
|
+
return (0, import_node_crypto15.createHash)("sha256").update(secret).digest("hex");
|
|
49187
49247
|
}
|
|
49188
49248
|
function ensureControlPollSecret(identity, save = saveHostIdentity) {
|
|
49189
49249
|
if (!identity || identity.controlPollSecret) return identity;
|
|
49190
|
-
const upgraded = { ...identity, controlPollSecret: (0,
|
|
49250
|
+
const upgraded = { ...identity, controlPollSecret: (0, import_node_crypto15.randomBytes)(32).toString("base64url") };
|
|
49191
49251
|
save(upgraded);
|
|
49192
49252
|
return upgraded;
|
|
49193
49253
|
}
|
|
49194
49254
|
function saveHostIdentity(identity) {
|
|
49195
49255
|
const file = hostIdentityPath();
|
|
49196
|
-
|
|
49197
|
-
|
|
49256
|
+
fs85.mkdirSync(path99.dirname(file), { recursive: true, mode: 448 });
|
|
49257
|
+
fs85.writeFileSync(file, JSON.stringify(identity, null, 2), {
|
|
49198
49258
|
encoding: "utf8",
|
|
49199
49259
|
mode: 384
|
|
49200
49260
|
});
|
|
@@ -49239,7 +49299,7 @@ function isTerminalEnrollError(err) {
|
|
|
49239
49299
|
}
|
|
49240
49300
|
function deleteHostIdentity() {
|
|
49241
49301
|
try {
|
|
49242
|
-
|
|
49302
|
+
fs85.rmSync(hostIdentityPath(), { force: true });
|
|
49243
49303
|
} catch {
|
|
49244
49304
|
}
|
|
49245
49305
|
}
|
|
@@ -49263,12 +49323,12 @@ async function postJson(pathname, body) {
|
|
|
49263
49323
|
function resolveHostLabel(label) {
|
|
49264
49324
|
const explicit = label?.trim();
|
|
49265
49325
|
const envLabel = process.env.CODEAM_HOST_LABEL?.trim();
|
|
49266
|
-
const resolved = explicit || envLabel ||
|
|
49326
|
+
const resolved = explicit || envLabel || os62.hostname();
|
|
49267
49327
|
return resolved.slice(0, 80);
|
|
49268
49328
|
}
|
|
49269
49329
|
async function redeemEnrollToken(token, label) {
|
|
49270
|
-
const controlPollSecret = (0,
|
|
49271
|
-
const pluginSecretHash = (0,
|
|
49330
|
+
const controlPollSecret = (0, import_node_crypto15.randomBytes)(32).toString("base64url");
|
|
49331
|
+
const pluginSecretHash = (0, import_node_crypto15.createHash)("sha256").update(controlPollSecret).digest("hex");
|
|
49272
49332
|
const data = await postJson("/api/self-hosted/redeem", {
|
|
49273
49333
|
token,
|
|
49274
49334
|
label: resolveHostLabel(label),
|
|
@@ -49456,9 +49516,9 @@ async function host(args2) {
|
|
|
49456
49516
|
|
|
49457
49517
|
// src/commands/host-agent.ts
|
|
49458
49518
|
var import_node_child_process35 = require("child_process");
|
|
49459
|
-
var
|
|
49460
|
-
var
|
|
49461
|
-
var
|
|
49519
|
+
var os66 = __toESM(require("os"));
|
|
49520
|
+
var fs89 = __toESM(require("fs"));
|
|
49521
|
+
var path103 = __toESM(require("path"));
|
|
49462
49522
|
|
|
49463
49523
|
// src/skills/persist-from-payload.ts
|
|
49464
49524
|
function persistOrClearSkillsFromPayload(skills) {
|
|
@@ -49467,13 +49527,13 @@ function persistOrClearSkillsFromPayload(skills) {
|
|
|
49467
49527
|
}
|
|
49468
49528
|
|
|
49469
49529
|
// src/commands/host/session-state.ts
|
|
49470
|
-
var
|
|
49471
|
-
var
|
|
49472
|
-
var
|
|
49530
|
+
var fs86 = __toESM(require("fs"));
|
|
49531
|
+
var os63 = __toESM(require("os"));
|
|
49532
|
+
var path100 = __toESM(require("path"));
|
|
49473
49533
|
function hostSessionStatePath(env = process.env) {
|
|
49474
49534
|
const override = env.CODEAM_HOST_SESSION_STATE_FILE;
|
|
49475
49535
|
if (override && override.trim()) return override.trim();
|
|
49476
|
-
return
|
|
49536
|
+
return path100.join(os63.homedir(), ".codeam", "host-agent-sessions.json");
|
|
49477
49537
|
}
|
|
49478
49538
|
function isRecord5(v) {
|
|
49479
49539
|
if (typeof v !== "object" || v === null) return false;
|
|
@@ -49484,7 +49544,7 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
49484
49544
|
return {
|
|
49485
49545
|
load() {
|
|
49486
49546
|
try {
|
|
49487
|
-
const raw = JSON.parse(
|
|
49547
|
+
const raw = JSON.parse(fs86.readFileSync(file, "utf8"));
|
|
49488
49548
|
return Array.isArray(raw?.sessions) ? raw.sessions.filter(isRecord5) : null;
|
|
49489
49549
|
} catch {
|
|
49490
49550
|
return null;
|
|
@@ -49492,18 +49552,18 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
49492
49552
|
},
|
|
49493
49553
|
save(list) {
|
|
49494
49554
|
try {
|
|
49495
|
-
|
|
49555
|
+
fs86.mkdirSync(path100.dirname(file), { recursive: true, mode: 448 });
|
|
49496
49556
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
49497
|
-
|
|
49557
|
+
fs86.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
|
|
49498
49558
|
mode: 384
|
|
49499
49559
|
});
|
|
49500
|
-
|
|
49560
|
+
fs86.renameSync(tmp, file);
|
|
49501
49561
|
} catch {
|
|
49502
49562
|
}
|
|
49503
49563
|
},
|
|
49504
49564
|
clear() {
|
|
49505
49565
|
try {
|
|
49506
|
-
|
|
49566
|
+
fs86.rmSync(file, { force: true });
|
|
49507
49567
|
} catch {
|
|
49508
49568
|
}
|
|
49509
49569
|
}
|
|
@@ -49526,10 +49586,10 @@ function planSessionResume(records, max) {
|
|
|
49526
49586
|
return { resume: ordered.slice(0, bound), dropped: ordered.slice(bound) };
|
|
49527
49587
|
}
|
|
49528
49588
|
function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
49529
|
-
const target =
|
|
49589
|
+
const target = path100.resolve(cwd);
|
|
49530
49590
|
const reconnectable = (s) => !!s.pluginId && !!s.pollSecret && !!s.agent;
|
|
49531
49591
|
const matches = sessions3.filter(
|
|
49532
|
-
(s) => !!s.cwd &&
|
|
49592
|
+
(s) => !!s.cwd && path100.resolve(s.cwd) === target && reconnectable(s)
|
|
49533
49593
|
);
|
|
49534
49594
|
if (matches.length > 0) {
|
|
49535
49595
|
matches.sort((a, b) => b.pairedAt - a.pairedAt);
|
|
@@ -49541,11 +49601,11 @@ function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
|
49541
49601
|
|
|
49542
49602
|
// src/commands/host/git-tooling.ts
|
|
49543
49603
|
var import_node_child_process31 = require("child_process");
|
|
49544
|
-
var
|
|
49545
|
-
var
|
|
49546
|
-
var
|
|
49604
|
+
var fs87 = __toESM(require("fs"));
|
|
49605
|
+
var os64 = __toESM(require("os"));
|
|
49606
|
+
var path101 = __toESM(require("path"));
|
|
49547
49607
|
function codeamBinDir() {
|
|
49548
|
-
return process.env.CODEAM_BIN_DIR ??
|
|
49608
|
+
return process.env.CODEAM_BIN_DIR ?? path101.join(os64.homedir(), ".codeam", "bin");
|
|
49549
49609
|
}
|
|
49550
49610
|
var FALLBACK_GH_VERSION = "2.62.0";
|
|
49551
49611
|
var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
|
|
@@ -49577,7 +49637,7 @@ async function download(url2, dest) {
|
|
|
49577
49637
|
const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
|
|
49578
49638
|
if (!res.ok || !res.body) return false;
|
|
49579
49639
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
49580
|
-
|
|
49640
|
+
fs87.writeFileSync(dest, buf);
|
|
49581
49641
|
return true;
|
|
49582
49642
|
} catch {
|
|
49583
49643
|
return false;
|
|
@@ -49600,8 +49660,8 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
49600
49660
|
const version3 = await resolveVersionFn(token);
|
|
49601
49661
|
const asset = `gh_${version3}_${osToken}_${arch2}`;
|
|
49602
49662
|
const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
|
|
49603
|
-
const tmpRoot =
|
|
49604
|
-
const archive =
|
|
49663
|
+
const tmpRoot = fs87.mkdtempSync(path101.join(os64.tmpdir(), "codeam-gh-"));
|
|
49664
|
+
const archive = path101.join(tmpRoot, `${asset}.${ext}`);
|
|
49605
49665
|
if (!await downloadFn(url2, archive)) {
|
|
49606
49666
|
log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
|
|
49607
49667
|
return null;
|
|
@@ -49611,16 +49671,16 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
49611
49671
|
log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
|
|
49612
49672
|
return null;
|
|
49613
49673
|
}
|
|
49614
|
-
const extractedBin =
|
|
49615
|
-
if (!
|
|
49674
|
+
const extractedBin = path101.join(tmpRoot, asset, "bin", binaryName);
|
|
49675
|
+
if (!fs87.existsSync(extractedBin)) {
|
|
49616
49676
|
log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
|
|
49617
49677
|
return null;
|
|
49618
49678
|
}
|
|
49619
49679
|
const binDir = codeamBinDir();
|
|
49620
|
-
|
|
49621
|
-
const target =
|
|
49622
|
-
|
|
49623
|
-
|
|
49680
|
+
fs87.mkdirSync(binDir, { recursive: true });
|
|
49681
|
+
const target = path101.join(binDir, binaryName);
|
|
49682
|
+
fs87.copyFileSync(extractedBin, target);
|
|
49683
|
+
fs87.chmodSync(target, 493);
|
|
49624
49684
|
log.info("host-agent", `gh installed to ${target} (v${version3})`);
|
|
49625
49685
|
return target;
|
|
49626
49686
|
} catch (e) {
|
|
@@ -49657,19 +49717,19 @@ async function ensureGhAuth(runner, ghCmd, token) {
|
|
|
49657
49717
|
}
|
|
49658
49718
|
function ghConfigDir() {
|
|
49659
49719
|
if (process.env.GH_CONFIG_DIR) return process.env.GH_CONFIG_DIR;
|
|
49660
|
-
if (process.env.XDG_CONFIG_HOME) return
|
|
49720
|
+
if (process.env.XDG_CONFIG_HOME) return path101.join(process.env.XDG_CONFIG_HOME, "gh");
|
|
49661
49721
|
if (process.platform === "win32" && process.env.APPDATA) {
|
|
49662
|
-
return
|
|
49722
|
+
return path101.join(process.env.APPDATA, "GitHub CLI");
|
|
49663
49723
|
}
|
|
49664
|
-
return
|
|
49724
|
+
return path101.join(os64.homedir(), ".config", "gh");
|
|
49665
49725
|
}
|
|
49666
49726
|
function writeGhHostsToken(token) {
|
|
49667
49727
|
try {
|
|
49668
49728
|
const dir = ghConfigDir();
|
|
49669
|
-
const file =
|
|
49670
|
-
if (
|
|
49671
|
-
|
|
49672
|
-
|
|
49729
|
+
const file = path101.join(dir, "hosts.yml");
|
|
49730
|
+
if (fs87.existsSync(file)) return false;
|
|
49731
|
+
fs87.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
49732
|
+
fs87.writeFileSync(
|
|
49673
49733
|
file,
|
|
49674
49734
|
`github.com:
|
|
49675
49735
|
oauth_token: ${token}
|
|
@@ -49712,8 +49772,8 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
49712
49772
|
const version3 = await resolveLatestGlabVersion();
|
|
49713
49773
|
const asset = `glab_${version3}_${osToken}_${arch2}`;
|
|
49714
49774
|
const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
|
|
49715
|
-
const tmpRoot =
|
|
49716
|
-
const archive =
|
|
49775
|
+
const tmpRoot = fs87.mkdtempSync(path101.join(os64.tmpdir(), "codeam-glab-"));
|
|
49776
|
+
const archive = path101.join(tmpRoot, `${asset}.${ext}`);
|
|
49717
49777
|
if (!await downloadFn(url2, archive)) {
|
|
49718
49778
|
log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
|
|
49719
49779
|
return null;
|
|
@@ -49724,20 +49784,20 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
49724
49784
|
return null;
|
|
49725
49785
|
}
|
|
49726
49786
|
const candidates = [
|
|
49727
|
-
|
|
49728
|
-
|
|
49729
|
-
|
|
49787
|
+
path101.join(tmpRoot, "bin", binaryName),
|
|
49788
|
+
path101.join(tmpRoot, asset, "bin", binaryName),
|
|
49789
|
+
path101.join(tmpRoot, binaryName)
|
|
49730
49790
|
];
|
|
49731
|
-
const extractedBin = candidates.find((c2) =>
|
|
49791
|
+
const extractedBin = candidates.find((c2) => fs87.existsSync(c2));
|
|
49732
49792
|
if (!extractedBin) {
|
|
49733
49793
|
log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
|
|
49734
49794
|
return null;
|
|
49735
49795
|
}
|
|
49736
49796
|
const binDir = codeamBinDir();
|
|
49737
|
-
|
|
49738
|
-
const target =
|
|
49739
|
-
|
|
49740
|
-
|
|
49797
|
+
fs87.mkdirSync(binDir, { recursive: true });
|
|
49798
|
+
const target = path101.join(binDir, binaryName);
|
|
49799
|
+
fs87.copyFileSync(extractedBin, target);
|
|
49800
|
+
fs87.chmodSync(target, 493);
|
|
49741
49801
|
log.info("host-agent", `glab installed to ${target} (v${version3})`);
|
|
49742
49802
|
return target;
|
|
49743
49803
|
} catch (e) {
|
|
@@ -49819,9 +49879,9 @@ var defaultGitToolingRunner = {
|
|
|
49819
49879
|
var import_node_child_process33 = require("child_process");
|
|
49820
49880
|
|
|
49821
49881
|
// src/lib/updateNotifier.ts
|
|
49822
|
-
var
|
|
49823
|
-
var
|
|
49824
|
-
var
|
|
49882
|
+
var fs88 = __toESM(require("fs"));
|
|
49883
|
+
var os65 = __toESM(require("os"));
|
|
49884
|
+
var path102 = __toESM(require("path"));
|
|
49825
49885
|
var https8 = __toESM(require("https"));
|
|
49826
49886
|
var import_node_child_process32 = require("child_process");
|
|
49827
49887
|
var import_picocolors12 = __toESM(require("picocolors"));
|
|
@@ -49830,12 +49890,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
|
|
|
49830
49890
|
var TTL_MS = 24 * 60 * 60 * 1e3;
|
|
49831
49891
|
var REQUEST_TIMEOUT_MS = 1500;
|
|
49832
49892
|
function cachePath() {
|
|
49833
|
-
const dir =
|
|
49834
|
-
return
|
|
49893
|
+
const dir = path102.join(os65.homedir(), ".codeam");
|
|
49894
|
+
return path102.join(dir, "update-check.json");
|
|
49835
49895
|
}
|
|
49836
49896
|
function readCache() {
|
|
49837
49897
|
try {
|
|
49838
|
-
const raw =
|
|
49898
|
+
const raw = fs88.readFileSync(cachePath(), "utf8");
|
|
49839
49899
|
const parsed = JSON.parse(raw);
|
|
49840
49900
|
if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
|
|
49841
49901
|
return parsed;
|
|
@@ -49846,10 +49906,10 @@ function readCache() {
|
|
|
49846
49906
|
function writeCache(cache) {
|
|
49847
49907
|
try {
|
|
49848
49908
|
const file = cachePath();
|
|
49849
|
-
|
|
49909
|
+
fs88.mkdirSync(path102.dirname(file), { recursive: true });
|
|
49850
49910
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
49851
|
-
|
|
49852
|
-
|
|
49911
|
+
fs88.writeFileSync(tmp, JSON.stringify(cache));
|
|
49912
|
+
fs88.renameSync(tmp, file);
|
|
49853
49913
|
} catch {
|
|
49854
49914
|
}
|
|
49855
49915
|
}
|
|
@@ -49923,8 +49983,8 @@ function isLinkedInstall() {
|
|
|
49923
49983
|
timeout: 2e3
|
|
49924
49984
|
}).trim();
|
|
49925
49985
|
if (!root) return false;
|
|
49926
|
-
const pkgPath =
|
|
49927
|
-
return
|
|
49986
|
+
const pkgPath = path102.join(root, PKG_NAME);
|
|
49987
|
+
return fs88.lstatSync(pkgPath).isSymbolicLink();
|
|
49928
49988
|
} catch {
|
|
49929
49989
|
return false;
|
|
49930
49990
|
}
|
|
@@ -49960,7 +50020,7 @@ function maybeAutoUpdate(currentVersion, latest) {
|
|
|
49960
50020
|
return;
|
|
49961
50021
|
}
|
|
49962
50022
|
try {
|
|
49963
|
-
|
|
50023
|
+
fs88.unlinkSync(cachePath());
|
|
49964
50024
|
} catch {
|
|
49965
50025
|
}
|
|
49966
50026
|
process.stderr.write(` ${import_picocolors12.default.green("\u2713")} Updated. Resuming session...
|
|
@@ -49976,7 +50036,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
49976
50036
|
if (process.env.NODE_ENV === "test") return;
|
|
49977
50037
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
49978
50038
|
if (process.env.CI) return;
|
|
49979
|
-
const current2 = true ? "2.76.
|
|
50039
|
+
const current2 = true ? "2.76.6" : null;
|
|
49980
50040
|
if (!current2) return;
|
|
49981
50041
|
const cache = readCache();
|
|
49982
50042
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -49993,7 +50053,7 @@ function checkForUpdates() {
|
|
|
49993
50053
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
49994
50054
|
if (process.env.CI) return;
|
|
49995
50055
|
if (!process.stdout.isTTY) return;
|
|
49996
|
-
const current2 = true ? "2.76.
|
|
50056
|
+
const current2 = true ? "2.76.6" : null;
|
|
49997
50057
|
if (!current2) return;
|
|
49998
50058
|
const cache = readCache();
|
|
49999
50059
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -50016,7 +50076,7 @@ var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
|
50016
50076
|
var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
|
|
50017
50077
|
var SUDO_PREFLIGHT_TIMEOUT_MS = 5e3;
|
|
50018
50078
|
function currentCliVersion() {
|
|
50019
|
-
return true ? "2.76.
|
|
50079
|
+
return true ? "2.76.6" : null;
|
|
50020
50080
|
}
|
|
50021
50081
|
async function installedVersion(deps) {
|
|
50022
50082
|
const ls = await deps.run(
|
|
@@ -50369,7 +50429,7 @@ var ORPHAN_KILL_SETTLE_MS = 500;
|
|
|
50369
50429
|
function needsSelfRelaunch(env = process.env, pid = process.pid) {
|
|
50370
50430
|
return !env.INVOCATION_ID && pid !== 1;
|
|
50371
50431
|
}
|
|
50372
|
-
function isContainerEnvironment(existsSyncFn =
|
|
50432
|
+
function isContainerEnvironment(existsSyncFn = fs89.existsSync, readFileSyncFn = (p2) => fs89.readFileSync(p2, "utf8")) {
|
|
50373
50433
|
try {
|
|
50374
50434
|
if (existsSyncFn("/.dockerenv")) return true;
|
|
50375
50435
|
} catch {
|
|
@@ -50834,13 +50894,13 @@ var HostAgentSupervisor = class {
|
|
|
50834
50894
|
const relay = this.relay;
|
|
50835
50895
|
if (!relay) return;
|
|
50836
50896
|
const raw = cmd.payload?.path;
|
|
50837
|
-
const target = typeof raw === "string" && raw.trim() ?
|
|
50897
|
+
const target = typeof raw === "string" && raw.trim() ? path103.resolve(raw.trim()) : os66.homedir();
|
|
50838
50898
|
try {
|
|
50839
|
-
const dirents = await
|
|
50899
|
+
const dirents = await fs89.promises.readdir(target, { withFileTypes: true });
|
|
50840
50900
|
const entries2 = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
|
|
50841
50901
|
(a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
|
|
50842
50902
|
);
|
|
50843
|
-
const parent =
|
|
50903
|
+
const parent = path103.dirname(target);
|
|
50844
50904
|
await relay.sendResult(cmd.id, "completed", {
|
|
50845
50905
|
path: target,
|
|
50846
50906
|
// null at the filesystem root so the UI can hide the ".." affordance.
|
|
@@ -51188,14 +51248,14 @@ var HostAgentSupervisor = class {
|
|
|
51188
51248
|
...buildHouseProxyChildEnv({ baseUrl, token, openRouter: openRouter === true }),
|
|
51189
51249
|
CODEAM_AUTO_TOKEN: payload.autoPairToken
|
|
51190
51250
|
};
|
|
51191
|
-
const houseConfigDir =
|
|
51192
|
-
|
|
51251
|
+
const houseConfigDir = path103.join(
|
|
51252
|
+
os66.homedir(),
|
|
51193
51253
|
".codeam",
|
|
51194
51254
|
"house-claude",
|
|
51195
51255
|
payload.deployId
|
|
51196
51256
|
);
|
|
51197
51257
|
try {
|
|
51198
|
-
|
|
51258
|
+
fs89.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
|
|
51199
51259
|
} catch {
|
|
51200
51260
|
}
|
|
51201
51261
|
childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
|
|
@@ -51221,7 +51281,7 @@ var HostAgentSupervisor = class {
|
|
|
51221
51281
|
report("installing", "installing agent CLI");
|
|
51222
51282
|
await this.runAgentInstall(payload.agentInstallScript);
|
|
51223
51283
|
}
|
|
51224
|
-
const home = process.env.HOME ||
|
|
51284
|
+
const home = process.env.HOME || os66.homedir();
|
|
51225
51285
|
childEnv.PATH = `${home}/.local/bin:${process.env.PATH ?? ""}`;
|
|
51226
51286
|
if (payload.cloneToken) {
|
|
51227
51287
|
try {
|
|
@@ -51229,13 +51289,13 @@ var HostAgentSupervisor = class {
|
|
|
51229
51289
|
if ((payload.repoProvider ?? "github") === "gitlab") {
|
|
51230
51290
|
const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
|
|
51231
51291
|
if (glabCmd) {
|
|
51232
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
51292
|
+
childEnv.PATH = `${codeamBinDir()}${path103.delimiter}${childEnv.PATH}`;
|
|
51233
51293
|
await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
|
|
51234
51294
|
}
|
|
51235
51295
|
} else {
|
|
51236
51296
|
const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
|
|
51237
51297
|
if (ghCmd) {
|
|
51238
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
51298
|
+
childEnv.PATH = `${codeamBinDir()}${path103.delimiter}${childEnv.PATH}`;
|
|
51239
51299
|
await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
|
|
51240
51300
|
}
|
|
51241
51301
|
}
|
|
@@ -51263,9 +51323,9 @@ var HostAgentSupervisor = class {
|
|
|
51263
51323
|
);
|
|
51264
51324
|
if (!payload.suppressOnboardingWelcome) {
|
|
51265
51325
|
try {
|
|
51266
|
-
const cfgDir = childEnv.CLAUDE_CONFIG_DIR ||
|
|
51267
|
-
const projectDir =
|
|
51268
|
-
const hasPriorConversation =
|
|
51326
|
+
const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path103.join(os66.homedir(), ".claude");
|
|
51327
|
+
const projectDir = path103.join(cfgDir, "projects", encodeCwd(cwd));
|
|
51328
|
+
const hasPriorConversation = fs89.existsSync(projectDir) && fs89.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
|
|
51269
51329
|
if (hasPriorConversation) {
|
|
51270
51330
|
childEnv.CODEAM_RESUME_LATEST = "1";
|
|
51271
51331
|
log.info(
|
|
@@ -51419,7 +51479,7 @@ var HostAgentSupervisor = class {
|
|
|
51419
51479
|
fallbackResumeTarget() {
|
|
51420
51480
|
const session = getActiveSession();
|
|
51421
51481
|
if (!session || !session.pluginId || !session.pollSecret || !session.agent) return null;
|
|
51422
|
-
const cwd = session.cwd &&
|
|
51482
|
+
const cwd = session.cwd && fs89.existsSync(session.cwd) ? session.cwd : process.cwd();
|
|
51423
51483
|
if (isFilesystemRoot(cwd)) {
|
|
51424
51484
|
log.warn(
|
|
51425
51485
|
"host-agent",
|
|
@@ -51459,7 +51519,7 @@ var HostAgentSupervisor = class {
|
|
|
51459
51519
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: no saved pairing on this box`);
|
|
51460
51520
|
return;
|
|
51461
51521
|
}
|
|
51462
|
-
if (!session.cwd || !
|
|
51522
|
+
if (!session.cwd || !fs89.existsSync(session.cwd)) {
|
|
51463
51523
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: workspace is gone`);
|
|
51464
51524
|
return;
|
|
51465
51525
|
}
|
|
@@ -51501,7 +51561,7 @@ var HostAgentSupervisor = class {
|
|
|
51501
51561
|
const persisted = new Map((this.sessionStore.load() ?? []).map((r) => [r.deployId, r.agent]));
|
|
51502
51562
|
for (const c2 of this.children.values()) persisted.set(c2.deployId, c2.agent);
|
|
51503
51563
|
return this.listSavedSessions().map((s) => ({ s, deployId: deployIdFromWorkspace(s.cwd) })).filter(
|
|
51504
|
-
(x) => x.deployId !== null && !!x.s.cwd &&
|
|
51564
|
+
(x) => x.deployId !== null && !!x.s.cwd && fs89.existsSync(x.s.cwd)
|
|
51505
51565
|
).map(({ s, deployId }) => {
|
|
51506
51566
|
const agent = persisted.get(deployId);
|
|
51507
51567
|
return { deployId, sessionId: s.id, ...agent ? { agent } : {} };
|
|
@@ -51553,7 +51613,7 @@ var HostAgentSupervisor = class {
|
|
|
51553
51613
|
if (this.children.has(deployId)) return;
|
|
51554
51614
|
const st3 = this.resumeStateFor(target);
|
|
51555
51615
|
try {
|
|
51556
|
-
const cwd =
|
|
51616
|
+
const cwd = fs89.existsSync(target.cwd) ? target.cwd : process.cwd();
|
|
51557
51617
|
const proc = this.resumeSpawner(
|
|
51558
51618
|
{ ...readHouseProxyChildEnv(deployId), CODEAM_RESUME_SESSION_ID: session.id },
|
|
51559
51619
|
cwd
|
|
@@ -51580,7 +51640,7 @@ var HostAgentSupervisor = class {
|
|
|
51580
51640
|
return;
|
|
51581
51641
|
}
|
|
51582
51642
|
if (tracked && signal) {
|
|
51583
|
-
this.onResumeChildExit(target, 128 + (
|
|
51643
|
+
this.onResumeChildExit(target, 128 + (os66.constants.signals[signal] ?? 9), `signal ${signal}`);
|
|
51584
51644
|
return;
|
|
51585
51645
|
}
|
|
51586
51646
|
log.warn(
|
|
@@ -51623,7 +51683,7 @@ var HostAgentSupervisor = class {
|
|
|
51623
51683
|
if (Date.now() - child.startedAt < CRASH_RESPAWN_MIN_UPTIME_MS) return false;
|
|
51624
51684
|
const session = pickSavedSessionForWorkspace(this.listSavedSessions(), child.cwd);
|
|
51625
51685
|
if (!session) return false;
|
|
51626
|
-
const exitCode = typeof code === "number" ? code : 128 + (signal ?
|
|
51686
|
+
const exitCode = typeof code === "number" ? code : 128 + (signal ? os66.constants.signals[signal] ?? 9 : 9);
|
|
51627
51687
|
log.warn(
|
|
51628
51688
|
"host-agent",
|
|
51629
51689
|
`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 +51832,12 @@ var HostAgentSupervisor = class {
|
|
|
51772
51832
|
this.untrackChild(deployId);
|
|
51773
51833
|
}
|
|
51774
51834
|
const dirs = [
|
|
51775
|
-
|
|
51776
|
-
|
|
51835
|
+
path103.join(selfHostedWorkspaceRoot(), deployId),
|
|
51836
|
+
path103.join(os66.homedir(), ".codeam", "house-claude", deployId)
|
|
51777
51837
|
];
|
|
51778
51838
|
for (const dir of dirs) {
|
|
51779
51839
|
try {
|
|
51780
|
-
|
|
51840
|
+
fs89.rmSync(dir, { recursive: true, force: true });
|
|
51781
51841
|
} catch (err) {
|
|
51782
51842
|
log.warn(
|
|
51783
51843
|
"host-agent",
|
|
@@ -51936,9 +51996,9 @@ async function invite() {
|
|
|
51936
51996
|
// src/commands/doctor.ts
|
|
51937
51997
|
var import_node_dns = require("dns");
|
|
51938
51998
|
var import_node_util11 = require("util");
|
|
51939
|
-
var
|
|
51940
|
-
var
|
|
51941
|
-
var
|
|
51999
|
+
var import_node_crypto16 = require("crypto");
|
|
52000
|
+
var fs90 = __toESM(require("fs"));
|
|
52001
|
+
var path104 = __toESM(require("path"));
|
|
51942
52002
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
51943
52003
|
var dnsResolveP = (0, import_node_util11.promisify)(import_node_dns.resolve);
|
|
51944
52004
|
async function checkDns(apiBase2) {
|
|
@@ -51994,13 +52054,13 @@ async function checkHealth(apiBase2) {
|
|
|
51994
52054
|
}
|
|
51995
52055
|
}
|
|
51996
52056
|
function checkConfigDir() {
|
|
51997
|
-
const dir =
|
|
52057
|
+
const dir = path104.join(require("os").homedir(), ".codeam");
|
|
51998
52058
|
try {
|
|
51999
|
-
|
|
52000
|
-
const probe =
|
|
52001
|
-
|
|
52002
|
-
const read =
|
|
52003
|
-
|
|
52059
|
+
fs90.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
52060
|
+
const probe = path104.join(dir, ".doctor-probe");
|
|
52061
|
+
fs90.writeFileSync(probe, "ok", { mode: 384 });
|
|
52062
|
+
const read = fs90.readFileSync(probe, "utf8");
|
|
52063
|
+
fs90.unlinkSync(probe);
|
|
52004
52064
|
if (read !== "ok") throw new Error("write/read round-trip mismatch");
|
|
52005
52065
|
return {
|
|
52006
52066
|
id: "config-dir",
|
|
@@ -52040,9 +52100,9 @@ function checkSessions() {
|
|
|
52040
52100
|
}
|
|
52041
52101
|
}
|
|
52042
52102
|
function checkAgentBinaries() {
|
|
52043
|
-
const
|
|
52103
|
+
const os69 = createOsStrategy();
|
|
52044
52104
|
return getEnabledAgents().map((meta) => {
|
|
52045
|
-
const found =
|
|
52105
|
+
const found = os69.findInPath(meta.binaryName);
|
|
52046
52106
|
return {
|
|
52047
52107
|
id: `agent-${meta.id}`,
|
|
52048
52108
|
label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
|
|
@@ -52064,7 +52124,7 @@ function checkNodePty() {
|
|
|
52064
52124
|
detail: "not required on this platform"
|
|
52065
52125
|
};
|
|
52066
52126
|
}
|
|
52067
|
-
const vendoredPath =
|
|
52127
|
+
const vendoredPath = path104.join(__dirname, "vendor", "node-pty");
|
|
52068
52128
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
52069
52129
|
try {
|
|
52070
52130
|
require(target);
|
|
@@ -52106,9 +52166,9 @@ function checkChokidar() {
|
|
|
52106
52166
|
}
|
|
52107
52167
|
async function doctor(args2 = []) {
|
|
52108
52168
|
const json = args2.includes("--json");
|
|
52109
|
-
const cliVersion = true ? "2.76.
|
|
52169
|
+
const cliVersion = true ? "2.76.6" : "0.0.0-dev";
|
|
52110
52170
|
const apiBase2 = resolveApiBaseUrl();
|
|
52111
|
-
const diagnosticId = (0,
|
|
52171
|
+
const diagnosticId = (0, import_node_crypto16.randomUUID)();
|
|
52112
52172
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
52113
52173
|
const [dns, health] = await Promise.all([
|
|
52114
52174
|
checkDns(apiBase2),
|
|
@@ -52314,8 +52374,8 @@ var LAUNCHER_ENV = Object.freeze({
|
|
|
52314
52374
|
|
|
52315
52375
|
// src/integrations/mcp-run.ts
|
|
52316
52376
|
var import_node_fs20 = require("fs");
|
|
52317
|
-
var
|
|
52318
|
-
var
|
|
52377
|
+
var import_node_os17 = __toESM(require("os"));
|
|
52378
|
+
var import_node_path22 = __toESM(require("path"));
|
|
52319
52379
|
|
|
52320
52380
|
// src/integrations/token-client.ts
|
|
52321
52381
|
var REFRESH_AHEAD_MS = 5 * 60 * 1e3;
|
|
@@ -52395,8 +52455,8 @@ function commandExists(command2) {
|
|
|
52395
52455
|
}
|
|
52396
52456
|
function localBinCandidates(command2) {
|
|
52397
52457
|
return [
|
|
52398
|
-
|
|
52399
|
-
|
|
52458
|
+
import_node_path22.default.join(import_node_os17.default.homedir(), ".local", "bin", command2),
|
|
52459
|
+
import_node_path22.default.join(import_node_os17.default.homedir(), ".cargo", "bin", command2)
|
|
52400
52460
|
];
|
|
52401
52461
|
}
|
|
52402
52462
|
function resolveLauncherPath(command2, deps = {
|
|
@@ -52630,7 +52690,7 @@ async function mcpWarm(argv = [], opts = {}) {
|
|
|
52630
52690
|
// src/commands/version.ts
|
|
52631
52691
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
52632
52692
|
function version2() {
|
|
52633
|
-
const v = true ? "2.76.
|
|
52693
|
+
const v = true ? "2.76.6" : "unknown";
|
|
52634
52694
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
52635
52695
|
}
|
|
52636
52696
|
|
|
@@ -52779,10 +52839,10 @@ var EXIT_CODE_NAMES = {
|
|
|
52779
52839
|
};
|
|
52780
52840
|
|
|
52781
52841
|
// src/index.ts
|
|
52782
|
-
var
|
|
52842
|
+
var os68 = __toESM(require("os"));
|
|
52783
52843
|
if (!process.env.HOME) {
|
|
52784
52844
|
try {
|
|
52785
|
-
const home =
|
|
52845
|
+
const home = os68.homedir();
|
|
52786
52846
|
if (home) process.env.HOME = home;
|
|
52787
52847
|
} catch {
|
|
52788
52848
|
}
|