@chosengeneration/light-code 0.69.0 → 0.70.0
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/dist/cli.js +740 -188
- package/dist/client/client.js +25 -25
- package/dist/server.js +735 -186
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -15482,7 +15482,7 @@ var require_events = __commonJS({
|
|
|
15482
15482
|
var { webidl } = require_webidl();
|
|
15483
15483
|
var { kEnumerableProperty } = require_util();
|
|
15484
15484
|
var { MessagePort } = __require("worker_threads");
|
|
15485
|
-
var
|
|
15485
|
+
var MessageEvent2 = class _MessageEvent extends Event {
|
|
15486
15486
|
#eventInit;
|
|
15487
15487
|
constructor(type, eventInitDict = {}) {
|
|
15488
15488
|
webidl.argumentLengthCheck(arguments, 1, { header: "MessageEvent constructor" });
|
|
@@ -15550,7 +15550,7 @@ var require_events = __commonJS({
|
|
|
15550
15550
|
return this.#eventInit.reason;
|
|
15551
15551
|
}
|
|
15552
15552
|
};
|
|
15553
|
-
var
|
|
15553
|
+
var ErrorEvent2 = class _ErrorEvent extends Event {
|
|
15554
15554
|
#eventInit;
|
|
15555
15555
|
constructor(type, eventInitDict) {
|
|
15556
15556
|
webidl.argumentLengthCheck(arguments, 1, { header: "ErrorEvent constructor" });
|
|
@@ -15580,7 +15580,7 @@ var require_events = __commonJS({
|
|
|
15580
15580
|
return this.#eventInit.error;
|
|
15581
15581
|
}
|
|
15582
15582
|
};
|
|
15583
|
-
Object.defineProperties(
|
|
15583
|
+
Object.defineProperties(MessageEvent2.prototype, {
|
|
15584
15584
|
[Symbol.toStringTag]: {
|
|
15585
15585
|
value: "MessageEvent",
|
|
15586
15586
|
configurable: true
|
|
@@ -15601,7 +15601,7 @@ var require_events = __commonJS({
|
|
|
15601
15601
|
code: kEnumerableProperty,
|
|
15602
15602
|
wasClean: kEnumerableProperty
|
|
15603
15603
|
});
|
|
15604
|
-
Object.defineProperties(
|
|
15604
|
+
Object.defineProperties(ErrorEvent2.prototype, {
|
|
15605
15605
|
[Symbol.toStringTag]: {
|
|
15606
15606
|
value: "ErrorEvent",
|
|
15607
15607
|
configurable: true
|
|
@@ -15711,9 +15711,9 @@ var require_events = __commonJS({
|
|
|
15711
15711
|
}
|
|
15712
15712
|
]);
|
|
15713
15713
|
module.exports = {
|
|
15714
|
-
MessageEvent,
|
|
15714
|
+
MessageEvent: MessageEvent2,
|
|
15715
15715
|
CloseEvent,
|
|
15716
|
-
ErrorEvent
|
|
15716
|
+
ErrorEvent: ErrorEvent2
|
|
15717
15717
|
};
|
|
15718
15718
|
}
|
|
15719
15719
|
});
|
|
@@ -15724,7 +15724,7 @@ var require_util7 = __commonJS({
|
|
|
15724
15724
|
"use strict";
|
|
15725
15725
|
var { kReadyState, kController, kResponse, kBinaryType, kWebSocketURL } = require_symbols5();
|
|
15726
15726
|
var { states, opcodes } = require_constants5();
|
|
15727
|
-
var { MessageEvent, ErrorEvent } = require_events();
|
|
15727
|
+
var { MessageEvent: MessageEvent2, ErrorEvent: ErrorEvent2 } = require_events();
|
|
15728
15728
|
function isEstablished(ws) {
|
|
15729
15729
|
return ws[kReadyState] === states.OPEN;
|
|
15730
15730
|
}
|
|
@@ -15757,7 +15757,7 @@ var require_util7 = __commonJS({
|
|
|
15757
15757
|
dataForEvent = new Uint8Array(data).buffer;
|
|
15758
15758
|
}
|
|
15759
15759
|
}
|
|
15760
|
-
fireEvent("message", ws,
|
|
15760
|
+
fireEvent("message", ws, MessageEvent2, {
|
|
15761
15761
|
origin: ws[kWebSocketURL].origin,
|
|
15762
15762
|
data: dataForEvent
|
|
15763
15763
|
});
|
|
@@ -15790,7 +15790,7 @@ var require_util7 = __commonJS({
|
|
|
15790
15790
|
response.socket.destroy();
|
|
15791
15791
|
}
|
|
15792
15792
|
if (reason) {
|
|
15793
|
-
fireEvent("error", ws,
|
|
15793
|
+
fireEvent("error", ws, ErrorEvent2, {
|
|
15794
15794
|
error: new Error(reason)
|
|
15795
15795
|
});
|
|
15796
15796
|
}
|
|
@@ -39442,6 +39442,19 @@ var stdioServerSchema = external_exports.object({
|
|
|
39442
39442
|
});
|
|
39443
39443
|
var httpServerSchema = external_exports.object({
|
|
39444
39444
|
url: external_exports.string().min(1).url(),
|
|
39445
|
+
/**
|
|
39446
|
+
* Which HTTP transport this server speaks.
|
|
39447
|
+
*
|
|
39448
|
+
* **It was not here, and zod strips what it does not declare** — so a config pasted from
|
|
39449
|
+
* another client saying `"type": "sse"` parsed happily, lost that word, and was then driven
|
|
39450
|
+
* with Streamable HTTP. §11 requires a pasted config to work unchanged, and this is the one
|
|
39451
|
+
* field that decides whether it works at all. Reported from real use as a remote server that
|
|
39452
|
+
* another client talks to and this one gets 401 from.
|
|
39453
|
+
*
|
|
39454
|
+
* Absent means "work it out" — see `buildTransport`. `http` is accepted as a spelling of
|
|
39455
|
+
* `streamable-http` because both appear in the wild.
|
|
39456
|
+
*/
|
|
39457
|
+
type: external_exports.enum(["sse", "streamable-http", "http"]).optional(),
|
|
39445
39458
|
headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
39446
39459
|
disabled: external_exports.boolean().optional(),
|
|
39447
39460
|
disabledTools: external_exports.array(external_exports.string()).optional(),
|
|
@@ -54213,21 +54226,477 @@ var StdioClientTransport = class {
|
|
|
54213
54226
|
}
|
|
54214
54227
|
};
|
|
54215
54228
|
|
|
54216
|
-
// ../../node_modules/.pnpm
|
|
54217
|
-
var
|
|
54218
|
-
|
|
54219
|
-
|
|
54220
|
-
return void 0;
|
|
54229
|
+
// ../../node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/index.js
|
|
54230
|
+
var ParseError = class extends Error {
|
|
54231
|
+
constructor(message3, options) {
|
|
54232
|
+
super(message3), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
54221
54233
|
}
|
|
54222
|
-
|
|
54223
|
-
|
|
54224
|
-
|
|
54225
|
-
|
|
54226
|
-
|
|
54227
|
-
|
|
54234
|
+
};
|
|
54235
|
+
var LF = 10;
|
|
54236
|
+
var CR = 13;
|
|
54237
|
+
var SPACE = 32;
|
|
54238
|
+
function noop(_arg) {
|
|
54239
|
+
}
|
|
54240
|
+
function createParser(config2) {
|
|
54241
|
+
if (typeof config2 == "function")
|
|
54242
|
+
throw new TypeError(
|
|
54243
|
+
"`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"
|
|
54244
|
+
);
|
|
54245
|
+
const { onEvent = noop, onError = noop, onRetry = noop, onComment, maxBufferSize } = config2, pendingFragments = [];
|
|
54246
|
+
let pendingFragmentsLength = 0, isFirstChunk = true, id, data = "", dataLines = 0, eventType, terminated = false;
|
|
54247
|
+
function feed(chunk) {
|
|
54248
|
+
if (terminated)
|
|
54249
|
+
throw new Error(
|
|
54250
|
+
"Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."
|
|
54251
|
+
);
|
|
54252
|
+
if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
54253
|
+
const trailing2 = processLines(chunk);
|
|
54254
|
+
trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
|
|
54255
|
+
return;
|
|
54228
54256
|
}
|
|
54229
|
-
|
|
54257
|
+
if (chunk.indexOf(`
|
|
54258
|
+
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
54259
|
+
pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
|
|
54260
|
+
return;
|
|
54261
|
+
}
|
|
54262
|
+
pendingFragments.push(chunk);
|
|
54263
|
+
const input = pendingFragments.join("");
|
|
54264
|
+
pendingFragments.length = 0, pendingFragmentsLength = 0;
|
|
54265
|
+
const trailing = processLines(input);
|
|
54266
|
+
trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
|
|
54267
|
+
}
|
|
54268
|
+
function checkBufferSize() {
|
|
54269
|
+
maxBufferSize !== void 0 && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = true, pendingFragments.length = 0, pendingFragmentsLength = 0, id = void 0, data = "", dataLines = 0, eventType = void 0, onError(
|
|
54270
|
+
new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {
|
|
54271
|
+
type: "max-buffer-size-exceeded"
|
|
54272
|
+
})
|
|
54273
|
+
)));
|
|
54274
|
+
}
|
|
54275
|
+
function processLines(chunk) {
|
|
54276
|
+
let searchIndex = 0;
|
|
54277
|
+
if (chunk.indexOf("\r") === -1) {
|
|
54278
|
+
let lfIndex = chunk.indexOf(`
|
|
54279
|
+
`, searchIndex);
|
|
54280
|
+
for (; lfIndex !== -1; ) {
|
|
54281
|
+
if (searchIndex === lfIndex) {
|
|
54282
|
+
dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
54283
|
+
`, searchIndex);
|
|
54284
|
+
continue;
|
|
54285
|
+
}
|
|
54286
|
+
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
54287
|
+
if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
|
|
54288
|
+
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
54289
|
+
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
|
|
54290
|
+
onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
54291
|
+
`, searchIndex);
|
|
54292
|
+
continue;
|
|
54293
|
+
}
|
|
54294
|
+
data = dataLines === 0 ? value : `${data}
|
|
54295
|
+
${value}`, dataLines++;
|
|
54296
|
+
} else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
54297
|
+
chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
|
|
54298
|
+
lfIndex
|
|
54299
|
+
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
54300
|
+
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
54301
|
+
`, searchIndex);
|
|
54302
|
+
}
|
|
54303
|
+
return chunk.slice(searchIndex);
|
|
54304
|
+
}
|
|
54305
|
+
for (; searchIndex < chunk.length; ) {
|
|
54306
|
+
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
54307
|
+
`, searchIndex);
|
|
54308
|
+
let lineEnd = -1;
|
|
54309
|
+
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = crIndex < lfIndex ? crIndex : lfIndex : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1)
|
|
54310
|
+
break;
|
|
54311
|
+
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
|
|
54312
|
+
}
|
|
54313
|
+
return chunk.slice(searchIndex);
|
|
54314
|
+
}
|
|
54315
|
+
function parseLine(chunk, start, end) {
|
|
54316
|
+
if (start === end) {
|
|
54317
|
+
dispatchEvent();
|
|
54318
|
+
return;
|
|
54319
|
+
}
|
|
54320
|
+
const firstCharCode = chunk.charCodeAt(start);
|
|
54321
|
+
if (isDataPrefix(chunk, start, firstCharCode)) {
|
|
54322
|
+
const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
54323
|
+
data = dataLines === 0 ? value2 : `${data}
|
|
54324
|
+
${value2}`, dataLines++;
|
|
54325
|
+
return;
|
|
54326
|
+
}
|
|
54327
|
+
if (isEventPrefix(chunk, start, firstCharCode)) {
|
|
54328
|
+
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
|
|
54329
|
+
return;
|
|
54330
|
+
}
|
|
54331
|
+
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
54332
|
+
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
54333
|
+
id = value2.includes("\0") ? void 0 : value2;
|
|
54334
|
+
return;
|
|
54335
|
+
}
|
|
54336
|
+
if (firstCharCode === 58) {
|
|
54337
|
+
if (onComment) {
|
|
54338
|
+
const line2 = chunk.slice(start, end);
|
|
54339
|
+
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
|
|
54340
|
+
}
|
|
54341
|
+
return;
|
|
54342
|
+
}
|
|
54343
|
+
const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
|
|
54344
|
+
if (fieldSeparatorIndex === -1) {
|
|
54345
|
+
processField(line, "", line);
|
|
54346
|
+
return;
|
|
54347
|
+
}
|
|
54348
|
+
const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
54349
|
+
processField(field, value, line);
|
|
54230
54350
|
}
|
|
54351
|
+
function processField(field, value, line) {
|
|
54352
|
+
switch (field) {
|
|
54353
|
+
case "event":
|
|
54354
|
+
eventType = value || void 0;
|
|
54355
|
+
break;
|
|
54356
|
+
case "data":
|
|
54357
|
+
data = dataLines === 0 ? value : `${data}
|
|
54358
|
+
${value}`, dataLines++;
|
|
54359
|
+
break;
|
|
54360
|
+
case "id":
|
|
54361
|
+
id = value.includes("\0") ? void 0 : value;
|
|
54362
|
+
break;
|
|
54363
|
+
case "retry":
|
|
54364
|
+
/^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
|
|
54365
|
+
new ParseError(`Invalid \`retry\` value: "${value}"`, {
|
|
54366
|
+
type: "invalid-retry",
|
|
54367
|
+
value,
|
|
54368
|
+
line
|
|
54369
|
+
})
|
|
54370
|
+
);
|
|
54371
|
+
break;
|
|
54372
|
+
default:
|
|
54373
|
+
onError(
|
|
54374
|
+
new ParseError(
|
|
54375
|
+
`Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,
|
|
54376
|
+
{ type: "unknown-field", field, value, line }
|
|
54377
|
+
)
|
|
54378
|
+
);
|
|
54379
|
+
break;
|
|
54380
|
+
}
|
|
54381
|
+
}
|
|
54382
|
+
function dispatchEvent() {
|
|
54383
|
+
dataLines > 0 && onEvent({
|
|
54384
|
+
id,
|
|
54385
|
+
event: eventType,
|
|
54386
|
+
data
|
|
54387
|
+
}), id = void 0, data = "", dataLines = 0, eventType = void 0;
|
|
54388
|
+
}
|
|
54389
|
+
function reset(options = {}) {
|
|
54390
|
+
if (options.consume && pendingFragments.length > 0) {
|
|
54391
|
+
const incompleteLine = pendingFragments.join("");
|
|
54392
|
+
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
54393
|
+
}
|
|
54394
|
+
isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = false;
|
|
54395
|
+
}
|
|
54396
|
+
return { feed, reset };
|
|
54397
|
+
}
|
|
54398
|
+
function isDataPrefix(chunk, i, firstCharCode) {
|
|
54399
|
+
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
54400
|
+
}
|
|
54401
|
+
function isEventPrefix(chunk, i, firstCharCode) {
|
|
54402
|
+
return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
|
|
54403
|
+
}
|
|
54404
|
+
|
|
54405
|
+
// ../../node_modules/.pnpm/eventsource@3.0.7/node_modules/eventsource/dist/index.js
|
|
54406
|
+
var ErrorEvent = class extends Event {
|
|
54407
|
+
/**
|
|
54408
|
+
* Constructs a new `ErrorEvent` instance. This is typically not called directly,
|
|
54409
|
+
* but rather emitted by the `EventSource` object when an error occurs.
|
|
54410
|
+
*
|
|
54411
|
+
* @param type - The type of the event (should be "error")
|
|
54412
|
+
* @param errorEventInitDict - Optional properties to include in the error event
|
|
54413
|
+
*/
|
|
54414
|
+
constructor(type, errorEventInitDict) {
|
|
54415
|
+
var _a3, _b;
|
|
54416
|
+
super(type), this.code = (_a3 = errorEventInitDict == null ? void 0 : errorEventInitDict.code) != null ? _a3 : void 0, this.message = (_b = errorEventInitDict == null ? void 0 : errorEventInitDict.message) != null ? _b : void 0;
|
|
54417
|
+
}
|
|
54418
|
+
/**
|
|
54419
|
+
* Node.js "hides" the `message` and `code` properties of the `ErrorEvent` instance,
|
|
54420
|
+
* when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
|
|
54421
|
+
* we explicitly include the properties in the `inspect` method.
|
|
54422
|
+
*
|
|
54423
|
+
* This is automatically called by Node.js when you `console.log` an instance of this class.
|
|
54424
|
+
*
|
|
54425
|
+
* @param _depth - The current depth
|
|
54426
|
+
* @param options - The options passed to `util.inspect`
|
|
54427
|
+
* @param inspect - The inspect function to use (prevents having to import it from `util`)
|
|
54428
|
+
* @returns A string representation of the error
|
|
54429
|
+
*/
|
|
54430
|
+
[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
|
|
54431
|
+
return inspect(inspectableError(this), options);
|
|
54432
|
+
}
|
|
54433
|
+
/**
|
|
54434
|
+
* Deno "hides" the `message` and `code` properties of the `ErrorEvent` instance,
|
|
54435
|
+
* when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
|
|
54436
|
+
* we explicitly include the properties in the `inspect` method.
|
|
54437
|
+
*
|
|
54438
|
+
* This is automatically called by Deno when you `console.log` an instance of this class.
|
|
54439
|
+
*
|
|
54440
|
+
* @param inspect - The inspect function to use (prevents having to import it from `util`)
|
|
54441
|
+
* @param options - The options passed to `Deno.inspect`
|
|
54442
|
+
* @returns A string representation of the error
|
|
54443
|
+
*/
|
|
54444
|
+
[/* @__PURE__ */ Symbol.for("Deno.customInspect")](inspect, options) {
|
|
54445
|
+
return inspect(inspectableError(this), options);
|
|
54446
|
+
}
|
|
54447
|
+
};
|
|
54448
|
+
function syntaxError(message3) {
|
|
54449
|
+
const DomException = globalThis.DOMException;
|
|
54450
|
+
return typeof DomException == "function" ? new DomException(message3, "SyntaxError") : new SyntaxError(message3);
|
|
54451
|
+
}
|
|
54452
|
+
function flattenError2(err) {
|
|
54453
|
+
return err instanceof Error ? "errors" in err && Array.isArray(err.errors) ? err.errors.map(flattenError2).join(", ") : "cause" in err && err.cause instanceof Error ? `${err}: ${flattenError2(err.cause)}` : err.message : `${err}`;
|
|
54454
|
+
}
|
|
54455
|
+
function inspectableError(err) {
|
|
54456
|
+
return {
|
|
54457
|
+
type: err.type,
|
|
54458
|
+
message: err.message,
|
|
54459
|
+
code: err.code,
|
|
54460
|
+
defaultPrevented: err.defaultPrevented,
|
|
54461
|
+
cancelable: err.cancelable,
|
|
54462
|
+
timeStamp: err.timeStamp
|
|
54463
|
+
};
|
|
54464
|
+
}
|
|
54465
|
+
var __typeError = (msg) => {
|
|
54466
|
+
throw TypeError(msg);
|
|
54467
|
+
};
|
|
54468
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
54469
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
54470
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
54471
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
54472
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
54473
|
+
var _readyState;
|
|
54474
|
+
var _url2;
|
|
54475
|
+
var _redirectUrl;
|
|
54476
|
+
var _withCredentials;
|
|
54477
|
+
var _fetch;
|
|
54478
|
+
var _reconnectInterval;
|
|
54479
|
+
var _reconnectTimer;
|
|
54480
|
+
var _lastEventId;
|
|
54481
|
+
var _controller;
|
|
54482
|
+
var _parser;
|
|
54483
|
+
var _onError;
|
|
54484
|
+
var _onMessage;
|
|
54485
|
+
var _onOpen;
|
|
54486
|
+
var _EventSource_instances;
|
|
54487
|
+
var connect_fn;
|
|
54488
|
+
var _onFetchResponse;
|
|
54489
|
+
var _onFetchError;
|
|
54490
|
+
var getRequestOptions_fn;
|
|
54491
|
+
var _onEvent;
|
|
54492
|
+
var _onRetryChange;
|
|
54493
|
+
var failConnection_fn;
|
|
54494
|
+
var scheduleReconnect_fn;
|
|
54495
|
+
var _reconnect;
|
|
54496
|
+
var EventSource = class extends EventTarget {
|
|
54497
|
+
constructor(url2, eventSourceInitDict) {
|
|
54498
|
+
var _a3, _b;
|
|
54499
|
+
super(), __privateAdd(this, _EventSource_instances), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, __privateAdd(this, _readyState), __privateAdd(this, _url2), __privateAdd(this, _redirectUrl), __privateAdd(this, _withCredentials), __privateAdd(this, _fetch), __privateAdd(this, _reconnectInterval), __privateAdd(this, _reconnectTimer), __privateAdd(this, _lastEventId, null), __privateAdd(this, _controller), __privateAdd(this, _parser), __privateAdd(this, _onError, null), __privateAdd(this, _onMessage, null), __privateAdd(this, _onOpen, null), __privateAdd(this, _onFetchResponse, async (response) => {
|
|
54500
|
+
var _a22;
|
|
54501
|
+
__privateGet(this, _parser).reset();
|
|
54502
|
+
const { body, redirected, status, headers } = response;
|
|
54503
|
+
if (status === 204) {
|
|
54504
|
+
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
|
|
54505
|
+
return;
|
|
54506
|
+
}
|
|
54507
|
+
if (redirected ? __privateSet(this, _redirectUrl, new URL(response.url)) : __privateSet(this, _redirectUrl, void 0), status !== 200) {
|
|
54508
|
+
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, `Non-200 status code (${status})`, status);
|
|
54509
|
+
return;
|
|
54510
|
+
}
|
|
54511
|
+
if (!(headers.get("content-type") || "").startsWith("text/event-stream")) {
|
|
54512
|
+
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, 'Invalid content type, expected "text/event-stream"', status);
|
|
54513
|
+
return;
|
|
54514
|
+
}
|
|
54515
|
+
if (__privateGet(this, _readyState) === this.CLOSED)
|
|
54516
|
+
return;
|
|
54517
|
+
__privateSet(this, _readyState, this.OPEN);
|
|
54518
|
+
const openEvent = new Event("open");
|
|
54519
|
+
if ((_a22 = __privateGet(this, _onOpen)) == null || _a22.call(this, openEvent), this.dispatchEvent(openEvent), typeof body != "object" || !body || !("getReader" in body)) {
|
|
54520
|
+
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Invalid response body, expected a web ReadableStream", status), this.close();
|
|
54521
|
+
return;
|
|
54522
|
+
}
|
|
54523
|
+
const decoder = new TextDecoder(), reader = body.getReader();
|
|
54524
|
+
let open = true;
|
|
54525
|
+
do {
|
|
54526
|
+
const { done, value } = await reader.read();
|
|
54527
|
+
value && __privateGet(this, _parser).feed(decoder.decode(value, { stream: !done })), done && (open = false, __privateGet(this, _parser).reset(), __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this));
|
|
54528
|
+
} while (open);
|
|
54529
|
+
}), __privateAdd(this, _onFetchError, (err) => {
|
|
54530
|
+
__privateSet(this, _controller, void 0), !(err.name === "AbortError" || err.type === "aborted") && __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this, flattenError2(err));
|
|
54531
|
+
}), __privateAdd(this, _onEvent, (event) => {
|
|
54532
|
+
typeof event.id == "string" && __privateSet(this, _lastEventId, event.id);
|
|
54533
|
+
const messageEvent = new MessageEvent(event.event || "message", {
|
|
54534
|
+
data: event.data,
|
|
54535
|
+
origin: __privateGet(this, _redirectUrl) ? __privateGet(this, _redirectUrl).origin : __privateGet(this, _url2).origin,
|
|
54536
|
+
lastEventId: event.id || ""
|
|
54537
|
+
});
|
|
54538
|
+
__privateGet(this, _onMessage) && (!event.event || event.event === "message") && __privateGet(this, _onMessage).call(this, messageEvent), this.dispatchEvent(messageEvent);
|
|
54539
|
+
}), __privateAdd(this, _onRetryChange, (value) => {
|
|
54540
|
+
__privateSet(this, _reconnectInterval, value);
|
|
54541
|
+
}), __privateAdd(this, _reconnect, () => {
|
|
54542
|
+
__privateSet(this, _reconnectTimer, void 0), __privateGet(this, _readyState) === this.CONNECTING && __privateMethod(this, _EventSource_instances, connect_fn).call(this);
|
|
54543
|
+
});
|
|
54544
|
+
try {
|
|
54545
|
+
if (url2 instanceof URL)
|
|
54546
|
+
__privateSet(this, _url2, url2);
|
|
54547
|
+
else if (typeof url2 == "string")
|
|
54548
|
+
__privateSet(this, _url2, new URL(url2, getBaseURL()));
|
|
54549
|
+
else
|
|
54550
|
+
throw new Error("Invalid URL");
|
|
54551
|
+
} catch {
|
|
54552
|
+
throw syntaxError("An invalid or illegal string was specified");
|
|
54553
|
+
}
|
|
54554
|
+
__privateSet(this, _parser, createParser({
|
|
54555
|
+
onEvent: __privateGet(this, _onEvent),
|
|
54556
|
+
onRetry: __privateGet(this, _onRetryChange)
|
|
54557
|
+
})), __privateSet(this, _readyState, this.CONNECTING), __privateSet(this, _reconnectInterval, 3e3), __privateSet(this, _fetch, (_a3 = eventSourceInitDict == null ? void 0 : eventSourceInitDict.fetch) != null ? _a3 : globalThis.fetch), __privateSet(this, _withCredentials, (_b = eventSourceInitDict == null ? void 0 : eventSourceInitDict.withCredentials) != null ? _b : false), __privateMethod(this, _EventSource_instances, connect_fn).call(this);
|
|
54558
|
+
}
|
|
54559
|
+
/**
|
|
54560
|
+
* Returns the state of this EventSource object's connection. It can have the values described below.
|
|
54561
|
+
*
|
|
54562
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
|
|
54563
|
+
*
|
|
54564
|
+
* Note: typed as `number` instead of `0 | 1 | 2` for compatibility with the `EventSource` interface,
|
|
54565
|
+
* defined in the TypeScript `dom` library.
|
|
54566
|
+
*
|
|
54567
|
+
* @public
|
|
54568
|
+
*/
|
|
54569
|
+
get readyState() {
|
|
54570
|
+
return __privateGet(this, _readyState);
|
|
54571
|
+
}
|
|
54572
|
+
/**
|
|
54573
|
+
* Returns the URL providing the event stream.
|
|
54574
|
+
*
|
|
54575
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
|
|
54576
|
+
*
|
|
54577
|
+
* @public
|
|
54578
|
+
*/
|
|
54579
|
+
get url() {
|
|
54580
|
+
return __privateGet(this, _url2).href;
|
|
54581
|
+
}
|
|
54582
|
+
/**
|
|
54583
|
+
* Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
|
|
54584
|
+
*
|
|
54585
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
|
|
54586
|
+
*/
|
|
54587
|
+
get withCredentials() {
|
|
54588
|
+
return __privateGet(this, _withCredentials);
|
|
54589
|
+
}
|
|
54590
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
|
54591
|
+
get onerror() {
|
|
54592
|
+
return __privateGet(this, _onError);
|
|
54593
|
+
}
|
|
54594
|
+
set onerror(value) {
|
|
54595
|
+
__privateSet(this, _onError, value);
|
|
54596
|
+
}
|
|
54597
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
|
|
54598
|
+
get onmessage() {
|
|
54599
|
+
return __privateGet(this, _onMessage);
|
|
54600
|
+
}
|
|
54601
|
+
set onmessage(value) {
|
|
54602
|
+
__privateSet(this, _onMessage, value);
|
|
54603
|
+
}
|
|
54604
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
|
|
54605
|
+
get onopen() {
|
|
54606
|
+
return __privateGet(this, _onOpen);
|
|
54607
|
+
}
|
|
54608
|
+
set onopen(value) {
|
|
54609
|
+
__privateSet(this, _onOpen, value);
|
|
54610
|
+
}
|
|
54611
|
+
addEventListener(type, listener, options) {
|
|
54612
|
+
const listen = listener;
|
|
54613
|
+
super.addEventListener(type, listen, options);
|
|
54614
|
+
}
|
|
54615
|
+
removeEventListener(type, listener, options) {
|
|
54616
|
+
const listen = listener;
|
|
54617
|
+
super.removeEventListener(type, listen, options);
|
|
54618
|
+
}
|
|
54619
|
+
/**
|
|
54620
|
+
* Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
|
|
54621
|
+
*
|
|
54622
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
|
|
54623
|
+
*
|
|
54624
|
+
* @public
|
|
54625
|
+
*/
|
|
54626
|
+
close() {
|
|
54627
|
+
__privateGet(this, _reconnectTimer) && clearTimeout(__privateGet(this, _reconnectTimer)), __privateGet(this, _readyState) !== this.CLOSED && (__privateGet(this, _controller) && __privateGet(this, _controller).abort(), __privateSet(this, _readyState, this.CLOSED), __privateSet(this, _controller, void 0));
|
|
54628
|
+
}
|
|
54629
|
+
};
|
|
54630
|
+
_readyState = /* @__PURE__ */ new WeakMap(), _url2 = /* @__PURE__ */ new WeakMap(), _redirectUrl = /* @__PURE__ */ new WeakMap(), _withCredentials = /* @__PURE__ */ new WeakMap(), _fetch = /* @__PURE__ */ new WeakMap(), _reconnectInterval = /* @__PURE__ */ new WeakMap(), _reconnectTimer = /* @__PURE__ */ new WeakMap(), _lastEventId = /* @__PURE__ */ new WeakMap(), _controller = /* @__PURE__ */ new WeakMap(), _parser = /* @__PURE__ */ new WeakMap(), _onError = /* @__PURE__ */ new WeakMap(), _onMessage = /* @__PURE__ */ new WeakMap(), _onOpen = /* @__PURE__ */ new WeakMap(), _EventSource_instances = /* @__PURE__ */ new WeakSet(), /**
|
|
54631
|
+
* Connect to the given URL and start receiving events
|
|
54632
|
+
*
|
|
54633
|
+
* @internal
|
|
54634
|
+
*/
|
|
54635
|
+
connect_fn = function() {
|
|
54636
|
+
__privateSet(this, _readyState, this.CONNECTING), __privateSet(this, _controller, new AbortController()), __privateGet(this, _fetch)(__privateGet(this, _url2), __privateMethod(this, _EventSource_instances, getRequestOptions_fn).call(this)).then(__privateGet(this, _onFetchResponse)).catch(__privateGet(this, _onFetchError));
|
|
54637
|
+
}, _onFetchResponse = /* @__PURE__ */ new WeakMap(), _onFetchError = /* @__PURE__ */ new WeakMap(), /**
|
|
54638
|
+
* Get request options for the `fetch()` request
|
|
54639
|
+
*
|
|
54640
|
+
* @returns The request options
|
|
54641
|
+
* @internal
|
|
54642
|
+
*/
|
|
54643
|
+
getRequestOptions_fn = function() {
|
|
54644
|
+
var _a3;
|
|
54645
|
+
const init = {
|
|
54646
|
+
// [spec] Let `corsAttributeState` be `Anonymous`…
|
|
54647
|
+
// [spec] …will have their mode set to "cors"…
|
|
54648
|
+
mode: "cors",
|
|
54649
|
+
redirect: "follow",
|
|
54650
|
+
headers: { Accept: "text/event-stream", ...__privateGet(this, _lastEventId) ? { "Last-Event-ID": __privateGet(this, _lastEventId) } : void 0 },
|
|
54651
|
+
cache: "no-store",
|
|
54652
|
+
signal: (_a3 = __privateGet(this, _controller)) == null ? void 0 : _a3.signal
|
|
54653
|
+
};
|
|
54654
|
+
return "window" in globalThis && (init.credentials = this.withCredentials ? "include" : "same-origin"), init;
|
|
54655
|
+
}, _onEvent = /* @__PURE__ */ new WeakMap(), _onRetryChange = /* @__PURE__ */ new WeakMap(), /**
|
|
54656
|
+
* Handles the process referred to in the EventSource specification as "failing a connection".
|
|
54657
|
+
*
|
|
54658
|
+
* @param error - The error causing the connection to fail
|
|
54659
|
+
* @param code - The HTTP status code, if available
|
|
54660
|
+
* @internal
|
|
54661
|
+
*/
|
|
54662
|
+
failConnection_fn = function(message3, code) {
|
|
54663
|
+
var _a3;
|
|
54664
|
+
__privateGet(this, _readyState) !== this.CLOSED && __privateSet(this, _readyState, this.CLOSED);
|
|
54665
|
+
const errorEvent = new ErrorEvent("error", { code, message: message3 });
|
|
54666
|
+
(_a3 = __privateGet(this, _onError)) == null || _a3.call(this, errorEvent), this.dispatchEvent(errorEvent);
|
|
54667
|
+
}, /**
|
|
54668
|
+
* Schedules a reconnection attempt against the EventSource endpoint.
|
|
54669
|
+
*
|
|
54670
|
+
* @param message - The error causing the connection to fail
|
|
54671
|
+
* @param code - The HTTP status code, if available
|
|
54672
|
+
* @internal
|
|
54673
|
+
*/
|
|
54674
|
+
scheduleReconnect_fn = function(message3, code) {
|
|
54675
|
+
var _a3;
|
|
54676
|
+
if (__privateGet(this, _readyState) === this.CLOSED)
|
|
54677
|
+
return;
|
|
54678
|
+
__privateSet(this, _readyState, this.CONNECTING);
|
|
54679
|
+
const errorEvent = new ErrorEvent("error", { code, message: message3 });
|
|
54680
|
+
(_a3 = __privateGet(this, _onError)) == null || _a3.call(this, errorEvent), this.dispatchEvent(errorEvent), __privateSet(this, _reconnectTimer, setTimeout(__privateGet(this, _reconnect), __privateGet(this, _reconnectInterval)));
|
|
54681
|
+
}, _reconnect = /* @__PURE__ */ new WeakMap(), /**
|
|
54682
|
+
* ReadyState representing an EventSource currently trying to connect
|
|
54683
|
+
*
|
|
54684
|
+
* @public
|
|
54685
|
+
*/
|
|
54686
|
+
EventSource.CONNECTING = 0, /**
|
|
54687
|
+
* ReadyState representing an EventSource connection that is open (eg connected)
|
|
54688
|
+
*
|
|
54689
|
+
* @public
|
|
54690
|
+
*/
|
|
54691
|
+
EventSource.OPEN = 1, /**
|
|
54692
|
+
* ReadyState representing an EventSource connection that is closed (eg disconnected)
|
|
54693
|
+
*
|
|
54694
|
+
* @public
|
|
54695
|
+
*/
|
|
54696
|
+
EventSource.CLOSED = 2;
|
|
54697
|
+
function getBaseURL() {
|
|
54698
|
+
const doc = "document" in globalThis ? globalThis.document : void 0;
|
|
54699
|
+
return doc && typeof doc == "object" && "baseURI" in doc && typeof doc.baseURI == "string" ? doc.baseURI : void 0;
|
|
54231
54700
|
}
|
|
54232
54701
|
|
|
54233
54702
|
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1_ed45788dfbfe808cc09dd7daea6bd385/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.js
|
|
@@ -55100,180 +55569,212 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
|
|
|
55100
55569
|
return OAuthClientInformationFullSchema.parse(await response.json());
|
|
55101
55570
|
}
|
|
55102
55571
|
|
|
55103
|
-
// ../../node_modules/.pnpm
|
|
55104
|
-
var
|
|
55105
|
-
constructor(message3,
|
|
55106
|
-
super(message3)
|
|
55572
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1_ed45788dfbfe808cc09dd7daea6bd385/node_modules/@modelcontextprotocol/sdk/dist/esm/client/sse.js
|
|
55573
|
+
var SseError = class extends Error {
|
|
55574
|
+
constructor(code, message3, event) {
|
|
55575
|
+
super(`SSE error: ${message3}`);
|
|
55576
|
+
this.code = code;
|
|
55577
|
+
this.event = event;
|
|
55107
55578
|
}
|
|
55108
55579
|
};
|
|
55109
|
-
var
|
|
55110
|
-
|
|
55111
|
-
|
|
55112
|
-
|
|
55113
|
-
|
|
55114
|
-
|
|
55115
|
-
|
|
55116
|
-
|
|
55117
|
-
|
|
55118
|
-
);
|
|
55119
|
-
|
|
55120
|
-
|
|
55121
|
-
|
|
55122
|
-
|
|
55123
|
-
throw new Error(
|
|
55124
|
-
"Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."
|
|
55125
|
-
);
|
|
55126
|
-
if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
55127
|
-
const trailing2 = processLines(chunk);
|
|
55128
|
-
trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
|
|
55129
|
-
return;
|
|
55580
|
+
var SSEClientTransport = class {
|
|
55581
|
+
constructor(url2, opts) {
|
|
55582
|
+
this._url = url2;
|
|
55583
|
+
this._resourceMetadataUrl = void 0;
|
|
55584
|
+
this._scope = void 0;
|
|
55585
|
+
this._eventSourceInit = opts?.eventSourceInit;
|
|
55586
|
+
this._requestInit = opts?.requestInit;
|
|
55587
|
+
this._authProvider = opts?.authProvider;
|
|
55588
|
+
this._fetch = opts?.fetch;
|
|
55589
|
+
this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
|
|
55590
|
+
}
|
|
55591
|
+
async _authThenStart() {
|
|
55592
|
+
if (!this._authProvider) {
|
|
55593
|
+
throw new UnauthorizedError("No auth provider");
|
|
55130
55594
|
}
|
|
55131
|
-
|
|
55132
|
-
|
|
55133
|
-
|
|
55134
|
-
|
|
55595
|
+
let result;
|
|
55596
|
+
try {
|
|
55597
|
+
result = await auth(this._authProvider, {
|
|
55598
|
+
serverUrl: this._url,
|
|
55599
|
+
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
55600
|
+
scope: this._scope,
|
|
55601
|
+
fetchFn: this._fetchWithInit
|
|
55602
|
+
});
|
|
55603
|
+
} catch (error51) {
|
|
55604
|
+
this.onerror?.(error51);
|
|
55605
|
+
throw error51;
|
|
55135
55606
|
}
|
|
55136
|
-
|
|
55137
|
-
|
|
55138
|
-
|
|
55139
|
-
|
|
55140
|
-
trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
|
|
55141
|
-
}
|
|
55142
|
-
function checkBufferSize() {
|
|
55143
|
-
maxBufferSize !== void 0 && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = true, pendingFragments.length = 0, pendingFragmentsLength = 0, id = void 0, data = "", dataLines = 0, eventType = void 0, onError(
|
|
55144
|
-
new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {
|
|
55145
|
-
type: "max-buffer-size-exceeded"
|
|
55146
|
-
})
|
|
55147
|
-
)));
|
|
55607
|
+
if (result !== "AUTHORIZED") {
|
|
55608
|
+
throw new UnauthorizedError();
|
|
55609
|
+
}
|
|
55610
|
+
return await this._startOrAuth();
|
|
55148
55611
|
}
|
|
55149
|
-
|
|
55150
|
-
|
|
55151
|
-
if (
|
|
55152
|
-
|
|
55153
|
-
|
|
55154
|
-
|
|
55155
|
-
if (searchIndex === lfIndex) {
|
|
55156
|
-
dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
55157
|
-
`, searchIndex);
|
|
55158
|
-
continue;
|
|
55159
|
-
}
|
|
55160
|
-
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
55161
|
-
if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
|
|
55162
|
-
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
55163
|
-
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
|
|
55164
|
-
onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
55165
|
-
`, searchIndex);
|
|
55166
|
-
continue;
|
|
55167
|
-
}
|
|
55168
|
-
data = dataLines === 0 ? value : `${data}
|
|
55169
|
-
${value}`, dataLines++;
|
|
55170
|
-
} else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
55171
|
-
chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
|
|
55172
|
-
lfIndex
|
|
55173
|
-
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
55174
|
-
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
55175
|
-
`, searchIndex);
|
|
55612
|
+
async _commonHeaders() {
|
|
55613
|
+
const headers = {};
|
|
55614
|
+
if (this._authProvider) {
|
|
55615
|
+
const tokens = await this._authProvider.tokens();
|
|
55616
|
+
if (tokens) {
|
|
55617
|
+
headers["Authorization"] = `Bearer ${tokens.access_token}`;
|
|
55176
55618
|
}
|
|
55177
|
-
return chunk.slice(searchIndex);
|
|
55178
55619
|
}
|
|
55179
|
-
|
|
55180
|
-
|
|
55181
|
-
`, searchIndex);
|
|
55182
|
-
let lineEnd = -1;
|
|
55183
|
-
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = crIndex < lfIndex ? crIndex : lfIndex : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1)
|
|
55184
|
-
break;
|
|
55185
|
-
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
|
|
55620
|
+
if (this._protocolVersion) {
|
|
55621
|
+
headers["mcp-protocol-version"] = this._protocolVersion;
|
|
55186
55622
|
}
|
|
55187
|
-
|
|
55623
|
+
const extraHeaders = normalizeHeaders(this._requestInit?.headers);
|
|
55624
|
+
return new Headers({
|
|
55625
|
+
...headers,
|
|
55626
|
+
...extraHeaders
|
|
55627
|
+
});
|
|
55188
55628
|
}
|
|
55189
|
-
|
|
55190
|
-
|
|
55191
|
-
|
|
55192
|
-
|
|
55629
|
+
_startOrAuth() {
|
|
55630
|
+
const fetchImpl = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
|
|
55631
|
+
return new Promise((resolve, reject2) => {
|
|
55632
|
+
this._eventSource = new EventSource(this._url.href, {
|
|
55633
|
+
...this._eventSourceInit,
|
|
55634
|
+
fetch: async (url2, init) => {
|
|
55635
|
+
const headers = await this._commonHeaders();
|
|
55636
|
+
headers.set("Accept", "text/event-stream");
|
|
55637
|
+
const response = await fetchImpl(url2, {
|
|
55638
|
+
...init,
|
|
55639
|
+
headers
|
|
55640
|
+
});
|
|
55641
|
+
if (response.status === 401 && response.headers.has("www-authenticate")) {
|
|
55642
|
+
const { resourceMetadataUrl, scope } = extractWWWAuthenticateParams(response);
|
|
55643
|
+
this._resourceMetadataUrl = resourceMetadataUrl;
|
|
55644
|
+
this._scope = scope;
|
|
55645
|
+
}
|
|
55646
|
+
return response;
|
|
55647
|
+
}
|
|
55648
|
+
});
|
|
55649
|
+
this._abortController = new AbortController();
|
|
55650
|
+
this._eventSource.onerror = (event) => {
|
|
55651
|
+
if (event.code === 401 && this._authProvider) {
|
|
55652
|
+
this._authThenStart().then(resolve, reject2);
|
|
55653
|
+
return;
|
|
55654
|
+
}
|
|
55655
|
+
const error51 = new SseError(event.code, event.message, event);
|
|
55656
|
+
reject2(error51);
|
|
55657
|
+
this.onerror?.(error51);
|
|
55658
|
+
};
|
|
55659
|
+
this._eventSource.onopen = () => {
|
|
55660
|
+
};
|
|
55661
|
+
this._eventSource.addEventListener("endpoint", (event) => {
|
|
55662
|
+
const messageEvent = event;
|
|
55663
|
+
try {
|
|
55664
|
+
this._endpoint = new URL(messageEvent.data, this._url);
|
|
55665
|
+
if (this._endpoint.origin !== this._url.origin) {
|
|
55666
|
+
throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`);
|
|
55667
|
+
}
|
|
55668
|
+
} catch (error51) {
|
|
55669
|
+
reject2(error51);
|
|
55670
|
+
this.onerror?.(error51);
|
|
55671
|
+
void this.close();
|
|
55672
|
+
return;
|
|
55673
|
+
}
|
|
55674
|
+
resolve();
|
|
55675
|
+
});
|
|
55676
|
+
this._eventSource.onmessage = (event) => {
|
|
55677
|
+
const messageEvent = event;
|
|
55678
|
+
let message3;
|
|
55679
|
+
try {
|
|
55680
|
+
message3 = JSONRPCMessageSchema.parse(JSON.parse(messageEvent.data));
|
|
55681
|
+
} catch (error51) {
|
|
55682
|
+
this.onerror?.(error51);
|
|
55683
|
+
return;
|
|
55684
|
+
}
|
|
55685
|
+
this.onmessage?.(message3);
|
|
55686
|
+
};
|
|
55687
|
+
});
|
|
55688
|
+
}
|
|
55689
|
+
async start() {
|
|
55690
|
+
if (this._eventSource) {
|
|
55691
|
+
throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");
|
|
55193
55692
|
}
|
|
55194
|
-
|
|
55195
|
-
|
|
55196
|
-
|
|
55197
|
-
|
|
55198
|
-
|
|
55199
|
-
|
|
55693
|
+
return await this._startOrAuth();
|
|
55694
|
+
}
|
|
55695
|
+
/**
|
|
55696
|
+
* Call this method after the user has finished authorizing via their user agent and is redirected back to the MCP client application. This will exchange the authorization code for an access token, enabling the next connection attempt to successfully auth.
|
|
55697
|
+
*/
|
|
55698
|
+
async finishAuth(authorizationCode) {
|
|
55699
|
+
if (!this._authProvider) {
|
|
55700
|
+
throw new UnauthorizedError("No auth provider");
|
|
55200
55701
|
}
|
|
55201
|
-
|
|
55202
|
-
|
|
55203
|
-
|
|
55702
|
+
const result = await auth(this._authProvider, {
|
|
55703
|
+
serverUrl: this._url,
|
|
55704
|
+
authorizationCode,
|
|
55705
|
+
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
55706
|
+
scope: this._scope,
|
|
55707
|
+
fetchFn: this._fetchWithInit
|
|
55708
|
+
});
|
|
55709
|
+
if (result !== "AUTHORIZED") {
|
|
55710
|
+
throw new UnauthorizedError("Failed to authorize");
|
|
55204
55711
|
}
|
|
55205
|
-
|
|
55206
|
-
|
|
55207
|
-
|
|
55208
|
-
|
|
55712
|
+
}
|
|
55713
|
+
async close() {
|
|
55714
|
+
this._abortController?.abort();
|
|
55715
|
+
this._eventSource?.close();
|
|
55716
|
+
this.onclose?.();
|
|
55717
|
+
}
|
|
55718
|
+
async send(message3) {
|
|
55719
|
+
if (!this._endpoint) {
|
|
55720
|
+
throw new Error("Not connected");
|
|
55209
55721
|
}
|
|
55210
|
-
|
|
55211
|
-
|
|
55212
|
-
|
|
55213
|
-
|
|
55722
|
+
try {
|
|
55723
|
+
const headers = await this._commonHeaders();
|
|
55724
|
+
headers.set("content-type", "application/json");
|
|
55725
|
+
const init = {
|
|
55726
|
+
...this._requestInit,
|
|
55727
|
+
method: "POST",
|
|
55728
|
+
headers,
|
|
55729
|
+
body: JSON.stringify(message3),
|
|
55730
|
+
signal: this._abortController?.signal
|
|
55731
|
+
};
|
|
55732
|
+
const response = await (this._fetch ?? fetch)(this._endpoint, init);
|
|
55733
|
+
if (!response.ok) {
|
|
55734
|
+
const text = await response.text().catch(() => null);
|
|
55735
|
+
if (response.status === 401 && this._authProvider) {
|
|
55736
|
+
const { resourceMetadataUrl, scope } = extractWWWAuthenticateParams(response);
|
|
55737
|
+
this._resourceMetadataUrl = resourceMetadataUrl;
|
|
55738
|
+
this._scope = scope;
|
|
55739
|
+
const result = await auth(this._authProvider, {
|
|
55740
|
+
serverUrl: this._url,
|
|
55741
|
+
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
55742
|
+
scope: this._scope,
|
|
55743
|
+
fetchFn: this._fetchWithInit
|
|
55744
|
+
});
|
|
55745
|
+
if (result !== "AUTHORIZED") {
|
|
55746
|
+
throw new UnauthorizedError();
|
|
55747
|
+
}
|
|
55748
|
+
return this.send(message3);
|
|
55749
|
+
}
|
|
55750
|
+
throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
|
|
55214
55751
|
}
|
|
55215
|
-
|
|
55216
|
-
}
|
|
55217
|
-
|
|
55218
|
-
|
|
55219
|
-
processField(line, "", line);
|
|
55220
|
-
return;
|
|
55752
|
+
await response.body?.cancel();
|
|
55753
|
+
} catch (error51) {
|
|
55754
|
+
this.onerror?.(error51);
|
|
55755
|
+
throw error51;
|
|
55221
55756
|
}
|
|
55222
|
-
const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
55223
|
-
processField(field, value, line);
|
|
55224
55757
|
}
|
|
55225
|
-
|
|
55226
|
-
|
|
55227
|
-
case "event":
|
|
55228
|
-
eventType = value || void 0;
|
|
55229
|
-
break;
|
|
55230
|
-
case "data":
|
|
55231
|
-
data = dataLines === 0 ? value : `${data}
|
|
55232
|
-
${value}`, dataLines++;
|
|
55233
|
-
break;
|
|
55234
|
-
case "id":
|
|
55235
|
-
id = value.includes("\0") ? void 0 : value;
|
|
55236
|
-
break;
|
|
55237
|
-
case "retry":
|
|
55238
|
-
/^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
|
|
55239
|
-
new ParseError(`Invalid \`retry\` value: "${value}"`, {
|
|
55240
|
-
type: "invalid-retry",
|
|
55241
|
-
value,
|
|
55242
|
-
line
|
|
55243
|
-
})
|
|
55244
|
-
);
|
|
55245
|
-
break;
|
|
55246
|
-
default:
|
|
55247
|
-
onError(
|
|
55248
|
-
new ParseError(
|
|
55249
|
-
`Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,
|
|
55250
|
-
{ type: "unknown-field", field, value, line }
|
|
55251
|
-
)
|
|
55252
|
-
);
|
|
55253
|
-
break;
|
|
55254
|
-
}
|
|
55758
|
+
setProtocolVersion(version2) {
|
|
55759
|
+
this._protocolVersion = version2;
|
|
55255
55760
|
}
|
|
55256
|
-
|
|
55257
|
-
|
|
55258
|
-
|
|
55259
|
-
|
|
55260
|
-
|
|
55261
|
-
|
|
55761
|
+
};
|
|
55762
|
+
|
|
55763
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1_ed45788dfbfe808cc09dd7daea6bd385/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
|
|
55764
|
+
var import_content_type = __toESM(require_content_type(), 1);
|
|
55765
|
+
function mediaTypeEssence(header) {
|
|
55766
|
+
if (!header) {
|
|
55767
|
+
return void 0;
|
|
55262
55768
|
}
|
|
55263
|
-
|
|
55264
|
-
|
|
55265
|
-
|
|
55266
|
-
|
|
55769
|
+
try {
|
|
55770
|
+
return import_content_type.default.parse(header).type;
|
|
55771
|
+
} catch {
|
|
55772
|
+
const essence = (header.split(";", 1)[0] ?? "").trim().toLowerCase();
|
|
55773
|
+
if (essence === "" || header.slice(essence.length).includes(",")) {
|
|
55774
|
+
return void 0;
|
|
55267
55775
|
}
|
|
55268
|
-
|
|
55776
|
+
return essence;
|
|
55269
55777
|
}
|
|
55270
|
-
return { feed, reset };
|
|
55271
|
-
}
|
|
55272
|
-
function isDataPrefix(chunk, i, firstCharCode) {
|
|
55273
|
-
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
55274
|
-
}
|
|
55275
|
-
function isEventPrefix(chunk, i, firstCharCode) {
|
|
55276
|
-
return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
|
|
55277
55778
|
}
|
|
55278
55779
|
|
|
55279
55780
|
// ../../node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/stream.js
|
|
@@ -55737,10 +56238,15 @@ async function buildTransport(config2, secrets) {
|
|
|
55737
56238
|
});
|
|
55738
56239
|
}
|
|
55739
56240
|
const headers = await interpolateSecrets(config2.headers, secrets);
|
|
55740
|
-
|
|
55741
|
-
|
|
55742
|
-
|
|
55743
|
-
return
|
|
56241
|
+
return httpTransport(config2.url, headers, httpKindOf(config2));
|
|
56242
|
+
}
|
|
56243
|
+
function httpKindOf(config2) {
|
|
56244
|
+
return config2.type === "sse" ? "sse" : "streamable-http";
|
|
56245
|
+
}
|
|
56246
|
+
function httpTransport(url2, headers, kind) {
|
|
56247
|
+
const options = Object.keys(headers).length > 0 ? { requestInit: { headers } } : {};
|
|
56248
|
+
const transport = kind === "sse" ? new SSEClientTransport(new URL(url2), options) : new StreamableHTTPClientTransport(new URL(url2), options);
|
|
56249
|
+
return transport;
|
|
55744
56250
|
}
|
|
55745
56251
|
var McpConnection = class {
|
|
55746
56252
|
serverName;
|
|
@@ -55769,10 +56275,30 @@ var McpConnection = class {
|
|
|
55769
56275
|
if (transport instanceof StdioClientTransport) {
|
|
55770
56276
|
this.attachStderr(transport);
|
|
55771
56277
|
}
|
|
55772
|
-
|
|
56278
|
+
try {
|
|
56279
|
+
await client.connect(transport);
|
|
56280
|
+
} catch (error51) {
|
|
56281
|
+
const fallback = await this.fallbackTransport(error51);
|
|
56282
|
+
if (fallback === void 0)
|
|
56283
|
+
throw error51;
|
|
56284
|
+
await client.connect(fallback);
|
|
56285
|
+
this.client = client;
|
|
56286
|
+
this.transport = fallback;
|
|
56287
|
+
this.onLog(`Connected over SSE; Streamable HTTP was refused (${describeError(error51)})`);
|
|
56288
|
+
return;
|
|
56289
|
+
}
|
|
55773
56290
|
this.client = client;
|
|
55774
56291
|
this.transport = transport;
|
|
55775
56292
|
}
|
|
56293
|
+
/** The other HTTP protocol, when this server never said which it speaks. */
|
|
56294
|
+
async fallbackTransport(error51) {
|
|
56295
|
+
const config2 = this.config;
|
|
56296
|
+
if (isStdioServer(config2) || config2.type !== void 0)
|
|
56297
|
+
return void 0;
|
|
56298
|
+
this.onLog(`Streamable HTTP failed (${describeError(error51)}) \u2014 retrying as SSE`);
|
|
56299
|
+
const headers = await interpolateSecrets(config2.headers, this.secrets);
|
|
56300
|
+
return httpTransport(config2.url, headers, "sse");
|
|
56301
|
+
}
|
|
55776
56302
|
attachStderr(transport) {
|
|
55777
56303
|
const stream = transport.stderr;
|
|
55778
56304
|
if (stream === null)
|
|
@@ -55829,6 +56355,9 @@ function renderToolResult(result) {
|
|
|
55829
56355
|
});
|
|
55830
56356
|
return parts.join("\n");
|
|
55831
56357
|
}
|
|
56358
|
+
function describeError(error51) {
|
|
56359
|
+
return error51 instanceof Error ? error51.message : String(error51);
|
|
56360
|
+
}
|
|
55832
56361
|
|
|
55833
56362
|
// ../../packages/core/dist/mcp/registry.js
|
|
55834
56363
|
function adaptTool(serverName, toolName, description, inputSchema, call) {
|
|
@@ -61508,7 +62037,7 @@ function stripEmpty(source) {
|
|
|
61508
62037
|
var SCHEDULE_TICK_MS = 15e3;
|
|
61509
62038
|
var STUCK_RUN_MS = 30 * 6e4;
|
|
61510
62039
|
function wireChatBridge(services) {
|
|
61511
|
-
const { transport, secrets, ui, workspaceRoot, storageDir
|
|
62040
|
+
const { transport, secrets, ui, workspaceRoot, storageDir } = services;
|
|
61512
62041
|
const logger = new Logger({ level: "debug", sink: services.logSink });
|
|
61513
62042
|
const configManager = new ConfigManager(services.configStore, services.workspaceRoot);
|
|
61514
62043
|
const httpClient = services.httpClient ?? new FetchHttpClient();
|
|
@@ -62839,9 +63368,17 @@ ${preview.text}` } : {}
|
|
|
62839
63368
|
// that stops to wait for one would never finish.
|
|
62840
63369
|
...schedule === void 0 ? { requestForm } : {},
|
|
62841
63370
|
signal: activeAbortController.signal,
|
|
62842
|
-
|
|
62843
|
-
|
|
62844
|
-
|
|
63371
|
+
/*
|
|
63372
|
+
* Supplied by the host, not imported by core: the binary is platform-specific and
|
|
63373
|
+
* lives in the VSIX, so resolving it is a host concern (§4).
|
|
63374
|
+
*
|
|
63375
|
+
* Asked per turn rather than captured once, because a VS Code extension update
|
|
63376
|
+
* deletes the folder the previous answer pointed into. See `HostServices`.
|
|
63377
|
+
*/
|
|
63378
|
+
...(() => {
|
|
63379
|
+
const resolved = services.ripgrepPath();
|
|
63380
|
+
return resolved !== void 0 ? { ripgrepPath: resolved } : {};
|
|
63381
|
+
})()
|
|
62845
63382
|
};
|
|
62846
63383
|
consultationContext = () => toolContext;
|
|
62847
63384
|
pythonNestedContext = toolContext;
|
|
@@ -64704,6 +65241,7 @@ ${direction}` : attachMentions(text, mentions);
|
|
|
64704
65241
|
});
|
|
64705
65242
|
}
|
|
64706
65243
|
async function ignoredFilesPredicate() {
|
|
65244
|
+
const ripgrepPath = services.ripgrepPath();
|
|
64707
65245
|
if (workspaceRoot === void 0 || ripgrepPath === void 0)
|
|
64708
65246
|
return void 0;
|
|
64709
65247
|
try {
|
|
@@ -68242,6 +68780,17 @@ ${output}${note}`,
|
|
|
68242
68780
|
|
|
68243
68781
|
// ../../packages/core/dist/tools/listFiles.js
|
|
68244
68782
|
import { execFile as execFile7 } from "node:child_process";
|
|
68783
|
+
|
|
68784
|
+
// ../../packages/core/dist/tools/ripgrepError.js
|
|
68785
|
+
function describeRipgrepFailure(error51, what) {
|
|
68786
|
+
const code = error51?.code;
|
|
68787
|
+
if (code === "ENOENT") {
|
|
68788
|
+
return `${what} is unavailable: the ripgrep binary it runs could not be found. This usually means Light Code was updated while this window was open, which replaces the folder the binary was in. Reloading the window (Developer: Reload Window) restores it. If it persists, the binary may have been removed by antivirus software.`;
|
|
68789
|
+
}
|
|
68790
|
+
return `${what} failed: ${error51 instanceof Error ? error51.message : String(error51)}`;
|
|
68791
|
+
}
|
|
68792
|
+
|
|
68793
|
+
// ../../packages/core/dist/tools/listFiles.js
|
|
68245
68794
|
var paramsSchema16 = external_exports.object({
|
|
68246
68795
|
path: external_exports.string().min(1).default(".").describe("Directory to list, relative to the workspace root."),
|
|
68247
68796
|
recursive: external_exports.boolean().optional().describe("List the full subtree instead of just this directory."),
|
|
@@ -68303,7 +68852,7 @@ var listFilesTool = {
|
|
|
68303
68852
|
content: params.includeIgnored === true ? "(no files found)" : "(no files found \u2014 .gitignore-excluded files are skipped; retry with includeIgnored: true)"
|
|
68304
68853
|
};
|
|
68305
68854
|
} catch (error51) {
|
|
68306
|
-
return { content:
|
|
68855
|
+
return { content: describeRipgrepFailure(error51, "Listing files recursively"), isError: true };
|
|
68307
68856
|
}
|
|
68308
68857
|
}
|
|
68309
68858
|
const entries = await context.fs.readdir(resolved.realPath);
|
|
@@ -68511,7 +69060,7 @@ var searchFilesTool = {
|
|
|
68511
69060
|
content: params.includeIgnored === true ? "(no matches)" : "(no matches \u2014 .gitignore-excluded files were not searched; retry with includeIgnored: true)"
|
|
68512
69061
|
};
|
|
68513
69062
|
} catch (error51) {
|
|
68514
|
-
return { content:
|
|
69063
|
+
return { content: describeRipgrepFailure(error51, "Search"), isError: true };
|
|
68515
69064
|
}
|
|
68516
69065
|
}
|
|
68517
69066
|
};
|
|
@@ -71184,7 +71733,7 @@ function respondJson(response, status, body) {
|
|
|
71184
71733
|
}
|
|
71185
71734
|
|
|
71186
71735
|
// src/cli.ts
|
|
71187
|
-
var VERSION = true ? "0.
|
|
71736
|
+
var VERSION = true ? "0.70.0" : "unknown (not a packaged build)";
|
|
71188
71737
|
var compat = installNodeCompat();
|
|
71189
71738
|
function lastMeaningfulLine(problem) {
|
|
71190
71739
|
const lines = problem.split(String.fromCharCode(10)).map((line) => line.trim()).filter((line) => line.length > 0 && !line.endsWith(":"));
|
|
@@ -71299,7 +71848,10 @@ Did you mean: --admin-id ${strayAdminValue.join(" --admin-id ")}
|
|
|
71299
71848
|
workspaceRoot,
|
|
71300
71849
|
dataDir,
|
|
71301
71850
|
clientDir: path35.join(here, "client"),
|
|
71302
|
-
|
|
71851
|
+
// A function because `HostServices` asks per turn — see there for the extension update
|
|
71852
|
+
// that made a single resolution wrong. Resolved once here and handed over as a constant:
|
|
71853
|
+
// nothing moves a server's own `node_modules` under it mid-run.
|
|
71854
|
+
ripgrepPath: /* @__PURE__ */ ((resolved) => () => resolved)(resolveRipgrep()),
|
|
71303
71855
|
...credentialTool !== void 0 ? { credentialTool: { interpreter: credentialPython, file: credentialTool } } : {},
|
|
71304
71856
|
handoffSeconds,
|
|
71305
71857
|
noToken,
|