codeam-cli 2.61.68 → 2.61.70
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 +12 -0
- package/dist/index.js +479 -380
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -119,7 +119,7 @@ async function runHttpRelay(delivery, client3, id) {
|
|
|
119
119
|
requestInit: { headers: buildHttpHeaders(delivery.httpHeaders, token) }
|
|
120
120
|
});
|
|
121
121
|
const stdioTransport = new StdioServerTransport();
|
|
122
|
-
await new Promise((
|
|
122
|
+
await new Promise((resolve9, reject) => {
|
|
123
123
|
let done = false;
|
|
124
124
|
const finish = (err) => {
|
|
125
125
|
if (done) return;
|
|
@@ -127,7 +127,7 @@ async function runHttpRelay(delivery, client3, id) {
|
|
|
127
127
|
void httpTransport.close().catch(() => void 0);
|
|
128
128
|
void stdioTransport.close().catch(() => void 0);
|
|
129
129
|
if (err) reject(err);
|
|
130
|
-
else
|
|
130
|
+
else resolve9();
|
|
131
131
|
};
|
|
132
132
|
stdioTransport.onmessage = (msg) => {
|
|
133
133
|
void httpTransport.send(msg).catch((e) => {
|
|
@@ -1882,8 +1882,8 @@ var HEADROOM_MODELS = [
|
|
|
1882
1882
|
}
|
|
1883
1883
|
];
|
|
1884
1884
|
function headroomSnapshotDownloadLine(model, opts = {}) {
|
|
1885
|
-
const
|
|
1886
|
-
const patterns = model.allowPatterns.map((p2) => `"${p2}"`).join(
|
|
1885
|
+
const sep7 = opts.spaceAfterComma ? ", " : ",";
|
|
1886
|
+
const patterns = model.allowPatterns.map((p2) => `"${p2}"`).join(sep7);
|
|
1887
1887
|
return `snapshot_download("${model.repo}", allow_patterns=[${patterns}])`;
|
|
1888
1888
|
}
|
|
1889
1889
|
function headroomModelPredownloadScript(opts = {}) {
|
|
@@ -2172,11 +2172,11 @@ function quiet(fn) {
|
|
|
2172
2172
|
log.debug(TAG, "ignored sync error", err);
|
|
2173
2173
|
}
|
|
2174
2174
|
}
|
|
2175
|
-
function rmIfExistsQuiet(
|
|
2175
|
+
function rmIfExistsQuiet(path80) {
|
|
2176
2176
|
try {
|
|
2177
|
-
fs2.rmSync(
|
|
2177
|
+
fs2.rmSync(path80, { force: true });
|
|
2178
2178
|
} catch (err) {
|
|
2179
|
-
log.debug(TAG, `rmIfExists failed for ${
|
|
2179
|
+
log.debug(TAG, `rmIfExists failed for ${path80}`, err);
|
|
2180
2180
|
}
|
|
2181
2181
|
}
|
|
2182
2182
|
function killQuiet(target, signal = "SIGTERM") {
|
|
@@ -2360,8 +2360,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
|
|
|
2360
2360
|
return decodedFile;
|
|
2361
2361
|
};
|
|
2362
2362
|
}
|
|
2363
|
-
function normalizeWindowsPath(
|
|
2364
|
-
return
|
|
2363
|
+
function normalizeWindowsPath(path80) {
|
|
2364
|
+
return path80.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
2365
2365
|
}
|
|
2366
2366
|
|
|
2367
2367
|
// ../../node_modules/@posthog/core/dist/featureFlagUtils.mjs
|
|
@@ -4841,15 +4841,15 @@ async function addSourceContext(frames) {
|
|
|
4841
4841
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
4842
4842
|
return frames;
|
|
4843
4843
|
}
|
|
4844
|
-
function getContextLinesFromFile(
|
|
4845
|
-
return new Promise((
|
|
4846
|
-
const stream = (0, import_node_fs.createReadStream)(
|
|
4844
|
+
function getContextLinesFromFile(path80, ranges, output) {
|
|
4845
|
+
return new Promise((resolve9) => {
|
|
4846
|
+
const stream = (0, import_node_fs.createReadStream)(path80);
|
|
4847
4847
|
const lineReaded = (0, import_node_readline.createInterface)({
|
|
4848
4848
|
input: stream
|
|
4849
4849
|
});
|
|
4850
4850
|
function destroyStreamAndResolve() {
|
|
4851
4851
|
stream.destroy();
|
|
4852
|
-
|
|
4852
|
+
resolve9();
|
|
4853
4853
|
}
|
|
4854
4854
|
let lineNumber = 0;
|
|
4855
4855
|
let currentRangeIndex = 0;
|
|
@@ -4858,7 +4858,7 @@ function getContextLinesFromFile(path79, ranges, output) {
|
|
|
4858
4858
|
let rangeStart = range[0];
|
|
4859
4859
|
let rangeEnd = range[1];
|
|
4860
4860
|
function onStreamError() {
|
|
4861
|
-
LRU_FILE_CONTENTS_FS_READ_FAILED.set(
|
|
4861
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(path80, 1);
|
|
4862
4862
|
lineReaded.close();
|
|
4863
4863
|
lineReaded.removeAllListeners();
|
|
4864
4864
|
destroyStreamAndResolve();
|
|
@@ -4919,8 +4919,8 @@ function clearLineContext(frame) {
|
|
|
4919
4919
|
delete frame.context_line;
|
|
4920
4920
|
delete frame.post_context;
|
|
4921
4921
|
}
|
|
4922
|
-
function shouldSkipContextLinesForFile(
|
|
4923
|
-
return
|
|
4922
|
+
function shouldSkipContextLinesForFile(path80) {
|
|
4923
|
+
return path80.startsWith("node:") || path80.endsWith(".min.js") || path80.endsWith(".min.cjs") || path80.endsWith(".min.mjs") || path80.startsWith("data:");
|
|
4924
4924
|
}
|
|
4925
4925
|
function shouldSkipContextLinesForFrame(frame) {
|
|
4926
4926
|
if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
|
|
@@ -6136,9 +6136,9 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
|
|
|
6136
6136
|
if (!waitUntil) return;
|
|
6137
6137
|
if (this.disabled || this.optedOut) return;
|
|
6138
6138
|
if (!this._waitUntilCycle) {
|
|
6139
|
-
let
|
|
6139
|
+
let resolve9;
|
|
6140
6140
|
const promise = new Promise((r) => {
|
|
6141
|
-
|
|
6141
|
+
resolve9 = r;
|
|
6142
6142
|
});
|
|
6143
6143
|
try {
|
|
6144
6144
|
waitUntil(promise);
|
|
@@ -6146,7 +6146,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
|
|
|
6146
6146
|
return;
|
|
6147
6147
|
}
|
|
6148
6148
|
this._waitUntilCycle = {
|
|
6149
|
-
resolve:
|
|
6149
|
+
resolve: resolve9,
|
|
6150
6150
|
startedAt: Date.now(),
|
|
6151
6151
|
timer: void 0
|
|
6152
6152
|
};
|
|
@@ -6170,12 +6170,12 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
|
|
|
6170
6170
|
return cycle?.resolve;
|
|
6171
6171
|
}
|
|
6172
6172
|
async resolveWaitUntilFlush() {
|
|
6173
|
-
const
|
|
6173
|
+
const resolve9 = this._consumeWaitUntilCycle();
|
|
6174
6174
|
try {
|
|
6175
6175
|
await super.flush();
|
|
6176
6176
|
} catch {
|
|
6177
6177
|
} finally {
|
|
6178
|
-
|
|
6178
|
+
resolve9?.();
|
|
6179
6179
|
}
|
|
6180
6180
|
}
|
|
6181
6181
|
getPersistedProperty(key) {
|
|
@@ -6267,15 +6267,15 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
|
|
|
6267
6267
|
async waitForLocalEvaluationReady(timeoutMs = THIRTY_SECONDS) {
|
|
6268
6268
|
if (this.isLocalEvaluationReady()) return true;
|
|
6269
6269
|
if (void 0 === this.featureFlagsPoller) return false;
|
|
6270
|
-
return new Promise((
|
|
6270
|
+
return new Promise((resolve9) => {
|
|
6271
6271
|
const timeout = setTimeout(() => {
|
|
6272
6272
|
cleanup();
|
|
6273
|
-
|
|
6273
|
+
resolve9(false);
|
|
6274
6274
|
}, timeoutMs);
|
|
6275
6275
|
const cleanup = this._events.on("localEvaluationFlagsLoaded", (count) => {
|
|
6276
6276
|
clearTimeout(timeout);
|
|
6277
6277
|
cleanup();
|
|
6278
|
-
|
|
6278
|
+
resolve9(count > 0);
|
|
6279
6279
|
});
|
|
6280
6280
|
});
|
|
6281
6281
|
}
|
|
@@ -6712,13 +6712,13 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
|
|
|
6712
6712
|
this.context?.enter(data, options);
|
|
6713
6713
|
}
|
|
6714
6714
|
async _shutdown(shutdownTimeoutMs) {
|
|
6715
|
-
const
|
|
6715
|
+
const resolve9 = this._consumeWaitUntilCycle();
|
|
6716
6716
|
await this.featureFlagsPoller?.stopPoller(shutdownTimeoutMs);
|
|
6717
6717
|
this.errorTracking.shutdown();
|
|
6718
6718
|
try {
|
|
6719
6719
|
return await super._shutdown(shutdownTimeoutMs);
|
|
6720
6720
|
} finally {
|
|
6721
|
-
|
|
6721
|
+
resolve9?.();
|
|
6722
6722
|
}
|
|
6723
6723
|
}
|
|
6724
6724
|
async _requestRemoteConfigPayload(flagKey) {
|
|
@@ -7074,7 +7074,7 @@ function readAnonId() {
|
|
|
7074
7074
|
}
|
|
7075
7075
|
function superProperties() {
|
|
7076
7076
|
return {
|
|
7077
|
-
cliVersion: true ? "2.61.
|
|
7077
|
+
cliVersion: true ? "2.61.70" : "0.0.0-dev",
|
|
7078
7078
|
nodeVersion: process.version,
|
|
7079
7079
|
platform: process.platform,
|
|
7080
7080
|
arch: process.arch,
|
|
@@ -7221,10 +7221,10 @@ var _execSeam = {
|
|
|
7221
7221
|
}
|
|
7222
7222
|
};
|
|
7223
7223
|
var _execSeamAsync = {
|
|
7224
|
-
exec: (file, args2, opts) => new Promise((
|
|
7224
|
+
exec: (file, args2, opts) => new Promise((resolve9, reject) => {
|
|
7225
7225
|
(0, import_child_process.execFile)(file, args2, opts, (err, stdout) => {
|
|
7226
7226
|
if (err) reject(err);
|
|
7227
|
-
else
|
|
7227
|
+
else resolve9(typeof stdout === "string" ? stdout : stdout.toString("utf8"));
|
|
7228
7228
|
});
|
|
7229
7229
|
})
|
|
7230
7230
|
};
|
|
@@ -7255,7 +7255,7 @@ var os4 = __toESM(require("os"));
|
|
|
7255
7255
|
// package.json
|
|
7256
7256
|
var package_default = {
|
|
7257
7257
|
name: "codeam-cli",
|
|
7258
|
-
version: "2.61.
|
|
7258
|
+
version: "2.61.70",
|
|
7259
7259
|
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.",
|
|
7260
7260
|
type: "commonjs",
|
|
7261
7261
|
main: "dist/index.js",
|
|
@@ -7381,8 +7381,8 @@ async function requestCode(pluginId, pluginSecretHash) {
|
|
|
7381
7381
|
});
|
|
7382
7382
|
let timer;
|
|
7383
7383
|
const timeoutSentinel = /* @__PURE__ */ Symbol("request-code-timeout");
|
|
7384
|
-
const timeoutPromise = new Promise((
|
|
7385
|
-
timer = setTimeout(() =>
|
|
7384
|
+
const timeoutPromise = new Promise((resolve9) => {
|
|
7385
|
+
timer = setTimeout(() => resolve9(timeoutSentinel), REQUEST_CODE_TIMEOUT_MS);
|
|
7386
7386
|
});
|
|
7387
7387
|
const result = await Promise.race([post2, timeoutPromise]);
|
|
7388
7388
|
clearTimeout(timer);
|
|
@@ -7713,7 +7713,7 @@ async function postBeadsProvisioning(input) {
|
|
|
7713
7713
|
}
|
|
7714
7714
|
}
|
|
7715
7715
|
async function _postJsonAuthed(url2, body, pluginAuthToken) {
|
|
7716
|
-
return new Promise((
|
|
7716
|
+
return new Promise((resolve9, reject) => {
|
|
7717
7717
|
const data = JSON.stringify(body);
|
|
7718
7718
|
const u2 = new URL(url2);
|
|
7719
7719
|
const transport = u2.protocol === "https:" ? https : http;
|
|
@@ -7745,9 +7745,9 @@ async function _postJsonAuthed(url2, body, pluginAuthToken) {
|
|
|
7745
7745
|
return;
|
|
7746
7746
|
}
|
|
7747
7747
|
try {
|
|
7748
|
-
|
|
7748
|
+
resolve9(JSON.parse(responseBody));
|
|
7749
7749
|
} catch {
|
|
7750
|
-
|
|
7750
|
+
resolve9(null);
|
|
7751
7751
|
}
|
|
7752
7752
|
});
|
|
7753
7753
|
}
|
|
@@ -7772,7 +7772,7 @@ function makeHttpError(statusCode, retryAfterHeader, responseBody) {
|
|
|
7772
7772
|
return err;
|
|
7773
7773
|
}
|
|
7774
7774
|
async function _postJson(url2, body, extraHeaders) {
|
|
7775
|
-
return new Promise((
|
|
7775
|
+
return new Promise((resolve9, reject) => {
|
|
7776
7776
|
const data = JSON.stringify(body);
|
|
7777
7777
|
const u2 = new URL(url2);
|
|
7778
7778
|
const transport = u2.protocol === "https:" ? https : http;
|
|
@@ -7802,9 +7802,9 @@ async function _postJson(url2, body, extraHeaders) {
|
|
|
7802
7802
|
return;
|
|
7803
7803
|
}
|
|
7804
7804
|
try {
|
|
7805
|
-
|
|
7805
|
+
resolve9(JSON.parse(body2));
|
|
7806
7806
|
} catch {
|
|
7807
|
-
|
|
7807
|
+
resolve9(null);
|
|
7808
7808
|
}
|
|
7809
7809
|
});
|
|
7810
7810
|
}
|
|
@@ -7819,7 +7819,7 @@ async function _postJson(url2, body, extraHeaders) {
|
|
|
7819
7819
|
});
|
|
7820
7820
|
}
|
|
7821
7821
|
async function _getJson(url2, extraHeaders) {
|
|
7822
|
-
return new Promise((
|
|
7822
|
+
return new Promise((resolve9, reject) => {
|
|
7823
7823
|
const u2 = new URL(url2);
|
|
7824
7824
|
const transport = u2.protocol === "https:" ? https : http;
|
|
7825
7825
|
const req = transport.request(
|
|
@@ -7843,9 +7843,9 @@ async function _getJson(url2, extraHeaders) {
|
|
|
7843
7843
|
return;
|
|
7844
7844
|
}
|
|
7845
7845
|
try {
|
|
7846
|
-
|
|
7846
|
+
resolve9(JSON.parse(body));
|
|
7847
7847
|
} catch {
|
|
7848
|
-
|
|
7848
|
+
resolve9(null);
|
|
7849
7849
|
}
|
|
7850
7850
|
});
|
|
7851
7851
|
}
|
|
@@ -8427,7 +8427,7 @@ var CommandRelayService = class _CommandRelayService {
|
|
|
8427
8427
|
// fresh + clear the "CLI update available" banner after a self-update
|
|
8428
8428
|
// (a codespace that reinstalls @latest reconnects via heartbeat, not
|
|
8429
8429
|
// pair/reconnect). Older backends ignore the extra field.
|
|
8430
|
-
..."2.61.
|
|
8430
|
+
..."2.61.70" ? { ideVersion: "2.61.70" } : {}
|
|
8431
8431
|
}).then(() => log.trace("relay", `heartbeat ok online=${online}`)).catch((err) => log.trace("relay", `heartbeat failed online=${online}`, err));
|
|
8432
8432
|
}
|
|
8433
8433
|
/**
|
|
@@ -8591,7 +8591,7 @@ var _transport2 = {
|
|
|
8591
8591
|
post: _post
|
|
8592
8592
|
};
|
|
8593
8593
|
function _post(url2, headers, payload) {
|
|
8594
|
-
return new Promise((
|
|
8594
|
+
return new Promise((resolve9, reject) => {
|
|
8595
8595
|
let settled = false;
|
|
8596
8596
|
const u2 = new URL(url2);
|
|
8597
8597
|
const lib = u2.protocol === "https:" ? https3 : http3;
|
|
@@ -8616,7 +8616,7 @@ function _post(url2, headers, payload) {
|
|
|
8616
8616
|
res.on("end", () => {
|
|
8617
8617
|
if (settled) return;
|
|
8618
8618
|
settled = true;
|
|
8619
|
-
|
|
8619
|
+
resolve9({ statusCode: res.statusCode ?? 0, body });
|
|
8620
8620
|
});
|
|
8621
8621
|
}
|
|
8622
8622
|
);
|
|
@@ -8654,10 +8654,10 @@ var WINDOWS_LEGACY_JUNCTIONS = [
|
|
|
8654
8654
|
/[\\/]Start Menu([\\/]|$)/i,
|
|
8655
8655
|
/[\\/]Templates([\\/]|$)/i
|
|
8656
8656
|
];
|
|
8657
|
-
function isUnsafeWindowsWatchRoot(dir,
|
|
8657
|
+
function isUnsafeWindowsWatchRoot(dir, homedir48) {
|
|
8658
8658
|
const norm = (p2) => p2.replace(/\//g, "\\").replace(/\\+$/, "").toLowerCase();
|
|
8659
8659
|
const cwd = norm(dir);
|
|
8660
|
-
const home = norm(
|
|
8660
|
+
const home = norm(homedir48);
|
|
8661
8661
|
if (cwd === home) return true;
|
|
8662
8662
|
if (/^[a-z]:$/.test(cwd)) return true;
|
|
8663
8663
|
const sysRoots = [
|
|
@@ -9304,12 +9304,12 @@ var _gitSeam = {
|
|
|
9304
9304
|
run: _runGitImpl
|
|
9305
9305
|
};
|
|
9306
9306
|
async function _runGitImpl(cwd, args2, opts = {}) {
|
|
9307
|
-
return new Promise((
|
|
9307
|
+
return new Promise((resolve9) => {
|
|
9308
9308
|
let proc;
|
|
9309
9309
|
try {
|
|
9310
9310
|
proc = (0, import_child_process3.spawn)("git", args2, { cwd, env: process.env });
|
|
9311
9311
|
} catch {
|
|
9312
|
-
|
|
9312
|
+
resolve9(null);
|
|
9313
9313
|
return;
|
|
9314
9314
|
}
|
|
9315
9315
|
let stdout = "";
|
|
@@ -9320,13 +9320,13 @@ async function _runGitImpl(cwd, args2, opts = {}) {
|
|
|
9320
9320
|
proc.stderr?.on("data", (c2) => {
|
|
9321
9321
|
stderr += c2.toString();
|
|
9322
9322
|
});
|
|
9323
|
-
proc.on("error", () =>
|
|
9323
|
+
proc.on("error", () => resolve9(null));
|
|
9324
9324
|
proc.on("close", (code) => {
|
|
9325
9325
|
if (code === 0 || opts.allowNonZeroExit) {
|
|
9326
|
-
|
|
9326
|
+
resolve9(stdout);
|
|
9327
9327
|
} else {
|
|
9328
9328
|
log.trace("fileWatcher", `git ${args2.join(" ")} exited ${code} stderr=${stderr.slice(0, 200)}`);
|
|
9329
|
-
|
|
9329
|
+
resolve9(null);
|
|
9330
9330
|
}
|
|
9331
9331
|
});
|
|
9332
9332
|
});
|
|
@@ -9412,7 +9412,7 @@ var ChunkEmitter = class {
|
|
|
9412
9412
|
if (this.pairingInvalid) {
|
|
9413
9413
|
return Promise.resolve({ dead: true });
|
|
9414
9414
|
}
|
|
9415
|
-
return new Promise((
|
|
9415
|
+
return new Promise((resolve9) => {
|
|
9416
9416
|
let refreshedOnce = false;
|
|
9417
9417
|
const attempt = (attemptsLeft) => {
|
|
9418
9418
|
_transport3.post(this.url, this.headers, payload).then(({ statusCode, body: resBody }) => {
|
|
@@ -9420,13 +9420,13 @@ var ChunkEmitter = class {
|
|
|
9420
9420
|
if (statusCode === 410 || statusCode === 404 && /SESSION_NOT_FOUND|SESSION_GONE/.test(resBody)) {
|
|
9421
9421
|
process.stderr.write("[codeam] session was deleted/disconnected \u2014 stopping output stream.\n");
|
|
9422
9422
|
log.info("chunkEmitter", `dead status=${statusCode} took=${tookMs}ms`);
|
|
9423
|
-
|
|
9423
|
+
resolve9({ dead: true });
|
|
9424
9424
|
return;
|
|
9425
9425
|
}
|
|
9426
9426
|
if (statusCode === 401 || statusCode === 403) {
|
|
9427
9427
|
if (refreshedOnce) {
|
|
9428
9428
|
this.markPairingInvalid(statusCode, tookMs);
|
|
9429
|
-
|
|
9429
|
+
resolve9({ dead: true });
|
|
9430
9430
|
return;
|
|
9431
9431
|
}
|
|
9432
9432
|
log.warn("chunkEmitter", `auth ${statusCode} took=${tookMs}ms \u2014 attempting silent refresh`);
|
|
@@ -9442,10 +9442,10 @@ var ChunkEmitter = class {
|
|
|
9442
9442
|
}
|
|
9443
9443
|
if (refresh.kind === "gone") {
|
|
9444
9444
|
this.markPairingInvalid(statusCode, tookMs);
|
|
9445
|
-
|
|
9445
|
+
resolve9({ dead: true });
|
|
9446
9446
|
return;
|
|
9447
9447
|
}
|
|
9448
|
-
|
|
9448
|
+
resolve9({ dead: false });
|
|
9449
9449
|
})();
|
|
9450
9450
|
return;
|
|
9451
9451
|
}
|
|
@@ -9456,7 +9456,7 @@ var ChunkEmitter = class {
|
|
|
9456
9456
|
} else {
|
|
9457
9457
|
log.info("chunkEmitter", `ok status=${statusCode} took=${tookMs}ms`);
|
|
9458
9458
|
}
|
|
9459
|
-
|
|
9459
|
+
resolve9({ dead: false });
|
|
9460
9460
|
}).catch((err) => {
|
|
9461
9461
|
log.warn(
|
|
9462
9462
|
"chunkEmitter",
|
|
@@ -9467,7 +9467,7 @@ var ChunkEmitter = class {
|
|
|
9467
9467
|
const delay = 200 * (maxRetries - attemptsLeft + 1);
|
|
9468
9468
|
setTimeout(() => attempt(attemptsLeft - 1), delay);
|
|
9469
9469
|
} else {
|
|
9470
|
-
|
|
9470
|
+
resolve9({ dead: false });
|
|
9471
9471
|
}
|
|
9472
9472
|
});
|
|
9473
9473
|
};
|
|
@@ -9490,7 +9490,7 @@ var _transport3 = {
|
|
|
9490
9490
|
post: _post2
|
|
9491
9491
|
};
|
|
9492
9492
|
function _post2(url2, headers, payload) {
|
|
9493
|
-
return new Promise((
|
|
9493
|
+
return new Promise((resolve9, reject) => {
|
|
9494
9494
|
let settled = false;
|
|
9495
9495
|
const u2 = new URL(url2);
|
|
9496
9496
|
const transport = u2.protocol === "https:" ? https4 : http4;
|
|
@@ -9514,7 +9514,7 @@ function _post2(url2, headers, payload) {
|
|
|
9514
9514
|
res.on("end", () => {
|
|
9515
9515
|
if (settled) return;
|
|
9516
9516
|
settled = true;
|
|
9517
|
-
|
|
9517
|
+
resolve9({ statusCode: res.statusCode ?? 0, body: resData });
|
|
9518
9518
|
});
|
|
9519
9519
|
}
|
|
9520
9520
|
);
|
|
@@ -10589,12 +10589,12 @@ async function applyFileReview(workingDir, filePath, action) {
|
|
|
10589
10589
|
return { ok: true, action, filePath, repoRoot };
|
|
10590
10590
|
}
|
|
10591
10591
|
function runGit2(cwd, args2) {
|
|
10592
|
-
return new Promise((
|
|
10592
|
+
return new Promise((resolve9) => {
|
|
10593
10593
|
let proc;
|
|
10594
10594
|
try {
|
|
10595
10595
|
proc = (0, import_child_process6.spawn)("git", args2, { cwd, env: process.env });
|
|
10596
10596
|
} catch (err) {
|
|
10597
|
-
|
|
10597
|
+
resolve9({ ok: false, code: -1, stdout: "", stderr: err.message });
|
|
10598
10598
|
return;
|
|
10599
10599
|
}
|
|
10600
10600
|
let stdout = "";
|
|
@@ -10607,11 +10607,11 @@ function runGit2(cwd, args2) {
|
|
|
10607
10607
|
});
|
|
10608
10608
|
proc.on(
|
|
10609
10609
|
"error",
|
|
10610
|
-
(err) =>
|
|
10610
|
+
(err) => resolve9({ ok: false, code: -1, stdout, stderr: stderr + err.message })
|
|
10611
10611
|
);
|
|
10612
10612
|
proc.on(
|
|
10613
10613
|
"close",
|
|
10614
|
-
(code) =>
|
|
10614
|
+
(code) => resolve9({ ok: code === 0, code: code ?? -1, stdout, stderr })
|
|
10615
10615
|
);
|
|
10616
10616
|
});
|
|
10617
10617
|
}
|
|
@@ -13283,10 +13283,10 @@ function buildForPlatform(platform3) {
|
|
|
13283
13283
|
var import_node_crypto4 = require("crypto");
|
|
13284
13284
|
|
|
13285
13285
|
// src/agents/claude/resolver.ts
|
|
13286
|
-
function buildClaudeLaunch(extraArgs = [],
|
|
13287
|
-
const found =
|
|
13286
|
+
function buildClaudeLaunch(extraArgs = [], os60 = createOsStrategy()) {
|
|
13287
|
+
const found = os60.findInPath("claude") ?? os60.findInPath("claude-code");
|
|
13288
13288
|
if (!found) return null;
|
|
13289
|
-
return
|
|
13289
|
+
return os60.buildLaunch(found, extraArgs);
|
|
13290
13290
|
}
|
|
13291
13291
|
|
|
13292
13292
|
// src/agents/claude/installer.ts
|
|
@@ -13313,12 +13313,12 @@ function isAvailable() {
|
|
|
13313
13313
|
}
|
|
13314
13314
|
function augmentPath() {
|
|
13315
13315
|
const dirs = probeInstallDirs();
|
|
13316
|
-
const
|
|
13316
|
+
const sep7 = path16.delimiter;
|
|
13317
13317
|
const current = process.env.PATH ?? "";
|
|
13318
|
-
const existing = new Set(current.split(
|
|
13318
|
+
const existing = new Set(current.split(sep7).filter(Boolean));
|
|
13319
13319
|
const additions = dirs.filter((d3) => !existing.has(d3));
|
|
13320
13320
|
if (additions.length === 0) return;
|
|
13321
|
-
process.env.PATH = additions.join(
|
|
13321
|
+
process.env.PATH = additions.join(sep7) + sep7 + current;
|
|
13322
13322
|
}
|
|
13323
13323
|
function runInstaller() {
|
|
13324
13324
|
const isWindows = process.platform === "win32";
|
|
@@ -13330,15 +13330,15 @@ function runInstaller() {
|
|
|
13330
13330
|
"-Command",
|
|
13331
13331
|
"irm https://claude.ai/install.ps1 | iex"
|
|
13332
13332
|
] : ["-c", "curl -fsSL https://claude.ai/install.sh | bash"];
|
|
13333
|
-
return new Promise((
|
|
13333
|
+
return new Promise((resolve9) => {
|
|
13334
13334
|
const proc = (0, import_child_process9.spawn)(cmd, args2, { stdio: "inherit" });
|
|
13335
13335
|
proc.on("error", (err) => {
|
|
13336
13336
|
console.error(`
|
|
13337
13337
|
\u2717 Installer failed to launch: ${err.message}`);
|
|
13338
|
-
|
|
13338
|
+
resolve9(false);
|
|
13339
13339
|
});
|
|
13340
13340
|
proc.on("exit", (code) => {
|
|
13341
|
-
|
|
13341
|
+
resolve9(code === 0);
|
|
13342
13342
|
});
|
|
13343
13343
|
});
|
|
13344
13344
|
}
|
|
@@ -13471,7 +13471,7 @@ function extractSetupTokenFromOutput(output) {
|
|
|
13471
13471
|
return m ? m[0] : null;
|
|
13472
13472
|
}
|
|
13473
13473
|
function captureClaudeSetupToken() {
|
|
13474
|
-
return new Promise((
|
|
13474
|
+
return new Promise((resolve9, reject) => {
|
|
13475
13475
|
const child = (0, import_node_child_process3.spawn)("claude", ["setup-token"], {
|
|
13476
13476
|
stdio: ["inherit", "pipe", "inherit"]
|
|
13477
13477
|
});
|
|
@@ -13485,7 +13485,7 @@ function captureClaudeSetupToken() {
|
|
|
13485
13485
|
child.on("exit", (code) => {
|
|
13486
13486
|
const token = extractSetupTokenFromOutput(out2);
|
|
13487
13487
|
if (token) {
|
|
13488
|
-
|
|
13488
|
+
resolve9({ method: "setup_token", credential: token, source: "setup-token" });
|
|
13489
13489
|
return;
|
|
13490
13490
|
}
|
|
13491
13491
|
reject(
|
|
@@ -13571,17 +13571,17 @@ function parseUsageOutput(raw) {
|
|
|
13571
13571
|
return { percent, resetAt };
|
|
13572
13572
|
}
|
|
13573
13573
|
async function fetchClaudeQuota() {
|
|
13574
|
-
return new Promise((
|
|
13574
|
+
return new Promise((resolve9) => {
|
|
13575
13575
|
const claudeCmd = findInPath("claude") ? "claude" : "claude-code";
|
|
13576
13576
|
if (!claudeCmd) {
|
|
13577
|
-
|
|
13577
|
+
resolve9(null);
|
|
13578
13578
|
return;
|
|
13579
13579
|
}
|
|
13580
13580
|
const helperPath = path18.join(os13.tmpdir(), "codeam-quota-helper.py");
|
|
13581
13581
|
fs15.writeFileSync(helperPath, HELPER_SCRIPT, { mode: 420 });
|
|
13582
13582
|
const python = findInPath("python3") ?? findInPath("python");
|
|
13583
13583
|
if (!python) {
|
|
13584
|
-
|
|
13584
|
+
resolve9(null);
|
|
13585
13585
|
return;
|
|
13586
13586
|
}
|
|
13587
13587
|
const proc = (0, import_child_process10.spawn)(python, [helperPath, claudeCmd, "--tools", ""], {
|
|
@@ -13608,13 +13608,13 @@ async function fetchClaudeQuota() {
|
|
|
13608
13608
|
fs15.unlinkSync(helperPath);
|
|
13609
13609
|
} catch {
|
|
13610
13610
|
}
|
|
13611
|
-
|
|
13611
|
+
resolve9(result);
|
|
13612
13612
|
}, 5e3);
|
|
13613
13613
|
}, 8e3);
|
|
13614
13614
|
setTimeout(() => {
|
|
13615
13615
|
if (!resolved) {
|
|
13616
13616
|
resolved = true;
|
|
13617
|
-
|
|
13617
|
+
resolve9(null);
|
|
13618
13618
|
}
|
|
13619
13619
|
try {
|
|
13620
13620
|
proc.kill();
|
|
@@ -13639,12 +13639,12 @@ function killActiveSpawnAndCaptureChildren() {
|
|
|
13639
13639
|
}
|
|
13640
13640
|
async function spawnAndCapture(cmd, args2, opts = {}) {
|
|
13641
13641
|
const timeoutMs = opts.timeoutMs ?? 6e4;
|
|
13642
|
-
return new Promise((
|
|
13642
|
+
return new Promise((resolve9) => {
|
|
13643
13643
|
let settled = false;
|
|
13644
13644
|
const settle = (value) => {
|
|
13645
13645
|
if (settled) return;
|
|
13646
13646
|
settled = true;
|
|
13647
|
-
|
|
13647
|
+
resolve9(value);
|
|
13648
13648
|
};
|
|
13649
13649
|
let child;
|
|
13650
13650
|
try {
|
|
@@ -13876,8 +13876,8 @@ var ClaudeRuntimeStrategy = class {
|
|
|
13876
13876
|
meta = getAgent("claude");
|
|
13877
13877
|
mode = "interactive";
|
|
13878
13878
|
os;
|
|
13879
|
-
constructor(
|
|
13880
|
-
this.os =
|
|
13879
|
+
constructor(os60) {
|
|
13880
|
+
this.os = os60;
|
|
13881
13881
|
}
|
|
13882
13882
|
/**
|
|
13883
13883
|
* Claude Code's react-ink TUI enables bracketed-paste mode at
|
|
@@ -14555,7 +14555,7 @@ function newestRolloutIdSince(sessionsRoot, resolvedCwd, floorMs) {
|
|
|
14555
14555
|
return bestId;
|
|
14556
14556
|
}
|
|
14557
14557
|
function sleep2(ms) {
|
|
14558
|
-
return new Promise((
|
|
14558
|
+
return new Promise((resolve9) => setTimeout(resolve9, ms));
|
|
14559
14559
|
}
|
|
14560
14560
|
function getCurrentUsage2(historyDir) {
|
|
14561
14561
|
if (!import_node_fs3.default.existsSync(historyDir)) return null;
|
|
@@ -14657,8 +14657,8 @@ function codexCredentialLocator() {
|
|
|
14657
14657
|
function codexLoginLauncher() {
|
|
14658
14658
|
return {
|
|
14659
14659
|
async ensureInstalled() {
|
|
14660
|
-
const
|
|
14661
|
-
return
|
|
14660
|
+
const os60 = createOsStrategy();
|
|
14661
|
+
return os60.findInPath("codex") !== null;
|
|
14662
14662
|
},
|
|
14663
14663
|
launch() {
|
|
14664
14664
|
return (0, import_node_child_process4.spawn)("codex", ["login"], { stdio: "inherit" });
|
|
@@ -14681,8 +14681,8 @@ var CodexRuntimeStrategy = class {
|
|
|
14681
14681
|
meta = getAgent("codex");
|
|
14682
14682
|
mode = "interactive";
|
|
14683
14683
|
os;
|
|
14684
|
-
constructor(
|
|
14685
|
-
this.os =
|
|
14684
|
+
constructor(os60) {
|
|
14685
|
+
this.os = os60;
|
|
14686
14686
|
}
|
|
14687
14687
|
async prepareLaunch() {
|
|
14688
14688
|
let binary = this.os.findInPath("codex");
|
|
@@ -14791,16 +14791,16 @@ var CodexRuntimeStrategy = class {
|
|
|
14791
14791
|
});
|
|
14792
14792
|
}
|
|
14793
14793
|
};
|
|
14794
|
-
function resolveNpm(
|
|
14795
|
-
return
|
|
14794
|
+
function resolveNpm(os60) {
|
|
14795
|
+
return os60.id === "win32" ? "npm.cmd" : "npm";
|
|
14796
14796
|
}
|
|
14797
|
-
async function installCodexViaNpm(
|
|
14798
|
-
return new Promise((
|
|
14799
|
-
const proc = (0, import_node_child_process5.spawn)(resolveNpm(
|
|
14797
|
+
async function installCodexViaNpm(os60) {
|
|
14798
|
+
return new Promise((resolve9, reject) => {
|
|
14799
|
+
const proc = (0, import_node_child_process5.spawn)(resolveNpm(os60), ["install", "-g", "@openai/codex"], {
|
|
14800
14800
|
stdio: "inherit"
|
|
14801
14801
|
});
|
|
14802
14802
|
proc.on("close", (code) => {
|
|
14803
|
-
if (code === 0)
|
|
14803
|
+
if (code === 0) resolve9();
|
|
14804
14804
|
else reject(new Error(`npm install -g @openai/codex exited ${code}`));
|
|
14805
14805
|
});
|
|
14806
14806
|
proc.on("error", (err) => {
|
|
@@ -14813,16 +14813,16 @@ async function installCodexViaNpm(os59) {
|
|
|
14813
14813
|
});
|
|
14814
14814
|
});
|
|
14815
14815
|
}
|
|
14816
|
-
function augmentNpmGlobalBin(
|
|
14816
|
+
function augmentNpmGlobalBin(os60) {
|
|
14817
14817
|
try {
|
|
14818
|
-
const result = (0, import_node_child_process5.spawnSync)(resolveNpm(
|
|
14818
|
+
const result = (0, import_node_child_process5.spawnSync)(resolveNpm(os60), ["prefix", "-g"], {
|
|
14819
14819
|
stdio: ["ignore", "pipe", "ignore"]
|
|
14820
14820
|
});
|
|
14821
14821
|
if (result.status !== 0) return;
|
|
14822
14822
|
const prefix = result.stdout.toString().trim();
|
|
14823
14823
|
if (!prefix) return;
|
|
14824
|
-
const binDir =
|
|
14825
|
-
|
|
14824
|
+
const binDir = os60.id === "win32" ? prefix : path24.join(prefix, "bin");
|
|
14825
|
+
os60.augmentPath([binDir]);
|
|
14826
14826
|
} catch {
|
|
14827
14827
|
}
|
|
14828
14828
|
}
|
|
@@ -14906,16 +14906,16 @@ var import_node_child_process8 = require("child_process");
|
|
|
14906
14906
|
// src/agents/coderabbit/installer.ts
|
|
14907
14907
|
var import_node_child_process6 = require("child_process");
|
|
14908
14908
|
var INSTALL_URL = "https://cli.coderabbit.ai/install.sh";
|
|
14909
|
-
async function ensureCoderabbitInstalled(
|
|
14910
|
-
if (
|
|
14911
|
-
if (
|
|
14909
|
+
async function ensureCoderabbitInstalled(os60) {
|
|
14910
|
+
if (os60.findInPath("coderabbit")) return true;
|
|
14911
|
+
if (os60.id === "win32") {
|
|
14912
14912
|
console.error(
|
|
14913
14913
|
"\n \u2717 CodeRabbit on Windows requires WSL.\n Install the CLI inside your WSL distribution\n (curl -fsSL https://cli.coderabbit.ai/install.sh | sh)\n then re-run `codeam link coderabbit` from WSL.\n"
|
|
14914
14914
|
);
|
|
14915
14915
|
return false;
|
|
14916
14916
|
}
|
|
14917
14917
|
console.log("\n CodeRabbit CLI not found \u2014 installing via the official script\u2026\n");
|
|
14918
|
-
const ok = await new Promise((
|
|
14918
|
+
const ok = await new Promise((resolve9) => {
|
|
14919
14919
|
const INSTALL_TIMEOUT_MS2 = 15e4;
|
|
14920
14920
|
const proc = (0, import_node_child_process6.spawn)(
|
|
14921
14921
|
"sh",
|
|
@@ -14927,7 +14927,7 @@ async function ensureCoderabbitInstalled(os59) {
|
|
|
14927
14927
|
if (settled) return;
|
|
14928
14928
|
settled = true;
|
|
14929
14929
|
clearTimeout(timer);
|
|
14930
|
-
|
|
14930
|
+
resolve9(v);
|
|
14931
14931
|
};
|
|
14932
14932
|
const timer = setTimeout(() => {
|
|
14933
14933
|
console.error("\n \u2717 CodeRabbit install timed out \u2014 check network egress and retry.\n");
|
|
@@ -14941,8 +14941,8 @@ async function ensureCoderabbitInstalled(os59) {
|
|
|
14941
14941
|
proc.on("error", () => finish(false));
|
|
14942
14942
|
});
|
|
14943
14943
|
if (!ok) return false;
|
|
14944
|
-
|
|
14945
|
-
return
|
|
14944
|
+
os60.augmentPath([`${os60.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
|
|
14945
|
+
return os60.findInPath("coderabbit") !== null;
|
|
14946
14946
|
}
|
|
14947
14947
|
|
|
14948
14948
|
// src/agents/coderabbit/link.ts
|
|
@@ -14977,10 +14977,10 @@ function coderabbitCredentialLocator() {
|
|
|
14977
14977
|
validate: validateNonEmptyCredential
|
|
14978
14978
|
};
|
|
14979
14979
|
}
|
|
14980
|
-
function coderabbitLoginLauncher(
|
|
14980
|
+
function coderabbitLoginLauncher(os60) {
|
|
14981
14981
|
return {
|
|
14982
14982
|
async ensureInstalled() {
|
|
14983
|
-
return ensureCoderabbitInstalled(
|
|
14983
|
+
return ensureCoderabbitInstalled(os60);
|
|
14984
14984
|
},
|
|
14985
14985
|
launch() {
|
|
14986
14986
|
return (0, import_node_child_process7.spawn)("coderabbit", ["auth", "login"], { stdio: "inherit" });
|
|
@@ -15036,8 +15036,8 @@ function pickLine(obj) {
|
|
|
15036
15036
|
function toHunk(raw, groupSeverity) {
|
|
15037
15037
|
if (!raw || typeof raw !== "object") return null;
|
|
15038
15038
|
const o = raw;
|
|
15039
|
-
const
|
|
15040
|
-
if (!
|
|
15039
|
+
const path80 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
|
|
15040
|
+
if (!path80) return null;
|
|
15041
15041
|
const message = asString(
|
|
15042
15042
|
pick(o, [
|
|
15043
15043
|
"comment",
|
|
@@ -15054,7 +15054,7 @@ function toHunk(raw, groupSeverity) {
|
|
|
15054
15054
|
const severity = normSeverity(pick(o, ["severity", "level", "priority", "impact"])) ?? normSeverity(groupSeverity);
|
|
15055
15055
|
const locObj = pick(o, ["location"]) ?? o;
|
|
15056
15056
|
return {
|
|
15057
|
-
path:
|
|
15057
|
+
path: path80.trim(),
|
|
15058
15058
|
line: pickLine(o) ?? pickLine(locObj),
|
|
15059
15059
|
severity,
|
|
15060
15060
|
message: (title && message ? `${title}: ${message}` : title || message).trim() || "(no message)"
|
|
@@ -15137,10 +15137,10 @@ function parsePlain(stdout) {
|
|
|
15137
15137
|
for (const line of stdout.split(/\r?\n/)) {
|
|
15138
15138
|
const m = line.match(HUNK_LINE_RE);
|
|
15139
15139
|
if (!m) continue;
|
|
15140
|
-
const [,
|
|
15141
|
-
if (!
|
|
15140
|
+
const [, path80, lineNo, sevToken, message] = m;
|
|
15141
|
+
if (!path80 || !lineNo || !message) continue;
|
|
15142
15142
|
hunks.push({
|
|
15143
|
-
path:
|
|
15143
|
+
path: path80.trim(),
|
|
15144
15144
|
line: Number(lineNo),
|
|
15145
15145
|
severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
|
|
15146
15146
|
message: message.trim().replace(/^[*-]\s+/, "")
|
|
@@ -15200,8 +15200,8 @@ var CoderabbitRuntimeStrategy = class {
|
|
|
15200
15200
|
meta = getAgent("coderabbit");
|
|
15201
15201
|
mode = "batch";
|
|
15202
15202
|
os;
|
|
15203
|
-
constructor(
|
|
15204
|
-
this.os =
|
|
15203
|
+
constructor(os60) {
|
|
15204
|
+
this.os = os60;
|
|
15205
15205
|
}
|
|
15206
15206
|
getDefaultArgs() {
|
|
15207
15207
|
return ["review", "--agent"];
|
|
@@ -15237,7 +15237,7 @@ var CoderabbitRuntimeStrategy = class {
|
|
|
15237
15237
|
}
|
|
15238
15238
|
async runOneShot(input) {
|
|
15239
15239
|
const launch = await this.prepareInvocation(input);
|
|
15240
|
-
return new Promise((
|
|
15240
|
+
return new Promise((resolve9, reject) => {
|
|
15241
15241
|
const stdoutBuf = [];
|
|
15242
15242
|
const stderrBuf = [];
|
|
15243
15243
|
const proc = (0, import_node_child_process8.spawn)(launch.cmd, launch.args, {
|
|
@@ -15249,7 +15249,7 @@ var CoderabbitRuntimeStrategy = class {
|
|
|
15249
15249
|
if (settled) return;
|
|
15250
15250
|
settled = true;
|
|
15251
15251
|
clearTimeout(timer);
|
|
15252
|
-
|
|
15252
|
+
resolve9(out2);
|
|
15253
15253
|
};
|
|
15254
15254
|
const timer = setTimeout(() => {
|
|
15255
15255
|
if (settled) return;
|
|
@@ -15472,10 +15472,10 @@ function cursorCredentialLocator() {
|
|
|
15472
15472
|
validate: validateNonEmptyCredential
|
|
15473
15473
|
};
|
|
15474
15474
|
}
|
|
15475
|
-
function cursorLoginLauncher(
|
|
15475
|
+
function cursorLoginLauncher(os60) {
|
|
15476
15476
|
return {
|
|
15477
15477
|
async ensureInstalled() {
|
|
15478
|
-
if (
|
|
15478
|
+
if (os60.findInPath("cursor-agent")) return true;
|
|
15479
15479
|
console.error(
|
|
15480
15480
|
"\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"
|
|
15481
15481
|
);
|
|
@@ -15539,8 +15539,8 @@ var CursorRuntimeStrategy = class {
|
|
|
15539
15539
|
meta = getAgent("cursor");
|
|
15540
15540
|
mode = "interactive";
|
|
15541
15541
|
os;
|
|
15542
|
-
constructor(
|
|
15543
|
-
this.os =
|
|
15542
|
+
constructor(os60) {
|
|
15543
|
+
this.os = os60;
|
|
15544
15544
|
}
|
|
15545
15545
|
async prepareLaunch() {
|
|
15546
15546
|
const binary = this.os.findInPath("cursor-agent");
|
|
@@ -15756,10 +15756,10 @@ function aiderCredentialLocator() {
|
|
|
15756
15756
|
validate: validateNonEmptyCredential
|
|
15757
15757
|
};
|
|
15758
15758
|
}
|
|
15759
|
-
function aiderLoginLauncher(
|
|
15759
|
+
function aiderLoginLauncher(os60) {
|
|
15760
15760
|
return {
|
|
15761
15761
|
async ensureInstalled() {
|
|
15762
|
-
if (
|
|
15762
|
+
if (os60.findInPath("aider")) return true;
|
|
15763
15763
|
console.error(
|
|
15764
15764
|
"\n \u2717 aider binary not on PATH.\n Install Aider:\n pip install aider-chat\n then re-run `codeam link aider`.\n"
|
|
15765
15765
|
);
|
|
@@ -15769,7 +15769,7 @@ function aiderLoginLauncher(os59) {
|
|
|
15769
15769
|
console.error(
|
|
15770
15770
|
"\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"
|
|
15771
15771
|
);
|
|
15772
|
-
return (0, import_node_child_process11.spawn)(
|
|
15772
|
+
return (0, import_node_child_process11.spawn)(os60.id === "win32" ? "cmd.exe" : "sh", os60.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
|
|
15773
15773
|
stdio: "ignore"
|
|
15774
15774
|
});
|
|
15775
15775
|
}
|
|
@@ -15841,8 +15841,8 @@ var AiderRuntimeStrategy = class {
|
|
|
15841
15841
|
meta = getAgent("aider");
|
|
15842
15842
|
mode = "interactive";
|
|
15843
15843
|
os;
|
|
15844
|
-
constructor(
|
|
15845
|
-
this.os =
|
|
15844
|
+
constructor(os60) {
|
|
15845
|
+
this.os = os60;
|
|
15846
15846
|
}
|
|
15847
15847
|
async prepareLaunch() {
|
|
15848
15848
|
const binary = this.os.findInPath("aider");
|
|
@@ -15974,8 +15974,8 @@ function geminiCredentialLocator() {
|
|
|
15974
15974
|
function geminiLoginLauncher() {
|
|
15975
15975
|
return {
|
|
15976
15976
|
async ensureInstalled() {
|
|
15977
|
-
const
|
|
15978
|
-
return
|
|
15977
|
+
const os60 = createOsStrategy();
|
|
15978
|
+
return os60.findInPath("gemini") !== null;
|
|
15979
15979
|
},
|
|
15980
15980
|
launch() {
|
|
15981
15981
|
return (0, import_node_child_process12.spawn)("gemini", ["auth", "login"], { stdio: "inherit" });
|
|
@@ -16165,8 +16165,8 @@ var GeminiRuntimeStrategy = class {
|
|
|
16165
16165
|
meta = getAgent("gemini");
|
|
16166
16166
|
mode = "interactive";
|
|
16167
16167
|
os;
|
|
16168
|
-
constructor(
|
|
16169
|
-
this.os =
|
|
16168
|
+
constructor(os60) {
|
|
16169
|
+
this.os = os60;
|
|
16170
16170
|
}
|
|
16171
16171
|
async prepareLaunch() {
|
|
16172
16172
|
const binary = this.os.findInPath("gemini");
|
|
@@ -16380,7 +16380,7 @@ function newestSessionSince(bucket, floorMs) {
|
|
|
16380
16380
|
return bestId;
|
|
16381
16381
|
}
|
|
16382
16382
|
function sleep3(ms) {
|
|
16383
|
-
return new Promise((
|
|
16383
|
+
return new Promise((resolve9) => setTimeout(resolve9, ms));
|
|
16384
16384
|
}
|
|
16385
16385
|
function joinTextParts(parts) {
|
|
16386
16386
|
if (!Array.isArray(parts)) return "";
|
|
@@ -16457,8 +16457,8 @@ var KimiRuntimeStrategy = class {
|
|
|
16457
16457
|
meta = getAgent("kimi");
|
|
16458
16458
|
mode = "interactive";
|
|
16459
16459
|
os;
|
|
16460
|
-
constructor(
|
|
16461
|
-
this.os =
|
|
16460
|
+
constructor(os60) {
|
|
16461
|
+
this.os = os60;
|
|
16462
16462
|
}
|
|
16463
16463
|
async prepareLaunch() {
|
|
16464
16464
|
const binary = this.os.findInPath("kimi");
|
|
@@ -16600,8 +16600,8 @@ var OpencodeRuntimeStrategy = class {
|
|
|
16600
16600
|
meta = getAgent("opencode");
|
|
16601
16601
|
mode = "interactive";
|
|
16602
16602
|
os;
|
|
16603
|
-
constructor(
|
|
16604
|
-
this.os =
|
|
16603
|
+
constructor(os60) {
|
|
16604
|
+
this.os = os60;
|
|
16605
16605
|
}
|
|
16606
16606
|
async prepareLaunch() {
|
|
16607
16607
|
const binary = this.os.findInPath("opencode");
|
|
@@ -16685,20 +16685,20 @@ var OpencodeRuntimeStrategy = class {
|
|
|
16685
16685
|
|
|
16686
16686
|
// src/agents/registry.ts
|
|
16687
16687
|
var runtimeBuilders = {
|
|
16688
|
-
claude: (
|
|
16689
|
-
codex: (
|
|
16690
|
-
coderabbit: (
|
|
16691
|
-
cursor: (
|
|
16692
|
-
aider: (
|
|
16693
|
-
gemini: (
|
|
16694
|
-
kimi: (
|
|
16695
|
-
opencode: (
|
|
16688
|
+
claude: (os60) => new ClaudeRuntimeStrategy(os60),
|
|
16689
|
+
codex: (os60) => new CodexRuntimeStrategy(os60),
|
|
16690
|
+
coderabbit: (os60) => new CoderabbitRuntimeStrategy(os60),
|
|
16691
|
+
cursor: (os60) => new CursorRuntimeStrategy(os60),
|
|
16692
|
+
aider: (os60) => new AiderRuntimeStrategy(os60),
|
|
16693
|
+
gemini: (os60) => new GeminiRuntimeStrategy(os60),
|
|
16694
|
+
kimi: (os60) => new KimiRuntimeStrategy(os60),
|
|
16695
|
+
opencode: (os60) => new OpencodeRuntimeStrategy(os60)
|
|
16696
16696
|
};
|
|
16697
16697
|
var deployBuilders = {
|
|
16698
16698
|
claude: () => new ClaudeDeployStrategy(),
|
|
16699
16699
|
codex: () => new CodexDeployStrategy()
|
|
16700
16700
|
};
|
|
16701
|
-
function createAgentStrategy(agent,
|
|
16701
|
+
function createAgentStrategy(agent, os60 = createOsStrategy()) {
|
|
16702
16702
|
if (!AGENT_REGISTRY[agent]?.enabled) {
|
|
16703
16703
|
throw new Error(
|
|
16704
16704
|
`Agent "${agent}" is not supported in this codeam-cli version. Upgrade with 'npm i -g codeam-cli@latest'.`
|
|
@@ -16708,10 +16708,10 @@ function createAgentStrategy(agent, os59 = createOsStrategy()) {
|
|
|
16708
16708
|
if (!build) {
|
|
16709
16709
|
throw new Error(`No runtime strategy registered for agent "${agent}"`);
|
|
16710
16710
|
}
|
|
16711
|
-
return build(
|
|
16711
|
+
return build(os60);
|
|
16712
16712
|
}
|
|
16713
|
-
function createInteractiveAgentStrategy(agent,
|
|
16714
|
-
const s = createAgentStrategy(agent,
|
|
16713
|
+
function createInteractiveAgentStrategy(agent, os60 = createOsStrategy()) {
|
|
16714
|
+
const s = createAgentStrategy(agent, os60);
|
|
16715
16715
|
if (s.mode !== "interactive") {
|
|
16716
16716
|
throw new Error(
|
|
16717
16717
|
`Agent "${agent}" is a batch agent; use createAgentStrategy + .runOneShot for one-shot reviews.`
|
|
@@ -16827,7 +16827,7 @@ async function link(args2 = []) {
|
|
|
16827
16827
|
waitSpin.start(waitMsg());
|
|
16828
16828
|
const countdown = setInterval(() => waitSpin.message(waitMsg()), 1e3);
|
|
16829
16829
|
countdown.unref?.();
|
|
16830
|
-
const paired = await new Promise((
|
|
16830
|
+
const paired = await new Promise((resolve9, reject) => {
|
|
16831
16831
|
let stopPoll = null;
|
|
16832
16832
|
const sigint = () => {
|
|
16833
16833
|
clearInterval(countdown);
|
|
@@ -16840,7 +16840,7 @@ async function link(args2 = []) {
|
|
|
16840
16840
|
process.removeListener("SIGINT", sigint);
|
|
16841
16841
|
clearInterval(countdown);
|
|
16842
16842
|
waitSpin.stop("Paired");
|
|
16843
|
-
|
|
16843
|
+
resolve9(info);
|
|
16844
16844
|
},
|
|
16845
16845
|
() => {
|
|
16846
16846
|
clearInterval(countdown);
|
|
@@ -16998,14 +16998,14 @@ async function captureFreshCredentials(ctx) {
|
|
|
16998
16998
|
}
|
|
16999
16999
|
};
|
|
17000
17000
|
try {
|
|
17001
|
-
const token = await new Promise((
|
|
17001
|
+
const token = await new Promise((resolve9, reject) => {
|
|
17002
17002
|
let settled = false;
|
|
17003
17003
|
const tryExtract = async () => {
|
|
17004
17004
|
if (settled) return;
|
|
17005
17005
|
const t2 = await ctx.locator.extract();
|
|
17006
17006
|
if (t2 && !settled) {
|
|
17007
17007
|
settled = true;
|
|
17008
|
-
|
|
17008
|
+
resolve9(t2);
|
|
17009
17009
|
}
|
|
17010
17010
|
};
|
|
17011
17011
|
watcher.on("add", () => void tryExtract());
|
|
@@ -17214,7 +17214,7 @@ function deliverPendingCoderabbitCallback(callbackUrl) {
|
|
|
17214
17214
|
function runCoderabbitOAuthLogin(deps) {
|
|
17215
17215
|
const timeoutMs = deps.timeoutMs ?? 18e4;
|
|
17216
17216
|
const spawnProc = deps.spawn ?? spawnCoderabbitLoginProc;
|
|
17217
|
-
return new Promise((
|
|
17217
|
+
return new Promise((resolve9) => {
|
|
17218
17218
|
let settled = false;
|
|
17219
17219
|
let stdout = "";
|
|
17220
17220
|
let last = null;
|
|
@@ -17227,13 +17227,13 @@ function runCoderabbitOAuthLogin(deps) {
|
|
|
17227
17227
|
child.kill("SIGKILL");
|
|
17228
17228
|
} catch {
|
|
17229
17229
|
}
|
|
17230
|
-
|
|
17230
|
+
resolve9(r);
|
|
17231
17231
|
};
|
|
17232
17232
|
let child;
|
|
17233
17233
|
try {
|
|
17234
17234
|
child = spawnProc("coderabbit", ["auth", "login", "--agent"]);
|
|
17235
17235
|
} catch (err) {
|
|
17236
|
-
|
|
17236
|
+
resolve9({ ok: false, error: err instanceof Error ? err.message : "spawn failed" });
|
|
17237
17237
|
return;
|
|
17238
17238
|
}
|
|
17239
17239
|
const timer = setTimeout(
|
|
@@ -17408,26 +17408,26 @@ function restoreCoderabbitOauthBlob(value) {
|
|
|
17408
17408
|
(0, import_node_fs5.writeFileSync)(path36.join(dir, file), contents, { mode: 384 });
|
|
17409
17409
|
}
|
|
17410
17410
|
async function configureCoderabbit(input, deps = {}) {
|
|
17411
|
-
const
|
|
17411
|
+
const os60 = deps.os ?? createOsStrategy();
|
|
17412
17412
|
const ensureInstalled = deps.ensureInstalled ?? ensureCoderabbitInstalled;
|
|
17413
17413
|
const isLoggedIn = deps.isLoggedIn ?? defaultIsLoggedIn;
|
|
17414
17414
|
const runOAuth = deps.runOAuthLogin ?? runCoderabbitOAuthLogin;
|
|
17415
17415
|
const snapshot = deps.snapshotDir ?? (() => snapshotCredentialDir());
|
|
17416
17416
|
const capture2 = deps.captureCredential ?? ((b) => diffCapturedCredential(b));
|
|
17417
17417
|
const loginWithApiKey = deps.loginWithApiKey ?? defaultLoginWithApiKey;
|
|
17418
|
-
const home =
|
|
17419
|
-
|
|
17420
|
-
|
|
17418
|
+
const home = os60.homeDir();
|
|
17419
|
+
os60.augmentPath(
|
|
17420
|
+
os60.id === "win32" ? [
|
|
17421
17421
|
path36.join(home, ".local", "bin"),
|
|
17422
17422
|
path36.join(process.env.APPDATA ?? path36.join(home, "AppData", "Roaming"), "npm"),
|
|
17423
17423
|
path36.join(home, "scoop", "shims")
|
|
17424
17424
|
] : [path36.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"]
|
|
17425
17425
|
);
|
|
17426
|
-
const installed2 =
|
|
17426
|
+
const installed2 = os60.findInPath("coderabbit") !== null;
|
|
17427
17427
|
const base = () => ({
|
|
17428
17428
|
action: input.action,
|
|
17429
17429
|
supported: true,
|
|
17430
|
-
installed:
|
|
17430
|
+
installed: os60.findInPath("coderabbit") !== null,
|
|
17431
17431
|
loggedIn: false
|
|
17432
17432
|
});
|
|
17433
17433
|
if (input.action === "status") {
|
|
@@ -17441,7 +17441,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
17441
17441
|
const key = (input.apiKey ?? "").trim();
|
|
17442
17442
|
if (!key) return { ...res2, error: "No API key provided" };
|
|
17443
17443
|
if (!res2.installed) {
|
|
17444
|
-
const ok = await ensureInstalled(
|
|
17444
|
+
const ok = await ensureInstalled(os60);
|
|
17445
17445
|
res2.installed = ok;
|
|
17446
17446
|
if (!ok) return { ...res2, error: "CodeRabbit CLI could not be installed" };
|
|
17447
17447
|
}
|
|
@@ -17465,7 +17465,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
17465
17465
|
}
|
|
17466
17466
|
if (!res2.installed) {
|
|
17467
17467
|
deps.onEvent?.({ kind: "installing" });
|
|
17468
|
-
const ok = await ensureInstalled(
|
|
17468
|
+
const ok = await ensureInstalled(os60);
|
|
17469
17469
|
res2.installed = ok;
|
|
17470
17470
|
if (!ok) return { ...res2, error: "CodeRabbit CLI could not be installed" };
|
|
17471
17471
|
}
|
|
@@ -17495,7 +17495,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
17495
17495
|
const res2 = base();
|
|
17496
17496
|
if (!installed2) {
|
|
17497
17497
|
deps.onEvent?.({ kind: "installing" });
|
|
17498
|
-
const ok = await ensureInstalled(
|
|
17498
|
+
const ok = await ensureInstalled(os60);
|
|
17499
17499
|
res2.installed = ok;
|
|
17500
17500
|
if (!ok) return { ...res2, error: "CodeRabbit CLI could not be installed" };
|
|
17501
17501
|
}
|
|
@@ -17535,7 +17535,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
17535
17535
|
}
|
|
17536
17536
|
const res = base();
|
|
17537
17537
|
if (!res.installed) {
|
|
17538
|
-
const ok = await ensureInstalled(
|
|
17538
|
+
const ok = await ensureInstalled(os60);
|
|
17539
17539
|
res.installed = ok;
|
|
17540
17540
|
if (!ok) return { ...res, error: "CodeRabbit CLI is not installed" };
|
|
17541
17541
|
}
|
|
@@ -17692,23 +17692,23 @@ async function reviewPullRequest(params, deps) {
|
|
|
17692
17692
|
return report;
|
|
17693
17693
|
}
|
|
17694
17694
|
function defaultRunGh(args2) {
|
|
17695
|
-
return new Promise((
|
|
17695
|
+
return new Promise((resolve9) => {
|
|
17696
17696
|
const stdout = [];
|
|
17697
17697
|
const stderr = [];
|
|
17698
17698
|
let proc;
|
|
17699
17699
|
try {
|
|
17700
17700
|
proc = (0, import_node_child_process17.spawn)("gh", args2, { stdio: ["ignore", "pipe", "pipe"] });
|
|
17701
17701
|
} catch (err) {
|
|
17702
|
-
|
|
17702
|
+
resolve9({ code: -1, stdout: "", stderr: err instanceof Error ? err.message : String(err) });
|
|
17703
17703
|
return;
|
|
17704
17704
|
}
|
|
17705
17705
|
proc.stdout?.on("data", (b) => stdout.push(b));
|
|
17706
17706
|
proc.stderr?.on("data", (b) => stderr.push(b));
|
|
17707
17707
|
proc.on("error", (err) => {
|
|
17708
|
-
|
|
17708
|
+
resolve9({ code: -1, stdout: "", stderr: err.message });
|
|
17709
17709
|
});
|
|
17710
17710
|
proc.on("close", (code) => {
|
|
17711
|
-
|
|
17711
|
+
resolve9({
|
|
17712
17712
|
code: code ?? 0,
|
|
17713
17713
|
stdout: Buffer.concat(stdout).toString("utf8"),
|
|
17714
17714
|
stderr: Buffer.concat(stderr).toString("utf8")
|
|
@@ -18680,7 +18680,7 @@ var defaultGitToolingRunner = {
|
|
|
18680
18680
|
}
|
|
18681
18681
|
},
|
|
18682
18682
|
run(cmd, args2, opts = {}) {
|
|
18683
|
-
return new Promise((
|
|
18683
|
+
return new Promise((resolve9) => {
|
|
18684
18684
|
const child = (0, import_node_child_process20.spawn)(cmd, args2, {
|
|
18685
18685
|
stdio: [opts.input !== void 0 ? "pipe" : "ignore", "ignore", "pipe"]
|
|
18686
18686
|
});
|
|
@@ -18689,7 +18689,7 @@ var defaultGitToolingRunner = {
|
|
|
18689
18689
|
const done = (code) => {
|
|
18690
18690
|
if (settled) return;
|
|
18691
18691
|
settled = true;
|
|
18692
|
-
|
|
18692
|
+
resolve9({ code, stderr });
|
|
18693
18693
|
};
|
|
18694
18694
|
child.stderr?.on("data", (b) => {
|
|
18695
18695
|
stderr += b.toString();
|
|
@@ -18847,7 +18847,7 @@ var defaultHeadroomRunner = {
|
|
|
18847
18847
|
}
|
|
18848
18848
|
},
|
|
18849
18849
|
run(cmd, args2, opts = {}) {
|
|
18850
|
-
return new Promise((
|
|
18850
|
+
return new Promise((resolve9) => {
|
|
18851
18851
|
const spawnEnv = opts.env ?? process.env;
|
|
18852
18852
|
const child = (0, import_node_child_process21.spawn)(cmd, args2, { stdio: ["ignore", "pipe", "pipe"], env: spawnEnv });
|
|
18853
18853
|
let stderrBuf = "";
|
|
@@ -18856,7 +18856,7 @@ var defaultHeadroomRunner = {
|
|
|
18856
18856
|
const done = (code) => {
|
|
18857
18857
|
if (settled) return;
|
|
18858
18858
|
settled = true;
|
|
18859
|
-
|
|
18859
|
+
resolve9({ code, stderr: stderrBuf, stdout: stdoutBuf });
|
|
18860
18860
|
};
|
|
18861
18861
|
child.stdout?.on("data", (b) => {
|
|
18862
18862
|
const chunk = b.toString();
|
|
@@ -19427,14 +19427,14 @@ function compareSemver(a, b) {
|
|
|
19427
19427
|
return 0;
|
|
19428
19428
|
}
|
|
19429
19429
|
function fetchLatest() {
|
|
19430
|
-
return new Promise((
|
|
19430
|
+
return new Promise((resolve9) => {
|
|
19431
19431
|
const req = https6.get(
|
|
19432
19432
|
REGISTRY_URL,
|
|
19433
19433
|
{ headers: { Accept: "application/json" }, timeout: REQUEST_TIMEOUT_MS },
|
|
19434
19434
|
(res) => {
|
|
19435
19435
|
if (res.statusCode !== 200) {
|
|
19436
19436
|
res.resume();
|
|
19437
|
-
|
|
19437
|
+
resolve9(null);
|
|
19438
19438
|
return;
|
|
19439
19439
|
}
|
|
19440
19440
|
let buf = "";
|
|
@@ -19446,21 +19446,21 @@ function fetchLatest() {
|
|
|
19446
19446
|
try {
|
|
19447
19447
|
const json = JSON.parse(buf);
|
|
19448
19448
|
if (typeof json.version === "string") {
|
|
19449
|
-
|
|
19449
|
+
resolve9(json.version);
|
|
19450
19450
|
} else {
|
|
19451
|
-
|
|
19451
|
+
resolve9(null);
|
|
19452
19452
|
}
|
|
19453
19453
|
} catch {
|
|
19454
|
-
|
|
19454
|
+
resolve9(null);
|
|
19455
19455
|
}
|
|
19456
19456
|
});
|
|
19457
19457
|
}
|
|
19458
19458
|
);
|
|
19459
19459
|
req.on("timeout", () => {
|
|
19460
19460
|
req.destroy();
|
|
19461
|
-
|
|
19461
|
+
resolve9(null);
|
|
19462
19462
|
});
|
|
19463
|
-
req.on("error", () =>
|
|
19463
|
+
req.on("error", () => resolve9(null));
|
|
19464
19464
|
});
|
|
19465
19465
|
}
|
|
19466
19466
|
function notifyIfStale(currentVersion, latest) {
|
|
@@ -19536,7 +19536,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
19536
19536
|
if (process.env.NODE_ENV === "test") return;
|
|
19537
19537
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
19538
19538
|
if (process.env.CI) return;
|
|
19539
|
-
const current = true ? "2.61.
|
|
19539
|
+
const current = true ? "2.61.70" : null;
|
|
19540
19540
|
if (!current) return;
|
|
19541
19541
|
const cache = readCache();
|
|
19542
19542
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -19553,7 +19553,7 @@ function checkForUpdates() {
|
|
|
19553
19553
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
19554
19554
|
if (process.env.CI) return;
|
|
19555
19555
|
if (!process.stdout.isTTY) return;
|
|
19556
|
-
const current = true ? "2.61.
|
|
19556
|
+
const current = true ? "2.61.70" : null;
|
|
19557
19557
|
if (!current) return;
|
|
19558
19558
|
const cache = readCache();
|
|
19559
19559
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -19573,13 +19573,13 @@ var SELF_UPDATE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
|
19573
19573
|
var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
|
|
19574
19574
|
var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
19575
19575
|
function currentCliVersion() {
|
|
19576
|
-
return true ? "2.61.
|
|
19576
|
+
return true ? "2.61.70" : null;
|
|
19577
19577
|
}
|
|
19578
19578
|
function runCmd(cmd, args2, timeoutMs) {
|
|
19579
|
-
return new Promise((
|
|
19579
|
+
return new Promise((resolve9) => {
|
|
19580
19580
|
(0, import_node_child_process23.execFile)(cmd, args2, { timeout: timeoutMs }, (err, stdout, stderr) => {
|
|
19581
19581
|
const code = err && typeof err.code === "number" ? err.code : err ? null : 0;
|
|
19582
|
-
|
|
19582
|
+
resolve9({ code, stdout: stdout ?? "", stderr: stderr ?? "" });
|
|
19583
19583
|
});
|
|
19584
19584
|
});
|
|
19585
19585
|
}
|
|
@@ -19807,6 +19807,9 @@ function isDeployPayload(p2) {
|
|
|
19807
19807
|
function isStopPayload(p2) {
|
|
19808
19808
|
return typeof p2.sessionId === "string";
|
|
19809
19809
|
}
|
|
19810
|
+
function isCleanupPayload(p2) {
|
|
19811
|
+
return typeof p2.deployId === "string" && p2.deployId.length > 0;
|
|
19812
|
+
}
|
|
19810
19813
|
var FLEET_CONTAINER_NAME_RE = /^codeam-box-[a-z0-9]+$/;
|
|
19811
19814
|
function isFleetContainerName(v) {
|
|
19812
19815
|
return typeof v === "string" && FLEET_CONTAINER_NAME_RE.test(v);
|
|
@@ -19902,7 +19905,7 @@ function buildFleetBoxRunArgs(p2) {
|
|
|
19902
19905
|
var DOCKER_RUN_TIMEOUT_MS = 12e4;
|
|
19903
19906
|
var defaultDockerRunner = {
|
|
19904
19907
|
run(args2, opts = {}) {
|
|
19905
|
-
return new Promise((
|
|
19908
|
+
return new Promise((resolve9) => {
|
|
19906
19909
|
const child = (0, import_node_child_process25.spawn)("docker", args2, {
|
|
19907
19910
|
stdio: ["ignore", "pipe", "pipe"],
|
|
19908
19911
|
env: { ...process.env, ...opts.env }
|
|
@@ -19921,7 +19924,7 @@ var defaultDockerRunner = {
|
|
|
19921
19924
|
if (settled) return;
|
|
19922
19925
|
settled = true;
|
|
19923
19926
|
clearTimeout(timer);
|
|
19924
|
-
|
|
19927
|
+
resolve9({ code, stderr: stderrBuf, stdout: stdoutBuf });
|
|
19925
19928
|
};
|
|
19926
19929
|
child.stdout?.on("data", (b) => {
|
|
19927
19930
|
stdoutBuf += b.toString();
|
|
@@ -20250,6 +20253,14 @@ var HostAgentSupervisor = class {
|
|
|
20250
20253
|
this.stopChild(cmd.payload.sessionId);
|
|
20251
20254
|
return;
|
|
20252
20255
|
}
|
|
20256
|
+
if (cmd.type === "self_hosted_cleanup") {
|
|
20257
|
+
if (!isCleanupPayload(cmd.payload)) {
|
|
20258
|
+
log.warn("host-agent", `ignoring malformed self_hosted_cleanup id=${cmd.id}`);
|
|
20259
|
+
return;
|
|
20260
|
+
}
|
|
20261
|
+
this.cleanupWorkspace(cmd.payload.deployId);
|
|
20262
|
+
return;
|
|
20263
|
+
}
|
|
20253
20264
|
if (cmd.type === "host_list_dir") {
|
|
20254
20265
|
await this.listDir(cmd);
|
|
20255
20266
|
return;
|
|
@@ -20772,7 +20783,7 @@ var HostAgentSupervisor = class {
|
|
|
20772
20783
|
* host-agent whose env may lack it.
|
|
20773
20784
|
*/
|
|
20774
20785
|
runAgentInstall(script) {
|
|
20775
|
-
return new Promise((
|
|
20786
|
+
return new Promise((resolve9) => {
|
|
20776
20787
|
const home = process.env.HOME || os38.homedir();
|
|
20777
20788
|
const child = (0, import_node_child_process25.spawn)("sh", ["-c", script], {
|
|
20778
20789
|
env: { ...process.env, HOME: home },
|
|
@@ -20788,7 +20799,7 @@ var HostAgentSupervisor = class {
|
|
|
20788
20799
|
const done = () => {
|
|
20789
20800
|
if (settled) return;
|
|
20790
20801
|
settled = true;
|
|
20791
|
-
|
|
20802
|
+
resolve9();
|
|
20792
20803
|
};
|
|
20793
20804
|
const timer = setTimeout(() => {
|
|
20794
20805
|
log.warn(
|
|
@@ -20838,6 +20849,44 @@ var HostAgentSupervisor = class {
|
|
|
20838
20849
|
}
|
|
20839
20850
|
this.children.delete(child.deployId);
|
|
20840
20851
|
}
|
|
20852
|
+
/**
|
|
20853
|
+
* Handle `self_hosted_cleanup { deployId }` — the app deleted this deploy's
|
|
20854
|
+
* session. Remove its on-disk workspace so a persistent box doesn't accumulate
|
|
20855
|
+
* one dir per deleted session. Stops any still-running child for the deploy
|
|
20856
|
+
* first (the delete also pushes `session_terminated` to the child, but this is
|
|
20857
|
+
* race-safe), then removes the two `~/.codeam/...<deployId>` dirs.
|
|
20858
|
+
*
|
|
20859
|
+
* Idempotent (`force: true` → no throw if already gone) and inherently safe:
|
|
20860
|
+
* the dir is keyed by the UNIQUE `deployId`, so it can never be another live
|
|
20861
|
+
* session's workspace, and these paths only ever exist for a cloned
|
|
20862
|
+
* self-hosted deploy (a local / absolute-path target has no such dir → no-op).
|
|
20863
|
+
*/
|
|
20864
|
+
cleanupWorkspace(deployId) {
|
|
20865
|
+
const short = deployId.slice(0, 8);
|
|
20866
|
+
const child = this.children.get(deployId);
|
|
20867
|
+
if (child) {
|
|
20868
|
+
try {
|
|
20869
|
+
child.proc.kill("SIGTERM");
|
|
20870
|
+
} catch {
|
|
20871
|
+
}
|
|
20872
|
+
this.children.delete(deployId);
|
|
20873
|
+
}
|
|
20874
|
+
const dirs = [
|
|
20875
|
+
path46.join(selfHostedWorkspaceRoot(), deployId),
|
|
20876
|
+
path46.join(os38.homedir(), ".codeam", "house-claude", deployId)
|
|
20877
|
+
];
|
|
20878
|
+
for (const dir of dirs) {
|
|
20879
|
+
try {
|
|
20880
|
+
fs43.rmSync(dir, { recursive: true, force: true });
|
|
20881
|
+
} catch (err) {
|
|
20882
|
+
log.warn(
|
|
20883
|
+
"host-agent",
|
|
20884
|
+
`cleanup: failed to remove ${dir}: ${err.message}`
|
|
20885
|
+
);
|
|
20886
|
+
}
|
|
20887
|
+
}
|
|
20888
|
+
log.info("host-agent", `cleaned up workspace for deleted deploy=${short}`);
|
|
20889
|
+
}
|
|
20841
20890
|
/**
|
|
20842
20891
|
* Handle `self_hosted_refresh_credentials` (the user re-linked the agent).
|
|
20843
20892
|
* Unseal the fresh credential and re-provision the agent's on-disk auth IN
|
|
@@ -21250,12 +21299,12 @@ async function isExecutableBinary(p2) {
|
|
|
21250
21299
|
}
|
|
21251
21300
|
}
|
|
21252
21301
|
function extractTgz(tgzPath, destDir) {
|
|
21253
|
-
return new Promise((
|
|
21302
|
+
return new Promise((resolve9, reject) => {
|
|
21254
21303
|
const child = (0, import_child_process15.spawn)("tar", ["-xzf", tgzPath, "-C", destDir], { stdio: "ignore" });
|
|
21255
21304
|
child.on("error", (err) => reject(err));
|
|
21256
21305
|
child.on(
|
|
21257
21306
|
"exit",
|
|
21258
|
-
(code) => code === 0 ?
|
|
21307
|
+
(code) => code === 0 ? resolve9() : reject(new Error(`tar exited with code ${code} while extracting cloudflared`))
|
|
21259
21308
|
);
|
|
21260
21309
|
});
|
|
21261
21310
|
}
|
|
@@ -21469,12 +21518,12 @@ function parseExpoUrl(stdout) {
|
|
|
21469
21518
|
// src/services/preview/port-ready.ts
|
|
21470
21519
|
var net = __toESM(require("net"));
|
|
21471
21520
|
function isPortListening(port, host2 = "127.0.0.1") {
|
|
21472
|
-
return new Promise((
|
|
21521
|
+
return new Promise((resolve9) => {
|
|
21473
21522
|
const socket = new net.Socket();
|
|
21474
21523
|
const done = (result) => {
|
|
21475
21524
|
socket.removeAllListeners();
|
|
21476
21525
|
socket.destroy();
|
|
21477
|
-
|
|
21526
|
+
resolve9(result);
|
|
21478
21527
|
};
|
|
21479
21528
|
socket.setTimeout(1e3);
|
|
21480
21529
|
socket.once("connect", () => done(true));
|
|
@@ -21500,7 +21549,7 @@ var import_path6 = __toESM(require("path"));
|
|
|
21500
21549
|
// src/services/preview/run-setup.ts
|
|
21501
21550
|
var import_child_process17 = require("child_process");
|
|
21502
21551
|
function runSetupCommand(cmd, args2, cwd, env, opts) {
|
|
21503
|
-
return new Promise((
|
|
21552
|
+
return new Promise((resolve9) => {
|
|
21504
21553
|
const child = (0, import_child_process17.spawn)(cmd, args2, {
|
|
21505
21554
|
cwd,
|
|
21506
21555
|
env: { ...process.env, ...env ?? {} },
|
|
@@ -21520,20 +21569,20 @@ function runSetupCommand(cmd, args2, cwd, env, opts) {
|
|
|
21520
21569
|
settled = true;
|
|
21521
21570
|
log.info("preview", `${tag}: timed out after ${opts.timeoutMs}ms \u2014 killing`);
|
|
21522
21571
|
killQuiet(child);
|
|
21523
|
-
|
|
21572
|
+
resolve9({ status: "timeout", code: null });
|
|
21524
21573
|
}, opts.timeoutMs);
|
|
21525
21574
|
child.once("exit", (code) => {
|
|
21526
21575
|
if (settled) return;
|
|
21527
21576
|
settled = true;
|
|
21528
21577
|
clearTimeout(timer);
|
|
21529
|
-
if (code === 0)
|
|
21530
|
-
else
|
|
21578
|
+
if (code === 0) resolve9({ status: "ok", code: 0 });
|
|
21579
|
+
else resolve9({ status: "failed", code });
|
|
21531
21580
|
});
|
|
21532
21581
|
child.once("error", () => {
|
|
21533
21582
|
if (settled) return;
|
|
21534
21583
|
settled = true;
|
|
21535
21584
|
clearTimeout(timer);
|
|
21536
|
-
|
|
21585
|
+
resolve9({ status: "failed", code: null });
|
|
21537
21586
|
});
|
|
21538
21587
|
});
|
|
21539
21588
|
}
|
|
@@ -21775,23 +21824,23 @@ async function awaitTunnelRegistered(candidate, hostname4, deadlineMs) {
|
|
|
21775
21824
|
ac.signal.addEventListener("abort", detach, { once: true });
|
|
21776
21825
|
};
|
|
21777
21826
|
try {
|
|
21778
|
-
return await new Promise((
|
|
21827
|
+
return await new Promise((resolve9) => {
|
|
21779
21828
|
const onChunk = (chunk) => {
|
|
21780
21829
|
const s = chunk.toString();
|
|
21781
21830
|
if (!url2) url2 = parseCloudflaredUrl(s);
|
|
21782
21831
|
if (TUNNEL_REGISTERED_RE.test(s)) registered = true;
|
|
21783
21832
|
const trimmed = s.replace(/\n+$/g, "");
|
|
21784
21833
|
if (trimmed.length > 0) log.info("preview", `cloudflared: ${trimmed}`);
|
|
21785
|
-
if (url2 && registered)
|
|
21834
|
+
if (url2 && registered) resolve9({ kind: "registered", url: url2 });
|
|
21786
21835
|
};
|
|
21787
21836
|
const onExit = (code) => {
|
|
21788
|
-
|
|
21837
|
+
resolve9({ kind: "exited", sawUrl: url2 != null, code });
|
|
21789
21838
|
};
|
|
21790
21839
|
const { stdout, stderr } = candidate;
|
|
21791
21840
|
if (stdout) scoped(() => stdout.on("data", onChunk), () => stdout.off("data", onChunk));
|
|
21792
21841
|
if (stderr) scoped(() => stderr.on("data", onChunk), () => stderr.off("data", onChunk));
|
|
21793
21842
|
scoped(() => candidate.on("exit", onExit), () => candidate.off("exit", onExit));
|
|
21794
|
-
timer = setTimeout(() =>
|
|
21843
|
+
timer = setTimeout(() => resolve9({ kind: "timeout", sawUrl: url2 != null }), deadlineMs);
|
|
21795
21844
|
});
|
|
21796
21845
|
} finally {
|
|
21797
21846
|
ac.abort();
|
|
@@ -22328,12 +22377,12 @@ var _spawnSeam = {
|
|
|
22328
22377
|
run: _defaultSpawn
|
|
22329
22378
|
};
|
|
22330
22379
|
function _defaultSpawn(binaryPath, args2, opts) {
|
|
22331
|
-
return new Promise((
|
|
22380
|
+
return new Promise((resolve9) => {
|
|
22332
22381
|
let proc;
|
|
22333
22382
|
try {
|
|
22334
22383
|
proc = (0, import_child_process19.spawn)(binaryPath, args2, { cwd: opts.cwd, env: opts.env });
|
|
22335
22384
|
} catch (err) {
|
|
22336
|
-
|
|
22385
|
+
resolve9({ code: -1, stdout: "", stderr: err.message });
|
|
22337
22386
|
return;
|
|
22338
22387
|
}
|
|
22339
22388
|
let stdout = "";
|
|
@@ -22344,8 +22393,8 @@ function _defaultSpawn(binaryPath, args2, opts) {
|
|
|
22344
22393
|
proc.stderr?.on("data", (c2) => {
|
|
22345
22394
|
stderr += c2.toString();
|
|
22346
22395
|
});
|
|
22347
|
-
proc.on("error", (err) =>
|
|
22348
|
-
proc.on("close", (code) =>
|
|
22396
|
+
proc.on("error", (err) => resolve9({ code: -1, stdout, stderr: err.message }));
|
|
22397
|
+
proc.on("close", (code) => resolve9({ code: code ?? -1, stdout, stderr }));
|
|
22349
22398
|
});
|
|
22350
22399
|
}
|
|
22351
22400
|
var _adapterSeam = {
|
|
@@ -22522,22 +22571,22 @@ var _installSpawnSeam = {
|
|
|
22522
22571
|
run: _defaultInstallSpawn
|
|
22523
22572
|
};
|
|
22524
22573
|
function _defaultInstallSpawn(strategy) {
|
|
22525
|
-
return new Promise((
|
|
22574
|
+
return new Promise((resolve9) => {
|
|
22526
22575
|
let proc;
|
|
22527
22576
|
try {
|
|
22528
22577
|
proc = (0, import_child_process20.spawn)(strategy.command, strategy.args, { env: process.env });
|
|
22529
22578
|
} catch (err) {
|
|
22530
|
-
|
|
22579
|
+
resolve9({ ok: false, code: -1, stderr: err.message });
|
|
22531
22580
|
return;
|
|
22532
22581
|
}
|
|
22533
22582
|
let stderr = "";
|
|
22534
22583
|
proc.stderr?.on("data", (c2) => {
|
|
22535
22584
|
stderr += c2.toString();
|
|
22536
22585
|
});
|
|
22537
|
-
proc.on("error", (err) =>
|
|
22586
|
+
proc.on("error", (err) => resolve9({ ok: false, code: -1, stderr: err.message }));
|
|
22538
22587
|
proc.on(
|
|
22539
22588
|
"close",
|
|
22540
|
-
(code) =>
|
|
22589
|
+
(code) => resolve9({ ok: code === 0, code: code ?? -1, stderr })
|
|
22541
22590
|
);
|
|
22542
22591
|
});
|
|
22543
22592
|
}
|
|
@@ -22598,11 +22647,11 @@ function resolveDoltInstallStrategy(platform3) {
|
|
|
22598
22647
|
}
|
|
22599
22648
|
var DOLT_RELEASE_BASE = "https://github.com/dolthub/dolt/releases/latest/download";
|
|
22600
22649
|
function doltPlatformTuple(platform3, arch2) {
|
|
22601
|
-
const
|
|
22650
|
+
const os60 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
|
|
22602
22651
|
const a = arch2 === "x64" ? "amd64" : arch2 === "arm64" ? "arm64" : null;
|
|
22603
22652
|
if (!a) return null;
|
|
22604
|
-
if (
|
|
22605
|
-
return `${
|
|
22653
|
+
if (os60 === "windows" && a !== "amd64") return null;
|
|
22654
|
+
return `${os60}-${a}`;
|
|
22606
22655
|
}
|
|
22607
22656
|
function resolveDoltTarballStrategy(targetDir, platform3, arch2) {
|
|
22608
22657
|
const tuple = doltPlatformTuple(platform3, arch2);
|
|
@@ -22706,14 +22755,14 @@ var _doltInstallSpawnSeam = {
|
|
|
22706
22755
|
};
|
|
22707
22756
|
var DOLT_INSTALL_TIMEOUT_MS = 12e4;
|
|
22708
22757
|
function _defaultDoltInstallSpawn(strategy) {
|
|
22709
|
-
return new Promise((
|
|
22758
|
+
return new Promise((resolve9) => {
|
|
22710
22759
|
let settled = false;
|
|
22711
22760
|
let timer;
|
|
22712
22761
|
const finish = (r) => {
|
|
22713
22762
|
if (settled) return;
|
|
22714
22763
|
settled = true;
|
|
22715
22764
|
if (timer) clearTimeout(timer);
|
|
22716
|
-
|
|
22765
|
+
resolve9(r);
|
|
22717
22766
|
};
|
|
22718
22767
|
let proc;
|
|
22719
22768
|
try {
|
|
@@ -24329,7 +24378,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
24329
24378
|
});
|
|
24330
24379
|
const token = ctx.pluginAuthToken;
|
|
24331
24380
|
void (async () => {
|
|
24332
|
-
const
|
|
24381
|
+
const os60 = createOsStrategy();
|
|
24333
24382
|
try {
|
|
24334
24383
|
const report = await reviewPullRequest(
|
|
24335
24384
|
{
|
|
@@ -24338,7 +24387,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
24338
24387
|
baseBranch: parsed.baseBranch
|
|
24339
24388
|
},
|
|
24340
24389
|
{
|
|
24341
|
-
runReview: (input) => new CoderabbitRuntimeStrategy(
|
|
24390
|
+
runReview: (input) => new CoderabbitRuntimeStrategy(os60).runOneShot(input),
|
|
24342
24391
|
runGh: (args2) => defaultRunGh(args2),
|
|
24343
24392
|
postReport: async (r) => {
|
|
24344
24393
|
if (!token) return;
|
|
@@ -24535,7 +24584,7 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
|
24535
24584
|
if (!nodeModulesDir) return 0;
|
|
24536
24585
|
const readdirSync12 = deps?.readdirSync ?? fs57.readdirSync;
|
|
24537
24586
|
const statSync15 = deps?.statSync ?? fs57.statSync;
|
|
24538
|
-
const
|
|
24587
|
+
const rmSync8 = deps?.rmSync ?? fs57.rmSync;
|
|
24539
24588
|
let removed = 0;
|
|
24540
24589
|
let entries;
|
|
24541
24590
|
try {
|
|
@@ -24549,7 +24598,7 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
|
24549
24598
|
try {
|
|
24550
24599
|
const st3 = statSync15(full);
|
|
24551
24600
|
if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
|
|
24552
|
-
|
|
24601
|
+
rmSync8(full, { recursive: true, force: true });
|
|
24553
24602
|
removed++;
|
|
24554
24603
|
} catch {
|
|
24555
24604
|
}
|
|
@@ -24570,16 +24619,16 @@ async function runNpmInstallLatest() {
|
|
|
24570
24619
|
const invocation = buildNpmInstallInvocation({ sudo: useSudo });
|
|
24571
24620
|
const useShell = process.platform === "win32";
|
|
24572
24621
|
const command2 = useShell && invocation.command.includes(" ") ? `"${invocation.command}"` : invocation.command;
|
|
24573
|
-
const result = await new Promise((
|
|
24622
|
+
const result = await new Promise((resolve9) => {
|
|
24574
24623
|
(0, import_child_process24.execFile)(
|
|
24575
24624
|
command2,
|
|
24576
24625
|
invocation.args,
|
|
24577
24626
|
{ timeout: CLI_UPDATE_INSTALL_TIMEOUT_MS, shell: useShell },
|
|
24578
24627
|
(err, _stdout, stderr) => {
|
|
24579
24628
|
if (!err) {
|
|
24580
|
-
|
|
24629
|
+
resolve9({ ok: true });
|
|
24581
24630
|
} else {
|
|
24582
|
-
|
|
24631
|
+
resolve9({ ok: false, error: (stderr || err.message).slice(0, 300) });
|
|
24583
24632
|
}
|
|
24584
24633
|
}
|
|
24585
24634
|
);
|
|
@@ -25174,7 +25223,7 @@ function buildKeepAlive(ctx) {
|
|
|
25174
25223
|
let timer = null;
|
|
25175
25224
|
async function setIdleTimeout(minutes) {
|
|
25176
25225
|
if (!ctx.inCodespace || !ctx.codespaceName) return;
|
|
25177
|
-
await new Promise((
|
|
25226
|
+
await new Promise((resolve9) => {
|
|
25178
25227
|
const proc = (0, import_child_process25.spawn)(
|
|
25179
25228
|
"gh",
|
|
25180
25229
|
[
|
|
@@ -25188,8 +25237,8 @@ function buildKeepAlive(ctx) {
|
|
|
25188
25237
|
{ stdio: "ignore", detached: true }
|
|
25189
25238
|
);
|
|
25190
25239
|
proc.unref();
|
|
25191
|
-
proc.on("exit", () =>
|
|
25192
|
-
proc.on("error", () =>
|
|
25240
|
+
proc.on("exit", () => resolve9());
|
|
25241
|
+
proc.on("error", () => resolve9());
|
|
25193
25242
|
});
|
|
25194
25243
|
}
|
|
25195
25244
|
return {
|
|
@@ -25407,11 +25456,11 @@ function resolveTokenValue(args2) {
|
|
|
25407
25456
|
}
|
|
25408
25457
|
const fileFlag = args2.find((a) => a.startsWith("--token-file="));
|
|
25409
25458
|
if (fileFlag) {
|
|
25410
|
-
const
|
|
25459
|
+
const path80 = fileFlag.slice("--token-file=".length);
|
|
25411
25460
|
try {
|
|
25412
|
-
const content = fs58.readFileSync(
|
|
25413
|
-
if (content.length === 0) fail(`--token-file ${
|
|
25414
|
-
rmIfExistsQuiet(
|
|
25461
|
+
const content = fs58.readFileSync(path80, "utf8").trim();
|
|
25462
|
+
if (content.length === 0) fail(`--token-file ${path80} is empty`);
|
|
25463
|
+
rmIfExistsQuiet(path80);
|
|
25415
25464
|
return content;
|
|
25416
25465
|
} catch (err) {
|
|
25417
25466
|
fail(`Could not read --token-file: ${err.message}`);
|
|
@@ -25668,10 +25717,10 @@ function wrapWithHeadroom(launch, opts) {
|
|
|
25668
25717
|
var _present;
|
|
25669
25718
|
function headroomPresent() {
|
|
25670
25719
|
if (_present !== void 0) return Promise.resolve(_present);
|
|
25671
|
-
return new Promise((
|
|
25720
|
+
return new Promise((resolve9) => {
|
|
25672
25721
|
(0, import_node_child_process26.execFile)("headroom", ["--version"], (err) => {
|
|
25673
25722
|
_present = !err;
|
|
25674
|
-
|
|
25723
|
+
resolve9(_present);
|
|
25675
25724
|
});
|
|
25676
25725
|
});
|
|
25677
25726
|
}
|
|
@@ -26061,7 +26110,7 @@ function resolveClaudeNativeBinary(deps = {}) {
|
|
|
26061
26110
|
const candidate = import_path8.default.join(scopeDir, `claude-agent-sdk-${platformKey}`, binName);
|
|
26062
26111
|
return existsSync27(candidate) ? candidate : null;
|
|
26063
26112
|
}
|
|
26064
|
-
var realSleep = (ms) => new Promise((
|
|
26113
|
+
var realSleep = (ms) => new Promise((resolve9) => setTimeout(resolve9, ms));
|
|
26065
26114
|
async function waitForClaudeNativeBinary(opts = {}) {
|
|
26066
26115
|
const timeoutMs = opts.timeoutMs ?? 18e4;
|
|
26067
26116
|
const pollMs = opts.pollMs ?? 500;
|
|
@@ -26142,7 +26191,7 @@ var PERMANENT_ADAPTER_STARTUP_RE = /IneligibleTierError|UNSUPPORTED_CLIENT|no lo
|
|
|
26142
26191
|
function probeAdapterModuleGraph(command2, args2, opts = {}) {
|
|
26143
26192
|
const livenessMs = opts.livenessMs ?? 400;
|
|
26144
26193
|
const spawnFn = opts.spawnFn ?? import_child_process26.spawn;
|
|
26145
|
-
return new Promise((
|
|
26194
|
+
return new Promise((resolve9) => {
|
|
26146
26195
|
let settled = false;
|
|
26147
26196
|
let stderr = "";
|
|
26148
26197
|
let timer;
|
|
@@ -26155,12 +26204,12 @@ function probeAdapterModuleGraph(command2, args2, opts = {}) {
|
|
|
26155
26204
|
child?.kill("SIGKILL");
|
|
26156
26205
|
} catch {
|
|
26157
26206
|
}
|
|
26158
|
-
|
|
26207
|
+
resolve9(r);
|
|
26159
26208
|
};
|
|
26160
26209
|
try {
|
|
26161
26210
|
child = spawnFn(command2, [...args2], { stdio: ["pipe", "ignore", "pipe"] });
|
|
26162
26211
|
} catch {
|
|
26163
|
-
|
|
26212
|
+
resolve9("ok");
|
|
26164
26213
|
return;
|
|
26165
26214
|
}
|
|
26166
26215
|
child.stderr?.on("data", (d3) => {
|
|
@@ -26211,10 +26260,10 @@ function augmentPath2() {
|
|
|
26211
26260
|
if (!parts.includes(dir)) process.env.PATH = `${dir}:${process.env.PATH ?? ""}`;
|
|
26212
26261
|
}
|
|
26213
26262
|
async function runInstaller2() {
|
|
26214
|
-
return new Promise((
|
|
26263
|
+
return new Promise((resolve9) => {
|
|
26215
26264
|
const proc = (0, import_node_child_process27.spawn)("sh", ["-c", `curl -fsSL ${INSTALL_URL2} | bash`], { stdio: "inherit" });
|
|
26216
|
-
proc.on("close", (code) =>
|
|
26217
|
-
proc.on("error", () =>
|
|
26265
|
+
proc.on("close", (code) => resolve9(code === 0));
|
|
26266
|
+
proc.on("error", () => resolve9(false));
|
|
26218
26267
|
});
|
|
26219
26268
|
}
|
|
26220
26269
|
async function ensureKimiInstalled() {
|
|
@@ -26263,10 +26312,10 @@ function augmentPath3() {
|
|
|
26263
26312
|
if (!parts.includes(dir)) process.env.PATH = `${dir}:${process.env.PATH ?? ""}`;
|
|
26264
26313
|
}
|
|
26265
26314
|
async function runInstaller3() {
|
|
26266
|
-
return new Promise((
|
|
26315
|
+
return new Promise((resolve9) => {
|
|
26267
26316
|
const proc = (0, import_node_child_process28.spawn)("sh", ["-c", `curl -fsSL ${INSTALL_URL3} | bash`], { stdio: "inherit" });
|
|
26268
|
-
proc.on("close", (code) =>
|
|
26269
|
-
proc.on("error", () =>
|
|
26317
|
+
proc.on("close", (code) => resolve9(code === 0));
|
|
26318
|
+
proc.on("error", () => resolve9(false));
|
|
26270
26319
|
});
|
|
26271
26320
|
}
|
|
26272
26321
|
async function ensureOpencodeInstalled() {
|
|
@@ -26441,11 +26490,11 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
|
|
|
26441
26490
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_ADAPTER_RETRY_TIMEOUT_MS;
|
|
26442
26491
|
const pollMs = opts.pollMs ?? DEFAULT_ADAPTER_RETRY_POLL_MS;
|
|
26443
26492
|
const now = opts.now ?? Date.now;
|
|
26444
|
-
const sleep5 = opts.sleep ?? ((ms) => new Promise((
|
|
26445
|
-
const
|
|
26493
|
+
const sleep5 = opts.sleep ?? ((ms) => new Promise((resolve10) => setTimeout(resolve10, ms)));
|
|
26494
|
+
const resolve9 = opts.resolve ?? getAcpAdapter;
|
|
26446
26495
|
const attempt = () => {
|
|
26447
26496
|
try {
|
|
26448
|
-
return
|
|
26497
|
+
return resolve9(agent);
|
|
26449
26498
|
} catch {
|
|
26450
26499
|
return null;
|
|
26451
26500
|
}
|
|
@@ -26531,7 +26580,7 @@ function parseJsonl(filePath) {
|
|
|
26531
26580
|
return messages;
|
|
26532
26581
|
}
|
|
26533
26582
|
function post(endpoint, body, pluginAuthToken) {
|
|
26534
|
-
return new Promise((
|
|
26583
|
+
return new Promise((resolve9) => {
|
|
26535
26584
|
const payload = JSON.stringify(body);
|
|
26536
26585
|
const u2 = new URL(`${API_BASE8}${endpoint}`);
|
|
26537
26586
|
const transport = u2.protocol === "https:" ? https7 : http6;
|
|
@@ -26556,17 +26605,17 @@ function post(endpoint, body, pluginAuthToken) {
|
|
|
26556
26605
|
res.resume();
|
|
26557
26606
|
const ok = res.statusCode !== void 0 && res.statusCode >= 200 && res.statusCode < 300;
|
|
26558
26607
|
if (!ok) log.warn("history:post", `${endpoint} \u2192 HTTP ${res.statusCode}`);
|
|
26559
|
-
|
|
26608
|
+
resolve9(ok);
|
|
26560
26609
|
}
|
|
26561
26610
|
);
|
|
26562
26611
|
req.on("error", (err) => {
|
|
26563
26612
|
log.warn("history:post", `${endpoint} network error`, err);
|
|
26564
|
-
|
|
26613
|
+
resolve9(false);
|
|
26565
26614
|
});
|
|
26566
26615
|
req.on("timeout", () => {
|
|
26567
26616
|
log.warn("history:post", `${endpoint} timeout after 15s`);
|
|
26568
26617
|
req.destroy();
|
|
26569
|
-
|
|
26618
|
+
resolve9(false);
|
|
26570
26619
|
});
|
|
26571
26620
|
req.write(payload);
|
|
26572
26621
|
req.end();
|
|
@@ -27063,8 +27112,8 @@ var HistoryService = class _HistoryService {
|
|
|
27063
27112
|
var import_node_child_process29 = require("child_process");
|
|
27064
27113
|
var fs61 = __toESM(require("fs/promises"));
|
|
27065
27114
|
var fsSync = __toESM(require("fs"));
|
|
27066
|
-
var
|
|
27067
|
-
var
|
|
27115
|
+
var os53 = __toESM(require("os"));
|
|
27116
|
+
var path67 = __toESM(require("path"));
|
|
27068
27117
|
var import_node_stream = require("stream");
|
|
27069
27118
|
|
|
27070
27119
|
// ../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
@@ -29103,12 +29152,12 @@ var Connection = class {
|
|
|
29103
29152
|
const id = this.nextRequestId++;
|
|
29104
29153
|
let cancel = () => {
|
|
29105
29154
|
};
|
|
29106
|
-
const responsePromise = new Promise((
|
|
29155
|
+
const responsePromise = new Promise((resolve9, reject) => {
|
|
29107
29156
|
const pendingResponse = {
|
|
29108
29157
|
resolve: (response) => {
|
|
29109
29158
|
try {
|
|
29110
29159
|
const value = mapResponse ? mapResponse(response) : response;
|
|
29111
|
-
|
|
29160
|
+
resolve9(value);
|
|
29112
29161
|
} catch (error) {
|
|
29113
29162
|
reject(error);
|
|
29114
29163
|
}
|
|
@@ -29186,8 +29235,8 @@ var Connection = class {
|
|
|
29186
29235
|
initialize(stream, handlers2) {
|
|
29187
29236
|
this.stream = stream;
|
|
29188
29237
|
this.staticHandlers = handlers2;
|
|
29189
|
-
this.closedPromise = new Promise((
|
|
29190
|
-
this.abortController.signal.addEventListener("abort", () =>
|
|
29238
|
+
this.closedPromise = new Promise((resolve9) => {
|
|
29239
|
+
this.abortController.signal.addEventListener("abort", () => resolve9());
|
|
29191
29240
|
});
|
|
29192
29241
|
void this.receive();
|
|
29193
29242
|
}
|
|
@@ -29975,8 +30024,8 @@ var AsyncQueue = class {
|
|
|
29975
30024
|
if (this.failed) {
|
|
29976
30025
|
return Promise.reject(this.failure);
|
|
29977
30026
|
}
|
|
29978
|
-
return new Promise((
|
|
29979
|
-
this.waiters.push({ resolve:
|
|
30027
|
+
return new Promise((resolve9, reject) => {
|
|
30028
|
+
this.waiters.push({ resolve: resolve9, reject });
|
|
29980
30029
|
});
|
|
29981
30030
|
}
|
|
29982
30031
|
};
|
|
@@ -31089,6 +31138,40 @@ function createIdleTimeout(idleMs, makeError, activeIdleMs = idleMs) {
|
|
|
31089
31138
|
};
|
|
31090
31139
|
}
|
|
31091
31140
|
|
|
31141
|
+
// src/agents/acp/internal-paths.ts
|
|
31142
|
+
var path66 = __toESM(require("path"));
|
|
31143
|
+
var os52 = __toESM(require("os"));
|
|
31144
|
+
var INTERNAL_TOKENS = [".codeam", "house-claude"];
|
|
31145
|
+
function textReferencesInternal(text) {
|
|
31146
|
+
if (!text) return false;
|
|
31147
|
+
return INTERNAL_TOKENS.some((t2) => text.includes(t2));
|
|
31148
|
+
}
|
|
31149
|
+
function pathIsInternal(p2, homeDir2 = os52.homedir()) {
|
|
31150
|
+
if (!p2) return false;
|
|
31151
|
+
const abs = path66.resolve(p2);
|
|
31152
|
+
const home = path66.resolve(homeDir2);
|
|
31153
|
+
const within = (root) => abs === root || abs.startsWith(root + path66.sep);
|
|
31154
|
+
return within(path66.join(home, ".codeam")) || within(path66.join(home, ".beads")) || abs === path66.join(home, ".codeam-host.log") || abs.includes(`${path66.sep}house-claude${path66.sep}`) || abs.endsWith(`${path66.sep}house-claude`);
|
|
31155
|
+
}
|
|
31156
|
+
function toolCallReferencesInternal(call) {
|
|
31157
|
+
if (textReferencesInternal(call.title)) return true;
|
|
31158
|
+
if (call.rawInput != null) {
|
|
31159
|
+
try {
|
|
31160
|
+
return textReferencesInternal(JSON.stringify(call.rawInput));
|
|
31161
|
+
} catch {
|
|
31162
|
+
return false;
|
|
31163
|
+
}
|
|
31164
|
+
}
|
|
31165
|
+
return false;
|
|
31166
|
+
}
|
|
31167
|
+
function internalPathPermissionOutcome(request) {
|
|
31168
|
+
if (!toolCallReferencesInternal(request.toolCall)) return null;
|
|
31169
|
+
const reject = request.options.find((o) => o.kind === "reject_always") ?? request.options.find((o) => o.kind === "reject_once");
|
|
31170
|
+
if (reject) return { outcome: { outcome: "selected", optionId: reject.optionId } };
|
|
31171
|
+
return { outcome: { outcome: "cancelled" } };
|
|
31172
|
+
}
|
|
31173
|
+
var INTERNAL_BLOCK_REASON = "This path is a CodeAgent platform internal (CodeAgent's own runtime plumbing, not part of the user's project) and is off-limits. Continue with the user's own project files.";
|
|
31174
|
+
|
|
31092
31175
|
// src/agents/acp/client.ts
|
|
31093
31176
|
var TRANSIENT_ADAPTER_SPAWN_RE = /ETXTBSY|ENOENT/;
|
|
31094
31177
|
var MAX_START_ATTEMPTS = 5;
|
|
@@ -31780,14 +31863,14 @@ var AcpClient = class {
|
|
|
31780
31863
|
this.sessionId = null;
|
|
31781
31864
|
try {
|
|
31782
31865
|
child.kill("SIGTERM");
|
|
31783
|
-
const grace = new Promise((
|
|
31866
|
+
const grace = new Promise((resolve9) => {
|
|
31784
31867
|
const t2 = setTimeout(() => {
|
|
31785
31868
|
killQuiet(child, "SIGKILL");
|
|
31786
|
-
|
|
31869
|
+
resolve9();
|
|
31787
31870
|
}, 2e3);
|
|
31788
31871
|
child.once("exit", () => {
|
|
31789
31872
|
clearTimeout(t2);
|
|
31790
|
-
|
|
31873
|
+
resolve9();
|
|
31791
31874
|
});
|
|
31792
31875
|
});
|
|
31793
31876
|
await grace;
|
|
@@ -31848,6 +31931,9 @@ var AcpClient = class {
|
|
|
31848
31931
|
}
|
|
31849
31932
|
},
|
|
31850
31933
|
readTextFile: async (params) => {
|
|
31934
|
+
if (!isLocalSession() && pathIsInternal(params.path)) {
|
|
31935
|
+
throw new RequestError(-32002, INTERNAL_BLOCK_REASON, { uri: params.path });
|
|
31936
|
+
}
|
|
31851
31937
|
try {
|
|
31852
31938
|
const content = await fs61.readFile(params.path, "utf8");
|
|
31853
31939
|
return applyLineRange(content, params.line ?? null, params.limit ?? null);
|
|
@@ -31868,6 +31954,9 @@ var AcpClient = class {
|
|
|
31868
31954
|
}
|
|
31869
31955
|
},
|
|
31870
31956
|
writeTextFile: async (params) => {
|
|
31957
|
+
if (!isLocalSession() && pathIsInternal(params.path)) {
|
|
31958
|
+
throw new RequestError(-32002, INTERNAL_BLOCK_REASON, { uri: params.path });
|
|
31959
|
+
}
|
|
31871
31960
|
try {
|
|
31872
31961
|
await fs61.writeFile(params.path, params.content, "utf8");
|
|
31873
31962
|
return {};
|
|
@@ -31929,29 +32018,29 @@ function applyLineRange(content, line, limit) {
|
|
|
31929
32018
|
return { content: lines.slice(start2, end).join("\n") };
|
|
31930
32019
|
}
|
|
31931
32020
|
function knownAgentBinaryDirs() {
|
|
31932
|
-
const home =
|
|
32021
|
+
const home = os53.homedir();
|
|
31933
32022
|
const out2 = [];
|
|
31934
32023
|
out2.push("/tmp/codeam-node20/bin");
|
|
31935
32024
|
for (const root of [
|
|
31936
32025
|
"/usr/local/share/nvm/versions/node",
|
|
31937
|
-
|
|
32026
|
+
path67.join(home, ".nvm/versions/node")
|
|
31938
32027
|
]) {
|
|
31939
32028
|
try {
|
|
31940
32029
|
for (const child of fsSync.readdirSync(root)) {
|
|
31941
|
-
out2.push(
|
|
32030
|
+
out2.push(path67.join(root, child, "bin"));
|
|
31942
32031
|
}
|
|
31943
32032
|
} catch {
|
|
31944
32033
|
}
|
|
31945
32034
|
}
|
|
31946
|
-
out2.push(
|
|
32035
|
+
out2.push(path67.join(home, ".volta/bin"));
|
|
31947
32036
|
out2.push("/usr/local/bin");
|
|
31948
32037
|
out2.push("/usr/bin");
|
|
31949
|
-
out2.push(
|
|
31950
|
-
out2.push(
|
|
32038
|
+
out2.push(path67.join(home, ".local/bin"));
|
|
32039
|
+
out2.push(path67.join(home, "bin"));
|
|
31951
32040
|
if (process.platform === "win32") {
|
|
31952
32041
|
const { LOCALAPPDATA, APPDATA } = process.env;
|
|
31953
|
-
if (LOCALAPPDATA) out2.push(
|
|
31954
|
-
if (APPDATA) out2.push(
|
|
32042
|
+
if (LOCALAPPDATA) out2.push(path67.join(LOCALAPPDATA, "cursor-agent"));
|
|
32043
|
+
if (APPDATA) out2.push(path67.join(APPDATA, "npm"));
|
|
31955
32044
|
}
|
|
31956
32045
|
return out2.filter((p2) => {
|
|
31957
32046
|
try {
|
|
@@ -31963,7 +32052,7 @@ function knownAgentBinaryDirs() {
|
|
|
31963
32052
|
}
|
|
31964
32053
|
function expandPathForAgentBinaries(existingPath) {
|
|
31965
32054
|
const existing = new Set(
|
|
31966
|
-
existingPath.split(
|
|
32055
|
+
existingPath.split(path67.delimiter).filter((p2) => p2.length > 0)
|
|
31967
32056
|
);
|
|
31968
32057
|
const additions = [];
|
|
31969
32058
|
for (const dir of knownAgentBinaryDirs()) {
|
|
@@ -31973,7 +32062,7 @@ function expandPathForAgentBinaries(existingPath) {
|
|
|
31973
32062
|
}
|
|
31974
32063
|
}
|
|
31975
32064
|
if (additions.length === 0) return existingPath;
|
|
31976
|
-
return [...additions, existingPath].filter((p2) => p2.length > 0).join(
|
|
32065
|
+
return [...additions, existingPath].filter((p2) => p2.length > 0).join(path67.delimiter);
|
|
31977
32066
|
}
|
|
31978
32067
|
|
|
31979
32068
|
// src/agents/acp/headroom-budget-proxy.ts
|
|
@@ -32016,7 +32105,7 @@ var _transport4 = {
|
|
|
32016
32105
|
get: _get
|
|
32017
32106
|
};
|
|
32018
32107
|
function _post3(url2, headers, payload) {
|
|
32019
|
-
return new Promise((
|
|
32108
|
+
return new Promise((resolve9, reject) => {
|
|
32020
32109
|
let settled = false;
|
|
32021
32110
|
const u2 = new URL(url2);
|
|
32022
32111
|
const lib = u2.protocol === "https:" ? https8 : http7;
|
|
@@ -32041,7 +32130,7 @@ function _post3(url2, headers, payload) {
|
|
|
32041
32130
|
res.on("end", () => {
|
|
32042
32131
|
if (settled) return;
|
|
32043
32132
|
settled = true;
|
|
32044
|
-
|
|
32133
|
+
resolve9({ statusCode: res.statusCode ?? 0, body });
|
|
32045
32134
|
});
|
|
32046
32135
|
}
|
|
32047
32136
|
);
|
|
@@ -32058,7 +32147,7 @@ function _post3(url2, headers, payload) {
|
|
|
32058
32147
|
});
|
|
32059
32148
|
}
|
|
32060
32149
|
function _get(url2, headers) {
|
|
32061
|
-
return new Promise((
|
|
32150
|
+
return new Promise((resolve9, reject) => {
|
|
32062
32151
|
let settled = false;
|
|
32063
32152
|
const u2 = new URL(url2);
|
|
32064
32153
|
const lib = u2.protocol === "https:" ? https8 : http7;
|
|
@@ -32082,7 +32171,7 @@ function _get(url2, headers) {
|
|
|
32082
32171
|
res.on("end", () => {
|
|
32083
32172
|
if (settled) return;
|
|
32084
32173
|
settled = true;
|
|
32085
|
-
|
|
32174
|
+
resolve9({ statusCode: res.statusCode ?? 0, body });
|
|
32086
32175
|
});
|
|
32087
32176
|
}
|
|
32088
32177
|
);
|
|
@@ -32456,13 +32545,13 @@ function commonPrefixLength(a, b) {
|
|
|
32456
32545
|
// src/agents/acp/onboarding.ts
|
|
32457
32546
|
var import_child_process27 = require("child_process");
|
|
32458
32547
|
var fs62 = __toESM(require("fs"));
|
|
32459
|
-
var
|
|
32460
|
-
var
|
|
32548
|
+
var os54 = __toESM(require("os"));
|
|
32549
|
+
var path68 = __toESM(require("path"));
|
|
32461
32550
|
var _onboardingSeam = {
|
|
32462
|
-
markerPath: (sessionId) =>
|
|
32551
|
+
markerPath: (sessionId) => path68.join(os54.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
|
|
32463
32552
|
exists: (p2) => fs62.existsSync(p2),
|
|
32464
32553
|
write: (p2) => {
|
|
32465
|
-
fs62.mkdirSync(
|
|
32554
|
+
fs62.mkdirSync(path68.dirname(p2), { recursive: true });
|
|
32466
32555
|
fs62.writeFileSync(p2, "");
|
|
32467
32556
|
},
|
|
32468
32557
|
disabled: () => {
|
|
@@ -32500,7 +32589,7 @@ function resolveRepoName(cwd) {
|
|
|
32500
32589
|
if (name) return name;
|
|
32501
32590
|
}
|
|
32502
32591
|
}
|
|
32503
|
-
const base =
|
|
32592
|
+
const base = path68.basename(cwd || "");
|
|
32504
32593
|
if (base && !isUuid(base)) return base;
|
|
32505
32594
|
return "this project";
|
|
32506
32595
|
}
|
|
@@ -32753,12 +32842,12 @@ var import_crypto5 = require("crypto");
|
|
|
32753
32842
|
// src/services/turn-files/git-changeset.ts
|
|
32754
32843
|
var import_child_process28 = require("child_process");
|
|
32755
32844
|
var fs64 = __toESM(require("fs/promises"));
|
|
32756
|
-
var
|
|
32845
|
+
var path70 = __toESM(require("path"));
|
|
32757
32846
|
|
|
32758
32847
|
// src/services/turn-files/review-ignore.ts
|
|
32759
32848
|
var import_ignore2 = __toESM(require("ignore"));
|
|
32760
32849
|
var fs63 = __toESM(require("fs"));
|
|
32761
|
-
var
|
|
32850
|
+
var path69 = __toESM(require("path"));
|
|
32762
32851
|
var CURATED_REVIEW_IGNORE = [
|
|
32763
32852
|
// Google Cloud SDK (the incident) — installs a huge python tree.
|
|
32764
32853
|
"google-cloud-sdk/",
|
|
@@ -32797,7 +32886,7 @@ var CURATED_REVIEW_IGNORE = [
|
|
|
32797
32886
|
function makeReviewIgnore(repoRoot) {
|
|
32798
32887
|
const ig = (0, import_ignore2.default)().add(CURATED_REVIEW_IGNORE);
|
|
32799
32888
|
try {
|
|
32800
|
-
const custom = fs63.readFileSync(
|
|
32889
|
+
const custom = fs63.readFileSync(path69.join(repoRoot, ".codeam", "reviewignore"), "utf8");
|
|
32801
32890
|
ig.add(custom);
|
|
32802
32891
|
} catch {
|
|
32803
32892
|
}
|
|
@@ -32842,7 +32931,7 @@ async function collectRepoChangeset(opts) {
|
|
|
32842
32931
|
let stats;
|
|
32843
32932
|
if (!truncated && row.fileStatus === "added" && numstatEntry === void 0) {
|
|
32844
32933
|
const lineCount = await readUntrackedLineCount(
|
|
32845
|
-
|
|
32934
|
+
path70.join(opts.repoRoot, row.filePath)
|
|
32846
32935
|
);
|
|
32847
32936
|
stats = { added: lineCount, removed: 0 };
|
|
32848
32937
|
} else {
|
|
@@ -32934,12 +33023,12 @@ function runGit3(cwd, args2) {
|
|
|
32934
33023
|
return _runGitImpl2.run(cwd, args2);
|
|
32935
33024
|
}
|
|
32936
33025
|
function defaultRunGit(cwd, args2) {
|
|
32937
|
-
return new Promise((
|
|
33026
|
+
return new Promise((resolve9) => {
|
|
32938
33027
|
let proc;
|
|
32939
33028
|
try {
|
|
32940
33029
|
proc = (0, import_child_process28.spawn)("git", args2, { cwd, env: process.env });
|
|
32941
33030
|
} catch {
|
|
32942
|
-
|
|
33031
|
+
resolve9(null);
|
|
32943
33032
|
return;
|
|
32944
33033
|
}
|
|
32945
33034
|
let stdout = "";
|
|
@@ -32950,16 +33039,16 @@ function defaultRunGit(cwd, args2) {
|
|
|
32950
33039
|
proc.stderr?.on("data", (c2) => {
|
|
32951
33040
|
stderr += c2.toString();
|
|
32952
33041
|
});
|
|
32953
|
-
proc.on("error", () =>
|
|
33042
|
+
proc.on("error", () => resolve9(null));
|
|
32954
33043
|
proc.on("close", (code) => {
|
|
32955
33044
|
if (code === 0) {
|
|
32956
|
-
|
|
33045
|
+
resolve9(stdout);
|
|
32957
33046
|
} else {
|
|
32958
33047
|
log.trace(
|
|
32959
33048
|
"turnFiles",
|
|
32960
33049
|
`git ${args2.join(" ")} exited ${code} stderr=${stderr.slice(0, 200)}`
|
|
32961
33050
|
);
|
|
32962
|
-
|
|
33051
|
+
resolve9(null);
|
|
32963
33052
|
}
|
|
32964
33053
|
});
|
|
32965
33054
|
});
|
|
@@ -32984,8 +33073,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
32984
33073
|
if (hasGit) {
|
|
32985
33074
|
out2.push({
|
|
32986
33075
|
repoRoot: dir,
|
|
32987
|
-
repoPath:
|
|
32988
|
-
repoName:
|
|
33076
|
+
repoPath: path70.relative(workingDir, dir),
|
|
33077
|
+
repoName: path70.basename(dir)
|
|
32989
33078
|
});
|
|
32990
33079
|
return;
|
|
32991
33080
|
}
|
|
@@ -32993,14 +33082,14 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
32993
33082
|
if (!entry.isDirectory) continue;
|
|
32994
33083
|
if (entry.name === "node_modules") continue;
|
|
32995
33084
|
if (entry.name === "dist" || entry.name === "build") continue;
|
|
32996
|
-
await walk(
|
|
33085
|
+
await walk(path70.join(dir, entry.name), depth + 1);
|
|
32997
33086
|
}
|
|
32998
33087
|
}
|
|
32999
33088
|
}
|
|
33000
33089
|
|
|
33001
33090
|
// src/services/turn-files/files-outbox.ts
|
|
33002
33091
|
var fs65 = __toESM(require("fs/promises"));
|
|
33003
|
-
var
|
|
33092
|
+
var path71 = __toESM(require("path"));
|
|
33004
33093
|
var import_os12 = require("os");
|
|
33005
33094
|
var HOME_OUTBOX_DIR = ".codeam/outbox";
|
|
33006
33095
|
var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -33033,15 +33122,15 @@ var FilesOutbox = class {
|
|
|
33033
33122
|
backoffIndex = 0;
|
|
33034
33123
|
stopped = false;
|
|
33035
33124
|
constructor(opts) {
|
|
33036
|
-
const base = opts.baseDir ??
|
|
33037
|
-
this.filePath =
|
|
33125
|
+
const base = opts.baseDir ?? path71.join(homeDir(), HOME_OUTBOX_DIR);
|
|
33126
|
+
this.filePath = path71.join(base, `${opts.sessionId}.jsonl`);
|
|
33038
33127
|
this.post = opts.post;
|
|
33039
33128
|
this.autoSchedule = opts.autoSchedule !== false;
|
|
33040
33129
|
}
|
|
33041
33130
|
/** Persist the entry to disk and trigger a flush. Returns once the
|
|
33042
33131
|
* line is durable on disk (not once the POST succeeds). */
|
|
33043
33132
|
async enqueue(entry) {
|
|
33044
|
-
await fs65.mkdir(
|
|
33133
|
+
await fs65.mkdir(path71.dirname(this.filePath), { recursive: true });
|
|
33045
33134
|
await fs65.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
|
|
33046
33135
|
this.backoffIndex = 0;
|
|
33047
33136
|
if (this.autoSchedule) this.scheduleFlush(0);
|
|
@@ -33347,25 +33436,25 @@ function baselineKey(entry) {
|
|
|
33347
33436
|
|
|
33348
33437
|
// src/agents/acp/withTimeout.ts
|
|
33349
33438
|
function withTimeout(p2, ms) {
|
|
33350
|
-
return new Promise((
|
|
33439
|
+
return new Promise((resolve9) => {
|
|
33351
33440
|
let settled = false;
|
|
33352
33441
|
const timer = setTimeout(() => {
|
|
33353
33442
|
if (settled) return;
|
|
33354
33443
|
settled = true;
|
|
33355
|
-
|
|
33444
|
+
resolve9(void 0);
|
|
33356
33445
|
}, ms);
|
|
33357
33446
|
p2.then(
|
|
33358
33447
|
(v) => {
|
|
33359
33448
|
if (settled) return;
|
|
33360
33449
|
settled = true;
|
|
33361
33450
|
clearTimeout(timer);
|
|
33362
|
-
|
|
33451
|
+
resolve9(v);
|
|
33363
33452
|
},
|
|
33364
33453
|
() => {
|
|
33365
33454
|
if (settled) return;
|
|
33366
33455
|
settled = true;
|
|
33367
33456
|
clearTimeout(timer);
|
|
33368
|
-
|
|
33457
|
+
resolve9(void 0);
|
|
33369
33458
|
}
|
|
33370
33459
|
);
|
|
33371
33460
|
});
|
|
@@ -34304,7 +34393,7 @@ var StreamingState = class {
|
|
|
34304
34393
|
* default-reject. Caller is the SDK's `onRequestPermission`.
|
|
34305
34394
|
*/
|
|
34306
34395
|
registerPermission(args2) {
|
|
34307
|
-
return new Promise((
|
|
34396
|
+
return new Promise((resolve9) => {
|
|
34308
34397
|
const timeoutTimer = setTimeout(() => {
|
|
34309
34398
|
if (this.pending?.kind === "permission" && this.pending.questionId === args2.questionId) {
|
|
34310
34399
|
log.warn(
|
|
@@ -34312,7 +34401,7 @@ var StreamingState = class {
|
|
|
34312
34401
|
`permission ${args2.questionId.slice(0, 8)} TTL expired \u2014 auto-cancel`
|
|
34313
34402
|
);
|
|
34314
34403
|
this.pending = null;
|
|
34315
|
-
|
|
34404
|
+
resolve9({ outcome: { outcome: "cancelled" } });
|
|
34316
34405
|
}
|
|
34317
34406
|
}, PERMISSION_TIMEOUT_MS);
|
|
34318
34407
|
this.pending = {
|
|
@@ -34320,7 +34409,7 @@ var StreamingState = class {
|
|
|
34320
34409
|
questionId: args2.questionId,
|
|
34321
34410
|
labels: args2.labels,
|
|
34322
34411
|
optionIdByLabel: args2.optionIdByLabel,
|
|
34323
|
-
resolve:
|
|
34412
|
+
resolve: resolve9,
|
|
34324
34413
|
timeoutTimer
|
|
34325
34414
|
};
|
|
34326
34415
|
});
|
|
@@ -34352,14 +34441,14 @@ var StreamingState = class {
|
|
|
34352
34441
|
const label = this.pending.labels[index];
|
|
34353
34442
|
const optionId = label ? this.pending.optionIdByLabel[label] : void 0;
|
|
34354
34443
|
clearTimeout(this.pending.timeoutTimer);
|
|
34355
|
-
const
|
|
34444
|
+
const resolve9 = this.pending.resolve;
|
|
34356
34445
|
this.pending = null;
|
|
34357
34446
|
if (!optionId) {
|
|
34358
34447
|
log.warn("acpRunner", `select_option index=${index} out of bounds \u2014 cancel`);
|
|
34359
|
-
|
|
34448
|
+
resolve9({ outcome: { outcome: "cancelled" } });
|
|
34360
34449
|
return { kind: "resolved" };
|
|
34361
34450
|
}
|
|
34362
|
-
|
|
34451
|
+
resolve9({ outcome: { outcome: "selected", optionId } });
|
|
34363
34452
|
return { kind: "resolved" };
|
|
34364
34453
|
}
|
|
34365
34454
|
const text = this.pending.options[index];
|
|
@@ -34799,6 +34888,16 @@ async function runAcpSession(opts) {
|
|
|
34799
34888
|
beginLoadReplay: () => streaming.beginLoadReplay(),
|
|
34800
34889
|
endLoadReplay: () => streaming.endLoadReplay(),
|
|
34801
34890
|
onRequestPermission: async (request) => {
|
|
34891
|
+
if (!isLocalSession()) {
|
|
34892
|
+
const denied = internalPathPermissionOutcome(request);
|
|
34893
|
+
if (denied) {
|
|
34894
|
+
log.warn(
|
|
34895
|
+
"acpRunner",
|
|
34896
|
+
"internal-path guard \u2014 denying tool call referencing a CodeAgent platform internal"
|
|
34897
|
+
);
|
|
34898
|
+
return denied;
|
|
34899
|
+
}
|
|
34900
|
+
}
|
|
34802
34901
|
if (opts.autoApprovePermissions) {
|
|
34803
34902
|
const allow = pickAllowOption(request.options);
|
|
34804
34903
|
if (allow) {
|
|
@@ -36077,8 +36176,8 @@ function fetchQuotaUsage(runtime, historySvc) {
|
|
|
36077
36176
|
|
|
36078
36177
|
// src/beads/workflow-hint.ts
|
|
36079
36178
|
var fs66 = __toESM(require("fs"));
|
|
36080
|
-
var
|
|
36081
|
-
var
|
|
36179
|
+
var path72 = __toESM(require("path"));
|
|
36180
|
+
var os55 = __toESM(require("os"));
|
|
36082
36181
|
var BEADS_HINT_MARKER = "<!-- codeam:beads-workflow -->";
|
|
36083
36182
|
var BEADS_HINT = `${BEADS_HINT_MARKER}
|
|
36084
36183
|
# Beads (bd) \u2014 task tracking + persistent memory (ALWAYS use it)
|
|
@@ -36092,16 +36191,16 @@ This environment uses **bd (beads)** for issue/task tracking and persistent memo
|
|
|
36092
36191
|
- \`bd ready\` (available work) \xB7 \`bd show <id>\` \xB7 \`bd update <id> --claim\` \xB7 \`bd close <id>\`.
|
|
36093
36192
|
- Use \`bd remember "..."\` for persistent knowledge \u2014 do NOT use MEMORY.md files.
|
|
36094
36193
|
${BEADS_HINT_MARKER}`;
|
|
36095
|
-
function ensureBeadsWorkflowHint(homeDir2 =
|
|
36194
|
+
function ensureBeadsWorkflowHint(homeDir2 = os55.homedir()) {
|
|
36096
36195
|
try {
|
|
36097
|
-
const file =
|
|
36196
|
+
const file = path72.join(homeDir2, ".claude", "CLAUDE.md");
|
|
36098
36197
|
let existing = "";
|
|
36099
36198
|
try {
|
|
36100
36199
|
existing = fs66.readFileSync(file, "utf8");
|
|
36101
36200
|
} catch {
|
|
36102
36201
|
}
|
|
36103
36202
|
if (existing.includes(BEADS_HINT_MARKER)) return;
|
|
36104
|
-
fs66.mkdirSync(
|
|
36203
|
+
fs66.mkdirSync(path72.dirname(file), { recursive: true });
|
|
36105
36204
|
const next = existing.trim() ? `${existing.trimEnd()}
|
|
36106
36205
|
|
|
36107
36206
|
${BEADS_HINT}
|
|
@@ -36369,10 +36468,10 @@ var NativeTuiDriver = class _NativeTuiDriver {
|
|
|
36369
36468
|
this.lastOutput = this.now();
|
|
36370
36469
|
}
|
|
36371
36470
|
whenSafeToYield() {
|
|
36372
|
-
return new Promise((
|
|
36471
|
+
return new Promise((resolve9) => {
|
|
36373
36472
|
const tick = () => {
|
|
36374
36473
|
const quietFor = this.now() - this.lastOutput;
|
|
36375
|
-
if (quietFor >= this.idleMs)
|
|
36474
|
+
if (quietFor >= this.idleMs) resolve9();
|
|
36376
36475
|
else setTimeout(tick, this.idleMs - quietFor);
|
|
36377
36476
|
};
|
|
36378
36477
|
tick();
|
|
@@ -36507,11 +36606,11 @@ var AcpDriver = class {
|
|
|
36507
36606
|
this.turnActive = false;
|
|
36508
36607
|
const waiters = this.waiters;
|
|
36509
36608
|
this.waiters = [];
|
|
36510
|
-
waiters.forEach((
|
|
36609
|
+
waiters.forEach((resolve9) => resolve9());
|
|
36511
36610
|
}
|
|
36512
36611
|
whenSafeToYield() {
|
|
36513
36612
|
if (!this.turnActive) return Promise.resolve();
|
|
36514
|
-
return new Promise((
|
|
36613
|
+
return new Promise((resolve9) => this.waiters.push(resolve9));
|
|
36515
36614
|
}
|
|
36516
36615
|
};
|
|
36517
36616
|
|
|
@@ -36846,12 +36945,12 @@ function toEpochMs(ts) {
|
|
|
36846
36945
|
|
|
36847
36946
|
// src/agents/claude/onboarding.ts
|
|
36848
36947
|
var fs68 = __toESM(require("fs"));
|
|
36849
|
-
var
|
|
36850
|
-
var
|
|
36948
|
+
var os57 = __toESM(require("os"));
|
|
36949
|
+
var path73 = __toESM(require("path"));
|
|
36851
36950
|
var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
|
|
36852
36951
|
function ensureClaudeOnboarded(cwd) {
|
|
36853
36952
|
try {
|
|
36854
|
-
const file =
|
|
36953
|
+
const file = path73.join(os57.homedir(), ".claude.json");
|
|
36855
36954
|
let config = {};
|
|
36856
36955
|
try {
|
|
36857
36956
|
config = JSON.parse(fs68.readFileSync(file, "utf8"));
|
|
@@ -36879,7 +36978,7 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
36879
36978
|
}
|
|
36880
36979
|
}
|
|
36881
36980
|
if (!changed) return;
|
|
36882
|
-
fs68.mkdirSync(
|
|
36981
|
+
fs68.mkdirSync(path73.dirname(file), { recursive: true });
|
|
36883
36982
|
fs68.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
36884
36983
|
log.info(
|
|
36885
36984
|
"claude",
|
|
@@ -37006,8 +37105,8 @@ async function start(requestedAgent, presetSession) {
|
|
|
37006
37105
|
let gateTimer;
|
|
37007
37106
|
await Promise.race([
|
|
37008
37107
|
Promise.all([depsReady, agentBinaryReady]),
|
|
37009
|
-
new Promise((
|
|
37010
|
-
gateTimer = setTimeout(
|
|
37108
|
+
new Promise((resolve9) => {
|
|
37109
|
+
gateTimer = setTimeout(resolve9, GATE_TIMEOUT_MS);
|
|
37011
37110
|
})
|
|
37012
37111
|
]);
|
|
37013
37112
|
if (gateTimer) clearTimeout(gateTimer);
|
|
@@ -37362,7 +37461,7 @@ async function pair(args2 = []) {
|
|
|
37362
37461
|
waitSpin.message(waitMessage());
|
|
37363
37462
|
}, 1e3);
|
|
37364
37463
|
countdownInterval.unref?.();
|
|
37365
|
-
await new Promise((
|
|
37464
|
+
await new Promise((resolve9) => {
|
|
37366
37465
|
let stopPolling = null;
|
|
37367
37466
|
function sigintHandler() {
|
|
37368
37467
|
clearInterval(countdownInterval);
|
|
@@ -37413,7 +37512,7 @@ async function pair(args2 = []) {
|
|
|
37413
37512
|
pluginAuthToken: info.pluginAuthToken
|
|
37414
37513
|
});
|
|
37415
37514
|
}
|
|
37416
|
-
|
|
37515
|
+
resolve9();
|
|
37417
37516
|
},
|
|
37418
37517
|
() => {
|
|
37419
37518
|
clearInterval(countdownInterval);
|
|
@@ -37598,7 +37697,7 @@ var import_picocolors11 = __toESM(require("picocolors"));
|
|
|
37598
37697
|
var import_child_process29 = require("child_process");
|
|
37599
37698
|
var import_util4 = require("util");
|
|
37600
37699
|
var import_picocolors9 = __toESM(require("picocolors"));
|
|
37601
|
-
var
|
|
37700
|
+
var path74 = __toESM(require("path"));
|
|
37602
37701
|
var execFileP6 = (0, import_util4.promisify)(import_child_process29.execFile);
|
|
37603
37702
|
var MAX_BUFFER = 8 * 1024 * 1024;
|
|
37604
37703
|
function resetStdinForChild() {
|
|
@@ -37642,12 +37741,12 @@ var GitHubCodespacesProvider = class {
|
|
|
37642
37741
|
}
|
|
37643
37742
|
if (!isAuthed) {
|
|
37644
37743
|
resetStdinForChild();
|
|
37645
|
-
await new Promise((
|
|
37744
|
+
await new Promise((resolve9, reject) => {
|
|
37646
37745
|
const proc = (0, import_child_process29.spawn)("gh", ["auth", "login", "-s", "codespace,repo,read:user"], {
|
|
37647
37746
|
stdio: "inherit"
|
|
37648
37747
|
});
|
|
37649
37748
|
proc.on("exit", (code) => {
|
|
37650
|
-
if (code === 0)
|
|
37749
|
+
if (code === 0) resolve9();
|
|
37651
37750
|
else reject(new Error("gh auth login failed."));
|
|
37652
37751
|
});
|
|
37653
37752
|
proc.on("error", reject);
|
|
@@ -37676,13 +37775,13 @@ var GitHubCodespacesProvider = class {
|
|
|
37676
37775
|
}
|
|
37677
37776
|
wt(noteLines.join("\n"), "One more permission needed");
|
|
37678
37777
|
resetStdinForChild();
|
|
37679
|
-
const refreshCode = await new Promise((
|
|
37778
|
+
const refreshCode = await new Promise((resolve9, reject) => {
|
|
37680
37779
|
const proc = (0, import_child_process29.spawn)(
|
|
37681
37780
|
"gh",
|
|
37682
37781
|
["auth", "refresh", "-h", "github.com", "-s", "codespace"],
|
|
37683
37782
|
{ stdio: "inherit" }
|
|
37684
37783
|
);
|
|
37685
|
-
proc.on("exit", (code) =>
|
|
37784
|
+
proc.on("exit", (code) => resolve9(code ?? 1));
|
|
37686
37785
|
proc.on("error", reject);
|
|
37687
37786
|
});
|
|
37688
37787
|
if (refreshCode !== 0) {
|
|
@@ -37826,10 +37925,10 @@ var GitHubCodespacesProvider = class {
|
|
|
37826
37925
|
if (q(proceed) || !proceed) return;
|
|
37827
37926
|
O2.step(`Installing gh via ${installCmd.describe}\u2026`);
|
|
37828
37927
|
resetStdinForChild();
|
|
37829
|
-
const ok = await new Promise((
|
|
37928
|
+
const ok = await new Promise((resolve9) => {
|
|
37830
37929
|
const proc = (0, import_child_process29.spawn)(installCmd.exe, installCmd.args, { stdio: "inherit" });
|
|
37831
|
-
proc.on("exit", (code) =>
|
|
37832
|
-
proc.on("error", () =>
|
|
37930
|
+
proc.on("exit", (code) => resolve9(code === 0));
|
|
37931
|
+
proc.on("error", () => resolve9(false));
|
|
37833
37932
|
});
|
|
37834
37933
|
if (ok) O2.success("gh installed");
|
|
37835
37934
|
else O2.error("gh install failed");
|
|
@@ -37853,14 +37952,14 @@ var GitHubCodespacesProvider = class {
|
|
|
37853
37952
|
"Expanding GitHub scopes"
|
|
37854
37953
|
);
|
|
37855
37954
|
resetStdinForChild();
|
|
37856
|
-
await new Promise((
|
|
37955
|
+
await new Promise((resolve9, reject) => {
|
|
37857
37956
|
const proc = (0, import_child_process29.spawn)(
|
|
37858
37957
|
"gh",
|
|
37859
37958
|
["auth", "refresh", "-h", "github.com", "-s", "repo,read:org"],
|
|
37860
37959
|
{ stdio: "inherit" }
|
|
37861
37960
|
);
|
|
37862
37961
|
proc.on("exit", (code) => {
|
|
37863
|
-
if (code === 0)
|
|
37962
|
+
if (code === 0) resolve9();
|
|
37864
37963
|
else reject(new Error(
|
|
37865
37964
|
"gh auth refresh failed. Re-run `gh auth refresh -h github.com -s repo,read:org` manually."
|
|
37866
37965
|
));
|
|
@@ -38031,13 +38130,13 @@ var GitHubCodespacesProvider = class {
|
|
|
38031
38130
|
}
|
|
38032
38131
|
async streamCommand(workspaceId, command2) {
|
|
38033
38132
|
resetStdinForChild();
|
|
38034
|
-
return new Promise((
|
|
38133
|
+
return new Promise((resolve9, reject) => {
|
|
38035
38134
|
const proc = (0, import_child_process29.spawn)(
|
|
38036
38135
|
"gh",
|
|
38037
38136
|
["codespace", "ssh", "-c", workspaceId, "--", "-tt", command2],
|
|
38038
38137
|
{ stdio: "inherit" }
|
|
38039
38138
|
);
|
|
38040
|
-
proc.on("exit", (code) =>
|
|
38139
|
+
proc.on("exit", (code) => resolve9({ code: code ?? 0 }));
|
|
38041
38140
|
proc.on("error", reject);
|
|
38042
38141
|
});
|
|
38043
38142
|
}
|
|
@@ -38058,7 +38157,7 @@ var GitHubCodespacesProvider = class {
|
|
|
38058
38157
|
"--",
|
|
38059
38158
|
`mkdir -p ${shellQuote(remoteDir)} && tar -xzf - -C ${shellQuote(remoteDir)}`
|
|
38060
38159
|
];
|
|
38061
|
-
await new Promise((
|
|
38160
|
+
await new Promise((resolve9, reject) => {
|
|
38062
38161
|
const tar = (0, import_child_process29.spawn)("tar", tarArgs, {
|
|
38063
38162
|
stdio: ["ignore", "pipe", "pipe"],
|
|
38064
38163
|
env: tarEnv
|
|
@@ -38078,7 +38177,7 @@ var GitHubCodespacesProvider = class {
|
|
|
38078
38177
|
ssh.on("error", reject);
|
|
38079
38178
|
ssh.on("exit", (code) => {
|
|
38080
38179
|
if (code === 0) {
|
|
38081
|
-
|
|
38180
|
+
resolve9();
|
|
38082
38181
|
} else {
|
|
38083
38182
|
const reason = (sshErr || tarErr || `exit ${code}`).trim().slice(0, 500);
|
|
38084
38183
|
reject(new Error(`Remote tar failed: ${reason}`));
|
|
@@ -38087,7 +38186,7 @@ var GitHubCodespacesProvider = class {
|
|
|
38087
38186
|
});
|
|
38088
38187
|
}
|
|
38089
38188
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
38090
|
-
const remoteDir =
|
|
38189
|
+
const remoteDir = path74.posix.dirname(remotePath);
|
|
38091
38190
|
const parts = [
|
|
38092
38191
|
`mkdir -p ${shellQuote(remoteDir)}`,
|
|
38093
38192
|
`cat > ${shellQuote(remotePath)}`
|
|
@@ -38096,7 +38195,7 @@ var GitHubCodespacesProvider = class {
|
|
|
38096
38195
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote(remotePath)}`);
|
|
38097
38196
|
}
|
|
38098
38197
|
const cmd = parts.join(" && ");
|
|
38099
|
-
await new Promise((
|
|
38198
|
+
await new Promise((resolve9, reject) => {
|
|
38100
38199
|
const proc = (0, import_child_process29.spawn)(
|
|
38101
38200
|
"gh",
|
|
38102
38201
|
["codespace", "ssh", "-c", workspaceId, "--", cmd],
|
|
@@ -38108,7 +38207,7 @@ var GitHubCodespacesProvider = class {
|
|
|
38108
38207
|
});
|
|
38109
38208
|
proc.on("error", reject);
|
|
38110
38209
|
proc.on("exit", (code) => {
|
|
38111
|
-
if (code === 0)
|
|
38210
|
+
if (code === 0) resolve9();
|
|
38112
38211
|
else reject(new Error(`Remote write failed: ${(stderr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
38113
38212
|
});
|
|
38114
38213
|
proc.stdin?.write(contents);
|
|
@@ -38157,7 +38256,7 @@ function shellQuote(s) {
|
|
|
38157
38256
|
// src/services/providers/gitpod.ts
|
|
38158
38257
|
var import_child_process30 = require("child_process");
|
|
38159
38258
|
var import_util5 = require("util");
|
|
38160
|
-
var
|
|
38259
|
+
var path75 = __toESM(require("path"));
|
|
38161
38260
|
var import_picocolors10 = __toESM(require("picocolors"));
|
|
38162
38261
|
var execFileP7 = (0, import_util5.promisify)(import_child_process30.execFile);
|
|
38163
38262
|
var MAX_BUFFER2 = 8 * 1024 * 1024;
|
|
@@ -38198,10 +38297,10 @@ var GitpodProvider = class {
|
|
|
38198
38297
|
"Authenticating Gitpod"
|
|
38199
38298
|
);
|
|
38200
38299
|
resetStdinForChild2();
|
|
38201
|
-
await new Promise((
|
|
38300
|
+
await new Promise((resolve9, reject) => {
|
|
38202
38301
|
const proc = (0, import_child_process30.spawn)("gitpod", ["login"], { stdio: "inherit" });
|
|
38203
38302
|
proc.on("exit", (code) => {
|
|
38204
|
-
if (code === 0)
|
|
38303
|
+
if (code === 0) resolve9();
|
|
38205
38304
|
else reject(new Error("gitpod login failed."));
|
|
38206
38305
|
});
|
|
38207
38306
|
proc.on("error", reject);
|
|
@@ -38350,13 +38449,13 @@ var GitpodProvider = class {
|
|
|
38350
38449
|
}
|
|
38351
38450
|
async streamCommand(workspaceId, command2) {
|
|
38352
38451
|
resetStdinForChild2();
|
|
38353
|
-
return new Promise((
|
|
38452
|
+
return new Promise((resolve9, reject) => {
|
|
38354
38453
|
const proc = (0, import_child_process30.spawn)(
|
|
38355
38454
|
"gitpod",
|
|
38356
38455
|
["workspace", "ssh", workspaceId, "--", "-tt", command2],
|
|
38357
38456
|
{ stdio: "inherit" }
|
|
38358
38457
|
);
|
|
38359
|
-
proc.on("exit", (code) =>
|
|
38458
|
+
proc.on("exit", (code) => resolve9({ code: code ?? 0 }));
|
|
38360
38459
|
proc.on("error", reject);
|
|
38361
38460
|
});
|
|
38362
38461
|
}
|
|
@@ -38370,7 +38469,7 @@ var GitpodProvider = class {
|
|
|
38370
38469
|
tarArgs.push(".");
|
|
38371
38470
|
const tarEnv = { ...process.env, COPYFILE_DISABLE: "1" };
|
|
38372
38471
|
const remoteCmd = `mkdir -p ${shellQuote2(remoteDir)} && tar -xzf - -C ${shellQuote2(remoteDir)}`;
|
|
38373
|
-
await new Promise((
|
|
38472
|
+
await new Promise((resolve9, reject) => {
|
|
38374
38473
|
const tar = (0, import_child_process30.spawn)("tar", tarArgs, {
|
|
38375
38474
|
stdio: ["ignore", "pipe", "pipe"],
|
|
38376
38475
|
env: tarEnv
|
|
@@ -38391,13 +38490,13 @@ var GitpodProvider = class {
|
|
|
38391
38490
|
tar.on("error", reject);
|
|
38392
38491
|
ssh.on("error", reject);
|
|
38393
38492
|
ssh.on("exit", (code) => {
|
|
38394
|
-
if (code === 0)
|
|
38493
|
+
if (code === 0) resolve9();
|
|
38395
38494
|
else reject(new Error(`Remote tar failed: ${(sshErr || tarErr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
38396
38495
|
});
|
|
38397
38496
|
});
|
|
38398
38497
|
}
|
|
38399
38498
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
38400
|
-
const remoteDir =
|
|
38499
|
+
const remoteDir = path75.posix.dirname(remotePath);
|
|
38401
38500
|
const parts = [
|
|
38402
38501
|
`mkdir -p ${shellQuote2(remoteDir)}`,
|
|
38403
38502
|
`cat > ${shellQuote2(remotePath)}`
|
|
@@ -38406,7 +38505,7 @@ var GitpodProvider = class {
|
|
|
38406
38505
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote2(remotePath)}`);
|
|
38407
38506
|
}
|
|
38408
38507
|
const cmd = parts.join(" && ");
|
|
38409
|
-
await new Promise((
|
|
38508
|
+
await new Promise((resolve9, reject) => {
|
|
38410
38509
|
const proc = (0, import_child_process30.spawn)(
|
|
38411
38510
|
"gitpod",
|
|
38412
38511
|
["workspace", "ssh", workspaceId, "--", cmd],
|
|
@@ -38418,7 +38517,7 @@ var GitpodProvider = class {
|
|
|
38418
38517
|
});
|
|
38419
38518
|
proc.on("error", reject);
|
|
38420
38519
|
proc.on("exit", (code) => {
|
|
38421
|
-
if (code === 0)
|
|
38520
|
+
if (code === 0) resolve9();
|
|
38422
38521
|
else reject(new Error(`Remote write failed: ${(stderr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
38423
38522
|
});
|
|
38424
38523
|
proc.stdin?.write(contents);
|
|
@@ -38433,7 +38532,7 @@ function shellQuote2(s) {
|
|
|
38433
38532
|
// src/services/providers/gitlab-workspaces.ts
|
|
38434
38533
|
var import_child_process31 = require("child_process");
|
|
38435
38534
|
var import_util6 = require("util");
|
|
38436
|
-
var
|
|
38535
|
+
var path76 = __toESM(require("path"));
|
|
38437
38536
|
var execFileP8 = (0, import_util6.promisify)(import_child_process31.execFile);
|
|
38438
38537
|
var MAX_BUFFER3 = 8 * 1024 * 1024;
|
|
38439
38538
|
var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
|
|
@@ -38475,14 +38574,14 @@ var GitLabWorkspacesProvider = class {
|
|
|
38475
38574
|
"Authenticating GitLab"
|
|
38476
38575
|
);
|
|
38477
38576
|
resetStdinForChild3();
|
|
38478
|
-
await new Promise((
|
|
38577
|
+
await new Promise((resolve9, reject) => {
|
|
38479
38578
|
const proc = (0, import_child_process31.spawn)(
|
|
38480
38579
|
"glab",
|
|
38481
38580
|
["auth", "login", "--scopes", "api,read_user,read_repository"],
|
|
38482
38581
|
{ stdio: "inherit" }
|
|
38483
38582
|
);
|
|
38484
38583
|
proc.on("exit", (code) => {
|
|
38485
|
-
if (code === 0)
|
|
38584
|
+
if (code === 0) resolve9();
|
|
38486
38585
|
else reject(new Error("glab auth login failed."));
|
|
38487
38586
|
});
|
|
38488
38587
|
proc.on("error", reject);
|
|
@@ -38647,13 +38746,13 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
38647
38746
|
async streamCommand(workspaceId, command2) {
|
|
38648
38747
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
38649
38748
|
resetStdinForChild3();
|
|
38650
|
-
return new Promise((
|
|
38749
|
+
return new Promise((resolve9, reject) => {
|
|
38651
38750
|
const proc = (0, import_child_process31.spawn)(
|
|
38652
38751
|
"ssh",
|
|
38653
38752
|
["-tt", "-o", "StrictHostKeyChecking=accept-new", `${workspaceId}@${sshHost}`, command2],
|
|
38654
38753
|
{ stdio: "inherit" }
|
|
38655
38754
|
);
|
|
38656
|
-
proc.on("exit", (code) =>
|
|
38755
|
+
proc.on("exit", (code) => resolve9({ code: code ?? 0 }));
|
|
38657
38756
|
proc.on("error", reject);
|
|
38658
38757
|
});
|
|
38659
38758
|
}
|
|
@@ -38668,7 +38767,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
38668
38767
|
tarArgs.push(".");
|
|
38669
38768
|
const tarEnv = { ...process.env, COPYFILE_DISABLE: "1" };
|
|
38670
38769
|
const remoteCmd = `mkdir -p ${shellQuote3(remoteDir)} && tar -xzf - -C ${shellQuote3(remoteDir)}`;
|
|
38671
|
-
await new Promise((
|
|
38770
|
+
await new Promise((resolve9, reject) => {
|
|
38672
38771
|
const tar = (0, import_child_process31.spawn)("tar", tarArgs, { stdio: ["ignore", "pipe", "pipe"], env: tarEnv });
|
|
38673
38772
|
const ssh = (0, import_child_process31.spawn)(
|
|
38674
38773
|
"ssh",
|
|
@@ -38686,20 +38785,20 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
38686
38785
|
tar.on("error", reject);
|
|
38687
38786
|
ssh.on("error", reject);
|
|
38688
38787
|
ssh.on("exit", (code) => {
|
|
38689
|
-
if (code === 0)
|
|
38788
|
+
if (code === 0) resolve9();
|
|
38690
38789
|
else reject(new Error(`Remote tar failed: ${(sshErr || tarErr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
38691
38790
|
});
|
|
38692
38791
|
});
|
|
38693
38792
|
}
|
|
38694
38793
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
38695
38794
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
38696
|
-
const remoteDir =
|
|
38795
|
+
const remoteDir = path76.posix.dirname(remotePath);
|
|
38697
38796
|
const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
|
|
38698
38797
|
if (options.mode != null) {
|
|
38699
38798
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
38700
38799
|
}
|
|
38701
38800
|
const cmd = parts.join(" && ");
|
|
38702
|
-
await new Promise((
|
|
38801
|
+
await new Promise((resolve9, reject) => {
|
|
38703
38802
|
const proc = (0, import_child_process31.spawn)(
|
|
38704
38803
|
"ssh",
|
|
38705
38804
|
["-o", "StrictHostKeyChecking=accept-new", `${workspaceId}@${sshHost}`, cmd],
|
|
@@ -38711,7 +38810,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
38711
38810
|
});
|
|
38712
38811
|
proc.on("error", reject);
|
|
38713
38812
|
proc.on("exit", (code) => {
|
|
38714
|
-
if (code === 0)
|
|
38813
|
+
if (code === 0) resolve9();
|
|
38715
38814
|
else reject(new Error(`Remote write failed: ${(stderr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
38716
38815
|
});
|
|
38717
38816
|
proc.stdin?.write(contents);
|
|
@@ -38761,7 +38860,7 @@ function shellQuote3(s) {
|
|
|
38761
38860
|
// src/services/providers/railway.ts
|
|
38762
38861
|
var import_child_process32 = require("child_process");
|
|
38763
38862
|
var import_util7 = require("util");
|
|
38764
|
-
var
|
|
38863
|
+
var path77 = __toESM(require("path"));
|
|
38765
38864
|
var execFileP9 = (0, import_util7.promisify)(import_child_process32.execFile);
|
|
38766
38865
|
var MAX_BUFFER4 = 8 * 1024 * 1024;
|
|
38767
38866
|
function resetStdinForChild4() {
|
|
@@ -38802,10 +38901,10 @@ var RailwayProvider = class {
|
|
|
38802
38901
|
"Authenticating Railway"
|
|
38803
38902
|
);
|
|
38804
38903
|
resetStdinForChild4();
|
|
38805
|
-
await new Promise((
|
|
38904
|
+
await new Promise((resolve9, reject) => {
|
|
38806
38905
|
const proc = (0, import_child_process32.spawn)("railway", ["login"], { stdio: "inherit" });
|
|
38807
38906
|
proc.on("exit", (code) => {
|
|
38808
|
-
if (code === 0)
|
|
38907
|
+
if (code === 0) resolve9();
|
|
38809
38908
|
else reject(new Error("railway login failed."));
|
|
38810
38909
|
});
|
|
38811
38910
|
proc.on("error", reject);
|
|
@@ -38945,13 +39044,13 @@ var RailwayProvider = class {
|
|
|
38945
39044
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
38946
39045
|
}
|
|
38947
39046
|
resetStdinForChild4();
|
|
38948
|
-
return new Promise((
|
|
39047
|
+
return new Promise((resolve9, reject) => {
|
|
38949
39048
|
const proc = (0, import_child_process32.spawn)(
|
|
38950
39049
|
"railway",
|
|
38951
39050
|
["shell", "--project", projectId, "--service", serviceId, "--command", command2],
|
|
38952
39051
|
{ stdio: "inherit" }
|
|
38953
39052
|
);
|
|
38954
|
-
proc.on("exit", (code) =>
|
|
39053
|
+
proc.on("exit", (code) => resolve9({ code: code ?? 0 }));
|
|
38955
39054
|
proc.on("error", reject);
|
|
38956
39055
|
});
|
|
38957
39056
|
}
|
|
@@ -38969,7 +39068,7 @@ var RailwayProvider = class {
|
|
|
38969
39068
|
tarArgs.push(".");
|
|
38970
39069
|
const tarEnv = { ...process.env, COPYFILE_DISABLE: "1" };
|
|
38971
39070
|
const remoteCmd = `mkdir -p ${shellQuote4(remoteDir)} && tar -xzf - -C ${shellQuote4(remoteDir)}`;
|
|
38972
|
-
await new Promise((
|
|
39071
|
+
await new Promise((resolve9, reject) => {
|
|
38973
39072
|
const tar = (0, import_child_process32.spawn)("tar", tarArgs, { stdio: ["ignore", "pipe", "pipe"], env: tarEnv });
|
|
38974
39073
|
const sh = (0, import_child_process32.spawn)(
|
|
38975
39074
|
"railway",
|
|
@@ -38987,7 +39086,7 @@ var RailwayProvider = class {
|
|
|
38987
39086
|
tar.on("error", reject);
|
|
38988
39087
|
sh.on("error", reject);
|
|
38989
39088
|
sh.on("exit", (code) => {
|
|
38990
|
-
if (code === 0)
|
|
39089
|
+
if (code === 0) resolve9();
|
|
38991
39090
|
else reject(new Error(`Remote tar failed: ${(shErr || tarErr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
38992
39091
|
});
|
|
38993
39092
|
});
|
|
@@ -38997,13 +39096,13 @@ var RailwayProvider = class {
|
|
|
38997
39096
|
if (!projectId || !serviceId) {
|
|
38998
39097
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
38999
39098
|
}
|
|
39000
|
-
const remoteDir =
|
|
39099
|
+
const remoteDir = path77.posix.dirname(remotePath);
|
|
39001
39100
|
const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
|
|
39002
39101
|
if (options.mode != null) {
|
|
39003
39102
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
39004
39103
|
}
|
|
39005
39104
|
const cmd = parts.join(" && ");
|
|
39006
|
-
await new Promise((
|
|
39105
|
+
await new Promise((resolve9, reject) => {
|
|
39007
39106
|
const proc = (0, import_child_process32.spawn)(
|
|
39008
39107
|
"railway",
|
|
39009
39108
|
["shell", "--project", projectId, "--service", serviceId, "--command", cmd],
|
|
@@ -39015,7 +39114,7 @@ var RailwayProvider = class {
|
|
|
39015
39114
|
});
|
|
39016
39115
|
proc.on("error", reject);
|
|
39017
39116
|
proc.on("exit", (code) => {
|
|
39018
|
-
if (code === 0)
|
|
39117
|
+
if (code === 0) resolve9();
|
|
39019
39118
|
else reject(new Error(`Remote write failed: ${(stderr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
39020
39119
|
});
|
|
39021
39120
|
proc.stdin?.write(contents);
|
|
@@ -39644,7 +39743,7 @@ var import_node_dns = require("dns");
|
|
|
39644
39743
|
var import_node_util5 = require("util");
|
|
39645
39744
|
var import_node_crypto13 = require("crypto");
|
|
39646
39745
|
var fs69 = __toESM(require("fs"));
|
|
39647
|
-
var
|
|
39746
|
+
var path78 = __toESM(require("path"));
|
|
39648
39747
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
39649
39748
|
var dnsResolveP = (0, import_node_util5.promisify)(import_node_dns.resolve);
|
|
39650
39749
|
async function checkDns(apiBase2) {
|
|
@@ -39700,10 +39799,10 @@ async function checkHealth(apiBase2) {
|
|
|
39700
39799
|
}
|
|
39701
39800
|
}
|
|
39702
39801
|
function checkConfigDir() {
|
|
39703
|
-
const dir =
|
|
39802
|
+
const dir = path78.join(require("os").homedir(), ".codeam");
|
|
39704
39803
|
try {
|
|
39705
39804
|
fs69.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
39706
|
-
const probe =
|
|
39805
|
+
const probe = path78.join(dir, ".doctor-probe");
|
|
39707
39806
|
fs69.writeFileSync(probe, "ok", { mode: 384 });
|
|
39708
39807
|
const read2 = fs69.readFileSync(probe, "utf8");
|
|
39709
39808
|
fs69.unlinkSync(probe);
|
|
@@ -39746,9 +39845,9 @@ function checkSessions() {
|
|
|
39746
39845
|
}
|
|
39747
39846
|
}
|
|
39748
39847
|
function checkAgentBinaries() {
|
|
39749
|
-
const
|
|
39848
|
+
const os60 = createOsStrategy();
|
|
39750
39849
|
return getEnabledAgents().map((meta) => {
|
|
39751
|
-
const found =
|
|
39850
|
+
const found = os60.findInPath(meta.binaryName);
|
|
39752
39851
|
return {
|
|
39753
39852
|
id: `agent-${meta.id}`,
|
|
39754
39853
|
label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
|
|
@@ -39770,7 +39869,7 @@ function checkNodePty() {
|
|
|
39770
39869
|
detail: "not required on this platform"
|
|
39771
39870
|
};
|
|
39772
39871
|
}
|
|
39773
|
-
const vendoredPath =
|
|
39872
|
+
const vendoredPath = path78.join(__dirname, "vendor", "node-pty");
|
|
39774
39873
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
39775
39874
|
try {
|
|
39776
39875
|
require(target);
|
|
@@ -39812,7 +39911,7 @@ function checkChokidar() {
|
|
|
39812
39911
|
}
|
|
39813
39912
|
async function doctor(args2 = []) {
|
|
39814
39913
|
const json = args2.includes("--json");
|
|
39815
|
-
const cliVersion = true ? "2.61.
|
|
39914
|
+
const cliVersion = true ? "2.61.70" : "0.0.0-dev";
|
|
39816
39915
|
const apiBase2 = resolveApiBaseUrl();
|
|
39817
39916
|
const diagnosticId = (0, import_node_crypto13.randomUUID)();
|
|
39818
39917
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
@@ -40091,11 +40190,11 @@ var RestartableStdioProxy = class {
|
|
|
40091
40190
|
rl.on("close", () => this.child?.stdin?.end());
|
|
40092
40191
|
const timer = setInterval(() => this.checkRestart(stdout), RESTART_CHECK_INTERVAL_MS);
|
|
40093
40192
|
timer.unref();
|
|
40094
|
-
return new Promise((
|
|
40193
|
+
return new Promise((resolve9) => {
|
|
40095
40194
|
this.ended = (code) => {
|
|
40096
40195
|
clearInterval(timer);
|
|
40097
40196
|
process.exitCode = code;
|
|
40098
|
-
|
|
40197
|
+
resolve9();
|
|
40099
40198
|
};
|
|
40100
40199
|
});
|
|
40101
40200
|
}
|
|
@@ -40334,7 +40433,7 @@ async function mcpRun(args2) {
|
|
|
40334
40433
|
// src/commands/version.ts
|
|
40335
40434
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
40336
40435
|
function version2() {
|
|
40337
|
-
const v = true ? "2.61.
|
|
40436
|
+
const v = true ? "2.61.70" : "unknown";
|
|
40338
40437
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
40339
40438
|
}
|
|
40340
40439
|
|
|
@@ -40483,10 +40582,10 @@ var EXIT_CODE_NAMES = {
|
|
|
40483
40582
|
};
|
|
40484
40583
|
|
|
40485
40584
|
// src/index.ts
|
|
40486
|
-
var
|
|
40585
|
+
var os59 = __toESM(require("os"));
|
|
40487
40586
|
if (!process.env.HOME) {
|
|
40488
40587
|
try {
|
|
40489
|
-
const home =
|
|
40588
|
+
const home = os59.homedir();
|
|
40490
40589
|
if (home) process.env.HOME = home;
|
|
40491
40590
|
} catch {
|
|
40492
40591
|
}
|