@chosengeneration/light-code 0.69.0 → 0.74.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 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 MessageEvent = class _MessageEvent extends Event {
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 ErrorEvent = class _ErrorEvent extends Event {
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(MessageEvent.prototype, {
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(ErrorEvent.prototype, {
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, MessageEvent, {
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, ErrorEvent, {
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(),
@@ -47010,6 +47023,14 @@ function merge2(single, many) {
47010
47023
  }
47011
47024
  return out;
47012
47025
  }
47026
+ function aliasFields(names) {
47027
+ const cleaned = merge2(void 0, names);
47028
+ const [primary, ...rest] = cleaned;
47029
+ return {
47030
+ primary,
47031
+ rest: rest.length > 0 ? rest : void 0
47032
+ };
47033
+ }
47013
47034
 
47014
47035
  // ../../packages/core/dist/tools/searchCodebase.js
47015
47036
  var paramsSchema6 = external_exports.object({
@@ -47185,16 +47206,44 @@ function toHit(match, self) {
47185
47206
  }
47186
47207
  async function searchTeamSkills(options, query, size = 5, signal) {
47187
47208
  const vector = await options.embedder.embed(query);
47188
- const matches = await options.searcher.searchByVector(options.collection, vector, {
47189
- size,
47190
- ...signal !== void 0 ? { signal } : {}
47191
- });
47192
- return matches.map((match) => toHit(match, options.owner));
47209
+ const tried = [];
47210
+ let firstError;
47211
+ for (const collection of options.collections) {
47212
+ tried.push(collection);
47213
+ let matches;
47214
+ try {
47215
+ matches = await options.searcher.searchByVector(collection, vector, {
47216
+ size,
47217
+ ...signal !== void 0 ? { signal } : {}
47218
+ });
47219
+ } catch (error51) {
47220
+ firstError ??= error51 instanceof Error ? error51 : new Error(String(error51));
47221
+ continue;
47222
+ }
47223
+ if (matches.length > 0) {
47224
+ return { hits: matches.map((match) => toHit(match, options.owner)), collection, tried };
47225
+ }
47226
+ }
47227
+ if (firstError !== void 0)
47228
+ throw firstError;
47229
+ return { hits: [], collection: void 0, tried };
47193
47230
  }
47194
47231
  async function findTeamSkillsNamed(options, name, signal) {
47195
- const candidates = await searchTeamSkills(options, name, 25, signal);
47196
47232
  const wanted = name.trim().toLowerCase();
47197
- return candidates.filter((hit) => hit.name.trim().toLowerCase() === wanted);
47233
+ const found = /* @__PURE__ */ new Map();
47234
+ for (const collection of options.collections) {
47235
+ let result;
47236
+ try {
47237
+ result = await searchTeamSkills({ ...options, collections: [collection] }, name, 25, signal);
47238
+ } catch {
47239
+ continue;
47240
+ }
47241
+ for (const hit of result.hits) {
47242
+ if (hit.name.trim().toLowerCase() === wanted)
47243
+ found.set(`${hit.owner ?? "?"}/${hit.name}`, hit);
47244
+ }
47245
+ }
47246
+ return [...found.values()];
47198
47247
  }
47199
47248
  function describeTeamSkillCollision(name, hits) {
47200
47249
  const others = hits.filter((hit) => !hit.isMine);
@@ -47210,11 +47259,13 @@ function describeTeamSkillCollision(name, hits) {
47210
47259
  " name and does not overwrite theirs."
47211
47260
  ].join("\n");
47212
47261
  }
47213
- function renderTeamSkillHits(hits, query) {
47262
+ function renderTeamSkillHits(found, query) {
47263
+ const { hits, collection, tried } = found;
47214
47264
  if (hits.length === 0) {
47215
47265
  return `No team skills match: ${query}
47216
- Either nobody has written one, or the shared skills index has not been built yet (Settings \u2192 Skills). This does not mean the subject is undocumented.`;
47266
+ ` + (tried.length > 0 ? "Looked in " + tried.join(", ") + ". " : "") + "Either nobody has written one, or the shared skills index has not been built yet (Settings \u2192 Skills). This does not mean the subject is undocumented.";
47217
47267
  }
47268
+ const widened = collection !== void 0 && tried.length > 1 && tried[0] !== collection ? "Nothing in " + tried.slice(0, tried.indexOf(collection)).join(", ") + "; these are from " + collection + "." : void 0;
47218
47269
  const rendered = hits.map((hit, position) => {
47219
47270
  const who = hit.isMine ? "yours" : hit.owner ?? "unknown owner";
47220
47271
  const where = hit.project === void 0 ? who : `${who} / ${hit.project}`;
@@ -47223,6 +47274,7 @@ ${hit.text}`;
47223
47274
  }).join("\n\n---\n\n");
47224
47275
  return [
47225
47276
  `${hits.length} team skill(s) matching: ${query}`,
47277
+ ...widened !== void 0 ? [widened] : [],
47226
47278
  'Anything not marked "yours" is a colleague\u2019s and has no file on this machine \u2014 the text',
47227
47279
  "above is the whole of it, so do not try to read_file it. To keep one, write your own copy",
47228
47280
  "with write_skill; that stores it under your name and leaves theirs alone.",
@@ -47265,24 +47317,27 @@ function createSearchTeamSkillsTool(options) {
47265
47317
  async execute(params) {
47266
47318
  const startedAt = Date.now();
47267
47319
  try {
47268
- const hits = await searchTeamSkills(options, params.query, params.size ?? 5);
47320
+ const found = await searchTeamSkills(options, params.query, params.size ?? 5);
47269
47321
  options.observer?.record({
47270
47322
  at: startedAt,
47271
47323
  source: "search_team_skills",
47324
+ // The one that answered, not the one that was asked first — the log is evidence about
47325
+ // what happened, and a widened search is exactly what somebody would want to see.
47326
+ collection: found.collection ?? found.tried.join(" \u2192 "),
47272
47327
  query: params.query,
47273
- collection: options.collection,
47274
- hits: hits.length,
47328
+ hits: found.hits.length,
47275
47329
  elapsedMs: Date.now() - startedAt,
47276
47330
  via: "index"
47277
47331
  });
47278
- return { content: renderTeamSkillHits(hits, params.query) };
47332
+ return { content: renderTeamSkillHits(found, params.query) };
47279
47333
  } catch (error51) {
47280
47334
  const message3 = error51 instanceof Error ? error51.message : String(error51);
47281
47335
  options.observer?.record({
47282
47336
  at: startedAt,
47283
47337
  source: "search_team_skills",
47284
47338
  query: params.query,
47285
- collection: options.collection,
47339
+ // Every name that would have been tried: the search failed before one could answer.
47340
+ collection: options.collections.join(" \u2192 "),
47286
47341
  hits: 0,
47287
47342
  elapsedMs: Date.now() - startedAt,
47288
47343
  error: message3
@@ -54213,21 +54268,477 @@ var StdioClientTransport = class {
54213
54268
  }
54214
54269
  };
54215
54270
 
54216
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1_ed45788dfbfe808cc09dd7daea6bd385/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
54217
- var import_content_type = __toESM(require_content_type(), 1);
54218
- function mediaTypeEssence(header) {
54219
- if (!header) {
54220
- return void 0;
54271
+ // ../../node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/index.js
54272
+ var ParseError = class extends Error {
54273
+ constructor(message3, options) {
54274
+ super(message3), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
54221
54275
  }
54222
- try {
54223
- return import_content_type.default.parse(header).type;
54224
- } catch {
54225
- const essence = (header.split(";", 1)[0] ?? "").trim().toLowerCase();
54226
- if (essence === "" || header.slice(essence.length).includes(",")) {
54227
- return void 0;
54276
+ };
54277
+ var LF = 10;
54278
+ var CR = 13;
54279
+ var SPACE = 32;
54280
+ function noop(_arg) {
54281
+ }
54282
+ function createParser(config2) {
54283
+ if (typeof config2 == "function")
54284
+ throw new TypeError(
54285
+ "`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"
54286
+ );
54287
+ const { onEvent = noop, onError = noop, onRetry = noop, onComment, maxBufferSize } = config2, pendingFragments = [];
54288
+ let pendingFragmentsLength = 0, isFirstChunk = true, id, data = "", dataLines = 0, eventType, terminated = false;
54289
+ function feed(chunk) {
54290
+ if (terminated)
54291
+ throw new Error(
54292
+ "Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."
54293
+ );
54294
+ if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
54295
+ const trailing2 = processLines(chunk);
54296
+ trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
54297
+ return;
54228
54298
  }
54229
- return essence;
54299
+ if (chunk.indexOf(`
54300
+ `) === -1 && chunk.indexOf("\r") === -1) {
54301
+ pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
54302
+ return;
54303
+ }
54304
+ pendingFragments.push(chunk);
54305
+ const input = pendingFragments.join("");
54306
+ pendingFragments.length = 0, pendingFragmentsLength = 0;
54307
+ const trailing = processLines(input);
54308
+ trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
54309
+ }
54310
+ function checkBufferSize() {
54311
+ maxBufferSize !== void 0 && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = true, pendingFragments.length = 0, pendingFragmentsLength = 0, id = void 0, data = "", dataLines = 0, eventType = void 0, onError(
54312
+ new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {
54313
+ type: "max-buffer-size-exceeded"
54314
+ })
54315
+ )));
54316
+ }
54317
+ function processLines(chunk) {
54318
+ let searchIndex = 0;
54319
+ if (chunk.indexOf("\r") === -1) {
54320
+ let lfIndex = chunk.indexOf(`
54321
+ `, searchIndex);
54322
+ for (; lfIndex !== -1; ) {
54323
+ if (searchIndex === lfIndex) {
54324
+ dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
54325
+ `, searchIndex);
54326
+ continue;
54327
+ }
54328
+ const firstCharCode = chunk.charCodeAt(searchIndex);
54329
+ if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
54330
+ const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
54331
+ if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
54332
+ onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
54333
+ `, searchIndex);
54334
+ continue;
54335
+ }
54336
+ data = dataLines === 0 ? value : `${data}
54337
+ ${value}`, dataLines++;
54338
+ } else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
54339
+ chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
54340
+ lfIndex
54341
+ ) || void 0 : parseLine(chunk, searchIndex, lfIndex);
54342
+ searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
54343
+ `, searchIndex);
54344
+ }
54345
+ return chunk.slice(searchIndex);
54346
+ }
54347
+ for (; searchIndex < chunk.length; ) {
54348
+ const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
54349
+ `, searchIndex);
54350
+ let lineEnd = -1;
54351
+ 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)
54352
+ break;
54353
+ parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
54354
+ }
54355
+ return chunk.slice(searchIndex);
54356
+ }
54357
+ function parseLine(chunk, start, end) {
54358
+ if (start === end) {
54359
+ dispatchEvent();
54360
+ return;
54361
+ }
54362
+ const firstCharCode = chunk.charCodeAt(start);
54363
+ if (isDataPrefix(chunk, start, firstCharCode)) {
54364
+ const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
54365
+ data = dataLines === 0 ? value2 : `${data}
54366
+ ${value2}`, dataLines++;
54367
+ return;
54368
+ }
54369
+ if (isEventPrefix(chunk, start, firstCharCode)) {
54370
+ eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
54371
+ return;
54372
+ }
54373
+ if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
54374
+ const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
54375
+ id = value2.includes("\0") ? void 0 : value2;
54376
+ return;
54377
+ }
54378
+ if (firstCharCode === 58) {
54379
+ if (onComment) {
54380
+ const line2 = chunk.slice(start, end);
54381
+ onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
54382
+ }
54383
+ return;
54384
+ }
54385
+ const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
54386
+ if (fieldSeparatorIndex === -1) {
54387
+ processField(line, "", line);
54388
+ return;
54389
+ }
54390
+ const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
54391
+ processField(field, value, line);
54230
54392
  }
54393
+ function processField(field, value, line) {
54394
+ switch (field) {
54395
+ case "event":
54396
+ eventType = value || void 0;
54397
+ break;
54398
+ case "data":
54399
+ data = dataLines === 0 ? value : `${data}
54400
+ ${value}`, dataLines++;
54401
+ break;
54402
+ case "id":
54403
+ id = value.includes("\0") ? void 0 : value;
54404
+ break;
54405
+ case "retry":
54406
+ /^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
54407
+ new ParseError(`Invalid \`retry\` value: "${value}"`, {
54408
+ type: "invalid-retry",
54409
+ value,
54410
+ line
54411
+ })
54412
+ );
54413
+ break;
54414
+ default:
54415
+ onError(
54416
+ new ParseError(
54417
+ `Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,
54418
+ { type: "unknown-field", field, value, line }
54419
+ )
54420
+ );
54421
+ break;
54422
+ }
54423
+ }
54424
+ function dispatchEvent() {
54425
+ dataLines > 0 && onEvent({
54426
+ id,
54427
+ event: eventType,
54428
+ data
54429
+ }), id = void 0, data = "", dataLines = 0, eventType = void 0;
54430
+ }
54431
+ function reset(options = {}) {
54432
+ if (options.consume && pendingFragments.length > 0) {
54433
+ const incompleteLine = pendingFragments.join("");
54434
+ parseLine(incompleteLine, 0, incompleteLine.length);
54435
+ }
54436
+ isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = false;
54437
+ }
54438
+ return { feed, reset };
54439
+ }
54440
+ function isDataPrefix(chunk, i, firstCharCode) {
54441
+ return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
54442
+ }
54443
+ function isEventPrefix(chunk, i, firstCharCode) {
54444
+ 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;
54445
+ }
54446
+
54447
+ // ../../node_modules/.pnpm/eventsource@3.0.7/node_modules/eventsource/dist/index.js
54448
+ var ErrorEvent = class extends Event {
54449
+ /**
54450
+ * Constructs a new `ErrorEvent` instance. This is typically not called directly,
54451
+ * but rather emitted by the `EventSource` object when an error occurs.
54452
+ *
54453
+ * @param type - The type of the event (should be "error")
54454
+ * @param errorEventInitDict - Optional properties to include in the error event
54455
+ */
54456
+ constructor(type, errorEventInitDict) {
54457
+ var _a3, _b;
54458
+ 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;
54459
+ }
54460
+ /**
54461
+ * Node.js "hides" the `message` and `code` properties of the `ErrorEvent` instance,
54462
+ * when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
54463
+ * we explicitly include the properties in the `inspect` method.
54464
+ *
54465
+ * This is automatically called by Node.js when you `console.log` an instance of this class.
54466
+ *
54467
+ * @param _depth - The current depth
54468
+ * @param options - The options passed to `util.inspect`
54469
+ * @param inspect - The inspect function to use (prevents having to import it from `util`)
54470
+ * @returns A string representation of the error
54471
+ */
54472
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
54473
+ return inspect(inspectableError(this), options);
54474
+ }
54475
+ /**
54476
+ * Deno "hides" the `message` and `code` properties of the `ErrorEvent` instance,
54477
+ * when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
54478
+ * we explicitly include the properties in the `inspect` method.
54479
+ *
54480
+ * This is automatically called by Deno when you `console.log` an instance of this class.
54481
+ *
54482
+ * @param inspect - The inspect function to use (prevents having to import it from `util`)
54483
+ * @param options - The options passed to `Deno.inspect`
54484
+ * @returns A string representation of the error
54485
+ */
54486
+ [/* @__PURE__ */ Symbol.for("Deno.customInspect")](inspect, options) {
54487
+ return inspect(inspectableError(this), options);
54488
+ }
54489
+ };
54490
+ function syntaxError(message3) {
54491
+ const DomException = globalThis.DOMException;
54492
+ return typeof DomException == "function" ? new DomException(message3, "SyntaxError") : new SyntaxError(message3);
54493
+ }
54494
+ function flattenError2(err) {
54495
+ 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}`;
54496
+ }
54497
+ function inspectableError(err) {
54498
+ return {
54499
+ type: err.type,
54500
+ message: err.message,
54501
+ code: err.code,
54502
+ defaultPrevented: err.defaultPrevented,
54503
+ cancelable: err.cancelable,
54504
+ timeStamp: err.timeStamp
54505
+ };
54506
+ }
54507
+ var __typeError = (msg) => {
54508
+ throw TypeError(msg);
54509
+ };
54510
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
54511
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
54512
+ 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);
54513
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
54514
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
54515
+ var _readyState;
54516
+ var _url2;
54517
+ var _redirectUrl;
54518
+ var _withCredentials;
54519
+ var _fetch;
54520
+ var _reconnectInterval;
54521
+ var _reconnectTimer;
54522
+ var _lastEventId;
54523
+ var _controller;
54524
+ var _parser;
54525
+ var _onError;
54526
+ var _onMessage;
54527
+ var _onOpen;
54528
+ var _EventSource_instances;
54529
+ var connect_fn;
54530
+ var _onFetchResponse;
54531
+ var _onFetchError;
54532
+ var getRequestOptions_fn;
54533
+ var _onEvent;
54534
+ var _onRetryChange;
54535
+ var failConnection_fn;
54536
+ var scheduleReconnect_fn;
54537
+ var _reconnect;
54538
+ var EventSource = class extends EventTarget {
54539
+ constructor(url2, eventSourceInitDict) {
54540
+ var _a3, _b;
54541
+ 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) => {
54542
+ var _a22;
54543
+ __privateGet(this, _parser).reset();
54544
+ const { body, redirected, status, headers } = response;
54545
+ if (status === 204) {
54546
+ __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
54547
+ return;
54548
+ }
54549
+ if (redirected ? __privateSet(this, _redirectUrl, new URL(response.url)) : __privateSet(this, _redirectUrl, void 0), status !== 200) {
54550
+ __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, `Non-200 status code (${status})`, status);
54551
+ return;
54552
+ }
54553
+ if (!(headers.get("content-type") || "").startsWith("text/event-stream")) {
54554
+ __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, 'Invalid content type, expected "text/event-stream"', status);
54555
+ return;
54556
+ }
54557
+ if (__privateGet(this, _readyState) === this.CLOSED)
54558
+ return;
54559
+ __privateSet(this, _readyState, this.OPEN);
54560
+ const openEvent = new Event("open");
54561
+ if ((_a22 = __privateGet(this, _onOpen)) == null || _a22.call(this, openEvent), this.dispatchEvent(openEvent), typeof body != "object" || !body || !("getReader" in body)) {
54562
+ __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Invalid response body, expected a web ReadableStream", status), this.close();
54563
+ return;
54564
+ }
54565
+ const decoder = new TextDecoder(), reader = body.getReader();
54566
+ let open = true;
54567
+ do {
54568
+ const { done, value } = await reader.read();
54569
+ 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));
54570
+ } while (open);
54571
+ }), __privateAdd(this, _onFetchError, (err) => {
54572
+ __privateSet(this, _controller, void 0), !(err.name === "AbortError" || err.type === "aborted") && __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this, flattenError2(err));
54573
+ }), __privateAdd(this, _onEvent, (event) => {
54574
+ typeof event.id == "string" && __privateSet(this, _lastEventId, event.id);
54575
+ const messageEvent = new MessageEvent(event.event || "message", {
54576
+ data: event.data,
54577
+ origin: __privateGet(this, _redirectUrl) ? __privateGet(this, _redirectUrl).origin : __privateGet(this, _url2).origin,
54578
+ lastEventId: event.id || ""
54579
+ });
54580
+ __privateGet(this, _onMessage) && (!event.event || event.event === "message") && __privateGet(this, _onMessage).call(this, messageEvent), this.dispatchEvent(messageEvent);
54581
+ }), __privateAdd(this, _onRetryChange, (value) => {
54582
+ __privateSet(this, _reconnectInterval, value);
54583
+ }), __privateAdd(this, _reconnect, () => {
54584
+ __privateSet(this, _reconnectTimer, void 0), __privateGet(this, _readyState) === this.CONNECTING && __privateMethod(this, _EventSource_instances, connect_fn).call(this);
54585
+ });
54586
+ try {
54587
+ if (url2 instanceof URL)
54588
+ __privateSet(this, _url2, url2);
54589
+ else if (typeof url2 == "string")
54590
+ __privateSet(this, _url2, new URL(url2, getBaseURL()));
54591
+ else
54592
+ throw new Error("Invalid URL");
54593
+ } catch {
54594
+ throw syntaxError("An invalid or illegal string was specified");
54595
+ }
54596
+ __privateSet(this, _parser, createParser({
54597
+ onEvent: __privateGet(this, _onEvent),
54598
+ onRetry: __privateGet(this, _onRetryChange)
54599
+ })), __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);
54600
+ }
54601
+ /**
54602
+ * Returns the state of this EventSource object's connection. It can have the values described below.
54603
+ *
54604
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
54605
+ *
54606
+ * Note: typed as `number` instead of `0 | 1 | 2` for compatibility with the `EventSource` interface,
54607
+ * defined in the TypeScript `dom` library.
54608
+ *
54609
+ * @public
54610
+ */
54611
+ get readyState() {
54612
+ return __privateGet(this, _readyState);
54613
+ }
54614
+ /**
54615
+ * Returns the URL providing the event stream.
54616
+ *
54617
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
54618
+ *
54619
+ * @public
54620
+ */
54621
+ get url() {
54622
+ return __privateGet(this, _url2).href;
54623
+ }
54624
+ /**
54625
+ * Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
54626
+ *
54627
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
54628
+ */
54629
+ get withCredentials() {
54630
+ return __privateGet(this, _withCredentials);
54631
+ }
54632
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
54633
+ get onerror() {
54634
+ return __privateGet(this, _onError);
54635
+ }
54636
+ set onerror(value) {
54637
+ __privateSet(this, _onError, value);
54638
+ }
54639
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
54640
+ get onmessage() {
54641
+ return __privateGet(this, _onMessage);
54642
+ }
54643
+ set onmessage(value) {
54644
+ __privateSet(this, _onMessage, value);
54645
+ }
54646
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
54647
+ get onopen() {
54648
+ return __privateGet(this, _onOpen);
54649
+ }
54650
+ set onopen(value) {
54651
+ __privateSet(this, _onOpen, value);
54652
+ }
54653
+ addEventListener(type, listener, options) {
54654
+ const listen = listener;
54655
+ super.addEventListener(type, listen, options);
54656
+ }
54657
+ removeEventListener(type, listener, options) {
54658
+ const listen = listener;
54659
+ super.removeEventListener(type, listen, options);
54660
+ }
54661
+ /**
54662
+ * Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
54663
+ *
54664
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
54665
+ *
54666
+ * @public
54667
+ */
54668
+ close() {
54669
+ __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));
54670
+ }
54671
+ };
54672
+ _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(), /**
54673
+ * Connect to the given URL and start receiving events
54674
+ *
54675
+ * @internal
54676
+ */
54677
+ connect_fn = function() {
54678
+ __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));
54679
+ }, _onFetchResponse = /* @__PURE__ */ new WeakMap(), _onFetchError = /* @__PURE__ */ new WeakMap(), /**
54680
+ * Get request options for the `fetch()` request
54681
+ *
54682
+ * @returns The request options
54683
+ * @internal
54684
+ */
54685
+ getRequestOptions_fn = function() {
54686
+ var _a3;
54687
+ const init = {
54688
+ // [spec] Let `corsAttributeState` be `Anonymous`…
54689
+ // [spec] …will have their mode set to "cors"…
54690
+ mode: "cors",
54691
+ redirect: "follow",
54692
+ headers: { Accept: "text/event-stream", ...__privateGet(this, _lastEventId) ? { "Last-Event-ID": __privateGet(this, _lastEventId) } : void 0 },
54693
+ cache: "no-store",
54694
+ signal: (_a3 = __privateGet(this, _controller)) == null ? void 0 : _a3.signal
54695
+ };
54696
+ return "window" in globalThis && (init.credentials = this.withCredentials ? "include" : "same-origin"), init;
54697
+ }, _onEvent = /* @__PURE__ */ new WeakMap(), _onRetryChange = /* @__PURE__ */ new WeakMap(), /**
54698
+ * Handles the process referred to in the EventSource specification as "failing a connection".
54699
+ *
54700
+ * @param error - The error causing the connection to fail
54701
+ * @param code - The HTTP status code, if available
54702
+ * @internal
54703
+ */
54704
+ failConnection_fn = function(message3, code) {
54705
+ var _a3;
54706
+ __privateGet(this, _readyState) !== this.CLOSED && __privateSet(this, _readyState, this.CLOSED);
54707
+ const errorEvent = new ErrorEvent("error", { code, message: message3 });
54708
+ (_a3 = __privateGet(this, _onError)) == null || _a3.call(this, errorEvent), this.dispatchEvent(errorEvent);
54709
+ }, /**
54710
+ * Schedules a reconnection attempt against the EventSource endpoint.
54711
+ *
54712
+ * @param message - The error causing the connection to fail
54713
+ * @param code - The HTTP status code, if available
54714
+ * @internal
54715
+ */
54716
+ scheduleReconnect_fn = function(message3, code) {
54717
+ var _a3;
54718
+ if (__privateGet(this, _readyState) === this.CLOSED)
54719
+ return;
54720
+ __privateSet(this, _readyState, this.CONNECTING);
54721
+ const errorEvent = new ErrorEvent("error", { code, message: message3 });
54722
+ (_a3 = __privateGet(this, _onError)) == null || _a3.call(this, errorEvent), this.dispatchEvent(errorEvent), __privateSet(this, _reconnectTimer, setTimeout(__privateGet(this, _reconnect), __privateGet(this, _reconnectInterval)));
54723
+ }, _reconnect = /* @__PURE__ */ new WeakMap(), /**
54724
+ * ReadyState representing an EventSource currently trying to connect
54725
+ *
54726
+ * @public
54727
+ */
54728
+ EventSource.CONNECTING = 0, /**
54729
+ * ReadyState representing an EventSource connection that is open (eg connected)
54730
+ *
54731
+ * @public
54732
+ */
54733
+ EventSource.OPEN = 1, /**
54734
+ * ReadyState representing an EventSource connection that is closed (eg disconnected)
54735
+ *
54736
+ * @public
54737
+ */
54738
+ EventSource.CLOSED = 2;
54739
+ function getBaseURL() {
54740
+ const doc = "document" in globalThis ? globalThis.document : void 0;
54741
+ return doc && typeof doc == "object" && "baseURI" in doc && typeof doc.baseURI == "string" ? doc.baseURI : void 0;
54231
54742
  }
54232
54743
 
54233
54744
  // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1_ed45788dfbfe808cc09dd7daea6bd385/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.js
@@ -55100,180 +55611,212 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
55100
55611
  return OAuthClientInformationFullSchema.parse(await response.json());
55101
55612
  }
55102
55613
 
55103
- // ../../node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/index.js
55104
- var ParseError = class extends Error {
55105
- constructor(message3, options) {
55106
- super(message3), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
55614
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1_ed45788dfbfe808cc09dd7daea6bd385/node_modules/@modelcontextprotocol/sdk/dist/esm/client/sse.js
55615
+ var SseError = class extends Error {
55616
+ constructor(code, message3, event) {
55617
+ super(`SSE error: ${message3}`);
55618
+ this.code = code;
55619
+ this.event = event;
55107
55620
  }
55108
55621
  };
55109
- var LF = 10;
55110
- var CR = 13;
55111
- var SPACE = 32;
55112
- function noop(_arg) {
55113
- }
55114
- function createParser(config2) {
55115
- if (typeof config2 == "function")
55116
- throw new TypeError(
55117
- "`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"
55118
- );
55119
- const { onEvent = noop, onError = noop, onRetry = noop, onComment, maxBufferSize } = config2, pendingFragments = [];
55120
- let pendingFragmentsLength = 0, isFirstChunk = true, id, data = "", dataLines = 0, eventType, terminated = false;
55121
- function feed(chunk) {
55122
- if (terminated)
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;
55622
+ var SSEClientTransport = class {
55623
+ constructor(url2, opts) {
55624
+ this._url = url2;
55625
+ this._resourceMetadataUrl = void 0;
55626
+ this._scope = void 0;
55627
+ this._eventSourceInit = opts?.eventSourceInit;
55628
+ this._requestInit = opts?.requestInit;
55629
+ this._authProvider = opts?.authProvider;
55630
+ this._fetch = opts?.fetch;
55631
+ this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
55632
+ }
55633
+ async _authThenStart() {
55634
+ if (!this._authProvider) {
55635
+ throw new UnauthorizedError("No auth provider");
55130
55636
  }
55131
- if (chunk.indexOf(`
55132
- `) === -1 && chunk.indexOf("\r") === -1) {
55133
- pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
55134
- return;
55637
+ let result;
55638
+ try {
55639
+ result = await auth(this._authProvider, {
55640
+ serverUrl: this._url,
55641
+ resourceMetadataUrl: this._resourceMetadataUrl,
55642
+ scope: this._scope,
55643
+ fetchFn: this._fetchWithInit
55644
+ });
55645
+ } catch (error51) {
55646
+ this.onerror?.(error51);
55647
+ throw error51;
55135
55648
  }
55136
- pendingFragments.push(chunk);
55137
- const input = pendingFragments.join("");
55138
- pendingFragments.length = 0, pendingFragmentsLength = 0;
55139
- const trailing = processLines(input);
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
- )));
55649
+ if (result !== "AUTHORIZED") {
55650
+ throw new UnauthorizedError();
55651
+ }
55652
+ return await this._startOrAuth();
55148
55653
  }
55149
- function processLines(chunk) {
55150
- let searchIndex = 0;
55151
- if (chunk.indexOf("\r") === -1) {
55152
- let lfIndex = chunk.indexOf(`
55153
- `, searchIndex);
55154
- for (; lfIndex !== -1; ) {
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);
55654
+ async _commonHeaders() {
55655
+ const headers = {};
55656
+ if (this._authProvider) {
55657
+ const tokens = await this._authProvider.tokens();
55658
+ if (tokens) {
55659
+ headers["Authorization"] = `Bearer ${tokens.access_token}`;
55176
55660
  }
55177
- return chunk.slice(searchIndex);
55178
55661
  }
55179
- for (; searchIndex < chunk.length; ) {
55180
- const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
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++;
55662
+ if (this._protocolVersion) {
55663
+ headers["mcp-protocol-version"] = this._protocolVersion;
55186
55664
  }
55187
- return chunk.slice(searchIndex);
55665
+ const extraHeaders = normalizeHeaders(this._requestInit?.headers);
55666
+ return new Headers({
55667
+ ...headers,
55668
+ ...extraHeaders
55669
+ });
55188
55670
  }
55189
- function parseLine(chunk, start, end) {
55190
- if (start === end) {
55191
- dispatchEvent();
55192
- return;
55671
+ _startOrAuth() {
55672
+ const fetchImpl = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
55673
+ return new Promise((resolve, reject2) => {
55674
+ this._eventSource = new EventSource(this._url.href, {
55675
+ ...this._eventSourceInit,
55676
+ fetch: async (url2, init) => {
55677
+ const headers = await this._commonHeaders();
55678
+ headers.set("Accept", "text/event-stream");
55679
+ const response = await fetchImpl(url2, {
55680
+ ...init,
55681
+ headers
55682
+ });
55683
+ if (response.status === 401 && response.headers.has("www-authenticate")) {
55684
+ const { resourceMetadataUrl, scope } = extractWWWAuthenticateParams(response);
55685
+ this._resourceMetadataUrl = resourceMetadataUrl;
55686
+ this._scope = scope;
55687
+ }
55688
+ return response;
55689
+ }
55690
+ });
55691
+ this._abortController = new AbortController();
55692
+ this._eventSource.onerror = (event) => {
55693
+ if (event.code === 401 && this._authProvider) {
55694
+ this._authThenStart().then(resolve, reject2);
55695
+ return;
55696
+ }
55697
+ const error51 = new SseError(event.code, event.message, event);
55698
+ reject2(error51);
55699
+ this.onerror?.(error51);
55700
+ };
55701
+ this._eventSource.onopen = () => {
55702
+ };
55703
+ this._eventSource.addEventListener("endpoint", (event) => {
55704
+ const messageEvent = event;
55705
+ try {
55706
+ this._endpoint = new URL(messageEvent.data, this._url);
55707
+ if (this._endpoint.origin !== this._url.origin) {
55708
+ throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`);
55709
+ }
55710
+ } catch (error51) {
55711
+ reject2(error51);
55712
+ this.onerror?.(error51);
55713
+ void this.close();
55714
+ return;
55715
+ }
55716
+ resolve();
55717
+ });
55718
+ this._eventSource.onmessage = (event) => {
55719
+ const messageEvent = event;
55720
+ let message3;
55721
+ try {
55722
+ message3 = JSONRPCMessageSchema.parse(JSON.parse(messageEvent.data));
55723
+ } catch (error51) {
55724
+ this.onerror?.(error51);
55725
+ return;
55726
+ }
55727
+ this.onmessage?.(message3);
55728
+ };
55729
+ });
55730
+ }
55731
+ async start() {
55732
+ if (this._eventSource) {
55733
+ throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");
55193
55734
  }
55194
- const firstCharCode = chunk.charCodeAt(start);
55195
- if (isDataPrefix(chunk, start, firstCharCode)) {
55196
- const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
55197
- data = dataLines === 0 ? value2 : `${data}
55198
- ${value2}`, dataLines++;
55199
- return;
55735
+ return await this._startOrAuth();
55736
+ }
55737
+ /**
55738
+ * 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.
55739
+ */
55740
+ async finishAuth(authorizationCode) {
55741
+ if (!this._authProvider) {
55742
+ throw new UnauthorizedError("No auth provider");
55200
55743
  }
55201
- if (isEventPrefix(chunk, start, firstCharCode)) {
55202
- eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
55203
- return;
55744
+ const result = await auth(this._authProvider, {
55745
+ serverUrl: this._url,
55746
+ authorizationCode,
55747
+ resourceMetadataUrl: this._resourceMetadataUrl,
55748
+ scope: this._scope,
55749
+ fetchFn: this._fetchWithInit
55750
+ });
55751
+ if (result !== "AUTHORIZED") {
55752
+ throw new UnauthorizedError("Failed to authorize");
55204
55753
  }
55205
- if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
55206
- const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
55207
- id = value2.includes("\0") ? void 0 : value2;
55208
- return;
55754
+ }
55755
+ async close() {
55756
+ this._abortController?.abort();
55757
+ this._eventSource?.close();
55758
+ this.onclose?.();
55759
+ }
55760
+ async send(message3) {
55761
+ if (!this._endpoint) {
55762
+ throw new Error("Not connected");
55209
55763
  }
55210
- if (firstCharCode === 58) {
55211
- if (onComment) {
55212
- const line2 = chunk.slice(start, end);
55213
- onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
55764
+ try {
55765
+ const headers = await this._commonHeaders();
55766
+ headers.set("content-type", "application/json");
55767
+ const init = {
55768
+ ...this._requestInit,
55769
+ method: "POST",
55770
+ headers,
55771
+ body: JSON.stringify(message3),
55772
+ signal: this._abortController?.signal
55773
+ };
55774
+ const response = await (this._fetch ?? fetch)(this._endpoint, init);
55775
+ if (!response.ok) {
55776
+ const text = await response.text().catch(() => null);
55777
+ if (response.status === 401 && this._authProvider) {
55778
+ const { resourceMetadataUrl, scope } = extractWWWAuthenticateParams(response);
55779
+ this._resourceMetadataUrl = resourceMetadataUrl;
55780
+ this._scope = scope;
55781
+ const result = await auth(this._authProvider, {
55782
+ serverUrl: this._url,
55783
+ resourceMetadataUrl: this._resourceMetadataUrl,
55784
+ scope: this._scope,
55785
+ fetchFn: this._fetchWithInit
55786
+ });
55787
+ if (result !== "AUTHORIZED") {
55788
+ throw new UnauthorizedError();
55789
+ }
55790
+ return this.send(message3);
55791
+ }
55792
+ throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
55214
55793
  }
55215
- return;
55216
- }
55217
- const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
55218
- if (fieldSeparatorIndex === -1) {
55219
- processField(line, "", line);
55220
- return;
55794
+ await response.body?.cancel();
55795
+ } catch (error51) {
55796
+ this.onerror?.(error51);
55797
+ throw error51;
55221
55798
  }
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
55799
  }
55225
- function processField(field, value, line) {
55226
- switch (field) {
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
- }
55800
+ setProtocolVersion(version2) {
55801
+ this._protocolVersion = version2;
55255
55802
  }
55256
- function dispatchEvent() {
55257
- dataLines > 0 && onEvent({
55258
- id,
55259
- event: eventType,
55260
- data
55261
- }), id = void 0, data = "", dataLines = 0, eventType = void 0;
55803
+ };
55804
+
55805
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1_ed45788dfbfe808cc09dd7daea6bd385/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
55806
+ var import_content_type = __toESM(require_content_type(), 1);
55807
+ function mediaTypeEssence(header) {
55808
+ if (!header) {
55809
+ return void 0;
55262
55810
  }
55263
- function reset(options = {}) {
55264
- if (options.consume && pendingFragments.length > 0) {
55265
- const incompleteLine = pendingFragments.join("");
55266
- parseLine(incompleteLine, 0, incompleteLine.length);
55811
+ try {
55812
+ return import_content_type.default.parse(header).type;
55813
+ } catch {
55814
+ const essence = (header.split(";", 1)[0] ?? "").trim().toLowerCase();
55815
+ if (essence === "" || header.slice(essence.length).includes(",")) {
55816
+ return void 0;
55267
55817
  }
55268
- isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = false;
55818
+ return essence;
55269
55819
  }
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
55820
  }
55278
55821
 
55279
55822
  // ../../node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/stream.js
@@ -55737,10 +56280,15 @@ async function buildTransport(config2, secrets) {
55737
56280
  });
55738
56281
  }
55739
56282
  const headers = await interpolateSecrets(config2.headers, secrets);
55740
- const httpTransport = new StreamableHTTPClientTransport(new URL(config2.url), {
55741
- ...Object.keys(headers).length > 0 ? { requestInit: { headers } } : {}
55742
- });
55743
- return httpTransport;
56283
+ return httpTransport(config2.url, headers, httpKindOf(config2));
56284
+ }
56285
+ function httpKindOf(config2) {
56286
+ return config2.type === "sse" ? "sse" : "streamable-http";
56287
+ }
56288
+ function httpTransport(url2, headers, kind) {
56289
+ const options = Object.keys(headers).length > 0 ? { requestInit: { headers } } : {};
56290
+ const transport = kind === "sse" ? new SSEClientTransport(new URL(url2), options) : new StreamableHTTPClientTransport(new URL(url2), options);
56291
+ return transport;
55744
56292
  }
55745
56293
  var McpConnection = class {
55746
56294
  serverName;
@@ -55769,10 +56317,31 @@ var McpConnection = class {
55769
56317
  if (transport instanceof StdioClientTransport) {
55770
56318
  this.attachStderr(transport);
55771
56319
  }
55772
- await client.connect(transport);
56320
+ this.onLog(await describeMcpRequest(this.config, this.secrets));
56321
+ try {
56322
+ await client.connect(transport);
56323
+ } catch (error51) {
56324
+ const fallback = await this.fallbackTransport(error51);
56325
+ if (fallback === void 0)
56326
+ throw error51;
56327
+ await client.connect(fallback);
56328
+ this.client = client;
56329
+ this.transport = fallback;
56330
+ this.onLog(`Connected over SSE; Streamable HTTP was refused (${describeError(error51)})`);
56331
+ return;
56332
+ }
55773
56333
  this.client = client;
55774
56334
  this.transport = transport;
55775
56335
  }
56336
+ /** The other HTTP protocol, when this server never said which it speaks. */
56337
+ async fallbackTransport(error51) {
56338
+ const config2 = this.config;
56339
+ if (isStdioServer(config2) || config2.type !== void 0)
56340
+ return void 0;
56341
+ this.onLog(`Streamable HTTP failed (${describeError(error51)}) \u2014 retrying as SSE`);
56342
+ const headers = await interpolateSecrets(config2.headers, this.secrets);
56343
+ return httpTransport(config2.url, headers, "sse");
56344
+ }
55776
56345
  attachStderr(transport) {
55777
56346
  const stream = transport.stderr;
55778
56347
  if (stream === null)
@@ -55829,6 +56398,23 @@ function renderToolResult(result) {
55829
56398
  });
55830
56399
  return parts.join("\n");
55831
56400
  }
56401
+ function describeError(error51) {
56402
+ return error51 instanceof Error ? error51.message : String(error51);
56403
+ }
56404
+ async function describeMcpRequest(config2, secrets) {
56405
+ if (isStdioServer(config2))
56406
+ return `Starting ${config2.command}`;
56407
+ const kind = config2.type ?? "streamable-http (no type set; SSE is the fallback)";
56408
+ let names;
56409
+ try {
56410
+ const resolved = await interpolateSecrets(config2.headers, secrets);
56411
+ names = Object.entries(resolved).map(([name, value]) => value.trim().length === 0 ? `${name} (EMPTY)` : name);
56412
+ } catch (error51) {
56413
+ return `Connecting to ${config2.url} as ${kind}; headers unresolved: ${describeError(error51)}`;
56414
+ }
56415
+ const headers = names.length === 0 ? "no headers configured" : `headers: ${names.join(", ")}`;
56416
+ return `Connecting to ${config2.url} as ${kind}; ${headers}`;
56417
+ }
55832
56418
 
55833
56419
  // ../../packages/core/dist/mcp/registry.js
55834
56420
  function adaptTool(serverName, toolName, description, inputSchema, call) {
@@ -57940,6 +58526,8 @@ async function truncateToolResult(content, store, maxChars = DEFAULT_MAX_CHARS)
57940
58526
  var DEFAULT_MAX_ITERATIONS = 25;
57941
58527
  var BOOKKEEPING_TOOLS = /* @__PURE__ */ new Set(["plan_progress"]);
57942
58528
  var MAX_REFUNDED_STEPS = 20;
58529
+ var FORM_DISMISSED = "The user dismissed the form without answering.";
58530
+ var MAX_FORM_RESETS = 5;
57943
58531
  var MAX_CONSECUTIVE_MISTAKES = 3;
57944
58532
  async function prepareModelMessages(conversation, provider, tools, options, events) {
57945
58533
  const contextWindow = options.contextWindow ?? 0;
@@ -58122,6 +58710,7 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
58122
58710
  conversation.addUserMessage(userMessage, options.images);
58123
58711
  const maxIterations = options.maxIterations ?? DEFAULT_MAX_ITERATIONS;
58124
58712
  let refunded = 0;
58713
+ let formResets = 0;
58125
58714
  const mistakeCounts = /* @__PURE__ */ new Map();
58126
58715
  let continueNudges = 0;
58127
58716
  const mode = options.mode ?? CODE_MODE;
@@ -58195,6 +58784,10 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
58195
58784
  conversation.addUserMessage(message3);
58196
58785
  events.onQueuedMessageConsumed?.(message3);
58197
58786
  }
58787
+ if (queued.length > 0) {
58788
+ iteration = -1;
58789
+ refunded = 0;
58790
+ }
58198
58791
  if (toolCall.name === "attempt_completion" || toolCall.name === "ask_followup_question") {
58199
58792
  events.onDone();
58200
58793
  return;
@@ -58203,6 +58796,11 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
58203
58796
  refunded += 1;
58204
58797
  iteration -= 1;
58205
58798
  }
58799
+ if (toolCall.name === "ask_user_form" && result.isError !== true && !result.content.startsWith(FORM_DISMISSED) && formResets < MAX_FORM_RESETS) {
58800
+ formResets += 1;
58801
+ iteration = -1;
58802
+ refunded = 0;
58803
+ }
58206
58804
  if (result.path !== void 0) {
58207
58805
  if (result.isError === true) {
58208
58806
  const count = (mistakeCounts.get(result.path) ?? 0) + 1;
@@ -58216,7 +58814,7 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
58216
58814
  }
58217
58815
  }
58218
58816
  }
58219
- events.onError(`Stopped after ${maxIterations} steps in one turn. Nothing is lost \u2014 send another message (for example "continue") to carry on from here. Raise the limit in Settings \u2192 Approvals if this task legitimately needs more.`);
58817
+ events.onError(`Stopped after ${maxIterations} steps since your last message. Nothing is lost \u2014 send another message (for example "continue") to carry on from here. Raise the limit in Settings \u2192 Approvals if this task legitimately needs more.`);
58220
58818
  }
58221
58819
 
58222
58820
  // ../../packages/core/dist/host/bridge.js
@@ -61508,7 +62106,7 @@ function stripEmpty(source) {
61508
62106
  var SCHEDULE_TICK_MS = 15e3;
61509
62107
  var STUCK_RUN_MS = 30 * 6e4;
61510
62108
  function wireChatBridge(services) {
61511
- const { transport, secrets, ui, workspaceRoot, storageDir, ripgrepPath } = services;
62109
+ const { transport, secrets, ui, workspaceRoot, storageDir } = services;
61512
62110
  const logger = new Logger({ level: "debug", sink: services.logSink });
61513
62111
  const configManager = new ConfigManager(services.configStore, services.workspaceRoot);
61514
62112
  const httpClient = services.httpClient ?? new FetchHttpClient();
@@ -62839,9 +63437,17 @@ ${preview.text}` } : {}
62839
63437
  // that stops to wait for one would never finish.
62840
63438
  ...schedule === void 0 ? { requestForm } : {},
62841
63439
  signal: activeAbortController.signal,
62842
- // Supplied by the host, not imported by core: the binary is platform-specific and
62843
- // lives in the VSIX, so resolving it is a host concern (§4).
62844
- ...ripgrepPath !== void 0 ? { ripgrepPath } : {}
63440
+ /*
63441
+ * Supplied by the host, not imported by core: the binary is platform-specific and
63442
+ * lives in the VSIX, so resolving it is a host concern (§4).
63443
+ *
63444
+ * Asked per turn rather than captured once, because a VS Code extension update
63445
+ * deletes the folder the previous answer pointed into. See `HostServices`.
63446
+ */
63447
+ ...(() => {
63448
+ const resolved = services.ripgrepPath();
63449
+ return resolved !== void 0 ? { ripgrepPath: resolved } : {};
63450
+ })()
62845
63451
  };
62846
63452
  consultationContext = () => toolContext;
62847
63453
  pythonNestedContext = toolContext;
@@ -62929,8 +63535,12 @@ ${direction}` : attachMentions(text, mentions);
62929
63535
  skillAliases(config2).length > 0 && search !== void 0 && embedder !== void 0 ? {
62930
63536
  searcher: search.searcher,
62931
63537
  embedder,
62932
- // The first is the default circle, exactly as it is for the codebase index.
62933
- collection: skillAliases(config2)[0],
63538
+ /*
63539
+ * All of them, in order — the first is the ordinary circle and the rest are what a
63540
+ * search widens into when it holds nothing. Handing over only the first is what
63541
+ * made the extra names typed in the panel do nothing at all for skills.
63542
+ */
63543
+ collections: skillAliases(config2),
62934
63544
  ...indexOwner(config2) !== void 0 ? { owner: indexOwner(config2) } : {}
62935
63545
  } : void 0,
62936
63546
  /*
@@ -64560,15 +65170,19 @@ ${direction}` : attachMentions(text, mentions);
64560
65170
  const digest = createHash3("sha256").update(path24.resolve(workspaceRoot).toLowerCase()).digest("hex").slice(0, 16);
64561
65171
  return `${config2?.embedder?.indexPrefix ?? DEFAULT_INDEX_PREFIX}-${digest}`;
64562
65172
  }
64563
- async function handleSaveSkillsAlias(alias) {
65173
+ async function handleSaveSkillsAlias(aliases) {
64564
65174
  try {
64565
65175
  const { config: config2 } = await configManager.load();
64566
- const trimmed = alias.trim();
64567
65176
  const embedder = { ...config2.embedder ?? {} };
64568
- if (trimmed.length > 0)
64569
- embedder.skillsAlias = trimmed;
65177
+ const { primary, rest } = aliasFields(aliases);
65178
+ if (primary !== void 0)
65179
+ embedder.skillsAlias = primary;
64570
65180
  else
64571
65181
  delete embedder.skillsAlias;
65182
+ if (rest !== void 0)
65183
+ embedder.skillsAliases = rest;
65184
+ else
65185
+ delete embedder.skillsAliases;
64572
65186
  await configManager.save("user", { embedder });
64573
65187
  const { config: next } = await configManager.load();
64574
65188
  await postEmbedder(next);
@@ -64704,6 +65318,7 @@ ${direction}` : attachMentions(text, mentions);
64704
65318
  });
64705
65319
  }
64706
65320
  async function ignoredFilesPredicate() {
65321
+ const ripgrepPath = services.ripgrepPath();
64707
65322
  if (workspaceRoot === void 0 || ripgrepPath === void 0)
64708
65323
  return void 0;
64709
65324
  try {
@@ -65289,26 +65904,50 @@ ${direction}` : attachMentions(text, mentions);
65289
65904
  // rather than replacing a blank with the default and looking like it was set.
65290
65905
  ...config2.embedder?.indexPrefix !== void 0 ? { indexPrefix: config2.embedder.indexPrefix } : {},
65291
65906
  ...config2.embedder?.indexAlias !== void 0 ? { indexAlias: config2.embedder.indexAlias } : {},
65907
+ /*
65908
+ * Both spellings of both, because the panel shows the merged list and cannot merge what it
65909
+ * was never sent. The singular halves stay for older configs and older builds; the panel
65910
+ * runs them through `codebaseAliases`/`skillAliases`, which is the one place that knows how
65911
+ * the two fit together.
65912
+ */
65913
+ ...config2.embedder?.indexAliases !== void 0 ? { indexAliases: config2.embedder.indexAliases } : {},
65914
+ ...config2.embedder?.skillsAliases !== void 0 ? { skillsAliases: config2.embedder.skillsAliases } : {},
65292
65915
  ...config2.embedder?.skillsAlias !== void 0 ? { skillsAlias: config2.embedder.skillsAlias } : {},
65293
65916
  defaultIndexPrefix: DEFAULT_INDEX_PREFIX,
65294
65917
  indexedFiles
65295
65918
  });
65296
65919
  }
65297
- async function handleSaveEmbedder(profileId, model, dimensions, indexName, indexPrefix, indexAlias) {
65920
+ async function handleSaveEmbedder(profileId, model, dimensions, indexName, indexPrefix, indexAliases) {
65298
65921
  try {
65299
- await configManager.save("user", {
65300
- embedder: {
65301
- profileId,
65302
- model,
65303
- dimensions,
65304
- ...indexName !== void 0 && indexName.trim().length > 0 ? { indexName: indexName.trim() } : {},
65305
- // Absent rather than empty when cleared, so the default applies instead of a name
65306
- // beginning with a stray dash.
65307
- ...indexPrefix !== void 0 && indexPrefix.trim().length > 0 ? { indexPrefix: indexPrefix.trim() } : {},
65308
- // Same treatment: cleared means absent, which is what turns team scope back off.
65309
- ...indexAlias !== void 0 && indexAlias.trim().length > 0 ? { indexAlias: indexAlias.trim() } : {}
65310
- }
65311
- });
65922
+ const { config: current } = await configManager.load();
65923
+ const embedder = {
65924
+ ...current.embedder ?? {},
65925
+ profileId,
65926
+ model,
65927
+ dimensions
65928
+ };
65929
+ const put = (key, value) => {
65930
+ if (value === void 0)
65931
+ return;
65932
+ if (value.trim().length > 0)
65933
+ embedder[key] = value.trim();
65934
+ else
65935
+ delete embedder[key];
65936
+ };
65937
+ put("indexName", indexName);
65938
+ put("indexPrefix", indexPrefix);
65939
+ if (indexAliases !== void 0) {
65940
+ const { primary, rest } = aliasFields(indexAliases);
65941
+ if (primary !== void 0)
65942
+ embedder["indexAlias"] = primary;
65943
+ else
65944
+ delete embedder["indexAlias"];
65945
+ if (rest !== void 0)
65946
+ embedder["indexAliases"] = rest;
65947
+ else
65948
+ delete embedder["indexAliases"];
65949
+ }
65950
+ await configManager.save("user", { embedder });
65312
65951
  const { config: config2 } = await configManager.load();
65313
65952
  await postEmbedder(config2);
65314
65953
  scheduleDocsReindex("index prefix changed");
@@ -66347,7 +66986,7 @@ ${direction}` : attachMentions(text, mentions);
66347
66986
  } else if (message3.type === "clearMailIndex") {
66348
66987
  void handleClearMailIndex(message3.resync === true);
66349
66988
  } else if (message3.type === "saveSkillsAlias") {
66350
- void handleSaveSkillsAlias(message3.alias);
66989
+ void handleSaveSkillsAlias(message3.aliases);
66351
66990
  } else if (message3.type === "cancelIndexing") {
66352
66991
  if (message3.kind === void 0) {
66353
66992
  indexingAbort?.abort();
@@ -66359,7 +66998,7 @@ ${direction}` : attachMentions(text, mentions);
66359
66998
  indexingAborts.get(message3.kind)?.abort();
66360
66999
  }
66361
67000
  } else if (message3.type === "saveEmbedder") {
66362
- void handleSaveEmbedder(message3.profileId, message3.model, message3.dimensions, message3.indexName, message3.indexPrefix, message3.indexAlias);
67001
+ void handleSaveEmbedder(message3.profileId, message3.model, message3.dimensions, message3.indexName, message3.indexPrefix, message3.indexAliases);
66363
67002
  } else if (message3.type === "requestEmbedderModels") {
66364
67003
  void handleRequestEmbedderModels(message3.profileId);
66365
67004
  } else if (message3.type === "openWalkthrough") {
@@ -68242,6 +68881,17 @@ ${output}${note}`,
68242
68881
 
68243
68882
  // ../../packages/core/dist/tools/listFiles.js
68244
68883
  import { execFile as execFile7 } from "node:child_process";
68884
+
68885
+ // ../../packages/core/dist/tools/ripgrepError.js
68886
+ function describeRipgrepFailure(error51, what) {
68887
+ const code = error51?.code;
68888
+ if (code === "ENOENT") {
68889
+ 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.`;
68890
+ }
68891
+ return `${what} failed: ${error51 instanceof Error ? error51.message : String(error51)}`;
68892
+ }
68893
+
68894
+ // ../../packages/core/dist/tools/listFiles.js
68245
68895
  var paramsSchema16 = external_exports.object({
68246
68896
  path: external_exports.string().min(1).default(".").describe("Directory to list, relative to the workspace root."),
68247
68897
  recursive: external_exports.boolean().optional().describe("List the full subtree instead of just this directory."),
@@ -68303,7 +68953,7 @@ var listFilesTool = {
68303
68953
  content: params.includeIgnored === true ? "(no files found)" : "(no files found \u2014 .gitignore-excluded files are skipped; retry with includeIgnored: true)"
68304
68954
  };
68305
68955
  } catch (error51) {
68306
- return { content: `Could not list files: ${error51 instanceof Error ? error51.message : String(error51)}`, isError: true };
68956
+ return { content: describeRipgrepFailure(error51, "Listing files recursively"), isError: true };
68307
68957
  }
68308
68958
  }
68309
68959
  const entries = await context.fs.readdir(resolved.realPath);
@@ -68511,7 +69161,7 @@ var searchFilesTool = {
68511
69161
  content: params.includeIgnored === true ? "(no matches)" : "(no matches \u2014 .gitignore-excluded files were not searched; retry with includeIgnored: true)"
68512
69162
  };
68513
69163
  } catch (error51) {
68514
- return { content: `Search failed: ${error51 instanceof Error ? error51.message : String(error51)}`, isError: true };
69164
+ return { content: describeRipgrepFailure(error51, "Search"), isError: true };
68515
69165
  }
68516
69166
  }
68517
69167
  };
@@ -71184,7 +71834,7 @@ function respondJson(response, status, body) {
71184
71834
  }
71185
71835
 
71186
71836
  // src/cli.ts
71187
- var VERSION = true ? "0.69.0" : "unknown (not a packaged build)";
71837
+ var VERSION = true ? "0.74.0" : "unknown (not a packaged build)";
71188
71838
  var compat = installNodeCompat();
71189
71839
  function lastMeaningfulLine(problem) {
71190
71840
  const lines = problem.split(String.fromCharCode(10)).map((line) => line.trim()).filter((line) => line.length > 0 && !line.endsWith(":"));
@@ -71299,7 +71949,10 @@ Did you mean: --admin-id ${strayAdminValue.join(" --admin-id ")}
71299
71949
  workspaceRoot,
71300
71950
  dataDir,
71301
71951
  clientDir: path35.join(here, "client"),
71302
- ripgrepPath: resolveRipgrep(),
71952
+ // A function because `HostServices` asks per turn — see there for the extension update
71953
+ // that made a single resolution wrong. Resolved once here and handed over as a constant:
71954
+ // nothing moves a server's own `node_modules` under it mid-run.
71955
+ ripgrepPath: /* @__PURE__ */ ((resolved) => () => resolved)(resolveRipgrep()),
71303
71956
  ...credentialTool !== void 0 ? { credentialTool: { interpreter: credentialPython, file: credentialTool } } : {},
71304
71957
  handoffSeconds,
71305
71958
  noToken,