@introspection-ai/recipes 0.13.0 → 0.14.1
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 +46 -57
- 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 +18 -0
- package/dist/recipe-check.d.ts.map +1 -0
- package/dist/recipe-check.js +261 -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 +9 -14
- package/docs/interactions.md +12 -11
- package/docs/mcp-auth.md +6 -6
- package/docs/mcp-configuration.md +73 -25
- package/docs/pi-extension.md +39 -11
- package/docs/recipe-flow.md +9 -9
- package/docs/recipe-format.md +106 -41
- package/docs/recipe-judges.md +24 -36
- 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/runtime-library.md +0 -171
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
buildToolMetadataList
|
|
4
|
+
} from "./chunk-XANPGTLI.js";
|
|
5
|
+
|
|
6
|
+
// node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/tool-cache.js
|
|
7
|
+
var runtimeCache = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
function cacheKey(serverName, options) {
|
|
9
|
+
const includeSchema = options.includeSchema !== false;
|
|
10
|
+
const autoAuthorize = options.autoAuthorize !== false;
|
|
11
|
+
const allowCachedAuth = options.allowCachedAuth !== false;
|
|
12
|
+
const disableOAuth = options.disableOAuth === true;
|
|
13
|
+
return `${serverName}::schema:${includeSchema ? "1" : "0"}::auth:${autoAuthorize ? "1" : "0"}::cached-auth:${allowCachedAuth ? "1" : "0"}::disable-oauth:${disableOAuth ? "1" : "0"}`;
|
|
14
|
+
}
|
|
15
|
+
async function loadToolMetadata(runtime, serverName, options = {}) {
|
|
16
|
+
const key = cacheKey(serverName, options);
|
|
17
|
+
let cache = runtimeCache.get(runtime);
|
|
18
|
+
if (!cache) {
|
|
19
|
+
cache = /* @__PURE__ */ new Map();
|
|
20
|
+
runtimeCache.set(runtime, cache);
|
|
21
|
+
}
|
|
22
|
+
const existing = cache.get(key);
|
|
23
|
+
if (existing) {
|
|
24
|
+
return existing;
|
|
25
|
+
}
|
|
26
|
+
const includeSchema = options.includeSchema !== false;
|
|
27
|
+
const autoAuthorize = options.autoAuthorize !== false;
|
|
28
|
+
const listOptions = {
|
|
29
|
+
includeSchema,
|
|
30
|
+
autoAuthorize,
|
|
31
|
+
allowCachedAuth: options.allowCachedAuth ?? true,
|
|
32
|
+
disableOAuth: options.disableOAuth
|
|
33
|
+
};
|
|
34
|
+
const promise = runtime.listTools(serverName, listOptions).then((tools) => buildToolMetadataList(tools, { sort: false })).catch((error) => {
|
|
35
|
+
cache?.delete(key);
|
|
36
|
+
throw error;
|
|
37
|
+
});
|
|
38
|
+
cache.set(key, promise);
|
|
39
|
+
return promise;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
loadToolMetadata
|
|
44
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
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/record-replay-env.js
|
|
4
|
+
var KEEP_ALIVE_DISABLED_FOR_MODE = "*";
|
|
5
|
+
function buildRecordCommandEnv(sessionName, server) {
|
|
6
|
+
return buildModeEnv({
|
|
7
|
+
MCPORTER_RECORD: sessionName,
|
|
8
|
+
MCPORTER_RECORD_SERVER: server,
|
|
9
|
+
MCPORTER_DISABLE_KEEPALIVE: KEEP_ALIVE_DISABLED_FOR_MODE
|
|
10
|
+
}, ["MCPORTER_REPLAY", "MCPORTER_REPLAY_SERVER"]);
|
|
11
|
+
}
|
|
12
|
+
function buildReplayCommandEnv(sessionName, server) {
|
|
13
|
+
return buildModeEnv({
|
|
14
|
+
MCPORTER_REPLAY: sessionName,
|
|
15
|
+
MCPORTER_REPLAY_SERVER: server,
|
|
16
|
+
MCPORTER_DISABLE_KEEPALIVE: KEEP_ALIVE_DISABLED_FOR_MODE
|
|
17
|
+
}, ["MCPORTER_RECORD", "MCPORTER_RECORD_SERVER"]);
|
|
18
|
+
}
|
|
19
|
+
function isRecordReplayModeActive(env = process.env) {
|
|
20
|
+
return Boolean(env.MCPORTER_RECORD || env.MCPORTER_REPLAY);
|
|
21
|
+
}
|
|
22
|
+
function isReplayModeActive(env = process.env) {
|
|
23
|
+
return Boolean(!env.MCPORTER_RECORD && env.MCPORTER_REPLAY);
|
|
24
|
+
}
|
|
25
|
+
function buildModeEnv(set, unset) {
|
|
26
|
+
const env = { ...process.env };
|
|
27
|
+
for (const key of unset) {
|
|
28
|
+
delete env[key];
|
|
29
|
+
}
|
|
30
|
+
for (const [key, value] of Object.entries(set)) {
|
|
31
|
+
if (value) {
|
|
32
|
+
env[key] = value;
|
|
33
|
+
} else {
|
|
34
|
+
delete env[key];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return env;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
buildRecordCommandEnv,
|
|
42
|
+
buildReplayCommandEnv,
|
|
43
|
+
isRecordReplayModeActive,
|
|
44
|
+
isReplayModeActive
|
|
45
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
isKeepAliveServer
|
|
4
|
+
} from "./chunk-LS7PMWSR.js";
|
|
5
|
+
import {
|
|
6
|
+
ErrorCode,
|
|
7
|
+
McpError
|
|
8
|
+
} from "./chunk-D3MRAZ6H.js";
|
|
9
|
+
|
|
10
|
+
// node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/daemon/runtime-wrapper.js
|
|
11
|
+
function createKeepAliveRuntime(base, options) {
|
|
12
|
+
if (!options.daemonClient || options.keepAliveServers.size === 0) {
|
|
13
|
+
return base;
|
|
14
|
+
}
|
|
15
|
+
return new KeepAliveRuntime(base, options.daemonClient, options.keepAliveServers);
|
|
16
|
+
}
|
|
17
|
+
var KeepAliveRuntime = class {
|
|
18
|
+
base;
|
|
19
|
+
daemon;
|
|
20
|
+
keepAliveServers;
|
|
21
|
+
restartPromises = /* @__PURE__ */ new Map();
|
|
22
|
+
constructor(base, daemon, keepAliveServers) {
|
|
23
|
+
this.base = base;
|
|
24
|
+
this.daemon = daemon;
|
|
25
|
+
this.keepAliveServers = keepAliveServers;
|
|
26
|
+
}
|
|
27
|
+
listServers() {
|
|
28
|
+
return this.base.listServers();
|
|
29
|
+
}
|
|
30
|
+
getDefinitions() {
|
|
31
|
+
return this.base.getDefinitions();
|
|
32
|
+
}
|
|
33
|
+
getDefinition(server) {
|
|
34
|
+
return this.base.getDefinition(server);
|
|
35
|
+
}
|
|
36
|
+
registerDefinition(definition, options) {
|
|
37
|
+
this.base.registerDefinition(definition, options);
|
|
38
|
+
if (isKeepAliveServer(definition)) {
|
|
39
|
+
this.keepAliveServers.add(definition.name);
|
|
40
|
+
} else {
|
|
41
|
+
this.keepAliveServers.delete(definition.name);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async getInstructions(server) {
|
|
45
|
+
return this.base.getInstructions?.(server);
|
|
46
|
+
}
|
|
47
|
+
async listTools(server, options) {
|
|
48
|
+
if (options?.oauthSessionOptions) {
|
|
49
|
+
return this.base.listTools(server, options);
|
|
50
|
+
}
|
|
51
|
+
if (this.shouldUseDaemon(server)) {
|
|
52
|
+
return await this.invokeWithRestart(server, "listTools", () => this.daemon.listTools({
|
|
53
|
+
server,
|
|
54
|
+
includeSchema: options?.includeSchema,
|
|
55
|
+
autoAuthorize: options?.autoAuthorize,
|
|
56
|
+
allowCachedAuth: options?.allowCachedAuth ?? true,
|
|
57
|
+
disableOAuth: options?.disableOAuth
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
return this.base.listTools(server, options);
|
|
61
|
+
}
|
|
62
|
+
async callTool(server, toolName, options) {
|
|
63
|
+
if (this.shouldUseDaemon(server)) {
|
|
64
|
+
return this.invokeWithRestart(server, "callTool", () => this.daemon.callTool({
|
|
65
|
+
server,
|
|
66
|
+
tool: toolName,
|
|
67
|
+
args: options?.args,
|
|
68
|
+
timeoutMs: options?.timeoutMs,
|
|
69
|
+
disableOAuth: options?.disableOAuth
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
return this.base.callTool(server, toolName, options);
|
|
73
|
+
}
|
|
74
|
+
async listResources(server, options) {
|
|
75
|
+
if (options?.oauthSessionOptions) {
|
|
76
|
+
return this.base.listResources(server, options);
|
|
77
|
+
}
|
|
78
|
+
const { allowCachedAuth, disableOAuth, ...params } = options ?? {};
|
|
79
|
+
if (this.shouldUseDaemon(server)) {
|
|
80
|
+
return this.invokeWithRestart(server, "listResources", () => this.daemon.listResources({ server, params, allowCachedAuth, disableOAuth }));
|
|
81
|
+
}
|
|
82
|
+
return this.base.listResources(server, options);
|
|
83
|
+
}
|
|
84
|
+
async readResource(server, uri, options) {
|
|
85
|
+
if (options?.oauthSessionOptions) {
|
|
86
|
+
return this.base.readResource(server, uri, options);
|
|
87
|
+
}
|
|
88
|
+
if (this.shouldUseDaemon(server)) {
|
|
89
|
+
return this.invokeWithRestart(server, "readResource", () => this.daemon.readResource({
|
|
90
|
+
server,
|
|
91
|
+
uri,
|
|
92
|
+
allowCachedAuth: options?.allowCachedAuth,
|
|
93
|
+
disableOAuth: options?.disableOAuth
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
return this.base.readResource(server, uri, options);
|
|
97
|
+
}
|
|
98
|
+
async connect(server, options) {
|
|
99
|
+
return this.base.connect(server, options);
|
|
100
|
+
}
|
|
101
|
+
async close(server) {
|
|
102
|
+
if (!server) {
|
|
103
|
+
await this.base.close();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (this.shouldUseDaemon(server)) {
|
|
107
|
+
await this.daemon.closeServer({ server }).catch(() => {
|
|
108
|
+
});
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
await this.base.close(server);
|
|
112
|
+
}
|
|
113
|
+
shouldUseDaemon(server) {
|
|
114
|
+
return this.keepAliveServers.has(server);
|
|
115
|
+
}
|
|
116
|
+
async invokeWithRestart(server, operation, action) {
|
|
117
|
+
try {
|
|
118
|
+
return await action();
|
|
119
|
+
} catch (error) {
|
|
120
|
+
if (!shouldRestartDaemonServer(error)) {
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
logDaemonRetry(server, operation, error);
|
|
124
|
+
await this.restartServer(server);
|
|
125
|
+
return action();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async restartServer(server) {
|
|
129
|
+
const existing = this.restartPromises.get(server);
|
|
130
|
+
if (existing) {
|
|
131
|
+
await existing;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const restart = this.daemon.closeServer({ server }).catch(() => {
|
|
135
|
+
});
|
|
136
|
+
this.restartPromises.set(server, restart);
|
|
137
|
+
try {
|
|
138
|
+
await restart;
|
|
139
|
+
} finally {
|
|
140
|
+
this.restartPromises.delete(server);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
var NON_FATAL_CODES = /* @__PURE__ */ new Set([ErrorCode.InvalidRequest, ErrorCode.MethodNotFound, ErrorCode.InvalidParams]);
|
|
145
|
+
function shouldRestartDaemonServer(error) {
|
|
146
|
+
if (!error) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
if (error instanceof McpError) {
|
|
150
|
+
return !NON_FATAL_CODES.has(error.code);
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
function logDaemonRetry(server, operation, error) {
|
|
155
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
156
|
+
console.error(`[mcporter] Restarting '${server}' before retrying ${operation}: ${reason}`);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export {
|
|
160
|
+
createKeepAliveRuntime
|
|
161
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
consumeTimeoutFlag
|
|
4
|
+
} from "./chunk-BNV3TPE4.js";
|
|
5
|
+
import {
|
|
6
|
+
extractEphemeralServerFlags
|
|
7
|
+
} from "./chunk-LQQEYD76.js";
|
|
8
|
+
import {
|
|
9
|
+
consumeOutputFormat
|
|
10
|
+
} from "./chunk-YVZKMV5H.js";
|
|
11
|
+
|
|
12
|
+
// node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/list-flags.js
|
|
13
|
+
function extractListFlags(args) {
|
|
14
|
+
let schema = false;
|
|
15
|
+
let timeoutMs;
|
|
16
|
+
let requiredOnly = true;
|
|
17
|
+
let verbose = false;
|
|
18
|
+
let includeSources = false;
|
|
19
|
+
let brief = false;
|
|
20
|
+
let quiet = false;
|
|
21
|
+
let exitCode = false;
|
|
22
|
+
let statusOnly = false;
|
|
23
|
+
let disableOAuth = false;
|
|
24
|
+
const format = consumeOutputFormat(args, {
|
|
25
|
+
defaultFormat: "text",
|
|
26
|
+
allowed: ["text", "json"],
|
|
27
|
+
enableRawShortcut: false,
|
|
28
|
+
jsonShortcutFlag: "--json"
|
|
29
|
+
});
|
|
30
|
+
const ephemeral = extractEphemeralServerFlags(args);
|
|
31
|
+
let index = 0;
|
|
32
|
+
while (index < args.length) {
|
|
33
|
+
const token = args[index];
|
|
34
|
+
if (token === "--schema") {
|
|
35
|
+
schema = true;
|
|
36
|
+
args.splice(index, 1);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (token === "--yes") {
|
|
40
|
+
args.splice(index, 1);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (token === "--all-parameters") {
|
|
44
|
+
requiredOnly = false;
|
|
45
|
+
args.splice(index, 1);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (token === "--verbose") {
|
|
49
|
+
verbose = true;
|
|
50
|
+
args.splice(index, 1);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (token === "--sources") {
|
|
54
|
+
includeSources = true;
|
|
55
|
+
args.splice(index, 1);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (token === "--brief" || token === "--signatures") {
|
|
59
|
+
brief = true;
|
|
60
|
+
args.splice(index, 1);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (token === "--quiet") {
|
|
64
|
+
quiet = true;
|
|
65
|
+
exitCode = true;
|
|
66
|
+
args.splice(index, 1);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (token === "--exit-code") {
|
|
70
|
+
exitCode = true;
|
|
71
|
+
args.splice(index, 1);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (token === "--status") {
|
|
75
|
+
statusOnly = true;
|
|
76
|
+
args.splice(index, 1);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (token === "--no-oauth") {
|
|
80
|
+
disableOAuth = true;
|
|
81
|
+
args.splice(index, 1);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (token === "--timeout") {
|
|
85
|
+
timeoutMs = consumeTimeoutFlag(args, index, { flagName: "--timeout" });
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
index += 1;
|
|
89
|
+
}
|
|
90
|
+
if (brief) {
|
|
91
|
+
const conflicts = [];
|
|
92
|
+
if (format === "json") {
|
|
93
|
+
conflicts.push("--json");
|
|
94
|
+
}
|
|
95
|
+
if (schema) {
|
|
96
|
+
conflicts.push("--schema");
|
|
97
|
+
}
|
|
98
|
+
if (verbose) {
|
|
99
|
+
conflicts.push("--verbose");
|
|
100
|
+
}
|
|
101
|
+
if (!requiredOnly) {
|
|
102
|
+
conflicts.push("--all-parameters");
|
|
103
|
+
}
|
|
104
|
+
if (conflicts.length > 0) {
|
|
105
|
+
throw new Error(`--brief cannot be used with ${conflicts.join(", ")}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (statusOnly) {
|
|
109
|
+
const conflicts = [];
|
|
110
|
+
if (brief) {
|
|
111
|
+
conflicts.push("--brief");
|
|
112
|
+
}
|
|
113
|
+
if (schema) {
|
|
114
|
+
conflicts.push("--schema");
|
|
115
|
+
}
|
|
116
|
+
if (!requiredOnly) {
|
|
117
|
+
conflicts.push("--all-parameters");
|
|
118
|
+
}
|
|
119
|
+
if (conflicts.length > 0) {
|
|
120
|
+
throw new Error(`--status cannot be used with ${conflicts.join(", ")}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
schema,
|
|
125
|
+
timeoutMs,
|
|
126
|
+
requiredOnly,
|
|
127
|
+
ephemeral,
|
|
128
|
+
format,
|
|
129
|
+
verbose,
|
|
130
|
+
includeSources,
|
|
131
|
+
brief,
|
|
132
|
+
quiet,
|
|
133
|
+
exitCode,
|
|
134
|
+
statusOnly,
|
|
135
|
+
disableOAuth
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export {
|
|
140
|
+
extractListFlags
|
|
141
|
+
};
|
|
@@ -0,0 +1,208 @@
|
|
|
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-metadata.js
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
5
|
+
import fs from "node:fs/promises";
|
|
6
|
+
function metadataPathForArtifact(artifactPath) {
|
|
7
|
+
return `${artifactPath}.metadata.json`;
|
|
8
|
+
}
|
|
9
|
+
async function readCliMetadata(artifactPath) {
|
|
10
|
+
let embeddedError;
|
|
11
|
+
try {
|
|
12
|
+
return await readMetadataFromCli(artifactPath);
|
|
13
|
+
} catch (error) {
|
|
14
|
+
embeddedError = error;
|
|
15
|
+
}
|
|
16
|
+
const legacyPath = metadataPathForArtifact(artifactPath);
|
|
17
|
+
try {
|
|
18
|
+
const buffer = await fs.readFile(legacyPath, "utf8");
|
|
19
|
+
return JSON.parse(buffer);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (isErrno(error, "ENOENT") && embeddedError) {
|
|
22
|
+
throw embeddedError;
|
|
23
|
+
}
|
|
24
|
+
if (!isErrno(error, "ENOENT")) {
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
throw embeddedError;
|
|
29
|
+
}
|
|
30
|
+
async function readMetadataFromCli(artifactPath) {
|
|
31
|
+
return await new Promise((resolve, reject) => {
|
|
32
|
+
const child = spawn(artifactPath, ["__mcporter_inspect"], {
|
|
33
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
34
|
+
});
|
|
35
|
+
let stdout = "";
|
|
36
|
+
let stderr = "";
|
|
37
|
+
child.stdout.setEncoding("utf8");
|
|
38
|
+
child.stdout.on("data", (data) => {
|
|
39
|
+
stdout += String(data);
|
|
40
|
+
});
|
|
41
|
+
child.stderr.setEncoding("utf8");
|
|
42
|
+
child.stderr.on("data", (data) => {
|
|
43
|
+
stderr += String(data);
|
|
44
|
+
});
|
|
45
|
+
child.on("error", (error) => reject(error));
|
|
46
|
+
child.on("close", (code) => {
|
|
47
|
+
if (code !== 0) {
|
|
48
|
+
reject(new Error(`Failed to inspect CLI artifact at ${artifactPath}${stderr ? `: ${stderr.trim()}` : ""} (exit code ${code ?? -1})`));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const parsed = JSON.parse(stdout);
|
|
53
|
+
resolve(parsed);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
reject(new Error(`Unable to parse embedded metadata from ${artifactPath}: ${error instanceof Error ? error.message : String(error)}`));
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function isErrno(error, code) {
|
|
61
|
+
return Boolean(error && typeof error === "object" && error.code === code);
|
|
62
|
+
}
|
|
63
|
+
function serializeDefinition(definition) {
|
|
64
|
+
if (definition.command.kind === "http") {
|
|
65
|
+
return {
|
|
66
|
+
name: definition.name,
|
|
67
|
+
description: definition.description,
|
|
68
|
+
command: {
|
|
69
|
+
kind: "http",
|
|
70
|
+
url: definition.command.url.toString(),
|
|
71
|
+
headers: definition.command.headers
|
|
72
|
+
},
|
|
73
|
+
env: definition.env,
|
|
74
|
+
auth: definition.auth,
|
|
75
|
+
tokenCacheDir: definition.tokenCacheDir,
|
|
76
|
+
clientName: definition.clientName,
|
|
77
|
+
oauthClientId: definition.oauthClientId,
|
|
78
|
+
oauthClientSecretEnv: definition.oauthClientSecretEnv,
|
|
79
|
+
oauthTokenEndpointAuthMethod: definition.oauthTokenEndpointAuthMethod,
|
|
80
|
+
oauthRedirectUrl: definition.oauthRedirectUrl,
|
|
81
|
+
oauthScope: definition.oauthScope,
|
|
82
|
+
refresh: definition.refresh,
|
|
83
|
+
httpFetch: definition.httpFetch,
|
|
84
|
+
allowedTools: definition.allowedTools,
|
|
85
|
+
blockedTools: definition.blockedTools
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
name: definition.name,
|
|
90
|
+
description: definition.description,
|
|
91
|
+
command: {
|
|
92
|
+
kind: "stdio",
|
|
93
|
+
command: definition.command.command,
|
|
94
|
+
args: [...definition.command.args],
|
|
95
|
+
cwd: definition.command.cwd
|
|
96
|
+
},
|
|
97
|
+
env: definition.env,
|
|
98
|
+
auth: definition.auth,
|
|
99
|
+
tokenCacheDir: definition.tokenCacheDir,
|
|
100
|
+
clientName: definition.clientName,
|
|
101
|
+
oauthClientId: definition.oauthClientId,
|
|
102
|
+
oauthClientSecretEnv: definition.oauthClientSecretEnv,
|
|
103
|
+
oauthTokenEndpointAuthMethod: definition.oauthTokenEndpointAuthMethod,
|
|
104
|
+
oauthRedirectUrl: definition.oauthRedirectUrl,
|
|
105
|
+
oauthScope: definition.oauthScope,
|
|
106
|
+
refresh: definition.refresh,
|
|
107
|
+
httpFetch: definition.httpFetch,
|
|
108
|
+
allowedTools: definition.allowedTools,
|
|
109
|
+
blockedTools: definition.blockedTools
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// node_modules/.pnpm/mcporter@0.12.3/node_modules/mcporter/dist/cli/generate/template-data.js
|
|
114
|
+
function buildGenerateCliCommand(invocation, definition, globalFlags = {}) {
|
|
115
|
+
const tokens = ["mcporter"];
|
|
116
|
+
const configPath = invocation.configPath ?? globalFlags["--config"];
|
|
117
|
+
const rootDir = invocation.rootDir ?? globalFlags["--root"];
|
|
118
|
+
if (configPath) {
|
|
119
|
+
tokens.push("--config", configPath);
|
|
120
|
+
}
|
|
121
|
+
if (rootDir) {
|
|
122
|
+
tokens.push("--root", rootDir);
|
|
123
|
+
}
|
|
124
|
+
tokens.push("generate-cli");
|
|
125
|
+
const serverRef = invocation.serverRef ?? definition.name ?? JSON.stringify(definition);
|
|
126
|
+
tokens.push("--server", serverRef);
|
|
127
|
+
if (invocation.outputPath) {
|
|
128
|
+
tokens.push("--output", invocation.outputPath);
|
|
129
|
+
}
|
|
130
|
+
if (invocation.bundler && invocation.bundler !== "rolldown") {
|
|
131
|
+
tokens.push("--bundler", invocation.bundler);
|
|
132
|
+
}
|
|
133
|
+
if (typeof invocation.bundle === "string") {
|
|
134
|
+
tokens.push("--bundle", invocation.bundle);
|
|
135
|
+
} else if (invocation.bundle) {
|
|
136
|
+
tokens.push("--bundle");
|
|
137
|
+
}
|
|
138
|
+
if (typeof invocation.compile === "string") {
|
|
139
|
+
tokens.push("--compile", invocation.compile);
|
|
140
|
+
} else if (invocation.compile) {
|
|
141
|
+
tokens.push("--compile");
|
|
142
|
+
}
|
|
143
|
+
if (invocation.runtime) {
|
|
144
|
+
tokens.push("--runtime", invocation.runtime);
|
|
145
|
+
}
|
|
146
|
+
if (invocation.timeoutMs && invocation.timeoutMs !== 3e4) {
|
|
147
|
+
tokens.push("--timeout", String(invocation.timeoutMs));
|
|
148
|
+
}
|
|
149
|
+
if (invocation.minify) {
|
|
150
|
+
tokens.push("--minify");
|
|
151
|
+
}
|
|
152
|
+
if (invocation.includeTools && invocation.includeTools.length > 0) {
|
|
153
|
+
tokens.push("--include-tools", invocation.includeTools.join(","));
|
|
154
|
+
}
|
|
155
|
+
if (invocation.excludeTools && invocation.excludeTools.length > 0) {
|
|
156
|
+
tokens.push("--exclude-tools", invocation.excludeTools.join(","));
|
|
157
|
+
}
|
|
158
|
+
return tokens.map(shellQuote).join(" ");
|
|
159
|
+
}
|
|
160
|
+
function resolveGenerateRequestFromArtifact(parsed, metadata, globalFlags) {
|
|
161
|
+
if (!parsed.from) {
|
|
162
|
+
throw new Error("Missing --from artifact path.");
|
|
163
|
+
}
|
|
164
|
+
const invocation = { ...metadata.invocation };
|
|
165
|
+
const serverRef = parsed.server ?? invocation.serverRef ?? metadata.server.name ?? JSON.stringify(metadata.server.definition);
|
|
166
|
+
if (!serverRef) {
|
|
167
|
+
throw new Error("Unable to determine server definition from artifact; pass --server with a target name.");
|
|
168
|
+
}
|
|
169
|
+
const includeTools = parsed.includeTools ?? invocation.includeTools;
|
|
170
|
+
const excludeTools = parsed.excludeTools ?? invocation.excludeTools;
|
|
171
|
+
if (includeTools && excludeTools) {
|
|
172
|
+
throw new Error("Cannot combine --include-tools and --exclude-tools.");
|
|
173
|
+
}
|
|
174
|
+
if (includeTools && includeTools.length === 0) {
|
|
175
|
+
throw new Error("--include-tools requires at least one tool name.");
|
|
176
|
+
}
|
|
177
|
+
if (excludeTools && excludeTools.length === 0) {
|
|
178
|
+
throw new Error("--exclude-tools requires at least one tool name.");
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
serverRef,
|
|
182
|
+
configPath: globalFlags["--config"] ?? invocation.configPath,
|
|
183
|
+
rootDir: globalFlags["--root"] ?? invocation.rootDir,
|
|
184
|
+
outputPath: parsed.output ?? invocation.outputPath,
|
|
185
|
+
runtime: parsed.runtime ?? invocation.runtime,
|
|
186
|
+
bundler: parsed.bundler ?? invocation.bundler,
|
|
187
|
+
bundle: parsed.bundle ?? invocation.bundle,
|
|
188
|
+
timeoutMs: parsed.timeout ?? invocation.timeoutMs,
|
|
189
|
+
compile: parsed.compile ?? invocation.compile,
|
|
190
|
+
minify: parsed.minify ?? invocation.minify ?? false,
|
|
191
|
+
includeTools,
|
|
192
|
+
excludeTools
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function shellQuote(value) {
|
|
196
|
+
if (/^[A-Za-z0-9_./@%-]+$/.test(value)) {
|
|
197
|
+
return value;
|
|
198
|
+
}
|
|
199
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export {
|
|
203
|
+
readCliMetadata,
|
|
204
|
+
serializeDefinition,
|
|
205
|
+
buildGenerateCliCommand,
|
|
206
|
+
resolveGenerateRequestFromArtifact,
|
|
207
|
+
shellQuote
|
|
208
|
+
};
|