@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/server.js CHANGED
@@ -15481,7 +15481,7 @@ var require_events = __commonJS({
15481
15481
  var { webidl } = require_webidl();
15482
15482
  var { kEnumerableProperty } = require_util();
15483
15483
  var { MessagePort } = __require("worker_threads");
15484
- var MessageEvent = class _MessageEvent extends Event {
15484
+ var MessageEvent2 = class _MessageEvent extends Event {
15485
15485
  #eventInit;
15486
15486
  constructor(type, eventInitDict = {}) {
15487
15487
  webidl.argumentLengthCheck(arguments, 1, { header: "MessageEvent constructor" });
@@ -15549,7 +15549,7 @@ var require_events = __commonJS({
15549
15549
  return this.#eventInit.reason;
15550
15550
  }
15551
15551
  };
15552
- var ErrorEvent = class _ErrorEvent extends Event {
15552
+ var ErrorEvent2 = class _ErrorEvent extends Event {
15553
15553
  #eventInit;
15554
15554
  constructor(type, eventInitDict) {
15555
15555
  webidl.argumentLengthCheck(arguments, 1, { header: "ErrorEvent constructor" });
@@ -15579,7 +15579,7 @@ var require_events = __commonJS({
15579
15579
  return this.#eventInit.error;
15580
15580
  }
15581
15581
  };
15582
- Object.defineProperties(MessageEvent.prototype, {
15582
+ Object.defineProperties(MessageEvent2.prototype, {
15583
15583
  [Symbol.toStringTag]: {
15584
15584
  value: "MessageEvent",
15585
15585
  configurable: true
@@ -15600,7 +15600,7 @@ var require_events = __commonJS({
15600
15600
  code: kEnumerableProperty,
15601
15601
  wasClean: kEnumerableProperty
15602
15602
  });
15603
- Object.defineProperties(ErrorEvent.prototype, {
15603
+ Object.defineProperties(ErrorEvent2.prototype, {
15604
15604
  [Symbol.toStringTag]: {
15605
15605
  value: "ErrorEvent",
15606
15606
  configurable: true
@@ -15710,9 +15710,9 @@ var require_events = __commonJS({
15710
15710
  }
15711
15711
  ]);
15712
15712
  module.exports = {
15713
- MessageEvent,
15713
+ MessageEvent: MessageEvent2,
15714
15714
  CloseEvent,
15715
- ErrorEvent
15715
+ ErrorEvent: ErrorEvent2
15716
15716
  };
15717
15717
  }
15718
15718
  });
@@ -15723,7 +15723,7 @@ var require_util7 = __commonJS({
15723
15723
  "use strict";
15724
15724
  var { kReadyState, kController, kResponse, kBinaryType, kWebSocketURL } = require_symbols5();
15725
15725
  var { states, opcodes } = require_constants5();
15726
- var { MessageEvent, ErrorEvent } = require_events();
15726
+ var { MessageEvent: MessageEvent2, ErrorEvent: ErrorEvent2 } = require_events();
15727
15727
  function isEstablished(ws) {
15728
15728
  return ws[kReadyState] === states.OPEN;
15729
15729
  }
@@ -15756,7 +15756,7 @@ var require_util7 = __commonJS({
15756
15756
  dataForEvent = new Uint8Array(data).buffer;
15757
15757
  }
15758
15758
  }
15759
- fireEvent("message", ws, MessageEvent, {
15759
+ fireEvent("message", ws, MessageEvent2, {
15760
15760
  origin: ws[kWebSocketURL].origin,
15761
15761
  data: dataForEvent
15762
15762
  });
@@ -15789,7 +15789,7 @@ var require_util7 = __commonJS({
15789
15789
  response.socket.destroy();
15790
15790
  }
15791
15791
  if (reason) {
15792
- fireEvent("error", ws, ErrorEvent, {
15792
+ fireEvent("error", ws, ErrorEvent2, {
15793
15793
  error: new Error(reason)
15794
15794
  });
15795
15795
  }
@@ -39293,6 +39293,19 @@ var stdioServerSchema = external_exports.object({
39293
39293
  });
39294
39294
  var httpServerSchema = external_exports.object({
39295
39295
  url: external_exports.string().min(1).url(),
39296
+ /**
39297
+ * Which HTTP transport this server speaks.
39298
+ *
39299
+ * **It was not here, and zod strips what it does not declare** — so a config pasted from
39300
+ * another client saying `"type": "sse"` parsed happily, lost that word, and was then driven
39301
+ * with Streamable HTTP. §11 requires a pasted config to work unchanged, and this is the one
39302
+ * field that decides whether it works at all. Reported from real use as a remote server that
39303
+ * another client talks to and this one gets 401 from.
39304
+ *
39305
+ * Absent means "work it out" — see `buildTransport`. `http` is accepted as a spelling of
39306
+ * `streamable-http` because both appear in the wild.
39307
+ */
39308
+ type: external_exports.enum(["sse", "streamable-http", "http"]).optional(),
39296
39309
  headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
39297
39310
  disabled: external_exports.boolean().optional(),
39298
39311
  disabledTools: external_exports.array(external_exports.string()).optional(),
@@ -46868,6 +46881,14 @@ function merge2(single, many) {
46868
46881
  }
46869
46882
  return out;
46870
46883
  }
46884
+ function aliasFields(names) {
46885
+ const cleaned = merge2(void 0, names);
46886
+ const [primary, ...rest] = cleaned;
46887
+ return {
46888
+ primary,
46889
+ rest: rest.length > 0 ? rest : void 0
46890
+ };
46891
+ }
46871
46892
 
46872
46893
  // ../../packages/core/dist/tools/searchCodebase.js
46873
46894
  var paramsSchema6 = external_exports.object({
@@ -47043,16 +47064,44 @@ function toHit(match, self) {
47043
47064
  }
47044
47065
  async function searchTeamSkills(options, query, size = 5, signal) {
47045
47066
  const vector = await options.embedder.embed(query);
47046
- const matches = await options.searcher.searchByVector(options.collection, vector, {
47047
- size,
47048
- ...signal !== void 0 ? { signal } : {}
47049
- });
47050
- return matches.map((match) => toHit(match, options.owner));
47067
+ const tried = [];
47068
+ let firstError;
47069
+ for (const collection of options.collections) {
47070
+ tried.push(collection);
47071
+ let matches;
47072
+ try {
47073
+ matches = await options.searcher.searchByVector(collection, vector, {
47074
+ size,
47075
+ ...signal !== void 0 ? { signal } : {}
47076
+ });
47077
+ } catch (error51) {
47078
+ firstError ??= error51 instanceof Error ? error51 : new Error(String(error51));
47079
+ continue;
47080
+ }
47081
+ if (matches.length > 0) {
47082
+ return { hits: matches.map((match) => toHit(match, options.owner)), collection, tried };
47083
+ }
47084
+ }
47085
+ if (firstError !== void 0)
47086
+ throw firstError;
47087
+ return { hits: [], collection: void 0, tried };
47051
47088
  }
47052
47089
  async function findTeamSkillsNamed(options, name, signal) {
47053
- const candidates = await searchTeamSkills(options, name, 25, signal);
47054
47090
  const wanted = name.trim().toLowerCase();
47055
- return candidates.filter((hit) => hit.name.trim().toLowerCase() === wanted);
47091
+ const found = /* @__PURE__ */ new Map();
47092
+ for (const collection of options.collections) {
47093
+ let result;
47094
+ try {
47095
+ result = await searchTeamSkills({ ...options, collections: [collection] }, name, 25, signal);
47096
+ } catch {
47097
+ continue;
47098
+ }
47099
+ for (const hit of result.hits) {
47100
+ if (hit.name.trim().toLowerCase() === wanted)
47101
+ found.set(`${hit.owner ?? "?"}/${hit.name}`, hit);
47102
+ }
47103
+ }
47104
+ return [...found.values()];
47056
47105
  }
47057
47106
  function describeTeamSkillCollision(name, hits) {
47058
47107
  const others = hits.filter((hit) => !hit.isMine);
@@ -47068,11 +47117,13 @@ function describeTeamSkillCollision(name, hits) {
47068
47117
  " name and does not overwrite theirs."
47069
47118
  ].join("\n");
47070
47119
  }
47071
- function renderTeamSkillHits(hits, query) {
47120
+ function renderTeamSkillHits(found, query) {
47121
+ const { hits, collection, tried } = found;
47072
47122
  if (hits.length === 0) {
47073
47123
  return `No team skills match: ${query}
47074
- 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.`;
47124
+ ` + (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.";
47075
47125
  }
47126
+ 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;
47076
47127
  const rendered = hits.map((hit, position) => {
47077
47128
  const who = hit.isMine ? "yours" : hit.owner ?? "unknown owner";
47078
47129
  const where = hit.project === void 0 ? who : `${who} / ${hit.project}`;
@@ -47081,6 +47132,7 @@ ${hit.text}`;
47081
47132
  }).join("\n\n---\n\n");
47082
47133
  return [
47083
47134
  `${hits.length} team skill(s) matching: ${query}`,
47135
+ ...widened !== void 0 ? [widened] : [],
47084
47136
  'Anything not marked "yours" is a colleague\u2019s and has no file on this machine \u2014 the text',
47085
47137
  "above is the whole of it, so do not try to read_file it. To keep one, write your own copy",
47086
47138
  "with write_skill; that stores it under your name and leaves theirs alone.",
@@ -47123,24 +47175,27 @@ function createSearchTeamSkillsTool(options) {
47123
47175
  async execute(params) {
47124
47176
  const startedAt = Date.now();
47125
47177
  try {
47126
- const hits = await searchTeamSkills(options, params.query, params.size ?? 5);
47178
+ const found = await searchTeamSkills(options, params.query, params.size ?? 5);
47127
47179
  options.observer?.record({
47128
47180
  at: startedAt,
47129
47181
  source: "search_team_skills",
47182
+ // The one that answered, not the one that was asked first — the log is evidence about
47183
+ // what happened, and a widened search is exactly what somebody would want to see.
47184
+ collection: found.collection ?? found.tried.join(" \u2192 "),
47130
47185
  query: params.query,
47131
- collection: options.collection,
47132
- hits: hits.length,
47186
+ hits: found.hits.length,
47133
47187
  elapsedMs: Date.now() - startedAt,
47134
47188
  via: "index"
47135
47189
  });
47136
- return { content: renderTeamSkillHits(hits, params.query) };
47190
+ return { content: renderTeamSkillHits(found, params.query) };
47137
47191
  } catch (error51) {
47138
47192
  const message3 = error51 instanceof Error ? error51.message : String(error51);
47139
47193
  options.observer?.record({
47140
47194
  at: startedAt,
47141
47195
  source: "search_team_skills",
47142
47196
  query: params.query,
47143
- collection: options.collection,
47197
+ // Every name that would have been tried: the search failed before one could answer.
47198
+ collection: options.collections.join(" \u2192 "),
47144
47199
  hits: 0,
47145
47200
  elapsedMs: Date.now() - startedAt,
47146
47201
  error: message3
@@ -54071,21 +54126,477 @@ var StdioClientTransport = class {
54071
54126
  }
54072
54127
  };
54073
54128
 
54074
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1_ed45788dfbfe808cc09dd7daea6bd385/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
54075
- var import_content_type = __toESM(require_content_type(), 1);
54076
- function mediaTypeEssence(header) {
54077
- if (!header) {
54078
- return void 0;
54129
+ // ../../node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/index.js
54130
+ var ParseError = class extends Error {
54131
+ constructor(message3, options) {
54132
+ super(message3), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
54079
54133
  }
54080
- try {
54081
- return import_content_type.default.parse(header).type;
54082
- } catch {
54083
- const essence = (header.split(";", 1)[0] ?? "").trim().toLowerCase();
54084
- if (essence === "" || header.slice(essence.length).includes(",")) {
54085
- return void 0;
54134
+ };
54135
+ var LF = 10;
54136
+ var CR = 13;
54137
+ var SPACE = 32;
54138
+ function noop(_arg) {
54139
+ }
54140
+ function createParser(config2) {
54141
+ if (typeof config2 == "function")
54142
+ throw new TypeError(
54143
+ "`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"
54144
+ );
54145
+ const { onEvent = noop, onError = noop, onRetry = noop, onComment, maxBufferSize } = config2, pendingFragments = [];
54146
+ let pendingFragmentsLength = 0, isFirstChunk = true, id, data = "", dataLines = 0, eventType, terminated = false;
54147
+ function feed(chunk) {
54148
+ if (terminated)
54149
+ throw new Error(
54150
+ "Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."
54151
+ );
54152
+ if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
54153
+ const trailing2 = processLines(chunk);
54154
+ trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
54155
+ return;
54086
54156
  }
54087
- return essence;
54157
+ if (chunk.indexOf(`
54158
+ `) === -1 && chunk.indexOf("\r") === -1) {
54159
+ pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
54160
+ return;
54161
+ }
54162
+ pendingFragments.push(chunk);
54163
+ const input = pendingFragments.join("");
54164
+ pendingFragments.length = 0, pendingFragmentsLength = 0;
54165
+ const trailing = processLines(input);
54166
+ trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
54167
+ }
54168
+ function checkBufferSize() {
54169
+ maxBufferSize !== void 0 && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = true, pendingFragments.length = 0, pendingFragmentsLength = 0, id = void 0, data = "", dataLines = 0, eventType = void 0, onError(
54170
+ new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {
54171
+ type: "max-buffer-size-exceeded"
54172
+ })
54173
+ )));
54174
+ }
54175
+ function processLines(chunk) {
54176
+ let searchIndex = 0;
54177
+ if (chunk.indexOf("\r") === -1) {
54178
+ let lfIndex = chunk.indexOf(`
54179
+ `, searchIndex);
54180
+ for (; lfIndex !== -1; ) {
54181
+ if (searchIndex === lfIndex) {
54182
+ dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
54183
+ `, searchIndex);
54184
+ continue;
54185
+ }
54186
+ const firstCharCode = chunk.charCodeAt(searchIndex);
54187
+ if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
54188
+ const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
54189
+ if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
54190
+ onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
54191
+ `, searchIndex);
54192
+ continue;
54193
+ }
54194
+ data = dataLines === 0 ? value : `${data}
54195
+ ${value}`, dataLines++;
54196
+ } else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
54197
+ chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
54198
+ lfIndex
54199
+ ) || void 0 : parseLine(chunk, searchIndex, lfIndex);
54200
+ searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
54201
+ `, searchIndex);
54202
+ }
54203
+ return chunk.slice(searchIndex);
54204
+ }
54205
+ for (; searchIndex < chunk.length; ) {
54206
+ const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
54207
+ `, searchIndex);
54208
+ let lineEnd = -1;
54209
+ 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)
54210
+ break;
54211
+ parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
54212
+ }
54213
+ return chunk.slice(searchIndex);
54214
+ }
54215
+ function parseLine(chunk, start, end) {
54216
+ if (start === end) {
54217
+ dispatchEvent();
54218
+ return;
54219
+ }
54220
+ const firstCharCode = chunk.charCodeAt(start);
54221
+ if (isDataPrefix(chunk, start, firstCharCode)) {
54222
+ const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
54223
+ data = dataLines === 0 ? value2 : `${data}
54224
+ ${value2}`, dataLines++;
54225
+ return;
54226
+ }
54227
+ if (isEventPrefix(chunk, start, firstCharCode)) {
54228
+ eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
54229
+ return;
54230
+ }
54231
+ if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
54232
+ const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
54233
+ id = value2.includes("\0") ? void 0 : value2;
54234
+ return;
54235
+ }
54236
+ if (firstCharCode === 58) {
54237
+ if (onComment) {
54238
+ const line2 = chunk.slice(start, end);
54239
+ onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
54240
+ }
54241
+ return;
54242
+ }
54243
+ const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
54244
+ if (fieldSeparatorIndex === -1) {
54245
+ processField(line, "", line);
54246
+ return;
54247
+ }
54248
+ const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
54249
+ processField(field, value, line);
54088
54250
  }
54251
+ function processField(field, value, line) {
54252
+ switch (field) {
54253
+ case "event":
54254
+ eventType = value || void 0;
54255
+ break;
54256
+ case "data":
54257
+ data = dataLines === 0 ? value : `${data}
54258
+ ${value}`, dataLines++;
54259
+ break;
54260
+ case "id":
54261
+ id = value.includes("\0") ? void 0 : value;
54262
+ break;
54263
+ case "retry":
54264
+ /^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
54265
+ new ParseError(`Invalid \`retry\` value: "${value}"`, {
54266
+ type: "invalid-retry",
54267
+ value,
54268
+ line
54269
+ })
54270
+ );
54271
+ break;
54272
+ default:
54273
+ onError(
54274
+ new ParseError(
54275
+ `Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,
54276
+ { type: "unknown-field", field, value, line }
54277
+ )
54278
+ );
54279
+ break;
54280
+ }
54281
+ }
54282
+ function dispatchEvent() {
54283
+ dataLines > 0 && onEvent({
54284
+ id,
54285
+ event: eventType,
54286
+ data
54287
+ }), id = void 0, data = "", dataLines = 0, eventType = void 0;
54288
+ }
54289
+ function reset(options = {}) {
54290
+ if (options.consume && pendingFragments.length > 0) {
54291
+ const incompleteLine = pendingFragments.join("");
54292
+ parseLine(incompleteLine, 0, incompleteLine.length);
54293
+ }
54294
+ isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = false;
54295
+ }
54296
+ return { feed, reset };
54297
+ }
54298
+ function isDataPrefix(chunk, i, firstCharCode) {
54299
+ return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
54300
+ }
54301
+ function isEventPrefix(chunk, i, firstCharCode) {
54302
+ 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;
54303
+ }
54304
+
54305
+ // ../../node_modules/.pnpm/eventsource@3.0.7/node_modules/eventsource/dist/index.js
54306
+ var ErrorEvent = class extends Event {
54307
+ /**
54308
+ * Constructs a new `ErrorEvent` instance. This is typically not called directly,
54309
+ * but rather emitted by the `EventSource` object when an error occurs.
54310
+ *
54311
+ * @param type - The type of the event (should be "error")
54312
+ * @param errorEventInitDict - Optional properties to include in the error event
54313
+ */
54314
+ constructor(type, errorEventInitDict) {
54315
+ var _a3, _b;
54316
+ 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;
54317
+ }
54318
+ /**
54319
+ * Node.js "hides" the `message` and `code` properties of the `ErrorEvent` instance,
54320
+ * when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
54321
+ * we explicitly include the properties in the `inspect` method.
54322
+ *
54323
+ * This is automatically called by Node.js when you `console.log` an instance of this class.
54324
+ *
54325
+ * @param _depth - The current depth
54326
+ * @param options - The options passed to `util.inspect`
54327
+ * @param inspect - The inspect function to use (prevents having to import it from `util`)
54328
+ * @returns A string representation of the error
54329
+ */
54330
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
54331
+ return inspect(inspectableError(this), options);
54332
+ }
54333
+ /**
54334
+ * Deno "hides" the `message` and `code` properties of the `ErrorEvent` instance,
54335
+ * when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
54336
+ * we explicitly include the properties in the `inspect` method.
54337
+ *
54338
+ * This is automatically called by Deno when you `console.log` an instance of this class.
54339
+ *
54340
+ * @param inspect - The inspect function to use (prevents having to import it from `util`)
54341
+ * @param options - The options passed to `Deno.inspect`
54342
+ * @returns A string representation of the error
54343
+ */
54344
+ [/* @__PURE__ */ Symbol.for("Deno.customInspect")](inspect, options) {
54345
+ return inspect(inspectableError(this), options);
54346
+ }
54347
+ };
54348
+ function syntaxError(message3) {
54349
+ const DomException = globalThis.DOMException;
54350
+ return typeof DomException == "function" ? new DomException(message3, "SyntaxError") : new SyntaxError(message3);
54351
+ }
54352
+ function flattenError2(err) {
54353
+ 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}`;
54354
+ }
54355
+ function inspectableError(err) {
54356
+ return {
54357
+ type: err.type,
54358
+ message: err.message,
54359
+ code: err.code,
54360
+ defaultPrevented: err.defaultPrevented,
54361
+ cancelable: err.cancelable,
54362
+ timeStamp: err.timeStamp
54363
+ };
54364
+ }
54365
+ var __typeError = (msg) => {
54366
+ throw TypeError(msg);
54367
+ };
54368
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
54369
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
54370
+ 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);
54371
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
54372
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
54373
+ var _readyState;
54374
+ var _url2;
54375
+ var _redirectUrl;
54376
+ var _withCredentials;
54377
+ var _fetch;
54378
+ var _reconnectInterval;
54379
+ var _reconnectTimer;
54380
+ var _lastEventId;
54381
+ var _controller;
54382
+ var _parser;
54383
+ var _onError;
54384
+ var _onMessage;
54385
+ var _onOpen;
54386
+ var _EventSource_instances;
54387
+ var connect_fn;
54388
+ var _onFetchResponse;
54389
+ var _onFetchError;
54390
+ var getRequestOptions_fn;
54391
+ var _onEvent;
54392
+ var _onRetryChange;
54393
+ var failConnection_fn;
54394
+ var scheduleReconnect_fn;
54395
+ var _reconnect;
54396
+ var EventSource = class extends EventTarget {
54397
+ constructor(url2, eventSourceInitDict) {
54398
+ var _a3, _b;
54399
+ 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) => {
54400
+ var _a22;
54401
+ __privateGet(this, _parser).reset();
54402
+ const { body, redirected, status, headers } = response;
54403
+ if (status === 204) {
54404
+ __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
54405
+ return;
54406
+ }
54407
+ if (redirected ? __privateSet(this, _redirectUrl, new URL(response.url)) : __privateSet(this, _redirectUrl, void 0), status !== 200) {
54408
+ __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, `Non-200 status code (${status})`, status);
54409
+ return;
54410
+ }
54411
+ if (!(headers.get("content-type") || "").startsWith("text/event-stream")) {
54412
+ __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, 'Invalid content type, expected "text/event-stream"', status);
54413
+ return;
54414
+ }
54415
+ if (__privateGet(this, _readyState) === this.CLOSED)
54416
+ return;
54417
+ __privateSet(this, _readyState, this.OPEN);
54418
+ const openEvent = new Event("open");
54419
+ if ((_a22 = __privateGet(this, _onOpen)) == null || _a22.call(this, openEvent), this.dispatchEvent(openEvent), typeof body != "object" || !body || !("getReader" in body)) {
54420
+ __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Invalid response body, expected a web ReadableStream", status), this.close();
54421
+ return;
54422
+ }
54423
+ const decoder = new TextDecoder(), reader = body.getReader();
54424
+ let open = true;
54425
+ do {
54426
+ const { done, value } = await reader.read();
54427
+ 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));
54428
+ } while (open);
54429
+ }), __privateAdd(this, _onFetchError, (err) => {
54430
+ __privateSet(this, _controller, void 0), !(err.name === "AbortError" || err.type === "aborted") && __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this, flattenError2(err));
54431
+ }), __privateAdd(this, _onEvent, (event) => {
54432
+ typeof event.id == "string" && __privateSet(this, _lastEventId, event.id);
54433
+ const messageEvent = new MessageEvent(event.event || "message", {
54434
+ data: event.data,
54435
+ origin: __privateGet(this, _redirectUrl) ? __privateGet(this, _redirectUrl).origin : __privateGet(this, _url2).origin,
54436
+ lastEventId: event.id || ""
54437
+ });
54438
+ __privateGet(this, _onMessage) && (!event.event || event.event === "message") && __privateGet(this, _onMessage).call(this, messageEvent), this.dispatchEvent(messageEvent);
54439
+ }), __privateAdd(this, _onRetryChange, (value) => {
54440
+ __privateSet(this, _reconnectInterval, value);
54441
+ }), __privateAdd(this, _reconnect, () => {
54442
+ __privateSet(this, _reconnectTimer, void 0), __privateGet(this, _readyState) === this.CONNECTING && __privateMethod(this, _EventSource_instances, connect_fn).call(this);
54443
+ });
54444
+ try {
54445
+ if (url2 instanceof URL)
54446
+ __privateSet(this, _url2, url2);
54447
+ else if (typeof url2 == "string")
54448
+ __privateSet(this, _url2, new URL(url2, getBaseURL()));
54449
+ else
54450
+ throw new Error("Invalid URL");
54451
+ } catch {
54452
+ throw syntaxError("An invalid or illegal string was specified");
54453
+ }
54454
+ __privateSet(this, _parser, createParser({
54455
+ onEvent: __privateGet(this, _onEvent),
54456
+ onRetry: __privateGet(this, _onRetryChange)
54457
+ })), __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);
54458
+ }
54459
+ /**
54460
+ * Returns the state of this EventSource object's connection. It can have the values described below.
54461
+ *
54462
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
54463
+ *
54464
+ * Note: typed as `number` instead of `0 | 1 | 2` for compatibility with the `EventSource` interface,
54465
+ * defined in the TypeScript `dom` library.
54466
+ *
54467
+ * @public
54468
+ */
54469
+ get readyState() {
54470
+ return __privateGet(this, _readyState);
54471
+ }
54472
+ /**
54473
+ * Returns the URL providing the event stream.
54474
+ *
54475
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
54476
+ *
54477
+ * @public
54478
+ */
54479
+ get url() {
54480
+ return __privateGet(this, _url2).href;
54481
+ }
54482
+ /**
54483
+ * Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
54484
+ *
54485
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
54486
+ */
54487
+ get withCredentials() {
54488
+ return __privateGet(this, _withCredentials);
54489
+ }
54490
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
54491
+ get onerror() {
54492
+ return __privateGet(this, _onError);
54493
+ }
54494
+ set onerror(value) {
54495
+ __privateSet(this, _onError, value);
54496
+ }
54497
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
54498
+ get onmessage() {
54499
+ return __privateGet(this, _onMessage);
54500
+ }
54501
+ set onmessage(value) {
54502
+ __privateSet(this, _onMessage, value);
54503
+ }
54504
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
54505
+ get onopen() {
54506
+ return __privateGet(this, _onOpen);
54507
+ }
54508
+ set onopen(value) {
54509
+ __privateSet(this, _onOpen, value);
54510
+ }
54511
+ addEventListener(type, listener, options) {
54512
+ const listen = listener;
54513
+ super.addEventListener(type, listen, options);
54514
+ }
54515
+ removeEventListener(type, listener, options) {
54516
+ const listen = listener;
54517
+ super.removeEventListener(type, listen, options);
54518
+ }
54519
+ /**
54520
+ * Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
54521
+ *
54522
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
54523
+ *
54524
+ * @public
54525
+ */
54526
+ close() {
54527
+ __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));
54528
+ }
54529
+ };
54530
+ _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(), /**
54531
+ * Connect to the given URL and start receiving events
54532
+ *
54533
+ * @internal
54534
+ */
54535
+ connect_fn = function() {
54536
+ __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));
54537
+ }, _onFetchResponse = /* @__PURE__ */ new WeakMap(), _onFetchError = /* @__PURE__ */ new WeakMap(), /**
54538
+ * Get request options for the `fetch()` request
54539
+ *
54540
+ * @returns The request options
54541
+ * @internal
54542
+ */
54543
+ getRequestOptions_fn = function() {
54544
+ var _a3;
54545
+ const init = {
54546
+ // [spec] Let `corsAttributeState` be `Anonymous`…
54547
+ // [spec] …will have their mode set to "cors"…
54548
+ mode: "cors",
54549
+ redirect: "follow",
54550
+ headers: { Accept: "text/event-stream", ...__privateGet(this, _lastEventId) ? { "Last-Event-ID": __privateGet(this, _lastEventId) } : void 0 },
54551
+ cache: "no-store",
54552
+ signal: (_a3 = __privateGet(this, _controller)) == null ? void 0 : _a3.signal
54553
+ };
54554
+ return "window" in globalThis && (init.credentials = this.withCredentials ? "include" : "same-origin"), init;
54555
+ }, _onEvent = /* @__PURE__ */ new WeakMap(), _onRetryChange = /* @__PURE__ */ new WeakMap(), /**
54556
+ * Handles the process referred to in the EventSource specification as "failing a connection".
54557
+ *
54558
+ * @param error - The error causing the connection to fail
54559
+ * @param code - The HTTP status code, if available
54560
+ * @internal
54561
+ */
54562
+ failConnection_fn = function(message3, code) {
54563
+ var _a3;
54564
+ __privateGet(this, _readyState) !== this.CLOSED && __privateSet(this, _readyState, this.CLOSED);
54565
+ const errorEvent = new ErrorEvent("error", { code, message: message3 });
54566
+ (_a3 = __privateGet(this, _onError)) == null || _a3.call(this, errorEvent), this.dispatchEvent(errorEvent);
54567
+ }, /**
54568
+ * Schedules a reconnection attempt against the EventSource endpoint.
54569
+ *
54570
+ * @param message - The error causing the connection to fail
54571
+ * @param code - The HTTP status code, if available
54572
+ * @internal
54573
+ */
54574
+ scheduleReconnect_fn = function(message3, code) {
54575
+ var _a3;
54576
+ if (__privateGet(this, _readyState) === this.CLOSED)
54577
+ return;
54578
+ __privateSet(this, _readyState, this.CONNECTING);
54579
+ const errorEvent = new ErrorEvent("error", { code, message: message3 });
54580
+ (_a3 = __privateGet(this, _onError)) == null || _a3.call(this, errorEvent), this.dispatchEvent(errorEvent), __privateSet(this, _reconnectTimer, setTimeout(__privateGet(this, _reconnect), __privateGet(this, _reconnectInterval)));
54581
+ }, _reconnect = /* @__PURE__ */ new WeakMap(), /**
54582
+ * ReadyState representing an EventSource currently trying to connect
54583
+ *
54584
+ * @public
54585
+ */
54586
+ EventSource.CONNECTING = 0, /**
54587
+ * ReadyState representing an EventSource connection that is open (eg connected)
54588
+ *
54589
+ * @public
54590
+ */
54591
+ EventSource.OPEN = 1, /**
54592
+ * ReadyState representing an EventSource connection that is closed (eg disconnected)
54593
+ *
54594
+ * @public
54595
+ */
54596
+ EventSource.CLOSED = 2;
54597
+ function getBaseURL() {
54598
+ const doc = "document" in globalThis ? globalThis.document : void 0;
54599
+ return doc && typeof doc == "object" && "baseURI" in doc && typeof doc.baseURI == "string" ? doc.baseURI : void 0;
54089
54600
  }
54090
54601
 
54091
54602
  // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1_ed45788dfbfe808cc09dd7daea6bd385/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.js
@@ -54958,180 +55469,212 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
54958
55469
  return OAuthClientInformationFullSchema.parse(await response.json());
54959
55470
  }
54960
55471
 
54961
- // ../../node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/index.js
54962
- var ParseError = class extends Error {
54963
- constructor(message3, options) {
54964
- super(message3), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
55472
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1_ed45788dfbfe808cc09dd7daea6bd385/node_modules/@modelcontextprotocol/sdk/dist/esm/client/sse.js
55473
+ var SseError = class extends Error {
55474
+ constructor(code, message3, event) {
55475
+ super(`SSE error: ${message3}`);
55476
+ this.code = code;
55477
+ this.event = event;
54965
55478
  }
54966
55479
  };
54967
- var LF = 10;
54968
- var CR = 13;
54969
- var SPACE = 32;
54970
- function noop(_arg) {
54971
- }
54972
- function createParser(config2) {
54973
- if (typeof config2 == "function")
54974
- throw new TypeError(
54975
- "`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"
54976
- );
54977
- const { onEvent = noop, onError = noop, onRetry = noop, onComment, maxBufferSize } = config2, pendingFragments = [];
54978
- let pendingFragmentsLength = 0, isFirstChunk = true, id, data = "", dataLines = 0, eventType, terminated = false;
54979
- function feed(chunk) {
54980
- if (terminated)
54981
- throw new Error(
54982
- "Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."
54983
- );
54984
- if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
54985
- const trailing2 = processLines(chunk);
54986
- trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
54987
- return;
55480
+ var SSEClientTransport = class {
55481
+ constructor(url2, opts) {
55482
+ this._url = url2;
55483
+ this._resourceMetadataUrl = void 0;
55484
+ this._scope = void 0;
55485
+ this._eventSourceInit = opts?.eventSourceInit;
55486
+ this._requestInit = opts?.requestInit;
55487
+ this._authProvider = opts?.authProvider;
55488
+ this._fetch = opts?.fetch;
55489
+ this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
55490
+ }
55491
+ async _authThenStart() {
55492
+ if (!this._authProvider) {
55493
+ throw new UnauthorizedError("No auth provider");
54988
55494
  }
54989
- if (chunk.indexOf(`
54990
- `) === -1 && chunk.indexOf("\r") === -1) {
54991
- pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
54992
- return;
55495
+ let result;
55496
+ try {
55497
+ result = await auth(this._authProvider, {
55498
+ serverUrl: this._url,
55499
+ resourceMetadataUrl: this._resourceMetadataUrl,
55500
+ scope: this._scope,
55501
+ fetchFn: this._fetchWithInit
55502
+ });
55503
+ } catch (error51) {
55504
+ this.onerror?.(error51);
55505
+ throw error51;
54993
55506
  }
54994
- pendingFragments.push(chunk);
54995
- const input = pendingFragments.join("");
54996
- pendingFragments.length = 0, pendingFragmentsLength = 0;
54997
- const trailing = processLines(input);
54998
- trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
54999
- }
55000
- function checkBufferSize() {
55001
- maxBufferSize !== void 0 && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = true, pendingFragments.length = 0, pendingFragmentsLength = 0, id = void 0, data = "", dataLines = 0, eventType = void 0, onError(
55002
- new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {
55003
- type: "max-buffer-size-exceeded"
55004
- })
55005
- )));
55507
+ if (result !== "AUTHORIZED") {
55508
+ throw new UnauthorizedError();
55509
+ }
55510
+ return await this._startOrAuth();
55006
55511
  }
55007
- function processLines(chunk) {
55008
- let searchIndex = 0;
55009
- if (chunk.indexOf("\r") === -1) {
55010
- let lfIndex = chunk.indexOf(`
55011
- `, searchIndex);
55012
- for (; lfIndex !== -1; ) {
55013
- if (searchIndex === lfIndex) {
55014
- dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
55015
- `, searchIndex);
55016
- continue;
55017
- }
55018
- const firstCharCode = chunk.charCodeAt(searchIndex);
55019
- if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
55020
- const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
55021
- if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
55022
- onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
55023
- `, searchIndex);
55024
- continue;
55025
- }
55026
- data = dataLines === 0 ? value : `${data}
55027
- ${value}`, dataLines++;
55028
- } else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
55029
- chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
55030
- lfIndex
55031
- ) || void 0 : parseLine(chunk, searchIndex, lfIndex);
55032
- searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
55033
- `, searchIndex);
55512
+ async _commonHeaders() {
55513
+ const headers = {};
55514
+ if (this._authProvider) {
55515
+ const tokens = await this._authProvider.tokens();
55516
+ if (tokens) {
55517
+ headers["Authorization"] = `Bearer ${tokens.access_token}`;
55034
55518
  }
55035
- return chunk.slice(searchIndex);
55036
55519
  }
55037
- for (; searchIndex < chunk.length; ) {
55038
- const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
55039
- `, searchIndex);
55040
- let lineEnd = -1;
55041
- 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)
55042
- break;
55043
- parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
55520
+ if (this._protocolVersion) {
55521
+ headers["mcp-protocol-version"] = this._protocolVersion;
55044
55522
  }
55045
- return chunk.slice(searchIndex);
55523
+ const extraHeaders = normalizeHeaders(this._requestInit?.headers);
55524
+ return new Headers({
55525
+ ...headers,
55526
+ ...extraHeaders
55527
+ });
55046
55528
  }
55047
- function parseLine(chunk, start, end) {
55048
- if (start === end) {
55049
- dispatchEvent();
55050
- return;
55529
+ _startOrAuth() {
55530
+ const fetchImpl = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
55531
+ return new Promise((resolve, reject2) => {
55532
+ this._eventSource = new EventSource(this._url.href, {
55533
+ ...this._eventSourceInit,
55534
+ fetch: async (url2, init) => {
55535
+ const headers = await this._commonHeaders();
55536
+ headers.set("Accept", "text/event-stream");
55537
+ const response = await fetchImpl(url2, {
55538
+ ...init,
55539
+ headers
55540
+ });
55541
+ if (response.status === 401 && response.headers.has("www-authenticate")) {
55542
+ const { resourceMetadataUrl, scope } = extractWWWAuthenticateParams(response);
55543
+ this._resourceMetadataUrl = resourceMetadataUrl;
55544
+ this._scope = scope;
55545
+ }
55546
+ return response;
55547
+ }
55548
+ });
55549
+ this._abortController = new AbortController();
55550
+ this._eventSource.onerror = (event) => {
55551
+ if (event.code === 401 && this._authProvider) {
55552
+ this._authThenStart().then(resolve, reject2);
55553
+ return;
55554
+ }
55555
+ const error51 = new SseError(event.code, event.message, event);
55556
+ reject2(error51);
55557
+ this.onerror?.(error51);
55558
+ };
55559
+ this._eventSource.onopen = () => {
55560
+ };
55561
+ this._eventSource.addEventListener("endpoint", (event) => {
55562
+ const messageEvent = event;
55563
+ try {
55564
+ this._endpoint = new URL(messageEvent.data, this._url);
55565
+ if (this._endpoint.origin !== this._url.origin) {
55566
+ throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`);
55567
+ }
55568
+ } catch (error51) {
55569
+ reject2(error51);
55570
+ this.onerror?.(error51);
55571
+ void this.close();
55572
+ return;
55573
+ }
55574
+ resolve();
55575
+ });
55576
+ this._eventSource.onmessage = (event) => {
55577
+ const messageEvent = event;
55578
+ let message3;
55579
+ try {
55580
+ message3 = JSONRPCMessageSchema.parse(JSON.parse(messageEvent.data));
55581
+ } catch (error51) {
55582
+ this.onerror?.(error51);
55583
+ return;
55584
+ }
55585
+ this.onmessage?.(message3);
55586
+ };
55587
+ });
55588
+ }
55589
+ async start() {
55590
+ if (this._eventSource) {
55591
+ throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");
55051
55592
  }
55052
- const firstCharCode = chunk.charCodeAt(start);
55053
- if (isDataPrefix(chunk, start, firstCharCode)) {
55054
- const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
55055
- data = dataLines === 0 ? value2 : `${data}
55056
- ${value2}`, dataLines++;
55057
- return;
55593
+ return await this._startOrAuth();
55594
+ }
55595
+ /**
55596
+ * 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.
55597
+ */
55598
+ async finishAuth(authorizationCode) {
55599
+ if (!this._authProvider) {
55600
+ throw new UnauthorizedError("No auth provider");
55058
55601
  }
55059
- if (isEventPrefix(chunk, start, firstCharCode)) {
55060
- eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
55061
- return;
55602
+ const result = await auth(this._authProvider, {
55603
+ serverUrl: this._url,
55604
+ authorizationCode,
55605
+ resourceMetadataUrl: this._resourceMetadataUrl,
55606
+ scope: this._scope,
55607
+ fetchFn: this._fetchWithInit
55608
+ });
55609
+ if (result !== "AUTHORIZED") {
55610
+ throw new UnauthorizedError("Failed to authorize");
55062
55611
  }
55063
- if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
55064
- const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
55065
- id = value2.includes("\0") ? void 0 : value2;
55066
- return;
55612
+ }
55613
+ async close() {
55614
+ this._abortController?.abort();
55615
+ this._eventSource?.close();
55616
+ this.onclose?.();
55617
+ }
55618
+ async send(message3) {
55619
+ if (!this._endpoint) {
55620
+ throw new Error("Not connected");
55067
55621
  }
55068
- if (firstCharCode === 58) {
55069
- if (onComment) {
55070
- const line2 = chunk.slice(start, end);
55071
- onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
55622
+ try {
55623
+ const headers = await this._commonHeaders();
55624
+ headers.set("content-type", "application/json");
55625
+ const init = {
55626
+ ...this._requestInit,
55627
+ method: "POST",
55628
+ headers,
55629
+ body: JSON.stringify(message3),
55630
+ signal: this._abortController?.signal
55631
+ };
55632
+ const response = await (this._fetch ?? fetch)(this._endpoint, init);
55633
+ if (!response.ok) {
55634
+ const text = await response.text().catch(() => null);
55635
+ if (response.status === 401 && this._authProvider) {
55636
+ const { resourceMetadataUrl, scope } = extractWWWAuthenticateParams(response);
55637
+ this._resourceMetadataUrl = resourceMetadataUrl;
55638
+ this._scope = scope;
55639
+ const result = await auth(this._authProvider, {
55640
+ serverUrl: this._url,
55641
+ resourceMetadataUrl: this._resourceMetadataUrl,
55642
+ scope: this._scope,
55643
+ fetchFn: this._fetchWithInit
55644
+ });
55645
+ if (result !== "AUTHORIZED") {
55646
+ throw new UnauthorizedError();
55647
+ }
55648
+ return this.send(message3);
55649
+ }
55650
+ throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
55072
55651
  }
55073
- return;
55074
- }
55075
- const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
55076
- if (fieldSeparatorIndex === -1) {
55077
- processField(line, "", line);
55078
- return;
55652
+ await response.body?.cancel();
55653
+ } catch (error51) {
55654
+ this.onerror?.(error51);
55655
+ throw error51;
55079
55656
  }
55080
- const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
55081
- processField(field, value, line);
55082
55657
  }
55083
- function processField(field, value, line) {
55084
- switch (field) {
55085
- case "event":
55086
- eventType = value || void 0;
55087
- break;
55088
- case "data":
55089
- data = dataLines === 0 ? value : `${data}
55090
- ${value}`, dataLines++;
55091
- break;
55092
- case "id":
55093
- id = value.includes("\0") ? void 0 : value;
55094
- break;
55095
- case "retry":
55096
- /^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
55097
- new ParseError(`Invalid \`retry\` value: "${value}"`, {
55098
- type: "invalid-retry",
55099
- value,
55100
- line
55101
- })
55102
- );
55103
- break;
55104
- default:
55105
- onError(
55106
- new ParseError(
55107
- `Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,
55108
- { type: "unknown-field", field, value, line }
55109
- )
55110
- );
55111
- break;
55112
- }
55658
+ setProtocolVersion(version2) {
55659
+ this._protocolVersion = version2;
55113
55660
  }
55114
- function dispatchEvent() {
55115
- dataLines > 0 && onEvent({
55116
- id,
55117
- event: eventType,
55118
- data
55119
- }), id = void 0, data = "", dataLines = 0, eventType = void 0;
55661
+ };
55662
+
55663
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1_ed45788dfbfe808cc09dd7daea6bd385/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
55664
+ var import_content_type = __toESM(require_content_type(), 1);
55665
+ function mediaTypeEssence(header) {
55666
+ if (!header) {
55667
+ return void 0;
55120
55668
  }
55121
- function reset(options = {}) {
55122
- if (options.consume && pendingFragments.length > 0) {
55123
- const incompleteLine = pendingFragments.join("");
55124
- parseLine(incompleteLine, 0, incompleteLine.length);
55669
+ try {
55670
+ return import_content_type.default.parse(header).type;
55671
+ } catch {
55672
+ const essence = (header.split(";", 1)[0] ?? "").trim().toLowerCase();
55673
+ if (essence === "" || header.slice(essence.length).includes(",")) {
55674
+ return void 0;
55125
55675
  }
55126
- isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = false;
55676
+ return essence;
55127
55677
  }
55128
- return { feed, reset };
55129
- }
55130
- function isDataPrefix(chunk, i, firstCharCode) {
55131
- return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
55132
- }
55133
- function isEventPrefix(chunk, i, firstCharCode) {
55134
- 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;
55135
55678
  }
55136
55679
 
55137
55680
  // ../../node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/stream.js
@@ -55595,10 +56138,15 @@ async function buildTransport(config2, secrets) {
55595
56138
  });
55596
56139
  }
55597
56140
  const headers = await interpolateSecrets(config2.headers, secrets);
55598
- const httpTransport = new StreamableHTTPClientTransport(new URL(config2.url), {
55599
- ...Object.keys(headers).length > 0 ? { requestInit: { headers } } : {}
55600
- });
55601
- return httpTransport;
56141
+ return httpTransport(config2.url, headers, httpKindOf(config2));
56142
+ }
56143
+ function httpKindOf(config2) {
56144
+ return config2.type === "sse" ? "sse" : "streamable-http";
56145
+ }
56146
+ function httpTransport(url2, headers, kind) {
56147
+ const options = Object.keys(headers).length > 0 ? { requestInit: { headers } } : {};
56148
+ const transport = kind === "sse" ? new SSEClientTransport(new URL(url2), options) : new StreamableHTTPClientTransport(new URL(url2), options);
56149
+ return transport;
55602
56150
  }
55603
56151
  var McpConnection = class {
55604
56152
  serverName;
@@ -55627,10 +56175,31 @@ var McpConnection = class {
55627
56175
  if (transport instanceof StdioClientTransport) {
55628
56176
  this.attachStderr(transport);
55629
56177
  }
55630
- await client.connect(transport);
56178
+ this.onLog(await describeMcpRequest(this.config, this.secrets));
56179
+ try {
56180
+ await client.connect(transport);
56181
+ } catch (error51) {
56182
+ const fallback = await this.fallbackTransport(error51);
56183
+ if (fallback === void 0)
56184
+ throw error51;
56185
+ await client.connect(fallback);
56186
+ this.client = client;
56187
+ this.transport = fallback;
56188
+ this.onLog(`Connected over SSE; Streamable HTTP was refused (${describeError(error51)})`);
56189
+ return;
56190
+ }
55631
56191
  this.client = client;
55632
56192
  this.transport = transport;
55633
56193
  }
56194
+ /** The other HTTP protocol, when this server never said which it speaks. */
56195
+ async fallbackTransport(error51) {
56196
+ const config2 = this.config;
56197
+ if (isStdioServer(config2) || config2.type !== void 0)
56198
+ return void 0;
56199
+ this.onLog(`Streamable HTTP failed (${describeError(error51)}) \u2014 retrying as SSE`);
56200
+ const headers = await interpolateSecrets(config2.headers, this.secrets);
56201
+ return httpTransport(config2.url, headers, "sse");
56202
+ }
55634
56203
  attachStderr(transport) {
55635
56204
  const stream = transport.stderr;
55636
56205
  if (stream === null)
@@ -55687,6 +56256,23 @@ function renderToolResult(result) {
55687
56256
  });
55688
56257
  return parts.join("\n");
55689
56258
  }
56259
+ function describeError(error51) {
56260
+ return error51 instanceof Error ? error51.message : String(error51);
56261
+ }
56262
+ async function describeMcpRequest(config2, secrets) {
56263
+ if (isStdioServer(config2))
56264
+ return `Starting ${config2.command}`;
56265
+ const kind = config2.type ?? "streamable-http (no type set; SSE is the fallback)";
56266
+ let names;
56267
+ try {
56268
+ const resolved = await interpolateSecrets(config2.headers, secrets);
56269
+ names = Object.entries(resolved).map(([name, value]) => value.trim().length === 0 ? `${name} (EMPTY)` : name);
56270
+ } catch (error51) {
56271
+ return `Connecting to ${config2.url} as ${kind}; headers unresolved: ${describeError(error51)}`;
56272
+ }
56273
+ const headers = names.length === 0 ? "no headers configured" : `headers: ${names.join(", ")}`;
56274
+ return `Connecting to ${config2.url} as ${kind}; ${headers}`;
56275
+ }
55690
56276
 
55691
56277
  // ../../packages/core/dist/mcp/registry.js
55692
56278
  function adaptTool(serverName, toolName, description, inputSchema, call) {
@@ -57798,6 +58384,8 @@ async function truncateToolResult(content, store, maxChars = DEFAULT_MAX_CHARS)
57798
58384
  var DEFAULT_MAX_ITERATIONS = 25;
57799
58385
  var BOOKKEEPING_TOOLS = /* @__PURE__ */ new Set(["plan_progress"]);
57800
58386
  var MAX_REFUNDED_STEPS = 20;
58387
+ var FORM_DISMISSED = "The user dismissed the form without answering.";
58388
+ var MAX_FORM_RESETS = 5;
57801
58389
  var MAX_CONSECUTIVE_MISTAKES = 3;
57802
58390
  async function prepareModelMessages(conversation, provider, tools, options, events) {
57803
58391
  const contextWindow = options.contextWindow ?? 0;
@@ -57980,6 +58568,7 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
57980
58568
  conversation.addUserMessage(userMessage, options.images);
57981
58569
  const maxIterations = options.maxIterations ?? DEFAULT_MAX_ITERATIONS;
57982
58570
  let refunded = 0;
58571
+ let formResets = 0;
57983
58572
  const mistakeCounts = /* @__PURE__ */ new Map();
57984
58573
  let continueNudges = 0;
57985
58574
  const mode = options.mode ?? CODE_MODE;
@@ -58053,6 +58642,10 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
58053
58642
  conversation.addUserMessage(message3);
58054
58643
  events.onQueuedMessageConsumed?.(message3);
58055
58644
  }
58645
+ if (queued.length > 0) {
58646
+ iteration = -1;
58647
+ refunded = 0;
58648
+ }
58056
58649
  if (toolCall.name === "attempt_completion" || toolCall.name === "ask_followup_question") {
58057
58650
  events.onDone();
58058
58651
  return;
@@ -58061,6 +58654,11 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
58061
58654
  refunded += 1;
58062
58655
  iteration -= 1;
58063
58656
  }
58657
+ if (toolCall.name === "ask_user_form" && result.isError !== true && !result.content.startsWith(FORM_DISMISSED) && formResets < MAX_FORM_RESETS) {
58658
+ formResets += 1;
58659
+ iteration = -1;
58660
+ refunded = 0;
58661
+ }
58064
58662
  if (result.path !== void 0) {
58065
58663
  if (result.isError === true) {
58066
58664
  const count = (mistakeCounts.get(result.path) ?? 0) + 1;
@@ -58074,7 +58672,7 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
58074
58672
  }
58075
58673
  }
58076
58674
  }
58077
- 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.`);
58675
+ 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.`);
58078
58676
  }
58079
58677
 
58080
58678
  // ../../packages/core/dist/host/bridge.js
@@ -61366,7 +61964,7 @@ function stripEmpty(source) {
61366
61964
  var SCHEDULE_TICK_MS = 15e3;
61367
61965
  var STUCK_RUN_MS = 30 * 6e4;
61368
61966
  function wireChatBridge(services) {
61369
- const { transport, secrets, ui, workspaceRoot, storageDir, ripgrepPath } = services;
61967
+ const { transport, secrets, ui, workspaceRoot, storageDir } = services;
61370
61968
  const logger = new Logger({ level: "debug", sink: services.logSink });
61371
61969
  const configManager = new ConfigManager(services.configStore, services.workspaceRoot);
61372
61970
  const httpClient = services.httpClient ?? new FetchHttpClient();
@@ -62697,9 +63295,17 @@ ${preview.text}` } : {}
62697
63295
  // that stops to wait for one would never finish.
62698
63296
  ...schedule === void 0 ? { requestForm } : {},
62699
63297
  signal: activeAbortController.signal,
62700
- // Supplied by the host, not imported by core: the binary is platform-specific and
62701
- // lives in the VSIX, so resolving it is a host concern (§4).
62702
- ...ripgrepPath !== void 0 ? { ripgrepPath } : {}
63298
+ /*
63299
+ * Supplied by the host, not imported by core: the binary is platform-specific and
63300
+ * lives in the VSIX, so resolving it is a host concern (§4).
63301
+ *
63302
+ * Asked per turn rather than captured once, because a VS Code extension update
63303
+ * deletes the folder the previous answer pointed into. See `HostServices`.
63304
+ */
63305
+ ...(() => {
63306
+ const resolved = services.ripgrepPath();
63307
+ return resolved !== void 0 ? { ripgrepPath: resolved } : {};
63308
+ })()
62703
63309
  };
62704
63310
  consultationContext = () => toolContext;
62705
63311
  pythonNestedContext = toolContext;
@@ -62787,8 +63393,12 @@ ${direction}` : attachMentions(text, mentions);
62787
63393
  skillAliases(config2).length > 0 && search !== void 0 && embedder !== void 0 ? {
62788
63394
  searcher: search.searcher,
62789
63395
  embedder,
62790
- // The first is the default circle, exactly as it is for the codebase index.
62791
- collection: skillAliases(config2)[0],
63396
+ /*
63397
+ * All of them, in order — the first is the ordinary circle and the rest are what a
63398
+ * search widens into when it holds nothing. Handing over only the first is what
63399
+ * made the extra names typed in the panel do nothing at all for skills.
63400
+ */
63401
+ collections: skillAliases(config2),
62792
63402
  ...indexOwner(config2) !== void 0 ? { owner: indexOwner(config2) } : {}
62793
63403
  } : void 0,
62794
63404
  /*
@@ -64418,15 +65028,19 @@ ${direction}` : attachMentions(text, mentions);
64418
65028
  const digest = createHash3("sha256").update(path23.resolve(workspaceRoot).toLowerCase()).digest("hex").slice(0, 16);
64419
65029
  return `${config2?.embedder?.indexPrefix ?? DEFAULT_INDEX_PREFIX}-${digest}`;
64420
65030
  }
64421
- async function handleSaveSkillsAlias(alias) {
65031
+ async function handleSaveSkillsAlias(aliases) {
64422
65032
  try {
64423
65033
  const { config: config2 } = await configManager.load();
64424
- const trimmed = alias.trim();
64425
65034
  const embedder = { ...config2.embedder ?? {} };
64426
- if (trimmed.length > 0)
64427
- embedder.skillsAlias = trimmed;
65035
+ const { primary, rest } = aliasFields(aliases);
65036
+ if (primary !== void 0)
65037
+ embedder.skillsAlias = primary;
64428
65038
  else
64429
65039
  delete embedder.skillsAlias;
65040
+ if (rest !== void 0)
65041
+ embedder.skillsAliases = rest;
65042
+ else
65043
+ delete embedder.skillsAliases;
64430
65044
  await configManager.save("user", { embedder });
64431
65045
  const { config: next } = await configManager.load();
64432
65046
  await postEmbedder(next);
@@ -64562,6 +65176,7 @@ ${direction}` : attachMentions(text, mentions);
64562
65176
  });
64563
65177
  }
64564
65178
  async function ignoredFilesPredicate() {
65179
+ const ripgrepPath = services.ripgrepPath();
64565
65180
  if (workspaceRoot === void 0 || ripgrepPath === void 0)
64566
65181
  return void 0;
64567
65182
  try {
@@ -65147,26 +65762,50 @@ ${direction}` : attachMentions(text, mentions);
65147
65762
  // rather than replacing a blank with the default and looking like it was set.
65148
65763
  ...config2.embedder?.indexPrefix !== void 0 ? { indexPrefix: config2.embedder.indexPrefix } : {},
65149
65764
  ...config2.embedder?.indexAlias !== void 0 ? { indexAlias: config2.embedder.indexAlias } : {},
65765
+ /*
65766
+ * Both spellings of both, because the panel shows the merged list and cannot merge what it
65767
+ * was never sent. The singular halves stay for older configs and older builds; the panel
65768
+ * runs them through `codebaseAliases`/`skillAliases`, which is the one place that knows how
65769
+ * the two fit together.
65770
+ */
65771
+ ...config2.embedder?.indexAliases !== void 0 ? { indexAliases: config2.embedder.indexAliases } : {},
65772
+ ...config2.embedder?.skillsAliases !== void 0 ? { skillsAliases: config2.embedder.skillsAliases } : {},
65150
65773
  ...config2.embedder?.skillsAlias !== void 0 ? { skillsAlias: config2.embedder.skillsAlias } : {},
65151
65774
  defaultIndexPrefix: DEFAULT_INDEX_PREFIX,
65152
65775
  indexedFiles
65153
65776
  });
65154
65777
  }
65155
- async function handleSaveEmbedder(profileId, model, dimensions, indexName, indexPrefix, indexAlias) {
65778
+ async function handleSaveEmbedder(profileId, model, dimensions, indexName, indexPrefix, indexAliases) {
65156
65779
  try {
65157
- await configManager.save("user", {
65158
- embedder: {
65159
- profileId,
65160
- model,
65161
- dimensions,
65162
- ...indexName !== void 0 && indexName.trim().length > 0 ? { indexName: indexName.trim() } : {},
65163
- // Absent rather than empty when cleared, so the default applies instead of a name
65164
- // beginning with a stray dash.
65165
- ...indexPrefix !== void 0 && indexPrefix.trim().length > 0 ? { indexPrefix: indexPrefix.trim() } : {},
65166
- // Same treatment: cleared means absent, which is what turns team scope back off.
65167
- ...indexAlias !== void 0 && indexAlias.trim().length > 0 ? { indexAlias: indexAlias.trim() } : {}
65168
- }
65169
- });
65780
+ const { config: current } = await configManager.load();
65781
+ const embedder = {
65782
+ ...current.embedder ?? {},
65783
+ profileId,
65784
+ model,
65785
+ dimensions
65786
+ };
65787
+ const put = (key, value) => {
65788
+ if (value === void 0)
65789
+ return;
65790
+ if (value.trim().length > 0)
65791
+ embedder[key] = value.trim();
65792
+ else
65793
+ delete embedder[key];
65794
+ };
65795
+ put("indexName", indexName);
65796
+ put("indexPrefix", indexPrefix);
65797
+ if (indexAliases !== void 0) {
65798
+ const { primary, rest } = aliasFields(indexAliases);
65799
+ if (primary !== void 0)
65800
+ embedder["indexAlias"] = primary;
65801
+ else
65802
+ delete embedder["indexAlias"];
65803
+ if (rest !== void 0)
65804
+ embedder["indexAliases"] = rest;
65805
+ else
65806
+ delete embedder["indexAliases"];
65807
+ }
65808
+ await configManager.save("user", { embedder });
65170
65809
  const { config: config2 } = await configManager.load();
65171
65810
  await postEmbedder(config2);
65172
65811
  scheduleDocsReindex("index prefix changed");
@@ -66205,7 +66844,7 @@ ${direction}` : attachMentions(text, mentions);
66205
66844
  } else if (message3.type === "clearMailIndex") {
66206
66845
  void handleClearMailIndex(message3.resync === true);
66207
66846
  } else if (message3.type === "saveSkillsAlias") {
66208
- void handleSaveSkillsAlias(message3.alias);
66847
+ void handleSaveSkillsAlias(message3.aliases);
66209
66848
  } else if (message3.type === "cancelIndexing") {
66210
66849
  if (message3.kind === void 0) {
66211
66850
  indexingAbort?.abort();
@@ -66217,7 +66856,7 @@ ${direction}` : attachMentions(text, mentions);
66217
66856
  indexingAborts.get(message3.kind)?.abort();
66218
66857
  }
66219
66858
  } else if (message3.type === "saveEmbedder") {
66220
- void handleSaveEmbedder(message3.profileId, message3.model, message3.dimensions, message3.indexName, message3.indexPrefix, message3.indexAlias);
66859
+ void handleSaveEmbedder(message3.profileId, message3.model, message3.dimensions, message3.indexName, message3.indexPrefix, message3.indexAliases);
66221
66860
  } else if (message3.type === "requestEmbedderModels") {
66222
66861
  void handleRequestEmbedderModels(message3.profileId);
66223
66862
  } else if (message3.type === "openWalkthrough") {
@@ -68100,6 +68739,17 @@ ${output}${note}`,
68100
68739
 
68101
68740
  // ../../packages/core/dist/tools/listFiles.js
68102
68741
  import { execFile as execFile7 } from "node:child_process";
68742
+
68743
+ // ../../packages/core/dist/tools/ripgrepError.js
68744
+ function describeRipgrepFailure(error51, what) {
68745
+ const code = error51?.code;
68746
+ if (code === "ENOENT") {
68747
+ 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.`;
68748
+ }
68749
+ return `${what} failed: ${error51 instanceof Error ? error51.message : String(error51)}`;
68750
+ }
68751
+
68752
+ // ../../packages/core/dist/tools/listFiles.js
68103
68753
  var paramsSchema16 = external_exports.object({
68104
68754
  path: external_exports.string().min(1).default(".").describe("Directory to list, relative to the workspace root."),
68105
68755
  recursive: external_exports.boolean().optional().describe("List the full subtree instead of just this directory."),
@@ -68161,7 +68811,7 @@ var listFilesTool = {
68161
68811
  content: params.includeIgnored === true ? "(no files found)" : "(no files found \u2014 .gitignore-excluded files are skipped; retry with includeIgnored: true)"
68162
68812
  };
68163
68813
  } catch (error51) {
68164
- return { content: `Could not list files: ${error51 instanceof Error ? error51.message : String(error51)}`, isError: true };
68814
+ return { content: describeRipgrepFailure(error51, "Listing files recursively"), isError: true };
68165
68815
  }
68166
68816
  }
68167
68817
  const entries = await context.fs.readdir(resolved.realPath);
@@ -68369,7 +69019,7 @@ var searchFilesTool = {
68369
69019
  content: params.includeIgnored === true ? "(no matches)" : "(no matches \u2014 .gitignore-excluded files were not searched; retry with includeIgnored: true)"
68370
69020
  };
68371
69021
  } catch (error51) {
68372
- return { content: `Search failed: ${error51 instanceof Error ? error51.message : String(error51)}`, isError: true };
69022
+ return { content: describeRipgrepFailure(error51, "Search"), isError: true };
68373
69023
  }
68374
69024
  }
68375
69025
  };