@introspection-ai/recipes 0.13.0 → 0.14.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 (222) hide show
  1. package/README.md +45 -58
  2. package/dist/{agent-tool.d.ts → agents.d.ts} +4 -1
  3. package/dist/agents.d.ts.map +1 -0
  4. package/dist/{agent-tool.js → agents.js} +1 -1
  5. package/dist/agents.js.map +1 -0
  6. package/dist/api/extensions.d.ts +3 -0
  7. package/dist/api/extensions.d.ts.map +1 -0
  8. package/dist/api/extensions.js +2 -0
  9. package/dist/api/extensions.js.map +1 -0
  10. package/dist/api/mcp.d.ts +4 -0
  11. package/dist/api/mcp.d.ts.map +1 -0
  12. package/dist/api/mcp.js +2 -0
  13. package/dist/api/mcp.js.map +1 -0
  14. package/dist/api/session.d.ts +3 -0
  15. package/dist/api/session.d.ts.map +1 -0
  16. package/dist/api/session.js +2 -0
  17. package/dist/api/session.js.map +1 -0
  18. package/dist/child-agent.d.ts +5 -4
  19. package/dist/child-agent.d.ts.map +1 -1
  20. package/dist/child-agent.js +26 -117
  21. package/dist/child-agent.js.map +1 -1
  22. package/dist/child-session.d.ts +23 -0
  23. package/dist/child-session.d.ts.map +1 -0
  24. package/dist/child-session.js +48 -0
  25. package/dist/child-session.js.map +1 -0
  26. package/dist/extensions.d.ts +29 -0
  27. package/dist/extensions.d.ts.map +1 -0
  28. package/dist/extensions.js +119 -0
  29. package/dist/extensions.js.map +1 -0
  30. package/dist/index.d.ts +4 -13
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +2 -13
  33. package/dist/index.js.map +1 -1
  34. package/dist/inspect.d.ts +38 -5
  35. package/dist/inspect.d.ts.map +1 -1
  36. package/dist/inspect.js +92 -41
  37. package/dist/inspect.js.map +1 -1
  38. package/dist/interactions.d.ts +18 -2
  39. package/dist/interactions.d.ts.map +1 -1
  40. package/dist/interactions.js +41 -10
  41. package/dist/interactions.js.map +1 -1
  42. package/dist/mcp-catalog.d.ts +1 -0
  43. package/dist/mcp-catalog.d.ts.map +1 -1
  44. package/dist/mcp-catalog.js +14 -6
  45. package/dist/mcp-catalog.js.map +1 -1
  46. package/dist/mcp-chunks/auth-command-ZLGYIEUY.js +273 -0
  47. package/dist/mcp-chunks/call-arguments-LU3W6D3K.js +13 -0
  48. package/dist/mcp-chunks/call-command-LKTKSYTH.js +612 -0
  49. package/dist/mcp-chunks/chunk-2U4BSDC4.js +3951 -0
  50. package/dist/mcp-chunks/chunk-2XL7MG7R.js +272 -0
  51. package/dist/mcp-chunks/chunk-3BJA27PY.js +2321 -0
  52. package/dist/mcp-chunks/chunk-4SQKWYFF.js +15 -0
  53. package/dist/mcp-chunks/chunk-5QOSCSQB.js +290 -0
  54. package/dist/mcp-chunks/chunk-6W5QFASN.js +77 -0
  55. package/dist/mcp-chunks/chunk-6XCZGU3G.js +1004 -0
  56. package/dist/mcp-chunks/chunk-7FHEBT5G.js +149 -0
  57. package/dist/mcp-chunks/chunk-7KA2VJVZ.js +114 -0
  58. package/dist/mcp-chunks/chunk-7UDVSOOF.js +138 -0
  59. package/dist/mcp-chunks/chunk-BNV3TPE4.js +66 -0
  60. package/dist/mcp-chunks/chunk-BTLAWHTA.js +129 -0
  61. package/dist/mcp-chunks/chunk-BV56DXPW.js +13 -0
  62. package/dist/mcp-chunks/chunk-BWHIA4PC.js +90 -0
  63. package/dist/mcp-chunks/chunk-BZIQOWE6.js +267 -0
  64. package/dist/mcp-chunks/chunk-D3MRAZ6H.js +16140 -0
  65. package/dist/mcp-chunks/chunk-DHBE7UBH.js +750 -0
  66. package/dist/mcp-chunks/chunk-E22DYOW5.js +251 -0
  67. package/dist/mcp-chunks/chunk-ECIVB7P4.js +139 -0
  68. package/dist/mcp-chunks/chunk-HKRJ6O36.js +1076 -0
  69. package/dist/mcp-chunks/chunk-IABRYROW.js +44 -0
  70. package/dist/mcp-chunks/chunk-J6LYIZXN.js +45 -0
  71. package/dist/mcp-chunks/chunk-L7NTQVYN.js +161 -0
  72. package/dist/mcp-chunks/chunk-LEZSACDE.js +141 -0
  73. package/dist/mcp-chunks/chunk-LKIBAYKU.js +208 -0
  74. package/dist/mcp-chunks/chunk-LNH5LAJD.js +152 -0
  75. package/dist/mcp-chunks/chunk-LQQEYD76.js +124 -0
  76. package/dist/mcp-chunks/chunk-LRKZP7DJ.js +47 -0
  77. package/dist/mcp-chunks/chunk-LS7PMWSR.js +109 -0
  78. package/dist/mcp-chunks/chunk-M3TPODXI.js +95 -0
  79. package/dist/mcp-chunks/chunk-MZ2NARG7.js +400 -0
  80. package/dist/mcp-chunks/chunk-N46NEFAF.js +45 -0
  81. package/dist/mcp-chunks/chunk-NNOEGEUZ.js +17273 -0
  82. package/dist/mcp-chunks/chunk-NRAJX5E4.js +69 -0
  83. package/dist/mcp-chunks/chunk-P3PSC54P.js +869 -0
  84. package/dist/mcp-chunks/chunk-PIIYJR44.js +6341 -0
  85. package/dist/mcp-chunks/chunk-PWYFKGKG.js +385 -0
  86. package/dist/mcp-chunks/chunk-SJCCBNZ4.js +45 -0
  87. package/dist/mcp-chunks/chunk-TATVT5IT.js +194 -0
  88. package/dist/mcp-chunks/chunk-TEUKFFQL.js +29 -0
  89. package/dist/mcp-chunks/chunk-UKYNQGNE.js +150 -0
  90. package/dist/mcp-chunks/chunk-UNKB4SBV.js +37 -0
  91. package/dist/mcp-chunks/chunk-WD6BOD24.js +138 -0
  92. package/dist/mcp-chunks/chunk-WQJZMCJN.js +73 -0
  93. package/dist/mcp-chunks/chunk-XANPGTLI.js +364 -0
  94. package/dist/mcp-chunks/chunk-XQK2JSW4.js +35 -0
  95. package/dist/mcp-chunks/chunk-YHQUTU6L.js +571 -0
  96. package/dist/mcp-chunks/chunk-YVZKMV5H.js +57 -0
  97. package/dist/mcp-chunks/cli-UV4QJZZM.js +929 -0
  98. package/dist/mcp-chunks/client-S7RQUG5U.js +13 -0
  99. package/dist/mcp-chunks/config-command-NLAGKID5.js +1101 -0
  100. package/dist/mcp-chunks/daemon-command-U242Z6VY.js +26 -0
  101. package/dist/mcp-chunks/dist-LK3SHAMX.js +6478 -0
  102. package/dist/mcp-chunks/emit-ts-command-VBXVXO6V.js +386 -0
  103. package/dist/mcp-chunks/generate-cli-runner-6CAZZA3P.js +1426 -0
  104. package/dist/mcp-chunks/inspect-cli-command-3ZORTOR7.js +111 -0
  105. package/dist/mcp-chunks/launch-YKRXHXJI.js +10 -0
  106. package/dist/mcp-chunks/lifecycle-XVKRHPH3.js +16 -0
  107. package/dist/mcp-chunks/list-command-2MEGGNFQ.js +4190 -0
  108. package/dist/mcp-chunks/output-utils-NKESLAJ6.js +12 -0
  109. package/dist/mcp-chunks/prompt-B1Yc1NPt-VGOTWJMN.js +918 -0
  110. package/dist/mcp-chunks/record-command-YXHTTTT5.js +17 -0
  111. package/dist/mcp-chunks/replay-command-25HJ6AQU.js +85 -0
  112. package/dist/mcp-chunks/resource-command-OO4NYF5C.js +97 -0
  113. package/dist/mcp-chunks/result-utils-MOHHLNM7.js +15 -0
  114. package/dist/mcp-chunks/runtime-5WJ3G25Y.js +33 -0
  115. package/dist/mcp-chunks/runtime-wrapper-RPWDIDBF.js +10 -0
  116. package/dist/mcp-chunks/serve-command-DHXJZMMN.js +3302 -0
  117. package/dist/mcp-chunks/timeouts-W2XWCCXR.js +18 -0
  118. package/dist/mcp-chunks/vault-command-PIYIUEZL.js +154 -0
  119. package/dist/mcp-daemon-client.d.ts +6 -1
  120. package/dist/mcp-daemon-client.d.ts.map +1 -1
  121. package/dist/mcp-daemon-client.js +119 -2
  122. package/dist/mcp-daemon-client.js.map +1 -1
  123. package/dist/mcp-daemon-protocol.d.ts +18 -1
  124. package/dist/mcp-daemon-protocol.d.ts.map +1 -1
  125. package/dist/mcp-daemon-protocol.js +31 -0
  126. package/dist/mcp-daemon-protocol.js.map +1 -1
  127. package/dist/mcp-daemon.js +169 -76602
  128. package/dist/mcp-daemon.js.map +1 -1
  129. package/dist/mcp-policy.d.ts +11 -0
  130. package/dist/mcp-policy.d.ts.map +1 -0
  131. package/dist/mcp-policy.js +27 -0
  132. package/dist/mcp-policy.js.map +1 -0
  133. package/dist/mcp-run-worker.js +38 -76540
  134. package/dist/mcp-tools.d.ts +39 -0
  135. package/dist/mcp-tools.d.ts.map +1 -0
  136. package/dist/mcp-tools.js +493 -0
  137. package/dist/mcp-tools.js.map +1 -0
  138. package/dist/mcp.d.ts +21 -9
  139. package/dist/mcp.d.ts.map +1 -1
  140. package/dist/mcp.js +101 -31
  141. package/dist/mcp.js.map +1 -1
  142. package/dist/model-binding.d.ts +39 -0
  143. package/dist/model-binding.d.ts.map +1 -0
  144. package/dist/model-binding.js +103 -0
  145. package/dist/model-binding.js.map +1 -0
  146. package/dist/pi-extension.d.ts +2 -22
  147. package/dist/pi-extension.d.ts.map +1 -1
  148. package/dist/pi-extension.js +296 -71
  149. package/dist/pi-extension.js.map +1 -1
  150. package/dist/recipe/resolve.d.ts +43 -20
  151. package/dist/recipe/resolve.d.ts.map +1 -1
  152. package/dist/recipe/resolve.js +215 -70
  153. package/dist/recipe/resolve.js.map +1 -1
  154. package/dist/recipe-agent.d.ts +24 -27
  155. package/dist/recipe-agent.d.ts.map +1 -1
  156. package/dist/recipe-agent.js +278 -230
  157. package/dist/recipe-agent.js.map +1 -1
  158. package/dist/recipe-check.d.ts +17 -0
  159. package/dist/recipe-check.d.ts.map +1 -0
  160. package/dist/recipe-check.js +258 -0
  161. package/dist/recipe-check.js.map +1 -0
  162. package/dist/recipe-extensions.d.ts.map +1 -1
  163. package/dist/recipe-extensions.js +0 -3
  164. package/dist/recipe-extensions.js.map +1 -1
  165. package/dist/recipe-model.d.ts +3 -1
  166. package/dist/recipe-model.d.ts.map +1 -1
  167. package/dist/recipe-model.js +15 -12
  168. package/dist/recipe-model.js.map +1 -1
  169. package/dist/recipe-package.d.ts +6 -28
  170. package/dist/recipe-package.d.ts.map +1 -1
  171. package/dist/recipe-package.js +248 -191
  172. package/dist/recipe-package.js.map +1 -1
  173. package/dist/recipe-skills.d.ts.map +1 -1
  174. package/dist/recipe-skills.js +42 -29
  175. package/dist/recipe-skills.js.map +1 -1
  176. package/dist/run-controller.d.ts +10 -9
  177. package/dist/run-controller.d.ts.map +1 -1
  178. package/dist/run-controller.js +28 -21
  179. package/dist/run-controller.js.map +1 -1
  180. package/dist/session.d.ts +40 -53
  181. package/dist/session.d.ts.map +1 -1
  182. package/dist/session.js +312 -173
  183. package/dist/session.js.map +1 -1
  184. package/dist/test-utils.d.ts +7 -7
  185. package/dist/test-utils.d.ts.map +1 -1
  186. package/dist/test-utils.js +32 -15
  187. package/dist/test-utils.js.map +1 -1
  188. package/docs/agent-composition.md +41 -35
  189. package/docs/host-api.md +201 -0
  190. package/docs/index.md +8 -14
  191. package/docs/interactions.md +12 -11
  192. package/docs/mcp-auth.md +6 -6
  193. package/docs/mcp-configuration.md +72 -24
  194. package/docs/pi-extension.md +39 -11
  195. package/docs/recipe-flow.md +9 -9
  196. package/docs/recipe-format.md +90 -41
  197. package/package.json +23 -17
  198. package/vendor/mcp-client/darwin-arm64/mcp-client +0 -0
  199. package/vendor/mcp-client/darwin-x64/mcp-client +0 -0
  200. package/vendor/mcp-client/linux-arm64/mcp-client +0 -0
  201. package/vendor/recipe-check/darwin-arm64/recipe-check +0 -0
  202. package/vendor/recipe-check/darwin-x64/recipe-check +0 -0
  203. package/vendor/recipe-check/linux-arm64/recipe-check +0 -0
  204. package/vendor/recipe-check/linux-x64/recipe-check +0 -0
  205. package/vendor/recipe-check/linux-x64-musl/recipe-check +0 -0
  206. package/vendor/recipe-check/win32-x64/recipe-check.exe +0 -0
  207. package/dist/agent-tool.d.ts.map +0 -1
  208. package/dist/agent-tool.js.map +0 -1
  209. package/dist/run.d.ts +0 -28
  210. package/dist/run.d.ts.map +0 -1
  211. package/dist/run.js +0 -84
  212. package/dist/run.js.map +0 -1
  213. package/dist/testing.d.ts +0 -25
  214. package/dist/testing.d.ts.map +0 -1
  215. package/dist/testing.js +0 -96
  216. package/dist/testing.js.map +0 -1
  217. package/docs/deployment-configuration.md +0 -65
  218. package/docs/migration.md +0 -70
  219. package/docs/python-bindings-release.md +0 -47
  220. package/docs/recipe-evals.md +0 -70
  221. package/docs/recipe-judges.md +0 -152
  222. package/docs/runtime-library.md +0 -171
@@ -0,0 +1,150 @@
1
+ import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import {
3
+ UnauthorizedError
4
+ } from "./chunk-P3PSC54P.js";
5
+
6
+ // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/error-classifier.js
7
+ var AUTH_STATUSES = /* @__PURE__ */ new Set([401, 403]);
8
+ var OFFLINE_PATTERNS = [
9
+ "fetch failed",
10
+ "econnrefused",
11
+ "connection refused",
12
+ "connection closed",
13
+ "connection reset",
14
+ "socket hang up",
15
+ "connect timeout",
16
+ "network is unreachable",
17
+ "timed out",
18
+ "timeout",
19
+ "timeout after",
20
+ "getaddrinfo",
21
+ "enotfound",
22
+ "enoent",
23
+ "eai_again",
24
+ "econnaborted",
25
+ "ehostunreach",
26
+ "no such host",
27
+ "failed to start",
28
+ "spawn enoent"
29
+ ];
30
+ var HTTP_STATUS_FALLBACK = /\bhttps?:\/\/[^\s]+(?:\s+returned\s+)?(?:status|code)?\s*(\d{3})\b/i;
31
+ var STATUS_DIRECT_PATTERN = /\b(?:status(?:\s+code)?|http(?:\s+(?:status|code|error))?)[:\s]*(\d{3})\b/i;
32
+ var STDIO_EXIT_PATTERN = /exit(?:ed)?(?:\s+with)?(?:\s+(?:code|status))\s+(-?\d+)/i;
33
+ var STDIO_SIGNAL_PATTERN = /signal\s+([A-Z0-9]+)/i;
34
+ function analyzeConnectionError(error) {
35
+ const rawMessage = extractMessage(error);
36
+ if (error instanceof UnauthorizedError) {
37
+ return { kind: "auth", rawMessage };
38
+ }
39
+ const stdio = extractStdioExit(rawMessage);
40
+ if (stdio) {
41
+ return { kind: "stdio-exit", rawMessage, ...stdio };
42
+ }
43
+ const errorCode = extractErrorCode(error);
44
+ const statusCode = errorCode ?? extractStatusCode(rawMessage);
45
+ const normalized = rawMessage.toLowerCase();
46
+ if (AUTH_STATUSES.has(statusCode ?? -1) || containsAuthToken(normalized)) {
47
+ return { kind: "auth", rawMessage, statusCode };
48
+ }
49
+ if (statusCode && statusCode >= 400) {
50
+ return { kind: "http", rawMessage, statusCode };
51
+ }
52
+ if (OFFLINE_PATTERNS.some((pattern) => normalized.includes(pattern))) {
53
+ return { kind: "offline", rawMessage };
54
+ }
55
+ return { kind: "other", rawMessage };
56
+ }
57
+ function extractMessage(error) {
58
+ if (error instanceof Error) {
59
+ return error.message ?? "";
60
+ }
61
+ if (typeof error === "string") {
62
+ return error;
63
+ }
64
+ if (error === void 0 || error === null) {
65
+ return "";
66
+ }
67
+ try {
68
+ return JSON.stringify(error);
69
+ } catch {
70
+ return "";
71
+ }
72
+ }
73
+ function extractErrorCode(error) {
74
+ if (typeof error === "object" && error !== null && "code" in error) {
75
+ const code = error.code;
76
+ if (typeof code === "number" && Number.isFinite(code) && code >= 100 && code < 600) {
77
+ return code;
78
+ }
79
+ }
80
+ return void 0;
81
+ }
82
+ function extractStatusCode(message) {
83
+ const candidates = [
84
+ message.match(/status code\s*\((\d{3})\)/i)?.[1],
85
+ message.match(STATUS_DIRECT_PATTERN)?.[1],
86
+ message.match(HTTP_STATUS_FALLBACK)?.[1]
87
+ ].filter(Boolean);
88
+ for (const candidate of candidates) {
89
+ const parsed = Number.parseInt(candidate, 10);
90
+ if (Number.isFinite(parsed)) {
91
+ return parsed;
92
+ }
93
+ }
94
+ const trimmed = message.trim();
95
+ if (trimmed.startsWith("{")) {
96
+ try {
97
+ const parsed = JSON.parse(trimmed);
98
+ const candidate = findStatusInObject(parsed);
99
+ if (typeof candidate === "number") {
100
+ return candidate;
101
+ }
102
+ if (typeof candidate === "string") {
103
+ const numeric = Number.parseInt(candidate, 10);
104
+ if (Number.isFinite(numeric)) {
105
+ return numeric;
106
+ }
107
+ }
108
+ } catch {
109
+ }
110
+ }
111
+ return void 0;
112
+ }
113
+ function containsAuthToken(normalizedMessage) {
114
+ return normalizedMessage.includes("401") || normalizedMessage.includes("unauthorized") || normalizedMessage.includes("invalid_token") || normalizedMessage.includes("forbidden");
115
+ }
116
+ function extractStdioExit(message) {
117
+ if (!message.toLowerCase().includes("stdio") && !STDIO_EXIT_PATTERN.test(message)) {
118
+ return void 0;
119
+ }
120
+ const exitMatch = message.match(STDIO_EXIT_PATTERN);
121
+ const signalMatch = message.match(STDIO_SIGNAL_PATTERN);
122
+ if (!exitMatch && !signalMatch) {
123
+ return void 0;
124
+ }
125
+ const exitCode = exitMatch ? Number.parseInt(exitMatch[1] ?? "", 10) : void 0;
126
+ return {
127
+ stdioExitCode: Number.isFinite(exitCode) ? exitCode : void 0,
128
+ stdioSignal: signalMatch?.[1]
129
+ };
130
+ }
131
+ function findStatusInObject(value) {
132
+ if (!value || typeof value !== "object") {
133
+ return void 0;
134
+ }
135
+ const record = value;
136
+ if (typeof record.status === "number" || typeof record.status === "string") {
137
+ return record.status;
138
+ }
139
+ if (typeof record.code === "number" || typeof record.code === "string") {
140
+ return record.code;
141
+ }
142
+ if (typeof record.error === "object" && record.error !== null) {
143
+ return findStatusInObject(record.error);
144
+ }
145
+ return void 0;
146
+ }
147
+
148
+ export {
149
+ analyzeConnectionError
150
+ };
@@ -0,0 +1,37 @@
1
+ import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import {
3
+ createPrefixedConsoleLogger,
4
+ resolveLogLevelFromEnv
5
+ } from "./chunk-6W5QFASN.js";
6
+
7
+ // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/logger-context.js
8
+ var activeLogLevel = resolveLogLevelFromEnv();
9
+ var activeLogger = createPrefixedConsoleLogger("mcporter", activeLogLevel);
10
+ function getActiveLogLevel() {
11
+ return activeLogLevel;
12
+ }
13
+ function getActiveLogger() {
14
+ return activeLogger;
15
+ }
16
+ function setLogLevel(level) {
17
+ activeLogLevel = level;
18
+ activeLogger = createPrefixedConsoleLogger("mcporter", activeLogLevel);
19
+ }
20
+ function logInfo(message) {
21
+ activeLogger.info(message);
22
+ }
23
+ function logWarn(message) {
24
+ activeLogger.warn(message);
25
+ }
26
+ function logError(message, error) {
27
+ activeLogger.error(message, error);
28
+ }
29
+
30
+ export {
31
+ getActiveLogLevel,
32
+ getActiveLogger,
33
+ setLogLevel,
34
+ logInfo,
35
+ logWarn,
36
+ logError
37
+ };
@@ -0,0 +1,138 @@
1
+ import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import {
3
+ findServerByHttpUrl
4
+ } from "./chunk-TEUKFFQL.js";
5
+ import {
6
+ persistEphemeralServer,
7
+ resolveEphemeralServer,
8
+ splitCommandLine
9
+ } from "./chunk-E22DYOW5.js";
10
+ import {
11
+ looksLikeHttpUrl,
12
+ normalizeHttpUrlCandidate
13
+ } from "./chunk-M3TPODXI.js";
14
+
15
+ // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/ephemeral-target.js
16
+ async function prepareEphemeralServerTarget(options) {
17
+ let target = options.target;
18
+ let spec = options.ephemeral ? { ...options.ephemeral } : void 0;
19
+ const promoteUrlCandidate = (value) => {
20
+ if (!value) {
21
+ return value;
22
+ }
23
+ const normalized = normalizeHttpUrlCandidate(value);
24
+ if (!normalized) {
25
+ return value;
26
+ }
27
+ const reused = findServerByHttpUrl(options.runtime.getDefinitions(), normalized);
28
+ if (reused) {
29
+ return reused;
30
+ }
31
+ if (!spec) {
32
+ spec = { httpUrl: normalized };
33
+ } else if (!spec.httpUrl) {
34
+ spec = { ...spec, httpUrl: normalized };
35
+ }
36
+ return void 0;
37
+ };
38
+ target = promoteUrlCandidate(target);
39
+ if (!spec) {
40
+ const inferredInline = inferInlineStdioSpec(target);
41
+ if (inferredInline) {
42
+ spec = inferredInline;
43
+ target = void 0;
44
+ }
45
+ }
46
+ if (spec) {
47
+ applyNameHints(spec, options.nameHints);
48
+ }
49
+ if (!spec) {
50
+ return { target };
51
+ }
52
+ if (spec.httpUrl) {
53
+ const normalized = normalizeHttpUrlCandidate(spec.httpUrl);
54
+ if (normalized) {
55
+ spec = { ...spec, httpUrl: normalized };
56
+ if (options.reuseFromSpec) {
57
+ const reused = findServerByHttpUrl(options.runtime.getDefinitions(), normalized);
58
+ if (reused) {
59
+ return { target: reused };
60
+ }
61
+ }
62
+ }
63
+ }
64
+ const resolution = resolveEphemeralServer(spec);
65
+ options.runtime.registerDefinition(resolution.definition, { overwrite: true });
66
+ if (spec.persistPath) {
67
+ await persistEphemeralServer(resolution, spec.persistPath);
68
+ }
69
+ const resolvedTarget = target ?? resolution.name;
70
+ return { target: resolvedTarget, resolution, persistPath: spec.persistPath };
71
+ }
72
+ async function persistPreparedEphemeralServer(runtime, prepared) {
73
+ if (!prepared?.resolution || !prepared.persistPath) {
74
+ return;
75
+ }
76
+ let currentDefinition;
77
+ try {
78
+ currentDefinition = runtime.getDefinition(prepared.resolution.name);
79
+ } catch {
80
+ return;
81
+ }
82
+ const persistedEntry = { ...prepared.resolution.persistedEntry };
83
+ if (currentDefinition.auth === "oauth") {
84
+ persistedEntry.auth = "oauth";
85
+ }
86
+ await persistEphemeralServer({
87
+ ...prepared.resolution,
88
+ persistedEntry
89
+ }, prepared.persistPath);
90
+ }
91
+ function applyNameHints(spec, hints) {
92
+ if (!spec || spec.name || !hints) {
93
+ return;
94
+ }
95
+ for (const hint of hints) {
96
+ if (!hint) {
97
+ continue;
98
+ }
99
+ if (looksLikeHttpUrl(hint)) {
100
+ continue;
101
+ }
102
+ spec.name = hint;
103
+ break;
104
+ }
105
+ }
106
+ function inferInlineStdioSpec(target) {
107
+ if (!target) {
108
+ return void 0;
109
+ }
110
+ const trimmed = target.trim();
111
+ if (!trimmed) {
112
+ return void 0;
113
+ }
114
+ if (looksLikeHttpUrl(trimmed)) {
115
+ return void 0;
116
+ }
117
+ if (!trimmed.includes(" ")) {
118
+ return void 0;
119
+ }
120
+ try {
121
+ const parts = splitCommandLine(trimmed);
122
+ if (parts.length < 2) {
123
+ return void 0;
124
+ }
125
+ const executable = parts[0]?.split(/[\\/]/).pop();
126
+ if (executable !== "npx") {
127
+ return void 0;
128
+ }
129
+ return { stdioCommand: trimmed };
130
+ } catch {
131
+ return void 0;
132
+ }
133
+ }
134
+
135
+ export {
136
+ prepareEphemeralServerTarget,
137
+ persistPreparedEphemeralServer
138
+ };
@@ -0,0 +1,73 @@
1
+ import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import {
3
+ expandHome,
4
+ mcporterConfigCandidates
5
+ } from "./chunk-ECIVB7P4.js";
6
+
7
+ // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/config/path-discovery.js
8
+ import fsSync from "node:fs";
9
+ import fs from "node:fs/promises";
10
+ import path from "node:path";
11
+ async function listConfigLayerPaths(options = {}, rootDir = process.cwd()) {
12
+ const explicitPath = options.configPath ?? process.env.MCPORTER_CONFIG;
13
+ if (explicitPath) {
14
+ return [path.resolve(expandHome(explicitPath.trim()))];
15
+ }
16
+ const paths = [];
17
+ const homeCandidates = homeConfigCandidates();
18
+ const existingHome = homeCandidates.find((candidate) => pathExists(candidate));
19
+ if (existingHome) {
20
+ paths.push(existingHome);
21
+ }
22
+ const projectPath = path.resolve(rootDir, "config", "mcporter.json");
23
+ if (pathExists(projectPath)) {
24
+ paths.push(projectPath);
25
+ }
26
+ return paths;
27
+ }
28
+ function resolveConfigPath(configPath, rootDir) {
29
+ if (configPath) {
30
+ return { path: path.resolve(configPath), explicit: true };
31
+ }
32
+ const envConfig = process.env.MCPORTER_CONFIG;
33
+ if (envConfig && envConfig.trim().length > 0) {
34
+ return { path: path.resolve(expandHome(envConfig.trim())), explicit: true };
35
+ }
36
+ const projectPath = path.resolve(rootDir, "config", "mcporter.json");
37
+ if (pathExists(projectPath)) {
38
+ return { path: projectPath, explicit: false };
39
+ }
40
+ const homeCandidates = homeConfigCandidates();
41
+ const existingHome = homeCandidates.find((candidate) => pathExists(candidate));
42
+ if (existingHome) {
43
+ return { path: existingHome, explicit: false };
44
+ }
45
+ return { path: projectPath, explicit: false };
46
+ }
47
+ function homeConfigCandidates() {
48
+ return mcporterConfigCandidates();
49
+ }
50
+ function pathExists(filePath) {
51
+ try {
52
+ fsSync.accessSync(filePath);
53
+ return true;
54
+ } catch {
55
+ return false;
56
+ }
57
+ }
58
+ async function pathExistsAsync(filePath) {
59
+ try {
60
+ await fs.access(filePath);
61
+ return true;
62
+ } catch {
63
+ return false;
64
+ }
65
+ }
66
+
67
+ export {
68
+ listConfigLayerPaths,
69
+ resolveConfigPath,
70
+ homeConfigCandidates,
71
+ pathExists,
72
+ pathExistsAsync
73
+ };