@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,149 @@
1
+ import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import {
3
+ legacyMcporterDir
4
+ } from "./chunk-ECIVB7P4.js";
5
+
6
+ // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/runtime/record-transport.js
7
+ import fs from "node:fs/promises";
8
+ import path from "node:path";
9
+ var initializedRecordingPaths = /* @__PURE__ */ new Map();
10
+ var PRIVATE_RECORDING_DIR_MODE = 448;
11
+ var PRIVATE_RECORDING_FILE_MODE = 384;
12
+ var RecordTransport = class {
13
+ opts;
14
+ onclose;
15
+ onerror;
16
+ onmessage;
17
+ sessionId;
18
+ finishAuth;
19
+ writes = Promise.resolve();
20
+ closeRecorded = false;
21
+ constructor(opts) {
22
+ this.opts = opts;
23
+ this.sessionId = opts.inner.sessionId;
24
+ const finishAuth = opts.inner.finishAuth;
25
+ if (finishAuth) {
26
+ this.finishAuth = (authorizationCode) => finishAuth.call(opts.inner, authorizationCode);
27
+ }
28
+ }
29
+ get pid() {
30
+ const pid = this.opts.inner.pid;
31
+ return typeof pid === "number" && pid > 0 ? pid : null;
32
+ }
33
+ get _process() {
34
+ return this.opts.inner._process ?? null;
35
+ }
36
+ async start() {
37
+ await initializeRecordingFile(this.opts.recordPath);
38
+ this.opts.inner.onclose = () => {
39
+ void this.appendCloseOnce();
40
+ this.onclose?.();
41
+ };
42
+ this.opts.inner.onerror = (error) => {
43
+ this.onerror?.(error);
44
+ };
45
+ this.opts.inner.onmessage = (message) => {
46
+ void this.appendLine(this.withMeta(message, "recv"));
47
+ this.onmessage?.(message);
48
+ };
49
+ await this.appendLifecycle("start");
50
+ await this.opts.inner.start();
51
+ this.sessionId = this.opts.inner.sessionId;
52
+ }
53
+ async send(message, options) {
54
+ await this.appendLine(this.withMeta(message, "send"));
55
+ await this.opts.inner.send(message, options);
56
+ }
57
+ async close() {
58
+ await this.appendCloseOnce();
59
+ await this.opts.inner.close();
60
+ await this.writes;
61
+ }
62
+ setProtocolVersion(version) {
63
+ this.opts.inner.setProtocolVersion?.(version);
64
+ }
65
+ async appendLifecycle(event) {
66
+ await this.appendLine(this.withMeta({
67
+ jsonrpc: "2.0",
68
+ method: `$transport/${event}`
69
+ }, "lifecycle"));
70
+ }
71
+ async appendCloseOnce() {
72
+ if (this.closeRecorded) {
73
+ return;
74
+ }
75
+ this.closeRecorded = true;
76
+ await this.appendLifecycle("close");
77
+ }
78
+ withMeta(message, dir) {
79
+ return {
80
+ ...message,
81
+ _meta: {
82
+ dir,
83
+ server: this.opts.server,
84
+ ts: (/* @__PURE__ */ new Date()).toISOString()
85
+ }
86
+ };
87
+ }
88
+ async appendLine(message) {
89
+ const line = `${JSON.stringify(message)}
90
+ `;
91
+ this.writes = this.writes.then(async () => {
92
+ await ensurePrivateRecordingDir(this.opts.recordPath);
93
+ await fs.appendFile(this.opts.recordPath, line, {
94
+ encoding: "utf8",
95
+ mode: PRIVATE_RECORDING_FILE_MODE
96
+ });
97
+ });
98
+ await this.writes;
99
+ }
100
+ };
101
+ function initializeRecordingFile(recordPath) {
102
+ const existing = initializedRecordingPaths.get(recordPath);
103
+ if (existing) {
104
+ return existing;
105
+ }
106
+ const initialization = ensurePrivateRecordingDir(recordPath).then(() => fs.writeFile(recordPath, "", {
107
+ encoding: "utf8",
108
+ mode: PRIVATE_RECORDING_FILE_MODE
109
+ })).then(() => fs.chmod(recordPath, PRIVATE_RECORDING_FILE_MODE)).catch((error) => {
110
+ initializedRecordingPaths.delete(recordPath);
111
+ throw error;
112
+ });
113
+ initializedRecordingPaths.set(recordPath, initialization);
114
+ return initialization;
115
+ }
116
+ async function ensurePrivateRecordingDir(recordPath) {
117
+ const recordingDir = path.dirname(recordPath);
118
+ await fs.mkdir(recordingDir, {
119
+ recursive: true,
120
+ mode: PRIVATE_RECORDING_DIR_MODE
121
+ });
122
+ await fs.chmod(recordingDir, PRIVATE_RECORDING_DIR_MODE);
123
+ }
124
+ function resolveRecordingPath(sessionName) {
125
+ const normalized = normalizeRecordingSessionName(sessionName);
126
+ return path.join(legacyMcporterDir(), "recordings", `${normalized}.ndjson`);
127
+ }
128
+ function resolveRecordingConfigPath(sessionName) {
129
+ const normalized = normalizeRecordingSessionName(sessionName);
130
+ return path.join(legacyMcporterDir(), "recordings", `${normalized}.config.json`);
131
+ }
132
+ function normalizeRecordingSessionName(sessionName) {
133
+ const normalized = sessionName.trim();
134
+ if (!normalized) {
135
+ throw new Error("Recording session name is required.");
136
+ }
137
+ if (normalized.includes("/") || normalized.includes("\\") || normalized === "." || normalized === "..") {
138
+ throw new Error(`Invalid recording session name '${sessionName}'. Use a simple file name without path separators.`);
139
+ }
140
+ return normalized;
141
+ }
142
+
143
+ export {
144
+ PRIVATE_RECORDING_FILE_MODE,
145
+ RecordTransport,
146
+ ensurePrivateRecordingDir,
147
+ resolveRecordingPath,
148
+ resolveRecordingConfigPath
149
+ };
@@ -0,0 +1,114 @@
1
+ import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import {
3
+ dimText,
4
+ extraDimText,
5
+ redText,
6
+ yellowText
7
+ } from "./chunk-N46NEFAF.js";
8
+ import {
9
+ analyzeConnectionError
10
+ } from "./chunk-UKYNQGNE.js";
11
+
12
+ // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/path-utils.js
13
+ import os from "node:os";
14
+ import path from "node:path";
15
+ function formatPathForDisplay(filePath) {
16
+ const cwd = process.cwd();
17
+ const relative = path.relative(cwd, filePath);
18
+ const displayPath = relative && !relative.startsWith("..") && !path.isAbsolute(relative) ? relative : filePath.replace(os.homedir(), "~");
19
+ return displayPath;
20
+ }
21
+
22
+ // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/list-format.js
23
+ function renderServerListRow(result, timeoutMs, options = {}) {
24
+ const description = result.server.description ? dimText(` \u2014 ${result.server.description}`) : "";
25
+ const durationLabel = dimText(`${(result.durationMs / 1e3).toFixed(1)}s`);
26
+ const sourceSuffix = formatSourceSuffix(result.server.sources ?? result.server.source, false, {
27
+ verbose: options.verbose
28
+ });
29
+ const prefix = `- ${result.server.name}${description}`;
30
+ if (result.status === "ok") {
31
+ const toolSuffix = result.tools.length === 0 ? "no tools reported" : `${result.tools.length === 1 ? "1 tool" : `${result.tools.length} tools`}`;
32
+ return {
33
+ line: `${prefix} (${toolSuffix}, ${durationLabel})${sourceSuffix}`,
34
+ summary: toolSuffix,
35
+ category: "ok"
36
+ };
37
+ }
38
+ const timeoutSeconds = Math.round(timeoutMs / 1e3);
39
+ const advice = classifyListError(result.error, result.server.name, timeoutSeconds);
40
+ return {
41
+ line: `${prefix} (${advice.colored}, ${durationLabel})${sourceSuffix}`,
42
+ summary: advice.summary,
43
+ category: advice.category,
44
+ authCommand: advice.authCommand,
45
+ issue: advice.issue
46
+ };
47
+ }
48
+ function formatSourceSuffix(sourceOrSources, inline = false, options = {}) {
49
+ const sources = Array.isArray(sourceOrSources) ? [...sourceOrSources] : sourceOrSources ? [sourceOrSources] : [];
50
+ if (sources.length === 0) {
51
+ return "";
52
+ }
53
+ const verbose = options.verbose ?? false;
54
+ if (!verbose) {
55
+ const primary2 = sources[0];
56
+ if (primary2.kind !== "import") {
57
+ return "";
58
+ }
59
+ const formatted = formatPathForDisplay(primary2.path);
60
+ const tinted2 = extraDimText(inline ? formatted : `[source: ${formatted}]`);
61
+ return inline ? tinted2 : ` ${tinted2}`;
62
+ }
63
+ const [primary, ...alternates] = sources;
64
+ const primaryLabel = buildSourceLabel(primary, { primary: true });
65
+ const altLabels = alternates.map((entry) => {
66
+ const shadowedByLocal = primary.kind === "local" && entry.kind !== "local";
67
+ return buildSourceLabel(entry, { shadowReason: shadowedByLocal ? "shadowed by local" : "shadowed" });
68
+ });
69
+ const label = altLabels.length === 0 ? `source: ${primaryLabel}` : `sources: ${[primaryLabel, ...altLabels].join(" \xB7 ")}`;
70
+ const tinted = extraDimText(inline ? label : `[${label}]`);
71
+ return inline ? tinted : ` ${tinted}`;
72
+ }
73
+ function buildSourceLabel(source, options) {
74
+ const base = formatPathForDisplay(source.path);
75
+ const tags = [];
76
+ if (options.primary) {
77
+ tags.push("primary");
78
+ }
79
+ if (options.shadowReason) {
80
+ tags.push(options.shadowReason);
81
+ }
82
+ if (source.importKind) {
83
+ tags.push(source.importKind);
84
+ }
85
+ return tags.length === 0 ? base : `${base} (${tags.join(", ")})`;
86
+ }
87
+ function classifyListError(error, serverName, _timeoutSeconds, options) {
88
+ const issue = analyzeConnectionError(error);
89
+ if (issue.kind === "auth") {
90
+ const authCommand = options?.authCommand ?? `mcporter auth ${serverName}`;
91
+ const note2 = yellowText(`auth required \u2014 run '${authCommand}'`);
92
+ return { colored: note2, summary: "auth required", category: "auth", authCommand, issue };
93
+ }
94
+ if (issue.kind === "offline") {
95
+ const note2 = redText("offline \u2014 unable to reach server");
96
+ return { colored: note2, summary: "offline", category: "offline", issue };
97
+ }
98
+ if (issue.kind === "http") {
99
+ const statusText = issue.statusCode ? `HTTP ${issue.statusCode}` : "HTTP error";
100
+ const detail = issue.rawMessage && issue.rawMessage !== String(issue.statusCode) ? ` \u2014 ${issue.rawMessage}` : "";
101
+ const note2 = redText(`${statusText}${detail}`);
102
+ return { colored: note2, summary: statusText.toLowerCase(), category: "http", issue };
103
+ }
104
+ const rawMessage = issue.rawMessage || "unknown error";
105
+ const note = redText(rawMessage);
106
+ return { colored: note, summary: rawMessage, category: "error", issue };
107
+ }
108
+
109
+ export {
110
+ formatPathForDisplay,
111
+ renderServerListRow,
112
+ formatSourceSuffix,
113
+ classifyListError
114
+ };
@@ -0,0 +1,138 @@
1
+ import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import {
3
+ buildRecordCommandEnv
4
+ } from "./chunk-J6LYIZXN.js";
5
+ import {
6
+ PRIVATE_RECORDING_FILE_MODE,
7
+ ensurePrivateRecordingDir,
8
+ resolveRecordingConfigPath,
9
+ resolveRecordingPath
10
+ } from "./chunk-7FHEBT5G.js";
11
+
12
+ // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/record-command.js
13
+ import { spawn } from "node:child_process";
14
+ import fs from "node:fs/promises";
15
+ async function handleRecordCli(args) {
16
+ const parsed = parseRecordArgs(args);
17
+ const recordPath = resolveRecordingPath(parsed.sessionName);
18
+ if (parsed.command.length > 0) {
19
+ await runWithRecordingEnv(parsed, buildRecordCommandEnv(parsed.sessionName, parsed.server));
20
+ return;
21
+ }
22
+ await writeModeConfig(parsed, {
23
+ mode: "record",
24
+ recordPath,
25
+ env: {
26
+ MCPORTER_RECORD: parsed.sessionName,
27
+ ...parsed.server ? { MCPORTER_RECORD_SERVER: parsed.server } : {},
28
+ MCPORTER_DISABLE_KEEPALIVE: "*"
29
+ }
30
+ });
31
+ console.log(`Recording configuration written to ${resolveRecordingConfigPath(parsed.sessionName)}`);
32
+ const envInstructions = [
33
+ `MCPORTER_RECORD=${parsed.sessionName}`,
34
+ ...parsed.server ? [`MCPORTER_RECORD_SERVER=${parsed.server}`] : [],
35
+ "MCPORTER_DISABLE_KEEPALIVE=*"
36
+ ];
37
+ console.log(`Set ${envInstructions.join(" and ")} before the next mcporter call to record ${recordPath}.`);
38
+ }
39
+ function printRecordHelp() {
40
+ console.log(`Usage: mcporter record <session-name> [--server <name>] [-- <command-to-run>]
41
+
42
+ Capture MCP JSON-RPC traffic to ~/.mcporter/recordings/<session-name>.ndjson.
43
+
44
+ Flags:
45
+ --server <name> Restrict recording to one configured server.`);
46
+ }
47
+ function parseRecordArgs(args) {
48
+ return parseSessionCommandArgs(args, "record");
49
+ }
50
+ function parseReplayArgs(args) {
51
+ return parseSessionCommandArgs(args, "replay");
52
+ }
53
+ async function writeModeConfig(parsed, extra) {
54
+ const configPath = resolveRecordingConfigPath(parsed.sessionName);
55
+ await ensurePrivateRecordingDir(configPath);
56
+ await fs.writeFile(configPath, `${JSON.stringify({
57
+ session: parsed.sessionName,
58
+ server: parsed.server,
59
+ ...extra
60
+ }, null, 2)}
61
+ `, {
62
+ encoding: "utf8",
63
+ mode: PRIVATE_RECORDING_FILE_MODE
64
+ });
65
+ await fs.chmod(configPath, PRIVATE_RECORDING_FILE_MODE);
66
+ }
67
+ async function runWithRecordingEnv(parsed, env) {
68
+ const [command, ...commandArgs] = parsed.command;
69
+ if (!command) {
70
+ return;
71
+ }
72
+ await new Promise((resolve, reject) => {
73
+ const child = spawn(command, commandArgs, {
74
+ stdio: "inherit",
75
+ env
76
+ });
77
+ child.once("error", reject);
78
+ child.once("exit", (code, signal) => {
79
+ if (signal) {
80
+ reject(new Error(`Command '${command}' exited from signal ${signal}.`));
81
+ return;
82
+ }
83
+ process.exitCode = code ?? 0;
84
+ resolve();
85
+ });
86
+ });
87
+ }
88
+ function parseSessionCommandArgs(args, commandName) {
89
+ let server;
90
+ const tokens = [...args];
91
+ const commandSeparator = tokens.indexOf("--");
92
+ const command = commandSeparator === -1 ? [] : tokens.splice(commandSeparator);
93
+ if (command[0] === "--") {
94
+ command.shift();
95
+ }
96
+ const remaining = [];
97
+ for (let index = 0; index < tokens.length; index += 1) {
98
+ const token = tokens[index];
99
+ if (!token) {
100
+ continue;
101
+ }
102
+ if (token === "--server") {
103
+ const value = tokens[index + 1];
104
+ if (!value) {
105
+ throw new Error("Flag '--server' requires a server name.");
106
+ }
107
+ server = value;
108
+ index += 1;
109
+ continue;
110
+ }
111
+ if (token.startsWith("--server=")) {
112
+ server = token.slice("--server=".length);
113
+ if (!server) {
114
+ throw new Error("Flag '--server' requires a server name.");
115
+ }
116
+ continue;
117
+ }
118
+ if (token.startsWith("-")) {
119
+ throw new Error(`Unknown ${commandName} flag '${token}'.`);
120
+ }
121
+ remaining.push(token);
122
+ }
123
+ const sessionName = remaining[0];
124
+ if (!sessionName) {
125
+ throw new Error(`Usage: mcporter ${commandName} <session-name> [--server <name>] [-- <command-to-run>]`);
126
+ }
127
+ if (remaining.length > 1) {
128
+ throw new Error(`Unexpected ${commandName} argument '${remaining[1]}'. Put commands after '--'.`);
129
+ }
130
+ return { sessionName, server, command };
131
+ }
132
+
133
+ export {
134
+ handleRecordCli,
135
+ printRecordHelp,
136
+ parseRecordArgs,
137
+ parseReplayArgs
138
+ };
@@ -0,0 +1,66 @@
1
+ import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+
3
+ // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/timeouts.js
4
+ var DEFAULT_LIST_TIMEOUT_MS = 3e4;
5
+ var DEFAULT_CALL_TIMEOUT_MS = 6e4;
6
+ var POSITIVE_INTEGER_PATTERN = /^[1-9]\d*$/;
7
+ function parsePositiveInteger(raw) {
8
+ if (!raw || !POSITIVE_INTEGER_PATTERN.test(raw)) {
9
+ return void 0;
10
+ }
11
+ const parsed = Number(raw);
12
+ return Number.isFinite(parsed) ? parsed : void 0;
13
+ }
14
+ function parseTimeout(raw, fallback) {
15
+ if (!raw) {
16
+ return fallback;
17
+ }
18
+ return parsePositiveInteger(raw) ?? fallback;
19
+ }
20
+ var LIST_TIMEOUT_MS = parseTimeout(process.env.MCPORTER_LIST_TIMEOUT, DEFAULT_LIST_TIMEOUT_MS);
21
+ function resolveCallTimeout(override) {
22
+ if (typeof override === "number" && Number.isFinite(override) && override > 0) {
23
+ return override;
24
+ }
25
+ return parseTimeout(process.env.MCPORTER_CALL_TIMEOUT, DEFAULT_CALL_TIMEOUT_MS);
26
+ }
27
+ function withTimeout(promise, timeoutMs) {
28
+ if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
29
+ return promise;
30
+ }
31
+ return new Promise((resolve, reject) => {
32
+ const timer = setTimeout(() => {
33
+ reject(new Error("Timeout"));
34
+ }, timeoutMs);
35
+ promise.then((value) => {
36
+ clearTimeout(timer);
37
+ resolve(value);
38
+ }, (error) => {
39
+ clearTimeout(timer);
40
+ reject(error);
41
+ });
42
+ });
43
+ }
44
+ function consumeTimeoutFlag(args, index, options) {
45
+ const flagName = options?.flagName ?? "--timeout";
46
+ const missingValueMessage = options?.missingValueMessage ?? `Flag '${flagName}' requires a value.`;
47
+ const value = args[index + 1];
48
+ if (!value) {
49
+ throw new Error(missingValueMessage);
50
+ }
51
+ const parsed = parsePositiveInteger(value);
52
+ if (parsed === void 0) {
53
+ throw new Error(`${flagName} must be a positive integer (milliseconds).`);
54
+ }
55
+ args.splice(index, 2);
56
+ return parsed;
57
+ }
58
+
59
+ export {
60
+ parsePositiveInteger,
61
+ parseTimeout,
62
+ LIST_TIMEOUT_MS,
63
+ resolveCallTimeout,
64
+ withTimeout,
65
+ consumeTimeoutFlag
66
+ };
@@ -0,0 +1,129 @@
1
+ import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import {
3
+ logInfo,
4
+ logWarn
5
+ } from "./chunk-UNKB4SBV.js";
6
+
7
+ // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/runtime-debug.js
8
+ var DEBUG_HANG = process.env.MCPORTER_DEBUG_HANG === "1";
9
+ function describeHandle(handle) {
10
+ if (!handle || typeof handle !== "object" && typeof handle !== "function") {
11
+ return String(handle);
12
+ }
13
+ const ctor = handle.constructor?.name ?? typeof handle;
14
+ if (ctor === "Socket") {
15
+ try {
16
+ const socket = handle;
17
+ const parts = ["Socket"];
18
+ if (socket.localAddress) {
19
+ parts.push(`local=${socket.localAddress}:${socket.localPort ?? "?"}`);
20
+ }
21
+ if (socket.remoteAddress) {
22
+ parts.push(`remote=${socket.remoteAddress}:${socket.remotePort ?? "?"}`);
23
+ }
24
+ if (typeof socket.address === "function") {
25
+ const addr = socket.address?.();
26
+ if (addr) {
27
+ parts.push(`addr=${addr.address}:${addr.port}`);
28
+ }
29
+ }
30
+ const host = handle._host;
31
+ if (host) {
32
+ parts.push(`host=${host}`);
33
+ }
34
+ const pipeName = handle.path;
35
+ if (pipeName) {
36
+ parts.push(`path=${pipeName}`);
37
+ }
38
+ const extraKeys = Reflect.ownKeys(handle).filter((key) => typeof key === "string" && key.startsWith("_") && !["_events", "_eventsCount"].includes(key)).slice(0, 4);
39
+ if (extraKeys.length > 0) {
40
+ parts.push(`keys=${extraKeys.join(",")}`);
41
+ }
42
+ return parts.join(" ");
43
+ } catch {
44
+ return ctor;
45
+ }
46
+ }
47
+ if (typeof handle === "object") {
48
+ const pid = handle.pid;
49
+ if (typeof pid === "number") {
50
+ return `${ctor} (pid=${pid})`;
51
+ }
52
+ const fd = handle.fd;
53
+ if (typeof fd === "number") {
54
+ return `${ctor} (fd=${fd})`;
55
+ }
56
+ }
57
+ return ctor;
58
+ }
59
+ function dumpActiveHandles(label) {
60
+ if (!DEBUG_HANG) {
61
+ return;
62
+ }
63
+ const proc = process;
64
+ const activeHandles = proc._getActiveHandles?.() ?? [];
65
+ const activeRequests = proc._getActiveRequests?.() ?? [];
66
+ logInfo(`[debug] ${label}: ${activeHandles.length} active handle(s), ${activeRequests.length} request(s)`);
67
+ for (const handle of activeHandles) {
68
+ logInfo(`[debug] handle => ${describeHandle(handle)}`);
69
+ }
70
+ for (const request of activeRequests) {
71
+ logInfo(`[debug] request => ${describeHandle(request)}`);
72
+ }
73
+ }
74
+ function terminateChildProcesses(label) {
75
+ const proc = process;
76
+ const handles = proc._getActiveHandles?.() ?? [];
77
+ for (const handle of handles) {
78
+ if (!handle || typeof handle !== "object") {
79
+ continue;
80
+ }
81
+ const candidate = handle;
82
+ const ctor = handle.constructor?.name ?? "";
83
+ if (ctor === "Socket" && typeof handle.destroy === "function") {
84
+ try {
85
+ handle.destroy?.();
86
+ if (typeof handle.unref === "function") {
87
+ handle.unref?.();
88
+ }
89
+ } catch {
90
+ }
91
+ }
92
+ if (typeof candidate.stdout?.destroy === "function") {
93
+ try {
94
+ candidate.stdout.destroy?.();
95
+ } catch {
96
+ }
97
+ }
98
+ if (typeof candidate.stderr?.destroy === "function") {
99
+ try {
100
+ candidate.stderr.destroy?.();
101
+ } catch {
102
+ }
103
+ }
104
+ if (typeof candidate.stdin?.end === "function") {
105
+ try {
106
+ candidate.stdin.end?.();
107
+ } catch {
108
+ }
109
+ }
110
+ if (DEBUG_HANG) {
111
+ const killed = candidate.kill?.("SIGKILL") ?? false;
112
+ if (candidate.pid) {
113
+ const outcome = killed ? "killed" : "kill-failed";
114
+ logWarn(`[debug] forcibly ${outcome} child pid=${candidate.pid} (${label})`);
115
+ }
116
+ } else if (typeof candidate.kill === "function" && typeof candidate.pid === "number" && !candidate.killed) {
117
+ try {
118
+ candidate.kill("SIGKILL");
119
+ } catch {
120
+ }
121
+ }
122
+ }
123
+ }
124
+
125
+ export {
126
+ DEBUG_HANG,
127
+ dumpActiveHandles,
128
+ terminateChildProcesses
129
+ };
@@ -0,0 +1,13 @@
1
+ import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+
3
+ // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/errors.js
4
+ var CliUsageError = class extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ this.name = "CliUsageError";
8
+ }
9
+ };
10
+
11
+ export {
12
+ CliUsageError
13
+ };
@@ -0,0 +1,90 @@
1
+ import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+
3
+ // node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/identifier-helpers.js
4
+ var AUTO_THRESHOLD_RATIO = 0.3;
5
+ var AUTO_THRESHOLD_MIN = 2;
6
+ function chooseClosestIdentifier(input, candidates) {
7
+ if (candidates.length === 0) {
8
+ return void 0;
9
+ }
10
+ const normalizedInput = normalizeIdentifier(input);
11
+ let bestName;
12
+ let bestScore = Number.POSITIVE_INFINITY;
13
+ for (const candidate of candidates) {
14
+ if (candidate === input) {
15
+ return { kind: "auto", value: candidate };
16
+ }
17
+ const normalizedCandidate = normalizeIdentifier(candidate);
18
+ if (normalizedCandidate === normalizedInput) {
19
+ return { kind: "auto", value: candidate };
20
+ }
21
+ if (candidate.toLowerCase() === input.toLowerCase()) {
22
+ return { kind: "auto", value: candidate };
23
+ }
24
+ const score = levenshtein(normalizedInput, normalizedCandidate);
25
+ if (score < bestScore) {
26
+ bestScore = score;
27
+ bestName = candidate;
28
+ }
29
+ }
30
+ if (!bestName) {
31
+ return void 0;
32
+ }
33
+ const normalizedBest = normalizeIdentifier(bestName);
34
+ const lengthBaseline = Math.max(normalizedInput.length, normalizedBest.length, 1);
35
+ const threshold = Math.max(AUTO_THRESHOLD_MIN, Math.floor(lengthBaseline * AUTO_THRESHOLD_RATIO));
36
+ if (bestScore <= threshold) {
37
+ return { kind: "auto", value: bestName };
38
+ }
39
+ return { kind: "suggest", value: bestName };
40
+ }
41
+ function normalizeIdentifier(value) {
42
+ return value.replace(/[^a-z0-9]/gi, "").toLowerCase();
43
+ }
44
+ function renderIdentifierResolutionMessages(context) {
45
+ const resolvedDisplay = context.entity === "tool" && context.scope ? `${context.scope}.${context.resolution.value}` : context.resolution.value;
46
+ const attemptedDisplay = context.entity === "tool" && context.scope ? `${context.scope}.${context.attempted}` : context.attempted;
47
+ if (context.resolution.kind === "auto") {
48
+ const noun = context.entity === "tool" ? "tool call" : "server name";
49
+ return {
50
+ auto: `[mcporter] Auto-corrected ${noun} to ${resolvedDisplay} (input: ${attemptedDisplay}).`
51
+ };
52
+ }
53
+ return {
54
+ suggest: `[mcporter] Did you mean ${resolvedDisplay}?`
55
+ };
56
+ }
57
+ function levenshtein(a, b) {
58
+ if (a === b) {
59
+ return 0;
60
+ }
61
+ if (a.length === 0) {
62
+ return b.length;
63
+ }
64
+ if (b.length === 0) {
65
+ return a.length;
66
+ }
67
+ const previous = Array.from({ length: b.length + 1 }, (_, index) => index);
68
+ const current = Array.from({ length: b.length + 1 }, () => 0);
69
+ for (let i = 1; i <= a.length; i += 1) {
70
+ current[0] = i;
71
+ const charA = a[i - 1];
72
+ for (let j = 1; j <= b.length; j += 1) {
73
+ const charB = b[j - 1];
74
+ const insertCost = (current[j - 1] ?? Number.POSITIVE_INFINITY) + 1;
75
+ const deleteCost = (previous[j] ?? Number.POSITIVE_INFINITY) + 1;
76
+ const replaceCost = (previous[j - 1] ?? Number.POSITIVE_INFINITY) + (charA === charB ? 0 : 1);
77
+ current[j] = Math.min(insertCost, deleteCost, replaceCost);
78
+ }
79
+ for (let j = 0; j <= b.length; j += 1) {
80
+ previous[j] = current[j] ?? Number.POSITIVE_INFINITY;
81
+ }
82
+ }
83
+ return previous[b.length] ?? Number.POSITIVE_INFINITY;
84
+ }
85
+
86
+ export {
87
+ chooseClosestIdentifier,
88
+ normalizeIdentifier,
89
+ renderIdentifierResolutionMessages
90
+ };