codeam-cli 2.76.45 → 2.76.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/index.js +835 -622
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -374,8 +374,8 @@ function defaultSpawn(timeoutMs) {
|
|
|
374
374
|
});
|
|
375
375
|
}
|
|
376
376
|
function resolveConvexBin(cwd) {
|
|
377
|
-
const local =
|
|
378
|
-
if (
|
|
377
|
+
const local = path118.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "convex.cmd" : "convex");
|
|
378
|
+
if (fs106.existsSync(local)) return { cmd: local, args: [] };
|
|
379
379
|
return { cmd: "npx", args: ["--yes", "convex"] };
|
|
380
380
|
}
|
|
381
381
|
function redact(text, key) {
|
|
@@ -506,13 +506,13 @@ async function runConvexAdminMcp(client3, id) {
|
|
|
506
506
|
});
|
|
507
507
|
await server.connect(new StdioServerTransport());
|
|
508
508
|
}
|
|
509
|
-
var import_node_child_process42,
|
|
509
|
+
var import_node_child_process42, fs106, path118, TOOLS;
|
|
510
510
|
var init_convex_admin_mcp = __esm({
|
|
511
511
|
"src/integrations/convex-admin-mcp.ts"() {
|
|
512
512
|
"use strict";
|
|
513
513
|
import_node_child_process42 = require("child_process");
|
|
514
|
-
|
|
515
|
-
|
|
514
|
+
fs106 = __toESM(require("fs"));
|
|
515
|
+
path118 = __toESM(require("path"));
|
|
516
516
|
TOOLS = [
|
|
517
517
|
{
|
|
518
518
|
name: "tables",
|
|
@@ -4393,11 +4393,11 @@ function quiet(fn) {
|
|
|
4393
4393
|
log.debug(TAG, "ignored sync error", err);
|
|
4394
4394
|
}
|
|
4395
4395
|
}
|
|
4396
|
-
function rmIfExistsQuiet(
|
|
4396
|
+
function rmIfExistsQuiet(path120) {
|
|
4397
4397
|
try {
|
|
4398
|
-
fs2.rmSync(
|
|
4398
|
+
fs2.rmSync(path120, { force: true });
|
|
4399
4399
|
} catch (err) {
|
|
4400
|
-
log.debug(TAG, `rmIfExists failed for ${
|
|
4400
|
+
log.debug(TAG, `rmIfExists failed for ${path120}`, err);
|
|
4401
4401
|
}
|
|
4402
4402
|
}
|
|
4403
4403
|
function killQuiet(target, signal = "SIGTERM") {
|
|
@@ -4563,9 +4563,9 @@ var _default = makeConfig();
|
|
|
4563
4563
|
var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, setSessionAgent, setSquadAuto, getSquadAuto, clearAll, saveCliConfig, loadCliConfig } = _default;
|
|
4564
4564
|
|
|
4565
4565
|
// src/commands/pair-auto.ts
|
|
4566
|
-
var
|
|
4567
|
-
var
|
|
4568
|
-
var
|
|
4566
|
+
var fs72 = __toESM(require("fs"));
|
|
4567
|
+
var os52 = __toESM(require("os"));
|
|
4568
|
+
var path79 = __toESM(require("path"));
|
|
4569
4569
|
var import_crypto4 = require("crypto");
|
|
4570
4570
|
|
|
4571
4571
|
// src/services/telemetry.service.ts
|
|
@@ -4601,8 +4601,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
|
|
|
4601
4601
|
return decodedFile;
|
|
4602
4602
|
};
|
|
4603
4603
|
}
|
|
4604
|
-
function normalizeWindowsPath(
|
|
4605
|
-
return
|
|
4604
|
+
function normalizeWindowsPath(path120) {
|
|
4605
|
+
return path120.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
4606
4606
|
}
|
|
4607
4607
|
|
|
4608
4608
|
// ../../node_modules/@posthog/core/dist/error-tracking/index.mjs
|
|
@@ -7335,13 +7335,13 @@ var PostHogCoreStateless = class {
|
|
|
7335
7335
|
sentFromRoute += batchMessages.length;
|
|
7336
7336
|
}
|
|
7337
7337
|
}
|
|
7338
|
-
async _sendOtlpBatch({ path:
|
|
7338
|
+
async _sendOtlpBatch({ path: path120, payload }) {
|
|
7339
7339
|
if (this.disabled) return {
|
|
7340
7340
|
kind: "fatal",
|
|
7341
7341
|
error: new Error("The client is disabled")
|
|
7342
7342
|
};
|
|
7343
7343
|
const serialized = JSON.stringify(payload);
|
|
7344
|
-
const url2 = `${this.host}/i/v1/${
|
|
7344
|
+
const url2 = `${this.host}/i/v1/${path120}?token=${encodeURIComponent(this.apiKey)}`;
|
|
7345
7345
|
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
|
|
7346
7346
|
const fetchOptions = {
|
|
7347
7347
|
method: "POST",
|
|
@@ -8581,14 +8581,14 @@ async function addSourceContext(frames, openSourceFile = import_promises.open, l
|
|
|
8581
8581
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
8582
8582
|
return frames;
|
|
8583
8583
|
}
|
|
8584
|
-
async function openRegularSourceFile(
|
|
8584
|
+
async function openRegularSourceFile(path120, openSourceFile, logger) {
|
|
8585
8585
|
let fileHandle;
|
|
8586
8586
|
let isValid = false;
|
|
8587
8587
|
try {
|
|
8588
|
-
fileHandle = await openSourceFile(
|
|
8588
|
+
fileHandle = await openSourceFile(path120, import_node_fs.constants.O_RDONLY | import_node_fs.constants.O_NONBLOCK);
|
|
8589
8589
|
const fileStat = await fileHandle.stat();
|
|
8590
8590
|
if (!fileStat.isFile()) return;
|
|
8591
|
-
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${
|
|
8591
|
+
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${path120}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
|
|
8592
8592
|
isValid = true;
|
|
8593
8593
|
return fileHandle;
|
|
8594
8594
|
} catch {
|
|
@@ -8598,8 +8598,8 @@ async function openRegularSourceFile(path118, openSourceFile, logger) {
|
|
|
8598
8598
|
});
|
|
8599
8599
|
}
|
|
8600
8600
|
}
|
|
8601
|
-
async function getContextLinesFromFile(
|
|
8602
|
-
const fileHandle = await openRegularSourceFile(
|
|
8601
|
+
async function getContextLinesFromFile(path120, ranges, output, cacheKey, openSourceFile, logger) {
|
|
8602
|
+
const fileHandle = await openRegularSourceFile(path120, openSourceFile, logger);
|
|
8603
8603
|
if (void 0 === fileHandle) return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
8604
8604
|
const openedFileHandle = fileHandle;
|
|
8605
8605
|
return new Promise((resolve13) => {
|
|
@@ -8701,22 +8701,22 @@ function clearLineContext(frame) {
|
|
|
8701
8701
|
delete frame.context_line;
|
|
8702
8702
|
delete frame.post_context;
|
|
8703
8703
|
}
|
|
8704
|
-
function shouldSkipContextLinesForFile(
|
|
8705
|
-
return
|
|
8704
|
+
function shouldSkipContextLinesForFile(path120) {
|
|
8705
|
+
return path120.startsWith("node:") || path120.endsWith(".min.js") || path120.endsWith(".min.cjs") || path120.endsWith(".min.mjs") || path120.startsWith("data:");
|
|
8706
8706
|
}
|
|
8707
8707
|
function shouldSkipContextLinesForFrame(frame) {
|
|
8708
8708
|
if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
|
|
8709
8709
|
if (void 0 !== frame.colno && frame.colno > MAX_CONTEXTLINES_COLNO) return true;
|
|
8710
8710
|
return false;
|
|
8711
8711
|
}
|
|
8712
|
-
function makeSourceCacheKey(
|
|
8713
|
-
if ((0, import_node_path.isAbsolute)(
|
|
8712
|
+
function makeSourceCacheKey(path120, basePath) {
|
|
8713
|
+
if ((0, import_node_path.isAbsolute)(path120)) return JSON.stringify([
|
|
8714
8714
|
null,
|
|
8715
|
-
|
|
8715
|
+
path120
|
|
8716
8716
|
]);
|
|
8717
8717
|
return void 0 === basePath ? void 0 : JSON.stringify([
|
|
8718
8718
|
basePath,
|
|
8719
|
-
|
|
8719
|
+
path120
|
|
8720
8720
|
]);
|
|
8721
8721
|
}
|
|
8722
8722
|
function rangeExistsInContentCache(cacheKey, range) {
|
|
@@ -11378,7 +11378,7 @@ function readAnonId() {
|
|
|
11378
11378
|
}
|
|
11379
11379
|
function superProperties() {
|
|
11380
11380
|
return {
|
|
11381
|
-
cliVersion: true ? "2.76.
|
|
11381
|
+
cliVersion: true ? "2.76.47" : "0.0.0-dev",
|
|
11382
11382
|
nodeVersion: process.version,
|
|
11383
11383
|
platform: process.platform,
|
|
11384
11384
|
arch: process.arch,
|
|
@@ -11627,7 +11627,7 @@ var http = __toESM(require("http"));
|
|
|
11627
11627
|
// package.json
|
|
11628
11628
|
var package_default = {
|
|
11629
11629
|
name: "codeam-cli",
|
|
11630
|
-
version: "2.76.
|
|
11630
|
+
version: "2.76.47",
|
|
11631
11631
|
description: "Workflow-continuity bridge for AI coding agents. Wrap Claude Code or Codex in a PTY and supervise, approve, and redirect the session from any device \u2014 async. The terminal companion for CodeAgent Mobile.",
|
|
11632
11632
|
type: "commonjs",
|
|
11633
11633
|
main: "dist/index.js",
|
|
@@ -13003,7 +13003,7 @@ var CommandRelayService = class _CommandRelayService {
|
|
|
13003
13003
|
// fresh + clear the "CLI update available" banner after a self-update
|
|
13004
13004
|
// (a codespace that reinstalls @latest reconnects via heartbeat, not
|
|
13005
13005
|
// pair/reconnect). Older backends ignore the extra field.
|
|
13006
|
-
..."2.76.
|
|
13006
|
+
..."2.76.47" ? { ideVersion: "2.76.47" } : {}
|
|
13007
13007
|
};
|
|
13008
13008
|
try {
|
|
13009
13009
|
const res = await _postJson(`${API_BASE2}/api/plugin/heartbeat`, body, this.pollSecretHeader());
|
|
@@ -13326,10 +13326,10 @@ var WINDOWS_LEGACY_JUNCTIONS = [
|
|
|
13326
13326
|
/[\\/]Start Menu([\\/]|$)/i,
|
|
13327
13327
|
/[\\/]Templates([\\/]|$)/i
|
|
13328
13328
|
];
|
|
13329
|
-
function isUnsafeWindowsWatchRoot(dir,
|
|
13329
|
+
function isUnsafeWindowsWatchRoot(dir, homedir58) {
|
|
13330
13330
|
const norm = (p2) => p2.replace(/\//g, "\\").replace(/\\+$/, "").toLowerCase();
|
|
13331
13331
|
const cwd = norm(dir);
|
|
13332
|
-
const home = norm(
|
|
13332
|
+
const home = norm(homedir58);
|
|
13333
13333
|
if (cwd === home) return true;
|
|
13334
13334
|
if (/^[a-z]:$/.test(cwd)) return true;
|
|
13335
13335
|
const sysRoots = [
|
|
@@ -14484,9 +14484,9 @@ function closeAllTerminals() {
|
|
|
14484
14484
|
}
|
|
14485
14485
|
|
|
14486
14486
|
// src/commands/start/handlers.ts
|
|
14487
|
-
var
|
|
14488
|
-
var
|
|
14489
|
-
var
|
|
14487
|
+
var fs71 = __toESM(require("fs"));
|
|
14488
|
+
var os51 = __toESM(require("os"));
|
|
14489
|
+
var path78 = __toESM(require("path"));
|
|
14490
14490
|
var import_crypto3 = require("crypto");
|
|
14491
14491
|
var import_child_process25 = require("child_process");
|
|
14492
14492
|
|
|
@@ -18133,10 +18133,10 @@ function buildForPlatform(platform3) {
|
|
|
18133
18133
|
var import_node_crypto5 = require("crypto");
|
|
18134
18134
|
|
|
18135
18135
|
// src/agents/claude/resolver.ts
|
|
18136
|
-
function buildClaudeLaunch(extraArgs = [],
|
|
18137
|
-
const found =
|
|
18136
|
+
function buildClaudeLaunch(extraArgs = [], os78 = createOsStrategy()) {
|
|
18137
|
+
const found = os78.findInPath("claude") ?? os78.findInPath("claude-code");
|
|
18138
18138
|
if (!found) return null;
|
|
18139
|
-
return
|
|
18139
|
+
return os78.buildLaunch(found, extraArgs);
|
|
18140
18140
|
}
|
|
18141
18141
|
|
|
18142
18142
|
// src/agents/claude/installer.ts
|
|
@@ -18235,8 +18235,8 @@ function parseClaudeAuthStatus(stdout) {
|
|
|
18235
18235
|
return "unknown";
|
|
18236
18236
|
}
|
|
18237
18237
|
}
|
|
18238
|
-
function probeClaudeLocalAuth(
|
|
18239
|
-
const bin =
|
|
18238
|
+
function probeClaudeLocalAuth(os78, timeoutMs = 1e4) {
|
|
18239
|
+
const bin = os78.findInPath("claude") ?? os78.findInPath("claude-code");
|
|
18240
18240
|
if (!bin) return Promise.resolve("unknown");
|
|
18241
18241
|
return new Promise((resolve13) => {
|
|
18242
18242
|
try {
|
|
@@ -19014,8 +19014,8 @@ var ClaudeRuntimeStrategy = class {
|
|
|
19014
19014
|
meta = getAgent("claude");
|
|
19015
19015
|
mode = "interactive";
|
|
19016
19016
|
os;
|
|
19017
|
-
constructor(
|
|
19018
|
-
this.os =
|
|
19017
|
+
constructor(os78) {
|
|
19018
|
+
this.os = os78;
|
|
19019
19019
|
}
|
|
19020
19020
|
probeLocalAuth() {
|
|
19021
19021
|
return probeClaudeLocalAuth(this.os);
|
|
@@ -19445,11 +19445,25 @@ var SquadState = class {
|
|
|
19445
19445
|
journalPath;
|
|
19446
19446
|
turns;
|
|
19447
19447
|
members = /* @__PURE__ */ new Map();
|
|
19448
|
+
/** Backend roster fetch (`/api/plugin/agents/roster`); absent → never refreshes. */
|
|
19449
|
+
fetchRoster;
|
|
19448
19450
|
constructor(opts) {
|
|
19449
19451
|
this.journalPath = journalPathFor(opts.homeDir ?? os17.homedir(), opts.sessionId);
|
|
19450
19452
|
this.turns = loadJournal(this.journalPath);
|
|
19453
|
+
this.fetchRoster = opts.fetchRoster ?? null;
|
|
19451
19454
|
if (opts.auto) this.setAuto(opts.auto);
|
|
19452
19455
|
}
|
|
19456
|
+
/**
|
|
19457
|
+
* Re-fetch the roster from the backend (on demand — never on a timer). A
|
|
19458
|
+
* failed/offline fetch keeps the last known roster. Resolves to the roster
|
|
19459
|
+
* now in effect.
|
|
19460
|
+
*/
|
|
19461
|
+
async refreshRoster() {
|
|
19462
|
+
if (!this.fetchRoster) return this.roster;
|
|
19463
|
+
const fresh = await this.fetchRoster();
|
|
19464
|
+
if (fresh) this.roster = fresh;
|
|
19465
|
+
return this.roster;
|
|
19466
|
+
}
|
|
19453
19467
|
get auto() {
|
|
19454
19468
|
return this.autoConfig;
|
|
19455
19469
|
}
|
|
@@ -20118,8 +20132,8 @@ function codexCredentialLocator() {
|
|
|
20118
20132
|
function codexLoginLauncher() {
|
|
20119
20133
|
return {
|
|
20120
20134
|
async ensureInstalled() {
|
|
20121
|
-
const
|
|
20122
|
-
return
|
|
20135
|
+
const os78 = createOsStrategy();
|
|
20136
|
+
return os78.findInPath("codex") !== null;
|
|
20123
20137
|
},
|
|
20124
20138
|
launch() {
|
|
20125
20139
|
return (0, import_node_child_process4.spawn)("codex", ["login"], { stdio: "inherit" });
|
|
@@ -20148,8 +20162,8 @@ var CodexRuntimeStrategy = class {
|
|
|
20148
20162
|
meta = getAgent("codex");
|
|
20149
20163
|
mode = "interactive";
|
|
20150
20164
|
os;
|
|
20151
|
-
constructor(
|
|
20152
|
-
this.os =
|
|
20165
|
+
constructor(os78) {
|
|
20166
|
+
this.os = os78;
|
|
20153
20167
|
}
|
|
20154
20168
|
async prepareLaunch() {
|
|
20155
20169
|
let binary = this.os.findInPath("codex");
|
|
@@ -20270,12 +20284,12 @@ var CodexRuntimeStrategy = class {
|
|
|
20270
20284
|
return (await runOnce()).text;
|
|
20271
20285
|
}
|
|
20272
20286
|
};
|
|
20273
|
-
function resolveNpm(
|
|
20274
|
-
return
|
|
20287
|
+
function resolveNpm(os78) {
|
|
20288
|
+
return os78.id === "win32" ? "npm.cmd" : "npm";
|
|
20275
20289
|
}
|
|
20276
|
-
async function installCodexViaNpm(
|
|
20290
|
+
async function installCodexViaNpm(os78) {
|
|
20277
20291
|
return new Promise((resolve13, reject) => {
|
|
20278
|
-
const proc = (0, import_node_child_process5.spawn)(resolveNpm(
|
|
20292
|
+
const proc = (0, import_node_child_process5.spawn)(resolveNpm(os78), ["install", "-g", "--no-audit", "--no-fund", "@openai/codex"], {
|
|
20279
20293
|
stdio: "inherit"
|
|
20280
20294
|
});
|
|
20281
20295
|
proc.on("close", (code) => {
|
|
@@ -20292,16 +20306,16 @@ async function installCodexViaNpm(os76) {
|
|
|
20292
20306
|
});
|
|
20293
20307
|
});
|
|
20294
20308
|
}
|
|
20295
|
-
function augmentNpmGlobalBin(
|
|
20309
|
+
function augmentNpmGlobalBin(os78) {
|
|
20296
20310
|
try {
|
|
20297
|
-
const result = (0, import_node_child_process5.spawnSync)(resolveNpm(
|
|
20311
|
+
const result = (0, import_node_child_process5.spawnSync)(resolveNpm(os78), ["prefix", "-g"], {
|
|
20298
20312
|
stdio: ["ignore", "pipe", "ignore"]
|
|
20299
20313
|
});
|
|
20300
20314
|
if (result.status !== 0) return;
|
|
20301
20315
|
const prefix = result.stdout.toString().trim();
|
|
20302
20316
|
if (!prefix) return;
|
|
20303
|
-
const binDir =
|
|
20304
|
-
|
|
20317
|
+
const binDir = os78.id === "win32" ? prefix : path27.join(prefix, "bin");
|
|
20318
|
+
os78.augmentPath([binDir]);
|
|
20305
20319
|
} catch {
|
|
20306
20320
|
}
|
|
20307
20321
|
}
|
|
@@ -20495,10 +20509,10 @@ function manualInstallHint(runner, tools) {
|
|
|
20495
20509
|
const argv = osPackageInstallArgv(detectPackageManager(runner), [...tools]);
|
|
20496
20510
|
return argv ? `\`sudo ${argv.join(" ")}\`` : `your package manager (e.g. \`${pkgs}\`)`;
|
|
20497
20511
|
}
|
|
20498
|
-
function writeUnzipShim(
|
|
20512
|
+
function writeUnzipShim(os78, runner) {
|
|
20499
20513
|
const python = ["python3", "python"].find((p2) => runner.which(p2));
|
|
20500
20514
|
if (!python) return null;
|
|
20501
|
-
const dir =
|
|
20515
|
+
const dir = os78.scratchPath("codeam-cr-prereq");
|
|
20502
20516
|
const shim = path29.join(dir, "unzip");
|
|
20503
20517
|
const script = `#!/bin/sh
|
|
20504
20518
|
set -e
|
|
@@ -20520,9 +20534,9 @@ exec ${python} -m zipfile -e "$archive" "$dest"
|
|
|
20520
20534
|
(0, import_node_fs6.chmodSync)(shim, 448);
|
|
20521
20535
|
return dir;
|
|
20522
20536
|
}
|
|
20523
|
-
async function ensureInstallPrerequisites(
|
|
20537
|
+
async function ensureInstallPrerequisites(os78, deps = {}) {
|
|
20524
20538
|
const runner = deps.runner ?? defaultOsRunner;
|
|
20525
|
-
const missing = REQUIRED_TOOLS.filter((t2) =>
|
|
20539
|
+
const missing = REQUIRED_TOOLS.filter((t2) => os78.findInPath(t2) === null);
|
|
20526
20540
|
if (missing.length === 0) return { ok: true, extraPath: [] };
|
|
20527
20541
|
log.info(
|
|
20528
20542
|
"coderabbit",
|
|
@@ -20541,10 +20555,10 @@ async function ensureInstallPrerequisites(os76, deps = {}) {
|
|
|
20541
20555
|
);
|
|
20542
20556
|
}
|
|
20543
20557
|
}
|
|
20544
|
-
const stillMissing = REQUIRED_TOOLS.filter((t2) =>
|
|
20558
|
+
const stillMissing = REQUIRED_TOOLS.filter((t2) => os78.findInPath(t2) === null);
|
|
20545
20559
|
if (stillMissing.length === 0) return { ok: true, extraPath: [] };
|
|
20546
20560
|
if (stillMissing.length === 1 && stillMissing[0] === "unzip") {
|
|
20547
|
-
const shimDir = writeUnzipShim(
|
|
20561
|
+
const shimDir = writeUnzipShim(os78, runner);
|
|
20548
20562
|
if (shimDir) {
|
|
20549
20563
|
log.info("coderabbit", "unzip is unavailable \u2014 using a scoped python zipfile shim");
|
|
20550
20564
|
return { ok: true, extraPath: [shimDir] };
|
|
@@ -20607,15 +20621,15 @@ function summarizeInstallFailure(output) {
|
|
|
20607
20621
|
}
|
|
20608
20622
|
return lines.length > 0 ? lines[lines.length - 1] : null;
|
|
20609
20623
|
}
|
|
20610
|
-
async function ensureCoderabbitInstalled(
|
|
20611
|
-
if (
|
|
20612
|
-
if (
|
|
20624
|
+
async function ensureCoderabbitInstalled(os78, deps = {}) {
|
|
20625
|
+
if (os78.findInPath("coderabbit")) return { ok: true };
|
|
20626
|
+
if (os78.id === "win32") {
|
|
20613
20627
|
return {
|
|
20614
20628
|
ok: false,
|
|
20615
20629
|
error: "CodeRabbit on Windows requires WSL. Install the CLI inside your WSL distribution (curl -fsSL https://cli.coderabbit.ai/install.sh | sh), then try again."
|
|
20616
20630
|
};
|
|
20617
20631
|
}
|
|
20618
|
-
const prereq = await ensureInstallPrerequisites(
|
|
20632
|
+
const prereq = await ensureInstallPrerequisites(os78, deps);
|
|
20619
20633
|
if (!prereq.ok) return { ok: false, error: prereq.error };
|
|
20620
20634
|
const env = { ...process.env };
|
|
20621
20635
|
if (prereq.extraPath.length > 0) {
|
|
@@ -20624,8 +20638,8 @@ async function ensureCoderabbitInstalled(os76, deps = {}) {
|
|
|
20624
20638
|
log.info("coderabbit", "CodeRabbit CLI not found \u2014 installing via the official script");
|
|
20625
20639
|
const run3 = deps.runInstallScript ?? defaultRunInstallScript;
|
|
20626
20640
|
const { code, output } = await run3(env);
|
|
20627
|
-
|
|
20628
|
-
const binary =
|
|
20641
|
+
os78.augmentPath([`${os78.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
|
|
20642
|
+
const binary = os78.findInPath("coderabbit");
|
|
20629
20643
|
const detail = summarizeInstallFailure(output);
|
|
20630
20644
|
if (binary !== null) {
|
|
20631
20645
|
if (code === 0) return { ok: true };
|
|
@@ -20679,10 +20693,10 @@ function coderabbitCredentialLocator() {
|
|
|
20679
20693
|
validate: validateNonEmptyCredential
|
|
20680
20694
|
};
|
|
20681
20695
|
}
|
|
20682
|
-
function coderabbitLoginLauncher(
|
|
20696
|
+
function coderabbitLoginLauncher(os78) {
|
|
20683
20697
|
return {
|
|
20684
20698
|
async ensureInstalled() {
|
|
20685
|
-
const result = await ensureCoderabbitInstalled(
|
|
20699
|
+
const result = await ensureCoderabbitInstalled(os78);
|
|
20686
20700
|
if (!result.ok && result.error) console.error(`
|
|
20687
20701
|
\u2717 ${result.error}
|
|
20688
20702
|
`);
|
|
@@ -20742,8 +20756,8 @@ function pickLine(obj) {
|
|
|
20742
20756
|
function toHunk(raw, groupSeverity) {
|
|
20743
20757
|
if (!raw || typeof raw !== "object") return null;
|
|
20744
20758
|
const o = raw;
|
|
20745
|
-
const
|
|
20746
|
-
if (!
|
|
20759
|
+
const path120 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
|
|
20760
|
+
if (!path120) return null;
|
|
20747
20761
|
const message = asString(
|
|
20748
20762
|
pick(o, [
|
|
20749
20763
|
"comment",
|
|
@@ -20760,7 +20774,7 @@ function toHunk(raw, groupSeverity) {
|
|
|
20760
20774
|
const severity = normSeverity(pick(o, ["severity", "level", "priority", "impact"])) ?? normSeverity(groupSeverity);
|
|
20761
20775
|
const locObj = pick(o, ["location"]) ?? o;
|
|
20762
20776
|
return {
|
|
20763
|
-
path:
|
|
20777
|
+
path: path120.trim(),
|
|
20764
20778
|
line: pickLine(o) ?? pickLine(locObj),
|
|
20765
20779
|
severity,
|
|
20766
20780
|
message: (title && message ? `${title}: ${message}` : title || message).trim() || "(no message)"
|
|
@@ -20843,10 +20857,10 @@ function parsePlain(stdout) {
|
|
|
20843
20857
|
for (const line of stdout.split(/\r?\n/)) {
|
|
20844
20858
|
const m = line.match(HUNK_LINE_RE);
|
|
20845
20859
|
if (!m) continue;
|
|
20846
|
-
const [,
|
|
20847
|
-
if (!
|
|
20860
|
+
const [, path120, lineNo, sevToken, message] = m;
|
|
20861
|
+
if (!path120 || !lineNo || !message) continue;
|
|
20848
20862
|
hunks.push({
|
|
20849
|
-
path:
|
|
20863
|
+
path: path120.trim(),
|
|
20850
20864
|
line: Number(lineNo),
|
|
20851
20865
|
severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
|
|
20852
20866
|
message: message.trim().replace(/^[*-]\s+/, "")
|
|
@@ -20906,8 +20920,8 @@ var CoderabbitRuntimeStrategy = class {
|
|
|
20906
20920
|
meta = getAgent("coderabbit");
|
|
20907
20921
|
mode = "batch";
|
|
20908
20922
|
os;
|
|
20909
|
-
constructor(
|
|
20910
|
-
this.os =
|
|
20923
|
+
constructor(os78) {
|
|
20924
|
+
this.os = os78;
|
|
20911
20925
|
}
|
|
20912
20926
|
getDefaultArgs() {
|
|
20913
20927
|
return ["review", "--agent"];
|
|
@@ -21178,10 +21192,10 @@ function cursorCredentialLocator() {
|
|
|
21178
21192
|
validate: validateNonEmptyCredential
|
|
21179
21193
|
};
|
|
21180
21194
|
}
|
|
21181
|
-
function cursorLoginLauncher(
|
|
21195
|
+
function cursorLoginLauncher(os78) {
|
|
21182
21196
|
return {
|
|
21183
21197
|
async ensureInstalled() {
|
|
21184
|
-
if (
|
|
21198
|
+
if (os78.findInPath("cursor-agent")) return true;
|
|
21185
21199
|
console.error(
|
|
21186
21200
|
"\n \u2717 cursor-agent binary not on PATH.\n Install Cursor (https://cursor.com/) and ensure the CLI\n plugin is enabled, then re-run `codeam link cursor`.\n"
|
|
21187
21201
|
);
|
|
@@ -21245,8 +21259,8 @@ var CursorRuntimeStrategy = class {
|
|
|
21245
21259
|
meta = getAgent("cursor");
|
|
21246
21260
|
mode = "interactive";
|
|
21247
21261
|
os;
|
|
21248
|
-
constructor(
|
|
21249
|
-
this.os =
|
|
21262
|
+
constructor(os78) {
|
|
21263
|
+
this.os = os78;
|
|
21250
21264
|
}
|
|
21251
21265
|
async prepareLaunch() {
|
|
21252
21266
|
const binary = this.os.findInPath("cursor-agent");
|
|
@@ -21464,10 +21478,10 @@ function aiderCredentialLocator() {
|
|
|
21464
21478
|
validate: validateNonEmptyCredential
|
|
21465
21479
|
};
|
|
21466
21480
|
}
|
|
21467
|
-
function aiderLoginLauncher(
|
|
21481
|
+
function aiderLoginLauncher(os78) {
|
|
21468
21482
|
return {
|
|
21469
21483
|
async ensureInstalled() {
|
|
21470
|
-
if (
|
|
21484
|
+
if (os78.findInPath("aider")) return true;
|
|
21471
21485
|
console.error(
|
|
21472
21486
|
"\n \u2717 aider binary not on PATH.\n Install Aider:\n pip install aider-chat\n then re-run `codeam link aider`.\n"
|
|
21473
21487
|
);
|
|
@@ -21477,7 +21491,7 @@ function aiderLoginLauncher(os76) {
|
|
|
21477
21491
|
console.error(
|
|
21478
21492
|
"\n Aider has no interactive login flow.\n Set ANTHROPIC_API_KEY or OPENAI_API_KEY in your shell,\n or re-run `codeam link aider --api-key=<your-key>`.\n"
|
|
21479
21493
|
);
|
|
21480
|
-
return (0, import_node_child_process12.spawn)(
|
|
21494
|
+
return (0, import_node_child_process12.spawn)(os78.id === "win32" ? "cmd.exe" : "sh", os78.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
|
|
21481
21495
|
stdio: "ignore"
|
|
21482
21496
|
});
|
|
21483
21497
|
}
|
|
@@ -21761,8 +21775,8 @@ var AiderRuntimeStrategy = class {
|
|
|
21761
21775
|
meta = getAgent("aider");
|
|
21762
21776
|
mode = "interactive";
|
|
21763
21777
|
os;
|
|
21764
|
-
constructor(
|
|
21765
|
-
this.os =
|
|
21778
|
+
constructor(os78) {
|
|
21779
|
+
this.os = os78;
|
|
21766
21780
|
}
|
|
21767
21781
|
async prepareLaunch() {
|
|
21768
21782
|
augmentUserLocalBinPaths();
|
|
@@ -21895,8 +21909,8 @@ function geminiCredentialLocator() {
|
|
|
21895
21909
|
function geminiLoginLauncher() {
|
|
21896
21910
|
return {
|
|
21897
21911
|
async ensureInstalled() {
|
|
21898
|
-
const
|
|
21899
|
-
return
|
|
21912
|
+
const os78 = createOsStrategy();
|
|
21913
|
+
return os78.findInPath("gemini") !== null;
|
|
21900
21914
|
},
|
|
21901
21915
|
launch() {
|
|
21902
21916
|
return (0, import_node_child_process13.spawn)("gemini", ["auth", "login"], { stdio: "inherit" });
|
|
@@ -22086,8 +22100,8 @@ var GeminiRuntimeStrategy = class {
|
|
|
22086
22100
|
meta = getAgent("gemini");
|
|
22087
22101
|
mode = "interactive";
|
|
22088
22102
|
os;
|
|
22089
|
-
constructor(
|
|
22090
|
-
this.os =
|
|
22103
|
+
constructor(os78) {
|
|
22104
|
+
this.os = os78;
|
|
22091
22105
|
}
|
|
22092
22106
|
async prepareLaunch() {
|
|
22093
22107
|
const binary = this.os.findInPath("gemini");
|
|
@@ -22380,8 +22394,8 @@ var KimiRuntimeStrategy = class {
|
|
|
22380
22394
|
meta = getAgent("kimi");
|
|
22381
22395
|
mode = "interactive";
|
|
22382
22396
|
os;
|
|
22383
|
-
constructor(
|
|
22384
|
-
this.os =
|
|
22397
|
+
constructor(os78) {
|
|
22398
|
+
this.os = os78;
|
|
22385
22399
|
}
|
|
22386
22400
|
async prepareLaunch() {
|
|
22387
22401
|
const binary = this.os.findInPath("kimi");
|
|
@@ -22525,8 +22539,8 @@ var OpencodeRuntimeStrategy = class {
|
|
|
22525
22539
|
meta = getAgent("opencode");
|
|
22526
22540
|
mode = "interactive";
|
|
22527
22541
|
os;
|
|
22528
|
-
constructor(
|
|
22529
|
-
this.os =
|
|
22542
|
+
constructor(os78) {
|
|
22543
|
+
this.os = os78;
|
|
22530
22544
|
}
|
|
22531
22545
|
async prepareLaunch() {
|
|
22532
22546
|
const binary = this.os.findInPath("opencode");
|
|
@@ -22709,8 +22723,8 @@ var AntigravityRuntimeStrategy = class {
|
|
|
22709
22723
|
meta = getAgent("antigravity");
|
|
22710
22724
|
mode = "interactive";
|
|
22711
22725
|
os;
|
|
22712
|
-
constructor(
|
|
22713
|
-
this.os =
|
|
22726
|
+
constructor(os78) {
|
|
22727
|
+
this.os = os78;
|
|
22714
22728
|
}
|
|
22715
22729
|
async prepareLaunch() {
|
|
22716
22730
|
const binary = this.os.findInPath("agy");
|
|
@@ -22807,21 +22821,21 @@ var AntigravityRuntimeStrategy = class {
|
|
|
22807
22821
|
|
|
22808
22822
|
// src/agents/registry.ts
|
|
22809
22823
|
var runtimeBuilders = {
|
|
22810
|
-
claude: (
|
|
22811
|
-
codex: (
|
|
22812
|
-
coderabbit: (
|
|
22813
|
-
cursor: (
|
|
22814
|
-
aider: (
|
|
22815
|
-
gemini: (
|
|
22816
|
-
kimi: (
|
|
22817
|
-
opencode: (
|
|
22818
|
-
antigravity: (
|
|
22824
|
+
claude: (os78) => new ClaudeRuntimeStrategy(os78),
|
|
22825
|
+
codex: (os78) => new CodexRuntimeStrategy(os78),
|
|
22826
|
+
coderabbit: (os78) => new CoderabbitRuntimeStrategy(os78),
|
|
22827
|
+
cursor: (os78) => new CursorRuntimeStrategy(os78),
|
|
22828
|
+
aider: (os78) => new AiderRuntimeStrategy(os78),
|
|
22829
|
+
gemini: (os78) => new GeminiRuntimeStrategy(os78),
|
|
22830
|
+
kimi: (os78) => new KimiRuntimeStrategy(os78),
|
|
22831
|
+
opencode: (os78) => new OpencodeRuntimeStrategy(os78),
|
|
22832
|
+
antigravity: (os78) => new AntigravityRuntimeStrategy(os78)
|
|
22819
22833
|
};
|
|
22820
22834
|
var deployBuilders = {
|
|
22821
22835
|
claude: () => new ClaudeDeployStrategy(),
|
|
22822
22836
|
codex: () => new CodexDeployStrategy()
|
|
22823
22837
|
};
|
|
22824
|
-
function createAgentStrategy(agent,
|
|
22838
|
+
function createAgentStrategy(agent, os78 = createOsStrategy()) {
|
|
22825
22839
|
if (!AGENT_REGISTRY[agent]?.enabled) {
|
|
22826
22840
|
throw new Error(
|
|
22827
22841
|
`Agent "${agent}" is not supported in this codeam-cli version. Upgrade with 'npm i -g codeam-cli@latest'.`
|
|
@@ -22831,10 +22845,10 @@ function createAgentStrategy(agent, os76 = createOsStrategy()) {
|
|
|
22831
22845
|
if (!build) {
|
|
22832
22846
|
throw new Error(`No runtime strategy registered for agent "${agent}"`);
|
|
22833
22847
|
}
|
|
22834
|
-
return build(
|
|
22848
|
+
return build(os78);
|
|
22835
22849
|
}
|
|
22836
|
-
function createInteractiveAgentStrategy(agent,
|
|
22837
|
-
const s = createAgentStrategy(agent,
|
|
22850
|
+
function createInteractiveAgentStrategy(agent, os78 = createOsStrategy()) {
|
|
22851
|
+
const s = createAgentStrategy(agent, os78);
|
|
22838
22852
|
if (s.mode !== "interactive") {
|
|
22839
22853
|
throw new Error(
|
|
22840
22854
|
`Agent "${agent}" is a batch agent; use createAgentStrategy + .runOneShot for one-shot reviews.`
|
|
@@ -23548,8 +23562,8 @@ function collectChangedFiles(cwd) {
|
|
|
23548
23562
|
}
|
|
23549
23563
|
return [...byPath.values()];
|
|
23550
23564
|
}
|
|
23551
|
-
function restoreCoderabbitOauthBlob(
|
|
23552
|
-
const dir = path42.join(
|
|
23565
|
+
function restoreCoderabbitOauthBlob(os78, value) {
|
|
23566
|
+
const dir = path42.join(os78.homeDir(), ".coderabbit");
|
|
23553
23567
|
(0, import_node_fs7.mkdirSync)(dir, { recursive: true });
|
|
23554
23568
|
let file = "auth.json";
|
|
23555
23569
|
let contents = value.trim();
|
|
@@ -23569,26 +23583,26 @@ function installFailureMessage(result) {
|
|
|
23569
23583
|
return result.error ?? "CodeRabbit CLI could not be installed";
|
|
23570
23584
|
}
|
|
23571
23585
|
async function configureCoderabbit(input, deps = {}) {
|
|
23572
|
-
const
|
|
23586
|
+
const os78 = deps.os ?? createOsStrategy();
|
|
23573
23587
|
const ensureInstalled = deps.ensureInstalled ?? ensureCoderabbitInstalled;
|
|
23574
23588
|
const isLoggedIn = deps.isLoggedIn ?? defaultIsLoggedIn;
|
|
23575
23589
|
const runOAuth = deps.runOAuthLogin ?? runCoderabbitOAuthLogin;
|
|
23576
23590
|
const snapshot = deps.snapshotDir ?? (() => snapshotCredentialDir());
|
|
23577
23591
|
const capture2 = deps.captureCredential ?? ((b) => diffCapturedCredential(b));
|
|
23578
23592
|
const loginWithApiKey = deps.loginWithApiKey ?? defaultLoginWithApiKey;
|
|
23579
|
-
const home =
|
|
23580
|
-
|
|
23581
|
-
|
|
23593
|
+
const home = os78.homeDir();
|
|
23594
|
+
os78.augmentPath(
|
|
23595
|
+
os78.id === "win32" ? [
|
|
23582
23596
|
path42.join(home, ".local", "bin"),
|
|
23583
23597
|
path42.join(process.env.APPDATA ?? path42.join(home, "AppData", "Roaming"), "npm"),
|
|
23584
23598
|
path42.join(home, "scoop", "shims")
|
|
23585
23599
|
] : [path42.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"]
|
|
23586
23600
|
);
|
|
23587
|
-
const installed2 =
|
|
23601
|
+
const installed2 = os78.findInPath("coderabbit") !== null;
|
|
23588
23602
|
const base = () => ({
|
|
23589
23603
|
action: input.action,
|
|
23590
23604
|
supported: true,
|
|
23591
|
-
installed:
|
|
23605
|
+
installed: os78.findInPath("coderabbit") !== null,
|
|
23592
23606
|
loggedIn: false
|
|
23593
23607
|
});
|
|
23594
23608
|
if (input.action === "status") {
|
|
@@ -23602,7 +23616,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
23602
23616
|
const key = (input.apiKey ?? "").trim();
|
|
23603
23617
|
if (!key) return { ...res2, error: "No API key provided" };
|
|
23604
23618
|
if (!res2.installed) {
|
|
23605
|
-
const inst = await ensureInstalled(
|
|
23619
|
+
const inst = await ensureInstalled(os78);
|
|
23606
23620
|
res2.installed = inst.ok;
|
|
23607
23621
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
23608
23622
|
}
|
|
@@ -23626,7 +23640,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
23626
23640
|
}
|
|
23627
23641
|
if (!res2.installed) {
|
|
23628
23642
|
deps.onEvent?.({ kind: "installing" });
|
|
23629
|
-
const inst = await ensureInstalled(
|
|
23643
|
+
const inst = await ensureInstalled(os78);
|
|
23630
23644
|
res2.installed = inst.ok;
|
|
23631
23645
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
23632
23646
|
}
|
|
@@ -23643,7 +23657,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
23643
23657
|
return { ...res2, loggedIn: true, linked: true };
|
|
23644
23658
|
}
|
|
23645
23659
|
try {
|
|
23646
|
-
restoreCoderabbitOauthBlob(
|
|
23660
|
+
restoreCoderabbitOauthBlob(os78, cred.credential);
|
|
23647
23661
|
} catch (err) {
|
|
23648
23662
|
return {
|
|
23649
23663
|
...res2,
|
|
@@ -23667,7 +23681,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
23667
23681
|
const res2 = base();
|
|
23668
23682
|
if (!installed2) {
|
|
23669
23683
|
deps.onEvent?.({ kind: "installing" });
|
|
23670
|
-
const inst = await ensureInstalled(
|
|
23684
|
+
const inst = await ensureInstalled(os78);
|
|
23671
23685
|
res2.installed = inst.ok;
|
|
23672
23686
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
23673
23687
|
}
|
|
@@ -23707,7 +23721,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
23707
23721
|
}
|
|
23708
23722
|
const res = base();
|
|
23709
23723
|
if (!res.installed) {
|
|
23710
|
-
const inst = await ensureInstalled(
|
|
23724
|
+
const inst = await ensureInstalled(os78);
|
|
23711
23725
|
res.installed = inst.ok;
|
|
23712
23726
|
if (!inst.ok) return { ...res, error: installFailureMessage(inst) };
|
|
23713
23727
|
}
|
|
@@ -27031,6 +27045,111 @@ function classifyProviderBilling(text, env) {
|
|
|
27031
27045
|
};
|
|
27032
27046
|
}
|
|
27033
27047
|
|
|
27048
|
+
// src/agents/antigravity/reply-failure.ts
|
|
27049
|
+
var fs58 = __toESM(require("fs"));
|
|
27050
|
+
var os42 = __toESM(require("os"));
|
|
27051
|
+
var path65 = __toESM(require("path"));
|
|
27052
|
+
var AGY_TERMINATED_RE = /Agent execution terminated due to error/i;
|
|
27053
|
+
var AGY_ERROR_REPLY_MAX = 1e3;
|
|
27054
|
+
var AUTH_CAUSE_RE = new RegExp(
|
|
27055
|
+
[
|
|
27056
|
+
"API_KEY_INVALID",
|
|
27057
|
+
"API key not valid",
|
|
27058
|
+
"API key expired",
|
|
27059
|
+
"\\bUNAUTHENTICATED\\b",
|
|
27060
|
+
"invalid authentication credentials",
|
|
27061
|
+
"(?:Error|code|status)[:\\s]*401\\b",
|
|
27062
|
+
"\\binvalid_grant\\b",
|
|
27063
|
+
"Token has been expired or revoked",
|
|
27064
|
+
// PERMISSION_DENIED is auth only with a credential reason (a blocked or
|
|
27065
|
+
// unregistered key, an under-scoped token) — not e.g. a disabled API.
|
|
27066
|
+
"PERMISSION_DENIED[^\\n]{0,400}?(?:API_KEY_\\w+|ACCESS_TOKEN_\\w+|CREDENTIALS_MISSING|CONSUMER_INVALID|unregistered callers)"
|
|
27067
|
+
].join("|"),
|
|
27068
|
+
"i"
|
|
27069
|
+
);
|
|
27070
|
+
var AGY_LOG_TAIL_BYTES = 16 * 1024;
|
|
27071
|
+
var SINCE_SLACK_MS = 2e3;
|
|
27072
|
+
var GLOG_PREFIX_RE = /^([IWEF])(\d{2})(\d{2}) (\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,6}))?\s/;
|
|
27073
|
+
function antigravityLogDir(home) {
|
|
27074
|
+
return path65.join(home, ".gemini", "antigravity-cli", "log");
|
|
27075
|
+
}
|
|
27076
|
+
function newestAcpServerLog(home) {
|
|
27077
|
+
const dir = antigravityLogDir(home);
|
|
27078
|
+
let best = null;
|
|
27079
|
+
for (const name of fs58.readdirSync(dir)) {
|
|
27080
|
+
if (!/^acp-server-.*\.log$/.test(name)) continue;
|
|
27081
|
+
const file = path65.join(dir, name);
|
|
27082
|
+
const mtime = fs58.statSync(file).mtimeMs;
|
|
27083
|
+
if (!best || mtime > best.mtime) best = { file, mtime };
|
|
27084
|
+
}
|
|
27085
|
+
return best?.file ?? null;
|
|
27086
|
+
}
|
|
27087
|
+
function readTail(file, bytes) {
|
|
27088
|
+
const fd = fs58.openSync(file, "r");
|
|
27089
|
+
try {
|
|
27090
|
+
const size = fs58.fstatSync(fd).size;
|
|
27091
|
+
const start2 = Math.max(0, size - bytes);
|
|
27092
|
+
const buf = Buffer.alloc(size - start2);
|
|
27093
|
+
fs58.readSync(fd, buf, 0, buf.length, start2);
|
|
27094
|
+
return buf.toString("utf8");
|
|
27095
|
+
} finally {
|
|
27096
|
+
fs58.closeSync(fd);
|
|
27097
|
+
}
|
|
27098
|
+
}
|
|
27099
|
+
function glogTime(m, now) {
|
|
27100
|
+
const year = new Date(now).getFullYear();
|
|
27101
|
+
const ms = Number((m[7] ?? "0").padEnd(3, "0").slice(0, 3));
|
|
27102
|
+
const at3 = (y2) => new Date(y2, Number(m[2]) - 1, Number(m[3]), Number(m[4]), Number(m[5]), Number(m[6]), ms).getTime();
|
|
27103
|
+
const t2 = at3(year);
|
|
27104
|
+
return t2 > now + 864e5 ? at3(year - 1) : t2;
|
|
27105
|
+
}
|
|
27106
|
+
function recentErrorEntries(tail, since, now = Date.now()) {
|
|
27107
|
+
const out2 = [];
|
|
27108
|
+
let keep = false;
|
|
27109
|
+
for (const line of tail.split("\n")) {
|
|
27110
|
+
const m = GLOG_PREFIX_RE.exec(line);
|
|
27111
|
+
if (m) {
|
|
27112
|
+
const severe = m[1] === "E" || m[1] === "F";
|
|
27113
|
+
keep = severe && (since === void 0 || glogTime(m, now) >= since - SINCE_SLACK_MS);
|
|
27114
|
+
if (keep) out2.push(line);
|
|
27115
|
+
} else if (keep && out2.length > 0) {
|
|
27116
|
+
out2[out2.length - 1] += `
|
|
27117
|
+
${line}`;
|
|
27118
|
+
}
|
|
27119
|
+
}
|
|
27120
|
+
return out2;
|
|
27121
|
+
}
|
|
27122
|
+
function redactCredentials(text) {
|
|
27123
|
+
return text.replace(/AIza[0-9A-Za-z_-]{10,}/g, "AIza\u2026[redacted]").replace(/ya29\.[0-9A-Za-z._-]+/g, "ya29.\u2026[redacted]").replace(/1\/\/[0-9A-Za-z._-]{10,}/g, "1//\u2026[redacted]");
|
|
27124
|
+
}
|
|
27125
|
+
function authCauseFromLog(home, since) {
|
|
27126
|
+
try {
|
|
27127
|
+
const file = newestAcpServerLog(home);
|
|
27128
|
+
if (!file) return null;
|
|
27129
|
+
const entries2 = recentErrorEntries(readTail(file, AGY_LOG_TAIL_BYTES), since);
|
|
27130
|
+
for (let i = entries2.length - 1; i >= 0; i--) {
|
|
27131
|
+
if (AUTH_CAUSE_RE.test(entries2[i])) return entries2[i];
|
|
27132
|
+
}
|
|
27133
|
+
return null;
|
|
27134
|
+
} catch {
|
|
27135
|
+
return null;
|
|
27136
|
+
}
|
|
27137
|
+
}
|
|
27138
|
+
function classifyAntigravityReply(finalText, ctx = {}) {
|
|
27139
|
+
const t2 = finalText.trim();
|
|
27140
|
+
if (t2.length === 0 || t2.length > AGY_ERROR_REPLY_MAX) return null;
|
|
27141
|
+
if (!AGY_TERMINATED_RE.test(t2)) return null;
|
|
27142
|
+
if (AUTH_CAUSE_RE.test(t2)) return "auth_failed";
|
|
27143
|
+
const home = ctx.env?.HOME || os42.homedir();
|
|
27144
|
+
const cause = authCauseFromLog(home, ctx.turnStartedAt);
|
|
27145
|
+
if (!cause) return "agent_error";
|
|
27146
|
+
log.info(
|
|
27147
|
+
"acpRunner",
|
|
27148
|
+
`antigravity: credential failure in agy log \u2014 ${redactCredentials(cause).slice(0, 300)}`
|
|
27149
|
+
);
|
|
27150
|
+
return "auth_failed";
|
|
27151
|
+
}
|
|
27152
|
+
|
|
27034
27153
|
// src/agents/acp/agent-hooks.ts
|
|
27035
27154
|
function replyIsCursorUpgradeRequired(finalText) {
|
|
27036
27155
|
const t2 = finalText.trim().toLowerCase();
|
|
@@ -27071,6 +27190,9 @@ var ACP_AGENT_HOOKS = {
|
|
|
27071
27190
|
cursor: {
|
|
27072
27191
|
statusPage: { vendor: "Cursor", url: "https://status.cursor.com" },
|
|
27073
27192
|
classifyCompletedReply: (finalText) => replyIsCursorUpgradeRequired(finalText) ? "upgrade_required" : null
|
|
27193
|
+
},
|
|
27194
|
+
antigravity: {
|
|
27195
|
+
classifyCompletedReply: classifyAntigravityReply
|
|
27074
27196
|
}
|
|
27075
27197
|
};
|
|
27076
27198
|
function agentHooks(agent) {
|
|
@@ -27157,7 +27279,11 @@ function completedReplyFailureBubble(opts) {
|
|
|
27157
27279
|
if (replyIsByoProviderBilling(opts.finalText, env)) {
|
|
27158
27280
|
return byoProviderBillingMessage(byoProviderName({ env, agent: opts.agent }));
|
|
27159
27281
|
}
|
|
27160
|
-
|
|
27282
|
+
const agentReplyClass = agentHooks(opts.agent)?.classifyCompletedReply?.(opts.finalText, { env });
|
|
27283
|
+
if (agentReplyClass === "auth_failed" || replyIsAuthFailure(opts.finalText)) {
|
|
27284
|
+
return AUTH_FAILURE_MESSAGE;
|
|
27285
|
+
}
|
|
27286
|
+
if (agentReplyClass === "agent_error") return TURN_FAILURE_MESSAGE;
|
|
27161
27287
|
return null;
|
|
27162
27288
|
}
|
|
27163
27289
|
function houseAgentLimitMessage(text) {
|
|
@@ -27308,8 +27434,8 @@ function adapterExitMessage(opts) {
|
|
|
27308
27434
|
|
|
27309
27435
|
// src/services/preview/start-orchestrator.ts
|
|
27310
27436
|
var import_child_process20 = require("child_process");
|
|
27311
|
-
var
|
|
27312
|
-
var
|
|
27437
|
+
var fs62 = __toESM(require("fs"));
|
|
27438
|
+
var path69 = __toESM(require("path"));
|
|
27313
27439
|
var import_which3 = __toESM(require("which"));
|
|
27314
27440
|
|
|
27315
27441
|
// src/services/preview/detection-cwd.ts
|
|
@@ -27343,13 +27469,13 @@ function resolveDetectionCwd(root, cwd) {
|
|
|
27343
27469
|
|
|
27344
27470
|
// src/services/project-env/index.ts
|
|
27345
27471
|
var import_fs6 = require("fs");
|
|
27346
|
-
var
|
|
27472
|
+
var path68 = __toESM(require("path"));
|
|
27347
27473
|
|
|
27348
27474
|
// src/beads/project-key.ts
|
|
27349
27475
|
var import_child_process19 = require("child_process");
|
|
27350
27476
|
var crypto2 = __toESM(require("crypto"));
|
|
27351
|
-
var
|
|
27352
|
-
var
|
|
27477
|
+
var fs60 = __toESM(require("fs"));
|
|
27478
|
+
var path67 = __toESM(require("path"));
|
|
27353
27479
|
function normalizeOrigin(raw) {
|
|
27354
27480
|
const trimmed = raw.trim();
|
|
27355
27481
|
if (!trimmed) return null;
|
|
@@ -27375,17 +27501,17 @@ function normalizeOrigin(raw) {
|
|
|
27375
27501
|
return `${host2}/${pathPart}`;
|
|
27376
27502
|
}
|
|
27377
27503
|
function findRepoRoot(cwd) {
|
|
27378
|
-
let dir =
|
|
27504
|
+
let dir = path67.resolve(cwd);
|
|
27379
27505
|
const seen2 = /* @__PURE__ */ new Set();
|
|
27380
27506
|
for (let i = 0; i < 256; i++) {
|
|
27381
27507
|
if (seen2.has(dir)) return null;
|
|
27382
27508
|
seen2.add(dir);
|
|
27383
27509
|
try {
|
|
27384
|
-
const stat3 =
|
|
27510
|
+
const stat3 = fs60.statSync(path67.join(dir, ".git"), { throwIfNoEntry: false });
|
|
27385
27511
|
if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
|
|
27386
27512
|
} catch {
|
|
27387
27513
|
}
|
|
27388
|
-
const parent =
|
|
27514
|
+
const parent = path67.dirname(dir);
|
|
27389
27515
|
if (parent === dir) return null;
|
|
27390
27516
|
dir = parent;
|
|
27391
27517
|
}
|
|
@@ -27396,7 +27522,7 @@ var _execSeam3 = {
|
|
|
27396
27522
|
const out2 = (0, import_child_process19.execFileSync)(file, args2, opts);
|
|
27397
27523
|
return typeof out2 === "string" ? out2 : out2.toString("utf8");
|
|
27398
27524
|
},
|
|
27399
|
-
realpath: (p2) =>
|
|
27525
|
+
realpath: (p2) => fs60.realpathSync(p2)
|
|
27400
27526
|
};
|
|
27401
27527
|
function readOrigin(cwd) {
|
|
27402
27528
|
try {
|
|
@@ -27425,7 +27551,7 @@ function deriveProjectIdentity(cwd = process.cwd()) {
|
|
|
27425
27551
|
} catch {
|
|
27426
27552
|
}
|
|
27427
27553
|
const hash = crypto2.createHash("sha256").update(real).digest("hex");
|
|
27428
|
-
return { projectKey: `path:${hash}`, projectLabel:
|
|
27554
|
+
return { projectKey: `path:${hash}`, projectLabel: path67.basename(real) || "project" };
|
|
27429
27555
|
}
|
|
27430
27556
|
|
|
27431
27557
|
// src/services/project-env/index.ts
|
|
@@ -27438,7 +27564,7 @@ async function readIfExists(p2) {
|
|
|
27438
27564
|
}
|
|
27439
27565
|
async function syncProjectEnvUp(cwd, ctx) {
|
|
27440
27566
|
if (!ctx.pluginAuthToken) return;
|
|
27441
|
-
const content = await readIfExists(
|
|
27567
|
+
const content = await readIfExists(path68.join(cwd, ".env"));
|
|
27442
27568
|
if (content == null) return;
|
|
27443
27569
|
try {
|
|
27444
27570
|
const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
|
|
@@ -27460,7 +27586,7 @@ async function syncProjectEnvUp(cwd, ctx) {
|
|
|
27460
27586
|
}
|
|
27461
27587
|
async function restoreProjectEnvIfMissing(cwd, ctx) {
|
|
27462
27588
|
if (!ctx.pluginAuthToken) return false;
|
|
27463
|
-
const envPath =
|
|
27589
|
+
const envPath = path68.join(cwd, ".env");
|
|
27464
27590
|
if (await readIfExists(envPath) != null) return false;
|
|
27465
27591
|
try {
|
|
27466
27592
|
const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
|
|
@@ -27471,7 +27597,7 @@ async function restoreProjectEnvIfMissing(cwd, ctx) {
|
|
|
27471
27597
|
projectKey
|
|
27472
27598
|
});
|
|
27473
27599
|
if (!stored) return false;
|
|
27474
|
-
const tmp =
|
|
27600
|
+
const tmp = path68.join(cwd, ".env.codeam-restore.tmp");
|
|
27475
27601
|
await import_fs6.promises.writeFile(tmp, stored.content, { encoding: "utf8", mode: 384 });
|
|
27476
27602
|
await import_fs6.promises.rename(tmp, envPath);
|
|
27477
27603
|
log.info("project-env", `restored .env (${stored.keyCount} vars) for ${projectLabel}`);
|
|
@@ -27787,8 +27913,8 @@ function normalizeDetectionForSpawn(detection, cwd) {
|
|
|
27787
27913
|
if (args2.length === 0) return detection;
|
|
27788
27914
|
const binName = args2[0];
|
|
27789
27915
|
if (binName.startsWith("-")) return detection;
|
|
27790
|
-
const binPath =
|
|
27791
|
-
if (!
|
|
27916
|
+
const binPath = path69.join(cwd, "node_modules", ".bin", binName);
|
|
27917
|
+
if (!fs62.existsSync(binPath)) return detection;
|
|
27792
27918
|
return {
|
|
27793
27919
|
...detection,
|
|
27794
27920
|
command: binPath,
|
|
@@ -28136,7 +28262,7 @@ async function startDevServer(ctx, extraEnv = {}) {
|
|
|
28136
28262
|
killProcessTree(devServer, "SIGTERM");
|
|
28137
28263
|
emit2(USER_EVENTS.PREVIEW_ERROR, {
|
|
28138
28264
|
stage: "spawn",
|
|
28139
|
-
message: describeSpawnFailure(spawnError, spawnable.command,
|
|
28265
|
+
message: describeSpawnFailure(spawnError, spawnable.command, path69.relative(ctx.rootCwd, cwd)) ?? `The dev server exited (code ${outcome.code}) before it was ready. It may need a database or other services.`,
|
|
28140
28266
|
stderrTail: stripAnsi(outputTail).slice(-8e3)
|
|
28141
28267
|
});
|
|
28142
28268
|
return null;
|
|
@@ -28271,9 +28397,9 @@ function describeSpawnFailure(err, command2, relDir) {
|
|
|
28271
28397
|
|
|
28272
28398
|
// src/beads/bd-adapter.ts
|
|
28273
28399
|
var import_child_process21 = require("child_process");
|
|
28274
|
-
var
|
|
28275
|
-
var
|
|
28276
|
-
var
|
|
28400
|
+
var fs63 = __toESM(require("fs"));
|
|
28401
|
+
var os43 = __toESM(require("os"));
|
|
28402
|
+
var path70 = __toESM(require("path"));
|
|
28277
28403
|
|
|
28278
28404
|
// src/beads/schema-migrate.ts
|
|
28279
28405
|
var SCHEMA_SKEW_RE = /Error 1146|table not found|refusing to auto-apply \d+ pending schema migration/i;
|
|
@@ -28322,11 +28448,11 @@ function _defaultResolveBundled() {
|
|
|
28322
28448
|
} catch {
|
|
28323
28449
|
return null;
|
|
28324
28450
|
}
|
|
28325
|
-
const binDir =
|
|
28451
|
+
const binDir = path70.join(path70.dirname(pkgJsonPath), "bin");
|
|
28326
28452
|
const binaryName = process.platform === "win32" ? "bd.exe" : "bd";
|
|
28327
|
-
const binaryPath =
|
|
28453
|
+
const binaryPath = path70.join(binDir, binaryName);
|
|
28328
28454
|
try {
|
|
28329
|
-
|
|
28455
|
+
fs63.accessSync(binaryPath, fs63.constants.F_OK);
|
|
28330
28456
|
return binaryPath;
|
|
28331
28457
|
} catch {
|
|
28332
28458
|
return null;
|
|
@@ -28336,13 +28462,13 @@ function resolveBdOnPath() {
|
|
|
28336
28462
|
return _resolveSeam.resolveOnPath();
|
|
28337
28463
|
}
|
|
28338
28464
|
function _defaultResolveOnPath() {
|
|
28339
|
-
const dirs = (process.env.PATH ?? "").split(
|
|
28465
|
+
const dirs = (process.env.PATH ?? "").split(path70.delimiter).filter(Boolean);
|
|
28340
28466
|
const candidates = process.platform === "win32" ? ["bd.exe", "bd.cmd", "bd"] : ["bd"];
|
|
28341
28467
|
for (const dir of dirs) {
|
|
28342
28468
|
for (const candidate of candidates) {
|
|
28343
|
-
const full =
|
|
28469
|
+
const full = path70.join(dir, candidate);
|
|
28344
28470
|
try {
|
|
28345
|
-
|
|
28471
|
+
fs63.accessSync(full, fs63.constants.F_OK);
|
|
28346
28472
|
return full;
|
|
28347
28473
|
} catch {
|
|
28348
28474
|
}
|
|
@@ -28429,7 +28555,7 @@ var BdAdapter = class {
|
|
|
28429
28555
|
const env = { ...process.env };
|
|
28430
28556
|
if (!env.HOME) {
|
|
28431
28557
|
try {
|
|
28432
|
-
const home =
|
|
28558
|
+
const home = os43.homedir();
|
|
28433
28559
|
if (home) env.HOME = home;
|
|
28434
28560
|
} catch {
|
|
28435
28561
|
}
|
|
@@ -28531,9 +28657,9 @@ function coerceIssue(row, projectKey) {
|
|
|
28531
28657
|
|
|
28532
28658
|
// src/beads/provisioner.ts
|
|
28533
28659
|
var import_child_process24 = require("child_process");
|
|
28534
|
-
var
|
|
28535
|
-
var
|
|
28536
|
-
var
|
|
28660
|
+
var fs65 = __toESM(require("fs"));
|
|
28661
|
+
var os45 = __toESM(require("os"));
|
|
28662
|
+
var path72 = __toESM(require("path"));
|
|
28537
28663
|
|
|
28538
28664
|
// src/beads/install-bd.ts
|
|
28539
28665
|
var import_child_process22 = require("child_process");
|
|
@@ -28598,9 +28724,9 @@ async function installBd(platform3 = process.platform) {
|
|
|
28598
28724
|
|
|
28599
28725
|
// src/beads/install-dolt.ts
|
|
28600
28726
|
var import_child_process23 = require("child_process");
|
|
28601
|
-
var
|
|
28602
|
-
var
|
|
28603
|
-
var
|
|
28727
|
+
var fs64 = __toESM(require("fs"));
|
|
28728
|
+
var os44 = __toESM(require("os"));
|
|
28729
|
+
var path71 = __toESM(require("path"));
|
|
28604
28730
|
var DOLT_INSTALL_SH_URL = "https://github.com/dolthub/dolt/releases/latest/download/install.sh";
|
|
28605
28731
|
var DOLT_MSI_URL = "https://github.com/dolthub/dolt/releases/latest/download/dolt-windows-amd64.msi";
|
|
28606
28732
|
function resolveDoltInstallStrategy(platform3) {
|
|
@@ -28640,11 +28766,11 @@ function resolveDoltInstallStrategy(platform3) {
|
|
|
28640
28766
|
}
|
|
28641
28767
|
var DOLT_RELEASE_BASE = "https://github.com/dolthub/dolt/releases/latest/download";
|
|
28642
28768
|
function doltPlatformTuple(platform3, arch2) {
|
|
28643
|
-
const
|
|
28769
|
+
const os78 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
|
|
28644
28770
|
const a = arch2 === "x64" ? "amd64" : arch2 === "arm64" ? "arm64" : null;
|
|
28645
28771
|
if (!a) return null;
|
|
28646
|
-
if (
|
|
28647
|
-
return `${
|
|
28772
|
+
if (os78 === "windows" && a !== "amd64") return null;
|
|
28773
|
+
return `${os78}-${a}`;
|
|
28648
28774
|
}
|
|
28649
28775
|
function resolveDoltTarballStrategy(targetDir, platform3, arch2) {
|
|
28650
28776
|
const tuple = doltPlatformTuple(platform3, arch2);
|
|
@@ -28689,14 +28815,14 @@ async function installDoltToDir(targetDir, platform3 = process.platform, arch2 =
|
|
|
28689
28815
|
return result;
|
|
28690
28816
|
}
|
|
28691
28817
|
var _doltPathSeam = {
|
|
28692
|
-
homedir: () =>
|
|
28818
|
+
homedir: () => os44.homedir(),
|
|
28693
28819
|
getPath: () => process.env.PATH ?? "",
|
|
28694
28820
|
setPath: (p2) => {
|
|
28695
28821
|
process.env.PATH = p2;
|
|
28696
28822
|
},
|
|
28697
28823
|
exists: (p2) => {
|
|
28698
28824
|
try {
|
|
28699
|
-
|
|
28825
|
+
fs64.accessSync(p2, fs64.constants.F_OK);
|
|
28700
28826
|
return true;
|
|
28701
28827
|
} catch {
|
|
28702
28828
|
return false;
|
|
@@ -28707,7 +28833,7 @@ function doltBinaryNames(platform3) {
|
|
|
28707
28833
|
return platform3 === "win32" ? ["dolt.exe", "dolt.cmd", "dolt"] : ["dolt"];
|
|
28708
28834
|
}
|
|
28709
28835
|
function knownDoltDirs(platform3) {
|
|
28710
|
-
const P3 = platform3 === "win32" ?
|
|
28836
|
+
const P3 = platform3 === "win32" ? path71.win32 : path71.posix;
|
|
28711
28837
|
const home = _doltPathSeam.homedir();
|
|
28712
28838
|
if (platform3 === "win32") {
|
|
28713
28839
|
return [
|
|
@@ -28723,7 +28849,7 @@ function knownDoltDirs(platform3) {
|
|
|
28723
28849
|
].filter(Boolean);
|
|
28724
28850
|
}
|
|
28725
28851
|
function ensureDoltResolvable(platform3 = process.platform) {
|
|
28726
|
-
const P3 = platform3 === "win32" ?
|
|
28852
|
+
const P3 = platform3 === "win32" ? path71.win32 : path71.posix;
|
|
28727
28853
|
const delim = platform3 === "win32" ? ";" : ":";
|
|
28728
28854
|
const names = doltBinaryNames(platform3);
|
|
28729
28855
|
const pathDirs = _doltPathSeam.getPath().split(delim).filter(Boolean);
|
|
@@ -28902,10 +29028,10 @@ var _provisionSeam = {
|
|
|
28902
29028
|
/** Does the project's git remote carry Dolt data (`refs/dolt/data`)? */
|
|
28903
29029
|
remoteHasDoltData,
|
|
28904
29030
|
/** Throwaway cwd for a user-level-only `bd setup` (see GLOBAL_ONLY_RECIPES). */
|
|
28905
|
-
makeSetupCwd: () =>
|
|
29031
|
+
makeSetupCwd: () => fs65.mkdtempSync(path72.join(os45.tmpdir(), "codeam-bd-setup-")),
|
|
28906
29032
|
removeSetupCwd: (dir) => {
|
|
28907
29033
|
try {
|
|
28908
|
-
|
|
29034
|
+
fs65.rmSync(dir, { recursive: true, force: true });
|
|
28909
29035
|
} catch {
|
|
28910
29036
|
}
|
|
28911
29037
|
}
|
|
@@ -28927,17 +29053,17 @@ function remoteHasDoltData(cwd) {
|
|
|
28927
29053
|
}
|
|
28928
29054
|
var _linkSeam = {
|
|
28929
29055
|
platform: () => process.platform,
|
|
28930
|
-
homedir: () =>
|
|
29056
|
+
homedir: () => os45.homedir(),
|
|
28931
29057
|
isWritableDir: (dir) => {
|
|
28932
29058
|
try {
|
|
28933
|
-
|
|
29059
|
+
fs65.accessSync(dir, fs65.constants.W_OK);
|
|
28934
29060
|
return true;
|
|
28935
29061
|
} catch {
|
|
28936
29062
|
return false;
|
|
28937
29063
|
}
|
|
28938
29064
|
},
|
|
28939
29065
|
ensureDir: (dir) => {
|
|
28940
|
-
|
|
29066
|
+
fs65.mkdirSync(dir, { recursive: true });
|
|
28941
29067
|
},
|
|
28942
29068
|
/**
|
|
28943
29069
|
* A directory to symlink `bd` into so the AGENT's shell + Claude Code's
|
|
@@ -28958,9 +29084,9 @@ var _linkSeam = {
|
|
|
28958
29084
|
* which `linkBdOntoPath` creates if missing.
|
|
28959
29085
|
*/
|
|
28960
29086
|
cliBinDir: () => {
|
|
28961
|
-
const pathDirs = (process.env.PATH ?? "").split(
|
|
29087
|
+
const pathDirs = (process.env.PATH ?? "").split(path72.delimiter).filter(Boolean);
|
|
28962
29088
|
const home = _linkSeam.homedir();
|
|
28963
|
-
const localBin = home ?
|
|
29089
|
+
const localBin = home ? path72.join(home, ".local", "bin") : null;
|
|
28964
29090
|
if (localBin) {
|
|
28965
29091
|
try {
|
|
28966
29092
|
_linkSeam.ensureDir(localBin);
|
|
@@ -28970,16 +29096,16 @@ var _linkSeam = {
|
|
|
28970
29096
|
const candidates = [];
|
|
28971
29097
|
if (localBin) candidates.push(localBin);
|
|
28972
29098
|
try {
|
|
28973
|
-
candidates.push(
|
|
29099
|
+
candidates.push(path72.dirname(process.execPath));
|
|
28974
29100
|
} catch {
|
|
28975
29101
|
}
|
|
28976
29102
|
candidates.push("/usr/local/bin");
|
|
28977
29103
|
const entry = process.argv[1];
|
|
28978
29104
|
if (entry) {
|
|
28979
29105
|
try {
|
|
28980
|
-
candidates.push(
|
|
29106
|
+
candidates.push(path72.dirname(fs65.realpathSync(entry)));
|
|
28981
29107
|
} catch {
|
|
28982
|
-
candidates.push(
|
|
29108
|
+
candidates.push(path72.dirname(entry));
|
|
28983
29109
|
}
|
|
28984
29110
|
}
|
|
28985
29111
|
const onPathWritable = candidates.find(
|
|
@@ -28991,20 +29117,20 @@ var _linkSeam = {
|
|
|
28991
29117
|
/** Current symlink target at `linkPath`, or null when absent / not a link. */
|
|
28992
29118
|
readlink: (linkPath) => {
|
|
28993
29119
|
try {
|
|
28994
|
-
return
|
|
29120
|
+
return fs65.readlinkSync(linkPath);
|
|
28995
29121
|
} catch {
|
|
28996
29122
|
return null;
|
|
28997
29123
|
}
|
|
28998
29124
|
},
|
|
28999
|
-
unlink: (linkPath) =>
|
|
29000
|
-
symlink: (target, linkPath) =>
|
|
29125
|
+
unlink: (linkPath) => fs65.unlinkSync(linkPath),
|
|
29126
|
+
symlink: (target, linkPath) => fs65.symlinkSync(target, linkPath)
|
|
29001
29127
|
};
|
|
29002
29128
|
function linkBdOntoPath(binaryPath) {
|
|
29003
29129
|
if (_linkSeam.platform() === "win32") return;
|
|
29004
29130
|
const binDir = _linkSeam.cliBinDir();
|
|
29005
29131
|
if (!binDir) return;
|
|
29006
29132
|
_linkSeam.ensureDir(binDir);
|
|
29007
|
-
const linkPath =
|
|
29133
|
+
const linkPath = path72.join(binDir, "bd");
|
|
29008
29134
|
if (linkPath === binaryPath) return;
|
|
29009
29135
|
const current2 = _linkSeam.readlink(linkPath);
|
|
29010
29136
|
if (current2 === binaryPath) return;
|
|
@@ -29242,16 +29368,16 @@ function dedupeRecipes(agents) {
|
|
|
29242
29368
|
}
|
|
29243
29369
|
function ensureLocalGitExclude(cwd, patterns) {
|
|
29244
29370
|
try {
|
|
29245
|
-
const gitDir =
|
|
29246
|
-
if (!
|
|
29247
|
-
const file =
|
|
29248
|
-
|
|
29249
|
-
const current2 =
|
|
29371
|
+
const gitDir = path72.join(cwd, ".git");
|
|
29372
|
+
if (!fs65.statSync(gitDir).isDirectory()) return;
|
|
29373
|
+
const file = path72.join(gitDir, "info", "exclude");
|
|
29374
|
+
fs65.mkdirSync(path72.dirname(file), { recursive: true });
|
|
29375
|
+
const current2 = fs65.existsSync(file) ? fs65.readFileSync(file, "utf8") : "";
|
|
29250
29376
|
const have = new Set(current2.split(/\r?\n/).map((l) => l.trim()));
|
|
29251
29377
|
const missing = patterns.filter((p2) => !have.has(p2));
|
|
29252
29378
|
if (missing.length === 0) return;
|
|
29253
29379
|
const prefix = current2.length > 0 && !current2.endsWith("\n") ? "\n" : "";
|
|
29254
|
-
|
|
29380
|
+
fs65.appendFileSync(file, `${prefix}# CodeAgent: beads state stays local
|
|
29255
29381
|
${missing.join("\n")}
|
|
29256
29382
|
`);
|
|
29257
29383
|
} catch {
|
|
@@ -29260,7 +29386,7 @@ ${missing.join("\n")}
|
|
|
29260
29386
|
|
|
29261
29387
|
// src/beads/watcher.ts
|
|
29262
29388
|
var crypto4 = __toESM(require("crypto"));
|
|
29263
|
-
var
|
|
29389
|
+
var path73 = __toESM(require("path"));
|
|
29264
29390
|
var API_BASE5 = resolveApiBaseUrl();
|
|
29265
29391
|
var DEBOUNCE_MS2 = 400;
|
|
29266
29392
|
var ZERO_SUMMARY = {
|
|
@@ -29284,7 +29410,7 @@ var BeadsWatcher = class {
|
|
|
29284
29410
|
constructor(opts) {
|
|
29285
29411
|
this.opts = opts;
|
|
29286
29412
|
this.bd = opts.adapter ?? new BdAdapter({ cwd: opts.cwd, beadsDir: opts.beadsDir });
|
|
29287
|
-
this.feedPath = opts.feedPath ??
|
|
29413
|
+
this.feedPath = opts.feedPath ?? path73.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
|
|
29288
29414
|
this.apiBase = opts.apiBaseUrl ?? API_BASE5;
|
|
29289
29415
|
}
|
|
29290
29416
|
opts;
|
|
@@ -29939,8 +30065,8 @@ function cleanupAttachmentTempFiles() {
|
|
|
29939
30065
|
function saveFilesTemp(files) {
|
|
29940
30066
|
return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
|
|
29941
30067
|
const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
|
|
29942
|
-
const tmpPath =
|
|
29943
|
-
|
|
30068
|
+
const tmpPath = path78.join(os51.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
|
|
30069
|
+
fs71.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
|
|
29944
30070
|
pendingAttachmentFiles.add(tmpPath);
|
|
29945
30071
|
return tmpPath;
|
|
29946
30072
|
});
|
|
@@ -30186,10 +30312,10 @@ var listFiles = async (ctx, cmd, parsed) => {
|
|
|
30186
30312
|
await ctx.relay.sendResult(cmd.id, "completed", result);
|
|
30187
30313
|
};
|
|
30188
30314
|
var envReadH = async (ctx, cmd) => {
|
|
30189
|
-
const envPath =
|
|
30315
|
+
const envPath = path78.join(process.cwd(), ".env");
|
|
30190
30316
|
await restoreProjectEnvIfMissing(process.cwd(), ctx);
|
|
30191
30317
|
try {
|
|
30192
|
-
const raw = await
|
|
30318
|
+
const raw = await fs71.promises.readFile(envPath, "utf8");
|
|
30193
30319
|
await ctx.relay.sendResult(cmd.id, "completed", {
|
|
30194
30320
|
exists: true,
|
|
30195
30321
|
vars: parseDotenv(raw)
|
|
@@ -30218,7 +30344,7 @@ var envParseH = async (ctx, cmd, parsed) => {
|
|
|
30218
30344
|
const existing = /* @__PURE__ */ new Map();
|
|
30219
30345
|
if (!replace) {
|
|
30220
30346
|
try {
|
|
30221
|
-
const raw = await
|
|
30347
|
+
const raw = await fs71.promises.readFile(path78.join(process.cwd(), ".env"), "utf8");
|
|
30222
30348
|
for (const v of parseDotenv(raw)) existing.set(v.key, v.value);
|
|
30223
30349
|
} catch {
|
|
30224
30350
|
}
|
|
@@ -30258,15 +30384,15 @@ var envWriteH = async (ctx, cmd, parsed) => {
|
|
|
30258
30384
|
}
|
|
30259
30385
|
seen2.add(v.key);
|
|
30260
30386
|
}
|
|
30261
|
-
const envPath =
|
|
30262
|
-
const tmpPath =
|
|
30387
|
+
const envPath = path78.join(process.cwd(), ".env");
|
|
30388
|
+
const tmpPath = path78.join(process.cwd(), ".env.codeam.tmp");
|
|
30263
30389
|
try {
|
|
30264
|
-
await
|
|
30265
|
-
await
|
|
30390
|
+
await fs71.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
|
|
30391
|
+
await fs71.promises.rename(tmpPath, envPath);
|
|
30266
30392
|
await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
|
|
30267
30393
|
void syncProjectEnvUp(process.cwd(), ctx);
|
|
30268
30394
|
} catch (err) {
|
|
30269
|
-
await
|
|
30395
|
+
await fs71.promises.rm(tmpPath, { force: true }).catch(() => void 0);
|
|
30270
30396
|
await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
|
|
30271
30397
|
}
|
|
30272
30398
|
};
|
|
@@ -30492,7 +30618,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
30492
30618
|
});
|
|
30493
30619
|
const token = ctx.pluginAuthToken;
|
|
30494
30620
|
void (async () => {
|
|
30495
|
-
const
|
|
30621
|
+
const os78 = createOsStrategy();
|
|
30496
30622
|
try {
|
|
30497
30623
|
const report = await reviewPullRequest(
|
|
30498
30624
|
{
|
|
@@ -30501,7 +30627,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
30501
30627
|
baseBranch: parsed.baseBranch
|
|
30502
30628
|
},
|
|
30503
30629
|
{
|
|
30504
|
-
runReview: (input) => new CoderabbitRuntimeStrategy(
|
|
30630
|
+
runReview: (input) => new CoderabbitRuntimeStrategy(os78).runOneShot(input),
|
|
30505
30631
|
runGh: (args2) => defaultRunGh(args2),
|
|
30506
30632
|
postReport: async (r) => {
|
|
30507
30633
|
if (!token) return;
|
|
@@ -30615,9 +30741,9 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
|
|
|
30615
30741
|
function buildNpmInstallInvocation(opts) {
|
|
30616
30742
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
30617
30743
|
const execPath = opts?.execPath ?? process.execPath;
|
|
30618
|
-
const exists2 = opts?.existsSync ??
|
|
30744
|
+
const exists2 = opts?.existsSync ?? fs71.existsSync;
|
|
30619
30745
|
const platform3 = opts?.platform ?? process.platform;
|
|
30620
|
-
const p2 = platform3 === "win32" ?
|
|
30746
|
+
const p2 = platform3 === "win32" ? path78.win32 : path78.posix;
|
|
30621
30747
|
const normalized = entryScript.split(/[\\/]/).join("/");
|
|
30622
30748
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
30623
30749
|
const markerIdx = normalized.indexOf(marker);
|
|
@@ -30636,7 +30762,7 @@ function isPermissionError(stderr) {
|
|
|
30636
30762
|
function resolveGlobalNodeModulesDir(opts) {
|
|
30637
30763
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
30638
30764
|
const platform3 = opts?.platform ?? process.platform;
|
|
30639
|
-
const p2 = platform3 === "win32" ?
|
|
30765
|
+
const p2 = platform3 === "win32" ? path78.win32 : path78.posix;
|
|
30640
30766
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
30641
30767
|
const markerIdx = entryScript.split(/[\\/]/).join("/").indexOf(marker);
|
|
30642
30768
|
if (markerIdx <= 0) return null;
|
|
@@ -30646,23 +30772,23 @@ function resolveGlobalNodeModulesDir(opts) {
|
|
|
30646
30772
|
var STALE_STAGING_AGE_MS = CLI_UPDATE_INSTALL_TIMEOUT_MS;
|
|
30647
30773
|
function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
30648
30774
|
if (!nodeModulesDir) return 0;
|
|
30649
|
-
const
|
|
30650
|
-
const
|
|
30651
|
-
const
|
|
30775
|
+
const readdirSync20 = deps?.readdirSync ?? fs71.readdirSync;
|
|
30776
|
+
const statSync19 = deps?.statSync ?? fs71.statSync;
|
|
30777
|
+
const rmSync16 = deps?.rmSync ?? fs71.rmSync;
|
|
30652
30778
|
let removed = 0;
|
|
30653
30779
|
let entries2;
|
|
30654
30780
|
try {
|
|
30655
|
-
entries2 =
|
|
30781
|
+
entries2 = readdirSync20(nodeModulesDir);
|
|
30656
30782
|
} catch {
|
|
30657
30783
|
return 0;
|
|
30658
30784
|
}
|
|
30659
30785
|
for (const name of entries2) {
|
|
30660
30786
|
if (!/^\.codeam-cli-/.test(name)) continue;
|
|
30661
|
-
const full =
|
|
30787
|
+
const full = path78.join(nodeModulesDir, name);
|
|
30662
30788
|
try {
|
|
30663
|
-
const st3 =
|
|
30789
|
+
const st3 = statSync19(full);
|
|
30664
30790
|
if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
|
|
30665
|
-
|
|
30791
|
+
rmSync16(full, { recursive: true, force: true });
|
|
30666
30792
|
removed++;
|
|
30667
30793
|
} catch {
|
|
30668
30794
|
}
|
|
@@ -31807,11 +31933,11 @@ function resolveTokenValue(args2) {
|
|
|
31807
31933
|
}
|
|
31808
31934
|
const fileFlag = args2.find((a) => a.startsWith("--token-file="));
|
|
31809
31935
|
if (fileFlag) {
|
|
31810
|
-
const
|
|
31936
|
+
const path120 = fileFlag.slice("--token-file=".length);
|
|
31811
31937
|
try {
|
|
31812
|
-
const content =
|
|
31813
|
-
if (content.length === 0) fail(`--token-file ${
|
|
31814
|
-
rmIfExistsQuiet(
|
|
31938
|
+
const content = fs72.readFileSync(path120, "utf8").trim();
|
|
31939
|
+
if (content.length === 0) fail(`--token-file ${path120} is empty`);
|
|
31940
|
+
rmIfExistsQuiet(path120);
|
|
31815
31941
|
return content;
|
|
31816
31942
|
} catch (err) {
|
|
31817
31943
|
fail(`Could not read --token-file: ${err.message}`);
|
|
@@ -31903,12 +32029,12 @@ async function claim(token, pluginId, pluginSecretHash) {
|
|
|
31903
32029
|
}
|
|
31904
32030
|
}
|
|
31905
32031
|
function pairAutoLockPath() {
|
|
31906
|
-
return
|
|
32032
|
+
return path79.join(os52.homedir(), ".codeam", "pair-auto.lock");
|
|
31907
32033
|
}
|
|
31908
32034
|
var procRoot = "/proc";
|
|
31909
32035
|
function readProcFile(rel) {
|
|
31910
32036
|
try {
|
|
31911
|
-
return
|
|
32037
|
+
return fs72.readFileSync(path79.join(procRoot, rel), "utf8");
|
|
31912
32038
|
} catch {
|
|
31913
32039
|
return void 0;
|
|
31914
32040
|
}
|
|
@@ -31929,7 +32055,7 @@ function currentBootId() {
|
|
|
31929
32055
|
function readLockRecord(lockPath) {
|
|
31930
32056
|
let raw;
|
|
31931
32057
|
try {
|
|
31932
|
-
raw =
|
|
32058
|
+
raw = fs72.readFileSync(lockPath, "utf8");
|
|
31933
32059
|
} catch {
|
|
31934
32060
|
return void 0;
|
|
31935
32061
|
}
|
|
@@ -31978,7 +32104,7 @@ function isLiveLockHolder(rec) {
|
|
|
31978
32104
|
}
|
|
31979
32105
|
function releaseOwnLock(lockPath) {
|
|
31980
32106
|
try {
|
|
31981
|
-
if (readLockRecord(lockPath)?.pid === process.pid)
|
|
32107
|
+
if (readLockRecord(lockPath)?.pid === process.pid) fs72.unlinkSync(lockPath);
|
|
31982
32108
|
} catch {
|
|
31983
32109
|
}
|
|
31984
32110
|
}
|
|
@@ -32002,7 +32128,7 @@ function snapshotProcessTree(root) {
|
|
|
32002
32128
|
const children = /* @__PURE__ */ new Map();
|
|
32003
32129
|
let entries2 = [];
|
|
32004
32130
|
try {
|
|
32005
|
-
entries2 =
|
|
32131
|
+
entries2 = fs72.readdirSync(procRoot).filter((e) => /^\d+$/.test(e));
|
|
32006
32132
|
} catch {
|
|
32007
32133
|
}
|
|
32008
32134
|
for (const e of entries2) {
|
|
@@ -32037,18 +32163,18 @@ function signalProcessTree(refs, signal) {
|
|
|
32037
32163
|
}
|
|
32038
32164
|
function daemonLockPath(sessionId) {
|
|
32039
32165
|
const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
32040
|
-
return
|
|
32166
|
+
return path79.join(os52.homedir(), ".codeam", `daemon-${safe}.lock`);
|
|
32041
32167
|
}
|
|
32042
32168
|
function acquireDaemonLock(sessionId) {
|
|
32043
32169
|
const lockPath = daemonLockPath(sessionId);
|
|
32044
32170
|
try {
|
|
32045
|
-
|
|
32171
|
+
fs72.mkdirSync(path79.dirname(lockPath), { recursive: true });
|
|
32046
32172
|
try {
|
|
32047
|
-
|
|
32173
|
+
fs72.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
32048
32174
|
} catch (e) {
|
|
32049
32175
|
if (e.code !== "EEXIST") throw e;
|
|
32050
32176
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
32051
|
-
|
|
32177
|
+
fs72.writeFileSync(lockPath, ownLockBody());
|
|
32052
32178
|
}
|
|
32053
32179
|
const release3 = () => releaseOwnLock(lockPath);
|
|
32054
32180
|
process.once("exit", release3);
|
|
@@ -32068,13 +32194,13 @@ function acquireDaemonLock(sessionId) {
|
|
|
32068
32194
|
function acquireSingletonLock() {
|
|
32069
32195
|
const lockPath = pairAutoLockPath();
|
|
32070
32196
|
try {
|
|
32071
|
-
|
|
32197
|
+
fs72.mkdirSync(path79.dirname(lockPath), { recursive: true });
|
|
32072
32198
|
try {
|
|
32073
|
-
|
|
32199
|
+
fs72.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
32074
32200
|
} catch (e) {
|
|
32075
32201
|
if (e.code !== "EEXIST") throw e;
|
|
32076
32202
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
32077
|
-
|
|
32203
|
+
fs72.writeFileSync(lockPath, ownLockBody());
|
|
32078
32204
|
}
|
|
32079
32205
|
process.once("exit", () => releaseOwnLock(lockPath));
|
|
32080
32206
|
return true;
|
|
@@ -32500,7 +32626,7 @@ var AgentService = class _AgentService {
|
|
|
32500
32626
|
};
|
|
32501
32627
|
|
|
32502
32628
|
// src/agents/acp/adapters.ts
|
|
32503
|
-
var
|
|
32629
|
+
var path80 = __toESM(require("path"));
|
|
32504
32630
|
|
|
32505
32631
|
// src/agents/kimi/installer.ts
|
|
32506
32632
|
var import_node_child_process28 = require("child_process");
|
|
@@ -32621,13 +32747,13 @@ function resolveBin(pkgName, binName) {
|
|
|
32621
32747
|
try {
|
|
32622
32748
|
const manifestPath = require_.resolve(`${pkgName}/package.json`);
|
|
32623
32749
|
const manifest = require_(`${pkgName}/package.json`);
|
|
32624
|
-
const pkgDir =
|
|
32750
|
+
const pkgDir = path80.dirname(manifestPath);
|
|
32625
32751
|
const bin = manifest.bin;
|
|
32626
32752
|
if (!bin) return null;
|
|
32627
|
-
if (typeof bin === "string") return
|
|
32753
|
+
if (typeof bin === "string") return path80.resolve(pkgDir, bin);
|
|
32628
32754
|
const target = binName ?? Object.keys(bin)[0];
|
|
32629
32755
|
if (!target || !bin[target]) return null;
|
|
32630
|
-
return
|
|
32756
|
+
return path80.resolve(pkgDir, bin[target]);
|
|
32631
32757
|
} catch {
|
|
32632
32758
|
return null;
|
|
32633
32759
|
}
|
|
@@ -32642,7 +32768,7 @@ function npmAdapterPackageDir(agent) {
|
|
|
32642
32768
|
const pkg = NPM_ADAPTER_PACKAGES[agent];
|
|
32643
32769
|
if (!pkg) return null;
|
|
32644
32770
|
try {
|
|
32645
|
-
return
|
|
32771
|
+
return path80.dirname(require_.resolve(`${pkg}/package.json`));
|
|
32646
32772
|
} catch {
|
|
32647
32773
|
return null;
|
|
32648
32774
|
}
|
|
@@ -32846,8 +32972,8 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
|
|
|
32846
32972
|
}
|
|
32847
32973
|
|
|
32848
32974
|
// src/agents/acp/prefetch-module-graph.ts
|
|
32849
|
-
var
|
|
32850
|
-
var
|
|
32975
|
+
var fs73 = __toESM(require("fs"));
|
|
32976
|
+
var path81 = __toESM(require("path"));
|
|
32851
32977
|
var LOADABLE_EXT = /* @__PURE__ */ new Set([".js", ".mjs", ".cjs", ".json", ".node"]);
|
|
32852
32978
|
var DEFAULT_MODULE_GRAPH_LIMITS = {
|
|
32853
32979
|
maxFiles: 2e3,
|
|
@@ -32856,23 +32982,23 @@ var DEFAULT_MODULE_GRAPH_LIMITS = {
|
|
|
32856
32982
|
concurrency: 16
|
|
32857
32983
|
};
|
|
32858
32984
|
var realFs = {
|
|
32859
|
-
readdir: (dir) =>
|
|
32860
|
-
readFile: (file) =>
|
|
32861
|
-
stat: (file) =>
|
|
32985
|
+
readdir: (dir) => fs73.promises.readdir(dir, { withFileTypes: true }),
|
|
32986
|
+
readFile: (file) => fs73.promises.readFile(file),
|
|
32987
|
+
stat: (file) => fs73.promises.stat(file)
|
|
32862
32988
|
};
|
|
32863
32989
|
function findPackageDir(dep, fromDir) {
|
|
32864
32990
|
let dir = fromDir;
|
|
32865
32991
|
for (; ; ) {
|
|
32866
|
-
const candidate =
|
|
32867
|
-
if (
|
|
32868
|
-
const parent =
|
|
32992
|
+
const candidate = path81.join(dir, "node_modules", dep);
|
|
32993
|
+
if (fs73.existsSync(path81.join(candidate, "package.json"))) return candidate;
|
|
32994
|
+
const parent = path81.dirname(dir);
|
|
32869
32995
|
if (parent === dir) return null;
|
|
32870
32996
|
dir = parent;
|
|
32871
32997
|
}
|
|
32872
32998
|
}
|
|
32873
32999
|
function runtimeDependencies(pkgDir) {
|
|
32874
33000
|
try {
|
|
32875
|
-
const manifest = JSON.parse(
|
|
33001
|
+
const manifest = JSON.parse(fs73.readFileSync(path81.join(pkgDir, "package.json"), "utf8"));
|
|
32876
33002
|
return Object.keys(manifest.dependencies ?? {});
|
|
32877
33003
|
} catch {
|
|
32878
33004
|
return [];
|
|
@@ -32891,14 +33017,14 @@ async function packageFiles(pkgDir, fsd, out2, maxFiles) {
|
|
|
32891
33017
|
for (const entry of entries2) {
|
|
32892
33018
|
if (out2.length >= maxFiles) return;
|
|
32893
33019
|
if (entry.name.startsWith(".")) continue;
|
|
32894
|
-
const full =
|
|
33020
|
+
const full = path81.join(dir, entry.name);
|
|
32895
33021
|
if (entry.isDirectory()) {
|
|
32896
33022
|
if (entry.name !== "node_modules") stack.push(full);
|
|
32897
33023
|
continue;
|
|
32898
33024
|
}
|
|
32899
33025
|
if (!entry.isFile()) continue;
|
|
32900
33026
|
if (entry.name.endsWith(".d.ts") || entry.name.endsWith(".map")) continue;
|
|
32901
|
-
if (LOADABLE_EXT.has(
|
|
33027
|
+
if (LOADABLE_EXT.has(path81.extname(entry.name))) out2.push(full);
|
|
32902
33028
|
}
|
|
32903
33029
|
}
|
|
32904
33030
|
}
|
|
@@ -32908,7 +33034,7 @@ async function collectModuleGraphFiles(rootPkgDir, limits = DEFAULT_MODULE_GRAPH
|
|
|
32908
33034
|
const queue = [rootPkgDir];
|
|
32909
33035
|
while (queue.length > 0 && files.length < limits.maxFiles) {
|
|
32910
33036
|
const pkgDir = queue.shift();
|
|
32911
|
-
const key =
|
|
33037
|
+
const key = fs73.existsSync(pkgDir) ? fs73.realpathSync(pkgDir) : pkgDir;
|
|
32912
33038
|
if (seen2.has(key)) continue;
|
|
32913
33039
|
seen2.add(key);
|
|
32914
33040
|
await packageFiles(pkgDir, fsd, files, limits.maxFiles);
|
|
@@ -33020,9 +33146,9 @@ async function waitForNoAgentStarting(opts) {
|
|
|
33020
33146
|
|
|
33021
33147
|
// src/agents/acp/runner.ts
|
|
33022
33148
|
var import_node_crypto15 = require("crypto");
|
|
33023
|
-
var
|
|
33024
|
-
var
|
|
33025
|
-
var
|
|
33149
|
+
var fs92 = __toESM(require("fs"));
|
|
33150
|
+
var os64 = __toESM(require("os"));
|
|
33151
|
+
var path101 = __toESM(require("path"));
|
|
33026
33152
|
|
|
33027
33153
|
// src/agents/acp/provider-billing-signal.ts
|
|
33028
33154
|
var seen = /* @__PURE__ */ new Set();
|
|
@@ -33054,8 +33180,8 @@ function noteProviderBillingSignal(opts) {
|
|
|
33054
33180
|
}
|
|
33055
33181
|
|
|
33056
33182
|
// src/services/history.service.ts
|
|
33057
|
-
var
|
|
33058
|
-
var
|
|
33183
|
+
var fs75 = __toESM(require("fs"));
|
|
33184
|
+
var path83 = __toESM(require("path"));
|
|
33059
33185
|
var https6 = __toESM(require("https"));
|
|
33060
33186
|
var http10 = __toESM(require("http"));
|
|
33061
33187
|
var import_zod3 = require("zod");
|
|
@@ -33116,7 +33242,7 @@ function parseJsonl(filePath) {
|
|
|
33116
33242
|
const messages = [];
|
|
33117
33243
|
let raw;
|
|
33118
33244
|
try {
|
|
33119
|
-
raw =
|
|
33245
|
+
raw = fs75.readFileSync(filePath, "utf8");
|
|
33120
33246
|
} catch (err) {
|
|
33121
33247
|
if (err.code !== "ENOENT") {
|
|
33122
33248
|
log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
|
|
@@ -33276,7 +33402,7 @@ var HistoryService = class _HistoryService {
|
|
|
33276
33402
|
// session-start upload answered false, the active-conversation pointer was
|
|
33277
33403
|
// never re-pointed after a Box wake, and the app opened an empty "New
|
|
33278
33404
|
// conversation" over the resumed one (QA box, 2026-09-29).
|
|
33279
|
-
|
|
33405
|
+
path83.join(claudeConfigDir(), "projects", encodeCwd(this.cwd));
|
|
33280
33406
|
}
|
|
33281
33407
|
/** Set the current Claude conversation ID (extracted from /cost command or session start) */
|
|
33282
33408
|
setCurrentConversationId(id) {
|
|
@@ -33288,7 +33414,7 @@ var HistoryService = class _HistoryService {
|
|
|
33288
33414
|
/** Return the current message count in the active conversation. */
|
|
33289
33415
|
getCurrentMessageCount() {
|
|
33290
33416
|
if (!this.currentConversationId) return 0;
|
|
33291
|
-
const filePath =
|
|
33417
|
+
const filePath = path83.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
33292
33418
|
return parseJsonl(filePath).length;
|
|
33293
33419
|
}
|
|
33294
33420
|
/**
|
|
@@ -33299,7 +33425,7 @@ var HistoryService = class _HistoryService {
|
|
|
33299
33425
|
const deadline = Date.now() + timeoutMs;
|
|
33300
33426
|
while (Date.now() < deadline) {
|
|
33301
33427
|
if (!this.currentConversationId) return null;
|
|
33302
|
-
const filePath =
|
|
33428
|
+
const filePath = path83.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
33303
33429
|
const messages = parseJsonl(filePath);
|
|
33304
33430
|
if (messages.length > previousCount) {
|
|
33305
33431
|
for (let i = messages.length - 1; i >= previousCount; i--) {
|
|
@@ -33326,18 +33452,18 @@ var HistoryService = class _HistoryService {
|
|
|
33326
33452
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
33327
33453
|
const oneShots = readOneShotConversations(this.cwd);
|
|
33328
33454
|
try {
|
|
33329
|
-
const files =
|
|
33330
|
-
(e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(
|
|
33455
|
+
const files = fs75.readdirSync(dir, { withFileTypes: true }).filter(
|
|
33456
|
+
(e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(path83.basename(e.name, ".jsonl"))
|
|
33331
33457
|
).map((e) => {
|
|
33332
33458
|
try {
|
|
33333
|
-
const stat3 =
|
|
33459
|
+
const stat3 = fs75.statSync(path83.join(dir, e.name));
|
|
33334
33460
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
33335
33461
|
} catch {
|
|
33336
33462
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
33337
33463
|
}
|
|
33338
33464
|
}).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
33339
33465
|
if (files.length > 0) {
|
|
33340
|
-
this.currentConversationId =
|
|
33466
|
+
this.currentConversationId = path83.basename(files[0].name, ".jsonl");
|
|
33341
33467
|
}
|
|
33342
33468
|
} catch {
|
|
33343
33469
|
}
|
|
@@ -33371,13 +33497,13 @@ var HistoryService = class _HistoryService {
|
|
|
33371
33497
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
33372
33498
|
let entries2;
|
|
33373
33499
|
try {
|
|
33374
|
-
entries2 =
|
|
33500
|
+
entries2 = fs75.readdirSync(dir, { withFileTypes: true });
|
|
33375
33501
|
} catch {
|
|
33376
33502
|
return null;
|
|
33377
33503
|
}
|
|
33378
33504
|
const files = entries2.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
33379
33505
|
try {
|
|
33380
|
-
const stat3 =
|
|
33506
|
+
const stat3 = fs75.statSync(path83.join(dir, e.name));
|
|
33381
33507
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
33382
33508
|
} catch {
|
|
33383
33509
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
@@ -33386,12 +33512,12 @@ var HistoryService = class _HistoryService {
|
|
|
33386
33512
|
if (files.length === 0) return null;
|
|
33387
33513
|
const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
|
|
33388
33514
|
if (!files.some((f) => f.name === targetFile)) return null;
|
|
33389
|
-
return this.extractUsageFromFile(
|
|
33515
|
+
return this.extractUsageFromFile(path83.join(dir, targetFile));
|
|
33390
33516
|
}
|
|
33391
33517
|
extractUsageFromFile(filePath) {
|
|
33392
33518
|
let raw;
|
|
33393
33519
|
try {
|
|
33394
|
-
raw =
|
|
33520
|
+
raw = fs75.readFileSync(filePath, "utf8");
|
|
33395
33521
|
} catch {
|
|
33396
33522
|
return null;
|
|
33397
33523
|
}
|
|
@@ -33443,9 +33569,9 @@ var HistoryService = class _HistoryService {
|
|
|
33443
33569
|
let totalCost = 0;
|
|
33444
33570
|
let files;
|
|
33445
33571
|
try {
|
|
33446
|
-
files =
|
|
33572
|
+
files = fs75.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
|
|
33447
33573
|
try {
|
|
33448
|
-
return
|
|
33574
|
+
return fs75.statSync(path83.join(projectDir, f)).mtimeMs >= monthStartMs;
|
|
33449
33575
|
} catch {
|
|
33450
33576
|
return false;
|
|
33451
33577
|
}
|
|
@@ -33456,7 +33582,7 @@ var HistoryService = class _HistoryService {
|
|
|
33456
33582
|
for (const file of files) {
|
|
33457
33583
|
let raw;
|
|
33458
33584
|
try {
|
|
33459
|
-
raw =
|
|
33585
|
+
raw = fs75.readFileSync(path83.join(projectDir, file), "utf8");
|
|
33460
33586
|
} catch {
|
|
33461
33587
|
continue;
|
|
33462
33588
|
}
|
|
@@ -33535,7 +33661,7 @@ var HistoryService = class _HistoryService {
|
|
|
33535
33661
|
if (this.runtime.resolveHistoryFile) {
|
|
33536
33662
|
return this.runtime.resolveHistoryFile(this.cwd, sessionId);
|
|
33537
33663
|
}
|
|
33538
|
-
return
|
|
33664
|
+
return path83.join(this.projectDir, `${sessionId}.jsonl`);
|
|
33539
33665
|
}
|
|
33540
33666
|
/**
|
|
33541
33667
|
* Parse a conversation's messages from disk, agent-aware. Claude uses the
|
|
@@ -33573,7 +33699,7 @@ var HistoryService = class _HistoryService {
|
|
|
33573
33699
|
};
|
|
33574
33700
|
});
|
|
33575
33701
|
}
|
|
33576
|
-
return parseJsonl(
|
|
33702
|
+
return parseJsonl(path83.join(this.projectDir, `${sessionId}.jsonl`));
|
|
33577
33703
|
}
|
|
33578
33704
|
/** One in-flight full upload per conversation — the baton mirror and a
|
|
33579
33705
|
* `get_conversation` used to upload the same transcript concurrently. */
|
|
@@ -33655,7 +33781,7 @@ var HistoryService = class _HistoryService {
|
|
|
33655
33781
|
if (!filePath) return false;
|
|
33656
33782
|
let mtimeMs;
|
|
33657
33783
|
try {
|
|
33658
|
-
mtimeMs =
|
|
33784
|
+
mtimeMs = fs75.statSync(filePath).mtimeMs;
|
|
33659
33785
|
} catch {
|
|
33660
33786
|
return false;
|
|
33661
33787
|
}
|
|
@@ -33730,10 +33856,10 @@ var HistoryService = class _HistoryService {
|
|
|
33730
33856
|
|
|
33731
33857
|
// src/agents/acp/client.ts
|
|
33732
33858
|
var import_node_child_process30 = require("child_process");
|
|
33733
|
-
var
|
|
33859
|
+
var fs76 = __toESM(require("fs/promises"));
|
|
33734
33860
|
var fsSync = __toESM(require("fs"));
|
|
33735
|
-
var
|
|
33736
|
-
var
|
|
33861
|
+
var os55 = __toESM(require("os"));
|
|
33862
|
+
var path85 = __toESM(require("path"));
|
|
33737
33863
|
var import_node_stream = require("stream");
|
|
33738
33864
|
|
|
33739
33865
|
// ../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
@@ -37759,8 +37885,8 @@ function createIdleTimeout(idleMs, makeError, activeIdleMs = idleMs) {
|
|
|
37759
37885
|
}
|
|
37760
37886
|
|
|
37761
37887
|
// src/agents/acp/internal-paths.ts
|
|
37762
|
-
var
|
|
37763
|
-
var
|
|
37888
|
+
var path84 = __toESM(require("path"));
|
|
37889
|
+
var os54 = __toESM(require("os"));
|
|
37764
37890
|
var INTERNAL_TOKENS = [".codeam", "house-claude"];
|
|
37765
37891
|
var PROSE_ONLY_TOOL_KINDS = /* @__PURE__ */ new Set(["think", "switch_mode"]);
|
|
37766
37892
|
function isProseOnlyToolKind(kind) {
|
|
@@ -37772,13 +37898,13 @@ function textReferencesInternal(text) {
|
|
|
37772
37898
|
const scrubbed = text.replace(SELF_HOSTED_WORKSPACE_RE, " ");
|
|
37773
37899
|
return INTERNAL_TOKENS.some((t2) => scrubbed.includes(t2));
|
|
37774
37900
|
}
|
|
37775
|
-
function pathIsInternal(p2, homeDir2 =
|
|
37901
|
+
function pathIsInternal(p2, homeDir2 = os54.homedir()) {
|
|
37776
37902
|
if (!p2) return false;
|
|
37777
|
-
const abs =
|
|
37778
|
-
const home =
|
|
37779
|
-
const within = (root) => abs === root || abs.startsWith(root +
|
|
37780
|
-
if (within(
|
|
37781
|
-
return within(
|
|
37903
|
+
const abs = path84.resolve(p2);
|
|
37904
|
+
const home = path84.resolve(homeDir2);
|
|
37905
|
+
const within = (root) => abs === root || abs.startsWith(root + path84.sep);
|
|
37906
|
+
if (within(path84.join(home, ".codeam", "self-hosted"))) return false;
|
|
37907
|
+
return within(path84.join(home, ".codeam")) || within(path84.join(home, ".beads")) || abs === path84.join(home, ".codeam-host.log") || abs.includes(`${path84.sep}house-claude${path84.sep}`) || abs.endsWith(`${path84.sep}house-claude`);
|
|
37782
37908
|
}
|
|
37783
37909
|
function toolCallReferencesInternal(call, homeDir2) {
|
|
37784
37910
|
if (call.locations?.some((l) => pathIsInternal(l.path, homeDir2))) return true;
|
|
@@ -38972,7 +39098,7 @@ var AcpClient = class {
|
|
|
38972
39098
|
throw new RequestError(-32002, GUARDRAIL_SECRET_READ_BLOCK_REASON, { uri: params.path });
|
|
38973
39099
|
}
|
|
38974
39100
|
try {
|
|
38975
|
-
const content = await
|
|
39101
|
+
const content = await fs76.readFile(params.path, "utf8");
|
|
38976
39102
|
return applyLineRange(content, params.line ?? null, params.limit ?? null);
|
|
38977
39103
|
} catch (err) {
|
|
38978
39104
|
const code = err.code;
|
|
@@ -38993,7 +39119,7 @@ var AcpClient = class {
|
|
|
38993
39119
|
throw new RequestError(-32002, INTERNAL_BLOCK_REASON, { uri: params.path });
|
|
38994
39120
|
}
|
|
38995
39121
|
try {
|
|
38996
|
-
await
|
|
39122
|
+
await fs76.writeFile(params.path, params.content, "utf8");
|
|
38997
39123
|
return {};
|
|
38998
39124
|
} catch (err) {
|
|
38999
39125
|
const code = err.code;
|
|
@@ -39081,30 +39207,30 @@ function applyLineRange(content, line, limit) {
|
|
|
39081
39207
|
return { content: lines.slice(start2, end).join("\n") };
|
|
39082
39208
|
}
|
|
39083
39209
|
function knownAgentBinaryDirs() {
|
|
39084
|
-
const home =
|
|
39210
|
+
const home = os55.homedir();
|
|
39085
39211
|
const out2 = [];
|
|
39086
39212
|
out2.push("/tmp/codeam-node20/bin");
|
|
39087
39213
|
for (const root of [
|
|
39088
39214
|
"/usr/local/share/nvm/versions/node",
|
|
39089
|
-
|
|
39215
|
+
path85.join(home, ".nvm/versions/node")
|
|
39090
39216
|
]) {
|
|
39091
39217
|
try {
|
|
39092
39218
|
for (const child of fsSync.readdirSync(root)) {
|
|
39093
|
-
out2.push(
|
|
39219
|
+
out2.push(path85.join(root, child, "bin"));
|
|
39094
39220
|
}
|
|
39095
39221
|
} catch {
|
|
39096
39222
|
}
|
|
39097
39223
|
}
|
|
39098
|
-
out2.push(
|
|
39224
|
+
out2.push(path85.join(home, ".volta/bin"));
|
|
39099
39225
|
out2.push("/usr/local/bin");
|
|
39100
39226
|
out2.push("/usr/bin");
|
|
39101
|
-
out2.push(
|
|
39102
|
-
out2.push(
|
|
39227
|
+
out2.push(path85.join(home, ".local/bin"));
|
|
39228
|
+
out2.push(path85.join(home, "bin"));
|
|
39103
39229
|
out2.push(...agentInstallBinDirs());
|
|
39104
39230
|
if (process.platform === "win32") {
|
|
39105
39231
|
const { LOCALAPPDATA, APPDATA } = process.env;
|
|
39106
|
-
if (LOCALAPPDATA) out2.push(
|
|
39107
|
-
if (APPDATA) out2.push(
|
|
39232
|
+
if (LOCALAPPDATA) out2.push(path85.join(LOCALAPPDATA, "cursor-agent"));
|
|
39233
|
+
if (APPDATA) out2.push(path85.join(APPDATA, "npm"));
|
|
39108
39234
|
}
|
|
39109
39235
|
return out2.filter((p2) => {
|
|
39110
39236
|
try {
|
|
@@ -39115,7 +39241,7 @@ function knownAgentBinaryDirs() {
|
|
|
39115
39241
|
});
|
|
39116
39242
|
}
|
|
39117
39243
|
function expandPathForAgentBinaries(existingPath) {
|
|
39118
|
-
const existing = new Set(existingPath.split(
|
|
39244
|
+
const existing = new Set(existingPath.split(path85.delimiter).filter((p2) => p2.length > 0));
|
|
39119
39245
|
const additions = [];
|
|
39120
39246
|
for (const dir of knownAgentBinaryDirs()) {
|
|
39121
39247
|
if (!existing.has(dir)) {
|
|
@@ -39124,17 +39250,17 @@ function expandPathForAgentBinaries(existingPath) {
|
|
|
39124
39250
|
}
|
|
39125
39251
|
}
|
|
39126
39252
|
if (additions.length === 0) return existingPath;
|
|
39127
|
-
return [...additions, existingPath].filter((p2) => p2.length > 0).join(
|
|
39253
|
+
return [...additions, existingPath].filter((p2) => p2.length > 0).join(path85.delimiter);
|
|
39128
39254
|
}
|
|
39129
39255
|
|
|
39130
39256
|
// src/commands/host/agent-install.ts
|
|
39131
39257
|
var import_child_process27 = require("child_process");
|
|
39132
|
-
var
|
|
39258
|
+
var os56 = __toESM(require("os"));
|
|
39133
39259
|
function runAgentInstallScript(script, opts = {}) {
|
|
39134
39260
|
const timeoutMs = opts.timeoutMs ?? 18e4;
|
|
39135
39261
|
const scope = opts.logScope ?? "agent-install";
|
|
39136
39262
|
return new Promise((resolve13) => {
|
|
39137
|
-
const home = process.env.HOME ||
|
|
39263
|
+
const home = process.env.HOME || os56.homedir();
|
|
39138
39264
|
const child = (0, import_child_process27.spawn)("sh", ["-c", script], {
|
|
39139
39265
|
env: { ...process.env, HOME: home },
|
|
39140
39266
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -39396,9 +39522,9 @@ async function performAgentSwitch(deps, rawAgentId, fastPath = {}) {
|
|
|
39396
39522
|
}
|
|
39397
39523
|
|
|
39398
39524
|
// src/commands/host/agent-provisioning.ts
|
|
39399
|
-
var
|
|
39400
|
-
var
|
|
39401
|
-
var
|
|
39525
|
+
var fs77 = __toESM(require("fs"));
|
|
39526
|
+
var os57 = __toESM(require("os"));
|
|
39527
|
+
var path86 = __toESM(require("path"));
|
|
39402
39528
|
var PUBLIC_TO_INTERNAL_AGENT = {
|
|
39403
39529
|
claude_code: "claude",
|
|
39404
39530
|
claude: "claude",
|
|
@@ -39416,22 +39542,22 @@ function toInternalAgentId(publicAgentId) {
|
|
|
39416
39542
|
return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
|
|
39417
39543
|
}
|
|
39418
39544
|
function ensureDir(dir) {
|
|
39419
|
-
|
|
39545
|
+
fs77.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
39420
39546
|
}
|
|
39421
39547
|
function writeFile0600(filePath, contents) {
|
|
39422
|
-
ensureDir(
|
|
39423
|
-
|
|
39548
|
+
ensureDir(path86.dirname(filePath));
|
|
39549
|
+
fs77.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
|
|
39424
39550
|
restrictToOwner(filePath);
|
|
39425
39551
|
}
|
|
39426
39552
|
function rmIfExists(filePath) {
|
|
39427
39553
|
try {
|
|
39428
|
-
|
|
39554
|
+
fs77.rmSync(filePath, { force: true });
|
|
39429
39555
|
} catch {
|
|
39430
39556
|
}
|
|
39431
39557
|
}
|
|
39432
39558
|
var claudeProvisioner = {
|
|
39433
39559
|
write(auth, home) {
|
|
39434
|
-
const credentialsJson =
|
|
39560
|
+
const credentialsJson = path86.join(home, ".claude", ".credentials.json");
|
|
39435
39561
|
if (auth.kind === "api_key") {
|
|
39436
39562
|
rmIfExists(credentialsJson);
|
|
39437
39563
|
return { ANTHROPIC_API_KEY: auth.value };
|
|
@@ -39443,8 +39569,8 @@ var claudeProvisioner = {
|
|
|
39443
39569
|
} else {
|
|
39444
39570
|
rmIfExists(credentialsJson);
|
|
39445
39571
|
}
|
|
39446
|
-
const claudeJson =
|
|
39447
|
-
if (!
|
|
39572
|
+
const claudeJson = path86.join(home, ".claude.json");
|
|
39573
|
+
if (!fs77.existsSync(claudeJson)) {
|
|
39448
39574
|
writeFile0600(
|
|
39449
39575
|
claudeJson,
|
|
39450
39576
|
JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
|
|
@@ -39455,7 +39581,7 @@ var claudeProvisioner = {
|
|
|
39455
39581
|
};
|
|
39456
39582
|
var codexProvisioner = {
|
|
39457
39583
|
write(auth, home) {
|
|
39458
|
-
const authJson =
|
|
39584
|
+
const authJson = path86.join(home, ".codex", "auth.json");
|
|
39459
39585
|
if (auth.kind === "api_key") {
|
|
39460
39586
|
writeFile0600(authJson, JSON.stringify({ auth_mode: "apikey", OPENAI_API_KEY: auth.value }));
|
|
39461
39587
|
return { OPENAI_API_KEY: auth.value };
|
|
@@ -39478,7 +39604,7 @@ function codexLoginStamp(raw) {
|
|
|
39478
39604
|
function keepsFresherCodexLogin(authJsonPath, incoming) {
|
|
39479
39605
|
let onDisk;
|
|
39480
39606
|
try {
|
|
39481
|
-
onDisk =
|
|
39607
|
+
onDisk = fs77.readFileSync(authJsonPath, "utf8");
|
|
39482
39608
|
} catch {
|
|
39483
39609
|
return false;
|
|
39484
39610
|
}
|
|
@@ -39489,8 +39615,8 @@ function keepsFresherCodexLogin(authJsonPath, incoming) {
|
|
|
39489
39615
|
}
|
|
39490
39616
|
var geminiProvisioner = {
|
|
39491
39617
|
write(auth, home) {
|
|
39492
|
-
const settingsJson =
|
|
39493
|
-
const oauthCreds =
|
|
39618
|
+
const settingsJson = path86.join(home, ".gemini", "settings.json");
|
|
39619
|
+
const oauthCreds = path86.join(home, ".gemini", "oauth_creds.json");
|
|
39494
39620
|
if (auth.kind === "api_key") {
|
|
39495
39621
|
rmIfExists(oauthCreds);
|
|
39496
39622
|
writeFile0600(settingsJson, '{"security":{"auth":{"selectedType":"gemini-api-key"}}}');
|
|
@@ -39503,7 +39629,7 @@ var geminiProvisioner = {
|
|
|
39503
39629
|
};
|
|
39504
39630
|
var cursorProvisioner = {
|
|
39505
39631
|
write(auth, home) {
|
|
39506
|
-
const authJson =
|
|
39632
|
+
const authJson = path86.join(home, ".config", "cursor", "auth.json");
|
|
39507
39633
|
if (auth.kind === "api_key") {
|
|
39508
39634
|
rmIfExists(authJson);
|
|
39509
39635
|
return { CURSOR_API_KEY: auth.value };
|
|
@@ -39545,21 +39671,21 @@ max_context_size = 262144
|
|
|
39545
39671
|
var kimiProvisioner = {
|
|
39546
39672
|
write(auth, home) {
|
|
39547
39673
|
const credentialsFiles = [
|
|
39548
|
-
|
|
39549
|
-
|
|
39674
|
+
path86.join(home, ".kimi", "credentials", "kimi-code.json"),
|
|
39675
|
+
path86.join(home, ".kimi-code", "credentials", "kimi-code.json")
|
|
39550
39676
|
];
|
|
39551
39677
|
if (auth.kind === "api_key") {
|
|
39552
39678
|
credentialsFiles.forEach(rmIfExists);
|
|
39553
39679
|
return { KIMI_API_KEY: auth.value };
|
|
39554
39680
|
}
|
|
39555
39681
|
credentialsFiles.forEach((f) => writeFile0600(f, auth.value));
|
|
39556
|
-
writeFile0600(
|
|
39682
|
+
writeFile0600(path86.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
|
|
39557
39683
|
return {};
|
|
39558
39684
|
}
|
|
39559
39685
|
};
|
|
39560
39686
|
function readAntigravitySettings(file) {
|
|
39561
39687
|
try {
|
|
39562
|
-
const parsed = JSON.parse(
|
|
39688
|
+
const parsed = JSON.parse(fs77.readFileSync(file, "utf8"));
|
|
39563
39689
|
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
39564
39690
|
return { ...parsed };
|
|
39565
39691
|
}
|
|
@@ -39597,8 +39723,8 @@ var antigravityProvisioner = {
|
|
|
39597
39723
|
};
|
|
39598
39724
|
var coderabbitProvisioner = {
|
|
39599
39725
|
write(auth, home) {
|
|
39600
|
-
const dir =
|
|
39601
|
-
const authJson =
|
|
39726
|
+
const dir = path86.join(home, ".coderabbit");
|
|
39727
|
+
const authJson = path86.join(dir, "auth.json");
|
|
39602
39728
|
if (auth.kind === "api_key") {
|
|
39603
39729
|
rmIfExists(authJson);
|
|
39604
39730
|
return { CODERABBIT_API_KEY: auth.value };
|
|
@@ -39610,13 +39736,13 @@ var coderabbitProvisioner = {
|
|
|
39610
39736
|
try {
|
|
39611
39737
|
const parsed = JSON.parse(value);
|
|
39612
39738
|
if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
|
|
39613
|
-
file =
|
|
39739
|
+
file = path86.basename(parsed.file);
|
|
39614
39740
|
contents = parsed.contents;
|
|
39615
39741
|
}
|
|
39616
39742
|
} catch {
|
|
39617
39743
|
}
|
|
39618
39744
|
}
|
|
39619
|
-
writeFile0600(
|
|
39745
|
+
writeFile0600(path86.join(dir, file), contents);
|
|
39620
39746
|
return {};
|
|
39621
39747
|
}
|
|
39622
39748
|
};
|
|
@@ -39649,7 +39775,7 @@ var UnsupportedAgentError = class extends Error {
|
|
|
39649
39775
|
this.agentId = agentId;
|
|
39650
39776
|
}
|
|
39651
39777
|
};
|
|
39652
|
-
function provisionAgentCredentials(publicAgentId, auth, homeDir2 =
|
|
39778
|
+
function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os57.homedir()) {
|
|
39653
39779
|
const internal = toInternalAgentId(publicAgentId);
|
|
39654
39780
|
if (!internal) throw new UnsupportedAgentError(publicAgentId);
|
|
39655
39781
|
const provisioner = PROVISIONERS[internal];
|
|
@@ -39658,8 +39784,8 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os56.homedir(
|
|
|
39658
39784
|
}
|
|
39659
39785
|
|
|
39660
39786
|
// src/beads/workflow-hint.ts
|
|
39661
|
-
var
|
|
39662
|
-
var
|
|
39787
|
+
var fs78 = __toESM(require("fs"));
|
|
39788
|
+
var path87 = __toESM(require("path"));
|
|
39663
39789
|
var BEADS_HINT_MARKER = "<!-- codeam:beads-workflow -->";
|
|
39664
39790
|
var BEADS_HINT = `${BEADS_HINT_MARKER}
|
|
39665
39791
|
# Beads (bd) \u2014 task tracking + persistent memory (ALWAYS use it)
|
|
@@ -39686,11 +39812,11 @@ function ensureBeadsWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
|
39686
39812
|
try {
|
|
39687
39813
|
let existing = "";
|
|
39688
39814
|
try {
|
|
39689
|
-
existing =
|
|
39815
|
+
existing = fs78.readFileSync(file, "utf8");
|
|
39690
39816
|
} catch {
|
|
39691
39817
|
}
|
|
39692
39818
|
if (existing.includes(BEADS_HINT)) return;
|
|
39693
|
-
|
|
39819
|
+
fs78.mkdirSync(path87.dirname(file), { recursive: true });
|
|
39694
39820
|
let next;
|
|
39695
39821
|
const open = existing.indexOf(BEADS_HINT_MARKER);
|
|
39696
39822
|
const close = open === -1 ? -1 : existing.indexOf(BEADS_HINT_MARKER, open + BEADS_HINT_MARKER.length);
|
|
@@ -39703,40 +39829,40 @@ ${BEADS_HINT}
|
|
|
39703
39829
|
` : `${BEADS_HINT}
|
|
39704
39830
|
`;
|
|
39705
39831
|
}
|
|
39706
|
-
|
|
39832
|
+
fs78.writeFileSync(file, next);
|
|
39707
39833
|
} catch {
|
|
39708
39834
|
}
|
|
39709
39835
|
}
|
|
39710
39836
|
|
|
39711
39837
|
// src/agents/agent-standard.ts
|
|
39712
|
-
var
|
|
39713
|
-
var
|
|
39714
|
-
var
|
|
39838
|
+
var fs79 = __toESM(require("fs"));
|
|
39839
|
+
var path88 = __toESM(require("path"));
|
|
39840
|
+
var os58 = __toESM(require("os"));
|
|
39715
39841
|
function ensureAgentStandard(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
39716
39842
|
try {
|
|
39717
39843
|
let existing = "";
|
|
39718
39844
|
try {
|
|
39719
|
-
existing =
|
|
39845
|
+
existing = fs79.readFileSync(file, "utf8");
|
|
39720
39846
|
} catch {
|
|
39721
39847
|
}
|
|
39722
39848
|
if (existing.includes(AGENT_STANDARD_MARKER)) return;
|
|
39723
|
-
|
|
39849
|
+
fs79.mkdirSync(path88.dirname(file), { recursive: true });
|
|
39724
39850
|
const next = existing.trim() ? `${existing.trimEnd()}
|
|
39725
39851
|
|
|
39726
39852
|
${AGENT_STANDARD_BLOCK}
|
|
39727
39853
|
` : `${AGENT_STANDARD_BLOCK}
|
|
39728
39854
|
`;
|
|
39729
|
-
|
|
39855
|
+
fs79.writeFileSync(file, next);
|
|
39730
39856
|
} catch {
|
|
39731
39857
|
}
|
|
39732
39858
|
}
|
|
39733
39859
|
var _agentStandardSeam = {
|
|
39734
39860
|
isLocalSession: () => isLocalSession(),
|
|
39735
|
-
markerPath: (sessionId) =>
|
|
39736
|
-
exists: (p2) =>
|
|
39861
|
+
markerPath: (sessionId) => path88.join(os58.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
|
|
39862
|
+
exists: (p2) => fs79.existsSync(p2),
|
|
39737
39863
|
write: (p2) => {
|
|
39738
|
-
|
|
39739
|
-
|
|
39864
|
+
fs79.mkdirSync(path88.dirname(p2), { recursive: true });
|
|
39865
|
+
fs79.writeFileSync(p2, "");
|
|
39740
39866
|
}
|
|
39741
39867
|
};
|
|
39742
39868
|
function isClaude(agent) {
|
|
@@ -40597,15 +40723,15 @@ function withholdTrailingPartialFenceMarker(text) {
|
|
|
40597
40723
|
|
|
40598
40724
|
// src/agents/acp/onboarding.ts
|
|
40599
40725
|
var import_child_process28 = require("child_process");
|
|
40600
|
-
var
|
|
40601
|
-
var
|
|
40602
|
-
var
|
|
40726
|
+
var fs81 = __toESM(require("fs"));
|
|
40727
|
+
var os59 = __toESM(require("os"));
|
|
40728
|
+
var path90 = __toESM(require("path"));
|
|
40603
40729
|
var _onboardingSeam = {
|
|
40604
|
-
markerPath: (sessionId) =>
|
|
40605
|
-
exists: (p2) =>
|
|
40730
|
+
markerPath: (sessionId) => path90.join(os59.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
|
|
40731
|
+
exists: (p2) => fs81.existsSync(p2),
|
|
40606
40732
|
write: (p2) => {
|
|
40607
|
-
|
|
40608
|
-
|
|
40733
|
+
fs81.mkdirSync(path90.dirname(p2), { recursive: true });
|
|
40734
|
+
fs81.writeFileSync(p2, "");
|
|
40609
40735
|
},
|
|
40610
40736
|
disabled: () => {
|
|
40611
40737
|
const v = process.env.CODEAM_ONBOARDING_DISABLED;
|
|
@@ -40642,7 +40768,7 @@ function resolveRepoName(cwd) {
|
|
|
40642
40768
|
if (name) return name;
|
|
40643
40769
|
}
|
|
40644
40770
|
}
|
|
40645
|
-
const base =
|
|
40771
|
+
const base = path90.basename(cwd || "");
|
|
40646
40772
|
if (base && !isUuid(base)) return base;
|
|
40647
40773
|
return "this project";
|
|
40648
40774
|
}
|
|
@@ -41042,14 +41168,14 @@ var import_crypto5 = require("crypto");
|
|
|
41042
41168
|
|
|
41043
41169
|
// src/services/turn-files/git-changeset.ts
|
|
41044
41170
|
var import_child_process29 = require("child_process");
|
|
41045
|
-
var
|
|
41171
|
+
var fs83 = __toESM(require("fs/promises"));
|
|
41046
41172
|
var import_fs10 = require("fs");
|
|
41047
|
-
var
|
|
41173
|
+
var path92 = __toESM(require("path"));
|
|
41048
41174
|
|
|
41049
41175
|
// src/services/turn-files/review-ignore.ts
|
|
41050
41176
|
var import_ignore2 = __toESM(require("ignore"));
|
|
41051
|
-
var
|
|
41052
|
-
var
|
|
41177
|
+
var fs82 = __toESM(require("fs"));
|
|
41178
|
+
var path91 = __toESM(require("path"));
|
|
41053
41179
|
var CURATED_REVIEW_IGNORE = [
|
|
41054
41180
|
// Google Cloud SDK (the incident) — installs a huge python tree.
|
|
41055
41181
|
"google-cloud-sdk/",
|
|
@@ -41093,7 +41219,7 @@ var CURATED_REVIEW_IGNORE = [
|
|
|
41093
41219
|
function makeReviewIgnore(repoRoot) {
|
|
41094
41220
|
const ig = (0, import_ignore2.default)().add(CURATED_REVIEW_IGNORE);
|
|
41095
41221
|
try {
|
|
41096
|
-
const custom =
|
|
41222
|
+
const custom = fs82.readFileSync(path91.join(repoRoot, ".codeam", "reviewignore"), "utf8");
|
|
41097
41223
|
ig.add(custom);
|
|
41098
41224
|
} catch {
|
|
41099
41225
|
}
|
|
@@ -41128,7 +41254,7 @@ async function collectRepoChangeset(opts) {
|
|
|
41128
41254
|
const rows = parseStatus(status2).filter(
|
|
41129
41255
|
(row) => !isIgnoredFilePath(row.filePath) && !reviewIgnore(row.filePath) && // A socket, FIFO or device node is never a change to review (a
|
|
41130
41256
|
// `cc-socks/1522.sock` reached the Files tab).
|
|
41131
|
-
isReviewablePath(
|
|
41257
|
+
isReviewablePath(path92.join(opts.repoRoot, row.filePath))
|
|
41132
41258
|
);
|
|
41133
41259
|
const MAX_CHANGESET_FILES = Math.max(1, Number(process.env.CODEAM_MAX_CHANGESET_FILES ?? 500));
|
|
41134
41260
|
const truncated = rows.length > MAX_CHANGESET_FILES;
|
|
@@ -41145,7 +41271,7 @@ async function collectRepoChangeset(opts) {
|
|
|
41145
41271
|
let stats;
|
|
41146
41272
|
if (!truncated && row.fileStatus === "added" && numstatEntry === void 0) {
|
|
41147
41273
|
const lineCount = await readUntrackedLineCount(
|
|
41148
|
-
|
|
41274
|
+
path92.join(opts.repoRoot, row.filePath)
|
|
41149
41275
|
);
|
|
41150
41276
|
stats = { added: lineCount, removed: 0 };
|
|
41151
41277
|
} else {
|
|
@@ -41176,7 +41302,7 @@ function readUntrackedLineCount(absPath) {
|
|
|
41176
41302
|
}
|
|
41177
41303
|
async function defaultReadUntrackedLineCount(absPath) {
|
|
41178
41304
|
try {
|
|
41179
|
-
const content = await
|
|
41305
|
+
const content = await fs83.readFile(absPath, "utf8");
|
|
41180
41306
|
let count = 0;
|
|
41181
41307
|
let pos = -1;
|
|
41182
41308
|
while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
|
|
@@ -41268,7 +41394,7 @@ function defaultRunGit(cwd, args2) {
|
|
|
41268
41394
|
});
|
|
41269
41395
|
}
|
|
41270
41396
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
41271
|
-
const
|
|
41397
|
+
const fs107 = await import("fs/promises");
|
|
41272
41398
|
const out2 = [];
|
|
41273
41399
|
await walk2(workingDir, 0);
|
|
41274
41400
|
return out2;
|
|
@@ -41276,7 +41402,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
41276
41402
|
if (depth2 > maxDepth) return;
|
|
41277
41403
|
let entries2 = [];
|
|
41278
41404
|
try {
|
|
41279
|
-
const dirents = await
|
|
41405
|
+
const dirents = await fs107.readdir(dir, { withFileTypes: true });
|
|
41280
41406
|
entries2 = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
41281
41407
|
} catch {
|
|
41282
41408
|
return;
|
|
@@ -41287,8 +41413,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
41287
41413
|
if (hasGit) {
|
|
41288
41414
|
out2.push({
|
|
41289
41415
|
repoRoot: dir,
|
|
41290
|
-
repoPath:
|
|
41291
|
-
repoName:
|
|
41416
|
+
repoPath: path92.relative(workingDir, dir),
|
|
41417
|
+
repoName: path92.basename(dir)
|
|
41292
41418
|
});
|
|
41293
41419
|
return;
|
|
41294
41420
|
}
|
|
@@ -41296,7 +41422,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
41296
41422
|
if (!entry.isDirectory) continue;
|
|
41297
41423
|
if (entry.name === "node_modules") continue;
|
|
41298
41424
|
if (entry.name === "dist" || entry.name === "build") continue;
|
|
41299
|
-
await walk2(
|
|
41425
|
+
await walk2(path92.join(dir, entry.name), depth2 + 1);
|
|
41300
41426
|
}
|
|
41301
41427
|
}
|
|
41302
41428
|
}
|
|
@@ -41310,8 +41436,8 @@ function isReviewablePath(absPath) {
|
|
|
41310
41436
|
}
|
|
41311
41437
|
|
|
41312
41438
|
// src/services/turn-files/files-outbox.ts
|
|
41313
|
-
var
|
|
41314
|
-
var
|
|
41439
|
+
var fs84 = __toESM(require("fs/promises"));
|
|
41440
|
+
var path93 = __toESM(require("path"));
|
|
41315
41441
|
var import_os15 = require("os");
|
|
41316
41442
|
var HOME_OUTBOX_DIR = ".codeam/outbox";
|
|
41317
41443
|
var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -41344,16 +41470,16 @@ var FilesOutbox = class {
|
|
|
41344
41470
|
backoffIndex = 0;
|
|
41345
41471
|
stopped = false;
|
|
41346
41472
|
constructor(opts) {
|
|
41347
|
-
const base = opts.baseDir ??
|
|
41348
|
-
this.filePath =
|
|
41473
|
+
const base = opts.baseDir ?? path93.join(homeDir(), HOME_OUTBOX_DIR);
|
|
41474
|
+
this.filePath = path93.join(base, `${opts.sessionId}.jsonl`);
|
|
41349
41475
|
this.post = opts.post;
|
|
41350
41476
|
this.autoSchedule = opts.autoSchedule !== false;
|
|
41351
41477
|
}
|
|
41352
41478
|
/** Persist the entry to disk and trigger a flush. Returns once the
|
|
41353
41479
|
* line is durable on disk (not once the POST succeeds). */
|
|
41354
41480
|
async enqueue(entry) {
|
|
41355
|
-
await
|
|
41356
|
-
await
|
|
41481
|
+
await fs84.mkdir(path93.dirname(this.filePath), { recursive: true });
|
|
41482
|
+
await fs84.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
|
|
41357
41483
|
this.backoffIndex = 0;
|
|
41358
41484
|
if (this.autoSchedule) this.scheduleFlush(0);
|
|
41359
41485
|
}
|
|
@@ -41444,7 +41570,7 @@ var FilesOutbox = class {
|
|
|
41444
41570
|
async readAll() {
|
|
41445
41571
|
let raw = "";
|
|
41446
41572
|
try {
|
|
41447
|
-
raw = await
|
|
41573
|
+
raw = await fs84.readFile(this.filePath, "utf8");
|
|
41448
41574
|
} catch {
|
|
41449
41575
|
return [];
|
|
41450
41576
|
}
|
|
@@ -41468,12 +41594,12 @@ var FilesOutbox = class {
|
|
|
41468
41594
|
async rewrite(entries2) {
|
|
41469
41595
|
const tmpPath = `${this.filePath}.${process.pid}.tmp`;
|
|
41470
41596
|
if (entries2.length === 0) {
|
|
41471
|
-
await
|
|
41597
|
+
await fs84.unlink(this.filePath).catch(() => void 0);
|
|
41472
41598
|
return;
|
|
41473
41599
|
}
|
|
41474
41600
|
const payload = entries2.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
41475
|
-
await
|
|
41476
|
-
await
|
|
41601
|
+
await fs84.writeFile(tmpPath, payload, "utf8");
|
|
41602
|
+
await fs84.rename(tmpPath, this.filePath);
|
|
41477
41603
|
}
|
|
41478
41604
|
};
|
|
41479
41605
|
function applyJitter(ms) {
|
|
@@ -41843,8 +41969,8 @@ async function readActiveConversationMarker(cwd, homeDir2) {
|
|
|
41843
41969
|
|
|
41844
41970
|
// src/packs/gates.ts
|
|
41845
41971
|
var import_node_child_process31 = require("child_process");
|
|
41846
|
-
var
|
|
41847
|
-
var
|
|
41972
|
+
var fs86 = __toESM(require("fs"));
|
|
41973
|
+
var path95 = __toESM(require("path"));
|
|
41848
41974
|
var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((resolve13) => {
|
|
41849
41975
|
(0, import_node_child_process31.execFile)(
|
|
41850
41976
|
file,
|
|
@@ -41894,7 +42020,7 @@ async function changedFiles(run3, cwd, from, to) {
|
|
|
41894
42020
|
}
|
|
41895
42021
|
function readWorkspaceFile(cwd, relPath) {
|
|
41896
42022
|
try {
|
|
41897
|
-
return
|
|
42023
|
+
return fs86.readFileSync(path95.join(cwd, relPath), "utf8");
|
|
41898
42024
|
} catch {
|
|
41899
42025
|
return null;
|
|
41900
42026
|
}
|
|
@@ -41903,14 +42029,14 @@ var NO_TEST_PLACEHOLDER = 'echo "Error: no test specified"';
|
|
|
41903
42029
|
var CHECKS_TIMEOUT_MS = 5 * 6e4;
|
|
41904
42030
|
function detectChecksCommand(cwd) {
|
|
41905
42031
|
try {
|
|
41906
|
-
const cfg = JSON.parse(
|
|
42032
|
+
const cfg = JSON.parse(fs86.readFileSync(path95.join(cwd, ".codeam", "pack.json"), "utf8"));
|
|
41907
42033
|
if (typeof cfg.checksCommand === "string" && cfg.checksCommand.trim().length > 0) {
|
|
41908
42034
|
return cfg.checksCommand.trim();
|
|
41909
42035
|
}
|
|
41910
42036
|
} catch {
|
|
41911
42037
|
}
|
|
41912
42038
|
try {
|
|
41913
|
-
const pkg = JSON.parse(
|
|
42039
|
+
const pkg = JSON.parse(fs86.readFileSync(path95.join(cwd, "package.json"), "utf8"));
|
|
41914
42040
|
const test = pkg.scripts?.test;
|
|
41915
42041
|
if (typeof test === "string" && test.trim().length > 0 && !test.includes(NO_TEST_PLACEHOLDER)) {
|
|
41916
42042
|
return "npm test";
|
|
@@ -41928,39 +42054,39 @@ ${res.stderr}`.trim();
|
|
|
41928
42054
|
}
|
|
41929
42055
|
|
|
41930
42056
|
// src/packs/run-store.ts
|
|
41931
|
-
var
|
|
41932
|
-
var
|
|
42057
|
+
var fs87 = __toESM(require("fs"));
|
|
42058
|
+
var path96 = __toESM(require("path"));
|
|
41933
42059
|
var crypto5 = __toESM(require("crypto"));
|
|
41934
42060
|
function packsDir(cwd) {
|
|
41935
|
-
return
|
|
42061
|
+
return path96.join(cwd, ".codeam", "packs");
|
|
41936
42062
|
}
|
|
41937
42063
|
function runDir(cwd, runId) {
|
|
41938
|
-
return
|
|
42064
|
+
return path96.join(packsDir(cwd), runId);
|
|
41939
42065
|
}
|
|
41940
42066
|
function newRunId() {
|
|
41941
42067
|
return `pk_${Date.now().toString(36)}_${crypto5.randomBytes(4).toString("hex")}`;
|
|
41942
42068
|
}
|
|
41943
42069
|
function writeJsonAtomic(file, value) {
|
|
41944
|
-
|
|
42070
|
+
fs87.mkdirSync(path96.dirname(file), { recursive: true });
|
|
41945
42071
|
const tmp = `${file}.tmp`;
|
|
41946
|
-
|
|
41947
|
-
|
|
42072
|
+
fs87.writeFileSync(tmp, JSON.stringify(value, null, 2));
|
|
42073
|
+
fs87.renameSync(tmp, file);
|
|
41948
42074
|
}
|
|
41949
42075
|
function saveRun(cwd, state) {
|
|
41950
|
-
writeJsonAtomic(
|
|
42076
|
+
writeJsonAtomic(path96.join(runDir(cwd, state.runId), "run.json"), state);
|
|
41951
42077
|
}
|
|
41952
42078
|
function saveStageHandoff(cwd, runId, stageIndex, role, handoff) {
|
|
41953
42079
|
const name = `${String(stageIndex + 1).padStart(2, "0")}-${role}.json`;
|
|
41954
|
-
writeJsonAtomic(
|
|
42080
|
+
writeJsonAtomic(path96.join(runDir(cwd, runId), name), handoff);
|
|
41955
42081
|
}
|
|
41956
42082
|
function loadLatestRun(cwd) {
|
|
41957
42083
|
try {
|
|
41958
42084
|
const dir = packsDir(cwd);
|
|
41959
|
-
const entries2 =
|
|
42085
|
+
const entries2 = fs87.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
41960
42086
|
for (let i = entries2.length - 1; i >= 0; i--) {
|
|
41961
|
-
const file =
|
|
42087
|
+
const file = path96.join(dir, entries2[i], "run.json");
|
|
41962
42088
|
try {
|
|
41963
|
-
const parsed = JSON.parse(
|
|
42089
|
+
const parsed = JSON.parse(fs87.readFileSync(file, "utf8"));
|
|
41964
42090
|
if (parsed && typeof parsed.runId === "string") return parsed;
|
|
41965
42091
|
} catch {
|
|
41966
42092
|
}
|
|
@@ -41971,17 +42097,17 @@ function loadLatestRun(cwd) {
|
|
|
41971
42097
|
}
|
|
41972
42098
|
function ensureLedgerIgnored(cwd) {
|
|
41973
42099
|
try {
|
|
41974
|
-
const gitDir =
|
|
41975
|
-
if (!
|
|
41976
|
-
const exclude =
|
|
42100
|
+
const gitDir = path96.join(cwd, ".git");
|
|
42101
|
+
if (!fs87.existsSync(gitDir)) return;
|
|
42102
|
+
const exclude = path96.join(gitDir, "info", "exclude");
|
|
41977
42103
|
let existing = "";
|
|
41978
42104
|
try {
|
|
41979
|
-
existing =
|
|
42105
|
+
existing = fs87.readFileSync(exclude, "utf8");
|
|
41980
42106
|
} catch {
|
|
41981
42107
|
}
|
|
41982
42108
|
if (existing.includes(".codeam/packs/")) return;
|
|
41983
|
-
|
|
41984
|
-
|
|
42109
|
+
fs87.mkdirSync(path96.dirname(exclude), { recursive: true });
|
|
42110
|
+
fs87.writeFileSync(exclude, `${existing.trimEnd()}
|
|
41985
42111
|
.codeam/packs/
|
|
41986
42112
|
`.trimStart());
|
|
41987
42113
|
} catch {
|
|
@@ -42976,20 +43102,20 @@ async function mcpRouter() {
|
|
|
42976
43102
|
}
|
|
42977
43103
|
|
|
42978
43104
|
// src/integrations/mcp-secrets.ts
|
|
42979
|
-
var
|
|
42980
|
-
var
|
|
42981
|
-
var
|
|
43105
|
+
var fs89 = __toESM(require("fs"));
|
|
43106
|
+
var os62 = __toESM(require("os"));
|
|
43107
|
+
var path98 = __toESM(require("path"));
|
|
42982
43108
|
var MCP_SECRETS_FILE_ENV = "CODEAM_MCP_SECRETS_FILE";
|
|
42983
43109
|
function mcpSecretsDir() {
|
|
42984
|
-
return
|
|
43110
|
+
return path98.join(os62.homedir(), ".codeam", "mcp-secrets");
|
|
42985
43111
|
}
|
|
42986
43112
|
function mcpSecretsPath(scope, pid = process.pid) {
|
|
42987
|
-
return
|
|
43113
|
+
return path98.join(mcpSecretsDir(), `${pid}-${scope}.json`);
|
|
42988
43114
|
}
|
|
42989
43115
|
var registeredForCleanup = /* @__PURE__ */ new Set();
|
|
42990
43116
|
function readFileVars(file) {
|
|
42991
43117
|
try {
|
|
42992
|
-
const parsed = JSON.parse(
|
|
43118
|
+
const parsed = JSON.parse(fs89.readFileSync(file, "utf8"));
|
|
42993
43119
|
if (!parsed || typeof parsed !== "object") return {};
|
|
42994
43120
|
const out2 = {};
|
|
42995
43121
|
for (const [k2, v] of Object.entries(parsed)) {
|
|
@@ -43011,7 +43137,7 @@ function pidAlive2(pid) {
|
|
|
43011
43137
|
function pruneStale(dir) {
|
|
43012
43138
|
let names = [];
|
|
43013
43139
|
try {
|
|
43014
|
-
names =
|
|
43140
|
+
names = fs89.readdirSync(dir);
|
|
43015
43141
|
} catch {
|
|
43016
43142
|
return;
|
|
43017
43143
|
}
|
|
@@ -43021,25 +43147,25 @@ function pruneStale(dir) {
|
|
|
43021
43147
|
const pid = Number(m[1]);
|
|
43022
43148
|
if (pid === process.pid || pidAlive2(pid)) continue;
|
|
43023
43149
|
try {
|
|
43024
|
-
|
|
43150
|
+
fs89.unlinkSync(path98.join(dir, name));
|
|
43025
43151
|
} catch {
|
|
43026
43152
|
}
|
|
43027
43153
|
}
|
|
43028
43154
|
}
|
|
43029
43155
|
function writeMcpSecrets(vars, file) {
|
|
43030
43156
|
try {
|
|
43031
|
-
const dir =
|
|
43032
|
-
|
|
43157
|
+
const dir = path98.dirname(file);
|
|
43158
|
+
fs89.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
43033
43159
|
pruneStale(dir);
|
|
43034
43160
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
43035
|
-
|
|
43036
|
-
|
|
43037
|
-
|
|
43161
|
+
fs89.writeFileSync(tmp, JSON.stringify(vars), { mode: 384 });
|
|
43162
|
+
fs89.renameSync(tmp, file);
|
|
43163
|
+
fs89.chmodSync(file, 384);
|
|
43038
43164
|
if (!registeredForCleanup.has(file)) {
|
|
43039
43165
|
registeredForCleanup.add(file);
|
|
43040
43166
|
process.once("exit", () => {
|
|
43041
43167
|
try {
|
|
43042
|
-
|
|
43168
|
+
fs89.unlinkSync(file);
|
|
43043
43169
|
} catch {
|
|
43044
43170
|
}
|
|
43045
43171
|
});
|
|
@@ -43129,11 +43255,11 @@ function previewMcpServer(bridge) {
|
|
|
43129
43255
|
};
|
|
43130
43256
|
}
|
|
43131
43257
|
function httpCall(baseUrl, token) {
|
|
43132
|
-
return async (
|
|
43258
|
+
return async (path120, method, body, timeoutMs) => {
|
|
43133
43259
|
const ac = new AbortController();
|
|
43134
43260
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
43135
43261
|
try {
|
|
43136
|
-
const res = await fetch(`${baseUrl}${
|
|
43262
|
+
const res = await fetch(`${baseUrl}${path120}`, {
|
|
43137
43263
|
method,
|
|
43138
43264
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
43139
43265
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -43270,11 +43396,11 @@ function scratchMcpServer(bridge) {
|
|
|
43270
43396
|
};
|
|
43271
43397
|
}
|
|
43272
43398
|
function httpCall2(baseUrl, token) {
|
|
43273
|
-
return async (
|
|
43399
|
+
return async (path120, method, body, timeoutMs) => {
|
|
43274
43400
|
const ac = new AbortController();
|
|
43275
43401
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
43276
43402
|
try {
|
|
43277
|
-
const res = await fetch(`${baseUrl}${
|
|
43403
|
+
const res = await fetch(`${baseUrl}${path120}`, {
|
|
43278
43404
|
method,
|
|
43279
43405
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
43280
43406
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -44174,9 +44300,12 @@ async function routeSquadTask(ctx, target) {
|
|
|
44174
44300
|
if (!routeToAgent) {
|
|
44175
44301
|
return { ok: false, error: "Routing to another agent is not supported on this session." };
|
|
44176
44302
|
}
|
|
44177
|
-
const
|
|
44178
|
-
if (roster && !
|
|
44179
|
-
|
|
44303
|
+
const inRoster = (r) => Boolean(r && r.agents.some((a) => a.agentId === target));
|
|
44304
|
+
if (squad?.roster && !inRoster(squad.roster)) {
|
|
44305
|
+
const fresh = await squad.refreshRoster();
|
|
44306
|
+
if (!inRoster(fresh)) {
|
|
44307
|
+
return { ok: false, error: `Unknown agent '${target}' \u2014 not in your squad.` };
|
|
44308
|
+
}
|
|
44180
44309
|
}
|
|
44181
44310
|
const member = squad?.member(target);
|
|
44182
44311
|
const fastPathArmed = Boolean(member && (member.provisioned || member.binaryVerified));
|
|
@@ -44445,10 +44574,15 @@ async function runStartTaskTurn(ctx, payload, blocks, promptText) {
|
|
|
44445
44574
|
const { client: client3, history } = ctx;
|
|
44446
44575
|
let turnClosed = false;
|
|
44447
44576
|
try {
|
|
44577
|
+
const turnStartedAt = Date.now();
|
|
44448
44578
|
const reply = await promptWithContextFallback(ctx, client3, turnBlocks, turnPieces);
|
|
44449
44579
|
const finalText = streaming.getCurrentText();
|
|
44450
44580
|
noteProviderBillingSignal({ text: finalText, source: "reply", agent: opts.agent });
|
|
44451
|
-
|
|
44581
|
+
const agentReplyClass = agentHooks(opts.agent)?.classifyCompletedReply?.(finalText, {
|
|
44582
|
+
turnStartedAt,
|
|
44583
|
+
env: currentAgentEnv()
|
|
44584
|
+
}) ?? null;
|
|
44585
|
+
if (agentReplyClass === "upgrade_required") {
|
|
44452
44586
|
await streaming.closeWithBubble(CURSOR_UPGRADE_MESSAGE);
|
|
44453
44587
|
turnClosed = true;
|
|
44454
44588
|
history.appendAgentReply(CURSOR_UPGRADE_MESSAGE);
|
|
@@ -44487,7 +44621,7 @@ async function runStartTaskTurn(ctx, payload, blocks, promptText) {
|
|
|
44487
44621
|
error: "provider account has no credits (402)"
|
|
44488
44622
|
});
|
|
44489
44623
|
return;
|
|
44490
|
-
} else if (replyIsAuthFailure(finalText)) {
|
|
44624
|
+
} else if (agentReplyClass === "auth_failed" || replyIsAuthFailure(finalText)) {
|
|
44491
44625
|
await streaming.closeWithBubble(AUTH_FAILURE_MESSAGE);
|
|
44492
44626
|
turnClosed = true;
|
|
44493
44627
|
history.appendAgentReply(AUTH_FAILURE_MESSAGE);
|
|
@@ -44515,6 +44649,18 @@ async function runStartTaskTurn(ctx, payload, blocks, promptText) {
|
|
|
44515
44649
|
error: "agent reply reported 1M-context usage-credits gate"
|
|
44516
44650
|
});
|
|
44517
44651
|
return;
|
|
44652
|
+
} else if (agentReplyClass === "agent_error") {
|
|
44653
|
+
await streaming.closeWithBubble(TURN_FAILURE_MESSAGE);
|
|
44654
|
+
turnClosed = true;
|
|
44655
|
+
history.appendAgentReply(TURN_FAILURE_MESSAGE);
|
|
44656
|
+
void history.flush();
|
|
44657
|
+
turnFiles.flushTurn().catch((err) => {
|
|
44658
|
+
log.warn("acpRunner", `turnFiles.flushTurn failed: ${describeError(err)}`);
|
|
44659
|
+
});
|
|
44660
|
+
log.info("acpRunner", `start_task \u2190 agent-error-in-reply id=${cmd.id.slice(0, 8)}`);
|
|
44661
|
+
reportTurn2(ctx, "failed", "TURN_ERROR");
|
|
44662
|
+
await relay.sendResult(cmd.id, "failed", { error: "agent reply reported an error" });
|
|
44663
|
+
return;
|
|
44518
44664
|
} else if (reply.stopReason === "end_turn" && finalText.trim().length === 0 && !streaming.hasVisibleProgress()) {
|
|
44519
44665
|
const bubble = emptyReplyMessage(opts.agent);
|
|
44520
44666
|
await streaming.closeWithBubble(bubble);
|
|
@@ -46271,16 +46417,15 @@ async function runAcpSession(opts) {
|
|
|
46271
46417
|
const pendingHandoff = { current: null };
|
|
46272
46418
|
const squad = new SquadState({
|
|
46273
46419
|
sessionId: opts.sessionId,
|
|
46274
|
-
auto: getSquadAuto(opts.pluginId)
|
|
46275
|
-
|
|
46276
|
-
const refreshSquadRoster = () => {
|
|
46277
|
-
void fetchSquadRoster({
|
|
46420
|
+
auto: getSquadAuto(opts.pluginId),
|
|
46421
|
+
fetchRoster: () => fetchSquadRoster({
|
|
46278
46422
|
sessionId: opts.sessionId,
|
|
46279
46423
|
pluginId: opts.pluginId,
|
|
46280
46424
|
pluginAuthToken: opts.pluginAuthToken
|
|
46281
|
-
})
|
|
46282
|
-
|
|
46283
|
-
|
|
46425
|
+
})
|
|
46426
|
+
});
|
|
46427
|
+
const refreshSquadRoster = () => {
|
|
46428
|
+
void squad.refreshRoster();
|
|
46284
46429
|
};
|
|
46285
46430
|
refreshSquadRoster();
|
|
46286
46431
|
const pendingProposal = { current: null };
|
|
@@ -46383,17 +46528,17 @@ async function runAcpSession(opts) {
|
|
|
46383
46528
|
switchCredentialEnv = provisionAgentCredentials(agentId, auth);
|
|
46384
46529
|
},
|
|
46385
46530
|
provisionHouseProxy: ({ baseUrl, token, model, managedAgentId }) => {
|
|
46386
|
-
const claudeConfigDir2 =
|
|
46387
|
-
|
|
46531
|
+
const claudeConfigDir2 = path101.join(
|
|
46532
|
+
os64.homedir(),
|
|
46388
46533
|
".codeam",
|
|
46389
46534
|
"house-claude",
|
|
46390
46535
|
`switch-${opts.pluginId}`
|
|
46391
46536
|
);
|
|
46392
46537
|
try {
|
|
46393
|
-
|
|
46538
|
+
fs92.mkdirSync(claudeConfigDir2, { recursive: true, mode: 448 });
|
|
46394
46539
|
} catch {
|
|
46395
46540
|
}
|
|
46396
|
-
const memoryFile =
|
|
46541
|
+
const memoryFile = path101.join(claudeConfigDir2, "CLAUDE.md");
|
|
46397
46542
|
ensureBeadsWorkflowHint(void 0, memoryFile);
|
|
46398
46543
|
ensureAgentStandard(void 0, memoryFile);
|
|
46399
46544
|
if (isScratchWorkspace(process.cwd())) ensureScratchWorkflowHint(void 0, memoryFile);
|
|
@@ -47633,9 +47778,9 @@ function pickPinnedSession(pinnedId, listSessions2) {
|
|
|
47633
47778
|
}
|
|
47634
47779
|
|
|
47635
47780
|
// src/agents/retired-proxy-cleanup.ts
|
|
47636
|
-
var
|
|
47637
|
-
var
|
|
47638
|
-
var
|
|
47781
|
+
var fs93 = __toESM(require("fs"));
|
|
47782
|
+
var path102 = __toESM(require("path"));
|
|
47783
|
+
var os65 = __toESM(require("os"));
|
|
47639
47784
|
var RETIRED_PROXY_RE = /^https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):8787(?:[/?#]|$)/i;
|
|
47640
47785
|
var HEADROOM_CMD_RE = /(^|[\s/"'])headroom(\s|$)/i;
|
|
47641
47786
|
var MARKETPLACE_KEY = "headroom-marketplace";
|
|
@@ -47644,12 +47789,12 @@ function isHeadroomHook(group) {
|
|
|
47644
47789
|
(h) => typeof h?.command === "string" && HEADROOM_CMD_RE.test(h.command)
|
|
47645
47790
|
);
|
|
47646
47791
|
}
|
|
47647
|
-
function sanitizeRetiredProxyConfig(homeDir2 =
|
|
47792
|
+
function sanitizeRetiredProxyConfig(homeDir2 = os65.homedir()) {
|
|
47648
47793
|
const out2 = { inspected: false, changed: false, removed: [] };
|
|
47649
|
-
const file =
|
|
47794
|
+
const file = path102.join(homeDir2, ".claude", "settings.json");
|
|
47650
47795
|
let parsed;
|
|
47651
47796
|
try {
|
|
47652
|
-
parsed = JSON.parse(
|
|
47797
|
+
parsed = JSON.parse(fs93.readFileSync(file, "utf8"));
|
|
47653
47798
|
} catch {
|
|
47654
47799
|
return out2;
|
|
47655
47800
|
}
|
|
@@ -47691,9 +47836,9 @@ function sanitizeRetiredProxyConfig(homeDir2 = os64.homedir()) {
|
|
|
47691
47836
|
if (!out2.changed) return out2;
|
|
47692
47837
|
try {
|
|
47693
47838
|
const tmp = `${file}.codeam.tmp`;
|
|
47694
|
-
|
|
47839
|
+
fs93.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
|
|
47695
47840
|
`, { mode: 384 });
|
|
47696
|
-
|
|
47841
|
+
fs93.renameSync(tmp, file);
|
|
47697
47842
|
} catch {
|
|
47698
47843
|
out2.changed = false;
|
|
47699
47844
|
}
|
|
@@ -48239,7 +48384,7 @@ var AcpDriver = class {
|
|
|
48239
48384
|
};
|
|
48240
48385
|
|
|
48241
48386
|
// src/baton/transcript-mirror.ts
|
|
48242
|
-
var
|
|
48387
|
+
var fs94 = __toESM(require("fs"));
|
|
48243
48388
|
var TranscriptMirror = class {
|
|
48244
48389
|
constructor(deps) {
|
|
48245
48390
|
this.deps = deps;
|
|
@@ -48333,7 +48478,7 @@ var TranscriptMirror = class {
|
|
|
48333
48478
|
}
|
|
48334
48479
|
};
|
|
48335
48480
|
function defaultWatch(file, onChange) {
|
|
48336
|
-
const w3 =
|
|
48481
|
+
const w3 = fs94.watch(file, { persistent: false }, () => onChange());
|
|
48337
48482
|
return () => w3.close();
|
|
48338
48483
|
}
|
|
48339
48484
|
|
|
@@ -48833,16 +48978,16 @@ function keepDeviceAwake(deps = {}) {
|
|
|
48833
48978
|
}
|
|
48834
48979
|
|
|
48835
48980
|
// src/agents/claude/onboarding.ts
|
|
48836
|
-
var
|
|
48837
|
-
var
|
|
48838
|
-
var
|
|
48981
|
+
var fs95 = __toESM(require("fs"));
|
|
48982
|
+
var os67 = __toESM(require("os"));
|
|
48983
|
+
var path103 = __toESM(require("path"));
|
|
48839
48984
|
var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
|
|
48840
48985
|
function ensureClaudeOnboarded(cwd) {
|
|
48841
48986
|
try {
|
|
48842
|
-
const file =
|
|
48987
|
+
const file = path103.join(os67.homedir(), ".claude.json");
|
|
48843
48988
|
let config = {};
|
|
48844
48989
|
try {
|
|
48845
|
-
config = JSON.parse(
|
|
48990
|
+
config = JSON.parse(fs95.readFileSync(file, "utf8"));
|
|
48846
48991
|
} catch {
|
|
48847
48992
|
}
|
|
48848
48993
|
let changed = false;
|
|
@@ -48867,8 +49012,8 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
48867
49012
|
}
|
|
48868
49013
|
}
|
|
48869
49014
|
if (!changed) return;
|
|
48870
|
-
|
|
48871
|
-
|
|
49015
|
+
fs95.mkdirSync(path103.dirname(file), { recursive: true });
|
|
49016
|
+
fs95.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
48872
49017
|
log.info(
|
|
48873
49018
|
"claude",
|
|
48874
49019
|
`pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
|
|
@@ -49740,7 +49885,7 @@ var import_picocolors10 = __toESM(require("picocolors"));
|
|
|
49740
49885
|
var import_child_process30 = require("child_process");
|
|
49741
49886
|
var import_util4 = require("util");
|
|
49742
49887
|
var import_picocolors8 = __toESM(require("picocolors"));
|
|
49743
|
-
var
|
|
49888
|
+
var path104 = __toESM(require("path"));
|
|
49744
49889
|
var execFileP6 = (0, import_util4.promisify)(import_child_process30.execFile);
|
|
49745
49890
|
var MAX_BUFFER = 8 * 1024 * 1024;
|
|
49746
49891
|
function resetStdinForChild() {
|
|
@@ -50229,7 +50374,7 @@ var GitHubCodespacesProvider = class {
|
|
|
50229
50374
|
});
|
|
50230
50375
|
}
|
|
50231
50376
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
50232
|
-
const remoteDir =
|
|
50377
|
+
const remoteDir = path104.posix.dirname(remotePath);
|
|
50233
50378
|
const parts = [
|
|
50234
50379
|
`mkdir -p ${shellQuote(remoteDir)}`,
|
|
50235
50380
|
`cat > ${shellQuote(remotePath)}`
|
|
@@ -50299,7 +50444,7 @@ function shellQuote(s) {
|
|
|
50299
50444
|
// src/services/providers/gitpod.ts
|
|
50300
50445
|
var import_child_process31 = require("child_process");
|
|
50301
50446
|
var import_util5 = require("util");
|
|
50302
|
-
var
|
|
50447
|
+
var path105 = __toESM(require("path"));
|
|
50303
50448
|
var import_picocolors9 = __toESM(require("picocolors"));
|
|
50304
50449
|
var execFileP7 = (0, import_util5.promisify)(import_child_process31.execFile);
|
|
50305
50450
|
var MAX_BUFFER2 = 8 * 1024 * 1024;
|
|
@@ -50539,7 +50684,7 @@ var GitpodProvider = class {
|
|
|
50539
50684
|
});
|
|
50540
50685
|
}
|
|
50541
50686
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
50542
|
-
const remoteDir =
|
|
50687
|
+
const remoteDir = path105.posix.dirname(remotePath);
|
|
50543
50688
|
const parts = [
|
|
50544
50689
|
`mkdir -p ${shellQuote2(remoteDir)}`,
|
|
50545
50690
|
`cat > ${shellQuote2(remotePath)}`
|
|
@@ -50575,7 +50720,7 @@ function shellQuote2(s) {
|
|
|
50575
50720
|
// src/services/providers/gitlab-workspaces.ts
|
|
50576
50721
|
var import_child_process32 = require("child_process");
|
|
50577
50722
|
var import_util6 = require("util");
|
|
50578
|
-
var
|
|
50723
|
+
var path106 = __toESM(require("path"));
|
|
50579
50724
|
var execFileP8 = (0, import_util6.promisify)(import_child_process32.execFile);
|
|
50580
50725
|
var MAX_BUFFER3 = 8 * 1024 * 1024;
|
|
50581
50726
|
var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
|
|
@@ -50835,7 +50980,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
50835
50980
|
}
|
|
50836
50981
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
50837
50982
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
50838
|
-
const remoteDir =
|
|
50983
|
+
const remoteDir = path106.posix.dirname(remotePath);
|
|
50839
50984
|
const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
|
|
50840
50985
|
if (options.mode != null) {
|
|
50841
50986
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
@@ -50903,7 +51048,7 @@ function shellQuote3(s) {
|
|
|
50903
51048
|
// src/services/providers/railway.ts
|
|
50904
51049
|
var import_child_process33 = require("child_process");
|
|
50905
51050
|
var import_util7 = require("util");
|
|
50906
|
-
var
|
|
51051
|
+
var path107 = __toESM(require("path"));
|
|
50907
51052
|
var execFileP9 = (0, import_util7.promisify)(import_child_process33.execFile);
|
|
50908
51053
|
var MAX_BUFFER4 = 8 * 1024 * 1024;
|
|
50909
51054
|
function resetStdinForChild4() {
|
|
@@ -51139,7 +51284,7 @@ var RailwayProvider = class {
|
|
|
51139
51284
|
if (!projectId || !serviceId) {
|
|
51140
51285
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
51141
51286
|
}
|
|
51142
|
-
const remoteDir =
|
|
51287
|
+
const remoteDir = path107.posix.dirname(remotePath);
|
|
51143
51288
|
const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
|
|
51144
51289
|
if (options.mode != null) {
|
|
51145
51290
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
@@ -51679,14 +51824,14 @@ async function stopWorkspaceFromLocal(target) {
|
|
|
51679
51824
|
}
|
|
51680
51825
|
|
|
51681
51826
|
// src/commands/host/host-client.ts
|
|
51682
|
-
var
|
|
51683
|
-
var
|
|
51684
|
-
var
|
|
51827
|
+
var fs96 = __toESM(require("fs"));
|
|
51828
|
+
var os68 = __toESM(require("os"));
|
|
51829
|
+
var path108 = __toESM(require("path"));
|
|
51685
51830
|
var import_node_crypto16 = require("crypto");
|
|
51686
51831
|
function sampleCpuTimes() {
|
|
51687
51832
|
let idle = 0;
|
|
51688
51833
|
let total = 0;
|
|
51689
|
-
for (const cpu of
|
|
51834
|
+
for (const cpu of os68.cpus()) {
|
|
51690
51835
|
const t2 = cpu.times;
|
|
51691
51836
|
idle += t2.idle;
|
|
51692
51837
|
total += t2.user + t2.nice + t2.sys + t2.idle + t2.irq;
|
|
@@ -51706,8 +51851,8 @@ var MetricsCollector = class {
|
|
|
51706
51851
|
const prev = this.prevCpu;
|
|
51707
51852
|
this.prevCpu = current2;
|
|
51708
51853
|
if (!prev) {
|
|
51709
|
-
const cores =
|
|
51710
|
-
const proxy =
|
|
51854
|
+
const cores = os68.cpus().length || 1;
|
|
51855
|
+
const proxy = os68.loadavg()[0] / cores * 100;
|
|
51711
51856
|
return Math.min(100, Math.max(0, Math.round(proxy)));
|
|
51712
51857
|
}
|
|
51713
51858
|
const idleDelta = current2.idle - prev.idle;
|
|
@@ -51720,8 +51865,8 @@ var MetricsCollector = class {
|
|
|
51720
51865
|
collect() {
|
|
51721
51866
|
return {
|
|
51722
51867
|
cpuPct: this.cpuPct(),
|
|
51723
|
-
ramUsedMb: Math.round((
|
|
51724
|
-
ramTotalMb: Math.round(
|
|
51868
|
+
ramUsedMb: Math.round((os68.totalmem() - os68.freemem()) / 1048576),
|
|
51869
|
+
ramTotalMb: Math.round(os68.totalmem() / 1048576),
|
|
51725
51870
|
latencyMs: this.lastLatencyMs
|
|
51726
51871
|
};
|
|
51727
51872
|
}
|
|
@@ -51733,19 +51878,19 @@ function apiBase() {
|
|
|
51733
51878
|
return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
|
|
51734
51879
|
}
|
|
51735
51880
|
function hostIdentityPath() {
|
|
51736
|
-
return
|
|
51881
|
+
return path108.join(os68.homedir(), ".codeam", "host-agent.json");
|
|
51737
51882
|
}
|
|
51738
51883
|
function collectOsInfo() {
|
|
51739
51884
|
return {
|
|
51740
|
-
distro:
|
|
51741
|
-
arch:
|
|
51742
|
-
kernel:
|
|
51885
|
+
distro: os68.platform(),
|
|
51886
|
+
arch: os68.arch(),
|
|
51887
|
+
kernel: os68.release(),
|
|
51743
51888
|
nodeVersion: process.versions.node
|
|
51744
51889
|
};
|
|
51745
51890
|
}
|
|
51746
51891
|
function loadHostIdentity() {
|
|
51747
51892
|
try {
|
|
51748
|
-
const raw =
|
|
51893
|
+
const raw = fs96.readFileSync(hostIdentityPath(), "utf8");
|
|
51749
51894
|
const parsed = JSON.parse(raw);
|
|
51750
51895
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
|
|
51751
51896
|
const p2 = parsed;
|
|
@@ -51774,8 +51919,8 @@ function ensureControlPollSecret(identity, save = saveHostIdentity) {
|
|
|
51774
51919
|
}
|
|
51775
51920
|
function saveHostIdentity(identity) {
|
|
51776
51921
|
const file = hostIdentityPath();
|
|
51777
|
-
|
|
51778
|
-
|
|
51922
|
+
fs96.mkdirSync(path108.dirname(file), { recursive: true, mode: 448 });
|
|
51923
|
+
fs96.writeFileSync(file, JSON.stringify(identity, null, 2), {
|
|
51779
51924
|
encoding: "utf8",
|
|
51780
51925
|
mode: 384
|
|
51781
51926
|
});
|
|
@@ -51820,7 +51965,7 @@ function isTerminalEnrollError(err) {
|
|
|
51820
51965
|
}
|
|
51821
51966
|
function deleteHostIdentity() {
|
|
51822
51967
|
try {
|
|
51823
|
-
|
|
51968
|
+
fs96.rmSync(hostIdentityPath(), { force: true });
|
|
51824
51969
|
} catch {
|
|
51825
51970
|
}
|
|
51826
51971
|
}
|
|
@@ -51844,7 +51989,7 @@ async function postJson(pathname, body) {
|
|
|
51844
51989
|
function resolveHostLabel(label) {
|
|
51845
51990
|
const explicit = label?.trim();
|
|
51846
51991
|
const envLabel = process.env.CODEAM_HOST_LABEL?.trim();
|
|
51847
|
-
const resolved = explicit || envLabel ||
|
|
51992
|
+
const resolved = explicit || envLabel || os68.hostname();
|
|
51848
51993
|
return resolved.slice(0, 80);
|
|
51849
51994
|
}
|
|
51850
51995
|
async function redeemEnrollToken(token, label) {
|
|
@@ -52046,11 +52191,49 @@ async function host(args2) {
|
|
|
52046
52191
|
);
|
|
52047
52192
|
}
|
|
52048
52193
|
|
|
52194
|
+
// src/commands/host/credential-env-store.ts
|
|
52195
|
+
var fs97 = __toESM(require("fs"));
|
|
52196
|
+
var os69 = __toESM(require("os"));
|
|
52197
|
+
var path109 = __toESM(require("path"));
|
|
52198
|
+
function credentialEnvPath(deployId) {
|
|
52199
|
+
if (!DEPLOY_ID_RE.test(deployId) || deployId.includes("..")) return null;
|
|
52200
|
+
return path109.join(os69.homedir(), ".codeam", "credential-env", `${deployId}.json`);
|
|
52201
|
+
}
|
|
52202
|
+
function persistCredentialEnv(deployId, env) {
|
|
52203
|
+
const file = credentialEnvPath(deployId);
|
|
52204
|
+
if (!file) return;
|
|
52205
|
+
try {
|
|
52206
|
+
if (Object.keys(env).length === 0) fs97.rmSync(file, { force: true });
|
|
52207
|
+
else writeJson0600(file, env);
|
|
52208
|
+
} catch (err) {
|
|
52209
|
+
log.warn(
|
|
52210
|
+
"host-agent",
|
|
52211
|
+
`failed to persist the credential env of deploy=${deployId.slice(0, 8)} (best-effort): ${err instanceof Error ? err.message : String(err)}`
|
|
52212
|
+
);
|
|
52213
|
+
}
|
|
52214
|
+
}
|
|
52215
|
+
function readCredentialEnv(deployId) {
|
|
52216
|
+
const file = credentialEnvPath(deployId);
|
|
52217
|
+
if (!file) return {};
|
|
52218
|
+
try {
|
|
52219
|
+
const parsed = JSON.parse(fs97.readFileSync(file, "utf8"));
|
|
52220
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
|
|
52221
|
+
const out2 = {};
|
|
52222
|
+
for (const [k2, v] of Object.entries(parsed)) if (typeof v === "string") out2[k2] = v;
|
|
52223
|
+
return out2;
|
|
52224
|
+
} catch {
|
|
52225
|
+
return {};
|
|
52226
|
+
}
|
|
52227
|
+
}
|
|
52228
|
+
function clearCredentialEnv(deployId) {
|
|
52229
|
+
persistCredentialEnv(deployId, {});
|
|
52230
|
+
}
|
|
52231
|
+
|
|
52049
52232
|
// src/commands/host-agent.ts
|
|
52050
52233
|
var import_node_child_process40 = require("child_process");
|
|
52051
|
-
var
|
|
52052
|
-
var
|
|
52053
|
-
var
|
|
52234
|
+
var os75 = __toESM(require("os"));
|
|
52235
|
+
var fs104 = __toESM(require("fs"));
|
|
52236
|
+
var path116 = __toESM(require("path"));
|
|
52054
52237
|
|
|
52055
52238
|
// src/skills/persist-from-payload.ts
|
|
52056
52239
|
function persistOrClearSkillsFromPayload(skills) {
|
|
@@ -52059,13 +52242,13 @@ function persistOrClearSkillsFromPayload(skills) {
|
|
|
52059
52242
|
}
|
|
52060
52243
|
|
|
52061
52244
|
// src/commands/host/session-state.ts
|
|
52062
|
-
var
|
|
52063
|
-
var
|
|
52064
|
-
var
|
|
52245
|
+
var fs98 = __toESM(require("fs"));
|
|
52246
|
+
var os70 = __toESM(require("os"));
|
|
52247
|
+
var path110 = __toESM(require("path"));
|
|
52065
52248
|
function hostSessionStatePath(env = process.env) {
|
|
52066
52249
|
const override = env.CODEAM_HOST_SESSION_STATE_FILE;
|
|
52067
52250
|
if (override && override.trim()) return override.trim();
|
|
52068
|
-
return
|
|
52251
|
+
return path110.join(os70.homedir(), ".codeam", "host-agent-sessions.json");
|
|
52069
52252
|
}
|
|
52070
52253
|
function isRecord6(v) {
|
|
52071
52254
|
if (typeof v !== "object" || v === null) return false;
|
|
@@ -52076,7 +52259,7 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
52076
52259
|
return {
|
|
52077
52260
|
load() {
|
|
52078
52261
|
try {
|
|
52079
|
-
const raw = JSON.parse(
|
|
52262
|
+
const raw = JSON.parse(fs98.readFileSync(file, "utf8"));
|
|
52080
52263
|
return Array.isArray(raw?.sessions) ? raw.sessions.filter(isRecord6) : null;
|
|
52081
52264
|
} catch {
|
|
52082
52265
|
return null;
|
|
@@ -52084,18 +52267,18 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
52084
52267
|
},
|
|
52085
52268
|
save(list) {
|
|
52086
52269
|
try {
|
|
52087
|
-
|
|
52270
|
+
fs98.mkdirSync(path110.dirname(file), { recursive: true, mode: 448 });
|
|
52088
52271
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
52089
|
-
|
|
52272
|
+
fs98.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
|
|
52090
52273
|
mode: 384
|
|
52091
52274
|
});
|
|
52092
|
-
|
|
52275
|
+
fs98.renameSync(tmp, file);
|
|
52093
52276
|
} catch {
|
|
52094
52277
|
}
|
|
52095
52278
|
},
|
|
52096
52279
|
clear() {
|
|
52097
52280
|
try {
|
|
52098
|
-
|
|
52281
|
+
fs98.rmSync(file, { force: true });
|
|
52099
52282
|
} catch {
|
|
52100
52283
|
}
|
|
52101
52284
|
}
|
|
@@ -52118,10 +52301,10 @@ function planSessionResume(records, max) {
|
|
|
52118
52301
|
return { resume: ordered.slice(0, bound), dropped: ordered.slice(bound) };
|
|
52119
52302
|
}
|
|
52120
52303
|
function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
52121
|
-
const target =
|
|
52304
|
+
const target = path110.resolve(cwd);
|
|
52122
52305
|
const reconnectable = (s) => !!s.pluginId && !!s.pollSecret && !!s.agent;
|
|
52123
52306
|
const matches = sessions3.filter(
|
|
52124
|
-
(s) => !!s.cwd &&
|
|
52307
|
+
(s) => !!s.cwd && path110.resolve(s.cwd) === target && reconnectable(s)
|
|
52125
52308
|
);
|
|
52126
52309
|
if (matches.length > 0) {
|
|
52127
52310
|
matches.sort((a, b) => b.pairedAt - a.pairedAt);
|
|
@@ -52133,11 +52316,11 @@ function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
|
52133
52316
|
|
|
52134
52317
|
// src/commands/host/git-tooling.ts
|
|
52135
52318
|
var import_node_child_process34 = require("child_process");
|
|
52136
|
-
var
|
|
52137
|
-
var
|
|
52138
|
-
var
|
|
52319
|
+
var fs99 = __toESM(require("fs"));
|
|
52320
|
+
var os71 = __toESM(require("os"));
|
|
52321
|
+
var path111 = __toESM(require("path"));
|
|
52139
52322
|
function codeamBinDir() {
|
|
52140
|
-
return process.env.CODEAM_BIN_DIR ??
|
|
52323
|
+
return process.env.CODEAM_BIN_DIR ?? path111.join(os71.homedir(), ".codeam", "bin");
|
|
52141
52324
|
}
|
|
52142
52325
|
var FALLBACK_GH_VERSION = "2.62.0";
|
|
52143
52326
|
var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
|
|
@@ -52169,7 +52352,7 @@ async function download(url2, dest) {
|
|
|
52169
52352
|
const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
|
|
52170
52353
|
if (!res.ok || !res.body) return false;
|
|
52171
52354
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
52172
|
-
|
|
52355
|
+
fs99.writeFileSync(dest, buf);
|
|
52173
52356
|
return true;
|
|
52174
52357
|
} catch {
|
|
52175
52358
|
return false;
|
|
@@ -52192,8 +52375,8 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
52192
52375
|
const version3 = await resolveVersionFn(token);
|
|
52193
52376
|
const asset = `gh_${version3}_${osToken}_${arch2}`;
|
|
52194
52377
|
const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
|
|
52195
|
-
const tmpRoot =
|
|
52196
|
-
const archive =
|
|
52378
|
+
const tmpRoot = fs99.mkdtempSync(path111.join(os71.tmpdir(), "codeam-gh-"));
|
|
52379
|
+
const archive = path111.join(tmpRoot, `${asset}.${ext}`);
|
|
52197
52380
|
if (!await downloadFn(url2, archive)) {
|
|
52198
52381
|
log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
|
|
52199
52382
|
return null;
|
|
@@ -52203,16 +52386,16 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
52203
52386
|
log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
|
|
52204
52387
|
return null;
|
|
52205
52388
|
}
|
|
52206
|
-
const extractedBin =
|
|
52207
|
-
if (!
|
|
52389
|
+
const extractedBin = path111.join(tmpRoot, asset, "bin", binaryName);
|
|
52390
|
+
if (!fs99.existsSync(extractedBin)) {
|
|
52208
52391
|
log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
|
|
52209
52392
|
return null;
|
|
52210
52393
|
}
|
|
52211
52394
|
const binDir = codeamBinDir();
|
|
52212
|
-
|
|
52213
|
-
const target =
|
|
52214
|
-
|
|
52215
|
-
|
|
52395
|
+
fs99.mkdirSync(binDir, { recursive: true });
|
|
52396
|
+
const target = path111.join(binDir, binaryName);
|
|
52397
|
+
fs99.copyFileSync(extractedBin, target);
|
|
52398
|
+
fs99.chmodSync(target, 493);
|
|
52216
52399
|
log.info("host-agent", `gh installed to ${target} (v${version3})`);
|
|
52217
52400
|
return target;
|
|
52218
52401
|
} catch (e) {
|
|
@@ -52249,19 +52432,19 @@ async function ensureGhAuth(runner, ghCmd, token) {
|
|
|
52249
52432
|
}
|
|
52250
52433
|
function ghConfigDir() {
|
|
52251
52434
|
if (process.env.GH_CONFIG_DIR) return process.env.GH_CONFIG_DIR;
|
|
52252
|
-
if (process.env.XDG_CONFIG_HOME) return
|
|
52435
|
+
if (process.env.XDG_CONFIG_HOME) return path111.join(process.env.XDG_CONFIG_HOME, "gh");
|
|
52253
52436
|
if (process.platform === "win32" && process.env.APPDATA) {
|
|
52254
|
-
return
|
|
52437
|
+
return path111.join(process.env.APPDATA, "GitHub CLI");
|
|
52255
52438
|
}
|
|
52256
|
-
return
|
|
52439
|
+
return path111.join(os71.homedir(), ".config", "gh");
|
|
52257
52440
|
}
|
|
52258
52441
|
function writeGhHostsToken(token) {
|
|
52259
52442
|
try {
|
|
52260
52443
|
const dir = ghConfigDir();
|
|
52261
|
-
const file =
|
|
52262
|
-
if (
|
|
52263
|
-
|
|
52264
|
-
|
|
52444
|
+
const file = path111.join(dir, "hosts.yml");
|
|
52445
|
+
if (fs99.existsSync(file)) return false;
|
|
52446
|
+
fs99.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
52447
|
+
fs99.writeFileSync(
|
|
52265
52448
|
file,
|
|
52266
52449
|
`github.com:
|
|
52267
52450
|
oauth_token: ${token}
|
|
@@ -52304,8 +52487,8 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
52304
52487
|
const version3 = await resolveLatestGlabVersion();
|
|
52305
52488
|
const asset = `glab_${version3}_${osToken}_${arch2}`;
|
|
52306
52489
|
const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
|
|
52307
|
-
const tmpRoot =
|
|
52308
|
-
const archive =
|
|
52490
|
+
const tmpRoot = fs99.mkdtempSync(path111.join(os71.tmpdir(), "codeam-glab-"));
|
|
52491
|
+
const archive = path111.join(tmpRoot, `${asset}.${ext}`);
|
|
52309
52492
|
if (!await downloadFn(url2, archive)) {
|
|
52310
52493
|
log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
|
|
52311
52494
|
return null;
|
|
@@ -52316,20 +52499,20 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
52316
52499
|
return null;
|
|
52317
52500
|
}
|
|
52318
52501
|
const candidates = [
|
|
52319
|
-
|
|
52320
|
-
|
|
52321
|
-
|
|
52502
|
+
path111.join(tmpRoot, "bin", binaryName),
|
|
52503
|
+
path111.join(tmpRoot, asset, "bin", binaryName),
|
|
52504
|
+
path111.join(tmpRoot, binaryName)
|
|
52322
52505
|
];
|
|
52323
|
-
const extractedBin = candidates.find((c2) =>
|
|
52506
|
+
const extractedBin = candidates.find((c2) => fs99.existsSync(c2));
|
|
52324
52507
|
if (!extractedBin) {
|
|
52325
52508
|
log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
|
|
52326
52509
|
return null;
|
|
52327
52510
|
}
|
|
52328
52511
|
const binDir = codeamBinDir();
|
|
52329
|
-
|
|
52330
|
-
const target =
|
|
52331
|
-
|
|
52332
|
-
|
|
52512
|
+
fs99.mkdirSync(binDir, { recursive: true });
|
|
52513
|
+
const target = path111.join(binDir, binaryName);
|
|
52514
|
+
fs99.copyFileSync(extractedBin, target);
|
|
52515
|
+
fs99.chmodSync(target, 493);
|
|
52333
52516
|
log.info("host-agent", `glab installed to ${target} (v${version3})`);
|
|
52334
52517
|
return target;
|
|
52335
52518
|
} catch (e) {
|
|
@@ -52408,14 +52591,14 @@ var defaultGitToolingRunner = {
|
|
|
52408
52591
|
};
|
|
52409
52592
|
|
|
52410
52593
|
// src/lib/cli-versions.ts
|
|
52411
|
-
var
|
|
52412
|
-
var
|
|
52413
|
-
var
|
|
52594
|
+
var fs101 = __toESM(require("fs"));
|
|
52595
|
+
var os73 = __toESM(require("os"));
|
|
52596
|
+
var path113 = __toESM(require("path"));
|
|
52414
52597
|
|
|
52415
52598
|
// src/lib/updateNotifier.ts
|
|
52416
|
-
var
|
|
52417
|
-
var
|
|
52418
|
-
var
|
|
52599
|
+
var fs100 = __toESM(require("fs"));
|
|
52600
|
+
var os72 = __toESM(require("os"));
|
|
52601
|
+
var path112 = __toESM(require("path"));
|
|
52419
52602
|
var https8 = __toESM(require("https"));
|
|
52420
52603
|
var import_node_child_process35 = require("child_process");
|
|
52421
52604
|
var import_picocolors12 = __toESM(require("picocolors"));
|
|
@@ -52424,12 +52607,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
|
|
|
52424
52607
|
var TTL_MS = 24 * 60 * 60 * 1e3;
|
|
52425
52608
|
var REQUEST_TIMEOUT_MS = 1500;
|
|
52426
52609
|
function cachePath() {
|
|
52427
|
-
const dir =
|
|
52428
|
-
return
|
|
52610
|
+
const dir = path112.join(os72.homedir(), ".codeam");
|
|
52611
|
+
return path112.join(dir, "update-check.json");
|
|
52429
52612
|
}
|
|
52430
52613
|
function readCache() {
|
|
52431
52614
|
try {
|
|
52432
|
-
const raw =
|
|
52615
|
+
const raw = fs100.readFileSync(cachePath(), "utf8");
|
|
52433
52616
|
const parsed = JSON.parse(raw);
|
|
52434
52617
|
if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
|
|
52435
52618
|
return parsed;
|
|
@@ -52440,10 +52623,10 @@ function readCache() {
|
|
|
52440
52623
|
function writeCache(cache) {
|
|
52441
52624
|
try {
|
|
52442
52625
|
const file = cachePath();
|
|
52443
|
-
|
|
52626
|
+
fs100.mkdirSync(path112.dirname(file), { recursive: true });
|
|
52444
52627
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
52445
|
-
|
|
52446
|
-
|
|
52628
|
+
fs100.writeFileSync(tmp, JSON.stringify(cache));
|
|
52629
|
+
fs100.renameSync(tmp, file);
|
|
52447
52630
|
} catch {
|
|
52448
52631
|
}
|
|
52449
52632
|
}
|
|
@@ -52517,8 +52700,8 @@ function isLinkedInstall() {
|
|
|
52517
52700
|
timeout: 2e3
|
|
52518
52701
|
}).trim();
|
|
52519
52702
|
if (!root) return false;
|
|
52520
|
-
const pkgPath =
|
|
52521
|
-
return
|
|
52703
|
+
const pkgPath = path112.join(root, PKG_NAME);
|
|
52704
|
+
return fs100.lstatSync(pkgPath).isSymbolicLink();
|
|
52522
52705
|
} catch {
|
|
52523
52706
|
return false;
|
|
52524
52707
|
}
|
|
@@ -52554,7 +52737,7 @@ function maybeAutoUpdate(currentVersion, latest) {
|
|
|
52554
52737
|
return;
|
|
52555
52738
|
}
|
|
52556
52739
|
try {
|
|
52557
|
-
|
|
52740
|
+
fs100.unlinkSync(cachePath());
|
|
52558
52741
|
} catch {
|
|
52559
52742
|
}
|
|
52560
52743
|
process.stderr.write(` ${import_picocolors12.default.green("\u2713")} Updated. Resuming session...
|
|
@@ -52570,7 +52753,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
52570
52753
|
if (process.env.NODE_ENV === "test") return;
|
|
52571
52754
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
52572
52755
|
if (process.env.CI) return;
|
|
52573
|
-
const current2 = true ? "2.76.
|
|
52756
|
+
const current2 = true ? "2.76.47" : null;
|
|
52574
52757
|
if (!current2) return;
|
|
52575
52758
|
const cache = readCache();
|
|
52576
52759
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -52587,7 +52770,7 @@ function checkForUpdates() {
|
|
|
52587
52770
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
52588
52771
|
if (process.env.CI) return;
|
|
52589
52772
|
if (!process.stdout.isTTY) return;
|
|
52590
|
-
const current2 = true ? "2.76.
|
|
52773
|
+
const current2 = true ? "2.76.47" : null;
|
|
52591
52774
|
if (!current2) return;
|
|
52592
52775
|
const cache = readCache();
|
|
52593
52776
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -52610,10 +52793,10 @@ function versionedModeSupported(platform3 = process.platform) {
|
|
|
52610
52793
|
return platform3 !== "win32";
|
|
52611
52794
|
}
|
|
52612
52795
|
function cliVersionsRoot(env = process.env) {
|
|
52613
|
-
return env.CODEAM_CLI_VERSIONS_DIR ||
|
|
52796
|
+
return env.CODEAM_CLI_VERSIONS_DIR || path113.join(os73.homedir(), ".codeam", "cli");
|
|
52614
52797
|
}
|
|
52615
52798
|
function packageDirOf(versionDir) {
|
|
52616
|
-
return
|
|
52799
|
+
return path113.join(versionDir, "node_modules", CLI_PKG);
|
|
52617
52800
|
}
|
|
52618
52801
|
function isRecord7(v) {
|
|
52619
52802
|
return typeof v === "object" && v !== null;
|
|
@@ -52621,7 +52804,7 @@ function isRecord7(v) {
|
|
|
52621
52804
|
function readPkg2(versionDir) {
|
|
52622
52805
|
try {
|
|
52623
52806
|
const raw = JSON.parse(
|
|
52624
|
-
|
|
52807
|
+
fs101.readFileSync(path113.join(packageDirOf(versionDir), "package.json"), "utf8")
|
|
52625
52808
|
);
|
|
52626
52809
|
return isRecord7(raw) ? raw : null;
|
|
52627
52810
|
} catch {
|
|
@@ -52634,15 +52817,15 @@ function entryOf(versionDir) {
|
|
|
52634
52817
|
const bin = pkg.bin;
|
|
52635
52818
|
const named = isRecord7(bin) ? bin.codeam : void 0;
|
|
52636
52819
|
const rel = typeof bin === "string" ? bin : typeof named === "string" ? named : "dist/index.js";
|
|
52637
|
-
const entry =
|
|
52638
|
-
return
|
|
52820
|
+
const entry = path113.join(packageDirOf(versionDir), rel);
|
|
52821
|
+
return fs101.existsSync(entry) ? entry : null;
|
|
52639
52822
|
}
|
|
52640
52823
|
function launcherOf(versionDir) {
|
|
52641
52824
|
const entry = entryOf(versionDir);
|
|
52642
52825
|
if (!entry) return null;
|
|
52643
|
-
const bin =
|
|
52826
|
+
const bin = path113.join(versionDir, "node_modules", ".bin", "codeam");
|
|
52644
52827
|
try {
|
|
52645
|
-
return
|
|
52828
|
+
return fs101.realpathSync(bin) === fs101.realpathSync(entry) ? bin : entry;
|
|
52646
52829
|
} catch {
|
|
52647
52830
|
return entry;
|
|
52648
52831
|
}
|
|
@@ -52655,16 +52838,16 @@ var BAD_MARKER_TTL_MS = 24 * 60 * 6e4;
|
|
|
52655
52838
|
var PRE_READY_WINDOW_MS = 60 * 6e4;
|
|
52656
52839
|
function isBad(versionDir, now = Date.now()) {
|
|
52657
52840
|
try {
|
|
52658
|
-
return now -
|
|
52841
|
+
return now - fs101.statSync(path113.join(versionDir, ".bad")).mtimeMs < BAD_MARKER_TTL_MS;
|
|
52659
52842
|
} catch {
|
|
52660
52843
|
return false;
|
|
52661
52844
|
}
|
|
52662
52845
|
}
|
|
52663
52846
|
function recordPreReadyFailure(versionDir, now = Date.now()) {
|
|
52664
|
-
const file =
|
|
52847
|
+
const file = path113.join(versionDir, ".prefail");
|
|
52665
52848
|
let count = 0;
|
|
52666
52849
|
try {
|
|
52667
|
-
const [n, at3] =
|
|
52850
|
+
const [n, at3] = fs101.readFileSync(file, "utf8").trim().split(" ").map(Number);
|
|
52668
52851
|
if (Number.isFinite(n) && Number.isFinite(at3) && now - at3 < PRE_READY_WINDOW_MS) {
|
|
52669
52852
|
count = n;
|
|
52670
52853
|
}
|
|
@@ -52672,45 +52855,45 @@ function recordPreReadyFailure(versionDir, now = Date.now()) {
|
|
|
52672
52855
|
}
|
|
52673
52856
|
count += 1;
|
|
52674
52857
|
try {
|
|
52675
|
-
|
|
52858
|
+
fs101.writeFileSync(file, `${count} ${now}`);
|
|
52676
52859
|
} catch {
|
|
52677
52860
|
}
|
|
52678
52861
|
return count;
|
|
52679
52862
|
}
|
|
52680
52863
|
function clearPreReadyFailures(versionDir) {
|
|
52681
|
-
|
|
52864
|
+
fs101.rmSync(path113.join(versionDir, ".prefail"), { force: true });
|
|
52682
52865
|
}
|
|
52683
52866
|
function markBad(versionDir, reason) {
|
|
52684
52867
|
try {
|
|
52685
|
-
|
|
52868
|
+
fs101.writeFileSync(path113.join(versionDir, ".bad"), `${(/* @__PURE__ */ new Date()).toISOString()} ${reason}
|
|
52686
52869
|
`);
|
|
52687
52870
|
} catch {
|
|
52688
52871
|
}
|
|
52689
52872
|
}
|
|
52690
52873
|
function pointerTarget(root, name) {
|
|
52691
52874
|
try {
|
|
52692
|
-
return
|
|
52875
|
+
return fs101.realpathSync(path113.join(root, name));
|
|
52693
52876
|
} catch {
|
|
52694
52877
|
return null;
|
|
52695
52878
|
}
|
|
52696
52879
|
}
|
|
52697
52880
|
function atomicPoint(root, name, targetDir) {
|
|
52698
|
-
const realRoot =
|
|
52699
|
-
const tmp =
|
|
52700
|
-
|
|
52881
|
+
const realRoot = fs101.realpathSync(root);
|
|
52882
|
+
const tmp = path113.join(realRoot, `.${name}.tmp-${process.pid}-${Date.now()}`);
|
|
52883
|
+
fs101.symlinkSync(path113.relative(realRoot, fs101.realpathSync(targetDir)), tmp, "dir");
|
|
52701
52884
|
try {
|
|
52702
|
-
|
|
52885
|
+
fs101.renameSync(tmp, path113.join(realRoot, name));
|
|
52703
52886
|
} catch (err) {
|
|
52704
|
-
|
|
52887
|
+
fs101.rmSync(tmp, { force: true });
|
|
52705
52888
|
throw err;
|
|
52706
52889
|
}
|
|
52707
52890
|
}
|
|
52708
52891
|
function samePath(a, b) {
|
|
52709
52892
|
const canon = (p2) => {
|
|
52710
52893
|
try {
|
|
52711
|
-
return
|
|
52894
|
+
return fs101.realpathSync(p2);
|
|
52712
52895
|
} catch {
|
|
52713
|
-
return
|
|
52896
|
+
return path113.resolve(p2);
|
|
52714
52897
|
}
|
|
52715
52898
|
};
|
|
52716
52899
|
return canon(a) === canon(b);
|
|
@@ -52745,15 +52928,15 @@ function versionDirContaining(root, file) {
|
|
|
52745
52928
|
let real;
|
|
52746
52929
|
let realRoot;
|
|
52747
52930
|
try {
|
|
52748
|
-
real =
|
|
52749
|
-
realRoot =
|
|
52931
|
+
real = fs101.realpathSync(file);
|
|
52932
|
+
realRoot = fs101.realpathSync(root);
|
|
52750
52933
|
} catch {
|
|
52751
52934
|
return null;
|
|
52752
52935
|
}
|
|
52753
|
-
const rel =
|
|
52754
|
-
if (rel.startsWith("..") ||
|
|
52755
|
-
const first = rel.split(
|
|
52756
|
-
return first && SEMVER_DIR.test(first) ?
|
|
52936
|
+
const rel = path113.relative(realRoot, real);
|
|
52937
|
+
if (rel.startsWith("..") || path113.isAbsolute(rel)) return null;
|
|
52938
|
+
const first = rel.split(path113.sep)[0];
|
|
52939
|
+
return first && SEMVER_DIR.test(first) ? path113.join(realRoot, first) : null;
|
|
52757
52940
|
}
|
|
52758
52941
|
function pidAlive3(pid) {
|
|
52759
52942
|
try {
|
|
@@ -52766,9 +52949,9 @@ function pidAlive3(pid) {
|
|
|
52766
52949
|
var CLK_TCK = 100;
|
|
52767
52950
|
function processStartMs(pid) {
|
|
52768
52951
|
try {
|
|
52769
|
-
const stat3 =
|
|
52952
|
+
const stat3 = fs101.readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
52770
52953
|
const ticks = Number(stat3.slice(stat3.lastIndexOf(")") + 2).split(" ")[19]);
|
|
52771
|
-
const btime = /^btime (\d+)$/m.exec(
|
|
52954
|
+
const btime = /^btime (\d+)$/m.exec(fs101.readFileSync("/proc/stat", "utf8"))?.[1];
|
|
52772
52955
|
if (!Number.isFinite(ticks) || !btime) return null;
|
|
52773
52956
|
return Number(btime) * 1e3 + ticks * 1e3 / CLK_TCK;
|
|
52774
52957
|
} catch {
|
|
@@ -52777,10 +52960,10 @@ function processStartMs(pid) {
|
|
|
52777
52960
|
}
|
|
52778
52961
|
var PID_REUSE_SLACK_MS = 2e3;
|
|
52779
52962
|
function livePids(versionDir) {
|
|
52780
|
-
const dir =
|
|
52963
|
+
const dir = path113.join(versionDir, ".pids");
|
|
52781
52964
|
let names;
|
|
52782
52965
|
try {
|
|
52783
|
-
names =
|
|
52966
|
+
names = fs101.readdirSync(dir);
|
|
52784
52967
|
} catch {
|
|
52785
52968
|
return [];
|
|
52786
52969
|
}
|
|
@@ -52789,7 +52972,7 @@ function livePids(versionDir) {
|
|
|
52789
52972
|
const started = processStartMs(pid);
|
|
52790
52973
|
if (started === null) return true;
|
|
52791
52974
|
try {
|
|
52792
|
-
return started <=
|
|
52975
|
+
return started <= fs101.statSync(path113.join(dir, String(pid))).mtimeMs + PID_REUSE_SLACK_MS;
|
|
52793
52976
|
} catch {
|
|
52794
52977
|
return true;
|
|
52795
52978
|
}
|
|
@@ -52798,11 +52981,11 @@ function livePids(versionDir) {
|
|
|
52798
52981
|
function registerRunningVersion(root = cliVersionsRoot(), entry = process.argv[1]) {
|
|
52799
52982
|
const dir = versionDirContaining(root, entry);
|
|
52800
52983
|
if (!dir) return;
|
|
52801
|
-
const file =
|
|
52984
|
+
const file = path113.join(dir, ".pids", String(process.pid));
|
|
52802
52985
|
try {
|
|
52803
|
-
|
|
52804
|
-
|
|
52805
|
-
process.once("exit", () =>
|
|
52986
|
+
fs101.mkdirSync(path113.dirname(file), { recursive: true });
|
|
52987
|
+
fs101.writeFileSync(file, "");
|
|
52988
|
+
process.once("exit", () => fs101.rmSync(file, { force: true }));
|
|
52806
52989
|
} catch {
|
|
52807
52990
|
}
|
|
52808
52991
|
}
|
|
@@ -52810,7 +52993,7 @@ function gcVersions(root) {
|
|
|
52810
52993
|
const removed = [];
|
|
52811
52994
|
let names;
|
|
52812
52995
|
try {
|
|
52813
|
-
names =
|
|
52996
|
+
names = fs101.readdirSync(root).filter((n) => SEMVER_DIR.test(n));
|
|
52814
52997
|
} catch {
|
|
52815
52998
|
return removed;
|
|
52816
52999
|
}
|
|
@@ -52818,13 +53001,13 @@ function gcVersions(root) {
|
|
|
52818
53001
|
[...names].sort((a, b) => compareSemver(b, a)).slice(0, GC_KEEP_NEWEST)
|
|
52819
53002
|
);
|
|
52820
53003
|
for (const p2 of [pointerTarget(root, "current"), pointerTarget(root, "previous")]) {
|
|
52821
|
-
if (p2) keep.add(
|
|
53004
|
+
if (p2) keep.add(path113.basename(p2));
|
|
52822
53005
|
}
|
|
52823
53006
|
for (const name of names) {
|
|
52824
|
-
const dir =
|
|
53007
|
+
const dir = path113.join(root, name);
|
|
52825
53008
|
if (keep.has(name) || livePids(dir).length > 0) continue;
|
|
52826
53009
|
try {
|
|
52827
|
-
|
|
53010
|
+
fs101.rmSync(dir, { recursive: true, force: true });
|
|
52828
53011
|
removed.push(name);
|
|
52829
53012
|
} catch {
|
|
52830
53013
|
}
|
|
@@ -52832,25 +53015,25 @@ function gcVersions(root) {
|
|
|
52832
53015
|
return removed;
|
|
52833
53016
|
}
|
|
52834
53017
|
function acquireInstallLock(root) {
|
|
52835
|
-
const lock =
|
|
53018
|
+
const lock = path113.join(root, ".install.lock");
|
|
52836
53019
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
52837
53020
|
try {
|
|
52838
|
-
const fd =
|
|
52839
|
-
|
|
52840
|
-
|
|
52841
|
-
return () =>
|
|
53021
|
+
const fd = fs101.openSync(lock, "wx");
|
|
53022
|
+
fs101.writeSync(fd, String(process.pid));
|
|
53023
|
+
fs101.closeSync(fd);
|
|
53024
|
+
return () => fs101.rmSync(lock, { force: true });
|
|
52842
53025
|
} catch (err) {
|
|
52843
53026
|
if (err.code !== "EEXIST") return null;
|
|
52844
53027
|
let stale = false;
|
|
52845
53028
|
try {
|
|
52846
|
-
const owner = Number(
|
|
52847
|
-
const age = Date.now() -
|
|
53029
|
+
const owner = Number(fs101.readFileSync(lock, "utf8"));
|
|
53030
|
+
const age = Date.now() - fs101.statSync(lock).mtimeMs;
|
|
52848
53031
|
stale = !Number.isInteger(owner) || !pidAlive3(owner) || age > LOCK_STALE_MS;
|
|
52849
53032
|
} catch {
|
|
52850
53033
|
stale = true;
|
|
52851
53034
|
}
|
|
52852
53035
|
if (!stale) return null;
|
|
52853
|
-
|
|
53036
|
+
fs101.rmSync(lock, { force: true });
|
|
52854
53037
|
}
|
|
52855
53038
|
}
|
|
52856
53039
|
return null;
|
|
@@ -52858,9 +53041,9 @@ function acquireInstallLock(root) {
|
|
|
52858
53041
|
|
|
52859
53042
|
// src/commands/host/host-launch.ts
|
|
52860
53043
|
var import_node_child_process37 = require("child_process");
|
|
52861
|
-
var
|
|
52862
|
-
var
|
|
52863
|
-
var
|
|
53044
|
+
var fs103 = __toESM(require("fs"));
|
|
53045
|
+
var os74 = __toESM(require("os"));
|
|
53046
|
+
var path115 = __toESM(require("path"));
|
|
52864
53047
|
|
|
52865
53048
|
// src/exit-codes.ts
|
|
52866
53049
|
var EXIT_OK = 0;
|
|
@@ -52882,8 +53065,8 @@ var EXIT_CODE_NAMES = {
|
|
|
52882
53065
|
|
|
52883
53066
|
// src/commands/host/self-update.ts
|
|
52884
53067
|
var import_node_child_process36 = require("child_process");
|
|
52885
|
-
var
|
|
52886
|
-
var
|
|
53068
|
+
var fs102 = __toESM(require("fs"));
|
|
53069
|
+
var path114 = __toESM(require("path"));
|
|
52887
53070
|
var SELF_UPDATE_PKG = "codeam-cli";
|
|
52888
53071
|
var SELF_UPDATE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
52889
53072
|
var SELF_UPDATE_STARTUP_DELAY_MS = 5e3;
|
|
@@ -52893,7 +53076,7 @@ var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
|
|
|
52893
53076
|
var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
52894
53077
|
var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
|
|
52895
53078
|
function currentCliVersion() {
|
|
52896
|
-
return true ? "2.76.
|
|
53079
|
+
return true ? "2.76.47" : null;
|
|
52897
53080
|
}
|
|
52898
53081
|
async function installedVersion(deps) {
|
|
52899
53082
|
const ls = await deps.run(
|
|
@@ -53009,9 +53192,9 @@ function collectOldVersions(root) {
|
|
|
53009
53192
|
var VERIFY_TIMEOUT_MS = 3e4;
|
|
53010
53193
|
async function installVersioned(deps, root, latest, running2) {
|
|
53011
53194
|
const node = deps.nodePath ?? process.execPath;
|
|
53012
|
-
const target =
|
|
53195
|
+
const target = path114.join(root, latest);
|
|
53013
53196
|
try {
|
|
53014
|
-
|
|
53197
|
+
fs102.mkdirSync(root, { recursive: true });
|
|
53015
53198
|
} catch {
|
|
53016
53199
|
return { status: "skipped" };
|
|
53017
53200
|
}
|
|
@@ -53035,7 +53218,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
53035
53218
|
}
|
|
53036
53219
|
const reusable = entryOf(target) && versionOf(target) === latest;
|
|
53037
53220
|
if (!reusable) {
|
|
53038
|
-
|
|
53221
|
+
fs102.rmSync(target, { recursive: true, force: true });
|
|
53039
53222
|
const install = await deps.run(
|
|
53040
53223
|
"npm",
|
|
53041
53224
|
[
|
|
@@ -53050,7 +53233,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
53050
53233
|
SELF_UPDATE_INSTALL_TIMEOUT_MS
|
|
53051
53234
|
);
|
|
53052
53235
|
if (install.code !== 0) {
|
|
53053
|
-
|
|
53236
|
+
fs102.rmSync(target, { recursive: true, force: true });
|
|
53054
53237
|
log.warn(
|
|
53055
53238
|
"host-agent",
|
|
53056
53239
|
`self-update: versioned install exited ${String(install.code)} \u2014 staying on ${running2}: ` + install.stderr.slice(-300)
|
|
@@ -53061,7 +53244,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
53061
53244
|
const entry = entryOf(target);
|
|
53062
53245
|
const check = entry ? await deps.run(node, [entry, "--version"], VERIFY_TIMEOUT_MS) : { code: null, stdout: "", stderr: "no entry point" };
|
|
53063
53246
|
if (check.code !== 0 || !check.stdout.includes(latest)) {
|
|
53064
|
-
|
|
53247
|
+
fs102.rmSync(target, { recursive: true, force: true });
|
|
53065
53248
|
log.warn(
|
|
53066
53249
|
"host-agent",
|
|
53067
53250
|
`self-update: ${latest} failed verification (exit ${String(check.code)}: ${(check.stdout + check.stderr).trim().slice(-200)}) \u2014 staying on ${running2}`
|
|
@@ -53077,7 +53260,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
53077
53260
|
return { status: "updated", version: latest };
|
|
53078
53261
|
} catch (err) {
|
|
53079
53262
|
const cur = pointerTarget(root, "current");
|
|
53080
|
-
if (!cur ||
|
|
53263
|
+
if (!cur || path114.basename(cur) !== latest) fs102.rmSync(target, { recursive: true, force: true });
|
|
53081
53264
|
log.warn(
|
|
53082
53265
|
"host-agent",
|
|
53083
53266
|
`self-update: versioned install failed: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -53116,7 +53299,7 @@ function signalHostReady(send = process.send?.bind(process)) {
|
|
|
53116
53299
|
}
|
|
53117
53300
|
function defaultDeps() {
|
|
53118
53301
|
return {
|
|
53119
|
-
ownVersion: true ? "2.76.
|
|
53302
|
+
ownVersion: true ? "2.76.47" : null,
|
|
53120
53303
|
root: cliVersionsRoot(),
|
|
53121
53304
|
args: process.argv.slice(3),
|
|
53122
53305
|
execPath: process.execPath,
|
|
@@ -53213,13 +53396,13 @@ function needsSelfRelaunch(env = process.env, pid = process.pid, ctx = {}) {
|
|
|
53213
53396
|
}
|
|
53214
53397
|
function readPid1Cmdline() {
|
|
53215
53398
|
try {
|
|
53216
|
-
return
|
|
53399
|
+
return fs103.readFileSync("/proc/1/cmdline", "utf8").split("\0").filter(Boolean);
|
|
53217
53400
|
} catch {
|
|
53218
53401
|
return [];
|
|
53219
53402
|
}
|
|
53220
53403
|
}
|
|
53221
53404
|
function isOurTiniEntrypoint(argv) {
|
|
53222
|
-
return argv.some((a) =>
|
|
53405
|
+
return argv.some((a) => path115.basename(a) === "tini") && argv.includes("host-agent");
|
|
53223
53406
|
}
|
|
53224
53407
|
function relaunchArgv(execPath, argv) {
|
|
53225
53408
|
return ["-c", 'sleep 2; exec "$0" "$@"', execPath, ...argv.slice(1)];
|
|
@@ -53261,7 +53444,7 @@ function defaultRestartForUpdate(version3, supervised, io = {}) {
|
|
|
53261
53444
|
}
|
|
53262
53445
|
exit(0);
|
|
53263
53446
|
}
|
|
53264
|
-
function isContainerEnvironment(existsSyncFn =
|
|
53447
|
+
function isContainerEnvironment(existsSyncFn = fs103.existsSync, readFileSyncFn = (p2) => fs103.readFileSync(p2, "utf8")) {
|
|
53265
53448
|
try {
|
|
53266
53449
|
if (existsSyncFn("/.dockerenv")) return true;
|
|
53267
53450
|
} catch {
|
|
@@ -53273,16 +53456,16 @@ function isContainerEnvironment(existsSyncFn = fs101.existsSync, readFileSyncFn
|
|
|
53273
53456
|
}
|
|
53274
53457
|
return false;
|
|
53275
53458
|
}
|
|
53276
|
-
function hostAgentPidFile(home =
|
|
53277
|
-
return
|
|
53459
|
+
function hostAgentPidFile(home = os74.homedir()) {
|
|
53460
|
+
return path115.join(home, ".codeam", "host-agent.pid");
|
|
53278
53461
|
}
|
|
53279
53462
|
function writeHostAgentPidFile(file = hostAgentPidFile(), pid = process.pid) {
|
|
53280
53463
|
try {
|
|
53281
|
-
|
|
53282
|
-
|
|
53464
|
+
fs103.mkdirSync(path115.dirname(file), { recursive: true });
|
|
53465
|
+
fs103.writeFileSync(file, String(pid));
|
|
53283
53466
|
process.once("exit", () => {
|
|
53284
53467
|
try {
|
|
53285
|
-
if (
|
|
53468
|
+
if (fs103.readFileSync(file, "utf8").trim() === String(pid)) fs103.rmSync(file, { force: true });
|
|
53286
53469
|
} catch {
|
|
53287
53470
|
}
|
|
53288
53471
|
});
|
|
@@ -53518,6 +53701,7 @@ ${err.message}` : err.message;
|
|
|
53518
53701
|
// src/commands/host-agent.ts
|
|
53519
53702
|
var HEARTBEAT_INTERVAL_MS = 2e4;
|
|
53520
53703
|
var RESUME_RETRY_BACKOFF_MS = [15e3, 3e4, 6e4, 12e4];
|
|
53704
|
+
var AUTH_FILE_CACHED_IN_MEMORY = /* @__PURE__ */ new Set(["antigravity"]);
|
|
53521
53705
|
var CRASH_RESPAWN_MIN_UPTIME_MS = 6e4;
|
|
53522
53706
|
var RESUME_REPROBE_INTERVAL_MS = 5 * 6e4;
|
|
53523
53707
|
var RESUME_HEALTHY_AFTER_MS = 10 * 6e4;
|
|
@@ -54134,13 +54318,13 @@ var HostAgentSupervisor = class {
|
|
|
54134
54318
|
const relay = this.relay;
|
|
54135
54319
|
if (!relay) return;
|
|
54136
54320
|
const raw = cmd.payload?.path;
|
|
54137
|
-
const target = typeof raw === "string" && raw.trim() ?
|
|
54321
|
+
const target = typeof raw === "string" && raw.trim() ? path116.resolve(raw.trim()) : os75.homedir();
|
|
54138
54322
|
try {
|
|
54139
|
-
const dirents = await
|
|
54323
|
+
const dirents = await fs104.promises.readdir(target, { withFileTypes: true });
|
|
54140
54324
|
const entries2 = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
|
|
54141
54325
|
(a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
|
|
54142
54326
|
);
|
|
54143
|
-
const parent =
|
|
54327
|
+
const parent = path116.dirname(target);
|
|
54144
54328
|
await relay.sendResult(cmd.id, "completed", {
|
|
54145
54329
|
path: target,
|
|
54146
54330
|
// null at the filesystem root so the UI can hide the ".." affordance.
|
|
@@ -54618,14 +54802,14 @@ var HostAgentSupervisor = class {
|
|
|
54618
54802
|
}),
|
|
54619
54803
|
CODEAM_AUTO_TOKEN: payload.autoPairToken
|
|
54620
54804
|
};
|
|
54621
|
-
const houseConfigDir =
|
|
54622
|
-
|
|
54805
|
+
const houseConfigDir = path116.join(
|
|
54806
|
+
os75.homedir(),
|
|
54623
54807
|
".codeam",
|
|
54624
54808
|
"house-claude",
|
|
54625
54809
|
payload.deployId
|
|
54626
54810
|
);
|
|
54627
54811
|
try {
|
|
54628
|
-
|
|
54812
|
+
fs104.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
|
|
54629
54813
|
} catch {
|
|
54630
54814
|
}
|
|
54631
54815
|
childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
|
|
@@ -54642,6 +54826,7 @@ var HostAgentSupervisor = class {
|
|
|
54642
54826
|
const credEnv = provisionAgentCredentials(payload.agentId, auth, void 0);
|
|
54643
54827
|
if (Object.keys(credEnv).length > 0) this.credentialEnvByDeploy.set(payload.deployId, credEnv);
|
|
54644
54828
|
else this.credentialEnvByDeploy.delete(payload.deployId);
|
|
54829
|
+
persistCredentialEnv(payload.deployId, credEnv);
|
|
54645
54830
|
childEnv = {
|
|
54646
54831
|
...credEnv,
|
|
54647
54832
|
CODEAM_AUTO_TOKEN: payload.autoPairToken
|
|
@@ -54654,7 +54839,7 @@ var HostAgentSupervisor = class {
|
|
|
54654
54839
|
report("installing", "installing agent CLI");
|
|
54655
54840
|
await this.runAgentInstall(payload.agentInstallScript);
|
|
54656
54841
|
}
|
|
54657
|
-
const home = process.env.HOME ||
|
|
54842
|
+
const home = process.env.HOME || os75.homedir();
|
|
54658
54843
|
childEnv.PATH = `${home}/.local/bin:${process.env.PATH ?? ""}`;
|
|
54659
54844
|
if (payload.cloneToken) {
|
|
54660
54845
|
try {
|
|
@@ -54662,13 +54847,13 @@ var HostAgentSupervisor = class {
|
|
|
54662
54847
|
if ((payload.repoProvider ?? "github") === "gitlab") {
|
|
54663
54848
|
const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
|
|
54664
54849
|
if (glabCmd) {
|
|
54665
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
54850
|
+
childEnv.PATH = `${codeamBinDir()}${path116.delimiter}${childEnv.PATH}`;
|
|
54666
54851
|
await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
|
|
54667
54852
|
}
|
|
54668
54853
|
} else {
|
|
54669
54854
|
const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
|
|
54670
54855
|
if (ghCmd) {
|
|
54671
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
54856
|
+
childEnv.PATH = `${codeamBinDir()}${path116.delimiter}${childEnv.PATH}`;
|
|
54672
54857
|
await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
|
|
54673
54858
|
}
|
|
54674
54859
|
}
|
|
@@ -54696,9 +54881,9 @@ var HostAgentSupervisor = class {
|
|
|
54696
54881
|
);
|
|
54697
54882
|
if (!payload.suppressOnboardingWelcome) {
|
|
54698
54883
|
try {
|
|
54699
|
-
const cfgDir = childEnv.CLAUDE_CONFIG_DIR ||
|
|
54700
|
-
const projectDir =
|
|
54701
|
-
const hasPriorConversation =
|
|
54884
|
+
const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path116.join(os75.homedir(), ".claude");
|
|
54885
|
+
const projectDir = path116.join(cfgDir, "projects", encodeCwd(cwd));
|
|
54886
|
+
const hasPriorConversation = fs104.existsSync(projectDir) && fs104.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
|
|
54702
54887
|
if (hasPriorConversation) {
|
|
54703
54888
|
childEnv.CODEAM_RESUME_LATEST = "1";
|
|
54704
54889
|
log.info(
|
|
@@ -54852,7 +55037,7 @@ var HostAgentSupervisor = class {
|
|
|
54852
55037
|
fallbackResumeTarget() {
|
|
54853
55038
|
const session = getActiveSession();
|
|
54854
55039
|
if (!session || !session.pluginId || !session.pollSecret || !session.agent) return null;
|
|
54855
|
-
const cwd = session.cwd &&
|
|
55040
|
+
const cwd = session.cwd && fs104.existsSync(session.cwd) ? session.cwd : process.cwd();
|
|
54856
55041
|
if (isFilesystemRoot(cwd)) {
|
|
54857
55042
|
log.warn(
|
|
54858
55043
|
"host-agent",
|
|
@@ -54899,7 +55084,7 @@ var HostAgentSupervisor = class {
|
|
|
54899
55084
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: no saved pairing on this box`);
|
|
54900
55085
|
return;
|
|
54901
55086
|
}
|
|
54902
|
-
if (!session.cwd || !
|
|
55087
|
+
if (!session.cwd || !fs104.existsSync(session.cwd)) {
|
|
54903
55088
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: workspace is gone`);
|
|
54904
55089
|
return;
|
|
54905
55090
|
}
|
|
@@ -54941,7 +55126,7 @@ var HostAgentSupervisor = class {
|
|
|
54941
55126
|
const persisted = new Map((this.sessionStore.load() ?? []).map((r) => [r.deployId, r.agent]));
|
|
54942
55127
|
for (const c2 of this.children.values()) persisted.set(c2.deployId, c2.agent);
|
|
54943
55128
|
return this.listSavedSessions().map((s) => ({ s, deployId: deployIdFromWorkspace(s.cwd) })).filter(
|
|
54944
|
-
(x) => x.deployId !== null && !!x.s.cwd &&
|
|
55129
|
+
(x) => x.deployId !== null && !!x.s.cwd && fs104.existsSync(x.s.cwd)
|
|
54945
55130
|
).map(({ s, deployId }) => {
|
|
54946
55131
|
const agent = persisted.get(deployId);
|
|
54947
55132
|
return { deployId, sessionId: s.id, ...agent ? { agent } : {} };
|
|
@@ -55026,7 +55211,7 @@ var HostAgentSupervisor = class {
|
|
|
55026
55211
|
if (this.children.has(deployId)) return;
|
|
55027
55212
|
const st3 = this.resumeStateFor(target);
|
|
55028
55213
|
try {
|
|
55029
|
-
const cwd =
|
|
55214
|
+
const cwd = fs104.existsSync(target.cwd) ? target.cwd : process.cwd();
|
|
55030
55215
|
if (isWrapperCheckout(cwd)) {
|
|
55031
55216
|
log.warn(
|
|
55032
55217
|
"host-agent",
|
|
@@ -55041,7 +55226,7 @@ var HostAgentSupervisor = class {
|
|
|
55041
55226
|
const proc = this.resumeSpawner(
|
|
55042
55227
|
{
|
|
55043
55228
|
...readHouseProxyChildEnv(deployId),
|
|
55044
|
-
...this.
|
|
55229
|
+
...this.credentialEnvFor(deployId),
|
|
55045
55230
|
CODEAM_RESUME_SESSION_ID: session.id
|
|
55046
55231
|
},
|
|
55047
55232
|
cwd
|
|
@@ -55068,7 +55253,7 @@ var HostAgentSupervisor = class {
|
|
|
55068
55253
|
return;
|
|
55069
55254
|
}
|
|
55070
55255
|
if (tracked && signal) {
|
|
55071
|
-
this.onResumeChildExit(target, 128 + (
|
|
55256
|
+
this.onResumeChildExit(target, 128 + (os75.constants.signals[signal] ?? 9), `signal ${signal}`);
|
|
55072
55257
|
return;
|
|
55073
55258
|
}
|
|
55074
55259
|
log.warn(
|
|
@@ -55111,7 +55296,7 @@ var HostAgentSupervisor = class {
|
|
|
55111
55296
|
if (Date.now() - child.startedAt < CRASH_RESPAWN_MIN_UPTIME_MS) return false;
|
|
55112
55297
|
const session = pickSavedSessionForWorkspace(this.listSavedSessions(), child.cwd);
|
|
55113
55298
|
if (!session) return false;
|
|
55114
|
-
const exitCode = typeof code === "number" ? code : 128 + (signal ?
|
|
55299
|
+
const exitCode = typeof code === "number" ? code : 128 + (signal ? os75.constants.signals[signal] ?? 9 : 9);
|
|
55115
55300
|
log.warn(
|
|
55116
55301
|
"host-agent",
|
|
55117
55302
|
`session deploy=${child.deployId.slice(0, 8)} died (${signal ?? code}) after ${Math.round((Date.now() - child.startedAt) / 1e3)}s \u2014 respawning it (resume)`
|
|
@@ -55252,6 +55437,7 @@ var HostAgentSupervisor = class {
|
|
|
55252
55437
|
cleanupWorkspace(deployId) {
|
|
55253
55438
|
const short = deployId.slice(0, 8);
|
|
55254
55439
|
this.credentialEnvByDeploy.delete(deployId);
|
|
55440
|
+
clearCredentialEnv(deployId);
|
|
55255
55441
|
const child = this.children.get(deployId);
|
|
55256
55442
|
if (child) {
|
|
55257
55443
|
try {
|
|
@@ -55261,12 +55447,12 @@ var HostAgentSupervisor = class {
|
|
|
55261
55447
|
this.untrackChild(deployId);
|
|
55262
55448
|
}
|
|
55263
55449
|
const dirs = [
|
|
55264
|
-
|
|
55265
|
-
|
|
55450
|
+
path116.join(selfHostedWorkspaceRoot(), deployId),
|
|
55451
|
+
path116.join(os75.homedir(), ".codeam", "house-claude", deployId)
|
|
55266
55452
|
];
|
|
55267
55453
|
for (const dir of dirs) {
|
|
55268
55454
|
try {
|
|
55269
|
-
|
|
55455
|
+
fs104.rmSync(dir, { recursive: true, force: true });
|
|
55270
55456
|
} catch (err) {
|
|
55271
55457
|
log.warn(
|
|
55272
55458
|
"host-agent",
|
|
@@ -55300,8 +55486,23 @@ var HostAgentSupervisor = class {
|
|
|
55300
55486
|
const auth = await this.resolveAgentAuth(this.identity, payload.sealedAgentAuth);
|
|
55301
55487
|
const credEnv = provisionAgentCredentials(payload.agentId, auth, void 0);
|
|
55302
55488
|
const affected = [...this.children.values()].filter((c2) => c2.agent === payload.agentId);
|
|
55489
|
+
if (Object.keys(credEnv).length === 0 && AUTH_FILE_CACHED_IN_MEMORY.has(payload.agentId)) {
|
|
55490
|
+
for (const child of affected) {
|
|
55491
|
+
this.credentialEnvByDeploy.delete(child.deployId);
|
|
55492
|
+
clearCredentialEnv(child.deployId);
|
|
55493
|
+
this.restartWithFreshCredentials(child);
|
|
55494
|
+
}
|
|
55495
|
+
log.info(
|
|
55496
|
+
"host-agent",
|
|
55497
|
+
`refreshed login file for agent=${payload.agentId}; restarted ${affected.length} child(ren)`
|
|
55498
|
+
);
|
|
55499
|
+
return;
|
|
55500
|
+
}
|
|
55303
55501
|
if (Object.keys(credEnv).length === 0) {
|
|
55304
|
-
for (const c2 of affected)
|
|
55502
|
+
for (const c2 of affected) {
|
|
55503
|
+
this.credentialEnvByDeploy.delete(c2.deployId);
|
|
55504
|
+
clearCredentialEnv(c2.deployId);
|
|
55505
|
+
}
|
|
55305
55506
|
log.info(
|
|
55306
55507
|
"host-agent",
|
|
55307
55508
|
`refreshed credentials in place for agent=${payload.agentId} (${this.children.size} active child(ren))`
|
|
@@ -55310,6 +55511,7 @@ var HostAgentSupervisor = class {
|
|
|
55310
55511
|
}
|
|
55311
55512
|
for (const child of affected) {
|
|
55312
55513
|
this.credentialEnvByDeploy.set(child.deployId, credEnv);
|
|
55514
|
+
persistCredentialEnv(child.deployId, credEnv);
|
|
55313
55515
|
this.restartWithFreshCredentials(child);
|
|
55314
55516
|
}
|
|
55315
55517
|
log.info(
|
|
@@ -55329,6 +55531,17 @@ var HostAgentSupervisor = class {
|
|
|
55329
55531
|
* reports `ended` nor crash-respawns), then resume the same conversation;
|
|
55330
55532
|
* `resumeOne` waits out the dying daemon if it still holds the session.
|
|
55331
55533
|
*/
|
|
55534
|
+
/**
|
|
55535
|
+
* The env credential of a deploy for a (re)spawn: memory first, else what an earlier host-agent
|
|
55536
|
+
* process persisted (a Box rebuilt on its volume, a wake, a self-update restart).
|
|
55537
|
+
*/
|
|
55538
|
+
credentialEnvFor(deployId) {
|
|
55539
|
+
const inMemory = this.credentialEnvByDeploy.get(deployId);
|
|
55540
|
+
if (inMemory) return inMemory;
|
|
55541
|
+
const persisted = readCredentialEnv(deployId);
|
|
55542
|
+
if (Object.keys(persisted).length > 0) this.credentialEnvByDeploy.set(deployId, persisted);
|
|
55543
|
+
return persisted;
|
|
55544
|
+
}
|
|
55332
55545
|
restartWithFreshCredentials(child) {
|
|
55333
55546
|
const session = pickSavedSessionForWorkspace(this.listSavedSessions(), child.cwd, child.deployId);
|
|
55334
55547
|
if (!session) {
|
|
@@ -55485,8 +55698,8 @@ async function invite() {
|
|
|
55485
55698
|
var import_node_dns = require("dns");
|
|
55486
55699
|
var import_node_util11 = require("util");
|
|
55487
55700
|
var import_node_crypto17 = require("crypto");
|
|
55488
|
-
var
|
|
55489
|
-
var
|
|
55701
|
+
var fs105 = __toESM(require("fs"));
|
|
55702
|
+
var path117 = __toESM(require("path"));
|
|
55490
55703
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
55491
55704
|
var dnsResolveP = (0, import_node_util11.promisify)(import_node_dns.resolve);
|
|
55492
55705
|
async function checkDns(apiBase2) {
|
|
@@ -55542,13 +55755,13 @@ async function checkHealth(apiBase2) {
|
|
|
55542
55755
|
}
|
|
55543
55756
|
}
|
|
55544
55757
|
function checkConfigDir() {
|
|
55545
|
-
const dir =
|
|
55758
|
+
const dir = path117.join(require("os").homedir(), ".codeam");
|
|
55546
55759
|
try {
|
|
55547
|
-
|
|
55548
|
-
const probe =
|
|
55549
|
-
|
|
55550
|
-
const read =
|
|
55551
|
-
|
|
55760
|
+
fs105.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
55761
|
+
const probe = path117.join(dir, ".doctor-probe");
|
|
55762
|
+
fs105.writeFileSync(probe, "ok", { mode: 384 });
|
|
55763
|
+
const read = fs105.readFileSync(probe, "utf8");
|
|
55764
|
+
fs105.unlinkSync(probe);
|
|
55552
55765
|
if (read !== "ok") throw new Error("write/read round-trip mismatch");
|
|
55553
55766
|
return {
|
|
55554
55767
|
id: "config-dir",
|
|
@@ -55588,9 +55801,9 @@ function checkSessions() {
|
|
|
55588
55801
|
}
|
|
55589
55802
|
}
|
|
55590
55803
|
function checkAgentBinaries() {
|
|
55591
|
-
const
|
|
55804
|
+
const os78 = createOsStrategy();
|
|
55592
55805
|
return getEnabledAgents().map((meta) => {
|
|
55593
|
-
const found =
|
|
55806
|
+
const found = os78.findInPath(meta.binaryName);
|
|
55594
55807
|
return {
|
|
55595
55808
|
id: `agent-${meta.id}`,
|
|
55596
55809
|
label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
|
|
@@ -55612,7 +55825,7 @@ function checkNodePty() {
|
|
|
55612
55825
|
detail: "not required on this platform"
|
|
55613
55826
|
};
|
|
55614
55827
|
}
|
|
55615
|
-
const vendoredPath =
|
|
55828
|
+
const vendoredPath = path117.join(__dirname, "vendor", "node-pty");
|
|
55616
55829
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
55617
55830
|
try {
|
|
55618
55831
|
require(target);
|
|
@@ -55654,7 +55867,7 @@ function checkChokidar() {
|
|
|
55654
55867
|
}
|
|
55655
55868
|
async function doctor(args2 = []) {
|
|
55656
55869
|
const json = args2.includes("--json");
|
|
55657
|
-
const cliVersion = true ? "2.76.
|
|
55870
|
+
const cliVersion = true ? "2.76.47" : "0.0.0-dev";
|
|
55658
55871
|
const apiBase2 = resolveApiBaseUrl();
|
|
55659
55872
|
const diagnosticId = (0, import_node_crypto17.randomUUID)();
|
|
55660
55873
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
@@ -56190,7 +56403,7 @@ async function mcpWarm(argv = [], opts = {}) {
|
|
|
56190
56403
|
// src/commands/version.ts
|
|
56191
56404
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
56192
56405
|
function version2() {
|
|
56193
|
-
const v = true ? "2.76.
|
|
56406
|
+
const v = true ? "2.76.47" : "unknown";
|
|
56194
56407
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
56195
56408
|
}
|
|
56196
56409
|
|
|
@@ -56323,10 +56536,10 @@ function tryShowSubcommandHelp(cmd, args2) {
|
|
|
56323
56536
|
var _subcommandHelpKeys = Object.keys(HELPS);
|
|
56324
56537
|
|
|
56325
56538
|
// src/index.ts
|
|
56326
|
-
var
|
|
56539
|
+
var os77 = __toESM(require("os"));
|
|
56327
56540
|
if (!process.env.HOME) {
|
|
56328
56541
|
try {
|
|
56329
|
-
const home =
|
|
56542
|
+
const home = os77.homedir();
|
|
56330
56543
|
if (home) process.env.HOME = home;
|
|
56331
56544
|
} catch {
|
|
56332
56545
|
}
|