codeam-cli 2.76.40 → 2.76.42
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 +7 -0
- package/dist/index.js +334 -271
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -375,7 +375,7 @@ function defaultSpawn(timeoutMs) {
|
|
|
375
375
|
}
|
|
376
376
|
function resolveConvexBin(cwd) {
|
|
377
377
|
const local = path114.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "convex.cmd" : "convex");
|
|
378
|
-
if (
|
|
378
|
+
if (fs102.existsSync(local)) return { cmd: local, args: [] };
|
|
379
379
|
return { cmd: "npx", args: ["--yes", "convex"] };
|
|
380
380
|
}
|
|
381
381
|
function redact(text, key) {
|
|
@@ -506,12 +506,12 @@ async function runConvexAdminMcp(client3, id) {
|
|
|
506
506
|
});
|
|
507
507
|
await server.connect(new StdioServerTransport());
|
|
508
508
|
}
|
|
509
|
-
var import_node_child_process40,
|
|
509
|
+
var import_node_child_process40, fs102, path114, TOOLS;
|
|
510
510
|
var init_convex_admin_mcp = __esm({
|
|
511
511
|
"src/integrations/convex-admin-mcp.ts"() {
|
|
512
512
|
"use strict";
|
|
513
513
|
import_node_child_process40 = require("child_process");
|
|
514
|
-
|
|
514
|
+
fs102 = __toESM(require("fs"));
|
|
515
515
|
path114 = __toESM(require("path"));
|
|
516
516
|
TOOLS = [
|
|
517
517
|
{
|
|
@@ -4539,7 +4539,7 @@ var _default = makeConfig();
|
|
|
4539
4539
|
var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, setSessionAgent, setSquadAuto, getSquadAuto, clearAll, saveCliConfig, loadCliConfig } = _default;
|
|
4540
4540
|
|
|
4541
4541
|
// src/commands/pair-auto.ts
|
|
4542
|
-
var
|
|
4542
|
+
var fs69 = __toESM(require("fs"));
|
|
4543
4543
|
var os49 = __toESM(require("os"));
|
|
4544
4544
|
var path76 = __toESM(require("path"));
|
|
4545
4545
|
var import_crypto4 = require("crypto");
|
|
@@ -11354,7 +11354,7 @@ function readAnonId() {
|
|
|
11354
11354
|
}
|
|
11355
11355
|
function superProperties() {
|
|
11356
11356
|
return {
|
|
11357
|
-
cliVersion: true ? "2.76.
|
|
11357
|
+
cliVersion: true ? "2.76.42" : "0.0.0-dev",
|
|
11358
11358
|
nodeVersion: process.version,
|
|
11359
11359
|
platform: process.platform,
|
|
11360
11360
|
arch: process.arch,
|
|
@@ -11603,7 +11603,7 @@ var http = __toESM(require("http"));
|
|
|
11603
11603
|
// package.json
|
|
11604
11604
|
var package_default = {
|
|
11605
11605
|
name: "codeam-cli",
|
|
11606
|
-
version: "2.76.
|
|
11606
|
+
version: "2.76.42",
|
|
11607
11607
|
description: "Workflow-continuity bridge for AI coding agents. Wrap Claude Code or Codex in a PTY and supervise, approve, and redirect the session from any device \u2014 async. The terminal companion for CodeAgent Mobile.",
|
|
11608
11608
|
type: "commonjs",
|
|
11609
11609
|
main: "dist/index.js",
|
|
@@ -12979,7 +12979,7 @@ var CommandRelayService = class _CommandRelayService {
|
|
|
12979
12979
|
// fresh + clear the "CLI update available" banner after a self-update
|
|
12980
12980
|
// (a codespace that reinstalls @latest reconnects via heartbeat, not
|
|
12981
12981
|
// pair/reconnect). Older backends ignore the extra field.
|
|
12982
|
-
..."2.76.
|
|
12982
|
+
..."2.76.42" ? { ideVersion: "2.76.42" } : {}
|
|
12983
12983
|
};
|
|
12984
12984
|
try {
|
|
12985
12985
|
const res = await _postJson(`${API_BASE2}/api/plugin/heartbeat`, body, this.pollSecretHeader());
|
|
@@ -14460,7 +14460,7 @@ function closeAllTerminals() {
|
|
|
14460
14460
|
}
|
|
14461
14461
|
|
|
14462
14462
|
// src/commands/start/handlers.ts
|
|
14463
|
-
var
|
|
14463
|
+
var fs68 = __toESM(require("fs"));
|
|
14464
14464
|
var os48 = __toESM(require("os"));
|
|
14465
14465
|
var path75 = __toESM(require("path"));
|
|
14466
14466
|
var import_crypto3 = require("crypto");
|
|
@@ -21542,14 +21542,14 @@ function defaultSdkDir() {
|
|
|
21542
21542
|
return resolveSdkDirViaRequire();
|
|
21543
21543
|
}
|
|
21544
21544
|
function resolveClaudeNativeBinary(deps = {}) {
|
|
21545
|
-
const
|
|
21545
|
+
const existsSync37 = deps.existsSync ?? import_fs.default.existsSync;
|
|
21546
21546
|
const platformKey = deps.platformKey ?? currentPlatformKey();
|
|
21547
21547
|
const sdkDir = deps.sdkDir !== void 0 ? deps.sdkDir : defaultSdkDir();
|
|
21548
21548
|
if (!sdkDir) return null;
|
|
21549
21549
|
const scopeDir = import_path4.default.dirname(sdkDir);
|
|
21550
21550
|
const binName = platformKey.startsWith("win32-") ? "claude.exe" : "claude";
|
|
21551
21551
|
const candidate = import_path4.default.join(scopeDir, `claude-agent-sdk-${platformKey}`, binName);
|
|
21552
|
-
return
|
|
21552
|
+
return existsSync37(candidate) ? candidate : null;
|
|
21553
21553
|
}
|
|
21554
21554
|
var realSleep = (ms) => new Promise((resolve13) => setTimeout(resolve13, ms));
|
|
21555
21555
|
async function waitForClaudeNativeBinary(opts = {}) {
|
|
@@ -21640,18 +21640,18 @@ function augmentUserLocalBinPaths(deps = {}) {
|
|
|
21640
21640
|
env.PATH = [...additions, ...parts].join(p2.delimiter);
|
|
21641
21641
|
}
|
|
21642
21642
|
function resolveCursorAgentBinary(deps = {}) {
|
|
21643
|
-
const
|
|
21643
|
+
const existsSync37 = deps.existsSync ?? import_fs.default.existsSync;
|
|
21644
21644
|
const platform3 = deps.platform ?? process.platform;
|
|
21645
21645
|
const env = deps.env ?? process.env;
|
|
21646
21646
|
if (platform3 === "win32") {
|
|
21647
21647
|
const localAppData = env.LOCALAPPDATA;
|
|
21648
21648
|
if (!localAppData) return null;
|
|
21649
21649
|
const exe = import_path4.default.win32.join(localAppData, "cursor-agent", "cursor-agent.exe");
|
|
21650
|
-
return
|
|
21650
|
+
return existsSync37(exe) ? exe : null;
|
|
21651
21651
|
}
|
|
21652
21652
|
const home = deps.homedir ?? import_os4.default.homedir();
|
|
21653
21653
|
const unix = import_path4.default.posix.join(home, ".local", "bin", "cursor-agent");
|
|
21654
|
-
return
|
|
21654
|
+
return existsSync37(unix) ? unix : null;
|
|
21655
21655
|
}
|
|
21656
21656
|
async function waitForCursorAgent(opts = {}) {
|
|
21657
21657
|
const timeoutMs = opts.timeoutMs ?? 18e4;
|
|
@@ -24874,6 +24874,7 @@ function quoteIfNeeded(value) {
|
|
|
24874
24874
|
}
|
|
24875
24875
|
|
|
24876
24876
|
// src/services/preview/expo.ts
|
|
24877
|
+
var fs45 = __toESM(require("fs"));
|
|
24877
24878
|
var http6 = __toESM(require("http"));
|
|
24878
24879
|
var path52 = __toESM(require("path"));
|
|
24879
24880
|
var EXPO_PACKAGER_PROXY_URL_ENV = "EXPO_PACKAGER_PROXY_URL";
|
|
@@ -24917,6 +24918,38 @@ async function waitForExpoManifest(port, opts) {
|
|
|
24917
24918
|
await new Promise((r) => setTimeout(r, interval));
|
|
24918
24919
|
}
|
|
24919
24920
|
}
|
|
24921
|
+
var EXPO_WEB_PACKAGES = ["react-native-web", "react-dom", "@expo/metro-runtime"];
|
|
24922
|
+
function missingExpoWebPackages(cwd) {
|
|
24923
|
+
return EXPO_WEB_PACKAGES.filter(
|
|
24924
|
+
(p2) => !fs45.existsSync(path52.join(cwd, "node_modules", p2, "package.json"))
|
|
24925
|
+
);
|
|
24926
|
+
}
|
|
24927
|
+
function expoWebInstallSpecs(cwd, missing) {
|
|
24928
|
+
let pinned = {};
|
|
24929
|
+
try {
|
|
24930
|
+
const raw = JSON.parse(
|
|
24931
|
+
fs45.readFileSync(path52.join(cwd, "node_modules", "expo", "bundledNativeModules.json"), "utf8")
|
|
24932
|
+
);
|
|
24933
|
+
if (raw && typeof raw === "object" && !Array.isArray(raw)) pinned = raw;
|
|
24934
|
+
} catch {
|
|
24935
|
+
}
|
|
24936
|
+
return missing.map((p2) => typeof pinned[p2] === "string" ? `${p2}@${String(pinned[p2])}` : p2);
|
|
24937
|
+
}
|
|
24938
|
+
function expoWebDepsInstall(cwd) {
|
|
24939
|
+
const missing = missingExpoWebPackages(cwd);
|
|
24940
|
+
if (missing.length === 0) return null;
|
|
24941
|
+
return {
|
|
24942
|
+
cmd: "npm",
|
|
24943
|
+
args: [
|
|
24944
|
+
"install",
|
|
24945
|
+
"--no-save",
|
|
24946
|
+
"--legacy-peer-deps",
|
|
24947
|
+
"--no-audit",
|
|
24948
|
+
"--no-fund",
|
|
24949
|
+
...expoWebInstallSpecs(cwd, missing)
|
|
24950
|
+
]
|
|
24951
|
+
};
|
|
24952
|
+
}
|
|
24920
24953
|
|
|
24921
24954
|
// src/services/preview/parser.ts
|
|
24922
24955
|
var REQUIRED_FIELDS2 = [
|
|
@@ -25489,9 +25522,21 @@ async function provisionProjectDependencies(cwd) {
|
|
|
25489
25522
|
// src/services/preview/setup-deps.ts
|
|
25490
25523
|
var import_fs5 = __toESM(require("fs"));
|
|
25491
25524
|
var import_path8 = __toESM(require("path"));
|
|
25525
|
+
function missingDeclaredDep(cwd) {
|
|
25526
|
+
let pkg;
|
|
25527
|
+
try {
|
|
25528
|
+
pkg = JSON.parse(import_fs5.default.readFileSync(import_path8.default.join(cwd, "package.json"), "utf8"));
|
|
25529
|
+
} catch {
|
|
25530
|
+
return null;
|
|
25531
|
+
}
|
|
25532
|
+
for (const name of Object.keys({ ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} })) {
|
|
25533
|
+
if (!import_fs5.default.existsSync(import_path8.default.join(cwd, "node_modules", name, "package.json"))) return name;
|
|
25534
|
+
}
|
|
25535
|
+
return null;
|
|
25536
|
+
}
|
|
25492
25537
|
function detectMissingNodeDeps(cwd) {
|
|
25493
25538
|
if (!import_fs5.default.existsSync(import_path8.default.join(cwd, "package.json"))) return null;
|
|
25494
|
-
if (import_fs5.default.existsSync(import_path8.default.join(cwd, "node_modules"))) return null;
|
|
25539
|
+
if (import_fs5.default.existsSync(import_path8.default.join(cwd, "node_modules")) && missingDeclaredDep(cwd) === null) return null;
|
|
25495
25540
|
if (import_fs5.default.existsSync(import_path8.default.join(cwd, "yarn.lock"))) {
|
|
25496
25541
|
return { cmd: "yarn", args: ["install"] };
|
|
25497
25542
|
}
|
|
@@ -25530,7 +25575,7 @@ function isComposerInstallCommand(cmd, args2) {
|
|
|
25530
25575
|
}
|
|
25531
25576
|
|
|
25532
25577
|
// src/services/preview/script-candidates.ts
|
|
25533
|
-
var
|
|
25578
|
+
var fs48 = __toESM(require("fs"));
|
|
25534
25579
|
var path55 = __toESM(require("path"));
|
|
25535
25580
|
var EXCLUDE_RE = /(^|:)(deploy|publish|release|build|test|e2e|lint|format|typecheck|type-check|clean|prebuild|postinstall|preinstall|prepare|install|migrate|seed|db|prisma|codegen|storybook-build)(:|$)/i;
|
|
25536
25581
|
var EXCLUDE_BODY_RE = /\b(run:android|run:ios|gradlew|fastlane|xcodebuild|eas build|eas submit)\b/i;
|
|
@@ -25549,7 +25594,7 @@ function frameworkFor(pkg, body) {
|
|
|
25549
25594
|
}
|
|
25550
25595
|
function readPkg(file) {
|
|
25551
25596
|
try {
|
|
25552
|
-
return JSON.parse(
|
|
25597
|
+
return JSON.parse(fs48.readFileSync(file, "utf8"));
|
|
25553
25598
|
} catch {
|
|
25554
25599
|
return null;
|
|
25555
25600
|
}
|
|
@@ -25559,7 +25604,7 @@ function expandGlob(root, pattern) {
|
|
|
25559
25604
|
if (!clean.endsWith("/*")) return [clean];
|
|
25560
25605
|
const base = clean.slice(0, -2);
|
|
25561
25606
|
try {
|
|
25562
|
-
return
|
|
25607
|
+
return fs48.readdirSync(path55.join(root, base), { withFileTypes: true }).filter((d3) => d3.isDirectory() && !d3.name.startsWith(".") && d3.name !== "node_modules").map((d3) => path55.join(base, d3.name));
|
|
25563
25608
|
} catch {
|
|
25564
25609
|
return [];
|
|
25565
25610
|
}
|
|
@@ -25568,7 +25613,7 @@ function workspaceDirs(root, rootPkg) {
|
|
|
25568
25613
|
const ws = rootPkg?.workspaces;
|
|
25569
25614
|
const patterns = Array.isArray(ws) ? ws : ws?.packages ?? [];
|
|
25570
25615
|
try {
|
|
25571
|
-
const pnpm =
|
|
25616
|
+
const pnpm = fs48.readFileSync(path55.join(root, "pnpm-workspace.yaml"), "utf8");
|
|
25572
25617
|
for (const m of pnpm.matchAll(/^\s*-\s*['"]?([^'"\n]+)['"]?\s*$/gm)) patterns.push(m[1]);
|
|
25573
25618
|
} catch {
|
|
25574
25619
|
}
|
|
@@ -26353,7 +26398,7 @@ async function readActivePreviewMarker(cwd, homeDir2) {
|
|
|
26353
26398
|
}
|
|
26354
26399
|
|
|
26355
26400
|
// src/agents/acp/guardrail-config.ts
|
|
26356
|
-
var
|
|
26401
|
+
var fs53 = __toESM(require("fs"));
|
|
26357
26402
|
var path60 = __toESM(require("path"));
|
|
26358
26403
|
var os37 = __toESM(require("os"));
|
|
26359
26404
|
var current = null;
|
|
@@ -26362,7 +26407,7 @@ function guardrailConfigPath(homeDir2 = os37.homedir()) {
|
|
|
26362
26407
|
}
|
|
26363
26408
|
function loadGuardrailPolicy(homeDir2 = os37.homedir()) {
|
|
26364
26409
|
try {
|
|
26365
|
-
current = normalizeGuardrailPolicy(JSON.parse(
|
|
26410
|
+
current = normalizeGuardrailPolicy(JSON.parse(fs53.readFileSync(guardrailConfigPath(homeDir2), "utf8")));
|
|
26366
26411
|
} catch {
|
|
26367
26412
|
current = { ...DEFAULT_GUARDRAIL_POLICY };
|
|
26368
26413
|
}
|
|
@@ -26376,8 +26421,8 @@ function setGuardrailPolicy(raw, homeDir2 = os37.homedir()) {
|
|
|
26376
26421
|
current = next;
|
|
26377
26422
|
try {
|
|
26378
26423
|
const p2 = guardrailConfigPath(homeDir2);
|
|
26379
|
-
|
|
26380
|
-
|
|
26424
|
+
fs53.mkdirSync(path60.dirname(p2), { recursive: true });
|
|
26425
|
+
fs53.writeFileSync(p2, JSON.stringify(next, null, 2));
|
|
26381
26426
|
} catch {
|
|
26382
26427
|
}
|
|
26383
26428
|
return next;
|
|
@@ -26393,7 +26438,7 @@ function shouldOfferOneMRecovery(opts) {
|
|
|
26393
26438
|
}
|
|
26394
26439
|
|
|
26395
26440
|
// src/commands/host/house-proxy-config.ts
|
|
26396
|
-
var
|
|
26441
|
+
var fs54 = __toESM(require("fs"));
|
|
26397
26442
|
var os38 = __toESM(require("os"));
|
|
26398
26443
|
var path61 = __toESM(require("path"));
|
|
26399
26444
|
function houseProxyConfigPath() {
|
|
@@ -26405,10 +26450,10 @@ function deployHouseProxyConfigPath(deployId) {
|
|
|
26405
26450
|
return path61.join(os38.homedir(), ".codeam", "house-proxy", `${deployId}.json`);
|
|
26406
26451
|
}
|
|
26407
26452
|
function writeJson0600(file, value) {
|
|
26408
|
-
|
|
26453
|
+
fs54.mkdirSync(path61.dirname(file), { recursive: true, mode: 448 });
|
|
26409
26454
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
26410
|
-
|
|
26411
|
-
|
|
26455
|
+
fs54.writeFileSync(tmp, JSON.stringify(value, null, 2), { encoding: "utf8", mode: 384 });
|
|
26456
|
+
fs54.renameSync(tmp, file);
|
|
26412
26457
|
restrictToOwner(file);
|
|
26413
26458
|
}
|
|
26414
26459
|
function persistHouseProxyConfig(config, deployId) {
|
|
@@ -26425,7 +26470,7 @@ function persistHouseProxyConfig(config, deployId) {
|
|
|
26425
26470
|
}
|
|
26426
26471
|
function clearHouseProxyConfig(deployId) {
|
|
26427
26472
|
try {
|
|
26428
|
-
|
|
26473
|
+
fs54.rmSync(houseProxyConfigPath(), { force: true });
|
|
26429
26474
|
const perDeploy = deployId ? deployHouseProxyConfigPath(deployId) : null;
|
|
26430
26475
|
if (perDeploy) writeJson0600(perDeploy, { none: true });
|
|
26431
26476
|
} catch {
|
|
@@ -26448,12 +26493,12 @@ function houseProxyTokenExpiring(token, nowSec, windowSec = HOUSE_PROXY_REFRESH_
|
|
|
26448
26493
|
}
|
|
26449
26494
|
function persistedConfigFile(deployId) {
|
|
26450
26495
|
const perDeploy = deployId ? deployHouseProxyConfigPath(deployId) : null;
|
|
26451
|
-
const file = perDeploy &&
|
|
26452
|
-
return
|
|
26496
|
+
const file = perDeploy && fs54.existsSync(perDeploy) ? perDeploy : houseProxyConfigPath();
|
|
26497
|
+
return fs54.existsSync(file) ? file : null;
|
|
26453
26498
|
}
|
|
26454
26499
|
function readConfigObject(file) {
|
|
26455
26500
|
try {
|
|
26456
|
-
const parsed = JSON.parse(
|
|
26501
|
+
const parsed = JSON.parse(fs54.readFileSync(file, "utf8"));
|
|
26457
26502
|
return typeof parsed === "object" && parsed !== null ? parsed : null;
|
|
26458
26503
|
} catch {
|
|
26459
26504
|
return null;
|
|
@@ -26486,8 +26531,8 @@ function rewriteHouseProxyToken(deployId, freshToken) {
|
|
|
26486
26531
|
function readHouseProxyChildEnv(deployId) {
|
|
26487
26532
|
try {
|
|
26488
26533
|
const perDeploy = deployId ? deployHouseProxyConfigPath(deployId) : null;
|
|
26489
|
-
const file = perDeploy &&
|
|
26490
|
-
const raw =
|
|
26534
|
+
const file = perDeploy && fs54.existsSync(perDeploy) ? perDeploy : houseProxyConfigPath();
|
|
26535
|
+
const raw = fs54.readFileSync(file, "utf8");
|
|
26491
26536
|
const parsed = JSON.parse(raw);
|
|
26492
26537
|
if (typeof parsed !== "object" || parsed === null) return {};
|
|
26493
26538
|
const o = parsed;
|
|
@@ -26597,7 +26642,7 @@ function pickHouseProxyEnv(env) {
|
|
|
26597
26642
|
}
|
|
26598
26643
|
|
|
26599
26644
|
// src/lib/provider-routing.ts
|
|
26600
|
-
var
|
|
26645
|
+
var fs55 = __toESM(require("fs"));
|
|
26601
26646
|
var os39 = __toESM(require("os"));
|
|
26602
26647
|
var path62 = __toESM(require("path"));
|
|
26603
26648
|
var PROVIDER_BASE_URL_ENV_KEYS = [
|
|
@@ -26622,7 +26667,7 @@ function redactUrlToOrigin(raw) {
|
|
|
26622
26667
|
}
|
|
26623
26668
|
function readOpencodeProviderOrigins(opts = {}) {
|
|
26624
26669
|
const home = opts.homeDir ?? os39.homedir();
|
|
26625
|
-
const readFile8 = opts.readFile ?? ((f) =>
|
|
26670
|
+
const readFile8 = opts.readFile ?? ((f) => fs55.readFileSync(f, "utf8"));
|
|
26626
26671
|
const candidates = [];
|
|
26627
26672
|
if (opts.cwd) {
|
|
26628
26673
|
candidates.push(path62.join(opts.cwd, "opencode.json"), path62.join(opts.cwd, "opencode.jsonc"));
|
|
@@ -26983,7 +27028,7 @@ function adapterExitMessage(opts) {
|
|
|
26983
27028
|
|
|
26984
27029
|
// src/services/preview/start-orchestrator.ts
|
|
26985
27030
|
var import_child_process20 = require("child_process");
|
|
26986
|
-
var
|
|
27031
|
+
var fs59 = __toESM(require("fs"));
|
|
26987
27032
|
var path66 = __toESM(require("path"));
|
|
26988
27033
|
var import_which3 = __toESM(require("which"));
|
|
26989
27034
|
|
|
@@ -27023,7 +27068,7 @@ var path65 = __toESM(require("path"));
|
|
|
27023
27068
|
// src/beads/project-key.ts
|
|
27024
27069
|
var import_child_process19 = require("child_process");
|
|
27025
27070
|
var crypto2 = __toESM(require("crypto"));
|
|
27026
|
-
var
|
|
27071
|
+
var fs57 = __toESM(require("fs"));
|
|
27027
27072
|
var path64 = __toESM(require("path"));
|
|
27028
27073
|
function normalizeOrigin(raw) {
|
|
27029
27074
|
const trimmed = raw.trim();
|
|
@@ -27056,7 +27101,7 @@ function findRepoRoot(cwd) {
|
|
|
27056
27101
|
if (seen2.has(dir)) return null;
|
|
27057
27102
|
seen2.add(dir);
|
|
27058
27103
|
try {
|
|
27059
|
-
const stat3 =
|
|
27104
|
+
const stat3 = fs57.statSync(path64.join(dir, ".git"), { throwIfNoEntry: false });
|
|
27060
27105
|
if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
|
|
27061
27106
|
} catch {
|
|
27062
27107
|
}
|
|
@@ -27071,7 +27116,7 @@ var _execSeam3 = {
|
|
|
27071
27116
|
const out2 = (0, import_child_process19.execFileSync)(file, args2, opts);
|
|
27072
27117
|
return typeof out2 === "string" ? out2 : out2.toString("utf8");
|
|
27073
27118
|
},
|
|
27074
|
-
realpath: (p2) =>
|
|
27119
|
+
realpath: (p2) => fs57.realpathSync(p2)
|
|
27075
27120
|
};
|
|
27076
27121
|
function readOrigin(cwd) {
|
|
27077
27122
|
try {
|
|
@@ -27463,7 +27508,7 @@ function normalizeDetectionForSpawn(detection, cwd) {
|
|
|
27463
27508
|
const binName = args2[0];
|
|
27464
27509
|
if (binName.startsWith("-")) return detection;
|
|
27465
27510
|
const binPath = path66.join(cwd, "node_modules", ".bin", binName);
|
|
27466
|
-
if (!
|
|
27511
|
+
if (!fs59.existsSync(binPath)) return detection;
|
|
27467
27512
|
return {
|
|
27468
27513
|
...detection,
|
|
27469
27514
|
command: binPath,
|
|
@@ -27487,7 +27532,8 @@ async function runPreviewStart(args2) {
|
|
|
27487
27532
|
emit2(USER_EVENTS.PREVIEW_READY, {
|
|
27488
27533
|
url: existing.url,
|
|
27489
27534
|
framework: existing.framework,
|
|
27490
|
-
port: detection.port
|
|
27535
|
+
port: detection.port,
|
|
27536
|
+
...existing.expoGoUrl ? { expoGoUrl: existing.expoGoUrl } : {}
|
|
27491
27537
|
});
|
|
27492
27538
|
return;
|
|
27493
27539
|
}
|
|
@@ -27515,6 +27561,16 @@ async function runPreviewStart(args2) {
|
|
|
27515
27561
|
}
|
|
27516
27562
|
async function runExpoBringUp(ctx) {
|
|
27517
27563
|
const { detection, emit: emit2, emitProgress } = ctx;
|
|
27564
|
+
const webInstall = expoWebDepsInstall(ctx.cwd);
|
|
27565
|
+
let web = webInstall === null;
|
|
27566
|
+
if (webInstall) {
|
|
27567
|
+
emitProgress("SETUP_RUN", `${webInstall.cmd} ${webInstall.args.join(" ")} (Expo web preview)`);
|
|
27568
|
+
const r = await runSetupCommand(webInstall.cmd, webInstall.args, ctx.cwd, detection.env, {
|
|
27569
|
+
timeoutMs: INSTALL_TIMEOUT_MS2
|
|
27570
|
+
});
|
|
27571
|
+
web = r.status === "ok";
|
|
27572
|
+
if (!web) emitProgress("SETUP_RUN", `web packages not installed (${r.status}) \u2014 Expo Go only`);
|
|
27573
|
+
}
|
|
27518
27574
|
emitProgress("TUNNEL_STARTING", `cloudflared quick tunnel \u2192 Expo :${detection.port}`);
|
|
27519
27575
|
const pub = await bringUpPublicUrl(ctx, detection.port);
|
|
27520
27576
|
if (!pub.ok) {
|
|
@@ -27526,8 +27582,11 @@ async function runExpoBringUp(ctx) {
|
|
|
27526
27582
|
killQuiet(pub.tunnel);
|
|
27527
27583
|
return;
|
|
27528
27584
|
}
|
|
27585
|
+
const expoGoUrl = expoGoDeepLink(pub.url);
|
|
27529
27586
|
announceReady(ctx, dev, {
|
|
27530
|
-
|
|
27587
|
+
// The web build in the frame + Expo Go beside it; an SDK without web deps keeps the QR alone.
|
|
27588
|
+
url: web ? pub.url : expoGoUrl,
|
|
27589
|
+
expoGoUrl: web ? expoGoUrl : void 0,
|
|
27531
27590
|
tunnel: pub.tunnel,
|
|
27532
27591
|
// No inspector: a DOM inspector means nothing against a native app.
|
|
27533
27592
|
inspector: null
|
|
@@ -27542,6 +27601,7 @@ function announceReady(ctx, dev, tun) {
|
|
|
27542
27601
|
tunnel: tun.tunnel,
|
|
27543
27602
|
inspector: tun.inspector,
|
|
27544
27603
|
url: tun.url,
|
|
27604
|
+
expoGoUrl: tun.expoGoUrl,
|
|
27545
27605
|
framework: detection.framework,
|
|
27546
27606
|
detection,
|
|
27547
27607
|
cwd: ctx.cwd
|
|
@@ -27554,7 +27614,8 @@ function announceReady(ctx, dev, tun) {
|
|
|
27554
27614
|
emit2(USER_EVENTS.PREVIEW_READY, {
|
|
27555
27615
|
url: tun.url,
|
|
27556
27616
|
framework: detection.framework,
|
|
27557
|
-
port: detection.port
|
|
27617
|
+
port: detection.port,
|
|
27618
|
+
...tun.expoGoUrl ? { expoGoUrl: tun.expoGoUrl } : {}
|
|
27558
27619
|
});
|
|
27559
27620
|
}
|
|
27560
27621
|
async function runPreflightInstall(ctx, install, why) {
|
|
@@ -27682,7 +27743,8 @@ async function startDevServer(ctx, extraEnv = {}) {
|
|
|
27682
27743
|
emit2(USER_EVENTS.PREVIEW_READY, {
|
|
27683
27744
|
url: raceExisting.url,
|
|
27684
27745
|
framework: raceExisting.framework,
|
|
27685
|
-
port: detection.port
|
|
27746
|
+
port: detection.port,
|
|
27747
|
+
...raceExisting.expoGoUrl ? { expoGoUrl: raceExisting.expoGoUrl } : {}
|
|
27686
27748
|
});
|
|
27687
27749
|
return null;
|
|
27688
27750
|
}
|
|
@@ -27917,7 +27979,7 @@ function describeSpawnFailure(err, command2, relDir) {
|
|
|
27917
27979
|
|
|
27918
27980
|
// src/beads/bd-adapter.ts
|
|
27919
27981
|
var import_child_process21 = require("child_process");
|
|
27920
|
-
var
|
|
27982
|
+
var fs60 = __toESM(require("fs"));
|
|
27921
27983
|
var os40 = __toESM(require("os"));
|
|
27922
27984
|
var path67 = __toESM(require("path"));
|
|
27923
27985
|
|
|
@@ -27972,7 +28034,7 @@ function _defaultResolveBundled() {
|
|
|
27972
28034
|
const binaryName = process.platform === "win32" ? "bd.exe" : "bd";
|
|
27973
28035
|
const binaryPath = path67.join(binDir, binaryName);
|
|
27974
28036
|
try {
|
|
27975
|
-
|
|
28037
|
+
fs60.accessSync(binaryPath, fs60.constants.F_OK);
|
|
27976
28038
|
return binaryPath;
|
|
27977
28039
|
} catch {
|
|
27978
28040
|
return null;
|
|
@@ -27988,7 +28050,7 @@ function _defaultResolveOnPath() {
|
|
|
27988
28050
|
for (const candidate of candidates) {
|
|
27989
28051
|
const full = path67.join(dir, candidate);
|
|
27990
28052
|
try {
|
|
27991
|
-
|
|
28053
|
+
fs60.accessSync(full, fs60.constants.F_OK);
|
|
27992
28054
|
return full;
|
|
27993
28055
|
} catch {
|
|
27994
28056
|
}
|
|
@@ -28177,7 +28239,7 @@ function coerceIssue(row, projectKey) {
|
|
|
28177
28239
|
|
|
28178
28240
|
// src/beads/provisioner.ts
|
|
28179
28241
|
var import_child_process24 = require("child_process");
|
|
28180
|
-
var
|
|
28242
|
+
var fs62 = __toESM(require("fs"));
|
|
28181
28243
|
var os42 = __toESM(require("os"));
|
|
28182
28244
|
var path69 = __toESM(require("path"));
|
|
28183
28245
|
|
|
@@ -28244,7 +28306,7 @@ async function installBd(platform3 = process.platform) {
|
|
|
28244
28306
|
|
|
28245
28307
|
// src/beads/install-dolt.ts
|
|
28246
28308
|
var import_child_process23 = require("child_process");
|
|
28247
|
-
var
|
|
28309
|
+
var fs61 = __toESM(require("fs"));
|
|
28248
28310
|
var os41 = __toESM(require("os"));
|
|
28249
28311
|
var path68 = __toESM(require("path"));
|
|
28250
28312
|
var DOLT_INSTALL_SH_URL = "https://github.com/dolthub/dolt/releases/latest/download/install.sh";
|
|
@@ -28342,7 +28404,7 @@ var _doltPathSeam = {
|
|
|
28342
28404
|
},
|
|
28343
28405
|
exists: (p2) => {
|
|
28344
28406
|
try {
|
|
28345
|
-
|
|
28407
|
+
fs61.accessSync(p2, fs61.constants.F_OK);
|
|
28346
28408
|
return true;
|
|
28347
28409
|
} catch {
|
|
28348
28410
|
return false;
|
|
@@ -28546,10 +28608,10 @@ var _provisionSeam = {
|
|
|
28546
28608
|
/** Does the project's git remote carry Dolt data (`refs/dolt/data`)? */
|
|
28547
28609
|
remoteHasDoltData,
|
|
28548
28610
|
/** Throwaway cwd for a user-level-only `bd setup` (see GLOBAL_ONLY_RECIPES). */
|
|
28549
|
-
makeSetupCwd: () =>
|
|
28611
|
+
makeSetupCwd: () => fs62.mkdtempSync(path69.join(os42.tmpdir(), "codeam-bd-setup-")),
|
|
28550
28612
|
removeSetupCwd: (dir) => {
|
|
28551
28613
|
try {
|
|
28552
|
-
|
|
28614
|
+
fs62.rmSync(dir, { recursive: true, force: true });
|
|
28553
28615
|
} catch {
|
|
28554
28616
|
}
|
|
28555
28617
|
}
|
|
@@ -28574,14 +28636,14 @@ var _linkSeam = {
|
|
|
28574
28636
|
homedir: () => os42.homedir(),
|
|
28575
28637
|
isWritableDir: (dir) => {
|
|
28576
28638
|
try {
|
|
28577
|
-
|
|
28639
|
+
fs62.accessSync(dir, fs62.constants.W_OK);
|
|
28578
28640
|
return true;
|
|
28579
28641
|
} catch {
|
|
28580
28642
|
return false;
|
|
28581
28643
|
}
|
|
28582
28644
|
},
|
|
28583
28645
|
ensureDir: (dir) => {
|
|
28584
|
-
|
|
28646
|
+
fs62.mkdirSync(dir, { recursive: true });
|
|
28585
28647
|
},
|
|
28586
28648
|
/**
|
|
28587
28649
|
* A directory to symlink `bd` into so the AGENT's shell + Claude Code's
|
|
@@ -28621,7 +28683,7 @@ var _linkSeam = {
|
|
|
28621
28683
|
const entry = process.argv[1];
|
|
28622
28684
|
if (entry) {
|
|
28623
28685
|
try {
|
|
28624
|
-
candidates.push(path69.dirname(
|
|
28686
|
+
candidates.push(path69.dirname(fs62.realpathSync(entry)));
|
|
28625
28687
|
} catch {
|
|
28626
28688
|
candidates.push(path69.dirname(entry));
|
|
28627
28689
|
}
|
|
@@ -28635,13 +28697,13 @@ var _linkSeam = {
|
|
|
28635
28697
|
/** Current symlink target at `linkPath`, or null when absent / not a link. */
|
|
28636
28698
|
readlink: (linkPath) => {
|
|
28637
28699
|
try {
|
|
28638
|
-
return
|
|
28700
|
+
return fs62.readlinkSync(linkPath);
|
|
28639
28701
|
} catch {
|
|
28640
28702
|
return null;
|
|
28641
28703
|
}
|
|
28642
28704
|
},
|
|
28643
|
-
unlink: (linkPath) =>
|
|
28644
|
-
symlink: (target, linkPath) =>
|
|
28705
|
+
unlink: (linkPath) => fs62.unlinkSync(linkPath),
|
|
28706
|
+
symlink: (target, linkPath) => fs62.symlinkSync(target, linkPath)
|
|
28645
28707
|
};
|
|
28646
28708
|
function linkBdOntoPath(binaryPath) {
|
|
28647
28709
|
if (_linkSeam.platform() === "win32") return;
|
|
@@ -28887,15 +28949,15 @@ function dedupeRecipes(agents) {
|
|
|
28887
28949
|
function ensureLocalGitExclude(cwd, patterns) {
|
|
28888
28950
|
try {
|
|
28889
28951
|
const gitDir = path69.join(cwd, ".git");
|
|
28890
|
-
if (!
|
|
28952
|
+
if (!fs62.statSync(gitDir).isDirectory()) return;
|
|
28891
28953
|
const file = path69.join(gitDir, "info", "exclude");
|
|
28892
|
-
|
|
28893
|
-
const current2 =
|
|
28954
|
+
fs62.mkdirSync(path69.dirname(file), { recursive: true });
|
|
28955
|
+
const current2 = fs62.existsSync(file) ? fs62.readFileSync(file, "utf8") : "";
|
|
28894
28956
|
const have = new Set(current2.split(/\r?\n/).map((l) => l.trim()));
|
|
28895
28957
|
const missing = patterns.filter((p2) => !have.has(p2));
|
|
28896
28958
|
if (missing.length === 0) return;
|
|
28897
28959
|
const prefix = current2.length > 0 && !current2.endsWith("\n") ? "\n" : "";
|
|
28898
|
-
|
|
28960
|
+
fs62.appendFileSync(file, `${prefix}# CodeAgent: beads state stays local
|
|
28899
28961
|
${missing.join("\n")}
|
|
28900
28962
|
`);
|
|
28901
28963
|
} catch {
|
|
@@ -29584,7 +29646,7 @@ function saveFilesTemp(files) {
|
|
|
29584
29646
|
return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
|
|
29585
29647
|
const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
|
|
29586
29648
|
const tmpPath = path75.join(os48.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
|
|
29587
|
-
|
|
29649
|
+
fs68.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
|
|
29588
29650
|
pendingAttachmentFiles.add(tmpPath);
|
|
29589
29651
|
return tmpPath;
|
|
29590
29652
|
});
|
|
@@ -29833,7 +29895,7 @@ var envReadH = async (ctx, cmd) => {
|
|
|
29833
29895
|
const envPath = path75.join(process.cwd(), ".env");
|
|
29834
29896
|
await restoreProjectEnvIfMissing(process.cwd(), ctx);
|
|
29835
29897
|
try {
|
|
29836
|
-
const raw = await
|
|
29898
|
+
const raw = await fs68.promises.readFile(envPath, "utf8");
|
|
29837
29899
|
await ctx.relay.sendResult(cmd.id, "completed", {
|
|
29838
29900
|
exists: true,
|
|
29839
29901
|
vars: parseDotenv(raw)
|
|
@@ -29862,7 +29924,7 @@ var envParseH = async (ctx, cmd, parsed) => {
|
|
|
29862
29924
|
const existing = /* @__PURE__ */ new Map();
|
|
29863
29925
|
if (!replace) {
|
|
29864
29926
|
try {
|
|
29865
|
-
const raw = await
|
|
29927
|
+
const raw = await fs68.promises.readFile(path75.join(process.cwd(), ".env"), "utf8");
|
|
29866
29928
|
for (const v of parseDotenv(raw)) existing.set(v.key, v.value);
|
|
29867
29929
|
} catch {
|
|
29868
29930
|
}
|
|
@@ -29905,12 +29967,12 @@ var envWriteH = async (ctx, cmd, parsed) => {
|
|
|
29905
29967
|
const envPath = path75.join(process.cwd(), ".env");
|
|
29906
29968
|
const tmpPath = path75.join(process.cwd(), ".env.codeam.tmp");
|
|
29907
29969
|
try {
|
|
29908
|
-
await
|
|
29909
|
-
await
|
|
29970
|
+
await fs68.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
|
|
29971
|
+
await fs68.promises.rename(tmpPath, envPath);
|
|
29910
29972
|
await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
|
|
29911
29973
|
void syncProjectEnvUp(process.cwd(), ctx);
|
|
29912
29974
|
} catch (err) {
|
|
29913
|
-
await
|
|
29975
|
+
await fs68.promises.rm(tmpPath, { force: true }).catch(() => void 0);
|
|
29914
29976
|
await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
|
|
29915
29977
|
}
|
|
29916
29978
|
};
|
|
@@ -30259,7 +30321,7 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
|
|
|
30259
30321
|
function buildNpmInstallInvocation(opts) {
|
|
30260
30322
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
30261
30323
|
const execPath = opts?.execPath ?? process.execPath;
|
|
30262
|
-
const exists2 = opts?.existsSync ??
|
|
30324
|
+
const exists2 = opts?.existsSync ?? fs68.existsSync;
|
|
30263
30325
|
const platform3 = opts?.platform ?? process.platform;
|
|
30264
30326
|
const p2 = platform3 === "win32" ? path75.win32 : path75.posix;
|
|
30265
30327
|
const normalized = entryScript.split(/[\\/]/).join("/");
|
|
@@ -30290,9 +30352,9 @@ function resolveGlobalNodeModulesDir(opts) {
|
|
|
30290
30352
|
var STALE_STAGING_AGE_MS = CLI_UPDATE_INSTALL_TIMEOUT_MS;
|
|
30291
30353
|
function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
30292
30354
|
if (!nodeModulesDir) return 0;
|
|
30293
|
-
const readdirSync18 = deps?.readdirSync ??
|
|
30294
|
-
const statSync17 = deps?.statSync ??
|
|
30295
|
-
const rmSync15 = deps?.rmSync ??
|
|
30355
|
+
const readdirSync18 = deps?.readdirSync ?? fs68.readdirSync;
|
|
30356
|
+
const statSync17 = deps?.statSync ?? fs68.statSync;
|
|
30357
|
+
const rmSync15 = deps?.rmSync ?? fs68.rmSync;
|
|
30296
30358
|
let removed = 0;
|
|
30297
30359
|
let entries2;
|
|
30298
30360
|
try {
|
|
@@ -30857,7 +30919,8 @@ function makePreviewReaffirm(args2) {
|
|
|
30857
30919
|
return {
|
|
30858
30920
|
url: active2.url,
|
|
30859
30921
|
framework: active2.framework,
|
|
30860
|
-
port: active2.detection.port
|
|
30922
|
+
port: active2.detection.port,
|
|
30923
|
+
...active2.expoGoUrl ? { expoGoUrl: active2.expoGoUrl } : {}
|
|
30861
30924
|
};
|
|
30862
30925
|
},
|
|
30863
30926
|
emitReady: (payload) => {
|
|
@@ -31452,7 +31515,7 @@ function resolveTokenValue(args2) {
|
|
|
31452
31515
|
if (fileFlag) {
|
|
31453
31516
|
const path116 = fileFlag.slice("--token-file=".length);
|
|
31454
31517
|
try {
|
|
31455
|
-
const content =
|
|
31518
|
+
const content = fs69.readFileSync(path116, "utf8").trim();
|
|
31456
31519
|
if (content.length === 0) fail(`--token-file ${path116} is empty`);
|
|
31457
31520
|
rmIfExistsQuiet(path116);
|
|
31458
31521
|
return content;
|
|
@@ -31551,7 +31614,7 @@ function pairAutoLockPath() {
|
|
|
31551
31614
|
var procRoot = "/proc";
|
|
31552
31615
|
function readProcFile(rel) {
|
|
31553
31616
|
try {
|
|
31554
|
-
return
|
|
31617
|
+
return fs69.readFileSync(path76.join(procRoot, rel), "utf8");
|
|
31555
31618
|
} catch {
|
|
31556
31619
|
return void 0;
|
|
31557
31620
|
}
|
|
@@ -31572,7 +31635,7 @@ function currentBootId() {
|
|
|
31572
31635
|
function readLockRecord(lockPath) {
|
|
31573
31636
|
let raw;
|
|
31574
31637
|
try {
|
|
31575
|
-
raw =
|
|
31638
|
+
raw = fs69.readFileSync(lockPath, "utf8");
|
|
31576
31639
|
} catch {
|
|
31577
31640
|
return void 0;
|
|
31578
31641
|
}
|
|
@@ -31621,7 +31684,7 @@ function isLiveLockHolder(rec) {
|
|
|
31621
31684
|
}
|
|
31622
31685
|
function releaseOwnLock(lockPath) {
|
|
31623
31686
|
try {
|
|
31624
|
-
if (readLockRecord(lockPath)?.pid === process.pid)
|
|
31687
|
+
if (readLockRecord(lockPath)?.pid === process.pid) fs69.unlinkSync(lockPath);
|
|
31625
31688
|
} catch {
|
|
31626
31689
|
}
|
|
31627
31690
|
}
|
|
@@ -31645,7 +31708,7 @@ function snapshotProcessTree(root) {
|
|
|
31645
31708
|
const children = /* @__PURE__ */ new Map();
|
|
31646
31709
|
let entries2 = [];
|
|
31647
31710
|
try {
|
|
31648
|
-
entries2 =
|
|
31711
|
+
entries2 = fs69.readdirSync(procRoot).filter((e) => /^\d+$/.test(e));
|
|
31649
31712
|
} catch {
|
|
31650
31713
|
}
|
|
31651
31714
|
for (const e of entries2) {
|
|
@@ -31685,13 +31748,13 @@ function daemonLockPath(sessionId) {
|
|
|
31685
31748
|
function acquireDaemonLock(sessionId) {
|
|
31686
31749
|
const lockPath = daemonLockPath(sessionId);
|
|
31687
31750
|
try {
|
|
31688
|
-
|
|
31751
|
+
fs69.mkdirSync(path76.dirname(lockPath), { recursive: true });
|
|
31689
31752
|
try {
|
|
31690
|
-
|
|
31753
|
+
fs69.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
31691
31754
|
} catch (e) {
|
|
31692
31755
|
if (e.code !== "EEXIST") throw e;
|
|
31693
31756
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
31694
|
-
|
|
31757
|
+
fs69.writeFileSync(lockPath, ownLockBody());
|
|
31695
31758
|
}
|
|
31696
31759
|
const release3 = () => releaseOwnLock(lockPath);
|
|
31697
31760
|
process.once("exit", release3);
|
|
@@ -31711,13 +31774,13 @@ function acquireDaemonLock(sessionId) {
|
|
|
31711
31774
|
function acquireSingletonLock() {
|
|
31712
31775
|
const lockPath = pairAutoLockPath();
|
|
31713
31776
|
try {
|
|
31714
|
-
|
|
31777
|
+
fs69.mkdirSync(path76.dirname(lockPath), { recursive: true });
|
|
31715
31778
|
try {
|
|
31716
|
-
|
|
31779
|
+
fs69.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
31717
31780
|
} catch (e) {
|
|
31718
31781
|
if (e.code !== "EEXIST") throw e;
|
|
31719
31782
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
31720
|
-
|
|
31783
|
+
fs69.writeFileSync(lockPath, ownLockBody());
|
|
31721
31784
|
}
|
|
31722
31785
|
process.once("exit", () => releaseOwnLock(lockPath));
|
|
31723
31786
|
return true;
|
|
@@ -32469,7 +32532,7 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
|
|
|
32469
32532
|
}
|
|
32470
32533
|
|
|
32471
32534
|
// src/agents/acp/prefetch-module-graph.ts
|
|
32472
|
-
var
|
|
32535
|
+
var fs70 = __toESM(require("fs"));
|
|
32473
32536
|
var path78 = __toESM(require("path"));
|
|
32474
32537
|
var LOADABLE_EXT = /* @__PURE__ */ new Set([".js", ".mjs", ".cjs", ".json", ".node"]);
|
|
32475
32538
|
var DEFAULT_MODULE_GRAPH_LIMITS = {
|
|
@@ -32479,15 +32542,15 @@ var DEFAULT_MODULE_GRAPH_LIMITS = {
|
|
|
32479
32542
|
concurrency: 16
|
|
32480
32543
|
};
|
|
32481
32544
|
var realFs = {
|
|
32482
|
-
readdir: (dir) =>
|
|
32483
|
-
readFile: (file) =>
|
|
32484
|
-
stat: (file) =>
|
|
32545
|
+
readdir: (dir) => fs70.promises.readdir(dir, { withFileTypes: true }),
|
|
32546
|
+
readFile: (file) => fs70.promises.readFile(file),
|
|
32547
|
+
stat: (file) => fs70.promises.stat(file)
|
|
32485
32548
|
};
|
|
32486
32549
|
function findPackageDir(dep, fromDir) {
|
|
32487
32550
|
let dir = fromDir;
|
|
32488
32551
|
for (; ; ) {
|
|
32489
32552
|
const candidate = path78.join(dir, "node_modules", dep);
|
|
32490
|
-
if (
|
|
32553
|
+
if (fs70.existsSync(path78.join(candidate, "package.json"))) return candidate;
|
|
32491
32554
|
const parent = path78.dirname(dir);
|
|
32492
32555
|
if (parent === dir) return null;
|
|
32493
32556
|
dir = parent;
|
|
@@ -32495,7 +32558,7 @@ function findPackageDir(dep, fromDir) {
|
|
|
32495
32558
|
}
|
|
32496
32559
|
function runtimeDependencies(pkgDir) {
|
|
32497
32560
|
try {
|
|
32498
|
-
const manifest = JSON.parse(
|
|
32561
|
+
const manifest = JSON.parse(fs70.readFileSync(path78.join(pkgDir, "package.json"), "utf8"));
|
|
32499
32562
|
return Object.keys(manifest.dependencies ?? {});
|
|
32500
32563
|
} catch {
|
|
32501
32564
|
return [];
|
|
@@ -32531,7 +32594,7 @@ async function collectModuleGraphFiles(rootPkgDir, limits = DEFAULT_MODULE_GRAPH
|
|
|
32531
32594
|
const queue = [rootPkgDir];
|
|
32532
32595
|
while (queue.length > 0 && files.length < limits.maxFiles) {
|
|
32533
32596
|
const pkgDir = queue.shift();
|
|
32534
|
-
const key =
|
|
32597
|
+
const key = fs70.existsSync(pkgDir) ? fs70.realpathSync(pkgDir) : pkgDir;
|
|
32535
32598
|
if (seen2.has(key)) continue;
|
|
32536
32599
|
seen2.add(key);
|
|
32537
32600
|
await packageFiles(pkgDir, fsd, files, limits.maxFiles);
|
|
@@ -32643,7 +32706,7 @@ async function waitForNoAgentStarting(opts) {
|
|
|
32643
32706
|
|
|
32644
32707
|
// src/agents/acp/runner.ts
|
|
32645
32708
|
var import_node_crypto15 = require("crypto");
|
|
32646
|
-
var
|
|
32709
|
+
var fs89 = __toESM(require("fs"));
|
|
32647
32710
|
var os61 = __toESM(require("os"));
|
|
32648
32711
|
var path98 = __toESM(require("path"));
|
|
32649
32712
|
|
|
@@ -32677,7 +32740,7 @@ function noteProviderBillingSignal(opts) {
|
|
|
32677
32740
|
}
|
|
32678
32741
|
|
|
32679
32742
|
// src/services/history.service.ts
|
|
32680
|
-
var
|
|
32743
|
+
var fs72 = __toESM(require("fs"));
|
|
32681
32744
|
var path80 = __toESM(require("path"));
|
|
32682
32745
|
var https6 = __toESM(require("https"));
|
|
32683
32746
|
var http10 = __toESM(require("http"));
|
|
@@ -32739,7 +32802,7 @@ function parseJsonl(filePath) {
|
|
|
32739
32802
|
const messages = [];
|
|
32740
32803
|
let raw;
|
|
32741
32804
|
try {
|
|
32742
|
-
raw =
|
|
32805
|
+
raw = fs72.readFileSync(filePath, "utf8");
|
|
32743
32806
|
} catch (err) {
|
|
32744
32807
|
if (err.code !== "ENOENT") {
|
|
32745
32808
|
log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
|
|
@@ -32949,11 +33012,11 @@ var HistoryService = class _HistoryService {
|
|
|
32949
33012
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
32950
33013
|
const oneShots = readOneShotConversations(this.cwd);
|
|
32951
33014
|
try {
|
|
32952
|
-
const files =
|
|
33015
|
+
const files = fs72.readdirSync(dir, { withFileTypes: true }).filter(
|
|
32953
33016
|
(e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(path80.basename(e.name, ".jsonl"))
|
|
32954
33017
|
).map((e) => {
|
|
32955
33018
|
try {
|
|
32956
|
-
const stat3 =
|
|
33019
|
+
const stat3 = fs72.statSync(path80.join(dir, e.name));
|
|
32957
33020
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
32958
33021
|
} catch {
|
|
32959
33022
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
@@ -32994,13 +33057,13 @@ var HistoryService = class _HistoryService {
|
|
|
32994
33057
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
32995
33058
|
let entries2;
|
|
32996
33059
|
try {
|
|
32997
|
-
entries2 =
|
|
33060
|
+
entries2 = fs72.readdirSync(dir, { withFileTypes: true });
|
|
32998
33061
|
} catch {
|
|
32999
33062
|
return null;
|
|
33000
33063
|
}
|
|
33001
33064
|
const files = entries2.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
33002
33065
|
try {
|
|
33003
|
-
const stat3 =
|
|
33066
|
+
const stat3 = fs72.statSync(path80.join(dir, e.name));
|
|
33004
33067
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
33005
33068
|
} catch {
|
|
33006
33069
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
@@ -33014,7 +33077,7 @@ var HistoryService = class _HistoryService {
|
|
|
33014
33077
|
extractUsageFromFile(filePath) {
|
|
33015
33078
|
let raw;
|
|
33016
33079
|
try {
|
|
33017
|
-
raw =
|
|
33080
|
+
raw = fs72.readFileSync(filePath, "utf8");
|
|
33018
33081
|
} catch {
|
|
33019
33082
|
return null;
|
|
33020
33083
|
}
|
|
@@ -33066,9 +33129,9 @@ var HistoryService = class _HistoryService {
|
|
|
33066
33129
|
let totalCost = 0;
|
|
33067
33130
|
let files;
|
|
33068
33131
|
try {
|
|
33069
|
-
files =
|
|
33132
|
+
files = fs72.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
|
|
33070
33133
|
try {
|
|
33071
|
-
return
|
|
33134
|
+
return fs72.statSync(path80.join(projectDir, f)).mtimeMs >= monthStartMs;
|
|
33072
33135
|
} catch {
|
|
33073
33136
|
return false;
|
|
33074
33137
|
}
|
|
@@ -33079,7 +33142,7 @@ var HistoryService = class _HistoryService {
|
|
|
33079
33142
|
for (const file of files) {
|
|
33080
33143
|
let raw;
|
|
33081
33144
|
try {
|
|
33082
|
-
raw =
|
|
33145
|
+
raw = fs72.readFileSync(path80.join(projectDir, file), "utf8");
|
|
33083
33146
|
} catch {
|
|
33084
33147
|
continue;
|
|
33085
33148
|
}
|
|
@@ -33278,7 +33341,7 @@ var HistoryService = class _HistoryService {
|
|
|
33278
33341
|
if (!filePath) return false;
|
|
33279
33342
|
let mtimeMs;
|
|
33280
33343
|
try {
|
|
33281
|
-
mtimeMs =
|
|
33344
|
+
mtimeMs = fs72.statSync(filePath).mtimeMs;
|
|
33282
33345
|
} catch {
|
|
33283
33346
|
return false;
|
|
33284
33347
|
}
|
|
@@ -33353,7 +33416,7 @@ var HistoryService = class _HistoryService {
|
|
|
33353
33416
|
|
|
33354
33417
|
// src/agents/acp/client.ts
|
|
33355
33418
|
var import_node_child_process28 = require("child_process");
|
|
33356
|
-
var
|
|
33419
|
+
var fs73 = __toESM(require("fs/promises"));
|
|
33357
33420
|
var fsSync = __toESM(require("fs"));
|
|
33358
33421
|
var os52 = __toESM(require("os"));
|
|
33359
33422
|
var path82 = __toESM(require("path"));
|
|
@@ -38595,7 +38658,7 @@ var AcpClient = class {
|
|
|
38595
38658
|
throw new RequestError(-32002, GUARDRAIL_SECRET_READ_BLOCK_REASON, { uri: params.path });
|
|
38596
38659
|
}
|
|
38597
38660
|
try {
|
|
38598
|
-
const content = await
|
|
38661
|
+
const content = await fs73.readFile(params.path, "utf8");
|
|
38599
38662
|
return applyLineRange(content, params.line ?? null, params.limit ?? null);
|
|
38600
38663
|
} catch (err) {
|
|
38601
38664
|
const code = err.code;
|
|
@@ -38616,7 +38679,7 @@ var AcpClient = class {
|
|
|
38616
38679
|
throw new RequestError(-32002, INTERNAL_BLOCK_REASON, { uri: params.path });
|
|
38617
38680
|
}
|
|
38618
38681
|
try {
|
|
38619
|
-
await
|
|
38682
|
+
await fs73.writeFile(params.path, params.content, "utf8");
|
|
38620
38683
|
return {};
|
|
38621
38684
|
} catch (err) {
|
|
38622
38685
|
const code = err.code;
|
|
@@ -39019,7 +39082,7 @@ async function performAgentSwitch(deps, rawAgentId, fastPath = {}) {
|
|
|
39019
39082
|
}
|
|
39020
39083
|
|
|
39021
39084
|
// src/commands/host/agent-provisioning.ts
|
|
39022
|
-
var
|
|
39085
|
+
var fs74 = __toESM(require("fs"));
|
|
39023
39086
|
var os54 = __toESM(require("os"));
|
|
39024
39087
|
var path83 = __toESM(require("path"));
|
|
39025
39088
|
var PUBLIC_TO_INTERNAL_AGENT = {
|
|
@@ -39038,16 +39101,16 @@ function toInternalAgentId(publicAgentId) {
|
|
|
39038
39101
|
return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
|
|
39039
39102
|
}
|
|
39040
39103
|
function ensureDir(dir) {
|
|
39041
|
-
|
|
39104
|
+
fs74.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
39042
39105
|
}
|
|
39043
39106
|
function writeFile0600(filePath, contents) {
|
|
39044
39107
|
ensureDir(path83.dirname(filePath));
|
|
39045
|
-
|
|
39108
|
+
fs74.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
|
|
39046
39109
|
restrictToOwner(filePath);
|
|
39047
39110
|
}
|
|
39048
39111
|
function rmIfExists(filePath) {
|
|
39049
39112
|
try {
|
|
39050
|
-
|
|
39113
|
+
fs74.rmSync(filePath, { force: true });
|
|
39051
39114
|
} catch {
|
|
39052
39115
|
}
|
|
39053
39116
|
}
|
|
@@ -39066,7 +39129,7 @@ var claudeProvisioner = {
|
|
|
39066
39129
|
rmIfExists(credentialsJson);
|
|
39067
39130
|
}
|
|
39068
39131
|
const claudeJson = path83.join(home, ".claude.json");
|
|
39069
|
-
if (!
|
|
39132
|
+
if (!fs74.existsSync(claudeJson)) {
|
|
39070
39133
|
writeFile0600(
|
|
39071
39134
|
claudeJson,
|
|
39072
39135
|
JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
|
|
@@ -39100,7 +39163,7 @@ function codexLoginStamp(raw) {
|
|
|
39100
39163
|
function keepsFresherCodexLogin(authJsonPath, incoming) {
|
|
39101
39164
|
let onDisk;
|
|
39102
39165
|
try {
|
|
39103
|
-
onDisk =
|
|
39166
|
+
onDisk = fs74.readFileSync(authJsonPath, "utf8");
|
|
39104
39167
|
} catch {
|
|
39105
39168
|
return false;
|
|
39106
39169
|
}
|
|
@@ -39241,7 +39304,7 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os54.homedir(
|
|
|
39241
39304
|
}
|
|
39242
39305
|
|
|
39243
39306
|
// src/beads/workflow-hint.ts
|
|
39244
|
-
var
|
|
39307
|
+
var fs75 = __toESM(require("fs"));
|
|
39245
39308
|
var path84 = __toESM(require("path"));
|
|
39246
39309
|
var BEADS_HINT_MARKER = "<!-- codeam:beads-workflow -->";
|
|
39247
39310
|
var BEADS_HINT = `${BEADS_HINT_MARKER}
|
|
@@ -39269,11 +39332,11 @@ function ensureBeadsWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
|
39269
39332
|
try {
|
|
39270
39333
|
let existing = "";
|
|
39271
39334
|
try {
|
|
39272
|
-
existing =
|
|
39335
|
+
existing = fs75.readFileSync(file, "utf8");
|
|
39273
39336
|
} catch {
|
|
39274
39337
|
}
|
|
39275
39338
|
if (existing.includes(BEADS_HINT)) return;
|
|
39276
|
-
|
|
39339
|
+
fs75.mkdirSync(path84.dirname(file), { recursive: true });
|
|
39277
39340
|
let next;
|
|
39278
39341
|
const open = existing.indexOf(BEADS_HINT_MARKER);
|
|
39279
39342
|
const close = open === -1 ? -1 : existing.indexOf(BEADS_HINT_MARKER, open + BEADS_HINT_MARKER.length);
|
|
@@ -39286,40 +39349,40 @@ ${BEADS_HINT}
|
|
|
39286
39349
|
` : `${BEADS_HINT}
|
|
39287
39350
|
`;
|
|
39288
39351
|
}
|
|
39289
|
-
|
|
39352
|
+
fs75.writeFileSync(file, next);
|
|
39290
39353
|
} catch {
|
|
39291
39354
|
}
|
|
39292
39355
|
}
|
|
39293
39356
|
|
|
39294
39357
|
// src/agents/agent-standard.ts
|
|
39295
|
-
var
|
|
39358
|
+
var fs76 = __toESM(require("fs"));
|
|
39296
39359
|
var path85 = __toESM(require("path"));
|
|
39297
39360
|
var os55 = __toESM(require("os"));
|
|
39298
39361
|
function ensureAgentStandard(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
39299
39362
|
try {
|
|
39300
39363
|
let existing = "";
|
|
39301
39364
|
try {
|
|
39302
|
-
existing =
|
|
39365
|
+
existing = fs76.readFileSync(file, "utf8");
|
|
39303
39366
|
} catch {
|
|
39304
39367
|
}
|
|
39305
39368
|
if (existing.includes(AGENT_STANDARD_MARKER)) return;
|
|
39306
|
-
|
|
39369
|
+
fs76.mkdirSync(path85.dirname(file), { recursive: true });
|
|
39307
39370
|
const next = existing.trim() ? `${existing.trimEnd()}
|
|
39308
39371
|
|
|
39309
39372
|
${AGENT_STANDARD_BLOCK}
|
|
39310
39373
|
` : `${AGENT_STANDARD_BLOCK}
|
|
39311
39374
|
`;
|
|
39312
|
-
|
|
39375
|
+
fs76.writeFileSync(file, next);
|
|
39313
39376
|
} catch {
|
|
39314
39377
|
}
|
|
39315
39378
|
}
|
|
39316
39379
|
var _agentStandardSeam = {
|
|
39317
39380
|
isLocalSession: () => isLocalSession(),
|
|
39318
39381
|
markerPath: (sessionId) => path85.join(os55.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
|
|
39319
|
-
exists: (p2) =>
|
|
39382
|
+
exists: (p2) => fs76.existsSync(p2),
|
|
39320
39383
|
write: (p2) => {
|
|
39321
|
-
|
|
39322
|
-
|
|
39384
|
+
fs76.mkdirSync(path85.dirname(p2), { recursive: true });
|
|
39385
|
+
fs76.writeFileSync(p2, "");
|
|
39323
39386
|
}
|
|
39324
39387
|
};
|
|
39325
39388
|
function isClaude(agent) {
|
|
@@ -40180,15 +40243,15 @@ function withholdTrailingPartialFenceMarker(text) {
|
|
|
40180
40243
|
|
|
40181
40244
|
// src/agents/acp/onboarding.ts
|
|
40182
40245
|
var import_child_process28 = require("child_process");
|
|
40183
|
-
var
|
|
40246
|
+
var fs78 = __toESM(require("fs"));
|
|
40184
40247
|
var os56 = __toESM(require("os"));
|
|
40185
40248
|
var path87 = __toESM(require("path"));
|
|
40186
40249
|
var _onboardingSeam = {
|
|
40187
40250
|
markerPath: (sessionId) => path87.join(os56.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
|
|
40188
|
-
exists: (p2) =>
|
|
40251
|
+
exists: (p2) => fs78.existsSync(p2),
|
|
40189
40252
|
write: (p2) => {
|
|
40190
|
-
|
|
40191
|
-
|
|
40253
|
+
fs78.mkdirSync(path87.dirname(p2), { recursive: true });
|
|
40254
|
+
fs78.writeFileSync(p2, "");
|
|
40192
40255
|
},
|
|
40193
40256
|
disabled: () => {
|
|
40194
40257
|
const v = process.env.CODEAM_ONBOARDING_DISABLED;
|
|
@@ -40625,13 +40688,13 @@ var import_crypto5 = require("crypto");
|
|
|
40625
40688
|
|
|
40626
40689
|
// src/services/turn-files/git-changeset.ts
|
|
40627
40690
|
var import_child_process29 = require("child_process");
|
|
40628
|
-
var
|
|
40691
|
+
var fs80 = __toESM(require("fs/promises"));
|
|
40629
40692
|
var import_fs10 = require("fs");
|
|
40630
40693
|
var path89 = __toESM(require("path"));
|
|
40631
40694
|
|
|
40632
40695
|
// src/services/turn-files/review-ignore.ts
|
|
40633
40696
|
var import_ignore2 = __toESM(require("ignore"));
|
|
40634
|
-
var
|
|
40697
|
+
var fs79 = __toESM(require("fs"));
|
|
40635
40698
|
var path88 = __toESM(require("path"));
|
|
40636
40699
|
var CURATED_REVIEW_IGNORE = [
|
|
40637
40700
|
// Google Cloud SDK (the incident) — installs a huge python tree.
|
|
@@ -40676,7 +40739,7 @@ var CURATED_REVIEW_IGNORE = [
|
|
|
40676
40739
|
function makeReviewIgnore(repoRoot) {
|
|
40677
40740
|
const ig = (0, import_ignore2.default)().add(CURATED_REVIEW_IGNORE);
|
|
40678
40741
|
try {
|
|
40679
|
-
const custom =
|
|
40742
|
+
const custom = fs79.readFileSync(path88.join(repoRoot, ".codeam", "reviewignore"), "utf8");
|
|
40680
40743
|
ig.add(custom);
|
|
40681
40744
|
} catch {
|
|
40682
40745
|
}
|
|
@@ -40759,7 +40822,7 @@ function readUntrackedLineCount(absPath) {
|
|
|
40759
40822
|
}
|
|
40760
40823
|
async function defaultReadUntrackedLineCount(absPath) {
|
|
40761
40824
|
try {
|
|
40762
|
-
const content = await
|
|
40825
|
+
const content = await fs80.readFile(absPath, "utf8");
|
|
40763
40826
|
let count = 0;
|
|
40764
40827
|
let pos = -1;
|
|
40765
40828
|
while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
|
|
@@ -40851,7 +40914,7 @@ function defaultRunGit(cwd, args2) {
|
|
|
40851
40914
|
});
|
|
40852
40915
|
}
|
|
40853
40916
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
40854
|
-
const
|
|
40917
|
+
const fs103 = await import("fs/promises");
|
|
40855
40918
|
const out2 = [];
|
|
40856
40919
|
await walk2(workingDir, 0);
|
|
40857
40920
|
return out2;
|
|
@@ -40859,7 +40922,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
40859
40922
|
if (depth2 > maxDepth) return;
|
|
40860
40923
|
let entries2 = [];
|
|
40861
40924
|
try {
|
|
40862
|
-
const dirents = await
|
|
40925
|
+
const dirents = await fs103.readdir(dir, { withFileTypes: true });
|
|
40863
40926
|
entries2 = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
40864
40927
|
} catch {
|
|
40865
40928
|
return;
|
|
@@ -40893,7 +40956,7 @@ function isReviewablePath(absPath) {
|
|
|
40893
40956
|
}
|
|
40894
40957
|
|
|
40895
40958
|
// src/services/turn-files/files-outbox.ts
|
|
40896
|
-
var
|
|
40959
|
+
var fs81 = __toESM(require("fs/promises"));
|
|
40897
40960
|
var path90 = __toESM(require("path"));
|
|
40898
40961
|
var import_os14 = require("os");
|
|
40899
40962
|
var HOME_OUTBOX_DIR = ".codeam/outbox";
|
|
@@ -40935,8 +40998,8 @@ var FilesOutbox = class {
|
|
|
40935
40998
|
/** Persist the entry to disk and trigger a flush. Returns once the
|
|
40936
40999
|
* line is durable on disk (not once the POST succeeds). */
|
|
40937
41000
|
async enqueue(entry) {
|
|
40938
|
-
await
|
|
40939
|
-
await
|
|
41001
|
+
await fs81.mkdir(path90.dirname(this.filePath), { recursive: true });
|
|
41002
|
+
await fs81.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
|
|
40940
41003
|
this.backoffIndex = 0;
|
|
40941
41004
|
if (this.autoSchedule) this.scheduleFlush(0);
|
|
40942
41005
|
}
|
|
@@ -41027,7 +41090,7 @@ var FilesOutbox = class {
|
|
|
41027
41090
|
async readAll() {
|
|
41028
41091
|
let raw = "";
|
|
41029
41092
|
try {
|
|
41030
|
-
raw = await
|
|
41093
|
+
raw = await fs81.readFile(this.filePath, "utf8");
|
|
41031
41094
|
} catch {
|
|
41032
41095
|
return [];
|
|
41033
41096
|
}
|
|
@@ -41051,12 +41114,12 @@ var FilesOutbox = class {
|
|
|
41051
41114
|
async rewrite(entries2) {
|
|
41052
41115
|
const tmpPath = `${this.filePath}.${process.pid}.tmp`;
|
|
41053
41116
|
if (entries2.length === 0) {
|
|
41054
|
-
await
|
|
41117
|
+
await fs81.unlink(this.filePath).catch(() => void 0);
|
|
41055
41118
|
return;
|
|
41056
41119
|
}
|
|
41057
41120
|
const payload = entries2.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
41058
|
-
await
|
|
41059
|
-
await
|
|
41121
|
+
await fs81.writeFile(tmpPath, payload, "utf8");
|
|
41122
|
+
await fs81.rename(tmpPath, this.filePath);
|
|
41060
41123
|
}
|
|
41061
41124
|
};
|
|
41062
41125
|
function applyJitter(ms) {
|
|
@@ -41426,7 +41489,7 @@ async function readActiveConversationMarker(cwd, homeDir2) {
|
|
|
41426
41489
|
|
|
41427
41490
|
// src/packs/gates.ts
|
|
41428
41491
|
var import_node_child_process29 = require("child_process");
|
|
41429
|
-
var
|
|
41492
|
+
var fs83 = __toESM(require("fs"));
|
|
41430
41493
|
var path92 = __toESM(require("path"));
|
|
41431
41494
|
var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((resolve13) => {
|
|
41432
41495
|
(0, import_node_child_process29.execFile)(
|
|
@@ -41477,7 +41540,7 @@ async function changedFiles(run3, cwd, from, to) {
|
|
|
41477
41540
|
}
|
|
41478
41541
|
function readWorkspaceFile(cwd, relPath) {
|
|
41479
41542
|
try {
|
|
41480
|
-
return
|
|
41543
|
+
return fs83.readFileSync(path92.join(cwd, relPath), "utf8");
|
|
41481
41544
|
} catch {
|
|
41482
41545
|
return null;
|
|
41483
41546
|
}
|
|
@@ -41486,14 +41549,14 @@ var NO_TEST_PLACEHOLDER = 'echo "Error: no test specified"';
|
|
|
41486
41549
|
var CHECKS_TIMEOUT_MS = 5 * 6e4;
|
|
41487
41550
|
function detectChecksCommand(cwd) {
|
|
41488
41551
|
try {
|
|
41489
|
-
const cfg = JSON.parse(
|
|
41552
|
+
const cfg = JSON.parse(fs83.readFileSync(path92.join(cwd, ".codeam", "pack.json"), "utf8"));
|
|
41490
41553
|
if (typeof cfg.checksCommand === "string" && cfg.checksCommand.trim().length > 0) {
|
|
41491
41554
|
return cfg.checksCommand.trim();
|
|
41492
41555
|
}
|
|
41493
41556
|
} catch {
|
|
41494
41557
|
}
|
|
41495
41558
|
try {
|
|
41496
|
-
const pkg = JSON.parse(
|
|
41559
|
+
const pkg = JSON.parse(fs83.readFileSync(path92.join(cwd, "package.json"), "utf8"));
|
|
41497
41560
|
const test = pkg.scripts?.test;
|
|
41498
41561
|
if (typeof test === "string" && test.trim().length > 0 && !test.includes(NO_TEST_PLACEHOLDER)) {
|
|
41499
41562
|
return "npm test";
|
|
@@ -41511,7 +41574,7 @@ ${res.stderr}`.trim();
|
|
|
41511
41574
|
}
|
|
41512
41575
|
|
|
41513
41576
|
// src/packs/run-store.ts
|
|
41514
|
-
var
|
|
41577
|
+
var fs84 = __toESM(require("fs"));
|
|
41515
41578
|
var path93 = __toESM(require("path"));
|
|
41516
41579
|
var crypto5 = __toESM(require("crypto"));
|
|
41517
41580
|
function packsDir(cwd) {
|
|
@@ -41524,10 +41587,10 @@ function newRunId() {
|
|
|
41524
41587
|
return `pk_${Date.now().toString(36)}_${crypto5.randomBytes(4).toString("hex")}`;
|
|
41525
41588
|
}
|
|
41526
41589
|
function writeJsonAtomic(file, value) {
|
|
41527
|
-
|
|
41590
|
+
fs84.mkdirSync(path93.dirname(file), { recursive: true });
|
|
41528
41591
|
const tmp = `${file}.tmp`;
|
|
41529
|
-
|
|
41530
|
-
|
|
41592
|
+
fs84.writeFileSync(tmp, JSON.stringify(value, null, 2));
|
|
41593
|
+
fs84.renameSync(tmp, file);
|
|
41531
41594
|
}
|
|
41532
41595
|
function saveRun(cwd, state) {
|
|
41533
41596
|
writeJsonAtomic(path93.join(runDir(cwd, state.runId), "run.json"), state);
|
|
@@ -41539,11 +41602,11 @@ function saveStageHandoff(cwd, runId, stageIndex, role, handoff) {
|
|
|
41539
41602
|
function loadLatestRun(cwd) {
|
|
41540
41603
|
try {
|
|
41541
41604
|
const dir = packsDir(cwd);
|
|
41542
|
-
const entries2 =
|
|
41605
|
+
const entries2 = fs84.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
41543
41606
|
for (let i = entries2.length - 1; i >= 0; i--) {
|
|
41544
41607
|
const file = path93.join(dir, entries2[i], "run.json");
|
|
41545
41608
|
try {
|
|
41546
|
-
const parsed = JSON.parse(
|
|
41609
|
+
const parsed = JSON.parse(fs84.readFileSync(file, "utf8"));
|
|
41547
41610
|
if (parsed && typeof parsed.runId === "string") return parsed;
|
|
41548
41611
|
} catch {
|
|
41549
41612
|
}
|
|
@@ -41555,16 +41618,16 @@ function loadLatestRun(cwd) {
|
|
|
41555
41618
|
function ensureLedgerIgnored(cwd) {
|
|
41556
41619
|
try {
|
|
41557
41620
|
const gitDir = path93.join(cwd, ".git");
|
|
41558
|
-
if (!
|
|
41621
|
+
if (!fs84.existsSync(gitDir)) return;
|
|
41559
41622
|
const exclude = path93.join(gitDir, "info", "exclude");
|
|
41560
41623
|
let existing = "";
|
|
41561
41624
|
try {
|
|
41562
|
-
existing =
|
|
41625
|
+
existing = fs84.readFileSync(exclude, "utf8");
|
|
41563
41626
|
} catch {
|
|
41564
41627
|
}
|
|
41565
41628
|
if (existing.includes(".codeam/packs/")) return;
|
|
41566
|
-
|
|
41567
|
-
|
|
41629
|
+
fs84.mkdirSync(path93.dirname(exclude), { recursive: true });
|
|
41630
|
+
fs84.writeFileSync(exclude, `${existing.trimEnd()}
|
|
41568
41631
|
.codeam/packs/
|
|
41569
41632
|
`.trimStart());
|
|
41570
41633
|
} catch {
|
|
@@ -42559,7 +42622,7 @@ async function mcpRouter() {
|
|
|
42559
42622
|
}
|
|
42560
42623
|
|
|
42561
42624
|
// src/integrations/mcp-secrets.ts
|
|
42562
|
-
var
|
|
42625
|
+
var fs86 = __toESM(require("fs"));
|
|
42563
42626
|
var os59 = __toESM(require("os"));
|
|
42564
42627
|
var path95 = __toESM(require("path"));
|
|
42565
42628
|
var MCP_SECRETS_FILE_ENV = "CODEAM_MCP_SECRETS_FILE";
|
|
@@ -42572,7 +42635,7 @@ function mcpSecretsPath(scope, pid = process.pid) {
|
|
|
42572
42635
|
var registeredForCleanup = /* @__PURE__ */ new Set();
|
|
42573
42636
|
function readFileVars(file) {
|
|
42574
42637
|
try {
|
|
42575
|
-
const parsed = JSON.parse(
|
|
42638
|
+
const parsed = JSON.parse(fs86.readFileSync(file, "utf8"));
|
|
42576
42639
|
if (!parsed || typeof parsed !== "object") return {};
|
|
42577
42640
|
const out2 = {};
|
|
42578
42641
|
for (const [k2, v] of Object.entries(parsed)) {
|
|
@@ -42594,7 +42657,7 @@ function pidAlive2(pid) {
|
|
|
42594
42657
|
function pruneStale(dir) {
|
|
42595
42658
|
let names = [];
|
|
42596
42659
|
try {
|
|
42597
|
-
names =
|
|
42660
|
+
names = fs86.readdirSync(dir);
|
|
42598
42661
|
} catch {
|
|
42599
42662
|
return;
|
|
42600
42663
|
}
|
|
@@ -42604,7 +42667,7 @@ function pruneStale(dir) {
|
|
|
42604
42667
|
const pid = Number(m[1]);
|
|
42605
42668
|
if (pid === process.pid || pidAlive2(pid)) continue;
|
|
42606
42669
|
try {
|
|
42607
|
-
|
|
42670
|
+
fs86.unlinkSync(path95.join(dir, name));
|
|
42608
42671
|
} catch {
|
|
42609
42672
|
}
|
|
42610
42673
|
}
|
|
@@ -42612,17 +42675,17 @@ function pruneStale(dir) {
|
|
|
42612
42675
|
function writeMcpSecrets(vars, file) {
|
|
42613
42676
|
try {
|
|
42614
42677
|
const dir = path95.dirname(file);
|
|
42615
|
-
|
|
42678
|
+
fs86.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
42616
42679
|
pruneStale(dir);
|
|
42617
42680
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
42618
|
-
|
|
42619
|
-
|
|
42620
|
-
|
|
42681
|
+
fs86.writeFileSync(tmp, JSON.stringify(vars), { mode: 384 });
|
|
42682
|
+
fs86.renameSync(tmp, file);
|
|
42683
|
+
fs86.chmodSync(file, 384);
|
|
42621
42684
|
if (!registeredForCleanup.has(file)) {
|
|
42622
42685
|
registeredForCleanup.add(file);
|
|
42623
42686
|
process.once("exit", () => {
|
|
42624
42687
|
try {
|
|
42625
|
-
|
|
42688
|
+
fs86.unlinkSync(file);
|
|
42626
42689
|
} catch {
|
|
42627
42690
|
}
|
|
42628
42691
|
});
|
|
@@ -45973,7 +46036,7 @@ async function runAcpSession(opts) {
|
|
|
45973
46036
|
`switch-${opts.pluginId}`
|
|
45974
46037
|
);
|
|
45975
46038
|
try {
|
|
45976
|
-
|
|
46039
|
+
fs89.mkdirSync(claudeConfigDir2, { recursive: true, mode: 448 });
|
|
45977
46040
|
} catch {
|
|
45978
46041
|
}
|
|
45979
46042
|
const memoryFile = path98.join(claudeConfigDir2, "CLAUDE.md");
|
|
@@ -47216,7 +47279,7 @@ function pickPinnedSession(pinnedId, listSessions2) {
|
|
|
47216
47279
|
}
|
|
47217
47280
|
|
|
47218
47281
|
// src/agents/retired-proxy-cleanup.ts
|
|
47219
|
-
var
|
|
47282
|
+
var fs90 = __toESM(require("fs"));
|
|
47220
47283
|
var path99 = __toESM(require("path"));
|
|
47221
47284
|
var os62 = __toESM(require("os"));
|
|
47222
47285
|
var RETIRED_PROXY_RE = /^https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):8787(?:[/?#]|$)/i;
|
|
@@ -47232,7 +47295,7 @@ function sanitizeRetiredProxyConfig(homeDir2 = os62.homedir()) {
|
|
|
47232
47295
|
const file = path99.join(homeDir2, ".claude", "settings.json");
|
|
47233
47296
|
let parsed;
|
|
47234
47297
|
try {
|
|
47235
|
-
parsed = JSON.parse(
|
|
47298
|
+
parsed = JSON.parse(fs90.readFileSync(file, "utf8"));
|
|
47236
47299
|
} catch {
|
|
47237
47300
|
return out2;
|
|
47238
47301
|
}
|
|
@@ -47274,9 +47337,9 @@ function sanitizeRetiredProxyConfig(homeDir2 = os62.homedir()) {
|
|
|
47274
47337
|
if (!out2.changed) return out2;
|
|
47275
47338
|
try {
|
|
47276
47339
|
const tmp = `${file}.codeam.tmp`;
|
|
47277
|
-
|
|
47340
|
+
fs90.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
|
|
47278
47341
|
`, { mode: 384 });
|
|
47279
|
-
|
|
47342
|
+
fs90.renameSync(tmp, file);
|
|
47280
47343
|
} catch {
|
|
47281
47344
|
out2.changed = false;
|
|
47282
47345
|
}
|
|
@@ -47822,7 +47885,7 @@ var AcpDriver = class {
|
|
|
47822
47885
|
};
|
|
47823
47886
|
|
|
47824
47887
|
// src/baton/transcript-mirror.ts
|
|
47825
|
-
var
|
|
47888
|
+
var fs91 = __toESM(require("fs"));
|
|
47826
47889
|
var TranscriptMirror = class {
|
|
47827
47890
|
constructor(deps) {
|
|
47828
47891
|
this.deps = deps;
|
|
@@ -47916,7 +47979,7 @@ var TranscriptMirror = class {
|
|
|
47916
47979
|
}
|
|
47917
47980
|
};
|
|
47918
47981
|
function defaultWatch(file, onChange) {
|
|
47919
|
-
const w3 =
|
|
47982
|
+
const w3 = fs91.watch(file, { persistent: false }, () => onChange());
|
|
47920
47983
|
return () => w3.close();
|
|
47921
47984
|
}
|
|
47922
47985
|
|
|
@@ -48416,7 +48479,7 @@ function keepDeviceAwake(deps = {}) {
|
|
|
48416
48479
|
}
|
|
48417
48480
|
|
|
48418
48481
|
// src/agents/claude/onboarding.ts
|
|
48419
|
-
var
|
|
48482
|
+
var fs92 = __toESM(require("fs"));
|
|
48420
48483
|
var os64 = __toESM(require("os"));
|
|
48421
48484
|
var path100 = __toESM(require("path"));
|
|
48422
48485
|
var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
|
|
@@ -48425,7 +48488,7 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
48425
48488
|
const file = path100.join(os64.homedir(), ".claude.json");
|
|
48426
48489
|
let config = {};
|
|
48427
48490
|
try {
|
|
48428
|
-
config = JSON.parse(
|
|
48491
|
+
config = JSON.parse(fs92.readFileSync(file, "utf8"));
|
|
48429
48492
|
} catch {
|
|
48430
48493
|
}
|
|
48431
48494
|
let changed = false;
|
|
@@ -48450,8 +48513,8 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
48450
48513
|
}
|
|
48451
48514
|
}
|
|
48452
48515
|
if (!changed) return;
|
|
48453
|
-
|
|
48454
|
-
|
|
48516
|
+
fs92.mkdirSync(path100.dirname(file), { recursive: true });
|
|
48517
|
+
fs92.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
48455
48518
|
log.info(
|
|
48456
48519
|
"claude",
|
|
48457
48520
|
`pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
|
|
@@ -51262,7 +51325,7 @@ async function stopWorkspaceFromLocal(target) {
|
|
|
51262
51325
|
}
|
|
51263
51326
|
|
|
51264
51327
|
// src/commands/host/host-client.ts
|
|
51265
|
-
var
|
|
51328
|
+
var fs93 = __toESM(require("fs"));
|
|
51266
51329
|
var os65 = __toESM(require("os"));
|
|
51267
51330
|
var path105 = __toESM(require("path"));
|
|
51268
51331
|
var import_node_crypto16 = require("crypto");
|
|
@@ -51328,7 +51391,7 @@ function collectOsInfo() {
|
|
|
51328
51391
|
}
|
|
51329
51392
|
function loadHostIdentity() {
|
|
51330
51393
|
try {
|
|
51331
|
-
const raw =
|
|
51394
|
+
const raw = fs93.readFileSync(hostIdentityPath(), "utf8");
|
|
51332
51395
|
const parsed = JSON.parse(raw);
|
|
51333
51396
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
|
|
51334
51397
|
const p2 = parsed;
|
|
@@ -51357,8 +51420,8 @@ function ensureControlPollSecret(identity, save = saveHostIdentity) {
|
|
|
51357
51420
|
}
|
|
51358
51421
|
function saveHostIdentity(identity) {
|
|
51359
51422
|
const file = hostIdentityPath();
|
|
51360
|
-
|
|
51361
|
-
|
|
51423
|
+
fs93.mkdirSync(path105.dirname(file), { recursive: true, mode: 448 });
|
|
51424
|
+
fs93.writeFileSync(file, JSON.stringify(identity, null, 2), {
|
|
51362
51425
|
encoding: "utf8",
|
|
51363
51426
|
mode: 384
|
|
51364
51427
|
});
|
|
@@ -51403,7 +51466,7 @@ function isTerminalEnrollError(err) {
|
|
|
51403
51466
|
}
|
|
51404
51467
|
function deleteHostIdentity() {
|
|
51405
51468
|
try {
|
|
51406
|
-
|
|
51469
|
+
fs93.rmSync(hostIdentityPath(), { force: true });
|
|
51407
51470
|
} catch {
|
|
51408
51471
|
}
|
|
51409
51472
|
}
|
|
@@ -51632,7 +51695,7 @@ async function host(args2) {
|
|
|
51632
51695
|
// src/commands/host-agent.ts
|
|
51633
51696
|
var import_node_child_process38 = require("child_process");
|
|
51634
51697
|
var os71 = __toESM(require("os"));
|
|
51635
|
-
var
|
|
51698
|
+
var fs100 = __toESM(require("fs"));
|
|
51636
51699
|
var path112 = __toESM(require("path"));
|
|
51637
51700
|
|
|
51638
51701
|
// src/skills/persist-from-payload.ts
|
|
@@ -51642,7 +51705,7 @@ function persistOrClearSkillsFromPayload(skills) {
|
|
|
51642
51705
|
}
|
|
51643
51706
|
|
|
51644
51707
|
// src/commands/host/session-state.ts
|
|
51645
|
-
var
|
|
51708
|
+
var fs94 = __toESM(require("fs"));
|
|
51646
51709
|
var os66 = __toESM(require("os"));
|
|
51647
51710
|
var path106 = __toESM(require("path"));
|
|
51648
51711
|
function hostSessionStatePath(env = process.env) {
|
|
@@ -51659,7 +51722,7 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
51659
51722
|
return {
|
|
51660
51723
|
load() {
|
|
51661
51724
|
try {
|
|
51662
|
-
const raw = JSON.parse(
|
|
51725
|
+
const raw = JSON.parse(fs94.readFileSync(file, "utf8"));
|
|
51663
51726
|
return Array.isArray(raw?.sessions) ? raw.sessions.filter(isRecord5) : null;
|
|
51664
51727
|
} catch {
|
|
51665
51728
|
return null;
|
|
@@ -51667,18 +51730,18 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
51667
51730
|
},
|
|
51668
51731
|
save(list) {
|
|
51669
51732
|
try {
|
|
51670
|
-
|
|
51733
|
+
fs94.mkdirSync(path106.dirname(file), { recursive: true, mode: 448 });
|
|
51671
51734
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
51672
|
-
|
|
51735
|
+
fs94.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
|
|
51673
51736
|
mode: 384
|
|
51674
51737
|
});
|
|
51675
|
-
|
|
51738
|
+
fs94.renameSync(tmp, file);
|
|
51676
51739
|
} catch {
|
|
51677
51740
|
}
|
|
51678
51741
|
},
|
|
51679
51742
|
clear() {
|
|
51680
51743
|
try {
|
|
51681
|
-
|
|
51744
|
+
fs94.rmSync(file, { force: true });
|
|
51682
51745
|
} catch {
|
|
51683
51746
|
}
|
|
51684
51747
|
}
|
|
@@ -51716,7 +51779,7 @@ function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
|
51716
51779
|
|
|
51717
51780
|
// src/commands/host/git-tooling.ts
|
|
51718
51781
|
var import_node_child_process32 = require("child_process");
|
|
51719
|
-
var
|
|
51782
|
+
var fs95 = __toESM(require("fs"));
|
|
51720
51783
|
var os67 = __toESM(require("os"));
|
|
51721
51784
|
var path107 = __toESM(require("path"));
|
|
51722
51785
|
function codeamBinDir() {
|
|
@@ -51752,7 +51815,7 @@ async function download(url2, dest) {
|
|
|
51752
51815
|
const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
|
|
51753
51816
|
if (!res.ok || !res.body) return false;
|
|
51754
51817
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
51755
|
-
|
|
51818
|
+
fs95.writeFileSync(dest, buf);
|
|
51756
51819
|
return true;
|
|
51757
51820
|
} catch {
|
|
51758
51821
|
return false;
|
|
@@ -51775,7 +51838,7 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
51775
51838
|
const version3 = await resolveVersionFn(token);
|
|
51776
51839
|
const asset = `gh_${version3}_${osToken}_${arch2}`;
|
|
51777
51840
|
const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
|
|
51778
|
-
const tmpRoot =
|
|
51841
|
+
const tmpRoot = fs95.mkdtempSync(path107.join(os67.tmpdir(), "codeam-gh-"));
|
|
51779
51842
|
const archive = path107.join(tmpRoot, `${asset}.${ext}`);
|
|
51780
51843
|
if (!await downloadFn(url2, archive)) {
|
|
51781
51844
|
log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
|
|
@@ -51787,15 +51850,15 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
51787
51850
|
return null;
|
|
51788
51851
|
}
|
|
51789
51852
|
const extractedBin = path107.join(tmpRoot, asset, "bin", binaryName);
|
|
51790
|
-
if (!
|
|
51853
|
+
if (!fs95.existsSync(extractedBin)) {
|
|
51791
51854
|
log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
|
|
51792
51855
|
return null;
|
|
51793
51856
|
}
|
|
51794
51857
|
const binDir = codeamBinDir();
|
|
51795
|
-
|
|
51858
|
+
fs95.mkdirSync(binDir, { recursive: true });
|
|
51796
51859
|
const target = path107.join(binDir, binaryName);
|
|
51797
|
-
|
|
51798
|
-
|
|
51860
|
+
fs95.copyFileSync(extractedBin, target);
|
|
51861
|
+
fs95.chmodSync(target, 493);
|
|
51799
51862
|
log.info("host-agent", `gh installed to ${target} (v${version3})`);
|
|
51800
51863
|
return target;
|
|
51801
51864
|
} catch (e) {
|
|
@@ -51842,9 +51905,9 @@ function writeGhHostsToken(token) {
|
|
|
51842
51905
|
try {
|
|
51843
51906
|
const dir = ghConfigDir();
|
|
51844
51907
|
const file = path107.join(dir, "hosts.yml");
|
|
51845
|
-
if (
|
|
51846
|
-
|
|
51847
|
-
|
|
51908
|
+
if (fs95.existsSync(file)) return false;
|
|
51909
|
+
fs95.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
51910
|
+
fs95.writeFileSync(
|
|
51848
51911
|
file,
|
|
51849
51912
|
`github.com:
|
|
51850
51913
|
oauth_token: ${token}
|
|
@@ -51887,7 +51950,7 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
51887
51950
|
const version3 = await resolveLatestGlabVersion();
|
|
51888
51951
|
const asset = `glab_${version3}_${osToken}_${arch2}`;
|
|
51889
51952
|
const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
|
|
51890
|
-
const tmpRoot =
|
|
51953
|
+
const tmpRoot = fs95.mkdtempSync(path107.join(os67.tmpdir(), "codeam-glab-"));
|
|
51891
51954
|
const archive = path107.join(tmpRoot, `${asset}.${ext}`);
|
|
51892
51955
|
if (!await downloadFn(url2, archive)) {
|
|
51893
51956
|
log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
|
|
@@ -51903,16 +51966,16 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
51903
51966
|
path107.join(tmpRoot, asset, "bin", binaryName),
|
|
51904
51967
|
path107.join(tmpRoot, binaryName)
|
|
51905
51968
|
];
|
|
51906
|
-
const extractedBin = candidates.find((c2) =>
|
|
51969
|
+
const extractedBin = candidates.find((c2) => fs95.existsSync(c2));
|
|
51907
51970
|
if (!extractedBin) {
|
|
51908
51971
|
log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
|
|
51909
51972
|
return null;
|
|
51910
51973
|
}
|
|
51911
51974
|
const binDir = codeamBinDir();
|
|
51912
|
-
|
|
51975
|
+
fs95.mkdirSync(binDir, { recursive: true });
|
|
51913
51976
|
const target = path107.join(binDir, binaryName);
|
|
51914
|
-
|
|
51915
|
-
|
|
51977
|
+
fs95.copyFileSync(extractedBin, target);
|
|
51978
|
+
fs95.chmodSync(target, 493);
|
|
51916
51979
|
log.info("host-agent", `glab installed to ${target} (v${version3})`);
|
|
51917
51980
|
return target;
|
|
51918
51981
|
} catch (e) {
|
|
@@ -51991,12 +52054,12 @@ var defaultGitToolingRunner = {
|
|
|
51991
52054
|
};
|
|
51992
52055
|
|
|
51993
52056
|
// src/lib/cli-versions.ts
|
|
51994
|
-
var
|
|
52057
|
+
var fs97 = __toESM(require("fs"));
|
|
51995
52058
|
var os69 = __toESM(require("os"));
|
|
51996
52059
|
var path109 = __toESM(require("path"));
|
|
51997
52060
|
|
|
51998
52061
|
// src/lib/updateNotifier.ts
|
|
51999
|
-
var
|
|
52062
|
+
var fs96 = __toESM(require("fs"));
|
|
52000
52063
|
var os68 = __toESM(require("os"));
|
|
52001
52064
|
var path108 = __toESM(require("path"));
|
|
52002
52065
|
var https8 = __toESM(require("https"));
|
|
@@ -52012,7 +52075,7 @@ function cachePath() {
|
|
|
52012
52075
|
}
|
|
52013
52076
|
function readCache() {
|
|
52014
52077
|
try {
|
|
52015
|
-
const raw =
|
|
52078
|
+
const raw = fs96.readFileSync(cachePath(), "utf8");
|
|
52016
52079
|
const parsed = JSON.parse(raw);
|
|
52017
52080
|
if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
|
|
52018
52081
|
return parsed;
|
|
@@ -52023,10 +52086,10 @@ function readCache() {
|
|
|
52023
52086
|
function writeCache(cache) {
|
|
52024
52087
|
try {
|
|
52025
52088
|
const file = cachePath();
|
|
52026
|
-
|
|
52089
|
+
fs96.mkdirSync(path108.dirname(file), { recursive: true });
|
|
52027
52090
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
52028
|
-
|
|
52029
|
-
|
|
52091
|
+
fs96.writeFileSync(tmp, JSON.stringify(cache));
|
|
52092
|
+
fs96.renameSync(tmp, file);
|
|
52030
52093
|
} catch {
|
|
52031
52094
|
}
|
|
52032
52095
|
}
|
|
@@ -52101,7 +52164,7 @@ function isLinkedInstall() {
|
|
|
52101
52164
|
}).trim();
|
|
52102
52165
|
if (!root) return false;
|
|
52103
52166
|
const pkgPath = path108.join(root, PKG_NAME);
|
|
52104
|
-
return
|
|
52167
|
+
return fs96.lstatSync(pkgPath).isSymbolicLink();
|
|
52105
52168
|
} catch {
|
|
52106
52169
|
return false;
|
|
52107
52170
|
}
|
|
@@ -52137,7 +52200,7 @@ function maybeAutoUpdate(currentVersion, latest) {
|
|
|
52137
52200
|
return;
|
|
52138
52201
|
}
|
|
52139
52202
|
try {
|
|
52140
|
-
|
|
52203
|
+
fs96.unlinkSync(cachePath());
|
|
52141
52204
|
} catch {
|
|
52142
52205
|
}
|
|
52143
52206
|
process.stderr.write(` ${import_picocolors12.default.green("\u2713")} Updated. Resuming session...
|
|
@@ -52153,7 +52216,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
52153
52216
|
if (process.env.NODE_ENV === "test") return;
|
|
52154
52217
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
52155
52218
|
if (process.env.CI) return;
|
|
52156
|
-
const current2 = true ? "2.76.
|
|
52219
|
+
const current2 = true ? "2.76.42" : null;
|
|
52157
52220
|
if (!current2) return;
|
|
52158
52221
|
const cache = readCache();
|
|
52159
52222
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -52170,7 +52233,7 @@ function checkForUpdates() {
|
|
|
52170
52233
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
52171
52234
|
if (process.env.CI) return;
|
|
52172
52235
|
if (!process.stdout.isTTY) return;
|
|
52173
|
-
const current2 = true ? "2.76.
|
|
52236
|
+
const current2 = true ? "2.76.42" : null;
|
|
52174
52237
|
if (!current2) return;
|
|
52175
52238
|
const cache = readCache();
|
|
52176
52239
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -52204,7 +52267,7 @@ function isRecord6(v) {
|
|
|
52204
52267
|
function readPkg2(versionDir) {
|
|
52205
52268
|
try {
|
|
52206
52269
|
const raw = JSON.parse(
|
|
52207
|
-
|
|
52270
|
+
fs97.readFileSync(path109.join(packageDirOf(versionDir), "package.json"), "utf8")
|
|
52208
52271
|
);
|
|
52209
52272
|
return isRecord6(raw) ? raw : null;
|
|
52210
52273
|
} catch {
|
|
@@ -52218,14 +52281,14 @@ function entryOf(versionDir) {
|
|
|
52218
52281
|
const named = isRecord6(bin) ? bin.codeam : void 0;
|
|
52219
52282
|
const rel = typeof bin === "string" ? bin : typeof named === "string" ? named : "dist/index.js";
|
|
52220
52283
|
const entry = path109.join(packageDirOf(versionDir), rel);
|
|
52221
|
-
return
|
|
52284
|
+
return fs97.existsSync(entry) ? entry : null;
|
|
52222
52285
|
}
|
|
52223
52286
|
function launcherOf(versionDir) {
|
|
52224
52287
|
const entry = entryOf(versionDir);
|
|
52225
52288
|
if (!entry) return null;
|
|
52226
52289
|
const bin = path109.join(versionDir, "node_modules", ".bin", "codeam");
|
|
52227
52290
|
try {
|
|
52228
|
-
return
|
|
52291
|
+
return fs97.realpathSync(bin) === fs97.realpathSync(entry) ? bin : entry;
|
|
52229
52292
|
} catch {
|
|
52230
52293
|
return entry;
|
|
52231
52294
|
}
|
|
@@ -52238,7 +52301,7 @@ var BAD_MARKER_TTL_MS = 24 * 60 * 6e4;
|
|
|
52238
52301
|
var PRE_READY_WINDOW_MS = 60 * 6e4;
|
|
52239
52302
|
function isBad(versionDir, now = Date.now()) {
|
|
52240
52303
|
try {
|
|
52241
|
-
return now -
|
|
52304
|
+
return now - fs97.statSync(path109.join(versionDir, ".bad")).mtimeMs < BAD_MARKER_TTL_MS;
|
|
52242
52305
|
} catch {
|
|
52243
52306
|
return false;
|
|
52244
52307
|
}
|
|
@@ -52247,7 +52310,7 @@ function recordPreReadyFailure(versionDir, now = Date.now()) {
|
|
|
52247
52310
|
const file = path109.join(versionDir, ".prefail");
|
|
52248
52311
|
let count = 0;
|
|
52249
52312
|
try {
|
|
52250
|
-
const [n, at3] =
|
|
52313
|
+
const [n, at3] = fs97.readFileSync(file, "utf8").trim().split(" ").map(Number);
|
|
52251
52314
|
if (Number.isFinite(n) && Number.isFinite(at3) && now - at3 < PRE_READY_WINDOW_MS) {
|
|
52252
52315
|
count = n;
|
|
52253
52316
|
}
|
|
@@ -52255,43 +52318,43 @@ function recordPreReadyFailure(versionDir, now = Date.now()) {
|
|
|
52255
52318
|
}
|
|
52256
52319
|
count += 1;
|
|
52257
52320
|
try {
|
|
52258
|
-
|
|
52321
|
+
fs97.writeFileSync(file, `${count} ${now}`);
|
|
52259
52322
|
} catch {
|
|
52260
52323
|
}
|
|
52261
52324
|
return count;
|
|
52262
52325
|
}
|
|
52263
52326
|
function clearPreReadyFailures(versionDir) {
|
|
52264
|
-
|
|
52327
|
+
fs97.rmSync(path109.join(versionDir, ".prefail"), { force: true });
|
|
52265
52328
|
}
|
|
52266
52329
|
function markBad(versionDir, reason) {
|
|
52267
52330
|
try {
|
|
52268
|
-
|
|
52331
|
+
fs97.writeFileSync(path109.join(versionDir, ".bad"), `${(/* @__PURE__ */ new Date()).toISOString()} ${reason}
|
|
52269
52332
|
`);
|
|
52270
52333
|
} catch {
|
|
52271
52334
|
}
|
|
52272
52335
|
}
|
|
52273
52336
|
function pointerTarget(root, name) {
|
|
52274
52337
|
try {
|
|
52275
|
-
return
|
|
52338
|
+
return fs97.realpathSync(path109.join(root, name));
|
|
52276
52339
|
} catch {
|
|
52277
52340
|
return null;
|
|
52278
52341
|
}
|
|
52279
52342
|
}
|
|
52280
52343
|
function atomicPoint(root, name, targetDir) {
|
|
52281
|
-
const realRoot =
|
|
52344
|
+
const realRoot = fs97.realpathSync(root);
|
|
52282
52345
|
const tmp = path109.join(realRoot, `.${name}.tmp-${process.pid}-${Date.now()}`);
|
|
52283
|
-
|
|
52346
|
+
fs97.symlinkSync(path109.relative(realRoot, fs97.realpathSync(targetDir)), tmp, "dir");
|
|
52284
52347
|
try {
|
|
52285
|
-
|
|
52348
|
+
fs97.renameSync(tmp, path109.join(realRoot, name));
|
|
52286
52349
|
} catch (err) {
|
|
52287
|
-
|
|
52350
|
+
fs97.rmSync(tmp, { force: true });
|
|
52288
52351
|
throw err;
|
|
52289
52352
|
}
|
|
52290
52353
|
}
|
|
52291
52354
|
function samePath(a, b) {
|
|
52292
52355
|
const canon = (p2) => {
|
|
52293
52356
|
try {
|
|
52294
|
-
return
|
|
52357
|
+
return fs97.realpathSync(p2);
|
|
52295
52358
|
} catch {
|
|
52296
52359
|
return path109.resolve(p2);
|
|
52297
52360
|
}
|
|
@@ -52328,8 +52391,8 @@ function versionDirContaining(root, file) {
|
|
|
52328
52391
|
let real;
|
|
52329
52392
|
let realRoot;
|
|
52330
52393
|
try {
|
|
52331
|
-
real =
|
|
52332
|
-
realRoot =
|
|
52394
|
+
real = fs97.realpathSync(file);
|
|
52395
|
+
realRoot = fs97.realpathSync(root);
|
|
52333
52396
|
} catch {
|
|
52334
52397
|
return null;
|
|
52335
52398
|
}
|
|
@@ -52349,9 +52412,9 @@ function pidAlive3(pid) {
|
|
|
52349
52412
|
var CLK_TCK = 100;
|
|
52350
52413
|
function processStartMs(pid) {
|
|
52351
52414
|
try {
|
|
52352
|
-
const stat3 =
|
|
52415
|
+
const stat3 = fs97.readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
52353
52416
|
const ticks = Number(stat3.slice(stat3.lastIndexOf(")") + 2).split(" ")[19]);
|
|
52354
|
-
const btime = /^btime (\d+)$/m.exec(
|
|
52417
|
+
const btime = /^btime (\d+)$/m.exec(fs97.readFileSync("/proc/stat", "utf8"))?.[1];
|
|
52355
52418
|
if (!Number.isFinite(ticks) || !btime) return null;
|
|
52356
52419
|
return Number(btime) * 1e3 + ticks * 1e3 / CLK_TCK;
|
|
52357
52420
|
} catch {
|
|
@@ -52363,7 +52426,7 @@ function livePids(versionDir) {
|
|
|
52363
52426
|
const dir = path109.join(versionDir, ".pids");
|
|
52364
52427
|
let names;
|
|
52365
52428
|
try {
|
|
52366
|
-
names =
|
|
52429
|
+
names = fs97.readdirSync(dir);
|
|
52367
52430
|
} catch {
|
|
52368
52431
|
return [];
|
|
52369
52432
|
}
|
|
@@ -52372,7 +52435,7 @@ function livePids(versionDir) {
|
|
|
52372
52435
|
const started = processStartMs(pid);
|
|
52373
52436
|
if (started === null) return true;
|
|
52374
52437
|
try {
|
|
52375
|
-
return started <=
|
|
52438
|
+
return started <= fs97.statSync(path109.join(dir, String(pid))).mtimeMs + PID_REUSE_SLACK_MS;
|
|
52376
52439
|
} catch {
|
|
52377
52440
|
return true;
|
|
52378
52441
|
}
|
|
@@ -52383,9 +52446,9 @@ function registerRunningVersion(root = cliVersionsRoot(), entry = process.argv[1
|
|
|
52383
52446
|
if (!dir) return;
|
|
52384
52447
|
const file = path109.join(dir, ".pids", String(process.pid));
|
|
52385
52448
|
try {
|
|
52386
|
-
|
|
52387
|
-
|
|
52388
|
-
process.once("exit", () =>
|
|
52449
|
+
fs97.mkdirSync(path109.dirname(file), { recursive: true });
|
|
52450
|
+
fs97.writeFileSync(file, "");
|
|
52451
|
+
process.once("exit", () => fs97.rmSync(file, { force: true }));
|
|
52389
52452
|
} catch {
|
|
52390
52453
|
}
|
|
52391
52454
|
}
|
|
@@ -52393,7 +52456,7 @@ function gcVersions(root) {
|
|
|
52393
52456
|
const removed = [];
|
|
52394
52457
|
let names;
|
|
52395
52458
|
try {
|
|
52396
|
-
names =
|
|
52459
|
+
names = fs97.readdirSync(root).filter((n) => SEMVER_DIR.test(n));
|
|
52397
52460
|
} catch {
|
|
52398
52461
|
return removed;
|
|
52399
52462
|
}
|
|
@@ -52407,7 +52470,7 @@ function gcVersions(root) {
|
|
|
52407
52470
|
const dir = path109.join(root, name);
|
|
52408
52471
|
if (keep.has(name) || livePids(dir).length > 0) continue;
|
|
52409
52472
|
try {
|
|
52410
|
-
|
|
52473
|
+
fs97.rmSync(dir, { recursive: true, force: true });
|
|
52411
52474
|
removed.push(name);
|
|
52412
52475
|
} catch {
|
|
52413
52476
|
}
|
|
@@ -52418,22 +52481,22 @@ function acquireInstallLock(root) {
|
|
|
52418
52481
|
const lock = path109.join(root, ".install.lock");
|
|
52419
52482
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
52420
52483
|
try {
|
|
52421
|
-
const fd =
|
|
52422
|
-
|
|
52423
|
-
|
|
52424
|
-
return () =>
|
|
52484
|
+
const fd = fs97.openSync(lock, "wx");
|
|
52485
|
+
fs97.writeSync(fd, String(process.pid));
|
|
52486
|
+
fs97.closeSync(fd);
|
|
52487
|
+
return () => fs97.rmSync(lock, { force: true });
|
|
52425
52488
|
} catch (err) {
|
|
52426
52489
|
if (err.code !== "EEXIST") return null;
|
|
52427
52490
|
let stale = false;
|
|
52428
52491
|
try {
|
|
52429
|
-
const owner = Number(
|
|
52430
|
-
const age = Date.now() -
|
|
52492
|
+
const owner = Number(fs97.readFileSync(lock, "utf8"));
|
|
52493
|
+
const age = Date.now() - fs97.statSync(lock).mtimeMs;
|
|
52431
52494
|
stale = !Number.isInteger(owner) || !pidAlive3(owner) || age > LOCK_STALE_MS;
|
|
52432
52495
|
} catch {
|
|
52433
52496
|
stale = true;
|
|
52434
52497
|
}
|
|
52435
52498
|
if (!stale) return null;
|
|
52436
|
-
|
|
52499
|
+
fs97.rmSync(lock, { force: true });
|
|
52437
52500
|
}
|
|
52438
52501
|
}
|
|
52439
52502
|
return null;
|
|
@@ -52441,7 +52504,7 @@ function acquireInstallLock(root) {
|
|
|
52441
52504
|
|
|
52442
52505
|
// src/commands/host/host-launch.ts
|
|
52443
52506
|
var import_node_child_process35 = require("child_process");
|
|
52444
|
-
var
|
|
52507
|
+
var fs99 = __toESM(require("fs"));
|
|
52445
52508
|
var os70 = __toESM(require("os"));
|
|
52446
52509
|
var path111 = __toESM(require("path"));
|
|
52447
52510
|
|
|
@@ -52465,7 +52528,7 @@ var EXIT_CODE_NAMES = {
|
|
|
52465
52528
|
|
|
52466
52529
|
// src/commands/host/self-update.ts
|
|
52467
52530
|
var import_node_child_process34 = require("child_process");
|
|
52468
|
-
var
|
|
52531
|
+
var fs98 = __toESM(require("fs"));
|
|
52469
52532
|
var path110 = __toESM(require("path"));
|
|
52470
52533
|
var SELF_UPDATE_PKG = "codeam-cli";
|
|
52471
52534
|
var SELF_UPDATE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
@@ -52476,7 +52539,7 @@ var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
|
|
|
52476
52539
|
var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
52477
52540
|
var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
|
|
52478
52541
|
function currentCliVersion() {
|
|
52479
|
-
return true ? "2.76.
|
|
52542
|
+
return true ? "2.76.42" : null;
|
|
52480
52543
|
}
|
|
52481
52544
|
async function installedVersion(deps) {
|
|
52482
52545
|
const ls = await deps.run(
|
|
@@ -52594,7 +52657,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
52594
52657
|
const node = deps.nodePath ?? process.execPath;
|
|
52595
52658
|
const target = path110.join(root, latest);
|
|
52596
52659
|
try {
|
|
52597
|
-
|
|
52660
|
+
fs98.mkdirSync(root, { recursive: true });
|
|
52598
52661
|
} catch {
|
|
52599
52662
|
return { status: "skipped" };
|
|
52600
52663
|
}
|
|
@@ -52618,7 +52681,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
52618
52681
|
}
|
|
52619
52682
|
const reusable = entryOf(target) && versionOf(target) === latest;
|
|
52620
52683
|
if (!reusable) {
|
|
52621
|
-
|
|
52684
|
+
fs98.rmSync(target, { recursive: true, force: true });
|
|
52622
52685
|
const install = await deps.run(
|
|
52623
52686
|
"npm",
|
|
52624
52687
|
[
|
|
@@ -52633,7 +52696,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
52633
52696
|
SELF_UPDATE_INSTALL_TIMEOUT_MS
|
|
52634
52697
|
);
|
|
52635
52698
|
if (install.code !== 0) {
|
|
52636
|
-
|
|
52699
|
+
fs98.rmSync(target, { recursive: true, force: true });
|
|
52637
52700
|
log.warn(
|
|
52638
52701
|
"host-agent",
|
|
52639
52702
|
`self-update: versioned install exited ${String(install.code)} \u2014 staying on ${running2}: ` + install.stderr.slice(-300)
|
|
@@ -52644,7 +52707,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
52644
52707
|
const entry = entryOf(target);
|
|
52645
52708
|
const check = entry ? await deps.run(node, [entry, "--version"], VERIFY_TIMEOUT_MS) : { code: null, stdout: "", stderr: "no entry point" };
|
|
52646
52709
|
if (check.code !== 0 || !check.stdout.includes(latest)) {
|
|
52647
|
-
|
|
52710
|
+
fs98.rmSync(target, { recursive: true, force: true });
|
|
52648
52711
|
log.warn(
|
|
52649
52712
|
"host-agent",
|
|
52650
52713
|
`self-update: ${latest} failed verification (exit ${String(check.code)}: ${(check.stdout + check.stderr).trim().slice(-200)}) \u2014 staying on ${running2}`
|
|
@@ -52660,7 +52723,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
52660
52723
|
return { status: "updated", version: latest };
|
|
52661
52724
|
} catch (err) {
|
|
52662
52725
|
const cur = pointerTarget(root, "current");
|
|
52663
|
-
if (!cur || path110.basename(cur) !== latest)
|
|
52726
|
+
if (!cur || path110.basename(cur) !== latest) fs98.rmSync(target, { recursive: true, force: true });
|
|
52664
52727
|
log.warn(
|
|
52665
52728
|
"host-agent",
|
|
52666
52729
|
`self-update: versioned install failed: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -52699,7 +52762,7 @@ function signalHostReady(send = process.send?.bind(process)) {
|
|
|
52699
52762
|
}
|
|
52700
52763
|
function defaultDeps() {
|
|
52701
52764
|
return {
|
|
52702
|
-
ownVersion: true ? "2.76.
|
|
52765
|
+
ownVersion: true ? "2.76.42" : null,
|
|
52703
52766
|
root: cliVersionsRoot(),
|
|
52704
52767
|
args: process.argv.slice(3),
|
|
52705
52768
|
execPath: process.execPath,
|
|
@@ -52796,7 +52859,7 @@ function needsSelfRelaunch(env = process.env, pid = process.pid, ctx = {}) {
|
|
|
52796
52859
|
}
|
|
52797
52860
|
function readPid1Cmdline() {
|
|
52798
52861
|
try {
|
|
52799
|
-
return
|
|
52862
|
+
return fs99.readFileSync("/proc/1/cmdline", "utf8").split("\0").filter(Boolean);
|
|
52800
52863
|
} catch {
|
|
52801
52864
|
return [];
|
|
52802
52865
|
}
|
|
@@ -52844,7 +52907,7 @@ function defaultRestartForUpdate(version3, supervised, io = {}) {
|
|
|
52844
52907
|
}
|
|
52845
52908
|
exit(0);
|
|
52846
52909
|
}
|
|
52847
|
-
function isContainerEnvironment(existsSyncFn =
|
|
52910
|
+
function isContainerEnvironment(existsSyncFn = fs99.existsSync, readFileSyncFn = (p2) => fs99.readFileSync(p2, "utf8")) {
|
|
52848
52911
|
try {
|
|
52849
52912
|
if (existsSyncFn("/.dockerenv")) return true;
|
|
52850
52913
|
} catch {
|
|
@@ -52861,11 +52924,11 @@ function hostAgentPidFile(home = os70.homedir()) {
|
|
|
52861
52924
|
}
|
|
52862
52925
|
function writeHostAgentPidFile(file = hostAgentPidFile(), pid = process.pid) {
|
|
52863
52926
|
try {
|
|
52864
|
-
|
|
52865
|
-
|
|
52927
|
+
fs99.mkdirSync(path111.dirname(file), { recursive: true });
|
|
52928
|
+
fs99.writeFileSync(file, String(pid));
|
|
52866
52929
|
process.once("exit", () => {
|
|
52867
52930
|
try {
|
|
52868
|
-
if (
|
|
52931
|
+
if (fs99.readFileSync(file, "utf8").trim() === String(pid)) fs99.rmSync(file, { force: true });
|
|
52869
52932
|
} catch {
|
|
52870
52933
|
}
|
|
52871
52934
|
});
|
|
@@ -53719,7 +53782,7 @@ var HostAgentSupervisor = class {
|
|
|
53719
53782
|
const raw = cmd.payload?.path;
|
|
53720
53783
|
const target = typeof raw === "string" && raw.trim() ? path112.resolve(raw.trim()) : os71.homedir();
|
|
53721
53784
|
try {
|
|
53722
|
-
const dirents = await
|
|
53785
|
+
const dirents = await fs100.promises.readdir(target, { withFileTypes: true });
|
|
53723
53786
|
const entries2 = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
|
|
53724
53787
|
(a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
|
|
53725
53788
|
);
|
|
@@ -54208,7 +54271,7 @@ var HostAgentSupervisor = class {
|
|
|
54208
54271
|
payload.deployId
|
|
54209
54272
|
);
|
|
54210
54273
|
try {
|
|
54211
|
-
|
|
54274
|
+
fs100.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
|
|
54212
54275
|
} catch {
|
|
54213
54276
|
}
|
|
54214
54277
|
childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
|
|
@@ -54281,7 +54344,7 @@ var HostAgentSupervisor = class {
|
|
|
54281
54344
|
try {
|
|
54282
54345
|
const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path112.join(os71.homedir(), ".claude");
|
|
54283
54346
|
const projectDir = path112.join(cfgDir, "projects", encodeCwd(cwd));
|
|
54284
|
-
const hasPriorConversation =
|
|
54347
|
+
const hasPriorConversation = fs100.existsSync(projectDir) && fs100.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
|
|
54285
54348
|
if (hasPriorConversation) {
|
|
54286
54349
|
childEnv.CODEAM_RESUME_LATEST = "1";
|
|
54287
54350
|
log.info(
|
|
@@ -54435,7 +54498,7 @@ var HostAgentSupervisor = class {
|
|
|
54435
54498
|
fallbackResumeTarget() {
|
|
54436
54499
|
const session = getActiveSession();
|
|
54437
54500
|
if (!session || !session.pluginId || !session.pollSecret || !session.agent) return null;
|
|
54438
|
-
const cwd = session.cwd &&
|
|
54501
|
+
const cwd = session.cwd && fs100.existsSync(session.cwd) ? session.cwd : process.cwd();
|
|
54439
54502
|
if (isFilesystemRoot(cwd)) {
|
|
54440
54503
|
log.warn(
|
|
54441
54504
|
"host-agent",
|
|
@@ -54482,7 +54545,7 @@ var HostAgentSupervisor = class {
|
|
|
54482
54545
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: no saved pairing on this box`);
|
|
54483
54546
|
return;
|
|
54484
54547
|
}
|
|
54485
|
-
if (!session.cwd || !
|
|
54548
|
+
if (!session.cwd || !fs100.existsSync(session.cwd)) {
|
|
54486
54549
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: workspace is gone`);
|
|
54487
54550
|
return;
|
|
54488
54551
|
}
|
|
@@ -54524,7 +54587,7 @@ var HostAgentSupervisor = class {
|
|
|
54524
54587
|
const persisted = new Map((this.sessionStore.load() ?? []).map((r) => [r.deployId, r.agent]));
|
|
54525
54588
|
for (const c2 of this.children.values()) persisted.set(c2.deployId, c2.agent);
|
|
54526
54589
|
return this.listSavedSessions().map((s) => ({ s, deployId: deployIdFromWorkspace(s.cwd) })).filter(
|
|
54527
|
-
(x) => x.deployId !== null && !!x.s.cwd &&
|
|
54590
|
+
(x) => x.deployId !== null && !!x.s.cwd && fs100.existsSync(x.s.cwd)
|
|
54528
54591
|
).map(({ s, deployId }) => {
|
|
54529
54592
|
const agent = persisted.get(deployId);
|
|
54530
54593
|
return { deployId, sessionId: s.id, ...agent ? { agent } : {} };
|
|
@@ -54609,7 +54672,7 @@ var HostAgentSupervisor = class {
|
|
|
54609
54672
|
if (this.children.has(deployId)) return;
|
|
54610
54673
|
const st3 = this.resumeStateFor(target);
|
|
54611
54674
|
try {
|
|
54612
|
-
const cwd =
|
|
54675
|
+
const cwd = fs100.existsSync(target.cwd) ? target.cwd : process.cwd();
|
|
54613
54676
|
if (isWrapperCheckout(cwd)) {
|
|
54614
54677
|
log.warn(
|
|
54615
54678
|
"host-agent",
|
|
@@ -54849,7 +54912,7 @@ var HostAgentSupervisor = class {
|
|
|
54849
54912
|
];
|
|
54850
54913
|
for (const dir of dirs) {
|
|
54851
54914
|
try {
|
|
54852
|
-
|
|
54915
|
+
fs100.rmSync(dir, { recursive: true, force: true });
|
|
54853
54916
|
} catch (err) {
|
|
54854
54917
|
log.warn(
|
|
54855
54918
|
"host-agent",
|
|
@@ -55068,7 +55131,7 @@ async function invite() {
|
|
|
55068
55131
|
var import_node_dns = require("dns");
|
|
55069
55132
|
var import_node_util11 = require("util");
|
|
55070
55133
|
var import_node_crypto17 = require("crypto");
|
|
55071
|
-
var
|
|
55134
|
+
var fs101 = __toESM(require("fs"));
|
|
55072
55135
|
var path113 = __toESM(require("path"));
|
|
55073
55136
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
55074
55137
|
var dnsResolveP = (0, import_node_util11.promisify)(import_node_dns.resolve);
|
|
@@ -55127,11 +55190,11 @@ async function checkHealth(apiBase2) {
|
|
|
55127
55190
|
function checkConfigDir() {
|
|
55128
55191
|
const dir = path113.join(require("os").homedir(), ".codeam");
|
|
55129
55192
|
try {
|
|
55130
|
-
|
|
55193
|
+
fs101.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
55131
55194
|
const probe = path113.join(dir, ".doctor-probe");
|
|
55132
|
-
|
|
55133
|
-
const read =
|
|
55134
|
-
|
|
55195
|
+
fs101.writeFileSync(probe, "ok", { mode: 384 });
|
|
55196
|
+
const read = fs101.readFileSync(probe, "utf8");
|
|
55197
|
+
fs101.unlinkSync(probe);
|
|
55135
55198
|
if (read !== "ok") throw new Error("write/read round-trip mismatch");
|
|
55136
55199
|
return {
|
|
55137
55200
|
id: "config-dir",
|
|
@@ -55237,7 +55300,7 @@ function checkChokidar() {
|
|
|
55237
55300
|
}
|
|
55238
55301
|
async function doctor(args2 = []) {
|
|
55239
55302
|
const json = args2.includes("--json");
|
|
55240
|
-
const cliVersion = true ? "2.76.
|
|
55303
|
+
const cliVersion = true ? "2.76.42" : "0.0.0-dev";
|
|
55241
55304
|
const apiBase2 = resolveApiBaseUrl();
|
|
55242
55305
|
const diagnosticId = (0, import_node_crypto17.randomUUID)();
|
|
55243
55306
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
@@ -55773,7 +55836,7 @@ async function mcpWarm(argv = [], opts = {}) {
|
|
|
55773
55836
|
// src/commands/version.ts
|
|
55774
55837
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
55775
55838
|
function version2() {
|
|
55776
|
-
const v = true ? "2.76.
|
|
55839
|
+
const v = true ? "2.76.42" : "unknown";
|
|
55777
55840
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
55778
55841
|
}
|
|
55779
55842
|
|