@introspection-ai/recipes 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/dist/inspect.d.ts +1 -0
  2. package/dist/inspect.d.ts.map +1 -1
  3. package/dist/inspect.js +3 -0
  4. package/dist/inspect.js.map +1 -1
  5. package/dist/mcp-chunks/{auth-command-ZLGYIEUY.js → auth-command-3K7V3VCW.js} +31 -35
  6. package/dist/mcp-chunks/call-arguments-TX3F2TEE.js +15 -0
  7. package/dist/mcp-chunks/{call-command-LKTKSYTH.js → call-command-OFPHPFM5.js} +36 -34
  8. package/dist/mcp-chunks/chunk-2FSDGCHW.js +3299 -0
  9. package/dist/mcp-chunks/{chunk-BV56DXPW.js → chunk-2JHHONW4.js} +1 -1
  10. package/dist/mcp-chunks/chunk-2MEHGB7D.js +63 -0
  11. package/dist/mcp-chunks/chunk-3IZQW4H4.js +929 -0
  12. package/dist/mcp-chunks/{chunk-MZ2NARG7.js → chunk-54EWGONA.js} +5 -5
  13. package/dist/mcp-chunks/{chunk-LQQEYD76.js → chunk-55JIHDU3.js} +1 -1
  14. package/dist/mcp-chunks/chunk-64EP2BVO.js +39 -0
  15. package/dist/mcp-chunks/{chunk-LS7PMWSR.js → chunk-6D6KPSXN.js} +1 -1
  16. package/dist/mcp-chunks/{chunk-2XL7MG7R.js → chunk-7A63PAGP.js} +15 -9
  17. package/dist/mcp-chunks/chunk-7DH57OKF.js +28 -0
  18. package/dist/mcp-chunks/{chunk-BTLAWHTA.js → chunk-7RDLPFIO.js} +2 -2
  19. package/dist/mcp-chunks/chunk-C2PQFLWS.js +422 -0
  20. package/dist/mcp-chunks/chunk-CA5WFJZA.js +197 -0
  21. package/dist/mcp-chunks/{chunk-LNH5LAJD.js → chunk-CNDY7WB4.js} +2 -2
  22. package/dist/mcp-chunks/{chunk-UKYNQGNE.js → chunk-DEUU7WSN.js} +34 -8
  23. package/dist/mcp-chunks/{chunk-LKIBAYKU.js → chunk-DXPHJFSA.js} +25 -35
  24. package/dist/mcp-chunks/{chunk-J6LYIZXN.js → chunk-E6RVTWJY.js} +1 -1
  25. package/dist/mcp-chunks/{chunk-7FHEBT5G.js → chunk-E6T37ED6.js} +18 -13
  26. package/dist/mcp-chunks/chunk-ETWN4IIA.js +57 -0
  27. package/dist/mcp-chunks/{chunk-YVZKMV5H.js → chunk-F3LL4EBL.js} +1 -1
  28. package/dist/mcp-chunks/chunk-FWP4RACK.js +42 -0
  29. package/dist/mcp-chunks/{chunk-6W5QFASN.js → chunk-GFYTST6N.js} +1 -1
  30. package/dist/mcp-chunks/{chunk-TEUKFFQL.js → chunk-GIF7LOYU.js} +2 -2
  31. package/dist/mcp-chunks/{chunk-QXJUA3ND.js → chunk-GSZOK5TS.js} +828 -7
  32. package/dist/mcp-chunks/chunk-H7F5RZXS.js +26 -0
  33. package/dist/mcp-chunks/{chunk-ECIVB7P4.js → chunk-HAO6PL7Z.js} +2 -37
  34. package/dist/mcp-chunks/{chunk-WQJZMCJN.js → chunk-HTZ2URXW.js} +5 -3
  35. package/dist/mcp-chunks/{chunk-BWHIA4PC.js → chunk-JAKI24KR.js} +1 -1
  36. package/dist/mcp-chunks/{chunk-PWYFKGKG.js → chunk-KSGYBW3F.js} +180 -89
  37. package/dist/mcp-chunks/{chunk-SJCCBNZ4.js → chunk-KSMY7PXI.js} +1 -1
  38. package/dist/mcp-chunks/{chunk-2U4BSDC4.js → chunk-L4VKBFYI.js} +48 -29
  39. package/dist/mcp-chunks/{chunk-LEZSACDE.js → chunk-LICH4Q7A.js} +4 -4
  40. package/dist/mcp-chunks/{chunk-PIIYJR44.js → chunk-LNSUME65.js} +29 -33
  41. package/dist/mcp-chunks/{chunk-D3MRAZ6H.js → chunk-LWVFSQYX.js} +13974 -15562
  42. package/dist/mcp-chunks/{chunk-7KA2VJVZ.js → chunk-NCXEJ35U.js} +10 -5
  43. package/dist/mcp-chunks/{chunk-5QOSCSQB.js → chunk-NZOIX6XW.js} +2 -2
  44. package/dist/mcp-chunks/{chunk-XANPGTLI.js → chunk-P3RN22HQ.js} +11 -4
  45. package/dist/mcp-chunks/{chunk-IABRYROW.js → chunk-PKOJCYNA.js} +3 -3
  46. package/dist/mcp-chunks/{chunk-BNV3TPE4.js → chunk-QJACOI2W.js} +5 -13
  47. package/dist/mcp-chunks/{chunk-UNKB4SBV.js → chunk-RBVYCKCD.js} +2 -2
  48. package/dist/mcp-chunks/{chunk-DHBE7UBH.js → chunk-SB2UUURE.js} +12 -42
  49. package/dist/mcp-chunks/{chunk-4SQKWYFF.js → chunk-SFREPU3D.js} +1 -1
  50. package/dist/mcp-chunks/{chunk-BZIQOWE6.js → chunk-SRZZQ6TL.js} +35 -36
  51. package/dist/mcp-chunks/{chunk-M3TPODXI.js → chunk-UENXT3NE.js} +1 -1
  52. package/dist/mcp-chunks/chunk-UHOKCTZT.js +37 -0
  53. package/dist/mcp-chunks/{chunk-E22DYOW5.js → chunk-WWO5WGH5.js} +5 -5
  54. package/dist/mcp-chunks/{chunk-6XCZGU3G.js → chunk-WXBPMFSN.js} +149 -192
  55. package/dist/mcp-chunks/{chunk-XQK2JSW4.js → chunk-XRGLP3Z2.js} +14 -2
  56. package/dist/mcp-chunks/{chunk-L7NTQVYN.js → chunk-XTL4MHFH.js} +28 -10
  57. package/dist/mcp-chunks/{chunk-N46NEFAF.js → chunk-XUF6KARU.js} +1 -1
  58. package/dist/mcp-chunks/{chunk-WD6BOD24.js → chunk-YCYSQA5V.js} +23 -4
  59. package/dist/mcp-chunks/chunk-YPJ5EHXR.js +17394 -0
  60. package/dist/mcp-chunks/{chunk-NRAJX5E4.js → chunk-YSPT6F7K.js} +3 -3
  61. package/dist/mcp-chunks/{chunk-7UDVSOOF.js → chunk-YTKRAHO6.js} +54 -46
  62. package/dist/mcp-chunks/chunk-ZBFZ5UFE.js +67 -0
  63. package/dist/mcp-chunks/{cli-UV4QJZZM.js → cli-E4P6SZLQ.js} +89 -76
  64. package/dist/mcp-chunks/client-2EJC4PLL.js +18 -0
  65. package/dist/mcp-chunks/{config-command-NLAGKID5.js → config-command-MWF3RHPQ.js} +38 -59
  66. package/dist/mcp-chunks/daemon-command-6CJ26MKI.js +33 -0
  67. package/dist/mcp-chunks/{dist-LK3SHAMX.js → dist-ZIPUENTM.js} +527 -469
  68. package/dist/mcp-chunks/{emit-ts-command-VBXVXO6V.js → emit-ts-command-GOVJJ64A.js} +16 -13
  69. package/dist/mcp-chunks/{generate-cli-runner-6CAZZA3P.js → generate-cli-runner-L5OQIMEY.js} +242 -247
  70. package/dist/mcp-chunks/{inspect-cli-command-3ZORTOR7.js → inspect-cli-command-7OMMREPE.js} +10 -9
  71. package/dist/mcp-chunks/{launch-YKRXHXJI.js → launch-BWXPLPB7.js} +1 -1
  72. package/dist/mcp-chunks/{lifecycle-XVKRHPH3.js → lifecycle-B5UC65PT.js} +1 -1
  73. package/dist/mcp-chunks/{list-command-2MEGGNFQ.js → list-command-ZO4HVFQK.js} +74 -43
  74. package/dist/mcp-chunks/{output-utils-NKESLAJ6.js → output-utils-M3TJ2N4M.js} +3 -3
  75. package/dist/mcp-chunks/{prompt-B1Yc1NPt-VGOTWJMN.js → prompt-CH6TK0bC-C7OTKGRD.js} +1 -3
  76. package/dist/mcp-chunks/{record-command-YXHTTTT5.js → record-command-VD3HUQIC.js} +5 -4
  77. package/dist/mcp-chunks/replay-command-AX6IN7YD.js +42 -0
  78. package/dist/mcp-chunks/{resource-command-OO4NYF5C.js → resource-command-JEZ2DW2G.js} +10 -10
  79. package/dist/mcp-chunks/{result-utils-MOHHLNM7.js → result-utils-3YHYGS45.js} +4 -4
  80. package/dist/mcp-chunks/runtime-HSYVOME7.js +37 -0
  81. package/dist/mcp-chunks/{runtime-wrapper-RPWDIDBF.js → runtime-wrapper-UREU7GC3.js} +7 -3
  82. package/dist/mcp-chunks/serve-command-M47YZ6JN.js +16018 -0
  83. package/dist/mcp-chunks/{timeouts-W2XWCCXR.js → timeouts-THZRYP4B.js} +3 -1
  84. package/dist/mcp-chunks/{vault-command-PIYIUEZL.js → vault-command-53P7MLCB.js} +7 -6
  85. package/dist/mcp-chunks/webapi-PHEQZQKH.js +3316 -0
  86. package/dist/mcp-client.js +11 -1
  87. package/dist/mcp-client.js.map +1 -1
  88. package/dist/mcp-daemon-client.d.ts.map +1 -1
  89. package/dist/mcp-daemon-client.js +3 -0
  90. package/dist/mcp-daemon-client.js.map +1 -1
  91. package/dist/mcp-daemon-protocol.d.ts +6 -0
  92. package/dist/mcp-daemon-protocol.d.ts.map +1 -1
  93. package/dist/mcp-daemon-protocol.js.map +1 -1
  94. package/dist/mcp-daemon.js +43 -22
  95. package/dist/mcp-daemon.js.map +1 -1
  96. package/dist/mcp-run-worker.js +29 -22
  97. package/dist/mcp-trace-context.d.ts +6 -0
  98. package/dist/mcp-trace-context.d.ts.map +1 -0
  99. package/dist/mcp-trace-context.js +31 -0
  100. package/dist/mcp-trace-context.js.map +1 -0
  101. package/dist/model-binding.d.ts.map +1 -1
  102. package/dist/model-binding.js +8 -4
  103. package/dist/model-binding.js.map +1 -1
  104. package/dist/pi-extension.d.ts.map +1 -1
  105. package/dist/pi-extension.js +12 -0
  106. package/dist/pi-extension.js.map +1 -1
  107. package/dist/recipe/resolve.d.ts +2 -0
  108. package/dist/recipe/resolve.d.ts.map +1 -1
  109. package/dist/recipe/resolve.js +2 -1
  110. package/dist/recipe/resolve.js.map +1 -1
  111. package/dist/recipe-agent.d.ts +5 -2
  112. package/dist/recipe-agent.d.ts.map +1 -1
  113. package/dist/recipe-agent.js +20 -4
  114. package/dist/recipe-agent.js.map +1 -1
  115. package/dist/recipe-model.d.ts +7 -1
  116. package/dist/recipe-model.d.ts.map +1 -1
  117. package/dist/recipe-model.js +89 -20
  118. package/dist/recipe-model.js.map +1 -1
  119. package/dist/recipe-session.d.ts +14 -0
  120. package/dist/recipe-session.d.ts.map +1 -0
  121. package/dist/recipe-session.js +181 -0
  122. package/dist/recipe-session.js.map +1 -0
  123. package/dist/session.d.ts.map +1 -1
  124. package/dist/session.js +23 -1
  125. package/dist/session.js.map +1 -1
  126. package/docs/agent-composition.md +46 -22
  127. package/docs/pi-extension.md +9 -3
  128. package/docs/recipe-format.md +41 -5
  129. package/package.json +7 -7
  130. package/vendor/introspection-recipe-check/darwin-arm64/introspection-recipe-check +0 -0
  131. package/vendor/introspection-recipe-check/darwin-x64/introspection-recipe-check +0 -0
  132. package/vendor/introspection-recipe-check/linux-arm64/introspection-recipe-check +0 -0
  133. package/vendor/introspection-recipe-check/linux-x64/introspection-recipe-check +0 -0
  134. package/vendor/introspection-recipe-check/linux-x64-musl/introspection-recipe-check +0 -0
  135. package/vendor/introspection-recipe-check/win32-x64/introspection-recipe-check.exe +0 -0
  136. package/dist/mcp-chunks/call-arguments-LU3W6D3K.js +0 -13
  137. package/dist/mcp-chunks/chunk-HKRJ6O36.js +0 -1076
  138. package/dist/mcp-chunks/chunk-NNOEGEUZ.js +0 -17273
  139. package/dist/mcp-chunks/chunk-P3PSC54P.js +0 -869
  140. package/dist/mcp-chunks/chunk-TATVT5IT.js +0 -194
  141. package/dist/mcp-chunks/chunk-YHQUTU6L.js +0 -571
  142. package/dist/mcp-chunks/client-S7RQUG5U.js +0 -13
  143. package/dist/mcp-chunks/daemon-command-U242Z6VY.js +0 -26
  144. package/dist/mcp-chunks/replay-command-25HJ6AQU.js +0 -85
  145. package/dist/mcp-chunks/runtime-5WJ3G25Y.js +0 -33
  146. package/dist/mcp-chunks/serve-command-DHXJZMMN.js +0 -3302
@@ -2,15 +2,15 @@ import { createRequire as __createRequire } from "node:module"; const require =
2
2
  import {
3
3
  buildFallbackLiteral,
4
4
  pickExampleLiteral
5
- } from "./chunk-XANPGTLI.js";
5
+ } from "./chunk-P3RN22HQ.js";
6
6
  import {
7
7
  cyanText,
8
8
  dimText,
9
9
  extraDimText,
10
10
  yellowText
11
- } from "./chunk-N46NEFAF.js";
11
+ } from "./chunk-XUF6KARU.js";
12
12
 
13
- // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/list-signature.js
13
+ // node_modules/.pnpm/mcporter@0.13.0/node_modules/mcporter/dist/cli/list-signature.js
14
14
  function formatFunctionSignature(name, options, outputSchema, formatOptions) {
15
15
  const colorize = formatOptions?.colorize !== false;
16
16
  const keyword = colorize ? extraDimText("function") : "function";
@@ -189,7 +189,7 @@ function formatArrayItemType(type) {
189
189
  }
190
190
  }
191
191
 
192
- // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/list-doc-comments.js
192
+ // node_modules/.pnpm/mcporter@0.13.0/node_modules/mcporter/dist/cli/list-doc-comments.js
193
193
  var DEFAULT_WRAP_WIDTH = 100;
194
194
  function buildDocComment(description, options, opts) {
195
195
  const colorize = opts?.colorize !== false;
@@ -300,7 +300,7 @@ function wrapCommentText(text, width = DEFAULT_WRAP_WIDTH) {
300
300
  return lines;
301
301
  }
302
302
 
303
- // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/list-detail-helpers.js
303
+ // node_modules/.pnpm/mcporter@0.13.0/node_modules/mcporter/dist/cli/list-detail-helpers.js
304
304
  var DEFAULT_MIN_VISIBLE_PARAMS = 5;
305
305
  function selectDisplayOptions(options, requiredOnly, minVisible = DEFAULT_MIN_VISIBLE_PARAMS) {
306
306
  if (!requiredOnly || options.length <= minVisible) {
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
 
3
- // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/ephemeral-flags.js
3
+ // node_modules/.pnpm/mcporter@0.13.0/node_modules/mcporter/dist/cli/ephemeral-flags.js
4
4
  function extractEphemeralServerFlags(args, options = {}) {
5
5
  let spec;
6
6
  const ensureSpec = () => {
@@ -0,0 +1,39 @@
1
+ import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+
3
+ // node_modules/.pnpm/mcporter@0.13.0/node_modules/mcporter/dist/network-family-autoselection.js
4
+ import net from "node:net";
5
+ var NODE_DEFAULT_ATTEMPT_TIMEOUT_MS = 250;
6
+ var MCPORTER_ATTEMPT_TIMEOUT_MS = 1500;
7
+ var NODE_OPTION = "--network-family-autoselection-attempt-timeout";
8
+ function configureAutoSelectFamilyAttemptTimeout(defaults = net, nodeOptions = process.env.NODE_OPTIONS) {
9
+ if (hasExplicitNodeOption(nodeOptions))
10
+ return false;
11
+ if (defaults.getDefaultAutoSelectFamilyAttemptTimeout() !== NODE_DEFAULT_ATTEMPT_TIMEOUT_MS)
12
+ return false;
13
+ defaults.setDefaultAutoSelectFamilyAttemptTimeout(MCPORTER_ATTEMPT_TIMEOUT_MS);
14
+ return true;
15
+ }
16
+ function hasExplicitNodeOption(nodeOptions) {
17
+ if (!nodeOptions)
18
+ return false;
19
+ let offset = 0;
20
+ while (offset < nodeOptions.length) {
21
+ const index = nodeOptions.indexOf(NODE_OPTION, offset);
22
+ if (index === -1)
23
+ return false;
24
+ const before = nodeOptions[index - 1];
25
+ const after = nodeOptions[index + NODE_OPTION.length];
26
+ if (isNodeOptionBoundary(before) && (after === "=" || isNodeOptionBoundary(after))) {
27
+ return true;
28
+ }
29
+ offset = index + NODE_OPTION.length;
30
+ }
31
+ return false;
32
+ }
33
+ function isNodeOptionBoundary(character) {
34
+ return character === void 0 || character === "'" || character === '"' || /\s/u.test(character);
35
+ }
36
+
37
+ export {
38
+ configureAutoSelectFamilyAttemptTimeout
39
+ };
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
 
3
- // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/lifecycle.js
3
+ // node_modules/.pnpm/mcporter@0.13.0/node_modules/mcporter/dist/lifecycle.js
4
4
  var DEFAULT_KEEP_ALIVE = /* @__PURE__ */ new Set(["chrome-devtools", "mobile-mcp", "playwright", "cloudbase"]);
5
5
  var includeOverride = parseList(process.env.MCPORTER_KEEPALIVE);
6
6
  var excludeOverride = parseList(process.env.MCPORTER_DISABLE_KEEPALIVE ?? process.env.MCPORTER_NO_KEEPALIVE);
@@ -1,6 +1,19 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
 
3
- // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/fs-json.js
3
+ // node_modules/.pnpm/mcporter@0.13.0/node_modules/mcporter/dist/process-utils.js
4
+ function isProcessRunning(pid) {
5
+ if (!Number.isInteger(pid) || pid <= 0) {
6
+ return false;
7
+ }
8
+ try {
9
+ process.kill(pid, 0);
10
+ return true;
11
+ } catch (error) {
12
+ return error.code === "EPERM";
13
+ }
14
+ }
15
+
16
+ // node_modules/.pnpm/mcporter@0.13.0/node_modules/mcporter/dist/fs-json.js
4
17
  import crypto from "node:crypto";
5
18
  import { constants } from "node:fs";
6
19
  import fs from "node:fs/promises";
@@ -247,14 +260,6 @@ async function isLockRecoverable(lockPath) {
247
260
  }
248
261
  return await isMalformedLockStale(lockPath);
249
262
  }
250
- function isProcessRunning(pid) {
251
- try {
252
- process.kill(pid, 0);
253
- return true;
254
- } catch (error) {
255
- return error.code === "EPERM";
256
- }
257
- }
258
263
  async function isMalformedLockStale(lockPath) {
259
264
  try {
260
265
  const stats = await fs.stat(lockPath);
@@ -265,6 +270,7 @@ async function isMalformedLockStale(lockPath) {
265
270
  }
266
271
 
267
272
  export {
273
+ isProcessRunning,
268
274
  readJsonFile,
269
275
  writeTextFileAtomic,
270
276
  writeJsonFile,
@@ -0,0 +1,28 @@
1
+ import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import {
3
+ analyzeConnectionError
4
+ } from "./chunk-DEUU7WSN.js";
5
+
6
+ // node_modules/.pnpm/mcporter@0.13.0/node_modules/mcporter/dist/runtime-oauth-support.js
7
+ function maybeEnableOAuth(definition, logger) {
8
+ if (definition.auth === "oauth" || definition.auth === "refreshable_bearer") {
9
+ return void 0;
10
+ }
11
+ if (definition.command.kind !== "http") {
12
+ return void 0;
13
+ }
14
+ logger.info(`Detected OAuth requirement for '${definition.name}'. Launching browser flow...`);
15
+ return {
16
+ ...definition,
17
+ auth: "oauth"
18
+ };
19
+ }
20
+ function isUnauthorizedError(error) {
21
+ const issue = analyzeConnectionError(error);
22
+ return issue.kind === "auth";
23
+ }
24
+
25
+ export {
26
+ maybeEnableOAuth,
27
+ isUnauthorizedError
28
+ };
@@ -2,9 +2,9 @@ import { createRequire as __createRequire } from "node:module"; const require =
2
2
  import {
3
3
  logInfo,
4
4
  logWarn
5
- } from "./chunk-UNKB4SBV.js";
5
+ } from "./chunk-RBVYCKCD.js";
6
6
 
7
- // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/runtime-debug.js
7
+ // node_modules/.pnpm/mcporter@0.13.0/node_modules/mcporter/dist/cli/runtime-debug.js
8
8
  var DEBUG_HANG = process.env.MCPORTER_DEBUG_HANG === "1";
9
9
  function describeHandle(handle) {
10
10
  if (!handle || typeof handle !== "object" && typeof handle !== "function") {
@@ -0,0 +1,422 @@
1
+ import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import {
3
+ readJsonFile,
4
+ withFileLock,
5
+ writeJsonFile
6
+ } from "./chunk-7A63PAGP.js";
7
+ import {
8
+ mcporterDir
9
+ } from "./chunk-FWP4RACK.js";
10
+
11
+ // node_modules/.pnpm/mcporter@0.13.0/node_modules/mcporter/dist/oauth-vault.js
12
+ import crypto from "node:crypto";
13
+ import path from "node:path";
14
+
15
+ // node_modules/.pnpm/mcporter@0.13.0/node_modules/mcporter/dist/oauth-credential-validation.js
16
+ function isRecord(value) {
17
+ return Boolean(value && typeof value === "object" && !Array.isArray(value));
18
+ }
19
+ function isOptionalString(record, key) {
20
+ return record[key] === void 0 || typeof record[key] === "string";
21
+ }
22
+ function isOptionalFiniteNumber(record, key) {
23
+ return record[key] === void 0 || typeof record[key] === "number" && Number.isFinite(record[key]);
24
+ }
25
+ function isStoredOAuthTokens(value) {
26
+ if (!isRecord(value))
27
+ return false;
28
+ return typeof value.access_token === "string" && value.access_token.length > 0 && typeof value.token_type === "string" && value.token_type.length > 0 && isOptionalString(value, "refresh_token") && isOptionalString(value, "scope") && isOptionalString(value, "issuer") && isOptionalFiniteNumber(value, "expires_in") && isOptionalFiniteNumber(value, "expires_at") && isOptionalFiniteNumber(value, "expiresAt");
29
+ }
30
+ function isStoredOAuthClientInformation(value) {
31
+ if (!isRecord(value))
32
+ return false;
33
+ return isOptionalString(value, "issuer");
34
+ }
35
+
36
+ // node_modules/.pnpm/mcporter@0.13.0/node_modules/mcporter/dist/oauth-token-generation.js
37
+ import { randomUUID } from "node:crypto";
38
+ import { isDeepStrictEqual } from "node:util";
39
+ var TOKEN_GENERATION_FIELD = "__mcporter_generation";
40
+ var CLIENT_GENERATION_FIELD = "__mcporter_client_generation";
41
+ function tokenGenerationOf(tokens) {
42
+ const generation = tokens[TOKEN_GENERATION_FIELD];
43
+ return typeof generation === "string" && generation.length > 0 ? generation : void 0;
44
+ }
45
+ function clientGenerationOf(info) {
46
+ const generation = info[CLIENT_GENERATION_FIELD];
47
+ return typeof generation === "string" && generation.length > 0 ? generation : void 0;
48
+ }
49
+ function withoutTokenGeneration(tokens) {
50
+ const copy = { ...tokens };
51
+ delete copy[TOKEN_GENERATION_FIELD];
52
+ return copy;
53
+ }
54
+ function withoutClientGeneration(info) {
55
+ const copy = { ...info };
56
+ delete copy[CLIENT_GENERATION_FIELD];
57
+ return copy;
58
+ }
59
+ function withOAuthTokenGeneration(tokens) {
60
+ const generation = tokenGenerationOf(tokens) ?? randomUUID();
61
+ return { ...withoutTokenGeneration(tokens), [TOKEN_GENERATION_FIELD]: generation };
62
+ }
63
+ function withHiddenOAuthTokenGeneration(tokens) {
64
+ const generation = tokenGenerationOf(tokens);
65
+ if (!generation) {
66
+ return tokens;
67
+ }
68
+ const copy = withoutTokenGeneration(tokens);
69
+ Object.defineProperty(copy, TOKEN_GENERATION_FIELD, { value: generation, enumerable: false });
70
+ return copy;
71
+ }
72
+ function withOAuthClientGeneration(info) {
73
+ const generation = clientGenerationOf(info) ?? randomUUID();
74
+ const copy = { ...withoutClientGeneration(info) };
75
+ copy[CLIENT_GENERATION_FIELD] = generation;
76
+ return copy;
77
+ }
78
+ function withHiddenOAuthClientGeneration(info) {
79
+ const generation = clientGenerationOf(info);
80
+ if (!generation) {
81
+ return info;
82
+ }
83
+ const copy = withoutClientGeneration(info);
84
+ Object.defineProperty(copy, CLIENT_GENERATION_FIELD, { value: generation, enumerable: false });
85
+ return copy;
86
+ }
87
+ function sameOAuthTokenGeneration(current, expected) {
88
+ if (!current) {
89
+ return false;
90
+ }
91
+ const currentGeneration = tokenGenerationOf(current);
92
+ const expectedGeneration = tokenGenerationOf(expected);
93
+ if (currentGeneration || expectedGeneration) {
94
+ return currentGeneration !== void 0 && currentGeneration === expectedGeneration && sameOAuthTokenValue(current, expected);
95
+ }
96
+ return isDeepStrictEqual(current, expected);
97
+ }
98
+ function sameOAuthTokenValue(left, right) {
99
+ return isDeepStrictEqual(withoutTokenGeneration(left), withoutTokenGeneration(right));
100
+ }
101
+ function sameOAuthClientGeneration(current, expected) {
102
+ if (!current) {
103
+ return false;
104
+ }
105
+ const currentGeneration = clientGenerationOf(current);
106
+ const expectedGeneration = clientGenerationOf(expected);
107
+ if (currentGeneration || expectedGeneration) {
108
+ return currentGeneration !== void 0 && currentGeneration === expectedGeneration && sameOAuthClientValue(current, expected);
109
+ }
110
+ return isDeepStrictEqual(current, expected);
111
+ }
112
+ function sameOAuthClientValue(left, right) {
113
+ return isDeepStrictEqual(withoutClientGeneration(left), withoutClientGeneration(right));
114
+ }
115
+
116
+ // node_modules/.pnpm/mcporter@0.13.0/node_modules/mcporter/dist/oauth-vault.js
117
+ function getOAuthVaultPath() {
118
+ return path.join(mcporterDir("data"), "credentials.json");
119
+ }
120
+ async function readVaultState() {
121
+ try {
122
+ const existing = await readJsonFile(getOAuthVaultPath());
123
+ if (existing && (existing.version === 1 || existing.version === 2) && existing.entries && typeof existing.entries === "object") {
124
+ return {
125
+ vault: { ...existing, version: 2 },
126
+ needsRepair: existing.version !== 2
127
+ };
128
+ }
129
+ if (existing !== void 0) {
130
+ return { vault: emptyVault(), needsRepair: true };
131
+ }
132
+ } catch (error) {
133
+ if (!(error instanceof SyntaxError)) {
134
+ throw error;
135
+ }
136
+ return { vault: emptyVault(), needsRepair: true };
137
+ }
138
+ return { vault: emptyVault(), needsRepair: false };
139
+ }
140
+ async function readVault() {
141
+ return (await readVaultState()).vault;
142
+ }
143
+ function emptyVault() {
144
+ return { version: 2, entries: {} };
145
+ }
146
+ async function writeVault(contents) {
147
+ await writeJsonFile(getOAuthVaultPath(), contents);
148
+ }
149
+ function vaultKeyForDefinition(definition) {
150
+ const descriptor = {
151
+ name: definition.name,
152
+ url: definition.command.kind === "http" ? definition.command.url.toString() : null,
153
+ command: definition.command.kind === "stdio" ? { command: definition.command.command, args: definition.command.args ?? [] } : null
154
+ };
155
+ const hash = crypto.createHash("sha256").update(JSON.stringify(descriptor)).digest("hex").slice(0, 16);
156
+ return `${definition.name}|${hash}`;
157
+ }
158
+ async function reconcileVaultServerUrl(definition) {
159
+ if (definition.command.kind !== "http") {
160
+ return;
161
+ }
162
+ const serverUrl = definition.command.url.toString();
163
+ await withFileLock(getOAuthVaultPath(), async () => {
164
+ const { vault, needsRepair } = await readVaultState();
165
+ const serverUrls = stringRecord(vault.serverUrls);
166
+ const previousUrl = serverUrls[definition.name];
167
+ const namedEntryUrls = Object.values(vault.entries).filter((entry) => isVaultEntry(entry) && entry.serverName === definition.name).flatMap((entry) => typeof entry.serverUrl === "string" ? [entry.serverUrl] : []);
168
+ const urlChanged = previousUrl !== void 0 && previousUrl !== serverUrl || namedEntryUrls.some((url) => url !== serverUrl);
169
+ if (urlChanged) {
170
+ const invalidatedUrls = new Set([serverUrl, previousUrl, ...namedEntryUrls].filter((url) => url !== void 0));
171
+ for (const [key, entry] of Object.entries(vault.entries)) {
172
+ if (isVaultEntry(entry) && (entry.serverName === definition.name || isLegacyOAuthRenameCandidate(definition, entry) && entry.serverUrl !== void 0 && invalidatedUrls.has(entry.serverUrl))) {
173
+ delete vault.entries[key];
174
+ }
175
+ }
176
+ }
177
+ if (previousUrl === serverUrl && !urlChanged && !needsRepair) {
178
+ return;
179
+ }
180
+ vault.serverUrls = { ...serverUrls, [definition.name]: serverUrl };
181
+ await writeVault(vault);
182
+ });
183
+ }
184
+ function stringRecord(value) {
185
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
186
+ return {};
187
+ }
188
+ return Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string"));
189
+ }
190
+ async function loadVaultEntryForRecovery(definition) {
191
+ const vault = await readVault();
192
+ const key = vaultKeyForDefinition(definition);
193
+ const resolved = resolveVaultEntry(vault, definition);
194
+ const tokenSnapshots = /* @__PURE__ */ new Map();
195
+ const clientSnapshots = /* @__PURE__ */ new Map();
196
+ for (const targetKey of [key, ...legacyOAuthRenameKeys(vault, definition, key)]) {
197
+ const candidate = isVaultEntry(vault.entries[targetKey]) ? vault.entries[targetKey] : void 0;
198
+ if (candidate?.tokens && resolved?.tokens && sameOAuthTokenValue(candidate.tokens, resolved.tokens)) {
199
+ tokenSnapshots.set(targetKey, candidate.tokens);
200
+ }
201
+ if (candidate?.clientInfo && resolved?.clientInfo && sameOAuthClientValue(candidate.clientInfo, resolved.clientInfo)) {
202
+ clientSnapshots.set(targetKey, candidate.clientInfo);
203
+ }
204
+ }
205
+ return {
206
+ entry: externalVaultEntry(resolved),
207
+ tokenSnapshots,
208
+ clientSnapshots
209
+ };
210
+ }
211
+ function resolveVaultEntry(vault, definition) {
212
+ const key = vaultKeyForDefinition(definition);
213
+ const exact = isVaultEntry(vault.entries[key]) ? vault.entries[key] : void 0;
214
+ const fallback = findSameUrlCredentials(vault, definition, key, exact);
215
+ if (!fallback.tokens && !fallback.clientInfo) {
216
+ return exact;
217
+ }
218
+ if (!exact) {
219
+ return {
220
+ serverName: definition.name,
221
+ serverUrl: definition.command.kind === "http" ? definition.command.url.toString() : void 0,
222
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
223
+ tokens: fallback.tokens,
224
+ clientInfo: fallback.clientInfo
225
+ };
226
+ }
227
+ return {
228
+ ...exact,
229
+ tokens: exact.tokens ?? fallback.tokens,
230
+ clientInfo: exact.clientInfo ?? (exact.tokens ? void 0 : fallback.clientInfo)
231
+ };
232
+ }
233
+ function externalVaultEntry(entry) {
234
+ if (!entry) {
235
+ return entry;
236
+ }
237
+ const { tokens, clientInfo, ...metadata } = entry;
238
+ return {
239
+ ...metadata,
240
+ ...isStoredOAuthTokens(tokens) ? { tokens: withHiddenOAuthTokenGeneration(tokens) } : {},
241
+ ...isStoredOAuthClientInformation(clientInfo) ? { clientInfo: withHiddenOAuthClientGeneration(clientInfo) } : {}
242
+ };
243
+ }
244
+ function findSameUrlCredentials(vault, definition, exactKey, exact) {
245
+ if (definition.command.kind !== "http") {
246
+ return { sourceKeys: [] };
247
+ }
248
+ const serverUrl = definition.command.url.toString();
249
+ const candidates = Object.entries(vault.entries).filter(([key, entry]) => key !== exactKey && isVaultEntry(entry) && entry.serverUrl === serverUrl && isLegacyOAuthRenameCandidate(definition, entry) && (entry.tokens || entry.clientInfo)).map(([key, entry]) => ({ key, entry })).toSorted((a, b) => Date.parse(b.entry.updatedAt) - Date.parse(a.entry.updatedAt));
250
+ const requiredClientId = definition.oauthClientId ?? clientIdFromEntry(exact);
251
+ if (requiredClientId) {
252
+ const tokenSource = candidates.find(({ entry }) => (entry.tokens || entry.clientInfo) && clientIdFromEntry(entry) === requiredClientId);
253
+ return {
254
+ tokens: tokenSource?.entry.tokens,
255
+ clientInfo: exact?.clientInfo ? void 0 : tokenSource?.entry.clientInfo,
256
+ sourceKeys: tokenSource ? [tokenSource.key] : []
257
+ };
258
+ }
259
+ const source = candidates.find(({ entry }) => entry.clientInfo && clientIdFromEntry(entry));
260
+ return {
261
+ tokens: source?.entry.tokens,
262
+ clientInfo: source?.entry.clientInfo,
263
+ sourceKeys: source ? [source.key] : []
264
+ };
265
+ }
266
+ function isLegacyOAuthRenameCandidate(definition, entry) {
267
+ return entry.serverName === `${definition.name}-oauth`;
268
+ }
269
+ function legacyOAuthRenameKeys(vault, definition, exactKey) {
270
+ if (definition.command.kind !== "http") {
271
+ return [];
272
+ }
273
+ const serverUrl = definition.command.url.toString();
274
+ return Object.entries(vault.entries).filter(([key, entry]) => key !== exactKey && isVaultEntry(entry) && entry.serverUrl === serverUrl && isLegacyOAuthRenameCandidate(definition, entry)).map(([key]) => key);
275
+ }
276
+ function isVaultEntry(entry) {
277
+ return Boolean(entry && typeof entry === "object" && typeof entry.serverName === "string" && typeof entry.updatedAt === "string");
278
+ }
279
+ function clientIdFromEntry(entry) {
280
+ const clientId = entry?.clientInfo?.client_id;
281
+ return typeof clientId === "string" && clientId.length > 0 ? clientId : void 0;
282
+ }
283
+ async function saveVaultEntry(definition, patch) {
284
+ await withFileLock(getOAuthVaultPath(), async () => {
285
+ const vault = await readVault();
286
+ const key = vaultKeyForDefinition(definition);
287
+ const existing = isVaultEntry(vault.entries[key]) ? vault.entries[key] : void 0;
288
+ const fallback = findSameUrlCredentials(vault, definition, key, existing);
289
+ const current = existing ?? {
290
+ serverName: definition.name,
291
+ serverUrl: definition.command.kind === "http" ? definition.command.url.toString() : void 0,
292
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
293
+ };
294
+ vault.entries[key] = {
295
+ ...current,
296
+ ...patch,
297
+ ...patch.tokens ? { tokens: withOAuthTokenGeneration(patch.tokens) } : {},
298
+ clientInfo: (patch.clientInfo ? withOAuthClientGeneration(patch.clientInfo) : void 0) ?? current.clientInfo ?? (patch.tokens && !current.tokens ? fallback.clientInfo : void 0),
299
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
300
+ };
301
+ await writeVault(vault);
302
+ });
303
+ }
304
+ function tokensMatch(tokens, expected) {
305
+ return expected !== void 0 && sameOAuthTokenGeneration(tokens, expected);
306
+ }
307
+ async function clearVaultTokensIfMatching(definition, expectedTokens, expectedClientInfo, tokenSnapshots, clientSnapshots) {
308
+ const key = vaultKeyForDefinition(definition);
309
+ await withFileLock(getOAuthVaultPath(), async () => {
310
+ const { vault, needsRepair } = await readVaultState();
311
+ const exact = isVaultEntry(vault.entries[key]) ? vault.entries[key] : void 0;
312
+ const fallbackKeys = findSameUrlCredentials(vault, definition, key, exact).sourceKeys;
313
+ const targetKeys = tokenSnapshots || clientSnapshots ? [.../* @__PURE__ */ new Set([...tokenSnapshots?.keys() ?? [], ...clientSnapshots?.keys() ?? []])] : [key, ...fallbackKeys];
314
+ let mutated = false;
315
+ for (const targetKey of targetKeys) {
316
+ const entry = isVaultEntry(vault.entries[targetKey]) ? vault.entries[targetKey] : void 0;
317
+ if (!entry) {
318
+ continue;
319
+ }
320
+ const updated = { ...entry };
321
+ let entryMutated = false;
322
+ const tokenSnapshot = tokenSnapshots ? tokenSnapshots.get(targetKey) : expectedTokens;
323
+ const clientSnapshot = clientSnapshots ? clientSnapshots.get(targetKey) : expectedClientInfo;
324
+ const ownTokensRejected = tokensMatch(entry.tokens, tokenSnapshot);
325
+ if (ownTokensRejected) {
326
+ delete updated.tokens;
327
+ entryMutated = true;
328
+ }
329
+ if (clientSnapshot && sameOAuthClientGeneration(updated.clientInfo, clientSnapshot)) {
330
+ delete updated.clientInfo;
331
+ entryMutated = true;
332
+ }
333
+ if (!entryMutated) {
334
+ continue;
335
+ }
336
+ updated.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
337
+ vault.entries[targetKey] = updated;
338
+ mutated = true;
339
+ }
340
+ if (mutated || needsRepair) {
341
+ await writeVault(vault);
342
+ }
343
+ });
344
+ }
345
+ async function clearVaultEntry(definition, scope) {
346
+ const key = vaultKeyForDefinition(definition);
347
+ await withFileLock(getOAuthVaultPath(), async () => {
348
+ const { vault, needsRepair } = await readVaultState();
349
+ const existing = isVaultEntry(vault.entries[key]) ? vault.entries[key] : void 0;
350
+ const fallback = findSameUrlCredentials(vault, definition, key, existing);
351
+ const inheritedKeys = scope === "all" ? legacyOAuthRenameKeys(vault, definition, key) : fallback.sourceKeys;
352
+ if (!existing && inheritedKeys.length === 0) {
353
+ if (needsRepair) {
354
+ await writeVault(vault);
355
+ }
356
+ return;
357
+ }
358
+ if (scope === "all") {
359
+ delete vault.entries[key];
360
+ } else if (existing) {
361
+ const updated = { ...existing };
362
+ if (scope === "tokens") {
363
+ delete updated.tokens;
364
+ }
365
+ if (scope === "client") {
366
+ delete updated.clientInfo;
367
+ }
368
+ if (scope === "verifier") {
369
+ delete updated.codeVerifier;
370
+ }
371
+ if (scope === "state") {
372
+ delete updated.state;
373
+ }
374
+ if (scope === "discovery") {
375
+ delete updated.discoveryState;
376
+ delete updated.authorizationServerUrl;
377
+ delete updated.resourceUrl;
378
+ }
379
+ updated.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
380
+ vault.entries[key] = updated;
381
+ }
382
+ for (const fallbackKey of inheritedKeys) {
383
+ const inherited = vault.entries[fallbackKey];
384
+ if (!inherited) {
385
+ continue;
386
+ }
387
+ if (scope === "all") {
388
+ delete vault.entries[fallbackKey];
389
+ continue;
390
+ }
391
+ const updated = { ...inherited };
392
+ if (scope === "tokens") {
393
+ delete updated.tokens;
394
+ }
395
+ if (scope === "client") {
396
+ delete updated.clientInfo;
397
+ }
398
+ updated.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
399
+ vault.entries[fallbackKey] = updated;
400
+ }
401
+ await writeVault(vault);
402
+ });
403
+ }
404
+
405
+ export {
406
+ isStoredOAuthTokens,
407
+ isStoredOAuthClientInformation,
408
+ withOAuthTokenGeneration,
409
+ withHiddenOAuthTokenGeneration,
410
+ withOAuthClientGeneration,
411
+ withHiddenOAuthClientGeneration,
412
+ sameOAuthTokenGeneration,
413
+ sameOAuthTokenValue,
414
+ sameOAuthClientGeneration,
415
+ sameOAuthClientValue,
416
+ getOAuthVaultPath,
417
+ reconcileVaultServerUrl,
418
+ loadVaultEntryForRecovery,
419
+ saveVaultEntry,
420
+ clearVaultTokensIfMatching,
421
+ clearVaultEntry
422
+ };