@ponythewhite/base-context 1.0.2 → 1.0.5
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 +19 -0
- package/dist/base-context-runtime/pyproject.toml +1 -1
- package/dist/base-context-runtime/src/rlm/mcp.py +39 -17
- package/dist/base-context-runtime/test/test_mcp.py +87 -1
- package/dist/base-context-runtime/uv.lock +1 -1
- package/dist/build-info.json +1 -1
- package/dist/bundle/amazon-bedrock.js +2 -2
- package/dist/bundle/{bundled-modules-PWOGKUQQ.js → bundled-modules-UVCJPNFC.js} +4 -4
- package/dist/bundle/{chunk-IADCPVEI.js → chunk-6FZM46AU.js} +27 -12
- package/dist/bundle/{chunk-HKINIBP4.js → chunk-LFPWHI42.js} +1 -1
- package/dist/bundle/{chunk-27QCJ2AZ.js → chunk-UPVDERMD.js} +0 -12
- package/dist/bundle/{chunk-44PEHPOG.js → chunk-WFJRFQGG.js} +402 -277
- package/dist/bundle/{cli-main-4DS7Y3PI.js → cli-main-OYVMMJUO.js} +3 -3
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/{main-SV7JLVEB.js → main-AVMYOTHF.js} +4 -4
- package/dist/cli/daemon-ps.d.ts.map +1 -1
- package/dist/cli/daemon-ps.js +1 -0
- package/dist/cli/daemon-ps.js.map +1 -1
- package/dist/core/auth-storage.d.ts +4 -0
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +77 -19
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/kernel/bootstrap.d.ts.map +1 -1
- package/dist/core/kernel/bootstrap.js +5 -2
- package/dist/core/kernel/bootstrap.js.map +1 -1
- package/dist/core/mcp/mcp-manager.d.ts.map +1 -1
- package/dist/core/mcp/mcp-manager.js +2 -2
- package/dist/core/mcp/mcp-manager.js.map +1 -1
- package/dist/installer.mjs +5 -2
- package/dist/modes/daemon/daemon-supervisor-ownership.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-supervisor-ownership.js +16 -16
- package/dist/modes/daemon/daemon-supervisor-ownership.js.map +1 -1
- package/dist/modes/interactive/auth-flows.d.ts.map +1 -1
- package/dist/modes/interactive/auth-flows.js +7 -6
- package/dist/modes/interactive/auth-flows.js.map +1 -1
- package/dist/modes/interactive/components/brand-announcement.d.ts +5 -0
- package/dist/modes/interactive/components/brand-announcement.d.ts.map +1 -0
- package/dist/modes/interactive/components/brand-announcement.js +14 -0
- package/dist/modes/interactive/components/brand-announcement.js.map +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +3 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +3 -1
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/menu-panel.d.ts +1 -0
- package/dist/modes/interactive/components/menu-panel.d.ts.map +1 -1
- package/dist/modes/interactive/components/menu-panel.js +3 -0
- package/dist/modes/interactive/components/menu-panel.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +9 -6
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +11 -9
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/shared/startup-notices.d.ts.map +1 -1
- package/dist/modes/shared/startup-notices.js +1 -1
- package/dist/modes/shared/startup-notices.js.map +1 -1
- package/dist/themes/synerise-logo.d.ts +3 -0
- package/dist/themes/synerise-logo.d.ts.map +1 -0
- package/dist/themes/synerise-logo.js +9 -0
- package/dist/themes/synerise-logo.js.map +1 -0
- package/package.json +6 -6
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/components/earendil-announcement.d.ts +0 -5
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +0 -1
- package/dist/modes/interactive/components/earendil-announcement.js +0 -40
- package/dist/modes/interactive/components/earendil-announcement.js.map +0 -1
- package/dist/themes/prime-logo.d.ts +0 -9
- package/dist/themes/prime-logo.d.ts.map +0 -1
- package/dist/themes/prime-logo.js +0 -18
- package/dist/themes/prime-logo.js.map +0 -1
|
@@ -347,7 +347,7 @@ import {
|
|
|
347
347
|
watchWithErrorHandler,
|
|
348
348
|
workerRosterEntryFromSummary,
|
|
349
349
|
wrapTextWithAnsi
|
|
350
|
-
} from "./chunk-
|
|
350
|
+
} from "./chunk-6FZM46AU.js";
|
|
351
351
|
import {
|
|
352
352
|
array,
|
|
353
353
|
boolean,
|
|
@@ -366,7 +366,7 @@ import {
|
|
|
366
366
|
import {
|
|
367
367
|
installFileLogSink,
|
|
368
368
|
setLogContext
|
|
369
|
-
} from "./chunk-
|
|
369
|
+
} from "./chunk-LFPWHI42.js";
|
|
370
370
|
import {
|
|
371
371
|
APP_NAME,
|
|
372
372
|
APP_TITLE,
|
|
@@ -383,7 +383,6 @@ import {
|
|
|
383
383
|
getAgentLogPath,
|
|
384
384
|
getAuthPath,
|
|
385
385
|
getBinDir,
|
|
386
|
-
getBundledInteractiveAssetPath,
|
|
387
386
|
getBundledSkillsDir,
|
|
388
387
|
getChangelogPath,
|
|
389
388
|
getClientErrorLogPath,
|
|
@@ -413,7 +412,7 @@ import {
|
|
|
413
412
|
shouldUseWindowsShell,
|
|
414
413
|
signalProcessGroupOrProcess,
|
|
415
414
|
typebox_exports
|
|
416
|
-
} from "./chunk-
|
|
415
|
+
} from "./chunk-UPVDERMD.js";
|
|
417
416
|
import {
|
|
418
417
|
PRODUCT,
|
|
419
418
|
PRODUCT_ENV
|
|
@@ -605,9 +604,9 @@ var require_pump = __commonJS({
|
|
|
605
604
|
"../../node_modules/pump/index.js"(exports, module) {
|
|
606
605
|
var once = require_once();
|
|
607
606
|
var eos = require_end_of_stream();
|
|
608
|
-
var
|
|
607
|
+
var fs5;
|
|
609
608
|
try {
|
|
610
|
-
|
|
609
|
+
fs5 = __require("fs");
|
|
611
610
|
} catch (e) {
|
|
612
611
|
}
|
|
613
612
|
var noop = function() {
|
|
@@ -618,8 +617,8 @@ var require_pump = __commonJS({
|
|
|
618
617
|
};
|
|
619
618
|
var isFS = function(stream) {
|
|
620
619
|
if (!ancient) return false;
|
|
621
|
-
if (!
|
|
622
|
-
return (stream instanceof (
|
|
620
|
+
if (!fs5) return false;
|
|
621
|
+
return (stream instanceof (fs5.ReadStream || noop) || stream instanceof (fs5.WriteStream || noop)) && isFn(stream.close);
|
|
623
622
|
};
|
|
624
623
|
var isRequest = function(stream) {
|
|
625
624
|
return stream.setHeader && isFn(stream.abort);
|
|
@@ -831,7 +830,7 @@ var require_pend = __commonJS({
|
|
|
831
830
|
// ../../node_modules/fd-slicer/index.js
|
|
832
831
|
var require_fd_slicer = __commonJS({
|
|
833
832
|
"../../node_modules/fd-slicer/index.js"(exports) {
|
|
834
|
-
var
|
|
833
|
+
var fs5 = __require("fs");
|
|
835
834
|
var util = __require("util");
|
|
836
835
|
var stream = __require("stream");
|
|
837
836
|
var Readable3 = stream.Readable;
|
|
@@ -856,7 +855,7 @@ var require_fd_slicer = __commonJS({
|
|
|
856
855
|
FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
|
857
856
|
var self = this;
|
|
858
857
|
self.pend.go(function(cb) {
|
|
859
|
-
|
|
858
|
+
fs5.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
|
|
860
859
|
cb();
|
|
861
860
|
callback(err, bytesRead, buffer2);
|
|
862
861
|
});
|
|
@@ -865,7 +864,7 @@ var require_fd_slicer = __commonJS({
|
|
|
865
864
|
FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
|
866
865
|
var self = this;
|
|
867
866
|
self.pend.go(function(cb) {
|
|
868
|
-
|
|
867
|
+
fs5.write(self.fd, buffer, offset, length, position, function(err, written, buffer2) {
|
|
869
868
|
cb();
|
|
870
869
|
callback(err, written, buffer2);
|
|
871
870
|
});
|
|
@@ -886,7 +885,7 @@ var require_fd_slicer = __commonJS({
|
|
|
886
885
|
if (self.refCount > 0) return;
|
|
887
886
|
if (self.refCount < 0) throw new Error("invalid unref");
|
|
888
887
|
if (self.autoClose) {
|
|
889
|
-
|
|
888
|
+
fs5.close(self.fd, onCloseDone);
|
|
890
889
|
}
|
|
891
890
|
function onCloseDone(err) {
|
|
892
891
|
if (err) {
|
|
@@ -923,7 +922,7 @@ var require_fd_slicer = __commonJS({
|
|
|
923
922
|
self.context.pend.go(function(cb) {
|
|
924
923
|
if (self.destroyed) return cb();
|
|
925
924
|
var buffer = new Buffer(toRead);
|
|
926
|
-
|
|
925
|
+
fs5.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
|
|
927
926
|
if (err) {
|
|
928
927
|
self.destroy(err);
|
|
929
928
|
} else if (bytesRead === 0) {
|
|
@@ -970,7 +969,7 @@ var require_fd_slicer = __commonJS({
|
|
|
970
969
|
}
|
|
971
970
|
self.context.pend.go(function(cb) {
|
|
972
971
|
if (self.destroyed) return cb();
|
|
973
|
-
|
|
972
|
+
fs5.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err2, bytes) {
|
|
974
973
|
if (err2) {
|
|
975
974
|
self.destroy();
|
|
976
975
|
cb();
|
|
@@ -1397,7 +1396,7 @@ var require_buffer_crc32 = __commonJS({
|
|
|
1397
1396
|
// ../../node_modules/yauzl/index.js
|
|
1398
1397
|
var require_yauzl = __commonJS({
|
|
1399
1398
|
"../../node_modules/yauzl/index.js"(exports) {
|
|
1400
|
-
var
|
|
1399
|
+
var fs5 = __require("fs");
|
|
1401
1400
|
var zlib = __require("zlib");
|
|
1402
1401
|
var fd_slicer = require_fd_slicer();
|
|
1403
1402
|
var crc32 = require_buffer_crc32();
|
|
@@ -1427,10 +1426,10 @@ var require_yauzl = __commonJS({
|
|
|
1427
1426
|
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
|
1428
1427
|
if (options.strictFileNames == null) options.strictFileNames = false;
|
|
1429
1428
|
if (callback == null) callback = defaultCallback;
|
|
1430
|
-
|
|
1429
|
+
fs5.open(path6, "r", function(err, fd) {
|
|
1431
1430
|
if (err) return callback(err);
|
|
1432
1431
|
fromFd(fd, options, function(err2, zipfile) {
|
|
1433
|
-
if (err2)
|
|
1432
|
+
if (err2) fs5.close(fd, defaultCallback);
|
|
1434
1433
|
callback(err2, zipfile);
|
|
1435
1434
|
});
|
|
1436
1435
|
});
|
|
@@ -1447,7 +1446,7 @@ var require_yauzl = __commonJS({
|
|
|
1447
1446
|
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
|
1448
1447
|
if (options.strictFileNames == null) options.strictFileNames = false;
|
|
1449
1448
|
if (callback == null) callback = defaultCallback;
|
|
1450
|
-
|
|
1449
|
+
fs5.fstat(fd, function(err, stats) {
|
|
1451
1450
|
if (err) return callback(err);
|
|
1452
1451
|
var reader = fd_slicer.createFromFd(fd, { autoClose: true });
|
|
1453
1452
|
fromRandomAccessReader(reader, stats.size, options, callback);
|
|
@@ -2027,7 +2026,7 @@ var require_yauzl = __commonJS({
|
|
|
2027
2026
|
var require_extract_zip = __commonJS({
|
|
2028
2027
|
"../../node_modules/extract-zip/index.js"(exports, module) {
|
|
2029
2028
|
var debug = require_src()("extract-zip");
|
|
2030
|
-
var { createWriteStream: createWriteStream2, promises:
|
|
2029
|
+
var { createWriteStream: createWriteStream2, promises: fs5 } = __require("fs");
|
|
2031
2030
|
var getStream = require_get_stream();
|
|
2032
2031
|
var path6 = __require("path");
|
|
2033
2032
|
var { promisify } = __require("util");
|
|
@@ -2068,8 +2067,8 @@ var require_extract_zip = __commonJS({
|
|
|
2068
2067
|
}
|
|
2069
2068
|
const destDir = path6.dirname(path6.join(this.opts.dir, entry.fileName));
|
|
2070
2069
|
try {
|
|
2071
|
-
await
|
|
2072
|
-
const canonicalDestDir = await
|
|
2070
|
+
await fs5.mkdir(destDir, { recursive: true });
|
|
2071
|
+
const canonicalDestDir = await fs5.realpath(destDir);
|
|
2073
2072
|
const relativeDestDir = path6.relative(this.opts.dir, canonicalDestDir);
|
|
2074
2073
|
if (relativeDestDir.split(path6.sep).includes("..")) {
|
|
2075
2074
|
throw new Error(`Out of bound path "${canonicalDestDir}" found while processing file ${entry.fileName}`);
|
|
@@ -2113,14 +2112,14 @@ var require_extract_zip = __commonJS({
|
|
|
2113
2112
|
mkdirOptions.mode = procMode;
|
|
2114
2113
|
}
|
|
2115
2114
|
debug("mkdir", { dir: destDir, ...mkdirOptions });
|
|
2116
|
-
await
|
|
2115
|
+
await fs5.mkdir(destDir, mkdirOptions);
|
|
2117
2116
|
if (isDir) return;
|
|
2118
2117
|
debug("opening read stream", dest);
|
|
2119
2118
|
const readStream = await promisify(this.zipfile.openReadStream.bind(this.zipfile))(entry);
|
|
2120
2119
|
if (symlink) {
|
|
2121
2120
|
const link = await getStream(readStream);
|
|
2122
2121
|
debug("creating symlink", link, dest);
|
|
2123
|
-
await
|
|
2122
|
+
await fs5.symlink(link, dest);
|
|
2124
2123
|
} else {
|
|
2125
2124
|
await pipeline2(readStream, createWriteStream2(dest, { mode: procMode }));
|
|
2126
2125
|
}
|
|
@@ -2152,8 +2151,8 @@ var require_extract_zip = __commonJS({
|
|
|
2152
2151
|
if (!path6.isAbsolute(opts.dir)) {
|
|
2153
2152
|
throw new Error("Target directory is expected to be absolute");
|
|
2154
2153
|
}
|
|
2155
|
-
await
|
|
2156
|
-
opts.dir = await
|
|
2154
|
+
await fs5.mkdir(opts.dir, { recursive: true });
|
|
2155
|
+
opts.dir = await fs5.realpath(opts.dir);
|
|
2157
2156
|
return new Extractor(zipPath, opts).extract();
|
|
2158
2157
|
};
|
|
2159
2158
|
}
|
|
@@ -2348,7 +2347,7 @@ function formatErrorDetails(error) {
|
|
|
2348
2347
|
return String(error);
|
|
2349
2348
|
}
|
|
2350
2349
|
async function startCallbackServer(expectedState) {
|
|
2351
|
-
const { createServer:
|
|
2350
|
+
const { createServer: createServer4 } = await getNodeApis();
|
|
2352
2351
|
return new Promise((resolve26, reject) => {
|
|
2353
2352
|
let settleWait;
|
|
2354
2353
|
const waitForCodePromise = new Promise((resolveWait) => {
|
|
@@ -2359,7 +2358,7 @@ async function startCallbackServer(expectedState) {
|
|
|
2359
2358
|
resolveWait(value);
|
|
2360
2359
|
};
|
|
2361
2360
|
});
|
|
2362
|
-
const server =
|
|
2361
|
+
const server = createServer4((req, res) => {
|
|
2363
2362
|
try {
|
|
2364
2363
|
const url2 = new URL(req.url || "", "http://localhost");
|
|
2365
2364
|
if (url2.pathname !== CALLBACK_PATH) {
|
|
@@ -3263,6 +3262,7 @@ async function getOAuthApiKey(providerId, credentials) {
|
|
|
3263
3262
|
}
|
|
3264
3263
|
|
|
3265
3264
|
// ../ai/src/mcp/oauth.ts
|
|
3265
|
+
import { createServer } from "node:http";
|
|
3266
3266
|
var CALLBACK_HOST3 = process.env.BASE_CONTEXT_OAUTH_CALLBACK_HOST || "127.0.0.1";
|
|
3267
3267
|
var CALLBACK_PORT_BASE = Number(process.env.BASE_CONTEXT_MCP_OAUTH_CALLBACK_PORT || 53700);
|
|
3268
3268
|
var CALLBACK_PORT_COUNT = 10;
|
|
@@ -3271,6 +3271,8 @@ var CALLBACK_PORTS = Array.from({ length: CALLBACK_PORT_COUNT }, (_2, i) => CALL
|
|
|
3271
3271
|
var redirectUriFor = (port) => `http://localhost:${port}${CALLBACK_PATH2}`;
|
|
3272
3272
|
var ALL_REDIRECT_URIS = CALLBACK_PORTS.map(redirectUriFor);
|
|
3273
3273
|
var TOKEN_EXPIRY_BUFFER_MS = 5 * 60 * 1e3;
|
|
3274
|
+
var OAUTH_REQUEST_TIMEOUT_MS = 3e4;
|
|
3275
|
+
var OAUTH_MAX_RESPONSE_BYTES = 1024 * 1024;
|
|
3274
3276
|
function validatedHttpsUrl(value, name) {
|
|
3275
3277
|
let url2;
|
|
3276
3278
|
try {
|
|
@@ -3296,15 +3298,74 @@ function authorizationServerMetadataUrls(issuer) {
|
|
|
3296
3298
|
new URL(`${path6}/.well-known/openid-configuration`, url2.origin).toString()
|
|
3297
3299
|
];
|
|
3298
3300
|
}
|
|
3299
|
-
async function
|
|
3300
|
-
|
|
3301
|
+
async function withResponse(url2, init, read) {
|
|
3302
|
+
const controller = new AbortController();
|
|
3303
|
+
const signal = init.signal ? AbortSignal.any([init.signal, controller.signal]) : controller.signal;
|
|
3304
|
+
const timer = setTimeout(() => controller.abort(new Error("MCP OAuth request timed out")), OAUTH_REQUEST_TIMEOUT_MS);
|
|
3305
|
+
let response;
|
|
3306
|
+
try {
|
|
3307
|
+
signal.throwIfAborted();
|
|
3308
|
+
response = await fetch(url2, { ...init, signal, redirect: "error" });
|
|
3309
|
+
return await read(response, signal);
|
|
3310
|
+
} finally {
|
|
3311
|
+
clearTimeout(timer);
|
|
3312
|
+
if (response?.body && !response.body.locked) void response.body.cancel().catch(() => {
|
|
3313
|
+
});
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
async function readJson(response, signal, label) {
|
|
3317
|
+
const reader = response.body?.getReader();
|
|
3318
|
+
if (!reader) throw new Error(`${label} returned invalid JSON`);
|
|
3319
|
+
const decoder = new TextDecoder();
|
|
3320
|
+
let text = "";
|
|
3321
|
+
let bytes = 0;
|
|
3322
|
+
const cancel = () => {
|
|
3323
|
+
void reader.cancel().catch(() => {
|
|
3324
|
+
});
|
|
3325
|
+
};
|
|
3326
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
3327
|
+
try {
|
|
3328
|
+
while (true) {
|
|
3329
|
+
signal.throwIfAborted();
|
|
3330
|
+
const { done, value } = await reader.read();
|
|
3331
|
+
signal.throwIfAborted();
|
|
3332
|
+
if (done) break;
|
|
3333
|
+
bytes += value.byteLength;
|
|
3334
|
+
if (bytes > OAUTH_MAX_RESPONSE_BYTES) throw new Error(`${label} exceeded the OAuth response size limit`);
|
|
3335
|
+
text += decoder.decode(value, { stream: true });
|
|
3336
|
+
}
|
|
3337
|
+
text += decoder.decode();
|
|
3338
|
+
} finally {
|
|
3339
|
+
signal.removeEventListener("abort", cancel);
|
|
3340
|
+
cancel();
|
|
3341
|
+
reader.releaseLock();
|
|
3342
|
+
}
|
|
3343
|
+
try {
|
|
3344
|
+
return JSON.parse(text);
|
|
3345
|
+
} catch {
|
|
3346
|
+
throw new Error(`${label} returned invalid JSON`);
|
|
3347
|
+
}
|
|
3301
3348
|
}
|
|
3302
3349
|
async function fetchJson2(url2, init) {
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
throw new Error(`${
|
|
3350
|
+
return withResponse(url2, init, async (response, signal) => {
|
|
3351
|
+
const label = `${init.method ?? "GET"} ${url2}`;
|
|
3352
|
+
if (!response.ok) throw new Error(`${label} failed: ${response.status}`);
|
|
3353
|
+
return readJson(response, signal, label);
|
|
3354
|
+
});
|
|
3355
|
+
}
|
|
3356
|
+
async function abortable(work, signal) {
|
|
3357
|
+
if (!signal) return work;
|
|
3358
|
+
let onAbort;
|
|
3359
|
+
const aborted = new Promise((_2, reject) => {
|
|
3360
|
+
onAbort = () => reject(signal.reason);
|
|
3361
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
3362
|
+
if (signal.aborted) onAbort();
|
|
3363
|
+
});
|
|
3364
|
+
try {
|
|
3365
|
+
return await Promise.race([work, aborted]);
|
|
3366
|
+
} finally {
|
|
3367
|
+
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
3306
3368
|
}
|
|
3307
|
-
return res.json();
|
|
3308
3369
|
}
|
|
3309
3370
|
function authorizationServerMetadata(value, issuer, requireExactIssuer) {
|
|
3310
3371
|
if (!value || typeof value !== "object") throw new Error(`Authorization server metadata for ${issuer} is invalid`);
|
|
@@ -3330,21 +3391,28 @@ function authorizationServerMetadata(value, issuer, requireExactIssuer) {
|
|
|
3330
3391
|
if (metadata.registration_endpoint) validatedHttpsUrl(metadata.registration_endpoint, "Registration endpoint");
|
|
3331
3392
|
return metadata;
|
|
3332
3393
|
}
|
|
3333
|
-
async function jsonMetadata(response, url2) {
|
|
3394
|
+
async function jsonMetadata(response, url2, signal) {
|
|
3334
3395
|
if (response.status !== 200) throw new Error(`GET ${url2} failed: ${response.status}`);
|
|
3335
3396
|
const contentType = response.headers.get("content-type")?.split(";", 1)[0].trim().toLowerCase();
|
|
3336
3397
|
if (contentType !== "application/json") throw new Error(`GET ${url2} did not return application/json`);
|
|
3337
|
-
return response
|
|
3398
|
+
return readJson(response, signal, `GET ${url2}`);
|
|
3338
3399
|
}
|
|
3339
|
-
async function discoverAuthorizationServer(issuer, requireExactIssuer) {
|
|
3400
|
+
async function discoverAuthorizationServer(issuer, requireExactIssuer, signal) {
|
|
3340
3401
|
const candidates = authorizationServerMetadataUrls(issuer);
|
|
3341
3402
|
let lastError;
|
|
3342
3403
|
for (const candidate of candidates) {
|
|
3343
3404
|
try {
|
|
3344
|
-
const
|
|
3345
|
-
|
|
3346
|
-
|
|
3405
|
+
const metadata = await withResponse(candidate, { signal }, async (response, requestSignal) => {
|
|
3406
|
+
if (response.status === 404) return void 0;
|
|
3407
|
+
return authorizationServerMetadata(
|
|
3408
|
+
await jsonMetadata(response, candidate, requestSignal),
|
|
3409
|
+
issuer,
|
|
3410
|
+
requireExactIssuer
|
|
3411
|
+
);
|
|
3412
|
+
});
|
|
3413
|
+
if (metadata) return metadata;
|
|
3347
3414
|
} catch (error) {
|
|
3415
|
+
signal?.throwIfAborted();
|
|
3348
3416
|
lastError = error;
|
|
3349
3417
|
}
|
|
3350
3418
|
}
|
|
@@ -3370,6 +3438,9 @@ function resourceMetadata(value, resource) {
|
|
|
3370
3438
|
throw new Error("Protected-resource metadata has an invalid authorization server");
|
|
3371
3439
|
validatedHttpsUrl(issuer, "Authorization server issuer");
|
|
3372
3440
|
}
|
|
3441
|
+
if (metadata.scopes_supported !== void 0 && (!Array.isArray(metadata.scopes_supported) || metadata.scopes_supported.some((scope) => typeof scope !== "string"))) {
|
|
3442
|
+
throw new Error("Protected-resource metadata has invalid scopes_supported");
|
|
3443
|
+
}
|
|
3373
3444
|
return metadata;
|
|
3374
3445
|
}
|
|
3375
3446
|
function resourceMetadataUrl(resource) {
|
|
@@ -3381,34 +3452,39 @@ function headerResourceMetadata(value) {
|
|
|
3381
3452
|
if (!match2) return void 0;
|
|
3382
3453
|
return match2[1].replace(/\\(.)/g, "$1");
|
|
3383
3454
|
}
|
|
3384
|
-
async function tryProtectedResourceMetadata(url2) {
|
|
3455
|
+
async function tryProtectedResourceMetadata(url2, signal) {
|
|
3385
3456
|
const resource = validatedHttpsUrl(url2, "MCP endpoint");
|
|
3386
3457
|
let headerUrl;
|
|
3387
3458
|
try {
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3459
|
+
headerUrl = await withResponse(
|
|
3460
|
+
resource.toString(),
|
|
3461
|
+
{ signal },
|
|
3462
|
+
async (response) => headerResourceMetadata(response.headers.get("www-authenticate"))
|
|
3463
|
+
);
|
|
3391
3464
|
} catch {
|
|
3465
|
+
signal?.throwIfAborted();
|
|
3392
3466
|
}
|
|
3393
3467
|
const candidate = headerUrl ? validatedHttpsUrl(headerUrl, "resource_metadata").toString() : resourceMetadataUrl(resource);
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3468
|
+
return withResponse(candidate, { signal }, async (response, requestSignal) => {
|
|
3469
|
+
if (response.status === 404 && !headerUrl) return void 0;
|
|
3470
|
+
return resourceMetadata(await jsonMetadata(response, candidate, requestSignal), canonicalResource(resource));
|
|
3471
|
+
});
|
|
3397
3472
|
}
|
|
3398
|
-
async function discover(url2) {
|
|
3399
|
-
const protectedResource = await tryProtectedResourceMetadata(url2);
|
|
3473
|
+
async function discover(url2, signal) {
|
|
3474
|
+
const protectedResource = await tryProtectedResourceMetadata(url2, signal);
|
|
3400
3475
|
if (protectedResource) {
|
|
3401
3476
|
const issuer2 = protectedResource.authorization_servers[0];
|
|
3402
3477
|
return {
|
|
3403
|
-
metadata: await discoverAuthorizationServer(issuer2, true),
|
|
3478
|
+
metadata: await discoverAuthorizationServer(issuer2, true, signal),
|
|
3479
|
+
scopes: protectedResource.scopes_supported,
|
|
3404
3480
|
resource: protectedResource.resource,
|
|
3405
3481
|
issuer: issuer2
|
|
3406
3482
|
};
|
|
3407
3483
|
}
|
|
3408
3484
|
const issuer = validatedHttpsUrl(url2, "MCP endpoint").origin;
|
|
3409
|
-
return { metadata: await discoverAuthorizationServer(issuer, false) };
|
|
3485
|
+
return { metadata: await discoverAuthorizationServer(issuer, false, signal) };
|
|
3410
3486
|
}
|
|
3411
|
-
async function registerClient(registrationEndpoint, label) {
|
|
3487
|
+
async function registerClient(registrationEndpoint, label, signal) {
|
|
3412
3488
|
validatedHttpsUrl(registrationEndpoint, "Registration endpoint");
|
|
3413
3489
|
const body = {
|
|
3414
3490
|
client_name: label,
|
|
@@ -3420,7 +3496,8 @@ async function registerClient(registrationEndpoint, label) {
|
|
|
3420
3496
|
const data = await fetchJson2(registrationEndpoint, {
|
|
3421
3497
|
method: "POST",
|
|
3422
3498
|
headers: { "Content-Type": "application/json" },
|
|
3423
|
-
body: JSON.stringify(body)
|
|
3499
|
+
body: JSON.stringify(body),
|
|
3500
|
+
signal
|
|
3424
3501
|
});
|
|
3425
3502
|
if (typeof data.client_id !== "string" || !data.client_id) {
|
|
3426
3503
|
throw new Error(`Dynamic client registration at ${registrationEndpoint} returned no client_id`);
|
|
@@ -3428,7 +3505,6 @@ async function registerClient(registrationEndpoint, label) {
|
|
|
3428
3505
|
return data.client_id;
|
|
3429
3506
|
}
|
|
3430
3507
|
async function startCallbackServer2(label) {
|
|
3431
|
-
const { createServer: createServer3 } = await import("node:http");
|
|
3432
3508
|
let settle;
|
|
3433
3509
|
const waitPromise = new Promise((resolve26) => {
|
|
3434
3510
|
let settled = false;
|
|
@@ -3465,7 +3541,7 @@ async function startCallbackServer2(label) {
|
|
|
3465
3541
|
};
|
|
3466
3542
|
let lastError;
|
|
3467
3543
|
for (const port of CALLBACK_PORTS) {
|
|
3468
|
-
const server =
|
|
3544
|
+
const server = createServer(handler);
|
|
3469
3545
|
let bindErr;
|
|
3470
3546
|
server.on("error", (err) => bindErr?.(err));
|
|
3471
3547
|
try {
|
|
@@ -3516,23 +3592,22 @@ function parseRedirectInput(input, expectedState) {
|
|
|
3516
3592
|
}
|
|
3517
3593
|
return { code, state: state ?? expectedState };
|
|
3518
3594
|
}
|
|
3519
|
-
async function exchangeToken(tokenEndpoint, params) {
|
|
3595
|
+
async function exchangeToken(tokenEndpoint, params, signal) {
|
|
3520
3596
|
validatedHttpsUrl(tokenEndpoint, "Token endpoint");
|
|
3521
|
-
const
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
}
|
|
3597
|
+
const token = await withResponse(
|
|
3598
|
+
tokenEndpoint,
|
|
3599
|
+
{
|
|
3600
|
+
method: "POST",
|
|
3601
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
3602
|
+
body: new URLSearchParams(params).toString(),
|
|
3603
|
+
signal
|
|
3604
|
+
},
|
|
3605
|
+
async (response, requestSignal) => {
|
|
3606
|
+
const label = `Token request to ${tokenEndpoint}`;
|
|
3607
|
+
if (!response.ok) throw new Error(`${label} failed: ${response.status}`);
|
|
3608
|
+
return readJson(response, requestSignal, label);
|
|
3609
|
+
}
|
|
3610
|
+
);
|
|
3536
3611
|
if (!token || typeof token !== "object" || typeof token.access_token !== "string") {
|
|
3537
3612
|
throw new Error(`Token request to ${tokenEndpoint} returned no access_token`);
|
|
3538
3613
|
}
|
|
@@ -3562,7 +3637,7 @@ function toCredentials(token, tokenEndpoint, clientId, endpoint, resource, issue
|
|
|
3562
3637
|
function createMcpOAuthProvider(config) {
|
|
3563
3638
|
const label = config.label ?? config.server;
|
|
3564
3639
|
async function login(callbacks) {
|
|
3565
|
-
const discovery = await discover(config.url);
|
|
3640
|
+
const discovery = await discover(config.url, callbacks.signal);
|
|
3566
3641
|
const { metadata: meta } = discovery;
|
|
3567
3642
|
callbacks.onProgress?.(`Discovered ${discovery.issuer ?? meta.issuer}`);
|
|
3568
3643
|
let clientId = config.clientId;
|
|
@@ -3573,13 +3648,15 @@ function createMcpOAuthProvider(config) {
|
|
|
3573
3648
|
);
|
|
3574
3649
|
}
|
|
3575
3650
|
callbacks.onProgress?.("Registering OAuth client\u2026");
|
|
3576
|
-
clientId = await registerClient(meta.registration_endpoint, `
|
|
3651
|
+
clientId = await registerClient(meta.registration_endpoint, `Base Context (${label})`, callbacks.signal);
|
|
3577
3652
|
}
|
|
3578
3653
|
const { verifier, challenge } = await generatePKCE();
|
|
3579
3654
|
const state = randomState();
|
|
3580
|
-
const scope = config.scopes ??
|
|
3655
|
+
const scope = config.scopes ?? discovery.scopes?.join(" ");
|
|
3656
|
+
callbacks.signal?.throwIfAborted();
|
|
3581
3657
|
const cb = await startCallbackServer2(label);
|
|
3582
3658
|
try {
|
|
3659
|
+
callbacks.signal?.throwIfAborted();
|
|
3583
3660
|
const authParams = new URLSearchParams({
|
|
3584
3661
|
client_id: clientId,
|
|
3585
3662
|
response_type: "code",
|
|
@@ -3596,6 +3673,7 @@ function createMcpOAuthProvider(config) {
|
|
|
3596
3673
|
url: authorizationUrl.toString(),
|
|
3597
3674
|
instructions: "Complete login in your browser. If the browser is on another machine, paste the final redirect URL here."
|
|
3598
3675
|
});
|
|
3676
|
+
callbacks.signal?.throwIfAborted();
|
|
3599
3677
|
let result;
|
|
3600
3678
|
let manualCancelled = false;
|
|
3601
3679
|
let manualError;
|
|
@@ -3614,16 +3692,19 @@ function createMcpOAuthProvider(config) {
|
|
|
3614
3692
|
cb.cancel();
|
|
3615
3693
|
return null;
|
|
3616
3694
|
});
|
|
3617
|
-
const fromCallback = await cb.waitForCode();
|
|
3618
|
-
result = fromCallback ?? await manual;
|
|
3695
|
+
const fromCallback = await abortable(cb.waitForCode(), callbacks.signal);
|
|
3696
|
+
result = fromCallback ?? await abortable(manual, callbacks.signal);
|
|
3619
3697
|
if (!result && manualError) throw manualError;
|
|
3620
3698
|
} else {
|
|
3621
|
-
result = await cb.waitForCode();
|
|
3699
|
+
result = await abortable(cb.waitForCode(), callbacks.signal);
|
|
3622
3700
|
if (!result) {
|
|
3623
|
-
const input = await
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3701
|
+
const input = await abortable(
|
|
3702
|
+
callbacks.onPrompt({
|
|
3703
|
+
message: "Paste the authorization code or full redirect URL:",
|
|
3704
|
+
placeholder: cb.redirectUri
|
|
3705
|
+
}),
|
|
3706
|
+
callbacks.signal
|
|
3707
|
+
);
|
|
3627
3708
|
result = parseRedirectInput(input, state);
|
|
3628
3709
|
}
|
|
3629
3710
|
}
|
|
@@ -3634,16 +3715,21 @@ function createMcpOAuthProvider(config) {
|
|
|
3634
3715
|
throw new Error("OAuth state mismatch");
|
|
3635
3716
|
}
|
|
3636
3717
|
callbacks.onProgress?.("Exchanging authorization code for tokens\u2026");
|
|
3637
|
-
const token = await exchangeToken(
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3718
|
+
const token = await exchangeToken(
|
|
3719
|
+
meta.token_endpoint,
|
|
3720
|
+
{
|
|
3721
|
+
grant_type: "authorization_code",
|
|
3722
|
+
code: result.code,
|
|
3723
|
+
redirect_uri: cb.redirectUri,
|
|
3724
|
+
client_id: clientId,
|
|
3725
|
+
code_verifier: verifier,
|
|
3726
|
+
...discovery.resource ? { resource: discovery.resource } : {}
|
|
3727
|
+
},
|
|
3728
|
+
callbacks.signal
|
|
3729
|
+
);
|
|
3645
3730
|
return toCredentials(token, meta.token_endpoint, clientId, config.url, discovery.resource, discovery.issuer);
|
|
3646
3731
|
} finally {
|
|
3732
|
+
cb.cancel();
|
|
3647
3733
|
cb.server.close();
|
|
3648
3734
|
}
|
|
3649
3735
|
}
|
|
@@ -4638,7 +4724,7 @@ ${loadError}`));
|
|
|
4638
4724
|
import { resolve as resolve11 } from "node:path";
|
|
4639
4725
|
|
|
4640
4726
|
// dist/core/auth-storage.js
|
|
4641
|
-
import { createHash } from "node:crypto";
|
|
4727
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
4642
4728
|
|
|
4643
4729
|
// ../ai/src/oauth.ts
|
|
4644
4730
|
var oauth_exports = {};
|
|
@@ -5143,11 +5229,18 @@ var AuthStorage = class _AuthStorage {
|
|
|
5143
5229
|
this.staleAuthSources.set(provider, next);
|
|
5144
5230
|
}
|
|
5145
5231
|
}
|
|
5232
|
+
parseStorageState(content) {
|
|
5233
|
+
const { __base_context_login_attempts: loginAttempts = {}, ...credentials } = JSON.parse(content || "{}");
|
|
5234
|
+
return { credentials, loginAttempts };
|
|
5235
|
+
}
|
|
5236
|
+
serializeStorageState({ credentials, loginAttempts }) {
|
|
5237
|
+
return JSON.stringify({
|
|
5238
|
+
...credentials,
|
|
5239
|
+
...Object.keys(loginAttempts).length > 0 ? { __base_context_login_attempts: loginAttempts } : {}
|
|
5240
|
+
}, null, 2);
|
|
5241
|
+
}
|
|
5146
5242
|
parseStorageData(content) {
|
|
5147
|
-
|
|
5148
|
-
return {};
|
|
5149
|
-
}
|
|
5150
|
-
return JSON.parse(content);
|
|
5243
|
+
return this.parseStorageState(content).credentials;
|
|
5151
5244
|
}
|
|
5152
5245
|
/**
|
|
5153
5246
|
* Reload credentials from storage.
|
|
@@ -5172,14 +5265,14 @@ var AuthStorage = class _AuthStorage {
|
|
|
5172
5265
|
}
|
|
5173
5266
|
try {
|
|
5174
5267
|
this.storage.withLock((current) => {
|
|
5175
|
-
const
|
|
5176
|
-
|
|
5268
|
+
const state = this.parseStorageState(current);
|
|
5269
|
+
delete state.loginAttempts[provider];
|
|
5177
5270
|
if (credential) {
|
|
5178
|
-
|
|
5271
|
+
state.credentials[provider] = credential;
|
|
5179
5272
|
} else {
|
|
5180
|
-
delete
|
|
5273
|
+
delete state.credentials[provider];
|
|
5181
5274
|
}
|
|
5182
|
-
return { result: void 0, next:
|
|
5275
|
+
return { result: void 0, next: this.serializeStorageState(state) };
|
|
5183
5276
|
});
|
|
5184
5277
|
} catch (error) {
|
|
5185
5278
|
this.recordError(error);
|
|
@@ -5218,12 +5311,12 @@ var AuthStorage = class _AuthStorage {
|
|
|
5218
5311
|
removeVerified(provider) {
|
|
5219
5312
|
this.assertWritableStorage();
|
|
5220
5313
|
this.storage.withLock((current) => {
|
|
5221
|
-
const
|
|
5222
|
-
if (!(provider in
|
|
5314
|
+
const state = this.parseStorageState(current);
|
|
5315
|
+
if (!(provider in state.credentials) && !(provider in state.loginAttempts))
|
|
5223
5316
|
return { result: void 0 };
|
|
5224
|
-
|
|
5225
|
-
delete
|
|
5226
|
-
return { result: void 0, next:
|
|
5317
|
+
delete state.credentials[provider];
|
|
5318
|
+
delete state.loginAttempts[provider];
|
|
5319
|
+
return { result: void 0, next: this.serializeStorageState(state) };
|
|
5227
5320
|
});
|
|
5228
5321
|
delete this.data[provider];
|
|
5229
5322
|
this.clearStaleAuthSource(provider, "stored");
|
|
@@ -5277,8 +5370,55 @@ var AuthStorage = class _AuthStorage {
|
|
|
5277
5370
|
if (!provider) {
|
|
5278
5371
|
throw new Error(`Unknown OAuth provider: ${providerId}`);
|
|
5279
5372
|
}
|
|
5280
|
-
|
|
5281
|
-
|
|
5373
|
+
await this.setFromLogin(providerId, async () => ({ type: "oauth", ...await provider.login(callbacks) }), callbacks.signal);
|
|
5374
|
+
}
|
|
5375
|
+
/** Collect credentials without holding the lock, then commit only for the current login. */
|
|
5376
|
+
async setFromLogin(providerId, collectCredential, signal) {
|
|
5377
|
+
this.assertWritableStorage();
|
|
5378
|
+
if (signal?.aborted)
|
|
5379
|
+
throw new Error("Login cancelled");
|
|
5380
|
+
const attemptId = randomUUID();
|
|
5381
|
+
this.storage.withLock((current) => {
|
|
5382
|
+
const state = this.parseStorageState(current);
|
|
5383
|
+
state.loginAttempts[providerId] = attemptId;
|
|
5384
|
+
return { result: void 0, next: this.serializeStorageState(state) };
|
|
5385
|
+
});
|
|
5386
|
+
const releaseAttempt = () => {
|
|
5387
|
+
try {
|
|
5388
|
+
this.storage.withLock((current) => {
|
|
5389
|
+
const state = this.parseStorageState(current);
|
|
5390
|
+
if (state.loginAttempts[providerId] !== attemptId)
|
|
5391
|
+
return { result: void 0 };
|
|
5392
|
+
delete state.loginAttempts[providerId];
|
|
5393
|
+
return { result: void 0, next: this.serializeStorageState(state) };
|
|
5394
|
+
});
|
|
5395
|
+
} catch (error) {
|
|
5396
|
+
this.recordError(error);
|
|
5397
|
+
}
|
|
5398
|
+
};
|
|
5399
|
+
signal?.addEventListener("abort", releaseAttempt, { once: true });
|
|
5400
|
+
try {
|
|
5401
|
+
const credential = await collectCredential();
|
|
5402
|
+
if (signal?.aborted)
|
|
5403
|
+
throw new Error("Login cancelled");
|
|
5404
|
+
const data = this.storage.withLock((current) => {
|
|
5405
|
+
const state = this.parseStorageState(current);
|
|
5406
|
+
if (state.loginAttempts[providerId] !== attemptId) {
|
|
5407
|
+
throw new Error("Login cancelled: credentials changed or login was superseded");
|
|
5408
|
+
}
|
|
5409
|
+
delete state.loginAttempts[providerId];
|
|
5410
|
+
state.credentials[providerId] = credential;
|
|
5411
|
+
return { result: state.credentials, next: this.serializeStorageState(state) };
|
|
5412
|
+
});
|
|
5413
|
+
this.data = data;
|
|
5414
|
+
this.loadError = null;
|
|
5415
|
+
this.clearStaleAuthSource(providerId, "stored");
|
|
5416
|
+
} catch (error) {
|
|
5417
|
+
releaseAttempt();
|
|
5418
|
+
throw error;
|
|
5419
|
+
} finally {
|
|
5420
|
+
signal?.removeEventListener("abort", releaseAttempt);
|
|
5421
|
+
}
|
|
5282
5422
|
}
|
|
5283
5423
|
/**
|
|
5284
5424
|
* Logout from a provider.
|
|
@@ -5299,7 +5439,8 @@ var AuthStorage = class _AuthStorage {
|
|
|
5299
5439
|
return null;
|
|
5300
5440
|
}
|
|
5301
5441
|
const result = await this.storage.withLockAsync(async (current) => {
|
|
5302
|
-
const
|
|
5442
|
+
const state = this.parseStorageState(current);
|
|
5443
|
+
const currentData = state.credentials;
|
|
5303
5444
|
this.data = currentData;
|
|
5304
5445
|
this.loadError = null;
|
|
5305
5446
|
const cred = currentData[providerId];
|
|
@@ -5325,7 +5466,7 @@ var AuthStorage = class _AuthStorage {
|
|
|
5325
5466
|
};
|
|
5326
5467
|
this.data = merged;
|
|
5327
5468
|
this.loadError = null;
|
|
5328
|
-
return { result: refreshed, next:
|
|
5469
|
+
return { result: refreshed, next: this.serializeStorageState({ ...state, credentials: merged }) };
|
|
5329
5470
|
});
|
|
5330
5471
|
return result;
|
|
5331
5472
|
}
|
|
@@ -7080,7 +7221,7 @@ async function selectConfig(options) {
|
|
|
7080
7221
|
// dist/cli/daemon-update-restart.js
|
|
7081
7222
|
var import_proper_lockfile3 = __toESM(require_proper_lockfile(), 1);
|
|
7082
7223
|
import { spawn } from "node:child_process";
|
|
7083
|
-
import { createHash as createHash2, randomUUID } from "node:crypto";
|
|
7224
|
+
import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
|
|
7084
7225
|
import { mkdirSync as mkdirSync3, readFileSync as readFileSync3, renameSync as renameSync2, rmSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
7085
7226
|
import { resolve as resolve2 } from "node:path";
|
|
7086
7227
|
var DAEMON_UPDATE_RESTART_COORDINATOR_FLAG = "--internal-update-restart-coordinator";
|
|
@@ -7141,7 +7282,7 @@ function socketKey(socketPath) {
|
|
|
7141
7282
|
return createHash2("sha256").update(normalizeSocketPath(socketPath)).digest("hex");
|
|
7142
7283
|
}
|
|
7143
7284
|
function writeJsonAtomically(path6, value) {
|
|
7144
|
-
const tempPath = `${path6}.${process.pid}.${
|
|
7285
|
+
const tempPath = `${path6}.${process.pid}.${randomUUID2()}.tmp`;
|
|
7145
7286
|
try {
|
|
7146
7287
|
writeFileSync3(tempPath, `${JSON.stringify(value, null, 2)}
|
|
7147
7288
|
`, { mode: 384 });
|
|
@@ -7375,7 +7516,7 @@ var DaemonUpdateRestartCoordinatorAlreadyRunningError = class extends Error {
|
|
|
7375
7516
|
async function acquireDaemonUpdateRestartCoordinator(options) {
|
|
7376
7517
|
const registryDir = options.registryDir ?? defaultCoordinatorRegistryDir();
|
|
7377
7518
|
const path6 = coordinatorRecordPath(registryDir, options.socketPath);
|
|
7378
|
-
const token =
|
|
7519
|
+
const token = randomUUID2();
|
|
7379
7520
|
const processStartId = getProcessStartId(process.pid);
|
|
7380
7521
|
const record3 = {
|
|
7381
7522
|
version: 1,
|
|
@@ -7461,7 +7602,7 @@ function selectedUpdateInstallation() {
|
|
|
7461
7602
|
return ownedVersion(owned.root, selected.active);
|
|
7462
7603
|
}
|
|
7463
7604
|
async function launchDaemonUpdateRestartCoordinator(options) {
|
|
7464
|
-
const requestId =
|
|
7605
|
+
const requestId = randomUUID2();
|
|
7465
7606
|
const agentDir = resolve2(options.agentDir);
|
|
7466
7607
|
const socketPath = resolveDaemonUpdateRestartSocketPath(options.socketPath);
|
|
7467
7608
|
const statusPath = createStatusPath(agentDir, socketPath, requestId);
|
|
@@ -14345,7 +14486,7 @@ var DefaultPackageManager = class {
|
|
|
14345
14486
|
|
|
14346
14487
|
// dist/modes/daemon/daemon-supervisor-ownership.js
|
|
14347
14488
|
var import_proper_lockfile4 = __toESM(require_proper_lockfile(), 1);
|
|
14348
|
-
import { createHash as createHash4, randomUUID as
|
|
14489
|
+
import { createHash as createHash4, randomUUID as randomUUID3 } from "node:crypto";
|
|
14349
14490
|
import { existsSync as existsSync4, mkdirSync as mkdirSync5, readdirSync as readdirSync2, readFileSync as readFileSync5, realpathSync, renameSync as renameSync3, rmSync as rmSync3, statSync as statSync2, writeFileSync as writeFileSync5 } from "node:fs";
|
|
14350
14491
|
import { basename as basename3, dirname as dirname6, join as join7, resolve as resolve4 } from "node:path";
|
|
14351
14492
|
var DAEMON_SUPERVISOR_REGISTRY_DIR_ENV = "BASE_CONTEXT_INTERNAL_DAEMON_SUPERVISOR_REGISTRY_DIR";
|
|
@@ -14413,17 +14554,15 @@ var RenewableRegistryRecord = class {
|
|
|
14413
14554
|
await this.refreshPromise;
|
|
14414
14555
|
}
|
|
14415
14556
|
async performRenew() {
|
|
14416
|
-
|
|
14417
|
-
|
|
14418
|
-
|
|
14419
|
-
|
|
14420
|
-
|
|
14421
|
-
|
|
14422
|
-
});
|
|
14423
|
-
} catch (error) {
|
|
14557
|
+
const held = await withDaemonSupervisorRegistryGuard(this.registryDir, () => {
|
|
14558
|
+
if (this.stopped || this.lost)
|
|
14559
|
+
return false;
|
|
14560
|
+
return this.renewUnderGuard();
|
|
14561
|
+
});
|
|
14562
|
+
if (!held) {
|
|
14424
14563
|
this.lost = true;
|
|
14425
14564
|
clearInterval(this.refreshTimer);
|
|
14426
|
-
throw
|
|
14565
|
+
throw this.createLostError();
|
|
14427
14566
|
}
|
|
14428
14567
|
}
|
|
14429
14568
|
async stop() {
|
|
@@ -14490,7 +14629,7 @@ var DaemonSupervisorOwnership = class {
|
|
|
14490
14629
|
if (!current || current.token !== this.record.token) {
|
|
14491
14630
|
return;
|
|
14492
14631
|
}
|
|
14493
|
-
releasedDirectory = `${this.ownerDirectory}.released-${
|
|
14632
|
+
releasedDirectory = `${this.ownerDirectory}.released-${randomUUID3()}`;
|
|
14494
14633
|
renameSync3(this.ownerDirectory, releasedDirectory);
|
|
14495
14634
|
});
|
|
14496
14635
|
this.released = true;
|
|
@@ -14520,13 +14659,14 @@ var DaemonShutdownAdmission = class {
|
|
|
14520
14659
|
renewUnderGuard() {
|
|
14521
14660
|
const path6 = shutdownAdmissionPath(this.registryDir);
|
|
14522
14661
|
const current = readShutdownAdmission(path6);
|
|
14523
|
-
if (!current || current.token !== this.record.token || current.pid !== this.record.pid || current.processStartId !== this.record.processStartId ||
|
|
14524
|
-
|
|
14662
|
+
if (!current || current.token !== this.record.token || current.pid !== this.record.pid || current.processStartId !== this.record.processStartId || !matchesExactProcessIdentity(this.record)) {
|
|
14663
|
+
return false;
|
|
14525
14664
|
}
|
|
14526
14665
|
const now = Date.now();
|
|
14527
14666
|
this.record.updatedAt = new Date(now).toISOString();
|
|
14528
14667
|
this.record.expiresAt = new Date(now + SHUTDOWN_ADMISSION_LEASE_MS).toISOString();
|
|
14529
14668
|
writeJsonAtomically2(path6, this.record);
|
|
14669
|
+
return true;
|
|
14530
14670
|
}
|
|
14531
14671
|
async release() {
|
|
14532
14672
|
if (this.released) {
|
|
@@ -14636,7 +14776,7 @@ async function mutateDaemonSupervisorOwner(generation, expectedToken, mutation,
|
|
|
14636
14776
|
async function acquireDaemonSupervisorOwnership(options) {
|
|
14637
14777
|
const registryDir = options.registryDir ?? defaultDaemonSupervisorRegistryDir();
|
|
14638
14778
|
mkdirSync5(registryDir, { recursive: true, mode: 448 });
|
|
14639
|
-
const token =
|
|
14779
|
+
const token = randomUUID3();
|
|
14640
14780
|
const processStartId = getProcessStartId(process.pid);
|
|
14641
14781
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
14642
14782
|
const record3 = {
|
|
@@ -14677,7 +14817,7 @@ async function acquireDaemonSupervisorOwnership(options) {
|
|
|
14677
14817
|
if (isProcessIdentityAlive2(owner)) {
|
|
14678
14818
|
throw new DaemonSupervisorAlreadyRunningError(owner);
|
|
14679
14819
|
}
|
|
14680
|
-
const staleDirectory = `${directory}.stale-${
|
|
14820
|
+
const staleDirectory = `${directory}.stale-${randomUUID3()}`;
|
|
14681
14821
|
renameSync3(directory, staleDirectory);
|
|
14682
14822
|
staleDirectories.push(staleDirectory);
|
|
14683
14823
|
}
|
|
@@ -14740,7 +14880,7 @@ async function acquireDaemonShutdownAdmission() {
|
|
|
14740
14880
|
const now = Date.now();
|
|
14741
14881
|
acquired = {
|
|
14742
14882
|
version: OWNER_VERSION,
|
|
14743
|
-
token:
|
|
14883
|
+
token: randomUUID3(),
|
|
14744
14884
|
pid: process.pid,
|
|
14745
14885
|
...processStartId ? { processStartId } : {},
|
|
14746
14886
|
createdAt: new Date(now).toISOString(),
|
|
@@ -14757,7 +14897,7 @@ async function acquireDaemonShutdownAdmission() {
|
|
|
14757
14897
|
}
|
|
14758
14898
|
async function isDaemonShutdownAdmissionActive() {
|
|
14759
14899
|
const registryDir = defaultDaemonSupervisorRegistryDir();
|
|
14760
|
-
return withDaemonSupervisorRegistryGuard(registryDir, () =>
|
|
14900
|
+
return withDaemonSupervisorRegistryGuard(registryDir, () => shutdownAdmissionIsActive(readShutdownAdmission(shutdownAdmissionPath(registryDir))));
|
|
14761
14901
|
}
|
|
14762
14902
|
async function persistDaemonStartupFenceFromOwner(socketPath, hello, registryDir, legacyRegistryDir = void 0) {
|
|
14763
14903
|
registryDir ??= defaultDaemonSupervisorRegistryDir();
|
|
@@ -14795,7 +14935,7 @@ async function persistDaemonStartupFenceFromOwner(socketPath, hello, registryDir
|
|
|
14795
14935
|
}
|
|
14796
14936
|
const record3 = {
|
|
14797
14937
|
version: OWNER_VERSION,
|
|
14798
|
-
token:
|
|
14938
|
+
token: randomUUID3(),
|
|
14799
14939
|
ownerToken: owner.token,
|
|
14800
14940
|
pid: owner.pid,
|
|
14801
14941
|
processStartId: owner.processStartId,
|
|
@@ -14923,7 +15063,7 @@ function readOwnerRecordForScope(directory, isRelevant) {
|
|
|
14923
15063
|
const scope = readOwnerScope(directory);
|
|
14924
15064
|
const entries2 = !scope ? readdirSync2(directory) : [];
|
|
14925
15065
|
if (!scope && !entries2.includes("owner.json") && !entries2.includes("scope.json")) {
|
|
14926
|
-
const abandonedDirectory = `${directory}.abandoned-${
|
|
15066
|
+
const abandonedDirectory = `${directory}.abandoned-${randomUUID3()}`;
|
|
14927
15067
|
renameSync3(directory, abandonedDirectory);
|
|
14928
15068
|
rmSync3(abandonedDirectory, { recursive: true, force: true });
|
|
14929
15069
|
return void 0;
|
|
@@ -15000,13 +15140,16 @@ function readStartupFence(path6) {
|
|
|
15000
15140
|
throw error;
|
|
15001
15141
|
}
|
|
15002
15142
|
}
|
|
15143
|
+
function shutdownAdmissionIsActive(admission) {
|
|
15144
|
+
return admission !== void 0 && Date.parse(admission.expiresAt) > Date.now() && isProcessIdentityAlive2(admission);
|
|
15145
|
+
}
|
|
15003
15146
|
function readActiveShutdownAdmission(registryDir) {
|
|
15004
15147
|
const path6 = shutdownAdmissionPath(registryDir);
|
|
15005
15148
|
const admission = readShutdownAdmission(path6);
|
|
15006
15149
|
if (!admission) {
|
|
15007
15150
|
return void 0;
|
|
15008
15151
|
}
|
|
15009
|
-
if (
|
|
15152
|
+
if (shutdownAdmissionIsActive(admission)) {
|
|
15010
15153
|
return admission;
|
|
15011
15154
|
}
|
|
15012
15155
|
rmSync3(path6, { force: true });
|
|
@@ -15031,7 +15174,7 @@ function readShutdownAdmission(path6) {
|
|
|
15031
15174
|
}
|
|
15032
15175
|
}
|
|
15033
15176
|
function writeJsonAtomically2(path6, value) {
|
|
15034
|
-
const tempPath = `${path6}.${process.pid}.${
|
|
15177
|
+
const tempPath = `${path6}.${process.pid}.${randomUUID3()}.tmp`;
|
|
15035
15178
|
try {
|
|
15036
15179
|
writeFileSync5(tempPath, `${JSON.stringify(value, null, 2)}
|
|
15037
15180
|
`, { mode: 384 });
|
|
@@ -15053,7 +15196,7 @@ function delay2(ms2) {
|
|
|
15053
15196
|
}
|
|
15054
15197
|
|
|
15055
15198
|
// dist/owned-install.js
|
|
15056
|
-
import { randomUUID as
|
|
15199
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
15057
15200
|
import { existsSync as existsSync5, mkdirSync as mkdirSync6, readdirSync as readdirSync3, readFileSync as readFileSync6, renameSync as renameSync4, statSync as statSync3, writeFileSync as writeFileSync6 } from "node:fs";
|
|
15058
15201
|
import { homedir as homedir3, tmpdir as tmpdir2 } from "node:os";
|
|
15059
15202
|
import { dirname as dirname7, join as join8, resolve as resolve5 } from "node:path";
|
|
@@ -15214,7 +15357,7 @@ async function installOwnedRelease(options) {
|
|
|
15214
15357
|
});
|
|
15215
15358
|
assertSelection(root, expected);
|
|
15216
15359
|
initializeRoot(root);
|
|
15217
|
-
const installation = ownedVersion(root, `${version}-${
|
|
15360
|
+
const installation = ownedVersion(root, `${version}-${randomUUID4()}`);
|
|
15218
15361
|
const directory = join8(root, "versions", installation.version);
|
|
15219
15362
|
mkdirSync6(directory, { recursive: true, mode: 448 });
|
|
15220
15363
|
writeFileSync6(join8(directory, "package.json"), `${JSON.stringify({
|
|
@@ -17979,6 +18122,7 @@ async function runShutdownAllConverging(json, force, assertAdmission) {
|
|
|
17979
18122
|
}
|
|
17980
18123
|
async function stopHiddenSupervisors(stopped, failed, handledPids, reportedFailures, assertAdmission) {
|
|
17981
18124
|
while (true) {
|
|
18125
|
+
await assertAdmission();
|
|
17982
18126
|
const listeners = scanListeningDaemons().filter((listener) => !isWorkerSocketPath(listener.socketPath));
|
|
17983
18127
|
const bySocket = /* @__PURE__ */ new Map();
|
|
17984
18128
|
for (const listener of listeners) {
|
|
@@ -20989,8 +21133,8 @@ var McpManager = class {
|
|
|
20989
21133
|
const { bearerTokenEnvVar } = integration.config;
|
|
20990
21134
|
if (!integration.usesOAuth && !bearerTokenEnvVar)
|
|
20991
21135
|
return true;
|
|
20992
|
-
if (bearerTokenEnvVar
|
|
20993
|
-
return
|
|
21136
|
+
if (bearerTokenEnvVar) {
|
|
21137
|
+
return Boolean(process.env[bearerTokenEnvVar]?.trim());
|
|
20994
21138
|
}
|
|
20995
21139
|
const providerId = this.providerId(integration.server);
|
|
20996
21140
|
const cred = this.authStorage.get(providerId);
|
|
@@ -24557,7 +24701,7 @@ function runMigrations(cwd) {
|
|
|
24557
24701
|
|
|
24558
24702
|
// dist/modes/daemon/daemon-catalog-process.js
|
|
24559
24703
|
import { spawn as spawn6 } from "node:child_process";
|
|
24560
|
-
import { randomUUID as
|
|
24704
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
24561
24705
|
import { existsSync as existsSync16 } from "node:fs";
|
|
24562
24706
|
import { createRequire as createRequire2 } from "node:module";
|
|
24563
24707
|
import { join as join19, sep as sep7 } from "node:path";
|
|
@@ -27434,7 +27578,7 @@ var DaemonCatalogClient = class {
|
|
|
27434
27578
|
if (options && "page" in options)
|
|
27435
27579
|
return this.request({
|
|
27436
27580
|
type: "request",
|
|
27437
|
-
id:
|
|
27581
|
+
id: randomUUID5(),
|
|
27438
27582
|
command: "list",
|
|
27439
27583
|
cwd,
|
|
27440
27584
|
sessionDir,
|
|
@@ -27443,16 +27587,16 @@ var DaemonCatalogClient = class {
|
|
|
27443
27587
|
ledgerSessionDir: options.ledgerSessionDir,
|
|
27444
27588
|
scope: options.scope
|
|
27445
27589
|
});
|
|
27446
|
-
const data = await this.request({ type: "request", id:
|
|
27590
|
+
const data = await this.request({ type: "request", id: randomUUID5(), command: "list", cwd, sessionDir }, options);
|
|
27447
27591
|
return data.sessions.map(deserializeSessionInfo);
|
|
27448
27592
|
}
|
|
27449
27593
|
async rename(sessionPath, name) {
|
|
27450
|
-
await this.request({ type: "request", id:
|
|
27594
|
+
await this.request({ type: "request", id: randomUUID5(), command: "rename", sessionPath, name });
|
|
27451
27595
|
}
|
|
27452
27596
|
async resolve(selector, cwd, sessionDir) {
|
|
27453
27597
|
const data = await this.request({
|
|
27454
27598
|
type: "request",
|
|
27455
|
-
id:
|
|
27599
|
+
id: randomUUID5(),
|
|
27456
27600
|
command: "resolve",
|
|
27457
27601
|
selector,
|
|
27458
27602
|
cwd,
|
|
@@ -27461,12 +27605,12 @@ var DaemonCatalogClient = class {
|
|
|
27461
27605
|
return data.sessionPath;
|
|
27462
27606
|
}
|
|
27463
27607
|
delete(sessionPath) {
|
|
27464
|
-
return this.request({ type: "request", id:
|
|
27608
|
+
return this.request({ type: "request", id: randomUUID5(), command: "delete", sessionPath });
|
|
27465
27609
|
}
|
|
27466
27610
|
async archive(sessionPath, sessionId) {
|
|
27467
27611
|
const data = await this.request({
|
|
27468
27612
|
type: "request",
|
|
27469
|
-
id:
|
|
27613
|
+
id: randomUUID5(),
|
|
27470
27614
|
command: "archive",
|
|
27471
27615
|
sessionPath,
|
|
27472
27616
|
sessionId
|
|
@@ -27476,7 +27620,7 @@ var DaemonCatalogClient = class {
|
|
|
27476
27620
|
async markInterrupted(sessionPath, activeSessionId, operations) {
|
|
27477
27621
|
await this.request({
|
|
27478
27622
|
type: "request",
|
|
27479
|
-
id:
|
|
27623
|
+
id: randomUUID5(),
|
|
27480
27624
|
command: "mark_interrupted",
|
|
27481
27625
|
sessionPath,
|
|
27482
27626
|
activeSessionId,
|
|
@@ -27490,7 +27634,7 @@ var DaemonCatalogClient = class {
|
|
|
27490
27634
|
const child = this.child;
|
|
27491
27635
|
if (!child && !this.starting)
|
|
27492
27636
|
return;
|
|
27493
|
-
await this.request({ type: "request", id:
|
|
27637
|
+
await this.request({ type: "request", id: randomUUID5(), command: "shutdown" }).catch(() => void 0);
|
|
27494
27638
|
if (child?.connected)
|
|
27495
27639
|
child.disconnect();
|
|
27496
27640
|
if (this.child === child)
|
|
@@ -27964,7 +28108,7 @@ function bashToolCallId(runId) {
|
|
|
27964
28108
|
}
|
|
27965
28109
|
|
|
27966
28110
|
// dist/modes/acp/acp-mode.js
|
|
27967
|
-
import { randomUUID as
|
|
28111
|
+
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
27968
28112
|
import { realpathSync as realpathSync4, statSync as statSync6 } from "node:fs";
|
|
27969
28113
|
import { resolve as resolve19 } from "node:path";
|
|
27970
28114
|
import { Readable } from "node:stream";
|
|
@@ -33064,7 +33208,7 @@ async function runAcpModeWithConnection(connection, options = {}) {
|
|
|
33064
33208
|
takeOverStdout();
|
|
33065
33209
|
}
|
|
33066
33210
|
const supportsMcpServers = connection.supportsAcpMcpServers?.() === true && connection.replaceAcpMcpServers !== void 0 && connection.releaseAcpMcpServers !== void 0;
|
|
33067
|
-
const acpMcpOwnerId =
|
|
33211
|
+
const acpMcpOwnerId = randomUUID6();
|
|
33068
33212
|
let acpMcpServerNames = [];
|
|
33069
33213
|
const clearAcpMcpServers = async (serverNames = acpMcpServerNames) => {
|
|
33070
33214
|
if (!supportsMcpServers || !connection.releaseAcpMcpServers)
|
|
@@ -33187,7 +33331,7 @@ async function runAcpModeWithConnection(connection, options = {}) {
|
|
|
33187
33331
|
await entry.inputPauseRelease.promise.catch(() => void 0);
|
|
33188
33332
|
entry.inputPauseRelease = void 0;
|
|
33189
33333
|
}
|
|
33190
|
-
const leaseKey = entry.inputPauseKey ??
|
|
33334
|
+
const leaseKey = entry.inputPauseKey ?? randomUUID6();
|
|
33191
33335
|
entry.inputPauseKey = leaseKey;
|
|
33192
33336
|
const pause = await connection.acquireSessionInputPause(leaseKey);
|
|
33193
33337
|
entry.inputPause = pause;
|
|
@@ -33279,7 +33423,7 @@ async function runAcpModeWithConnection(connection, options = {}) {
|
|
|
33279
33423
|
if (typeof requestedCwd === "string" && requestedCwd.length > 0 && actualCwd && !sameCwd(requestedCwd, actualCwd)) {
|
|
33280
33424
|
cwdMismatch = { requested: requestedCwd, actual: actualCwd };
|
|
33281
33425
|
}
|
|
33282
|
-
const sessionId =
|
|
33426
|
+
const sessionId = randomUUID6();
|
|
33283
33427
|
const producer = new AcpUpdateProducer(sessionId, ctx.client);
|
|
33284
33428
|
let inputPauseRelease;
|
|
33285
33429
|
if (closedInputPause) {
|
|
@@ -33605,7 +33749,7 @@ async function runAcpModeWithConnection(connection, options = {}) {
|
|
|
33605
33749
|
}
|
|
33606
33750
|
|
|
33607
33751
|
// dist/modes/agent-connection/daemon-agent-connection.js
|
|
33608
|
-
import { randomUUID as
|
|
33752
|
+
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
33609
33753
|
|
|
33610
33754
|
// dist/modes/agents-view/roster-store.js
|
|
33611
33755
|
var STALE_ROSTER_DAEMON_MESSAGE = "Daemon is stale: it does not advertise the agent_roster capability; restart the daemon";
|
|
@@ -34084,7 +34228,7 @@ var DaemonAgentConnection = class _DaemonAgentConnection {
|
|
|
34084
34228
|
listeners = /* @__PURE__ */ new Set();
|
|
34085
34229
|
unsubscribeDaemonMessages;
|
|
34086
34230
|
unsubscribeDaemonClose;
|
|
34087
|
-
clientId = `daemon-agent-connection:${
|
|
34231
|
+
clientId = `daemon-agent-connection:${randomUUID7()}`;
|
|
34088
34232
|
sessionInputPauses = /* @__PURE__ */ new Map();
|
|
34089
34233
|
sessionInputPauseGeneration = 0;
|
|
34090
34234
|
ownedSessionPromotionTail = Promise.resolve();
|
|
@@ -34709,7 +34853,7 @@ var DaemonAgentConnection = class _DaemonAgentConnection {
|
|
|
34709
34853
|
}, DAEMON_LONG_RUNNING_REQUEST_TIMEOUT_MS);
|
|
34710
34854
|
return;
|
|
34711
34855
|
}
|
|
34712
|
-
const admissionId = `prompt-admission:${
|
|
34856
|
+
const admissionId = `prompt-admission:${randomUUID7()}`;
|
|
34713
34857
|
let resolveAbort = () => {
|
|
34714
34858
|
};
|
|
34715
34859
|
const aborted = new Promise((resolve26) => {
|
|
@@ -36560,8 +36704,8 @@ var CustomEditor = class extends Editor {
|
|
|
36560
36704
|
};
|
|
36561
36705
|
|
|
36562
36706
|
// dist/modes/interactive/interactive-mode.js
|
|
36563
|
-
import { randomUUID as
|
|
36564
|
-
import * as
|
|
36707
|
+
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
36708
|
+
import * as fs4 from "node:fs";
|
|
36565
36709
|
import * as os3 from "node:os";
|
|
36566
36710
|
import * as path5 from "node:path";
|
|
36567
36711
|
import { spawnSync as spawnSync8 } from "child_process";
|
|
@@ -36876,17 +37020,14 @@ function requireNewPrompt(value) {
|
|
|
36876
37020
|
return prompt;
|
|
36877
37021
|
}
|
|
36878
37022
|
|
|
36879
|
-
// dist/themes/
|
|
36880
|
-
var
|
|
36881
|
-
|
|
36882
|
-
|
|
36883
|
-
|
|
36884
|
-
|
|
36885
|
-
|
|
36886
|
-
|
|
36887
|
-
\u2588\u2588\u2588\u2588\u2588 \u2580\u2588\u2584\u2584\u2584\u2588\u2588\u2588\u2588\u2588\u2580
|
|
36888
|
-
\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580
|
|
36889
|
-
\u2580\u2588\u2588\u2588\u2580\u2580 \u2588\u2588\u2588\u2588\u2588\u2580`;
|
|
37023
|
+
// dist/themes/synerise-logo.js
|
|
37024
|
+
var SYNERISE_LOGO = ` #### # # # # ##### #### ##### #### #####
|
|
37025
|
+
# # # ## # # # # # # #
|
|
37026
|
+
### # # # # #### #### # ### ####
|
|
37027
|
+
# # # ## # # # # # #
|
|
37028
|
+
#### # # # ##### # # ##### #### #####
|
|
37029
|
+
|
|
37030
|
+
Synerise base-context`;
|
|
36890
37031
|
|
|
36891
37032
|
// dist/utils/changelog.js
|
|
36892
37033
|
import { existsSync as existsSync19, readFileSync as readFileSync16 } from "fs";
|
|
@@ -36943,7 +37084,7 @@ import { platform as platform2 } from "os";
|
|
|
36943
37084
|
|
|
36944
37085
|
// dist/utils/clipboard-image.js
|
|
36945
37086
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
36946
|
-
import { randomUUID as
|
|
37087
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
36947
37088
|
import { readFileSync as readFileSync17, unlinkSync as unlinkSync3 } from "fs";
|
|
36948
37089
|
import { tmpdir as tmpdir3 } from "os";
|
|
36949
37090
|
import { join as join22 } from "path";
|
|
@@ -37049,7 +37190,7 @@ function isWSL(env = process.env) {
|
|
|
37049
37190
|
}
|
|
37050
37191
|
}
|
|
37051
37192
|
function readClipboardImageViaPowerShell() {
|
|
37052
|
-
const tmpFile = join22(tmpdir3(), `pi-wsl-clip-${
|
|
37193
|
+
const tmpFile = join22(tmpdir3(), `pi-wsl-clip-${randomUUID8()}.png`);
|
|
37053
37194
|
try {
|
|
37054
37195
|
const winPathResult = runCommand("wslpath", ["-w", tmpFile], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });
|
|
37055
37196
|
if (!winPathResult.ok) {
|
|
@@ -37325,7 +37466,7 @@ async function checkTmuxKeyboardSetup() {
|
|
|
37325
37466
|
return "tmux extended-keys is off. Modified Enter keys may not work. Add `set -g extended-keys on` to ~/.tmux.conf and restart tmux.";
|
|
37326
37467
|
}
|
|
37327
37468
|
if (extendedKeysFormat === "xterm") {
|
|
37328
|
-
return "tmux extended-keys-format is xterm.
|
|
37469
|
+
return "tmux extended-keys-format is xterm. base-context works best with csi-u. Add `set -g extended-keys-format csi-u` to ~/.tmux.conf and restart tmux.";
|
|
37329
37470
|
}
|
|
37330
37471
|
return void 0;
|
|
37331
37472
|
}
|
|
@@ -37632,6 +37773,9 @@ var MenuSearchInput = class {
|
|
|
37632
37773
|
setValue(value) {
|
|
37633
37774
|
this.input.setValue(value);
|
|
37634
37775
|
}
|
|
37776
|
+
setMasked(masked) {
|
|
37777
|
+
this.input.setMasked(masked);
|
|
37778
|
+
}
|
|
37635
37779
|
handleInput(data) {
|
|
37636
37780
|
this.input.handleInput(data);
|
|
37637
37781
|
}
|
|
@@ -37967,6 +38111,7 @@ var LoginDialogComponent = class extends Container {
|
|
|
37967
38111
|
* Show input for manual code/URL entry (for callback server providers)
|
|
37968
38112
|
*/
|
|
37969
38113
|
showManualInput(prompt) {
|
|
38114
|
+
this.input.setMasked(true);
|
|
37970
38115
|
this.addSectionSpacer();
|
|
37971
38116
|
this.addSectionTitle("Manual fallback");
|
|
37972
38117
|
this.addMutedText(prompt);
|
|
@@ -37990,7 +38135,8 @@ var LoginDialogComponent = class extends Container {
|
|
|
37990
38135
|
* Called by onPrompt callback - show prompt and wait for input
|
|
37991
38136
|
* Note: Does NOT clear content, appends to existing (preserves URL from showAuth)
|
|
37992
38137
|
*/
|
|
37993
|
-
showPrompt(message, placeholder) {
|
|
38138
|
+
showPrompt(message, placeholder, options) {
|
|
38139
|
+
this.input.setMasked(options?.masked === true);
|
|
37994
38140
|
this.addSectionSpacer();
|
|
37995
38141
|
this.addSectionTitle(message);
|
|
37996
38142
|
if (placeholder) {
|
|
@@ -38528,7 +38674,7 @@ var ProviderAuthFlows = class {
|
|
|
38528
38674
|
const selector = new OAuthSelectorComponent("logout", this.host.modelRegistry.authStorage, providerOptions, async (providerOption) => {
|
|
38529
38675
|
close();
|
|
38530
38676
|
try {
|
|
38531
|
-
this.host.modelRegistry.authStorage.
|
|
38677
|
+
this.host.modelRegistry.authStorage.removeVerified(providerOption.id);
|
|
38532
38678
|
this.host.modelRegistry.refresh();
|
|
38533
38679
|
await this.host.onAuthChanged?.();
|
|
38534
38680
|
const message = providerOption.authType === "oauth" ? `Logged out of ${providerOption.name}` : `Removed stored API key for ${providerOption.name}. Environment variables and models.json config are unchanged.`;
|
|
@@ -38666,11 +38812,12 @@ var ProviderAuthFlows = class {
|
|
|
38666
38812
|
this.host.ui.requestRender();
|
|
38667
38813
|
};
|
|
38668
38814
|
try {
|
|
38669
|
-
|
|
38670
|
-
|
|
38671
|
-
|
|
38672
|
-
|
|
38673
|
-
|
|
38815
|
+
await this.host.modelRegistry.authStorage.setFromLogin(providerId, async () => {
|
|
38816
|
+
const apiKey = (await dialog.showPrompt("Enter API key:", void 0, { masked: true })).trim();
|
|
38817
|
+
if (!apiKey)
|
|
38818
|
+
throw new Error("API key cannot be empty.");
|
|
38819
|
+
return { type: "api_key", key: apiKey };
|
|
38820
|
+
}, dialog.signal);
|
|
38674
38821
|
closeDialog();
|
|
38675
38822
|
return await this.completeProviderAuthentication(providerId, providerName, "api_key", void 0, kind);
|
|
38676
38823
|
} catch (error) {
|
|
@@ -39826,6 +39973,17 @@ var BranchSummaryMessageComponent = class extends Box {
|
|
|
39826
39973
|
}
|
|
39827
39974
|
};
|
|
39828
39975
|
|
|
39976
|
+
// dist/modes/interactive/components/brand-announcement.js
|
|
39977
|
+
var BrandAnnouncementComponent = class extends Container {
|
|
39978
|
+
constructor() {
|
|
39979
|
+
super();
|
|
39980
|
+
this.addChild(new DynamicBorder((text) => theme.fg("accent", text)));
|
|
39981
|
+
this.addChild(new Text(theme.fg("accent", SYNERISE_LOGO), 1, 0));
|
|
39982
|
+
this.addChild(new Spacer(1));
|
|
39983
|
+
this.addChild(new DynamicBorder((text) => theme.fg("accent", text)));
|
|
39984
|
+
}
|
|
39985
|
+
};
|
|
39986
|
+
|
|
39829
39987
|
// dist/modes/interactive/components/compaction-outcome-message.js
|
|
39830
39988
|
var CompactionOutcomeMessageComponent = class extends Container {
|
|
39831
39989
|
constructor(message) {
|
|
@@ -42168,45 +42326,9 @@ var DaxnutsComponent = class {
|
|
|
42168
42326
|
}
|
|
42169
42327
|
};
|
|
42170
42328
|
|
|
42171
|
-
// dist/modes/interactive/components/earendil-announcement.js
|
|
42172
|
-
import * as fs3 from "node:fs";
|
|
42173
|
-
var BLOG_URL = "https://mariozechner.at/posts/2026-04-08-ive-sold-out/";
|
|
42174
|
-
var IMAGE_FILENAME = "clankolas.png";
|
|
42175
|
-
var cachedImageBase64;
|
|
42176
|
-
var attemptedImageLoad = false;
|
|
42177
|
-
function loadImageBase64() {
|
|
42178
|
-
if (attemptedImageLoad) {
|
|
42179
|
-
return cachedImageBase64;
|
|
42180
|
-
}
|
|
42181
|
-
attemptedImageLoad = true;
|
|
42182
|
-
try {
|
|
42183
|
-
cachedImageBase64 = fs3.readFileSync(getBundledInteractiveAssetPath(IMAGE_FILENAME)).toString("base64");
|
|
42184
|
-
} catch {
|
|
42185
|
-
cachedImageBase64 = void 0;
|
|
42186
|
-
}
|
|
42187
|
-
return cachedImageBase64;
|
|
42188
|
-
}
|
|
42189
|
-
var EarendilAnnouncementComponent = class extends Container {
|
|
42190
|
-
constructor() {
|
|
42191
|
-
super();
|
|
42192
|
-
this.addChild(new DynamicBorder((text) => theme.fg("accent", text)));
|
|
42193
|
-
this.addChild(new Text(theme.bold(theme.fg("accent", "pi has joined Earendil")), 1, 0));
|
|
42194
|
-
this.addChild(new Spacer(1));
|
|
42195
|
-
this.addChild(new Text(theme.fg("muted", "Read the blog post:"), 1, 0));
|
|
42196
|
-
this.addChild(new Text(theme.fg("mdLink", BLOG_URL), 1, 0));
|
|
42197
|
-
this.addChild(new Spacer(1));
|
|
42198
|
-
const imageBase64 = loadImageBase64();
|
|
42199
|
-
if (imageBase64) {
|
|
42200
|
-
this.addChild(new Image(imageBase64, "image/png", { fallbackColor: (text) => theme.fg("muted", text) }, { maxWidthCells: 56, filename: IMAGE_FILENAME, fallbackOnly: true }));
|
|
42201
|
-
this.addChild(new Spacer(1));
|
|
42202
|
-
}
|
|
42203
|
-
this.addChild(new DynamicBorder((text) => theme.fg("accent", text)));
|
|
42204
|
-
}
|
|
42205
|
-
};
|
|
42206
|
-
|
|
42207
42329
|
// dist/modes/interactive/components/extension-editor.js
|
|
42208
42330
|
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
42209
|
-
import * as
|
|
42331
|
+
import * as fs3 from "node:fs";
|
|
42210
42332
|
import * as os2 from "node:os";
|
|
42211
42333
|
import * as path4 from "node:path";
|
|
42212
42334
|
var ExtensionEditorComponent = class extends Container {
|
|
@@ -42268,7 +42390,7 @@ var ExtensionEditorComponent = class extends Container {
|
|
|
42268
42390
|
const currentText = this.editor.getText();
|
|
42269
42391
|
const tmpFile = path4.join(os2.tmpdir(), `pi-extension-editor-${Date.now()}.md`);
|
|
42270
42392
|
try {
|
|
42271
|
-
|
|
42393
|
+
fs3.writeFileSync(tmpFile, currentText, "utf-8");
|
|
42272
42394
|
this.tui.stop();
|
|
42273
42395
|
const [editor, ...editorArgs] = editorCmd.split(" ");
|
|
42274
42396
|
const result = spawnSync7(editor, [...editorArgs, tmpFile], {
|
|
@@ -42276,12 +42398,12 @@ var ExtensionEditorComponent = class extends Container {
|
|
|
42276
42398
|
shell: process.platform === "win32"
|
|
42277
42399
|
});
|
|
42278
42400
|
if (result.status === 0) {
|
|
42279
|
-
const newContent =
|
|
42401
|
+
const newContent = fs3.readFileSync(tmpFile, "utf-8").replace(/\n$/, "");
|
|
42280
42402
|
this.editor.setText(newContent);
|
|
42281
42403
|
}
|
|
42282
42404
|
} finally {
|
|
42283
42405
|
try {
|
|
42284
|
-
|
|
42406
|
+
fs3.unlinkSync(tmpFile);
|
|
42285
42407
|
} catch {
|
|
42286
42408
|
}
|
|
42287
42409
|
this.tui.start();
|
|
@@ -46792,6 +46914,8 @@ var SettingsSelectorComponent = class extends Container {
|
|
|
46792
46914
|
constructor(config, callbacks) {
|
|
46793
46915
|
super();
|
|
46794
46916
|
let currentWarnings = { ...config.warnings };
|
|
46917
|
+
let currentTheme = config.currentTheme;
|
|
46918
|
+
const themeLabel = (name) => name === "prime" ? "Synerise" : name;
|
|
46795
46919
|
const idleEvictionValues = [30, 60, 90, 180, 360];
|
|
46796
46920
|
if (typeof config.idleEvictionMinutes === "number" && !idleEvictionValues.includes(config.idleEvictionMinutes)) {
|
|
46797
46921
|
idleEvictionValues.push(config.idleEvictionMinutes);
|
|
@@ -46889,15 +47013,16 @@ var SettingsSelectorComponent = class extends Container {
|
|
|
46889
47013
|
id: "theme",
|
|
46890
47014
|
label: "Theme",
|
|
46891
47015
|
description: "Color theme for the interface",
|
|
46892
|
-
currentValue:
|
|
46893
|
-
submenu: (
|
|
47016
|
+
currentValue: themeLabel(currentTheme),
|
|
47017
|
+
submenu: (_currentValue, done) => new SelectSubmenu("Theme", "Select color theme", config.availableThemes.map((t) => ({
|
|
46894
47018
|
value: t,
|
|
46895
|
-
label: t
|
|
46896
|
-
})),
|
|
47019
|
+
label: themeLabel(t)
|
|
47020
|
+
})), currentTheme, (value) => {
|
|
47021
|
+
currentTheme = value;
|
|
46897
47022
|
callbacks.onThemeChange(value);
|
|
46898
|
-
done(value);
|
|
47023
|
+
done(themeLabel(value));
|
|
46899
47024
|
}, () => {
|
|
46900
|
-
callbacks.onThemePreview?.(
|
|
47025
|
+
callbacks.onThemePreview?.(currentTheme);
|
|
46901
47026
|
done();
|
|
46902
47027
|
}, (value) => {
|
|
46903
47028
|
callbacks.onThemePreview?.(value);
|
|
@@ -48738,7 +48863,7 @@ var BrandSplashHeader = class {
|
|
|
48738
48863
|
this.getCwd = getCwd;
|
|
48739
48864
|
this.verboseInstructions = verboseInstructions;
|
|
48740
48865
|
this.options = options;
|
|
48741
|
-
this.logoRaw = (options.logo ??
|
|
48866
|
+
this.logoRaw = (options.logo ?? SYNERISE_LOGO).split("\n");
|
|
48742
48867
|
this.logoCanvasWidth = this.logoRaw.reduce((max, line) => Math.max(max, visibleWidth(line)), 0);
|
|
48743
48868
|
}
|
|
48744
48869
|
invalidate() {
|
|
@@ -51827,7 +51952,7 @@ ${message}`, ["Yes", "No"], opts);
|
|
|
51827
51952
|
}
|
|
51828
51953
|
const previousTurns = this.sideQuestionTurns.filter((turn) => turn.answer).map((turn) => ({ question: turn.question, answer: turn.answer }));
|
|
51829
51954
|
const event = {
|
|
51830
|
-
id:
|
|
51955
|
+
id: randomUUID9(),
|
|
51831
51956
|
question,
|
|
51832
51957
|
answer: "",
|
|
51833
51958
|
status: "running"
|
|
@@ -51881,7 +52006,7 @@ ${message}`, ["Yes", "No"], opts);
|
|
|
51881
52006
|
const truncation = truncateTail(rawOutput);
|
|
51882
52007
|
const output = truncation.content.replace(/\n+$/, "");
|
|
51883
52008
|
this.sideQuestionTurns.push({
|
|
51884
|
-
id: `side-bash-${
|
|
52009
|
+
id: `side-bash-${randomUUID9()}`,
|
|
51885
52010
|
question: bash.input,
|
|
51886
52011
|
answer: bashOutputToText({
|
|
51887
52012
|
output,
|
|
@@ -51975,7 +52100,7 @@ ${message}`, ["Yes", "No"], opts);
|
|
|
51975
52100
|
if (this.sideQuestionComponent && slashCommand !== void 0 && (isBuiltinSlashCommandName(slashCommand.name) || this.connectionCommands.some((command) => command.name === slashCommand.name))) {
|
|
51976
52101
|
this.editor.addToHistory?.(text);
|
|
51977
52102
|
this.sideQuestionComponent.addTurn({
|
|
51978
|
-
id: `side-notice-${
|
|
52103
|
+
id: `side-notice-${randomUUID9()}`,
|
|
51979
52104
|
question: text,
|
|
51980
52105
|
answer: "Slash commands are not available in side conversations. Press esc to return to the main thread.",
|
|
51981
52106
|
status: "complete"
|
|
@@ -52214,7 +52339,7 @@ ${message}`, ["Yes", "No"], opts);
|
|
|
52214
52339
|
this.showWarning("Wait for the current side question to finish or cancel it first.");
|
|
52215
52340
|
return;
|
|
52216
52341
|
}
|
|
52217
|
-
const sideBash = this.sideQuestionComponent ? { runId:
|
|
52342
|
+
const sideBash = this.sideQuestionComponent ? { runId: randomUUID9(), input: text, seedTranscript: !isExcluded } : void 0;
|
|
52218
52343
|
if (sideBash) {
|
|
52219
52344
|
this.sideQuestionBash = sideBash;
|
|
52220
52345
|
} else {
|
|
@@ -52259,7 +52384,7 @@ ${message}`, ["Yes", "No"], opts);
|
|
|
52259
52384
|
if (this.hasPastedImagesFor(text)) {
|
|
52260
52385
|
this.editor.setText(text);
|
|
52261
52386
|
this.sideQuestionComponent.addTurn({
|
|
52262
|
-
id: `side-notice-${
|
|
52387
|
+
id: `side-notice-${randomUUID9()}`,
|
|
52263
52388
|
question: text,
|
|
52264
52389
|
answer: "Images are not supported in side conversations. Press esc to return to the main thread.",
|
|
52265
52390
|
status: "complete"
|
|
@@ -54217,7 +54342,7 @@ ${message}`, ["Yes", "No"], opts);
|
|
|
54217
54342
|
const currentText = this.editor.getExpandedText?.() ?? this.editor.getText();
|
|
54218
54343
|
const tmpFile = path5.join(os3.tmpdir(), `pi-editor-${Date.now()}.pi.md`);
|
|
54219
54344
|
try {
|
|
54220
|
-
|
|
54345
|
+
fs4.writeFileSync(tmpFile, currentText, "utf-8");
|
|
54221
54346
|
this.ui.stop();
|
|
54222
54347
|
const [editor, ...editorArgs] = editorCmd.split(" ");
|
|
54223
54348
|
const result = spawnSync8(editor, [...editorArgs, tmpFile], {
|
|
@@ -54225,12 +54350,12 @@ ${message}`, ["Yes", "No"], opts);
|
|
|
54225
54350
|
shell: process.platform === "win32"
|
|
54226
54351
|
});
|
|
54227
54352
|
if (result.status === 0) {
|
|
54228
|
-
const newContent =
|
|
54353
|
+
const newContent = fs4.readFileSync(tmpFile, "utf-8").replace(/\n$/, "");
|
|
54229
54354
|
this.editor.setText(newContent);
|
|
54230
54355
|
}
|
|
54231
54356
|
} finally {
|
|
54232
54357
|
try {
|
|
54233
|
-
|
|
54358
|
+
fs4.unlinkSync(tmpFile);
|
|
54234
54359
|
} catch {
|
|
54235
54360
|
}
|
|
54236
54361
|
this.ui.start();
|
|
@@ -55239,12 +55364,12 @@ Fell back to dark theme.`);
|
|
|
55239
55364
|
this.showError("Usage: /mcp logout <name>");
|
|
55240
55365
|
return;
|
|
55241
55366
|
}
|
|
55242
|
-
|
|
55243
|
-
|
|
55244
|
-
|
|
55367
|
+
try {
|
|
55368
|
+
authStorage.removeVerified(`mcp:${server}`);
|
|
55369
|
+
await this.reloadAfterMcpChange(`Disconnected ${server}.`);
|
|
55370
|
+
} catch (error) {
|
|
55371
|
+
this.showError(`Logout failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
55245
55372
|
}
|
|
55246
|
-
authStorage.logout(`mcp:${server}`);
|
|
55247
|
-
await this.reloadAfterMcpChange(`Disconnected ${server}.`);
|
|
55248
55373
|
return;
|
|
55249
55374
|
}
|
|
55250
55375
|
try {
|
|
@@ -55685,8 +55810,8 @@ Fell back to dark theme.`);
|
|
|
55685
55810
|
`;
|
|
55686
55811
|
let files = [];
|
|
55687
55812
|
try {
|
|
55688
|
-
if (
|
|
55689
|
-
files =
|
|
55813
|
+
if (fs4.existsSync(logsDir)) {
|
|
55814
|
+
files = fs4.readdirSync(logsDir).filter((name) => !name.startsWith("."));
|
|
55690
55815
|
}
|
|
55691
55816
|
} catch {
|
|
55692
55817
|
}
|
|
@@ -55697,7 +55822,7 @@ Fell back to dark theme.`);
|
|
|
55697
55822
|
for (const name of files.sort()) {
|
|
55698
55823
|
let size = "";
|
|
55699
55824
|
try {
|
|
55700
|
-
size = ` ${theme.fg("dim", `(${(
|
|
55825
|
+
size = ` ${theme.fg("dim", `(${(fs4.statSync(path5.join(logsDir, name)).size / 1024).toFixed(1)} KB)`)}`;
|
|
55701
55826
|
} catch {
|
|
55702
55827
|
}
|
|
55703
55828
|
info += `${theme.fg("dim", "\u2022")} ${name}${size}
|
|
@@ -56144,8 +56269,8 @@ ${interrupt ? `| \`${interrupt}\` | Interrupt current operation |
|
|
|
56144
56269
|
...messages.map((msg) => JSON.stringify(msg)),
|
|
56145
56270
|
""
|
|
56146
56271
|
].join("\n");
|
|
56147
|
-
|
|
56148
|
-
|
|
56272
|
+
fs4.mkdirSync(path5.dirname(debugLogPath), { recursive: true });
|
|
56273
|
+
fs4.writeFileSync(debugLogPath, debugData);
|
|
56149
56274
|
this.chatContainer.addChild(new Spacer(1));
|
|
56150
56275
|
this.chatContainer.addChild(new Text(`${theme.fg("accent", "\u2713 Debug log written")}
|
|
56151
56276
|
${theme.fg("muted", debugLogPath)}`, 1, 1));
|
|
@@ -56161,7 +56286,7 @@ ${theme.fg("muted", debugLogPath)}`, 1, 1));
|
|
|
56161
56286
|
}
|
|
56162
56287
|
handleDementedDelves() {
|
|
56163
56288
|
this.chatContainer.addChild(new Spacer(1));
|
|
56164
|
-
this.chatContainer.addChild(new
|
|
56289
|
+
this.chatContainer.addChild(new BrandAnnouncementComponent());
|
|
56165
56290
|
this.ui.requestRender();
|
|
56166
56291
|
}
|
|
56167
56292
|
handleDaxnuts() {
|
|
@@ -58723,10 +58848,10 @@ function padLine(line, width) {
|
|
|
58723
58848
|
|
|
58724
58849
|
// dist/modes/daemon/daemon-mode.js
|
|
58725
58850
|
import { spawn as spawn9 } from "node:child_process";
|
|
58726
|
-
import { createHash as createHash8, randomUUID as
|
|
58727
|
-
import { existsSync as existsSync24, mkdirSync as mkdirSync16, readFileSync as
|
|
58851
|
+
import { createHash as createHash8, randomUUID as randomUUID13, timingSafeEqual } from "node:crypto";
|
|
58852
|
+
import { existsSync as existsSync24, mkdirSync as mkdirSync16, readFileSync as readFileSync22, renameSync as renameSync11, rmSync as rmSync12, writeFileSync as writeFileSync11 } from "node:fs";
|
|
58728
58853
|
import { stat as stat3 } from "node:fs/promises";
|
|
58729
|
-
import { createConnection as createConnection2, createServer } from "node:net";
|
|
58854
|
+
import { createConnection as createConnection2, createServer as createServer2 } from "node:net";
|
|
58730
58855
|
import { basename as basename11, dirname as dirname18, isAbsolute as isAbsolute5, join as join30, resolve as resolve23 } from "node:path";
|
|
58731
58856
|
|
|
58732
58857
|
// dist/core/rlm-journal-owner.js
|
|
@@ -58904,10 +59029,10 @@ var RlmJournalOwner = class _RlmJournalOwner {
|
|
|
58904
59029
|
};
|
|
58905
59030
|
|
|
58906
59031
|
// dist/modes/daemon/active-session-state.js
|
|
58907
|
-
import { randomUUID as
|
|
59032
|
+
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
58908
59033
|
function createActiveSessionId(existingIds) {
|
|
58909
59034
|
while (true) {
|
|
58910
|
-
const activeSessionId = formatSessionDisplayId(
|
|
59035
|
+
const activeSessionId = formatSessionDisplayId(randomUUID10());
|
|
58911
59036
|
if (!existingIds?.has(activeSessionId)) {
|
|
58912
59037
|
return activeSessionId;
|
|
58913
59038
|
}
|
|
@@ -59204,7 +59329,7 @@ async function withClientEnv(env, fn) {
|
|
|
59204
59329
|
}
|
|
59205
59330
|
|
|
59206
59331
|
// dist/modes/daemon/daemon-extension-binding.js
|
|
59207
|
-
import { randomUUID as
|
|
59332
|
+
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
59208
59333
|
function slimSessionEventForWire(event) {
|
|
59209
59334
|
if (event.type !== "message_update") {
|
|
59210
59335
|
return event;
|
|
@@ -59281,7 +59406,7 @@ function createCommandContextActions(state) {
|
|
|
59281
59406
|
}
|
|
59282
59407
|
function createExtensionUIContext(state, broadcast) {
|
|
59283
59408
|
const emitUiRequest = (method, payload) => {
|
|
59284
|
-
const id =
|
|
59409
|
+
const id = randomUUID11();
|
|
59285
59410
|
broadcast(state, {
|
|
59286
59411
|
type: "extension_ui_request",
|
|
59287
59412
|
activeSessionId: state.activeSessionId,
|
|
@@ -59381,7 +59506,7 @@ function hasExtensionUiClientForMethod(state, method) {
|
|
|
59381
59506
|
}
|
|
59382
59507
|
|
|
59383
59508
|
// dist/modes/daemon/daemon-rlm-capacity.js
|
|
59384
|
-
import { randomUUID as
|
|
59509
|
+
import { randomUUID as randomUUID12 } from "node:crypto";
|
|
59385
59510
|
var DaemonRlmCapacityClient = class {
|
|
59386
59511
|
options;
|
|
59387
59512
|
reservations = /* @__PURE__ */ new Map();
|
|
@@ -59405,7 +59530,7 @@ var DaemonRlmCapacityClient = class {
|
|
|
59405
59530
|
return this.reserve(origin, true);
|
|
59406
59531
|
}
|
|
59407
59532
|
async reserve(origin, residentRoot) {
|
|
59408
|
-
const reservationId =
|
|
59533
|
+
const reservationId = randomUUID12();
|
|
59409
59534
|
const record3 = { ...origin, reservationId, ...residentRoot ? { residentRoot } : {} };
|
|
59410
59535
|
this.reservations.set(reservationId, record3);
|
|
59411
59536
|
let released = false;
|
|
@@ -59877,7 +60002,7 @@ async function readRlmSubagentDisplayEntry(sessionDir) {
|
|
|
59877
60002
|
}
|
|
59878
60003
|
|
|
59879
60004
|
// dist/modes/daemon/snapshot-transcript-cache.js
|
|
59880
|
-
import { mkdirSync as mkdirSync14, readFileSync as
|
|
60005
|
+
import { mkdirSync as mkdirSync14, readFileSync as readFileSync20, rmSync as rmSync11, writeFileSync as writeFileSync10 } from "node:fs";
|
|
59881
60006
|
import { join as join29 } from "node:path";
|
|
59882
60007
|
var SNAPSHOT_TARGET_CHUNK_BYTES = 512 * 1024;
|
|
59883
60008
|
var SNAPSHOT_MEMORY_CACHE_BYTES = 4 * 1024 * 1024;
|
|
@@ -59968,7 +60093,7 @@ var SnapshotTranscriptCache = class {
|
|
|
59968
60093
|
if (!chunk.path) {
|
|
59969
60094
|
throw new Error(`Snapshot transcript chunk ${index} has no backing storage`);
|
|
59970
60095
|
}
|
|
59971
|
-
return
|
|
60096
|
+
return readFileSync20(chunk.path);
|
|
59972
60097
|
}
|
|
59973
60098
|
*[Symbol.iterator]() {
|
|
59974
60099
|
for (let index = 0; index < this.chunkCount; index++) {
|
|
@@ -60124,7 +60249,7 @@ var SnapshotTranscriptCache = class {
|
|
|
60124
60249
|
};
|
|
60125
60250
|
|
|
60126
60251
|
// dist/modes/daemon/worker-recovery-journal.js
|
|
60127
|
-
import { fchmodSync, fstatSync as fstatSync3, fsyncSync as fsyncSync6, mkdirSync as mkdirSync15, openSync as openSync6, readFileSync as
|
|
60252
|
+
import { fchmodSync, fstatSync as fstatSync3, fsyncSync as fsyncSync6, mkdirSync as mkdirSync15, openSync as openSync6, readFileSync as readFileSync21, readSync as readSync3, renameSync as renameSync10 } from "node:fs";
|
|
60128
60253
|
import { dirname as dirname17 } from "node:path";
|
|
60129
60254
|
|
|
60130
60255
|
// dist/modes/daemon/recovery-journal-io.js
|
|
@@ -60155,7 +60280,7 @@ function parseRecords(path6) {
|
|
|
60155
60280
|
const latest = /* @__PURE__ */ new Map();
|
|
60156
60281
|
let contents;
|
|
60157
60282
|
try {
|
|
60158
|
-
contents =
|
|
60283
|
+
contents = readFileSync21(path6, "utf8");
|
|
60159
60284
|
} catch (error) {
|
|
60160
60285
|
if (error.code === "ENOENT")
|
|
60161
60286
|
return { latest, incompleteTail: false };
|
|
@@ -60552,7 +60677,7 @@ var AgentDaemon = class {
|
|
|
60552
60677
|
await this.openRlmJournalOwner();
|
|
60553
60678
|
try {
|
|
60554
60679
|
await prepareDaemonSocketPath(this.socketPath);
|
|
60555
|
-
this.server =
|
|
60680
|
+
this.server = createServer2((socket) => this.handleConnection(socket));
|
|
60556
60681
|
await new Promise((resolveListen, rejectListen) => {
|
|
60557
60682
|
const onError = (error) => {
|
|
60558
60683
|
this.server?.off("listening", onListening);
|
|
@@ -60731,7 +60856,7 @@ var AgentDaemon = class {
|
|
|
60731
60856
|
let ownsLock = false;
|
|
60732
60857
|
try {
|
|
60733
60858
|
for (let attempt2 = 0; attempt2 < 3 && !ownsLock; attempt2++) {
|
|
60734
|
-
const token =
|
|
60859
|
+
const token = randomUUID13();
|
|
60735
60860
|
const candidateDirectory = `${lockDirectory}.candidate-${process.pid}-${token}`;
|
|
60736
60861
|
mkdirSync16(candidateDirectory, { mode: 448 });
|
|
60737
60862
|
writeFileSync11(join30(candidateDirectory, "pid"), `${process.pid}
|
|
@@ -60750,7 +60875,7 @@ var AgentDaemon = class {
|
|
|
60750
60875
|
}
|
|
60751
60876
|
let ownerPid;
|
|
60752
60877
|
try {
|
|
60753
|
-
ownerPid = Number(
|
|
60878
|
+
ownerPid = Number(readFileSync22(join30(lockDirectory, "pid"), "utf8").trim());
|
|
60754
60879
|
} catch {
|
|
60755
60880
|
}
|
|
60756
60881
|
if (ownerPid && this.isProcessAlive(ownerPid)) {
|
|
@@ -63793,7 +63918,7 @@ var AgentDaemon = class {
|
|
|
63793
63918
|
return success(command.id, "acquire_session_input_pause", { pauseId: existing[0] });
|
|
63794
63919
|
}
|
|
63795
63920
|
const state = this.getSessionState(command.activeSessionId);
|
|
63796
|
-
const pauseId =
|
|
63921
|
+
const pauseId = randomUUID13();
|
|
63797
63922
|
this.sessionInputPauses.set(pauseId, {
|
|
63798
63923
|
activeSessionId: command.activeSessionId,
|
|
63799
63924
|
owner: client,
|
|
@@ -66340,14 +66465,14 @@ async function resolveDaemonSessionPath(selector, cwd, sessionDir) {
|
|
|
66340
66465
|
|
|
66341
66466
|
// dist/modes/daemon/daemon-supervisor.js
|
|
66342
66467
|
import { spawn as spawn10 } from "node:child_process";
|
|
66343
|
-
import { createHash as createHash9, randomBytes, randomUUID as
|
|
66344
|
-
import { chmodSync as chmodSync3, existsSync as existsSync25, mkdirSync as mkdirSync18, readdirSync as readdirSync10, readFileSync as
|
|
66345
|
-
import { createServer as
|
|
66468
|
+
import { createHash as createHash9, randomBytes, randomUUID as randomUUID14 } from "node:crypto";
|
|
66469
|
+
import { chmodSync as chmodSync3, existsSync as existsSync25, mkdirSync as mkdirSync18, readdirSync as readdirSync10, readFileSync as readFileSync24, renameSync as renameSync13, rmSync as rmSync13, writeFileSync as writeFileSync12 } from "node:fs";
|
|
66470
|
+
import { createServer as createServer3 } from "node:net";
|
|
66346
66471
|
import { basename as basename12, dirname as dirname20, join as join31, resolve as resolve24 } from "node:path";
|
|
66347
66472
|
import { Writable } from "node:stream";
|
|
66348
66473
|
|
|
66349
66474
|
// dist/modes/daemon/command-recovery-journal.js
|
|
66350
|
-
import { fchmodSync as fchmodSync2, fstatSync as fstatSync4, fsyncSync as fsyncSync7, mkdirSync as mkdirSync17, openSync as openSync7, readFileSync as
|
|
66475
|
+
import { fchmodSync as fchmodSync2, fstatSync as fstatSync4, fsyncSync as fsyncSync7, mkdirSync as mkdirSync17, openSync as openSync7, readFileSync as readFileSync23, readSync as readSync4, renameSync as renameSync12 } from "node:fs";
|
|
66351
66476
|
import { dirname as dirname19 } from "node:path";
|
|
66352
66477
|
var COMPACT_AFTER_RECORDS = 4096;
|
|
66353
66478
|
function createCommandIdempotencyKey(clientId, commandId) {
|
|
@@ -66430,7 +66555,7 @@ var CommandRecoveryJournal = class {
|
|
|
66430
66555
|
load() {
|
|
66431
66556
|
let contents;
|
|
66432
66557
|
try {
|
|
66433
|
-
contents =
|
|
66558
|
+
contents = readFileSync23(this.path, "utf8");
|
|
66434
66559
|
} catch (error) {
|
|
66435
66560
|
if (error.code === "ENOENT") {
|
|
66436
66561
|
return;
|
|
@@ -66974,7 +67099,7 @@ var DaemonSupervisor = class {
|
|
|
66974
67099
|
sessionInputPauses = /* @__PURE__ */ new Map();
|
|
66975
67100
|
signalCleanupHandlers = [];
|
|
66976
67101
|
descriptorDir;
|
|
66977
|
-
generation =
|
|
67102
|
+
generation = randomUUID14();
|
|
66978
67103
|
supervisorConfigPath;
|
|
66979
67104
|
defaultSessionConfig;
|
|
66980
67105
|
snapshotCacheRoot;
|
|
@@ -67057,7 +67182,7 @@ var DaemonSupervisor = class {
|
|
|
67057
67182
|
const workersToAdopt = [...this.workers.values()];
|
|
67058
67183
|
for (const worker of workersToAdopt)
|
|
67059
67184
|
this.pendingRlmCapacity.add(worker);
|
|
67060
|
-
this.server =
|
|
67185
|
+
this.server = createServer3((socket) => this.handleConnection(socket));
|
|
67061
67186
|
await this.listen();
|
|
67062
67187
|
this.assertSocketLeaseHeld();
|
|
67063
67188
|
this.socketIdentity = getDaemonSocketIdentity(this.socketPath);
|
|
@@ -67514,7 +67639,7 @@ var DaemonSupervisor = class {
|
|
|
67514
67639
|
}
|
|
67515
67640
|
const path6 = join31(this.descriptorDir, name);
|
|
67516
67641
|
try {
|
|
67517
|
-
const descriptor = JSON.parse(
|
|
67642
|
+
const descriptor = JSON.parse(readFileSync24(path6, "utf8"));
|
|
67518
67643
|
if (!isDaemonWorkerDescriptor(descriptor, this.socketPath)) {
|
|
67519
67644
|
continue;
|
|
67520
67645
|
}
|
|
@@ -67556,7 +67681,7 @@ var DaemonSupervisor = class {
|
|
|
67556
67681
|
const descriptorPath = join31(this.descriptorDir, name);
|
|
67557
67682
|
let descriptor;
|
|
67558
67683
|
try {
|
|
67559
|
-
descriptor = JSON.parse(
|
|
67684
|
+
descriptor = JSON.parse(readFileSync24(descriptorPath, "utf8"));
|
|
67560
67685
|
} catch {
|
|
67561
67686
|
continue;
|
|
67562
67687
|
}
|
|
@@ -67572,7 +67697,7 @@ var DaemonSupervisor = class {
|
|
|
67572
67697
|
}
|
|
67573
67698
|
loadPersistedSupervisorConfig() {
|
|
67574
67699
|
try {
|
|
67575
|
-
const parsed = JSON.parse(
|
|
67700
|
+
const parsed = JSON.parse(readFileSync24(this.supervisorConfigPath, "utf8"));
|
|
67576
67701
|
if (parsed.version !== 1 || typeof parsed.socketPath !== "string" || normalizeSocketPath(parsed.socketPath) !== this.socketPath || !parsed.defaultSessionConfig || typeof parsed.defaultSessionConfig !== "object" || typeof parsed.defaultSessionConfig.agentDir !== "string") {
|
|
67577
67702
|
return void 0;
|
|
67578
67703
|
}
|
|
@@ -67709,7 +67834,7 @@ var DaemonSupervisor = class {
|
|
|
67709
67834
|
}
|
|
67710
67835
|
try {
|
|
67711
67836
|
const response = await this.forwardToWorker(entry.worker, {
|
|
67712
|
-
id:
|
|
67837
|
+
id: randomUUID14(),
|
|
67713
67838
|
type: "release_session_input_pause",
|
|
67714
67839
|
activeSessionId: entry.activeSessionId,
|
|
67715
67840
|
pauseId: entry.pauseId
|
|
@@ -67846,7 +67971,7 @@ var DaemonSupervisor = class {
|
|
|
67846
67971
|
client,
|
|
67847
67972
|
activeSessionId: command.activeSessionId,
|
|
67848
67973
|
publicAdmissionId: command.admissionId,
|
|
67849
|
-
workerAdmissionId: `supervisor-admission:${
|
|
67974
|
+
workerAdmissionId: `supervisor-admission:${randomUUID14()}`,
|
|
67850
67975
|
status: "waiting",
|
|
67851
67976
|
controller: new AbortController()
|
|
67852
67977
|
};
|
|
@@ -68339,7 +68464,7 @@ var DaemonSupervisor = class {
|
|
|
68339
68464
|
if (!this.clients.has(client) || (this.sessionInputPauseEpochs.get(client) ?? 0) !== acquisitionEpoch) {
|
|
68340
68465
|
try {
|
|
68341
68466
|
const release = await this.forwardToWorker(match2.worker, {
|
|
68342
|
-
id:
|
|
68467
|
+
id: randomUUID14(),
|
|
68343
68468
|
type: "release_session_input_pause",
|
|
68344
68469
|
activeSessionId,
|
|
68345
68470
|
pauseId
|
|
@@ -69164,7 +69289,7 @@ var DaemonSupervisor = class {
|
|
|
69164
69289
|
const rootActiveSessionId = existing?.descriptor.rootActiveSessionId ?? createActiveSessionId();
|
|
69165
69290
|
const socketPath = existing?.descriptor.socketPath ?? workerSocketPath(this.socketPath, workerId);
|
|
69166
69291
|
const token = existing?.descriptor.authenticationToken ?? randomBytes(32).toString("base64url");
|
|
69167
|
-
const workerInstanceId =
|
|
69292
|
+
const workerInstanceId = randomUUID14();
|
|
69168
69293
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
69169
69294
|
const descriptorPath = existing?.descriptorPath ?? join31(this.descriptorDir, `${workerId}.json`);
|
|
69170
69295
|
const recoveryJournalPath = existing?.descriptor.recoveryJournalPath ?? join31(this.descriptorDir, `${workerId}.recovery.jsonl`);
|
|
@@ -70624,7 +70749,7 @@ var DaemonSupervisor = class {
|
|
|
70624
70749
|
if (!socketIdentity) {
|
|
70625
70750
|
throw new Error("Direct transport requires an exact worker socket identity");
|
|
70626
70751
|
}
|
|
70627
|
-
const grantId =
|
|
70752
|
+
const grantId = randomUUID14();
|
|
70628
70753
|
const token = randomBytes(32).toString("base64url");
|
|
70629
70754
|
const expiresAt = new Date(Date.now() + PEER_TRANSPORT_GRANT_TTL_MS).toISOString();
|
|
70630
70755
|
const resolvedActiveSessionId = currentSummary.activeSessionId ?? currentSummary.id;
|
|
@@ -71758,7 +71883,7 @@ var DaemonSupervisor = class {
|
|
|
71758
71883
|
writeFileSync12(tempPath, `${JSON.stringify(manifest)}
|
|
71759
71884
|
`, { mode: 384 });
|
|
71760
71885
|
chmodSync3(tempPath, 384);
|
|
71761
|
-
const validated = JSON.parse(
|
|
71886
|
+
const validated = JSON.parse(readFileSync24(tempPath, "utf8"));
|
|
71762
71887
|
if (!Array.isArray(validated.sessions) || validated.sessions.length !== manifest.sessions.length) {
|
|
71763
71888
|
throw new Error("Could not validate aggregate update manifest");
|
|
71764
71889
|
}
|
|
@@ -73137,7 +73262,7 @@ var RpcClient = class {
|
|
|
73137
73262
|
};
|
|
73138
73263
|
|
|
73139
73264
|
// dist/modes/rpc/rpc-extension-ui-context.js
|
|
73140
|
-
import { randomUUID as
|
|
73265
|
+
import { randomUUID as randomUUID15 } from "node:crypto";
|
|
73141
73266
|
function createRpcExtensionUiBridge(output) {
|
|
73142
73267
|
const pending = /* @__PURE__ */ new Map();
|
|
73143
73268
|
let closed = false;
|
|
@@ -73145,7 +73270,7 @@ function createRpcExtensionUiBridge(output) {
|
|
|
73145
73270
|
if (closed || opts?.signal?.aborted) {
|
|
73146
73271
|
return Promise.resolve(defaultValue);
|
|
73147
73272
|
}
|
|
73148
|
-
const id =
|
|
73273
|
+
const id = randomUUID15();
|
|
73149
73274
|
return new Promise((resolve26) => {
|
|
73150
73275
|
let timeout;
|
|
73151
73276
|
const cleanup = () => {
|
|
@@ -73170,7 +73295,7 @@ function createRpcExtensionUiBridge(output) {
|
|
|
73170
73295
|
});
|
|
73171
73296
|
};
|
|
73172
73297
|
const fireAndForget = (request) => {
|
|
73173
|
-
output({ type: "extension_ui_request", id:
|
|
73298
|
+
output({ type: "extension_ui_request", id: randomUUID15(), ...request });
|
|
73174
73299
|
};
|
|
73175
73300
|
const uiContext = {
|
|
73176
73301
|
select: (title, options, opts) => createDialogPromise(opts, void 0, { method: "select", title, options, timeout: opts?.timeout }, (response) => "cancelled" in response && response.cancelled ? void 0 : "value" in response ? response.value : void 0),
|