codeam-cli 2.75.35 → 2.75.37
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 +13 -0
- package/dist/index.js +423 -357
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -77,12 +77,12 @@ var require_src = __commonJS({
|
|
|
77
77
|
lineEnd: `${CSI2}K`,
|
|
78
78
|
lineStart: `${CSI2}1K`,
|
|
79
79
|
lines(count) {
|
|
80
|
-
let
|
|
80
|
+
let clear2 = "";
|
|
81
81
|
for (let i = 0; i < count; i++)
|
|
82
|
-
|
|
82
|
+
clear2 += this.line + (i < count - 1 ? cursor.up() : "");
|
|
83
83
|
if (count)
|
|
84
|
-
|
|
85
|
-
return
|
|
84
|
+
clear2 += cursor.left;
|
|
85
|
+
return clear2;
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
module2.exports = { cursor, scroll, erase, beep };
|
|
@@ -357,8 +357,8 @@ function defaultSpawn(timeoutMs) {
|
|
|
357
357
|
});
|
|
358
358
|
}
|
|
359
359
|
function resolveConvexBin(cwd) {
|
|
360
|
-
const local =
|
|
361
|
-
if (
|
|
360
|
+
const local = path96.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "convex.cmd" : "convex");
|
|
361
|
+
if (fs82.existsSync(local)) return { cmd: local, args: [] };
|
|
362
362
|
return { cmd: "npx", args: ["--yes", "convex"] };
|
|
363
363
|
}
|
|
364
364
|
function redact(text, key) {
|
|
@@ -489,13 +489,13 @@ async function runConvexAdminMcp(client3, id) {
|
|
|
489
489
|
});
|
|
490
490
|
await server.connect(new StdioServerTransport());
|
|
491
491
|
}
|
|
492
|
-
var import_node_child_process32,
|
|
492
|
+
var import_node_child_process32, fs82, path96, TOOLS;
|
|
493
493
|
var init_convex_admin_mcp = __esm({
|
|
494
494
|
"src/integrations/convex-admin-mcp.ts"() {
|
|
495
495
|
"use strict";
|
|
496
496
|
import_node_child_process32 = require("child_process");
|
|
497
|
-
|
|
498
|
-
|
|
497
|
+
fs82 = __toESM(require("fs"));
|
|
498
|
+
path96 = __toESM(require("path"));
|
|
499
499
|
TOOLS = [
|
|
500
500
|
{
|
|
501
501
|
name: "tables",
|
|
@@ -578,7 +578,7 @@ function createToolCallWatchdog(deps) {
|
|
|
578
578
|
const clearTimer = deps.clearTimer ?? ((t2) => clearTimeout(t2));
|
|
579
579
|
const timers = /* @__PURE__ */ new Map();
|
|
580
580
|
const answered = /* @__PURE__ */ new Set();
|
|
581
|
-
const
|
|
581
|
+
const clear2 = (id) => {
|
|
582
582
|
const t2 = timers.get(id);
|
|
583
583
|
if (t2) {
|
|
584
584
|
clearTimer(t2);
|
|
@@ -590,7 +590,7 @@ function createToolCallWatchdog(deps) {
|
|
|
590
590
|
const m = msg;
|
|
591
591
|
if (m.method !== "tools/call" || m.id === void 0) return;
|
|
592
592
|
const id = m.id;
|
|
593
|
-
|
|
593
|
+
clear2(id);
|
|
594
594
|
const timer = setTimer(() => {
|
|
595
595
|
timers.delete(id);
|
|
596
596
|
answered.add(id);
|
|
@@ -610,7 +610,7 @@ function createToolCallWatchdog(deps) {
|
|
|
610
610
|
onServerMessage(msg) {
|
|
611
611
|
const m = msg;
|
|
612
612
|
if (m.id === void 0 || m.method !== void 0) return false;
|
|
613
|
-
|
|
613
|
+
clear2(m.id);
|
|
614
614
|
return answered.delete(m.id);
|
|
615
615
|
},
|
|
616
616
|
dispose() {
|
|
@@ -3545,11 +3545,11 @@ function quiet(fn) {
|
|
|
3545
3545
|
log.debug(TAG, "ignored sync error", err);
|
|
3546
3546
|
}
|
|
3547
3547
|
}
|
|
3548
|
-
function rmIfExistsQuiet(
|
|
3548
|
+
function rmIfExistsQuiet(path98) {
|
|
3549
3549
|
try {
|
|
3550
|
-
fs2.rmSync(
|
|
3550
|
+
fs2.rmSync(path98, { force: true });
|
|
3551
3551
|
} catch (err) {
|
|
3552
|
-
log.debug(TAG, `rmIfExists failed for ${
|
|
3552
|
+
log.debug(TAG, `rmIfExists failed for ${path98}`, err);
|
|
3553
3553
|
}
|
|
3554
3554
|
}
|
|
3555
3555
|
function killQuiet(target, signal = "SIGTERM") {
|
|
@@ -3753,8 +3753,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
|
|
|
3753
3753
|
return decodedFile;
|
|
3754
3754
|
};
|
|
3755
3755
|
}
|
|
3756
|
-
function normalizeWindowsPath(
|
|
3757
|
-
return
|
|
3756
|
+
function normalizeWindowsPath(path98) {
|
|
3757
|
+
return path98.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
3758
3758
|
}
|
|
3759
3759
|
|
|
3760
3760
|
// ../../node_modules/@posthog/core/dist/error-tracking/index.mjs
|
|
@@ -4828,20 +4828,20 @@ var ErrorPropertiesBuilder = class {
|
|
|
4828
4828
|
};
|
|
4829
4829
|
return context;
|
|
4830
4830
|
}
|
|
4831
|
-
buildCoercingContext(mechanism, hint,
|
|
4832
|
-
const coerce = (input,
|
|
4833
|
-
if (!(
|
|
4831
|
+
buildCoercingContext(mechanism, hint, depth2 = 0) {
|
|
4832
|
+
const coerce = (input, depth3) => {
|
|
4833
|
+
if (!(depth3 <= MAX_CAUSE_RECURSION)) return;
|
|
4834
4834
|
{
|
|
4835
|
-
const ctx = this.buildCoercingContext(mechanism, hint,
|
|
4835
|
+
const ctx = this.buildCoercingContext(mechanism, hint, depth3);
|
|
4836
4836
|
return this.applyCoercers(input, ctx);
|
|
4837
4837
|
}
|
|
4838
4838
|
};
|
|
4839
4839
|
const context = {
|
|
4840
4840
|
...hint,
|
|
4841
|
-
syntheticException: 0 ==
|
|
4841
|
+
syntheticException: 0 == depth2 ? hint.syntheticException : void 0,
|
|
4842
4842
|
mechanism,
|
|
4843
|
-
apply: (input) => coerce(input,
|
|
4844
|
-
next: (input) => coerce(input,
|
|
4843
|
+
apply: (input) => coerce(input, depth2),
|
|
4844
|
+
next: (input) => coerce(input, depth2 + 1)
|
|
4845
4845
|
};
|
|
4846
4846
|
return context;
|
|
4847
4847
|
}
|
|
@@ -6487,13 +6487,13 @@ var PostHogCoreStateless = class {
|
|
|
6487
6487
|
sentFromRoute += batchMessages.length;
|
|
6488
6488
|
}
|
|
6489
6489
|
}
|
|
6490
|
-
async _sendOtlpBatch({ path:
|
|
6490
|
+
async _sendOtlpBatch({ path: path98, payload }) {
|
|
6491
6491
|
if (this.disabled) return {
|
|
6492
6492
|
kind: "fatal",
|
|
6493
6493
|
error: new Error("The client is disabled")
|
|
6494
6494
|
};
|
|
6495
6495
|
const serialized = JSON.stringify(payload);
|
|
6496
|
-
const url2 = `${this.host}/i/v1/${
|
|
6496
|
+
const url2 = `${this.host}/i/v1/${path98}?token=${encodeURIComponent(this.apiKey)}`;
|
|
6497
6497
|
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
|
|
6498
6498
|
const fetchOptions = {
|
|
6499
6499
|
method: "POST",
|
|
@@ -7139,7 +7139,7 @@ function encodeBigInt(value, logger) {
|
|
|
7139
7139
|
intValue: decimal
|
|
7140
7140
|
};
|
|
7141
7141
|
}
|
|
7142
|
-
function encodeAnyValue(value, logger, state,
|
|
7142
|
+
function encodeAnyValue(value, logger, state, depth2) {
|
|
7143
7143
|
if (state.remainingNodes <= 0) return {
|
|
7144
7144
|
stringValue: TRUNCATED_VALUE
|
|
7145
7145
|
};
|
|
@@ -7187,7 +7187,7 @@ function encodeAnyValue(value, logger, state, depth) {
|
|
|
7187
7187
|
if (state.ancestors.has(value)) return {
|
|
7188
7188
|
stringValue: CIRCULAR_VALUE
|
|
7189
7189
|
};
|
|
7190
|
-
if (
|
|
7190
|
+
if (depth2 >= MAX_JSON_SAFE_VALUE_DEPTH) return {
|
|
7191
7191
|
stringValue: TRUNCATED_VALUE
|
|
7192
7192
|
};
|
|
7193
7193
|
if (value instanceof Date) {
|
|
@@ -7201,17 +7201,17 @@ function encodeAnyValue(value, logger, state, depth) {
|
|
|
7201
7201
|
try {
|
|
7202
7202
|
try {
|
|
7203
7203
|
const toJSON = value.toJSON;
|
|
7204
|
-
if ("function" == typeof toJSON) return encodeAnyValue(toJSON.call(value), logger, state,
|
|
7204
|
+
if ("function" == typeof toJSON) return encodeAnyValue(toJSON.call(value), logger, state, depth2 + 1);
|
|
7205
7205
|
} catch {
|
|
7206
7206
|
}
|
|
7207
7207
|
if (isArray(value)) return {
|
|
7208
7208
|
arrayValue: {
|
|
7209
|
-
values: encodeArrayValues(value, logger, state,
|
|
7209
|
+
values: encodeArrayValues(value, logger, state, depth2 + 1)
|
|
7210
7210
|
}
|
|
7211
7211
|
};
|
|
7212
7212
|
return {
|
|
7213
7213
|
kvlistValue: {
|
|
7214
|
-
values: encodeKeyValueList(value, logger, state,
|
|
7214
|
+
values: encodeKeyValueList(value, logger, state, depth2 + 1)
|
|
7215
7215
|
}
|
|
7216
7216
|
};
|
|
7217
7217
|
} finally {
|
|
@@ -7222,14 +7222,14 @@ function encodeAnyValue(value, logger, state, depth) {
|
|
|
7222
7222
|
stringValue: sanitizeString(String(value))
|
|
7223
7223
|
};
|
|
7224
7224
|
}
|
|
7225
|
-
function encodeArrayValues(values, logger, state,
|
|
7225
|
+
function encodeArrayValues(values, logger, state, depth2) {
|
|
7226
7226
|
const result = [];
|
|
7227
7227
|
const itemCount = Math.min(values.length, MAX_JSON_SAFE_VALUE_ITEMS);
|
|
7228
7228
|
let index = 0;
|
|
7229
7229
|
for (; index < itemCount && state.remainingNodes > 0; index++) try {
|
|
7230
7230
|
const element = index in values ? values[index] : void 0;
|
|
7231
7231
|
if (isNullish(element)) continue;
|
|
7232
|
-
result.push(encodeAnyValue(element, logger, state,
|
|
7232
|
+
result.push(encodeAnyValue(element, logger, state, depth2));
|
|
7233
7233
|
} catch {
|
|
7234
7234
|
result.push({
|
|
7235
7235
|
stringValue: UNSERIALIZABLE_VALUE
|
|
@@ -7240,7 +7240,7 @@ function encodeArrayValues(values, logger, state, depth) {
|
|
|
7240
7240
|
});
|
|
7241
7241
|
return result;
|
|
7242
7242
|
}
|
|
7243
|
-
function encodeKeyValueList(attrs, logger, state,
|
|
7243
|
+
function encodeKeyValueList(attrs, logger, state, depth2) {
|
|
7244
7244
|
const result = [];
|
|
7245
7245
|
for (const key in attrs) if (propertyIsEnumerable.call(attrs, key)) {
|
|
7246
7246
|
if (!key) {
|
|
@@ -7256,7 +7256,7 @@ function encodeKeyValueList(attrs, logger, state, depth) {
|
|
|
7256
7256
|
if (isNull(value) || isUndefined(value)) continue;
|
|
7257
7257
|
result.push({
|
|
7258
7258
|
key: sanitizeString(key),
|
|
7259
|
-
value: encodeAnyValue(value, logger, state,
|
|
7259
|
+
value: encodeAnyValue(value, logger, state, depth2)
|
|
7260
7260
|
});
|
|
7261
7261
|
} catch {
|
|
7262
7262
|
result.push({
|
|
@@ -7733,14 +7733,14 @@ async function addSourceContext(frames, openSourceFile = import_promises.open, l
|
|
|
7733
7733
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
7734
7734
|
return frames;
|
|
7735
7735
|
}
|
|
7736
|
-
async function openRegularSourceFile(
|
|
7736
|
+
async function openRegularSourceFile(path98, openSourceFile, logger) {
|
|
7737
7737
|
let fileHandle;
|
|
7738
7738
|
let isValid = false;
|
|
7739
7739
|
try {
|
|
7740
|
-
fileHandle = await openSourceFile(
|
|
7740
|
+
fileHandle = await openSourceFile(path98, import_node_fs.constants.O_RDONLY | import_node_fs.constants.O_NONBLOCK);
|
|
7741
7741
|
const fileStat = await fileHandle.stat();
|
|
7742
7742
|
if (!fileStat.isFile()) return;
|
|
7743
|
-
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${
|
|
7743
|
+
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${path98}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
|
|
7744
7744
|
isValid = true;
|
|
7745
7745
|
return fileHandle;
|
|
7746
7746
|
} catch {
|
|
@@ -7750,8 +7750,8 @@ async function openRegularSourceFile(path97, openSourceFile, logger) {
|
|
|
7750
7750
|
});
|
|
7751
7751
|
}
|
|
7752
7752
|
}
|
|
7753
|
-
async function getContextLinesFromFile(
|
|
7754
|
-
const fileHandle = await openRegularSourceFile(
|
|
7753
|
+
async function getContextLinesFromFile(path98, ranges, output, cacheKey, openSourceFile, logger) {
|
|
7754
|
+
const fileHandle = await openRegularSourceFile(path98, openSourceFile, logger);
|
|
7755
7755
|
if (void 0 === fileHandle) return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
7756
7756
|
const openedFileHandle = fileHandle;
|
|
7757
7757
|
return new Promise((resolve12) => {
|
|
@@ -7853,22 +7853,22 @@ function clearLineContext(frame) {
|
|
|
7853
7853
|
delete frame.context_line;
|
|
7854
7854
|
delete frame.post_context;
|
|
7855
7855
|
}
|
|
7856
|
-
function shouldSkipContextLinesForFile(
|
|
7857
|
-
return
|
|
7856
|
+
function shouldSkipContextLinesForFile(path98) {
|
|
7857
|
+
return path98.startsWith("node:") || path98.endsWith(".min.js") || path98.endsWith(".min.cjs") || path98.endsWith(".min.mjs") || path98.startsWith("data:");
|
|
7858
7858
|
}
|
|
7859
7859
|
function shouldSkipContextLinesForFrame(frame) {
|
|
7860
7860
|
if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
|
|
7861
7861
|
if (void 0 !== frame.colno && frame.colno > MAX_CONTEXTLINES_COLNO) return true;
|
|
7862
7862
|
return false;
|
|
7863
7863
|
}
|
|
7864
|
-
function makeSourceCacheKey(
|
|
7865
|
-
if ((0, import_node_path.isAbsolute)(
|
|
7864
|
+
function makeSourceCacheKey(path98, basePath) {
|
|
7865
|
+
if ((0, import_node_path.isAbsolute)(path98)) return JSON.stringify([
|
|
7866
7866
|
null,
|
|
7867
|
-
|
|
7867
|
+
path98
|
|
7868
7868
|
]);
|
|
7869
7869
|
return void 0 === basePath ? void 0 : JSON.stringify([
|
|
7870
7870
|
basePath,
|
|
7871
|
-
|
|
7871
|
+
path98
|
|
7872
7872
|
]);
|
|
7873
7873
|
}
|
|
7874
7874
|
function rangeExistsInContentCache(cacheKey, range) {
|
|
@@ -10529,7 +10529,7 @@ function readAnonId() {
|
|
|
10529
10529
|
}
|
|
10530
10530
|
function superProperties() {
|
|
10531
10531
|
return {
|
|
10532
|
-
cliVersion: true ? "2.75.
|
|
10532
|
+
cliVersion: true ? "2.75.37" : "0.0.0-dev",
|
|
10533
10533
|
nodeVersion: process.version,
|
|
10534
10534
|
platform: process.platform,
|
|
10535
10535
|
arch: process.arch,
|
|
@@ -10771,7 +10771,7 @@ var http = __toESM(require("http"));
|
|
|
10771
10771
|
// package.json
|
|
10772
10772
|
var package_default = {
|
|
10773
10773
|
name: "codeam-cli",
|
|
10774
|
-
version: "2.75.
|
|
10774
|
+
version: "2.75.37",
|
|
10775
10775
|
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.",
|
|
10776
10776
|
type: "commonjs",
|
|
10777
10777
|
main: "dist/index.js",
|
|
@@ -12101,7 +12101,7 @@ var CommandRelayService = class _CommandRelayService {
|
|
|
12101
12101
|
// fresh + clear the "CLI update available" banner after a self-update
|
|
12102
12102
|
// (a codespace that reinstalls @latest reconnects via heartbeat, not
|
|
12103
12103
|
// pair/reconnect). Older backends ignore the extra field.
|
|
12104
|
-
..."2.75.
|
|
12104
|
+
..."2.75.37" ? { ideVersion: "2.75.37" } : {}
|
|
12105
12105
|
};
|
|
12106
12106
|
try {
|
|
12107
12107
|
const res = await _postJson(`${API_BASE2}/api/plugin/heartbeat`, body);
|
|
@@ -12419,10 +12419,10 @@ var WINDOWS_LEGACY_JUNCTIONS = [
|
|
|
12419
12419
|
/[\\/]Start Menu([\\/]|$)/i,
|
|
12420
12420
|
/[\\/]Templates([\\/]|$)/i
|
|
12421
12421
|
];
|
|
12422
|
-
function isUnsafeWindowsWatchRoot(dir,
|
|
12422
|
+
function isUnsafeWindowsWatchRoot(dir, homedir53) {
|
|
12423
12423
|
const norm = (p2) => p2.replace(/\//g, "\\").replace(/\\+$/, "").toLowerCase();
|
|
12424
12424
|
const cwd = norm(dir);
|
|
12425
|
-
const home = norm(
|
|
12425
|
+
const home = norm(homedir53);
|
|
12426
12426
|
if (cwd === home) return true;
|
|
12427
12427
|
if (/^[a-z]:$/.test(cwd)) return true;
|
|
12428
12428
|
const sysRoots = [
|
|
@@ -13821,8 +13821,8 @@ async function isExistingFile(absPath) {
|
|
|
13821
13821
|
return false;
|
|
13822
13822
|
}
|
|
13823
13823
|
}
|
|
13824
|
-
async function walkForSuffix(dir, needleVariants,
|
|
13825
|
-
if (
|
|
13824
|
+
async function walkForSuffix(dir, needleVariants, depth2, ctx) {
|
|
13825
|
+
if (depth2 > MAX_WALK_DEPTH) return;
|
|
13826
13826
|
if (ctx.visited > MAX_VISITED_DIRS) return;
|
|
13827
13827
|
if (ctx.matches.length >= ctx.cap) return;
|
|
13828
13828
|
ctx.visited++;
|
|
@@ -13844,7 +13844,7 @@ async function walkForSuffix(dir, needleVariants, depth, ctx) {
|
|
|
13844
13844
|
if (!e.isDirectory()) continue;
|
|
13845
13845
|
if (SUBDIR_IGNORE.has(e.name)) continue;
|
|
13846
13846
|
if (e.name.startsWith(".") && SUBDIR_IGNORE.has(e.name)) continue;
|
|
13847
|
-
await walkForSuffix(path7.join(dir, e.name), needleVariants,
|
|
13847
|
+
await walkForSuffix(path7.join(dir, e.name), needleVariants, depth2 + 1, ctx);
|
|
13848
13848
|
if (ctx.matches.length >= ctx.cap) return;
|
|
13849
13849
|
}
|
|
13850
13850
|
}
|
|
@@ -13966,7 +13966,7 @@ async function listProjectFiles(opts = {}) {
|
|
|
13966
13966
|
const q2 = (opts.query ?? "").trim().toLowerCase();
|
|
13967
13967
|
const out2 = [];
|
|
13968
13968
|
let truncated = false;
|
|
13969
|
-
async function walk(dir,
|
|
13969
|
+
async function walk(dir, depth2) {
|
|
13970
13970
|
if (out2.length >= cap) {
|
|
13971
13971
|
truncated = true;
|
|
13972
13972
|
return;
|
|
@@ -13985,8 +13985,8 @@ async function listProjectFiles(opts = {}) {
|
|
|
13985
13985
|
if (PROJECT_IGNORE.has(e.name)) continue;
|
|
13986
13986
|
const full = path8.join(dir, e.name);
|
|
13987
13987
|
if (e.isDirectory()) {
|
|
13988
|
-
if (
|
|
13989
|
-
await walk(full,
|
|
13988
|
+
if (depth2 >= 12) continue;
|
|
13989
|
+
await walk(full, depth2 + 1);
|
|
13990
13990
|
} else if (e.isFile()) {
|
|
13991
13991
|
const rel = path8.relative(root, full);
|
|
13992
13992
|
if (q2 && !rel.toLowerCase().includes(q2) && !e.name.toLowerCase().includes(q2)) {
|
|
@@ -17152,10 +17152,10 @@ function buildForPlatform(platform3) {
|
|
|
17152
17152
|
var import_node_crypto4 = require("crypto");
|
|
17153
17153
|
|
|
17154
17154
|
// src/agents/claude/resolver.ts
|
|
17155
|
-
function buildClaudeLaunch(extraArgs = [],
|
|
17156
|
-
const found =
|
|
17155
|
+
function buildClaudeLaunch(extraArgs = [], os67 = createOsStrategy()) {
|
|
17156
|
+
const found = os67.findInPath("claude") ?? os67.findInPath("claude-code");
|
|
17157
17157
|
if (!found) return null;
|
|
17158
|
-
return
|
|
17158
|
+
return os67.buildLaunch(found, extraArgs);
|
|
17159
17159
|
}
|
|
17160
17160
|
|
|
17161
17161
|
// src/agents/claude/installer.ts
|
|
@@ -17933,8 +17933,8 @@ var ClaudeRuntimeStrategy = class {
|
|
|
17933
17933
|
meta = getAgent("claude");
|
|
17934
17934
|
mode = "interactive";
|
|
17935
17935
|
os;
|
|
17936
|
-
constructor(
|
|
17937
|
-
this.os =
|
|
17936
|
+
constructor(os67) {
|
|
17937
|
+
this.os = os67;
|
|
17938
17938
|
}
|
|
17939
17939
|
/**
|
|
17940
17940
|
* Claude Code's react-ink TUI enables bracketed-paste mode at
|
|
@@ -19028,8 +19028,8 @@ function codexCredentialLocator() {
|
|
|
19028
19028
|
function codexLoginLauncher() {
|
|
19029
19029
|
return {
|
|
19030
19030
|
async ensureInstalled() {
|
|
19031
|
-
const
|
|
19032
|
-
return
|
|
19031
|
+
const os67 = createOsStrategy();
|
|
19032
|
+
return os67.findInPath("codex") !== null;
|
|
19033
19033
|
},
|
|
19034
19034
|
launch() {
|
|
19035
19035
|
return (0, import_node_child_process3.spawn)("codex", ["login"], { stdio: "inherit" });
|
|
@@ -19052,8 +19052,8 @@ var CodexRuntimeStrategy = class {
|
|
|
19052
19052
|
meta = getAgent("codex");
|
|
19053
19053
|
mode = "interactive";
|
|
19054
19054
|
os;
|
|
19055
|
-
constructor(
|
|
19056
|
-
this.os =
|
|
19055
|
+
constructor(os67) {
|
|
19056
|
+
this.os = os67;
|
|
19057
19057
|
}
|
|
19058
19058
|
async prepareLaunch() {
|
|
19059
19059
|
let binary = this.os.findInPath("codex");
|
|
@@ -19163,12 +19163,12 @@ var CodexRuntimeStrategy = class {
|
|
|
19163
19163
|
});
|
|
19164
19164
|
}
|
|
19165
19165
|
};
|
|
19166
|
-
function resolveNpm(
|
|
19167
|
-
return
|
|
19166
|
+
function resolveNpm(os67) {
|
|
19167
|
+
return os67.id === "win32" ? "npm.cmd" : "npm";
|
|
19168
19168
|
}
|
|
19169
|
-
async function installCodexViaNpm(
|
|
19169
|
+
async function installCodexViaNpm(os67) {
|
|
19170
19170
|
return new Promise((resolve12, reject) => {
|
|
19171
|
-
const proc = (0, import_node_child_process4.spawn)(resolveNpm(
|
|
19171
|
+
const proc = (0, import_node_child_process4.spawn)(resolveNpm(os67), ["install", "-g", "@openai/codex"], {
|
|
19172
19172
|
stdio: "inherit"
|
|
19173
19173
|
});
|
|
19174
19174
|
proc.on("close", (code) => {
|
|
@@ -19185,16 +19185,16 @@ async function installCodexViaNpm(os66) {
|
|
|
19185
19185
|
});
|
|
19186
19186
|
});
|
|
19187
19187
|
}
|
|
19188
|
-
function augmentNpmGlobalBin(
|
|
19188
|
+
function augmentNpmGlobalBin(os67) {
|
|
19189
19189
|
try {
|
|
19190
|
-
const result = (0, import_node_child_process4.spawnSync)(resolveNpm(
|
|
19190
|
+
const result = (0, import_node_child_process4.spawnSync)(resolveNpm(os67), ["prefix", "-g"], {
|
|
19191
19191
|
stdio: ["ignore", "pipe", "ignore"]
|
|
19192
19192
|
});
|
|
19193
19193
|
if (result.status !== 0) return;
|
|
19194
19194
|
const prefix = result.stdout.toString().trim();
|
|
19195
19195
|
if (!prefix) return;
|
|
19196
|
-
const binDir =
|
|
19197
|
-
|
|
19196
|
+
const binDir = os67.id === "win32" ? prefix : path24.join(prefix, "bin");
|
|
19197
|
+
os67.augmentPath([binDir]);
|
|
19198
19198
|
} catch {
|
|
19199
19199
|
}
|
|
19200
19200
|
}
|
|
@@ -19388,10 +19388,10 @@ function manualInstallHint(runner, tools) {
|
|
|
19388
19388
|
const argv = osPackageInstallArgv(detectPackageManager(runner), [...tools]);
|
|
19389
19389
|
return argv ? `\`sudo ${argv.join(" ")}\`` : `your package manager (e.g. \`${pkgs}\`)`;
|
|
19390
19390
|
}
|
|
19391
|
-
function writeUnzipShim(
|
|
19391
|
+
function writeUnzipShim(os67, runner) {
|
|
19392
19392
|
const python = ["python3", "python"].find((p2) => runner.which(p2));
|
|
19393
19393
|
if (!python) return null;
|
|
19394
|
-
const dir =
|
|
19394
|
+
const dir = os67.scratchPath("codeam-cr-prereq");
|
|
19395
19395
|
const shim = path26.join(dir, "unzip");
|
|
19396
19396
|
const script = `#!/bin/sh
|
|
19397
19397
|
set -e
|
|
@@ -19413,9 +19413,9 @@ exec ${python} -m zipfile -e "$archive" "$dest"
|
|
|
19413
19413
|
(0, import_node_fs5.chmodSync)(shim, 448);
|
|
19414
19414
|
return dir;
|
|
19415
19415
|
}
|
|
19416
|
-
async function ensureInstallPrerequisites(
|
|
19416
|
+
async function ensureInstallPrerequisites(os67, deps = {}) {
|
|
19417
19417
|
const runner = deps.runner ?? defaultOsRunner;
|
|
19418
|
-
const missing = REQUIRED_TOOLS.filter((t2) =>
|
|
19418
|
+
const missing = REQUIRED_TOOLS.filter((t2) => os67.findInPath(t2) === null);
|
|
19419
19419
|
if (missing.length === 0) return { ok: true, extraPath: [] };
|
|
19420
19420
|
log.info(
|
|
19421
19421
|
"coderabbit",
|
|
@@ -19434,10 +19434,10 @@ async function ensureInstallPrerequisites(os66, deps = {}) {
|
|
|
19434
19434
|
);
|
|
19435
19435
|
}
|
|
19436
19436
|
}
|
|
19437
|
-
const stillMissing = REQUIRED_TOOLS.filter((t2) =>
|
|
19437
|
+
const stillMissing = REQUIRED_TOOLS.filter((t2) => os67.findInPath(t2) === null);
|
|
19438
19438
|
if (stillMissing.length === 0) return { ok: true, extraPath: [] };
|
|
19439
19439
|
if (stillMissing.length === 1 && stillMissing[0] === "unzip") {
|
|
19440
|
-
const shimDir = writeUnzipShim(
|
|
19440
|
+
const shimDir = writeUnzipShim(os67, runner);
|
|
19441
19441
|
if (shimDir) {
|
|
19442
19442
|
log.info("coderabbit", "unzip is unavailable \u2014 using a scoped python zipfile shim");
|
|
19443
19443
|
return { ok: true, extraPath: [shimDir] };
|
|
@@ -19500,15 +19500,15 @@ function summarizeInstallFailure(output) {
|
|
|
19500
19500
|
}
|
|
19501
19501
|
return lines.length > 0 ? lines[lines.length - 1] : null;
|
|
19502
19502
|
}
|
|
19503
|
-
async function ensureCoderabbitInstalled(
|
|
19504
|
-
if (
|
|
19505
|
-
if (
|
|
19503
|
+
async function ensureCoderabbitInstalled(os67, deps = {}) {
|
|
19504
|
+
if (os67.findInPath("coderabbit")) return { ok: true };
|
|
19505
|
+
if (os67.id === "win32") {
|
|
19506
19506
|
return {
|
|
19507
19507
|
ok: false,
|
|
19508
19508
|
error: "CodeRabbit on Windows requires WSL. Install the CLI inside your WSL distribution (curl -fsSL https://cli.coderabbit.ai/install.sh | sh), then try again."
|
|
19509
19509
|
};
|
|
19510
19510
|
}
|
|
19511
|
-
const prereq = await ensureInstallPrerequisites(
|
|
19511
|
+
const prereq = await ensureInstallPrerequisites(os67, deps);
|
|
19512
19512
|
if (!prereq.ok) return { ok: false, error: prereq.error };
|
|
19513
19513
|
const env = { ...process.env };
|
|
19514
19514
|
if (prereq.extraPath.length > 0) {
|
|
@@ -19517,8 +19517,8 @@ async function ensureCoderabbitInstalled(os66, deps = {}) {
|
|
|
19517
19517
|
log.info("coderabbit", "CodeRabbit CLI not found \u2014 installing via the official script");
|
|
19518
19518
|
const run = deps.runInstallScript ?? defaultRunInstallScript;
|
|
19519
19519
|
const { code, output } = await run(env);
|
|
19520
|
-
|
|
19521
|
-
const binary =
|
|
19520
|
+
os67.augmentPath([`${os67.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
|
|
19521
|
+
const binary = os67.findInPath("coderabbit");
|
|
19522
19522
|
const detail = summarizeInstallFailure(output);
|
|
19523
19523
|
if (binary !== null) {
|
|
19524
19524
|
if (code === 0) return { ok: true };
|
|
@@ -19572,10 +19572,10 @@ function coderabbitCredentialLocator() {
|
|
|
19572
19572
|
validate: validateNonEmptyCredential
|
|
19573
19573
|
};
|
|
19574
19574
|
}
|
|
19575
|
-
function coderabbitLoginLauncher(
|
|
19575
|
+
function coderabbitLoginLauncher(os67) {
|
|
19576
19576
|
return {
|
|
19577
19577
|
async ensureInstalled() {
|
|
19578
|
-
const result = await ensureCoderabbitInstalled(
|
|
19578
|
+
const result = await ensureCoderabbitInstalled(os67);
|
|
19579
19579
|
if (!result.ok && result.error) console.error(`
|
|
19580
19580
|
\u2717 ${result.error}
|
|
19581
19581
|
`);
|
|
@@ -19635,8 +19635,8 @@ function pickLine(obj) {
|
|
|
19635
19635
|
function toHunk(raw, groupSeverity) {
|
|
19636
19636
|
if (!raw || typeof raw !== "object") return null;
|
|
19637
19637
|
const o = raw;
|
|
19638
|
-
const
|
|
19639
|
-
if (!
|
|
19638
|
+
const path98 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
|
|
19639
|
+
if (!path98) return null;
|
|
19640
19640
|
const message = asString(
|
|
19641
19641
|
pick(o, [
|
|
19642
19642
|
"comment",
|
|
@@ -19653,7 +19653,7 @@ function toHunk(raw, groupSeverity) {
|
|
|
19653
19653
|
const severity = normSeverity(pick(o, ["severity", "level", "priority", "impact"])) ?? normSeverity(groupSeverity);
|
|
19654
19654
|
const locObj = pick(o, ["location"]) ?? o;
|
|
19655
19655
|
return {
|
|
19656
|
-
path:
|
|
19656
|
+
path: path98.trim(),
|
|
19657
19657
|
line: pickLine(o) ?? pickLine(locObj),
|
|
19658
19658
|
severity,
|
|
19659
19659
|
message: (title && message ? `${title}: ${message}` : title || message).trim() || "(no message)"
|
|
@@ -19736,10 +19736,10 @@ function parsePlain(stdout) {
|
|
|
19736
19736
|
for (const line of stdout.split(/\r?\n/)) {
|
|
19737
19737
|
const m = line.match(HUNK_LINE_RE);
|
|
19738
19738
|
if (!m) continue;
|
|
19739
|
-
const [,
|
|
19740
|
-
if (!
|
|
19739
|
+
const [, path98, lineNo, sevToken, message] = m;
|
|
19740
|
+
if (!path98 || !lineNo || !message) continue;
|
|
19741
19741
|
hunks.push({
|
|
19742
|
-
path:
|
|
19742
|
+
path: path98.trim(),
|
|
19743
19743
|
line: Number(lineNo),
|
|
19744
19744
|
severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
|
|
19745
19745
|
message: message.trim().replace(/^[*-]\s+/, "")
|
|
@@ -19799,8 +19799,8 @@ var CoderabbitRuntimeStrategy = class {
|
|
|
19799
19799
|
meta = getAgent("coderabbit");
|
|
19800
19800
|
mode = "batch";
|
|
19801
19801
|
os;
|
|
19802
|
-
constructor(
|
|
19803
|
-
this.os =
|
|
19802
|
+
constructor(os67) {
|
|
19803
|
+
this.os = os67;
|
|
19804
19804
|
}
|
|
19805
19805
|
getDefaultArgs() {
|
|
19806
19806
|
return ["review", "--agent"];
|
|
@@ -20071,10 +20071,10 @@ function cursorCredentialLocator() {
|
|
|
20071
20071
|
validate: validateNonEmptyCredential
|
|
20072
20072
|
};
|
|
20073
20073
|
}
|
|
20074
|
-
function cursorLoginLauncher(
|
|
20074
|
+
function cursorLoginLauncher(os67) {
|
|
20075
20075
|
return {
|
|
20076
20076
|
async ensureInstalled() {
|
|
20077
|
-
if (
|
|
20077
|
+
if (os67.findInPath("cursor-agent")) return true;
|
|
20078
20078
|
console.error(
|
|
20079
20079
|
"\n \u2717 cursor-agent binary not on PATH.\n Install Cursor (https://cursor.com/) and ensure the CLI\n plugin is enabled, then re-run `codeam link cursor`.\n"
|
|
20080
20080
|
);
|
|
@@ -20138,8 +20138,8 @@ var CursorRuntimeStrategy = class {
|
|
|
20138
20138
|
meta = getAgent("cursor");
|
|
20139
20139
|
mode = "interactive";
|
|
20140
20140
|
os;
|
|
20141
|
-
constructor(
|
|
20142
|
-
this.os =
|
|
20141
|
+
constructor(os67) {
|
|
20142
|
+
this.os = os67;
|
|
20143
20143
|
}
|
|
20144
20144
|
async prepareLaunch() {
|
|
20145
20145
|
const binary = this.os.findInPath("cursor-agent");
|
|
@@ -20356,10 +20356,10 @@ function aiderCredentialLocator() {
|
|
|
20356
20356
|
validate: validateNonEmptyCredential
|
|
20357
20357
|
};
|
|
20358
20358
|
}
|
|
20359
|
-
function aiderLoginLauncher(
|
|
20359
|
+
function aiderLoginLauncher(os67) {
|
|
20360
20360
|
return {
|
|
20361
20361
|
async ensureInstalled() {
|
|
20362
|
-
if (
|
|
20362
|
+
if (os67.findInPath("aider")) return true;
|
|
20363
20363
|
console.error(
|
|
20364
20364
|
"\n \u2717 aider binary not on PATH.\n Install Aider:\n pip install aider-chat\n then re-run `codeam link aider`.\n"
|
|
20365
20365
|
);
|
|
@@ -20369,7 +20369,7 @@ function aiderLoginLauncher(os66) {
|
|
|
20369
20369
|
console.error(
|
|
20370
20370
|
"\n Aider has no interactive login flow.\n Set ANTHROPIC_API_KEY or OPENAI_API_KEY in your shell,\n or re-run `codeam link aider --api-key=<your-key>`.\n"
|
|
20371
20371
|
);
|
|
20372
|
-
return (0, import_node_child_process11.spawn)(
|
|
20372
|
+
return (0, import_node_child_process11.spawn)(os67.id === "win32" ? "cmd.exe" : "sh", os67.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
|
|
20373
20373
|
stdio: "ignore"
|
|
20374
20374
|
});
|
|
20375
20375
|
}
|
|
@@ -20458,14 +20458,14 @@ function defaultSdkDir() {
|
|
|
20458
20458
|
return resolveSdkDirViaRequire();
|
|
20459
20459
|
}
|
|
20460
20460
|
function resolveClaudeNativeBinary(deps = {}) {
|
|
20461
|
-
const
|
|
20461
|
+
const existsSync31 = deps.existsSync ?? import_fs.default.existsSync;
|
|
20462
20462
|
const platformKey = deps.platformKey ?? currentPlatformKey();
|
|
20463
20463
|
const sdkDir = deps.sdkDir !== void 0 ? deps.sdkDir : defaultSdkDir();
|
|
20464
20464
|
if (!sdkDir) return null;
|
|
20465
20465
|
const scopeDir = import_path4.default.dirname(sdkDir);
|
|
20466
20466
|
const binName = platformKey.startsWith("win32-") ? "claude.exe" : "claude";
|
|
20467
20467
|
const candidate = import_path4.default.join(scopeDir, `claude-agent-sdk-${platformKey}`, binName);
|
|
20468
|
-
return
|
|
20468
|
+
return existsSync31(candidate) ? candidate : null;
|
|
20469
20469
|
}
|
|
20470
20470
|
var realSleep = (ms) => new Promise((resolve12) => setTimeout(resolve12, ms));
|
|
20471
20471
|
async function waitForClaudeNativeBinary(opts = {}) {
|
|
@@ -20547,18 +20547,18 @@ function augmentUserLocalBinPaths(deps = {}) {
|
|
|
20547
20547
|
env.PATH = [...additions, ...parts].join(p2.delimiter);
|
|
20548
20548
|
}
|
|
20549
20549
|
function resolveCursorAgentBinary(deps = {}) {
|
|
20550
|
-
const
|
|
20550
|
+
const existsSync31 = deps.existsSync ?? import_fs.default.existsSync;
|
|
20551
20551
|
const platform3 = deps.platform ?? process.platform;
|
|
20552
20552
|
const env = deps.env ?? process.env;
|
|
20553
20553
|
if (platform3 === "win32") {
|
|
20554
20554
|
const localAppData = env.LOCALAPPDATA;
|
|
20555
20555
|
if (!localAppData) return null;
|
|
20556
20556
|
const exe = import_path4.default.win32.join(localAppData, "cursor-agent", "cursor-agent.exe");
|
|
20557
|
-
return
|
|
20557
|
+
return existsSync31(exe) ? exe : null;
|
|
20558
20558
|
}
|
|
20559
20559
|
const home = deps.homedir ?? import_os4.default.homedir();
|
|
20560
20560
|
const unix = import_path4.default.posix.join(home, ".local", "bin", "cursor-agent");
|
|
20561
|
-
return
|
|
20561
|
+
return existsSync31(unix) ? unix : null;
|
|
20562
20562
|
}
|
|
20563
20563
|
async function waitForCursorAgent(opts = {}) {
|
|
20564
20564
|
const timeoutMs = opts.timeoutMs ?? 18e4;
|
|
@@ -20644,8 +20644,8 @@ var AiderRuntimeStrategy = class {
|
|
|
20644
20644
|
meta = getAgent("aider");
|
|
20645
20645
|
mode = "interactive";
|
|
20646
20646
|
os;
|
|
20647
|
-
constructor(
|
|
20648
|
-
this.os =
|
|
20647
|
+
constructor(os67) {
|
|
20648
|
+
this.os = os67;
|
|
20649
20649
|
}
|
|
20650
20650
|
async prepareLaunch() {
|
|
20651
20651
|
augmentUserLocalBinPaths();
|
|
@@ -20778,8 +20778,8 @@ function geminiCredentialLocator() {
|
|
|
20778
20778
|
function geminiLoginLauncher() {
|
|
20779
20779
|
return {
|
|
20780
20780
|
async ensureInstalled() {
|
|
20781
|
-
const
|
|
20782
|
-
return
|
|
20781
|
+
const os67 = createOsStrategy();
|
|
20782
|
+
return os67.findInPath("gemini") !== null;
|
|
20783
20783
|
},
|
|
20784
20784
|
launch() {
|
|
20785
20785
|
return (0, import_node_child_process12.spawn)("gemini", ["auth", "login"], { stdio: "inherit" });
|
|
@@ -20969,8 +20969,8 @@ var GeminiRuntimeStrategy = class {
|
|
|
20969
20969
|
meta = getAgent("gemini");
|
|
20970
20970
|
mode = "interactive";
|
|
20971
20971
|
os;
|
|
20972
|
-
constructor(
|
|
20973
|
-
this.os =
|
|
20972
|
+
constructor(os67) {
|
|
20973
|
+
this.os = os67;
|
|
20974
20974
|
}
|
|
20975
20975
|
async prepareLaunch() {
|
|
20976
20976
|
const binary = this.os.findInPath("gemini");
|
|
@@ -21262,8 +21262,8 @@ var KimiRuntimeStrategy = class {
|
|
|
21262
21262
|
meta = getAgent("kimi");
|
|
21263
21263
|
mode = "interactive";
|
|
21264
21264
|
os;
|
|
21265
|
-
constructor(
|
|
21266
|
-
this.os =
|
|
21265
|
+
constructor(os67) {
|
|
21266
|
+
this.os = os67;
|
|
21267
21267
|
}
|
|
21268
21268
|
async prepareLaunch() {
|
|
21269
21269
|
const binary = this.os.findInPath("kimi");
|
|
@@ -21406,8 +21406,8 @@ var OpencodeRuntimeStrategy = class {
|
|
|
21406
21406
|
meta = getAgent("opencode");
|
|
21407
21407
|
mode = "interactive";
|
|
21408
21408
|
os;
|
|
21409
|
-
constructor(
|
|
21410
|
-
this.os =
|
|
21409
|
+
constructor(os67) {
|
|
21410
|
+
this.os = os67;
|
|
21411
21411
|
}
|
|
21412
21412
|
async prepareLaunch() {
|
|
21413
21413
|
const binary = this.os.findInPath("opencode");
|
|
@@ -21492,20 +21492,20 @@ var OpencodeRuntimeStrategy = class {
|
|
|
21492
21492
|
|
|
21493
21493
|
// src/agents/registry.ts
|
|
21494
21494
|
var runtimeBuilders = {
|
|
21495
|
-
claude: (
|
|
21496
|
-
codex: (
|
|
21497
|
-
coderabbit: (
|
|
21498
|
-
cursor: (
|
|
21499
|
-
aider: (
|
|
21500
|
-
gemini: (
|
|
21501
|
-
kimi: (
|
|
21502
|
-
opencode: (
|
|
21495
|
+
claude: (os67) => new ClaudeRuntimeStrategy(os67),
|
|
21496
|
+
codex: (os67) => new CodexRuntimeStrategy(os67),
|
|
21497
|
+
coderabbit: (os67) => new CoderabbitRuntimeStrategy(os67),
|
|
21498
|
+
cursor: (os67) => new CursorRuntimeStrategy(os67),
|
|
21499
|
+
aider: (os67) => new AiderRuntimeStrategy(os67),
|
|
21500
|
+
gemini: (os67) => new GeminiRuntimeStrategy(os67),
|
|
21501
|
+
kimi: (os67) => new KimiRuntimeStrategy(os67),
|
|
21502
|
+
opencode: (os67) => new OpencodeRuntimeStrategy(os67)
|
|
21503
21503
|
};
|
|
21504
21504
|
var deployBuilders = {
|
|
21505
21505
|
claude: () => new ClaudeDeployStrategy(),
|
|
21506
21506
|
codex: () => new CodexDeployStrategy()
|
|
21507
21507
|
};
|
|
21508
|
-
function createAgentStrategy(agent,
|
|
21508
|
+
function createAgentStrategy(agent, os67 = createOsStrategy()) {
|
|
21509
21509
|
if (!AGENT_REGISTRY[agent]?.enabled) {
|
|
21510
21510
|
throw new Error(
|
|
21511
21511
|
`Agent "${agent}" is not supported in this codeam-cli version. Upgrade with 'npm i -g codeam-cli@latest'.`
|
|
@@ -21515,10 +21515,10 @@ function createAgentStrategy(agent, os66 = createOsStrategy()) {
|
|
|
21515
21515
|
if (!build) {
|
|
21516
21516
|
throw new Error(`No runtime strategy registered for agent "${agent}"`);
|
|
21517
21517
|
}
|
|
21518
|
-
return build(
|
|
21518
|
+
return build(os67);
|
|
21519
21519
|
}
|
|
21520
|
-
function createInteractiveAgentStrategy(agent,
|
|
21521
|
-
const s = createAgentStrategy(agent,
|
|
21520
|
+
function createInteractiveAgentStrategy(agent, os67 = createOsStrategy()) {
|
|
21521
|
+
const s = createAgentStrategy(agent, os67);
|
|
21522
21522
|
if (s.mode !== "interactive") {
|
|
21523
21523
|
throw new Error(
|
|
21524
21524
|
`Agent "${agent}" is a batch agent; use createAgentStrategy + .runOneShot for one-shot reviews.`
|
|
@@ -22232,8 +22232,8 @@ function collectChangedFiles(cwd) {
|
|
|
22232
22232
|
}
|
|
22233
22233
|
return [...byPath.values()];
|
|
22234
22234
|
}
|
|
22235
|
-
function restoreCoderabbitOauthBlob(
|
|
22236
|
-
const dir = path38.join(
|
|
22235
|
+
function restoreCoderabbitOauthBlob(os67, value) {
|
|
22236
|
+
const dir = path38.join(os67.homeDir(), ".coderabbit");
|
|
22237
22237
|
(0, import_node_fs6.mkdirSync)(dir, { recursive: true });
|
|
22238
22238
|
let file = "auth.json";
|
|
22239
22239
|
let contents = value.trim();
|
|
@@ -22253,26 +22253,26 @@ function installFailureMessage(result) {
|
|
|
22253
22253
|
return result.error ?? "CodeRabbit CLI could not be installed";
|
|
22254
22254
|
}
|
|
22255
22255
|
async function configureCoderabbit(input, deps = {}) {
|
|
22256
|
-
const
|
|
22256
|
+
const os67 = deps.os ?? createOsStrategy();
|
|
22257
22257
|
const ensureInstalled = deps.ensureInstalled ?? ensureCoderabbitInstalled;
|
|
22258
22258
|
const isLoggedIn = deps.isLoggedIn ?? defaultIsLoggedIn;
|
|
22259
22259
|
const runOAuth = deps.runOAuthLogin ?? runCoderabbitOAuthLogin;
|
|
22260
22260
|
const snapshot = deps.snapshotDir ?? (() => snapshotCredentialDir());
|
|
22261
22261
|
const capture2 = deps.captureCredential ?? ((b) => diffCapturedCredential(b));
|
|
22262
22262
|
const loginWithApiKey = deps.loginWithApiKey ?? defaultLoginWithApiKey;
|
|
22263
|
-
const home =
|
|
22264
|
-
|
|
22265
|
-
|
|
22263
|
+
const home = os67.homeDir();
|
|
22264
|
+
os67.augmentPath(
|
|
22265
|
+
os67.id === "win32" ? [
|
|
22266
22266
|
path38.join(home, ".local", "bin"),
|
|
22267
22267
|
path38.join(process.env.APPDATA ?? path38.join(home, "AppData", "Roaming"), "npm"),
|
|
22268
22268
|
path38.join(home, "scoop", "shims")
|
|
22269
22269
|
] : [path38.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"]
|
|
22270
22270
|
);
|
|
22271
|
-
const installed2 =
|
|
22271
|
+
const installed2 = os67.findInPath("coderabbit") !== null;
|
|
22272
22272
|
const base = () => ({
|
|
22273
22273
|
action: input.action,
|
|
22274
22274
|
supported: true,
|
|
22275
|
-
installed:
|
|
22275
|
+
installed: os67.findInPath("coderabbit") !== null,
|
|
22276
22276
|
loggedIn: false
|
|
22277
22277
|
});
|
|
22278
22278
|
if (input.action === "status") {
|
|
@@ -22286,7 +22286,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22286
22286
|
const key = (input.apiKey ?? "").trim();
|
|
22287
22287
|
if (!key) return { ...res2, error: "No API key provided" };
|
|
22288
22288
|
if (!res2.installed) {
|
|
22289
|
-
const inst = await ensureInstalled(
|
|
22289
|
+
const inst = await ensureInstalled(os67);
|
|
22290
22290
|
res2.installed = inst.ok;
|
|
22291
22291
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
22292
22292
|
}
|
|
@@ -22310,7 +22310,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22310
22310
|
}
|
|
22311
22311
|
if (!res2.installed) {
|
|
22312
22312
|
deps.onEvent?.({ kind: "installing" });
|
|
22313
|
-
const inst = await ensureInstalled(
|
|
22313
|
+
const inst = await ensureInstalled(os67);
|
|
22314
22314
|
res2.installed = inst.ok;
|
|
22315
22315
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
22316
22316
|
}
|
|
@@ -22327,7 +22327,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22327
22327
|
return { ...res2, loggedIn: true, linked: true };
|
|
22328
22328
|
}
|
|
22329
22329
|
try {
|
|
22330
|
-
restoreCoderabbitOauthBlob(
|
|
22330
|
+
restoreCoderabbitOauthBlob(os67, cred.credential);
|
|
22331
22331
|
} catch (err) {
|
|
22332
22332
|
return {
|
|
22333
22333
|
...res2,
|
|
@@ -22351,7 +22351,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22351
22351
|
const res2 = base();
|
|
22352
22352
|
if (!installed2) {
|
|
22353
22353
|
deps.onEvent?.({ kind: "installing" });
|
|
22354
|
-
const inst = await ensureInstalled(
|
|
22354
|
+
const inst = await ensureInstalled(os67);
|
|
22355
22355
|
res2.installed = inst.ok;
|
|
22356
22356
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
22357
22357
|
}
|
|
@@ -22391,7 +22391,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22391
22391
|
}
|
|
22392
22392
|
const res = base();
|
|
22393
22393
|
if (!res.installed) {
|
|
22394
|
-
const inst = await ensureInstalled(
|
|
22394
|
+
const inst = await ensureInstalled(os67);
|
|
22395
22395
|
res.installed = inst.ok;
|
|
22396
22396
|
if (!inst.ok) return { ...res, error: installFailureMessage(inst) };
|
|
22397
22397
|
}
|
|
@@ -23344,7 +23344,7 @@ function tryParseObject(s) {
|
|
|
23344
23344
|
function extractFirstJsonObject(s) {
|
|
23345
23345
|
const start2 = s.indexOf("{");
|
|
23346
23346
|
if (start2 < 0) return null;
|
|
23347
|
-
let
|
|
23347
|
+
let depth2 = 0;
|
|
23348
23348
|
let inString = false;
|
|
23349
23349
|
let escaped = false;
|
|
23350
23350
|
for (let i = start2; i < s.length; i += 1) {
|
|
@@ -23365,10 +23365,10 @@ function extractFirstJsonObject(s) {
|
|
|
23365
23365
|
inString = true;
|
|
23366
23366
|
continue;
|
|
23367
23367
|
}
|
|
23368
|
-
if (c2 === "{")
|
|
23368
|
+
if (c2 === "{") depth2 += 1;
|
|
23369
23369
|
else if (c2 === "}") {
|
|
23370
|
-
|
|
23371
|
-
if (
|
|
23370
|
+
depth2 -= 1;
|
|
23371
|
+
if (depth2 === 0) return s.slice(start2, i + 1);
|
|
23372
23372
|
}
|
|
23373
23373
|
}
|
|
23374
23374
|
return null;
|
|
@@ -25779,11 +25779,11 @@ function resolveDoltInstallStrategy(platform3) {
|
|
|
25779
25779
|
}
|
|
25780
25780
|
var DOLT_RELEASE_BASE = "https://github.com/dolthub/dolt/releases/latest/download";
|
|
25781
25781
|
function doltPlatformTuple(platform3, arch2) {
|
|
25782
|
-
const
|
|
25782
|
+
const os67 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
|
|
25783
25783
|
const a = arch2 === "x64" ? "amd64" : arch2 === "arm64" ? "arm64" : null;
|
|
25784
25784
|
if (!a) return null;
|
|
25785
|
-
if (
|
|
25786
|
-
return `${
|
|
25785
|
+
if (os67 === "windows" && a !== "amd64") return null;
|
|
25786
|
+
return `${os67}-${a}`;
|
|
25787
25787
|
}
|
|
25788
25788
|
function resolveDoltTarballStrategy(targetDir, platform3, arch2) {
|
|
25789
25789
|
const tuple = doltPlatformTuple(platform3, arch2);
|
|
@@ -27472,7 +27472,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
27472
27472
|
});
|
|
27473
27473
|
const token = ctx.pluginAuthToken;
|
|
27474
27474
|
void (async () => {
|
|
27475
|
-
const
|
|
27475
|
+
const os67 = createOsStrategy();
|
|
27476
27476
|
try {
|
|
27477
27477
|
const report = await reviewPullRequest(
|
|
27478
27478
|
{
|
|
@@ -27481,7 +27481,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
27481
27481
|
baseBranch: parsed.baseBranch
|
|
27482
27482
|
},
|
|
27483
27483
|
{
|
|
27484
|
-
runReview: (input) => new CoderabbitRuntimeStrategy(
|
|
27484
|
+
runReview: (input) => new CoderabbitRuntimeStrategy(os67).runOneShot(input),
|
|
27485
27485
|
runGh: (args2) => defaultRunGh(args2),
|
|
27486
27486
|
postReport: async (r) => {
|
|
27487
27487
|
if (!token) return;
|
|
@@ -27621,7 +27621,7 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
|
27621
27621
|
if (!nodeModulesDir) return 0;
|
|
27622
27622
|
const readdirSync14 = deps?.readdirSync ?? fs51.readdirSync;
|
|
27623
27623
|
const statSync15 = deps?.statSync ?? fs51.statSync;
|
|
27624
|
-
const
|
|
27624
|
+
const rmSync10 = deps?.rmSync ?? fs51.rmSync;
|
|
27625
27625
|
let removed = 0;
|
|
27626
27626
|
let entries;
|
|
27627
27627
|
try {
|
|
@@ -27635,7 +27635,7 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
|
27635
27635
|
try {
|
|
27636
27636
|
const st3 = statSync15(full);
|
|
27637
27637
|
if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
|
|
27638
|
-
|
|
27638
|
+
rmSync10(full, { recursive: true, force: true });
|
|
27639
27639
|
removed++;
|
|
27640
27640
|
} catch {
|
|
27641
27641
|
}
|
|
@@ -28661,11 +28661,11 @@ function resolveTokenValue(args2) {
|
|
|
28661
28661
|
}
|
|
28662
28662
|
const fileFlag = args2.find((a) => a.startsWith("--token-file="));
|
|
28663
28663
|
if (fileFlag) {
|
|
28664
|
-
const
|
|
28664
|
+
const path98 = fileFlag.slice("--token-file=".length);
|
|
28665
28665
|
try {
|
|
28666
|
-
const content = fs52.readFileSync(
|
|
28667
|
-
if (content.length === 0) fail(`--token-file ${
|
|
28668
|
-
rmIfExistsQuiet(
|
|
28666
|
+
const content = fs52.readFileSync(path98, "utf8").trim();
|
|
28667
|
+
if (content.length === 0) fail(`--token-file ${path98} is empty`);
|
|
28668
|
+
rmIfExistsQuiet(path98);
|
|
28669
28669
|
return content;
|
|
28670
28670
|
} catch (err) {
|
|
28671
28671
|
fail(`Could not read --token-file: ${err.message}`);
|
|
@@ -29758,9 +29758,9 @@ async function prepareWorkspace(repoOrPath, deployId, cloneToken, provider = "gi
|
|
|
29758
29758
|
|
|
29759
29759
|
// src/agents/acp/runner.ts
|
|
29760
29760
|
var import_node_crypto11 = require("crypto");
|
|
29761
|
-
var
|
|
29762
|
-
var
|
|
29763
|
-
var
|
|
29761
|
+
var fs72 = __toESM(require("fs"));
|
|
29762
|
+
var os56 = __toESM(require("os"));
|
|
29763
|
+
var path83 = __toESM(require("path"));
|
|
29764
29764
|
|
|
29765
29765
|
// src/lib/provider-routing.ts
|
|
29766
29766
|
var fs55 = __toESM(require("fs"));
|
|
@@ -37725,6 +37725,7 @@ var import_crypto4 = require("crypto");
|
|
|
37725
37725
|
// src/services/turn-files/git-changeset.ts
|
|
37726
37726
|
var import_child_process29 = require("child_process");
|
|
37727
37727
|
var fs63 = __toESM(require("fs/promises"));
|
|
37728
|
+
var import_fs7 = require("fs");
|
|
37728
37729
|
var path74 = __toESM(require("path"));
|
|
37729
37730
|
|
|
37730
37731
|
// src/services/turn-files/review-ignore.ts
|
|
@@ -37764,7 +37765,12 @@ var CURATED_REVIEW_IGNORE = [
|
|
|
37764
37765
|
"awscli/",
|
|
37765
37766
|
// CodeAgent's own runtime prefixes (never a user change).
|
|
37766
37767
|
".codeam/",
|
|
37767
|
-
"codeam-node20/"
|
|
37768
|
+
"codeam-node20/",
|
|
37769
|
+
// Beads (issue tracker + agent memory) and its Dolt store — our tooling's
|
|
37770
|
+
// state, written on every bd op; it showed up as `.beads/issues.jsonl` in
|
|
37771
|
+
// the user's review (break-it 2026-09-26).
|
|
37772
|
+
".beads/",
|
|
37773
|
+
".dolt/"
|
|
37768
37774
|
];
|
|
37769
37775
|
function makeReviewIgnore(repoRoot) {
|
|
37770
37776
|
const ig = (0, import_ignore2.default)().add(CURATED_REVIEW_IGNORE);
|
|
@@ -37786,7 +37792,12 @@ function makeReviewIgnore(repoRoot) {
|
|
|
37786
37792
|
|
|
37787
37793
|
// src/services/turn-files/git-changeset.ts
|
|
37788
37794
|
async function collectRepoChangeset(opts) {
|
|
37789
|
-
const status2 = await runGit3(opts.repoRoot, [
|
|
37795
|
+
const status2 = await runGit3(opts.repoRoot, [
|
|
37796
|
+
"status",
|
|
37797
|
+
"--porcelain=v1",
|
|
37798
|
+
"-z",
|
|
37799
|
+
"--untracked-files=all"
|
|
37800
|
+
]);
|
|
37790
37801
|
if (status2 === null) return null;
|
|
37791
37802
|
const numstatRaw = await runGit3(opts.repoRoot, [
|
|
37792
37803
|
"diff",
|
|
@@ -37797,7 +37808,9 @@ async function collectRepoChangeset(opts) {
|
|
|
37797
37808
|
const numstat = parseNumstat(numstatRaw ?? "");
|
|
37798
37809
|
const reviewIgnore = makeReviewIgnore(opts.repoRoot);
|
|
37799
37810
|
const rows = parseStatus(status2).filter(
|
|
37800
|
-
(row) => !isIgnoredFilePath(row.filePath) && !reviewIgnore(row.filePath)
|
|
37811
|
+
(row) => !isIgnoredFilePath(row.filePath) && !reviewIgnore(row.filePath) && // A socket, FIFO or device node is never a change to review (a
|
|
37812
|
+
// `cc-socks/1522.sock` reached the Files tab).
|
|
37813
|
+
isReviewablePath(path74.join(opts.repoRoot, row.filePath))
|
|
37801
37814
|
);
|
|
37802
37815
|
const MAX_CHANGESET_FILES = Math.max(1, Number(process.env.CODEAM_MAX_CHANGESET_FILES ?? 500));
|
|
37803
37816
|
const truncated = rows.length > MAX_CHANGESET_FILES;
|
|
@@ -37937,15 +37950,15 @@ function defaultRunGit(cwd, args2) {
|
|
|
37937
37950
|
});
|
|
37938
37951
|
}
|
|
37939
37952
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
37940
|
-
const
|
|
37953
|
+
const fs83 = await import("fs/promises");
|
|
37941
37954
|
const out2 = [];
|
|
37942
37955
|
await walk(workingDir, 0);
|
|
37943
37956
|
return out2;
|
|
37944
|
-
async function walk(dir,
|
|
37945
|
-
if (
|
|
37957
|
+
async function walk(dir, depth2) {
|
|
37958
|
+
if (depth2 > maxDepth) return;
|
|
37946
37959
|
let entries = [];
|
|
37947
37960
|
try {
|
|
37948
|
-
const dirents = await
|
|
37961
|
+
const dirents = await fs83.readdir(dir, { withFileTypes: true });
|
|
37949
37962
|
entries = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
37950
37963
|
} catch {
|
|
37951
37964
|
return;
|
|
@@ -37965,10 +37978,18 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
37965
37978
|
if (!entry.isDirectory) continue;
|
|
37966
37979
|
if (entry.name === "node_modules") continue;
|
|
37967
37980
|
if (entry.name === "dist" || entry.name === "build") continue;
|
|
37968
|
-
await walk(path74.join(dir, entry.name),
|
|
37981
|
+
await walk(path74.join(dir, entry.name), depth2 + 1);
|
|
37969
37982
|
}
|
|
37970
37983
|
}
|
|
37971
37984
|
}
|
|
37985
|
+
function isReviewablePath(absPath) {
|
|
37986
|
+
try {
|
|
37987
|
+
const st3 = (0, import_fs7.lstatSync)(absPath);
|
|
37988
|
+
return st3.isFile() || st3.isSymbolicLink();
|
|
37989
|
+
} catch {
|
|
37990
|
+
return true;
|
|
37991
|
+
}
|
|
37992
|
+
}
|
|
37972
37993
|
|
|
37973
37994
|
// src/services/turn-files/files-outbox.ts
|
|
37974
37995
|
var fs64 = __toESM(require("fs/promises"));
|
|
@@ -38680,10 +38701,52 @@ async function postCredentialSync(opts, fetchImpl = fetch) {
|
|
|
38680
38701
|
}
|
|
38681
38702
|
}
|
|
38682
38703
|
|
|
38683
|
-
// src/
|
|
38684
|
-
var import_node_child_process23 = require("child_process");
|
|
38704
|
+
// src/services/turn-marker.ts
|
|
38685
38705
|
var fs65 = __toESM(require("fs"));
|
|
38706
|
+
var os52 = __toESM(require("os"));
|
|
38686
38707
|
var path76 = __toESM(require("path"));
|
|
38708
|
+
var depth = 0;
|
|
38709
|
+
function codeamHome() {
|
|
38710
|
+
return path76.join(os52.homedir(), ".codeam");
|
|
38711
|
+
}
|
|
38712
|
+
function turnMarkerPath(pid = process.pid, home = codeamHome()) {
|
|
38713
|
+
return path76.join(home, "turns", String(pid));
|
|
38714
|
+
}
|
|
38715
|
+
function mark() {
|
|
38716
|
+
try {
|
|
38717
|
+
const file = turnMarkerPath();
|
|
38718
|
+
fs65.mkdirSync(path76.dirname(file), { recursive: true });
|
|
38719
|
+
fs65.writeFileSync(file, String(Date.now()));
|
|
38720
|
+
} catch {
|
|
38721
|
+
}
|
|
38722
|
+
}
|
|
38723
|
+
function clear() {
|
|
38724
|
+
try {
|
|
38725
|
+
fs65.rmSync(turnMarkerPath(), { force: true });
|
|
38726
|
+
} catch {
|
|
38727
|
+
}
|
|
38728
|
+
}
|
|
38729
|
+
async function withTurnMarker(fn) {
|
|
38730
|
+
if (depth++ === 0) mark();
|
|
38731
|
+
try {
|
|
38732
|
+
return await fn();
|
|
38733
|
+
} finally {
|
|
38734
|
+
if (--depth === 0) clear();
|
|
38735
|
+
}
|
|
38736
|
+
}
|
|
38737
|
+
function isProcessMidTurn(pid, home) {
|
|
38738
|
+
if (!pid) return false;
|
|
38739
|
+
try {
|
|
38740
|
+
return fs65.existsSync(turnMarkerPath(pid, home));
|
|
38741
|
+
} catch {
|
|
38742
|
+
return false;
|
|
38743
|
+
}
|
|
38744
|
+
}
|
|
38745
|
+
|
|
38746
|
+
// src/packs/gates.ts
|
|
38747
|
+
var import_node_child_process23 = require("child_process");
|
|
38748
|
+
var fs66 = __toESM(require("fs"));
|
|
38749
|
+
var path77 = __toESM(require("path"));
|
|
38687
38750
|
var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((resolve12) => {
|
|
38688
38751
|
(0, import_node_child_process23.execFile)(
|
|
38689
38752
|
file,
|
|
@@ -38733,7 +38796,7 @@ async function changedFiles(run, cwd, from, to) {
|
|
|
38733
38796
|
}
|
|
38734
38797
|
function readWorkspaceFile(cwd, relPath) {
|
|
38735
38798
|
try {
|
|
38736
|
-
return
|
|
38799
|
+
return fs66.readFileSync(path77.join(cwd, relPath), "utf8");
|
|
38737
38800
|
} catch {
|
|
38738
38801
|
return null;
|
|
38739
38802
|
}
|
|
@@ -38742,14 +38805,14 @@ var NO_TEST_PLACEHOLDER = 'echo "Error: no test specified"';
|
|
|
38742
38805
|
var CHECKS_TIMEOUT_MS = 5 * 6e4;
|
|
38743
38806
|
function detectChecksCommand(cwd) {
|
|
38744
38807
|
try {
|
|
38745
|
-
const cfg = JSON.parse(
|
|
38808
|
+
const cfg = JSON.parse(fs66.readFileSync(path77.join(cwd, ".codeam", "pack.json"), "utf8"));
|
|
38746
38809
|
if (typeof cfg.checksCommand === "string" && cfg.checksCommand.trim().length > 0) {
|
|
38747
38810
|
return cfg.checksCommand.trim();
|
|
38748
38811
|
}
|
|
38749
38812
|
} catch {
|
|
38750
38813
|
}
|
|
38751
38814
|
try {
|
|
38752
|
-
const pkg = JSON.parse(
|
|
38815
|
+
const pkg = JSON.parse(fs66.readFileSync(path77.join(cwd, "package.json"), "utf8"));
|
|
38753
38816
|
const test = pkg.scripts?.test;
|
|
38754
38817
|
if (typeof test === "string" && test.trim().length > 0 && !test.includes(NO_TEST_PLACEHOLDER)) {
|
|
38755
38818
|
return "npm test";
|
|
@@ -38767,39 +38830,39 @@ ${res.stderr}`.trim();
|
|
|
38767
38830
|
}
|
|
38768
38831
|
|
|
38769
38832
|
// src/packs/run-store.ts
|
|
38770
|
-
var
|
|
38771
|
-
var
|
|
38833
|
+
var fs67 = __toESM(require("fs"));
|
|
38834
|
+
var path78 = __toESM(require("path"));
|
|
38772
38835
|
var crypto5 = __toESM(require("crypto"));
|
|
38773
38836
|
function packsDir(cwd) {
|
|
38774
|
-
return
|
|
38837
|
+
return path78.join(cwd, ".codeam", "packs");
|
|
38775
38838
|
}
|
|
38776
38839
|
function runDir(cwd, runId) {
|
|
38777
|
-
return
|
|
38840
|
+
return path78.join(packsDir(cwd), runId);
|
|
38778
38841
|
}
|
|
38779
38842
|
function newRunId() {
|
|
38780
38843
|
return `pk_${Date.now().toString(36)}_${crypto5.randomBytes(4).toString("hex")}`;
|
|
38781
38844
|
}
|
|
38782
38845
|
function writeJsonAtomic(file, value) {
|
|
38783
|
-
|
|
38846
|
+
fs67.mkdirSync(path78.dirname(file), { recursive: true });
|
|
38784
38847
|
const tmp = `${file}.tmp`;
|
|
38785
|
-
|
|
38786
|
-
|
|
38848
|
+
fs67.writeFileSync(tmp, JSON.stringify(value, null, 2));
|
|
38849
|
+
fs67.renameSync(tmp, file);
|
|
38787
38850
|
}
|
|
38788
38851
|
function saveRun(cwd, state) {
|
|
38789
|
-
writeJsonAtomic(
|
|
38852
|
+
writeJsonAtomic(path78.join(runDir(cwd, state.runId), "run.json"), state);
|
|
38790
38853
|
}
|
|
38791
38854
|
function saveStageHandoff(cwd, runId, stageIndex, role, handoff) {
|
|
38792
38855
|
const name = `${String(stageIndex + 1).padStart(2, "0")}-${role}.json`;
|
|
38793
|
-
writeJsonAtomic(
|
|
38856
|
+
writeJsonAtomic(path78.join(runDir(cwd, runId), name), handoff);
|
|
38794
38857
|
}
|
|
38795
38858
|
function loadLatestRun(cwd) {
|
|
38796
38859
|
try {
|
|
38797
38860
|
const dir = packsDir(cwd);
|
|
38798
|
-
const entries =
|
|
38861
|
+
const entries = fs67.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
38799
38862
|
for (let i = entries.length - 1; i >= 0; i--) {
|
|
38800
|
-
const file =
|
|
38863
|
+
const file = path78.join(dir, entries[i], "run.json");
|
|
38801
38864
|
try {
|
|
38802
|
-
const parsed = JSON.parse(
|
|
38865
|
+
const parsed = JSON.parse(fs67.readFileSync(file, "utf8"));
|
|
38803
38866
|
if (parsed && typeof parsed.runId === "string") return parsed;
|
|
38804
38867
|
} catch {
|
|
38805
38868
|
}
|
|
@@ -38810,17 +38873,17 @@ function loadLatestRun(cwd) {
|
|
|
38810
38873
|
}
|
|
38811
38874
|
function ensureLedgerIgnored(cwd) {
|
|
38812
38875
|
try {
|
|
38813
|
-
const gitDir =
|
|
38814
|
-
if (!
|
|
38815
|
-
const exclude =
|
|
38876
|
+
const gitDir = path78.join(cwd, ".git");
|
|
38877
|
+
if (!fs67.existsSync(gitDir)) return;
|
|
38878
|
+
const exclude = path78.join(gitDir, "info", "exclude");
|
|
38816
38879
|
let existing = "";
|
|
38817
38880
|
try {
|
|
38818
|
-
existing =
|
|
38881
|
+
existing = fs67.readFileSync(exclude, "utf8");
|
|
38819
38882
|
} catch {
|
|
38820
38883
|
}
|
|
38821
38884
|
if (existing.includes(".codeam/packs/")) return;
|
|
38822
|
-
|
|
38823
|
-
|
|
38885
|
+
fs67.mkdirSync(path78.dirname(exclude), { recursive: true });
|
|
38886
|
+
fs67.writeFileSync(exclude, `${existing.trimEnd()}
|
|
38824
38887
|
.codeam/packs/
|
|
38825
38888
|
`.trimStart());
|
|
38826
38889
|
} catch {
|
|
@@ -39801,20 +39864,20 @@ async function mcpRouter() {
|
|
|
39801
39864
|
}
|
|
39802
39865
|
|
|
39803
39866
|
// src/integrations/mcp-secrets.ts
|
|
39804
|
-
var
|
|
39805
|
-
var
|
|
39806
|
-
var
|
|
39867
|
+
var fs69 = __toESM(require("fs"));
|
|
39868
|
+
var os54 = __toESM(require("os"));
|
|
39869
|
+
var path80 = __toESM(require("path"));
|
|
39807
39870
|
var MCP_SECRETS_FILE_ENV = "CODEAM_MCP_SECRETS_FILE";
|
|
39808
39871
|
function mcpSecretsDir() {
|
|
39809
|
-
return
|
|
39872
|
+
return path80.join(os54.homedir(), ".codeam", "mcp-secrets");
|
|
39810
39873
|
}
|
|
39811
39874
|
function mcpSecretsPath(scope, pid = process.pid) {
|
|
39812
|
-
return
|
|
39875
|
+
return path80.join(mcpSecretsDir(), `${pid}-${scope}.json`);
|
|
39813
39876
|
}
|
|
39814
39877
|
var registeredForCleanup = /* @__PURE__ */ new Set();
|
|
39815
39878
|
function readFileVars(file) {
|
|
39816
39879
|
try {
|
|
39817
|
-
const parsed = JSON.parse(
|
|
39880
|
+
const parsed = JSON.parse(fs69.readFileSync(file, "utf8"));
|
|
39818
39881
|
if (!parsed || typeof parsed !== "object") return {};
|
|
39819
39882
|
const out2 = {};
|
|
39820
39883
|
for (const [k2, v] of Object.entries(parsed)) {
|
|
@@ -39836,7 +39899,7 @@ function pidAlive(pid) {
|
|
|
39836
39899
|
function pruneStale(dir) {
|
|
39837
39900
|
let names = [];
|
|
39838
39901
|
try {
|
|
39839
|
-
names =
|
|
39902
|
+
names = fs69.readdirSync(dir);
|
|
39840
39903
|
} catch {
|
|
39841
39904
|
return;
|
|
39842
39905
|
}
|
|
@@ -39846,25 +39909,25 @@ function pruneStale(dir) {
|
|
|
39846
39909
|
const pid = Number(m[1]);
|
|
39847
39910
|
if (pid === process.pid || pidAlive(pid)) continue;
|
|
39848
39911
|
try {
|
|
39849
|
-
|
|
39912
|
+
fs69.unlinkSync(path80.join(dir, name));
|
|
39850
39913
|
} catch {
|
|
39851
39914
|
}
|
|
39852
39915
|
}
|
|
39853
39916
|
}
|
|
39854
39917
|
function writeMcpSecrets(vars, file) {
|
|
39855
39918
|
try {
|
|
39856
|
-
const dir =
|
|
39857
|
-
|
|
39919
|
+
const dir = path80.dirname(file);
|
|
39920
|
+
fs69.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
39858
39921
|
pruneStale(dir);
|
|
39859
39922
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
39860
|
-
|
|
39861
|
-
|
|
39862
|
-
|
|
39923
|
+
fs69.writeFileSync(tmp, JSON.stringify(vars), { mode: 384 });
|
|
39924
|
+
fs69.renameSync(tmp, file);
|
|
39925
|
+
fs69.chmodSync(file, 384);
|
|
39863
39926
|
if (!registeredForCleanup.has(file)) {
|
|
39864
39927
|
registeredForCleanup.add(file);
|
|
39865
39928
|
process.once("exit", () => {
|
|
39866
39929
|
try {
|
|
39867
|
-
|
|
39930
|
+
fs69.unlinkSync(file);
|
|
39868
39931
|
} catch {
|
|
39869
39932
|
}
|
|
39870
39933
|
});
|
|
@@ -39950,11 +40013,11 @@ function previewMcpServer(bridge) {
|
|
|
39950
40013
|
};
|
|
39951
40014
|
}
|
|
39952
40015
|
function httpCall(baseUrl, token) {
|
|
39953
|
-
return async (
|
|
40016
|
+
return async (path98, method, body, timeoutMs) => {
|
|
39954
40017
|
const ac = new AbortController();
|
|
39955
40018
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
39956
40019
|
try {
|
|
39957
|
-
const res = await fetch(`${baseUrl}${
|
|
40020
|
+
const res = await fetch(`${baseUrl}${path98}`, {
|
|
39958
40021
|
method,
|
|
39959
40022
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
39960
40023
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -41725,8 +41788,8 @@ var ACP_COMMAND_HANDLERS = {
|
|
|
41725
41788
|
integrations_sync: integrationsSyncH,
|
|
41726
41789
|
integrations_detect: integrationsDetectH,
|
|
41727
41790
|
beads_action: beadsActionH,
|
|
41728
|
-
start_task: startTaskH,
|
|
41729
|
-
group_mention_task: groupMentionTaskH,
|
|
41791
|
+
start_task: (ctx) => withTurnMarker(() => startTaskH(ctx)),
|
|
41792
|
+
group_mention_task: (ctx) => withTurnMarker(() => groupMentionTaskH(ctx)),
|
|
41730
41793
|
stop_task: stopTaskH,
|
|
41731
41794
|
escape_key: stopTaskH,
|
|
41732
41795
|
get_conversation: getConversationH,
|
|
@@ -41738,7 +41801,7 @@ var ACP_COMMAND_HANDLERS = {
|
|
|
41738
41801
|
select_option: selectOptionH,
|
|
41739
41802
|
provide_input: provideInputH,
|
|
41740
41803
|
resume_session: resumeSessionH,
|
|
41741
|
-
switch_agent: switchAgentH,
|
|
41804
|
+
switch_agent: (ctx) => withTurnMarker(() => switchAgentH(ctx)),
|
|
41742
41805
|
change_model: changeModelH,
|
|
41743
41806
|
summarize: summarizeH,
|
|
41744
41807
|
session_terminated: sessionShutdownH,
|
|
@@ -42850,17 +42913,17 @@ async function runAcpSession(opts) {
|
|
|
42850
42913
|
switchCredentialEnv = provisionAgentCredentials(agentId, auth);
|
|
42851
42914
|
},
|
|
42852
42915
|
provisionHouseProxy: ({ baseUrl, token, model, managedAgentId }) => {
|
|
42853
|
-
const claudeConfigDir =
|
|
42854
|
-
|
|
42916
|
+
const claudeConfigDir = path83.join(
|
|
42917
|
+
os56.homedir(),
|
|
42855
42918
|
".codeam",
|
|
42856
42919
|
"house-claude",
|
|
42857
42920
|
`switch-${opts.pluginId}`
|
|
42858
42921
|
);
|
|
42859
42922
|
try {
|
|
42860
|
-
|
|
42923
|
+
fs72.mkdirSync(claudeConfigDir, { recursive: true, mode: 448 });
|
|
42861
42924
|
} catch {
|
|
42862
42925
|
}
|
|
42863
|
-
const memoryFile =
|
|
42926
|
+
const memoryFile = path83.join(claudeConfigDir, "CLAUDE.md");
|
|
42864
42927
|
ensureBeadsWorkflowHint(void 0, memoryFile);
|
|
42865
42928
|
ensureAgentStandard(void 0, memoryFile);
|
|
42866
42929
|
const cfg = {
|
|
@@ -44088,9 +44151,9 @@ function pickPinnedSession(pinnedId, listSessions2) {
|
|
|
44088
44151
|
}
|
|
44089
44152
|
|
|
44090
44153
|
// src/agents/retired-proxy-cleanup.ts
|
|
44091
|
-
var
|
|
44092
|
-
var
|
|
44093
|
-
var
|
|
44154
|
+
var fs73 = __toESM(require("fs"));
|
|
44155
|
+
var path84 = __toESM(require("path"));
|
|
44156
|
+
var os57 = __toESM(require("os"));
|
|
44094
44157
|
var RETIRED_PROXY_RE = /^https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):8787(?:[/?#]|$)/i;
|
|
44095
44158
|
var HEADROOM_CMD_RE = /(^|[\s/"'])headroom(\s|$)/i;
|
|
44096
44159
|
var MARKETPLACE_KEY = "headroom-marketplace";
|
|
@@ -44099,12 +44162,12 @@ function isHeadroomHook(group) {
|
|
|
44099
44162
|
(h) => typeof h?.command === "string" && HEADROOM_CMD_RE.test(h.command)
|
|
44100
44163
|
);
|
|
44101
44164
|
}
|
|
44102
|
-
function sanitizeRetiredProxyConfig(homeDir2 =
|
|
44165
|
+
function sanitizeRetiredProxyConfig(homeDir2 = os57.homedir()) {
|
|
44103
44166
|
const out2 = { inspected: false, changed: false, removed: [] };
|
|
44104
|
-
const file =
|
|
44167
|
+
const file = path84.join(homeDir2, ".claude", "settings.json");
|
|
44105
44168
|
let parsed;
|
|
44106
44169
|
try {
|
|
44107
|
-
parsed = JSON.parse(
|
|
44170
|
+
parsed = JSON.parse(fs73.readFileSync(file, "utf8"));
|
|
44108
44171
|
} catch {
|
|
44109
44172
|
return out2;
|
|
44110
44173
|
}
|
|
@@ -44146,9 +44209,9 @@ function sanitizeRetiredProxyConfig(homeDir2 = os56.homedir()) {
|
|
|
44146
44209
|
if (!out2.changed) return out2;
|
|
44147
44210
|
try {
|
|
44148
44211
|
const tmp = `${file}.codeam.tmp`;
|
|
44149
|
-
|
|
44212
|
+
fs73.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
|
|
44150
44213
|
`, { mode: 384 });
|
|
44151
|
-
|
|
44214
|
+
fs73.renameSync(tmp, file);
|
|
44152
44215
|
} catch {
|
|
44153
44216
|
out2.changed = false;
|
|
44154
44217
|
}
|
|
@@ -44680,7 +44743,7 @@ var AcpDriver = class {
|
|
|
44680
44743
|
};
|
|
44681
44744
|
|
|
44682
44745
|
// src/baton/transcript-mirror.ts
|
|
44683
|
-
var
|
|
44746
|
+
var fs74 = __toESM(require("fs"));
|
|
44684
44747
|
var TranscriptMirror = class {
|
|
44685
44748
|
constructor(deps) {
|
|
44686
44749
|
this.deps = deps;
|
|
@@ -44774,7 +44837,7 @@ var TranscriptMirror = class {
|
|
|
44774
44837
|
}
|
|
44775
44838
|
};
|
|
44776
44839
|
function defaultWatch(file, onChange) {
|
|
44777
|
-
const w3 =
|
|
44840
|
+
const w3 = fs74.watch(file, { persistent: false }, () => onChange());
|
|
44778
44841
|
return () => w3.close();
|
|
44779
44842
|
}
|
|
44780
44843
|
|
|
@@ -45120,16 +45183,16 @@ function keepDeviceAwake(deps = {}) {
|
|
|
45120
45183
|
}
|
|
45121
45184
|
|
|
45122
45185
|
// src/agents/claude/onboarding.ts
|
|
45123
|
-
var
|
|
45124
|
-
var
|
|
45125
|
-
var
|
|
45186
|
+
var fs75 = __toESM(require("fs"));
|
|
45187
|
+
var os59 = __toESM(require("os"));
|
|
45188
|
+
var path85 = __toESM(require("path"));
|
|
45126
45189
|
var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
|
|
45127
45190
|
function ensureClaudeOnboarded(cwd) {
|
|
45128
45191
|
try {
|
|
45129
|
-
const file =
|
|
45192
|
+
const file = path85.join(os59.homedir(), ".claude.json");
|
|
45130
45193
|
let config = {};
|
|
45131
45194
|
try {
|
|
45132
|
-
config = JSON.parse(
|
|
45195
|
+
config = JSON.parse(fs75.readFileSync(file, "utf8"));
|
|
45133
45196
|
} catch {
|
|
45134
45197
|
}
|
|
45135
45198
|
let changed = false;
|
|
@@ -45154,8 +45217,8 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
45154
45217
|
}
|
|
45155
45218
|
}
|
|
45156
45219
|
if (!changed) return;
|
|
45157
|
-
|
|
45158
|
-
|
|
45220
|
+
fs75.mkdirSync(path85.dirname(file), { recursive: true });
|
|
45221
|
+
fs75.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
45159
45222
|
log.info(
|
|
45160
45223
|
"claude",
|
|
45161
45224
|
`pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
|
|
@@ -45932,7 +45995,7 @@ var import_picocolors10 = __toESM(require("picocolors"));
|
|
|
45932
45995
|
var import_child_process30 = require("child_process");
|
|
45933
45996
|
var import_util4 = require("util");
|
|
45934
45997
|
var import_picocolors8 = __toESM(require("picocolors"));
|
|
45935
|
-
var
|
|
45998
|
+
var path86 = __toESM(require("path"));
|
|
45936
45999
|
var execFileP6 = (0, import_util4.promisify)(import_child_process30.execFile);
|
|
45937
46000
|
var MAX_BUFFER = 8 * 1024 * 1024;
|
|
45938
46001
|
function resetStdinForChild() {
|
|
@@ -46421,7 +46484,7 @@ var GitHubCodespacesProvider = class {
|
|
|
46421
46484
|
});
|
|
46422
46485
|
}
|
|
46423
46486
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
46424
|
-
const remoteDir =
|
|
46487
|
+
const remoteDir = path86.posix.dirname(remotePath);
|
|
46425
46488
|
const parts = [
|
|
46426
46489
|
`mkdir -p ${shellQuote(remoteDir)}`,
|
|
46427
46490
|
`cat > ${shellQuote(remotePath)}`
|
|
@@ -46491,7 +46554,7 @@ function shellQuote(s) {
|
|
|
46491
46554
|
// src/services/providers/gitpod.ts
|
|
46492
46555
|
var import_child_process31 = require("child_process");
|
|
46493
46556
|
var import_util5 = require("util");
|
|
46494
|
-
var
|
|
46557
|
+
var path87 = __toESM(require("path"));
|
|
46495
46558
|
var import_picocolors9 = __toESM(require("picocolors"));
|
|
46496
46559
|
var execFileP7 = (0, import_util5.promisify)(import_child_process31.execFile);
|
|
46497
46560
|
var MAX_BUFFER2 = 8 * 1024 * 1024;
|
|
@@ -46731,7 +46794,7 @@ var GitpodProvider = class {
|
|
|
46731
46794
|
});
|
|
46732
46795
|
}
|
|
46733
46796
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
46734
|
-
const remoteDir =
|
|
46797
|
+
const remoteDir = path87.posix.dirname(remotePath);
|
|
46735
46798
|
const parts = [
|
|
46736
46799
|
`mkdir -p ${shellQuote2(remoteDir)}`,
|
|
46737
46800
|
`cat > ${shellQuote2(remotePath)}`
|
|
@@ -46767,7 +46830,7 @@ function shellQuote2(s) {
|
|
|
46767
46830
|
// src/services/providers/gitlab-workspaces.ts
|
|
46768
46831
|
var import_child_process32 = require("child_process");
|
|
46769
46832
|
var import_util6 = require("util");
|
|
46770
|
-
var
|
|
46833
|
+
var path88 = __toESM(require("path"));
|
|
46771
46834
|
var execFileP8 = (0, import_util6.promisify)(import_child_process32.execFile);
|
|
46772
46835
|
var MAX_BUFFER3 = 8 * 1024 * 1024;
|
|
46773
46836
|
var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
|
|
@@ -47027,7 +47090,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
47027
47090
|
}
|
|
47028
47091
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
47029
47092
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
47030
|
-
const remoteDir =
|
|
47093
|
+
const remoteDir = path88.posix.dirname(remotePath);
|
|
47031
47094
|
const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
|
|
47032
47095
|
if (options.mode != null) {
|
|
47033
47096
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
@@ -47095,7 +47158,7 @@ function shellQuote3(s) {
|
|
|
47095
47158
|
// src/services/providers/railway.ts
|
|
47096
47159
|
var import_child_process33 = require("child_process");
|
|
47097
47160
|
var import_util7 = require("util");
|
|
47098
|
-
var
|
|
47161
|
+
var path89 = __toESM(require("path"));
|
|
47099
47162
|
var execFileP9 = (0, import_util7.promisify)(import_child_process33.execFile);
|
|
47100
47163
|
var MAX_BUFFER4 = 8 * 1024 * 1024;
|
|
47101
47164
|
function resetStdinForChild4() {
|
|
@@ -47331,7 +47394,7 @@ var RailwayProvider = class {
|
|
|
47331
47394
|
if (!projectId || !serviceId) {
|
|
47332
47395
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
47333
47396
|
}
|
|
47334
|
-
const remoteDir =
|
|
47397
|
+
const remoteDir = path89.posix.dirname(remotePath);
|
|
47335
47398
|
const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
|
|
47336
47399
|
if (options.mode != null) {
|
|
47337
47400
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
@@ -47871,14 +47934,14 @@ async function stopWorkspaceFromLocal(target) {
|
|
|
47871
47934
|
}
|
|
47872
47935
|
|
|
47873
47936
|
// src/commands/host/host-client.ts
|
|
47874
|
-
var
|
|
47875
|
-
var
|
|
47876
|
-
var
|
|
47937
|
+
var fs76 = __toESM(require("fs"));
|
|
47938
|
+
var os60 = __toESM(require("os"));
|
|
47939
|
+
var path90 = __toESM(require("path"));
|
|
47877
47940
|
var import_node_crypto12 = require("crypto");
|
|
47878
47941
|
function sampleCpuTimes() {
|
|
47879
47942
|
let idle = 0;
|
|
47880
47943
|
let total = 0;
|
|
47881
|
-
for (const cpu of
|
|
47944
|
+
for (const cpu of os60.cpus()) {
|
|
47882
47945
|
const t2 = cpu.times;
|
|
47883
47946
|
idle += t2.idle;
|
|
47884
47947
|
total += t2.user + t2.nice + t2.sys + t2.idle + t2.irq;
|
|
@@ -47898,8 +47961,8 @@ var MetricsCollector = class {
|
|
|
47898
47961
|
const prev = this.prevCpu;
|
|
47899
47962
|
this.prevCpu = current2;
|
|
47900
47963
|
if (!prev) {
|
|
47901
|
-
const cores =
|
|
47902
|
-
const proxy =
|
|
47964
|
+
const cores = os60.cpus().length || 1;
|
|
47965
|
+
const proxy = os60.loadavg()[0] / cores * 100;
|
|
47903
47966
|
return Math.min(100, Math.max(0, Math.round(proxy)));
|
|
47904
47967
|
}
|
|
47905
47968
|
const idleDelta = current2.idle - prev.idle;
|
|
@@ -47912,8 +47975,8 @@ var MetricsCollector = class {
|
|
|
47912
47975
|
collect() {
|
|
47913
47976
|
return {
|
|
47914
47977
|
cpuPct: this.cpuPct(),
|
|
47915
|
-
ramUsedMb: Math.round((
|
|
47916
|
-
ramTotalMb: Math.round(
|
|
47978
|
+
ramUsedMb: Math.round((os60.totalmem() - os60.freemem()) / 1048576),
|
|
47979
|
+
ramTotalMb: Math.round(os60.totalmem() / 1048576),
|
|
47917
47980
|
latencyMs: this.lastLatencyMs
|
|
47918
47981
|
};
|
|
47919
47982
|
}
|
|
@@ -47922,19 +47985,19 @@ function apiBase() {
|
|
|
47922
47985
|
return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
|
|
47923
47986
|
}
|
|
47924
47987
|
function hostIdentityPath() {
|
|
47925
|
-
return
|
|
47988
|
+
return path90.join(os60.homedir(), ".codeam", "host-agent.json");
|
|
47926
47989
|
}
|
|
47927
47990
|
function collectOsInfo() {
|
|
47928
47991
|
return {
|
|
47929
|
-
distro:
|
|
47930
|
-
arch:
|
|
47931
|
-
kernel:
|
|
47992
|
+
distro: os60.platform(),
|
|
47993
|
+
arch: os60.arch(),
|
|
47994
|
+
kernel: os60.release(),
|
|
47932
47995
|
nodeVersion: process.versions.node
|
|
47933
47996
|
};
|
|
47934
47997
|
}
|
|
47935
47998
|
function loadHostIdentity() {
|
|
47936
47999
|
try {
|
|
47937
|
-
const raw =
|
|
48000
|
+
const raw = fs76.readFileSync(hostIdentityPath(), "utf8");
|
|
47938
48001
|
const parsed = JSON.parse(raw);
|
|
47939
48002
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
|
|
47940
48003
|
const p2 = parsed;
|
|
@@ -47962,8 +48025,8 @@ function ensureControlPollSecret(identity, save = saveHostIdentity) {
|
|
|
47962
48025
|
}
|
|
47963
48026
|
function saveHostIdentity(identity) {
|
|
47964
48027
|
const file = hostIdentityPath();
|
|
47965
|
-
|
|
47966
|
-
|
|
48028
|
+
fs76.mkdirSync(path90.dirname(file), { recursive: true, mode: 448 });
|
|
48029
|
+
fs76.writeFileSync(file, JSON.stringify(identity, null, 2), {
|
|
47967
48030
|
encoding: "utf8",
|
|
47968
48031
|
mode: 384
|
|
47969
48032
|
});
|
|
@@ -48008,7 +48071,7 @@ function isTerminalEnrollError(err) {
|
|
|
48008
48071
|
}
|
|
48009
48072
|
function deleteHostIdentity() {
|
|
48010
48073
|
try {
|
|
48011
|
-
|
|
48074
|
+
fs76.rmSync(hostIdentityPath(), { force: true });
|
|
48012
48075
|
} catch {
|
|
48013
48076
|
}
|
|
48014
48077
|
}
|
|
@@ -48032,7 +48095,7 @@ async function postJson(pathname, body) {
|
|
|
48032
48095
|
function resolveHostLabel(label) {
|
|
48033
48096
|
const explicit = label?.trim();
|
|
48034
48097
|
const envLabel = process.env.CODEAM_HOST_LABEL?.trim();
|
|
48035
|
-
const resolved = explicit || envLabel ||
|
|
48098
|
+
const resolved = explicit || envLabel || os60.hostname();
|
|
48036
48099
|
return resolved.slice(0, 80);
|
|
48037
48100
|
}
|
|
48038
48101
|
async function redeemEnrollToken(token, label) {
|
|
@@ -48225,9 +48288,9 @@ async function host(args2) {
|
|
|
48225
48288
|
|
|
48226
48289
|
// src/commands/host-agent.ts
|
|
48227
48290
|
var import_node_child_process30 = require("child_process");
|
|
48228
|
-
var
|
|
48229
|
-
var
|
|
48230
|
-
var
|
|
48291
|
+
var os64 = __toESM(require("os"));
|
|
48292
|
+
var fs80 = __toESM(require("fs"));
|
|
48293
|
+
var path94 = __toESM(require("path"));
|
|
48231
48294
|
|
|
48232
48295
|
// src/skills/persist-from-payload.ts
|
|
48233
48296
|
function persistOrClearSkillsFromPayload(skills) {
|
|
@@ -48236,13 +48299,13 @@ function persistOrClearSkillsFromPayload(skills) {
|
|
|
48236
48299
|
}
|
|
48237
48300
|
|
|
48238
48301
|
// src/commands/host/session-state.ts
|
|
48239
|
-
var
|
|
48240
|
-
var
|
|
48241
|
-
var
|
|
48302
|
+
var fs77 = __toESM(require("fs"));
|
|
48303
|
+
var os61 = __toESM(require("os"));
|
|
48304
|
+
var path91 = __toESM(require("path"));
|
|
48242
48305
|
function hostSessionStatePath(env = process.env) {
|
|
48243
48306
|
const override = env.CODEAM_HOST_SESSION_STATE_FILE;
|
|
48244
48307
|
if (override && override.trim()) return override.trim();
|
|
48245
|
-
return
|
|
48308
|
+
return path91.join(os61.homedir(), ".codeam", "host-agent-sessions.json");
|
|
48246
48309
|
}
|
|
48247
48310
|
function isRecord5(v) {
|
|
48248
48311
|
if (typeof v !== "object" || v === null) return false;
|
|
@@ -48253,7 +48316,7 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
48253
48316
|
return {
|
|
48254
48317
|
load() {
|
|
48255
48318
|
try {
|
|
48256
|
-
const raw = JSON.parse(
|
|
48319
|
+
const raw = JSON.parse(fs77.readFileSync(file, "utf8"));
|
|
48257
48320
|
return Array.isArray(raw?.sessions) ? raw.sessions.filter(isRecord5) : [];
|
|
48258
48321
|
} catch {
|
|
48259
48322
|
return [];
|
|
@@ -48261,18 +48324,18 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
48261
48324
|
},
|
|
48262
48325
|
save(list) {
|
|
48263
48326
|
try {
|
|
48264
|
-
|
|
48327
|
+
fs77.mkdirSync(path91.dirname(file), { recursive: true, mode: 448 });
|
|
48265
48328
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
48266
|
-
|
|
48329
|
+
fs77.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
|
|
48267
48330
|
mode: 384
|
|
48268
48331
|
});
|
|
48269
|
-
|
|
48332
|
+
fs77.renameSync(tmp, file);
|
|
48270
48333
|
} catch {
|
|
48271
48334
|
}
|
|
48272
48335
|
},
|
|
48273
48336
|
clear() {
|
|
48274
48337
|
try {
|
|
48275
|
-
|
|
48338
|
+
fs77.rmSync(file, { force: true });
|
|
48276
48339
|
} catch {
|
|
48277
48340
|
}
|
|
48278
48341
|
}
|
|
@@ -48295,10 +48358,10 @@ function planSessionResume(records, max) {
|
|
|
48295
48358
|
return { resume: ordered.slice(0, bound), dropped: ordered.slice(bound) };
|
|
48296
48359
|
}
|
|
48297
48360
|
function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
48298
|
-
const target =
|
|
48361
|
+
const target = path91.resolve(cwd);
|
|
48299
48362
|
const reconnectable = (s) => !!s.pluginId && !!s.pollSecret && !!s.agent;
|
|
48300
48363
|
const matches = sessions3.filter(
|
|
48301
|
-
(s) => !!s.cwd &&
|
|
48364
|
+
(s) => !!s.cwd && path91.resolve(s.cwd) === target && reconnectable(s)
|
|
48302
48365
|
);
|
|
48303
48366
|
if (matches.length > 0) {
|
|
48304
48367
|
matches.sort((a, b) => b.pairedAt - a.pairedAt);
|
|
@@ -48310,11 +48373,11 @@ function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
|
48310
48373
|
|
|
48311
48374
|
// src/commands/host/git-tooling.ts
|
|
48312
48375
|
var import_node_child_process26 = require("child_process");
|
|
48313
|
-
var
|
|
48314
|
-
var
|
|
48315
|
-
var
|
|
48376
|
+
var fs78 = __toESM(require("fs"));
|
|
48377
|
+
var os62 = __toESM(require("os"));
|
|
48378
|
+
var path92 = __toESM(require("path"));
|
|
48316
48379
|
function codeamBinDir() {
|
|
48317
|
-
return process.env.CODEAM_BIN_DIR ??
|
|
48380
|
+
return process.env.CODEAM_BIN_DIR ?? path92.join(os62.homedir(), ".codeam", "bin");
|
|
48318
48381
|
}
|
|
48319
48382
|
var FALLBACK_GH_VERSION = "2.62.0";
|
|
48320
48383
|
var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
|
|
@@ -48346,7 +48409,7 @@ async function download(url2, dest) {
|
|
|
48346
48409
|
const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
|
|
48347
48410
|
if (!res.ok || !res.body) return false;
|
|
48348
48411
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
48349
|
-
|
|
48412
|
+
fs78.writeFileSync(dest, buf);
|
|
48350
48413
|
return true;
|
|
48351
48414
|
} catch {
|
|
48352
48415
|
return false;
|
|
@@ -48369,8 +48432,8 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
48369
48432
|
const version3 = await resolveVersionFn(token);
|
|
48370
48433
|
const asset = `gh_${version3}_${osToken}_${arch2}`;
|
|
48371
48434
|
const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
|
|
48372
|
-
const tmpRoot =
|
|
48373
|
-
const archive =
|
|
48435
|
+
const tmpRoot = fs78.mkdtempSync(path92.join(os62.tmpdir(), "codeam-gh-"));
|
|
48436
|
+
const archive = path92.join(tmpRoot, `${asset}.${ext}`);
|
|
48374
48437
|
if (!await downloadFn(url2, archive)) {
|
|
48375
48438
|
log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
|
|
48376
48439
|
return null;
|
|
@@ -48380,16 +48443,16 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
48380
48443
|
log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
|
|
48381
48444
|
return null;
|
|
48382
48445
|
}
|
|
48383
|
-
const extractedBin =
|
|
48384
|
-
if (!
|
|
48446
|
+
const extractedBin = path92.join(tmpRoot, asset, "bin", binaryName);
|
|
48447
|
+
if (!fs78.existsSync(extractedBin)) {
|
|
48385
48448
|
log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
|
|
48386
48449
|
return null;
|
|
48387
48450
|
}
|
|
48388
48451
|
const binDir = codeamBinDir();
|
|
48389
|
-
|
|
48390
|
-
const target =
|
|
48391
|
-
|
|
48392
|
-
|
|
48452
|
+
fs78.mkdirSync(binDir, { recursive: true });
|
|
48453
|
+
const target = path92.join(binDir, binaryName);
|
|
48454
|
+
fs78.copyFileSync(extractedBin, target);
|
|
48455
|
+
fs78.chmodSync(target, 493);
|
|
48393
48456
|
log.info("host-agent", `gh installed to ${target} (v${version3})`);
|
|
48394
48457
|
return target;
|
|
48395
48458
|
} catch (e) {
|
|
@@ -48426,19 +48489,19 @@ async function ensureGhAuth(runner, ghCmd, token) {
|
|
|
48426
48489
|
}
|
|
48427
48490
|
function ghConfigDir() {
|
|
48428
48491
|
if (process.env.GH_CONFIG_DIR) return process.env.GH_CONFIG_DIR;
|
|
48429
|
-
if (process.env.XDG_CONFIG_HOME) return
|
|
48492
|
+
if (process.env.XDG_CONFIG_HOME) return path92.join(process.env.XDG_CONFIG_HOME, "gh");
|
|
48430
48493
|
if (process.platform === "win32" && process.env.APPDATA) {
|
|
48431
|
-
return
|
|
48494
|
+
return path92.join(process.env.APPDATA, "GitHub CLI");
|
|
48432
48495
|
}
|
|
48433
|
-
return
|
|
48496
|
+
return path92.join(os62.homedir(), ".config", "gh");
|
|
48434
48497
|
}
|
|
48435
48498
|
function writeGhHostsToken(token) {
|
|
48436
48499
|
try {
|
|
48437
48500
|
const dir = ghConfigDir();
|
|
48438
|
-
const file =
|
|
48439
|
-
if (
|
|
48440
|
-
|
|
48441
|
-
|
|
48501
|
+
const file = path92.join(dir, "hosts.yml");
|
|
48502
|
+
if (fs78.existsSync(file)) return false;
|
|
48503
|
+
fs78.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
48504
|
+
fs78.writeFileSync(
|
|
48442
48505
|
file,
|
|
48443
48506
|
`github.com:
|
|
48444
48507
|
oauth_token: ${token}
|
|
@@ -48481,8 +48544,8 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
48481
48544
|
const version3 = await resolveLatestGlabVersion();
|
|
48482
48545
|
const asset = `glab_${version3}_${osToken}_${arch2}`;
|
|
48483
48546
|
const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
|
|
48484
|
-
const tmpRoot =
|
|
48485
|
-
const archive =
|
|
48547
|
+
const tmpRoot = fs78.mkdtempSync(path92.join(os62.tmpdir(), "codeam-glab-"));
|
|
48548
|
+
const archive = path92.join(tmpRoot, `${asset}.${ext}`);
|
|
48486
48549
|
if (!await downloadFn(url2, archive)) {
|
|
48487
48550
|
log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
|
|
48488
48551
|
return null;
|
|
@@ -48493,20 +48556,20 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
48493
48556
|
return null;
|
|
48494
48557
|
}
|
|
48495
48558
|
const candidates = [
|
|
48496
|
-
|
|
48497
|
-
|
|
48498
|
-
|
|
48559
|
+
path92.join(tmpRoot, "bin", binaryName),
|
|
48560
|
+
path92.join(tmpRoot, asset, "bin", binaryName),
|
|
48561
|
+
path92.join(tmpRoot, binaryName)
|
|
48499
48562
|
];
|
|
48500
|
-
const extractedBin = candidates.find((c2) =>
|
|
48563
|
+
const extractedBin = candidates.find((c2) => fs78.existsSync(c2));
|
|
48501
48564
|
if (!extractedBin) {
|
|
48502
48565
|
log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
|
|
48503
48566
|
return null;
|
|
48504
48567
|
}
|
|
48505
48568
|
const binDir = codeamBinDir();
|
|
48506
|
-
|
|
48507
|
-
const target =
|
|
48508
|
-
|
|
48509
|
-
|
|
48569
|
+
fs78.mkdirSync(binDir, { recursive: true });
|
|
48570
|
+
const target = path92.join(binDir, binaryName);
|
|
48571
|
+
fs78.copyFileSync(extractedBin, target);
|
|
48572
|
+
fs78.chmodSync(target, 493);
|
|
48510
48573
|
log.info("host-agent", `glab installed to ${target} (v${version3})`);
|
|
48511
48574
|
return target;
|
|
48512
48575
|
} catch (e) {
|
|
@@ -48588,9 +48651,9 @@ var defaultGitToolingRunner = {
|
|
|
48588
48651
|
var import_node_child_process28 = require("child_process");
|
|
48589
48652
|
|
|
48590
48653
|
// src/lib/updateNotifier.ts
|
|
48591
|
-
var
|
|
48592
|
-
var
|
|
48593
|
-
var
|
|
48654
|
+
var fs79 = __toESM(require("fs"));
|
|
48655
|
+
var os63 = __toESM(require("os"));
|
|
48656
|
+
var path93 = __toESM(require("path"));
|
|
48594
48657
|
var https8 = __toESM(require("https"));
|
|
48595
48658
|
var import_node_child_process27 = require("child_process");
|
|
48596
48659
|
var import_picocolors12 = __toESM(require("picocolors"));
|
|
@@ -48599,12 +48662,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
|
|
|
48599
48662
|
var TTL_MS = 24 * 60 * 60 * 1e3;
|
|
48600
48663
|
var REQUEST_TIMEOUT_MS = 1500;
|
|
48601
48664
|
function cachePath() {
|
|
48602
|
-
const dir =
|
|
48603
|
-
return
|
|
48665
|
+
const dir = path93.join(os63.homedir(), ".codeam");
|
|
48666
|
+
return path93.join(dir, "update-check.json");
|
|
48604
48667
|
}
|
|
48605
48668
|
function readCache() {
|
|
48606
48669
|
try {
|
|
48607
|
-
const raw =
|
|
48670
|
+
const raw = fs79.readFileSync(cachePath(), "utf8");
|
|
48608
48671
|
const parsed = JSON.parse(raw);
|
|
48609
48672
|
if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
|
|
48610
48673
|
return parsed;
|
|
@@ -48615,10 +48678,10 @@ function readCache() {
|
|
|
48615
48678
|
function writeCache(cache) {
|
|
48616
48679
|
try {
|
|
48617
48680
|
const file = cachePath();
|
|
48618
|
-
|
|
48681
|
+
fs79.mkdirSync(path93.dirname(file), { recursive: true });
|
|
48619
48682
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
48620
|
-
|
|
48621
|
-
|
|
48683
|
+
fs79.writeFileSync(tmp, JSON.stringify(cache));
|
|
48684
|
+
fs79.renameSync(tmp, file);
|
|
48622
48685
|
} catch {
|
|
48623
48686
|
}
|
|
48624
48687
|
}
|
|
@@ -48692,8 +48755,8 @@ function isLinkedInstall() {
|
|
|
48692
48755
|
timeout: 2e3
|
|
48693
48756
|
}).trim();
|
|
48694
48757
|
if (!root) return false;
|
|
48695
|
-
const pkgPath =
|
|
48696
|
-
return
|
|
48758
|
+
const pkgPath = path93.join(root, PKG_NAME);
|
|
48759
|
+
return fs79.lstatSync(pkgPath).isSymbolicLink();
|
|
48697
48760
|
} catch {
|
|
48698
48761
|
return false;
|
|
48699
48762
|
}
|
|
@@ -48729,7 +48792,7 @@ function maybeAutoUpdate(currentVersion, latest) {
|
|
|
48729
48792
|
return;
|
|
48730
48793
|
}
|
|
48731
48794
|
try {
|
|
48732
|
-
|
|
48795
|
+
fs79.unlinkSync(cachePath());
|
|
48733
48796
|
} catch {
|
|
48734
48797
|
}
|
|
48735
48798
|
process.stderr.write(` ${import_picocolors12.default.green("\u2713")} Updated. Resuming session...
|
|
@@ -48745,7 +48808,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
48745
48808
|
if (process.env.NODE_ENV === "test") return;
|
|
48746
48809
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
48747
48810
|
if (process.env.CI) return;
|
|
48748
|
-
const current2 = true ? "2.75.
|
|
48811
|
+
const current2 = true ? "2.75.37" : null;
|
|
48749
48812
|
if (!current2) return;
|
|
48750
48813
|
const cache = readCache();
|
|
48751
48814
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -48762,7 +48825,7 @@ function checkForUpdates() {
|
|
|
48762
48825
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
48763
48826
|
if (process.env.CI) return;
|
|
48764
48827
|
if (!process.stdout.isTTY) return;
|
|
48765
|
-
const current2 = true ? "2.75.
|
|
48828
|
+
const current2 = true ? "2.75.37" : null;
|
|
48766
48829
|
if (!current2) return;
|
|
48767
48830
|
const cache = readCache();
|
|
48768
48831
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -48785,7 +48848,7 @@ var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
|
48785
48848
|
var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
|
|
48786
48849
|
var SUDO_PREFLIGHT_TIMEOUT_MS = 5e3;
|
|
48787
48850
|
function currentCliVersion() {
|
|
48788
|
-
return true ? "2.75.
|
|
48851
|
+
return true ? "2.75.37" : null;
|
|
48789
48852
|
}
|
|
48790
48853
|
async function installedVersion(deps) {
|
|
48791
48854
|
const ls = await deps.run(
|
|
@@ -49144,6 +49207,7 @@ var HostAgentSupervisor = class {
|
|
|
49144
49207
|
this.selfUpdate = deps.selfUpdate ?? runSelfUpdate;
|
|
49145
49208
|
this.now = deps.now ?? (() => Date.now());
|
|
49146
49209
|
this.onUpdated = deps.onUpdated ?? defaultOnUpdated;
|
|
49210
|
+
this.isChildMidTurn = deps.isChildMidTurn ?? ((pid) => isProcessMidTurn(pid));
|
|
49147
49211
|
this.docker = deps.docker ?? defaultDockerRunner;
|
|
49148
49212
|
this.postResumeFailure = deps.postResumeFailure ?? postSessionErrorBubble;
|
|
49149
49213
|
}
|
|
@@ -49160,6 +49224,7 @@ var HostAgentSupervisor = class {
|
|
|
49160
49224
|
/** Self-update check + install (injectable; defaults to runSelfUpdate). */
|
|
49161
49225
|
selfUpdate;
|
|
49162
49226
|
now;
|
|
49227
|
+
isChildMidTurn;
|
|
49163
49228
|
/** Restart action after a successful self-update (defaults to process.exit). */
|
|
49164
49229
|
onUpdated;
|
|
49165
49230
|
/** Guards against overlapping self-update ticks (a slow npm install). */
|
|
@@ -49363,19 +49428,20 @@ var HostAgentSupervisor = class {
|
|
|
49363
49428
|
* idle tick) rather than yank an active turn.
|
|
49364
49429
|
*/
|
|
49365
49430
|
maybeRestartForUpdate(version3) {
|
|
49366
|
-
|
|
49431
|
+
const midTurn = [...this.children.values()].some((c2) => this.isChildMidTurn(c2.proc.pid));
|
|
49432
|
+
if (midTurn) {
|
|
49367
49433
|
const since = this.pendingRestartSince ?? this.now();
|
|
49368
49434
|
const waited = this.now() - since;
|
|
49369
49435
|
if (waited < SELF_UPDATE_DEFER_MAX_MS) {
|
|
49370
49436
|
log.info(
|
|
49371
49437
|
"host-agent",
|
|
49372
|
-
`self-update: ${version3} installed but
|
|
49438
|
+
`self-update: ${version3} installed but a session is mid-turn \u2014 deferring restart`
|
|
49373
49439
|
);
|
|
49374
49440
|
return false;
|
|
49375
49441
|
}
|
|
49376
49442
|
log.warn(
|
|
49377
49443
|
"host-agent",
|
|
49378
|
-
`self-update: ${version3} has been owed for ${Math.round(waited / 36e5)}h with
|
|
49444
|
+
`self-update: ${version3} has been owed for ${Math.round(waited / 36e5)}h with a session still mid-turn \u2014 restarting anyway rather than staying on old code`
|
|
49379
49445
|
);
|
|
49380
49446
|
}
|
|
49381
49447
|
this.onUpdated(version3);
|
|
@@ -49526,13 +49592,13 @@ var HostAgentSupervisor = class {
|
|
|
49526
49592
|
const relay = this.relay;
|
|
49527
49593
|
if (!relay) return;
|
|
49528
49594
|
const raw = cmd.payload?.path;
|
|
49529
|
-
const target = typeof raw === "string" && raw.trim() ?
|
|
49595
|
+
const target = typeof raw === "string" && raw.trim() ? path94.resolve(raw.trim()) : os64.homedir();
|
|
49530
49596
|
try {
|
|
49531
|
-
const dirents = await
|
|
49597
|
+
const dirents = await fs80.promises.readdir(target, { withFileTypes: true });
|
|
49532
49598
|
const entries = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
|
|
49533
49599
|
(a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
|
|
49534
49600
|
);
|
|
49535
|
-
const parent =
|
|
49601
|
+
const parent = path94.dirname(target);
|
|
49536
49602
|
await relay.sendResult(cmd.id, "completed", {
|
|
49537
49603
|
path: target,
|
|
49538
49604
|
// null at the filesystem root so the UI can hide the ".." affordance.
|
|
@@ -49879,14 +49945,14 @@ var HostAgentSupervisor = class {
|
|
|
49879
49945
|
...buildHouseProxyChildEnv({ baseUrl, token, openRouter: openRouter === true }),
|
|
49880
49946
|
CODEAM_AUTO_TOKEN: payload.autoPairToken
|
|
49881
49947
|
};
|
|
49882
|
-
const houseConfigDir =
|
|
49883
|
-
|
|
49948
|
+
const houseConfigDir = path94.join(
|
|
49949
|
+
os64.homedir(),
|
|
49884
49950
|
".codeam",
|
|
49885
49951
|
"house-claude",
|
|
49886
49952
|
payload.deployId
|
|
49887
49953
|
);
|
|
49888
49954
|
try {
|
|
49889
|
-
|
|
49955
|
+
fs80.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
|
|
49890
49956
|
} catch {
|
|
49891
49957
|
}
|
|
49892
49958
|
childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
|
|
@@ -49912,7 +49978,7 @@ var HostAgentSupervisor = class {
|
|
|
49912
49978
|
report("installing", "installing agent CLI");
|
|
49913
49979
|
await this.runAgentInstall(payload.agentInstallScript);
|
|
49914
49980
|
}
|
|
49915
|
-
const home = process.env.HOME ||
|
|
49981
|
+
const home = process.env.HOME || os64.homedir();
|
|
49916
49982
|
childEnv.PATH = `${home}/.local/bin:${process.env.PATH ?? ""}`;
|
|
49917
49983
|
if (payload.cloneToken) {
|
|
49918
49984
|
try {
|
|
@@ -49920,13 +49986,13 @@ var HostAgentSupervisor = class {
|
|
|
49920
49986
|
if ((payload.repoProvider ?? "github") === "gitlab") {
|
|
49921
49987
|
const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
|
|
49922
49988
|
if (glabCmd) {
|
|
49923
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
49989
|
+
childEnv.PATH = `${codeamBinDir()}${path94.delimiter}${childEnv.PATH}`;
|
|
49924
49990
|
await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
|
|
49925
49991
|
}
|
|
49926
49992
|
} else {
|
|
49927
49993
|
const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
|
|
49928
49994
|
if (ghCmd) {
|
|
49929
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
49995
|
+
childEnv.PATH = `${codeamBinDir()}${path94.delimiter}${childEnv.PATH}`;
|
|
49930
49996
|
await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
|
|
49931
49997
|
}
|
|
49932
49998
|
}
|
|
@@ -49954,9 +50020,9 @@ var HostAgentSupervisor = class {
|
|
|
49954
50020
|
);
|
|
49955
50021
|
if (!payload.suppressOnboardingWelcome) {
|
|
49956
50022
|
try {
|
|
49957
|
-
const cfgDir = childEnv.CLAUDE_CONFIG_DIR ||
|
|
49958
|
-
const projectDir =
|
|
49959
|
-
const hasPriorConversation =
|
|
50023
|
+
const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path94.join(os64.homedir(), ".claude");
|
|
50024
|
+
const projectDir = path94.join(cfgDir, "projects", encodeCwd(cwd));
|
|
50025
|
+
const hasPriorConversation = fs80.existsSync(projectDir) && fs80.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
|
|
49960
50026
|
if (hasPriorConversation) {
|
|
49961
50027
|
childEnv.CODEAM_RESUME_LATEST = "1";
|
|
49962
50028
|
log.info(
|
|
@@ -50107,7 +50173,7 @@ var HostAgentSupervisor = class {
|
|
|
50107
50173
|
fallbackResumeTarget() {
|
|
50108
50174
|
const session = getActiveSession();
|
|
50109
50175
|
if (!session || !session.pluginId || !session.pollSecret || !session.agent) return null;
|
|
50110
|
-
const cwd = session.cwd &&
|
|
50176
|
+
const cwd = session.cwd && fs80.existsSync(session.cwd) ? session.cwd : process.cwd();
|
|
50111
50177
|
const deployId = deployIdFromWorkspace(session.cwd) ?? session.id;
|
|
50112
50178
|
return { deployId, cwd, session };
|
|
50113
50179
|
}
|
|
@@ -50140,7 +50206,7 @@ var HostAgentSupervisor = class {
|
|
|
50140
50206
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: no saved pairing on this box`);
|
|
50141
50207
|
return;
|
|
50142
50208
|
}
|
|
50143
|
-
if (!session.cwd || !
|
|
50209
|
+
if (!session.cwd || !fs80.existsSync(session.cwd)) {
|
|
50144
50210
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: workspace is gone`);
|
|
50145
50211
|
return;
|
|
50146
50212
|
}
|
|
@@ -50182,7 +50248,7 @@ var HostAgentSupervisor = class {
|
|
|
50182
50248
|
const persisted = new Map(this.sessionStore.load().map((r) => [r.deployId, r.agent]));
|
|
50183
50249
|
for (const c2 of this.children.values()) persisted.set(c2.deployId, c2.agent);
|
|
50184
50250
|
return this.listSavedSessions().map((s) => ({ s, deployId: deployIdFromWorkspace(s.cwd) })).filter(
|
|
50185
|
-
(x) => x.deployId !== null && !!x.s.cwd &&
|
|
50251
|
+
(x) => x.deployId !== null && !!x.s.cwd && fs80.existsSync(x.s.cwd)
|
|
50186
50252
|
).map(({ s, deployId }) => {
|
|
50187
50253
|
const agent = persisted.get(deployId);
|
|
50188
50254
|
return { deployId, sessionId: s.id, ...agent ? { agent } : {} };
|
|
@@ -50197,7 +50263,7 @@ var HostAgentSupervisor = class {
|
|
|
50197
50263
|
if (this.children.has(deployId)) return;
|
|
50198
50264
|
const st3 = this.resumeStateFor(target);
|
|
50199
50265
|
try {
|
|
50200
|
-
const cwd =
|
|
50266
|
+
const cwd = fs80.existsSync(target.cwd) ? target.cwd : process.cwd();
|
|
50201
50267
|
const proc = this.resumeSpawner(
|
|
50202
50268
|
{ ...readHouseProxyChildEnv(deployId), CODEAM_RESUME_SESSION_ID: session.id },
|
|
50203
50269
|
cwd
|
|
@@ -50224,7 +50290,7 @@ var HostAgentSupervisor = class {
|
|
|
50224
50290
|
return;
|
|
50225
50291
|
}
|
|
50226
50292
|
if (tracked && signal) {
|
|
50227
|
-
this.onResumeChildExit(target, 128 + (
|
|
50293
|
+
this.onResumeChildExit(target, 128 + (os64.constants.signals[signal] ?? 9), `signal ${signal}`);
|
|
50228
50294
|
return;
|
|
50229
50295
|
}
|
|
50230
50296
|
log.warn(
|
|
@@ -50267,7 +50333,7 @@ var HostAgentSupervisor = class {
|
|
|
50267
50333
|
if (Date.now() - child.startedAt < CRASH_RESPAWN_MIN_UPTIME_MS) return false;
|
|
50268
50334
|
const session = pickSavedSessionForWorkspace(this.listSavedSessions(), child.cwd);
|
|
50269
50335
|
if (!session) return false;
|
|
50270
|
-
const exitCode = typeof code === "number" ? code : 128 + (signal ?
|
|
50336
|
+
const exitCode = typeof code === "number" ? code : 128 + (signal ? os64.constants.signals[signal] ?? 9 : 9);
|
|
50271
50337
|
log.warn(
|
|
50272
50338
|
"host-agent",
|
|
50273
50339
|
`session deploy=${child.deployId.slice(0, 8)} died (${signal ?? code}) after ${Math.round((Date.now() - child.startedAt) / 1e3)}s \u2014 respawning it (resume)`
|
|
@@ -50416,12 +50482,12 @@ var HostAgentSupervisor = class {
|
|
|
50416
50482
|
this.untrackChild(deployId);
|
|
50417
50483
|
}
|
|
50418
50484
|
const dirs = [
|
|
50419
|
-
|
|
50420
|
-
|
|
50485
|
+
path94.join(selfHostedWorkspaceRoot(), deployId),
|
|
50486
|
+
path94.join(os64.homedir(), ".codeam", "house-claude", deployId)
|
|
50421
50487
|
];
|
|
50422
50488
|
for (const dir of dirs) {
|
|
50423
50489
|
try {
|
|
50424
|
-
|
|
50490
|
+
fs80.rmSync(dir, { recursive: true, force: true });
|
|
50425
50491
|
} catch (err) {
|
|
50426
50492
|
log.warn(
|
|
50427
50493
|
"host-agent",
|
|
@@ -50581,8 +50647,8 @@ async function invite() {
|
|
|
50581
50647
|
var import_node_dns = require("dns");
|
|
50582
50648
|
var import_node_util6 = require("util");
|
|
50583
50649
|
var import_node_crypto13 = require("crypto");
|
|
50584
|
-
var
|
|
50585
|
-
var
|
|
50650
|
+
var fs81 = __toESM(require("fs"));
|
|
50651
|
+
var path95 = __toESM(require("path"));
|
|
50586
50652
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
50587
50653
|
var dnsResolveP = (0, import_node_util6.promisify)(import_node_dns.resolve);
|
|
50588
50654
|
async function checkDns(apiBase2) {
|
|
@@ -50638,13 +50704,13 @@ async function checkHealth(apiBase2) {
|
|
|
50638
50704
|
}
|
|
50639
50705
|
}
|
|
50640
50706
|
function checkConfigDir() {
|
|
50641
|
-
const dir =
|
|
50707
|
+
const dir = path95.join(require("os").homedir(), ".codeam");
|
|
50642
50708
|
try {
|
|
50643
|
-
|
|
50644
|
-
const probe =
|
|
50645
|
-
|
|
50646
|
-
const read =
|
|
50647
|
-
|
|
50709
|
+
fs81.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
50710
|
+
const probe = path95.join(dir, ".doctor-probe");
|
|
50711
|
+
fs81.writeFileSync(probe, "ok", { mode: 384 });
|
|
50712
|
+
const read = fs81.readFileSync(probe, "utf8");
|
|
50713
|
+
fs81.unlinkSync(probe);
|
|
50648
50714
|
if (read !== "ok") throw new Error("write/read round-trip mismatch");
|
|
50649
50715
|
return {
|
|
50650
50716
|
id: "config-dir",
|
|
@@ -50684,9 +50750,9 @@ function checkSessions() {
|
|
|
50684
50750
|
}
|
|
50685
50751
|
}
|
|
50686
50752
|
function checkAgentBinaries() {
|
|
50687
|
-
const
|
|
50753
|
+
const os67 = createOsStrategy();
|
|
50688
50754
|
return getEnabledAgents().map((meta) => {
|
|
50689
|
-
const found =
|
|
50755
|
+
const found = os67.findInPath(meta.binaryName);
|
|
50690
50756
|
return {
|
|
50691
50757
|
id: `agent-${meta.id}`,
|
|
50692
50758
|
label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
|
|
@@ -50708,7 +50774,7 @@ function checkNodePty() {
|
|
|
50708
50774
|
detail: "not required on this platform"
|
|
50709
50775
|
};
|
|
50710
50776
|
}
|
|
50711
|
-
const vendoredPath =
|
|
50777
|
+
const vendoredPath = path95.join(__dirname, "vendor", "node-pty");
|
|
50712
50778
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
50713
50779
|
try {
|
|
50714
50780
|
require(target);
|
|
@@ -50750,7 +50816,7 @@ function checkChokidar() {
|
|
|
50750
50816
|
}
|
|
50751
50817
|
async function doctor(args2 = []) {
|
|
50752
50818
|
const json = args2.includes("--json");
|
|
50753
|
-
const cliVersion = true ? "2.75.
|
|
50819
|
+
const cliVersion = true ? "2.75.37" : "0.0.0-dev";
|
|
50754
50820
|
const apiBase2 = resolveApiBaseUrl();
|
|
50755
50821
|
const diagnosticId = (0, import_node_crypto13.randomUUID)();
|
|
50756
50822
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
@@ -50812,8 +50878,8 @@ ${import_picocolors14.default.bold(" codeam doctor")}
|
|
|
50812
50878
|
`);
|
|
50813
50879
|
out2.write("\n");
|
|
50814
50880
|
for (const c2 of r.checks) {
|
|
50815
|
-
const
|
|
50816
|
-
out2.write(` ${
|
|
50881
|
+
const mark2 = c2.ok ? import_picocolors14.default.green("\u2713") : c2.optional ? import_picocolors14.default.yellow("!") : import_picocolors14.default.red("\u2717");
|
|
50882
|
+
out2.write(` ${mark2} ${c2.label}${import_picocolors14.default.dim(` \u2014 ${c2.detail}`)}
|
|
50817
50883
|
`);
|
|
50818
50884
|
if (!c2.ok && c2.hint) {
|
|
50819
50885
|
for (const line of c2.hint.split("\n")) {
|
|
@@ -51274,7 +51340,7 @@ async function mcpWarm(argv = [], opts = {}) {
|
|
|
51274
51340
|
// src/commands/version.ts
|
|
51275
51341
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
51276
51342
|
function version2() {
|
|
51277
|
-
const v = true ? "2.75.
|
|
51343
|
+
const v = true ? "2.75.37" : "unknown";
|
|
51278
51344
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
51279
51345
|
}
|
|
51280
51346
|
|
|
@@ -51423,10 +51489,10 @@ var EXIT_CODE_NAMES = {
|
|
|
51423
51489
|
};
|
|
51424
51490
|
|
|
51425
51491
|
// src/index.ts
|
|
51426
|
-
var
|
|
51492
|
+
var os66 = __toESM(require("os"));
|
|
51427
51493
|
if (!process.env.HOME) {
|
|
51428
51494
|
try {
|
|
51429
|
-
const home =
|
|
51495
|
+
const home = os66.homedir();
|
|
51430
51496
|
if (home) process.env.HOME = home;
|
|
51431
51497
|
} catch {
|
|
51432
51498
|
}
|