codeam-cli 2.76.7 → 2.76.9
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 +16 -0
- package/dist/index.js +578 -513
- 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.9" : "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.9",
|
|
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.9" ? { ideVersion: "2.76.9" } : {}
|
|
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+/, "")
|
|
@@ -25130,19 +25130,67 @@ 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"].some((dir) => import_node_fs14.default.existsSync(import_node_path12.default.join(cwd, dir, "index.html")));
|
|
25161
|
+
}
|
|
25162
|
+
function isEmptyScratchProject(cwd) {
|
|
25163
|
+
if (!isScratchWorkspace(cwd)) return false;
|
|
25164
|
+
const entries2 = rootEntries(cwd);
|
|
25165
|
+
return entries2 !== null && entries2.every((e) => e.startsWith(".") || AGENT_NOTES.has(e));
|
|
25166
|
+
}
|
|
25167
|
+
var bringUps = /* @__PURE__ */ new Set();
|
|
25168
|
+
function notePreviewBringUp(sessionId) {
|
|
25169
|
+
bringUps.add(sessionId);
|
|
25170
|
+
}
|
|
25171
|
+
function maybeAutoOpenScratchPreview(sessionId, bridge, cwd = process.cwd()) {
|
|
25172
|
+
if (!isScratchWorkspace(cwd) || bringUps.has(sessionId)) return false;
|
|
25173
|
+
if (bridge.status().status !== "idle") return false;
|
|
25174
|
+
if (!hasServableProject(cwd)) return false;
|
|
25175
|
+
bringUps.add(sessionId);
|
|
25176
|
+
void bridge.start().catch(() => {
|
|
25177
|
+
});
|
|
25178
|
+
return true;
|
|
25179
|
+
}
|
|
25180
|
+
|
|
25133
25181
|
// src/services/preview/active-marker.ts
|
|
25134
25182
|
var import_node_crypto11 = require("crypto");
|
|
25135
25183
|
var import_promises5 = __toESM(require("fs/promises"));
|
|
25136
25184
|
var import_node_os7 = __toESM(require("os"));
|
|
25137
|
-
var
|
|
25185
|
+
var import_node_path13 = __toESM(require("path"));
|
|
25138
25186
|
function markerPath2(cwd, homeDir2 = import_node_os7.default.homedir()) {
|
|
25139
|
-
const key = (0, import_node_crypto11.createHash)("sha256").update(
|
|
25140
|
-
return
|
|
25187
|
+
const key = (0, import_node_crypto11.createHash)("sha256").update(import_node_path13.default.resolve(cwd)).digest("hex").slice(0, 16);
|
|
25188
|
+
return import_node_path13.default.join(homeDir2, ".codeam", "preview-active", `${key}.json`);
|
|
25141
25189
|
}
|
|
25142
25190
|
async function writeActivePreviewMarker(cwd, detection, homeDir2) {
|
|
25143
25191
|
try {
|
|
25144
25192
|
const file = markerPath2(cwd, homeDir2);
|
|
25145
|
-
await import_promises5.default.mkdir(
|
|
25193
|
+
await import_promises5.default.mkdir(import_node_path13.default.dirname(file), { recursive: true });
|
|
25146
25194
|
await import_promises5.default.writeFile(
|
|
25147
25195
|
file,
|
|
25148
25196
|
JSON.stringify({ detection, at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2) + "\n",
|
|
@@ -25165,16 +25213,16 @@ async function readActivePreviewMarker(cwd, homeDir2) {
|
|
|
25165
25213
|
}
|
|
25166
25214
|
|
|
25167
25215
|
// src/agents/acp/guardrail-config.ts
|
|
25168
|
-
var
|
|
25169
|
-
var
|
|
25216
|
+
var fs51 = __toESM(require("fs"));
|
|
25217
|
+
var path59 = __toESM(require("path"));
|
|
25170
25218
|
var os36 = __toESM(require("os"));
|
|
25171
25219
|
var current = null;
|
|
25172
25220
|
function guardrailConfigPath(homeDir2 = os36.homedir()) {
|
|
25173
|
-
return
|
|
25221
|
+
return path59.join(homeDir2, ".codeam", "guardrails.json");
|
|
25174
25222
|
}
|
|
25175
25223
|
function loadGuardrailPolicy(homeDir2 = os36.homedir()) {
|
|
25176
25224
|
try {
|
|
25177
|
-
current = normalizeGuardrailPolicy(JSON.parse(
|
|
25225
|
+
current = normalizeGuardrailPolicy(JSON.parse(fs51.readFileSync(guardrailConfigPath(homeDir2), "utf8")));
|
|
25178
25226
|
} catch {
|
|
25179
25227
|
current = { ...DEFAULT_GUARDRAIL_POLICY };
|
|
25180
25228
|
}
|
|
@@ -25188,8 +25236,8 @@ function setGuardrailPolicy(raw, homeDir2 = os36.homedir()) {
|
|
|
25188
25236
|
current = next;
|
|
25189
25237
|
try {
|
|
25190
25238
|
const p2 = guardrailConfigPath(homeDir2);
|
|
25191
|
-
|
|
25192
|
-
|
|
25239
|
+
fs51.mkdirSync(path59.dirname(p2), { recursive: true });
|
|
25240
|
+
fs51.writeFileSync(p2, JSON.stringify(next, null, 2));
|
|
25193
25241
|
} catch {
|
|
25194
25242
|
}
|
|
25195
25243
|
return next;
|
|
@@ -25205,22 +25253,22 @@ function shouldOfferOneMRecovery(opts) {
|
|
|
25205
25253
|
}
|
|
25206
25254
|
|
|
25207
25255
|
// src/commands/host/house-proxy-config.ts
|
|
25208
|
-
var
|
|
25256
|
+
var fs52 = __toESM(require("fs"));
|
|
25209
25257
|
var os37 = __toESM(require("os"));
|
|
25210
|
-
var
|
|
25258
|
+
var path60 = __toESM(require("path"));
|
|
25211
25259
|
function houseProxyConfigPath() {
|
|
25212
|
-
return
|
|
25260
|
+
return path60.join(os37.homedir(), ".codeam", "house-proxy.json");
|
|
25213
25261
|
}
|
|
25214
25262
|
var DEPLOY_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
25215
25263
|
function deployHouseProxyConfigPath(deployId) {
|
|
25216
25264
|
if (!DEPLOY_ID_RE.test(deployId) || deployId.includes("..")) return null;
|
|
25217
|
-
return
|
|
25265
|
+
return path60.join(os37.homedir(), ".codeam", "house-proxy", `${deployId}.json`);
|
|
25218
25266
|
}
|
|
25219
25267
|
function writeJson0600(file, value) {
|
|
25220
|
-
|
|
25268
|
+
fs52.mkdirSync(path60.dirname(file), { recursive: true, mode: 448 });
|
|
25221
25269
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
25222
|
-
|
|
25223
|
-
|
|
25270
|
+
fs52.writeFileSync(tmp, JSON.stringify(value, null, 2), { encoding: "utf8", mode: 384 });
|
|
25271
|
+
fs52.renameSync(tmp, file);
|
|
25224
25272
|
restrictToOwner(file);
|
|
25225
25273
|
}
|
|
25226
25274
|
function persistHouseProxyConfig(config, deployId) {
|
|
@@ -25237,7 +25285,7 @@ function persistHouseProxyConfig(config, deployId) {
|
|
|
25237
25285
|
}
|
|
25238
25286
|
function clearHouseProxyConfig(deployId) {
|
|
25239
25287
|
try {
|
|
25240
|
-
|
|
25288
|
+
fs52.rmSync(houseProxyConfigPath(), { force: true });
|
|
25241
25289
|
const perDeploy = deployId ? deployHouseProxyConfigPath(deployId) : null;
|
|
25242
25290
|
if (perDeploy) writeJson0600(perDeploy, { none: true });
|
|
25243
25291
|
} catch {
|
|
@@ -25246,8 +25294,8 @@ function clearHouseProxyConfig(deployId) {
|
|
|
25246
25294
|
function readHouseProxyChildEnv(deployId) {
|
|
25247
25295
|
try {
|
|
25248
25296
|
const perDeploy = deployId ? deployHouseProxyConfigPath(deployId) : null;
|
|
25249
|
-
const file = perDeploy &&
|
|
25250
|
-
const raw =
|
|
25297
|
+
const file = perDeploy && fs52.existsSync(perDeploy) ? perDeploy : houseProxyConfigPath();
|
|
25298
|
+
const raw = fs52.readFileSync(file, "utf8");
|
|
25251
25299
|
const parsed = JSON.parse(raw);
|
|
25252
25300
|
if (typeof parsed !== "object" || parsed === null) return {};
|
|
25253
25301
|
const o = parsed;
|
|
@@ -25353,9 +25401,9 @@ function pickHouseProxyEnv(env) {
|
|
|
25353
25401
|
}
|
|
25354
25402
|
|
|
25355
25403
|
// src/lib/provider-routing.ts
|
|
25356
|
-
var
|
|
25404
|
+
var fs53 = __toESM(require("fs"));
|
|
25357
25405
|
var os38 = __toESM(require("os"));
|
|
25358
|
-
var
|
|
25406
|
+
var path61 = __toESM(require("path"));
|
|
25359
25407
|
var PROVIDER_BASE_URL_ENV_KEYS = [
|
|
25360
25408
|
"ANTHROPIC_BASE_URL",
|
|
25361
25409
|
"OPENAI_BASE_URL",
|
|
@@ -25378,14 +25426,14 @@ function redactUrlToOrigin(raw) {
|
|
|
25378
25426
|
}
|
|
25379
25427
|
function readOpencodeProviderOrigins(opts = {}) {
|
|
25380
25428
|
const home = opts.homeDir ?? os38.homedir();
|
|
25381
|
-
const readFile7 = opts.readFile ?? ((f) =>
|
|
25429
|
+
const readFile7 = opts.readFile ?? ((f) => fs53.readFileSync(f, "utf8"));
|
|
25382
25430
|
const candidates = [];
|
|
25383
25431
|
if (opts.cwd) {
|
|
25384
|
-
candidates.push(
|
|
25432
|
+
candidates.push(path61.join(opts.cwd, "opencode.json"), path61.join(opts.cwd, "opencode.jsonc"));
|
|
25385
25433
|
}
|
|
25386
25434
|
candidates.push(
|
|
25387
|
-
|
|
25388
|
-
|
|
25435
|
+
path61.join(home, ".config", "opencode", "opencode.json"),
|
|
25436
|
+
path61.join(home, ".config", "opencode", "opencode.jsonc")
|
|
25389
25437
|
);
|
|
25390
25438
|
const out2 = [];
|
|
25391
25439
|
const seen2 = /* @__PURE__ */ new Set();
|
|
@@ -25693,19 +25741,19 @@ function adapterExitMessage(opts) {
|
|
|
25693
25741
|
|
|
25694
25742
|
// src/services/preview/start-orchestrator.ts
|
|
25695
25743
|
var import_child_process20 = require("child_process");
|
|
25696
|
-
var
|
|
25697
|
-
var
|
|
25744
|
+
var fs56 = __toESM(require("fs"));
|
|
25745
|
+
var path64 = __toESM(require("path"));
|
|
25698
25746
|
var import_which3 = __toESM(require("which"));
|
|
25699
25747
|
|
|
25700
25748
|
// src/services/project-env/index.ts
|
|
25701
25749
|
var import_fs6 = require("fs");
|
|
25702
|
-
var
|
|
25750
|
+
var path63 = __toESM(require("path"));
|
|
25703
25751
|
|
|
25704
25752
|
// src/beads/project-key.ts
|
|
25705
25753
|
var import_child_process19 = require("child_process");
|
|
25706
25754
|
var crypto2 = __toESM(require("crypto"));
|
|
25707
|
-
var
|
|
25708
|
-
var
|
|
25755
|
+
var fs54 = __toESM(require("fs"));
|
|
25756
|
+
var path62 = __toESM(require("path"));
|
|
25709
25757
|
function normalizeOrigin(raw) {
|
|
25710
25758
|
const trimmed = raw.trim();
|
|
25711
25759
|
if (!trimmed) return null;
|
|
@@ -25731,17 +25779,17 @@ function normalizeOrigin(raw) {
|
|
|
25731
25779
|
return `${host2}/${pathPart}`;
|
|
25732
25780
|
}
|
|
25733
25781
|
function findRepoRoot(cwd) {
|
|
25734
|
-
let dir =
|
|
25782
|
+
let dir = path62.resolve(cwd);
|
|
25735
25783
|
const seen2 = /* @__PURE__ */ new Set();
|
|
25736
25784
|
for (let i = 0; i < 256; i++) {
|
|
25737
25785
|
if (seen2.has(dir)) return null;
|
|
25738
25786
|
seen2.add(dir);
|
|
25739
25787
|
try {
|
|
25740
|
-
const stat3 =
|
|
25788
|
+
const stat3 = fs54.statSync(path62.join(dir, ".git"), { throwIfNoEntry: false });
|
|
25741
25789
|
if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
|
|
25742
25790
|
} catch {
|
|
25743
25791
|
}
|
|
25744
|
-
const parent =
|
|
25792
|
+
const parent = path62.dirname(dir);
|
|
25745
25793
|
if (parent === dir) return null;
|
|
25746
25794
|
dir = parent;
|
|
25747
25795
|
}
|
|
@@ -25752,7 +25800,7 @@ var _execSeam3 = {
|
|
|
25752
25800
|
const out2 = (0, import_child_process19.execFileSync)(file, args2, opts);
|
|
25753
25801
|
return typeof out2 === "string" ? out2 : out2.toString("utf8");
|
|
25754
25802
|
},
|
|
25755
|
-
realpath: (p2) =>
|
|
25803
|
+
realpath: (p2) => fs54.realpathSync(p2)
|
|
25756
25804
|
};
|
|
25757
25805
|
function readOrigin(cwd) {
|
|
25758
25806
|
try {
|
|
@@ -25781,7 +25829,7 @@ function deriveProjectIdentity(cwd = process.cwd()) {
|
|
|
25781
25829
|
} catch {
|
|
25782
25830
|
}
|
|
25783
25831
|
const hash = crypto2.createHash("sha256").update(real).digest("hex");
|
|
25784
|
-
return { projectKey: `path:${hash}`, projectLabel:
|
|
25832
|
+
return { projectKey: `path:${hash}`, projectLabel: path62.basename(real) || "project" };
|
|
25785
25833
|
}
|
|
25786
25834
|
|
|
25787
25835
|
// src/services/project-env/index.ts
|
|
@@ -25794,7 +25842,7 @@ async function readIfExists(p2) {
|
|
|
25794
25842
|
}
|
|
25795
25843
|
async function syncProjectEnvUp(cwd, ctx) {
|
|
25796
25844
|
if (!ctx.pluginAuthToken) return;
|
|
25797
|
-
const content = await readIfExists(
|
|
25845
|
+
const content = await readIfExists(path63.join(cwd, ".env"));
|
|
25798
25846
|
if (content == null) return;
|
|
25799
25847
|
try {
|
|
25800
25848
|
const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
|
|
@@ -25816,7 +25864,7 @@ async function syncProjectEnvUp(cwd, ctx) {
|
|
|
25816
25864
|
}
|
|
25817
25865
|
async function restoreProjectEnvIfMissing(cwd, ctx) {
|
|
25818
25866
|
if (!ctx.pluginAuthToken) return false;
|
|
25819
|
-
const envPath =
|
|
25867
|
+
const envPath = path63.join(cwd, ".env");
|
|
25820
25868
|
if (await readIfExists(envPath) != null) return false;
|
|
25821
25869
|
try {
|
|
25822
25870
|
const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
|
|
@@ -25827,7 +25875,7 @@ async function restoreProjectEnvIfMissing(cwd, ctx) {
|
|
|
25827
25875
|
projectKey
|
|
25828
25876
|
});
|
|
25829
25877
|
if (!stored) return false;
|
|
25830
|
-
const tmp =
|
|
25878
|
+
const tmp = path63.join(cwd, ".env.codeam-restore.tmp");
|
|
25831
25879
|
await import_fs6.promises.writeFile(tmp, stored.content, { encoding: "utf8", mode: 384 });
|
|
25832
25880
|
await import_fs6.promises.rename(tmp, envPath);
|
|
25833
25881
|
log.info("project-env", `restored .env (${stored.keyCount} vars) for ${projectLabel}`);
|
|
@@ -26591,8 +26639,8 @@ function normalizeDetectionForSpawn(detection, cwd) {
|
|
|
26591
26639
|
if (args2.length === 0) return detection;
|
|
26592
26640
|
const binName = args2[0];
|
|
26593
26641
|
if (binName.startsWith("-")) return detection;
|
|
26594
|
-
const binPath =
|
|
26595
|
-
if (!
|
|
26642
|
+
const binPath = path64.join(cwd, "node_modules", ".bin", binName);
|
|
26643
|
+
if (!fs56.existsSync(binPath)) return detection;
|
|
26596
26644
|
return {
|
|
26597
26645
|
...detection,
|
|
26598
26646
|
command: binPath,
|
|
@@ -27005,9 +27053,9 @@ async function bringUpPublicUrl(ctx, tunnelPort) {
|
|
|
27005
27053
|
|
|
27006
27054
|
// src/beads/bd-adapter.ts
|
|
27007
27055
|
var import_child_process21 = require("child_process");
|
|
27008
|
-
var
|
|
27056
|
+
var fs57 = __toESM(require("fs"));
|
|
27009
27057
|
var os39 = __toESM(require("os"));
|
|
27010
|
-
var
|
|
27058
|
+
var path65 = __toESM(require("path"));
|
|
27011
27059
|
var BD_PACKAGE = "@beads/bd";
|
|
27012
27060
|
function resolveBundledBdBinary() {
|
|
27013
27061
|
return _resolveSeam.resolveBundled();
|
|
@@ -27019,11 +27067,11 @@ function _defaultResolveBundled() {
|
|
|
27019
27067
|
} catch {
|
|
27020
27068
|
return null;
|
|
27021
27069
|
}
|
|
27022
|
-
const binDir =
|
|
27070
|
+
const binDir = path65.join(path65.dirname(pkgJsonPath), "bin");
|
|
27023
27071
|
const binaryName = process.platform === "win32" ? "bd.exe" : "bd";
|
|
27024
|
-
const binaryPath =
|
|
27072
|
+
const binaryPath = path65.join(binDir, binaryName);
|
|
27025
27073
|
try {
|
|
27026
|
-
|
|
27074
|
+
fs57.accessSync(binaryPath, fs57.constants.F_OK);
|
|
27027
27075
|
return binaryPath;
|
|
27028
27076
|
} catch {
|
|
27029
27077
|
return null;
|
|
@@ -27033,13 +27081,13 @@ function resolveBdOnPath() {
|
|
|
27033
27081
|
return _resolveSeam.resolveOnPath();
|
|
27034
27082
|
}
|
|
27035
27083
|
function _defaultResolveOnPath() {
|
|
27036
|
-
const dirs = (process.env.PATH ?? "").split(
|
|
27084
|
+
const dirs = (process.env.PATH ?? "").split(path65.delimiter).filter(Boolean);
|
|
27037
27085
|
const candidates = process.platform === "win32" ? ["bd.exe", "bd.cmd", "bd"] : ["bd"];
|
|
27038
27086
|
for (const dir of dirs) {
|
|
27039
27087
|
for (const candidate of candidates) {
|
|
27040
|
-
const full =
|
|
27088
|
+
const full = path65.join(dir, candidate);
|
|
27041
27089
|
try {
|
|
27042
|
-
|
|
27090
|
+
fs57.accessSync(full, fs57.constants.F_OK);
|
|
27043
27091
|
return full;
|
|
27044
27092
|
} catch {
|
|
27045
27093
|
}
|
|
@@ -27216,9 +27264,9 @@ function coerceIssue(row, projectKey) {
|
|
|
27216
27264
|
|
|
27217
27265
|
// src/beads/provisioner.ts
|
|
27218
27266
|
var import_child_process24 = require("child_process");
|
|
27219
|
-
var
|
|
27267
|
+
var fs59 = __toESM(require("fs"));
|
|
27220
27268
|
var os41 = __toESM(require("os"));
|
|
27221
|
-
var
|
|
27269
|
+
var path67 = __toESM(require("path"));
|
|
27222
27270
|
|
|
27223
27271
|
// src/beads/install-bd.ts
|
|
27224
27272
|
var import_child_process22 = require("child_process");
|
|
@@ -27283,9 +27331,9 @@ async function installBd(platform3 = process.platform) {
|
|
|
27283
27331
|
|
|
27284
27332
|
// src/beads/install-dolt.ts
|
|
27285
27333
|
var import_child_process23 = require("child_process");
|
|
27286
|
-
var
|
|
27334
|
+
var fs58 = __toESM(require("fs"));
|
|
27287
27335
|
var os40 = __toESM(require("os"));
|
|
27288
|
-
var
|
|
27336
|
+
var path66 = __toESM(require("path"));
|
|
27289
27337
|
var DOLT_INSTALL_SH_URL = "https://github.com/dolthub/dolt/releases/latest/download/install.sh";
|
|
27290
27338
|
var DOLT_MSI_URL = "https://github.com/dolthub/dolt/releases/latest/download/dolt-windows-amd64.msi";
|
|
27291
27339
|
function resolveDoltInstallStrategy(platform3) {
|
|
@@ -27381,7 +27429,7 @@ var _doltPathSeam = {
|
|
|
27381
27429
|
},
|
|
27382
27430
|
exists: (p2) => {
|
|
27383
27431
|
try {
|
|
27384
|
-
|
|
27432
|
+
fs58.accessSync(p2, fs58.constants.F_OK);
|
|
27385
27433
|
return true;
|
|
27386
27434
|
} catch {
|
|
27387
27435
|
return false;
|
|
@@ -27392,7 +27440,7 @@ function doltBinaryNames(platform3) {
|
|
|
27392
27440
|
return platform3 === "win32" ? ["dolt.exe", "dolt.cmd", "dolt"] : ["dolt"];
|
|
27393
27441
|
}
|
|
27394
27442
|
function knownDoltDirs(platform3) {
|
|
27395
|
-
const P3 = platform3 === "win32" ?
|
|
27443
|
+
const P3 = platform3 === "win32" ? path66.win32 : path66.posix;
|
|
27396
27444
|
const home = _doltPathSeam.homedir();
|
|
27397
27445
|
if (platform3 === "win32") {
|
|
27398
27446
|
return [
|
|
@@ -27408,7 +27456,7 @@ function knownDoltDirs(platform3) {
|
|
|
27408
27456
|
].filter(Boolean);
|
|
27409
27457
|
}
|
|
27410
27458
|
function ensureDoltResolvable(platform3 = process.platform) {
|
|
27411
|
-
const P3 = platform3 === "win32" ?
|
|
27459
|
+
const P3 = platform3 === "win32" ? path66.win32 : path66.posix;
|
|
27412
27460
|
const delim = platform3 === "win32" ? ";" : ":";
|
|
27413
27461
|
const names = doltBinaryNames(platform3);
|
|
27414
27462
|
const pathDirs = _doltPathSeam.getPath().split(delim).filter(Boolean);
|
|
@@ -27605,14 +27653,14 @@ var _linkSeam = {
|
|
|
27605
27653
|
homedir: () => os41.homedir(),
|
|
27606
27654
|
isWritableDir: (dir) => {
|
|
27607
27655
|
try {
|
|
27608
|
-
|
|
27656
|
+
fs59.accessSync(dir, fs59.constants.W_OK);
|
|
27609
27657
|
return true;
|
|
27610
27658
|
} catch {
|
|
27611
27659
|
return false;
|
|
27612
27660
|
}
|
|
27613
27661
|
},
|
|
27614
27662
|
ensureDir: (dir) => {
|
|
27615
|
-
|
|
27663
|
+
fs59.mkdirSync(dir, { recursive: true });
|
|
27616
27664
|
},
|
|
27617
27665
|
/**
|
|
27618
27666
|
* A directory to symlink `bd` into so the AGENT's shell + Claude Code's
|
|
@@ -27633,9 +27681,9 @@ var _linkSeam = {
|
|
|
27633
27681
|
* which `linkBdOntoPath` creates if missing.
|
|
27634
27682
|
*/
|
|
27635
27683
|
cliBinDir: () => {
|
|
27636
|
-
const pathDirs = (process.env.PATH ?? "").split(
|
|
27684
|
+
const pathDirs = (process.env.PATH ?? "").split(path67.delimiter).filter(Boolean);
|
|
27637
27685
|
const home = _linkSeam.homedir();
|
|
27638
|
-
const localBin = home ?
|
|
27686
|
+
const localBin = home ? path67.join(home, ".local", "bin") : null;
|
|
27639
27687
|
if (localBin) {
|
|
27640
27688
|
try {
|
|
27641
27689
|
_linkSeam.ensureDir(localBin);
|
|
@@ -27645,16 +27693,16 @@ var _linkSeam = {
|
|
|
27645
27693
|
const candidates = [];
|
|
27646
27694
|
if (localBin) candidates.push(localBin);
|
|
27647
27695
|
try {
|
|
27648
|
-
candidates.push(
|
|
27696
|
+
candidates.push(path67.dirname(process.execPath));
|
|
27649
27697
|
} catch {
|
|
27650
27698
|
}
|
|
27651
27699
|
candidates.push("/usr/local/bin");
|
|
27652
27700
|
const entry = process.argv[1];
|
|
27653
27701
|
if (entry) {
|
|
27654
27702
|
try {
|
|
27655
|
-
candidates.push(
|
|
27703
|
+
candidates.push(path67.dirname(fs59.realpathSync(entry)));
|
|
27656
27704
|
} catch {
|
|
27657
|
-
candidates.push(
|
|
27705
|
+
candidates.push(path67.dirname(entry));
|
|
27658
27706
|
}
|
|
27659
27707
|
}
|
|
27660
27708
|
const onPathWritable = candidates.find(
|
|
@@ -27666,20 +27714,20 @@ var _linkSeam = {
|
|
|
27666
27714
|
/** Current symlink target at `linkPath`, or null when absent / not a link. */
|
|
27667
27715
|
readlink: (linkPath) => {
|
|
27668
27716
|
try {
|
|
27669
|
-
return
|
|
27717
|
+
return fs59.readlinkSync(linkPath);
|
|
27670
27718
|
} catch {
|
|
27671
27719
|
return null;
|
|
27672
27720
|
}
|
|
27673
27721
|
},
|
|
27674
|
-
unlink: (linkPath) =>
|
|
27675
|
-
symlink: (target, linkPath) =>
|
|
27722
|
+
unlink: (linkPath) => fs59.unlinkSync(linkPath),
|
|
27723
|
+
symlink: (target, linkPath) => fs59.symlinkSync(target, linkPath)
|
|
27676
27724
|
};
|
|
27677
27725
|
function linkBdOntoPath(binaryPath) {
|
|
27678
27726
|
if (_linkSeam.platform() === "win32") return;
|
|
27679
27727
|
const binDir = _linkSeam.cliBinDir();
|
|
27680
27728
|
if (!binDir) return;
|
|
27681
27729
|
_linkSeam.ensureDir(binDir);
|
|
27682
|
-
const linkPath =
|
|
27730
|
+
const linkPath = path67.join(binDir, "bd");
|
|
27683
27731
|
if (linkPath === binaryPath) return;
|
|
27684
27732
|
const current2 = _linkSeam.readlink(linkPath);
|
|
27685
27733
|
if (current2 === binaryPath) return;
|
|
@@ -27893,16 +27941,16 @@ function dedupeRecipes(agents) {
|
|
|
27893
27941
|
}
|
|
27894
27942
|
function ensureLocalGitExclude(cwd, patterns) {
|
|
27895
27943
|
try {
|
|
27896
|
-
const gitDir =
|
|
27897
|
-
if (!
|
|
27898
|
-
const file =
|
|
27899
|
-
|
|
27900
|
-
const current2 =
|
|
27944
|
+
const gitDir = path67.join(cwd, ".git");
|
|
27945
|
+
if (!fs59.statSync(gitDir).isDirectory()) return;
|
|
27946
|
+
const file = path67.join(gitDir, "info", "exclude");
|
|
27947
|
+
fs59.mkdirSync(path67.dirname(file), { recursive: true });
|
|
27948
|
+
const current2 = fs59.existsSync(file) ? fs59.readFileSync(file, "utf8") : "";
|
|
27901
27949
|
const have = new Set(current2.split(/\r?\n/).map((l) => l.trim()));
|
|
27902
27950
|
const missing = patterns.filter((p2) => !have.has(p2));
|
|
27903
27951
|
if (missing.length === 0) return;
|
|
27904
27952
|
const prefix = current2.length > 0 && !current2.endsWith("\n") ? "\n" : "";
|
|
27905
|
-
|
|
27953
|
+
fs59.appendFileSync(file, `${prefix}# CodeAgent: beads state stays local
|
|
27906
27954
|
${missing.join("\n")}
|
|
27907
27955
|
`);
|
|
27908
27956
|
} catch {
|
|
@@ -27911,7 +27959,7 @@ ${missing.join("\n")}
|
|
|
27911
27959
|
|
|
27912
27960
|
// src/beads/watcher.ts
|
|
27913
27961
|
var crypto4 = __toESM(require("crypto"));
|
|
27914
|
-
var
|
|
27962
|
+
var path68 = __toESM(require("path"));
|
|
27915
27963
|
var API_BASE5 = resolveApiBaseUrl();
|
|
27916
27964
|
var DEBOUNCE_MS2 = 400;
|
|
27917
27965
|
var ZERO_SUMMARY = {
|
|
@@ -27935,7 +27983,7 @@ var BeadsWatcher = class {
|
|
|
27935
27983
|
constructor(opts) {
|
|
27936
27984
|
this.opts = opts;
|
|
27937
27985
|
this.bd = opts.adapter ?? new BdAdapter({ cwd: opts.cwd, beadsDir: opts.beadsDir });
|
|
27938
|
-
this.feedPath = opts.feedPath ??
|
|
27986
|
+
this.feedPath = opts.feedPath ?? path68.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
|
|
27939
27987
|
this.apiBase = opts.apiBaseUrl ?? API_BASE5;
|
|
27940
27988
|
}
|
|
27941
27989
|
opts;
|
|
@@ -28186,15 +28234,15 @@ async function handleBeadsActionCommand(action, started) {
|
|
|
28186
28234
|
}
|
|
28187
28235
|
|
|
28188
28236
|
// src/beads/config-store.ts
|
|
28189
|
-
var
|
|
28237
|
+
var import_node_fs15 = __toESM(require("fs"));
|
|
28190
28238
|
var import_node_os8 = __toESM(require("os"));
|
|
28191
|
-
var
|
|
28239
|
+
var import_node_path14 = __toESM(require("path"));
|
|
28192
28240
|
function beadsConfigPath() {
|
|
28193
|
-
return
|
|
28241
|
+
return import_node_path14.default.join(import_node_os8.default.homedir(), ".codeam", "beads-config.json");
|
|
28194
28242
|
}
|
|
28195
28243
|
function readBeadsEnabled() {
|
|
28196
28244
|
try {
|
|
28197
|
-
const raw =
|
|
28245
|
+
const raw = import_node_fs15.default.readFileSync(beadsConfigPath(), "utf8");
|
|
28198
28246
|
const cfg = JSON.parse(raw);
|
|
28199
28247
|
return cfg.enabled !== false;
|
|
28200
28248
|
} catch {
|
|
@@ -28203,10 +28251,10 @@ function readBeadsEnabled() {
|
|
|
28203
28251
|
}
|
|
28204
28252
|
function persistBeadsConfig(cfg) {
|
|
28205
28253
|
const file = beadsConfigPath();
|
|
28206
|
-
|
|
28254
|
+
import_node_fs15.default.mkdirSync(import_node_path14.default.dirname(file), { recursive: true });
|
|
28207
28255
|
const tmp = `${file}.tmp`;
|
|
28208
|
-
|
|
28209
|
-
|
|
28256
|
+
import_node_fs15.default.writeFileSync(tmp, JSON.stringify(cfg), { mode: 384 });
|
|
28257
|
+
import_node_fs15.default.renameSync(tmp, file);
|
|
28210
28258
|
restrictToOwner(file);
|
|
28211
28259
|
}
|
|
28212
28260
|
|
|
@@ -28345,12 +28393,12 @@ async function configureBeads(action, ctx, deps) {
|
|
|
28345
28393
|
var import_node_os11 = __toESM(require("os"));
|
|
28346
28394
|
|
|
28347
28395
|
// src/skills/materialize.ts
|
|
28348
|
-
var
|
|
28396
|
+
var import_node_fs16 = __toESM(require("fs"));
|
|
28349
28397
|
var import_node_os9 = __toESM(require("os"));
|
|
28350
|
-
var
|
|
28398
|
+
var import_node_path15 = __toESM(require("path"));
|
|
28351
28399
|
var NS = "codeam-";
|
|
28352
28400
|
function skillDirFor(id, home = import_node_os9.default.homedir()) {
|
|
28353
|
-
return
|
|
28401
|
+
return import_node_path15.default.join(home, ".claude", "skills", `${NS}${id}`);
|
|
28354
28402
|
}
|
|
28355
28403
|
function renderSkillMd(id, description, body) {
|
|
28356
28404
|
const desc = description.replace(/\s*\n\s*/g, " ").trim();
|
|
@@ -28367,21 +28415,21 @@ function materializeSkill(id, home = import_node_os9.default.homedir()) {
|
|
|
28367
28415
|
if (!def?.delivery.skillFile) return false;
|
|
28368
28416
|
try {
|
|
28369
28417
|
const dir = skillDirFor(id, home);
|
|
28370
|
-
|
|
28371
|
-
|
|
28372
|
-
|
|
28418
|
+
import_node_fs16.default.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
28419
|
+
import_node_fs16.default.writeFileSync(
|
|
28420
|
+
import_node_path15.default.join(dir, "SKILL.md"),
|
|
28373
28421
|
renderSkillMd(id, def.description, def.delivery.skillFile.body),
|
|
28374
28422
|
{ encoding: "utf8", mode: 384 }
|
|
28375
28423
|
);
|
|
28376
|
-
const baseDir =
|
|
28377
|
-
const baseDirWithSep = baseDir +
|
|
28424
|
+
const baseDir = import_node_path15.default.resolve(dir);
|
|
28425
|
+
const baseDirWithSep = baseDir + import_node_path15.default.sep;
|
|
28378
28426
|
for (const [rel, contents] of Object.entries(def.delivery.skillFile.files ?? {})) {
|
|
28379
|
-
const target =
|
|
28380
|
-
if (!
|
|
28427
|
+
const target = import_node_path15.default.join(dir, rel);
|
|
28428
|
+
if (!import_node_path15.default.resolve(target).startsWith(baseDirWithSep) && import_node_path15.default.resolve(target) !== baseDir) {
|
|
28381
28429
|
continue;
|
|
28382
28430
|
}
|
|
28383
|
-
|
|
28384
|
-
|
|
28431
|
+
import_node_fs16.default.mkdirSync(import_node_path15.default.dirname(target), { recursive: true, mode: 448 });
|
|
28432
|
+
import_node_fs16.default.writeFileSync(target, contents, { encoding: "utf8", mode: 384 });
|
|
28385
28433
|
}
|
|
28386
28434
|
return true;
|
|
28387
28435
|
} catch (err) {
|
|
@@ -28391,21 +28439,21 @@ function materializeSkill(id, home = import_node_os9.default.homedir()) {
|
|
|
28391
28439
|
}
|
|
28392
28440
|
function removeSkill(id, home = import_node_os9.default.homedir()) {
|
|
28393
28441
|
try {
|
|
28394
|
-
|
|
28442
|
+
import_node_fs16.default.rmSync(skillDirFor(id, home), { recursive: true, force: true });
|
|
28395
28443
|
} catch {
|
|
28396
28444
|
}
|
|
28397
28445
|
}
|
|
28398
28446
|
|
|
28399
28447
|
// src/skills/manifest.ts
|
|
28400
|
-
var
|
|
28448
|
+
var import_node_fs17 = __toESM(require("fs"));
|
|
28401
28449
|
var import_node_os10 = __toESM(require("os"));
|
|
28402
|
-
var
|
|
28450
|
+
var import_node_path16 = __toESM(require("path"));
|
|
28403
28451
|
function skillsManifestPath() {
|
|
28404
|
-
return
|
|
28452
|
+
return import_node_path16.default.join(import_node_os10.default.homedir(), ".codeam", "skills.json");
|
|
28405
28453
|
}
|
|
28406
28454
|
function readSkillsManifest() {
|
|
28407
28455
|
try {
|
|
28408
|
-
const raw = JSON.parse(
|
|
28456
|
+
const raw = JSON.parse(import_node_fs17.default.readFileSync(skillsManifestPath(), "utf8"));
|
|
28409
28457
|
if (!Array.isArray(raw?.skills)) return null;
|
|
28410
28458
|
raw.skills = raw.skills.filter(
|
|
28411
28459
|
(s) => Boolean(s) && typeof s === "object" && typeof s.id === "string"
|
|
@@ -28418,10 +28466,10 @@ function readSkillsManifest() {
|
|
|
28418
28466
|
function persistSkillsManifest(m) {
|
|
28419
28467
|
try {
|
|
28420
28468
|
const file = skillsManifestPath();
|
|
28421
|
-
|
|
28469
|
+
import_node_fs17.default.mkdirSync(import_node_path16.default.dirname(file), { recursive: true, mode: 448 });
|
|
28422
28470
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
28423
|
-
|
|
28424
|
-
|
|
28471
|
+
import_node_fs17.default.writeFileSync(tmp, JSON.stringify(m, null, 2), { encoding: "utf8", mode: 384 });
|
|
28472
|
+
import_node_fs17.default.renameSync(tmp, file);
|
|
28425
28473
|
restrictToOwner(file);
|
|
28426
28474
|
} catch (err) {
|
|
28427
28475
|
log.warn(
|
|
@@ -28432,7 +28480,7 @@ function persistSkillsManifest(m) {
|
|
|
28432
28480
|
}
|
|
28433
28481
|
function clearSkillsManifest() {
|
|
28434
28482
|
try {
|
|
28435
|
-
|
|
28483
|
+
import_node_fs17.default.rmSync(skillsManifestPath(), { force: true });
|
|
28436
28484
|
} catch {
|
|
28437
28485
|
}
|
|
28438
28486
|
}
|
|
@@ -28475,8 +28523,8 @@ function cleanupAttachmentTempFiles() {
|
|
|
28475
28523
|
function saveFilesTemp(files) {
|
|
28476
28524
|
return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
|
|
28477
28525
|
const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
|
|
28478
|
-
const tmpPath =
|
|
28479
|
-
|
|
28526
|
+
const tmpPath = path72.join(os46.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
|
|
28527
|
+
fs63.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
|
|
28480
28528
|
pendingAttachmentFiles.add(tmpPath);
|
|
28481
28529
|
return tmpPath;
|
|
28482
28530
|
});
|
|
@@ -28721,10 +28769,10 @@ var listFiles = async (ctx, cmd, parsed) => {
|
|
|
28721
28769
|
await ctx.relay.sendResult(cmd.id, "completed", result);
|
|
28722
28770
|
};
|
|
28723
28771
|
var envReadH = async (ctx, cmd) => {
|
|
28724
|
-
const envPath =
|
|
28772
|
+
const envPath = path72.join(process.cwd(), ".env");
|
|
28725
28773
|
await restoreProjectEnvIfMissing(process.cwd(), ctx);
|
|
28726
28774
|
try {
|
|
28727
|
-
const raw = await
|
|
28775
|
+
const raw = await fs63.promises.readFile(envPath, "utf8");
|
|
28728
28776
|
await ctx.relay.sendResult(cmd.id, "completed", {
|
|
28729
28777
|
exists: true,
|
|
28730
28778
|
vars: parseDotenv(raw)
|
|
@@ -28753,7 +28801,7 @@ var envParseH = async (ctx, cmd, parsed) => {
|
|
|
28753
28801
|
const existing = /* @__PURE__ */ new Map();
|
|
28754
28802
|
if (!replace) {
|
|
28755
28803
|
try {
|
|
28756
|
-
const raw = await
|
|
28804
|
+
const raw = await fs63.promises.readFile(path72.join(process.cwd(), ".env"), "utf8");
|
|
28757
28805
|
for (const v of parseDotenv(raw)) existing.set(v.key, v.value);
|
|
28758
28806
|
} catch {
|
|
28759
28807
|
}
|
|
@@ -28793,15 +28841,15 @@ var envWriteH = async (ctx, cmd, parsed) => {
|
|
|
28793
28841
|
}
|
|
28794
28842
|
seen2.add(v.key);
|
|
28795
28843
|
}
|
|
28796
|
-
const envPath =
|
|
28797
|
-
const tmpPath =
|
|
28844
|
+
const envPath = path72.join(process.cwd(), ".env");
|
|
28845
|
+
const tmpPath = path72.join(process.cwd(), ".env.codeam.tmp");
|
|
28798
28846
|
try {
|
|
28799
|
-
await
|
|
28800
|
-
await
|
|
28847
|
+
await fs63.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
|
|
28848
|
+
await fs63.promises.rename(tmpPath, envPath);
|
|
28801
28849
|
await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
|
|
28802
28850
|
void syncProjectEnvUp(process.cwd(), ctx);
|
|
28803
28851
|
} catch (err) {
|
|
28804
|
-
await
|
|
28852
|
+
await fs63.promises.rm(tmpPath, { force: true }).catch(() => void 0);
|
|
28805
28853
|
await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
|
|
28806
28854
|
}
|
|
28807
28855
|
};
|
|
@@ -29150,9 +29198,9 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
|
|
|
29150
29198
|
function buildNpmInstallInvocation(opts) {
|
|
29151
29199
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
29152
29200
|
const execPath = opts?.execPath ?? process.execPath;
|
|
29153
|
-
const exists2 = opts?.existsSync ??
|
|
29201
|
+
const exists2 = opts?.existsSync ?? fs63.existsSync;
|
|
29154
29202
|
const platform3 = opts?.platform ?? process.platform;
|
|
29155
|
-
const p2 = platform3 === "win32" ?
|
|
29203
|
+
const p2 = platform3 === "win32" ? path72.win32 : path72.posix;
|
|
29156
29204
|
const normalized = entryScript.split(/[\\/]/).join("/");
|
|
29157
29205
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
29158
29206
|
const markerIdx = normalized.indexOf(marker);
|
|
@@ -29171,7 +29219,7 @@ function isPermissionError(stderr) {
|
|
|
29171
29219
|
function resolveGlobalNodeModulesDir(opts) {
|
|
29172
29220
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
29173
29221
|
const platform3 = opts?.platform ?? process.platform;
|
|
29174
|
-
const p2 = platform3 === "win32" ?
|
|
29222
|
+
const p2 = platform3 === "win32" ? path72.win32 : path72.posix;
|
|
29175
29223
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
29176
29224
|
const markerIdx = entryScript.split(/[\\/]/).join("/").indexOf(marker);
|
|
29177
29225
|
if (markerIdx <= 0) return null;
|
|
@@ -29181,9 +29229,9 @@ function resolveGlobalNodeModulesDir(opts) {
|
|
|
29181
29229
|
var STALE_STAGING_AGE_MS = CLI_UPDATE_INSTALL_TIMEOUT_MS;
|
|
29182
29230
|
function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
29183
29231
|
if (!nodeModulesDir) return 0;
|
|
29184
|
-
const readdirSync17 = deps?.readdirSync ??
|
|
29185
|
-
const statSync16 = deps?.statSync ??
|
|
29186
|
-
const rmSync11 = deps?.rmSync ??
|
|
29232
|
+
const readdirSync17 = deps?.readdirSync ?? fs63.readdirSync;
|
|
29233
|
+
const statSync16 = deps?.statSync ?? fs63.statSync;
|
|
29234
|
+
const rmSync11 = deps?.rmSync ?? fs63.rmSync;
|
|
29187
29235
|
let removed = 0;
|
|
29188
29236
|
let entries2;
|
|
29189
29237
|
try {
|
|
@@ -29193,7 +29241,7 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
|
29193
29241
|
}
|
|
29194
29242
|
for (const name of entries2) {
|
|
29195
29243
|
if (!/^\.codeam-cli-/.test(name)) continue;
|
|
29196
|
-
const full =
|
|
29244
|
+
const full = path72.join(nodeModulesDir, name);
|
|
29197
29245
|
try {
|
|
29198
29246
|
const st3 = statSync16(full);
|
|
29199
29247
|
if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
|
|
@@ -29612,6 +29660,14 @@ async function resolvePreviewDetection(args2) {
|
|
|
29612
29660
|
payload: originPayload(payload, origin)
|
|
29613
29661
|
});
|
|
29614
29662
|
};
|
|
29663
|
+
if (isEmptyScratchProject(process.cwd())) {
|
|
29664
|
+
log.info("preview", "detect: empty scratch project \u2014 nothing to preview yet");
|
|
29665
|
+
emit2(USER_EVENTS.PREVIEW_ERROR, {
|
|
29666
|
+
stage: "unsupported",
|
|
29667
|
+
message: "Nothing to preview yet \u2014 this project is empty. Ask your agent to build something and it opens the preview."
|
|
29668
|
+
});
|
|
29669
|
+
return null;
|
|
29670
|
+
}
|
|
29615
29671
|
if (typeof runtime.generateOneShot !== "function") {
|
|
29616
29672
|
log.info("preview", `runtime ${runtime.id} has no generateOneShot \u2014 emitting unsupported`);
|
|
29617
29673
|
emit2(USER_EVENTS.PREVIEW_ERROR, {
|
|
@@ -29809,6 +29865,7 @@ async function offerScratchSaveOnce(ctx, pluginAuthToken) {
|
|
|
29809
29865
|
}
|
|
29810
29866
|
function startPreviewFromDetection(ctx, detection, pluginAuthToken, opts = {}) {
|
|
29811
29867
|
previewRequestedInProcess = true;
|
|
29868
|
+
notePreviewBringUp(ctx.sessionId);
|
|
29812
29869
|
const emit2 = (type, payload) => {
|
|
29813
29870
|
const tagged = originPayload(payload, opts.origin) ?? {};
|
|
29814
29871
|
opts.onEvent?.(type, tagged);
|
|
@@ -30307,11 +30364,11 @@ function resolveTokenValue(args2) {
|
|
|
30307
30364
|
}
|
|
30308
30365
|
const fileFlag = args2.find((a) => a.startsWith("--token-file="));
|
|
30309
30366
|
if (fileFlag) {
|
|
30310
|
-
const
|
|
30367
|
+
const path109 = fileFlag.slice("--token-file=".length);
|
|
30311
30368
|
try {
|
|
30312
|
-
const content =
|
|
30313
|
-
if (content.length === 0) fail(`--token-file ${
|
|
30314
|
-
rmIfExistsQuiet(
|
|
30369
|
+
const content = fs64.readFileSync(path109, "utf8").trim();
|
|
30370
|
+
if (content.length === 0) fail(`--token-file ${path109} is empty`);
|
|
30371
|
+
rmIfExistsQuiet(path109);
|
|
30315
30372
|
return content;
|
|
30316
30373
|
} catch (err) {
|
|
30317
30374
|
fail(`Could not read --token-file: ${err.message}`);
|
|
@@ -30403,12 +30460,12 @@ async function claim(token, pluginId, pluginSecretHash) {
|
|
|
30403
30460
|
}
|
|
30404
30461
|
}
|
|
30405
30462
|
function pairAutoLockPath() {
|
|
30406
|
-
return
|
|
30463
|
+
return path73.join(os47.homedir(), ".codeam", "pair-auto.lock");
|
|
30407
30464
|
}
|
|
30408
30465
|
var procRoot = "/proc";
|
|
30409
30466
|
function readProcFile(rel) {
|
|
30410
30467
|
try {
|
|
30411
|
-
return
|
|
30468
|
+
return fs64.readFileSync(path73.join(procRoot, rel), "utf8");
|
|
30412
30469
|
} catch {
|
|
30413
30470
|
return void 0;
|
|
30414
30471
|
}
|
|
@@ -30429,7 +30486,7 @@ function currentBootId() {
|
|
|
30429
30486
|
function readLockRecord(lockPath) {
|
|
30430
30487
|
let raw;
|
|
30431
30488
|
try {
|
|
30432
|
-
raw =
|
|
30489
|
+
raw = fs64.readFileSync(lockPath, "utf8");
|
|
30433
30490
|
} catch {
|
|
30434
30491
|
return void 0;
|
|
30435
30492
|
}
|
|
@@ -30478,7 +30535,7 @@ function isLiveLockHolder(rec) {
|
|
|
30478
30535
|
}
|
|
30479
30536
|
function releaseOwnLock(lockPath) {
|
|
30480
30537
|
try {
|
|
30481
|
-
if (readLockRecord(lockPath)?.pid === process.pid)
|
|
30538
|
+
if (readLockRecord(lockPath)?.pid === process.pid) fs64.unlinkSync(lockPath);
|
|
30482
30539
|
} catch {
|
|
30483
30540
|
}
|
|
30484
30541
|
}
|
|
@@ -30502,7 +30559,7 @@ function snapshotProcessTree(root) {
|
|
|
30502
30559
|
const children = /* @__PURE__ */ new Map();
|
|
30503
30560
|
let entries2 = [];
|
|
30504
30561
|
try {
|
|
30505
|
-
entries2 =
|
|
30562
|
+
entries2 = fs64.readdirSync(procRoot).filter((e) => /^\d+$/.test(e));
|
|
30506
30563
|
} catch {
|
|
30507
30564
|
}
|
|
30508
30565
|
for (const e of entries2) {
|
|
@@ -30537,18 +30594,18 @@ function signalProcessTree(refs, signal) {
|
|
|
30537
30594
|
}
|
|
30538
30595
|
function daemonLockPath(sessionId) {
|
|
30539
30596
|
const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
30540
|
-
return
|
|
30597
|
+
return path73.join(os47.homedir(), ".codeam", `daemon-${safe}.lock`);
|
|
30541
30598
|
}
|
|
30542
30599
|
function acquireDaemonLock(sessionId) {
|
|
30543
30600
|
const lockPath = daemonLockPath(sessionId);
|
|
30544
30601
|
try {
|
|
30545
|
-
|
|
30602
|
+
fs64.mkdirSync(path73.dirname(lockPath), { recursive: true });
|
|
30546
30603
|
try {
|
|
30547
|
-
|
|
30604
|
+
fs64.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
30548
30605
|
} catch (e) {
|
|
30549
30606
|
if (e.code !== "EEXIST") throw e;
|
|
30550
30607
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
30551
|
-
|
|
30608
|
+
fs64.writeFileSync(lockPath, ownLockBody());
|
|
30552
30609
|
}
|
|
30553
30610
|
const release3 = () => releaseOwnLock(lockPath);
|
|
30554
30611
|
process.once("exit", release3);
|
|
@@ -30568,13 +30625,13 @@ function acquireDaemonLock(sessionId) {
|
|
|
30568
30625
|
function acquireSingletonLock() {
|
|
30569
30626
|
const lockPath = pairAutoLockPath();
|
|
30570
30627
|
try {
|
|
30571
|
-
|
|
30628
|
+
fs64.mkdirSync(path73.dirname(lockPath), { recursive: true });
|
|
30572
30629
|
try {
|
|
30573
|
-
|
|
30630
|
+
fs64.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
30574
30631
|
} catch (e) {
|
|
30575
30632
|
if (e.code !== "EEXIST") throw e;
|
|
30576
30633
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
30577
|
-
|
|
30634
|
+
fs64.writeFileSync(lockPath, ownLockBody());
|
|
30578
30635
|
}
|
|
30579
30636
|
process.once("exit", () => releaseOwnLock(lockPath));
|
|
30580
30637
|
return true;
|
|
@@ -30991,15 +31048,15 @@ var AgentService = class _AgentService {
|
|
|
30991
31048
|
};
|
|
30992
31049
|
|
|
30993
31050
|
// src/agents/acp/adapters.ts
|
|
30994
|
-
var
|
|
31051
|
+
var path74 = __toESM(require("path"));
|
|
30995
31052
|
|
|
30996
31053
|
// src/agents/kimi/installer.ts
|
|
30997
31054
|
var import_node_child_process25 = require("child_process");
|
|
30998
31055
|
var import_node_os12 = require("os");
|
|
30999
|
-
var
|
|
31056
|
+
var import_node_path17 = require("path");
|
|
31000
31057
|
var INSTALL_URL2 = "https://code.kimi.com/kimi-code/install.sh";
|
|
31001
31058
|
function kimiBinDir() {
|
|
31002
|
-
return (0,
|
|
31059
|
+
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
31060
|
}
|
|
31004
31061
|
function kimiRuns() {
|
|
31005
31062
|
const r = (0, import_node_child_process25.spawnSync)("kimi", ["--version"], { stdio: "ignore", timeout: 15e3 });
|
|
@@ -31049,10 +31106,10 @@ async function ensureKimiInstalled() {
|
|
|
31049
31106
|
// src/agents/opencode/installer.ts
|
|
31050
31107
|
var import_node_child_process26 = require("child_process");
|
|
31051
31108
|
var import_node_os13 = require("os");
|
|
31052
|
-
var
|
|
31109
|
+
var import_node_path18 = require("path");
|
|
31053
31110
|
var INSTALL_URL3 = "https://opencode.ai/install";
|
|
31054
31111
|
function opencodeBinDir() {
|
|
31055
|
-
return (0,
|
|
31112
|
+
return (0, import_node_path18.join)(process.env.OPENCODE_HOME || (0, import_node_path18.join)((0, import_node_os13.homedir)(), ".opencode"), "bin");
|
|
31056
31113
|
}
|
|
31057
31114
|
function opencodeRuns() {
|
|
31058
31115
|
const r = (0, import_node_child_process26.spawnSync)("opencode", ["--version"], { stdio: "ignore", timeout: 15e3 });
|
|
@@ -31111,13 +31168,13 @@ function resolveBin(pkgName, binName) {
|
|
|
31111
31168
|
try {
|
|
31112
31169
|
const manifestPath = require_.resolve(`${pkgName}/package.json`);
|
|
31113
31170
|
const manifest = require_(`${pkgName}/package.json`);
|
|
31114
|
-
const pkgDir =
|
|
31171
|
+
const pkgDir = path74.dirname(manifestPath);
|
|
31115
31172
|
const bin = manifest.bin;
|
|
31116
31173
|
if (!bin) return null;
|
|
31117
|
-
if (typeof bin === "string") return
|
|
31174
|
+
if (typeof bin === "string") return path74.resolve(pkgDir, bin);
|
|
31118
31175
|
const target = binName ?? Object.keys(bin)[0];
|
|
31119
31176
|
if (!target || !bin[target]) return null;
|
|
31120
|
-
return
|
|
31177
|
+
return path74.resolve(pkgDir, bin[target]);
|
|
31121
31178
|
} catch {
|
|
31122
31179
|
return null;
|
|
31123
31180
|
}
|
|
@@ -31298,9 +31355,9 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
|
|
|
31298
31355
|
|
|
31299
31356
|
// src/agents/acp/runner.ts
|
|
31300
31357
|
var import_node_crypto15 = require("crypto");
|
|
31301
|
-
var
|
|
31358
|
+
var fs83 = __toESM(require("fs"));
|
|
31302
31359
|
var os59 = __toESM(require("os"));
|
|
31303
|
-
var
|
|
31360
|
+
var path94 = __toESM(require("path"));
|
|
31304
31361
|
|
|
31305
31362
|
// src/agents/acp/provider-billing-signal.ts
|
|
31306
31363
|
var seen = /* @__PURE__ */ new Set();
|
|
@@ -31332,8 +31389,8 @@ function noteProviderBillingSignal(opts) {
|
|
|
31332
31389
|
}
|
|
31333
31390
|
|
|
31334
31391
|
// src/services/history.service.ts
|
|
31335
|
-
var
|
|
31336
|
-
var
|
|
31392
|
+
var fs65 = __toESM(require("fs"));
|
|
31393
|
+
var path75 = __toESM(require("path"));
|
|
31337
31394
|
var https6 = __toESM(require("https"));
|
|
31338
31395
|
var http10 = __toESM(require("http"));
|
|
31339
31396
|
var import_zod2 = require("zod");
|
|
@@ -31394,7 +31451,7 @@ function parseJsonl(filePath) {
|
|
|
31394
31451
|
const messages = [];
|
|
31395
31452
|
let raw;
|
|
31396
31453
|
try {
|
|
31397
|
-
raw =
|
|
31454
|
+
raw = fs65.readFileSync(filePath, "utf8");
|
|
31398
31455
|
} catch (err) {
|
|
31399
31456
|
if (err.code !== "ENOENT") {
|
|
31400
31457
|
log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
|
|
@@ -31554,7 +31611,7 @@ var HistoryService = class _HistoryService {
|
|
|
31554
31611
|
// session-start upload answered false, the active-conversation pointer was
|
|
31555
31612
|
// never re-pointed after a Box wake, and the app opened an empty "New
|
|
31556
31613
|
// conversation" over the resumed one (QA box, 2026-09-29).
|
|
31557
|
-
|
|
31614
|
+
path75.join(claudeConfigDir(), "projects", encodeCwd(this.cwd));
|
|
31558
31615
|
}
|
|
31559
31616
|
/** Set the current Claude conversation ID (extracted from /cost command or session start) */
|
|
31560
31617
|
setCurrentConversationId(id) {
|
|
@@ -31566,7 +31623,7 @@ var HistoryService = class _HistoryService {
|
|
|
31566
31623
|
/** Return the current message count in the active conversation. */
|
|
31567
31624
|
getCurrentMessageCount() {
|
|
31568
31625
|
if (!this.currentConversationId) return 0;
|
|
31569
|
-
const filePath =
|
|
31626
|
+
const filePath = path75.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
31570
31627
|
return parseJsonl(filePath).length;
|
|
31571
31628
|
}
|
|
31572
31629
|
/**
|
|
@@ -31577,7 +31634,7 @@ var HistoryService = class _HistoryService {
|
|
|
31577
31634
|
const deadline = Date.now() + timeoutMs;
|
|
31578
31635
|
while (Date.now() < deadline) {
|
|
31579
31636
|
if (!this.currentConversationId) return null;
|
|
31580
|
-
const filePath =
|
|
31637
|
+
const filePath = path75.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
31581
31638
|
const messages = parseJsonl(filePath);
|
|
31582
31639
|
if (messages.length > previousCount) {
|
|
31583
31640
|
for (let i = messages.length - 1; i >= previousCount; i--) {
|
|
@@ -31604,18 +31661,18 @@ var HistoryService = class _HistoryService {
|
|
|
31604
31661
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
31605
31662
|
const oneShots = readOneShotConversations(this.cwd);
|
|
31606
31663
|
try {
|
|
31607
|
-
const files =
|
|
31608
|
-
(e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(
|
|
31664
|
+
const files = fs65.readdirSync(dir, { withFileTypes: true }).filter(
|
|
31665
|
+
(e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(path75.basename(e.name, ".jsonl"))
|
|
31609
31666
|
).map((e) => {
|
|
31610
31667
|
try {
|
|
31611
|
-
const stat3 =
|
|
31668
|
+
const stat3 = fs65.statSync(path75.join(dir, e.name));
|
|
31612
31669
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
31613
31670
|
} catch {
|
|
31614
31671
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
31615
31672
|
}
|
|
31616
31673
|
}).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
31617
31674
|
if (files.length > 0) {
|
|
31618
|
-
this.currentConversationId =
|
|
31675
|
+
this.currentConversationId = path75.basename(files[0].name, ".jsonl");
|
|
31619
31676
|
}
|
|
31620
31677
|
} catch {
|
|
31621
31678
|
}
|
|
@@ -31649,13 +31706,13 @@ var HistoryService = class _HistoryService {
|
|
|
31649
31706
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
31650
31707
|
let entries2;
|
|
31651
31708
|
try {
|
|
31652
|
-
entries2 =
|
|
31709
|
+
entries2 = fs65.readdirSync(dir, { withFileTypes: true });
|
|
31653
31710
|
} catch {
|
|
31654
31711
|
return null;
|
|
31655
31712
|
}
|
|
31656
31713
|
const files = entries2.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
31657
31714
|
try {
|
|
31658
|
-
const stat3 =
|
|
31715
|
+
const stat3 = fs65.statSync(path75.join(dir, e.name));
|
|
31659
31716
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
31660
31717
|
} catch {
|
|
31661
31718
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
@@ -31664,12 +31721,12 @@ var HistoryService = class _HistoryService {
|
|
|
31664
31721
|
if (files.length === 0) return null;
|
|
31665
31722
|
const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
|
|
31666
31723
|
if (!files.some((f) => f.name === targetFile)) return null;
|
|
31667
|
-
return this.extractUsageFromFile(
|
|
31724
|
+
return this.extractUsageFromFile(path75.join(dir, targetFile));
|
|
31668
31725
|
}
|
|
31669
31726
|
extractUsageFromFile(filePath) {
|
|
31670
31727
|
let raw;
|
|
31671
31728
|
try {
|
|
31672
|
-
raw =
|
|
31729
|
+
raw = fs65.readFileSync(filePath, "utf8");
|
|
31673
31730
|
} catch {
|
|
31674
31731
|
return null;
|
|
31675
31732
|
}
|
|
@@ -31721,9 +31778,9 @@ var HistoryService = class _HistoryService {
|
|
|
31721
31778
|
let totalCost = 0;
|
|
31722
31779
|
let files;
|
|
31723
31780
|
try {
|
|
31724
|
-
files =
|
|
31781
|
+
files = fs65.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
|
|
31725
31782
|
try {
|
|
31726
|
-
return
|
|
31783
|
+
return fs65.statSync(path75.join(projectDir, f)).mtimeMs >= monthStartMs;
|
|
31727
31784
|
} catch {
|
|
31728
31785
|
return false;
|
|
31729
31786
|
}
|
|
@@ -31734,7 +31791,7 @@ var HistoryService = class _HistoryService {
|
|
|
31734
31791
|
for (const file of files) {
|
|
31735
31792
|
let raw;
|
|
31736
31793
|
try {
|
|
31737
|
-
raw =
|
|
31794
|
+
raw = fs65.readFileSync(path75.join(projectDir, file), "utf8");
|
|
31738
31795
|
} catch {
|
|
31739
31796
|
continue;
|
|
31740
31797
|
}
|
|
@@ -31813,7 +31870,7 @@ var HistoryService = class _HistoryService {
|
|
|
31813
31870
|
if (this.runtime.resolveHistoryFile) {
|
|
31814
31871
|
return this.runtime.resolveHistoryFile(this.cwd, sessionId);
|
|
31815
31872
|
}
|
|
31816
|
-
return
|
|
31873
|
+
return path75.join(this.projectDir, `${sessionId}.jsonl`);
|
|
31817
31874
|
}
|
|
31818
31875
|
/**
|
|
31819
31876
|
* Parse a conversation's messages from disk, agent-aware. Claude uses the
|
|
@@ -31851,7 +31908,7 @@ var HistoryService = class _HistoryService {
|
|
|
31851
31908
|
};
|
|
31852
31909
|
});
|
|
31853
31910
|
}
|
|
31854
|
-
return parseJsonl(
|
|
31911
|
+
return parseJsonl(path75.join(this.projectDir, `${sessionId}.jsonl`));
|
|
31855
31912
|
}
|
|
31856
31913
|
/** One in-flight full upload per conversation — the baton mirror and a
|
|
31857
31914
|
* `get_conversation` used to upload the same transcript concurrently. */
|
|
@@ -31933,7 +31990,7 @@ var HistoryService = class _HistoryService {
|
|
|
31933
31990
|
if (!filePath) return false;
|
|
31934
31991
|
let mtimeMs;
|
|
31935
31992
|
try {
|
|
31936
|
-
mtimeMs =
|
|
31993
|
+
mtimeMs = fs65.statSync(filePath).mtimeMs;
|
|
31937
31994
|
} catch {
|
|
31938
31995
|
return false;
|
|
31939
31996
|
}
|
|
@@ -32008,10 +32065,10 @@ var HistoryService = class _HistoryService {
|
|
|
32008
32065
|
|
|
32009
32066
|
// src/agents/acp/client.ts
|
|
32010
32067
|
var import_node_child_process27 = require("child_process");
|
|
32011
|
-
var
|
|
32068
|
+
var fs66 = __toESM(require("fs/promises"));
|
|
32012
32069
|
var fsSync = __toESM(require("fs"));
|
|
32013
32070
|
var os49 = __toESM(require("os"));
|
|
32014
|
-
var
|
|
32071
|
+
var path77 = __toESM(require("path"));
|
|
32015
32072
|
var import_node_stream = require("stream");
|
|
32016
32073
|
|
|
32017
32074
|
// ../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
@@ -36037,7 +36094,7 @@ function createIdleTimeout(idleMs, makeError, activeIdleMs = idleMs) {
|
|
|
36037
36094
|
}
|
|
36038
36095
|
|
|
36039
36096
|
// src/agents/acp/internal-paths.ts
|
|
36040
|
-
var
|
|
36097
|
+
var path76 = __toESM(require("path"));
|
|
36041
36098
|
var os48 = __toESM(require("os"));
|
|
36042
36099
|
var INTERNAL_TOKENS = [".codeam", "house-claude"];
|
|
36043
36100
|
var PROSE_ONLY_TOOL_KINDS = /* @__PURE__ */ new Set(["think", "switch_mode"]);
|
|
@@ -36052,11 +36109,11 @@ function textReferencesInternal(text) {
|
|
|
36052
36109
|
}
|
|
36053
36110
|
function pathIsInternal(p2, homeDir2 = os48.homedir()) {
|
|
36054
36111
|
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(
|
|
36112
|
+
const abs = path76.resolve(p2);
|
|
36113
|
+
const home = path76.resolve(homeDir2);
|
|
36114
|
+
const within = (root) => abs === root || abs.startsWith(root + path76.sep);
|
|
36115
|
+
if (within(path76.join(home, ".codeam", "self-hosted"))) return false;
|
|
36116
|
+
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
36117
|
}
|
|
36061
36118
|
function toolCallReferencesInternal(call, homeDir2) {
|
|
36062
36119
|
if (call.locations?.some((l) => pathIsInternal(l.path, homeDir2))) return true;
|
|
@@ -37152,7 +37209,7 @@ var AcpClient = class {
|
|
|
37152
37209
|
throw new RequestError(-32002, GUARDRAIL_SECRET_READ_BLOCK_REASON, { uri: params.path });
|
|
37153
37210
|
}
|
|
37154
37211
|
try {
|
|
37155
|
-
const content = await
|
|
37212
|
+
const content = await fs66.readFile(params.path, "utf8");
|
|
37156
37213
|
return applyLineRange(content, params.line ?? null, params.limit ?? null);
|
|
37157
37214
|
} catch (err) {
|
|
37158
37215
|
const code = err.code;
|
|
@@ -37173,7 +37230,7 @@ var AcpClient = class {
|
|
|
37173
37230
|
throw new RequestError(-32002, INTERNAL_BLOCK_REASON, { uri: params.path });
|
|
37174
37231
|
}
|
|
37175
37232
|
try {
|
|
37176
|
-
await
|
|
37233
|
+
await fs66.writeFile(params.path, params.content, "utf8");
|
|
37177
37234
|
return {};
|
|
37178
37235
|
} catch (err) {
|
|
37179
37236
|
const code = err.code;
|
|
@@ -37266,25 +37323,25 @@ function knownAgentBinaryDirs() {
|
|
|
37266
37323
|
out2.push("/tmp/codeam-node20/bin");
|
|
37267
37324
|
for (const root of [
|
|
37268
37325
|
"/usr/local/share/nvm/versions/node",
|
|
37269
|
-
|
|
37326
|
+
path77.join(home, ".nvm/versions/node")
|
|
37270
37327
|
]) {
|
|
37271
37328
|
try {
|
|
37272
37329
|
for (const child of fsSync.readdirSync(root)) {
|
|
37273
|
-
out2.push(
|
|
37330
|
+
out2.push(path77.join(root, child, "bin"));
|
|
37274
37331
|
}
|
|
37275
37332
|
} catch {
|
|
37276
37333
|
}
|
|
37277
37334
|
}
|
|
37278
|
-
out2.push(
|
|
37335
|
+
out2.push(path77.join(home, ".volta/bin"));
|
|
37279
37336
|
out2.push("/usr/local/bin");
|
|
37280
37337
|
out2.push("/usr/bin");
|
|
37281
|
-
out2.push(
|
|
37282
|
-
out2.push(
|
|
37338
|
+
out2.push(path77.join(home, ".local/bin"));
|
|
37339
|
+
out2.push(path77.join(home, "bin"));
|
|
37283
37340
|
out2.push(...agentInstallBinDirs());
|
|
37284
37341
|
if (process.platform === "win32") {
|
|
37285
37342
|
const { LOCALAPPDATA, APPDATA } = process.env;
|
|
37286
|
-
if (LOCALAPPDATA) out2.push(
|
|
37287
|
-
if (APPDATA) out2.push(
|
|
37343
|
+
if (LOCALAPPDATA) out2.push(path77.join(LOCALAPPDATA, "cursor-agent"));
|
|
37344
|
+
if (APPDATA) out2.push(path77.join(APPDATA, "npm"));
|
|
37288
37345
|
}
|
|
37289
37346
|
return out2.filter((p2) => {
|
|
37290
37347
|
try {
|
|
@@ -37295,7 +37352,7 @@ function knownAgentBinaryDirs() {
|
|
|
37295
37352
|
});
|
|
37296
37353
|
}
|
|
37297
37354
|
function expandPathForAgentBinaries(existingPath) {
|
|
37298
|
-
const existing = new Set(existingPath.split(
|
|
37355
|
+
const existing = new Set(existingPath.split(path77.delimiter).filter((p2) => p2.length > 0));
|
|
37299
37356
|
const additions = [];
|
|
37300
37357
|
for (const dir of knownAgentBinaryDirs()) {
|
|
37301
37358
|
if (!existing.has(dir)) {
|
|
@@ -37304,7 +37361,7 @@ function expandPathForAgentBinaries(existingPath) {
|
|
|
37304
37361
|
}
|
|
37305
37362
|
}
|
|
37306
37363
|
if (additions.length === 0) return existingPath;
|
|
37307
|
-
return [...additions, existingPath].filter((p2) => p2.length > 0).join(
|
|
37364
|
+
return [...additions, existingPath].filter((p2) => p2.length > 0).join(path77.delimiter);
|
|
37308
37365
|
}
|
|
37309
37366
|
|
|
37310
37367
|
// src/commands/host/agent-install.ts
|
|
@@ -37576,9 +37633,9 @@ async function performAgentSwitch(deps, rawAgentId, fastPath = {}) {
|
|
|
37576
37633
|
}
|
|
37577
37634
|
|
|
37578
37635
|
// src/commands/host/agent-provisioning.ts
|
|
37579
|
-
var
|
|
37636
|
+
var fs67 = __toESM(require("fs"));
|
|
37580
37637
|
var os51 = __toESM(require("os"));
|
|
37581
|
-
var
|
|
37638
|
+
var path78 = __toESM(require("path"));
|
|
37582
37639
|
var PUBLIC_TO_INTERNAL_AGENT = {
|
|
37583
37640
|
claude_code: "claude",
|
|
37584
37641
|
claude: "claude",
|
|
@@ -37595,22 +37652,22 @@ function toInternalAgentId(publicAgentId) {
|
|
|
37595
37652
|
return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
|
|
37596
37653
|
}
|
|
37597
37654
|
function ensureDir(dir) {
|
|
37598
|
-
|
|
37655
|
+
fs67.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
37599
37656
|
}
|
|
37600
37657
|
function writeFile0600(filePath, contents) {
|
|
37601
|
-
ensureDir(
|
|
37602
|
-
|
|
37658
|
+
ensureDir(path78.dirname(filePath));
|
|
37659
|
+
fs67.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
|
|
37603
37660
|
restrictToOwner(filePath);
|
|
37604
37661
|
}
|
|
37605
37662
|
function rmIfExists(filePath) {
|
|
37606
37663
|
try {
|
|
37607
|
-
|
|
37664
|
+
fs67.rmSync(filePath, { force: true });
|
|
37608
37665
|
} catch {
|
|
37609
37666
|
}
|
|
37610
37667
|
}
|
|
37611
37668
|
var claudeProvisioner = {
|
|
37612
37669
|
write(auth, home) {
|
|
37613
|
-
const credentialsJson =
|
|
37670
|
+
const credentialsJson = path78.join(home, ".claude", ".credentials.json");
|
|
37614
37671
|
if (auth.kind === "api_key") {
|
|
37615
37672
|
rmIfExists(credentialsJson);
|
|
37616
37673
|
return { ANTHROPIC_API_KEY: auth.value };
|
|
@@ -37622,8 +37679,8 @@ var claudeProvisioner = {
|
|
|
37622
37679
|
} else {
|
|
37623
37680
|
rmIfExists(credentialsJson);
|
|
37624
37681
|
}
|
|
37625
|
-
const claudeJson =
|
|
37626
|
-
if (!
|
|
37682
|
+
const claudeJson = path78.join(home, ".claude.json");
|
|
37683
|
+
if (!fs67.existsSync(claudeJson)) {
|
|
37627
37684
|
writeFile0600(
|
|
37628
37685
|
claudeJson,
|
|
37629
37686
|
JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
|
|
@@ -37634,7 +37691,7 @@ var claudeProvisioner = {
|
|
|
37634
37691
|
};
|
|
37635
37692
|
var codexProvisioner = {
|
|
37636
37693
|
write(auth, home) {
|
|
37637
|
-
const authJson =
|
|
37694
|
+
const authJson = path78.join(home, ".codex", "auth.json");
|
|
37638
37695
|
if (auth.kind === "api_key") {
|
|
37639
37696
|
writeFile0600(authJson, JSON.stringify({ auth_mode: "apikey", OPENAI_API_KEY: auth.value }));
|
|
37640
37697
|
return { OPENAI_API_KEY: auth.value };
|
|
@@ -37657,7 +37714,7 @@ function codexLoginStamp(raw) {
|
|
|
37657
37714
|
function keepsFresherCodexLogin(authJsonPath, incoming) {
|
|
37658
37715
|
let onDisk;
|
|
37659
37716
|
try {
|
|
37660
|
-
onDisk =
|
|
37717
|
+
onDisk = fs67.readFileSync(authJsonPath, "utf8");
|
|
37661
37718
|
} catch {
|
|
37662
37719
|
return false;
|
|
37663
37720
|
}
|
|
@@ -37668,8 +37725,8 @@ function keepsFresherCodexLogin(authJsonPath, incoming) {
|
|
|
37668
37725
|
}
|
|
37669
37726
|
var geminiProvisioner = {
|
|
37670
37727
|
write(auth, home) {
|
|
37671
|
-
const settingsJson =
|
|
37672
|
-
const oauthCreds =
|
|
37728
|
+
const settingsJson = path78.join(home, ".gemini", "settings.json");
|
|
37729
|
+
const oauthCreds = path78.join(home, ".gemini", "oauth_creds.json");
|
|
37673
37730
|
if (auth.kind === "api_key") {
|
|
37674
37731
|
rmIfExists(oauthCreds);
|
|
37675
37732
|
writeFile0600(settingsJson, '{"security":{"auth":{"selectedType":"gemini-api-key"}}}');
|
|
@@ -37682,7 +37739,7 @@ var geminiProvisioner = {
|
|
|
37682
37739
|
};
|
|
37683
37740
|
var cursorProvisioner = {
|
|
37684
37741
|
write(auth, home) {
|
|
37685
|
-
const authJson =
|
|
37742
|
+
const authJson = path78.join(home, ".config", "cursor", "auth.json");
|
|
37686
37743
|
if (auth.kind === "api_key") {
|
|
37687
37744
|
rmIfExists(authJson);
|
|
37688
37745
|
return { CURSOR_API_KEY: auth.value };
|
|
@@ -37724,22 +37781,22 @@ max_context_size = 262144
|
|
|
37724
37781
|
var kimiProvisioner = {
|
|
37725
37782
|
write(auth, home) {
|
|
37726
37783
|
const credentialsFiles = [
|
|
37727
|
-
|
|
37728
|
-
|
|
37784
|
+
path78.join(home, ".kimi", "credentials", "kimi-code.json"),
|
|
37785
|
+
path78.join(home, ".kimi-code", "credentials", "kimi-code.json")
|
|
37729
37786
|
];
|
|
37730
37787
|
if (auth.kind === "api_key") {
|
|
37731
37788
|
credentialsFiles.forEach(rmIfExists);
|
|
37732
37789
|
return { KIMI_API_KEY: auth.value };
|
|
37733
37790
|
}
|
|
37734
37791
|
credentialsFiles.forEach((f) => writeFile0600(f, auth.value));
|
|
37735
|
-
writeFile0600(
|
|
37792
|
+
writeFile0600(path78.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
|
|
37736
37793
|
return {};
|
|
37737
37794
|
}
|
|
37738
37795
|
};
|
|
37739
37796
|
var coderabbitProvisioner = {
|
|
37740
37797
|
write(auth, home) {
|
|
37741
|
-
const dir =
|
|
37742
|
-
const authJson =
|
|
37798
|
+
const dir = path78.join(home, ".coderabbit");
|
|
37799
|
+
const authJson = path78.join(dir, "auth.json");
|
|
37743
37800
|
if (auth.kind === "api_key") {
|
|
37744
37801
|
rmIfExists(authJson);
|
|
37745
37802
|
return { CODERABBIT_API_KEY: auth.value };
|
|
@@ -37751,13 +37808,13 @@ var coderabbitProvisioner = {
|
|
|
37751
37808
|
try {
|
|
37752
37809
|
const parsed = JSON.parse(value);
|
|
37753
37810
|
if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
|
|
37754
|
-
file =
|
|
37811
|
+
file = path78.basename(parsed.file);
|
|
37755
37812
|
contents = parsed.contents;
|
|
37756
37813
|
}
|
|
37757
37814
|
} catch {
|
|
37758
37815
|
}
|
|
37759
37816
|
}
|
|
37760
|
-
writeFile0600(
|
|
37817
|
+
writeFile0600(path78.join(dir, file), contents);
|
|
37761
37818
|
return {};
|
|
37762
37819
|
}
|
|
37763
37820
|
};
|
|
@@ -37794,8 +37851,8 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os51.homedir(
|
|
|
37794
37851
|
}
|
|
37795
37852
|
|
|
37796
37853
|
// src/beads/workflow-hint.ts
|
|
37797
|
-
var
|
|
37798
|
-
var
|
|
37854
|
+
var fs68 = __toESM(require("fs"));
|
|
37855
|
+
var path79 = __toESM(require("path"));
|
|
37799
37856
|
var BEADS_HINT_MARKER = "<!-- codeam:beads-workflow -->";
|
|
37800
37857
|
var BEADS_HINT = `${BEADS_HINT_MARKER}
|
|
37801
37858
|
# Beads (bd) \u2014 task tracking + persistent memory (ALWAYS use it)
|
|
@@ -37822,11 +37879,11 @@ function ensureBeadsWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
|
37822
37879
|
try {
|
|
37823
37880
|
let existing = "";
|
|
37824
37881
|
try {
|
|
37825
|
-
existing =
|
|
37882
|
+
existing = fs68.readFileSync(file, "utf8");
|
|
37826
37883
|
} catch {
|
|
37827
37884
|
}
|
|
37828
37885
|
if (existing.includes(BEADS_HINT)) return;
|
|
37829
|
-
|
|
37886
|
+
fs68.mkdirSync(path79.dirname(file), { recursive: true });
|
|
37830
37887
|
let next;
|
|
37831
37888
|
const open = existing.indexOf(BEADS_HINT_MARKER);
|
|
37832
37889
|
const close = open === -1 ? -1 : existing.indexOf(BEADS_HINT_MARKER, open + BEADS_HINT_MARKER.length);
|
|
@@ -37839,40 +37896,40 @@ ${BEADS_HINT}
|
|
|
37839
37896
|
` : `${BEADS_HINT}
|
|
37840
37897
|
`;
|
|
37841
37898
|
}
|
|
37842
|
-
|
|
37899
|
+
fs68.writeFileSync(file, next);
|
|
37843
37900
|
} catch {
|
|
37844
37901
|
}
|
|
37845
37902
|
}
|
|
37846
37903
|
|
|
37847
37904
|
// src/agents/agent-standard.ts
|
|
37848
|
-
var
|
|
37849
|
-
var
|
|
37905
|
+
var fs69 = __toESM(require("fs"));
|
|
37906
|
+
var path80 = __toESM(require("path"));
|
|
37850
37907
|
var os52 = __toESM(require("os"));
|
|
37851
37908
|
function ensureAgentStandard(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
37852
37909
|
try {
|
|
37853
37910
|
let existing = "";
|
|
37854
37911
|
try {
|
|
37855
|
-
existing =
|
|
37912
|
+
existing = fs69.readFileSync(file, "utf8");
|
|
37856
37913
|
} catch {
|
|
37857
37914
|
}
|
|
37858
37915
|
if (existing.includes(AGENT_STANDARD_MARKER)) return;
|
|
37859
|
-
|
|
37916
|
+
fs69.mkdirSync(path80.dirname(file), { recursive: true });
|
|
37860
37917
|
const next = existing.trim() ? `${existing.trimEnd()}
|
|
37861
37918
|
|
|
37862
37919
|
${AGENT_STANDARD_BLOCK}
|
|
37863
37920
|
` : `${AGENT_STANDARD_BLOCK}
|
|
37864
37921
|
`;
|
|
37865
|
-
|
|
37922
|
+
fs69.writeFileSync(file, next);
|
|
37866
37923
|
} catch {
|
|
37867
37924
|
}
|
|
37868
37925
|
}
|
|
37869
37926
|
var _agentStandardSeam = {
|
|
37870
37927
|
isLocalSession: () => isLocalSession(),
|
|
37871
|
-
markerPath: (sessionId) =>
|
|
37872
|
-
exists: (p2) =>
|
|
37928
|
+
markerPath: (sessionId) => path80.join(os52.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
|
|
37929
|
+
exists: (p2) => fs69.existsSync(p2),
|
|
37873
37930
|
write: (p2) => {
|
|
37874
|
-
|
|
37875
|
-
|
|
37931
|
+
fs69.mkdirSync(path80.dirname(p2), { recursive: true });
|
|
37932
|
+
fs69.writeFileSync(p2, "");
|
|
37876
37933
|
}
|
|
37877
37934
|
};
|
|
37878
37935
|
function isClaude(agent) {
|
|
@@ -37892,6 +37949,48 @@ function maybePrefaceAgentStandard(blocks, agent, sessionId, seam = _agentStanda
|
|
|
37892
37949
|
blocks.unshift({ type: "text", text: AGENT_STANDARD_TEXT });
|
|
37893
37950
|
}
|
|
37894
37951
|
|
|
37952
|
+
// src/scratch/workflow-hint.ts
|
|
37953
|
+
var import_node_fs18 = __toESM(require("fs"));
|
|
37954
|
+
var import_node_path19 = __toESM(require("path"));
|
|
37955
|
+
var SCRATCH_HINT_MARKER = "<!-- codeam:scratch-workflow -->";
|
|
37956
|
+
var SCRATCH_HINT = `${SCRATCH_HINT_MARKER}
|
|
37957
|
+
# From-scratch projects (CodeAgent Box)
|
|
37958
|
+
|
|
37959
|
+
When the working directory is a project started from scratch (no git remote,
|
|
37960
|
+
a \`.git/codeam-scratch\` marker):
|
|
37961
|
+
|
|
37962
|
+
- Build something small, visible and working first. As soon as it can be
|
|
37963
|
+
seen, start it with the \`codeagent_preview\` \`start_preview\` tool and tell the
|
|
37964
|
+
user the preview is open.
|
|
37965
|
+
- If the user asks what you can do or for ideas, list them in a few short
|
|
37966
|
+
lines and build the first one in the same turn (unless they ask you to
|
|
37967
|
+
wait), so they see something running right away.
|
|
37968
|
+
- Saving is the user's choice in the app (Save to GitHub / GitLab, or a ZIP).
|
|
37969
|
+
Never push, create repositories or ask for git credentials yourself. Once the
|
|
37970
|
+
user has seen something working, call \`suggest_save_project\` ONCE if the
|
|
37971
|
+
app has not offered to save yet.
|
|
37972
|
+
${SCRATCH_HINT_MARKER}`;
|
|
37973
|
+
function ensureScratchWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
37974
|
+
try {
|
|
37975
|
+
let existing = "";
|
|
37976
|
+
try {
|
|
37977
|
+
existing = import_node_fs18.default.readFileSync(file, "utf8");
|
|
37978
|
+
} catch {
|
|
37979
|
+
}
|
|
37980
|
+
if (existing.includes(SCRATCH_HINT)) return;
|
|
37981
|
+
import_node_fs18.default.mkdirSync(import_node_path19.default.dirname(file), { recursive: true });
|
|
37982
|
+
const open = existing.indexOf(SCRATCH_HINT_MARKER);
|
|
37983
|
+
const close = open === -1 ? -1 : existing.indexOf(SCRATCH_HINT_MARKER, open + SCRATCH_HINT_MARKER.length);
|
|
37984
|
+
const next = open !== -1 && close !== -1 ? existing.slice(0, open) + SCRATCH_HINT + existing.slice(close + SCRATCH_HINT_MARKER.length) : existing.trim() ? `${existing.trimEnd()}
|
|
37985
|
+
|
|
37986
|
+
${SCRATCH_HINT}
|
|
37987
|
+
` : `${SCRATCH_HINT}
|
|
37988
|
+
`;
|
|
37989
|
+
import_node_fs18.default.writeFileSync(file, next);
|
|
37990
|
+
} catch {
|
|
37991
|
+
}
|
|
37992
|
+
}
|
|
37993
|
+
|
|
37895
37994
|
// src/services/streaming/transport.ts
|
|
37896
37995
|
var http11 = __toESM(require("http"));
|
|
37897
37996
|
var https7 = __toESM(require("https"));
|
|
@@ -38565,15 +38664,15 @@ function withholdTrailingPartialFenceMarker(text) {
|
|
|
38565
38664
|
|
|
38566
38665
|
// src/agents/acp/onboarding.ts
|
|
38567
38666
|
var import_child_process28 = require("child_process");
|
|
38568
|
-
var
|
|
38667
|
+
var fs71 = __toESM(require("fs"));
|
|
38569
38668
|
var os53 = __toESM(require("os"));
|
|
38570
|
-
var
|
|
38669
|
+
var path82 = __toESM(require("path"));
|
|
38571
38670
|
var _onboardingSeam = {
|
|
38572
|
-
markerPath: (sessionId) =>
|
|
38573
|
-
exists: (p2) =>
|
|
38671
|
+
markerPath: (sessionId) => path82.join(os53.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
|
|
38672
|
+
exists: (p2) => fs71.existsSync(p2),
|
|
38574
38673
|
write: (p2) => {
|
|
38575
|
-
|
|
38576
|
-
|
|
38674
|
+
fs71.mkdirSync(path82.dirname(p2), { recursive: true });
|
|
38675
|
+
fs71.writeFileSync(p2, "");
|
|
38577
38676
|
},
|
|
38578
38677
|
disabled: () => {
|
|
38579
38678
|
const v = process.env.CODEAM_ONBOARDING_DISABLED;
|
|
@@ -38610,7 +38709,7 @@ function resolveRepoName(cwd) {
|
|
|
38610
38709
|
if (name) return name;
|
|
38611
38710
|
}
|
|
38612
38711
|
}
|
|
38613
|
-
const base =
|
|
38712
|
+
const base = path82.basename(cwd || "");
|
|
38614
38713
|
if (base && !isUuid(base)) return base;
|
|
38615
38714
|
return "this project";
|
|
38616
38715
|
}
|
|
@@ -39002,14 +39101,14 @@ var import_crypto5 = require("crypto");
|
|
|
39002
39101
|
|
|
39003
39102
|
// src/services/turn-files/git-changeset.ts
|
|
39004
39103
|
var import_child_process29 = require("child_process");
|
|
39005
|
-
var
|
|
39104
|
+
var fs73 = __toESM(require("fs/promises"));
|
|
39006
39105
|
var import_fs7 = require("fs");
|
|
39007
|
-
var
|
|
39106
|
+
var path84 = __toESM(require("path"));
|
|
39008
39107
|
|
|
39009
39108
|
// src/services/turn-files/review-ignore.ts
|
|
39010
39109
|
var import_ignore2 = __toESM(require("ignore"));
|
|
39011
|
-
var
|
|
39012
|
-
var
|
|
39110
|
+
var fs72 = __toESM(require("fs"));
|
|
39111
|
+
var path83 = __toESM(require("path"));
|
|
39013
39112
|
var CURATED_REVIEW_IGNORE = [
|
|
39014
39113
|
// Google Cloud SDK (the incident) — installs a huge python tree.
|
|
39015
39114
|
"google-cloud-sdk/",
|
|
@@ -39053,7 +39152,7 @@ var CURATED_REVIEW_IGNORE = [
|
|
|
39053
39152
|
function makeReviewIgnore(repoRoot) {
|
|
39054
39153
|
const ig = (0, import_ignore2.default)().add(CURATED_REVIEW_IGNORE);
|
|
39055
39154
|
try {
|
|
39056
|
-
const custom =
|
|
39155
|
+
const custom = fs72.readFileSync(path83.join(repoRoot, ".codeam", "reviewignore"), "utf8");
|
|
39057
39156
|
ig.add(custom);
|
|
39058
39157
|
} catch {
|
|
39059
39158
|
}
|
|
@@ -39088,7 +39187,7 @@ async function collectRepoChangeset(opts) {
|
|
|
39088
39187
|
const rows = parseStatus(status2).filter(
|
|
39089
39188
|
(row) => !isIgnoredFilePath(row.filePath) && !reviewIgnore(row.filePath) && // A socket, FIFO or device node is never a change to review (a
|
|
39090
39189
|
// `cc-socks/1522.sock` reached the Files tab).
|
|
39091
|
-
isReviewablePath(
|
|
39190
|
+
isReviewablePath(path84.join(opts.repoRoot, row.filePath))
|
|
39092
39191
|
);
|
|
39093
39192
|
const MAX_CHANGESET_FILES = Math.max(1, Number(process.env.CODEAM_MAX_CHANGESET_FILES ?? 500));
|
|
39094
39193
|
const truncated = rows.length > MAX_CHANGESET_FILES;
|
|
@@ -39105,7 +39204,7 @@ async function collectRepoChangeset(opts) {
|
|
|
39105
39204
|
let stats;
|
|
39106
39205
|
if (!truncated && row.fileStatus === "added" && numstatEntry === void 0) {
|
|
39107
39206
|
const lineCount = await readUntrackedLineCount(
|
|
39108
|
-
|
|
39207
|
+
path84.join(opts.repoRoot, row.filePath)
|
|
39109
39208
|
);
|
|
39110
39209
|
stats = { added: lineCount, removed: 0 };
|
|
39111
39210
|
} else {
|
|
@@ -39136,7 +39235,7 @@ function readUntrackedLineCount(absPath) {
|
|
|
39136
39235
|
}
|
|
39137
39236
|
async function defaultReadUntrackedLineCount(absPath) {
|
|
39138
39237
|
try {
|
|
39139
|
-
const content = await
|
|
39238
|
+
const content = await fs73.readFile(absPath, "utf8");
|
|
39140
39239
|
let count = 0;
|
|
39141
39240
|
let pos = -1;
|
|
39142
39241
|
while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
|
|
@@ -39228,7 +39327,7 @@ function defaultRunGit(cwd, args2) {
|
|
|
39228
39327
|
});
|
|
39229
39328
|
}
|
|
39230
39329
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
39231
|
-
const
|
|
39330
|
+
const fs94 = await import("fs/promises");
|
|
39232
39331
|
const out2 = [];
|
|
39233
39332
|
await walk2(workingDir, 0);
|
|
39234
39333
|
return out2;
|
|
@@ -39236,7 +39335,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
39236
39335
|
if (depth2 > maxDepth) return;
|
|
39237
39336
|
let entries2 = [];
|
|
39238
39337
|
try {
|
|
39239
|
-
const dirents = await
|
|
39338
|
+
const dirents = await fs94.readdir(dir, { withFileTypes: true });
|
|
39240
39339
|
entries2 = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
39241
39340
|
} catch {
|
|
39242
39341
|
return;
|
|
@@ -39247,8 +39346,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
39247
39346
|
if (hasGit) {
|
|
39248
39347
|
out2.push({
|
|
39249
39348
|
repoRoot: dir,
|
|
39250
|
-
repoPath:
|
|
39251
|
-
repoName:
|
|
39349
|
+
repoPath: path84.relative(workingDir, dir),
|
|
39350
|
+
repoName: path84.basename(dir)
|
|
39252
39351
|
});
|
|
39253
39352
|
return;
|
|
39254
39353
|
}
|
|
@@ -39256,7 +39355,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
39256
39355
|
if (!entry.isDirectory) continue;
|
|
39257
39356
|
if (entry.name === "node_modules") continue;
|
|
39258
39357
|
if (entry.name === "dist" || entry.name === "build") continue;
|
|
39259
|
-
await walk2(
|
|
39358
|
+
await walk2(path84.join(dir, entry.name), depth2 + 1);
|
|
39260
39359
|
}
|
|
39261
39360
|
}
|
|
39262
39361
|
}
|
|
@@ -39270,8 +39369,8 @@ function isReviewablePath(absPath) {
|
|
|
39270
39369
|
}
|
|
39271
39370
|
|
|
39272
39371
|
// src/services/turn-files/files-outbox.ts
|
|
39273
|
-
var
|
|
39274
|
-
var
|
|
39372
|
+
var fs74 = __toESM(require("fs/promises"));
|
|
39373
|
+
var path85 = __toESM(require("path"));
|
|
39275
39374
|
var import_os12 = require("os");
|
|
39276
39375
|
var HOME_OUTBOX_DIR = ".codeam/outbox";
|
|
39277
39376
|
var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -39304,16 +39403,16 @@ var FilesOutbox = class {
|
|
|
39304
39403
|
backoffIndex = 0;
|
|
39305
39404
|
stopped = false;
|
|
39306
39405
|
constructor(opts) {
|
|
39307
|
-
const base = opts.baseDir ??
|
|
39308
|
-
this.filePath =
|
|
39406
|
+
const base = opts.baseDir ?? path85.join(homeDir(), HOME_OUTBOX_DIR);
|
|
39407
|
+
this.filePath = path85.join(base, `${opts.sessionId}.jsonl`);
|
|
39309
39408
|
this.post = opts.post;
|
|
39310
39409
|
this.autoSchedule = opts.autoSchedule !== false;
|
|
39311
39410
|
}
|
|
39312
39411
|
/** Persist the entry to disk and trigger a flush. Returns once the
|
|
39313
39412
|
* line is durable on disk (not once the POST succeeds). */
|
|
39314
39413
|
async enqueue(entry) {
|
|
39315
|
-
await
|
|
39316
|
-
await
|
|
39414
|
+
await fs74.mkdir(path85.dirname(this.filePath), { recursive: true });
|
|
39415
|
+
await fs74.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
|
|
39317
39416
|
this.backoffIndex = 0;
|
|
39318
39417
|
if (this.autoSchedule) this.scheduleFlush(0);
|
|
39319
39418
|
}
|
|
@@ -39404,7 +39503,7 @@ var FilesOutbox = class {
|
|
|
39404
39503
|
async readAll() {
|
|
39405
39504
|
let raw = "";
|
|
39406
39505
|
try {
|
|
39407
|
-
raw = await
|
|
39506
|
+
raw = await fs74.readFile(this.filePath, "utf8");
|
|
39408
39507
|
} catch {
|
|
39409
39508
|
return [];
|
|
39410
39509
|
}
|
|
@@ -39428,12 +39527,12 @@ var FilesOutbox = class {
|
|
|
39428
39527
|
async rewrite(entries2) {
|
|
39429
39528
|
const tmpPath = `${this.filePath}.${process.pid}.tmp`;
|
|
39430
39529
|
if (entries2.length === 0) {
|
|
39431
|
-
await
|
|
39530
|
+
await fs74.unlink(this.filePath).catch(() => void 0);
|
|
39432
39531
|
return;
|
|
39433
39532
|
}
|
|
39434
39533
|
const payload = entries2.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
39435
|
-
await
|
|
39436
|
-
await
|
|
39534
|
+
await fs74.writeFile(tmpPath, payload, "utf8");
|
|
39535
|
+
await fs74.rename(tmpPath, this.filePath);
|
|
39437
39536
|
}
|
|
39438
39537
|
};
|
|
39439
39538
|
function applyJitter(ms) {
|
|
@@ -39753,15 +39852,15 @@ async function postCredentialSync(opts, fetchImpl = fetch) {
|
|
|
39753
39852
|
var import_node_crypto13 = require("crypto");
|
|
39754
39853
|
var import_promises6 = __toESM(require("fs/promises"));
|
|
39755
39854
|
var import_node_os14 = __toESM(require("os"));
|
|
39756
|
-
var
|
|
39855
|
+
var import_node_path20 = __toESM(require("path"));
|
|
39757
39856
|
function markerPath3(cwd, homeDir2 = import_node_os14.default.homedir()) {
|
|
39758
|
-
const key = (0, import_node_crypto13.createHash)("sha256").update(
|
|
39759
|
-
return
|
|
39857
|
+
const key = (0, import_node_crypto13.createHash)("sha256").update(import_node_path20.default.resolve(cwd)).digest("hex").slice(0, 16);
|
|
39858
|
+
return import_node_path20.default.join(homeDir2, ".codeam", "conversation-active", `${key}.json`);
|
|
39760
39859
|
}
|
|
39761
39860
|
async function writeActiveConversationMarker(cwd, conversationId, homeDir2) {
|
|
39762
39861
|
try {
|
|
39763
39862
|
const file = markerPath3(cwd, homeDir2);
|
|
39764
|
-
await import_promises6.default.mkdir(
|
|
39863
|
+
await import_promises6.default.mkdir(import_node_path20.default.dirname(file), { recursive: true });
|
|
39765
39864
|
await import_promises6.default.writeFile(
|
|
39766
39865
|
file,
|
|
39767
39866
|
JSON.stringify({ conversationId, at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2) + "\n",
|
|
@@ -39781,27 +39880,27 @@ async function readActiveConversationMarker(cwd, homeDir2) {
|
|
|
39781
39880
|
}
|
|
39782
39881
|
|
|
39783
39882
|
// src/services/turn-marker.ts
|
|
39784
|
-
var
|
|
39883
|
+
var fs76 = __toESM(require("fs"));
|
|
39785
39884
|
var os55 = __toESM(require("os"));
|
|
39786
|
-
var
|
|
39885
|
+
var path87 = __toESM(require("path"));
|
|
39787
39886
|
var depth = 0;
|
|
39788
39887
|
function codeamHome() {
|
|
39789
|
-
return
|
|
39888
|
+
return path87.join(os55.homedir(), ".codeam");
|
|
39790
39889
|
}
|
|
39791
39890
|
function turnMarkerPath(pid = process.pid, home = codeamHome()) {
|
|
39792
|
-
return
|
|
39891
|
+
return path87.join(home, "turns", String(pid));
|
|
39793
39892
|
}
|
|
39794
39893
|
function mark() {
|
|
39795
39894
|
try {
|
|
39796
39895
|
const file = turnMarkerPath();
|
|
39797
|
-
|
|
39798
|
-
|
|
39896
|
+
fs76.mkdirSync(path87.dirname(file), { recursive: true });
|
|
39897
|
+
fs76.writeFileSync(file, String(Date.now()));
|
|
39799
39898
|
} catch {
|
|
39800
39899
|
}
|
|
39801
39900
|
}
|
|
39802
39901
|
function clear() {
|
|
39803
39902
|
try {
|
|
39804
|
-
|
|
39903
|
+
fs76.rmSync(turnMarkerPath(), { force: true });
|
|
39805
39904
|
} catch {
|
|
39806
39905
|
}
|
|
39807
39906
|
}
|
|
@@ -39816,7 +39915,7 @@ async function withTurnMarker(fn) {
|
|
|
39816
39915
|
function isProcessMidTurn(pid, home) {
|
|
39817
39916
|
if (!pid) return false;
|
|
39818
39917
|
try {
|
|
39819
|
-
return
|
|
39918
|
+
return fs76.existsSync(turnMarkerPath(pid, home));
|
|
39820
39919
|
} catch {
|
|
39821
39920
|
return false;
|
|
39822
39921
|
}
|
|
@@ -39824,8 +39923,8 @@ function isProcessMidTurn(pid, home) {
|
|
|
39824
39923
|
|
|
39825
39924
|
// src/packs/gates.ts
|
|
39826
39925
|
var import_node_child_process28 = require("child_process");
|
|
39827
|
-
var
|
|
39828
|
-
var
|
|
39926
|
+
var fs77 = __toESM(require("fs"));
|
|
39927
|
+
var path88 = __toESM(require("path"));
|
|
39829
39928
|
var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((resolve12) => {
|
|
39830
39929
|
(0, import_node_child_process28.execFile)(
|
|
39831
39930
|
file,
|
|
@@ -39875,7 +39974,7 @@ async function changedFiles(run3, cwd, from, to) {
|
|
|
39875
39974
|
}
|
|
39876
39975
|
function readWorkspaceFile(cwd, relPath) {
|
|
39877
39976
|
try {
|
|
39878
|
-
return
|
|
39977
|
+
return fs77.readFileSync(path88.join(cwd, relPath), "utf8");
|
|
39879
39978
|
} catch {
|
|
39880
39979
|
return null;
|
|
39881
39980
|
}
|
|
@@ -39884,14 +39983,14 @@ var NO_TEST_PLACEHOLDER = 'echo "Error: no test specified"';
|
|
|
39884
39983
|
var CHECKS_TIMEOUT_MS = 5 * 6e4;
|
|
39885
39984
|
function detectChecksCommand(cwd) {
|
|
39886
39985
|
try {
|
|
39887
|
-
const cfg = JSON.parse(
|
|
39986
|
+
const cfg = JSON.parse(fs77.readFileSync(path88.join(cwd, ".codeam", "pack.json"), "utf8"));
|
|
39888
39987
|
if (typeof cfg.checksCommand === "string" && cfg.checksCommand.trim().length > 0) {
|
|
39889
39988
|
return cfg.checksCommand.trim();
|
|
39890
39989
|
}
|
|
39891
39990
|
} catch {
|
|
39892
39991
|
}
|
|
39893
39992
|
try {
|
|
39894
|
-
const pkg = JSON.parse(
|
|
39993
|
+
const pkg = JSON.parse(fs77.readFileSync(path88.join(cwd, "package.json"), "utf8"));
|
|
39895
39994
|
const test = pkg.scripts?.test;
|
|
39896
39995
|
if (typeof test === "string" && test.trim().length > 0 && !test.includes(NO_TEST_PLACEHOLDER)) {
|
|
39897
39996
|
return "npm test";
|
|
@@ -39909,39 +40008,39 @@ ${res.stderr}`.trim();
|
|
|
39909
40008
|
}
|
|
39910
40009
|
|
|
39911
40010
|
// src/packs/run-store.ts
|
|
39912
|
-
var
|
|
39913
|
-
var
|
|
40011
|
+
var fs78 = __toESM(require("fs"));
|
|
40012
|
+
var path89 = __toESM(require("path"));
|
|
39914
40013
|
var crypto5 = __toESM(require("crypto"));
|
|
39915
40014
|
function packsDir(cwd) {
|
|
39916
|
-
return
|
|
40015
|
+
return path89.join(cwd, ".codeam", "packs");
|
|
39917
40016
|
}
|
|
39918
40017
|
function runDir(cwd, runId) {
|
|
39919
|
-
return
|
|
40018
|
+
return path89.join(packsDir(cwd), runId);
|
|
39920
40019
|
}
|
|
39921
40020
|
function newRunId() {
|
|
39922
40021
|
return `pk_${Date.now().toString(36)}_${crypto5.randomBytes(4).toString("hex")}`;
|
|
39923
40022
|
}
|
|
39924
40023
|
function writeJsonAtomic(file, value) {
|
|
39925
|
-
|
|
40024
|
+
fs78.mkdirSync(path89.dirname(file), { recursive: true });
|
|
39926
40025
|
const tmp = `${file}.tmp`;
|
|
39927
|
-
|
|
39928
|
-
|
|
40026
|
+
fs78.writeFileSync(tmp, JSON.stringify(value, null, 2));
|
|
40027
|
+
fs78.renameSync(tmp, file);
|
|
39929
40028
|
}
|
|
39930
40029
|
function saveRun(cwd, state) {
|
|
39931
|
-
writeJsonAtomic(
|
|
40030
|
+
writeJsonAtomic(path89.join(runDir(cwd, state.runId), "run.json"), state);
|
|
39932
40031
|
}
|
|
39933
40032
|
function saveStageHandoff(cwd, runId, stageIndex, role, handoff) {
|
|
39934
40033
|
const name = `${String(stageIndex + 1).padStart(2, "0")}-${role}.json`;
|
|
39935
|
-
writeJsonAtomic(
|
|
40034
|
+
writeJsonAtomic(path89.join(runDir(cwd, runId), name), handoff);
|
|
39936
40035
|
}
|
|
39937
40036
|
function loadLatestRun(cwd) {
|
|
39938
40037
|
try {
|
|
39939
40038
|
const dir = packsDir(cwd);
|
|
39940
|
-
const entries2 =
|
|
40039
|
+
const entries2 = fs78.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
39941
40040
|
for (let i = entries2.length - 1; i >= 0; i--) {
|
|
39942
|
-
const file =
|
|
40041
|
+
const file = path89.join(dir, entries2[i], "run.json");
|
|
39943
40042
|
try {
|
|
39944
|
-
const parsed = JSON.parse(
|
|
40043
|
+
const parsed = JSON.parse(fs78.readFileSync(file, "utf8"));
|
|
39945
40044
|
if (parsed && typeof parsed.runId === "string") return parsed;
|
|
39946
40045
|
} catch {
|
|
39947
40046
|
}
|
|
@@ -39952,17 +40051,17 @@ function loadLatestRun(cwd) {
|
|
|
39952
40051
|
}
|
|
39953
40052
|
function ensureLedgerIgnored(cwd) {
|
|
39954
40053
|
try {
|
|
39955
|
-
const gitDir =
|
|
39956
|
-
if (!
|
|
39957
|
-
const exclude =
|
|
40054
|
+
const gitDir = path89.join(cwd, ".git");
|
|
40055
|
+
if (!fs78.existsSync(gitDir)) return;
|
|
40056
|
+
const exclude = path89.join(gitDir, "info", "exclude");
|
|
39958
40057
|
let existing = "";
|
|
39959
40058
|
try {
|
|
39960
|
-
existing =
|
|
40059
|
+
existing = fs78.readFileSync(exclude, "utf8");
|
|
39961
40060
|
} catch {
|
|
39962
40061
|
}
|
|
39963
40062
|
if (existing.includes(".codeam/packs/")) return;
|
|
39964
|
-
|
|
39965
|
-
|
|
40063
|
+
fs78.mkdirSync(path89.dirname(exclude), { recursive: true });
|
|
40064
|
+
fs78.writeFileSync(exclude, `${existing.trimEnd()}
|
|
39966
40065
|
.codeam/packs/
|
|
39967
40066
|
`.trimStart());
|
|
39968
40067
|
} catch {
|
|
@@ -40739,15 +40838,15 @@ var packStatusH = async (ctx) => {
|
|
|
40739
40838
|
};
|
|
40740
40839
|
|
|
40741
40840
|
// src/integrations/manifest.ts
|
|
40742
|
-
var
|
|
40841
|
+
var import_node_fs19 = __toESM(require("fs"));
|
|
40743
40842
|
var import_node_os15 = __toESM(require("os"));
|
|
40744
|
-
var
|
|
40843
|
+
var import_node_path21 = __toESM(require("path"));
|
|
40745
40844
|
function integrationsManifestPath() {
|
|
40746
|
-
return
|
|
40845
|
+
return import_node_path21.default.join(import_node_os15.default.homedir(), ".codeam", "integrations.json");
|
|
40747
40846
|
}
|
|
40748
40847
|
function readIntegrationsManifest() {
|
|
40749
40848
|
try {
|
|
40750
|
-
const raw = JSON.parse(
|
|
40849
|
+
const raw = JSON.parse(import_node_fs19.default.readFileSync(integrationsManifestPath(), "utf8"));
|
|
40751
40850
|
if (!Array.isArray(raw?.integrations)) return null;
|
|
40752
40851
|
return raw;
|
|
40753
40852
|
} catch {
|
|
@@ -40757,10 +40856,10 @@ function readIntegrationsManifest() {
|
|
|
40757
40856
|
function persistIntegrationsManifest(m) {
|
|
40758
40857
|
try {
|
|
40759
40858
|
const file = integrationsManifestPath();
|
|
40760
|
-
|
|
40859
|
+
import_node_fs19.default.mkdirSync(import_node_path21.default.dirname(file), { recursive: true, mode: 448 });
|
|
40761
40860
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
40762
|
-
|
|
40763
|
-
|
|
40861
|
+
import_node_fs19.default.writeFileSync(tmp, JSON.stringify(m, null, 2), { encoding: "utf8", mode: 384 });
|
|
40862
|
+
import_node_fs19.default.renameSync(tmp, file);
|
|
40764
40863
|
restrictToOwner(file);
|
|
40765
40864
|
} catch (err) {
|
|
40766
40865
|
log.warn(
|
|
@@ -40771,7 +40870,7 @@ function persistIntegrationsManifest(m) {
|
|
|
40771
40870
|
}
|
|
40772
40871
|
function clearIntegrationsManifest() {
|
|
40773
40872
|
try {
|
|
40774
|
-
|
|
40873
|
+
import_node_fs19.default.rmSync(integrationsManifestPath(), { force: true });
|
|
40775
40874
|
} catch {
|
|
40776
40875
|
}
|
|
40777
40876
|
}
|
|
@@ -40943,20 +41042,20 @@ async function mcpRouter() {
|
|
|
40943
41042
|
}
|
|
40944
41043
|
|
|
40945
41044
|
// src/integrations/mcp-secrets.ts
|
|
40946
|
-
var
|
|
41045
|
+
var fs80 = __toESM(require("fs"));
|
|
40947
41046
|
var os57 = __toESM(require("os"));
|
|
40948
|
-
var
|
|
41047
|
+
var path91 = __toESM(require("path"));
|
|
40949
41048
|
var MCP_SECRETS_FILE_ENV = "CODEAM_MCP_SECRETS_FILE";
|
|
40950
41049
|
function mcpSecretsDir() {
|
|
40951
|
-
return
|
|
41050
|
+
return path91.join(os57.homedir(), ".codeam", "mcp-secrets");
|
|
40952
41051
|
}
|
|
40953
41052
|
function mcpSecretsPath(scope, pid = process.pid) {
|
|
40954
|
-
return
|
|
41053
|
+
return path91.join(mcpSecretsDir(), `${pid}-${scope}.json`);
|
|
40955
41054
|
}
|
|
40956
41055
|
var registeredForCleanup = /* @__PURE__ */ new Set();
|
|
40957
41056
|
function readFileVars(file) {
|
|
40958
41057
|
try {
|
|
40959
|
-
const parsed = JSON.parse(
|
|
41058
|
+
const parsed = JSON.parse(fs80.readFileSync(file, "utf8"));
|
|
40960
41059
|
if (!parsed || typeof parsed !== "object") return {};
|
|
40961
41060
|
const out2 = {};
|
|
40962
41061
|
for (const [k2, v] of Object.entries(parsed)) {
|
|
@@ -40978,7 +41077,7 @@ function pidAlive2(pid) {
|
|
|
40978
41077
|
function pruneStale(dir) {
|
|
40979
41078
|
let names = [];
|
|
40980
41079
|
try {
|
|
40981
|
-
names =
|
|
41080
|
+
names = fs80.readdirSync(dir);
|
|
40982
41081
|
} catch {
|
|
40983
41082
|
return;
|
|
40984
41083
|
}
|
|
@@ -40988,25 +41087,25 @@ function pruneStale(dir) {
|
|
|
40988
41087
|
const pid = Number(m[1]);
|
|
40989
41088
|
if (pid === process.pid || pidAlive2(pid)) continue;
|
|
40990
41089
|
try {
|
|
40991
|
-
|
|
41090
|
+
fs80.unlinkSync(path91.join(dir, name));
|
|
40992
41091
|
} catch {
|
|
40993
41092
|
}
|
|
40994
41093
|
}
|
|
40995
41094
|
}
|
|
40996
41095
|
function writeMcpSecrets(vars, file) {
|
|
40997
41096
|
try {
|
|
40998
|
-
const dir =
|
|
40999
|
-
|
|
41097
|
+
const dir = path91.dirname(file);
|
|
41098
|
+
fs80.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
41000
41099
|
pruneStale(dir);
|
|
41001
41100
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
41002
|
-
|
|
41003
|
-
|
|
41004
|
-
|
|
41101
|
+
fs80.writeFileSync(tmp, JSON.stringify(vars), { mode: 384 });
|
|
41102
|
+
fs80.renameSync(tmp, file);
|
|
41103
|
+
fs80.chmodSync(file, 384);
|
|
41005
41104
|
if (!registeredForCleanup.has(file)) {
|
|
41006
41105
|
registeredForCleanup.add(file);
|
|
41007
41106
|
process.once("exit", () => {
|
|
41008
41107
|
try {
|
|
41009
|
-
|
|
41108
|
+
fs80.unlinkSync(file);
|
|
41010
41109
|
} catch {
|
|
41011
41110
|
}
|
|
41012
41111
|
});
|
|
@@ -41092,11 +41191,11 @@ function previewMcpServer(bridge) {
|
|
|
41092
41191
|
};
|
|
41093
41192
|
}
|
|
41094
41193
|
function httpCall(baseUrl, token) {
|
|
41095
|
-
return async (
|
|
41194
|
+
return async (path109, method, body, timeoutMs) => {
|
|
41096
41195
|
const ac = new AbortController();
|
|
41097
41196
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
41098
41197
|
try {
|
|
41099
|
-
const res = await fetch(`${baseUrl}${
|
|
41198
|
+
const res = await fetch(`${baseUrl}${path109}`, {
|
|
41100
41199
|
method,
|
|
41101
41200
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
41102
41201
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -41201,6 +41300,7 @@ var SCRATCH_TOOLS = [
|
|
|
41201
41300
|
description: [
|
|
41202
41301
|
"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
41302
|
"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.",
|
|
41303
|
+
"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
41304
|
'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
41305
|
"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
41306
|
].join(" "),
|
|
@@ -41223,11 +41323,11 @@ function scratchMcpServer(bridge) {
|
|
|
41223
41323
|
};
|
|
41224
41324
|
}
|
|
41225
41325
|
function httpCall2(baseUrl, token) {
|
|
41226
|
-
return async (
|
|
41326
|
+
return async (path109, method, body, timeoutMs) => {
|
|
41227
41327
|
const ac = new AbortController();
|
|
41228
41328
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
41229
41329
|
try {
|
|
41230
|
-
const res = await fetch(`${baseUrl}${
|
|
41330
|
+
const res = await fetch(`${baseUrl}${path109}`, {
|
|
41231
41331
|
method,
|
|
41232
41332
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
41233
41333
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -41353,12 +41453,12 @@ function buildIntegrationMcpServers(ctx) {
|
|
|
41353
41453
|
}
|
|
41354
41454
|
|
|
41355
41455
|
// src/services/local-mcp-servers.ts
|
|
41356
|
-
var
|
|
41456
|
+
var import_node_fs20 = __toESM(require("fs"));
|
|
41357
41457
|
var import_node_os16 = __toESM(require("os"));
|
|
41358
|
-
var
|
|
41458
|
+
var import_node_path22 = __toESM(require("path"));
|
|
41359
41459
|
var MAX_LOCAL_MCP_SERVERS = 10;
|
|
41360
41460
|
function localMcpServersPath() {
|
|
41361
|
-
return
|
|
41461
|
+
return import_node_path22.default.join(import_node_os16.default.homedir(), ".codeam", "mcp-servers.json");
|
|
41362
41462
|
}
|
|
41363
41463
|
function isStringArray(v) {
|
|
41364
41464
|
return Array.isArray(v) && v.every((item) => typeof item === "string");
|
|
@@ -41376,7 +41476,7 @@ function isValidEntry(entry) {
|
|
|
41376
41476
|
function readLocalMcpServers() {
|
|
41377
41477
|
let raw;
|
|
41378
41478
|
try {
|
|
41379
|
-
raw =
|
|
41479
|
+
raw = import_node_fs20.default.readFileSync(localMcpServersPath(), "utf8");
|
|
41380
41480
|
} catch {
|
|
41381
41481
|
return [];
|
|
41382
41482
|
}
|
|
@@ -41767,11 +41867,11 @@ function readJson(req) {
|
|
|
41767
41867
|
var agentPreviewBridge = new AgentPreviewBridge();
|
|
41768
41868
|
|
|
41769
41869
|
// src/integrations/detect-stack.ts
|
|
41770
|
-
var
|
|
41771
|
-
var
|
|
41870
|
+
var import_node_fs21 = __toESM(require("fs"));
|
|
41871
|
+
var import_node_path23 = __toESM(require("path"));
|
|
41772
41872
|
function readSafe(cwd, rel) {
|
|
41773
41873
|
try {
|
|
41774
|
-
return
|
|
41874
|
+
return import_node_fs21.default.readFileSync(import_node_path23.default.join(cwd, rel), "utf8");
|
|
41775
41875
|
} catch {
|
|
41776
41876
|
return "";
|
|
41777
41877
|
}
|
|
@@ -42419,6 +42519,9 @@ async function startTaskH(ctx) {
|
|
|
42419
42519
|
`start_task \u2190 done stopReason=${reply.stopReason ?? "?"} id=${cmd.id.slice(0, 8)}`
|
|
42420
42520
|
);
|
|
42421
42521
|
await relay.sendResult(cmd.id, "completed", { stopReason: reply.stopReason });
|
|
42522
|
+
if (reply.stopReason === "end_turn" && maybeAutoOpenScratchPreview(opts.sessionId, agentPreviewBridge)) {
|
|
42523
|
+
log.info("acpRunner", "scratch: turn left a servable project and no preview \u2014 opening it");
|
|
42524
|
+
}
|
|
42422
42525
|
return;
|
|
42423
42526
|
}
|
|
42424
42527
|
} catch (err) {
|
|
@@ -44127,19 +44230,20 @@ async function runAcpSession(opts) {
|
|
|
44127
44230
|
switchCredentialEnv = provisionAgentCredentials(agentId, auth);
|
|
44128
44231
|
},
|
|
44129
44232
|
provisionHouseProxy: ({ baseUrl, token, model, managedAgentId }) => {
|
|
44130
|
-
const claudeConfigDir2 =
|
|
44233
|
+
const claudeConfigDir2 = path94.join(
|
|
44131
44234
|
os59.homedir(),
|
|
44132
44235
|
".codeam",
|
|
44133
44236
|
"house-claude",
|
|
44134
44237
|
`switch-${opts.pluginId}`
|
|
44135
44238
|
);
|
|
44136
44239
|
try {
|
|
44137
|
-
|
|
44240
|
+
fs83.mkdirSync(claudeConfigDir2, { recursive: true, mode: 448 });
|
|
44138
44241
|
} catch {
|
|
44139
44242
|
}
|
|
44140
|
-
const memoryFile =
|
|
44243
|
+
const memoryFile = path94.join(claudeConfigDir2, "CLAUDE.md");
|
|
44141
44244
|
ensureBeadsWorkflowHint(void 0, memoryFile);
|
|
44142
44245
|
ensureAgentStandard(void 0, memoryFile);
|
|
44246
|
+
if (isScratchWorkspace(process.cwd())) ensureScratchWorkflowHint(void 0, memoryFile);
|
|
44143
44247
|
const cfg = {
|
|
44144
44248
|
baseUrl,
|
|
44145
44249
|
token,
|
|
@@ -45352,45 +45456,6 @@ function startClaudeCredentialSync(opts) {
|
|
|
45352
45456
|
};
|
|
45353
45457
|
}
|
|
45354
45458
|
|
|
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
45459
|
// src/commands/start/pick-session.ts
|
|
45395
45460
|
function pickPinnedSession(pinnedId, listSessions2) {
|
|
45396
45461
|
const id = pinnedId?.trim();
|
|
@@ -45406,8 +45471,8 @@ function pickPinnedSession(pinnedId, listSessions2) {
|
|
|
45406
45471
|
}
|
|
45407
45472
|
|
|
45408
45473
|
// src/agents/retired-proxy-cleanup.ts
|
|
45409
|
-
var
|
|
45410
|
-
var
|
|
45474
|
+
var fs84 = __toESM(require("fs"));
|
|
45475
|
+
var path95 = __toESM(require("path"));
|
|
45411
45476
|
var os60 = __toESM(require("os"));
|
|
45412
45477
|
var RETIRED_PROXY_RE = /^https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):8787(?:[/?#]|$)/i;
|
|
45413
45478
|
var HEADROOM_CMD_RE = /(^|[\s/"'])headroom(\s|$)/i;
|
|
@@ -45419,10 +45484,10 @@ function isHeadroomHook(group) {
|
|
|
45419
45484
|
}
|
|
45420
45485
|
function sanitizeRetiredProxyConfig(homeDir2 = os60.homedir()) {
|
|
45421
45486
|
const out2 = { inspected: false, changed: false, removed: [] };
|
|
45422
|
-
const file =
|
|
45487
|
+
const file = path95.join(homeDir2, ".claude", "settings.json");
|
|
45423
45488
|
let parsed;
|
|
45424
45489
|
try {
|
|
45425
|
-
parsed = JSON.parse(
|
|
45490
|
+
parsed = JSON.parse(fs84.readFileSync(file, "utf8"));
|
|
45426
45491
|
} catch {
|
|
45427
45492
|
return out2;
|
|
45428
45493
|
}
|
|
@@ -45464,9 +45529,9 @@ function sanitizeRetiredProxyConfig(homeDir2 = os60.homedir()) {
|
|
|
45464
45529
|
if (!out2.changed) return out2;
|
|
45465
45530
|
try {
|
|
45466
45531
|
const tmp = `${file}.codeam.tmp`;
|
|
45467
|
-
|
|
45532
|
+
fs84.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
|
|
45468
45533
|
`, { mode: 384 });
|
|
45469
|
-
|
|
45534
|
+
fs84.renameSync(tmp, file);
|
|
45470
45535
|
} catch {
|
|
45471
45536
|
out2.changed = false;
|
|
45472
45537
|
}
|
|
@@ -45998,7 +46063,7 @@ var AcpDriver = class {
|
|
|
45998
46063
|
};
|
|
45999
46064
|
|
|
46000
46065
|
// src/baton/transcript-mirror.ts
|
|
46001
|
-
var
|
|
46066
|
+
var fs85 = __toESM(require("fs"));
|
|
46002
46067
|
var TranscriptMirror = class {
|
|
46003
46068
|
constructor(deps) {
|
|
46004
46069
|
this.deps = deps;
|
|
@@ -46092,7 +46157,7 @@ var TranscriptMirror = class {
|
|
|
46092
46157
|
}
|
|
46093
46158
|
};
|
|
46094
46159
|
function defaultWatch(file, onChange) {
|
|
46095
|
-
const w3 =
|
|
46160
|
+
const w3 = fs85.watch(file, { persistent: false }, () => onChange());
|
|
46096
46161
|
return () => w3.close();
|
|
46097
46162
|
}
|
|
46098
46163
|
|
|
@@ -46438,16 +46503,16 @@ function keepDeviceAwake(deps = {}) {
|
|
|
46438
46503
|
}
|
|
46439
46504
|
|
|
46440
46505
|
// src/agents/claude/onboarding.ts
|
|
46441
|
-
var
|
|
46506
|
+
var fs86 = __toESM(require("fs"));
|
|
46442
46507
|
var os62 = __toESM(require("os"));
|
|
46443
|
-
var
|
|
46508
|
+
var path96 = __toESM(require("path"));
|
|
46444
46509
|
var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
|
|
46445
46510
|
function ensureClaudeOnboarded(cwd) {
|
|
46446
46511
|
try {
|
|
46447
|
-
const file =
|
|
46512
|
+
const file = path96.join(os62.homedir(), ".claude.json");
|
|
46448
46513
|
let config = {};
|
|
46449
46514
|
try {
|
|
46450
|
-
config = JSON.parse(
|
|
46515
|
+
config = JSON.parse(fs86.readFileSync(file, "utf8"));
|
|
46451
46516
|
} catch {
|
|
46452
46517
|
}
|
|
46453
46518
|
let changed = false;
|
|
@@ -46472,8 +46537,8 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
46472
46537
|
}
|
|
46473
46538
|
}
|
|
46474
46539
|
if (!changed) return;
|
|
46475
|
-
|
|
46476
|
-
|
|
46540
|
+
fs86.mkdirSync(path96.dirname(file), { recursive: true });
|
|
46541
|
+
fs86.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
46477
46542
|
log.info(
|
|
46478
46543
|
"claude",
|
|
46479
46544
|
`pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
|
|
@@ -47265,7 +47330,7 @@ var import_picocolors10 = __toESM(require("picocolors"));
|
|
|
47265
47330
|
var import_child_process30 = require("child_process");
|
|
47266
47331
|
var import_util4 = require("util");
|
|
47267
47332
|
var import_picocolors8 = __toESM(require("picocolors"));
|
|
47268
|
-
var
|
|
47333
|
+
var path97 = __toESM(require("path"));
|
|
47269
47334
|
var execFileP6 = (0, import_util4.promisify)(import_child_process30.execFile);
|
|
47270
47335
|
var MAX_BUFFER = 8 * 1024 * 1024;
|
|
47271
47336
|
function resetStdinForChild() {
|
|
@@ -47754,7 +47819,7 @@ var GitHubCodespacesProvider = class {
|
|
|
47754
47819
|
});
|
|
47755
47820
|
}
|
|
47756
47821
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
47757
|
-
const remoteDir =
|
|
47822
|
+
const remoteDir = path97.posix.dirname(remotePath);
|
|
47758
47823
|
const parts = [
|
|
47759
47824
|
`mkdir -p ${shellQuote(remoteDir)}`,
|
|
47760
47825
|
`cat > ${shellQuote(remotePath)}`
|
|
@@ -47824,7 +47889,7 @@ function shellQuote(s) {
|
|
|
47824
47889
|
// src/services/providers/gitpod.ts
|
|
47825
47890
|
var import_child_process31 = require("child_process");
|
|
47826
47891
|
var import_util5 = require("util");
|
|
47827
|
-
var
|
|
47892
|
+
var path98 = __toESM(require("path"));
|
|
47828
47893
|
var import_picocolors9 = __toESM(require("picocolors"));
|
|
47829
47894
|
var execFileP7 = (0, import_util5.promisify)(import_child_process31.execFile);
|
|
47830
47895
|
var MAX_BUFFER2 = 8 * 1024 * 1024;
|
|
@@ -48064,7 +48129,7 @@ var GitpodProvider = class {
|
|
|
48064
48129
|
});
|
|
48065
48130
|
}
|
|
48066
48131
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
48067
|
-
const remoteDir =
|
|
48132
|
+
const remoteDir = path98.posix.dirname(remotePath);
|
|
48068
48133
|
const parts = [
|
|
48069
48134
|
`mkdir -p ${shellQuote2(remoteDir)}`,
|
|
48070
48135
|
`cat > ${shellQuote2(remotePath)}`
|
|
@@ -48100,7 +48165,7 @@ function shellQuote2(s) {
|
|
|
48100
48165
|
// src/services/providers/gitlab-workspaces.ts
|
|
48101
48166
|
var import_child_process32 = require("child_process");
|
|
48102
48167
|
var import_util6 = require("util");
|
|
48103
|
-
var
|
|
48168
|
+
var path99 = __toESM(require("path"));
|
|
48104
48169
|
var execFileP8 = (0, import_util6.promisify)(import_child_process32.execFile);
|
|
48105
48170
|
var MAX_BUFFER3 = 8 * 1024 * 1024;
|
|
48106
48171
|
var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
|
|
@@ -48360,7 +48425,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48360
48425
|
}
|
|
48361
48426
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
48362
48427
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
48363
|
-
const remoteDir =
|
|
48428
|
+
const remoteDir = path99.posix.dirname(remotePath);
|
|
48364
48429
|
const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
|
|
48365
48430
|
if (options.mode != null) {
|
|
48366
48431
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
@@ -48428,7 +48493,7 @@ function shellQuote3(s) {
|
|
|
48428
48493
|
// src/services/providers/railway.ts
|
|
48429
48494
|
var import_child_process33 = require("child_process");
|
|
48430
48495
|
var import_util7 = require("util");
|
|
48431
|
-
var
|
|
48496
|
+
var path100 = __toESM(require("path"));
|
|
48432
48497
|
var execFileP9 = (0, import_util7.promisify)(import_child_process33.execFile);
|
|
48433
48498
|
var MAX_BUFFER4 = 8 * 1024 * 1024;
|
|
48434
48499
|
function resetStdinForChild4() {
|
|
@@ -48664,7 +48729,7 @@ var RailwayProvider = class {
|
|
|
48664
48729
|
if (!projectId || !serviceId) {
|
|
48665
48730
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
48666
48731
|
}
|
|
48667
|
-
const remoteDir =
|
|
48732
|
+
const remoteDir = path100.posix.dirname(remotePath);
|
|
48668
48733
|
const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
|
|
48669
48734
|
if (options.mode != null) {
|
|
48670
48735
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
@@ -49204,9 +49269,9 @@ async function stopWorkspaceFromLocal(target) {
|
|
|
49204
49269
|
}
|
|
49205
49270
|
|
|
49206
49271
|
// src/commands/host/host-client.ts
|
|
49207
|
-
var
|
|
49272
|
+
var fs87 = __toESM(require("fs"));
|
|
49208
49273
|
var os63 = __toESM(require("os"));
|
|
49209
|
-
var
|
|
49274
|
+
var path101 = __toESM(require("path"));
|
|
49210
49275
|
var import_node_crypto16 = require("crypto");
|
|
49211
49276
|
function sampleCpuTimes() {
|
|
49212
49277
|
let idle = 0;
|
|
@@ -49255,7 +49320,7 @@ function apiBase() {
|
|
|
49255
49320
|
return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
|
|
49256
49321
|
}
|
|
49257
49322
|
function hostIdentityPath() {
|
|
49258
|
-
return
|
|
49323
|
+
return path101.join(os63.homedir(), ".codeam", "host-agent.json");
|
|
49259
49324
|
}
|
|
49260
49325
|
function collectOsInfo() {
|
|
49261
49326
|
return {
|
|
@@ -49267,7 +49332,7 @@ function collectOsInfo() {
|
|
|
49267
49332
|
}
|
|
49268
49333
|
function loadHostIdentity() {
|
|
49269
49334
|
try {
|
|
49270
|
-
const raw =
|
|
49335
|
+
const raw = fs87.readFileSync(hostIdentityPath(), "utf8");
|
|
49271
49336
|
const parsed = JSON.parse(raw);
|
|
49272
49337
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
|
|
49273
49338
|
const p2 = parsed;
|
|
@@ -49295,8 +49360,8 @@ function ensureControlPollSecret(identity, save = saveHostIdentity) {
|
|
|
49295
49360
|
}
|
|
49296
49361
|
function saveHostIdentity(identity) {
|
|
49297
49362
|
const file = hostIdentityPath();
|
|
49298
|
-
|
|
49299
|
-
|
|
49363
|
+
fs87.mkdirSync(path101.dirname(file), { recursive: true, mode: 448 });
|
|
49364
|
+
fs87.writeFileSync(file, JSON.stringify(identity, null, 2), {
|
|
49300
49365
|
encoding: "utf8",
|
|
49301
49366
|
mode: 384
|
|
49302
49367
|
});
|
|
@@ -49341,7 +49406,7 @@ function isTerminalEnrollError(err) {
|
|
|
49341
49406
|
}
|
|
49342
49407
|
function deleteHostIdentity() {
|
|
49343
49408
|
try {
|
|
49344
|
-
|
|
49409
|
+
fs87.rmSync(hostIdentityPath(), { force: true });
|
|
49345
49410
|
} catch {
|
|
49346
49411
|
}
|
|
49347
49412
|
}
|
|
@@ -49559,8 +49624,8 @@ async function host(args2) {
|
|
|
49559
49624
|
// src/commands/host-agent.ts
|
|
49560
49625
|
var import_node_child_process35 = require("child_process");
|
|
49561
49626
|
var os67 = __toESM(require("os"));
|
|
49562
|
-
var
|
|
49563
|
-
var
|
|
49627
|
+
var fs91 = __toESM(require("fs"));
|
|
49628
|
+
var path105 = __toESM(require("path"));
|
|
49564
49629
|
|
|
49565
49630
|
// src/skills/persist-from-payload.ts
|
|
49566
49631
|
function persistOrClearSkillsFromPayload(skills) {
|
|
@@ -49569,13 +49634,13 @@ function persistOrClearSkillsFromPayload(skills) {
|
|
|
49569
49634
|
}
|
|
49570
49635
|
|
|
49571
49636
|
// src/commands/host/session-state.ts
|
|
49572
|
-
var
|
|
49637
|
+
var fs88 = __toESM(require("fs"));
|
|
49573
49638
|
var os64 = __toESM(require("os"));
|
|
49574
|
-
var
|
|
49639
|
+
var path102 = __toESM(require("path"));
|
|
49575
49640
|
function hostSessionStatePath(env = process.env) {
|
|
49576
49641
|
const override = env.CODEAM_HOST_SESSION_STATE_FILE;
|
|
49577
49642
|
if (override && override.trim()) return override.trim();
|
|
49578
|
-
return
|
|
49643
|
+
return path102.join(os64.homedir(), ".codeam", "host-agent-sessions.json");
|
|
49579
49644
|
}
|
|
49580
49645
|
function isRecord5(v) {
|
|
49581
49646
|
if (typeof v !== "object" || v === null) return false;
|
|
@@ -49586,7 +49651,7 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
49586
49651
|
return {
|
|
49587
49652
|
load() {
|
|
49588
49653
|
try {
|
|
49589
|
-
const raw = JSON.parse(
|
|
49654
|
+
const raw = JSON.parse(fs88.readFileSync(file, "utf8"));
|
|
49590
49655
|
return Array.isArray(raw?.sessions) ? raw.sessions.filter(isRecord5) : null;
|
|
49591
49656
|
} catch {
|
|
49592
49657
|
return null;
|
|
@@ -49594,18 +49659,18 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
49594
49659
|
},
|
|
49595
49660
|
save(list) {
|
|
49596
49661
|
try {
|
|
49597
|
-
|
|
49662
|
+
fs88.mkdirSync(path102.dirname(file), { recursive: true, mode: 448 });
|
|
49598
49663
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
49599
|
-
|
|
49664
|
+
fs88.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
|
|
49600
49665
|
mode: 384
|
|
49601
49666
|
});
|
|
49602
|
-
|
|
49667
|
+
fs88.renameSync(tmp, file);
|
|
49603
49668
|
} catch {
|
|
49604
49669
|
}
|
|
49605
49670
|
},
|
|
49606
49671
|
clear() {
|
|
49607
49672
|
try {
|
|
49608
|
-
|
|
49673
|
+
fs88.rmSync(file, { force: true });
|
|
49609
49674
|
} catch {
|
|
49610
49675
|
}
|
|
49611
49676
|
}
|
|
@@ -49628,10 +49693,10 @@ function planSessionResume(records, max) {
|
|
|
49628
49693
|
return { resume: ordered.slice(0, bound), dropped: ordered.slice(bound) };
|
|
49629
49694
|
}
|
|
49630
49695
|
function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
49631
|
-
const target =
|
|
49696
|
+
const target = path102.resolve(cwd);
|
|
49632
49697
|
const reconnectable = (s) => !!s.pluginId && !!s.pollSecret && !!s.agent;
|
|
49633
49698
|
const matches = sessions3.filter(
|
|
49634
|
-
(s) => !!s.cwd &&
|
|
49699
|
+
(s) => !!s.cwd && path102.resolve(s.cwd) === target && reconnectable(s)
|
|
49635
49700
|
);
|
|
49636
49701
|
if (matches.length > 0) {
|
|
49637
49702
|
matches.sort((a, b) => b.pairedAt - a.pairedAt);
|
|
@@ -49643,11 +49708,11 @@ function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
|
49643
49708
|
|
|
49644
49709
|
// src/commands/host/git-tooling.ts
|
|
49645
49710
|
var import_node_child_process31 = require("child_process");
|
|
49646
|
-
var
|
|
49711
|
+
var fs89 = __toESM(require("fs"));
|
|
49647
49712
|
var os65 = __toESM(require("os"));
|
|
49648
|
-
var
|
|
49713
|
+
var path103 = __toESM(require("path"));
|
|
49649
49714
|
function codeamBinDir() {
|
|
49650
|
-
return process.env.CODEAM_BIN_DIR ??
|
|
49715
|
+
return process.env.CODEAM_BIN_DIR ?? path103.join(os65.homedir(), ".codeam", "bin");
|
|
49651
49716
|
}
|
|
49652
49717
|
var FALLBACK_GH_VERSION = "2.62.0";
|
|
49653
49718
|
var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
|
|
@@ -49679,7 +49744,7 @@ async function download(url2, dest) {
|
|
|
49679
49744
|
const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
|
|
49680
49745
|
if (!res.ok || !res.body) return false;
|
|
49681
49746
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
49682
|
-
|
|
49747
|
+
fs89.writeFileSync(dest, buf);
|
|
49683
49748
|
return true;
|
|
49684
49749
|
} catch {
|
|
49685
49750
|
return false;
|
|
@@ -49702,8 +49767,8 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
49702
49767
|
const version3 = await resolveVersionFn(token);
|
|
49703
49768
|
const asset = `gh_${version3}_${osToken}_${arch2}`;
|
|
49704
49769
|
const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
|
|
49705
|
-
const tmpRoot =
|
|
49706
|
-
const archive =
|
|
49770
|
+
const tmpRoot = fs89.mkdtempSync(path103.join(os65.tmpdir(), "codeam-gh-"));
|
|
49771
|
+
const archive = path103.join(tmpRoot, `${asset}.${ext}`);
|
|
49707
49772
|
if (!await downloadFn(url2, archive)) {
|
|
49708
49773
|
log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
|
|
49709
49774
|
return null;
|
|
@@ -49713,16 +49778,16 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
49713
49778
|
log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
|
|
49714
49779
|
return null;
|
|
49715
49780
|
}
|
|
49716
|
-
const extractedBin =
|
|
49717
|
-
if (!
|
|
49781
|
+
const extractedBin = path103.join(tmpRoot, asset, "bin", binaryName);
|
|
49782
|
+
if (!fs89.existsSync(extractedBin)) {
|
|
49718
49783
|
log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
|
|
49719
49784
|
return null;
|
|
49720
49785
|
}
|
|
49721
49786
|
const binDir = codeamBinDir();
|
|
49722
|
-
|
|
49723
|
-
const target =
|
|
49724
|
-
|
|
49725
|
-
|
|
49787
|
+
fs89.mkdirSync(binDir, { recursive: true });
|
|
49788
|
+
const target = path103.join(binDir, binaryName);
|
|
49789
|
+
fs89.copyFileSync(extractedBin, target);
|
|
49790
|
+
fs89.chmodSync(target, 493);
|
|
49726
49791
|
log.info("host-agent", `gh installed to ${target} (v${version3})`);
|
|
49727
49792
|
return target;
|
|
49728
49793
|
} catch (e) {
|
|
@@ -49759,19 +49824,19 @@ async function ensureGhAuth(runner, ghCmd, token) {
|
|
|
49759
49824
|
}
|
|
49760
49825
|
function ghConfigDir() {
|
|
49761
49826
|
if (process.env.GH_CONFIG_DIR) return process.env.GH_CONFIG_DIR;
|
|
49762
|
-
if (process.env.XDG_CONFIG_HOME) return
|
|
49827
|
+
if (process.env.XDG_CONFIG_HOME) return path103.join(process.env.XDG_CONFIG_HOME, "gh");
|
|
49763
49828
|
if (process.platform === "win32" && process.env.APPDATA) {
|
|
49764
|
-
return
|
|
49829
|
+
return path103.join(process.env.APPDATA, "GitHub CLI");
|
|
49765
49830
|
}
|
|
49766
|
-
return
|
|
49831
|
+
return path103.join(os65.homedir(), ".config", "gh");
|
|
49767
49832
|
}
|
|
49768
49833
|
function writeGhHostsToken(token) {
|
|
49769
49834
|
try {
|
|
49770
49835
|
const dir = ghConfigDir();
|
|
49771
|
-
const file =
|
|
49772
|
-
if (
|
|
49773
|
-
|
|
49774
|
-
|
|
49836
|
+
const file = path103.join(dir, "hosts.yml");
|
|
49837
|
+
if (fs89.existsSync(file)) return false;
|
|
49838
|
+
fs89.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
49839
|
+
fs89.writeFileSync(
|
|
49775
49840
|
file,
|
|
49776
49841
|
`github.com:
|
|
49777
49842
|
oauth_token: ${token}
|
|
@@ -49814,8 +49879,8 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
49814
49879
|
const version3 = await resolveLatestGlabVersion();
|
|
49815
49880
|
const asset = `glab_${version3}_${osToken}_${arch2}`;
|
|
49816
49881
|
const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
|
|
49817
|
-
const tmpRoot =
|
|
49818
|
-
const archive =
|
|
49882
|
+
const tmpRoot = fs89.mkdtempSync(path103.join(os65.tmpdir(), "codeam-glab-"));
|
|
49883
|
+
const archive = path103.join(tmpRoot, `${asset}.${ext}`);
|
|
49819
49884
|
if (!await downloadFn(url2, archive)) {
|
|
49820
49885
|
log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
|
|
49821
49886
|
return null;
|
|
@@ -49826,20 +49891,20 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
49826
49891
|
return null;
|
|
49827
49892
|
}
|
|
49828
49893
|
const candidates = [
|
|
49829
|
-
|
|
49830
|
-
|
|
49831
|
-
|
|
49894
|
+
path103.join(tmpRoot, "bin", binaryName),
|
|
49895
|
+
path103.join(tmpRoot, asset, "bin", binaryName),
|
|
49896
|
+
path103.join(tmpRoot, binaryName)
|
|
49832
49897
|
];
|
|
49833
|
-
const extractedBin = candidates.find((c2) =>
|
|
49898
|
+
const extractedBin = candidates.find((c2) => fs89.existsSync(c2));
|
|
49834
49899
|
if (!extractedBin) {
|
|
49835
49900
|
log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
|
|
49836
49901
|
return null;
|
|
49837
49902
|
}
|
|
49838
49903
|
const binDir = codeamBinDir();
|
|
49839
|
-
|
|
49840
|
-
const target =
|
|
49841
|
-
|
|
49842
|
-
|
|
49904
|
+
fs89.mkdirSync(binDir, { recursive: true });
|
|
49905
|
+
const target = path103.join(binDir, binaryName);
|
|
49906
|
+
fs89.copyFileSync(extractedBin, target);
|
|
49907
|
+
fs89.chmodSync(target, 493);
|
|
49843
49908
|
log.info("host-agent", `glab installed to ${target} (v${version3})`);
|
|
49844
49909
|
return target;
|
|
49845
49910
|
} catch (e) {
|
|
@@ -49921,9 +49986,9 @@ var defaultGitToolingRunner = {
|
|
|
49921
49986
|
var import_node_child_process33 = require("child_process");
|
|
49922
49987
|
|
|
49923
49988
|
// src/lib/updateNotifier.ts
|
|
49924
|
-
var
|
|
49989
|
+
var fs90 = __toESM(require("fs"));
|
|
49925
49990
|
var os66 = __toESM(require("os"));
|
|
49926
|
-
var
|
|
49991
|
+
var path104 = __toESM(require("path"));
|
|
49927
49992
|
var https8 = __toESM(require("https"));
|
|
49928
49993
|
var import_node_child_process32 = require("child_process");
|
|
49929
49994
|
var import_picocolors12 = __toESM(require("picocolors"));
|
|
@@ -49932,12 +49997,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
|
|
|
49932
49997
|
var TTL_MS = 24 * 60 * 60 * 1e3;
|
|
49933
49998
|
var REQUEST_TIMEOUT_MS = 1500;
|
|
49934
49999
|
function cachePath() {
|
|
49935
|
-
const dir =
|
|
49936
|
-
return
|
|
50000
|
+
const dir = path104.join(os66.homedir(), ".codeam");
|
|
50001
|
+
return path104.join(dir, "update-check.json");
|
|
49937
50002
|
}
|
|
49938
50003
|
function readCache() {
|
|
49939
50004
|
try {
|
|
49940
|
-
const raw =
|
|
50005
|
+
const raw = fs90.readFileSync(cachePath(), "utf8");
|
|
49941
50006
|
const parsed = JSON.parse(raw);
|
|
49942
50007
|
if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
|
|
49943
50008
|
return parsed;
|
|
@@ -49948,10 +50013,10 @@ function readCache() {
|
|
|
49948
50013
|
function writeCache(cache) {
|
|
49949
50014
|
try {
|
|
49950
50015
|
const file = cachePath();
|
|
49951
|
-
|
|
50016
|
+
fs90.mkdirSync(path104.dirname(file), { recursive: true });
|
|
49952
50017
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
49953
|
-
|
|
49954
|
-
|
|
50018
|
+
fs90.writeFileSync(tmp, JSON.stringify(cache));
|
|
50019
|
+
fs90.renameSync(tmp, file);
|
|
49955
50020
|
} catch {
|
|
49956
50021
|
}
|
|
49957
50022
|
}
|
|
@@ -50025,8 +50090,8 @@ function isLinkedInstall() {
|
|
|
50025
50090
|
timeout: 2e3
|
|
50026
50091
|
}).trim();
|
|
50027
50092
|
if (!root) return false;
|
|
50028
|
-
const pkgPath =
|
|
50029
|
-
return
|
|
50093
|
+
const pkgPath = path104.join(root, PKG_NAME);
|
|
50094
|
+
return fs90.lstatSync(pkgPath).isSymbolicLink();
|
|
50030
50095
|
} catch {
|
|
50031
50096
|
return false;
|
|
50032
50097
|
}
|
|
@@ -50062,7 +50127,7 @@ function maybeAutoUpdate(currentVersion, latest) {
|
|
|
50062
50127
|
return;
|
|
50063
50128
|
}
|
|
50064
50129
|
try {
|
|
50065
|
-
|
|
50130
|
+
fs90.unlinkSync(cachePath());
|
|
50066
50131
|
} catch {
|
|
50067
50132
|
}
|
|
50068
50133
|
process.stderr.write(` ${import_picocolors12.default.green("\u2713")} Updated. Resuming session...
|
|
@@ -50078,7 +50143,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
50078
50143
|
if (process.env.NODE_ENV === "test") return;
|
|
50079
50144
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
50080
50145
|
if (process.env.CI) return;
|
|
50081
|
-
const current2 = true ? "2.76.
|
|
50146
|
+
const current2 = true ? "2.76.9" : null;
|
|
50082
50147
|
if (!current2) return;
|
|
50083
50148
|
const cache = readCache();
|
|
50084
50149
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -50095,7 +50160,7 @@ function checkForUpdates() {
|
|
|
50095
50160
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
50096
50161
|
if (process.env.CI) return;
|
|
50097
50162
|
if (!process.stdout.isTTY) return;
|
|
50098
|
-
const current2 = true ? "2.76.
|
|
50163
|
+
const current2 = true ? "2.76.9" : null;
|
|
50099
50164
|
if (!current2) return;
|
|
50100
50165
|
const cache = readCache();
|
|
50101
50166
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -50118,7 +50183,7 @@ var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
|
50118
50183
|
var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
|
|
50119
50184
|
var SUDO_PREFLIGHT_TIMEOUT_MS = 5e3;
|
|
50120
50185
|
function currentCliVersion() {
|
|
50121
|
-
return true ? "2.76.
|
|
50186
|
+
return true ? "2.76.9" : null;
|
|
50122
50187
|
}
|
|
50123
50188
|
async function installedVersion(deps) {
|
|
50124
50189
|
const ls = await deps.run(
|
|
@@ -50471,7 +50536,7 @@ var ORPHAN_KILL_SETTLE_MS = 500;
|
|
|
50471
50536
|
function needsSelfRelaunch(env = process.env, pid = process.pid) {
|
|
50472
50537
|
return !env.INVOCATION_ID && pid !== 1;
|
|
50473
50538
|
}
|
|
50474
|
-
function isContainerEnvironment(existsSyncFn =
|
|
50539
|
+
function isContainerEnvironment(existsSyncFn = fs91.existsSync, readFileSyncFn = (p2) => fs91.readFileSync(p2, "utf8")) {
|
|
50475
50540
|
try {
|
|
50476
50541
|
if (existsSyncFn("/.dockerenv")) return true;
|
|
50477
50542
|
} catch {
|
|
@@ -50936,13 +51001,13 @@ var HostAgentSupervisor = class {
|
|
|
50936
51001
|
const relay = this.relay;
|
|
50937
51002
|
if (!relay) return;
|
|
50938
51003
|
const raw = cmd.payload?.path;
|
|
50939
|
-
const target = typeof raw === "string" && raw.trim() ?
|
|
51004
|
+
const target = typeof raw === "string" && raw.trim() ? path105.resolve(raw.trim()) : os67.homedir();
|
|
50940
51005
|
try {
|
|
50941
|
-
const dirents = await
|
|
51006
|
+
const dirents = await fs91.promises.readdir(target, { withFileTypes: true });
|
|
50942
51007
|
const entries2 = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
|
|
50943
51008
|
(a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
|
|
50944
51009
|
);
|
|
50945
|
-
const parent =
|
|
51010
|
+
const parent = path105.dirname(target);
|
|
50946
51011
|
await relay.sendResult(cmd.id, "completed", {
|
|
50947
51012
|
path: target,
|
|
50948
51013
|
// null at the filesystem root so the UI can hide the ".." affordance.
|
|
@@ -51290,14 +51355,14 @@ var HostAgentSupervisor = class {
|
|
|
51290
51355
|
...buildHouseProxyChildEnv({ baseUrl, token, openRouter: openRouter === true }),
|
|
51291
51356
|
CODEAM_AUTO_TOKEN: payload.autoPairToken
|
|
51292
51357
|
};
|
|
51293
|
-
const houseConfigDir =
|
|
51358
|
+
const houseConfigDir = path105.join(
|
|
51294
51359
|
os67.homedir(),
|
|
51295
51360
|
".codeam",
|
|
51296
51361
|
"house-claude",
|
|
51297
51362
|
payload.deployId
|
|
51298
51363
|
);
|
|
51299
51364
|
try {
|
|
51300
|
-
|
|
51365
|
+
fs91.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
|
|
51301
51366
|
} catch {
|
|
51302
51367
|
}
|
|
51303
51368
|
childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
|
|
@@ -51331,13 +51396,13 @@ var HostAgentSupervisor = class {
|
|
|
51331
51396
|
if ((payload.repoProvider ?? "github") === "gitlab") {
|
|
51332
51397
|
const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
|
|
51333
51398
|
if (glabCmd) {
|
|
51334
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
51399
|
+
childEnv.PATH = `${codeamBinDir()}${path105.delimiter}${childEnv.PATH}`;
|
|
51335
51400
|
await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
|
|
51336
51401
|
}
|
|
51337
51402
|
} else {
|
|
51338
51403
|
const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
|
|
51339
51404
|
if (ghCmd) {
|
|
51340
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
51405
|
+
childEnv.PATH = `${codeamBinDir()}${path105.delimiter}${childEnv.PATH}`;
|
|
51341
51406
|
await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
|
|
51342
51407
|
}
|
|
51343
51408
|
}
|
|
@@ -51365,9 +51430,9 @@ var HostAgentSupervisor = class {
|
|
|
51365
51430
|
);
|
|
51366
51431
|
if (!payload.suppressOnboardingWelcome) {
|
|
51367
51432
|
try {
|
|
51368
|
-
const cfgDir = childEnv.CLAUDE_CONFIG_DIR ||
|
|
51369
|
-
const projectDir =
|
|
51370
|
-
const hasPriorConversation =
|
|
51433
|
+
const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path105.join(os67.homedir(), ".claude");
|
|
51434
|
+
const projectDir = path105.join(cfgDir, "projects", encodeCwd(cwd));
|
|
51435
|
+
const hasPriorConversation = fs91.existsSync(projectDir) && fs91.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
|
|
51371
51436
|
if (hasPriorConversation) {
|
|
51372
51437
|
childEnv.CODEAM_RESUME_LATEST = "1";
|
|
51373
51438
|
log.info(
|
|
@@ -51521,7 +51586,7 @@ var HostAgentSupervisor = class {
|
|
|
51521
51586
|
fallbackResumeTarget() {
|
|
51522
51587
|
const session = getActiveSession();
|
|
51523
51588
|
if (!session || !session.pluginId || !session.pollSecret || !session.agent) return null;
|
|
51524
|
-
const cwd = session.cwd &&
|
|
51589
|
+
const cwd = session.cwd && fs91.existsSync(session.cwd) ? session.cwd : process.cwd();
|
|
51525
51590
|
if (isFilesystemRoot(cwd)) {
|
|
51526
51591
|
log.warn(
|
|
51527
51592
|
"host-agent",
|
|
@@ -51561,7 +51626,7 @@ var HostAgentSupervisor = class {
|
|
|
51561
51626
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: no saved pairing on this box`);
|
|
51562
51627
|
return;
|
|
51563
51628
|
}
|
|
51564
|
-
if (!session.cwd || !
|
|
51629
|
+
if (!session.cwd || !fs91.existsSync(session.cwd)) {
|
|
51565
51630
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: workspace is gone`);
|
|
51566
51631
|
return;
|
|
51567
51632
|
}
|
|
@@ -51603,7 +51668,7 @@ var HostAgentSupervisor = class {
|
|
|
51603
51668
|
const persisted = new Map((this.sessionStore.load() ?? []).map((r) => [r.deployId, r.agent]));
|
|
51604
51669
|
for (const c2 of this.children.values()) persisted.set(c2.deployId, c2.agent);
|
|
51605
51670
|
return this.listSavedSessions().map((s) => ({ s, deployId: deployIdFromWorkspace(s.cwd) })).filter(
|
|
51606
|
-
(x) => x.deployId !== null && !!x.s.cwd &&
|
|
51671
|
+
(x) => x.deployId !== null && !!x.s.cwd && fs91.existsSync(x.s.cwd)
|
|
51607
51672
|
).map(({ s, deployId }) => {
|
|
51608
51673
|
const agent = persisted.get(deployId);
|
|
51609
51674
|
return { deployId, sessionId: s.id, ...agent ? { agent } : {} };
|
|
@@ -51655,7 +51720,7 @@ var HostAgentSupervisor = class {
|
|
|
51655
51720
|
if (this.children.has(deployId)) return;
|
|
51656
51721
|
const st3 = this.resumeStateFor(target);
|
|
51657
51722
|
try {
|
|
51658
|
-
const cwd =
|
|
51723
|
+
const cwd = fs91.existsSync(target.cwd) ? target.cwd : process.cwd();
|
|
51659
51724
|
const proc = this.resumeSpawner(
|
|
51660
51725
|
{ ...readHouseProxyChildEnv(deployId), CODEAM_RESUME_SESSION_ID: session.id },
|
|
51661
51726
|
cwd
|
|
@@ -51874,12 +51939,12 @@ var HostAgentSupervisor = class {
|
|
|
51874
51939
|
this.untrackChild(deployId);
|
|
51875
51940
|
}
|
|
51876
51941
|
const dirs = [
|
|
51877
|
-
|
|
51878
|
-
|
|
51942
|
+
path105.join(selfHostedWorkspaceRoot(), deployId),
|
|
51943
|
+
path105.join(os67.homedir(), ".codeam", "house-claude", deployId)
|
|
51879
51944
|
];
|
|
51880
51945
|
for (const dir of dirs) {
|
|
51881
51946
|
try {
|
|
51882
|
-
|
|
51947
|
+
fs91.rmSync(dir, { recursive: true, force: true });
|
|
51883
51948
|
} catch (err) {
|
|
51884
51949
|
log.warn(
|
|
51885
51950
|
"host-agent",
|
|
@@ -52039,8 +52104,8 @@ async function invite() {
|
|
|
52039
52104
|
var import_node_dns = require("dns");
|
|
52040
52105
|
var import_node_util11 = require("util");
|
|
52041
52106
|
var import_node_crypto17 = require("crypto");
|
|
52042
|
-
var
|
|
52043
|
-
var
|
|
52107
|
+
var fs92 = __toESM(require("fs"));
|
|
52108
|
+
var path106 = __toESM(require("path"));
|
|
52044
52109
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
52045
52110
|
var dnsResolveP = (0, import_node_util11.promisify)(import_node_dns.resolve);
|
|
52046
52111
|
async function checkDns(apiBase2) {
|
|
@@ -52096,13 +52161,13 @@ async function checkHealth(apiBase2) {
|
|
|
52096
52161
|
}
|
|
52097
52162
|
}
|
|
52098
52163
|
function checkConfigDir() {
|
|
52099
|
-
const dir =
|
|
52164
|
+
const dir = path106.join(require("os").homedir(), ".codeam");
|
|
52100
52165
|
try {
|
|
52101
|
-
|
|
52102
|
-
const probe =
|
|
52103
|
-
|
|
52104
|
-
const read =
|
|
52105
|
-
|
|
52166
|
+
fs92.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
52167
|
+
const probe = path106.join(dir, ".doctor-probe");
|
|
52168
|
+
fs92.writeFileSync(probe, "ok", { mode: 384 });
|
|
52169
|
+
const read = fs92.readFileSync(probe, "utf8");
|
|
52170
|
+
fs92.unlinkSync(probe);
|
|
52106
52171
|
if (read !== "ok") throw new Error("write/read round-trip mismatch");
|
|
52107
52172
|
return {
|
|
52108
52173
|
id: "config-dir",
|
|
@@ -52166,7 +52231,7 @@ function checkNodePty() {
|
|
|
52166
52231
|
detail: "not required on this platform"
|
|
52167
52232
|
};
|
|
52168
52233
|
}
|
|
52169
|
-
const vendoredPath =
|
|
52234
|
+
const vendoredPath = path106.join(__dirname, "vendor", "node-pty");
|
|
52170
52235
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
52171
52236
|
try {
|
|
52172
52237
|
require(target);
|
|
@@ -52208,7 +52273,7 @@ function checkChokidar() {
|
|
|
52208
52273
|
}
|
|
52209
52274
|
async function doctor(args2 = []) {
|
|
52210
52275
|
const json = args2.includes("--json");
|
|
52211
|
-
const cliVersion = true ? "2.76.
|
|
52276
|
+
const cliVersion = true ? "2.76.9" : "0.0.0-dev";
|
|
52212
52277
|
const apiBase2 = resolveApiBaseUrl();
|
|
52213
52278
|
const diagnosticId = (0, import_node_crypto17.randomUUID)();
|
|
52214
52279
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
@@ -52415,9 +52480,9 @@ var LAUNCHER_ENV = Object.freeze({
|
|
|
52415
52480
|
});
|
|
52416
52481
|
|
|
52417
52482
|
// src/integrations/mcp-run.ts
|
|
52418
|
-
var
|
|
52483
|
+
var import_node_fs22 = require("fs");
|
|
52419
52484
|
var import_node_os18 = __toESM(require("os"));
|
|
52420
|
-
var
|
|
52485
|
+
var import_node_path24 = __toESM(require("path"));
|
|
52421
52486
|
|
|
52422
52487
|
// src/integrations/token-client.ts
|
|
52423
52488
|
var REFRESH_AHEAD_MS = 5 * 60 * 1e3;
|
|
@@ -52497,13 +52562,13 @@ function commandExists(command2) {
|
|
|
52497
52562
|
}
|
|
52498
52563
|
function localBinCandidates(command2) {
|
|
52499
52564
|
return [
|
|
52500
|
-
|
|
52501
|
-
|
|
52565
|
+
import_node_path24.default.join(import_node_os18.default.homedir(), ".local", "bin", command2),
|
|
52566
|
+
import_node_path24.default.join(import_node_os18.default.homedir(), ".cargo", "bin", command2)
|
|
52502
52567
|
];
|
|
52503
52568
|
}
|
|
52504
52569
|
function resolveLauncherPath(command2, deps = {
|
|
52505
52570
|
commandExists,
|
|
52506
|
-
existsSync:
|
|
52571
|
+
existsSync: import_node_fs22.existsSync
|
|
52507
52572
|
}) {
|
|
52508
52573
|
if (deps.commandExists(command2)) return command2;
|
|
52509
52574
|
for (const candidate of localBinCandidates(command2)) {
|
|
@@ -52732,7 +52797,7 @@ async function mcpWarm(argv = [], opts = {}) {
|
|
|
52732
52797
|
// src/commands/version.ts
|
|
52733
52798
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
52734
52799
|
function version2() {
|
|
52735
|
-
const v = true ? "2.76.
|
|
52800
|
+
const v = true ? "2.76.9" : "unknown";
|
|
52736
52801
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
52737
52802
|
}
|
|
52738
52803
|
|