codeam-cli 2.76.42 → 2.76.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.js +733 -655
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -374,8 +374,8 @@ function defaultSpawn(timeoutMs) {
|
|
|
374
374
|
});
|
|
375
375
|
}
|
|
376
376
|
function resolveConvexBin(cwd) {
|
|
377
|
-
const local =
|
|
378
|
-
if (
|
|
377
|
+
const local = path115.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "convex.cmd" : "convex");
|
|
378
|
+
if (fs103.existsSync(local)) return { cmd: local, args: [] };
|
|
379
379
|
return { cmd: "npx", args: ["--yes", "convex"] };
|
|
380
380
|
}
|
|
381
381
|
function redact(text, key) {
|
|
@@ -506,13 +506,13 @@ async function runConvexAdminMcp(client3, id) {
|
|
|
506
506
|
});
|
|
507
507
|
await server.connect(new StdioServerTransport());
|
|
508
508
|
}
|
|
509
|
-
var import_node_child_process40,
|
|
509
|
+
var import_node_child_process40, fs103, path115, TOOLS;
|
|
510
510
|
var init_convex_admin_mcp = __esm({
|
|
511
511
|
"src/integrations/convex-admin-mcp.ts"() {
|
|
512
512
|
"use strict";
|
|
513
513
|
import_node_child_process40 = require("child_process");
|
|
514
|
-
|
|
515
|
-
|
|
514
|
+
fs103 = __toESM(require("fs"));
|
|
515
|
+
path115 = __toESM(require("path"));
|
|
516
516
|
TOOLS = [
|
|
517
517
|
{
|
|
518
518
|
name: "tables",
|
|
@@ -3518,8 +3518,10 @@ function pointPickerScript(opts) {
|
|
|
3518
3518
|
|
|
3519
3519
|
// Inside a React Native WebView the document is TOP-LEVEL (window.parent ===
|
|
3520
3520
|
// window), so the only way out is the bridge RN injects. It carries STRINGS.
|
|
3521
|
+
// Any mode may answer through it: the host app owns the WebView, there is no
|
|
3522
|
+
// third party to keep out \u2014 only the control API (the door below) needs
|
|
3523
|
+
// \`globalName\`, because a global turns the picker on with nobody's permission.
|
|
3521
3524
|
function rnBridge() {
|
|
3522
|
-
if (!GLOBAL) return null;
|
|
3523
3525
|
var rn = W.ReactNativeWebView;
|
|
3524
3526
|
return rn && typeof rn.postMessage === 'function' ? rn : null;
|
|
3525
3527
|
}
|
|
@@ -3530,13 +3532,17 @@ function pointPickerScript(opts) {
|
|
|
3530
3532
|
msg[FIELD] = CH;
|
|
3531
3533
|
msg.type = type;
|
|
3532
3534
|
if (extra) for (var k in extra) msg[k] = extra[k];
|
|
3535
|
+
// A parent window first (the feed framing the app; a host that installed
|
|
3536
|
+
// one); only a top-level document falls back to the React Native bridge
|
|
3537
|
+
// (2026-11-01: Remix's phone app got no \`on\` and no \`pick\` here).
|
|
3538
|
+
if (W.parent !== W) {
|
|
3539
|
+
try { W.parent.postMessage(msg, driver); } catch (e) {}
|
|
3540
|
+
return;
|
|
3541
|
+
}
|
|
3533
3542
|
var rn = rnBridge();
|
|
3534
3543
|
if (rn) {
|
|
3535
3544
|
try { rn.postMessage(JSON.stringify(msg)); } catch (e) {}
|
|
3536
|
-
return;
|
|
3537
3545
|
}
|
|
3538
|
-
if (W.parent === W) return;
|
|
3539
|
-
try { W.parent.postMessage(msg, driver); } catch (e) {}
|
|
3540
3546
|
}
|
|
3541
3547
|
|
|
3542
3548
|
function clip(s, max) { return s.length > max ? s.slice(0, max - 1) + '\\u2026' : s; }
|
|
@@ -4369,11 +4375,11 @@ function quiet(fn) {
|
|
|
4369
4375
|
log.debug(TAG, "ignored sync error", err);
|
|
4370
4376
|
}
|
|
4371
4377
|
}
|
|
4372
|
-
function rmIfExistsQuiet(
|
|
4378
|
+
function rmIfExistsQuiet(path117) {
|
|
4373
4379
|
try {
|
|
4374
|
-
fs2.rmSync(
|
|
4380
|
+
fs2.rmSync(path117, { force: true });
|
|
4375
4381
|
} catch (err) {
|
|
4376
|
-
log.debug(TAG, `rmIfExists failed for ${
|
|
4382
|
+
log.debug(TAG, `rmIfExists failed for ${path117}`, err);
|
|
4377
4383
|
}
|
|
4378
4384
|
}
|
|
4379
4385
|
function killQuiet(target, signal = "SIGTERM") {
|
|
@@ -4539,9 +4545,9 @@ var _default = makeConfig();
|
|
|
4539
4545
|
var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, setSessionAgent, setSquadAuto, getSquadAuto, clearAll, saveCliConfig, loadCliConfig } = _default;
|
|
4540
4546
|
|
|
4541
4547
|
// src/commands/pair-auto.ts
|
|
4542
|
-
var
|
|
4543
|
-
var
|
|
4544
|
-
var
|
|
4548
|
+
var fs70 = __toESM(require("fs"));
|
|
4549
|
+
var os50 = __toESM(require("os"));
|
|
4550
|
+
var path77 = __toESM(require("path"));
|
|
4545
4551
|
var import_crypto4 = require("crypto");
|
|
4546
4552
|
|
|
4547
4553
|
// src/services/telemetry.service.ts
|
|
@@ -4577,8 +4583,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
|
|
|
4577
4583
|
return decodedFile;
|
|
4578
4584
|
};
|
|
4579
4585
|
}
|
|
4580
|
-
function normalizeWindowsPath(
|
|
4581
|
-
return
|
|
4586
|
+
function normalizeWindowsPath(path117) {
|
|
4587
|
+
return path117.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
4582
4588
|
}
|
|
4583
4589
|
|
|
4584
4590
|
// ../../node_modules/@posthog/core/dist/error-tracking/index.mjs
|
|
@@ -7311,13 +7317,13 @@ var PostHogCoreStateless = class {
|
|
|
7311
7317
|
sentFromRoute += batchMessages.length;
|
|
7312
7318
|
}
|
|
7313
7319
|
}
|
|
7314
|
-
async _sendOtlpBatch({ path:
|
|
7320
|
+
async _sendOtlpBatch({ path: path117, payload }) {
|
|
7315
7321
|
if (this.disabled) return {
|
|
7316
7322
|
kind: "fatal",
|
|
7317
7323
|
error: new Error("The client is disabled")
|
|
7318
7324
|
};
|
|
7319
7325
|
const serialized = JSON.stringify(payload);
|
|
7320
|
-
const url2 = `${this.host}/i/v1/${
|
|
7326
|
+
const url2 = `${this.host}/i/v1/${path117}?token=${encodeURIComponent(this.apiKey)}`;
|
|
7321
7327
|
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
|
|
7322
7328
|
const fetchOptions = {
|
|
7323
7329
|
method: "POST",
|
|
@@ -8557,14 +8563,14 @@ async function addSourceContext(frames, openSourceFile = import_promises.open, l
|
|
|
8557
8563
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
8558
8564
|
return frames;
|
|
8559
8565
|
}
|
|
8560
|
-
async function openRegularSourceFile(
|
|
8566
|
+
async function openRegularSourceFile(path117, openSourceFile, logger) {
|
|
8561
8567
|
let fileHandle;
|
|
8562
8568
|
let isValid = false;
|
|
8563
8569
|
try {
|
|
8564
|
-
fileHandle = await openSourceFile(
|
|
8570
|
+
fileHandle = await openSourceFile(path117, import_node_fs.constants.O_RDONLY | import_node_fs.constants.O_NONBLOCK);
|
|
8565
8571
|
const fileStat = await fileHandle.stat();
|
|
8566
8572
|
if (!fileStat.isFile()) return;
|
|
8567
|
-
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${
|
|
8573
|
+
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${path117}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
|
|
8568
8574
|
isValid = true;
|
|
8569
8575
|
return fileHandle;
|
|
8570
8576
|
} catch {
|
|
@@ -8574,8 +8580,8 @@ async function openRegularSourceFile(path116, openSourceFile, logger) {
|
|
|
8574
8580
|
});
|
|
8575
8581
|
}
|
|
8576
8582
|
}
|
|
8577
|
-
async function getContextLinesFromFile(
|
|
8578
|
-
const fileHandle = await openRegularSourceFile(
|
|
8583
|
+
async function getContextLinesFromFile(path117, ranges, output, cacheKey, openSourceFile, logger) {
|
|
8584
|
+
const fileHandle = await openRegularSourceFile(path117, openSourceFile, logger);
|
|
8579
8585
|
if (void 0 === fileHandle) return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
8580
8586
|
const openedFileHandle = fileHandle;
|
|
8581
8587
|
return new Promise((resolve13) => {
|
|
@@ -8677,22 +8683,22 @@ function clearLineContext(frame) {
|
|
|
8677
8683
|
delete frame.context_line;
|
|
8678
8684
|
delete frame.post_context;
|
|
8679
8685
|
}
|
|
8680
|
-
function shouldSkipContextLinesForFile(
|
|
8681
|
-
return
|
|
8686
|
+
function shouldSkipContextLinesForFile(path117) {
|
|
8687
|
+
return path117.startsWith("node:") || path117.endsWith(".min.js") || path117.endsWith(".min.cjs") || path117.endsWith(".min.mjs") || path117.startsWith("data:");
|
|
8682
8688
|
}
|
|
8683
8689
|
function shouldSkipContextLinesForFrame(frame) {
|
|
8684
8690
|
if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
|
|
8685
8691
|
if (void 0 !== frame.colno && frame.colno > MAX_CONTEXTLINES_COLNO) return true;
|
|
8686
8692
|
return false;
|
|
8687
8693
|
}
|
|
8688
|
-
function makeSourceCacheKey(
|
|
8689
|
-
if ((0, import_node_path.isAbsolute)(
|
|
8694
|
+
function makeSourceCacheKey(path117, basePath) {
|
|
8695
|
+
if ((0, import_node_path.isAbsolute)(path117)) return JSON.stringify([
|
|
8690
8696
|
null,
|
|
8691
|
-
|
|
8697
|
+
path117
|
|
8692
8698
|
]);
|
|
8693
8699
|
return void 0 === basePath ? void 0 : JSON.stringify([
|
|
8694
8700
|
basePath,
|
|
8695
|
-
|
|
8701
|
+
path117
|
|
8696
8702
|
]);
|
|
8697
8703
|
}
|
|
8698
8704
|
function rangeExistsInContentCache(cacheKey, range) {
|
|
@@ -11354,7 +11360,7 @@ function readAnonId() {
|
|
|
11354
11360
|
}
|
|
11355
11361
|
function superProperties() {
|
|
11356
11362
|
return {
|
|
11357
|
-
cliVersion: true ? "2.76.
|
|
11363
|
+
cliVersion: true ? "2.76.44" : "0.0.0-dev",
|
|
11358
11364
|
nodeVersion: process.version,
|
|
11359
11365
|
platform: process.platform,
|
|
11360
11366
|
arch: process.arch,
|
|
@@ -11603,7 +11609,7 @@ var http = __toESM(require("http"));
|
|
|
11603
11609
|
// package.json
|
|
11604
11610
|
var package_default = {
|
|
11605
11611
|
name: "codeam-cli",
|
|
11606
|
-
version: "2.76.
|
|
11612
|
+
version: "2.76.44",
|
|
11607
11613
|
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.",
|
|
11608
11614
|
type: "commonjs",
|
|
11609
11615
|
main: "dist/index.js",
|
|
@@ -12979,7 +12985,7 @@ var CommandRelayService = class _CommandRelayService {
|
|
|
12979
12985
|
// fresh + clear the "CLI update available" banner after a self-update
|
|
12980
12986
|
// (a codespace that reinstalls @latest reconnects via heartbeat, not
|
|
12981
12987
|
// pair/reconnect). Older backends ignore the extra field.
|
|
12982
|
-
..."2.76.
|
|
12988
|
+
..."2.76.44" ? { ideVersion: "2.76.44" } : {}
|
|
12983
12989
|
};
|
|
12984
12990
|
try {
|
|
12985
12991
|
const res = await _postJson(`${API_BASE2}/api/plugin/heartbeat`, body, this.pollSecretHeader());
|
|
@@ -13302,10 +13308,10 @@ var WINDOWS_LEGACY_JUNCTIONS = [
|
|
|
13302
13308
|
/[\\/]Start Menu([\\/]|$)/i,
|
|
13303
13309
|
/[\\/]Templates([\\/]|$)/i
|
|
13304
13310
|
];
|
|
13305
|
-
function isUnsafeWindowsWatchRoot(dir,
|
|
13311
|
+
function isUnsafeWindowsWatchRoot(dir, homedir55) {
|
|
13306
13312
|
const norm = (p2) => p2.replace(/\//g, "\\").replace(/\\+$/, "").toLowerCase();
|
|
13307
13313
|
const cwd = norm(dir);
|
|
13308
|
-
const home = norm(
|
|
13314
|
+
const home = norm(homedir55);
|
|
13309
13315
|
if (cwd === home) return true;
|
|
13310
13316
|
if (/^[a-z]:$/.test(cwd)) return true;
|
|
13311
13317
|
const sysRoots = [
|
|
@@ -14460,9 +14466,9 @@ function closeAllTerminals() {
|
|
|
14460
14466
|
}
|
|
14461
14467
|
|
|
14462
14468
|
// src/commands/start/handlers.ts
|
|
14463
|
-
var
|
|
14464
|
-
var
|
|
14465
|
-
var
|
|
14469
|
+
var fs69 = __toESM(require("fs"));
|
|
14470
|
+
var os49 = __toESM(require("os"));
|
|
14471
|
+
var path76 = __toESM(require("path"));
|
|
14466
14472
|
var import_crypto3 = require("crypto");
|
|
14467
14473
|
var import_child_process25 = require("child_process");
|
|
14468
14474
|
|
|
@@ -18109,10 +18115,10 @@ function buildForPlatform(platform3) {
|
|
|
18109
18115
|
var import_node_crypto5 = require("crypto");
|
|
18110
18116
|
|
|
18111
18117
|
// src/agents/claude/resolver.ts
|
|
18112
|
-
function buildClaudeLaunch(extraArgs = [],
|
|
18113
|
-
const found =
|
|
18118
|
+
function buildClaudeLaunch(extraArgs = [], os75 = createOsStrategy()) {
|
|
18119
|
+
const found = os75.findInPath("claude") ?? os75.findInPath("claude-code");
|
|
18114
18120
|
if (!found) return null;
|
|
18115
|
-
return
|
|
18121
|
+
return os75.buildLaunch(found, extraArgs);
|
|
18116
18122
|
}
|
|
18117
18123
|
|
|
18118
18124
|
// src/agents/claude/installer.ts
|
|
@@ -18211,8 +18217,8 @@ function parseClaudeAuthStatus(stdout) {
|
|
|
18211
18217
|
return "unknown";
|
|
18212
18218
|
}
|
|
18213
18219
|
}
|
|
18214
|
-
function probeClaudeLocalAuth(
|
|
18215
|
-
const bin =
|
|
18220
|
+
function probeClaudeLocalAuth(os75, timeoutMs = 1e4) {
|
|
18221
|
+
const bin = os75.findInPath("claude") ?? os75.findInPath("claude-code");
|
|
18216
18222
|
if (!bin) return Promise.resolve("unknown");
|
|
18217
18223
|
return new Promise((resolve13) => {
|
|
18218
18224
|
try {
|
|
@@ -18990,8 +18996,8 @@ var ClaudeRuntimeStrategy = class {
|
|
|
18990
18996
|
meta = getAgent("claude");
|
|
18991
18997
|
mode = "interactive";
|
|
18992
18998
|
os;
|
|
18993
|
-
constructor(
|
|
18994
|
-
this.os =
|
|
18999
|
+
constructor(os75) {
|
|
19000
|
+
this.os = os75;
|
|
18995
19001
|
}
|
|
18996
19002
|
probeLocalAuth() {
|
|
18997
19003
|
return probeClaudeLocalAuth(this.os);
|
|
@@ -20094,8 +20100,8 @@ function codexCredentialLocator() {
|
|
|
20094
20100
|
function codexLoginLauncher() {
|
|
20095
20101
|
return {
|
|
20096
20102
|
async ensureInstalled() {
|
|
20097
|
-
const
|
|
20098
|
-
return
|
|
20103
|
+
const os75 = createOsStrategy();
|
|
20104
|
+
return os75.findInPath("codex") !== null;
|
|
20099
20105
|
},
|
|
20100
20106
|
launch() {
|
|
20101
20107
|
return (0, import_node_child_process4.spawn)("codex", ["login"], { stdio: "inherit" });
|
|
@@ -20124,8 +20130,8 @@ var CodexRuntimeStrategy = class {
|
|
|
20124
20130
|
meta = getAgent("codex");
|
|
20125
20131
|
mode = "interactive";
|
|
20126
20132
|
os;
|
|
20127
|
-
constructor(
|
|
20128
|
-
this.os =
|
|
20133
|
+
constructor(os75) {
|
|
20134
|
+
this.os = os75;
|
|
20129
20135
|
}
|
|
20130
20136
|
async prepareLaunch() {
|
|
20131
20137
|
let binary = this.os.findInPath("codex");
|
|
@@ -20246,12 +20252,12 @@ var CodexRuntimeStrategy = class {
|
|
|
20246
20252
|
return (await runOnce()).text;
|
|
20247
20253
|
}
|
|
20248
20254
|
};
|
|
20249
|
-
function resolveNpm(
|
|
20250
|
-
return
|
|
20255
|
+
function resolveNpm(os75) {
|
|
20256
|
+
return os75.id === "win32" ? "npm.cmd" : "npm";
|
|
20251
20257
|
}
|
|
20252
|
-
async function installCodexViaNpm(
|
|
20258
|
+
async function installCodexViaNpm(os75) {
|
|
20253
20259
|
return new Promise((resolve13, reject) => {
|
|
20254
|
-
const proc = (0, import_node_child_process5.spawn)(resolveNpm(
|
|
20260
|
+
const proc = (0, import_node_child_process5.spawn)(resolveNpm(os75), ["install", "-g", "--no-audit", "--no-fund", "@openai/codex"], {
|
|
20255
20261
|
stdio: "inherit"
|
|
20256
20262
|
});
|
|
20257
20263
|
proc.on("close", (code) => {
|
|
@@ -20268,16 +20274,16 @@ async function installCodexViaNpm(os74) {
|
|
|
20268
20274
|
});
|
|
20269
20275
|
});
|
|
20270
20276
|
}
|
|
20271
|
-
function augmentNpmGlobalBin(
|
|
20277
|
+
function augmentNpmGlobalBin(os75) {
|
|
20272
20278
|
try {
|
|
20273
|
-
const result = (0, import_node_child_process5.spawnSync)(resolveNpm(
|
|
20279
|
+
const result = (0, import_node_child_process5.spawnSync)(resolveNpm(os75), ["prefix", "-g"], {
|
|
20274
20280
|
stdio: ["ignore", "pipe", "ignore"]
|
|
20275
20281
|
});
|
|
20276
20282
|
if (result.status !== 0) return;
|
|
20277
20283
|
const prefix = result.stdout.toString().trim();
|
|
20278
20284
|
if (!prefix) return;
|
|
20279
|
-
const binDir =
|
|
20280
|
-
|
|
20285
|
+
const binDir = os75.id === "win32" ? prefix : path27.join(prefix, "bin");
|
|
20286
|
+
os75.augmentPath([binDir]);
|
|
20281
20287
|
} catch {
|
|
20282
20288
|
}
|
|
20283
20289
|
}
|
|
@@ -20471,10 +20477,10 @@ function manualInstallHint(runner, tools) {
|
|
|
20471
20477
|
const argv = osPackageInstallArgv(detectPackageManager(runner), [...tools]);
|
|
20472
20478
|
return argv ? `\`sudo ${argv.join(" ")}\`` : `your package manager (e.g. \`${pkgs}\`)`;
|
|
20473
20479
|
}
|
|
20474
|
-
function writeUnzipShim(
|
|
20480
|
+
function writeUnzipShim(os75, runner) {
|
|
20475
20481
|
const python = ["python3", "python"].find((p2) => runner.which(p2));
|
|
20476
20482
|
if (!python) return null;
|
|
20477
|
-
const dir =
|
|
20483
|
+
const dir = os75.scratchPath("codeam-cr-prereq");
|
|
20478
20484
|
const shim = path29.join(dir, "unzip");
|
|
20479
20485
|
const script = `#!/bin/sh
|
|
20480
20486
|
set -e
|
|
@@ -20496,9 +20502,9 @@ exec ${python} -m zipfile -e "$archive" "$dest"
|
|
|
20496
20502
|
(0, import_node_fs6.chmodSync)(shim, 448);
|
|
20497
20503
|
return dir;
|
|
20498
20504
|
}
|
|
20499
|
-
async function ensureInstallPrerequisites(
|
|
20505
|
+
async function ensureInstallPrerequisites(os75, deps = {}) {
|
|
20500
20506
|
const runner = deps.runner ?? defaultOsRunner;
|
|
20501
|
-
const missing = REQUIRED_TOOLS.filter((t2) =>
|
|
20507
|
+
const missing = REQUIRED_TOOLS.filter((t2) => os75.findInPath(t2) === null);
|
|
20502
20508
|
if (missing.length === 0) return { ok: true, extraPath: [] };
|
|
20503
20509
|
log.info(
|
|
20504
20510
|
"coderabbit",
|
|
@@ -20517,10 +20523,10 @@ async function ensureInstallPrerequisites(os74, deps = {}) {
|
|
|
20517
20523
|
);
|
|
20518
20524
|
}
|
|
20519
20525
|
}
|
|
20520
|
-
const stillMissing = REQUIRED_TOOLS.filter((t2) =>
|
|
20526
|
+
const stillMissing = REQUIRED_TOOLS.filter((t2) => os75.findInPath(t2) === null);
|
|
20521
20527
|
if (stillMissing.length === 0) return { ok: true, extraPath: [] };
|
|
20522
20528
|
if (stillMissing.length === 1 && stillMissing[0] === "unzip") {
|
|
20523
|
-
const shimDir = writeUnzipShim(
|
|
20529
|
+
const shimDir = writeUnzipShim(os75, runner);
|
|
20524
20530
|
if (shimDir) {
|
|
20525
20531
|
log.info("coderabbit", "unzip is unavailable \u2014 using a scoped python zipfile shim");
|
|
20526
20532
|
return { ok: true, extraPath: [shimDir] };
|
|
@@ -20583,15 +20589,15 @@ function summarizeInstallFailure(output) {
|
|
|
20583
20589
|
}
|
|
20584
20590
|
return lines.length > 0 ? lines[lines.length - 1] : null;
|
|
20585
20591
|
}
|
|
20586
|
-
async function ensureCoderabbitInstalled(
|
|
20587
|
-
if (
|
|
20588
|
-
if (
|
|
20592
|
+
async function ensureCoderabbitInstalled(os75, deps = {}) {
|
|
20593
|
+
if (os75.findInPath("coderabbit")) return { ok: true };
|
|
20594
|
+
if (os75.id === "win32") {
|
|
20589
20595
|
return {
|
|
20590
20596
|
ok: false,
|
|
20591
20597
|
error: "CodeRabbit on Windows requires WSL. Install the CLI inside your WSL distribution (curl -fsSL https://cli.coderabbit.ai/install.sh | sh), then try again."
|
|
20592
20598
|
};
|
|
20593
20599
|
}
|
|
20594
|
-
const prereq = await ensureInstallPrerequisites(
|
|
20600
|
+
const prereq = await ensureInstallPrerequisites(os75, deps);
|
|
20595
20601
|
if (!prereq.ok) return { ok: false, error: prereq.error };
|
|
20596
20602
|
const env = { ...process.env };
|
|
20597
20603
|
if (prereq.extraPath.length > 0) {
|
|
@@ -20600,8 +20606,8 @@ async function ensureCoderabbitInstalled(os74, deps = {}) {
|
|
|
20600
20606
|
log.info("coderabbit", "CodeRabbit CLI not found \u2014 installing via the official script");
|
|
20601
20607
|
const run3 = deps.runInstallScript ?? defaultRunInstallScript;
|
|
20602
20608
|
const { code, output } = await run3(env);
|
|
20603
|
-
|
|
20604
|
-
const binary =
|
|
20609
|
+
os75.augmentPath([`${os75.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
|
|
20610
|
+
const binary = os75.findInPath("coderabbit");
|
|
20605
20611
|
const detail = summarizeInstallFailure(output);
|
|
20606
20612
|
if (binary !== null) {
|
|
20607
20613
|
if (code === 0) return { ok: true };
|
|
@@ -20655,10 +20661,10 @@ function coderabbitCredentialLocator() {
|
|
|
20655
20661
|
validate: validateNonEmptyCredential
|
|
20656
20662
|
};
|
|
20657
20663
|
}
|
|
20658
|
-
function coderabbitLoginLauncher(
|
|
20664
|
+
function coderabbitLoginLauncher(os75) {
|
|
20659
20665
|
return {
|
|
20660
20666
|
async ensureInstalled() {
|
|
20661
|
-
const result = await ensureCoderabbitInstalled(
|
|
20667
|
+
const result = await ensureCoderabbitInstalled(os75);
|
|
20662
20668
|
if (!result.ok && result.error) console.error(`
|
|
20663
20669
|
\u2717 ${result.error}
|
|
20664
20670
|
`);
|
|
@@ -20718,8 +20724,8 @@ function pickLine(obj) {
|
|
|
20718
20724
|
function toHunk(raw, groupSeverity) {
|
|
20719
20725
|
if (!raw || typeof raw !== "object") return null;
|
|
20720
20726
|
const o = raw;
|
|
20721
|
-
const
|
|
20722
|
-
if (!
|
|
20727
|
+
const path117 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
|
|
20728
|
+
if (!path117) return null;
|
|
20723
20729
|
const message = asString(
|
|
20724
20730
|
pick(o, [
|
|
20725
20731
|
"comment",
|
|
@@ -20736,7 +20742,7 @@ function toHunk(raw, groupSeverity) {
|
|
|
20736
20742
|
const severity = normSeverity(pick(o, ["severity", "level", "priority", "impact"])) ?? normSeverity(groupSeverity);
|
|
20737
20743
|
const locObj = pick(o, ["location"]) ?? o;
|
|
20738
20744
|
return {
|
|
20739
|
-
path:
|
|
20745
|
+
path: path117.trim(),
|
|
20740
20746
|
line: pickLine(o) ?? pickLine(locObj),
|
|
20741
20747
|
severity,
|
|
20742
20748
|
message: (title && message ? `${title}: ${message}` : title || message).trim() || "(no message)"
|
|
@@ -20819,10 +20825,10 @@ function parsePlain(stdout) {
|
|
|
20819
20825
|
for (const line of stdout.split(/\r?\n/)) {
|
|
20820
20826
|
const m = line.match(HUNK_LINE_RE);
|
|
20821
20827
|
if (!m) continue;
|
|
20822
|
-
const [,
|
|
20823
|
-
if (!
|
|
20828
|
+
const [, path117, lineNo, sevToken, message] = m;
|
|
20829
|
+
if (!path117 || !lineNo || !message) continue;
|
|
20824
20830
|
hunks.push({
|
|
20825
|
-
path:
|
|
20831
|
+
path: path117.trim(),
|
|
20826
20832
|
line: Number(lineNo),
|
|
20827
20833
|
severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
|
|
20828
20834
|
message: message.trim().replace(/^[*-]\s+/, "")
|
|
@@ -20882,8 +20888,8 @@ var CoderabbitRuntimeStrategy = class {
|
|
|
20882
20888
|
meta = getAgent("coderabbit");
|
|
20883
20889
|
mode = "batch";
|
|
20884
20890
|
os;
|
|
20885
|
-
constructor(
|
|
20886
|
-
this.os =
|
|
20891
|
+
constructor(os75) {
|
|
20892
|
+
this.os = os75;
|
|
20887
20893
|
}
|
|
20888
20894
|
getDefaultArgs() {
|
|
20889
20895
|
return ["review", "--agent"];
|
|
@@ -21154,10 +21160,10 @@ function cursorCredentialLocator() {
|
|
|
21154
21160
|
validate: validateNonEmptyCredential
|
|
21155
21161
|
};
|
|
21156
21162
|
}
|
|
21157
|
-
function cursorLoginLauncher(
|
|
21163
|
+
function cursorLoginLauncher(os75) {
|
|
21158
21164
|
return {
|
|
21159
21165
|
async ensureInstalled() {
|
|
21160
|
-
if (
|
|
21166
|
+
if (os75.findInPath("cursor-agent")) return true;
|
|
21161
21167
|
console.error(
|
|
21162
21168
|
"\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"
|
|
21163
21169
|
);
|
|
@@ -21221,8 +21227,8 @@ var CursorRuntimeStrategy = class {
|
|
|
21221
21227
|
meta = getAgent("cursor");
|
|
21222
21228
|
mode = "interactive";
|
|
21223
21229
|
os;
|
|
21224
|
-
constructor(
|
|
21225
|
-
this.os =
|
|
21230
|
+
constructor(os75) {
|
|
21231
|
+
this.os = os75;
|
|
21226
21232
|
}
|
|
21227
21233
|
async prepareLaunch() {
|
|
21228
21234
|
const binary = this.os.findInPath("cursor-agent");
|
|
@@ -21440,10 +21446,10 @@ function aiderCredentialLocator() {
|
|
|
21440
21446
|
validate: validateNonEmptyCredential
|
|
21441
21447
|
};
|
|
21442
21448
|
}
|
|
21443
|
-
function aiderLoginLauncher(
|
|
21449
|
+
function aiderLoginLauncher(os75) {
|
|
21444
21450
|
return {
|
|
21445
21451
|
async ensureInstalled() {
|
|
21446
|
-
if (
|
|
21452
|
+
if (os75.findInPath("aider")) return true;
|
|
21447
21453
|
console.error(
|
|
21448
21454
|
"\n \u2717 aider binary not on PATH.\n Install Aider:\n pip install aider-chat\n then re-run `codeam link aider`.\n"
|
|
21449
21455
|
);
|
|
@@ -21453,7 +21459,7 @@ function aiderLoginLauncher(os74) {
|
|
|
21453
21459
|
console.error(
|
|
21454
21460
|
"\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"
|
|
21455
21461
|
);
|
|
21456
|
-
return (0, import_node_child_process12.spawn)(
|
|
21462
|
+
return (0, import_node_child_process12.spawn)(os75.id === "win32" ? "cmd.exe" : "sh", os75.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
|
|
21457
21463
|
stdio: "ignore"
|
|
21458
21464
|
});
|
|
21459
21465
|
}
|
|
@@ -21737,8 +21743,8 @@ var AiderRuntimeStrategy = class {
|
|
|
21737
21743
|
meta = getAgent("aider");
|
|
21738
21744
|
mode = "interactive";
|
|
21739
21745
|
os;
|
|
21740
|
-
constructor(
|
|
21741
|
-
this.os =
|
|
21746
|
+
constructor(os75) {
|
|
21747
|
+
this.os = os75;
|
|
21742
21748
|
}
|
|
21743
21749
|
async prepareLaunch() {
|
|
21744
21750
|
augmentUserLocalBinPaths();
|
|
@@ -21871,8 +21877,8 @@ function geminiCredentialLocator() {
|
|
|
21871
21877
|
function geminiLoginLauncher() {
|
|
21872
21878
|
return {
|
|
21873
21879
|
async ensureInstalled() {
|
|
21874
|
-
const
|
|
21875
|
-
return
|
|
21880
|
+
const os75 = createOsStrategy();
|
|
21881
|
+
return os75.findInPath("gemini") !== null;
|
|
21876
21882
|
},
|
|
21877
21883
|
launch() {
|
|
21878
21884
|
return (0, import_node_child_process13.spawn)("gemini", ["auth", "login"], { stdio: "inherit" });
|
|
@@ -22062,8 +22068,8 @@ var GeminiRuntimeStrategy = class {
|
|
|
22062
22068
|
meta = getAgent("gemini");
|
|
22063
22069
|
mode = "interactive";
|
|
22064
22070
|
os;
|
|
22065
|
-
constructor(
|
|
22066
|
-
this.os =
|
|
22071
|
+
constructor(os75) {
|
|
22072
|
+
this.os = os75;
|
|
22067
22073
|
}
|
|
22068
22074
|
async prepareLaunch() {
|
|
22069
22075
|
const binary = this.os.findInPath("gemini");
|
|
@@ -22356,8 +22362,8 @@ var KimiRuntimeStrategy = class {
|
|
|
22356
22362
|
meta = getAgent("kimi");
|
|
22357
22363
|
mode = "interactive";
|
|
22358
22364
|
os;
|
|
22359
|
-
constructor(
|
|
22360
|
-
this.os =
|
|
22365
|
+
constructor(os75) {
|
|
22366
|
+
this.os = os75;
|
|
22361
22367
|
}
|
|
22362
22368
|
async prepareLaunch() {
|
|
22363
22369
|
const binary = this.os.findInPath("kimi");
|
|
@@ -22501,8 +22507,8 @@ var OpencodeRuntimeStrategy = class {
|
|
|
22501
22507
|
meta = getAgent("opencode");
|
|
22502
22508
|
mode = "interactive";
|
|
22503
22509
|
os;
|
|
22504
|
-
constructor(
|
|
22505
|
-
this.os =
|
|
22510
|
+
constructor(os75) {
|
|
22511
|
+
this.os = os75;
|
|
22506
22512
|
}
|
|
22507
22513
|
async prepareLaunch() {
|
|
22508
22514
|
const binary = this.os.findInPath("opencode");
|
|
@@ -22588,20 +22594,20 @@ var OpencodeRuntimeStrategy = class {
|
|
|
22588
22594
|
|
|
22589
22595
|
// src/agents/registry.ts
|
|
22590
22596
|
var runtimeBuilders = {
|
|
22591
|
-
claude: (
|
|
22592
|
-
codex: (
|
|
22593
|
-
coderabbit: (
|
|
22594
|
-
cursor: (
|
|
22595
|
-
aider: (
|
|
22596
|
-
gemini: (
|
|
22597
|
-
kimi: (
|
|
22598
|
-
opencode: (
|
|
22597
|
+
claude: (os75) => new ClaudeRuntimeStrategy(os75),
|
|
22598
|
+
codex: (os75) => new CodexRuntimeStrategy(os75),
|
|
22599
|
+
coderabbit: (os75) => new CoderabbitRuntimeStrategy(os75),
|
|
22600
|
+
cursor: (os75) => new CursorRuntimeStrategy(os75),
|
|
22601
|
+
aider: (os75) => new AiderRuntimeStrategy(os75),
|
|
22602
|
+
gemini: (os75) => new GeminiRuntimeStrategy(os75),
|
|
22603
|
+
kimi: (os75) => new KimiRuntimeStrategy(os75),
|
|
22604
|
+
opencode: (os75) => new OpencodeRuntimeStrategy(os75)
|
|
22599
22605
|
};
|
|
22600
22606
|
var deployBuilders = {
|
|
22601
22607
|
claude: () => new ClaudeDeployStrategy(),
|
|
22602
22608
|
codex: () => new CodexDeployStrategy()
|
|
22603
22609
|
};
|
|
22604
|
-
function createAgentStrategy(agent,
|
|
22610
|
+
function createAgentStrategy(agent, os75 = createOsStrategy()) {
|
|
22605
22611
|
if (!AGENT_REGISTRY[agent]?.enabled) {
|
|
22606
22612
|
throw new Error(
|
|
22607
22613
|
`Agent "${agent}" is not supported in this codeam-cli version. Upgrade with 'npm i -g codeam-cli@latest'.`
|
|
@@ -22611,10 +22617,10 @@ function createAgentStrategy(agent, os74 = createOsStrategy()) {
|
|
|
22611
22617
|
if (!build) {
|
|
22612
22618
|
throw new Error(`No runtime strategy registered for agent "${agent}"`);
|
|
22613
22619
|
}
|
|
22614
|
-
return build(
|
|
22620
|
+
return build(os75);
|
|
22615
22621
|
}
|
|
22616
|
-
function createInteractiveAgentStrategy(agent,
|
|
22617
|
-
const s = createAgentStrategy(agent,
|
|
22622
|
+
function createInteractiveAgentStrategy(agent, os75 = createOsStrategy()) {
|
|
22623
|
+
const s = createAgentStrategy(agent, os75);
|
|
22618
22624
|
if (s.mode !== "interactive") {
|
|
22619
22625
|
throw new Error(
|
|
22620
22626
|
`Agent "${agent}" is a batch agent; use createAgentStrategy + .runOneShot for one-shot reviews.`
|
|
@@ -23328,8 +23334,8 @@ function collectChangedFiles(cwd) {
|
|
|
23328
23334
|
}
|
|
23329
23335
|
return [...byPath.values()];
|
|
23330
23336
|
}
|
|
23331
|
-
function restoreCoderabbitOauthBlob(
|
|
23332
|
-
const dir = path41.join(
|
|
23337
|
+
function restoreCoderabbitOauthBlob(os75, value) {
|
|
23338
|
+
const dir = path41.join(os75.homeDir(), ".coderabbit");
|
|
23333
23339
|
(0, import_node_fs7.mkdirSync)(dir, { recursive: true });
|
|
23334
23340
|
let file = "auth.json";
|
|
23335
23341
|
let contents = value.trim();
|
|
@@ -23349,26 +23355,26 @@ function installFailureMessage(result) {
|
|
|
23349
23355
|
return result.error ?? "CodeRabbit CLI could not be installed";
|
|
23350
23356
|
}
|
|
23351
23357
|
async function configureCoderabbit(input, deps = {}) {
|
|
23352
|
-
const
|
|
23358
|
+
const os75 = deps.os ?? createOsStrategy();
|
|
23353
23359
|
const ensureInstalled = deps.ensureInstalled ?? ensureCoderabbitInstalled;
|
|
23354
23360
|
const isLoggedIn = deps.isLoggedIn ?? defaultIsLoggedIn;
|
|
23355
23361
|
const runOAuth = deps.runOAuthLogin ?? runCoderabbitOAuthLogin;
|
|
23356
23362
|
const snapshot = deps.snapshotDir ?? (() => snapshotCredentialDir());
|
|
23357
23363
|
const capture2 = deps.captureCredential ?? ((b) => diffCapturedCredential(b));
|
|
23358
23364
|
const loginWithApiKey = deps.loginWithApiKey ?? defaultLoginWithApiKey;
|
|
23359
|
-
const home =
|
|
23360
|
-
|
|
23361
|
-
|
|
23365
|
+
const home = os75.homeDir();
|
|
23366
|
+
os75.augmentPath(
|
|
23367
|
+
os75.id === "win32" ? [
|
|
23362
23368
|
path41.join(home, ".local", "bin"),
|
|
23363
23369
|
path41.join(process.env.APPDATA ?? path41.join(home, "AppData", "Roaming"), "npm"),
|
|
23364
23370
|
path41.join(home, "scoop", "shims")
|
|
23365
23371
|
] : [path41.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"]
|
|
23366
23372
|
);
|
|
23367
|
-
const installed2 =
|
|
23373
|
+
const installed2 = os75.findInPath("coderabbit") !== null;
|
|
23368
23374
|
const base = () => ({
|
|
23369
23375
|
action: input.action,
|
|
23370
23376
|
supported: true,
|
|
23371
|
-
installed:
|
|
23377
|
+
installed: os75.findInPath("coderabbit") !== null,
|
|
23372
23378
|
loggedIn: false
|
|
23373
23379
|
});
|
|
23374
23380
|
if (input.action === "status") {
|
|
@@ -23382,7 +23388,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
23382
23388
|
const key = (input.apiKey ?? "").trim();
|
|
23383
23389
|
if (!key) return { ...res2, error: "No API key provided" };
|
|
23384
23390
|
if (!res2.installed) {
|
|
23385
|
-
const inst = await ensureInstalled(
|
|
23391
|
+
const inst = await ensureInstalled(os75);
|
|
23386
23392
|
res2.installed = inst.ok;
|
|
23387
23393
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
23388
23394
|
}
|
|
@@ -23406,7 +23412,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
23406
23412
|
}
|
|
23407
23413
|
if (!res2.installed) {
|
|
23408
23414
|
deps.onEvent?.({ kind: "installing" });
|
|
23409
|
-
const inst = await ensureInstalled(
|
|
23415
|
+
const inst = await ensureInstalled(os75);
|
|
23410
23416
|
res2.installed = inst.ok;
|
|
23411
23417
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
23412
23418
|
}
|
|
@@ -23423,7 +23429,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
23423
23429
|
return { ...res2, loggedIn: true, linked: true };
|
|
23424
23430
|
}
|
|
23425
23431
|
try {
|
|
23426
|
-
restoreCoderabbitOauthBlob(
|
|
23432
|
+
restoreCoderabbitOauthBlob(os75, cred.credential);
|
|
23427
23433
|
} catch (err) {
|
|
23428
23434
|
return {
|
|
23429
23435
|
...res2,
|
|
@@ -23447,7 +23453,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
23447
23453
|
const res2 = base();
|
|
23448
23454
|
if (!installed2) {
|
|
23449
23455
|
deps.onEvent?.({ kind: "installing" });
|
|
23450
|
-
const inst = await ensureInstalled(
|
|
23456
|
+
const inst = await ensureInstalled(os75);
|
|
23451
23457
|
res2.installed = inst.ok;
|
|
23452
23458
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
23453
23459
|
}
|
|
@@ -23487,7 +23493,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
23487
23493
|
}
|
|
23488
23494
|
const res = base();
|
|
23489
23495
|
if (!res.installed) {
|
|
23490
|
-
const inst = await ensureInstalled(
|
|
23496
|
+
const inst = await ensureInstalled(os75);
|
|
23491
23497
|
res.installed = inst.ok;
|
|
23492
23498
|
if (!inst.ok) return { ...res, error: installFailureMessage(inst) };
|
|
23493
23499
|
}
|
|
@@ -24924,19 +24930,49 @@ function missingExpoWebPackages(cwd) {
|
|
|
24924
24930
|
(p2) => !fs45.existsSync(path52.join(cwd, "node_modules", p2, "package.json"))
|
|
24925
24931
|
);
|
|
24926
24932
|
}
|
|
24933
|
+
function missingExpoPackages(cwd) {
|
|
24934
|
+
const core = fs45.existsSync(path52.join(cwd, "node_modules", "expo", "package.json")) ? [] : ["expo"];
|
|
24935
|
+
return [...core, ...missingExpoWebPackages(cwd)];
|
|
24936
|
+
}
|
|
24937
|
+
var EXPO_SDK_BY_REACT_NATIVE = {
|
|
24938
|
+
"0.76": "52",
|
|
24939
|
+
"0.79": "53",
|
|
24940
|
+
"0.81": "54"
|
|
24941
|
+
};
|
|
24942
|
+
var WEB_PACKAGES_BY_SDK = {
|
|
24943
|
+
"54": { "react-native-web": "~0.21.0", "react-dom": "19.1.0", "@expo/metro-runtime": "~6.1.2" }
|
|
24944
|
+
};
|
|
24945
|
+
function expoSdkOf(cwd) {
|
|
24946
|
+
try {
|
|
24947
|
+
const raw = JSON.parse(
|
|
24948
|
+
fs45.readFileSync(path52.join(cwd, "node_modules", "react-native", "package.json"), "utf8")
|
|
24949
|
+
);
|
|
24950
|
+
const m = typeof raw.version === "string" ? /^(\d+\.\d+)\./.exec(raw.version) : null;
|
|
24951
|
+
return m ? EXPO_SDK_BY_REACT_NATIVE[m[1]] ?? null : null;
|
|
24952
|
+
} catch {
|
|
24953
|
+
return null;
|
|
24954
|
+
}
|
|
24955
|
+
}
|
|
24927
24956
|
function expoWebInstallSpecs(cwd, missing) {
|
|
24928
24957
|
let pinned = {};
|
|
24929
24958
|
try {
|
|
24930
24959
|
const raw = JSON.parse(
|
|
24931
24960
|
fs45.readFileSync(path52.join(cwd, "node_modules", "expo", "bundledNativeModules.json"), "utf8")
|
|
24932
24961
|
);
|
|
24933
|
-
if (raw && typeof raw === "object" && !Array.isArray(raw))
|
|
24962
|
+
if (raw && typeof raw === "object" && !Array.isArray(raw))
|
|
24963
|
+
pinned = raw;
|
|
24934
24964
|
} catch {
|
|
24935
24965
|
}
|
|
24936
|
-
|
|
24966
|
+
const sdk = expoSdkOf(cwd);
|
|
24967
|
+
const web = sdk ? WEB_PACKAGES_BY_SDK[sdk] ?? {} : {};
|
|
24968
|
+
return missing.map((p2) => {
|
|
24969
|
+
if (typeof pinned[p2] === "string") return `${p2}@${String(pinned[p2])}`;
|
|
24970
|
+
if (p2 === "expo") return sdk ? `expo@~${sdk}.0.0` : "expo";
|
|
24971
|
+
return web[p2] ? `${p2}@${web[p2]}` : p2;
|
|
24972
|
+
});
|
|
24937
24973
|
}
|
|
24938
24974
|
function expoWebDepsInstall(cwd) {
|
|
24939
|
-
const missing =
|
|
24975
|
+
const missing = missingExpoPackages(cwd);
|
|
24940
24976
|
if (missing.length === 0) return null;
|
|
24941
24977
|
return {
|
|
24942
24978
|
cmd: "npm",
|
|
@@ -25187,11 +25223,41 @@ function stopChild(child) {
|
|
|
25187
25223
|
|
|
25188
25224
|
// src/services/preview/run-setup.ts
|
|
25189
25225
|
var import_child_process18 = require("child_process");
|
|
25226
|
+
var fs46 = __toESM(require("fs"));
|
|
25227
|
+
var os35 = __toESM(require("os"));
|
|
25228
|
+
var path53 = __toESM(require("path"));
|
|
25229
|
+
function npmCacheOverride(env = process.env, home = os35.homedir(), ownerUid = (p2) => {
|
|
25230
|
+
try {
|
|
25231
|
+
return fs46.statSync(p2).uid;
|
|
25232
|
+
} catch {
|
|
25233
|
+
return null;
|
|
25234
|
+
}
|
|
25235
|
+
}, uid = process.getuid?.()) {
|
|
25236
|
+
const cache = env.npm_config_cache;
|
|
25237
|
+
if (!cache || uid === void 0) return {};
|
|
25238
|
+
const foreign = (p2) => {
|
|
25239
|
+
const owner = ownerUid(p2);
|
|
25240
|
+
return owner !== null && owner !== uid;
|
|
25241
|
+
};
|
|
25242
|
+
const roots = [cache, path53.join(cache, "_cacache"), path53.join(cache, "_logs")];
|
|
25243
|
+
const indexes = [
|
|
25244
|
+
path53.join(cache, "_cacache", "index-v5"),
|
|
25245
|
+
path53.join(cache, "_cacache", "content-v2", "sha512")
|
|
25246
|
+
];
|
|
25247
|
+
const entries2 = indexes.flatMap((d3) => {
|
|
25248
|
+
try {
|
|
25249
|
+
return fs46.readdirSync(d3).map((e) => path53.join(d3, e));
|
|
25250
|
+
} catch {
|
|
25251
|
+
return [];
|
|
25252
|
+
}
|
|
25253
|
+
});
|
|
25254
|
+
return [...roots, ...indexes, ...entries2].some(foreign) ? { npm_config_cache: path53.join(home, ".npm") } : {};
|
|
25255
|
+
}
|
|
25190
25256
|
function runSetupCommand(cmd, args2, cwd, env, opts) {
|
|
25191
25257
|
return new Promise((resolve13) => {
|
|
25192
25258
|
const child = (0, import_child_process18.spawn)(cmd, args2, {
|
|
25193
25259
|
cwd,
|
|
25194
|
-
env: { ...process.env, ...env ?? {} },
|
|
25260
|
+
env: { ...process.env, ...npmCacheOverride(), ...env ?? {} },
|
|
25195
25261
|
stdio: ["ignore", "pipe", "pipe"]
|
|
25196
25262
|
});
|
|
25197
25263
|
let settled = false;
|
|
@@ -25575,8 +25641,8 @@ function isComposerInstallCommand(cmd, args2) {
|
|
|
25575
25641
|
}
|
|
25576
25642
|
|
|
25577
25643
|
// src/services/preview/script-candidates.ts
|
|
25578
|
-
var
|
|
25579
|
-
var
|
|
25644
|
+
var fs49 = __toESM(require("fs"));
|
|
25645
|
+
var path56 = __toESM(require("path"));
|
|
25580
25646
|
var EXCLUDE_RE = /(^|:)(deploy|publish|release|build|test|e2e|lint|format|typecheck|type-check|clean|prebuild|postinstall|preinstall|prepare|install|migrate|seed|db|prisma|codegen|storybook-build)(:|$)/i;
|
|
25581
25647
|
var EXCLUDE_BODY_RE = /\b(run:android|run:ios|gradlew|fastlane|xcodebuild|eas build|eas submit)\b/i;
|
|
25582
25648
|
var MAX_APPS = 40;
|
|
@@ -25594,7 +25660,7 @@ function frameworkFor(pkg, body) {
|
|
|
25594
25660
|
}
|
|
25595
25661
|
function readPkg(file) {
|
|
25596
25662
|
try {
|
|
25597
|
-
return JSON.parse(
|
|
25663
|
+
return JSON.parse(fs49.readFileSync(file, "utf8"));
|
|
25598
25664
|
} catch {
|
|
25599
25665
|
return null;
|
|
25600
25666
|
}
|
|
@@ -25604,7 +25670,7 @@ function expandGlob(root, pattern) {
|
|
|
25604
25670
|
if (!clean.endsWith("/*")) return [clean];
|
|
25605
25671
|
const base = clean.slice(0, -2);
|
|
25606
25672
|
try {
|
|
25607
|
-
return
|
|
25673
|
+
return fs49.readdirSync(path56.join(root, base), { withFileTypes: true }).filter((d3) => d3.isDirectory() && !d3.name.startsWith(".") && d3.name !== "node_modules").map((d3) => path56.join(base, d3.name));
|
|
25608
25674
|
} catch {
|
|
25609
25675
|
return [];
|
|
25610
25676
|
}
|
|
@@ -25613,7 +25679,7 @@ function workspaceDirs(root, rootPkg) {
|
|
|
25613
25679
|
const ws = rootPkg?.workspaces;
|
|
25614
25680
|
const patterns = Array.isArray(ws) ? ws : ws?.packages ?? [];
|
|
25615
25681
|
try {
|
|
25616
|
-
const pnpm =
|
|
25682
|
+
const pnpm = fs49.readFileSync(path56.join(root, "pnpm-workspace.yaml"), "utf8");
|
|
25617
25683
|
for (const m of pnpm.matchAll(/^\s*-\s*['"]?([^'"\n]+)['"]?\s*$/gm)) patterns.push(m[1]);
|
|
25618
25684
|
} catch {
|
|
25619
25685
|
}
|
|
@@ -25624,14 +25690,14 @@ function workspaceDirs(root, rootPkg) {
|
|
|
25624
25690
|
}
|
|
25625
25691
|
function listScriptCandidates(root) {
|
|
25626
25692
|
const out2 = [];
|
|
25627
|
-
const rootPkg = readPkg(
|
|
25693
|
+
const rootPkg = readPkg(path56.join(root, "package.json"));
|
|
25628
25694
|
const add = (pkg, appDir) => {
|
|
25629
25695
|
for (const [script, body] of Object.entries(pkg.scripts ?? {})) {
|
|
25630
25696
|
if (out2.length >= MAX_CANDIDATES) return;
|
|
25631
25697
|
if (EXCLUDE_RE.test(script) || EXCLUDE_BODY_RE.test(body)) continue;
|
|
25632
25698
|
const fw = frameworkFor(pkg, body);
|
|
25633
25699
|
out2.push({
|
|
25634
|
-
app: pkg.name ?? (appDir === "." ?
|
|
25700
|
+
app: pkg.name ?? (appDir === "." ? path56.basename(root) : appDir),
|
|
25635
25701
|
appDir,
|
|
25636
25702
|
script,
|
|
25637
25703
|
body,
|
|
@@ -25645,8 +25711,8 @@ function listScriptCandidates(root) {
|
|
|
25645
25711
|
};
|
|
25646
25712
|
if (rootPkg) add(rootPkg, ".");
|
|
25647
25713
|
for (const dir of workspaceDirs(root, rootPkg)) {
|
|
25648
|
-
const pkg = readPkg(
|
|
25649
|
-
if (pkg) add(pkg, dir.split(
|
|
25714
|
+
const pkg = readPkg(path56.join(root, dir, "package.json"));
|
|
25715
|
+
if (pkg) add(pkg, dir.split(path56.sep).join("/"));
|
|
25650
25716
|
}
|
|
25651
25717
|
return out2;
|
|
25652
25718
|
}
|
|
@@ -26398,31 +26464,31 @@ async function readActivePreviewMarker(cwd, homeDir2) {
|
|
|
26398
26464
|
}
|
|
26399
26465
|
|
|
26400
26466
|
// src/agents/acp/guardrail-config.ts
|
|
26401
|
-
var
|
|
26402
|
-
var
|
|
26403
|
-
var
|
|
26467
|
+
var fs54 = __toESM(require("fs"));
|
|
26468
|
+
var path61 = __toESM(require("path"));
|
|
26469
|
+
var os38 = __toESM(require("os"));
|
|
26404
26470
|
var current = null;
|
|
26405
|
-
function guardrailConfigPath(homeDir2 =
|
|
26406
|
-
return
|
|
26471
|
+
function guardrailConfigPath(homeDir2 = os38.homedir()) {
|
|
26472
|
+
return path61.join(homeDir2, ".codeam", "guardrails.json");
|
|
26407
26473
|
}
|
|
26408
|
-
function loadGuardrailPolicy(homeDir2 =
|
|
26474
|
+
function loadGuardrailPolicy(homeDir2 = os38.homedir()) {
|
|
26409
26475
|
try {
|
|
26410
|
-
current = normalizeGuardrailPolicy(JSON.parse(
|
|
26476
|
+
current = normalizeGuardrailPolicy(JSON.parse(fs54.readFileSync(guardrailConfigPath(homeDir2), "utf8")));
|
|
26411
26477
|
} catch {
|
|
26412
26478
|
current = { ...DEFAULT_GUARDRAIL_POLICY };
|
|
26413
26479
|
}
|
|
26414
26480
|
return current;
|
|
26415
26481
|
}
|
|
26416
|
-
function getGuardrailPolicy(homeDir2 =
|
|
26482
|
+
function getGuardrailPolicy(homeDir2 = os38.homedir()) {
|
|
26417
26483
|
return current ?? loadGuardrailPolicy(homeDir2);
|
|
26418
26484
|
}
|
|
26419
|
-
function setGuardrailPolicy(raw, homeDir2 =
|
|
26485
|
+
function setGuardrailPolicy(raw, homeDir2 = os38.homedir()) {
|
|
26420
26486
|
const next = normalizeGuardrailPolicy(raw);
|
|
26421
26487
|
current = next;
|
|
26422
26488
|
try {
|
|
26423
26489
|
const p2 = guardrailConfigPath(homeDir2);
|
|
26424
|
-
|
|
26425
|
-
|
|
26490
|
+
fs54.mkdirSync(path61.dirname(p2), { recursive: true });
|
|
26491
|
+
fs54.writeFileSync(p2, JSON.stringify(next, null, 2));
|
|
26426
26492
|
} catch {
|
|
26427
26493
|
}
|
|
26428
26494
|
return next;
|
|
@@ -26438,22 +26504,22 @@ function shouldOfferOneMRecovery(opts) {
|
|
|
26438
26504
|
}
|
|
26439
26505
|
|
|
26440
26506
|
// src/commands/host/house-proxy-config.ts
|
|
26441
|
-
var
|
|
26442
|
-
var
|
|
26443
|
-
var
|
|
26507
|
+
var fs55 = __toESM(require("fs"));
|
|
26508
|
+
var os39 = __toESM(require("os"));
|
|
26509
|
+
var path62 = __toESM(require("path"));
|
|
26444
26510
|
function houseProxyConfigPath() {
|
|
26445
|
-
return
|
|
26511
|
+
return path62.join(os39.homedir(), ".codeam", "house-proxy.json");
|
|
26446
26512
|
}
|
|
26447
26513
|
var DEPLOY_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
26448
26514
|
function deployHouseProxyConfigPath(deployId) {
|
|
26449
26515
|
if (!DEPLOY_ID_RE.test(deployId) || deployId.includes("..")) return null;
|
|
26450
|
-
return
|
|
26516
|
+
return path62.join(os39.homedir(), ".codeam", "house-proxy", `${deployId}.json`);
|
|
26451
26517
|
}
|
|
26452
26518
|
function writeJson0600(file, value) {
|
|
26453
|
-
|
|
26519
|
+
fs55.mkdirSync(path62.dirname(file), { recursive: true, mode: 448 });
|
|
26454
26520
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
26455
|
-
|
|
26456
|
-
|
|
26521
|
+
fs55.writeFileSync(tmp, JSON.stringify(value, null, 2), { encoding: "utf8", mode: 384 });
|
|
26522
|
+
fs55.renameSync(tmp, file);
|
|
26457
26523
|
restrictToOwner(file);
|
|
26458
26524
|
}
|
|
26459
26525
|
function persistHouseProxyConfig(config, deployId) {
|
|
@@ -26470,7 +26536,7 @@ function persistHouseProxyConfig(config, deployId) {
|
|
|
26470
26536
|
}
|
|
26471
26537
|
function clearHouseProxyConfig(deployId) {
|
|
26472
26538
|
try {
|
|
26473
|
-
|
|
26539
|
+
fs55.rmSync(houseProxyConfigPath(), { force: true });
|
|
26474
26540
|
const perDeploy = deployId ? deployHouseProxyConfigPath(deployId) : null;
|
|
26475
26541
|
if (perDeploy) writeJson0600(perDeploy, { none: true });
|
|
26476
26542
|
} catch {
|
|
@@ -26493,12 +26559,12 @@ function houseProxyTokenExpiring(token, nowSec, windowSec = HOUSE_PROXY_REFRESH_
|
|
|
26493
26559
|
}
|
|
26494
26560
|
function persistedConfigFile(deployId) {
|
|
26495
26561
|
const perDeploy = deployId ? deployHouseProxyConfigPath(deployId) : null;
|
|
26496
|
-
const file = perDeploy &&
|
|
26497
|
-
return
|
|
26562
|
+
const file = perDeploy && fs55.existsSync(perDeploy) ? perDeploy : houseProxyConfigPath();
|
|
26563
|
+
return fs55.existsSync(file) ? file : null;
|
|
26498
26564
|
}
|
|
26499
26565
|
function readConfigObject(file) {
|
|
26500
26566
|
try {
|
|
26501
|
-
const parsed = JSON.parse(
|
|
26567
|
+
const parsed = JSON.parse(fs55.readFileSync(file, "utf8"));
|
|
26502
26568
|
return typeof parsed === "object" && parsed !== null ? parsed : null;
|
|
26503
26569
|
} catch {
|
|
26504
26570
|
return null;
|
|
@@ -26531,8 +26597,8 @@ function rewriteHouseProxyToken(deployId, freshToken) {
|
|
|
26531
26597
|
function readHouseProxyChildEnv(deployId) {
|
|
26532
26598
|
try {
|
|
26533
26599
|
const perDeploy = deployId ? deployHouseProxyConfigPath(deployId) : null;
|
|
26534
|
-
const file = perDeploy &&
|
|
26535
|
-
const raw =
|
|
26600
|
+
const file = perDeploy && fs55.existsSync(perDeploy) ? perDeploy : houseProxyConfigPath();
|
|
26601
|
+
const raw = fs55.readFileSync(file, "utf8");
|
|
26536
26602
|
const parsed = JSON.parse(raw);
|
|
26537
26603
|
if (typeof parsed !== "object" || parsed === null) return {};
|
|
26538
26604
|
const o = parsed;
|
|
@@ -26642,9 +26708,9 @@ function pickHouseProxyEnv(env) {
|
|
|
26642
26708
|
}
|
|
26643
26709
|
|
|
26644
26710
|
// src/lib/provider-routing.ts
|
|
26645
|
-
var
|
|
26646
|
-
var
|
|
26647
|
-
var
|
|
26711
|
+
var fs56 = __toESM(require("fs"));
|
|
26712
|
+
var os40 = __toESM(require("os"));
|
|
26713
|
+
var path63 = __toESM(require("path"));
|
|
26648
26714
|
var PROVIDER_BASE_URL_ENV_KEYS = [
|
|
26649
26715
|
"ANTHROPIC_BASE_URL",
|
|
26650
26716
|
"OPENAI_BASE_URL",
|
|
@@ -26666,15 +26732,15 @@ function redactUrlToOrigin(raw) {
|
|
|
26666
26732
|
}
|
|
26667
26733
|
}
|
|
26668
26734
|
function readOpencodeProviderOrigins(opts = {}) {
|
|
26669
|
-
const home = opts.homeDir ??
|
|
26670
|
-
const readFile8 = opts.readFile ?? ((f) =>
|
|
26735
|
+
const home = opts.homeDir ?? os40.homedir();
|
|
26736
|
+
const readFile8 = opts.readFile ?? ((f) => fs56.readFileSync(f, "utf8"));
|
|
26671
26737
|
const candidates = [];
|
|
26672
26738
|
if (opts.cwd) {
|
|
26673
|
-
candidates.push(
|
|
26739
|
+
candidates.push(path63.join(opts.cwd, "opencode.json"), path63.join(opts.cwd, "opencode.jsonc"));
|
|
26674
26740
|
}
|
|
26675
26741
|
candidates.push(
|
|
26676
|
-
|
|
26677
|
-
|
|
26742
|
+
path63.join(home, ".config", "opencode", "opencode.json"),
|
|
26743
|
+
path63.join(home, ".config", "opencode", "opencode.jsonc")
|
|
26678
26744
|
);
|
|
26679
26745
|
const out2 = [];
|
|
26680
26746
|
const seen2 = /* @__PURE__ */ new Set();
|
|
@@ -27028,8 +27094,8 @@ function adapterExitMessage(opts) {
|
|
|
27028
27094
|
|
|
27029
27095
|
// src/services/preview/start-orchestrator.ts
|
|
27030
27096
|
var import_child_process20 = require("child_process");
|
|
27031
|
-
var
|
|
27032
|
-
var
|
|
27097
|
+
var fs60 = __toESM(require("fs"));
|
|
27098
|
+
var path67 = __toESM(require("path"));
|
|
27033
27099
|
var import_which3 = __toESM(require("which"));
|
|
27034
27100
|
|
|
27035
27101
|
// src/services/preview/detection-cwd.ts
|
|
@@ -27063,13 +27129,13 @@ function resolveDetectionCwd(root, cwd) {
|
|
|
27063
27129
|
|
|
27064
27130
|
// src/services/project-env/index.ts
|
|
27065
27131
|
var import_fs6 = require("fs");
|
|
27066
|
-
var
|
|
27132
|
+
var path66 = __toESM(require("path"));
|
|
27067
27133
|
|
|
27068
27134
|
// src/beads/project-key.ts
|
|
27069
27135
|
var import_child_process19 = require("child_process");
|
|
27070
27136
|
var crypto2 = __toESM(require("crypto"));
|
|
27071
|
-
var
|
|
27072
|
-
var
|
|
27137
|
+
var fs58 = __toESM(require("fs"));
|
|
27138
|
+
var path65 = __toESM(require("path"));
|
|
27073
27139
|
function normalizeOrigin(raw) {
|
|
27074
27140
|
const trimmed = raw.trim();
|
|
27075
27141
|
if (!trimmed) return null;
|
|
@@ -27095,17 +27161,17 @@ function normalizeOrigin(raw) {
|
|
|
27095
27161
|
return `${host2}/${pathPart}`;
|
|
27096
27162
|
}
|
|
27097
27163
|
function findRepoRoot(cwd) {
|
|
27098
|
-
let dir =
|
|
27164
|
+
let dir = path65.resolve(cwd);
|
|
27099
27165
|
const seen2 = /* @__PURE__ */ new Set();
|
|
27100
27166
|
for (let i = 0; i < 256; i++) {
|
|
27101
27167
|
if (seen2.has(dir)) return null;
|
|
27102
27168
|
seen2.add(dir);
|
|
27103
27169
|
try {
|
|
27104
|
-
const stat3 =
|
|
27170
|
+
const stat3 = fs58.statSync(path65.join(dir, ".git"), { throwIfNoEntry: false });
|
|
27105
27171
|
if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
|
|
27106
27172
|
} catch {
|
|
27107
27173
|
}
|
|
27108
|
-
const parent =
|
|
27174
|
+
const parent = path65.dirname(dir);
|
|
27109
27175
|
if (parent === dir) return null;
|
|
27110
27176
|
dir = parent;
|
|
27111
27177
|
}
|
|
@@ -27116,7 +27182,7 @@ var _execSeam3 = {
|
|
|
27116
27182
|
const out2 = (0, import_child_process19.execFileSync)(file, args2, opts);
|
|
27117
27183
|
return typeof out2 === "string" ? out2 : out2.toString("utf8");
|
|
27118
27184
|
},
|
|
27119
|
-
realpath: (p2) =>
|
|
27185
|
+
realpath: (p2) => fs58.realpathSync(p2)
|
|
27120
27186
|
};
|
|
27121
27187
|
function readOrigin(cwd) {
|
|
27122
27188
|
try {
|
|
@@ -27145,7 +27211,7 @@ function deriveProjectIdentity(cwd = process.cwd()) {
|
|
|
27145
27211
|
} catch {
|
|
27146
27212
|
}
|
|
27147
27213
|
const hash = crypto2.createHash("sha256").update(real).digest("hex");
|
|
27148
|
-
return { projectKey: `path:${hash}`, projectLabel:
|
|
27214
|
+
return { projectKey: `path:${hash}`, projectLabel: path65.basename(real) || "project" };
|
|
27149
27215
|
}
|
|
27150
27216
|
|
|
27151
27217
|
// src/services/project-env/index.ts
|
|
@@ -27158,7 +27224,7 @@ async function readIfExists(p2) {
|
|
|
27158
27224
|
}
|
|
27159
27225
|
async function syncProjectEnvUp(cwd, ctx) {
|
|
27160
27226
|
if (!ctx.pluginAuthToken) return;
|
|
27161
|
-
const content = await readIfExists(
|
|
27227
|
+
const content = await readIfExists(path66.join(cwd, ".env"));
|
|
27162
27228
|
if (content == null) return;
|
|
27163
27229
|
try {
|
|
27164
27230
|
const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
|
|
@@ -27180,7 +27246,7 @@ async function syncProjectEnvUp(cwd, ctx) {
|
|
|
27180
27246
|
}
|
|
27181
27247
|
async function restoreProjectEnvIfMissing(cwd, ctx) {
|
|
27182
27248
|
if (!ctx.pluginAuthToken) return false;
|
|
27183
|
-
const envPath =
|
|
27249
|
+
const envPath = path66.join(cwd, ".env");
|
|
27184
27250
|
if (await readIfExists(envPath) != null) return false;
|
|
27185
27251
|
try {
|
|
27186
27252
|
const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
|
|
@@ -27191,7 +27257,7 @@ async function restoreProjectEnvIfMissing(cwd, ctx) {
|
|
|
27191
27257
|
projectKey
|
|
27192
27258
|
});
|
|
27193
27259
|
if (!stored) return false;
|
|
27194
|
-
const tmp =
|
|
27260
|
+
const tmp = path66.join(cwd, ".env.codeam-restore.tmp");
|
|
27195
27261
|
await import_fs6.promises.writeFile(tmp, stored.content, { encoding: "utf8", mode: 384 });
|
|
27196
27262
|
await import_fs6.promises.rename(tmp, envPath);
|
|
27197
27263
|
log.info("project-env", `restored .env (${stored.keyCount} vars) for ${projectLabel}`);
|
|
@@ -27507,8 +27573,8 @@ function normalizeDetectionForSpawn(detection, cwd) {
|
|
|
27507
27573
|
if (args2.length === 0) return detection;
|
|
27508
27574
|
const binName = args2[0];
|
|
27509
27575
|
if (binName.startsWith("-")) return detection;
|
|
27510
|
-
const binPath =
|
|
27511
|
-
if (!
|
|
27576
|
+
const binPath = path67.join(cwd, "node_modules", ".bin", binName);
|
|
27577
|
+
if (!fs60.existsSync(binPath)) return detection;
|
|
27512
27578
|
return {
|
|
27513
27579
|
...detection,
|
|
27514
27580
|
command: binPath,
|
|
@@ -27565,9 +27631,15 @@ async function runExpoBringUp(ctx) {
|
|
|
27565
27631
|
let web = webInstall === null;
|
|
27566
27632
|
if (webInstall) {
|
|
27567
27633
|
emitProgress("SETUP_RUN", `${webInstall.cmd} ${webInstall.args.join(" ")} (Expo web preview)`);
|
|
27568
|
-
const r = await runSetupCommand(
|
|
27569
|
-
|
|
27570
|
-
|
|
27634
|
+
const r = await runSetupCommand(
|
|
27635
|
+
webInstall.cmd,
|
|
27636
|
+
webInstall.args,
|
|
27637
|
+
ctx.cwd,
|
|
27638
|
+
detection.env,
|
|
27639
|
+
{
|
|
27640
|
+
timeoutMs: INSTALL_TIMEOUT_MS2
|
|
27641
|
+
}
|
|
27642
|
+
);
|
|
27571
27643
|
web = r.status === "ok";
|
|
27572
27644
|
if (!web) emitProgress("SETUP_RUN", `web packages not installed (${r.status}) \u2014 Expo Go only`);
|
|
27573
27645
|
}
|
|
@@ -27810,7 +27882,13 @@ async function startDevServer(ctx, extraEnv = {}) {
|
|
|
27810
27882
|
// never shows its "Serving HTTP on … (http://0.0.0.0:8000/)" line while it
|
|
27811
27883
|
// already serves — every such preview ended in a 120 s ready_timeout
|
|
27812
27884
|
// (codeagent-nczt.9). First, so the project's own env can still override it.
|
|
27813
|
-
env: {
|
|
27885
|
+
env: {
|
|
27886
|
+
PYTHONUNBUFFERED: "1",
|
|
27887
|
+
...process.env,
|
|
27888
|
+
...npmCacheOverride(),
|
|
27889
|
+
...spawnable.env ?? {},
|
|
27890
|
+
...extraEnv
|
|
27891
|
+
},
|
|
27814
27892
|
stdio: ["ignore", "pipe", "pipe"],
|
|
27815
27893
|
// POSIX: lead a new process group so teardown can SIGTERM the whole
|
|
27816
27894
|
// tree. Dev servers fork worker children that bind the port; killing
|
|
@@ -27844,7 +27922,7 @@ async function startDevServer(ctx, extraEnv = {}) {
|
|
|
27844
27922
|
killProcessTree(devServer, "SIGTERM");
|
|
27845
27923
|
emit2(USER_EVENTS.PREVIEW_ERROR, {
|
|
27846
27924
|
stage: "spawn",
|
|
27847
|
-
message: describeSpawnFailure(spawnError, spawnable.command,
|
|
27925
|
+
message: describeSpawnFailure(spawnError, spawnable.command, path67.relative(ctx.rootCwd, cwd)) ?? `The dev server exited (code ${outcome.code}) before it was ready. It may need a database or other services.`,
|
|
27848
27926
|
stderrTail: stripAnsi(outputTail).slice(-8e3)
|
|
27849
27927
|
});
|
|
27850
27928
|
return null;
|
|
@@ -27979,9 +28057,9 @@ function describeSpawnFailure(err, command2, relDir) {
|
|
|
27979
28057
|
|
|
27980
28058
|
// src/beads/bd-adapter.ts
|
|
27981
28059
|
var import_child_process21 = require("child_process");
|
|
27982
|
-
var
|
|
27983
|
-
var
|
|
27984
|
-
var
|
|
28060
|
+
var fs61 = __toESM(require("fs"));
|
|
28061
|
+
var os41 = __toESM(require("os"));
|
|
28062
|
+
var path68 = __toESM(require("path"));
|
|
27985
28063
|
|
|
27986
28064
|
// src/beads/schema-migrate.ts
|
|
27987
28065
|
var SCHEMA_SKEW_RE = /Error 1146|table not found|refusing to auto-apply \d+ pending schema migration/i;
|
|
@@ -28030,11 +28108,11 @@ function _defaultResolveBundled() {
|
|
|
28030
28108
|
} catch {
|
|
28031
28109
|
return null;
|
|
28032
28110
|
}
|
|
28033
|
-
const binDir =
|
|
28111
|
+
const binDir = path68.join(path68.dirname(pkgJsonPath), "bin");
|
|
28034
28112
|
const binaryName = process.platform === "win32" ? "bd.exe" : "bd";
|
|
28035
|
-
const binaryPath =
|
|
28113
|
+
const binaryPath = path68.join(binDir, binaryName);
|
|
28036
28114
|
try {
|
|
28037
|
-
|
|
28115
|
+
fs61.accessSync(binaryPath, fs61.constants.F_OK);
|
|
28038
28116
|
return binaryPath;
|
|
28039
28117
|
} catch {
|
|
28040
28118
|
return null;
|
|
@@ -28044,13 +28122,13 @@ function resolveBdOnPath() {
|
|
|
28044
28122
|
return _resolveSeam.resolveOnPath();
|
|
28045
28123
|
}
|
|
28046
28124
|
function _defaultResolveOnPath() {
|
|
28047
|
-
const dirs = (process.env.PATH ?? "").split(
|
|
28125
|
+
const dirs = (process.env.PATH ?? "").split(path68.delimiter).filter(Boolean);
|
|
28048
28126
|
const candidates = process.platform === "win32" ? ["bd.exe", "bd.cmd", "bd"] : ["bd"];
|
|
28049
28127
|
for (const dir of dirs) {
|
|
28050
28128
|
for (const candidate of candidates) {
|
|
28051
|
-
const full =
|
|
28129
|
+
const full = path68.join(dir, candidate);
|
|
28052
28130
|
try {
|
|
28053
|
-
|
|
28131
|
+
fs61.accessSync(full, fs61.constants.F_OK);
|
|
28054
28132
|
return full;
|
|
28055
28133
|
} catch {
|
|
28056
28134
|
}
|
|
@@ -28137,7 +28215,7 @@ var BdAdapter = class {
|
|
|
28137
28215
|
const env = { ...process.env };
|
|
28138
28216
|
if (!env.HOME) {
|
|
28139
28217
|
try {
|
|
28140
|
-
const home =
|
|
28218
|
+
const home = os41.homedir();
|
|
28141
28219
|
if (home) env.HOME = home;
|
|
28142
28220
|
} catch {
|
|
28143
28221
|
}
|
|
@@ -28239,9 +28317,9 @@ function coerceIssue(row, projectKey) {
|
|
|
28239
28317
|
|
|
28240
28318
|
// src/beads/provisioner.ts
|
|
28241
28319
|
var import_child_process24 = require("child_process");
|
|
28242
|
-
var
|
|
28243
|
-
var
|
|
28244
|
-
var
|
|
28320
|
+
var fs63 = __toESM(require("fs"));
|
|
28321
|
+
var os43 = __toESM(require("os"));
|
|
28322
|
+
var path70 = __toESM(require("path"));
|
|
28245
28323
|
|
|
28246
28324
|
// src/beads/install-bd.ts
|
|
28247
28325
|
var import_child_process22 = require("child_process");
|
|
@@ -28306,9 +28384,9 @@ async function installBd(platform3 = process.platform) {
|
|
|
28306
28384
|
|
|
28307
28385
|
// src/beads/install-dolt.ts
|
|
28308
28386
|
var import_child_process23 = require("child_process");
|
|
28309
|
-
var
|
|
28310
|
-
var
|
|
28311
|
-
var
|
|
28387
|
+
var fs62 = __toESM(require("fs"));
|
|
28388
|
+
var os42 = __toESM(require("os"));
|
|
28389
|
+
var path69 = __toESM(require("path"));
|
|
28312
28390
|
var DOLT_INSTALL_SH_URL = "https://github.com/dolthub/dolt/releases/latest/download/install.sh";
|
|
28313
28391
|
var DOLT_MSI_URL = "https://github.com/dolthub/dolt/releases/latest/download/dolt-windows-amd64.msi";
|
|
28314
28392
|
function resolveDoltInstallStrategy(platform3) {
|
|
@@ -28348,11 +28426,11 @@ function resolveDoltInstallStrategy(platform3) {
|
|
|
28348
28426
|
}
|
|
28349
28427
|
var DOLT_RELEASE_BASE = "https://github.com/dolthub/dolt/releases/latest/download";
|
|
28350
28428
|
function doltPlatformTuple(platform3, arch2) {
|
|
28351
|
-
const
|
|
28429
|
+
const os75 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
|
|
28352
28430
|
const a = arch2 === "x64" ? "amd64" : arch2 === "arm64" ? "arm64" : null;
|
|
28353
28431
|
if (!a) return null;
|
|
28354
|
-
if (
|
|
28355
|
-
return `${
|
|
28432
|
+
if (os75 === "windows" && a !== "amd64") return null;
|
|
28433
|
+
return `${os75}-${a}`;
|
|
28356
28434
|
}
|
|
28357
28435
|
function resolveDoltTarballStrategy(targetDir, platform3, arch2) {
|
|
28358
28436
|
const tuple = doltPlatformTuple(platform3, arch2);
|
|
@@ -28397,14 +28475,14 @@ async function installDoltToDir(targetDir, platform3 = process.platform, arch2 =
|
|
|
28397
28475
|
return result;
|
|
28398
28476
|
}
|
|
28399
28477
|
var _doltPathSeam = {
|
|
28400
|
-
homedir: () =>
|
|
28478
|
+
homedir: () => os42.homedir(),
|
|
28401
28479
|
getPath: () => process.env.PATH ?? "",
|
|
28402
28480
|
setPath: (p2) => {
|
|
28403
28481
|
process.env.PATH = p2;
|
|
28404
28482
|
},
|
|
28405
28483
|
exists: (p2) => {
|
|
28406
28484
|
try {
|
|
28407
|
-
|
|
28485
|
+
fs62.accessSync(p2, fs62.constants.F_OK);
|
|
28408
28486
|
return true;
|
|
28409
28487
|
} catch {
|
|
28410
28488
|
return false;
|
|
@@ -28415,7 +28493,7 @@ function doltBinaryNames(platform3) {
|
|
|
28415
28493
|
return platform3 === "win32" ? ["dolt.exe", "dolt.cmd", "dolt"] : ["dolt"];
|
|
28416
28494
|
}
|
|
28417
28495
|
function knownDoltDirs(platform3) {
|
|
28418
|
-
const P3 = platform3 === "win32" ?
|
|
28496
|
+
const P3 = platform3 === "win32" ? path69.win32 : path69.posix;
|
|
28419
28497
|
const home = _doltPathSeam.homedir();
|
|
28420
28498
|
if (platform3 === "win32") {
|
|
28421
28499
|
return [
|
|
@@ -28431,7 +28509,7 @@ function knownDoltDirs(platform3) {
|
|
|
28431
28509
|
].filter(Boolean);
|
|
28432
28510
|
}
|
|
28433
28511
|
function ensureDoltResolvable(platform3 = process.platform) {
|
|
28434
|
-
const P3 = platform3 === "win32" ?
|
|
28512
|
+
const P3 = platform3 === "win32" ? path69.win32 : path69.posix;
|
|
28435
28513
|
const delim = platform3 === "win32" ? ";" : ":";
|
|
28436
28514
|
const names = doltBinaryNames(platform3);
|
|
28437
28515
|
const pathDirs = _doltPathSeam.getPath().split(delim).filter(Boolean);
|
|
@@ -28608,10 +28686,10 @@ var _provisionSeam = {
|
|
|
28608
28686
|
/** Does the project's git remote carry Dolt data (`refs/dolt/data`)? */
|
|
28609
28687
|
remoteHasDoltData,
|
|
28610
28688
|
/** Throwaway cwd for a user-level-only `bd setup` (see GLOBAL_ONLY_RECIPES). */
|
|
28611
|
-
makeSetupCwd: () =>
|
|
28689
|
+
makeSetupCwd: () => fs63.mkdtempSync(path70.join(os43.tmpdir(), "codeam-bd-setup-")),
|
|
28612
28690
|
removeSetupCwd: (dir) => {
|
|
28613
28691
|
try {
|
|
28614
|
-
|
|
28692
|
+
fs63.rmSync(dir, { recursive: true, force: true });
|
|
28615
28693
|
} catch {
|
|
28616
28694
|
}
|
|
28617
28695
|
}
|
|
@@ -28633,17 +28711,17 @@ function remoteHasDoltData(cwd) {
|
|
|
28633
28711
|
}
|
|
28634
28712
|
var _linkSeam = {
|
|
28635
28713
|
platform: () => process.platform,
|
|
28636
|
-
homedir: () =>
|
|
28714
|
+
homedir: () => os43.homedir(),
|
|
28637
28715
|
isWritableDir: (dir) => {
|
|
28638
28716
|
try {
|
|
28639
|
-
|
|
28717
|
+
fs63.accessSync(dir, fs63.constants.W_OK);
|
|
28640
28718
|
return true;
|
|
28641
28719
|
} catch {
|
|
28642
28720
|
return false;
|
|
28643
28721
|
}
|
|
28644
28722
|
},
|
|
28645
28723
|
ensureDir: (dir) => {
|
|
28646
|
-
|
|
28724
|
+
fs63.mkdirSync(dir, { recursive: true });
|
|
28647
28725
|
},
|
|
28648
28726
|
/**
|
|
28649
28727
|
* A directory to symlink `bd` into so the AGENT's shell + Claude Code's
|
|
@@ -28664,9 +28742,9 @@ var _linkSeam = {
|
|
|
28664
28742
|
* which `linkBdOntoPath` creates if missing.
|
|
28665
28743
|
*/
|
|
28666
28744
|
cliBinDir: () => {
|
|
28667
|
-
const pathDirs = (process.env.PATH ?? "").split(
|
|
28745
|
+
const pathDirs = (process.env.PATH ?? "").split(path70.delimiter).filter(Boolean);
|
|
28668
28746
|
const home = _linkSeam.homedir();
|
|
28669
|
-
const localBin = home ?
|
|
28747
|
+
const localBin = home ? path70.join(home, ".local", "bin") : null;
|
|
28670
28748
|
if (localBin) {
|
|
28671
28749
|
try {
|
|
28672
28750
|
_linkSeam.ensureDir(localBin);
|
|
@@ -28676,16 +28754,16 @@ var _linkSeam = {
|
|
|
28676
28754
|
const candidates = [];
|
|
28677
28755
|
if (localBin) candidates.push(localBin);
|
|
28678
28756
|
try {
|
|
28679
|
-
candidates.push(
|
|
28757
|
+
candidates.push(path70.dirname(process.execPath));
|
|
28680
28758
|
} catch {
|
|
28681
28759
|
}
|
|
28682
28760
|
candidates.push("/usr/local/bin");
|
|
28683
28761
|
const entry = process.argv[1];
|
|
28684
28762
|
if (entry) {
|
|
28685
28763
|
try {
|
|
28686
|
-
candidates.push(
|
|
28764
|
+
candidates.push(path70.dirname(fs63.realpathSync(entry)));
|
|
28687
28765
|
} catch {
|
|
28688
|
-
candidates.push(
|
|
28766
|
+
candidates.push(path70.dirname(entry));
|
|
28689
28767
|
}
|
|
28690
28768
|
}
|
|
28691
28769
|
const onPathWritable = candidates.find(
|
|
@@ -28697,20 +28775,20 @@ var _linkSeam = {
|
|
|
28697
28775
|
/** Current symlink target at `linkPath`, or null when absent / not a link. */
|
|
28698
28776
|
readlink: (linkPath) => {
|
|
28699
28777
|
try {
|
|
28700
|
-
return
|
|
28778
|
+
return fs63.readlinkSync(linkPath);
|
|
28701
28779
|
} catch {
|
|
28702
28780
|
return null;
|
|
28703
28781
|
}
|
|
28704
28782
|
},
|
|
28705
|
-
unlink: (linkPath) =>
|
|
28706
|
-
symlink: (target, linkPath) =>
|
|
28783
|
+
unlink: (linkPath) => fs63.unlinkSync(linkPath),
|
|
28784
|
+
symlink: (target, linkPath) => fs63.symlinkSync(target, linkPath)
|
|
28707
28785
|
};
|
|
28708
28786
|
function linkBdOntoPath(binaryPath) {
|
|
28709
28787
|
if (_linkSeam.platform() === "win32") return;
|
|
28710
28788
|
const binDir = _linkSeam.cliBinDir();
|
|
28711
28789
|
if (!binDir) return;
|
|
28712
28790
|
_linkSeam.ensureDir(binDir);
|
|
28713
|
-
const linkPath =
|
|
28791
|
+
const linkPath = path70.join(binDir, "bd");
|
|
28714
28792
|
if (linkPath === binaryPath) return;
|
|
28715
28793
|
const current2 = _linkSeam.readlink(linkPath);
|
|
28716
28794
|
if (current2 === binaryPath) return;
|
|
@@ -28948,16 +29026,16 @@ function dedupeRecipes(agents) {
|
|
|
28948
29026
|
}
|
|
28949
29027
|
function ensureLocalGitExclude(cwd, patterns) {
|
|
28950
29028
|
try {
|
|
28951
|
-
const gitDir =
|
|
28952
|
-
if (!
|
|
28953
|
-
const file =
|
|
28954
|
-
|
|
28955
|
-
const current2 =
|
|
29029
|
+
const gitDir = path70.join(cwd, ".git");
|
|
29030
|
+
if (!fs63.statSync(gitDir).isDirectory()) return;
|
|
29031
|
+
const file = path70.join(gitDir, "info", "exclude");
|
|
29032
|
+
fs63.mkdirSync(path70.dirname(file), { recursive: true });
|
|
29033
|
+
const current2 = fs63.existsSync(file) ? fs63.readFileSync(file, "utf8") : "";
|
|
28956
29034
|
const have = new Set(current2.split(/\r?\n/).map((l) => l.trim()));
|
|
28957
29035
|
const missing = patterns.filter((p2) => !have.has(p2));
|
|
28958
29036
|
if (missing.length === 0) return;
|
|
28959
29037
|
const prefix = current2.length > 0 && !current2.endsWith("\n") ? "\n" : "";
|
|
28960
|
-
|
|
29038
|
+
fs63.appendFileSync(file, `${prefix}# CodeAgent: beads state stays local
|
|
28961
29039
|
${missing.join("\n")}
|
|
28962
29040
|
`);
|
|
28963
29041
|
} catch {
|
|
@@ -28966,7 +29044,7 @@ ${missing.join("\n")}
|
|
|
28966
29044
|
|
|
28967
29045
|
// src/beads/watcher.ts
|
|
28968
29046
|
var crypto4 = __toESM(require("crypto"));
|
|
28969
|
-
var
|
|
29047
|
+
var path71 = __toESM(require("path"));
|
|
28970
29048
|
var API_BASE5 = resolveApiBaseUrl();
|
|
28971
29049
|
var DEBOUNCE_MS2 = 400;
|
|
28972
29050
|
var ZERO_SUMMARY = {
|
|
@@ -28990,7 +29068,7 @@ var BeadsWatcher = class {
|
|
|
28990
29068
|
constructor(opts) {
|
|
28991
29069
|
this.opts = opts;
|
|
28992
29070
|
this.bd = opts.adapter ?? new BdAdapter({ cwd: opts.cwd, beadsDir: opts.beadsDir });
|
|
28993
|
-
this.feedPath = opts.feedPath ??
|
|
29071
|
+
this.feedPath = opts.feedPath ?? path71.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
|
|
28994
29072
|
this.apiBase = opts.apiBaseUrl ?? API_BASE5;
|
|
28995
29073
|
}
|
|
28996
29074
|
opts;
|
|
@@ -29645,8 +29723,8 @@ function cleanupAttachmentTempFiles() {
|
|
|
29645
29723
|
function saveFilesTemp(files) {
|
|
29646
29724
|
return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
|
|
29647
29725
|
const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
|
|
29648
|
-
const tmpPath =
|
|
29649
|
-
|
|
29726
|
+
const tmpPath = path76.join(os49.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
|
|
29727
|
+
fs69.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
|
|
29650
29728
|
pendingAttachmentFiles.add(tmpPath);
|
|
29651
29729
|
return tmpPath;
|
|
29652
29730
|
});
|
|
@@ -29892,10 +29970,10 @@ var listFiles = async (ctx, cmd, parsed) => {
|
|
|
29892
29970
|
await ctx.relay.sendResult(cmd.id, "completed", result);
|
|
29893
29971
|
};
|
|
29894
29972
|
var envReadH = async (ctx, cmd) => {
|
|
29895
|
-
const envPath =
|
|
29973
|
+
const envPath = path76.join(process.cwd(), ".env");
|
|
29896
29974
|
await restoreProjectEnvIfMissing(process.cwd(), ctx);
|
|
29897
29975
|
try {
|
|
29898
|
-
const raw = await
|
|
29976
|
+
const raw = await fs69.promises.readFile(envPath, "utf8");
|
|
29899
29977
|
await ctx.relay.sendResult(cmd.id, "completed", {
|
|
29900
29978
|
exists: true,
|
|
29901
29979
|
vars: parseDotenv(raw)
|
|
@@ -29924,7 +30002,7 @@ var envParseH = async (ctx, cmd, parsed) => {
|
|
|
29924
30002
|
const existing = /* @__PURE__ */ new Map();
|
|
29925
30003
|
if (!replace) {
|
|
29926
30004
|
try {
|
|
29927
|
-
const raw = await
|
|
30005
|
+
const raw = await fs69.promises.readFile(path76.join(process.cwd(), ".env"), "utf8");
|
|
29928
30006
|
for (const v of parseDotenv(raw)) existing.set(v.key, v.value);
|
|
29929
30007
|
} catch {
|
|
29930
30008
|
}
|
|
@@ -29964,15 +30042,15 @@ var envWriteH = async (ctx, cmd, parsed) => {
|
|
|
29964
30042
|
}
|
|
29965
30043
|
seen2.add(v.key);
|
|
29966
30044
|
}
|
|
29967
|
-
const envPath =
|
|
29968
|
-
const tmpPath =
|
|
30045
|
+
const envPath = path76.join(process.cwd(), ".env");
|
|
30046
|
+
const tmpPath = path76.join(process.cwd(), ".env.codeam.tmp");
|
|
29969
30047
|
try {
|
|
29970
|
-
await
|
|
29971
|
-
await
|
|
30048
|
+
await fs69.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
|
|
30049
|
+
await fs69.promises.rename(tmpPath, envPath);
|
|
29972
30050
|
await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
|
|
29973
30051
|
void syncProjectEnvUp(process.cwd(), ctx);
|
|
29974
30052
|
} catch (err) {
|
|
29975
|
-
await
|
|
30053
|
+
await fs69.promises.rm(tmpPath, { force: true }).catch(() => void 0);
|
|
29976
30054
|
await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
|
|
29977
30055
|
}
|
|
29978
30056
|
};
|
|
@@ -30198,7 +30276,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
30198
30276
|
});
|
|
30199
30277
|
const token = ctx.pluginAuthToken;
|
|
30200
30278
|
void (async () => {
|
|
30201
|
-
const
|
|
30279
|
+
const os75 = createOsStrategy();
|
|
30202
30280
|
try {
|
|
30203
30281
|
const report = await reviewPullRequest(
|
|
30204
30282
|
{
|
|
@@ -30207,7 +30285,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
30207
30285
|
baseBranch: parsed.baseBranch
|
|
30208
30286
|
},
|
|
30209
30287
|
{
|
|
30210
|
-
runReview: (input) => new CoderabbitRuntimeStrategy(
|
|
30288
|
+
runReview: (input) => new CoderabbitRuntimeStrategy(os75).runOneShot(input),
|
|
30211
30289
|
runGh: (args2) => defaultRunGh(args2),
|
|
30212
30290
|
postReport: async (r) => {
|
|
30213
30291
|
if (!token) return;
|
|
@@ -30321,9 +30399,9 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
|
|
|
30321
30399
|
function buildNpmInstallInvocation(opts) {
|
|
30322
30400
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
30323
30401
|
const execPath = opts?.execPath ?? process.execPath;
|
|
30324
|
-
const exists2 = opts?.existsSync ??
|
|
30402
|
+
const exists2 = opts?.existsSync ?? fs69.existsSync;
|
|
30325
30403
|
const platform3 = opts?.platform ?? process.platform;
|
|
30326
|
-
const p2 = platform3 === "win32" ?
|
|
30404
|
+
const p2 = platform3 === "win32" ? path76.win32 : path76.posix;
|
|
30327
30405
|
const normalized = entryScript.split(/[\\/]/).join("/");
|
|
30328
30406
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
30329
30407
|
const markerIdx = normalized.indexOf(marker);
|
|
@@ -30342,7 +30420,7 @@ function isPermissionError(stderr) {
|
|
|
30342
30420
|
function resolveGlobalNodeModulesDir(opts) {
|
|
30343
30421
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
30344
30422
|
const platform3 = opts?.platform ?? process.platform;
|
|
30345
|
-
const p2 = platform3 === "win32" ?
|
|
30423
|
+
const p2 = platform3 === "win32" ? path76.win32 : path76.posix;
|
|
30346
30424
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
30347
30425
|
const markerIdx = entryScript.split(/[\\/]/).join("/").indexOf(marker);
|
|
30348
30426
|
if (markerIdx <= 0) return null;
|
|
@@ -30352,21 +30430,21 @@ function resolveGlobalNodeModulesDir(opts) {
|
|
|
30352
30430
|
var STALE_STAGING_AGE_MS = CLI_UPDATE_INSTALL_TIMEOUT_MS;
|
|
30353
30431
|
function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
30354
30432
|
if (!nodeModulesDir) return 0;
|
|
30355
|
-
const
|
|
30356
|
-
const
|
|
30357
|
-
const rmSync15 = deps?.rmSync ??
|
|
30433
|
+
const readdirSync19 = deps?.readdirSync ?? fs69.readdirSync;
|
|
30434
|
+
const statSync18 = deps?.statSync ?? fs69.statSync;
|
|
30435
|
+
const rmSync15 = deps?.rmSync ?? fs69.rmSync;
|
|
30358
30436
|
let removed = 0;
|
|
30359
30437
|
let entries2;
|
|
30360
30438
|
try {
|
|
30361
|
-
entries2 =
|
|
30439
|
+
entries2 = readdirSync19(nodeModulesDir);
|
|
30362
30440
|
} catch {
|
|
30363
30441
|
return 0;
|
|
30364
30442
|
}
|
|
30365
30443
|
for (const name of entries2) {
|
|
30366
30444
|
if (!/^\.codeam-cli-/.test(name)) continue;
|
|
30367
|
-
const full =
|
|
30445
|
+
const full = path76.join(nodeModulesDir, name);
|
|
30368
30446
|
try {
|
|
30369
|
-
const st3 =
|
|
30447
|
+
const st3 = statSync18(full);
|
|
30370
30448
|
if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
|
|
30371
30449
|
rmSync15(full, { recursive: true, force: true });
|
|
30372
30450
|
removed++;
|
|
@@ -31513,11 +31591,11 @@ function resolveTokenValue(args2) {
|
|
|
31513
31591
|
}
|
|
31514
31592
|
const fileFlag = args2.find((a) => a.startsWith("--token-file="));
|
|
31515
31593
|
if (fileFlag) {
|
|
31516
|
-
const
|
|
31594
|
+
const path117 = fileFlag.slice("--token-file=".length);
|
|
31517
31595
|
try {
|
|
31518
|
-
const content =
|
|
31519
|
-
if (content.length === 0) fail(`--token-file ${
|
|
31520
|
-
rmIfExistsQuiet(
|
|
31596
|
+
const content = fs70.readFileSync(path117, "utf8").trim();
|
|
31597
|
+
if (content.length === 0) fail(`--token-file ${path117} is empty`);
|
|
31598
|
+
rmIfExistsQuiet(path117);
|
|
31521
31599
|
return content;
|
|
31522
31600
|
} catch (err) {
|
|
31523
31601
|
fail(`Could not read --token-file: ${err.message}`);
|
|
@@ -31609,12 +31687,12 @@ async function claim(token, pluginId, pluginSecretHash) {
|
|
|
31609
31687
|
}
|
|
31610
31688
|
}
|
|
31611
31689
|
function pairAutoLockPath() {
|
|
31612
|
-
return
|
|
31690
|
+
return path77.join(os50.homedir(), ".codeam", "pair-auto.lock");
|
|
31613
31691
|
}
|
|
31614
31692
|
var procRoot = "/proc";
|
|
31615
31693
|
function readProcFile(rel) {
|
|
31616
31694
|
try {
|
|
31617
|
-
return
|
|
31695
|
+
return fs70.readFileSync(path77.join(procRoot, rel), "utf8");
|
|
31618
31696
|
} catch {
|
|
31619
31697
|
return void 0;
|
|
31620
31698
|
}
|
|
@@ -31635,7 +31713,7 @@ function currentBootId() {
|
|
|
31635
31713
|
function readLockRecord(lockPath) {
|
|
31636
31714
|
let raw;
|
|
31637
31715
|
try {
|
|
31638
|
-
raw =
|
|
31716
|
+
raw = fs70.readFileSync(lockPath, "utf8");
|
|
31639
31717
|
} catch {
|
|
31640
31718
|
return void 0;
|
|
31641
31719
|
}
|
|
@@ -31684,7 +31762,7 @@ function isLiveLockHolder(rec) {
|
|
|
31684
31762
|
}
|
|
31685
31763
|
function releaseOwnLock(lockPath) {
|
|
31686
31764
|
try {
|
|
31687
|
-
if (readLockRecord(lockPath)?.pid === process.pid)
|
|
31765
|
+
if (readLockRecord(lockPath)?.pid === process.pid) fs70.unlinkSync(lockPath);
|
|
31688
31766
|
} catch {
|
|
31689
31767
|
}
|
|
31690
31768
|
}
|
|
@@ -31708,7 +31786,7 @@ function snapshotProcessTree(root) {
|
|
|
31708
31786
|
const children = /* @__PURE__ */ new Map();
|
|
31709
31787
|
let entries2 = [];
|
|
31710
31788
|
try {
|
|
31711
|
-
entries2 =
|
|
31789
|
+
entries2 = fs70.readdirSync(procRoot).filter((e) => /^\d+$/.test(e));
|
|
31712
31790
|
} catch {
|
|
31713
31791
|
}
|
|
31714
31792
|
for (const e of entries2) {
|
|
@@ -31743,18 +31821,18 @@ function signalProcessTree(refs, signal) {
|
|
|
31743
31821
|
}
|
|
31744
31822
|
function daemonLockPath(sessionId) {
|
|
31745
31823
|
const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
31746
|
-
return
|
|
31824
|
+
return path77.join(os50.homedir(), ".codeam", `daemon-${safe}.lock`);
|
|
31747
31825
|
}
|
|
31748
31826
|
function acquireDaemonLock(sessionId) {
|
|
31749
31827
|
const lockPath = daemonLockPath(sessionId);
|
|
31750
31828
|
try {
|
|
31751
|
-
|
|
31829
|
+
fs70.mkdirSync(path77.dirname(lockPath), { recursive: true });
|
|
31752
31830
|
try {
|
|
31753
|
-
|
|
31831
|
+
fs70.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
31754
31832
|
} catch (e) {
|
|
31755
31833
|
if (e.code !== "EEXIST") throw e;
|
|
31756
31834
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
31757
|
-
|
|
31835
|
+
fs70.writeFileSync(lockPath, ownLockBody());
|
|
31758
31836
|
}
|
|
31759
31837
|
const release3 = () => releaseOwnLock(lockPath);
|
|
31760
31838
|
process.once("exit", release3);
|
|
@@ -31774,13 +31852,13 @@ function acquireDaemonLock(sessionId) {
|
|
|
31774
31852
|
function acquireSingletonLock() {
|
|
31775
31853
|
const lockPath = pairAutoLockPath();
|
|
31776
31854
|
try {
|
|
31777
|
-
|
|
31855
|
+
fs70.mkdirSync(path77.dirname(lockPath), { recursive: true });
|
|
31778
31856
|
try {
|
|
31779
|
-
|
|
31857
|
+
fs70.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
31780
31858
|
} catch (e) {
|
|
31781
31859
|
if (e.code !== "EEXIST") throw e;
|
|
31782
31860
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
31783
|
-
|
|
31861
|
+
fs70.writeFileSync(lockPath, ownLockBody());
|
|
31784
31862
|
}
|
|
31785
31863
|
process.once("exit", () => releaseOwnLock(lockPath));
|
|
31786
31864
|
return true;
|
|
@@ -32206,7 +32284,7 @@ var AgentService = class _AgentService {
|
|
|
32206
32284
|
};
|
|
32207
32285
|
|
|
32208
32286
|
// src/agents/acp/adapters.ts
|
|
32209
|
-
var
|
|
32287
|
+
var path78 = __toESM(require("path"));
|
|
32210
32288
|
|
|
32211
32289
|
// src/agents/kimi/installer.ts
|
|
32212
32290
|
var import_node_child_process26 = require("child_process");
|
|
@@ -32327,13 +32405,13 @@ function resolveBin(pkgName, binName) {
|
|
|
32327
32405
|
try {
|
|
32328
32406
|
const manifestPath = require_.resolve(`${pkgName}/package.json`);
|
|
32329
32407
|
const manifest = require_(`${pkgName}/package.json`);
|
|
32330
|
-
const pkgDir =
|
|
32408
|
+
const pkgDir = path78.dirname(manifestPath);
|
|
32331
32409
|
const bin = manifest.bin;
|
|
32332
32410
|
if (!bin) return null;
|
|
32333
|
-
if (typeof bin === "string") return
|
|
32411
|
+
if (typeof bin === "string") return path78.resolve(pkgDir, bin);
|
|
32334
32412
|
const target = binName ?? Object.keys(bin)[0];
|
|
32335
32413
|
if (!target || !bin[target]) return null;
|
|
32336
|
-
return
|
|
32414
|
+
return path78.resolve(pkgDir, bin[target]);
|
|
32337
32415
|
} catch {
|
|
32338
32416
|
return null;
|
|
32339
32417
|
}
|
|
@@ -32348,7 +32426,7 @@ function npmAdapterPackageDir(agent) {
|
|
|
32348
32426
|
const pkg = NPM_ADAPTER_PACKAGES[agent];
|
|
32349
32427
|
if (!pkg) return null;
|
|
32350
32428
|
try {
|
|
32351
|
-
return
|
|
32429
|
+
return path78.dirname(require_.resolve(`${pkg}/package.json`));
|
|
32352
32430
|
} catch {
|
|
32353
32431
|
return null;
|
|
32354
32432
|
}
|
|
@@ -32532,8 +32610,8 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
|
|
|
32532
32610
|
}
|
|
32533
32611
|
|
|
32534
32612
|
// src/agents/acp/prefetch-module-graph.ts
|
|
32535
|
-
var
|
|
32536
|
-
var
|
|
32613
|
+
var fs71 = __toESM(require("fs"));
|
|
32614
|
+
var path79 = __toESM(require("path"));
|
|
32537
32615
|
var LOADABLE_EXT = /* @__PURE__ */ new Set([".js", ".mjs", ".cjs", ".json", ".node"]);
|
|
32538
32616
|
var DEFAULT_MODULE_GRAPH_LIMITS = {
|
|
32539
32617
|
maxFiles: 2e3,
|
|
@@ -32542,23 +32620,23 @@ var DEFAULT_MODULE_GRAPH_LIMITS = {
|
|
|
32542
32620
|
concurrency: 16
|
|
32543
32621
|
};
|
|
32544
32622
|
var realFs = {
|
|
32545
|
-
readdir: (dir) =>
|
|
32546
|
-
readFile: (file) =>
|
|
32547
|
-
stat: (file) =>
|
|
32623
|
+
readdir: (dir) => fs71.promises.readdir(dir, { withFileTypes: true }),
|
|
32624
|
+
readFile: (file) => fs71.promises.readFile(file),
|
|
32625
|
+
stat: (file) => fs71.promises.stat(file)
|
|
32548
32626
|
};
|
|
32549
32627
|
function findPackageDir(dep, fromDir) {
|
|
32550
32628
|
let dir = fromDir;
|
|
32551
32629
|
for (; ; ) {
|
|
32552
|
-
const candidate =
|
|
32553
|
-
if (
|
|
32554
|
-
const parent =
|
|
32630
|
+
const candidate = path79.join(dir, "node_modules", dep);
|
|
32631
|
+
if (fs71.existsSync(path79.join(candidate, "package.json"))) return candidate;
|
|
32632
|
+
const parent = path79.dirname(dir);
|
|
32555
32633
|
if (parent === dir) return null;
|
|
32556
32634
|
dir = parent;
|
|
32557
32635
|
}
|
|
32558
32636
|
}
|
|
32559
32637
|
function runtimeDependencies(pkgDir) {
|
|
32560
32638
|
try {
|
|
32561
|
-
const manifest = JSON.parse(
|
|
32639
|
+
const manifest = JSON.parse(fs71.readFileSync(path79.join(pkgDir, "package.json"), "utf8"));
|
|
32562
32640
|
return Object.keys(manifest.dependencies ?? {});
|
|
32563
32641
|
} catch {
|
|
32564
32642
|
return [];
|
|
@@ -32577,14 +32655,14 @@ async function packageFiles(pkgDir, fsd, out2, maxFiles) {
|
|
|
32577
32655
|
for (const entry of entries2) {
|
|
32578
32656
|
if (out2.length >= maxFiles) return;
|
|
32579
32657
|
if (entry.name.startsWith(".")) continue;
|
|
32580
|
-
const full =
|
|
32658
|
+
const full = path79.join(dir, entry.name);
|
|
32581
32659
|
if (entry.isDirectory()) {
|
|
32582
32660
|
if (entry.name !== "node_modules") stack.push(full);
|
|
32583
32661
|
continue;
|
|
32584
32662
|
}
|
|
32585
32663
|
if (!entry.isFile()) continue;
|
|
32586
32664
|
if (entry.name.endsWith(".d.ts") || entry.name.endsWith(".map")) continue;
|
|
32587
|
-
if (LOADABLE_EXT.has(
|
|
32665
|
+
if (LOADABLE_EXT.has(path79.extname(entry.name))) out2.push(full);
|
|
32588
32666
|
}
|
|
32589
32667
|
}
|
|
32590
32668
|
}
|
|
@@ -32594,7 +32672,7 @@ async function collectModuleGraphFiles(rootPkgDir, limits = DEFAULT_MODULE_GRAPH
|
|
|
32594
32672
|
const queue = [rootPkgDir];
|
|
32595
32673
|
while (queue.length > 0 && files.length < limits.maxFiles) {
|
|
32596
32674
|
const pkgDir = queue.shift();
|
|
32597
|
-
const key =
|
|
32675
|
+
const key = fs71.existsSync(pkgDir) ? fs71.realpathSync(pkgDir) : pkgDir;
|
|
32598
32676
|
if (seen2.has(key)) continue;
|
|
32599
32677
|
seen2.add(key);
|
|
32600
32678
|
await packageFiles(pkgDir, fsd, files, limits.maxFiles);
|
|
@@ -32706,9 +32784,9 @@ async function waitForNoAgentStarting(opts) {
|
|
|
32706
32784
|
|
|
32707
32785
|
// src/agents/acp/runner.ts
|
|
32708
32786
|
var import_node_crypto15 = require("crypto");
|
|
32709
|
-
var
|
|
32710
|
-
var
|
|
32711
|
-
var
|
|
32787
|
+
var fs90 = __toESM(require("fs"));
|
|
32788
|
+
var os62 = __toESM(require("os"));
|
|
32789
|
+
var path99 = __toESM(require("path"));
|
|
32712
32790
|
|
|
32713
32791
|
// src/agents/acp/provider-billing-signal.ts
|
|
32714
32792
|
var seen = /* @__PURE__ */ new Set();
|
|
@@ -32740,8 +32818,8 @@ function noteProviderBillingSignal(opts) {
|
|
|
32740
32818
|
}
|
|
32741
32819
|
|
|
32742
32820
|
// src/services/history.service.ts
|
|
32743
|
-
var
|
|
32744
|
-
var
|
|
32821
|
+
var fs73 = __toESM(require("fs"));
|
|
32822
|
+
var path81 = __toESM(require("path"));
|
|
32745
32823
|
var https6 = __toESM(require("https"));
|
|
32746
32824
|
var http10 = __toESM(require("http"));
|
|
32747
32825
|
var import_zod3 = require("zod");
|
|
@@ -32802,7 +32880,7 @@ function parseJsonl(filePath) {
|
|
|
32802
32880
|
const messages = [];
|
|
32803
32881
|
let raw;
|
|
32804
32882
|
try {
|
|
32805
|
-
raw =
|
|
32883
|
+
raw = fs73.readFileSync(filePath, "utf8");
|
|
32806
32884
|
} catch (err) {
|
|
32807
32885
|
if (err.code !== "ENOENT") {
|
|
32808
32886
|
log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
|
|
@@ -32962,7 +33040,7 @@ var HistoryService = class _HistoryService {
|
|
|
32962
33040
|
// session-start upload answered false, the active-conversation pointer was
|
|
32963
33041
|
// never re-pointed after a Box wake, and the app opened an empty "New
|
|
32964
33042
|
// conversation" over the resumed one (QA box, 2026-09-29).
|
|
32965
|
-
|
|
33043
|
+
path81.join(claudeConfigDir(), "projects", encodeCwd(this.cwd));
|
|
32966
33044
|
}
|
|
32967
33045
|
/** Set the current Claude conversation ID (extracted from /cost command or session start) */
|
|
32968
33046
|
setCurrentConversationId(id) {
|
|
@@ -32974,7 +33052,7 @@ var HistoryService = class _HistoryService {
|
|
|
32974
33052
|
/** Return the current message count in the active conversation. */
|
|
32975
33053
|
getCurrentMessageCount() {
|
|
32976
33054
|
if (!this.currentConversationId) return 0;
|
|
32977
|
-
const filePath =
|
|
33055
|
+
const filePath = path81.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
32978
33056
|
return parseJsonl(filePath).length;
|
|
32979
33057
|
}
|
|
32980
33058
|
/**
|
|
@@ -32985,7 +33063,7 @@ var HistoryService = class _HistoryService {
|
|
|
32985
33063
|
const deadline = Date.now() + timeoutMs;
|
|
32986
33064
|
while (Date.now() < deadline) {
|
|
32987
33065
|
if (!this.currentConversationId) return null;
|
|
32988
|
-
const filePath =
|
|
33066
|
+
const filePath = path81.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
32989
33067
|
const messages = parseJsonl(filePath);
|
|
32990
33068
|
if (messages.length > previousCount) {
|
|
32991
33069
|
for (let i = messages.length - 1; i >= previousCount; i--) {
|
|
@@ -33012,18 +33090,18 @@ var HistoryService = class _HistoryService {
|
|
|
33012
33090
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
33013
33091
|
const oneShots = readOneShotConversations(this.cwd);
|
|
33014
33092
|
try {
|
|
33015
|
-
const files =
|
|
33016
|
-
(e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(
|
|
33093
|
+
const files = fs73.readdirSync(dir, { withFileTypes: true }).filter(
|
|
33094
|
+
(e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(path81.basename(e.name, ".jsonl"))
|
|
33017
33095
|
).map((e) => {
|
|
33018
33096
|
try {
|
|
33019
|
-
const stat3 =
|
|
33097
|
+
const stat3 = fs73.statSync(path81.join(dir, e.name));
|
|
33020
33098
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
33021
33099
|
} catch {
|
|
33022
33100
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
33023
33101
|
}
|
|
33024
33102
|
}).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
33025
33103
|
if (files.length > 0) {
|
|
33026
|
-
this.currentConversationId =
|
|
33104
|
+
this.currentConversationId = path81.basename(files[0].name, ".jsonl");
|
|
33027
33105
|
}
|
|
33028
33106
|
} catch {
|
|
33029
33107
|
}
|
|
@@ -33057,13 +33135,13 @@ var HistoryService = class _HistoryService {
|
|
|
33057
33135
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
33058
33136
|
let entries2;
|
|
33059
33137
|
try {
|
|
33060
|
-
entries2 =
|
|
33138
|
+
entries2 = fs73.readdirSync(dir, { withFileTypes: true });
|
|
33061
33139
|
} catch {
|
|
33062
33140
|
return null;
|
|
33063
33141
|
}
|
|
33064
33142
|
const files = entries2.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
33065
33143
|
try {
|
|
33066
|
-
const stat3 =
|
|
33144
|
+
const stat3 = fs73.statSync(path81.join(dir, e.name));
|
|
33067
33145
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
33068
33146
|
} catch {
|
|
33069
33147
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
@@ -33072,12 +33150,12 @@ var HistoryService = class _HistoryService {
|
|
|
33072
33150
|
if (files.length === 0) return null;
|
|
33073
33151
|
const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
|
|
33074
33152
|
if (!files.some((f) => f.name === targetFile)) return null;
|
|
33075
|
-
return this.extractUsageFromFile(
|
|
33153
|
+
return this.extractUsageFromFile(path81.join(dir, targetFile));
|
|
33076
33154
|
}
|
|
33077
33155
|
extractUsageFromFile(filePath) {
|
|
33078
33156
|
let raw;
|
|
33079
33157
|
try {
|
|
33080
|
-
raw =
|
|
33158
|
+
raw = fs73.readFileSync(filePath, "utf8");
|
|
33081
33159
|
} catch {
|
|
33082
33160
|
return null;
|
|
33083
33161
|
}
|
|
@@ -33129,9 +33207,9 @@ var HistoryService = class _HistoryService {
|
|
|
33129
33207
|
let totalCost = 0;
|
|
33130
33208
|
let files;
|
|
33131
33209
|
try {
|
|
33132
|
-
files =
|
|
33210
|
+
files = fs73.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
|
|
33133
33211
|
try {
|
|
33134
|
-
return
|
|
33212
|
+
return fs73.statSync(path81.join(projectDir, f)).mtimeMs >= monthStartMs;
|
|
33135
33213
|
} catch {
|
|
33136
33214
|
return false;
|
|
33137
33215
|
}
|
|
@@ -33142,7 +33220,7 @@ var HistoryService = class _HistoryService {
|
|
|
33142
33220
|
for (const file of files) {
|
|
33143
33221
|
let raw;
|
|
33144
33222
|
try {
|
|
33145
|
-
raw =
|
|
33223
|
+
raw = fs73.readFileSync(path81.join(projectDir, file), "utf8");
|
|
33146
33224
|
} catch {
|
|
33147
33225
|
continue;
|
|
33148
33226
|
}
|
|
@@ -33221,7 +33299,7 @@ var HistoryService = class _HistoryService {
|
|
|
33221
33299
|
if (this.runtime.resolveHistoryFile) {
|
|
33222
33300
|
return this.runtime.resolveHistoryFile(this.cwd, sessionId);
|
|
33223
33301
|
}
|
|
33224
|
-
return
|
|
33302
|
+
return path81.join(this.projectDir, `${sessionId}.jsonl`);
|
|
33225
33303
|
}
|
|
33226
33304
|
/**
|
|
33227
33305
|
* Parse a conversation's messages from disk, agent-aware. Claude uses the
|
|
@@ -33259,7 +33337,7 @@ var HistoryService = class _HistoryService {
|
|
|
33259
33337
|
};
|
|
33260
33338
|
});
|
|
33261
33339
|
}
|
|
33262
|
-
return parseJsonl(
|
|
33340
|
+
return parseJsonl(path81.join(this.projectDir, `${sessionId}.jsonl`));
|
|
33263
33341
|
}
|
|
33264
33342
|
/** One in-flight full upload per conversation — the baton mirror and a
|
|
33265
33343
|
* `get_conversation` used to upload the same transcript concurrently. */
|
|
@@ -33341,7 +33419,7 @@ var HistoryService = class _HistoryService {
|
|
|
33341
33419
|
if (!filePath) return false;
|
|
33342
33420
|
let mtimeMs;
|
|
33343
33421
|
try {
|
|
33344
|
-
mtimeMs =
|
|
33422
|
+
mtimeMs = fs73.statSync(filePath).mtimeMs;
|
|
33345
33423
|
} catch {
|
|
33346
33424
|
return false;
|
|
33347
33425
|
}
|
|
@@ -33416,10 +33494,10 @@ var HistoryService = class _HistoryService {
|
|
|
33416
33494
|
|
|
33417
33495
|
// src/agents/acp/client.ts
|
|
33418
33496
|
var import_node_child_process28 = require("child_process");
|
|
33419
|
-
var
|
|
33497
|
+
var fs74 = __toESM(require("fs/promises"));
|
|
33420
33498
|
var fsSync = __toESM(require("fs"));
|
|
33421
|
-
var
|
|
33422
|
-
var
|
|
33499
|
+
var os53 = __toESM(require("os"));
|
|
33500
|
+
var path83 = __toESM(require("path"));
|
|
33423
33501
|
var import_node_stream = require("stream");
|
|
33424
33502
|
|
|
33425
33503
|
// ../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
@@ -37445,8 +37523,8 @@ function createIdleTimeout(idleMs, makeError, activeIdleMs = idleMs) {
|
|
|
37445
37523
|
}
|
|
37446
37524
|
|
|
37447
37525
|
// src/agents/acp/internal-paths.ts
|
|
37448
|
-
var
|
|
37449
|
-
var
|
|
37526
|
+
var path82 = __toESM(require("path"));
|
|
37527
|
+
var os52 = __toESM(require("os"));
|
|
37450
37528
|
var INTERNAL_TOKENS = [".codeam", "house-claude"];
|
|
37451
37529
|
var PROSE_ONLY_TOOL_KINDS = /* @__PURE__ */ new Set(["think", "switch_mode"]);
|
|
37452
37530
|
function isProseOnlyToolKind(kind) {
|
|
@@ -37458,13 +37536,13 @@ function textReferencesInternal(text) {
|
|
|
37458
37536
|
const scrubbed = text.replace(SELF_HOSTED_WORKSPACE_RE, " ");
|
|
37459
37537
|
return INTERNAL_TOKENS.some((t2) => scrubbed.includes(t2));
|
|
37460
37538
|
}
|
|
37461
|
-
function pathIsInternal(p2, homeDir2 =
|
|
37539
|
+
function pathIsInternal(p2, homeDir2 = os52.homedir()) {
|
|
37462
37540
|
if (!p2) return false;
|
|
37463
|
-
const abs =
|
|
37464
|
-
const home =
|
|
37465
|
-
const within = (root) => abs === root || abs.startsWith(root +
|
|
37466
|
-
if (within(
|
|
37467
|
-
return within(
|
|
37541
|
+
const abs = path82.resolve(p2);
|
|
37542
|
+
const home = path82.resolve(homeDir2);
|
|
37543
|
+
const within = (root) => abs === root || abs.startsWith(root + path82.sep);
|
|
37544
|
+
if (within(path82.join(home, ".codeam", "self-hosted"))) return false;
|
|
37545
|
+
return within(path82.join(home, ".codeam")) || within(path82.join(home, ".beads")) || abs === path82.join(home, ".codeam-host.log") || abs.includes(`${path82.sep}house-claude${path82.sep}`) || abs.endsWith(`${path82.sep}house-claude`);
|
|
37468
37546
|
}
|
|
37469
37547
|
function toolCallReferencesInternal(call, homeDir2) {
|
|
37470
37548
|
if (call.locations?.some((l) => pathIsInternal(l.path, homeDir2))) return true;
|
|
@@ -38658,7 +38736,7 @@ var AcpClient = class {
|
|
|
38658
38736
|
throw new RequestError(-32002, GUARDRAIL_SECRET_READ_BLOCK_REASON, { uri: params.path });
|
|
38659
38737
|
}
|
|
38660
38738
|
try {
|
|
38661
|
-
const content = await
|
|
38739
|
+
const content = await fs74.readFile(params.path, "utf8");
|
|
38662
38740
|
return applyLineRange(content, params.line ?? null, params.limit ?? null);
|
|
38663
38741
|
} catch (err) {
|
|
38664
38742
|
const code = err.code;
|
|
@@ -38679,7 +38757,7 @@ var AcpClient = class {
|
|
|
38679
38757
|
throw new RequestError(-32002, INTERNAL_BLOCK_REASON, { uri: params.path });
|
|
38680
38758
|
}
|
|
38681
38759
|
try {
|
|
38682
|
-
await
|
|
38760
|
+
await fs74.writeFile(params.path, params.content, "utf8");
|
|
38683
38761
|
return {};
|
|
38684
38762
|
} catch (err) {
|
|
38685
38763
|
const code = err.code;
|
|
@@ -38767,30 +38845,30 @@ function applyLineRange(content, line, limit) {
|
|
|
38767
38845
|
return { content: lines.slice(start2, end).join("\n") };
|
|
38768
38846
|
}
|
|
38769
38847
|
function knownAgentBinaryDirs() {
|
|
38770
|
-
const home =
|
|
38848
|
+
const home = os53.homedir();
|
|
38771
38849
|
const out2 = [];
|
|
38772
38850
|
out2.push("/tmp/codeam-node20/bin");
|
|
38773
38851
|
for (const root of [
|
|
38774
38852
|
"/usr/local/share/nvm/versions/node",
|
|
38775
|
-
|
|
38853
|
+
path83.join(home, ".nvm/versions/node")
|
|
38776
38854
|
]) {
|
|
38777
38855
|
try {
|
|
38778
38856
|
for (const child of fsSync.readdirSync(root)) {
|
|
38779
|
-
out2.push(
|
|
38857
|
+
out2.push(path83.join(root, child, "bin"));
|
|
38780
38858
|
}
|
|
38781
38859
|
} catch {
|
|
38782
38860
|
}
|
|
38783
38861
|
}
|
|
38784
|
-
out2.push(
|
|
38862
|
+
out2.push(path83.join(home, ".volta/bin"));
|
|
38785
38863
|
out2.push("/usr/local/bin");
|
|
38786
38864
|
out2.push("/usr/bin");
|
|
38787
|
-
out2.push(
|
|
38788
|
-
out2.push(
|
|
38865
|
+
out2.push(path83.join(home, ".local/bin"));
|
|
38866
|
+
out2.push(path83.join(home, "bin"));
|
|
38789
38867
|
out2.push(...agentInstallBinDirs());
|
|
38790
38868
|
if (process.platform === "win32") {
|
|
38791
38869
|
const { LOCALAPPDATA, APPDATA } = process.env;
|
|
38792
|
-
if (LOCALAPPDATA) out2.push(
|
|
38793
|
-
if (APPDATA) out2.push(
|
|
38870
|
+
if (LOCALAPPDATA) out2.push(path83.join(LOCALAPPDATA, "cursor-agent"));
|
|
38871
|
+
if (APPDATA) out2.push(path83.join(APPDATA, "npm"));
|
|
38794
38872
|
}
|
|
38795
38873
|
return out2.filter((p2) => {
|
|
38796
38874
|
try {
|
|
@@ -38801,7 +38879,7 @@ function knownAgentBinaryDirs() {
|
|
|
38801
38879
|
});
|
|
38802
38880
|
}
|
|
38803
38881
|
function expandPathForAgentBinaries(existingPath) {
|
|
38804
|
-
const existing = new Set(existingPath.split(
|
|
38882
|
+
const existing = new Set(existingPath.split(path83.delimiter).filter((p2) => p2.length > 0));
|
|
38805
38883
|
const additions = [];
|
|
38806
38884
|
for (const dir of knownAgentBinaryDirs()) {
|
|
38807
38885
|
if (!existing.has(dir)) {
|
|
@@ -38810,17 +38888,17 @@ function expandPathForAgentBinaries(existingPath) {
|
|
|
38810
38888
|
}
|
|
38811
38889
|
}
|
|
38812
38890
|
if (additions.length === 0) return existingPath;
|
|
38813
|
-
return [...additions, existingPath].filter((p2) => p2.length > 0).join(
|
|
38891
|
+
return [...additions, existingPath].filter((p2) => p2.length > 0).join(path83.delimiter);
|
|
38814
38892
|
}
|
|
38815
38893
|
|
|
38816
38894
|
// src/commands/host/agent-install.ts
|
|
38817
38895
|
var import_child_process27 = require("child_process");
|
|
38818
|
-
var
|
|
38896
|
+
var os54 = __toESM(require("os"));
|
|
38819
38897
|
function runAgentInstallScript(script, opts = {}) {
|
|
38820
38898
|
const timeoutMs = opts.timeoutMs ?? 18e4;
|
|
38821
38899
|
const scope = opts.logScope ?? "agent-install";
|
|
38822
38900
|
return new Promise((resolve13) => {
|
|
38823
|
-
const home = process.env.HOME ||
|
|
38901
|
+
const home = process.env.HOME || os54.homedir();
|
|
38824
38902
|
const child = (0, import_child_process27.spawn)("sh", ["-c", script], {
|
|
38825
38903
|
env: { ...process.env, HOME: home },
|
|
38826
38904
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -39082,9 +39160,9 @@ async function performAgentSwitch(deps, rawAgentId, fastPath = {}) {
|
|
|
39082
39160
|
}
|
|
39083
39161
|
|
|
39084
39162
|
// src/commands/host/agent-provisioning.ts
|
|
39085
|
-
var
|
|
39086
|
-
var
|
|
39087
|
-
var
|
|
39163
|
+
var fs75 = __toESM(require("fs"));
|
|
39164
|
+
var os55 = __toESM(require("os"));
|
|
39165
|
+
var path84 = __toESM(require("path"));
|
|
39088
39166
|
var PUBLIC_TO_INTERNAL_AGENT = {
|
|
39089
39167
|
claude_code: "claude",
|
|
39090
39168
|
claude: "claude",
|
|
@@ -39101,22 +39179,22 @@ function toInternalAgentId(publicAgentId) {
|
|
|
39101
39179
|
return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
|
|
39102
39180
|
}
|
|
39103
39181
|
function ensureDir(dir) {
|
|
39104
|
-
|
|
39182
|
+
fs75.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
39105
39183
|
}
|
|
39106
39184
|
function writeFile0600(filePath, contents) {
|
|
39107
|
-
ensureDir(
|
|
39108
|
-
|
|
39185
|
+
ensureDir(path84.dirname(filePath));
|
|
39186
|
+
fs75.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
|
|
39109
39187
|
restrictToOwner(filePath);
|
|
39110
39188
|
}
|
|
39111
39189
|
function rmIfExists(filePath) {
|
|
39112
39190
|
try {
|
|
39113
|
-
|
|
39191
|
+
fs75.rmSync(filePath, { force: true });
|
|
39114
39192
|
} catch {
|
|
39115
39193
|
}
|
|
39116
39194
|
}
|
|
39117
39195
|
var claudeProvisioner = {
|
|
39118
39196
|
write(auth, home) {
|
|
39119
|
-
const credentialsJson =
|
|
39197
|
+
const credentialsJson = path84.join(home, ".claude", ".credentials.json");
|
|
39120
39198
|
if (auth.kind === "api_key") {
|
|
39121
39199
|
rmIfExists(credentialsJson);
|
|
39122
39200
|
return { ANTHROPIC_API_KEY: auth.value };
|
|
@@ -39128,8 +39206,8 @@ var claudeProvisioner = {
|
|
|
39128
39206
|
} else {
|
|
39129
39207
|
rmIfExists(credentialsJson);
|
|
39130
39208
|
}
|
|
39131
|
-
const claudeJson =
|
|
39132
|
-
if (!
|
|
39209
|
+
const claudeJson = path84.join(home, ".claude.json");
|
|
39210
|
+
if (!fs75.existsSync(claudeJson)) {
|
|
39133
39211
|
writeFile0600(
|
|
39134
39212
|
claudeJson,
|
|
39135
39213
|
JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
|
|
@@ -39140,7 +39218,7 @@ var claudeProvisioner = {
|
|
|
39140
39218
|
};
|
|
39141
39219
|
var codexProvisioner = {
|
|
39142
39220
|
write(auth, home) {
|
|
39143
|
-
const authJson =
|
|
39221
|
+
const authJson = path84.join(home, ".codex", "auth.json");
|
|
39144
39222
|
if (auth.kind === "api_key") {
|
|
39145
39223
|
writeFile0600(authJson, JSON.stringify({ auth_mode: "apikey", OPENAI_API_KEY: auth.value }));
|
|
39146
39224
|
return { OPENAI_API_KEY: auth.value };
|
|
@@ -39163,7 +39241,7 @@ function codexLoginStamp(raw) {
|
|
|
39163
39241
|
function keepsFresherCodexLogin(authJsonPath, incoming) {
|
|
39164
39242
|
let onDisk;
|
|
39165
39243
|
try {
|
|
39166
|
-
onDisk =
|
|
39244
|
+
onDisk = fs75.readFileSync(authJsonPath, "utf8");
|
|
39167
39245
|
} catch {
|
|
39168
39246
|
return false;
|
|
39169
39247
|
}
|
|
@@ -39174,8 +39252,8 @@ function keepsFresherCodexLogin(authJsonPath, incoming) {
|
|
|
39174
39252
|
}
|
|
39175
39253
|
var geminiProvisioner = {
|
|
39176
39254
|
write(auth, home) {
|
|
39177
|
-
const settingsJson =
|
|
39178
|
-
const oauthCreds =
|
|
39255
|
+
const settingsJson = path84.join(home, ".gemini", "settings.json");
|
|
39256
|
+
const oauthCreds = path84.join(home, ".gemini", "oauth_creds.json");
|
|
39179
39257
|
if (auth.kind === "api_key") {
|
|
39180
39258
|
rmIfExists(oauthCreds);
|
|
39181
39259
|
writeFile0600(settingsJson, '{"security":{"auth":{"selectedType":"gemini-api-key"}}}');
|
|
@@ -39188,7 +39266,7 @@ var geminiProvisioner = {
|
|
|
39188
39266
|
};
|
|
39189
39267
|
var cursorProvisioner = {
|
|
39190
39268
|
write(auth, home) {
|
|
39191
|
-
const authJson =
|
|
39269
|
+
const authJson = path84.join(home, ".config", "cursor", "auth.json");
|
|
39192
39270
|
if (auth.kind === "api_key") {
|
|
39193
39271
|
rmIfExists(authJson);
|
|
39194
39272
|
return { CURSOR_API_KEY: auth.value };
|
|
@@ -39230,22 +39308,22 @@ max_context_size = 262144
|
|
|
39230
39308
|
var kimiProvisioner = {
|
|
39231
39309
|
write(auth, home) {
|
|
39232
39310
|
const credentialsFiles = [
|
|
39233
|
-
|
|
39234
|
-
|
|
39311
|
+
path84.join(home, ".kimi", "credentials", "kimi-code.json"),
|
|
39312
|
+
path84.join(home, ".kimi-code", "credentials", "kimi-code.json")
|
|
39235
39313
|
];
|
|
39236
39314
|
if (auth.kind === "api_key") {
|
|
39237
39315
|
credentialsFiles.forEach(rmIfExists);
|
|
39238
39316
|
return { KIMI_API_KEY: auth.value };
|
|
39239
39317
|
}
|
|
39240
39318
|
credentialsFiles.forEach((f) => writeFile0600(f, auth.value));
|
|
39241
|
-
writeFile0600(
|
|
39319
|
+
writeFile0600(path84.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
|
|
39242
39320
|
return {};
|
|
39243
39321
|
}
|
|
39244
39322
|
};
|
|
39245
39323
|
var coderabbitProvisioner = {
|
|
39246
39324
|
write(auth, home) {
|
|
39247
|
-
const dir =
|
|
39248
|
-
const authJson =
|
|
39325
|
+
const dir = path84.join(home, ".coderabbit");
|
|
39326
|
+
const authJson = path84.join(dir, "auth.json");
|
|
39249
39327
|
if (auth.kind === "api_key") {
|
|
39250
39328
|
rmIfExists(authJson);
|
|
39251
39329
|
return { CODERABBIT_API_KEY: auth.value };
|
|
@@ -39257,13 +39335,13 @@ var coderabbitProvisioner = {
|
|
|
39257
39335
|
try {
|
|
39258
39336
|
const parsed = JSON.parse(value);
|
|
39259
39337
|
if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
|
|
39260
|
-
file =
|
|
39338
|
+
file = path84.basename(parsed.file);
|
|
39261
39339
|
contents = parsed.contents;
|
|
39262
39340
|
}
|
|
39263
39341
|
} catch {
|
|
39264
39342
|
}
|
|
39265
39343
|
}
|
|
39266
|
-
writeFile0600(
|
|
39344
|
+
writeFile0600(path84.join(dir, file), contents);
|
|
39267
39345
|
return {};
|
|
39268
39346
|
}
|
|
39269
39347
|
};
|
|
@@ -39295,7 +39373,7 @@ var UnsupportedAgentError = class extends Error {
|
|
|
39295
39373
|
this.agentId = agentId;
|
|
39296
39374
|
}
|
|
39297
39375
|
};
|
|
39298
|
-
function provisionAgentCredentials(publicAgentId, auth, homeDir2 =
|
|
39376
|
+
function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os55.homedir()) {
|
|
39299
39377
|
const internal = toInternalAgentId(publicAgentId);
|
|
39300
39378
|
if (!internal) throw new UnsupportedAgentError(publicAgentId);
|
|
39301
39379
|
const provisioner = PROVISIONERS[internal];
|
|
@@ -39304,8 +39382,8 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os54.homedir(
|
|
|
39304
39382
|
}
|
|
39305
39383
|
|
|
39306
39384
|
// src/beads/workflow-hint.ts
|
|
39307
|
-
var
|
|
39308
|
-
var
|
|
39385
|
+
var fs76 = __toESM(require("fs"));
|
|
39386
|
+
var path85 = __toESM(require("path"));
|
|
39309
39387
|
var BEADS_HINT_MARKER = "<!-- codeam:beads-workflow -->";
|
|
39310
39388
|
var BEADS_HINT = `${BEADS_HINT_MARKER}
|
|
39311
39389
|
# Beads (bd) \u2014 task tracking + persistent memory (ALWAYS use it)
|
|
@@ -39332,11 +39410,11 @@ function ensureBeadsWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
|
39332
39410
|
try {
|
|
39333
39411
|
let existing = "";
|
|
39334
39412
|
try {
|
|
39335
|
-
existing =
|
|
39413
|
+
existing = fs76.readFileSync(file, "utf8");
|
|
39336
39414
|
} catch {
|
|
39337
39415
|
}
|
|
39338
39416
|
if (existing.includes(BEADS_HINT)) return;
|
|
39339
|
-
|
|
39417
|
+
fs76.mkdirSync(path85.dirname(file), { recursive: true });
|
|
39340
39418
|
let next;
|
|
39341
39419
|
const open = existing.indexOf(BEADS_HINT_MARKER);
|
|
39342
39420
|
const close = open === -1 ? -1 : existing.indexOf(BEADS_HINT_MARKER, open + BEADS_HINT_MARKER.length);
|
|
@@ -39349,40 +39427,40 @@ ${BEADS_HINT}
|
|
|
39349
39427
|
` : `${BEADS_HINT}
|
|
39350
39428
|
`;
|
|
39351
39429
|
}
|
|
39352
|
-
|
|
39430
|
+
fs76.writeFileSync(file, next);
|
|
39353
39431
|
} catch {
|
|
39354
39432
|
}
|
|
39355
39433
|
}
|
|
39356
39434
|
|
|
39357
39435
|
// src/agents/agent-standard.ts
|
|
39358
|
-
var
|
|
39359
|
-
var
|
|
39360
|
-
var
|
|
39436
|
+
var fs77 = __toESM(require("fs"));
|
|
39437
|
+
var path86 = __toESM(require("path"));
|
|
39438
|
+
var os56 = __toESM(require("os"));
|
|
39361
39439
|
function ensureAgentStandard(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
39362
39440
|
try {
|
|
39363
39441
|
let existing = "";
|
|
39364
39442
|
try {
|
|
39365
|
-
existing =
|
|
39443
|
+
existing = fs77.readFileSync(file, "utf8");
|
|
39366
39444
|
} catch {
|
|
39367
39445
|
}
|
|
39368
39446
|
if (existing.includes(AGENT_STANDARD_MARKER)) return;
|
|
39369
|
-
|
|
39447
|
+
fs77.mkdirSync(path86.dirname(file), { recursive: true });
|
|
39370
39448
|
const next = existing.trim() ? `${existing.trimEnd()}
|
|
39371
39449
|
|
|
39372
39450
|
${AGENT_STANDARD_BLOCK}
|
|
39373
39451
|
` : `${AGENT_STANDARD_BLOCK}
|
|
39374
39452
|
`;
|
|
39375
|
-
|
|
39453
|
+
fs77.writeFileSync(file, next);
|
|
39376
39454
|
} catch {
|
|
39377
39455
|
}
|
|
39378
39456
|
}
|
|
39379
39457
|
var _agentStandardSeam = {
|
|
39380
39458
|
isLocalSession: () => isLocalSession(),
|
|
39381
|
-
markerPath: (sessionId) =>
|
|
39382
|
-
exists: (p2) =>
|
|
39459
|
+
markerPath: (sessionId) => path86.join(os56.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
|
|
39460
|
+
exists: (p2) => fs77.existsSync(p2),
|
|
39383
39461
|
write: (p2) => {
|
|
39384
|
-
|
|
39385
|
-
|
|
39462
|
+
fs77.mkdirSync(path86.dirname(p2), { recursive: true });
|
|
39463
|
+
fs77.writeFileSync(p2, "");
|
|
39386
39464
|
}
|
|
39387
39465
|
};
|
|
39388
39466
|
function isClaude(agent) {
|
|
@@ -40243,15 +40321,15 @@ function withholdTrailingPartialFenceMarker(text) {
|
|
|
40243
40321
|
|
|
40244
40322
|
// src/agents/acp/onboarding.ts
|
|
40245
40323
|
var import_child_process28 = require("child_process");
|
|
40246
|
-
var
|
|
40247
|
-
var
|
|
40248
|
-
var
|
|
40324
|
+
var fs79 = __toESM(require("fs"));
|
|
40325
|
+
var os57 = __toESM(require("os"));
|
|
40326
|
+
var path88 = __toESM(require("path"));
|
|
40249
40327
|
var _onboardingSeam = {
|
|
40250
|
-
markerPath: (sessionId) =>
|
|
40251
|
-
exists: (p2) =>
|
|
40328
|
+
markerPath: (sessionId) => path88.join(os57.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
|
|
40329
|
+
exists: (p2) => fs79.existsSync(p2),
|
|
40252
40330
|
write: (p2) => {
|
|
40253
|
-
|
|
40254
|
-
|
|
40331
|
+
fs79.mkdirSync(path88.dirname(p2), { recursive: true });
|
|
40332
|
+
fs79.writeFileSync(p2, "");
|
|
40255
40333
|
},
|
|
40256
40334
|
disabled: () => {
|
|
40257
40335
|
const v = process.env.CODEAM_ONBOARDING_DISABLED;
|
|
@@ -40288,7 +40366,7 @@ function resolveRepoName(cwd) {
|
|
|
40288
40366
|
if (name) return name;
|
|
40289
40367
|
}
|
|
40290
40368
|
}
|
|
40291
|
-
const base =
|
|
40369
|
+
const base = path88.basename(cwd || "");
|
|
40292
40370
|
if (base && !isUuid(base)) return base;
|
|
40293
40371
|
return "this project";
|
|
40294
40372
|
}
|
|
@@ -40688,14 +40766,14 @@ var import_crypto5 = require("crypto");
|
|
|
40688
40766
|
|
|
40689
40767
|
// src/services/turn-files/git-changeset.ts
|
|
40690
40768
|
var import_child_process29 = require("child_process");
|
|
40691
|
-
var
|
|
40769
|
+
var fs81 = __toESM(require("fs/promises"));
|
|
40692
40770
|
var import_fs10 = require("fs");
|
|
40693
|
-
var
|
|
40771
|
+
var path90 = __toESM(require("path"));
|
|
40694
40772
|
|
|
40695
40773
|
// src/services/turn-files/review-ignore.ts
|
|
40696
40774
|
var import_ignore2 = __toESM(require("ignore"));
|
|
40697
|
-
var
|
|
40698
|
-
var
|
|
40775
|
+
var fs80 = __toESM(require("fs"));
|
|
40776
|
+
var path89 = __toESM(require("path"));
|
|
40699
40777
|
var CURATED_REVIEW_IGNORE = [
|
|
40700
40778
|
// Google Cloud SDK (the incident) — installs a huge python tree.
|
|
40701
40779
|
"google-cloud-sdk/",
|
|
@@ -40739,7 +40817,7 @@ var CURATED_REVIEW_IGNORE = [
|
|
|
40739
40817
|
function makeReviewIgnore(repoRoot) {
|
|
40740
40818
|
const ig = (0, import_ignore2.default)().add(CURATED_REVIEW_IGNORE);
|
|
40741
40819
|
try {
|
|
40742
|
-
const custom =
|
|
40820
|
+
const custom = fs80.readFileSync(path89.join(repoRoot, ".codeam", "reviewignore"), "utf8");
|
|
40743
40821
|
ig.add(custom);
|
|
40744
40822
|
} catch {
|
|
40745
40823
|
}
|
|
@@ -40774,7 +40852,7 @@ async function collectRepoChangeset(opts) {
|
|
|
40774
40852
|
const rows = parseStatus(status2).filter(
|
|
40775
40853
|
(row) => !isIgnoredFilePath(row.filePath) && !reviewIgnore(row.filePath) && // A socket, FIFO or device node is never a change to review (a
|
|
40776
40854
|
// `cc-socks/1522.sock` reached the Files tab).
|
|
40777
|
-
isReviewablePath(
|
|
40855
|
+
isReviewablePath(path90.join(opts.repoRoot, row.filePath))
|
|
40778
40856
|
);
|
|
40779
40857
|
const MAX_CHANGESET_FILES = Math.max(1, Number(process.env.CODEAM_MAX_CHANGESET_FILES ?? 500));
|
|
40780
40858
|
const truncated = rows.length > MAX_CHANGESET_FILES;
|
|
@@ -40791,7 +40869,7 @@ async function collectRepoChangeset(opts) {
|
|
|
40791
40869
|
let stats;
|
|
40792
40870
|
if (!truncated && row.fileStatus === "added" && numstatEntry === void 0) {
|
|
40793
40871
|
const lineCount = await readUntrackedLineCount(
|
|
40794
|
-
|
|
40872
|
+
path90.join(opts.repoRoot, row.filePath)
|
|
40795
40873
|
);
|
|
40796
40874
|
stats = { added: lineCount, removed: 0 };
|
|
40797
40875
|
} else {
|
|
@@ -40822,7 +40900,7 @@ function readUntrackedLineCount(absPath) {
|
|
|
40822
40900
|
}
|
|
40823
40901
|
async function defaultReadUntrackedLineCount(absPath) {
|
|
40824
40902
|
try {
|
|
40825
|
-
const content = await
|
|
40903
|
+
const content = await fs81.readFile(absPath, "utf8");
|
|
40826
40904
|
let count = 0;
|
|
40827
40905
|
let pos = -1;
|
|
40828
40906
|
while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
|
|
@@ -40914,7 +40992,7 @@ function defaultRunGit(cwd, args2) {
|
|
|
40914
40992
|
});
|
|
40915
40993
|
}
|
|
40916
40994
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
40917
|
-
const
|
|
40995
|
+
const fs104 = await import("fs/promises");
|
|
40918
40996
|
const out2 = [];
|
|
40919
40997
|
await walk2(workingDir, 0);
|
|
40920
40998
|
return out2;
|
|
@@ -40922,7 +41000,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
40922
41000
|
if (depth2 > maxDepth) return;
|
|
40923
41001
|
let entries2 = [];
|
|
40924
41002
|
try {
|
|
40925
|
-
const dirents = await
|
|
41003
|
+
const dirents = await fs104.readdir(dir, { withFileTypes: true });
|
|
40926
41004
|
entries2 = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
40927
41005
|
} catch {
|
|
40928
41006
|
return;
|
|
@@ -40933,8 +41011,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
40933
41011
|
if (hasGit) {
|
|
40934
41012
|
out2.push({
|
|
40935
41013
|
repoRoot: dir,
|
|
40936
|
-
repoPath:
|
|
40937
|
-
repoName:
|
|
41014
|
+
repoPath: path90.relative(workingDir, dir),
|
|
41015
|
+
repoName: path90.basename(dir)
|
|
40938
41016
|
});
|
|
40939
41017
|
return;
|
|
40940
41018
|
}
|
|
@@ -40942,7 +41020,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
40942
41020
|
if (!entry.isDirectory) continue;
|
|
40943
41021
|
if (entry.name === "node_modules") continue;
|
|
40944
41022
|
if (entry.name === "dist" || entry.name === "build") continue;
|
|
40945
|
-
await walk2(
|
|
41023
|
+
await walk2(path90.join(dir, entry.name), depth2 + 1);
|
|
40946
41024
|
}
|
|
40947
41025
|
}
|
|
40948
41026
|
}
|
|
@@ -40956,8 +41034,8 @@ function isReviewablePath(absPath) {
|
|
|
40956
41034
|
}
|
|
40957
41035
|
|
|
40958
41036
|
// src/services/turn-files/files-outbox.ts
|
|
40959
|
-
var
|
|
40960
|
-
var
|
|
41037
|
+
var fs82 = __toESM(require("fs/promises"));
|
|
41038
|
+
var path91 = __toESM(require("path"));
|
|
40961
41039
|
var import_os14 = require("os");
|
|
40962
41040
|
var HOME_OUTBOX_DIR = ".codeam/outbox";
|
|
40963
41041
|
var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -40990,16 +41068,16 @@ var FilesOutbox = class {
|
|
|
40990
41068
|
backoffIndex = 0;
|
|
40991
41069
|
stopped = false;
|
|
40992
41070
|
constructor(opts) {
|
|
40993
|
-
const base = opts.baseDir ??
|
|
40994
|
-
this.filePath =
|
|
41071
|
+
const base = opts.baseDir ?? path91.join(homeDir(), HOME_OUTBOX_DIR);
|
|
41072
|
+
this.filePath = path91.join(base, `${opts.sessionId}.jsonl`);
|
|
40995
41073
|
this.post = opts.post;
|
|
40996
41074
|
this.autoSchedule = opts.autoSchedule !== false;
|
|
40997
41075
|
}
|
|
40998
41076
|
/** Persist the entry to disk and trigger a flush. Returns once the
|
|
40999
41077
|
* line is durable on disk (not once the POST succeeds). */
|
|
41000
41078
|
async enqueue(entry) {
|
|
41001
|
-
await
|
|
41002
|
-
await
|
|
41079
|
+
await fs82.mkdir(path91.dirname(this.filePath), { recursive: true });
|
|
41080
|
+
await fs82.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
|
|
41003
41081
|
this.backoffIndex = 0;
|
|
41004
41082
|
if (this.autoSchedule) this.scheduleFlush(0);
|
|
41005
41083
|
}
|
|
@@ -41090,7 +41168,7 @@ var FilesOutbox = class {
|
|
|
41090
41168
|
async readAll() {
|
|
41091
41169
|
let raw = "";
|
|
41092
41170
|
try {
|
|
41093
|
-
raw = await
|
|
41171
|
+
raw = await fs82.readFile(this.filePath, "utf8");
|
|
41094
41172
|
} catch {
|
|
41095
41173
|
return [];
|
|
41096
41174
|
}
|
|
@@ -41114,12 +41192,12 @@ var FilesOutbox = class {
|
|
|
41114
41192
|
async rewrite(entries2) {
|
|
41115
41193
|
const tmpPath = `${this.filePath}.${process.pid}.tmp`;
|
|
41116
41194
|
if (entries2.length === 0) {
|
|
41117
|
-
await
|
|
41195
|
+
await fs82.unlink(this.filePath).catch(() => void 0);
|
|
41118
41196
|
return;
|
|
41119
41197
|
}
|
|
41120
41198
|
const payload = entries2.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
41121
|
-
await
|
|
41122
|
-
await
|
|
41199
|
+
await fs82.writeFile(tmpPath, payload, "utf8");
|
|
41200
|
+
await fs82.rename(tmpPath, this.filePath);
|
|
41123
41201
|
}
|
|
41124
41202
|
};
|
|
41125
41203
|
function applyJitter(ms) {
|
|
@@ -41489,8 +41567,8 @@ async function readActiveConversationMarker(cwd, homeDir2) {
|
|
|
41489
41567
|
|
|
41490
41568
|
// src/packs/gates.ts
|
|
41491
41569
|
var import_node_child_process29 = require("child_process");
|
|
41492
|
-
var
|
|
41493
|
-
var
|
|
41570
|
+
var fs84 = __toESM(require("fs"));
|
|
41571
|
+
var path93 = __toESM(require("path"));
|
|
41494
41572
|
var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((resolve13) => {
|
|
41495
41573
|
(0, import_node_child_process29.execFile)(
|
|
41496
41574
|
file,
|
|
@@ -41540,7 +41618,7 @@ async function changedFiles(run3, cwd, from, to) {
|
|
|
41540
41618
|
}
|
|
41541
41619
|
function readWorkspaceFile(cwd, relPath) {
|
|
41542
41620
|
try {
|
|
41543
|
-
return
|
|
41621
|
+
return fs84.readFileSync(path93.join(cwd, relPath), "utf8");
|
|
41544
41622
|
} catch {
|
|
41545
41623
|
return null;
|
|
41546
41624
|
}
|
|
@@ -41549,14 +41627,14 @@ var NO_TEST_PLACEHOLDER = 'echo "Error: no test specified"';
|
|
|
41549
41627
|
var CHECKS_TIMEOUT_MS = 5 * 6e4;
|
|
41550
41628
|
function detectChecksCommand(cwd) {
|
|
41551
41629
|
try {
|
|
41552
|
-
const cfg = JSON.parse(
|
|
41630
|
+
const cfg = JSON.parse(fs84.readFileSync(path93.join(cwd, ".codeam", "pack.json"), "utf8"));
|
|
41553
41631
|
if (typeof cfg.checksCommand === "string" && cfg.checksCommand.trim().length > 0) {
|
|
41554
41632
|
return cfg.checksCommand.trim();
|
|
41555
41633
|
}
|
|
41556
41634
|
} catch {
|
|
41557
41635
|
}
|
|
41558
41636
|
try {
|
|
41559
|
-
const pkg = JSON.parse(
|
|
41637
|
+
const pkg = JSON.parse(fs84.readFileSync(path93.join(cwd, "package.json"), "utf8"));
|
|
41560
41638
|
const test = pkg.scripts?.test;
|
|
41561
41639
|
if (typeof test === "string" && test.trim().length > 0 && !test.includes(NO_TEST_PLACEHOLDER)) {
|
|
41562
41640
|
return "npm test";
|
|
@@ -41574,39 +41652,39 @@ ${res.stderr}`.trim();
|
|
|
41574
41652
|
}
|
|
41575
41653
|
|
|
41576
41654
|
// src/packs/run-store.ts
|
|
41577
|
-
var
|
|
41578
|
-
var
|
|
41655
|
+
var fs85 = __toESM(require("fs"));
|
|
41656
|
+
var path94 = __toESM(require("path"));
|
|
41579
41657
|
var crypto5 = __toESM(require("crypto"));
|
|
41580
41658
|
function packsDir(cwd) {
|
|
41581
|
-
return
|
|
41659
|
+
return path94.join(cwd, ".codeam", "packs");
|
|
41582
41660
|
}
|
|
41583
41661
|
function runDir(cwd, runId) {
|
|
41584
|
-
return
|
|
41662
|
+
return path94.join(packsDir(cwd), runId);
|
|
41585
41663
|
}
|
|
41586
41664
|
function newRunId() {
|
|
41587
41665
|
return `pk_${Date.now().toString(36)}_${crypto5.randomBytes(4).toString("hex")}`;
|
|
41588
41666
|
}
|
|
41589
41667
|
function writeJsonAtomic(file, value) {
|
|
41590
|
-
|
|
41668
|
+
fs85.mkdirSync(path94.dirname(file), { recursive: true });
|
|
41591
41669
|
const tmp = `${file}.tmp`;
|
|
41592
|
-
|
|
41593
|
-
|
|
41670
|
+
fs85.writeFileSync(tmp, JSON.stringify(value, null, 2));
|
|
41671
|
+
fs85.renameSync(tmp, file);
|
|
41594
41672
|
}
|
|
41595
41673
|
function saveRun(cwd, state) {
|
|
41596
|
-
writeJsonAtomic(
|
|
41674
|
+
writeJsonAtomic(path94.join(runDir(cwd, state.runId), "run.json"), state);
|
|
41597
41675
|
}
|
|
41598
41676
|
function saveStageHandoff(cwd, runId, stageIndex, role, handoff) {
|
|
41599
41677
|
const name = `${String(stageIndex + 1).padStart(2, "0")}-${role}.json`;
|
|
41600
|
-
writeJsonAtomic(
|
|
41678
|
+
writeJsonAtomic(path94.join(runDir(cwd, runId), name), handoff);
|
|
41601
41679
|
}
|
|
41602
41680
|
function loadLatestRun(cwd) {
|
|
41603
41681
|
try {
|
|
41604
41682
|
const dir = packsDir(cwd);
|
|
41605
|
-
const entries2 =
|
|
41683
|
+
const entries2 = fs85.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
41606
41684
|
for (let i = entries2.length - 1; i >= 0; i--) {
|
|
41607
|
-
const file =
|
|
41685
|
+
const file = path94.join(dir, entries2[i], "run.json");
|
|
41608
41686
|
try {
|
|
41609
|
-
const parsed = JSON.parse(
|
|
41687
|
+
const parsed = JSON.parse(fs85.readFileSync(file, "utf8"));
|
|
41610
41688
|
if (parsed && typeof parsed.runId === "string") return parsed;
|
|
41611
41689
|
} catch {
|
|
41612
41690
|
}
|
|
@@ -41617,17 +41695,17 @@ function loadLatestRun(cwd) {
|
|
|
41617
41695
|
}
|
|
41618
41696
|
function ensureLedgerIgnored(cwd) {
|
|
41619
41697
|
try {
|
|
41620
|
-
const gitDir =
|
|
41621
|
-
if (!
|
|
41622
|
-
const exclude =
|
|
41698
|
+
const gitDir = path94.join(cwd, ".git");
|
|
41699
|
+
if (!fs85.existsSync(gitDir)) return;
|
|
41700
|
+
const exclude = path94.join(gitDir, "info", "exclude");
|
|
41623
41701
|
let existing = "";
|
|
41624
41702
|
try {
|
|
41625
|
-
existing =
|
|
41703
|
+
existing = fs85.readFileSync(exclude, "utf8");
|
|
41626
41704
|
} catch {
|
|
41627
41705
|
}
|
|
41628
41706
|
if (existing.includes(".codeam/packs/")) return;
|
|
41629
|
-
|
|
41630
|
-
|
|
41707
|
+
fs85.mkdirSync(path94.dirname(exclude), { recursive: true });
|
|
41708
|
+
fs85.writeFileSync(exclude, `${existing.trimEnd()}
|
|
41631
41709
|
.codeam/packs/
|
|
41632
41710
|
`.trimStart());
|
|
41633
41711
|
} catch {
|
|
@@ -42622,20 +42700,20 @@ async function mcpRouter() {
|
|
|
42622
42700
|
}
|
|
42623
42701
|
|
|
42624
42702
|
// src/integrations/mcp-secrets.ts
|
|
42625
|
-
var
|
|
42626
|
-
var
|
|
42627
|
-
var
|
|
42703
|
+
var fs87 = __toESM(require("fs"));
|
|
42704
|
+
var os60 = __toESM(require("os"));
|
|
42705
|
+
var path96 = __toESM(require("path"));
|
|
42628
42706
|
var MCP_SECRETS_FILE_ENV = "CODEAM_MCP_SECRETS_FILE";
|
|
42629
42707
|
function mcpSecretsDir() {
|
|
42630
|
-
return
|
|
42708
|
+
return path96.join(os60.homedir(), ".codeam", "mcp-secrets");
|
|
42631
42709
|
}
|
|
42632
42710
|
function mcpSecretsPath(scope, pid = process.pid) {
|
|
42633
|
-
return
|
|
42711
|
+
return path96.join(mcpSecretsDir(), `${pid}-${scope}.json`);
|
|
42634
42712
|
}
|
|
42635
42713
|
var registeredForCleanup = /* @__PURE__ */ new Set();
|
|
42636
42714
|
function readFileVars(file) {
|
|
42637
42715
|
try {
|
|
42638
|
-
const parsed = JSON.parse(
|
|
42716
|
+
const parsed = JSON.parse(fs87.readFileSync(file, "utf8"));
|
|
42639
42717
|
if (!parsed || typeof parsed !== "object") return {};
|
|
42640
42718
|
const out2 = {};
|
|
42641
42719
|
for (const [k2, v] of Object.entries(parsed)) {
|
|
@@ -42657,7 +42735,7 @@ function pidAlive2(pid) {
|
|
|
42657
42735
|
function pruneStale(dir) {
|
|
42658
42736
|
let names = [];
|
|
42659
42737
|
try {
|
|
42660
|
-
names =
|
|
42738
|
+
names = fs87.readdirSync(dir);
|
|
42661
42739
|
} catch {
|
|
42662
42740
|
return;
|
|
42663
42741
|
}
|
|
@@ -42667,25 +42745,25 @@ function pruneStale(dir) {
|
|
|
42667
42745
|
const pid = Number(m[1]);
|
|
42668
42746
|
if (pid === process.pid || pidAlive2(pid)) continue;
|
|
42669
42747
|
try {
|
|
42670
|
-
|
|
42748
|
+
fs87.unlinkSync(path96.join(dir, name));
|
|
42671
42749
|
} catch {
|
|
42672
42750
|
}
|
|
42673
42751
|
}
|
|
42674
42752
|
}
|
|
42675
42753
|
function writeMcpSecrets(vars, file) {
|
|
42676
42754
|
try {
|
|
42677
|
-
const dir =
|
|
42678
|
-
|
|
42755
|
+
const dir = path96.dirname(file);
|
|
42756
|
+
fs87.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
42679
42757
|
pruneStale(dir);
|
|
42680
42758
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
42681
|
-
|
|
42682
|
-
|
|
42683
|
-
|
|
42759
|
+
fs87.writeFileSync(tmp, JSON.stringify(vars), { mode: 384 });
|
|
42760
|
+
fs87.renameSync(tmp, file);
|
|
42761
|
+
fs87.chmodSync(file, 384);
|
|
42684
42762
|
if (!registeredForCleanup.has(file)) {
|
|
42685
42763
|
registeredForCleanup.add(file);
|
|
42686
42764
|
process.once("exit", () => {
|
|
42687
42765
|
try {
|
|
42688
|
-
|
|
42766
|
+
fs87.unlinkSync(file);
|
|
42689
42767
|
} catch {
|
|
42690
42768
|
}
|
|
42691
42769
|
});
|
|
@@ -42775,11 +42853,11 @@ function previewMcpServer(bridge) {
|
|
|
42775
42853
|
};
|
|
42776
42854
|
}
|
|
42777
42855
|
function httpCall(baseUrl, token) {
|
|
42778
|
-
return async (
|
|
42856
|
+
return async (path117, method, body, timeoutMs) => {
|
|
42779
42857
|
const ac = new AbortController();
|
|
42780
42858
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
42781
42859
|
try {
|
|
42782
|
-
const res = await fetch(`${baseUrl}${
|
|
42860
|
+
const res = await fetch(`${baseUrl}${path117}`, {
|
|
42783
42861
|
method,
|
|
42784
42862
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
42785
42863
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -42916,11 +42994,11 @@ function scratchMcpServer(bridge) {
|
|
|
42916
42994
|
};
|
|
42917
42995
|
}
|
|
42918
42996
|
function httpCall2(baseUrl, token) {
|
|
42919
|
-
return async (
|
|
42997
|
+
return async (path117, method, body, timeoutMs) => {
|
|
42920
42998
|
const ac = new AbortController();
|
|
42921
42999
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
42922
43000
|
try {
|
|
42923
|
-
const res = await fetch(`${baseUrl}${
|
|
43001
|
+
const res = await fetch(`${baseUrl}${path117}`, {
|
|
42924
43002
|
method,
|
|
42925
43003
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
42926
43004
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -46029,17 +46107,17 @@ async function runAcpSession(opts) {
|
|
|
46029
46107
|
switchCredentialEnv = provisionAgentCredentials(agentId, auth);
|
|
46030
46108
|
},
|
|
46031
46109
|
provisionHouseProxy: ({ baseUrl, token, model, managedAgentId }) => {
|
|
46032
|
-
const claudeConfigDir2 =
|
|
46033
|
-
|
|
46110
|
+
const claudeConfigDir2 = path99.join(
|
|
46111
|
+
os62.homedir(),
|
|
46034
46112
|
".codeam",
|
|
46035
46113
|
"house-claude",
|
|
46036
46114
|
`switch-${opts.pluginId}`
|
|
46037
46115
|
);
|
|
46038
46116
|
try {
|
|
46039
|
-
|
|
46117
|
+
fs90.mkdirSync(claudeConfigDir2, { recursive: true, mode: 448 });
|
|
46040
46118
|
} catch {
|
|
46041
46119
|
}
|
|
46042
|
-
const memoryFile =
|
|
46120
|
+
const memoryFile = path99.join(claudeConfigDir2, "CLAUDE.md");
|
|
46043
46121
|
ensureBeadsWorkflowHint(void 0, memoryFile);
|
|
46044
46122
|
ensureAgentStandard(void 0, memoryFile);
|
|
46045
46123
|
if (isScratchWorkspace(process.cwd())) ensureScratchWorkflowHint(void 0, memoryFile);
|
|
@@ -47279,9 +47357,9 @@ function pickPinnedSession(pinnedId, listSessions2) {
|
|
|
47279
47357
|
}
|
|
47280
47358
|
|
|
47281
47359
|
// src/agents/retired-proxy-cleanup.ts
|
|
47282
|
-
var
|
|
47283
|
-
var
|
|
47284
|
-
var
|
|
47360
|
+
var fs91 = __toESM(require("fs"));
|
|
47361
|
+
var path100 = __toESM(require("path"));
|
|
47362
|
+
var os63 = __toESM(require("os"));
|
|
47285
47363
|
var RETIRED_PROXY_RE = /^https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):8787(?:[/?#]|$)/i;
|
|
47286
47364
|
var HEADROOM_CMD_RE = /(^|[\s/"'])headroom(\s|$)/i;
|
|
47287
47365
|
var MARKETPLACE_KEY = "headroom-marketplace";
|
|
@@ -47290,12 +47368,12 @@ function isHeadroomHook(group) {
|
|
|
47290
47368
|
(h) => typeof h?.command === "string" && HEADROOM_CMD_RE.test(h.command)
|
|
47291
47369
|
);
|
|
47292
47370
|
}
|
|
47293
|
-
function sanitizeRetiredProxyConfig(homeDir2 =
|
|
47371
|
+
function sanitizeRetiredProxyConfig(homeDir2 = os63.homedir()) {
|
|
47294
47372
|
const out2 = { inspected: false, changed: false, removed: [] };
|
|
47295
|
-
const file =
|
|
47373
|
+
const file = path100.join(homeDir2, ".claude", "settings.json");
|
|
47296
47374
|
let parsed;
|
|
47297
47375
|
try {
|
|
47298
|
-
parsed = JSON.parse(
|
|
47376
|
+
parsed = JSON.parse(fs91.readFileSync(file, "utf8"));
|
|
47299
47377
|
} catch {
|
|
47300
47378
|
return out2;
|
|
47301
47379
|
}
|
|
@@ -47337,9 +47415,9 @@ function sanitizeRetiredProxyConfig(homeDir2 = os62.homedir()) {
|
|
|
47337
47415
|
if (!out2.changed) return out2;
|
|
47338
47416
|
try {
|
|
47339
47417
|
const tmp = `${file}.codeam.tmp`;
|
|
47340
|
-
|
|
47418
|
+
fs91.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
|
|
47341
47419
|
`, { mode: 384 });
|
|
47342
|
-
|
|
47420
|
+
fs91.renameSync(tmp, file);
|
|
47343
47421
|
} catch {
|
|
47344
47422
|
out2.changed = false;
|
|
47345
47423
|
}
|
|
@@ -47885,7 +47963,7 @@ var AcpDriver = class {
|
|
|
47885
47963
|
};
|
|
47886
47964
|
|
|
47887
47965
|
// src/baton/transcript-mirror.ts
|
|
47888
|
-
var
|
|
47966
|
+
var fs92 = __toESM(require("fs"));
|
|
47889
47967
|
var TranscriptMirror = class {
|
|
47890
47968
|
constructor(deps) {
|
|
47891
47969
|
this.deps = deps;
|
|
@@ -47979,7 +48057,7 @@ var TranscriptMirror = class {
|
|
|
47979
48057
|
}
|
|
47980
48058
|
};
|
|
47981
48059
|
function defaultWatch(file, onChange) {
|
|
47982
|
-
const w3 =
|
|
48060
|
+
const w3 = fs92.watch(file, { persistent: false }, () => onChange());
|
|
47983
48061
|
return () => w3.close();
|
|
47984
48062
|
}
|
|
47985
48063
|
|
|
@@ -48479,16 +48557,16 @@ function keepDeviceAwake(deps = {}) {
|
|
|
48479
48557
|
}
|
|
48480
48558
|
|
|
48481
48559
|
// src/agents/claude/onboarding.ts
|
|
48482
|
-
var
|
|
48483
|
-
var
|
|
48484
|
-
var
|
|
48560
|
+
var fs93 = __toESM(require("fs"));
|
|
48561
|
+
var os65 = __toESM(require("os"));
|
|
48562
|
+
var path101 = __toESM(require("path"));
|
|
48485
48563
|
var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
|
|
48486
48564
|
function ensureClaudeOnboarded(cwd) {
|
|
48487
48565
|
try {
|
|
48488
|
-
const file =
|
|
48566
|
+
const file = path101.join(os65.homedir(), ".claude.json");
|
|
48489
48567
|
let config = {};
|
|
48490
48568
|
try {
|
|
48491
|
-
config = JSON.parse(
|
|
48569
|
+
config = JSON.parse(fs93.readFileSync(file, "utf8"));
|
|
48492
48570
|
} catch {
|
|
48493
48571
|
}
|
|
48494
48572
|
let changed = false;
|
|
@@ -48513,8 +48591,8 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
48513
48591
|
}
|
|
48514
48592
|
}
|
|
48515
48593
|
if (!changed) return;
|
|
48516
|
-
|
|
48517
|
-
|
|
48594
|
+
fs93.mkdirSync(path101.dirname(file), { recursive: true });
|
|
48595
|
+
fs93.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
48518
48596
|
log.info(
|
|
48519
48597
|
"claude",
|
|
48520
48598
|
`pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
|
|
@@ -49386,7 +49464,7 @@ var import_picocolors10 = __toESM(require("picocolors"));
|
|
|
49386
49464
|
var import_child_process30 = require("child_process");
|
|
49387
49465
|
var import_util4 = require("util");
|
|
49388
49466
|
var import_picocolors8 = __toESM(require("picocolors"));
|
|
49389
|
-
var
|
|
49467
|
+
var path102 = __toESM(require("path"));
|
|
49390
49468
|
var execFileP6 = (0, import_util4.promisify)(import_child_process30.execFile);
|
|
49391
49469
|
var MAX_BUFFER = 8 * 1024 * 1024;
|
|
49392
49470
|
function resetStdinForChild() {
|
|
@@ -49875,7 +49953,7 @@ var GitHubCodespacesProvider = class {
|
|
|
49875
49953
|
});
|
|
49876
49954
|
}
|
|
49877
49955
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
49878
|
-
const remoteDir =
|
|
49956
|
+
const remoteDir = path102.posix.dirname(remotePath);
|
|
49879
49957
|
const parts = [
|
|
49880
49958
|
`mkdir -p ${shellQuote(remoteDir)}`,
|
|
49881
49959
|
`cat > ${shellQuote(remotePath)}`
|
|
@@ -49945,7 +50023,7 @@ function shellQuote(s) {
|
|
|
49945
50023
|
// src/services/providers/gitpod.ts
|
|
49946
50024
|
var import_child_process31 = require("child_process");
|
|
49947
50025
|
var import_util5 = require("util");
|
|
49948
|
-
var
|
|
50026
|
+
var path103 = __toESM(require("path"));
|
|
49949
50027
|
var import_picocolors9 = __toESM(require("picocolors"));
|
|
49950
50028
|
var execFileP7 = (0, import_util5.promisify)(import_child_process31.execFile);
|
|
49951
50029
|
var MAX_BUFFER2 = 8 * 1024 * 1024;
|
|
@@ -50185,7 +50263,7 @@ var GitpodProvider = class {
|
|
|
50185
50263
|
});
|
|
50186
50264
|
}
|
|
50187
50265
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
50188
|
-
const remoteDir =
|
|
50266
|
+
const remoteDir = path103.posix.dirname(remotePath);
|
|
50189
50267
|
const parts = [
|
|
50190
50268
|
`mkdir -p ${shellQuote2(remoteDir)}`,
|
|
50191
50269
|
`cat > ${shellQuote2(remotePath)}`
|
|
@@ -50221,7 +50299,7 @@ function shellQuote2(s) {
|
|
|
50221
50299
|
// src/services/providers/gitlab-workspaces.ts
|
|
50222
50300
|
var import_child_process32 = require("child_process");
|
|
50223
50301
|
var import_util6 = require("util");
|
|
50224
|
-
var
|
|
50302
|
+
var path104 = __toESM(require("path"));
|
|
50225
50303
|
var execFileP8 = (0, import_util6.promisify)(import_child_process32.execFile);
|
|
50226
50304
|
var MAX_BUFFER3 = 8 * 1024 * 1024;
|
|
50227
50305
|
var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
|
|
@@ -50481,7 +50559,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
50481
50559
|
}
|
|
50482
50560
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
50483
50561
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
50484
|
-
const remoteDir =
|
|
50562
|
+
const remoteDir = path104.posix.dirname(remotePath);
|
|
50485
50563
|
const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
|
|
50486
50564
|
if (options.mode != null) {
|
|
50487
50565
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
@@ -50549,7 +50627,7 @@ function shellQuote3(s) {
|
|
|
50549
50627
|
// src/services/providers/railway.ts
|
|
50550
50628
|
var import_child_process33 = require("child_process");
|
|
50551
50629
|
var import_util7 = require("util");
|
|
50552
|
-
var
|
|
50630
|
+
var path105 = __toESM(require("path"));
|
|
50553
50631
|
var execFileP9 = (0, import_util7.promisify)(import_child_process33.execFile);
|
|
50554
50632
|
var MAX_BUFFER4 = 8 * 1024 * 1024;
|
|
50555
50633
|
function resetStdinForChild4() {
|
|
@@ -50785,7 +50863,7 @@ var RailwayProvider = class {
|
|
|
50785
50863
|
if (!projectId || !serviceId) {
|
|
50786
50864
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
50787
50865
|
}
|
|
50788
|
-
const remoteDir =
|
|
50866
|
+
const remoteDir = path105.posix.dirname(remotePath);
|
|
50789
50867
|
const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
|
|
50790
50868
|
if (options.mode != null) {
|
|
50791
50869
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
@@ -51325,14 +51403,14 @@ async function stopWorkspaceFromLocal(target) {
|
|
|
51325
51403
|
}
|
|
51326
51404
|
|
|
51327
51405
|
// src/commands/host/host-client.ts
|
|
51328
|
-
var
|
|
51329
|
-
var
|
|
51330
|
-
var
|
|
51406
|
+
var fs94 = __toESM(require("fs"));
|
|
51407
|
+
var os66 = __toESM(require("os"));
|
|
51408
|
+
var path106 = __toESM(require("path"));
|
|
51331
51409
|
var import_node_crypto16 = require("crypto");
|
|
51332
51410
|
function sampleCpuTimes() {
|
|
51333
51411
|
let idle = 0;
|
|
51334
51412
|
let total = 0;
|
|
51335
|
-
for (const cpu of
|
|
51413
|
+
for (const cpu of os66.cpus()) {
|
|
51336
51414
|
const t2 = cpu.times;
|
|
51337
51415
|
idle += t2.idle;
|
|
51338
51416
|
total += t2.user + t2.nice + t2.sys + t2.idle + t2.irq;
|
|
@@ -51352,8 +51430,8 @@ var MetricsCollector = class {
|
|
|
51352
51430
|
const prev = this.prevCpu;
|
|
51353
51431
|
this.prevCpu = current2;
|
|
51354
51432
|
if (!prev) {
|
|
51355
|
-
const cores =
|
|
51356
|
-
const proxy =
|
|
51433
|
+
const cores = os66.cpus().length || 1;
|
|
51434
|
+
const proxy = os66.loadavg()[0] / cores * 100;
|
|
51357
51435
|
return Math.min(100, Math.max(0, Math.round(proxy)));
|
|
51358
51436
|
}
|
|
51359
51437
|
const idleDelta = current2.idle - prev.idle;
|
|
@@ -51366,8 +51444,8 @@ var MetricsCollector = class {
|
|
|
51366
51444
|
collect() {
|
|
51367
51445
|
return {
|
|
51368
51446
|
cpuPct: this.cpuPct(),
|
|
51369
|
-
ramUsedMb: Math.round((
|
|
51370
|
-
ramTotalMb: Math.round(
|
|
51447
|
+
ramUsedMb: Math.round((os66.totalmem() - os66.freemem()) / 1048576),
|
|
51448
|
+
ramTotalMb: Math.round(os66.totalmem() / 1048576),
|
|
51371
51449
|
latencyMs: this.lastLatencyMs
|
|
51372
51450
|
};
|
|
51373
51451
|
}
|
|
@@ -51379,19 +51457,19 @@ function apiBase() {
|
|
|
51379
51457
|
return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
|
|
51380
51458
|
}
|
|
51381
51459
|
function hostIdentityPath() {
|
|
51382
|
-
return
|
|
51460
|
+
return path106.join(os66.homedir(), ".codeam", "host-agent.json");
|
|
51383
51461
|
}
|
|
51384
51462
|
function collectOsInfo() {
|
|
51385
51463
|
return {
|
|
51386
|
-
distro:
|
|
51387
|
-
arch:
|
|
51388
|
-
kernel:
|
|
51464
|
+
distro: os66.platform(),
|
|
51465
|
+
arch: os66.arch(),
|
|
51466
|
+
kernel: os66.release(),
|
|
51389
51467
|
nodeVersion: process.versions.node
|
|
51390
51468
|
};
|
|
51391
51469
|
}
|
|
51392
51470
|
function loadHostIdentity() {
|
|
51393
51471
|
try {
|
|
51394
|
-
const raw =
|
|
51472
|
+
const raw = fs94.readFileSync(hostIdentityPath(), "utf8");
|
|
51395
51473
|
const parsed = JSON.parse(raw);
|
|
51396
51474
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
|
|
51397
51475
|
const p2 = parsed;
|
|
@@ -51420,8 +51498,8 @@ function ensureControlPollSecret(identity, save = saveHostIdentity) {
|
|
|
51420
51498
|
}
|
|
51421
51499
|
function saveHostIdentity(identity) {
|
|
51422
51500
|
const file = hostIdentityPath();
|
|
51423
|
-
|
|
51424
|
-
|
|
51501
|
+
fs94.mkdirSync(path106.dirname(file), { recursive: true, mode: 448 });
|
|
51502
|
+
fs94.writeFileSync(file, JSON.stringify(identity, null, 2), {
|
|
51425
51503
|
encoding: "utf8",
|
|
51426
51504
|
mode: 384
|
|
51427
51505
|
});
|
|
@@ -51466,7 +51544,7 @@ function isTerminalEnrollError(err) {
|
|
|
51466
51544
|
}
|
|
51467
51545
|
function deleteHostIdentity() {
|
|
51468
51546
|
try {
|
|
51469
|
-
|
|
51547
|
+
fs94.rmSync(hostIdentityPath(), { force: true });
|
|
51470
51548
|
} catch {
|
|
51471
51549
|
}
|
|
51472
51550
|
}
|
|
@@ -51490,7 +51568,7 @@ async function postJson(pathname, body) {
|
|
|
51490
51568
|
function resolveHostLabel(label) {
|
|
51491
51569
|
const explicit = label?.trim();
|
|
51492
51570
|
const envLabel = process.env.CODEAM_HOST_LABEL?.trim();
|
|
51493
|
-
const resolved = explicit || envLabel ||
|
|
51571
|
+
const resolved = explicit || envLabel || os66.hostname();
|
|
51494
51572
|
return resolved.slice(0, 80);
|
|
51495
51573
|
}
|
|
51496
51574
|
async function redeemEnrollToken(token, label) {
|
|
@@ -51694,9 +51772,9 @@ async function host(args2) {
|
|
|
51694
51772
|
|
|
51695
51773
|
// src/commands/host-agent.ts
|
|
51696
51774
|
var import_node_child_process38 = require("child_process");
|
|
51697
|
-
var
|
|
51698
|
-
var
|
|
51699
|
-
var
|
|
51775
|
+
var os72 = __toESM(require("os"));
|
|
51776
|
+
var fs101 = __toESM(require("fs"));
|
|
51777
|
+
var path113 = __toESM(require("path"));
|
|
51700
51778
|
|
|
51701
51779
|
// src/skills/persist-from-payload.ts
|
|
51702
51780
|
function persistOrClearSkillsFromPayload(skills) {
|
|
@@ -51705,13 +51783,13 @@ function persistOrClearSkillsFromPayload(skills) {
|
|
|
51705
51783
|
}
|
|
51706
51784
|
|
|
51707
51785
|
// src/commands/host/session-state.ts
|
|
51708
|
-
var
|
|
51709
|
-
var
|
|
51710
|
-
var
|
|
51786
|
+
var fs95 = __toESM(require("fs"));
|
|
51787
|
+
var os67 = __toESM(require("os"));
|
|
51788
|
+
var path107 = __toESM(require("path"));
|
|
51711
51789
|
function hostSessionStatePath(env = process.env) {
|
|
51712
51790
|
const override = env.CODEAM_HOST_SESSION_STATE_FILE;
|
|
51713
51791
|
if (override && override.trim()) return override.trim();
|
|
51714
|
-
return
|
|
51792
|
+
return path107.join(os67.homedir(), ".codeam", "host-agent-sessions.json");
|
|
51715
51793
|
}
|
|
51716
51794
|
function isRecord5(v) {
|
|
51717
51795
|
if (typeof v !== "object" || v === null) return false;
|
|
@@ -51722,7 +51800,7 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
51722
51800
|
return {
|
|
51723
51801
|
load() {
|
|
51724
51802
|
try {
|
|
51725
|
-
const raw = JSON.parse(
|
|
51803
|
+
const raw = JSON.parse(fs95.readFileSync(file, "utf8"));
|
|
51726
51804
|
return Array.isArray(raw?.sessions) ? raw.sessions.filter(isRecord5) : null;
|
|
51727
51805
|
} catch {
|
|
51728
51806
|
return null;
|
|
@@ -51730,18 +51808,18 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
51730
51808
|
},
|
|
51731
51809
|
save(list) {
|
|
51732
51810
|
try {
|
|
51733
|
-
|
|
51811
|
+
fs95.mkdirSync(path107.dirname(file), { recursive: true, mode: 448 });
|
|
51734
51812
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
51735
|
-
|
|
51813
|
+
fs95.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
|
|
51736
51814
|
mode: 384
|
|
51737
51815
|
});
|
|
51738
|
-
|
|
51816
|
+
fs95.renameSync(tmp, file);
|
|
51739
51817
|
} catch {
|
|
51740
51818
|
}
|
|
51741
51819
|
},
|
|
51742
51820
|
clear() {
|
|
51743
51821
|
try {
|
|
51744
|
-
|
|
51822
|
+
fs95.rmSync(file, { force: true });
|
|
51745
51823
|
} catch {
|
|
51746
51824
|
}
|
|
51747
51825
|
}
|
|
@@ -51764,10 +51842,10 @@ function planSessionResume(records, max) {
|
|
|
51764
51842
|
return { resume: ordered.slice(0, bound), dropped: ordered.slice(bound) };
|
|
51765
51843
|
}
|
|
51766
51844
|
function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
51767
|
-
const target =
|
|
51845
|
+
const target = path107.resolve(cwd);
|
|
51768
51846
|
const reconnectable = (s) => !!s.pluginId && !!s.pollSecret && !!s.agent;
|
|
51769
51847
|
const matches = sessions3.filter(
|
|
51770
|
-
(s) => !!s.cwd &&
|
|
51848
|
+
(s) => !!s.cwd && path107.resolve(s.cwd) === target && reconnectable(s)
|
|
51771
51849
|
);
|
|
51772
51850
|
if (matches.length > 0) {
|
|
51773
51851
|
matches.sort((a, b) => b.pairedAt - a.pairedAt);
|
|
@@ -51779,11 +51857,11 @@ function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
|
51779
51857
|
|
|
51780
51858
|
// src/commands/host/git-tooling.ts
|
|
51781
51859
|
var import_node_child_process32 = require("child_process");
|
|
51782
|
-
var
|
|
51783
|
-
var
|
|
51784
|
-
var
|
|
51860
|
+
var fs96 = __toESM(require("fs"));
|
|
51861
|
+
var os68 = __toESM(require("os"));
|
|
51862
|
+
var path108 = __toESM(require("path"));
|
|
51785
51863
|
function codeamBinDir() {
|
|
51786
|
-
return process.env.CODEAM_BIN_DIR ??
|
|
51864
|
+
return process.env.CODEAM_BIN_DIR ?? path108.join(os68.homedir(), ".codeam", "bin");
|
|
51787
51865
|
}
|
|
51788
51866
|
var FALLBACK_GH_VERSION = "2.62.0";
|
|
51789
51867
|
var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
|
|
@@ -51815,7 +51893,7 @@ async function download(url2, dest) {
|
|
|
51815
51893
|
const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
|
|
51816
51894
|
if (!res.ok || !res.body) return false;
|
|
51817
51895
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
51818
|
-
|
|
51896
|
+
fs96.writeFileSync(dest, buf);
|
|
51819
51897
|
return true;
|
|
51820
51898
|
} catch {
|
|
51821
51899
|
return false;
|
|
@@ -51838,8 +51916,8 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
51838
51916
|
const version3 = await resolveVersionFn(token);
|
|
51839
51917
|
const asset = `gh_${version3}_${osToken}_${arch2}`;
|
|
51840
51918
|
const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
|
|
51841
|
-
const tmpRoot =
|
|
51842
|
-
const archive =
|
|
51919
|
+
const tmpRoot = fs96.mkdtempSync(path108.join(os68.tmpdir(), "codeam-gh-"));
|
|
51920
|
+
const archive = path108.join(tmpRoot, `${asset}.${ext}`);
|
|
51843
51921
|
if (!await downloadFn(url2, archive)) {
|
|
51844
51922
|
log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
|
|
51845
51923
|
return null;
|
|
@@ -51849,16 +51927,16 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
51849
51927
|
log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
|
|
51850
51928
|
return null;
|
|
51851
51929
|
}
|
|
51852
|
-
const extractedBin =
|
|
51853
|
-
if (!
|
|
51930
|
+
const extractedBin = path108.join(tmpRoot, asset, "bin", binaryName);
|
|
51931
|
+
if (!fs96.existsSync(extractedBin)) {
|
|
51854
51932
|
log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
|
|
51855
51933
|
return null;
|
|
51856
51934
|
}
|
|
51857
51935
|
const binDir = codeamBinDir();
|
|
51858
|
-
|
|
51859
|
-
const target =
|
|
51860
|
-
|
|
51861
|
-
|
|
51936
|
+
fs96.mkdirSync(binDir, { recursive: true });
|
|
51937
|
+
const target = path108.join(binDir, binaryName);
|
|
51938
|
+
fs96.copyFileSync(extractedBin, target);
|
|
51939
|
+
fs96.chmodSync(target, 493);
|
|
51862
51940
|
log.info("host-agent", `gh installed to ${target} (v${version3})`);
|
|
51863
51941
|
return target;
|
|
51864
51942
|
} catch (e) {
|
|
@@ -51895,19 +51973,19 @@ async function ensureGhAuth(runner, ghCmd, token) {
|
|
|
51895
51973
|
}
|
|
51896
51974
|
function ghConfigDir() {
|
|
51897
51975
|
if (process.env.GH_CONFIG_DIR) return process.env.GH_CONFIG_DIR;
|
|
51898
|
-
if (process.env.XDG_CONFIG_HOME) return
|
|
51976
|
+
if (process.env.XDG_CONFIG_HOME) return path108.join(process.env.XDG_CONFIG_HOME, "gh");
|
|
51899
51977
|
if (process.platform === "win32" && process.env.APPDATA) {
|
|
51900
|
-
return
|
|
51978
|
+
return path108.join(process.env.APPDATA, "GitHub CLI");
|
|
51901
51979
|
}
|
|
51902
|
-
return
|
|
51980
|
+
return path108.join(os68.homedir(), ".config", "gh");
|
|
51903
51981
|
}
|
|
51904
51982
|
function writeGhHostsToken(token) {
|
|
51905
51983
|
try {
|
|
51906
51984
|
const dir = ghConfigDir();
|
|
51907
|
-
const file =
|
|
51908
|
-
if (
|
|
51909
|
-
|
|
51910
|
-
|
|
51985
|
+
const file = path108.join(dir, "hosts.yml");
|
|
51986
|
+
if (fs96.existsSync(file)) return false;
|
|
51987
|
+
fs96.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
51988
|
+
fs96.writeFileSync(
|
|
51911
51989
|
file,
|
|
51912
51990
|
`github.com:
|
|
51913
51991
|
oauth_token: ${token}
|
|
@@ -51950,8 +52028,8 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
51950
52028
|
const version3 = await resolveLatestGlabVersion();
|
|
51951
52029
|
const asset = `glab_${version3}_${osToken}_${arch2}`;
|
|
51952
52030
|
const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
|
|
51953
|
-
const tmpRoot =
|
|
51954
|
-
const archive =
|
|
52031
|
+
const tmpRoot = fs96.mkdtempSync(path108.join(os68.tmpdir(), "codeam-glab-"));
|
|
52032
|
+
const archive = path108.join(tmpRoot, `${asset}.${ext}`);
|
|
51955
52033
|
if (!await downloadFn(url2, archive)) {
|
|
51956
52034
|
log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
|
|
51957
52035
|
return null;
|
|
@@ -51962,20 +52040,20 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
51962
52040
|
return null;
|
|
51963
52041
|
}
|
|
51964
52042
|
const candidates = [
|
|
51965
|
-
|
|
51966
|
-
|
|
51967
|
-
|
|
52043
|
+
path108.join(tmpRoot, "bin", binaryName),
|
|
52044
|
+
path108.join(tmpRoot, asset, "bin", binaryName),
|
|
52045
|
+
path108.join(tmpRoot, binaryName)
|
|
51968
52046
|
];
|
|
51969
|
-
const extractedBin = candidates.find((c2) =>
|
|
52047
|
+
const extractedBin = candidates.find((c2) => fs96.existsSync(c2));
|
|
51970
52048
|
if (!extractedBin) {
|
|
51971
52049
|
log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
|
|
51972
52050
|
return null;
|
|
51973
52051
|
}
|
|
51974
52052
|
const binDir = codeamBinDir();
|
|
51975
|
-
|
|
51976
|
-
const target =
|
|
51977
|
-
|
|
51978
|
-
|
|
52053
|
+
fs96.mkdirSync(binDir, { recursive: true });
|
|
52054
|
+
const target = path108.join(binDir, binaryName);
|
|
52055
|
+
fs96.copyFileSync(extractedBin, target);
|
|
52056
|
+
fs96.chmodSync(target, 493);
|
|
51979
52057
|
log.info("host-agent", `glab installed to ${target} (v${version3})`);
|
|
51980
52058
|
return target;
|
|
51981
52059
|
} catch (e) {
|
|
@@ -52054,14 +52132,14 @@ var defaultGitToolingRunner = {
|
|
|
52054
52132
|
};
|
|
52055
52133
|
|
|
52056
52134
|
// src/lib/cli-versions.ts
|
|
52135
|
+
var fs98 = __toESM(require("fs"));
|
|
52136
|
+
var os70 = __toESM(require("os"));
|
|
52137
|
+
var path110 = __toESM(require("path"));
|
|
52138
|
+
|
|
52139
|
+
// src/lib/updateNotifier.ts
|
|
52057
52140
|
var fs97 = __toESM(require("fs"));
|
|
52058
52141
|
var os69 = __toESM(require("os"));
|
|
52059
52142
|
var path109 = __toESM(require("path"));
|
|
52060
|
-
|
|
52061
|
-
// src/lib/updateNotifier.ts
|
|
52062
|
-
var fs96 = __toESM(require("fs"));
|
|
52063
|
-
var os68 = __toESM(require("os"));
|
|
52064
|
-
var path108 = __toESM(require("path"));
|
|
52065
52143
|
var https8 = __toESM(require("https"));
|
|
52066
52144
|
var import_node_child_process33 = require("child_process");
|
|
52067
52145
|
var import_picocolors12 = __toESM(require("picocolors"));
|
|
@@ -52070,12 +52148,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
|
|
|
52070
52148
|
var TTL_MS = 24 * 60 * 60 * 1e3;
|
|
52071
52149
|
var REQUEST_TIMEOUT_MS = 1500;
|
|
52072
52150
|
function cachePath() {
|
|
52073
|
-
const dir =
|
|
52074
|
-
return
|
|
52151
|
+
const dir = path109.join(os69.homedir(), ".codeam");
|
|
52152
|
+
return path109.join(dir, "update-check.json");
|
|
52075
52153
|
}
|
|
52076
52154
|
function readCache() {
|
|
52077
52155
|
try {
|
|
52078
|
-
const raw =
|
|
52156
|
+
const raw = fs97.readFileSync(cachePath(), "utf8");
|
|
52079
52157
|
const parsed = JSON.parse(raw);
|
|
52080
52158
|
if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
|
|
52081
52159
|
return parsed;
|
|
@@ -52086,10 +52164,10 @@ function readCache() {
|
|
|
52086
52164
|
function writeCache(cache) {
|
|
52087
52165
|
try {
|
|
52088
52166
|
const file = cachePath();
|
|
52089
|
-
|
|
52167
|
+
fs97.mkdirSync(path109.dirname(file), { recursive: true });
|
|
52090
52168
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
52091
|
-
|
|
52092
|
-
|
|
52169
|
+
fs97.writeFileSync(tmp, JSON.stringify(cache));
|
|
52170
|
+
fs97.renameSync(tmp, file);
|
|
52093
52171
|
} catch {
|
|
52094
52172
|
}
|
|
52095
52173
|
}
|
|
@@ -52163,8 +52241,8 @@ function isLinkedInstall() {
|
|
|
52163
52241
|
timeout: 2e3
|
|
52164
52242
|
}).trim();
|
|
52165
52243
|
if (!root) return false;
|
|
52166
|
-
const pkgPath =
|
|
52167
|
-
return
|
|
52244
|
+
const pkgPath = path109.join(root, PKG_NAME);
|
|
52245
|
+
return fs97.lstatSync(pkgPath).isSymbolicLink();
|
|
52168
52246
|
} catch {
|
|
52169
52247
|
return false;
|
|
52170
52248
|
}
|
|
@@ -52200,7 +52278,7 @@ function maybeAutoUpdate(currentVersion, latest) {
|
|
|
52200
52278
|
return;
|
|
52201
52279
|
}
|
|
52202
52280
|
try {
|
|
52203
|
-
|
|
52281
|
+
fs97.unlinkSync(cachePath());
|
|
52204
52282
|
} catch {
|
|
52205
52283
|
}
|
|
52206
52284
|
process.stderr.write(` ${import_picocolors12.default.green("\u2713")} Updated. Resuming session...
|
|
@@ -52216,7 +52294,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
52216
52294
|
if (process.env.NODE_ENV === "test") return;
|
|
52217
52295
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
52218
52296
|
if (process.env.CI) return;
|
|
52219
|
-
const current2 = true ? "2.76.
|
|
52297
|
+
const current2 = true ? "2.76.44" : null;
|
|
52220
52298
|
if (!current2) return;
|
|
52221
52299
|
const cache = readCache();
|
|
52222
52300
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -52233,7 +52311,7 @@ function checkForUpdates() {
|
|
|
52233
52311
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
52234
52312
|
if (process.env.CI) return;
|
|
52235
52313
|
if (!process.stdout.isTTY) return;
|
|
52236
|
-
const current2 = true ? "2.76.
|
|
52314
|
+
const current2 = true ? "2.76.44" : null;
|
|
52237
52315
|
if (!current2) return;
|
|
52238
52316
|
const cache = readCache();
|
|
52239
52317
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -52256,10 +52334,10 @@ function versionedModeSupported(platform3 = process.platform) {
|
|
|
52256
52334
|
return platform3 !== "win32";
|
|
52257
52335
|
}
|
|
52258
52336
|
function cliVersionsRoot(env = process.env) {
|
|
52259
|
-
return env.CODEAM_CLI_VERSIONS_DIR ||
|
|
52337
|
+
return env.CODEAM_CLI_VERSIONS_DIR || path110.join(os70.homedir(), ".codeam", "cli");
|
|
52260
52338
|
}
|
|
52261
52339
|
function packageDirOf(versionDir) {
|
|
52262
|
-
return
|
|
52340
|
+
return path110.join(versionDir, "node_modules", CLI_PKG);
|
|
52263
52341
|
}
|
|
52264
52342
|
function isRecord6(v) {
|
|
52265
52343
|
return typeof v === "object" && v !== null;
|
|
@@ -52267,7 +52345,7 @@ function isRecord6(v) {
|
|
|
52267
52345
|
function readPkg2(versionDir) {
|
|
52268
52346
|
try {
|
|
52269
52347
|
const raw = JSON.parse(
|
|
52270
|
-
|
|
52348
|
+
fs98.readFileSync(path110.join(packageDirOf(versionDir), "package.json"), "utf8")
|
|
52271
52349
|
);
|
|
52272
52350
|
return isRecord6(raw) ? raw : null;
|
|
52273
52351
|
} catch {
|
|
@@ -52280,15 +52358,15 @@ function entryOf(versionDir) {
|
|
|
52280
52358
|
const bin = pkg.bin;
|
|
52281
52359
|
const named = isRecord6(bin) ? bin.codeam : void 0;
|
|
52282
52360
|
const rel = typeof bin === "string" ? bin : typeof named === "string" ? named : "dist/index.js";
|
|
52283
|
-
const entry =
|
|
52284
|
-
return
|
|
52361
|
+
const entry = path110.join(packageDirOf(versionDir), rel);
|
|
52362
|
+
return fs98.existsSync(entry) ? entry : null;
|
|
52285
52363
|
}
|
|
52286
52364
|
function launcherOf(versionDir) {
|
|
52287
52365
|
const entry = entryOf(versionDir);
|
|
52288
52366
|
if (!entry) return null;
|
|
52289
|
-
const bin =
|
|
52367
|
+
const bin = path110.join(versionDir, "node_modules", ".bin", "codeam");
|
|
52290
52368
|
try {
|
|
52291
|
-
return
|
|
52369
|
+
return fs98.realpathSync(bin) === fs98.realpathSync(entry) ? bin : entry;
|
|
52292
52370
|
} catch {
|
|
52293
52371
|
return entry;
|
|
52294
52372
|
}
|
|
@@ -52301,16 +52379,16 @@ var BAD_MARKER_TTL_MS = 24 * 60 * 6e4;
|
|
|
52301
52379
|
var PRE_READY_WINDOW_MS = 60 * 6e4;
|
|
52302
52380
|
function isBad(versionDir, now = Date.now()) {
|
|
52303
52381
|
try {
|
|
52304
|
-
return now -
|
|
52382
|
+
return now - fs98.statSync(path110.join(versionDir, ".bad")).mtimeMs < BAD_MARKER_TTL_MS;
|
|
52305
52383
|
} catch {
|
|
52306
52384
|
return false;
|
|
52307
52385
|
}
|
|
52308
52386
|
}
|
|
52309
52387
|
function recordPreReadyFailure(versionDir, now = Date.now()) {
|
|
52310
|
-
const file =
|
|
52388
|
+
const file = path110.join(versionDir, ".prefail");
|
|
52311
52389
|
let count = 0;
|
|
52312
52390
|
try {
|
|
52313
|
-
const [n, at3] =
|
|
52391
|
+
const [n, at3] = fs98.readFileSync(file, "utf8").trim().split(" ").map(Number);
|
|
52314
52392
|
if (Number.isFinite(n) && Number.isFinite(at3) && now - at3 < PRE_READY_WINDOW_MS) {
|
|
52315
52393
|
count = n;
|
|
52316
52394
|
}
|
|
@@ -52318,45 +52396,45 @@ function recordPreReadyFailure(versionDir, now = Date.now()) {
|
|
|
52318
52396
|
}
|
|
52319
52397
|
count += 1;
|
|
52320
52398
|
try {
|
|
52321
|
-
|
|
52399
|
+
fs98.writeFileSync(file, `${count} ${now}`);
|
|
52322
52400
|
} catch {
|
|
52323
52401
|
}
|
|
52324
52402
|
return count;
|
|
52325
52403
|
}
|
|
52326
52404
|
function clearPreReadyFailures(versionDir) {
|
|
52327
|
-
|
|
52405
|
+
fs98.rmSync(path110.join(versionDir, ".prefail"), { force: true });
|
|
52328
52406
|
}
|
|
52329
52407
|
function markBad(versionDir, reason) {
|
|
52330
52408
|
try {
|
|
52331
|
-
|
|
52409
|
+
fs98.writeFileSync(path110.join(versionDir, ".bad"), `${(/* @__PURE__ */ new Date()).toISOString()} ${reason}
|
|
52332
52410
|
`);
|
|
52333
52411
|
} catch {
|
|
52334
52412
|
}
|
|
52335
52413
|
}
|
|
52336
52414
|
function pointerTarget(root, name) {
|
|
52337
52415
|
try {
|
|
52338
|
-
return
|
|
52416
|
+
return fs98.realpathSync(path110.join(root, name));
|
|
52339
52417
|
} catch {
|
|
52340
52418
|
return null;
|
|
52341
52419
|
}
|
|
52342
52420
|
}
|
|
52343
52421
|
function atomicPoint(root, name, targetDir) {
|
|
52344
|
-
const realRoot =
|
|
52345
|
-
const tmp =
|
|
52346
|
-
|
|
52422
|
+
const realRoot = fs98.realpathSync(root);
|
|
52423
|
+
const tmp = path110.join(realRoot, `.${name}.tmp-${process.pid}-${Date.now()}`);
|
|
52424
|
+
fs98.symlinkSync(path110.relative(realRoot, fs98.realpathSync(targetDir)), tmp, "dir");
|
|
52347
52425
|
try {
|
|
52348
|
-
|
|
52426
|
+
fs98.renameSync(tmp, path110.join(realRoot, name));
|
|
52349
52427
|
} catch (err) {
|
|
52350
|
-
|
|
52428
|
+
fs98.rmSync(tmp, { force: true });
|
|
52351
52429
|
throw err;
|
|
52352
52430
|
}
|
|
52353
52431
|
}
|
|
52354
52432
|
function samePath(a, b) {
|
|
52355
52433
|
const canon = (p2) => {
|
|
52356
52434
|
try {
|
|
52357
|
-
return
|
|
52435
|
+
return fs98.realpathSync(p2);
|
|
52358
52436
|
} catch {
|
|
52359
|
-
return
|
|
52437
|
+
return path110.resolve(p2);
|
|
52360
52438
|
}
|
|
52361
52439
|
};
|
|
52362
52440
|
return canon(a) === canon(b);
|
|
@@ -52391,15 +52469,15 @@ function versionDirContaining(root, file) {
|
|
|
52391
52469
|
let real;
|
|
52392
52470
|
let realRoot;
|
|
52393
52471
|
try {
|
|
52394
|
-
real =
|
|
52395
|
-
realRoot =
|
|
52472
|
+
real = fs98.realpathSync(file);
|
|
52473
|
+
realRoot = fs98.realpathSync(root);
|
|
52396
52474
|
} catch {
|
|
52397
52475
|
return null;
|
|
52398
52476
|
}
|
|
52399
|
-
const rel =
|
|
52400
|
-
if (rel.startsWith("..") ||
|
|
52401
|
-
const first = rel.split(
|
|
52402
|
-
return first && SEMVER_DIR.test(first) ?
|
|
52477
|
+
const rel = path110.relative(realRoot, real);
|
|
52478
|
+
if (rel.startsWith("..") || path110.isAbsolute(rel)) return null;
|
|
52479
|
+
const first = rel.split(path110.sep)[0];
|
|
52480
|
+
return first && SEMVER_DIR.test(first) ? path110.join(realRoot, first) : null;
|
|
52403
52481
|
}
|
|
52404
52482
|
function pidAlive3(pid) {
|
|
52405
52483
|
try {
|
|
@@ -52412,9 +52490,9 @@ function pidAlive3(pid) {
|
|
|
52412
52490
|
var CLK_TCK = 100;
|
|
52413
52491
|
function processStartMs(pid) {
|
|
52414
52492
|
try {
|
|
52415
|
-
const stat3 =
|
|
52493
|
+
const stat3 = fs98.readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
52416
52494
|
const ticks = Number(stat3.slice(stat3.lastIndexOf(")") + 2).split(" ")[19]);
|
|
52417
|
-
const btime = /^btime (\d+)$/m.exec(
|
|
52495
|
+
const btime = /^btime (\d+)$/m.exec(fs98.readFileSync("/proc/stat", "utf8"))?.[1];
|
|
52418
52496
|
if (!Number.isFinite(ticks) || !btime) return null;
|
|
52419
52497
|
return Number(btime) * 1e3 + ticks * 1e3 / CLK_TCK;
|
|
52420
52498
|
} catch {
|
|
@@ -52423,10 +52501,10 @@ function processStartMs(pid) {
|
|
|
52423
52501
|
}
|
|
52424
52502
|
var PID_REUSE_SLACK_MS = 2e3;
|
|
52425
52503
|
function livePids(versionDir) {
|
|
52426
|
-
const dir =
|
|
52504
|
+
const dir = path110.join(versionDir, ".pids");
|
|
52427
52505
|
let names;
|
|
52428
52506
|
try {
|
|
52429
|
-
names =
|
|
52507
|
+
names = fs98.readdirSync(dir);
|
|
52430
52508
|
} catch {
|
|
52431
52509
|
return [];
|
|
52432
52510
|
}
|
|
@@ -52435,7 +52513,7 @@ function livePids(versionDir) {
|
|
|
52435
52513
|
const started = processStartMs(pid);
|
|
52436
52514
|
if (started === null) return true;
|
|
52437
52515
|
try {
|
|
52438
|
-
return started <=
|
|
52516
|
+
return started <= fs98.statSync(path110.join(dir, String(pid))).mtimeMs + PID_REUSE_SLACK_MS;
|
|
52439
52517
|
} catch {
|
|
52440
52518
|
return true;
|
|
52441
52519
|
}
|
|
@@ -52444,11 +52522,11 @@ function livePids(versionDir) {
|
|
|
52444
52522
|
function registerRunningVersion(root = cliVersionsRoot(), entry = process.argv[1]) {
|
|
52445
52523
|
const dir = versionDirContaining(root, entry);
|
|
52446
52524
|
if (!dir) return;
|
|
52447
|
-
const file =
|
|
52525
|
+
const file = path110.join(dir, ".pids", String(process.pid));
|
|
52448
52526
|
try {
|
|
52449
|
-
|
|
52450
|
-
|
|
52451
|
-
process.once("exit", () =>
|
|
52527
|
+
fs98.mkdirSync(path110.dirname(file), { recursive: true });
|
|
52528
|
+
fs98.writeFileSync(file, "");
|
|
52529
|
+
process.once("exit", () => fs98.rmSync(file, { force: true }));
|
|
52452
52530
|
} catch {
|
|
52453
52531
|
}
|
|
52454
52532
|
}
|
|
@@ -52456,7 +52534,7 @@ function gcVersions(root) {
|
|
|
52456
52534
|
const removed = [];
|
|
52457
52535
|
let names;
|
|
52458
52536
|
try {
|
|
52459
|
-
names =
|
|
52537
|
+
names = fs98.readdirSync(root).filter((n) => SEMVER_DIR.test(n));
|
|
52460
52538
|
} catch {
|
|
52461
52539
|
return removed;
|
|
52462
52540
|
}
|
|
@@ -52464,13 +52542,13 @@ function gcVersions(root) {
|
|
|
52464
52542
|
[...names].sort((a, b) => compareSemver(b, a)).slice(0, GC_KEEP_NEWEST)
|
|
52465
52543
|
);
|
|
52466
52544
|
for (const p2 of [pointerTarget(root, "current"), pointerTarget(root, "previous")]) {
|
|
52467
|
-
if (p2) keep.add(
|
|
52545
|
+
if (p2) keep.add(path110.basename(p2));
|
|
52468
52546
|
}
|
|
52469
52547
|
for (const name of names) {
|
|
52470
|
-
const dir =
|
|
52548
|
+
const dir = path110.join(root, name);
|
|
52471
52549
|
if (keep.has(name) || livePids(dir).length > 0) continue;
|
|
52472
52550
|
try {
|
|
52473
|
-
|
|
52551
|
+
fs98.rmSync(dir, { recursive: true, force: true });
|
|
52474
52552
|
removed.push(name);
|
|
52475
52553
|
} catch {
|
|
52476
52554
|
}
|
|
@@ -52478,25 +52556,25 @@ function gcVersions(root) {
|
|
|
52478
52556
|
return removed;
|
|
52479
52557
|
}
|
|
52480
52558
|
function acquireInstallLock(root) {
|
|
52481
|
-
const lock =
|
|
52559
|
+
const lock = path110.join(root, ".install.lock");
|
|
52482
52560
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
52483
52561
|
try {
|
|
52484
|
-
const fd =
|
|
52485
|
-
|
|
52486
|
-
|
|
52487
|
-
return () =>
|
|
52562
|
+
const fd = fs98.openSync(lock, "wx");
|
|
52563
|
+
fs98.writeSync(fd, String(process.pid));
|
|
52564
|
+
fs98.closeSync(fd);
|
|
52565
|
+
return () => fs98.rmSync(lock, { force: true });
|
|
52488
52566
|
} catch (err) {
|
|
52489
52567
|
if (err.code !== "EEXIST") return null;
|
|
52490
52568
|
let stale = false;
|
|
52491
52569
|
try {
|
|
52492
|
-
const owner = Number(
|
|
52493
|
-
const age = Date.now() -
|
|
52570
|
+
const owner = Number(fs98.readFileSync(lock, "utf8"));
|
|
52571
|
+
const age = Date.now() - fs98.statSync(lock).mtimeMs;
|
|
52494
52572
|
stale = !Number.isInteger(owner) || !pidAlive3(owner) || age > LOCK_STALE_MS;
|
|
52495
52573
|
} catch {
|
|
52496
52574
|
stale = true;
|
|
52497
52575
|
}
|
|
52498
52576
|
if (!stale) return null;
|
|
52499
|
-
|
|
52577
|
+
fs98.rmSync(lock, { force: true });
|
|
52500
52578
|
}
|
|
52501
52579
|
}
|
|
52502
52580
|
return null;
|
|
@@ -52504,9 +52582,9 @@ function acquireInstallLock(root) {
|
|
|
52504
52582
|
|
|
52505
52583
|
// src/commands/host/host-launch.ts
|
|
52506
52584
|
var import_node_child_process35 = require("child_process");
|
|
52507
|
-
var
|
|
52508
|
-
var
|
|
52509
|
-
var
|
|
52585
|
+
var fs100 = __toESM(require("fs"));
|
|
52586
|
+
var os71 = __toESM(require("os"));
|
|
52587
|
+
var path112 = __toESM(require("path"));
|
|
52510
52588
|
|
|
52511
52589
|
// src/exit-codes.ts
|
|
52512
52590
|
var EXIT_OK = 0;
|
|
@@ -52528,8 +52606,8 @@ var EXIT_CODE_NAMES = {
|
|
|
52528
52606
|
|
|
52529
52607
|
// src/commands/host/self-update.ts
|
|
52530
52608
|
var import_node_child_process34 = require("child_process");
|
|
52531
|
-
var
|
|
52532
|
-
var
|
|
52609
|
+
var fs99 = __toESM(require("fs"));
|
|
52610
|
+
var path111 = __toESM(require("path"));
|
|
52533
52611
|
var SELF_UPDATE_PKG = "codeam-cli";
|
|
52534
52612
|
var SELF_UPDATE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
52535
52613
|
var SELF_UPDATE_STARTUP_DELAY_MS = 5e3;
|
|
@@ -52539,7 +52617,7 @@ var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
|
|
|
52539
52617
|
var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
52540
52618
|
var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
|
|
52541
52619
|
function currentCliVersion() {
|
|
52542
|
-
return true ? "2.76.
|
|
52620
|
+
return true ? "2.76.44" : null;
|
|
52543
52621
|
}
|
|
52544
52622
|
async function installedVersion(deps) {
|
|
52545
52623
|
const ls = await deps.run(
|
|
@@ -52655,9 +52733,9 @@ function collectOldVersions(root) {
|
|
|
52655
52733
|
var VERIFY_TIMEOUT_MS = 3e4;
|
|
52656
52734
|
async function installVersioned(deps, root, latest, running2) {
|
|
52657
52735
|
const node = deps.nodePath ?? process.execPath;
|
|
52658
|
-
const target =
|
|
52736
|
+
const target = path111.join(root, latest);
|
|
52659
52737
|
try {
|
|
52660
|
-
|
|
52738
|
+
fs99.mkdirSync(root, { recursive: true });
|
|
52661
52739
|
} catch {
|
|
52662
52740
|
return { status: "skipped" };
|
|
52663
52741
|
}
|
|
@@ -52681,7 +52759,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
52681
52759
|
}
|
|
52682
52760
|
const reusable = entryOf(target) && versionOf(target) === latest;
|
|
52683
52761
|
if (!reusable) {
|
|
52684
|
-
|
|
52762
|
+
fs99.rmSync(target, { recursive: true, force: true });
|
|
52685
52763
|
const install = await deps.run(
|
|
52686
52764
|
"npm",
|
|
52687
52765
|
[
|
|
@@ -52696,7 +52774,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
52696
52774
|
SELF_UPDATE_INSTALL_TIMEOUT_MS
|
|
52697
52775
|
);
|
|
52698
52776
|
if (install.code !== 0) {
|
|
52699
|
-
|
|
52777
|
+
fs99.rmSync(target, { recursive: true, force: true });
|
|
52700
52778
|
log.warn(
|
|
52701
52779
|
"host-agent",
|
|
52702
52780
|
`self-update: versioned install exited ${String(install.code)} \u2014 staying on ${running2}: ` + install.stderr.slice(-300)
|
|
@@ -52707,7 +52785,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
52707
52785
|
const entry = entryOf(target);
|
|
52708
52786
|
const check = entry ? await deps.run(node, [entry, "--version"], VERIFY_TIMEOUT_MS) : { code: null, stdout: "", stderr: "no entry point" };
|
|
52709
52787
|
if (check.code !== 0 || !check.stdout.includes(latest)) {
|
|
52710
|
-
|
|
52788
|
+
fs99.rmSync(target, { recursive: true, force: true });
|
|
52711
52789
|
log.warn(
|
|
52712
52790
|
"host-agent",
|
|
52713
52791
|
`self-update: ${latest} failed verification (exit ${String(check.code)}: ${(check.stdout + check.stderr).trim().slice(-200)}) \u2014 staying on ${running2}`
|
|
@@ -52723,7 +52801,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
52723
52801
|
return { status: "updated", version: latest };
|
|
52724
52802
|
} catch (err) {
|
|
52725
52803
|
const cur = pointerTarget(root, "current");
|
|
52726
|
-
if (!cur ||
|
|
52804
|
+
if (!cur || path111.basename(cur) !== latest) fs99.rmSync(target, { recursive: true, force: true });
|
|
52727
52805
|
log.warn(
|
|
52728
52806
|
"host-agent",
|
|
52729
52807
|
`self-update: versioned install failed: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -52762,7 +52840,7 @@ function signalHostReady(send = process.send?.bind(process)) {
|
|
|
52762
52840
|
}
|
|
52763
52841
|
function defaultDeps() {
|
|
52764
52842
|
return {
|
|
52765
|
-
ownVersion: true ? "2.76.
|
|
52843
|
+
ownVersion: true ? "2.76.44" : null,
|
|
52766
52844
|
root: cliVersionsRoot(),
|
|
52767
52845
|
args: process.argv.slice(3),
|
|
52768
52846
|
execPath: process.execPath,
|
|
@@ -52859,13 +52937,13 @@ function needsSelfRelaunch(env = process.env, pid = process.pid, ctx = {}) {
|
|
|
52859
52937
|
}
|
|
52860
52938
|
function readPid1Cmdline() {
|
|
52861
52939
|
try {
|
|
52862
|
-
return
|
|
52940
|
+
return fs100.readFileSync("/proc/1/cmdline", "utf8").split("\0").filter(Boolean);
|
|
52863
52941
|
} catch {
|
|
52864
52942
|
return [];
|
|
52865
52943
|
}
|
|
52866
52944
|
}
|
|
52867
52945
|
function isOurTiniEntrypoint(argv) {
|
|
52868
|
-
return argv.some((a) =>
|
|
52946
|
+
return argv.some((a) => path112.basename(a) === "tini") && argv.includes("host-agent");
|
|
52869
52947
|
}
|
|
52870
52948
|
function relaunchArgv(execPath, argv) {
|
|
52871
52949
|
return ["-c", 'sleep 2; exec "$0" "$@"', execPath, ...argv.slice(1)];
|
|
@@ -52907,7 +52985,7 @@ function defaultRestartForUpdate(version3, supervised, io = {}) {
|
|
|
52907
52985
|
}
|
|
52908
52986
|
exit(0);
|
|
52909
52987
|
}
|
|
52910
|
-
function isContainerEnvironment(existsSyncFn =
|
|
52988
|
+
function isContainerEnvironment(existsSyncFn = fs100.existsSync, readFileSyncFn = (p2) => fs100.readFileSync(p2, "utf8")) {
|
|
52911
52989
|
try {
|
|
52912
52990
|
if (existsSyncFn("/.dockerenv")) return true;
|
|
52913
52991
|
} catch {
|
|
@@ -52919,16 +52997,16 @@ function isContainerEnvironment(existsSyncFn = fs99.existsSync, readFileSyncFn =
|
|
|
52919
52997
|
}
|
|
52920
52998
|
return false;
|
|
52921
52999
|
}
|
|
52922
|
-
function hostAgentPidFile(home =
|
|
52923
|
-
return
|
|
53000
|
+
function hostAgentPidFile(home = os71.homedir()) {
|
|
53001
|
+
return path112.join(home, ".codeam", "host-agent.pid");
|
|
52924
53002
|
}
|
|
52925
53003
|
function writeHostAgentPidFile(file = hostAgentPidFile(), pid = process.pid) {
|
|
52926
53004
|
try {
|
|
52927
|
-
|
|
52928
|
-
|
|
53005
|
+
fs100.mkdirSync(path112.dirname(file), { recursive: true });
|
|
53006
|
+
fs100.writeFileSync(file, String(pid));
|
|
52929
53007
|
process.once("exit", () => {
|
|
52930
53008
|
try {
|
|
52931
|
-
if (
|
|
53009
|
+
if (fs100.readFileSync(file, "utf8").trim() === String(pid)) fs100.rmSync(file, { force: true });
|
|
52932
53010
|
} catch {
|
|
52933
53011
|
}
|
|
52934
53012
|
});
|
|
@@ -53780,13 +53858,13 @@ var HostAgentSupervisor = class {
|
|
|
53780
53858
|
const relay = this.relay;
|
|
53781
53859
|
if (!relay) return;
|
|
53782
53860
|
const raw = cmd.payload?.path;
|
|
53783
|
-
const target = typeof raw === "string" && raw.trim() ?
|
|
53861
|
+
const target = typeof raw === "string" && raw.trim() ? path113.resolve(raw.trim()) : os72.homedir();
|
|
53784
53862
|
try {
|
|
53785
|
-
const dirents = await
|
|
53863
|
+
const dirents = await fs101.promises.readdir(target, { withFileTypes: true });
|
|
53786
53864
|
const entries2 = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
|
|
53787
53865
|
(a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
|
|
53788
53866
|
);
|
|
53789
|
-
const parent =
|
|
53867
|
+
const parent = path113.dirname(target);
|
|
53790
53868
|
await relay.sendResult(cmd.id, "completed", {
|
|
53791
53869
|
path: target,
|
|
53792
53870
|
// null at the filesystem root so the UI can hide the ".." affordance.
|
|
@@ -54264,14 +54342,14 @@ var HostAgentSupervisor = class {
|
|
|
54264
54342
|
}),
|
|
54265
54343
|
CODEAM_AUTO_TOKEN: payload.autoPairToken
|
|
54266
54344
|
};
|
|
54267
|
-
const houseConfigDir =
|
|
54268
|
-
|
|
54345
|
+
const houseConfigDir = path113.join(
|
|
54346
|
+
os72.homedir(),
|
|
54269
54347
|
".codeam",
|
|
54270
54348
|
"house-claude",
|
|
54271
54349
|
payload.deployId
|
|
54272
54350
|
);
|
|
54273
54351
|
try {
|
|
54274
|
-
|
|
54352
|
+
fs101.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
|
|
54275
54353
|
} catch {
|
|
54276
54354
|
}
|
|
54277
54355
|
childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
|
|
@@ -54300,7 +54378,7 @@ var HostAgentSupervisor = class {
|
|
|
54300
54378
|
report("installing", "installing agent CLI");
|
|
54301
54379
|
await this.runAgentInstall(payload.agentInstallScript);
|
|
54302
54380
|
}
|
|
54303
|
-
const home = process.env.HOME ||
|
|
54381
|
+
const home = process.env.HOME || os72.homedir();
|
|
54304
54382
|
childEnv.PATH = `${home}/.local/bin:${process.env.PATH ?? ""}`;
|
|
54305
54383
|
if (payload.cloneToken) {
|
|
54306
54384
|
try {
|
|
@@ -54308,13 +54386,13 @@ var HostAgentSupervisor = class {
|
|
|
54308
54386
|
if ((payload.repoProvider ?? "github") === "gitlab") {
|
|
54309
54387
|
const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
|
|
54310
54388
|
if (glabCmd) {
|
|
54311
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
54389
|
+
childEnv.PATH = `${codeamBinDir()}${path113.delimiter}${childEnv.PATH}`;
|
|
54312
54390
|
await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
|
|
54313
54391
|
}
|
|
54314
54392
|
} else {
|
|
54315
54393
|
const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
|
|
54316
54394
|
if (ghCmd) {
|
|
54317
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
54395
|
+
childEnv.PATH = `${codeamBinDir()}${path113.delimiter}${childEnv.PATH}`;
|
|
54318
54396
|
await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
|
|
54319
54397
|
}
|
|
54320
54398
|
}
|
|
@@ -54342,9 +54420,9 @@ var HostAgentSupervisor = class {
|
|
|
54342
54420
|
);
|
|
54343
54421
|
if (!payload.suppressOnboardingWelcome) {
|
|
54344
54422
|
try {
|
|
54345
|
-
const cfgDir = childEnv.CLAUDE_CONFIG_DIR ||
|
|
54346
|
-
const projectDir =
|
|
54347
|
-
const hasPriorConversation =
|
|
54423
|
+
const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path113.join(os72.homedir(), ".claude");
|
|
54424
|
+
const projectDir = path113.join(cfgDir, "projects", encodeCwd(cwd));
|
|
54425
|
+
const hasPriorConversation = fs101.existsSync(projectDir) && fs101.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
|
|
54348
54426
|
if (hasPriorConversation) {
|
|
54349
54427
|
childEnv.CODEAM_RESUME_LATEST = "1";
|
|
54350
54428
|
log.info(
|
|
@@ -54498,7 +54576,7 @@ var HostAgentSupervisor = class {
|
|
|
54498
54576
|
fallbackResumeTarget() {
|
|
54499
54577
|
const session = getActiveSession();
|
|
54500
54578
|
if (!session || !session.pluginId || !session.pollSecret || !session.agent) return null;
|
|
54501
|
-
const cwd = session.cwd &&
|
|
54579
|
+
const cwd = session.cwd && fs101.existsSync(session.cwd) ? session.cwd : process.cwd();
|
|
54502
54580
|
if (isFilesystemRoot(cwd)) {
|
|
54503
54581
|
log.warn(
|
|
54504
54582
|
"host-agent",
|
|
@@ -54545,7 +54623,7 @@ var HostAgentSupervisor = class {
|
|
|
54545
54623
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: no saved pairing on this box`);
|
|
54546
54624
|
return;
|
|
54547
54625
|
}
|
|
54548
|
-
if (!session.cwd || !
|
|
54626
|
+
if (!session.cwd || !fs101.existsSync(session.cwd)) {
|
|
54549
54627
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: workspace is gone`);
|
|
54550
54628
|
return;
|
|
54551
54629
|
}
|
|
@@ -54587,7 +54665,7 @@ var HostAgentSupervisor = class {
|
|
|
54587
54665
|
const persisted = new Map((this.sessionStore.load() ?? []).map((r) => [r.deployId, r.agent]));
|
|
54588
54666
|
for (const c2 of this.children.values()) persisted.set(c2.deployId, c2.agent);
|
|
54589
54667
|
return this.listSavedSessions().map((s) => ({ s, deployId: deployIdFromWorkspace(s.cwd) })).filter(
|
|
54590
|
-
(x) => x.deployId !== null && !!x.s.cwd &&
|
|
54668
|
+
(x) => x.deployId !== null && !!x.s.cwd && fs101.existsSync(x.s.cwd)
|
|
54591
54669
|
).map(({ s, deployId }) => {
|
|
54592
54670
|
const agent = persisted.get(deployId);
|
|
54593
54671
|
return { deployId, sessionId: s.id, ...agent ? { agent } : {} };
|
|
@@ -54672,7 +54750,7 @@ var HostAgentSupervisor = class {
|
|
|
54672
54750
|
if (this.children.has(deployId)) return;
|
|
54673
54751
|
const st3 = this.resumeStateFor(target);
|
|
54674
54752
|
try {
|
|
54675
|
-
const cwd =
|
|
54753
|
+
const cwd = fs101.existsSync(target.cwd) ? target.cwd : process.cwd();
|
|
54676
54754
|
if (isWrapperCheckout(cwd)) {
|
|
54677
54755
|
log.warn(
|
|
54678
54756
|
"host-agent",
|
|
@@ -54714,7 +54792,7 @@ var HostAgentSupervisor = class {
|
|
|
54714
54792
|
return;
|
|
54715
54793
|
}
|
|
54716
54794
|
if (tracked && signal) {
|
|
54717
|
-
this.onResumeChildExit(target, 128 + (
|
|
54795
|
+
this.onResumeChildExit(target, 128 + (os72.constants.signals[signal] ?? 9), `signal ${signal}`);
|
|
54718
54796
|
return;
|
|
54719
54797
|
}
|
|
54720
54798
|
log.warn(
|
|
@@ -54757,7 +54835,7 @@ var HostAgentSupervisor = class {
|
|
|
54757
54835
|
if (Date.now() - child.startedAt < CRASH_RESPAWN_MIN_UPTIME_MS) return false;
|
|
54758
54836
|
const session = pickSavedSessionForWorkspace(this.listSavedSessions(), child.cwd);
|
|
54759
54837
|
if (!session) return false;
|
|
54760
|
-
const exitCode = typeof code === "number" ? code : 128 + (signal ?
|
|
54838
|
+
const exitCode = typeof code === "number" ? code : 128 + (signal ? os72.constants.signals[signal] ?? 9 : 9);
|
|
54761
54839
|
log.warn(
|
|
54762
54840
|
"host-agent",
|
|
54763
54841
|
`session deploy=${child.deployId.slice(0, 8)} died (${signal ?? code}) after ${Math.round((Date.now() - child.startedAt) / 1e3)}s \u2014 respawning it (resume)`
|
|
@@ -54907,12 +54985,12 @@ var HostAgentSupervisor = class {
|
|
|
54907
54985
|
this.untrackChild(deployId);
|
|
54908
54986
|
}
|
|
54909
54987
|
const dirs = [
|
|
54910
|
-
|
|
54911
|
-
|
|
54988
|
+
path113.join(selfHostedWorkspaceRoot(), deployId),
|
|
54989
|
+
path113.join(os72.homedir(), ".codeam", "house-claude", deployId)
|
|
54912
54990
|
];
|
|
54913
54991
|
for (const dir of dirs) {
|
|
54914
54992
|
try {
|
|
54915
|
-
|
|
54993
|
+
fs101.rmSync(dir, { recursive: true, force: true });
|
|
54916
54994
|
} catch (err) {
|
|
54917
54995
|
log.warn(
|
|
54918
54996
|
"host-agent",
|
|
@@ -55131,8 +55209,8 @@ async function invite() {
|
|
|
55131
55209
|
var import_node_dns = require("dns");
|
|
55132
55210
|
var import_node_util11 = require("util");
|
|
55133
55211
|
var import_node_crypto17 = require("crypto");
|
|
55134
|
-
var
|
|
55135
|
-
var
|
|
55212
|
+
var fs102 = __toESM(require("fs"));
|
|
55213
|
+
var path114 = __toESM(require("path"));
|
|
55136
55214
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
55137
55215
|
var dnsResolveP = (0, import_node_util11.promisify)(import_node_dns.resolve);
|
|
55138
55216
|
async function checkDns(apiBase2) {
|
|
@@ -55188,13 +55266,13 @@ async function checkHealth(apiBase2) {
|
|
|
55188
55266
|
}
|
|
55189
55267
|
}
|
|
55190
55268
|
function checkConfigDir() {
|
|
55191
|
-
const dir =
|
|
55269
|
+
const dir = path114.join(require("os").homedir(), ".codeam");
|
|
55192
55270
|
try {
|
|
55193
|
-
|
|
55194
|
-
const probe =
|
|
55195
|
-
|
|
55196
|
-
const read =
|
|
55197
|
-
|
|
55271
|
+
fs102.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
55272
|
+
const probe = path114.join(dir, ".doctor-probe");
|
|
55273
|
+
fs102.writeFileSync(probe, "ok", { mode: 384 });
|
|
55274
|
+
const read = fs102.readFileSync(probe, "utf8");
|
|
55275
|
+
fs102.unlinkSync(probe);
|
|
55198
55276
|
if (read !== "ok") throw new Error("write/read round-trip mismatch");
|
|
55199
55277
|
return {
|
|
55200
55278
|
id: "config-dir",
|
|
@@ -55234,9 +55312,9 @@ function checkSessions() {
|
|
|
55234
55312
|
}
|
|
55235
55313
|
}
|
|
55236
55314
|
function checkAgentBinaries() {
|
|
55237
|
-
const
|
|
55315
|
+
const os75 = createOsStrategy();
|
|
55238
55316
|
return getEnabledAgents().map((meta) => {
|
|
55239
|
-
const found =
|
|
55317
|
+
const found = os75.findInPath(meta.binaryName);
|
|
55240
55318
|
return {
|
|
55241
55319
|
id: `agent-${meta.id}`,
|
|
55242
55320
|
label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
|
|
@@ -55258,7 +55336,7 @@ function checkNodePty() {
|
|
|
55258
55336
|
detail: "not required on this platform"
|
|
55259
55337
|
};
|
|
55260
55338
|
}
|
|
55261
|
-
const vendoredPath =
|
|
55339
|
+
const vendoredPath = path114.join(__dirname, "vendor", "node-pty");
|
|
55262
55340
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
55263
55341
|
try {
|
|
55264
55342
|
require(target);
|
|
@@ -55300,7 +55378,7 @@ function checkChokidar() {
|
|
|
55300
55378
|
}
|
|
55301
55379
|
async function doctor(args2 = []) {
|
|
55302
55380
|
const json = args2.includes("--json");
|
|
55303
|
-
const cliVersion = true ? "2.76.
|
|
55381
|
+
const cliVersion = true ? "2.76.44" : "0.0.0-dev";
|
|
55304
55382
|
const apiBase2 = resolveApiBaseUrl();
|
|
55305
55383
|
const diagnosticId = (0, import_node_crypto17.randomUUID)();
|
|
55306
55384
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
@@ -55836,7 +55914,7 @@ async function mcpWarm(argv = [], opts = {}) {
|
|
|
55836
55914
|
// src/commands/version.ts
|
|
55837
55915
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
55838
55916
|
function version2() {
|
|
55839
|
-
const v = true ? "2.76.
|
|
55917
|
+
const v = true ? "2.76.44" : "unknown";
|
|
55840
55918
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
55841
55919
|
}
|
|
55842
55920
|
|
|
@@ -55969,10 +56047,10 @@ function tryShowSubcommandHelp(cmd, args2) {
|
|
|
55969
56047
|
var _subcommandHelpKeys = Object.keys(HELPS);
|
|
55970
56048
|
|
|
55971
56049
|
// src/index.ts
|
|
55972
|
-
var
|
|
56050
|
+
var os74 = __toESM(require("os"));
|
|
55973
56051
|
if (!process.env.HOME) {
|
|
55974
56052
|
try {
|
|
55975
|
-
const home =
|
|
56053
|
+
const home = os74.homedir();
|
|
55976
56054
|
if (home) process.env.HOME = home;
|
|
55977
56055
|
} catch {
|
|
55978
56056
|
}
|