codeam-cli 2.75.23 → 2.75.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.js +515 -396
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -357,8 +357,8 @@ function defaultSpawn(timeoutMs) {
|
|
|
357
357
|
});
|
|
358
358
|
}
|
|
359
359
|
function resolveConvexBin(cwd) {
|
|
360
|
-
const local =
|
|
361
|
-
if (
|
|
360
|
+
const local = path94.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "convex.cmd" : "convex");
|
|
361
|
+
if (fs80.existsSync(local)) return { cmd: local, args: [] };
|
|
362
362
|
return { cmd: "npx", args: ["--yes", "convex"] };
|
|
363
363
|
}
|
|
364
364
|
function redact(text, key) {
|
|
@@ -489,13 +489,13 @@ async function runConvexAdminMcp(client3, id) {
|
|
|
489
489
|
});
|
|
490
490
|
await server.connect(new StdioServerTransport());
|
|
491
491
|
}
|
|
492
|
-
var import_node_child_process32,
|
|
492
|
+
var import_node_child_process32, fs80, path94, TOOLS;
|
|
493
493
|
var init_convex_admin_mcp = __esm({
|
|
494
494
|
"src/integrations/convex-admin-mcp.ts"() {
|
|
495
495
|
"use strict";
|
|
496
496
|
import_node_child_process32 = require("child_process");
|
|
497
|
-
|
|
498
|
-
|
|
497
|
+
fs80 = __toESM(require("fs"));
|
|
498
|
+
path94 = __toESM(require("path"));
|
|
499
499
|
TOOLS = [
|
|
500
500
|
{
|
|
501
501
|
name: "tables",
|
|
@@ -3525,11 +3525,11 @@ function quiet(fn) {
|
|
|
3525
3525
|
log.debug(TAG, "ignored sync error", err);
|
|
3526
3526
|
}
|
|
3527
3527
|
}
|
|
3528
|
-
function rmIfExistsQuiet(
|
|
3528
|
+
function rmIfExistsQuiet(path96) {
|
|
3529
3529
|
try {
|
|
3530
|
-
fs2.rmSync(
|
|
3530
|
+
fs2.rmSync(path96, { force: true });
|
|
3531
3531
|
} catch (err) {
|
|
3532
|
-
log.debug(TAG, `rmIfExists failed for ${
|
|
3532
|
+
log.debug(TAG, `rmIfExists failed for ${path96}`, err);
|
|
3533
3533
|
}
|
|
3534
3534
|
}
|
|
3535
3535
|
function killQuiet(target, signal = "SIGTERM") {
|
|
@@ -3695,9 +3695,9 @@ var _default = makeConfig();
|
|
|
3695
3695
|
var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, setSessionAgent, setSquadAuto, getSquadAuto, clearAll, saveCliConfig, loadCliConfig } = _default;
|
|
3696
3696
|
|
|
3697
3697
|
// src/commands/pair-auto.ts
|
|
3698
|
-
var
|
|
3698
|
+
var fs52 = __toESM(require("fs"));
|
|
3699
3699
|
var os40 = __toESM(require("os"));
|
|
3700
|
-
var
|
|
3700
|
+
var path60 = __toESM(require("path"));
|
|
3701
3701
|
var import_crypto3 = require("crypto");
|
|
3702
3702
|
|
|
3703
3703
|
// src/services/telemetry.service.ts
|
|
@@ -3733,8 +3733,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
|
|
|
3733
3733
|
return decodedFile;
|
|
3734
3734
|
};
|
|
3735
3735
|
}
|
|
3736
|
-
function normalizeWindowsPath(
|
|
3737
|
-
return
|
|
3736
|
+
function normalizeWindowsPath(path96) {
|
|
3737
|
+
return path96.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
3738
3738
|
}
|
|
3739
3739
|
|
|
3740
3740
|
// ../../node_modules/@posthog/core/dist/error-tracking/index.mjs
|
|
@@ -6467,13 +6467,13 @@ var PostHogCoreStateless = class {
|
|
|
6467
6467
|
sentFromRoute += batchMessages.length;
|
|
6468
6468
|
}
|
|
6469
6469
|
}
|
|
6470
|
-
async _sendOtlpBatch({ path:
|
|
6470
|
+
async _sendOtlpBatch({ path: path96, payload }) {
|
|
6471
6471
|
if (this.disabled) return {
|
|
6472
6472
|
kind: "fatal",
|
|
6473
6473
|
error: new Error("The client is disabled")
|
|
6474
6474
|
};
|
|
6475
6475
|
const serialized = JSON.stringify(payload);
|
|
6476
|
-
const url2 = `${this.host}/i/v1/${
|
|
6476
|
+
const url2 = `${this.host}/i/v1/${path96}?token=${encodeURIComponent(this.apiKey)}`;
|
|
6477
6477
|
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
|
|
6478
6478
|
const fetchOptions = {
|
|
6479
6479
|
method: "POST",
|
|
@@ -7713,14 +7713,14 @@ async function addSourceContext(frames, openSourceFile = import_promises.open, l
|
|
|
7713
7713
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
7714
7714
|
return frames;
|
|
7715
7715
|
}
|
|
7716
|
-
async function openRegularSourceFile(
|
|
7716
|
+
async function openRegularSourceFile(path96, openSourceFile, logger) {
|
|
7717
7717
|
let fileHandle;
|
|
7718
7718
|
let isValid = false;
|
|
7719
7719
|
try {
|
|
7720
|
-
fileHandle = await openSourceFile(
|
|
7720
|
+
fileHandle = await openSourceFile(path96, import_node_fs.constants.O_RDONLY | import_node_fs.constants.O_NONBLOCK);
|
|
7721
7721
|
const fileStat = await fileHandle.stat();
|
|
7722
7722
|
if (!fileStat.isFile()) return;
|
|
7723
|
-
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${
|
|
7723
|
+
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${path96}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
|
|
7724
7724
|
isValid = true;
|
|
7725
7725
|
return fileHandle;
|
|
7726
7726
|
} catch {
|
|
@@ -7730,8 +7730,8 @@ async function openRegularSourceFile(path95, openSourceFile, logger) {
|
|
|
7730
7730
|
});
|
|
7731
7731
|
}
|
|
7732
7732
|
}
|
|
7733
|
-
async function getContextLinesFromFile(
|
|
7734
|
-
const fileHandle = await openRegularSourceFile(
|
|
7733
|
+
async function getContextLinesFromFile(path96, ranges, output, cacheKey, openSourceFile, logger) {
|
|
7734
|
+
const fileHandle = await openRegularSourceFile(path96, openSourceFile, logger);
|
|
7735
7735
|
if (void 0 === fileHandle) return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
7736
7736
|
const openedFileHandle = fileHandle;
|
|
7737
7737
|
return new Promise((resolve12) => {
|
|
@@ -7833,22 +7833,22 @@ function clearLineContext(frame) {
|
|
|
7833
7833
|
delete frame.context_line;
|
|
7834
7834
|
delete frame.post_context;
|
|
7835
7835
|
}
|
|
7836
|
-
function shouldSkipContextLinesForFile(
|
|
7837
|
-
return
|
|
7836
|
+
function shouldSkipContextLinesForFile(path96) {
|
|
7837
|
+
return path96.startsWith("node:") || path96.endsWith(".min.js") || path96.endsWith(".min.cjs") || path96.endsWith(".min.mjs") || path96.startsWith("data:");
|
|
7838
7838
|
}
|
|
7839
7839
|
function shouldSkipContextLinesForFrame(frame) {
|
|
7840
7840
|
if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
|
|
7841
7841
|
if (void 0 !== frame.colno && frame.colno > MAX_CONTEXTLINES_COLNO) return true;
|
|
7842
7842
|
return false;
|
|
7843
7843
|
}
|
|
7844
|
-
function makeSourceCacheKey(
|
|
7845
|
-
if ((0, import_node_path.isAbsolute)(
|
|
7844
|
+
function makeSourceCacheKey(path96, basePath) {
|
|
7845
|
+
if ((0, import_node_path.isAbsolute)(path96)) return JSON.stringify([
|
|
7846
7846
|
null,
|
|
7847
|
-
|
|
7847
|
+
path96
|
|
7848
7848
|
]);
|
|
7849
7849
|
return void 0 === basePath ? void 0 : JSON.stringify([
|
|
7850
7850
|
basePath,
|
|
7851
|
-
|
|
7851
|
+
path96
|
|
7852
7852
|
]);
|
|
7853
7853
|
}
|
|
7854
7854
|
function rangeExistsInContentCache(cacheKey, range) {
|
|
@@ -10509,7 +10509,7 @@ function readAnonId() {
|
|
|
10509
10509
|
}
|
|
10510
10510
|
function superProperties() {
|
|
10511
10511
|
return {
|
|
10512
|
-
cliVersion: true ? "2.75.
|
|
10512
|
+
cliVersion: true ? "2.75.25" : "0.0.0-dev",
|
|
10513
10513
|
nodeVersion: process.version,
|
|
10514
10514
|
platform: process.platform,
|
|
10515
10515
|
arch: process.arch,
|
|
@@ -10751,7 +10751,7 @@ var http = __toESM(require("http"));
|
|
|
10751
10751
|
// package.json
|
|
10752
10752
|
var package_default = {
|
|
10753
10753
|
name: "codeam-cli",
|
|
10754
|
-
version: "2.75.
|
|
10754
|
+
version: "2.75.25",
|
|
10755
10755
|
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.",
|
|
10756
10756
|
type: "commonjs",
|
|
10757
10757
|
main: "dist/index.js",
|
|
@@ -12081,7 +12081,7 @@ var CommandRelayService = class _CommandRelayService {
|
|
|
12081
12081
|
// fresh + clear the "CLI update available" banner after a self-update
|
|
12082
12082
|
// (a codespace that reinstalls @latest reconnects via heartbeat, not
|
|
12083
12083
|
// pair/reconnect). Older backends ignore the extra field.
|
|
12084
|
-
..."2.75.
|
|
12084
|
+
..."2.75.25" ? { ideVersion: "2.75.25" } : {}
|
|
12085
12085
|
};
|
|
12086
12086
|
try {
|
|
12087
12087
|
const res = await _postJson(`${API_BASE2}/api/plugin/heartbeat`, body);
|
|
@@ -13534,9 +13534,9 @@ function closeAllTerminals() {
|
|
|
13534
13534
|
}
|
|
13535
13535
|
|
|
13536
13536
|
// src/commands/start/handlers.ts
|
|
13537
|
-
var
|
|
13537
|
+
var fs51 = __toESM(require("fs"));
|
|
13538
13538
|
var os39 = __toESM(require("os"));
|
|
13539
|
-
var
|
|
13539
|
+
var path59 = __toESM(require("path"));
|
|
13540
13540
|
var import_crypto2 = require("crypto");
|
|
13541
13541
|
var import_child_process25 = require("child_process");
|
|
13542
13542
|
|
|
@@ -17150,12 +17150,12 @@ function isAvailable() {
|
|
|
17150
17150
|
}
|
|
17151
17151
|
function augmentPath() {
|
|
17152
17152
|
const dirs = probeInstallDirs();
|
|
17153
|
-
const
|
|
17153
|
+
const sep7 = path15.delimiter;
|
|
17154
17154
|
const current2 = process.env.PATH ?? "";
|
|
17155
|
-
const existing = new Set(current2.split(
|
|
17155
|
+
const existing = new Set(current2.split(sep7).filter(Boolean));
|
|
17156
17156
|
const additions = dirs.filter((d3) => !existing.has(d3));
|
|
17157
17157
|
if (additions.length === 0) return;
|
|
17158
|
-
process.env.PATH = additions.join(
|
|
17158
|
+
process.env.PATH = additions.join(sep7) + sep7 + current2;
|
|
17159
17159
|
}
|
|
17160
17160
|
function runInstaller() {
|
|
17161
17161
|
const isWindows = process.platform === "win32";
|
|
@@ -19603,8 +19603,8 @@ function pickLine(obj) {
|
|
|
19603
19603
|
function toHunk(raw, groupSeverity) {
|
|
19604
19604
|
if (!raw || typeof raw !== "object") return null;
|
|
19605
19605
|
const o = raw;
|
|
19606
|
-
const
|
|
19607
|
-
if (!
|
|
19606
|
+
const path96 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
|
|
19607
|
+
if (!path96) return null;
|
|
19608
19608
|
const message = asString(
|
|
19609
19609
|
pick(o, [
|
|
19610
19610
|
"comment",
|
|
@@ -19621,7 +19621,7 @@ function toHunk(raw, groupSeverity) {
|
|
|
19621
19621
|
const severity = normSeverity(pick(o, ["severity", "level", "priority", "impact"])) ?? normSeverity(groupSeverity);
|
|
19622
19622
|
const locObj = pick(o, ["location"]) ?? o;
|
|
19623
19623
|
return {
|
|
19624
|
-
path:
|
|
19624
|
+
path: path96.trim(),
|
|
19625
19625
|
line: pickLine(o) ?? pickLine(locObj),
|
|
19626
19626
|
severity,
|
|
19627
19627
|
message: (title && message ? `${title}: ${message}` : title || message).trim() || "(no message)"
|
|
@@ -19704,10 +19704,10 @@ function parsePlain(stdout) {
|
|
|
19704
19704
|
for (const line of stdout.split(/\r?\n/)) {
|
|
19705
19705
|
const m = line.match(HUNK_LINE_RE);
|
|
19706
19706
|
if (!m) continue;
|
|
19707
|
-
const [,
|
|
19708
|
-
if (!
|
|
19707
|
+
const [, path96, lineNo, sevToken, message] = m;
|
|
19708
|
+
if (!path96 || !lineNo || !message) continue;
|
|
19709
19709
|
hunks.push({
|
|
19710
|
-
path:
|
|
19710
|
+
path: path96.trim(),
|
|
19711
19711
|
line: Number(lineNo),
|
|
19712
19712
|
severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
|
|
19713
19713
|
message: message.trim().replace(/^[*-]\s+/, "")
|
|
@@ -23164,7 +23164,8 @@ async function readPreviewConfig(cwd) {
|
|
|
23164
23164
|
async function writePreviewConfig(cwd, detection) {
|
|
23165
23165
|
const filePath = configPath(cwd);
|
|
23166
23166
|
await import_promises4.default.mkdir(import_path6.default.dirname(filePath), { recursive: true });
|
|
23167
|
-
|
|
23167
|
+
const { candidates: _candidates, ...config } = detection;
|
|
23168
|
+
await import_promises4.default.writeFile(filePath, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
23168
23169
|
}
|
|
23169
23170
|
|
|
23170
23171
|
// src/services/preview/dotenv.ts
|
|
@@ -23839,6 +23840,107 @@ function isJsInstallCommand(cmd, args2) {
|
|
|
23839
23840
|
return verb === "install" || verb === "i" || verb === "ci";
|
|
23840
23841
|
}
|
|
23841
23842
|
|
|
23843
|
+
// src/services/preview/script-candidates.ts
|
|
23844
|
+
var fs40 = __toESM(require("fs"));
|
|
23845
|
+
var path48 = __toESM(require("path"));
|
|
23846
|
+
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;
|
|
23847
|
+
var EXCLUDE_BODY_RE = /\b(run:android|run:ios|gradlew|fastlane|xcodebuild|eas build|eas submit)\b/i;
|
|
23848
|
+
var MAX_APPS = 40;
|
|
23849
|
+
var MAX_CANDIDATES = 120;
|
|
23850
|
+
function frameworkFor(pkg, body) {
|
|
23851
|
+
const deps = { ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} };
|
|
23852
|
+
const has = (d3) => d3 in deps || new RegExp(`\\b${d3}\\b`).test(body);
|
|
23853
|
+
if (has("expo")) return { framework: "Expo", port: 8081, ready_pattern: "Waiting on http|Metro waiting|Logs for your project" };
|
|
23854
|
+
if (has("next")) return { framework: "Next.js", port: 3e3, ready_pattern: "Ready in|Local:.*http" };
|
|
23855
|
+
if (has("vite")) return { framework: "Vite", port: 5173, ready_pattern: "Local:.*http" };
|
|
23856
|
+
if (has("@angular/cli") || /\bng serve\b/.test(body)) return { framework: "Angular", port: 4200, ready_pattern: "Local:.*http|compiled successfully" };
|
|
23857
|
+
if (has("react-scripts")) return { framework: "Create React App", port: 3e3, ready_pattern: "Compiled|Local:.*http" };
|
|
23858
|
+
if (has("nx") || /\bnx\b/.test(body)) return { framework: "Nx", port: 4200, ready_pattern: "Local:.*http|ready|listening" };
|
|
23859
|
+
return { framework: "Node", port: 3e3, ready_pattern: "Local:.*http|ready|listening|started" };
|
|
23860
|
+
}
|
|
23861
|
+
function readPkg(file) {
|
|
23862
|
+
try {
|
|
23863
|
+
return JSON.parse(fs40.readFileSync(file, "utf8"));
|
|
23864
|
+
} catch {
|
|
23865
|
+
return null;
|
|
23866
|
+
}
|
|
23867
|
+
}
|
|
23868
|
+
function expandGlob(root, pattern) {
|
|
23869
|
+
const clean = pattern.replace(/\/+$/, "");
|
|
23870
|
+
if (!clean.endsWith("/*")) return [clean];
|
|
23871
|
+
const base = clean.slice(0, -2);
|
|
23872
|
+
try {
|
|
23873
|
+
return fs40.readdirSync(path48.join(root, base), { withFileTypes: true }).filter((d3) => d3.isDirectory() && !d3.name.startsWith(".") && d3.name !== "node_modules").map((d3) => path48.join(base, d3.name));
|
|
23874
|
+
} catch {
|
|
23875
|
+
return [];
|
|
23876
|
+
}
|
|
23877
|
+
}
|
|
23878
|
+
function workspaceDirs(root, rootPkg) {
|
|
23879
|
+
const ws = rootPkg?.workspaces;
|
|
23880
|
+
const patterns = Array.isArray(ws) ? ws : ws?.packages ?? [];
|
|
23881
|
+
try {
|
|
23882
|
+
const pnpm = fs40.readFileSync(path48.join(root, "pnpm-workspace.yaml"), "utf8");
|
|
23883
|
+
for (const m of pnpm.matchAll(/^\s*-\s*['"]?([^'"\n]+)['"]?\s*$/gm)) patterns.push(m[1]);
|
|
23884
|
+
} catch {
|
|
23885
|
+
}
|
|
23886
|
+
if (patterns.length === 0) patterns.push("apps/*", "packages/*");
|
|
23887
|
+
const dirs = /* @__PURE__ */ new Set();
|
|
23888
|
+
for (const p2 of patterns) for (const d3 of expandGlob(root, p2)) dirs.add(d3);
|
|
23889
|
+
return [...dirs].slice(0, MAX_APPS);
|
|
23890
|
+
}
|
|
23891
|
+
function listScriptCandidates(root) {
|
|
23892
|
+
const out2 = [];
|
|
23893
|
+
const rootPkg = readPkg(path48.join(root, "package.json"));
|
|
23894
|
+
const add = (pkg, appDir) => {
|
|
23895
|
+
for (const [script, body] of Object.entries(pkg.scripts ?? {})) {
|
|
23896
|
+
if (out2.length >= MAX_CANDIDATES) return;
|
|
23897
|
+
if (EXCLUDE_RE.test(script) || EXCLUDE_BODY_RE.test(body)) continue;
|
|
23898
|
+
const fw = frameworkFor(pkg, body);
|
|
23899
|
+
out2.push({
|
|
23900
|
+
app: pkg.name ?? (appDir === "." ? path48.basename(root) : appDir),
|
|
23901
|
+
appDir,
|
|
23902
|
+
script,
|
|
23903
|
+
body,
|
|
23904
|
+
framework: fw.framework,
|
|
23905
|
+
command: "npm",
|
|
23906
|
+
args: appDir === "." ? ["run", script] : ["--prefix", appDir, "run", script],
|
|
23907
|
+
port: fw.port,
|
|
23908
|
+
ready_pattern: fw.ready_pattern
|
|
23909
|
+
});
|
|
23910
|
+
}
|
|
23911
|
+
};
|
|
23912
|
+
if (rootPkg) add(rootPkg, ".");
|
|
23913
|
+
for (const dir of workspaceDirs(root, rootPkg)) {
|
|
23914
|
+
const pkg = readPkg(path48.join(root, dir, "package.json"));
|
|
23915
|
+
if (pkg) add(pkg, dir.split(path48.sep).join("/"));
|
|
23916
|
+
}
|
|
23917
|
+
return out2;
|
|
23918
|
+
}
|
|
23919
|
+
|
|
23920
|
+
// src/services/preview/prewarm-deps.ts
|
|
23921
|
+
var inFlight = null;
|
|
23922
|
+
var PREWARM_INSTALL_TIMEOUT_MS = 5 * 6e4;
|
|
23923
|
+
function prewarmNodeDeps(cwd) {
|
|
23924
|
+
if (inFlight) return inFlight;
|
|
23925
|
+
const missing = detectMissingNodeDeps(cwd);
|
|
23926
|
+
if (!missing || missing.cmd !== "npm") return Promise.resolve();
|
|
23927
|
+
log.info("preview", `prewarm: installing deps (${missing.cmd} ${missing.args.join(" ")})`);
|
|
23928
|
+
const started = Date.now();
|
|
23929
|
+
inFlight = runSetupCommand(missing.cmd, missing.args, cwd, void 0, {
|
|
23930
|
+
timeoutMs: PREWARM_INSTALL_TIMEOUT_MS
|
|
23931
|
+
}).then((r) => {
|
|
23932
|
+
log.info("preview", `prewarm: deps ${r.status} after ${Date.now() - started}ms`);
|
|
23933
|
+
}).catch((err) => {
|
|
23934
|
+
log.info("preview", `prewarm: deps install threw (${String(err)})`);
|
|
23935
|
+
}).finally(() => {
|
|
23936
|
+
inFlight = null;
|
|
23937
|
+
});
|
|
23938
|
+
return inFlight;
|
|
23939
|
+
}
|
|
23940
|
+
function awaitPrewarmInstall() {
|
|
23941
|
+
return inFlight ?? Promise.resolve();
|
|
23942
|
+
}
|
|
23943
|
+
|
|
23842
23944
|
// src/services/preview/tunnel-bringup.ts
|
|
23843
23945
|
var TUNNEL_REGISTERED_RE = /Registered tunnel connection/i;
|
|
23844
23946
|
async function awaitTunnelRegistered(candidate, hostname3, deadlineMs) {
|
|
@@ -23975,19 +24077,19 @@ function activePreviewSessionIds() {
|
|
|
23975
24077
|
|
|
23976
24078
|
// src/services/preview/start-orchestrator.ts
|
|
23977
24079
|
var import_child_process20 = require("child_process");
|
|
23978
|
-
var
|
|
23979
|
-
var
|
|
24080
|
+
var fs43 = __toESM(require("fs"));
|
|
24081
|
+
var path51 = __toESM(require("path"));
|
|
23980
24082
|
var import_which2 = __toESM(require("which"));
|
|
23981
24083
|
|
|
23982
24084
|
// src/services/project-env/index.ts
|
|
23983
24085
|
var import_fs6 = require("fs");
|
|
23984
|
-
var
|
|
24086
|
+
var path50 = __toESM(require("path"));
|
|
23985
24087
|
|
|
23986
24088
|
// src/beads/project-key.ts
|
|
23987
24089
|
var import_child_process19 = require("child_process");
|
|
23988
24090
|
var crypto2 = __toESM(require("crypto"));
|
|
23989
|
-
var
|
|
23990
|
-
var
|
|
24091
|
+
var fs41 = __toESM(require("fs"));
|
|
24092
|
+
var path49 = __toESM(require("path"));
|
|
23991
24093
|
function normalizeOrigin(raw) {
|
|
23992
24094
|
const trimmed = raw.trim();
|
|
23993
24095
|
if (!trimmed) return null;
|
|
@@ -24013,17 +24115,17 @@ function normalizeOrigin(raw) {
|
|
|
24013
24115
|
return `${host2}/${pathPart}`;
|
|
24014
24116
|
}
|
|
24015
24117
|
function findRepoRoot(cwd) {
|
|
24016
|
-
let dir =
|
|
24118
|
+
let dir = path49.resolve(cwd);
|
|
24017
24119
|
const seen2 = /* @__PURE__ */ new Set();
|
|
24018
24120
|
for (let i = 0; i < 256; i++) {
|
|
24019
24121
|
if (seen2.has(dir)) return null;
|
|
24020
24122
|
seen2.add(dir);
|
|
24021
24123
|
try {
|
|
24022
|
-
const stat3 =
|
|
24124
|
+
const stat3 = fs41.statSync(path49.join(dir, ".git"), { throwIfNoEntry: false });
|
|
24023
24125
|
if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
|
|
24024
24126
|
} catch {
|
|
24025
24127
|
}
|
|
24026
|
-
const parent =
|
|
24128
|
+
const parent = path49.dirname(dir);
|
|
24027
24129
|
if (parent === dir) return null;
|
|
24028
24130
|
dir = parent;
|
|
24029
24131
|
}
|
|
@@ -24034,7 +24136,7 @@ var _execSeam3 = {
|
|
|
24034
24136
|
const out2 = (0, import_child_process19.execFileSync)(file, args2, opts);
|
|
24035
24137
|
return typeof out2 === "string" ? out2 : out2.toString("utf8");
|
|
24036
24138
|
},
|
|
24037
|
-
realpath: (p2) =>
|
|
24139
|
+
realpath: (p2) => fs41.realpathSync(p2)
|
|
24038
24140
|
};
|
|
24039
24141
|
function readOrigin(cwd) {
|
|
24040
24142
|
try {
|
|
@@ -24063,7 +24165,7 @@ function deriveProjectIdentity(cwd = process.cwd()) {
|
|
|
24063
24165
|
} catch {
|
|
24064
24166
|
}
|
|
24065
24167
|
const hash = crypto2.createHash("sha256").update(real).digest("hex");
|
|
24066
|
-
return { projectKey: `path:${hash}`, projectLabel:
|
|
24168
|
+
return { projectKey: `path:${hash}`, projectLabel: path49.basename(real) || "project" };
|
|
24067
24169
|
}
|
|
24068
24170
|
|
|
24069
24171
|
// src/services/project-env/index.ts
|
|
@@ -24076,7 +24178,7 @@ async function readIfExists(p2) {
|
|
|
24076
24178
|
}
|
|
24077
24179
|
async function syncProjectEnvUp(cwd, ctx) {
|
|
24078
24180
|
if (!ctx.pluginAuthToken) return;
|
|
24079
|
-
const content = await readIfExists(
|
|
24181
|
+
const content = await readIfExists(path50.join(cwd, ".env"));
|
|
24080
24182
|
if (content == null) return;
|
|
24081
24183
|
try {
|
|
24082
24184
|
const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
|
|
@@ -24098,7 +24200,7 @@ async function syncProjectEnvUp(cwd, ctx) {
|
|
|
24098
24200
|
}
|
|
24099
24201
|
async function restoreProjectEnvIfMissing(cwd, ctx) {
|
|
24100
24202
|
if (!ctx.pluginAuthToken) return false;
|
|
24101
|
-
const envPath =
|
|
24203
|
+
const envPath = path50.join(cwd, ".env");
|
|
24102
24204
|
if (await readIfExists(envPath) != null) return false;
|
|
24103
24205
|
try {
|
|
24104
24206
|
const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
|
|
@@ -24109,7 +24211,7 @@ async function restoreProjectEnvIfMissing(cwd, ctx) {
|
|
|
24109
24211
|
projectKey
|
|
24110
24212
|
});
|
|
24111
24213
|
if (!stored) return false;
|
|
24112
|
-
const tmp =
|
|
24214
|
+
const tmp = path50.join(cwd, ".env.codeam-restore.tmp");
|
|
24113
24215
|
await import_fs6.promises.writeFile(tmp, stored.content, { encoding: "utf8", mode: 384 });
|
|
24114
24216
|
await import_fs6.promises.rename(tmp, envPath);
|
|
24115
24217
|
log.info("project-env", `restored .env (${stored.keyCount} vars) for ${projectLabel}`);
|
|
@@ -24630,6 +24732,12 @@ var TUNNEL_REGISTER_DEADLINE_MS = 45e3;
|
|
|
24630
24732
|
function compileReadyPattern(pattern) {
|
|
24631
24733
|
return new RegExp(pattern, "i");
|
|
24632
24734
|
}
|
|
24735
|
+
var DEV_SERVER_READY_TIMEOUT_MS = 12e4;
|
|
24736
|
+
var MONOREPO_READY_TIMEOUT_MS = 36e4;
|
|
24737
|
+
function devServerReadyTimeoutMs(detection) {
|
|
24738
|
+
const text = [detection.framework, detection.command ?? "", ...detection.args ?? []].join(" ");
|
|
24739
|
+
return /\b(nx|turbo|turborepo|lerna)\b/i.test(text) ? MONOREPO_READY_TIMEOUT_MS : DEV_SERVER_READY_TIMEOUT_MS;
|
|
24740
|
+
}
|
|
24633
24741
|
async function waitForDevServerReady(devServer, readyRe, opts = {
|
|
24634
24742
|
timeoutMs: 12e4
|
|
24635
24743
|
}) {
|
|
@@ -24689,8 +24797,8 @@ function normalizeDetectionForSpawn(detection, cwd) {
|
|
|
24689
24797
|
if (args2.length === 0) return detection;
|
|
24690
24798
|
const binName = args2[0];
|
|
24691
24799
|
if (binName.startsWith("-")) return detection;
|
|
24692
|
-
const binPath =
|
|
24693
|
-
if (!
|
|
24800
|
+
const binPath = path51.join(cwd, "node_modules", ".bin", binName);
|
|
24801
|
+
if (!fs43.existsSync(binPath)) return detection;
|
|
24694
24802
|
return {
|
|
24695
24803
|
...detection,
|
|
24696
24804
|
command: binPath,
|
|
@@ -24784,6 +24892,7 @@ async function provisionDeps(ctx) {
|
|
|
24784
24892
|
pluginAuthToken: ctx.projectEnvAuth.pluginAuthToken
|
|
24785
24893
|
});
|
|
24786
24894
|
}
|
|
24895
|
+
await awaitPrewarmInstall();
|
|
24787
24896
|
const missingDeps = detectMissingNodeDeps(cwd);
|
|
24788
24897
|
let preflightRan = false;
|
|
24789
24898
|
if (missingDeps) {
|
|
@@ -24963,7 +25072,7 @@ async function startDevServer(ctx, extraEnv = {}) {
|
|
|
24963
25072
|
const isNextJs = /next/i.test(detection.framework);
|
|
24964
25073
|
const portProbe = isExpo ? () => waitForExpoManifest(detection.port, { timeoutMs: 1e3, intervalMs: 250 }) : isNextJs ? () => waitForPortListening(detection.port, { timeoutMs: 1e3, intervalMs: 250 }) : void 0;
|
|
24965
25074
|
const outcome = await waitForDevServerReady(devServer, readyRe, {
|
|
24966
|
-
timeoutMs:
|
|
25075
|
+
timeoutMs: devServerReadyTimeoutMs(detection),
|
|
24967
25076
|
onChunk: (s) => {
|
|
24968
25077
|
outputTail = (outputTail + s).slice(-16e3);
|
|
24969
25078
|
},
|
|
@@ -25089,9 +25198,9 @@ async function bringUpPublicUrl(ctx, tunnelPort) {
|
|
|
25089
25198
|
|
|
25090
25199
|
// src/beads/bd-adapter.ts
|
|
25091
25200
|
var import_child_process21 = require("child_process");
|
|
25092
|
-
var
|
|
25201
|
+
var fs44 = __toESM(require("fs"));
|
|
25093
25202
|
var os31 = __toESM(require("os"));
|
|
25094
|
-
var
|
|
25203
|
+
var path52 = __toESM(require("path"));
|
|
25095
25204
|
var BD_PACKAGE = "@beads/bd";
|
|
25096
25205
|
function resolveBundledBdBinary() {
|
|
25097
25206
|
return _resolveSeam.resolveBundled();
|
|
@@ -25103,11 +25212,11 @@ function _defaultResolveBundled() {
|
|
|
25103
25212
|
} catch {
|
|
25104
25213
|
return null;
|
|
25105
25214
|
}
|
|
25106
|
-
const binDir =
|
|
25215
|
+
const binDir = path52.join(path52.dirname(pkgJsonPath), "bin");
|
|
25107
25216
|
const binaryName = process.platform === "win32" ? "bd.exe" : "bd";
|
|
25108
|
-
const binaryPath =
|
|
25217
|
+
const binaryPath = path52.join(binDir, binaryName);
|
|
25109
25218
|
try {
|
|
25110
|
-
|
|
25219
|
+
fs44.accessSync(binaryPath, fs44.constants.F_OK);
|
|
25111
25220
|
return binaryPath;
|
|
25112
25221
|
} catch {
|
|
25113
25222
|
return null;
|
|
@@ -25117,13 +25226,13 @@ function resolveBdOnPath() {
|
|
|
25117
25226
|
return _resolveSeam.resolveOnPath();
|
|
25118
25227
|
}
|
|
25119
25228
|
function _defaultResolveOnPath() {
|
|
25120
|
-
const dirs = (process.env.PATH ?? "").split(
|
|
25229
|
+
const dirs = (process.env.PATH ?? "").split(path52.delimiter).filter(Boolean);
|
|
25121
25230
|
const candidates = process.platform === "win32" ? ["bd.exe", "bd.cmd", "bd"] : ["bd"];
|
|
25122
25231
|
for (const dir of dirs) {
|
|
25123
25232
|
for (const candidate of candidates) {
|
|
25124
|
-
const full =
|
|
25233
|
+
const full = path52.join(dir, candidate);
|
|
25125
25234
|
try {
|
|
25126
|
-
|
|
25235
|
+
fs44.accessSync(full, fs44.constants.F_OK);
|
|
25127
25236
|
return full;
|
|
25128
25237
|
} catch {
|
|
25129
25238
|
}
|
|
@@ -25300,9 +25409,9 @@ function coerceIssue(row, projectKey) {
|
|
|
25300
25409
|
|
|
25301
25410
|
// src/beads/provisioner.ts
|
|
25302
25411
|
var import_child_process24 = require("child_process");
|
|
25303
|
-
var
|
|
25412
|
+
var fs46 = __toESM(require("fs"));
|
|
25304
25413
|
var os33 = __toESM(require("os"));
|
|
25305
|
-
var
|
|
25414
|
+
var path54 = __toESM(require("path"));
|
|
25306
25415
|
|
|
25307
25416
|
// src/beads/install-bd.ts
|
|
25308
25417
|
var import_child_process22 = require("child_process");
|
|
@@ -25367,9 +25476,9 @@ async function installBd(platform3 = process.platform) {
|
|
|
25367
25476
|
|
|
25368
25477
|
// src/beads/install-dolt.ts
|
|
25369
25478
|
var import_child_process23 = require("child_process");
|
|
25370
|
-
var
|
|
25479
|
+
var fs45 = __toESM(require("fs"));
|
|
25371
25480
|
var os32 = __toESM(require("os"));
|
|
25372
|
-
var
|
|
25481
|
+
var path53 = __toESM(require("path"));
|
|
25373
25482
|
var DOLT_INSTALL_SH_URL = "https://github.com/dolthub/dolt/releases/latest/download/install.sh";
|
|
25374
25483
|
var DOLT_MSI_URL = "https://github.com/dolthub/dolt/releases/latest/download/dolt-windows-amd64.msi";
|
|
25375
25484
|
function resolveDoltInstallStrategy(platform3) {
|
|
@@ -25465,7 +25574,7 @@ var _doltPathSeam = {
|
|
|
25465
25574
|
},
|
|
25466
25575
|
exists: (p2) => {
|
|
25467
25576
|
try {
|
|
25468
|
-
|
|
25577
|
+
fs45.accessSync(p2, fs45.constants.F_OK);
|
|
25469
25578
|
return true;
|
|
25470
25579
|
} catch {
|
|
25471
25580
|
return false;
|
|
@@ -25476,7 +25585,7 @@ function doltBinaryNames(platform3) {
|
|
|
25476
25585
|
return platform3 === "win32" ? ["dolt.exe", "dolt.cmd", "dolt"] : ["dolt"];
|
|
25477
25586
|
}
|
|
25478
25587
|
function knownDoltDirs(platform3) {
|
|
25479
|
-
const P3 = platform3 === "win32" ?
|
|
25588
|
+
const P3 = platform3 === "win32" ? path53.win32 : path53.posix;
|
|
25480
25589
|
const home = _doltPathSeam.homedir();
|
|
25481
25590
|
if (platform3 === "win32") {
|
|
25482
25591
|
return [
|
|
@@ -25492,7 +25601,7 @@ function knownDoltDirs(platform3) {
|
|
|
25492
25601
|
].filter(Boolean);
|
|
25493
25602
|
}
|
|
25494
25603
|
function ensureDoltResolvable(platform3 = process.platform) {
|
|
25495
|
-
const P3 = platform3 === "win32" ?
|
|
25604
|
+
const P3 = platform3 === "win32" ? path53.win32 : path53.posix;
|
|
25496
25605
|
const delim = platform3 === "win32" ? ";" : ":";
|
|
25497
25606
|
const names = doltBinaryNames(platform3);
|
|
25498
25607
|
const pathDirs = _doltPathSeam.getPath().split(delim).filter(Boolean);
|
|
@@ -25689,14 +25798,14 @@ var _linkSeam = {
|
|
|
25689
25798
|
homedir: () => os33.homedir(),
|
|
25690
25799
|
isWritableDir: (dir) => {
|
|
25691
25800
|
try {
|
|
25692
|
-
|
|
25801
|
+
fs46.accessSync(dir, fs46.constants.W_OK);
|
|
25693
25802
|
return true;
|
|
25694
25803
|
} catch {
|
|
25695
25804
|
return false;
|
|
25696
25805
|
}
|
|
25697
25806
|
},
|
|
25698
25807
|
ensureDir: (dir) => {
|
|
25699
|
-
|
|
25808
|
+
fs46.mkdirSync(dir, { recursive: true });
|
|
25700
25809
|
},
|
|
25701
25810
|
/**
|
|
25702
25811
|
* A directory to symlink `bd` into so the AGENT's shell + Claude Code's
|
|
@@ -25717,9 +25826,9 @@ var _linkSeam = {
|
|
|
25717
25826
|
* which `linkBdOntoPath` creates if missing.
|
|
25718
25827
|
*/
|
|
25719
25828
|
cliBinDir: () => {
|
|
25720
|
-
const pathDirs = (process.env.PATH ?? "").split(
|
|
25829
|
+
const pathDirs = (process.env.PATH ?? "").split(path54.delimiter).filter(Boolean);
|
|
25721
25830
|
const home = _linkSeam.homedir();
|
|
25722
|
-
const localBin = home ?
|
|
25831
|
+
const localBin = home ? path54.join(home, ".local", "bin") : null;
|
|
25723
25832
|
if (localBin) {
|
|
25724
25833
|
try {
|
|
25725
25834
|
_linkSeam.ensureDir(localBin);
|
|
@@ -25729,16 +25838,16 @@ var _linkSeam = {
|
|
|
25729
25838
|
const candidates = [];
|
|
25730
25839
|
if (localBin) candidates.push(localBin);
|
|
25731
25840
|
try {
|
|
25732
|
-
candidates.push(
|
|
25841
|
+
candidates.push(path54.dirname(process.execPath));
|
|
25733
25842
|
} catch {
|
|
25734
25843
|
}
|
|
25735
25844
|
candidates.push("/usr/local/bin");
|
|
25736
25845
|
const entry = process.argv[1];
|
|
25737
25846
|
if (entry) {
|
|
25738
25847
|
try {
|
|
25739
|
-
candidates.push(
|
|
25848
|
+
candidates.push(path54.dirname(fs46.realpathSync(entry)));
|
|
25740
25849
|
} catch {
|
|
25741
|
-
candidates.push(
|
|
25850
|
+
candidates.push(path54.dirname(entry));
|
|
25742
25851
|
}
|
|
25743
25852
|
}
|
|
25744
25853
|
const onPathWritable = candidates.find(
|
|
@@ -25750,20 +25859,20 @@ var _linkSeam = {
|
|
|
25750
25859
|
/** Current symlink target at `linkPath`, or null when absent / not a link. */
|
|
25751
25860
|
readlink: (linkPath) => {
|
|
25752
25861
|
try {
|
|
25753
|
-
return
|
|
25862
|
+
return fs46.readlinkSync(linkPath);
|
|
25754
25863
|
} catch {
|
|
25755
25864
|
return null;
|
|
25756
25865
|
}
|
|
25757
25866
|
},
|
|
25758
|
-
unlink: (linkPath) =>
|
|
25759
|
-
symlink: (target, linkPath) =>
|
|
25867
|
+
unlink: (linkPath) => fs46.unlinkSync(linkPath),
|
|
25868
|
+
symlink: (target, linkPath) => fs46.symlinkSync(target, linkPath)
|
|
25760
25869
|
};
|
|
25761
25870
|
function linkBdOntoPath(binaryPath) {
|
|
25762
25871
|
if (_linkSeam.platform() === "win32") return;
|
|
25763
25872
|
const binDir = _linkSeam.cliBinDir();
|
|
25764
25873
|
if (!binDir) return;
|
|
25765
25874
|
_linkSeam.ensureDir(binDir);
|
|
25766
|
-
const linkPath =
|
|
25875
|
+
const linkPath = path54.join(binDir, "bd");
|
|
25767
25876
|
if (linkPath === binaryPath) return;
|
|
25768
25877
|
const current2 = _linkSeam.readlink(linkPath);
|
|
25769
25878
|
if (current2 === binaryPath) return;
|
|
@@ -25968,7 +26077,7 @@ function dedupeRecipes(agents) {
|
|
|
25968
26077
|
|
|
25969
26078
|
// src/beads/watcher.ts
|
|
25970
26079
|
var crypto4 = __toESM(require("crypto"));
|
|
25971
|
-
var
|
|
26080
|
+
var path55 = __toESM(require("path"));
|
|
25972
26081
|
var API_BASE5 = resolveApiBaseUrl();
|
|
25973
26082
|
var DEBOUNCE_MS2 = 400;
|
|
25974
26083
|
var ZERO_SUMMARY = {
|
|
@@ -25992,7 +26101,7 @@ var BeadsWatcher = class {
|
|
|
25992
26101
|
constructor(opts) {
|
|
25993
26102
|
this.opts = opts;
|
|
25994
26103
|
this.bd = opts.adapter ?? new BdAdapter({ cwd: opts.cwd, beadsDir: opts.beadsDir });
|
|
25995
|
-
this.feedPath = opts.feedPath ??
|
|
26104
|
+
this.feedPath = opts.feedPath ?? path55.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
|
|
25996
26105
|
this.apiBase = opts.apiBaseUrl ?? API_BASE5;
|
|
25997
26106
|
}
|
|
25998
26107
|
opts;
|
|
@@ -26567,8 +26676,8 @@ function cleanupAttachmentTempFiles() {
|
|
|
26567
26676
|
function saveFilesTemp(files) {
|
|
26568
26677
|
return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
|
|
26569
26678
|
const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
|
|
26570
|
-
const tmpPath =
|
|
26571
|
-
|
|
26679
|
+
const tmpPath = path59.join(os39.tmpdir(), `codeam-${(0, import_crypto2.randomUUID)()}-${safeName}`);
|
|
26680
|
+
fs51.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
|
|
26572
26681
|
pendingAttachmentFiles.add(tmpPath);
|
|
26573
26682
|
return tmpPath;
|
|
26574
26683
|
});
|
|
@@ -26803,10 +26912,10 @@ var listFiles = async (ctx, cmd, parsed) => {
|
|
|
26803
26912
|
await ctx.relay.sendResult(cmd.id, "completed", result);
|
|
26804
26913
|
};
|
|
26805
26914
|
var envReadH = async (ctx, cmd) => {
|
|
26806
|
-
const envPath =
|
|
26915
|
+
const envPath = path59.join(process.cwd(), ".env");
|
|
26807
26916
|
await restoreProjectEnvIfMissing(process.cwd(), ctx);
|
|
26808
26917
|
try {
|
|
26809
|
-
const raw = await
|
|
26918
|
+
const raw = await fs51.promises.readFile(envPath, "utf8");
|
|
26810
26919
|
await ctx.relay.sendResult(cmd.id, "completed", {
|
|
26811
26920
|
exists: true,
|
|
26812
26921
|
vars: parseDotenv(raw)
|
|
@@ -26835,7 +26944,7 @@ var envParseH = async (ctx, cmd, parsed) => {
|
|
|
26835
26944
|
const existing = /* @__PURE__ */ new Map();
|
|
26836
26945
|
if (!replace) {
|
|
26837
26946
|
try {
|
|
26838
|
-
const raw = await
|
|
26947
|
+
const raw = await fs51.promises.readFile(path59.join(process.cwd(), ".env"), "utf8");
|
|
26839
26948
|
for (const v of parseDotenv(raw)) existing.set(v.key, v.value);
|
|
26840
26949
|
} catch {
|
|
26841
26950
|
}
|
|
@@ -26875,15 +26984,15 @@ var envWriteH = async (ctx, cmd, parsed) => {
|
|
|
26875
26984
|
}
|
|
26876
26985
|
seen2.add(v.key);
|
|
26877
26986
|
}
|
|
26878
|
-
const envPath =
|
|
26879
|
-
const tmpPath =
|
|
26987
|
+
const envPath = path59.join(process.cwd(), ".env");
|
|
26988
|
+
const tmpPath = path59.join(process.cwd(), ".env.codeam.tmp");
|
|
26880
26989
|
try {
|
|
26881
|
-
await
|
|
26882
|
-
await
|
|
26990
|
+
await fs51.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
|
|
26991
|
+
await fs51.promises.rename(tmpPath, envPath);
|
|
26883
26992
|
await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
|
|
26884
26993
|
void syncProjectEnvUp(process.cwd(), ctx);
|
|
26885
26994
|
} catch (err) {
|
|
26886
|
-
await
|
|
26995
|
+
await fs51.promises.rm(tmpPath, { force: true }).catch(() => void 0);
|
|
26887
26996
|
await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
|
|
26888
26997
|
}
|
|
26889
26998
|
};
|
|
@@ -27215,9 +27324,9 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
|
|
|
27215
27324
|
function buildNpmInstallInvocation(opts) {
|
|
27216
27325
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
27217
27326
|
const execPath = opts?.execPath ?? process.execPath;
|
|
27218
|
-
const exists2 = opts?.existsSync ??
|
|
27327
|
+
const exists2 = opts?.existsSync ?? fs51.existsSync;
|
|
27219
27328
|
const platform3 = opts?.platform ?? process.platform;
|
|
27220
|
-
const p2 = platform3 === "win32" ?
|
|
27329
|
+
const p2 = platform3 === "win32" ? path59.win32 : path59.posix;
|
|
27221
27330
|
const normalized = entryScript.split(/[\\/]/).join("/");
|
|
27222
27331
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
27223
27332
|
const markerIdx = normalized.indexOf(marker);
|
|
@@ -27239,7 +27348,7 @@ function isPermissionError(stderr) {
|
|
|
27239
27348
|
function resolveGlobalNodeModulesDir(opts) {
|
|
27240
27349
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
27241
27350
|
const platform3 = opts?.platform ?? process.platform;
|
|
27242
|
-
const p2 = platform3 === "win32" ?
|
|
27351
|
+
const p2 = platform3 === "win32" ? path59.win32 : path59.posix;
|
|
27243
27352
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
27244
27353
|
const markerIdx = entryScript.split(/[\\/]/).join("/").indexOf(marker);
|
|
27245
27354
|
if (markerIdx <= 0) return null;
|
|
@@ -27249,19 +27358,19 @@ function resolveGlobalNodeModulesDir(opts) {
|
|
|
27249
27358
|
var STALE_STAGING_AGE_MS = CLI_UPDATE_INSTALL_TIMEOUT_MS;
|
|
27250
27359
|
function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
27251
27360
|
if (!nodeModulesDir) return 0;
|
|
27252
|
-
const
|
|
27253
|
-
const statSync15 = deps?.statSync ??
|
|
27254
|
-
const rmSync9 = deps?.rmSync ??
|
|
27361
|
+
const readdirSync13 = deps?.readdirSync ?? fs51.readdirSync;
|
|
27362
|
+
const statSync15 = deps?.statSync ?? fs51.statSync;
|
|
27363
|
+
const rmSync9 = deps?.rmSync ?? fs51.rmSync;
|
|
27255
27364
|
let removed = 0;
|
|
27256
27365
|
let entries;
|
|
27257
27366
|
try {
|
|
27258
|
-
entries =
|
|
27367
|
+
entries = readdirSync13(nodeModulesDir);
|
|
27259
27368
|
} catch {
|
|
27260
27369
|
return 0;
|
|
27261
27370
|
}
|
|
27262
27371
|
for (const name of entries) {
|
|
27263
27372
|
if (!/^\.codeam-cli-/.test(name)) continue;
|
|
27264
|
-
const full =
|
|
27373
|
+
const full = path59.join(nodeModulesDir, name);
|
|
27265
27374
|
try {
|
|
27266
27375
|
const st3 = statSync15(full);
|
|
27267
27376
|
if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
|
|
@@ -27680,7 +27789,7 @@ var requestPreviewDetectH = (ctx) => {
|
|
|
27680
27789
|
pluginId: ctx.pluginId,
|
|
27681
27790
|
pluginAuthToken,
|
|
27682
27791
|
type: USER_EVENTS.PREVIEW_DETECTION_READY,
|
|
27683
|
-
payload: { detection: fromFile }
|
|
27792
|
+
payload: { detection: withScriptCandidates(fromFile) }
|
|
27684
27793
|
});
|
|
27685
27794
|
return;
|
|
27686
27795
|
}
|
|
@@ -27754,10 +27863,19 @@ ${failure?.rawExcerpt ?? ""}`
|
|
|
27754
27863
|
pluginId: ctx.pluginId,
|
|
27755
27864
|
pluginAuthToken,
|
|
27756
27865
|
type: USER_EVENTS.PREVIEW_DETECTION_READY,
|
|
27757
|
-
payload: { detection }
|
|
27866
|
+
payload: { detection: withScriptCandidates(detection) }
|
|
27758
27867
|
});
|
|
27759
27868
|
})();
|
|
27760
27869
|
};
|
|
27870
|
+
function withScriptCandidates(detection) {
|
|
27871
|
+
try {
|
|
27872
|
+
const candidates = listScriptCandidates(process.cwd());
|
|
27873
|
+
return candidates.length > 0 ? { ...detection, candidates } : detection;
|
|
27874
|
+
} catch (err) {
|
|
27875
|
+
log.info("preview", `detect: listing script candidates failed (non-fatal): ${String(err)}`);
|
|
27876
|
+
return detection;
|
|
27877
|
+
}
|
|
27878
|
+
}
|
|
27761
27879
|
var previewPrewarmStarted = false;
|
|
27762
27880
|
function makePreviewReaffirm(args2) {
|
|
27763
27881
|
const token = args2.pluginAuthToken;
|
|
@@ -27787,6 +27905,7 @@ function makePreviewReaffirm(args2) {
|
|
|
27787
27905
|
function prewarmPreviewDetection(runtime) {
|
|
27788
27906
|
if (previewPrewarmStarted) return;
|
|
27789
27907
|
previewPrewarmStarted = true;
|
|
27908
|
+
void prewarmNodeDeps(process.cwd());
|
|
27790
27909
|
if (typeof runtime.generateOneShot !== "function") return;
|
|
27791
27910
|
const generateOneShot = runtime.generateOneShot.bind(runtime);
|
|
27792
27911
|
void (async () => {
|
|
@@ -28283,11 +28402,11 @@ function resolveTokenValue(args2) {
|
|
|
28283
28402
|
}
|
|
28284
28403
|
const fileFlag = args2.find((a) => a.startsWith("--token-file="));
|
|
28285
28404
|
if (fileFlag) {
|
|
28286
|
-
const
|
|
28405
|
+
const path96 = fileFlag.slice("--token-file=".length);
|
|
28287
28406
|
try {
|
|
28288
|
-
const content =
|
|
28289
|
-
if (content.length === 0) fail(`--token-file ${
|
|
28290
|
-
rmIfExistsQuiet(
|
|
28407
|
+
const content = fs52.readFileSync(path96, "utf8").trim();
|
|
28408
|
+
if (content.length === 0) fail(`--token-file ${path96} is empty`);
|
|
28409
|
+
rmIfExistsQuiet(path96);
|
|
28291
28410
|
return content;
|
|
28292
28411
|
} catch (err) {
|
|
28293
28412
|
fail(`Could not read --token-file: ${err.message}`);
|
|
@@ -28379,12 +28498,12 @@ async function claim(token, pluginId, pluginSecretHash) {
|
|
|
28379
28498
|
}
|
|
28380
28499
|
}
|
|
28381
28500
|
function pairAutoLockPath() {
|
|
28382
|
-
return
|
|
28501
|
+
return path60.join(os40.homedir(), ".codeam", "pair-auto.lock");
|
|
28383
28502
|
}
|
|
28384
28503
|
var procRoot = "/proc";
|
|
28385
28504
|
function readProcFile(rel) {
|
|
28386
28505
|
try {
|
|
28387
|
-
return
|
|
28506
|
+
return fs52.readFileSync(path60.join(procRoot, rel), "utf8");
|
|
28388
28507
|
} catch {
|
|
28389
28508
|
return void 0;
|
|
28390
28509
|
}
|
|
@@ -28405,7 +28524,7 @@ function currentBootId() {
|
|
|
28405
28524
|
function readLockRecord(lockPath) {
|
|
28406
28525
|
let raw;
|
|
28407
28526
|
try {
|
|
28408
|
-
raw =
|
|
28527
|
+
raw = fs52.readFileSync(lockPath, "utf8");
|
|
28409
28528
|
} catch {
|
|
28410
28529
|
return void 0;
|
|
28411
28530
|
}
|
|
@@ -28454,24 +28573,24 @@ function isLiveLockHolder(rec) {
|
|
|
28454
28573
|
}
|
|
28455
28574
|
function releaseOwnLock(lockPath) {
|
|
28456
28575
|
try {
|
|
28457
|
-
if (readLockRecord(lockPath)?.pid === process.pid)
|
|
28576
|
+
if (readLockRecord(lockPath)?.pid === process.pid) fs52.unlinkSync(lockPath);
|
|
28458
28577
|
} catch {
|
|
28459
28578
|
}
|
|
28460
28579
|
}
|
|
28461
28580
|
function daemonLockPath(sessionId) {
|
|
28462
28581
|
const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
28463
|
-
return
|
|
28582
|
+
return path60.join(os40.homedir(), ".codeam", `daemon-${safe}.lock`);
|
|
28464
28583
|
}
|
|
28465
28584
|
function acquireDaemonLock(sessionId) {
|
|
28466
28585
|
const lockPath = daemonLockPath(sessionId);
|
|
28467
28586
|
try {
|
|
28468
|
-
|
|
28587
|
+
fs52.mkdirSync(path60.dirname(lockPath), { recursive: true });
|
|
28469
28588
|
try {
|
|
28470
|
-
|
|
28589
|
+
fs52.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
28471
28590
|
} catch (e) {
|
|
28472
28591
|
if (e.code !== "EEXIST") throw e;
|
|
28473
28592
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
28474
|
-
|
|
28593
|
+
fs52.writeFileSync(lockPath, ownLockBody());
|
|
28475
28594
|
}
|
|
28476
28595
|
const release3 = () => releaseOwnLock(lockPath);
|
|
28477
28596
|
process.once("exit", release3);
|
|
@@ -28491,13 +28610,13 @@ function acquireDaemonLock(sessionId) {
|
|
|
28491
28610
|
function acquireSingletonLock() {
|
|
28492
28611
|
const lockPath = pairAutoLockPath();
|
|
28493
28612
|
try {
|
|
28494
|
-
|
|
28613
|
+
fs52.mkdirSync(path60.dirname(lockPath), { recursive: true });
|
|
28495
28614
|
try {
|
|
28496
|
-
|
|
28615
|
+
fs52.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
28497
28616
|
} catch (e) {
|
|
28498
28617
|
if (e.code !== "EEXIST") throw e;
|
|
28499
28618
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
28500
|
-
|
|
28619
|
+
fs52.writeFileSync(lockPath, ownLockBody());
|
|
28501
28620
|
}
|
|
28502
28621
|
process.once("exit", () => releaseOwnLock(lockPath));
|
|
28503
28622
|
return true;
|
|
@@ -28914,7 +29033,7 @@ var AgentService = class _AgentService {
|
|
|
28914
29033
|
};
|
|
28915
29034
|
|
|
28916
29035
|
// src/agents/acp/adapters.ts
|
|
28917
|
-
var
|
|
29036
|
+
var path61 = __toESM(require("path"));
|
|
28918
29037
|
|
|
28919
29038
|
// src/agents/kimi/installer.ts
|
|
28920
29039
|
var import_node_child_process19 = require("child_process");
|
|
@@ -29034,13 +29153,13 @@ function resolveBin(pkgName, binName) {
|
|
|
29034
29153
|
try {
|
|
29035
29154
|
const manifestPath = require_.resolve(`${pkgName}/package.json`);
|
|
29036
29155
|
const manifest = require_(`${pkgName}/package.json`);
|
|
29037
|
-
const pkgDir =
|
|
29156
|
+
const pkgDir = path61.dirname(manifestPath);
|
|
29038
29157
|
const bin = manifest.bin;
|
|
29039
29158
|
if (!bin) return null;
|
|
29040
|
-
if (typeof bin === "string") return
|
|
29159
|
+
if (typeof bin === "string") return path61.resolve(pkgDir, bin);
|
|
29041
29160
|
const target = binName ?? Object.keys(bin)[0];
|
|
29042
29161
|
if (!target || !bin[target]) return null;
|
|
29043
|
-
return
|
|
29162
|
+
return path61.resolve(pkgDir, bin[target]);
|
|
29044
29163
|
} catch {
|
|
29045
29164
|
return null;
|
|
29046
29165
|
}
|
|
@@ -29221,29 +29340,29 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
|
|
|
29221
29340
|
|
|
29222
29341
|
// src/agents/acp/runner.ts
|
|
29223
29342
|
var import_node_crypto10 = require("crypto");
|
|
29224
|
-
var
|
|
29343
|
+
var fs69 = __toESM(require("fs"));
|
|
29225
29344
|
var os53 = __toESM(require("os"));
|
|
29226
|
-
var
|
|
29345
|
+
var path80 = __toESM(require("path"));
|
|
29227
29346
|
|
|
29228
29347
|
// src/lib/provider-routing.ts
|
|
29229
|
-
var
|
|
29348
|
+
var fs54 = __toESM(require("fs"));
|
|
29230
29349
|
var os42 = __toESM(require("os"));
|
|
29231
|
-
var
|
|
29350
|
+
var path63 = __toESM(require("path"));
|
|
29232
29351
|
|
|
29233
29352
|
// src/commands/host/house-proxy-config.ts
|
|
29234
|
-
var
|
|
29353
|
+
var fs53 = __toESM(require("fs"));
|
|
29235
29354
|
var os41 = __toESM(require("os"));
|
|
29236
|
-
var
|
|
29355
|
+
var path62 = __toESM(require("path"));
|
|
29237
29356
|
function houseProxyConfigPath() {
|
|
29238
|
-
return
|
|
29357
|
+
return path62.join(os41.homedir(), ".codeam", "house-proxy.json");
|
|
29239
29358
|
}
|
|
29240
29359
|
function persistHouseProxyConfig(config) {
|
|
29241
29360
|
try {
|
|
29242
29361
|
const file = houseProxyConfigPath();
|
|
29243
|
-
|
|
29362
|
+
fs53.mkdirSync(path62.dirname(file), { recursive: true, mode: 448 });
|
|
29244
29363
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
29245
|
-
|
|
29246
|
-
|
|
29364
|
+
fs53.writeFileSync(tmp, JSON.stringify(config, null, 2), { encoding: "utf8", mode: 384 });
|
|
29365
|
+
fs53.renameSync(tmp, file);
|
|
29247
29366
|
restrictToOwner(file);
|
|
29248
29367
|
} catch (err) {
|
|
29249
29368
|
log.warn(
|
|
@@ -29254,13 +29373,13 @@ function persistHouseProxyConfig(config) {
|
|
|
29254
29373
|
}
|
|
29255
29374
|
function clearHouseProxyConfig() {
|
|
29256
29375
|
try {
|
|
29257
|
-
|
|
29376
|
+
fs53.rmSync(houseProxyConfigPath(), { force: true });
|
|
29258
29377
|
} catch {
|
|
29259
29378
|
}
|
|
29260
29379
|
}
|
|
29261
29380
|
function readHouseProxyChildEnv() {
|
|
29262
29381
|
try {
|
|
29263
|
-
const raw =
|
|
29382
|
+
const raw = fs53.readFileSync(houseProxyConfigPath(), "utf8");
|
|
29264
29383
|
const parsed = JSON.parse(raw);
|
|
29265
29384
|
if (typeof parsed !== "object" || parsed === null) return {};
|
|
29266
29385
|
const o = parsed;
|
|
@@ -29387,14 +29506,14 @@ function redactUrlToOrigin(raw) {
|
|
|
29387
29506
|
}
|
|
29388
29507
|
function readOpencodeProviderOrigins(opts = {}) {
|
|
29389
29508
|
const home = opts.homeDir ?? os42.homedir();
|
|
29390
|
-
const readFile7 = opts.readFile ?? ((f) =>
|
|
29509
|
+
const readFile7 = opts.readFile ?? ((f) => fs54.readFileSync(f, "utf8"));
|
|
29391
29510
|
const candidates = [];
|
|
29392
29511
|
if (opts.cwd) {
|
|
29393
|
-
candidates.push(
|
|
29512
|
+
candidates.push(path63.join(opts.cwd, "opencode.json"), path63.join(opts.cwd, "opencode.jsonc"));
|
|
29394
29513
|
}
|
|
29395
29514
|
candidates.push(
|
|
29396
|
-
|
|
29397
|
-
|
|
29515
|
+
path63.join(home, ".config", "opencode", "opencode.json"),
|
|
29516
|
+
path63.join(home, ".config", "opencode", "opencode.jsonc")
|
|
29398
29517
|
);
|
|
29399
29518
|
const out2 = [];
|
|
29400
29519
|
const seen2 = /* @__PURE__ */ new Set();
|
|
@@ -29501,8 +29620,8 @@ function noteProviderBillingSignal(opts) {
|
|
|
29501
29620
|
}
|
|
29502
29621
|
|
|
29503
29622
|
// src/services/history.service.ts
|
|
29504
|
-
var
|
|
29505
|
-
var
|
|
29623
|
+
var fs55 = __toESM(require("fs"));
|
|
29624
|
+
var path64 = __toESM(require("path"));
|
|
29506
29625
|
var os43 = __toESM(require("os"));
|
|
29507
29626
|
var https6 = __toESM(require("https"));
|
|
29508
29627
|
var http9 = __toESM(require("http"));
|
|
@@ -29564,7 +29683,7 @@ function parseJsonl(filePath) {
|
|
|
29564
29683
|
const messages = [];
|
|
29565
29684
|
let raw;
|
|
29566
29685
|
try {
|
|
29567
|
-
raw =
|
|
29686
|
+
raw = fs55.readFileSync(filePath, "utf8");
|
|
29568
29687
|
} catch (err) {
|
|
29569
29688
|
if (err.code !== "ENOENT") {
|
|
29570
29689
|
log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
|
|
@@ -29718,7 +29837,7 @@ var HistoryService = class _HistoryService {
|
|
|
29718
29837
|
return this._quotaPercent === null || Date.now() - this._quotaFetchedAt > ttlMs;
|
|
29719
29838
|
}
|
|
29720
29839
|
get projectDir() {
|
|
29721
|
-
return this.runtime.resolveHistoryDir(this.cwd) ??
|
|
29840
|
+
return this.runtime.resolveHistoryDir(this.cwd) ?? path64.join(os43.homedir(), ".claude", "projects", encodeCwd(this.cwd));
|
|
29722
29841
|
}
|
|
29723
29842
|
/** Set the current Claude conversation ID (extracted from /cost command or session start) */
|
|
29724
29843
|
setCurrentConversationId(id) {
|
|
@@ -29730,7 +29849,7 @@ var HistoryService = class _HistoryService {
|
|
|
29730
29849
|
/** Return the current message count in the active conversation. */
|
|
29731
29850
|
getCurrentMessageCount() {
|
|
29732
29851
|
if (!this.currentConversationId) return 0;
|
|
29733
|
-
const filePath =
|
|
29852
|
+
const filePath = path64.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
29734
29853
|
return parseJsonl(filePath).length;
|
|
29735
29854
|
}
|
|
29736
29855
|
/**
|
|
@@ -29741,7 +29860,7 @@ var HistoryService = class _HistoryService {
|
|
|
29741
29860
|
const deadline = Date.now() + timeoutMs;
|
|
29742
29861
|
while (Date.now() < deadline) {
|
|
29743
29862
|
if (!this.currentConversationId) return null;
|
|
29744
|
-
const filePath =
|
|
29863
|
+
const filePath = path64.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
29745
29864
|
const messages = parseJsonl(filePath);
|
|
29746
29865
|
if (messages.length > previousCount) {
|
|
29747
29866
|
for (let i = messages.length - 1; i >= previousCount; i--) {
|
|
@@ -29767,16 +29886,16 @@ var HistoryService = class _HistoryService {
|
|
|
29767
29886
|
const dir = this.projectDir;
|
|
29768
29887
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
29769
29888
|
try {
|
|
29770
|
-
const files =
|
|
29889
|
+
const files = fs55.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
29771
29890
|
try {
|
|
29772
|
-
const stat3 =
|
|
29891
|
+
const stat3 = fs55.statSync(path64.join(dir, e.name));
|
|
29773
29892
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
29774
29893
|
} catch {
|
|
29775
29894
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
29776
29895
|
}
|
|
29777
29896
|
}).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
29778
29897
|
if (files.length > 0) {
|
|
29779
|
-
this.currentConversationId =
|
|
29898
|
+
this.currentConversationId = path64.basename(files[0].name, ".jsonl");
|
|
29780
29899
|
}
|
|
29781
29900
|
} catch {
|
|
29782
29901
|
}
|
|
@@ -29810,13 +29929,13 @@ var HistoryService = class _HistoryService {
|
|
|
29810
29929
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
29811
29930
|
let entries;
|
|
29812
29931
|
try {
|
|
29813
|
-
entries =
|
|
29932
|
+
entries = fs55.readdirSync(dir, { withFileTypes: true });
|
|
29814
29933
|
} catch {
|
|
29815
29934
|
return null;
|
|
29816
29935
|
}
|
|
29817
29936
|
const files = entries.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
29818
29937
|
try {
|
|
29819
|
-
const stat3 =
|
|
29938
|
+
const stat3 = fs55.statSync(path64.join(dir, e.name));
|
|
29820
29939
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
29821
29940
|
} catch {
|
|
29822
29941
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
@@ -29825,12 +29944,12 @@ var HistoryService = class _HistoryService {
|
|
|
29825
29944
|
if (files.length === 0) return null;
|
|
29826
29945
|
const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
|
|
29827
29946
|
if (!files.some((f) => f.name === targetFile)) return null;
|
|
29828
|
-
return this.extractUsageFromFile(
|
|
29947
|
+
return this.extractUsageFromFile(path64.join(dir, targetFile));
|
|
29829
29948
|
}
|
|
29830
29949
|
extractUsageFromFile(filePath) {
|
|
29831
29950
|
let raw;
|
|
29832
29951
|
try {
|
|
29833
|
-
raw =
|
|
29952
|
+
raw = fs55.readFileSync(filePath, "utf8");
|
|
29834
29953
|
} catch {
|
|
29835
29954
|
return null;
|
|
29836
29955
|
}
|
|
@@ -29882,9 +30001,9 @@ var HistoryService = class _HistoryService {
|
|
|
29882
30001
|
let totalCost = 0;
|
|
29883
30002
|
let files;
|
|
29884
30003
|
try {
|
|
29885
|
-
files =
|
|
30004
|
+
files = fs55.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
|
|
29886
30005
|
try {
|
|
29887
|
-
return
|
|
30006
|
+
return fs55.statSync(path64.join(projectDir, f)).mtimeMs >= monthStartMs;
|
|
29888
30007
|
} catch {
|
|
29889
30008
|
return false;
|
|
29890
30009
|
}
|
|
@@ -29895,7 +30014,7 @@ var HistoryService = class _HistoryService {
|
|
|
29895
30014
|
for (const file of files) {
|
|
29896
30015
|
let raw;
|
|
29897
30016
|
try {
|
|
29898
|
-
raw =
|
|
30017
|
+
raw = fs55.readFileSync(path64.join(projectDir, file), "utf8");
|
|
29899
30018
|
} catch {
|
|
29900
30019
|
continue;
|
|
29901
30020
|
}
|
|
@@ -29974,7 +30093,7 @@ var HistoryService = class _HistoryService {
|
|
|
29974
30093
|
if (this.runtime.resolveHistoryFile) {
|
|
29975
30094
|
return this.runtime.resolveHistoryFile(this.cwd, sessionId);
|
|
29976
30095
|
}
|
|
29977
|
-
return
|
|
30096
|
+
return path64.join(this.projectDir, `${sessionId}.jsonl`);
|
|
29978
30097
|
}
|
|
29979
30098
|
/**
|
|
29980
30099
|
* Parse a conversation's messages from disk, agent-aware. Claude uses the
|
|
@@ -30012,14 +30131,14 @@ var HistoryService = class _HistoryService {
|
|
|
30012
30131
|
};
|
|
30013
30132
|
});
|
|
30014
30133
|
}
|
|
30015
|
-
return parseJsonl(
|
|
30134
|
+
return parseJsonl(path64.join(this.projectDir, `${sessionId}.jsonl`));
|
|
30016
30135
|
}
|
|
30017
30136
|
/** One in-flight full upload per conversation — the baton mirror and a
|
|
30018
30137
|
* `get_conversation` used to upload the same transcript concurrently. */
|
|
30019
30138
|
uploadsInFlight = /* @__PURE__ */ new Map();
|
|
30020
30139
|
async loadConversation(sessionId) {
|
|
30021
|
-
const
|
|
30022
|
-
if (
|
|
30140
|
+
const inFlight2 = this.uploadsInFlight.get(sessionId);
|
|
30141
|
+
if (inFlight2) return inFlight2;
|
|
30023
30142
|
const run = this.loadConversationNow(sessionId).finally(() => {
|
|
30024
30143
|
this.uploadsInFlight.delete(sessionId);
|
|
30025
30144
|
});
|
|
@@ -30094,7 +30213,7 @@ var HistoryService = class _HistoryService {
|
|
|
30094
30213
|
if (!filePath) return false;
|
|
30095
30214
|
let mtimeMs;
|
|
30096
30215
|
try {
|
|
30097
|
-
mtimeMs =
|
|
30216
|
+
mtimeMs = fs55.statSync(filePath).mtimeMs;
|
|
30098
30217
|
} catch {
|
|
30099
30218
|
return false;
|
|
30100
30219
|
}
|
|
@@ -30169,10 +30288,10 @@ var HistoryService = class _HistoryService {
|
|
|
30169
30288
|
|
|
30170
30289
|
// src/agents/acp/client.ts
|
|
30171
30290
|
var import_node_child_process21 = require("child_process");
|
|
30172
|
-
var
|
|
30291
|
+
var fs56 = __toESM(require("fs/promises"));
|
|
30173
30292
|
var fsSync = __toESM(require("fs"));
|
|
30174
30293
|
var os45 = __toESM(require("os"));
|
|
30175
|
-
var
|
|
30294
|
+
var path66 = __toESM(require("path"));
|
|
30176
30295
|
var import_node_stream = require("stream");
|
|
30177
30296
|
|
|
30178
30297
|
// ../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
@@ -34198,7 +34317,7 @@ function createIdleTimeout(idleMs, makeError, activeIdleMs = idleMs) {
|
|
|
34198
34317
|
}
|
|
34199
34318
|
|
|
34200
34319
|
// src/agents/acp/internal-paths.ts
|
|
34201
|
-
var
|
|
34320
|
+
var path65 = __toESM(require("path"));
|
|
34202
34321
|
var os44 = __toESM(require("os"));
|
|
34203
34322
|
var INTERNAL_TOKENS = [".codeam", "house-claude"];
|
|
34204
34323
|
var PROSE_ONLY_TOOL_KINDS = /* @__PURE__ */ new Set(["think", "switch_mode"]);
|
|
@@ -34213,11 +34332,11 @@ function textReferencesInternal(text) {
|
|
|
34213
34332
|
}
|
|
34214
34333
|
function pathIsInternal(p2, homeDir2 = os44.homedir()) {
|
|
34215
34334
|
if (!p2) return false;
|
|
34216
|
-
const abs =
|
|
34217
|
-
const home =
|
|
34218
|
-
const within = (root) => abs === root || abs.startsWith(root +
|
|
34219
|
-
if (within(
|
|
34220
|
-
return within(
|
|
34335
|
+
const abs = path65.resolve(p2);
|
|
34336
|
+
const home = path65.resolve(homeDir2);
|
|
34337
|
+
const within = (root) => abs === root || abs.startsWith(root + path65.sep);
|
|
34338
|
+
if (within(path65.join(home, ".codeam", "self-hosted"))) return false;
|
|
34339
|
+
return within(path65.join(home, ".codeam")) || within(path65.join(home, ".beads")) || abs === path65.join(home, ".codeam-host.log") || abs.includes(`${path65.sep}house-claude${path65.sep}`) || abs.endsWith(`${path65.sep}house-claude`);
|
|
34221
34340
|
}
|
|
34222
34341
|
function toolCallReferencesInternal(call, homeDir2) {
|
|
34223
34342
|
if (call.locations?.some((l) => pathIsInternal(l.path, homeDir2))) return true;
|
|
@@ -35312,7 +35431,7 @@ var AcpClient = class {
|
|
|
35312
35431
|
throw new RequestError(-32002, GUARDRAIL_SECRET_READ_BLOCK_REASON, { uri: params.path });
|
|
35313
35432
|
}
|
|
35314
35433
|
try {
|
|
35315
|
-
const content = await
|
|
35434
|
+
const content = await fs56.readFile(params.path, "utf8");
|
|
35316
35435
|
return applyLineRange(content, params.line ?? null, params.limit ?? null);
|
|
35317
35436
|
} catch (err) {
|
|
35318
35437
|
const code = err.code;
|
|
@@ -35333,7 +35452,7 @@ var AcpClient = class {
|
|
|
35333
35452
|
throw new RequestError(-32002, INTERNAL_BLOCK_REASON, { uri: params.path });
|
|
35334
35453
|
}
|
|
35335
35454
|
try {
|
|
35336
|
-
await
|
|
35455
|
+
await fs56.writeFile(params.path, params.content, "utf8");
|
|
35337
35456
|
return {};
|
|
35338
35457
|
} catch (err) {
|
|
35339
35458
|
const code = err.code;
|
|
@@ -35426,25 +35545,25 @@ function knownAgentBinaryDirs() {
|
|
|
35426
35545
|
out2.push("/tmp/codeam-node20/bin");
|
|
35427
35546
|
for (const root of [
|
|
35428
35547
|
"/usr/local/share/nvm/versions/node",
|
|
35429
|
-
|
|
35548
|
+
path66.join(home, ".nvm/versions/node")
|
|
35430
35549
|
]) {
|
|
35431
35550
|
try {
|
|
35432
35551
|
for (const child of fsSync.readdirSync(root)) {
|
|
35433
|
-
out2.push(
|
|
35552
|
+
out2.push(path66.join(root, child, "bin"));
|
|
35434
35553
|
}
|
|
35435
35554
|
} catch {
|
|
35436
35555
|
}
|
|
35437
35556
|
}
|
|
35438
|
-
out2.push(
|
|
35557
|
+
out2.push(path66.join(home, ".volta/bin"));
|
|
35439
35558
|
out2.push("/usr/local/bin");
|
|
35440
35559
|
out2.push("/usr/bin");
|
|
35441
|
-
out2.push(
|
|
35442
|
-
out2.push(
|
|
35560
|
+
out2.push(path66.join(home, ".local/bin"));
|
|
35561
|
+
out2.push(path66.join(home, "bin"));
|
|
35443
35562
|
out2.push(...agentInstallBinDirs());
|
|
35444
35563
|
if (process.platform === "win32") {
|
|
35445
35564
|
const { LOCALAPPDATA, APPDATA } = process.env;
|
|
35446
|
-
if (LOCALAPPDATA) out2.push(
|
|
35447
|
-
if (APPDATA) out2.push(
|
|
35565
|
+
if (LOCALAPPDATA) out2.push(path66.join(LOCALAPPDATA, "cursor-agent"));
|
|
35566
|
+
if (APPDATA) out2.push(path66.join(APPDATA, "npm"));
|
|
35448
35567
|
}
|
|
35449
35568
|
return out2.filter((p2) => {
|
|
35450
35569
|
try {
|
|
@@ -35455,7 +35574,7 @@ function knownAgentBinaryDirs() {
|
|
|
35455
35574
|
});
|
|
35456
35575
|
}
|
|
35457
35576
|
function expandPathForAgentBinaries(existingPath) {
|
|
35458
|
-
const existing = new Set(existingPath.split(
|
|
35577
|
+
const existing = new Set(existingPath.split(path66.delimiter).filter((p2) => p2.length > 0));
|
|
35459
35578
|
const additions = [];
|
|
35460
35579
|
for (const dir of knownAgentBinaryDirs()) {
|
|
35461
35580
|
if (!existing.has(dir)) {
|
|
@@ -35464,7 +35583,7 @@ function expandPathForAgentBinaries(existingPath) {
|
|
|
35464
35583
|
}
|
|
35465
35584
|
}
|
|
35466
35585
|
if (additions.length === 0) return existingPath;
|
|
35467
|
-
return [...additions, existingPath].filter((p2) => p2.length > 0).join(
|
|
35586
|
+
return [...additions, existingPath].filter((p2) => p2.length > 0).join(path66.delimiter);
|
|
35468
35587
|
}
|
|
35469
35588
|
|
|
35470
35589
|
// src/commands/host/agent-install.ts
|
|
@@ -35736,9 +35855,9 @@ async function performAgentSwitch(deps, rawAgentId, fastPath = {}) {
|
|
|
35736
35855
|
}
|
|
35737
35856
|
|
|
35738
35857
|
// src/commands/host/agent-provisioning.ts
|
|
35739
|
-
var
|
|
35858
|
+
var fs57 = __toESM(require("fs"));
|
|
35740
35859
|
var os47 = __toESM(require("os"));
|
|
35741
|
-
var
|
|
35860
|
+
var path67 = __toESM(require("path"));
|
|
35742
35861
|
var PUBLIC_TO_INTERNAL_AGENT = {
|
|
35743
35862
|
claude_code: "claude",
|
|
35744
35863
|
claude: "claude",
|
|
@@ -35755,22 +35874,22 @@ function toInternalAgentId(publicAgentId) {
|
|
|
35755
35874
|
return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
|
|
35756
35875
|
}
|
|
35757
35876
|
function ensureDir(dir) {
|
|
35758
|
-
|
|
35877
|
+
fs57.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
35759
35878
|
}
|
|
35760
35879
|
function writeFile0600(filePath, contents) {
|
|
35761
|
-
ensureDir(
|
|
35762
|
-
|
|
35880
|
+
ensureDir(path67.dirname(filePath));
|
|
35881
|
+
fs57.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
|
|
35763
35882
|
restrictToOwner(filePath);
|
|
35764
35883
|
}
|
|
35765
35884
|
function rmIfExists(filePath) {
|
|
35766
35885
|
try {
|
|
35767
|
-
|
|
35886
|
+
fs57.rmSync(filePath, { force: true });
|
|
35768
35887
|
} catch {
|
|
35769
35888
|
}
|
|
35770
35889
|
}
|
|
35771
35890
|
var claudeProvisioner = {
|
|
35772
35891
|
write(auth, home) {
|
|
35773
|
-
const credentialsJson =
|
|
35892
|
+
const credentialsJson = path67.join(home, ".claude", ".credentials.json");
|
|
35774
35893
|
if (auth.kind === "api_key") {
|
|
35775
35894
|
rmIfExists(credentialsJson);
|
|
35776
35895
|
return { ANTHROPIC_API_KEY: auth.value };
|
|
@@ -35782,8 +35901,8 @@ var claudeProvisioner = {
|
|
|
35782
35901
|
} else {
|
|
35783
35902
|
rmIfExists(credentialsJson);
|
|
35784
35903
|
}
|
|
35785
|
-
const claudeJson =
|
|
35786
|
-
if (!
|
|
35904
|
+
const claudeJson = path67.join(home, ".claude.json");
|
|
35905
|
+
if (!fs57.existsSync(claudeJson)) {
|
|
35787
35906
|
writeFile0600(
|
|
35788
35907
|
claudeJson,
|
|
35789
35908
|
JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
|
|
@@ -35794,7 +35913,7 @@ var claudeProvisioner = {
|
|
|
35794
35913
|
};
|
|
35795
35914
|
var codexProvisioner = {
|
|
35796
35915
|
write(auth, home) {
|
|
35797
|
-
const authJson =
|
|
35916
|
+
const authJson = path67.join(home, ".codex", "auth.json");
|
|
35798
35917
|
if (auth.kind === "api_key") {
|
|
35799
35918
|
writeFile0600(authJson, JSON.stringify({ auth_mode: "apikey", OPENAI_API_KEY: auth.value }));
|
|
35800
35919
|
return { OPENAI_API_KEY: auth.value };
|
|
@@ -35805,8 +35924,8 @@ var codexProvisioner = {
|
|
|
35805
35924
|
};
|
|
35806
35925
|
var geminiProvisioner = {
|
|
35807
35926
|
write(auth, home) {
|
|
35808
|
-
const settingsJson =
|
|
35809
|
-
const oauthCreds =
|
|
35927
|
+
const settingsJson = path67.join(home, ".gemini", "settings.json");
|
|
35928
|
+
const oauthCreds = path67.join(home, ".gemini", "oauth_creds.json");
|
|
35810
35929
|
if (auth.kind === "api_key") {
|
|
35811
35930
|
rmIfExists(oauthCreds);
|
|
35812
35931
|
writeFile0600(settingsJson, '{"security":{"auth":{"selectedType":"gemini-api-key"}}}');
|
|
@@ -35819,7 +35938,7 @@ var geminiProvisioner = {
|
|
|
35819
35938
|
};
|
|
35820
35939
|
var cursorProvisioner = {
|
|
35821
35940
|
write(auth, home) {
|
|
35822
|
-
const authJson =
|
|
35941
|
+
const authJson = path67.join(home, ".config", "cursor", "auth.json");
|
|
35823
35942
|
if (auth.kind === "api_key") {
|
|
35824
35943
|
rmIfExists(authJson);
|
|
35825
35944
|
return { CURSOR_API_KEY: auth.value };
|
|
@@ -35861,22 +35980,22 @@ max_context_size = 262144
|
|
|
35861
35980
|
var kimiProvisioner = {
|
|
35862
35981
|
write(auth, home) {
|
|
35863
35982
|
const credentialsFiles = [
|
|
35864
|
-
|
|
35865
|
-
|
|
35983
|
+
path67.join(home, ".kimi", "credentials", "kimi-code.json"),
|
|
35984
|
+
path67.join(home, ".kimi-code", "credentials", "kimi-code.json")
|
|
35866
35985
|
];
|
|
35867
35986
|
if (auth.kind === "api_key") {
|
|
35868
35987
|
credentialsFiles.forEach(rmIfExists);
|
|
35869
35988
|
return { KIMI_API_KEY: auth.value };
|
|
35870
35989
|
}
|
|
35871
35990
|
credentialsFiles.forEach((f) => writeFile0600(f, auth.value));
|
|
35872
|
-
writeFile0600(
|
|
35991
|
+
writeFile0600(path67.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
|
|
35873
35992
|
return {};
|
|
35874
35993
|
}
|
|
35875
35994
|
};
|
|
35876
35995
|
var coderabbitProvisioner = {
|
|
35877
35996
|
write(auth, home) {
|
|
35878
|
-
const dir =
|
|
35879
|
-
const authJson =
|
|
35997
|
+
const dir = path67.join(home, ".coderabbit");
|
|
35998
|
+
const authJson = path67.join(dir, "auth.json");
|
|
35880
35999
|
if (auth.kind === "api_key") {
|
|
35881
36000
|
rmIfExists(authJson);
|
|
35882
36001
|
return { CODERABBIT_API_KEY: auth.value };
|
|
@@ -35888,13 +36007,13 @@ var coderabbitProvisioner = {
|
|
|
35888
36007
|
try {
|
|
35889
36008
|
const parsed = JSON.parse(value);
|
|
35890
36009
|
if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
|
|
35891
|
-
file =
|
|
36010
|
+
file = path67.basename(parsed.file);
|
|
35892
36011
|
contents = parsed.contents;
|
|
35893
36012
|
}
|
|
35894
36013
|
} catch {
|
|
35895
36014
|
}
|
|
35896
36015
|
}
|
|
35897
|
-
writeFile0600(
|
|
36016
|
+
writeFile0600(path67.join(dir, file), contents);
|
|
35898
36017
|
return {};
|
|
35899
36018
|
}
|
|
35900
36019
|
};
|
|
@@ -35931,16 +36050,16 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os47.homedir(
|
|
|
35931
36050
|
}
|
|
35932
36051
|
|
|
35933
36052
|
// src/beads/workflow-hint.ts
|
|
35934
|
-
var
|
|
35935
|
-
var
|
|
36053
|
+
var fs58 = __toESM(require("fs"));
|
|
36054
|
+
var path69 = __toESM(require("path"));
|
|
35936
36055
|
|
|
35937
36056
|
// src/agents/claude-memory-file.ts
|
|
35938
36057
|
var os48 = __toESM(require("os"));
|
|
35939
|
-
var
|
|
36058
|
+
var path68 = __toESM(require("path"));
|
|
35940
36059
|
function claudeMemoryFile(homeDir2, env = process.env) {
|
|
35941
|
-
if (homeDir2) return
|
|
36060
|
+
if (homeDir2) return path68.join(homeDir2, ".claude", "CLAUDE.md");
|
|
35942
36061
|
const configDir = env.CLAUDE_CONFIG_DIR?.trim();
|
|
35943
|
-
return configDir ?
|
|
36062
|
+
return configDir ? path68.join(configDir, "CLAUDE.md") : path68.join(os48.homedir(), ".claude", "CLAUDE.md");
|
|
35944
36063
|
}
|
|
35945
36064
|
|
|
35946
36065
|
// src/beads/workflow-hint.ts
|
|
@@ -35970,11 +36089,11 @@ function ensureBeadsWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
|
35970
36089
|
try {
|
|
35971
36090
|
let existing = "";
|
|
35972
36091
|
try {
|
|
35973
|
-
existing =
|
|
36092
|
+
existing = fs58.readFileSync(file, "utf8");
|
|
35974
36093
|
} catch {
|
|
35975
36094
|
}
|
|
35976
36095
|
if (existing.includes(BEADS_HINT)) return;
|
|
35977
|
-
|
|
36096
|
+
fs58.mkdirSync(path69.dirname(file), { recursive: true });
|
|
35978
36097
|
let next;
|
|
35979
36098
|
const open = existing.indexOf(BEADS_HINT_MARKER);
|
|
35980
36099
|
const close = open === -1 ? -1 : existing.indexOf(BEADS_HINT_MARKER, open + BEADS_HINT_MARKER.length);
|
|
@@ -35987,40 +36106,40 @@ ${BEADS_HINT}
|
|
|
35987
36106
|
` : `${BEADS_HINT}
|
|
35988
36107
|
`;
|
|
35989
36108
|
}
|
|
35990
|
-
|
|
36109
|
+
fs58.writeFileSync(file, next);
|
|
35991
36110
|
} catch {
|
|
35992
36111
|
}
|
|
35993
36112
|
}
|
|
35994
36113
|
|
|
35995
36114
|
// src/agents/agent-standard.ts
|
|
35996
|
-
var
|
|
35997
|
-
var
|
|
36115
|
+
var fs59 = __toESM(require("fs"));
|
|
36116
|
+
var path70 = __toESM(require("path"));
|
|
35998
36117
|
var os49 = __toESM(require("os"));
|
|
35999
36118
|
function ensureAgentStandard(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
36000
36119
|
try {
|
|
36001
36120
|
let existing = "";
|
|
36002
36121
|
try {
|
|
36003
|
-
existing =
|
|
36122
|
+
existing = fs59.readFileSync(file, "utf8");
|
|
36004
36123
|
} catch {
|
|
36005
36124
|
}
|
|
36006
36125
|
if (existing.includes(AGENT_STANDARD_MARKER)) return;
|
|
36007
|
-
|
|
36126
|
+
fs59.mkdirSync(path70.dirname(file), { recursive: true });
|
|
36008
36127
|
const next = existing.trim() ? `${existing.trimEnd()}
|
|
36009
36128
|
|
|
36010
36129
|
${AGENT_STANDARD_BLOCK}
|
|
36011
36130
|
` : `${AGENT_STANDARD_BLOCK}
|
|
36012
36131
|
`;
|
|
36013
|
-
|
|
36132
|
+
fs59.writeFileSync(file, next);
|
|
36014
36133
|
} catch {
|
|
36015
36134
|
}
|
|
36016
36135
|
}
|
|
36017
36136
|
var _agentStandardSeam = {
|
|
36018
36137
|
isLocalSession: () => isLocalSession(),
|
|
36019
|
-
markerPath: (sessionId) =>
|
|
36020
|
-
exists: (p2) =>
|
|
36138
|
+
markerPath: (sessionId) => path70.join(os49.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
|
|
36139
|
+
exists: (p2) => fs59.existsSync(p2),
|
|
36021
36140
|
write: (p2) => {
|
|
36022
|
-
|
|
36023
|
-
|
|
36141
|
+
fs59.mkdirSync(path70.dirname(p2), { recursive: true });
|
|
36142
|
+
fs59.writeFileSync(p2, "");
|
|
36024
36143
|
}
|
|
36025
36144
|
};
|
|
36026
36145
|
function isClaude(agent) {
|
|
@@ -36713,15 +36832,15 @@ function withholdTrailingPartialFenceMarker(text) {
|
|
|
36713
36832
|
|
|
36714
36833
|
// src/agents/acp/onboarding.ts
|
|
36715
36834
|
var import_child_process28 = require("child_process");
|
|
36716
|
-
var
|
|
36835
|
+
var fs60 = __toESM(require("fs"));
|
|
36717
36836
|
var os50 = __toESM(require("os"));
|
|
36718
|
-
var
|
|
36837
|
+
var path71 = __toESM(require("path"));
|
|
36719
36838
|
var _onboardingSeam = {
|
|
36720
|
-
markerPath: (sessionId) =>
|
|
36721
|
-
exists: (p2) =>
|
|
36839
|
+
markerPath: (sessionId) => path71.join(os50.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
|
|
36840
|
+
exists: (p2) => fs60.existsSync(p2),
|
|
36722
36841
|
write: (p2) => {
|
|
36723
|
-
|
|
36724
|
-
|
|
36842
|
+
fs60.mkdirSync(path71.dirname(p2), { recursive: true });
|
|
36843
|
+
fs60.writeFileSync(p2, "");
|
|
36725
36844
|
},
|
|
36726
36845
|
disabled: () => {
|
|
36727
36846
|
const v = process.env.CODEAM_ONBOARDING_DISABLED;
|
|
@@ -36758,7 +36877,7 @@ function resolveRepoName(cwd) {
|
|
|
36758
36877
|
if (name) return name;
|
|
36759
36878
|
}
|
|
36760
36879
|
}
|
|
36761
|
-
const base =
|
|
36880
|
+
const base = path71.basename(cwd || "");
|
|
36762
36881
|
if (base && !isUuid(base)) return base;
|
|
36763
36882
|
return "this project";
|
|
36764
36883
|
}
|
|
@@ -37150,13 +37269,13 @@ var import_crypto4 = require("crypto");
|
|
|
37150
37269
|
|
|
37151
37270
|
// src/services/turn-files/git-changeset.ts
|
|
37152
37271
|
var import_child_process29 = require("child_process");
|
|
37153
|
-
var
|
|
37154
|
-
var
|
|
37272
|
+
var fs62 = __toESM(require("fs/promises"));
|
|
37273
|
+
var path73 = __toESM(require("path"));
|
|
37155
37274
|
|
|
37156
37275
|
// src/services/turn-files/review-ignore.ts
|
|
37157
37276
|
var import_ignore2 = __toESM(require("ignore"));
|
|
37158
|
-
var
|
|
37159
|
-
var
|
|
37277
|
+
var fs61 = __toESM(require("fs"));
|
|
37278
|
+
var path72 = __toESM(require("path"));
|
|
37160
37279
|
var CURATED_REVIEW_IGNORE = [
|
|
37161
37280
|
// Google Cloud SDK (the incident) — installs a huge python tree.
|
|
37162
37281
|
"google-cloud-sdk/",
|
|
@@ -37195,7 +37314,7 @@ var CURATED_REVIEW_IGNORE = [
|
|
|
37195
37314
|
function makeReviewIgnore(repoRoot) {
|
|
37196
37315
|
const ig = (0, import_ignore2.default)().add(CURATED_REVIEW_IGNORE);
|
|
37197
37316
|
try {
|
|
37198
|
-
const custom =
|
|
37317
|
+
const custom = fs61.readFileSync(path72.join(repoRoot, ".codeam", "reviewignore"), "utf8");
|
|
37199
37318
|
ig.add(custom);
|
|
37200
37319
|
} catch {
|
|
37201
37320
|
}
|
|
@@ -37240,7 +37359,7 @@ async function collectRepoChangeset(opts) {
|
|
|
37240
37359
|
let stats;
|
|
37241
37360
|
if (!truncated && row.fileStatus === "added" && numstatEntry === void 0) {
|
|
37242
37361
|
const lineCount = await readUntrackedLineCount(
|
|
37243
|
-
|
|
37362
|
+
path73.join(opts.repoRoot, row.filePath)
|
|
37244
37363
|
);
|
|
37245
37364
|
stats = { added: lineCount, removed: 0 };
|
|
37246
37365
|
} else {
|
|
@@ -37271,7 +37390,7 @@ function readUntrackedLineCount(absPath) {
|
|
|
37271
37390
|
}
|
|
37272
37391
|
async function defaultReadUntrackedLineCount(absPath) {
|
|
37273
37392
|
try {
|
|
37274
|
-
const content = await
|
|
37393
|
+
const content = await fs62.readFile(absPath, "utf8");
|
|
37275
37394
|
let count = 0;
|
|
37276
37395
|
let pos = -1;
|
|
37277
37396
|
while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
|
|
@@ -37363,7 +37482,7 @@ function defaultRunGit(cwd, args2) {
|
|
|
37363
37482
|
});
|
|
37364
37483
|
}
|
|
37365
37484
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
37366
|
-
const
|
|
37485
|
+
const fs81 = await import("fs/promises");
|
|
37367
37486
|
const out2 = [];
|
|
37368
37487
|
await walk(workingDir, 0);
|
|
37369
37488
|
return out2;
|
|
@@ -37371,7 +37490,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
37371
37490
|
if (depth > maxDepth) return;
|
|
37372
37491
|
let entries = [];
|
|
37373
37492
|
try {
|
|
37374
|
-
const dirents = await
|
|
37493
|
+
const dirents = await fs81.readdir(dir, { withFileTypes: true });
|
|
37375
37494
|
entries = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
37376
37495
|
} catch {
|
|
37377
37496
|
return;
|
|
@@ -37382,8 +37501,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
37382
37501
|
if (hasGit) {
|
|
37383
37502
|
out2.push({
|
|
37384
37503
|
repoRoot: dir,
|
|
37385
|
-
repoPath:
|
|
37386
|
-
repoName:
|
|
37504
|
+
repoPath: path73.relative(workingDir, dir),
|
|
37505
|
+
repoName: path73.basename(dir)
|
|
37387
37506
|
});
|
|
37388
37507
|
return;
|
|
37389
37508
|
}
|
|
@@ -37391,14 +37510,14 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
37391
37510
|
if (!entry.isDirectory) continue;
|
|
37392
37511
|
if (entry.name === "node_modules") continue;
|
|
37393
37512
|
if (entry.name === "dist" || entry.name === "build") continue;
|
|
37394
|
-
await walk(
|
|
37513
|
+
await walk(path73.join(dir, entry.name), depth + 1);
|
|
37395
37514
|
}
|
|
37396
37515
|
}
|
|
37397
37516
|
}
|
|
37398
37517
|
|
|
37399
37518
|
// src/services/turn-files/files-outbox.ts
|
|
37400
|
-
var
|
|
37401
|
-
var
|
|
37519
|
+
var fs63 = __toESM(require("fs/promises"));
|
|
37520
|
+
var path74 = __toESM(require("path"));
|
|
37402
37521
|
var import_os12 = require("os");
|
|
37403
37522
|
var HOME_OUTBOX_DIR = ".codeam/outbox";
|
|
37404
37523
|
var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -37431,16 +37550,16 @@ var FilesOutbox = class {
|
|
|
37431
37550
|
backoffIndex = 0;
|
|
37432
37551
|
stopped = false;
|
|
37433
37552
|
constructor(opts) {
|
|
37434
|
-
const base = opts.baseDir ??
|
|
37435
|
-
this.filePath =
|
|
37553
|
+
const base = opts.baseDir ?? path74.join(homeDir(), HOME_OUTBOX_DIR);
|
|
37554
|
+
this.filePath = path74.join(base, `${opts.sessionId}.jsonl`);
|
|
37436
37555
|
this.post = opts.post;
|
|
37437
37556
|
this.autoSchedule = opts.autoSchedule !== false;
|
|
37438
37557
|
}
|
|
37439
37558
|
/** Persist the entry to disk and trigger a flush. Returns once the
|
|
37440
37559
|
* line is durable on disk (not once the POST succeeds). */
|
|
37441
37560
|
async enqueue(entry) {
|
|
37442
|
-
await
|
|
37443
|
-
await
|
|
37561
|
+
await fs63.mkdir(path74.dirname(this.filePath), { recursive: true });
|
|
37562
|
+
await fs63.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
|
|
37444
37563
|
this.backoffIndex = 0;
|
|
37445
37564
|
if (this.autoSchedule) this.scheduleFlush(0);
|
|
37446
37565
|
}
|
|
@@ -37531,7 +37650,7 @@ var FilesOutbox = class {
|
|
|
37531
37650
|
async readAll() {
|
|
37532
37651
|
let raw = "";
|
|
37533
37652
|
try {
|
|
37534
|
-
raw = await
|
|
37653
|
+
raw = await fs63.readFile(this.filePath, "utf8");
|
|
37535
37654
|
} catch {
|
|
37536
37655
|
return [];
|
|
37537
37656
|
}
|
|
@@ -37555,12 +37674,12 @@ var FilesOutbox = class {
|
|
|
37555
37674
|
async rewrite(entries) {
|
|
37556
37675
|
const tmpPath = `${this.filePath}.${process.pid}.tmp`;
|
|
37557
37676
|
if (entries.length === 0) {
|
|
37558
|
-
await
|
|
37677
|
+
await fs63.unlink(this.filePath).catch(() => void 0);
|
|
37559
37678
|
return;
|
|
37560
37679
|
}
|
|
37561
37680
|
const payload = entries.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
37562
|
-
await
|
|
37563
|
-
await
|
|
37681
|
+
await fs63.writeFile(tmpPath, payload, "utf8");
|
|
37682
|
+
await fs63.rename(tmpPath, this.filePath);
|
|
37564
37683
|
}
|
|
37565
37684
|
};
|
|
37566
37685
|
function applyJitter(ms) {
|
|
@@ -38108,8 +38227,8 @@ async function postCredentialSync(opts, fetchImpl = fetch) {
|
|
|
38108
38227
|
|
|
38109
38228
|
// src/packs/gates.ts
|
|
38110
38229
|
var import_node_child_process22 = require("child_process");
|
|
38111
|
-
var
|
|
38112
|
-
var
|
|
38230
|
+
var fs64 = __toESM(require("fs"));
|
|
38231
|
+
var path75 = __toESM(require("path"));
|
|
38113
38232
|
var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((resolve12) => {
|
|
38114
38233
|
(0, import_node_child_process22.execFile)(
|
|
38115
38234
|
file,
|
|
@@ -38159,7 +38278,7 @@ async function changedFiles(run, cwd, from, to) {
|
|
|
38159
38278
|
}
|
|
38160
38279
|
function readWorkspaceFile(cwd, relPath) {
|
|
38161
38280
|
try {
|
|
38162
|
-
return
|
|
38281
|
+
return fs64.readFileSync(path75.join(cwd, relPath), "utf8");
|
|
38163
38282
|
} catch {
|
|
38164
38283
|
return null;
|
|
38165
38284
|
}
|
|
@@ -38168,14 +38287,14 @@ var NO_TEST_PLACEHOLDER = 'echo "Error: no test specified"';
|
|
|
38168
38287
|
var CHECKS_TIMEOUT_MS = 5 * 6e4;
|
|
38169
38288
|
function detectChecksCommand(cwd) {
|
|
38170
38289
|
try {
|
|
38171
|
-
const cfg = JSON.parse(
|
|
38290
|
+
const cfg = JSON.parse(fs64.readFileSync(path75.join(cwd, ".codeam", "pack.json"), "utf8"));
|
|
38172
38291
|
if (typeof cfg.checksCommand === "string" && cfg.checksCommand.trim().length > 0) {
|
|
38173
38292
|
return cfg.checksCommand.trim();
|
|
38174
38293
|
}
|
|
38175
38294
|
} catch {
|
|
38176
38295
|
}
|
|
38177
38296
|
try {
|
|
38178
|
-
const pkg = JSON.parse(
|
|
38297
|
+
const pkg = JSON.parse(fs64.readFileSync(path75.join(cwd, "package.json"), "utf8"));
|
|
38179
38298
|
const test = pkg.scripts?.test;
|
|
38180
38299
|
if (typeof test === "string" && test.trim().length > 0 && !test.includes(NO_TEST_PLACEHOLDER)) {
|
|
38181
38300
|
return "npm test";
|
|
@@ -38193,39 +38312,39 @@ ${res.stderr}`.trim();
|
|
|
38193
38312
|
}
|
|
38194
38313
|
|
|
38195
38314
|
// src/packs/run-store.ts
|
|
38196
|
-
var
|
|
38197
|
-
var
|
|
38315
|
+
var fs65 = __toESM(require("fs"));
|
|
38316
|
+
var path76 = __toESM(require("path"));
|
|
38198
38317
|
var crypto5 = __toESM(require("crypto"));
|
|
38199
38318
|
function packsDir(cwd) {
|
|
38200
|
-
return
|
|
38319
|
+
return path76.join(cwd, ".codeam", "packs");
|
|
38201
38320
|
}
|
|
38202
38321
|
function runDir(cwd, runId) {
|
|
38203
|
-
return
|
|
38322
|
+
return path76.join(packsDir(cwd), runId);
|
|
38204
38323
|
}
|
|
38205
38324
|
function newRunId() {
|
|
38206
38325
|
return `pk_${Date.now().toString(36)}_${crypto5.randomBytes(4).toString("hex")}`;
|
|
38207
38326
|
}
|
|
38208
38327
|
function writeJsonAtomic(file, value) {
|
|
38209
|
-
|
|
38328
|
+
fs65.mkdirSync(path76.dirname(file), { recursive: true });
|
|
38210
38329
|
const tmp = `${file}.tmp`;
|
|
38211
|
-
|
|
38212
|
-
|
|
38330
|
+
fs65.writeFileSync(tmp, JSON.stringify(value, null, 2));
|
|
38331
|
+
fs65.renameSync(tmp, file);
|
|
38213
38332
|
}
|
|
38214
38333
|
function saveRun(cwd, state) {
|
|
38215
|
-
writeJsonAtomic(
|
|
38334
|
+
writeJsonAtomic(path76.join(runDir(cwd, state.runId), "run.json"), state);
|
|
38216
38335
|
}
|
|
38217
38336
|
function saveStageHandoff(cwd, runId, stageIndex, role, handoff) {
|
|
38218
38337
|
const name = `${String(stageIndex + 1).padStart(2, "0")}-${role}.json`;
|
|
38219
|
-
writeJsonAtomic(
|
|
38338
|
+
writeJsonAtomic(path76.join(runDir(cwd, runId), name), handoff);
|
|
38220
38339
|
}
|
|
38221
38340
|
function loadLatestRun(cwd) {
|
|
38222
38341
|
try {
|
|
38223
38342
|
const dir = packsDir(cwd);
|
|
38224
|
-
const entries =
|
|
38343
|
+
const entries = fs65.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
38225
38344
|
for (let i = entries.length - 1; i >= 0; i--) {
|
|
38226
|
-
const file =
|
|
38345
|
+
const file = path76.join(dir, entries[i], "run.json");
|
|
38227
38346
|
try {
|
|
38228
|
-
const parsed = JSON.parse(
|
|
38347
|
+
const parsed = JSON.parse(fs65.readFileSync(file, "utf8"));
|
|
38229
38348
|
if (parsed && typeof parsed.runId === "string") return parsed;
|
|
38230
38349
|
} catch {
|
|
38231
38350
|
}
|
|
@@ -38236,17 +38355,17 @@ function loadLatestRun(cwd) {
|
|
|
38236
38355
|
}
|
|
38237
38356
|
function ensureLedgerIgnored(cwd) {
|
|
38238
38357
|
try {
|
|
38239
|
-
const gitDir =
|
|
38240
|
-
if (!
|
|
38241
|
-
const exclude =
|
|
38358
|
+
const gitDir = path76.join(cwd, ".git");
|
|
38359
|
+
if (!fs65.existsSync(gitDir)) return;
|
|
38360
|
+
const exclude = path76.join(gitDir, "info", "exclude");
|
|
38242
38361
|
let existing = "";
|
|
38243
38362
|
try {
|
|
38244
|
-
existing =
|
|
38363
|
+
existing = fs65.readFileSync(exclude, "utf8");
|
|
38245
38364
|
} catch {
|
|
38246
38365
|
}
|
|
38247
38366
|
if (existing.includes(".codeam/packs/")) return;
|
|
38248
|
-
|
|
38249
|
-
|
|
38367
|
+
fs65.mkdirSync(path76.dirname(exclude), { recursive: true });
|
|
38368
|
+
fs65.writeFileSync(exclude, `${existing.trimEnd()}
|
|
38250
38369
|
.codeam/packs/
|
|
38251
38370
|
`.trimStart());
|
|
38252
38371
|
} catch {
|
|
@@ -41723,17 +41842,17 @@ async function runAcpSession(opts) {
|
|
|
41723
41842
|
switchCredentialEnv = provisionAgentCredentials(agentId, auth);
|
|
41724
41843
|
},
|
|
41725
41844
|
provisionHouseProxy: ({ baseUrl, token, model, managedAgentId }) => {
|
|
41726
|
-
const claudeConfigDir =
|
|
41845
|
+
const claudeConfigDir = path80.join(
|
|
41727
41846
|
os53.homedir(),
|
|
41728
41847
|
".codeam",
|
|
41729
41848
|
"house-claude",
|
|
41730
41849
|
`switch-${opts.pluginId}`
|
|
41731
41850
|
);
|
|
41732
41851
|
try {
|
|
41733
|
-
|
|
41852
|
+
fs69.mkdirSync(claudeConfigDir, { recursive: true, mode: 448 });
|
|
41734
41853
|
} catch {
|
|
41735
41854
|
}
|
|
41736
|
-
const memoryFile =
|
|
41855
|
+
const memoryFile = path80.join(claudeConfigDir, "CLAUDE.md");
|
|
41737
41856
|
ensureBeadsWorkflowHint(void 0, memoryFile);
|
|
41738
41857
|
ensureAgentStandard(void 0, memoryFile);
|
|
41739
41858
|
const cfg = {
|
|
@@ -42956,8 +43075,8 @@ function pickPinnedSession(pinnedId, listSessions2) {
|
|
|
42956
43075
|
}
|
|
42957
43076
|
|
|
42958
43077
|
// src/agents/retired-proxy-cleanup.ts
|
|
42959
|
-
var
|
|
42960
|
-
var
|
|
43078
|
+
var fs70 = __toESM(require("fs"));
|
|
43079
|
+
var path81 = __toESM(require("path"));
|
|
42961
43080
|
var os54 = __toESM(require("os"));
|
|
42962
43081
|
var RETIRED_PROXY_RE = /^https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):8787(?:[/?#]|$)/i;
|
|
42963
43082
|
var HEADROOM_CMD_RE = /(^|[\s/"'])headroom(\s|$)/i;
|
|
@@ -42969,10 +43088,10 @@ function isHeadroomHook(group) {
|
|
|
42969
43088
|
}
|
|
42970
43089
|
function sanitizeRetiredProxyConfig(homeDir2 = os54.homedir()) {
|
|
42971
43090
|
const out2 = { inspected: false, changed: false, removed: [] };
|
|
42972
|
-
const file =
|
|
43091
|
+
const file = path81.join(homeDir2, ".claude", "settings.json");
|
|
42973
43092
|
let parsed;
|
|
42974
43093
|
try {
|
|
42975
|
-
parsed = JSON.parse(
|
|
43094
|
+
parsed = JSON.parse(fs70.readFileSync(file, "utf8"));
|
|
42976
43095
|
} catch {
|
|
42977
43096
|
return out2;
|
|
42978
43097
|
}
|
|
@@ -43014,9 +43133,9 @@ function sanitizeRetiredProxyConfig(homeDir2 = os54.homedir()) {
|
|
|
43014
43133
|
if (!out2.changed) return out2;
|
|
43015
43134
|
try {
|
|
43016
43135
|
const tmp = `${file}.codeam.tmp`;
|
|
43017
|
-
|
|
43136
|
+
fs70.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
|
|
43018
43137
|
`, { mode: 384 });
|
|
43019
|
-
|
|
43138
|
+
fs70.renameSync(tmp, file);
|
|
43020
43139
|
} catch {
|
|
43021
43140
|
out2.changed = false;
|
|
43022
43141
|
}
|
|
@@ -43548,7 +43667,7 @@ var AcpDriver = class {
|
|
|
43548
43667
|
};
|
|
43549
43668
|
|
|
43550
43669
|
// src/baton/transcript-mirror.ts
|
|
43551
|
-
var
|
|
43670
|
+
var fs71 = __toESM(require("fs"));
|
|
43552
43671
|
var TranscriptMirror = class {
|
|
43553
43672
|
constructor(deps) {
|
|
43554
43673
|
this.deps = deps;
|
|
@@ -43642,7 +43761,7 @@ var TranscriptMirror = class {
|
|
|
43642
43761
|
}
|
|
43643
43762
|
};
|
|
43644
43763
|
function defaultWatch(file, onChange) {
|
|
43645
|
-
const w3 =
|
|
43764
|
+
const w3 = fs71.watch(file, { persistent: false }, () => onChange());
|
|
43646
43765
|
return () => w3.close();
|
|
43647
43766
|
}
|
|
43648
43767
|
|
|
@@ -43988,16 +44107,16 @@ function keepDeviceAwake(deps = {}) {
|
|
|
43988
44107
|
}
|
|
43989
44108
|
|
|
43990
44109
|
// src/agents/claude/onboarding.ts
|
|
43991
|
-
var
|
|
44110
|
+
var fs72 = __toESM(require("fs"));
|
|
43992
44111
|
var os56 = __toESM(require("os"));
|
|
43993
|
-
var
|
|
44112
|
+
var path82 = __toESM(require("path"));
|
|
43994
44113
|
var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
|
|
43995
44114
|
function ensureClaudeOnboarded(cwd) {
|
|
43996
44115
|
try {
|
|
43997
|
-
const file =
|
|
44116
|
+
const file = path82.join(os56.homedir(), ".claude.json");
|
|
43998
44117
|
let config = {};
|
|
43999
44118
|
try {
|
|
44000
|
-
config = JSON.parse(
|
|
44119
|
+
config = JSON.parse(fs72.readFileSync(file, "utf8"));
|
|
44001
44120
|
} catch {
|
|
44002
44121
|
}
|
|
44003
44122
|
let changed = false;
|
|
@@ -44022,8 +44141,8 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
44022
44141
|
}
|
|
44023
44142
|
}
|
|
44024
44143
|
if (!changed) return;
|
|
44025
|
-
|
|
44026
|
-
|
|
44144
|
+
fs72.mkdirSync(path82.dirname(file), { recursive: true });
|
|
44145
|
+
fs72.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
44027
44146
|
log.info(
|
|
44028
44147
|
"claude",
|
|
44029
44148
|
`pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
|
|
@@ -44792,7 +44911,7 @@ var import_picocolors10 = __toESM(require("picocolors"));
|
|
|
44792
44911
|
var import_child_process30 = require("child_process");
|
|
44793
44912
|
var import_util4 = require("util");
|
|
44794
44913
|
var import_picocolors8 = __toESM(require("picocolors"));
|
|
44795
|
-
var
|
|
44914
|
+
var path83 = __toESM(require("path"));
|
|
44796
44915
|
var execFileP5 = (0, import_util4.promisify)(import_child_process30.execFile);
|
|
44797
44916
|
var MAX_BUFFER = 8 * 1024 * 1024;
|
|
44798
44917
|
function resetStdinForChild() {
|
|
@@ -45281,7 +45400,7 @@ var GitHubCodespacesProvider = class {
|
|
|
45281
45400
|
});
|
|
45282
45401
|
}
|
|
45283
45402
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
45284
|
-
const remoteDir =
|
|
45403
|
+
const remoteDir = path83.posix.dirname(remotePath);
|
|
45285
45404
|
const parts = [
|
|
45286
45405
|
`mkdir -p ${shellQuote(remoteDir)}`,
|
|
45287
45406
|
`cat > ${shellQuote(remotePath)}`
|
|
@@ -45351,7 +45470,7 @@ function shellQuote(s) {
|
|
|
45351
45470
|
// src/services/providers/gitpod.ts
|
|
45352
45471
|
var import_child_process31 = require("child_process");
|
|
45353
45472
|
var import_util5 = require("util");
|
|
45354
|
-
var
|
|
45473
|
+
var path84 = __toESM(require("path"));
|
|
45355
45474
|
var import_picocolors9 = __toESM(require("picocolors"));
|
|
45356
45475
|
var execFileP6 = (0, import_util5.promisify)(import_child_process31.execFile);
|
|
45357
45476
|
var MAX_BUFFER2 = 8 * 1024 * 1024;
|
|
@@ -45591,7 +45710,7 @@ var GitpodProvider = class {
|
|
|
45591
45710
|
});
|
|
45592
45711
|
}
|
|
45593
45712
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
45594
|
-
const remoteDir =
|
|
45713
|
+
const remoteDir = path84.posix.dirname(remotePath);
|
|
45595
45714
|
const parts = [
|
|
45596
45715
|
`mkdir -p ${shellQuote2(remoteDir)}`,
|
|
45597
45716
|
`cat > ${shellQuote2(remotePath)}`
|
|
@@ -45627,7 +45746,7 @@ function shellQuote2(s) {
|
|
|
45627
45746
|
// src/services/providers/gitlab-workspaces.ts
|
|
45628
45747
|
var import_child_process32 = require("child_process");
|
|
45629
45748
|
var import_util6 = require("util");
|
|
45630
|
-
var
|
|
45749
|
+
var path85 = __toESM(require("path"));
|
|
45631
45750
|
var execFileP7 = (0, import_util6.promisify)(import_child_process32.execFile);
|
|
45632
45751
|
var MAX_BUFFER3 = 8 * 1024 * 1024;
|
|
45633
45752
|
var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
|
|
@@ -45887,7 +46006,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
45887
46006
|
}
|
|
45888
46007
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
45889
46008
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
45890
|
-
const remoteDir =
|
|
46009
|
+
const remoteDir = path85.posix.dirname(remotePath);
|
|
45891
46010
|
const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
|
|
45892
46011
|
if (options.mode != null) {
|
|
45893
46012
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
@@ -45955,7 +46074,7 @@ function shellQuote3(s) {
|
|
|
45955
46074
|
// src/services/providers/railway.ts
|
|
45956
46075
|
var import_child_process33 = require("child_process");
|
|
45957
46076
|
var import_util7 = require("util");
|
|
45958
|
-
var
|
|
46077
|
+
var path86 = __toESM(require("path"));
|
|
45959
46078
|
var execFileP8 = (0, import_util7.promisify)(import_child_process33.execFile);
|
|
45960
46079
|
var MAX_BUFFER4 = 8 * 1024 * 1024;
|
|
45961
46080
|
function resetStdinForChild4() {
|
|
@@ -46191,7 +46310,7 @@ var RailwayProvider = class {
|
|
|
46191
46310
|
if (!projectId || !serviceId) {
|
|
46192
46311
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
46193
46312
|
}
|
|
46194
|
-
const remoteDir =
|
|
46313
|
+
const remoteDir = path86.posix.dirname(remotePath);
|
|
46195
46314
|
const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
|
|
46196
46315
|
if (options.mode != null) {
|
|
46197
46316
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
@@ -46731,9 +46850,9 @@ async function stopWorkspaceFromLocal(target) {
|
|
|
46731
46850
|
}
|
|
46732
46851
|
|
|
46733
46852
|
// src/commands/host/host-client.ts
|
|
46734
|
-
var
|
|
46853
|
+
var fs73 = __toESM(require("fs"));
|
|
46735
46854
|
var os57 = __toESM(require("os"));
|
|
46736
|
-
var
|
|
46855
|
+
var path87 = __toESM(require("path"));
|
|
46737
46856
|
var import_node_crypto11 = require("crypto");
|
|
46738
46857
|
function sampleCpuTimes() {
|
|
46739
46858
|
let idle = 0;
|
|
@@ -46781,7 +46900,7 @@ function apiBase() {
|
|
|
46781
46900
|
return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
|
|
46782
46901
|
}
|
|
46783
46902
|
function hostIdentityPath() {
|
|
46784
|
-
return
|
|
46903
|
+
return path87.join(os57.homedir(), ".codeam", "host-agent.json");
|
|
46785
46904
|
}
|
|
46786
46905
|
function collectOsInfo() {
|
|
46787
46906
|
return {
|
|
@@ -46793,7 +46912,7 @@ function collectOsInfo() {
|
|
|
46793
46912
|
}
|
|
46794
46913
|
function loadHostIdentity() {
|
|
46795
46914
|
try {
|
|
46796
|
-
const raw =
|
|
46915
|
+
const raw = fs73.readFileSync(hostIdentityPath(), "utf8");
|
|
46797
46916
|
const parsed = JSON.parse(raw);
|
|
46798
46917
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
|
|
46799
46918
|
const p2 = parsed;
|
|
@@ -46812,8 +46931,8 @@ function loadHostIdentity() {
|
|
|
46812
46931
|
}
|
|
46813
46932
|
function saveHostIdentity(identity) {
|
|
46814
46933
|
const file = hostIdentityPath();
|
|
46815
|
-
|
|
46816
|
-
|
|
46934
|
+
fs73.mkdirSync(path87.dirname(file), { recursive: true, mode: 448 });
|
|
46935
|
+
fs73.writeFileSync(file, JSON.stringify(identity, null, 2), {
|
|
46817
46936
|
encoding: "utf8",
|
|
46818
46937
|
mode: 384
|
|
46819
46938
|
});
|
|
@@ -46858,7 +46977,7 @@ function isTerminalEnrollError(err) {
|
|
|
46858
46977
|
}
|
|
46859
46978
|
function deleteHostIdentity() {
|
|
46860
46979
|
try {
|
|
46861
|
-
|
|
46980
|
+
fs73.rmSync(hostIdentityPath(), { force: true });
|
|
46862
46981
|
} catch {
|
|
46863
46982
|
}
|
|
46864
46983
|
}
|
|
@@ -47072,8 +47191,8 @@ async function host(args2) {
|
|
|
47072
47191
|
// src/commands/host-agent.ts
|
|
47073
47192
|
var import_node_child_process30 = require("child_process");
|
|
47074
47193
|
var os62 = __toESM(require("os"));
|
|
47075
|
-
var
|
|
47076
|
-
var
|
|
47194
|
+
var fs78 = __toESM(require("fs"));
|
|
47195
|
+
var path92 = __toESM(require("path"));
|
|
47077
47196
|
|
|
47078
47197
|
// src/skills/persist-from-payload.ts
|
|
47079
47198
|
function persistOrClearSkillsFromPayload(skills) {
|
|
@@ -47082,13 +47201,13 @@ function persistOrClearSkillsFromPayload(skills) {
|
|
|
47082
47201
|
}
|
|
47083
47202
|
|
|
47084
47203
|
// src/commands/host/session-state.ts
|
|
47085
|
-
var
|
|
47204
|
+
var fs74 = __toESM(require("fs"));
|
|
47086
47205
|
var os58 = __toESM(require("os"));
|
|
47087
|
-
var
|
|
47206
|
+
var path88 = __toESM(require("path"));
|
|
47088
47207
|
function hostSessionStatePath(env = process.env) {
|
|
47089
47208
|
const override = env.CODEAM_HOST_SESSION_STATE_FILE;
|
|
47090
47209
|
if (override && override.trim()) return override.trim();
|
|
47091
|
-
return
|
|
47210
|
+
return path88.join(os58.homedir(), ".codeam", "host-agent-sessions.json");
|
|
47092
47211
|
}
|
|
47093
47212
|
function isRecord5(v) {
|
|
47094
47213
|
if (typeof v !== "object" || v === null) return false;
|
|
@@ -47099,7 +47218,7 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
47099
47218
|
return {
|
|
47100
47219
|
load() {
|
|
47101
47220
|
try {
|
|
47102
|
-
const raw = JSON.parse(
|
|
47221
|
+
const raw = JSON.parse(fs74.readFileSync(file, "utf8"));
|
|
47103
47222
|
return Array.isArray(raw?.sessions) ? raw.sessions.filter(isRecord5) : [];
|
|
47104
47223
|
} catch {
|
|
47105
47224
|
return [];
|
|
@@ -47107,18 +47226,18 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
47107
47226
|
},
|
|
47108
47227
|
save(list) {
|
|
47109
47228
|
try {
|
|
47110
|
-
|
|
47229
|
+
fs74.mkdirSync(path88.dirname(file), { recursive: true, mode: 448 });
|
|
47111
47230
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
47112
|
-
|
|
47231
|
+
fs74.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
|
|
47113
47232
|
mode: 384
|
|
47114
47233
|
});
|
|
47115
|
-
|
|
47234
|
+
fs74.renameSync(tmp, file);
|
|
47116
47235
|
} catch {
|
|
47117
47236
|
}
|
|
47118
47237
|
},
|
|
47119
47238
|
clear() {
|
|
47120
47239
|
try {
|
|
47121
|
-
|
|
47240
|
+
fs74.rmSync(file, { force: true });
|
|
47122
47241
|
} catch {
|
|
47123
47242
|
}
|
|
47124
47243
|
}
|
|
@@ -47141,9 +47260,9 @@ function planSessionResume(records, max) {
|
|
|
47141
47260
|
return { resume: ordered.slice(0, bound), dropped: ordered.slice(bound) };
|
|
47142
47261
|
}
|
|
47143
47262
|
function pickSavedSessionForWorkspace(sessions3, cwd) {
|
|
47144
|
-
const target =
|
|
47263
|
+
const target = path88.resolve(cwd);
|
|
47145
47264
|
const matches = sessions3.filter(
|
|
47146
|
-
(s) => !!s.cwd &&
|
|
47265
|
+
(s) => !!s.cwd && path88.resolve(s.cwd) === target && !!s.pluginId && !!s.pollSecret && !!s.agent
|
|
47147
47266
|
);
|
|
47148
47267
|
if (matches.length === 0) return null;
|
|
47149
47268
|
matches.sort((a, b) => b.pairedAt - a.pairedAt);
|
|
@@ -47151,25 +47270,25 @@ function pickSavedSessionForWorkspace(sessions3, cwd) {
|
|
|
47151
47270
|
}
|
|
47152
47271
|
|
|
47153
47272
|
// src/commands/host/workspace.ts
|
|
47154
|
-
var
|
|
47273
|
+
var fs75 = __toESM(require("fs"));
|
|
47155
47274
|
var os59 = __toESM(require("os"));
|
|
47156
|
-
var
|
|
47275
|
+
var path89 = __toESM(require("path"));
|
|
47157
47276
|
var import_node_child_process25 = require("child_process");
|
|
47158
47277
|
var import_node_util5 = require("util");
|
|
47159
47278
|
var execFileP9 = (0, import_node_util5.promisify)(import_node_child_process25.execFile);
|
|
47160
47279
|
function isAbsolutePathTarget(target) {
|
|
47161
|
-
return
|
|
47280
|
+
return path89.isAbsolute(target);
|
|
47162
47281
|
}
|
|
47163
47282
|
function selfHostedWorkspaceRoot() {
|
|
47164
|
-
return
|
|
47283
|
+
return path89.join(os59.homedir(), ".codeam", "self-hosted");
|
|
47165
47284
|
}
|
|
47166
47285
|
function deployIdFromWorkspace(cwd) {
|
|
47167
47286
|
if (!cwd) return null;
|
|
47168
47287
|
const root = selfHostedWorkspaceRoot();
|
|
47169
|
-
const resolved =
|
|
47170
|
-
const rel =
|
|
47171
|
-
if (!rel || rel.startsWith("..") ||
|
|
47172
|
-
const parts = rel.split(
|
|
47288
|
+
const resolved = path89.resolve(cwd);
|
|
47289
|
+
const rel = path89.relative(root, resolved);
|
|
47290
|
+
if (!rel || rel.startsWith("..") || path89.isAbsolute(rel)) return null;
|
|
47291
|
+
const parts = rel.split(path89.sep).filter(Boolean);
|
|
47173
47292
|
if (parts.length !== 1) return null;
|
|
47174
47293
|
return parts[0];
|
|
47175
47294
|
}
|
|
@@ -47241,15 +47360,15 @@ async function configureGitCredentials(dest, repoRef, cloneToken, provider = "gi
|
|
|
47241
47360
|
const isGitlab = provider === "gitlab";
|
|
47242
47361
|
if (isGitlab ? !gitlabProjectPath(repoRef.trim()) : !githubOwnerRepo(repoRef.trim())) return;
|
|
47243
47362
|
if (!cloneToken) return;
|
|
47244
|
-
const credFile =
|
|
47363
|
+
const credFile = path89.join(dest, ".git", "codeam-credentials");
|
|
47245
47364
|
const credLine = isGitlab ? `https://oauth2:${cloneToken}@gitlab.com
|
|
47246
47365
|
` : `https://x-access-token:${cloneToken}@github.com
|
|
47247
47366
|
`;
|
|
47248
|
-
|
|
47367
|
+
fs75.writeFileSync(credFile, credLine, { mode: 384 });
|
|
47249
47368
|
restrictToOwner(credFile);
|
|
47250
47369
|
const env = nonInteractiveGitEnv();
|
|
47251
47370
|
const git2 = (args2) => execFileP9("git", ["-C", dest, ...args2], { timeout: 3e4, env });
|
|
47252
|
-
const credFilePosix = credFile.split(
|
|
47371
|
+
const credFilePosix = credFile.split(path89.sep).join("/");
|
|
47253
47372
|
await git2(["config", "--local", "--replace-all", "credential.helper", ""]).catch(() => {
|
|
47254
47373
|
});
|
|
47255
47374
|
await git2([
|
|
@@ -47282,17 +47401,17 @@ function maskToken(text, cloneToken) {
|
|
|
47282
47401
|
}
|
|
47283
47402
|
async function prepareWorkspace(repoOrPath, deployId, cloneToken, provider = "github", branch) {
|
|
47284
47403
|
if (isAbsolutePathTarget(repoOrPath)) {
|
|
47285
|
-
if (!
|
|
47404
|
+
if (!fs75.existsSync(repoOrPath)) {
|
|
47286
47405
|
throw new Error(`deploy target path does not exist: ${repoOrPath}`);
|
|
47287
47406
|
}
|
|
47288
47407
|
return repoOrPath;
|
|
47289
47408
|
}
|
|
47290
|
-
const dest =
|
|
47291
|
-
if (
|
|
47409
|
+
const dest = path89.join(selfHostedWorkspaceRoot(), deployId);
|
|
47410
|
+
if (fs75.existsSync(path89.join(dest, ".git"))) {
|
|
47292
47411
|
if (cloneToken) await configureGitCredentials(dest, repoOrPath, cloneToken, provider);
|
|
47293
47412
|
return dest;
|
|
47294
47413
|
}
|
|
47295
|
-
|
|
47414
|
+
fs75.mkdirSync(selfHostedWorkspaceRoot(), { recursive: true, mode: 448 });
|
|
47296
47415
|
const cloneUrl = repoCloneUrl(repoOrPath, cloneToken, provider);
|
|
47297
47416
|
const cloneArgs = branch ? ["clone", "--depth", "1", "--branch", branch, cloneUrl, dest] : ["clone", "--depth", "1", cloneUrl, dest];
|
|
47298
47417
|
try {
|
|
@@ -47311,11 +47430,11 @@ async function prepareWorkspace(repoOrPath, deployId, cloneToken, provider = "gi
|
|
|
47311
47430
|
|
|
47312
47431
|
// src/commands/host/git-tooling.ts
|
|
47313
47432
|
var import_node_child_process26 = require("child_process");
|
|
47314
|
-
var
|
|
47433
|
+
var fs76 = __toESM(require("fs"));
|
|
47315
47434
|
var os60 = __toESM(require("os"));
|
|
47316
|
-
var
|
|
47435
|
+
var path90 = __toESM(require("path"));
|
|
47317
47436
|
function codeamBinDir() {
|
|
47318
|
-
return process.env.CODEAM_BIN_DIR ??
|
|
47437
|
+
return process.env.CODEAM_BIN_DIR ?? path90.join(os60.homedir(), ".codeam", "bin");
|
|
47319
47438
|
}
|
|
47320
47439
|
var FALLBACK_GH_VERSION = "2.62.0";
|
|
47321
47440
|
var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
|
|
@@ -47347,7 +47466,7 @@ async function download(url2, dest) {
|
|
|
47347
47466
|
const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
|
|
47348
47467
|
if (!res.ok || !res.body) return false;
|
|
47349
47468
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
47350
|
-
|
|
47469
|
+
fs76.writeFileSync(dest, buf);
|
|
47351
47470
|
return true;
|
|
47352
47471
|
} catch {
|
|
47353
47472
|
return false;
|
|
@@ -47370,8 +47489,8 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
47370
47489
|
const version3 = await resolveVersionFn(token);
|
|
47371
47490
|
const asset = `gh_${version3}_${osToken}_${arch2}`;
|
|
47372
47491
|
const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
|
|
47373
|
-
const tmpRoot =
|
|
47374
|
-
const archive =
|
|
47492
|
+
const tmpRoot = fs76.mkdtempSync(path90.join(os60.tmpdir(), "codeam-gh-"));
|
|
47493
|
+
const archive = path90.join(tmpRoot, `${asset}.${ext}`);
|
|
47375
47494
|
if (!await downloadFn(url2, archive)) {
|
|
47376
47495
|
log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
|
|
47377
47496
|
return null;
|
|
@@ -47381,16 +47500,16 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
47381
47500
|
log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
|
|
47382
47501
|
return null;
|
|
47383
47502
|
}
|
|
47384
|
-
const extractedBin =
|
|
47385
|
-
if (!
|
|
47503
|
+
const extractedBin = path90.join(tmpRoot, asset, "bin", binaryName);
|
|
47504
|
+
if (!fs76.existsSync(extractedBin)) {
|
|
47386
47505
|
log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
|
|
47387
47506
|
return null;
|
|
47388
47507
|
}
|
|
47389
47508
|
const binDir = codeamBinDir();
|
|
47390
|
-
|
|
47391
|
-
const target =
|
|
47392
|
-
|
|
47393
|
-
|
|
47509
|
+
fs76.mkdirSync(binDir, { recursive: true });
|
|
47510
|
+
const target = path90.join(binDir, binaryName);
|
|
47511
|
+
fs76.copyFileSync(extractedBin, target);
|
|
47512
|
+
fs76.chmodSync(target, 493);
|
|
47394
47513
|
log.info("host-agent", `gh installed to ${target} (v${version3})`);
|
|
47395
47514
|
return target;
|
|
47396
47515
|
} catch (e) {
|
|
@@ -47427,19 +47546,19 @@ async function ensureGhAuth(runner, ghCmd, token) {
|
|
|
47427
47546
|
}
|
|
47428
47547
|
function ghConfigDir() {
|
|
47429
47548
|
if (process.env.GH_CONFIG_DIR) return process.env.GH_CONFIG_DIR;
|
|
47430
|
-
if (process.env.XDG_CONFIG_HOME) return
|
|
47549
|
+
if (process.env.XDG_CONFIG_HOME) return path90.join(process.env.XDG_CONFIG_HOME, "gh");
|
|
47431
47550
|
if (process.platform === "win32" && process.env.APPDATA) {
|
|
47432
|
-
return
|
|
47551
|
+
return path90.join(process.env.APPDATA, "GitHub CLI");
|
|
47433
47552
|
}
|
|
47434
|
-
return
|
|
47553
|
+
return path90.join(os60.homedir(), ".config", "gh");
|
|
47435
47554
|
}
|
|
47436
47555
|
function writeGhHostsToken(token) {
|
|
47437
47556
|
try {
|
|
47438
47557
|
const dir = ghConfigDir();
|
|
47439
|
-
const file =
|
|
47440
|
-
if (
|
|
47441
|
-
|
|
47442
|
-
|
|
47558
|
+
const file = path90.join(dir, "hosts.yml");
|
|
47559
|
+
if (fs76.existsSync(file)) return false;
|
|
47560
|
+
fs76.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
47561
|
+
fs76.writeFileSync(
|
|
47443
47562
|
file,
|
|
47444
47563
|
`github.com:
|
|
47445
47564
|
oauth_token: ${token}
|
|
@@ -47482,8 +47601,8 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
47482
47601
|
const version3 = await resolveLatestGlabVersion();
|
|
47483
47602
|
const asset = `glab_${version3}_${osToken}_${arch2}`;
|
|
47484
47603
|
const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
|
|
47485
|
-
const tmpRoot =
|
|
47486
|
-
const archive =
|
|
47604
|
+
const tmpRoot = fs76.mkdtempSync(path90.join(os60.tmpdir(), "codeam-glab-"));
|
|
47605
|
+
const archive = path90.join(tmpRoot, `${asset}.${ext}`);
|
|
47487
47606
|
if (!await downloadFn(url2, archive)) {
|
|
47488
47607
|
log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
|
|
47489
47608
|
return null;
|
|
@@ -47494,20 +47613,20 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
47494
47613
|
return null;
|
|
47495
47614
|
}
|
|
47496
47615
|
const candidates = [
|
|
47497
|
-
|
|
47498
|
-
|
|
47499
|
-
|
|
47616
|
+
path90.join(tmpRoot, "bin", binaryName),
|
|
47617
|
+
path90.join(tmpRoot, asset, "bin", binaryName),
|
|
47618
|
+
path90.join(tmpRoot, binaryName)
|
|
47500
47619
|
];
|
|
47501
|
-
const extractedBin = candidates.find((c2) =>
|
|
47620
|
+
const extractedBin = candidates.find((c2) => fs76.existsSync(c2));
|
|
47502
47621
|
if (!extractedBin) {
|
|
47503
47622
|
log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
|
|
47504
47623
|
return null;
|
|
47505
47624
|
}
|
|
47506
47625
|
const binDir = codeamBinDir();
|
|
47507
|
-
|
|
47508
|
-
const target =
|
|
47509
|
-
|
|
47510
|
-
|
|
47626
|
+
fs76.mkdirSync(binDir, { recursive: true });
|
|
47627
|
+
const target = path90.join(binDir, binaryName);
|
|
47628
|
+
fs76.copyFileSync(extractedBin, target);
|
|
47629
|
+
fs76.chmodSync(target, 493);
|
|
47511
47630
|
log.info("host-agent", `glab installed to ${target} (v${version3})`);
|
|
47512
47631
|
return target;
|
|
47513
47632
|
} catch (e) {
|
|
@@ -47589,9 +47708,9 @@ var defaultGitToolingRunner = {
|
|
|
47589
47708
|
var import_node_child_process28 = require("child_process");
|
|
47590
47709
|
|
|
47591
47710
|
// src/lib/updateNotifier.ts
|
|
47592
|
-
var
|
|
47711
|
+
var fs77 = __toESM(require("fs"));
|
|
47593
47712
|
var os61 = __toESM(require("os"));
|
|
47594
|
-
var
|
|
47713
|
+
var path91 = __toESM(require("path"));
|
|
47595
47714
|
var https8 = __toESM(require("https"));
|
|
47596
47715
|
var import_node_child_process27 = require("child_process");
|
|
47597
47716
|
var import_picocolors12 = __toESM(require("picocolors"));
|
|
@@ -47600,12 +47719,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
|
|
|
47600
47719
|
var TTL_MS = 24 * 60 * 60 * 1e3;
|
|
47601
47720
|
var REQUEST_TIMEOUT_MS = 1500;
|
|
47602
47721
|
function cachePath() {
|
|
47603
|
-
const dir =
|
|
47604
|
-
return
|
|
47722
|
+
const dir = path91.join(os61.homedir(), ".codeam");
|
|
47723
|
+
return path91.join(dir, "update-check.json");
|
|
47605
47724
|
}
|
|
47606
47725
|
function readCache() {
|
|
47607
47726
|
try {
|
|
47608
|
-
const raw =
|
|
47727
|
+
const raw = fs77.readFileSync(cachePath(), "utf8");
|
|
47609
47728
|
const parsed = JSON.parse(raw);
|
|
47610
47729
|
if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
|
|
47611
47730
|
return parsed;
|
|
@@ -47616,10 +47735,10 @@ function readCache() {
|
|
|
47616
47735
|
function writeCache(cache) {
|
|
47617
47736
|
try {
|
|
47618
47737
|
const file = cachePath();
|
|
47619
|
-
|
|
47738
|
+
fs77.mkdirSync(path91.dirname(file), { recursive: true });
|
|
47620
47739
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
47621
|
-
|
|
47622
|
-
|
|
47740
|
+
fs77.writeFileSync(tmp, JSON.stringify(cache));
|
|
47741
|
+
fs77.renameSync(tmp, file);
|
|
47623
47742
|
} catch {
|
|
47624
47743
|
}
|
|
47625
47744
|
}
|
|
@@ -47693,8 +47812,8 @@ function isLinkedInstall() {
|
|
|
47693
47812
|
timeout: 2e3
|
|
47694
47813
|
}).trim();
|
|
47695
47814
|
if (!root) return false;
|
|
47696
|
-
const pkgPath =
|
|
47697
|
-
return
|
|
47815
|
+
const pkgPath = path91.join(root, PKG_NAME);
|
|
47816
|
+
return fs77.lstatSync(pkgPath).isSymbolicLink();
|
|
47698
47817
|
} catch {
|
|
47699
47818
|
return false;
|
|
47700
47819
|
}
|
|
@@ -47730,7 +47849,7 @@ function maybeAutoUpdate(currentVersion, latest) {
|
|
|
47730
47849
|
return;
|
|
47731
47850
|
}
|
|
47732
47851
|
try {
|
|
47733
|
-
|
|
47852
|
+
fs77.unlinkSync(cachePath());
|
|
47734
47853
|
} catch {
|
|
47735
47854
|
}
|
|
47736
47855
|
process.stderr.write(` ${import_picocolors12.default.green("\u2713")} Updated. Resuming session...
|
|
@@ -47746,7 +47865,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
47746
47865
|
if (process.env.NODE_ENV === "test") return;
|
|
47747
47866
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
47748
47867
|
if (process.env.CI) return;
|
|
47749
|
-
const current2 = true ? "2.75.
|
|
47868
|
+
const current2 = true ? "2.75.25" : null;
|
|
47750
47869
|
if (!current2) return;
|
|
47751
47870
|
const cache = readCache();
|
|
47752
47871
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -47763,7 +47882,7 @@ function checkForUpdates() {
|
|
|
47763
47882
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
47764
47883
|
if (process.env.CI) return;
|
|
47765
47884
|
if (!process.stdout.isTTY) return;
|
|
47766
|
-
const current2 = true ? "2.75.
|
|
47885
|
+
const current2 = true ? "2.75.25" : null;
|
|
47767
47886
|
if (!current2) return;
|
|
47768
47887
|
const cache = readCache();
|
|
47769
47888
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -47786,7 +47905,7 @@ var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
|
47786
47905
|
var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
|
|
47787
47906
|
var SUDO_PREFLIGHT_TIMEOUT_MS = 5e3;
|
|
47788
47907
|
function currentCliVersion() {
|
|
47789
|
-
return true ? "2.75.
|
|
47908
|
+
return true ? "2.75.25" : null;
|
|
47790
47909
|
}
|
|
47791
47910
|
async function installedVersion(deps) {
|
|
47792
47911
|
const ls = await deps.run(
|
|
@@ -48519,13 +48638,13 @@ var HostAgentSupervisor = class {
|
|
|
48519
48638
|
const relay = this.relay;
|
|
48520
48639
|
if (!relay) return;
|
|
48521
48640
|
const raw = cmd.payload?.path;
|
|
48522
|
-
const target = typeof raw === "string" && raw.trim() ?
|
|
48641
|
+
const target = typeof raw === "string" && raw.trim() ? path92.resolve(raw.trim()) : os62.homedir();
|
|
48523
48642
|
try {
|
|
48524
|
-
const dirents = await
|
|
48643
|
+
const dirents = await fs78.promises.readdir(target, { withFileTypes: true });
|
|
48525
48644
|
const entries = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
|
|
48526
48645
|
(a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
|
|
48527
48646
|
);
|
|
48528
|
-
const parent =
|
|
48647
|
+
const parent = path92.dirname(target);
|
|
48529
48648
|
await relay.sendResult(cmd.id, "completed", {
|
|
48530
48649
|
path: target,
|
|
48531
48650
|
// null at the filesystem root so the UI can hide the ".." affordance.
|
|
@@ -48872,14 +48991,14 @@ var HostAgentSupervisor = class {
|
|
|
48872
48991
|
...buildHouseProxyChildEnv({ baseUrl, token, openRouter: openRouter === true }),
|
|
48873
48992
|
CODEAM_AUTO_TOKEN: payload.autoPairToken
|
|
48874
48993
|
};
|
|
48875
|
-
const houseConfigDir =
|
|
48994
|
+
const houseConfigDir = path92.join(
|
|
48876
48995
|
os62.homedir(),
|
|
48877
48996
|
".codeam",
|
|
48878
48997
|
"house-claude",
|
|
48879
48998
|
payload.deployId
|
|
48880
48999
|
);
|
|
48881
49000
|
try {
|
|
48882
|
-
|
|
49001
|
+
fs78.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
|
|
48883
49002
|
} catch {
|
|
48884
49003
|
}
|
|
48885
49004
|
childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
|
|
@@ -48913,13 +49032,13 @@ var HostAgentSupervisor = class {
|
|
|
48913
49032
|
if ((payload.repoProvider ?? "github") === "gitlab") {
|
|
48914
49033
|
const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
|
|
48915
49034
|
if (glabCmd) {
|
|
48916
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
49035
|
+
childEnv.PATH = `${codeamBinDir()}${path92.delimiter}${childEnv.PATH}`;
|
|
48917
49036
|
await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
|
|
48918
49037
|
}
|
|
48919
49038
|
} else {
|
|
48920
49039
|
const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
|
|
48921
49040
|
if (ghCmd) {
|
|
48922
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
49041
|
+
childEnv.PATH = `${codeamBinDir()}${path92.delimiter}${childEnv.PATH}`;
|
|
48923
49042
|
await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
|
|
48924
49043
|
}
|
|
48925
49044
|
}
|
|
@@ -48947,9 +49066,9 @@ var HostAgentSupervisor = class {
|
|
|
48947
49066
|
);
|
|
48948
49067
|
if (!payload.suppressOnboardingWelcome) {
|
|
48949
49068
|
try {
|
|
48950
|
-
const cfgDir = childEnv.CLAUDE_CONFIG_DIR ||
|
|
48951
|
-
const projectDir =
|
|
48952
|
-
const hasPriorConversation =
|
|
49069
|
+
const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path92.join(os62.homedir(), ".claude");
|
|
49070
|
+
const projectDir = path92.join(cfgDir, "projects", encodeCwd(cwd));
|
|
49071
|
+
const hasPriorConversation = fs78.existsSync(projectDir) && fs78.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
|
|
48953
49072
|
if (hasPriorConversation) {
|
|
48954
49073
|
childEnv.CODEAM_RESUME_LATEST = "1";
|
|
48955
49074
|
log.info(
|
|
@@ -49100,7 +49219,7 @@ var HostAgentSupervisor = class {
|
|
|
49100
49219
|
fallbackResumeTarget() {
|
|
49101
49220
|
const session = getActiveSession();
|
|
49102
49221
|
if (!session || !session.pluginId || !session.pollSecret || !session.agent) return null;
|
|
49103
|
-
const cwd = session.cwd &&
|
|
49222
|
+
const cwd = session.cwd && fs78.existsSync(session.cwd) ? session.cwd : process.cwd();
|
|
49104
49223
|
const deployId = deployIdFromWorkspace(session.cwd) ?? session.id;
|
|
49105
49224
|
return { deployId, cwd, session };
|
|
49106
49225
|
}
|
|
@@ -49120,7 +49239,7 @@ var HostAgentSupervisor = class {
|
|
|
49120
49239
|
if (this.children.has(deployId)) return;
|
|
49121
49240
|
const st3 = this.resumeStateFor(target);
|
|
49122
49241
|
try {
|
|
49123
|
-
const cwd =
|
|
49242
|
+
const cwd = fs78.existsSync(target.cwd) ? target.cwd : process.cwd();
|
|
49124
49243
|
const proc = this.resumeSpawner(
|
|
49125
49244
|
{ ...readHouseProxyChildEnv(), CODEAM_RESUME_SESSION_ID: session.id },
|
|
49126
49245
|
cwd
|
|
@@ -49338,12 +49457,12 @@ var HostAgentSupervisor = class {
|
|
|
49338
49457
|
this.untrackChild(deployId);
|
|
49339
49458
|
}
|
|
49340
49459
|
const dirs = [
|
|
49341
|
-
|
|
49342
|
-
|
|
49460
|
+
path92.join(selfHostedWorkspaceRoot(), deployId),
|
|
49461
|
+
path92.join(os62.homedir(), ".codeam", "house-claude", deployId)
|
|
49343
49462
|
];
|
|
49344
49463
|
for (const dir of dirs) {
|
|
49345
49464
|
try {
|
|
49346
|
-
|
|
49465
|
+
fs78.rmSync(dir, { recursive: true, force: true });
|
|
49347
49466
|
} catch (err) {
|
|
49348
49467
|
log.warn(
|
|
49349
49468
|
"host-agent",
|
|
@@ -49503,8 +49622,8 @@ async function invite() {
|
|
|
49503
49622
|
var import_node_dns = require("dns");
|
|
49504
49623
|
var import_node_util6 = require("util");
|
|
49505
49624
|
var import_node_crypto12 = require("crypto");
|
|
49506
|
-
var
|
|
49507
|
-
var
|
|
49625
|
+
var fs79 = __toESM(require("fs"));
|
|
49626
|
+
var path93 = __toESM(require("path"));
|
|
49508
49627
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
49509
49628
|
var dnsResolveP = (0, import_node_util6.promisify)(import_node_dns.resolve);
|
|
49510
49629
|
async function checkDns(apiBase2) {
|
|
@@ -49560,13 +49679,13 @@ async function checkHealth(apiBase2) {
|
|
|
49560
49679
|
}
|
|
49561
49680
|
}
|
|
49562
49681
|
function checkConfigDir() {
|
|
49563
|
-
const dir =
|
|
49682
|
+
const dir = path93.join(require("os").homedir(), ".codeam");
|
|
49564
49683
|
try {
|
|
49565
|
-
|
|
49566
|
-
const probe =
|
|
49567
|
-
|
|
49568
|
-
const read =
|
|
49569
|
-
|
|
49684
|
+
fs79.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
49685
|
+
const probe = path93.join(dir, ".doctor-probe");
|
|
49686
|
+
fs79.writeFileSync(probe, "ok", { mode: 384 });
|
|
49687
|
+
const read = fs79.readFileSync(probe, "utf8");
|
|
49688
|
+
fs79.unlinkSync(probe);
|
|
49570
49689
|
if (read !== "ok") throw new Error("write/read round-trip mismatch");
|
|
49571
49690
|
return {
|
|
49572
49691
|
id: "config-dir",
|
|
@@ -49630,7 +49749,7 @@ function checkNodePty() {
|
|
|
49630
49749
|
detail: "not required on this platform"
|
|
49631
49750
|
};
|
|
49632
49751
|
}
|
|
49633
|
-
const vendoredPath =
|
|
49752
|
+
const vendoredPath = path93.join(__dirname, "vendor", "node-pty");
|
|
49634
49753
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
49635
49754
|
try {
|
|
49636
49755
|
require(target);
|
|
@@ -49672,7 +49791,7 @@ function checkChokidar() {
|
|
|
49672
49791
|
}
|
|
49673
49792
|
async function doctor(args2 = []) {
|
|
49674
49793
|
const json = args2.includes("--json");
|
|
49675
|
-
const cliVersion = true ? "2.75.
|
|
49794
|
+
const cliVersion = true ? "2.75.25" : "0.0.0-dev";
|
|
49676
49795
|
const apiBase2 = resolveApiBaseUrl();
|
|
49677
49796
|
const diagnosticId = (0, import_node_crypto12.randomUUID)();
|
|
49678
49797
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
@@ -50196,7 +50315,7 @@ async function mcpWarm(argv = [], opts = {}) {
|
|
|
50196
50315
|
// src/commands/version.ts
|
|
50197
50316
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
50198
50317
|
function version2() {
|
|
50199
|
-
const v = true ? "2.75.
|
|
50318
|
+
const v = true ? "2.75.25" : "unknown";
|
|
50200
50319
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
50201
50320
|
}
|
|
50202
50321
|
|