codeam-cli 2.76.10 → 2.76.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.js +1034 -550
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -90,11 +90,11 @@ var require_src = __commonJS({
|
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
// src/integrations/stdio-proxy.ts
|
|
93
|
-
var
|
|
93
|
+
var import_node_child_process37, import_node_readline3, RESTART_CHECK_INTERVAL_MS, SIGKILL_ESCALATION_MS, TOOL_CALL_TIMEOUT_MS, REPLAY_INIT_ID, RestartableStdioProxy;
|
|
94
94
|
var init_stdio_proxy = __esm({
|
|
95
95
|
"src/integrations/stdio-proxy.ts"() {
|
|
96
96
|
"use strict";
|
|
97
|
-
|
|
97
|
+
import_node_child_process37 = require("child_process");
|
|
98
98
|
import_node_readline3 = __toESM(require("readline"));
|
|
99
99
|
RESTART_CHECK_INTERVAL_MS = 3e4;
|
|
100
100
|
SIGKILL_ESCALATION_MS = 2e3;
|
|
@@ -128,11 +128,11 @@ var init_stdio_proxy = __esm({
|
|
|
128
128
|
rl.on("close", () => this.child?.stdin?.end());
|
|
129
129
|
const timer = setInterval(() => this.checkRestart(stdout), RESTART_CHECK_INTERVAL_MS);
|
|
130
130
|
timer.unref();
|
|
131
|
-
return new Promise((
|
|
131
|
+
return new Promise((resolve14) => {
|
|
132
132
|
this.ended = (code) => {
|
|
133
133
|
clearInterval(timer);
|
|
134
134
|
process.exitCode = code;
|
|
135
|
-
|
|
135
|
+
resolve14();
|
|
136
136
|
};
|
|
137
137
|
});
|
|
138
138
|
}
|
|
@@ -271,7 +271,7 @@ var init_stdio_proxy = __esm({
|
|
|
271
271
|
}
|
|
272
272
|
async spawnChild(stdout, preResolved) {
|
|
273
273
|
const spec = preResolved ?? await this.opts.spawnSpec();
|
|
274
|
-
const spawn46 = this.opts.spawnImpl ??
|
|
274
|
+
const spawn46 = this.opts.spawnImpl ?? import_node_child_process37.spawn;
|
|
275
275
|
const child = spawn46(spec.command, spec.args, {
|
|
276
276
|
env: { ...process.env, ...spec.env },
|
|
277
277
|
// env only — never argv
|
|
@@ -313,18 +313,18 @@ function deploymentNameFromKey(key) {
|
|
|
313
313
|
return null;
|
|
314
314
|
}
|
|
315
315
|
function defaultSpawn(timeoutMs) {
|
|
316
|
-
return (cmd, args2, opts) => new Promise((
|
|
316
|
+
return (cmd, args2, opts) => new Promise((resolve14) => {
|
|
317
317
|
let out2 = "";
|
|
318
318
|
let err = "";
|
|
319
319
|
let done = false;
|
|
320
320
|
const finish = (code) => {
|
|
321
321
|
if (done) return;
|
|
322
322
|
done = true;
|
|
323
|
-
|
|
323
|
+
resolve14({ code, stdout: out2, stderr: err });
|
|
324
324
|
};
|
|
325
325
|
let child;
|
|
326
326
|
try {
|
|
327
|
-
child = (0,
|
|
327
|
+
child = (0, import_node_child_process38.spawn)(cmd, args2, { cwd: opts.cwd, env: opts.env, stdio: ["ignore", "pipe", "pipe"] });
|
|
328
328
|
} catch (e) {
|
|
329
329
|
finish(1);
|
|
330
330
|
err = e instanceof Error ? e.message : String(e);
|
|
@@ -357,8 +357,8 @@ function defaultSpawn(timeoutMs) {
|
|
|
357
357
|
});
|
|
358
358
|
}
|
|
359
359
|
function resolveConvexBin(cwd) {
|
|
360
|
-
const local =
|
|
361
|
-
if (
|
|
360
|
+
const local = path110.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "convex.cmd" : "convex");
|
|
361
|
+
if (fs96.existsSync(local)) return { cmd: local, args: [] };
|
|
362
362
|
return { cmd: "npx", args: ["--yes", "convex"] };
|
|
363
363
|
}
|
|
364
364
|
function redact(text, key) {
|
|
@@ -489,13 +489,13 @@ async function runConvexAdminMcp(client3, id) {
|
|
|
489
489
|
});
|
|
490
490
|
await server.connect(new StdioServerTransport());
|
|
491
491
|
}
|
|
492
|
-
var
|
|
492
|
+
var import_node_child_process38, fs96, path110, TOOLS;
|
|
493
493
|
var init_convex_admin_mcp = __esm({
|
|
494
494
|
"src/integrations/convex-admin-mcp.ts"() {
|
|
495
495
|
"use strict";
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
496
|
+
import_node_child_process38 = require("child_process");
|
|
497
|
+
fs96 = __toESM(require("fs"));
|
|
498
|
+
path110 = __toESM(require("path"));
|
|
499
499
|
TOOLS = [
|
|
500
500
|
{
|
|
501
501
|
name: "tables",
|
|
@@ -656,7 +656,7 @@ async function runHttpRelay(delivery, client3, id) {
|
|
|
656
656
|
requestInit: { headers: buildHttpHeaders(delivery.httpHeaders, token) }
|
|
657
657
|
});
|
|
658
658
|
const stdioTransport = new StdioServerTransport();
|
|
659
|
-
await new Promise((
|
|
659
|
+
await new Promise((resolve14, reject) => {
|
|
660
660
|
let done = false;
|
|
661
661
|
const watchdog = createToolCallWatchdog({
|
|
662
662
|
timeoutMs: TOOL_CALL_TIMEOUT_MS,
|
|
@@ -670,7 +670,7 @@ async function runHttpRelay(delivery, client3, id) {
|
|
|
670
670
|
void httpTransport.close().catch(() => void 0);
|
|
671
671
|
void stdioTransport.close().catch(() => void 0);
|
|
672
672
|
if (err) reject(err);
|
|
673
|
-
else
|
|
673
|
+
else resolve14();
|
|
674
674
|
};
|
|
675
675
|
stdioTransport.onmessage = (msg) => {
|
|
676
676
|
watchdog.onClientMessage(msg);
|
|
@@ -3595,11 +3595,11 @@ function quiet(fn) {
|
|
|
3595
3595
|
log.debug(TAG, "ignored sync error", err);
|
|
3596
3596
|
}
|
|
3597
3597
|
}
|
|
3598
|
-
function rmIfExistsQuiet(
|
|
3598
|
+
function rmIfExistsQuiet(path112) {
|
|
3599
3599
|
try {
|
|
3600
|
-
fs2.rmSync(
|
|
3600
|
+
fs2.rmSync(path112, { force: true });
|
|
3601
3601
|
} catch (err) {
|
|
3602
|
-
log.debug(TAG, `rmIfExists failed for ${
|
|
3602
|
+
log.debug(TAG, `rmIfExists failed for ${path112}`, err);
|
|
3603
3603
|
}
|
|
3604
3604
|
}
|
|
3605
3605
|
function killQuiet(target, signal = "SIGTERM") {
|
|
@@ -3803,8 +3803,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
|
|
|
3803
3803
|
return decodedFile;
|
|
3804
3804
|
};
|
|
3805
3805
|
}
|
|
3806
|
-
function normalizeWindowsPath(
|
|
3807
|
-
return
|
|
3806
|
+
function normalizeWindowsPath(path112) {
|
|
3807
|
+
return path112.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
3808
3808
|
}
|
|
3809
3809
|
|
|
3810
3810
|
// ../../node_modules/@posthog/core/dist/error-tracking/index.mjs
|
|
@@ -4726,11 +4726,11 @@ async function raceWithTimeout(promise, timeoutMs, onTimeout) {
|
|
|
4726
4726
|
try {
|
|
4727
4727
|
return await Promise.race([
|
|
4728
4728
|
promise,
|
|
4729
|
-
new Promise((
|
|
4729
|
+
new Promise((resolve14, reject) => {
|
|
4730
4730
|
timeoutHandle = safeSetTimeout(() => {
|
|
4731
4731
|
try {
|
|
4732
4732
|
onTimeout?.();
|
|
4733
|
-
|
|
4733
|
+
resolve14();
|
|
4734
4734
|
} catch (error) {
|
|
4735
4735
|
reject(error);
|
|
4736
4736
|
}
|
|
@@ -6537,13 +6537,13 @@ var PostHogCoreStateless = class {
|
|
|
6537
6537
|
sentFromRoute += batchMessages.length;
|
|
6538
6538
|
}
|
|
6539
6539
|
}
|
|
6540
|
-
async _sendOtlpBatch({ path:
|
|
6540
|
+
async _sendOtlpBatch({ path: path112, payload }) {
|
|
6541
6541
|
if (this.disabled) return {
|
|
6542
6542
|
kind: "fatal",
|
|
6543
6543
|
error: new Error("The client is disabled")
|
|
6544
6544
|
};
|
|
6545
6545
|
const serialized = JSON.stringify(payload);
|
|
6546
|
-
const url2 = `${this.host}/i/v1/${
|
|
6546
|
+
const url2 = `${this.host}/i/v1/${path112}?token=${encodeURIComponent(this.apiKey)}`;
|
|
6547
6547
|
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
|
|
6548
6548
|
const fetchOptions = {
|
|
6549
6549
|
method: "POST",
|
|
@@ -7783,14 +7783,14 @@ async function addSourceContext(frames, openSourceFile = import_promises.open, l
|
|
|
7783
7783
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
7784
7784
|
return frames;
|
|
7785
7785
|
}
|
|
7786
|
-
async function openRegularSourceFile(
|
|
7786
|
+
async function openRegularSourceFile(path112, openSourceFile, logger) {
|
|
7787
7787
|
let fileHandle;
|
|
7788
7788
|
let isValid = false;
|
|
7789
7789
|
try {
|
|
7790
|
-
fileHandle = await openSourceFile(
|
|
7790
|
+
fileHandle = await openSourceFile(path112, import_node_fs.constants.O_RDONLY | import_node_fs.constants.O_NONBLOCK);
|
|
7791
7791
|
const fileStat = await fileHandle.stat();
|
|
7792
7792
|
if (!fileStat.isFile()) return;
|
|
7793
|
-
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${
|
|
7793
|
+
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${path112}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
|
|
7794
7794
|
isValid = true;
|
|
7795
7795
|
return fileHandle;
|
|
7796
7796
|
} catch {
|
|
@@ -7800,17 +7800,17 @@ async function openRegularSourceFile(path109, openSourceFile, logger) {
|
|
|
7800
7800
|
});
|
|
7801
7801
|
}
|
|
7802
7802
|
}
|
|
7803
|
-
async function getContextLinesFromFile(
|
|
7804
|
-
const fileHandle = await openRegularSourceFile(
|
|
7803
|
+
async function getContextLinesFromFile(path112, ranges, output, cacheKey, openSourceFile, logger) {
|
|
7804
|
+
const fileHandle = await openRegularSourceFile(path112, openSourceFile, logger);
|
|
7805
7805
|
if (void 0 === fileHandle) return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
7806
7806
|
const openedFileHandle = fileHandle;
|
|
7807
|
-
return new Promise((
|
|
7807
|
+
return new Promise((resolve14) => {
|
|
7808
7808
|
let finished = false;
|
|
7809
7809
|
function destroyStreamAndResolve(stream2) {
|
|
7810
7810
|
if (finished) return;
|
|
7811
7811
|
finished = true;
|
|
7812
7812
|
stream2?.destroy();
|
|
7813
|
-
openedFileHandle.close().then(
|
|
7813
|
+
openedFileHandle.close().then(resolve14, resolve14);
|
|
7814
7814
|
}
|
|
7815
7815
|
let stream;
|
|
7816
7816
|
try {
|
|
@@ -7903,22 +7903,22 @@ function clearLineContext(frame) {
|
|
|
7903
7903
|
delete frame.context_line;
|
|
7904
7904
|
delete frame.post_context;
|
|
7905
7905
|
}
|
|
7906
|
-
function shouldSkipContextLinesForFile(
|
|
7907
|
-
return
|
|
7906
|
+
function shouldSkipContextLinesForFile(path112) {
|
|
7907
|
+
return path112.startsWith("node:") || path112.endsWith(".min.js") || path112.endsWith(".min.cjs") || path112.endsWith(".min.mjs") || path112.startsWith("data:");
|
|
7908
7908
|
}
|
|
7909
7909
|
function shouldSkipContextLinesForFrame(frame) {
|
|
7910
7910
|
if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
|
|
7911
7911
|
if (void 0 !== frame.colno && frame.colno > MAX_CONTEXTLINES_COLNO) return true;
|
|
7912
7912
|
return false;
|
|
7913
7913
|
}
|
|
7914
|
-
function makeSourceCacheKey(
|
|
7915
|
-
if ((0, import_node_path.isAbsolute)(
|
|
7914
|
+
function makeSourceCacheKey(path112, basePath) {
|
|
7915
|
+
if ((0, import_node_path.isAbsolute)(path112)) return JSON.stringify([
|
|
7916
7916
|
null,
|
|
7917
|
-
|
|
7917
|
+
path112
|
|
7918
7918
|
]);
|
|
7919
7919
|
return void 0 === basePath ? void 0 : JSON.stringify([
|
|
7920
7920
|
basePath,
|
|
7921
|
-
|
|
7921
|
+
path112
|
|
7922
7922
|
]);
|
|
7923
7923
|
}
|
|
7924
7924
|
function rangeExistsInContentCache(cacheKey, range) {
|
|
@@ -8999,7 +8999,7 @@ var V1CaptureSender = class {
|
|
|
8999
8999
|
this.fetchFn = hooks.fetch;
|
|
9000
9000
|
this.onError = hooks.onError;
|
|
9001
9001
|
this.now = hooks.now ?? Date.now;
|
|
9002
|
-
this.sleep = hooks.sleep ?? ((ms) => new Promise((
|
|
9002
|
+
this.sleep = hooks.sleep ?? ((ms) => new Promise((resolve14) => safeSetTimeout(resolve14, ms)));
|
|
9003
9003
|
this.generateRequestId = hooks.generateRequestId ?? uuidv7;
|
|
9004
9004
|
this.compress = hooks.compress ?? gzipCompress;
|
|
9005
9005
|
}
|
|
@@ -9363,9 +9363,9 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
|
|
|
9363
9363
|
if (!waitUntil) return;
|
|
9364
9364
|
if (this.disabled || this.optedOut) return;
|
|
9365
9365
|
if (!this._waitUntilCycle) {
|
|
9366
|
-
let
|
|
9366
|
+
let resolve14;
|
|
9367
9367
|
const promise = new Promise((r) => {
|
|
9368
|
-
|
|
9368
|
+
resolve14 = r;
|
|
9369
9369
|
});
|
|
9370
9370
|
try {
|
|
9371
9371
|
waitUntil(promise);
|
|
@@ -9373,7 +9373,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
|
|
|
9373
9373
|
return;
|
|
9374
9374
|
}
|
|
9375
9375
|
this._waitUntilCycle = {
|
|
9376
|
-
resolve:
|
|
9376
|
+
resolve: resolve14,
|
|
9377
9377
|
startedAt: Date.now(),
|
|
9378
9378
|
timer: void 0
|
|
9379
9379
|
};
|
|
@@ -9397,12 +9397,12 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
|
|
|
9397
9397
|
return cycle?.resolve;
|
|
9398
9398
|
}
|
|
9399
9399
|
async resolveWaitUntilFlush() {
|
|
9400
|
-
const
|
|
9400
|
+
const resolve14 = this._consumeWaitUntilCycle();
|
|
9401
9401
|
try {
|
|
9402
9402
|
await this.flushWithPendingPromises();
|
|
9403
9403
|
} catch {
|
|
9404
9404
|
} finally {
|
|
9405
|
-
|
|
9405
|
+
resolve14?.();
|
|
9406
9406
|
}
|
|
9407
9407
|
}
|
|
9408
9408
|
getPersistedProperty(key) {
|
|
@@ -9660,15 +9660,15 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
|
|
|
9660
9660
|
async waitForLocalEvaluationReady(timeoutMs = THIRTY_SECONDS) {
|
|
9661
9661
|
if (this.isLocalEvaluationReady()) return true;
|
|
9662
9662
|
if (void 0 === this.featureFlagsPoller) return false;
|
|
9663
|
-
return new Promise((
|
|
9663
|
+
return new Promise((resolve14) => {
|
|
9664
9664
|
const timeout = setTimeout(() => {
|
|
9665
9665
|
cleanup();
|
|
9666
|
-
|
|
9666
|
+
resolve14(false);
|
|
9667
9667
|
}, timeoutMs);
|
|
9668
9668
|
const cleanup = this._events.on("localEvaluationFlagsLoaded", (count) => {
|
|
9669
9669
|
clearTimeout(timeout);
|
|
9670
9670
|
cleanup();
|
|
9671
|
-
|
|
9671
|
+
resolve14(count > 0);
|
|
9672
9672
|
});
|
|
9673
9673
|
});
|
|
9674
9674
|
}
|
|
@@ -10172,7 +10172,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
|
|
|
10172
10172
|
}
|
|
10173
10173
|
async _shutdown(shutdownTimeoutMs) {
|
|
10174
10174
|
const shutdownDeadlineMs = Date.now() + (shutdownTimeoutMs ?? 3e4);
|
|
10175
|
-
const
|
|
10175
|
+
const resolve14 = this._consumeWaitUntilCycle();
|
|
10176
10176
|
await this.featureFlagsPoller?.stopPoller(shutdownTimeoutMs);
|
|
10177
10177
|
this.errorTracking.shutdown();
|
|
10178
10178
|
if (this._metrics) {
|
|
@@ -10184,7 +10184,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
|
|
|
10184
10184
|
return await super._shutdown(Math.max(0, shutdownDeadlineMs - Date.now()));
|
|
10185
10185
|
} finally {
|
|
10186
10186
|
this.distinctIdHasSentFlagCalls = {};
|
|
10187
|
-
|
|
10187
|
+
resolve14?.();
|
|
10188
10188
|
}
|
|
10189
10189
|
}
|
|
10190
10190
|
async _requestRemoteConfigPayload(flagKey) {
|
|
@@ -10579,7 +10579,7 @@ function readAnonId() {
|
|
|
10579
10579
|
}
|
|
10580
10580
|
function superProperties() {
|
|
10581
10581
|
return {
|
|
10582
|
-
cliVersion: true ? "2.76.
|
|
10582
|
+
cliVersion: true ? "2.76.11" : "0.0.0-dev",
|
|
10583
10583
|
nodeVersion: process.version,
|
|
10584
10584
|
platform: process.platform,
|
|
10585
10585
|
arch: process.arch,
|
|
@@ -10726,10 +10726,10 @@ var _execSeam = {
|
|
|
10726
10726
|
}
|
|
10727
10727
|
};
|
|
10728
10728
|
var _execSeamAsync = {
|
|
10729
|
-
exec: (file, args2, opts) => new Promise((
|
|
10729
|
+
exec: (file, args2, opts) => new Promise((resolve14, reject) => {
|
|
10730
10730
|
(0, import_child_process.execFile)(file, args2, opts, (err, stdout) => {
|
|
10731
10731
|
if (err) reject(err);
|
|
10732
|
-
else
|
|
10732
|
+
else resolve14(typeof stdout === "string" ? stdout : stdout.toString("utf8"));
|
|
10733
10733
|
});
|
|
10734
10734
|
})
|
|
10735
10735
|
};
|
|
@@ -10824,7 +10824,7 @@ var http = __toESM(require("http"));
|
|
|
10824
10824
|
// package.json
|
|
10825
10825
|
var package_default = {
|
|
10826
10826
|
name: "codeam-cli",
|
|
10827
|
-
version: "2.76.
|
|
10827
|
+
version: "2.76.11",
|
|
10828
10828
|
description: "Workflow-continuity bridge for AI coding agents. Wrap Claude Code or Codex in a PTY and supervise, approve, and redirect the session from any device \u2014 async. The terminal companion for CodeAgent Mobile.",
|
|
10829
10829
|
type: "commonjs",
|
|
10830
10830
|
main: "dist/index.js",
|
|
@@ -10958,8 +10958,8 @@ async function requestCode(pluginId, pluginSecretHash) {
|
|
|
10958
10958
|
});
|
|
10959
10959
|
let timer;
|
|
10960
10960
|
const timeoutSentinel = /* @__PURE__ */ Symbol("request-code-timeout");
|
|
10961
|
-
const timeoutPromise = new Promise((
|
|
10962
|
-
timer = setTimeout(() =>
|
|
10961
|
+
const timeoutPromise = new Promise((resolve14) => {
|
|
10962
|
+
timer = setTimeout(() => resolve14(timeoutSentinel), REQUEST_CODE_TIMEOUT_MS);
|
|
10963
10963
|
});
|
|
10964
10964
|
const result = await Promise.race([post3, timeoutPromise]);
|
|
10965
10965
|
clearTimeout(timer);
|
|
@@ -11413,7 +11413,7 @@ async function postBeadsProvisioning(input) {
|
|
|
11413
11413
|
}
|
|
11414
11414
|
}
|
|
11415
11415
|
async function _postJsonAuthed(url2, body, pluginAuthToken) {
|
|
11416
|
-
return new Promise((
|
|
11416
|
+
return new Promise((resolve14, reject) => {
|
|
11417
11417
|
const data = JSON.stringify(body);
|
|
11418
11418
|
const u2 = new URL(url2);
|
|
11419
11419
|
const transport = u2.protocol === "https:" ? https : http;
|
|
@@ -11443,9 +11443,9 @@ async function _postJsonAuthed(url2, body, pluginAuthToken) {
|
|
|
11443
11443
|
return;
|
|
11444
11444
|
}
|
|
11445
11445
|
try {
|
|
11446
|
-
|
|
11446
|
+
resolve14(JSON.parse(responseBody));
|
|
11447
11447
|
} catch {
|
|
11448
|
-
|
|
11448
|
+
resolve14(null);
|
|
11449
11449
|
}
|
|
11450
11450
|
});
|
|
11451
11451
|
}
|
|
@@ -11471,7 +11471,7 @@ function makeHttpError(statusCode, retryAfterHeader, responseBody) {
|
|
|
11471
11471
|
return err;
|
|
11472
11472
|
}
|
|
11473
11473
|
async function _postJson(url2, body, extraHeaders) {
|
|
11474
|
-
return new Promise((
|
|
11474
|
+
return new Promise((resolve14, reject) => {
|
|
11475
11475
|
const data = JSON.stringify(body);
|
|
11476
11476
|
const u2 = new URL(url2);
|
|
11477
11477
|
const transport = u2.protocol === "https:" ? https : http;
|
|
@@ -11501,9 +11501,9 @@ async function _postJson(url2, body, extraHeaders) {
|
|
|
11501
11501
|
return;
|
|
11502
11502
|
}
|
|
11503
11503
|
try {
|
|
11504
|
-
|
|
11504
|
+
resolve14(JSON.parse(body2));
|
|
11505
11505
|
} catch {
|
|
11506
|
-
|
|
11506
|
+
resolve14(null);
|
|
11507
11507
|
}
|
|
11508
11508
|
});
|
|
11509
11509
|
}
|
|
@@ -11518,7 +11518,7 @@ async function _postJson(url2, body, extraHeaders) {
|
|
|
11518
11518
|
});
|
|
11519
11519
|
}
|
|
11520
11520
|
async function _getJson(url2, extraHeaders) {
|
|
11521
|
-
return new Promise((
|
|
11521
|
+
return new Promise((resolve14, reject) => {
|
|
11522
11522
|
const u2 = new URL(url2);
|
|
11523
11523
|
const transport = u2.protocol === "https:" ? https : http;
|
|
11524
11524
|
const req = transport.request(
|
|
@@ -11542,9 +11542,9 @@ async function _getJson(url2, extraHeaders) {
|
|
|
11542
11542
|
return;
|
|
11543
11543
|
}
|
|
11544
11544
|
try {
|
|
11545
|
-
|
|
11545
|
+
resolve14(JSON.parse(body));
|
|
11546
11546
|
} catch {
|
|
11547
|
-
|
|
11547
|
+
resolve14(null);
|
|
11548
11548
|
}
|
|
11549
11549
|
});
|
|
11550
11550
|
}
|
|
@@ -12160,7 +12160,7 @@ var CommandRelayService = class _CommandRelayService {
|
|
|
12160
12160
|
// fresh + clear the "CLI update available" banner after a self-update
|
|
12161
12161
|
// (a codespace that reinstalls @latest reconnects via heartbeat, not
|
|
12162
12162
|
// pair/reconnect). Older backends ignore the extra field.
|
|
12163
|
-
..."2.76.
|
|
12163
|
+
..."2.76.11" ? { ideVersion: "2.76.11" } : {}
|
|
12164
12164
|
};
|
|
12165
12165
|
try {
|
|
12166
12166
|
const res = await _postJson(`${API_BASE2}/api/plugin/heartbeat`, body);
|
|
@@ -12305,8 +12305,8 @@ async function stopRelayWithGoodbye(relay, timeoutMs = RELAY_GOODBYE_TIMEOUT_MS)
|
|
|
12305
12305
|
try {
|
|
12306
12306
|
await Promise.race([
|
|
12307
12307
|
relay.stopAndFlush(),
|
|
12308
|
-
new Promise((
|
|
12309
|
-
timer = setTimeout(
|
|
12308
|
+
new Promise((resolve14) => {
|
|
12309
|
+
timer = setTimeout(resolve14, timeoutMs);
|
|
12310
12310
|
})
|
|
12311
12311
|
]);
|
|
12312
12312
|
} catch {
|
|
@@ -12415,7 +12415,7 @@ var _transport2 = {
|
|
|
12415
12415
|
post: _post
|
|
12416
12416
|
};
|
|
12417
12417
|
function _post(url2, headers, payload) {
|
|
12418
|
-
return new Promise((
|
|
12418
|
+
return new Promise((resolve14, reject) => {
|
|
12419
12419
|
let settled = false;
|
|
12420
12420
|
const u2 = new URL(url2);
|
|
12421
12421
|
const lib = u2.protocol === "https:" ? https3 : http3;
|
|
@@ -12440,7 +12440,7 @@ function _post(url2, headers, payload) {
|
|
|
12440
12440
|
res.on("end", () => {
|
|
12441
12441
|
if (settled) return;
|
|
12442
12442
|
settled = true;
|
|
12443
|
-
|
|
12443
|
+
resolve14({ statusCode: res.statusCode ?? 0, body });
|
|
12444
12444
|
});
|
|
12445
12445
|
}
|
|
12446
12446
|
);
|
|
@@ -12478,10 +12478,10 @@ var WINDOWS_LEGACY_JUNCTIONS = [
|
|
|
12478
12478
|
/[\\/]Start Menu([\\/]|$)/i,
|
|
12479
12479
|
/[\\/]Templates([\\/]|$)/i
|
|
12480
12480
|
];
|
|
12481
|
-
function isUnsafeWindowsWatchRoot(dir,
|
|
12481
|
+
function isUnsafeWindowsWatchRoot(dir, homedir54) {
|
|
12482
12482
|
const norm = (p2) => p2.replace(/\//g, "\\").replace(/\\+$/, "").toLowerCase();
|
|
12483
12483
|
const cwd = norm(dir);
|
|
12484
|
-
const home = norm(
|
|
12484
|
+
const home = norm(homedir54);
|
|
12485
12485
|
if (cwd === home) return true;
|
|
12486
12486
|
if (/^[a-z]:$/.test(cwd)) return true;
|
|
12487
12487
|
const sysRoots = [
|
|
@@ -13139,12 +13139,12 @@ var _gitSeam = {
|
|
|
13139
13139
|
run: _runGitImpl
|
|
13140
13140
|
};
|
|
13141
13141
|
async function _runGitImpl(cwd, args2, opts = {}) {
|
|
13142
|
-
return new Promise((
|
|
13142
|
+
return new Promise((resolve14) => {
|
|
13143
13143
|
let proc;
|
|
13144
13144
|
try {
|
|
13145
13145
|
proc = (0, import_child_process3.spawn)("git", args2, { cwd, env: process.env });
|
|
13146
13146
|
} catch {
|
|
13147
|
-
|
|
13147
|
+
resolve14(null);
|
|
13148
13148
|
return;
|
|
13149
13149
|
}
|
|
13150
13150
|
let stdout = "";
|
|
@@ -13155,13 +13155,13 @@ async function _runGitImpl(cwd, args2, opts = {}) {
|
|
|
13155
13155
|
proc.stderr?.on("data", (c2) => {
|
|
13156
13156
|
stderr += c2.toString();
|
|
13157
13157
|
});
|
|
13158
|
-
proc.on("error", () =>
|
|
13158
|
+
proc.on("error", () => resolve14(null));
|
|
13159
13159
|
proc.on("close", (code) => {
|
|
13160
13160
|
if (code === 0 || opts.allowNonZeroExit) {
|
|
13161
|
-
|
|
13161
|
+
resolve14(stdout);
|
|
13162
13162
|
} else {
|
|
13163
13163
|
log.trace("fileWatcher", `git ${args2.join(" ")} exited ${code} stderr=${stderr.slice(0, 200)}`);
|
|
13164
|
-
|
|
13164
|
+
resolve14(null);
|
|
13165
13165
|
}
|
|
13166
13166
|
});
|
|
13167
13167
|
});
|
|
@@ -13247,7 +13247,7 @@ var ChunkEmitter = class {
|
|
|
13247
13247
|
if (this.pairingInvalid) {
|
|
13248
13248
|
return Promise.resolve({ dead: true });
|
|
13249
13249
|
}
|
|
13250
|
-
return new Promise((
|
|
13250
|
+
return new Promise((resolve14) => {
|
|
13251
13251
|
let refreshedOnce = false;
|
|
13252
13252
|
const attempt = (attemptsLeft) => {
|
|
13253
13253
|
_transport3.post(this.url, this.headers, payload).then(({ statusCode, body: resBody }) => {
|
|
@@ -13255,13 +13255,13 @@ var ChunkEmitter = class {
|
|
|
13255
13255
|
if (statusCode === 410 || statusCode === 404 && /SESSION_NOT_FOUND|SESSION_GONE/.test(resBody)) {
|
|
13256
13256
|
process.stderr.write("[codeam] session was deleted/disconnected \u2014 stopping output stream.\n");
|
|
13257
13257
|
log.info("chunkEmitter", `dead status=${statusCode} took=${tookMs}ms`);
|
|
13258
|
-
|
|
13258
|
+
resolve14({ dead: true });
|
|
13259
13259
|
return;
|
|
13260
13260
|
}
|
|
13261
13261
|
if (statusCode === 401 || statusCode === 403) {
|
|
13262
13262
|
if (refreshedOnce) {
|
|
13263
13263
|
this.markPairingInvalid(statusCode, tookMs);
|
|
13264
|
-
|
|
13264
|
+
resolve14({ dead: true });
|
|
13265
13265
|
return;
|
|
13266
13266
|
}
|
|
13267
13267
|
log.warn("chunkEmitter", `auth ${statusCode} took=${tookMs}ms \u2014 attempting silent refresh`);
|
|
@@ -13277,10 +13277,10 @@ var ChunkEmitter = class {
|
|
|
13277
13277
|
}
|
|
13278
13278
|
if (refresh.kind === "gone") {
|
|
13279
13279
|
this.markPairingInvalid(statusCode, tookMs);
|
|
13280
|
-
|
|
13280
|
+
resolve14({ dead: true });
|
|
13281
13281
|
return;
|
|
13282
13282
|
}
|
|
13283
|
-
|
|
13283
|
+
resolve14({ dead: false });
|
|
13284
13284
|
})();
|
|
13285
13285
|
return;
|
|
13286
13286
|
}
|
|
@@ -13291,7 +13291,7 @@ var ChunkEmitter = class {
|
|
|
13291
13291
|
} else {
|
|
13292
13292
|
log.info("chunkEmitter", `ok status=${statusCode} took=${tookMs}ms`);
|
|
13293
13293
|
}
|
|
13294
|
-
|
|
13294
|
+
resolve14({ dead: false });
|
|
13295
13295
|
}).catch((err) => {
|
|
13296
13296
|
log.warn(
|
|
13297
13297
|
"chunkEmitter",
|
|
@@ -13302,7 +13302,7 @@ var ChunkEmitter = class {
|
|
|
13302
13302
|
const delay = 200 * (maxRetries - attemptsLeft + 1);
|
|
13303
13303
|
setTimeout(() => attempt(attemptsLeft - 1), delay);
|
|
13304
13304
|
} else {
|
|
13305
|
-
|
|
13305
|
+
resolve14({ dead: false });
|
|
13306
13306
|
}
|
|
13307
13307
|
});
|
|
13308
13308
|
};
|
|
@@ -13325,7 +13325,7 @@ var _transport3 = {
|
|
|
13325
13325
|
post: _post2
|
|
13326
13326
|
};
|
|
13327
13327
|
function _post2(url2, headers, payload) {
|
|
13328
|
-
return new Promise((
|
|
13328
|
+
return new Promise((resolve14, reject) => {
|
|
13329
13329
|
let settled = false;
|
|
13330
13330
|
const u2 = new URL(url2);
|
|
13331
13331
|
const transport = u2.protocol === "https:" ? https4 : http4;
|
|
@@ -13349,7 +13349,7 @@ function _post2(url2, headers, payload) {
|
|
|
13349
13349
|
res.on("end", () => {
|
|
13350
13350
|
if (settled) return;
|
|
13351
13351
|
settled = true;
|
|
13352
|
-
|
|
13352
|
+
resolve14({ statusCode: res.statusCode ?? 0, body: resData });
|
|
13353
13353
|
});
|
|
13354
13354
|
}
|
|
13355
13355
|
);
|
|
@@ -14443,12 +14443,12 @@ async function applyFileReview(workingDir, filePath, action) {
|
|
|
14443
14443
|
return { ok: true, action, filePath, repoRoot };
|
|
14444
14444
|
}
|
|
14445
14445
|
function runGit2(cwd, args2) {
|
|
14446
|
-
return new Promise((
|
|
14446
|
+
return new Promise((resolve14) => {
|
|
14447
14447
|
let proc;
|
|
14448
14448
|
try {
|
|
14449
14449
|
proc = (0, import_child_process6.spawn)("git", args2, { cwd, env: process.env });
|
|
14450
14450
|
} catch (err) {
|
|
14451
|
-
|
|
14451
|
+
resolve14({ ok: false, code: -1, stdout: "", stderr: err.message });
|
|
14452
14452
|
return;
|
|
14453
14453
|
}
|
|
14454
14454
|
let stdout = "";
|
|
@@ -14461,11 +14461,11 @@ function runGit2(cwd, args2) {
|
|
|
14461
14461
|
});
|
|
14462
14462
|
proc.on(
|
|
14463
14463
|
"error",
|
|
14464
|
-
(err) =>
|
|
14464
|
+
(err) => resolve14({ ok: false, code: -1, stdout, stderr: stderr + err.message })
|
|
14465
14465
|
);
|
|
14466
14466
|
proc.on(
|
|
14467
14467
|
"close",
|
|
14468
|
-
(code) =>
|
|
14468
|
+
(code) => resolve14({ ok: code === 0, code: code ?? -1, stdout, stderr })
|
|
14469
14469
|
);
|
|
14470
14470
|
});
|
|
14471
14471
|
}
|
|
@@ -16804,13 +16804,13 @@ var UnixPtyStrategy = class {
|
|
|
16804
16804
|
this.proc = null;
|
|
16805
16805
|
if (proc) {
|
|
16806
16806
|
proc.removeAllListeners("exit");
|
|
16807
|
-
const exited = new Promise((
|
|
16808
|
-
if (proc.exitCode !== null || proc.signalCode !== null) return
|
|
16809
|
-
proc.once("exit", () =>
|
|
16807
|
+
const exited = new Promise((resolve14) => {
|
|
16808
|
+
if (proc.exitCode !== null || proc.signalCode !== null) return resolve14();
|
|
16809
|
+
proc.once("exit", () => resolve14());
|
|
16810
16810
|
});
|
|
16811
16811
|
proc.kill("SIGTERM");
|
|
16812
|
-
const timer = new Promise((
|
|
16813
|
-
const t2 = setTimeout(() =>
|
|
16812
|
+
const timer = new Promise((resolve14) => {
|
|
16813
|
+
const t2 = setTimeout(() => resolve14("timeout"), timeoutMs);
|
|
16814
16814
|
void exited.then(() => clearTimeout(t2));
|
|
16815
16815
|
});
|
|
16816
16816
|
if (await Promise.race([exited, timer]) === "timeout") {
|
|
@@ -17237,10 +17237,10 @@ function buildForPlatform(platform3) {
|
|
|
17237
17237
|
var import_node_crypto5 = require("crypto");
|
|
17238
17238
|
|
|
17239
17239
|
// src/agents/claude/resolver.ts
|
|
17240
|
-
function buildClaudeLaunch(extraArgs = [],
|
|
17241
|
-
const found =
|
|
17240
|
+
function buildClaudeLaunch(extraArgs = [], os72 = createOsStrategy()) {
|
|
17241
|
+
const found = os72.findInPath("claude") ?? os72.findInPath("claude-code");
|
|
17242
17242
|
if (!found) return null;
|
|
17243
|
-
return
|
|
17243
|
+
return os72.buildLaunch(found, extraArgs);
|
|
17244
17244
|
}
|
|
17245
17245
|
|
|
17246
17246
|
// src/agents/claude/installer.ts
|
|
@@ -17267,12 +17267,12 @@ function isAvailable() {
|
|
|
17267
17267
|
}
|
|
17268
17268
|
function augmentPath() {
|
|
17269
17269
|
const dirs = probeInstallDirs();
|
|
17270
|
-
const
|
|
17270
|
+
const sep8 = path15.delimiter;
|
|
17271
17271
|
const current2 = process.env.PATH ?? "";
|
|
17272
|
-
const existing = new Set(current2.split(
|
|
17272
|
+
const existing = new Set(current2.split(sep8).filter(Boolean));
|
|
17273
17273
|
const additions = dirs.filter((d3) => !existing.has(d3));
|
|
17274
17274
|
if (additions.length === 0) return;
|
|
17275
|
-
process.env.PATH = additions.join(
|
|
17275
|
+
process.env.PATH = additions.join(sep8) + sep8 + current2;
|
|
17276
17276
|
}
|
|
17277
17277
|
function runInstaller() {
|
|
17278
17278
|
const isWindows = process.platform === "win32";
|
|
@@ -17284,15 +17284,15 @@ function runInstaller() {
|
|
|
17284
17284
|
"-Command",
|
|
17285
17285
|
"irm https://claude.ai/install.ps1 | iex"
|
|
17286
17286
|
] : ["-c", "curl -fsSL https://claude.ai/install.sh | bash"];
|
|
17287
|
-
return new Promise((
|
|
17287
|
+
return new Promise((resolve14) => {
|
|
17288
17288
|
const proc = (0, import_child_process9.spawn)(cmd, args2, { stdio: "inherit" });
|
|
17289
17289
|
proc.on("error", (err) => {
|
|
17290
17290
|
console.error(`
|
|
17291
17291
|
\u2717 Installer failed to launch: ${err.message}`);
|
|
17292
|
-
|
|
17292
|
+
resolve14(false);
|
|
17293
17293
|
});
|
|
17294
17294
|
proc.on("exit", (code) => {
|
|
17295
|
-
|
|
17295
|
+
resolve14(code === 0);
|
|
17296
17296
|
});
|
|
17297
17297
|
});
|
|
17298
17298
|
}
|
|
@@ -17427,7 +17427,7 @@ function extractSetupTokenFromOutput(output) {
|
|
|
17427
17427
|
return m ? m[0] : null;
|
|
17428
17428
|
}
|
|
17429
17429
|
function captureClaudeSetupToken() {
|
|
17430
|
-
return new Promise((
|
|
17430
|
+
return new Promise((resolve14, reject) => {
|
|
17431
17431
|
const child = (0, import_node_child_process2.spawn)("claude", ["setup-token"], {
|
|
17432
17432
|
stdio: ["inherit", "pipe", "inherit"]
|
|
17433
17433
|
});
|
|
@@ -17441,7 +17441,7 @@ function captureClaudeSetupToken() {
|
|
|
17441
17441
|
child.on("exit", (code) => {
|
|
17442
17442
|
const token = extractSetupTokenFromOutput(out2);
|
|
17443
17443
|
if (token) {
|
|
17444
|
-
|
|
17444
|
+
resolve14({ method: "setup_token", credential: token, source: "setup-token" });
|
|
17445
17445
|
return;
|
|
17446
17446
|
}
|
|
17447
17447
|
reject(
|
|
@@ -17527,17 +17527,17 @@ function parseUsageOutput(raw) {
|
|
|
17527
17527
|
return { percent, resetAt };
|
|
17528
17528
|
}
|
|
17529
17529
|
async function fetchClaudeQuota() {
|
|
17530
|
-
return new Promise((
|
|
17530
|
+
return new Promise((resolve14) => {
|
|
17531
17531
|
const claudeCmd = findInPath("claude") ? "claude" : "claude-code";
|
|
17532
17532
|
if (!claudeCmd) {
|
|
17533
|
-
|
|
17533
|
+
resolve14(null);
|
|
17534
17534
|
return;
|
|
17535
17535
|
}
|
|
17536
17536
|
const helperPath = path17.join(os11.tmpdir(), "codeam-quota-helper.py");
|
|
17537
17537
|
fs13.writeFileSync(helperPath, HELPER_SCRIPT, { mode: 420 });
|
|
17538
17538
|
const python = findInPath("python3") ?? findInPath("python");
|
|
17539
17539
|
if (!python) {
|
|
17540
|
-
|
|
17540
|
+
resolve14(null);
|
|
17541
17541
|
return;
|
|
17542
17542
|
}
|
|
17543
17543
|
const proc = (0, import_child_process10.spawn)(python, [helperPath, claudeCmd, "--tools", ""], {
|
|
@@ -17564,13 +17564,13 @@ async function fetchClaudeQuota() {
|
|
|
17564
17564
|
fs13.unlinkSync(helperPath);
|
|
17565
17565
|
} catch {
|
|
17566
17566
|
}
|
|
17567
|
-
|
|
17567
|
+
resolve14(result);
|
|
17568
17568
|
}, 5e3);
|
|
17569
17569
|
}, 8e3);
|
|
17570
17570
|
setTimeout(() => {
|
|
17571
17571
|
if (!resolved) {
|
|
17572
17572
|
resolved = true;
|
|
17573
|
-
|
|
17573
|
+
resolve14(null);
|
|
17574
17574
|
}
|
|
17575
17575
|
try {
|
|
17576
17576
|
proc.kill();
|
|
@@ -17609,12 +17609,12 @@ function killActiveSpawnAndCaptureChildren() {
|
|
|
17609
17609
|
}
|
|
17610
17610
|
async function spawnAndCapture(cmd, args2, opts = {}) {
|
|
17611
17611
|
const timeoutMs = opts.timeoutMs ?? 6e4;
|
|
17612
|
-
return new Promise((
|
|
17612
|
+
return new Promise((resolve14) => {
|
|
17613
17613
|
let settled = false;
|
|
17614
17614
|
const settle = (value) => {
|
|
17615
17615
|
if (settled) return;
|
|
17616
17616
|
settled = true;
|
|
17617
|
-
|
|
17617
|
+
resolve14(value);
|
|
17618
17618
|
};
|
|
17619
17619
|
let child;
|
|
17620
17620
|
try {
|
|
@@ -18066,8 +18066,8 @@ var ClaudeRuntimeStrategy = class {
|
|
|
18066
18066
|
meta = getAgent("claude");
|
|
18067
18067
|
mode = "interactive";
|
|
18068
18068
|
os;
|
|
18069
|
-
constructor(
|
|
18070
|
-
this.os =
|
|
18069
|
+
constructor(os72) {
|
|
18070
|
+
this.os = os72;
|
|
18071
18071
|
}
|
|
18072
18072
|
/**
|
|
18073
18073
|
* Claude Code's react-ink TUI enables bracketed-paste mode at
|
|
@@ -19065,7 +19065,7 @@ function newestRolloutIdSince(sessionsRoot, resolvedCwd, floorMs) {
|
|
|
19065
19065
|
return bestId;
|
|
19066
19066
|
}
|
|
19067
19067
|
function sleep2(ms) {
|
|
19068
|
-
return new Promise((
|
|
19068
|
+
return new Promise((resolve14) => setTimeout(resolve14, ms));
|
|
19069
19069
|
}
|
|
19070
19070
|
function getCurrentUsage2(historyDir) {
|
|
19071
19071
|
if (!import_node_fs4.default.existsSync(historyDir)) return null;
|
|
@@ -19167,8 +19167,8 @@ function codexCredentialLocator() {
|
|
|
19167
19167
|
function codexLoginLauncher() {
|
|
19168
19168
|
return {
|
|
19169
19169
|
async ensureInstalled() {
|
|
19170
|
-
const
|
|
19171
|
-
return
|
|
19170
|
+
const os72 = createOsStrategy();
|
|
19171
|
+
return os72.findInPath("codex") !== null;
|
|
19172
19172
|
},
|
|
19173
19173
|
launch() {
|
|
19174
19174
|
return (0, import_node_child_process3.spawn)("codex", ["login"], { stdio: "inherit" });
|
|
@@ -19191,8 +19191,8 @@ var CodexRuntimeStrategy = class {
|
|
|
19191
19191
|
meta = getAgent("codex");
|
|
19192
19192
|
mode = "interactive";
|
|
19193
19193
|
os;
|
|
19194
|
-
constructor(
|
|
19195
|
-
this.os =
|
|
19194
|
+
constructor(os72) {
|
|
19195
|
+
this.os = os72;
|
|
19196
19196
|
}
|
|
19197
19197
|
async prepareLaunch() {
|
|
19198
19198
|
let binary = this.os.findInPath("codex");
|
|
@@ -19303,16 +19303,16 @@ var CodexRuntimeStrategy = class {
|
|
|
19303
19303
|
});
|
|
19304
19304
|
}
|
|
19305
19305
|
};
|
|
19306
|
-
function resolveNpm(
|
|
19307
|
-
return
|
|
19306
|
+
function resolveNpm(os72) {
|
|
19307
|
+
return os72.id === "win32" ? "npm.cmd" : "npm";
|
|
19308
19308
|
}
|
|
19309
|
-
async function installCodexViaNpm(
|
|
19310
|
-
return new Promise((
|
|
19311
|
-
const proc = (0, import_node_child_process4.spawn)(resolveNpm(
|
|
19309
|
+
async function installCodexViaNpm(os72) {
|
|
19310
|
+
return new Promise((resolve14, reject) => {
|
|
19311
|
+
const proc = (0, import_node_child_process4.spawn)(resolveNpm(os72), ["install", "-g", "@openai/codex"], {
|
|
19312
19312
|
stdio: "inherit"
|
|
19313
19313
|
});
|
|
19314
19314
|
proc.on("close", (code) => {
|
|
19315
|
-
if (code === 0)
|
|
19315
|
+
if (code === 0) resolve14();
|
|
19316
19316
|
else reject(new Error(`npm install -g @openai/codex exited ${code}`));
|
|
19317
19317
|
});
|
|
19318
19318
|
proc.on("error", (err) => {
|
|
@@ -19325,16 +19325,16 @@ async function installCodexViaNpm(os70) {
|
|
|
19325
19325
|
});
|
|
19326
19326
|
});
|
|
19327
19327
|
}
|
|
19328
|
-
function augmentNpmGlobalBin(
|
|
19328
|
+
function augmentNpmGlobalBin(os72) {
|
|
19329
19329
|
try {
|
|
19330
|
-
const result = (0, import_node_child_process4.spawnSync)(resolveNpm(
|
|
19330
|
+
const result = (0, import_node_child_process4.spawnSync)(resolveNpm(os72), ["prefix", "-g"], {
|
|
19331
19331
|
stdio: ["ignore", "pipe", "ignore"]
|
|
19332
19332
|
});
|
|
19333
19333
|
if (result.status !== 0) return;
|
|
19334
19334
|
const prefix = result.stdout.toString().trim();
|
|
19335
19335
|
if (!prefix) return;
|
|
19336
|
-
const binDir =
|
|
19337
|
-
|
|
19336
|
+
const binDir = os72.id === "win32" ? prefix : path26.join(prefix, "bin");
|
|
19337
|
+
os72.augmentPath([binDir]);
|
|
19338
19338
|
} catch {
|
|
19339
19339
|
}
|
|
19340
19340
|
}
|
|
@@ -19432,7 +19432,7 @@ var defaultOsRunner = {
|
|
|
19432
19432
|
}
|
|
19433
19433
|
},
|
|
19434
19434
|
run(cmd, args2, opts = {}) {
|
|
19435
|
-
return new Promise((
|
|
19435
|
+
return new Promise((resolve14) => {
|
|
19436
19436
|
const spawnEnv = opts.env ?? process.env;
|
|
19437
19437
|
const child = (0, import_node_child_process5.spawn)(cmd, args2, { stdio: ["ignore", "pipe", "pipe"], env: spawnEnv });
|
|
19438
19438
|
let stderrBuf = "";
|
|
@@ -19441,7 +19441,7 @@ var defaultOsRunner = {
|
|
|
19441
19441
|
const done = (code) => {
|
|
19442
19442
|
if (settled) return;
|
|
19443
19443
|
settled = true;
|
|
19444
|
-
|
|
19444
|
+
resolve14({ code, stderr: stderrBuf, stdout: stdoutBuf });
|
|
19445
19445
|
};
|
|
19446
19446
|
child.stdout?.on("data", (b) => {
|
|
19447
19447
|
const chunk = b.toString();
|
|
@@ -19528,10 +19528,10 @@ function manualInstallHint(runner, tools) {
|
|
|
19528
19528
|
const argv = osPackageInstallArgv(detectPackageManager(runner), [...tools]);
|
|
19529
19529
|
return argv ? `\`sudo ${argv.join(" ")}\`` : `your package manager (e.g. \`${pkgs}\`)`;
|
|
19530
19530
|
}
|
|
19531
|
-
function writeUnzipShim(
|
|
19531
|
+
function writeUnzipShim(os72, runner) {
|
|
19532
19532
|
const python = ["python3", "python"].find((p2) => runner.which(p2));
|
|
19533
19533
|
if (!python) return null;
|
|
19534
|
-
const dir =
|
|
19534
|
+
const dir = os72.scratchPath("codeam-cr-prereq");
|
|
19535
19535
|
const shim = path28.join(dir, "unzip");
|
|
19536
19536
|
const script = `#!/bin/sh
|
|
19537
19537
|
set -e
|
|
@@ -19553,9 +19553,9 @@ exec ${python} -m zipfile -e "$archive" "$dest"
|
|
|
19553
19553
|
(0, import_node_fs6.chmodSync)(shim, 448);
|
|
19554
19554
|
return dir;
|
|
19555
19555
|
}
|
|
19556
|
-
async function ensureInstallPrerequisites(
|
|
19556
|
+
async function ensureInstallPrerequisites(os72, deps = {}) {
|
|
19557
19557
|
const runner = deps.runner ?? defaultOsRunner;
|
|
19558
|
-
const missing = REQUIRED_TOOLS.filter((t2) =>
|
|
19558
|
+
const missing = REQUIRED_TOOLS.filter((t2) => os72.findInPath(t2) === null);
|
|
19559
19559
|
if (missing.length === 0) return { ok: true, extraPath: [] };
|
|
19560
19560
|
log.info(
|
|
19561
19561
|
"coderabbit",
|
|
@@ -19574,10 +19574,10 @@ async function ensureInstallPrerequisites(os70, deps = {}) {
|
|
|
19574
19574
|
);
|
|
19575
19575
|
}
|
|
19576
19576
|
}
|
|
19577
|
-
const stillMissing = REQUIRED_TOOLS.filter((t2) =>
|
|
19577
|
+
const stillMissing = REQUIRED_TOOLS.filter((t2) => os72.findInPath(t2) === null);
|
|
19578
19578
|
if (stillMissing.length === 0) return { ok: true, extraPath: [] };
|
|
19579
19579
|
if (stillMissing.length === 1 && stillMissing[0] === "unzip") {
|
|
19580
|
-
const shimDir = writeUnzipShim(
|
|
19580
|
+
const shimDir = writeUnzipShim(os72, runner);
|
|
19581
19581
|
if (shimDir) {
|
|
19582
19582
|
log.info("coderabbit", "unzip is unavailable \u2014 using a scoped python zipfile shim");
|
|
19583
19583
|
return { ok: true, extraPath: [shimDir] };
|
|
@@ -19590,7 +19590,7 @@ async function ensureInstallPrerequisites(os70, deps = {}) {
|
|
|
19590
19590
|
};
|
|
19591
19591
|
}
|
|
19592
19592
|
function defaultRunInstallScript(env) {
|
|
19593
|
-
return new Promise((
|
|
19593
|
+
return new Promise((resolve14) => {
|
|
19594
19594
|
const proc = (0, import_node_child_process6.spawn)(
|
|
19595
19595
|
"sh",
|
|
19596
19596
|
["-c", `curl -fsSL --connect-timeout 15 --max-time 120 ${INSTALL_URL} | sh`],
|
|
@@ -19602,7 +19602,7 @@ function defaultRunInstallScript(env) {
|
|
|
19602
19602
|
if (settled) return;
|
|
19603
19603
|
settled = true;
|
|
19604
19604
|
clearTimeout(timer);
|
|
19605
|
-
|
|
19605
|
+
resolve14({ code, output });
|
|
19606
19606
|
};
|
|
19607
19607
|
const onData = (b) => {
|
|
19608
19608
|
const chunk = b.toString();
|
|
@@ -19640,15 +19640,15 @@ function summarizeInstallFailure(output) {
|
|
|
19640
19640
|
}
|
|
19641
19641
|
return lines.length > 0 ? lines[lines.length - 1] : null;
|
|
19642
19642
|
}
|
|
19643
|
-
async function ensureCoderabbitInstalled(
|
|
19644
|
-
if (
|
|
19645
|
-
if (
|
|
19643
|
+
async function ensureCoderabbitInstalled(os72, deps = {}) {
|
|
19644
|
+
if (os72.findInPath("coderabbit")) return { ok: true };
|
|
19645
|
+
if (os72.id === "win32") {
|
|
19646
19646
|
return {
|
|
19647
19647
|
ok: false,
|
|
19648
19648
|
error: "CodeRabbit on Windows requires WSL. Install the CLI inside your WSL distribution (curl -fsSL https://cli.coderabbit.ai/install.sh | sh), then try again."
|
|
19649
19649
|
};
|
|
19650
19650
|
}
|
|
19651
|
-
const prereq = await ensureInstallPrerequisites(
|
|
19651
|
+
const prereq = await ensureInstallPrerequisites(os72, deps);
|
|
19652
19652
|
if (!prereq.ok) return { ok: false, error: prereq.error };
|
|
19653
19653
|
const env = { ...process.env };
|
|
19654
19654
|
if (prereq.extraPath.length > 0) {
|
|
@@ -19657,8 +19657,8 @@ async function ensureCoderabbitInstalled(os70, deps = {}) {
|
|
|
19657
19657
|
log.info("coderabbit", "CodeRabbit CLI not found \u2014 installing via the official script");
|
|
19658
19658
|
const run3 = deps.runInstallScript ?? defaultRunInstallScript;
|
|
19659
19659
|
const { code, output } = await run3(env);
|
|
19660
|
-
|
|
19661
|
-
const binary =
|
|
19660
|
+
os72.augmentPath([`${os72.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
|
|
19661
|
+
const binary = os72.findInPath("coderabbit");
|
|
19662
19662
|
const detail = summarizeInstallFailure(output);
|
|
19663
19663
|
if (binary !== null) {
|
|
19664
19664
|
if (code === 0) return { ok: true };
|
|
@@ -19712,10 +19712,10 @@ function coderabbitCredentialLocator() {
|
|
|
19712
19712
|
validate: validateNonEmptyCredential
|
|
19713
19713
|
};
|
|
19714
19714
|
}
|
|
19715
|
-
function coderabbitLoginLauncher(
|
|
19715
|
+
function coderabbitLoginLauncher(os72) {
|
|
19716
19716
|
return {
|
|
19717
19717
|
async ensureInstalled() {
|
|
19718
|
-
const result = await ensureCoderabbitInstalled(
|
|
19718
|
+
const result = await ensureCoderabbitInstalled(os72);
|
|
19719
19719
|
if (!result.ok && result.error) console.error(`
|
|
19720
19720
|
\u2717 ${result.error}
|
|
19721
19721
|
`);
|
|
@@ -19775,8 +19775,8 @@ function pickLine(obj) {
|
|
|
19775
19775
|
function toHunk(raw, groupSeverity) {
|
|
19776
19776
|
if (!raw || typeof raw !== "object") return null;
|
|
19777
19777
|
const o = raw;
|
|
19778
|
-
const
|
|
19779
|
-
if (!
|
|
19778
|
+
const path112 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
|
|
19779
|
+
if (!path112) return null;
|
|
19780
19780
|
const message = asString(
|
|
19781
19781
|
pick(o, [
|
|
19782
19782
|
"comment",
|
|
@@ -19793,7 +19793,7 @@ function toHunk(raw, groupSeverity) {
|
|
|
19793
19793
|
const severity = normSeverity(pick(o, ["severity", "level", "priority", "impact"])) ?? normSeverity(groupSeverity);
|
|
19794
19794
|
const locObj = pick(o, ["location"]) ?? o;
|
|
19795
19795
|
return {
|
|
19796
|
-
path:
|
|
19796
|
+
path: path112.trim(),
|
|
19797
19797
|
line: pickLine(o) ?? pickLine(locObj),
|
|
19798
19798
|
severity,
|
|
19799
19799
|
message: (title && message ? `${title}: ${message}` : title || message).trim() || "(no message)"
|
|
@@ -19876,10 +19876,10 @@ function parsePlain(stdout) {
|
|
|
19876
19876
|
for (const line of stdout.split(/\r?\n/)) {
|
|
19877
19877
|
const m = line.match(HUNK_LINE_RE);
|
|
19878
19878
|
if (!m) continue;
|
|
19879
|
-
const [,
|
|
19880
|
-
if (!
|
|
19879
|
+
const [, path112, lineNo, sevToken, message] = m;
|
|
19880
|
+
if (!path112 || !lineNo || !message) continue;
|
|
19881
19881
|
hunks.push({
|
|
19882
|
-
path:
|
|
19882
|
+
path: path112.trim(),
|
|
19883
19883
|
line: Number(lineNo),
|
|
19884
19884
|
severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
|
|
19885
19885
|
message: message.trim().replace(/^[*-]\s+/, "")
|
|
@@ -19939,8 +19939,8 @@ var CoderabbitRuntimeStrategy = class {
|
|
|
19939
19939
|
meta = getAgent("coderabbit");
|
|
19940
19940
|
mode = "batch";
|
|
19941
19941
|
os;
|
|
19942
|
-
constructor(
|
|
19943
|
-
this.os =
|
|
19942
|
+
constructor(os72) {
|
|
19943
|
+
this.os = os72;
|
|
19944
19944
|
}
|
|
19945
19945
|
getDefaultArgs() {
|
|
19946
19946
|
return ["review", "--agent"];
|
|
@@ -19976,7 +19976,7 @@ var CoderabbitRuntimeStrategy = class {
|
|
|
19976
19976
|
}
|
|
19977
19977
|
async runOneShot(input) {
|
|
19978
19978
|
const launch = await this.prepareInvocation(input);
|
|
19979
|
-
return new Promise((
|
|
19979
|
+
return new Promise((resolve14, reject) => {
|
|
19980
19980
|
const stdoutBuf = [];
|
|
19981
19981
|
const stderrBuf = [];
|
|
19982
19982
|
const proc = (0, import_node_child_process8.spawn)(launch.cmd, launch.args, {
|
|
@@ -19988,7 +19988,7 @@ var CoderabbitRuntimeStrategy = class {
|
|
|
19988
19988
|
if (settled) return;
|
|
19989
19989
|
settled = true;
|
|
19990
19990
|
clearTimeout(timer);
|
|
19991
|
-
|
|
19991
|
+
resolve14(out2);
|
|
19992
19992
|
};
|
|
19993
19993
|
const timer = setTimeout(() => {
|
|
19994
19994
|
if (settled) return;
|
|
@@ -20211,10 +20211,10 @@ function cursorCredentialLocator() {
|
|
|
20211
20211
|
validate: validateNonEmptyCredential
|
|
20212
20212
|
};
|
|
20213
20213
|
}
|
|
20214
|
-
function cursorLoginLauncher(
|
|
20214
|
+
function cursorLoginLauncher(os72) {
|
|
20215
20215
|
return {
|
|
20216
20216
|
async ensureInstalled() {
|
|
20217
|
-
if (
|
|
20217
|
+
if (os72.findInPath("cursor-agent")) return true;
|
|
20218
20218
|
console.error(
|
|
20219
20219
|
"\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"
|
|
20220
20220
|
);
|
|
@@ -20278,8 +20278,8 @@ var CursorRuntimeStrategy = class {
|
|
|
20278
20278
|
meta = getAgent("cursor");
|
|
20279
20279
|
mode = "interactive";
|
|
20280
20280
|
os;
|
|
20281
|
-
constructor(
|
|
20282
|
-
this.os =
|
|
20281
|
+
constructor(os72) {
|
|
20282
|
+
this.os = os72;
|
|
20283
20283
|
}
|
|
20284
20284
|
async prepareLaunch() {
|
|
20285
20285
|
const binary = this.os.findInPath("cursor-agent");
|
|
@@ -20497,10 +20497,10 @@ function aiderCredentialLocator() {
|
|
|
20497
20497
|
validate: validateNonEmptyCredential
|
|
20498
20498
|
};
|
|
20499
20499
|
}
|
|
20500
|
-
function aiderLoginLauncher(
|
|
20500
|
+
function aiderLoginLauncher(os72) {
|
|
20501
20501
|
return {
|
|
20502
20502
|
async ensureInstalled() {
|
|
20503
|
-
if (
|
|
20503
|
+
if (os72.findInPath("aider")) return true;
|
|
20504
20504
|
console.error(
|
|
20505
20505
|
"\n \u2717 aider binary not on PATH.\n Install Aider:\n pip install aider-chat\n then re-run `codeam link aider`.\n"
|
|
20506
20506
|
);
|
|
@@ -20510,7 +20510,7 @@ function aiderLoginLauncher(os70) {
|
|
|
20510
20510
|
console.error(
|
|
20511
20511
|
"\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"
|
|
20512
20512
|
);
|
|
20513
|
-
return (0, import_node_child_process11.spawn)(
|
|
20513
|
+
return (0, import_node_child_process11.spawn)(os72.id === "win32" ? "cmd.exe" : "sh", os72.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
|
|
20514
20514
|
stdio: "ignore"
|
|
20515
20515
|
});
|
|
20516
20516
|
}
|
|
@@ -20599,16 +20599,16 @@ function defaultSdkDir() {
|
|
|
20599
20599
|
return resolveSdkDirViaRequire();
|
|
20600
20600
|
}
|
|
20601
20601
|
function resolveClaudeNativeBinary(deps = {}) {
|
|
20602
|
-
const
|
|
20602
|
+
const existsSync35 = deps.existsSync ?? import_fs.default.existsSync;
|
|
20603
20603
|
const platformKey = deps.platformKey ?? currentPlatformKey();
|
|
20604
20604
|
const sdkDir = deps.sdkDir !== void 0 ? deps.sdkDir : defaultSdkDir();
|
|
20605
20605
|
if (!sdkDir) return null;
|
|
20606
20606
|
const scopeDir = import_path4.default.dirname(sdkDir);
|
|
20607
20607
|
const binName = platformKey.startsWith("win32-") ? "claude.exe" : "claude";
|
|
20608
20608
|
const candidate = import_path4.default.join(scopeDir, `claude-agent-sdk-${platformKey}`, binName);
|
|
20609
|
-
return
|
|
20609
|
+
return existsSync35(candidate) ? candidate : null;
|
|
20610
20610
|
}
|
|
20611
|
-
var realSleep = (ms) => new Promise((
|
|
20611
|
+
var realSleep = (ms) => new Promise((resolve14) => setTimeout(resolve14, ms));
|
|
20612
20612
|
async function waitForClaudeNativeBinary(opts = {}) {
|
|
20613
20613
|
const timeoutMs = opts.timeoutMs ?? 18e4;
|
|
20614
20614
|
const pollMs = opts.pollMs ?? 500;
|
|
@@ -20688,18 +20688,18 @@ function augmentUserLocalBinPaths(deps = {}) {
|
|
|
20688
20688
|
env.PATH = [...additions, ...parts].join(p2.delimiter);
|
|
20689
20689
|
}
|
|
20690
20690
|
function resolveCursorAgentBinary(deps = {}) {
|
|
20691
|
-
const
|
|
20691
|
+
const existsSync35 = deps.existsSync ?? import_fs.default.existsSync;
|
|
20692
20692
|
const platform3 = deps.platform ?? process.platform;
|
|
20693
20693
|
const env = deps.env ?? process.env;
|
|
20694
20694
|
if (platform3 === "win32") {
|
|
20695
20695
|
const localAppData = env.LOCALAPPDATA;
|
|
20696
20696
|
if (!localAppData) return null;
|
|
20697
20697
|
const exe = import_path4.default.win32.join(localAppData, "cursor-agent", "cursor-agent.exe");
|
|
20698
|
-
return
|
|
20698
|
+
return existsSync35(exe) ? exe : null;
|
|
20699
20699
|
}
|
|
20700
20700
|
const home = deps.homedir ?? import_os4.default.homedir();
|
|
20701
20701
|
const unix = import_path4.default.posix.join(home, ".local", "bin", "cursor-agent");
|
|
20702
|
-
return
|
|
20702
|
+
return existsSync35(unix) ? unix : null;
|
|
20703
20703
|
}
|
|
20704
20704
|
async function waitForCursorAgent(opts = {}) {
|
|
20705
20705
|
const timeoutMs = opts.timeoutMs ?? 18e4;
|
|
@@ -20720,7 +20720,7 @@ var PERMANENT_ADAPTER_STARTUP_RE = /IneligibleTierError|UNSUPPORTED_CLIENT|no lo
|
|
|
20720
20720
|
function probeAdapterModuleGraph(command2, args2, opts = {}) {
|
|
20721
20721
|
const livenessMs = opts.livenessMs ?? 400;
|
|
20722
20722
|
const spawnFn = opts.spawnFn ?? import_child_process13.spawn;
|
|
20723
|
-
return new Promise((
|
|
20723
|
+
return new Promise((resolve14) => {
|
|
20724
20724
|
let settled = false;
|
|
20725
20725
|
let stderr = "";
|
|
20726
20726
|
let timer;
|
|
@@ -20733,12 +20733,12 @@ function probeAdapterModuleGraph(command2, args2, opts = {}) {
|
|
|
20733
20733
|
child?.kill("SIGKILL");
|
|
20734
20734
|
} catch {
|
|
20735
20735
|
}
|
|
20736
|
-
|
|
20736
|
+
resolve14(r);
|
|
20737
20737
|
};
|
|
20738
20738
|
try {
|
|
20739
20739
|
child = spawnFn(command2, [...args2], { stdio: ["pipe", "ignore", "pipe"] });
|
|
20740
20740
|
} catch {
|
|
20741
|
-
|
|
20741
|
+
resolve14("ok");
|
|
20742
20742
|
return;
|
|
20743
20743
|
}
|
|
20744
20744
|
child.stderr?.on("data", (d3) => {
|
|
@@ -20785,8 +20785,8 @@ var AiderRuntimeStrategy = class {
|
|
|
20785
20785
|
meta = getAgent("aider");
|
|
20786
20786
|
mode = "interactive";
|
|
20787
20787
|
os;
|
|
20788
|
-
constructor(
|
|
20789
|
-
this.os =
|
|
20788
|
+
constructor(os72) {
|
|
20789
|
+
this.os = os72;
|
|
20790
20790
|
}
|
|
20791
20791
|
async prepareLaunch() {
|
|
20792
20792
|
augmentUserLocalBinPaths();
|
|
@@ -20919,8 +20919,8 @@ function geminiCredentialLocator() {
|
|
|
20919
20919
|
function geminiLoginLauncher() {
|
|
20920
20920
|
return {
|
|
20921
20921
|
async ensureInstalled() {
|
|
20922
|
-
const
|
|
20923
|
-
return
|
|
20922
|
+
const os72 = createOsStrategy();
|
|
20923
|
+
return os72.findInPath("gemini") !== null;
|
|
20924
20924
|
},
|
|
20925
20925
|
launch() {
|
|
20926
20926
|
return (0, import_node_child_process12.spawn)("gemini", ["auth", "login"], { stdio: "inherit" });
|
|
@@ -21110,8 +21110,8 @@ var GeminiRuntimeStrategy = class {
|
|
|
21110
21110
|
meta = getAgent("gemini");
|
|
21111
21111
|
mode = "interactive";
|
|
21112
21112
|
os;
|
|
21113
|
-
constructor(
|
|
21114
|
-
this.os =
|
|
21113
|
+
constructor(os72) {
|
|
21114
|
+
this.os = os72;
|
|
21115
21115
|
}
|
|
21116
21116
|
async prepareLaunch() {
|
|
21117
21117
|
const binary = this.os.findInPath("gemini");
|
|
@@ -21327,7 +21327,7 @@ function newestSessionSince(bucket, floorMs) {
|
|
|
21327
21327
|
return bestId;
|
|
21328
21328
|
}
|
|
21329
21329
|
function sleep3(ms) {
|
|
21330
|
-
return new Promise((
|
|
21330
|
+
return new Promise((resolve14) => setTimeout(resolve14, ms));
|
|
21331
21331
|
}
|
|
21332
21332
|
function joinTextParts(parts) {
|
|
21333
21333
|
if (!Array.isArray(parts)) return "";
|
|
@@ -21404,8 +21404,8 @@ var KimiRuntimeStrategy = class {
|
|
|
21404
21404
|
meta = getAgent("kimi");
|
|
21405
21405
|
mode = "interactive";
|
|
21406
21406
|
os;
|
|
21407
|
-
constructor(
|
|
21408
|
-
this.os =
|
|
21407
|
+
constructor(os72) {
|
|
21408
|
+
this.os = os72;
|
|
21409
21409
|
}
|
|
21410
21410
|
async prepareLaunch() {
|
|
21411
21411
|
const binary = this.os.findInPath("kimi");
|
|
@@ -21549,8 +21549,8 @@ var OpencodeRuntimeStrategy = class {
|
|
|
21549
21549
|
meta = getAgent("opencode");
|
|
21550
21550
|
mode = "interactive";
|
|
21551
21551
|
os;
|
|
21552
|
-
constructor(
|
|
21553
|
-
this.os =
|
|
21552
|
+
constructor(os72) {
|
|
21553
|
+
this.os = os72;
|
|
21554
21554
|
}
|
|
21555
21555
|
async prepareLaunch() {
|
|
21556
21556
|
const binary = this.os.findInPath("opencode");
|
|
@@ -21636,20 +21636,20 @@ var OpencodeRuntimeStrategy = class {
|
|
|
21636
21636
|
|
|
21637
21637
|
// src/agents/registry.ts
|
|
21638
21638
|
var runtimeBuilders = {
|
|
21639
|
-
claude: (
|
|
21640
|
-
codex: (
|
|
21641
|
-
coderabbit: (
|
|
21642
|
-
cursor: (
|
|
21643
|
-
aider: (
|
|
21644
|
-
gemini: (
|
|
21645
|
-
kimi: (
|
|
21646
|
-
opencode: (
|
|
21639
|
+
claude: (os72) => new ClaudeRuntimeStrategy(os72),
|
|
21640
|
+
codex: (os72) => new CodexRuntimeStrategy(os72),
|
|
21641
|
+
coderabbit: (os72) => new CoderabbitRuntimeStrategy(os72),
|
|
21642
|
+
cursor: (os72) => new CursorRuntimeStrategy(os72),
|
|
21643
|
+
aider: (os72) => new AiderRuntimeStrategy(os72),
|
|
21644
|
+
gemini: (os72) => new GeminiRuntimeStrategy(os72),
|
|
21645
|
+
kimi: (os72) => new KimiRuntimeStrategy(os72),
|
|
21646
|
+
opencode: (os72) => new OpencodeRuntimeStrategy(os72)
|
|
21647
21647
|
};
|
|
21648
21648
|
var deployBuilders = {
|
|
21649
21649
|
claude: () => new ClaudeDeployStrategy(),
|
|
21650
21650
|
codex: () => new CodexDeployStrategy()
|
|
21651
21651
|
};
|
|
21652
|
-
function createAgentStrategy(agent,
|
|
21652
|
+
function createAgentStrategy(agent, os72 = createOsStrategy()) {
|
|
21653
21653
|
if (!AGENT_REGISTRY[agent]?.enabled) {
|
|
21654
21654
|
throw new Error(
|
|
21655
21655
|
`Agent "${agent}" is not supported in this codeam-cli version. Upgrade with 'npm i -g codeam-cli@latest'.`
|
|
@@ -21659,10 +21659,10 @@ function createAgentStrategy(agent, os70 = createOsStrategy()) {
|
|
|
21659
21659
|
if (!build) {
|
|
21660
21660
|
throw new Error(`No runtime strategy registered for agent "${agent}"`);
|
|
21661
21661
|
}
|
|
21662
|
-
return build(
|
|
21662
|
+
return build(os72);
|
|
21663
21663
|
}
|
|
21664
|
-
function createInteractiveAgentStrategy(agent,
|
|
21665
|
-
const s = createAgentStrategy(agent,
|
|
21664
|
+
function createInteractiveAgentStrategy(agent, os72 = createOsStrategy()) {
|
|
21665
|
+
const s = createAgentStrategy(agent, os72);
|
|
21666
21666
|
if (s.mode !== "interactive") {
|
|
21667
21667
|
throw new Error(
|
|
21668
21668
|
`Agent "${agent}" is a batch agent; use createAgentStrategy + .runOneShot for one-shot reviews.`
|
|
@@ -21778,7 +21778,7 @@ async function link(args2 = []) {
|
|
|
21778
21778
|
waitSpin.start(waitMsg());
|
|
21779
21779
|
const countdown = setInterval(() => waitSpin.message(waitMsg()), 1e3);
|
|
21780
21780
|
countdown.unref?.();
|
|
21781
|
-
const paired = await new Promise((
|
|
21781
|
+
const paired = await new Promise((resolve14, reject) => {
|
|
21782
21782
|
let stopPoll = null;
|
|
21783
21783
|
const sigint = () => {
|
|
21784
21784
|
clearInterval(countdown);
|
|
@@ -21791,7 +21791,7 @@ async function link(args2 = []) {
|
|
|
21791
21791
|
process.removeListener("SIGINT", sigint);
|
|
21792
21792
|
clearInterval(countdown);
|
|
21793
21793
|
waitSpin.stop("Paired");
|
|
21794
|
-
|
|
21794
|
+
resolve14(info);
|
|
21795
21795
|
},
|
|
21796
21796
|
() => {
|
|
21797
21797
|
clearInterval(countdown);
|
|
@@ -21949,14 +21949,14 @@ async function captureFreshCredentials(ctx) {
|
|
|
21949
21949
|
}
|
|
21950
21950
|
};
|
|
21951
21951
|
try {
|
|
21952
|
-
const token = await new Promise((
|
|
21952
|
+
const token = await new Promise((resolve14, reject) => {
|
|
21953
21953
|
let settled = false;
|
|
21954
21954
|
const tryExtract = async () => {
|
|
21955
21955
|
if (settled) return;
|
|
21956
21956
|
const t2 = await ctx.locator.extract();
|
|
21957
21957
|
if (t2 && !settled) {
|
|
21958
21958
|
settled = true;
|
|
21959
|
-
|
|
21959
|
+
resolve14(t2);
|
|
21960
21960
|
}
|
|
21961
21961
|
};
|
|
21962
21962
|
watcher.on("add", () => void tryExtract());
|
|
@@ -22200,7 +22200,7 @@ function deliverPendingCoderabbitCallback(callbackUrl) {
|
|
|
22200
22200
|
function runCoderabbitOAuthLogin(deps) {
|
|
22201
22201
|
const timeoutMs = deps.timeoutMs ?? 18e4;
|
|
22202
22202
|
const spawnProc = deps.spawn ?? spawnCoderabbitLoginProc;
|
|
22203
|
-
return new Promise((
|
|
22203
|
+
return new Promise((resolve14) => {
|
|
22204
22204
|
let settled = false;
|
|
22205
22205
|
let stdout = "";
|
|
22206
22206
|
let last = null;
|
|
@@ -22213,13 +22213,13 @@ function runCoderabbitOAuthLogin(deps) {
|
|
|
22213
22213
|
child.kill("SIGKILL");
|
|
22214
22214
|
} catch {
|
|
22215
22215
|
}
|
|
22216
|
-
|
|
22216
|
+
resolve14(r);
|
|
22217
22217
|
};
|
|
22218
22218
|
let child;
|
|
22219
22219
|
try {
|
|
22220
22220
|
child = spawnProc("coderabbit", ["auth", "login", "--agent"]);
|
|
22221
22221
|
} catch (err) {
|
|
22222
|
-
|
|
22222
|
+
resolve14({ ok: false, error: err instanceof Error ? err.message : "spawn failed" });
|
|
22223
22223
|
return;
|
|
22224
22224
|
}
|
|
22225
22225
|
const timer = setTimeout(
|
|
@@ -22376,8 +22376,8 @@ function collectChangedFiles(cwd) {
|
|
|
22376
22376
|
}
|
|
22377
22377
|
return [...byPath.values()];
|
|
22378
22378
|
}
|
|
22379
|
-
function restoreCoderabbitOauthBlob(
|
|
22380
|
-
const dir = path40.join(
|
|
22379
|
+
function restoreCoderabbitOauthBlob(os72, value) {
|
|
22380
|
+
const dir = path40.join(os72.homeDir(), ".coderabbit");
|
|
22381
22381
|
(0, import_node_fs7.mkdirSync)(dir, { recursive: true });
|
|
22382
22382
|
let file = "auth.json";
|
|
22383
22383
|
let contents = value.trim();
|
|
@@ -22397,26 +22397,26 @@ function installFailureMessage(result) {
|
|
|
22397
22397
|
return result.error ?? "CodeRabbit CLI could not be installed";
|
|
22398
22398
|
}
|
|
22399
22399
|
async function configureCoderabbit(input, deps = {}) {
|
|
22400
|
-
const
|
|
22400
|
+
const os72 = deps.os ?? createOsStrategy();
|
|
22401
22401
|
const ensureInstalled = deps.ensureInstalled ?? ensureCoderabbitInstalled;
|
|
22402
22402
|
const isLoggedIn = deps.isLoggedIn ?? defaultIsLoggedIn;
|
|
22403
22403
|
const runOAuth = deps.runOAuthLogin ?? runCoderabbitOAuthLogin;
|
|
22404
22404
|
const snapshot = deps.snapshotDir ?? (() => snapshotCredentialDir());
|
|
22405
22405
|
const capture2 = deps.captureCredential ?? ((b) => diffCapturedCredential(b));
|
|
22406
22406
|
const loginWithApiKey = deps.loginWithApiKey ?? defaultLoginWithApiKey;
|
|
22407
|
-
const home =
|
|
22408
|
-
|
|
22409
|
-
|
|
22407
|
+
const home = os72.homeDir();
|
|
22408
|
+
os72.augmentPath(
|
|
22409
|
+
os72.id === "win32" ? [
|
|
22410
22410
|
path40.join(home, ".local", "bin"),
|
|
22411
22411
|
path40.join(process.env.APPDATA ?? path40.join(home, "AppData", "Roaming"), "npm"),
|
|
22412
22412
|
path40.join(home, "scoop", "shims")
|
|
22413
22413
|
] : [path40.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"]
|
|
22414
22414
|
);
|
|
22415
|
-
const installed2 =
|
|
22415
|
+
const installed2 = os72.findInPath("coderabbit") !== null;
|
|
22416
22416
|
const base = () => ({
|
|
22417
22417
|
action: input.action,
|
|
22418
22418
|
supported: true,
|
|
22419
|
-
installed:
|
|
22419
|
+
installed: os72.findInPath("coderabbit") !== null,
|
|
22420
22420
|
loggedIn: false
|
|
22421
22421
|
});
|
|
22422
22422
|
if (input.action === "status") {
|
|
@@ -22430,7 +22430,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22430
22430
|
const key = (input.apiKey ?? "").trim();
|
|
22431
22431
|
if (!key) return { ...res2, error: "No API key provided" };
|
|
22432
22432
|
if (!res2.installed) {
|
|
22433
|
-
const inst = await ensureInstalled(
|
|
22433
|
+
const inst = await ensureInstalled(os72);
|
|
22434
22434
|
res2.installed = inst.ok;
|
|
22435
22435
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
22436
22436
|
}
|
|
@@ -22454,7 +22454,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22454
22454
|
}
|
|
22455
22455
|
if (!res2.installed) {
|
|
22456
22456
|
deps.onEvent?.({ kind: "installing" });
|
|
22457
|
-
const inst = await ensureInstalled(
|
|
22457
|
+
const inst = await ensureInstalled(os72);
|
|
22458
22458
|
res2.installed = inst.ok;
|
|
22459
22459
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
22460
22460
|
}
|
|
@@ -22471,7 +22471,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22471
22471
|
return { ...res2, loggedIn: true, linked: true };
|
|
22472
22472
|
}
|
|
22473
22473
|
try {
|
|
22474
|
-
restoreCoderabbitOauthBlob(
|
|
22474
|
+
restoreCoderabbitOauthBlob(os72, cred.credential);
|
|
22475
22475
|
} catch (err) {
|
|
22476
22476
|
return {
|
|
22477
22477
|
...res2,
|
|
@@ -22495,7 +22495,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22495
22495
|
const res2 = base();
|
|
22496
22496
|
if (!installed2) {
|
|
22497
22497
|
deps.onEvent?.({ kind: "installing" });
|
|
22498
|
-
const inst = await ensureInstalled(
|
|
22498
|
+
const inst = await ensureInstalled(os72);
|
|
22499
22499
|
res2.installed = inst.ok;
|
|
22500
22500
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
22501
22501
|
}
|
|
@@ -22535,7 +22535,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22535
22535
|
}
|
|
22536
22536
|
const res = base();
|
|
22537
22537
|
if (!res.installed) {
|
|
22538
|
-
const inst = await ensureInstalled(
|
|
22538
|
+
const inst = await ensureInstalled(os72);
|
|
22539
22539
|
res.installed = inst.ok;
|
|
22540
22540
|
if (!inst.ok) return { ...res, error: installFailureMessage(inst) };
|
|
22541
22541
|
}
|
|
@@ -22692,23 +22692,23 @@ async function reviewPullRequest(params, deps) {
|
|
|
22692
22692
|
return report;
|
|
22693
22693
|
}
|
|
22694
22694
|
function defaultRunGh(args2) {
|
|
22695
|
-
return new Promise((
|
|
22695
|
+
return new Promise((resolve14) => {
|
|
22696
22696
|
const stdout = [];
|
|
22697
22697
|
const stderr = [];
|
|
22698
22698
|
let proc;
|
|
22699
22699
|
try {
|
|
22700
22700
|
proc = (0, import_node_child_process17.spawn)("gh", args2, { stdio: ["ignore", "pipe", "pipe"] });
|
|
22701
22701
|
} catch (err) {
|
|
22702
|
-
|
|
22702
|
+
resolve14({ code: -1, stdout: "", stderr: err instanceof Error ? err.message : String(err) });
|
|
22703
22703
|
return;
|
|
22704
22704
|
}
|
|
22705
22705
|
proc.stdout?.on("data", (b) => stdout.push(b));
|
|
22706
22706
|
proc.stderr?.on("data", (b) => stderr.push(b));
|
|
22707
22707
|
proc.on("error", (err) => {
|
|
22708
|
-
|
|
22708
|
+
resolve14({ code: -1, stdout: "", stderr: err.message });
|
|
22709
22709
|
});
|
|
22710
22710
|
proc.on("close", (code) => {
|
|
22711
|
-
|
|
22711
|
+
resolve14({
|
|
22712
22712
|
code: code ?? 0,
|
|
22713
22713
|
stdout: Buffer.concat(stdout).toString("utf8"),
|
|
22714
22714
|
stderr: Buffer.concat(stderr).toString("utf8")
|
|
@@ -23028,7 +23028,7 @@ var import_node_fs11 = __toESM(require("fs"));
|
|
|
23028
23028
|
var import_node_path9 = __toESM(require("path"));
|
|
23029
23029
|
var import_yazl = require("yazl");
|
|
23030
23030
|
function buildZip(cwd, list, outFile) {
|
|
23031
|
-
return new Promise((
|
|
23031
|
+
return new Promise((resolve14, reject) => {
|
|
23032
23032
|
const zip = new import_yazl.ZipFile();
|
|
23033
23033
|
for (const f of list.files) {
|
|
23034
23034
|
const abs = import_node_path9.default.join(cwd, f.rel);
|
|
@@ -23038,7 +23038,7 @@ function buildZip(cwd, list, outFile) {
|
|
|
23038
23038
|
if (list.envExample) zip.addBuffer(Buffer.from(list.envExample), ".env.example");
|
|
23039
23039
|
const out2 = import_node_fs11.default.createWriteStream(outFile, { mode: 384 });
|
|
23040
23040
|
zip.outputStream.pipe(out2);
|
|
23041
|
-
out2.on("close", () =>
|
|
23041
|
+
out2.on("close", () => resolve14(import_node_fs11.default.statSync(outFile).size));
|
|
23042
23042
|
out2.on("error", reject);
|
|
23043
23043
|
zip.outputStream.on("error", reject);
|
|
23044
23044
|
zip.end();
|
|
@@ -23230,12 +23230,12 @@ async function isExecutableBinary(p2) {
|
|
|
23230
23230
|
}
|
|
23231
23231
|
}
|
|
23232
23232
|
function extractTgz(tgzPath, destDir) {
|
|
23233
|
-
return new Promise((
|
|
23233
|
+
return new Promise((resolve14, reject) => {
|
|
23234
23234
|
const child = (0, import_child_process14.spawn)("tar", ["-xzf", tgzPath, "-C", destDir], { stdio: "ignore" });
|
|
23235
23235
|
child.on("error", (err) => reject(err));
|
|
23236
23236
|
child.on(
|
|
23237
23237
|
"exit",
|
|
23238
|
-
(code) => code === 0 ?
|
|
23238
|
+
(code) => code === 0 ? resolve14() : reject(new Error(`tar exited with code ${code} while extracting cloudflared`))
|
|
23239
23239
|
);
|
|
23240
23240
|
});
|
|
23241
23241
|
}
|
|
@@ -23816,17 +23816,17 @@ function expoGoDeepLink(publicUrl) {
|
|
|
23816
23816
|
return `exps://${new URL(publicUrl).host}`;
|
|
23817
23817
|
}
|
|
23818
23818
|
function isExpoManifestServed(port, host2 = "127.0.0.1") {
|
|
23819
|
-
return new Promise((
|
|
23819
|
+
return new Promise((resolve14) => {
|
|
23820
23820
|
const req = http6.get(
|
|
23821
23821
|
{ host: host2, port, path: "/", headers: { "expo-platform": "ios" }, timeout: 1500 },
|
|
23822
23822
|
(res) => {
|
|
23823
23823
|
const ok = res.statusCode !== void 0 && res.statusCode >= 200 && res.statusCode < 300;
|
|
23824
23824
|
res.resume();
|
|
23825
|
-
|
|
23825
|
+
resolve14(ok);
|
|
23826
23826
|
}
|
|
23827
23827
|
);
|
|
23828
23828
|
req.once("timeout", () => req.destroy());
|
|
23829
|
-
req.once("error", () =>
|
|
23829
|
+
req.once("error", () => resolve14(false));
|
|
23830
23830
|
});
|
|
23831
23831
|
}
|
|
23832
23832
|
async function waitForExpoManifest(port, opts) {
|
|
@@ -23974,12 +23974,12 @@ function describeDetectionFailure(raw) {
|
|
|
23974
23974
|
// src/services/preview/port-ready.ts
|
|
23975
23975
|
var net = __toESM(require("net"));
|
|
23976
23976
|
function isPortListening(port, host2 = "127.0.0.1") {
|
|
23977
|
-
return new Promise((
|
|
23977
|
+
return new Promise((resolve14) => {
|
|
23978
23978
|
const socket = new net.Socket();
|
|
23979
23979
|
const done = (result) => {
|
|
23980
23980
|
socket.removeAllListeners();
|
|
23981
23981
|
socket.destroy();
|
|
23982
|
-
|
|
23982
|
+
resolve14(result);
|
|
23983
23983
|
};
|
|
23984
23984
|
socket.setTimeout(1e3);
|
|
23985
23985
|
socket.once("connect", () => done(true));
|
|
@@ -24017,14 +24017,14 @@ const { PGLiteSocketServer } = require('@electric-sql/pglite-socket');
|
|
|
24017
24017
|
})().catch((e) => { console.error(String(e && e.message)); process.exit(1); });
|
|
24018
24018
|
`;
|
|
24019
24019
|
function isListening(port) {
|
|
24020
|
-
return new Promise((
|
|
24020
|
+
return new Promise((resolve14) => {
|
|
24021
24021
|
const s = net2.connect({ host: "127.0.0.1", port }, () => {
|
|
24022
24022
|
s.destroy();
|
|
24023
|
-
|
|
24024
|
-
}).on("error", () =>
|
|
24023
|
+
resolve14(true);
|
|
24024
|
+
}).on("error", () => resolve14(false));
|
|
24025
24025
|
s.setTimeout(1e3, () => {
|
|
24026
24026
|
s.destroy();
|
|
24027
|
-
|
|
24027
|
+
resolve14(false);
|
|
24028
24028
|
});
|
|
24029
24029
|
});
|
|
24030
24030
|
}
|
|
@@ -24072,7 +24072,7 @@ function stopChild(child) {
|
|
|
24072
24072
|
// src/services/preview/run-setup.ts
|
|
24073
24073
|
var import_child_process18 = require("child_process");
|
|
24074
24074
|
function runSetupCommand(cmd, args2, cwd, env, opts) {
|
|
24075
|
-
return new Promise((
|
|
24075
|
+
return new Promise((resolve14) => {
|
|
24076
24076
|
const child = (0, import_child_process18.spawn)(cmd, args2, {
|
|
24077
24077
|
cwd,
|
|
24078
24078
|
env: { ...process.env, ...env ?? {} },
|
|
@@ -24092,20 +24092,20 @@ function runSetupCommand(cmd, args2, cwd, env, opts) {
|
|
|
24092
24092
|
settled = true;
|
|
24093
24093
|
log.info("preview", `${tag}: timed out after ${opts.timeoutMs}ms \u2014 killing`);
|
|
24094
24094
|
killQuiet(child);
|
|
24095
|
-
|
|
24095
|
+
resolve14({ status: "timeout", code: null });
|
|
24096
24096
|
}, opts.timeoutMs);
|
|
24097
24097
|
child.once("exit", (code) => {
|
|
24098
24098
|
if (settled) return;
|
|
24099
24099
|
settled = true;
|
|
24100
24100
|
clearTimeout(timer);
|
|
24101
|
-
if (code === 0)
|
|
24102
|
-
else
|
|
24101
|
+
if (code === 0) resolve14({ status: "ok", code: 0 });
|
|
24102
|
+
else resolve14({ status: "failed", code });
|
|
24103
24103
|
});
|
|
24104
24104
|
child.once("error", () => {
|
|
24105
24105
|
if (settled) return;
|
|
24106
24106
|
settled = true;
|
|
24107
24107
|
clearTimeout(timer);
|
|
24108
|
-
|
|
24108
|
+
resolve14({ status: "failed", code: null });
|
|
24109
24109
|
});
|
|
24110
24110
|
});
|
|
24111
24111
|
}
|
|
@@ -24561,23 +24561,23 @@ async function awaitTunnelRegistered(candidate, hostname3, deadlineMs) {
|
|
|
24561
24561
|
ac.signal.addEventListener("abort", detach, { once: true });
|
|
24562
24562
|
};
|
|
24563
24563
|
try {
|
|
24564
|
-
return await new Promise((
|
|
24564
|
+
return await new Promise((resolve14) => {
|
|
24565
24565
|
const onChunk = (chunk) => {
|
|
24566
24566
|
const s = chunk.toString();
|
|
24567
24567
|
if (!url2) url2 = parseCloudflaredUrl(s);
|
|
24568
24568
|
if (TUNNEL_REGISTERED_RE.test(s)) registered = true;
|
|
24569
24569
|
const trimmed = s.replace(/\n+$/g, "");
|
|
24570
24570
|
if (trimmed.length > 0) log.info("preview", `cloudflared: ${trimmed}`);
|
|
24571
|
-
if (url2 && registered)
|
|
24571
|
+
if (url2 && registered) resolve14({ kind: "registered", url: url2 });
|
|
24572
24572
|
};
|
|
24573
24573
|
const onExit = (code) => {
|
|
24574
|
-
|
|
24574
|
+
resolve14({ kind: "exited", sawUrl: url2 != null, code });
|
|
24575
24575
|
};
|
|
24576
24576
|
const { stdout, stderr } = candidate;
|
|
24577
24577
|
if (stdout) scoped(() => stdout.on("data", onChunk), () => stdout.off("data", onChunk));
|
|
24578
24578
|
if (stderr) scoped(() => stderr.on("data", onChunk), () => stderr.off("data", onChunk));
|
|
24579
24579
|
scoped(() => candidate.on("exit", onExit), () => candidate.off("exit", onExit));
|
|
24580
|
-
timer = setTimeout(() =>
|
|
24580
|
+
timer = setTimeout(() => resolve14({ kind: "timeout", sawUrl: url2 != null }), deadlineMs);
|
|
24581
24581
|
});
|
|
24582
24582
|
} finally {
|
|
24583
24583
|
ac.abort();
|
|
@@ -24600,7 +24600,7 @@ function verdictFor(res) {
|
|
|
24600
24600
|
}
|
|
24601
24601
|
return { adopt: true };
|
|
24602
24602
|
}
|
|
24603
|
-
var probePort = (port) => new Promise((
|
|
24603
|
+
var probePort = (port) => new Promise((resolve14) => {
|
|
24604
24604
|
const req = http7.get(
|
|
24605
24605
|
{ host: "127.0.0.1", port, path: "/", timeout: PROBE_TIMEOUT_MS },
|
|
24606
24606
|
(res) => {
|
|
@@ -24611,16 +24611,16 @@ var probePort = (port) => new Promise((resolve12) => {
|
|
|
24611
24611
|
});
|
|
24612
24612
|
res.on(
|
|
24613
24613
|
"end",
|
|
24614
|
-
() =>
|
|
24614
|
+
() => resolve14({ contentType: res.headers["content-type"], bodyStart: body })
|
|
24615
24615
|
);
|
|
24616
|
-
res.on("error", () =>
|
|
24616
|
+
res.on("error", () => resolve14(null));
|
|
24617
24617
|
}
|
|
24618
24618
|
);
|
|
24619
24619
|
req.on("timeout", () => {
|
|
24620
24620
|
req.destroy();
|
|
24621
|
-
|
|
24621
|
+
resolve14(null);
|
|
24622
24622
|
});
|
|
24623
|
-
req.on("error", () =>
|
|
24623
|
+
req.on("error", () => resolve14(null));
|
|
24624
24624
|
});
|
|
24625
24625
|
async function canAdoptPort(port, probe = probePort) {
|
|
24626
24626
|
try {
|
|
@@ -26035,18 +26035,18 @@ async function startInspectorProxy(opts) {
|
|
|
26035
26035
|
clientSocket.on("error", drop2);
|
|
26036
26036
|
clientSocket.on("close", drop2);
|
|
26037
26037
|
});
|
|
26038
|
-
await new Promise((
|
|
26038
|
+
await new Promise((resolve14, reject) => {
|
|
26039
26039
|
server.once("error", reject);
|
|
26040
|
-
server.listen(0, "127.0.0.1", () =>
|
|
26040
|
+
server.listen(0, "127.0.0.1", () => resolve14());
|
|
26041
26041
|
});
|
|
26042
26042
|
const port = server.address().port;
|
|
26043
26043
|
return {
|
|
26044
26044
|
port,
|
|
26045
|
-
close: () => new Promise((
|
|
26045
|
+
close: () => new Promise((resolve14) => {
|
|
26046
26046
|
for (const socket of upgraded) socket.destroy();
|
|
26047
26047
|
upgraded.clear();
|
|
26048
26048
|
server.closeAllConnections?.();
|
|
26049
|
-
server.close(() =>
|
|
26049
|
+
server.close(() => resolve14());
|
|
26050
26050
|
})
|
|
26051
26051
|
};
|
|
26052
26052
|
}
|
|
@@ -27130,12 +27130,12 @@ var _spawnSeam = {
|
|
|
27130
27130
|
run: _defaultSpawn
|
|
27131
27131
|
};
|
|
27132
27132
|
function _defaultSpawn(binaryPath, args2, opts) {
|
|
27133
|
-
return new Promise((
|
|
27133
|
+
return new Promise((resolve14) => {
|
|
27134
27134
|
let proc;
|
|
27135
27135
|
try {
|
|
27136
27136
|
proc = (0, import_child_process21.spawn)(binaryPath, args2, { cwd: opts.cwd, env: opts.env });
|
|
27137
27137
|
} catch (err) {
|
|
27138
|
-
|
|
27138
|
+
resolve14({ code: -1, stdout: "", stderr: err.message });
|
|
27139
27139
|
return;
|
|
27140
27140
|
}
|
|
27141
27141
|
let stdout = "";
|
|
@@ -27146,8 +27146,8 @@ function _defaultSpawn(binaryPath, args2, opts) {
|
|
|
27146
27146
|
proc.stderr?.on("data", (c2) => {
|
|
27147
27147
|
stderr += c2.toString();
|
|
27148
27148
|
});
|
|
27149
|
-
proc.on("error", (err) =>
|
|
27150
|
-
proc.on("close", (code) =>
|
|
27149
|
+
proc.on("error", (err) => resolve14({ code: -1, stdout, stderr: err.message }));
|
|
27150
|
+
proc.on("close", (code) => resolve14({ code: code ?? -1, stdout, stderr }));
|
|
27151
27151
|
});
|
|
27152
27152
|
}
|
|
27153
27153
|
var _adapterSeam = {
|
|
@@ -27324,22 +27324,22 @@ var _installSpawnSeam = {
|
|
|
27324
27324
|
run: _defaultInstallSpawn
|
|
27325
27325
|
};
|
|
27326
27326
|
function _defaultInstallSpawn(strategy) {
|
|
27327
|
-
return new Promise((
|
|
27327
|
+
return new Promise((resolve14) => {
|
|
27328
27328
|
let proc;
|
|
27329
27329
|
try {
|
|
27330
27330
|
proc = (0, import_child_process22.spawn)(strategy.command, strategy.args, { env: process.env });
|
|
27331
27331
|
} catch (err) {
|
|
27332
|
-
|
|
27332
|
+
resolve14({ ok: false, code: -1, stderr: err.message });
|
|
27333
27333
|
return;
|
|
27334
27334
|
}
|
|
27335
27335
|
let stderr = "";
|
|
27336
27336
|
proc.stderr?.on("data", (c2) => {
|
|
27337
27337
|
stderr += c2.toString();
|
|
27338
27338
|
});
|
|
27339
|
-
proc.on("error", (err) =>
|
|
27339
|
+
proc.on("error", (err) => resolve14({ ok: false, code: -1, stderr: err.message }));
|
|
27340
27340
|
proc.on(
|
|
27341
27341
|
"close",
|
|
27342
|
-
(code) =>
|
|
27342
|
+
(code) => resolve14({ ok: code === 0, code: code ?? -1, stderr })
|
|
27343
27343
|
);
|
|
27344
27344
|
});
|
|
27345
27345
|
}
|
|
@@ -27400,11 +27400,11 @@ function resolveDoltInstallStrategy(platform3) {
|
|
|
27400
27400
|
}
|
|
27401
27401
|
var DOLT_RELEASE_BASE = "https://github.com/dolthub/dolt/releases/latest/download";
|
|
27402
27402
|
function doltPlatformTuple(platform3, arch2) {
|
|
27403
|
-
const
|
|
27403
|
+
const os72 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
|
|
27404
27404
|
const a = arch2 === "x64" ? "amd64" : arch2 === "arm64" ? "arm64" : null;
|
|
27405
27405
|
if (!a) return null;
|
|
27406
|
-
if (
|
|
27407
|
-
return `${
|
|
27406
|
+
if (os72 === "windows" && a !== "amd64") return null;
|
|
27407
|
+
return `${os72}-${a}`;
|
|
27408
27408
|
}
|
|
27409
27409
|
function resolveDoltTarballStrategy(targetDir, platform3, arch2) {
|
|
27410
27410
|
const tuple = doltPlatformTuple(platform3, arch2);
|
|
@@ -27508,14 +27508,14 @@ var _doltInstallSpawnSeam = {
|
|
|
27508
27508
|
};
|
|
27509
27509
|
var DOLT_INSTALL_TIMEOUT_MS = 12e4;
|
|
27510
27510
|
function _defaultDoltInstallSpawn(strategy) {
|
|
27511
|
-
return new Promise((
|
|
27511
|
+
return new Promise((resolve14) => {
|
|
27512
27512
|
let settled = false;
|
|
27513
27513
|
let timer;
|
|
27514
27514
|
const finish = (r) => {
|
|
27515
27515
|
if (settled) return;
|
|
27516
27516
|
settled = true;
|
|
27517
27517
|
if (timer) clearTimeout(timer);
|
|
27518
|
-
|
|
27518
|
+
resolve14(r);
|
|
27519
27519
|
};
|
|
27520
27520
|
let proc;
|
|
27521
27521
|
try {
|
|
@@ -29102,7 +29102,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
29102
29102
|
});
|
|
29103
29103
|
const token = ctx.pluginAuthToken;
|
|
29104
29104
|
void (async () => {
|
|
29105
|
-
const
|
|
29105
|
+
const os72 = createOsStrategy();
|
|
29106
29106
|
try {
|
|
29107
29107
|
const report = await reviewPullRequest(
|
|
29108
29108
|
{
|
|
@@ -29111,7 +29111,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
29111
29111
|
baseBranch: parsed.baseBranch
|
|
29112
29112
|
},
|
|
29113
29113
|
{
|
|
29114
|
-
runReview: (input) => new CoderabbitRuntimeStrategy(
|
|
29114
|
+
runReview: (input) => new CoderabbitRuntimeStrategy(os72).runOneShot(input),
|
|
29115
29115
|
runGh: (args2) => defaultRunGh(args2),
|
|
29116
29116
|
postReport: async (r) => {
|
|
29117
29117
|
if (!token) return;
|
|
@@ -29256,13 +29256,13 @@ function resolveGlobalNodeModulesDir(opts) {
|
|
|
29256
29256
|
var STALE_STAGING_AGE_MS = CLI_UPDATE_INSTALL_TIMEOUT_MS;
|
|
29257
29257
|
function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
29258
29258
|
if (!nodeModulesDir) return 0;
|
|
29259
|
-
const
|
|
29260
|
-
const
|
|
29261
|
-
const
|
|
29259
|
+
const readdirSync18 = deps?.readdirSync ?? fs63.readdirSync;
|
|
29260
|
+
const statSync17 = deps?.statSync ?? fs63.statSync;
|
|
29261
|
+
const rmSync14 = deps?.rmSync ?? fs63.rmSync;
|
|
29262
29262
|
let removed = 0;
|
|
29263
29263
|
let entries2;
|
|
29264
29264
|
try {
|
|
29265
|
-
entries2 =
|
|
29265
|
+
entries2 = readdirSync18(nodeModulesDir);
|
|
29266
29266
|
} catch {
|
|
29267
29267
|
return 0;
|
|
29268
29268
|
}
|
|
@@ -29270,9 +29270,9 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
|
29270
29270
|
if (!/^\.codeam-cli-/.test(name)) continue;
|
|
29271
29271
|
const full = path72.join(nodeModulesDir, name);
|
|
29272
29272
|
try {
|
|
29273
|
-
const st3 =
|
|
29273
|
+
const st3 = statSync17(full);
|
|
29274
29274
|
if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
|
|
29275
|
-
|
|
29275
|
+
rmSync14(full, { recursive: true, force: true });
|
|
29276
29276
|
removed++;
|
|
29277
29277
|
} catch {
|
|
29278
29278
|
}
|
|
@@ -29293,16 +29293,16 @@ async function runNpmInstallLatest() {
|
|
|
29293
29293
|
const invocation = buildNpmInstallInvocation({ sudo: useSudo });
|
|
29294
29294
|
const useShell = process.platform === "win32";
|
|
29295
29295
|
const command2 = useShell && invocation.command.includes(" ") ? `"${invocation.command}"` : invocation.command;
|
|
29296
|
-
const result = await new Promise((
|
|
29296
|
+
const result = await new Promise((resolve14) => {
|
|
29297
29297
|
(0, import_child_process25.execFile)(
|
|
29298
29298
|
command2,
|
|
29299
29299
|
invocation.args,
|
|
29300
29300
|
{ timeout: CLI_UPDATE_INSTALL_TIMEOUT_MS, shell: useShell },
|
|
29301
29301
|
(err, _stdout, stderr) => {
|
|
29302
29302
|
if (!err) {
|
|
29303
|
-
|
|
29303
|
+
resolve14({ ok: true });
|
|
29304
29304
|
} else {
|
|
29305
|
-
|
|
29305
|
+
resolve14({ ok: false, error: (stderr || err.message).slice(0, 300) });
|
|
29306
29306
|
}
|
|
29307
29307
|
}
|
|
29308
29308
|
);
|
|
@@ -29655,8 +29655,8 @@ async function runDetectOneShot(generate, timeoutMs = PREVIEW_DETECT_TIMEOUT_MS)
|
|
|
29655
29655
|
};
|
|
29656
29656
|
const onFailedOutput = (stdout) => onStderr(`
|
|
29657
29657
|
${stdout}`);
|
|
29658
|
-
const deadline = new Promise((
|
|
29659
|
-
timer = setTimeout(() =>
|
|
29658
|
+
const deadline = new Promise((resolve14) => {
|
|
29659
|
+
timer = setTimeout(() => resolve14({ raw: null, timedOut: true, stderr }), timeoutMs);
|
|
29660
29660
|
timer.unref?.();
|
|
29661
29661
|
});
|
|
29662
29662
|
const oneShot = generate(PREVIEW_DETECT_PROMPT, { timeoutMs, onStderr, onFailedOutput }).then(
|
|
@@ -30124,7 +30124,7 @@ function buildKeepAlive(ctx) {
|
|
|
30124
30124
|
let timer = null;
|
|
30125
30125
|
async function setIdleTimeout(minutes) {
|
|
30126
30126
|
if (!ctx.inCodespace || !ctx.codespaceName) return;
|
|
30127
|
-
await new Promise((
|
|
30127
|
+
await new Promise((resolve14) => {
|
|
30128
30128
|
const proc = (0, import_child_process26.spawn)(
|
|
30129
30129
|
"gh",
|
|
30130
30130
|
[
|
|
@@ -30138,8 +30138,8 @@ function buildKeepAlive(ctx) {
|
|
|
30138
30138
|
{ stdio: "ignore", detached: true }
|
|
30139
30139
|
);
|
|
30140
30140
|
proc.unref();
|
|
30141
|
-
proc.on("exit", () =>
|
|
30142
|
-
proc.on("error", () =>
|
|
30141
|
+
proc.on("exit", () => resolve14());
|
|
30142
|
+
proc.on("error", () => resolve14());
|
|
30143
30143
|
});
|
|
30144
30144
|
}
|
|
30145
30145
|
return {
|
|
@@ -30391,11 +30391,11 @@ function resolveTokenValue(args2) {
|
|
|
30391
30391
|
}
|
|
30392
30392
|
const fileFlag = args2.find((a) => a.startsWith("--token-file="));
|
|
30393
30393
|
if (fileFlag) {
|
|
30394
|
-
const
|
|
30394
|
+
const path112 = fileFlag.slice("--token-file=".length);
|
|
30395
30395
|
try {
|
|
30396
|
-
const content = fs64.readFileSync(
|
|
30397
|
-
if (content.length === 0) fail(`--token-file ${
|
|
30398
|
-
rmIfExistsQuiet(
|
|
30396
|
+
const content = fs64.readFileSync(path112, "utf8").trim();
|
|
30397
|
+
if (content.length === 0) fail(`--token-file ${path112} is empty`);
|
|
30398
|
+
rmIfExistsQuiet(path112);
|
|
30399
30399
|
return content;
|
|
30400
30400
|
} catch (err) {
|
|
30401
30401
|
fail(`Could not read --token-file: ${err.message}`);
|
|
@@ -31096,10 +31096,10 @@ function augmentKimiPath() {
|
|
|
31096
31096
|
}
|
|
31097
31097
|
var augmentPath2 = augmentKimiPath;
|
|
31098
31098
|
async function runInstaller2() {
|
|
31099
|
-
return new Promise((
|
|
31099
|
+
return new Promise((resolve14) => {
|
|
31100
31100
|
const proc = (0, import_node_child_process25.spawn)("sh", ["-c", `curl -fsSL ${INSTALL_URL2} | bash`], { stdio: "inherit" });
|
|
31101
|
-
proc.on("close", (code) =>
|
|
31102
|
-
proc.on("error", () =>
|
|
31101
|
+
proc.on("close", (code) => resolve14(code === 0));
|
|
31102
|
+
proc.on("error", () => resolve14(false));
|
|
31103
31103
|
});
|
|
31104
31104
|
}
|
|
31105
31105
|
async function ensureKimiInstalled() {
|
|
@@ -31149,10 +31149,10 @@ function augmentOpencodePath() {
|
|
|
31149
31149
|
}
|
|
31150
31150
|
var augmentPath3 = augmentOpencodePath;
|
|
31151
31151
|
async function runInstaller3() {
|
|
31152
|
-
return new Promise((
|
|
31152
|
+
return new Promise((resolve14) => {
|
|
31153
31153
|
const proc = (0, import_node_child_process26.spawn)("sh", ["-c", `curl -fsSL ${INSTALL_URL3} | bash`], { stdio: "inherit" });
|
|
31154
|
-
proc.on("close", (code) =>
|
|
31155
|
-
proc.on("error", () =>
|
|
31154
|
+
proc.on("close", (code) => resolve14(code === 0));
|
|
31155
|
+
proc.on("error", () => resolve14(false));
|
|
31156
31156
|
});
|
|
31157
31157
|
}
|
|
31158
31158
|
async function ensureOpencodeInstalled() {
|
|
@@ -31360,11 +31360,11 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
|
|
|
31360
31360
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_ADAPTER_RETRY_TIMEOUT_MS;
|
|
31361
31361
|
const pollMs = opts.pollMs ?? DEFAULT_ADAPTER_RETRY_POLL_MS;
|
|
31362
31362
|
const now = opts.now ?? Date.now;
|
|
31363
|
-
const sleep5 = opts.sleep ?? ((ms) => new Promise((
|
|
31364
|
-
const
|
|
31363
|
+
const sleep5 = opts.sleep ?? ((ms) => new Promise((resolve15) => setTimeout(resolve15, ms)));
|
|
31364
|
+
const resolve14 = opts.resolve ?? getAcpAdapter;
|
|
31365
31365
|
const attempt = () => {
|
|
31366
31366
|
try {
|
|
31367
|
-
return
|
|
31367
|
+
return resolve14(agent);
|
|
31368
31368
|
} catch {
|
|
31369
31369
|
return null;
|
|
31370
31370
|
}
|
|
@@ -31519,7 +31519,7 @@ function parseJsonl(filePath) {
|
|
|
31519
31519
|
return messages;
|
|
31520
31520
|
}
|
|
31521
31521
|
function postWithStatus(endpoint, body, pluginAuthToken) {
|
|
31522
|
-
return new Promise((
|
|
31522
|
+
return new Promise((resolve14) => {
|
|
31523
31523
|
const payload = JSON.stringify(body);
|
|
31524
31524
|
const u2 = new URL(`${API_BASE7}${endpoint}`);
|
|
31525
31525
|
const transport = u2.protocol === "https:" ? https6 : http10;
|
|
@@ -31550,17 +31550,17 @@ function postWithStatus(endpoint, body, pluginAuthToken) {
|
|
|
31550
31550
|
const ra = Number(res.headers["retry-after"]);
|
|
31551
31551
|
retryAfterMs = Number.isFinite(ra) && ra > 0 ? ra * 1e3 : 2e4;
|
|
31552
31552
|
}
|
|
31553
|
-
|
|
31553
|
+
resolve14({ ok, status: status2, retryAfterMs });
|
|
31554
31554
|
}
|
|
31555
31555
|
);
|
|
31556
31556
|
req.on("error", (err) => {
|
|
31557
31557
|
log.warn("history:post", `${endpoint} network error`, err);
|
|
31558
|
-
|
|
31558
|
+
resolve14({ ok: false, status: null, retryAfterMs: null });
|
|
31559
31559
|
});
|
|
31560
31560
|
req.on("timeout", () => {
|
|
31561
31561
|
log.warn("history:post", `${endpoint} timeout after 15s`);
|
|
31562
31562
|
req.destroy();
|
|
31563
|
-
|
|
31563
|
+
resolve14({ ok: false, status: null, retryAfterMs: null });
|
|
31564
31564
|
});
|
|
31565
31565
|
req.write(payload);
|
|
31566
31566
|
req.end();
|
|
@@ -34134,12 +34134,12 @@ var Connection = class {
|
|
|
34134
34134
|
const id = this.nextRequestId++;
|
|
34135
34135
|
let cancel = () => {
|
|
34136
34136
|
};
|
|
34137
|
-
const responsePromise = new Promise((
|
|
34137
|
+
const responsePromise = new Promise((resolve14, reject) => {
|
|
34138
34138
|
const pendingResponse = {
|
|
34139
34139
|
resolve: (response) => {
|
|
34140
34140
|
try {
|
|
34141
34141
|
const value = mapResponse ? mapResponse(response) : response;
|
|
34142
|
-
|
|
34142
|
+
resolve14(value);
|
|
34143
34143
|
} catch (error) {
|
|
34144
34144
|
reject(error);
|
|
34145
34145
|
}
|
|
@@ -34217,8 +34217,8 @@ var Connection = class {
|
|
|
34217
34217
|
initialize(stream, handlers2) {
|
|
34218
34218
|
this.stream = stream;
|
|
34219
34219
|
this.staticHandlers = handlers2;
|
|
34220
|
-
this.closedPromise = new Promise((
|
|
34221
|
-
this.abortController.signal.addEventListener("abort", () =>
|
|
34220
|
+
this.closedPromise = new Promise((resolve14) => {
|
|
34221
|
+
this.abortController.signal.addEventListener("abort", () => resolve14());
|
|
34222
34222
|
});
|
|
34223
34223
|
void this.receive();
|
|
34224
34224
|
}
|
|
@@ -35006,8 +35006,8 @@ var AsyncQueue = class {
|
|
|
35006
35006
|
if (this.failed) {
|
|
35007
35007
|
return Promise.reject(this.failure);
|
|
35008
35008
|
}
|
|
35009
|
-
return new Promise((
|
|
35010
|
-
this.waiters.push({ resolve:
|
|
35009
|
+
return new Promise((resolve14, reject) => {
|
|
35010
|
+
this.waiters.push({ resolve: resolve14, reject });
|
|
35011
35011
|
});
|
|
35012
35012
|
}
|
|
35013
35013
|
};
|
|
@@ -36699,7 +36699,7 @@ var AcpClient = class {
|
|
|
36699
36699
|
this.pendingToolCalls.clear();
|
|
36700
36700
|
try {
|
|
36701
36701
|
const result = await Promise.race([send, idle.promise]);
|
|
36702
|
-
await new Promise((
|
|
36702
|
+
await new Promise((resolve14) => setImmediate(resolve14));
|
|
36703
36703
|
log.info(
|
|
36704
36704
|
"acpClient",
|
|
36705
36705
|
`prompt \u2190 ok stopReason=${result.stopReason ?? "?"} elapsedMs=${Date.now() - t0}`
|
|
@@ -36915,8 +36915,8 @@ var AcpClient = class {
|
|
|
36915
36915
|
if (!this.connection || !this.sessionId) return "deferred";
|
|
36916
36916
|
this.mcpReprovisionPending = servers;
|
|
36917
36917
|
if (this.mcpDebounceTimer) clearTimeout(this.mcpDebounceTimer);
|
|
36918
|
-
const settled = new Promise((
|
|
36919
|
-
this.mcpDebounceWaiters.push(
|
|
36918
|
+
const settled = new Promise((resolve14) => {
|
|
36919
|
+
this.mcpDebounceWaiters.push(resolve14);
|
|
36920
36920
|
});
|
|
36921
36921
|
this.mcpDebounceTimer = setTimeout(() => {
|
|
36922
36922
|
this.mcpDebounceTimer = null;
|
|
@@ -37160,15 +37160,15 @@ var AcpClient = class {
|
|
|
37160
37160
|
} else {
|
|
37161
37161
|
child.kill("SIGTERM");
|
|
37162
37162
|
}
|
|
37163
|
-
const grace = new Promise((
|
|
37163
|
+
const grace = new Promise((resolve14) => {
|
|
37164
37164
|
const t2 = setTimeout(() => {
|
|
37165
37165
|
if (process.platform !== "win32" && pid) killQuiet(-pid, "SIGKILL");
|
|
37166
37166
|
else killQuiet(child, "SIGKILL");
|
|
37167
|
-
|
|
37167
|
+
resolve14();
|
|
37168
37168
|
}, 2e3);
|
|
37169
37169
|
child.once("exit", () => {
|
|
37170
37170
|
clearTimeout(t2);
|
|
37171
|
-
|
|
37171
|
+
resolve14();
|
|
37172
37172
|
});
|
|
37173
37173
|
});
|
|
37174
37174
|
await grace;
|
|
@@ -37397,7 +37397,7 @@ var os50 = __toESM(require("os"));
|
|
|
37397
37397
|
function runAgentInstallScript(script, opts = {}) {
|
|
37398
37398
|
const timeoutMs = opts.timeoutMs ?? 18e4;
|
|
37399
37399
|
const scope = opts.logScope ?? "agent-install";
|
|
37400
|
-
return new Promise((
|
|
37400
|
+
return new Promise((resolve14) => {
|
|
37401
37401
|
const home = process.env.HOME || os50.homedir();
|
|
37402
37402
|
const child = (0, import_child_process27.spawn)("sh", ["-c", script], {
|
|
37403
37403
|
env: { ...process.env, HOME: home },
|
|
@@ -37413,7 +37413,7 @@ function runAgentInstallScript(script, opts = {}) {
|
|
|
37413
37413
|
const done = (result) => {
|
|
37414
37414
|
if (settled) return;
|
|
37415
37415
|
settled = true;
|
|
37416
|
-
|
|
37416
|
+
resolve14(result);
|
|
37417
37417
|
};
|
|
37418
37418
|
const timer = setTimeout(() => {
|
|
37419
37419
|
log.warn(scope, `agent install timed out (${Math.round(timeoutMs / 1e3)}s)`);
|
|
@@ -38026,7 +38026,7 @@ var _transport4 = {
|
|
|
38026
38026
|
get: _get
|
|
38027
38027
|
};
|
|
38028
38028
|
function _post3(url2, headers, payload) {
|
|
38029
|
-
return new Promise((
|
|
38029
|
+
return new Promise((resolve14, reject) => {
|
|
38030
38030
|
let settled = false;
|
|
38031
38031
|
const u2 = new URL(url2);
|
|
38032
38032
|
const lib = u2.protocol === "https:" ? https7 : http11;
|
|
@@ -38051,7 +38051,7 @@ function _post3(url2, headers, payload) {
|
|
|
38051
38051
|
res.on("end", () => {
|
|
38052
38052
|
if (settled) return;
|
|
38053
38053
|
settled = true;
|
|
38054
|
-
|
|
38054
|
+
resolve14({ statusCode: res.statusCode ?? 0, body });
|
|
38055
38055
|
});
|
|
38056
38056
|
}
|
|
38057
38057
|
);
|
|
@@ -38068,7 +38068,7 @@ function _post3(url2, headers, payload) {
|
|
|
38068
38068
|
});
|
|
38069
38069
|
}
|
|
38070
38070
|
function _get(url2, headers) {
|
|
38071
|
-
return new Promise((
|
|
38071
|
+
return new Promise((resolve14, reject) => {
|
|
38072
38072
|
let settled = false;
|
|
38073
38073
|
const u2 = new URL(url2);
|
|
38074
38074
|
const lib = u2.protocol === "https:" ? https7 : http11;
|
|
@@ -38092,7 +38092,7 @@ function _get(url2, headers) {
|
|
|
38092
38092
|
res.on("end", () => {
|
|
38093
38093
|
if (settled) return;
|
|
38094
38094
|
settled = true;
|
|
38095
|
-
|
|
38095
|
+
resolve14({ statusCode: res.statusCode ?? 0, body });
|
|
38096
38096
|
});
|
|
38097
38097
|
}
|
|
38098
38098
|
);
|
|
@@ -39323,12 +39323,12 @@ function runGit3(cwd, args2) {
|
|
|
39323
39323
|
return _runGitImpl2.run(cwd, args2);
|
|
39324
39324
|
}
|
|
39325
39325
|
function defaultRunGit(cwd, args2) {
|
|
39326
|
-
return new Promise((
|
|
39326
|
+
return new Promise((resolve14) => {
|
|
39327
39327
|
let proc;
|
|
39328
39328
|
try {
|
|
39329
39329
|
proc = (0, import_child_process29.spawn)("git", args2, { cwd, env: process.env });
|
|
39330
39330
|
} catch {
|
|
39331
|
-
|
|
39331
|
+
resolve14(null);
|
|
39332
39332
|
return;
|
|
39333
39333
|
}
|
|
39334
39334
|
let stdout = "";
|
|
@@ -39339,22 +39339,22 @@ function defaultRunGit(cwd, args2) {
|
|
|
39339
39339
|
proc.stderr?.on("data", (c2) => {
|
|
39340
39340
|
stderr += c2.toString();
|
|
39341
39341
|
});
|
|
39342
|
-
proc.on("error", () =>
|
|
39342
|
+
proc.on("error", () => resolve14(null));
|
|
39343
39343
|
proc.on("close", (code) => {
|
|
39344
39344
|
if (code === 0) {
|
|
39345
|
-
|
|
39345
|
+
resolve14(stdout);
|
|
39346
39346
|
} else {
|
|
39347
39347
|
log.trace(
|
|
39348
39348
|
"turnFiles",
|
|
39349
39349
|
`git ${args2.join(" ")} exited ${code} stderr=${stderr.slice(0, 200)}`
|
|
39350
39350
|
);
|
|
39351
|
-
|
|
39351
|
+
resolve14(null);
|
|
39352
39352
|
}
|
|
39353
39353
|
});
|
|
39354
39354
|
});
|
|
39355
39355
|
}
|
|
39356
39356
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
39357
|
-
const
|
|
39357
|
+
const fs97 = await import("fs/promises");
|
|
39358
39358
|
const out2 = [];
|
|
39359
39359
|
await walk2(workingDir, 0);
|
|
39360
39360
|
return out2;
|
|
@@ -39362,7 +39362,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
39362
39362
|
if (depth2 > maxDepth) return;
|
|
39363
39363
|
let entries2 = [];
|
|
39364
39364
|
try {
|
|
39365
|
-
const dirents = await
|
|
39365
|
+
const dirents = await fs97.readdir(dir, { withFileTypes: true });
|
|
39366
39366
|
entries2 = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
39367
39367
|
} catch {
|
|
39368
39368
|
return;
|
|
@@ -39765,25 +39765,25 @@ function baselineKey(entry) {
|
|
|
39765
39765
|
|
|
39766
39766
|
// src/agents/acp/withTimeout.ts
|
|
39767
39767
|
function withTimeout(p2, ms) {
|
|
39768
|
-
return new Promise((
|
|
39768
|
+
return new Promise((resolve14) => {
|
|
39769
39769
|
let settled = false;
|
|
39770
39770
|
const timer = setTimeout(() => {
|
|
39771
39771
|
if (settled) return;
|
|
39772
39772
|
settled = true;
|
|
39773
|
-
|
|
39773
|
+
resolve14(void 0);
|
|
39774
39774
|
}, ms);
|
|
39775
39775
|
p2.then(
|
|
39776
39776
|
(v) => {
|
|
39777
39777
|
if (settled) return;
|
|
39778
39778
|
settled = true;
|
|
39779
39779
|
clearTimeout(timer);
|
|
39780
|
-
|
|
39780
|
+
resolve14(v);
|
|
39781
39781
|
},
|
|
39782
39782
|
() => {
|
|
39783
39783
|
if (settled) return;
|
|
39784
39784
|
settled = true;
|
|
39785
39785
|
clearTimeout(timer);
|
|
39786
|
-
|
|
39786
|
+
resolve14(void 0);
|
|
39787
39787
|
}
|
|
39788
39788
|
);
|
|
39789
39789
|
});
|
|
@@ -39952,7 +39952,7 @@ function isProcessMidTurn(pid, home) {
|
|
|
39952
39952
|
var import_node_child_process28 = require("child_process");
|
|
39953
39953
|
var fs77 = __toESM(require("fs"));
|
|
39954
39954
|
var path88 = __toESM(require("path"));
|
|
39955
|
-
var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((
|
|
39955
|
+
var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((resolve14) => {
|
|
39956
39956
|
(0, import_node_child_process28.execFile)(
|
|
39957
39957
|
file,
|
|
39958
39958
|
args2,
|
|
@@ -39968,7 +39968,7 @@ var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((re
|
|
|
39968
39968
|
const rawCode = err.code;
|
|
39969
39969
|
code = typeof rawCode === "number" ? rawCode : 1;
|
|
39970
39970
|
}
|
|
39971
|
-
|
|
39971
|
+
resolve14({ code, stdout: stdout ?? "", stderr: stderr ?? "" });
|
|
39972
39972
|
}
|
|
39973
39973
|
);
|
|
39974
39974
|
});
|
|
@@ -41218,11 +41218,11 @@ function previewMcpServer(bridge) {
|
|
|
41218
41218
|
};
|
|
41219
41219
|
}
|
|
41220
41220
|
function httpCall(baseUrl, token) {
|
|
41221
|
-
return async (
|
|
41221
|
+
return async (path112, method, body, timeoutMs) => {
|
|
41222
41222
|
const ac = new AbortController();
|
|
41223
41223
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
41224
41224
|
try {
|
|
41225
|
-
const res = await fetch(`${baseUrl}${
|
|
41225
|
+
const res = await fetch(`${baseUrl}${path112}`, {
|
|
41226
41226
|
method,
|
|
41227
41227
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
41228
41228
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -41350,11 +41350,11 @@ function scratchMcpServer(bridge) {
|
|
|
41350
41350
|
};
|
|
41351
41351
|
}
|
|
41352
41352
|
function httpCall2(baseUrl, token) {
|
|
41353
|
-
return async (
|
|
41353
|
+
return async (path112, method, body, timeoutMs) => {
|
|
41354
41354
|
const ac = new AbortController();
|
|
41355
41355
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
41356
41356
|
try {
|
|
41357
|
-
const res = await fetch(`${baseUrl}${
|
|
41357
|
+
const res = await fetch(`${baseUrl}${path112}`, {
|
|
41358
41358
|
method,
|
|
41359
41359
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
41360
41360
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -41610,24 +41610,24 @@ var AgentPreviewBridge = class {
|
|
|
41610
41610
|
* preview tools are then simply absent, never a failed session. */
|
|
41611
41611
|
listen() {
|
|
41612
41612
|
if (this.listening) return this.listening;
|
|
41613
|
-
this.listening = new Promise((
|
|
41613
|
+
this.listening = new Promise((resolve14) => {
|
|
41614
41614
|
const server = http12.createServer((req, res) => {
|
|
41615
41615
|
void this.handle(req, res);
|
|
41616
41616
|
});
|
|
41617
41617
|
server.on("error", (err) => {
|
|
41618
41618
|
log.warn("agent-preview", `bridge failed to listen: ${String(err)}`);
|
|
41619
|
-
|
|
41619
|
+
resolve14(null);
|
|
41620
41620
|
});
|
|
41621
41621
|
server.listen(0, "127.0.0.1", () => {
|
|
41622
41622
|
const addr = server.address();
|
|
41623
41623
|
if (!addr || typeof addr === "string") {
|
|
41624
|
-
|
|
41624
|
+
resolve14(null);
|
|
41625
41625
|
return;
|
|
41626
41626
|
}
|
|
41627
41627
|
server.unref();
|
|
41628
41628
|
this.server = server;
|
|
41629
41629
|
this.bound = { url: `http://127.0.0.1:${addr.port}`, token: this.token };
|
|
41630
|
-
|
|
41630
|
+
resolve14(this.bound);
|
|
41631
41631
|
});
|
|
41632
41632
|
});
|
|
41633
41633
|
return this.listening;
|
|
@@ -41664,9 +41664,9 @@ var AgentPreviewBridge = class {
|
|
|
41664
41664
|
}
|
|
41665
41665
|
const inflight = this.inflight;
|
|
41666
41666
|
let timer;
|
|
41667
|
-
const pending2 = new Promise((
|
|
41667
|
+
const pending2 = new Promise((resolve14) => {
|
|
41668
41668
|
timer = setTimeout(
|
|
41669
|
-
() =>
|
|
41669
|
+
() => resolve14({
|
|
41670
41670
|
status: "starting",
|
|
41671
41671
|
message: "The preview is still coming up (dependencies or a slow dev server). It keeps going in the background \u2014 call preview_status in a minute."
|
|
41672
41672
|
}),
|
|
@@ -41869,7 +41869,7 @@ function authorized(header, token) {
|
|
|
41869
41869
|
return presented.length === expected.length && (0, import_node_crypto14.timingSafeEqual)(presented, expected);
|
|
41870
41870
|
}
|
|
41871
41871
|
function readJson(req) {
|
|
41872
|
-
return new Promise((
|
|
41872
|
+
return new Promise((resolve14, reject) => {
|
|
41873
41873
|
let raw = "";
|
|
41874
41874
|
req.setEncoding("utf8");
|
|
41875
41875
|
req.on("data", (chunk) => {
|
|
@@ -41880,10 +41880,10 @@ function readJson(req) {
|
|
|
41880
41880
|
}
|
|
41881
41881
|
});
|
|
41882
41882
|
req.on("end", () => {
|
|
41883
|
-
if (!raw) return
|
|
41883
|
+
if (!raw) return resolve14({});
|
|
41884
41884
|
try {
|
|
41885
41885
|
const parsed = JSON.parse(raw);
|
|
41886
|
-
|
|
41886
|
+
resolve14(parsed && typeof parsed === "object" ? parsed : {});
|
|
41887
41887
|
} catch {
|
|
41888
41888
|
reject(new Error("invalid JSON"));
|
|
41889
41889
|
}
|
|
@@ -43010,15 +43010,15 @@ async function prewarmNewMcpEntries(manifest, previousIds) {
|
|
|
43010
43010
|
);
|
|
43011
43011
|
await Promise.all(
|
|
43012
43012
|
fresh.map(
|
|
43013
|
-
(e) => new Promise((
|
|
43013
|
+
(e) => new Promise((resolve14) => {
|
|
43014
43014
|
const mcp = e.delivery.mcp;
|
|
43015
43015
|
const child = (0, import_node_child_process29.execFile)(
|
|
43016
43016
|
mcp.command,
|
|
43017
43017
|
[...mcp.args, "--help"],
|
|
43018
43018
|
{ timeout: 9e4 },
|
|
43019
|
-
() =>
|
|
43019
|
+
() => resolve14()
|
|
43020
43020
|
);
|
|
43021
|
-
child.on("error", () =>
|
|
43021
|
+
child.on("error", () => resolve14());
|
|
43022
43022
|
})
|
|
43023
43023
|
)
|
|
43024
43024
|
);
|
|
@@ -43285,7 +43285,7 @@ var StreamingState = class {
|
|
|
43285
43285
|
* protested "J'ai rien refusé". The line is the user's evidence.
|
|
43286
43286
|
*/
|
|
43287
43287
|
registerPermission(args2) {
|
|
43288
|
-
return new Promise((
|
|
43288
|
+
return new Promise((resolve14) => {
|
|
43289
43289
|
const timeoutTimer = setTimeout(() => {
|
|
43290
43290
|
if (this.pending?.kind === "permission" && this.pending.questionId === args2.questionId) {
|
|
43291
43291
|
log.warn(
|
|
@@ -43298,14 +43298,14 @@ var StreamingState = class {
|
|
|
43298
43298
|
content: permissionExpiredNotice(),
|
|
43299
43299
|
done: true
|
|
43300
43300
|
});
|
|
43301
|
-
|
|
43301
|
+
resolve14({ outcome: { outcome: "cancelled" } });
|
|
43302
43302
|
}
|
|
43303
43303
|
}, PERMISSION_TIMEOUT_MS);
|
|
43304
43304
|
this.setPending({
|
|
43305
43305
|
kind: "permission",
|
|
43306
43306
|
questionId: args2.questionId,
|
|
43307
43307
|
options: args2.options,
|
|
43308
|
-
resolve:
|
|
43308
|
+
resolve: resolve14,
|
|
43309
43309
|
timeoutTimer
|
|
43310
43310
|
});
|
|
43311
43311
|
});
|
|
@@ -43342,14 +43342,14 @@ var StreamingState = class {
|
|
|
43342
43342
|
const byId = optionId ? this.pending.options.find((o) => o.optionId === optionId) : void 0;
|
|
43343
43343
|
const picked = byId ?? this.pending.options[index];
|
|
43344
43344
|
clearTimeout(this.pending.timeoutTimer);
|
|
43345
|
-
const
|
|
43345
|
+
const resolve14 = this.pending.resolve;
|
|
43346
43346
|
this.setPending(null);
|
|
43347
43347
|
if (!picked) {
|
|
43348
43348
|
log.warn("acpRunner", `select_option index=${index} out of bounds \u2014 cancel`);
|
|
43349
|
-
|
|
43349
|
+
resolve14({ outcome: { outcome: "cancelled" } });
|
|
43350
43350
|
return { kind: "resolved", optionId: null };
|
|
43351
43351
|
}
|
|
43352
|
-
|
|
43352
|
+
resolve14({ outcome: { outcome: "selected", optionId: picked.optionId } });
|
|
43353
43353
|
return { kind: "resolved", optionId: picked.optionId };
|
|
43354
43354
|
}
|
|
43355
43355
|
const text = this.pending.options[index];
|
|
@@ -45948,10 +45948,10 @@ var NativeTuiDriver = class _NativeTuiDriver {
|
|
|
45948
45948
|
this.lastOutput = this.now();
|
|
45949
45949
|
}
|
|
45950
45950
|
whenSafeToYield() {
|
|
45951
|
-
return new Promise((
|
|
45951
|
+
return new Promise((resolve14) => {
|
|
45952
45952
|
const tick = () => {
|
|
45953
45953
|
const quietFor = this.now() - this.lastOutput;
|
|
45954
|
-
if (quietFor >= this.idleMs)
|
|
45954
|
+
if (quietFor >= this.idleMs) resolve14();
|
|
45955
45955
|
else setTimeout(tick, this.idleMs - quietFor);
|
|
45956
45956
|
};
|
|
45957
45957
|
tick();
|
|
@@ -46014,10 +46014,10 @@ var AcpDriver = class {
|
|
|
46014
46014
|
* one ever is, assume resumable so behaviour is unchanged.
|
|
46015
46015
|
*/
|
|
46016
46016
|
hasTranscript(conversationId) {
|
|
46017
|
-
const
|
|
46018
|
-
if (typeof
|
|
46017
|
+
const resolve14 = this.deps.runtime.resolveHistoryFile;
|
|
46018
|
+
if (typeof resolve14 !== "function") return true;
|
|
46019
46019
|
try {
|
|
46020
|
-
return
|
|
46020
|
+
return resolve14.call(this.deps.runtime, this.deps.opts.cwd, conversationId) !== null;
|
|
46021
46021
|
} catch {
|
|
46022
46022
|
return true;
|
|
46023
46023
|
}
|
|
@@ -46081,11 +46081,11 @@ var AcpDriver = class {
|
|
|
46081
46081
|
this.turnActive = false;
|
|
46082
46082
|
const waiters = this.waiters;
|
|
46083
46083
|
this.waiters = [];
|
|
46084
|
-
waiters.forEach((
|
|
46084
|
+
waiters.forEach((resolve14) => resolve14());
|
|
46085
46085
|
}
|
|
46086
46086
|
whenSafeToYield() {
|
|
46087
46087
|
if (!this.turnActive) return Promise.resolve();
|
|
46088
|
-
return new Promise((
|
|
46088
|
+
return new Promise((resolve14) => this.waiters.push(resolve14));
|
|
46089
46089
|
}
|
|
46090
46090
|
};
|
|
46091
46091
|
|
|
@@ -46739,8 +46739,8 @@ async function start(requestedAgent, presetSession) {
|
|
|
46739
46739
|
let gateTimer;
|
|
46740
46740
|
await Promise.race([
|
|
46741
46741
|
Promise.all([depsReady, agentBinaryReady]),
|
|
46742
|
-
new Promise((
|
|
46743
|
-
gateTimer = setTimeout(
|
|
46742
|
+
new Promise((resolve14) => {
|
|
46743
|
+
gateTimer = setTimeout(resolve14, GATE_TIMEOUT_MS);
|
|
46744
46744
|
})
|
|
46745
46745
|
]);
|
|
46746
46746
|
if (gateTimer) clearTimeout(gateTimer);
|
|
@@ -47121,7 +47121,7 @@ async function pair(args2 = []) {
|
|
|
47121
47121
|
waitSpin.message(waitMessage());
|
|
47122
47122
|
}, 1e3);
|
|
47123
47123
|
countdownInterval.unref?.();
|
|
47124
|
-
await new Promise((
|
|
47124
|
+
await new Promise((resolve14) => {
|
|
47125
47125
|
let stopPolling = null;
|
|
47126
47126
|
function sigintHandler() {
|
|
47127
47127
|
clearInterval(countdownInterval);
|
|
@@ -47172,7 +47172,7 @@ async function pair(args2 = []) {
|
|
|
47172
47172
|
pluginAuthToken: info.pluginAuthToken
|
|
47173
47173
|
});
|
|
47174
47174
|
}
|
|
47175
|
-
|
|
47175
|
+
resolve14();
|
|
47176
47176
|
},
|
|
47177
47177
|
() => {
|
|
47178
47178
|
clearInterval(countdownInterval);
|
|
@@ -47401,12 +47401,12 @@ var GitHubCodespacesProvider = class {
|
|
|
47401
47401
|
}
|
|
47402
47402
|
if (!isAuthed) {
|
|
47403
47403
|
resetStdinForChild();
|
|
47404
|
-
await new Promise((
|
|
47404
|
+
await new Promise((resolve14, reject) => {
|
|
47405
47405
|
const proc = (0, import_child_process30.spawn)("gh", ["auth", "login", "-s", "codespace,repo,read:user"], {
|
|
47406
47406
|
stdio: "inherit"
|
|
47407
47407
|
});
|
|
47408
47408
|
proc.on("exit", (code) => {
|
|
47409
|
-
if (code === 0)
|
|
47409
|
+
if (code === 0) resolve14();
|
|
47410
47410
|
else reject(new Error("gh auth login failed."));
|
|
47411
47411
|
});
|
|
47412
47412
|
proc.on("error", reject);
|
|
@@ -47435,13 +47435,13 @@ var GitHubCodespacesProvider = class {
|
|
|
47435
47435
|
}
|
|
47436
47436
|
wt(noteLines.join("\n"), "One more permission needed");
|
|
47437
47437
|
resetStdinForChild();
|
|
47438
|
-
const refreshCode = await new Promise((
|
|
47438
|
+
const refreshCode = await new Promise((resolve14, reject) => {
|
|
47439
47439
|
const proc = (0, import_child_process30.spawn)(
|
|
47440
47440
|
"gh",
|
|
47441
47441
|
["auth", "refresh", "-h", "github.com", "-s", "codespace"],
|
|
47442
47442
|
{ stdio: "inherit" }
|
|
47443
47443
|
);
|
|
47444
|
-
proc.on("exit", (code) =>
|
|
47444
|
+
proc.on("exit", (code) => resolve14(code ?? 1));
|
|
47445
47445
|
proc.on("error", reject);
|
|
47446
47446
|
});
|
|
47447
47447
|
if (refreshCode !== 0) {
|
|
@@ -47585,10 +47585,10 @@ var GitHubCodespacesProvider = class {
|
|
|
47585
47585
|
if (q(proceed) || !proceed) return;
|
|
47586
47586
|
O2.step(`Installing gh via ${installCmd.describe}\u2026`);
|
|
47587
47587
|
resetStdinForChild();
|
|
47588
|
-
const ok = await new Promise((
|
|
47588
|
+
const ok = await new Promise((resolve14) => {
|
|
47589
47589
|
const proc = (0, import_child_process30.spawn)(installCmd.exe, installCmd.args, { stdio: "inherit" });
|
|
47590
|
-
proc.on("exit", (code) =>
|
|
47591
|
-
proc.on("error", () =>
|
|
47590
|
+
proc.on("exit", (code) => resolve14(code === 0));
|
|
47591
|
+
proc.on("error", () => resolve14(false));
|
|
47592
47592
|
});
|
|
47593
47593
|
if (ok) O2.success("gh installed");
|
|
47594
47594
|
else O2.error("gh install failed");
|
|
@@ -47612,14 +47612,14 @@ var GitHubCodespacesProvider = class {
|
|
|
47612
47612
|
"Expanding GitHub scopes"
|
|
47613
47613
|
);
|
|
47614
47614
|
resetStdinForChild();
|
|
47615
|
-
await new Promise((
|
|
47615
|
+
await new Promise((resolve14, reject) => {
|
|
47616
47616
|
const proc = (0, import_child_process30.spawn)(
|
|
47617
47617
|
"gh",
|
|
47618
47618
|
["auth", "refresh", "-h", "github.com", "-s", "repo,read:org"],
|
|
47619
47619
|
{ stdio: "inherit" }
|
|
47620
47620
|
);
|
|
47621
47621
|
proc.on("exit", (code) => {
|
|
47622
|
-
if (code === 0)
|
|
47622
|
+
if (code === 0) resolve14();
|
|
47623
47623
|
else reject(new Error(
|
|
47624
47624
|
"gh auth refresh failed. Re-run `gh auth refresh -h github.com -s repo,read:org` manually."
|
|
47625
47625
|
));
|
|
@@ -47790,13 +47790,13 @@ var GitHubCodespacesProvider = class {
|
|
|
47790
47790
|
}
|
|
47791
47791
|
async streamCommand(workspaceId, command2) {
|
|
47792
47792
|
resetStdinForChild();
|
|
47793
|
-
return new Promise((
|
|
47793
|
+
return new Promise((resolve14, reject) => {
|
|
47794
47794
|
const proc = (0, import_child_process30.spawn)(
|
|
47795
47795
|
"gh",
|
|
47796
47796
|
["codespace", "ssh", "-c", workspaceId, "--", "-tt", command2],
|
|
47797
47797
|
{ stdio: "inherit" }
|
|
47798
47798
|
);
|
|
47799
|
-
proc.on("exit", (code) =>
|
|
47799
|
+
proc.on("exit", (code) => resolve14({ code: code ?? 0 }));
|
|
47800
47800
|
proc.on("error", reject);
|
|
47801
47801
|
});
|
|
47802
47802
|
}
|
|
@@ -47817,7 +47817,7 @@ var GitHubCodespacesProvider = class {
|
|
|
47817
47817
|
"--",
|
|
47818
47818
|
`mkdir -p ${shellQuote(remoteDir)} && tar -xzf - -C ${shellQuote(remoteDir)}`
|
|
47819
47819
|
];
|
|
47820
|
-
await new Promise((
|
|
47820
|
+
await new Promise((resolve14, reject) => {
|
|
47821
47821
|
const tar = (0, import_child_process30.spawn)("tar", tarArgs, {
|
|
47822
47822
|
stdio: ["ignore", "pipe", "pipe"],
|
|
47823
47823
|
env: tarEnv
|
|
@@ -47837,7 +47837,7 @@ var GitHubCodespacesProvider = class {
|
|
|
47837
47837
|
ssh.on("error", reject);
|
|
47838
47838
|
ssh.on("exit", (code) => {
|
|
47839
47839
|
if (code === 0) {
|
|
47840
|
-
|
|
47840
|
+
resolve14();
|
|
47841
47841
|
} else {
|
|
47842
47842
|
const reason = (sshErr || tarErr || `exit ${code}`).trim().slice(0, 500);
|
|
47843
47843
|
reject(new Error(`Remote tar failed: ${reason}`));
|
|
@@ -47855,7 +47855,7 @@ var GitHubCodespacesProvider = class {
|
|
|
47855
47855
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote(remotePath)}`);
|
|
47856
47856
|
}
|
|
47857
47857
|
const cmd = parts.join(" && ");
|
|
47858
|
-
await new Promise((
|
|
47858
|
+
await new Promise((resolve14, reject) => {
|
|
47859
47859
|
const proc = (0, import_child_process30.spawn)(
|
|
47860
47860
|
"gh",
|
|
47861
47861
|
["codespace", "ssh", "-c", workspaceId, "--", cmd],
|
|
@@ -47867,7 +47867,7 @@ var GitHubCodespacesProvider = class {
|
|
|
47867
47867
|
});
|
|
47868
47868
|
proc.on("error", reject);
|
|
47869
47869
|
proc.on("exit", (code) => {
|
|
47870
|
-
if (code === 0)
|
|
47870
|
+
if (code === 0) resolve14();
|
|
47871
47871
|
else reject(new Error(`Remote write failed: ${(stderr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
47872
47872
|
});
|
|
47873
47873
|
proc.stdin?.write(contents);
|
|
@@ -47957,10 +47957,10 @@ var GitpodProvider = class {
|
|
|
47957
47957
|
"Authenticating Gitpod"
|
|
47958
47958
|
);
|
|
47959
47959
|
resetStdinForChild2();
|
|
47960
|
-
await new Promise((
|
|
47960
|
+
await new Promise((resolve14, reject) => {
|
|
47961
47961
|
const proc = (0, import_child_process31.spawn)("gitpod", ["login"], { stdio: "inherit" });
|
|
47962
47962
|
proc.on("exit", (code) => {
|
|
47963
|
-
if (code === 0)
|
|
47963
|
+
if (code === 0) resolve14();
|
|
47964
47964
|
else reject(new Error("gitpod login failed."));
|
|
47965
47965
|
});
|
|
47966
47966
|
proc.on("error", reject);
|
|
@@ -48109,13 +48109,13 @@ var GitpodProvider = class {
|
|
|
48109
48109
|
}
|
|
48110
48110
|
async streamCommand(workspaceId, command2) {
|
|
48111
48111
|
resetStdinForChild2();
|
|
48112
|
-
return new Promise((
|
|
48112
|
+
return new Promise((resolve14, reject) => {
|
|
48113
48113
|
const proc = (0, import_child_process31.spawn)(
|
|
48114
48114
|
"gitpod",
|
|
48115
48115
|
["workspace", "ssh", workspaceId, "--", "-tt", command2],
|
|
48116
48116
|
{ stdio: "inherit" }
|
|
48117
48117
|
);
|
|
48118
|
-
proc.on("exit", (code) =>
|
|
48118
|
+
proc.on("exit", (code) => resolve14({ code: code ?? 0 }));
|
|
48119
48119
|
proc.on("error", reject);
|
|
48120
48120
|
});
|
|
48121
48121
|
}
|
|
@@ -48129,7 +48129,7 @@ var GitpodProvider = class {
|
|
|
48129
48129
|
tarArgs.push(".");
|
|
48130
48130
|
const tarEnv = { ...process.env, COPYFILE_DISABLE: "1" };
|
|
48131
48131
|
const remoteCmd = `mkdir -p ${shellQuote2(remoteDir)} && tar -xzf - -C ${shellQuote2(remoteDir)}`;
|
|
48132
|
-
await new Promise((
|
|
48132
|
+
await new Promise((resolve14, reject) => {
|
|
48133
48133
|
const tar = (0, import_child_process31.spawn)("tar", tarArgs, {
|
|
48134
48134
|
stdio: ["ignore", "pipe", "pipe"],
|
|
48135
48135
|
env: tarEnv
|
|
@@ -48150,7 +48150,7 @@ var GitpodProvider = class {
|
|
|
48150
48150
|
tar.on("error", reject);
|
|
48151
48151
|
ssh.on("error", reject);
|
|
48152
48152
|
ssh.on("exit", (code) => {
|
|
48153
|
-
if (code === 0)
|
|
48153
|
+
if (code === 0) resolve14();
|
|
48154
48154
|
else reject(new Error(`Remote tar failed: ${(sshErr || tarErr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48155
48155
|
});
|
|
48156
48156
|
});
|
|
@@ -48165,7 +48165,7 @@ var GitpodProvider = class {
|
|
|
48165
48165
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote2(remotePath)}`);
|
|
48166
48166
|
}
|
|
48167
48167
|
const cmd = parts.join(" && ");
|
|
48168
|
-
await new Promise((
|
|
48168
|
+
await new Promise((resolve14, reject) => {
|
|
48169
48169
|
const proc = (0, import_child_process31.spawn)(
|
|
48170
48170
|
"gitpod",
|
|
48171
48171
|
["workspace", "ssh", workspaceId, "--", cmd],
|
|
@@ -48177,7 +48177,7 @@ var GitpodProvider = class {
|
|
|
48177
48177
|
});
|
|
48178
48178
|
proc.on("error", reject);
|
|
48179
48179
|
proc.on("exit", (code) => {
|
|
48180
|
-
if (code === 0)
|
|
48180
|
+
if (code === 0) resolve14();
|
|
48181
48181
|
else reject(new Error(`Remote write failed: ${(stderr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48182
48182
|
});
|
|
48183
48183
|
proc.stdin?.write(contents);
|
|
@@ -48234,14 +48234,14 @@ var GitLabWorkspacesProvider = class {
|
|
|
48234
48234
|
"Authenticating GitLab"
|
|
48235
48235
|
);
|
|
48236
48236
|
resetStdinForChild3();
|
|
48237
|
-
await new Promise((
|
|
48237
|
+
await new Promise((resolve14, reject) => {
|
|
48238
48238
|
const proc = (0, import_child_process32.spawn)(
|
|
48239
48239
|
"glab",
|
|
48240
48240
|
["auth", "login", "--scopes", "api,read_user,read_repository"],
|
|
48241
48241
|
{ stdio: "inherit" }
|
|
48242
48242
|
);
|
|
48243
48243
|
proc.on("exit", (code) => {
|
|
48244
|
-
if (code === 0)
|
|
48244
|
+
if (code === 0) resolve14();
|
|
48245
48245
|
else reject(new Error("glab auth login failed."));
|
|
48246
48246
|
});
|
|
48247
48247
|
proc.on("error", reject);
|
|
@@ -48406,13 +48406,13 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48406
48406
|
async streamCommand(workspaceId, command2) {
|
|
48407
48407
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
48408
48408
|
resetStdinForChild3();
|
|
48409
|
-
return new Promise((
|
|
48409
|
+
return new Promise((resolve14, reject) => {
|
|
48410
48410
|
const proc = (0, import_child_process32.spawn)(
|
|
48411
48411
|
"ssh",
|
|
48412
48412
|
["-tt", "-o", "StrictHostKeyChecking=accept-new", `${workspaceId}@${sshHost}`, command2],
|
|
48413
48413
|
{ stdio: "inherit" }
|
|
48414
48414
|
);
|
|
48415
|
-
proc.on("exit", (code) =>
|
|
48415
|
+
proc.on("exit", (code) => resolve14({ code: code ?? 0 }));
|
|
48416
48416
|
proc.on("error", reject);
|
|
48417
48417
|
});
|
|
48418
48418
|
}
|
|
@@ -48427,7 +48427,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48427
48427
|
tarArgs.push(".");
|
|
48428
48428
|
const tarEnv = { ...process.env, COPYFILE_DISABLE: "1" };
|
|
48429
48429
|
const remoteCmd = `mkdir -p ${shellQuote3(remoteDir)} && tar -xzf - -C ${shellQuote3(remoteDir)}`;
|
|
48430
|
-
await new Promise((
|
|
48430
|
+
await new Promise((resolve14, reject) => {
|
|
48431
48431
|
const tar = (0, import_child_process32.spawn)("tar", tarArgs, { stdio: ["ignore", "pipe", "pipe"], env: tarEnv });
|
|
48432
48432
|
const ssh = (0, import_child_process32.spawn)(
|
|
48433
48433
|
"ssh",
|
|
@@ -48445,7 +48445,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48445
48445
|
tar.on("error", reject);
|
|
48446
48446
|
ssh.on("error", reject);
|
|
48447
48447
|
ssh.on("exit", (code) => {
|
|
48448
|
-
if (code === 0)
|
|
48448
|
+
if (code === 0) resolve14();
|
|
48449
48449
|
else reject(new Error(`Remote tar failed: ${(sshErr || tarErr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48450
48450
|
});
|
|
48451
48451
|
});
|
|
@@ -48458,7 +48458,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48458
48458
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
48459
48459
|
}
|
|
48460
48460
|
const cmd = parts.join(" && ");
|
|
48461
|
-
await new Promise((
|
|
48461
|
+
await new Promise((resolve14, reject) => {
|
|
48462
48462
|
const proc = (0, import_child_process32.spawn)(
|
|
48463
48463
|
"ssh",
|
|
48464
48464
|
["-o", "StrictHostKeyChecking=accept-new", `${workspaceId}@${sshHost}`, cmd],
|
|
@@ -48470,7 +48470,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48470
48470
|
});
|
|
48471
48471
|
proc.on("error", reject);
|
|
48472
48472
|
proc.on("exit", (code) => {
|
|
48473
|
-
if (code === 0)
|
|
48473
|
+
if (code === 0) resolve14();
|
|
48474
48474
|
else reject(new Error(`Remote write failed: ${(stderr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48475
48475
|
});
|
|
48476
48476
|
proc.stdin?.write(contents);
|
|
@@ -48561,10 +48561,10 @@ var RailwayProvider = class {
|
|
|
48561
48561
|
"Authenticating Railway"
|
|
48562
48562
|
);
|
|
48563
48563
|
resetStdinForChild4();
|
|
48564
|
-
await new Promise((
|
|
48564
|
+
await new Promise((resolve14, reject) => {
|
|
48565
48565
|
const proc = (0, import_child_process33.spawn)("railway", ["login"], { stdio: "inherit" });
|
|
48566
48566
|
proc.on("exit", (code) => {
|
|
48567
|
-
if (code === 0)
|
|
48567
|
+
if (code === 0) resolve14();
|
|
48568
48568
|
else reject(new Error("railway login failed."));
|
|
48569
48569
|
});
|
|
48570
48570
|
proc.on("error", reject);
|
|
@@ -48704,13 +48704,13 @@ var RailwayProvider = class {
|
|
|
48704
48704
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
48705
48705
|
}
|
|
48706
48706
|
resetStdinForChild4();
|
|
48707
|
-
return new Promise((
|
|
48707
|
+
return new Promise((resolve14, reject) => {
|
|
48708
48708
|
const proc = (0, import_child_process33.spawn)(
|
|
48709
48709
|
"railway",
|
|
48710
48710
|
["shell", "--project", projectId, "--service", serviceId, "--command", command2],
|
|
48711
48711
|
{ stdio: "inherit" }
|
|
48712
48712
|
);
|
|
48713
|
-
proc.on("exit", (code) =>
|
|
48713
|
+
proc.on("exit", (code) => resolve14({ code: code ?? 0 }));
|
|
48714
48714
|
proc.on("error", reject);
|
|
48715
48715
|
});
|
|
48716
48716
|
}
|
|
@@ -48728,7 +48728,7 @@ var RailwayProvider = class {
|
|
|
48728
48728
|
tarArgs.push(".");
|
|
48729
48729
|
const tarEnv = { ...process.env, COPYFILE_DISABLE: "1" };
|
|
48730
48730
|
const remoteCmd = `mkdir -p ${shellQuote4(remoteDir)} && tar -xzf - -C ${shellQuote4(remoteDir)}`;
|
|
48731
|
-
await new Promise((
|
|
48731
|
+
await new Promise((resolve14, reject) => {
|
|
48732
48732
|
const tar = (0, import_child_process33.spawn)("tar", tarArgs, { stdio: ["ignore", "pipe", "pipe"], env: tarEnv });
|
|
48733
48733
|
const sh = (0, import_child_process33.spawn)(
|
|
48734
48734
|
"railway",
|
|
@@ -48746,7 +48746,7 @@ var RailwayProvider = class {
|
|
|
48746
48746
|
tar.on("error", reject);
|
|
48747
48747
|
sh.on("error", reject);
|
|
48748
48748
|
sh.on("exit", (code) => {
|
|
48749
|
-
if (code === 0)
|
|
48749
|
+
if (code === 0) resolve14();
|
|
48750
48750
|
else reject(new Error(`Remote tar failed: ${(shErr || tarErr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48751
48751
|
});
|
|
48752
48752
|
});
|
|
@@ -48762,7 +48762,7 @@ var RailwayProvider = class {
|
|
|
48762
48762
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
48763
48763
|
}
|
|
48764
48764
|
const cmd = parts.join(" && ");
|
|
48765
|
-
await new Promise((
|
|
48765
|
+
await new Promise((resolve14, reject) => {
|
|
48766
48766
|
const proc = (0, import_child_process33.spawn)(
|
|
48767
48767
|
"railway",
|
|
48768
48768
|
["shell", "--project", projectId, "--service", serviceId, "--command", cmd],
|
|
@@ -48774,7 +48774,7 @@ var RailwayProvider = class {
|
|
|
48774
48774
|
});
|
|
48775
48775
|
proc.on("error", reject);
|
|
48776
48776
|
proc.on("exit", (code) => {
|
|
48777
|
-
if (code === 0)
|
|
48777
|
+
if (code === 0) resolve14();
|
|
48778
48778
|
else reject(new Error(`Remote write failed: ${(stderr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48779
48779
|
});
|
|
48780
48780
|
proc.stdin?.write(contents);
|
|
@@ -49649,10 +49649,10 @@ async function host(args2) {
|
|
|
49649
49649
|
}
|
|
49650
49650
|
|
|
49651
49651
|
// src/commands/host-agent.ts
|
|
49652
|
-
var
|
|
49653
|
-
var
|
|
49654
|
-
var
|
|
49655
|
-
var
|
|
49652
|
+
var import_node_child_process36 = require("child_process");
|
|
49653
|
+
var os69 = __toESM(require("os"));
|
|
49654
|
+
var fs94 = __toESM(require("fs"));
|
|
49655
|
+
var path108 = __toESM(require("path"));
|
|
49656
49656
|
|
|
49657
49657
|
// src/skills/persist-from-payload.ts
|
|
49658
49658
|
function persistOrClearSkillsFromPayload(skills) {
|
|
@@ -49973,7 +49973,7 @@ var defaultGitToolingRunner = {
|
|
|
49973
49973
|
}
|
|
49974
49974
|
},
|
|
49975
49975
|
run(cmd, args2, opts = {}) {
|
|
49976
|
-
return new Promise((
|
|
49976
|
+
return new Promise((resolve14) => {
|
|
49977
49977
|
const child = (0, import_node_child_process31.spawn)(cmd, args2, {
|
|
49978
49978
|
stdio: [opts.input !== void 0 ? "pipe" : "ignore", "ignore", "pipe"]
|
|
49979
49979
|
});
|
|
@@ -49982,7 +49982,7 @@ var defaultGitToolingRunner = {
|
|
|
49982
49982
|
const done = (code) => {
|
|
49983
49983
|
if (settled) return;
|
|
49984
49984
|
settled = true;
|
|
49985
|
-
|
|
49985
|
+
resolve14({ code, stderr });
|
|
49986
49986
|
};
|
|
49987
49987
|
child.stderr?.on("data", (b) => {
|
|
49988
49988
|
stderr += b.toString();
|
|
@@ -50009,8 +50009,10 @@ var defaultGitToolingRunner = {
|
|
|
50009
50009
|
}
|
|
50010
50010
|
};
|
|
50011
50011
|
|
|
50012
|
-
// src/
|
|
50013
|
-
var
|
|
50012
|
+
// src/lib/cli-versions.ts
|
|
50013
|
+
var fs91 = __toESM(require("fs"));
|
|
50014
|
+
var os67 = __toESM(require("os"));
|
|
50015
|
+
var path105 = __toESM(require("path"));
|
|
50014
50016
|
|
|
50015
50017
|
// src/lib/updateNotifier.ts
|
|
50016
50018
|
var fs90 = __toESM(require("fs"));
|
|
@@ -50061,14 +50063,14 @@ function compareSemver(a, b) {
|
|
|
50061
50063
|
return 0;
|
|
50062
50064
|
}
|
|
50063
50065
|
function fetchLatest() {
|
|
50064
|
-
return new Promise((
|
|
50066
|
+
return new Promise((resolve14) => {
|
|
50065
50067
|
const req = https8.get(
|
|
50066
50068
|
REGISTRY_URL,
|
|
50067
50069
|
{ headers: { Accept: "application/json" }, timeout: REQUEST_TIMEOUT_MS },
|
|
50068
50070
|
(res) => {
|
|
50069
50071
|
if (res.statusCode !== 200) {
|
|
50070
50072
|
res.resume();
|
|
50071
|
-
|
|
50073
|
+
resolve14(null);
|
|
50072
50074
|
return;
|
|
50073
50075
|
}
|
|
50074
50076
|
let buf = "";
|
|
@@ -50080,21 +50082,21 @@ function fetchLatest() {
|
|
|
50080
50082
|
try {
|
|
50081
50083
|
const json = JSON.parse(buf);
|
|
50082
50084
|
if (typeof json.version === "string") {
|
|
50083
|
-
|
|
50085
|
+
resolve14(json.version);
|
|
50084
50086
|
} else {
|
|
50085
|
-
|
|
50087
|
+
resolve14(null);
|
|
50086
50088
|
}
|
|
50087
50089
|
} catch {
|
|
50088
|
-
|
|
50090
|
+
resolve14(null);
|
|
50089
50091
|
}
|
|
50090
50092
|
});
|
|
50091
50093
|
}
|
|
50092
50094
|
);
|
|
50093
50095
|
req.on("timeout", () => {
|
|
50094
50096
|
req.destroy();
|
|
50095
|
-
|
|
50097
|
+
resolve14(null);
|
|
50096
50098
|
});
|
|
50097
|
-
req.on("error", () =>
|
|
50099
|
+
req.on("error", () => resolve14(null));
|
|
50098
50100
|
});
|
|
50099
50101
|
}
|
|
50100
50102
|
function notifyIfStale(currentVersion, latest) {
|
|
@@ -50170,7 +50172,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
50170
50172
|
if (process.env.NODE_ENV === "test") return;
|
|
50171
50173
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
50172
50174
|
if (process.env.CI) return;
|
|
50173
|
-
const current2 = true ? "2.76.
|
|
50175
|
+
const current2 = true ? "2.76.11" : null;
|
|
50174
50176
|
if (!current2) return;
|
|
50175
50177
|
const cache = readCache();
|
|
50176
50178
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -50187,7 +50189,7 @@ function checkForUpdates() {
|
|
|
50187
50189
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
50188
50190
|
if (process.env.CI) return;
|
|
50189
50191
|
if (!process.stdout.isTTY) return;
|
|
50190
|
-
const current2 = true ? "2.76.
|
|
50192
|
+
const current2 = true ? "2.76.11" : null;
|
|
50191
50193
|
if (!current2) return;
|
|
50192
50194
|
const cache = readCache();
|
|
50193
50195
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -50201,16 +50203,264 @@ function checkForUpdates() {
|
|
|
50201
50203
|
});
|
|
50202
50204
|
}
|
|
50203
50205
|
|
|
50206
|
+
// src/lib/cli-versions.ts
|
|
50207
|
+
var CLI_PKG = "codeam-cli";
|
|
50208
|
+
var SEMVER_DIR = /^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/;
|
|
50209
|
+
var GC_KEEP_NEWEST = 3;
|
|
50210
|
+
var LOCK_STALE_MS = 15 * 6e4;
|
|
50211
|
+
function versionedModeSupported(platform3 = process.platform) {
|
|
50212
|
+
return platform3 !== "win32";
|
|
50213
|
+
}
|
|
50214
|
+
function cliVersionsRoot(env = process.env) {
|
|
50215
|
+
return env.CODEAM_CLI_VERSIONS_DIR || path105.join(os67.homedir(), ".codeam", "cli");
|
|
50216
|
+
}
|
|
50217
|
+
function packageDirOf(versionDir) {
|
|
50218
|
+
return path105.join(versionDir, "node_modules", CLI_PKG);
|
|
50219
|
+
}
|
|
50220
|
+
function isRecord6(v) {
|
|
50221
|
+
return typeof v === "object" && v !== null;
|
|
50222
|
+
}
|
|
50223
|
+
function readPkg2(versionDir) {
|
|
50224
|
+
try {
|
|
50225
|
+
const raw = JSON.parse(
|
|
50226
|
+
fs91.readFileSync(path105.join(packageDirOf(versionDir), "package.json"), "utf8")
|
|
50227
|
+
);
|
|
50228
|
+
return isRecord6(raw) ? raw : null;
|
|
50229
|
+
} catch {
|
|
50230
|
+
return null;
|
|
50231
|
+
}
|
|
50232
|
+
}
|
|
50233
|
+
function entryOf(versionDir) {
|
|
50234
|
+
const pkg = readPkg2(versionDir);
|
|
50235
|
+
if (!pkg) return null;
|
|
50236
|
+
const bin = pkg.bin;
|
|
50237
|
+
const named = isRecord6(bin) ? bin.codeam : void 0;
|
|
50238
|
+
const rel = typeof bin === "string" ? bin : typeof named === "string" ? named : "dist/index.js";
|
|
50239
|
+
const entry = path105.join(packageDirOf(versionDir), rel);
|
|
50240
|
+
return fs91.existsSync(entry) ? entry : null;
|
|
50241
|
+
}
|
|
50242
|
+
function launcherOf(versionDir) {
|
|
50243
|
+
const entry = entryOf(versionDir);
|
|
50244
|
+
if (!entry) return null;
|
|
50245
|
+
const bin = path105.join(versionDir, "node_modules", ".bin", "codeam");
|
|
50246
|
+
try {
|
|
50247
|
+
return fs91.realpathSync(bin) === fs91.realpathSync(entry) ? bin : entry;
|
|
50248
|
+
} catch {
|
|
50249
|
+
return entry;
|
|
50250
|
+
}
|
|
50251
|
+
}
|
|
50252
|
+
function versionOf(versionDir) {
|
|
50253
|
+
const v = readPkg2(versionDir)?.version;
|
|
50254
|
+
return typeof v === "string" ? v : null;
|
|
50255
|
+
}
|
|
50256
|
+
var BAD_MARKER_TTL_MS = 24 * 60 * 6e4;
|
|
50257
|
+
var PRE_READY_WINDOW_MS = 60 * 6e4;
|
|
50258
|
+
function isBad(versionDir, now = Date.now()) {
|
|
50259
|
+
try {
|
|
50260
|
+
return now - fs91.statSync(path105.join(versionDir, ".bad")).mtimeMs < BAD_MARKER_TTL_MS;
|
|
50261
|
+
} catch {
|
|
50262
|
+
return false;
|
|
50263
|
+
}
|
|
50264
|
+
}
|
|
50265
|
+
function recordPreReadyFailure(versionDir, now = Date.now()) {
|
|
50266
|
+
const file = path105.join(versionDir, ".prefail");
|
|
50267
|
+
let count = 0;
|
|
50268
|
+
try {
|
|
50269
|
+
const [n, at3] = fs91.readFileSync(file, "utf8").trim().split(" ").map(Number);
|
|
50270
|
+
if (Number.isFinite(n) && Number.isFinite(at3) && now - at3 < PRE_READY_WINDOW_MS) {
|
|
50271
|
+
count = n;
|
|
50272
|
+
}
|
|
50273
|
+
} catch {
|
|
50274
|
+
}
|
|
50275
|
+
count += 1;
|
|
50276
|
+
try {
|
|
50277
|
+
fs91.writeFileSync(file, `${count} ${now}`);
|
|
50278
|
+
} catch {
|
|
50279
|
+
}
|
|
50280
|
+
return count;
|
|
50281
|
+
}
|
|
50282
|
+
function clearPreReadyFailures(versionDir) {
|
|
50283
|
+
fs91.rmSync(path105.join(versionDir, ".prefail"), { force: true });
|
|
50284
|
+
}
|
|
50285
|
+
function markBad(versionDir, reason) {
|
|
50286
|
+
try {
|
|
50287
|
+
fs91.writeFileSync(path105.join(versionDir, ".bad"), `${(/* @__PURE__ */ new Date()).toISOString()} ${reason}
|
|
50288
|
+
`);
|
|
50289
|
+
} catch {
|
|
50290
|
+
}
|
|
50291
|
+
}
|
|
50292
|
+
function pointerTarget(root, name) {
|
|
50293
|
+
try {
|
|
50294
|
+
return fs91.realpathSync(path105.join(root, name));
|
|
50295
|
+
} catch {
|
|
50296
|
+
return null;
|
|
50297
|
+
}
|
|
50298
|
+
}
|
|
50299
|
+
function atomicPoint(root, name, targetDir) {
|
|
50300
|
+
const tmp = path105.join(root, `.${name}.tmp-${process.pid}-${Date.now()}`);
|
|
50301
|
+
fs91.symlinkSync(path105.relative(root, targetDir), tmp, "dir");
|
|
50302
|
+
try {
|
|
50303
|
+
fs91.renameSync(tmp, path105.join(root, name));
|
|
50304
|
+
} catch (err) {
|
|
50305
|
+
fs91.rmSync(tmp, { force: true });
|
|
50306
|
+
throw err;
|
|
50307
|
+
}
|
|
50308
|
+
}
|
|
50309
|
+
function switchCurrent(root, versionDir) {
|
|
50310
|
+
const old = pointerTarget(root, "current");
|
|
50311
|
+
if (old && path105.resolve(old) !== path105.resolve(versionDir)) atomicPoint(root, "previous", old);
|
|
50312
|
+
atomicPoint(root, "current", versionDir);
|
|
50313
|
+
}
|
|
50314
|
+
function validCurrent(root) {
|
|
50315
|
+
const dir = pointerTarget(root, "current");
|
|
50316
|
+
if (!dir || isBad(dir)) return null;
|
|
50317
|
+
const version3 = versionOf(dir);
|
|
50318
|
+
const entry = launcherOf(dir);
|
|
50319
|
+
return version3 && entry ? { dir, version: version3, entry } : null;
|
|
50320
|
+
}
|
|
50321
|
+
function rollbackCurrent(root) {
|
|
50322
|
+
const prev = pointerTarget(root, "previous");
|
|
50323
|
+
if (!prev || isBad(prev) || !entryOf(prev)) return null;
|
|
50324
|
+
const cur = pointerTarget(root, "current");
|
|
50325
|
+
if (cur && path105.resolve(cur) !== path105.resolve(prev)) atomicPoint(root, "previous", cur);
|
|
50326
|
+
atomicPoint(root, "current", prev);
|
|
50327
|
+
return versionOf(prev);
|
|
50328
|
+
}
|
|
50329
|
+
function hostEntry(root, ownVersion, fallback, platform3 = process.platform) {
|
|
50330
|
+
if (!versionedModeSupported(platform3) || !ownVersion) return fallback;
|
|
50331
|
+
const cur = validCurrent(root);
|
|
50332
|
+
return cur && compareSemver(cur.version, ownVersion) >= 0 ? cur.entry : fallback;
|
|
50333
|
+
}
|
|
50334
|
+
function versionDirContaining(root, file) {
|
|
50335
|
+
if (!file) return null;
|
|
50336
|
+
let real;
|
|
50337
|
+
let realRoot;
|
|
50338
|
+
try {
|
|
50339
|
+
real = fs91.realpathSync(file);
|
|
50340
|
+
realRoot = fs91.realpathSync(root);
|
|
50341
|
+
} catch {
|
|
50342
|
+
return null;
|
|
50343
|
+
}
|
|
50344
|
+
const rel = path105.relative(realRoot, real);
|
|
50345
|
+
if (rel.startsWith("..") || path105.isAbsolute(rel)) return null;
|
|
50346
|
+
const first = rel.split(path105.sep)[0];
|
|
50347
|
+
return first && SEMVER_DIR.test(first) ? path105.join(realRoot, first) : null;
|
|
50348
|
+
}
|
|
50349
|
+
function pidAlive3(pid) {
|
|
50350
|
+
try {
|
|
50351
|
+
process.kill(pid, 0);
|
|
50352
|
+
return true;
|
|
50353
|
+
} catch (err) {
|
|
50354
|
+
return err.code === "EPERM";
|
|
50355
|
+
}
|
|
50356
|
+
}
|
|
50357
|
+
function livePids(versionDir) {
|
|
50358
|
+
let names;
|
|
50359
|
+
try {
|
|
50360
|
+
names = fs91.readdirSync(path105.join(versionDir, ".pids"));
|
|
50361
|
+
} catch {
|
|
50362
|
+
return [];
|
|
50363
|
+
}
|
|
50364
|
+
return names.map(Number).filter((pid) => Number.isInteger(pid) && pid > 0 && pidAlive3(pid));
|
|
50365
|
+
}
|
|
50366
|
+
function registerRunningVersion(root = cliVersionsRoot(), entry = process.argv[1]) {
|
|
50367
|
+
const dir = versionDirContaining(root, entry);
|
|
50368
|
+
if (!dir) return;
|
|
50369
|
+
const file = path105.join(dir, ".pids", String(process.pid));
|
|
50370
|
+
try {
|
|
50371
|
+
fs91.mkdirSync(path105.dirname(file), { recursive: true });
|
|
50372
|
+
fs91.writeFileSync(file, "");
|
|
50373
|
+
process.once("exit", () => fs91.rmSync(file, { force: true }));
|
|
50374
|
+
} catch {
|
|
50375
|
+
}
|
|
50376
|
+
}
|
|
50377
|
+
function gcVersions(root) {
|
|
50378
|
+
const removed = [];
|
|
50379
|
+
let names;
|
|
50380
|
+
try {
|
|
50381
|
+
names = fs91.readdirSync(root).filter((n) => SEMVER_DIR.test(n));
|
|
50382
|
+
} catch {
|
|
50383
|
+
return removed;
|
|
50384
|
+
}
|
|
50385
|
+
const keep = new Set(
|
|
50386
|
+
[...names].sort((a, b) => compareSemver(b, a)).slice(0, GC_KEEP_NEWEST)
|
|
50387
|
+
);
|
|
50388
|
+
for (const p2 of [pointerTarget(root, "current"), pointerTarget(root, "previous")]) {
|
|
50389
|
+
if (p2) keep.add(path105.basename(p2));
|
|
50390
|
+
}
|
|
50391
|
+
for (const name of names) {
|
|
50392
|
+
const dir = path105.join(root, name);
|
|
50393
|
+
if (keep.has(name) || livePids(dir).length > 0) continue;
|
|
50394
|
+
try {
|
|
50395
|
+
fs91.rmSync(dir, { recursive: true, force: true });
|
|
50396
|
+
removed.push(name);
|
|
50397
|
+
} catch {
|
|
50398
|
+
}
|
|
50399
|
+
}
|
|
50400
|
+
return removed;
|
|
50401
|
+
}
|
|
50402
|
+
function acquireInstallLock(root) {
|
|
50403
|
+
const lock = path105.join(root, ".install.lock");
|
|
50404
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
50405
|
+
try {
|
|
50406
|
+
const fd = fs91.openSync(lock, "wx");
|
|
50407
|
+
fs91.writeSync(fd, String(process.pid));
|
|
50408
|
+
fs91.closeSync(fd);
|
|
50409
|
+
return () => fs91.rmSync(lock, { force: true });
|
|
50410
|
+
} catch (err) {
|
|
50411
|
+
if (err.code !== "EEXIST") return null;
|
|
50412
|
+
let stale = false;
|
|
50413
|
+
try {
|
|
50414
|
+
const owner = Number(fs91.readFileSync(lock, "utf8"));
|
|
50415
|
+
const age = Date.now() - fs91.statSync(lock).mtimeMs;
|
|
50416
|
+
stale = !Number.isInteger(owner) || !pidAlive3(owner) || age > LOCK_STALE_MS;
|
|
50417
|
+
} catch {
|
|
50418
|
+
stale = true;
|
|
50419
|
+
}
|
|
50420
|
+
if (!stale) return null;
|
|
50421
|
+
fs91.rmSync(lock, { force: true });
|
|
50422
|
+
}
|
|
50423
|
+
}
|
|
50424
|
+
return null;
|
|
50425
|
+
}
|
|
50426
|
+
|
|
50427
|
+
// src/commands/host/host-launch.ts
|
|
50428
|
+
var import_node_child_process34 = require("child_process");
|
|
50429
|
+
var fs93 = __toESM(require("fs"));
|
|
50430
|
+
var os68 = __toESM(require("os"));
|
|
50431
|
+
var path107 = __toESM(require("path"));
|
|
50432
|
+
|
|
50433
|
+
// src/exit-codes.ts
|
|
50434
|
+
var EXIT_OK = 0;
|
|
50435
|
+
var EXIT_FAILURE = 1;
|
|
50436
|
+
var EXIT_USAGE = 2;
|
|
50437
|
+
var EXIT_NEEDS_PAIRING = 3;
|
|
50438
|
+
var EXIT_HOST_NOT_ENROLLED = 78;
|
|
50439
|
+
var EXIT_SIGINT = 130;
|
|
50440
|
+
var EXIT_SIGTERM = 143;
|
|
50441
|
+
var EXIT_CODE_NAMES = {
|
|
50442
|
+
[EXIT_OK]: "ok",
|
|
50443
|
+
[EXIT_FAILURE]: "failure",
|
|
50444
|
+
[EXIT_USAGE]: "usage_error",
|
|
50445
|
+
[EXIT_NEEDS_PAIRING]: "needs_pairing",
|
|
50446
|
+
[EXIT_HOST_NOT_ENROLLED]: "host_not_enrolled",
|
|
50447
|
+
[EXIT_SIGINT]: "sigint",
|
|
50448
|
+
[EXIT_SIGTERM]: "sigterm"
|
|
50449
|
+
};
|
|
50450
|
+
|
|
50204
50451
|
// src/commands/host/self-update.ts
|
|
50452
|
+
var import_node_child_process33 = require("child_process");
|
|
50453
|
+
var fs92 = __toESM(require("fs"));
|
|
50454
|
+
var path106 = __toESM(require("path"));
|
|
50205
50455
|
var SELF_UPDATE_PKG = "codeam-cli";
|
|
50206
50456
|
var SELF_UPDATE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
50457
|
+
var SELF_UPDATE_STARTUP_DELAY_MS = 5e3;
|
|
50207
50458
|
var SELF_UPDATE_DEFER_MAX_MS = 24 * 60 * 60 * 1e3;
|
|
50208
50459
|
var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
|
|
50209
50460
|
var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
50210
50461
|
var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
|
|
50211
|
-
var SUDO_PREFLIGHT_TIMEOUT_MS = 5e3;
|
|
50212
50462
|
function currentCliVersion() {
|
|
50213
|
-
return true ? "2.76.
|
|
50463
|
+
return true ? "2.76.11" : null;
|
|
50214
50464
|
}
|
|
50215
50465
|
async function installedVersion(deps) {
|
|
50216
50466
|
const ls = await deps.run(
|
|
@@ -50226,10 +50476,10 @@ async function installedVersion(deps) {
|
|
|
50226
50476
|
}
|
|
50227
50477
|
}
|
|
50228
50478
|
function runCmd(cmd, args2, timeoutMs) {
|
|
50229
|
-
return new Promise((
|
|
50479
|
+
return new Promise((resolve14) => {
|
|
50230
50480
|
(0, import_node_child_process33.execFile)(cmd, args2, { timeout: timeoutMs }, (err, stdout, stderr) => {
|
|
50231
50481
|
const code = err && typeof err.code === "number" ? err.code : err ? null : 0;
|
|
50232
|
-
|
|
50482
|
+
resolve14({ code, stdout: stdout ?? "", stderr: stderr ?? "" });
|
|
50233
50483
|
});
|
|
50234
50484
|
});
|
|
50235
50485
|
}
|
|
@@ -50237,7 +50487,11 @@ async function runSelfUpdate() {
|
|
|
50237
50487
|
return runSelfUpdateWith({
|
|
50238
50488
|
run: runCmd,
|
|
50239
50489
|
currentVersion: currentCliVersion,
|
|
50240
|
-
isRoot: () => process.getuid?.() === 0
|
|
50490
|
+
isRoot: () => process.getuid?.() === 0,
|
|
50491
|
+
versionsRoot: cliVersionsRoot(),
|
|
50492
|
+
runningEntry: process.argv[1],
|
|
50493
|
+
nodePath: process.execPath,
|
|
50494
|
+
platform: process.platform
|
|
50241
50495
|
});
|
|
50242
50496
|
}
|
|
50243
50497
|
async function runSelfUpdateWith(deps) {
|
|
@@ -50247,6 +50501,15 @@ async function runSelfUpdateWith(deps) {
|
|
|
50247
50501
|
log.trace("host-agent", "self-update: no __CLI_VERSION__ \u2014 skipping");
|
|
50248
50502
|
return { status: "skipped" };
|
|
50249
50503
|
}
|
|
50504
|
+
const root = deps.versionsRoot ?? cliVersionsRoot();
|
|
50505
|
+
const versioned = versionedModeSupported(deps.platform) ? validCurrent(root) : null;
|
|
50506
|
+
if (versioned && compareSemver(versioned.version, current2) > 0) {
|
|
50507
|
+
log.info(
|
|
50508
|
+
"host-agent",
|
|
50509
|
+
`self-update: ${versioned.version} already current in ${root} (running ${current2}) \u2014 restarting onto it`
|
|
50510
|
+
);
|
|
50511
|
+
return { status: "updated", version: versioned.version };
|
|
50512
|
+
}
|
|
50250
50513
|
const onDisk = await installedVersion(deps);
|
|
50251
50514
|
if (onDisk && compareSemver(onDisk, current2) > 0) {
|
|
50252
50515
|
log.info(
|
|
@@ -50272,49 +50535,299 @@ async function runSelfUpdateWith(deps) {
|
|
|
50272
50535
|
if (compareSemver(latest, current2) <= 0) {
|
|
50273
50536
|
return { status: "current" };
|
|
50274
50537
|
}
|
|
50275
|
-
|
|
50276
|
-
|
|
50277
|
-
|
|
50278
|
-
|
|
50279
|
-
|
|
50280
|
-
|
|
50281
|
-
|
|
50282
|
-
|
|
50283
|
-
|
|
50538
|
+
if (!versionedModeSupported(deps.platform)) {
|
|
50539
|
+
log.info("host-agent", `self-update: ${current2} \u2192 ${latest} available \u2014 installing (global)`);
|
|
50540
|
+
return await installGlobalLegacy(deps, latest, current2);
|
|
50541
|
+
}
|
|
50542
|
+
log.info("host-agent", `self-update: ${current2} \u2192 ${latest} available \u2014 installing side-by-side`);
|
|
50543
|
+
return await installVersioned(deps, root, latest, current2);
|
|
50544
|
+
} catch (err) {
|
|
50545
|
+
log.warn(
|
|
50546
|
+
"host-agent",
|
|
50547
|
+
`self-update: unexpected error: ${err instanceof Error ? err.message : String(err)}`
|
|
50548
|
+
);
|
|
50549
|
+
return { status: "skipped" };
|
|
50550
|
+
}
|
|
50551
|
+
}
|
|
50552
|
+
var VERIFY_TIMEOUT_MS = 3e4;
|
|
50553
|
+
async function installVersioned(deps, root, latest, running2) {
|
|
50554
|
+
const node = deps.nodePath ?? process.execPath;
|
|
50555
|
+
const target = path106.join(root, latest);
|
|
50556
|
+
try {
|
|
50557
|
+
fs92.mkdirSync(root, { recursive: true });
|
|
50558
|
+
} catch {
|
|
50559
|
+
return { status: "skipped" };
|
|
50560
|
+
}
|
|
50561
|
+
if (isBad(target)) {
|
|
50562
|
+
log.warn("host-agent", `self-update: ${latest} is marked bad (crashed before ready) \u2014 not reinstalling`);
|
|
50563
|
+
return { status: "skipped" };
|
|
50564
|
+
}
|
|
50565
|
+
const release3 = acquireInstallLock(root);
|
|
50566
|
+
if (!release3) {
|
|
50567
|
+
log.info("host-agent", "self-update: another install holds the lock \u2014 skipping this tick");
|
|
50568
|
+
return { status: "skipped" };
|
|
50569
|
+
}
|
|
50570
|
+
try {
|
|
50571
|
+
const runningDir = versionDirContaining(root, deps.runningEntry);
|
|
50572
|
+
const reusable = entryOf(target) && versionOf(target) === latest;
|
|
50573
|
+
if (!reusable) {
|
|
50574
|
+
if (runningDir && path106.resolve(runningDir) === path106.resolve(target)) {
|
|
50575
|
+
return { status: "skipped" };
|
|
50576
|
+
}
|
|
50577
|
+
fs92.rmSync(target, { recursive: true, force: true });
|
|
50578
|
+
const install = await deps.run(
|
|
50579
|
+
"npm",
|
|
50580
|
+
[
|
|
50581
|
+
"install",
|
|
50582
|
+
"--prefix",
|
|
50583
|
+
target,
|
|
50584
|
+
"--no-audit",
|
|
50585
|
+
"--no-fund",
|
|
50586
|
+
"--loglevel=error",
|
|
50587
|
+
`${SELF_UPDATE_PKG}@${latest}`
|
|
50588
|
+
],
|
|
50589
|
+
SELF_UPDATE_INSTALL_TIMEOUT_MS
|
|
50590
|
+
);
|
|
50591
|
+
if (install.code !== 0) {
|
|
50592
|
+
fs92.rmSync(target, { recursive: true, force: true });
|
|
50284
50593
|
log.warn(
|
|
50285
50594
|
"host-agent",
|
|
50286
|
-
|
|
50595
|
+
`self-update: versioned install exited ${String(install.code)} \u2014 staying on ${running2}: ` + install.stderr.slice(-300)
|
|
50287
50596
|
);
|
|
50597
|
+
return { status: "skipped" };
|
|
50288
50598
|
}
|
|
50289
50599
|
}
|
|
50290
|
-
|
|
50600
|
+
const entry = entryOf(target);
|
|
50601
|
+
const check = entry ? await deps.run(node, [entry, "--version"], VERIFY_TIMEOUT_MS) : { code: null, stdout: "", stderr: "no entry point" };
|
|
50602
|
+
if (check.code !== 0 || !check.stdout.includes(latest)) {
|
|
50603
|
+
fs92.rmSync(target, { recursive: true, force: true });
|
|
50291
50604
|
log.warn(
|
|
50292
50605
|
"host-agent",
|
|
50293
|
-
`self-update:
|
|
50606
|
+
`self-update: ${latest} failed verification (exit ${String(check.code)}: ${(check.stdout + check.stderr).trim().slice(-200)}) \u2014 staying on ${running2}`
|
|
50294
50607
|
);
|
|
50295
50608
|
return { status: "skipped" };
|
|
50296
50609
|
}
|
|
50297
|
-
|
|
50298
|
-
|
|
50299
|
-
|
|
50300
|
-
|
|
50610
|
+
switchCurrent(root, target);
|
|
50611
|
+
const removed = gcVersions(root);
|
|
50612
|
+
log.info(
|
|
50613
|
+
"host-agent",
|
|
50614
|
+
`self-update: ${latest} installed + verified at ${target}, now current` + (removed.length ? ` (gc: ${removed.join(", ")})` : "")
|
|
50301
50615
|
);
|
|
50302
|
-
|
|
50303
|
-
return { status: "updated", version: installed2 };
|
|
50616
|
+
return { status: "updated", version: latest };
|
|
50304
50617
|
} catch (err) {
|
|
50618
|
+
const cur = pointerTarget(root, "current");
|
|
50619
|
+
if (!cur || path106.basename(cur) !== latest) fs92.rmSync(target, { recursive: true, force: true });
|
|
50305
50620
|
log.warn(
|
|
50306
50621
|
"host-agent",
|
|
50307
|
-
`self-update:
|
|
50622
|
+
`self-update: versioned install failed: ${err instanceof Error ? err.message : String(err)}`
|
|
50308
50623
|
);
|
|
50309
50624
|
return { status: "skipped" };
|
|
50625
|
+
} finally {
|
|
50626
|
+
release3();
|
|
50627
|
+
}
|
|
50628
|
+
}
|
|
50629
|
+
async function installGlobalLegacy(deps, latest, running2) {
|
|
50630
|
+
const install = await deps.run(
|
|
50631
|
+
"npm",
|
|
50632
|
+
["install", "-g", `${SELF_UPDATE_PKG}@latest`],
|
|
50633
|
+
SELF_UPDATE_INSTALL_TIMEOUT_MS
|
|
50634
|
+
);
|
|
50635
|
+
if (install.code !== 0) {
|
|
50636
|
+
log.warn("host-agent", `self-update: install exited ${String(install.code)} \u2014 staying on ${running2}`);
|
|
50637
|
+
return { status: "skipped" };
|
|
50638
|
+
}
|
|
50639
|
+
return { status: "updated", version: latest };
|
|
50640
|
+
}
|
|
50641
|
+
|
|
50642
|
+
// src/commands/host/host-launch.ts
|
|
50643
|
+
var SUPERVISED_FLAG = "--supervised";
|
|
50644
|
+
var READY_MESSAGE = "codeam-host-ready";
|
|
50645
|
+
var MAX_FAST_RESPAWNS = 5;
|
|
50646
|
+
var FAST_EXIT_MS = 3e4;
|
|
50647
|
+
var readySent = false;
|
|
50648
|
+
function signalHostReady(send = process.send?.bind(process)) {
|
|
50649
|
+
if (readySent || !send) return;
|
|
50650
|
+
readySent = true;
|
|
50651
|
+
try {
|
|
50652
|
+
send(READY_MESSAGE);
|
|
50653
|
+
} catch {
|
|
50654
|
+
}
|
|
50655
|
+
}
|
|
50656
|
+
function defaultDeps() {
|
|
50657
|
+
return {
|
|
50658
|
+
ownVersion: true ? "2.76.11" : null,
|
|
50659
|
+
root: cliVersionsRoot(),
|
|
50660
|
+
args: process.argv.slice(3),
|
|
50661
|
+
execPath: process.execPath,
|
|
50662
|
+
platform: process.platform,
|
|
50663
|
+
now: () => Date.now(),
|
|
50664
|
+
spawn: (cmd, args2) => (0, import_node_child_process34.spawn)(cmd, args2, { stdio: ["inherit", "inherit", "inherit", "ipc"] }),
|
|
50665
|
+
exit: (code) => process.exit(code),
|
|
50666
|
+
reraise: (signal) => {
|
|
50667
|
+
process.removeAllListeners(signal);
|
|
50668
|
+
process.kill(process.pid, signal);
|
|
50669
|
+
},
|
|
50670
|
+
warn: (msg) => process.stderr.write(`${msg}
|
|
50671
|
+
`),
|
|
50672
|
+
stdinIsTty: Boolean(process.stdin.isTTY)
|
|
50673
|
+
};
|
|
50674
|
+
}
|
|
50675
|
+
async function superviseCurrent(over = {}) {
|
|
50676
|
+
const deps = { ...defaultDeps(), ...over };
|
|
50677
|
+
if (!versionedModeSupported(deps.platform) || deps.args.includes(SUPERVISED_FLAG)) return "self";
|
|
50678
|
+
let fastRespawns = 0;
|
|
50679
|
+
for (; ; ) {
|
|
50680
|
+
const cur = validCurrent(deps.root);
|
|
50681
|
+
if (!cur || !deps.ownVersion || compareSemver(cur.version, deps.ownVersion) <= 0) return "self";
|
|
50682
|
+
const startedAt = deps.now();
|
|
50683
|
+
let ready = false;
|
|
50684
|
+
let stopping = false;
|
|
50685
|
+
const child = deps.spawn(deps.execPath, [cur.entry, "host-agent", SUPERVISED_FLAG, ...deps.args]);
|
|
50686
|
+
child.on("message", (m) => {
|
|
50687
|
+
if (m === READY_MESSAGE) {
|
|
50688
|
+
ready = true;
|
|
50689
|
+
clearPreReadyFailures(cur.dir);
|
|
50690
|
+
}
|
|
50691
|
+
});
|
|
50692
|
+
const signals = deps.stdinIsTty ? ["SIGTERM", "SIGHUP"] : ["SIGTERM", "SIGHUP", "SIGINT"];
|
|
50693
|
+
const forward = (sig) => () => {
|
|
50694
|
+
stopping = true;
|
|
50695
|
+
try {
|
|
50696
|
+
child.kill(sig);
|
|
50697
|
+
} catch {
|
|
50698
|
+
}
|
|
50699
|
+
};
|
|
50700
|
+
const handlers2 = signals.map((sig) => [sig, forward(sig)]);
|
|
50701
|
+
for (const [sig, h] of handlers2) process.on(sig, h);
|
|
50702
|
+
const ignoreSigint = () => {
|
|
50703
|
+
stopping = true;
|
|
50704
|
+
};
|
|
50705
|
+
if (deps.stdinIsTty) process.on("SIGINT", ignoreSigint);
|
|
50706
|
+
const { code, signal } = await new Promise(
|
|
50707
|
+
(resolve14) => {
|
|
50708
|
+
child.once("exit", (c2, s) => resolve14({ code: c2, signal: s }));
|
|
50709
|
+
child.once("error", () => resolve14({ code: 1, signal: null }));
|
|
50710
|
+
}
|
|
50711
|
+
);
|
|
50712
|
+
for (const [sig, h] of handlers2) process.off(sig, h);
|
|
50713
|
+
if (deps.stdinIsTty) process.off("SIGINT", ignoreSigint);
|
|
50714
|
+
if (signal) {
|
|
50715
|
+
deps.reraise(signal);
|
|
50716
|
+
return "supervised";
|
|
50717
|
+
}
|
|
50718
|
+
if (stopping || code === EXIT_HOST_NOT_ENROLLED) {
|
|
50719
|
+
deps.exit(code ?? 1);
|
|
50720
|
+
return "supervised";
|
|
50721
|
+
}
|
|
50722
|
+
if (code === 0) {
|
|
50723
|
+
fastRespawns = deps.now() - startedAt < FAST_EXIT_MS ? fastRespawns + 1 : 0;
|
|
50724
|
+
if (fastRespawns > MAX_FAST_RESPAWNS) {
|
|
50725
|
+
deps.warn("codeam: host-agent keeps restarting \u2014 running the launcher\u2019s own version");
|
|
50726
|
+
return "self";
|
|
50727
|
+
}
|
|
50728
|
+
continue;
|
|
50729
|
+
}
|
|
50730
|
+
if (!ready) {
|
|
50731
|
+
const strikes = recordPreReadyFailure(cur.dir);
|
|
50732
|
+
if (strikes < 2) {
|
|
50733
|
+
deps.warn(`codeam: ${cur.version} exited ${String(code)} before ready \u2014 retrying once`);
|
|
50734
|
+
continue;
|
|
50735
|
+
}
|
|
50736
|
+
markBad(cur.dir, `host-agent exited ${String(code)} before ready (${strikes}x)`);
|
|
50737
|
+
const now = rollbackCurrent(deps.root);
|
|
50738
|
+
deps.warn(
|
|
50739
|
+
`codeam: ${cur.version} exited ${String(code)} before ready twice \u2014 marked bad` + (now ? `, rolled back to ${now}` : "")
|
|
50740
|
+
);
|
|
50741
|
+
continue;
|
|
50742
|
+
}
|
|
50743
|
+
deps.exit(code ?? 1);
|
|
50744
|
+
return "supervised";
|
|
50745
|
+
}
|
|
50746
|
+
}
|
|
50747
|
+
function needsSelfRelaunch(env = process.env, pid = process.pid, ctx = {}) {
|
|
50748
|
+
if (env.INVOCATION_ID || pid === 1) return false;
|
|
50749
|
+
const ppid = ctx.ppid ?? process.ppid;
|
|
50750
|
+
if (ppid === 1 && isOurTiniEntrypoint((ctx.pid1Cmdline ?? readPid1Cmdline)())) return false;
|
|
50751
|
+
return true;
|
|
50752
|
+
}
|
|
50753
|
+
function readPid1Cmdline() {
|
|
50754
|
+
try {
|
|
50755
|
+
return fs93.readFileSync("/proc/1/cmdline", "utf8").split("\0").filter(Boolean);
|
|
50756
|
+
} catch {
|
|
50757
|
+
return [];
|
|
50758
|
+
}
|
|
50759
|
+
}
|
|
50760
|
+
function isOurTiniEntrypoint(argv) {
|
|
50761
|
+
return argv.some((a) => path107.basename(a) === "tini") && argv.includes("host-agent");
|
|
50762
|
+
}
|
|
50763
|
+
function relaunchArgv(execPath, argv) {
|
|
50764
|
+
return ["-c", 'sleep 2; exec "$0" "$@"', execPath, ...argv.slice(1)];
|
|
50765
|
+
}
|
|
50766
|
+
function defaultRestartForUpdate(version3, supervised, io = {}) {
|
|
50767
|
+
const exit = io.exit ?? ((code) => process.exit(code));
|
|
50768
|
+
const relaunch = !supervised && (io.needsRelaunch ?? needsSelfRelaunch());
|
|
50769
|
+
log.info(
|
|
50770
|
+
"host-agent",
|
|
50771
|
+
`self-update: installed ${version3}, restarting${supervised ? " (supervised)" : relaunch ? " (self-relaunch, no supervisor)" : ""}`
|
|
50772
|
+
);
|
|
50773
|
+
if (relaunch) {
|
|
50774
|
+
const entry = io.entry ?? hostEntry(
|
|
50775
|
+
io.root ?? cliVersionsRoot(),
|
|
50776
|
+
io.ownVersion === void 0 ? currentCliVersion() : io.ownVersion,
|
|
50777
|
+
io.argv1 ?? process.argv[1] ?? ""
|
|
50778
|
+
);
|
|
50779
|
+
const argv = [process.argv[0] ?? process.execPath, entry, ...process.argv.slice(2)];
|
|
50780
|
+
try {
|
|
50781
|
+
(io.relaunch ?? ((a) => (0, import_node_child_process34.spawn)("/bin/sh", relaunchArgv(process.execPath, a), {
|
|
50782
|
+
cwd: process.cwd(),
|
|
50783
|
+
env: process.env,
|
|
50784
|
+
detached: true,
|
|
50785
|
+
stdio: "ignore"
|
|
50786
|
+
}).unref()))(argv);
|
|
50787
|
+
} catch (err) {
|
|
50788
|
+
log.error("host-agent", "self-update: relaunch failed \u2014 staying on the old binary", err);
|
|
50789
|
+
return;
|
|
50790
|
+
}
|
|
50791
|
+
}
|
|
50792
|
+
exit(0);
|
|
50793
|
+
}
|
|
50794
|
+
function isContainerEnvironment(existsSyncFn = fs93.existsSync, readFileSyncFn = (p2) => fs93.readFileSync(p2, "utf8")) {
|
|
50795
|
+
try {
|
|
50796
|
+
if (existsSyncFn("/.dockerenv")) return true;
|
|
50797
|
+
} catch {
|
|
50798
|
+
}
|
|
50799
|
+
try {
|
|
50800
|
+
const cgroup = readFileSyncFn("/proc/1/cgroup");
|
|
50801
|
+
if (/docker|containerd|kubepods/.test(cgroup)) return true;
|
|
50802
|
+
} catch {
|
|
50310
50803
|
}
|
|
50804
|
+
return false;
|
|
50805
|
+
}
|
|
50806
|
+
function hostAgentPidFile(home = os68.homedir()) {
|
|
50807
|
+
return path107.join(home, ".codeam", "host-agent.pid");
|
|
50808
|
+
}
|
|
50809
|
+
function writeHostAgentPidFile(file = hostAgentPidFile(), pid = process.pid) {
|
|
50810
|
+
try {
|
|
50811
|
+
fs93.mkdirSync(path107.dirname(file), { recursive: true });
|
|
50812
|
+
fs93.writeFileSync(file, String(pid));
|
|
50813
|
+
process.once("exit", () => {
|
|
50814
|
+
try {
|
|
50815
|
+
if (fs93.readFileSync(file, "utf8").trim() === String(pid)) fs93.rmSync(file, { force: true });
|
|
50816
|
+
} catch {
|
|
50817
|
+
}
|
|
50818
|
+
});
|
|
50819
|
+
} catch {
|
|
50820
|
+
}
|
|
50821
|
+
}
|
|
50822
|
+
function bindSupervisedLifecycle(proc, onOrphaned) {
|
|
50823
|
+
proc.once("disconnect", onOrphaned);
|
|
50311
50824
|
}
|
|
50312
50825
|
|
|
50313
50826
|
// src/commands/host/teardown.ts
|
|
50314
|
-
var
|
|
50827
|
+
var import_node_child_process35 = require("child_process");
|
|
50315
50828
|
var defaultDisableService = () => {
|
|
50316
50829
|
try {
|
|
50317
|
-
(0,
|
|
50830
|
+
(0, import_node_child_process35.execFileSync)("systemctl", ["disable", "--now", "codeam-host-agent"], { stdio: "ignore" });
|
|
50318
50831
|
} catch {
|
|
50319
50832
|
}
|
|
50320
50833
|
};
|
|
@@ -50485,8 +50998,8 @@ var DOCKER_RUN_TIMEOUT_MS = 12e4;
|
|
|
50485
50998
|
var DOCKER_RUN_WITH_PULL_TIMEOUT_MS = 6e5;
|
|
50486
50999
|
var defaultDockerRunner = {
|
|
50487
51000
|
run(args2, opts = {}) {
|
|
50488
|
-
return new Promise((
|
|
50489
|
-
const child = (0,
|
|
51001
|
+
return new Promise((resolve14) => {
|
|
51002
|
+
const child = (0, import_node_child_process36.spawn)("docker", args2, {
|
|
50490
51003
|
stdio: ["ignore", "pipe", "pipe"],
|
|
50491
51004
|
env: { ...process.env, ...opts.env }
|
|
50492
51005
|
});
|
|
@@ -50504,7 +51017,7 @@ var defaultDockerRunner = {
|
|
|
50504
51017
|
if (settled) return;
|
|
50505
51018
|
settled = true;
|
|
50506
51019
|
clearTimeout(timer);
|
|
50507
|
-
|
|
51020
|
+
resolve14({ code, stderr: stderrBuf, stdout: stdoutBuf });
|
|
50508
51021
|
};
|
|
50509
51022
|
child.stdout?.on("data", (b) => {
|
|
50510
51023
|
stdoutBuf += b.toString();
|
|
@@ -50531,13 +51044,16 @@ var CONTROL_AGENT_META = {
|
|
|
50531
51044
|
// Synthetic control channel — capability flags are moot (no agent runs).
|
|
50532
51045
|
acp: false
|
|
50533
51046
|
};
|
|
50534
|
-
|
|
51047
|
+
function sessionEntry() {
|
|
51048
|
+
return hostEntry(cliVersionsRoot(), currentCliVersion(), process.argv[1]);
|
|
51049
|
+
}
|
|
51050
|
+
var defaultSpawner = (env, cwd, args2 = []) => (0, import_node_child_process36.spawn)(process.execPath, [sessionEntry(), "pair-auto", ...args2], {
|
|
50535
51051
|
cwd,
|
|
50536
51052
|
env: { ...process.env, ...env },
|
|
50537
51053
|
stdio: ["ignore", "pipe", "pipe"],
|
|
50538
51054
|
detached: false
|
|
50539
51055
|
});
|
|
50540
|
-
var defaultResumeSpawner = (env, cwd) => (0,
|
|
51056
|
+
var defaultResumeSpawner = (env, cwd) => (0, import_node_child_process36.spawn)(process.execPath, [sessionEntry()], {
|
|
50541
51057
|
cwd,
|
|
50542
51058
|
// CODEAM_AUTO_APPROVE=1 → ACP path (baton off). CODEAM_RESUME_LATEST=1 →
|
|
50543
51059
|
// continue the user's most-recent conversation instead of opening an empty
|
|
@@ -50556,48 +51072,12 @@ var defaultOnIdentityRejected = () => {
|
|
|
50556
51072
|
"host-agent",
|
|
50557
51073
|
"host identity rejected by backend \u2014 disabled service + wiped sealed identity, exiting"
|
|
50558
51074
|
);
|
|
50559
|
-
process.exit(
|
|
51075
|
+
process.exit(EXIT_HOST_NOT_ENROLLED);
|
|
50560
51076
|
};
|
|
50561
51077
|
var ORPHAN_TERM_GRACE_MS = 3e3;
|
|
50562
51078
|
var ORPHAN_KILL_SETTLE_MS = 500;
|
|
50563
|
-
function needsSelfRelaunch(env = process.env, pid = process.pid) {
|
|
50564
|
-
return !env.INVOCATION_ID && pid !== 1;
|
|
50565
|
-
}
|
|
50566
|
-
function isContainerEnvironment(existsSyncFn = fs91.existsSync, readFileSyncFn = (p2) => fs91.readFileSync(p2, "utf8")) {
|
|
50567
|
-
try {
|
|
50568
|
-
if (existsSyncFn("/.dockerenv")) return true;
|
|
50569
|
-
} catch {
|
|
50570
|
-
}
|
|
50571
|
-
try {
|
|
50572
|
-
const cgroup = readFileSyncFn("/proc/1/cgroup");
|
|
50573
|
-
if (/docker|containerd|kubepods/.test(cgroup)) return true;
|
|
50574
|
-
} catch {
|
|
50575
|
-
}
|
|
50576
|
-
return false;
|
|
50577
|
-
}
|
|
50578
|
-
function relaunchArgv(execPath, argv) {
|
|
50579
|
-
return ["-c", 'sleep 2; exec "$0" "$@"', execPath, ...argv.slice(1)];
|
|
50580
|
-
}
|
|
50581
51079
|
var defaultOnUpdated = (version3) => {
|
|
50582
|
-
|
|
50583
|
-
log.info(
|
|
50584
|
-
"host-agent",
|
|
50585
|
-
`self-update: installed ${version3}, restarting${relaunch ? " (self-relaunch, no supervisor)" : ""}`
|
|
50586
|
-
);
|
|
50587
|
-
if (relaunch) {
|
|
50588
|
-
try {
|
|
50589
|
-
(0, import_node_child_process35.spawn)("/bin/sh", relaunchArgv(process.execPath, process.argv), {
|
|
50590
|
-
cwd: process.cwd(),
|
|
50591
|
-
env: process.env,
|
|
50592
|
-
detached: true,
|
|
50593
|
-
stdio: "ignore"
|
|
50594
|
-
}).unref();
|
|
50595
|
-
} catch (err) {
|
|
50596
|
-
log.error("host-agent", "self-update: relaunch failed \u2014 staying on the old binary", err);
|
|
50597
|
-
return;
|
|
50598
|
-
}
|
|
50599
|
-
}
|
|
50600
|
-
process.exit(0);
|
|
51080
|
+
defaultRestartForUpdate(version3, process.argv.slice(3).includes(SUPERVISED_FLAG));
|
|
50601
51081
|
};
|
|
50602
51082
|
var HostAgentSupervisor = class {
|
|
50603
51083
|
constructor(identity, deps = {}) {
|
|
@@ -50633,6 +51113,7 @@ var HostAgentSupervisor = class {
|
|
|
50633
51113
|
heartbeatTimer = null;
|
|
50634
51114
|
/** Periodic self-update timer (npm check + install + restart). */
|
|
50635
51115
|
selfUpdateTimer = null;
|
|
51116
|
+
selfUpdateStartupTimer = null;
|
|
50636
51117
|
/** Self-update check + install (injectable; defaults to runSelfUpdate). */
|
|
50637
51118
|
selfUpdate;
|
|
50638
51119
|
now;
|
|
@@ -50726,11 +51207,17 @@ var HostAgentSupervisor = class {
|
|
|
50726
51207
|
this.reportLiveSet("boot");
|
|
50727
51208
|
const updateMs = this.selfUpdateIntervalMs();
|
|
50728
51209
|
if (updateMs > 0) {
|
|
51210
|
+
this.selfUpdateStartupTimer = setTimeout(
|
|
51211
|
+
() => void this.selfUpdateTick(),
|
|
51212
|
+
SELF_UPDATE_STARTUP_DELAY_MS
|
|
51213
|
+
);
|
|
51214
|
+
this.selfUpdateStartupTimer.unref?.();
|
|
50729
51215
|
this.selfUpdateTimer = setInterval(() => void this.selfUpdateTick(), updateMs);
|
|
50730
51216
|
this.selfUpdateTimer.unref?.();
|
|
50731
51217
|
} else {
|
|
50732
51218
|
log.info("host-agent", "self-update disabled (CODEAM_HOST_SELF_UPDATE_MS<=0)");
|
|
50733
51219
|
}
|
|
51220
|
+
(this.deps.writePidFile ?? writeHostAgentPidFile)();
|
|
50734
51221
|
log.info("host-agent", `supervisor up host=${this.identity.hostId.slice(0, 8)}`);
|
|
50735
51222
|
}
|
|
50736
51223
|
/** Stop the control channel + heartbeats + kill every child. */
|
|
@@ -50752,6 +51239,10 @@ var HostAgentSupervisor = class {
|
|
|
50752
51239
|
clearInterval(this.selfUpdateTimer);
|
|
50753
51240
|
this.selfUpdateTimer = null;
|
|
50754
51241
|
}
|
|
51242
|
+
if (this.selfUpdateStartupTimer) {
|
|
51243
|
+
clearTimeout(this.selfUpdateStartupTimer);
|
|
51244
|
+
this.selfUpdateStartupTimer = null;
|
|
51245
|
+
}
|
|
50755
51246
|
this.relay?.stop();
|
|
50756
51247
|
for (const child of this.children.values()) {
|
|
50757
51248
|
killQuiet(child.proc);
|
|
@@ -50797,6 +51288,7 @@ var HostAgentSupervisor = class {
|
|
|
50797
51288
|
}
|
|
50798
51289
|
const latencyMs = await sendHostHeartbeat(this.identity, metrics);
|
|
50799
51290
|
this.metrics.recordLatency(latencyMs);
|
|
51291
|
+
signalHostReady();
|
|
50800
51292
|
if (!this.reportedConnected) {
|
|
50801
51293
|
this.reportedConnected = true;
|
|
50802
51294
|
void reportProgress(
|
|
@@ -51028,13 +51520,13 @@ var HostAgentSupervisor = class {
|
|
|
51028
51520
|
const relay = this.relay;
|
|
51029
51521
|
if (!relay) return;
|
|
51030
51522
|
const raw = cmd.payload?.path;
|
|
51031
|
-
const target = typeof raw === "string" && raw.trim() ?
|
|
51523
|
+
const target = typeof raw === "string" && raw.trim() ? path108.resolve(raw.trim()) : os69.homedir();
|
|
51032
51524
|
try {
|
|
51033
|
-
const dirents = await
|
|
51525
|
+
const dirents = await fs94.promises.readdir(target, { withFileTypes: true });
|
|
51034
51526
|
const entries2 = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
|
|
51035
51527
|
(a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
|
|
51036
51528
|
);
|
|
51037
|
-
const parent =
|
|
51529
|
+
const parent = path108.dirname(target);
|
|
51038
51530
|
await relay.sendResult(cmd.id, "completed", {
|
|
51039
51531
|
path: target,
|
|
51040
51532
|
// null at the filesystem root so the UI can hide the ".." affordance.
|
|
@@ -51388,14 +51880,14 @@ var HostAgentSupervisor = class {
|
|
|
51388
51880
|
}),
|
|
51389
51881
|
CODEAM_AUTO_TOKEN: payload.autoPairToken
|
|
51390
51882
|
};
|
|
51391
|
-
const houseConfigDir =
|
|
51392
|
-
|
|
51883
|
+
const houseConfigDir = path108.join(
|
|
51884
|
+
os69.homedir(),
|
|
51393
51885
|
".codeam",
|
|
51394
51886
|
"house-claude",
|
|
51395
51887
|
payload.deployId
|
|
51396
51888
|
);
|
|
51397
51889
|
try {
|
|
51398
|
-
|
|
51890
|
+
fs94.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
|
|
51399
51891
|
} catch {
|
|
51400
51892
|
}
|
|
51401
51893
|
childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
|
|
@@ -51422,7 +51914,7 @@ var HostAgentSupervisor = class {
|
|
|
51422
51914
|
report("installing", "installing agent CLI");
|
|
51423
51915
|
await this.runAgentInstall(payload.agentInstallScript);
|
|
51424
51916
|
}
|
|
51425
|
-
const home = process.env.HOME ||
|
|
51917
|
+
const home = process.env.HOME || os69.homedir();
|
|
51426
51918
|
childEnv.PATH = `${home}/.local/bin:${process.env.PATH ?? ""}`;
|
|
51427
51919
|
if (payload.cloneToken) {
|
|
51428
51920
|
try {
|
|
@@ -51430,13 +51922,13 @@ var HostAgentSupervisor = class {
|
|
|
51430
51922
|
if ((payload.repoProvider ?? "github") === "gitlab") {
|
|
51431
51923
|
const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
|
|
51432
51924
|
if (glabCmd) {
|
|
51433
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
51925
|
+
childEnv.PATH = `${codeamBinDir()}${path108.delimiter}${childEnv.PATH}`;
|
|
51434
51926
|
await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
|
|
51435
51927
|
}
|
|
51436
51928
|
} else {
|
|
51437
51929
|
const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
|
|
51438
51930
|
if (ghCmd) {
|
|
51439
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
51931
|
+
childEnv.PATH = `${codeamBinDir()}${path108.delimiter}${childEnv.PATH}`;
|
|
51440
51932
|
await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
|
|
51441
51933
|
}
|
|
51442
51934
|
}
|
|
@@ -51464,9 +51956,9 @@ var HostAgentSupervisor = class {
|
|
|
51464
51956
|
);
|
|
51465
51957
|
if (!payload.suppressOnboardingWelcome) {
|
|
51466
51958
|
try {
|
|
51467
|
-
const cfgDir = childEnv.CLAUDE_CONFIG_DIR ||
|
|
51468
|
-
const projectDir =
|
|
51469
|
-
const hasPriorConversation =
|
|
51959
|
+
const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path108.join(os69.homedir(), ".claude");
|
|
51960
|
+
const projectDir = path108.join(cfgDir, "projects", encodeCwd(cwd));
|
|
51961
|
+
const hasPriorConversation = fs94.existsSync(projectDir) && fs94.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
|
|
51470
51962
|
if (hasPriorConversation) {
|
|
51471
51963
|
childEnv.CODEAM_RESUME_LATEST = "1";
|
|
51472
51964
|
log.info(
|
|
@@ -51620,7 +52112,7 @@ var HostAgentSupervisor = class {
|
|
|
51620
52112
|
fallbackResumeTarget() {
|
|
51621
52113
|
const session = getActiveSession();
|
|
51622
52114
|
if (!session || !session.pluginId || !session.pollSecret || !session.agent) return null;
|
|
51623
|
-
const cwd = session.cwd &&
|
|
52115
|
+
const cwd = session.cwd && fs94.existsSync(session.cwd) ? session.cwd : process.cwd();
|
|
51624
52116
|
if (isFilesystemRoot(cwd)) {
|
|
51625
52117
|
log.warn(
|
|
51626
52118
|
"host-agent",
|
|
@@ -51660,7 +52152,7 @@ var HostAgentSupervisor = class {
|
|
|
51660
52152
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: no saved pairing on this box`);
|
|
51661
52153
|
return;
|
|
51662
52154
|
}
|
|
51663
|
-
if (!session.cwd || !
|
|
52155
|
+
if (!session.cwd || !fs94.existsSync(session.cwd)) {
|
|
51664
52156
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: workspace is gone`);
|
|
51665
52157
|
return;
|
|
51666
52158
|
}
|
|
@@ -51702,7 +52194,7 @@ var HostAgentSupervisor = class {
|
|
|
51702
52194
|
const persisted = new Map((this.sessionStore.load() ?? []).map((r) => [r.deployId, r.agent]));
|
|
51703
52195
|
for (const c2 of this.children.values()) persisted.set(c2.deployId, c2.agent);
|
|
51704
52196
|
return this.listSavedSessions().map((s) => ({ s, deployId: deployIdFromWorkspace(s.cwd) })).filter(
|
|
51705
|
-
(x) => x.deployId !== null && !!x.s.cwd &&
|
|
52197
|
+
(x) => x.deployId !== null && !!x.s.cwd && fs94.existsSync(x.s.cwd)
|
|
51706
52198
|
).map(({ s, deployId }) => {
|
|
51707
52199
|
const agent = persisted.get(deployId);
|
|
51708
52200
|
return { deployId, sessionId: s.id, ...agent ? { agent } : {} };
|
|
@@ -51754,7 +52246,7 @@ var HostAgentSupervisor = class {
|
|
|
51754
52246
|
if (this.children.has(deployId)) return;
|
|
51755
52247
|
const st3 = this.resumeStateFor(target);
|
|
51756
52248
|
try {
|
|
51757
|
-
const cwd =
|
|
52249
|
+
const cwd = fs94.existsSync(target.cwd) ? target.cwd : process.cwd();
|
|
51758
52250
|
const proc = this.resumeSpawner(
|
|
51759
52251
|
{ ...readHouseProxyChildEnv(deployId), CODEAM_RESUME_SESSION_ID: session.id },
|
|
51760
52252
|
cwd
|
|
@@ -51781,7 +52273,7 @@ var HostAgentSupervisor = class {
|
|
|
51781
52273
|
return;
|
|
51782
52274
|
}
|
|
51783
52275
|
if (tracked && signal) {
|
|
51784
|
-
this.onResumeChildExit(target, 128 + (
|
|
52276
|
+
this.onResumeChildExit(target, 128 + (os69.constants.signals[signal] ?? 9), `signal ${signal}`);
|
|
51785
52277
|
return;
|
|
51786
52278
|
}
|
|
51787
52279
|
log.warn(
|
|
@@ -51824,7 +52316,7 @@ var HostAgentSupervisor = class {
|
|
|
51824
52316
|
if (Date.now() - child.startedAt < CRASH_RESPAWN_MIN_UPTIME_MS) return false;
|
|
51825
52317
|
const session = pickSavedSessionForWorkspace(this.listSavedSessions(), child.cwd);
|
|
51826
52318
|
if (!session) return false;
|
|
51827
|
-
const exitCode = typeof code === "number" ? code : 128 + (signal ?
|
|
52319
|
+
const exitCode = typeof code === "number" ? code : 128 + (signal ? os69.constants.signals[signal] ?? 9 : 9);
|
|
51828
52320
|
log.warn(
|
|
51829
52321
|
"host-agent",
|
|
51830
52322
|
`session deploy=${child.deployId.slice(0, 8)} died (${signal ?? code}) after ${Math.round((Date.now() - child.startedAt) / 1e3)}s \u2014 respawning it (resume)`
|
|
@@ -51973,12 +52465,12 @@ var HostAgentSupervisor = class {
|
|
|
51973
52465
|
this.untrackChild(deployId);
|
|
51974
52466
|
}
|
|
51975
52467
|
const dirs = [
|
|
51976
|
-
|
|
51977
|
-
|
|
52468
|
+
path108.join(selfHostedWorkspaceRoot(), deployId),
|
|
52469
|
+
path108.join(os69.homedir(), ".codeam", "house-claude", deployId)
|
|
51978
52470
|
];
|
|
51979
52471
|
for (const dir of dirs) {
|
|
51980
52472
|
try {
|
|
51981
|
-
|
|
52473
|
+
fs94.rmSync(dir, { recursive: true, force: true });
|
|
51982
52474
|
} catch (err) {
|
|
51983
52475
|
log.warn(
|
|
51984
52476
|
"host-agent",
|
|
@@ -52056,13 +52548,19 @@ async function resolveHostIdentity(enrollToken) {
|
|
|
52056
52548
|
}
|
|
52057
52549
|
async function hostAgent(args2 = []) {
|
|
52058
52550
|
installRelayCrashGuards();
|
|
52551
|
+
if (await superviseCurrent({ args: args2 }) === "supervised") return;
|
|
52059
52552
|
const tokenArg = args2.find((a) => a.startsWith("--token="));
|
|
52060
52553
|
const enrollToken = (tokenArg ? tokenArg.slice("--token=".length).trim() : "") || process.env.CODEAM_ENROLL_TOKEN || void 0;
|
|
52061
52554
|
const identity = await resolveHostIdentity(enrollToken);
|
|
52062
52555
|
if (!identity) {
|
|
52063
|
-
|
|
52064
|
-
"host-agent
|
|
52556
|
+
log.error(
|
|
52557
|
+
"host-agent",
|
|
52558
|
+
"no sealed host identity and no enroll token. Re-run the installer from the app (tokens expire after 15 min)."
|
|
52065
52559
|
);
|
|
52560
|
+
process.stderr.write(
|
|
52561
|
+
"host-agent: no sealed host identity and no enroll token. Re-run the installer from the app (tokens expire after 15 min).\n"
|
|
52562
|
+
);
|
|
52563
|
+
process.exit(EXIT_HOST_NOT_ENROLLED);
|
|
52066
52564
|
}
|
|
52067
52565
|
const supervisor = new HostAgentSupervisor(identity);
|
|
52068
52566
|
supervisor.start();
|
|
@@ -52072,6 +52570,7 @@ async function hostAgent(args2 = []) {
|
|
|
52072
52570
|
};
|
|
52073
52571
|
process.once("SIGINT", shutdown);
|
|
52074
52572
|
process.once("SIGTERM", shutdown);
|
|
52573
|
+
if (args2.includes(SUPERVISED_FLAG)) bindSupervisedLifecycle(process, shutdown);
|
|
52075
52574
|
await new Promise(() => {
|
|
52076
52575
|
});
|
|
52077
52576
|
}
|
|
@@ -52138,8 +52637,8 @@ async function invite() {
|
|
|
52138
52637
|
var import_node_dns = require("dns");
|
|
52139
52638
|
var import_node_util11 = require("util");
|
|
52140
52639
|
var import_node_crypto17 = require("crypto");
|
|
52141
|
-
var
|
|
52142
|
-
var
|
|
52640
|
+
var fs95 = __toESM(require("fs"));
|
|
52641
|
+
var path109 = __toESM(require("path"));
|
|
52143
52642
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
52144
52643
|
var dnsResolveP = (0, import_node_util11.promisify)(import_node_dns.resolve);
|
|
52145
52644
|
async function checkDns(apiBase2) {
|
|
@@ -52195,13 +52694,13 @@ async function checkHealth(apiBase2) {
|
|
|
52195
52694
|
}
|
|
52196
52695
|
}
|
|
52197
52696
|
function checkConfigDir() {
|
|
52198
|
-
const dir =
|
|
52697
|
+
const dir = path109.join(require("os").homedir(), ".codeam");
|
|
52199
52698
|
try {
|
|
52200
|
-
|
|
52201
|
-
const probe =
|
|
52202
|
-
|
|
52203
|
-
const read =
|
|
52204
|
-
|
|
52699
|
+
fs95.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
52700
|
+
const probe = path109.join(dir, ".doctor-probe");
|
|
52701
|
+
fs95.writeFileSync(probe, "ok", { mode: 384 });
|
|
52702
|
+
const read = fs95.readFileSync(probe, "utf8");
|
|
52703
|
+
fs95.unlinkSync(probe);
|
|
52205
52704
|
if (read !== "ok") throw new Error("write/read round-trip mismatch");
|
|
52206
52705
|
return {
|
|
52207
52706
|
id: "config-dir",
|
|
@@ -52241,9 +52740,9 @@ function checkSessions() {
|
|
|
52241
52740
|
}
|
|
52242
52741
|
}
|
|
52243
52742
|
function checkAgentBinaries() {
|
|
52244
|
-
const
|
|
52743
|
+
const os72 = createOsStrategy();
|
|
52245
52744
|
return getEnabledAgents().map((meta) => {
|
|
52246
|
-
const found =
|
|
52745
|
+
const found = os72.findInPath(meta.binaryName);
|
|
52247
52746
|
return {
|
|
52248
52747
|
id: `agent-${meta.id}`,
|
|
52249
52748
|
label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
|
|
@@ -52265,7 +52764,7 @@ function checkNodePty() {
|
|
|
52265
52764
|
detail: "not required on this platform"
|
|
52266
52765
|
};
|
|
52267
52766
|
}
|
|
52268
|
-
const vendoredPath =
|
|
52767
|
+
const vendoredPath = path109.join(__dirname, "vendor", "node-pty");
|
|
52269
52768
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
52270
52769
|
try {
|
|
52271
52770
|
require(target);
|
|
@@ -52307,7 +52806,7 @@ function checkChokidar() {
|
|
|
52307
52806
|
}
|
|
52308
52807
|
async function doctor(args2 = []) {
|
|
52309
52808
|
const json = args2.includes("--json");
|
|
52310
|
-
const cliVersion = true ? "2.76.
|
|
52809
|
+
const cliVersion = true ? "2.76.11" : "0.0.0-dev";
|
|
52311
52810
|
const apiBase2 = resolveApiBaseUrl();
|
|
52312
52811
|
const diagnosticId = (0, import_node_crypto17.randomUUID)();
|
|
52313
52812
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
@@ -52504,7 +53003,7 @@ async function completion(args2) {
|
|
|
52504
53003
|
}
|
|
52505
53004
|
|
|
52506
53005
|
// src/integrations/mcp-run.ts
|
|
52507
|
-
var
|
|
53006
|
+
var import_node_child_process39 = require("child_process");
|
|
52508
53007
|
|
|
52509
53008
|
// src/integrations/launcher-env.ts
|
|
52510
53009
|
var LAUNCHER_ENV = Object.freeze({
|
|
@@ -52588,7 +53087,7 @@ function resolveDelivery(id) {
|
|
|
52588
53087
|
function commandExists(command2) {
|
|
52589
53088
|
try {
|
|
52590
53089
|
const probe = process.platform === "win32" ? "where" : "which";
|
|
52591
|
-
(0,
|
|
53090
|
+
(0, import_node_child_process39.execFileSync)(probe, [command2], { stdio: "ignore" });
|
|
52592
53091
|
return true;
|
|
52593
53092
|
} catch {
|
|
52594
53093
|
return false;
|
|
@@ -52621,7 +53120,7 @@ function ensureCommand(command2) {
|
|
|
52621
53120
|
}
|
|
52622
53121
|
if (command2 === "uvx") {
|
|
52623
53122
|
try {
|
|
52624
|
-
(0,
|
|
53123
|
+
(0, import_node_child_process39.execSync)("curl -LsSf https://astral.sh/uv/install.sh | sh", {
|
|
52625
53124
|
stdio: ["ignore", process.stderr, process.stderr],
|
|
52626
53125
|
timeout: 18e4,
|
|
52627
53126
|
env: { ...process.env, UV_NO_MODIFY_PATH: "1" }
|
|
@@ -52630,7 +53129,7 @@ function ensureCommand(command2) {
|
|
|
52630
53129
|
}
|
|
52631
53130
|
if (resolveLauncherPath(command2) !== command2) return;
|
|
52632
53131
|
try {
|
|
52633
|
-
(0,
|
|
53132
|
+
(0, import_node_child_process39.execSync)("python3 -m pip install --user --quiet uv", {
|
|
52634
53133
|
stdio: ["ignore", process.stderr, process.stderr],
|
|
52635
53134
|
timeout: 18e4
|
|
52636
53135
|
});
|
|
@@ -52708,7 +53207,7 @@ async function mcpRun(args2) {
|
|
|
52708
53207
|
}
|
|
52709
53208
|
|
|
52710
53209
|
// src/integrations/mcp-warm.ts
|
|
52711
|
-
var
|
|
53210
|
+
var import_node_child_process40 = require("child_process");
|
|
52712
53211
|
function specOf(delivery) {
|
|
52713
53212
|
if (!delivery.command) return null;
|
|
52714
53213
|
const spec = (delivery.args ?? []).find((a) => !a.startsWith("-"));
|
|
@@ -52751,8 +53250,8 @@ var WARM_PACKAGE_TIMEOUT_MS = 12e4;
|
|
|
52751
53250
|
var WARM_TOTAL_BUDGET_MS = 10 * 6e4;
|
|
52752
53251
|
var WARM_CONCURRENCY = 4;
|
|
52753
53252
|
function runCapturing(command2, args2, timeoutMs) {
|
|
52754
|
-
return new Promise((
|
|
52755
|
-
const child = (0,
|
|
53253
|
+
return new Promise((resolve14) => {
|
|
53254
|
+
const child = (0, import_node_child_process40.spawn)(command2, args2, {
|
|
52756
53255
|
env: { ...process.env, ...LAUNCHER_ENV },
|
|
52757
53256
|
stdio: ["ignore", "ignore", "pipe"],
|
|
52758
53257
|
// `npx`/`uv` are `.cmd` shims on Windows; Node ≥ 20.12 refuses to spawn a
|
|
@@ -52766,15 +53265,15 @@ function runCapturing(command2, args2, timeoutMs) {
|
|
|
52766
53265
|
child.stderr?.on("data", (c2) => stderr += c2);
|
|
52767
53266
|
const timer = setTimeout(() => {
|
|
52768
53267
|
child.kill("SIGKILL");
|
|
52769
|
-
|
|
53268
|
+
resolve14({ status: null, stderr, error: new Error(`spawn ${command2} ETIMEDOUT`) });
|
|
52770
53269
|
}, timeoutMs);
|
|
52771
53270
|
child.on("error", (error) => {
|
|
52772
53271
|
clearTimeout(timer);
|
|
52773
|
-
|
|
53272
|
+
resolve14({ status: null, stderr, error });
|
|
52774
53273
|
});
|
|
52775
53274
|
child.on("close", (status2) => {
|
|
52776
53275
|
clearTimeout(timer);
|
|
52777
|
-
|
|
53276
|
+
resolve14({ status: status2, stderr });
|
|
52778
53277
|
});
|
|
52779
53278
|
});
|
|
52780
53279
|
}
|
|
@@ -52831,7 +53330,7 @@ async function mcpWarm(argv = [], opts = {}) {
|
|
|
52831
53330
|
// src/commands/version.ts
|
|
52832
53331
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
52833
53332
|
function version2() {
|
|
52834
|
-
const v = true ? "2.76.
|
|
53333
|
+
const v = true ? "2.76.11" : "unknown";
|
|
52835
53334
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
52836
53335
|
}
|
|
52837
53336
|
|
|
@@ -52963,32 +53462,17 @@ function tryShowSubcommandHelp(cmd, args2) {
|
|
|
52963
53462
|
}
|
|
52964
53463
|
var _subcommandHelpKeys = Object.keys(HELPS);
|
|
52965
53464
|
|
|
52966
|
-
// src/exit-codes.ts
|
|
52967
|
-
var EXIT_OK = 0;
|
|
52968
|
-
var EXIT_FAILURE = 1;
|
|
52969
|
-
var EXIT_USAGE = 2;
|
|
52970
|
-
var EXIT_NEEDS_PAIRING = 3;
|
|
52971
|
-
var EXIT_SIGINT = 130;
|
|
52972
|
-
var EXIT_SIGTERM = 143;
|
|
52973
|
-
var EXIT_CODE_NAMES = {
|
|
52974
|
-
[EXIT_OK]: "ok",
|
|
52975
|
-
[EXIT_FAILURE]: "failure",
|
|
52976
|
-
[EXIT_USAGE]: "usage_error",
|
|
52977
|
-
[EXIT_NEEDS_PAIRING]: "needs_pairing",
|
|
52978
|
-
[EXIT_SIGINT]: "sigint",
|
|
52979
|
-
[EXIT_SIGTERM]: "sigterm"
|
|
52980
|
-
};
|
|
52981
|
-
|
|
52982
53465
|
// src/index.ts
|
|
52983
|
-
var
|
|
53466
|
+
var os71 = __toESM(require("os"));
|
|
52984
53467
|
if (!process.env.HOME) {
|
|
52985
53468
|
try {
|
|
52986
|
-
const home =
|
|
53469
|
+
const home = os71.homedir();
|
|
52987
53470
|
if (home) process.env.HOME = home;
|
|
52988
53471
|
} catch {
|
|
52989
53472
|
}
|
|
52990
53473
|
}
|
|
52991
53474
|
loadCodespaceEnv();
|
|
53475
|
+
registerRunningVersion();
|
|
52992
53476
|
var [, , command, ...args] = process.argv;
|
|
52993
53477
|
async function main() {
|
|
52994
53478
|
const isMetaCommand = command === "--version" || command === "-v" || command === "version" || command === "--help" || command === "-h" || command === "help";
|