replicas-engine 0.1.1466 → 0.1.1469

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/src/index.js CHANGED
@@ -22,12 +22,12 @@ import {
22
22
  serializePrompts,
23
23
  serializeResources,
24
24
  serializeTools
25
- } from "./chunk-UP57BRAF.js";
25
+ } from "./chunk-DYAYKYJO.js";
26
26
  import {
27
27
  evaluateCommandProtection,
28
28
  extractToolCommand,
29
29
  reportCommandProtectionBlock
30
- } from "./chunk-C7YV32F5.js";
30
+ } from "./chunk-VPOFUDT5.js";
31
31
  import {
32
32
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
33
33
  AGENT_MESSAGE_DELTA_METHOD,
@@ -65,10 +65,10 @@ import {
65
65
  spawnMuseMsp,
66
66
  startMuseSession,
67
67
  uuidV7
68
- } from "./chunk-LSPWJ77C.js";
68
+ } from "./chunk-2YQDYO67.js";
69
69
  import {
70
70
  publishedPullRequestUrls
71
- } from "./chunk-INE6DSVM.js";
71
+ } from "./chunk-JG3ESZI7.js";
72
72
  import {
73
73
  ACCOUNT_RATE_LIMITS_READ_METHOD,
74
74
  AsyncLock,
@@ -143,7 +143,7 @@ import {
143
143
  timestampFromSeconds,
144
144
  upsertCredentialFileLines,
145
145
  writeSecureCredentialFile
146
- } from "./chunk-KGUZCADU.js";
146
+ } from "./chunk-MOSHKZWN.js";
147
147
  import {
148
148
  ENGINE_ENV,
149
149
  UNQUOTED_PATHS_CONFIG,
@@ -154,15 +154,15 @@ import {
154
154
  resolveDiffBase,
155
155
  setAgentCredentialSnapshot,
156
156
  setLinearSessionId
157
- } from "./chunk-6NNVX27C.js";
157
+ } from "./chunk-OTFBY4WF.js";
158
158
  import {
159
159
  getCodexModelProvider
160
- } from "./chunk-BIK43UNT.js";
160
+ } from "./chunk-AMBSJQ6V.js";
161
161
  import {
162
162
  SUBPROCESS_MAX_BUFFER,
163
163
  execAsync,
164
164
  execFileAsync
165
- } from "./chunk-FBWRYQF6.js";
165
+ } from "./chunk-BI3P7Y24.js";
166
166
  import {
167
167
  isRecord as isRecord2
168
168
  } from "./chunk-UZSNFLDQ.js";
@@ -439,7 +439,7 @@ import {
439
439
  workspaceTokenRequestSchema,
440
440
  workspaceTokenResponseSchema,
441
441
  wrapInTag
442
- } from "./chunk-Z6IBBEX5.js";
442
+ } from "./chunk-LWUFKQAD.js";
443
443
  import {
444
444
  cloneMcpConfig,
445
445
  ensureCompatibilityImports,
@@ -456,7 +456,7 @@ import {
456
456
  writeProjectServerDisabledOverride,
457
457
  writeSharedServerEntry,
458
458
  writeStarterSharedConfig
459
- } from "./chunk-UHBYG6JY.js";
459
+ } from "./chunk-UU7DWQFZ.js";
460
460
  import {
461
461
  MCP_STATUS_EVENT,
462
462
  MCP_STATUS_SNAPSHOT_VERSION,
@@ -503,7 +503,7 @@ import {
503
503
  truncateAtWord,
504
504
  truncateToWidth,
505
505
  visibleWidth
506
- } from "./chunk-BMC4R5IZ.js";
506
+ } from "./chunk-244SUBHF.js";
507
507
  import {
508
508
  __commonJS,
509
509
  __export,
@@ -4067,15 +4067,34 @@ var require_data2 = __commonJS({
4067
4067
  }
4068
4068
  });
4069
4069
 
4070
- // ../node_modules/.bun/fast-uri@3.1.2/node_modules/fast-uri/lib/utils.js
4070
+ // ../node_modules/.bun/fast-uri@3.1.9/node_modules/fast-uri/lib/utils.js
4071
4071
  var require_utils2 = __commonJS({
4072
- "../node_modules/.bun/fast-uri@3.1.2/node_modules/fast-uri/lib/utils.js"(exports, module) {
4072
+ "../node_modules/.bun/fast-uri@3.1.9/node_modules/fast-uri/lib/utils.js"(exports, module) {
4073
4073
  "use strict";
4074
4074
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
4075
4075
  var 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);
4076
+ var isPort = RegExp.prototype.test.bind(/^\d*$/u);
4076
4077
  var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
4077
4078
  var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
4078
- var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
4079
+ var isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u);
4080
+ var isQueryFragmentCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u);
4081
+ var isUserinfoCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u);
4082
+ var BYTE_HEX = new Array(256);
4083
+ {
4084
+ const HEX_DIGITS = "0123456789ABCDEF";
4085
+ for (let i = 0; i < 256; i++) {
4086
+ BYTE_HEX[i] = "%" + HEX_DIGITS[i >> 4] + HEX_DIGITS[i & 15];
4087
+ }
4088
+ }
4089
+ function percentEncodeNonAscii(cp2) {
4090
+ if (cp2 < 2048) {
4091
+ return BYTE_HEX[192 | cp2 >> 6] + BYTE_HEX[128 | cp2 & 63];
4092
+ }
4093
+ if (cp2 < 65536) {
4094
+ return BYTE_HEX[224 | cp2 >> 12] + BYTE_HEX[128 | cp2 >> 6 & 63] + BYTE_HEX[128 | cp2 & 63];
4095
+ }
4096
+ return BYTE_HEX[240 | cp2 >> 18] + BYTE_HEX[128 | cp2 >> 12 & 63] + BYTE_HEX[128 | cp2 >> 6 & 63] + BYTE_HEX[128 | cp2 & 63];
4097
+ }
4079
4098
  function stringArrayToHexStripped(input) {
4080
4099
  let acc = "";
4081
4100
  let code = 0;
@@ -4100,91 +4119,105 @@ var require_utils2 = __commonJS({
4100
4119
  }
4101
4120
  return acc;
4102
4121
  }
4122
+ var isHextet = RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/);
4123
+ var isIPvFuture = RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/);
4124
+ var isZoneCharacter = RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/);
4103
4125
  var nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
4104
- function consumeIsZone(buffer) {
4105
- buffer.length = 0;
4106
- return true;
4107
- }
4108
- function consumeHextets(buffer, address, output) {
4109
- if (buffer.length) {
4110
- const hex = stringArrayToHexStripped(buffer);
4111
- if (hex !== "") {
4112
- address.push(hex);
4113
- } else {
4114
- output.error = true;
4115
- return false;
4126
+ function isZoneIdentifier(zone) {
4127
+ if (zone.length === 0) return false;
4128
+ for (let i = 0; i < zone.length; i++) {
4129
+ if (isZoneCharacter(zone[i])) continue;
4130
+ if (zone[i] === "%" && i + 2 < zone.length && isHexPair(zone.slice(i + 1, i + 3))) {
4131
+ i += 2;
4132
+ continue;
4116
4133
  }
4117
- buffer.length = 0;
4134
+ return false;
4118
4135
  }
4119
4136
  return true;
4120
4137
  }
4121
- function getIPV6(input) {
4122
- let tokenCount = 0;
4123
- const output = { error: false, address: "", zone: "" };
4124
- const address = [];
4125
- const buffer = [];
4126
- let endipv6Encountered = false;
4127
- let endIpv6 = false;
4128
- let consume = consumeHextets;
4129
- for (let i = 0; i < input.length; i++) {
4130
- const cursor = input[i];
4131
- if (cursor === "[" || cursor === "]") {
4132
- continue;
4133
- }
4134
- if (cursor === ":") {
4135
- if (endipv6Encountered === true) {
4136
- endIpv6 = true;
4137
- }
4138
- if (!consume(buffer, address, output)) {
4139
- break;
4138
+ function compressIPv6ZeroRun(hextets) {
4139
+ let bestStart = -1;
4140
+ let bestLength = 0;
4141
+ let runStart = -1;
4142
+ let runLength = 0;
4143
+ for (let i = 0; i < hextets.length; i++) {
4144
+ if (hextets[i] === "0") {
4145
+ if (runStart === -1) runStart = i;
4146
+ runLength++;
4147
+ if (runLength > bestLength) {
4148
+ bestLength = runLength;
4149
+ bestStart = runStart;
4140
4150
  }
4141
- if (++tokenCount > 7) {
4142
- output.error = true;
4143
- break;
4144
- }
4145
- if (i > 0 && input[i - 1] === ":") {
4146
- endipv6Encountered = true;
4147
- }
4148
- address.push(":");
4149
- continue;
4150
- } else if (cursor === "%") {
4151
- if (!consume(buffer, address, output)) {
4152
- break;
4153
- }
4154
- consume = consumeIsZone;
4155
4151
  } else {
4156
- buffer.push(cursor);
4152
+ runStart = -1;
4153
+ runLength = 0;
4154
+ }
4155
+ }
4156
+ if (bestLength < 2) return hextets.join(":");
4157
+ const head = hextets.slice(0, bestStart).join(":");
4158
+ const tail = hextets.slice(bestStart + bestLength).join(":");
4159
+ return head + "::" + tail;
4160
+ }
4161
+ function normalizeIPv6Address(input) {
4162
+ const compression = input.indexOf("::");
4163
+ if (compression !== -1 && input.indexOf("::", compression + 1) !== -1) return void 0;
4164
+ const left = compression === -1 ? input.split(":") : input.slice(0, compression).split(":");
4165
+ const right = compression === -1 ? [] : input.slice(compression + 2).split(":");
4166
+ if (compression !== -1) {
4167
+ if (left.length === 1 && left[0] === "") left.length = 0;
4168
+ if (right.length === 1 && right[0] === "") right.length = 0;
4169
+ }
4170
+ const parts = left.concat(right);
4171
+ let hextetCount = 0;
4172
+ for (let i = 0; i < parts.length; i++) {
4173
+ const part = parts[i];
4174
+ if (part === "") return void 0;
4175
+ if (part.indexOf(".") !== -1) {
4176
+ if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !isIPv4(part)) return void 0;
4177
+ hextetCount += 2;
4157
4178
  continue;
4158
4179
  }
4180
+ if (!isHextet(part)) return void 0;
4181
+ parts[i] = parseInt(part, 16).toString(16);
4182
+ hextetCount++;
4159
4183
  }
4160
- if (buffer.length) {
4161
- if (consume === consumeIsZone) {
4162
- output.zone = buffer.join("");
4163
- } else if (endIpv6) {
4164
- address.push(buffer.join(""));
4165
- } else {
4166
- address.push(stringArrayToHexStripped(buffer));
4167
- }
4184
+ if (compression === -1) {
4185
+ if (hextetCount !== 8) return void 0;
4186
+ return compressIPv6ZeroRun(parts);
4168
4187
  }
4169
- output.address = address.join("");
4170
- return output;
4188
+ if (hextetCount >= 8) return void 0;
4189
+ const expanded = parts.slice(0, left.length);
4190
+ for (let i = hextetCount; i < 8; i++) expanded.push("0");
4191
+ for (let i = left.length; i < parts.length; i++) expanded.push(parts[i]);
4192
+ return compressIPv6ZeroRun(expanded);
4171
4193
  }
4172
4194
  function normalizeIPv6(host) {
4173
- if (findToken(host, ":") < 2) {
4174
- return { host, isIPV6: false };
4175
- }
4176
- const ipv6 = getIPV6(host);
4177
- if (!ipv6.error) {
4178
- let newHost = ipv6.address;
4179
- let escapedHost = ipv6.address;
4180
- if (ipv6.zone) {
4181
- newHost += "%" + ipv6.zone;
4182
- escapedHost += "%25" + ipv6.zone;
4183
- }
4184
- return { host: newHost, isIPV6: true, escapedHost };
4185
- } else {
4186
- return { host, isIPV6: false };
4187
- }
4195
+ const bracketed = host[0] === "[" && host[host.length - 1] === "]";
4196
+ const hasBracket = host[0] === "[" || host[host.length - 1] === "]";
4197
+ if (hasBracket && !bracketed) return { host, isIPV6: false, error: true };
4198
+ let input = bracketed ? host.slice(1, -1) : host;
4199
+ if (bracketed && isIPvFuture(input)) {
4200
+ input = input.toLowerCase();
4201
+ return { host: `[${input}]`, escapedHost: input, isIPV6: false, isIPVFuture: true };
4202
+ }
4203
+ if (findToken(input, ":") < 2) {
4204
+ return { host, isIPV6: false, error: bracketed };
4205
+ }
4206
+ let zoneIdentifier = "";
4207
+ const zoneSeparator = input.indexOf("%");
4208
+ if (zoneSeparator !== -1) {
4209
+ const separatorLength = input.slice(zoneSeparator, zoneSeparator + 3).toLowerCase() === "%25" ? 3 : 1;
4210
+ zoneIdentifier = input.slice(zoneSeparator + separatorLength);
4211
+ if (!isZoneIdentifier(zoneIdentifier)) return { host, isIPV6: false, error: true };
4212
+ input = input.slice(0, zoneSeparator);
4213
+ }
4214
+ const address = normalizeIPv6Address(input);
4215
+ if (address === void 0) return { host, isIPV6: false, error: true };
4216
+ return {
4217
+ host: address + (zoneIdentifier ? "%" + zoneIdentifier : ""),
4218
+ escapedHost: address + (zoneIdentifier ? "%25" + zoneIdentifier : ""),
4219
+ isIPV6: true
4220
+ };
4188
4221
  }
4189
4222
  function findToken(str, token) {
4190
4223
  let ind = 0;
@@ -4268,6 +4301,37 @@ var require_utils2 = __commonJS({
4268
4301
  }
4269
4302
  return output.join("");
4270
4303
  }
4304
+ function removeDotSegmentsRelative(path7) {
4305
+ if (path7 === "" || path7[0] === "/") {
4306
+ return removeDotSegments(path7);
4307
+ }
4308
+ const segments = path7.split("/");
4309
+ const last = segments.length - 1;
4310
+ const output = [];
4311
+ let trailingDirectory = false;
4312
+ for (let i = 0; i <= last; i++) {
4313
+ const segment = segments[i];
4314
+ if (segment === "." || segment === "..") {
4315
+ if (segment === "..") {
4316
+ if (output.length !== 0 && output[output.length - 1] !== "..") {
4317
+ output.pop();
4318
+ } else {
4319
+ output.push("..");
4320
+ }
4321
+ }
4322
+ trailingDirectory = i === last;
4323
+ } else {
4324
+ output.push(segment);
4325
+ }
4326
+ }
4327
+ if (trailingDirectory && output[output.length - 1] !== "..") {
4328
+ output.push("");
4329
+ }
4330
+ if (output.length === 0 || output[0] === "" || output[0].includes(":")) {
4331
+ output.unshift(".");
4332
+ }
4333
+ return output.join("/");
4334
+ }
4271
4335
  var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" };
4272
4336
  var HOST_DELIM_RE = /[@/?#:]/g;
4273
4337
  var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
@@ -4303,7 +4367,8 @@ var require_utils2 = __commonJS({
4303
4367
  function normalizePathEncoding(input) {
4304
4368
  let output = "";
4305
4369
  for (let i = 0; i < input.length; i++) {
4306
- if (input[i] === "%" && i + 2 < input.length) {
4370
+ const ch = input[i];
4371
+ if (ch === "%" && i + 2 < input.length) {
4307
4372
  const hex = input.slice(i + 1, i + 3);
4308
4373
  if (isHexPair(hex)) {
4309
4374
  const normalizedHex = hex.toUpperCase();
@@ -4317,10 +4382,152 @@ var require_utils2 = __commonJS({
4317
4382
  continue;
4318
4383
  }
4319
4384
  }
4320
- if (isPathCharacter(input[i])) {
4321
- output += input[i];
4385
+ if (isPathCharacter(ch)) {
4386
+ output += ch;
4322
4387
  } else {
4323
- output += escape(input[i]);
4388
+ const code = input.charCodeAt(i);
4389
+ if (code < 128) {
4390
+ output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
4391
+ } else if (code < 55296 || code > 57343) {
4392
+ output += percentEncodeNonAscii(code);
4393
+ } else if (code <= 56319 && i + 1 < input.length) {
4394
+ const low = input.charCodeAt(i + 1);
4395
+ if (low >= 56320 && low <= 57343) {
4396
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
4397
+ i++;
4398
+ } else {
4399
+ output += percentEncodeNonAscii(65533);
4400
+ }
4401
+ } else {
4402
+ output += percentEncodeNonAscii(65533);
4403
+ }
4404
+ }
4405
+ }
4406
+ return output;
4407
+ }
4408
+ function serializePathEncoding(input, pathNoScheme = false) {
4409
+ let output = "";
4410
+ let firstSegment = pathNoScheme && input[0] !== "/";
4411
+ for (let i = 0; i < input.length; i++) {
4412
+ const ch = input[i];
4413
+ if (ch === "%" && i + 2 < input.length) {
4414
+ const hex = input.slice(i + 1, i + 3);
4415
+ if (isHexPair(hex)) {
4416
+ output += "%" + hex.toUpperCase();
4417
+ i += 2;
4418
+ continue;
4419
+ }
4420
+ }
4421
+ if (ch === "/") {
4422
+ firstSegment = false;
4423
+ }
4424
+ if (isPathCharacter(ch) && (ch !== ":" || !firstSegment)) {
4425
+ output += ch;
4426
+ } else {
4427
+ const code = input.charCodeAt(i);
4428
+ if (code < 128) {
4429
+ output += BYTE_HEX[code];
4430
+ } else if (code < 55296 || code > 57343) {
4431
+ output += percentEncodeNonAscii(code);
4432
+ } else if (code <= 56319 && i + 1 < input.length) {
4433
+ const low = input.charCodeAt(i + 1);
4434
+ if (low >= 56320 && low <= 57343) {
4435
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
4436
+ i++;
4437
+ } else {
4438
+ output += percentEncodeNonAscii(65533);
4439
+ }
4440
+ } else {
4441
+ output += percentEncodeNonAscii(65533);
4442
+ }
4443
+ }
4444
+ }
4445
+ return output;
4446
+ }
4447
+ function encodeComponent(input, isAllowed) {
4448
+ let output = "";
4449
+ for (let i = 0; i < input.length; i++) {
4450
+ const ch = input[i];
4451
+ if (ch === "%" && i + 2 < input.length) {
4452
+ const hex = input.slice(i + 1, i + 3);
4453
+ if (isHexPair(hex)) {
4454
+ output += "%" + hex.toUpperCase();
4455
+ i += 2;
4456
+ continue;
4457
+ }
4458
+ }
4459
+ if (isAllowed(ch)) {
4460
+ output += ch;
4461
+ } else {
4462
+ const code = input.charCodeAt(i);
4463
+ if (code < 128) {
4464
+ output += BYTE_HEX[code];
4465
+ } else if (code < 55296 || code > 57343) {
4466
+ output += percentEncodeNonAscii(code);
4467
+ } else if (code <= 56319 && i + 1 < input.length) {
4468
+ const low = input.charCodeAt(i + 1);
4469
+ if (low >= 56320 && low <= 57343) {
4470
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
4471
+ i++;
4472
+ } else {
4473
+ output += percentEncodeNonAscii(65533);
4474
+ }
4475
+ } else {
4476
+ output += percentEncodeNonAscii(65533);
4477
+ }
4478
+ }
4479
+ }
4480
+ return output;
4481
+ }
4482
+ function encodeUserinfo(input) {
4483
+ return encodeComponent(input, isUserinfoCharacter);
4484
+ }
4485
+ function encodeQuery(input) {
4486
+ return encodeComponent(input, isQueryFragmentCharacter);
4487
+ }
4488
+ function encodeFragment(input) {
4489
+ return encodeComponent(input, isQueryFragmentCharacter);
4490
+ }
4491
+ function isEscapeSafe(cp2) {
4492
+ return cp2 >= 48 && cp2 <= 57 || cp2 >= 65 && cp2 <= 90 || cp2 >= 97 && cp2 <= 122 || cp2 === 42 || cp2 === 43 || cp2 === 45 || cp2 === 46 || cp2 === 47 || cp2 === 64 || cp2 === 95;
4493
+ }
4494
+ function normalizeQueryFragmentEncoding(input) {
4495
+ let output = "";
4496
+ for (let i = 0; i < input.length; i++) {
4497
+ const ch = input[i];
4498
+ if (ch === "%" && i + 2 < input.length) {
4499
+ const hex = input.slice(i + 1, i + 3);
4500
+ if (isHexPair(hex)) {
4501
+ const normalizedHex = hex.toUpperCase();
4502
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
4503
+ if (isUnreserved(decoded)) {
4504
+ output += decoded;
4505
+ } else {
4506
+ output += "%" + normalizedHex;
4507
+ }
4508
+ i += 2;
4509
+ continue;
4510
+ }
4511
+ }
4512
+ if (isQueryFragmentCharacter(ch)) {
4513
+ output += ch;
4514
+ } else {
4515
+ const code = input.charCodeAt(i);
4516
+ if (code < 128) {
4517
+ output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
4518
+ } else if (code < 55296 || code > 57343) {
4519
+ output += percentEncodeNonAscii(code);
4520
+ } else if (code <= 56319 && i + 1 < input.length) {
4521
+ const low = input.charCodeAt(i + 1);
4522
+ if (low >= 56320 && low <= 57343) {
4523
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
4524
+ i++;
4525
+ } else {
4526
+ output += percentEncodeNonAscii(65533);
4527
+ }
4528
+ } else {
4529
+ output += percentEncodeNonAscii(65533);
4530
+ }
4324
4531
  }
4325
4532
  }
4326
4533
  return output;
@@ -4343,14 +4550,18 @@ var require_utils2 = __commonJS({
4343
4550
  function recomposeAuthority(component) {
4344
4551
  const uriTokens = [];
4345
4552
  if (component.userinfo !== void 0) {
4346
- uriTokens.push(component.userinfo);
4553
+ uriTokens.push(encodeUserinfo(component.userinfo));
4347
4554
  uriTokens.push("@");
4348
4555
  }
4349
4556
  if (component.host !== void 0) {
4350
- let host = unescape(component.host);
4557
+ let host = component.host;
4351
4558
  if (!isIPv4(host)) {
4352
- const ipV6res = normalizeIPv6(host);
4353
- if (ipV6res.isIPV6 === true) {
4559
+ let ipV6res = normalizeIPv6(host);
4560
+ if (ipV6res.isIPV6 !== true && ipV6res.isIPVFuture !== true) {
4561
+ host = normalizePercentEncoding(host, true);
4562
+ ipV6res = normalizeIPv6(host);
4563
+ }
4564
+ if (ipV6res.isIPV6 === true || ipV6res.isIPVFuture === true) {
4354
4565
  host = `[${ipV6res.escapedHost}]`;
4355
4566
  } else {
4356
4567
  host = reescapeHostDelimiters(host, false);
@@ -4359,8 +4570,12 @@ var require_utils2 = __commonJS({
4359
4570
  uriTokens.push(host);
4360
4571
  }
4361
4572
  if (typeof component.port === "number" || typeof component.port === "string") {
4573
+ const port2 = String(component.port);
4574
+ if (!isPort(port2)) {
4575
+ throw new TypeError("URI port is malformed.");
4576
+ }
4362
4577
  uriTokens.push(":");
4363
- uriTokens.push(String(component.port));
4578
+ uriTokens.push(port2);
4364
4579
  }
4365
4580
  return uriTokens.length ? uriTokens.join("") : void 0;
4366
4581
  }
@@ -4370,8 +4585,14 @@ var require_utils2 = __commonJS({
4370
4585
  reescapeHostDelimiters,
4371
4586
  normalizePercentEncoding,
4372
4587
  normalizePathEncoding,
4588
+ serializePathEncoding,
4589
+ normalizeQueryFragmentEncoding,
4590
+ encodeUserinfo,
4591
+ encodeQuery,
4592
+ encodeFragment,
4373
4593
  escapePreservingEscapes,
4374
4594
  removeDotSegments,
4595
+ removeDotSegmentsRelative,
4375
4596
  isIPv4,
4376
4597
  isUUID,
4377
4598
  normalizeIPv6,
@@ -4380,12 +4601,12 @@ var require_utils2 = __commonJS({
4380
4601
  }
4381
4602
  });
4382
4603
 
4383
- // ../node_modules/.bun/fast-uri@3.1.2/node_modules/fast-uri/lib/schemes.js
4604
+ // ../node_modules/.bun/fast-uri@3.1.9/node_modules/fast-uri/lib/schemes.js
4384
4605
  var require_schemes2 = __commonJS({
4385
- "../node_modules/.bun/fast-uri@3.1.2/node_modules/fast-uri/lib/schemes.js"(exports, module) {
4606
+ "../node_modules/.bun/fast-uri@3.1.9/node_modules/fast-uri/lib/schemes.js"(exports, module) {
4386
4607
  "use strict";
4387
4608
  var { isUUID } = require_utils2();
4388
- var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
4609
+ var URN_REG = /^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu;
4389
4610
  var supportedSchemeNames = (
4390
4611
  /** @type {const} */
4391
4612
  [
@@ -4446,9 +4667,10 @@ var require_schemes2 = __commonJS({
4446
4667
  wsComponent.secure = void 0;
4447
4668
  }
4448
4669
  if (wsComponent.resourceName) {
4449
- const [path7, query2] = wsComponent.resourceName.split("?");
4670
+ const queryIndex = wsComponent.resourceName.indexOf("?");
4671
+ const path7 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
4450
4672
  wsComponent.path = path7 && path7 !== "/" ? path7 : void 0;
4451
- wsComponent.query = query2;
4673
+ wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
4452
4674
  wsComponent.resourceName = void 0;
4453
4675
  }
4454
4676
  wsComponent.fragment = void 0;
@@ -4460,7 +4682,7 @@ var require_schemes2 = __commonJS({
4460
4682
  return urnComponent;
4461
4683
  }
4462
4684
  const matches = urnComponent.path.match(URN_REG);
4463
- if (matches) {
4685
+ if (matches && matches[0] === urnComponent.path) {
4464
4686
  const scheme = options.scheme || urnComponent.scheme || "urn";
4465
4687
  urnComponent.nid = matches[1].toLowerCase();
4466
4688
  urnComponent.nss = matches[2];
@@ -4590,12 +4812,23 @@ var require_schemes2 = __commonJS({
4590
4812
  }
4591
4813
  });
4592
4814
 
4593
- // ../node_modules/.bun/fast-uri@3.1.2/node_modules/fast-uri/index.js
4815
+ // ../node_modules/.bun/fast-uri@3.1.9/node_modules/fast-uri/index.js
4594
4816
  var require_fast_uri2 = __commonJS({
4595
- "../node_modules/.bun/fast-uri@3.1.2/node_modules/fast-uri/index.js"(exports, module) {
4817
+ "../node_modules/.bun/fast-uri@3.1.9/node_modules/fast-uri/index.js"(exports, module) {
4596
4818
  "use strict";
4597
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils2();
4819
+ var { normalizeIPv6, removeDotSegments, removeDotSegmentsRelative, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils2();
4598
4820
  var { SCHEMES, getSchemeHandler } = require_schemes2();
4821
+ var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
4822
+ var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
4823
+ var MALFORMED_HOST_ERROR = "URI host is malformed.";
4824
+ var FORBIDDEN_DOMAIN_HOST_CHARACTER = /[\0-\x20"#/:<>?@[\\\]^`{|}\x7F]/u;
4825
+ function validateScheme(scheme) {
4826
+ const stringScheme = String(scheme);
4827
+ if (!VALID_SCHEME.test(stringScheme)) {
4828
+ throw new TypeError(MALFORMED_SCHEME_ERROR);
4829
+ }
4830
+ return stringScheme;
4831
+ }
4599
4832
  function normalize(uri, options) {
4600
4833
  if (typeof uri === "string") {
4601
4834
  uri = /** @type {T} */
@@ -4608,7 +4841,37 @@ var require_fast_uri2 = __commonJS({
4608
4841
  }
4609
4842
  function resolve7(baseURI, relativeURI, options) {
4610
4843
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
4611
- const resolved = resolveComponent(parse2(baseURI, schemelessOptions), parse2(relativeURI, schemelessOptions), schemelessOptions, true);
4844
+ const {
4845
+ parsed: baseParsed,
4846
+ malformedAuthorityOrPort: baseMalformed,
4847
+ malformedPercentEncoding: baseMalformedPercentEncoding,
4848
+ malformedSchemeSpecific: baseMalformedSchemeSpecific,
4849
+ malformedHost: baseMalformedHost,
4850
+ malformedScheme: baseMalformedScheme
4851
+ } = parseWithStatus(baseURI, schemelessOptions);
4852
+ const {
4853
+ parsed: relativeParsed,
4854
+ malformedAuthorityOrPort: relativeMalformed,
4855
+ malformedPercentEncoding: relativeMalformedPercentEncoding,
4856
+ malformedSchemeSpecific: relativeMalformedSchemeSpecific,
4857
+ malformedHost: relativeMalformedHost,
4858
+ malformedScheme: relativeMalformedScheme
4859
+ } = parseWithStatus(relativeURI, schemelessOptions);
4860
+ if (baseMalformed || relativeMalformed || baseMalformedPercentEncoding || relativeMalformedPercentEncoding || baseMalformedSchemeSpecific || relativeMalformedSchemeSpecific || baseMalformedHost || relativeMalformedHost || baseMalformedScheme || relativeMalformedScheme) {
4861
+ throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
4862
+ }
4863
+ const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
4864
+ const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
4865
+ const resolvedHost = resolved.host;
4866
+ const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
4867
+ if (hasForbiddenDomainHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP)) {
4868
+ throw new Error(MALFORMED_HOST_ERROR);
4869
+ }
4870
+ canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
4871
+ const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !/\P{ASCII}/u.test(resolvedHost);
4872
+ if (resolved.error && !encodedASCIIHost) {
4873
+ throw new Error(resolved.error);
4874
+ }
4612
4875
  schemelessOptions.skipEscape = true;
4613
4876
  return serialize(resolved, schemelessOptions);
4614
4877
  }
@@ -4645,14 +4908,15 @@ var require_fast_uri2 = __commonJS({
4645
4908
  if (relative3.path[0] === "/") {
4646
4909
  target.path = removeDotSegments(relative3.path);
4647
4910
  } else {
4648
- if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
4911
+ const baseHasAuthority = base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0;
4912
+ if (baseHasAuthority && !base.path) {
4649
4913
  target.path = "/" + relative3.path;
4650
4914
  } else if (!base.path) {
4651
4915
  target.path = relative3.path;
4652
4916
  } else {
4653
4917
  target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative3.path;
4654
4918
  }
4655
- target.path = removeDotSegments(target.path);
4919
+ target.path = base.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
4656
4920
  }
4657
4921
  target.query = relative3.query;
4658
4922
  }
@@ -4668,7 +4932,7 @@ var require_fast_uri2 = __commonJS({
4668
4932
  function equal(uriA, uriB, options) {
4669
4933
  const normalizedA = normalizeComparableURI(uriA, options);
4670
4934
  const normalizedB = normalizeComparableURI(uriB, options);
4671
- return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase();
4935
+ return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA === normalizedB;
4672
4936
  }
4673
4937
  function serialize(cmpts, opts) {
4674
4938
  const component = {
@@ -4689,19 +4953,23 @@ var require_fast_uri2 = __commonJS({
4689
4953
  };
4690
4954
  const options = Object.assign({}, opts);
4691
4955
  const uriTokens = [];
4956
+ if (component.scheme) {
4957
+ component.scheme = validateScheme(component.scheme);
4958
+ }
4692
4959
  const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
4693
4960
  if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
4961
+ const hasAuthority = component.userinfo !== void 0 || component.host !== void 0 || component.port !== void 0;
4962
+ const schemelessReference = (component.scheme === void 0 || options.reference === "suffix") && !hasAuthority;
4963
+ const pathNoScheme = !options.skipEscape && schemelessReference;
4694
4964
  if (component.path !== void 0) {
4695
4965
  if (!options.skipEscape) {
4696
- component.path = escapePreservingEscapes(component.path);
4697
- if (component.scheme !== void 0) {
4698
- component.path = component.path.split("%3A").join(":");
4699
- }
4966
+ component.path = serializePathEncoding(component.path, pathNoScheme);
4700
4967
  } else {
4701
4968
  component.path = normalizePercentEncoding(component.path);
4702
4969
  }
4703
4970
  }
4704
4971
  if (options.reference !== "suffix" && component.scheme) {
4972
+ component.scheme = validateScheme(component.scheme);
4705
4973
  uriTokens.push(component.scheme, ":");
4706
4974
  }
4707
4975
  const authority = recomposeAuthority(component);
@@ -4717,7 +4985,10 @@ var require_fast_uri2 = __commonJS({
4717
4985
  if (component.path !== void 0) {
4718
4986
  let s = component.path;
4719
4987
  if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
4720
- s = removeDotSegments(s);
4988
+ s = schemelessReference && s[0] !== "/" ? removeDotSegmentsRelative(s) : removeDotSegments(s);
4989
+ }
4990
+ if (schemelessReference) {
4991
+ s = serializePathEncoding(s, true);
4721
4992
  }
4722
4993
  if (authority === void 0 && s[0] === "/" && s[1] === "/") {
4723
4994
  s = "/%2F" + s.slice(2);
@@ -4725,14 +4996,16 @@ var require_fast_uri2 = __commonJS({
4725
4996
  uriTokens.push(s);
4726
4997
  }
4727
4998
  if (component.query !== void 0) {
4728
- uriTokens.push("?", component.query);
4999
+ uriTokens.push("?", encodeQuery(component.query));
4729
5000
  }
4730
5001
  if (component.fragment !== void 0) {
4731
- uriTokens.push("#", component.fragment);
5002
+ uriTokens.push("#", encodeFragment(component.fragment));
4732
5003
  }
4733
5004
  return uriTokens.join("");
4734
5005
  }
4735
5006
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
5007
+ var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
5008
+ var AUTHORITY_INTRODUCER_REGION = /^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;
4736
5009
  function getParseError(parsed, matches) {
4737
5010
  if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
4738
5011
  return 'URI path must start with "/" when authority is present.';
@@ -4742,6 +5015,53 @@ var require_fast_uri2 = __commonJS({
4742
5015
  }
4743
5016
  return void 0;
4744
5017
  }
5018
+ function hasMalformedPercentEncoding(component) {
5019
+ if (component === void 0) return false;
5020
+ let percent = component.indexOf("%");
5021
+ while (percent !== -1) {
5022
+ if (percent + 2 >= component.length || !/^[\da-f]{2}$/iu.test(component.slice(percent + 1, percent + 3))) {
5023
+ return true;
5024
+ }
5025
+ percent = component.indexOf("%", percent + 3);
5026
+ }
5027
+ return false;
5028
+ }
5029
+ function isIPLiteral(host) {
5030
+ return host[0] === "[" && host[host.length - 1] === "]";
5031
+ }
5032
+ function hasMalformedComponentPercentEncoding(matches) {
5033
+ const host = matches[4];
5034
+ return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
5035
+ }
5036
+ function canonicalizeHost(parsed, options, schemeHandler, isIP) {
5037
+ if (hasForbiddenDomainHost(parsed, options, schemeHandler, isIP)) {
5038
+ parsed.error = parsed.error || MALFORMED_HOST_ERROR;
5039
+ return true;
5040
+ }
5041
+ if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
5042
+ let url3;
5043
+ try {
5044
+ url3 = new URL("http://" + parsed.host);
5045
+ } catch (e) {
5046
+ parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
5047
+ return true;
5048
+ }
5049
+ if (!isHostOnlyURL(url3)) {
5050
+ parsed.error = parsed.error || MALFORMED_HOST_ERROR;
5051
+ return true;
5052
+ }
5053
+ parsed.host = url3.hostname;
5054
+ }
5055
+ return false;
5056
+ }
5057
+ function hasForbiddenDomainHost(parsed, options, schemeHandler, isIP) {
5058
+ return Boolean(
5059
+ parsed.host && isIP === false && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && FORBIDDEN_DOMAIN_HOST_CHARACTER.test(parsed.host)
5060
+ );
5061
+ }
5062
+ function isHostOnlyURL(url3) {
5063
+ return url3.username === "" && url3.password === "" && url3.port === "" && url3.pathname === "/" && url3.search === "" && url3.hash === "" && url3.hostname !== "";
5064
+ }
4745
5065
  function parseWithStatus(uri, opts) {
4746
5066
  const options = Object.assign({}, opts);
4747
5067
  const parsed = {
@@ -4754,6 +5074,11 @@ var require_fast_uri2 = __commonJS({
4754
5074
  fragment: void 0
4755
5075
  };
4756
5076
  let malformedAuthorityOrPort = false;
5077
+ let malformedPercentEncoding = false;
5078
+ let malformedSchemeSpecific = false;
5079
+ let malformedHost = false;
5080
+ let malformedIPLiteral = false;
5081
+ let malformedScheme = false;
4757
5082
  let isIP = false;
4758
5083
  if (options.reference === "suffix") {
4759
5084
  if (options.scheme) {
@@ -4762,6 +5087,25 @@ var require_fast_uri2 = __commonJS({
4762
5087
  uri = "//" + uri;
4763
5088
  }
4764
5089
  }
5090
+ const authorityMatch = uri.match(AUTHORITY_PREFIX);
5091
+ if (authorityMatch !== null && authorityMatch[1].indexOf("\\") !== -1) {
5092
+ parsed.error = "URI authority must not contain a literal backslash.";
5093
+ malformedAuthorityOrPort = true;
5094
+ }
5095
+ const introducerMatch = uri.match(AUTHORITY_INTRODUCER_REGION);
5096
+ if (introducerMatch !== null) {
5097
+ const region = introducerMatch[1];
5098
+ const normalizedRegion = region.replace(/[\t\n\r]/g, "");
5099
+ if (normalizedRegion.length >= 2) {
5100
+ if (normalizedRegion.slice(0, 2) !== "//") {
5101
+ parsed.error = parsed.error || "URI authority must not contain a literal backslash.";
5102
+ malformedAuthorityOrPort = true;
5103
+ } else if (region.length !== normalizedRegion.length) {
5104
+ parsed.error = parsed.error || "URI authority introducer must not contain whitespace.";
5105
+ malformedAuthorityOrPort = true;
5106
+ }
5107
+ }
5108
+ }
4765
5109
  const matches = uri.match(URI_PARSE);
4766
5110
  if (matches) {
4767
5111
  parsed.scheme = matches[1];
@@ -4771,6 +5115,18 @@ var require_fast_uri2 = __commonJS({
4771
5115
  parsed.path = matches[6] || "";
4772
5116
  parsed.query = matches[7];
4773
5117
  parsed.fragment = matches[8];
5118
+ if (parsed.scheme !== void 0) {
5119
+ if (VALID_SCHEME.test(parsed.scheme)) {
5120
+ parsed.scheme = parsed.scheme.toLowerCase();
5121
+ } else {
5122
+ parsed.error = parsed.error || MALFORMED_SCHEME_ERROR;
5123
+ malformedScheme = true;
5124
+ }
5125
+ }
5126
+ malformedPercentEncoding = hasMalformedComponentPercentEncoding(matches);
5127
+ if (malformedPercentEncoding) {
5128
+ parsed.error = parsed.error || "URI contains malformed percent-encoding.";
5129
+ }
4774
5130
  if (isNaN(parsed.port)) {
4775
5131
  parsed.port = matches[5];
4776
5132
  }
@@ -4782,9 +5138,16 @@ var require_fast_uri2 = __commonJS({
4782
5138
  if (parsed.host) {
4783
5139
  const ipv4result = isIPv4(parsed.host);
4784
5140
  if (ipv4result === false) {
5141
+ const bracketedIPLiteral = isIPLiteral(parsed.host);
5142
+ const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1;
4785
5143
  const ipv6result = normalizeIPv6(parsed.host);
4786
- parsed.host = ipv6result.host.toLowerCase();
4787
- isIP = ipv6result.isIPV6;
5144
+ isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
5145
+ malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
5146
+ parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
5147
+ if (malformedIPLiteral) {
5148
+ parsed.error = parsed.error || MALFORMED_HOST_ERROR;
5149
+ malformedAuthorityOrPort = true;
5150
+ }
4788
5151
  } else {
4789
5152
  isIP = true;
4790
5153
  }
@@ -4802,42 +5165,37 @@ var require_fast_uri2 = __commonJS({
4802
5165
  parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
4803
5166
  }
4804
5167
  const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
4805
- if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
4806
- if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
4807
- try {
4808
- parsed.host = URL.domainToASCII(parsed.host.toLowerCase());
4809
- } catch (e) {
4810
- parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
4811
- }
5168
+ if (!malformedIPLiteral) {
5169
+ malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
5170
+ }
5171
+ if (uri.indexOf("%") !== -1 && parsed.host !== void 0 && !malformedIPLiteral) {
5172
+ let host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
5173
+ if (!isIP) {
5174
+ host = normalizePercentEncoding(host.toLowerCase());
4812
5175
  }
5176
+ parsed.host = isIP || options.scheme !== "null" ? reescapeHostDelimiters(host, isIP) : host;
4813
5177
  }
4814
5178
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
4815
- if (uri.indexOf("%") !== -1) {
4816
- if (parsed.scheme !== void 0) {
4817
- parsed.scheme = unescape(parsed.scheme);
4818
- }
4819
- if (parsed.host !== void 0) {
4820
- parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
4821
- }
4822
- }
4823
5179
  if (parsed.path) {
4824
5180
  parsed.path = normalizePathEncoding(parsed.path);
4825
5181
  }
5182
+ if (parsed.query) {
5183
+ parsed.query = normalizeQueryFragmentEncoding(parsed.query);
5184
+ }
4826
5185
  if (parsed.fragment) {
4827
- try {
4828
- parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
4829
- } catch {
4830
- parsed.error = parsed.error || "URI malformed";
4831
- }
5186
+ parsed.fragment = normalizeQueryFragmentEncoding(parsed.fragment);
4832
5187
  }
4833
5188
  }
4834
5189
  if (schemeHandler && schemeHandler.parse) {
4835
5190
  schemeHandler.parse(parsed, options);
5191
+ if (schemeHandler === SCHEMES.urn && parsed.nid === void 0) {
5192
+ malformedSchemeSpecific = true;
5193
+ }
4836
5194
  }
4837
5195
  } else {
4838
5196
  parsed.error = parsed.error || "URI can not be parsed.";
4839
5197
  }
4840
- return { parsed, malformedAuthorityOrPort };
5198
+ return { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme };
4841
5199
  }
4842
5200
  function parse2(uri, opts) {
4843
5201
  return parseWithStatus(uri, opts).parsed;
@@ -4846,20 +5204,28 @@ var require_fast_uri2 = __commonJS({
4846
5204
  return normalizeStringWithStatus(uri, opts).normalized;
4847
5205
  }
4848
5206
  function normalizeStringWithStatus(uri, opts) {
4849
- const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
5207
+ const { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = parseWithStatus(uri, opts);
4850
5208
  return {
4851
- normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts),
4852
- malformedAuthorityOrPort
5209
+ normalized: malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? uri : serialize(parsed, opts),
5210
+ malformedAuthorityOrPort,
5211
+ malformedPercentEncoding,
5212
+ malformedSchemeSpecific,
5213
+ malformedHost,
5214
+ malformedScheme
4853
5215
  };
4854
5216
  }
4855
5217
  function normalizeComparableURI(uri, opts) {
4856
- if (typeof uri === "string") {
4857
- const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts);
4858
- return malformedAuthorityOrPort ? void 0 : normalized;
5218
+ if (typeof uri !== "string" && typeof uri !== "object") {
5219
+ return void 0;
4859
5220
  }
4860
- if (typeof uri === "object") {
4861
- return serialize(uri, opts);
5221
+ let value;
5222
+ try {
5223
+ value = typeof uri === "string" ? uri : serialize(uri, opts);
5224
+ } catch {
5225
+ return void 0;
4862
5226
  }
5227
+ const { normalized, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = normalizeStringWithStatus(value, opts);
5228
+ return malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? void 0 : normalized;
4863
5229
  }
4864
5230
  var fastUri = {
4865
5231
  SCHEMES,
@@ -22489,10 +22855,10 @@ __export(typebox_exports, {
22489
22855
  With: () => With2
22490
22856
  });
22491
22857
 
22492
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/init.ts
22858
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/init.ts
22493
22859
  import { existsSync as existsSync11 } from "fs";
22494
22860
 
22495
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/errors.ts
22861
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/errors.ts
22496
22862
  var McpUiError = class extends Error {
22497
22863
  code;
22498
22864
  context;
@@ -22671,7 +23037,7 @@ var InputRequiredNeedsUiError = class extends McpUiError {
22671
23037
  details;
22672
23038
  };
22673
23039
 
22674
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/logger.ts
23040
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/logger.ts
22675
23041
  var LEVEL_PRIORITY = {
22676
23042
  debug: 0,
22677
23043
  info: 1,
@@ -22788,7 +23154,7 @@ if (process.env.MCP_UI_DEBUG === "1" || process.env.MCP_UI_DEBUG === "true") {
22788
23154
  logger.setLevel("debug");
22789
23155
  }
22790
23156
 
22791
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/consent-manager.ts
23157
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/consent-manager.ts
22792
23158
  var ConsentManager = class {
22793
23159
  constructor(mode = "once-per-server") {
22794
23160
  this.mode = mode;
@@ -22843,7 +23209,7 @@ var ConsentManager = class {
22843
23209
  }
22844
23210
  };
22845
23211
 
22846
- // ../node_modules/.bun/@modelcontextprotocol+client@2.0.0/node_modules/@modelcontextprotocol/client/dist/chunk-Br0eD_fh.mjs
23212
+ // ../node_modules/.bun/@modelcontextprotocol+client@2.3.0/node_modules/@modelcontextprotocol/client/dist/chunk-Br0eD_fh.mjs
22847
23213
  var __create = Object.create;
22848
23214
  var __defProp = Object.defineProperty;
22849
23215
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -22883,7 +23249,7 @@ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__g
22883
23249
  enumerable: true
22884
23250
  }) : target, mod));
22885
23251
 
22886
- // ../node_modules/.bun/@modelcontextprotocol+client@2.0.0/node_modules/@modelcontextprotocol/client/dist/dialects-BOhdv1Fc.mjs
23252
+ // ../node_modules/.bun/@modelcontextprotocol+client@2.3.0/node_modules/@modelcontextprotocol/client/dist/dialects-BOhdv1Fc.mjs
22887
23253
  var DRAFT_2020_12_URIS = /* @__PURE__ */ new Set(["https://json-schema.org/draft/2020-12/schema", "http://json-schema.org/draft/2020-12/schema"]);
22888
23254
  var DRAFT_2019_09_URIS = /* @__PURE__ */ new Set(["https://json-schema.org/draft/2019-09/schema", "http://json-schema.org/draft/2019-09/schema"]);
22889
23255
  var DRAFT_07_URIS = /* @__PURE__ */ new Set(["https://json-schema.org/draft-07/schema", "http://json-schema.org/draft-07/schema"]);
@@ -22900,7 +23266,7 @@ function declaredDialect(schema, remedy) {
22900
23266
  throw new Error(`JSON Schema declares an unsupported dialect ("$schema": "${schema.$schema.slice(0, 200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${remedy}`);
22901
23267
  }
22902
23268
 
22903
- // ../node_modules/.bun/@modelcontextprotocol+core@2.0.0/node_modules/@modelcontextprotocol/core/dist/auth-CUe6YdwF.mjs
23269
+ // ../node_modules/.bun/@modelcontextprotocol+core@2.3.0/node_modules/@modelcontextprotocol/core/dist/auth-BNDyLTqp.mjs
22904
23270
  import * as z from "zod/v4";
22905
23271
  var LATEST_PROTOCOL_VERSION = "2025-11-25";
22906
23272
  var SUPPORTED_PROTOCOL_VERSIONS = [
@@ -23738,7 +24104,8 @@ var OAuthMetadataSchema = z.looseObject({
23738
24104
  introspection_endpoint_auth_signing_alg_values_supported: z.array(z.string()).optional(),
23739
24105
  code_challenge_methods_supported: z.array(z.string()).optional(),
23740
24106
  client_id_metadata_document_supported: z.boolean().optional(),
23741
- authorization_response_iss_parameter_supported: z.boolean().optional().catch(void 0)
24107
+ authorization_response_iss_parameter_supported: z.boolean().optional().catch(void 0),
24108
+ dpop_signing_alg_values_supported: z.array(z.string()).optional()
23742
24109
  });
23743
24110
  var OpenIdProviderMetadataSchema = z.looseObject({
23744
24111
  issuer: z.string(),
@@ -23789,7 +24156,8 @@ var OAuthTokensSchema = z.object({
23789
24156
  token_type: z.string(),
23790
24157
  expires_in: z.coerce.number().optional(),
23791
24158
  scope: z.string().optional(),
23792
- refresh_token: z.string().optional()
24159
+ refresh_token: z.string().optional(),
24160
+ issuer: z.string().optional().catch(void 0)
23793
24161
  }).strip();
23794
24162
  var IdJagTokenExchangeResponseSchema = z.object({
23795
24163
  issued_token_type: z.literal("urn:ietf:params:oauth:token-type:id-jag"),
@@ -23827,7 +24195,8 @@ var OAuthClientInformationSchema = z.object({
23827
24195
  client_id: z.string(),
23828
24196
  client_secret: z.string().optional(),
23829
24197
  client_id_issued_at: z.number().optional(),
23830
- client_secret_expires_at: z.number().optional()
24198
+ client_secret_expires_at: z.number().optional(),
24199
+ issuer: z.string().optional().catch(void 0)
23831
24200
  }).strip();
23832
24201
  var OAuthClientInformationFullSchema = OAuthClientMetadataSchema.merge(OAuthClientInformationSchema);
23833
24202
  var OAuthClientRegistrationErrorSchema = z.object({
@@ -23839,7 +24208,7 @@ var OAuthTokenRevocationRequestSchema = z.object({
23839
24208
  token_type_hint: z.string().optional()
23840
24209
  }).strip();
23841
24210
 
23842
- // ../node_modules/.bun/@modelcontextprotocol+client@2.0.0/node_modules/@modelcontextprotocol/client/dist/src-D_zzAWoS.mjs
24211
+ // ../node_modules/.bun/@modelcontextprotocol+client@2.3.0/node_modules/@modelcontextprotocol/client/dist/src-WCy6ifGf.mjs
23843
24212
  import * as z2 from "zod/v4";
23844
24213
  var BRANDS = /* @__PURE__ */ Symbol.for("mcp.sdk.errorBrands");
23845
24214
  function stampErrorBrands(instance, ctor) {
@@ -23886,6 +24255,8 @@ var OAuthErrorCode = /* @__PURE__ */ (function(OAuthErrorCode$1) {
23886
24255
  OAuthErrorCode$1["InvalidRedirectUri"] = "invalid_redirect_uri";
23887
24256
  OAuthErrorCode$1["InsufficientScope"] = "insufficient_scope";
23888
24257
  OAuthErrorCode$1["InvalidTarget"] = "invalid_target";
24258
+ OAuthErrorCode$1["InvalidDpopProof"] = "invalid_dpop_proof";
24259
+ OAuthErrorCode$1["UseDpopNonce"] = "use_dpop_nonce";
23889
24260
  return OAuthErrorCode$1;
23890
24261
  })({});
23891
24262
  var OAuthError = class OAuthError2 extends Error {
@@ -23975,8 +24346,18 @@ var SdkError = class extends Error {
23975
24346
  if (typeof this !== "function") throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");
23976
24347
  return brandedHasInstance(this, value);
23977
24348
  }
23978
- constructor(code, message, data) {
23979
- super(message);
24349
+ /**
24350
+ * @param code - Stable string code identifying the failure ({@linkcode SdkErrorCode}).
24351
+ * @param message - Human-readable description.
24352
+ * @param data - Optional structured payload (for example the HTTP status carried by
24353
+ * {@linkcode SdkHttpError}). Opaque to the SDK: a `cause` key inside `data` is not
24354
+ * promoted to `Error.cause`.
24355
+ * @param options - Standard `ErrorOptions`, forwarded to `Error`. Pass the underlying
24356
+ * failure as `{ cause }` so it is reachable through the `Error.cause` chain that
24357
+ * loggers and error trackers walk.
24358
+ */
24359
+ constructor(code, message, data, options) {
24360
+ super(message, options);
23980
24361
  this.code = code;
23981
24362
  this.data = data;
23982
24363
  this.name = "SdkError";
@@ -23987,8 +24368,11 @@ var SdkHttpError = class extends SdkError {
23987
24368
  static {
23988
24369
  Object.defineProperty(this, "mcpBrand", { value: "mcp.SdkHttpError" });
23989
24370
  }
23990
- constructor(code, message, data) {
23991
- super(code, message, data);
24371
+ /**
24372
+ * @param options - Standard `ErrorOptions`, forwarded to `Error` (see {@linkcode SdkError}).
24373
+ */
24374
+ constructor(code, message, data, options) {
24375
+ super(code, message, data, options);
23992
24376
  this.name = "SdkHttpError";
23993
24377
  }
23994
24378
  get status() {
@@ -24003,6 +24387,12 @@ function resourceUrlFromServerUrl(url3) {
24003
24387
  resourceURL.hash = "";
24004
24388
  return resourceURL;
24005
24389
  }
24390
+ function withoutIssuer(body) {
24391
+ if (typeof body !== "object" || body === null || Array.isArray(body)) return body;
24392
+ const copy = { ...body };
24393
+ delete copy.issuer;
24394
+ return copy;
24395
+ }
24006
24396
  function checkResourceAllowed({ requestedResource, configuredResource }) {
24007
24397
  const requested = typeof requestedResource === "string" ? new URL(requestedResource) : new URL(requestedResource.href);
24008
24398
  const configured = typeof configuredResource === "string" ? new URL(configuredResource) : new URL(configuredResource.href);
@@ -25112,7 +25502,7 @@ function getNotificationSchema(method) {
25112
25502
  }
25113
25503
  var rev2025RequestMethods = Object.keys(requestMethodKeys$1);
25114
25504
  var rev2025NotificationMethods = Object.keys(notificationMethodKeys$1);
25115
- function isPlainObject$4(value) {
25505
+ function isPlainObject$5(value) {
25116
25506
  return value !== null && typeof value === "object" && !Array.isArray(value);
25117
25507
  }
25118
25508
  function triState$1(schema, raw) {
@@ -25135,7 +25525,7 @@ var NOT_IN_ERA$1 = {
25135
25525
  reason: "not-in-era"
25136
25526
  };
25137
25527
  function toolNeedsLegacyWrap(t) {
25138
- return isPlainObject$4(t) && isPlainObject$4(t["outputSchema"]) && isNonObjectJsonSchemaRoot(t["outputSchema"]);
25528
+ return isPlainObject$5(t) && isPlainObject$5(t["outputSchema"]) && isNonObjectJsonSchemaRoot(t["outputSchema"]);
25139
25529
  }
25140
25530
  function toNeutralResult(value) {
25141
25531
  return value;
@@ -25169,7 +25559,7 @@ var rev2025Codec = {
25169
25559
  };
25170
25560
  },
25171
25561
  decodeResult(_method, raw) {
25172
- if (isPlainObject$4(raw) && "resultType" in raw) {
25562
+ if (isPlainObject$5(raw) && "resultType" in raw) {
25173
25563
  const stripped = { ...raw };
25174
25564
  delete stripped["resultType"];
25175
25565
  return {
@@ -26066,7 +26456,8 @@ function build() {
26066
26456
  ListResourceTemplatesResultResponseSchema: wireResultResponse(ListResourceTemplatesResultSchema$1),
26067
26457
  ReadResourceResultResponseSchema: wireResultResponse(z2.union([ReadResourceResultSchema$1, InputRequiredResultSchema])),
26068
26458
  CompleteResultResponseSchema: wireResultResponse(CompleteResultSchema$1),
26069
- DiscoverResultResponseSchema: wireResultResponse(DiscoverResultSchema$1)
26459
+ DiscoverResultResponseSchema: wireResultResponse(DiscoverResultSchema$1),
26460
+ SubscriptionsListenResultResponseSchema: wireResultResponse(SubscriptionsListenResultSchema$1)
26070
26461
  };
26071
26462
  }
26072
26463
  var memo;
@@ -26248,7 +26639,7 @@ function fillCacheFields(method, result) {
26248
26639
  delete filled[RESULT_CACHE_HINT_FALLBACK];
26249
26640
  return filled;
26250
26641
  }
26251
- function isPlainObject$3(value) {
26642
+ function isPlainObject$4(value) {
26252
26643
  return value !== null && typeof value === "object" && !Array.isArray(value);
26253
26644
  }
26254
26645
  function stampServerInfoMeta(result, serverInfo) {
@@ -26258,7 +26649,7 @@ function stampServerInfoMeta(result, serverInfo) {
26258
26649
  ...result,
26259
26650
  _meta: { [SERVER_INFO_META_KEY]: serverInfo }
26260
26651
  };
26261
- if (!isPlainObject$3(meta)) return result;
26652
+ if (!isPlainObject$4(meta)) return result;
26262
26653
  if (meta[SERVER_INFO_META_KEY] !== void 0) return result;
26263
26654
  return {
26264
26655
  ...result,
@@ -26362,7 +26753,7 @@ function getNotificationSchema2026(method) {
26362
26753
  }
26363
26754
  var rev2026RequestMethods = Object.keys(requestMethodKeys);
26364
26755
  var rev2026NotificationMethods = Object.keys(notificationMethodKeys);
26365
- function isPlainObject$2(value) {
26756
+ function isPlainObject$3(value) {
26366
26757
  return value !== null && typeof value === "object" && !Array.isArray(value);
26367
26758
  }
26368
26759
  function triState(schema, raw) {
@@ -26396,14 +26787,14 @@ function enforceDeletedFields(method, result) {
26396
26787
  return next;
26397
26788
  };
26398
26789
  const tools = result.tools;
26399
- if (method === "tools/list" && Array.isArray(tools) && tools.some((tool) => isPlainObject$2(tool) && "execution" in tool)) copy().tools = tools.map((tool) => {
26400
- if (!isPlainObject$2(tool) || !("execution" in tool)) return tool;
26790
+ if (method === "tools/list" && Array.isArray(tools) && tools.some((tool) => isPlainObject$3(tool) && "execution" in tool)) copy().tools = tools.map((tool) => {
26791
+ if (!isPlainObject$3(tool) || !("execution" in tool)) return tool;
26401
26792
  const rest = { ...tool };
26402
26793
  delete rest["execution"];
26403
26794
  return rest;
26404
26795
  });
26405
26796
  const capabilities = result.capabilities;
26406
- if (isPlainObject$2(capabilities) && "tasks" in capabilities) {
26797
+ if (isPlainObject$3(capabilities) && "tasks" in capabilities) {
26407
26798
  const rest = { ...capabilities };
26408
26799
  delete rest["tasks"];
26409
26800
  copy().capabilities = rest;
@@ -26450,7 +26841,7 @@ var rev2026Codec = {
26450
26841
  projectCallToolResult: (result) => appendTextFallbackForNonObject(result),
26451
26842
  inputRequestSchema: getInputRequestSchema2026,
26452
26843
  decodeResult(method, raw) {
26453
- if (!isPlainObject$2(raw)) return {
26844
+ if (!isPlainObject$3(raw)) return {
26454
26845
  kind: "invalid",
26455
26846
  error: new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${method}: not an object`, { method })
26456
26847
  };
@@ -26471,8 +26862,10 @@ var rev2026Codec = {
26471
26862
  };
26472
26863
  if (rawResultType === "input_required") {
26473
26864
  const rawInputRequests = raw["inputRequests"];
26474
- const inputRequests = isPlainObject$2(rawInputRequests) ? rawInputRequests : {};
26865
+ const inputRequests = isPlainObject$3(rawInputRequests) ? rawInputRequests : {};
26475
26866
  const requestState = raw["requestState"];
26867
+ const metaParse = raw["_meta"] === void 0 ? void 0 : buildSchemas2026().ResultMetaSchema.safeParse(raw["_meta"]);
26868
+ const meta = metaParse?.success ? metaParse.data : void 0;
26476
26869
  if (Object.keys(inputRequests).length === 0 && typeof requestState !== "string") return {
26477
26870
  kind: "invalid",
26478
26871
  error: new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${method}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`, {
@@ -26483,7 +26876,8 @@ var rev2026Codec = {
26483
26876
  return {
26484
26877
  kind: "input_required",
26485
26878
  inputRequests,
26486
- ...typeof requestState === "string" && { requestState }
26879
+ ...typeof requestState === "string" && { requestState },
26880
+ ...meta !== void 0 && { _meta: meta }
26487
26881
  };
26488
26882
  }
26489
26883
  if (rawResultType !== "complete") return {
@@ -26550,6 +26944,9 @@ function isSpecRequestMethod(method) {
26550
26944
  function isSpecNotificationMethod(method) {
26551
26945
  return ALL_CODECS.some((codec) => codec.hasNotificationMethod(method));
26552
26946
  }
26947
+ function isExtensionReusedRequestMethod(method) {
26948
+ return method === "tasks/get" || method === "tasks/cancel";
26949
+ }
26553
26950
  var ALL_CODECS = [rev2025Codec, rev2026Codec];
26554
26951
  var schemas_exports = /* @__PURE__ */ __exportAll({
26555
26952
  AnnotationsSchema: () => AnnotationsSchema,
@@ -26921,7 +27318,7 @@ var INBOUND_VALIDATION_LADDER = [
26921
27318
  evaluatedAt: "pre-dispatch",
26922
27319
  codes: [HEADER_MISMATCH_ERROR_CODE],
26923
27320
  conformance: ["http-header-validation"],
26924
- rationale: "SEP-2243 standard `Mcp-Method` / `Mcp-Name` headers \u2014 presence, sentinel decoding, and `Mcp-Name` \u2194 body cross-check \u2014 are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The classifier\u2019s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5\u20136) are consulted."
27321
+ rationale: "SEP-2243 standard `MCP-Protocol-Version` / `Mcp-Method` / `Mcp-Name` headers \u2014 presence, sentinel decoding, and `Mcp-Name` \u2194 body cross-check \u2014 are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The spec requires `MCP-Protocol-Version` and `Mcp-Method` on every modern *request* POST (`Mcp-Name` only for the methods that mirror `params.name` / `params.uri` / `params.taskId`, see `MCP_NAME_HEADER_SOURCE`) and names them in that order, so a request missing several is answered by the earliest. Notification POSTs are exempt: the presence half runs on requests only, so a modern-enveloped notification is dispatched even with no standard headers at all. The classifier\u2019s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half \u2014 including the missing `MCP-Protocol-Version` cell, which cannot live on the edge rung without breaking body-primary classification. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5\u20136) are consulted."
26925
27322
  },
26926
27323
  {
26927
27324
  rung: "client-capabilities",
@@ -26948,6 +27345,26 @@ var LADDER_ERROR_HTTP_STATUS = {
26948
27345
  [ProtocolErrorCode.MissingRequiredClientCapability]: 400,
26949
27346
  [HEADER_MISMATCH_ERROR_CODE]: 400
26950
27347
  };
27348
+ var MCP_NAME_HEADER_SOURCE = {
27349
+ "tools/call": "name",
27350
+ "prompts/get": "name",
27351
+ "resources/read": "uri",
27352
+ "tasks/get": "taskId",
27353
+ "tasks/update": "taskId",
27354
+ "tasks/cancel": "taskId"
27355
+ };
27356
+ function mcpNameSource(method, params) {
27357
+ const field = Object.hasOwn(MCP_NAME_HEADER_SOURCE, method) ? MCP_NAME_HEADER_SOURCE[method] : void 0;
27358
+ if (field === void 0) return;
27359
+ const raw = isPlainObject$2(params) ? params[field] : void 0;
27360
+ return {
27361
+ field,
27362
+ value: typeof raw === "string" ? raw : void 0
27363
+ };
27364
+ }
27365
+ function isPlainObject$2(value) {
27366
+ return value !== null && typeof value === "object" && !Array.isArray(value);
27367
+ }
26951
27368
  function parseSchema(schema, data) {
26952
27369
  return z2.safeParse(schema, data);
26953
27370
  }
@@ -27568,6 +27985,8 @@ var Protocol = class {
27568
27985
  _transport;
27569
27986
  _requestMessageId = 0;
27570
27987
  _requestHandlers = /* @__PURE__ */ new Map();
27988
+ /** Methods registered with an explicit schema; the era gate in `_onrequest` reads it for the Tasks extension names. */
27989
+ _customSchemaRequestMethods = /* @__PURE__ */ new Set();
27571
27990
  _requestHandlerAbortControllers = /* @__PURE__ */ new Map();
27572
27991
  _notificationHandlers = /* @__PURE__ */ new Map();
27573
27992
  _responseHandlers = /* @__PURE__ */ new Map();
@@ -27704,7 +28123,7 @@ var Protocol = class {
27704
28123
  return this._requestHandlers.get(method);
27705
28124
  }
27706
28125
  async _oncancel(notification) {
27707
- if (!notification.params.requestId) return;
28126
+ if (notification.params.requestId === void 0) return;
27708
28127
  this._requestHandlerAbortControllers.get(notification.params.requestId)?.abort(notification.params.reason);
27709
28128
  }
27710
28129
  _setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
@@ -27851,7 +28270,7 @@ var Protocol = class {
27851
28270
  return;
27852
28271
  }
27853
28272
  }
27854
- if (isSpecRequestMethod(request.method) && !codec.hasRequestMethod(request.method)) {
28273
+ if (isSpecRequestMethod(request.method) && !codec.hasRequestMethod(request.method) && !(isExtensionReusedRequestMethod(request.method) && this._customSchemaRequestMethods.has(request.method))) {
27855
28274
  sendErrorResponse(ProtocolErrorCode.MethodNotFound, "Method not found");
27856
28275
  return;
27857
28276
  }
@@ -27984,8 +28403,11 @@ var Protocol = class {
27984
28403
  }
27985
28404
  request(request, schemaOrOptions, maybeOptions) {
27986
28405
  const codec = this._resolveOutboundCodec(request.method);
28406
+ if (isStandardSchema(schemaOrOptions)) {
28407
+ if (!isExtensionReusedRequestMethod(request.method)) this._assertOutboundRequestInEra(codec, request.method);
28408
+ return this._requestWithSchemaViaCodec(codec, request, schemaOrOptions, maybeOptions);
28409
+ }
27987
28410
  this._assertOutboundRequestInEra(codec, request.method);
27988
- if (isStandardSchema(schemaOrOptions)) return this._requestWithSchemaViaCodec(codec, request, schemaOrOptions, maybeOptions);
27989
28411
  const validate = codecResultValidator(codec, request.method);
27990
28412
  if (validate === void 0) throw new TypeError(`'${request.method}' is not a spec method; pass a result schema as the second argument to request().`);
27991
28413
  return this._requestWithSchemaViaCodec(codec, request, validate, schemaOrOptions);
@@ -28103,19 +28525,20 @@ var Protocol = class {
28103
28525
  const cancel = (reason) => {
28104
28526
  if (responseReceived) return;
28105
28527
  this._progressHandlers.delete(messageId);
28106
- if (requestAbort === void 0) this._transport?.send(this._envelopeOutbound({
28107
- jsonrpc: "2.0",
28108
- method: "notifications/cancelled",
28109
- params: {
28110
- requestId: messageId,
28111
- reason: String(reason)
28112
- }
28113
- }), {
28114
- relatedRequestId,
28115
- resumptionToken,
28116
- onresumptiontoken
28117
- }).catch((error) => this._onerror(/* @__PURE__ */ new Error(`Failed to send cancellation: ${error}`)));
28118
- else requestAbort.abort();
28528
+ if (requestAbort === void 0) {
28529
+ if (request.method !== "initialize") this._transport?.send(this._envelopeOutbound({
28530
+ jsonrpc: "2.0",
28531
+ method: "notifications/cancelled",
28532
+ params: {
28533
+ requestId: messageId,
28534
+ reason: String(reason)
28535
+ }
28536
+ }), {
28537
+ relatedRequestId,
28538
+ resumptionToken,
28539
+ onresumptiontoken
28540
+ }).catch((error) => this._onerror(/* @__PURE__ */ new Error(`Failed to send cancellation: ${error}`)));
28541
+ } else requestAbort.abort();
28119
28542
  reject(reason instanceof SdkError ? reason : new SdkError(SdkErrorCode.RequestTimeout, String(reason)));
28120
28543
  };
28121
28544
  this._responseHandlers.set(messageId, (response) => {
@@ -28177,7 +28600,7 @@ var Protocol = class {
28177
28600
  * Emits a notification, which is a one-way message that does not expect a response.
28178
28601
  */
28179
28602
  async notification(notification, options) {
28180
- return this._notificationViaCodec(this._resolveOutboundCodec(notification.method), notification, options);
28603
+ return await this._notificationViaCodec(this._resolveOutboundCodec(notification.method), notification, options);
28181
28604
  }
28182
28605
  /**
28183
28606
  * The notification funnel proper, keyed by the resolved era codec —
@@ -28195,7 +28618,7 @@ var Protocol = class {
28195
28618
  jsonrpc: "2.0",
28196
28619
  ...notification
28197
28620
  });
28198
- if ((this._options?.debouncedNotificationMethods ?? []).includes(notification.method) && !notification.params && !options?.relatedRequestId) {
28621
+ if ((this._options?.debouncedNotificationMethods ?? []).includes(notification.method) && !notification.params && options?.relatedRequestId === void 0) {
28199
28622
  if (this._pendingDebouncedNotifications.has(notification.method)) return;
28200
28623
  this._pendingDebouncedNotifications.add(notification.method);
28201
28624
  Promise.resolve().then(() => {
@@ -28228,6 +28651,8 @@ var Protocol = class {
28228
28651
  return maybeHandler(parsed.data, ctx);
28229
28652
  };
28230
28653
  else throw new TypeError("setRequestHandler: handler is required");
28654
+ if (typeof schemasOrHandler === "function") this._customSchemaRequestMethods.delete(method);
28655
+ else this._customSchemaRequestMethods.add(method);
28231
28656
  this._requestHandlers.set(method, this._wrapHandler(method, stored));
28232
28657
  }
28233
28658
  /**
@@ -28257,6 +28682,7 @@ var Protocol = class {
28257
28682
  */
28258
28683
  removeRequestHandler(method) {
28259
28684
  this._requestHandlers.delete(method);
28685
+ this._customSchemaRequestMethods.delete(method);
28260
28686
  }
28261
28687
  /**
28262
28688
  * Asserts that a request handler has not already been set for the given method, in preparation for a new one being automatically installed.
@@ -28407,7 +28833,8 @@ function manualInputRequiredValue(decoded) {
28407
28833
  return {
28408
28834
  resultType: "input_required",
28409
28835
  inputRequests: decoded.inputRequests,
28410
- ...decoded.requestState !== void 0 && { requestState: decoded.requestState }
28836
+ ...decoded.requestState !== void 0 && { requestState: decoded.requestState },
28837
+ ...decoded._meta !== void 0 && { _meta: decoded._meta }
28411
28838
  };
28412
28839
  }
28413
28840
  var require_content_type = /* @__PURE__ */ __commonJSMin(((exports) => {
@@ -28524,8 +28951,69 @@ function createFetchWithInit(baseFetch = fetch, baseInit) {
28524
28951
  });
28525
28952
  };
28526
28953
  }
28954
+ var REDIRECT_STATUSES = /* @__PURE__ */ new Set([
28955
+ 301,
28956
+ 302,
28957
+ 303,
28958
+ 307,
28959
+ 308
28960
+ ]);
28961
+ var MAX_REDIRECTS = 5;
28962
+ function isWithinOrigin(from, to) {
28963
+ if (from.protocol === to.protocol && from.host === to.host) return true;
28964
+ return from.protocol === "http:" && to.protocol === "https:" && from.hostname === to.hostname && !from.port && !to.port;
28965
+ }
28966
+ function redirectTarget(url3, response) {
28967
+ const location = REDIRECT_STATUSES.has(response.status) ? response.headers?.get("location") : void 0;
28968
+ if (!location) return void 0;
28969
+ try {
28970
+ return new URL(location, url3);
28971
+ } catch {
28972
+ return;
28973
+ }
28974
+ }
28975
+ var leftToFetch = /* @__PURE__ */ new WeakSet();
28976
+ function fetchLeavingRedirects(baseFetch) {
28977
+ const copy = (url3, init) => baseFetch(url3, init);
28978
+ leftToFetch.add(copy);
28979
+ return copy;
28980
+ }
28981
+ function fetchWithinOrigin(baseFetch) {
28982
+ if (leftToFetch.has(baseFetch)) return baseFetch;
28983
+ return async (url3, init) => {
28984
+ if (init?.redirect === "error" || init?.redirect === "manual") return baseFetch(url3, init);
28985
+ const method = (init?.method ?? "GET").toUpperCase();
28986
+ let current = url3;
28987
+ for (let followed = 0; ; followed++) {
28988
+ const response = await baseFetch(current, {
28989
+ ...init,
28990
+ redirect: "manual"
28991
+ });
28992
+ const target = redirectTarget(current, response);
28993
+ if (!target || followed === MAX_REDIRECTS) return response;
28994
+ const from = new URL(current);
28995
+ const keepsMethod = method === "GET" || response.status === 307 || response.status === 308;
28996
+ const keepsUserinfo = !(target.username || target.password) || target.username === from.username && target.password === from.password;
28997
+ if (!keepsMethod || !keepsUserinfo || !isWithinOrigin(from, target)) return response;
28998
+ await response.text?.().catch(() => {
28999
+ });
29000
+ current = target;
29001
+ }
29002
+ };
29003
+ }
29004
+ function unfollowedRedirect(url3, response) {
29005
+ if (response.type === "opaqueredirect") return "Redirect not followed: this runtime does not expose where it points";
29006
+ const target = redirectTarget(response.url || url3, response);
29007
+ if (!target) return void 0;
29008
+ target.username = target.password = target.search = target.hash = "";
29009
+ if (target.protocol === "http:" && new URL(response.url || url3).protocol === "https:") {
29010
+ target.protocol = "https:";
29011
+ return `Redirect from https to plain http not followed; try ${target.href} as the endpoint`;
29012
+ }
29013
+ return `Redirect to ${target.href} not followed; use that URL as the endpoint if it is the intended server`;
29014
+ }
28527
29015
 
28528
- // ../node_modules/.bun/@modelcontextprotocol+client@2.0.0/node_modules/@modelcontextprotocol/client/dist/ajvProvider-97rDpkRx.mjs
29016
+ // ../node_modules/.bun/@modelcontextprotocol+client@2.3.0/node_modules/@modelcontextprotocol/client/dist/ajvProvider-97rDpkRx.mjs
28529
29017
  var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
28530
29018
  Object.defineProperty(exports, "__esModule", { value: true });
28531
29019
  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;
@@ -35535,7 +36023,7 @@ var AjvJsonSchemaValidator = class {
35535
36023
  };
35536
36024
  var Ajv = import_ajv.Ajv;
35537
36025
 
35538
- // ../node_modules/.bun/@modelcontextprotocol+client@2.0.0/node_modules/@modelcontextprotocol/client/dist/shimsNode.mjs
36026
+ // ../node_modules/.bun/@modelcontextprotocol+client@2.3.0/node_modules/@modelcontextprotocol/client/dist/shimsNode.mjs
35539
36027
  var CORS_IS_POSSIBLE = false;
35540
36028
 
35541
36029
  // ../node_modules/.bun/pkce-challenge@5.0.1/node_modules/pkce-challenge/dist/index.node.js
@@ -36079,7 +36567,7 @@ var EventSourceParserStream = class extends TransformStream {
36079
36567
  }
36080
36568
  };
36081
36569
 
36082
- // ../node_modules/.bun/@modelcontextprotocol+client@2.0.0/node_modules/@modelcontextprotocol/client/dist/index.mjs
36570
+ // ../node_modules/.bun/@modelcontextprotocol+client@2.3.0/node_modules/@modelcontextprotocol/client/dist/index.mjs
36083
36571
  var OAuthClientFlowError = class extends Error {
36084
36572
  static {
36085
36573
  Object.defineProperty(this, "mcpBrand", { value: "mcp.OAuthClientFlowError" });
@@ -36147,7 +36635,7 @@ var InsecureTokenEndpointError = class extends OAuthClientFlowError {
36147
36635
  /** The token endpoint URL that was rejected. */
36148
36636
  tokenEndpoint;
36149
36637
  constructor(tokenEndpoint) {
36150
- super(`Refusing to send credentials to non-https token endpoint '${tokenEndpoint}'. OAuth token requests MUST use TLS (localhost / 127.0.0.1 / ::1 are exempt).`);
36638
+ super(`Refusing to send credentials to non-https token endpoint '${tokenEndpoint}'. OAuth token requests MUST use TLS (localhost / *.localhost / 127.0.0.1 / ::1 are exempt).`);
36151
36639
  this.tokenEndpoint = tokenEndpoint;
36152
36640
  }
36153
36641
  };
@@ -36156,7 +36644,7 @@ var AuthorizationServerMismatchError = class extends OAuthClientFlowError {
36156
36644
  Object.defineProperty(this, "mcpBrand", { value: "mcp.AuthorizationServerMismatchError" });
36157
36645
  }
36158
36646
  constructor(recordedIssuer, currentIssuer) {
36159
- super(`Authorization server changed between redirect and callback (redirected to ${JSON.stringify(recordedIssuer)}, callback resolved ${JSON.stringify(currentIssuer)}); refusing to send authorization_code/code_verifier to a different token endpoint`);
36647
+ super(`Authorization server mismatch: credentials are bound to ${JSON.stringify(recordedIssuer)} but this call resolved ${JSON.stringify(currentIssuer)}; refusing to present them to a different authorization server`);
36160
36648
  this.recordedIssuer = recordedIssuer;
36161
36649
  this.currentIssuer = currentIssuer;
36162
36650
  }
@@ -36179,10 +36667,13 @@ var InsufficientScopeError = class extends OAuthClientFlowError {
36179
36667
  }
36180
36668
  };
36181
36669
  function discardIfIssuerMismatch(stored, issuer, opts) {
36182
- if (stored === void 0) return void 0;
36183
- if (stored.issuer === void 0) {
36670
+ if (!stored) return void 0;
36671
+ if (typeof stored.issuer !== "string") {
36184
36672
  if (opts?.canPersistStamp !== false) console.warn("[mcp-sdk] SEP-2352: stored OAuth credential has no 'issuer' stamp (pre-upgrade storage or provider not round-tripping the value). SEP-2352 isolation is inactive for this read; ensure your provider round-trips the issuer field.");
36185
- return stored;
36673
+ return stored.issuer === void 0 ? stored : {
36674
+ ...stored,
36675
+ issuer: void 0
36676
+ };
36186
36677
  }
36187
36678
  return issuersMatch(stored.issuer, issuer) ? stored : void 0;
36188
36679
  }
@@ -36337,7 +36828,7 @@ function applyPublicAuth(clientId, params) {
36337
36828
  params.set("client_id", clientId);
36338
36829
  }
36339
36830
  function isLoopbackHost(hostname) {
36340
- return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]" || hostname === "::1";
36831
+ return hostname === "localhost" || hostname.endsWith(".localhost") || hostname === "127.0.0.1" || hostname === "[::1]" || hostname === "::1";
36341
36832
  }
36342
36833
  function assertSecureTokenEndpoint(tokenEndpoint) {
36343
36834
  const url3 = new URL(String(tokenEndpoint));
@@ -36376,16 +36867,22 @@ async function parseErrorResponse(input) {
36376
36867
  return new OAuthError(OAuthErrorCode.ServerError, errorMessage);
36377
36868
  }
36378
36869
  }
36870
+ function warnCredentialInvalidation(provider, error, invalidated) {
36871
+ const action = provider.invalidateCredentials === void 0 ? `retrying authorization without discarding the stored ${invalidated} (provider implements no invalidateCredentials())` : `invalidating the stored ${invalidated} and retrying authorization`;
36872
+ console.warn(`[mcp-sdk] OAuth ${JSON.stringify(error.code)} \u2014 ${action}. Cause: ${JSON.stringify(error.message)}`);
36873
+ }
36379
36874
  async function auth(provider, options) {
36380
36875
  try {
36381
36876
  return await authInternal(provider, options);
36382
36877
  } catch (error) {
36383
36878
  if (error instanceof OAuthError) {
36384
36879
  if (error.code === OAuthErrorCode.InvalidClient || error.code === OAuthErrorCode.UnauthorizedClient) {
36880
+ warnCredentialInvalidation(provider, error, "client credentials and tokens");
36385
36881
  await provider.invalidateCredentials?.("client");
36386
36882
  await provider.invalidateCredentials?.("tokens");
36387
36883
  return await authInternal(provider, options);
36388
- } else if (error.code === OAuthErrorCode.InvalidGrant) {
36884
+ } else if (error.code === OAuthErrorCode.InvalidGrant || error.code === OAuthErrorCode.InvalidDpopProof) {
36885
+ warnCredentialInvalidation(provider, error, "tokens");
36389
36886
  await provider.invalidateCredentials?.("tokens");
36390
36887
  return await authInternal(provider, options);
36391
36888
  }
@@ -36453,8 +36950,9 @@ async function authInternal(provider, { serverUrl, authorizationCode, iss, scope
36453
36950
  } else if (!issuersMatch(recordedIssuer, issuer)) throw new AuthorizationServerMismatchError(recordedIssuer, issuer);
36454
36951
  }
36455
36952
  if (freshDiscoveryState) await provider.saveDiscoveryState?.(freshDiscoveryState);
36456
- const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
36457
- if (resource) await provider.saveResourceUrl?.(String(resource));
36953
+ const selectedResource = await selectResourceURL(serverUrl, provider, resourceMetadata);
36954
+ const resource = selectedResource && resourceMetadata && !provider.validateResourceURL ? resourceMetadata.resource : selectedResource;
36955
+ if (resource) await provider.saveResourceUrl?.(resourceIndicatorToString(resource));
36458
36956
  const resolvedScope = determineScope({
36459
36957
  requestedScope: scope,
36460
36958
  resourceMetadata,
@@ -36525,24 +37023,30 @@ async function authInternal(provider, { serverUrl, authorizationCode, iss, scope
36525
37023
  };
36526
37024
  await provider.saveTokens(tokens, infoCtx);
36527
37025
  }
36528
- if (tokens?.refresh_token && !forceReauthorization) try {
36529
- const newTokens = await refreshAuthorization(authorizationServerUrl, {
36530
- metadata,
36531
- clientInformation,
36532
- refreshToken: tokens.refresh_token,
36533
- resource,
36534
- addClientAuthentication: provider.addClientAuthentication,
36535
- fetchFn
36536
- });
36537
- await provider.saveTokens({
36538
- ...newTokens,
36539
- issuer
36540
- }, infoCtx);
36541
- return "AUTHORIZED";
36542
- } catch (error) {
36543
- if (error instanceof InsecureTokenEndpointError) throw error;
36544
- if (!(error instanceof OAuthError) || error.code === OAuthErrorCode.ServerError) {
36545
- } else throw error;
37026
+ if (tokens?.refresh_token && !forceReauthorization) {
37027
+ let newTokens;
37028
+ try {
37029
+ newTokens = await refreshAuthorization(authorizationServerUrl, {
37030
+ metadata,
37031
+ clientInformation,
37032
+ refreshToken: tokens.refresh_token,
37033
+ resource,
37034
+ addClientAuthentication: provider.addClientAuthentication,
37035
+ dpop: await provider.dpop?.(),
37036
+ fetchFn
37037
+ });
37038
+ } catch (error) {
37039
+ if (error instanceof InsecureTokenEndpointError) throw error;
37040
+ if (!(error instanceof OAuthError) || error.code === OAuthErrorCode.ServerError) console.warn(`[mcp-sdk] Could not refresh OAuth tokens; falling back to a new authorization request. Cause: ${JSON.stringify(error instanceof Error ? error.message : String(error))}`);
37041
+ else throw error;
37042
+ }
37043
+ if (newTokens) {
37044
+ await provider.saveTokens({
37045
+ ...newTokens,
37046
+ issuer
37047
+ }, infoCtx);
37048
+ return "AUTHORIZED";
37049
+ }
36546
37050
  }
36547
37051
  const state = provider.state ? await provider.state() : void 0;
36548
37052
  const { authorizationUrl, codeVerifier } = await startAuthorization(authorizationServerUrl, {
@@ -36576,11 +37080,12 @@ async function selectResourceURL(serverUrl, provider, resourceMetadata) {
36576
37080
  })) throw new Error(`Protected resource ${resourceMetadata.resource} does not match expected ${defaultResource} (or origin)`);
36577
37081
  return new URL(resourceMetadata.resource);
36578
37082
  }
37083
+ var RECOGNIZED_CHALLENGE_SCHEMES = /* @__PURE__ */ new Set(["bearer", "dpop"]);
36579
37084
  function extractWWWAuthenticateParams(res) {
36580
37085
  const authenticateHeader = res.headers.get("WWW-Authenticate");
36581
37086
  if (!authenticateHeader) return {};
36582
37087
  const [type, scheme] = authenticateHeader.split(" ");
36583
- if (type?.toLowerCase() !== "bearer" || !scheme) return {};
37088
+ if (!type || !RECOGNIZED_CHALLENGE_SCHEMES.has(type.toLowerCase()) || !scheme) return {};
36584
37089
  const resourceMetadataMatch = extractFieldFromWwwAuth(res, "resource_metadata") || void 0;
36585
37090
  let resourceMetadataUrl;
36586
37091
  if (resourceMetadataMatch) try {
@@ -36626,12 +37131,13 @@ async function discoverOAuthProtectedResourceMetadata(serverUrl, opts, fetchFn =
36626
37131
  return OAuthProtectedResourceMetadataSchema.parse(await response.json());
36627
37132
  }
36628
37133
  async function fetchWithCorsRetry(url3, headers, fetchFn = fetch) {
37134
+ const withinOrigin = fetchWithinOrigin(fetchFn);
36629
37135
  try {
36630
- return await fetchFn(url3, { headers });
37136
+ return await withinOrigin(url3, { headers });
36631
37137
  } catch (error) {
36632
37138
  if (!(error instanceof TypeError) || !CORS_IS_POSSIBLE) throw error;
36633
37139
  if (headers) try {
36634
- return await fetchFn(url3, {});
37140
+ return await withinOrigin(url3, {});
36635
37141
  } catch (retryError) {
36636
37142
  if (!(retryError instanceof TypeError)) throw retryError;
36637
37143
  return;
@@ -36649,7 +37155,7 @@ async function tryMetadataDiscovery(url3, protocolVersion, fetchFn = fetch) {
36649
37155
  function shouldAttemptFallback(response, pathname) {
36650
37156
  if (!response) return true;
36651
37157
  if (pathname === "/") return false;
36652
- return response.status >= 400 && response.status < 500 || response.status === 502;
37158
+ return !response.ok && response.status < 500 || response.status === 502;
36653
37159
  }
36654
37160
  async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {
36655
37161
  const issuer = new URL(serverUrl);
@@ -36706,7 +37212,7 @@ async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fet
36706
37212
  if (!response.ok) {
36707
37213
  await response.text?.().catch(() => {
36708
37214
  });
36709
- if (response.status >= 400 && response.status < 500 || response.status === 502) continue;
37215
+ if (response.status < 500 || response.status === 502) continue;
36710
37216
  throw new Error(`HTTP ${response.status} trying to load ${type === "oauth" ? "OAuth" : "OpenID provider"} metadata from ${endpointUrl}`);
36711
37217
  }
36712
37218
  const parsed = type === "oauth" ? OAuthMetadataSchema.parse(await response.json()) : OpenIdProviderDiscoveryMetadataSchema.parse(await response.json());
@@ -36737,6 +37243,9 @@ async function discoverOAuthServerInfo(serverUrl, opts) {
36737
37243
  resourceMetadata
36738
37244
  };
36739
37245
  }
37246
+ function resourceIndicatorToString(resource) {
37247
+ return typeof resource === "string" ? resource : resource.href;
37248
+ }
36740
37249
  async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource }) {
36741
37250
  let authorizationUrl;
36742
37251
  if (metadata) {
@@ -36755,7 +37264,7 @@ async function startAuthorization(authorizationServerUrl, { metadata, clientInfo
36755
37264
  if (state) authorizationUrl.searchParams.set("state", state);
36756
37265
  if (scope) authorizationUrl.searchParams.set("scope", scope);
36757
37266
  if (scope?.split(" ").includes("offline_access")) authorizationUrl.searchParams.append("prompt", "consent");
36758
- if (resource) authorizationUrl.searchParams.set("resource", resource.href);
37267
+ if (resource) authorizationUrl.searchParams.set("resource", resourceIndicatorToString(resource));
36759
37268
  return {
36760
37269
  authorizationUrl,
36761
37270
  codeVerifier
@@ -36769,30 +37278,46 @@ function prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, redire
36769
37278
  redirect_uri: String(redirectUri)
36770
37279
  });
36771
37280
  }
36772
- async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequestParams, clientInformation, addClientAuthentication, resource, fetchFn }) {
37281
+ async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequestParams, clientInformation, addClientAuthentication, resource, dpop, fetchFn }) {
36773
37282
  const tokenUrl = assertSecureTokenEndpoint(metadata?.token_endpoint ?? new URL("/token", authorizationServerUrl));
36774
37283
  const headers = new Headers({
36775
37284
  "Content-Type": "application/x-www-form-urlencoded",
36776
37285
  Accept: "application/json"
36777
37286
  });
36778
- if (resource) tokenRequestParams.set("resource", resource.href);
36779
- if (addClientAuthentication) await addClientAuthentication(headers, tokenRequestParams, tokenUrl, metadata);
36780
- else if (clientInformation) applyClientAuthentication(selectClientAuthMethod(clientInformation, metadata?.token_endpoint_auth_methods_supported ?? []), clientInformation, headers, tokenRequestParams);
36781
- const response = await (fetchFn ?? fetch)(tokenUrl, {
36782
- method: "POST",
36783
- headers,
36784
- body: tokenRequestParams
36785
- });
37287
+ if (resource) tokenRequestParams.set("resource", resourceIndicatorToString(resource));
37288
+ if (!addClientAuthentication && clientInformation) applyClientAuthentication(selectClientAuthMethod(clientInformation, metadata?.token_endpoint_auth_methods_supported ?? []), clientInformation, headers, tokenRequestParams);
37289
+ const requestOnce = async () => {
37290
+ const requestHeaders = new Headers(headers);
37291
+ if (addClientAuthentication) await addClientAuthentication(requestHeaders, tokenRequestParams, tokenUrl, metadata);
37292
+ if (dpop) requestHeaders.set("DPoP", await dpop.buildProof({
37293
+ htm: "POST",
37294
+ htu: tokenUrl
37295
+ }));
37296
+ return fetchWithinOrigin(fetchFn ?? fetch)(tokenUrl, {
37297
+ method: "POST",
37298
+ headers: requestHeaders,
37299
+ body: tokenRequestParams
37300
+ });
37301
+ };
37302
+ let response = await requestOnce();
37303
+ if (dpop && response.status === 400) {
37304
+ if ((await response.clone().json().catch(() => {
37305
+ }))?.error === OAuthErrorCode.UseDpopNonce) {
37306
+ dpop.observeNonce(response, tokenUrl);
37307
+ response = await requestOnce();
37308
+ }
37309
+ }
37310
+ dpop?.observeNonce(response, tokenUrl);
36786
37311
  if (!response.ok) throw await parseErrorResponse(response);
36787
37312
  const json = await response.json();
36788
37313
  try {
36789
- return OAuthTokensSchema.parse(json);
37314
+ return OAuthTokensSchema.parse(withoutIssuer(json));
36790
37315
  } catch (parseError) {
36791
37316
  if (typeof json === "object" && json !== null && "error" in json) throw await parseErrorResponse(JSON.stringify(json));
36792
37317
  throw parseError;
36793
37318
  }
36794
37319
  }
36795
- async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, addClientAuthentication, fetchFn }) {
37320
+ async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, addClientAuthentication, dpop, fetchFn }) {
36796
37321
  return {
36797
37322
  refresh_token: refreshToken,
36798
37323
  ...await executeTokenRequest(authorizationServerUrl, {
@@ -36804,6 +37329,7 @@ async function refreshAuthorization(authorizationServerUrl, { metadata, clientIn
36804
37329
  clientInformation,
36805
37330
  addClientAuthentication,
36806
37331
  resource,
37332
+ dpop,
36807
37333
  fetchFn
36808
37334
  })
36809
37335
  };
@@ -36814,6 +37340,14 @@ async function fetchToken(provider, authorizationServerUrl, { metadata, resource
36814
37340
  expectedIssuer: metadata?.issuer,
36815
37341
  issParameterSupported: isIssParameterSupported(metadata)
36816
37342
  });
37343
+ const issuer = metadata?.issuer ?? String(authorizationServerUrl);
37344
+ const readClientInformation = async () => {
37345
+ const rawClientInfo = await provider.clientInformation({ issuer });
37346
+ const checked = discardIfIssuerMismatch(rawClientInfo, issuer, { canPersistStamp: false });
37347
+ if (rawClientInfo && checked === void 0) throw new AuthorizationServerMismatchError(String(rawClientInfo.issuer), issuer);
37348
+ return checked;
37349
+ };
37350
+ let clientInformation = await readClientInformation();
36817
37351
  const effectiveScope = scope ?? provider.clientMetadata.scope;
36818
37352
  let tokenRequestParams;
36819
37353
  if (provider.prepareTokenRequest) tokenRequestParams = await provider.prepareTokenRequest(effectiveScope);
@@ -36822,13 +37356,14 @@ async function fetchToken(provider, authorizationServerUrl, { metadata, resource
36822
37356
  if (!provider.redirectUrl) throw new Error("redirectUrl is required for authorization_code flow");
36823
37357
  tokenRequestParams = prepareAuthorizationCodeRequest(authorizationCode, await provider.codeVerifier(), provider.redirectUrl);
36824
37358
  }
36825
- const clientInformation = await provider.clientInformation({ issuer: metadata?.issuer ?? String(authorizationServerUrl) });
37359
+ clientInformation ??= await readClientInformation();
36826
37360
  return executeTokenRequest(authorizationServerUrl, {
36827
37361
  metadata,
36828
37362
  tokenRequestParams,
36829
- clientInformation: clientInformation ?? void 0,
37363
+ clientInformation,
36830
37364
  addClientAuthentication: provider.addClientAuthentication,
36831
37365
  resource,
37366
+ dpop: await provider.dpop?.(),
36832
37367
  fetchFn
36833
37368
  });
36834
37369
  }
@@ -36842,7 +37377,7 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
36842
37377
  ...clientMetadata,
36843
37378
  ...scope === void 0 ? {} : { scope }
36844
37379
  };
36845
- const response = await (fetchFn ?? fetch)(registrationUrl, {
37380
+ const response = await fetchWithinOrigin(fetchFn ?? fetch)(registrationUrl, {
36846
37381
  method: "POST",
36847
37382
  headers: { "Content-Type": "application/json" },
36848
37383
  body: JSON.stringify(submittedMetadata)
@@ -36852,7 +37387,7 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
36852
37387
  body: await response.text(),
36853
37388
  submittedMetadata
36854
37389
  });
36855
- return OAuthClientInformationFullSchema.parse(await response.json());
37390
+ return OAuthClientInformationFullSchema.parse(withoutIssuer(await response.json()));
36856
37391
  }
36857
37392
  var CAP_EXEMPT_METHODS = /* @__PURE__ */ new Set([
36858
37393
  "tools/list",
@@ -37347,6 +37882,11 @@ function classifyProbeOutcome(outcome, context) {
37347
37882
  return classifyHttpError(outcome, context);
37348
37883
  case "network-error":
37349
37884
  return classifyNetworkError(outcome.error, context);
37885
+ case "unusable-reply":
37886
+ return {
37887
+ kind: "error",
37888
+ error: new SdkError(SdkErrorCode.EraNegotiationFailed, `Version negotiation probe failed: the server answered with an unusable reply (${describeError(outcome.error)})`, { cause: outcome.error }, { cause: outcome.error })
37889
+ };
37350
37890
  case "auth-required":
37351
37891
  return {
37352
37892
  kind: "error",
@@ -37438,7 +37978,7 @@ function classifyNetworkError(error, context) {
37438
37978
  if (context.environment === "browser" && isOpaqueFetchTypeError(error)) return { kind: "legacy" };
37439
37979
  return {
37440
37980
  kind: "error",
37441
- error: new SdkError(SdkErrorCode.EraNegotiationFailed, `Version negotiation probe failed: ${describeError(error)}`, { cause: error })
37981
+ error: new SdkError(SdkErrorCode.EraNegotiationFailed, `Version negotiation probe failed: ${describeError(error)}`, { cause: error }, { cause: error })
37442
37982
  };
37443
37983
  }
37444
37984
  function isOpaqueFetchTypeError(error) {
@@ -37637,6 +38177,10 @@ function buildProbeRequest(id, protocolVersion, clientInfo, capabilities) {
37637
38177
  }) }
37638
38178
  };
37639
38179
  }
38180
+ function isUnusableReplyError(error) {
38181
+ if (error instanceof SdkError && error.code === SdkErrorCode.ClientHttpUnexpectedContent) return true;
38182
+ return error instanceof Error && error.name === "SyntaxError";
38183
+ }
37640
38184
  function normalizeReply(reply, timeoutMs) {
37641
38185
  switch (reply.kind) {
37642
38186
  case "response":
@@ -37662,6 +38206,10 @@ function normalizeReply(reply, timeoutMs) {
37662
38206
  statusText: error.data.statusText
37663
38207
  };
37664
38208
  }
38209
+ if (isUnusableReplyError(error)) return {
38210
+ kind: "unusable-reply",
38211
+ error
38212
+ };
37665
38213
  return {
37666
38214
  kind: "network-error",
37667
38215
  error
@@ -38472,7 +39020,7 @@ var Client = class extends Protocol {
38472
39020
  }, options);
38473
39021
  const hit = await this._serveFromCache("prompts/list", void 0, options);
38474
39022
  if (hit !== void 0) return hit;
38475
- return this._listAllPages("prompts/list", params, options, (acc, page2) => acc.prompts.push(...page2.prompts));
39023
+ return this._listAllPages("prompts/list", params, options, (r) => r.prompts);
38476
39024
  }
38477
39025
  /**
38478
39026
  * Lists available resources.
@@ -38511,7 +39059,7 @@ var Client = class extends Protocol {
38511
39059
  }, options);
38512
39060
  const hit = await this._serveFromCache("resources/list", void 0, options);
38513
39061
  if (hit !== void 0) return hit;
38514
- return this._listAllPages("resources/list", params, options, (acc, page2) => acc.resources.push(...page2.resources));
39062
+ return this._listAllPages("resources/list", params, options, (r) => r.resources);
38515
39063
  }
38516
39064
  /**
38517
39065
  * Lists available resource URI templates for dynamic resources.
@@ -38536,7 +39084,7 @@ var Client = class extends Protocol {
38536
39084
  }, options);
38537
39085
  const hit = await this._serveFromCache("resources/templates/list", void 0, options);
38538
39086
  if (hit !== void 0) return hit;
38539
- return this._listAllPages("resources/templates/list", params, options, (acc, page2) => acc.resourceTemplates.push(...page2.resourceTemplates));
39087
+ return this._listAllPages("resources/templates/list", params, options, (r) => r.resourceTemplates);
38540
39088
  }
38541
39089
  /**
38542
39090
  * Walk every page of a paginated list verb, aggregate, and write ONE
@@ -38544,8 +39092,7 @@ var Client = class extends Protocol {
38544
39092
  * methods' no-`cursor` auto-aggregate path. Page 1's result object is
38545
39093
  * mutated in place (its items array is extended; `nextCursor` is
38546
39094
  * cleared); page-1 metadata (`ttlMs`, `cacheScope`, `_meta`) is preserved.
38547
- * A `nextCursor` that repeats stops the walk (defence against a
38548
- * non-converging server, mcp.d's `drainList` guard);
39095
+ * A page with the same items and `nextCursor` as the previous page ends the walk;
38549
39096
  * {@linkcode ClientOptions.listMaxPages} is a hard cap — hitting it
38550
39097
  * throws, so a partial aggregate is never cached. The
38551
39098
  * captured-generation guard skips the write when a `list_changed` landed
@@ -38560,7 +39107,7 @@ var Client = class extends Protocol {
38560
39107
  * trace context) supplied to the public `list*()` reaches every wire
38561
39108
  * request the walk issues.
38562
39109
  */
38563
- async _listAllPages(method, baseParams, options, append, finalize) {
39110
+ async _listAllPages(method, baseParams, options, items, finalize) {
38564
39111
  const bypass = options?.cacheMode === "bypass";
38565
39112
  const generation = this._cache.captureGeneration(method);
38566
39113
  const acc = await this.request({
@@ -38568,14 +39115,13 @@ var Client = class extends Protocol {
38568
39115
  ...baseParams && { params: { ...baseParams } }
38569
39116
  }, options);
38570
39117
  let cursor = acc.nextCursor;
38571
- const seen = /* @__PURE__ */ new Set();
39118
+ let previous = acc;
38572
39119
  let pages = 1;
38573
- while (cursor !== void 0 && !seen.has(cursor)) {
39120
+ while (cursor !== void 0) {
38574
39121
  if (this._listMaxPages !== 0 && pages >= this._listMaxPages) throw new SdkError(SdkErrorCode.ListPaginationExceeded, `${method}: exceeded listMaxPages (${this._listMaxPages}); server pagination did not terminate`, {
38575
39122
  method,
38576
39123
  listMaxPages: this._listMaxPages
38577
39124
  });
38578
- seen.add(cursor);
38579
39125
  const page2 = await this.request({
38580
39126
  method,
38581
39127
  params: {
@@ -38583,7 +39129,9 @@ var Client = class extends Protocol {
38583
39129
  cursor
38584
39130
  }
38585
39131
  }, options);
38586
- append(acc, page2);
39132
+ if (page2.nextCursor === cursor && JSON.stringify(items(page2)) === JSON.stringify(items(previous))) break;
39133
+ items(acc).push(...items(page2));
39134
+ previous = page2;
38587
39135
  cursor = page2.nextCursor;
38588
39136
  pages++;
38589
39137
  }
@@ -38847,19 +39395,22 @@ var Client = class extends Protocol {
38847
39395
  notifications: filter
38848
39396
  }
38849
39397
  };
39398
+ const routeSendFailure = (error) => {
39399
+ settle({
39400
+ cause: "remote",
39401
+ error: error instanceof Error ? error : new Error(String(error))
39402
+ });
39403
+ };
38850
39404
  try {
38851
- await this.transport.send(jsonrpcRequest, {
39405
+ this.transport.send(jsonrpcRequest, {
38852
39406
  requestSignal: requestAbort.signal,
38853
39407
  onRequestStreamEnd: () => settle({
38854
39408
  cause: "remote",
38855
39409
  error: /* @__PURE__ */ new Error("subscriptions/listen: stream ended")
38856
39410
  })
38857
- });
39411
+ }).catch(routeSendFailure);
38858
39412
  } catch (error) {
38859
- settle({
38860
- cause: "remote",
38861
- error: error instanceof Error ? error : new Error(String(error))
38862
- });
39413
+ routeSendFailure(error);
38863
39414
  }
38864
39415
  return {
38865
39416
  honoredFilter: await opening,
@@ -39111,7 +39662,7 @@ var Client = class extends Protocol {
39111
39662
  }
39112
39663
  const hit = await this._serveFromCache("tools/list", void 0, options);
39113
39664
  if (hit !== void 0) return hit;
39114
- return this._listAllPages("tools/list", params, options, (acc, page2) => acc.tools.push(...page2.tools), (acc) => this._excludeInvalidXMcpHeaderTools(acc));
39665
+ return this._listAllPages("tools/list", params, options, (r) => r.tools, (acc) => this._excludeInvalidXMcpHeaderTools(acc));
39115
39666
  }
39116
39667
  /**
39117
39668
  * SEP-2243 (protocol revision 2026-07-28): a Streamable HTTP client MUST
@@ -39182,6 +39733,63 @@ var Client = class extends Protocol {
39182
39733
  return this.notification({ method: "notifications/roots/list_changed" });
39183
39734
  }
39184
39735
  };
39736
+ function hasDpopChallenge(wwwAuthenticate) {
39737
+ return /(?:^|,)\s*dpop(?:\s|$|,)/i.test(wwwAuthenticate);
39738
+ }
39739
+ function isDpopNonceChallenge(response) {
39740
+ if (response.status !== 401) return false;
39741
+ const wwwAuthenticate = response.headers.get("www-authenticate") ?? "";
39742
+ return hasDpopChallenge(wwwAuthenticate) && /use_dpop_nonce/i.test(wwwAuthenticate);
39743
+ }
39744
+ var withDpop = (session, getToken) => (next) => {
39745
+ const resolveSession = typeof session === "function" ? session : () => session;
39746
+ return async (input, init) => {
39747
+ const method = (init?.method ?? "GET").toUpperCase();
39748
+ const url3 = new URL(input.toString());
39749
+ const activeSession = await resolveSession();
39750
+ if (!activeSession) return next(input, init);
39751
+ const makeRequest = async () => {
39752
+ const accessToken = await getToken();
39753
+ if (!accessToken) return next(input, init);
39754
+ const headers = new Headers(init?.headers);
39755
+ const proof = await activeSession.buildProof({
39756
+ htm: method,
39757
+ htu: url3,
39758
+ accessToken
39759
+ });
39760
+ headers.set("Authorization", `DPoP ${accessToken}`);
39761
+ headers.set("DPoP", proof);
39762
+ return next(input, {
39763
+ ...init,
39764
+ headers
39765
+ });
39766
+ };
39767
+ let response = await makeRequest();
39768
+ if (isDpopNonceChallenge(response) && response.headers.has("dpop-nonce")) {
39769
+ activeSession.observeNonce(response, url3);
39770
+ await response.text?.().catch(() => {
39771
+ });
39772
+ response = await makeRequest();
39773
+ }
39774
+ activeSession.observeNonce(response, url3);
39775
+ return response;
39776
+ };
39777
+ };
39778
+ var withDpopFromProvider = (provider) => withDpop(async () => {
39779
+ try {
39780
+ return await provider.dpop?.();
39781
+ } catch (error) {
39782
+ throw markAuthSeamEscape(error);
39783
+ }
39784
+ }, async () => {
39785
+ let tokens;
39786
+ try {
39787
+ tokens = await provider.tokens();
39788
+ } catch (error) {
39789
+ throw markAuthSeamEscape(error);
39790
+ }
39791
+ return tokens?.token_type?.toLowerCase() === "dpop" ? tokens.access_token : void 0;
39792
+ });
39185
39793
  var SseError = class extends Error {
39186
39794
  static {
39187
39795
  Object.defineProperty(this, "mcpBrand", { value: "mcp.SseError" });
@@ -39223,6 +39831,8 @@ var SSEClientTransport = class {
39223
39831
  _skipIssuerMetadataValidation;
39224
39832
  _fetch;
39225
39833
  _fetchWithInit;
39834
+ _redirectPolicy;
39835
+ _dpop;
39226
39836
  _protocolVersion;
39227
39837
  onclose;
39228
39838
  onerror;
@@ -39234,32 +39844,46 @@ var SSEClientTransport = class {
39234
39844
  this._eventSourceInit = opts?.eventSourceInit;
39235
39845
  this._requestInit = opts?.requestInit;
39236
39846
  this._skipIssuerMetadataValidation = opts?.skipIssuerMetadataValidation;
39847
+ this._fetch = opts?.fetch;
39237
39848
  if (isOAuthClientProvider(opts?.authProvider)) {
39238
39849
  this._oauthProvider = opts.authProvider;
39239
39850
  this._authProvider = adaptOAuthProvider(opts.authProvider, { skipIssuerMetadataValidation: opts.skipIssuerMetadataValidation });
39851
+ if (opts.authProvider.dpop) {
39852
+ this._dpop = withDpopFromProvider(opts.authProvider);
39853
+ this._fetch = this._dpop(opts.fetch ?? fetch);
39854
+ }
39240
39855
  } else this._authProvider = opts?.authProvider;
39241
- this._fetch = opts?.fetch;
39856
+ this._redirectPolicy = opts?.redirectPolicy;
39242
39857
  this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
39858
+ if (this._redirectPolicy === "follow") this._fetchWithInit = fetchLeavingRedirects(this._fetchWithInit);
39243
39859
  }
39244
39860
  _last401Response;
39861
+ _connectAuthRetried = false;
39862
+ /** `baseFetch` with redirects handled as `redirectPolicy` says. */
39863
+ _redirects(baseFetch) {
39864
+ return this._redirectPolicy === "follow" ? baseFetch : fetchWithinOrigin(baseFetch);
39865
+ }
39866
+ /** Error text for a redirect `response` that was not followed, or `undefined` for any other response. */
39867
+ _unfollowedRedirect(url3, response) {
39868
+ const text = this._redirectPolicy === "follow" ? void 0 : unfollowedRedirect(url3, response);
39869
+ return text && `${text} (redirectPolicy: 'same-origin')`;
39870
+ }
39245
39871
  async _commonHeaders() {
39246
- const headers = {};
39872
+ const headers = new Headers(this._requestInit?.headers || void 0);
39247
39873
  let token;
39248
39874
  try {
39249
39875
  token = await this._authProvider?.token();
39250
39876
  } catch (error) {
39251
39877
  throw markAuthSeamEscape(error);
39252
39878
  }
39253
- if (token) headers["Authorization"] = `Bearer ${token}`;
39254
- if (this._protocolVersion) headers["mcp-protocol-version"] = this._protocolVersion;
39255
- const extraHeaders = normalizeHeaders(this._requestInit?.headers);
39256
- return new Headers({
39257
- ...headers,
39258
- ...extraHeaders
39259
- });
39879
+ if (token) headers.set("Authorization", `Bearer ${token}`);
39880
+ if (this._protocolVersion) headers.set("mcp-protocol-version", this._protocolVersion);
39881
+ return headers;
39260
39882
  }
39261
39883
  _startOrAuth() {
39262
- const fetchImpl = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
39884
+ const eventSourceFetch = this._eventSourceInit?.fetch;
39885
+ const fetchImpl = this._redirects(eventSourceFetch ? this._dpop?.(eventSourceFetch) ?? eventSourceFetch : this._fetch ?? fetch);
39886
+ let redirect;
39263
39887
  return new Promise((resolve7, reject) => {
39264
39888
  this._eventSource = new EventSource(this._url.href, {
39265
39889
  ...this._eventSourceInit,
@@ -39270,6 +39894,7 @@ var SSEClientTransport = class {
39270
39894
  ...init,
39271
39895
  headers
39272
39896
  });
39897
+ redirect = this._unfollowedRedirect(url3, response);
39273
39898
  if (response.status === 401) {
39274
39899
  this._last401Response = response;
39275
39900
  if (response.headers.has("www-authenticate")) {
@@ -39284,31 +39909,41 @@ var SSEClientTransport = class {
39284
39909
  this._abortController = new AbortController();
39285
39910
  this._eventSource.onerror = (event) => {
39286
39911
  if (event.code === 401 && this._authProvider) {
39287
- if (this._authProvider.onUnauthorized && this._last401Response) {
39912
+ if (this._authProvider.onUnauthorized && this._last401Response && !this._connectAuthRetried) {
39288
39913
  const response = this._last401Response;
39289
39914
  this._last401Response = void 0;
39915
+ this._connectAuthRetried = true;
39290
39916
  this._eventSource?.close();
39291
39917
  this._authProvider.onUnauthorized({
39292
39918
  response,
39293
39919
  serverUrl: this._url,
39294
39920
  fetchFn: this._fetchWithInit
39295
39921
  }).then(() => this._startOrAuth().then(resolve7, reject), (error$2) => {
39922
+ this._connectAuthRetried = false;
39296
39923
  markAuthSeamEscape(error$2);
39297
39924
  this.onerror?.(error$2);
39298
39925
  reject(error$2);
39299
39926
  });
39300
39927
  return;
39301
39928
  }
39302
- const error$1 = markAuthSeamEscape(new UnauthorizedError());
39929
+ const retried = this._connectAuthRetried;
39930
+ this._connectAuthRetried = false;
39931
+ const error$1 = markAuthSeamEscape(retried ? new SdkHttpError(SdkErrorCode.ClientHttpAuthentication, "Server returned 401 after re-authentication", {
39932
+ status: 401,
39933
+ statusText: this._last401Response?.statusText ?? ""
39934
+ }) : new UnauthorizedError());
39935
+ this._last401Response = void 0;
39303
39936
  reject(error$1);
39304
39937
  this.onerror?.(error$1);
39305
39938
  return;
39306
39939
  }
39307
- const error = new SseError(event.code, event.message, event);
39940
+ this._connectAuthRetried = false;
39941
+ const error = new SseError(event.code, redirect ?? event.message, event);
39308
39942
  reject(error);
39309
39943
  this.onerror?.(error);
39310
39944
  };
39311
39945
  this._eventSource.onopen = () => {
39946
+ this._connectAuthRetried = false;
39312
39947
  };
39313
39948
  this._eventSource.addEventListener("endpoint", (event) => {
39314
39949
  const messageEvent = event;
@@ -39376,7 +40011,7 @@ var SSEClientTransport = class {
39376
40011
  body: JSON.stringify(message),
39377
40012
  signal: this._abortController?.signal
39378
40013
  };
39379
- const response = await (this._fetch ?? fetch)(this._endpoint, init);
40014
+ const response = await this._redirects(this._fetch ?? fetch)(this._endpoint, init);
39380
40015
  if (!response.ok) {
39381
40016
  if (response.status === 401 && this._authProvider) {
39382
40017
  if (response.headers.has("www-authenticate")) {
@@ -39407,7 +40042,7 @@ var SSEClientTransport = class {
39407
40042
  throw markAuthSeamEscape(new UnauthorizedError());
39408
40043
  }
39409
40044
  const text = await response.text?.().catch(() => null);
39410
- throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
40045
+ throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${this._unfollowedRedirect(this._endpoint, response) ?? text}`);
39411
40046
  }
39412
40047
  await response.text?.().catch(() => {
39413
40048
  });
@@ -39429,6 +40064,7 @@ var DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS = {
39429
40064
  };
39430
40065
  var RESERVED_REQUEST_HEADER_NAMES = /* @__PURE__ */ new Set([
39431
40066
  "authorization",
40067
+ "dpop",
39432
40068
  "content-type",
39433
40069
  "mcp-protocol-version",
39434
40070
  "mcp-method",
@@ -39467,6 +40103,7 @@ var StreamableHTTPClientTransport = class {
39467
40103
  _skipIssuerMetadataValidation;
39468
40104
  _fetch;
39469
40105
  _fetchWithInit;
40106
+ _redirectPolicy;
39470
40107
  _sessionId;
39471
40108
  _reconnectionOptions;
39472
40109
  _protocolVersion;
@@ -39491,12 +40128,15 @@ var StreamableHTTPClientTransport = class {
39491
40128
  this._scope = void 0;
39492
40129
  this._requestInit = opts?.requestInit;
39493
40130
  this._skipIssuerMetadataValidation = opts?.skipIssuerMetadataValidation;
40131
+ this._fetch = opts?.fetch;
39494
40132
  if (isOAuthClientProvider(opts?.authProvider)) {
39495
40133
  this._oauthProvider = opts.authProvider;
39496
40134
  this._authProvider = adaptOAuthProvider(opts.authProvider, { skipIssuerMetadataValidation: opts.skipIssuerMetadataValidation });
40135
+ if (opts.authProvider.dpop) this._fetch = withDpopFromProvider(opts.authProvider)(opts.fetch ?? fetch);
39497
40136
  } else this._authProvider = opts?.authProvider;
39498
- this._fetch = opts?.fetch;
40137
+ this._redirectPolicy = opts?.redirectPolicy;
39499
40138
  this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
40139
+ if (this._redirectPolicy === "follow") this._fetchWithInit = fetchLeavingRedirects(this._fetchWithInit);
39500
40140
  this._sessionId = opts?.sessionId;
39501
40141
  this._protocolVersion = opts?.protocolVersion;
39502
40142
  this._reconnectionOptions = opts?.reconnectionOptions ?? DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS;
@@ -39548,22 +40188,27 @@ var StreamableHTTPClientTransport = class {
39548
40188
  skipIssuerMetadataValidation: this._skipIssuerMetadataValidation
39549
40189
  });
39550
40190
  }
40191
+ /** `baseFetch` with redirects handled as `redirectPolicy` says. */
40192
+ _redirects(baseFetch) {
40193
+ return this._redirectPolicy === "follow" ? baseFetch : fetchWithinOrigin(baseFetch);
40194
+ }
40195
+ /** Error text for a redirect `response` that was not followed, or `undefined` for any other response. */
40196
+ _unfollowedRedirect(url3, response) {
40197
+ const text = this._redirectPolicy === "follow" ? void 0 : unfollowedRedirect(url3, response);
40198
+ return text && `${text} (redirectPolicy: 'same-origin')`;
40199
+ }
39551
40200
  async _commonHeaders() {
39552
- const headers = {};
40201
+ const headers = new Headers(this._requestInit?.headers || void 0);
39553
40202
  let token;
39554
40203
  try {
39555
40204
  token = await this._authProvider?.token();
39556
40205
  } catch (error) {
39557
40206
  throw markAuthSeamEscape(error);
39558
40207
  }
39559
- if (token) headers["Authorization"] = `Bearer ${token}`;
39560
- if (this._sessionId) headers["mcp-session-id"] = this._sessionId;
39561
- if (this._protocolVersion) headers["mcp-protocol-version"] = this._protocolVersion;
39562
- const extraHeaders = normalizeHeaders(this._requestInit?.headers);
39563
- return new Headers({
39564
- ...headers,
39565
- ...extraHeaders
39566
- });
40208
+ if (token) headers.set("Authorization", `Bearer ${token}`);
40209
+ if (this._sessionId) headers.set("mcp-session-id", this._sessionId);
40210
+ if (this._protocolVersion) headers.set("mcp-protocol-version", this._protocolVersion);
40211
+ return headers;
39567
40212
  }
39568
40213
  /**
39569
40214
  * Body-derived per-request headers: when an outgoing request carries a
@@ -39579,9 +40224,8 @@ var StreamableHTTPClientTransport = class {
39579
40224
  if (typeof envelopeVersion !== "string") return;
39580
40225
  headers.set("mcp-protocol-version", envelopeVersion);
39581
40226
  headers.set("mcp-method", message.method);
39582
- const params = message.params;
39583
- const nameHeader = message.method === "resources/read" ? typeof params?.uri === "string" ? params.uri : void 0 : typeof params?.name === "string" ? params.name : void 0;
39584
- if (nameHeader !== void 0) headers.set("mcp-name", encodeMcpParamValue(nameHeader));
40227
+ const source = mcpNameSource(message.method, message.params);
40228
+ if (source?.value !== void 0) headers.set("mcp-name", encodeMcpParamValue(source.value));
39585
40229
  }
39586
40230
  /**
39587
40231
  * `true` when the outbound message is a single request carrying a
@@ -39604,7 +40248,7 @@ var StreamableHTTPClientTransport = class {
39604
40248
  if (resumptionToken) headers.set("last-event-id", resumptionToken);
39605
40249
  const transportSignal = this._abortController?.signal;
39606
40250
  const signal = requestSignal !== void 0 && transportSignal !== void 0 ? anySignal(transportSignal, requestSignal) : requestSignal ?? transportSignal;
39607
- const response = await (this._fetch ?? fetch)(this._url, {
40251
+ const response = await this._redirects(this._fetch ?? fetch)(this._url, {
39608
40252
  ...this._requestInit,
39609
40253
  method: "GET",
39610
40254
  headers,
@@ -39659,7 +40303,8 @@ var StreamableHTTPClientTransport = class {
39659
40303
  options.onRequestStreamEnd?.();
39660
40304
  return;
39661
40305
  }
39662
- throw new SdkHttpError(SdkErrorCode.ClientHttpFailedToOpenStream, `Failed to open SSE stream: ${response.statusText}`, {
40306
+ const reason = this._unfollowedRedirect(this._url, response) ?? response.statusText;
40307
+ throw new SdkHttpError(SdkErrorCode.ClientHttpFailedToOpenStream, `Failed to open SSE stream: ${reason}`, {
39663
40308
  status: response.status,
39664
40309
  statusText: response.statusText
39665
40310
  });
@@ -39848,7 +40493,7 @@ var StreamableHTTPClientTransport = class {
39848
40493
  body: JSON.stringify(message),
39849
40494
  signal
39850
40495
  };
39851
- const response = await (this._fetch ?? fetch)(this._url, init);
40496
+ const response = await this._redirects(this._fetch ?? fetch)(this._url, init);
39852
40497
  if (isHandshake && response.ok) this._sessionId = response.headers.get("mcp-session-id") || void 0;
39853
40498
  if (!response.ok) {
39854
40499
  if (response.status === 401 && this._authProvider) {
@@ -39902,7 +40547,8 @@ var StreamableHTTPClientTransport = class {
39902
40547
  }
39903
40548
  } catch {
39904
40549
  }
39905
- throw new SdkHttpError(SdkErrorCode.ClientHttpNotImplemented, `Error POSTing to endpoint: ${text}`, {
40550
+ const reason = this._unfollowedRedirect(this._url, response) ?? text;
40551
+ throw new SdkHttpError(SdkErrorCode.ClientHttpNotImplemented, `Error POSTing to endpoint: ${reason}`, {
39906
40552
  status: response.status,
39907
40553
  statusText: response.statusText,
39908
40554
  text
@@ -39962,10 +40608,10 @@ var StreamableHTTPClientTransport = class {
39962
40608
  headers,
39963
40609
  signal: this._abortController?.signal
39964
40610
  };
39965
- const response = await (this._fetch ?? fetch)(this._url, init);
40611
+ const response = await this._redirects(this._fetch ?? fetch)(this._url, init);
39966
40612
  await response.text?.().catch(() => {
39967
40613
  });
39968
- if (!response.ok && response.status !== 405) throw new SdkHttpError(SdkErrorCode.ClientHttpFailedToTerminateSession, `Failed to terminate session: ${response.statusText}`, {
40614
+ if (!response.ok && response.status !== 405) throw new SdkHttpError(SdkErrorCode.ClientHttpFailedToTerminateSession, `Failed to terminate session: ${this._unfollowedRedirect(this._url, response) ?? response.statusText}`, {
39969
40615
  status: response.status,
39970
40616
  statusText: response.statusText
39971
40617
  });
@@ -39996,27 +40642,33 @@ var StreamableHTTPClientTransport = class {
39996
40642
  }
39997
40643
  };
39998
40644
 
39999
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/server-manager.ts
40645
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/server-manager.ts
40000
40646
  import { mkdirSync as mkdirSync3, statSync as statSync3 } from "fs";
40001
40647
  import { isDeepStrictEqual } from "util";
40002
40648
 
40003
- // ../node_modules/.bun/@modelcontextprotocol+client@2.0.0/node_modules/@modelcontextprotocol/client/dist/stdio.mjs
40649
+ // ../node_modules/.bun/@modelcontextprotocol+client@2.3.0/node_modules/@modelcontextprotocol/client/dist/stdio.mjs
40004
40650
  var import_cross_spawn = __toESM(require_cross_spawn(), 1);
40005
40651
  import process2 from "process";
40006
40652
  import { PassThrough } from "stream";
40007
40653
  var DEFAULT_INHERITED_ENV_VARS = process2.platform === "win32" ? [
40008
40654
  "APPDATA",
40655
+ "COMSPEC",
40009
40656
  "HOMEDRIVE",
40010
40657
  "HOMEPATH",
40011
40658
  "LOCALAPPDATA",
40012
40659
  "PATH",
40660
+ "PATHEXT",
40013
40661
  "PROCESSOR_ARCHITECTURE",
40662
+ "PROGRAMDATA",
40663
+ "PROGRAMFILES",
40664
+ "PROGRAMFILES(X86)",
40665
+ "PROGRAMW6432",
40014
40666
  "SYSTEMDRIVE",
40015
40667
  "SYSTEMROOT",
40016
40668
  "TEMP",
40017
40669
  "USERNAME",
40018
40670
  "USERPROFILE",
40019
- "PROGRAMFILES"
40671
+ "WINDIR"
40020
40672
  ] : [
40021
40673
  "HOME",
40022
40674
  "LOGNAME",
@@ -40206,7 +40858,7 @@ var StdioClientTransport = class {
40206
40858
  }
40207
40859
  };
40208
40860
 
40209
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/unix-socket-transport.ts
40861
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/unix-socket-transport.ts
40210
40862
  import { createConnection } from "net";
40211
40863
  var UnixSocketClientTransport = class {
40212
40864
  constructor(socketPath) {
@@ -40282,7 +40934,7 @@ var UnixSocketClientTransport = class {
40282
40934
  }
40283
40935
  };
40284
40936
 
40285
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-probe.ts
40937
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/mcp-probe.ts
40286
40938
  var PROBE_TIMEOUT_MS = 5e3;
40287
40939
  var MODERN_PROTOCOL_VERSION = "2026-07-28";
40288
40940
  var LEGACY_PROTOCOL_VERSION = "2025-06-18";
@@ -40429,11 +41081,11 @@ async function probeMcpEndpoint(url3) {
40429
41081
  return getOutcome.kind === "mcp" ? getOutcome.result : ambiguousNotMcp(getResponse) ?? ambiguousResult ?? notMcp(getResponse);
40430
41082
  }
40431
41083
 
40432
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/npx-resolver.ts
41084
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/npx-resolver.ts
40433
41085
  import { existsSync as existsSync9, readFileSync as readFileSync2, realpathSync, readdirSync, statSync as statSync2, writeFileSync as writeFileSync3, renameSync, mkdirSync as mkdirSync2, openSync, readSync, closeSync, unlinkSync } from "fs";
40434
41086
  import { join as join16, dirname as dirname8, extname as extname2, resolve as resolve2, sep } from "path";
40435
41087
 
40436
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/abort.ts
41088
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/abort.ts
40437
41089
  function throwIfAborted(signal) {
40438
41090
  if (!signal?.aborted) return;
40439
41091
  throw signal.reason instanceof Error ? signal.reason : new Error(String(signal.reason ?? "MCP request aborted"));
@@ -40468,7 +41120,7 @@ async function abortable(promise, signal) {
40468
41120
  });
40469
41121
  }
40470
41122
 
40471
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/npx-resolver.ts
41123
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/npx-resolver.ts
40472
41124
  var import_cross_spawn2 = __toESM(require_cross_spawn(), 1);
40473
41125
  var CACHE_VERSION = 2;
40474
41126
  var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
@@ -40887,7 +41539,7 @@ function safeStatMtime(path7) {
40887
41539
  }
40888
41540
  }
40889
41541
 
40890
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/json-schema-validator.ts
41542
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/json-schema-validator.ts
40891
41543
  var import_ajv2 = __toESM(require_ajv2(), 1);
40892
41544
  var import__ = __toESM(require__(), 1);
40893
41545
  var import_ajv_formats = __toESM(require_dist2(), 1);
@@ -40941,7 +41593,7 @@ function createJsonSchemaValidator() {
40941
41593
  };
40942
41594
  }
40943
41595
 
40944
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-auth.ts
41596
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/mcp-auth.ts
40945
41597
  import { spawnSync } from "child_process";
40946
41598
  import { createHash as createHash3 } from "crypto";
40947
41599
  import { createRequire } from "module";
@@ -41579,7 +42231,7 @@ function clearTokens(serverName, options) {
41579
42231
  }
41580
42232
  }
41581
42233
 
41582
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-oauth-provider.ts
42234
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/mcp-oauth-provider.ts
41583
42235
  function defaultClientName() {
41584
42236
  const app2 = getAppName();
41585
42237
  return app2 === "pi" ? "Pi Coding Agent" : app2;
@@ -42653,7 +43305,7 @@ defineLazyProperty(apps, "browser", () => "browser");
42653
43305
  defineLazyProperty(apps, "browserPrivate", () => "browserPrivate");
42654
43306
  var open_default = open2;
42655
43307
 
42656
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-callback-server.ts
43308
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/mcp-callback-server.ts
42657
43309
  import { createServer as createServer2 } from "http";
42658
43310
  var PAGE_STYLE = `
42659
43311
  :root { color-scheme: light dark; }
@@ -43029,7 +43681,7 @@ function stopCallbackServerIfIdle() {
43029
43681
  return operation;
43030
43682
  }
43031
43683
 
43032
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/runtime-owner.ts
43684
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/runtime-owner.ts
43033
43685
  function createMcpRuntimeOwner() {
43034
43686
  const controller = new AbortController();
43035
43687
  const cleanups = [];
@@ -43104,7 +43756,7 @@ function isAbortError(error, signal) {
43104
43756
  return error instanceof Error && (error.name === "AbortError" || error.message === "MCP extension runtime stopped");
43105
43757
  }
43106
43758
 
43107
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-auth-flow.ts
43759
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/mcp-auth-flow.ts
43108
43760
  function applyOAuthConfig(discovery, config) {
43109
43761
  return {
43110
43762
  ...discovery,
@@ -43375,8 +44027,8 @@ async function startAuth(serverName, serverUrl, definition, options = {}) {
43375
44027
  if (existingPendingAuth?.serverUrl === serverUrl) {
43376
44028
  return { authorizationUrl: existingPendingAuth.authorizationUrl };
43377
44029
  }
43378
- const redirectTarget = config.redirectUri !== void 0 ? parseOAuthRedirectUri(config.redirectUri) : void 0;
43379
- const manualRedirect = redirectTarget?.mode === "manual";
44030
+ const redirectTarget2 = config.redirectUri !== void 0 ? parseOAuthRedirectUri(config.redirectUri) : void 0;
44031
+ const manualRedirect = redirectTarget2?.mode === "manual";
43380
44032
  const oauthState = generateState();
43381
44033
  if (!manualRedirect) {
43382
44034
  try {
@@ -43384,7 +44036,7 @@ async function startAuth(serverName, serverUrl, definition, options = {}) {
43384
44036
  strictPort: Boolean(config.clientId) || config.redirectUri !== void 0,
43385
44037
  oauthState,
43386
44038
  reserveState: true,
43387
- ...redirectTarget?.mode === "local" ? { port: redirectTarget.port, callbackHost: redirectTarget.callbackHost, callbackPath: redirectTarget.callbackPath } : {}
44039
+ ...redirectTarget2?.mode === "local" ? { port: redirectTarget2.port, callbackHost: redirectTarget2.callbackHost, callbackPath: redirectTarget2.callbackPath } : {}
43388
44040
  });
43389
44041
  throwIfAborted(signal);
43390
44042
  } catch (error) {
@@ -43816,7 +44468,7 @@ async function shutdownOAuth(runtime = legacyRuntime) {
43816
44468
  }
43817
44469
  }
43818
44470
 
43819
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-bearer-store.ts
44471
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/mcp-bearer-store.ts
43820
44472
  import { createHash as createHash4 } from "crypto";
43821
44473
  import { createRequire as createRequire2 } from "module";
43822
44474
  import { dirname as dirname10, join as join18 } from "path";
@@ -44054,7 +44706,7 @@ function inspectBearerTokenForUrl(serverName, serverUrl) {
44054
44706
  }
44055
44707
  }
44056
44708
 
44057
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/sampling-handler.ts
44709
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/sampling-handler.ts
44058
44710
  import { complete } from "@earendil-works/pi-ai/compat";
44059
44711
  function registerSamplingHandler(client, options) {
44060
44712
  client.setRequestHandler("sampling/createMessage", (request) => {
@@ -44270,7 +44922,7 @@ function zeroUsage() {
44270
44922
  };
44271
44923
  }
44272
44924
 
44273
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/elicitation-handler.ts
44925
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/elicitation-handler.ts
44274
44926
  function registerElicitationHandler(client, options) {
44275
44927
  client.setRequestHandler("elicitation/create", (request) => handleElicitationRequest(options, request));
44276
44928
  }
@@ -44532,7 +45184,7 @@ function humanizeName(name) {
44532
45184
  return name.replace(/[_-]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/^./, (char) => char.toUpperCase());
44533
45185
  }
44534
45186
 
44535
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-trace.ts
45187
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/mcp-trace.ts
44536
45188
  import { appendFile as appendFile3, mkdir as mkdir14, writeFile as writeFile6 } from "fs/promises";
44537
45189
  import { Buffer as Buffer3 } from "buffer";
44538
45190
  import { dirname as dirname11, isAbsolute as isAbsolute2, resolve as resolve3 } from "path";
@@ -44735,7 +45387,7 @@ function traceTransportKind(definition, transport) {
44735
45387
  return definition.url ? "streamable-http" : "unknown";
44736
45388
  }
44737
45389
 
44738
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/request-headers-command.ts
45390
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/request-headers-command.ts
44739
45391
  import { spawn as spawn3, spawnSync as spawnSync2 } from "child_process";
44740
45392
  import { randomUUID as randomUUID4 } from "crypto";
44741
45393
  var DEFAULT_TIMEOUT_MS = 1e4;
@@ -45010,7 +45662,7 @@ function createRequestHeadersCommandFetch(config, delegate = globalThis.fetch) {
45010
45662
  };
45011
45663
  }
45012
45664
 
45013
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/server-manager.ts
45665
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/server-manager.ts
45014
45666
  var MAX_CAPTURED_STDERR_BYTES = 8 * 1024;
45015
45667
  var MAX_CAPTURED_STDERR_LINES = 3;
45016
45668
  var abortCleanupPromises = /* @__PURE__ */ new WeakMap();
@@ -46209,7 +46861,7 @@ function normalizeRequestTimeoutMs(timeoutMs) {
46209
46861
  return typeof timeoutMs === "number" && Number.isFinite(timeoutMs) && timeoutMs > 0 ? timeoutMs : void 0;
46210
46862
  }
46211
46863
 
46212
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/session-recovery.ts
46864
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/session-recovery.ts
46213
46865
  var CONNECTION_CLOSED_PROTOCOL_CODE = -32e3;
46214
46866
  var SERVER_NOT_INITIALIZED_MCP_MESSAGES = /* @__PURE__ */ new Set([
46215
46867
  "Server not initialized",
@@ -46285,7 +46937,7 @@ async function withSessionRecovery(deps, serverName, fn) {
46285
46937
  }
46286
46938
  }
46287
46939
 
46288
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/lifecycle.ts
46940
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/lifecycle.ts
46289
46941
  var KEEP_ALIVE_RETRY_BASE_MS = 3e4;
46290
46942
  var KEEP_ALIVE_RETRY_MAX_MS = 5 * 6e4;
46291
46943
  var KEEP_ALIVE_CHECK_CONCURRENCY = 10;
@@ -46641,7 +47293,7 @@ function shouldReconnectAfterRefresh(error, hadSessionId) {
46641
47293
  return error instanceof SdkError && (error.code === SdkErrorCode.NotConnected || error.code === SdkErrorCode.ConnectionClosed);
46642
47294
  }
46643
47295
 
46644
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/tool-metadata.ts
47296
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/tool-metadata.ts
46645
47297
  function buildToolMetadata(tools, resources, definition, serverName, prefix, configuredServers, knownMetadata, includeMissingConfiguredCandidates = false) {
46646
47298
  const metadata = [];
46647
47299
  const failedTools = [];
@@ -46875,7 +47527,7 @@ function appendSchemaAnnotations(parts, schema) {
46875
47527
  }
46876
47528
  }
46877
47529
 
46878
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/ui-resource-handler.ts
47530
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/ui-resource-handler.ts
46879
47531
  var UiResourceHandler = class {
46880
47532
  constructor(manager, config = void 0) {
46881
47533
  this.manager = manager;
@@ -47077,7 +47729,7 @@ function isRecord3(value) {
47077
47729
  return typeof value === "object" && value !== null && !Array.isArray(value);
47078
47730
  }
47079
47731
 
47080
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/failure-backoff.ts
47732
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/failure-backoff.ts
47081
47733
  var FAILURE_BACKOFF_MS = 60 * 1e3;
47082
47734
  function getFailureAgeSeconds(state, serverName) {
47083
47735
  const failedAt = state.failureTracker.get(serverName);
@@ -47095,7 +47747,7 @@ function isServerInActiveFailureBackoff(state, serverName) {
47095
47747
  return connection?.status !== "connected" && connection?.status !== "needs-auth" && getFailureAgeSeconds(state, serverName) !== null;
47096
47748
  }
47097
47749
 
47098
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-status.ts
47750
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/mcp-status.ts
47099
47751
  function createMcpStatusSnapshot(state) {
47100
47752
  const servers = [];
47101
47753
  let totalTools = 0;
@@ -47170,7 +47822,7 @@ function publishMcpStatusShutdown(events) {
47170
47822
  }
47171
47823
  }
47172
47824
 
47173
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/init.ts
47825
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/init.ts
47174
47826
  var MAX_FAILURE_MESSAGE_CHARS = 8 * 1024;
47175
47827
  var failureExpiryTimers = /* @__PURE__ */ new WeakMap();
47176
47828
  function getFailureExpiryTimers(state) {
@@ -47732,7 +48384,7 @@ function getEffectiveIdleTimeoutMinutes(state, serverName) {
47732
48384
  return typeof state.config.settings?.idleTimeout === "number" ? state.config.settings.idleTimeout : 10;
47733
48385
  }
47734
48386
 
47735
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/onboarding-state.ts
48387
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/onboarding-state.ts
47736
48388
  import { existsSync as existsSync12, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync4, renameSync as renameSync2 } from "fs";
47737
48389
  import { dirname as dirname12 } from "path";
47738
48390
  var DEFAULT_STATE = {
@@ -47793,7 +48445,7 @@ function markSetupCompleted(fingerprint) {
47793
48445
  });
47794
48446
  }
47795
48447
 
47796
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/commands.ts
48448
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/commands.ts
47797
48449
  function terminalHyperlink(label, url3) {
47798
48450
  return `\x1B]8;;${sanitizeTerminalText(url3)}\x1B\\${sanitizeTerminalText(label)}\x1B]8;;\x1B\\`;
47799
48451
  }
@@ -48161,7 +48813,7 @@ async function openMcpSetup(state, pi, ctx, configOverridePath, mode = "setup",
48161
48813
  }
48162
48814
  const discovery = getMcpDiscoverySummary(configOverridePath, ctx.cwd, options);
48163
48815
  const onboardingState = loadOnboardingState();
48164
- const { createMcpSetupPanel } = await import("./mcp-setup-panel-RG6Z4BOM.js");
48816
+ const { createMcpSetupPanel } = await import("./mcp-setup-panel-7NV26F37.js");
48165
48817
  let configChanged = false;
48166
48818
  const callbacks = {
48167
48819
  previewImports: (imports) => previewCompatibilityImports(imports, configOverridePath),
@@ -48288,7 +48940,7 @@ async function openMcpPanel(state, pi, ctx, configOverridePath, onDirectToolsCon
48288
48940
  const { lines: noticeLines, fingerprint } = buildSharedConfigNoticeLines(configPath, ctx.cwd);
48289
48941
  let overlayHandle;
48290
48942
  const callbacks = buildMcpPanelCallbacks(state, config, ctx, () => overlayHandle);
48291
- const { createMcpPanel } = await import("./mcp-panel-2XMW56WJ.js");
48943
+ const { createMcpPanel } = await import("./mcp-panel-H3TDJYHQ.js");
48292
48944
  let configChanged = false;
48293
48945
  await new Promise((resolve7) => {
48294
48946
  ctx.ui.custom(
@@ -48360,7 +49012,7 @@ async function openMcpAuthPanel(state, pi, ctx, configOverridePath) {
48360
49012
  const provenanceMap = getServerProvenance(configPath, ctx.cwd);
48361
49013
  let overlayHandle;
48362
49014
  const callbacks = buildMcpPanelCallbacks(state, config, ctx, () => overlayHandle);
48363
- const { createMcpPanel } = await import("./mcp-panel-2XMW56WJ.js");
49015
+ const { createMcpPanel } = await import("./mcp-panel-H3TDJYHQ.js");
48364
49016
  await new Promise((resolve7) => {
48365
49017
  ctx.ui.custom(
48366
49018
  (tui, _theme, keybindings, done) => {
@@ -48385,7 +49037,7 @@ async function openMcpAuthPanel(state, pi, ctx, configOverridePath) {
48385
49037
  return { configChanged: false };
48386
49038
  }
48387
49039
 
48388
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/tool-registrar.ts
49040
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/tool-registrar.ts
48389
49041
  import { mkdtempSync, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "fs";
48390
49042
  import { tmpdir } from "os";
48391
49043
  import { join as join19 } from "path";
@@ -48588,7 +49240,7 @@ function stringifyStructuredContent(value) {
48588
49240
  }
48589
49241
  }
48590
49242
 
48591
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-output-guard.ts
49243
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/mcp-output-guard.ts
48592
49244
  import { randomBytes as randomBytes3 } from "crypto";
48593
49245
  import { mkdtemp, rm as rm5, writeFile as writeFile7 } from "fs/promises";
48594
49246
  import { tmpdir as tmpdir2 } from "os";
@@ -48948,18 +49600,18 @@ function formatSize(bytes) {
48948
49600
  return `${(bytes / (1024 * 1024)).toFixed(1)} MiB`;
48949
49601
  }
48950
49602
 
48951
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/ui-session.ts
49603
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/ui-session.ts
48952
49604
  import { execFile as execFile6 } from "child_process";
48953
49605
  import { randomUUID as randomUUID7 } from "crypto";
48954
49606
  import net from "net";
48955
49607
 
48956
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/ui-server.ts
49608
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/ui-server.ts
48957
49609
  import http2 from "http";
48958
49610
  import fs7 from "fs/promises";
48959
49611
  import path6 from "path";
48960
49612
  import { randomUUID as randomUUID6 } from "crypto";
48961
49613
 
48962
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/host-html-template.ts
49614
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/host-html-template.ts
48963
49615
  var DEFAULT_APP_BRIDGE_MODULE_URL = "/app-bridge.bundle.js";
48964
49616
  var APP_SANDBOX = "allow-scripts allow-forms allow-modals allow-popups allow-downloads";
48965
49617
  var APP_PROXY_SANDBOX = `${APP_SANDBOX} allow-same-origin`;
@@ -49427,7 +50079,7 @@ function escapeHtml2(value) {
49427
50079
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
49428
50080
  }
49429
50081
 
49430
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/sandbox-proxy-template.ts
50082
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/sandbox-proxy-template.ts
49431
50083
  var SANDBOX_PROXY_SANDBOX = "allow-scripts allow-forms allow-modals allow-popups allow-downloads allow-same-origin";
49432
50084
  var SANDBOX_INNER_SANDBOX = SANDBOX_PROXY_SANDBOX;
49433
50085
  var SANDBOX_PROXY_PATH = "/sandbox";
@@ -49618,7 +50270,7 @@ function safeInlineJSON2(value) {
49618
50270
  return json.replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
49619
50271
  }
49620
50272
 
49621
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/tool-approval.ts
50273
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/tool-approval.ts
49622
50274
  import { createHash as createHash5, randomUUID as randomUUID5 } from "crypto";
49623
50275
  function stableStringify(value) {
49624
50276
  if (value === null || value === void 0 || typeof value !== "object") {
@@ -49754,7 +50406,7 @@ ${preview}`,
49754
50406
  return { ok: false, reason: "denied" };
49755
50407
  }
49756
50408
 
49757
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/ui-server.ts
50409
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/ui-server.ts
49758
50410
  var MAX_BODY_SIZE = 2 * 1024 * 1024;
49759
50411
  var ABANDONED_GRACE_MS = 6e4;
49760
50412
  var WATCHDOG_INTERVAL_MS = 5e3;
@@ -50545,7 +51197,7 @@ function sendText(res, status, text) {
50545
51197
  res.end(text);
50546
51198
  }
50547
51199
 
50548
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/glimpse-ui.ts
51200
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/glimpse-ui.ts
50549
51201
  import { existsSync as existsSync13 } from "fs";
50550
51202
  import { execFileSync as execFileSync2 } from "child_process";
50551
51203
  import { join as join21, dirname as dirname14 } from "path";
@@ -50605,7 +51257,7 @@ async function openGlimpseWindow(html, options) {
50605
51257
  };
50606
51258
  }
50607
51259
 
50608
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/ui-session.ts
51260
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/ui-session.ts
50609
51261
  var activeGlimpseWindow = null;
50610
51262
  function summarizeUiSessionResult(uiSession) {
50611
51263
  if (!uiSession) {
@@ -54207,7 +54859,7 @@ var Delete2 = _Object_({
54207
54859
  });
54208
54860
  var Edit = Union([Insert2, Update2, Delete2]);
54209
54861
 
54210
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/direct-tools.ts
54862
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/direct-tools.ts
54211
54863
  var BUILTIN_NAMES = /* @__PURE__ */ new Set(["read", "bash", "edit", "write", "grep", "find", "ls", "mcp"]);
54212
54864
  var DIRECT_TOOLS_ADVISORY_THRESHOLD = 75;
54213
54865
  function prepareDirectToolArguments(inputSchema, args) {
@@ -54735,7 +55387,7 @@ ${formatSchema(spec.inputSchema)}` : "";
54735
55387
  };
54736
55388
  }
54737
55389
 
54738
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/prompts.ts
55390
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/prompts.ts
54739
55391
  function resolveCachedPrompts(config) {
54740
55392
  const cache2 = loadMetadataCache();
54741
55393
  if (!cache2?.servers) return [];
@@ -54978,10 +55630,10 @@ function buildCommandDescription(metadata) {
54978
55630
  return truncateAtWord(`MCP: ${base}`, 120) || `MCP prompt from ${metadata.serverName}`;
54979
55631
  }
54980
55632
 
54981
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/proxy-modes.ts
55633
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/proxy-modes.ts
54982
55634
  import { createRequire as createRequire4 } from "module";
54983
55635
 
54984
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/ts-shape.ts
55636
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/ts-shape.ts
54985
55637
  var UNSUPPORTED_KEYWORDS = ["if", "then", "else", "allOf", "not", "patternProperties", "additionalProperties"];
54986
55638
  function renderTsShape(inputSchema) {
54987
55639
  try {
@@ -55116,7 +55768,7 @@ function needsParentheses(type) {
55116
55768
  return type.includes(" | ");
55117
55769
  }
55118
55770
 
55119
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/search-ranking.ts
55771
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/search-ranking.ts
55120
55772
  var MIN_STEM_LENGTH = 4;
55121
55773
  var FIELD_WEIGHTS = {
55122
55774
  name: 12,
@@ -55298,7 +55950,7 @@ function rankSuggestions(state, name, limit) {
55298
55950
  return rankToolMatches(state, query2, void 0, false).slice(0, limit).map((match) => match.tool.name);
55299
55951
  }
55300
55952
 
55301
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/proxy-modes.ts
55953
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/proxy-modes.ts
55302
55954
  var require4 = createRequire4(import.meta.url);
55303
55955
  var MAX_REGEX_SEARCH_QUERY_LENGTH = 256;
55304
55956
  var INSTRUCTIONS_PREVIEW_LENGTH = 300;
@@ -56578,7 +57230,7 @@ ${formatSchema(toolMeta.inputSchema)}` : "";
56578
57230
  }
56579
57231
  }
56580
57232
 
56581
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/tool-result-renderer.ts
57233
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/tool-result-renderer.ts
56582
57234
  var plainTheme = { fg: (_name, text) => text };
56583
57235
  var DEFAULT_MAX_CALL_INPUT_CHARS = 1500;
56584
57236
  var DEFAULT_MAX_COMPACT_INPUT_CHARS = 240;
@@ -56902,7 +57554,7 @@ function createMcpToolResultRenderer(renderOptions) {
56902
57554
  return (result, options, theme, context) => renderMcpToolResult(result, options, theme, context, renderOptions);
56903
57555
  }
56904
57556
 
56905
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/error-signal.ts
57557
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/error-signal.ts
56906
57558
  function toolErrorOverride(details) {
56907
57559
  if (details && typeof details === "object" && "error" in details) {
56908
57560
  const code = details.error;
@@ -56919,7 +57571,7 @@ function toolErrorOverride(details) {
56919
57571
  return void 0;
56920
57572
  }
56921
57573
 
56922
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-code.ts
57574
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/mcp-code.ts
56923
57575
  import { formatWithOptions } from "util";
56924
57576
  import { Worker } from "worker_threads";
56925
57577
  var DEFAULT_MCP_SCRIPT_TIMEOUT_MS = 3e4;
@@ -57198,7 +57850,7 @@ async function runMcpScript(state, code, timeoutMs = DEFAULT_MCP_SCRIPT_TIMEOUT_
57198
57850
  };
57199
57851
  }
57200
57852
 
57201
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-references.ts
57853
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/mcp-references.ts
57202
57854
  var ENCODED_NAMESPACE_MARKER = "_mcpns_";
57203
57855
  function namespaceServerPart(serverName) {
57204
57856
  const normalized = serverName.replace(/-/g, "_");
@@ -57220,7 +57872,7 @@ function hasCallableCachedTargets(entry, definition) {
57220
57872
  return entry.tools.length > 0 || definition.exposeResources !== false && (entry.resources?.length ?? 0) > 0;
57221
57873
  }
57222
57874
 
57223
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/namespace-tools.ts
57875
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/namespace-tools.ts
57224
57876
  function namespaceProxyCandidate(config, cache2, envOverride, existingDirectNames, serverName) {
57225
57877
  const definition = config.mcpServers[serverName];
57226
57878
  if (!definition || isServerDisabled(definition)) return null;
@@ -57381,7 +58033,7 @@ function syncNamespaceProxyTools(input) {
57381
58033
  return result;
57382
58034
  }
57383
58035
 
57384
- // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/index.ts
58036
+ // ../node_modules/.bun/pi-mcp-adapter@2.32.1+f2da34192be1730e/node_modules/pi-mcp-adapter/index.ts
57385
58037
  var INIT_WAIT_TIMEOUT_MS = 3e4;
57386
58038
  var INIT_FAILURE_MESSAGE_MAX_CHARS = 1e3;
57387
58039
  var INIT_WAIT_TIMED_OUT = /* @__PURE__ */ Symbol("init-wait-timed-out");
@@ -65292,7 +65944,7 @@ Connection: close\r
65292
65944
  });
65293
65945
  /*! Bundled license information:
65294
65946
 
65295
- @modelcontextprotocol/client/dist/src-D_zzAWoS.mjs:
65947
+ @modelcontextprotocol/client/dist/src-WCy6ifGf.mjs:
65296
65948
  (*!
65297
65949
  * content-type
65298
65950
  * Copyright(c) 2015 Douglas Christopher Wilson