codeam-cli 2.60.15 → 2.60.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.js +634 -433
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -778,11 +778,11 @@ function quiet(fn) {
|
|
|
778
778
|
log.debug(TAG, "ignored sync error", err);
|
|
779
779
|
}
|
|
780
780
|
}
|
|
781
|
-
function rmIfExistsQuiet(
|
|
781
|
+
function rmIfExistsQuiet(path70) {
|
|
782
782
|
try {
|
|
783
|
-
fs2.rmSync(
|
|
783
|
+
fs2.rmSync(path70, { force: true });
|
|
784
784
|
} catch (err) {
|
|
785
|
-
log.debug(TAG, `rmIfExists failed for ${
|
|
785
|
+
log.debug(TAG, `rmIfExists failed for ${path70}`, err);
|
|
786
786
|
}
|
|
787
787
|
}
|
|
788
788
|
function killQuiet(target, signal = "SIGTERM") {
|
|
@@ -928,9 +928,9 @@ var _default = makeConfig();
|
|
|
928
928
|
var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, clearAll, saveCliConfig, loadCliConfig } = _default;
|
|
929
929
|
|
|
930
930
|
// src/commands/pair-auto.ts
|
|
931
|
-
var
|
|
932
|
-
var
|
|
933
|
-
var
|
|
931
|
+
var fs53 = __toESM(require("fs"));
|
|
932
|
+
var os42 = __toESM(require("os"));
|
|
933
|
+
var path56 = __toESM(require("path"));
|
|
934
934
|
var import_crypto4 = require("crypto");
|
|
935
935
|
|
|
936
936
|
// src/services/telemetry.service.ts
|
|
@@ -966,8 +966,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
|
|
|
966
966
|
return decodedFile;
|
|
967
967
|
};
|
|
968
968
|
}
|
|
969
|
-
function normalizeWindowsPath(
|
|
970
|
-
return
|
|
969
|
+
function normalizeWindowsPath(path70) {
|
|
970
|
+
return path70.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
971
971
|
}
|
|
972
972
|
|
|
973
973
|
// ../../node_modules/@posthog/core/dist/featureFlagUtils.mjs
|
|
@@ -3447,9 +3447,9 @@ async function addSourceContext(frames) {
|
|
|
3447
3447
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
3448
3448
|
return frames;
|
|
3449
3449
|
}
|
|
3450
|
-
function getContextLinesFromFile(
|
|
3450
|
+
function getContextLinesFromFile(path70, ranges, output) {
|
|
3451
3451
|
return new Promise((resolve7) => {
|
|
3452
|
-
const stream = (0, import_node_fs.createReadStream)(
|
|
3452
|
+
const stream = (0, import_node_fs.createReadStream)(path70);
|
|
3453
3453
|
const lineReaded = (0, import_node_readline.createInterface)({
|
|
3454
3454
|
input: stream
|
|
3455
3455
|
});
|
|
@@ -3464,7 +3464,7 @@ function getContextLinesFromFile(path69, ranges, output) {
|
|
|
3464
3464
|
let rangeStart = range[0];
|
|
3465
3465
|
let rangeEnd = range[1];
|
|
3466
3466
|
function onStreamError() {
|
|
3467
|
-
LRU_FILE_CONTENTS_FS_READ_FAILED.set(
|
|
3467
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(path70, 1);
|
|
3468
3468
|
lineReaded.close();
|
|
3469
3469
|
lineReaded.removeAllListeners();
|
|
3470
3470
|
destroyStreamAndResolve();
|
|
@@ -3525,8 +3525,8 @@ function clearLineContext(frame) {
|
|
|
3525
3525
|
delete frame.context_line;
|
|
3526
3526
|
delete frame.post_context;
|
|
3527
3527
|
}
|
|
3528
|
-
function shouldSkipContextLinesForFile(
|
|
3529
|
-
return
|
|
3528
|
+
function shouldSkipContextLinesForFile(path70) {
|
|
3529
|
+
return path70.startsWith("node:") || path70.endsWith(".min.js") || path70.endsWith(".min.cjs") || path70.endsWith(".min.mjs") || path70.startsWith("data:");
|
|
3530
3530
|
}
|
|
3531
3531
|
function shouldSkipContextLinesForFrame(frame) {
|
|
3532
3532
|
if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
|
|
@@ -5680,7 +5680,7 @@ function readAnonId() {
|
|
|
5680
5680
|
}
|
|
5681
5681
|
function superProperties() {
|
|
5682
5682
|
return {
|
|
5683
|
-
cliVersion: true ? "2.60.
|
|
5683
|
+
cliVersion: true ? "2.60.17" : "0.0.0-dev",
|
|
5684
5684
|
nodeVersion: process.version,
|
|
5685
5685
|
platform: process.platform,
|
|
5686
5686
|
arch: process.arch,
|
|
@@ -5861,7 +5861,7 @@ var os4 = __toESM(require("os"));
|
|
|
5861
5861
|
// package.json
|
|
5862
5862
|
var package_default = {
|
|
5863
5863
|
name: "codeam-cli",
|
|
5864
|
-
version: "2.60.
|
|
5864
|
+
version: "2.60.17",
|
|
5865
5865
|
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.",
|
|
5866
5866
|
type: "commonjs",
|
|
5867
5867
|
main: "dist/index.js",
|
|
@@ -6932,7 +6932,7 @@ var CommandRelayService = class {
|
|
|
6932
6932
|
// fresh + clear the "CLI update available" banner after a self-update
|
|
6933
6933
|
// (a codespace that reinstalls @latest reconnects via heartbeat, not
|
|
6934
6934
|
// pair/reconnect). Older backends ignore the extra field.
|
|
6935
|
-
..."2.60.
|
|
6935
|
+
..."2.60.17" ? { ideVersion: "2.60.17" } : {}
|
|
6936
6936
|
}).then(() => log.trace("relay", `heartbeat ok online=${online}`)).catch((err) => log.trace("relay", `heartbeat failed online=${online}`, err));
|
|
6937
6937
|
}
|
|
6938
6938
|
/**
|
|
@@ -7159,10 +7159,10 @@ var WINDOWS_LEGACY_JUNCTIONS = [
|
|
|
7159
7159
|
/[\\/]Start Menu([\\/]|$)/i,
|
|
7160
7160
|
/[\\/]Templates([\\/]|$)/i
|
|
7161
7161
|
];
|
|
7162
|
-
function isUnsafeWindowsWatchRoot(dir,
|
|
7162
|
+
function isUnsafeWindowsWatchRoot(dir, homedir41) {
|
|
7163
7163
|
const norm = (p2) => p2.replace(/\//g, "\\").replace(/\\+$/, "").toLowerCase();
|
|
7164
7164
|
const cwd = norm(dir);
|
|
7165
|
-
const home = norm(
|
|
7165
|
+
const home = norm(homedir41);
|
|
7166
7166
|
if (cwd === home) return true;
|
|
7167
7167
|
if (/^[a-z]:$/.test(cwd)) return true;
|
|
7168
7168
|
const sysRoots = [
|
|
@@ -8306,9 +8306,9 @@ function closeAllTerminals() {
|
|
|
8306
8306
|
}
|
|
8307
8307
|
|
|
8308
8308
|
// src/commands/start/handlers.ts
|
|
8309
|
-
var
|
|
8310
|
-
var
|
|
8311
|
-
var
|
|
8309
|
+
var fs52 = __toESM(require("fs"));
|
|
8310
|
+
var os41 = __toESM(require("os"));
|
|
8311
|
+
var path55 = __toESM(require("path"));
|
|
8312
8312
|
var import_crypto3 = require("crypto");
|
|
8313
8313
|
var import_child_process23 = require("child_process");
|
|
8314
8314
|
|
|
@@ -9089,9 +9089,9 @@ function findGitRoot2(startDir) {
|
|
|
9089
9089
|
}
|
|
9090
9090
|
|
|
9091
9091
|
// src/commands/link.ts
|
|
9092
|
-
var
|
|
9093
|
-
var
|
|
9094
|
-
var
|
|
9092
|
+
var import_node_crypto7 = require("crypto");
|
|
9093
|
+
var fs30 = __toESM(require("fs"));
|
|
9094
|
+
var path34 = __toESM(require("path"));
|
|
9095
9095
|
var import_chokidar = __toESM(require("chokidar"));
|
|
9096
9096
|
var import_picocolors2 = __toESM(require("picocolors"));
|
|
9097
9097
|
|
|
@@ -11738,10 +11738,10 @@ function buildForPlatform(platform3) {
|
|
|
11738
11738
|
var import_node_crypto4 = require("crypto");
|
|
11739
11739
|
|
|
11740
11740
|
// src/agents/claude/resolver.ts
|
|
11741
|
-
function buildClaudeLaunch(extraArgs = [],
|
|
11742
|
-
const found =
|
|
11741
|
+
function buildClaudeLaunch(extraArgs = [], os49 = createOsStrategy()) {
|
|
11742
|
+
const found = os49.findInPath("claude") ?? os49.findInPath("claude-code");
|
|
11743
11743
|
if (!found) return null;
|
|
11744
|
-
return
|
|
11744
|
+
return os49.buildLaunch(found, extraArgs);
|
|
11745
11745
|
}
|
|
11746
11746
|
|
|
11747
11747
|
// src/agents/claude/installer.ts
|
|
@@ -12331,8 +12331,8 @@ var ClaudeRuntimeStrategy = class {
|
|
|
12331
12331
|
meta = getAgent("claude");
|
|
12332
12332
|
mode = "interactive";
|
|
12333
12333
|
os;
|
|
12334
|
-
constructor(
|
|
12335
|
-
this.os =
|
|
12334
|
+
constructor(os49) {
|
|
12335
|
+
this.os = os49;
|
|
12336
12336
|
}
|
|
12337
12337
|
/**
|
|
12338
12338
|
* Claude Code's react-ink TUI enables bracketed-paste mode at
|
|
@@ -13031,8 +13031,8 @@ function codexCredentialLocator() {
|
|
|
13031
13031
|
function codexLoginLauncher() {
|
|
13032
13032
|
return {
|
|
13033
13033
|
async ensureInstalled() {
|
|
13034
|
-
const
|
|
13035
|
-
return
|
|
13034
|
+
const os49 = createOsStrategy();
|
|
13035
|
+
return os49.findInPath("codex") !== null;
|
|
13036
13036
|
},
|
|
13037
13037
|
launch() {
|
|
13038
13038
|
return (0, import_node_child_process4.spawn)("codex", ["login"], { stdio: "inherit" });
|
|
@@ -13055,8 +13055,8 @@ var CodexRuntimeStrategy = class {
|
|
|
13055
13055
|
meta = getAgent("codex");
|
|
13056
13056
|
mode = "interactive";
|
|
13057
13057
|
os;
|
|
13058
|
-
constructor(
|
|
13059
|
-
this.os =
|
|
13058
|
+
constructor(os49) {
|
|
13059
|
+
this.os = os49;
|
|
13060
13060
|
}
|
|
13061
13061
|
async prepareLaunch() {
|
|
13062
13062
|
let binary = this.os.findInPath("codex");
|
|
@@ -13155,12 +13155,12 @@ var CodexRuntimeStrategy = class {
|
|
|
13155
13155
|
});
|
|
13156
13156
|
}
|
|
13157
13157
|
};
|
|
13158
|
-
function resolveNpm(
|
|
13159
|
-
return
|
|
13158
|
+
function resolveNpm(os49) {
|
|
13159
|
+
return os49.id === "win32" ? "npm.cmd" : "npm";
|
|
13160
13160
|
}
|
|
13161
|
-
async function installCodexViaNpm(
|
|
13161
|
+
async function installCodexViaNpm(os49) {
|
|
13162
13162
|
return new Promise((resolve7, reject) => {
|
|
13163
|
-
const proc = (0, import_node_child_process5.spawn)(resolveNpm(
|
|
13163
|
+
const proc = (0, import_node_child_process5.spawn)(resolveNpm(os49), ["install", "-g", "@openai/codex"], {
|
|
13164
13164
|
stdio: "inherit"
|
|
13165
13165
|
});
|
|
13166
13166
|
proc.on("close", (code) => {
|
|
@@ -13177,16 +13177,16 @@ async function installCodexViaNpm(os48) {
|
|
|
13177
13177
|
});
|
|
13178
13178
|
});
|
|
13179
13179
|
}
|
|
13180
|
-
function augmentNpmGlobalBin(
|
|
13180
|
+
function augmentNpmGlobalBin(os49) {
|
|
13181
13181
|
try {
|
|
13182
|
-
const result = (0, import_node_child_process5.spawnSync)(resolveNpm(
|
|
13182
|
+
const result = (0, import_node_child_process5.spawnSync)(resolveNpm(os49), ["prefix", "-g"], {
|
|
13183
13183
|
stdio: ["ignore", "pipe", "ignore"]
|
|
13184
13184
|
});
|
|
13185
13185
|
if (result.status !== 0) return;
|
|
13186
13186
|
const prefix = result.stdout.toString().trim();
|
|
13187
13187
|
if (!prefix) return;
|
|
13188
|
-
const binDir =
|
|
13189
|
-
|
|
13188
|
+
const binDir = os49.id === "win32" ? prefix : path24.join(prefix, "bin");
|
|
13189
|
+
os49.augmentPath([binDir]);
|
|
13190
13190
|
} catch {
|
|
13191
13191
|
}
|
|
13192
13192
|
}
|
|
@@ -13270,9 +13270,9 @@ var import_node_child_process8 = require("child_process");
|
|
|
13270
13270
|
// src/agents/coderabbit/installer.ts
|
|
13271
13271
|
var import_node_child_process6 = require("child_process");
|
|
13272
13272
|
var INSTALL_URL = "https://cli.coderabbit.ai/install.sh";
|
|
13273
|
-
async function ensureCoderabbitInstalled(
|
|
13274
|
-
if (
|
|
13275
|
-
if (
|
|
13273
|
+
async function ensureCoderabbitInstalled(os49) {
|
|
13274
|
+
if (os49.findInPath("coderabbit")) return true;
|
|
13275
|
+
if (os49.id === "win32") {
|
|
13276
13276
|
console.error(
|
|
13277
13277
|
"\n \u2717 CodeRabbit on Windows requires WSL.\n Install the CLI inside your WSL distribution\n (curl -fsSL https://cli.coderabbit.ai/install.sh | sh)\n then re-run `codeam link coderabbit` from WSL.\n"
|
|
13278
13278
|
);
|
|
@@ -13287,8 +13287,8 @@ async function ensureCoderabbitInstalled(os48) {
|
|
|
13287
13287
|
proc.on("error", () => resolve7(false));
|
|
13288
13288
|
});
|
|
13289
13289
|
if (!ok) return false;
|
|
13290
|
-
|
|
13291
|
-
return
|
|
13290
|
+
os49.augmentPath([`${os49.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
|
|
13291
|
+
return os49.findInPath("coderabbit") !== null;
|
|
13292
13292
|
}
|
|
13293
13293
|
|
|
13294
13294
|
// src/agents/coderabbit/link.ts
|
|
@@ -13323,10 +13323,10 @@ function coderabbitCredentialLocator() {
|
|
|
13323
13323
|
validate: validateNonEmptyCredential
|
|
13324
13324
|
};
|
|
13325
13325
|
}
|
|
13326
|
-
function coderabbitLoginLauncher(
|
|
13326
|
+
function coderabbitLoginLauncher(os49) {
|
|
13327
13327
|
return {
|
|
13328
13328
|
async ensureInstalled() {
|
|
13329
|
-
return ensureCoderabbitInstalled(
|
|
13329
|
+
return ensureCoderabbitInstalled(os49);
|
|
13330
13330
|
},
|
|
13331
13331
|
launch() {
|
|
13332
13332
|
return (0, import_node_child_process7.spawn)("coderabbit", ["login"], { stdio: "inherit" });
|
|
@@ -13349,11 +13349,11 @@ function parseReview(stdout) {
|
|
|
13349
13349
|
for (const line of lines) {
|
|
13350
13350
|
const m = line.match(HUNK_LINE_RE);
|
|
13351
13351
|
if (!m) continue;
|
|
13352
|
-
const [,
|
|
13353
|
-
if (!
|
|
13352
|
+
const [, path70, lineNo, sevToken, message] = m;
|
|
13353
|
+
if (!path70 || !lineNo || !message) continue;
|
|
13354
13354
|
const cleanedMessage = message.trim().replace(/^[*-]\s+/, "");
|
|
13355
13355
|
hunks.push({
|
|
13356
|
-
path:
|
|
13356
|
+
path: path70.trim(),
|
|
13357
13357
|
line: Number(lineNo),
|
|
13358
13358
|
severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
|
|
13359
13359
|
message: cleanedMessage
|
|
@@ -13372,8 +13372,8 @@ var CoderabbitRuntimeStrategy = class {
|
|
|
13372
13372
|
meta = getAgent("coderabbit");
|
|
13373
13373
|
mode = "batch";
|
|
13374
13374
|
os;
|
|
13375
|
-
constructor(
|
|
13376
|
-
this.os =
|
|
13375
|
+
constructor(os49) {
|
|
13376
|
+
this.os = os49;
|
|
13377
13377
|
}
|
|
13378
13378
|
getDefaultArgs() {
|
|
13379
13379
|
return ["review"];
|
|
@@ -13547,10 +13547,10 @@ function cursorCredentialLocator() {
|
|
|
13547
13547
|
validate: validateNonEmptyCredential
|
|
13548
13548
|
};
|
|
13549
13549
|
}
|
|
13550
|
-
function cursorLoginLauncher(
|
|
13550
|
+
function cursorLoginLauncher(os49) {
|
|
13551
13551
|
return {
|
|
13552
13552
|
async ensureInstalled() {
|
|
13553
|
-
if (
|
|
13553
|
+
if (os49.findInPath("cursor-agent")) return true;
|
|
13554
13554
|
console.error(
|
|
13555
13555
|
"\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"
|
|
13556
13556
|
);
|
|
@@ -13612,8 +13612,8 @@ var CursorRuntimeStrategy = class {
|
|
|
13612
13612
|
meta = getAgent("cursor");
|
|
13613
13613
|
mode = "interactive";
|
|
13614
13614
|
os;
|
|
13615
|
-
constructor(
|
|
13616
|
-
this.os =
|
|
13615
|
+
constructor(os49) {
|
|
13616
|
+
this.os = os49;
|
|
13617
13617
|
}
|
|
13618
13618
|
async prepareLaunch() {
|
|
13619
13619
|
const binary = this.os.findInPath("cursor-agent");
|
|
@@ -13759,10 +13759,10 @@ function aiderCredentialLocator() {
|
|
|
13759
13759
|
validate: validateNonEmptyCredential
|
|
13760
13760
|
};
|
|
13761
13761
|
}
|
|
13762
|
-
function aiderLoginLauncher(
|
|
13762
|
+
function aiderLoginLauncher(os49) {
|
|
13763
13763
|
return {
|
|
13764
13764
|
async ensureInstalled() {
|
|
13765
|
-
if (
|
|
13765
|
+
if (os49.findInPath("aider")) return true;
|
|
13766
13766
|
console.error(
|
|
13767
13767
|
"\n \u2717 aider binary not on PATH.\n Install Aider:\n pip install aider-chat\n then re-run `codeam link aider`.\n"
|
|
13768
13768
|
);
|
|
@@ -13772,7 +13772,7 @@ function aiderLoginLauncher(os48) {
|
|
|
13772
13772
|
console.error(
|
|
13773
13773
|
"\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"
|
|
13774
13774
|
);
|
|
13775
|
-
return (0, import_node_child_process10.spawn)(
|
|
13775
|
+
return (0, import_node_child_process10.spawn)(os49.id === "win32" ? "cmd.exe" : "sh", os49.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
|
|
13776
13776
|
stdio: "ignore"
|
|
13777
13777
|
});
|
|
13778
13778
|
}
|
|
@@ -13844,8 +13844,8 @@ var AiderRuntimeStrategy = class {
|
|
|
13844
13844
|
meta = getAgent("aider");
|
|
13845
13845
|
mode = "interactive";
|
|
13846
13846
|
os;
|
|
13847
|
-
constructor(
|
|
13848
|
-
this.os =
|
|
13847
|
+
constructor(os49) {
|
|
13848
|
+
this.os = os49;
|
|
13849
13849
|
}
|
|
13850
13850
|
async prepareLaunch() {
|
|
13851
13851
|
const binary = this.os.findInPath("aider");
|
|
@@ -13977,8 +13977,8 @@ function geminiCredentialLocator() {
|
|
|
13977
13977
|
function geminiLoginLauncher() {
|
|
13978
13978
|
return {
|
|
13979
13979
|
async ensureInstalled() {
|
|
13980
|
-
const
|
|
13981
|
-
return
|
|
13980
|
+
const os49 = createOsStrategy();
|
|
13981
|
+
return os49.findInPath("gemini") !== null;
|
|
13982
13982
|
},
|
|
13983
13983
|
launch() {
|
|
13984
13984
|
return (0, import_node_child_process11.spawn)("gemini", ["auth", "login"], { stdio: "inherit" });
|
|
@@ -14168,8 +14168,8 @@ var GeminiRuntimeStrategy = class {
|
|
|
14168
14168
|
meta = getAgent("gemini");
|
|
14169
14169
|
mode = "interactive";
|
|
14170
14170
|
os;
|
|
14171
|
-
constructor(
|
|
14172
|
-
this.os =
|
|
14171
|
+
constructor(os49) {
|
|
14172
|
+
this.os = os49;
|
|
14173
14173
|
}
|
|
14174
14174
|
async prepareLaunch() {
|
|
14175
14175
|
const binary = this.os.findInPath("gemini");
|
|
@@ -14280,6 +14280,135 @@ var GeminiRuntimeStrategy = class {
|
|
|
14280
14280
|
var import_node_child_process12 = require("child_process");
|
|
14281
14281
|
var import_node_os3 = require("os");
|
|
14282
14282
|
var import_node_path4 = require("path");
|
|
14283
|
+
|
|
14284
|
+
// src/agents/kimi/history.ts
|
|
14285
|
+
var fs29 = __toESM(require("fs"));
|
|
14286
|
+
var os26 = __toESM(require("os"));
|
|
14287
|
+
var path33 = __toESM(require("path"));
|
|
14288
|
+
var import_node_crypto6 = require("crypto");
|
|
14289
|
+
function kimiHome() {
|
|
14290
|
+
return process.env.KIMI_CODE_HOME || path33.join(os26.homedir(), ".kimi-code");
|
|
14291
|
+
}
|
|
14292
|
+
function workDirKey(cwd) {
|
|
14293
|
+
const hash = (0, import_node_crypto6.createHash)("sha256").update(cwd).digest("hex").slice(0, 12);
|
|
14294
|
+
return `wd_${path33.basename(cwd)}_${hash}`;
|
|
14295
|
+
}
|
|
14296
|
+
function resolveHistoryDir6(cwd) {
|
|
14297
|
+
const dir = path33.join(kimiHome(), "sessions", workDirKey(cwd));
|
|
14298
|
+
if (!fs29.existsSync(dir)) {
|
|
14299
|
+
log.debug("kimi", `resolveHistoryDir \u2014 session bucket not present yet: ${dir}`);
|
|
14300
|
+
return null;
|
|
14301
|
+
}
|
|
14302
|
+
return dir;
|
|
14303
|
+
}
|
|
14304
|
+
var WIRE_REL = path33.join("agents", "main", "wire.jsonl");
|
|
14305
|
+
function resolveHistoryFile5(cwd, sessionId) {
|
|
14306
|
+
const fromIndex = sessionDirFromIndex(sessionId);
|
|
14307
|
+
if (fromIndex) {
|
|
14308
|
+
const p2 = path33.join(fromIndex, WIRE_REL);
|
|
14309
|
+
if (fs29.existsSync(p2)) return p2;
|
|
14310
|
+
}
|
|
14311
|
+
const bucket = path33.join(kimiHome(), "sessions", workDirKey(cwd));
|
|
14312
|
+
const computed = path33.join(bucket, sessionId, WIRE_REL);
|
|
14313
|
+
if (fs29.existsSync(computed)) return computed;
|
|
14314
|
+
const scanned = scanBucketsForSession(sessionId);
|
|
14315
|
+
if (scanned) return scanned;
|
|
14316
|
+
return null;
|
|
14317
|
+
}
|
|
14318
|
+
function sessionDirFromIndex(sessionId) {
|
|
14319
|
+
try {
|
|
14320
|
+
const raw = fs29.readFileSync(path33.join(kimiHome(), "session_index.jsonl"), "utf8");
|
|
14321
|
+
for (const line of raw.split("\n")) {
|
|
14322
|
+
if (!line.includes(sessionId)) continue;
|
|
14323
|
+
try {
|
|
14324
|
+
const rec = JSON.parse(line);
|
|
14325
|
+
if (rec.sessionId === sessionId && typeof rec.sessionDir === "string") {
|
|
14326
|
+
return rec.sessionDir;
|
|
14327
|
+
}
|
|
14328
|
+
} catch {
|
|
14329
|
+
}
|
|
14330
|
+
}
|
|
14331
|
+
} catch {
|
|
14332
|
+
}
|
|
14333
|
+
return null;
|
|
14334
|
+
}
|
|
14335
|
+
function scanBucketsForSession(sessionId) {
|
|
14336
|
+
const sessionsRoot = path33.join(kimiHome(), "sessions");
|
|
14337
|
+
let buckets;
|
|
14338
|
+
try {
|
|
14339
|
+
buckets = fs29.readdirSync(sessionsRoot, { withFileTypes: true });
|
|
14340
|
+
} catch {
|
|
14341
|
+
return null;
|
|
14342
|
+
}
|
|
14343
|
+
for (const b of buckets) {
|
|
14344
|
+
if (!b.isDirectory()) continue;
|
|
14345
|
+
const candidate = path33.join(sessionsRoot, b.name, sessionId, WIRE_REL);
|
|
14346
|
+
if (fs29.existsSync(candidate)) return candidate;
|
|
14347
|
+
}
|
|
14348
|
+
return null;
|
|
14349
|
+
}
|
|
14350
|
+
function joinTextParts(parts) {
|
|
14351
|
+
if (!Array.isArray(parts)) return "";
|
|
14352
|
+
return parts.filter((p2) => p2 && p2.type === "text" && typeof p2.text === "string").map((p2) => p2.text).join("").trim();
|
|
14353
|
+
}
|
|
14354
|
+
function parseHistoryFile6(filePath) {
|
|
14355
|
+
let raw;
|
|
14356
|
+
try {
|
|
14357
|
+
raw = fs29.readFileSync(filePath, "utf8");
|
|
14358
|
+
} catch {
|
|
14359
|
+
return [];
|
|
14360
|
+
}
|
|
14361
|
+
const out2 = [];
|
|
14362
|
+
let idx = 0;
|
|
14363
|
+
let assistantBuf = "";
|
|
14364
|
+
let assistantTime = 0;
|
|
14365
|
+
const flushAssistant = () => {
|
|
14366
|
+
const text = assistantBuf.trim();
|
|
14367
|
+
if (text) {
|
|
14368
|
+
out2.push({
|
|
14369
|
+
id: `kimi:${idx}`,
|
|
14370
|
+
role: "agent",
|
|
14371
|
+
text,
|
|
14372
|
+
timestamp: new Date(assistantTime || 0).toISOString()
|
|
14373
|
+
});
|
|
14374
|
+
idx += 1;
|
|
14375
|
+
}
|
|
14376
|
+
assistantBuf = "";
|
|
14377
|
+
assistantTime = 0;
|
|
14378
|
+
};
|
|
14379
|
+
for (const line of raw.split("\n")) {
|
|
14380
|
+
if (!line.trim()) continue;
|
|
14381
|
+
let rec;
|
|
14382
|
+
try {
|
|
14383
|
+
rec = JSON.parse(line);
|
|
14384
|
+
} catch {
|
|
14385
|
+
continue;
|
|
14386
|
+
}
|
|
14387
|
+
if (rec.type === "turn.prompt") {
|
|
14388
|
+
flushAssistant();
|
|
14389
|
+
const text = joinTextParts(rec.input);
|
|
14390
|
+
if (text) {
|
|
14391
|
+
out2.push({
|
|
14392
|
+
id: `kimi:${idx}`,
|
|
14393
|
+
role: "user",
|
|
14394
|
+
text,
|
|
14395
|
+
timestamp: new Date(rec.time || 0).toISOString()
|
|
14396
|
+
});
|
|
14397
|
+
idx += 1;
|
|
14398
|
+
}
|
|
14399
|
+
} else if (rec.type === "context.append_loop_event" && rec.event?.type === "content.part" && rec.event.part?.type === "text" && typeof rec.event.part.text === "string") {
|
|
14400
|
+
assistantBuf += rec.event.part.text;
|
|
14401
|
+
if (!assistantTime) assistantTime = rec.time || 0;
|
|
14402
|
+
}
|
|
14403
|
+
}
|
|
14404
|
+
flushAssistant();
|
|
14405
|
+
return out2;
|
|
14406
|
+
}
|
|
14407
|
+
function getCurrentUsage5(_historyDir) {
|
|
14408
|
+
return null;
|
|
14409
|
+
}
|
|
14410
|
+
|
|
14411
|
+
// src/agents/kimi/runtime.ts
|
|
14283
14412
|
var KIMI_CONTEXT_WINDOW = 262144;
|
|
14284
14413
|
var KIMI_MODELS = [
|
|
14285
14414
|
{ id: "kimi-for-coding", label: "Kimi for Coding", contextWindow: KIMI_CONTEXT_WINDOW }
|
|
@@ -14293,8 +14422,8 @@ var KimiRuntimeStrategy = class {
|
|
|
14293
14422
|
meta = getAgent("kimi");
|
|
14294
14423
|
mode = "interactive";
|
|
14295
14424
|
os;
|
|
14296
|
-
constructor(
|
|
14297
|
-
this.os =
|
|
14425
|
+
constructor(os49) {
|
|
14426
|
+
this.os = os49;
|
|
14298
14427
|
}
|
|
14299
14428
|
async prepareLaunch() {
|
|
14300
14429
|
const binary = this.os.findInPath("kimi");
|
|
@@ -14306,17 +14435,29 @@ var KimiRuntimeStrategy = class {
|
|
|
14306
14435
|
const launch = this.os.buildLaunch(binary, []);
|
|
14307
14436
|
return { cmd: launch.cmd, args: launch.args };
|
|
14308
14437
|
}
|
|
14309
|
-
|
|
14310
|
-
|
|
14438
|
+
/** Re-attach the same conversation on baton hand-back — kimi resumes a session
|
|
14439
|
+
* by id with `kimi -S <id>` (`-S, --session [id]`). */
|
|
14440
|
+
resumeLaunchArgs(sessionId, _opts) {
|
|
14441
|
+
return ["-S", sessionId];
|
|
14311
14442
|
}
|
|
14312
|
-
resolveHistoryDir(
|
|
14313
|
-
return
|
|
14443
|
+
resolveHistoryDir(cwd) {
|
|
14444
|
+
return resolveHistoryDir6(cwd);
|
|
14314
14445
|
}
|
|
14315
|
-
|
|
14316
|
-
|
|
14446
|
+
/**
|
|
14447
|
+
* `<KIMI_CODE_HOME>/sessions/wd_<key>/<sessionId>/agents/main/wire.jsonl`.
|
|
14448
|
+
* Implementing this is what lets the baton engage for Kimi
|
|
14449
|
+
* (`runtimeSupportsBaton`), so LOCAL_DRIVE can tail the transcript and Take
|
|
14450
|
+
* Control resumes the SAME conversation over ACP `session/load` — verified
|
|
14451
|
+
* live: `kimi acp` advertises `loadSession:true`.
|
|
14452
|
+
*/
|
|
14453
|
+
resolveHistoryFile(cwd, sessionId) {
|
|
14454
|
+
return resolveHistoryFile5(cwd, sessionId);
|
|
14317
14455
|
}
|
|
14318
|
-
|
|
14319
|
-
return
|
|
14456
|
+
parseHistoryFile(filePath) {
|
|
14457
|
+
return parseHistoryFile6(filePath);
|
|
14458
|
+
}
|
|
14459
|
+
getCurrentUsage(historyDir) {
|
|
14460
|
+
return getCurrentUsage5(historyDir);
|
|
14320
14461
|
}
|
|
14321
14462
|
async fetchWeeklyUsage() {
|
|
14322
14463
|
return null;
|
|
@@ -14383,19 +14524,19 @@ var KimiRuntimeStrategy = class {
|
|
|
14383
14524
|
|
|
14384
14525
|
// src/agents/registry.ts
|
|
14385
14526
|
var runtimeBuilders = {
|
|
14386
|
-
claude: (
|
|
14387
|
-
codex: (
|
|
14388
|
-
coderabbit: (
|
|
14389
|
-
cursor: (
|
|
14390
|
-
aider: (
|
|
14391
|
-
gemini: (
|
|
14392
|
-
kimi: (
|
|
14527
|
+
claude: (os49) => new ClaudeRuntimeStrategy(os49),
|
|
14528
|
+
codex: (os49) => new CodexRuntimeStrategy(os49),
|
|
14529
|
+
coderabbit: (os49) => new CoderabbitRuntimeStrategy(os49),
|
|
14530
|
+
cursor: (os49) => new CursorRuntimeStrategy(os49),
|
|
14531
|
+
aider: (os49) => new AiderRuntimeStrategy(os49),
|
|
14532
|
+
gemini: (os49) => new GeminiRuntimeStrategy(os49),
|
|
14533
|
+
kimi: (os49) => new KimiRuntimeStrategy(os49)
|
|
14393
14534
|
};
|
|
14394
14535
|
var deployBuilders = {
|
|
14395
14536
|
claude: () => new ClaudeDeployStrategy(),
|
|
14396
14537
|
codex: () => new CodexDeployStrategy()
|
|
14397
14538
|
};
|
|
14398
|
-
function createAgentStrategy(agent,
|
|
14539
|
+
function createAgentStrategy(agent, os49 = createOsStrategy()) {
|
|
14399
14540
|
if (!AGENT_REGISTRY[agent]?.enabled) {
|
|
14400
14541
|
throw new Error(
|
|
14401
14542
|
`Agent "${agent}" is not supported in this codeam-cli version. Upgrade with 'npm i -g codeam-cli@latest'.`
|
|
@@ -14405,10 +14546,10 @@ function createAgentStrategy(agent, os48 = createOsStrategy()) {
|
|
|
14405
14546
|
if (!build) {
|
|
14406
14547
|
throw new Error(`No runtime strategy registered for agent "${agent}"`);
|
|
14407
14548
|
}
|
|
14408
|
-
return build(
|
|
14549
|
+
return build(os49);
|
|
14409
14550
|
}
|
|
14410
|
-
function createInteractiveAgentStrategy(agent,
|
|
14411
|
-
const s = createAgentStrategy(agent,
|
|
14551
|
+
function createInteractiveAgentStrategy(agent, os49 = createOsStrategy()) {
|
|
14552
|
+
const s = createAgentStrategy(agent, os49);
|
|
14412
14553
|
if (s.mode !== "interactive") {
|
|
14413
14554
|
throw new Error(
|
|
14414
14555
|
`Agent "${agent}" is a batch agent; use createAgentStrategy + .runOneShot for one-shot reviews.`
|
|
@@ -14464,7 +14605,7 @@ function parseLinkArgs(args2) {
|
|
|
14464
14605
|
if (apiKeyFileArg) {
|
|
14465
14606
|
const filePath = apiKeyFileArg.slice("--api-key-file=".length);
|
|
14466
14607
|
try {
|
|
14467
|
-
apiKey =
|
|
14608
|
+
apiKey = fs30.readFileSync(path34.resolve(filePath), "utf8").trim();
|
|
14468
14609
|
} catch (err) {
|
|
14469
14610
|
throw new Error(`Could not read --api-key-file ${filePath}: ${err.message}`);
|
|
14470
14611
|
}
|
|
@@ -14491,9 +14632,9 @@ async function link(args2 = []) {
|
|
|
14491
14632
|
await linkDryRunPreflight(ctx);
|
|
14492
14633
|
return;
|
|
14493
14634
|
}
|
|
14494
|
-
const pluginId = (0,
|
|
14495
|
-
const pollSecret = (0,
|
|
14496
|
-
const pluginSecretHash = (0,
|
|
14635
|
+
const pluginId = (0, import_node_crypto7.randomUUID)();
|
|
14636
|
+
const pollSecret = (0, import_node_crypto7.randomBytes)(32).toString("base64url");
|
|
14637
|
+
const pluginSecretHash = (0, import_node_crypto7.createHash)("sha256").update(pollSecret).digest("hex");
|
|
14497
14638
|
const spin = dist_exports.spinner();
|
|
14498
14639
|
spin.start("Requesting pairing code...");
|
|
14499
14640
|
const pairing = await requestCode(pluginId, pluginSecretHash);
|
|
@@ -14591,7 +14732,7 @@ async function link(args2 = []) {
|
|
|
14591
14732
|
return;
|
|
14592
14733
|
}
|
|
14593
14734
|
if (parsed.tokenFile) {
|
|
14594
|
-
const credential =
|
|
14735
|
+
const credential = fs30.readFileSync(path34.resolve(parsed.tokenFile), "utf8").trim();
|
|
14595
14736
|
if (!credential) {
|
|
14596
14737
|
showError(`--token-file ${parsed.tokenFile} is empty.`);
|
|
14597
14738
|
process.exit(1);
|
|
@@ -14809,14 +14950,14 @@ async function linkDryRunPreflight(ctx) {
|
|
|
14809
14950
|
|
|
14810
14951
|
// src/commands/host-agent.ts
|
|
14811
14952
|
var import_node_child_process20 = require("child_process");
|
|
14812
|
-
var
|
|
14813
|
-
var
|
|
14814
|
-
var
|
|
14953
|
+
var os34 = __toESM(require("os"));
|
|
14954
|
+
var fs40 = __toESM(require("fs"));
|
|
14955
|
+
var path42 = __toESM(require("path"));
|
|
14815
14956
|
|
|
14816
14957
|
// src/commands/host/host-client.ts
|
|
14817
|
-
var
|
|
14818
|
-
var
|
|
14819
|
-
var
|
|
14958
|
+
var fs32 = __toESM(require("fs"));
|
|
14959
|
+
var os28 = __toESM(require("os"));
|
|
14960
|
+
var path35 = __toESM(require("path"));
|
|
14820
14961
|
|
|
14821
14962
|
// src/lib/restrict-to-owner.ts
|
|
14822
14963
|
var import_node_fs5 = __toESM(require("fs"));
|
|
@@ -14855,7 +14996,7 @@ function restrictToOwner(filePath) {
|
|
|
14855
14996
|
function sampleCpuTimes() {
|
|
14856
14997
|
let idle = 0;
|
|
14857
14998
|
let total = 0;
|
|
14858
|
-
for (const cpu of
|
|
14999
|
+
for (const cpu of os28.cpus()) {
|
|
14859
15000
|
const t2 = cpu.times;
|
|
14860
15001
|
idle += t2.idle;
|
|
14861
15002
|
total += t2.user + t2.nice + t2.sys + t2.idle + t2.irq;
|
|
@@ -14874,8 +15015,8 @@ var MetricsCollector = class {
|
|
|
14874
15015
|
const prev = this.prevCpu;
|
|
14875
15016
|
this.prevCpu = current;
|
|
14876
15017
|
if (!prev) {
|
|
14877
|
-
const cores =
|
|
14878
|
-
const proxy =
|
|
15018
|
+
const cores = os28.cpus().length || 1;
|
|
15019
|
+
const proxy = os28.loadavg()[0] / cores * 100;
|
|
14879
15020
|
return Math.min(100, Math.max(0, Math.round(proxy)));
|
|
14880
15021
|
}
|
|
14881
15022
|
const idleDelta = current.idle - prev.idle;
|
|
@@ -14888,8 +15029,8 @@ var MetricsCollector = class {
|
|
|
14888
15029
|
collect() {
|
|
14889
15030
|
return {
|
|
14890
15031
|
cpuPct: this.cpuPct(),
|
|
14891
|
-
ramUsedMb: Math.round((
|
|
14892
|
-
ramTotalMb: Math.round(
|
|
15032
|
+
ramUsedMb: Math.round((os28.totalmem() - os28.freemem()) / 1048576),
|
|
15033
|
+
ramTotalMb: Math.round(os28.totalmem() / 1048576),
|
|
14893
15034
|
latencyMs: this.lastLatencyMs
|
|
14894
15035
|
};
|
|
14895
15036
|
}
|
|
@@ -14898,19 +15039,19 @@ function apiBase() {
|
|
|
14898
15039
|
return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
|
|
14899
15040
|
}
|
|
14900
15041
|
function hostIdentityPath() {
|
|
14901
|
-
return
|
|
15042
|
+
return path35.join(os28.homedir(), ".codeam", "host-agent.json");
|
|
14902
15043
|
}
|
|
14903
15044
|
function collectOsInfo() {
|
|
14904
15045
|
return {
|
|
14905
|
-
distro:
|
|
14906
|
-
arch:
|
|
14907
|
-
kernel:
|
|
15046
|
+
distro: os28.platform(),
|
|
15047
|
+
arch: os28.arch(),
|
|
15048
|
+
kernel: os28.release(),
|
|
14908
15049
|
nodeVersion: process.versions.node
|
|
14909
15050
|
};
|
|
14910
15051
|
}
|
|
14911
15052
|
function loadHostIdentity() {
|
|
14912
15053
|
try {
|
|
14913
|
-
const raw =
|
|
15054
|
+
const raw = fs32.readFileSync(hostIdentityPath(), "utf8");
|
|
14914
15055
|
const parsed = JSON.parse(raw);
|
|
14915
15056
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
|
|
14916
15057
|
const p2 = parsed;
|
|
@@ -14923,8 +15064,8 @@ function loadHostIdentity() {
|
|
|
14923
15064
|
}
|
|
14924
15065
|
function saveHostIdentity(identity) {
|
|
14925
15066
|
const file = hostIdentityPath();
|
|
14926
|
-
|
|
14927
|
-
|
|
15067
|
+
fs32.mkdirSync(path35.dirname(file), { recursive: true, mode: 448 });
|
|
15068
|
+
fs32.writeFileSync(file, JSON.stringify(identity, null, 2), {
|
|
14928
15069
|
encoding: "utf8",
|
|
14929
15070
|
mode: 384
|
|
14930
15071
|
});
|
|
@@ -14969,7 +15110,7 @@ function isTerminalEnrollError(err) {
|
|
|
14969
15110
|
}
|
|
14970
15111
|
function deleteHostIdentity() {
|
|
14971
15112
|
try {
|
|
14972
|
-
|
|
15113
|
+
fs32.rmSync(hostIdentityPath(), { force: true });
|
|
14973
15114
|
} catch {
|
|
14974
15115
|
}
|
|
14975
15116
|
}
|
|
@@ -15092,17 +15233,17 @@ async function reportDeployProgress(auth, deployId, step, message, sessionId) {
|
|
|
15092
15233
|
}
|
|
15093
15234
|
|
|
15094
15235
|
// src/commands/host/workspace.ts
|
|
15095
|
-
var
|
|
15096
|
-
var
|
|
15097
|
-
var
|
|
15236
|
+
var fs33 = __toESM(require("fs"));
|
|
15237
|
+
var os29 = __toESM(require("os"));
|
|
15238
|
+
var path36 = __toESM(require("path"));
|
|
15098
15239
|
var import_node_child_process14 = require("child_process");
|
|
15099
15240
|
var import_node_util4 = require("util");
|
|
15100
15241
|
var execFileP4 = (0, import_node_util4.promisify)(import_node_child_process14.execFile);
|
|
15101
15242
|
function isAbsolutePathTarget(target) {
|
|
15102
|
-
return
|
|
15243
|
+
return path36.isAbsolute(target);
|
|
15103
15244
|
}
|
|
15104
15245
|
function selfHostedWorkspaceRoot() {
|
|
15105
|
-
return
|
|
15246
|
+
return path36.join(os29.homedir(), ".codeam", "self-hosted");
|
|
15106
15247
|
}
|
|
15107
15248
|
function nonInteractiveGitEnv() {
|
|
15108
15249
|
return {
|
|
@@ -15155,13 +15296,13 @@ async function fetchGithubIdentity(token) {
|
|
|
15155
15296
|
async function configureGitCredentials(dest, repoRef, cloneToken) {
|
|
15156
15297
|
const gh = githubOwnerRepo(repoRef.trim());
|
|
15157
15298
|
if (!gh || !cloneToken) return;
|
|
15158
|
-
const credFile =
|
|
15159
|
-
|
|
15299
|
+
const credFile = path36.join(dest, ".git", "codeam-credentials");
|
|
15300
|
+
fs33.writeFileSync(credFile, `https://x-access-token:${cloneToken}@github.com
|
|
15160
15301
|
`, { mode: 384 });
|
|
15161
15302
|
restrictToOwner(credFile);
|
|
15162
15303
|
const env = nonInteractiveGitEnv();
|
|
15163
15304
|
const git2 = (args2) => execFileP4("git", ["-C", dest, ...args2], { timeout: 3e4, env });
|
|
15164
|
-
const credFilePosix = credFile.split(
|
|
15305
|
+
const credFilePosix = credFile.split(path36.sep).join("/");
|
|
15165
15306
|
await git2(["config", "--local", "--replace-all", "credential.helper", ""]).catch(() => {
|
|
15166
15307
|
});
|
|
15167
15308
|
await git2([
|
|
@@ -15197,17 +15338,17 @@ function maskToken(text, cloneToken) {
|
|
|
15197
15338
|
}
|
|
15198
15339
|
async function prepareWorkspace(repoOrPath, deployId, cloneToken) {
|
|
15199
15340
|
if (isAbsolutePathTarget(repoOrPath)) {
|
|
15200
|
-
if (!
|
|
15341
|
+
if (!fs33.existsSync(repoOrPath)) {
|
|
15201
15342
|
throw new Error(`deploy target path does not exist: ${repoOrPath}`);
|
|
15202
15343
|
}
|
|
15203
15344
|
return repoOrPath;
|
|
15204
15345
|
}
|
|
15205
|
-
const dest =
|
|
15206
|
-
if (
|
|
15346
|
+
const dest = path36.join(selfHostedWorkspaceRoot(), deployId);
|
|
15347
|
+
if (fs33.existsSync(path36.join(dest, ".git"))) {
|
|
15207
15348
|
if (cloneToken) await configureGitCredentials(dest, repoOrPath, cloneToken);
|
|
15208
15349
|
return dest;
|
|
15209
15350
|
}
|
|
15210
|
-
|
|
15351
|
+
fs33.mkdirSync(selfHostedWorkspaceRoot(), { recursive: true, mode: 448 });
|
|
15211
15352
|
const cloneUrl = repoCloneUrl(repoOrPath, cloneToken);
|
|
15212
15353
|
try {
|
|
15213
15354
|
await execFileP4("git", ["clone", "--depth", "1", cloneUrl, dest], {
|
|
@@ -15224,9 +15365,9 @@ async function prepareWorkspace(repoOrPath, deployId, cloneToken) {
|
|
|
15224
15365
|
}
|
|
15225
15366
|
|
|
15226
15367
|
// src/commands/host/agent-provisioning.ts
|
|
15227
|
-
var
|
|
15228
|
-
var
|
|
15229
|
-
var
|
|
15368
|
+
var fs34 = __toESM(require("fs"));
|
|
15369
|
+
var os30 = __toESM(require("os"));
|
|
15370
|
+
var path37 = __toESM(require("path"));
|
|
15230
15371
|
var PUBLIC_TO_INTERNAL_AGENT = {
|
|
15231
15372
|
claude_code: "claude",
|
|
15232
15373
|
claude: "claude",
|
|
@@ -15242,22 +15383,22 @@ function toInternalAgentId(publicAgentId) {
|
|
|
15242
15383
|
return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
|
|
15243
15384
|
}
|
|
15244
15385
|
function ensureDir(dir) {
|
|
15245
|
-
|
|
15386
|
+
fs34.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
15246
15387
|
}
|
|
15247
15388
|
function writeFile0600(filePath, contents) {
|
|
15248
|
-
ensureDir(
|
|
15249
|
-
|
|
15389
|
+
ensureDir(path37.dirname(filePath));
|
|
15390
|
+
fs34.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
|
|
15250
15391
|
restrictToOwner(filePath);
|
|
15251
15392
|
}
|
|
15252
15393
|
function rmIfExists(filePath) {
|
|
15253
15394
|
try {
|
|
15254
|
-
|
|
15395
|
+
fs34.rmSync(filePath, { force: true });
|
|
15255
15396
|
} catch {
|
|
15256
15397
|
}
|
|
15257
15398
|
}
|
|
15258
15399
|
var claudeProvisioner = {
|
|
15259
15400
|
write(auth, home) {
|
|
15260
|
-
const credentialsJson =
|
|
15401
|
+
const credentialsJson = path37.join(home, ".claude", ".credentials.json");
|
|
15261
15402
|
if (auth.kind === "api_key") {
|
|
15262
15403
|
rmIfExists(credentialsJson);
|
|
15263
15404
|
return { ANTHROPIC_API_KEY: auth.value };
|
|
@@ -15269,8 +15410,8 @@ var claudeProvisioner = {
|
|
|
15269
15410
|
} else {
|
|
15270
15411
|
rmIfExists(credentialsJson);
|
|
15271
15412
|
}
|
|
15272
|
-
const claudeJson =
|
|
15273
|
-
if (!
|
|
15413
|
+
const claudeJson = path37.join(home, ".claude.json");
|
|
15414
|
+
if (!fs34.existsSync(claudeJson)) {
|
|
15274
15415
|
writeFile0600(
|
|
15275
15416
|
claudeJson,
|
|
15276
15417
|
JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
|
|
@@ -15281,7 +15422,7 @@ var claudeProvisioner = {
|
|
|
15281
15422
|
};
|
|
15282
15423
|
var codexProvisioner = {
|
|
15283
15424
|
write(auth, home) {
|
|
15284
|
-
const authJson =
|
|
15425
|
+
const authJson = path37.join(home, ".codex", "auth.json");
|
|
15285
15426
|
if (auth.kind === "api_key") {
|
|
15286
15427
|
rmIfExists(authJson);
|
|
15287
15428
|
return { OPENAI_API_KEY: auth.value };
|
|
@@ -15292,8 +15433,8 @@ var codexProvisioner = {
|
|
|
15292
15433
|
};
|
|
15293
15434
|
var geminiProvisioner = {
|
|
15294
15435
|
write(auth, home) {
|
|
15295
|
-
const settingsJson =
|
|
15296
|
-
const oauthCreds =
|
|
15436
|
+
const settingsJson = path37.join(home, ".gemini", "settings.json");
|
|
15437
|
+
const oauthCreds = path37.join(home, ".gemini", "oauth_creds.json");
|
|
15297
15438
|
if (auth.kind === "api_key") {
|
|
15298
15439
|
rmIfExists(oauthCreds);
|
|
15299
15440
|
writeFile0600(settingsJson, '{"security":{"auth":{"selectedType":"gemini-api-key"}}}');
|
|
@@ -15306,7 +15447,7 @@ var geminiProvisioner = {
|
|
|
15306
15447
|
};
|
|
15307
15448
|
var cursorProvisioner = {
|
|
15308
15449
|
write(auth, home) {
|
|
15309
|
-
const authJson =
|
|
15450
|
+
const authJson = path37.join(home, ".config", "cursor", "auth.json");
|
|
15310
15451
|
if (auth.kind === "api_key") {
|
|
15311
15452
|
rmIfExists(authJson);
|
|
15312
15453
|
return { CURSOR_API_KEY: auth.value };
|
|
@@ -15332,8 +15473,8 @@ var cursorProvisioner = {
|
|
|
15332
15473
|
var kimiProvisioner = {
|
|
15333
15474
|
write(auth, home) {
|
|
15334
15475
|
const credentialsFiles = [
|
|
15335
|
-
|
|
15336
|
-
|
|
15476
|
+
path37.join(home, ".kimi", "credentials", "kimi-code.json"),
|
|
15477
|
+
path37.join(home, ".kimi-code", "credentials", "kimi-code.json")
|
|
15337
15478
|
];
|
|
15338
15479
|
if (auth.kind === "api_key") {
|
|
15339
15480
|
credentialsFiles.forEach(rmIfExists);
|
|
@@ -15358,7 +15499,7 @@ var UnsupportedAgentError = class extends Error {
|
|
|
15358
15499
|
this.agentId = agentId;
|
|
15359
15500
|
}
|
|
15360
15501
|
};
|
|
15361
|
-
function provisionAgentCredentials(publicAgentId, auth, homeDir2 =
|
|
15502
|
+
function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os30.homedir()) {
|
|
15362
15503
|
const internal = toInternalAgentId(publicAgentId);
|
|
15363
15504
|
if (!internal) throw new UnsupportedAgentError(publicAgentId);
|
|
15364
15505
|
const provisioner = PROVISIONERS[internal];
|
|
@@ -15368,11 +15509,11 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os29.homedir(
|
|
|
15368
15509
|
|
|
15369
15510
|
// src/commands/host/git-tooling.ts
|
|
15370
15511
|
var import_node_child_process15 = require("child_process");
|
|
15371
|
-
var
|
|
15372
|
-
var
|
|
15373
|
-
var
|
|
15512
|
+
var fs35 = __toESM(require("fs"));
|
|
15513
|
+
var os31 = __toESM(require("os"));
|
|
15514
|
+
var path38 = __toESM(require("path"));
|
|
15374
15515
|
function codeamBinDir() {
|
|
15375
|
-
return process.env.CODEAM_BIN_DIR ??
|
|
15516
|
+
return process.env.CODEAM_BIN_DIR ?? path38.join(os31.homedir(), ".codeam", "bin");
|
|
15376
15517
|
}
|
|
15377
15518
|
var FALLBACK_GH_VERSION = "2.62.0";
|
|
15378
15519
|
var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
|
|
@@ -15404,7 +15545,7 @@ async function download(url, dest) {
|
|
|
15404
15545
|
const res = await fetch(url, { headers: { "User-Agent": "codeam-cli" } });
|
|
15405
15546
|
if (!res.ok || !res.body) return false;
|
|
15406
15547
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
15407
|
-
|
|
15548
|
+
fs35.writeFileSync(dest, buf);
|
|
15408
15549
|
return true;
|
|
15409
15550
|
} catch {
|
|
15410
15551
|
return false;
|
|
@@ -15427,8 +15568,8 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
15427
15568
|
const version3 = await resolveVersionFn(token);
|
|
15428
15569
|
const asset = `gh_${version3}_${osToken}_${arch2}`;
|
|
15429
15570
|
const url = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
|
|
15430
|
-
const tmpRoot =
|
|
15431
|
-
const archive =
|
|
15571
|
+
const tmpRoot = fs35.mkdtempSync(path38.join(os31.tmpdir(), "codeam-gh-"));
|
|
15572
|
+
const archive = path38.join(tmpRoot, `${asset}.${ext}`);
|
|
15432
15573
|
if (!await downloadFn(url, archive)) {
|
|
15433
15574
|
log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
|
|
15434
15575
|
return null;
|
|
@@ -15438,16 +15579,16 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
15438
15579
|
log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
|
|
15439
15580
|
return null;
|
|
15440
15581
|
}
|
|
15441
|
-
const extractedBin =
|
|
15442
|
-
if (!
|
|
15582
|
+
const extractedBin = path38.join(tmpRoot, asset, "bin", binaryName);
|
|
15583
|
+
if (!fs35.existsSync(extractedBin)) {
|
|
15443
15584
|
log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
|
|
15444
15585
|
return null;
|
|
15445
15586
|
}
|
|
15446
15587
|
const binDir = codeamBinDir();
|
|
15447
|
-
|
|
15448
|
-
const target =
|
|
15449
|
-
|
|
15450
|
-
|
|
15588
|
+
fs35.mkdirSync(binDir, { recursive: true });
|
|
15589
|
+
const target = path38.join(binDir, binaryName);
|
|
15590
|
+
fs35.copyFileSync(extractedBin, target);
|
|
15591
|
+
fs35.chmodSync(target, 493);
|
|
15451
15592
|
log.info("host-agent", `gh installed to ${target} (v${version3})`);
|
|
15452
15593
|
return target;
|
|
15453
15594
|
} catch (e) {
|
|
@@ -15934,23 +16075,23 @@ async function ensureModernPython(runner) {
|
|
|
15934
16075
|
}
|
|
15935
16076
|
|
|
15936
16077
|
// src/commands/host/headroom-bootstrap.ts
|
|
15937
|
-
var
|
|
15938
|
-
var
|
|
16078
|
+
var fs37 = __toESM(require("fs"));
|
|
16079
|
+
var path40 = __toESM(require("path"));
|
|
15939
16080
|
|
|
15940
16081
|
// src/commands/host/headroom-config.ts
|
|
15941
|
-
var
|
|
15942
|
-
var
|
|
15943
|
-
var
|
|
16082
|
+
var fs36 = __toESM(require("fs"));
|
|
16083
|
+
var os32 = __toESM(require("os"));
|
|
16084
|
+
var path39 = __toESM(require("path"));
|
|
15944
16085
|
function headroomConfigPath() {
|
|
15945
|
-
return
|
|
16086
|
+
return path39.join(os32.homedir(), ".codeam", "headroom-config.json");
|
|
15946
16087
|
}
|
|
15947
16088
|
function persistHeadroomConfig(config) {
|
|
15948
16089
|
try {
|
|
15949
16090
|
const file = headroomConfigPath();
|
|
15950
|
-
|
|
16091
|
+
fs36.mkdirSync(path39.dirname(file), { recursive: true, mode: 448 });
|
|
15951
16092
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
15952
|
-
|
|
15953
|
-
|
|
16093
|
+
fs36.writeFileSync(tmp, JSON.stringify(config, null, 2), { encoding: "utf8", mode: 384 });
|
|
16094
|
+
fs36.renameSync(tmp, file);
|
|
15954
16095
|
restrictToOwner(file);
|
|
15955
16096
|
} catch (err) {
|
|
15956
16097
|
log.warn(
|
|
@@ -15960,21 +16101,21 @@ function persistHeadroomConfig(config) {
|
|
|
15960
16101
|
}
|
|
15961
16102
|
}
|
|
15962
16103
|
function agentSettingsPath(kind) {
|
|
15963
|
-
const home =
|
|
15964
|
-
if (kind === "claude") return
|
|
15965
|
-
if (kind === "codex") return
|
|
15966
|
-
if (kind === "copilot") return
|
|
16104
|
+
const home = os32.homedir();
|
|
16105
|
+
if (kind === "claude") return path39.join(home, ".claude", "settings.json");
|
|
16106
|
+
if (kind === "codex") return path39.join(home, ".codex", "auth.json");
|
|
16107
|
+
if (kind === "copilot") return path39.join(home, ".config", "github-copilot", "hosts.json");
|
|
15967
16108
|
return null;
|
|
15968
16109
|
}
|
|
15969
16110
|
function backupAgentHeadroomConfig(kind) {
|
|
15970
16111
|
const src = agentSettingsPath(kind);
|
|
15971
16112
|
if (!src) return;
|
|
15972
16113
|
try {
|
|
15973
|
-
if (!
|
|
15974
|
-
const dest =
|
|
15975
|
-
|
|
15976
|
-
|
|
15977
|
-
|
|
16114
|
+
if (!fs36.existsSync(src)) return;
|
|
16115
|
+
const dest = path39.join(os32.homedir(), ".codeam", `headroom-backup-${kind}.json`);
|
|
16116
|
+
fs36.mkdirSync(path39.dirname(dest), { recursive: true, mode: 448 });
|
|
16117
|
+
fs36.copyFileSync(src, dest);
|
|
16118
|
+
fs36.chmodSync(dest, 384);
|
|
15978
16119
|
log.info("host-agent", `headroom config backup: ${src} \u2192 ${dest}`);
|
|
15979
16120
|
} catch (err) {
|
|
15980
16121
|
log.warn(
|
|
@@ -15986,12 +16127,12 @@ function backupAgentHeadroomConfig(kind) {
|
|
|
15986
16127
|
function restoreAgentHeadroomConfig(kind) {
|
|
15987
16128
|
const dest = agentSettingsPath(kind);
|
|
15988
16129
|
if (!dest) return false;
|
|
15989
|
-
const src =
|
|
15990
|
-
if (!
|
|
16130
|
+
const src = path39.join(os32.homedir(), ".codeam", `headroom-backup-${kind}.json`);
|
|
16131
|
+
if (!fs36.existsSync(src)) return false;
|
|
15991
16132
|
try {
|
|
15992
|
-
|
|
15993
|
-
|
|
15994
|
-
|
|
16133
|
+
fs36.mkdirSync(path39.dirname(dest), { recursive: true, mode: 448 });
|
|
16134
|
+
fs36.copyFileSync(src, dest);
|
|
16135
|
+
fs36.chmodSync(dest, 384);
|
|
15995
16136
|
log.info("host-agent", `headroom config restored: ${src} \u2192 ${dest}`);
|
|
15996
16137
|
return true;
|
|
15997
16138
|
} catch (err) {
|
|
@@ -16004,7 +16145,7 @@ function restoreAgentHeadroomConfig(kind) {
|
|
|
16004
16145
|
}
|
|
16005
16146
|
function readHeadroomChildEnv() {
|
|
16006
16147
|
try {
|
|
16007
|
-
const raw =
|
|
16148
|
+
const raw = fs36.readFileSync(headroomConfigPath(), "utf8");
|
|
16008
16149
|
const parsed = JSON.parse(raw);
|
|
16009
16150
|
if (typeof parsed !== "object" || parsed === null) return {};
|
|
16010
16151
|
const o = parsed;
|
|
@@ -16040,37 +16181,37 @@ function bundledClaudeBinDir() {
|
|
|
16040
16181
|
const roots = /* @__PURE__ */ new Set();
|
|
16041
16182
|
let dir = __dirname;
|
|
16042
16183
|
for (let i = 0; i < 6; i++) {
|
|
16043
|
-
roots.add(
|
|
16044
|
-
const parent =
|
|
16184
|
+
roots.add(path40.join(dir, "node_modules"));
|
|
16185
|
+
const parent = path40.dirname(dir);
|
|
16045
16186
|
if (parent === dir) break;
|
|
16046
16187
|
dir = parent;
|
|
16047
16188
|
}
|
|
16048
16189
|
try {
|
|
16049
16190
|
const main2 = require.resolve("@anthropic-ai/claude-agent-sdk");
|
|
16050
|
-
const marker = `${
|
|
16191
|
+
const marker = `${path40.sep}@anthropic-ai${path40.sep}`;
|
|
16051
16192
|
const idx = main2.lastIndexOf(marker);
|
|
16052
16193
|
if (idx !== -1) roots.add(main2.slice(0, idx));
|
|
16053
16194
|
} catch {
|
|
16054
16195
|
}
|
|
16055
16196
|
for (const nm of roots) {
|
|
16056
|
-
const atAnthropic =
|
|
16197
|
+
const atAnthropic = path40.join(nm, "@anthropic-ai");
|
|
16057
16198
|
let entries;
|
|
16058
16199
|
try {
|
|
16059
|
-
entries =
|
|
16200
|
+
entries = fs37.readdirSync(atAnthropic);
|
|
16060
16201
|
} catch {
|
|
16061
16202
|
continue;
|
|
16062
16203
|
}
|
|
16063
16204
|
for (const entry of entries) {
|
|
16064
16205
|
if (!entry.startsWith("claude-agent-sdk-")) continue;
|
|
16065
|
-
const bin =
|
|
16066
|
-
if (
|
|
16206
|
+
const bin = path40.join(atAnthropic, entry, "claude");
|
|
16207
|
+
if (fs37.existsSync(bin)) return path40.dirname(bin);
|
|
16067
16208
|
}
|
|
16068
16209
|
}
|
|
16069
16210
|
return null;
|
|
16070
16211
|
}
|
|
16071
16212
|
async function getFreeDiskBytes(dir) {
|
|
16072
16213
|
try {
|
|
16073
|
-
const s = await
|
|
16214
|
+
const s = await fs37.promises.statfs(dir);
|
|
16074
16215
|
return s.bsize * s.bavail;
|
|
16075
16216
|
} catch {
|
|
16076
16217
|
return null;
|
|
@@ -16132,7 +16273,7 @@ async function setupHeadroomForSelfHosted(agent, runner = defaultHeadroomRunner,
|
|
|
16132
16273
|
if (initKind === "claude") {
|
|
16133
16274
|
const claudeDir = bundledClaudeBinDir();
|
|
16134
16275
|
if (claudeDir) {
|
|
16135
|
-
initEnv.PATH = `${claudeDir}${
|
|
16276
|
+
initEnv.PATH = `${claudeDir}${path40.delimiter}${process.env["PATH"] ?? ""}`;
|
|
16136
16277
|
log.info("host-agent", `headroom init: bundled claude on PATH (${claudeDir})`);
|
|
16137
16278
|
} else {
|
|
16138
16279
|
log.warn("host-agent", "headroom init: bundled claude binary not found \u2014 init may fail");
|
|
@@ -16167,9 +16308,9 @@ async function setupHeadroomForSelfHosted(agent, runner = defaultHeadroomRunner,
|
|
|
16167
16308
|
var import_node_child_process18 = require("child_process");
|
|
16168
16309
|
|
|
16169
16310
|
// src/lib/updateNotifier.ts
|
|
16170
|
-
var
|
|
16171
|
-
var
|
|
16172
|
-
var
|
|
16311
|
+
var fs38 = __toESM(require("fs"));
|
|
16312
|
+
var os33 = __toESM(require("os"));
|
|
16313
|
+
var path41 = __toESM(require("path"));
|
|
16173
16314
|
var https6 = __toESM(require("https"));
|
|
16174
16315
|
var import_node_child_process17 = require("child_process");
|
|
16175
16316
|
var import_picocolors3 = __toESM(require("picocolors"));
|
|
@@ -16178,12 +16319,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
|
|
|
16178
16319
|
var TTL_MS = 24 * 60 * 60 * 1e3;
|
|
16179
16320
|
var REQUEST_TIMEOUT_MS = 1500;
|
|
16180
16321
|
function cachePath() {
|
|
16181
|
-
const dir =
|
|
16182
|
-
return
|
|
16322
|
+
const dir = path41.join(os33.homedir(), ".codeam");
|
|
16323
|
+
return path41.join(dir, "update-check.json");
|
|
16183
16324
|
}
|
|
16184
16325
|
function readCache() {
|
|
16185
16326
|
try {
|
|
16186
|
-
const raw =
|
|
16327
|
+
const raw = fs38.readFileSync(cachePath(), "utf8");
|
|
16187
16328
|
const parsed = JSON.parse(raw);
|
|
16188
16329
|
if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
|
|
16189
16330
|
return parsed;
|
|
@@ -16194,10 +16335,10 @@ function readCache() {
|
|
|
16194
16335
|
function writeCache(cache) {
|
|
16195
16336
|
try {
|
|
16196
16337
|
const file = cachePath();
|
|
16197
|
-
|
|
16338
|
+
fs38.mkdirSync(path41.dirname(file), { recursive: true });
|
|
16198
16339
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
16199
|
-
|
|
16200
|
-
|
|
16340
|
+
fs38.writeFileSync(tmp, JSON.stringify(cache));
|
|
16341
|
+
fs38.renameSync(tmp, file);
|
|
16201
16342
|
} catch {
|
|
16202
16343
|
}
|
|
16203
16344
|
}
|
|
@@ -16271,8 +16412,8 @@ function isLinkedInstall() {
|
|
|
16271
16412
|
timeout: 2e3
|
|
16272
16413
|
}).trim();
|
|
16273
16414
|
if (!root) return false;
|
|
16274
|
-
const pkgPath =
|
|
16275
|
-
return
|
|
16415
|
+
const pkgPath = path41.join(root, PKG_NAME);
|
|
16416
|
+
return fs38.lstatSync(pkgPath).isSymbolicLink();
|
|
16276
16417
|
} catch {
|
|
16277
16418
|
return false;
|
|
16278
16419
|
}
|
|
@@ -16308,7 +16449,7 @@ function maybeAutoUpdate(currentVersion, latest) {
|
|
|
16308
16449
|
return;
|
|
16309
16450
|
}
|
|
16310
16451
|
try {
|
|
16311
|
-
|
|
16452
|
+
fs38.unlinkSync(cachePath());
|
|
16312
16453
|
} catch {
|
|
16313
16454
|
}
|
|
16314
16455
|
process.stderr.write(` ${import_picocolors3.default.green("\u2713")} Updated. Resuming session...
|
|
@@ -16324,7 +16465,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
16324
16465
|
if (process.env.NODE_ENV === "test") return;
|
|
16325
16466
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
16326
16467
|
if (process.env.CI) return;
|
|
16327
|
-
const current = true ? "2.60.
|
|
16468
|
+
const current = true ? "2.60.17" : null;
|
|
16328
16469
|
if (!current) return;
|
|
16329
16470
|
const cache = readCache();
|
|
16330
16471
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -16341,7 +16482,7 @@ function checkForUpdates() {
|
|
|
16341
16482
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
16342
16483
|
if (process.env.CI) return;
|
|
16343
16484
|
if (!process.stdout.isTTY) return;
|
|
16344
|
-
const current = true ? "2.60.
|
|
16485
|
+
const current = true ? "2.60.17" : null;
|
|
16345
16486
|
if (!current) return;
|
|
16346
16487
|
const cache = readCache();
|
|
16347
16488
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -16361,7 +16502,7 @@ var SELF_UPDATE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
|
16361
16502
|
var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
|
|
16362
16503
|
var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
16363
16504
|
function currentCliVersion() {
|
|
16364
|
-
return true ? "2.60.
|
|
16505
|
+
return true ? "2.60.17" : null;
|
|
16365
16506
|
}
|
|
16366
16507
|
function runCmd(cmd, args2, timeoutMs) {
|
|
16367
16508
|
return new Promise((resolve7) => {
|
|
@@ -16428,7 +16569,7 @@ async function runSelfUpdate() {
|
|
|
16428
16569
|
|
|
16429
16570
|
// src/commands/host/teardown.ts
|
|
16430
16571
|
var import_node_child_process19 = require("child_process");
|
|
16431
|
-
var
|
|
16572
|
+
var fs39 = __toESM(require("fs"));
|
|
16432
16573
|
var defaultDisableService = () => {
|
|
16433
16574
|
try {
|
|
16434
16575
|
(0, import_node_child_process19.execFileSync)("systemctl", ["disable", "--now", "codeam-host-agent"], { stdio: "ignore" });
|
|
@@ -16437,7 +16578,7 @@ var defaultDisableService = () => {
|
|
|
16437
16578
|
};
|
|
16438
16579
|
var defaultTeardownHeadroom = () => {
|
|
16439
16580
|
try {
|
|
16440
|
-
const kind = JSON.parse(
|
|
16581
|
+
const kind = JSON.parse(fs39.readFileSync(headroomConfigPath(), "utf8")).agent;
|
|
16441
16582
|
if (kind) {
|
|
16442
16583
|
(0, import_node_child_process19.execFileSync)("headroom", ["unwrap", kind], { stdio: "ignore", timeout: 15e3 });
|
|
16443
16584
|
}
|
|
@@ -16505,8 +16646,8 @@ function maybeResumeLocalHeadroomReporter(ctx) {
|
|
|
16505
16646
|
if (process.env["HEADROOM_ENABLED"] === "1") return null;
|
|
16506
16647
|
try {
|
|
16507
16648
|
const file = headroomConfigPath();
|
|
16508
|
-
if (!
|
|
16509
|
-
const cfg = JSON.parse(
|
|
16649
|
+
if (!fs40.existsSync(file)) return null;
|
|
16650
|
+
const cfg = JSON.parse(fs40.readFileSync(file, "utf8"));
|
|
16510
16651
|
if (!cfg?.enabled) return null;
|
|
16511
16652
|
const agent = cfg.agent ?? "claude";
|
|
16512
16653
|
const ingestUrl = `${resolveApiBaseUrl()}/api/sessions/${ctx.sessionId}/headroom-savings`;
|
|
@@ -16911,9 +17052,9 @@ var HostAgentSupervisor = class {
|
|
|
16911
17052
|
API_TIMEOUT_MS: "3000000",
|
|
16912
17053
|
CODEAM_AUTO_TOKEN: payload.autoPairToken
|
|
16913
17054
|
};
|
|
16914
|
-
const houseConfigDir =
|
|
17055
|
+
const houseConfigDir = path42.join(os34.homedir(), ".codeam", "house-claude");
|
|
16915
17056
|
try {
|
|
16916
|
-
|
|
17057
|
+
fs40.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
|
|
16917
17058
|
} catch {
|
|
16918
17059
|
}
|
|
16919
17060
|
childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
|
|
@@ -16931,14 +17072,14 @@ var HostAgentSupervisor = class {
|
|
|
16931
17072
|
report("installing", "installing agent CLI");
|
|
16932
17073
|
await this.runAgentInstall(payload.agentInstallScript);
|
|
16933
17074
|
}
|
|
16934
|
-
const home = process.env.HOME ||
|
|
17075
|
+
const home = process.env.HOME || os34.homedir();
|
|
16935
17076
|
childEnv.PATH = `${home}/.local/bin:${process.env.PATH ?? ""}`;
|
|
16936
17077
|
if (payload.cloneToken) {
|
|
16937
17078
|
try {
|
|
16938
17079
|
report("preparing", "configuring git tooling");
|
|
16939
17080
|
const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
|
|
16940
17081
|
if (ghCmd) {
|
|
16941
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
17082
|
+
childEnv.PATH = `${codeamBinDir()}${path42.delimiter}${childEnv.PATH}`;
|
|
16942
17083
|
await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
|
|
16943
17084
|
}
|
|
16944
17085
|
} catch (e) {
|
|
@@ -16954,7 +17095,7 @@ var HostAgentSupervisor = class {
|
|
|
16954
17095
|
}
|
|
16955
17096
|
if (payload.headroomEnabled && payload.headroomAgent && payload.headroomSavingsIngestUrl && isHeadroomSupportedAgent(payload.headroomAgent)) {
|
|
16956
17097
|
report("headroom", "setting up Headroom proxy");
|
|
16957
|
-
const freeBytes = await this.getFreeDisk(
|
|
17098
|
+
const freeBytes = await this.getFreeDisk(os34.homedir());
|
|
16958
17099
|
const alreadyInstalled = this.isHeadroomInstalled();
|
|
16959
17100
|
if (!alreadyInstalled && freeBytes !== null && freeBytes < HEADROOM_MIN_FREE_DISK_BYTES) {
|
|
16960
17101
|
const freeGb = (freeBytes / 1e9).toFixed(1);
|
|
@@ -17076,7 +17217,7 @@ var HostAgentSupervisor = class {
|
|
|
17076
17217
|
*/
|
|
17077
17218
|
runAgentInstall(script) {
|
|
17078
17219
|
return new Promise((resolve7) => {
|
|
17079
|
-
const home = process.env.HOME ||
|
|
17220
|
+
const home = process.env.HOME || os34.homedir();
|
|
17080
17221
|
const child = (0, import_node_child_process20.spawn)("sh", ["-c", script], {
|
|
17081
17222
|
env: { ...process.env, HOME: home },
|
|
17082
17223
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -17260,9 +17401,9 @@ async function configureHeadroom(action, ctx, deps) {
|
|
|
17260
17401
|
}
|
|
17261
17402
|
|
|
17262
17403
|
// src/services/headroom/budget-relaunch.ts
|
|
17263
|
-
var
|
|
17264
|
-
var
|
|
17265
|
-
var
|
|
17404
|
+
var fs41 = __toESM(require("fs"));
|
|
17405
|
+
var os35 = __toESM(require("os"));
|
|
17406
|
+
var path43 = __toESM(require("path"));
|
|
17266
17407
|
var import_child_process13 = require("child_process");
|
|
17267
17408
|
function amendDeploymentManifestBudget(manifest, budget) {
|
|
17268
17409
|
const rawArgs = manifest.proxy_args ?? [];
|
|
@@ -17296,7 +17437,7 @@ function amendDeploymentManifestBudget(manifest, budget) {
|
|
|
17296
17437
|
return { ...manifest, proxy_args: newArgs, base_env: newEnv };
|
|
17297
17438
|
}
|
|
17298
17439
|
function findHeadroomDeployments(homeDir2, deps) {
|
|
17299
|
-
const deployDir =
|
|
17440
|
+
const deployDir = path43.join(homeDir2, ".headroom", "deploy");
|
|
17300
17441
|
let profiles;
|
|
17301
17442
|
try {
|
|
17302
17443
|
profiles = deps.readDir(deployDir);
|
|
@@ -17305,7 +17446,7 @@ function findHeadroomDeployments(homeDir2, deps) {
|
|
|
17305
17446
|
}
|
|
17306
17447
|
const results = [];
|
|
17307
17448
|
for (const profile of profiles) {
|
|
17308
|
-
const manifestPath =
|
|
17449
|
+
const manifestPath = path43.join(deployDir, profile, "manifest.json");
|
|
17309
17450
|
let raw;
|
|
17310
17451
|
try {
|
|
17311
17452
|
raw = deps.readJson(manifestPath);
|
|
@@ -17337,8 +17478,8 @@ async function applyBudgetToHeadroom(budget, deps) {
|
|
|
17337
17478
|
}
|
|
17338
17479
|
function writeManifestReal(manifestPath, manifest) {
|
|
17339
17480
|
const tmp = manifestPath + ".codeam.tmp";
|
|
17340
|
-
|
|
17341
|
-
|
|
17481
|
+
fs41.writeFileSync(tmp, JSON.stringify(manifest, null, 2) + "\n", { mode: 384 });
|
|
17482
|
+
fs41.renameSync(tmp, manifestPath);
|
|
17342
17483
|
}
|
|
17343
17484
|
function restartDeploymentReal(profile) {
|
|
17344
17485
|
try {
|
|
@@ -17368,11 +17509,11 @@ function spawnProxyReal2(_budget) {
|
|
|
17368
17509
|
});
|
|
17369
17510
|
}
|
|
17370
17511
|
function makeRealApplyBudgetDeps() {
|
|
17371
|
-
const homeDir2 =
|
|
17512
|
+
const homeDir2 = os35.homedir();
|
|
17372
17513
|
return {
|
|
17373
17514
|
findDeployments: () => findHeadroomDeployments(homeDir2, {
|
|
17374
|
-
readDir: (dir) =>
|
|
17375
|
-
readJson: (filePath) => JSON.parse(
|
|
17515
|
+
readDir: (dir) => fs41.readdirSync(dir),
|
|
17516
|
+
readJson: (filePath) => JSON.parse(fs41.readFileSync(filePath, "utf8"))
|
|
17376
17517
|
}),
|
|
17377
17518
|
writeManifest: writeManifestReal,
|
|
17378
17519
|
restartDeployment: restartDeploymentReal,
|
|
@@ -18052,8 +18193,8 @@ function activePreviewSessionIds() {
|
|
|
18052
18193
|
|
|
18053
18194
|
// src/services/preview/start-orchestrator.ts
|
|
18054
18195
|
var import_child_process17 = require("child_process");
|
|
18055
|
-
var
|
|
18056
|
-
var
|
|
18196
|
+
var fs46 = __toESM(require("fs"));
|
|
18197
|
+
var path48 = __toESM(require("path"));
|
|
18057
18198
|
var import_which2 = __toESM(require("which"));
|
|
18058
18199
|
var INSTALL_TIMEOUT_MS = 5 * 6e4;
|
|
18059
18200
|
var SETUP_TIMEOUT_MS = 2 * 6e4;
|
|
@@ -18120,8 +18261,8 @@ function normalizeDetectionForSpawn(detection, cwd) {
|
|
|
18120
18261
|
if (args2.length === 0) return detection;
|
|
18121
18262
|
const binName = args2[0];
|
|
18122
18263
|
if (binName.startsWith("-")) return detection;
|
|
18123
|
-
const binPath =
|
|
18124
|
-
if (!
|
|
18264
|
+
const binPath = path48.join(cwd, "node_modules", ".bin", binName);
|
|
18265
|
+
if (!fs46.existsSync(binPath)) return detection;
|
|
18125
18266
|
return {
|
|
18126
18267
|
...detection,
|
|
18127
18268
|
command: binPath,
|
|
@@ -18471,9 +18612,9 @@ async function establishTunnel(ctx, dev) {
|
|
|
18471
18612
|
|
|
18472
18613
|
// src/beads/bd-adapter.ts
|
|
18473
18614
|
var import_child_process18 = require("child_process");
|
|
18474
|
-
var
|
|
18475
|
-
var
|
|
18476
|
-
var
|
|
18615
|
+
var fs47 = __toESM(require("fs"));
|
|
18616
|
+
var os37 = __toESM(require("os"));
|
|
18617
|
+
var path49 = __toESM(require("path"));
|
|
18477
18618
|
var BD_PACKAGE = "@beads/bd";
|
|
18478
18619
|
function resolveBundledBdBinary() {
|
|
18479
18620
|
return _resolveSeam.resolveBundled();
|
|
@@ -18485,11 +18626,11 @@ function _defaultResolveBundled() {
|
|
|
18485
18626
|
} catch {
|
|
18486
18627
|
return null;
|
|
18487
18628
|
}
|
|
18488
|
-
const binDir =
|
|
18629
|
+
const binDir = path49.join(path49.dirname(pkgJsonPath), "bin");
|
|
18489
18630
|
const binaryName = process.platform === "win32" ? "bd.exe" : "bd";
|
|
18490
|
-
const binaryPath =
|
|
18631
|
+
const binaryPath = path49.join(binDir, binaryName);
|
|
18491
18632
|
try {
|
|
18492
|
-
|
|
18633
|
+
fs47.accessSync(binaryPath, fs47.constants.F_OK);
|
|
18493
18634
|
return binaryPath;
|
|
18494
18635
|
} catch {
|
|
18495
18636
|
return null;
|
|
@@ -18499,13 +18640,13 @@ function resolveBdOnPath() {
|
|
|
18499
18640
|
return _resolveSeam.resolveOnPath();
|
|
18500
18641
|
}
|
|
18501
18642
|
function _defaultResolveOnPath() {
|
|
18502
|
-
const dirs = (process.env.PATH ?? "").split(
|
|
18643
|
+
const dirs = (process.env.PATH ?? "").split(path49.delimiter).filter(Boolean);
|
|
18503
18644
|
const candidates = process.platform === "win32" ? ["bd.exe", "bd.cmd", "bd"] : ["bd"];
|
|
18504
18645
|
for (const dir of dirs) {
|
|
18505
18646
|
for (const candidate of candidates) {
|
|
18506
|
-
const full =
|
|
18647
|
+
const full = path49.join(dir, candidate);
|
|
18507
18648
|
try {
|
|
18508
|
-
|
|
18649
|
+
fs47.accessSync(full, fs47.constants.F_OK);
|
|
18509
18650
|
return full;
|
|
18510
18651
|
} catch {
|
|
18511
18652
|
}
|
|
@@ -18590,7 +18731,7 @@ var BdAdapter = class {
|
|
|
18590
18731
|
const env = { ...process.env };
|
|
18591
18732
|
if (!env.HOME) {
|
|
18592
18733
|
try {
|
|
18593
|
-
const home =
|
|
18734
|
+
const home = os37.homedir();
|
|
18594
18735
|
if (home) env.HOME = home;
|
|
18595
18736
|
} catch {
|
|
18596
18737
|
}
|
|
@@ -18682,9 +18823,9 @@ function coerceIssue(row, projectKey) {
|
|
|
18682
18823
|
|
|
18683
18824
|
// src/beads/provisioner.ts
|
|
18684
18825
|
var import_child_process22 = require("child_process");
|
|
18685
|
-
var
|
|
18686
|
-
var
|
|
18687
|
-
var
|
|
18826
|
+
var fs50 = __toESM(require("fs"));
|
|
18827
|
+
var os39 = __toESM(require("os"));
|
|
18828
|
+
var path52 = __toESM(require("path"));
|
|
18688
18829
|
|
|
18689
18830
|
// src/beads/install-bd.ts
|
|
18690
18831
|
var import_child_process19 = require("child_process");
|
|
@@ -18749,9 +18890,9 @@ async function installBd(platform3 = process.platform) {
|
|
|
18749
18890
|
|
|
18750
18891
|
// src/beads/install-dolt.ts
|
|
18751
18892
|
var import_child_process20 = require("child_process");
|
|
18752
|
-
var
|
|
18753
|
-
var
|
|
18754
|
-
var
|
|
18893
|
+
var fs48 = __toESM(require("fs"));
|
|
18894
|
+
var os38 = __toESM(require("os"));
|
|
18895
|
+
var path50 = __toESM(require("path"));
|
|
18755
18896
|
var DOLT_INSTALL_SH_URL = "https://github.com/dolthub/dolt/releases/latest/download/install.sh";
|
|
18756
18897
|
var DOLT_MSI_URL = "https://github.com/dolthub/dolt/releases/latest/download/dolt-windows-amd64.msi";
|
|
18757
18898
|
function resolveDoltInstallStrategy(platform3) {
|
|
@@ -18791,11 +18932,11 @@ function resolveDoltInstallStrategy(platform3) {
|
|
|
18791
18932
|
}
|
|
18792
18933
|
var DOLT_RELEASE_BASE = "https://github.com/dolthub/dolt/releases/latest/download";
|
|
18793
18934
|
function doltPlatformTuple(platform3, arch2) {
|
|
18794
|
-
const
|
|
18935
|
+
const os49 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
|
|
18795
18936
|
const a = arch2 === "x64" ? "amd64" : arch2 === "arm64" ? "arm64" : null;
|
|
18796
18937
|
if (!a) return null;
|
|
18797
|
-
if (
|
|
18798
|
-
return `${
|
|
18938
|
+
if (os49 === "windows" && a !== "amd64") return null;
|
|
18939
|
+
return `${os49}-${a}`;
|
|
18799
18940
|
}
|
|
18800
18941
|
function resolveDoltTarballStrategy(targetDir, platform3, arch2) {
|
|
18801
18942
|
const tuple = doltPlatformTuple(platform3, arch2);
|
|
@@ -18840,14 +18981,14 @@ async function installDoltToDir(targetDir, platform3 = process.platform, arch2 =
|
|
|
18840
18981
|
return result;
|
|
18841
18982
|
}
|
|
18842
18983
|
var _doltPathSeam = {
|
|
18843
|
-
homedir: () =>
|
|
18984
|
+
homedir: () => os38.homedir(),
|
|
18844
18985
|
getPath: () => process.env.PATH ?? "",
|
|
18845
18986
|
setPath: (p2) => {
|
|
18846
18987
|
process.env.PATH = p2;
|
|
18847
18988
|
},
|
|
18848
18989
|
exists: (p2) => {
|
|
18849
18990
|
try {
|
|
18850
|
-
|
|
18991
|
+
fs48.accessSync(p2, fs48.constants.F_OK);
|
|
18851
18992
|
return true;
|
|
18852
18993
|
} catch {
|
|
18853
18994
|
return false;
|
|
@@ -18858,7 +18999,7 @@ function doltBinaryNames(platform3) {
|
|
|
18858
18999
|
return platform3 === "win32" ? ["dolt.exe", "dolt.cmd", "dolt"] : ["dolt"];
|
|
18859
19000
|
}
|
|
18860
19001
|
function knownDoltDirs(platform3) {
|
|
18861
|
-
const P3 = platform3 === "win32" ?
|
|
19002
|
+
const P3 = platform3 === "win32" ? path50.win32 : path50.posix;
|
|
18862
19003
|
const home = _doltPathSeam.homedir();
|
|
18863
19004
|
if (platform3 === "win32") {
|
|
18864
19005
|
return [
|
|
@@ -18874,7 +19015,7 @@ function knownDoltDirs(platform3) {
|
|
|
18874
19015
|
].filter(Boolean);
|
|
18875
19016
|
}
|
|
18876
19017
|
function ensureDoltResolvable(platform3 = process.platform) {
|
|
18877
|
-
const P3 = platform3 === "win32" ?
|
|
19018
|
+
const P3 = platform3 === "win32" ? path50.win32 : path50.posix;
|
|
18878
19019
|
const delim = platform3 === "win32" ? ";" : ":";
|
|
18879
19020
|
const names = doltBinaryNames(platform3);
|
|
18880
19021
|
const pathDirs = _doltPathSeam.getPath().split(delim).filter(Boolean);
|
|
@@ -19010,8 +19151,8 @@ async function ensureSharedServer(adapter, options = {}) {
|
|
|
19010
19151
|
// src/beads/project-key.ts
|
|
19011
19152
|
var import_child_process21 = require("child_process");
|
|
19012
19153
|
var crypto2 = __toESM(require("crypto"));
|
|
19013
|
-
var
|
|
19014
|
-
var
|
|
19154
|
+
var fs49 = __toESM(require("fs"));
|
|
19155
|
+
var path51 = __toESM(require("path"));
|
|
19015
19156
|
function normalizeOrigin(raw) {
|
|
19016
19157
|
const trimmed = raw.trim();
|
|
19017
19158
|
if (!trimmed) return null;
|
|
@@ -19037,17 +19178,17 @@ function normalizeOrigin(raw) {
|
|
|
19037
19178
|
return `${host2}/${pathPart}`;
|
|
19038
19179
|
}
|
|
19039
19180
|
function findRepoRoot(cwd) {
|
|
19040
|
-
let dir =
|
|
19181
|
+
let dir = path51.resolve(cwd);
|
|
19041
19182
|
const seen = /* @__PURE__ */ new Set();
|
|
19042
19183
|
for (let i = 0; i < 256; i++) {
|
|
19043
19184
|
if (seen.has(dir)) return null;
|
|
19044
19185
|
seen.add(dir);
|
|
19045
19186
|
try {
|
|
19046
|
-
const stat3 =
|
|
19187
|
+
const stat3 = fs49.statSync(path51.join(dir, ".git"), { throwIfNoEntry: false });
|
|
19047
19188
|
if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
|
|
19048
19189
|
} catch {
|
|
19049
19190
|
}
|
|
19050
|
-
const parent =
|
|
19191
|
+
const parent = path51.dirname(dir);
|
|
19051
19192
|
if (parent === dir) return null;
|
|
19052
19193
|
dir = parent;
|
|
19053
19194
|
}
|
|
@@ -19058,7 +19199,7 @@ var _execSeam2 = {
|
|
|
19058
19199
|
const out2 = (0, import_child_process21.execFileSync)(file, args2, opts);
|
|
19059
19200
|
return typeof out2 === "string" ? out2 : out2.toString("utf8");
|
|
19060
19201
|
},
|
|
19061
|
-
realpath: (p2) =>
|
|
19202
|
+
realpath: (p2) => fs49.realpathSync(p2)
|
|
19062
19203
|
};
|
|
19063
19204
|
function readOrigin(cwd) {
|
|
19064
19205
|
try {
|
|
@@ -19087,7 +19228,7 @@ function deriveProjectIdentity(cwd = process.cwd()) {
|
|
|
19087
19228
|
} catch {
|
|
19088
19229
|
}
|
|
19089
19230
|
const hash = crypto2.createHash("sha256").update(real).digest("hex");
|
|
19090
|
-
return { projectKey: `path:${hash}`, projectLabel:
|
|
19231
|
+
return { projectKey: `path:${hash}`, projectLabel: path51.basename(real) || "project" };
|
|
19091
19232
|
}
|
|
19092
19233
|
|
|
19093
19234
|
// src/beads/project-prefix.ts
|
|
@@ -19132,17 +19273,17 @@ var _provisionSeam = {
|
|
|
19132
19273
|
};
|
|
19133
19274
|
var _linkSeam = {
|
|
19134
19275
|
platform: () => process.platform,
|
|
19135
|
-
homedir: () =>
|
|
19276
|
+
homedir: () => os39.homedir(),
|
|
19136
19277
|
isWritableDir: (dir) => {
|
|
19137
19278
|
try {
|
|
19138
|
-
|
|
19279
|
+
fs50.accessSync(dir, fs50.constants.W_OK);
|
|
19139
19280
|
return true;
|
|
19140
19281
|
} catch {
|
|
19141
19282
|
return false;
|
|
19142
19283
|
}
|
|
19143
19284
|
},
|
|
19144
19285
|
ensureDir: (dir) => {
|
|
19145
|
-
|
|
19286
|
+
fs50.mkdirSync(dir, { recursive: true });
|
|
19146
19287
|
},
|
|
19147
19288
|
/**
|
|
19148
19289
|
* A directory to symlink `bd` into so the AGENT's shell + Claude Code's
|
|
@@ -19163,9 +19304,9 @@ var _linkSeam = {
|
|
|
19163
19304
|
* which `linkBdOntoPath` creates if missing.
|
|
19164
19305
|
*/
|
|
19165
19306
|
cliBinDir: () => {
|
|
19166
|
-
const pathDirs = (process.env.PATH ?? "").split(
|
|
19307
|
+
const pathDirs = (process.env.PATH ?? "").split(path52.delimiter).filter(Boolean);
|
|
19167
19308
|
const home = _linkSeam.homedir();
|
|
19168
|
-
const localBin = home ?
|
|
19309
|
+
const localBin = home ? path52.join(home, ".local", "bin") : null;
|
|
19169
19310
|
if (localBin) {
|
|
19170
19311
|
try {
|
|
19171
19312
|
_linkSeam.ensureDir(localBin);
|
|
@@ -19175,16 +19316,16 @@ var _linkSeam = {
|
|
|
19175
19316
|
const candidates = [];
|
|
19176
19317
|
if (localBin) candidates.push(localBin);
|
|
19177
19318
|
try {
|
|
19178
|
-
candidates.push(
|
|
19319
|
+
candidates.push(path52.dirname(process.execPath));
|
|
19179
19320
|
} catch {
|
|
19180
19321
|
}
|
|
19181
19322
|
candidates.push("/usr/local/bin");
|
|
19182
19323
|
const entry = process.argv[1];
|
|
19183
19324
|
if (entry) {
|
|
19184
19325
|
try {
|
|
19185
|
-
candidates.push(
|
|
19326
|
+
candidates.push(path52.dirname(fs50.realpathSync(entry)));
|
|
19186
19327
|
} catch {
|
|
19187
|
-
candidates.push(
|
|
19328
|
+
candidates.push(path52.dirname(entry));
|
|
19188
19329
|
}
|
|
19189
19330
|
}
|
|
19190
19331
|
const onPathWritable = candidates.find(
|
|
@@ -19196,20 +19337,20 @@ var _linkSeam = {
|
|
|
19196
19337
|
/** Current symlink target at `linkPath`, or null when absent / not a link. */
|
|
19197
19338
|
readlink: (linkPath) => {
|
|
19198
19339
|
try {
|
|
19199
|
-
return
|
|
19340
|
+
return fs50.readlinkSync(linkPath);
|
|
19200
19341
|
} catch {
|
|
19201
19342
|
return null;
|
|
19202
19343
|
}
|
|
19203
19344
|
},
|
|
19204
|
-
unlink: (linkPath) =>
|
|
19205
|
-
symlink: (target, linkPath) =>
|
|
19345
|
+
unlink: (linkPath) => fs50.unlinkSync(linkPath),
|
|
19346
|
+
symlink: (target, linkPath) => fs50.symlinkSync(target, linkPath)
|
|
19206
19347
|
};
|
|
19207
19348
|
function linkBdOntoPath(binaryPath) {
|
|
19208
19349
|
if (_linkSeam.platform() === "win32") return;
|
|
19209
19350
|
const binDir = _linkSeam.cliBinDir();
|
|
19210
19351
|
if (!binDir) return;
|
|
19211
19352
|
_linkSeam.ensureDir(binDir);
|
|
19212
|
-
const linkPath =
|
|
19353
|
+
const linkPath = path52.join(binDir, "bd");
|
|
19213
19354
|
if (linkPath === binaryPath) return;
|
|
19214
19355
|
const current = _linkSeam.readlink(linkPath);
|
|
19215
19356
|
if (current === binaryPath) return;
|
|
@@ -19404,7 +19545,7 @@ function dedupeRecipes(agents) {
|
|
|
19404
19545
|
|
|
19405
19546
|
// src/beads/watcher.ts
|
|
19406
19547
|
var crypto4 = __toESM(require("crypto"));
|
|
19407
|
-
var
|
|
19548
|
+
var path53 = __toESM(require("path"));
|
|
19408
19549
|
var API_BASE6 = resolveApiBaseUrl();
|
|
19409
19550
|
var DEBOUNCE_MS2 = 400;
|
|
19410
19551
|
var ZERO_SUMMARY = {
|
|
@@ -19428,7 +19569,7 @@ var BeadsWatcher = class {
|
|
|
19428
19569
|
constructor(opts) {
|
|
19429
19570
|
this.opts = opts;
|
|
19430
19571
|
this.bd = opts.adapter ?? new BdAdapter({ cwd: opts.cwd, beadsDir: opts.beadsDir });
|
|
19431
|
-
this.feedPath = opts.feedPath ??
|
|
19572
|
+
this.feedPath = opts.feedPath ?? path53.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
|
|
19432
19573
|
this.apiBase = opts.apiBaseUrl ?? API_BASE6;
|
|
19433
19574
|
}
|
|
19434
19575
|
opts;
|
|
@@ -19845,8 +19986,8 @@ function cleanupAttachmentTempFiles() {
|
|
|
19845
19986
|
function saveFilesTemp(files) {
|
|
19846
19987
|
return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
|
|
19847
19988
|
const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
|
|
19848
|
-
const tmpPath =
|
|
19849
|
-
|
|
19989
|
+
const tmpPath = path55.join(os41.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
|
|
19990
|
+
fs52.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
|
|
19850
19991
|
pendingAttachmentFiles.add(tmpPath);
|
|
19851
19992
|
return tmpPath;
|
|
19852
19993
|
});
|
|
@@ -20058,9 +20199,9 @@ var listFiles = async (ctx, cmd, parsed) => {
|
|
|
20058
20199
|
await ctx.relay.sendResult(cmd.id, "completed", result);
|
|
20059
20200
|
};
|
|
20060
20201
|
var envReadH = async (ctx, cmd) => {
|
|
20061
|
-
const envPath =
|
|
20202
|
+
const envPath = path55.join(process.cwd(), ".env");
|
|
20062
20203
|
try {
|
|
20063
|
-
const raw = await
|
|
20204
|
+
const raw = await fs52.promises.readFile(envPath, "utf8");
|
|
20064
20205
|
await ctx.relay.sendResult(cmd.id, "completed", {
|
|
20065
20206
|
exists: true,
|
|
20066
20207
|
vars: parseDotenv(raw)
|
|
@@ -20091,14 +20232,14 @@ var envWriteH = async (ctx, cmd, parsed) => {
|
|
|
20091
20232
|
}
|
|
20092
20233
|
seen.add(v.key);
|
|
20093
20234
|
}
|
|
20094
|
-
const envPath =
|
|
20095
|
-
const tmpPath =
|
|
20235
|
+
const envPath = path55.join(process.cwd(), ".env");
|
|
20236
|
+
const tmpPath = path55.join(process.cwd(), ".env.codeam.tmp");
|
|
20096
20237
|
try {
|
|
20097
|
-
await
|
|
20098
|
-
await
|
|
20238
|
+
await fs52.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
|
|
20239
|
+
await fs52.promises.rename(tmpPath, envPath);
|
|
20099
20240
|
await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
|
|
20100
20241
|
} catch (err) {
|
|
20101
|
-
await
|
|
20242
|
+
await fs52.promises.rm(tmpPath, { force: true }).catch(() => void 0);
|
|
20102
20243
|
await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
|
|
20103
20244
|
}
|
|
20104
20245
|
};
|
|
@@ -20142,7 +20283,7 @@ var headroomConfigureH = async (ctx, cmd, parsed) => {
|
|
|
20142
20283
|
let configuredAgent = rawAgentId;
|
|
20143
20284
|
if (!configuredAgent) {
|
|
20144
20285
|
try {
|
|
20145
|
-
const raw = JSON.parse(
|
|
20286
|
+
const raw = JSON.parse(fs52.readFileSync(headroomConfigPath(), "utf8"));
|
|
20146
20287
|
configuredAgent = raw.agent ?? "";
|
|
20147
20288
|
} catch {
|
|
20148
20289
|
}
|
|
@@ -20176,7 +20317,7 @@ var headroomConfigureH = async (ctx, cmd, parsed) => {
|
|
|
20176
20317
|
persist: persistHeadroomConfig,
|
|
20177
20318
|
readEnabled: () => {
|
|
20178
20319
|
try {
|
|
20179
|
-
const raw = JSON.parse(
|
|
20320
|
+
const raw = JSON.parse(fs52.readFileSync(headroomConfigPath(), "utf8"));
|
|
20180
20321
|
return raw.enabled === true;
|
|
20181
20322
|
} catch {
|
|
20182
20323
|
return false;
|
|
@@ -20265,7 +20406,7 @@ var headroomBudgetH = async (ctx, cmd) => {
|
|
|
20265
20406
|
}
|
|
20266
20407
|
let headroomActive = false;
|
|
20267
20408
|
try {
|
|
20268
|
-
const raw = JSON.parse(
|
|
20409
|
+
const raw = JSON.parse(fs52.readFileSync(headroomConfigPath(), "utf8"));
|
|
20269
20410
|
headroomActive = raw.enabled === true;
|
|
20270
20411
|
} catch {
|
|
20271
20412
|
}
|
|
@@ -20275,7 +20416,7 @@ var headroomBudgetH = async (ctx, cmd) => {
|
|
|
20275
20416
|
}
|
|
20276
20417
|
let existingConfig = { enabled: true };
|
|
20277
20418
|
try {
|
|
20278
|
-
existingConfig = JSON.parse(
|
|
20419
|
+
existingConfig = JSON.parse(fs52.readFileSync(headroomConfigPath(), "utf8"));
|
|
20279
20420
|
} catch {
|
|
20280
20421
|
}
|
|
20281
20422
|
if (payload.budgetEnabled && payload.budgetUsd != null) {
|
|
@@ -20388,13 +20529,13 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
|
|
|
20388
20529
|
function buildNpmInstallInvocation(opts) {
|
|
20389
20530
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
20390
20531
|
const execPath = opts?.execPath ?? process.execPath;
|
|
20391
|
-
const exists2 = opts?.existsSync ??
|
|
20392
|
-
const normalized = entryScript.split(
|
|
20532
|
+
const exists2 = opts?.existsSync ?? fs52.existsSync;
|
|
20533
|
+
const normalized = entryScript.split(path55.sep).join("/");
|
|
20393
20534
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
20394
20535
|
const markerIdx = normalized.indexOf(marker);
|
|
20395
20536
|
const prefix = markerIdx > 0 ? entryScript.slice(0, markerIdx) : null;
|
|
20396
|
-
const siblingNpm =
|
|
20397
|
-
|
|
20537
|
+
const siblingNpm = path55.join(
|
|
20538
|
+
path55.dirname(execPath),
|
|
20398
20539
|
process.platform === "win32" ? "npm.cmd" : "npm"
|
|
20399
20540
|
);
|
|
20400
20541
|
const command2 = exists2(siblingNpm) ? siblingNpm : "npm";
|
|
@@ -21236,11 +21377,11 @@ function resolveTokenValue(args2) {
|
|
|
21236
21377
|
}
|
|
21237
21378
|
const fileFlag = args2.find((a) => a.startsWith("--token-file="));
|
|
21238
21379
|
if (fileFlag) {
|
|
21239
|
-
const
|
|
21380
|
+
const path70 = fileFlag.slice("--token-file=".length);
|
|
21240
21381
|
try {
|
|
21241
|
-
const content =
|
|
21242
|
-
if (content.length === 0) fail(`--token-file ${
|
|
21243
|
-
rmIfExistsQuiet(
|
|
21382
|
+
const content = fs53.readFileSync(path70, "utf8").trim();
|
|
21383
|
+
if (content.length === 0) fail(`--token-file ${path70} is empty`);
|
|
21384
|
+
rmIfExistsQuiet(path70);
|
|
21244
21385
|
return content;
|
|
21245
21386
|
} catch (err) {
|
|
21246
21387
|
fail(`Could not read --token-file: ${err.message}`);
|
|
@@ -21269,7 +21410,7 @@ async function claimOnce(token, pluginId, pluginSecretHash) {
|
|
|
21269
21410
|
pluginId,
|
|
21270
21411
|
ideName: "codeam-cli (codespace)",
|
|
21271
21412
|
ideVersion: process.env.npm_package_version ?? "unknown",
|
|
21272
|
-
hostname:
|
|
21413
|
+
hostname: os42.hostname(),
|
|
21273
21414
|
codespaceName: process.env.CODESPACE_NAME ?? "",
|
|
21274
21415
|
// Current git branch of the codespace's working directory, so the
|
|
21275
21416
|
// backend can populate `PairedSession.branch` for the codespace pair.
|
|
@@ -21330,7 +21471,7 @@ async function claim(token, pluginId, pluginSecretHash) {
|
|
|
21330
21471
|
}
|
|
21331
21472
|
}
|
|
21332
21473
|
function pairAutoLockPath() {
|
|
21333
|
-
return
|
|
21474
|
+
return path56.join(os42.homedir(), ".codeam", "pair-auto.lock");
|
|
21334
21475
|
}
|
|
21335
21476
|
function isLivePairAuto(pid) {
|
|
21336
21477
|
if (!Number.isInteger(pid) || pid <= 0 || pid === process.pid) return false;
|
|
@@ -21340,7 +21481,7 @@ function isLivePairAuto(pid) {
|
|
|
21340
21481
|
if (e.code !== "EPERM") return false;
|
|
21341
21482
|
}
|
|
21342
21483
|
try {
|
|
21343
|
-
return
|
|
21484
|
+
return fs53.readFileSync(`/proc/${pid}/cmdline`, "utf8").includes("codeam");
|
|
21344
21485
|
} catch {
|
|
21345
21486
|
return true;
|
|
21346
21487
|
}
|
|
@@ -21350,24 +21491,24 @@ function isLiveCodeam(pid) {
|
|
|
21350
21491
|
}
|
|
21351
21492
|
function daemonLockPath(sessionId) {
|
|
21352
21493
|
const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
21353
|
-
return
|
|
21494
|
+
return path56.join(os42.homedir(), ".codeam", `daemon-${safe}.lock`);
|
|
21354
21495
|
}
|
|
21355
21496
|
function acquireDaemonLock(sessionId) {
|
|
21356
21497
|
const lockPath = daemonLockPath(sessionId);
|
|
21357
21498
|
try {
|
|
21358
|
-
|
|
21499
|
+
fs53.mkdirSync(path56.dirname(lockPath), { recursive: true });
|
|
21359
21500
|
try {
|
|
21360
|
-
|
|
21501
|
+
fs53.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
|
|
21361
21502
|
} catch (e) {
|
|
21362
21503
|
if (e.code !== "EEXIST") throw e;
|
|
21363
|
-
const holder = Number(
|
|
21504
|
+
const holder = Number(fs53.readFileSync(lockPath, "utf8").trim());
|
|
21364
21505
|
if (holder && holder !== process.pid && isLiveCodeam(holder)) return false;
|
|
21365
|
-
|
|
21506
|
+
fs53.writeFileSync(lockPath, String(process.pid));
|
|
21366
21507
|
}
|
|
21367
21508
|
const release3 = () => {
|
|
21368
21509
|
try {
|
|
21369
|
-
if (
|
|
21370
|
-
|
|
21510
|
+
if (fs53.existsSync(lockPath) && Number(fs53.readFileSync(lockPath, "utf8").trim()) === process.pid) {
|
|
21511
|
+
fs53.unlinkSync(lockPath);
|
|
21371
21512
|
}
|
|
21372
21513
|
} catch {
|
|
21373
21514
|
}
|
|
@@ -21389,19 +21530,19 @@ function acquireDaemonLock(sessionId) {
|
|
|
21389
21530
|
function acquireSingletonLock() {
|
|
21390
21531
|
const lockPath = pairAutoLockPath();
|
|
21391
21532
|
try {
|
|
21392
|
-
|
|
21533
|
+
fs53.mkdirSync(path56.dirname(lockPath), { recursive: true });
|
|
21393
21534
|
try {
|
|
21394
|
-
|
|
21535
|
+
fs53.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
|
|
21395
21536
|
} catch (e) {
|
|
21396
21537
|
if (e.code !== "EEXIST") throw e;
|
|
21397
|
-
const holder = Number(
|
|
21538
|
+
const holder = Number(fs53.readFileSync(lockPath, "utf8").trim());
|
|
21398
21539
|
if (isLivePairAuto(holder)) return false;
|
|
21399
|
-
|
|
21540
|
+
fs53.writeFileSync(lockPath, String(process.pid));
|
|
21400
21541
|
}
|
|
21401
21542
|
process.once("exit", () => {
|
|
21402
21543
|
try {
|
|
21403
|
-
if (
|
|
21404
|
-
|
|
21544
|
+
if (fs53.existsSync(lockPath) && Number(fs53.readFileSync(lockPath, "utf8").trim()) === process.pid) {
|
|
21545
|
+
fs53.unlinkSync(lockPath);
|
|
21405
21546
|
}
|
|
21406
21547
|
} catch {
|
|
21407
21548
|
}
|
|
@@ -21846,7 +21987,7 @@ var AgentService = class _AgentService {
|
|
|
21846
21987
|
};
|
|
21847
21988
|
|
|
21848
21989
|
// src/agents/acp/adapters.ts
|
|
21849
|
-
var
|
|
21990
|
+
var path58 = __toESM(require("path"));
|
|
21850
21991
|
|
|
21851
21992
|
// src/agents/acp/agent-binary.ts
|
|
21852
21993
|
var import_fs4 = __toESM(require("fs"));
|
|
@@ -21879,14 +22020,14 @@ function defaultSdkDir() {
|
|
|
21879
22020
|
return resolveSdkDirViaRequire();
|
|
21880
22021
|
}
|
|
21881
22022
|
function resolveClaudeNativeBinary(deps = {}) {
|
|
21882
|
-
const
|
|
22023
|
+
const existsSync26 = deps.existsSync ?? import_fs4.default.existsSync;
|
|
21883
22024
|
const platformKey = deps.platformKey ?? currentPlatformKey();
|
|
21884
22025
|
const sdkDir = deps.sdkDir !== void 0 ? deps.sdkDir : defaultSdkDir();
|
|
21885
22026
|
if (!sdkDir) return null;
|
|
21886
22027
|
const scopeDir = import_path8.default.dirname(sdkDir);
|
|
21887
22028
|
const binName = platformKey.startsWith("win32-") ? "claude.exe" : "claude";
|
|
21888
22029
|
const candidate = import_path8.default.join(scopeDir, `claude-agent-sdk-${platformKey}`, binName);
|
|
21889
|
-
return
|
|
22030
|
+
return existsSync26(candidate) ? candidate : null;
|
|
21890
22031
|
}
|
|
21891
22032
|
var realSleep = (ms) => new Promise((resolve7) => setTimeout(resolve7, ms));
|
|
21892
22033
|
async function waitForClaudeNativeBinary(opts = {}) {
|
|
@@ -21937,18 +22078,18 @@ async function waitForCommandOnPath(cmd, opts = {}) {
|
|
|
21937
22078
|
return check();
|
|
21938
22079
|
}
|
|
21939
22080
|
function resolveCursorAgentBinary(deps = {}) {
|
|
21940
|
-
const
|
|
22081
|
+
const existsSync26 = deps.existsSync ?? import_fs4.default.existsSync;
|
|
21941
22082
|
const platform3 = deps.platform ?? process.platform;
|
|
21942
22083
|
const env = deps.env ?? process.env;
|
|
21943
22084
|
if (platform3 === "win32") {
|
|
21944
22085
|
const localAppData = env.LOCALAPPDATA;
|
|
21945
22086
|
if (!localAppData) return null;
|
|
21946
22087
|
const exe = import_path8.default.win32.join(localAppData, "cursor-agent", "cursor-agent.exe");
|
|
21947
|
-
return
|
|
22088
|
+
return existsSync26(exe) ? exe : null;
|
|
21948
22089
|
}
|
|
21949
22090
|
const home = deps.homedir ?? import_os8.default.homedir();
|
|
21950
22091
|
const unix = import_path8.default.posix.join(home, ".local", "bin", "cursor-agent");
|
|
21951
|
-
return
|
|
22092
|
+
return existsSync26(unix) ? unix : null;
|
|
21952
22093
|
}
|
|
21953
22094
|
async function waitForCursorAgent(opts = {}) {
|
|
21954
22095
|
const timeoutMs = opts.timeoutMs ?? 18e4;
|
|
@@ -22019,6 +22160,66 @@ async function waitForAdapterModuleGraph(command2, args2, opts = {}) {
|
|
|
22019
22160
|
return false;
|
|
22020
22161
|
}
|
|
22021
22162
|
|
|
22163
|
+
// src/agents/kimi/installer.ts
|
|
22164
|
+
var import_node_child_process22 = require("child_process");
|
|
22165
|
+
var import_node_os6 = require("os");
|
|
22166
|
+
var import_node_path6 = require("path");
|
|
22167
|
+
var INSTALL_URL2 = "https://code.kimi.com/kimi-code/install.sh";
|
|
22168
|
+
function kimiBinDir() {
|
|
22169
|
+
return (0, import_node_path6.join)(process.env.KIMI_CODE_HOME || (0, import_node_path6.join)((0, import_node_os6.homedir)(), ".kimi-code"), "bin");
|
|
22170
|
+
}
|
|
22171
|
+
function kimiRuns() {
|
|
22172
|
+
const r = (0, import_node_child_process22.spawnSync)("kimi", ["--version"], { stdio: "ignore", timeout: 15e3 });
|
|
22173
|
+
return !r.error && r.status === 0;
|
|
22174
|
+
}
|
|
22175
|
+
function augmentPath2() {
|
|
22176
|
+
const dir = kimiBinDir();
|
|
22177
|
+
const parts = (process.env.PATH ?? "").split(":");
|
|
22178
|
+
if (!parts.includes(dir)) process.env.PATH = `${dir}:${process.env.PATH ?? ""}`;
|
|
22179
|
+
}
|
|
22180
|
+
async function runInstaller2() {
|
|
22181
|
+
return new Promise((resolve7) => {
|
|
22182
|
+
const proc = (0, import_node_child_process22.spawn)("sh", ["-c", `curl -fsSL ${INSTALL_URL2} | bash`], { stdio: "inherit" });
|
|
22183
|
+
proc.on("close", (code) => resolve7(code === 0));
|
|
22184
|
+
proc.on("error", () => resolve7(false));
|
|
22185
|
+
});
|
|
22186
|
+
}
|
|
22187
|
+
async function ensureKimiInstalled() {
|
|
22188
|
+
augmentPath2();
|
|
22189
|
+
if (kimiRuns()) return true;
|
|
22190
|
+
if (process.platform === "win32") {
|
|
22191
|
+
console.error(
|
|
22192
|
+
`
|
|
22193
|
+
\u2717 Kimi Code CLI on Windows requires WSL.
|
|
22194
|
+
Install it inside WSL (curl -fsSL ${INSTALL_URL2} | bash)
|
|
22195
|
+
then re-run \`codeam pair\`.
|
|
22196
|
+
`
|
|
22197
|
+
);
|
|
22198
|
+
return false;
|
|
22199
|
+
}
|
|
22200
|
+
console.log("\n Kimi Code CLI not found \u2014 installing via the official script\u2026\n");
|
|
22201
|
+
let ok = await runInstaller2();
|
|
22202
|
+
augmentPath2();
|
|
22203
|
+
if (ok && !kimiRuns()) {
|
|
22204
|
+
log.warn("kimi", "installed binary does not run (partial download?) \u2014 re-installing once");
|
|
22205
|
+
ok = await runInstaller2();
|
|
22206
|
+
augmentPath2();
|
|
22207
|
+
}
|
|
22208
|
+
if (!ok) {
|
|
22209
|
+
log.warn("kimi", "installer failed \u2014 Kimi will be reported as not installed");
|
|
22210
|
+
return false;
|
|
22211
|
+
}
|
|
22212
|
+
return kimiRuns();
|
|
22213
|
+
}
|
|
22214
|
+
|
|
22215
|
+
// src/baton/gate.ts
|
|
22216
|
+
function runtimeSupportsBaton(runtime) {
|
|
22217
|
+
return typeof runtime.resolveHistoryFile === "function";
|
|
22218
|
+
}
|
|
22219
|
+
function isLocalSession(env = process.env) {
|
|
22220
|
+
return env.CODESPACES !== "true" && env.CODEAM_AUTO_APPROVE !== "1" && env.HEADROOM_ENABLED !== "1" && !env.CODEAM_AUTO_TOKEN && !env.CODEAM_ENROLL_TOKEN;
|
|
22221
|
+
}
|
|
22222
|
+
|
|
22022
22223
|
// src/agents/acp/adapters.ts
|
|
22023
22224
|
var require_ = require;
|
|
22024
22225
|
function claudeBinaryWaiter(opts = {}) {
|
|
@@ -22028,13 +22229,13 @@ function resolveBin(pkgName, binName) {
|
|
|
22028
22229
|
try {
|
|
22029
22230
|
const manifestPath = require_.resolve(`${pkgName}/package.json`);
|
|
22030
22231
|
const manifest = require_(`${pkgName}/package.json`);
|
|
22031
|
-
const pkgDir =
|
|
22232
|
+
const pkgDir = path58.dirname(manifestPath);
|
|
22032
22233
|
const bin = manifest.bin;
|
|
22033
22234
|
if (!bin) return null;
|
|
22034
|
-
if (typeof bin === "string") return
|
|
22235
|
+
if (typeof bin === "string") return path58.resolve(pkgDir, bin);
|
|
22035
22236
|
const target = binName ?? Object.keys(bin)[0];
|
|
22036
22237
|
if (!target || !bin[target]) return null;
|
|
22037
|
-
return
|
|
22238
|
+
return path58.resolve(pkgDir, bin[target]);
|
|
22038
22239
|
} catch {
|
|
22039
22240
|
return null;
|
|
22040
22241
|
}
|
|
@@ -22115,7 +22316,15 @@ var REGISTRY = {
|
|
|
22115
22316
|
command: "kimi",
|
|
22116
22317
|
args: ["acp"],
|
|
22117
22318
|
requiresAgentBinary: "kimi",
|
|
22118
|
-
|
|
22319
|
+
// On a LOCAL `codeam pair` the CLI installs kimi ON DEMAND before spawning
|
|
22320
|
+
// (parity with the codespace bootstrap's KimiProvisioningStrategy) — so a
|
|
22321
|
+
// user who selected Kimi but hasn't installed the CLI doesn't hit a raw
|
|
22322
|
+
// `ENOENT — 'kimi' not found`. On a codespace/self-hosted box the backend
|
|
22323
|
+
// provisions it, so there we just wait for the binary to appear.
|
|
22324
|
+
waitForBinary: async (o) => {
|
|
22325
|
+
if (isLocalSession()) await ensureKimiInstalled();
|
|
22326
|
+
return waitForCommandOnPath("kimi", o);
|
|
22327
|
+
}
|
|
22119
22328
|
})
|
|
22120
22329
|
};
|
|
22121
22330
|
function getAcpAdapter(agent) {
|
|
@@ -22127,12 +22336,12 @@ function requiresAcp(agent) {
|
|
|
22127
22336
|
}
|
|
22128
22337
|
|
|
22129
22338
|
// src/agents/acp/runner.ts
|
|
22130
|
-
var
|
|
22339
|
+
var import_node_crypto9 = require("crypto");
|
|
22131
22340
|
|
|
22132
22341
|
// src/services/history.service.ts
|
|
22133
|
-
var
|
|
22134
|
-
var
|
|
22135
|
-
var
|
|
22342
|
+
var fs55 = __toESM(require("fs"));
|
|
22343
|
+
var path59 = __toESM(require("path"));
|
|
22344
|
+
var os44 = __toESM(require("os"));
|
|
22136
22345
|
var https7 = __toESM(require("https"));
|
|
22137
22346
|
var http6 = __toESM(require("http"));
|
|
22138
22347
|
var import_zod2 = require("zod");
|
|
@@ -22159,7 +22368,7 @@ function parseJsonl(filePath) {
|
|
|
22159
22368
|
const messages = [];
|
|
22160
22369
|
let raw;
|
|
22161
22370
|
try {
|
|
22162
|
-
raw =
|
|
22371
|
+
raw = fs55.readFileSync(filePath, "utf8");
|
|
22163
22372
|
} catch (err) {
|
|
22164
22373
|
if (err.code !== "ENOENT") {
|
|
22165
22374
|
log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
|
|
@@ -22300,7 +22509,7 @@ var HistoryService = class _HistoryService {
|
|
|
22300
22509
|
return this._quotaPercent === null || Date.now() - this._quotaFetchedAt > ttlMs;
|
|
22301
22510
|
}
|
|
22302
22511
|
get projectDir() {
|
|
22303
|
-
return this.runtime.resolveHistoryDir(this.cwd) ??
|
|
22512
|
+
return this.runtime.resolveHistoryDir(this.cwd) ?? path59.join(os44.homedir(), ".claude", "projects", encodeCwd(this.cwd));
|
|
22304
22513
|
}
|
|
22305
22514
|
/** Set the current Claude conversation ID (extracted from /cost command or session start) */
|
|
22306
22515
|
setCurrentConversationId(id) {
|
|
@@ -22312,7 +22521,7 @@ var HistoryService = class _HistoryService {
|
|
|
22312
22521
|
/** Return the current message count in the active conversation. */
|
|
22313
22522
|
getCurrentMessageCount() {
|
|
22314
22523
|
if (!this.currentConversationId) return 0;
|
|
22315
|
-
const filePath =
|
|
22524
|
+
const filePath = path59.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
22316
22525
|
return parseJsonl(filePath).length;
|
|
22317
22526
|
}
|
|
22318
22527
|
/**
|
|
@@ -22323,7 +22532,7 @@ var HistoryService = class _HistoryService {
|
|
|
22323
22532
|
const deadline = Date.now() + timeoutMs;
|
|
22324
22533
|
while (Date.now() < deadline) {
|
|
22325
22534
|
if (!this.currentConversationId) return null;
|
|
22326
|
-
const filePath =
|
|
22535
|
+
const filePath = path59.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
22327
22536
|
const messages = parseJsonl(filePath);
|
|
22328
22537
|
if (messages.length > previousCount) {
|
|
22329
22538
|
for (let i = messages.length - 1; i >= previousCount; i--) {
|
|
@@ -22349,16 +22558,16 @@ var HistoryService = class _HistoryService {
|
|
|
22349
22558
|
const dir = this.projectDir;
|
|
22350
22559
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
22351
22560
|
try {
|
|
22352
|
-
const files =
|
|
22561
|
+
const files = fs55.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
22353
22562
|
try {
|
|
22354
|
-
const stat3 =
|
|
22563
|
+
const stat3 = fs55.statSync(path59.join(dir, e.name));
|
|
22355
22564
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
22356
22565
|
} catch {
|
|
22357
22566
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
22358
22567
|
}
|
|
22359
22568
|
}).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
22360
22569
|
if (files.length > 0) {
|
|
22361
|
-
this.currentConversationId =
|
|
22570
|
+
this.currentConversationId = path59.basename(files[0].name, ".jsonl");
|
|
22362
22571
|
}
|
|
22363
22572
|
} catch {
|
|
22364
22573
|
}
|
|
@@ -22392,13 +22601,13 @@ var HistoryService = class _HistoryService {
|
|
|
22392
22601
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
22393
22602
|
let entries;
|
|
22394
22603
|
try {
|
|
22395
|
-
entries =
|
|
22604
|
+
entries = fs55.readdirSync(dir, { withFileTypes: true });
|
|
22396
22605
|
} catch {
|
|
22397
22606
|
return null;
|
|
22398
22607
|
}
|
|
22399
22608
|
const files = entries.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
22400
22609
|
try {
|
|
22401
|
-
const stat3 =
|
|
22610
|
+
const stat3 = fs55.statSync(path59.join(dir, e.name));
|
|
22402
22611
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
22403
22612
|
} catch {
|
|
22404
22613
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
@@ -22407,12 +22616,12 @@ var HistoryService = class _HistoryService {
|
|
|
22407
22616
|
if (files.length === 0) return null;
|
|
22408
22617
|
const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
|
|
22409
22618
|
if (!files.some((f) => f.name === targetFile)) return null;
|
|
22410
|
-
return this.extractUsageFromFile(
|
|
22619
|
+
return this.extractUsageFromFile(path59.join(dir, targetFile));
|
|
22411
22620
|
}
|
|
22412
22621
|
extractUsageFromFile(filePath) {
|
|
22413
22622
|
let raw;
|
|
22414
22623
|
try {
|
|
22415
|
-
raw =
|
|
22624
|
+
raw = fs55.readFileSync(filePath, "utf8");
|
|
22416
22625
|
} catch {
|
|
22417
22626
|
return null;
|
|
22418
22627
|
}
|
|
@@ -22457,9 +22666,9 @@ var HistoryService = class _HistoryService {
|
|
|
22457
22666
|
let totalCost = 0;
|
|
22458
22667
|
let files;
|
|
22459
22668
|
try {
|
|
22460
|
-
files =
|
|
22669
|
+
files = fs55.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
|
|
22461
22670
|
try {
|
|
22462
|
-
return
|
|
22671
|
+
return fs55.statSync(path59.join(projectDir, f)).mtimeMs >= monthStartMs;
|
|
22463
22672
|
} catch {
|
|
22464
22673
|
return false;
|
|
22465
22674
|
}
|
|
@@ -22470,7 +22679,7 @@ var HistoryService = class _HistoryService {
|
|
|
22470
22679
|
for (const file of files) {
|
|
22471
22680
|
let raw;
|
|
22472
22681
|
try {
|
|
22473
|
-
raw =
|
|
22682
|
+
raw = fs55.readFileSync(path59.join(projectDir, file), "utf8");
|
|
22474
22683
|
} catch {
|
|
22475
22684
|
continue;
|
|
22476
22685
|
}
|
|
@@ -22549,7 +22758,7 @@ var HistoryService = class _HistoryService {
|
|
|
22549
22758
|
if (this.runtime.resolveHistoryFile) {
|
|
22550
22759
|
return this.runtime.resolveHistoryFile(this.cwd, sessionId);
|
|
22551
22760
|
}
|
|
22552
|
-
return
|
|
22761
|
+
return path59.join(this.projectDir, `${sessionId}.jsonl`);
|
|
22553
22762
|
}
|
|
22554
22763
|
/**
|
|
22555
22764
|
* Parse a conversation's messages from disk, agent-aware. Claude uses the
|
|
@@ -22583,7 +22792,7 @@ var HistoryService = class _HistoryService {
|
|
|
22583
22792
|
};
|
|
22584
22793
|
});
|
|
22585
22794
|
}
|
|
22586
|
-
return parseJsonl(
|
|
22795
|
+
return parseJsonl(path59.join(this.projectDir, `${sessionId}.jsonl`));
|
|
22587
22796
|
}
|
|
22588
22797
|
async loadConversation(sessionId) {
|
|
22589
22798
|
const messages = this.readConversation(sessionId);
|
|
@@ -22639,7 +22848,7 @@ var HistoryService = class _HistoryService {
|
|
|
22639
22848
|
if (!filePath) return false;
|
|
22640
22849
|
let mtimeMs;
|
|
22641
22850
|
try {
|
|
22642
|
-
mtimeMs =
|
|
22851
|
+
mtimeMs = fs55.statSync(filePath).mtimeMs;
|
|
22643
22852
|
} catch {
|
|
22644
22853
|
return false;
|
|
22645
22854
|
}
|
|
@@ -22707,11 +22916,11 @@ var HistoryService = class _HistoryService {
|
|
|
22707
22916
|
};
|
|
22708
22917
|
|
|
22709
22918
|
// src/agents/acp/client.ts
|
|
22710
|
-
var
|
|
22711
|
-
var
|
|
22919
|
+
var import_node_child_process23 = require("child_process");
|
|
22920
|
+
var fs56 = __toESM(require("fs/promises"));
|
|
22712
22921
|
var fsSync = __toESM(require("fs"));
|
|
22713
|
-
var
|
|
22714
|
-
var
|
|
22922
|
+
var os45 = __toESM(require("os"));
|
|
22923
|
+
var path60 = __toESM(require("path"));
|
|
22715
22924
|
var import_node_stream = require("stream");
|
|
22716
22925
|
|
|
22717
22926
|
// ../../node_modules/@agentclientprotocol/sdk/dist/acp.js
|
|
@@ -25311,7 +25520,7 @@ var AcpClient = class {
|
|
|
25311
25520
|
"acpClient",
|
|
25312
25521
|
`spawn cmd=${adapter.command} args=[${adapter.args.join(",")}] cwd=${cwd}`
|
|
25313
25522
|
);
|
|
25314
|
-
const child = (0,
|
|
25523
|
+
const child = (0, import_node_child_process23.spawn)(adapter.command, adapter.args, {
|
|
25315
25524
|
cwd,
|
|
25316
25525
|
// extraEnv (e.g. CLAUDE_CODE_DISABLE_1M_CONTEXT=1 on an on-demand
|
|
25317
25526
|
// re-spawn) layers over process.env; PATH stays last so the augmented
|
|
@@ -25625,7 +25834,7 @@ var AcpClient = class {
|
|
|
25625
25834
|
},
|
|
25626
25835
|
readTextFile: async (params) => {
|
|
25627
25836
|
try {
|
|
25628
|
-
const content = await
|
|
25837
|
+
const content = await fs56.readFile(params.path, "utf8");
|
|
25629
25838
|
return applyLineRange(content, params.line ?? null, params.limit ?? null);
|
|
25630
25839
|
} catch (err) {
|
|
25631
25840
|
const code = err.code;
|
|
@@ -25645,7 +25854,7 @@ var AcpClient = class {
|
|
|
25645
25854
|
},
|
|
25646
25855
|
writeTextFile: async (params) => {
|
|
25647
25856
|
try {
|
|
25648
|
-
await
|
|
25857
|
+
await fs56.writeFile(params.path, params.content, "utf8");
|
|
25649
25858
|
return {};
|
|
25650
25859
|
} catch (err) {
|
|
25651
25860
|
const code = err.code;
|
|
@@ -25694,29 +25903,29 @@ function applyLineRange(content, line, limit) {
|
|
|
25694
25903
|
return { content: lines.slice(start2, end).join("\n") };
|
|
25695
25904
|
}
|
|
25696
25905
|
function knownAgentBinaryDirs() {
|
|
25697
|
-
const home =
|
|
25906
|
+
const home = os45.homedir();
|
|
25698
25907
|
const out2 = [];
|
|
25699
25908
|
out2.push("/tmp/codeam-node20/bin");
|
|
25700
25909
|
for (const root of [
|
|
25701
25910
|
"/usr/local/share/nvm/versions/node",
|
|
25702
|
-
|
|
25911
|
+
path60.join(home, ".nvm/versions/node")
|
|
25703
25912
|
]) {
|
|
25704
25913
|
try {
|
|
25705
25914
|
for (const child of fsSync.readdirSync(root)) {
|
|
25706
|
-
out2.push(
|
|
25915
|
+
out2.push(path60.join(root, child, "bin"));
|
|
25707
25916
|
}
|
|
25708
25917
|
} catch {
|
|
25709
25918
|
}
|
|
25710
25919
|
}
|
|
25711
|
-
out2.push(
|
|
25920
|
+
out2.push(path60.join(home, ".volta/bin"));
|
|
25712
25921
|
out2.push("/usr/local/bin");
|
|
25713
25922
|
out2.push("/usr/bin");
|
|
25714
|
-
out2.push(
|
|
25715
|
-
out2.push(
|
|
25923
|
+
out2.push(path60.join(home, ".local/bin"));
|
|
25924
|
+
out2.push(path60.join(home, "bin"));
|
|
25716
25925
|
if (process.platform === "win32") {
|
|
25717
25926
|
const { LOCALAPPDATA, APPDATA } = process.env;
|
|
25718
|
-
if (LOCALAPPDATA) out2.push(
|
|
25719
|
-
if (APPDATA) out2.push(
|
|
25927
|
+
if (LOCALAPPDATA) out2.push(path60.join(LOCALAPPDATA, "cursor-agent"));
|
|
25928
|
+
if (APPDATA) out2.push(path60.join(APPDATA, "npm"));
|
|
25720
25929
|
}
|
|
25721
25930
|
return out2.filter((p2) => {
|
|
25722
25931
|
try {
|
|
@@ -25728,7 +25937,7 @@ function knownAgentBinaryDirs() {
|
|
|
25728
25937
|
}
|
|
25729
25938
|
function expandPathForAgentBinaries(existingPath) {
|
|
25730
25939
|
const existing = new Set(
|
|
25731
|
-
existingPath.split(
|
|
25940
|
+
existingPath.split(path60.delimiter).filter((p2) => p2.length > 0)
|
|
25732
25941
|
);
|
|
25733
25942
|
const additions = [];
|
|
25734
25943
|
for (const dir of knownAgentBinaryDirs()) {
|
|
@@ -25738,7 +25947,7 @@ function expandPathForAgentBinaries(existingPath) {
|
|
|
25738
25947
|
}
|
|
25739
25948
|
}
|
|
25740
25949
|
if (additions.length === 0) return existingPath;
|
|
25741
|
-
return [...additions, existingPath].filter((p2) => p2.length > 0).join(
|
|
25950
|
+
return [...additions, existingPath].filter((p2) => p2.length > 0).join(path60.delimiter);
|
|
25742
25951
|
}
|
|
25743
25952
|
|
|
25744
25953
|
// src/agents/acp/headroom-budget-proxy.ts
|
|
@@ -25749,12 +25958,12 @@ function buildRelaunchProxyEnv(baseEnv) {
|
|
|
25749
25958
|
return env;
|
|
25750
25959
|
}
|
|
25751
25960
|
var relaunchProxyWithoutBudget = async () => {
|
|
25752
|
-
const { spawn:
|
|
25961
|
+
const { spawn: spawn40 } = await import("child_process");
|
|
25753
25962
|
killHeadroomProxy();
|
|
25754
25963
|
await new Promise((r) => setTimeout(r, 500));
|
|
25755
25964
|
const proxyEnv = buildRelaunchProxyEnv(process.env);
|
|
25756
25965
|
try {
|
|
25757
|
-
const proxy =
|
|
25966
|
+
const proxy = spawn40(
|
|
25758
25967
|
"headroom",
|
|
25759
25968
|
["proxy", "--port", "8787"],
|
|
25760
25969
|
{ stdio: "ignore", detached: true, env: proxyEnv }
|
|
@@ -26220,15 +26429,15 @@ function commonPrefixLength(a, b) {
|
|
|
26220
26429
|
|
|
26221
26430
|
// src/agents/acp/onboarding.ts
|
|
26222
26431
|
var import_child_process26 = require("child_process");
|
|
26223
|
-
var
|
|
26224
|
-
var
|
|
26225
|
-
var
|
|
26432
|
+
var fs57 = __toESM(require("fs"));
|
|
26433
|
+
var os46 = __toESM(require("os"));
|
|
26434
|
+
var path61 = __toESM(require("path"));
|
|
26226
26435
|
var _onboardingSeam = {
|
|
26227
|
-
markerPath: (sessionId) =>
|
|
26228
|
-
exists: (p2) =>
|
|
26436
|
+
markerPath: (sessionId) => path61.join(os46.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
|
|
26437
|
+
exists: (p2) => fs57.existsSync(p2),
|
|
26229
26438
|
write: (p2) => {
|
|
26230
|
-
|
|
26231
|
-
|
|
26439
|
+
fs57.mkdirSync(path61.dirname(p2), { recursive: true });
|
|
26440
|
+
fs57.writeFileSync(p2, "");
|
|
26232
26441
|
},
|
|
26233
26442
|
disabled: () => {
|
|
26234
26443
|
const v = process.env.CODEAM_ONBOARDING_DISABLED;
|
|
@@ -26265,7 +26474,7 @@ function resolveRepoName(cwd) {
|
|
|
26265
26474
|
if (name) return name;
|
|
26266
26475
|
}
|
|
26267
26476
|
}
|
|
26268
|
-
const base =
|
|
26477
|
+
const base = path61.basename(cwd || "");
|
|
26269
26478
|
if (base && !isUuid(base)) return base;
|
|
26270
26479
|
return "this project";
|
|
26271
26480
|
}
|
|
@@ -26328,7 +26537,7 @@ async function runOnboardingTurn(opts) {
|
|
|
26328
26537
|
}
|
|
26329
26538
|
|
|
26330
26539
|
// src/agents/acp/mappers.ts
|
|
26331
|
-
var
|
|
26540
|
+
var import_node_crypto8 = require("crypto");
|
|
26332
26541
|
function mapSessionUpdate(notification) {
|
|
26333
26542
|
const update = notification.update;
|
|
26334
26543
|
switch (update.sessionUpdate) {
|
|
@@ -26391,7 +26600,7 @@ function mapPermissionRequest(request) {
|
|
|
26391
26600
|
}
|
|
26392
26601
|
return {
|
|
26393
26602
|
event: {
|
|
26394
|
-
questionId: (0,
|
|
26603
|
+
questionId: (0, import_node_crypto8.randomUUID)(),
|
|
26395
26604
|
prompt,
|
|
26396
26605
|
options: labels.length > 0 ? labels : void 0
|
|
26397
26606
|
},
|
|
@@ -26401,7 +26610,7 @@ function mapPermissionRequest(request) {
|
|
|
26401
26610
|
}
|
|
26402
26611
|
function messageChunkId(messageId) {
|
|
26403
26612
|
if (typeof messageId === "string" && messageId.length > 0) return messageId;
|
|
26404
|
-
return (0,
|
|
26613
|
+
return (0, import_node_crypto8.randomUUID)();
|
|
26405
26614
|
}
|
|
26406
26615
|
function extractText4(content) {
|
|
26407
26616
|
if (!content || typeof content !== "object") return null;
|
|
@@ -26517,8 +26726,8 @@ var import_crypto5 = require("crypto");
|
|
|
26517
26726
|
|
|
26518
26727
|
// src/services/turn-files/git-changeset.ts
|
|
26519
26728
|
var import_child_process27 = require("child_process");
|
|
26520
|
-
var
|
|
26521
|
-
var
|
|
26729
|
+
var fs58 = __toESM(require("fs/promises"));
|
|
26730
|
+
var path62 = __toESM(require("path"));
|
|
26522
26731
|
async function collectRepoChangeset(opts) {
|
|
26523
26732
|
const status2 = await runGit3(opts.repoRoot, ["status", "--porcelain=v1", "-z"]);
|
|
26524
26733
|
if (status2 === null) return null;
|
|
@@ -26536,7 +26745,7 @@ async function collectRepoChangeset(opts) {
|
|
|
26536
26745
|
let stats;
|
|
26537
26746
|
if (row.fileStatus === "added" && numstatEntry === void 0) {
|
|
26538
26747
|
const lineCount = await readUntrackedLineCount(
|
|
26539
|
-
|
|
26748
|
+
path62.join(opts.repoRoot, row.filePath)
|
|
26540
26749
|
);
|
|
26541
26750
|
stats = { added: lineCount, removed: 0 };
|
|
26542
26751
|
} else {
|
|
@@ -26567,7 +26776,7 @@ function readUntrackedLineCount(absPath) {
|
|
|
26567
26776
|
}
|
|
26568
26777
|
async function defaultReadUntrackedLineCount(absPath) {
|
|
26569
26778
|
try {
|
|
26570
|
-
const content = await
|
|
26779
|
+
const content = await fs58.readFile(absPath, "utf8");
|
|
26571
26780
|
let count = 0;
|
|
26572
26781
|
let pos = -1;
|
|
26573
26782
|
while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
|
|
@@ -26659,7 +26868,7 @@ function defaultRunGit(cwd, args2) {
|
|
|
26659
26868
|
});
|
|
26660
26869
|
}
|
|
26661
26870
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
26662
|
-
const
|
|
26871
|
+
const fs63 = await import("fs/promises");
|
|
26663
26872
|
const out2 = [];
|
|
26664
26873
|
await walk(workingDir, 0);
|
|
26665
26874
|
return out2;
|
|
@@ -26667,7 +26876,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
26667
26876
|
if (depth > maxDepth) return;
|
|
26668
26877
|
let entries = [];
|
|
26669
26878
|
try {
|
|
26670
|
-
const dirents = await
|
|
26879
|
+
const dirents = await fs63.readdir(dir, { withFileTypes: true });
|
|
26671
26880
|
entries = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
26672
26881
|
} catch {
|
|
26673
26882
|
return;
|
|
@@ -26678,8 +26887,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
26678
26887
|
if (hasGit) {
|
|
26679
26888
|
out2.push({
|
|
26680
26889
|
repoRoot: dir,
|
|
26681
|
-
repoPath:
|
|
26682
|
-
repoName:
|
|
26890
|
+
repoPath: path62.relative(workingDir, dir),
|
|
26891
|
+
repoName: path62.basename(dir)
|
|
26683
26892
|
});
|
|
26684
26893
|
return;
|
|
26685
26894
|
}
|
|
@@ -26687,14 +26896,14 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
26687
26896
|
if (!entry.isDirectory) continue;
|
|
26688
26897
|
if (entry.name === "node_modules") continue;
|
|
26689
26898
|
if (entry.name === "dist" || entry.name === "build") continue;
|
|
26690
|
-
await walk(
|
|
26899
|
+
await walk(path62.join(dir, entry.name), depth + 1);
|
|
26691
26900
|
}
|
|
26692
26901
|
}
|
|
26693
26902
|
}
|
|
26694
26903
|
|
|
26695
26904
|
// src/services/turn-files/files-outbox.ts
|
|
26696
|
-
var
|
|
26697
|
-
var
|
|
26905
|
+
var fs59 = __toESM(require("fs/promises"));
|
|
26906
|
+
var path63 = __toESM(require("path"));
|
|
26698
26907
|
var import_os9 = require("os");
|
|
26699
26908
|
var HOME_OUTBOX_DIR = ".codeam/outbox";
|
|
26700
26909
|
var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -26727,16 +26936,16 @@ var FilesOutbox = class {
|
|
|
26727
26936
|
backoffIndex = 0;
|
|
26728
26937
|
stopped = false;
|
|
26729
26938
|
constructor(opts) {
|
|
26730
|
-
const base = opts.baseDir ??
|
|
26731
|
-
this.filePath =
|
|
26939
|
+
const base = opts.baseDir ?? path63.join(homeDir(), HOME_OUTBOX_DIR);
|
|
26940
|
+
this.filePath = path63.join(base, `${opts.sessionId}.jsonl`);
|
|
26732
26941
|
this.post = opts.post;
|
|
26733
26942
|
this.autoSchedule = opts.autoSchedule !== false;
|
|
26734
26943
|
}
|
|
26735
26944
|
/** Persist the entry to disk and trigger a flush. Returns once the
|
|
26736
26945
|
* line is durable on disk (not once the POST succeeds). */
|
|
26737
26946
|
async enqueue(entry) {
|
|
26738
|
-
await
|
|
26739
|
-
await
|
|
26947
|
+
await fs59.mkdir(path63.dirname(this.filePath), { recursive: true });
|
|
26948
|
+
await fs59.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
|
|
26740
26949
|
this.backoffIndex = 0;
|
|
26741
26950
|
if (this.autoSchedule) this.scheduleFlush(0);
|
|
26742
26951
|
}
|
|
@@ -26825,7 +27034,7 @@ var FilesOutbox = class {
|
|
|
26825
27034
|
async readAll() {
|
|
26826
27035
|
let raw = "";
|
|
26827
27036
|
try {
|
|
26828
|
-
raw = await
|
|
27037
|
+
raw = await fs59.readFile(this.filePath, "utf8");
|
|
26829
27038
|
} catch {
|
|
26830
27039
|
return [];
|
|
26831
27040
|
}
|
|
@@ -26849,12 +27058,12 @@ var FilesOutbox = class {
|
|
|
26849
27058
|
async rewrite(entries) {
|
|
26850
27059
|
const tmpPath = `${this.filePath}.${process.pid}.tmp`;
|
|
26851
27060
|
if (entries.length === 0) {
|
|
26852
|
-
await
|
|
27061
|
+
await fs59.unlink(this.filePath).catch(() => void 0);
|
|
26853
27062
|
return;
|
|
26854
27063
|
}
|
|
26855
27064
|
const payload = entries.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
26856
|
-
await
|
|
26857
|
-
await
|
|
27065
|
+
await fs59.writeFile(tmpPath, payload, "utf8");
|
|
27066
|
+
await fs59.rename(tmpPath, this.filePath);
|
|
26858
27067
|
}
|
|
26859
27068
|
};
|
|
26860
27069
|
function applyJitter(ms) {
|
|
@@ -28214,7 +28423,7 @@ var AcpHistory = class {
|
|
|
28214
28423
|
this.summary = trimmed.length > 120 ? trimmed.slice(0, 117) + "\u2026" : trimmed;
|
|
28215
28424
|
}
|
|
28216
28425
|
this.messages.push({
|
|
28217
|
-
id: (0,
|
|
28426
|
+
id: (0, import_node_crypto9.randomUUID)(),
|
|
28218
28427
|
role: "user",
|
|
28219
28428
|
text,
|
|
28220
28429
|
timestamp: Date.now()
|
|
@@ -28223,7 +28432,7 @@ var AcpHistory = class {
|
|
|
28223
28432
|
appendAgentReply(text) {
|
|
28224
28433
|
if (text.length === 0) return;
|
|
28225
28434
|
this.messages.push({
|
|
28226
|
-
id: (0,
|
|
28435
|
+
id: (0, import_node_crypto9.randomUUID)(),
|
|
28227
28436
|
role: "agent",
|
|
28228
28437
|
text,
|
|
28229
28438
|
timestamp: Date.now()
|
|
@@ -28429,7 +28638,7 @@ async function runAcpSession(opts) {
|
|
|
28429
28638
|
currentIndex: 0,
|
|
28430
28639
|
done: true
|
|
28431
28640
|
}),
|
|
28432
|
-
publishAwaitingAnswer: (prompt, options) => publisher.publishAwaitingAnswer({ questionId: (0,
|
|
28641
|
+
publishAwaitingAnswer: (prompt, options) => publisher.publishAwaitingAnswer({ questionId: (0, import_node_crypto9.randomUUID)(), prompt, options }),
|
|
28433
28642
|
publishRawChunk: (chunk) => publisher.publishOutput(chunk),
|
|
28434
28643
|
sendResult: (commandId, status2, result) => relay.sendResult(commandId, status2, result),
|
|
28435
28644
|
appendAgentReply: (text) => history.appendAgentReply(text),
|
|
@@ -29610,14 +29819,6 @@ function fetchQuotaUsage(runtime, historySvc) {
|
|
|
29610
29819
|
});
|
|
29611
29820
|
}
|
|
29612
29821
|
|
|
29613
|
-
// src/baton/gate.ts
|
|
29614
|
-
function runtimeSupportsBaton(runtime) {
|
|
29615
|
-
return typeof runtime.resolveHistoryFile === "function";
|
|
29616
|
-
}
|
|
29617
|
-
function isLocalSession(env = process.env) {
|
|
29618
|
-
return env.CODESPACES !== "true" && env.CODEAM_AUTO_APPROVE !== "1" && env.HEADROOM_ENABLED !== "1" && !env.CODEAM_AUTO_TOKEN && !env.CODEAM_ENROLL_TOKEN;
|
|
29619
|
-
}
|
|
29620
|
-
|
|
29621
29822
|
// src/baton/baton-controller.ts
|
|
29622
29823
|
var BatonController = class {
|
|
29623
29824
|
constructor(deps) {
|
|
@@ -29798,7 +29999,7 @@ var NativeTuiDriver = class {
|
|
|
29798
29999
|
};
|
|
29799
30000
|
|
|
29800
30001
|
// src/baton/acp-driver.ts
|
|
29801
|
-
var
|
|
30002
|
+
var import_node_crypto10 = require("crypto");
|
|
29802
30003
|
var AcpDriver = class {
|
|
29803
30004
|
constructor(deps) {
|
|
29804
30005
|
this.deps = deps;
|
|
@@ -29891,7 +30092,7 @@ var AcpDriver = class {
|
|
|
29891
30092
|
currentIndex: 0,
|
|
29892
30093
|
done: true
|
|
29893
30094
|
}),
|
|
29894
|
-
publishAwaitingAnswer: (prompt, options) => publisher.publishAwaitingAnswer({ questionId: (0,
|
|
30095
|
+
publishAwaitingAnswer: (prompt, options) => publisher.publishAwaitingAnswer({ questionId: (0, import_node_crypto10.randomUUID)(), prompt, options }),
|
|
29895
30096
|
publishRawChunk: (chunk) => publisher.publishOutput(chunk),
|
|
29896
30097
|
sendResult: (commandId, status2, result) => relay.sendResult(commandId, status2, result),
|
|
29897
30098
|
appendAgentReply: (text) => history.appendAgentReply(text),
|
|
@@ -29934,7 +30135,7 @@ var AcpDriver = class {
|
|
|
29934
30135
|
};
|
|
29935
30136
|
|
|
29936
30137
|
// src/baton/transcript-mirror.ts
|
|
29937
|
-
var
|
|
30138
|
+
var fs60 = __toESM(require("fs"));
|
|
29938
30139
|
var TranscriptMirror = class {
|
|
29939
30140
|
constructor(deps) {
|
|
29940
30141
|
this.deps = deps;
|
|
@@ -30001,7 +30202,7 @@ var TranscriptMirror = class {
|
|
|
30001
30202
|
}
|
|
30002
30203
|
};
|
|
30003
30204
|
function defaultWatch(file, onChange) {
|
|
30004
|
-
const w3 =
|
|
30205
|
+
const w3 = fs60.watch(file, { persistent: false }, () => onChange());
|
|
30005
30206
|
return () => w3.close();
|
|
30006
30207
|
}
|
|
30007
30208
|
|
|
@@ -30248,15 +30449,15 @@ function toEpochMs(ts) {
|
|
|
30248
30449
|
}
|
|
30249
30450
|
|
|
30250
30451
|
// src/agents/claude/onboarding.ts
|
|
30251
|
-
var
|
|
30252
|
-
var
|
|
30253
|
-
var
|
|
30452
|
+
var fs61 = __toESM(require("fs"));
|
|
30453
|
+
var os47 = __toESM(require("os"));
|
|
30454
|
+
var path64 = __toESM(require("path"));
|
|
30254
30455
|
function ensureClaudeOnboarded() {
|
|
30255
30456
|
try {
|
|
30256
|
-
const file =
|
|
30457
|
+
const file = path64.join(os47.homedir(), ".claude.json");
|
|
30257
30458
|
let config = {};
|
|
30258
30459
|
try {
|
|
30259
|
-
config = JSON.parse(
|
|
30460
|
+
config = JSON.parse(fs61.readFileSync(file, "utf8"));
|
|
30260
30461
|
} catch {
|
|
30261
30462
|
}
|
|
30262
30463
|
if (config.hasCompletedOnboarding === true && typeof config.theme === "string") {
|
|
@@ -30267,8 +30468,8 @@ function ensureClaudeOnboarded() {
|
|
|
30267
30468
|
if (typeof config.lastOnboardingVersion !== "string") {
|
|
30268
30469
|
config.lastOnboardingVersion = "2.1.177";
|
|
30269
30470
|
}
|
|
30270
|
-
|
|
30271
|
-
|
|
30471
|
+
fs61.mkdirSync(path64.dirname(file), { recursive: true });
|
|
30472
|
+
fs61.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
30272
30473
|
log.info("claude", "pre-completed Claude onboarding (skip first-run theme picker)");
|
|
30273
30474
|
} catch (err) {
|
|
30274
30475
|
log.warn("claude", `ensureClaudeOnboarded failed (non-fatal): ${err.message}`);
|
|
@@ -30942,7 +31143,7 @@ var import_picocolors11 = __toESM(require("picocolors"));
|
|
|
30942
31143
|
var import_child_process28 = require("child_process");
|
|
30943
31144
|
var import_util4 = require("util");
|
|
30944
31145
|
var import_picocolors9 = __toESM(require("picocolors"));
|
|
30945
|
-
var
|
|
31146
|
+
var path65 = __toESM(require("path"));
|
|
30946
31147
|
var execFileP6 = (0, import_util4.promisify)(import_child_process28.execFile);
|
|
30947
31148
|
var MAX_BUFFER = 8 * 1024 * 1024;
|
|
30948
31149
|
function resetStdinForChild() {
|
|
@@ -31431,7 +31632,7 @@ var GitHubCodespacesProvider = class {
|
|
|
31431
31632
|
});
|
|
31432
31633
|
}
|
|
31433
31634
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
31434
|
-
const remoteDir =
|
|
31635
|
+
const remoteDir = path65.posix.dirname(remotePath);
|
|
31435
31636
|
const parts = [
|
|
31436
31637
|
`mkdir -p ${shellQuote(remoteDir)}`,
|
|
31437
31638
|
`cat > ${shellQuote(remotePath)}`
|
|
@@ -31501,7 +31702,7 @@ function shellQuote(s) {
|
|
|
31501
31702
|
// src/services/providers/gitpod.ts
|
|
31502
31703
|
var import_child_process29 = require("child_process");
|
|
31503
31704
|
var import_util5 = require("util");
|
|
31504
|
-
var
|
|
31705
|
+
var path66 = __toESM(require("path"));
|
|
31505
31706
|
var import_picocolors10 = __toESM(require("picocolors"));
|
|
31506
31707
|
var execFileP7 = (0, import_util5.promisify)(import_child_process29.execFile);
|
|
31507
31708
|
var MAX_BUFFER2 = 8 * 1024 * 1024;
|
|
@@ -31741,7 +31942,7 @@ var GitpodProvider = class {
|
|
|
31741
31942
|
});
|
|
31742
31943
|
}
|
|
31743
31944
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
31744
|
-
const remoteDir =
|
|
31945
|
+
const remoteDir = path66.posix.dirname(remotePath);
|
|
31745
31946
|
const parts = [
|
|
31746
31947
|
`mkdir -p ${shellQuote2(remoteDir)}`,
|
|
31747
31948
|
`cat > ${shellQuote2(remotePath)}`
|
|
@@ -31777,7 +31978,7 @@ function shellQuote2(s) {
|
|
|
31777
31978
|
// src/services/providers/gitlab-workspaces.ts
|
|
31778
31979
|
var import_child_process30 = require("child_process");
|
|
31779
31980
|
var import_util6 = require("util");
|
|
31780
|
-
var
|
|
31981
|
+
var path67 = __toESM(require("path"));
|
|
31781
31982
|
var execFileP8 = (0, import_util6.promisify)(import_child_process30.execFile);
|
|
31782
31983
|
var MAX_BUFFER3 = 8 * 1024 * 1024;
|
|
31783
31984
|
var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
|
|
@@ -32037,7 +32238,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
32037
32238
|
}
|
|
32038
32239
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
32039
32240
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
32040
|
-
const remoteDir =
|
|
32241
|
+
const remoteDir = path67.posix.dirname(remotePath);
|
|
32041
32242
|
const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
|
|
32042
32243
|
if (options.mode != null) {
|
|
32043
32244
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
@@ -32105,7 +32306,7 @@ function shellQuote3(s) {
|
|
|
32105
32306
|
// src/services/providers/railway.ts
|
|
32106
32307
|
var import_child_process31 = require("child_process");
|
|
32107
32308
|
var import_util7 = require("util");
|
|
32108
|
-
var
|
|
32309
|
+
var path68 = __toESM(require("path"));
|
|
32109
32310
|
var execFileP9 = (0, import_util7.promisify)(import_child_process31.execFile);
|
|
32110
32311
|
var MAX_BUFFER4 = 8 * 1024 * 1024;
|
|
32111
32312
|
function resetStdinForChild4() {
|
|
@@ -32341,7 +32542,7 @@ var RailwayProvider = class {
|
|
|
32341
32542
|
if (!projectId || !serviceId) {
|
|
32342
32543
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
32343
32544
|
}
|
|
32344
|
-
const remoteDir =
|
|
32545
|
+
const remoteDir = path68.posix.dirname(remotePath);
|
|
32345
32546
|
const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
|
|
32346
32547
|
if (options.mode != null) {
|
|
32347
32548
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
@@ -32986,9 +33187,9 @@ async function invite() {
|
|
|
32986
33187
|
// src/commands/doctor.ts
|
|
32987
33188
|
var import_node_dns = require("dns");
|
|
32988
33189
|
var import_node_util5 = require("util");
|
|
32989
|
-
var
|
|
32990
|
-
var
|
|
32991
|
-
var
|
|
33190
|
+
var import_node_crypto11 = require("crypto");
|
|
33191
|
+
var fs62 = __toESM(require("fs"));
|
|
33192
|
+
var path69 = __toESM(require("path"));
|
|
32992
33193
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
32993
33194
|
var dnsResolveP = (0, import_node_util5.promisify)(import_node_dns.resolve);
|
|
32994
33195
|
async function checkDns(apiBase2) {
|
|
@@ -33044,13 +33245,13 @@ async function checkHealth(apiBase2) {
|
|
|
33044
33245
|
}
|
|
33045
33246
|
}
|
|
33046
33247
|
function checkConfigDir() {
|
|
33047
|
-
const dir =
|
|
33248
|
+
const dir = path69.join(require("os").homedir(), ".codeam");
|
|
33048
33249
|
try {
|
|
33049
|
-
|
|
33050
|
-
const probe =
|
|
33051
|
-
|
|
33052
|
-
const read2 =
|
|
33053
|
-
|
|
33250
|
+
fs62.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
33251
|
+
const probe = path69.join(dir, ".doctor-probe");
|
|
33252
|
+
fs62.writeFileSync(probe, "ok", { mode: 384 });
|
|
33253
|
+
const read2 = fs62.readFileSync(probe, "utf8");
|
|
33254
|
+
fs62.unlinkSync(probe);
|
|
33054
33255
|
if (read2 !== "ok") throw new Error("write/read round-trip mismatch");
|
|
33055
33256
|
return {
|
|
33056
33257
|
id: "config-dir",
|
|
@@ -33090,9 +33291,9 @@ function checkSessions() {
|
|
|
33090
33291
|
}
|
|
33091
33292
|
}
|
|
33092
33293
|
function checkAgentBinaries() {
|
|
33093
|
-
const
|
|
33294
|
+
const os49 = createOsStrategy();
|
|
33094
33295
|
return getEnabledAgents().map((meta) => {
|
|
33095
|
-
const found =
|
|
33296
|
+
const found = os49.findInPath(meta.binaryName);
|
|
33096
33297
|
return {
|
|
33097
33298
|
id: `agent-${meta.id}`,
|
|
33098
33299
|
label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
|
|
@@ -33114,7 +33315,7 @@ function checkNodePty() {
|
|
|
33114
33315
|
detail: "not required on this platform"
|
|
33115
33316
|
};
|
|
33116
33317
|
}
|
|
33117
|
-
const vendoredPath =
|
|
33318
|
+
const vendoredPath = path69.join(__dirname, "vendor", "node-pty");
|
|
33118
33319
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
33119
33320
|
try {
|
|
33120
33321
|
require(target);
|
|
@@ -33156,9 +33357,9 @@ function checkChokidar() {
|
|
|
33156
33357
|
}
|
|
33157
33358
|
async function doctor(args2 = []) {
|
|
33158
33359
|
const json = args2.includes("--json");
|
|
33159
|
-
const cliVersion = true ? "2.60.
|
|
33360
|
+
const cliVersion = true ? "2.60.17" : "0.0.0-dev";
|
|
33160
33361
|
const apiBase2 = resolveApiBaseUrl();
|
|
33161
|
-
const diagnosticId = (0,
|
|
33362
|
+
const diagnosticId = (0, import_node_crypto11.randomUUID)();
|
|
33162
33363
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
33163
33364
|
const [dns, health] = await Promise.all([
|
|
33164
33365
|
checkDns(apiBase2),
|
|
@@ -33355,7 +33556,7 @@ async function completion(args2) {
|
|
|
33355
33556
|
// src/commands/version.ts
|
|
33356
33557
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
33357
33558
|
function version2() {
|
|
33358
|
-
const v = true ? "2.60.
|
|
33559
|
+
const v = true ? "2.60.17" : "unknown";
|
|
33359
33560
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
33360
33561
|
}
|
|
33361
33562
|
|
|
@@ -33504,10 +33705,10 @@ var EXIT_CODE_NAMES = {
|
|
|
33504
33705
|
};
|
|
33505
33706
|
|
|
33506
33707
|
// src/index.ts
|
|
33507
|
-
var
|
|
33708
|
+
var os48 = __toESM(require("os"));
|
|
33508
33709
|
if (!process.env.HOME) {
|
|
33509
33710
|
try {
|
|
33510
|
-
const home =
|
|
33711
|
+
const home = os48.homedir();
|
|
33511
33712
|
if (home) process.env.HOME = home;
|
|
33512
33713
|
} catch {
|
|
33513
33714
|
}
|