@mastra/mcp 1.17.3 → 1.17.4-alpha.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/index.cjs CHANGED
@@ -9834,7 +9834,7 @@ function toStandardSchema$4(schema) {
9834
9834
  return new AiSdkSchemaWrapper(schema);
9835
9835
  }
9836
9836
  //#endregion
9837
- //#region ../schema-compat/dist/json-schema-BstKYbJi.js
9837
+ //#region ../schema-compat/dist/json-schema-BKit3LVN.js
9838
9838
  var require_code$1 = /* @__PURE__ */ __commonJSMin$1(((exports) => {
9839
9839
  Object.defineProperty(exports, "__esModule", { value: true });
9840
9840
  exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0;
@@ -12440,11 +12440,27 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
12440
12440
  /** @type {(value: string) => boolean} */
12441
12441
  const isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
12442
12442
  /** @type {(value: string) => boolean} */
12443
+ const isPort = RegExp.prototype.test.bind(/^\d*$/u);
12444
+ /** @type {(value: string) => boolean} */
12443
12445
  const isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
12444
12446
  /** @type {(value: string) => boolean} */
12445
12447
  const isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
12446
12448
  /** @type {(value: string) => boolean} */
12447
- const isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
12449
+ const isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u);
12450
+ /** @type {(value: string) => boolean} */
12451
+ const isQueryFragmentCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u);
12452
+ /** @type {(value: string) => boolean} */
12453
+ const isUserinfoCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u);
12454
+ const BYTE_HEX = new Array(256);
12455
+ {
12456
+ const HEX_DIGITS = "0123456789ABCDEF";
12457
+ for (let i = 0; i < 256; i++) BYTE_HEX[i] = "%" + HEX_DIGITS[i >> 4] + HEX_DIGITS[i & 15];
12458
+ }
12459
+ function percentEncodeNonAscii(cp) {
12460
+ if (cp < 2048) return BYTE_HEX[192 | cp >> 6] + BYTE_HEX[128 | cp & 63];
12461
+ if (cp < 65536) return BYTE_HEX[224 | cp >> 12] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
12462
+ return BYTE_HEX[240 | cp >> 18] + BYTE_HEX[128 | cp >> 12 & 63] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
12463
+ }
12448
12464
  /**
12449
12465
  * @param {Array<string>} input
12450
12466
  * @returns {string}
@@ -12467,119 +12483,162 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
12467
12483
  }
12468
12484
  return acc;
12469
12485
  }
12470
- /**
12471
- * @typedef {Object} GetIPV6Result
12472
- * @property {boolean} error - Indicates if there was an error parsing the IPv6 address.
12473
- * @property {string} address - The parsed IPv6 address.
12474
- * @property {string} [zone] - The zone identifier, if present.
12475
- */
12486
+ /** @type {(value: string) => boolean} */
12487
+ const isHextet = RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/);
12488
+ /** @type {(value: string) => boolean} */
12489
+ const isIPvFuture = RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/);
12490
+ /** @type {(value: string) => boolean} */
12491
+ const isZoneCharacter = RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/);
12476
12492
  /**
12477
12493
  * @param {string} value
12478
12494
  * @returns {boolean}
12479
12495
  */
12480
12496
  const nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
12481
12497
  /**
12482
- * @param {Array<string>} buffer
12498
+ * @param {string} zone
12483
12499
  * @returns {boolean}
12484
12500
  */
12485
- function consumeIsZone(buffer) {
12486
- buffer.length = 0;
12501
+ function isZoneIdentifier(zone) {
12502
+ if (zone.length === 0) return false;
12503
+ for (let i = 0; i < zone.length; i++) {
12504
+ if (isZoneCharacter(zone[i])) continue;
12505
+ if (zone[i] === "%" && i + 2 < zone.length && isHexPair(zone.slice(i + 1, i + 3))) {
12506
+ i += 2;
12507
+ continue;
12508
+ }
12509
+ return false;
12510
+ }
12487
12511
  return true;
12488
12512
  }
12489
12513
  /**
12490
- * @param {Array<string>} buffer
12491
- * @param {Array<string>} address
12492
- * @param {GetIPV6Result} output
12493
- * @returns {boolean}
12514
+ * Compresses the longest run of zero hextets to "::" per RFC 5952. A run of a
12515
+ * single zero hextet is left uncompressed. On ties the leftmost run wins.
12516
+ *
12517
+ * @param {string[]} hextets
12518
+ * @returns {string}
12494
12519
  */
12495
- function consumeHextets(buffer, address, output) {
12496
- if (buffer.length) {
12497
- const hex = stringArrayToHexStripped(buffer);
12498
- if (hex !== "") address.push(hex);
12499
- else {
12500
- output.error = true;
12501
- return false;
12520
+ function compressIPv6ZeroRun(hextets) {
12521
+ let bestStart = -1;
12522
+ let bestLength = 0;
12523
+ let runStart = -1;
12524
+ let runLength = 0;
12525
+ for (let i = 0; i < hextets.length; i++) if (hextets[i] === "0") {
12526
+ if (runStart === -1) runStart = i;
12527
+ runLength++;
12528
+ if (runLength > bestLength) {
12529
+ bestLength = runLength;
12530
+ bestStart = runStart;
12502
12531
  }
12503
- buffer.length = 0;
12532
+ } else {
12533
+ runStart = -1;
12534
+ runLength = 0;
12504
12535
  }
12505
- return true;
12536
+ if (bestLength < 2) return hextets.join(":");
12537
+ const head = hextets.slice(0, bestStart).join(":");
12538
+ const tail = hextets.slice(bestStart + bestLength).join(":");
12539
+ return head + "::" + tail;
12506
12540
  }
12507
12541
  /**
12542
+ * Validates an IPv6 address against the alternatives in RFC 3986 section
12543
+ * 3.2.2 and returns the same address with leading hextet zeroes removed.
12544
+ * An embedded IPv4 address counts as two hextets and is only valid at the end.
12545
+ *
12508
12546
  * @param {string} input
12509
- * @returns {GetIPV6Result}
12547
+ * @returns {string|undefined}
12510
12548
  */
12511
- function getIPV6(input) {
12512
- let tokenCount = 0;
12513
- const output = {
12514
- error: false,
12515
- address: "",
12516
- zone: ""
12517
- };
12518
- /** @type {Array<string>} */
12519
- const address = [];
12520
- /** @type {Array<string>} */
12521
- const buffer = [];
12522
- let endipv6Encountered = false;
12523
- let endIpv6 = false;
12524
- let consume = consumeHextets;
12525
- for (let i = 0; i < input.length; i++) {
12526
- const cursor = input[i];
12527
- if (cursor === "[" || cursor === "]") continue;
12528
- if (cursor === ":") {
12529
- if (endipv6Encountered === true) endIpv6 = true;
12530
- if (!consume(buffer, address, output)) break;
12531
- if (++tokenCount > 7) {
12532
- output.error = true;
12533
- break;
12534
- }
12535
- if (i > 0 && input[i - 1] === ":") endipv6Encountered = true;
12536
- address.push(":");
12537
- continue;
12538
- } else if (cursor === "%") {
12539
- if (!consume(buffer, address, output)) break;
12540
- consume = consumeIsZone;
12541
- } else {
12542
- buffer.push(cursor);
12549
+ function normalizeIPv6Address(input) {
12550
+ const compression = input.indexOf("::");
12551
+ if (compression !== -1 && input.indexOf("::", compression + 1) !== -1) return void 0;
12552
+ const left = compression === -1 ? input.split(":") : input.slice(0, compression).split(":");
12553
+ const right = compression === -1 ? [] : input.slice(compression + 2).split(":");
12554
+ if (compression !== -1) {
12555
+ if (left.length === 1 && left[0] === "") left.length = 0;
12556
+ if (right.length === 1 && right[0] === "") right.length = 0;
12557
+ }
12558
+ const parts = left.concat(right);
12559
+ let hextetCount = 0;
12560
+ for (let i = 0; i < parts.length; i++) {
12561
+ const part = parts[i];
12562
+ if (part === "") return void 0;
12563
+ if (part.indexOf(".") !== -1) {
12564
+ if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !isIPv4(part)) return void 0;
12565
+ hextetCount += 2;
12543
12566
  continue;
12544
12567
  }
12568
+ if (!isHextet(part)) return void 0;
12569
+ parts[i] = parseInt(part, 16).toString(16);
12570
+ hextetCount++;
12545
12571
  }
12546
- if (buffer.length) if (consume === consumeIsZone) output.zone = buffer.join("");
12547
- else if (endIpv6) address.push(buffer.join(""));
12548
- else address.push(stringArrayToHexStripped(buffer));
12549
- output.address = address.join("");
12550
- return output;
12572
+ if (compression === -1) {
12573
+ if (hextetCount !== 8) return void 0;
12574
+ return compressIPv6ZeroRun(parts);
12575
+ }
12576
+ if (hextetCount >= 8) return void 0;
12577
+ const expanded = parts.slice(0, left.length);
12578
+ for (let i = hextetCount; i < 8; i++) expanded.push("0");
12579
+ for (let i = left.length; i < parts.length; i++) expanded.push(parts[i]);
12580
+ return compressIPv6ZeroRun(expanded);
12551
12581
  }
12552
12582
  /**
12553
12583
  * @typedef {Object} NormalizeIPv6Result
12554
12584
  * @property {string} host - The normalized host.
12555
12585
  * @property {string} [escapedHost] - The escaped host.
12556
12586
  * @property {boolean} isIPV6 - Indicates if the host is an IPv6 address.
12587
+ * @property {boolean} [isIPVFuture] - Indicates if the host is an IPvFuture literal.
12588
+ * @property {boolean} [error] - Indicates if a bracketed IP literal is malformed.
12557
12589
  */
12558
12590
  /**
12591
+ * Validates and normalizes a bracketed IP literal. Raw zone separators remain
12592
+ * accepted for backwards compatibility, while encoded separators and zone
12593
+ * contents follow RFC 6874.
12594
+ *
12559
12595
  * @param {string} host
12560
12596
  * @returns {NormalizeIPv6Result}
12561
12597
  */
12562
12598
  function normalizeIPv6(host) {
12563
- if (findToken(host, ":") < 2) return {
12599
+ const bracketed = host[0] === "[" && host[host.length - 1] === "]";
12600
+ if ((host[0] === "[" || host[host.length - 1] === "]") && !bracketed) return {
12564
12601
  host,
12565
- isIPV6: false
12602
+ isIPV6: false,
12603
+ error: true
12566
12604
  };
12567
- const ipv6 = getIPV6(host);
12568
- if (!ipv6.error) {
12569
- let newHost = ipv6.address;
12570
- let escapedHost = ipv6.address;
12571
- if (ipv6.zone) {
12572
- newHost += "%" + ipv6.zone;
12573
- escapedHost += "%25" + ipv6.zone;
12574
- }
12605
+ let input = bracketed ? host.slice(1, -1) : host;
12606
+ if (bracketed && isIPvFuture(input)) {
12607
+ input = input.toLowerCase();
12575
12608
  return {
12576
- host: newHost,
12577
- isIPV6: true,
12578
- escapedHost
12609
+ host: `[${input}]`,
12610
+ escapedHost: input,
12611
+ isIPV6: false,
12612
+ isIPVFuture: true
12579
12613
  };
12580
- } else return {
12614
+ }
12615
+ if (findToken(input, ":") < 2) return {
12581
12616
  host,
12582
- isIPV6: false
12617
+ isIPV6: false,
12618
+ error: bracketed
12619
+ };
12620
+ let zoneIdentifier = "";
12621
+ const zoneSeparator = input.indexOf("%");
12622
+ if (zoneSeparator !== -1) {
12623
+ const separatorLength = input.slice(zoneSeparator, zoneSeparator + 3).toLowerCase() === "%25" ? 3 : 1;
12624
+ zoneIdentifier = input.slice(zoneSeparator + separatorLength);
12625
+ if (!isZoneIdentifier(zoneIdentifier)) return {
12626
+ host,
12627
+ isIPV6: false,
12628
+ error: true
12629
+ };
12630
+ input = input.slice(0, zoneSeparator);
12631
+ }
12632
+ const address = normalizeIPv6Address(input);
12633
+ if (address === void 0) return {
12634
+ host,
12635
+ isIPV6: false,
12636
+ error: true
12637
+ };
12638
+ return {
12639
+ host: address + (zoneIdentifier ? "%" + zoneIdentifier : ""),
12640
+ escapedHost: address + (zoneIdentifier ? "%25" + zoneIdentifier : ""),
12641
+ isIPV6: true
12583
12642
  };
12584
12643
  }
12585
12644
  /**
@@ -12692,7 +12751,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
12692
12751
  }
12693
12752
  /**
12694
12753
  * Normalizes percent escapes and optionally decodes only unreserved ASCII bytes.
12695
- * Reserved delimiters such as `%2F` and `%2E` stay escaped.
12754
+ * Reserved delimiters such as `%2F` stay escaped; `%2E` is unreserved.
12696
12755
  *
12697
12756
  * @param {string} input
12698
12757
  * @param {boolean} [decodeUnreserved=false]
@@ -12728,7 +12787,8 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
12728
12787
  function normalizePathEncoding(input) {
12729
12788
  let output = "";
12730
12789
  for (let i = 0; i < input.length; i++) {
12731
- if (input[i] === "%" && i + 2 < input.length) {
12790
+ const ch = input[i];
12791
+ if (ch === "%" && i + 2 < input.length) {
12732
12792
  const hex = input.slice(i + 1, i + 3);
12733
12793
  if (isHexPair(hex)) {
12734
12794
  const normalizedHex = hex.toUpperCase();
@@ -12739,8 +12799,168 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
12739
12799
  continue;
12740
12800
  }
12741
12801
  }
12742
- if (isPathCharacter(input[i])) output += input[i];
12743
- else output += escape(input[i]);
12802
+ if (isPathCharacter(ch)) output += ch;
12803
+ else {
12804
+ const code = input.charCodeAt(i);
12805
+ if (code < 128) output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
12806
+ else if (code < 55296 || code > 57343) output += percentEncodeNonAscii(code);
12807
+ else if (code <= 56319 && i + 1 < input.length) {
12808
+ const low = input.charCodeAt(i + 1);
12809
+ if (low >= 56320 && low <= 57343) {
12810
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
12811
+ i++;
12812
+ } else output += percentEncodeNonAscii(65533);
12813
+ } else output += percentEncodeNonAscii(65533);
12814
+ }
12815
+ }
12816
+ return output;
12817
+ }
12818
+ /**
12819
+ * Serializes a path without rewriting reserved data. Raw RFC 3986 path
12820
+ * characters remain literal, valid escapes are preserved and uppercased, and
12821
+ * everything else is UTF-8 percent-encoded. In a path-noscheme, a colon in the
12822
+ * first segment must be escaped so the result cannot be parsed as a scheme.
12823
+ *
12824
+ * @param {string} input
12825
+ * @param {boolean} [pathNoScheme=false]
12826
+ * @returns {string}
12827
+ */
12828
+ function serializePathEncoding(input, pathNoScheme = false) {
12829
+ let output = "";
12830
+ let firstSegment = pathNoScheme && input[0] !== "/";
12831
+ for (let i = 0; i < input.length; i++) {
12832
+ const ch = input[i];
12833
+ if (ch === "%" && i + 2 < input.length) {
12834
+ const hex = input.slice(i + 1, i + 3);
12835
+ if (isHexPair(hex)) {
12836
+ output += "%" + hex.toUpperCase();
12837
+ i += 2;
12838
+ continue;
12839
+ }
12840
+ }
12841
+ if (ch === "/") firstSegment = false;
12842
+ if (isPathCharacter(ch) && (ch !== ":" || !firstSegment)) output += ch;
12843
+ else {
12844
+ const code = input.charCodeAt(i);
12845
+ if (code < 128) output += BYTE_HEX[code];
12846
+ else if (code < 55296 || code > 57343) output += percentEncodeNonAscii(code);
12847
+ else if (code <= 56319 && i + 1 < input.length) {
12848
+ const low = input.charCodeAt(i + 1);
12849
+ if (low >= 56320 && low <= 57343) {
12850
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
12851
+ i++;
12852
+ } else output += percentEncodeNonAscii(65533);
12853
+ } else output += percentEncodeNonAscii(65533);
12854
+ }
12855
+ }
12856
+ return output;
12857
+ }
12858
+ /**
12859
+ * Percent-encodes a URI component using its RFC 3986 literal character set.
12860
+ * Existing valid escapes are preserved and normalized to uppercase hex.
12861
+ *
12862
+ * @param {string} input
12863
+ * @param {(value: string) => boolean} isAllowed
12864
+ * @returns {string}
12865
+ */
12866
+ function encodeComponent(input, isAllowed) {
12867
+ let output = "";
12868
+ for (let i = 0; i < input.length; i++) {
12869
+ const ch = input[i];
12870
+ if (ch === "%" && i + 2 < input.length) {
12871
+ const hex = input.slice(i + 1, i + 3);
12872
+ if (isHexPair(hex)) {
12873
+ output += "%" + hex.toUpperCase();
12874
+ i += 2;
12875
+ continue;
12876
+ }
12877
+ }
12878
+ if (isAllowed(ch)) output += ch;
12879
+ else {
12880
+ const code = input.charCodeAt(i);
12881
+ if (code < 128) output += BYTE_HEX[code];
12882
+ else if (code < 55296 || code > 57343) output += percentEncodeNonAscii(code);
12883
+ else if (code <= 56319 && i + 1 < input.length) {
12884
+ const low = input.charCodeAt(i + 1);
12885
+ if (low >= 56320 && low <= 57343) {
12886
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
12887
+ i++;
12888
+ } else output += percentEncodeNonAscii(65533);
12889
+ } else output += percentEncodeNonAscii(65533);
12890
+ }
12891
+ }
12892
+ return output;
12893
+ }
12894
+ /**
12895
+ * Encodes userinfo while preserving its RFC 3986 §3.2.1 literal characters.
12896
+ * In particular, authority delimiters such as `@`, `/`, `?`, and `#` are data.
12897
+ *
12898
+ * @param {string} input
12899
+ * @returns {string}
12900
+ */
12901
+ function encodeUserinfo(input) {
12902
+ return encodeComponent(input, isUserinfoCharacter);
12903
+ }
12904
+ /**
12905
+ * Encodes query data using the RFC 3986 §3.4 grammar. A literal `#` must be
12906
+ * escaped because it would otherwise begin the fragment component.
12907
+ *
12908
+ * @param {string} input
12909
+ * @returns {string}
12910
+ */
12911
+ function encodeQuery(input) {
12912
+ return encodeComponent(input, isQueryFragmentCharacter);
12913
+ }
12914
+ /**
12915
+ * Encodes fragment data using the RFC 3986 §3.5 grammar.
12916
+ *
12917
+ * @param {string} input
12918
+ * @returns {string}
12919
+ */
12920
+ function encodeFragment(input) {
12921
+ return encodeComponent(input, isQueryFragmentCharacter);
12922
+ }
12923
+ function isEscapeSafe(cp) {
12924
+ return cp >= 48 && cp <= 57 || cp >= 65 && cp <= 90 || cp >= 97 && cp <= 122 || cp === 42 || cp === 43 || cp === 45 || cp === 46 || cp === 47 || cp === 64 || cp === 95;
12925
+ }
12926
+ /**
12927
+ * Normalizes the percent-encoding of a query or fragment component.
12928
+ *
12929
+ * Like `normalizePathEncoding`, but uses the query/fragment character set
12930
+ * (which additionally allows `?`) and decodes `.` since it has no dot-segment
12931
+ * meaning outside of a path.
12932
+ *
12933
+ * @param {string} input
12934
+ * @returns {string}
12935
+ */
12936
+ function normalizeQueryFragmentEncoding(input) {
12937
+ let output = "";
12938
+ for (let i = 0; i < input.length; i++) {
12939
+ const ch = input[i];
12940
+ if (ch === "%" && i + 2 < input.length) {
12941
+ const hex = input.slice(i + 1, i + 3);
12942
+ if (isHexPair(hex)) {
12943
+ const normalizedHex = hex.toUpperCase();
12944
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
12945
+ if (isUnreserved(decoded)) output += decoded;
12946
+ else output += "%" + normalizedHex;
12947
+ i += 2;
12948
+ continue;
12949
+ }
12950
+ }
12951
+ if (isQueryFragmentCharacter(ch)) output += ch;
12952
+ else {
12953
+ const code = input.charCodeAt(i);
12954
+ if (code < 128) output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
12955
+ else if (code < 55296 || code > 57343) output += percentEncodeNonAscii(code);
12956
+ else if (code <= 56319 && i + 1 < input.length) {
12957
+ const low = input.charCodeAt(i + 1);
12958
+ if (low >= 56320 && low <= 57343) {
12959
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
12960
+ i++;
12961
+ } else output += percentEncodeNonAscii(65533);
12962
+ } else output += percentEncodeNonAscii(65533);
12963
+ }
12744
12964
  }
12745
12965
  return output;
12746
12966
  }
@@ -12772,21 +12992,27 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
12772
12992
  function recomposeAuthority(component) {
12773
12993
  const uriTokens = [];
12774
12994
  if (component.userinfo !== void 0) {
12775
- uriTokens.push(component.userinfo);
12995
+ uriTokens.push(encodeUserinfo(component.userinfo));
12776
12996
  uriTokens.push("@");
12777
12997
  }
12778
12998
  if (component.host !== void 0) {
12779
- let host = unescape(component.host);
12999
+ let host = component.host;
12780
13000
  if (!isIPv4(host)) {
12781
- const ipV6res = normalizeIPv6(host);
12782
- if (ipV6res.isIPV6 === true) host = `[${ipV6res.escapedHost}]`;
13001
+ let ipV6res = normalizeIPv6(host);
13002
+ if (ipV6res.isIPV6 !== true && ipV6res.isIPVFuture !== true) {
13003
+ host = normalizePercentEncoding(host, true);
13004
+ ipV6res = normalizeIPv6(host);
13005
+ }
13006
+ if (ipV6res.isIPV6 === true || ipV6res.isIPVFuture === true) host = `[${ipV6res.escapedHost}]`;
12783
13007
  else host = reescapeHostDelimiters(host, false);
12784
13008
  }
12785
13009
  uriTokens.push(host);
12786
13010
  }
12787
13011
  if (typeof component.port === "number" || typeof component.port === "string") {
13012
+ const port = String(component.port);
13013
+ if (!isPort(port)) throw new TypeError("URI port is malformed.");
12788
13014
  uriTokens.push(":");
12789
- uriTokens.push(String(component.port));
13015
+ uriTokens.push(port);
12790
13016
  }
12791
13017
  return uriTokens.length ? uriTokens.join("") : void 0;
12792
13018
  }
@@ -12796,6 +13022,11 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
12796
13022
  reescapeHostDelimiters,
12797
13023
  normalizePercentEncoding,
12798
13024
  normalizePathEncoding,
13025
+ serializePathEncoding,
13026
+ normalizeQueryFragmentEncoding,
13027
+ encodeUserinfo,
13028
+ encodeQuery,
13029
+ encodeFragment,
12799
13030
  escapePreservingEscapes,
12800
13031
  removeDotSegments,
12801
13032
  isIPv4,
@@ -12806,7 +13037,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
12806
13037
  }));
12807
13038
  var require_schemes = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
12808
13039
  const { isUUID } = require_utils();
12809
- const URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
13040
+ const URN_REG = /^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu;
12810
13041
  const supportedSchemeNames = [
12811
13042
  "http",
12812
13043
  "https",
@@ -12877,9 +13108,10 @@ var require_schemes = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
12877
13108
  wsComponent.secure = void 0;
12878
13109
  }
12879
13110
  if (wsComponent.resourceName) {
12880
- const [path, query] = wsComponent.resourceName.split("?");
13111
+ const queryIndex = wsComponent.resourceName.indexOf("?");
13112
+ const path = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
12881
13113
  wsComponent.path = path && path !== "/" ? path : void 0;
12882
- wsComponent.query = query;
13114
+ wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
12883
13115
  wsComponent.resourceName = void 0;
12884
13116
  }
12885
13117
  wsComponent.fragment = void 0;
@@ -12892,7 +13124,7 @@ var require_schemes = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
12892
13124
  return urnComponent;
12893
13125
  }
12894
13126
  const matches = urnComponent.path.match(URN_REG);
12895
- if (matches) {
13127
+ if (matches && matches[0] === urnComponent.path) {
12896
13128
  const scheme = options.scheme || urnComponent.scheme || "urn";
12897
13129
  urnComponent.nid = matches[1].toLowerCase();
12898
13130
  urnComponent.nss = matches[2];
@@ -12986,8 +13218,19 @@ var require_schemes = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
12986
13218
  };
12987
13219
  }));
12988
13220
  var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
12989
- const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
13221
+ const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
12990
13222
  const { SCHEMES, getSchemeHandler } = require_schemes();
13223
+ const VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
13224
+ const MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
13225
+ /**
13226
+ * @param {string} scheme
13227
+ * @returns {string}
13228
+ */
13229
+ function decodeValidScheme(scheme) {
13230
+ const decodedScheme = unescape(String(scheme));
13231
+ if (!VALID_SCHEME.test(decodedScheme)) throw new TypeError(MALFORMED_SCHEME_ERROR);
13232
+ return decodedScheme;
13233
+ }
12991
13234
  /**
12992
13235
  * @template {import('./types/index').URIComponent|string} T
12993
13236
  * @param {T} uri
@@ -13007,10 +13250,16 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
13007
13250
  */
13008
13251
  function resolve(baseURI, relativeURI, options) {
13009
13252
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
13010
- const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
13011
- const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
13012
- if (baseMalformed || relativeMalformed) throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
13253
+ const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed, malformedPercentEncoding: baseMalformedPercentEncoding, malformedSchemeSpecific: baseMalformedSchemeSpecific, malformedHost: baseMalformedHost, malformedScheme: baseMalformedScheme } = parseWithStatus(baseURI, schemelessOptions);
13254
+ const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed, malformedPercentEncoding: relativeMalformedPercentEncoding, malformedSchemeSpecific: relativeMalformedSchemeSpecific, malformedHost: relativeMalformedHost, malformedScheme: relativeMalformedScheme } = parseWithStatus(relativeURI, schemelessOptions);
13255
+ if (baseMalformed || relativeMalformed || baseMalformedPercentEncoding || relativeMalformedPercentEncoding || baseMalformedSchemeSpecific || relativeMalformedSchemeSpecific || baseMalformedHost || relativeMalformedHost || baseMalformedScheme || relativeMalformedScheme) throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
13013
13256
  const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
13257
+ const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
13258
+ const resolvedHost = resolved.host;
13259
+ const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
13260
+ canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
13261
+ const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !/\P{ASCII}/u.test(resolvedHost);
13262
+ if (resolved.error && !encodedASCIIHost) throw new Error(resolved.error);
13014
13263
  schemelessOptions.skipEscape = true;
13015
13264
  return serialize(resolved, schemelessOptions);
13016
13265
  }
@@ -13076,7 +13325,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
13076
13325
  function equal(uriA, uriB, options) {
13077
13326
  const normalizedA = normalizeComparableURI(uriA, options);
13078
13327
  const normalizedB = normalizeComparableURI(uriB, options);
13079
- return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase();
13328
+ return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA === normalizedB;
13080
13329
  }
13081
13330
  /**
13082
13331
  * @param {Readonly<import('./types/index').URIComponent>} cmpts
@@ -13102,13 +13351,17 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
13102
13351
  };
13103
13352
  const options = Object.assign({}, opts);
13104
13353
  const uriTokens = [];
13354
+ if (component.scheme) component.scheme = decodeValidScheme(component.scheme);
13105
13355
  const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
13106
13356
  if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
13107
- if (component.path !== void 0) if (!options.skipEscape) {
13108
- component.path = escapePreservingEscapes(component.path);
13109
- if (component.scheme !== void 0) component.path = component.path.split("%3A").join(":");
13110
- } else component.path = normalizePercentEncoding(component.path);
13111
- if (options.reference !== "suffix" && component.scheme) uriTokens.push(component.scheme, ":");
13357
+ const hasAuthority = component.userinfo !== void 0 || component.host !== void 0 || component.port !== void 0;
13358
+ const pathNoScheme = !options.skipEscape && component.scheme === void 0 && !hasAuthority;
13359
+ if (component.path !== void 0) if (!options.skipEscape) component.path = serializePathEncoding(component.path, pathNoScheme);
13360
+ else component.path = normalizePercentEncoding(component.path);
13361
+ if (options.reference !== "suffix" && component.scheme) {
13362
+ component.scheme = decodeValidScheme(component.scheme);
13363
+ uriTokens.push(component.scheme, ":");
13364
+ }
13112
13365
  const authority = recomposeAuthority(component);
13113
13366
  if (authority !== void 0) {
13114
13367
  if (options.reference !== "suffix") uriTokens.push("//");
@@ -13118,11 +13371,12 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
13118
13371
  if (component.path !== void 0) {
13119
13372
  let s = component.path;
13120
13373
  if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) s = removeDotSegments(s);
13374
+ if (pathNoScheme) s = serializePathEncoding(s, true);
13121
13375
  if (authority === void 0 && s[0] === "/" && s[1] === "/") s = "/%2F" + s.slice(2);
13122
13376
  uriTokens.push(s);
13123
13377
  }
13124
- if (component.query !== void 0) uriTokens.push("?", component.query);
13125
- if (component.fragment !== void 0) uriTokens.push("#", component.fragment);
13378
+ if (component.query !== void 0) uriTokens.push("?", encodeQuery(component.query));
13379
+ if (component.fragment !== void 0) uriTokens.push("#", encodeFragment(component.fragment));
13126
13380
  return uriTokens.join("");
13127
13381
  }
13128
13382
  const URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
@@ -13138,9 +13392,61 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
13138
13392
  if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) return "URI port is malformed.";
13139
13393
  }
13140
13394
  /**
13395
+ * Checks percent syntax without decoding the represented octets. RFC 3986
13396
+ * percent-encoding is byte-oriented, so sequences such as `%FF` are valid even
13397
+ * though they are not independently valid UTF-8.
13398
+ *
13399
+ * @param {string|undefined} component
13400
+ * @returns {boolean}
13401
+ */
13402
+ function hasMalformedPercentEncoding(component) {
13403
+ if (component === void 0) return false;
13404
+ let percent = component.indexOf("%");
13405
+ while (percent !== -1) {
13406
+ if (percent + 2 >= component.length || !/^[\da-f]{2}$/iu.test(component.slice(percent + 1, percent + 3))) return true;
13407
+ percent = component.indexOf("%", percent + 3);
13408
+ }
13409
+ return false;
13410
+ }
13411
+ /**
13412
+ * Whether the host is a bracketed IP literal (RFC 3986 `IP-literal`).
13413
+ * An unterminated `[` is not a literal, so it must still be validated as a
13414
+ * reg-name instead of being waved through as an IP.
13415
+ *
13416
+ * @param {string} host
13417
+ * @returns {boolean}
13418
+ */
13419
+ function isIPLiteral(host) {
13420
+ return host[0] === "[" && host[host.length - 1] === "]";
13421
+ }
13422
+ /**
13423
+ * @param {RegExpMatchArray} matches
13424
+ * @returns {boolean}
13425
+ */
13426
+ function hasMalformedComponentPercentEncoding(matches) {
13427
+ const host = matches[4];
13428
+ return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
13429
+ }
13430
+ /**
13431
+ * @param {import('./types/index').URIComponent} parsed
13432
+ * @param {import('./types/index').Options} options
13433
+ * @param {{ domainHost?: boolean, unicodeSupport?: boolean }|undefined} schemeHandler
13434
+ * @param {boolean} isIP
13435
+ * @returns {boolean} whether host conversion failed
13436
+ */
13437
+ function canonicalizeHost(parsed, options, schemeHandler, isIP) {
13438
+ if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) try {
13439
+ parsed.host = new URL("http://" + parsed.host).hostname;
13440
+ } catch (e) {
13441
+ parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
13442
+ return true;
13443
+ }
13444
+ return false;
13445
+ }
13446
+ /**
13141
13447
  * @param {string} uri
13142
13448
  * @param {import('./types/index').Options} [opts]
13143
- * @returns {{ parsed: import('./types/index').URIComponent, malformedAuthorityOrPort: boolean }}
13449
+ * @returns {{ parsed: import('./types/index').URIComponent, malformedAuthorityOrPort: boolean, malformedPercentEncoding: boolean, malformedSchemeSpecific: boolean, malformedHost: boolean, malformedScheme: boolean }}
13144
13450
  */
13145
13451
  function parseWithStatus(uri, opts) {
13146
13452
  const options = Object.assign({}, opts);
@@ -13155,6 +13461,11 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
13155
13461
  fragment: void 0
13156
13462
  };
13157
13463
  let malformedAuthorityOrPort = false;
13464
+ let malformedPercentEncoding = false;
13465
+ let malformedSchemeSpecific = false;
13466
+ let malformedHost = false;
13467
+ let malformedIPLiteral = false;
13468
+ let malformedScheme = false;
13158
13469
  let isIP = false;
13159
13470
  if (options.reference === "suffix") if (options.scheme) uri = options.scheme + ":" + uri;
13160
13471
  else uri = "//" + uri;
@@ -13186,6 +13497,16 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
13186
13497
  parsed.path = matches[6] || "";
13187
13498
  parsed.query = matches[7];
13188
13499
  parsed.fragment = matches[8];
13500
+ if (parsed.scheme !== void 0) {
13501
+ const decodedScheme = unescape(parsed.scheme);
13502
+ if (VALID_SCHEME.test(decodedScheme)) parsed.scheme = decodedScheme.toLowerCase();
13503
+ else {
13504
+ parsed.error = parsed.error || MALFORMED_SCHEME_ERROR;
13505
+ malformedScheme = true;
13506
+ }
13507
+ }
13508
+ malformedPercentEncoding = hasMalformedComponentPercentEncoding(matches);
13509
+ if (malformedPercentEncoding) parsed.error = parsed.error || "URI contains malformed percent-encoding.";
13189
13510
  if (isNaN(parsed.port)) parsed.port = matches[5];
13190
13511
  const parseError = getParseError(parsed, matches);
13191
13512
  if (parseError !== void 0) {
@@ -13193,9 +13514,16 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
13193
13514
  malformedAuthorityOrPort = true;
13194
13515
  }
13195
13516
  if (parsed.host) if (isIPv4(parsed.host) === false) {
13517
+ const bracketedIPLiteral = isIPLiteral(parsed.host);
13518
+ const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1;
13196
13519
  const ipv6result = normalizeIPv6(parsed.host);
13197
- parsed.host = ipv6result.host.toLowerCase();
13198
- isIP = ipv6result.isIPV6;
13520
+ isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
13521
+ malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
13522
+ parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
13523
+ if (malformedIPLiteral) {
13524
+ parsed.error = parsed.error || "URI host is malformed.";
13525
+ malformedAuthorityOrPort = true;
13526
+ }
13199
13527
  } else isIP = true;
13200
13528
  if (parsed.scheme === void 0 && parsed.userinfo === void 0 && parsed.host === void 0 && parsed.port === void 0 && parsed.query === void 0 && !parsed.path) parsed.reference = "same-document";
13201
13529
  else if (parsed.scheme === void 0) parsed.reference = "relative";
@@ -13203,30 +13531,30 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
13203
13531
  else parsed.reference = "uri";
13204
13532
  if (options.reference && options.reference !== "suffix" && options.reference !== parsed.reference) parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
13205
13533
  const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
13206
- if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
13207
- if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) try {
13208
- parsed.host = new URL("http://" + parsed.host).hostname;
13209
- } catch (e) {
13210
- parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
13211
- }
13212
- }
13534
+ if (!malformedIPLiteral) malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
13213
13535
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
13214
13536
  if (uri.indexOf("%") !== -1) {
13215
- if (parsed.scheme !== void 0) parsed.scheme = unescape(parsed.scheme);
13216
- if (parsed.host !== void 0) parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
13537
+ if (parsed.host !== void 0 && !malformedIPLiteral) {
13538
+ const host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
13539
+ parsed.host = reescapeHostDelimiters(host, isIP);
13540
+ }
13217
13541
  }
13218
13542
  if (parsed.path) parsed.path = normalizePathEncoding(parsed.path);
13219
- if (parsed.fragment) try {
13220
- parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
13221
- } catch {
13222
- parsed.error = parsed.error || "URI malformed";
13223
- }
13543
+ if (parsed.query) parsed.query = normalizeQueryFragmentEncoding(parsed.query);
13544
+ if (parsed.fragment) parsed.fragment = normalizeQueryFragmentEncoding(parsed.fragment);
13545
+ }
13546
+ if (schemeHandler && schemeHandler.parse) {
13547
+ schemeHandler.parse(parsed, options);
13548
+ if (schemeHandler === SCHEMES.urn && parsed.nid === void 0) malformedSchemeSpecific = true;
13224
13549
  }
13225
- if (schemeHandler && schemeHandler.parse) schemeHandler.parse(parsed, options);
13226
13550
  } else parsed.error = parsed.error || "URI can not be parsed.";
13227
13551
  return {
13228
13552
  parsed,
13229
- malformedAuthorityOrPort
13553
+ malformedAuthorityOrPort,
13554
+ malformedPercentEncoding,
13555
+ malformedSchemeSpecific,
13556
+ malformedHost,
13557
+ malformedScheme
13230
13558
  };
13231
13559
  }
13232
13560
  /**
@@ -13248,13 +13576,17 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
13248
13576
  /**
13249
13577
  * @param {string} uri
13250
13578
  * @param {import('./types/index').Options} [opts]
13251
- * @returns {{ normalized: string, malformedAuthorityOrPort: boolean }}
13579
+ * @returns {{ normalized: string, malformedAuthorityOrPort: boolean, malformedPercentEncoding: boolean, malformedSchemeSpecific: boolean, malformedHost: boolean, malformedScheme: boolean }}
13252
13580
  */
13253
13581
  function normalizeStringWithStatus(uri, opts) {
13254
- const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
13582
+ const { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = parseWithStatus(uri, opts);
13255
13583
  return {
13256
- normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts),
13257
- malformedAuthorityOrPort
13584
+ normalized: malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? uri : serialize(parsed, opts),
13585
+ malformedAuthorityOrPort,
13586
+ malformedPercentEncoding,
13587
+ malformedSchemeSpecific,
13588
+ malformedHost,
13589
+ malformedScheme
13258
13590
  };
13259
13591
  }
13260
13592
  /**
@@ -13263,11 +13595,15 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
13263
13595
  * @returns {string|undefined}
13264
13596
  */
13265
13597
  function normalizeComparableURI(uri, opts) {
13266
- if (typeof uri === "string") {
13267
- const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts);
13268
- return malformedAuthorityOrPort ? void 0 : normalized;
13598
+ if (typeof uri !== "string" && typeof uri !== "object") return;
13599
+ let value;
13600
+ try {
13601
+ value = typeof uri === "string" ? uri : serialize(uri, opts);
13602
+ } catch {
13603
+ return;
13269
13604
  }
13270
- if (typeof uri === "object") return serialize(uri, opts);
13605
+ const { normalized, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = normalizeStringWithStatus(value, opts);
13606
+ return malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? void 0 : normalized;
13271
13607
  }
13272
13608
  const fastUri = {
13273
13609
  SCHEMES,
@@ -16542,7 +16878,7 @@ function toStandardSchema$2(zodSchema) {
16542
16878
  return wrapper;
16543
16879
  }
16544
16880
  //#endregion
16545
- //#region ../schema-compat/dist/schema-Bv9OdW1f.js
16881
+ //#region ../schema-compat/dist/schema-D_ikovK6.js
16546
16882
  /**
16547
16883
  * Supported JSON Schema targets for z.toJSONSchema().
16548
16884
  * Works with both real Zod v4 and Zod 3.25's v4 compat layer.
@@ -22948,38 +23284,30 @@ function isLoopbackHostname(hostname) {
22948
23284
  return hostname === "localhost" || hostname === "[::1]" || hostname === "::1" || LOOPBACK_IPV4.test(hostname);
22949
23285
  }
22950
23286
  /**
22951
- * MCPClient manages multiple MCP server connections and their tools in a Mastra application.
23287
+ * Manages Model Context Protocol (MCP) server connections and tool namespacing,
23288
+ * with access to tools, resources, prompts, and elicitation.
22952
23289
  *
22953
- * This class handles connection lifecycle, tool namespacing, and provides access to tools,
22954
- * resources, prompts, and elicitation across all configured servers.
23290
+ * Configure authentication when required by your servers.
22955
23291
  *
22956
23292
  * @example
23293
+ * `yourServerUrl` is a URL for a running MCP server's HTTP endpoint.
22957
23294
  * ```typescript
22958
23295
  * import { MCPClient } from '@mastra/mcp';
22959
- * import { Agent } from '@mastra/core/agent';
22960
23296
  *
22961
23297
  * const mcp = new MCPClient({
22962
23298
  * servers: {
22963
- * weather: {
22964
- * url: new URL('http://localhost:8080/sse'),
22965
- * },
22966
- * stockPrice: {
22967
- * command: 'npx',
22968
- * args: ['tsx', 'stock-price.ts'],
22969
- * env: { API_KEY: 'your-api-key' },
22970
- * },
23299
+ * remote: { url: yourServerUrl },
22971
23300
  * },
22972
- * timeout: 30000,
22973
- * });
22974
- *
22975
- * const agent = new Agent({
22976
- * id: 'multi-tool-agent',
22977
- * name: 'Multi-tool Agent',
22978
- * instructions: 'You have access to multiple tools.',
22979
- * model: 'openai/gpt-4o',
22980
- * tools: await mcp.listTools(),
22981
23301
  * });
22982
23302
  * ```
23303
+ *
23304
+ * @see For documentation bundled with your installed package, locate
23305
+ * `@mastra/mcp/package.json` with your project's resolver or package-manager
23306
+ * tooling, then read `dist/docs/SKILL.md` from that package root and follow its
23307
+ * reference links. Use package-manager tools for virtual or archived packages.
23308
+ *
23309
+ * @see [MCP client documentation](https://mastra.ai/reference/tools/mcp-client)
23310
+ * if packaged docs are unavailable.
22983
23311
  */
22984
23312
  var MCPClient = class extends _mastra_core_base.MastraBase {
22985
23313
  serverConfigs = {};
@@ -24386,7 +24714,7 @@ var streamSSE = (c, cb, onError) => {
24386
24714
  return c.newResponse(stream.responseReadable);
24387
24715
  };
24388
24716
  //#endregion
24389
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/hono-mcp-server-sse-transport/0.0.7/2a63beb8624fb1bf3c7a3ca090a15654580e3b90bf86b236de2fea1561bf2a49/node_modules/hono-mcp-server-sse-transport/build/sse.js
24717
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/hono-mcp-server-sse-transport/0.0.7/64266f0b1652040acd07ff3bd56a63a27af87510caf8cd4ce871013cbd451c67/node_modules/hono-mcp-server-sse-transport/build/sse.js
24390
24718
  const MAXIMUM_MESSAGE_SIZE = 4 * 1024 * 1024;
24391
24719
  var SSETransport = class {
24392
24720
  messageUrl;
@@ -24899,32 +25227,30 @@ const ACCEPTED_MODERN_ERA_HTTP_OPTION_KEYS = /* @__PURE__ */ new Set([
24899
25227
  "sessionIdGenerator"
24900
25228
  ]);
24901
25229
  /**
24902
- * MCPServer exposes Mastra tools, agents, and workflows as a Model Context Protocol (MCP) server.
24903
- *
24904
- * This class allows any MCP client (like Cursor, Windsurf, or Claude Desktop) to connect and use your
24905
- * Mastra capabilities. It supports both stdio (subprocess) and SSE (HTTP) MCP transports.
25230
+ * Exposes Mastra tools, agents, and workflows to Model Context Protocol (MCP) clients.
25231
+ * Supports stdio, SSE, and Streamable HTTP transports; start or mount a transport
25232
+ * to accept client connections.
24906
25233
  *
24907
25234
  * @example
25235
+ * `yourTool` is a tool you have already configured.
24908
25236
  * ```typescript
24909
25237
  * import { MCPServer } from '@mastra/mcp';
24910
- * import { createTool } from '@mastra/core/tools';
24911
- * import { z } from 'zod';
24912
- *
24913
- * const weatherTool = createTool({
24914
- * id: 'getWeather',
24915
- * description: 'Gets the current weather for a location.',
24916
- * inputSchema: z.object({ location: z.string() }),
24917
- * execute: async (inputData) => `Weather in ${inputData.location} is sunny.`,
24918
- * });
24919
25238
  *
24920
25239
  * const server = new MCPServer({
24921
- * name: 'My Weather Server',
25240
+ * id: 'my-server',
25241
+ * name: 'My Server',
24922
25242
  * version: '1.0.0',
24923
- * tools: { weatherTool },
25243
+ * tools: { yourTool },
24924
25244
  * });
24925
- *
24926
- * await server.startStdio();
24927
25245
  * ```
25246
+ *
25247
+ * @see For documentation bundled with your installed package, locate
25248
+ * `@mastra/mcp/package.json` with your project's resolver or package-manager
25249
+ * tooling, then read `dist/docs/SKILL.md` from that package root and follow its
25250
+ * reference links. Use package-manager tools for virtual or archived packages.
25251
+ *
25252
+ * @see [MCP server documentation](https://mastra.ai/reference/tools/mcp-server)
25253
+ * if packaged docs are unavailable.
24928
25254
  */
24929
25255
  var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
24930
25256
  server;