codeam-cli 2.76.13 → 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 +12 -0
- package/dist/index.js +650 -538
- 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 {
|
|
@@ -358,7 +358,7 @@ function defaultSpawn(timeoutMs) {
|
|
|
358
358
|
}
|
|
359
359
|
function resolveConvexBin(cwd) {
|
|
360
360
|
const local = path112.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "convex.cmd" : "convex");
|
|
361
|
-
if (
|
|
361
|
+
if (fs99.existsSync(local)) return { cmd: local, args: [] };
|
|
362
362
|
return { cmd: "npx", args: ["--yes", "convex"] };
|
|
363
363
|
}
|
|
364
364
|
function redact(text, key) {
|
|
@@ -489,12 +489,12 @@ async function runConvexAdminMcp(client3, id) {
|
|
|
489
489
|
});
|
|
490
490
|
await server.connect(new StdioServerTransport());
|
|
491
491
|
}
|
|
492
|
-
var import_node_child_process38,
|
|
492
|
+
var import_node_child_process38, fs99, path112, TOOLS;
|
|
493
493
|
var init_convex_admin_mcp = __esm({
|
|
494
494
|
"src/integrations/convex-admin-mcp.ts"() {
|
|
495
495
|
"use strict";
|
|
496
496
|
import_node_child_process38 = require("child_process");
|
|
497
|
-
|
|
497
|
+
fs99 = __toESM(require("fs"));
|
|
498
498
|
path112 = __toESM(require("path"));
|
|
499
499
|
TOOLS = [
|
|
500
500
|
{
|
|
@@ -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);
|
|
@@ -3765,7 +3765,7 @@ var _default = makeConfig();
|
|
|
3765
3765
|
var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, setSessionAgent, setSquadAuto, getSquadAuto, clearAll, saveCliConfig, loadCliConfig } = _default;
|
|
3766
3766
|
|
|
3767
3767
|
// src/commands/pair-auto.ts
|
|
3768
|
-
var
|
|
3768
|
+
var fs66 = __toESM(require("fs"));
|
|
3769
3769
|
var os48 = __toESM(require("os"));
|
|
3770
3770
|
var path74 = __toESM(require("path"));
|
|
3771
3771
|
var import_crypto4 = require("crypto");
|
|
@@ -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
|
);
|
|
@@ -13636,7 +13636,7 @@ function closeAllTerminals() {
|
|
|
13636
13636
|
}
|
|
13637
13637
|
|
|
13638
13638
|
// src/commands/start/handlers.ts
|
|
13639
|
-
var
|
|
13639
|
+
var fs65 = __toESM(require("fs"));
|
|
13640
13640
|
var os47 = __toESM(require("os"));
|
|
13641
13641
|
var path73 = __toESM(require("path"));
|
|
13642
13642
|
var import_crypto3 = require("crypto");
|
|
@@ -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 {
|
|
@@ -28295,10 +28295,12 @@ function persistBeadsConfig(cfg) {
|
|
|
28295
28295
|
}
|
|
28296
28296
|
|
|
28297
28297
|
// src/beads/provision-lock.ts
|
|
28298
|
-
var
|
|
28298
|
+
var import_fs8 = __toESM(require("fs"));
|
|
28299
28299
|
var import_os11 = __toESM(require("os"));
|
|
28300
28300
|
var import_path9 = __toESM(require("path"));
|
|
28301
|
-
|
|
28301
|
+
|
|
28302
|
+
// src/lib/process-identity.ts
|
|
28303
|
+
var import_fs7 = __toESM(require("fs"));
|
|
28302
28304
|
function pidIsAlive(pid) {
|
|
28303
28305
|
try {
|
|
28304
28306
|
process.kill(pid, 0);
|
|
@@ -28307,32 +28309,56 @@ function pidIsAlive(pid) {
|
|
|
28307
28309
|
return err.code === "EPERM";
|
|
28308
28310
|
}
|
|
28309
28311
|
}
|
|
28312
|
+
function procStartTime(pid) {
|
|
28313
|
+
try {
|
|
28314
|
+
const stat3 = import_fs7.default.readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
28315
|
+
const rest = stat3.slice(stat3.lastIndexOf(")") + 2).split(" ");
|
|
28316
|
+
return rest[19] ?? "";
|
|
28317
|
+
} catch {
|
|
28318
|
+
return "";
|
|
28319
|
+
}
|
|
28320
|
+
}
|
|
28321
|
+
function ownerRecord(pid, deps = {}) {
|
|
28322
|
+
return `${pid} ${(deps.startTimeOf ?? procStartTime)(pid)}`.trim();
|
|
28323
|
+
}
|
|
28324
|
+
function ownerIsAlive(record2, deps = {}) {
|
|
28325
|
+
const [pidText, recordedStart = ""] = record2.trim().split(/\s+/);
|
|
28326
|
+
const pid = Number(pidText);
|
|
28327
|
+
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
28328
|
+
if (!(deps.isAlive ?? pidIsAlive)(pid)) return false;
|
|
28329
|
+
if (!recordedStart) return true;
|
|
28330
|
+
const now = (deps.startTimeOf ?? procStartTime)(pid);
|
|
28331
|
+
return now === "" || now === recordedStart;
|
|
28332
|
+
}
|
|
28333
|
+
|
|
28334
|
+
// src/beads/provision-lock.ts
|
|
28335
|
+
var STALE_LOCK_MS = 5 * 6e4;
|
|
28310
28336
|
function tryAcquire(lockDir, deps) {
|
|
28311
28337
|
const pid = deps.pid ?? process.pid;
|
|
28312
28338
|
try {
|
|
28313
|
-
|
|
28314
|
-
|
|
28315
|
-
|
|
28339
|
+
import_fs8.default.mkdirSync(import_path9.default.dirname(lockDir), { recursive: true });
|
|
28340
|
+
import_fs8.default.mkdirSync(lockDir);
|
|
28341
|
+
import_fs8.default.writeFileSync(import_path9.default.join(lockDir, "pid"), ownerRecord(pid, deps));
|
|
28316
28342
|
return true;
|
|
28317
28343
|
} catch (err) {
|
|
28318
28344
|
if (err.code !== "EEXIST") return true;
|
|
28319
28345
|
}
|
|
28320
28346
|
let age;
|
|
28321
28347
|
try {
|
|
28322
|
-
age = (deps.now ?? Date.now)() -
|
|
28348
|
+
age = (deps.now ?? Date.now)() - import_fs8.default.statSync(lockDir).mtimeMs;
|
|
28323
28349
|
} catch {
|
|
28324
28350
|
return tryAcquireOnce(lockDir, deps);
|
|
28325
28351
|
}
|
|
28326
|
-
let holder =
|
|
28352
|
+
let holder = "";
|
|
28327
28353
|
try {
|
|
28328
|
-
holder =
|
|
28354
|
+
holder = import_fs8.default.readFileSync(import_path9.default.join(lockDir, "pid"), "utf8");
|
|
28329
28355
|
} catch {
|
|
28330
28356
|
if (age <= 1e4) return false;
|
|
28331
28357
|
}
|
|
28332
|
-
const alive =
|
|
28358
|
+
const alive = holder !== "" && ownerIsAlive(holder, deps);
|
|
28333
28359
|
if (alive && age <= STALE_LOCK_MS) return false;
|
|
28334
28360
|
try {
|
|
28335
|
-
|
|
28361
|
+
import_fs8.default.rmSync(lockDir, { recursive: true, force: true });
|
|
28336
28362
|
} catch {
|
|
28337
28363
|
return false;
|
|
28338
28364
|
}
|
|
@@ -28340,8 +28366,8 @@ function tryAcquire(lockDir, deps) {
|
|
|
28340
28366
|
}
|
|
28341
28367
|
function tryAcquireOnce(lockDir, deps) {
|
|
28342
28368
|
try {
|
|
28343
|
-
|
|
28344
|
-
|
|
28369
|
+
import_fs8.default.mkdirSync(lockDir);
|
|
28370
|
+
import_fs8.default.writeFileSync(import_path9.default.join(lockDir, "pid"), ownerRecord(deps.pid ?? process.pid, deps));
|
|
28345
28371
|
return true;
|
|
28346
28372
|
} catch {
|
|
28347
28373
|
return false;
|
|
@@ -28362,8 +28388,8 @@ async function withBeadsProvisionLock(fn, deps = {}) {
|
|
|
28362
28388
|
} finally {
|
|
28363
28389
|
if (held) {
|
|
28364
28390
|
try {
|
|
28365
|
-
const owner = Number(
|
|
28366
|
-
if (owner === (deps.pid ?? process.pid))
|
|
28391
|
+
const owner = Number(import_fs8.default.readFileSync(import_path9.default.join(lockDir, "pid"), "utf8").trim().split(/\s+/)[0]);
|
|
28392
|
+
if (owner === (deps.pid ?? process.pid)) import_fs8.default.rmSync(lockDir, { recursive: true, force: true });
|
|
28367
28393
|
} catch {
|
|
28368
28394
|
}
|
|
28369
28395
|
}
|
|
@@ -28639,7 +28665,7 @@ function saveFilesTemp(files) {
|
|
|
28639
28665
|
return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
|
|
28640
28666
|
const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
|
|
28641
28667
|
const tmpPath = path73.join(os47.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
|
|
28642
|
-
|
|
28668
|
+
fs65.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
|
|
28643
28669
|
pendingAttachmentFiles.add(tmpPath);
|
|
28644
28670
|
return tmpPath;
|
|
28645
28671
|
});
|
|
@@ -28887,7 +28913,7 @@ var envReadH = async (ctx, cmd) => {
|
|
|
28887
28913
|
const envPath = path73.join(process.cwd(), ".env");
|
|
28888
28914
|
await restoreProjectEnvIfMissing(process.cwd(), ctx);
|
|
28889
28915
|
try {
|
|
28890
|
-
const raw = await
|
|
28916
|
+
const raw = await fs65.promises.readFile(envPath, "utf8");
|
|
28891
28917
|
await ctx.relay.sendResult(cmd.id, "completed", {
|
|
28892
28918
|
exists: true,
|
|
28893
28919
|
vars: parseDotenv(raw)
|
|
@@ -28916,7 +28942,7 @@ var envParseH = async (ctx, cmd, parsed) => {
|
|
|
28916
28942
|
const existing = /* @__PURE__ */ new Map();
|
|
28917
28943
|
if (!replace) {
|
|
28918
28944
|
try {
|
|
28919
|
-
const raw = await
|
|
28945
|
+
const raw = await fs65.promises.readFile(path73.join(process.cwd(), ".env"), "utf8");
|
|
28920
28946
|
for (const v of parseDotenv(raw)) existing.set(v.key, v.value);
|
|
28921
28947
|
} catch {
|
|
28922
28948
|
}
|
|
@@ -28959,12 +28985,12 @@ var envWriteH = async (ctx, cmd, parsed) => {
|
|
|
28959
28985
|
const envPath = path73.join(process.cwd(), ".env");
|
|
28960
28986
|
const tmpPath = path73.join(process.cwd(), ".env.codeam.tmp");
|
|
28961
28987
|
try {
|
|
28962
|
-
await
|
|
28963
|
-
await
|
|
28988
|
+
await fs65.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
|
|
28989
|
+
await fs65.promises.rename(tmpPath, envPath);
|
|
28964
28990
|
await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
|
|
28965
28991
|
void syncProjectEnvUp(process.cwd(), ctx);
|
|
28966
28992
|
} catch (err) {
|
|
28967
|
-
await
|
|
28993
|
+
await fs65.promises.rm(tmpPath, { force: true }).catch(() => void 0);
|
|
28968
28994
|
await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
|
|
28969
28995
|
}
|
|
28970
28996
|
};
|
|
@@ -29313,7 +29339,7 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
|
|
|
29313
29339
|
function buildNpmInstallInvocation(opts) {
|
|
29314
29340
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
29315
29341
|
const execPath = opts?.execPath ?? process.execPath;
|
|
29316
|
-
const exists2 = opts?.existsSync ??
|
|
29342
|
+
const exists2 = opts?.existsSync ?? fs65.existsSync;
|
|
29317
29343
|
const platform3 = opts?.platform ?? process.platform;
|
|
29318
29344
|
const p2 = platform3 === "win32" ? path73.win32 : path73.posix;
|
|
29319
29345
|
const normalized = entryScript.split(/[\\/]/).join("/");
|
|
@@ -29344,9 +29370,9 @@ function resolveGlobalNodeModulesDir(opts) {
|
|
|
29344
29370
|
var STALE_STAGING_AGE_MS = CLI_UPDATE_INSTALL_TIMEOUT_MS;
|
|
29345
29371
|
function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
29346
29372
|
if (!nodeModulesDir) return 0;
|
|
29347
|
-
const readdirSync18 = deps?.readdirSync ??
|
|
29348
|
-
const statSync17 = deps?.statSync ??
|
|
29349
|
-
const rmSync14 = deps?.rmSync ??
|
|
29373
|
+
const readdirSync18 = deps?.readdirSync ?? fs65.readdirSync;
|
|
29374
|
+
const statSync17 = deps?.statSync ?? fs65.statSync;
|
|
29375
|
+
const rmSync14 = deps?.rmSync ?? fs65.rmSync;
|
|
29350
29376
|
let removed = 0;
|
|
29351
29377
|
let entries2;
|
|
29352
29378
|
try {
|
|
@@ -29381,16 +29407,16 @@ async function runNpmInstallLatest() {
|
|
|
29381
29407
|
const invocation = buildNpmInstallInvocation({ sudo: useSudo });
|
|
29382
29408
|
const useShell = process.platform === "win32";
|
|
29383
29409
|
const command2 = useShell && invocation.command.includes(" ") ? `"${invocation.command}"` : invocation.command;
|
|
29384
|
-
const result = await new Promise((
|
|
29410
|
+
const result = await new Promise((resolve13) => {
|
|
29385
29411
|
(0, import_child_process25.execFile)(
|
|
29386
29412
|
command2,
|
|
29387
29413
|
invocation.args,
|
|
29388
29414
|
{ timeout: CLI_UPDATE_INSTALL_TIMEOUT_MS, shell: useShell },
|
|
29389
29415
|
(err, _stdout, stderr) => {
|
|
29390
29416
|
if (!err) {
|
|
29391
|
-
|
|
29417
|
+
resolve13({ ok: true });
|
|
29392
29418
|
} else {
|
|
29393
|
-
|
|
29419
|
+
resolve13({ ok: false, error: (stderr || err.message).slice(0, 300) });
|
|
29394
29420
|
}
|
|
29395
29421
|
}
|
|
29396
29422
|
);
|
|
@@ -29743,8 +29769,8 @@ async function runDetectOneShot(generate, timeoutMs = PREVIEW_DETECT_TIMEOUT_MS)
|
|
|
29743
29769
|
};
|
|
29744
29770
|
const onFailedOutput = (stdout) => onStderr(`
|
|
29745
29771
|
${stdout}`);
|
|
29746
|
-
const deadline = new Promise((
|
|
29747
|
-
timer = setTimeout(() =>
|
|
29772
|
+
const deadline = new Promise((resolve13) => {
|
|
29773
|
+
timer = setTimeout(() => resolve13({ raw: null, timedOut: true, stderr }), timeoutMs);
|
|
29748
29774
|
timer.unref?.();
|
|
29749
29775
|
});
|
|
29750
29776
|
const oneShot = generate(PREVIEW_DETECT_PROMPT, { timeoutMs, onStderr, onFailedOutput }).then(
|
|
@@ -30212,7 +30238,7 @@ function buildKeepAlive(ctx) {
|
|
|
30212
30238
|
let timer = null;
|
|
30213
30239
|
async function setIdleTimeout(minutes) {
|
|
30214
30240
|
if (!ctx.inCodespace || !ctx.codespaceName) return;
|
|
30215
|
-
await new Promise((
|
|
30241
|
+
await new Promise((resolve13) => {
|
|
30216
30242
|
const proc = (0, import_child_process26.spawn)(
|
|
30217
30243
|
"gh",
|
|
30218
30244
|
[
|
|
@@ -30226,8 +30252,8 @@ function buildKeepAlive(ctx) {
|
|
|
30226
30252
|
{ stdio: "ignore", detached: true }
|
|
30227
30253
|
);
|
|
30228
30254
|
proc.unref();
|
|
30229
|
-
proc.on("exit", () =>
|
|
30230
|
-
proc.on("error", () =>
|
|
30255
|
+
proc.on("exit", () => resolve13());
|
|
30256
|
+
proc.on("error", () => resolve13());
|
|
30231
30257
|
});
|
|
30232
30258
|
}
|
|
30233
30259
|
return {
|
|
@@ -30481,7 +30507,7 @@ function resolveTokenValue(args2) {
|
|
|
30481
30507
|
if (fileFlag) {
|
|
30482
30508
|
const path114 = fileFlag.slice("--token-file=".length);
|
|
30483
30509
|
try {
|
|
30484
|
-
const content =
|
|
30510
|
+
const content = fs66.readFileSync(path114, "utf8").trim();
|
|
30485
30511
|
if (content.length === 0) fail(`--token-file ${path114} is empty`);
|
|
30486
30512
|
rmIfExistsQuiet(path114);
|
|
30487
30513
|
return content;
|
|
@@ -30580,7 +30606,7 @@ function pairAutoLockPath() {
|
|
|
30580
30606
|
var procRoot = "/proc";
|
|
30581
30607
|
function readProcFile(rel) {
|
|
30582
30608
|
try {
|
|
30583
|
-
return
|
|
30609
|
+
return fs66.readFileSync(path74.join(procRoot, rel), "utf8");
|
|
30584
30610
|
} catch {
|
|
30585
30611
|
return void 0;
|
|
30586
30612
|
}
|
|
@@ -30601,7 +30627,7 @@ function currentBootId() {
|
|
|
30601
30627
|
function readLockRecord(lockPath) {
|
|
30602
30628
|
let raw;
|
|
30603
30629
|
try {
|
|
30604
|
-
raw =
|
|
30630
|
+
raw = fs66.readFileSync(lockPath, "utf8");
|
|
30605
30631
|
} catch {
|
|
30606
30632
|
return void 0;
|
|
30607
30633
|
}
|
|
@@ -30650,7 +30676,7 @@ function isLiveLockHolder(rec) {
|
|
|
30650
30676
|
}
|
|
30651
30677
|
function releaseOwnLock(lockPath) {
|
|
30652
30678
|
try {
|
|
30653
|
-
if (readLockRecord(lockPath)?.pid === process.pid)
|
|
30679
|
+
if (readLockRecord(lockPath)?.pid === process.pid) fs66.unlinkSync(lockPath);
|
|
30654
30680
|
} catch {
|
|
30655
30681
|
}
|
|
30656
30682
|
}
|
|
@@ -30674,7 +30700,7 @@ function snapshotProcessTree(root) {
|
|
|
30674
30700
|
const children = /* @__PURE__ */ new Map();
|
|
30675
30701
|
let entries2 = [];
|
|
30676
30702
|
try {
|
|
30677
|
-
entries2 =
|
|
30703
|
+
entries2 = fs66.readdirSync(procRoot).filter((e) => /^\d+$/.test(e));
|
|
30678
30704
|
} catch {
|
|
30679
30705
|
}
|
|
30680
30706
|
for (const e of entries2) {
|
|
@@ -30714,13 +30740,13 @@ function daemonLockPath(sessionId) {
|
|
|
30714
30740
|
function acquireDaemonLock(sessionId) {
|
|
30715
30741
|
const lockPath = daemonLockPath(sessionId);
|
|
30716
30742
|
try {
|
|
30717
|
-
|
|
30743
|
+
fs66.mkdirSync(path74.dirname(lockPath), { recursive: true });
|
|
30718
30744
|
try {
|
|
30719
|
-
|
|
30745
|
+
fs66.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
30720
30746
|
} catch (e) {
|
|
30721
30747
|
if (e.code !== "EEXIST") throw e;
|
|
30722
30748
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
30723
|
-
|
|
30749
|
+
fs66.writeFileSync(lockPath, ownLockBody());
|
|
30724
30750
|
}
|
|
30725
30751
|
const release3 = () => releaseOwnLock(lockPath);
|
|
30726
30752
|
process.once("exit", release3);
|
|
@@ -30740,13 +30766,13 @@ function acquireDaemonLock(sessionId) {
|
|
|
30740
30766
|
function acquireSingletonLock() {
|
|
30741
30767
|
const lockPath = pairAutoLockPath();
|
|
30742
30768
|
try {
|
|
30743
|
-
|
|
30769
|
+
fs66.mkdirSync(path74.dirname(lockPath), { recursive: true });
|
|
30744
30770
|
try {
|
|
30745
|
-
|
|
30771
|
+
fs66.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
30746
30772
|
} catch (e) {
|
|
30747
30773
|
if (e.code !== "EEXIST") throw e;
|
|
30748
30774
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
30749
|
-
|
|
30775
|
+
fs66.writeFileSync(lockPath, ownLockBody());
|
|
30750
30776
|
}
|
|
30751
30777
|
process.once("exit", () => releaseOwnLock(lockPath));
|
|
30752
30778
|
return true;
|
|
@@ -31184,10 +31210,10 @@ function augmentKimiPath() {
|
|
|
31184
31210
|
}
|
|
31185
31211
|
var augmentPath2 = augmentKimiPath;
|
|
31186
31212
|
async function runInstaller2() {
|
|
31187
|
-
return new Promise((
|
|
31213
|
+
return new Promise((resolve13) => {
|
|
31188
31214
|
const proc = (0, import_node_child_process25.spawn)("sh", ["-c", `curl -fsSL ${INSTALL_URL2} | bash`], { stdio: "inherit" });
|
|
31189
|
-
proc.on("close", (code) =>
|
|
31190
|
-
proc.on("error", () =>
|
|
31215
|
+
proc.on("close", (code) => resolve13(code === 0));
|
|
31216
|
+
proc.on("error", () => resolve13(false));
|
|
31191
31217
|
});
|
|
31192
31218
|
}
|
|
31193
31219
|
async function ensureKimiInstalled() {
|
|
@@ -31237,10 +31263,10 @@ function augmentOpencodePath() {
|
|
|
31237
31263
|
}
|
|
31238
31264
|
var augmentPath3 = augmentOpencodePath;
|
|
31239
31265
|
async function runInstaller3() {
|
|
31240
|
-
return new Promise((
|
|
31266
|
+
return new Promise((resolve13) => {
|
|
31241
31267
|
const proc = (0, import_node_child_process26.spawn)("sh", ["-c", `curl -fsSL ${INSTALL_URL3} | bash`], { stdio: "inherit" });
|
|
31242
|
-
proc.on("close", (code) =>
|
|
31243
|
-
proc.on("error", () =>
|
|
31268
|
+
proc.on("close", (code) => resolve13(code === 0));
|
|
31269
|
+
proc.on("error", () => resolve13(false));
|
|
31244
31270
|
});
|
|
31245
31271
|
}
|
|
31246
31272
|
async function ensureOpencodeInstalled() {
|
|
@@ -31448,11 +31474,11 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
|
|
|
31448
31474
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_ADAPTER_RETRY_TIMEOUT_MS;
|
|
31449
31475
|
const pollMs = opts.pollMs ?? DEFAULT_ADAPTER_RETRY_POLL_MS;
|
|
31450
31476
|
const now = opts.now ?? Date.now;
|
|
31451
|
-
const sleep5 = opts.sleep ?? ((ms) => new Promise((
|
|
31452
|
-
const
|
|
31477
|
+
const sleep5 = opts.sleep ?? ((ms) => new Promise((resolve14) => setTimeout(resolve14, ms)));
|
|
31478
|
+
const resolve13 = opts.resolve ?? getAcpAdapter;
|
|
31453
31479
|
const attempt = () => {
|
|
31454
31480
|
try {
|
|
31455
|
-
return
|
|
31481
|
+
return resolve13(agent);
|
|
31456
31482
|
} catch {
|
|
31457
31483
|
return null;
|
|
31458
31484
|
}
|
|
@@ -31469,26 +31495,19 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
|
|
|
31469
31495
|
}
|
|
31470
31496
|
|
|
31471
31497
|
// src/commands/start/agent-startup-marks.ts
|
|
31472
|
-
var
|
|
31498
|
+
var import_fs9 = __toESM(require("fs"));
|
|
31473
31499
|
var import_os13 = __toESM(require("os"));
|
|
31474
31500
|
var import_path10 = __toESM(require("path"));
|
|
31475
31501
|
var STALE_MARK_MS = 18e4;
|
|
31476
31502
|
function marksDir(deps) {
|
|
31477
31503
|
return deps.dir ?? import_path10.default.join(import_os13.default.homedir(), ".codeam", "agent-startups");
|
|
31478
31504
|
}
|
|
31479
|
-
function pidIsAlive2(pid) {
|
|
31480
|
-
try {
|
|
31481
|
-
process.kill(pid, 0);
|
|
31482
|
-
return true;
|
|
31483
|
-
} catch (err) {
|
|
31484
|
-
return err.code === "EPERM";
|
|
31485
|
-
}
|
|
31486
|
-
}
|
|
31487
31505
|
function markAgentStarting(deps = {}) {
|
|
31488
|
-
const
|
|
31506
|
+
const pid = deps.pid ?? process.pid;
|
|
31507
|
+
const file = import_path10.default.join(marksDir(deps), String(pid));
|
|
31489
31508
|
try {
|
|
31490
|
-
|
|
31491
|
-
|
|
31509
|
+
import_fs9.default.mkdirSync(import_path10.default.dirname(file), { recursive: true });
|
|
31510
|
+
import_fs9.default.writeFileSync(file, ownerRecord(pid, deps));
|
|
31492
31511
|
} catch {
|
|
31493
31512
|
return () => void 0;
|
|
31494
31513
|
}
|
|
@@ -31497,7 +31516,7 @@ function markAgentStarting(deps = {}) {
|
|
|
31497
31516
|
if (released) return;
|
|
31498
31517
|
released = true;
|
|
31499
31518
|
try {
|
|
31500
|
-
|
|
31519
|
+
import_fs9.default.rmSync(file, { force: true });
|
|
31501
31520
|
} catch {
|
|
31502
31521
|
}
|
|
31503
31522
|
};
|
|
@@ -31506,10 +31525,9 @@ function otherAgentsStarting(deps = {}) {
|
|
|
31506
31525
|
const dir = marksDir(deps);
|
|
31507
31526
|
const self = deps.pid ?? process.pid;
|
|
31508
31527
|
const now = (deps.now ?? Date.now)();
|
|
31509
|
-
const isAlive = deps.isAlive ?? pidIsAlive2;
|
|
31510
31528
|
let names;
|
|
31511
31529
|
try {
|
|
31512
|
-
names =
|
|
31530
|
+
names = import_fs9.default.readdirSync(dir);
|
|
31513
31531
|
} catch {
|
|
31514
31532
|
return [];
|
|
31515
31533
|
}
|
|
@@ -31518,17 +31536,23 @@ function otherAgentsStarting(deps = {}) {
|
|
|
31518
31536
|
const pid = Number(name);
|
|
31519
31537
|
if (!Number.isInteger(pid) || pid <= 0 || pid === self) continue;
|
|
31520
31538
|
const file = import_path10.default.join(dir, name);
|
|
31521
|
-
let
|
|
31539
|
+
let record2 = "";
|
|
31540
|
+
try {
|
|
31541
|
+
record2 = import_fs9.default.readFileSync(file, "utf8");
|
|
31542
|
+
} catch {
|
|
31543
|
+
continue;
|
|
31544
|
+
}
|
|
31545
|
+
let stale = !ownerIsAlive(record2.trim() || String(pid), deps);
|
|
31522
31546
|
if (!stale) {
|
|
31523
31547
|
try {
|
|
31524
|
-
stale = now -
|
|
31548
|
+
stale = now - import_fs9.default.statSync(file).mtimeMs > STALE_MARK_MS;
|
|
31525
31549
|
} catch {
|
|
31526
31550
|
continue;
|
|
31527
31551
|
}
|
|
31528
31552
|
}
|
|
31529
31553
|
if (stale) {
|
|
31530
31554
|
try {
|
|
31531
|
-
|
|
31555
|
+
import_fs9.default.rmSync(file, { force: true });
|
|
31532
31556
|
} catch {
|
|
31533
31557
|
}
|
|
31534
31558
|
continue;
|
|
@@ -31548,7 +31572,7 @@ async function waitForNoAgentStarting(opts) {
|
|
|
31548
31572
|
|
|
31549
31573
|
// src/agents/acp/runner.ts
|
|
31550
31574
|
var import_node_crypto15 = require("crypto");
|
|
31551
|
-
var
|
|
31575
|
+
var fs86 = __toESM(require("fs"));
|
|
31552
31576
|
var os61 = __toESM(require("os"));
|
|
31553
31577
|
var path96 = __toESM(require("path"));
|
|
31554
31578
|
|
|
@@ -31582,7 +31606,7 @@ function noteProviderBillingSignal(opts) {
|
|
|
31582
31606
|
}
|
|
31583
31607
|
|
|
31584
31608
|
// src/services/history.service.ts
|
|
31585
|
-
var
|
|
31609
|
+
var fs68 = __toESM(require("fs"));
|
|
31586
31610
|
var path77 = __toESM(require("path"));
|
|
31587
31611
|
var https6 = __toESM(require("https"));
|
|
31588
31612
|
var http10 = __toESM(require("http"));
|
|
@@ -31644,7 +31668,7 @@ function parseJsonl(filePath) {
|
|
|
31644
31668
|
const messages = [];
|
|
31645
31669
|
let raw;
|
|
31646
31670
|
try {
|
|
31647
|
-
raw =
|
|
31671
|
+
raw = fs68.readFileSync(filePath, "utf8");
|
|
31648
31672
|
} catch (err) {
|
|
31649
31673
|
if (err.code !== "ENOENT") {
|
|
31650
31674
|
log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
|
|
@@ -31685,7 +31709,7 @@ function parseJsonl(filePath) {
|
|
|
31685
31709
|
return messages;
|
|
31686
31710
|
}
|
|
31687
31711
|
function postWithStatus(endpoint, body, pluginAuthToken) {
|
|
31688
|
-
return new Promise((
|
|
31712
|
+
return new Promise((resolve13) => {
|
|
31689
31713
|
const payload = JSON.stringify(body);
|
|
31690
31714
|
const u2 = new URL(`${API_BASE7}${endpoint}`);
|
|
31691
31715
|
const transport = u2.protocol === "https:" ? https6 : http10;
|
|
@@ -31716,17 +31740,17 @@ function postWithStatus(endpoint, body, pluginAuthToken) {
|
|
|
31716
31740
|
const ra = Number(res.headers["retry-after"]);
|
|
31717
31741
|
retryAfterMs = Number.isFinite(ra) && ra > 0 ? ra * 1e3 : 2e4;
|
|
31718
31742
|
}
|
|
31719
|
-
|
|
31743
|
+
resolve13({ ok, status: status2, retryAfterMs });
|
|
31720
31744
|
}
|
|
31721
31745
|
);
|
|
31722
31746
|
req.on("error", (err) => {
|
|
31723
31747
|
log.warn("history:post", `${endpoint} network error`, err);
|
|
31724
|
-
|
|
31748
|
+
resolve13({ ok: false, status: null, retryAfterMs: null });
|
|
31725
31749
|
});
|
|
31726
31750
|
req.on("timeout", () => {
|
|
31727
31751
|
log.warn("history:post", `${endpoint} timeout after 15s`);
|
|
31728
31752
|
req.destroy();
|
|
31729
|
-
|
|
31753
|
+
resolve13({ ok: false, status: null, retryAfterMs: null });
|
|
31730
31754
|
});
|
|
31731
31755
|
req.write(payload);
|
|
31732
31756
|
req.end();
|
|
@@ -31854,11 +31878,11 @@ var HistoryService = class _HistoryService {
|
|
|
31854
31878
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
31855
31879
|
const oneShots = readOneShotConversations(this.cwd);
|
|
31856
31880
|
try {
|
|
31857
|
-
const files =
|
|
31881
|
+
const files = fs68.readdirSync(dir, { withFileTypes: true }).filter(
|
|
31858
31882
|
(e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(path77.basename(e.name, ".jsonl"))
|
|
31859
31883
|
).map((e) => {
|
|
31860
31884
|
try {
|
|
31861
|
-
const stat3 =
|
|
31885
|
+
const stat3 = fs68.statSync(path77.join(dir, e.name));
|
|
31862
31886
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
31863
31887
|
} catch {
|
|
31864
31888
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
@@ -31899,13 +31923,13 @@ var HistoryService = class _HistoryService {
|
|
|
31899
31923
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
31900
31924
|
let entries2;
|
|
31901
31925
|
try {
|
|
31902
|
-
entries2 =
|
|
31926
|
+
entries2 = fs68.readdirSync(dir, { withFileTypes: true });
|
|
31903
31927
|
} catch {
|
|
31904
31928
|
return null;
|
|
31905
31929
|
}
|
|
31906
31930
|
const files = entries2.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
31907
31931
|
try {
|
|
31908
|
-
const stat3 =
|
|
31932
|
+
const stat3 = fs68.statSync(path77.join(dir, e.name));
|
|
31909
31933
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
31910
31934
|
} catch {
|
|
31911
31935
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
@@ -31919,7 +31943,7 @@ var HistoryService = class _HistoryService {
|
|
|
31919
31943
|
extractUsageFromFile(filePath) {
|
|
31920
31944
|
let raw;
|
|
31921
31945
|
try {
|
|
31922
|
-
raw =
|
|
31946
|
+
raw = fs68.readFileSync(filePath, "utf8");
|
|
31923
31947
|
} catch {
|
|
31924
31948
|
return null;
|
|
31925
31949
|
}
|
|
@@ -31971,9 +31995,9 @@ var HistoryService = class _HistoryService {
|
|
|
31971
31995
|
let totalCost = 0;
|
|
31972
31996
|
let files;
|
|
31973
31997
|
try {
|
|
31974
|
-
files =
|
|
31998
|
+
files = fs68.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
|
|
31975
31999
|
try {
|
|
31976
|
-
return
|
|
32000
|
+
return fs68.statSync(path77.join(projectDir, f)).mtimeMs >= monthStartMs;
|
|
31977
32001
|
} catch {
|
|
31978
32002
|
return false;
|
|
31979
32003
|
}
|
|
@@ -31984,7 +32008,7 @@ var HistoryService = class _HistoryService {
|
|
|
31984
32008
|
for (const file of files) {
|
|
31985
32009
|
let raw;
|
|
31986
32010
|
try {
|
|
31987
|
-
raw =
|
|
32011
|
+
raw = fs68.readFileSync(path77.join(projectDir, file), "utf8");
|
|
31988
32012
|
} catch {
|
|
31989
32013
|
continue;
|
|
31990
32014
|
}
|
|
@@ -32183,7 +32207,7 @@ var HistoryService = class _HistoryService {
|
|
|
32183
32207
|
if (!filePath) return false;
|
|
32184
32208
|
let mtimeMs;
|
|
32185
32209
|
try {
|
|
32186
|
-
mtimeMs =
|
|
32210
|
+
mtimeMs = fs68.statSync(filePath).mtimeMs;
|
|
32187
32211
|
} catch {
|
|
32188
32212
|
return false;
|
|
32189
32213
|
}
|
|
@@ -32258,7 +32282,7 @@ var HistoryService = class _HistoryService {
|
|
|
32258
32282
|
|
|
32259
32283
|
// src/agents/acp/client.ts
|
|
32260
32284
|
var import_node_child_process27 = require("child_process");
|
|
32261
|
-
var
|
|
32285
|
+
var fs69 = __toESM(require("fs/promises"));
|
|
32262
32286
|
var fsSync = __toESM(require("fs"));
|
|
32263
32287
|
var os51 = __toESM(require("os"));
|
|
32264
32288
|
var path79 = __toESM(require("path"));
|
|
@@ -34300,12 +34324,12 @@ var Connection = class {
|
|
|
34300
34324
|
const id = this.nextRequestId++;
|
|
34301
34325
|
let cancel = () => {
|
|
34302
34326
|
};
|
|
34303
|
-
const responsePromise = new Promise((
|
|
34327
|
+
const responsePromise = new Promise((resolve13, reject) => {
|
|
34304
34328
|
const pendingResponse = {
|
|
34305
34329
|
resolve: (response) => {
|
|
34306
34330
|
try {
|
|
34307
34331
|
const value = mapResponse ? mapResponse(response) : response;
|
|
34308
|
-
|
|
34332
|
+
resolve13(value);
|
|
34309
34333
|
} catch (error) {
|
|
34310
34334
|
reject(error);
|
|
34311
34335
|
}
|
|
@@ -34383,8 +34407,8 @@ var Connection = class {
|
|
|
34383
34407
|
initialize(stream, handlers2) {
|
|
34384
34408
|
this.stream = stream;
|
|
34385
34409
|
this.staticHandlers = handlers2;
|
|
34386
|
-
this.closedPromise = new Promise((
|
|
34387
|
-
this.abortController.signal.addEventListener("abort", () =>
|
|
34410
|
+
this.closedPromise = new Promise((resolve13) => {
|
|
34411
|
+
this.abortController.signal.addEventListener("abort", () => resolve13());
|
|
34388
34412
|
});
|
|
34389
34413
|
void this.receive();
|
|
34390
34414
|
}
|
|
@@ -35172,8 +35196,8 @@ var AsyncQueue = class {
|
|
|
35172
35196
|
if (this.failed) {
|
|
35173
35197
|
return Promise.reject(this.failure);
|
|
35174
35198
|
}
|
|
35175
|
-
return new Promise((
|
|
35176
|
-
this.waiters.push({ resolve:
|
|
35199
|
+
return new Promise((resolve13, reject) => {
|
|
35200
|
+
this.waiters.push({ resolve: resolve13, reject });
|
|
35177
35201
|
});
|
|
35178
35202
|
}
|
|
35179
35203
|
};
|
|
@@ -36865,7 +36889,7 @@ var AcpClient = class {
|
|
|
36865
36889
|
this.pendingToolCalls.clear();
|
|
36866
36890
|
try {
|
|
36867
36891
|
const result = await Promise.race([send, idle.promise]);
|
|
36868
|
-
await new Promise((
|
|
36892
|
+
await new Promise((resolve13) => setImmediate(resolve13));
|
|
36869
36893
|
log.info(
|
|
36870
36894
|
"acpClient",
|
|
36871
36895
|
`prompt \u2190 ok stopReason=${result.stopReason ?? "?"} elapsedMs=${Date.now() - t0}`
|
|
@@ -37081,8 +37105,8 @@ var AcpClient = class {
|
|
|
37081
37105
|
if (!this.connection || !this.sessionId) return "deferred";
|
|
37082
37106
|
this.mcpReprovisionPending = servers;
|
|
37083
37107
|
if (this.mcpDebounceTimer) clearTimeout(this.mcpDebounceTimer);
|
|
37084
|
-
const settled = new Promise((
|
|
37085
|
-
this.mcpDebounceWaiters.push(
|
|
37108
|
+
const settled = new Promise((resolve13) => {
|
|
37109
|
+
this.mcpDebounceWaiters.push(resolve13);
|
|
37086
37110
|
});
|
|
37087
37111
|
this.mcpDebounceTimer = setTimeout(() => {
|
|
37088
37112
|
this.mcpDebounceTimer = null;
|
|
@@ -37326,15 +37350,15 @@ var AcpClient = class {
|
|
|
37326
37350
|
} else {
|
|
37327
37351
|
child.kill("SIGTERM");
|
|
37328
37352
|
}
|
|
37329
|
-
const grace = new Promise((
|
|
37353
|
+
const grace = new Promise((resolve13) => {
|
|
37330
37354
|
const t2 = setTimeout(() => {
|
|
37331
37355
|
if (process.platform !== "win32" && pid) killQuiet(-pid, "SIGKILL");
|
|
37332
37356
|
else killQuiet(child, "SIGKILL");
|
|
37333
|
-
|
|
37357
|
+
resolve13();
|
|
37334
37358
|
}, 2e3);
|
|
37335
37359
|
child.once("exit", () => {
|
|
37336
37360
|
clearTimeout(t2);
|
|
37337
|
-
|
|
37361
|
+
resolve13();
|
|
37338
37362
|
});
|
|
37339
37363
|
});
|
|
37340
37364
|
await grace;
|
|
@@ -37402,7 +37426,7 @@ var AcpClient = class {
|
|
|
37402
37426
|
throw new RequestError(-32002, GUARDRAIL_SECRET_READ_BLOCK_REASON, { uri: params.path });
|
|
37403
37427
|
}
|
|
37404
37428
|
try {
|
|
37405
|
-
const content = await
|
|
37429
|
+
const content = await fs69.readFile(params.path, "utf8");
|
|
37406
37430
|
return applyLineRange(content, params.line ?? null, params.limit ?? null);
|
|
37407
37431
|
} catch (err) {
|
|
37408
37432
|
const code = err.code;
|
|
@@ -37423,7 +37447,7 @@ var AcpClient = class {
|
|
|
37423
37447
|
throw new RequestError(-32002, INTERNAL_BLOCK_REASON, { uri: params.path });
|
|
37424
37448
|
}
|
|
37425
37449
|
try {
|
|
37426
|
-
await
|
|
37450
|
+
await fs69.writeFile(params.path, params.content, "utf8");
|
|
37427
37451
|
return {};
|
|
37428
37452
|
} catch (err) {
|
|
37429
37453
|
const code = err.code;
|
|
@@ -37563,7 +37587,7 @@ var os52 = __toESM(require("os"));
|
|
|
37563
37587
|
function runAgentInstallScript(script, opts = {}) {
|
|
37564
37588
|
const timeoutMs = opts.timeoutMs ?? 18e4;
|
|
37565
37589
|
const scope = opts.logScope ?? "agent-install";
|
|
37566
|
-
return new Promise((
|
|
37590
|
+
return new Promise((resolve13) => {
|
|
37567
37591
|
const home = process.env.HOME || os52.homedir();
|
|
37568
37592
|
const child = (0, import_child_process27.spawn)("sh", ["-c", script], {
|
|
37569
37593
|
env: { ...process.env, HOME: home },
|
|
@@ -37579,7 +37603,7 @@ function runAgentInstallScript(script, opts = {}) {
|
|
|
37579
37603
|
const done = (result) => {
|
|
37580
37604
|
if (settled) return;
|
|
37581
37605
|
settled = true;
|
|
37582
|
-
|
|
37606
|
+
resolve13(result);
|
|
37583
37607
|
};
|
|
37584
37608
|
const timer = setTimeout(() => {
|
|
37585
37609
|
log.warn(scope, `agent install timed out (${Math.round(timeoutMs / 1e3)}s)`);
|
|
@@ -37826,7 +37850,7 @@ async function performAgentSwitch(deps, rawAgentId, fastPath = {}) {
|
|
|
37826
37850
|
}
|
|
37827
37851
|
|
|
37828
37852
|
// src/commands/host/agent-provisioning.ts
|
|
37829
|
-
var
|
|
37853
|
+
var fs70 = __toESM(require("fs"));
|
|
37830
37854
|
var os53 = __toESM(require("os"));
|
|
37831
37855
|
var path80 = __toESM(require("path"));
|
|
37832
37856
|
var PUBLIC_TO_INTERNAL_AGENT = {
|
|
@@ -37845,16 +37869,16 @@ function toInternalAgentId(publicAgentId) {
|
|
|
37845
37869
|
return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
|
|
37846
37870
|
}
|
|
37847
37871
|
function ensureDir(dir) {
|
|
37848
|
-
|
|
37872
|
+
fs70.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
37849
37873
|
}
|
|
37850
37874
|
function writeFile0600(filePath, contents) {
|
|
37851
37875
|
ensureDir(path80.dirname(filePath));
|
|
37852
|
-
|
|
37876
|
+
fs70.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
|
|
37853
37877
|
restrictToOwner(filePath);
|
|
37854
37878
|
}
|
|
37855
37879
|
function rmIfExists(filePath) {
|
|
37856
37880
|
try {
|
|
37857
|
-
|
|
37881
|
+
fs70.rmSync(filePath, { force: true });
|
|
37858
37882
|
} catch {
|
|
37859
37883
|
}
|
|
37860
37884
|
}
|
|
@@ -37873,7 +37897,7 @@ var claudeProvisioner = {
|
|
|
37873
37897
|
rmIfExists(credentialsJson);
|
|
37874
37898
|
}
|
|
37875
37899
|
const claudeJson = path80.join(home, ".claude.json");
|
|
37876
|
-
if (!
|
|
37900
|
+
if (!fs70.existsSync(claudeJson)) {
|
|
37877
37901
|
writeFile0600(
|
|
37878
37902
|
claudeJson,
|
|
37879
37903
|
JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
|
|
@@ -37907,7 +37931,7 @@ function codexLoginStamp(raw) {
|
|
|
37907
37931
|
function keepsFresherCodexLogin(authJsonPath, incoming) {
|
|
37908
37932
|
let onDisk;
|
|
37909
37933
|
try {
|
|
37910
|
-
onDisk =
|
|
37934
|
+
onDisk = fs70.readFileSync(authJsonPath, "utf8");
|
|
37911
37935
|
} catch {
|
|
37912
37936
|
return false;
|
|
37913
37937
|
}
|
|
@@ -38044,7 +38068,7 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os53.homedir(
|
|
|
38044
38068
|
}
|
|
38045
38069
|
|
|
38046
38070
|
// src/beads/workflow-hint.ts
|
|
38047
|
-
var
|
|
38071
|
+
var fs71 = __toESM(require("fs"));
|
|
38048
38072
|
var path81 = __toESM(require("path"));
|
|
38049
38073
|
var BEADS_HINT_MARKER = "<!-- codeam:beads-workflow -->";
|
|
38050
38074
|
var BEADS_HINT = `${BEADS_HINT_MARKER}
|
|
@@ -38072,11 +38096,11 @@ function ensureBeadsWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
|
38072
38096
|
try {
|
|
38073
38097
|
let existing = "";
|
|
38074
38098
|
try {
|
|
38075
|
-
existing =
|
|
38099
|
+
existing = fs71.readFileSync(file, "utf8");
|
|
38076
38100
|
} catch {
|
|
38077
38101
|
}
|
|
38078
38102
|
if (existing.includes(BEADS_HINT)) return;
|
|
38079
|
-
|
|
38103
|
+
fs71.mkdirSync(path81.dirname(file), { recursive: true });
|
|
38080
38104
|
let next;
|
|
38081
38105
|
const open = existing.indexOf(BEADS_HINT_MARKER);
|
|
38082
38106
|
const close = open === -1 ? -1 : existing.indexOf(BEADS_HINT_MARKER, open + BEADS_HINT_MARKER.length);
|
|
@@ -38089,40 +38113,40 @@ ${BEADS_HINT}
|
|
|
38089
38113
|
` : `${BEADS_HINT}
|
|
38090
38114
|
`;
|
|
38091
38115
|
}
|
|
38092
|
-
|
|
38116
|
+
fs71.writeFileSync(file, next);
|
|
38093
38117
|
} catch {
|
|
38094
38118
|
}
|
|
38095
38119
|
}
|
|
38096
38120
|
|
|
38097
38121
|
// src/agents/agent-standard.ts
|
|
38098
|
-
var
|
|
38122
|
+
var fs72 = __toESM(require("fs"));
|
|
38099
38123
|
var path82 = __toESM(require("path"));
|
|
38100
38124
|
var os54 = __toESM(require("os"));
|
|
38101
38125
|
function ensureAgentStandard(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
38102
38126
|
try {
|
|
38103
38127
|
let existing = "";
|
|
38104
38128
|
try {
|
|
38105
|
-
existing =
|
|
38129
|
+
existing = fs72.readFileSync(file, "utf8");
|
|
38106
38130
|
} catch {
|
|
38107
38131
|
}
|
|
38108
38132
|
if (existing.includes(AGENT_STANDARD_MARKER)) return;
|
|
38109
|
-
|
|
38133
|
+
fs72.mkdirSync(path82.dirname(file), { recursive: true });
|
|
38110
38134
|
const next = existing.trim() ? `${existing.trimEnd()}
|
|
38111
38135
|
|
|
38112
38136
|
${AGENT_STANDARD_BLOCK}
|
|
38113
38137
|
` : `${AGENT_STANDARD_BLOCK}
|
|
38114
38138
|
`;
|
|
38115
|
-
|
|
38139
|
+
fs72.writeFileSync(file, next);
|
|
38116
38140
|
} catch {
|
|
38117
38141
|
}
|
|
38118
38142
|
}
|
|
38119
38143
|
var _agentStandardSeam = {
|
|
38120
38144
|
isLocalSession: () => isLocalSession(),
|
|
38121
38145
|
markerPath: (sessionId) => path82.join(os54.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
|
|
38122
|
-
exists: (p2) =>
|
|
38146
|
+
exists: (p2) => fs72.existsSync(p2),
|
|
38123
38147
|
write: (p2) => {
|
|
38124
|
-
|
|
38125
|
-
|
|
38148
|
+
fs72.mkdirSync(path82.dirname(p2), { recursive: true });
|
|
38149
|
+
fs72.writeFileSync(p2, "");
|
|
38126
38150
|
}
|
|
38127
38151
|
};
|
|
38128
38152
|
function isClaude(agent) {
|
|
@@ -38192,7 +38216,7 @@ var _transport4 = {
|
|
|
38192
38216
|
get: _get
|
|
38193
38217
|
};
|
|
38194
38218
|
function _post3(url2, headers, payload) {
|
|
38195
|
-
return new Promise((
|
|
38219
|
+
return new Promise((resolve13, reject) => {
|
|
38196
38220
|
let settled = false;
|
|
38197
38221
|
const u2 = new URL(url2);
|
|
38198
38222
|
const lib = u2.protocol === "https:" ? https7 : http11;
|
|
@@ -38217,7 +38241,7 @@ function _post3(url2, headers, payload) {
|
|
|
38217
38241
|
res.on("end", () => {
|
|
38218
38242
|
if (settled) return;
|
|
38219
38243
|
settled = true;
|
|
38220
|
-
|
|
38244
|
+
resolve13({ statusCode: res.statusCode ?? 0, body });
|
|
38221
38245
|
});
|
|
38222
38246
|
}
|
|
38223
38247
|
);
|
|
@@ -38234,7 +38258,7 @@ function _post3(url2, headers, payload) {
|
|
|
38234
38258
|
});
|
|
38235
38259
|
}
|
|
38236
38260
|
function _get(url2, headers) {
|
|
38237
|
-
return new Promise((
|
|
38261
|
+
return new Promise((resolve13, reject) => {
|
|
38238
38262
|
let settled = false;
|
|
38239
38263
|
const u2 = new URL(url2);
|
|
38240
38264
|
const lib = u2.protocol === "https:" ? https7 : http11;
|
|
@@ -38258,7 +38282,7 @@ function _get(url2, headers) {
|
|
|
38258
38282
|
res.on("end", () => {
|
|
38259
38283
|
if (settled) return;
|
|
38260
38284
|
settled = true;
|
|
38261
|
-
|
|
38285
|
+
resolve13({ statusCode: res.statusCode ?? 0, body });
|
|
38262
38286
|
});
|
|
38263
38287
|
}
|
|
38264
38288
|
);
|
|
@@ -38857,15 +38881,15 @@ function withholdTrailingPartialFenceMarker(text) {
|
|
|
38857
38881
|
|
|
38858
38882
|
// src/agents/acp/onboarding.ts
|
|
38859
38883
|
var import_child_process28 = require("child_process");
|
|
38860
|
-
var
|
|
38884
|
+
var fs74 = __toESM(require("fs"));
|
|
38861
38885
|
var os55 = __toESM(require("os"));
|
|
38862
38886
|
var path84 = __toESM(require("path"));
|
|
38863
38887
|
var _onboardingSeam = {
|
|
38864
38888
|
markerPath: (sessionId) => path84.join(os55.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
|
|
38865
|
-
exists: (p2) =>
|
|
38889
|
+
exists: (p2) => fs74.existsSync(p2),
|
|
38866
38890
|
write: (p2) => {
|
|
38867
|
-
|
|
38868
|
-
|
|
38891
|
+
fs74.mkdirSync(path84.dirname(p2), { recursive: true });
|
|
38892
|
+
fs74.writeFileSync(p2, "");
|
|
38869
38893
|
},
|
|
38870
38894
|
disabled: () => {
|
|
38871
38895
|
const v = process.env.CODEAM_ONBOARDING_DISABLED;
|
|
@@ -39294,13 +39318,13 @@ var import_crypto5 = require("crypto");
|
|
|
39294
39318
|
|
|
39295
39319
|
// src/services/turn-files/git-changeset.ts
|
|
39296
39320
|
var import_child_process29 = require("child_process");
|
|
39297
|
-
var
|
|
39298
|
-
var
|
|
39321
|
+
var fs76 = __toESM(require("fs/promises"));
|
|
39322
|
+
var import_fs10 = require("fs");
|
|
39299
39323
|
var path86 = __toESM(require("path"));
|
|
39300
39324
|
|
|
39301
39325
|
// src/services/turn-files/review-ignore.ts
|
|
39302
39326
|
var import_ignore2 = __toESM(require("ignore"));
|
|
39303
|
-
var
|
|
39327
|
+
var fs75 = __toESM(require("fs"));
|
|
39304
39328
|
var path85 = __toESM(require("path"));
|
|
39305
39329
|
var CURATED_REVIEW_IGNORE = [
|
|
39306
39330
|
// Google Cloud SDK (the incident) — installs a huge python tree.
|
|
@@ -39345,7 +39369,7 @@ var CURATED_REVIEW_IGNORE = [
|
|
|
39345
39369
|
function makeReviewIgnore(repoRoot) {
|
|
39346
39370
|
const ig = (0, import_ignore2.default)().add(CURATED_REVIEW_IGNORE);
|
|
39347
39371
|
try {
|
|
39348
|
-
const custom =
|
|
39372
|
+
const custom = fs75.readFileSync(path85.join(repoRoot, ".codeam", "reviewignore"), "utf8");
|
|
39349
39373
|
ig.add(custom);
|
|
39350
39374
|
} catch {
|
|
39351
39375
|
}
|
|
@@ -39428,7 +39452,7 @@ function readUntrackedLineCount(absPath) {
|
|
|
39428
39452
|
}
|
|
39429
39453
|
async function defaultReadUntrackedLineCount(absPath) {
|
|
39430
39454
|
try {
|
|
39431
|
-
const content = await
|
|
39455
|
+
const content = await fs76.readFile(absPath, "utf8");
|
|
39432
39456
|
let count = 0;
|
|
39433
39457
|
let pos = -1;
|
|
39434
39458
|
while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
|
|
@@ -39489,12 +39513,12 @@ function runGit3(cwd, args2) {
|
|
|
39489
39513
|
return _runGitImpl2.run(cwd, args2);
|
|
39490
39514
|
}
|
|
39491
39515
|
function defaultRunGit(cwd, args2) {
|
|
39492
|
-
return new Promise((
|
|
39516
|
+
return new Promise((resolve13) => {
|
|
39493
39517
|
let proc;
|
|
39494
39518
|
try {
|
|
39495
39519
|
proc = (0, import_child_process29.spawn)("git", args2, { cwd, env: process.env });
|
|
39496
39520
|
} catch {
|
|
39497
|
-
|
|
39521
|
+
resolve13(null);
|
|
39498
39522
|
return;
|
|
39499
39523
|
}
|
|
39500
39524
|
let stdout = "";
|
|
@@ -39505,22 +39529,22 @@ function defaultRunGit(cwd, args2) {
|
|
|
39505
39529
|
proc.stderr?.on("data", (c2) => {
|
|
39506
39530
|
stderr += c2.toString();
|
|
39507
39531
|
});
|
|
39508
|
-
proc.on("error", () =>
|
|
39532
|
+
proc.on("error", () => resolve13(null));
|
|
39509
39533
|
proc.on("close", (code) => {
|
|
39510
39534
|
if (code === 0) {
|
|
39511
|
-
|
|
39535
|
+
resolve13(stdout);
|
|
39512
39536
|
} else {
|
|
39513
39537
|
log.trace(
|
|
39514
39538
|
"turnFiles",
|
|
39515
39539
|
`git ${args2.join(" ")} exited ${code} stderr=${stderr.slice(0, 200)}`
|
|
39516
39540
|
);
|
|
39517
|
-
|
|
39541
|
+
resolve13(null);
|
|
39518
39542
|
}
|
|
39519
39543
|
});
|
|
39520
39544
|
});
|
|
39521
39545
|
}
|
|
39522
39546
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
39523
|
-
const
|
|
39547
|
+
const fs100 = await import("fs/promises");
|
|
39524
39548
|
const out2 = [];
|
|
39525
39549
|
await walk2(workingDir, 0);
|
|
39526
39550
|
return out2;
|
|
@@ -39528,7 +39552,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
39528
39552
|
if (depth2 > maxDepth) return;
|
|
39529
39553
|
let entries2 = [];
|
|
39530
39554
|
try {
|
|
39531
|
-
const dirents = await
|
|
39555
|
+
const dirents = await fs100.readdir(dir, { withFileTypes: true });
|
|
39532
39556
|
entries2 = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
39533
39557
|
} catch {
|
|
39534
39558
|
return;
|
|
@@ -39554,7 +39578,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
39554
39578
|
}
|
|
39555
39579
|
function isReviewablePath(absPath) {
|
|
39556
39580
|
try {
|
|
39557
|
-
const st3 = (0,
|
|
39581
|
+
const st3 = (0, import_fs10.lstatSync)(absPath);
|
|
39558
39582
|
return st3.isFile() || st3.isSymbolicLink();
|
|
39559
39583
|
} catch {
|
|
39560
39584
|
return true;
|
|
@@ -39562,7 +39586,7 @@ function isReviewablePath(absPath) {
|
|
|
39562
39586
|
}
|
|
39563
39587
|
|
|
39564
39588
|
// src/services/turn-files/files-outbox.ts
|
|
39565
|
-
var
|
|
39589
|
+
var fs77 = __toESM(require("fs/promises"));
|
|
39566
39590
|
var path87 = __toESM(require("path"));
|
|
39567
39591
|
var import_os14 = require("os");
|
|
39568
39592
|
var HOME_OUTBOX_DIR = ".codeam/outbox";
|
|
@@ -39604,8 +39628,8 @@ var FilesOutbox = class {
|
|
|
39604
39628
|
/** Persist the entry to disk and trigger a flush. Returns once the
|
|
39605
39629
|
* line is durable on disk (not once the POST succeeds). */
|
|
39606
39630
|
async enqueue(entry) {
|
|
39607
|
-
await
|
|
39608
|
-
await
|
|
39631
|
+
await fs77.mkdir(path87.dirname(this.filePath), { recursive: true });
|
|
39632
|
+
await fs77.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
|
|
39609
39633
|
this.backoffIndex = 0;
|
|
39610
39634
|
if (this.autoSchedule) this.scheduleFlush(0);
|
|
39611
39635
|
}
|
|
@@ -39696,7 +39720,7 @@ var FilesOutbox = class {
|
|
|
39696
39720
|
async readAll() {
|
|
39697
39721
|
let raw = "";
|
|
39698
39722
|
try {
|
|
39699
|
-
raw = await
|
|
39723
|
+
raw = await fs77.readFile(this.filePath, "utf8");
|
|
39700
39724
|
} catch {
|
|
39701
39725
|
return [];
|
|
39702
39726
|
}
|
|
@@ -39720,12 +39744,12 @@ var FilesOutbox = class {
|
|
|
39720
39744
|
async rewrite(entries2) {
|
|
39721
39745
|
const tmpPath = `${this.filePath}.${process.pid}.tmp`;
|
|
39722
39746
|
if (entries2.length === 0) {
|
|
39723
|
-
await
|
|
39747
|
+
await fs77.unlink(this.filePath).catch(() => void 0);
|
|
39724
39748
|
return;
|
|
39725
39749
|
}
|
|
39726
39750
|
const payload = entries2.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
39727
|
-
await
|
|
39728
|
-
await
|
|
39751
|
+
await fs77.writeFile(tmpPath, payload, "utf8");
|
|
39752
|
+
await fs77.rename(tmpPath, this.filePath);
|
|
39729
39753
|
}
|
|
39730
39754
|
};
|
|
39731
39755
|
function applyJitter(ms) {
|
|
@@ -39931,25 +39955,25 @@ function baselineKey(entry) {
|
|
|
39931
39955
|
|
|
39932
39956
|
// src/agents/acp/withTimeout.ts
|
|
39933
39957
|
function withTimeout(p2, ms) {
|
|
39934
|
-
return new Promise((
|
|
39958
|
+
return new Promise((resolve13) => {
|
|
39935
39959
|
let settled = false;
|
|
39936
39960
|
const timer = setTimeout(() => {
|
|
39937
39961
|
if (settled) return;
|
|
39938
39962
|
settled = true;
|
|
39939
|
-
|
|
39963
|
+
resolve13(void 0);
|
|
39940
39964
|
}, ms);
|
|
39941
39965
|
p2.then(
|
|
39942
39966
|
(v) => {
|
|
39943
39967
|
if (settled) return;
|
|
39944
39968
|
settled = true;
|
|
39945
39969
|
clearTimeout(timer);
|
|
39946
|
-
|
|
39970
|
+
resolve13(v);
|
|
39947
39971
|
},
|
|
39948
39972
|
() => {
|
|
39949
39973
|
if (settled) return;
|
|
39950
39974
|
settled = true;
|
|
39951
39975
|
clearTimeout(timer);
|
|
39952
|
-
|
|
39976
|
+
resolve13(void 0);
|
|
39953
39977
|
}
|
|
39954
39978
|
);
|
|
39955
39979
|
});
|
|
@@ -40073,7 +40097,7 @@ async function readActiveConversationMarker(cwd, homeDir2) {
|
|
|
40073
40097
|
}
|
|
40074
40098
|
|
|
40075
40099
|
// src/services/turn-marker.ts
|
|
40076
|
-
var
|
|
40100
|
+
var fs79 = __toESM(require("fs"));
|
|
40077
40101
|
var os57 = __toESM(require("os"));
|
|
40078
40102
|
var path89 = __toESM(require("path"));
|
|
40079
40103
|
var depth = 0;
|
|
@@ -40086,14 +40110,14 @@ function turnMarkerPath(pid = process.pid, home = codeamHome()) {
|
|
|
40086
40110
|
function mark() {
|
|
40087
40111
|
try {
|
|
40088
40112
|
const file = turnMarkerPath();
|
|
40089
|
-
|
|
40090
|
-
|
|
40113
|
+
fs79.mkdirSync(path89.dirname(file), { recursive: true });
|
|
40114
|
+
fs79.writeFileSync(file, String(Date.now()));
|
|
40091
40115
|
} catch {
|
|
40092
40116
|
}
|
|
40093
40117
|
}
|
|
40094
40118
|
function clear() {
|
|
40095
40119
|
try {
|
|
40096
|
-
|
|
40120
|
+
fs79.rmSync(turnMarkerPath(), { force: true });
|
|
40097
40121
|
} catch {
|
|
40098
40122
|
}
|
|
40099
40123
|
}
|
|
@@ -40108,7 +40132,7 @@ async function withTurnMarker(fn) {
|
|
|
40108
40132
|
function isProcessMidTurn(pid, home) {
|
|
40109
40133
|
if (!pid) return false;
|
|
40110
40134
|
try {
|
|
40111
|
-
return
|
|
40135
|
+
return fs79.existsSync(turnMarkerPath(pid, home));
|
|
40112
40136
|
} catch {
|
|
40113
40137
|
return false;
|
|
40114
40138
|
}
|
|
@@ -40116,9 +40140,9 @@ function isProcessMidTurn(pid, home) {
|
|
|
40116
40140
|
|
|
40117
40141
|
// src/packs/gates.ts
|
|
40118
40142
|
var import_node_child_process28 = require("child_process");
|
|
40119
|
-
var
|
|
40143
|
+
var fs80 = __toESM(require("fs"));
|
|
40120
40144
|
var path90 = __toESM(require("path"));
|
|
40121
|
-
var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((
|
|
40145
|
+
var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((resolve13) => {
|
|
40122
40146
|
(0, import_node_child_process28.execFile)(
|
|
40123
40147
|
file,
|
|
40124
40148
|
args2,
|
|
@@ -40134,7 +40158,7 @@ var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((re
|
|
|
40134
40158
|
const rawCode = err.code;
|
|
40135
40159
|
code = typeof rawCode === "number" ? rawCode : 1;
|
|
40136
40160
|
}
|
|
40137
|
-
|
|
40161
|
+
resolve13({ code, stdout: stdout ?? "", stderr: stderr ?? "" });
|
|
40138
40162
|
}
|
|
40139
40163
|
);
|
|
40140
40164
|
});
|
|
@@ -40167,7 +40191,7 @@ async function changedFiles(run3, cwd, from, to) {
|
|
|
40167
40191
|
}
|
|
40168
40192
|
function readWorkspaceFile(cwd, relPath) {
|
|
40169
40193
|
try {
|
|
40170
|
-
return
|
|
40194
|
+
return fs80.readFileSync(path90.join(cwd, relPath), "utf8");
|
|
40171
40195
|
} catch {
|
|
40172
40196
|
return null;
|
|
40173
40197
|
}
|
|
@@ -40176,14 +40200,14 @@ var NO_TEST_PLACEHOLDER = 'echo "Error: no test specified"';
|
|
|
40176
40200
|
var CHECKS_TIMEOUT_MS = 5 * 6e4;
|
|
40177
40201
|
function detectChecksCommand(cwd) {
|
|
40178
40202
|
try {
|
|
40179
|
-
const cfg = JSON.parse(
|
|
40203
|
+
const cfg = JSON.parse(fs80.readFileSync(path90.join(cwd, ".codeam", "pack.json"), "utf8"));
|
|
40180
40204
|
if (typeof cfg.checksCommand === "string" && cfg.checksCommand.trim().length > 0) {
|
|
40181
40205
|
return cfg.checksCommand.trim();
|
|
40182
40206
|
}
|
|
40183
40207
|
} catch {
|
|
40184
40208
|
}
|
|
40185
40209
|
try {
|
|
40186
|
-
const pkg = JSON.parse(
|
|
40210
|
+
const pkg = JSON.parse(fs80.readFileSync(path90.join(cwd, "package.json"), "utf8"));
|
|
40187
40211
|
const test = pkg.scripts?.test;
|
|
40188
40212
|
if (typeof test === "string" && test.trim().length > 0 && !test.includes(NO_TEST_PLACEHOLDER)) {
|
|
40189
40213
|
return "npm test";
|
|
@@ -40201,7 +40225,7 @@ ${res.stderr}`.trim();
|
|
|
40201
40225
|
}
|
|
40202
40226
|
|
|
40203
40227
|
// src/packs/run-store.ts
|
|
40204
|
-
var
|
|
40228
|
+
var fs81 = __toESM(require("fs"));
|
|
40205
40229
|
var path91 = __toESM(require("path"));
|
|
40206
40230
|
var crypto5 = __toESM(require("crypto"));
|
|
40207
40231
|
function packsDir(cwd) {
|
|
@@ -40214,10 +40238,10 @@ function newRunId() {
|
|
|
40214
40238
|
return `pk_${Date.now().toString(36)}_${crypto5.randomBytes(4).toString("hex")}`;
|
|
40215
40239
|
}
|
|
40216
40240
|
function writeJsonAtomic(file, value) {
|
|
40217
|
-
|
|
40241
|
+
fs81.mkdirSync(path91.dirname(file), { recursive: true });
|
|
40218
40242
|
const tmp = `${file}.tmp`;
|
|
40219
|
-
|
|
40220
|
-
|
|
40243
|
+
fs81.writeFileSync(tmp, JSON.stringify(value, null, 2));
|
|
40244
|
+
fs81.renameSync(tmp, file);
|
|
40221
40245
|
}
|
|
40222
40246
|
function saveRun(cwd, state) {
|
|
40223
40247
|
writeJsonAtomic(path91.join(runDir(cwd, state.runId), "run.json"), state);
|
|
@@ -40229,11 +40253,11 @@ function saveStageHandoff(cwd, runId, stageIndex, role, handoff) {
|
|
|
40229
40253
|
function loadLatestRun(cwd) {
|
|
40230
40254
|
try {
|
|
40231
40255
|
const dir = packsDir(cwd);
|
|
40232
|
-
const entries2 =
|
|
40256
|
+
const entries2 = fs81.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
40233
40257
|
for (let i = entries2.length - 1; i >= 0; i--) {
|
|
40234
40258
|
const file = path91.join(dir, entries2[i], "run.json");
|
|
40235
40259
|
try {
|
|
40236
|
-
const parsed = JSON.parse(
|
|
40260
|
+
const parsed = JSON.parse(fs81.readFileSync(file, "utf8"));
|
|
40237
40261
|
if (parsed && typeof parsed.runId === "string") return parsed;
|
|
40238
40262
|
} catch {
|
|
40239
40263
|
}
|
|
@@ -40245,16 +40269,16 @@ function loadLatestRun(cwd) {
|
|
|
40245
40269
|
function ensureLedgerIgnored(cwd) {
|
|
40246
40270
|
try {
|
|
40247
40271
|
const gitDir = path91.join(cwd, ".git");
|
|
40248
|
-
if (!
|
|
40272
|
+
if (!fs81.existsSync(gitDir)) return;
|
|
40249
40273
|
const exclude = path91.join(gitDir, "info", "exclude");
|
|
40250
40274
|
let existing = "";
|
|
40251
40275
|
try {
|
|
40252
|
-
existing =
|
|
40276
|
+
existing = fs81.readFileSync(exclude, "utf8");
|
|
40253
40277
|
} catch {
|
|
40254
40278
|
}
|
|
40255
40279
|
if (existing.includes(".codeam/packs/")) return;
|
|
40256
|
-
|
|
40257
|
-
|
|
40280
|
+
fs81.mkdirSync(path91.dirname(exclude), { recursive: true });
|
|
40281
|
+
fs81.writeFileSync(exclude, `${existing.trimEnd()}
|
|
40258
40282
|
.codeam/packs/
|
|
40259
40283
|
`.trimStart());
|
|
40260
40284
|
} catch {
|
|
@@ -41235,7 +41259,7 @@ async function mcpRouter() {
|
|
|
41235
41259
|
}
|
|
41236
41260
|
|
|
41237
41261
|
// src/integrations/mcp-secrets.ts
|
|
41238
|
-
var
|
|
41262
|
+
var fs83 = __toESM(require("fs"));
|
|
41239
41263
|
var os59 = __toESM(require("os"));
|
|
41240
41264
|
var path93 = __toESM(require("path"));
|
|
41241
41265
|
var MCP_SECRETS_FILE_ENV = "CODEAM_MCP_SECRETS_FILE";
|
|
@@ -41248,7 +41272,7 @@ function mcpSecretsPath(scope, pid = process.pid) {
|
|
|
41248
41272
|
var registeredForCleanup = /* @__PURE__ */ new Set();
|
|
41249
41273
|
function readFileVars(file) {
|
|
41250
41274
|
try {
|
|
41251
|
-
const parsed = JSON.parse(
|
|
41275
|
+
const parsed = JSON.parse(fs83.readFileSync(file, "utf8"));
|
|
41252
41276
|
if (!parsed || typeof parsed !== "object") return {};
|
|
41253
41277
|
const out2 = {};
|
|
41254
41278
|
for (const [k2, v] of Object.entries(parsed)) {
|
|
@@ -41270,7 +41294,7 @@ function pidAlive2(pid) {
|
|
|
41270
41294
|
function pruneStale(dir) {
|
|
41271
41295
|
let names = [];
|
|
41272
41296
|
try {
|
|
41273
|
-
names =
|
|
41297
|
+
names = fs83.readdirSync(dir);
|
|
41274
41298
|
} catch {
|
|
41275
41299
|
return;
|
|
41276
41300
|
}
|
|
@@ -41280,7 +41304,7 @@ function pruneStale(dir) {
|
|
|
41280
41304
|
const pid = Number(m[1]);
|
|
41281
41305
|
if (pid === process.pid || pidAlive2(pid)) continue;
|
|
41282
41306
|
try {
|
|
41283
|
-
|
|
41307
|
+
fs83.unlinkSync(path93.join(dir, name));
|
|
41284
41308
|
} catch {
|
|
41285
41309
|
}
|
|
41286
41310
|
}
|
|
@@ -41288,17 +41312,17 @@ function pruneStale(dir) {
|
|
|
41288
41312
|
function writeMcpSecrets(vars, file) {
|
|
41289
41313
|
try {
|
|
41290
41314
|
const dir = path93.dirname(file);
|
|
41291
|
-
|
|
41315
|
+
fs83.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
41292
41316
|
pruneStale(dir);
|
|
41293
41317
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
41294
|
-
|
|
41295
|
-
|
|
41296
|
-
|
|
41318
|
+
fs83.writeFileSync(tmp, JSON.stringify(vars), { mode: 384 });
|
|
41319
|
+
fs83.renameSync(tmp, file);
|
|
41320
|
+
fs83.chmodSync(file, 384);
|
|
41297
41321
|
if (!registeredForCleanup.has(file)) {
|
|
41298
41322
|
registeredForCleanup.add(file);
|
|
41299
41323
|
process.once("exit", () => {
|
|
41300
41324
|
try {
|
|
41301
|
-
|
|
41325
|
+
fs83.unlinkSync(file);
|
|
41302
41326
|
} catch {
|
|
41303
41327
|
}
|
|
41304
41328
|
});
|
|
@@ -41776,24 +41800,24 @@ var AgentPreviewBridge = class {
|
|
|
41776
41800
|
* preview tools are then simply absent, never a failed session. */
|
|
41777
41801
|
listen() {
|
|
41778
41802
|
if (this.listening) return this.listening;
|
|
41779
|
-
this.listening = new Promise((
|
|
41803
|
+
this.listening = new Promise((resolve13) => {
|
|
41780
41804
|
const server = http12.createServer((req, res) => {
|
|
41781
41805
|
void this.handle(req, res);
|
|
41782
41806
|
});
|
|
41783
41807
|
server.on("error", (err) => {
|
|
41784
41808
|
log.warn("agent-preview", `bridge failed to listen: ${String(err)}`);
|
|
41785
|
-
|
|
41809
|
+
resolve13(null);
|
|
41786
41810
|
});
|
|
41787
41811
|
server.listen(0, "127.0.0.1", () => {
|
|
41788
41812
|
const addr = server.address();
|
|
41789
41813
|
if (!addr || typeof addr === "string") {
|
|
41790
|
-
|
|
41814
|
+
resolve13(null);
|
|
41791
41815
|
return;
|
|
41792
41816
|
}
|
|
41793
41817
|
server.unref();
|
|
41794
41818
|
this.server = server;
|
|
41795
41819
|
this.bound = { url: `http://127.0.0.1:${addr.port}`, token: this.token };
|
|
41796
|
-
|
|
41820
|
+
resolve13(this.bound);
|
|
41797
41821
|
});
|
|
41798
41822
|
});
|
|
41799
41823
|
return this.listening;
|
|
@@ -41830,9 +41854,9 @@ var AgentPreviewBridge = class {
|
|
|
41830
41854
|
}
|
|
41831
41855
|
const inflight = this.inflight;
|
|
41832
41856
|
let timer;
|
|
41833
|
-
const pending2 = new Promise((
|
|
41857
|
+
const pending2 = new Promise((resolve13) => {
|
|
41834
41858
|
timer = setTimeout(
|
|
41835
|
-
() =>
|
|
41859
|
+
() => resolve13({
|
|
41836
41860
|
status: "starting",
|
|
41837
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."
|
|
41838
41862
|
}),
|
|
@@ -42035,7 +42059,7 @@ function authorized(header, token) {
|
|
|
42035
42059
|
return presented.length === expected.length && (0, import_node_crypto14.timingSafeEqual)(presented, expected);
|
|
42036
42060
|
}
|
|
42037
42061
|
function readJson(req) {
|
|
42038
|
-
return new Promise((
|
|
42062
|
+
return new Promise((resolve13, reject) => {
|
|
42039
42063
|
let raw = "";
|
|
42040
42064
|
req.setEncoding("utf8");
|
|
42041
42065
|
req.on("data", (chunk) => {
|
|
@@ -42046,10 +42070,10 @@ function readJson(req) {
|
|
|
42046
42070
|
}
|
|
42047
42071
|
});
|
|
42048
42072
|
req.on("end", () => {
|
|
42049
|
-
if (!raw) return
|
|
42073
|
+
if (!raw) return resolve13({});
|
|
42050
42074
|
try {
|
|
42051
42075
|
const parsed = JSON.parse(raw);
|
|
42052
|
-
|
|
42076
|
+
resolve13(parsed && typeof parsed === "object" ? parsed : {});
|
|
42053
42077
|
} catch {
|
|
42054
42078
|
reject(new Error("invalid JSON"));
|
|
42055
42079
|
}
|
|
@@ -43176,15 +43200,15 @@ async function prewarmNewMcpEntries(manifest, previousIds) {
|
|
|
43176
43200
|
);
|
|
43177
43201
|
await Promise.all(
|
|
43178
43202
|
fresh.map(
|
|
43179
|
-
(e) => new Promise((
|
|
43203
|
+
(e) => new Promise((resolve13) => {
|
|
43180
43204
|
const mcp = e.delivery.mcp;
|
|
43181
43205
|
const child = (0, import_node_child_process29.execFile)(
|
|
43182
43206
|
mcp.command,
|
|
43183
43207
|
[...mcp.args, "--help"],
|
|
43184
43208
|
{ timeout: 9e4 },
|
|
43185
|
-
() =>
|
|
43209
|
+
() => resolve13()
|
|
43186
43210
|
);
|
|
43187
|
-
child.on("error", () =>
|
|
43211
|
+
child.on("error", () => resolve13());
|
|
43188
43212
|
})
|
|
43189
43213
|
)
|
|
43190
43214
|
);
|
|
@@ -43451,7 +43475,7 @@ var StreamingState = class {
|
|
|
43451
43475
|
* protested "J'ai rien refusé". The line is the user's evidence.
|
|
43452
43476
|
*/
|
|
43453
43477
|
registerPermission(args2) {
|
|
43454
|
-
return new Promise((
|
|
43478
|
+
return new Promise((resolve13) => {
|
|
43455
43479
|
const timeoutTimer = setTimeout(() => {
|
|
43456
43480
|
if (this.pending?.kind === "permission" && this.pending.questionId === args2.questionId) {
|
|
43457
43481
|
log.warn(
|
|
@@ -43464,14 +43488,14 @@ var StreamingState = class {
|
|
|
43464
43488
|
content: permissionExpiredNotice(),
|
|
43465
43489
|
done: true
|
|
43466
43490
|
});
|
|
43467
|
-
|
|
43491
|
+
resolve13({ outcome: { outcome: "cancelled" } });
|
|
43468
43492
|
}
|
|
43469
43493
|
}, PERMISSION_TIMEOUT_MS);
|
|
43470
43494
|
this.setPending({
|
|
43471
43495
|
kind: "permission",
|
|
43472
43496
|
questionId: args2.questionId,
|
|
43473
43497
|
options: args2.options,
|
|
43474
|
-
resolve:
|
|
43498
|
+
resolve: resolve13,
|
|
43475
43499
|
timeoutTimer
|
|
43476
43500
|
});
|
|
43477
43501
|
});
|
|
@@ -43508,14 +43532,14 @@ var StreamingState = class {
|
|
|
43508
43532
|
const byId = optionId ? this.pending.options.find((o) => o.optionId === optionId) : void 0;
|
|
43509
43533
|
const picked = byId ?? this.pending.options[index];
|
|
43510
43534
|
clearTimeout(this.pending.timeoutTimer);
|
|
43511
|
-
const
|
|
43535
|
+
const resolve13 = this.pending.resolve;
|
|
43512
43536
|
this.setPending(null);
|
|
43513
43537
|
if (!picked) {
|
|
43514
43538
|
log.warn("acpRunner", `select_option index=${index} out of bounds \u2014 cancel`);
|
|
43515
|
-
|
|
43539
|
+
resolve13({ outcome: { outcome: "cancelled" } });
|
|
43516
43540
|
return { kind: "resolved", optionId: null };
|
|
43517
43541
|
}
|
|
43518
|
-
|
|
43542
|
+
resolve13({ outcome: { outcome: "selected", optionId: picked.optionId } });
|
|
43519
43543
|
return { kind: "resolved", optionId: picked.optionId };
|
|
43520
43544
|
}
|
|
43521
43545
|
const text = this.pending.options[index];
|
|
@@ -44432,7 +44456,7 @@ async function runAcpSession(opts) {
|
|
|
44432
44456
|
`switch-${opts.pluginId}`
|
|
44433
44457
|
);
|
|
44434
44458
|
try {
|
|
44435
|
-
|
|
44459
|
+
fs86.mkdirSync(claudeConfigDir2, { recursive: true, mode: 448 });
|
|
44436
44460
|
} catch {
|
|
44437
44461
|
}
|
|
44438
44462
|
const memoryFile = path96.join(claudeConfigDir2, "CLAUDE.md");
|
|
@@ -45666,7 +45690,7 @@ function pickPinnedSession(pinnedId, listSessions2) {
|
|
|
45666
45690
|
}
|
|
45667
45691
|
|
|
45668
45692
|
// src/agents/retired-proxy-cleanup.ts
|
|
45669
|
-
var
|
|
45693
|
+
var fs87 = __toESM(require("fs"));
|
|
45670
45694
|
var path97 = __toESM(require("path"));
|
|
45671
45695
|
var os62 = __toESM(require("os"));
|
|
45672
45696
|
var RETIRED_PROXY_RE = /^https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):8787(?:[/?#]|$)/i;
|
|
@@ -45682,7 +45706,7 @@ function sanitizeRetiredProxyConfig(homeDir2 = os62.homedir()) {
|
|
|
45682
45706
|
const file = path97.join(homeDir2, ".claude", "settings.json");
|
|
45683
45707
|
let parsed;
|
|
45684
45708
|
try {
|
|
45685
|
-
parsed = JSON.parse(
|
|
45709
|
+
parsed = JSON.parse(fs87.readFileSync(file, "utf8"));
|
|
45686
45710
|
} catch {
|
|
45687
45711
|
return out2;
|
|
45688
45712
|
}
|
|
@@ -45724,9 +45748,9 @@ function sanitizeRetiredProxyConfig(homeDir2 = os62.homedir()) {
|
|
|
45724
45748
|
if (!out2.changed) return out2;
|
|
45725
45749
|
try {
|
|
45726
45750
|
const tmp = `${file}.codeam.tmp`;
|
|
45727
|
-
|
|
45751
|
+
fs87.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
|
|
45728
45752
|
`, { mode: 384 });
|
|
45729
|
-
|
|
45753
|
+
fs87.renameSync(tmp, file);
|
|
45730
45754
|
} catch {
|
|
45731
45755
|
out2.changed = false;
|
|
45732
45756
|
}
|
|
@@ -46116,10 +46140,10 @@ var NativeTuiDriver = class _NativeTuiDriver {
|
|
|
46116
46140
|
this.lastOutput = this.now();
|
|
46117
46141
|
}
|
|
46118
46142
|
whenSafeToYield() {
|
|
46119
|
-
return new Promise((
|
|
46143
|
+
return new Promise((resolve13) => {
|
|
46120
46144
|
const tick = () => {
|
|
46121
46145
|
const quietFor = this.now() - this.lastOutput;
|
|
46122
|
-
if (quietFor >= this.idleMs)
|
|
46146
|
+
if (quietFor >= this.idleMs) resolve13();
|
|
46123
46147
|
else setTimeout(tick, this.idleMs - quietFor);
|
|
46124
46148
|
};
|
|
46125
46149
|
tick();
|
|
@@ -46182,10 +46206,10 @@ var AcpDriver = class {
|
|
|
46182
46206
|
* one ever is, assume resumable so behaviour is unchanged.
|
|
46183
46207
|
*/
|
|
46184
46208
|
hasTranscript(conversationId) {
|
|
46185
|
-
const
|
|
46186
|
-
if (typeof
|
|
46209
|
+
const resolve13 = this.deps.runtime.resolveHistoryFile;
|
|
46210
|
+
if (typeof resolve13 !== "function") return true;
|
|
46187
46211
|
try {
|
|
46188
|
-
return
|
|
46212
|
+
return resolve13.call(this.deps.runtime, this.deps.opts.cwd, conversationId) !== null;
|
|
46189
46213
|
} catch {
|
|
46190
46214
|
return true;
|
|
46191
46215
|
}
|
|
@@ -46249,16 +46273,16 @@ var AcpDriver = class {
|
|
|
46249
46273
|
this.turnActive = false;
|
|
46250
46274
|
const waiters = this.waiters;
|
|
46251
46275
|
this.waiters = [];
|
|
46252
|
-
waiters.forEach((
|
|
46276
|
+
waiters.forEach((resolve13) => resolve13());
|
|
46253
46277
|
}
|
|
46254
46278
|
whenSafeToYield() {
|
|
46255
46279
|
if (!this.turnActive) return Promise.resolve();
|
|
46256
|
-
return new Promise((
|
|
46280
|
+
return new Promise((resolve13) => this.waiters.push(resolve13));
|
|
46257
46281
|
}
|
|
46258
46282
|
};
|
|
46259
46283
|
|
|
46260
46284
|
// src/baton/transcript-mirror.ts
|
|
46261
|
-
var
|
|
46285
|
+
var fs88 = __toESM(require("fs"));
|
|
46262
46286
|
var TranscriptMirror = class {
|
|
46263
46287
|
constructor(deps) {
|
|
46264
46288
|
this.deps = deps;
|
|
@@ -46352,7 +46376,7 @@ var TranscriptMirror = class {
|
|
|
46352
46376
|
}
|
|
46353
46377
|
};
|
|
46354
46378
|
function defaultWatch(file, onChange) {
|
|
46355
|
-
const w3 =
|
|
46379
|
+
const w3 = fs88.watch(file, { persistent: false }, () => onChange());
|
|
46356
46380
|
return () => w3.close();
|
|
46357
46381
|
}
|
|
46358
46382
|
|
|
@@ -46698,7 +46722,7 @@ function keepDeviceAwake(deps = {}) {
|
|
|
46698
46722
|
}
|
|
46699
46723
|
|
|
46700
46724
|
// src/agents/claude/onboarding.ts
|
|
46701
|
-
var
|
|
46725
|
+
var fs89 = __toESM(require("fs"));
|
|
46702
46726
|
var os64 = __toESM(require("os"));
|
|
46703
46727
|
var path98 = __toESM(require("path"));
|
|
46704
46728
|
var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
|
|
@@ -46707,7 +46731,7 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
46707
46731
|
const file = path98.join(os64.homedir(), ".claude.json");
|
|
46708
46732
|
let config = {};
|
|
46709
46733
|
try {
|
|
46710
|
-
config = JSON.parse(
|
|
46734
|
+
config = JSON.parse(fs89.readFileSync(file, "utf8"));
|
|
46711
46735
|
} catch {
|
|
46712
46736
|
}
|
|
46713
46737
|
let changed = false;
|
|
@@ -46732,8 +46756,8 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
46732
46756
|
}
|
|
46733
46757
|
}
|
|
46734
46758
|
if (!changed) return;
|
|
46735
|
-
|
|
46736
|
-
|
|
46759
|
+
fs89.mkdirSync(path98.dirname(file), { recursive: true });
|
|
46760
|
+
fs89.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
46737
46761
|
log.info(
|
|
46738
46762
|
"claude",
|
|
46739
46763
|
`pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
|
|
@@ -46846,8 +46870,8 @@ async function start(requestedAgent, presetSession) {
|
|
|
46846
46870
|
const releaseStartupMark = markAgentStarting();
|
|
46847
46871
|
process.once("exit", releaseStartupMark);
|
|
46848
46872
|
let settleOwnHandshake = () => void 0;
|
|
46849
|
-
const ownHandshakeSettled = new Promise((
|
|
46850
|
-
settleOwnHandshake =
|
|
46873
|
+
const ownHandshakeSettled = new Promise((resolve13) => {
|
|
46874
|
+
settleOwnHandshake = resolve13;
|
|
46851
46875
|
});
|
|
46852
46876
|
const releaseBeads = () => {
|
|
46853
46877
|
releaseStartupMark();
|
|
@@ -46857,7 +46881,7 @@ async function start(requestedAgent, presetSession) {
|
|
|
46857
46881
|
ownHandshakeSettled.then(
|
|
46858
46882
|
() => waitForNoAgentStarting({ timeoutMs: BEADS_AFTER_HANDSHAKE_CAP_MS })
|
|
46859
46883
|
),
|
|
46860
|
-
new Promise((
|
|
46884
|
+
new Promise((resolve13) => setTimeout(resolve13, BEADS_AFTER_HANDSHAKE_CAP_MS).unref())
|
|
46861
46885
|
]);
|
|
46862
46886
|
const beadsReady = provisionBeadsForStart({
|
|
46863
46887
|
sessionId: session.id,
|
|
@@ -46929,8 +46953,8 @@ async function start(requestedAgent, presetSession) {
|
|
|
46929
46953
|
let gateTimer;
|
|
46930
46954
|
await Promise.race([
|
|
46931
46955
|
Promise.all([depsReady, agentBinaryReady]),
|
|
46932
|
-
new Promise((
|
|
46933
|
-
gateTimer = setTimeout(
|
|
46956
|
+
new Promise((resolve13) => {
|
|
46957
|
+
gateTimer = setTimeout(resolve13, GATE_TIMEOUT_MS);
|
|
46934
46958
|
})
|
|
46935
46959
|
]);
|
|
46936
46960
|
if (gateTimer) clearTimeout(gateTimer);
|
|
@@ -47314,7 +47338,7 @@ async function pair(args2 = []) {
|
|
|
47314
47338
|
waitSpin.message(waitMessage());
|
|
47315
47339
|
}, 1e3);
|
|
47316
47340
|
countdownInterval.unref?.();
|
|
47317
|
-
await new Promise((
|
|
47341
|
+
await new Promise((resolve13) => {
|
|
47318
47342
|
let stopPolling = null;
|
|
47319
47343
|
function sigintHandler() {
|
|
47320
47344
|
clearInterval(countdownInterval);
|
|
@@ -47365,7 +47389,7 @@ async function pair(args2 = []) {
|
|
|
47365
47389
|
pluginAuthToken: info.pluginAuthToken
|
|
47366
47390
|
});
|
|
47367
47391
|
}
|
|
47368
|
-
|
|
47392
|
+
resolve13();
|
|
47369
47393
|
},
|
|
47370
47394
|
() => {
|
|
47371
47395
|
clearInterval(countdownInterval);
|
|
@@ -47594,12 +47618,12 @@ var GitHubCodespacesProvider = class {
|
|
|
47594
47618
|
}
|
|
47595
47619
|
if (!isAuthed) {
|
|
47596
47620
|
resetStdinForChild();
|
|
47597
|
-
await new Promise((
|
|
47621
|
+
await new Promise((resolve13, reject) => {
|
|
47598
47622
|
const proc = (0, import_child_process30.spawn)("gh", ["auth", "login", "-s", "codespace,repo,read:user"], {
|
|
47599
47623
|
stdio: "inherit"
|
|
47600
47624
|
});
|
|
47601
47625
|
proc.on("exit", (code) => {
|
|
47602
|
-
if (code === 0)
|
|
47626
|
+
if (code === 0) resolve13();
|
|
47603
47627
|
else reject(new Error("gh auth login failed."));
|
|
47604
47628
|
});
|
|
47605
47629
|
proc.on("error", reject);
|
|
@@ -47628,13 +47652,13 @@ var GitHubCodespacesProvider = class {
|
|
|
47628
47652
|
}
|
|
47629
47653
|
wt(noteLines.join("\n"), "One more permission needed");
|
|
47630
47654
|
resetStdinForChild();
|
|
47631
|
-
const refreshCode = await new Promise((
|
|
47655
|
+
const refreshCode = await new Promise((resolve13, reject) => {
|
|
47632
47656
|
const proc = (0, import_child_process30.spawn)(
|
|
47633
47657
|
"gh",
|
|
47634
47658
|
["auth", "refresh", "-h", "github.com", "-s", "codespace"],
|
|
47635
47659
|
{ stdio: "inherit" }
|
|
47636
47660
|
);
|
|
47637
|
-
proc.on("exit", (code) =>
|
|
47661
|
+
proc.on("exit", (code) => resolve13(code ?? 1));
|
|
47638
47662
|
proc.on("error", reject);
|
|
47639
47663
|
});
|
|
47640
47664
|
if (refreshCode !== 0) {
|
|
@@ -47778,10 +47802,10 @@ var GitHubCodespacesProvider = class {
|
|
|
47778
47802
|
if (q(proceed) || !proceed) return;
|
|
47779
47803
|
O2.step(`Installing gh via ${installCmd.describe}\u2026`);
|
|
47780
47804
|
resetStdinForChild();
|
|
47781
|
-
const ok = await new Promise((
|
|
47805
|
+
const ok = await new Promise((resolve13) => {
|
|
47782
47806
|
const proc = (0, import_child_process30.spawn)(installCmd.exe, installCmd.args, { stdio: "inherit" });
|
|
47783
|
-
proc.on("exit", (code) =>
|
|
47784
|
-
proc.on("error", () =>
|
|
47807
|
+
proc.on("exit", (code) => resolve13(code === 0));
|
|
47808
|
+
proc.on("error", () => resolve13(false));
|
|
47785
47809
|
});
|
|
47786
47810
|
if (ok) O2.success("gh installed");
|
|
47787
47811
|
else O2.error("gh install failed");
|
|
@@ -47805,14 +47829,14 @@ var GitHubCodespacesProvider = class {
|
|
|
47805
47829
|
"Expanding GitHub scopes"
|
|
47806
47830
|
);
|
|
47807
47831
|
resetStdinForChild();
|
|
47808
|
-
await new Promise((
|
|
47832
|
+
await new Promise((resolve13, reject) => {
|
|
47809
47833
|
const proc = (0, import_child_process30.spawn)(
|
|
47810
47834
|
"gh",
|
|
47811
47835
|
["auth", "refresh", "-h", "github.com", "-s", "repo,read:org"],
|
|
47812
47836
|
{ stdio: "inherit" }
|
|
47813
47837
|
);
|
|
47814
47838
|
proc.on("exit", (code) => {
|
|
47815
|
-
if (code === 0)
|
|
47839
|
+
if (code === 0) resolve13();
|
|
47816
47840
|
else reject(new Error(
|
|
47817
47841
|
"gh auth refresh failed. Re-run `gh auth refresh -h github.com -s repo,read:org` manually."
|
|
47818
47842
|
));
|
|
@@ -47983,13 +48007,13 @@ var GitHubCodespacesProvider = class {
|
|
|
47983
48007
|
}
|
|
47984
48008
|
async streamCommand(workspaceId, command2) {
|
|
47985
48009
|
resetStdinForChild();
|
|
47986
|
-
return new Promise((
|
|
48010
|
+
return new Promise((resolve13, reject) => {
|
|
47987
48011
|
const proc = (0, import_child_process30.spawn)(
|
|
47988
48012
|
"gh",
|
|
47989
48013
|
["codespace", "ssh", "-c", workspaceId, "--", "-tt", command2],
|
|
47990
48014
|
{ stdio: "inherit" }
|
|
47991
48015
|
);
|
|
47992
|
-
proc.on("exit", (code) =>
|
|
48016
|
+
proc.on("exit", (code) => resolve13({ code: code ?? 0 }));
|
|
47993
48017
|
proc.on("error", reject);
|
|
47994
48018
|
});
|
|
47995
48019
|
}
|
|
@@ -48010,7 +48034,7 @@ var GitHubCodespacesProvider = class {
|
|
|
48010
48034
|
"--",
|
|
48011
48035
|
`mkdir -p ${shellQuote(remoteDir)} && tar -xzf - -C ${shellQuote(remoteDir)}`
|
|
48012
48036
|
];
|
|
48013
|
-
await new Promise((
|
|
48037
|
+
await new Promise((resolve13, reject) => {
|
|
48014
48038
|
const tar = (0, import_child_process30.spawn)("tar", tarArgs, {
|
|
48015
48039
|
stdio: ["ignore", "pipe", "pipe"],
|
|
48016
48040
|
env: tarEnv
|
|
@@ -48030,7 +48054,7 @@ var GitHubCodespacesProvider = class {
|
|
|
48030
48054
|
ssh.on("error", reject);
|
|
48031
48055
|
ssh.on("exit", (code) => {
|
|
48032
48056
|
if (code === 0) {
|
|
48033
|
-
|
|
48057
|
+
resolve13();
|
|
48034
48058
|
} else {
|
|
48035
48059
|
const reason = (sshErr || tarErr || `exit ${code}`).trim().slice(0, 500);
|
|
48036
48060
|
reject(new Error(`Remote tar failed: ${reason}`));
|
|
@@ -48048,7 +48072,7 @@ var GitHubCodespacesProvider = class {
|
|
|
48048
48072
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote(remotePath)}`);
|
|
48049
48073
|
}
|
|
48050
48074
|
const cmd = parts.join(" && ");
|
|
48051
|
-
await new Promise((
|
|
48075
|
+
await new Promise((resolve13, reject) => {
|
|
48052
48076
|
const proc = (0, import_child_process30.spawn)(
|
|
48053
48077
|
"gh",
|
|
48054
48078
|
["codespace", "ssh", "-c", workspaceId, "--", cmd],
|
|
@@ -48060,7 +48084,7 @@ var GitHubCodespacesProvider = class {
|
|
|
48060
48084
|
});
|
|
48061
48085
|
proc.on("error", reject);
|
|
48062
48086
|
proc.on("exit", (code) => {
|
|
48063
|
-
if (code === 0)
|
|
48087
|
+
if (code === 0) resolve13();
|
|
48064
48088
|
else reject(new Error(`Remote write failed: ${(stderr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48065
48089
|
});
|
|
48066
48090
|
proc.stdin?.write(contents);
|
|
@@ -48150,10 +48174,10 @@ var GitpodProvider = class {
|
|
|
48150
48174
|
"Authenticating Gitpod"
|
|
48151
48175
|
);
|
|
48152
48176
|
resetStdinForChild2();
|
|
48153
|
-
await new Promise((
|
|
48177
|
+
await new Promise((resolve13, reject) => {
|
|
48154
48178
|
const proc = (0, import_child_process31.spawn)("gitpod", ["login"], { stdio: "inherit" });
|
|
48155
48179
|
proc.on("exit", (code) => {
|
|
48156
|
-
if (code === 0)
|
|
48180
|
+
if (code === 0) resolve13();
|
|
48157
48181
|
else reject(new Error("gitpod login failed."));
|
|
48158
48182
|
});
|
|
48159
48183
|
proc.on("error", reject);
|
|
@@ -48302,13 +48326,13 @@ var GitpodProvider = class {
|
|
|
48302
48326
|
}
|
|
48303
48327
|
async streamCommand(workspaceId, command2) {
|
|
48304
48328
|
resetStdinForChild2();
|
|
48305
|
-
return new Promise((
|
|
48329
|
+
return new Promise((resolve13, reject) => {
|
|
48306
48330
|
const proc = (0, import_child_process31.spawn)(
|
|
48307
48331
|
"gitpod",
|
|
48308
48332
|
["workspace", "ssh", workspaceId, "--", "-tt", command2],
|
|
48309
48333
|
{ stdio: "inherit" }
|
|
48310
48334
|
);
|
|
48311
|
-
proc.on("exit", (code) =>
|
|
48335
|
+
proc.on("exit", (code) => resolve13({ code: code ?? 0 }));
|
|
48312
48336
|
proc.on("error", reject);
|
|
48313
48337
|
});
|
|
48314
48338
|
}
|
|
@@ -48322,7 +48346,7 @@ var GitpodProvider = class {
|
|
|
48322
48346
|
tarArgs.push(".");
|
|
48323
48347
|
const tarEnv = { ...process.env, COPYFILE_DISABLE: "1" };
|
|
48324
48348
|
const remoteCmd = `mkdir -p ${shellQuote2(remoteDir)} && tar -xzf - -C ${shellQuote2(remoteDir)}`;
|
|
48325
|
-
await new Promise((
|
|
48349
|
+
await new Promise((resolve13, reject) => {
|
|
48326
48350
|
const tar = (0, import_child_process31.spawn)("tar", tarArgs, {
|
|
48327
48351
|
stdio: ["ignore", "pipe", "pipe"],
|
|
48328
48352
|
env: tarEnv
|
|
@@ -48343,7 +48367,7 @@ var GitpodProvider = class {
|
|
|
48343
48367
|
tar.on("error", reject);
|
|
48344
48368
|
ssh.on("error", reject);
|
|
48345
48369
|
ssh.on("exit", (code) => {
|
|
48346
|
-
if (code === 0)
|
|
48370
|
+
if (code === 0) resolve13();
|
|
48347
48371
|
else reject(new Error(`Remote tar failed: ${(sshErr || tarErr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48348
48372
|
});
|
|
48349
48373
|
});
|
|
@@ -48358,7 +48382,7 @@ var GitpodProvider = class {
|
|
|
48358
48382
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote2(remotePath)}`);
|
|
48359
48383
|
}
|
|
48360
48384
|
const cmd = parts.join(" && ");
|
|
48361
|
-
await new Promise((
|
|
48385
|
+
await new Promise((resolve13, reject) => {
|
|
48362
48386
|
const proc = (0, import_child_process31.spawn)(
|
|
48363
48387
|
"gitpod",
|
|
48364
48388
|
["workspace", "ssh", workspaceId, "--", cmd],
|
|
@@ -48370,7 +48394,7 @@ var GitpodProvider = class {
|
|
|
48370
48394
|
});
|
|
48371
48395
|
proc.on("error", reject);
|
|
48372
48396
|
proc.on("exit", (code) => {
|
|
48373
|
-
if (code === 0)
|
|
48397
|
+
if (code === 0) resolve13();
|
|
48374
48398
|
else reject(new Error(`Remote write failed: ${(stderr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48375
48399
|
});
|
|
48376
48400
|
proc.stdin?.write(contents);
|
|
@@ -48427,14 +48451,14 @@ var GitLabWorkspacesProvider = class {
|
|
|
48427
48451
|
"Authenticating GitLab"
|
|
48428
48452
|
);
|
|
48429
48453
|
resetStdinForChild3();
|
|
48430
|
-
await new Promise((
|
|
48454
|
+
await new Promise((resolve13, reject) => {
|
|
48431
48455
|
const proc = (0, import_child_process32.spawn)(
|
|
48432
48456
|
"glab",
|
|
48433
48457
|
["auth", "login", "--scopes", "api,read_user,read_repository"],
|
|
48434
48458
|
{ stdio: "inherit" }
|
|
48435
48459
|
);
|
|
48436
48460
|
proc.on("exit", (code) => {
|
|
48437
|
-
if (code === 0)
|
|
48461
|
+
if (code === 0) resolve13();
|
|
48438
48462
|
else reject(new Error("glab auth login failed."));
|
|
48439
48463
|
});
|
|
48440
48464
|
proc.on("error", reject);
|
|
@@ -48599,13 +48623,13 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48599
48623
|
async streamCommand(workspaceId, command2) {
|
|
48600
48624
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
48601
48625
|
resetStdinForChild3();
|
|
48602
|
-
return new Promise((
|
|
48626
|
+
return new Promise((resolve13, reject) => {
|
|
48603
48627
|
const proc = (0, import_child_process32.spawn)(
|
|
48604
48628
|
"ssh",
|
|
48605
48629
|
["-tt", "-o", "StrictHostKeyChecking=accept-new", `${workspaceId}@${sshHost}`, command2],
|
|
48606
48630
|
{ stdio: "inherit" }
|
|
48607
48631
|
);
|
|
48608
|
-
proc.on("exit", (code) =>
|
|
48632
|
+
proc.on("exit", (code) => resolve13({ code: code ?? 0 }));
|
|
48609
48633
|
proc.on("error", reject);
|
|
48610
48634
|
});
|
|
48611
48635
|
}
|
|
@@ -48620,7 +48644,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48620
48644
|
tarArgs.push(".");
|
|
48621
48645
|
const tarEnv = { ...process.env, COPYFILE_DISABLE: "1" };
|
|
48622
48646
|
const remoteCmd = `mkdir -p ${shellQuote3(remoteDir)} && tar -xzf - -C ${shellQuote3(remoteDir)}`;
|
|
48623
|
-
await new Promise((
|
|
48647
|
+
await new Promise((resolve13, reject) => {
|
|
48624
48648
|
const tar = (0, import_child_process32.spawn)("tar", tarArgs, { stdio: ["ignore", "pipe", "pipe"], env: tarEnv });
|
|
48625
48649
|
const ssh = (0, import_child_process32.spawn)(
|
|
48626
48650
|
"ssh",
|
|
@@ -48638,7 +48662,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48638
48662
|
tar.on("error", reject);
|
|
48639
48663
|
ssh.on("error", reject);
|
|
48640
48664
|
ssh.on("exit", (code) => {
|
|
48641
|
-
if (code === 0)
|
|
48665
|
+
if (code === 0) resolve13();
|
|
48642
48666
|
else reject(new Error(`Remote tar failed: ${(sshErr || tarErr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48643
48667
|
});
|
|
48644
48668
|
});
|
|
@@ -48651,7 +48675,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48651
48675
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
48652
48676
|
}
|
|
48653
48677
|
const cmd = parts.join(" && ");
|
|
48654
|
-
await new Promise((
|
|
48678
|
+
await new Promise((resolve13, reject) => {
|
|
48655
48679
|
const proc = (0, import_child_process32.spawn)(
|
|
48656
48680
|
"ssh",
|
|
48657
48681
|
["-o", "StrictHostKeyChecking=accept-new", `${workspaceId}@${sshHost}`, cmd],
|
|
@@ -48663,7 +48687,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48663
48687
|
});
|
|
48664
48688
|
proc.on("error", reject);
|
|
48665
48689
|
proc.on("exit", (code) => {
|
|
48666
|
-
if (code === 0)
|
|
48690
|
+
if (code === 0) resolve13();
|
|
48667
48691
|
else reject(new Error(`Remote write failed: ${(stderr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48668
48692
|
});
|
|
48669
48693
|
proc.stdin?.write(contents);
|
|
@@ -48754,10 +48778,10 @@ var RailwayProvider = class {
|
|
|
48754
48778
|
"Authenticating Railway"
|
|
48755
48779
|
);
|
|
48756
48780
|
resetStdinForChild4();
|
|
48757
|
-
await new Promise((
|
|
48781
|
+
await new Promise((resolve13, reject) => {
|
|
48758
48782
|
const proc = (0, import_child_process33.spawn)("railway", ["login"], { stdio: "inherit" });
|
|
48759
48783
|
proc.on("exit", (code) => {
|
|
48760
|
-
if (code === 0)
|
|
48784
|
+
if (code === 0) resolve13();
|
|
48761
48785
|
else reject(new Error("railway login failed."));
|
|
48762
48786
|
});
|
|
48763
48787
|
proc.on("error", reject);
|
|
@@ -48897,13 +48921,13 @@ var RailwayProvider = class {
|
|
|
48897
48921
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
48898
48922
|
}
|
|
48899
48923
|
resetStdinForChild4();
|
|
48900
|
-
return new Promise((
|
|
48924
|
+
return new Promise((resolve13, reject) => {
|
|
48901
48925
|
const proc = (0, import_child_process33.spawn)(
|
|
48902
48926
|
"railway",
|
|
48903
48927
|
["shell", "--project", projectId, "--service", serviceId, "--command", command2],
|
|
48904
48928
|
{ stdio: "inherit" }
|
|
48905
48929
|
);
|
|
48906
|
-
proc.on("exit", (code) =>
|
|
48930
|
+
proc.on("exit", (code) => resolve13({ code: code ?? 0 }));
|
|
48907
48931
|
proc.on("error", reject);
|
|
48908
48932
|
});
|
|
48909
48933
|
}
|
|
@@ -48921,7 +48945,7 @@ var RailwayProvider = class {
|
|
|
48921
48945
|
tarArgs.push(".");
|
|
48922
48946
|
const tarEnv = { ...process.env, COPYFILE_DISABLE: "1" };
|
|
48923
48947
|
const remoteCmd = `mkdir -p ${shellQuote4(remoteDir)} && tar -xzf - -C ${shellQuote4(remoteDir)}`;
|
|
48924
|
-
await new Promise((
|
|
48948
|
+
await new Promise((resolve13, reject) => {
|
|
48925
48949
|
const tar = (0, import_child_process33.spawn)("tar", tarArgs, { stdio: ["ignore", "pipe", "pipe"], env: tarEnv });
|
|
48926
48950
|
const sh = (0, import_child_process33.spawn)(
|
|
48927
48951
|
"railway",
|
|
@@ -48939,7 +48963,7 @@ var RailwayProvider = class {
|
|
|
48939
48963
|
tar.on("error", reject);
|
|
48940
48964
|
sh.on("error", reject);
|
|
48941
48965
|
sh.on("exit", (code) => {
|
|
48942
|
-
if (code === 0)
|
|
48966
|
+
if (code === 0) resolve13();
|
|
48943
48967
|
else reject(new Error(`Remote tar failed: ${(shErr || tarErr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48944
48968
|
});
|
|
48945
48969
|
});
|
|
@@ -48955,7 +48979,7 @@ var RailwayProvider = class {
|
|
|
48955
48979
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
48956
48980
|
}
|
|
48957
48981
|
const cmd = parts.join(" && ");
|
|
48958
|
-
await new Promise((
|
|
48982
|
+
await new Promise((resolve13, reject) => {
|
|
48959
48983
|
const proc = (0, import_child_process33.spawn)(
|
|
48960
48984
|
"railway",
|
|
48961
48985
|
["shell", "--project", projectId, "--service", serviceId, "--command", cmd],
|
|
@@ -48967,7 +48991,7 @@ var RailwayProvider = class {
|
|
|
48967
48991
|
});
|
|
48968
48992
|
proc.on("error", reject);
|
|
48969
48993
|
proc.on("exit", (code) => {
|
|
48970
|
-
if (code === 0)
|
|
48994
|
+
if (code === 0) resolve13();
|
|
48971
48995
|
else reject(new Error(`Remote write failed: ${(stderr || `exit ${code}`).trim().slice(0, 500)}`));
|
|
48972
48996
|
});
|
|
48973
48997
|
proc.stdin?.write(contents);
|
|
@@ -49489,7 +49513,7 @@ async function stopWorkspaceFromLocal(target) {
|
|
|
49489
49513
|
}
|
|
49490
49514
|
|
|
49491
49515
|
// src/commands/host/host-client.ts
|
|
49492
|
-
var
|
|
49516
|
+
var fs90 = __toESM(require("fs"));
|
|
49493
49517
|
var os65 = __toESM(require("os"));
|
|
49494
49518
|
var path103 = __toESM(require("path"));
|
|
49495
49519
|
var import_node_crypto16 = require("crypto");
|
|
@@ -49552,7 +49576,7 @@ function collectOsInfo() {
|
|
|
49552
49576
|
}
|
|
49553
49577
|
function loadHostIdentity() {
|
|
49554
49578
|
try {
|
|
49555
|
-
const raw =
|
|
49579
|
+
const raw = fs90.readFileSync(hostIdentityPath(), "utf8");
|
|
49556
49580
|
const parsed = JSON.parse(raw);
|
|
49557
49581
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
|
|
49558
49582
|
const p2 = parsed;
|
|
@@ -49580,8 +49604,8 @@ function ensureControlPollSecret(identity, save = saveHostIdentity) {
|
|
|
49580
49604
|
}
|
|
49581
49605
|
function saveHostIdentity(identity) {
|
|
49582
49606
|
const file = hostIdentityPath();
|
|
49583
|
-
|
|
49584
|
-
|
|
49607
|
+
fs90.mkdirSync(path103.dirname(file), { recursive: true, mode: 448 });
|
|
49608
|
+
fs90.writeFileSync(file, JSON.stringify(identity, null, 2), {
|
|
49585
49609
|
encoding: "utf8",
|
|
49586
49610
|
mode: 384
|
|
49587
49611
|
});
|
|
@@ -49626,7 +49650,7 @@ function isTerminalEnrollError(err) {
|
|
|
49626
49650
|
}
|
|
49627
49651
|
function deleteHostIdentity() {
|
|
49628
49652
|
try {
|
|
49629
|
-
|
|
49653
|
+
fs90.rmSync(hostIdentityPath(), { force: true });
|
|
49630
49654
|
} catch {
|
|
49631
49655
|
}
|
|
49632
49656
|
}
|
|
@@ -49844,7 +49868,7 @@ async function host(args2) {
|
|
|
49844
49868
|
// src/commands/host-agent.ts
|
|
49845
49869
|
var import_node_child_process36 = require("child_process");
|
|
49846
49870
|
var os71 = __toESM(require("os"));
|
|
49847
|
-
var
|
|
49871
|
+
var fs97 = __toESM(require("fs"));
|
|
49848
49872
|
var path110 = __toESM(require("path"));
|
|
49849
49873
|
|
|
49850
49874
|
// src/skills/persist-from-payload.ts
|
|
@@ -49854,7 +49878,7 @@ function persistOrClearSkillsFromPayload(skills) {
|
|
|
49854
49878
|
}
|
|
49855
49879
|
|
|
49856
49880
|
// src/commands/host/session-state.ts
|
|
49857
|
-
var
|
|
49881
|
+
var fs91 = __toESM(require("fs"));
|
|
49858
49882
|
var os66 = __toESM(require("os"));
|
|
49859
49883
|
var path104 = __toESM(require("path"));
|
|
49860
49884
|
function hostSessionStatePath(env = process.env) {
|
|
@@ -49871,7 +49895,7 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
49871
49895
|
return {
|
|
49872
49896
|
load() {
|
|
49873
49897
|
try {
|
|
49874
|
-
const raw = JSON.parse(
|
|
49898
|
+
const raw = JSON.parse(fs91.readFileSync(file, "utf8"));
|
|
49875
49899
|
return Array.isArray(raw?.sessions) ? raw.sessions.filter(isRecord5) : null;
|
|
49876
49900
|
} catch {
|
|
49877
49901
|
return null;
|
|
@@ -49879,18 +49903,18 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
49879
49903
|
},
|
|
49880
49904
|
save(list) {
|
|
49881
49905
|
try {
|
|
49882
|
-
|
|
49906
|
+
fs91.mkdirSync(path104.dirname(file), { recursive: true, mode: 448 });
|
|
49883
49907
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
49884
|
-
|
|
49908
|
+
fs91.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
|
|
49885
49909
|
mode: 384
|
|
49886
49910
|
});
|
|
49887
|
-
|
|
49911
|
+
fs91.renameSync(tmp, file);
|
|
49888
49912
|
} catch {
|
|
49889
49913
|
}
|
|
49890
49914
|
},
|
|
49891
49915
|
clear() {
|
|
49892
49916
|
try {
|
|
49893
|
-
|
|
49917
|
+
fs91.rmSync(file, { force: true });
|
|
49894
49918
|
} catch {
|
|
49895
49919
|
}
|
|
49896
49920
|
}
|
|
@@ -49928,7 +49952,7 @@ function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
|
49928
49952
|
|
|
49929
49953
|
// src/commands/host/git-tooling.ts
|
|
49930
49954
|
var import_node_child_process31 = require("child_process");
|
|
49931
|
-
var
|
|
49955
|
+
var fs92 = __toESM(require("fs"));
|
|
49932
49956
|
var os67 = __toESM(require("os"));
|
|
49933
49957
|
var path105 = __toESM(require("path"));
|
|
49934
49958
|
function codeamBinDir() {
|
|
@@ -49964,7 +49988,7 @@ async function download(url2, dest) {
|
|
|
49964
49988
|
const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
|
|
49965
49989
|
if (!res.ok || !res.body) return false;
|
|
49966
49990
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
49967
|
-
|
|
49991
|
+
fs92.writeFileSync(dest, buf);
|
|
49968
49992
|
return true;
|
|
49969
49993
|
} catch {
|
|
49970
49994
|
return false;
|
|
@@ -49987,7 +50011,7 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
49987
50011
|
const version3 = await resolveVersionFn(token);
|
|
49988
50012
|
const asset = `gh_${version3}_${osToken}_${arch2}`;
|
|
49989
50013
|
const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
|
|
49990
|
-
const tmpRoot =
|
|
50014
|
+
const tmpRoot = fs92.mkdtempSync(path105.join(os67.tmpdir(), "codeam-gh-"));
|
|
49991
50015
|
const archive = path105.join(tmpRoot, `${asset}.${ext}`);
|
|
49992
50016
|
if (!await downloadFn(url2, archive)) {
|
|
49993
50017
|
log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
|
|
@@ -49999,15 +50023,15 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
49999
50023
|
return null;
|
|
50000
50024
|
}
|
|
50001
50025
|
const extractedBin = path105.join(tmpRoot, asset, "bin", binaryName);
|
|
50002
|
-
if (!
|
|
50026
|
+
if (!fs92.existsSync(extractedBin)) {
|
|
50003
50027
|
log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
|
|
50004
50028
|
return null;
|
|
50005
50029
|
}
|
|
50006
50030
|
const binDir = codeamBinDir();
|
|
50007
|
-
|
|
50031
|
+
fs92.mkdirSync(binDir, { recursive: true });
|
|
50008
50032
|
const target = path105.join(binDir, binaryName);
|
|
50009
|
-
|
|
50010
|
-
|
|
50033
|
+
fs92.copyFileSync(extractedBin, target);
|
|
50034
|
+
fs92.chmodSync(target, 493);
|
|
50011
50035
|
log.info("host-agent", `gh installed to ${target} (v${version3})`);
|
|
50012
50036
|
return target;
|
|
50013
50037
|
} catch (e) {
|
|
@@ -50054,9 +50078,9 @@ function writeGhHostsToken(token) {
|
|
|
50054
50078
|
try {
|
|
50055
50079
|
const dir = ghConfigDir();
|
|
50056
50080
|
const file = path105.join(dir, "hosts.yml");
|
|
50057
|
-
if (
|
|
50058
|
-
|
|
50059
|
-
|
|
50081
|
+
if (fs92.existsSync(file)) return false;
|
|
50082
|
+
fs92.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
50083
|
+
fs92.writeFileSync(
|
|
50060
50084
|
file,
|
|
50061
50085
|
`github.com:
|
|
50062
50086
|
oauth_token: ${token}
|
|
@@ -50099,7 +50123,7 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
50099
50123
|
const version3 = await resolveLatestGlabVersion();
|
|
50100
50124
|
const asset = `glab_${version3}_${osToken}_${arch2}`;
|
|
50101
50125
|
const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
|
|
50102
|
-
const tmpRoot =
|
|
50126
|
+
const tmpRoot = fs92.mkdtempSync(path105.join(os67.tmpdir(), "codeam-glab-"));
|
|
50103
50127
|
const archive = path105.join(tmpRoot, `${asset}.${ext}`);
|
|
50104
50128
|
if (!await downloadFn(url2, archive)) {
|
|
50105
50129
|
log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
|
|
@@ -50115,16 +50139,16 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
50115
50139
|
path105.join(tmpRoot, asset, "bin", binaryName),
|
|
50116
50140
|
path105.join(tmpRoot, binaryName)
|
|
50117
50141
|
];
|
|
50118
|
-
const extractedBin = candidates.find((c2) =>
|
|
50142
|
+
const extractedBin = candidates.find((c2) => fs92.existsSync(c2));
|
|
50119
50143
|
if (!extractedBin) {
|
|
50120
50144
|
log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
|
|
50121
50145
|
return null;
|
|
50122
50146
|
}
|
|
50123
50147
|
const binDir = codeamBinDir();
|
|
50124
|
-
|
|
50148
|
+
fs92.mkdirSync(binDir, { recursive: true });
|
|
50125
50149
|
const target = path105.join(binDir, binaryName);
|
|
50126
|
-
|
|
50127
|
-
|
|
50150
|
+
fs92.copyFileSync(extractedBin, target);
|
|
50151
|
+
fs92.chmodSync(target, 493);
|
|
50128
50152
|
log.info("host-agent", `glab installed to ${target} (v${version3})`);
|
|
50129
50153
|
return target;
|
|
50130
50154
|
} catch (e) {
|
|
@@ -50166,7 +50190,7 @@ var defaultGitToolingRunner = {
|
|
|
50166
50190
|
}
|
|
50167
50191
|
},
|
|
50168
50192
|
run(cmd, args2, opts = {}) {
|
|
50169
|
-
return new Promise((
|
|
50193
|
+
return new Promise((resolve13) => {
|
|
50170
50194
|
const child = (0, import_node_child_process31.spawn)(cmd, args2, {
|
|
50171
50195
|
stdio: [opts.input !== void 0 ? "pipe" : "ignore", "ignore", "pipe"]
|
|
50172
50196
|
});
|
|
@@ -50175,7 +50199,7 @@ var defaultGitToolingRunner = {
|
|
|
50175
50199
|
const done = (code) => {
|
|
50176
50200
|
if (settled) return;
|
|
50177
50201
|
settled = true;
|
|
50178
|
-
|
|
50202
|
+
resolve13({ code, stderr });
|
|
50179
50203
|
};
|
|
50180
50204
|
child.stderr?.on("data", (b) => {
|
|
50181
50205
|
stderr += b.toString();
|
|
@@ -50203,12 +50227,12 @@ var defaultGitToolingRunner = {
|
|
|
50203
50227
|
};
|
|
50204
50228
|
|
|
50205
50229
|
// src/lib/cli-versions.ts
|
|
50206
|
-
var
|
|
50230
|
+
var fs94 = __toESM(require("fs"));
|
|
50207
50231
|
var os69 = __toESM(require("os"));
|
|
50208
50232
|
var path107 = __toESM(require("path"));
|
|
50209
50233
|
|
|
50210
50234
|
// src/lib/updateNotifier.ts
|
|
50211
|
-
var
|
|
50235
|
+
var fs93 = __toESM(require("fs"));
|
|
50212
50236
|
var os68 = __toESM(require("os"));
|
|
50213
50237
|
var path106 = __toESM(require("path"));
|
|
50214
50238
|
var https8 = __toESM(require("https"));
|
|
@@ -50224,7 +50248,7 @@ function cachePath() {
|
|
|
50224
50248
|
}
|
|
50225
50249
|
function readCache() {
|
|
50226
50250
|
try {
|
|
50227
|
-
const raw =
|
|
50251
|
+
const raw = fs93.readFileSync(cachePath(), "utf8");
|
|
50228
50252
|
const parsed = JSON.parse(raw);
|
|
50229
50253
|
if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
|
|
50230
50254
|
return parsed;
|
|
@@ -50235,10 +50259,10 @@ function readCache() {
|
|
|
50235
50259
|
function writeCache(cache) {
|
|
50236
50260
|
try {
|
|
50237
50261
|
const file = cachePath();
|
|
50238
|
-
|
|
50262
|
+
fs93.mkdirSync(path106.dirname(file), { recursive: true });
|
|
50239
50263
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
50240
|
-
|
|
50241
|
-
|
|
50264
|
+
fs93.writeFileSync(tmp, JSON.stringify(cache));
|
|
50265
|
+
fs93.renameSync(tmp, file);
|
|
50242
50266
|
} catch {
|
|
50243
50267
|
}
|
|
50244
50268
|
}
|
|
@@ -50256,14 +50280,14 @@ function compareSemver(a, b) {
|
|
|
50256
50280
|
return 0;
|
|
50257
50281
|
}
|
|
50258
50282
|
function fetchLatest() {
|
|
50259
|
-
return new Promise((
|
|
50283
|
+
return new Promise((resolve13) => {
|
|
50260
50284
|
const req = https8.get(
|
|
50261
50285
|
REGISTRY_URL,
|
|
50262
50286
|
{ headers: { Accept: "application/json" }, timeout: REQUEST_TIMEOUT_MS },
|
|
50263
50287
|
(res) => {
|
|
50264
50288
|
if (res.statusCode !== 200) {
|
|
50265
50289
|
res.resume();
|
|
50266
|
-
|
|
50290
|
+
resolve13(null);
|
|
50267
50291
|
return;
|
|
50268
50292
|
}
|
|
50269
50293
|
let buf = "";
|
|
@@ -50275,21 +50299,21 @@ function fetchLatest() {
|
|
|
50275
50299
|
try {
|
|
50276
50300
|
const json = JSON.parse(buf);
|
|
50277
50301
|
if (typeof json.version === "string") {
|
|
50278
|
-
|
|
50302
|
+
resolve13(json.version);
|
|
50279
50303
|
} else {
|
|
50280
|
-
|
|
50304
|
+
resolve13(null);
|
|
50281
50305
|
}
|
|
50282
50306
|
} catch {
|
|
50283
|
-
|
|
50307
|
+
resolve13(null);
|
|
50284
50308
|
}
|
|
50285
50309
|
});
|
|
50286
50310
|
}
|
|
50287
50311
|
);
|
|
50288
50312
|
req.on("timeout", () => {
|
|
50289
50313
|
req.destroy();
|
|
50290
|
-
|
|
50314
|
+
resolve13(null);
|
|
50291
50315
|
});
|
|
50292
|
-
req.on("error", () =>
|
|
50316
|
+
req.on("error", () => resolve13(null));
|
|
50293
50317
|
});
|
|
50294
50318
|
}
|
|
50295
50319
|
function notifyIfStale(currentVersion, latest) {
|
|
@@ -50313,7 +50337,7 @@ function isLinkedInstall() {
|
|
|
50313
50337
|
}).trim();
|
|
50314
50338
|
if (!root) return false;
|
|
50315
50339
|
const pkgPath = path106.join(root, PKG_NAME);
|
|
50316
|
-
return
|
|
50340
|
+
return fs93.lstatSync(pkgPath).isSymbolicLink();
|
|
50317
50341
|
} catch {
|
|
50318
50342
|
return false;
|
|
50319
50343
|
}
|
|
@@ -50349,7 +50373,7 @@ function maybeAutoUpdate(currentVersion, latest) {
|
|
|
50349
50373
|
return;
|
|
50350
50374
|
}
|
|
50351
50375
|
try {
|
|
50352
|
-
|
|
50376
|
+
fs93.unlinkSync(cachePath());
|
|
50353
50377
|
} catch {
|
|
50354
50378
|
}
|
|
50355
50379
|
process.stderr.write(` ${import_picocolors12.default.green("\u2713")} Updated. Resuming session...
|
|
@@ -50365,7 +50389,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
50365
50389
|
if (process.env.NODE_ENV === "test") return;
|
|
50366
50390
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
50367
50391
|
if (process.env.CI) return;
|
|
50368
|
-
const current2 = true ? "2.76.
|
|
50392
|
+
const current2 = true ? "2.76.15" : null;
|
|
50369
50393
|
if (!current2) return;
|
|
50370
50394
|
const cache = readCache();
|
|
50371
50395
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -50382,7 +50406,7 @@ function checkForUpdates() {
|
|
|
50382
50406
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
50383
50407
|
if (process.env.CI) return;
|
|
50384
50408
|
if (!process.stdout.isTTY) return;
|
|
50385
|
-
const current2 = true ? "2.76.
|
|
50409
|
+
const current2 = true ? "2.76.15" : null;
|
|
50386
50410
|
if (!current2) return;
|
|
50387
50411
|
const cache = readCache();
|
|
50388
50412
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -50416,7 +50440,7 @@ function isRecord6(v) {
|
|
|
50416
50440
|
function readPkg2(versionDir) {
|
|
50417
50441
|
try {
|
|
50418
50442
|
const raw = JSON.parse(
|
|
50419
|
-
|
|
50443
|
+
fs94.readFileSync(path107.join(packageDirOf(versionDir), "package.json"), "utf8")
|
|
50420
50444
|
);
|
|
50421
50445
|
return isRecord6(raw) ? raw : null;
|
|
50422
50446
|
} catch {
|
|
@@ -50430,14 +50454,14 @@ function entryOf(versionDir) {
|
|
|
50430
50454
|
const named = isRecord6(bin) ? bin.codeam : void 0;
|
|
50431
50455
|
const rel = typeof bin === "string" ? bin : typeof named === "string" ? named : "dist/index.js";
|
|
50432
50456
|
const entry = path107.join(packageDirOf(versionDir), rel);
|
|
50433
|
-
return
|
|
50457
|
+
return fs94.existsSync(entry) ? entry : null;
|
|
50434
50458
|
}
|
|
50435
50459
|
function launcherOf(versionDir) {
|
|
50436
50460
|
const entry = entryOf(versionDir);
|
|
50437
50461
|
if (!entry) return null;
|
|
50438
50462
|
const bin = path107.join(versionDir, "node_modules", ".bin", "codeam");
|
|
50439
50463
|
try {
|
|
50440
|
-
return
|
|
50464
|
+
return fs94.realpathSync(bin) === fs94.realpathSync(entry) ? bin : entry;
|
|
50441
50465
|
} catch {
|
|
50442
50466
|
return entry;
|
|
50443
50467
|
}
|
|
@@ -50450,7 +50474,7 @@ var BAD_MARKER_TTL_MS = 24 * 60 * 6e4;
|
|
|
50450
50474
|
var PRE_READY_WINDOW_MS = 60 * 6e4;
|
|
50451
50475
|
function isBad(versionDir, now = Date.now()) {
|
|
50452
50476
|
try {
|
|
50453
|
-
return now -
|
|
50477
|
+
return now - fs94.statSync(path107.join(versionDir, ".bad")).mtimeMs < BAD_MARKER_TTL_MS;
|
|
50454
50478
|
} catch {
|
|
50455
50479
|
return false;
|
|
50456
50480
|
}
|
|
@@ -50459,7 +50483,7 @@ function recordPreReadyFailure(versionDir, now = Date.now()) {
|
|
|
50459
50483
|
const file = path107.join(versionDir, ".prefail");
|
|
50460
50484
|
let count = 0;
|
|
50461
50485
|
try {
|
|
50462
|
-
const [n, at3] =
|
|
50486
|
+
const [n, at3] = fs94.readFileSync(file, "utf8").trim().split(" ").map(Number);
|
|
50463
50487
|
if (Number.isFinite(n) && Number.isFinite(at3) && now - at3 < PRE_READY_WINDOW_MS) {
|
|
50464
50488
|
count = n;
|
|
50465
50489
|
}
|
|
@@ -50467,41 +50491,52 @@ function recordPreReadyFailure(versionDir, now = Date.now()) {
|
|
|
50467
50491
|
}
|
|
50468
50492
|
count += 1;
|
|
50469
50493
|
try {
|
|
50470
|
-
|
|
50494
|
+
fs94.writeFileSync(file, `${count} ${now}`);
|
|
50471
50495
|
} catch {
|
|
50472
50496
|
}
|
|
50473
50497
|
return count;
|
|
50474
50498
|
}
|
|
50475
50499
|
function clearPreReadyFailures(versionDir) {
|
|
50476
|
-
|
|
50500
|
+
fs94.rmSync(path107.join(versionDir, ".prefail"), { force: true });
|
|
50477
50501
|
}
|
|
50478
50502
|
function markBad(versionDir, reason) {
|
|
50479
50503
|
try {
|
|
50480
|
-
|
|
50504
|
+
fs94.writeFileSync(path107.join(versionDir, ".bad"), `${(/* @__PURE__ */ new Date()).toISOString()} ${reason}
|
|
50481
50505
|
`);
|
|
50482
50506
|
} catch {
|
|
50483
50507
|
}
|
|
50484
50508
|
}
|
|
50485
50509
|
function pointerTarget(root, name) {
|
|
50486
50510
|
try {
|
|
50487
|
-
return
|
|
50511
|
+
return fs94.realpathSync(path107.join(root, name));
|
|
50488
50512
|
} catch {
|
|
50489
50513
|
return null;
|
|
50490
50514
|
}
|
|
50491
50515
|
}
|
|
50492
50516
|
function atomicPoint(root, name, targetDir) {
|
|
50493
|
-
const
|
|
50494
|
-
|
|
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");
|
|
50495
50520
|
try {
|
|
50496
|
-
|
|
50521
|
+
fs94.renameSync(tmp, path107.join(realRoot, name));
|
|
50497
50522
|
} catch (err) {
|
|
50498
|
-
|
|
50523
|
+
fs94.rmSync(tmp, { force: true });
|
|
50499
50524
|
throw err;
|
|
50500
50525
|
}
|
|
50501
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
|
+
}
|
|
50502
50537
|
function switchCurrent(root, versionDir) {
|
|
50503
50538
|
const old = pointerTarget(root, "current");
|
|
50504
|
-
if (old &&
|
|
50539
|
+
if (old && !samePath(old, versionDir)) atomicPoint(root, "previous", old);
|
|
50505
50540
|
atomicPoint(root, "current", versionDir);
|
|
50506
50541
|
}
|
|
50507
50542
|
function validCurrent(root) {
|
|
@@ -50515,7 +50550,7 @@ function rollbackCurrent(root) {
|
|
|
50515
50550
|
const prev = pointerTarget(root, "previous");
|
|
50516
50551
|
if (!prev || isBad(prev) || !entryOf(prev)) return null;
|
|
50517
50552
|
const cur = pointerTarget(root, "current");
|
|
50518
|
-
if (cur &&
|
|
50553
|
+
if (cur && !samePath(cur, prev)) atomicPoint(root, "previous", cur);
|
|
50519
50554
|
atomicPoint(root, "current", prev);
|
|
50520
50555
|
return versionOf(prev);
|
|
50521
50556
|
}
|
|
@@ -50529,8 +50564,8 @@ function versionDirContaining(root, file) {
|
|
|
50529
50564
|
let real;
|
|
50530
50565
|
let realRoot;
|
|
50531
50566
|
try {
|
|
50532
|
-
real =
|
|
50533
|
-
realRoot =
|
|
50567
|
+
real = fs94.realpathSync(file);
|
|
50568
|
+
realRoot = fs94.realpathSync(root);
|
|
50534
50569
|
} catch {
|
|
50535
50570
|
return null;
|
|
50536
50571
|
}
|
|
@@ -50550,7 +50585,7 @@ function pidAlive3(pid) {
|
|
|
50550
50585
|
function livePids(versionDir) {
|
|
50551
50586
|
let names;
|
|
50552
50587
|
try {
|
|
50553
|
-
names =
|
|
50588
|
+
names = fs94.readdirSync(path107.join(versionDir, ".pids"));
|
|
50554
50589
|
} catch {
|
|
50555
50590
|
return [];
|
|
50556
50591
|
}
|
|
@@ -50561,9 +50596,9 @@ function registerRunningVersion(root = cliVersionsRoot(), entry = process.argv[1
|
|
|
50561
50596
|
if (!dir) return;
|
|
50562
50597
|
const file = path107.join(dir, ".pids", String(process.pid));
|
|
50563
50598
|
try {
|
|
50564
|
-
|
|
50565
|
-
|
|
50566
|
-
process.once("exit", () =>
|
|
50599
|
+
fs94.mkdirSync(path107.dirname(file), { recursive: true });
|
|
50600
|
+
fs94.writeFileSync(file, "");
|
|
50601
|
+
process.once("exit", () => fs94.rmSync(file, { force: true }));
|
|
50567
50602
|
} catch {
|
|
50568
50603
|
}
|
|
50569
50604
|
}
|
|
@@ -50571,7 +50606,7 @@ function gcVersions(root) {
|
|
|
50571
50606
|
const removed = [];
|
|
50572
50607
|
let names;
|
|
50573
50608
|
try {
|
|
50574
|
-
names =
|
|
50609
|
+
names = fs94.readdirSync(root).filter((n) => SEMVER_DIR.test(n));
|
|
50575
50610
|
} catch {
|
|
50576
50611
|
return removed;
|
|
50577
50612
|
}
|
|
@@ -50585,7 +50620,7 @@ function gcVersions(root) {
|
|
|
50585
50620
|
const dir = path107.join(root, name);
|
|
50586
50621
|
if (keep.has(name) || livePids(dir).length > 0) continue;
|
|
50587
50622
|
try {
|
|
50588
|
-
|
|
50623
|
+
fs94.rmSync(dir, { recursive: true, force: true });
|
|
50589
50624
|
removed.push(name);
|
|
50590
50625
|
} catch {
|
|
50591
50626
|
}
|
|
@@ -50596,22 +50631,22 @@ function acquireInstallLock(root) {
|
|
|
50596
50631
|
const lock = path107.join(root, ".install.lock");
|
|
50597
50632
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
50598
50633
|
try {
|
|
50599
|
-
const fd =
|
|
50600
|
-
|
|
50601
|
-
|
|
50602
|
-
return () =>
|
|
50634
|
+
const fd = fs94.openSync(lock, "wx");
|
|
50635
|
+
fs94.writeSync(fd, String(process.pid));
|
|
50636
|
+
fs94.closeSync(fd);
|
|
50637
|
+
return () => fs94.rmSync(lock, { force: true });
|
|
50603
50638
|
} catch (err) {
|
|
50604
50639
|
if (err.code !== "EEXIST") return null;
|
|
50605
50640
|
let stale = false;
|
|
50606
50641
|
try {
|
|
50607
|
-
const owner = Number(
|
|
50608
|
-
const age = Date.now() -
|
|
50642
|
+
const owner = Number(fs94.readFileSync(lock, "utf8"));
|
|
50643
|
+
const age = Date.now() - fs94.statSync(lock).mtimeMs;
|
|
50609
50644
|
stale = !Number.isInteger(owner) || !pidAlive3(owner) || age > LOCK_STALE_MS;
|
|
50610
50645
|
} catch {
|
|
50611
50646
|
stale = true;
|
|
50612
50647
|
}
|
|
50613
50648
|
if (!stale) return null;
|
|
50614
|
-
|
|
50649
|
+
fs94.rmSync(lock, { force: true });
|
|
50615
50650
|
}
|
|
50616
50651
|
}
|
|
50617
50652
|
return null;
|
|
@@ -50619,7 +50654,7 @@ function acquireInstallLock(root) {
|
|
|
50619
50654
|
|
|
50620
50655
|
// src/commands/host/host-launch.ts
|
|
50621
50656
|
var import_node_child_process34 = require("child_process");
|
|
50622
|
-
var
|
|
50657
|
+
var fs96 = __toESM(require("fs"));
|
|
50623
50658
|
var os70 = __toESM(require("os"));
|
|
50624
50659
|
var path109 = __toESM(require("path"));
|
|
50625
50660
|
|
|
@@ -50643,7 +50678,7 @@ var EXIT_CODE_NAMES = {
|
|
|
50643
50678
|
|
|
50644
50679
|
// src/commands/host/self-update.ts
|
|
50645
50680
|
var import_node_child_process33 = require("child_process");
|
|
50646
|
-
var
|
|
50681
|
+
var fs95 = __toESM(require("fs"));
|
|
50647
50682
|
var path108 = __toESM(require("path"));
|
|
50648
50683
|
var SELF_UPDATE_PKG = "codeam-cli";
|
|
50649
50684
|
var SELF_UPDATE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
@@ -50653,7 +50688,7 @@ var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
|
|
|
50653
50688
|
var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
50654
50689
|
var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
|
|
50655
50690
|
function currentCliVersion() {
|
|
50656
|
-
return true ? "2.76.
|
|
50691
|
+
return true ? "2.76.15" : null;
|
|
50657
50692
|
}
|
|
50658
50693
|
async function installedVersion(deps) {
|
|
50659
50694
|
const ls = await deps.run(
|
|
@@ -50669,10 +50704,10 @@ async function installedVersion(deps) {
|
|
|
50669
50704
|
}
|
|
50670
50705
|
}
|
|
50671
50706
|
function runCmd(cmd, args2, timeoutMs) {
|
|
50672
|
-
return new Promise((
|
|
50707
|
+
return new Promise((resolve13) => {
|
|
50673
50708
|
(0, import_node_child_process33.execFile)(cmd, args2, { timeout: timeoutMs }, (err, stdout, stderr) => {
|
|
50674
50709
|
const code = err && typeof err.code === "number" ? err.code : err ? null : 0;
|
|
50675
|
-
|
|
50710
|
+
resolve13({ code, stdout: stdout ?? "", stderr: stderr ?? "" });
|
|
50676
50711
|
});
|
|
50677
50712
|
});
|
|
50678
50713
|
}
|
|
@@ -50696,14 +50731,22 @@ async function runSelfUpdateWith(deps) {
|
|
|
50696
50731
|
}
|
|
50697
50732
|
const root = deps.versionsRoot ?? cliVersionsRoot();
|
|
50698
50733
|
const versioned = versionedModeSupported(deps.platform) ? validCurrent(root) : null;
|
|
50699
|
-
|
|
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) {
|
|
50700
50743
|
log.info(
|
|
50701
50744
|
"host-agent",
|
|
50702
50745
|
`self-update: ${versioned.version} already current in ${root} (running ${current2}) \u2014 restarting onto it`
|
|
50703
50746
|
);
|
|
50704
50747
|
return { status: "updated", version: versioned.version };
|
|
50705
50748
|
}
|
|
50706
|
-
const onDisk = await installedVersion(deps);
|
|
50749
|
+
const onDisk = runningIsCurrent ? null : await installedVersion(deps);
|
|
50707
50750
|
if (onDisk && compareSemver(onDisk, current2) > 0) {
|
|
50708
50751
|
log.info(
|
|
50709
50752
|
"host-agent",
|
|
@@ -50717,15 +50760,19 @@ async function runSelfUpdateWith(deps) {
|
|
|
50717
50760
|
SELF_UPDATE_VIEW_TIMEOUT_MS
|
|
50718
50761
|
);
|
|
50719
50762
|
if (view.code !== 0) {
|
|
50720
|
-
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
|
+
);
|
|
50721
50767
|
return { status: "skipped" };
|
|
50722
50768
|
}
|
|
50723
50769
|
const latest = view.stdout.trim();
|
|
50724
50770
|
if (!latest) {
|
|
50725
|
-
log.
|
|
50771
|
+
log.warn("host-agent", `self-update: npm view returned nothing \u2014 cannot check, staying on ${current2}`);
|
|
50726
50772
|
return { status: "skipped" };
|
|
50727
50773
|
}
|
|
50728
50774
|
if (compareSemver(latest, current2) <= 0) {
|
|
50775
|
+
log.info("host-agent", `self-update: running ${current2}, npm latest ${latest} \u2014 up to date`);
|
|
50729
50776
|
return { status: "current" };
|
|
50730
50777
|
}
|
|
50731
50778
|
if (!versionedModeSupported(deps.platform)) {
|
|
@@ -50747,7 +50794,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
50747
50794
|
const node = deps.nodePath ?? process.execPath;
|
|
50748
50795
|
const target = path108.join(root, latest);
|
|
50749
50796
|
try {
|
|
50750
|
-
|
|
50797
|
+
fs95.mkdirSync(root, { recursive: true });
|
|
50751
50798
|
} catch {
|
|
50752
50799
|
return { status: "skipped" };
|
|
50753
50800
|
}
|
|
@@ -50762,12 +50809,16 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
50762
50809
|
}
|
|
50763
50810
|
try {
|
|
50764
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
|
+
}
|
|
50765
50819
|
const reusable = entryOf(target) && versionOf(target) === latest;
|
|
50766
50820
|
if (!reusable) {
|
|
50767
|
-
|
|
50768
|
-
return { status: "skipped" };
|
|
50769
|
-
}
|
|
50770
|
-
fs94.rmSync(target, { recursive: true, force: true });
|
|
50821
|
+
fs95.rmSync(target, { recursive: true, force: true });
|
|
50771
50822
|
const install = await deps.run(
|
|
50772
50823
|
"npm",
|
|
50773
50824
|
[
|
|
@@ -50782,7 +50833,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
50782
50833
|
SELF_UPDATE_INSTALL_TIMEOUT_MS
|
|
50783
50834
|
);
|
|
50784
50835
|
if (install.code !== 0) {
|
|
50785
|
-
|
|
50836
|
+
fs95.rmSync(target, { recursive: true, force: true });
|
|
50786
50837
|
log.warn(
|
|
50787
50838
|
"host-agent",
|
|
50788
50839
|
`self-update: versioned install exited ${String(install.code)} \u2014 staying on ${running2}: ` + install.stderr.slice(-300)
|
|
@@ -50793,7 +50844,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
50793
50844
|
const entry = entryOf(target);
|
|
50794
50845
|
const check = entry ? await deps.run(node, [entry, "--version"], VERIFY_TIMEOUT_MS) : { code: null, stdout: "", stderr: "no entry point" };
|
|
50795
50846
|
if (check.code !== 0 || !check.stdout.includes(latest)) {
|
|
50796
|
-
|
|
50847
|
+
fs95.rmSync(target, { recursive: true, force: true });
|
|
50797
50848
|
log.warn(
|
|
50798
50849
|
"host-agent",
|
|
50799
50850
|
`self-update: ${latest} failed verification (exit ${String(check.code)}: ${(check.stdout + check.stderr).trim().slice(-200)}) \u2014 staying on ${running2}`
|
|
@@ -50809,7 +50860,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
50809
50860
|
return { status: "updated", version: latest };
|
|
50810
50861
|
} catch (err) {
|
|
50811
50862
|
const cur = pointerTarget(root, "current");
|
|
50812
|
-
if (!cur || path108.basename(cur) !== latest)
|
|
50863
|
+
if (!cur || path108.basename(cur) !== latest) fs95.rmSync(target, { recursive: true, force: true });
|
|
50813
50864
|
log.warn(
|
|
50814
50865
|
"host-agent",
|
|
50815
50866
|
`self-update: versioned install failed: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -50848,7 +50899,7 @@ function signalHostReady(send = process.send?.bind(process)) {
|
|
|
50848
50899
|
}
|
|
50849
50900
|
function defaultDeps() {
|
|
50850
50901
|
return {
|
|
50851
|
-
ownVersion: true ? "2.76.
|
|
50902
|
+
ownVersion: true ? "2.76.15" : null,
|
|
50852
50903
|
root: cliVersionsRoot(),
|
|
50853
50904
|
args: process.argv.slice(3),
|
|
50854
50905
|
execPath: process.execPath,
|
|
@@ -50897,9 +50948,9 @@ async function superviseCurrent(over = {}) {
|
|
|
50897
50948
|
};
|
|
50898
50949
|
if (deps.stdinIsTty) process.on("SIGINT", ignoreSigint);
|
|
50899
50950
|
const { code, signal } = await new Promise(
|
|
50900
|
-
(
|
|
50901
|
-
child.once("exit", (c2, s) =>
|
|
50902
|
-
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 }));
|
|
50903
50954
|
}
|
|
50904
50955
|
);
|
|
50905
50956
|
for (const [sig, h] of handlers2) process.off(sig, h);
|
|
@@ -50945,7 +50996,7 @@ function needsSelfRelaunch(env = process.env, pid = process.pid, ctx = {}) {
|
|
|
50945
50996
|
}
|
|
50946
50997
|
function readPid1Cmdline() {
|
|
50947
50998
|
try {
|
|
50948
|
-
return
|
|
50999
|
+
return fs96.readFileSync("/proc/1/cmdline", "utf8").split("\0").filter(Boolean);
|
|
50949
51000
|
} catch {
|
|
50950
51001
|
return [];
|
|
50951
51002
|
}
|
|
@@ -50984,7 +51035,7 @@ function defaultRestartForUpdate(version3, supervised, io = {}) {
|
|
|
50984
51035
|
}
|
|
50985
51036
|
exit(0);
|
|
50986
51037
|
}
|
|
50987
|
-
function isContainerEnvironment(existsSyncFn =
|
|
51038
|
+
function isContainerEnvironment(existsSyncFn = fs96.existsSync, readFileSyncFn = (p2) => fs96.readFileSync(p2, "utf8")) {
|
|
50988
51039
|
try {
|
|
50989
51040
|
if (existsSyncFn("/.dockerenv")) return true;
|
|
50990
51041
|
} catch {
|
|
@@ -51001,11 +51052,11 @@ function hostAgentPidFile(home = os70.homedir()) {
|
|
|
51001
51052
|
}
|
|
51002
51053
|
function writeHostAgentPidFile(file = hostAgentPidFile(), pid = process.pid) {
|
|
51003
51054
|
try {
|
|
51004
|
-
|
|
51005
|
-
|
|
51055
|
+
fs96.mkdirSync(path109.dirname(file), { recursive: true });
|
|
51056
|
+
fs96.writeFileSync(file, String(pid));
|
|
51006
51057
|
process.once("exit", () => {
|
|
51007
51058
|
try {
|
|
51008
|
-
if (
|
|
51059
|
+
if (fs96.readFileSync(file, "utf8").trim() === String(pid)) fs96.rmSync(file, { force: true });
|
|
51009
51060
|
} catch {
|
|
51010
51061
|
}
|
|
51011
51062
|
});
|
|
@@ -51166,6 +51217,12 @@ function fleetUserIdFromContainerName(containerName) {
|
|
|
51166
51217
|
function isMissingContainerError(stderr) {
|
|
51167
51218
|
return /no such container/i.test(stderr);
|
|
51168
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
|
+
}
|
|
51169
51226
|
function isFleetPruneHostPayload(v) {
|
|
51170
51227
|
if (typeof v !== "object" || v === null) return false;
|
|
51171
51228
|
const p2 = v;
|
|
@@ -51241,7 +51298,7 @@ var DOCKER_RUN_WITH_PULL_TIMEOUT_MS = 6e5;
|
|
|
51241
51298
|
var DOCKER_PRUNE_TIMEOUT_MS = 6e5;
|
|
51242
51299
|
var defaultDockerRunner = {
|
|
51243
51300
|
run(args2, opts = {}) {
|
|
51244
|
-
return new Promise((
|
|
51301
|
+
return new Promise((resolve13) => {
|
|
51245
51302
|
const child = (0, import_node_child_process36.spawn)("docker", args2, {
|
|
51246
51303
|
stdio: ["ignore", "pipe", "pipe"],
|
|
51247
51304
|
env: { ...process.env, ...opts.env }
|
|
@@ -51260,7 +51317,7 @@ var defaultDockerRunner = {
|
|
|
51260
51317
|
if (settled) return;
|
|
51261
51318
|
settled = true;
|
|
51262
51319
|
clearTimeout(timer);
|
|
51263
|
-
|
|
51320
|
+
resolve13({ code, stderr: stderrBuf, stdout: stdoutBuf });
|
|
51264
51321
|
};
|
|
51265
51322
|
child.stdout?.on("data", (b) => {
|
|
51266
51323
|
stdoutBuf += b.toString();
|
|
@@ -51438,7 +51495,7 @@ var HostAgentSupervisor = class {
|
|
|
51438
51495
|
const make = this.deps.makeRelay ?? ((pluginId, onCommand, meta, pollSecret) => new CommandRelayService(pluginId, onCommand, meta, void 0, pollSecret));
|
|
51439
51496
|
this.relay = make(
|
|
51440
51497
|
this.identity.controlPluginId,
|
|
51441
|
-
(cmd) => this.
|
|
51498
|
+
(cmd) => this.dispatchRelayCommand(cmd),
|
|
51442
51499
|
CONTROL_AGENT_META,
|
|
51443
51500
|
this.identity.controlPollSecret
|
|
51444
51501
|
);
|
|
@@ -51600,19 +51657,20 @@ var HostAgentSupervisor = class {
|
|
|
51600
51657
|
*/
|
|
51601
51658
|
maybeRestartForUpdate(version3) {
|
|
51602
51659
|
const midTurn = [...this.children.values()].some((c2) => this.isChildMidTurn(c2.proc.pid));
|
|
51603
|
-
|
|
51660
|
+
const fleetBusy = this.fleetLanes.size > 0;
|
|
51661
|
+
if (midTurn || fleetBusy) {
|
|
51604
51662
|
const since = this.pendingRestartSince ?? this.now();
|
|
51605
51663
|
const waited = this.now() - since;
|
|
51606
51664
|
if (waited < SELF_UPDATE_DEFER_MAX_MS) {
|
|
51607
51665
|
log.info(
|
|
51608
51666
|
"host-agent",
|
|
51609
|
-
`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`
|
|
51610
51668
|
);
|
|
51611
51669
|
return false;
|
|
51612
51670
|
}
|
|
51613
51671
|
log.warn(
|
|
51614
51672
|
"host-agent",
|
|
51615
|
-
`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`
|
|
51616
51674
|
);
|
|
51617
51675
|
}
|
|
51618
51676
|
this.onUpdated(version3);
|
|
@@ -51644,6 +51702,58 @@ var HostAgentSupervisor = class {
|
|
|
51644
51702
|
* arbitrary command surface).
|
|
51645
51703
|
*/
|
|
51646
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) {
|
|
51647
51757
|
if (cmd.type === "fleet_create_box") {
|
|
51648
51758
|
if (!isFleetCreateBoxPayload(cmd.payload)) {
|
|
51649
51759
|
log.warn("host-agent", `ignoring malformed fleet_create_box id=${cmd.id}`);
|
|
@@ -51692,6 +51802,8 @@ var HostAgentSupervisor = class {
|
|
|
51692
51802
|
await this.fleetPruneHost(cmd.payload);
|
|
51693
51803
|
return;
|
|
51694
51804
|
}
|
|
51805
|
+
}
|
|
51806
|
+
async handleNonFleetCommand(cmd) {
|
|
51695
51807
|
if (cmd.type === "self_hosted_deploy") {
|
|
51696
51808
|
if (!isDeployPayload(cmd.payload)) {
|
|
51697
51809
|
log.warn("host-agent", `ignoring malformed self_hosted_deploy id=${cmd.id}`);
|
|
@@ -51765,7 +51877,7 @@ var HostAgentSupervisor = class {
|
|
|
51765
51877
|
const raw = cmd.payload?.path;
|
|
51766
51878
|
const target = typeof raw === "string" && raw.trim() ? path110.resolve(raw.trim()) : os71.homedir();
|
|
51767
51879
|
try {
|
|
51768
|
-
const dirents = await
|
|
51880
|
+
const dirents = await fs97.promises.readdir(target, { withFileTypes: true });
|
|
51769
51881
|
const entries2 = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
|
|
51770
51882
|
(a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
|
|
51771
51883
|
);
|
|
@@ -52247,7 +52359,7 @@ var HostAgentSupervisor = class {
|
|
|
52247
52359
|
payload.deployId
|
|
52248
52360
|
);
|
|
52249
52361
|
try {
|
|
52250
|
-
|
|
52362
|
+
fs97.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
|
|
52251
52363
|
} catch {
|
|
52252
52364
|
}
|
|
52253
52365
|
childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
|
|
@@ -52318,7 +52430,7 @@ var HostAgentSupervisor = class {
|
|
|
52318
52430
|
try {
|
|
52319
52431
|
const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path110.join(os71.homedir(), ".claude");
|
|
52320
52432
|
const projectDir = path110.join(cfgDir, "projects", encodeCwd(cwd));
|
|
52321
|
-
const hasPriorConversation =
|
|
52433
|
+
const hasPriorConversation = fs97.existsSync(projectDir) && fs97.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
|
|
52322
52434
|
if (hasPriorConversation) {
|
|
52323
52435
|
childEnv.CODEAM_RESUME_LATEST = "1";
|
|
52324
52436
|
log.info(
|
|
@@ -52472,7 +52584,7 @@ var HostAgentSupervisor = class {
|
|
|
52472
52584
|
fallbackResumeTarget() {
|
|
52473
52585
|
const session = getActiveSession();
|
|
52474
52586
|
if (!session || !session.pluginId || !session.pollSecret || !session.agent) return null;
|
|
52475
|
-
const cwd = session.cwd &&
|
|
52587
|
+
const cwd = session.cwd && fs97.existsSync(session.cwd) ? session.cwd : process.cwd();
|
|
52476
52588
|
if (isFilesystemRoot(cwd)) {
|
|
52477
52589
|
log.warn(
|
|
52478
52590
|
"host-agent",
|
|
@@ -52512,7 +52624,7 @@ var HostAgentSupervisor = class {
|
|
|
52512
52624
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: no saved pairing on this box`);
|
|
52513
52625
|
return;
|
|
52514
52626
|
}
|
|
52515
|
-
if (!session.cwd || !
|
|
52627
|
+
if (!session.cwd || !fs97.existsSync(session.cwd)) {
|
|
52516
52628
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: workspace is gone`);
|
|
52517
52629
|
return;
|
|
52518
52630
|
}
|
|
@@ -52554,7 +52666,7 @@ var HostAgentSupervisor = class {
|
|
|
52554
52666
|
const persisted = new Map((this.sessionStore.load() ?? []).map((r) => [r.deployId, r.agent]));
|
|
52555
52667
|
for (const c2 of this.children.values()) persisted.set(c2.deployId, c2.agent);
|
|
52556
52668
|
return this.listSavedSessions().map((s) => ({ s, deployId: deployIdFromWorkspace(s.cwd) })).filter(
|
|
52557
|
-
(x) => x.deployId !== null && !!x.s.cwd &&
|
|
52669
|
+
(x) => x.deployId !== null && !!x.s.cwd && fs97.existsSync(x.s.cwd)
|
|
52558
52670
|
).map(({ s, deployId }) => {
|
|
52559
52671
|
const agent = persisted.get(deployId);
|
|
52560
52672
|
return { deployId, sessionId: s.id, ...agent ? { agent } : {} };
|
|
@@ -52606,7 +52718,7 @@ var HostAgentSupervisor = class {
|
|
|
52606
52718
|
if (this.children.has(deployId)) return;
|
|
52607
52719
|
const st3 = this.resumeStateFor(target);
|
|
52608
52720
|
try {
|
|
52609
|
-
const cwd =
|
|
52721
|
+
const cwd = fs97.existsSync(target.cwd) ? target.cwd : process.cwd();
|
|
52610
52722
|
const proc = this.resumeSpawner(
|
|
52611
52723
|
{ ...readHouseProxyChildEnv(deployId), CODEAM_RESUME_SESSION_ID: session.id },
|
|
52612
52724
|
cwd
|
|
@@ -52830,7 +52942,7 @@ var HostAgentSupervisor = class {
|
|
|
52830
52942
|
];
|
|
52831
52943
|
for (const dir of dirs) {
|
|
52832
52944
|
try {
|
|
52833
|
-
|
|
52945
|
+
fs97.rmSync(dir, { recursive: true, force: true });
|
|
52834
52946
|
} catch (err) {
|
|
52835
52947
|
log.warn(
|
|
52836
52948
|
"host-agent",
|
|
@@ -52997,7 +53109,7 @@ async function invite() {
|
|
|
52997
53109
|
var import_node_dns = require("dns");
|
|
52998
53110
|
var import_node_util11 = require("util");
|
|
52999
53111
|
var import_node_crypto17 = require("crypto");
|
|
53000
|
-
var
|
|
53112
|
+
var fs98 = __toESM(require("fs"));
|
|
53001
53113
|
var path111 = __toESM(require("path"));
|
|
53002
53114
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
53003
53115
|
var dnsResolveP = (0, import_node_util11.promisify)(import_node_dns.resolve);
|
|
@@ -53056,11 +53168,11 @@ async function checkHealth(apiBase2) {
|
|
|
53056
53168
|
function checkConfigDir() {
|
|
53057
53169
|
const dir = path111.join(require("os").homedir(), ".codeam");
|
|
53058
53170
|
try {
|
|
53059
|
-
|
|
53171
|
+
fs98.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
53060
53172
|
const probe = path111.join(dir, ".doctor-probe");
|
|
53061
|
-
|
|
53062
|
-
const read =
|
|
53063
|
-
|
|
53173
|
+
fs98.writeFileSync(probe, "ok", { mode: 384 });
|
|
53174
|
+
const read = fs98.readFileSync(probe, "utf8");
|
|
53175
|
+
fs98.unlinkSync(probe);
|
|
53064
53176
|
if (read !== "ok") throw new Error("write/read round-trip mismatch");
|
|
53065
53177
|
return {
|
|
53066
53178
|
id: "config-dir",
|
|
@@ -53166,7 +53278,7 @@ function checkChokidar() {
|
|
|
53166
53278
|
}
|
|
53167
53279
|
async function doctor(args2 = []) {
|
|
53168
53280
|
const json = args2.includes("--json");
|
|
53169
|
-
const cliVersion = true ? "2.76.
|
|
53281
|
+
const cliVersion = true ? "2.76.15" : "0.0.0-dev";
|
|
53170
53282
|
const apiBase2 = resolveApiBaseUrl();
|
|
53171
53283
|
const diagnosticId = (0, import_node_crypto17.randomUUID)();
|
|
53172
53284
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
@@ -53610,7 +53722,7 @@ var WARM_PACKAGE_TIMEOUT_MS = 12e4;
|
|
|
53610
53722
|
var WARM_TOTAL_BUDGET_MS = 10 * 6e4;
|
|
53611
53723
|
var WARM_CONCURRENCY = 4;
|
|
53612
53724
|
function runCapturing(command2, args2, timeoutMs) {
|
|
53613
|
-
return new Promise((
|
|
53725
|
+
return new Promise((resolve13) => {
|
|
53614
53726
|
const child = (0, import_node_child_process40.spawn)(command2, args2, {
|
|
53615
53727
|
env: { ...process.env, ...LAUNCHER_ENV },
|
|
53616
53728
|
stdio: ["ignore", "ignore", "pipe"],
|
|
@@ -53625,15 +53737,15 @@ function runCapturing(command2, args2, timeoutMs) {
|
|
|
53625
53737
|
child.stderr?.on("data", (c2) => stderr += c2);
|
|
53626
53738
|
const timer = setTimeout(() => {
|
|
53627
53739
|
child.kill("SIGKILL");
|
|
53628
|
-
|
|
53740
|
+
resolve13({ status: null, stderr, error: new Error(`spawn ${command2} ETIMEDOUT`) });
|
|
53629
53741
|
}, timeoutMs);
|
|
53630
53742
|
child.on("error", (error) => {
|
|
53631
53743
|
clearTimeout(timer);
|
|
53632
|
-
|
|
53744
|
+
resolve13({ status: null, stderr, error });
|
|
53633
53745
|
});
|
|
53634
53746
|
child.on("close", (status2) => {
|
|
53635
53747
|
clearTimeout(timer);
|
|
53636
|
-
|
|
53748
|
+
resolve13({ status: status2, stderr });
|
|
53637
53749
|
});
|
|
53638
53750
|
});
|
|
53639
53751
|
}
|
|
@@ -53690,7 +53802,7 @@ async function mcpWarm(argv = [], opts = {}) {
|
|
|
53690
53802
|
// src/commands/version.ts
|
|
53691
53803
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
53692
53804
|
function version2() {
|
|
53693
|
-
const v = true ? "2.76.
|
|
53805
|
+
const v = true ? "2.76.15" : "unknown";
|
|
53694
53806
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
53695
53807
|
}
|
|
53696
53808
|
|