@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.
- package/README.md +45 -58
- package/dist/{agent-tool.d.ts → agents.d.ts} +4 -1
- package/dist/agents.d.ts.map +1 -0
- package/dist/{agent-tool.js → agents.js} +1 -1
- package/dist/agents.js.map +1 -0
- package/dist/api/extensions.d.ts +3 -0
- package/dist/api/extensions.d.ts.map +1 -0
- package/dist/api/extensions.js +2 -0
- package/dist/api/extensions.js.map +1 -0
- package/dist/api/mcp.d.ts +4 -0
- package/dist/api/mcp.d.ts.map +1 -0
- package/dist/api/mcp.js +2 -0
- package/dist/api/mcp.js.map +1 -0
- package/dist/api/session.d.ts +3 -0
- package/dist/api/session.d.ts.map +1 -0
- package/dist/api/session.js +2 -0
- package/dist/api/session.js.map +1 -0
- package/dist/child-agent.d.ts +5 -4
- package/dist/child-agent.d.ts.map +1 -1
- package/dist/child-agent.js +26 -117
- package/dist/child-agent.js.map +1 -1
- package/dist/child-session.d.ts +23 -0
- package/dist/child-session.d.ts.map +1 -0
- package/dist/child-session.js +48 -0
- package/dist/child-session.js.map +1 -0
- package/dist/extensions.d.ts +29 -0
- package/dist/extensions.d.ts.map +1 -0
- package/dist/extensions.js +119 -0
- package/dist/extensions.js.map +1 -0
- package/dist/index.d.ts +4 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -13
- package/dist/index.js.map +1 -1
- package/dist/inspect.d.ts +38 -5
- package/dist/inspect.d.ts.map +1 -1
- package/dist/inspect.js +92 -41
- package/dist/inspect.js.map +1 -1
- package/dist/interactions.d.ts +18 -2
- package/dist/interactions.d.ts.map +1 -1
- package/dist/interactions.js +41 -10
- package/dist/interactions.js.map +1 -1
- package/dist/mcp-catalog.d.ts +1 -0
- package/dist/mcp-catalog.d.ts.map +1 -1
- package/dist/mcp-catalog.js +14 -6
- package/dist/mcp-catalog.js.map +1 -1
- package/dist/mcp-chunks/auth-command-ZLGYIEUY.js +273 -0
- package/dist/mcp-chunks/call-arguments-LU3W6D3K.js +13 -0
- package/dist/mcp-chunks/call-command-LKTKSYTH.js +612 -0
- package/dist/mcp-chunks/chunk-2U4BSDC4.js +3951 -0
- package/dist/mcp-chunks/chunk-2XL7MG7R.js +272 -0
- package/dist/mcp-chunks/chunk-3BJA27PY.js +2321 -0
- package/dist/mcp-chunks/chunk-4SQKWYFF.js +15 -0
- package/dist/mcp-chunks/chunk-5QOSCSQB.js +290 -0
- package/dist/mcp-chunks/chunk-6W5QFASN.js +77 -0
- package/dist/mcp-chunks/chunk-6XCZGU3G.js +1004 -0
- package/dist/mcp-chunks/chunk-7FHEBT5G.js +149 -0
- package/dist/mcp-chunks/chunk-7KA2VJVZ.js +114 -0
- package/dist/mcp-chunks/chunk-7UDVSOOF.js +138 -0
- package/dist/mcp-chunks/chunk-BNV3TPE4.js +66 -0
- package/dist/mcp-chunks/chunk-BTLAWHTA.js +129 -0
- package/dist/mcp-chunks/chunk-BV56DXPW.js +13 -0
- package/dist/mcp-chunks/chunk-BWHIA4PC.js +90 -0
- package/dist/mcp-chunks/chunk-BZIQOWE6.js +267 -0
- package/dist/mcp-chunks/chunk-D3MRAZ6H.js +16140 -0
- package/dist/mcp-chunks/chunk-DHBE7UBH.js +750 -0
- package/dist/mcp-chunks/chunk-E22DYOW5.js +251 -0
- package/dist/mcp-chunks/chunk-ECIVB7P4.js +139 -0
- package/dist/mcp-chunks/chunk-HKRJ6O36.js +1076 -0
- package/dist/mcp-chunks/chunk-IABRYROW.js +44 -0
- package/dist/mcp-chunks/chunk-J6LYIZXN.js +45 -0
- package/dist/mcp-chunks/chunk-L7NTQVYN.js +161 -0
- package/dist/mcp-chunks/chunk-LEZSACDE.js +141 -0
- package/dist/mcp-chunks/chunk-LKIBAYKU.js +208 -0
- package/dist/mcp-chunks/chunk-LNH5LAJD.js +152 -0
- package/dist/mcp-chunks/chunk-LQQEYD76.js +124 -0
- package/dist/mcp-chunks/chunk-LRKZP7DJ.js +47 -0
- package/dist/mcp-chunks/chunk-LS7PMWSR.js +109 -0
- package/dist/mcp-chunks/chunk-M3TPODXI.js +95 -0
- package/dist/mcp-chunks/chunk-MZ2NARG7.js +400 -0
- package/dist/mcp-chunks/chunk-N46NEFAF.js +45 -0
- package/dist/mcp-chunks/chunk-NNOEGEUZ.js +17273 -0
- package/dist/mcp-chunks/chunk-NRAJX5E4.js +69 -0
- package/dist/mcp-chunks/chunk-P3PSC54P.js +869 -0
- package/dist/mcp-chunks/chunk-PIIYJR44.js +6341 -0
- package/dist/mcp-chunks/chunk-PWYFKGKG.js +385 -0
- package/dist/mcp-chunks/chunk-SJCCBNZ4.js +45 -0
- package/dist/mcp-chunks/chunk-TATVT5IT.js +194 -0
- package/dist/mcp-chunks/chunk-TEUKFFQL.js +29 -0
- package/dist/mcp-chunks/chunk-UKYNQGNE.js +150 -0
- package/dist/mcp-chunks/chunk-UNKB4SBV.js +37 -0
- package/dist/mcp-chunks/chunk-WD6BOD24.js +138 -0
- package/dist/mcp-chunks/chunk-WQJZMCJN.js +73 -0
- package/dist/mcp-chunks/chunk-XANPGTLI.js +364 -0
- package/dist/mcp-chunks/chunk-XQK2JSW4.js +35 -0
- package/dist/mcp-chunks/chunk-YHQUTU6L.js +571 -0
- package/dist/mcp-chunks/chunk-YVZKMV5H.js +57 -0
- package/dist/mcp-chunks/cli-UV4QJZZM.js +929 -0
- package/dist/mcp-chunks/client-S7RQUG5U.js +13 -0
- package/dist/mcp-chunks/config-command-NLAGKID5.js +1101 -0
- package/dist/mcp-chunks/daemon-command-U242Z6VY.js +26 -0
- package/dist/mcp-chunks/dist-LK3SHAMX.js +6478 -0
- package/dist/mcp-chunks/emit-ts-command-VBXVXO6V.js +386 -0
- package/dist/mcp-chunks/generate-cli-runner-6CAZZA3P.js +1426 -0
- package/dist/mcp-chunks/inspect-cli-command-3ZORTOR7.js +111 -0
- package/dist/mcp-chunks/launch-YKRXHXJI.js +10 -0
- package/dist/mcp-chunks/lifecycle-XVKRHPH3.js +16 -0
- package/dist/mcp-chunks/list-command-2MEGGNFQ.js +4190 -0
- package/dist/mcp-chunks/output-utils-NKESLAJ6.js +12 -0
- package/dist/mcp-chunks/prompt-B1Yc1NPt-VGOTWJMN.js +918 -0
- package/dist/mcp-chunks/record-command-YXHTTTT5.js +17 -0
- package/dist/mcp-chunks/replay-command-25HJ6AQU.js +85 -0
- package/dist/mcp-chunks/resource-command-OO4NYF5C.js +97 -0
- package/dist/mcp-chunks/result-utils-MOHHLNM7.js +15 -0
- package/dist/mcp-chunks/runtime-5WJ3G25Y.js +33 -0
- package/dist/mcp-chunks/runtime-wrapper-RPWDIDBF.js +10 -0
- package/dist/mcp-chunks/serve-command-DHXJZMMN.js +3302 -0
- package/dist/mcp-chunks/timeouts-W2XWCCXR.js +18 -0
- package/dist/mcp-chunks/vault-command-PIYIUEZL.js +154 -0
- package/dist/mcp-daemon-client.d.ts +6 -1
- package/dist/mcp-daemon-client.d.ts.map +1 -1
- package/dist/mcp-daemon-client.js +119 -2
- package/dist/mcp-daemon-client.js.map +1 -1
- package/dist/mcp-daemon-protocol.d.ts +18 -1
- package/dist/mcp-daemon-protocol.d.ts.map +1 -1
- package/dist/mcp-daemon-protocol.js +31 -0
- package/dist/mcp-daemon-protocol.js.map +1 -1
- package/dist/mcp-daemon.js +169 -76602
- package/dist/mcp-daemon.js.map +1 -1
- package/dist/mcp-policy.d.ts +11 -0
- package/dist/mcp-policy.d.ts.map +1 -0
- package/dist/mcp-policy.js +27 -0
- package/dist/mcp-policy.js.map +1 -0
- package/dist/mcp-run-worker.js +38 -76540
- package/dist/mcp-tools.d.ts +39 -0
- package/dist/mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools.js +493 -0
- package/dist/mcp-tools.js.map +1 -0
- package/dist/mcp.d.ts +21 -9
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +101 -31
- package/dist/mcp.js.map +1 -1
- package/dist/model-binding.d.ts +39 -0
- package/dist/model-binding.d.ts.map +1 -0
- package/dist/model-binding.js +103 -0
- package/dist/model-binding.js.map +1 -0
- package/dist/pi-extension.d.ts +2 -22
- package/dist/pi-extension.d.ts.map +1 -1
- package/dist/pi-extension.js +296 -71
- package/dist/pi-extension.js.map +1 -1
- package/dist/recipe/resolve.d.ts +43 -20
- package/dist/recipe/resolve.d.ts.map +1 -1
- package/dist/recipe/resolve.js +215 -70
- package/dist/recipe/resolve.js.map +1 -1
- package/dist/recipe-agent.d.ts +24 -27
- package/dist/recipe-agent.d.ts.map +1 -1
- package/dist/recipe-agent.js +278 -230
- package/dist/recipe-agent.js.map +1 -1
- package/dist/recipe-check.d.ts +17 -0
- package/dist/recipe-check.d.ts.map +1 -0
- package/dist/recipe-check.js +258 -0
- package/dist/recipe-check.js.map +1 -0
- package/dist/recipe-extensions.d.ts.map +1 -1
- package/dist/recipe-extensions.js +0 -3
- package/dist/recipe-extensions.js.map +1 -1
- package/dist/recipe-model.d.ts +3 -1
- package/dist/recipe-model.d.ts.map +1 -1
- package/dist/recipe-model.js +15 -12
- package/dist/recipe-model.js.map +1 -1
- package/dist/recipe-package.d.ts +6 -28
- package/dist/recipe-package.d.ts.map +1 -1
- package/dist/recipe-package.js +248 -191
- package/dist/recipe-package.js.map +1 -1
- package/dist/recipe-skills.d.ts.map +1 -1
- package/dist/recipe-skills.js +42 -29
- package/dist/recipe-skills.js.map +1 -1
- package/dist/run-controller.d.ts +10 -9
- package/dist/run-controller.d.ts.map +1 -1
- package/dist/run-controller.js +28 -21
- package/dist/run-controller.js.map +1 -1
- package/dist/session.d.ts +40 -53
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +312 -173
- package/dist/session.js.map +1 -1
- package/dist/test-utils.d.ts +7 -7
- package/dist/test-utils.d.ts.map +1 -1
- package/dist/test-utils.js +32 -15
- package/dist/test-utils.js.map +1 -1
- package/docs/agent-composition.md +41 -35
- package/docs/host-api.md +201 -0
- package/docs/index.md +8 -14
- package/docs/interactions.md +12 -11
- package/docs/mcp-auth.md +6 -6
- package/docs/mcp-configuration.md +72 -24
- package/docs/pi-extension.md +39 -11
- package/docs/recipe-flow.md +9 -9
- package/docs/recipe-format.md +90 -41
- package/package.json +23 -17
- package/vendor/mcp-client/darwin-arm64/mcp-client +0 -0
- package/vendor/mcp-client/darwin-x64/mcp-client +0 -0
- package/vendor/mcp-client/linux-arm64/mcp-client +0 -0
- package/vendor/recipe-check/darwin-arm64/recipe-check +0 -0
- package/vendor/recipe-check/darwin-x64/recipe-check +0 -0
- package/vendor/recipe-check/linux-arm64/recipe-check +0 -0
- package/vendor/recipe-check/linux-x64/recipe-check +0 -0
- package/vendor/recipe-check/linux-x64-musl/recipe-check +0 -0
- package/vendor/recipe-check/win32-x64/recipe-check.exe +0 -0
- package/dist/agent-tool.d.ts.map +0 -1
- package/dist/agent-tool.js.map +0 -1
- package/dist/run.d.ts +0 -28
- package/dist/run.d.ts.map +0 -1
- package/dist/run.js +0 -84
- package/dist/run.js.map +0 -1
- package/dist/testing.d.ts +0 -25
- package/dist/testing.d.ts.map +0 -1
- package/dist/testing.js +0 -96
- package/dist/testing.js.map +0 -1
- package/docs/deployment-configuration.md +0 -65
- package/docs/migration.md +0 -70
- package/docs/python-bindings-release.md +0 -47
- package/docs/recipe-evals.md +0 -70
- package/docs/recipe-judges.md +0 -152
- package/docs/runtime-library.md +0 -171
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
__configInternals
|
|
4
|
+
} from "./chunk-2U4BSDC4.js";
|
|
5
|
+
import {
|
|
6
|
+
withFileLock,
|
|
7
|
+
writeTextFileAtomic
|
|
8
|
+
} from "./chunk-2XL7MG7R.js";
|
|
9
|
+
import {
|
|
10
|
+
expandHome
|
|
11
|
+
} from "./chunk-ECIVB7P4.js";
|
|
12
|
+
import {
|
|
13
|
+
canonicalKeepAliveName,
|
|
14
|
+
resolveLifecycle
|
|
15
|
+
} from "./chunk-LS7PMWSR.js";
|
|
16
|
+
|
|
17
|
+
// node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/adhoc-server.js
|
|
18
|
+
import fs from "node:fs/promises";
|
|
19
|
+
import path from "node:path";
|
|
20
|
+
var TEMP_SOURCE = { kind: "local", path: "<adhoc>" };
|
|
21
|
+
function resolveEphemeralServer(spec) {
|
|
22
|
+
if (!spec.httpUrl && !spec.stdioCommand) {
|
|
23
|
+
throw new Error("Ad-hoc servers require either --http-url or --stdio.");
|
|
24
|
+
}
|
|
25
|
+
if (spec.httpUrl && spec.stdioCommand) {
|
|
26
|
+
throw new Error("Cannot combine --http-url and --stdio in the same ad-hoc server.");
|
|
27
|
+
}
|
|
28
|
+
if (spec.httpUrl) {
|
|
29
|
+
const url = new URL(spec.httpUrl);
|
|
30
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
|
31
|
+
throw new Error(`Unsupported protocol '${url.protocol}' for --http-url.`);
|
|
32
|
+
}
|
|
33
|
+
if (url.protocol === "http:" && !spec.allowInsecureHttp) {
|
|
34
|
+
throw new Error("HTTP endpoints require --allow-http to confirm insecure usage.");
|
|
35
|
+
}
|
|
36
|
+
const command2 = {
|
|
37
|
+
kind: "http",
|
|
38
|
+
url,
|
|
39
|
+
headers: __configInternals.ensureHttpAcceptHeader(spec.headers)
|
|
40
|
+
};
|
|
41
|
+
const canonical2 = spec.name ? void 0 : canonicalKeepAliveName(command2);
|
|
42
|
+
const name2 = normalizeEphemeralName(spec.name ?? canonical2 ?? inferNameFromUrl(url));
|
|
43
|
+
const lifecycle2 = resolveLifecycle(name2, void 0, command2);
|
|
44
|
+
const definition2 = {
|
|
45
|
+
name: name2,
|
|
46
|
+
description: spec.description,
|
|
47
|
+
command: command2,
|
|
48
|
+
env: spec.env && Object.keys(spec.env).length > 0 ? spec.env : void 0,
|
|
49
|
+
source: TEMP_SOURCE,
|
|
50
|
+
lifecycle: lifecycle2
|
|
51
|
+
};
|
|
52
|
+
const persistedEntry2 = {
|
|
53
|
+
baseUrl: url.href,
|
|
54
|
+
...spec.description ? { description: spec.description } : {},
|
|
55
|
+
...spec.env && Object.keys(spec.env).length > 0 ? { env: spec.env } : {},
|
|
56
|
+
...spec.headers && Object.keys(spec.headers).length > 0 ? { headers: spec.headers } : {},
|
|
57
|
+
...lifecycle2 ? { lifecycle: serializeLifecycle(lifecycle2) } : {}
|
|
58
|
+
};
|
|
59
|
+
return { definition: definition2, name: name2, persistedEntry: persistedEntry2 };
|
|
60
|
+
}
|
|
61
|
+
const stdioCommand = spec.stdioCommand;
|
|
62
|
+
const parts = splitCommandLine(stdioCommand);
|
|
63
|
+
if (parts.length === 0) {
|
|
64
|
+
throw new Error("--stdio requires a non-empty command.");
|
|
65
|
+
}
|
|
66
|
+
const [commandBinary, ...commandRest] = parts;
|
|
67
|
+
const commandArgs = commandRest.concat(spec.stdioArgs ?? []);
|
|
68
|
+
const cwd = spec.cwd ? path.resolve(spec.cwd) : process.cwd();
|
|
69
|
+
const command = {
|
|
70
|
+
kind: "stdio",
|
|
71
|
+
command: commandBinary,
|
|
72
|
+
args: commandArgs,
|
|
73
|
+
cwd
|
|
74
|
+
};
|
|
75
|
+
const canonical = spec.name ? void 0 : canonicalKeepAliveName(command);
|
|
76
|
+
const name = normalizeEphemeralName(spec.name ?? canonical ?? inferNameFromCommand(parts));
|
|
77
|
+
const lifecycle = resolveLifecycle(name, void 0, command);
|
|
78
|
+
const definition = {
|
|
79
|
+
name,
|
|
80
|
+
description: spec.description,
|
|
81
|
+
command,
|
|
82
|
+
env: spec.env && Object.keys(spec.env).length > 0 ? spec.env : void 0,
|
|
83
|
+
source: TEMP_SOURCE,
|
|
84
|
+
lifecycle
|
|
85
|
+
};
|
|
86
|
+
const persistedEntry = {
|
|
87
|
+
command: commandBinary,
|
|
88
|
+
...commandArgs.length > 0 ? { args: commandArgs } : {},
|
|
89
|
+
...spec.description ? { description: spec.description } : {},
|
|
90
|
+
...spec.env && Object.keys(spec.env).length > 0 ? { env: spec.env } : {},
|
|
91
|
+
...lifecycle ? { lifecycle: serializeLifecycle(lifecycle) } : {}
|
|
92
|
+
};
|
|
93
|
+
if (spec.cwd) {
|
|
94
|
+
persistedEntry.cwd = spec.cwd;
|
|
95
|
+
}
|
|
96
|
+
return { definition, name, persistedEntry };
|
|
97
|
+
}
|
|
98
|
+
async function persistEphemeralServer(resolution, rawPath) {
|
|
99
|
+
const resolvedPath = path.resolve(expandHome(rawPath));
|
|
100
|
+
await withFileLock(resolvedPath, async () => {
|
|
101
|
+
let existing;
|
|
102
|
+
try {
|
|
103
|
+
const buffer = await fs.readFile(resolvedPath, "utf8");
|
|
104
|
+
existing = JSON.parse(buffer);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
if (error.code !== "ENOENT") {
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
existing = { mcpServers: {} };
|
|
110
|
+
}
|
|
111
|
+
if (typeof existing.mcpServers !== "object" || existing.mcpServers === null) {
|
|
112
|
+
existing.mcpServers = {};
|
|
113
|
+
}
|
|
114
|
+
const servers = existing.mcpServers;
|
|
115
|
+
servers[resolution.name] = resolution.persistedEntry;
|
|
116
|
+
const serialized = `${JSON.stringify(existing, null, 2)}
|
|
117
|
+
`;
|
|
118
|
+
await writeTextFileAtomic(resolvedPath, serialized);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function inferNameFromUrl(url) {
|
|
122
|
+
const host = url.hostname.replace(/^www\./, "");
|
|
123
|
+
const pathSegments = url.pathname.split("/").filter(Boolean);
|
|
124
|
+
if (pathSegments.length === 0) {
|
|
125
|
+
return host;
|
|
126
|
+
}
|
|
127
|
+
return `${host}-${pathSegments[pathSegments.length - 1]}`;
|
|
128
|
+
}
|
|
129
|
+
function inferNameFromCommand(parts) {
|
|
130
|
+
const wrapperPackage = inferPackageFromWrapper(parts);
|
|
131
|
+
if (wrapperPackage) {
|
|
132
|
+
return wrapperPackage;
|
|
133
|
+
}
|
|
134
|
+
const executable = path.basename(parts[0] ?? "command");
|
|
135
|
+
if (parts.length === 1) {
|
|
136
|
+
return executable;
|
|
137
|
+
}
|
|
138
|
+
const script = parts.find((segment) => segment.endsWith(".ts") || segment.endsWith(".js"));
|
|
139
|
+
if (script) {
|
|
140
|
+
return `${executable}-${path.basename(script, path.extname(script))}`;
|
|
141
|
+
}
|
|
142
|
+
const fallback = parts[1] ?? "tool";
|
|
143
|
+
return `${executable}-${fallback}`;
|
|
144
|
+
}
|
|
145
|
+
function inferPackageFromWrapper(parts) {
|
|
146
|
+
if (parts.length < 2) {
|
|
147
|
+
return void 0;
|
|
148
|
+
}
|
|
149
|
+
const executable = path.basename(parts[0] ?? "");
|
|
150
|
+
if (executable !== "npx") {
|
|
151
|
+
return void 0;
|
|
152
|
+
}
|
|
153
|
+
for (let index = 1; index < parts.length; index += 1) {
|
|
154
|
+
const token = parts[index];
|
|
155
|
+
if (!token) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (token === "--") {
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
if (token.startsWith("-")) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
return stripPackageVersion(token);
|
|
165
|
+
}
|
|
166
|
+
return void 0;
|
|
167
|
+
}
|
|
168
|
+
function stripPackageVersion(token) {
|
|
169
|
+
if (token.startsWith("@")) {
|
|
170
|
+
const secondAt = token.indexOf("@", 1);
|
|
171
|
+
if (secondAt !== -1) {
|
|
172
|
+
return token.slice(0, secondAt);
|
|
173
|
+
}
|
|
174
|
+
return token;
|
|
175
|
+
}
|
|
176
|
+
const versionAt = token.indexOf("@");
|
|
177
|
+
if (versionAt > 0) {
|
|
178
|
+
return token.slice(0, versionAt);
|
|
179
|
+
}
|
|
180
|
+
return token;
|
|
181
|
+
}
|
|
182
|
+
function slugify(value) {
|
|
183
|
+
return value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, "-");
|
|
184
|
+
}
|
|
185
|
+
function normalizeEphemeralName(value) {
|
|
186
|
+
const name = slugify(value);
|
|
187
|
+
if (!name) {
|
|
188
|
+
throw new Error("Ad-hoc server name must contain at least one letter or digit.");
|
|
189
|
+
}
|
|
190
|
+
return name;
|
|
191
|
+
}
|
|
192
|
+
function splitCommandLine(input) {
|
|
193
|
+
const result = [];
|
|
194
|
+
let current = "";
|
|
195
|
+
let inSingle = false;
|
|
196
|
+
let inDouble = false;
|
|
197
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
198
|
+
const char = input.charAt(i);
|
|
199
|
+
if (char === "'" && !inDouble) {
|
|
200
|
+
inSingle = !inSingle;
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (char === '"' && !inSingle) {
|
|
204
|
+
inDouble = !inDouble;
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if (!inSingle && !inDouble && /\s/.test(char)) {
|
|
208
|
+
if (current !== "") {
|
|
209
|
+
result.push(current);
|
|
210
|
+
current = "";
|
|
211
|
+
}
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
if (char === "\\" && !inSingle && i + 1 < input.length) {
|
|
215
|
+
const next = input.charAt(i + 1);
|
|
216
|
+
if (inDouble && next !== '"' && next !== "\\" && next !== "$") {
|
|
217
|
+
current += char;
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
current += next;
|
|
221
|
+
i += 1;
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
current += char;
|
|
225
|
+
}
|
|
226
|
+
if (inSingle || inDouble) {
|
|
227
|
+
throw new Error("Unterminated quote in --stdio command.");
|
|
228
|
+
}
|
|
229
|
+
if (current !== "") {
|
|
230
|
+
result.push(current);
|
|
231
|
+
}
|
|
232
|
+
return result;
|
|
233
|
+
}
|
|
234
|
+
function serializeLifecycle(lifecycle) {
|
|
235
|
+
if (!lifecycle) {
|
|
236
|
+
return void 0;
|
|
237
|
+
}
|
|
238
|
+
if (lifecycle.mode === "keep-alive" && lifecycle.idleTimeoutMs === void 0) {
|
|
239
|
+
return "keep-alive";
|
|
240
|
+
}
|
|
241
|
+
if (lifecycle.mode === "keep-alive") {
|
|
242
|
+
return { mode: "keep-alive", idleTimeoutMs: lifecycle.idleTimeoutMs };
|
|
243
|
+
}
|
|
244
|
+
return "ephemeral";
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export {
|
|
248
|
+
resolveEphemeralServer,
|
|
249
|
+
persistEphemeralServer,
|
|
250
|
+
splitCommandLine
|
|
251
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
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/env.js
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
var ENV_DEFAULT_PATTERN = /^\$\{([A-Za-z_][A-Za-z0-9_]*)(?::-|:|-)?([^}]*)\}$/;
|
|
7
|
+
var ENV_INTERPOLATION_PATTERN = /\\?\$\{([A-Za-z_][A-Za-z0-9_]*)(?::-(.*?))?\}/g;
|
|
8
|
+
var ENV_DIRECT_PREFIX = "$env:";
|
|
9
|
+
function expandHome(input) {
|
|
10
|
+
if (!input.startsWith("~")) {
|
|
11
|
+
return input;
|
|
12
|
+
}
|
|
13
|
+
const home = os.homedir();
|
|
14
|
+
if (input === "~") {
|
|
15
|
+
return home;
|
|
16
|
+
}
|
|
17
|
+
if (input.startsWith("~/") || input.startsWith("~\\")) {
|
|
18
|
+
return path.join(home, input.slice(2));
|
|
19
|
+
}
|
|
20
|
+
return input;
|
|
21
|
+
}
|
|
22
|
+
function resolveEnvValue(raw) {
|
|
23
|
+
if (typeof raw !== "string") {
|
|
24
|
+
return String(raw);
|
|
25
|
+
}
|
|
26
|
+
const match = ENV_DEFAULT_PATTERN.exec(raw);
|
|
27
|
+
if (match) {
|
|
28
|
+
const envName = match[1];
|
|
29
|
+
const defaultValue = match[2] ?? "";
|
|
30
|
+
if (!envName) {
|
|
31
|
+
return raw;
|
|
32
|
+
}
|
|
33
|
+
const existing = process.env[envName];
|
|
34
|
+
if (existing && existing !== "") {
|
|
35
|
+
return existing;
|
|
36
|
+
}
|
|
37
|
+
return defaultValue;
|
|
38
|
+
}
|
|
39
|
+
if (raw.startsWith("$")) {
|
|
40
|
+
return resolveEnvPlaceholders(raw);
|
|
41
|
+
}
|
|
42
|
+
return raw;
|
|
43
|
+
}
|
|
44
|
+
function resolveEnvPlaceholders(value) {
|
|
45
|
+
if (value.startsWith(ENV_DIRECT_PREFIX)) {
|
|
46
|
+
const envName = value.slice(ENV_DIRECT_PREFIX.length);
|
|
47
|
+
const envValue = process.env[envName];
|
|
48
|
+
if (envValue === void 0) {
|
|
49
|
+
throw new Error(`Environment variable '${envName}' is required for MCP header substitution.`);
|
|
50
|
+
}
|
|
51
|
+
return envValue;
|
|
52
|
+
}
|
|
53
|
+
const missing = /* @__PURE__ */ new Set();
|
|
54
|
+
const replaced = value.replace(ENV_INTERPOLATION_PATTERN, (placeholder, envName, fallback) => {
|
|
55
|
+
const envValue = process.env[envName];
|
|
56
|
+
if (envValue !== void 0 && envValue !== "") {
|
|
57
|
+
return envValue;
|
|
58
|
+
}
|
|
59
|
+
if (fallback !== void 0) {
|
|
60
|
+
return fallback;
|
|
61
|
+
}
|
|
62
|
+
if (envValue === void 0) {
|
|
63
|
+
missing.add(envName);
|
|
64
|
+
return placeholder;
|
|
65
|
+
}
|
|
66
|
+
return envValue;
|
|
67
|
+
});
|
|
68
|
+
if (missing.size > 0) {
|
|
69
|
+
const names = [...missing].toSorted().join(", ");
|
|
70
|
+
throw new Error(`Environment variable(s) ${names} must be set for MCP header substitution.`);
|
|
71
|
+
}
|
|
72
|
+
return replaced;
|
|
73
|
+
}
|
|
74
|
+
async function withEnvOverrides(envOverrides, fn) {
|
|
75
|
+
if (!envOverrides || Object.keys(envOverrides).length === 0) {
|
|
76
|
+
return await fn();
|
|
77
|
+
}
|
|
78
|
+
const applied = [];
|
|
79
|
+
for (const [key, rawValue] of Object.entries(envOverrides)) {
|
|
80
|
+
if (process.env[key]) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const resolved = resolveEnvValue(rawValue);
|
|
84
|
+
if (resolved === "") {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
process.env[key] = resolved;
|
|
88
|
+
applied.push(key);
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
return await fn();
|
|
92
|
+
} finally {
|
|
93
|
+
for (const key of applied) {
|
|
94
|
+
delete process.env[key];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/paths.js
|
|
100
|
+
import os2 from "node:os";
|
|
101
|
+
import path2 from "node:path";
|
|
102
|
+
var XDG_HOME_ENV = {
|
|
103
|
+
config: "XDG_CONFIG_HOME",
|
|
104
|
+
data: "XDG_DATA_HOME",
|
|
105
|
+
state: "XDG_STATE_HOME",
|
|
106
|
+
cache: "XDG_CACHE_HOME"
|
|
107
|
+
};
|
|
108
|
+
function legacyMcporterDir() {
|
|
109
|
+
return path2.join(os2.homedir(), ".mcporter");
|
|
110
|
+
}
|
|
111
|
+
function mcporterDir(kind) {
|
|
112
|
+
const raw = process.env[XDG_HOME_ENV[kind]];
|
|
113
|
+
if (raw && raw.trim().length > 0) {
|
|
114
|
+
const resolved = expandHome(raw.trim());
|
|
115
|
+
if (path2.isAbsolute(resolved)) {
|
|
116
|
+
return path2.join(resolved, "mcporter");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return legacyMcporterDir();
|
|
120
|
+
}
|
|
121
|
+
function mcporterConfigCandidates() {
|
|
122
|
+
const base = mcporterDir("config");
|
|
123
|
+
const candidates = [path2.join(base, "mcporter.json"), path2.join(base, "mcporter.jsonc")];
|
|
124
|
+
if (base !== legacyMcporterDir()) {
|
|
125
|
+
const legacy = legacyMcporterDir();
|
|
126
|
+
candidates.push(path2.join(legacy, "mcporter.json"), path2.join(legacy, "mcporter.jsonc"));
|
|
127
|
+
}
|
|
128
|
+
return candidates;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export {
|
|
132
|
+
expandHome,
|
|
133
|
+
resolveEnvValue,
|
|
134
|
+
resolveEnvPlaceholders,
|
|
135
|
+
withEnvOverrides,
|
|
136
|
+
legacyMcporterDir,
|
|
137
|
+
mcporterDir,
|
|
138
|
+
mcporterConfigCandidates
|
|
139
|
+
};
|