codeam-cli 2.76.14 → 2.76.15
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 +393 -305
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -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((resolve13) => {
|
|
132
132
|
this.ended = (code) => {
|
|
133
133
|
clearInterval(timer);
|
|
134
134
|
process.exitCode = code;
|
|
135
|
-
|
|
135
|
+
resolve13();
|
|
136
136
|
};
|
|
137
137
|
});
|
|
138
138
|
}
|
|
@@ -313,14 +313,14 @@ 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((resolve13) => {
|
|
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
|
+
resolve13({ code, stdout: out2, stderr: err });
|
|
324
324
|
};
|
|
325
325
|
let child;
|
|
326
326
|
try {
|
|
@@ -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((resolve13, 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 resolve13();
|
|
674
674
|
};
|
|
675
675
|
stdioTransport.onmessage = (msg) => {
|
|
676
676
|
watchdog.onClientMessage(msg);
|
|
@@ -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((resolve13, reject) => {
|
|
4730
4730
|
timeoutHandle = safeSetTimeout(() => {
|
|
4731
4731
|
try {
|
|
4732
4732
|
onTimeout?.();
|
|
4733
|
-
|
|
4733
|
+
resolve13();
|
|
4734
4734
|
} catch (error) {
|
|
4735
4735
|
reject(error);
|
|
4736
4736
|
}
|
|
@@ -7804,13 +7804,13 @@ async function getContextLinesFromFile(path114, ranges, output, cacheKey, openSo
|
|
|
7804
7804
|
const fileHandle = await openRegularSourceFile(path114, 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((resolve13) => {
|
|
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(resolve13, resolve13);
|
|
7814
7814
|
}
|
|
7815
7815
|
let stream;
|
|
7816
7816
|
try {
|
|
@@ -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((resolve13) => safeSetTimeout(resolve13, 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 resolve13;
|
|
9367
9367
|
const promise = new Promise((r) => {
|
|
9368
|
-
|
|
9368
|
+
resolve13 = 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: resolve13,
|
|
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 resolve13 = this._consumeWaitUntilCycle();
|
|
9401
9401
|
try {
|
|
9402
9402
|
await this.flushWithPendingPromises();
|
|
9403
9403
|
} catch {
|
|
9404
9404
|
} finally {
|
|
9405
|
-
|
|
9405
|
+
resolve13?.();
|
|
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((resolve13) => {
|
|
9664
9664
|
const timeout = setTimeout(() => {
|
|
9665
9665
|
cleanup();
|
|
9666
|
-
|
|
9666
|
+
resolve13(false);
|
|
9667
9667
|
}, timeoutMs);
|
|
9668
9668
|
const cleanup = this._events.on("localEvaluationFlagsLoaded", (count) => {
|
|
9669
9669
|
clearTimeout(timeout);
|
|
9670
9670
|
cleanup();
|
|
9671
|
-
|
|
9671
|
+
resolve13(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 resolve13 = 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
|
+
resolve13?.();
|
|
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.15" : "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((resolve13, reject) => {
|
|
10730
10730
|
(0, import_child_process.execFile)(file, args2, opts, (err, stdout) => {
|
|
10731
10731
|
if (err) reject(err);
|
|
10732
|
-
else
|
|
10732
|
+
else resolve13(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.15",
|
|
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((resolve13) => {
|
|
10962
|
+
timer = setTimeout(() => resolve13(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((resolve13, 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
|
+
resolve13(JSON.parse(responseBody));
|
|
11447
11447
|
} catch {
|
|
11448
|
-
|
|
11448
|
+
resolve13(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((resolve13, 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
|
+
resolve13(JSON.parse(body2));
|
|
11505
11505
|
} catch {
|
|
11506
|
-
|
|
11506
|
+
resolve13(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((resolve13, 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
|
+
resolve13(JSON.parse(body));
|
|
11546
11546
|
} catch {
|
|
11547
|
-
|
|
11547
|
+
resolve13(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.15" ? { ideVersion: "2.76.15" } : {}
|
|
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((resolve13) => {
|
|
12309
|
+
timer = setTimeout(resolve13, 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((resolve13, 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
|
+
resolve13({ statusCode: res.statusCode ?? 0, body });
|
|
12444
12444
|
});
|
|
12445
12445
|
}
|
|
12446
12446
|
);
|
|
@@ -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((resolve13) => {
|
|
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
|
+
resolve13(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", () => resolve13(null));
|
|
13159
13159
|
proc.on("close", (code) => {
|
|
13160
13160
|
if (code === 0 || opts.allowNonZeroExit) {
|
|
13161
|
-
|
|
13161
|
+
resolve13(stdout);
|
|
13162
13162
|
} else {
|
|
13163
13163
|
log.trace("fileWatcher", `git ${args2.join(" ")} exited ${code} stderr=${stderr.slice(0, 200)}`);
|
|
13164
|
-
|
|
13164
|
+
resolve13(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((resolve13) => {
|
|
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
|
+
resolve13({ 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
|
+
resolve13({ 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
|
+
resolve13({ dead: true });
|
|
13281
13281
|
return;
|
|
13282
13282
|
}
|
|
13283
|
-
|
|
13283
|
+
resolve13({ 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
|
+
resolve13({ 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
|
+
resolve13({ 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((resolve13, 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
|
+
resolve13({ 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((resolve13) => {
|
|
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
|
+
resolve13({ 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) => resolve13({ ok: false, code: -1, stdout, stderr: stderr + err.message })
|
|
14465
14465
|
);
|
|
14466
14466
|
proc.on(
|
|
14467
14467
|
"close",
|
|
14468
|
-
(code) =>
|
|
14468
|
+
(code) => resolve13({ 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((resolve13) => {
|
|
16808
|
+
if (proc.exitCode !== null || proc.signalCode !== null) return resolve13();
|
|
16809
|
+
proc.once("exit", () => resolve13());
|
|
16810
16810
|
});
|
|
16811
16811
|
proc.kill("SIGTERM");
|
|
16812
|
-
const timer = new Promise((
|
|
16813
|
-
const t2 = setTimeout(() =>
|
|
16812
|
+
const timer = new Promise((resolve13) => {
|
|
16813
|
+
const t2 = setTimeout(() => resolve13("timeout"), timeoutMs);
|
|
16814
16814
|
void exited.then(() => clearTimeout(t2));
|
|
16815
16815
|
});
|
|
16816
16816
|
if (await Promise.race([exited, timer]) === "timeout") {
|
|
@@ -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((resolve13) => {
|
|
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
|
+
resolve13(false);
|
|
17293
17293
|
});
|
|
17294
17294
|
proc.on("exit", (code) => {
|
|
17295
|
-
|
|
17295
|
+
resolve13(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((resolve13, 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
|
+
resolve13({ 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((resolve13) => {
|
|
17531
17531
|
const claudeCmd = findInPath("claude") ? "claude" : "claude-code";
|
|
17532
17532
|
if (!claudeCmd) {
|
|
17533
|
-
|
|
17533
|
+
resolve13(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
|
+
resolve13(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
|
+
resolve13(result);
|
|
17568
17568
|
}, 5e3);
|
|
17569
17569
|
}, 8e3);
|
|
17570
17570
|
setTimeout(() => {
|
|
17571
17571
|
if (!resolved) {
|
|
17572
17572
|
resolved = true;
|
|
17573
|
-
|
|
17573
|
+
resolve13(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((resolve13) => {
|
|
17613
17613
|
let settled = false;
|
|
17614
17614
|
const settle = (value) => {
|
|
17615
17615
|
if (settled) return;
|
|
17616
17616
|
settled = true;
|
|
17617
|
-
|
|
17617
|
+
resolve13(value);
|
|
17618
17618
|
};
|
|
17619
17619
|
let child;
|
|
17620
17620
|
try {
|
|
@@ -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((resolve13) => setTimeout(resolve13, ms));
|
|
19069
19069
|
}
|
|
19070
19070
|
function getCurrentUsage2(historyDir) {
|
|
19071
19071
|
if (!import_node_fs4.default.existsSync(historyDir)) return null;
|
|
@@ -19307,12 +19307,12 @@ function resolveNpm(os74) {
|
|
|
19307
19307
|
return os74.id === "win32" ? "npm.cmd" : "npm";
|
|
19308
19308
|
}
|
|
19309
19309
|
async function installCodexViaNpm(os74) {
|
|
19310
|
-
return new Promise((
|
|
19310
|
+
return new Promise((resolve13, reject) => {
|
|
19311
19311
|
const proc = (0, import_node_child_process4.spawn)(resolveNpm(os74), ["install", "-g", "@openai/codex"], {
|
|
19312
19312
|
stdio: "inherit"
|
|
19313
19313
|
});
|
|
19314
19314
|
proc.on("close", (code) => {
|
|
19315
|
-
if (code === 0)
|
|
19315
|
+
if (code === 0) resolve13();
|
|
19316
19316
|
else reject(new Error(`npm install -g @openai/codex exited ${code}`));
|
|
19317
19317
|
});
|
|
19318
19318
|
proc.on("error", (err) => {
|
|
@@ -19432,7 +19432,7 @@ var defaultOsRunner = {
|
|
|
19432
19432
|
}
|
|
19433
19433
|
},
|
|
19434
19434
|
run(cmd, args2, opts = {}) {
|
|
19435
|
-
return new Promise((
|
|
19435
|
+
return new Promise((resolve13) => {
|
|
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
|
+
resolve13({ code, stderr: stderrBuf, stdout: stdoutBuf });
|
|
19445
19445
|
};
|
|
19446
19446
|
child.stdout?.on("data", (b) => {
|
|
19447
19447
|
const chunk = b.toString();
|
|
@@ -19590,7 +19590,7 @@ async function ensureInstallPrerequisites(os74, deps = {}) {
|
|
|
19590
19590
|
};
|
|
19591
19591
|
}
|
|
19592
19592
|
function defaultRunInstallScript(env) {
|
|
19593
|
-
return new Promise((
|
|
19593
|
+
return new Promise((resolve13) => {
|
|
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
|
+
resolve13({ code, output });
|
|
19606
19606
|
};
|
|
19607
19607
|
const onData = (b) => {
|
|
19608
19608
|
const chunk = b.toString();
|
|
@@ -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((resolve13, 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
|
+
resolve13(out2);
|
|
19992
19992
|
};
|
|
19993
19993
|
const timer = setTimeout(() => {
|
|
19994
19994
|
if (settled) return;
|
|
@@ -20608,7 +20608,7 @@ function resolveClaudeNativeBinary(deps = {}) {
|
|
|
20608
20608
|
const candidate = import_path4.default.join(scopeDir, `claude-agent-sdk-${platformKey}`, binName);
|
|
20609
20609
|
return existsSync35(candidate) ? candidate : null;
|
|
20610
20610
|
}
|
|
20611
|
-
var realSleep = (ms) => new Promise((
|
|
20611
|
+
var realSleep = (ms) => new Promise((resolve13) => setTimeout(resolve13, ms));
|
|
20612
20612
|
async function waitForClaudeNativeBinary(opts = {}) {
|
|
20613
20613
|
const timeoutMs = opts.timeoutMs ?? 18e4;
|
|
20614
20614
|
const pollMs = opts.pollMs ?? 500;
|
|
@@ -20729,7 +20729,7 @@ var PERMANENT_ADAPTER_STARTUP_RE = /IneligibleTierError|UNSUPPORTED_CLIENT|no lo
|
|
|
20729
20729
|
function probeAdapterModuleGraph(command2, args2, opts = {}) {
|
|
20730
20730
|
const livenessMs = opts.livenessMs ?? 400;
|
|
20731
20731
|
const spawnFn = opts.spawnFn ?? import_child_process13.spawn;
|
|
20732
|
-
return new Promise((
|
|
20732
|
+
return new Promise((resolve13) => {
|
|
20733
20733
|
let settled = false;
|
|
20734
20734
|
let stderr = "";
|
|
20735
20735
|
let timer;
|
|
@@ -20742,12 +20742,12 @@ function probeAdapterModuleGraph(command2, args2, opts = {}) {
|
|
|
20742
20742
|
child?.kill("SIGKILL");
|
|
20743
20743
|
} catch {
|
|
20744
20744
|
}
|
|
20745
|
-
|
|
20745
|
+
resolve13(r);
|
|
20746
20746
|
};
|
|
20747
20747
|
try {
|
|
20748
20748
|
child = spawnFn(command2, [...args2], { stdio: ["pipe", "ignore", "pipe"] });
|
|
20749
20749
|
} catch {
|
|
20750
|
-
|
|
20750
|
+
resolve13("ok");
|
|
20751
20751
|
return;
|
|
20752
20752
|
}
|
|
20753
20753
|
child.stderr?.on("data", (d3) => {
|
|
@@ -21336,7 +21336,7 @@ function newestSessionSince(bucket, floorMs) {
|
|
|
21336
21336
|
return bestId;
|
|
21337
21337
|
}
|
|
21338
21338
|
function sleep3(ms) {
|
|
21339
|
-
return new Promise((
|
|
21339
|
+
return new Promise((resolve13) => setTimeout(resolve13, ms));
|
|
21340
21340
|
}
|
|
21341
21341
|
function joinTextParts(parts) {
|
|
21342
21342
|
if (!Array.isArray(parts)) return "";
|
|
@@ -21787,7 +21787,7 @@ async function link(args2 = []) {
|
|
|
21787
21787
|
waitSpin.start(waitMsg());
|
|
21788
21788
|
const countdown = setInterval(() => waitSpin.message(waitMsg()), 1e3);
|
|
21789
21789
|
countdown.unref?.();
|
|
21790
|
-
const paired = await new Promise((
|
|
21790
|
+
const paired = await new Promise((resolve13, reject) => {
|
|
21791
21791
|
let stopPoll = null;
|
|
21792
21792
|
const sigint = () => {
|
|
21793
21793
|
clearInterval(countdown);
|
|
@@ -21800,7 +21800,7 @@ async function link(args2 = []) {
|
|
|
21800
21800
|
process.removeListener("SIGINT", sigint);
|
|
21801
21801
|
clearInterval(countdown);
|
|
21802
21802
|
waitSpin.stop("Paired");
|
|
21803
|
-
|
|
21803
|
+
resolve13(info);
|
|
21804
21804
|
},
|
|
21805
21805
|
() => {
|
|
21806
21806
|
clearInterval(countdown);
|
|
@@ -21958,14 +21958,14 @@ async function captureFreshCredentials(ctx) {
|
|
|
21958
21958
|
}
|
|
21959
21959
|
};
|
|
21960
21960
|
try {
|
|
21961
|
-
const token = await new Promise((
|
|
21961
|
+
const token = await new Promise((resolve13, reject) => {
|
|
21962
21962
|
let settled = false;
|
|
21963
21963
|
const tryExtract = async () => {
|
|
21964
21964
|
if (settled) return;
|
|
21965
21965
|
const t2 = await ctx.locator.extract();
|
|
21966
21966
|
if (t2 && !settled) {
|
|
21967
21967
|
settled = true;
|
|
21968
|
-
|
|
21968
|
+
resolve13(t2);
|
|
21969
21969
|
}
|
|
21970
21970
|
};
|
|
21971
21971
|
watcher.on("add", () => void tryExtract());
|
|
@@ -22209,7 +22209,7 @@ function deliverPendingCoderabbitCallback(callbackUrl) {
|
|
|
22209
22209
|
function runCoderabbitOAuthLogin(deps) {
|
|
22210
22210
|
const timeoutMs = deps.timeoutMs ?? 18e4;
|
|
22211
22211
|
const spawnProc = deps.spawn ?? spawnCoderabbitLoginProc;
|
|
22212
|
-
return new Promise((
|
|
22212
|
+
return new Promise((resolve13) => {
|
|
22213
22213
|
let settled = false;
|
|
22214
22214
|
let stdout = "";
|
|
22215
22215
|
let last = null;
|
|
@@ -22222,13 +22222,13 @@ function runCoderabbitOAuthLogin(deps) {
|
|
|
22222
22222
|
child.kill("SIGKILL");
|
|
22223
22223
|
} catch {
|
|
22224
22224
|
}
|
|
22225
|
-
|
|
22225
|
+
resolve13(r);
|
|
22226
22226
|
};
|
|
22227
22227
|
let child;
|
|
22228
22228
|
try {
|
|
22229
22229
|
child = spawnProc("coderabbit", ["auth", "login", "--agent"]);
|
|
22230
22230
|
} catch (err) {
|
|
22231
|
-
|
|
22231
|
+
resolve13({ ok: false, error: err instanceof Error ? err.message : "spawn failed" });
|
|
22232
22232
|
return;
|
|
22233
22233
|
}
|
|
22234
22234
|
const timer = setTimeout(
|
|
@@ -22701,23 +22701,23 @@ async function reviewPullRequest(params, deps) {
|
|
|
22701
22701
|
return report;
|
|
22702
22702
|
}
|
|
22703
22703
|
function defaultRunGh(args2) {
|
|
22704
|
-
return new Promise((
|
|
22704
|
+
return new Promise((resolve13) => {
|
|
22705
22705
|
const stdout = [];
|
|
22706
22706
|
const stderr = [];
|
|
22707
22707
|
let proc;
|
|
22708
22708
|
try {
|
|
22709
22709
|
proc = (0, import_node_child_process17.spawn)("gh", args2, { stdio: ["ignore", "pipe", "pipe"] });
|
|
22710
22710
|
} catch (err) {
|
|
22711
|
-
|
|
22711
|
+
resolve13({ code: -1, stdout: "", stderr: err instanceof Error ? err.message : String(err) });
|
|
22712
22712
|
return;
|
|
22713
22713
|
}
|
|
22714
22714
|
proc.stdout?.on("data", (b) => stdout.push(b));
|
|
22715
22715
|
proc.stderr?.on("data", (b) => stderr.push(b));
|
|
22716
22716
|
proc.on("error", (err) => {
|
|
22717
|
-
|
|
22717
|
+
resolve13({ code: -1, stdout: "", stderr: err.message });
|
|
22718
22718
|
});
|
|
22719
22719
|
proc.on("close", (code) => {
|
|
22720
|
-
|
|
22720
|
+
resolve13({
|
|
22721
22721
|
code: code ?? 0,
|
|
22722
22722
|
stdout: Buffer.concat(stdout).toString("utf8"),
|
|
22723
22723
|
stderr: Buffer.concat(stderr).toString("utf8")
|
|
@@ -23037,7 +23037,7 @@ var import_node_fs11 = __toESM(require("fs"));
|
|
|
23037
23037
|
var import_node_path9 = __toESM(require("path"));
|
|
23038
23038
|
var import_yazl = require("yazl");
|
|
23039
23039
|
function buildZip(cwd, list, outFile) {
|
|
23040
|
-
return new Promise((
|
|
23040
|
+
return new Promise((resolve13, reject) => {
|
|
23041
23041
|
const zip = new import_yazl.ZipFile();
|
|
23042
23042
|
for (const f of list.files) {
|
|
23043
23043
|
const abs = import_node_path9.default.join(cwd, f.rel);
|
|
@@ -23047,7 +23047,7 @@ function buildZip(cwd, list, outFile) {
|
|
|
23047
23047
|
if (list.envExample) zip.addBuffer(Buffer.from(list.envExample), ".env.example");
|
|
23048
23048
|
const out2 = import_node_fs11.default.createWriteStream(outFile, { mode: 384 });
|
|
23049
23049
|
zip.outputStream.pipe(out2);
|
|
23050
|
-
out2.on("close", () =>
|
|
23050
|
+
out2.on("close", () => resolve13(import_node_fs11.default.statSync(outFile).size));
|
|
23051
23051
|
out2.on("error", reject);
|
|
23052
23052
|
zip.outputStream.on("error", reject);
|
|
23053
23053
|
zip.end();
|
|
@@ -23239,12 +23239,12 @@ async function isExecutableBinary(p2) {
|
|
|
23239
23239
|
}
|
|
23240
23240
|
}
|
|
23241
23241
|
function extractTgz(tgzPath, destDir) {
|
|
23242
|
-
return new Promise((
|
|
23242
|
+
return new Promise((resolve13, reject) => {
|
|
23243
23243
|
const child = (0, import_child_process14.spawn)("tar", ["-xzf", tgzPath, "-C", destDir], { stdio: "ignore" });
|
|
23244
23244
|
child.on("error", (err) => reject(err));
|
|
23245
23245
|
child.on(
|
|
23246
23246
|
"exit",
|
|
23247
|
-
(code) => code === 0 ?
|
|
23247
|
+
(code) => code === 0 ? resolve13() : reject(new Error(`tar exited with code ${code} while extracting cloudflared`))
|
|
23248
23248
|
);
|
|
23249
23249
|
});
|
|
23250
23250
|
}
|
|
@@ -23825,17 +23825,17 @@ function expoGoDeepLink(publicUrl) {
|
|
|
23825
23825
|
return `exps://${new URL(publicUrl).host}`;
|
|
23826
23826
|
}
|
|
23827
23827
|
function isExpoManifestServed(port, host2 = "127.0.0.1") {
|
|
23828
|
-
return new Promise((
|
|
23828
|
+
return new Promise((resolve13) => {
|
|
23829
23829
|
const req = http6.get(
|
|
23830
23830
|
{ host: host2, port, path: "/", headers: { "expo-platform": "ios" }, timeout: 1500 },
|
|
23831
23831
|
(res) => {
|
|
23832
23832
|
const ok = res.statusCode !== void 0 && res.statusCode >= 200 && res.statusCode < 300;
|
|
23833
23833
|
res.resume();
|
|
23834
|
-
|
|
23834
|
+
resolve13(ok);
|
|
23835
23835
|
}
|
|
23836
23836
|
);
|
|
23837
23837
|
req.once("timeout", () => req.destroy());
|
|
23838
|
-
req.once("error", () =>
|
|
23838
|
+
req.once("error", () => resolve13(false));
|
|
23839
23839
|
});
|
|
23840
23840
|
}
|
|
23841
23841
|
async function waitForExpoManifest(port, opts) {
|
|
@@ -23983,12 +23983,12 @@ function describeDetectionFailure(raw) {
|
|
|
23983
23983
|
// src/services/preview/port-ready.ts
|
|
23984
23984
|
var net = __toESM(require("net"));
|
|
23985
23985
|
function isPortListening(port, host2 = "127.0.0.1") {
|
|
23986
|
-
return new Promise((
|
|
23986
|
+
return new Promise((resolve13) => {
|
|
23987
23987
|
const socket = new net.Socket();
|
|
23988
23988
|
const done = (result) => {
|
|
23989
23989
|
socket.removeAllListeners();
|
|
23990
23990
|
socket.destroy();
|
|
23991
|
-
|
|
23991
|
+
resolve13(result);
|
|
23992
23992
|
};
|
|
23993
23993
|
socket.setTimeout(1e3);
|
|
23994
23994
|
socket.once("connect", () => done(true));
|
|
@@ -24026,14 +24026,14 @@ const { PGLiteSocketServer } = require('@electric-sql/pglite-socket');
|
|
|
24026
24026
|
})().catch((e) => { console.error(String(e && e.message)); process.exit(1); });
|
|
24027
24027
|
`;
|
|
24028
24028
|
function isListening(port) {
|
|
24029
|
-
return new Promise((
|
|
24029
|
+
return new Promise((resolve13) => {
|
|
24030
24030
|
const s = net2.connect({ host: "127.0.0.1", port }, () => {
|
|
24031
24031
|
s.destroy();
|
|
24032
|
-
|
|
24033
|
-
}).on("error", () =>
|
|
24032
|
+
resolve13(true);
|
|
24033
|
+
}).on("error", () => resolve13(false));
|
|
24034
24034
|
s.setTimeout(1e3, () => {
|
|
24035
24035
|
s.destroy();
|
|
24036
|
-
|
|
24036
|
+
resolve13(false);
|
|
24037
24037
|
});
|
|
24038
24038
|
});
|
|
24039
24039
|
}
|
|
@@ -24081,7 +24081,7 @@ function stopChild(child) {
|
|
|
24081
24081
|
// src/services/preview/run-setup.ts
|
|
24082
24082
|
var import_child_process18 = require("child_process");
|
|
24083
24083
|
function runSetupCommand(cmd, args2, cwd, env, opts) {
|
|
24084
|
-
return new Promise((
|
|
24084
|
+
return new Promise((resolve13) => {
|
|
24085
24085
|
const child = (0, import_child_process18.spawn)(cmd, args2, {
|
|
24086
24086
|
cwd,
|
|
24087
24087
|
env: { ...process.env, ...env ?? {} },
|
|
@@ -24101,20 +24101,20 @@ function runSetupCommand(cmd, args2, cwd, env, opts) {
|
|
|
24101
24101
|
settled = true;
|
|
24102
24102
|
log.info("preview", `${tag}: timed out after ${opts.timeoutMs}ms \u2014 killing`);
|
|
24103
24103
|
killQuiet(child);
|
|
24104
|
-
|
|
24104
|
+
resolve13({ status: "timeout", code: null });
|
|
24105
24105
|
}, opts.timeoutMs);
|
|
24106
24106
|
child.once("exit", (code) => {
|
|
24107
24107
|
if (settled) return;
|
|
24108
24108
|
settled = true;
|
|
24109
24109
|
clearTimeout(timer);
|
|
24110
|
-
if (code === 0)
|
|
24111
|
-
else
|
|
24110
|
+
if (code === 0) resolve13({ status: "ok", code: 0 });
|
|
24111
|
+
else resolve13({ status: "failed", code });
|
|
24112
24112
|
});
|
|
24113
24113
|
child.once("error", () => {
|
|
24114
24114
|
if (settled) return;
|
|
24115
24115
|
settled = true;
|
|
24116
24116
|
clearTimeout(timer);
|
|
24117
|
-
|
|
24117
|
+
resolve13({ status: "failed", code: null });
|
|
24118
24118
|
});
|
|
24119
24119
|
});
|
|
24120
24120
|
}
|
|
@@ -24570,23 +24570,23 @@ async function awaitTunnelRegistered(candidate, hostname3, deadlineMs) {
|
|
|
24570
24570
|
ac.signal.addEventListener("abort", detach, { once: true });
|
|
24571
24571
|
};
|
|
24572
24572
|
try {
|
|
24573
|
-
return await new Promise((
|
|
24573
|
+
return await new Promise((resolve13) => {
|
|
24574
24574
|
const onChunk = (chunk) => {
|
|
24575
24575
|
const s = chunk.toString();
|
|
24576
24576
|
if (!url2) url2 = parseCloudflaredUrl(s);
|
|
24577
24577
|
if (TUNNEL_REGISTERED_RE.test(s)) registered = true;
|
|
24578
24578
|
const trimmed = s.replace(/\n+$/g, "");
|
|
24579
24579
|
if (trimmed.length > 0) log.info("preview", `cloudflared: ${trimmed}`);
|
|
24580
|
-
if (url2 && registered)
|
|
24580
|
+
if (url2 && registered) resolve13({ kind: "registered", url: url2 });
|
|
24581
24581
|
};
|
|
24582
24582
|
const onExit = (code) => {
|
|
24583
|
-
|
|
24583
|
+
resolve13({ kind: "exited", sawUrl: url2 != null, code });
|
|
24584
24584
|
};
|
|
24585
24585
|
const { stdout, stderr } = candidate;
|
|
24586
24586
|
if (stdout) scoped(() => stdout.on("data", onChunk), () => stdout.off("data", onChunk));
|
|
24587
24587
|
if (stderr) scoped(() => stderr.on("data", onChunk), () => stderr.off("data", onChunk));
|
|
24588
24588
|
scoped(() => candidate.on("exit", onExit), () => candidate.off("exit", onExit));
|
|
24589
|
-
timer = setTimeout(() =>
|
|
24589
|
+
timer = setTimeout(() => resolve13({ kind: "timeout", sawUrl: url2 != null }), deadlineMs);
|
|
24590
24590
|
});
|
|
24591
24591
|
} finally {
|
|
24592
24592
|
ac.abort();
|
|
@@ -24609,7 +24609,7 @@ function verdictFor(res) {
|
|
|
24609
24609
|
}
|
|
24610
24610
|
return { adopt: true };
|
|
24611
24611
|
}
|
|
24612
|
-
var probePort = (port) => new Promise((
|
|
24612
|
+
var probePort = (port) => new Promise((resolve13) => {
|
|
24613
24613
|
const req = http7.get(
|
|
24614
24614
|
{ host: "127.0.0.1", port, path: "/", timeout: PROBE_TIMEOUT_MS },
|
|
24615
24615
|
(res) => {
|
|
@@ -24620,16 +24620,16 @@ var probePort = (port) => new Promise((resolve14) => {
|
|
|
24620
24620
|
});
|
|
24621
24621
|
res.on(
|
|
24622
24622
|
"end",
|
|
24623
|
-
() =>
|
|
24623
|
+
() => resolve13({ contentType: res.headers["content-type"], bodyStart: body })
|
|
24624
24624
|
);
|
|
24625
|
-
res.on("error", () =>
|
|
24625
|
+
res.on("error", () => resolve13(null));
|
|
24626
24626
|
}
|
|
24627
24627
|
);
|
|
24628
24628
|
req.on("timeout", () => {
|
|
24629
24629
|
req.destroy();
|
|
24630
|
-
|
|
24630
|
+
resolve13(null);
|
|
24631
24631
|
});
|
|
24632
|
-
req.on("error", () =>
|
|
24632
|
+
req.on("error", () => resolve13(null));
|
|
24633
24633
|
});
|
|
24634
24634
|
async function canAdoptPort(port, probe = probePort) {
|
|
24635
24635
|
try {
|
|
@@ -26044,18 +26044,18 @@ async function startInspectorProxy(opts) {
|
|
|
26044
26044
|
clientSocket.on("error", drop2);
|
|
26045
26045
|
clientSocket.on("close", drop2);
|
|
26046
26046
|
});
|
|
26047
|
-
await new Promise((
|
|
26047
|
+
await new Promise((resolve13, reject) => {
|
|
26048
26048
|
server.once("error", reject);
|
|
26049
|
-
server.listen(0, "127.0.0.1", () =>
|
|
26049
|
+
server.listen(0, "127.0.0.1", () => resolve13());
|
|
26050
26050
|
});
|
|
26051
26051
|
const port = server.address().port;
|
|
26052
26052
|
return {
|
|
26053
26053
|
port,
|
|
26054
|
-
close: () => new Promise((
|
|
26054
|
+
close: () => new Promise((resolve13) => {
|
|
26055
26055
|
for (const socket of upgraded) socket.destroy();
|
|
26056
26056
|
upgraded.clear();
|
|
26057
26057
|
server.closeAllConnections?.();
|
|
26058
|
-
server.close(() =>
|
|
26058
|
+
server.close(() => resolve13());
|
|
26059
26059
|
})
|
|
26060
26060
|
};
|
|
26061
26061
|
}
|
|
@@ -27139,12 +27139,12 @@ var _spawnSeam = {
|
|
|
27139
27139
|
run: _defaultSpawn
|
|
27140
27140
|
};
|
|
27141
27141
|
function _defaultSpawn(binaryPath, args2, opts) {
|
|
27142
|
-
return new Promise((
|
|
27142
|
+
return new Promise((resolve13) => {
|
|
27143
27143
|
let proc;
|
|
27144
27144
|
try {
|
|
27145
27145
|
proc = (0, import_child_process21.spawn)(binaryPath, args2, { cwd: opts.cwd, env: opts.env });
|
|
27146
27146
|
} catch (err) {
|
|
27147
|
-
|
|
27147
|
+
resolve13({ code: -1, stdout: "", stderr: err.message });
|
|
27148
27148
|
return;
|
|
27149
27149
|
}
|
|
27150
27150
|
let stdout = "";
|
|
@@ -27155,8 +27155,8 @@ function _defaultSpawn(binaryPath, args2, opts) {
|
|
|
27155
27155
|
proc.stderr?.on("data", (c2) => {
|
|
27156
27156
|
stderr += c2.toString();
|
|
27157
27157
|
});
|
|
27158
|
-
proc.on("error", (err) =>
|
|
27159
|
-
proc.on("close", (code) =>
|
|
27158
|
+
proc.on("error", (err) => resolve13({ code: -1, stdout, stderr: err.message }));
|
|
27159
|
+
proc.on("close", (code) => resolve13({ code: code ?? -1, stdout, stderr }));
|
|
27160
27160
|
});
|
|
27161
27161
|
}
|
|
27162
27162
|
var _adapterSeam = {
|
|
@@ -27333,22 +27333,22 @@ var _installSpawnSeam = {
|
|
|
27333
27333
|
run: _defaultInstallSpawn
|
|
27334
27334
|
};
|
|
27335
27335
|
function _defaultInstallSpawn(strategy) {
|
|
27336
|
-
return new Promise((
|
|
27336
|
+
return new Promise((resolve13) => {
|
|
27337
27337
|
let proc;
|
|
27338
27338
|
try {
|
|
27339
27339
|
proc = (0, import_child_process22.spawn)(strategy.command, strategy.args, { env: process.env });
|
|
27340
27340
|
} catch (err) {
|
|
27341
|
-
|
|
27341
|
+
resolve13({ ok: false, code: -1, stderr: err.message });
|
|
27342
27342
|
return;
|
|
27343
27343
|
}
|
|
27344
27344
|
let stderr = "";
|
|
27345
27345
|
proc.stderr?.on("data", (c2) => {
|
|
27346
27346
|
stderr += c2.toString();
|
|
27347
27347
|
});
|
|
27348
|
-
proc.on("error", (err) =>
|
|
27348
|
+
proc.on("error", (err) => resolve13({ ok: false, code: -1, stderr: err.message }));
|
|
27349
27349
|
proc.on(
|
|
27350
27350
|
"close",
|
|
27351
|
-
(code) =>
|
|
27351
|
+
(code) => resolve13({ ok: code === 0, code: code ?? -1, stderr })
|
|
27352
27352
|
);
|
|
27353
27353
|
});
|
|
27354
27354
|
}
|
|
@@ -27517,14 +27517,14 @@ var _doltInstallSpawnSeam = {
|
|
|
27517
27517
|
};
|
|
27518
27518
|
var DOLT_INSTALL_TIMEOUT_MS = 12e4;
|
|
27519
27519
|
function _defaultDoltInstallSpawn(strategy) {
|
|
27520
|
-
return new Promise((
|
|
27520
|
+
return new Promise((resolve13) => {
|
|
27521
27521
|
let settled = false;
|
|
27522
27522
|
let timer;
|
|
27523
27523
|
const finish = (r) => {
|
|
27524
27524
|
if (settled) return;
|
|
27525
27525
|
settled = true;
|
|
27526
27526
|
if (timer) clearTimeout(timer);
|
|
27527
|
-
|
|
27527
|
+
resolve13(r);
|
|
27528
27528
|
};
|
|
27529
27529
|
let proc;
|
|
27530
27530
|
try {
|
|
@@ -29407,16 +29407,16 @@ async function runNpmInstallLatest() {
|
|
|
29407
29407
|
const invocation = buildNpmInstallInvocation({ sudo: useSudo });
|
|
29408
29408
|
const useShell = process.platform === "win32";
|
|
29409
29409
|
const command2 = useShell && invocation.command.includes(" ") ? `"${invocation.command}"` : invocation.command;
|
|
29410
|
-
const result = await new Promise((
|
|
29410
|
+
const result = await new Promise((resolve13) => {
|
|
29411
29411
|
(0, import_child_process25.execFile)(
|
|
29412
29412
|
command2,
|
|
29413
29413
|
invocation.args,
|
|
29414
29414
|
{ timeout: CLI_UPDATE_INSTALL_TIMEOUT_MS, shell: useShell },
|
|
29415
29415
|
(err, _stdout, stderr) => {
|
|
29416
29416
|
if (!err) {
|
|
29417
|
-
|
|
29417
|
+
resolve13({ ok: true });
|
|
29418
29418
|
} else {
|
|
29419
|
-
|
|
29419
|
+
resolve13({ ok: false, error: (stderr || err.message).slice(0, 300) });
|
|
29420
29420
|
}
|
|
29421
29421
|
}
|
|
29422
29422
|
);
|
|
@@ -29769,8 +29769,8 @@ async function runDetectOneShot(generate, timeoutMs = PREVIEW_DETECT_TIMEOUT_MS)
|
|
|
29769
29769
|
};
|
|
29770
29770
|
const onFailedOutput = (stdout) => onStderr(`
|
|
29771
29771
|
${stdout}`);
|
|
29772
|
-
const deadline = new Promise((
|
|
29773
|
-
timer = setTimeout(() =>
|
|
29772
|
+
const deadline = new Promise((resolve13) => {
|
|
29773
|
+
timer = setTimeout(() => resolve13({ raw: null, timedOut: true, stderr }), timeoutMs);
|
|
29774
29774
|
timer.unref?.();
|
|
29775
29775
|
});
|
|
29776
29776
|
const oneShot = generate(PREVIEW_DETECT_PROMPT, { timeoutMs, onStderr, onFailedOutput }).then(
|
|
@@ -30238,7 +30238,7 @@ function buildKeepAlive(ctx) {
|
|
|
30238
30238
|
let timer = null;
|
|
30239
30239
|
async function setIdleTimeout(minutes) {
|
|
30240
30240
|
if (!ctx.inCodespace || !ctx.codespaceName) return;
|
|
30241
|
-
await new Promise((
|
|
30241
|
+
await new Promise((resolve13) => {
|
|
30242
30242
|
const proc = (0, import_child_process26.spawn)(
|
|
30243
30243
|
"gh",
|
|
30244
30244
|
[
|
|
@@ -30252,8 +30252,8 @@ function buildKeepAlive(ctx) {
|
|
|
30252
30252
|
{ stdio: "ignore", detached: true }
|
|
30253
30253
|
);
|
|
30254
30254
|
proc.unref();
|
|
30255
|
-
proc.on("exit", () =>
|
|
30256
|
-
proc.on("error", () =>
|
|
30255
|
+
proc.on("exit", () => resolve13());
|
|
30256
|
+
proc.on("error", () => resolve13());
|
|
30257
30257
|
});
|
|
30258
30258
|
}
|
|
30259
30259
|
return {
|
|
@@ -31210,10 +31210,10 @@ function augmentKimiPath() {
|
|
|
31210
31210
|
}
|
|
31211
31211
|
var augmentPath2 = augmentKimiPath;
|
|
31212
31212
|
async function runInstaller2() {
|
|
31213
|
-
return new Promise((
|
|
31213
|
+
return new Promise((resolve13) => {
|
|
31214
31214
|
const proc = (0, import_node_child_process25.spawn)("sh", ["-c", `curl -fsSL ${INSTALL_URL2} | bash`], { stdio: "inherit" });
|
|
31215
|
-
proc.on("close", (code) =>
|
|
31216
|
-
proc.on("error", () =>
|
|
31215
|
+
proc.on("close", (code) => resolve13(code === 0));
|
|
31216
|
+
proc.on("error", () => resolve13(false));
|
|
31217
31217
|
});
|
|
31218
31218
|
}
|
|
31219
31219
|
async function ensureKimiInstalled() {
|
|
@@ -31263,10 +31263,10 @@ function augmentOpencodePath() {
|
|
|
31263
31263
|
}
|
|
31264
31264
|
var augmentPath3 = augmentOpencodePath;
|
|
31265
31265
|
async function runInstaller3() {
|
|
31266
|
-
return new Promise((
|
|
31266
|
+
return new Promise((resolve13) => {
|
|
31267
31267
|
const proc = (0, import_node_child_process26.spawn)("sh", ["-c", `curl -fsSL ${INSTALL_URL3} | bash`], { stdio: "inherit" });
|
|
31268
|
-
proc.on("close", (code) =>
|
|
31269
|
-
proc.on("error", () =>
|
|
31268
|
+
proc.on("close", (code) => resolve13(code === 0));
|
|
31269
|
+
proc.on("error", () => resolve13(false));
|
|
31270
31270
|
});
|
|
31271
31271
|
}
|
|
31272
31272
|
async function ensureOpencodeInstalled() {
|
|
@@ -31474,11 +31474,11 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
|
|
|
31474
31474
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_ADAPTER_RETRY_TIMEOUT_MS;
|
|
31475
31475
|
const pollMs = opts.pollMs ?? DEFAULT_ADAPTER_RETRY_POLL_MS;
|
|
31476
31476
|
const now = opts.now ?? Date.now;
|
|
31477
|
-
const sleep5 = opts.sleep ?? ((ms) => new Promise((
|
|
31478
|
-
const
|
|
31477
|
+
const sleep5 = opts.sleep ?? ((ms) => new Promise((resolve14) => setTimeout(resolve14, ms)));
|
|
31478
|
+
const resolve13 = opts.resolve ?? getAcpAdapter;
|
|
31479
31479
|
const attempt = () => {
|
|
31480
31480
|
try {
|
|
31481
|
-
return
|
|
31481
|
+
return resolve13(agent);
|
|
31482
31482
|
} catch {
|
|
31483
31483
|
return null;
|
|
31484
31484
|
}
|
|
@@ -31709,7 +31709,7 @@ function parseJsonl(filePath) {
|
|
|
31709
31709
|
return messages;
|
|
31710
31710
|
}
|
|
31711
31711
|
function postWithStatus(endpoint, body, pluginAuthToken) {
|
|
31712
|
-
return new Promise((
|
|
31712
|
+
return new Promise((resolve13) => {
|
|
31713
31713
|
const payload = JSON.stringify(body);
|
|
31714
31714
|
const u2 = new URL(`${API_BASE7}${endpoint}`);
|
|
31715
31715
|
const transport = u2.protocol === "https:" ? https6 : http10;
|
|
@@ -31740,17 +31740,17 @@ function postWithStatus(endpoint, body, pluginAuthToken) {
|
|
|
31740
31740
|
const ra = Number(res.headers["retry-after"]);
|
|
31741
31741
|
retryAfterMs = Number.isFinite(ra) && ra > 0 ? ra * 1e3 : 2e4;
|
|
31742
31742
|
}
|
|
31743
|
-
|
|
31743
|
+
resolve13({ ok, status: status2, retryAfterMs });
|
|
31744
31744
|
}
|
|
31745
31745
|
);
|
|
31746
31746
|
req.on("error", (err) => {
|
|
31747
31747
|
log.warn("history:post", `${endpoint} network error`, err);
|
|
31748
|
-
|
|
31748
|
+
resolve13({ ok: false, status: null, retryAfterMs: null });
|
|
31749
31749
|
});
|
|
31750
31750
|
req.on("timeout", () => {
|
|
31751
31751
|
log.warn("history:post", `${endpoint} timeout after 15s`);
|
|
31752
31752
|
req.destroy();
|
|
31753
|
-
|
|
31753
|
+
resolve13({ ok: false, status: null, retryAfterMs: null });
|
|
31754
31754
|
});
|
|
31755
31755
|
req.write(payload);
|
|
31756
31756
|
req.end();
|
|
@@ -34324,12 +34324,12 @@ var Connection = class {
|
|
|
34324
34324
|
const id = this.nextRequestId++;
|
|
34325
34325
|
let cancel = () => {
|
|
34326
34326
|
};
|
|
34327
|
-
const responsePromise = new Promise((
|
|
34327
|
+
const responsePromise = new Promise((resolve13, reject) => {
|
|
34328
34328
|
const pendingResponse = {
|
|
34329
34329
|
resolve: (response) => {
|
|
34330
34330
|
try {
|
|
34331
34331
|
const value = mapResponse ? mapResponse(response) : response;
|
|
34332
|
-
|
|
34332
|
+
resolve13(value);
|
|
34333
34333
|
} catch (error) {
|
|
34334
34334
|
reject(error);
|
|
34335
34335
|
}
|
|
@@ -34407,8 +34407,8 @@ var Connection = class {
|
|
|
34407
34407
|
initialize(stream, handlers2) {
|
|
34408
34408
|
this.stream = stream;
|
|
34409
34409
|
this.staticHandlers = handlers2;
|
|
34410
|
-
this.closedPromise = new Promise((
|
|
34411
|
-
this.abortController.signal.addEventListener("abort", () =>
|
|
34410
|
+
this.closedPromise = new Promise((resolve13) => {
|
|
34411
|
+
this.abortController.signal.addEventListener("abort", () => resolve13());
|
|
34412
34412
|
});
|
|
34413
34413
|
void this.receive();
|
|
34414
34414
|
}
|
|
@@ -35196,8 +35196,8 @@ var AsyncQueue = class {
|
|
|
35196
35196
|
if (this.failed) {
|
|
35197
35197
|
return Promise.reject(this.failure);
|
|
35198
35198
|
}
|
|
35199
|
-
return new Promise((
|
|
35200
|
-
this.waiters.push({ resolve:
|
|
35199
|
+
return new Promise((resolve13, reject) => {
|
|
35200
|
+
this.waiters.push({ resolve: resolve13, reject });
|
|
35201
35201
|
});
|
|
35202
35202
|
}
|
|
35203
35203
|
};
|
|
@@ -36889,7 +36889,7 @@ var AcpClient = class {
|
|
|
36889
36889
|
this.pendingToolCalls.clear();
|
|
36890
36890
|
try {
|
|
36891
36891
|
const result = await Promise.race([send, idle.promise]);
|
|
36892
|
-
await new Promise((
|
|
36892
|
+
await new Promise((resolve13) => setImmediate(resolve13));
|
|
36893
36893
|
log.info(
|
|
36894
36894
|
"acpClient",
|
|
36895
36895
|
`prompt \u2190 ok stopReason=${result.stopReason ?? "?"} elapsedMs=${Date.now() - t0}`
|
|
@@ -37105,8 +37105,8 @@ var AcpClient = class {
|
|
|
37105
37105
|
if (!this.connection || !this.sessionId) return "deferred";
|
|
37106
37106
|
this.mcpReprovisionPending = servers;
|
|
37107
37107
|
if (this.mcpDebounceTimer) clearTimeout(this.mcpDebounceTimer);
|
|
37108
|
-
const settled = new Promise((
|
|
37109
|
-
this.mcpDebounceWaiters.push(
|
|
37108
|
+
const settled = new Promise((resolve13) => {
|
|
37109
|
+
this.mcpDebounceWaiters.push(resolve13);
|
|
37110
37110
|
});
|
|
37111
37111
|
this.mcpDebounceTimer = setTimeout(() => {
|
|
37112
37112
|
this.mcpDebounceTimer = null;
|
|
@@ -37350,15 +37350,15 @@ var AcpClient = class {
|
|
|
37350
37350
|
} else {
|
|
37351
37351
|
child.kill("SIGTERM");
|
|
37352
37352
|
}
|
|
37353
|
-
const grace = new Promise((
|
|
37353
|
+
const grace = new Promise((resolve13) => {
|
|
37354
37354
|
const t2 = setTimeout(() => {
|
|
37355
37355
|
if (process.platform !== "win32" && pid) killQuiet(-pid, "SIGKILL");
|
|
37356
37356
|
else killQuiet(child, "SIGKILL");
|
|
37357
|
-
|
|
37357
|
+
resolve13();
|
|
37358
37358
|
}, 2e3);
|
|
37359
37359
|
child.once("exit", () => {
|
|
37360
37360
|
clearTimeout(t2);
|
|
37361
|
-
|
|
37361
|
+
resolve13();
|
|
37362
37362
|
});
|
|
37363
37363
|
});
|
|
37364
37364
|
await grace;
|
|
@@ -37587,7 +37587,7 @@ var os52 = __toESM(require("os"));
|
|
|
37587
37587
|
function runAgentInstallScript(script, opts = {}) {
|
|
37588
37588
|
const timeoutMs = opts.timeoutMs ?? 18e4;
|
|
37589
37589
|
const scope = opts.logScope ?? "agent-install";
|
|
37590
|
-
return new Promise((
|
|
37590
|
+
return new Promise((resolve13) => {
|
|
37591
37591
|
const home = process.env.HOME || os52.homedir();
|
|
37592
37592
|
const child = (0, import_child_process27.spawn)("sh", ["-c", script], {
|
|
37593
37593
|
env: { ...process.env, HOME: home },
|
|
@@ -37603,7 +37603,7 @@ function runAgentInstallScript(script, opts = {}) {
|
|
|
37603
37603
|
const done = (result) => {
|
|
37604
37604
|
if (settled) return;
|
|
37605
37605
|
settled = true;
|
|
37606
|
-
|
|
37606
|
+
resolve13(result);
|
|
37607
37607
|
};
|
|
37608
37608
|
const timer = setTimeout(() => {
|
|
37609
37609
|
log.warn(scope, `agent install timed out (${Math.round(timeoutMs / 1e3)}s)`);
|
|
@@ -38216,7 +38216,7 @@ var _transport4 = {
|
|
|
38216
38216
|
get: _get
|
|
38217
38217
|
};
|
|
38218
38218
|
function _post3(url2, headers, payload) {
|
|
38219
|
-
return new Promise((
|
|
38219
|
+
return new Promise((resolve13, reject) => {
|
|
38220
38220
|
let settled = false;
|
|
38221
38221
|
const u2 = new URL(url2);
|
|
38222
38222
|
const lib = u2.protocol === "https:" ? https7 : http11;
|
|
@@ -38241,7 +38241,7 @@ function _post3(url2, headers, payload) {
|
|
|
38241
38241
|
res.on("end", () => {
|
|
38242
38242
|
if (settled) return;
|
|
38243
38243
|
settled = true;
|
|
38244
|
-
|
|
38244
|
+
resolve13({ statusCode: res.statusCode ?? 0, body });
|
|
38245
38245
|
});
|
|
38246
38246
|
}
|
|
38247
38247
|
);
|
|
@@ -38258,7 +38258,7 @@ function _post3(url2, headers, payload) {
|
|
|
38258
38258
|
});
|
|
38259
38259
|
}
|
|
38260
38260
|
function _get(url2, headers) {
|
|
38261
|
-
return new Promise((
|
|
38261
|
+
return new Promise((resolve13, reject) => {
|
|
38262
38262
|
let settled = false;
|
|
38263
38263
|
const u2 = new URL(url2);
|
|
38264
38264
|
const lib = u2.protocol === "https:" ? https7 : http11;
|
|
@@ -38282,7 +38282,7 @@ function _get(url2, headers) {
|
|
|
38282
38282
|
res.on("end", () => {
|
|
38283
38283
|
if (settled) return;
|
|
38284
38284
|
settled = true;
|
|
38285
|
-
|
|
38285
|
+
resolve13({ statusCode: res.statusCode ?? 0, body });
|
|
38286
38286
|
});
|
|
38287
38287
|
}
|
|
38288
38288
|
);
|
|
@@ -39513,12 +39513,12 @@ function runGit3(cwd, args2) {
|
|
|
39513
39513
|
return _runGitImpl2.run(cwd, args2);
|
|
39514
39514
|
}
|
|
39515
39515
|
function defaultRunGit(cwd, args2) {
|
|
39516
|
-
return new Promise((
|
|
39516
|
+
return new Promise((resolve13) => {
|
|
39517
39517
|
let proc;
|
|
39518
39518
|
try {
|
|
39519
39519
|
proc = (0, import_child_process29.spawn)("git", args2, { cwd, env: process.env });
|
|
39520
39520
|
} catch {
|
|
39521
|
-
|
|
39521
|
+
resolve13(null);
|
|
39522
39522
|
return;
|
|
39523
39523
|
}
|
|
39524
39524
|
let stdout = "";
|
|
@@ -39529,16 +39529,16 @@ function defaultRunGit(cwd, args2) {
|
|
|
39529
39529
|
proc.stderr?.on("data", (c2) => {
|
|
39530
39530
|
stderr += c2.toString();
|
|
39531
39531
|
});
|
|
39532
|
-
proc.on("error", () =>
|
|
39532
|
+
proc.on("error", () => resolve13(null));
|
|
39533
39533
|
proc.on("close", (code) => {
|
|
39534
39534
|
if (code === 0) {
|
|
39535
|
-
|
|
39535
|
+
resolve13(stdout);
|
|
39536
39536
|
} else {
|
|
39537
39537
|
log.trace(
|
|
39538
39538
|
"turnFiles",
|
|
39539
39539
|
`git ${args2.join(" ")} exited ${code} stderr=${stderr.slice(0, 200)}`
|
|
39540
39540
|
);
|
|
39541
|
-
|
|
39541
|
+
resolve13(null);
|
|
39542
39542
|
}
|
|
39543
39543
|
});
|
|
39544
39544
|
});
|
|
@@ -39955,25 +39955,25 @@ function baselineKey(entry) {
|
|
|
39955
39955
|
|
|
39956
39956
|
// src/agents/acp/withTimeout.ts
|
|
39957
39957
|
function withTimeout(p2, ms) {
|
|
39958
|
-
return new Promise((
|
|
39958
|
+
return new Promise((resolve13) => {
|
|
39959
39959
|
let settled = false;
|
|
39960
39960
|
const timer = setTimeout(() => {
|
|
39961
39961
|
if (settled) return;
|
|
39962
39962
|
settled = true;
|
|
39963
|
-
|
|
39963
|
+
resolve13(void 0);
|
|
39964
39964
|
}, ms);
|
|
39965
39965
|
p2.then(
|
|
39966
39966
|
(v) => {
|
|
39967
39967
|
if (settled) return;
|
|
39968
39968
|
settled = true;
|
|
39969
39969
|
clearTimeout(timer);
|
|
39970
|
-
|
|
39970
|
+
resolve13(v);
|
|
39971
39971
|
},
|
|
39972
39972
|
() => {
|
|
39973
39973
|
if (settled) return;
|
|
39974
39974
|
settled = true;
|
|
39975
39975
|
clearTimeout(timer);
|
|
39976
|
-
|
|
39976
|
+
resolve13(void 0);
|
|
39977
39977
|
}
|
|
39978
39978
|
);
|
|
39979
39979
|
});
|
|
@@ -40142,7 +40142,7 @@ function isProcessMidTurn(pid, home) {
|
|
|
40142
40142
|
var import_node_child_process28 = require("child_process");
|
|
40143
40143
|
var fs80 = __toESM(require("fs"));
|
|
40144
40144
|
var path90 = __toESM(require("path"));
|
|
40145
|
-
var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((
|
|
40145
|
+
var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((resolve13) => {
|
|
40146
40146
|
(0, import_node_child_process28.execFile)(
|
|
40147
40147
|
file,
|
|
40148
40148
|
args2,
|
|
@@ -40158,7 +40158,7 @@ var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((re
|
|
|
40158
40158
|
const rawCode = err.code;
|
|
40159
40159
|
code = typeof rawCode === "number" ? rawCode : 1;
|
|
40160
40160
|
}
|
|
40161
|
-
|
|
40161
|
+
resolve13({ code, stdout: stdout ?? "", stderr: stderr ?? "" });
|
|
40162
40162
|
}
|
|
40163
40163
|
);
|
|
40164
40164
|
});
|
|
@@ -41800,24 +41800,24 @@ var AgentPreviewBridge = class {
|
|
|
41800
41800
|
* preview tools are then simply absent, never a failed session. */
|
|
41801
41801
|
listen() {
|
|
41802
41802
|
if (this.listening) return this.listening;
|
|
41803
|
-
this.listening = new Promise((
|
|
41803
|
+
this.listening = new Promise((resolve13) => {
|
|
41804
41804
|
const server = http12.createServer((req, res) => {
|
|
41805
41805
|
void this.handle(req, res);
|
|
41806
41806
|
});
|
|
41807
41807
|
server.on("error", (err) => {
|
|
41808
41808
|
log.warn("agent-preview", `bridge failed to listen: ${String(err)}`);
|
|
41809
|
-
|
|
41809
|
+
resolve13(null);
|
|
41810
41810
|
});
|
|
41811
41811
|
server.listen(0, "127.0.0.1", () => {
|
|
41812
41812
|
const addr = server.address();
|
|
41813
41813
|
if (!addr || typeof addr === "string") {
|
|
41814
|
-
|
|
41814
|
+
resolve13(null);
|
|
41815
41815
|
return;
|
|
41816
41816
|
}
|
|
41817
41817
|
server.unref();
|
|
41818
41818
|
this.server = server;
|
|
41819
41819
|
this.bound = { url: `http://127.0.0.1:${addr.port}`, token: this.token };
|
|
41820
|
-
|
|
41820
|
+
resolve13(this.bound);
|
|
41821
41821
|
});
|
|
41822
41822
|
});
|
|
41823
41823
|
return this.listening;
|
|
@@ -41854,9 +41854,9 @@ var AgentPreviewBridge = class {
|
|
|
41854
41854
|
}
|
|
41855
41855
|
const inflight = this.inflight;
|
|
41856
41856
|
let timer;
|
|
41857
|
-
const pending2 = new Promise((
|
|
41857
|
+
const pending2 = new Promise((resolve13) => {
|
|
41858
41858
|
timer = setTimeout(
|
|
41859
|
-
() =>
|
|
41859
|
+
() => resolve13({
|
|
41860
41860
|
status: "starting",
|
|
41861
41861
|
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."
|
|
41862
41862
|
}),
|
|
@@ -42059,7 +42059,7 @@ function authorized(header, token) {
|
|
|
42059
42059
|
return presented.length === expected.length && (0, import_node_crypto14.timingSafeEqual)(presented, expected);
|
|
42060
42060
|
}
|
|
42061
42061
|
function readJson(req) {
|
|
42062
|
-
return new Promise((
|
|
42062
|
+
return new Promise((resolve13, reject) => {
|
|
42063
42063
|
let raw = "";
|
|
42064
42064
|
req.setEncoding("utf8");
|
|
42065
42065
|
req.on("data", (chunk) => {
|
|
@@ -42070,10 +42070,10 @@ function readJson(req) {
|
|
|
42070
42070
|
}
|
|
42071
42071
|
});
|
|
42072
42072
|
req.on("end", () => {
|
|
42073
|
-
if (!raw) return
|
|
42073
|
+
if (!raw) return resolve13({});
|
|
42074
42074
|
try {
|
|
42075
42075
|
const parsed = JSON.parse(raw);
|
|
42076
|
-
|
|
42076
|
+
resolve13(parsed && typeof parsed === "object" ? parsed : {});
|
|
42077
42077
|
} catch {
|
|
42078
42078
|
reject(new Error("invalid JSON"));
|
|
42079
42079
|
}
|
|
@@ -43200,15 +43200,15 @@ async function prewarmNewMcpEntries(manifest, previousIds) {
|
|
|
43200
43200
|
);
|
|
43201
43201
|
await Promise.all(
|
|
43202
43202
|
fresh.map(
|
|
43203
|
-
(e) => new Promise((
|
|
43203
|
+
(e) => new Promise((resolve13) => {
|
|
43204
43204
|
const mcp = e.delivery.mcp;
|
|
43205
43205
|
const child = (0, import_node_child_process29.execFile)(
|
|
43206
43206
|
mcp.command,
|
|
43207
43207
|
[...mcp.args, "--help"],
|
|
43208
43208
|
{ timeout: 9e4 },
|
|
43209
|
-
() =>
|
|
43209
|
+
() => resolve13()
|
|
43210
43210
|
);
|
|
43211
|
-
child.on("error", () =>
|
|
43211
|
+
child.on("error", () => resolve13());
|
|
43212
43212
|
})
|
|
43213
43213
|
)
|
|
43214
43214
|
);
|
|
@@ -43475,7 +43475,7 @@ var StreamingState = class {
|
|
|
43475
43475
|
* protested "J'ai rien refusé". The line is the user's evidence.
|
|
43476
43476
|
*/
|
|
43477
43477
|
registerPermission(args2) {
|
|
43478
|
-
return new Promise((
|
|
43478
|
+
return new Promise((resolve13) => {
|
|
43479
43479
|
const timeoutTimer = setTimeout(() => {
|
|
43480
43480
|
if (this.pending?.kind === "permission" && this.pending.questionId === args2.questionId) {
|
|
43481
43481
|
log.warn(
|
|
@@ -43488,14 +43488,14 @@ var StreamingState = class {
|
|
|
43488
43488
|
content: permissionExpiredNotice(),
|
|
43489
43489
|
done: true
|
|
43490
43490
|
});
|
|
43491
|
-
|
|
43491
|
+
resolve13({ outcome: { outcome: "cancelled" } });
|
|
43492
43492
|
}
|
|
43493
43493
|
}, PERMISSION_TIMEOUT_MS);
|
|
43494
43494
|
this.setPending({
|
|
43495
43495
|
kind: "permission",
|
|
43496
43496
|
questionId: args2.questionId,
|
|
43497
43497
|
options: args2.options,
|
|
43498
|
-
resolve:
|
|
43498
|
+
resolve: resolve13,
|
|
43499
43499
|
timeoutTimer
|
|
43500
43500
|
});
|
|
43501
43501
|
});
|
|
@@ -43532,14 +43532,14 @@ var StreamingState = class {
|
|
|
43532
43532
|
const byId = optionId ? this.pending.options.find((o) => o.optionId === optionId) : void 0;
|
|
43533
43533
|
const picked = byId ?? this.pending.options[index];
|
|
43534
43534
|
clearTimeout(this.pending.timeoutTimer);
|
|
43535
|
-
const
|
|
43535
|
+
const resolve13 = this.pending.resolve;
|
|
43536
43536
|
this.setPending(null);
|
|
43537
43537
|
if (!picked) {
|
|
43538
43538
|
log.warn("acpRunner", `select_option index=${index} out of bounds \u2014 cancel`);
|
|
43539
|
-
|
|
43539
|
+
resolve13({ outcome: { outcome: "cancelled" } });
|
|
43540
43540
|
return { kind: "resolved", optionId: null };
|
|
43541
43541
|
}
|
|
43542
|
-
|
|
43542
|
+
resolve13({ outcome: { outcome: "selected", optionId: picked.optionId } });
|
|
43543
43543
|
return { kind: "resolved", optionId: picked.optionId };
|
|
43544
43544
|
}
|
|
43545
43545
|
const text = this.pending.options[index];
|
|
@@ -46140,10 +46140,10 @@ var NativeTuiDriver = class _NativeTuiDriver {
|
|
|
46140
46140
|
this.lastOutput = this.now();
|
|
46141
46141
|
}
|
|
46142
46142
|
whenSafeToYield() {
|
|
46143
|
-
return new Promise((
|
|
46143
|
+
return new Promise((resolve13) => {
|
|
46144
46144
|
const tick = () => {
|
|
46145
46145
|
const quietFor = this.now() - this.lastOutput;
|
|
46146
|
-
if (quietFor >= this.idleMs)
|
|
46146
|
+
if (quietFor >= this.idleMs) resolve13();
|
|
46147
46147
|
else setTimeout(tick, this.idleMs - quietFor);
|
|
46148
46148
|
};
|
|
46149
46149
|
tick();
|
|
@@ -46206,10 +46206,10 @@ var AcpDriver = class {
|
|
|
46206
46206
|
* one ever is, assume resumable so behaviour is unchanged.
|
|
46207
46207
|
*/
|
|
46208
46208
|
hasTranscript(conversationId) {
|
|
46209
|
-
const
|
|
46210
|
-
if (typeof
|
|
46209
|
+
const resolve13 = this.deps.runtime.resolveHistoryFile;
|
|
46210
|
+
if (typeof resolve13 !== "function") return true;
|
|
46211
46211
|
try {
|
|
46212
|
-
return
|
|
46212
|
+
return resolve13.call(this.deps.runtime, this.deps.opts.cwd, conversationId) !== null;
|
|
46213
46213
|
} catch {
|
|
46214
46214
|
return true;
|
|
46215
46215
|
}
|
|
@@ -46273,11 +46273,11 @@ var AcpDriver = class {
|
|
|
46273
46273
|
this.turnActive = false;
|
|
46274
46274
|
const waiters = this.waiters;
|
|
46275
46275
|
this.waiters = [];
|
|
46276
|
-
waiters.forEach((
|
|
46276
|
+
waiters.forEach((resolve13) => resolve13());
|
|
46277
46277
|
}
|
|
46278
46278
|
whenSafeToYield() {
|
|
46279
46279
|
if (!this.turnActive) return Promise.resolve();
|
|
46280
|
-
return new Promise((
|
|
46280
|
+
return new Promise((resolve13) => this.waiters.push(resolve13));
|
|
46281
46281
|
}
|
|
46282
46282
|
};
|
|
46283
46283
|
|
|
@@ -46870,8 +46870,8 @@ async function start(requestedAgent, presetSession) {
|
|
|
46870
46870
|
const releaseStartupMark = markAgentStarting();
|
|
46871
46871
|
process.once("exit", releaseStartupMark);
|
|
46872
46872
|
let settleOwnHandshake = () => void 0;
|
|
46873
|
-
const ownHandshakeSettled = new Promise((
|
|
46874
|
-
settleOwnHandshake =
|
|
46873
|
+
const ownHandshakeSettled = new Promise((resolve13) => {
|
|
46874
|
+
settleOwnHandshake = resolve13;
|
|
46875
46875
|
});
|
|
46876
46876
|
const releaseBeads = () => {
|
|
46877
46877
|
releaseStartupMark();
|
|
@@ -46881,7 +46881,7 @@ async function start(requestedAgent, presetSession) {
|
|
|
46881
46881
|
ownHandshakeSettled.then(
|
|
46882
46882
|
() => waitForNoAgentStarting({ timeoutMs: BEADS_AFTER_HANDSHAKE_CAP_MS })
|
|
46883
46883
|
),
|
|
46884
|
-
new Promise((
|
|
46884
|
+
new Promise((resolve13) => setTimeout(resolve13, BEADS_AFTER_HANDSHAKE_CAP_MS).unref())
|
|
46885
46885
|
]);
|
|
46886
46886
|
const beadsReady = provisionBeadsForStart({
|
|
46887
46887
|
sessionId: session.id,
|
|
@@ -46953,8 +46953,8 @@ async function start(requestedAgent, presetSession) {
|
|
|
46953
46953
|
let gateTimer;
|
|
46954
46954
|
await Promise.race([
|
|
46955
46955
|
Promise.all([depsReady, agentBinaryReady]),
|
|
46956
|
-
new Promise((
|
|
46957
|
-
gateTimer = setTimeout(
|
|
46956
|
+
new Promise((resolve13) => {
|
|
46957
|
+
gateTimer = setTimeout(resolve13, GATE_TIMEOUT_MS);
|
|
46958
46958
|
})
|
|
46959
46959
|
]);
|
|
46960
46960
|
if (gateTimer) clearTimeout(gateTimer);
|
|
@@ -47338,7 +47338,7 @@ async function pair(args2 = []) {
|
|
|
47338
47338
|
waitSpin.message(waitMessage());
|
|
47339
47339
|
}, 1e3);
|
|
47340
47340
|
countdownInterval.unref?.();
|
|
47341
|
-
await new Promise((
|
|
47341
|
+
await new Promise((resolve13) => {
|
|
47342
47342
|
let stopPolling = null;
|
|
47343
47343
|
function sigintHandler() {
|
|
47344
47344
|
clearInterval(countdownInterval);
|
|
@@ -47389,7 +47389,7 @@ async function pair(args2 = []) {
|
|
|
47389
47389
|
pluginAuthToken: info.pluginAuthToken
|
|
47390
47390
|
});
|
|
47391
47391
|
}
|
|
47392
|
-
|
|
47392
|
+
resolve13();
|
|
47393
47393
|
},
|
|
47394
47394
|
() => {
|
|
47395
47395
|
clearInterval(countdownInterval);
|
|
@@ -47618,12 +47618,12 @@ var GitHubCodespacesProvider = class {
|
|
|
47618
47618
|
}
|
|
47619
47619
|
if (!isAuthed) {
|
|
47620
47620
|
resetStdinForChild();
|
|
47621
|
-
await new Promise((
|
|
47621
|
+
await new Promise((resolve13, reject) => {
|
|
47622
47622
|
const proc = (0, import_child_process30.spawn)("gh", ["auth", "login", "-s", "codespace,repo,read:user"], {
|
|
47623
47623
|
stdio: "inherit"
|
|
47624
47624
|
});
|
|
47625
47625
|
proc.on("exit", (code) => {
|
|
47626
|
-
if (code === 0)
|
|
47626
|
+
if (code === 0) resolve13();
|
|
47627
47627
|
else reject(new Error("gh auth login failed."));
|
|
47628
47628
|
});
|
|
47629
47629
|
proc.on("error", reject);
|
|
@@ -47652,13 +47652,13 @@ var GitHubCodespacesProvider = class {
|
|
|
47652
47652
|
}
|
|
47653
47653
|
wt(noteLines.join("\n"), "One more permission needed");
|
|
47654
47654
|
resetStdinForChild();
|
|
47655
|
-
const refreshCode = await new Promise((
|
|
47655
|
+
const refreshCode = await new Promise((resolve13, reject) => {
|
|
47656
47656
|
const proc = (0, import_child_process30.spawn)(
|
|
47657
47657
|
"gh",
|
|
47658
47658
|
["auth", "refresh", "-h", "github.com", "-s", "codespace"],
|
|
47659
47659
|
{ stdio: "inherit" }
|
|
47660
47660
|
);
|
|
47661
|
-
proc.on("exit", (code) =>
|
|
47661
|
+
proc.on("exit", (code) => resolve13(code ?? 1));
|
|
47662
47662
|
proc.on("error", reject);
|
|
47663
47663
|
});
|
|
47664
47664
|
if (refreshCode !== 0) {
|
|
@@ -47802,10 +47802,10 @@ var GitHubCodespacesProvider = class {
|
|
|
47802
47802
|
if (q(proceed) || !proceed) return;
|
|
47803
47803
|
O2.step(`Installing gh via ${installCmd.describe}\u2026`);
|
|
47804
47804
|
resetStdinForChild();
|
|
47805
|
-
const ok = await new Promise((
|
|
47805
|
+
const ok = await new Promise((resolve13) => {
|
|
47806
47806
|
const proc = (0, import_child_process30.spawn)(installCmd.exe, installCmd.args, { stdio: "inherit" });
|
|
47807
|
-
proc.on("exit", (code) =>
|
|
47808
|
-
proc.on("error", () =>
|
|
47807
|
+
proc.on("exit", (code) => resolve13(code === 0));
|
|
47808
|
+
proc.on("error", () => resolve13(false));
|
|
47809
47809
|
});
|
|
47810
47810
|
if (ok) O2.success("gh installed");
|
|
47811
47811
|
else O2.error("gh install failed");
|
|
@@ -47829,14 +47829,14 @@ var GitHubCodespacesProvider = class {
|
|
|
47829
47829
|
"Expanding GitHub scopes"
|
|
47830
47830
|
);
|
|
47831
47831
|
resetStdinForChild();
|
|
47832
|
-
await new Promise((
|
|
47832
|
+
await new Promise((resolve13, reject) => {
|
|
47833
47833
|
const proc = (0, import_child_process30.spawn)(
|
|
47834
47834
|
"gh",
|
|
47835
47835
|
["auth", "refresh", "-h", "github.com", "-s", "repo,read:org"],
|
|
47836
47836
|
{ stdio: "inherit" }
|
|
47837
47837
|
);
|
|
47838
47838
|
proc.on("exit", (code) => {
|
|
47839
|
-
if (code === 0)
|
|
47839
|
+
if (code === 0) resolve13();
|
|
47840
47840
|
else reject(new Error(
|
|
47841
47841
|
"gh auth refresh failed. Re-run `gh auth refresh -h github.com -s repo,read:org` manually."
|
|
47842
47842
|
));
|
|
@@ -48007,13 +48007,13 @@ var GitHubCodespacesProvider = class {
|
|
|
48007
48007
|
}
|
|
48008
48008
|
async streamCommand(workspaceId, command2) {
|
|
48009
48009
|
resetStdinForChild();
|
|
48010
|
-
return new Promise((
|
|
48010
|
+
return new Promise((resolve13, reject) => {
|
|
48011
48011
|
const proc = (0, import_child_process30.spawn)(
|
|
48012
48012
|
"gh",
|
|
48013
48013
|
["codespace", "ssh", "-c", workspaceId, "--", "-tt", command2],
|
|
48014
48014
|
{ stdio: "inherit" }
|
|
48015
48015
|
);
|
|
48016
|
-
proc.on("exit", (code) =>
|
|
48016
|
+
proc.on("exit", (code) => resolve13({ code: code ?? 0 }));
|
|
48017
48017
|
proc.on("error", reject);
|
|
48018
48018
|
});
|
|
48019
48019
|
}
|
|
@@ -48034,7 +48034,7 @@ var GitHubCodespacesProvider = class {
|
|
|
48034
48034
|
"--",
|
|
48035
48035
|
`mkdir -p ${shellQuote(remoteDir)} && tar -xzf - -C ${shellQuote(remoteDir)}`
|
|
48036
48036
|
];
|
|
48037
|
-
await new Promise((
|
|
48037
|
+
await new Promise((resolve13, reject) => {
|
|
48038
48038
|
const tar = (0, import_child_process30.spawn)("tar", tarArgs, {
|
|
48039
48039
|
stdio: ["ignore", "pipe", "pipe"],
|
|
48040
48040
|
env: tarEnv
|
|
@@ -48054,7 +48054,7 @@ var GitHubCodespacesProvider = class {
|
|
|
48054
48054
|
ssh.on("error", reject);
|
|
48055
48055
|
ssh.on("exit", (code) => {
|
|
48056
48056
|
if (code === 0) {
|
|
48057
|
-
|
|
48057
|
+
resolve13();
|
|
48058
48058
|
} else {
|
|
48059
48059
|
const reason = (sshErr || tarErr || `exit ${code}`).trim().slice(0, 500);
|
|
48060
48060
|
reject(new Error(`Remote tar failed: ${reason}`));
|
|
@@ -48072,7 +48072,7 @@ var GitHubCodespacesProvider = class {
|
|
|
48072
48072
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote(remotePath)}`);
|
|
48073
48073
|
}
|
|
48074
48074
|
const cmd = parts.join(" && ");
|
|
48075
|
-
await new Promise((
|
|
48075
|
+
await new Promise((resolve13, reject) => {
|
|
48076
48076
|
const proc = (0, import_child_process30.spawn)(
|
|
48077
48077
|
"gh",
|
|
48078
48078
|
["codespace", "ssh", "-c", workspaceId, "--", cmd],
|
|
@@ -48084,7 +48084,7 @@ var GitHubCodespacesProvider = class {
|
|
|
48084
48084
|
});
|
|
48085
48085
|
proc.on("error", reject);
|
|
48086
48086
|
proc.on("exit", (code) => {
|
|
48087
|
-
if (code === 0)
|
|
48087
|
+
if (code === 0) resolve13();
|
|
48088
48088
|
else reject(new Error(`Remote write failed: ${(stderr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48089
48089
|
});
|
|
48090
48090
|
proc.stdin?.write(contents);
|
|
@@ -48174,10 +48174,10 @@ var GitpodProvider = class {
|
|
|
48174
48174
|
"Authenticating Gitpod"
|
|
48175
48175
|
);
|
|
48176
48176
|
resetStdinForChild2();
|
|
48177
|
-
await new Promise((
|
|
48177
|
+
await new Promise((resolve13, reject) => {
|
|
48178
48178
|
const proc = (0, import_child_process31.spawn)("gitpod", ["login"], { stdio: "inherit" });
|
|
48179
48179
|
proc.on("exit", (code) => {
|
|
48180
|
-
if (code === 0)
|
|
48180
|
+
if (code === 0) resolve13();
|
|
48181
48181
|
else reject(new Error("gitpod login failed."));
|
|
48182
48182
|
});
|
|
48183
48183
|
proc.on("error", reject);
|
|
@@ -48326,13 +48326,13 @@ var GitpodProvider = class {
|
|
|
48326
48326
|
}
|
|
48327
48327
|
async streamCommand(workspaceId, command2) {
|
|
48328
48328
|
resetStdinForChild2();
|
|
48329
|
-
return new Promise((
|
|
48329
|
+
return new Promise((resolve13, reject) => {
|
|
48330
48330
|
const proc = (0, import_child_process31.spawn)(
|
|
48331
48331
|
"gitpod",
|
|
48332
48332
|
["workspace", "ssh", workspaceId, "--", "-tt", command2],
|
|
48333
48333
|
{ stdio: "inherit" }
|
|
48334
48334
|
);
|
|
48335
|
-
proc.on("exit", (code) =>
|
|
48335
|
+
proc.on("exit", (code) => resolve13({ code: code ?? 0 }));
|
|
48336
48336
|
proc.on("error", reject);
|
|
48337
48337
|
});
|
|
48338
48338
|
}
|
|
@@ -48346,7 +48346,7 @@ var GitpodProvider = class {
|
|
|
48346
48346
|
tarArgs.push(".");
|
|
48347
48347
|
const tarEnv = { ...process.env, COPYFILE_DISABLE: "1" };
|
|
48348
48348
|
const remoteCmd = `mkdir -p ${shellQuote2(remoteDir)} && tar -xzf - -C ${shellQuote2(remoteDir)}`;
|
|
48349
|
-
await new Promise((
|
|
48349
|
+
await new Promise((resolve13, reject) => {
|
|
48350
48350
|
const tar = (0, import_child_process31.spawn)("tar", tarArgs, {
|
|
48351
48351
|
stdio: ["ignore", "pipe", "pipe"],
|
|
48352
48352
|
env: tarEnv
|
|
@@ -48367,7 +48367,7 @@ var GitpodProvider = class {
|
|
|
48367
48367
|
tar.on("error", reject);
|
|
48368
48368
|
ssh.on("error", reject);
|
|
48369
48369
|
ssh.on("exit", (code) => {
|
|
48370
|
-
if (code === 0)
|
|
48370
|
+
if (code === 0) resolve13();
|
|
48371
48371
|
else reject(new Error(`Remote tar failed: ${(sshErr || tarErr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48372
48372
|
});
|
|
48373
48373
|
});
|
|
@@ -48382,7 +48382,7 @@ var GitpodProvider = class {
|
|
|
48382
48382
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote2(remotePath)}`);
|
|
48383
48383
|
}
|
|
48384
48384
|
const cmd = parts.join(" && ");
|
|
48385
|
-
await new Promise((
|
|
48385
|
+
await new Promise((resolve13, reject) => {
|
|
48386
48386
|
const proc = (0, import_child_process31.spawn)(
|
|
48387
48387
|
"gitpod",
|
|
48388
48388
|
["workspace", "ssh", workspaceId, "--", cmd],
|
|
@@ -48394,7 +48394,7 @@ var GitpodProvider = class {
|
|
|
48394
48394
|
});
|
|
48395
48395
|
proc.on("error", reject);
|
|
48396
48396
|
proc.on("exit", (code) => {
|
|
48397
|
-
if (code === 0)
|
|
48397
|
+
if (code === 0) resolve13();
|
|
48398
48398
|
else reject(new Error(`Remote write failed: ${(stderr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48399
48399
|
});
|
|
48400
48400
|
proc.stdin?.write(contents);
|
|
@@ -48451,14 +48451,14 @@ var GitLabWorkspacesProvider = class {
|
|
|
48451
48451
|
"Authenticating GitLab"
|
|
48452
48452
|
);
|
|
48453
48453
|
resetStdinForChild3();
|
|
48454
|
-
await new Promise((
|
|
48454
|
+
await new Promise((resolve13, reject) => {
|
|
48455
48455
|
const proc = (0, import_child_process32.spawn)(
|
|
48456
48456
|
"glab",
|
|
48457
48457
|
["auth", "login", "--scopes", "api,read_user,read_repository"],
|
|
48458
48458
|
{ stdio: "inherit" }
|
|
48459
48459
|
);
|
|
48460
48460
|
proc.on("exit", (code) => {
|
|
48461
|
-
if (code === 0)
|
|
48461
|
+
if (code === 0) resolve13();
|
|
48462
48462
|
else reject(new Error("glab auth login failed."));
|
|
48463
48463
|
});
|
|
48464
48464
|
proc.on("error", reject);
|
|
@@ -48623,13 +48623,13 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48623
48623
|
async streamCommand(workspaceId, command2) {
|
|
48624
48624
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
48625
48625
|
resetStdinForChild3();
|
|
48626
|
-
return new Promise((
|
|
48626
|
+
return new Promise((resolve13, reject) => {
|
|
48627
48627
|
const proc = (0, import_child_process32.spawn)(
|
|
48628
48628
|
"ssh",
|
|
48629
48629
|
["-tt", "-o", "StrictHostKeyChecking=accept-new", `${workspaceId}@${sshHost}`, command2],
|
|
48630
48630
|
{ stdio: "inherit" }
|
|
48631
48631
|
);
|
|
48632
|
-
proc.on("exit", (code) =>
|
|
48632
|
+
proc.on("exit", (code) => resolve13({ code: code ?? 0 }));
|
|
48633
48633
|
proc.on("error", reject);
|
|
48634
48634
|
});
|
|
48635
48635
|
}
|
|
@@ -48644,7 +48644,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48644
48644
|
tarArgs.push(".");
|
|
48645
48645
|
const tarEnv = { ...process.env, COPYFILE_DISABLE: "1" };
|
|
48646
48646
|
const remoteCmd = `mkdir -p ${shellQuote3(remoteDir)} && tar -xzf - -C ${shellQuote3(remoteDir)}`;
|
|
48647
|
-
await new Promise((
|
|
48647
|
+
await new Promise((resolve13, reject) => {
|
|
48648
48648
|
const tar = (0, import_child_process32.spawn)("tar", tarArgs, { stdio: ["ignore", "pipe", "pipe"], env: tarEnv });
|
|
48649
48649
|
const ssh = (0, import_child_process32.spawn)(
|
|
48650
48650
|
"ssh",
|
|
@@ -48662,7 +48662,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48662
48662
|
tar.on("error", reject);
|
|
48663
48663
|
ssh.on("error", reject);
|
|
48664
48664
|
ssh.on("exit", (code) => {
|
|
48665
|
-
if (code === 0)
|
|
48665
|
+
if (code === 0) resolve13();
|
|
48666
48666
|
else reject(new Error(`Remote tar failed: ${(sshErr || tarErr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48667
48667
|
});
|
|
48668
48668
|
});
|
|
@@ -48675,7 +48675,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48675
48675
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
48676
48676
|
}
|
|
48677
48677
|
const cmd = parts.join(" && ");
|
|
48678
|
-
await new Promise((
|
|
48678
|
+
await new Promise((resolve13, reject) => {
|
|
48679
48679
|
const proc = (0, import_child_process32.spawn)(
|
|
48680
48680
|
"ssh",
|
|
48681
48681
|
["-o", "StrictHostKeyChecking=accept-new", `${workspaceId}@${sshHost}`, cmd],
|
|
@@ -48687,7 +48687,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48687
48687
|
});
|
|
48688
48688
|
proc.on("error", reject);
|
|
48689
48689
|
proc.on("exit", (code) => {
|
|
48690
|
-
if (code === 0)
|
|
48690
|
+
if (code === 0) resolve13();
|
|
48691
48691
|
else reject(new Error(`Remote write failed: ${(stderr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48692
48692
|
});
|
|
48693
48693
|
proc.stdin?.write(contents);
|
|
@@ -48778,10 +48778,10 @@ var RailwayProvider = class {
|
|
|
48778
48778
|
"Authenticating Railway"
|
|
48779
48779
|
);
|
|
48780
48780
|
resetStdinForChild4();
|
|
48781
|
-
await new Promise((
|
|
48781
|
+
await new Promise((resolve13, reject) => {
|
|
48782
48782
|
const proc = (0, import_child_process33.spawn)("railway", ["login"], { stdio: "inherit" });
|
|
48783
48783
|
proc.on("exit", (code) => {
|
|
48784
|
-
if (code === 0)
|
|
48784
|
+
if (code === 0) resolve13();
|
|
48785
48785
|
else reject(new Error("railway login failed."));
|
|
48786
48786
|
});
|
|
48787
48787
|
proc.on("error", reject);
|
|
@@ -48921,13 +48921,13 @@ var RailwayProvider = class {
|
|
|
48921
48921
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
48922
48922
|
}
|
|
48923
48923
|
resetStdinForChild4();
|
|
48924
|
-
return new Promise((
|
|
48924
|
+
return new Promise((resolve13, reject) => {
|
|
48925
48925
|
const proc = (0, import_child_process33.spawn)(
|
|
48926
48926
|
"railway",
|
|
48927
48927
|
["shell", "--project", projectId, "--service", serviceId, "--command", command2],
|
|
48928
48928
|
{ stdio: "inherit" }
|
|
48929
48929
|
);
|
|
48930
|
-
proc.on("exit", (code) =>
|
|
48930
|
+
proc.on("exit", (code) => resolve13({ code: code ?? 0 }));
|
|
48931
48931
|
proc.on("error", reject);
|
|
48932
48932
|
});
|
|
48933
48933
|
}
|
|
@@ -48945,7 +48945,7 @@ var RailwayProvider = class {
|
|
|
48945
48945
|
tarArgs.push(".");
|
|
48946
48946
|
const tarEnv = { ...process.env, COPYFILE_DISABLE: "1" };
|
|
48947
48947
|
const remoteCmd = `mkdir -p ${shellQuote4(remoteDir)} && tar -xzf - -C ${shellQuote4(remoteDir)}`;
|
|
48948
|
-
await new Promise((
|
|
48948
|
+
await new Promise((resolve13, reject) => {
|
|
48949
48949
|
const tar = (0, import_child_process33.spawn)("tar", tarArgs, { stdio: ["ignore", "pipe", "pipe"], env: tarEnv });
|
|
48950
48950
|
const sh = (0, import_child_process33.spawn)(
|
|
48951
48951
|
"railway",
|
|
@@ -48963,7 +48963,7 @@ var RailwayProvider = class {
|
|
|
48963
48963
|
tar.on("error", reject);
|
|
48964
48964
|
sh.on("error", reject);
|
|
48965
48965
|
sh.on("exit", (code) => {
|
|
48966
|
-
if (code === 0)
|
|
48966
|
+
if (code === 0) resolve13();
|
|
48967
48967
|
else reject(new Error(`Remote tar failed: ${(shErr || tarErr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48968
48968
|
});
|
|
48969
48969
|
});
|
|
@@ -48979,7 +48979,7 @@ var RailwayProvider = class {
|
|
|
48979
48979
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
48980
48980
|
}
|
|
48981
48981
|
const cmd = parts.join(" && ");
|
|
48982
|
-
await new Promise((
|
|
48982
|
+
await new Promise((resolve13, reject) => {
|
|
48983
48983
|
const proc = (0, import_child_process33.spawn)(
|
|
48984
48984
|
"railway",
|
|
48985
48985
|
["shell", "--project", projectId, "--service", serviceId, "--command", cmd],
|
|
@@ -48991,7 +48991,7 @@ var RailwayProvider = class {
|
|
|
48991
48991
|
});
|
|
48992
48992
|
proc.on("error", reject);
|
|
48993
48993
|
proc.on("exit", (code) => {
|
|
48994
|
-
if (code === 0)
|
|
48994
|
+
if (code === 0) resolve13();
|
|
48995
48995
|
else reject(new Error(`Remote write failed: ${(stderr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48996
48996
|
});
|
|
48997
48997
|
proc.stdin?.write(contents);
|
|
@@ -50190,7 +50190,7 @@ var defaultGitToolingRunner = {
|
|
|
50190
50190
|
}
|
|
50191
50191
|
},
|
|
50192
50192
|
run(cmd, args2, opts = {}) {
|
|
50193
|
-
return new Promise((
|
|
50193
|
+
return new Promise((resolve13) => {
|
|
50194
50194
|
const child = (0, import_node_child_process31.spawn)(cmd, args2, {
|
|
50195
50195
|
stdio: [opts.input !== void 0 ? "pipe" : "ignore", "ignore", "pipe"]
|
|
50196
50196
|
});
|
|
@@ -50199,7 +50199,7 @@ var defaultGitToolingRunner = {
|
|
|
50199
50199
|
const done = (code) => {
|
|
50200
50200
|
if (settled) return;
|
|
50201
50201
|
settled = true;
|
|
50202
|
-
|
|
50202
|
+
resolve13({ code, stderr });
|
|
50203
50203
|
};
|
|
50204
50204
|
child.stderr?.on("data", (b) => {
|
|
50205
50205
|
stderr += b.toString();
|
|
@@ -50280,14 +50280,14 @@ function compareSemver(a, b) {
|
|
|
50280
50280
|
return 0;
|
|
50281
50281
|
}
|
|
50282
50282
|
function fetchLatest() {
|
|
50283
|
-
return new Promise((
|
|
50283
|
+
return new Promise((resolve13) => {
|
|
50284
50284
|
const req = https8.get(
|
|
50285
50285
|
REGISTRY_URL,
|
|
50286
50286
|
{ headers: { Accept: "application/json" }, timeout: REQUEST_TIMEOUT_MS },
|
|
50287
50287
|
(res) => {
|
|
50288
50288
|
if (res.statusCode !== 200) {
|
|
50289
50289
|
res.resume();
|
|
50290
|
-
|
|
50290
|
+
resolve13(null);
|
|
50291
50291
|
return;
|
|
50292
50292
|
}
|
|
50293
50293
|
let buf = "";
|
|
@@ -50299,21 +50299,21 @@ function fetchLatest() {
|
|
|
50299
50299
|
try {
|
|
50300
50300
|
const json = JSON.parse(buf);
|
|
50301
50301
|
if (typeof json.version === "string") {
|
|
50302
|
-
|
|
50302
|
+
resolve13(json.version);
|
|
50303
50303
|
} else {
|
|
50304
|
-
|
|
50304
|
+
resolve13(null);
|
|
50305
50305
|
}
|
|
50306
50306
|
} catch {
|
|
50307
|
-
|
|
50307
|
+
resolve13(null);
|
|
50308
50308
|
}
|
|
50309
50309
|
});
|
|
50310
50310
|
}
|
|
50311
50311
|
);
|
|
50312
50312
|
req.on("timeout", () => {
|
|
50313
50313
|
req.destroy();
|
|
50314
|
-
|
|
50314
|
+
resolve13(null);
|
|
50315
50315
|
});
|
|
50316
|
-
req.on("error", () =>
|
|
50316
|
+
req.on("error", () => resolve13(null));
|
|
50317
50317
|
});
|
|
50318
50318
|
}
|
|
50319
50319
|
function notifyIfStale(currentVersion, latest) {
|
|
@@ -50389,7 +50389,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
50389
50389
|
if (process.env.NODE_ENV === "test") return;
|
|
50390
50390
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
50391
50391
|
if (process.env.CI) return;
|
|
50392
|
-
const current2 = true ? "2.76.
|
|
50392
|
+
const current2 = true ? "2.76.15" : null;
|
|
50393
50393
|
if (!current2) return;
|
|
50394
50394
|
const cache = readCache();
|
|
50395
50395
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -50406,7 +50406,7 @@ function checkForUpdates() {
|
|
|
50406
50406
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
50407
50407
|
if (process.env.CI) return;
|
|
50408
50408
|
if (!process.stdout.isTTY) return;
|
|
50409
|
-
const current2 = true ? "2.76.
|
|
50409
|
+
const current2 = true ? "2.76.15" : null;
|
|
50410
50410
|
if (!current2) return;
|
|
50411
50411
|
const cache = readCache();
|
|
50412
50412
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -50514,18 +50514,29 @@ function pointerTarget(root, name) {
|
|
|
50514
50514
|
}
|
|
50515
50515
|
}
|
|
50516
50516
|
function atomicPoint(root, name, targetDir) {
|
|
50517
|
-
const
|
|
50518
|
-
|
|
50517
|
+
const realRoot = fs94.realpathSync(root);
|
|
50518
|
+
const tmp = path107.join(realRoot, `.${name}.tmp-${process.pid}-${Date.now()}`);
|
|
50519
|
+
fs94.symlinkSync(path107.relative(realRoot, fs94.realpathSync(targetDir)), tmp, "dir");
|
|
50519
50520
|
try {
|
|
50520
|
-
fs94.renameSync(tmp, path107.join(
|
|
50521
|
+
fs94.renameSync(tmp, path107.join(realRoot, name));
|
|
50521
50522
|
} catch (err) {
|
|
50522
50523
|
fs94.rmSync(tmp, { force: true });
|
|
50523
50524
|
throw err;
|
|
50524
50525
|
}
|
|
50525
50526
|
}
|
|
50527
|
+
function samePath(a, b) {
|
|
50528
|
+
const canon = (p2) => {
|
|
50529
|
+
try {
|
|
50530
|
+
return fs94.realpathSync(p2);
|
|
50531
|
+
} catch {
|
|
50532
|
+
return path107.resolve(p2);
|
|
50533
|
+
}
|
|
50534
|
+
};
|
|
50535
|
+
return canon(a) === canon(b);
|
|
50536
|
+
}
|
|
50526
50537
|
function switchCurrent(root, versionDir) {
|
|
50527
50538
|
const old = pointerTarget(root, "current");
|
|
50528
|
-
if (old &&
|
|
50539
|
+
if (old && !samePath(old, versionDir)) atomicPoint(root, "previous", old);
|
|
50529
50540
|
atomicPoint(root, "current", versionDir);
|
|
50530
50541
|
}
|
|
50531
50542
|
function validCurrent(root) {
|
|
@@ -50539,7 +50550,7 @@ function rollbackCurrent(root) {
|
|
|
50539
50550
|
const prev = pointerTarget(root, "previous");
|
|
50540
50551
|
if (!prev || isBad(prev) || !entryOf(prev)) return null;
|
|
50541
50552
|
const cur = pointerTarget(root, "current");
|
|
50542
|
-
if (cur &&
|
|
50553
|
+
if (cur && !samePath(cur, prev)) atomicPoint(root, "previous", cur);
|
|
50543
50554
|
atomicPoint(root, "current", prev);
|
|
50544
50555
|
return versionOf(prev);
|
|
50545
50556
|
}
|
|
@@ -50677,7 +50688,7 @@ var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
|
|
|
50677
50688
|
var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
50678
50689
|
var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
|
|
50679
50690
|
function currentCliVersion() {
|
|
50680
|
-
return true ? "2.76.
|
|
50691
|
+
return true ? "2.76.15" : null;
|
|
50681
50692
|
}
|
|
50682
50693
|
async function installedVersion(deps) {
|
|
50683
50694
|
const ls = await deps.run(
|
|
@@ -50693,10 +50704,10 @@ async function installedVersion(deps) {
|
|
|
50693
50704
|
}
|
|
50694
50705
|
}
|
|
50695
50706
|
function runCmd(cmd, args2, timeoutMs) {
|
|
50696
|
-
return new Promise((
|
|
50707
|
+
return new Promise((resolve13) => {
|
|
50697
50708
|
(0, import_node_child_process33.execFile)(cmd, args2, { timeout: timeoutMs }, (err, stdout, stderr) => {
|
|
50698
50709
|
const code = err && typeof err.code === "number" ? err.code : err ? null : 0;
|
|
50699
|
-
|
|
50710
|
+
resolve13({ code, stdout: stdout ?? "", stderr: stderr ?? "" });
|
|
50700
50711
|
});
|
|
50701
50712
|
});
|
|
50702
50713
|
}
|
|
@@ -50720,14 +50731,22 @@ async function runSelfUpdateWith(deps) {
|
|
|
50720
50731
|
}
|
|
50721
50732
|
const root = deps.versionsRoot ?? cliVersionsRoot();
|
|
50722
50733
|
const versioned = versionedModeSupported(deps.platform) ? validCurrent(root) : null;
|
|
50723
|
-
|
|
50734
|
+
const runningDir = versioned ? versionDirContaining(root, deps.runningEntry) : null;
|
|
50735
|
+
const runningIsCurrent = versioned !== null && runningDir !== null && samePath(runningDir, versioned.dir);
|
|
50736
|
+
if (runningIsCurrent && versioned && versioned.version !== current2) {
|
|
50737
|
+
log.warn(
|
|
50738
|
+
"host-agent",
|
|
50739
|
+
`self-update: running ${current2} from ${versioned.dir}, whose package.json says ${versioned.version} \u2014 not restarting onto it (it is this same code)`
|
|
50740
|
+
);
|
|
50741
|
+
}
|
|
50742
|
+
if (versioned && !runningIsCurrent && compareSemver(versioned.version, current2) > 0) {
|
|
50724
50743
|
log.info(
|
|
50725
50744
|
"host-agent",
|
|
50726
50745
|
`self-update: ${versioned.version} already current in ${root} (running ${current2}) \u2014 restarting onto it`
|
|
50727
50746
|
);
|
|
50728
50747
|
return { status: "updated", version: versioned.version };
|
|
50729
50748
|
}
|
|
50730
|
-
const onDisk = await installedVersion(deps);
|
|
50749
|
+
const onDisk = runningIsCurrent ? null : await installedVersion(deps);
|
|
50731
50750
|
if (onDisk && compareSemver(onDisk, current2) > 0) {
|
|
50732
50751
|
log.info(
|
|
50733
50752
|
"host-agent",
|
|
@@ -50741,15 +50760,19 @@ async function runSelfUpdateWith(deps) {
|
|
|
50741
50760
|
SELF_UPDATE_VIEW_TIMEOUT_MS
|
|
50742
50761
|
);
|
|
50743
50762
|
if (view.code !== 0) {
|
|
50744
|
-
log.
|
|
50763
|
+
log.warn(
|
|
50764
|
+
"host-agent",
|
|
50765
|
+
`self-update: npm view ${SELF_UPDATE_PKG} exited ${String(view.code)} \u2014 cannot check, staying on ${current2}: ` + view.stderr.trim().slice(-300)
|
|
50766
|
+
);
|
|
50745
50767
|
return { status: "skipped" };
|
|
50746
50768
|
}
|
|
50747
50769
|
const latest = view.stdout.trim();
|
|
50748
50770
|
if (!latest) {
|
|
50749
|
-
log.
|
|
50771
|
+
log.warn("host-agent", `self-update: npm view returned nothing \u2014 cannot check, staying on ${current2}`);
|
|
50750
50772
|
return { status: "skipped" };
|
|
50751
50773
|
}
|
|
50752
50774
|
if (compareSemver(latest, current2) <= 0) {
|
|
50775
|
+
log.info("host-agent", `self-update: running ${current2}, npm latest ${latest} \u2014 up to date`);
|
|
50753
50776
|
return { status: "current" };
|
|
50754
50777
|
}
|
|
50755
50778
|
if (!versionedModeSupported(deps.platform)) {
|
|
@@ -50786,11 +50809,15 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
50786
50809
|
}
|
|
50787
50810
|
try {
|
|
50788
50811
|
const runningDir = versionDirContaining(root, deps.runningEntry);
|
|
50812
|
+
if (runningDir && samePath(runningDir, target)) {
|
|
50813
|
+
log.warn(
|
|
50814
|
+
"host-agent",
|
|
50815
|
+
`self-update: already running from ${target} (reports ${running2}) \u2014 leaving it alone`
|
|
50816
|
+
);
|
|
50817
|
+
return { status: "skipped" };
|
|
50818
|
+
}
|
|
50789
50819
|
const reusable = entryOf(target) && versionOf(target) === latest;
|
|
50790
50820
|
if (!reusable) {
|
|
50791
|
-
if (runningDir && path108.resolve(runningDir) === path108.resolve(target)) {
|
|
50792
|
-
return { status: "skipped" };
|
|
50793
|
-
}
|
|
50794
50821
|
fs95.rmSync(target, { recursive: true, force: true });
|
|
50795
50822
|
const install = await deps.run(
|
|
50796
50823
|
"npm",
|
|
@@ -50872,7 +50899,7 @@ function signalHostReady(send = process.send?.bind(process)) {
|
|
|
50872
50899
|
}
|
|
50873
50900
|
function defaultDeps() {
|
|
50874
50901
|
return {
|
|
50875
|
-
ownVersion: true ? "2.76.
|
|
50902
|
+
ownVersion: true ? "2.76.15" : null,
|
|
50876
50903
|
root: cliVersionsRoot(),
|
|
50877
50904
|
args: process.argv.slice(3),
|
|
50878
50905
|
execPath: process.execPath,
|
|
@@ -50921,9 +50948,9 @@ async function superviseCurrent(over = {}) {
|
|
|
50921
50948
|
};
|
|
50922
50949
|
if (deps.stdinIsTty) process.on("SIGINT", ignoreSigint);
|
|
50923
50950
|
const { code, signal } = await new Promise(
|
|
50924
|
-
(
|
|
50925
|
-
child.once("exit", (c2, s) =>
|
|
50926
|
-
child.once("error", () =>
|
|
50951
|
+
(resolve13) => {
|
|
50952
|
+
child.once("exit", (c2, s) => resolve13({ code: c2, signal: s }));
|
|
50953
|
+
child.once("error", () => resolve13({ code: 1, signal: null }));
|
|
50927
50954
|
}
|
|
50928
50955
|
);
|
|
50929
50956
|
for (const [sig, h] of handlers2) process.off(sig, h);
|
|
@@ -51190,6 +51217,12 @@ function fleetUserIdFromContainerName(containerName) {
|
|
|
51190
51217
|
function isMissingContainerError(stderr) {
|
|
51191
51218
|
return /no such container/i.test(stderr);
|
|
51192
51219
|
}
|
|
51220
|
+
function fleetLaneKey(cmd) {
|
|
51221
|
+
if (!cmd.type.startsWith("fleet_")) return null;
|
|
51222
|
+
if (cmd.type === "fleet_prune_host") return "host";
|
|
51223
|
+
const payload = cmd.payload;
|
|
51224
|
+
return typeof payload?.containerName === "string" ? payload.containerName : cmd.type;
|
|
51225
|
+
}
|
|
51193
51226
|
function isFleetPruneHostPayload(v) {
|
|
51194
51227
|
if (typeof v !== "object" || v === null) return false;
|
|
51195
51228
|
const p2 = v;
|
|
@@ -51265,7 +51298,7 @@ var DOCKER_RUN_WITH_PULL_TIMEOUT_MS = 6e5;
|
|
|
51265
51298
|
var DOCKER_PRUNE_TIMEOUT_MS = 6e5;
|
|
51266
51299
|
var defaultDockerRunner = {
|
|
51267
51300
|
run(args2, opts = {}) {
|
|
51268
|
-
return new Promise((
|
|
51301
|
+
return new Promise((resolve13) => {
|
|
51269
51302
|
const child = (0, import_node_child_process36.spawn)("docker", args2, {
|
|
51270
51303
|
stdio: ["ignore", "pipe", "pipe"],
|
|
51271
51304
|
env: { ...process.env, ...opts.env }
|
|
@@ -51284,7 +51317,7 @@ var defaultDockerRunner = {
|
|
|
51284
51317
|
if (settled) return;
|
|
51285
51318
|
settled = true;
|
|
51286
51319
|
clearTimeout(timer);
|
|
51287
|
-
|
|
51320
|
+
resolve13({ code, stderr: stderrBuf, stdout: stdoutBuf });
|
|
51288
51321
|
};
|
|
51289
51322
|
child.stdout?.on("data", (b) => {
|
|
51290
51323
|
stdoutBuf += b.toString();
|
|
@@ -51462,7 +51495,7 @@ var HostAgentSupervisor = class {
|
|
|
51462
51495
|
const make = this.deps.makeRelay ?? ((pluginId, onCommand, meta, pollSecret) => new CommandRelayService(pluginId, onCommand, meta, void 0, pollSecret));
|
|
51463
51496
|
this.relay = make(
|
|
51464
51497
|
this.identity.controlPluginId,
|
|
51465
|
-
(cmd) => this.
|
|
51498
|
+
(cmd) => this.dispatchRelayCommand(cmd),
|
|
51466
51499
|
CONTROL_AGENT_META,
|
|
51467
51500
|
this.identity.controlPollSecret
|
|
51468
51501
|
);
|
|
@@ -51624,19 +51657,20 @@ var HostAgentSupervisor = class {
|
|
|
51624
51657
|
*/
|
|
51625
51658
|
maybeRestartForUpdate(version3) {
|
|
51626
51659
|
const midTurn = [...this.children.values()].some((c2) => this.isChildMidTurn(c2.proc.pid));
|
|
51627
|
-
|
|
51660
|
+
const fleetBusy = this.fleetLanes.size > 0;
|
|
51661
|
+
if (midTurn || fleetBusy) {
|
|
51628
51662
|
const since = this.pendingRestartSince ?? this.now();
|
|
51629
51663
|
const waited = this.now() - since;
|
|
51630
51664
|
if (waited < SELF_UPDATE_DEFER_MAX_MS) {
|
|
51631
51665
|
log.info(
|
|
51632
51666
|
"host-agent",
|
|
51633
|
-
`self-update: ${version3} installed but a session is mid-turn \u2014 deferring restart`
|
|
51667
|
+
`self-update: ${version3} installed but ${fleetBusy ? `${this.fleetLanes.size} fleet op(s) are in flight` : "a session is mid-turn"} \u2014 deferring restart`
|
|
51634
51668
|
);
|
|
51635
51669
|
return false;
|
|
51636
51670
|
}
|
|
51637
51671
|
log.warn(
|
|
51638
51672
|
"host-agent",
|
|
51639
|
-
`self-update: ${version3} has been owed for ${Math.round(waited / 36e5)}h with a session still mid-turn \u2014 restarting anyway rather than staying on old code`
|
|
51673
|
+
`self-update: ${version3} has been owed for ${Math.round(waited / 36e5)}h with ${fleetBusy ? "fleet ops still in flight" : "a session still mid-turn"} \u2014 restarting anyway rather than staying on old code`
|
|
51640
51674
|
);
|
|
51641
51675
|
}
|
|
51642
51676
|
this.onUpdated(version3);
|
|
@@ -51668,6 +51702,58 @@ var HostAgentSupervisor = class {
|
|
|
51668
51702
|
* arbitrary command surface).
|
|
51669
51703
|
*/
|
|
51670
51704
|
async handleCommand(cmd) {
|
|
51705
|
+
const lane = fleetLaneKey(cmd);
|
|
51706
|
+
if (lane !== null) return this.runInFleetLane(lane, () => this.handleFleetCommand(cmd));
|
|
51707
|
+
await this.handleNonFleetCommand(cmd);
|
|
51708
|
+
}
|
|
51709
|
+
/**
|
|
51710
|
+
* The relay's entry point. A fleet command is NOT awaited here.
|
|
51711
|
+
*
|
|
51712
|
+
* The relay acks a batch the moment it arrives, then awaits each command of
|
|
51713
|
+
* the batch in order. Awaiting a fleet op there let one slow op hold every
|
|
51714
|
+
* command queued behind it: on 2026-10-02 the hourly sweep's
|
|
51715
|
+
* `fleet_migrate_box_image` commands were each pulling the freshly released
|
|
51716
|
+
* 7.7 GB image (up to 10 min apiece), a new user's scratch `fleet_create_box`
|
|
51717
|
+
* sat behind three of them in the same batch (received 18:04:07, never
|
|
51718
|
+
* started), the 18:06 self-update restart dropped it, and since it was already
|
|
51719
|
+
* acked nothing ever redelivered it — the box failed at the 18:30
|
|
51720
|
+
* provisioning sweep. Per-container lanes keep each box's ops in order; ops on
|
|
51721
|
+
* different boxes no longer wait for each other.
|
|
51722
|
+
*/
|
|
51723
|
+
dispatchRelayCommand(cmd) {
|
|
51724
|
+
const work = this.handleCommand(cmd);
|
|
51725
|
+
if (fleetLaneKey(cmd) === null) return work;
|
|
51726
|
+
void work;
|
|
51727
|
+
return Promise.resolve();
|
|
51728
|
+
}
|
|
51729
|
+
/** Fleet ops queued or running, keyed by container (or the host for a prune). */
|
|
51730
|
+
fleetLanes = /* @__PURE__ */ new Map();
|
|
51731
|
+
/** Number of fleet lanes with work queued or running — for tests + the restart gate. */
|
|
51732
|
+
fleetOpsInFlight() {
|
|
51733
|
+
return this.fleetLanes.size;
|
|
51734
|
+
}
|
|
51735
|
+
/**
|
|
51736
|
+
* Run `op` after every earlier op on the same lane. Never rejects: a failed op
|
|
51737
|
+
* is logged and the lane moves on. When the last lane drains and a self-update
|
|
51738
|
+
* restart is owed, take it now instead of waiting for the next hourly tick.
|
|
51739
|
+
*/
|
|
51740
|
+
runInFleetLane(key, op) {
|
|
51741
|
+
const prev = this.fleetLanes.get(key) ?? Promise.resolve();
|
|
51742
|
+
const next = prev.then(op).catch((err) => {
|
|
51743
|
+
log.warn(
|
|
51744
|
+
"host-agent",
|
|
51745
|
+
`fleet op on ${key} failed: ${err instanceof Error ? err.message : String(err)}`
|
|
51746
|
+
);
|
|
51747
|
+
});
|
|
51748
|
+
this.fleetLanes.set(key, next);
|
|
51749
|
+
return next.then(() => {
|
|
51750
|
+
if (this.fleetLanes.get(key) === next) this.fleetLanes.delete(key);
|
|
51751
|
+
if (this.fleetLanes.size === 0 && this.pendingRestartVersion !== null) {
|
|
51752
|
+
this.maybeRestartForUpdate(this.pendingRestartVersion);
|
|
51753
|
+
}
|
|
51754
|
+
});
|
|
51755
|
+
}
|
|
51756
|
+
async handleFleetCommand(cmd) {
|
|
51671
51757
|
if (cmd.type === "fleet_create_box") {
|
|
51672
51758
|
if (!isFleetCreateBoxPayload(cmd.payload)) {
|
|
51673
51759
|
log.warn("host-agent", `ignoring malformed fleet_create_box id=${cmd.id}`);
|
|
@@ -51716,6 +51802,8 @@ var HostAgentSupervisor = class {
|
|
|
51716
51802
|
await this.fleetPruneHost(cmd.payload);
|
|
51717
51803
|
return;
|
|
51718
51804
|
}
|
|
51805
|
+
}
|
|
51806
|
+
async handleNonFleetCommand(cmd) {
|
|
51719
51807
|
if (cmd.type === "self_hosted_deploy") {
|
|
51720
51808
|
if (!isDeployPayload(cmd.payload)) {
|
|
51721
51809
|
log.warn("host-agent", `ignoring malformed self_hosted_deploy id=${cmd.id}`);
|
|
@@ -53190,7 +53278,7 @@ function checkChokidar() {
|
|
|
53190
53278
|
}
|
|
53191
53279
|
async function doctor(args2 = []) {
|
|
53192
53280
|
const json = args2.includes("--json");
|
|
53193
|
-
const cliVersion = true ? "2.76.
|
|
53281
|
+
const cliVersion = true ? "2.76.15" : "0.0.0-dev";
|
|
53194
53282
|
const apiBase2 = resolveApiBaseUrl();
|
|
53195
53283
|
const diagnosticId = (0, import_node_crypto17.randomUUID)();
|
|
53196
53284
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
@@ -53634,7 +53722,7 @@ var WARM_PACKAGE_TIMEOUT_MS = 12e4;
|
|
|
53634
53722
|
var WARM_TOTAL_BUDGET_MS = 10 * 6e4;
|
|
53635
53723
|
var WARM_CONCURRENCY = 4;
|
|
53636
53724
|
function runCapturing(command2, args2, timeoutMs) {
|
|
53637
|
-
return new Promise((
|
|
53725
|
+
return new Promise((resolve13) => {
|
|
53638
53726
|
const child = (0, import_node_child_process40.spawn)(command2, args2, {
|
|
53639
53727
|
env: { ...process.env, ...LAUNCHER_ENV },
|
|
53640
53728
|
stdio: ["ignore", "ignore", "pipe"],
|
|
@@ -53649,15 +53737,15 @@ function runCapturing(command2, args2, timeoutMs) {
|
|
|
53649
53737
|
child.stderr?.on("data", (c2) => stderr += c2);
|
|
53650
53738
|
const timer = setTimeout(() => {
|
|
53651
53739
|
child.kill("SIGKILL");
|
|
53652
|
-
|
|
53740
|
+
resolve13({ status: null, stderr, error: new Error(`spawn ${command2} ETIMEDOUT`) });
|
|
53653
53741
|
}, timeoutMs);
|
|
53654
53742
|
child.on("error", (error) => {
|
|
53655
53743
|
clearTimeout(timer);
|
|
53656
|
-
|
|
53744
|
+
resolve13({ status: null, stderr, error });
|
|
53657
53745
|
});
|
|
53658
53746
|
child.on("close", (status2) => {
|
|
53659
53747
|
clearTimeout(timer);
|
|
53660
|
-
|
|
53748
|
+
resolve13({ status: status2, stderr });
|
|
53661
53749
|
});
|
|
53662
53750
|
});
|
|
53663
53751
|
}
|
|
@@ -53714,7 +53802,7 @@ async function mcpWarm(argv = [], opts = {}) {
|
|
|
53714
53802
|
// src/commands/version.ts
|
|
53715
53803
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
53716
53804
|
function version2() {
|
|
53717
|
-
const v = true ? "2.76.
|
|
53805
|
+
const v = true ? "2.76.15" : "unknown";
|
|
53718
53806
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
53719
53807
|
}
|
|
53720
53808
|
|