wicked-crew 0.18.14 → 0.18.16

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.
Files changed (123) hide show
  1. package/README.md +1 -1
  2. package/dist/api/chat-jobs.d.ts.map +1 -1
  3. package/dist/api/chat-jobs.js +26 -17
  4. package/dist/api/chat-jobs.js.map +1 -1
  5. package/dist/api/chat-proposals.d.ts.map +1 -1
  6. package/dist/api/chat-proposals.js +4 -2
  7. package/dist/api/chat-proposals.js.map +1 -1
  8. package/dist/api/chat-scope.d.ts +8 -0
  9. package/dist/api/chat-scope.d.ts.map +1 -1
  10. package/dist/api/chat-scope.js +32 -4
  11. package/dist/api/chat-scope.js.map +1 -1
  12. package/dist/api/mcp.d.ts +1 -0
  13. package/dist/api/mcp.d.ts.map +1 -1
  14. package/dist/api/mcp.js +16 -0
  15. package/dist/api/mcp.js.map +1 -1
  16. package/dist/api/needs.d.ts.map +1 -1
  17. package/dist/api/needs.js +19 -8
  18. package/dist/api/needs.js.map +1 -1
  19. package/dist/api/repo-input.d.ts +4 -3
  20. package/dist/api/repo-input.d.ts.map +1 -1
  21. package/dist/api/repo-input.js +7 -1
  22. package/dist/api/repo-input.js.map +1 -1
  23. package/dist/api/routes.d.ts +2 -0
  24. package/dist/api/routes.d.ts.map +1 -1
  25. package/dist/api/routes.js +4 -3
  26. package/dist/api/routes.js.map +1 -1
  27. package/dist/api/system-snapshot.d.ts +3 -0
  28. package/dist/api/system-snapshot.d.ts.map +1 -1
  29. package/dist/api/system-snapshot.js +21 -4
  30. package/dist/api/system-snapshot.js.map +1 -1
  31. package/dist/apps/exec/sources.d.ts.map +1 -1
  32. package/dist/apps/exec/sources.js +7 -1
  33. package/dist/apps/exec/sources.js.map +1 -1
  34. package/dist/apps-server/server/lib/bundle/server.mjs +1854 -1840
  35. package/dist/cli/service.d.ts.map +1 -1
  36. package/dist/cli/service.js +50 -9
  37. package/dist/cli/service.js.map +1 -1
  38. package/dist/learn/scheduler.d.ts +1 -1
  39. package/dist/learn/scheduler.d.ts.map +1 -1
  40. package/dist/learn/scheduler.js +1 -10
  41. package/dist/learn/scheduler.js.map +1 -1
  42. package/dist/mcp/env.d.ts +30 -0
  43. package/dist/mcp/env.d.ts.map +1 -0
  44. package/dist/mcp/env.js +102 -0
  45. package/dist/mcp/env.js.map +1 -0
  46. package/dist/mcp/probe.d.ts +2 -0
  47. package/dist/mcp/probe.d.ts.map +1 -1
  48. package/dist/mcp/probe.js +1 -0
  49. package/dist/mcp/probe.js.map +1 -1
  50. package/dist/mcp/registry-store.d.ts +2 -0
  51. package/dist/mcp/registry-store.d.ts.map +1 -1
  52. package/dist/mcp/registry-store.js.map +1 -1
  53. package/dist/mcp/registry.d.ts.map +1 -1
  54. package/dist/mcp/registry.js +8 -2
  55. package/dist/mcp/registry.js.map +1 -1
  56. package/dist/mcp-inspect/routes.d.ts.map +1 -1
  57. package/dist/mcp-inspect/routes.js +2 -1
  58. package/dist/mcp-inspect/routes.js.map +1 -1
  59. package/dist/schedules/scheduler.d.ts +3 -3
  60. package/dist/schedules/scheduler.d.ts.map +1 -1
  61. package/dist/schedules/scheduler.js +4 -7
  62. package/dist/schedules/scheduler.js.map +1 -1
  63. package/dist/studio/assets/{KnowledgeGraph-DLLuMkm1.js → KnowledgeGraph-Bgo9MFqp.js} +1 -1
  64. package/dist/studio/assets/index-CkosDNYp.css +32 -0
  65. package/dist/studio/assets/{index-Lnm21EpR.js → index-DNAGbMFA.js} +292 -292
  66. package/dist/studio/editors/wicked-apps/editor.json +1 -1
  67. package/dist/studio/editors/wicked-apps/index.html +1 -1
  68. package/dist/studio/editors/wicked-deck/editor.json +1 -1
  69. package/dist/studio/editors/wicked-deck/index.html +1 -1
  70. package/dist/studio/editors/wicked-doc/editor.json +1 -1
  71. package/dist/studio/editors/wicked-doc/index.html +1 -1
  72. package/dist/studio/editors/wicked-insights/editor.json +1 -1
  73. package/dist/studio/editors/wicked-insights/index.html +1 -1
  74. package/dist/studio/editors/wicked-page/editor.json +1 -1
  75. package/dist/studio/editors/wicked-page/index.html +1 -1
  76. package/dist/studio/editors/wicked-video/editor.json +1 -1
  77. package/dist/studio/editors/wicked-video/index.html +1 -1
  78. package/dist/studio/index.html +2 -2
  79. package/dist/studio/testid-inventory.json +10 -4
  80. package/dist/voice/routes.d.ts +16 -0
  81. package/dist/voice/routes.d.ts.map +1 -1
  82. package/dist/voice/routes.js +54 -0
  83. package/dist/voice/routes.js.map +1 -1
  84. package/dist/voice/service.d.ts +1 -1
  85. package/dist/voice/service.d.ts.map +1 -1
  86. package/dist/voice/service.js.map +1 -1
  87. package/dist/voice/tts-manifest.d.ts +37 -0
  88. package/dist/voice/tts-manifest.d.ts.map +1 -0
  89. package/dist/voice/tts-manifest.js +40 -0
  90. package/dist/voice/tts-manifest.js.map +1 -0
  91. package/dist/voice/tts.d.ts +214 -0
  92. package/dist/voice/tts.d.ts.map +1 -0
  93. package/dist/voice/tts.js +821 -0
  94. package/dist/voice/tts.js.map +1 -0
  95. package/dist/workflow-catalog/catalog-data-v2.d.ts.map +1 -1
  96. package/dist/workflow-catalog/catalog-data-v2.js +2 -0
  97. package/dist/workflow-catalog/catalog-data-v2.js.map +1 -1
  98. package/endpoint-manifest.json +64 -1
  99. package/package.json +5 -4
  100. package/voice-locks/darwin-arm64-cp310.txt +107 -0
  101. package/voice-locks/darwin-arm64-cp311.txt +118 -0
  102. package/voice-locks/darwin-arm64-cp312.txt +112 -0
  103. package/voice-locks/darwin-arm64-cp313.txt +112 -0
  104. package/voice-locks/darwin-arm64-cp314.txt +112 -0
  105. package/voice-locks/darwin-arm64-cp39.txt +102 -0
  106. package/voice-locks/darwin-x64-cp310.txt +107 -0
  107. package/voice-locks/darwin-x64-cp311.txt +124 -0
  108. package/voice-locks/darwin-x64-cp312.txt +118 -0
  109. package/voice-locks/darwin-x64-cp313.txt +118 -0
  110. package/voice-locks/darwin-x64-cp39.txt +102 -0
  111. package/voice-locks/linux-arm64-cp310.txt +107 -0
  112. package/voice-locks/linux-arm64-cp311.txt +118 -0
  113. package/voice-locks/linux-arm64-cp312.txt +112 -0
  114. package/voice-locks/linux-arm64-cp313.txt +112 -0
  115. package/voice-locks/linux-arm64-cp314.txt +112 -0
  116. package/voice-locks/linux-arm64-cp39.txt +102 -0
  117. package/voice-locks/linux-x64-cp310.txt +107 -0
  118. package/voice-locks/linux-x64-cp311.txt +118 -0
  119. package/voice-locks/linux-x64-cp312.txt +112 -0
  120. package/voice-locks/linux-x64-cp313.txt +112 -0
  121. package/voice-locks/linux-x64-cp314.txt +112 -0
  122. package/voice-locks/linux-x64-cp39.txt +102 -0
  123. package/dist/studio/assets/index-DsUknIuZ.css +0 -32
@@ -41201,6 +41201,503 @@ var require_graphql2 = __commonJS({
41201
41201
  }
41202
41202
  });
41203
41203
 
41204
+ // ../../node_modules/isexe/windows.js
41205
+ var require_windows = __commonJS({
41206
+ "../../node_modules/isexe/windows.js"(exports, module) {
41207
+ module.exports = isexe;
41208
+ isexe.sync = sync;
41209
+ var fs2 = __require("fs");
41210
+ function checkPathExt(path, options) {
41211
+ var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
41212
+ if (!pathext) {
41213
+ return true;
41214
+ }
41215
+ pathext = pathext.split(";");
41216
+ if (pathext.indexOf("") !== -1) {
41217
+ return true;
41218
+ }
41219
+ for (var i = 0; i < pathext.length; i++) {
41220
+ var p = pathext[i].toLowerCase();
41221
+ if (p && path.substr(-p.length).toLowerCase() === p) {
41222
+ return true;
41223
+ }
41224
+ }
41225
+ return false;
41226
+ }
41227
+ function checkStat(stat, path, options) {
41228
+ if (!stat.isSymbolicLink() && !stat.isFile()) {
41229
+ return false;
41230
+ }
41231
+ return checkPathExt(path, options);
41232
+ }
41233
+ function isexe(path, options, cb) {
41234
+ fs2.stat(path, function(er, stat) {
41235
+ cb(er, er ? false : checkStat(stat, path, options));
41236
+ });
41237
+ }
41238
+ function sync(path, options) {
41239
+ return checkStat(fs2.statSync(path), path, options);
41240
+ }
41241
+ }
41242
+ });
41243
+
41244
+ // ../../node_modules/isexe/mode.js
41245
+ var require_mode = __commonJS({
41246
+ "../../node_modules/isexe/mode.js"(exports, module) {
41247
+ module.exports = isexe;
41248
+ isexe.sync = sync;
41249
+ var fs2 = __require("fs");
41250
+ function isexe(path, options, cb) {
41251
+ fs2.stat(path, function(er, stat) {
41252
+ cb(er, er ? false : checkStat(stat, options));
41253
+ });
41254
+ }
41255
+ function sync(path, options) {
41256
+ return checkStat(fs2.statSync(path), options);
41257
+ }
41258
+ function checkStat(stat, options) {
41259
+ return stat.isFile() && checkMode(stat, options);
41260
+ }
41261
+ function checkMode(stat, options) {
41262
+ var mod = stat.mode;
41263
+ var uid2 = stat.uid;
41264
+ var gid = stat.gid;
41265
+ var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
41266
+ var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
41267
+ var u = parseInt("100", 8);
41268
+ var g = parseInt("010", 8);
41269
+ var o = parseInt("001", 8);
41270
+ var ug = u | g;
41271
+ var ret = mod & o || mod & g && gid === myGid || mod & u && uid2 === myUid || mod & ug && myUid === 0;
41272
+ return ret;
41273
+ }
41274
+ }
41275
+ });
41276
+
41277
+ // ../../node_modules/isexe/index.js
41278
+ var require_isexe = __commonJS({
41279
+ "../../node_modules/isexe/index.js"(exports, module) {
41280
+ var fs2 = __require("fs");
41281
+ var core;
41282
+ if (process.platform === "win32" || global.TESTING_WINDOWS) {
41283
+ core = require_windows();
41284
+ } else {
41285
+ core = require_mode();
41286
+ }
41287
+ module.exports = isexe;
41288
+ isexe.sync = sync;
41289
+ function isexe(path, options, cb) {
41290
+ if (typeof options === "function") {
41291
+ cb = options;
41292
+ options = {};
41293
+ }
41294
+ if (!cb) {
41295
+ if (typeof Promise !== "function") {
41296
+ throw new TypeError("callback not provided");
41297
+ }
41298
+ return new Promise(function(resolve4, reject) {
41299
+ isexe(path, options || {}, function(er, is) {
41300
+ if (er) {
41301
+ reject(er);
41302
+ } else {
41303
+ resolve4(is);
41304
+ }
41305
+ });
41306
+ });
41307
+ }
41308
+ core(path, options || {}, function(er, is) {
41309
+ if (er) {
41310
+ if (er.code === "EACCES" || options && options.ignoreErrors) {
41311
+ er = null;
41312
+ is = false;
41313
+ }
41314
+ }
41315
+ cb(er, is);
41316
+ });
41317
+ }
41318
+ function sync(path, options) {
41319
+ try {
41320
+ return core.sync(path, options || {});
41321
+ } catch (er) {
41322
+ if (options && options.ignoreErrors || er.code === "EACCES") {
41323
+ return false;
41324
+ } else {
41325
+ throw er;
41326
+ }
41327
+ }
41328
+ }
41329
+ }
41330
+ });
41331
+
41332
+ // ../../node_modules/which/which.js
41333
+ var require_which = __commonJS({
41334
+ "../../node_modules/which/which.js"(exports, module) {
41335
+ var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
41336
+ var path = __require("path");
41337
+ var COLON = isWindows ? ";" : ":";
41338
+ var isexe = require_isexe();
41339
+ var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
41340
+ var getPathInfo = (cmd, opt) => {
41341
+ const colon = opt.colon || COLON;
41342
+ const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
41343
+ // windows always checks the cwd first
41344
+ ...isWindows ? [process.cwd()] : [],
41345
+ ...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
41346
+ "").split(colon)
41347
+ ];
41348
+ const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
41349
+ const pathExt = isWindows ? pathExtExe.split(colon) : [""];
41350
+ if (isWindows) {
41351
+ if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
41352
+ pathExt.unshift("");
41353
+ }
41354
+ return {
41355
+ pathEnv,
41356
+ pathExt,
41357
+ pathExtExe
41358
+ };
41359
+ };
41360
+ var which = (cmd, opt, cb) => {
41361
+ if (typeof opt === "function") {
41362
+ cb = opt;
41363
+ opt = {};
41364
+ }
41365
+ if (!opt)
41366
+ opt = {};
41367
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
41368
+ const found = [];
41369
+ const step = (i) => new Promise((resolve4, reject) => {
41370
+ if (i === pathEnv.length)
41371
+ return opt.all && found.length ? resolve4(found) : reject(getNotFoundError(cmd));
41372
+ const ppRaw = pathEnv[i];
41373
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
41374
+ const pCmd = path.join(pathPart, cmd);
41375
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
41376
+ resolve4(subStep(p, i, 0));
41377
+ });
41378
+ const subStep = (p, i, ii) => new Promise((resolve4, reject) => {
41379
+ if (ii === pathExt.length)
41380
+ return resolve4(step(i + 1));
41381
+ const ext = pathExt[ii];
41382
+ isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
41383
+ if (!er && is) {
41384
+ if (opt.all)
41385
+ found.push(p + ext);
41386
+ else
41387
+ return resolve4(p + ext);
41388
+ }
41389
+ return resolve4(subStep(p, i, ii + 1));
41390
+ });
41391
+ });
41392
+ return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
41393
+ };
41394
+ var whichSync = (cmd, opt) => {
41395
+ opt = opt || {};
41396
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
41397
+ const found = [];
41398
+ for (let i = 0; i < pathEnv.length; i++) {
41399
+ const ppRaw = pathEnv[i];
41400
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
41401
+ const pCmd = path.join(pathPart, cmd);
41402
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
41403
+ for (let j = 0; j < pathExt.length; j++) {
41404
+ const cur = p + pathExt[j];
41405
+ try {
41406
+ const is = isexe.sync(cur, { pathExt: pathExtExe });
41407
+ if (is) {
41408
+ if (opt.all)
41409
+ found.push(cur);
41410
+ else
41411
+ return cur;
41412
+ }
41413
+ } catch (ex) {
41414
+ }
41415
+ }
41416
+ }
41417
+ if (opt.all && found.length)
41418
+ return found;
41419
+ if (opt.nothrow)
41420
+ return null;
41421
+ throw getNotFoundError(cmd);
41422
+ };
41423
+ module.exports = which;
41424
+ which.sync = whichSync;
41425
+ }
41426
+ });
41427
+
41428
+ // ../../node_modules/path-key/index.js
41429
+ var require_path_key = __commonJS({
41430
+ "../../node_modules/path-key/index.js"(exports, module) {
41431
+ "use strict";
41432
+ var pathKey = (options = {}) => {
41433
+ const environment = options.env || process.env;
41434
+ const platform = options.platform || process.platform;
41435
+ if (platform !== "win32") {
41436
+ return "PATH";
41437
+ }
41438
+ return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
41439
+ };
41440
+ module.exports = pathKey;
41441
+ module.exports.default = pathKey;
41442
+ }
41443
+ });
41444
+
41445
+ // ../../node_modules/cross-spawn/lib/util/resolveCommand.js
41446
+ var require_resolveCommand = __commonJS({
41447
+ "../../node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
41448
+ "use strict";
41449
+ var path = __require("path");
41450
+ var which = require_which();
41451
+ var getPathKey = require_path_key();
41452
+ function resolveCommandAttempt(parsed, withoutPathExt) {
41453
+ const env = parsed.options.env || process.env;
41454
+ const cwd = process.cwd();
41455
+ const hasCustomCwd = parsed.options.cwd != null;
41456
+ const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
41457
+ if (shouldSwitchCwd) {
41458
+ try {
41459
+ process.chdir(parsed.options.cwd);
41460
+ } catch (err) {
41461
+ }
41462
+ }
41463
+ let resolved;
41464
+ try {
41465
+ resolved = which.sync(parsed.command, {
41466
+ path: env[getPathKey({ env })],
41467
+ pathExt: withoutPathExt ? path.delimiter : void 0
41468
+ });
41469
+ } catch (e) {
41470
+ } finally {
41471
+ if (shouldSwitchCwd) {
41472
+ process.chdir(cwd);
41473
+ }
41474
+ }
41475
+ if (resolved) {
41476
+ resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
41477
+ }
41478
+ return resolved;
41479
+ }
41480
+ function resolveCommand(parsed) {
41481
+ return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
41482
+ }
41483
+ module.exports = resolveCommand;
41484
+ }
41485
+ });
41486
+
41487
+ // ../../node_modules/cross-spawn/lib/util/escape.js
41488
+ var require_escape = __commonJS({
41489
+ "../../node_modules/cross-spawn/lib/util/escape.js"(exports, module) {
41490
+ "use strict";
41491
+ var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
41492
+ function escapeCommand(arg) {
41493
+ arg = arg.replace(metaCharsRegExp, "^$1");
41494
+ return arg;
41495
+ }
41496
+ function escapeArgument(arg, doubleEscapeMetaChars) {
41497
+ arg = `${arg}`;
41498
+ arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
41499
+ arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
41500
+ arg = `"${arg}"`;
41501
+ arg = arg.replace(metaCharsRegExp, "^$1");
41502
+ if (doubleEscapeMetaChars) {
41503
+ arg = arg.replace(metaCharsRegExp, "^$1");
41504
+ }
41505
+ return arg;
41506
+ }
41507
+ module.exports.command = escapeCommand;
41508
+ module.exports.argument = escapeArgument;
41509
+ }
41510
+ });
41511
+
41512
+ // ../../node_modules/shebang-regex/index.js
41513
+ var require_shebang_regex = __commonJS({
41514
+ "../../node_modules/shebang-regex/index.js"(exports, module) {
41515
+ "use strict";
41516
+ module.exports = /^#!(.*)/;
41517
+ }
41518
+ });
41519
+
41520
+ // ../../node_modules/shebang-command/index.js
41521
+ var require_shebang_command = __commonJS({
41522
+ "../../node_modules/shebang-command/index.js"(exports, module) {
41523
+ "use strict";
41524
+ var shebangRegex = require_shebang_regex();
41525
+ module.exports = (string4 = "") => {
41526
+ const match = string4.match(shebangRegex);
41527
+ if (!match) {
41528
+ return null;
41529
+ }
41530
+ const [path, argument] = match[0].replace(/#! ?/, "").split(" ");
41531
+ const binary = path.split("/").pop();
41532
+ if (binary === "env") {
41533
+ return argument;
41534
+ }
41535
+ return argument ? `${binary} ${argument}` : binary;
41536
+ };
41537
+ }
41538
+ });
41539
+
41540
+ // ../../node_modules/cross-spawn/lib/util/readShebang.js
41541
+ var require_readShebang = __commonJS({
41542
+ "../../node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
41543
+ "use strict";
41544
+ var fs2 = __require("fs");
41545
+ var shebangCommand = require_shebang_command();
41546
+ function readShebang(command) {
41547
+ const size2 = 150;
41548
+ const buffer2 = Buffer.alloc(size2);
41549
+ let fd;
41550
+ try {
41551
+ fd = fs2.openSync(command, "r");
41552
+ fs2.readSync(fd, buffer2, 0, size2, 0);
41553
+ fs2.closeSync(fd);
41554
+ } catch (e) {
41555
+ }
41556
+ return shebangCommand(buffer2.toString());
41557
+ }
41558
+ module.exports = readShebang;
41559
+ }
41560
+ });
41561
+
41562
+ // ../../node_modules/cross-spawn/lib/parse.js
41563
+ var require_parse = __commonJS({
41564
+ "../../node_modules/cross-spawn/lib/parse.js"(exports, module) {
41565
+ "use strict";
41566
+ var path = __require("path");
41567
+ var resolveCommand = require_resolveCommand();
41568
+ var escape3 = require_escape();
41569
+ var readShebang = require_readShebang();
41570
+ var isWin = process.platform === "win32";
41571
+ var isExecutableRegExp = /\.(?:com|exe)$/i;
41572
+ var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
41573
+ function detectShebang(parsed) {
41574
+ parsed.file = resolveCommand(parsed);
41575
+ const shebang = parsed.file && readShebang(parsed.file);
41576
+ if (shebang) {
41577
+ parsed.args.unshift(parsed.file);
41578
+ parsed.command = shebang;
41579
+ return resolveCommand(parsed);
41580
+ }
41581
+ return parsed.file;
41582
+ }
41583
+ function parseNonShell(parsed) {
41584
+ if (!isWin) {
41585
+ return parsed;
41586
+ }
41587
+ const commandFile = detectShebang(parsed);
41588
+ const needsShell = !isExecutableRegExp.test(commandFile);
41589
+ if (parsed.options.forceShell || needsShell) {
41590
+ const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
41591
+ parsed.command = path.normalize(parsed.command);
41592
+ parsed.command = escape3.command(parsed.command);
41593
+ parsed.args = parsed.args.map((arg) => escape3.argument(arg, needsDoubleEscapeMetaChars));
41594
+ const shellCommand = [parsed.command].concat(parsed.args).join(" ");
41595
+ parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
41596
+ parsed.command = process.env.comspec || "cmd.exe";
41597
+ parsed.options.windowsVerbatimArguments = true;
41598
+ }
41599
+ return parsed;
41600
+ }
41601
+ function parse10(command, args, options) {
41602
+ if (args && !Array.isArray(args)) {
41603
+ options = args;
41604
+ args = null;
41605
+ }
41606
+ args = args ? args.slice(0) : [];
41607
+ options = Object.assign({}, options);
41608
+ const parsed = {
41609
+ command,
41610
+ args,
41611
+ options,
41612
+ file: void 0,
41613
+ original: {
41614
+ command,
41615
+ args
41616
+ }
41617
+ };
41618
+ return options.shell ? parsed : parseNonShell(parsed);
41619
+ }
41620
+ module.exports = parse10;
41621
+ }
41622
+ });
41623
+
41624
+ // ../../node_modules/cross-spawn/lib/enoent.js
41625
+ var require_enoent = __commonJS({
41626
+ "../../node_modules/cross-spawn/lib/enoent.js"(exports, module) {
41627
+ "use strict";
41628
+ var isWin = process.platform === "win32";
41629
+ function notFoundError(original, syscall) {
41630
+ return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
41631
+ code: "ENOENT",
41632
+ errno: "ENOENT",
41633
+ syscall: `${syscall} ${original.command}`,
41634
+ path: original.command,
41635
+ spawnargs: original.args
41636
+ });
41637
+ }
41638
+ function hookChildProcess(cp, parsed) {
41639
+ if (!isWin) {
41640
+ return;
41641
+ }
41642
+ const originalEmit = cp.emit;
41643
+ cp.emit = function(name, arg1) {
41644
+ if (name === "exit") {
41645
+ const err = verifyENOENT(arg1, parsed);
41646
+ if (err) {
41647
+ return originalEmit.call(cp, "error", err);
41648
+ }
41649
+ }
41650
+ return originalEmit.apply(cp, arguments);
41651
+ };
41652
+ }
41653
+ function verifyENOENT(status, parsed) {
41654
+ if (isWin && status === 1 && !parsed.file) {
41655
+ return notFoundError(parsed.original, "spawn");
41656
+ }
41657
+ return null;
41658
+ }
41659
+ function verifyENOENTSync(status, parsed) {
41660
+ if (isWin && status === 1 && !parsed.file) {
41661
+ return notFoundError(parsed.original, "spawnSync");
41662
+ }
41663
+ return null;
41664
+ }
41665
+ module.exports = {
41666
+ hookChildProcess,
41667
+ verifyENOENT,
41668
+ verifyENOENTSync,
41669
+ notFoundError
41670
+ };
41671
+ }
41672
+ });
41673
+
41674
+ // ../../node_modules/cross-spawn/index.js
41675
+ var require_cross_spawn = __commonJS({
41676
+ "../../node_modules/cross-spawn/index.js"(exports, module) {
41677
+ "use strict";
41678
+ var cp = __require("child_process");
41679
+ var parse10 = require_parse();
41680
+ var enoent = require_enoent();
41681
+ function spawn3(command, args, options) {
41682
+ const parsed = parse10(command, args, options);
41683
+ const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
41684
+ enoent.hookChildProcess(spawned, parsed);
41685
+ return spawned;
41686
+ }
41687
+ function spawnSync(command, args, options) {
41688
+ const parsed = parse10(command, args, options);
41689
+ const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
41690
+ result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
41691
+ return result;
41692
+ }
41693
+ module.exports = spawn3;
41694
+ module.exports.spawn = spawn3;
41695
+ module.exports.sync = spawnSync;
41696
+ module.exports._parse = parse10;
41697
+ module.exports._enoent = enoent;
41698
+ }
41699
+ });
41700
+
41204
41701
  // ../../node_modules/yaml/dist/nodes/identity.js
41205
41702
  var require_identity = __commonJS({
41206
41703
  "../../node_modules/yaml/dist/nodes/identity.js"(exports) {
@@ -55854,503 +56351,6 @@ var require_content_type = __commonJS({
55854
56351
  }
55855
56352
  });
55856
56353
 
55857
- // ../../node_modules/isexe/windows.js
55858
- var require_windows = __commonJS({
55859
- "../../node_modules/isexe/windows.js"(exports, module) {
55860
- module.exports = isexe;
55861
- isexe.sync = sync;
55862
- var fs2 = __require("fs");
55863
- function checkPathExt(path, options) {
55864
- var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
55865
- if (!pathext) {
55866
- return true;
55867
- }
55868
- pathext = pathext.split(";");
55869
- if (pathext.indexOf("") !== -1) {
55870
- return true;
55871
- }
55872
- for (var i = 0; i < pathext.length; i++) {
55873
- var p = pathext[i].toLowerCase();
55874
- if (p && path.substr(-p.length).toLowerCase() === p) {
55875
- return true;
55876
- }
55877
- }
55878
- return false;
55879
- }
55880
- function checkStat(stat, path, options) {
55881
- if (!stat.isSymbolicLink() && !stat.isFile()) {
55882
- return false;
55883
- }
55884
- return checkPathExt(path, options);
55885
- }
55886
- function isexe(path, options, cb) {
55887
- fs2.stat(path, function(er, stat) {
55888
- cb(er, er ? false : checkStat(stat, path, options));
55889
- });
55890
- }
55891
- function sync(path, options) {
55892
- return checkStat(fs2.statSync(path), path, options);
55893
- }
55894
- }
55895
- });
55896
-
55897
- // ../../node_modules/isexe/mode.js
55898
- var require_mode = __commonJS({
55899
- "../../node_modules/isexe/mode.js"(exports, module) {
55900
- module.exports = isexe;
55901
- isexe.sync = sync;
55902
- var fs2 = __require("fs");
55903
- function isexe(path, options, cb) {
55904
- fs2.stat(path, function(er, stat) {
55905
- cb(er, er ? false : checkStat(stat, options));
55906
- });
55907
- }
55908
- function sync(path, options) {
55909
- return checkStat(fs2.statSync(path), options);
55910
- }
55911
- function checkStat(stat, options) {
55912
- return stat.isFile() && checkMode(stat, options);
55913
- }
55914
- function checkMode(stat, options) {
55915
- var mod = stat.mode;
55916
- var uid2 = stat.uid;
55917
- var gid = stat.gid;
55918
- var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
55919
- var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
55920
- var u = parseInt("100", 8);
55921
- var g = parseInt("010", 8);
55922
- var o = parseInt("001", 8);
55923
- var ug = u | g;
55924
- var ret = mod & o || mod & g && gid === myGid || mod & u && uid2 === myUid || mod & ug && myUid === 0;
55925
- return ret;
55926
- }
55927
- }
55928
- });
55929
-
55930
- // ../../node_modules/isexe/index.js
55931
- var require_isexe = __commonJS({
55932
- "../../node_modules/isexe/index.js"(exports, module) {
55933
- var fs2 = __require("fs");
55934
- var core;
55935
- if (process.platform === "win32" || global.TESTING_WINDOWS) {
55936
- core = require_windows();
55937
- } else {
55938
- core = require_mode();
55939
- }
55940
- module.exports = isexe;
55941
- isexe.sync = sync;
55942
- function isexe(path, options, cb) {
55943
- if (typeof options === "function") {
55944
- cb = options;
55945
- options = {};
55946
- }
55947
- if (!cb) {
55948
- if (typeof Promise !== "function") {
55949
- throw new TypeError("callback not provided");
55950
- }
55951
- return new Promise(function(resolve4, reject) {
55952
- isexe(path, options || {}, function(er, is) {
55953
- if (er) {
55954
- reject(er);
55955
- } else {
55956
- resolve4(is);
55957
- }
55958
- });
55959
- });
55960
- }
55961
- core(path, options || {}, function(er, is) {
55962
- if (er) {
55963
- if (er.code === "EACCES" || options && options.ignoreErrors) {
55964
- er = null;
55965
- is = false;
55966
- }
55967
- }
55968
- cb(er, is);
55969
- });
55970
- }
55971
- function sync(path, options) {
55972
- try {
55973
- return core.sync(path, options || {});
55974
- } catch (er) {
55975
- if (options && options.ignoreErrors || er.code === "EACCES") {
55976
- return false;
55977
- } else {
55978
- throw er;
55979
- }
55980
- }
55981
- }
55982
- }
55983
- });
55984
-
55985
- // ../../node_modules/which/which.js
55986
- var require_which = __commonJS({
55987
- "../../node_modules/which/which.js"(exports, module) {
55988
- var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
55989
- var path = __require("path");
55990
- var COLON = isWindows ? ";" : ":";
55991
- var isexe = require_isexe();
55992
- var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
55993
- var getPathInfo = (cmd, opt) => {
55994
- const colon = opt.colon || COLON;
55995
- const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
55996
- // windows always checks the cwd first
55997
- ...isWindows ? [process.cwd()] : [],
55998
- ...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
55999
- "").split(colon)
56000
- ];
56001
- const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
56002
- const pathExt = isWindows ? pathExtExe.split(colon) : [""];
56003
- if (isWindows) {
56004
- if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
56005
- pathExt.unshift("");
56006
- }
56007
- return {
56008
- pathEnv,
56009
- pathExt,
56010
- pathExtExe
56011
- };
56012
- };
56013
- var which = (cmd, opt, cb) => {
56014
- if (typeof opt === "function") {
56015
- cb = opt;
56016
- opt = {};
56017
- }
56018
- if (!opt)
56019
- opt = {};
56020
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
56021
- const found = [];
56022
- const step = (i) => new Promise((resolve4, reject) => {
56023
- if (i === pathEnv.length)
56024
- return opt.all && found.length ? resolve4(found) : reject(getNotFoundError(cmd));
56025
- const ppRaw = pathEnv[i];
56026
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
56027
- const pCmd = path.join(pathPart, cmd);
56028
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
56029
- resolve4(subStep(p, i, 0));
56030
- });
56031
- const subStep = (p, i, ii) => new Promise((resolve4, reject) => {
56032
- if (ii === pathExt.length)
56033
- return resolve4(step(i + 1));
56034
- const ext = pathExt[ii];
56035
- isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
56036
- if (!er && is) {
56037
- if (opt.all)
56038
- found.push(p + ext);
56039
- else
56040
- return resolve4(p + ext);
56041
- }
56042
- return resolve4(subStep(p, i, ii + 1));
56043
- });
56044
- });
56045
- return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
56046
- };
56047
- var whichSync = (cmd, opt) => {
56048
- opt = opt || {};
56049
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
56050
- const found = [];
56051
- for (let i = 0; i < pathEnv.length; i++) {
56052
- const ppRaw = pathEnv[i];
56053
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
56054
- const pCmd = path.join(pathPart, cmd);
56055
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
56056
- for (let j = 0; j < pathExt.length; j++) {
56057
- const cur = p + pathExt[j];
56058
- try {
56059
- const is = isexe.sync(cur, { pathExt: pathExtExe });
56060
- if (is) {
56061
- if (opt.all)
56062
- found.push(cur);
56063
- else
56064
- return cur;
56065
- }
56066
- } catch (ex) {
56067
- }
56068
- }
56069
- }
56070
- if (opt.all && found.length)
56071
- return found;
56072
- if (opt.nothrow)
56073
- return null;
56074
- throw getNotFoundError(cmd);
56075
- };
56076
- module.exports = which;
56077
- which.sync = whichSync;
56078
- }
56079
- });
56080
-
56081
- // ../../node_modules/path-key/index.js
56082
- var require_path_key = __commonJS({
56083
- "../../node_modules/path-key/index.js"(exports, module) {
56084
- "use strict";
56085
- var pathKey = (options = {}) => {
56086
- const environment = options.env || process.env;
56087
- const platform = options.platform || process.platform;
56088
- if (platform !== "win32") {
56089
- return "PATH";
56090
- }
56091
- return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
56092
- };
56093
- module.exports = pathKey;
56094
- module.exports.default = pathKey;
56095
- }
56096
- });
56097
-
56098
- // ../../node_modules/cross-spawn/lib/util/resolveCommand.js
56099
- var require_resolveCommand = __commonJS({
56100
- "../../node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
56101
- "use strict";
56102
- var path = __require("path");
56103
- var which = require_which();
56104
- var getPathKey = require_path_key();
56105
- function resolveCommandAttempt(parsed, withoutPathExt) {
56106
- const env = parsed.options.env || process.env;
56107
- const cwd = process.cwd();
56108
- const hasCustomCwd = parsed.options.cwd != null;
56109
- const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
56110
- if (shouldSwitchCwd) {
56111
- try {
56112
- process.chdir(parsed.options.cwd);
56113
- } catch (err) {
56114
- }
56115
- }
56116
- let resolved;
56117
- try {
56118
- resolved = which.sync(parsed.command, {
56119
- path: env[getPathKey({ env })],
56120
- pathExt: withoutPathExt ? path.delimiter : void 0
56121
- });
56122
- } catch (e) {
56123
- } finally {
56124
- if (shouldSwitchCwd) {
56125
- process.chdir(cwd);
56126
- }
56127
- }
56128
- if (resolved) {
56129
- resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
56130
- }
56131
- return resolved;
56132
- }
56133
- function resolveCommand(parsed) {
56134
- return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
56135
- }
56136
- module.exports = resolveCommand;
56137
- }
56138
- });
56139
-
56140
- // ../../node_modules/cross-spawn/lib/util/escape.js
56141
- var require_escape = __commonJS({
56142
- "../../node_modules/cross-spawn/lib/util/escape.js"(exports, module) {
56143
- "use strict";
56144
- var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
56145
- function escapeCommand(arg) {
56146
- arg = arg.replace(metaCharsRegExp, "^$1");
56147
- return arg;
56148
- }
56149
- function escapeArgument(arg, doubleEscapeMetaChars) {
56150
- arg = `${arg}`;
56151
- arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
56152
- arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
56153
- arg = `"${arg}"`;
56154
- arg = arg.replace(metaCharsRegExp, "^$1");
56155
- if (doubleEscapeMetaChars) {
56156
- arg = arg.replace(metaCharsRegExp, "^$1");
56157
- }
56158
- return arg;
56159
- }
56160
- module.exports.command = escapeCommand;
56161
- module.exports.argument = escapeArgument;
56162
- }
56163
- });
56164
-
56165
- // ../../node_modules/shebang-regex/index.js
56166
- var require_shebang_regex = __commonJS({
56167
- "../../node_modules/shebang-regex/index.js"(exports, module) {
56168
- "use strict";
56169
- module.exports = /^#!(.*)/;
56170
- }
56171
- });
56172
-
56173
- // ../../node_modules/shebang-command/index.js
56174
- var require_shebang_command = __commonJS({
56175
- "../../node_modules/shebang-command/index.js"(exports, module) {
56176
- "use strict";
56177
- var shebangRegex = require_shebang_regex();
56178
- module.exports = (string4 = "") => {
56179
- const match = string4.match(shebangRegex);
56180
- if (!match) {
56181
- return null;
56182
- }
56183
- const [path, argument] = match[0].replace(/#! ?/, "").split(" ");
56184
- const binary = path.split("/").pop();
56185
- if (binary === "env") {
56186
- return argument;
56187
- }
56188
- return argument ? `${binary} ${argument}` : binary;
56189
- };
56190
- }
56191
- });
56192
-
56193
- // ../../node_modules/cross-spawn/lib/util/readShebang.js
56194
- var require_readShebang = __commonJS({
56195
- "../../node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
56196
- "use strict";
56197
- var fs2 = __require("fs");
56198
- var shebangCommand = require_shebang_command();
56199
- function readShebang(command) {
56200
- const size2 = 150;
56201
- const buffer2 = Buffer.alloc(size2);
56202
- let fd;
56203
- try {
56204
- fd = fs2.openSync(command, "r");
56205
- fs2.readSync(fd, buffer2, 0, size2, 0);
56206
- fs2.closeSync(fd);
56207
- } catch (e) {
56208
- }
56209
- return shebangCommand(buffer2.toString());
56210
- }
56211
- module.exports = readShebang;
56212
- }
56213
- });
56214
-
56215
- // ../../node_modules/cross-spawn/lib/parse.js
56216
- var require_parse = __commonJS({
56217
- "../../node_modules/cross-spawn/lib/parse.js"(exports, module) {
56218
- "use strict";
56219
- var path = __require("path");
56220
- var resolveCommand = require_resolveCommand();
56221
- var escape3 = require_escape();
56222
- var readShebang = require_readShebang();
56223
- var isWin = process.platform === "win32";
56224
- var isExecutableRegExp = /\.(?:com|exe)$/i;
56225
- var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
56226
- function detectShebang(parsed) {
56227
- parsed.file = resolveCommand(parsed);
56228
- const shebang = parsed.file && readShebang(parsed.file);
56229
- if (shebang) {
56230
- parsed.args.unshift(parsed.file);
56231
- parsed.command = shebang;
56232
- return resolveCommand(parsed);
56233
- }
56234
- return parsed.file;
56235
- }
56236
- function parseNonShell(parsed) {
56237
- if (!isWin) {
56238
- return parsed;
56239
- }
56240
- const commandFile = detectShebang(parsed);
56241
- const needsShell = !isExecutableRegExp.test(commandFile);
56242
- if (parsed.options.forceShell || needsShell) {
56243
- const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
56244
- parsed.command = path.normalize(parsed.command);
56245
- parsed.command = escape3.command(parsed.command);
56246
- parsed.args = parsed.args.map((arg) => escape3.argument(arg, needsDoubleEscapeMetaChars));
56247
- const shellCommand = [parsed.command].concat(parsed.args).join(" ");
56248
- parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
56249
- parsed.command = process.env.comspec || "cmd.exe";
56250
- parsed.options.windowsVerbatimArguments = true;
56251
- }
56252
- return parsed;
56253
- }
56254
- function parse10(command, args, options) {
56255
- if (args && !Array.isArray(args)) {
56256
- options = args;
56257
- args = null;
56258
- }
56259
- args = args ? args.slice(0) : [];
56260
- options = Object.assign({}, options);
56261
- const parsed = {
56262
- command,
56263
- args,
56264
- options,
56265
- file: void 0,
56266
- original: {
56267
- command,
56268
- args
56269
- }
56270
- };
56271
- return options.shell ? parsed : parseNonShell(parsed);
56272
- }
56273
- module.exports = parse10;
56274
- }
56275
- });
56276
-
56277
- // ../../node_modules/cross-spawn/lib/enoent.js
56278
- var require_enoent = __commonJS({
56279
- "../../node_modules/cross-spawn/lib/enoent.js"(exports, module) {
56280
- "use strict";
56281
- var isWin = process.platform === "win32";
56282
- function notFoundError(original, syscall) {
56283
- return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
56284
- code: "ENOENT",
56285
- errno: "ENOENT",
56286
- syscall: `${syscall} ${original.command}`,
56287
- path: original.command,
56288
- spawnargs: original.args
56289
- });
56290
- }
56291
- function hookChildProcess(cp, parsed) {
56292
- if (!isWin) {
56293
- return;
56294
- }
56295
- const originalEmit = cp.emit;
56296
- cp.emit = function(name, arg1) {
56297
- if (name === "exit") {
56298
- const err = verifyENOENT(arg1, parsed);
56299
- if (err) {
56300
- return originalEmit.call(cp, "error", err);
56301
- }
56302
- }
56303
- return originalEmit.apply(cp, arguments);
56304
- };
56305
- }
56306
- function verifyENOENT(status, parsed) {
56307
- if (isWin && status === 1 && !parsed.file) {
56308
- return notFoundError(parsed.original, "spawn");
56309
- }
56310
- return null;
56311
- }
56312
- function verifyENOENTSync(status, parsed) {
56313
- if (isWin && status === 1 && !parsed.file) {
56314
- return notFoundError(parsed.original, "spawnSync");
56315
- }
56316
- return null;
56317
- }
56318
- module.exports = {
56319
- hookChildProcess,
56320
- verifyENOENT,
56321
- verifyENOENTSync,
56322
- notFoundError
56323
- };
56324
- }
56325
- });
56326
-
56327
- // ../../node_modules/cross-spawn/index.js
56328
- var require_cross_spawn = __commonJS({
56329
- "../../node_modules/cross-spawn/index.js"(exports, module) {
56330
- "use strict";
56331
- var cp = __require("child_process");
56332
- var parse10 = require_parse();
56333
- var enoent = require_enoent();
56334
- function spawn3(command, args, options) {
56335
- const parsed = parse10(command, args, options);
56336
- const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
56337
- enoent.hookChildProcess(spawned, parsed);
56338
- return spawned;
56339
- }
56340
- function spawnSync(command, args, options) {
56341
- const parsed = parse10(command, args, options);
56342
- const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
56343
- result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
56344
- return result;
56345
- }
56346
- module.exports = spawn3;
56347
- module.exports.spawn = spawn3;
56348
- module.exports.sync = spawnSync;
56349
- module.exports._parse = parse10;
56350
- module.exports._enoent = enoent;
56351
- }
56352
- });
56353
-
56354
56354
  // ../apps-server/src/main.ts
56355
56355
  import { readFileSync as readFileSync6 } from "node:fs";
56356
56356
  import { join as join7 } from "node:path";
@@ -57109,7 +57109,7 @@ var UNIT_TOKEN_ROUTES = /* @__PURE__ */ new Set([
57109
57109
  ]);
57110
57110
 
57111
57111
  // src/apps/actions/write-path.ts
57112
- import { createHash as createHash10, randomUUID } from "node:crypto";
57112
+ import { createHash as createHash11, randomUUID } from "node:crypto";
57113
57113
 
57114
57114
  // src/mcp/classify.ts
57115
57115
  import { createHash as createHash2 } from "node:crypto";
@@ -59713,7 +59713,7 @@ async function pgPrivileges(args, writes = []) {
59713
59713
  }
59714
59714
 
59715
59715
  // src/sources/kinds.ts
59716
- import { createHash as createHash3 } from "node:crypto";
59716
+ import { createHash as createHash4 } from "node:crypto";
59717
59717
 
59718
59718
  // src/knowledge/registry/policy.ts
59719
59719
  var SECRET_PLACEHOLDER = "WICKED_SRC_1";
@@ -60856,536 +60856,276 @@ function agentMay(access, src, projectId, what) {
60856
60856
  return projectId !== null && access.projects.includes(projectId);
60857
60857
  }
60858
60858
 
60859
- // src/mcp/registry-store.ts
60860
- import { join as join2 } from "node:path";
60861
- function mcpStateDir() {
60862
- return join2(crewStateHome(), "mcp");
60863
- }
60859
+ // src/mcp/env.ts
60860
+ import { createHash as createHash3 } from "node:crypto";
60864
60861
 
60865
- // src/mcp/rest.ts
60866
- var import_yaml = __toESM(require_dist(), 1);
60867
- var REST_SPEC_TIMEOUT_MS = 1e4;
60868
- var REST_SPEC_MAX_BYTES = 1024 * 1024;
60869
- var REST_RESPONSE_MAX_BYTES = 1024 * 1024;
60870
- var REST_DEFAULT_TIMEOUT_MS = 3e4;
60871
- var MAX_TOOLS = 512;
60872
- var MAX_REF_DEPTH = 32;
60873
- var TOOL_NAME_MAX = 64;
60874
- var METHODS = ["get", "head", "options", "post", "put", "patch", "delete"];
60875
- var FORBIDDEN_HEADERS = /* @__PURE__ */ new Set([
60876
- "authorization",
60877
- "proxy-authorization",
60878
- "cookie",
60879
- "host",
60880
- "content-length",
60881
- "content-type",
60882
- "transfer-encoding",
60883
- "connection",
60884
- "keep-alive",
60885
- "upgrade",
60886
- "te",
60887
- "trailer",
60888
- "expect",
60889
- "forwarded",
60890
- "x-forwarded-for",
60891
- "x-forwarded-host",
60892
- "x-forwarded-proto"
60893
- ]);
60894
- var RestBoundaryError = class extends UpstreamCallError {
60895
- constructor(message) {
60896
- super("boundary", false, message);
60897
- }
60898
- };
60899
- function parseBaseUrl(raw) {
60900
- if (raw === null) return null;
60901
- let u;
60902
- try {
60903
- u = new URL(raw);
60904
- } catch {
60905
- return null;
60906
- }
60907
- if (u.protocol !== "https:" && u.protocol !== "http:") return null;
60908
- if (u.username !== "" || u.password !== "" || u.search !== "" || u.hash !== "") return null;
60909
- return u;
60910
- }
60911
- function basePath(base2) {
60912
- return base2.pathname.replace(/\/+$/, "");
60913
- }
60914
- function restTarget(config2) {
60915
- const base2 = parseBaseUrl(config2.url);
60916
- if (base2 === null) return null;
60917
- return { origin: base2.origin, basePath: basePath(base2), authHeader: config2.auth?.header?.toLowerCase() ?? null };
60918
- }
60919
- function specServers(doc, specUrl) {
60920
- const raw = Array.isArray(doc["servers"]) && doc["servers"].length > 0 ? doc["servers"] : [{ url: "/" }];
60921
- const out = [];
60922
- for (const s2 of raw) {
60923
- if (s2 === null || typeof s2 !== "object" || Array.isArray(s2)) continue;
60924
- const entry = s2;
60925
- if (typeof entry["url"] !== "string") continue;
60926
- const vars = entry["variables"] !== null && typeof entry["variables"] === "object" ? entry["variables"] : {};
60927
- let unresolved = false;
60928
- const filled = entry["url"].replace(/\{([^{}]+)\}/g, (_m, name) => {
60929
- const v = vars[name];
60930
- const dflt = v !== null && typeof v === "object" ? v["default"] : void 0;
60931
- if (typeof dflt !== "string") {
60932
- unresolved = true;
60933
- return "";
60934
- }
60935
- return dflt;
60936
- });
60937
- if (unresolved) continue;
60938
- let u;
60939
- try {
60940
- u = specUrl === null ? new URL(filled) : new URL(filled, specUrl);
60941
- } catch {
60942
- continue;
60943
- }
60944
- if (u.protocol === "https:" || u.protocol === "http:") out.push(u);
60945
- }
60946
- return out;
60947
- }
60948
- function restEgress(base2, doc, specUrl, target) {
60949
- const servers = specServers(doc, specUrl);
60950
- const path = basePath(base2);
60951
- const matches = servers.some((s2) => {
60952
- const prefix = basePath(s2);
60953
- return s2.origin === base2.origin && (prefix === "" || path === prefix || path.startsWith(`${prefix}/`));
60954
- });
60955
- const privateAddress = (target.addresses ?? [target]).some((a) => a.cls !== "global");
60956
- return { origin: base2.origin, basePath: path, servers: servers.map((s2) => s2.href), matches, privateAddress, resolved: true };
60957
- }
60958
- function pinnedUrl(base2, pathTemplate, values2) {
60959
- let missing = null;
60960
- const filled = pathTemplate.replace(/\{([^{}]+)\}/g, (_m, name) => {
60961
- const v = values2[name];
60962
- if (v === void 0) {
60963
- missing ??= name;
60964
- return "";
60965
- }
60966
- if (v === "." || v === ".." || v === "") throw new RestBoundaryError(`the path value for {${name}} (${JSON.stringify(v)}) would move the request off its path`);
60967
- return encodeURIComponent(v);
60968
- });
60969
- if (missing !== null) throw new UpstreamCallError("protocol", false, `the path variable {${missing}} has no value`);
60970
- if (!filled.startsWith("/")) throw new RestBoundaryError(`the path ${JSON.stringify(pathTemplate)} does not start with /`);
60971
- const url2 = new URL(base2.href);
60972
- const prefix = basePath(base2);
60973
- url2.pathname = `${prefix}${filled}`;
60974
- const escape3 = boundaryEscape(base2, url2);
60975
- if (escape3 !== null) throw new RestBoundaryError(escape3);
60976
- return url2;
60977
- }
60978
- function boundaryEscape(base2, url2) {
60979
- if (url2.origin !== base2.origin) return `the request to ${url2.origin} leaves the pinned host ${base2.origin}`;
60980
- const prefix = basePath(base2);
60981
- if (prefix !== "" && url2.pathname !== prefix && !url2.pathname.startsWith(`${prefix}/`)) {
60982
- return `the request path ${url2.pathname} leaves the pinned base path ${prefix}`;
60983
- }
60984
- return null;
60985
- }
60986
- function isObj(v) {
60987
- return v !== null && typeof v === "object" && !Array.isArray(v);
60988
- }
60989
- function pointer(doc, ref) {
60990
- if (!ref.startsWith("#/")) return void 0;
60991
- let cur = doc;
60992
- for (const raw of ref.slice(2).split("/")) {
60993
- const key = raw.replace(/~1/g, "/").replace(/~0/g, "~");
60994
- if (!isObj(cur) && !Array.isArray(cur)) return void 0;
60995
- cur = cur[key];
60996
- }
60997
- return cur;
60998
- }
60999
- function derefLocal(doc, value, seen = [], depth = 0) {
61000
- if (depth > MAX_REF_DEPTH) return {};
61001
- if (Array.isArray(value)) return value.map((v) => derefLocal(doc, v, seen, depth + 1));
61002
- if (!isObj(value)) return value;
61003
- const ref = value["$ref"];
61004
- if (typeof ref === "string") {
61005
- if (seen.includes(ref)) return {};
61006
- const target = pointer(doc, ref);
61007
- if (target === void 0) return {};
61008
- return derefLocal(doc, target, [...seen, ref], depth + 1);
61009
- }
61010
- const out = {};
61011
- for (const [k, v] of Object.entries(value)) out[k] = derefLocal(doc, v, seen, depth + 1);
61012
- return out;
61013
- }
61014
- function parseOpenApiText(text2) {
61015
- let parsed;
61016
- try {
61017
- parsed = JSON.parse(text2);
61018
- } catch {
61019
- try {
61020
- parsed = (0, import_yaml.parse)(text2, { maxAliasCount: 100 });
61021
- } catch (err) {
61022
- throw new Error(`the OpenAPI document is neither JSON nor YAML: ${err instanceof Error ? err.message : String(err)}`);
61023
- }
61024
- }
61025
- if (!isObj(parsed)) throw new Error("the OpenAPI document is not an object");
61026
- return parsed;
61027
- }
61028
- function toolNameFor(method, path, operationId) {
61029
- const raw = typeof operationId === "string" && operationId.trim() !== "" ? operationId : `${method}_${path}`;
61030
- const name = raw.replace(/[^A-Za-z0-9_-]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "").slice(0, TOOL_NAME_MAX);
61031
- return name === "" ? method : name;
61032
- }
61033
- function annotationsForMethod(method) {
61034
- switch (method) {
61035
- case "GET":
61036
- case "HEAD":
61037
- case "OPTIONS":
61038
- return { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true };
61039
- case "POST":
61040
- return { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true };
61041
- case "PUT":
61042
- return { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: true };
61043
- case "PATCH":
61044
- case "DELETE":
61045
- return { readOnlyHint: false, destructiveHint: true, idempotentHint: method === "DELETE", openWorldHint: true };
61046
- }
61047
- }
61048
- function paramsOf(doc, pathItem, op) {
61049
- const merged = /* @__PURE__ */ new Map();
61050
- for (const list of [pathItem["parameters"], op["parameters"]]) {
61051
- if (!Array.isArray(list)) continue;
61052
- for (const rawParam of list) {
61053
- const p = derefLocal(doc, rawParam);
61054
- if (!isObj(p) || typeof p["name"] !== "string" || p["name"] === "") continue;
61055
- const where = p["in"];
61056
- if (where !== "path" && where !== "query" && where !== "header") continue;
61057
- merged.set(`${where}:${where === "header" ? p["name"].toLowerCase() : p["name"]}`, {
61058
- name: p["name"],
61059
- in: where,
61060
- required: where === "path" || p["required"] === true,
61061
- schema: isObj(p["schema"]) ? p["schema"] : { type: "string" },
61062
- description: typeof p["description"] === "string" ? p["description"] : null
61063
- });
61064
- }
61065
- }
61066
- return [...merged.values()];
61067
- }
61068
- function jsonBodyOf(doc, op) {
61069
- const body = derefLocal(doc, op["requestBody"]);
61070
- if (!isObj(body)) return null;
61071
- const content = body["content"];
61072
- if (!isObj(content)) return null;
61073
- const key = Object.keys(content).find((k) => /^application\/(?:[\w.+-]+\+)?json\b/i.test(k));
61074
- if (key === void 0) return Object.keys(content).length === 0 ? null : "unsupported";
61075
- const media = content[key];
61076
- const schema = isObj(media) && isObj(media["schema"]) ? media["schema"] : {};
61077
- return { schema, required: body["required"] === true };
61078
- }
61079
- function importOpenApi(doc, opts = {}) {
61080
- const version2 = doc["openapi"];
61081
- if (typeof version2 !== "string" || !version2.startsWith("3.")) {
61082
- throw new Error('only OpenAPI 3.x documents are supported (the document has no "openapi": "3.x" field)');
61083
- }
61084
- const paths = doc["paths"];
61085
- if (!isObj(paths)) throw new Error("the OpenAPI document has no paths");
61086
- const forbidden = new Set(FORBIDDEN_HEADERS);
61087
- if (opts.authHeader !== void 0) forbidden.add(opts.authHeader.toLowerCase());
61088
- const wanted = opts.operations === void 0 || opts.operations === null ? null : new Set(opts.operations);
61089
- const matched = /* @__PURE__ */ new Set();
61090
- const used = /* @__PURE__ */ new Set();
61091
- const tools = [];
61092
- const skipped = [];
61093
- for (const [path, rawItem] of Object.entries(paths)) {
61094
- const pathItem = derefLocal(doc, rawItem);
61095
- if (!isObj(pathItem) || !path.startsWith("/")) continue;
61096
- for (const m of METHODS) {
61097
- const op = pathItem[m];
61098
- if (!isObj(op)) continue;
61099
- const method = m.toUpperCase();
61100
- const opId = typeof op["operationId"] === "string" ? op["operationId"] : null;
61101
- let name = toolNameFor(m, path, opId);
61102
- if (wanted !== null) {
61103
- const hit = [opId, name].find((n) => n !== null && wanted.has(n));
61104
- if (hit === void 0) continue;
61105
- matched.add(hit);
61106
- }
61107
- const label = `${method} ${path}`;
61108
- if (tools.length >= MAX_TOOLS) {
61109
- skipped.push(`${label}: more than ${MAX_TOOLS} operations`);
61110
- continue;
61111
- }
61112
- const body = jsonBodyOf(doc, op);
61113
- if (body === "unsupported") {
61114
- skipped.push(`${label}: its request body is not JSON`);
61115
- continue;
61116
- }
61117
- for (let n = 2; used.has(name); n++) name = `${toolNameFor(m, path, opId).slice(0, TOOL_NAME_MAX - 4)}_${n}`;
61118
- const properties = {};
61119
- const required2 = [];
61120
- const mapping = {
61121
- method,
61122
- pathTemplate: path,
61123
- pathMap: {},
61124
- queryMap: {},
61125
- headerMap: {},
61126
- bodyMap: null,
61127
- bodyArg: null,
61128
- argAllowlist: [],
61129
- timeoutMs: opts.timeoutMs ?? REST_DEFAULT_TIMEOUT_MS
61130
- };
61131
- const argName = (base2, where) => base2 in properties ? `${where}_${base2}` : base2;
61132
- const templateVars = new Set([...path.matchAll(/\{([^{}]+)\}/g)].map((x) => x[1]));
61133
- let unusable = null;
61134
- for (const p of paramsOf(doc, pathItem, op)) {
61135
- if (p.in === "header" && forbidden.has(p.name.toLowerCase())) continue;
61136
- if (p.in === "path" && !templateVars.has(p.name)) continue;
61137
- const arg = argName(p.name, p.in);
61138
- if (arg in properties) continue;
61139
- properties[arg] = derefLocal(doc, p.description === null ? p.schema : { ...p.schema, description: p.description });
61140
- if (p.required) required2.push(arg);
61141
- if (p.in === "path") mapping.pathMap[arg] = p.name;
61142
- else if (p.in === "query") mapping.queryMap[arg] = p.name;
61143
- else mapping.headerMap[arg] = p.name;
61144
- }
61145
- for (const v of templateVars) {
61146
- if (!Object.values(mapping.pathMap).includes(v)) {
61147
- const arg = argName(v, "path");
61148
- if (arg in properties) {
61149
- unusable = `its path variable {${v}} clashes with another argument`;
61150
- break;
61151
- }
61152
- properties[arg] = { type: "string" };
61153
- required2.push(arg);
61154
- mapping.pathMap[arg] = v;
61155
- }
61156
- }
61157
- if (unusable !== null) {
61158
- skipped.push(`${label}: ${unusable}`);
61159
- continue;
61160
- }
61161
- if (body !== null) {
61162
- const schema = derefLocal(doc, body.schema);
61163
- const props = isObj(schema["properties"]) ? schema["properties"] : null;
61164
- const fieldsFit = schema["type"] === "object" && props !== null && Object.keys(props).length > 0 && Object.keys(props).every((k) => !(k in properties));
61165
- if (fieldsFit && props !== null) {
61166
- mapping.bodyMap = {};
61167
- const bodyRequired = Array.isArray(schema["required"]) ? schema["required"].filter((x) => typeof x === "string") : [];
61168
- for (const [k, s2] of Object.entries(props)) {
61169
- properties[k] = s2;
61170
- mapping.bodyMap[k] = k;
61171
- if (body.required && bodyRequired.includes(k)) required2.push(k);
61172
- }
61173
- } else {
61174
- const arg = argName("body", "request");
61175
- properties[arg] = schema;
61176
- mapping.bodyArg = arg;
61177
- if (body.required) required2.push(arg);
61178
- }
61179
- }
61180
- mapping.argAllowlist = Object.keys(properties).sort();
61181
- const summary = typeof op["summary"] === "string" ? op["summary"] : typeof op["description"] === "string" ? op["description"] : "";
61182
- const description = `${summary.trim().slice(0, 1024)}${summary.trim() === "" ? "" : " "}(${label})`;
61183
- const annotations = annotationsForMethod(method);
61184
- if (typeof op["summary"] === "string" && op["summary"].trim() !== "") annotations.title = op["summary"].trim().slice(0, 200);
61185
- used.add(name);
61186
- tools.push({
61187
- name,
61188
- description,
61189
- inputSchema: { type: "object", properties, ...required2.length > 0 ? { required: required2 } : {}, additionalProperties: false },
61190
- outputSchema: null,
61191
- annotations,
61192
- rest: mapping
61193
- });
61194
- }
61195
- }
61196
- if (wanted !== null) {
61197
- const unknown2 = [...wanted].filter((w) => !matched.has(w));
61198
- if (unknown2.length > 0) throw new Error(`operations names ${unknown2.map((u) => JSON.stringify(u)).join(", ")}, which the OpenAPI document does not have`);
61199
- }
61200
- if (tools.length === 0) throw new Error(skipped.length > 0 ? `no operation could be wrapped: ${skipped.join("; ")}` : "the OpenAPI document has no operations to wrap");
61201
- const info = doc["info"];
61202
- const serverInfo = isObj(info) && typeof info["title"] === "string" ? { name: info["title"].slice(0, 200), version: typeof info["version"] === "string" ? info["version"].slice(0, 64) : "" } : null;
61203
- return { serverInfo, tools, skipped };
61204
- }
61205
- async function readCapped(res, max) {
61206
- if (res.body === null) return { text: "", truncated: false };
61207
- const reader = res.body.getReader();
61208
- const chunks = [];
61209
- let size2 = 0;
61210
- let truncated = false;
61211
- for (; ; ) {
61212
- const { done, value } = await reader.read();
61213
- if (done) break;
61214
- if (size2 + value.byteLength > max) {
61215
- chunks.push(value.subarray(0, max - size2));
61216
- size2 = max;
61217
- truncated = true;
61218
- await reader.cancel().catch(() => void 0);
61219
- break;
61220
- }
61221
- chunks.push(value);
61222
- size2 += value.byteLength;
61223
- }
61224
- return { text: Buffer.concat(chunks).toString("utf8"), truncated };
61225
- }
61226
- function authHeaders(config2, secret) {
61227
- if (config2.auth?.header === void 0 || secret === null) return {};
61228
- return { [config2.auth.header]: `${config2.auth.prefix ?? ""}${secret}` };
61229
- }
61230
- function dialOf(config2, dial) {
61231
- const resolver = dial.resolver ?? systemResolver;
61232
- return { fetch: dial.fetch ?? boundFetch(addressPolicyOf(config2), { resolver }), resolver };
61233
- }
61234
- async function probeRestServer(config2, secret, dial = {}) {
61235
- const secrets = secret === null ? [] : [secret];
61236
- const { fetch: fetchImpl, resolver } = dialOf(config2, dial);
61237
- try {
61238
- const base2 = parseBaseUrl(config2.url);
61239
- if (base2 === null) throw new Error("a rest server needs an http(s) base url with no credentials, query or fragment");
61240
- const target = await resolveTarget(base2.hostname, addressPolicyOf(config2), resolver);
61241
- checkScheme(base2, target, addressPolicyOf(config2));
61242
- let doc;
61243
- if (config2.openapi !== null && config2.openapi !== void 0) {
61244
- doc = config2.openapi;
61245
- } else if (config2.openapiUrl !== null && config2.openapiUrl !== void 0) {
61246
- const specUrl = new URL(config2.openapiUrl);
61247
- const headers = specUrl.origin === base2.origin ? authHeaders(config2, secret) : {};
61248
- const res = await fetchImpl(specUrl, { headers: { accept: "application/json, application/yaml;q=0.9, */*;q=0.5", ...headers }, redirect: "error", signal: AbortSignal.timeout(REST_SPEC_TIMEOUT_MS) });
61249
- if (!res.ok) throw new Error(`fetching the OpenAPI document answered HTTP ${res.status}`);
61250
- const { text: text2, truncated } = await readCapped(res, REST_SPEC_MAX_BYTES + 1);
61251
- if (truncated || Buffer.byteLength(text2, "utf8") > REST_SPEC_MAX_BYTES) throw new Error(`the OpenAPI document is larger than ${REST_SPEC_MAX_BYTES} bytes`);
61252
- doc = parseOpenApiText(text2);
61253
- } else {
61254
- throw new Error("a rest server needs openapiUrl or openapi");
61255
- }
61256
- const imported = importOpenApi(doc, { authHeader: config2.auth?.header, operations: config2.operations ?? null });
61257
- for (const t of imported.tools) {
61258
- const sample = Object.fromEntries(Object.values(t.rest.pathMap).map((v) => [v, "x"]));
61259
- pinnedUrl(base2, t.rest.pathTemplate, sample);
61260
- }
61261
- const egress = restEgress(base2, doc, config2.openapi !== null && config2.openapi !== void 0 ? null : config2.openapiUrl ?? null, target);
61262
- return scrubSecrets({ ok: true, serverInfo: imported.serverInfo, tools: imported.tools, skipped: imported.skipped, egress }, secrets);
61263
- } catch (err) {
61264
- const message = err instanceof Error ? err.message : String(err);
61265
- return scrubSecrets({ ok: false, error: message, ...err instanceof DialRefusedError ? { refusal: err.code } : {} }, secrets);
61266
- }
61267
- }
61268
- function scalar(v, what) {
61269
- if (typeof v === "string") return v;
61270
- if (typeof v === "number" || typeof v === "boolean") return String(v);
61271
- throw new UpstreamCallError("protocol", false, `${what} must be a string, number or boolean`);
61272
- }
61273
- function buildRestRequest(config2, secret, mapping, args) {
61274
- const base2 = parseBaseUrl(config2.url);
61275
- if (base2 === null) throw new RestBoundaryError("the server has no valid base url to pin the request to");
61276
- const allowed = new Set(mapping.argAllowlist);
61277
- const droppedArgs = Object.keys(args).filter((k) => !allowed.has(k)).sort();
61278
- const sent = Object.fromEntries(Object.entries(args).filter(([k]) => allowed.has(k)));
61279
- args = sent;
61280
- const pathValues = {};
61281
- for (const [arg, variable] of Object.entries(mapping.pathMap)) {
61282
- if (args[arg] !== void 0) pathValues[variable] = scalar(args[arg], `the path argument ${arg}`);
61283
- }
61284
- const url2 = pinnedUrl(base2, mapping.pathTemplate, pathValues);
61285
- for (const [arg, q] of Object.entries(mapping.queryMap)) {
61286
- const v = args[arg];
61287
- if (v === void 0 || v === null) continue;
61288
- if (Array.isArray(v)) for (const item of v) url2.searchParams.append(q, scalar(item, `the query argument ${arg}`));
61289
- else url2.searchParams.append(q, scalar(v, `the query argument ${arg}`));
61290
- }
61291
- const forbidden = new Set(FORBIDDEN_HEADERS);
61292
- if (config2.auth?.header !== void 0) forbidden.add(config2.auth.header.toLowerCase());
61293
- const headers = { accept: "application/json, */*;q=0.5" };
61294
- for (const [arg, h] of Object.entries(mapping.headerMap)) {
61295
- const v = args[arg];
61296
- if (v === void 0 || v === null || forbidden.has(h.toLowerCase())) continue;
61297
- const text2 = scalar(v, `the header argument ${arg}`);
61298
- if (/[\r\n\0]/.test(text2)) throw new UpstreamCallError("protocol", false, `the header argument ${arg} must be one line`);
61299
- if (Object.keys(headers).some((k) => k.toLowerCase() === h.toLowerCase())) continue;
61300
- headers[h] = text2;
61301
- }
61302
- let body;
61303
- if (mapping.bodyArg !== null && args[mapping.bodyArg] !== void 0) {
61304
- body = JSON.stringify(args[mapping.bodyArg]);
61305
- } else if (mapping.bodyMap !== null) {
61306
- const obj = {};
61307
- for (const [arg, key] of Object.entries(mapping.bodyMap)) if (args[arg] !== void 0) obj[key] = args[arg];
61308
- if (Object.keys(obj).length > 0 || mapping.method === "POST" || mapping.method === "PUT" || mapping.method === "PATCH") body = JSON.stringify(obj);
61309
- }
61310
- if (body !== void 0) headers["content-type"] = "application/json";
61311
- Object.assign(headers, authHeaders(config2, secret));
61312
- return { url: url2, init: { method: mapping.method, headers, ...body !== void 0 ? { body } : {} }, droppedArgs };
61313
- }
61314
- async function invokeRestTool(config2, secret, mapping, args, timeoutMs, dial = {}, onDispatch) {
61315
- const { url: url2, init, droppedArgs } = buildRestRequest(config2, secret, mapping, args);
61316
- const deadline = Math.max(1, Math.min(timeoutMs, mapping.timeoutMs));
61317
- const { fetch: fetchImpl } = dialOf(config2, dial);
61318
- let res;
61319
- try {
61320
- onDispatch?.();
61321
- res = await fetchImpl(url2, { ...init, redirect: "manual", signal: AbortSignal.timeout(deadline) });
61322
- } catch (err) {
61323
- if (err instanceof DialRedirectRefusedError) return refuseRedirect(config2, url2, err.status, err.location);
61324
- if (err instanceof UpstreamCallError) throw err;
61325
- const name = err instanceof Error ? err.name : "";
61326
- if (name === "TimeoutError" || name === "AbortError") throw new UpstreamCallError("timeout", false, `timed out after ${Math.round(deadline / 1e3)} s`);
61327
- throw new UpstreamCallError("transport", true, err instanceof Error ? err.message : String(err));
61328
- }
61329
- if (res.status >= 300 && res.status < 400) {
61330
- await res.body?.cancel().catch(() => void 0);
61331
- return refuseRedirect(config2, url2, res.status, res.headers.get("location"));
61332
- }
61333
- return readRestResult(res, droppedArgs);
61334
- }
61335
- function refuseRedirect(config2, url2, status, location) {
61336
- let target = null;
61337
- try {
61338
- target = location === null ? null : new URL(location, url2);
61339
- } catch {
61340
- target = null;
61341
- }
61342
- const base2 = parseBaseUrl(config2.url);
61343
- const escape3 = target !== null && base2 !== null ? boundaryEscape(base2, target) : null;
61344
- if (escape3 !== null) throw new RestBoundaryError(`the API redirected off its pin (${escape3}); not followed`);
61345
- throw new UpstreamCallError("http", false, `the API answered HTTP ${status} (a redirect); redirects are not followed`);
61346
- }
61347
- async function readRestResult(res, droppedArgs) {
61348
- if (res.status === 429 || res.status >= 500) {
61349
- await res.body?.cancel().catch(() => void 0);
61350
- throw new UpstreamCallError("http", true, `the API answered HTTP ${res.status}`);
61351
- }
61352
- let read;
61353
- try {
61354
- read = await readCapped(res, REST_RESPONSE_MAX_BYTES);
61355
- } catch (err) {
61356
- if (res.status >= 400) throw new UpstreamCallError("http", false, `the API answered HTTP ${res.status} (its body could not be read)`);
61357
- throw new UpstreamCallError("transport", true, `reading the response failed: ${err instanceof Error ? err.message : String(err)}`);
61358
- }
61359
- let structured;
61360
- if (!read.truncated && /json/i.test(res.headers.get("content-type") ?? "")) {
61361
- try {
61362
- const parsed = JSON.parse(read.text);
61363
- if (isObj(parsed)) structured = parsed;
61364
- } catch {
61365
- structured = void 0;
61366
- }
61367
- }
61368
- return {
61369
- content: [{ type: "text", text: read.text }],
61370
- ...structured !== void 0 ? { structuredContent: structured } : {},
61371
- isError: res.status >= 400,
61372
- _meta: { "wicked/rest": { status: res.status, droppedArgs, truncated: read.truncated } }
61373
- };
61374
- }
60862
+ // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
60863
+ var import_cross_spawn = __toESM(require_cross_spawn(), 1);
60864
+ import process2 from "node:process";
60865
+ import { PassThrough } from "node:stream";
61375
60866
 
61376
- // src/mcp/registry.ts
61377
- var PREVIEW_TTL_MS = 15 * 60 * 1e3;
61378
- var McpRegistryError = class extends Error {
61379
- constructor(status, code, message, humanMessage) {
61380
- super(message);
61381
- this.status = status;
61382
- this.code = code;
61383
- this.humanMessage = humanMessage;
61384
- }
61385
- status;
61386
- code;
61387
- humanMessage;
61388
- };
60867
+ // ../../node_modules/zod/v4/classic/external.js
60868
+ var external_exports = {};
60869
+ __export(external_exports, {
60870
+ $brand: () => $brand,
60871
+ $input: () => $input,
60872
+ $output: () => $output,
60873
+ INVALID: () => INVALID,
60874
+ NEVER: () => NEVER,
60875
+ TimePrecision: () => TimePrecision,
60876
+ ZodAny: () => ZodAny,
60877
+ ZodArray: () => ZodArray,
60878
+ ZodBase64: () => ZodBase64,
60879
+ ZodBase64URL: () => ZodBase64URL,
60880
+ ZodBigInt: () => ZodBigInt,
60881
+ ZodBigIntFormat: () => ZodBigIntFormat,
60882
+ ZodBoolean: () => ZodBoolean,
60883
+ ZodCIDRv4: () => ZodCIDRv4,
60884
+ ZodCIDRv6: () => ZodCIDRv6,
60885
+ ZodCUID: () => ZodCUID,
60886
+ ZodCUID2: () => ZodCUID2,
60887
+ ZodCatch: () => ZodCatch,
60888
+ ZodCodec: () => ZodCodec,
60889
+ ZodCompileAsyncError: () => ZodCompileAsyncError,
60890
+ ZodCompileUnsupportedError: () => ZodCompileUnsupportedError,
60891
+ ZodCreditCard: () => ZodCreditCard,
60892
+ ZodCustom: () => ZodCustom,
60893
+ ZodCustomStringFormat: () => ZodCustomStringFormat,
60894
+ ZodDate: () => ZodDate,
60895
+ ZodDefault: () => ZodDefault,
60896
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
60897
+ ZodE164: () => ZodE164,
60898
+ ZodEmail: () => ZodEmail,
60899
+ ZodEmoji: () => ZodEmoji,
60900
+ ZodEnum: () => ZodEnum,
60901
+ ZodError: () => ZodError,
60902
+ ZodExactOptional: () => ZodExactOptional,
60903
+ ZodFile: () => ZodFile,
60904
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
60905
+ ZodFunction: () => ZodFunction,
60906
+ ZodGUID: () => ZodGUID,
60907
+ ZodIBAN: () => ZodIBAN,
60908
+ ZodIPv4: () => ZodIPv4,
60909
+ ZodIPv6: () => ZodIPv6,
60910
+ ZodISODate: () => ZodISODate,
60911
+ ZodISODateTime: () => ZodISODateTime,
60912
+ ZodISODuration: () => ZodISODuration,
60913
+ ZodISOTime: () => ZodISOTime,
60914
+ ZodInstanceOf: () => ZodInstanceOf,
60915
+ ZodIntersection: () => ZodIntersection,
60916
+ ZodIssueCode: () => ZodIssueCode,
60917
+ ZodJWT: () => ZodJWT,
60918
+ ZodKSUID: () => ZodKSUID,
60919
+ ZodLazy: () => ZodLazy,
60920
+ ZodLiteral: () => ZodLiteral,
60921
+ ZodMAC: () => ZodMAC,
60922
+ ZodMap: () => ZodMap,
60923
+ ZodNaN: () => ZodNaN,
60924
+ ZodNanoID: () => ZodNanoID,
60925
+ ZodNever: () => ZodNever,
60926
+ ZodNonOptional: () => ZodNonOptional,
60927
+ ZodNull: () => ZodNull,
60928
+ ZodNullable: () => ZodNullable,
60929
+ ZodNumber: () => ZodNumber,
60930
+ ZodNumberFormat: () => ZodNumberFormat,
60931
+ ZodObject: () => ZodObject,
60932
+ ZodOptional: () => ZodOptional,
60933
+ ZodPipe: () => ZodPipe,
60934
+ ZodPrefault: () => ZodPrefault,
60935
+ ZodPreprocess: () => ZodPreprocess,
60936
+ ZodPromise: () => ZodPromise,
60937
+ ZodReadonly: () => ZodReadonly,
60938
+ ZodRealError: () => ZodRealError,
60939
+ ZodRecord: () => ZodRecord,
60940
+ ZodSet: () => ZodSet,
60941
+ ZodString: () => ZodString,
60942
+ ZodStringFormat: () => ZodStringFormat,
60943
+ ZodSuccess: () => ZodSuccess,
60944
+ ZodSymbol: () => ZodSymbol,
60945
+ ZodTemplateLiteral: () => ZodTemplateLiteral,
60946
+ ZodTransform: () => ZodTransform,
60947
+ ZodTuple: () => ZodTuple,
60948
+ ZodType: () => ZodType,
60949
+ ZodULID: () => ZodULID,
60950
+ ZodURL: () => ZodURL,
60951
+ ZodUUID: () => ZodUUID,
60952
+ ZodUndefined: () => ZodUndefined,
60953
+ ZodUnion: () => ZodUnion,
60954
+ ZodUnknown: () => ZodUnknown,
60955
+ ZodVoid: () => ZodVoid,
60956
+ ZodXID: () => ZodXID,
60957
+ ZodXor: () => ZodXor,
60958
+ _ZodString: () => _ZodString,
60959
+ _default: () => _default2,
60960
+ _function: () => _function,
60961
+ any: () => any,
60962
+ array: () => array,
60963
+ base64: () => base642,
60964
+ base64url: () => base64url2,
60965
+ bigint: () => bigint2,
60966
+ boolean: () => boolean2,
60967
+ catch: () => _catch2,
60968
+ check: () => check,
60969
+ cidrv4: () => cidrv42,
60970
+ cidrv6: () => cidrv62,
60971
+ clone: () => clone,
60972
+ codec: () => codec,
60973
+ coerce: () => coerce_exports,
60974
+ compile: () => compile,
60975
+ config: () => config,
60976
+ core: () => core_exports2,
60977
+ creditCard: () => creditCard2,
60978
+ cuid: () => cuid3,
60979
+ cuid2: () => cuid22,
60980
+ currencyCode: () => currencyCode2,
60981
+ custom: () => custom,
60982
+ date: () => date2,
60983
+ decode: () => decode2,
60984
+ decodeAsync: () => decodeAsync2,
60985
+ deepPartial: () => deepPartial,
60986
+ describe: () => describe2,
60987
+ discriminatedUnion: () => discriminatedUnion,
60988
+ e164: () => e1642,
60989
+ email: () => email2,
60990
+ emoji: () => emoji2,
60991
+ encode: () => encode2,
60992
+ encodeAsync: () => encodeAsync2,
60993
+ endsWith: () => _endsWith,
60994
+ enum: () => _enum2,
60995
+ exactOptional: () => exactOptional,
60996
+ file: () => file,
60997
+ flattenError: () => flattenError,
60998
+ float32: () => float32,
60999
+ float64: () => float64,
61000
+ formatError: () => formatError,
61001
+ fromJSONSchema: () => fromJSONSchema,
61002
+ function: () => _function,
61003
+ getDiscriminatedOption: () => getDiscriminatedOption,
61004
+ getErrorMap: () => getErrorMap,
61005
+ globalRegistry: () => globalRegistry,
61006
+ gt: () => _gt,
61007
+ gte: () => _gte,
61008
+ guid: () => guid2,
61009
+ hash: () => hash,
61010
+ hex: () => hex2,
61011
+ hostname: () => hostname2,
61012
+ httpUrl: () => httpUrl,
61013
+ iban: () => iban2,
61014
+ includes: () => _includes,
61015
+ input: () => input,
61016
+ instanceof: () => _instanceof,
61017
+ int: () => int,
61018
+ int32: () => int32,
61019
+ int64: () => int64,
61020
+ intersection: () => intersection,
61021
+ invertCodec: () => invertCodec,
61022
+ ipv4: () => ipv42,
61023
+ ipv6: () => ipv62,
61024
+ iso: () => iso_exports,
61025
+ json: () => json,
61026
+ jwt: () => jwt,
61027
+ keyof: () => keyof,
61028
+ ksuid: () => ksuid2,
61029
+ lazy: () => lazy,
61030
+ length: () => _length,
61031
+ literal: () => literal,
61032
+ locales: () => locales_exports,
61033
+ looseObject: () => looseObject,
61034
+ looseRecord: () => looseRecord,
61035
+ lowercase: () => _lowercase,
61036
+ lt: () => _lt,
61037
+ lte: () => _lte,
61038
+ mac: () => mac2,
61039
+ map: () => map,
61040
+ maxLength: () => _maxLength,
61041
+ maxSize: () => _maxSize,
61042
+ memoizer: () => memoizer,
61043
+ meta: () => meta2,
61044
+ mime: () => _mime,
61045
+ minLength: () => _minLength,
61046
+ minSize: () => _minSize,
61047
+ multipleOf: () => _multipleOf,
61048
+ nan: () => nan,
61049
+ nanoid: () => nanoid2,
61050
+ nativeEnum: () => nativeEnum,
61051
+ negative: () => _negative,
61052
+ never: () => never,
61053
+ nonnegative: () => _nonnegative,
61054
+ nonoptional: () => nonoptional,
61055
+ nonpositive: () => _nonpositive,
61056
+ normalize: () => _normalize,
61057
+ null: () => _null3,
61058
+ nullable: () => nullable,
61059
+ nullish: () => nullish2,
61060
+ number: () => number2,
61061
+ object: () => object,
61062
+ optional: () => optional,
61063
+ output: () => output,
61064
+ overwrite: () => _overwrite,
61065
+ parse: () => parse3,
61066
+ parseAsync: () => parseAsync2,
61067
+ partialRecord: () => partialRecord,
61068
+ pipe: () => pipe,
61069
+ positive: () => _positive,
61070
+ prefault: () => prefault,
61071
+ preprocess: () => preprocess,
61072
+ prettifyError: () => prettifyError,
61073
+ promise: () => promise,
61074
+ properties: () => _properties,
61075
+ property: () => _property,
61076
+ readonly: () => readonly,
61077
+ record: () => record,
61078
+ refine: () => refine,
61079
+ regex: () => _regex,
61080
+ regexes: () => regexes_exports,
61081
+ registry: () => registry,
61082
+ safeDecode: () => safeDecode2,
61083
+ safeDecodeAsync: () => safeDecodeAsync2,
61084
+ safeEncode: () => safeEncode2,
61085
+ safeEncodeAsync: () => safeEncodeAsync2,
61086
+ safeParse: () => safeParse2,
61087
+ safeParseAsync: () => safeParseAsync2,
61088
+ set: () => set,
61089
+ setErrorMap: () => setErrorMap,
61090
+ size: () => _size,
61091
+ slugify: () => _slugify,
61092
+ startsWith: () => _startsWith,
61093
+ strictObject: () => strictObject,
61094
+ string: () => string2,
61095
+ stringFormat: () => stringFormat,
61096
+ stringbool: () => stringbool,
61097
+ success: () => success,
61098
+ superRefine: () => superRefine,
61099
+ symbol: () => symbol,
61100
+ templateLiteral: () => templateLiteral,
61101
+ toJSONSchema: () => toJSONSchema,
61102
+ toLowerCase: () => _toLowerCase,
61103
+ toUpperCase: () => _toUpperCase,
61104
+ toZod: () => toZod,
61105
+ transform: () => transform,
61106
+ treeifyError: () => treeifyError,
61107
+ trim: () => _trim,
61108
+ tuple: () => tuple,
61109
+ uint32: () => uint32,
61110
+ uint64: () => uint64,
61111
+ ulid: () => ulid2,
61112
+ undefined: () => _undefined3,
61113
+ union: () => union,
61114
+ unknown: () => unknown,
61115
+ uppercase: () => _uppercase,
61116
+ url: () => url,
61117
+ util: () => util_exports,
61118
+ uuid: () => uuid2,
61119
+ uuidv4: () => uuidv4,
61120
+ uuidv6: () => uuidv6,
61121
+ uuidv7: () => uuidv7,
61122
+ validate: () => validate,
61123
+ validateAsync: () => validateAsync,
61124
+ void: () => _void2,
61125
+ withParser: () => withParser,
61126
+ xid: () => xid2,
61127
+ xor: () => xor2
61128
+ });
61389
61129
 
61390
61130
  // ../../node_modules/zod/v4/core/index.js
61391
61131
  var core_exports2 = {};
@@ -78094,487 +77834,6 @@ var JSONSchemaGenerator = class {
78094
77834
  // ../../node_modules/zod/v4/core/json-schema.js
78095
77835
  var json_schema_exports = {};
78096
77836
 
78097
- // ../../node_modules/zod/v4/core/visit.js
78098
- var RESOLVING = /* @__PURE__ */ Symbol("z.visit/resolving");
78099
- function visit(schema, fnOrHandlers) {
78100
- const fn = typeof fnOrHandlers === "function" ? fnOrHandlers : (node2, rewritten) => {
78101
- const h = fnOrHandlers[node2._zod.def.type];
78102
- return h ? h(node2, rewritten) : node2;
78103
- };
78104
- const cache = /* @__PURE__ */ new Map();
78105
- function run(s2) {
78106
- const cached2 = cache.get(s2);
78107
- if (cached2 === RESOLVING) {
78108
- return new $ZodLazy({
78109
- type: "lazy",
78110
- getter: () => cache.get(s2)
78111
- });
78112
- }
78113
- if (cached2 !== void 0)
78114
- return cached2;
78115
- cache.set(s2, RESOLVING);
78116
- const inner = mapInner(s2);
78117
- const mapped = fn(inner, inner !== s2);
78118
- cache.set(s2, mapped);
78119
- return mapped;
78120
- }
78121
- function mapInner(s2) {
78122
- const def = s2._zod.def;
78123
- const kind = def.type;
78124
- switch (kind) {
78125
- case "object": {
78126
- const oldShape = def.shape;
78127
- const keys = Object.keys(oldShape);
78128
- let changed = false;
78129
- const newShape = {};
78130
- for (const k of keys) {
78131
- const mapped = run(oldShape[k]);
78132
- if (mapped !== oldShape[k])
78133
- changed = true;
78134
- newShape[k] = mapped;
78135
- }
78136
- let newCatchall = def.catchall;
78137
- if (def.catchall) {
78138
- newCatchall = run(def.catchall);
78139
- if (newCatchall !== def.catchall)
78140
- changed = true;
78141
- }
78142
- return changed ? clone(s2, { ...def, shape: newShape, catchall: newCatchall }) : s2;
78143
- }
78144
- case "array": {
78145
- const mapped = run(def.element);
78146
- return mapped === def.element ? s2 : clone(s2, { ...def, element: mapped });
78147
- }
78148
- case "tuple": {
78149
- const oldItems = def.items;
78150
- let changed = false;
78151
- const newItems = [];
78152
- for (const item of oldItems) {
78153
- const mapped = run(item);
78154
- if (mapped !== item)
78155
- changed = true;
78156
- newItems.push(mapped);
78157
- }
78158
- let newRest = def.rest;
78159
- if (def.rest) {
78160
- newRest = run(def.rest);
78161
- if (newRest !== def.rest)
78162
- changed = true;
78163
- }
78164
- return changed ? clone(s2, { ...def, items: newItems, rest: newRest }) : s2;
78165
- }
78166
- case "record":
78167
- case "map": {
78168
- const newKey = run(def.keyType);
78169
- const newVal = run(def.valueType);
78170
- return newKey === def.keyType && newVal === def.valueType ? s2 : clone(s2, { ...def, keyType: newKey, valueType: newVal });
78171
- }
78172
- case "set": {
78173
- const newVal = run(def.valueType);
78174
- return newVal === def.valueType ? s2 : clone(s2, { ...def, valueType: newVal });
78175
- }
78176
- case "union": {
78177
- const oldOptions = def.options;
78178
- let changed = false;
78179
- const newOptions = [];
78180
- for (const opt of oldOptions) {
78181
- const mapped = run(opt);
78182
- if (mapped !== opt)
78183
- changed = true;
78184
- newOptions.push(mapped);
78185
- }
78186
- return changed ? clone(s2, { ...def, options: newOptions }) : s2;
78187
- }
78188
- case "intersection": {
78189
- const newLeft = run(def.left);
78190
- const newRight = run(def.right);
78191
- return newLeft === def.left && newRight === def.right ? s2 : clone(s2, { ...def, left: newLeft, right: newRight });
78192
- }
78193
- case "optional":
78194
- case "nullable":
78195
- case "default":
78196
- case "prefault":
78197
- case "catch":
78198
- case "readonly":
78199
- case "nonoptional":
78200
- case "promise":
78201
- case "success": {
78202
- const newInner = run(def.innerType);
78203
- return newInner === def.innerType ? s2 : clone(s2, { ...def, innerType: newInner });
78204
- }
78205
- case "pipe": {
78206
- const newIn = run(def.in);
78207
- const newOut = run(def.out);
78208
- return newIn === def.in && newOut === def.out ? s2 : clone(s2, { ...def, in: newIn, out: newOut });
78209
- }
78210
- case "function": {
78211
- const newInput = run(def.input);
78212
- const newOutput = run(def.output);
78213
- return newInput === def.input && newOutput === def.output ? s2 : clone(s2, { ...def, input: newInput, output: newOutput });
78214
- }
78215
- case "lazy": {
78216
- const original = def.getter;
78217
- const { _cachedInner, ...rest } = def;
78218
- return clone(s2, { ...rest, getter: () => run(original()) });
78219
- }
78220
- // A leaf by choice: `parts` are regex fragments, not data positions.
78221
- case "template_literal":
78222
- // Leaves.
78223
- case "string":
78224
- case "number":
78225
- case "int":
78226
- case "boolean":
78227
- case "bigint":
78228
- case "symbol":
78229
- case "undefined":
78230
- case "null":
78231
- case "void":
78232
- case "never":
78233
- case "any":
78234
- case "unknown":
78235
- case "date":
78236
- case "nan":
78237
- case "enum":
78238
- case "literal":
78239
- case "file":
78240
- case "transform":
78241
- case "custom":
78242
- return s2;
78243
- default: {
78244
- kind;
78245
- return s2;
78246
- }
78247
- }
78248
- }
78249
- return run(schema);
78250
- }
78251
-
78252
- // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
78253
- function isZ4Schema(s2) {
78254
- const schema = s2;
78255
- return !!schema._zod;
78256
- }
78257
- function safeParse2(schema, data) {
78258
- if (isZ4Schema(schema)) {
78259
- const result2 = safeParse(schema, data);
78260
- return result2;
78261
- }
78262
- const v3Schema = schema;
78263
- const result = v3Schema.safeParse(data);
78264
- return result;
78265
- }
78266
- function getObjectShape(schema) {
78267
- if (!schema)
78268
- return void 0;
78269
- let rawShape2;
78270
- if (isZ4Schema(schema)) {
78271
- const v4Schema = schema;
78272
- rawShape2 = v4Schema._zod?.def?.shape;
78273
- } else {
78274
- const v3Schema = schema;
78275
- rawShape2 = v3Schema.shape;
78276
- }
78277
- if (!rawShape2)
78278
- return void 0;
78279
- if (typeof rawShape2 === "function") {
78280
- try {
78281
- return rawShape2();
78282
- } catch {
78283
- return void 0;
78284
- }
78285
- }
78286
- return rawShape2;
78287
- }
78288
- function getLiteralValue(schema) {
78289
- if (isZ4Schema(schema)) {
78290
- const v4Schema = schema;
78291
- const def2 = v4Schema._zod?.def;
78292
- if (def2) {
78293
- if (def2.value !== void 0)
78294
- return def2.value;
78295
- if (Array.isArray(def2.values) && def2.values.length > 0) {
78296
- return def2.values[0];
78297
- }
78298
- }
78299
- }
78300
- const v3Schema = schema;
78301
- const def = v3Schema._def;
78302
- if (def) {
78303
- if (def.value !== void 0)
78304
- return def.value;
78305
- if (Array.isArray(def.values) && def.values.length > 0) {
78306
- return def.values[0];
78307
- }
78308
- }
78309
- const directValue = schema.value;
78310
- if (directValue !== void 0)
78311
- return directValue;
78312
- return void 0;
78313
- }
78314
-
78315
- // ../../node_modules/zod/v4/classic/external.js
78316
- var external_exports = {};
78317
- __export(external_exports, {
78318
- $brand: () => $brand,
78319
- $input: () => $input,
78320
- $output: () => $output,
78321
- INVALID: () => INVALID,
78322
- NEVER: () => NEVER,
78323
- TimePrecision: () => TimePrecision,
78324
- ZodAny: () => ZodAny,
78325
- ZodArray: () => ZodArray,
78326
- ZodBase64: () => ZodBase64,
78327
- ZodBase64URL: () => ZodBase64URL,
78328
- ZodBigInt: () => ZodBigInt,
78329
- ZodBigIntFormat: () => ZodBigIntFormat,
78330
- ZodBoolean: () => ZodBoolean,
78331
- ZodCIDRv4: () => ZodCIDRv4,
78332
- ZodCIDRv6: () => ZodCIDRv6,
78333
- ZodCUID: () => ZodCUID,
78334
- ZodCUID2: () => ZodCUID2,
78335
- ZodCatch: () => ZodCatch,
78336
- ZodCodec: () => ZodCodec,
78337
- ZodCompileAsyncError: () => ZodCompileAsyncError,
78338
- ZodCompileUnsupportedError: () => ZodCompileUnsupportedError,
78339
- ZodCreditCard: () => ZodCreditCard,
78340
- ZodCustom: () => ZodCustom,
78341
- ZodCustomStringFormat: () => ZodCustomStringFormat,
78342
- ZodDate: () => ZodDate,
78343
- ZodDefault: () => ZodDefault,
78344
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
78345
- ZodE164: () => ZodE164,
78346
- ZodEmail: () => ZodEmail,
78347
- ZodEmoji: () => ZodEmoji,
78348
- ZodEnum: () => ZodEnum,
78349
- ZodError: () => ZodError,
78350
- ZodExactOptional: () => ZodExactOptional,
78351
- ZodFile: () => ZodFile,
78352
- ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
78353
- ZodFunction: () => ZodFunction,
78354
- ZodGUID: () => ZodGUID,
78355
- ZodIBAN: () => ZodIBAN,
78356
- ZodIPv4: () => ZodIPv4,
78357
- ZodIPv6: () => ZodIPv6,
78358
- ZodISODate: () => ZodISODate,
78359
- ZodISODateTime: () => ZodISODateTime,
78360
- ZodISODuration: () => ZodISODuration,
78361
- ZodISOTime: () => ZodISOTime,
78362
- ZodInstanceOf: () => ZodInstanceOf,
78363
- ZodIntersection: () => ZodIntersection,
78364
- ZodIssueCode: () => ZodIssueCode,
78365
- ZodJWT: () => ZodJWT,
78366
- ZodKSUID: () => ZodKSUID,
78367
- ZodLazy: () => ZodLazy,
78368
- ZodLiteral: () => ZodLiteral,
78369
- ZodMAC: () => ZodMAC,
78370
- ZodMap: () => ZodMap,
78371
- ZodNaN: () => ZodNaN,
78372
- ZodNanoID: () => ZodNanoID,
78373
- ZodNever: () => ZodNever,
78374
- ZodNonOptional: () => ZodNonOptional,
78375
- ZodNull: () => ZodNull,
78376
- ZodNullable: () => ZodNullable,
78377
- ZodNumber: () => ZodNumber,
78378
- ZodNumberFormat: () => ZodNumberFormat,
78379
- ZodObject: () => ZodObject,
78380
- ZodOptional: () => ZodOptional,
78381
- ZodPipe: () => ZodPipe,
78382
- ZodPrefault: () => ZodPrefault,
78383
- ZodPreprocess: () => ZodPreprocess,
78384
- ZodPromise: () => ZodPromise,
78385
- ZodReadonly: () => ZodReadonly,
78386
- ZodRealError: () => ZodRealError,
78387
- ZodRecord: () => ZodRecord,
78388
- ZodSet: () => ZodSet,
78389
- ZodString: () => ZodString,
78390
- ZodStringFormat: () => ZodStringFormat,
78391
- ZodSuccess: () => ZodSuccess,
78392
- ZodSymbol: () => ZodSymbol,
78393
- ZodTemplateLiteral: () => ZodTemplateLiteral,
78394
- ZodTransform: () => ZodTransform,
78395
- ZodTuple: () => ZodTuple,
78396
- ZodType: () => ZodType,
78397
- ZodULID: () => ZodULID,
78398
- ZodURL: () => ZodURL,
78399
- ZodUUID: () => ZodUUID,
78400
- ZodUndefined: () => ZodUndefined,
78401
- ZodUnion: () => ZodUnion,
78402
- ZodUnknown: () => ZodUnknown,
78403
- ZodVoid: () => ZodVoid,
78404
- ZodXID: () => ZodXID,
78405
- ZodXor: () => ZodXor,
78406
- _ZodString: () => _ZodString,
78407
- _default: () => _default2,
78408
- _function: () => _function,
78409
- any: () => any,
78410
- array: () => array,
78411
- base64: () => base642,
78412
- base64url: () => base64url2,
78413
- bigint: () => bigint2,
78414
- boolean: () => boolean2,
78415
- catch: () => _catch2,
78416
- check: () => check,
78417
- cidrv4: () => cidrv42,
78418
- cidrv6: () => cidrv62,
78419
- clone: () => clone,
78420
- codec: () => codec,
78421
- coerce: () => coerce_exports,
78422
- compile: () => compile,
78423
- config: () => config,
78424
- core: () => core_exports2,
78425
- creditCard: () => creditCard2,
78426
- cuid: () => cuid3,
78427
- cuid2: () => cuid22,
78428
- currencyCode: () => currencyCode2,
78429
- custom: () => custom,
78430
- date: () => date2,
78431
- decode: () => decode2,
78432
- decodeAsync: () => decodeAsync2,
78433
- deepPartial: () => deepPartial,
78434
- describe: () => describe2,
78435
- discriminatedUnion: () => discriminatedUnion,
78436
- e164: () => e1642,
78437
- email: () => email2,
78438
- emoji: () => emoji2,
78439
- encode: () => encode2,
78440
- encodeAsync: () => encodeAsync2,
78441
- endsWith: () => _endsWith,
78442
- enum: () => _enum2,
78443
- exactOptional: () => exactOptional,
78444
- file: () => file,
78445
- flattenError: () => flattenError,
78446
- float32: () => float32,
78447
- float64: () => float64,
78448
- formatError: () => formatError,
78449
- fromJSONSchema: () => fromJSONSchema,
78450
- function: () => _function,
78451
- getDiscriminatedOption: () => getDiscriminatedOption,
78452
- getErrorMap: () => getErrorMap,
78453
- globalRegistry: () => globalRegistry,
78454
- gt: () => _gt,
78455
- gte: () => _gte,
78456
- guid: () => guid2,
78457
- hash: () => hash,
78458
- hex: () => hex2,
78459
- hostname: () => hostname2,
78460
- httpUrl: () => httpUrl,
78461
- iban: () => iban2,
78462
- includes: () => _includes,
78463
- input: () => input,
78464
- instanceof: () => _instanceof,
78465
- int: () => int,
78466
- int32: () => int32,
78467
- int64: () => int64,
78468
- intersection: () => intersection,
78469
- invertCodec: () => invertCodec,
78470
- ipv4: () => ipv42,
78471
- ipv6: () => ipv62,
78472
- iso: () => iso_exports,
78473
- json: () => json,
78474
- jwt: () => jwt,
78475
- keyof: () => keyof,
78476
- ksuid: () => ksuid2,
78477
- lazy: () => lazy,
78478
- length: () => _length,
78479
- literal: () => literal,
78480
- locales: () => locales_exports,
78481
- looseObject: () => looseObject,
78482
- looseRecord: () => looseRecord,
78483
- lowercase: () => _lowercase,
78484
- lt: () => _lt,
78485
- lte: () => _lte,
78486
- mac: () => mac2,
78487
- map: () => map,
78488
- maxLength: () => _maxLength,
78489
- maxSize: () => _maxSize,
78490
- memoizer: () => memoizer,
78491
- meta: () => meta2,
78492
- mime: () => _mime,
78493
- minLength: () => _minLength,
78494
- minSize: () => _minSize,
78495
- multipleOf: () => _multipleOf,
78496
- nan: () => nan,
78497
- nanoid: () => nanoid2,
78498
- nativeEnum: () => nativeEnum,
78499
- negative: () => _negative,
78500
- never: () => never,
78501
- nonnegative: () => _nonnegative,
78502
- nonoptional: () => nonoptional,
78503
- nonpositive: () => _nonpositive,
78504
- normalize: () => _normalize,
78505
- null: () => _null3,
78506
- nullable: () => nullable,
78507
- nullish: () => nullish2,
78508
- number: () => number2,
78509
- object: () => object2,
78510
- optional: () => optional,
78511
- output: () => output,
78512
- overwrite: () => _overwrite,
78513
- parse: () => parse3,
78514
- parseAsync: () => parseAsync2,
78515
- partialRecord: () => partialRecord,
78516
- pipe: () => pipe,
78517
- positive: () => _positive,
78518
- prefault: () => prefault,
78519
- preprocess: () => preprocess,
78520
- prettifyError: () => prettifyError,
78521
- promise: () => promise,
78522
- properties: () => _properties,
78523
- property: () => _property,
78524
- readonly: () => readonly,
78525
- record: () => record,
78526
- refine: () => refine,
78527
- regex: () => _regex,
78528
- regexes: () => regexes_exports,
78529
- registry: () => registry,
78530
- safeDecode: () => safeDecode2,
78531
- safeDecodeAsync: () => safeDecodeAsync2,
78532
- safeEncode: () => safeEncode2,
78533
- safeEncodeAsync: () => safeEncodeAsync2,
78534
- safeParse: () => safeParse3,
78535
- safeParseAsync: () => safeParseAsync2,
78536
- set: () => set,
78537
- setErrorMap: () => setErrorMap,
78538
- size: () => _size,
78539
- slugify: () => _slugify,
78540
- startsWith: () => _startsWith,
78541
- strictObject: () => strictObject,
78542
- string: () => string2,
78543
- stringFormat: () => stringFormat,
78544
- stringbool: () => stringbool,
78545
- success: () => success,
78546
- superRefine: () => superRefine,
78547
- symbol: () => symbol,
78548
- templateLiteral: () => templateLiteral,
78549
- toJSONSchema: () => toJSONSchema,
78550
- toLowerCase: () => _toLowerCase,
78551
- toUpperCase: () => _toUpperCase,
78552
- toZod: () => toZod,
78553
- transform: () => transform,
78554
- treeifyError: () => treeifyError,
78555
- trim: () => _trim,
78556
- tuple: () => tuple,
78557
- uint32: () => uint32,
78558
- uint64: () => uint64,
78559
- ulid: () => ulid2,
78560
- undefined: () => _undefined3,
78561
- union: () => union,
78562
- unknown: () => unknown,
78563
- uppercase: () => _uppercase,
78564
- url: () => url,
78565
- util: () => util_exports,
78566
- uuid: () => uuid2,
78567
- uuidv4: () => uuidv4,
78568
- uuidv6: () => uuidv6,
78569
- uuidv7: () => uuidv7,
78570
- validate: () => validate,
78571
- validateAsync: () => validateAsync,
78572
- void: () => _void2,
78573
- withParser: () => withParser,
78574
- xid: () => xid2,
78575
- xor: () => xor2
78576
- });
78577
-
78578
77837
  // ../../node_modules/zod/v4/classic/schemas.js
78579
77838
  var schemas_exports2 = {};
78580
77839
  __export(schemas_exports2, {
@@ -78719,7 +77978,7 @@ __export(schemas_exports2, {
78719
77978
  nullable: () => nullable,
78720
77979
  nullish: () => nullish2,
78721
77980
  number: () => number2,
78722
- object: () => object2,
77981
+ object: () => object,
78723
77982
  optional: () => optional,
78724
77983
  partialRecord: () => partialRecord,
78725
77984
  pipe: () => pipe,
@@ -78840,7 +78099,7 @@ var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, void 0
78840
78099
  // ../../node_modules/zod/v4/classic/parse.js
78841
78100
  var parse3 = /* @__PURE__ */ _parse(ZodRealError);
78842
78101
  var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
78843
- var safeParse3 = /* @__PURE__ */ _safeParse(ZodRealError);
78102
+ var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
78844
78103
  var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
78845
78104
  var encode2 = /* @__PURE__ */ _encode(ZodRealError);
78846
78105
  var decode2 = /* @__PURE__ */ _decode(ZodRealError);
@@ -78981,7 +78240,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
78981
78240
  return await parseAsync2(this, data, params, { callee: _parseAsync2 });
78982
78241
  },
78983
78242
  safeParse(data, params) {
78984
- return safeParse3(this, data, params);
78243
+ return safeParse2(this, data, params);
78985
78244
  },
78986
78245
  async safeParseAsync(data, params) {
78987
78246
  return safeParseAsync2(this, data, params);
@@ -79713,7 +78972,7 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
79713
78972
  return util_exports.required(ZodNonOptional, this, args[0]);
79714
78973
  }
79715
78974
  });
79716
- function object2(shape, params) {
78975
+ function object(shape, params) {
79717
78976
  const def = {
79718
78977
  type: "object",
79719
78978
  shape: shape ?? {},
@@ -81100,6 +80359,161 @@ function fromJSONSchema(schema, params) {
81100
80359
  return convertSchema(normalized, ctx);
81101
80360
  }
81102
80361
 
80362
+ // ../../node_modules/zod/v4/core/visit.js
80363
+ var RESOLVING = /* @__PURE__ */ Symbol("z.visit/resolving");
80364
+ function visit(schema, fnOrHandlers) {
80365
+ const fn = typeof fnOrHandlers === "function" ? fnOrHandlers : (node2, rewritten) => {
80366
+ const h = fnOrHandlers[node2._zod.def.type];
80367
+ return h ? h(node2, rewritten) : node2;
80368
+ };
80369
+ const cache = /* @__PURE__ */ new Map();
80370
+ function run(s2) {
80371
+ const cached2 = cache.get(s2);
80372
+ if (cached2 === RESOLVING) {
80373
+ return new $ZodLazy({
80374
+ type: "lazy",
80375
+ getter: () => cache.get(s2)
80376
+ });
80377
+ }
80378
+ if (cached2 !== void 0)
80379
+ return cached2;
80380
+ cache.set(s2, RESOLVING);
80381
+ const inner = mapInner(s2);
80382
+ const mapped = fn(inner, inner !== s2);
80383
+ cache.set(s2, mapped);
80384
+ return mapped;
80385
+ }
80386
+ function mapInner(s2) {
80387
+ const def = s2._zod.def;
80388
+ const kind = def.type;
80389
+ switch (kind) {
80390
+ case "object": {
80391
+ const oldShape = def.shape;
80392
+ const keys = Object.keys(oldShape);
80393
+ let changed = false;
80394
+ const newShape = {};
80395
+ for (const k of keys) {
80396
+ const mapped = run(oldShape[k]);
80397
+ if (mapped !== oldShape[k])
80398
+ changed = true;
80399
+ newShape[k] = mapped;
80400
+ }
80401
+ let newCatchall = def.catchall;
80402
+ if (def.catchall) {
80403
+ newCatchall = run(def.catchall);
80404
+ if (newCatchall !== def.catchall)
80405
+ changed = true;
80406
+ }
80407
+ return changed ? clone(s2, { ...def, shape: newShape, catchall: newCatchall }) : s2;
80408
+ }
80409
+ case "array": {
80410
+ const mapped = run(def.element);
80411
+ return mapped === def.element ? s2 : clone(s2, { ...def, element: mapped });
80412
+ }
80413
+ case "tuple": {
80414
+ const oldItems = def.items;
80415
+ let changed = false;
80416
+ const newItems = [];
80417
+ for (const item of oldItems) {
80418
+ const mapped = run(item);
80419
+ if (mapped !== item)
80420
+ changed = true;
80421
+ newItems.push(mapped);
80422
+ }
80423
+ let newRest = def.rest;
80424
+ if (def.rest) {
80425
+ newRest = run(def.rest);
80426
+ if (newRest !== def.rest)
80427
+ changed = true;
80428
+ }
80429
+ return changed ? clone(s2, { ...def, items: newItems, rest: newRest }) : s2;
80430
+ }
80431
+ case "record":
80432
+ case "map": {
80433
+ const newKey = run(def.keyType);
80434
+ const newVal = run(def.valueType);
80435
+ return newKey === def.keyType && newVal === def.valueType ? s2 : clone(s2, { ...def, keyType: newKey, valueType: newVal });
80436
+ }
80437
+ case "set": {
80438
+ const newVal = run(def.valueType);
80439
+ return newVal === def.valueType ? s2 : clone(s2, { ...def, valueType: newVal });
80440
+ }
80441
+ case "union": {
80442
+ const oldOptions = def.options;
80443
+ let changed = false;
80444
+ const newOptions = [];
80445
+ for (const opt of oldOptions) {
80446
+ const mapped = run(opt);
80447
+ if (mapped !== opt)
80448
+ changed = true;
80449
+ newOptions.push(mapped);
80450
+ }
80451
+ return changed ? clone(s2, { ...def, options: newOptions }) : s2;
80452
+ }
80453
+ case "intersection": {
80454
+ const newLeft = run(def.left);
80455
+ const newRight = run(def.right);
80456
+ return newLeft === def.left && newRight === def.right ? s2 : clone(s2, { ...def, left: newLeft, right: newRight });
80457
+ }
80458
+ case "optional":
80459
+ case "nullable":
80460
+ case "default":
80461
+ case "prefault":
80462
+ case "catch":
80463
+ case "readonly":
80464
+ case "nonoptional":
80465
+ case "promise":
80466
+ case "success": {
80467
+ const newInner = run(def.innerType);
80468
+ return newInner === def.innerType ? s2 : clone(s2, { ...def, innerType: newInner });
80469
+ }
80470
+ case "pipe": {
80471
+ const newIn = run(def.in);
80472
+ const newOut = run(def.out);
80473
+ return newIn === def.in && newOut === def.out ? s2 : clone(s2, { ...def, in: newIn, out: newOut });
80474
+ }
80475
+ case "function": {
80476
+ const newInput = run(def.input);
80477
+ const newOutput = run(def.output);
80478
+ return newInput === def.input && newOutput === def.output ? s2 : clone(s2, { ...def, input: newInput, output: newOutput });
80479
+ }
80480
+ case "lazy": {
80481
+ const original = def.getter;
80482
+ const { _cachedInner, ...rest } = def;
80483
+ return clone(s2, { ...rest, getter: () => run(original()) });
80484
+ }
80485
+ // A leaf by choice: `parts` are regex fragments, not data positions.
80486
+ case "template_literal":
80487
+ // Leaves.
80488
+ case "string":
80489
+ case "number":
80490
+ case "int":
80491
+ case "boolean":
80492
+ case "bigint":
80493
+ case "symbol":
80494
+ case "undefined":
80495
+ case "null":
80496
+ case "void":
80497
+ case "never":
80498
+ case "any":
80499
+ case "unknown":
80500
+ case "date":
80501
+ case "nan":
80502
+ case "enum":
80503
+ case "literal":
80504
+ case "file":
80505
+ case "transform":
80506
+ case "custom":
80507
+ return s2;
80508
+ default: {
80509
+ kind;
80510
+ return s2;
80511
+ }
80512
+ }
80513
+ }
80514
+ return run(schema);
80515
+ }
80516
+
81103
80517
  // ../../node_modules/zod/v4/classic/deep-partial.js
81104
80518
  function deepPartial(schema) {
81105
80519
  return visit(schema, {
@@ -81185,10 +80599,10 @@ var TaskCreationParamsSchema = looseObject({
81185
80599
  */
81186
80600
  pollInterval: number2().optional()
81187
80601
  });
81188
- var TaskMetadataSchema = object2({
80602
+ var TaskMetadataSchema = object({
81189
80603
  ttl: number2().optional()
81190
80604
  });
81191
- var RelatedTaskMetadataSchema = object2({
80605
+ var RelatedTaskMetadataSchema = object({
81192
80606
  taskId: string2()
81193
80607
  });
81194
80608
  var RequestMetaSchema = looseObject({
@@ -81201,7 +80615,7 @@ var RequestMetaSchema = looseObject({
81201
80615
  */
81202
80616
  [RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
81203
80617
  });
81204
- var BaseRequestParamsSchema = object2({
80618
+ var BaseRequestParamsSchema = object({
81205
80619
  /**
81206
80620
  * See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
81207
80621
  */
@@ -81219,18 +80633,18 @@ var TaskAugmentedRequestParamsSchema = BaseRequestParamsSchema.extend({
81219
80633
  task: TaskMetadataSchema.optional()
81220
80634
  });
81221
80635
  var isTaskAugmentedRequestParams = (value) => TaskAugmentedRequestParamsSchema.safeParse(value).success;
81222
- var RequestSchema = object2({
80636
+ var RequestSchema = object({
81223
80637
  method: string2(),
81224
80638
  params: BaseRequestParamsSchema.loose().optional()
81225
80639
  });
81226
- var NotificationsParamsSchema = object2({
80640
+ var NotificationsParamsSchema = object({
81227
80641
  /**
81228
80642
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
81229
80643
  * for notes on _meta usage.
81230
80644
  */
81231
80645
  _meta: RequestMetaSchema.optional()
81232
80646
  });
81233
- var NotificationSchema = object2({
80647
+ var NotificationSchema = object({
81234
80648
  method: string2(),
81235
80649
  params: NotificationsParamsSchema.loose().optional()
81236
80650
  });
@@ -81242,18 +80656,18 @@ var ResultSchema = looseObject({
81242
80656
  _meta: RequestMetaSchema.optional()
81243
80657
  });
81244
80658
  var RequestIdSchema = union([string2(), number2().int()]);
81245
- var JSONRPCRequestSchema = object2({
80659
+ var JSONRPCRequestSchema = object({
81246
80660
  jsonrpc: literal(JSONRPC_VERSION),
81247
80661
  id: RequestIdSchema,
81248
80662
  ...RequestSchema.shape
81249
80663
  }).strict();
81250
80664
  var isJSONRPCRequest = (value) => JSONRPCRequestSchema.safeParse(value).success;
81251
- var JSONRPCNotificationSchema = object2({
80665
+ var JSONRPCNotificationSchema = object({
81252
80666
  jsonrpc: literal(JSONRPC_VERSION),
81253
80667
  ...NotificationSchema.shape
81254
80668
  }).strict();
81255
80669
  var isJSONRPCNotification = (value) => JSONRPCNotificationSchema.safeParse(value).success;
81256
- var JSONRPCResultResponseSchema = object2({
80670
+ var JSONRPCResultResponseSchema = object({
81257
80671
  jsonrpc: literal(JSONRPC_VERSION),
81258
80672
  id: RequestIdSchema,
81259
80673
  result: ResultSchema
@@ -81270,10 +80684,10 @@ var ErrorCode;
81270
80684
  ErrorCode2[ErrorCode2["InternalError"] = -32603] = "InternalError";
81271
80685
  ErrorCode2[ErrorCode2["UrlElicitationRequired"] = -32042] = "UrlElicitationRequired";
81272
80686
  })(ErrorCode || (ErrorCode = {}));
81273
- var JSONRPCErrorResponseSchema = object2({
80687
+ var JSONRPCErrorResponseSchema = object({
81274
80688
  jsonrpc: literal(JSONRPC_VERSION),
81275
80689
  id: RequestIdSchema.optional(),
81276
- error: object2({
80690
+ error: object({
81277
80691
  /**
81278
80692
  * The error type that occurred.
81279
80693
  */
@@ -81313,7 +80727,7 @@ var CancelledNotificationSchema = NotificationSchema.extend({
81313
80727
  method: literal("notifications/cancelled"),
81314
80728
  params: CancelledNotificationParamsSchema
81315
80729
  });
81316
- var IconSchema = object2({
80730
+ var IconSchema = object({
81317
80731
  /**
81318
80732
  * URL or data URI for the icon.
81319
80733
  */
@@ -81338,7 +80752,7 @@ var IconSchema = object2({
81338
80752
  */
81339
80753
  theme: _enum2(["light", "dark"]).optional()
81340
80754
  });
81341
- var IconsSchema = object2({
80755
+ var IconsSchema = object({
81342
80756
  /**
81343
80757
  * Optional set of sized icons that the client can display in a user interface.
81344
80758
  *
@@ -81352,7 +80766,7 @@ var IconsSchema = object2({
81352
80766
  */
81353
80767
  icons: array(IconSchema).optional()
81354
80768
  });
81355
- var BaseMetadataSchema = object2({
80769
+ var BaseMetadataSchema = object({
81356
80770
  /** Intended for programmatic or logical use, but used as a display name in past specs or fallback */
81357
80771
  name: string2(),
81358
80772
  /**
@@ -81382,7 +80796,7 @@ var ImplementationSchema = BaseMetadataSchema.extend({
81382
80796
  */
81383
80797
  description: string2().optional()
81384
80798
  });
81385
- var FormElicitationCapabilitySchema = intersection(object2({
80799
+ var FormElicitationCapabilitySchema = intersection(object({
81386
80800
  applyDefaults: boolean2().optional()
81387
80801
  }), record(string2(), unknown()));
81388
80802
  var ElicitationCapabilitySchema = preprocess((value) => {
@@ -81392,7 +80806,7 @@ var ElicitationCapabilitySchema = preprocess((value) => {
81392
80806
  }
81393
80807
  }
81394
80808
  return value;
81395
- }, intersection(object2({
80809
+ }, intersection(object({
81396
80810
  form: FormElicitationCapabilitySchema.optional(),
81397
80811
  url: AssertObjectSchema.optional()
81398
80812
  }), record(string2(), unknown()).optional()));
@@ -81444,7 +80858,7 @@ var ServerTasksCapabilitySchema = looseObject({
81444
80858
  }).optional()
81445
80859
  }).optional()
81446
80860
  });
81447
- var ClientCapabilitiesSchema = object2({
80861
+ var ClientCapabilitiesSchema = object({
81448
80862
  /**
81449
80863
  * Experimental, non-standard capabilities that the client supports.
81450
80864
  */
@@ -81452,7 +80866,7 @@ var ClientCapabilitiesSchema = object2({
81452
80866
  /**
81453
80867
  * Present if the client supports sampling from an LLM.
81454
80868
  */
81455
- sampling: object2({
80869
+ sampling: object({
81456
80870
  /**
81457
80871
  * Present if the client supports context inclusion via includeContext parameter.
81458
80872
  * If not declared, servers SHOULD only use `includeContext: "none"` (or omit it).
@@ -81470,7 +80884,7 @@ var ClientCapabilitiesSchema = object2({
81470
80884
  /**
81471
80885
  * Present if the client supports listing roots.
81472
80886
  */
81473
- roots: object2({
80887
+ roots: object({
81474
80888
  /**
81475
80889
  * Whether the client supports issuing notifications for changes to the roots list.
81476
80890
  */
@@ -81497,7 +80911,7 @@ var InitializeRequestSchema = RequestSchema.extend({
81497
80911
  method: literal("initialize"),
81498
80912
  params: InitializeRequestParamsSchema
81499
80913
  });
81500
- var ServerCapabilitiesSchema = object2({
80914
+ var ServerCapabilitiesSchema = object({
81501
80915
  /**
81502
80916
  * Experimental, non-standard capabilities that the server supports.
81503
80917
  */
@@ -81513,7 +80927,7 @@ var ServerCapabilitiesSchema = object2({
81513
80927
  /**
81514
80928
  * Present if the server offers any prompt templates.
81515
80929
  */
81516
- prompts: object2({
80930
+ prompts: object({
81517
80931
  /**
81518
80932
  * Whether this server supports issuing notifications for changes to the prompt list.
81519
80933
  */
@@ -81522,7 +80936,7 @@ var ServerCapabilitiesSchema = object2({
81522
80936
  /**
81523
80937
  * Present if the server offers any resources to read.
81524
80938
  */
81525
- resources: object2({
80939
+ resources: object({
81526
80940
  /**
81527
80941
  * Whether this server supports clients subscribing to resource updates.
81528
80942
  */
@@ -81535,7 +80949,7 @@ var ServerCapabilitiesSchema = object2({
81535
80949
  /**
81536
80950
  * Present if the server offers any tools to call.
81537
80951
  */
81538
- tools: object2({
80952
+ tools: object({
81539
80953
  /**
81540
80954
  * Whether this server supports issuing notifications for changes to the tool list.
81541
80955
  */
@@ -81573,7 +80987,7 @@ var PingRequestSchema = RequestSchema.extend({
81573
80987
  method: literal("ping"),
81574
80988
  params: BaseRequestParamsSchema.optional()
81575
80989
  });
81576
- var ProgressSchema = object2({
80990
+ var ProgressSchema = object({
81577
80991
  /**
81578
80992
  * The progress thus far. This should increase every time progress is made, even if the total is unknown.
81579
80993
  */
@@ -81587,7 +81001,7 @@ var ProgressSchema = object2({
81587
81001
  */
81588
81002
  message: optional(string2())
81589
81003
  });
81590
- var ProgressNotificationParamsSchema = object2({
81004
+ var ProgressNotificationParamsSchema = object({
81591
81005
  ...NotificationsParamsSchema.shape,
81592
81006
  ...ProgressSchema.shape,
81593
81007
  /**
@@ -81617,7 +81031,7 @@ var PaginatedResultSchema = ResultSchema.extend({
81617
81031
  nextCursor: CursorSchema.optional()
81618
81032
  });
81619
81033
  var TaskStatusSchema = _enum2(["working", "input_required", "completed", "failed", "cancelled"]);
81620
- var TaskSchema = object2({
81034
+ var TaskSchema = object({
81621
81035
  taskId: string2(),
81622
81036
  status: TaskStatusSchema,
81623
81037
  /**
@@ -81674,7 +81088,7 @@ var CancelTaskRequestSchema = RequestSchema.extend({
81674
81088
  })
81675
81089
  });
81676
81090
  var CancelTaskResultSchema = ResultSchema.merge(TaskSchema);
81677
- var ResourceContentsSchema = object2({
81091
+ var ResourceContentsSchema = object({
81678
81092
  /**
81679
81093
  * The URI of this resource.
81680
81094
  */
@@ -81710,7 +81124,7 @@ var BlobResourceContentsSchema = ResourceContentsSchema.extend({
81710
81124
  blob: Base64Schema
81711
81125
  });
81712
81126
  var RoleSchema = _enum2(["user", "assistant"]);
81713
- var AnnotationsSchema = object2({
81127
+ var AnnotationsSchema = object({
81714
81128
  /**
81715
81129
  * Intended audience(s) for the resource.
81716
81130
  */
@@ -81724,7 +81138,7 @@ var AnnotationsSchema = object2({
81724
81138
  */
81725
81139
  lastModified: iso_exports.datetime({ offset: true }).optional()
81726
81140
  });
81727
- var ResourceSchema = object2({
81141
+ var ResourceSchema = object({
81728
81142
  ...BaseMetadataSchema.shape,
81729
81143
  ...IconsSchema.shape,
81730
81144
  /**
@@ -81757,7 +81171,7 @@ var ResourceSchema = object2({
81757
81171
  */
81758
81172
  _meta: optional(looseObject({}))
81759
81173
  });
81760
- var ResourceTemplateSchema = object2({
81174
+ var ResourceTemplateSchema = object({
81761
81175
  ...BaseMetadataSchema.shape,
81762
81176
  ...IconsSchema.shape,
81763
81177
  /**
@@ -81836,7 +81250,7 @@ var ResourceUpdatedNotificationSchema = NotificationSchema.extend({
81836
81250
  method: literal("notifications/resources/updated"),
81837
81251
  params: ResourceUpdatedNotificationParamsSchema
81838
81252
  });
81839
- var PromptArgumentSchema = object2({
81253
+ var PromptArgumentSchema = object({
81840
81254
  /**
81841
81255
  * The name of the argument.
81842
81256
  */
@@ -81850,7 +81264,7 @@ var PromptArgumentSchema = object2({
81850
81264
  */
81851
81265
  required: optional(boolean2())
81852
81266
  });
81853
- var PromptSchema = object2({
81267
+ var PromptSchema = object({
81854
81268
  ...BaseMetadataSchema.shape,
81855
81269
  ...IconsSchema.shape,
81856
81270
  /**
@@ -81887,7 +81301,7 @@ var GetPromptRequestSchema = RequestSchema.extend({
81887
81301
  method: literal("prompts/get"),
81888
81302
  params: GetPromptRequestParamsSchema
81889
81303
  });
81890
- var TextContentSchema = object2({
81304
+ var TextContentSchema = object({
81891
81305
  type: literal("text"),
81892
81306
  /**
81893
81307
  * The text content of the message.
@@ -81903,7 +81317,7 @@ var TextContentSchema = object2({
81903
81317
  */
81904
81318
  _meta: record(string2(), unknown()).optional()
81905
81319
  });
81906
- var ImageContentSchema = object2({
81320
+ var ImageContentSchema = object({
81907
81321
  type: literal("image"),
81908
81322
  /**
81909
81323
  * The base64-encoded image data.
@@ -81923,7 +81337,7 @@ var ImageContentSchema = object2({
81923
81337
  */
81924
81338
  _meta: record(string2(), unknown()).optional()
81925
81339
  });
81926
- var AudioContentSchema = object2({
81340
+ var AudioContentSchema = object({
81927
81341
  type: literal("audio"),
81928
81342
  /**
81929
81343
  * The base64-encoded audio data.
@@ -81943,7 +81357,7 @@ var AudioContentSchema = object2({
81943
81357
  */
81944
81358
  _meta: record(string2(), unknown()).optional()
81945
81359
  });
81946
- var ToolUseContentSchema = object2({
81360
+ var ToolUseContentSchema = object({
81947
81361
  type: literal("tool_use"),
81948
81362
  /**
81949
81363
  * The name of the tool to invoke.
@@ -81966,7 +81380,7 @@ var ToolUseContentSchema = object2({
81966
81380
  */
81967
81381
  _meta: record(string2(), unknown()).optional()
81968
81382
  });
81969
- var EmbeddedResourceSchema = object2({
81383
+ var EmbeddedResourceSchema = object({
81970
81384
  type: literal("resource"),
81971
81385
  resource: union([TextResourceContentsSchema, BlobResourceContentsSchema]),
81972
81386
  /**
@@ -81989,7 +81403,7 @@ var ContentBlockSchema = union([
81989
81403
  ResourceLinkSchema,
81990
81404
  EmbeddedResourceSchema
81991
81405
  ]);
81992
- var PromptMessageSchema = object2({
81406
+ var PromptMessageSchema = object({
81993
81407
  role: RoleSchema,
81994
81408
  content: ContentBlockSchema
81995
81409
  });
@@ -82004,7 +81418,7 @@ var PromptListChangedNotificationSchema = NotificationSchema.extend({
82004
81418
  method: literal("notifications/prompts/list_changed"),
82005
81419
  params: NotificationsParamsSchema.optional()
82006
81420
  });
82007
- var ToolAnnotationsSchema = object2({
81421
+ var ToolAnnotationsSchema = object({
82008
81422
  /**
82009
81423
  * A human-readable title for the tool.
82010
81424
  */
@@ -82043,7 +81457,7 @@ var ToolAnnotationsSchema = object2({
82043
81457
  */
82044
81458
  openWorldHint: boolean2().optional()
82045
81459
  });
82046
- var ToolExecutionSchema = object2({
81460
+ var ToolExecutionSchema = object({
82047
81461
  /**
82048
81462
  * Indicates the tool's preference for task-augmented execution.
82049
81463
  * - "required": Clients MUST invoke the tool as a task
@@ -82054,7 +81468,7 @@ var ToolExecutionSchema = object2({
82054
81468
  */
82055
81469
  taskSupport: _enum2(["required", "optional", "forbidden"]).optional()
82056
81470
  });
82057
- var ToolSchema = object2({
81471
+ var ToolSchema = object({
82058
81472
  ...BaseMetadataSchema.shape,
82059
81473
  ...IconsSchema.shape,
82060
81474
  /**
@@ -82065,7 +81479,7 @@ var ToolSchema = object2({
82065
81479
  * A JSON Schema 2020-12 object defining the expected parameters for the tool.
82066
81480
  * Must have type: 'object' at the root level per MCP spec.
82067
81481
  */
82068
- inputSchema: object2({
81482
+ inputSchema: object({
82069
81483
  type: literal("object"),
82070
81484
  properties: record(string2(), AssertObjectSchema).optional(),
82071
81485
  required: array(string2()).optional()
@@ -82075,7 +81489,7 @@ var ToolSchema = object2({
82075
81489
  * returned in the structuredContent field of a CallToolResult.
82076
81490
  * Must have type: 'object' at the root level per MCP spec.
82077
81491
  */
82078
- outputSchema: object2({
81492
+ outputSchema: object({
82079
81493
  type: literal("object"),
82080
81494
  properties: record(string2(), AssertObjectSchema).optional(),
82081
81495
  required: array(string2()).optional()
@@ -82151,7 +81565,7 @@ var ToolListChangedNotificationSchema = NotificationSchema.extend({
82151
81565
  method: literal("notifications/tools/list_changed"),
82152
81566
  params: NotificationsParamsSchema.optional()
82153
81567
  });
82154
- var ListChangedOptionsBaseSchema = object2({
81568
+ var ListChangedOptionsBaseSchema = object({
82155
81569
  /**
82156
81570
  * If true, the list will be refreshed automatically when a list changed notification is received.
82157
81571
  * The callback will be called with the updated list.
@@ -82200,13 +81614,13 @@ var LoggingMessageNotificationSchema = NotificationSchema.extend({
82200
81614
  method: literal("notifications/message"),
82201
81615
  params: LoggingMessageNotificationParamsSchema
82202
81616
  });
82203
- var ModelHintSchema = object2({
81617
+ var ModelHintSchema = object({
82204
81618
  /**
82205
81619
  * A hint for a model name.
82206
81620
  */
82207
81621
  name: string2().optional()
82208
81622
  });
82209
- var ModelPreferencesSchema = object2({
81623
+ var ModelPreferencesSchema = object({
82210
81624
  /**
82211
81625
  * Optional hints to use for model selection.
82212
81626
  */
@@ -82224,7 +81638,7 @@ var ModelPreferencesSchema = object2({
82224
81638
  */
82225
81639
  intelligencePriority: number2().min(0).max(1).optional()
82226
81640
  });
82227
- var ToolChoiceSchema = object2({
81641
+ var ToolChoiceSchema = object({
82228
81642
  /**
82229
81643
  * Controls when tools are used:
82230
81644
  * - "auto": Model decides whether to use tools (default)
@@ -82233,11 +81647,11 @@ var ToolChoiceSchema = object2({
82233
81647
  */
82234
81648
  mode: _enum2(["auto", "required", "none"]).optional()
82235
81649
  });
82236
- var ToolResultContentSchema = object2({
81650
+ var ToolResultContentSchema = object({
82237
81651
  type: literal("tool_result"),
82238
81652
  toolUseId: string2().describe("The unique identifier for the corresponding tool call."),
82239
81653
  content: array(ContentBlockSchema).default([]),
82240
- structuredContent: object2({}).loose().optional(),
81654
+ structuredContent: object({}).loose().optional(),
82241
81655
  isError: boolean2().optional(),
82242
81656
  /**
82243
81657
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
@@ -82253,7 +81667,7 @@ var SamplingMessageContentBlockSchema = discriminatedUnion("type", [
82253
81667
  ToolUseContentSchema,
82254
81668
  ToolResultContentSchema
82255
81669
  ]);
82256
- var SamplingMessageSchema = object2({
81670
+ var SamplingMessageSchema = object({
82257
81671
  role: RoleSchema,
82258
81672
  content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)]),
82259
81673
  /**
@@ -82353,13 +81767,13 @@ var CreateMessageResultWithToolsSchema = ResultSchema.extend({
82353
81767
  */
82354
81768
  content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)])
82355
81769
  });
82356
- var BooleanSchemaSchema = object2({
81770
+ var BooleanSchemaSchema = object({
82357
81771
  type: literal("boolean"),
82358
81772
  title: string2().optional(),
82359
81773
  description: string2().optional(),
82360
81774
  default: boolean2().optional()
82361
81775
  });
82362
- var StringSchemaSchema = object2({
81776
+ var StringSchemaSchema = object({
82363
81777
  type: literal("string"),
82364
81778
  title: string2().optional(),
82365
81779
  description: string2().optional(),
@@ -82368,7 +81782,7 @@ var StringSchemaSchema = object2({
82368
81782
  format: _enum2(["email", "uri", "date", "date-time"]).optional(),
82369
81783
  default: string2().optional()
82370
81784
  });
82371
- var NumberSchemaSchema = object2({
81785
+ var NumberSchemaSchema = object({
82372
81786
  type: _enum2(["number", "integer"]),
82373
81787
  title: string2().optional(),
82374
81788
  description: string2().optional(),
@@ -82376,24 +81790,24 @@ var NumberSchemaSchema = object2({
82376
81790
  maximum: number2().optional(),
82377
81791
  default: number2().optional()
82378
81792
  });
82379
- var UntitledSingleSelectEnumSchemaSchema = object2({
81793
+ var UntitledSingleSelectEnumSchemaSchema = object({
82380
81794
  type: literal("string"),
82381
81795
  title: string2().optional(),
82382
81796
  description: string2().optional(),
82383
81797
  enum: array(string2()),
82384
81798
  default: string2().optional()
82385
81799
  });
82386
- var TitledSingleSelectEnumSchemaSchema = object2({
81800
+ var TitledSingleSelectEnumSchemaSchema = object({
82387
81801
  type: literal("string"),
82388
81802
  title: string2().optional(),
82389
81803
  description: string2().optional(),
82390
- oneOf: array(object2({
81804
+ oneOf: array(object({
82391
81805
  const: string2(),
82392
81806
  title: string2()
82393
81807
  })),
82394
81808
  default: string2().optional()
82395
81809
  });
82396
- var LegacyTitledEnumSchemaSchema = object2({
81810
+ var LegacyTitledEnumSchemaSchema = object({
82397
81811
  type: literal("string"),
82398
81812
  title: string2().optional(),
82399
81813
  description: string2().optional(),
@@ -82402,26 +81816,26 @@ var LegacyTitledEnumSchemaSchema = object2({
82402
81816
  default: string2().optional()
82403
81817
  });
82404
81818
  var SingleSelectEnumSchemaSchema = union([UntitledSingleSelectEnumSchemaSchema, TitledSingleSelectEnumSchemaSchema]);
82405
- var UntitledMultiSelectEnumSchemaSchema = object2({
81819
+ var UntitledMultiSelectEnumSchemaSchema = object({
82406
81820
  type: literal("array"),
82407
81821
  title: string2().optional(),
82408
81822
  description: string2().optional(),
82409
81823
  minItems: number2().optional(),
82410
81824
  maxItems: number2().optional(),
82411
- items: object2({
81825
+ items: object({
82412
81826
  type: literal("string"),
82413
81827
  enum: array(string2())
82414
81828
  }),
82415
81829
  default: array(string2()).optional()
82416
81830
  });
82417
- var TitledMultiSelectEnumSchemaSchema = object2({
81831
+ var TitledMultiSelectEnumSchemaSchema = object({
82418
81832
  type: literal("array"),
82419
81833
  title: string2().optional(),
82420
81834
  description: string2().optional(),
82421
81835
  minItems: number2().optional(),
82422
81836
  maxItems: number2().optional(),
82423
- items: object2({
82424
- anyOf: array(object2({
81837
+ items: object({
81838
+ anyOf: array(object({
82425
81839
  const: string2(),
82426
81840
  title: string2()
82427
81841
  }))
@@ -82446,7 +81860,7 @@ var ElicitRequestFormParamsSchema = TaskAugmentedRequestParamsSchema.extend({
82446
81860
  * A restricted subset of JSON Schema.
82447
81861
  * Only top-level properties are allowed, without nesting.
82448
81862
  */
82449
- requestedSchema: object2({
81863
+ requestedSchema: object({
82450
81864
  type: literal("object"),
82451
81865
  properties: record(string2(), PrimitiveSchemaDefinitionSchema),
82452
81866
  required: array(string2()).optional()
@@ -82502,14 +81916,14 @@ var ElicitResultSchema = ResultSchema.extend({
82502
81916
  */
82503
81917
  content: preprocess((val) => val === null ? void 0 : val, record(string2(), union([string2(), number2(), boolean2(), array(string2())])).optional())
82504
81918
  });
82505
- var ResourceTemplateReferenceSchema = object2({
81919
+ var ResourceTemplateReferenceSchema = object({
82506
81920
  type: literal("ref/resource"),
82507
81921
  /**
82508
81922
  * The URI or URI template of the resource.
82509
81923
  */
82510
81924
  uri: string2()
82511
81925
  });
82512
- var PromptReferenceSchema = object2({
81926
+ var PromptReferenceSchema = object({
82513
81927
  type: literal("ref/prompt"),
82514
81928
  /**
82515
81929
  * The name of the prompt or prompt template
@@ -82521,7 +81935,7 @@ var CompleteRequestParamsSchema = BaseRequestParamsSchema.extend({
82521
81935
  /**
82522
81936
  * The argument's information
82523
81937
  */
82524
- argument: object2({
81938
+ argument: object({
82525
81939
  /**
82526
81940
  * The name of the argument
82527
81941
  */
@@ -82531,7 +81945,7 @@ var CompleteRequestParamsSchema = BaseRequestParamsSchema.extend({
82531
81945
  */
82532
81946
  value: string2()
82533
81947
  }),
82534
- context: object2({
81948
+ context: object({
82535
81949
  /**
82536
81950
  * Previously-resolved variables in a URI template or prompt.
82537
81951
  */
@@ -82558,7 +81972,7 @@ var CompleteResultSchema = ResultSchema.extend({
82558
81972
  hasMore: optional(boolean2())
82559
81973
  })
82560
81974
  });
82561
- var RootSchema = object2({
81975
+ var RootSchema = object({
82562
81976
  /**
82563
81977
  * The URI identifying the root. This *must* start with file:// for now.
82564
81978
  */
@@ -82673,20 +82087,831 @@ var McpError = class _McpError extends Error {
82673
82087
  return new UrlElicitationRequiredError(errorData.elicitations, message);
82674
82088
  }
82675
82089
  }
82676
- return new _McpError(code, message, data);
82090
+ return new _McpError(code, message, data);
82091
+ }
82092
+ };
82093
+ var UrlElicitationRequiredError = class extends McpError {
82094
+ constructor(elicitations, message = `URL elicitation${elicitations.length > 1 ? "s" : ""} required`) {
82095
+ super(ErrorCode.UrlElicitationRequired, message, {
82096
+ elicitations
82097
+ });
82098
+ }
82099
+ get elicitations() {
82100
+ return this.data?.elicitations ?? [];
82101
+ }
82102
+ };
82103
+
82104
+ // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
82105
+ var STDIO_DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
82106
+ var ReadBuffer = class {
82107
+ constructor(options) {
82108
+ this._maxBufferSize = options?.maxBufferSize ?? STDIO_DEFAULT_MAX_BUFFER_SIZE;
82109
+ }
82110
+ append(chunk) {
82111
+ const newSize = (this._buffer?.length ?? 0) + chunk.length;
82112
+ if (newSize > this._maxBufferSize) {
82113
+ this.clear();
82114
+ throw new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);
82115
+ }
82116
+ this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
82117
+ }
82118
+ readMessage() {
82119
+ if (!this._buffer) {
82120
+ return null;
82121
+ }
82122
+ const index = this._buffer.indexOf("\n");
82123
+ if (index === -1) {
82124
+ return null;
82125
+ }
82126
+ const line = this._buffer.toString("utf8", 0, index).replace(/\r$/, "");
82127
+ this._buffer = this._buffer.subarray(index + 1);
82128
+ return deserializeMessage(line);
82129
+ }
82130
+ clear() {
82131
+ this._buffer = void 0;
82132
+ }
82133
+ };
82134
+ function deserializeMessage(line) {
82135
+ return JSONRPCMessageSchema.parse(JSON.parse(line));
82136
+ }
82137
+ function serializeMessage(message) {
82138
+ return JSON.stringify(message) + "\n";
82139
+ }
82140
+
82141
+ // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
82142
+ var DEFAULT_INHERITED_ENV_VARS = process2.platform === "win32" ? [
82143
+ "APPDATA",
82144
+ "HOMEDRIVE",
82145
+ "HOMEPATH",
82146
+ "LOCALAPPDATA",
82147
+ "PATH",
82148
+ "PROCESSOR_ARCHITECTURE",
82149
+ "SYSTEMDRIVE",
82150
+ "SYSTEMROOT",
82151
+ "TEMP",
82152
+ "USERNAME",
82153
+ "USERPROFILE",
82154
+ "PROGRAMFILES"
82155
+ ] : (
82156
+ /* list inspired by the default env inheritance of sudo */
82157
+ ["HOME", "LOGNAME", "PATH", "SHELL", "TERM", "USER"]
82158
+ );
82159
+ function getDefaultEnvironment() {
82160
+ const env = {};
82161
+ for (const key of DEFAULT_INHERITED_ENV_VARS) {
82162
+ const value = process2.env[key];
82163
+ if (value === void 0) {
82164
+ continue;
82165
+ }
82166
+ if (value.startsWith("()")) {
82167
+ continue;
82168
+ }
82169
+ env[key] = value;
82170
+ }
82171
+ return env;
82172
+ }
82173
+ var StdioClientTransport = class {
82174
+ constructor(server) {
82175
+ this._stderrStream = null;
82176
+ this._serverParams = server;
82177
+ this._readBuffer = new ReadBuffer({ maxBufferSize: server.maxBufferSize });
82178
+ if (server.stderr === "pipe" || server.stderr === "overlapped") {
82179
+ this._stderrStream = new PassThrough();
82180
+ }
82181
+ }
82182
+ /**
82183
+ * Starts the server process and prepares to communicate with it.
82184
+ */
82185
+ async start() {
82186
+ if (this._process) {
82187
+ throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
82188
+ }
82189
+ return new Promise((resolve4, reject) => {
82190
+ this._process = (0, import_cross_spawn.default)(this._serverParams.command, this._serverParams.args ?? [], {
82191
+ // merge default env with server env because mcp server needs some env vars
82192
+ env: {
82193
+ ...getDefaultEnvironment(),
82194
+ ...this._serverParams.env
82195
+ },
82196
+ stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
82197
+ shell: false,
82198
+ windowsHide: process2.platform === "win32",
82199
+ cwd: this._serverParams.cwd
82200
+ });
82201
+ this._process.on("error", (error62) => {
82202
+ reject(error62);
82203
+ this.onerror?.(error62);
82204
+ });
82205
+ this._process.on("spawn", () => {
82206
+ resolve4();
82207
+ });
82208
+ this._process.on("close", (_code) => {
82209
+ this._process = void 0;
82210
+ this.onclose?.();
82211
+ });
82212
+ this._process.stdin?.on("error", (error62) => {
82213
+ this.onerror?.(error62);
82214
+ });
82215
+ this._process.stdout?.on("data", (chunk) => {
82216
+ try {
82217
+ this._readBuffer.append(chunk);
82218
+ this.processReadBuffer();
82219
+ } catch (error62) {
82220
+ this.onerror?.(error62);
82221
+ this.close().catch(() => {
82222
+ });
82223
+ }
82224
+ });
82225
+ this._process.stdout?.on("error", (error62) => {
82226
+ this.onerror?.(error62);
82227
+ });
82228
+ if (this._stderrStream && this._process.stderr) {
82229
+ this._process.stderr.pipe(this._stderrStream);
82230
+ }
82231
+ });
82232
+ }
82233
+ /**
82234
+ * The stderr stream of the child process, if `StdioServerParameters.stderr` was set to "pipe" or "overlapped".
82235
+ *
82236
+ * If stderr piping was requested, a PassThrough stream is returned _immediately_, allowing callers to
82237
+ * attach listeners before the start method is invoked. This prevents loss of any early
82238
+ * error output emitted by the child process.
82239
+ */
82240
+ get stderr() {
82241
+ if (this._stderrStream) {
82242
+ return this._stderrStream;
82243
+ }
82244
+ return this._process?.stderr ?? null;
82245
+ }
82246
+ /**
82247
+ * The child process pid spawned by this transport.
82248
+ *
82249
+ * This is only available after the transport has been started.
82250
+ */
82251
+ get pid() {
82252
+ return this._process?.pid ?? null;
82253
+ }
82254
+ processReadBuffer() {
82255
+ while (true) {
82256
+ try {
82257
+ const message = this._readBuffer.readMessage();
82258
+ if (message === null) {
82259
+ break;
82260
+ }
82261
+ this.onmessage?.(message);
82262
+ } catch (error62) {
82263
+ this.onerror?.(error62);
82264
+ }
82265
+ }
82266
+ }
82267
+ async close() {
82268
+ if (this._process) {
82269
+ const processToClose = this._process;
82270
+ this._process = void 0;
82271
+ const closePromise = new Promise((resolve4) => {
82272
+ processToClose.once("close", () => {
82273
+ resolve4();
82274
+ });
82275
+ });
82276
+ try {
82277
+ processToClose.stdin?.end();
82278
+ } catch {
82279
+ }
82280
+ await Promise.race([closePromise, new Promise((resolve4) => setTimeout(resolve4, 2e3).unref())]);
82281
+ if (processToClose.exitCode === null) {
82282
+ try {
82283
+ processToClose.kill("SIGTERM");
82284
+ } catch {
82285
+ }
82286
+ await Promise.race([closePromise, new Promise((resolve4) => setTimeout(resolve4, 2e3).unref())]);
82287
+ }
82288
+ if (processToClose.exitCode === null) {
82289
+ try {
82290
+ processToClose.kill("SIGKILL");
82291
+ } catch {
82292
+ }
82293
+ }
82294
+ }
82295
+ this._readBuffer.clear();
82296
+ }
82297
+ send(message) {
82298
+ return new Promise((resolve4) => {
82299
+ if (!this._process?.stdin) {
82300
+ throw new Error("Not connected");
82301
+ }
82302
+ const json2 = serializeMessage(message);
82303
+ if (this._process.stdin.write(json2)) {
82304
+ resolve4();
82305
+ } else {
82306
+ this._process.stdin.once("drain", resolve4);
82307
+ }
82308
+ });
82309
+ }
82310
+ };
82311
+
82312
+ // src/mcp/env.ts
82313
+ function envFingerprint(env) {
82314
+ if (env == null) return null;
82315
+ const names = Object.keys(env);
82316
+ if (names.length === 0) return null;
82317
+ const pairs = names.sort().map((n) => [n, env[n]]);
82318
+ return createHash3("sha256").update(canonicalJson(pairs)).digest("hex");
82319
+ }
82320
+
82321
+ // src/mcp/registry-store.ts
82322
+ import { join as join2 } from "node:path";
82323
+ function mcpStateDir() {
82324
+ return join2(crewStateHome(), "mcp");
82325
+ }
82326
+
82327
+ // src/mcp/rest.ts
82328
+ var import_yaml = __toESM(require_dist(), 1);
82329
+ var REST_SPEC_TIMEOUT_MS = 1e4;
82330
+ var REST_SPEC_MAX_BYTES = 1024 * 1024;
82331
+ var REST_RESPONSE_MAX_BYTES = 1024 * 1024;
82332
+ var REST_DEFAULT_TIMEOUT_MS = 3e4;
82333
+ var MAX_TOOLS = 512;
82334
+ var MAX_REF_DEPTH = 32;
82335
+ var TOOL_NAME_MAX = 64;
82336
+ var METHODS = ["get", "head", "options", "post", "put", "patch", "delete"];
82337
+ var FORBIDDEN_HEADERS = /* @__PURE__ */ new Set([
82338
+ "authorization",
82339
+ "proxy-authorization",
82340
+ "cookie",
82341
+ "host",
82342
+ "content-length",
82343
+ "content-type",
82344
+ "transfer-encoding",
82345
+ "connection",
82346
+ "keep-alive",
82347
+ "upgrade",
82348
+ "te",
82349
+ "trailer",
82350
+ "expect",
82351
+ "forwarded",
82352
+ "x-forwarded-for",
82353
+ "x-forwarded-host",
82354
+ "x-forwarded-proto"
82355
+ ]);
82356
+ var RestBoundaryError = class extends UpstreamCallError {
82357
+ constructor(message) {
82358
+ super("boundary", false, message);
82359
+ }
82360
+ };
82361
+ function parseBaseUrl(raw) {
82362
+ if (raw === null) return null;
82363
+ let u;
82364
+ try {
82365
+ u = new URL(raw);
82366
+ } catch {
82367
+ return null;
82368
+ }
82369
+ if (u.protocol !== "https:" && u.protocol !== "http:") return null;
82370
+ if (u.username !== "" || u.password !== "" || u.search !== "" || u.hash !== "") return null;
82371
+ return u;
82372
+ }
82373
+ function basePath(base2) {
82374
+ return base2.pathname.replace(/\/+$/, "");
82375
+ }
82376
+ function restTarget(config2) {
82377
+ const base2 = parseBaseUrl(config2.url);
82378
+ if (base2 === null) return null;
82379
+ return { origin: base2.origin, basePath: basePath(base2), authHeader: config2.auth?.header?.toLowerCase() ?? null };
82380
+ }
82381
+ function specServers(doc, specUrl) {
82382
+ const raw = Array.isArray(doc["servers"]) && doc["servers"].length > 0 ? doc["servers"] : [{ url: "/" }];
82383
+ const out = [];
82384
+ for (const s2 of raw) {
82385
+ if (s2 === null || typeof s2 !== "object" || Array.isArray(s2)) continue;
82386
+ const entry = s2;
82387
+ if (typeof entry["url"] !== "string") continue;
82388
+ const vars = entry["variables"] !== null && typeof entry["variables"] === "object" ? entry["variables"] : {};
82389
+ let unresolved = false;
82390
+ const filled = entry["url"].replace(/\{([^{}]+)\}/g, (_m, name) => {
82391
+ const v = vars[name];
82392
+ const dflt = v !== null && typeof v === "object" ? v["default"] : void 0;
82393
+ if (typeof dflt !== "string") {
82394
+ unresolved = true;
82395
+ return "";
82396
+ }
82397
+ return dflt;
82398
+ });
82399
+ if (unresolved) continue;
82400
+ let u;
82401
+ try {
82402
+ u = specUrl === null ? new URL(filled) : new URL(filled, specUrl);
82403
+ } catch {
82404
+ continue;
82405
+ }
82406
+ if (u.protocol === "https:" || u.protocol === "http:") out.push(u);
82407
+ }
82408
+ return out;
82409
+ }
82410
+ function restEgress(base2, doc, specUrl, target) {
82411
+ const servers = specServers(doc, specUrl);
82412
+ const path = basePath(base2);
82413
+ const matches = servers.some((s2) => {
82414
+ const prefix = basePath(s2);
82415
+ return s2.origin === base2.origin && (prefix === "" || path === prefix || path.startsWith(`${prefix}/`));
82416
+ });
82417
+ const privateAddress = (target.addresses ?? [target]).some((a) => a.cls !== "global");
82418
+ return { origin: base2.origin, basePath: path, servers: servers.map((s2) => s2.href), matches, privateAddress, resolved: true };
82419
+ }
82420
+ function pinnedUrl(base2, pathTemplate, values2) {
82421
+ let missing = null;
82422
+ const filled = pathTemplate.replace(/\{([^{}]+)\}/g, (_m, name) => {
82423
+ const v = values2[name];
82424
+ if (v === void 0) {
82425
+ missing ??= name;
82426
+ return "";
82427
+ }
82428
+ if (v === "." || v === ".." || v === "") throw new RestBoundaryError(`the path value for {${name}} (${JSON.stringify(v)}) would move the request off its path`);
82429
+ return encodeURIComponent(v);
82430
+ });
82431
+ if (missing !== null) throw new UpstreamCallError("protocol", false, `the path variable {${missing}} has no value`);
82432
+ if (!filled.startsWith("/")) throw new RestBoundaryError(`the path ${JSON.stringify(pathTemplate)} does not start with /`);
82433
+ const url2 = new URL(base2.href);
82434
+ const prefix = basePath(base2);
82435
+ url2.pathname = `${prefix}${filled}`;
82436
+ const escape3 = boundaryEscape(base2, url2);
82437
+ if (escape3 !== null) throw new RestBoundaryError(escape3);
82438
+ return url2;
82439
+ }
82440
+ function boundaryEscape(base2, url2) {
82441
+ if (url2.origin !== base2.origin) return `the request to ${url2.origin} leaves the pinned host ${base2.origin}`;
82442
+ const prefix = basePath(base2);
82443
+ if (prefix !== "" && url2.pathname !== prefix && !url2.pathname.startsWith(`${prefix}/`)) {
82444
+ return `the request path ${url2.pathname} leaves the pinned base path ${prefix}`;
82445
+ }
82446
+ return null;
82447
+ }
82448
+ function isObj(v) {
82449
+ return v !== null && typeof v === "object" && !Array.isArray(v);
82450
+ }
82451
+ function pointer(doc, ref) {
82452
+ if (!ref.startsWith("#/")) return void 0;
82453
+ let cur = doc;
82454
+ for (const raw of ref.slice(2).split("/")) {
82455
+ const key = raw.replace(/~1/g, "/").replace(/~0/g, "~");
82456
+ if (!isObj(cur) && !Array.isArray(cur)) return void 0;
82457
+ cur = cur[key];
82458
+ }
82459
+ return cur;
82460
+ }
82461
+ function derefLocal(doc, value, seen = [], depth = 0) {
82462
+ if (depth > MAX_REF_DEPTH) return {};
82463
+ if (Array.isArray(value)) return value.map((v) => derefLocal(doc, v, seen, depth + 1));
82464
+ if (!isObj(value)) return value;
82465
+ const ref = value["$ref"];
82466
+ if (typeof ref === "string") {
82467
+ if (seen.includes(ref)) return {};
82468
+ const target = pointer(doc, ref);
82469
+ if (target === void 0) return {};
82470
+ return derefLocal(doc, target, [...seen, ref], depth + 1);
82471
+ }
82472
+ const out = {};
82473
+ for (const [k, v] of Object.entries(value)) out[k] = derefLocal(doc, v, seen, depth + 1);
82474
+ return out;
82475
+ }
82476
+ function parseOpenApiText(text2) {
82477
+ let parsed;
82478
+ try {
82479
+ parsed = JSON.parse(text2);
82480
+ } catch {
82481
+ try {
82482
+ parsed = (0, import_yaml.parse)(text2, { maxAliasCount: 100 });
82483
+ } catch (err) {
82484
+ throw new Error(`the OpenAPI document is neither JSON nor YAML: ${err instanceof Error ? err.message : String(err)}`);
82485
+ }
82486
+ }
82487
+ if (!isObj(parsed)) throw new Error("the OpenAPI document is not an object");
82488
+ return parsed;
82489
+ }
82490
+ function toolNameFor(method, path, operationId) {
82491
+ const raw = typeof operationId === "string" && operationId.trim() !== "" ? operationId : `${method}_${path}`;
82492
+ const name = raw.replace(/[^A-Za-z0-9_-]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "").slice(0, TOOL_NAME_MAX);
82493
+ return name === "" ? method : name;
82494
+ }
82495
+ function annotationsForMethod(method) {
82496
+ switch (method) {
82497
+ case "GET":
82498
+ case "HEAD":
82499
+ case "OPTIONS":
82500
+ return { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true };
82501
+ case "POST":
82502
+ return { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true };
82503
+ case "PUT":
82504
+ return { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: true };
82505
+ case "PATCH":
82506
+ case "DELETE":
82507
+ return { readOnlyHint: false, destructiveHint: true, idempotentHint: method === "DELETE", openWorldHint: true };
82508
+ }
82509
+ }
82510
+ function paramsOf(doc, pathItem, op) {
82511
+ const merged = /* @__PURE__ */ new Map();
82512
+ for (const list of [pathItem["parameters"], op["parameters"]]) {
82513
+ if (!Array.isArray(list)) continue;
82514
+ for (const rawParam of list) {
82515
+ const p = derefLocal(doc, rawParam);
82516
+ if (!isObj(p) || typeof p["name"] !== "string" || p["name"] === "") continue;
82517
+ const where = p["in"];
82518
+ if (where !== "path" && where !== "query" && where !== "header") continue;
82519
+ merged.set(`${where}:${where === "header" ? p["name"].toLowerCase() : p["name"]}`, {
82520
+ name: p["name"],
82521
+ in: where,
82522
+ required: where === "path" || p["required"] === true,
82523
+ schema: isObj(p["schema"]) ? p["schema"] : { type: "string" },
82524
+ description: typeof p["description"] === "string" ? p["description"] : null
82525
+ });
82526
+ }
82527
+ }
82528
+ return [...merged.values()];
82529
+ }
82530
+ function jsonBodyOf(doc, op) {
82531
+ const body = derefLocal(doc, op["requestBody"]);
82532
+ if (!isObj(body)) return null;
82533
+ const content = body["content"];
82534
+ if (!isObj(content)) return null;
82535
+ const key = Object.keys(content).find((k) => /^application\/(?:[\w.+-]+\+)?json\b/i.test(k));
82536
+ if (key === void 0) return Object.keys(content).length === 0 ? null : "unsupported";
82537
+ const media = content[key];
82538
+ const schema = isObj(media) && isObj(media["schema"]) ? media["schema"] : {};
82539
+ return { schema, required: body["required"] === true };
82540
+ }
82541
+ function importOpenApi(doc, opts = {}) {
82542
+ const version2 = doc["openapi"];
82543
+ if (typeof version2 !== "string" || !version2.startsWith("3.")) {
82544
+ throw new Error('only OpenAPI 3.x documents are supported (the document has no "openapi": "3.x" field)');
82545
+ }
82546
+ const paths = doc["paths"];
82547
+ if (!isObj(paths)) throw new Error("the OpenAPI document has no paths");
82548
+ const forbidden = new Set(FORBIDDEN_HEADERS);
82549
+ if (opts.authHeader !== void 0) forbidden.add(opts.authHeader.toLowerCase());
82550
+ const wanted = opts.operations === void 0 || opts.operations === null ? null : new Set(opts.operations);
82551
+ const matched = /* @__PURE__ */ new Set();
82552
+ const used = /* @__PURE__ */ new Set();
82553
+ const tools = [];
82554
+ const skipped = [];
82555
+ for (const [path, rawItem] of Object.entries(paths)) {
82556
+ const pathItem = derefLocal(doc, rawItem);
82557
+ if (!isObj(pathItem) || !path.startsWith("/")) continue;
82558
+ for (const m of METHODS) {
82559
+ const op = pathItem[m];
82560
+ if (!isObj(op)) continue;
82561
+ const method = m.toUpperCase();
82562
+ const opId = typeof op["operationId"] === "string" ? op["operationId"] : null;
82563
+ let name = toolNameFor(m, path, opId);
82564
+ if (wanted !== null) {
82565
+ const hit = [opId, name].find((n) => n !== null && wanted.has(n));
82566
+ if (hit === void 0) continue;
82567
+ matched.add(hit);
82568
+ }
82569
+ const label = `${method} ${path}`;
82570
+ if (tools.length >= MAX_TOOLS) {
82571
+ skipped.push(`${label}: more than ${MAX_TOOLS} operations`);
82572
+ continue;
82573
+ }
82574
+ const body = jsonBodyOf(doc, op);
82575
+ if (body === "unsupported") {
82576
+ skipped.push(`${label}: its request body is not JSON`);
82577
+ continue;
82578
+ }
82579
+ for (let n = 2; used.has(name); n++) name = `${toolNameFor(m, path, opId).slice(0, TOOL_NAME_MAX - 4)}_${n}`;
82580
+ const properties = {};
82581
+ const required2 = [];
82582
+ const mapping = {
82583
+ method,
82584
+ pathTemplate: path,
82585
+ pathMap: {},
82586
+ queryMap: {},
82587
+ headerMap: {},
82588
+ bodyMap: null,
82589
+ bodyArg: null,
82590
+ argAllowlist: [],
82591
+ timeoutMs: opts.timeoutMs ?? REST_DEFAULT_TIMEOUT_MS
82592
+ };
82593
+ const argName = (base2, where) => base2 in properties ? `${where}_${base2}` : base2;
82594
+ const templateVars = new Set([...path.matchAll(/\{([^{}]+)\}/g)].map((x) => x[1]));
82595
+ let unusable = null;
82596
+ for (const p of paramsOf(doc, pathItem, op)) {
82597
+ if (p.in === "header" && forbidden.has(p.name.toLowerCase())) continue;
82598
+ if (p.in === "path" && !templateVars.has(p.name)) continue;
82599
+ const arg = argName(p.name, p.in);
82600
+ if (arg in properties) continue;
82601
+ properties[arg] = derefLocal(doc, p.description === null ? p.schema : { ...p.schema, description: p.description });
82602
+ if (p.required) required2.push(arg);
82603
+ if (p.in === "path") mapping.pathMap[arg] = p.name;
82604
+ else if (p.in === "query") mapping.queryMap[arg] = p.name;
82605
+ else mapping.headerMap[arg] = p.name;
82606
+ }
82607
+ for (const v of templateVars) {
82608
+ if (!Object.values(mapping.pathMap).includes(v)) {
82609
+ const arg = argName(v, "path");
82610
+ if (arg in properties) {
82611
+ unusable = `its path variable {${v}} clashes with another argument`;
82612
+ break;
82613
+ }
82614
+ properties[arg] = { type: "string" };
82615
+ required2.push(arg);
82616
+ mapping.pathMap[arg] = v;
82617
+ }
82618
+ }
82619
+ if (unusable !== null) {
82620
+ skipped.push(`${label}: ${unusable}`);
82621
+ continue;
82622
+ }
82623
+ if (body !== null) {
82624
+ const schema = derefLocal(doc, body.schema);
82625
+ const props = isObj(schema["properties"]) ? schema["properties"] : null;
82626
+ const fieldsFit = schema["type"] === "object" && props !== null && Object.keys(props).length > 0 && Object.keys(props).every((k) => !(k in properties));
82627
+ if (fieldsFit && props !== null) {
82628
+ mapping.bodyMap = {};
82629
+ const bodyRequired = Array.isArray(schema["required"]) ? schema["required"].filter((x) => typeof x === "string") : [];
82630
+ for (const [k, s2] of Object.entries(props)) {
82631
+ properties[k] = s2;
82632
+ mapping.bodyMap[k] = k;
82633
+ if (body.required && bodyRequired.includes(k)) required2.push(k);
82634
+ }
82635
+ } else {
82636
+ const arg = argName("body", "request");
82637
+ properties[arg] = schema;
82638
+ mapping.bodyArg = arg;
82639
+ if (body.required) required2.push(arg);
82640
+ }
82641
+ }
82642
+ mapping.argAllowlist = Object.keys(properties).sort();
82643
+ const summary = typeof op["summary"] === "string" ? op["summary"] : typeof op["description"] === "string" ? op["description"] : "";
82644
+ const description = `${summary.trim().slice(0, 1024)}${summary.trim() === "" ? "" : " "}(${label})`;
82645
+ const annotations = annotationsForMethod(method);
82646
+ if (typeof op["summary"] === "string" && op["summary"].trim() !== "") annotations.title = op["summary"].trim().slice(0, 200);
82647
+ used.add(name);
82648
+ tools.push({
82649
+ name,
82650
+ description,
82651
+ inputSchema: { type: "object", properties, ...required2.length > 0 ? { required: required2 } : {}, additionalProperties: false },
82652
+ outputSchema: null,
82653
+ annotations,
82654
+ rest: mapping
82655
+ });
82656
+ }
82677
82657
  }
82678
- };
82679
- var UrlElicitationRequiredError = class extends McpError {
82680
- constructor(elicitations, message = `URL elicitation${elicitations.length > 1 ? "s" : ""} required`) {
82681
- super(ErrorCode.UrlElicitationRequired, message, {
82682
- elicitations
82683
- });
82658
+ if (wanted !== null) {
82659
+ const unknown2 = [...wanted].filter((w) => !matched.has(w));
82660
+ if (unknown2.length > 0) throw new Error(`operations names ${unknown2.map((u) => JSON.stringify(u)).join(", ")}, which the OpenAPI document does not have`);
82684
82661
  }
82685
- get elicitations() {
82686
- return this.data?.elicitations ?? [];
82662
+ if (tools.length === 0) throw new Error(skipped.length > 0 ? `no operation could be wrapped: ${skipped.join("; ")}` : "the OpenAPI document has no operations to wrap");
82663
+ const info = doc["info"];
82664
+ const serverInfo = isObj(info) && typeof info["title"] === "string" ? { name: info["title"].slice(0, 200), version: typeof info["version"] === "string" ? info["version"].slice(0, 64) : "" } : null;
82665
+ return { serverInfo, tools, skipped };
82666
+ }
82667
+ async function readCapped(res, max) {
82668
+ if (res.body === null) return { text: "", truncated: false };
82669
+ const reader = res.body.getReader();
82670
+ const chunks = [];
82671
+ let size2 = 0;
82672
+ let truncated = false;
82673
+ for (; ; ) {
82674
+ const { done, value } = await reader.read();
82675
+ if (done) break;
82676
+ if (size2 + value.byteLength > max) {
82677
+ chunks.push(value.subarray(0, max - size2));
82678
+ size2 = max;
82679
+ truncated = true;
82680
+ await reader.cancel().catch(() => void 0);
82681
+ break;
82682
+ }
82683
+ chunks.push(value);
82684
+ size2 += value.byteLength;
82685
+ }
82686
+ return { text: Buffer.concat(chunks).toString("utf8"), truncated };
82687
+ }
82688
+ function authHeaders(config2, secret) {
82689
+ if (config2.auth?.header === void 0 || secret === null) return {};
82690
+ return { [config2.auth.header]: `${config2.auth.prefix ?? ""}${secret}` };
82691
+ }
82692
+ function dialOf(config2, dial) {
82693
+ const resolver = dial.resolver ?? systemResolver;
82694
+ return { fetch: dial.fetch ?? boundFetch(addressPolicyOf(config2), { resolver }), resolver };
82695
+ }
82696
+ async function probeRestServer(config2, secret, dial = {}) {
82697
+ const secrets = secret === null ? [] : [secret];
82698
+ const { fetch: fetchImpl, resolver } = dialOf(config2, dial);
82699
+ try {
82700
+ const base2 = parseBaseUrl(config2.url);
82701
+ if (base2 === null) throw new Error("a rest server needs an http(s) base url with no credentials, query or fragment");
82702
+ const target = await resolveTarget(base2.hostname, addressPolicyOf(config2), resolver);
82703
+ checkScheme(base2, target, addressPolicyOf(config2));
82704
+ let doc;
82705
+ if (config2.openapi !== null && config2.openapi !== void 0) {
82706
+ doc = config2.openapi;
82707
+ } else if (config2.openapiUrl !== null && config2.openapiUrl !== void 0) {
82708
+ const specUrl = new URL(config2.openapiUrl);
82709
+ const headers = specUrl.origin === base2.origin ? authHeaders(config2, secret) : {};
82710
+ const res = await fetchImpl(specUrl, { headers: { accept: "application/json, application/yaml;q=0.9, */*;q=0.5", ...headers }, redirect: "error", signal: AbortSignal.timeout(REST_SPEC_TIMEOUT_MS) });
82711
+ if (!res.ok) throw new Error(`fetching the OpenAPI document answered HTTP ${res.status}`);
82712
+ const { text: text2, truncated } = await readCapped(res, REST_SPEC_MAX_BYTES + 1);
82713
+ if (truncated || Buffer.byteLength(text2, "utf8") > REST_SPEC_MAX_BYTES) throw new Error(`the OpenAPI document is larger than ${REST_SPEC_MAX_BYTES} bytes`);
82714
+ doc = parseOpenApiText(text2);
82715
+ } else {
82716
+ throw new Error("a rest server needs openapiUrl or openapi");
82717
+ }
82718
+ const imported = importOpenApi(doc, { authHeader: config2.auth?.header, operations: config2.operations ?? null });
82719
+ for (const t of imported.tools) {
82720
+ const sample = Object.fromEntries(Object.values(t.rest.pathMap).map((v) => [v, "x"]));
82721
+ pinnedUrl(base2, t.rest.pathTemplate, sample);
82722
+ }
82723
+ const egress = restEgress(base2, doc, config2.openapi !== null && config2.openapi !== void 0 ? null : config2.openapiUrl ?? null, target);
82724
+ return scrubSecrets({ ok: true, serverInfo: imported.serverInfo, tools: imported.tools, skipped: imported.skipped, egress }, secrets);
82725
+ } catch (err) {
82726
+ const message = err instanceof Error ? err.message : String(err);
82727
+ return scrubSecrets({ ok: false, error: message, ...err instanceof DialRefusedError ? { refusal: err.code } : {} }, secrets);
82728
+ }
82729
+ }
82730
+ function scalar(v, what) {
82731
+ if (typeof v === "string") return v;
82732
+ if (typeof v === "number" || typeof v === "boolean") return String(v);
82733
+ throw new UpstreamCallError("protocol", false, `${what} must be a string, number or boolean`);
82734
+ }
82735
+ function buildRestRequest(config2, secret, mapping, args) {
82736
+ const base2 = parseBaseUrl(config2.url);
82737
+ if (base2 === null) throw new RestBoundaryError("the server has no valid base url to pin the request to");
82738
+ const allowed = new Set(mapping.argAllowlist);
82739
+ const droppedArgs = Object.keys(args).filter((k) => !allowed.has(k)).sort();
82740
+ const sent = Object.fromEntries(Object.entries(args).filter(([k]) => allowed.has(k)));
82741
+ args = sent;
82742
+ const pathValues = {};
82743
+ for (const [arg, variable] of Object.entries(mapping.pathMap)) {
82744
+ if (args[arg] !== void 0) pathValues[variable] = scalar(args[arg], `the path argument ${arg}`);
82745
+ }
82746
+ const url2 = pinnedUrl(base2, mapping.pathTemplate, pathValues);
82747
+ for (const [arg, q] of Object.entries(mapping.queryMap)) {
82748
+ const v = args[arg];
82749
+ if (v === void 0 || v === null) continue;
82750
+ if (Array.isArray(v)) for (const item of v) url2.searchParams.append(q, scalar(item, `the query argument ${arg}`));
82751
+ else url2.searchParams.append(q, scalar(v, `the query argument ${arg}`));
82752
+ }
82753
+ const forbidden = new Set(FORBIDDEN_HEADERS);
82754
+ if (config2.auth?.header !== void 0) forbidden.add(config2.auth.header.toLowerCase());
82755
+ const headers = { accept: "application/json, */*;q=0.5" };
82756
+ for (const [arg, h] of Object.entries(mapping.headerMap)) {
82757
+ const v = args[arg];
82758
+ if (v === void 0 || v === null || forbidden.has(h.toLowerCase())) continue;
82759
+ const text2 = scalar(v, `the header argument ${arg}`);
82760
+ if (/[\r\n\0]/.test(text2)) throw new UpstreamCallError("protocol", false, `the header argument ${arg} must be one line`);
82761
+ if (Object.keys(headers).some((k) => k.toLowerCase() === h.toLowerCase())) continue;
82762
+ headers[h] = text2;
82763
+ }
82764
+ let body;
82765
+ if (mapping.bodyArg !== null && args[mapping.bodyArg] !== void 0) {
82766
+ body = JSON.stringify(args[mapping.bodyArg]);
82767
+ } else if (mapping.bodyMap !== null) {
82768
+ const obj = {};
82769
+ for (const [arg, key] of Object.entries(mapping.bodyMap)) if (args[arg] !== void 0) obj[key] = args[arg];
82770
+ if (Object.keys(obj).length > 0 || mapping.method === "POST" || mapping.method === "PUT" || mapping.method === "PATCH") body = JSON.stringify(obj);
82771
+ }
82772
+ if (body !== void 0) headers["content-type"] = "application/json";
82773
+ Object.assign(headers, authHeaders(config2, secret));
82774
+ return { url: url2, init: { method: mapping.method, headers, ...body !== void 0 ? { body } : {} }, droppedArgs };
82775
+ }
82776
+ async function invokeRestTool(config2, secret, mapping, args, timeoutMs, dial = {}, onDispatch) {
82777
+ const { url: url2, init, droppedArgs } = buildRestRequest(config2, secret, mapping, args);
82778
+ const deadline = Math.max(1, Math.min(timeoutMs, mapping.timeoutMs));
82779
+ const { fetch: fetchImpl } = dialOf(config2, dial);
82780
+ let res;
82781
+ try {
82782
+ onDispatch?.();
82783
+ res = await fetchImpl(url2, { ...init, redirect: "manual", signal: AbortSignal.timeout(deadline) });
82784
+ } catch (err) {
82785
+ if (err instanceof DialRedirectRefusedError) return refuseRedirect(config2, url2, err.status, err.location);
82786
+ if (err instanceof UpstreamCallError) throw err;
82787
+ const name = err instanceof Error ? err.name : "";
82788
+ if (name === "TimeoutError" || name === "AbortError") throw new UpstreamCallError("timeout", false, `timed out after ${Math.round(deadline / 1e3)} s`);
82789
+ throw new UpstreamCallError("transport", true, err instanceof Error ? err.message : String(err));
82790
+ }
82791
+ if (res.status >= 300 && res.status < 400) {
82792
+ await res.body?.cancel().catch(() => void 0);
82793
+ return refuseRedirect(config2, url2, res.status, res.headers.get("location"));
82794
+ }
82795
+ return readRestResult(res, droppedArgs);
82796
+ }
82797
+ function refuseRedirect(config2, url2, status, location) {
82798
+ let target = null;
82799
+ try {
82800
+ target = location === null ? null : new URL(location, url2);
82801
+ } catch {
82802
+ target = null;
82803
+ }
82804
+ const base2 = parseBaseUrl(config2.url);
82805
+ const escape3 = target !== null && base2 !== null ? boundaryEscape(base2, target) : null;
82806
+ if (escape3 !== null) throw new RestBoundaryError(`the API redirected off its pin (${escape3}); not followed`);
82807
+ throw new UpstreamCallError("http", false, `the API answered HTTP ${status} (a redirect); redirects are not followed`);
82808
+ }
82809
+ async function readRestResult(res, droppedArgs) {
82810
+ if (res.status === 429 || res.status >= 500) {
82811
+ await res.body?.cancel().catch(() => void 0);
82812
+ throw new UpstreamCallError("http", true, `the API answered HTTP ${res.status}`);
82813
+ }
82814
+ let read;
82815
+ try {
82816
+ read = await readCapped(res, REST_RESPONSE_MAX_BYTES);
82817
+ } catch (err) {
82818
+ if (res.status >= 400) throw new UpstreamCallError("http", false, `the API answered HTTP ${res.status} (its body could not be read)`);
82819
+ throw new UpstreamCallError("transport", true, `reading the response failed: ${err instanceof Error ? err.message : String(err)}`);
82820
+ }
82821
+ let structured;
82822
+ if (!read.truncated && /json/i.test(res.headers.get("content-type") ?? "")) {
82823
+ try {
82824
+ const parsed = JSON.parse(read.text);
82825
+ if (isObj(parsed)) structured = parsed;
82826
+ } catch {
82827
+ structured = void 0;
82828
+ }
82829
+ }
82830
+ return {
82831
+ content: [{ type: "text", text: read.text }],
82832
+ ...structured !== void 0 ? { structuredContent: structured } : {},
82833
+ isError: res.status >= 400,
82834
+ _meta: { "wicked/rest": { status: res.status, droppedArgs, truncated: read.truncated } }
82835
+ };
82836
+ }
82837
+
82838
+ // src/mcp/registry.ts
82839
+ var PREVIEW_TTL_MS = 15 * 60 * 1e3;
82840
+ var McpRegistryError = class extends Error {
82841
+ constructor(status, code, message, humanMessage) {
82842
+ super(message);
82843
+ this.status = status;
82844
+ this.code = code;
82845
+ this.humanMessage = humanMessage;
82687
82846
  }
82847
+ status;
82848
+ code;
82849
+ humanMessage;
82688
82850
  };
82689
82851
 
82852
+ // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
82853
+ function isZ4Schema(s2) {
82854
+ const schema = s2;
82855
+ return !!schema._zod;
82856
+ }
82857
+ function safeParse3(schema, data) {
82858
+ if (isZ4Schema(schema)) {
82859
+ const result2 = safeParse(schema, data);
82860
+ return result2;
82861
+ }
82862
+ const v3Schema = schema;
82863
+ const result = v3Schema.safeParse(data);
82864
+ return result;
82865
+ }
82866
+ function getObjectShape(schema) {
82867
+ if (!schema)
82868
+ return void 0;
82869
+ let rawShape2;
82870
+ if (isZ4Schema(schema)) {
82871
+ const v4Schema = schema;
82872
+ rawShape2 = v4Schema._zod?.def?.shape;
82873
+ } else {
82874
+ const v3Schema = schema;
82875
+ rawShape2 = v3Schema.shape;
82876
+ }
82877
+ if (!rawShape2)
82878
+ return void 0;
82879
+ if (typeof rawShape2 === "function") {
82880
+ try {
82881
+ return rawShape2();
82882
+ } catch {
82883
+ return void 0;
82884
+ }
82885
+ }
82886
+ return rawShape2;
82887
+ }
82888
+ function getLiteralValue(schema) {
82889
+ if (isZ4Schema(schema)) {
82890
+ const v4Schema = schema;
82891
+ const def2 = v4Schema._zod?.def;
82892
+ if (def2) {
82893
+ if (def2.value !== void 0)
82894
+ return def2.value;
82895
+ if (Array.isArray(def2.values) && def2.values.length > 0) {
82896
+ return def2.values[0];
82897
+ }
82898
+ }
82899
+ }
82900
+ const v3Schema = schema;
82901
+ const def = v3Schema._def;
82902
+ if (def) {
82903
+ if (def.value !== void 0)
82904
+ return def.value;
82905
+ if (Array.isArray(def.values) && def.values.length > 0) {
82906
+ return def.values[0];
82907
+ }
82908
+ }
82909
+ const directValue = schema.value;
82910
+ if (directValue !== void 0)
82911
+ return directValue;
82912
+ return void 0;
82913
+ }
82914
+
82690
82915
  // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
82691
82916
  function isTerminal(status) {
82692
82917
  return status === "completed" || status === "failed" || status === "cancelled";
@@ -82709,7 +82934,7 @@ function getMethodLiteral(schema) {
82709
82934
  return value;
82710
82935
  }
82711
82936
  function parseWithCompat(schema, data) {
82712
- const result = safeParse2(schema, data);
82937
+ const result = safeParse3(schema, data);
82713
82938
  if (!result.success) {
82714
82939
  throw result.error;
82715
82940
  }
@@ -83329,7 +83554,7 @@ var Protocol = class {
83329
83554
  return reject(response);
83330
83555
  }
83331
83556
  try {
83332
- const parseResult = safeParse2(resultSchema, response.result);
83557
+ const parseResult = safeParse3(resultSchema, response.result);
83333
83558
  if (!parseResult.success) {
83334
83559
  reject(parseResult.error);
83335
83560
  } else {
@@ -84077,7 +84302,7 @@ var Client = class extends Protocol {
84077
84302
  const method = methodValue;
84078
84303
  if (method === "elicitation/create") {
84079
84304
  const wrappedHandler = async (request, extra) => {
84080
- const validatedRequest = safeParse2(ElicitRequestSchema, request);
84305
+ const validatedRequest = safeParse3(ElicitRequestSchema, request);
84081
84306
  if (!validatedRequest.success) {
84082
84307
  const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
84083
84308
  throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation request: ${errorMessage}`);
@@ -84093,14 +84318,14 @@ var Client = class extends Protocol {
84093
84318
  }
84094
84319
  const result = await Promise.resolve(handler(request, extra));
84095
84320
  if (params.task) {
84096
- const taskValidationResult = safeParse2(CreateTaskResultSchema, result);
84321
+ const taskValidationResult = safeParse3(CreateTaskResultSchema, result);
84097
84322
  if (!taskValidationResult.success) {
84098
84323
  const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
84099
84324
  throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
84100
84325
  }
84101
84326
  return taskValidationResult.data;
84102
84327
  }
84103
- const validationResult = safeParse2(ElicitResultSchema, result);
84328
+ const validationResult = safeParse3(ElicitResultSchema, result);
84104
84329
  if (!validationResult.success) {
84105
84330
  const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
84106
84331
  throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation result: ${errorMessage}`);
@@ -84121,7 +84346,7 @@ var Client = class extends Protocol {
84121
84346
  }
84122
84347
  if (method === "sampling/createMessage") {
84123
84348
  const wrappedHandler = async (request, extra) => {
84124
- const validatedRequest = safeParse2(CreateMessageRequestSchema, request);
84349
+ const validatedRequest = safeParse3(CreateMessageRequestSchema, request);
84125
84350
  if (!validatedRequest.success) {
84126
84351
  const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
84127
84352
  throw new McpError(ErrorCode.InvalidParams, `Invalid sampling request: ${errorMessage}`);
@@ -84129,7 +84354,7 @@ var Client = class extends Protocol {
84129
84354
  const { params } = validatedRequest.data;
84130
84355
  const result = await Promise.resolve(handler(request, extra));
84131
84356
  if (params.task) {
84132
- const taskValidationResult = safeParse2(CreateTaskResultSchema, result);
84357
+ const taskValidationResult = safeParse3(CreateTaskResultSchema, result);
84133
84358
  if (!taskValidationResult.success) {
84134
84359
  const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
84135
84360
  throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
@@ -84138,7 +84363,7 @@ var Client = class extends Protocol {
84138
84363
  }
84139
84364
  const hasTools = params.tools || params.toolChoice;
84140
84365
  const resultSchema = hasTools ? CreateMessageResultWithToolsSchema : CreateMessageResultSchema;
84141
- const validationResult = safeParse2(resultSchema, result);
84366
+ const validationResult = safeParse3(resultSchema, result);
84142
84367
  if (!validationResult.success) {
84143
84368
  const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
84144
84369
  throw new McpError(ErrorCode.InvalidParams, `Invalid sampling result: ${errorMessage}`);
@@ -84699,13 +84924,13 @@ var OpenIdProviderMetadataSchema = looseObject({
84699
84924
  op_tos_uri: SafeUrlSchema.optional(),
84700
84925
  client_id_metadata_document_supported: boolean2().optional()
84701
84926
  });
84702
- var OpenIdProviderDiscoveryMetadataSchema = object2({
84927
+ var OpenIdProviderDiscoveryMetadataSchema = object({
84703
84928
  ...OpenIdProviderMetadataSchema.shape,
84704
84929
  ...OAuthMetadataSchema.pick({
84705
84930
  code_challenge_methods_supported: true
84706
84931
  }).shape
84707
84932
  });
84708
- var OAuthTokensSchema = object2({
84933
+ var OAuthTokensSchema = object({
84709
84934
  access_token: string2(),
84710
84935
  id_token: string2().optional(),
84711
84936
  // Optional for OAuth 2.1, but necessary in OpenID Connect
@@ -84719,13 +84944,13 @@ var OAuthTokensSchema = object2({
84719
84944
  */
84720
84945
  issuer: string2().optional().catch(void 0)
84721
84946
  }).strip();
84722
- var OAuthErrorResponseSchema = object2({
84947
+ var OAuthErrorResponseSchema = object({
84723
84948
  error: string2(),
84724
84949
  error_description: string2().optional(),
84725
84950
  error_uri: string2().optional()
84726
84951
  });
84727
84952
  var OptionalSafeUrlSchema = SafeUrlSchema.optional().or(literal("").transform(() => void 0));
84728
- var OAuthClientMetadataSchema = object2({
84953
+ var OAuthClientMetadataSchema = object({
84729
84954
  redirect_uris: array(SafeUrlSchema),
84730
84955
  token_endpoint_auth_method: string2().optional(),
84731
84956
  grant_types: array(string2()).optional(),
@@ -84743,7 +84968,7 @@ var OAuthClientMetadataSchema = object2({
84743
84968
  software_version: string2().optional(),
84744
84969
  software_statement: string2().optional()
84745
84970
  }).strip();
84746
- var OAuthClientInformationSchema = object2({
84971
+ var OAuthClientInformationSchema = object({
84747
84972
  client_id: string2(),
84748
84973
  client_secret: string2().optional(),
84749
84974
  client_id_issued_at: number2().optional(),
@@ -84755,11 +84980,11 @@ var OAuthClientInformationSchema = object2({
84755
84980
  issuer: string2().optional().catch(void 0)
84756
84981
  }).strip();
84757
84982
  var OAuthClientInformationFullSchema = OAuthClientMetadataSchema.merge(OAuthClientInformationSchema);
84758
- var OAuthClientRegistrationErrorSchema = object2({
84983
+ var OAuthClientRegistrationErrorSchema = object({
84759
84984
  error: string2(),
84760
84985
  error_description: string2().optional()
84761
84986
  }).strip();
84762
- var OAuthTokenRevocationRequestSchema = object2({
84987
+ var OAuthTokenRevocationRequestSchema = object({
84763
84988
  token: string2(),
84764
84989
  token_type_hint: string2().optional()
84765
84990
  }).strip();
@@ -86081,219 +86306,6 @@ var StreamableHTTPClientTransport = class {
86081
86306
  }
86082
86307
  };
86083
86308
 
86084
- // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
86085
- var import_cross_spawn = __toESM(require_cross_spawn(), 1);
86086
- import process2 from "node:process";
86087
- import { PassThrough } from "node:stream";
86088
-
86089
- // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
86090
- var STDIO_DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
86091
- var ReadBuffer = class {
86092
- constructor(options) {
86093
- this._maxBufferSize = options?.maxBufferSize ?? STDIO_DEFAULT_MAX_BUFFER_SIZE;
86094
- }
86095
- append(chunk) {
86096
- const newSize = (this._buffer?.length ?? 0) + chunk.length;
86097
- if (newSize > this._maxBufferSize) {
86098
- this.clear();
86099
- throw new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);
86100
- }
86101
- this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
86102
- }
86103
- readMessage() {
86104
- if (!this._buffer) {
86105
- return null;
86106
- }
86107
- const index = this._buffer.indexOf("\n");
86108
- if (index === -1) {
86109
- return null;
86110
- }
86111
- const line = this._buffer.toString("utf8", 0, index).replace(/\r$/, "");
86112
- this._buffer = this._buffer.subarray(index + 1);
86113
- return deserializeMessage(line);
86114
- }
86115
- clear() {
86116
- this._buffer = void 0;
86117
- }
86118
- };
86119
- function deserializeMessage(line) {
86120
- return JSONRPCMessageSchema.parse(JSON.parse(line));
86121
- }
86122
- function serializeMessage(message) {
86123
- return JSON.stringify(message) + "\n";
86124
- }
86125
-
86126
- // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
86127
- var DEFAULT_INHERITED_ENV_VARS = process2.platform === "win32" ? [
86128
- "APPDATA",
86129
- "HOMEDRIVE",
86130
- "HOMEPATH",
86131
- "LOCALAPPDATA",
86132
- "PATH",
86133
- "PROCESSOR_ARCHITECTURE",
86134
- "SYSTEMDRIVE",
86135
- "SYSTEMROOT",
86136
- "TEMP",
86137
- "USERNAME",
86138
- "USERPROFILE",
86139
- "PROGRAMFILES"
86140
- ] : (
86141
- /* list inspired by the default env inheritance of sudo */
86142
- ["HOME", "LOGNAME", "PATH", "SHELL", "TERM", "USER"]
86143
- );
86144
- function getDefaultEnvironment() {
86145
- const env = {};
86146
- for (const key of DEFAULT_INHERITED_ENV_VARS) {
86147
- const value = process2.env[key];
86148
- if (value === void 0) {
86149
- continue;
86150
- }
86151
- if (value.startsWith("()")) {
86152
- continue;
86153
- }
86154
- env[key] = value;
86155
- }
86156
- return env;
86157
- }
86158
- var StdioClientTransport = class {
86159
- constructor(server) {
86160
- this._stderrStream = null;
86161
- this._serverParams = server;
86162
- this._readBuffer = new ReadBuffer({ maxBufferSize: server.maxBufferSize });
86163
- if (server.stderr === "pipe" || server.stderr === "overlapped") {
86164
- this._stderrStream = new PassThrough();
86165
- }
86166
- }
86167
- /**
86168
- * Starts the server process and prepares to communicate with it.
86169
- */
86170
- async start() {
86171
- if (this._process) {
86172
- throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
86173
- }
86174
- return new Promise((resolve4, reject) => {
86175
- this._process = (0, import_cross_spawn.default)(this._serverParams.command, this._serverParams.args ?? [], {
86176
- // merge default env with server env because mcp server needs some env vars
86177
- env: {
86178
- ...getDefaultEnvironment(),
86179
- ...this._serverParams.env
86180
- },
86181
- stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
86182
- shell: false,
86183
- windowsHide: process2.platform === "win32",
86184
- cwd: this._serverParams.cwd
86185
- });
86186
- this._process.on("error", (error62) => {
86187
- reject(error62);
86188
- this.onerror?.(error62);
86189
- });
86190
- this._process.on("spawn", () => {
86191
- resolve4();
86192
- });
86193
- this._process.on("close", (_code) => {
86194
- this._process = void 0;
86195
- this.onclose?.();
86196
- });
86197
- this._process.stdin?.on("error", (error62) => {
86198
- this.onerror?.(error62);
86199
- });
86200
- this._process.stdout?.on("data", (chunk) => {
86201
- try {
86202
- this._readBuffer.append(chunk);
86203
- this.processReadBuffer();
86204
- } catch (error62) {
86205
- this.onerror?.(error62);
86206
- this.close().catch(() => {
86207
- });
86208
- }
86209
- });
86210
- this._process.stdout?.on("error", (error62) => {
86211
- this.onerror?.(error62);
86212
- });
86213
- if (this._stderrStream && this._process.stderr) {
86214
- this._process.stderr.pipe(this._stderrStream);
86215
- }
86216
- });
86217
- }
86218
- /**
86219
- * The stderr stream of the child process, if `StdioServerParameters.stderr` was set to "pipe" or "overlapped".
86220
- *
86221
- * If stderr piping was requested, a PassThrough stream is returned _immediately_, allowing callers to
86222
- * attach listeners before the start method is invoked. This prevents loss of any early
86223
- * error output emitted by the child process.
86224
- */
86225
- get stderr() {
86226
- if (this._stderrStream) {
86227
- return this._stderrStream;
86228
- }
86229
- return this._process?.stderr ?? null;
86230
- }
86231
- /**
86232
- * The child process pid spawned by this transport.
86233
- *
86234
- * This is only available after the transport has been started.
86235
- */
86236
- get pid() {
86237
- return this._process?.pid ?? null;
86238
- }
86239
- processReadBuffer() {
86240
- while (true) {
86241
- try {
86242
- const message = this._readBuffer.readMessage();
86243
- if (message === null) {
86244
- break;
86245
- }
86246
- this.onmessage?.(message);
86247
- } catch (error62) {
86248
- this.onerror?.(error62);
86249
- }
86250
- }
86251
- }
86252
- async close() {
86253
- if (this._process) {
86254
- const processToClose = this._process;
86255
- this._process = void 0;
86256
- const closePromise = new Promise((resolve4) => {
86257
- processToClose.once("close", () => {
86258
- resolve4();
86259
- });
86260
- });
86261
- try {
86262
- processToClose.stdin?.end();
86263
- } catch {
86264
- }
86265
- await Promise.race([closePromise, new Promise((resolve4) => setTimeout(resolve4, 2e3).unref())]);
86266
- if (processToClose.exitCode === null) {
86267
- try {
86268
- processToClose.kill("SIGTERM");
86269
- } catch {
86270
- }
86271
- await Promise.race([closePromise, new Promise((resolve4) => setTimeout(resolve4, 2e3).unref())]);
86272
- }
86273
- if (processToClose.exitCode === null) {
86274
- try {
86275
- processToClose.kill("SIGKILL");
86276
- } catch {
86277
- }
86278
- }
86279
- }
86280
- this._readBuffer.clear();
86281
- }
86282
- send(message) {
86283
- return new Promise((resolve4) => {
86284
- if (!this._process?.stdin) {
86285
- throw new Error("Not connected");
86286
- }
86287
- const json2 = serializeMessage(message);
86288
- if (this._process.stdin.write(json2)) {
86289
- resolve4();
86290
- } else {
86291
- this._process.stdin.once("drain", resolve4);
86292
- }
86293
- });
86294
- }
86295
- };
86296
-
86297
86309
  // src/mcp/probe.ts
86298
86310
  var MCP_PROBE_TIMEOUT_MS = 45e3;
86299
86311
  var MCP_PROBE_RETRY_DELAYS_MS = [500, 1e3, 2e3, 4e3, 8e3, 8e3, 8e3];
@@ -86319,6 +86331,7 @@ function transportFor(config2, secret, dial = {}) {
86319
86331
  if (config2.kind === "sql" || config2.kind === "graphql") throw new Error(`a ${config2.kind} source is not an MCP server; it has no MCP transport`);
86320
86332
  if (config2.kind === "mcp-stdio") {
86321
86333
  const env = { ...getDefaultEnvironment() };
86334
+ Object.assign(env, config2.env);
86322
86335
  if (config2.auth?.env !== void 0 && secret !== null) env[config2.auth.env] = secret;
86323
86336
  const transport = new StdioClientTransport({ command: config2.command ?? "", args: config2.args, env, stderr: "pipe" });
86324
86337
  let tail = "";
@@ -86684,7 +86697,7 @@ function sourceDescriptor(config2) {
86684
86697
  secretRefs: config2.auth === null ? {} : { [SECRET_PLACEHOLDER]: config2.auth.ref },
86685
86698
  address: config2.address ?? null,
86686
86699
  policyVersion: entry.policyVersion,
86687
- tls: { mode: entry.tls.mode, ca: entry.tls.ca === null ? null : createHash3("sha256").update(entry.tls.ca).digest("hex") }
86700
+ tls: { mode: entry.tls.mode, ca: entry.tls.ca === null ? null : createHash4("sha256").update(entry.tls.ca).digest("hex") }
86688
86701
  };
86689
86702
  }
86690
86703
  const sql = config2.sql ?? null;
@@ -86692,12 +86705,12 @@ function sourceDescriptor(config2) {
86692
86705
  kind: config2.kind,
86693
86706
  url: config2.url,
86694
86707
  auth: config2.auth === null ? null : { ref: config2.auth.ref, header: config2.auth.header?.toLowerCase() ?? null, prefix: config2.auth.prefix ?? null },
86695
- sql: sql === null ? null : { driver: sql.driver, host: sql.host ?? null, port: sql.port ?? null, database: sql.database ?? null, user: sql.user ?? null, tls: sql.tls ?? "verify-full", ca: sql.ca == null ? null : createHash3("sha256").update(sql.ca).digest("hex"), snapshot: sql.snapshot ?? null },
86708
+ sql: sql === null ? null : { driver: sql.driver, host: sql.host ?? null, port: sql.port ?? null, database: sql.database ?? null, user: sql.user ?? null, tls: sql.tls ?? "verify-full", ca: sql.ca == null ? null : createHash4("sha256").update(sql.ca).digest("hex"), snapshot: sql.snapshot ?? null },
86696
86709
  address: config2.address ?? null
86697
86710
  };
86698
86711
  }
86699
86712
  function sourceDescriptorHash(config2) {
86700
- return createHash3("sha256").update(canonicalJson(sourceDescriptor(config2))).digest("hex");
86713
+ return createHash4("sha256").update(canonicalJson(sourceDescriptor(config2))).digest("hex");
86701
86714
  }
86702
86715
  function sqlConnectArgs(config2, password, dial = {}) {
86703
86716
  const sql = config2.sql;
@@ -86737,7 +86750,7 @@ async function describeSource(config2, secret, dial = {}, snapshotDir2) {
86737
86750
  }
86738
86751
 
86739
86752
  // src/sources/safety/postgres.ts
86740
- import { createHash as createHash4 } from "node:crypto";
86753
+ import { createHash as createHash5 } from "node:crypto";
86741
86754
 
86742
86755
  // src/sources/policy/pg.ts
86743
86756
  import { parse as parse5 } from "libpg-query";
@@ -87228,7 +87241,7 @@ async function pgTableSafetyIn(tx, schema, name, decl = null, opts = {}) {
87228
87241
  if (kind === "role") add("catalog_create", `the role ${n} can create objects in pg_catalog, where one could take a name a write uses: v1 row writes need pg_catalog writable by superusers only`);
87229
87242
  else add("catalog_object", `pg_catalog holds the ${kind} ${n}, created after initdb: v1 row writes need pg_catalog as initdb left it`);
87230
87243
  }
87231
- return { table: { schema, name }, safe: false, reasons, fingerprint: createHash4("sha256").update(JSON.stringify(found)).digest("hex"), oid: "", reltype: "", columns: [] };
87244
+ return { table: { schema, name }, safe: false, reasons, fingerprint: createHash5("sha256").update(JSON.stringify(found)).digest("hex"), oid: "", reltype: "", columns: [] };
87232
87245
  }
87233
87246
  const [t] = await q(
87234
87247
  `SELECT c.oid::pg_catalog.int8::pg_catalog.text AS oid, c.reltype::pg_catalog.int8::pg_catalog.text AS reltype, c.relkind::pg_catalog.text AS relkind, c.relispartition AS ispartition,
@@ -87457,7 +87470,7 @@ async function pgTableSafetyIn(tx, schema, name, decl = null, opts = {}) {
87457
87470
  if (!writable) add("written_type", `\`${label}.${col}\` is \`${c.type}\`, which a v1 row write cannot write or key on (floating point, json, xml, bytea and arrays are not writable)`);
87458
87471
  }
87459
87472
  }
87460
- const fingerprint = createHash4("sha256").update(
87473
+ const fingerprint = createHash5("sha256").update(
87461
87474
  canonicalJson({
87462
87475
  table: { schema, name, oid: t.oid, reltype: t.reltype, relkind: t.relkind, partition: t.ispartition, rowSecurity: t.rowsecurity, forceRowSecurity: t.forcerowsecurity, am: t.amname, amBuiltin: t.am_builtin },
87463
87476
  columns: columns.map((c) => ({ name: c.name, type: c.type, typid: c.typid, typtype: c.typtype, typschema: c.typschema, builtin: c.type_builtin, collation: c.collation, notnull: c.notnull, generated: c.generated, identity: c.identity, default: c.default_expr })),
@@ -87502,7 +87515,7 @@ async function pgTableSafety(args, schema, name, decl = null) {
87502
87515
  }
87503
87516
 
87504
87517
  // src/apps/check.ts
87505
- import { createHash as createHash5 } from "node:crypto";
87518
+ import { createHash as createHash6 } from "node:crypto";
87506
87519
 
87507
87520
  // src/apps/git.ts
87508
87521
  import { devNull } from "node:os";
@@ -88070,7 +88083,7 @@ function paramValueProblem(decl, value) {
88070
88083
  var QUERY_TEXT_MAX_BYTES = 64 * 1024;
88071
88084
  var LOCK_MAX_BYTES = 1024 * 1024;
88072
88085
  var QUERY_EXT = { sql: "sql", graphql: "graphql", rest: "json", mcp: "json", crew: "json", recall: "json" };
88073
- var sha2562 = (s2) => createHash5("sha256").update(s2).digest("hex");
88086
+ var sha2562 = (s2) => createHash6("sha256").update(s2).digest("hex");
88074
88087
  var actionHash = (action) => sha2562(canonicalJson(action));
88075
88088
  var UTF8 = new TextDecoder("utf-8", { fatal: true });
88076
88089
 
@@ -88248,9 +88261,9 @@ function buildApiCard(app, action, metadata, value, nowAt, absent, recordId) {
88248
88261
 
88249
88262
  // src/apps/exec/contract.ts
88250
88263
  var import_graphql5 = __toESM(require_graphql2(), 1);
88251
- import { createHash as createHash6 } from "node:crypto";
88264
+ import { createHash as createHash7 } from "node:crypto";
88252
88265
  var CONTRACT_VERSION = 1;
88253
- var sha = (v) => createHash6("sha256").update(canonicalJson(v)).digest("hex");
88266
+ var sha = (v) => createHash7("sha256").update(canonicalJson(v)).digest("hex");
88254
88267
  function paramOrder(params) {
88255
88268
  return params === void 0 ? [] : Object.keys(params.properties);
88256
88269
  }
@@ -88402,7 +88415,7 @@ function splitTable(table) {
88402
88415
 
88403
88416
  // src/apps/exec/executor.ts
88404
88417
  var import_graphql6 = __toESM(require_graphql2(), 1);
88405
- import { createHash as createHash9 } from "node:crypto";
88418
+ import { createHash as createHash10 } from "node:crypto";
88406
88419
 
88407
88420
  // src/sources/catalog/types.ts
88408
88421
  function policyCatalog(catalog, viewsAllowed = []) {
@@ -89370,7 +89383,7 @@ function ttlOf(refresh) {
89370
89383
  }
89371
89384
 
89372
89385
  // src/apps/exec/limits.ts
89373
- import { createHash as createHash7 } from "node:crypto";
89386
+ import { createHash as createHash8 } from "node:crypto";
89374
89387
  var QUERY_LIMITS = { concurrent: 4, queue: 16, perMinute: 60, actionsPerMinute: 20 };
89375
89388
  var RateLimited = class extends Error {
89376
89389
  constructor(message, retryAfterMs) {
@@ -89396,7 +89409,7 @@ var AppLimits = class {
89396
89409
  for (const [k, v] of this.queryUnits) if (t - v.startedAt >= 1e4) this.queryUnits.delete(k);
89397
89410
  this.lastQuerySweepAt = t;
89398
89411
  }
89399
- const digest = createHash7("sha256").update(read).digest("base64url").slice(0, 22);
89412
+ const digest = createHash8("sha256").update(read).digest("base64url").slice(0, 22);
89400
89413
  const unit = this.queryUnits.get(key);
89401
89414
  if (unit !== void 0 && t - unit.startedAt < 1e4 && !unit.reads.has(digest) && unit.reads.size < Math.max(1, appQueries)) {
89402
89415
  unit.reads.add(digest);
@@ -89727,12 +89740,13 @@ function sqlRowObjects(columns, rows) {
89727
89740
  }
89728
89741
 
89729
89742
  // src/apps/exec/sources.ts
89730
- import { createHash as createHash8 } from "node:crypto";
89731
- var sha2 = (v) => createHash8("sha256").update(canonicalJson(v)).digest("hex");
89743
+ import { createHash as createHash9 } from "node:crypto";
89744
+ var sha2 = (v) => createHash9("sha256").update(canonicalJson(v)).digest("hex");
89732
89745
  function appSourceDescriptor(config2) {
89733
89746
  const base2 = sourceDescriptor(config2);
89734
89747
  if (config2.kind === "sql" || config2.kind === "graphql") return base2;
89735
- return { ...base2, command: config2.command, args: [...config2.args], openapiUrl: config2.openapiUrl ?? null, openapi: config2.openapi == null ? null : sha2(config2.openapi) };
89748
+ const fp = envFingerprint(config2.env);
89749
+ return { ...base2, command: config2.command, args: [...config2.args], openapiUrl: config2.openapiUrl ?? null, openapi: config2.openapi == null ? null : sha2(config2.openapi), ...fp !== null ? { env: fp } : {} };
89736
89750
  }
89737
89751
  var CREW_PIN = (() => {
89738
89752
  const descriptor = { kind: "crew" };
@@ -90373,7 +90387,7 @@ var AppExecError = class extends Error {
90373
90387
  code;
90374
90388
  extra;
90375
90389
  };
90376
- var sha3 = (v) => createHash9("sha256").update(canonicalJson(v)).digest("hex");
90390
+ var sha3 = (v) => createHash10("sha256").update(canonicalJson(v)).digest("hex");
90377
90391
  var CALLS_PER_APP = 200;
90378
90392
  var RECALL_CACHE_MAX_MS = 6e4;
90379
90393
  var argValue = (a, byName) => a.kind === "literal" ? a.value : byName[a.name];
@@ -90426,7 +90440,7 @@ var AppExecutor = class {
90426
90440
  if (err instanceof RateLimited) throw new AppExecError(429, "rate_limited", err.message, { retryAfterMs: err.retryAfterMs });
90427
90441
  throw err;
90428
90442
  }
90429
- const key = sha3({ tree, query: q.id, params: bound.byName, descriptorHash, contractHash, credential: secret === null ? null : createHash9("sha256").update(secret).digest("hex"), ...plan.kind === "crew" ? { actor: input2.actor.id } : {}, ...plan.kind === "recall" ? { visible: plan.visibleHash, stamp: plan.stamp ?? null } : {} });
90443
+ const key = sha3({ tree, query: q.id, params: bound.byName, descriptorHash, contractHash, credential: secret === null ? null : createHash10("sha256").update(secret).digest("hex"), ...plan.kind === "crew" ? { actor: input2.actor.id } : {}, ...plan.kind === "recall" ? { visible: plan.visibleHash, stamp: plan.stamp ?? null } : {} });
90430
90444
  try {
90431
90445
  const sourceName2 = plan.kind === "crew" ? "crew" : plan.kind === "recall" ? "estate" : plan.source.name;
90432
90446
  const ttl = plan.kind === "recall" ? plan.text.from === "memories" ? 0 : Math.min(ttlOf(q.refresh), RECALL_CACHE_MAX_MS) : ttlOf(q.refresh);
@@ -91113,7 +91127,7 @@ var AppWriteError = class extends Error {
91113
91127
  code;
91114
91128
  extra;
91115
91129
  };
91116
- var sha4 = (v) => createHash10("sha256").update(canonicalJson(v)).digest("hex");
91130
+ var sha4 = (v) => createHash11("sha256").update(canonicalJson(v)).digest("hex");
91117
91131
  var refuse3 = (status, code, message) => new AppWriteError(status, code, message);
91118
91132
  var AppWritePath = class {
91119
91133
  constructor(deps) {
@@ -91668,7 +91682,7 @@ var SITE_PORT = 8080;
91668
91682
  var TEAMS_FRAME_ORIGINS = ["https://teams.microsoft.com", "https://*.teams.microsoft.com", "https://teams.cloud.microsoft"];
91669
91683
 
91670
91684
  // ../apps-server/src/identity.ts
91671
- import { createHash as createHash11 } from "node:crypto";
91685
+ import { createHash as createHash12 } from "node:crypto";
91672
91686
  var TEAMS_CLIENT_IDS = ["1fec8e78-bce4-4aaf-ab1b-5451cc387264", "5e3ce6c0-2b1f-4285-8d4b-75ee78787346"];
91673
91687
  var MAX_TOKEN = 16 * 1024;
91674
91688
  var LOG_LIST_MAX = 50;
@@ -91718,7 +91732,7 @@ var SignIn = class {
91718
91732
  if (identity.profile === "entra" && (identity.tenantId === void 0 || !/^[0-9a-f-]{36}$/i.test(identity.tenantId))) throw new Error("the entra profile names its tenant id");
91719
91733
  this.config = { issuer: identity.issuer, audience: identity.clientId, ...identity.allowRanges !== void 0 ? { allowRanges: identity.allowRanges } : {} };
91720
91734
  this.verify = opts.verify ?? verifyOidcClaims;
91721
- const ns = identity.profile === "entra" ? identity.tenantId.toLowerCase() : createHash11("sha256").update(`${identity.issuer}\0${identity.clientId}`).digest("hex").slice(0, 16);
91735
+ const ns = identity.profile === "entra" ? identity.tenantId.toLowerCase() : createHash12("sha256").update(`${identity.issuer}\0${identity.clientId}`).digest("hex").slice(0, 16);
91722
91736
  this.principal = `${identity.profile}:${ns}:`;
91723
91737
  }
91724
91738
  opts;
@@ -92120,8 +92134,8 @@ async function claimDataDir(dir, opts = {}) {
92120
92134
  }
92121
92135
 
92122
92136
  // ../apps-server/src/page.ts
92123
- import { createHash as createHash12 } from "node:crypto";
92124
- var b64sha = (s2) => createHash12("sha256").update(s2, "utf8").digest("base64");
92137
+ import { createHash as createHash13 } from "node:crypto";
92138
+ var b64sha = (s2) => createHash13("sha256").update(s2, "utf8").digest("base64");
92125
92139
  var escapeHtml = (s2) => s2.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
92126
92140
  function inlineJson(v) {
92127
92141
  return JSON.stringify(v).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");