codeam-cli 2.76.8 → 2.76.10
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 +25 -0
- package/dist/index.js +634 -535
- 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 = path107.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "convex.cmd" : "convex");
|
|
361
|
+
if (fs93.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_process37,
|
|
492
|
+
var import_node_child_process37, fs93, path107, 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_process37 = require("child_process");
|
|
497
|
-
|
|
498
|
-
|
|
497
|
+
fs93 = __toESM(require("fs"));
|
|
498
|
+
path107 = __toESM(require("path"));
|
|
499
499
|
TOOLS = [
|
|
500
500
|
{
|
|
501
501
|
name: "tables",
|
|
@@ -3595,11 +3595,11 @@ function quiet(fn) {
|
|
|
3595
3595
|
log.debug(TAG, "ignored sync error", err);
|
|
3596
3596
|
}
|
|
3597
3597
|
}
|
|
3598
|
-
function rmIfExistsQuiet(
|
|
3598
|
+
function rmIfExistsQuiet(path109) {
|
|
3599
3599
|
try {
|
|
3600
|
-
fs2.rmSync(
|
|
3600
|
+
fs2.rmSync(path109, { force: true });
|
|
3601
3601
|
} catch (err) {
|
|
3602
|
-
log.debug(TAG, `rmIfExists failed for ${
|
|
3602
|
+
log.debug(TAG, `rmIfExists failed for ${path109}`, err);
|
|
3603
3603
|
}
|
|
3604
3604
|
}
|
|
3605
3605
|
function killQuiet(target, signal = "SIGTERM") {
|
|
@@ -3765,9 +3765,9 @@ var _default = makeConfig();
|
|
|
3765
3765
|
var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, setSessionAgent, setSquadAuto, getSquadAuto, clearAll, saveCliConfig, loadCliConfig } = _default;
|
|
3766
3766
|
|
|
3767
3767
|
// src/commands/pair-auto.ts
|
|
3768
|
-
var
|
|
3768
|
+
var fs64 = __toESM(require("fs"));
|
|
3769
3769
|
var os47 = __toESM(require("os"));
|
|
3770
|
-
var
|
|
3770
|
+
var path73 = __toESM(require("path"));
|
|
3771
3771
|
var import_crypto4 = require("crypto");
|
|
3772
3772
|
|
|
3773
3773
|
// src/services/telemetry.service.ts
|
|
@@ -3803,8 +3803,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
|
|
|
3803
3803
|
return decodedFile;
|
|
3804
3804
|
};
|
|
3805
3805
|
}
|
|
3806
|
-
function normalizeWindowsPath(
|
|
3807
|
-
return
|
|
3806
|
+
function normalizeWindowsPath(path109) {
|
|
3807
|
+
return path109.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
3808
3808
|
}
|
|
3809
3809
|
|
|
3810
3810
|
// ../../node_modules/@posthog/core/dist/error-tracking/index.mjs
|
|
@@ -6537,13 +6537,13 @@ var PostHogCoreStateless = class {
|
|
|
6537
6537
|
sentFromRoute += batchMessages.length;
|
|
6538
6538
|
}
|
|
6539
6539
|
}
|
|
6540
|
-
async _sendOtlpBatch({ path:
|
|
6540
|
+
async _sendOtlpBatch({ path: path109, payload }) {
|
|
6541
6541
|
if (this.disabled) return {
|
|
6542
6542
|
kind: "fatal",
|
|
6543
6543
|
error: new Error("The client is disabled")
|
|
6544
6544
|
};
|
|
6545
6545
|
const serialized = JSON.stringify(payload);
|
|
6546
|
-
const url2 = `${this.host}/i/v1/${
|
|
6546
|
+
const url2 = `${this.host}/i/v1/${path109}?token=${encodeURIComponent(this.apiKey)}`;
|
|
6547
6547
|
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
|
|
6548
6548
|
const fetchOptions = {
|
|
6549
6549
|
method: "POST",
|
|
@@ -7783,14 +7783,14 @@ async function addSourceContext(frames, openSourceFile = import_promises.open, l
|
|
|
7783
7783
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
7784
7784
|
return frames;
|
|
7785
7785
|
}
|
|
7786
|
-
async function openRegularSourceFile(
|
|
7786
|
+
async function openRegularSourceFile(path109, openSourceFile, logger) {
|
|
7787
7787
|
let fileHandle;
|
|
7788
7788
|
let isValid = false;
|
|
7789
7789
|
try {
|
|
7790
|
-
fileHandle = await openSourceFile(
|
|
7790
|
+
fileHandle = await openSourceFile(path109, import_node_fs.constants.O_RDONLY | import_node_fs.constants.O_NONBLOCK);
|
|
7791
7791
|
const fileStat = await fileHandle.stat();
|
|
7792
7792
|
if (!fileStat.isFile()) return;
|
|
7793
|
-
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${
|
|
7793
|
+
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${path109}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
|
|
7794
7794
|
isValid = true;
|
|
7795
7795
|
return fileHandle;
|
|
7796
7796
|
} catch {
|
|
@@ -7800,8 +7800,8 @@ async function openRegularSourceFile(path108, openSourceFile, logger) {
|
|
|
7800
7800
|
});
|
|
7801
7801
|
}
|
|
7802
7802
|
}
|
|
7803
|
-
async function getContextLinesFromFile(
|
|
7804
|
-
const fileHandle = await openRegularSourceFile(
|
|
7803
|
+
async function getContextLinesFromFile(path109, ranges, output, cacheKey, openSourceFile, logger) {
|
|
7804
|
+
const fileHandle = await openRegularSourceFile(path109, openSourceFile, logger);
|
|
7805
7805
|
if (void 0 === fileHandle) return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
7806
7806
|
const openedFileHandle = fileHandle;
|
|
7807
7807
|
return new Promise((resolve12) => {
|
|
@@ -7903,22 +7903,22 @@ function clearLineContext(frame) {
|
|
|
7903
7903
|
delete frame.context_line;
|
|
7904
7904
|
delete frame.post_context;
|
|
7905
7905
|
}
|
|
7906
|
-
function shouldSkipContextLinesForFile(
|
|
7907
|
-
return
|
|
7906
|
+
function shouldSkipContextLinesForFile(path109) {
|
|
7907
|
+
return path109.startsWith("node:") || path109.endsWith(".min.js") || path109.endsWith(".min.cjs") || path109.endsWith(".min.mjs") || path109.startsWith("data:");
|
|
7908
7908
|
}
|
|
7909
7909
|
function shouldSkipContextLinesForFrame(frame) {
|
|
7910
7910
|
if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
|
|
7911
7911
|
if (void 0 !== frame.colno && frame.colno > MAX_CONTEXTLINES_COLNO) return true;
|
|
7912
7912
|
return false;
|
|
7913
7913
|
}
|
|
7914
|
-
function makeSourceCacheKey(
|
|
7915
|
-
if ((0, import_node_path.isAbsolute)(
|
|
7914
|
+
function makeSourceCacheKey(path109, basePath) {
|
|
7915
|
+
if ((0, import_node_path.isAbsolute)(path109)) return JSON.stringify([
|
|
7916
7916
|
null,
|
|
7917
|
-
|
|
7917
|
+
path109
|
|
7918
7918
|
]);
|
|
7919
7919
|
return void 0 === basePath ? void 0 : JSON.stringify([
|
|
7920
7920
|
basePath,
|
|
7921
|
-
|
|
7921
|
+
path109
|
|
7922
7922
|
]);
|
|
7923
7923
|
}
|
|
7924
7924
|
function rangeExistsInContentCache(cacheKey, range) {
|
|
@@ -10579,7 +10579,7 @@ function readAnonId() {
|
|
|
10579
10579
|
}
|
|
10580
10580
|
function superProperties() {
|
|
10581
10581
|
return {
|
|
10582
|
-
cliVersion: true ? "2.76.
|
|
10582
|
+
cliVersion: true ? "2.76.10" : "0.0.0-dev",
|
|
10583
10583
|
nodeVersion: process.version,
|
|
10584
10584
|
platform: process.platform,
|
|
10585
10585
|
arch: process.arch,
|
|
@@ -10824,7 +10824,7 @@ var http = __toESM(require("http"));
|
|
|
10824
10824
|
// package.json
|
|
10825
10825
|
var package_default = {
|
|
10826
10826
|
name: "codeam-cli",
|
|
10827
|
-
version: "2.76.
|
|
10827
|
+
version: "2.76.10",
|
|
10828
10828
|
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.",
|
|
10829
10829
|
type: "commonjs",
|
|
10830
10830
|
main: "dist/index.js",
|
|
@@ -12160,7 +12160,7 @@ var CommandRelayService = class _CommandRelayService {
|
|
|
12160
12160
|
// fresh + clear the "CLI update available" banner after a self-update
|
|
12161
12161
|
// (a codespace that reinstalls @latest reconnects via heartbeat, not
|
|
12162
12162
|
// pair/reconnect). Older backends ignore the extra field.
|
|
12163
|
-
..."2.76.
|
|
12163
|
+
..."2.76.10" ? { ideVersion: "2.76.10" } : {}
|
|
12164
12164
|
};
|
|
12165
12165
|
try {
|
|
12166
12166
|
const res = await _postJson(`${API_BASE2}/api/plugin/heartbeat`, body);
|
|
@@ -13636,9 +13636,9 @@ function closeAllTerminals() {
|
|
|
13636
13636
|
}
|
|
13637
13637
|
|
|
13638
13638
|
// src/commands/start/handlers.ts
|
|
13639
|
-
var
|
|
13639
|
+
var fs63 = __toESM(require("fs"));
|
|
13640
13640
|
var os46 = __toESM(require("os"));
|
|
13641
|
-
var
|
|
13641
|
+
var path72 = __toESM(require("path"));
|
|
13642
13642
|
var import_crypto3 = require("crypto");
|
|
13643
13643
|
var import_child_process25 = require("child_process");
|
|
13644
13644
|
|
|
@@ -19775,8 +19775,8 @@ function pickLine(obj) {
|
|
|
19775
19775
|
function toHunk(raw, groupSeverity) {
|
|
19776
19776
|
if (!raw || typeof raw !== "object") return null;
|
|
19777
19777
|
const o = raw;
|
|
19778
|
-
const
|
|
19779
|
-
if (!
|
|
19778
|
+
const path109 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
|
|
19779
|
+
if (!path109) return null;
|
|
19780
19780
|
const message = asString(
|
|
19781
19781
|
pick(o, [
|
|
19782
19782
|
"comment",
|
|
@@ -19793,7 +19793,7 @@ function toHunk(raw, groupSeverity) {
|
|
|
19793
19793
|
const severity = normSeverity(pick(o, ["severity", "level", "priority", "impact"])) ?? normSeverity(groupSeverity);
|
|
19794
19794
|
const locObj = pick(o, ["location"]) ?? o;
|
|
19795
19795
|
return {
|
|
19796
|
-
path:
|
|
19796
|
+
path: path109.trim(),
|
|
19797
19797
|
line: pickLine(o) ?? pickLine(locObj),
|
|
19798
19798
|
severity,
|
|
19799
19799
|
message: (title && message ? `${title}: ${message}` : title || message).trim() || "(no message)"
|
|
@@ -19876,10 +19876,10 @@ function parsePlain(stdout) {
|
|
|
19876
19876
|
for (const line of stdout.split(/\r?\n/)) {
|
|
19877
19877
|
const m = line.match(HUNK_LINE_RE);
|
|
19878
19878
|
if (!m) continue;
|
|
19879
|
-
const [,
|
|
19880
|
-
if (!
|
|
19879
|
+
const [, path109, lineNo, sevToken, message] = m;
|
|
19880
|
+
if (!path109 || !lineNo || !message) continue;
|
|
19881
19881
|
hunks.push({
|
|
19882
|
-
path:
|
|
19882
|
+
path: path109.trim(),
|
|
19883
19883
|
line: Number(lineNo),
|
|
19884
19884
|
severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
|
|
19885
19885
|
message: message.trim().replace(/^[*-]\s+/, "")
|
|
@@ -23621,9 +23621,9 @@ var healRestartCounts = /* @__PURE__ */ new Map();
|
|
|
23621
23621
|
function resetBuildHealState(sessionId) {
|
|
23622
23622
|
healRestartCounts.delete(sessionId);
|
|
23623
23623
|
}
|
|
23624
|
-
function readMarker2(
|
|
23624
|
+
function readMarker2(markerPath5) {
|
|
23625
23625
|
try {
|
|
23626
|
-
return fs42.readFileSync(
|
|
23626
|
+
return fs42.readFileSync(markerPath5, "utf8").trim();
|
|
23627
23627
|
} catch {
|
|
23628
23628
|
return null;
|
|
23629
23629
|
}
|
|
@@ -23633,12 +23633,12 @@ function watchForBuildClobber(deps) {
|
|
|
23633
23633
|
const debounceMs = deps.debounceMs ?? DEFAULT_DEBOUNCE_MS;
|
|
23634
23634
|
const maxRestarts = deps.maxRestarts ?? DEFAULT_MAX_RESTARTS;
|
|
23635
23635
|
const nextDir = path49.join(deps.cwd, ".next");
|
|
23636
|
-
const
|
|
23636
|
+
const markerPath5 = path49.join(nextDir, BUILD_MARKER_NAME);
|
|
23637
23637
|
let stopped = false;
|
|
23638
23638
|
let debounceTimer = null;
|
|
23639
23639
|
let dirUnwatch = null;
|
|
23640
23640
|
let cwdUnwatch = null;
|
|
23641
|
-
let lastKnownMarker = readMarker2(
|
|
23641
|
+
let lastKnownMarker = readMarker2(markerPath5);
|
|
23642
23642
|
const stop = () => {
|
|
23643
23643
|
if (stopped) return;
|
|
23644
23644
|
stopped = true;
|
|
@@ -23653,7 +23653,7 @@ function watchForBuildClobber(deps) {
|
|
|
23653
23653
|
};
|
|
23654
23654
|
const onDebouncedClobber = () => {
|
|
23655
23655
|
if (stopped) return;
|
|
23656
|
-
const current2 = readMarker2(
|
|
23656
|
+
const current2 = readMarker2(markerPath5);
|
|
23657
23657
|
if (current2 === lastKnownMarker) return;
|
|
23658
23658
|
lastKnownMarker = current2;
|
|
23659
23659
|
const count = (healRestartCounts.get(deps.sessionId) ?? 0) + 1;
|
|
@@ -23671,7 +23671,7 @@ function watchForBuildClobber(deps) {
|
|
|
23671
23671
|
}
|
|
23672
23672
|
log.info(
|
|
23673
23673
|
"preview",
|
|
23674
|
-
`build-heal: ${
|
|
23674
|
+
`build-heal: ${markerPath5} changed (a build likely ran) \u2014 restarting the dev server (${count}/${maxRestarts})`
|
|
23675
23675
|
);
|
|
23676
23676
|
deps.notify("Rebuilt \u2014 restarting preview");
|
|
23677
23677
|
deps.restart();
|
|
@@ -23686,7 +23686,7 @@ function watchForBuildClobber(deps) {
|
|
|
23686
23686
|
};
|
|
23687
23687
|
const attachDirWatch = () => {
|
|
23688
23688
|
if (dirUnwatch) return;
|
|
23689
|
-
lastKnownMarker = readMarker2(
|
|
23689
|
+
lastKnownMarker = readMarker2(markerPath5);
|
|
23690
23690
|
dirUnwatch = watchDir(nextDir, (filename) => {
|
|
23691
23691
|
if (filename === null || filename === BUILD_MARKER_NAME) onMarkerTouched();
|
|
23692
23692
|
});
|
|
@@ -25130,19 +25130,90 @@ async function saveToProviderH(ctx, provider) {
|
|
|
25130
25130
|
}
|
|
25131
25131
|
}
|
|
25132
25132
|
|
|
25133
|
+
// src/scratch/auto-preview.ts
|
|
25134
|
+
var import_node_fs14 = __toESM(require("fs"));
|
|
25135
|
+
var import_node_path12 = __toESM(require("path"));
|
|
25136
|
+
var SERVABLE_ROOT_FILES = /* @__PURE__ */ new Set([
|
|
25137
|
+
"package.json",
|
|
25138
|
+
"requirements.txt",
|
|
25139
|
+
"pyproject.toml",
|
|
25140
|
+
"manage.py",
|
|
25141
|
+
"app.py",
|
|
25142
|
+
"main.py",
|
|
25143
|
+
"Gemfile",
|
|
25144
|
+
"go.mod",
|
|
25145
|
+
"Cargo.toml",
|
|
25146
|
+
"composer.json"
|
|
25147
|
+
]);
|
|
25148
|
+
var AGENT_NOTES = /* @__PURE__ */ new Set(["CLAUDE.md", "AGENTS.md", "GEMINI.md"]);
|
|
25149
|
+
function rootEntries(cwd) {
|
|
25150
|
+
try {
|
|
25151
|
+
return import_node_fs14.default.readdirSync(cwd);
|
|
25152
|
+
} catch {
|
|
25153
|
+
return null;
|
|
25154
|
+
}
|
|
25155
|
+
}
|
|
25156
|
+
function hasServableProject(cwd) {
|
|
25157
|
+
const entries2 = rootEntries(cwd);
|
|
25158
|
+
if (!entries2) return false;
|
|
25159
|
+
if (entries2.some((e) => SERVABLE_ROOT_FILES.has(e) || /\.html?$/i.test(e))) return true;
|
|
25160
|
+
return ["public", "src", "dist", "build"].some(
|
|
25161
|
+
(dir) => import_node_fs14.default.existsSync(import_node_path12.default.join(cwd, dir, "index.html"))
|
|
25162
|
+
);
|
|
25163
|
+
}
|
|
25164
|
+
function isEmptyScratchProject(cwd) {
|
|
25165
|
+
if (!isScratchWorkspace(cwd)) return false;
|
|
25166
|
+
const entries2 = rootEntries(cwd);
|
|
25167
|
+
return entries2 !== null && entries2.every((e) => e.startsWith(".") || AGENT_NOTES.has(e));
|
|
25168
|
+
}
|
|
25169
|
+
var bringUps = /* @__PURE__ */ new Set();
|
|
25170
|
+
var AUTO_PREVIEW_MARKER = import_node_path12.default.join(".codeam", "auto-preview-state.json");
|
|
25171
|
+
function markerPath2(cwd) {
|
|
25172
|
+
return import_node_path12.default.join(cwd, AUTO_PREVIEW_MARKER);
|
|
25173
|
+
}
|
|
25174
|
+
function hasAttemptedMarker(cwd) {
|
|
25175
|
+
try {
|
|
25176
|
+
return import_node_fs14.default.existsSync(markerPath2(cwd));
|
|
25177
|
+
} catch {
|
|
25178
|
+
return false;
|
|
25179
|
+
}
|
|
25180
|
+
}
|
|
25181
|
+
function writeAttemptedMarker(cwd) {
|
|
25182
|
+
try {
|
|
25183
|
+
const file = markerPath2(cwd);
|
|
25184
|
+
import_node_fs14.default.mkdirSync(import_node_path12.default.dirname(file), { recursive: true });
|
|
25185
|
+
import_node_fs14.default.writeFileSync(file, '{"attempted":true}\n', "utf-8");
|
|
25186
|
+
} catch {
|
|
25187
|
+
}
|
|
25188
|
+
}
|
|
25189
|
+
function notePreviewBringUp(sessionId, cwd = process.cwd()) {
|
|
25190
|
+
bringUps.add(sessionId);
|
|
25191
|
+
if (isScratchWorkspace(cwd)) writeAttemptedMarker(cwd);
|
|
25192
|
+
}
|
|
25193
|
+
function maybeAutoOpenScratchPreview(sessionId, bridge, cwd = process.cwd()) {
|
|
25194
|
+
if (!isScratchWorkspace(cwd) || bringUps.has(sessionId) || hasAttemptedMarker(cwd)) return false;
|
|
25195
|
+
if (bridge.status().status !== "idle") return false;
|
|
25196
|
+
if (!hasServableProject(cwd)) return false;
|
|
25197
|
+
bringUps.add(sessionId);
|
|
25198
|
+
writeAttemptedMarker(cwd);
|
|
25199
|
+
void bridge.start().catch(() => {
|
|
25200
|
+
});
|
|
25201
|
+
return true;
|
|
25202
|
+
}
|
|
25203
|
+
|
|
25133
25204
|
// src/services/preview/active-marker.ts
|
|
25134
25205
|
var import_node_crypto11 = require("crypto");
|
|
25135
25206
|
var import_promises5 = __toESM(require("fs/promises"));
|
|
25136
25207
|
var import_node_os7 = __toESM(require("os"));
|
|
25137
|
-
var
|
|
25138
|
-
function
|
|
25139
|
-
const key = (0, import_node_crypto11.createHash)("sha256").update(
|
|
25140
|
-
return
|
|
25208
|
+
var import_node_path13 = __toESM(require("path"));
|
|
25209
|
+
function markerPath3(cwd, homeDir2 = import_node_os7.default.homedir()) {
|
|
25210
|
+
const key = (0, import_node_crypto11.createHash)("sha256").update(import_node_path13.default.resolve(cwd)).digest("hex").slice(0, 16);
|
|
25211
|
+
return import_node_path13.default.join(homeDir2, ".codeam", "preview-active", `${key}.json`);
|
|
25141
25212
|
}
|
|
25142
25213
|
async function writeActivePreviewMarker(cwd, detection, homeDir2) {
|
|
25143
25214
|
try {
|
|
25144
|
-
const file =
|
|
25145
|
-
await import_promises5.default.mkdir(
|
|
25215
|
+
const file = markerPath3(cwd, homeDir2);
|
|
25216
|
+
await import_promises5.default.mkdir(import_node_path13.default.dirname(file), { recursive: true });
|
|
25146
25217
|
await import_promises5.default.writeFile(
|
|
25147
25218
|
file,
|
|
25148
25219
|
JSON.stringify({ detection, at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2) + "\n",
|
|
@@ -25152,11 +25223,11 @@ async function writeActivePreviewMarker(cwd, detection, homeDir2) {
|
|
|
25152
25223
|
}
|
|
25153
25224
|
}
|
|
25154
25225
|
async function clearActivePreviewMarker(cwd, homeDir2) {
|
|
25155
|
-
await import_promises5.default.rm(
|
|
25226
|
+
await import_promises5.default.rm(markerPath3(cwd, homeDir2), { force: true }).catch(() => void 0);
|
|
25156
25227
|
}
|
|
25157
25228
|
async function readActivePreviewMarker(cwd, homeDir2) {
|
|
25158
25229
|
try {
|
|
25159
|
-
const raw = await import_promises5.default.readFile(
|
|
25230
|
+
const raw = await import_promises5.default.readFile(markerPath3(cwd, homeDir2), "utf8");
|
|
25160
25231
|
const parsed = JSON.parse(raw);
|
|
25161
25232
|
return parsed.detection && typeof parsed.detection.command === "string" ? parsed.detection : null;
|
|
25162
25233
|
} catch {
|
|
@@ -25165,16 +25236,16 @@ async function readActivePreviewMarker(cwd, homeDir2) {
|
|
|
25165
25236
|
}
|
|
25166
25237
|
|
|
25167
25238
|
// src/agents/acp/guardrail-config.ts
|
|
25168
|
-
var
|
|
25169
|
-
var
|
|
25239
|
+
var fs51 = __toESM(require("fs"));
|
|
25240
|
+
var path59 = __toESM(require("path"));
|
|
25170
25241
|
var os36 = __toESM(require("os"));
|
|
25171
25242
|
var current = null;
|
|
25172
25243
|
function guardrailConfigPath(homeDir2 = os36.homedir()) {
|
|
25173
|
-
return
|
|
25244
|
+
return path59.join(homeDir2, ".codeam", "guardrails.json");
|
|
25174
25245
|
}
|
|
25175
25246
|
function loadGuardrailPolicy(homeDir2 = os36.homedir()) {
|
|
25176
25247
|
try {
|
|
25177
|
-
current = normalizeGuardrailPolicy(JSON.parse(
|
|
25248
|
+
current = normalizeGuardrailPolicy(JSON.parse(fs51.readFileSync(guardrailConfigPath(homeDir2), "utf8")));
|
|
25178
25249
|
} catch {
|
|
25179
25250
|
current = { ...DEFAULT_GUARDRAIL_POLICY };
|
|
25180
25251
|
}
|
|
@@ -25188,8 +25259,8 @@ function setGuardrailPolicy(raw, homeDir2 = os36.homedir()) {
|
|
|
25188
25259
|
current = next;
|
|
25189
25260
|
try {
|
|
25190
25261
|
const p2 = guardrailConfigPath(homeDir2);
|
|
25191
|
-
|
|
25192
|
-
|
|
25262
|
+
fs51.mkdirSync(path59.dirname(p2), { recursive: true });
|
|
25263
|
+
fs51.writeFileSync(p2, JSON.stringify(next, null, 2));
|
|
25193
25264
|
} catch {
|
|
25194
25265
|
}
|
|
25195
25266
|
return next;
|
|
@@ -25205,22 +25276,22 @@ function shouldOfferOneMRecovery(opts) {
|
|
|
25205
25276
|
}
|
|
25206
25277
|
|
|
25207
25278
|
// src/commands/host/house-proxy-config.ts
|
|
25208
|
-
var
|
|
25279
|
+
var fs52 = __toESM(require("fs"));
|
|
25209
25280
|
var os37 = __toESM(require("os"));
|
|
25210
|
-
var
|
|
25281
|
+
var path60 = __toESM(require("path"));
|
|
25211
25282
|
function houseProxyConfigPath() {
|
|
25212
|
-
return
|
|
25283
|
+
return path60.join(os37.homedir(), ".codeam", "house-proxy.json");
|
|
25213
25284
|
}
|
|
25214
25285
|
var DEPLOY_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
25215
25286
|
function deployHouseProxyConfigPath(deployId) {
|
|
25216
25287
|
if (!DEPLOY_ID_RE.test(deployId) || deployId.includes("..")) return null;
|
|
25217
|
-
return
|
|
25288
|
+
return path60.join(os37.homedir(), ".codeam", "house-proxy", `${deployId}.json`);
|
|
25218
25289
|
}
|
|
25219
25290
|
function writeJson0600(file, value) {
|
|
25220
|
-
|
|
25291
|
+
fs52.mkdirSync(path60.dirname(file), { recursive: true, mode: 448 });
|
|
25221
25292
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
25222
|
-
|
|
25223
|
-
|
|
25293
|
+
fs52.writeFileSync(tmp, JSON.stringify(value, null, 2), { encoding: "utf8", mode: 384 });
|
|
25294
|
+
fs52.renameSync(tmp, file);
|
|
25224
25295
|
restrictToOwner(file);
|
|
25225
25296
|
}
|
|
25226
25297
|
function persistHouseProxyConfig(config, deployId) {
|
|
@@ -25237,7 +25308,7 @@ function persistHouseProxyConfig(config, deployId) {
|
|
|
25237
25308
|
}
|
|
25238
25309
|
function clearHouseProxyConfig(deployId) {
|
|
25239
25310
|
try {
|
|
25240
|
-
|
|
25311
|
+
fs52.rmSync(houseProxyConfigPath(), { force: true });
|
|
25241
25312
|
const perDeploy = deployId ? deployHouseProxyConfigPath(deployId) : null;
|
|
25242
25313
|
if (perDeploy) writeJson0600(perDeploy, { none: true });
|
|
25243
25314
|
} catch {
|
|
@@ -25246,8 +25317,8 @@ function clearHouseProxyConfig(deployId) {
|
|
|
25246
25317
|
function readHouseProxyChildEnv(deployId) {
|
|
25247
25318
|
try {
|
|
25248
25319
|
const perDeploy = deployId ? deployHouseProxyConfigPath(deployId) : null;
|
|
25249
|
-
const file = perDeploy &&
|
|
25250
|
-
const raw =
|
|
25320
|
+
const file = perDeploy && fs52.existsSync(perDeploy) ? perDeploy : houseProxyConfigPath();
|
|
25321
|
+
const raw = fs52.readFileSync(file, "utf8");
|
|
25251
25322
|
const parsed = JSON.parse(raw);
|
|
25252
25323
|
if (typeof parsed !== "object" || parsed === null) return {};
|
|
25253
25324
|
const o = parsed;
|
|
@@ -25299,12 +25370,16 @@ function buildHouseProxyChildEnv(cfg) {
|
|
|
25299
25370
|
};
|
|
25300
25371
|
if (cfg.openRouter === true) {
|
|
25301
25372
|
env.ANTHROPIC_API_KEY = "";
|
|
25302
|
-
} else {
|
|
25303
|
-
|
|
25304
|
-
env.
|
|
25305
|
-
env.
|
|
25306
|
-
env.
|
|
25307
|
-
|
|
25373
|
+
} else if (typeof cfg.model === "string" && cfg.model) {
|
|
25374
|
+
env.ANTHROPIC_MODEL = cfg.model;
|
|
25375
|
+
env.ANTHROPIC_DEFAULT_SONNET_MODEL = cfg.model;
|
|
25376
|
+
env.ANTHROPIC_DEFAULT_OPUS_MODEL = cfg.model;
|
|
25377
|
+
env.ANTHROPIC_DEFAULT_HAIKU_MODEL = cfg.model;
|
|
25378
|
+
} else if (!isManagedProviderId(cfg.managedAgentId)) {
|
|
25379
|
+
env.ANTHROPIC_MODEL = "MiniMax-M3";
|
|
25380
|
+
env.ANTHROPIC_DEFAULT_SONNET_MODEL = "MiniMax-M3";
|
|
25381
|
+
env.ANTHROPIC_DEFAULT_OPUS_MODEL = "MiniMax-M3";
|
|
25382
|
+
env.ANTHROPIC_DEFAULT_HAIKU_MODEL = "MiniMax-M3";
|
|
25308
25383
|
}
|
|
25309
25384
|
if (typeof cfg.claudeConfigDir === "string" && cfg.claudeConfigDir) {
|
|
25310
25385
|
env.CLAUDE_CONFIG_DIR = cfg.claudeConfigDir;
|
|
@@ -25353,9 +25428,9 @@ function pickHouseProxyEnv(env) {
|
|
|
25353
25428
|
}
|
|
25354
25429
|
|
|
25355
25430
|
// src/lib/provider-routing.ts
|
|
25356
|
-
var
|
|
25431
|
+
var fs53 = __toESM(require("fs"));
|
|
25357
25432
|
var os38 = __toESM(require("os"));
|
|
25358
|
-
var
|
|
25433
|
+
var path61 = __toESM(require("path"));
|
|
25359
25434
|
var PROVIDER_BASE_URL_ENV_KEYS = [
|
|
25360
25435
|
"ANTHROPIC_BASE_URL",
|
|
25361
25436
|
"OPENAI_BASE_URL",
|
|
@@ -25378,14 +25453,14 @@ function redactUrlToOrigin(raw) {
|
|
|
25378
25453
|
}
|
|
25379
25454
|
function readOpencodeProviderOrigins(opts = {}) {
|
|
25380
25455
|
const home = opts.homeDir ?? os38.homedir();
|
|
25381
|
-
const readFile7 = opts.readFile ?? ((f) =>
|
|
25456
|
+
const readFile7 = opts.readFile ?? ((f) => fs53.readFileSync(f, "utf8"));
|
|
25382
25457
|
const candidates = [];
|
|
25383
25458
|
if (opts.cwd) {
|
|
25384
|
-
candidates.push(
|
|
25459
|
+
candidates.push(path61.join(opts.cwd, "opencode.json"), path61.join(opts.cwd, "opencode.jsonc"));
|
|
25385
25460
|
}
|
|
25386
25461
|
candidates.push(
|
|
25387
|
-
|
|
25388
|
-
|
|
25462
|
+
path61.join(home, ".config", "opencode", "opencode.json"),
|
|
25463
|
+
path61.join(home, ".config", "opencode", "opencode.jsonc")
|
|
25389
25464
|
);
|
|
25390
25465
|
const out2 = [];
|
|
25391
25466
|
const seen2 = /* @__PURE__ */ new Set();
|
|
@@ -25693,19 +25768,19 @@ function adapterExitMessage(opts) {
|
|
|
25693
25768
|
|
|
25694
25769
|
// src/services/preview/start-orchestrator.ts
|
|
25695
25770
|
var import_child_process20 = require("child_process");
|
|
25696
|
-
var
|
|
25697
|
-
var
|
|
25771
|
+
var fs56 = __toESM(require("fs"));
|
|
25772
|
+
var path64 = __toESM(require("path"));
|
|
25698
25773
|
var import_which3 = __toESM(require("which"));
|
|
25699
25774
|
|
|
25700
25775
|
// src/services/project-env/index.ts
|
|
25701
25776
|
var import_fs6 = require("fs");
|
|
25702
|
-
var
|
|
25777
|
+
var path63 = __toESM(require("path"));
|
|
25703
25778
|
|
|
25704
25779
|
// src/beads/project-key.ts
|
|
25705
25780
|
var import_child_process19 = require("child_process");
|
|
25706
25781
|
var crypto2 = __toESM(require("crypto"));
|
|
25707
|
-
var
|
|
25708
|
-
var
|
|
25782
|
+
var fs54 = __toESM(require("fs"));
|
|
25783
|
+
var path62 = __toESM(require("path"));
|
|
25709
25784
|
function normalizeOrigin(raw) {
|
|
25710
25785
|
const trimmed = raw.trim();
|
|
25711
25786
|
if (!trimmed) return null;
|
|
@@ -25731,17 +25806,17 @@ function normalizeOrigin(raw) {
|
|
|
25731
25806
|
return `${host2}/${pathPart}`;
|
|
25732
25807
|
}
|
|
25733
25808
|
function findRepoRoot(cwd) {
|
|
25734
|
-
let dir =
|
|
25809
|
+
let dir = path62.resolve(cwd);
|
|
25735
25810
|
const seen2 = /* @__PURE__ */ new Set();
|
|
25736
25811
|
for (let i = 0; i < 256; i++) {
|
|
25737
25812
|
if (seen2.has(dir)) return null;
|
|
25738
25813
|
seen2.add(dir);
|
|
25739
25814
|
try {
|
|
25740
|
-
const stat3 =
|
|
25815
|
+
const stat3 = fs54.statSync(path62.join(dir, ".git"), { throwIfNoEntry: false });
|
|
25741
25816
|
if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
|
|
25742
25817
|
} catch {
|
|
25743
25818
|
}
|
|
25744
|
-
const parent =
|
|
25819
|
+
const parent = path62.dirname(dir);
|
|
25745
25820
|
if (parent === dir) return null;
|
|
25746
25821
|
dir = parent;
|
|
25747
25822
|
}
|
|
@@ -25752,7 +25827,7 @@ var _execSeam3 = {
|
|
|
25752
25827
|
const out2 = (0, import_child_process19.execFileSync)(file, args2, opts);
|
|
25753
25828
|
return typeof out2 === "string" ? out2 : out2.toString("utf8");
|
|
25754
25829
|
},
|
|
25755
|
-
realpath: (p2) =>
|
|
25830
|
+
realpath: (p2) => fs54.realpathSync(p2)
|
|
25756
25831
|
};
|
|
25757
25832
|
function readOrigin(cwd) {
|
|
25758
25833
|
try {
|
|
@@ -25781,7 +25856,7 @@ function deriveProjectIdentity(cwd = process.cwd()) {
|
|
|
25781
25856
|
} catch {
|
|
25782
25857
|
}
|
|
25783
25858
|
const hash = crypto2.createHash("sha256").update(real).digest("hex");
|
|
25784
|
-
return { projectKey: `path:${hash}`, projectLabel:
|
|
25859
|
+
return { projectKey: `path:${hash}`, projectLabel: path62.basename(real) || "project" };
|
|
25785
25860
|
}
|
|
25786
25861
|
|
|
25787
25862
|
// src/services/project-env/index.ts
|
|
@@ -25794,7 +25869,7 @@ async function readIfExists(p2) {
|
|
|
25794
25869
|
}
|
|
25795
25870
|
async function syncProjectEnvUp(cwd, ctx) {
|
|
25796
25871
|
if (!ctx.pluginAuthToken) return;
|
|
25797
|
-
const content = await readIfExists(
|
|
25872
|
+
const content = await readIfExists(path63.join(cwd, ".env"));
|
|
25798
25873
|
if (content == null) return;
|
|
25799
25874
|
try {
|
|
25800
25875
|
const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
|
|
@@ -25816,7 +25891,7 @@ async function syncProjectEnvUp(cwd, ctx) {
|
|
|
25816
25891
|
}
|
|
25817
25892
|
async function restoreProjectEnvIfMissing(cwd, ctx) {
|
|
25818
25893
|
if (!ctx.pluginAuthToken) return false;
|
|
25819
|
-
const envPath =
|
|
25894
|
+
const envPath = path63.join(cwd, ".env");
|
|
25820
25895
|
if (await readIfExists(envPath) != null) return false;
|
|
25821
25896
|
try {
|
|
25822
25897
|
const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
|
|
@@ -25827,7 +25902,7 @@ async function restoreProjectEnvIfMissing(cwd, ctx) {
|
|
|
25827
25902
|
projectKey
|
|
25828
25903
|
});
|
|
25829
25904
|
if (!stored) return false;
|
|
25830
|
-
const tmp =
|
|
25905
|
+
const tmp = path63.join(cwd, ".env.codeam-restore.tmp");
|
|
25831
25906
|
await import_fs6.promises.writeFile(tmp, stored.content, { encoding: "utf8", mode: 384 });
|
|
25832
25907
|
await import_fs6.promises.rename(tmp, envPath);
|
|
25833
25908
|
log.info("project-env", `restored .env (${stored.keyCount} vars) for ${projectLabel}`);
|
|
@@ -26591,8 +26666,8 @@ function normalizeDetectionForSpawn(detection, cwd) {
|
|
|
26591
26666
|
if (args2.length === 0) return detection;
|
|
26592
26667
|
const binName = args2[0];
|
|
26593
26668
|
if (binName.startsWith("-")) return detection;
|
|
26594
|
-
const binPath =
|
|
26595
|
-
if (!
|
|
26669
|
+
const binPath = path64.join(cwd, "node_modules", ".bin", binName);
|
|
26670
|
+
if (!fs56.existsSync(binPath)) return detection;
|
|
26596
26671
|
return {
|
|
26597
26672
|
...detection,
|
|
26598
26673
|
command: binPath,
|
|
@@ -27005,9 +27080,9 @@ async function bringUpPublicUrl(ctx, tunnelPort) {
|
|
|
27005
27080
|
|
|
27006
27081
|
// src/beads/bd-adapter.ts
|
|
27007
27082
|
var import_child_process21 = require("child_process");
|
|
27008
|
-
var
|
|
27083
|
+
var fs57 = __toESM(require("fs"));
|
|
27009
27084
|
var os39 = __toESM(require("os"));
|
|
27010
|
-
var
|
|
27085
|
+
var path65 = __toESM(require("path"));
|
|
27011
27086
|
var BD_PACKAGE = "@beads/bd";
|
|
27012
27087
|
function resolveBundledBdBinary() {
|
|
27013
27088
|
return _resolveSeam.resolveBundled();
|
|
@@ -27019,11 +27094,11 @@ function _defaultResolveBundled() {
|
|
|
27019
27094
|
} catch {
|
|
27020
27095
|
return null;
|
|
27021
27096
|
}
|
|
27022
|
-
const binDir =
|
|
27097
|
+
const binDir = path65.join(path65.dirname(pkgJsonPath), "bin");
|
|
27023
27098
|
const binaryName = process.platform === "win32" ? "bd.exe" : "bd";
|
|
27024
|
-
const binaryPath =
|
|
27099
|
+
const binaryPath = path65.join(binDir, binaryName);
|
|
27025
27100
|
try {
|
|
27026
|
-
|
|
27101
|
+
fs57.accessSync(binaryPath, fs57.constants.F_OK);
|
|
27027
27102
|
return binaryPath;
|
|
27028
27103
|
} catch {
|
|
27029
27104
|
return null;
|
|
@@ -27033,13 +27108,13 @@ function resolveBdOnPath() {
|
|
|
27033
27108
|
return _resolveSeam.resolveOnPath();
|
|
27034
27109
|
}
|
|
27035
27110
|
function _defaultResolveOnPath() {
|
|
27036
|
-
const dirs = (process.env.PATH ?? "").split(
|
|
27111
|
+
const dirs = (process.env.PATH ?? "").split(path65.delimiter).filter(Boolean);
|
|
27037
27112
|
const candidates = process.platform === "win32" ? ["bd.exe", "bd.cmd", "bd"] : ["bd"];
|
|
27038
27113
|
for (const dir of dirs) {
|
|
27039
27114
|
for (const candidate of candidates) {
|
|
27040
|
-
const full =
|
|
27115
|
+
const full = path65.join(dir, candidate);
|
|
27041
27116
|
try {
|
|
27042
|
-
|
|
27117
|
+
fs57.accessSync(full, fs57.constants.F_OK);
|
|
27043
27118
|
return full;
|
|
27044
27119
|
} catch {
|
|
27045
27120
|
}
|
|
@@ -27216,9 +27291,9 @@ function coerceIssue(row, projectKey) {
|
|
|
27216
27291
|
|
|
27217
27292
|
// src/beads/provisioner.ts
|
|
27218
27293
|
var import_child_process24 = require("child_process");
|
|
27219
|
-
var
|
|
27294
|
+
var fs59 = __toESM(require("fs"));
|
|
27220
27295
|
var os41 = __toESM(require("os"));
|
|
27221
|
-
var
|
|
27296
|
+
var path67 = __toESM(require("path"));
|
|
27222
27297
|
|
|
27223
27298
|
// src/beads/install-bd.ts
|
|
27224
27299
|
var import_child_process22 = require("child_process");
|
|
@@ -27283,9 +27358,9 @@ async function installBd(platform3 = process.platform) {
|
|
|
27283
27358
|
|
|
27284
27359
|
// src/beads/install-dolt.ts
|
|
27285
27360
|
var import_child_process23 = require("child_process");
|
|
27286
|
-
var
|
|
27361
|
+
var fs58 = __toESM(require("fs"));
|
|
27287
27362
|
var os40 = __toESM(require("os"));
|
|
27288
|
-
var
|
|
27363
|
+
var path66 = __toESM(require("path"));
|
|
27289
27364
|
var DOLT_INSTALL_SH_URL = "https://github.com/dolthub/dolt/releases/latest/download/install.sh";
|
|
27290
27365
|
var DOLT_MSI_URL = "https://github.com/dolthub/dolt/releases/latest/download/dolt-windows-amd64.msi";
|
|
27291
27366
|
function resolveDoltInstallStrategy(platform3) {
|
|
@@ -27381,7 +27456,7 @@ var _doltPathSeam = {
|
|
|
27381
27456
|
},
|
|
27382
27457
|
exists: (p2) => {
|
|
27383
27458
|
try {
|
|
27384
|
-
|
|
27459
|
+
fs58.accessSync(p2, fs58.constants.F_OK);
|
|
27385
27460
|
return true;
|
|
27386
27461
|
} catch {
|
|
27387
27462
|
return false;
|
|
@@ -27392,7 +27467,7 @@ function doltBinaryNames(platform3) {
|
|
|
27392
27467
|
return platform3 === "win32" ? ["dolt.exe", "dolt.cmd", "dolt"] : ["dolt"];
|
|
27393
27468
|
}
|
|
27394
27469
|
function knownDoltDirs(platform3) {
|
|
27395
|
-
const P3 = platform3 === "win32" ?
|
|
27470
|
+
const P3 = platform3 === "win32" ? path66.win32 : path66.posix;
|
|
27396
27471
|
const home = _doltPathSeam.homedir();
|
|
27397
27472
|
if (platform3 === "win32") {
|
|
27398
27473
|
return [
|
|
@@ -27408,7 +27483,7 @@ function knownDoltDirs(platform3) {
|
|
|
27408
27483
|
].filter(Boolean);
|
|
27409
27484
|
}
|
|
27410
27485
|
function ensureDoltResolvable(platform3 = process.platform) {
|
|
27411
|
-
const P3 = platform3 === "win32" ?
|
|
27486
|
+
const P3 = platform3 === "win32" ? path66.win32 : path66.posix;
|
|
27412
27487
|
const delim = platform3 === "win32" ? ";" : ":";
|
|
27413
27488
|
const names = doltBinaryNames(platform3);
|
|
27414
27489
|
const pathDirs = _doltPathSeam.getPath().split(delim).filter(Boolean);
|
|
@@ -27605,14 +27680,14 @@ var _linkSeam = {
|
|
|
27605
27680
|
homedir: () => os41.homedir(),
|
|
27606
27681
|
isWritableDir: (dir) => {
|
|
27607
27682
|
try {
|
|
27608
|
-
|
|
27683
|
+
fs59.accessSync(dir, fs59.constants.W_OK);
|
|
27609
27684
|
return true;
|
|
27610
27685
|
} catch {
|
|
27611
27686
|
return false;
|
|
27612
27687
|
}
|
|
27613
27688
|
},
|
|
27614
27689
|
ensureDir: (dir) => {
|
|
27615
|
-
|
|
27690
|
+
fs59.mkdirSync(dir, { recursive: true });
|
|
27616
27691
|
},
|
|
27617
27692
|
/**
|
|
27618
27693
|
* A directory to symlink `bd` into so the AGENT's shell + Claude Code's
|
|
@@ -27633,9 +27708,9 @@ var _linkSeam = {
|
|
|
27633
27708
|
* which `linkBdOntoPath` creates if missing.
|
|
27634
27709
|
*/
|
|
27635
27710
|
cliBinDir: () => {
|
|
27636
|
-
const pathDirs = (process.env.PATH ?? "").split(
|
|
27711
|
+
const pathDirs = (process.env.PATH ?? "").split(path67.delimiter).filter(Boolean);
|
|
27637
27712
|
const home = _linkSeam.homedir();
|
|
27638
|
-
const localBin = home ?
|
|
27713
|
+
const localBin = home ? path67.join(home, ".local", "bin") : null;
|
|
27639
27714
|
if (localBin) {
|
|
27640
27715
|
try {
|
|
27641
27716
|
_linkSeam.ensureDir(localBin);
|
|
@@ -27645,16 +27720,16 @@ var _linkSeam = {
|
|
|
27645
27720
|
const candidates = [];
|
|
27646
27721
|
if (localBin) candidates.push(localBin);
|
|
27647
27722
|
try {
|
|
27648
|
-
candidates.push(
|
|
27723
|
+
candidates.push(path67.dirname(process.execPath));
|
|
27649
27724
|
} catch {
|
|
27650
27725
|
}
|
|
27651
27726
|
candidates.push("/usr/local/bin");
|
|
27652
27727
|
const entry = process.argv[1];
|
|
27653
27728
|
if (entry) {
|
|
27654
27729
|
try {
|
|
27655
|
-
candidates.push(
|
|
27730
|
+
candidates.push(path67.dirname(fs59.realpathSync(entry)));
|
|
27656
27731
|
} catch {
|
|
27657
|
-
candidates.push(
|
|
27732
|
+
candidates.push(path67.dirname(entry));
|
|
27658
27733
|
}
|
|
27659
27734
|
}
|
|
27660
27735
|
const onPathWritable = candidates.find(
|
|
@@ -27666,20 +27741,20 @@ var _linkSeam = {
|
|
|
27666
27741
|
/** Current symlink target at `linkPath`, or null when absent / not a link. */
|
|
27667
27742
|
readlink: (linkPath) => {
|
|
27668
27743
|
try {
|
|
27669
|
-
return
|
|
27744
|
+
return fs59.readlinkSync(linkPath);
|
|
27670
27745
|
} catch {
|
|
27671
27746
|
return null;
|
|
27672
27747
|
}
|
|
27673
27748
|
},
|
|
27674
|
-
unlink: (linkPath) =>
|
|
27675
|
-
symlink: (target, linkPath) =>
|
|
27749
|
+
unlink: (linkPath) => fs59.unlinkSync(linkPath),
|
|
27750
|
+
symlink: (target, linkPath) => fs59.symlinkSync(target, linkPath)
|
|
27676
27751
|
};
|
|
27677
27752
|
function linkBdOntoPath(binaryPath) {
|
|
27678
27753
|
if (_linkSeam.platform() === "win32") return;
|
|
27679
27754
|
const binDir = _linkSeam.cliBinDir();
|
|
27680
27755
|
if (!binDir) return;
|
|
27681
27756
|
_linkSeam.ensureDir(binDir);
|
|
27682
|
-
const linkPath =
|
|
27757
|
+
const linkPath = path67.join(binDir, "bd");
|
|
27683
27758
|
if (linkPath === binaryPath) return;
|
|
27684
27759
|
const current2 = _linkSeam.readlink(linkPath);
|
|
27685
27760
|
if (current2 === binaryPath) return;
|
|
@@ -27893,16 +27968,16 @@ function dedupeRecipes(agents) {
|
|
|
27893
27968
|
}
|
|
27894
27969
|
function ensureLocalGitExclude(cwd, patterns) {
|
|
27895
27970
|
try {
|
|
27896
|
-
const gitDir =
|
|
27897
|
-
if (!
|
|
27898
|
-
const file =
|
|
27899
|
-
|
|
27900
|
-
const current2 =
|
|
27971
|
+
const gitDir = path67.join(cwd, ".git");
|
|
27972
|
+
if (!fs59.statSync(gitDir).isDirectory()) return;
|
|
27973
|
+
const file = path67.join(gitDir, "info", "exclude");
|
|
27974
|
+
fs59.mkdirSync(path67.dirname(file), { recursive: true });
|
|
27975
|
+
const current2 = fs59.existsSync(file) ? fs59.readFileSync(file, "utf8") : "";
|
|
27901
27976
|
const have = new Set(current2.split(/\r?\n/).map((l) => l.trim()));
|
|
27902
27977
|
const missing = patterns.filter((p2) => !have.has(p2));
|
|
27903
27978
|
if (missing.length === 0) return;
|
|
27904
27979
|
const prefix = current2.length > 0 && !current2.endsWith("\n") ? "\n" : "";
|
|
27905
|
-
|
|
27980
|
+
fs59.appendFileSync(file, `${prefix}# CodeAgent: beads state stays local
|
|
27906
27981
|
${missing.join("\n")}
|
|
27907
27982
|
`);
|
|
27908
27983
|
} catch {
|
|
@@ -27911,7 +27986,7 @@ ${missing.join("\n")}
|
|
|
27911
27986
|
|
|
27912
27987
|
// src/beads/watcher.ts
|
|
27913
27988
|
var crypto4 = __toESM(require("crypto"));
|
|
27914
|
-
var
|
|
27989
|
+
var path68 = __toESM(require("path"));
|
|
27915
27990
|
var API_BASE5 = resolveApiBaseUrl();
|
|
27916
27991
|
var DEBOUNCE_MS2 = 400;
|
|
27917
27992
|
var ZERO_SUMMARY = {
|
|
@@ -27935,7 +28010,7 @@ var BeadsWatcher = class {
|
|
|
27935
28010
|
constructor(opts) {
|
|
27936
28011
|
this.opts = opts;
|
|
27937
28012
|
this.bd = opts.adapter ?? new BdAdapter({ cwd: opts.cwd, beadsDir: opts.beadsDir });
|
|
27938
|
-
this.feedPath = opts.feedPath ??
|
|
28013
|
+
this.feedPath = opts.feedPath ?? path68.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
|
|
27939
28014
|
this.apiBase = opts.apiBaseUrl ?? API_BASE5;
|
|
27940
28015
|
}
|
|
27941
28016
|
opts;
|
|
@@ -28186,15 +28261,15 @@ async function handleBeadsActionCommand(action, started) {
|
|
|
28186
28261
|
}
|
|
28187
28262
|
|
|
28188
28263
|
// src/beads/config-store.ts
|
|
28189
|
-
var
|
|
28264
|
+
var import_node_fs15 = __toESM(require("fs"));
|
|
28190
28265
|
var import_node_os8 = __toESM(require("os"));
|
|
28191
|
-
var
|
|
28266
|
+
var import_node_path14 = __toESM(require("path"));
|
|
28192
28267
|
function beadsConfigPath() {
|
|
28193
|
-
return
|
|
28268
|
+
return import_node_path14.default.join(import_node_os8.default.homedir(), ".codeam", "beads-config.json");
|
|
28194
28269
|
}
|
|
28195
28270
|
function readBeadsEnabled() {
|
|
28196
28271
|
try {
|
|
28197
|
-
const raw =
|
|
28272
|
+
const raw = import_node_fs15.default.readFileSync(beadsConfigPath(), "utf8");
|
|
28198
28273
|
const cfg = JSON.parse(raw);
|
|
28199
28274
|
return cfg.enabled !== false;
|
|
28200
28275
|
} catch {
|
|
@@ -28203,10 +28278,10 @@ function readBeadsEnabled() {
|
|
|
28203
28278
|
}
|
|
28204
28279
|
function persistBeadsConfig(cfg) {
|
|
28205
28280
|
const file = beadsConfigPath();
|
|
28206
|
-
|
|
28281
|
+
import_node_fs15.default.mkdirSync(import_node_path14.default.dirname(file), { recursive: true });
|
|
28207
28282
|
const tmp = `${file}.tmp`;
|
|
28208
|
-
|
|
28209
|
-
|
|
28283
|
+
import_node_fs15.default.writeFileSync(tmp, JSON.stringify(cfg), { mode: 384 });
|
|
28284
|
+
import_node_fs15.default.renameSync(tmp, file);
|
|
28210
28285
|
restrictToOwner(file);
|
|
28211
28286
|
}
|
|
28212
28287
|
|
|
@@ -28345,12 +28420,12 @@ async function configureBeads(action, ctx, deps) {
|
|
|
28345
28420
|
var import_node_os11 = __toESM(require("os"));
|
|
28346
28421
|
|
|
28347
28422
|
// src/skills/materialize.ts
|
|
28348
|
-
var
|
|
28423
|
+
var import_node_fs16 = __toESM(require("fs"));
|
|
28349
28424
|
var import_node_os9 = __toESM(require("os"));
|
|
28350
|
-
var
|
|
28425
|
+
var import_node_path15 = __toESM(require("path"));
|
|
28351
28426
|
var NS = "codeam-";
|
|
28352
28427
|
function skillDirFor(id, home = import_node_os9.default.homedir()) {
|
|
28353
|
-
return
|
|
28428
|
+
return import_node_path15.default.join(home, ".claude", "skills", `${NS}${id}`);
|
|
28354
28429
|
}
|
|
28355
28430
|
function renderSkillMd(id, description, body) {
|
|
28356
28431
|
const desc = description.replace(/\s*\n\s*/g, " ").trim();
|
|
@@ -28367,21 +28442,21 @@ function materializeSkill(id, home = import_node_os9.default.homedir()) {
|
|
|
28367
28442
|
if (!def?.delivery.skillFile) return false;
|
|
28368
28443
|
try {
|
|
28369
28444
|
const dir = skillDirFor(id, home);
|
|
28370
|
-
|
|
28371
|
-
|
|
28372
|
-
|
|
28445
|
+
import_node_fs16.default.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
28446
|
+
import_node_fs16.default.writeFileSync(
|
|
28447
|
+
import_node_path15.default.join(dir, "SKILL.md"),
|
|
28373
28448
|
renderSkillMd(id, def.description, def.delivery.skillFile.body),
|
|
28374
28449
|
{ encoding: "utf8", mode: 384 }
|
|
28375
28450
|
);
|
|
28376
|
-
const baseDir =
|
|
28377
|
-
const baseDirWithSep = baseDir +
|
|
28451
|
+
const baseDir = import_node_path15.default.resolve(dir);
|
|
28452
|
+
const baseDirWithSep = baseDir + import_node_path15.default.sep;
|
|
28378
28453
|
for (const [rel, contents] of Object.entries(def.delivery.skillFile.files ?? {})) {
|
|
28379
|
-
const target =
|
|
28380
|
-
if (!
|
|
28454
|
+
const target = import_node_path15.default.join(dir, rel);
|
|
28455
|
+
if (!import_node_path15.default.resolve(target).startsWith(baseDirWithSep) && import_node_path15.default.resolve(target) !== baseDir) {
|
|
28381
28456
|
continue;
|
|
28382
28457
|
}
|
|
28383
|
-
|
|
28384
|
-
|
|
28458
|
+
import_node_fs16.default.mkdirSync(import_node_path15.default.dirname(target), { recursive: true, mode: 448 });
|
|
28459
|
+
import_node_fs16.default.writeFileSync(target, contents, { encoding: "utf8", mode: 384 });
|
|
28385
28460
|
}
|
|
28386
28461
|
return true;
|
|
28387
28462
|
} catch (err) {
|
|
@@ -28391,21 +28466,21 @@ function materializeSkill(id, home = import_node_os9.default.homedir()) {
|
|
|
28391
28466
|
}
|
|
28392
28467
|
function removeSkill(id, home = import_node_os9.default.homedir()) {
|
|
28393
28468
|
try {
|
|
28394
|
-
|
|
28469
|
+
import_node_fs16.default.rmSync(skillDirFor(id, home), { recursive: true, force: true });
|
|
28395
28470
|
} catch {
|
|
28396
28471
|
}
|
|
28397
28472
|
}
|
|
28398
28473
|
|
|
28399
28474
|
// src/skills/manifest.ts
|
|
28400
|
-
var
|
|
28475
|
+
var import_node_fs17 = __toESM(require("fs"));
|
|
28401
28476
|
var import_node_os10 = __toESM(require("os"));
|
|
28402
|
-
var
|
|
28477
|
+
var import_node_path16 = __toESM(require("path"));
|
|
28403
28478
|
function skillsManifestPath() {
|
|
28404
|
-
return
|
|
28479
|
+
return import_node_path16.default.join(import_node_os10.default.homedir(), ".codeam", "skills.json");
|
|
28405
28480
|
}
|
|
28406
28481
|
function readSkillsManifest() {
|
|
28407
28482
|
try {
|
|
28408
|
-
const raw = JSON.parse(
|
|
28483
|
+
const raw = JSON.parse(import_node_fs17.default.readFileSync(skillsManifestPath(), "utf8"));
|
|
28409
28484
|
if (!Array.isArray(raw?.skills)) return null;
|
|
28410
28485
|
raw.skills = raw.skills.filter(
|
|
28411
28486
|
(s) => Boolean(s) && typeof s === "object" && typeof s.id === "string"
|
|
@@ -28418,10 +28493,10 @@ function readSkillsManifest() {
|
|
|
28418
28493
|
function persistSkillsManifest(m) {
|
|
28419
28494
|
try {
|
|
28420
28495
|
const file = skillsManifestPath();
|
|
28421
|
-
|
|
28496
|
+
import_node_fs17.default.mkdirSync(import_node_path16.default.dirname(file), { recursive: true, mode: 448 });
|
|
28422
28497
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
28423
|
-
|
|
28424
|
-
|
|
28498
|
+
import_node_fs17.default.writeFileSync(tmp, JSON.stringify(m, null, 2), { encoding: "utf8", mode: 384 });
|
|
28499
|
+
import_node_fs17.default.renameSync(tmp, file);
|
|
28425
28500
|
restrictToOwner(file);
|
|
28426
28501
|
} catch (err) {
|
|
28427
28502
|
log.warn(
|
|
@@ -28432,7 +28507,7 @@ function persistSkillsManifest(m) {
|
|
|
28432
28507
|
}
|
|
28433
28508
|
function clearSkillsManifest() {
|
|
28434
28509
|
try {
|
|
28435
|
-
|
|
28510
|
+
import_node_fs17.default.rmSync(skillsManifestPath(), { force: true });
|
|
28436
28511
|
} catch {
|
|
28437
28512
|
}
|
|
28438
28513
|
}
|
|
@@ -28475,8 +28550,8 @@ function cleanupAttachmentTempFiles() {
|
|
|
28475
28550
|
function saveFilesTemp(files) {
|
|
28476
28551
|
return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
|
|
28477
28552
|
const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
|
|
28478
|
-
const tmpPath =
|
|
28479
|
-
|
|
28553
|
+
const tmpPath = path72.join(os46.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
|
|
28554
|
+
fs63.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
|
|
28480
28555
|
pendingAttachmentFiles.add(tmpPath);
|
|
28481
28556
|
return tmpPath;
|
|
28482
28557
|
});
|
|
@@ -28721,10 +28796,10 @@ var listFiles = async (ctx, cmd, parsed) => {
|
|
|
28721
28796
|
await ctx.relay.sendResult(cmd.id, "completed", result);
|
|
28722
28797
|
};
|
|
28723
28798
|
var envReadH = async (ctx, cmd) => {
|
|
28724
|
-
const envPath =
|
|
28799
|
+
const envPath = path72.join(process.cwd(), ".env");
|
|
28725
28800
|
await restoreProjectEnvIfMissing(process.cwd(), ctx);
|
|
28726
28801
|
try {
|
|
28727
|
-
const raw = await
|
|
28802
|
+
const raw = await fs63.promises.readFile(envPath, "utf8");
|
|
28728
28803
|
await ctx.relay.sendResult(cmd.id, "completed", {
|
|
28729
28804
|
exists: true,
|
|
28730
28805
|
vars: parseDotenv(raw)
|
|
@@ -28753,7 +28828,7 @@ var envParseH = async (ctx, cmd, parsed) => {
|
|
|
28753
28828
|
const existing = /* @__PURE__ */ new Map();
|
|
28754
28829
|
if (!replace) {
|
|
28755
28830
|
try {
|
|
28756
|
-
const raw = await
|
|
28831
|
+
const raw = await fs63.promises.readFile(path72.join(process.cwd(), ".env"), "utf8");
|
|
28757
28832
|
for (const v of parseDotenv(raw)) existing.set(v.key, v.value);
|
|
28758
28833
|
} catch {
|
|
28759
28834
|
}
|
|
@@ -28793,15 +28868,15 @@ var envWriteH = async (ctx, cmd, parsed) => {
|
|
|
28793
28868
|
}
|
|
28794
28869
|
seen2.add(v.key);
|
|
28795
28870
|
}
|
|
28796
|
-
const envPath =
|
|
28797
|
-
const tmpPath =
|
|
28871
|
+
const envPath = path72.join(process.cwd(), ".env");
|
|
28872
|
+
const tmpPath = path72.join(process.cwd(), ".env.codeam.tmp");
|
|
28798
28873
|
try {
|
|
28799
|
-
await
|
|
28800
|
-
await
|
|
28874
|
+
await fs63.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
|
|
28875
|
+
await fs63.promises.rename(tmpPath, envPath);
|
|
28801
28876
|
await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
|
|
28802
28877
|
void syncProjectEnvUp(process.cwd(), ctx);
|
|
28803
28878
|
} catch (err) {
|
|
28804
|
-
await
|
|
28879
|
+
await fs63.promises.rm(tmpPath, { force: true }).catch(() => void 0);
|
|
28805
28880
|
await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
|
|
28806
28881
|
}
|
|
28807
28882
|
};
|
|
@@ -29150,9 +29225,9 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
|
|
|
29150
29225
|
function buildNpmInstallInvocation(opts) {
|
|
29151
29226
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
29152
29227
|
const execPath = opts?.execPath ?? process.execPath;
|
|
29153
|
-
const exists2 = opts?.existsSync ??
|
|
29228
|
+
const exists2 = opts?.existsSync ?? fs63.existsSync;
|
|
29154
29229
|
const platform3 = opts?.platform ?? process.platform;
|
|
29155
|
-
const p2 = platform3 === "win32" ?
|
|
29230
|
+
const p2 = platform3 === "win32" ? path72.win32 : path72.posix;
|
|
29156
29231
|
const normalized = entryScript.split(/[\\/]/).join("/");
|
|
29157
29232
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
29158
29233
|
const markerIdx = normalized.indexOf(marker);
|
|
@@ -29171,7 +29246,7 @@ function isPermissionError(stderr) {
|
|
|
29171
29246
|
function resolveGlobalNodeModulesDir(opts) {
|
|
29172
29247
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
29173
29248
|
const platform3 = opts?.platform ?? process.platform;
|
|
29174
|
-
const p2 = platform3 === "win32" ?
|
|
29249
|
+
const p2 = platform3 === "win32" ? path72.win32 : path72.posix;
|
|
29175
29250
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
29176
29251
|
const markerIdx = entryScript.split(/[\\/]/).join("/").indexOf(marker);
|
|
29177
29252
|
if (markerIdx <= 0) return null;
|
|
@@ -29181,9 +29256,9 @@ function resolveGlobalNodeModulesDir(opts) {
|
|
|
29181
29256
|
var STALE_STAGING_AGE_MS = CLI_UPDATE_INSTALL_TIMEOUT_MS;
|
|
29182
29257
|
function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
29183
29258
|
if (!nodeModulesDir) return 0;
|
|
29184
|
-
const readdirSync17 = deps?.readdirSync ??
|
|
29185
|
-
const statSync16 = deps?.statSync ??
|
|
29186
|
-
const rmSync11 = deps?.rmSync ??
|
|
29259
|
+
const readdirSync17 = deps?.readdirSync ?? fs63.readdirSync;
|
|
29260
|
+
const statSync16 = deps?.statSync ?? fs63.statSync;
|
|
29261
|
+
const rmSync11 = deps?.rmSync ?? fs63.rmSync;
|
|
29187
29262
|
let removed = 0;
|
|
29188
29263
|
let entries2;
|
|
29189
29264
|
try {
|
|
@@ -29193,7 +29268,7 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
|
29193
29268
|
}
|
|
29194
29269
|
for (const name of entries2) {
|
|
29195
29270
|
if (!/^\.codeam-cli-/.test(name)) continue;
|
|
29196
|
-
const full =
|
|
29271
|
+
const full = path72.join(nodeModulesDir, name);
|
|
29197
29272
|
try {
|
|
29198
29273
|
const st3 = statSync16(full);
|
|
29199
29274
|
if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
|
|
@@ -29612,6 +29687,14 @@ async function resolvePreviewDetection(args2) {
|
|
|
29612
29687
|
payload: originPayload(payload, origin)
|
|
29613
29688
|
});
|
|
29614
29689
|
};
|
|
29690
|
+
if (isEmptyScratchProject(process.cwd())) {
|
|
29691
|
+
log.info("preview", "detect: empty scratch project \u2014 nothing to preview yet");
|
|
29692
|
+
emit2(USER_EVENTS.PREVIEW_ERROR, {
|
|
29693
|
+
stage: "unsupported",
|
|
29694
|
+
message: "Nothing to preview yet \u2014 this project is empty. Ask your agent to build something and it opens the preview."
|
|
29695
|
+
});
|
|
29696
|
+
return null;
|
|
29697
|
+
}
|
|
29615
29698
|
if (typeof runtime.generateOneShot !== "function") {
|
|
29616
29699
|
log.info("preview", `runtime ${runtime.id} has no generateOneShot \u2014 emitting unsupported`);
|
|
29617
29700
|
emit2(USER_EVENTS.PREVIEW_ERROR, {
|
|
@@ -29809,6 +29892,7 @@ async function offerScratchSaveOnce(ctx, pluginAuthToken) {
|
|
|
29809
29892
|
}
|
|
29810
29893
|
function startPreviewFromDetection(ctx, detection, pluginAuthToken, opts = {}) {
|
|
29811
29894
|
previewRequestedInProcess = true;
|
|
29895
|
+
notePreviewBringUp(ctx.sessionId);
|
|
29812
29896
|
const emit2 = (type, payload) => {
|
|
29813
29897
|
const tagged = originPayload(payload, opts.origin) ?? {};
|
|
29814
29898
|
opts.onEvent?.(type, tagged);
|
|
@@ -30307,11 +30391,11 @@ function resolveTokenValue(args2) {
|
|
|
30307
30391
|
}
|
|
30308
30392
|
const fileFlag = args2.find((a) => a.startsWith("--token-file="));
|
|
30309
30393
|
if (fileFlag) {
|
|
30310
|
-
const
|
|
30394
|
+
const path109 = fileFlag.slice("--token-file=".length);
|
|
30311
30395
|
try {
|
|
30312
|
-
const content =
|
|
30313
|
-
if (content.length === 0) fail(`--token-file ${
|
|
30314
|
-
rmIfExistsQuiet(
|
|
30396
|
+
const content = fs64.readFileSync(path109, "utf8").trim();
|
|
30397
|
+
if (content.length === 0) fail(`--token-file ${path109} is empty`);
|
|
30398
|
+
rmIfExistsQuiet(path109);
|
|
30315
30399
|
return content;
|
|
30316
30400
|
} catch (err) {
|
|
30317
30401
|
fail(`Could not read --token-file: ${err.message}`);
|
|
@@ -30403,12 +30487,12 @@ async function claim(token, pluginId, pluginSecretHash) {
|
|
|
30403
30487
|
}
|
|
30404
30488
|
}
|
|
30405
30489
|
function pairAutoLockPath() {
|
|
30406
|
-
return
|
|
30490
|
+
return path73.join(os47.homedir(), ".codeam", "pair-auto.lock");
|
|
30407
30491
|
}
|
|
30408
30492
|
var procRoot = "/proc";
|
|
30409
30493
|
function readProcFile(rel) {
|
|
30410
30494
|
try {
|
|
30411
|
-
return
|
|
30495
|
+
return fs64.readFileSync(path73.join(procRoot, rel), "utf8");
|
|
30412
30496
|
} catch {
|
|
30413
30497
|
return void 0;
|
|
30414
30498
|
}
|
|
@@ -30429,7 +30513,7 @@ function currentBootId() {
|
|
|
30429
30513
|
function readLockRecord(lockPath) {
|
|
30430
30514
|
let raw;
|
|
30431
30515
|
try {
|
|
30432
|
-
raw =
|
|
30516
|
+
raw = fs64.readFileSync(lockPath, "utf8");
|
|
30433
30517
|
} catch {
|
|
30434
30518
|
return void 0;
|
|
30435
30519
|
}
|
|
@@ -30478,7 +30562,7 @@ function isLiveLockHolder(rec) {
|
|
|
30478
30562
|
}
|
|
30479
30563
|
function releaseOwnLock(lockPath) {
|
|
30480
30564
|
try {
|
|
30481
|
-
if (readLockRecord(lockPath)?.pid === process.pid)
|
|
30565
|
+
if (readLockRecord(lockPath)?.pid === process.pid) fs64.unlinkSync(lockPath);
|
|
30482
30566
|
} catch {
|
|
30483
30567
|
}
|
|
30484
30568
|
}
|
|
@@ -30502,7 +30586,7 @@ function snapshotProcessTree(root) {
|
|
|
30502
30586
|
const children = /* @__PURE__ */ new Map();
|
|
30503
30587
|
let entries2 = [];
|
|
30504
30588
|
try {
|
|
30505
|
-
entries2 =
|
|
30589
|
+
entries2 = fs64.readdirSync(procRoot).filter((e) => /^\d+$/.test(e));
|
|
30506
30590
|
} catch {
|
|
30507
30591
|
}
|
|
30508
30592
|
for (const e of entries2) {
|
|
@@ -30537,18 +30621,18 @@ function signalProcessTree(refs, signal) {
|
|
|
30537
30621
|
}
|
|
30538
30622
|
function daemonLockPath(sessionId) {
|
|
30539
30623
|
const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
30540
|
-
return
|
|
30624
|
+
return path73.join(os47.homedir(), ".codeam", `daemon-${safe}.lock`);
|
|
30541
30625
|
}
|
|
30542
30626
|
function acquireDaemonLock(sessionId) {
|
|
30543
30627
|
const lockPath = daemonLockPath(sessionId);
|
|
30544
30628
|
try {
|
|
30545
|
-
|
|
30629
|
+
fs64.mkdirSync(path73.dirname(lockPath), { recursive: true });
|
|
30546
30630
|
try {
|
|
30547
|
-
|
|
30631
|
+
fs64.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
30548
30632
|
} catch (e) {
|
|
30549
30633
|
if (e.code !== "EEXIST") throw e;
|
|
30550
30634
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
30551
|
-
|
|
30635
|
+
fs64.writeFileSync(lockPath, ownLockBody());
|
|
30552
30636
|
}
|
|
30553
30637
|
const release3 = () => releaseOwnLock(lockPath);
|
|
30554
30638
|
process.once("exit", release3);
|
|
@@ -30568,13 +30652,13 @@ function acquireDaemonLock(sessionId) {
|
|
|
30568
30652
|
function acquireSingletonLock() {
|
|
30569
30653
|
const lockPath = pairAutoLockPath();
|
|
30570
30654
|
try {
|
|
30571
|
-
|
|
30655
|
+
fs64.mkdirSync(path73.dirname(lockPath), { recursive: true });
|
|
30572
30656
|
try {
|
|
30573
|
-
|
|
30657
|
+
fs64.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
30574
30658
|
} catch (e) {
|
|
30575
30659
|
if (e.code !== "EEXIST") throw e;
|
|
30576
30660
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
30577
|
-
|
|
30661
|
+
fs64.writeFileSync(lockPath, ownLockBody());
|
|
30578
30662
|
}
|
|
30579
30663
|
process.once("exit", () => releaseOwnLock(lockPath));
|
|
30580
30664
|
return true;
|
|
@@ -30991,15 +31075,15 @@ var AgentService = class _AgentService {
|
|
|
30991
31075
|
};
|
|
30992
31076
|
|
|
30993
31077
|
// src/agents/acp/adapters.ts
|
|
30994
|
-
var
|
|
31078
|
+
var path74 = __toESM(require("path"));
|
|
30995
31079
|
|
|
30996
31080
|
// src/agents/kimi/installer.ts
|
|
30997
31081
|
var import_node_child_process25 = require("child_process");
|
|
30998
31082
|
var import_node_os12 = require("os");
|
|
30999
|
-
var
|
|
31083
|
+
var import_node_path17 = require("path");
|
|
31000
31084
|
var INSTALL_URL2 = "https://code.kimi.com/kimi-code/install.sh";
|
|
31001
31085
|
function kimiBinDir() {
|
|
31002
|
-
return (0,
|
|
31086
|
+
return (0, import_node_path17.join)(process.env.KIMI_CODE_HOME || (0, import_node_path17.join)((0, import_node_os12.homedir)(), ".kimi-code"), "bin");
|
|
31003
31087
|
}
|
|
31004
31088
|
function kimiRuns() {
|
|
31005
31089
|
const r = (0, import_node_child_process25.spawnSync)("kimi", ["--version"], { stdio: "ignore", timeout: 15e3 });
|
|
@@ -31049,10 +31133,10 @@ async function ensureKimiInstalled() {
|
|
|
31049
31133
|
// src/agents/opencode/installer.ts
|
|
31050
31134
|
var import_node_child_process26 = require("child_process");
|
|
31051
31135
|
var import_node_os13 = require("os");
|
|
31052
|
-
var
|
|
31136
|
+
var import_node_path18 = require("path");
|
|
31053
31137
|
var INSTALL_URL3 = "https://opencode.ai/install";
|
|
31054
31138
|
function opencodeBinDir() {
|
|
31055
|
-
return (0,
|
|
31139
|
+
return (0, import_node_path18.join)(process.env.OPENCODE_HOME || (0, import_node_path18.join)((0, import_node_os13.homedir)(), ".opencode"), "bin");
|
|
31056
31140
|
}
|
|
31057
31141
|
function opencodeRuns() {
|
|
31058
31142
|
const r = (0, import_node_child_process26.spawnSync)("opencode", ["--version"], { stdio: "ignore", timeout: 15e3 });
|
|
@@ -31111,13 +31195,13 @@ function resolveBin(pkgName, binName) {
|
|
|
31111
31195
|
try {
|
|
31112
31196
|
const manifestPath = require_.resolve(`${pkgName}/package.json`);
|
|
31113
31197
|
const manifest = require_(`${pkgName}/package.json`);
|
|
31114
|
-
const pkgDir =
|
|
31198
|
+
const pkgDir = path74.dirname(manifestPath);
|
|
31115
31199
|
const bin = manifest.bin;
|
|
31116
31200
|
if (!bin) return null;
|
|
31117
|
-
if (typeof bin === "string") return
|
|
31201
|
+
if (typeof bin === "string") return path74.resolve(pkgDir, bin);
|
|
31118
31202
|
const target = binName ?? Object.keys(bin)[0];
|
|
31119
31203
|
if (!target || !bin[target]) return null;
|
|
31120
|
-
return
|
|
31204
|
+
return path74.resolve(pkgDir, bin[target]);
|
|
31121
31205
|
} catch {
|
|
31122
31206
|
return null;
|
|
31123
31207
|
}
|
|
@@ -31298,9 +31382,9 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
|
|
|
31298
31382
|
|
|
31299
31383
|
// src/agents/acp/runner.ts
|
|
31300
31384
|
var import_node_crypto15 = require("crypto");
|
|
31301
|
-
var
|
|
31385
|
+
var fs83 = __toESM(require("fs"));
|
|
31302
31386
|
var os59 = __toESM(require("os"));
|
|
31303
|
-
var
|
|
31387
|
+
var path94 = __toESM(require("path"));
|
|
31304
31388
|
|
|
31305
31389
|
// src/agents/acp/provider-billing-signal.ts
|
|
31306
31390
|
var seen = /* @__PURE__ */ new Set();
|
|
@@ -31332,8 +31416,8 @@ function noteProviderBillingSignal(opts) {
|
|
|
31332
31416
|
}
|
|
31333
31417
|
|
|
31334
31418
|
// src/services/history.service.ts
|
|
31335
|
-
var
|
|
31336
|
-
var
|
|
31419
|
+
var fs65 = __toESM(require("fs"));
|
|
31420
|
+
var path75 = __toESM(require("path"));
|
|
31337
31421
|
var https6 = __toESM(require("https"));
|
|
31338
31422
|
var http10 = __toESM(require("http"));
|
|
31339
31423
|
var import_zod2 = require("zod");
|
|
@@ -31394,7 +31478,7 @@ function parseJsonl(filePath) {
|
|
|
31394
31478
|
const messages = [];
|
|
31395
31479
|
let raw;
|
|
31396
31480
|
try {
|
|
31397
|
-
raw =
|
|
31481
|
+
raw = fs65.readFileSync(filePath, "utf8");
|
|
31398
31482
|
} catch (err) {
|
|
31399
31483
|
if (err.code !== "ENOENT") {
|
|
31400
31484
|
log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
|
|
@@ -31554,7 +31638,7 @@ var HistoryService = class _HistoryService {
|
|
|
31554
31638
|
// session-start upload answered false, the active-conversation pointer was
|
|
31555
31639
|
// never re-pointed after a Box wake, and the app opened an empty "New
|
|
31556
31640
|
// conversation" over the resumed one (QA box, 2026-09-29).
|
|
31557
|
-
|
|
31641
|
+
path75.join(claudeConfigDir(), "projects", encodeCwd(this.cwd));
|
|
31558
31642
|
}
|
|
31559
31643
|
/** Set the current Claude conversation ID (extracted from /cost command or session start) */
|
|
31560
31644
|
setCurrentConversationId(id) {
|
|
@@ -31566,7 +31650,7 @@ var HistoryService = class _HistoryService {
|
|
|
31566
31650
|
/** Return the current message count in the active conversation. */
|
|
31567
31651
|
getCurrentMessageCount() {
|
|
31568
31652
|
if (!this.currentConversationId) return 0;
|
|
31569
|
-
const filePath =
|
|
31653
|
+
const filePath = path75.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
31570
31654
|
return parseJsonl(filePath).length;
|
|
31571
31655
|
}
|
|
31572
31656
|
/**
|
|
@@ -31577,7 +31661,7 @@ var HistoryService = class _HistoryService {
|
|
|
31577
31661
|
const deadline = Date.now() + timeoutMs;
|
|
31578
31662
|
while (Date.now() < deadline) {
|
|
31579
31663
|
if (!this.currentConversationId) return null;
|
|
31580
|
-
const filePath =
|
|
31664
|
+
const filePath = path75.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
31581
31665
|
const messages = parseJsonl(filePath);
|
|
31582
31666
|
if (messages.length > previousCount) {
|
|
31583
31667
|
for (let i = messages.length - 1; i >= previousCount; i--) {
|
|
@@ -31604,18 +31688,18 @@ var HistoryService = class _HistoryService {
|
|
|
31604
31688
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
31605
31689
|
const oneShots = readOneShotConversations(this.cwd);
|
|
31606
31690
|
try {
|
|
31607
|
-
const files =
|
|
31608
|
-
(e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(
|
|
31691
|
+
const files = fs65.readdirSync(dir, { withFileTypes: true }).filter(
|
|
31692
|
+
(e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(path75.basename(e.name, ".jsonl"))
|
|
31609
31693
|
).map((e) => {
|
|
31610
31694
|
try {
|
|
31611
|
-
const stat3 =
|
|
31695
|
+
const stat3 = fs65.statSync(path75.join(dir, e.name));
|
|
31612
31696
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
31613
31697
|
} catch {
|
|
31614
31698
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
31615
31699
|
}
|
|
31616
31700
|
}).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
31617
31701
|
if (files.length > 0) {
|
|
31618
|
-
this.currentConversationId =
|
|
31702
|
+
this.currentConversationId = path75.basename(files[0].name, ".jsonl");
|
|
31619
31703
|
}
|
|
31620
31704
|
} catch {
|
|
31621
31705
|
}
|
|
@@ -31649,13 +31733,13 @@ var HistoryService = class _HistoryService {
|
|
|
31649
31733
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
31650
31734
|
let entries2;
|
|
31651
31735
|
try {
|
|
31652
|
-
entries2 =
|
|
31736
|
+
entries2 = fs65.readdirSync(dir, { withFileTypes: true });
|
|
31653
31737
|
} catch {
|
|
31654
31738
|
return null;
|
|
31655
31739
|
}
|
|
31656
31740
|
const files = entries2.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
31657
31741
|
try {
|
|
31658
|
-
const stat3 =
|
|
31742
|
+
const stat3 = fs65.statSync(path75.join(dir, e.name));
|
|
31659
31743
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
31660
31744
|
} catch {
|
|
31661
31745
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
@@ -31664,12 +31748,12 @@ var HistoryService = class _HistoryService {
|
|
|
31664
31748
|
if (files.length === 0) return null;
|
|
31665
31749
|
const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
|
|
31666
31750
|
if (!files.some((f) => f.name === targetFile)) return null;
|
|
31667
|
-
return this.extractUsageFromFile(
|
|
31751
|
+
return this.extractUsageFromFile(path75.join(dir, targetFile));
|
|
31668
31752
|
}
|
|
31669
31753
|
extractUsageFromFile(filePath) {
|
|
31670
31754
|
let raw;
|
|
31671
31755
|
try {
|
|
31672
|
-
raw =
|
|
31756
|
+
raw = fs65.readFileSync(filePath, "utf8");
|
|
31673
31757
|
} catch {
|
|
31674
31758
|
return null;
|
|
31675
31759
|
}
|
|
@@ -31721,9 +31805,9 @@ var HistoryService = class _HistoryService {
|
|
|
31721
31805
|
let totalCost = 0;
|
|
31722
31806
|
let files;
|
|
31723
31807
|
try {
|
|
31724
|
-
files =
|
|
31808
|
+
files = fs65.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
|
|
31725
31809
|
try {
|
|
31726
|
-
return
|
|
31810
|
+
return fs65.statSync(path75.join(projectDir, f)).mtimeMs >= monthStartMs;
|
|
31727
31811
|
} catch {
|
|
31728
31812
|
return false;
|
|
31729
31813
|
}
|
|
@@ -31734,7 +31818,7 @@ var HistoryService = class _HistoryService {
|
|
|
31734
31818
|
for (const file of files) {
|
|
31735
31819
|
let raw;
|
|
31736
31820
|
try {
|
|
31737
|
-
raw =
|
|
31821
|
+
raw = fs65.readFileSync(path75.join(projectDir, file), "utf8");
|
|
31738
31822
|
} catch {
|
|
31739
31823
|
continue;
|
|
31740
31824
|
}
|
|
@@ -31813,7 +31897,7 @@ var HistoryService = class _HistoryService {
|
|
|
31813
31897
|
if (this.runtime.resolveHistoryFile) {
|
|
31814
31898
|
return this.runtime.resolveHistoryFile(this.cwd, sessionId);
|
|
31815
31899
|
}
|
|
31816
|
-
return
|
|
31900
|
+
return path75.join(this.projectDir, `${sessionId}.jsonl`);
|
|
31817
31901
|
}
|
|
31818
31902
|
/**
|
|
31819
31903
|
* Parse a conversation's messages from disk, agent-aware. Claude uses the
|
|
@@ -31851,7 +31935,7 @@ var HistoryService = class _HistoryService {
|
|
|
31851
31935
|
};
|
|
31852
31936
|
});
|
|
31853
31937
|
}
|
|
31854
|
-
return parseJsonl(
|
|
31938
|
+
return parseJsonl(path75.join(this.projectDir, `${sessionId}.jsonl`));
|
|
31855
31939
|
}
|
|
31856
31940
|
/** One in-flight full upload per conversation — the baton mirror and a
|
|
31857
31941
|
* `get_conversation` used to upload the same transcript concurrently. */
|
|
@@ -31933,7 +32017,7 @@ var HistoryService = class _HistoryService {
|
|
|
31933
32017
|
if (!filePath) return false;
|
|
31934
32018
|
let mtimeMs;
|
|
31935
32019
|
try {
|
|
31936
|
-
mtimeMs =
|
|
32020
|
+
mtimeMs = fs65.statSync(filePath).mtimeMs;
|
|
31937
32021
|
} catch {
|
|
31938
32022
|
return false;
|
|
31939
32023
|
}
|
|
@@ -32008,10 +32092,10 @@ var HistoryService = class _HistoryService {
|
|
|
32008
32092
|
|
|
32009
32093
|
// src/agents/acp/client.ts
|
|
32010
32094
|
var import_node_child_process27 = require("child_process");
|
|
32011
|
-
var
|
|
32095
|
+
var fs66 = __toESM(require("fs/promises"));
|
|
32012
32096
|
var fsSync = __toESM(require("fs"));
|
|
32013
32097
|
var os49 = __toESM(require("os"));
|
|
32014
|
-
var
|
|
32098
|
+
var path77 = __toESM(require("path"));
|
|
32015
32099
|
var import_node_stream = require("stream");
|
|
32016
32100
|
|
|
32017
32101
|
// ../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
@@ -36037,7 +36121,7 @@ function createIdleTimeout(idleMs, makeError, activeIdleMs = idleMs) {
|
|
|
36037
36121
|
}
|
|
36038
36122
|
|
|
36039
36123
|
// src/agents/acp/internal-paths.ts
|
|
36040
|
-
var
|
|
36124
|
+
var path76 = __toESM(require("path"));
|
|
36041
36125
|
var os48 = __toESM(require("os"));
|
|
36042
36126
|
var INTERNAL_TOKENS = [".codeam", "house-claude"];
|
|
36043
36127
|
var PROSE_ONLY_TOOL_KINDS = /* @__PURE__ */ new Set(["think", "switch_mode"]);
|
|
@@ -36052,11 +36136,11 @@ function textReferencesInternal(text) {
|
|
|
36052
36136
|
}
|
|
36053
36137
|
function pathIsInternal(p2, homeDir2 = os48.homedir()) {
|
|
36054
36138
|
if (!p2) return false;
|
|
36055
|
-
const abs =
|
|
36056
|
-
const home =
|
|
36057
|
-
const within = (root) => abs === root || abs.startsWith(root +
|
|
36058
|
-
if (within(
|
|
36059
|
-
return within(
|
|
36139
|
+
const abs = path76.resolve(p2);
|
|
36140
|
+
const home = path76.resolve(homeDir2);
|
|
36141
|
+
const within = (root) => abs === root || abs.startsWith(root + path76.sep);
|
|
36142
|
+
if (within(path76.join(home, ".codeam", "self-hosted"))) return false;
|
|
36143
|
+
return within(path76.join(home, ".codeam")) || within(path76.join(home, ".beads")) || abs === path76.join(home, ".codeam-host.log") || abs.includes(`${path76.sep}house-claude${path76.sep}`) || abs.endsWith(`${path76.sep}house-claude`);
|
|
36060
36144
|
}
|
|
36061
36145
|
function toolCallReferencesInternal(call, homeDir2) {
|
|
36062
36146
|
if (call.locations?.some((l) => pathIsInternal(l.path, homeDir2))) return true;
|
|
@@ -37152,7 +37236,7 @@ var AcpClient = class {
|
|
|
37152
37236
|
throw new RequestError(-32002, GUARDRAIL_SECRET_READ_BLOCK_REASON, { uri: params.path });
|
|
37153
37237
|
}
|
|
37154
37238
|
try {
|
|
37155
|
-
const content = await
|
|
37239
|
+
const content = await fs66.readFile(params.path, "utf8");
|
|
37156
37240
|
return applyLineRange(content, params.line ?? null, params.limit ?? null);
|
|
37157
37241
|
} catch (err) {
|
|
37158
37242
|
const code = err.code;
|
|
@@ -37173,7 +37257,7 @@ var AcpClient = class {
|
|
|
37173
37257
|
throw new RequestError(-32002, INTERNAL_BLOCK_REASON, { uri: params.path });
|
|
37174
37258
|
}
|
|
37175
37259
|
try {
|
|
37176
|
-
await
|
|
37260
|
+
await fs66.writeFile(params.path, params.content, "utf8");
|
|
37177
37261
|
return {};
|
|
37178
37262
|
} catch (err) {
|
|
37179
37263
|
const code = err.code;
|
|
@@ -37266,25 +37350,25 @@ function knownAgentBinaryDirs() {
|
|
|
37266
37350
|
out2.push("/tmp/codeam-node20/bin");
|
|
37267
37351
|
for (const root of [
|
|
37268
37352
|
"/usr/local/share/nvm/versions/node",
|
|
37269
|
-
|
|
37353
|
+
path77.join(home, ".nvm/versions/node")
|
|
37270
37354
|
]) {
|
|
37271
37355
|
try {
|
|
37272
37356
|
for (const child of fsSync.readdirSync(root)) {
|
|
37273
|
-
out2.push(
|
|
37357
|
+
out2.push(path77.join(root, child, "bin"));
|
|
37274
37358
|
}
|
|
37275
37359
|
} catch {
|
|
37276
37360
|
}
|
|
37277
37361
|
}
|
|
37278
|
-
out2.push(
|
|
37362
|
+
out2.push(path77.join(home, ".volta/bin"));
|
|
37279
37363
|
out2.push("/usr/local/bin");
|
|
37280
37364
|
out2.push("/usr/bin");
|
|
37281
|
-
out2.push(
|
|
37282
|
-
out2.push(
|
|
37365
|
+
out2.push(path77.join(home, ".local/bin"));
|
|
37366
|
+
out2.push(path77.join(home, "bin"));
|
|
37283
37367
|
out2.push(...agentInstallBinDirs());
|
|
37284
37368
|
if (process.platform === "win32") {
|
|
37285
37369
|
const { LOCALAPPDATA, APPDATA } = process.env;
|
|
37286
|
-
if (LOCALAPPDATA) out2.push(
|
|
37287
|
-
if (APPDATA) out2.push(
|
|
37370
|
+
if (LOCALAPPDATA) out2.push(path77.join(LOCALAPPDATA, "cursor-agent"));
|
|
37371
|
+
if (APPDATA) out2.push(path77.join(APPDATA, "npm"));
|
|
37288
37372
|
}
|
|
37289
37373
|
return out2.filter((p2) => {
|
|
37290
37374
|
try {
|
|
@@ -37295,7 +37379,7 @@ function knownAgentBinaryDirs() {
|
|
|
37295
37379
|
});
|
|
37296
37380
|
}
|
|
37297
37381
|
function expandPathForAgentBinaries(existingPath) {
|
|
37298
|
-
const existing = new Set(existingPath.split(
|
|
37382
|
+
const existing = new Set(existingPath.split(path77.delimiter).filter((p2) => p2.length > 0));
|
|
37299
37383
|
const additions = [];
|
|
37300
37384
|
for (const dir of knownAgentBinaryDirs()) {
|
|
37301
37385
|
if (!existing.has(dir)) {
|
|
@@ -37304,7 +37388,7 @@ function expandPathForAgentBinaries(existingPath) {
|
|
|
37304
37388
|
}
|
|
37305
37389
|
}
|
|
37306
37390
|
if (additions.length === 0) return existingPath;
|
|
37307
|
-
return [...additions, existingPath].filter((p2) => p2.length > 0).join(
|
|
37391
|
+
return [...additions, existingPath].filter((p2) => p2.length > 0).join(path77.delimiter);
|
|
37308
37392
|
}
|
|
37309
37393
|
|
|
37310
37394
|
// src/commands/host/agent-install.ts
|
|
@@ -37576,9 +37660,9 @@ async function performAgentSwitch(deps, rawAgentId, fastPath = {}) {
|
|
|
37576
37660
|
}
|
|
37577
37661
|
|
|
37578
37662
|
// src/commands/host/agent-provisioning.ts
|
|
37579
|
-
var
|
|
37663
|
+
var fs67 = __toESM(require("fs"));
|
|
37580
37664
|
var os51 = __toESM(require("os"));
|
|
37581
|
-
var
|
|
37665
|
+
var path78 = __toESM(require("path"));
|
|
37582
37666
|
var PUBLIC_TO_INTERNAL_AGENT = {
|
|
37583
37667
|
claude_code: "claude",
|
|
37584
37668
|
claude: "claude",
|
|
@@ -37595,22 +37679,22 @@ function toInternalAgentId(publicAgentId) {
|
|
|
37595
37679
|
return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
|
|
37596
37680
|
}
|
|
37597
37681
|
function ensureDir(dir) {
|
|
37598
|
-
|
|
37682
|
+
fs67.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
37599
37683
|
}
|
|
37600
37684
|
function writeFile0600(filePath, contents) {
|
|
37601
|
-
ensureDir(
|
|
37602
|
-
|
|
37685
|
+
ensureDir(path78.dirname(filePath));
|
|
37686
|
+
fs67.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
|
|
37603
37687
|
restrictToOwner(filePath);
|
|
37604
37688
|
}
|
|
37605
37689
|
function rmIfExists(filePath) {
|
|
37606
37690
|
try {
|
|
37607
|
-
|
|
37691
|
+
fs67.rmSync(filePath, { force: true });
|
|
37608
37692
|
} catch {
|
|
37609
37693
|
}
|
|
37610
37694
|
}
|
|
37611
37695
|
var claudeProvisioner = {
|
|
37612
37696
|
write(auth, home) {
|
|
37613
|
-
const credentialsJson =
|
|
37697
|
+
const credentialsJson = path78.join(home, ".claude", ".credentials.json");
|
|
37614
37698
|
if (auth.kind === "api_key") {
|
|
37615
37699
|
rmIfExists(credentialsJson);
|
|
37616
37700
|
return { ANTHROPIC_API_KEY: auth.value };
|
|
@@ -37622,8 +37706,8 @@ var claudeProvisioner = {
|
|
|
37622
37706
|
} else {
|
|
37623
37707
|
rmIfExists(credentialsJson);
|
|
37624
37708
|
}
|
|
37625
|
-
const claudeJson =
|
|
37626
|
-
if (!
|
|
37709
|
+
const claudeJson = path78.join(home, ".claude.json");
|
|
37710
|
+
if (!fs67.existsSync(claudeJson)) {
|
|
37627
37711
|
writeFile0600(
|
|
37628
37712
|
claudeJson,
|
|
37629
37713
|
JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
|
|
@@ -37634,7 +37718,7 @@ var claudeProvisioner = {
|
|
|
37634
37718
|
};
|
|
37635
37719
|
var codexProvisioner = {
|
|
37636
37720
|
write(auth, home) {
|
|
37637
|
-
const authJson =
|
|
37721
|
+
const authJson = path78.join(home, ".codex", "auth.json");
|
|
37638
37722
|
if (auth.kind === "api_key") {
|
|
37639
37723
|
writeFile0600(authJson, JSON.stringify({ auth_mode: "apikey", OPENAI_API_KEY: auth.value }));
|
|
37640
37724
|
return { OPENAI_API_KEY: auth.value };
|
|
@@ -37657,7 +37741,7 @@ function codexLoginStamp(raw) {
|
|
|
37657
37741
|
function keepsFresherCodexLogin(authJsonPath, incoming) {
|
|
37658
37742
|
let onDisk;
|
|
37659
37743
|
try {
|
|
37660
|
-
onDisk =
|
|
37744
|
+
onDisk = fs67.readFileSync(authJsonPath, "utf8");
|
|
37661
37745
|
} catch {
|
|
37662
37746
|
return false;
|
|
37663
37747
|
}
|
|
@@ -37668,8 +37752,8 @@ function keepsFresherCodexLogin(authJsonPath, incoming) {
|
|
|
37668
37752
|
}
|
|
37669
37753
|
var geminiProvisioner = {
|
|
37670
37754
|
write(auth, home) {
|
|
37671
|
-
const settingsJson =
|
|
37672
|
-
const oauthCreds =
|
|
37755
|
+
const settingsJson = path78.join(home, ".gemini", "settings.json");
|
|
37756
|
+
const oauthCreds = path78.join(home, ".gemini", "oauth_creds.json");
|
|
37673
37757
|
if (auth.kind === "api_key") {
|
|
37674
37758
|
rmIfExists(oauthCreds);
|
|
37675
37759
|
writeFile0600(settingsJson, '{"security":{"auth":{"selectedType":"gemini-api-key"}}}');
|
|
@@ -37682,7 +37766,7 @@ var geminiProvisioner = {
|
|
|
37682
37766
|
};
|
|
37683
37767
|
var cursorProvisioner = {
|
|
37684
37768
|
write(auth, home) {
|
|
37685
|
-
const authJson =
|
|
37769
|
+
const authJson = path78.join(home, ".config", "cursor", "auth.json");
|
|
37686
37770
|
if (auth.kind === "api_key") {
|
|
37687
37771
|
rmIfExists(authJson);
|
|
37688
37772
|
return { CURSOR_API_KEY: auth.value };
|
|
@@ -37724,22 +37808,22 @@ max_context_size = 262144
|
|
|
37724
37808
|
var kimiProvisioner = {
|
|
37725
37809
|
write(auth, home) {
|
|
37726
37810
|
const credentialsFiles = [
|
|
37727
|
-
|
|
37728
|
-
|
|
37811
|
+
path78.join(home, ".kimi", "credentials", "kimi-code.json"),
|
|
37812
|
+
path78.join(home, ".kimi-code", "credentials", "kimi-code.json")
|
|
37729
37813
|
];
|
|
37730
37814
|
if (auth.kind === "api_key") {
|
|
37731
37815
|
credentialsFiles.forEach(rmIfExists);
|
|
37732
37816
|
return { KIMI_API_KEY: auth.value };
|
|
37733
37817
|
}
|
|
37734
37818
|
credentialsFiles.forEach((f) => writeFile0600(f, auth.value));
|
|
37735
|
-
writeFile0600(
|
|
37819
|
+
writeFile0600(path78.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
|
|
37736
37820
|
return {};
|
|
37737
37821
|
}
|
|
37738
37822
|
};
|
|
37739
37823
|
var coderabbitProvisioner = {
|
|
37740
37824
|
write(auth, home) {
|
|
37741
|
-
const dir =
|
|
37742
|
-
const authJson =
|
|
37825
|
+
const dir = path78.join(home, ".coderabbit");
|
|
37826
|
+
const authJson = path78.join(dir, "auth.json");
|
|
37743
37827
|
if (auth.kind === "api_key") {
|
|
37744
37828
|
rmIfExists(authJson);
|
|
37745
37829
|
return { CODERABBIT_API_KEY: auth.value };
|
|
@@ -37751,13 +37835,13 @@ var coderabbitProvisioner = {
|
|
|
37751
37835
|
try {
|
|
37752
37836
|
const parsed = JSON.parse(value);
|
|
37753
37837
|
if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
|
|
37754
|
-
file =
|
|
37838
|
+
file = path78.basename(parsed.file);
|
|
37755
37839
|
contents = parsed.contents;
|
|
37756
37840
|
}
|
|
37757
37841
|
} catch {
|
|
37758
37842
|
}
|
|
37759
37843
|
}
|
|
37760
|
-
writeFile0600(
|
|
37844
|
+
writeFile0600(path78.join(dir, file), contents);
|
|
37761
37845
|
return {};
|
|
37762
37846
|
}
|
|
37763
37847
|
};
|
|
@@ -37794,8 +37878,8 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os51.homedir(
|
|
|
37794
37878
|
}
|
|
37795
37879
|
|
|
37796
37880
|
// src/beads/workflow-hint.ts
|
|
37797
|
-
var
|
|
37798
|
-
var
|
|
37881
|
+
var fs68 = __toESM(require("fs"));
|
|
37882
|
+
var path79 = __toESM(require("path"));
|
|
37799
37883
|
var BEADS_HINT_MARKER = "<!-- codeam:beads-workflow -->";
|
|
37800
37884
|
var BEADS_HINT = `${BEADS_HINT_MARKER}
|
|
37801
37885
|
# Beads (bd) \u2014 task tracking + persistent memory (ALWAYS use it)
|
|
@@ -37822,11 +37906,11 @@ function ensureBeadsWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
|
37822
37906
|
try {
|
|
37823
37907
|
let existing = "";
|
|
37824
37908
|
try {
|
|
37825
|
-
existing =
|
|
37909
|
+
existing = fs68.readFileSync(file, "utf8");
|
|
37826
37910
|
} catch {
|
|
37827
37911
|
}
|
|
37828
37912
|
if (existing.includes(BEADS_HINT)) return;
|
|
37829
|
-
|
|
37913
|
+
fs68.mkdirSync(path79.dirname(file), { recursive: true });
|
|
37830
37914
|
let next;
|
|
37831
37915
|
const open = existing.indexOf(BEADS_HINT_MARKER);
|
|
37832
37916
|
const close = open === -1 ? -1 : existing.indexOf(BEADS_HINT_MARKER, open + BEADS_HINT_MARKER.length);
|
|
@@ -37839,40 +37923,40 @@ ${BEADS_HINT}
|
|
|
37839
37923
|
` : `${BEADS_HINT}
|
|
37840
37924
|
`;
|
|
37841
37925
|
}
|
|
37842
|
-
|
|
37926
|
+
fs68.writeFileSync(file, next);
|
|
37843
37927
|
} catch {
|
|
37844
37928
|
}
|
|
37845
37929
|
}
|
|
37846
37930
|
|
|
37847
37931
|
// src/agents/agent-standard.ts
|
|
37848
|
-
var
|
|
37849
|
-
var
|
|
37932
|
+
var fs69 = __toESM(require("fs"));
|
|
37933
|
+
var path80 = __toESM(require("path"));
|
|
37850
37934
|
var os52 = __toESM(require("os"));
|
|
37851
37935
|
function ensureAgentStandard(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
37852
37936
|
try {
|
|
37853
37937
|
let existing = "";
|
|
37854
37938
|
try {
|
|
37855
|
-
existing =
|
|
37939
|
+
existing = fs69.readFileSync(file, "utf8");
|
|
37856
37940
|
} catch {
|
|
37857
37941
|
}
|
|
37858
37942
|
if (existing.includes(AGENT_STANDARD_MARKER)) return;
|
|
37859
|
-
|
|
37943
|
+
fs69.mkdirSync(path80.dirname(file), { recursive: true });
|
|
37860
37944
|
const next = existing.trim() ? `${existing.trimEnd()}
|
|
37861
37945
|
|
|
37862
37946
|
${AGENT_STANDARD_BLOCK}
|
|
37863
37947
|
` : `${AGENT_STANDARD_BLOCK}
|
|
37864
37948
|
`;
|
|
37865
|
-
|
|
37949
|
+
fs69.writeFileSync(file, next);
|
|
37866
37950
|
} catch {
|
|
37867
37951
|
}
|
|
37868
37952
|
}
|
|
37869
37953
|
var _agentStandardSeam = {
|
|
37870
37954
|
isLocalSession: () => isLocalSession(),
|
|
37871
|
-
markerPath: (sessionId) =>
|
|
37872
|
-
exists: (p2) =>
|
|
37955
|
+
markerPath: (sessionId) => path80.join(os52.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
|
|
37956
|
+
exists: (p2) => fs69.existsSync(p2),
|
|
37873
37957
|
write: (p2) => {
|
|
37874
|
-
|
|
37875
|
-
|
|
37958
|
+
fs69.mkdirSync(path80.dirname(p2), { recursive: true });
|
|
37959
|
+
fs69.writeFileSync(p2, "");
|
|
37876
37960
|
}
|
|
37877
37961
|
};
|
|
37878
37962
|
function isClaude(agent) {
|
|
@@ -37892,6 +37976,48 @@ function maybePrefaceAgentStandard(blocks, agent, sessionId, seam = _agentStanda
|
|
|
37892
37976
|
blocks.unshift({ type: "text", text: AGENT_STANDARD_TEXT });
|
|
37893
37977
|
}
|
|
37894
37978
|
|
|
37979
|
+
// src/scratch/workflow-hint.ts
|
|
37980
|
+
var import_node_fs18 = __toESM(require("fs"));
|
|
37981
|
+
var import_node_path19 = __toESM(require("path"));
|
|
37982
|
+
var SCRATCH_HINT_MARKER = "<!-- codeam:scratch-workflow -->";
|
|
37983
|
+
var SCRATCH_HINT = `${SCRATCH_HINT_MARKER}
|
|
37984
|
+
# From-scratch projects (CodeAgent Box)
|
|
37985
|
+
|
|
37986
|
+
When the working directory is a project started from scratch (no git remote,
|
|
37987
|
+
a \`.git/codeam-scratch\` marker):
|
|
37988
|
+
|
|
37989
|
+
- Build something small, visible and working first. As soon as it can be
|
|
37990
|
+
seen, start it with the \`codeagent_preview\` \`start_preview\` tool and tell the
|
|
37991
|
+
user the preview is open.
|
|
37992
|
+
- If the user asks what you can do or for ideas, list them in a few short
|
|
37993
|
+
lines and build the first one in the same turn (unless they ask you to
|
|
37994
|
+
wait), so they see something running right away.
|
|
37995
|
+
- Saving is the user's choice in the app (Save to GitHub / GitLab, or a ZIP).
|
|
37996
|
+
Never push, create repositories or ask for git credentials yourself. Once the
|
|
37997
|
+
user has seen something working, call \`suggest_save_project\` ONCE if the
|
|
37998
|
+
app has not offered to save yet.
|
|
37999
|
+
${SCRATCH_HINT_MARKER}`;
|
|
38000
|
+
function ensureScratchWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
38001
|
+
try {
|
|
38002
|
+
let existing = "";
|
|
38003
|
+
try {
|
|
38004
|
+
existing = import_node_fs18.default.readFileSync(file, "utf8");
|
|
38005
|
+
} catch {
|
|
38006
|
+
}
|
|
38007
|
+
if (existing.includes(SCRATCH_HINT)) return;
|
|
38008
|
+
import_node_fs18.default.mkdirSync(import_node_path19.default.dirname(file), { recursive: true });
|
|
38009
|
+
const open = existing.indexOf(SCRATCH_HINT_MARKER);
|
|
38010
|
+
const close = open === -1 ? -1 : existing.indexOf(SCRATCH_HINT_MARKER, open + SCRATCH_HINT_MARKER.length);
|
|
38011
|
+
const next = open !== -1 && close !== -1 ? existing.slice(0, open) + SCRATCH_HINT + existing.slice(close + SCRATCH_HINT_MARKER.length) : existing.trim() ? `${existing.trimEnd()}
|
|
38012
|
+
|
|
38013
|
+
${SCRATCH_HINT}
|
|
38014
|
+
` : `${SCRATCH_HINT}
|
|
38015
|
+
`;
|
|
38016
|
+
import_node_fs18.default.writeFileSync(file, next);
|
|
38017
|
+
} catch {
|
|
38018
|
+
}
|
|
38019
|
+
}
|
|
38020
|
+
|
|
37895
38021
|
// src/services/streaming/transport.ts
|
|
37896
38022
|
var http11 = __toESM(require("http"));
|
|
37897
38023
|
var https7 = __toESM(require("https"));
|
|
@@ -38565,15 +38691,15 @@ function withholdTrailingPartialFenceMarker(text) {
|
|
|
38565
38691
|
|
|
38566
38692
|
// src/agents/acp/onboarding.ts
|
|
38567
38693
|
var import_child_process28 = require("child_process");
|
|
38568
|
-
var
|
|
38694
|
+
var fs71 = __toESM(require("fs"));
|
|
38569
38695
|
var os53 = __toESM(require("os"));
|
|
38570
|
-
var
|
|
38696
|
+
var path82 = __toESM(require("path"));
|
|
38571
38697
|
var _onboardingSeam = {
|
|
38572
|
-
markerPath: (sessionId) =>
|
|
38573
|
-
exists: (p2) =>
|
|
38698
|
+
markerPath: (sessionId) => path82.join(os53.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
|
|
38699
|
+
exists: (p2) => fs71.existsSync(p2),
|
|
38574
38700
|
write: (p2) => {
|
|
38575
|
-
|
|
38576
|
-
|
|
38701
|
+
fs71.mkdirSync(path82.dirname(p2), { recursive: true });
|
|
38702
|
+
fs71.writeFileSync(p2, "");
|
|
38577
38703
|
},
|
|
38578
38704
|
disabled: () => {
|
|
38579
38705
|
const v = process.env.CODEAM_ONBOARDING_DISABLED;
|
|
@@ -38610,7 +38736,7 @@ function resolveRepoName(cwd) {
|
|
|
38610
38736
|
if (name) return name;
|
|
38611
38737
|
}
|
|
38612
38738
|
}
|
|
38613
|
-
const base =
|
|
38739
|
+
const base = path82.basename(cwd || "");
|
|
38614
38740
|
if (base && !isUuid(base)) return base;
|
|
38615
38741
|
return "this project";
|
|
38616
38742
|
}
|
|
@@ -39002,14 +39128,14 @@ var import_crypto5 = require("crypto");
|
|
|
39002
39128
|
|
|
39003
39129
|
// src/services/turn-files/git-changeset.ts
|
|
39004
39130
|
var import_child_process29 = require("child_process");
|
|
39005
|
-
var
|
|
39131
|
+
var fs73 = __toESM(require("fs/promises"));
|
|
39006
39132
|
var import_fs7 = require("fs");
|
|
39007
|
-
var
|
|
39133
|
+
var path84 = __toESM(require("path"));
|
|
39008
39134
|
|
|
39009
39135
|
// src/services/turn-files/review-ignore.ts
|
|
39010
39136
|
var import_ignore2 = __toESM(require("ignore"));
|
|
39011
|
-
var
|
|
39012
|
-
var
|
|
39137
|
+
var fs72 = __toESM(require("fs"));
|
|
39138
|
+
var path83 = __toESM(require("path"));
|
|
39013
39139
|
var CURATED_REVIEW_IGNORE = [
|
|
39014
39140
|
// Google Cloud SDK (the incident) — installs a huge python tree.
|
|
39015
39141
|
"google-cloud-sdk/",
|
|
@@ -39053,7 +39179,7 @@ var CURATED_REVIEW_IGNORE = [
|
|
|
39053
39179
|
function makeReviewIgnore(repoRoot) {
|
|
39054
39180
|
const ig = (0, import_ignore2.default)().add(CURATED_REVIEW_IGNORE);
|
|
39055
39181
|
try {
|
|
39056
|
-
const custom =
|
|
39182
|
+
const custom = fs72.readFileSync(path83.join(repoRoot, ".codeam", "reviewignore"), "utf8");
|
|
39057
39183
|
ig.add(custom);
|
|
39058
39184
|
} catch {
|
|
39059
39185
|
}
|
|
@@ -39088,7 +39214,7 @@ async function collectRepoChangeset(opts) {
|
|
|
39088
39214
|
const rows = parseStatus(status2).filter(
|
|
39089
39215
|
(row) => !isIgnoredFilePath(row.filePath) && !reviewIgnore(row.filePath) && // A socket, FIFO or device node is never a change to review (a
|
|
39090
39216
|
// `cc-socks/1522.sock` reached the Files tab).
|
|
39091
|
-
isReviewablePath(
|
|
39217
|
+
isReviewablePath(path84.join(opts.repoRoot, row.filePath))
|
|
39092
39218
|
);
|
|
39093
39219
|
const MAX_CHANGESET_FILES = Math.max(1, Number(process.env.CODEAM_MAX_CHANGESET_FILES ?? 500));
|
|
39094
39220
|
const truncated = rows.length > MAX_CHANGESET_FILES;
|
|
@@ -39105,7 +39231,7 @@ async function collectRepoChangeset(opts) {
|
|
|
39105
39231
|
let stats;
|
|
39106
39232
|
if (!truncated && row.fileStatus === "added" && numstatEntry === void 0) {
|
|
39107
39233
|
const lineCount = await readUntrackedLineCount(
|
|
39108
|
-
|
|
39234
|
+
path84.join(opts.repoRoot, row.filePath)
|
|
39109
39235
|
);
|
|
39110
39236
|
stats = { added: lineCount, removed: 0 };
|
|
39111
39237
|
} else {
|
|
@@ -39136,7 +39262,7 @@ function readUntrackedLineCount(absPath) {
|
|
|
39136
39262
|
}
|
|
39137
39263
|
async function defaultReadUntrackedLineCount(absPath) {
|
|
39138
39264
|
try {
|
|
39139
|
-
const content = await
|
|
39265
|
+
const content = await fs73.readFile(absPath, "utf8");
|
|
39140
39266
|
let count = 0;
|
|
39141
39267
|
let pos = -1;
|
|
39142
39268
|
while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
|
|
@@ -39228,7 +39354,7 @@ function defaultRunGit(cwd, args2) {
|
|
|
39228
39354
|
});
|
|
39229
39355
|
}
|
|
39230
39356
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
39231
|
-
const
|
|
39357
|
+
const fs94 = await import("fs/promises");
|
|
39232
39358
|
const out2 = [];
|
|
39233
39359
|
await walk2(workingDir, 0);
|
|
39234
39360
|
return out2;
|
|
@@ -39236,7 +39362,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
39236
39362
|
if (depth2 > maxDepth) return;
|
|
39237
39363
|
let entries2 = [];
|
|
39238
39364
|
try {
|
|
39239
|
-
const dirents = await
|
|
39365
|
+
const dirents = await fs94.readdir(dir, { withFileTypes: true });
|
|
39240
39366
|
entries2 = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
39241
39367
|
} catch {
|
|
39242
39368
|
return;
|
|
@@ -39247,8 +39373,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
39247
39373
|
if (hasGit) {
|
|
39248
39374
|
out2.push({
|
|
39249
39375
|
repoRoot: dir,
|
|
39250
|
-
repoPath:
|
|
39251
|
-
repoName:
|
|
39376
|
+
repoPath: path84.relative(workingDir, dir),
|
|
39377
|
+
repoName: path84.basename(dir)
|
|
39252
39378
|
});
|
|
39253
39379
|
return;
|
|
39254
39380
|
}
|
|
@@ -39256,7 +39382,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
39256
39382
|
if (!entry.isDirectory) continue;
|
|
39257
39383
|
if (entry.name === "node_modules") continue;
|
|
39258
39384
|
if (entry.name === "dist" || entry.name === "build") continue;
|
|
39259
|
-
await walk2(
|
|
39385
|
+
await walk2(path84.join(dir, entry.name), depth2 + 1);
|
|
39260
39386
|
}
|
|
39261
39387
|
}
|
|
39262
39388
|
}
|
|
@@ -39270,8 +39396,8 @@ function isReviewablePath(absPath) {
|
|
|
39270
39396
|
}
|
|
39271
39397
|
|
|
39272
39398
|
// src/services/turn-files/files-outbox.ts
|
|
39273
|
-
var
|
|
39274
|
-
var
|
|
39399
|
+
var fs74 = __toESM(require("fs/promises"));
|
|
39400
|
+
var path85 = __toESM(require("path"));
|
|
39275
39401
|
var import_os12 = require("os");
|
|
39276
39402
|
var HOME_OUTBOX_DIR = ".codeam/outbox";
|
|
39277
39403
|
var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -39304,16 +39430,16 @@ var FilesOutbox = class {
|
|
|
39304
39430
|
backoffIndex = 0;
|
|
39305
39431
|
stopped = false;
|
|
39306
39432
|
constructor(opts) {
|
|
39307
|
-
const base = opts.baseDir ??
|
|
39308
|
-
this.filePath =
|
|
39433
|
+
const base = opts.baseDir ?? path85.join(homeDir(), HOME_OUTBOX_DIR);
|
|
39434
|
+
this.filePath = path85.join(base, `${opts.sessionId}.jsonl`);
|
|
39309
39435
|
this.post = opts.post;
|
|
39310
39436
|
this.autoSchedule = opts.autoSchedule !== false;
|
|
39311
39437
|
}
|
|
39312
39438
|
/** Persist the entry to disk and trigger a flush. Returns once the
|
|
39313
39439
|
* line is durable on disk (not once the POST succeeds). */
|
|
39314
39440
|
async enqueue(entry) {
|
|
39315
|
-
await
|
|
39316
|
-
await
|
|
39441
|
+
await fs74.mkdir(path85.dirname(this.filePath), { recursive: true });
|
|
39442
|
+
await fs74.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
|
|
39317
39443
|
this.backoffIndex = 0;
|
|
39318
39444
|
if (this.autoSchedule) this.scheduleFlush(0);
|
|
39319
39445
|
}
|
|
@@ -39404,7 +39530,7 @@ var FilesOutbox = class {
|
|
|
39404
39530
|
async readAll() {
|
|
39405
39531
|
let raw = "";
|
|
39406
39532
|
try {
|
|
39407
|
-
raw = await
|
|
39533
|
+
raw = await fs74.readFile(this.filePath, "utf8");
|
|
39408
39534
|
} catch {
|
|
39409
39535
|
return [];
|
|
39410
39536
|
}
|
|
@@ -39428,12 +39554,12 @@ var FilesOutbox = class {
|
|
|
39428
39554
|
async rewrite(entries2) {
|
|
39429
39555
|
const tmpPath = `${this.filePath}.${process.pid}.tmp`;
|
|
39430
39556
|
if (entries2.length === 0) {
|
|
39431
|
-
await
|
|
39557
|
+
await fs74.unlink(this.filePath).catch(() => void 0);
|
|
39432
39558
|
return;
|
|
39433
39559
|
}
|
|
39434
39560
|
const payload = entries2.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
39435
|
-
await
|
|
39436
|
-
await
|
|
39561
|
+
await fs74.writeFile(tmpPath, payload, "utf8");
|
|
39562
|
+
await fs74.rename(tmpPath, this.filePath);
|
|
39437
39563
|
}
|
|
39438
39564
|
};
|
|
39439
39565
|
function applyJitter(ms) {
|
|
@@ -39753,15 +39879,15 @@ async function postCredentialSync(opts, fetchImpl = fetch) {
|
|
|
39753
39879
|
var import_node_crypto13 = require("crypto");
|
|
39754
39880
|
var import_promises6 = __toESM(require("fs/promises"));
|
|
39755
39881
|
var import_node_os14 = __toESM(require("os"));
|
|
39756
|
-
var
|
|
39757
|
-
function
|
|
39758
|
-
const key = (0, import_node_crypto13.createHash)("sha256").update(
|
|
39759
|
-
return
|
|
39882
|
+
var import_node_path20 = __toESM(require("path"));
|
|
39883
|
+
function markerPath4(cwd, homeDir2 = import_node_os14.default.homedir()) {
|
|
39884
|
+
const key = (0, import_node_crypto13.createHash)("sha256").update(import_node_path20.default.resolve(cwd)).digest("hex").slice(0, 16);
|
|
39885
|
+
return import_node_path20.default.join(homeDir2, ".codeam", "conversation-active", `${key}.json`);
|
|
39760
39886
|
}
|
|
39761
39887
|
async function writeActiveConversationMarker(cwd, conversationId, homeDir2) {
|
|
39762
39888
|
try {
|
|
39763
|
-
const file =
|
|
39764
|
-
await import_promises6.default.mkdir(
|
|
39889
|
+
const file = markerPath4(cwd, homeDir2);
|
|
39890
|
+
await import_promises6.default.mkdir(import_node_path20.default.dirname(file), { recursive: true });
|
|
39765
39891
|
await import_promises6.default.writeFile(
|
|
39766
39892
|
file,
|
|
39767
39893
|
JSON.stringify({ conversationId, at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2) + "\n",
|
|
@@ -39772,7 +39898,7 @@ async function writeActiveConversationMarker(cwd, conversationId, homeDir2) {
|
|
|
39772
39898
|
}
|
|
39773
39899
|
async function readActiveConversationMarker(cwd, homeDir2) {
|
|
39774
39900
|
try {
|
|
39775
|
-
const raw = await import_promises6.default.readFile(
|
|
39901
|
+
const raw = await import_promises6.default.readFile(markerPath4(cwd, homeDir2), "utf8");
|
|
39776
39902
|
const parsed = JSON.parse(raw);
|
|
39777
39903
|
return typeof parsed.conversationId === "string" && parsed.conversationId ? parsed.conversationId : null;
|
|
39778
39904
|
} catch {
|
|
@@ -39781,27 +39907,27 @@ async function readActiveConversationMarker(cwd, homeDir2) {
|
|
|
39781
39907
|
}
|
|
39782
39908
|
|
|
39783
39909
|
// src/services/turn-marker.ts
|
|
39784
|
-
var
|
|
39910
|
+
var fs76 = __toESM(require("fs"));
|
|
39785
39911
|
var os55 = __toESM(require("os"));
|
|
39786
|
-
var
|
|
39912
|
+
var path87 = __toESM(require("path"));
|
|
39787
39913
|
var depth = 0;
|
|
39788
39914
|
function codeamHome() {
|
|
39789
|
-
return
|
|
39915
|
+
return path87.join(os55.homedir(), ".codeam");
|
|
39790
39916
|
}
|
|
39791
39917
|
function turnMarkerPath(pid = process.pid, home = codeamHome()) {
|
|
39792
|
-
return
|
|
39918
|
+
return path87.join(home, "turns", String(pid));
|
|
39793
39919
|
}
|
|
39794
39920
|
function mark() {
|
|
39795
39921
|
try {
|
|
39796
39922
|
const file = turnMarkerPath();
|
|
39797
|
-
|
|
39798
|
-
|
|
39923
|
+
fs76.mkdirSync(path87.dirname(file), { recursive: true });
|
|
39924
|
+
fs76.writeFileSync(file, String(Date.now()));
|
|
39799
39925
|
} catch {
|
|
39800
39926
|
}
|
|
39801
39927
|
}
|
|
39802
39928
|
function clear() {
|
|
39803
39929
|
try {
|
|
39804
|
-
|
|
39930
|
+
fs76.rmSync(turnMarkerPath(), { force: true });
|
|
39805
39931
|
} catch {
|
|
39806
39932
|
}
|
|
39807
39933
|
}
|
|
@@ -39816,7 +39942,7 @@ async function withTurnMarker(fn) {
|
|
|
39816
39942
|
function isProcessMidTurn(pid, home) {
|
|
39817
39943
|
if (!pid) return false;
|
|
39818
39944
|
try {
|
|
39819
|
-
return
|
|
39945
|
+
return fs76.existsSync(turnMarkerPath(pid, home));
|
|
39820
39946
|
} catch {
|
|
39821
39947
|
return false;
|
|
39822
39948
|
}
|
|
@@ -39824,8 +39950,8 @@ function isProcessMidTurn(pid, home) {
|
|
|
39824
39950
|
|
|
39825
39951
|
// src/packs/gates.ts
|
|
39826
39952
|
var import_node_child_process28 = require("child_process");
|
|
39827
|
-
var
|
|
39828
|
-
var
|
|
39953
|
+
var fs77 = __toESM(require("fs"));
|
|
39954
|
+
var path88 = __toESM(require("path"));
|
|
39829
39955
|
var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((resolve12) => {
|
|
39830
39956
|
(0, import_node_child_process28.execFile)(
|
|
39831
39957
|
file,
|
|
@@ -39875,7 +40001,7 @@ async function changedFiles(run3, cwd, from, to) {
|
|
|
39875
40001
|
}
|
|
39876
40002
|
function readWorkspaceFile(cwd, relPath) {
|
|
39877
40003
|
try {
|
|
39878
|
-
return
|
|
40004
|
+
return fs77.readFileSync(path88.join(cwd, relPath), "utf8");
|
|
39879
40005
|
} catch {
|
|
39880
40006
|
return null;
|
|
39881
40007
|
}
|
|
@@ -39884,14 +40010,14 @@ var NO_TEST_PLACEHOLDER = 'echo "Error: no test specified"';
|
|
|
39884
40010
|
var CHECKS_TIMEOUT_MS = 5 * 6e4;
|
|
39885
40011
|
function detectChecksCommand(cwd) {
|
|
39886
40012
|
try {
|
|
39887
|
-
const cfg = JSON.parse(
|
|
40013
|
+
const cfg = JSON.parse(fs77.readFileSync(path88.join(cwd, ".codeam", "pack.json"), "utf8"));
|
|
39888
40014
|
if (typeof cfg.checksCommand === "string" && cfg.checksCommand.trim().length > 0) {
|
|
39889
40015
|
return cfg.checksCommand.trim();
|
|
39890
40016
|
}
|
|
39891
40017
|
} catch {
|
|
39892
40018
|
}
|
|
39893
40019
|
try {
|
|
39894
|
-
const pkg = JSON.parse(
|
|
40020
|
+
const pkg = JSON.parse(fs77.readFileSync(path88.join(cwd, "package.json"), "utf8"));
|
|
39895
40021
|
const test = pkg.scripts?.test;
|
|
39896
40022
|
if (typeof test === "string" && test.trim().length > 0 && !test.includes(NO_TEST_PLACEHOLDER)) {
|
|
39897
40023
|
return "npm test";
|
|
@@ -39909,39 +40035,39 @@ ${res.stderr}`.trim();
|
|
|
39909
40035
|
}
|
|
39910
40036
|
|
|
39911
40037
|
// src/packs/run-store.ts
|
|
39912
|
-
var
|
|
39913
|
-
var
|
|
40038
|
+
var fs78 = __toESM(require("fs"));
|
|
40039
|
+
var path89 = __toESM(require("path"));
|
|
39914
40040
|
var crypto5 = __toESM(require("crypto"));
|
|
39915
40041
|
function packsDir(cwd) {
|
|
39916
|
-
return
|
|
40042
|
+
return path89.join(cwd, ".codeam", "packs");
|
|
39917
40043
|
}
|
|
39918
40044
|
function runDir(cwd, runId) {
|
|
39919
|
-
return
|
|
40045
|
+
return path89.join(packsDir(cwd), runId);
|
|
39920
40046
|
}
|
|
39921
40047
|
function newRunId() {
|
|
39922
40048
|
return `pk_${Date.now().toString(36)}_${crypto5.randomBytes(4).toString("hex")}`;
|
|
39923
40049
|
}
|
|
39924
40050
|
function writeJsonAtomic(file, value) {
|
|
39925
|
-
|
|
40051
|
+
fs78.mkdirSync(path89.dirname(file), { recursive: true });
|
|
39926
40052
|
const tmp = `${file}.tmp`;
|
|
39927
|
-
|
|
39928
|
-
|
|
40053
|
+
fs78.writeFileSync(tmp, JSON.stringify(value, null, 2));
|
|
40054
|
+
fs78.renameSync(tmp, file);
|
|
39929
40055
|
}
|
|
39930
40056
|
function saveRun(cwd, state) {
|
|
39931
|
-
writeJsonAtomic(
|
|
40057
|
+
writeJsonAtomic(path89.join(runDir(cwd, state.runId), "run.json"), state);
|
|
39932
40058
|
}
|
|
39933
40059
|
function saveStageHandoff(cwd, runId, stageIndex, role, handoff) {
|
|
39934
40060
|
const name = `${String(stageIndex + 1).padStart(2, "0")}-${role}.json`;
|
|
39935
|
-
writeJsonAtomic(
|
|
40061
|
+
writeJsonAtomic(path89.join(runDir(cwd, runId), name), handoff);
|
|
39936
40062
|
}
|
|
39937
40063
|
function loadLatestRun(cwd) {
|
|
39938
40064
|
try {
|
|
39939
40065
|
const dir = packsDir(cwd);
|
|
39940
|
-
const entries2 =
|
|
40066
|
+
const entries2 = fs78.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
39941
40067
|
for (let i = entries2.length - 1; i >= 0; i--) {
|
|
39942
|
-
const file =
|
|
40068
|
+
const file = path89.join(dir, entries2[i], "run.json");
|
|
39943
40069
|
try {
|
|
39944
|
-
const parsed = JSON.parse(
|
|
40070
|
+
const parsed = JSON.parse(fs78.readFileSync(file, "utf8"));
|
|
39945
40071
|
if (parsed && typeof parsed.runId === "string") return parsed;
|
|
39946
40072
|
} catch {
|
|
39947
40073
|
}
|
|
@@ -39952,17 +40078,17 @@ function loadLatestRun(cwd) {
|
|
|
39952
40078
|
}
|
|
39953
40079
|
function ensureLedgerIgnored(cwd) {
|
|
39954
40080
|
try {
|
|
39955
|
-
const gitDir =
|
|
39956
|
-
if (!
|
|
39957
|
-
const exclude =
|
|
40081
|
+
const gitDir = path89.join(cwd, ".git");
|
|
40082
|
+
if (!fs78.existsSync(gitDir)) return;
|
|
40083
|
+
const exclude = path89.join(gitDir, "info", "exclude");
|
|
39958
40084
|
let existing = "";
|
|
39959
40085
|
try {
|
|
39960
|
-
existing =
|
|
40086
|
+
existing = fs78.readFileSync(exclude, "utf8");
|
|
39961
40087
|
} catch {
|
|
39962
40088
|
}
|
|
39963
40089
|
if (existing.includes(".codeam/packs/")) return;
|
|
39964
|
-
|
|
39965
|
-
|
|
40090
|
+
fs78.mkdirSync(path89.dirname(exclude), { recursive: true });
|
|
40091
|
+
fs78.writeFileSync(exclude, `${existing.trimEnd()}
|
|
39966
40092
|
.codeam/packs/
|
|
39967
40093
|
`.trimStart());
|
|
39968
40094
|
} catch {
|
|
@@ -40739,15 +40865,15 @@ var packStatusH = async (ctx) => {
|
|
|
40739
40865
|
};
|
|
40740
40866
|
|
|
40741
40867
|
// src/integrations/manifest.ts
|
|
40742
|
-
var
|
|
40868
|
+
var import_node_fs19 = __toESM(require("fs"));
|
|
40743
40869
|
var import_node_os15 = __toESM(require("os"));
|
|
40744
|
-
var
|
|
40870
|
+
var import_node_path21 = __toESM(require("path"));
|
|
40745
40871
|
function integrationsManifestPath() {
|
|
40746
|
-
return
|
|
40872
|
+
return import_node_path21.default.join(import_node_os15.default.homedir(), ".codeam", "integrations.json");
|
|
40747
40873
|
}
|
|
40748
40874
|
function readIntegrationsManifest() {
|
|
40749
40875
|
try {
|
|
40750
|
-
const raw = JSON.parse(
|
|
40876
|
+
const raw = JSON.parse(import_node_fs19.default.readFileSync(integrationsManifestPath(), "utf8"));
|
|
40751
40877
|
if (!Array.isArray(raw?.integrations)) return null;
|
|
40752
40878
|
return raw;
|
|
40753
40879
|
} catch {
|
|
@@ -40757,10 +40883,10 @@ function readIntegrationsManifest() {
|
|
|
40757
40883
|
function persistIntegrationsManifest(m) {
|
|
40758
40884
|
try {
|
|
40759
40885
|
const file = integrationsManifestPath();
|
|
40760
|
-
|
|
40886
|
+
import_node_fs19.default.mkdirSync(import_node_path21.default.dirname(file), { recursive: true, mode: 448 });
|
|
40761
40887
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
40762
|
-
|
|
40763
|
-
|
|
40888
|
+
import_node_fs19.default.writeFileSync(tmp, JSON.stringify(m, null, 2), { encoding: "utf8", mode: 384 });
|
|
40889
|
+
import_node_fs19.default.renameSync(tmp, file);
|
|
40764
40890
|
restrictToOwner(file);
|
|
40765
40891
|
} catch (err) {
|
|
40766
40892
|
log.warn(
|
|
@@ -40771,7 +40897,7 @@ function persistIntegrationsManifest(m) {
|
|
|
40771
40897
|
}
|
|
40772
40898
|
function clearIntegrationsManifest() {
|
|
40773
40899
|
try {
|
|
40774
|
-
|
|
40900
|
+
import_node_fs19.default.rmSync(integrationsManifestPath(), { force: true });
|
|
40775
40901
|
} catch {
|
|
40776
40902
|
}
|
|
40777
40903
|
}
|
|
@@ -40943,20 +41069,20 @@ async function mcpRouter() {
|
|
|
40943
41069
|
}
|
|
40944
41070
|
|
|
40945
41071
|
// src/integrations/mcp-secrets.ts
|
|
40946
|
-
var
|
|
41072
|
+
var fs80 = __toESM(require("fs"));
|
|
40947
41073
|
var os57 = __toESM(require("os"));
|
|
40948
|
-
var
|
|
41074
|
+
var path91 = __toESM(require("path"));
|
|
40949
41075
|
var MCP_SECRETS_FILE_ENV = "CODEAM_MCP_SECRETS_FILE";
|
|
40950
41076
|
function mcpSecretsDir() {
|
|
40951
|
-
return
|
|
41077
|
+
return path91.join(os57.homedir(), ".codeam", "mcp-secrets");
|
|
40952
41078
|
}
|
|
40953
41079
|
function mcpSecretsPath(scope, pid = process.pid) {
|
|
40954
|
-
return
|
|
41080
|
+
return path91.join(mcpSecretsDir(), `${pid}-${scope}.json`);
|
|
40955
41081
|
}
|
|
40956
41082
|
var registeredForCleanup = /* @__PURE__ */ new Set();
|
|
40957
41083
|
function readFileVars(file) {
|
|
40958
41084
|
try {
|
|
40959
|
-
const parsed = JSON.parse(
|
|
41085
|
+
const parsed = JSON.parse(fs80.readFileSync(file, "utf8"));
|
|
40960
41086
|
if (!parsed || typeof parsed !== "object") return {};
|
|
40961
41087
|
const out2 = {};
|
|
40962
41088
|
for (const [k2, v] of Object.entries(parsed)) {
|
|
@@ -40978,7 +41104,7 @@ function pidAlive2(pid) {
|
|
|
40978
41104
|
function pruneStale(dir) {
|
|
40979
41105
|
let names = [];
|
|
40980
41106
|
try {
|
|
40981
|
-
names =
|
|
41107
|
+
names = fs80.readdirSync(dir);
|
|
40982
41108
|
} catch {
|
|
40983
41109
|
return;
|
|
40984
41110
|
}
|
|
@@ -40988,25 +41114,25 @@ function pruneStale(dir) {
|
|
|
40988
41114
|
const pid = Number(m[1]);
|
|
40989
41115
|
if (pid === process.pid || pidAlive2(pid)) continue;
|
|
40990
41116
|
try {
|
|
40991
|
-
|
|
41117
|
+
fs80.unlinkSync(path91.join(dir, name));
|
|
40992
41118
|
} catch {
|
|
40993
41119
|
}
|
|
40994
41120
|
}
|
|
40995
41121
|
}
|
|
40996
41122
|
function writeMcpSecrets(vars, file) {
|
|
40997
41123
|
try {
|
|
40998
|
-
const dir =
|
|
40999
|
-
|
|
41124
|
+
const dir = path91.dirname(file);
|
|
41125
|
+
fs80.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
41000
41126
|
pruneStale(dir);
|
|
41001
41127
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
41002
|
-
|
|
41003
|
-
|
|
41004
|
-
|
|
41128
|
+
fs80.writeFileSync(tmp, JSON.stringify(vars), { mode: 384 });
|
|
41129
|
+
fs80.renameSync(tmp, file);
|
|
41130
|
+
fs80.chmodSync(file, 384);
|
|
41005
41131
|
if (!registeredForCleanup.has(file)) {
|
|
41006
41132
|
registeredForCleanup.add(file);
|
|
41007
41133
|
process.once("exit", () => {
|
|
41008
41134
|
try {
|
|
41009
|
-
|
|
41135
|
+
fs80.unlinkSync(file);
|
|
41010
41136
|
} catch {
|
|
41011
41137
|
}
|
|
41012
41138
|
});
|
|
@@ -41092,11 +41218,11 @@ function previewMcpServer(bridge) {
|
|
|
41092
41218
|
};
|
|
41093
41219
|
}
|
|
41094
41220
|
function httpCall(baseUrl, token) {
|
|
41095
|
-
return async (
|
|
41221
|
+
return async (path109, method, body, timeoutMs) => {
|
|
41096
41222
|
const ac = new AbortController();
|
|
41097
41223
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
41098
41224
|
try {
|
|
41099
|
-
const res = await fetch(`${baseUrl}${
|
|
41225
|
+
const res = await fetch(`${baseUrl}${path109}`, {
|
|
41100
41226
|
method,
|
|
41101
41227
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
41102
41228
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -41201,6 +41327,7 @@ var SCRATCH_TOOLS = [
|
|
|
41201
41327
|
description: [
|
|
41202
41328
|
"This session is a from-scratch project on the user's CodeAgent Box. It is NOT connected to GitHub, and nothing is saved outside this workspace yet.",
|
|
41203
41329
|
"How to work here: build something small, visible and working. As soon as it can be seen, start it with the codeagent_preview start_preview tool and tell the user the preview is open.",
|
|
41330
|
+
"If the user asks what you can do or for ideas, list them in a few short lines and build the first one in the same turn (unless they ask you to wait), so they see something running right away.",
|
|
41204
41331
|
'Once the user has seen something working \u2014 or after a substantial change that is not saved yet \u2014 call this tool ONCE. It shows the user a "Save your project" card in the app (Save to GitHub or Download ZIP).',
|
|
41205
41332
|
"Do not push, create repositories or ask for GitHub credentials yourself: saving is the user's choice in the app. Do not call this tool again unless there are substantial new unsaved changes."
|
|
41206
41333
|
].join(" "),
|
|
@@ -41223,11 +41350,11 @@ function scratchMcpServer(bridge) {
|
|
|
41223
41350
|
};
|
|
41224
41351
|
}
|
|
41225
41352
|
function httpCall2(baseUrl, token) {
|
|
41226
|
-
return async (
|
|
41353
|
+
return async (path109, method, body, timeoutMs) => {
|
|
41227
41354
|
const ac = new AbortController();
|
|
41228
41355
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
41229
41356
|
try {
|
|
41230
|
-
const res = await fetch(`${baseUrl}${
|
|
41357
|
+
const res = await fetch(`${baseUrl}${path109}`, {
|
|
41231
41358
|
method,
|
|
41232
41359
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
41233
41360
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -41353,12 +41480,12 @@ function buildIntegrationMcpServers(ctx) {
|
|
|
41353
41480
|
}
|
|
41354
41481
|
|
|
41355
41482
|
// src/services/local-mcp-servers.ts
|
|
41356
|
-
var
|
|
41483
|
+
var import_node_fs20 = __toESM(require("fs"));
|
|
41357
41484
|
var import_node_os16 = __toESM(require("os"));
|
|
41358
|
-
var
|
|
41485
|
+
var import_node_path22 = __toESM(require("path"));
|
|
41359
41486
|
var MAX_LOCAL_MCP_SERVERS = 10;
|
|
41360
41487
|
function localMcpServersPath() {
|
|
41361
|
-
return
|
|
41488
|
+
return import_node_path22.default.join(import_node_os16.default.homedir(), ".codeam", "mcp-servers.json");
|
|
41362
41489
|
}
|
|
41363
41490
|
function isStringArray(v) {
|
|
41364
41491
|
return Array.isArray(v) && v.every((item) => typeof item === "string");
|
|
@@ -41376,7 +41503,7 @@ function isValidEntry(entry) {
|
|
|
41376
41503
|
function readLocalMcpServers() {
|
|
41377
41504
|
let raw;
|
|
41378
41505
|
try {
|
|
41379
|
-
raw =
|
|
41506
|
+
raw = import_node_fs20.default.readFileSync(localMcpServersPath(), "utf8");
|
|
41380
41507
|
} catch {
|
|
41381
41508
|
return [];
|
|
41382
41509
|
}
|
|
@@ -41767,11 +41894,11 @@ function readJson(req) {
|
|
|
41767
41894
|
var agentPreviewBridge = new AgentPreviewBridge();
|
|
41768
41895
|
|
|
41769
41896
|
// src/integrations/detect-stack.ts
|
|
41770
|
-
var
|
|
41771
|
-
var
|
|
41897
|
+
var import_node_fs21 = __toESM(require("fs"));
|
|
41898
|
+
var import_node_path23 = __toESM(require("path"));
|
|
41772
41899
|
function readSafe(cwd, rel) {
|
|
41773
41900
|
try {
|
|
41774
|
-
return
|
|
41901
|
+
return import_node_fs21.default.readFileSync(import_node_path23.default.join(cwd, rel), "utf8");
|
|
41775
41902
|
} catch {
|
|
41776
41903
|
return "";
|
|
41777
41904
|
}
|
|
@@ -42419,6 +42546,9 @@ async function startTaskH(ctx) {
|
|
|
42419
42546
|
`start_task \u2190 done stopReason=${reply.stopReason ?? "?"} id=${cmd.id.slice(0, 8)}`
|
|
42420
42547
|
);
|
|
42421
42548
|
await relay.sendResult(cmd.id, "completed", { stopReason: reply.stopReason });
|
|
42549
|
+
if (reply.stopReason === "end_turn" && maybeAutoOpenScratchPreview(opts.sessionId, agentPreviewBridge)) {
|
|
42550
|
+
log.info("acpRunner", "scratch: turn left a servable project and no preview \u2014 opening it");
|
|
42551
|
+
}
|
|
42422
42552
|
return;
|
|
42423
42553
|
}
|
|
42424
42554
|
} catch (err) {
|
|
@@ -44127,19 +44257,20 @@ async function runAcpSession(opts) {
|
|
|
44127
44257
|
switchCredentialEnv = provisionAgentCredentials(agentId, auth);
|
|
44128
44258
|
},
|
|
44129
44259
|
provisionHouseProxy: ({ baseUrl, token, model, managedAgentId }) => {
|
|
44130
|
-
const claudeConfigDir2 =
|
|
44260
|
+
const claudeConfigDir2 = path94.join(
|
|
44131
44261
|
os59.homedir(),
|
|
44132
44262
|
".codeam",
|
|
44133
44263
|
"house-claude",
|
|
44134
44264
|
`switch-${opts.pluginId}`
|
|
44135
44265
|
);
|
|
44136
44266
|
try {
|
|
44137
|
-
|
|
44267
|
+
fs83.mkdirSync(claudeConfigDir2, { recursive: true, mode: 448 });
|
|
44138
44268
|
} catch {
|
|
44139
44269
|
}
|
|
44140
|
-
const memoryFile =
|
|
44270
|
+
const memoryFile = path94.join(claudeConfigDir2, "CLAUDE.md");
|
|
44141
44271
|
ensureBeadsWorkflowHint(void 0, memoryFile);
|
|
44142
44272
|
ensureAgentStandard(void 0, memoryFile);
|
|
44273
|
+
if (isScratchWorkspace(process.cwd())) ensureScratchWorkflowHint(void 0, memoryFile);
|
|
44143
44274
|
const cfg = {
|
|
44144
44275
|
baseUrl,
|
|
44145
44276
|
token,
|
|
@@ -45352,45 +45483,6 @@ function startClaudeCredentialSync(opts) {
|
|
|
45352
45483
|
};
|
|
45353
45484
|
}
|
|
45354
45485
|
|
|
45355
|
-
// src/scratch/workflow-hint.ts
|
|
45356
|
-
var import_node_fs20 = __toESM(require("fs"));
|
|
45357
|
-
var import_node_path22 = __toESM(require("path"));
|
|
45358
|
-
var SCRATCH_HINT_MARKER = "<!-- codeam:scratch-workflow -->";
|
|
45359
|
-
var SCRATCH_HINT = `${SCRATCH_HINT_MARKER}
|
|
45360
|
-
# From-scratch projects (CodeAgent Box)
|
|
45361
|
-
|
|
45362
|
-
When the working directory is a project started from scratch (no git remote,
|
|
45363
|
-
a \`.git/codeam-scratch\` marker):
|
|
45364
|
-
|
|
45365
|
-
- Build something small, visible and working first. As soon as it can be
|
|
45366
|
-
seen, start it with the \`codeagent_preview\` \`start_preview\` tool and tell the
|
|
45367
|
-
user the preview is open.
|
|
45368
|
-
- Saving is the user's choice in the app (Save to GitHub / GitLab, or a ZIP).
|
|
45369
|
-
Never push, create repositories or ask for git credentials yourself. Once the
|
|
45370
|
-
user has seen something working, call \`suggest_save_project\` ONCE if the
|
|
45371
|
-
app has not offered to save yet.
|
|
45372
|
-
${SCRATCH_HINT_MARKER}`;
|
|
45373
|
-
function ensureScratchWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
45374
|
-
try {
|
|
45375
|
-
let existing = "";
|
|
45376
|
-
try {
|
|
45377
|
-
existing = import_node_fs20.default.readFileSync(file, "utf8");
|
|
45378
|
-
} catch {
|
|
45379
|
-
}
|
|
45380
|
-
if (existing.includes(SCRATCH_HINT)) return;
|
|
45381
|
-
import_node_fs20.default.mkdirSync(import_node_path22.default.dirname(file), { recursive: true });
|
|
45382
|
-
const open = existing.indexOf(SCRATCH_HINT_MARKER);
|
|
45383
|
-
const close = open === -1 ? -1 : existing.indexOf(SCRATCH_HINT_MARKER, open + SCRATCH_HINT_MARKER.length);
|
|
45384
|
-
const next = open !== -1 && close !== -1 ? existing.slice(0, open) + SCRATCH_HINT + existing.slice(close + SCRATCH_HINT_MARKER.length) : existing.trim() ? `${existing.trimEnd()}
|
|
45385
|
-
|
|
45386
|
-
${SCRATCH_HINT}
|
|
45387
|
-
` : `${SCRATCH_HINT}
|
|
45388
|
-
`;
|
|
45389
|
-
import_node_fs20.default.writeFileSync(file, next);
|
|
45390
|
-
} catch {
|
|
45391
|
-
}
|
|
45392
|
-
}
|
|
45393
|
-
|
|
45394
45486
|
// src/commands/start/pick-session.ts
|
|
45395
45487
|
function pickPinnedSession(pinnedId, listSessions2) {
|
|
45396
45488
|
const id = pinnedId?.trim();
|
|
@@ -45406,8 +45498,8 @@ function pickPinnedSession(pinnedId, listSessions2) {
|
|
|
45406
45498
|
}
|
|
45407
45499
|
|
|
45408
45500
|
// src/agents/retired-proxy-cleanup.ts
|
|
45409
|
-
var
|
|
45410
|
-
var
|
|
45501
|
+
var fs84 = __toESM(require("fs"));
|
|
45502
|
+
var path95 = __toESM(require("path"));
|
|
45411
45503
|
var os60 = __toESM(require("os"));
|
|
45412
45504
|
var RETIRED_PROXY_RE = /^https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):8787(?:[/?#]|$)/i;
|
|
45413
45505
|
var HEADROOM_CMD_RE = /(^|[\s/"'])headroom(\s|$)/i;
|
|
@@ -45419,10 +45511,10 @@ function isHeadroomHook(group) {
|
|
|
45419
45511
|
}
|
|
45420
45512
|
function sanitizeRetiredProxyConfig(homeDir2 = os60.homedir()) {
|
|
45421
45513
|
const out2 = { inspected: false, changed: false, removed: [] };
|
|
45422
|
-
const file =
|
|
45514
|
+
const file = path95.join(homeDir2, ".claude", "settings.json");
|
|
45423
45515
|
let parsed;
|
|
45424
45516
|
try {
|
|
45425
|
-
parsed = JSON.parse(
|
|
45517
|
+
parsed = JSON.parse(fs84.readFileSync(file, "utf8"));
|
|
45426
45518
|
} catch {
|
|
45427
45519
|
return out2;
|
|
45428
45520
|
}
|
|
@@ -45464,9 +45556,9 @@ function sanitizeRetiredProxyConfig(homeDir2 = os60.homedir()) {
|
|
|
45464
45556
|
if (!out2.changed) return out2;
|
|
45465
45557
|
try {
|
|
45466
45558
|
const tmp = `${file}.codeam.tmp`;
|
|
45467
|
-
|
|
45559
|
+
fs84.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
|
|
45468
45560
|
`, { mode: 384 });
|
|
45469
|
-
|
|
45561
|
+
fs84.renameSync(tmp, file);
|
|
45470
45562
|
} catch {
|
|
45471
45563
|
out2.changed = false;
|
|
45472
45564
|
}
|
|
@@ -45998,7 +46090,7 @@ var AcpDriver = class {
|
|
|
45998
46090
|
};
|
|
45999
46091
|
|
|
46000
46092
|
// src/baton/transcript-mirror.ts
|
|
46001
|
-
var
|
|
46093
|
+
var fs85 = __toESM(require("fs"));
|
|
46002
46094
|
var TranscriptMirror = class {
|
|
46003
46095
|
constructor(deps) {
|
|
46004
46096
|
this.deps = deps;
|
|
@@ -46092,7 +46184,7 @@ var TranscriptMirror = class {
|
|
|
46092
46184
|
}
|
|
46093
46185
|
};
|
|
46094
46186
|
function defaultWatch(file, onChange) {
|
|
46095
|
-
const w3 =
|
|
46187
|
+
const w3 = fs85.watch(file, { persistent: false }, () => onChange());
|
|
46096
46188
|
return () => w3.close();
|
|
46097
46189
|
}
|
|
46098
46190
|
|
|
@@ -46438,16 +46530,16 @@ function keepDeviceAwake(deps = {}) {
|
|
|
46438
46530
|
}
|
|
46439
46531
|
|
|
46440
46532
|
// src/agents/claude/onboarding.ts
|
|
46441
|
-
var
|
|
46533
|
+
var fs86 = __toESM(require("fs"));
|
|
46442
46534
|
var os62 = __toESM(require("os"));
|
|
46443
|
-
var
|
|
46535
|
+
var path96 = __toESM(require("path"));
|
|
46444
46536
|
var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
|
|
46445
46537
|
function ensureClaudeOnboarded(cwd) {
|
|
46446
46538
|
try {
|
|
46447
|
-
const file =
|
|
46539
|
+
const file = path96.join(os62.homedir(), ".claude.json");
|
|
46448
46540
|
let config = {};
|
|
46449
46541
|
try {
|
|
46450
|
-
config = JSON.parse(
|
|
46542
|
+
config = JSON.parse(fs86.readFileSync(file, "utf8"));
|
|
46451
46543
|
} catch {
|
|
46452
46544
|
}
|
|
46453
46545
|
let changed = false;
|
|
@@ -46472,8 +46564,8 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
46472
46564
|
}
|
|
46473
46565
|
}
|
|
46474
46566
|
if (!changed) return;
|
|
46475
|
-
|
|
46476
|
-
|
|
46567
|
+
fs86.mkdirSync(path96.dirname(file), { recursive: true });
|
|
46568
|
+
fs86.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
46477
46569
|
log.info(
|
|
46478
46570
|
"claude",
|
|
46479
46571
|
`pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
|
|
@@ -47265,7 +47357,7 @@ var import_picocolors10 = __toESM(require("picocolors"));
|
|
|
47265
47357
|
var import_child_process30 = require("child_process");
|
|
47266
47358
|
var import_util4 = require("util");
|
|
47267
47359
|
var import_picocolors8 = __toESM(require("picocolors"));
|
|
47268
|
-
var
|
|
47360
|
+
var path97 = __toESM(require("path"));
|
|
47269
47361
|
var execFileP6 = (0, import_util4.promisify)(import_child_process30.execFile);
|
|
47270
47362
|
var MAX_BUFFER = 8 * 1024 * 1024;
|
|
47271
47363
|
function resetStdinForChild() {
|
|
@@ -47754,7 +47846,7 @@ var GitHubCodespacesProvider = class {
|
|
|
47754
47846
|
});
|
|
47755
47847
|
}
|
|
47756
47848
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
47757
|
-
const remoteDir =
|
|
47849
|
+
const remoteDir = path97.posix.dirname(remotePath);
|
|
47758
47850
|
const parts = [
|
|
47759
47851
|
`mkdir -p ${shellQuote(remoteDir)}`,
|
|
47760
47852
|
`cat > ${shellQuote(remotePath)}`
|
|
@@ -47824,7 +47916,7 @@ function shellQuote(s) {
|
|
|
47824
47916
|
// src/services/providers/gitpod.ts
|
|
47825
47917
|
var import_child_process31 = require("child_process");
|
|
47826
47918
|
var import_util5 = require("util");
|
|
47827
|
-
var
|
|
47919
|
+
var path98 = __toESM(require("path"));
|
|
47828
47920
|
var import_picocolors9 = __toESM(require("picocolors"));
|
|
47829
47921
|
var execFileP7 = (0, import_util5.promisify)(import_child_process31.execFile);
|
|
47830
47922
|
var MAX_BUFFER2 = 8 * 1024 * 1024;
|
|
@@ -48064,7 +48156,7 @@ var GitpodProvider = class {
|
|
|
48064
48156
|
});
|
|
48065
48157
|
}
|
|
48066
48158
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
48067
|
-
const remoteDir =
|
|
48159
|
+
const remoteDir = path98.posix.dirname(remotePath);
|
|
48068
48160
|
const parts = [
|
|
48069
48161
|
`mkdir -p ${shellQuote2(remoteDir)}`,
|
|
48070
48162
|
`cat > ${shellQuote2(remotePath)}`
|
|
@@ -48100,7 +48192,7 @@ function shellQuote2(s) {
|
|
|
48100
48192
|
// src/services/providers/gitlab-workspaces.ts
|
|
48101
48193
|
var import_child_process32 = require("child_process");
|
|
48102
48194
|
var import_util6 = require("util");
|
|
48103
|
-
var
|
|
48195
|
+
var path99 = __toESM(require("path"));
|
|
48104
48196
|
var execFileP8 = (0, import_util6.promisify)(import_child_process32.execFile);
|
|
48105
48197
|
var MAX_BUFFER3 = 8 * 1024 * 1024;
|
|
48106
48198
|
var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
|
|
@@ -48360,7 +48452,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48360
48452
|
}
|
|
48361
48453
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
48362
48454
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
48363
|
-
const remoteDir =
|
|
48455
|
+
const remoteDir = path99.posix.dirname(remotePath);
|
|
48364
48456
|
const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
|
|
48365
48457
|
if (options.mode != null) {
|
|
48366
48458
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
@@ -48428,7 +48520,7 @@ function shellQuote3(s) {
|
|
|
48428
48520
|
// src/services/providers/railway.ts
|
|
48429
48521
|
var import_child_process33 = require("child_process");
|
|
48430
48522
|
var import_util7 = require("util");
|
|
48431
|
-
var
|
|
48523
|
+
var path100 = __toESM(require("path"));
|
|
48432
48524
|
var execFileP9 = (0, import_util7.promisify)(import_child_process33.execFile);
|
|
48433
48525
|
var MAX_BUFFER4 = 8 * 1024 * 1024;
|
|
48434
48526
|
function resetStdinForChild4() {
|
|
@@ -48664,7 +48756,7 @@ var RailwayProvider = class {
|
|
|
48664
48756
|
if (!projectId || !serviceId) {
|
|
48665
48757
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
48666
48758
|
}
|
|
48667
|
-
const remoteDir =
|
|
48759
|
+
const remoteDir = path100.posix.dirname(remotePath);
|
|
48668
48760
|
const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
|
|
48669
48761
|
if (options.mode != null) {
|
|
48670
48762
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
@@ -49204,9 +49296,9 @@ async function stopWorkspaceFromLocal(target) {
|
|
|
49204
49296
|
}
|
|
49205
49297
|
|
|
49206
49298
|
// src/commands/host/host-client.ts
|
|
49207
|
-
var
|
|
49299
|
+
var fs87 = __toESM(require("fs"));
|
|
49208
49300
|
var os63 = __toESM(require("os"));
|
|
49209
|
-
var
|
|
49301
|
+
var path101 = __toESM(require("path"));
|
|
49210
49302
|
var import_node_crypto16 = require("crypto");
|
|
49211
49303
|
function sampleCpuTimes() {
|
|
49212
49304
|
let idle = 0;
|
|
@@ -49255,7 +49347,7 @@ function apiBase() {
|
|
|
49255
49347
|
return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
|
|
49256
49348
|
}
|
|
49257
49349
|
function hostIdentityPath() {
|
|
49258
|
-
return
|
|
49350
|
+
return path101.join(os63.homedir(), ".codeam", "host-agent.json");
|
|
49259
49351
|
}
|
|
49260
49352
|
function collectOsInfo() {
|
|
49261
49353
|
return {
|
|
@@ -49267,7 +49359,7 @@ function collectOsInfo() {
|
|
|
49267
49359
|
}
|
|
49268
49360
|
function loadHostIdentity() {
|
|
49269
49361
|
try {
|
|
49270
|
-
const raw =
|
|
49362
|
+
const raw = fs87.readFileSync(hostIdentityPath(), "utf8");
|
|
49271
49363
|
const parsed = JSON.parse(raw);
|
|
49272
49364
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
|
|
49273
49365
|
const p2 = parsed;
|
|
@@ -49295,8 +49387,8 @@ function ensureControlPollSecret(identity, save = saveHostIdentity) {
|
|
|
49295
49387
|
}
|
|
49296
49388
|
function saveHostIdentity(identity) {
|
|
49297
49389
|
const file = hostIdentityPath();
|
|
49298
|
-
|
|
49299
|
-
|
|
49390
|
+
fs87.mkdirSync(path101.dirname(file), { recursive: true, mode: 448 });
|
|
49391
|
+
fs87.writeFileSync(file, JSON.stringify(identity, null, 2), {
|
|
49300
49392
|
encoding: "utf8",
|
|
49301
49393
|
mode: 384
|
|
49302
49394
|
});
|
|
@@ -49341,7 +49433,7 @@ function isTerminalEnrollError(err) {
|
|
|
49341
49433
|
}
|
|
49342
49434
|
function deleteHostIdentity() {
|
|
49343
49435
|
try {
|
|
49344
|
-
|
|
49436
|
+
fs87.rmSync(hostIdentityPath(), { force: true });
|
|
49345
49437
|
} catch {
|
|
49346
49438
|
}
|
|
49347
49439
|
}
|
|
@@ -49559,8 +49651,8 @@ async function host(args2) {
|
|
|
49559
49651
|
// src/commands/host-agent.ts
|
|
49560
49652
|
var import_node_child_process35 = require("child_process");
|
|
49561
49653
|
var os67 = __toESM(require("os"));
|
|
49562
|
-
var
|
|
49563
|
-
var
|
|
49654
|
+
var fs91 = __toESM(require("fs"));
|
|
49655
|
+
var path105 = __toESM(require("path"));
|
|
49564
49656
|
|
|
49565
49657
|
// src/skills/persist-from-payload.ts
|
|
49566
49658
|
function persistOrClearSkillsFromPayload(skills) {
|
|
@@ -49569,13 +49661,13 @@ function persistOrClearSkillsFromPayload(skills) {
|
|
|
49569
49661
|
}
|
|
49570
49662
|
|
|
49571
49663
|
// src/commands/host/session-state.ts
|
|
49572
|
-
var
|
|
49664
|
+
var fs88 = __toESM(require("fs"));
|
|
49573
49665
|
var os64 = __toESM(require("os"));
|
|
49574
|
-
var
|
|
49666
|
+
var path102 = __toESM(require("path"));
|
|
49575
49667
|
function hostSessionStatePath(env = process.env) {
|
|
49576
49668
|
const override = env.CODEAM_HOST_SESSION_STATE_FILE;
|
|
49577
49669
|
if (override && override.trim()) return override.trim();
|
|
49578
|
-
return
|
|
49670
|
+
return path102.join(os64.homedir(), ".codeam", "host-agent-sessions.json");
|
|
49579
49671
|
}
|
|
49580
49672
|
function isRecord5(v) {
|
|
49581
49673
|
if (typeof v !== "object" || v === null) return false;
|
|
@@ -49586,7 +49678,7 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
49586
49678
|
return {
|
|
49587
49679
|
load() {
|
|
49588
49680
|
try {
|
|
49589
|
-
const raw = JSON.parse(
|
|
49681
|
+
const raw = JSON.parse(fs88.readFileSync(file, "utf8"));
|
|
49590
49682
|
return Array.isArray(raw?.sessions) ? raw.sessions.filter(isRecord5) : null;
|
|
49591
49683
|
} catch {
|
|
49592
49684
|
return null;
|
|
@@ -49594,18 +49686,18 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
49594
49686
|
},
|
|
49595
49687
|
save(list) {
|
|
49596
49688
|
try {
|
|
49597
|
-
|
|
49689
|
+
fs88.mkdirSync(path102.dirname(file), { recursive: true, mode: 448 });
|
|
49598
49690
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
49599
|
-
|
|
49691
|
+
fs88.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
|
|
49600
49692
|
mode: 384
|
|
49601
49693
|
});
|
|
49602
|
-
|
|
49694
|
+
fs88.renameSync(tmp, file);
|
|
49603
49695
|
} catch {
|
|
49604
49696
|
}
|
|
49605
49697
|
},
|
|
49606
49698
|
clear() {
|
|
49607
49699
|
try {
|
|
49608
|
-
|
|
49700
|
+
fs88.rmSync(file, { force: true });
|
|
49609
49701
|
} catch {
|
|
49610
49702
|
}
|
|
49611
49703
|
}
|
|
@@ -49628,10 +49720,10 @@ function planSessionResume(records, max) {
|
|
|
49628
49720
|
return { resume: ordered.slice(0, bound), dropped: ordered.slice(bound) };
|
|
49629
49721
|
}
|
|
49630
49722
|
function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
49631
|
-
const target =
|
|
49723
|
+
const target = path102.resolve(cwd);
|
|
49632
49724
|
const reconnectable = (s) => !!s.pluginId && !!s.pollSecret && !!s.agent;
|
|
49633
49725
|
const matches = sessions3.filter(
|
|
49634
|
-
(s) => !!s.cwd &&
|
|
49726
|
+
(s) => !!s.cwd && path102.resolve(s.cwd) === target && reconnectable(s)
|
|
49635
49727
|
);
|
|
49636
49728
|
if (matches.length > 0) {
|
|
49637
49729
|
matches.sort((a, b) => b.pairedAt - a.pairedAt);
|
|
@@ -49643,11 +49735,11 @@ function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
|
49643
49735
|
|
|
49644
49736
|
// src/commands/host/git-tooling.ts
|
|
49645
49737
|
var import_node_child_process31 = require("child_process");
|
|
49646
|
-
var
|
|
49738
|
+
var fs89 = __toESM(require("fs"));
|
|
49647
49739
|
var os65 = __toESM(require("os"));
|
|
49648
|
-
var
|
|
49740
|
+
var path103 = __toESM(require("path"));
|
|
49649
49741
|
function codeamBinDir() {
|
|
49650
|
-
return process.env.CODEAM_BIN_DIR ??
|
|
49742
|
+
return process.env.CODEAM_BIN_DIR ?? path103.join(os65.homedir(), ".codeam", "bin");
|
|
49651
49743
|
}
|
|
49652
49744
|
var FALLBACK_GH_VERSION = "2.62.0";
|
|
49653
49745
|
var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
|
|
@@ -49679,7 +49771,7 @@ async function download(url2, dest) {
|
|
|
49679
49771
|
const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
|
|
49680
49772
|
if (!res.ok || !res.body) return false;
|
|
49681
49773
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
49682
|
-
|
|
49774
|
+
fs89.writeFileSync(dest, buf);
|
|
49683
49775
|
return true;
|
|
49684
49776
|
} catch {
|
|
49685
49777
|
return false;
|
|
@@ -49702,8 +49794,8 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
49702
49794
|
const version3 = await resolveVersionFn(token);
|
|
49703
49795
|
const asset = `gh_${version3}_${osToken}_${arch2}`;
|
|
49704
49796
|
const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
|
|
49705
|
-
const tmpRoot =
|
|
49706
|
-
const archive =
|
|
49797
|
+
const tmpRoot = fs89.mkdtempSync(path103.join(os65.tmpdir(), "codeam-gh-"));
|
|
49798
|
+
const archive = path103.join(tmpRoot, `${asset}.${ext}`);
|
|
49707
49799
|
if (!await downloadFn(url2, archive)) {
|
|
49708
49800
|
log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
|
|
49709
49801
|
return null;
|
|
@@ -49713,16 +49805,16 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
49713
49805
|
log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
|
|
49714
49806
|
return null;
|
|
49715
49807
|
}
|
|
49716
|
-
const extractedBin =
|
|
49717
|
-
if (!
|
|
49808
|
+
const extractedBin = path103.join(tmpRoot, asset, "bin", binaryName);
|
|
49809
|
+
if (!fs89.existsSync(extractedBin)) {
|
|
49718
49810
|
log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
|
|
49719
49811
|
return null;
|
|
49720
49812
|
}
|
|
49721
49813
|
const binDir = codeamBinDir();
|
|
49722
|
-
|
|
49723
|
-
const target =
|
|
49724
|
-
|
|
49725
|
-
|
|
49814
|
+
fs89.mkdirSync(binDir, { recursive: true });
|
|
49815
|
+
const target = path103.join(binDir, binaryName);
|
|
49816
|
+
fs89.copyFileSync(extractedBin, target);
|
|
49817
|
+
fs89.chmodSync(target, 493);
|
|
49726
49818
|
log.info("host-agent", `gh installed to ${target} (v${version3})`);
|
|
49727
49819
|
return target;
|
|
49728
49820
|
} catch (e) {
|
|
@@ -49759,19 +49851,19 @@ async function ensureGhAuth(runner, ghCmd, token) {
|
|
|
49759
49851
|
}
|
|
49760
49852
|
function ghConfigDir() {
|
|
49761
49853
|
if (process.env.GH_CONFIG_DIR) return process.env.GH_CONFIG_DIR;
|
|
49762
|
-
if (process.env.XDG_CONFIG_HOME) return
|
|
49854
|
+
if (process.env.XDG_CONFIG_HOME) return path103.join(process.env.XDG_CONFIG_HOME, "gh");
|
|
49763
49855
|
if (process.platform === "win32" && process.env.APPDATA) {
|
|
49764
|
-
return
|
|
49856
|
+
return path103.join(process.env.APPDATA, "GitHub CLI");
|
|
49765
49857
|
}
|
|
49766
|
-
return
|
|
49858
|
+
return path103.join(os65.homedir(), ".config", "gh");
|
|
49767
49859
|
}
|
|
49768
49860
|
function writeGhHostsToken(token) {
|
|
49769
49861
|
try {
|
|
49770
49862
|
const dir = ghConfigDir();
|
|
49771
|
-
const file =
|
|
49772
|
-
if (
|
|
49773
|
-
|
|
49774
|
-
|
|
49863
|
+
const file = path103.join(dir, "hosts.yml");
|
|
49864
|
+
if (fs89.existsSync(file)) return false;
|
|
49865
|
+
fs89.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
49866
|
+
fs89.writeFileSync(
|
|
49775
49867
|
file,
|
|
49776
49868
|
`github.com:
|
|
49777
49869
|
oauth_token: ${token}
|
|
@@ -49814,8 +49906,8 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
49814
49906
|
const version3 = await resolveLatestGlabVersion();
|
|
49815
49907
|
const asset = `glab_${version3}_${osToken}_${arch2}`;
|
|
49816
49908
|
const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
|
|
49817
|
-
const tmpRoot =
|
|
49818
|
-
const archive =
|
|
49909
|
+
const tmpRoot = fs89.mkdtempSync(path103.join(os65.tmpdir(), "codeam-glab-"));
|
|
49910
|
+
const archive = path103.join(tmpRoot, `${asset}.${ext}`);
|
|
49819
49911
|
if (!await downloadFn(url2, archive)) {
|
|
49820
49912
|
log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
|
|
49821
49913
|
return null;
|
|
@@ -49826,20 +49918,20 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
49826
49918
|
return null;
|
|
49827
49919
|
}
|
|
49828
49920
|
const candidates = [
|
|
49829
|
-
|
|
49830
|
-
|
|
49831
|
-
|
|
49921
|
+
path103.join(tmpRoot, "bin", binaryName),
|
|
49922
|
+
path103.join(tmpRoot, asset, "bin", binaryName),
|
|
49923
|
+
path103.join(tmpRoot, binaryName)
|
|
49832
49924
|
];
|
|
49833
|
-
const extractedBin = candidates.find((c2) =>
|
|
49925
|
+
const extractedBin = candidates.find((c2) => fs89.existsSync(c2));
|
|
49834
49926
|
if (!extractedBin) {
|
|
49835
49927
|
log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
|
|
49836
49928
|
return null;
|
|
49837
49929
|
}
|
|
49838
49930
|
const binDir = codeamBinDir();
|
|
49839
|
-
|
|
49840
|
-
const target =
|
|
49841
|
-
|
|
49842
|
-
|
|
49931
|
+
fs89.mkdirSync(binDir, { recursive: true });
|
|
49932
|
+
const target = path103.join(binDir, binaryName);
|
|
49933
|
+
fs89.copyFileSync(extractedBin, target);
|
|
49934
|
+
fs89.chmodSync(target, 493);
|
|
49843
49935
|
log.info("host-agent", `glab installed to ${target} (v${version3})`);
|
|
49844
49936
|
return target;
|
|
49845
49937
|
} catch (e) {
|
|
@@ -49921,9 +50013,9 @@ var defaultGitToolingRunner = {
|
|
|
49921
50013
|
var import_node_child_process33 = require("child_process");
|
|
49922
50014
|
|
|
49923
50015
|
// src/lib/updateNotifier.ts
|
|
49924
|
-
var
|
|
50016
|
+
var fs90 = __toESM(require("fs"));
|
|
49925
50017
|
var os66 = __toESM(require("os"));
|
|
49926
|
-
var
|
|
50018
|
+
var path104 = __toESM(require("path"));
|
|
49927
50019
|
var https8 = __toESM(require("https"));
|
|
49928
50020
|
var import_node_child_process32 = require("child_process");
|
|
49929
50021
|
var import_picocolors12 = __toESM(require("picocolors"));
|
|
@@ -49932,12 +50024,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
|
|
|
49932
50024
|
var TTL_MS = 24 * 60 * 60 * 1e3;
|
|
49933
50025
|
var REQUEST_TIMEOUT_MS = 1500;
|
|
49934
50026
|
function cachePath() {
|
|
49935
|
-
const dir =
|
|
49936
|
-
return
|
|
50027
|
+
const dir = path104.join(os66.homedir(), ".codeam");
|
|
50028
|
+
return path104.join(dir, "update-check.json");
|
|
49937
50029
|
}
|
|
49938
50030
|
function readCache() {
|
|
49939
50031
|
try {
|
|
49940
|
-
const raw =
|
|
50032
|
+
const raw = fs90.readFileSync(cachePath(), "utf8");
|
|
49941
50033
|
const parsed = JSON.parse(raw);
|
|
49942
50034
|
if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
|
|
49943
50035
|
return parsed;
|
|
@@ -49948,10 +50040,10 @@ function readCache() {
|
|
|
49948
50040
|
function writeCache(cache) {
|
|
49949
50041
|
try {
|
|
49950
50042
|
const file = cachePath();
|
|
49951
|
-
|
|
50043
|
+
fs90.mkdirSync(path104.dirname(file), { recursive: true });
|
|
49952
50044
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
49953
|
-
|
|
49954
|
-
|
|
50045
|
+
fs90.writeFileSync(tmp, JSON.stringify(cache));
|
|
50046
|
+
fs90.renameSync(tmp, file);
|
|
49955
50047
|
} catch {
|
|
49956
50048
|
}
|
|
49957
50049
|
}
|
|
@@ -50025,8 +50117,8 @@ function isLinkedInstall() {
|
|
|
50025
50117
|
timeout: 2e3
|
|
50026
50118
|
}).trim();
|
|
50027
50119
|
if (!root) return false;
|
|
50028
|
-
const pkgPath =
|
|
50029
|
-
return
|
|
50120
|
+
const pkgPath = path104.join(root, PKG_NAME);
|
|
50121
|
+
return fs90.lstatSync(pkgPath).isSymbolicLink();
|
|
50030
50122
|
} catch {
|
|
50031
50123
|
return false;
|
|
50032
50124
|
}
|
|
@@ -50062,7 +50154,7 @@ function maybeAutoUpdate(currentVersion, latest) {
|
|
|
50062
50154
|
return;
|
|
50063
50155
|
}
|
|
50064
50156
|
try {
|
|
50065
|
-
|
|
50157
|
+
fs90.unlinkSync(cachePath());
|
|
50066
50158
|
} catch {
|
|
50067
50159
|
}
|
|
50068
50160
|
process.stderr.write(` ${import_picocolors12.default.green("\u2713")} Updated. Resuming session...
|
|
@@ -50078,7 +50170,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
50078
50170
|
if (process.env.NODE_ENV === "test") return;
|
|
50079
50171
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
50080
50172
|
if (process.env.CI) return;
|
|
50081
|
-
const current2 = true ? "2.76.
|
|
50173
|
+
const current2 = true ? "2.76.10" : null;
|
|
50082
50174
|
if (!current2) return;
|
|
50083
50175
|
const cache = readCache();
|
|
50084
50176
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -50095,7 +50187,7 @@ function checkForUpdates() {
|
|
|
50095
50187
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
50096
50188
|
if (process.env.CI) return;
|
|
50097
50189
|
if (!process.stdout.isTTY) return;
|
|
50098
|
-
const current2 = true ? "2.76.
|
|
50190
|
+
const current2 = true ? "2.76.10" : null;
|
|
50099
50191
|
if (!current2) return;
|
|
50100
50192
|
const cache = readCache();
|
|
50101
50193
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -50118,7 +50210,7 @@ var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
|
50118
50210
|
var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
|
|
50119
50211
|
var SUDO_PREFLIGHT_TIMEOUT_MS = 5e3;
|
|
50120
50212
|
function currentCliVersion() {
|
|
50121
|
-
return true ? "2.76.
|
|
50213
|
+
return true ? "2.76.10" : null;
|
|
50122
50214
|
}
|
|
50123
50215
|
async function installedVersion(deps) {
|
|
50124
50216
|
const ls = await deps.run(
|
|
@@ -50471,7 +50563,7 @@ var ORPHAN_KILL_SETTLE_MS = 500;
|
|
|
50471
50563
|
function needsSelfRelaunch(env = process.env, pid = process.pid) {
|
|
50472
50564
|
return !env.INVOCATION_ID && pid !== 1;
|
|
50473
50565
|
}
|
|
50474
|
-
function isContainerEnvironment(existsSyncFn =
|
|
50566
|
+
function isContainerEnvironment(existsSyncFn = fs91.existsSync, readFileSyncFn = (p2) => fs91.readFileSync(p2, "utf8")) {
|
|
50475
50567
|
try {
|
|
50476
50568
|
if (existsSyncFn("/.dockerenv")) return true;
|
|
50477
50569
|
} catch {
|
|
@@ -50936,13 +51028,13 @@ var HostAgentSupervisor = class {
|
|
|
50936
51028
|
const relay = this.relay;
|
|
50937
51029
|
if (!relay) return;
|
|
50938
51030
|
const raw = cmd.payload?.path;
|
|
50939
|
-
const target = typeof raw === "string" && raw.trim() ?
|
|
51031
|
+
const target = typeof raw === "string" && raw.trim() ? path105.resolve(raw.trim()) : os67.homedir();
|
|
50940
51032
|
try {
|
|
50941
|
-
const dirents = await
|
|
51033
|
+
const dirents = await fs91.promises.readdir(target, { withFileTypes: true });
|
|
50942
51034
|
const entries2 = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
|
|
50943
51035
|
(a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
|
|
50944
51036
|
);
|
|
50945
|
-
const parent =
|
|
51037
|
+
const parent = path105.dirname(target);
|
|
50946
51038
|
await relay.sendResult(cmd.id, "completed", {
|
|
50947
51039
|
path: target,
|
|
50948
51040
|
// null at the filesystem root so the UI can hide the ".." affordance.
|
|
@@ -51286,18 +51378,24 @@ var HostAgentSupervisor = class {
|
|
|
51286
51378
|
let extraArgs = [];
|
|
51287
51379
|
if (payload.houseProxy) {
|
|
51288
51380
|
const { baseUrl, token, agentKind, openRouter } = payload.houseProxy;
|
|
51381
|
+
const managedAgentId = isManagedProviderId(payload.agentId) ? payload.agentId : void 0;
|
|
51289
51382
|
childEnv = {
|
|
51290
|
-
...buildHouseProxyChildEnv({
|
|
51383
|
+
...buildHouseProxyChildEnv({
|
|
51384
|
+
baseUrl,
|
|
51385
|
+
token,
|
|
51386
|
+
openRouter: openRouter === true,
|
|
51387
|
+
...managedAgentId ? { managedAgentId } : {}
|
|
51388
|
+
}),
|
|
51291
51389
|
CODEAM_AUTO_TOKEN: payload.autoPairToken
|
|
51292
51390
|
};
|
|
51293
|
-
const houseConfigDir =
|
|
51391
|
+
const houseConfigDir = path105.join(
|
|
51294
51392
|
os67.homedir(),
|
|
51295
51393
|
".codeam",
|
|
51296
51394
|
"house-claude",
|
|
51297
51395
|
payload.deployId
|
|
51298
51396
|
);
|
|
51299
51397
|
try {
|
|
51300
|
-
|
|
51398
|
+
fs91.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
|
|
51301
51399
|
} catch {
|
|
51302
51400
|
}
|
|
51303
51401
|
childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
|
|
@@ -51306,7 +51404,8 @@ var HostAgentSupervisor = class {
|
|
|
51306
51404
|
baseUrl,
|
|
51307
51405
|
token,
|
|
51308
51406
|
openRouter: !!openRouter,
|
|
51309
|
-
claudeConfigDir: houseConfigDir
|
|
51407
|
+
claudeConfigDir: houseConfigDir,
|
|
51408
|
+
...managedAgentId ? { managedAgentId } : {}
|
|
51310
51409
|
}, payload.deployId);
|
|
51311
51410
|
} else {
|
|
51312
51411
|
const auth = await this.resolveAgentAuth(this.identity, payload.sealedAgentAuth);
|
|
@@ -51331,13 +51430,13 @@ var HostAgentSupervisor = class {
|
|
|
51331
51430
|
if ((payload.repoProvider ?? "github") === "gitlab") {
|
|
51332
51431
|
const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
|
|
51333
51432
|
if (glabCmd) {
|
|
51334
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
51433
|
+
childEnv.PATH = `${codeamBinDir()}${path105.delimiter}${childEnv.PATH}`;
|
|
51335
51434
|
await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
|
|
51336
51435
|
}
|
|
51337
51436
|
} else {
|
|
51338
51437
|
const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
|
|
51339
51438
|
if (ghCmd) {
|
|
51340
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
51439
|
+
childEnv.PATH = `${codeamBinDir()}${path105.delimiter}${childEnv.PATH}`;
|
|
51341
51440
|
await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
|
|
51342
51441
|
}
|
|
51343
51442
|
}
|
|
@@ -51365,9 +51464,9 @@ var HostAgentSupervisor = class {
|
|
|
51365
51464
|
);
|
|
51366
51465
|
if (!payload.suppressOnboardingWelcome) {
|
|
51367
51466
|
try {
|
|
51368
|
-
const cfgDir = childEnv.CLAUDE_CONFIG_DIR ||
|
|
51369
|
-
const projectDir =
|
|
51370
|
-
const hasPriorConversation =
|
|
51467
|
+
const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path105.join(os67.homedir(), ".claude");
|
|
51468
|
+
const projectDir = path105.join(cfgDir, "projects", encodeCwd(cwd));
|
|
51469
|
+
const hasPriorConversation = fs91.existsSync(projectDir) && fs91.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
|
|
51371
51470
|
if (hasPriorConversation) {
|
|
51372
51471
|
childEnv.CODEAM_RESUME_LATEST = "1";
|
|
51373
51472
|
log.info(
|
|
@@ -51521,7 +51620,7 @@ var HostAgentSupervisor = class {
|
|
|
51521
51620
|
fallbackResumeTarget() {
|
|
51522
51621
|
const session = getActiveSession();
|
|
51523
51622
|
if (!session || !session.pluginId || !session.pollSecret || !session.agent) return null;
|
|
51524
|
-
const cwd = session.cwd &&
|
|
51623
|
+
const cwd = session.cwd && fs91.existsSync(session.cwd) ? session.cwd : process.cwd();
|
|
51525
51624
|
if (isFilesystemRoot(cwd)) {
|
|
51526
51625
|
log.warn(
|
|
51527
51626
|
"host-agent",
|
|
@@ -51561,7 +51660,7 @@ var HostAgentSupervisor = class {
|
|
|
51561
51660
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: no saved pairing on this box`);
|
|
51562
51661
|
return;
|
|
51563
51662
|
}
|
|
51564
|
-
if (!session.cwd || !
|
|
51663
|
+
if (!session.cwd || !fs91.existsSync(session.cwd)) {
|
|
51565
51664
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: workspace is gone`);
|
|
51566
51665
|
return;
|
|
51567
51666
|
}
|
|
@@ -51603,7 +51702,7 @@ var HostAgentSupervisor = class {
|
|
|
51603
51702
|
const persisted = new Map((this.sessionStore.load() ?? []).map((r) => [r.deployId, r.agent]));
|
|
51604
51703
|
for (const c2 of this.children.values()) persisted.set(c2.deployId, c2.agent);
|
|
51605
51704
|
return this.listSavedSessions().map((s) => ({ s, deployId: deployIdFromWorkspace(s.cwd) })).filter(
|
|
51606
|
-
(x) => x.deployId !== null && !!x.s.cwd &&
|
|
51705
|
+
(x) => x.deployId !== null && !!x.s.cwd && fs91.existsSync(x.s.cwd)
|
|
51607
51706
|
).map(({ s, deployId }) => {
|
|
51608
51707
|
const agent = persisted.get(deployId);
|
|
51609
51708
|
return { deployId, sessionId: s.id, ...agent ? { agent } : {} };
|
|
@@ -51655,7 +51754,7 @@ var HostAgentSupervisor = class {
|
|
|
51655
51754
|
if (this.children.has(deployId)) return;
|
|
51656
51755
|
const st3 = this.resumeStateFor(target);
|
|
51657
51756
|
try {
|
|
51658
|
-
const cwd =
|
|
51757
|
+
const cwd = fs91.existsSync(target.cwd) ? target.cwd : process.cwd();
|
|
51659
51758
|
const proc = this.resumeSpawner(
|
|
51660
51759
|
{ ...readHouseProxyChildEnv(deployId), CODEAM_RESUME_SESSION_ID: session.id },
|
|
51661
51760
|
cwd
|
|
@@ -51874,12 +51973,12 @@ var HostAgentSupervisor = class {
|
|
|
51874
51973
|
this.untrackChild(deployId);
|
|
51875
51974
|
}
|
|
51876
51975
|
const dirs = [
|
|
51877
|
-
|
|
51878
|
-
|
|
51976
|
+
path105.join(selfHostedWorkspaceRoot(), deployId),
|
|
51977
|
+
path105.join(os67.homedir(), ".codeam", "house-claude", deployId)
|
|
51879
51978
|
];
|
|
51880
51979
|
for (const dir of dirs) {
|
|
51881
51980
|
try {
|
|
51882
|
-
|
|
51981
|
+
fs91.rmSync(dir, { recursive: true, force: true });
|
|
51883
51982
|
} catch (err) {
|
|
51884
51983
|
log.warn(
|
|
51885
51984
|
"host-agent",
|
|
@@ -52039,8 +52138,8 @@ async function invite() {
|
|
|
52039
52138
|
var import_node_dns = require("dns");
|
|
52040
52139
|
var import_node_util11 = require("util");
|
|
52041
52140
|
var import_node_crypto17 = require("crypto");
|
|
52042
|
-
var
|
|
52043
|
-
var
|
|
52141
|
+
var fs92 = __toESM(require("fs"));
|
|
52142
|
+
var path106 = __toESM(require("path"));
|
|
52044
52143
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
52045
52144
|
var dnsResolveP = (0, import_node_util11.promisify)(import_node_dns.resolve);
|
|
52046
52145
|
async function checkDns(apiBase2) {
|
|
@@ -52096,13 +52195,13 @@ async function checkHealth(apiBase2) {
|
|
|
52096
52195
|
}
|
|
52097
52196
|
}
|
|
52098
52197
|
function checkConfigDir() {
|
|
52099
|
-
const dir =
|
|
52198
|
+
const dir = path106.join(require("os").homedir(), ".codeam");
|
|
52100
52199
|
try {
|
|
52101
|
-
|
|
52102
|
-
const probe =
|
|
52103
|
-
|
|
52104
|
-
const read =
|
|
52105
|
-
|
|
52200
|
+
fs92.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
52201
|
+
const probe = path106.join(dir, ".doctor-probe");
|
|
52202
|
+
fs92.writeFileSync(probe, "ok", { mode: 384 });
|
|
52203
|
+
const read = fs92.readFileSync(probe, "utf8");
|
|
52204
|
+
fs92.unlinkSync(probe);
|
|
52106
52205
|
if (read !== "ok") throw new Error("write/read round-trip mismatch");
|
|
52107
52206
|
return {
|
|
52108
52207
|
id: "config-dir",
|
|
@@ -52166,7 +52265,7 @@ function checkNodePty() {
|
|
|
52166
52265
|
detail: "not required on this platform"
|
|
52167
52266
|
};
|
|
52168
52267
|
}
|
|
52169
|
-
const vendoredPath =
|
|
52268
|
+
const vendoredPath = path106.join(__dirname, "vendor", "node-pty");
|
|
52170
52269
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
52171
52270
|
try {
|
|
52172
52271
|
require(target);
|
|
@@ -52208,7 +52307,7 @@ function checkChokidar() {
|
|
|
52208
52307
|
}
|
|
52209
52308
|
async function doctor(args2 = []) {
|
|
52210
52309
|
const json = args2.includes("--json");
|
|
52211
|
-
const cliVersion = true ? "2.76.
|
|
52310
|
+
const cliVersion = true ? "2.76.10" : "0.0.0-dev";
|
|
52212
52311
|
const apiBase2 = resolveApiBaseUrl();
|
|
52213
52312
|
const diagnosticId = (0, import_node_crypto17.randomUUID)();
|
|
52214
52313
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
@@ -52415,9 +52514,9 @@ var LAUNCHER_ENV = Object.freeze({
|
|
|
52415
52514
|
});
|
|
52416
52515
|
|
|
52417
52516
|
// src/integrations/mcp-run.ts
|
|
52418
|
-
var
|
|
52517
|
+
var import_node_fs22 = require("fs");
|
|
52419
52518
|
var import_node_os18 = __toESM(require("os"));
|
|
52420
|
-
var
|
|
52519
|
+
var import_node_path24 = __toESM(require("path"));
|
|
52421
52520
|
|
|
52422
52521
|
// src/integrations/token-client.ts
|
|
52423
52522
|
var REFRESH_AHEAD_MS = 5 * 60 * 1e3;
|
|
@@ -52497,13 +52596,13 @@ function commandExists(command2) {
|
|
|
52497
52596
|
}
|
|
52498
52597
|
function localBinCandidates(command2) {
|
|
52499
52598
|
return [
|
|
52500
|
-
|
|
52501
|
-
|
|
52599
|
+
import_node_path24.default.join(import_node_os18.default.homedir(), ".local", "bin", command2),
|
|
52600
|
+
import_node_path24.default.join(import_node_os18.default.homedir(), ".cargo", "bin", command2)
|
|
52502
52601
|
];
|
|
52503
52602
|
}
|
|
52504
52603
|
function resolveLauncherPath(command2, deps = {
|
|
52505
52604
|
commandExists,
|
|
52506
|
-
existsSync:
|
|
52605
|
+
existsSync: import_node_fs22.existsSync
|
|
52507
52606
|
}) {
|
|
52508
52607
|
if (deps.commandExists(command2)) return command2;
|
|
52509
52608
|
for (const candidate of localBinCandidates(command2)) {
|
|
@@ -52732,7 +52831,7 @@ async function mcpWarm(argv = [], opts = {}) {
|
|
|
52732
52831
|
// src/commands/version.ts
|
|
52733
52832
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
52734
52833
|
function version2() {
|
|
52735
|
-
const v = true ? "2.76.
|
|
52834
|
+
const v = true ? "2.76.10" : "unknown";
|
|
52736
52835
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
52737
52836
|
}
|
|
52738
52837
|
|