@execbox/core 0.1.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/LICENSE +21 -0
- package/README.md +113 -0
- package/dist/executor-C0lf5vWT.d.ts +182 -0
- package/dist/executor-C0lf5vWT.d.ts.map +1 -0
- package/dist/executor-DcnjQGwA.d.cts +182 -0
- package/dist/executor-DcnjQGwA.d.cts.map +1 -0
- package/dist/index.cjs +242 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +105 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +221 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/index.cjs +234 -0
- package/dist/mcp/index.cjs.map +1 -0
- package/dist/mcp/index.d.cts +77 -0
- package/dist/mcp/index.d.cts.map +1 -0
- package/dist/mcp/index.d.ts +77 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +230 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/resolveProvider-CUxAvFCK.js +338 -0
- package/dist/resolveProvider-CUxAvFCK.js.map +1 -0
- package/dist/resolveProvider-CixOjPKp.cjs +456 -0
- package/dist/resolveProvider-CixOjPKp.cjs.map +1 -0
- package/package.json +54 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { c as isJsonSerializable, d as isReservedWord, f as isValidIdentifier, l as sanitizeToolName, m as serializePropertyName, n as generateTypesFromJsonSchema, o as ExecuteFailure, p as sanitizeIdentifier, s as isExecuteFailure, t as resolveProvider, u as assertValidIdentifier } from "./resolveProvider-CUxAvFCK.js";
|
|
2
|
+
import { parse } from "acorn";
|
|
3
|
+
|
|
4
|
+
//#region src/executor/shared.ts
|
|
5
|
+
const EXECUTION_TIMEOUT_MESSAGE = "Execution timed out";
|
|
6
|
+
/**
|
|
7
|
+
* Canonical error codes that may safely cross trusted executor boundaries.
|
|
8
|
+
*/
|
|
9
|
+
const KNOWN_EXECUTE_ERROR_CODES = new Set([
|
|
10
|
+
"timeout",
|
|
11
|
+
"memory_limit",
|
|
12
|
+
"validation_error",
|
|
13
|
+
"tool_error",
|
|
14
|
+
"runtime_error",
|
|
15
|
+
"serialization_error",
|
|
16
|
+
"internal_error"
|
|
17
|
+
]);
|
|
18
|
+
/**
|
|
19
|
+
* Returns whether the value is one of execbox's stable execution error codes.
|
|
20
|
+
*/
|
|
21
|
+
function isKnownExecuteErrorCode(value) {
|
|
22
|
+
return KNOWN_EXECUTE_ERROR_CODES.has(value);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns the stable timeout message used across executor implementations.
|
|
26
|
+
*/
|
|
27
|
+
function getExecutionTimeoutMessage() {
|
|
28
|
+
return EXECUTION_TIMEOUT_MESSAGE;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates the canonical timeout failure result used for preflight cancellation.
|
|
32
|
+
*/
|
|
33
|
+
function createTimeoutExecuteResult(durationMs = 0) {
|
|
34
|
+
return {
|
|
35
|
+
durationMs,
|
|
36
|
+
error: {
|
|
37
|
+
code: "timeout",
|
|
38
|
+
message: getExecutionTimeoutMessage()
|
|
39
|
+
},
|
|
40
|
+
logs: [],
|
|
41
|
+
ok: false
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Normalizes an unknown thrown value into a human-readable message.
|
|
46
|
+
*/
|
|
47
|
+
function normalizeThrownMessage(error) {
|
|
48
|
+
if (error instanceof Error) return error.message;
|
|
49
|
+
if (typeof error === "object" && error !== null && "message" in error) {
|
|
50
|
+
const message = error.message;
|
|
51
|
+
if (typeof message === "string") return message;
|
|
52
|
+
}
|
|
53
|
+
return String(error);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns the thrown error name when one is available.
|
|
57
|
+
*/
|
|
58
|
+
function normalizeThrownName(error) {
|
|
59
|
+
if (error instanceof Error) return error.name;
|
|
60
|
+
if (typeof error === "object" && error !== null && "name" in error) {
|
|
61
|
+
const name = error.name;
|
|
62
|
+
if (typeof name === "string") return name;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Builds the standard tool execution context passed to resolved tool wrappers.
|
|
67
|
+
*/
|
|
68
|
+
function createExecutionContext(signal, providerName, safeToolName, originalToolName) {
|
|
69
|
+
return {
|
|
70
|
+
originalToolName,
|
|
71
|
+
providerName,
|
|
72
|
+
safeToolName,
|
|
73
|
+
signal
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Truncates captured logs to the configured line and character limits.
|
|
78
|
+
*/
|
|
79
|
+
function truncateLogs(logs, maxLogLines, maxLogChars) {
|
|
80
|
+
const limitedLines = logs.slice(0, maxLogLines);
|
|
81
|
+
let remainingChars = maxLogChars;
|
|
82
|
+
const truncated = [];
|
|
83
|
+
for (const line of limitedLines) {
|
|
84
|
+
if (remainingChars <= 0) break;
|
|
85
|
+
if (line.length <= remainingChars) {
|
|
86
|
+
truncated.push(line);
|
|
87
|
+
remainingChars -= line.length;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
truncated.push(line.slice(0, remainingChars));
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
return truncated;
|
|
94
|
+
}
|
|
95
|
+
function formatLogValue(value) {
|
|
96
|
+
if (typeof value === "string") return value;
|
|
97
|
+
if (value === void 0) return "undefined";
|
|
98
|
+
try {
|
|
99
|
+
return JSON.stringify(value);
|
|
100
|
+
} catch {
|
|
101
|
+
return String(value);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Formats guest console arguments into a single host-side log line.
|
|
106
|
+
*/
|
|
107
|
+
function formatConsoleLine(values) {
|
|
108
|
+
return values.map((value) => formatLogValue(value)).join(" ");
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/normalize.ts
|
|
113
|
+
function stripCodeFences(source) {
|
|
114
|
+
const match = source.match(/^\s*```[^\n]*\n([\s\S]*?)\n?```\s*$/);
|
|
115
|
+
return match ? match[1] : source;
|
|
116
|
+
}
|
|
117
|
+
function wrapAsync(body) {
|
|
118
|
+
if (body.trim().length === 0) return "async () => {}";
|
|
119
|
+
return `async () => {\n${body}\n}`;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Normalizes model-produced JavaScript into an executable async function body.
|
|
123
|
+
*/
|
|
124
|
+
function normalizeCode(source) {
|
|
125
|
+
const normalizedSource = stripCodeFences(source).trim();
|
|
126
|
+
if (normalizedSource.length === 0) return "async () => {}";
|
|
127
|
+
try {
|
|
128
|
+
const program = parse(normalizedSource, {
|
|
129
|
+
ecmaVersion: "latest",
|
|
130
|
+
sourceType: "module"
|
|
131
|
+
});
|
|
132
|
+
if (program.body?.length === 1) {
|
|
133
|
+
const [statement] = program.body;
|
|
134
|
+
if (statement.type === "FunctionDeclaration" && statement.id?.name) return wrapAsync(`${normalizedSource}\nreturn ${statement.id.name}();`);
|
|
135
|
+
if (statement.type === "ExpressionStatement" && statement.expression) {
|
|
136
|
+
if (statement.expression.type === "ArrowFunctionExpression" && statement.expression.async) return normalizedSource;
|
|
137
|
+
return wrapAsync(`return (${normalizedSource});`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const lastStatement = (program.body ?? []).at(-1);
|
|
141
|
+
if (lastStatement?.type === "ExpressionStatement" && lastStatement.expression) {
|
|
142
|
+
const bodyPrefix = normalizedSource.slice(0, lastStatement.start).trimEnd();
|
|
143
|
+
const expressionSource = normalizedSource.slice(lastStatement.expression.start, lastStatement.expression.end);
|
|
144
|
+
const lines = [];
|
|
145
|
+
if (bodyPrefix.length > 0) lines.push(bodyPrefix);
|
|
146
|
+
lines.push(`return (${expressionSource});`);
|
|
147
|
+
return wrapAsync(lines.join("\n"));
|
|
148
|
+
}
|
|
149
|
+
return wrapAsync(normalizedSource);
|
|
150
|
+
} catch {
|
|
151
|
+
return wrapAsync(normalizedSource);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/runner.ts
|
|
157
|
+
function toTrustedExecuteError(error) {
|
|
158
|
+
if (isExecuteFailure(error)) return {
|
|
159
|
+
code: error.code,
|
|
160
|
+
message: error.message
|
|
161
|
+
};
|
|
162
|
+
return {
|
|
163
|
+
code: "tool_error",
|
|
164
|
+
message: normalizeThrownMessage(error)
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Converts resolved providers into manifest metadata that reveals only namespace details.
|
|
169
|
+
*/
|
|
170
|
+
function extractProviderManifests(providers) {
|
|
171
|
+
return providers.map((provider) => ({
|
|
172
|
+
name: provider.name,
|
|
173
|
+
tools: Object.fromEntries(Object.entries(provider.tools).map(([safeToolName, descriptor]) => [safeToolName, {
|
|
174
|
+
description: descriptor.description,
|
|
175
|
+
originalName: descriptor.originalName,
|
|
176
|
+
safeName: descriptor.safeName
|
|
177
|
+
}])),
|
|
178
|
+
types: provider.types
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Creates a host-side dispatcher for runner-emitted tool calls.
|
|
183
|
+
*/
|
|
184
|
+
function createToolCallDispatcher(providers, signal) {
|
|
185
|
+
const providerMap = new Map(providers.map((provider) => [provider.name, provider]));
|
|
186
|
+
return async (call) => {
|
|
187
|
+
const provider = providerMap.get(call.providerName);
|
|
188
|
+
const descriptor = provider?.tools[call.safeToolName];
|
|
189
|
+
if (!provider || !descriptor) return {
|
|
190
|
+
error: {
|
|
191
|
+
code: "internal_error",
|
|
192
|
+
message: `Unknown tool ${call.providerName}.${call.safeToolName}`
|
|
193
|
+
},
|
|
194
|
+
ok: false
|
|
195
|
+
};
|
|
196
|
+
try {
|
|
197
|
+
if (signal.aborted) return {
|
|
198
|
+
error: {
|
|
199
|
+
code: "timeout",
|
|
200
|
+
message: getExecutionTimeoutMessage()
|
|
201
|
+
},
|
|
202
|
+
ok: false
|
|
203
|
+
};
|
|
204
|
+
const result = await descriptor.execute(call.input, createExecutionContext(signal, provider.name, descriptor.safeName, descriptor.originalName));
|
|
205
|
+
if (result !== void 0 && !isJsonSerializable(result)) throw new ExecuteFailure("serialization_error", "Host value is not JSON-serializable");
|
|
206
|
+
return {
|
|
207
|
+
ok: true,
|
|
208
|
+
result
|
|
209
|
+
};
|
|
210
|
+
} catch (error) {
|
|
211
|
+
return {
|
|
212
|
+
error: toTrustedExecuteError(error),
|
|
213
|
+
ok: false
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
//#endregion
|
|
220
|
+
export { ExecuteFailure, assertValidIdentifier, createExecutionContext, createTimeoutExecuteResult, createToolCallDispatcher, extractProviderManifests, formatConsoleLine, generateTypesFromJsonSchema, getExecutionTimeoutMessage, isExecuteFailure, isJsonSerializable, isKnownExecuteErrorCode, isReservedWord, isValidIdentifier, normalizeCode, normalizeThrownMessage, normalizeThrownName, resolveProvider, sanitizeIdentifier, sanitizeToolName, serializePropertyName, truncateLogs };
|
|
221
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["truncated: string[]"],"sources":["../src/executor/shared.ts","../src/normalize.ts","../src/runner.ts"],"sourcesContent":["import type {\n ExecuteError,\n ExecuteErrorCode,\n ExecuteResult,\n ToolExecutionContext,\n} from \"../types\";\n\nconst EXECUTION_TIMEOUT_MESSAGE = \"Execution timed out\";\n\n/**\n * Canonical error codes that may safely cross trusted executor boundaries.\n */\nconst KNOWN_EXECUTE_ERROR_CODES = new Set<ExecuteErrorCode>([\n \"timeout\",\n \"memory_limit\",\n \"validation_error\",\n \"tool_error\",\n \"runtime_error\",\n \"serialization_error\",\n \"internal_error\",\n]);\n\n/**\n * Returns whether the value is one of execbox's stable execution error codes.\n */\nexport function isKnownExecuteErrorCode(\n value: unknown,\n): value is ExecuteErrorCode {\n return KNOWN_EXECUTE_ERROR_CODES.has(value as ExecuteErrorCode);\n}\n\n/**\n * Returns the stable timeout message used across executor implementations.\n */\nexport function getExecutionTimeoutMessage(): string {\n return EXECUTION_TIMEOUT_MESSAGE;\n}\n\n/**\n * Creates the canonical timeout failure result used for preflight cancellation.\n */\nexport function createTimeoutExecuteResult(durationMs = 0): ExecuteResult {\n return {\n durationMs,\n error: {\n code: \"timeout\",\n message: getExecutionTimeoutMessage(),\n } satisfies ExecuteError,\n logs: [],\n ok: false,\n };\n}\n\n/**\n * Normalizes an unknown thrown value into a human-readable message.\n */\nexport function normalizeThrownMessage(error: unknown): string {\n if (error instanceof Error) {\n return error.message;\n }\n\n if (typeof error === \"object\" && error !== null && \"message\" in error) {\n const message = (error as { message?: unknown }).message;\n if (typeof message === \"string\") {\n return message;\n }\n }\n\n return String(error);\n}\n\n/**\n * Returns the thrown error name when one is available.\n */\nexport function normalizeThrownName(error: unknown): string | undefined {\n if (error instanceof Error) {\n return error.name;\n }\n\n if (typeof error === \"object\" && error !== null && \"name\" in error) {\n const name = (error as { name?: unknown }).name;\n if (typeof name === \"string\") {\n return name;\n }\n }\n\n return undefined;\n}\n\n/**\n * Builds the standard tool execution context passed to resolved tool wrappers.\n */\nexport function createExecutionContext(\n signal: AbortSignal,\n providerName: string,\n safeToolName: string,\n originalToolName: string,\n): ToolExecutionContext {\n return {\n originalToolName,\n providerName,\n safeToolName,\n signal,\n };\n}\n\n/**\n * Truncates captured logs to the configured line and character limits.\n */\nexport function truncateLogs(\n logs: string[],\n maxLogLines: number,\n maxLogChars: number,\n): string[] {\n const limitedLines = logs.slice(0, maxLogLines);\n let remainingChars = maxLogChars;\n const truncated: string[] = [];\n\n for (const line of limitedLines) {\n if (remainingChars <= 0) {\n break;\n }\n\n if (line.length <= remainingChars) {\n truncated.push(line);\n remainingChars -= line.length;\n continue;\n }\n\n truncated.push(line.slice(0, remainingChars));\n break;\n }\n\n return truncated;\n}\n\nfunction formatLogValue(value: unknown): string {\n if (typeof value === \"string\") {\n return value;\n }\n\n if (value === undefined) {\n return \"undefined\";\n }\n\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\n/**\n * Formats guest console arguments into a single host-side log line.\n */\nexport function formatConsoleLine(values: unknown[]): string {\n return values.map((value) => formatLogValue(value)).join(\" \");\n}\n","import { parse } from \"acorn\";\nimport type { Node } from \"acorn\";\n\ntype PositionedNode = Node & {\n end: number;\n start: number;\n body?: PositionedNode[];\n expression?: PositionedNode;\n async?: boolean;\n id?: {\n name: string;\n };\n};\n\nfunction stripCodeFences(source: string): string {\n const match = source.match(/^\\s*```[^\\n]*\\n([\\s\\S]*?)\\n?```\\s*$/);\n return match ? match[1] : source;\n}\n\nfunction wrapAsync(body: string): string {\n if (body.trim().length === 0) {\n return \"async () => {}\";\n }\n\n return `async () => {\\n${body}\\n}`;\n}\n\n/**\n * Normalizes model-produced JavaScript into an executable async function body.\n */\nexport function normalizeCode(source: string): string {\n const normalizedSource = stripCodeFences(source).trim();\n\n if (normalizedSource.length === 0) {\n return \"async () => {}\";\n }\n\n try {\n const program = parse(normalizedSource, {\n ecmaVersion: \"latest\",\n sourceType: \"module\",\n }) as PositionedNode;\n\n if (program.body?.length === 1) {\n const [statement] = program.body;\n\n if (statement.type === \"FunctionDeclaration\" && statement.id?.name) {\n return wrapAsync(`${normalizedSource}\\nreturn ${statement.id.name}();`);\n }\n\n if (statement.type === \"ExpressionStatement\" && statement.expression) {\n if (\n statement.expression.type === \"ArrowFunctionExpression\" &&\n statement.expression.async\n ) {\n return normalizedSource;\n }\n\n return wrapAsync(`return (${normalizedSource});`);\n }\n }\n\n const body = program.body ?? [];\n const lastStatement = body.at(-1);\n\n if (\n lastStatement?.type === \"ExpressionStatement\" &&\n lastStatement.expression\n ) {\n const bodyPrefix = normalizedSource\n .slice(0, lastStatement.start)\n .trimEnd();\n const expressionSource = normalizedSource.slice(\n lastStatement.expression.start,\n lastStatement.expression.end,\n );\n\n const lines = [];\n\n if (bodyPrefix.length > 0) {\n lines.push(bodyPrefix);\n }\n\n lines.push(`return (${expressionSource});`);\n\n return wrapAsync(lines.join(\"\\n\"));\n }\n\n return wrapAsync(normalizedSource);\n } catch {\n return wrapAsync(normalizedSource);\n }\n}\n","import {\n createExecutionContext,\n getExecutionTimeoutMessage,\n normalizeThrownMessage,\n} from \"./executor/shared.ts\";\nimport {\n ExecuteFailure,\n isExecuteFailure,\n isJsonSerializable,\n} from \"./errors.ts\";\nimport type { ExecuteError, ResolvedToolProvider } from \"./types.ts\";\n\n/**\n * Transport-safe metadata for one exposed tool.\n */\nexport interface ProviderToolManifest {\n description?: string;\n originalName: string;\n safeName: string;\n}\n\n/**\n * Namespace manifest shared with runner implementations.\n */\nexport interface ProviderManifest {\n name: string;\n tools: Record<string, ProviderToolManifest>;\n types: string;\n}\n\n/**\n * Execution limits forwarded to runner implementations.\n */\nexport interface ExecutorRuntimeOptions {\n maxLogChars?: number;\n maxLogLines?: number;\n memoryLimitBytes?: number;\n timeoutMs?: number;\n}\n\n/**\n * Public execution options accepted by executors per call.\n */\nexport interface ExecutionOptions extends ExecutorRuntimeOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Tool invocation request emitted from a runner.\n */\nexport interface ToolCall {\n input: unknown;\n providerName: string;\n safeToolName: string;\n}\n\n/**\n * Trusted host response to a tool invocation request.\n */\nexport type ToolCallResult =\n | {\n ok: true;\n result: unknown;\n }\n | {\n error: ExecuteError;\n ok: false;\n };\n\nfunction toTrustedExecuteError(error: unknown): ExecuteError {\n if (isExecuteFailure(error)) {\n return {\n code: error.code,\n message: error.message,\n };\n }\n\n return {\n code: \"tool_error\",\n message: normalizeThrownMessage(error),\n };\n}\n\n/**\n * Converts resolved providers into manifest metadata that reveals only namespace details.\n */\nexport function extractProviderManifests(\n providers: ResolvedToolProvider[],\n): ProviderManifest[] {\n return providers.map((provider) => ({\n name: provider.name,\n tools: Object.fromEntries(\n Object.entries(provider.tools).map(([safeToolName, descriptor]) => [\n safeToolName,\n {\n description: descriptor.description,\n originalName: descriptor.originalName,\n safeName: descriptor.safeName,\n },\n ]),\n ),\n types: provider.types,\n }));\n}\n\n/**\n * Creates a host-side dispatcher for runner-emitted tool calls.\n */\nexport function createToolCallDispatcher(\n providers: ResolvedToolProvider[],\n signal: AbortSignal,\n): (call: ToolCall) => Promise<ToolCallResult> {\n const providerMap = new Map(\n providers.map((provider) => [provider.name, provider] as const),\n );\n\n return async (call) => {\n const provider = providerMap.get(call.providerName);\n const descriptor = provider?.tools[call.safeToolName];\n\n if (!provider || !descriptor) {\n return {\n error: {\n code: \"internal_error\",\n message: `Unknown tool ${call.providerName}.${call.safeToolName}`,\n },\n ok: false,\n };\n }\n\n try {\n if (signal.aborted) {\n return {\n error: {\n code: \"timeout\",\n message: getExecutionTimeoutMessage(),\n },\n ok: false,\n };\n }\n\n const result = await descriptor.execute(\n call.input,\n createExecutionContext(\n signal,\n provider.name,\n descriptor.safeName,\n descriptor.originalName,\n ),\n );\n\n if (result !== undefined && !isJsonSerializable(result)) {\n throw new ExecuteFailure(\n \"serialization_error\",\n \"Host value is not JSON-serializable\",\n );\n }\n\n return {\n ok: true,\n result,\n };\n } catch (error) {\n return {\n error: toTrustedExecuteError(error),\n ok: false,\n };\n }\n };\n}\n"],"mappings":";;;;AAOA,MAAM,4BAA4B;;;;AAKlC,MAAM,4BAA4B,IAAI,IAAsB;CAC1D;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;;;;AAKF,SAAgB,wBACd,OAC2B;AAC3B,QAAO,0BAA0B,IAAI,MAA0B;;;;;AAMjE,SAAgB,6BAAqC;AACnD,QAAO;;;;;AAMT,SAAgB,2BAA2B,aAAa,GAAkB;AACxE,QAAO;EACL;EACA,OAAO;GACL,MAAM;GACN,SAAS,4BAA4B;GACtC;EACD,MAAM,EAAE;EACR,IAAI;EACL;;;;;AAMH,SAAgB,uBAAuB,OAAwB;AAC7D,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K,cAAc;EAClC,MAAM,SAAS;EACf,OAAO,OAAO,YACZ,OAAO,QAAQ,SAAS,MAAM,CAAC,KAAK,CAAC,cAAc,gBAAgB,CACjE,cACA;GACE,aAAa,WAAW;GACxB,cAAc,WAAW;GACzB,UAAU,WAAW;GACtB,CACF,CAAC,CACH;EACD,OAAO,SAAS;EACjB,EAAE;;;;;AAML,SAAgB,yBACd,WACA,QAC6C;CAC7C,MAAM,cAAc,IAAI,IACtB,UAAU,KAAK,aAAa,CAAC,SAAS,MAAM,SAAS,CAAU,CAChE;AAED,QAAO,OAAO,SAAS;EACrB,MAAM,WAAW,YAAY,IAAI,KAAK,aAAa;EACnD,MAAM,aAAa,UAAU,MAAM,KAAK;AAExC,MAAI,CAAC,YAAY,CAAC,WAChB,QAAO;GACL,OAAO;IACL,MAAM;IACN,SAAS,gBAAgB,KAAK,aAAa,GAAG,KAAK;IACpD;GACD,IAAI;GACL;AAGH,MAAI;AACF,OAAI,OAAO,QACT,QAAO;IACL,OAAO;KACL,MAAM;KACN,SAAS,4BAA4B;KACtC;IACD,IAAI;IACL;GAGH,MAAM,SAAS,MAAM,WAAW,QAC9B,KAAK,OACL,uBACE,QACA,SAAS,MACT,WAAW,UACX,WAAW,aACZ,CACF;AAED,OAAI,WAAW,UAAa,CAAC,mBAAmB,OAAO,CACrD,OAAM,IAAI,eACR,uBACA,sCACD;AAGH,UAAO;IACL,IAAI;IACJ;IACD;WACM,OAAO;AACd,UAAO;IACL,OAAO,sBAAsB,MAAM;IACnC,IAAI;IACL"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
const require_resolveProvider = require('../resolveProvider-CixOjPKp.cjs');
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
zod = require_resolveProvider.__toESM(zod);
|
|
4
|
+
let __modelcontextprotocol_sdk_server_mcp_js = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
5
|
+
let __modelcontextprotocol_sdk_client_index_js = require("@modelcontextprotocol/sdk/client/index.js");
|
|
6
|
+
let __modelcontextprotocol_sdk_inMemory_js = require("@modelcontextprotocol/sdk/inMemory.js");
|
|
7
|
+
|
|
8
|
+
//#region src/mcp/mcpWrappedToolTypes.ts
|
|
9
|
+
const MCP_CALL_TOOL_RESULT_TYPE = [
|
|
10
|
+
"type McpCallToolResult = {",
|
|
11
|
+
" content: Array<{",
|
|
12
|
+
" type: string;",
|
|
13
|
+
" text?: string;",
|
|
14
|
+
" data?: string;",
|
|
15
|
+
" mimeType?: string;",
|
|
16
|
+
" resource?: unknown;",
|
|
17
|
+
" uri?: string;",
|
|
18
|
+
" name?: string;",
|
|
19
|
+
" description?: string;",
|
|
20
|
+
" }>;",
|
|
21
|
+
" structuredContent?: unknown;",
|
|
22
|
+
" isError?: boolean;",
|
|
23
|
+
" _meta?: Record<string, unknown>;",
|
|
24
|
+
"};"
|
|
25
|
+
].join("\n");
|
|
26
|
+
/**
|
|
27
|
+
* Generates the wrapped MCP tool namespace declarations exposed to guest code.
|
|
28
|
+
*/
|
|
29
|
+
function generateMcpWrappedToolTypes(provider) {
|
|
30
|
+
const declarations = [MCP_CALL_TOOL_RESULT_TYPE];
|
|
31
|
+
for (const [safeName, tool] of Object.entries(provider.tools)) {
|
|
32
|
+
const comment = require_resolveProvider.renderDocComment([...tool.description ? [tool.description, ""] : [], "Wrapped MCP tool. Inspect structuredContent first, then fall back to content text items."]);
|
|
33
|
+
declarations.push([comment, `function ${safeName}(input: ${require_resolveProvider.schemaToType(tool.inputSchema)}): Promise<McpCallToolResult>;`].filter(Boolean).join("\n"));
|
|
34
|
+
}
|
|
35
|
+
return require_resolveProvider.renderNamespaceDeclaration(provider.name, declarations);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/mcp/createMcpToolProvider.ts
|
|
40
|
+
const DEFAULT_MCP_TOOL_CLIENT_INFO = {
|
|
41
|
+
name: "mcp-tool-client",
|
|
42
|
+
version: "0.0.0"
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Returns the upstream server identity when the source can provide one.
|
|
46
|
+
*/
|
|
47
|
+
function getMcpToolSourceServerInfo(source) {
|
|
48
|
+
if (source.serverInfo) return source.serverInfo;
|
|
49
|
+
if ("client" in source) return source.client.getServerVersion();
|
|
50
|
+
}
|
|
51
|
+
async function closeAll(closers) {
|
|
52
|
+
const rejected = (await Promise.allSettled(closers.map((close) => close()))).find((result) => result.status === "rejected");
|
|
53
|
+
if (rejected) throw rejected.reason;
|
|
54
|
+
}
|
|
55
|
+
async function openMcpToolClient(source, clientInfo) {
|
|
56
|
+
if ("client" in source) return {
|
|
57
|
+
client: source.client,
|
|
58
|
+
close: async () => {}
|
|
59
|
+
};
|
|
60
|
+
if (source.server.isConnected()) throw new Error("{ server } sources must be unconnected local MCP servers");
|
|
61
|
+
const [clientTransport, serverTransport] = __modelcontextprotocol_sdk_inMemory_js.InMemoryTransport.createLinkedPair();
|
|
62
|
+
const client = new __modelcontextprotocol_sdk_client_index_js.Client(clientInfo);
|
|
63
|
+
let closePromise;
|
|
64
|
+
await Promise.all([source.server.connect(serverTransport), client.connect(clientTransport)]);
|
|
65
|
+
return {
|
|
66
|
+
client,
|
|
67
|
+
close: async () => {
|
|
68
|
+
closePromise ??= closeAll([() => client.close(), () => source.server.close()]);
|
|
69
|
+
return closePromise;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Opens an MCP tool source as a resolved execution provider with explicit cleanup.
|
|
75
|
+
*/
|
|
76
|
+
async function openMcpToolProvider(source, options = {}) {
|
|
77
|
+
const connection = await openMcpToolClient(source, options.clientInfo ?? DEFAULT_MCP_TOOL_CLIENT_INFO);
|
|
78
|
+
try {
|
|
79
|
+
const toolsResponse = await connection.client.listTools();
|
|
80
|
+
const provider = {
|
|
81
|
+
name: options.namespace ?? "mcp",
|
|
82
|
+
tools: {}
|
|
83
|
+
};
|
|
84
|
+
for (const tool of toolsResponse.tools) provider.tools[tool.name] = {
|
|
85
|
+
description: tool.description,
|
|
86
|
+
execute: async (input, context) => {
|
|
87
|
+
const argumentsObject = typeof input === "object" && input !== null ? input : void 0;
|
|
88
|
+
return connection.client.callTool({
|
|
89
|
+
arguments: argumentsObject,
|
|
90
|
+
name: tool.name
|
|
91
|
+
}, void 0, { signal: context.signal });
|
|
92
|
+
},
|
|
93
|
+
inputSchema: tool.inputSchema
|
|
94
|
+
};
|
|
95
|
+
const resolvedProvider = require_resolveProvider.resolveProvider(provider);
|
|
96
|
+
return {
|
|
97
|
+
close: connection.close,
|
|
98
|
+
provider: {
|
|
99
|
+
...resolvedProvider,
|
|
100
|
+
types: generateMcpWrappedToolTypes(resolvedProvider)
|
|
101
|
+
},
|
|
102
|
+
serverInfo: getMcpToolSourceServerInfo(source)
|
|
103
|
+
};
|
|
104
|
+
} catch (error) {
|
|
105
|
+
await connection.close().catch(() => {});
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Wraps MCP tools from a client or server as a resolved execution provider.
|
|
111
|
+
*/
|
|
112
|
+
async function createMcpToolProvider(source, options = {}) {
|
|
113
|
+
return (await openMcpToolProvider(source, options)).provider;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/mcp/codeMcpServer.ts
|
|
118
|
+
const DEFAULT_MAX_TEXT_CHARS = 24e3;
|
|
119
|
+
const DEFAULT_MCP_CODE_WRAPPER_SERVER_INFO = {
|
|
120
|
+
name: "mcp-code-wrapper",
|
|
121
|
+
version: "0.0.0"
|
|
122
|
+
};
|
|
123
|
+
function truncateText(text, maxTextChars) {
|
|
124
|
+
return text.length <= maxTextChars ? text : text.slice(0, maxTextChars);
|
|
125
|
+
}
|
|
126
|
+
function renderText(value, maxTextChars) {
|
|
127
|
+
return truncateText(JSON.stringify(value, null, 2), maxTextChars);
|
|
128
|
+
}
|
|
129
|
+
function searchTools(provider, query, limit) {
|
|
130
|
+
const normalizedQuery = query?.toLowerCase().trim();
|
|
131
|
+
const matches = Object.entries(provider.tools).map(([safeName, descriptor]) => ({
|
|
132
|
+
description: descriptor.description,
|
|
133
|
+
inputSchema: descriptor.inputSchema,
|
|
134
|
+
originalName: descriptor.originalName,
|
|
135
|
+
outputSchema: descriptor.outputSchema,
|
|
136
|
+
safeName
|
|
137
|
+
})).filter((tool) => {
|
|
138
|
+
if (!normalizedQuery) return true;
|
|
139
|
+
return [
|
|
140
|
+
tool.originalName,
|
|
141
|
+
tool.safeName,
|
|
142
|
+
tool.description ?? ""
|
|
143
|
+
].some((field) => field.toLowerCase().includes(normalizedQuery));
|
|
144
|
+
}).slice(0, limit);
|
|
145
|
+
return {
|
|
146
|
+
namespace: provider.name,
|
|
147
|
+
originalToSafeName: provider.originalToSafeName,
|
|
148
|
+
safeToOriginalName: provider.safeToOriginalName,
|
|
149
|
+
tools: matches,
|
|
150
|
+
types: provider.types
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function registerExecuteTool(server, name, provider, executor, maxTextChars, description) {
|
|
154
|
+
server.registerTool.bind(server)(name, {
|
|
155
|
+
description,
|
|
156
|
+
inputSchema: { code: zod.string() }
|
|
157
|
+
}, async (args) => {
|
|
158
|
+
const execution = await executor.execute(args.code, [provider]);
|
|
159
|
+
return {
|
|
160
|
+
content: [{
|
|
161
|
+
text: renderText(execution, maxTextChars),
|
|
162
|
+
type: "text"
|
|
163
|
+
}],
|
|
164
|
+
isError: !execution.ok,
|
|
165
|
+
structuredContent: execution
|
|
166
|
+
};
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
function registerSearchTool(server, name, provider, maxTextChars) {
|
|
170
|
+
server.registerTool.bind(server)(name, {
|
|
171
|
+
description: `Search wrapped MCP tools exposed under the ${provider.name} namespace.`,
|
|
172
|
+
inputSchema: {
|
|
173
|
+
limit: zod.number().int().optional(),
|
|
174
|
+
query: zod.string().optional()
|
|
175
|
+
}
|
|
176
|
+
}, async (args) => {
|
|
177
|
+
const structuredContent = searchTools(provider, args.query, args.limit ?? 20);
|
|
178
|
+
return {
|
|
179
|
+
content: [{
|
|
180
|
+
text: renderText(structuredContent, maxTextChars),
|
|
181
|
+
type: "text"
|
|
182
|
+
}],
|
|
183
|
+
structuredContent
|
|
184
|
+
};
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
function attachOwnedClose(server, closeOwnedResources) {
|
|
188
|
+
const originalClose = server.close.bind(server);
|
|
189
|
+
let closePromise;
|
|
190
|
+
server.close = async () => {
|
|
191
|
+
closePromise ??= (async () => {
|
|
192
|
+
const rejected = (await Promise.allSettled([originalClose(), closeOwnedResources()])).find((result) => result.status === "rejected");
|
|
193
|
+
if (rejected) throw rejected.reason;
|
|
194
|
+
})();
|
|
195
|
+
return closePromise;
|
|
196
|
+
};
|
|
197
|
+
return server;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Creates an MCP server that exposes code-execution tools for a wrapped MCP source.
|
|
201
|
+
*/
|
|
202
|
+
async function codeMcpServer(source, options) {
|
|
203
|
+
const maxTextChars = options.maxTextChars ?? DEFAULT_MAX_TEXT_CHARS;
|
|
204
|
+
const mode = options.mode ?? "both";
|
|
205
|
+
const names = {
|
|
206
|
+
execute: options.names?.execute ?? "mcp_execute_code",
|
|
207
|
+
search: options.names?.search ?? "mcp_search_tools",
|
|
208
|
+
single: options.names?.single ?? "mcp_code"
|
|
209
|
+
};
|
|
210
|
+
const handle = await openMcpToolProvider(source, {
|
|
211
|
+
clientInfo: options.clientInfo,
|
|
212
|
+
namespace: options.namespace ?? "mcp"
|
|
213
|
+
});
|
|
214
|
+
const provider = handle.provider;
|
|
215
|
+
const server = new __modelcontextprotocol_sdk_server_mcp_js.McpServer(options.serverInfo ?? handle.serverInfo ?? DEFAULT_MCP_CODE_WRAPPER_SERVER_INFO);
|
|
216
|
+
try {
|
|
217
|
+
if (mode === "both" || mode === "split") {
|
|
218
|
+
registerSearchTool(server, names.search, provider, maxTextChars);
|
|
219
|
+
registerExecuteTool(server, names.execute, provider, options.executor, maxTextChars, `Execute JavaScript against the wrapped ${provider.name} MCP tool namespace.`);
|
|
220
|
+
}
|
|
221
|
+
if (mode === "both" || mode === "single") registerExecuteTool(server, names.single, provider, options.executor, maxTextChars, `Execute JavaScript against the wrapped ${provider.name} MCP tool namespace.\n\n${provider.types}`);
|
|
222
|
+
return attachOwnedClose(server, handle.close);
|
|
223
|
+
} catch (error) {
|
|
224
|
+
await handle.close().catch(() => {});
|
|
225
|
+
throw error;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
//#endregion
|
|
230
|
+
exports.codeMcpServer = codeMcpServer;
|
|
231
|
+
exports.createMcpToolProvider = createMcpToolProvider;
|
|
232
|
+
exports.getMcpToolSourceServerInfo = getMcpToolSourceServerInfo;
|
|
233
|
+
exports.openMcpToolProvider = openMcpToolProvider;
|
|
234
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["renderDocComment","schemaToType","renderNamespaceDeclaration","InMemoryTransport","Client","closePromise: Promise<void> | undefined","provider: ToolProvider","resolveProvider","z","closePromise: Promise<void> | undefined","McpServer"],"sources":["../../src/mcp/mcpWrappedToolTypes.ts","../../src/mcp/createMcpToolProvider.ts","../../src/mcp/codeMcpServer.ts"],"sourcesContent":["import type { ResolvedToolProvider } from \"../types\";\nimport { schemaToType } from \"../typegen/jsonSchema\";\nimport {\n renderDocComment,\n renderNamespaceDeclaration,\n} from \"../typegen/render\";\n\nconst MCP_CALL_TOOL_RESULT_TYPE = [\n \"type McpCallToolResult = {\",\n \" content: Array<{\",\n \" type: string;\",\n \" text?: string;\",\n \" data?: string;\",\n \" mimeType?: string;\",\n \" resource?: unknown;\",\n \" uri?: string;\",\n \" name?: string;\",\n \" description?: string;\",\n \" }>;\",\n \" structuredContent?: unknown;\",\n \" isError?: boolean;\",\n \" _meta?: Record<string, unknown>;\",\n \"};\",\n].join(\"\\n\");\n\n/**\n * Generates the wrapped MCP tool namespace declarations exposed to guest code.\n */\nexport function generateMcpWrappedToolTypes(\n provider: ResolvedToolProvider,\n): string {\n const declarations = [MCP_CALL_TOOL_RESULT_TYPE];\n\n for (const [safeName, tool] of Object.entries(provider.tools)) {\n const comment = renderDocComment([\n ...(tool.description ? [tool.description, \"\"] : []),\n \"Wrapped MCP tool. Inspect structuredContent first, then fall back to content text items.\",\n ]);\n\n declarations.push(\n [\n comment,\n `function ${safeName}(input: ${schemaToType(tool.inputSchema)}): Promise<McpCallToolResult>;`,\n ]\n .filter(Boolean)\n .join(\"\\n\"),\n );\n }\n\n return renderNamespaceDeclaration(provider.name, declarations);\n}\n","import { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport { InMemoryTransport } from \"@modelcontextprotocol/sdk/inMemory.js\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { Implementation } from \"@modelcontextprotocol/sdk/types.js\";\n\nimport { resolveProvider } from \"../provider/resolveProvider\";\nimport type { ResolvedToolProvider, ToolProvider } from \"../types\";\nimport { generateMcpWrappedToolTypes } from \"./mcpWrappedToolTypes\";\n\n/**\n * Source used to discover MCP tools for wrapping.\n */\nexport type McpToolSource =\n | { client: Client; serverInfo?: Implementation }\n | { server: McpServer; serverInfo?: Implementation };\n\nconst DEFAULT_MCP_TOOL_CLIENT_INFO = {\n name: \"mcp-tool-client\",\n version: \"0.0.0\",\n} satisfies Implementation;\n\n/**\n * Returns the upstream server identity when the source can provide one.\n */\nexport function getMcpToolSourceServerInfo(\n source: McpToolSource,\n): Implementation | undefined {\n if (source.serverInfo) {\n return source.serverInfo;\n }\n\n if (\"client\" in source) {\n return source.client.getServerVersion();\n }\n\n return undefined;\n}\n\n/**\n * Options for wrapping MCP tools into a code-execution provider.\n */\nexport interface CreateMcpToolProviderOptions {\n /** Namespace exposed to guest code for the wrapped tools. */\n namespace?: string;\n /** Implementation metadata exposed to local `{ server }` sources as the client identity. */\n clientInfo?: Implementation;\n}\n\n/**\n * Explicit handle for a wrapped MCP provider and any owned source connections.\n */\nexport interface McpToolProviderHandle {\n /** Resolved provider exposed to the executor or wrapper server. */\n provider: ResolvedToolProvider;\n /** Best-effort upstream server identity when available. */\n serverInfo?: Implementation;\n /** Releases any internal MCP client/server connection opened for the provider. */\n close: () => Promise<void>;\n}\n\ninterface OpenMcpToolClientResult {\n client: Client;\n close: () => Promise<void>;\n}\n\nasync function closeAll(closers: Array<() => Promise<void>>): Promise<void> {\n const results = await Promise.allSettled(closers.map((close) => close()));\n const rejected = results.find(\n (result): result is PromiseRejectedResult => result.status === \"rejected\",\n );\n\n if (rejected) {\n throw rejected.reason;\n }\n}\n\nasync function openMcpToolClient(\n source: McpToolSource,\n clientInfo: Implementation,\n): Promise<OpenMcpToolClientResult> {\n if (\"client\" in source) {\n return {\n client: source.client,\n close: async () => {},\n };\n }\n\n if (source.server.isConnected()) {\n throw new Error(\"{ server } sources must be unconnected local MCP servers\");\n }\n\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n const client = new Client(clientInfo);\n let closePromise: Promise<void> | undefined;\n\n await Promise.all([\n source.server.connect(serverTransport),\n client.connect(clientTransport),\n ]);\n\n return {\n client,\n close: async () => {\n closePromise ??= closeAll([\n () => client.close(),\n () => source.server.close(),\n ]);\n return closePromise;\n },\n };\n}\n\n/**\n * Opens an MCP tool source as a resolved execution provider with explicit cleanup.\n */\nexport async function openMcpToolProvider(\n source: McpToolSource,\n options: CreateMcpToolProviderOptions = {},\n): Promise<McpToolProviderHandle> {\n const connection = await openMcpToolClient(\n source,\n options.clientInfo ?? DEFAULT_MCP_TOOL_CLIENT_INFO,\n );\n\n try {\n const toolsResponse = await connection.client.listTools();\n const provider: ToolProvider = {\n name: options.namespace ?? \"mcp\",\n tools: {},\n };\n\n for (const tool of toolsResponse.tools) {\n provider.tools[tool.name] = {\n description: tool.description,\n execute: async (input, context) => {\n const argumentsObject =\n typeof input === \"object\" && input !== null\n ? (input as Record<string, unknown>)\n : undefined;\n\n return connection.client.callTool(\n {\n arguments: argumentsObject,\n name: tool.name,\n },\n undefined,\n { signal: context.signal },\n );\n },\n inputSchema: tool.inputSchema,\n };\n }\n\n const resolvedProvider = resolveProvider(provider);\n\n return {\n close: connection.close,\n provider: {\n ...resolvedProvider,\n types: generateMcpWrappedToolTypes(resolvedProvider),\n },\n serverInfo: getMcpToolSourceServerInfo(source),\n };\n } catch (error) {\n await connection.close().catch(() => {});\n throw error;\n }\n}\n\n/**\n * Wraps MCP tools from a client or server as a resolved execution provider.\n */\nexport async function createMcpToolProvider(\n source: McpToolSource,\n options: CreateMcpToolProviderOptions = {},\n): Promise<ResolvedToolProvider> {\n const handle = await openMcpToolProvider(source, options);\n return handle.provider;\n}\n","import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { Implementation } from \"@modelcontextprotocol/sdk/types.js\";\nimport * as z from \"zod\";\n\nimport type { Executor } from \"../executor/executor\";\nimport type { ResolvedToolProvider } from \"../types\";\nimport {\n openMcpToolProvider,\n type CreateMcpToolProviderOptions,\n type McpToolSource,\n} from \"./createMcpToolProvider\";\n\n/**\n * Options for exposing wrapped MCP tool execution through an MCP server.\n */\nexport interface CodeMcpServerOptions extends CreateMcpToolProviderOptions {\n /** Executor used to run guest JavaScript against the wrapped provider. */\n executor: Executor;\n /** Implementation metadata exposed to downstream clients as the wrapper server identity. */\n serverInfo?: Implementation;\n /** Maximum number of text characters returned in text content blocks. */\n maxTextChars?: number;\n /** Wrapper tool layout to expose on the returned server. */\n mode?: \"both\" | \"single\" | \"split\";\n /** Optional custom names for the wrapper tools. */\n names?: {\n execute?: string;\n search?: string;\n single?: string;\n };\n}\n\nconst DEFAULT_MAX_TEXT_CHARS = 24_000;\nconst DEFAULT_MCP_CODE_WRAPPER_SERVER_INFO = {\n name: \"mcp-code-wrapper\",\n version: \"0.0.0\",\n} satisfies Implementation;\n\nfunction truncateText(text: string, maxTextChars: number): string {\n return text.length <= maxTextChars ? text : text.slice(0, maxTextChars);\n}\n\nfunction renderText(value: unknown, maxTextChars: number): string {\n return truncateText(JSON.stringify(value, null, 2), maxTextChars);\n}\n\nfunction searchTools(\n provider: ResolvedToolProvider,\n query: string | undefined,\n limit: number,\n): Record<string, unknown> {\n const normalizedQuery = query?.toLowerCase().trim();\n const matches = Object.entries(provider.tools)\n .map(([safeName, descriptor]) => ({\n description: descriptor.description,\n inputSchema: descriptor.inputSchema,\n originalName: descriptor.originalName,\n outputSchema: descriptor.outputSchema,\n safeName,\n }))\n .filter((tool) => {\n if (!normalizedQuery) {\n return true;\n }\n\n return [tool.originalName, tool.safeName, tool.description ?? \"\"].some(\n (field) => field.toLowerCase().includes(normalizedQuery),\n );\n })\n .slice(0, limit);\n\n return {\n namespace: provider.name,\n originalToSafeName: provider.originalToSafeName,\n safeToOriginalName: provider.safeToOriginalName,\n tools: matches,\n types: provider.types,\n };\n}\n\nfunction registerExecuteTool(\n server: McpServer,\n name: string,\n provider: ResolvedToolProvider,\n executor: Executor,\n maxTextChars: number,\n description: string,\n): void {\n const registerTool = server.registerTool.bind(server) as (\n toolName: string,\n config: {\n description: string;\n inputSchema: Record<string, z.ZodTypeAny>;\n },\n handler: (args: { code: string }) => Promise<{\n content: Array<{ text: string; type: \"text\" }>;\n isError: boolean;\n structuredContent: Record<string, unknown>;\n }>,\n ) => void;\n\n registerTool(\n name,\n {\n description,\n inputSchema: {\n code: z.string(),\n },\n },\n async (args: { code: string }) => {\n const execution = await executor.execute(args.code, [provider]);\n\n return {\n content: [{ text: renderText(execution, maxTextChars), type: \"text\" }],\n isError: !execution.ok,\n structuredContent: execution as Record<string, unknown>,\n };\n },\n );\n}\n\nfunction registerSearchTool(\n server: McpServer,\n name: string,\n provider: ResolvedToolProvider,\n maxTextChars: number,\n): void {\n const registerTool = server.registerTool.bind(server) as (\n toolName: string,\n config: {\n description: string;\n inputSchema: Record<string, z.ZodTypeAny>;\n },\n handler: (args: { limit?: number; query?: string }) => Promise<{\n content: Array<{ text: string; type: \"text\" }>;\n structuredContent: Record<string, unknown>;\n }>,\n ) => void;\n\n registerTool(\n name,\n {\n description: `Search wrapped MCP tools exposed under the ${provider.name} namespace.`,\n inputSchema: {\n limit: z.number().int().optional(),\n query: z.string().optional(),\n },\n },\n async (args: { limit?: number; query?: string }) => {\n const structuredContent = searchTools(\n provider,\n args.query,\n args.limit ?? 20,\n );\n return {\n content: [\n { text: renderText(structuredContent, maxTextChars), type: \"text\" },\n ],\n structuredContent,\n };\n },\n );\n}\n\nfunction attachOwnedClose(\n server: McpServer,\n closeOwnedResources: () => Promise<void>,\n): McpServer {\n const originalClose = server.close.bind(server);\n let closePromise: Promise<void> | undefined;\n\n server.close = async () => {\n closePromise ??= (async () => {\n const results = await Promise.allSettled([\n originalClose(),\n closeOwnedResources(),\n ]);\n const rejected = results.find(\n (result): result is PromiseRejectedResult =>\n result.status === \"rejected\",\n );\n\n if (rejected) {\n throw rejected.reason;\n }\n })();\n\n return closePromise;\n };\n\n return server;\n}\n\n/**\n * Creates an MCP server that exposes code-execution tools for a wrapped MCP source.\n */\nexport async function codeMcpServer(\n source: McpToolSource,\n options: CodeMcpServerOptions,\n): Promise<McpServer> {\n const maxTextChars = options.maxTextChars ?? DEFAULT_MAX_TEXT_CHARS;\n const mode = options.mode ?? \"both\";\n const names = {\n execute: options.names?.execute ?? \"mcp_execute_code\",\n search: options.names?.search ?? \"mcp_search_tools\",\n single: options.names?.single ?? \"mcp_code\",\n };\n const handle = await openMcpToolProvider(source, {\n clientInfo: options.clientInfo,\n namespace: options.namespace ?? \"mcp\",\n });\n const provider = handle.provider;\n const server = new McpServer(\n options.serverInfo ??\n handle.serverInfo ??\n DEFAULT_MCP_CODE_WRAPPER_SERVER_INFO,\n );\n\n try {\n if (mode === \"both\" || mode === \"split\") {\n registerSearchTool(server, names.search, provider, maxTextChars);\n registerExecuteTool(\n server,\n names.execute,\n provider,\n options.executor,\n maxTextChars,\n `Execute JavaScript against the wrapped ${provider.name} MCP tool namespace.`,\n );\n }\n\n if (mode === \"both\" || mode === \"single\") {\n registerExecuteTool(\n server,\n names.single,\n provider,\n options.executor,\n maxTextChars,\n `Execute JavaScript against the wrapped ${provider.name} MCP tool namespace.\\n\\n${provider.types}`,\n );\n }\n\n return attachOwnedClose(server, handle.close);\n } catch (error) {\n await handle.close().catch(() => {});\n throw error;\n }\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,4BAA4B;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC,KAAK,KAAK;;;;AAKZ,SAAgB,4BACd,UACQ;CACR,MAAM,eAAe,CAAC,0BAA0B;AAEhD,MAAK,MAAM,CAAC,UAAU,SAAS,OAAO,QAAQ,SAAS,MAAM,EAAE;EAC7D,MAAM,UAAUA,yCAAiB,CAC/B,GAAI,KAAK,cAAc,CAAC,KAAK,aAAa,GAAG,GAAG,EAAE,EAClD,2FACD,CAAC;AAEF,eAAa,KACX,CACE,SACA,YAAY,SAAS,UAAUC,qCAAa,KAAK,YAAY,CAAC,gCAC/D,CACE,OAAO,QAAQ,CACf,KAAK,KAAK,CACd;;AAGH,QAAOC,mDAA2B,SAAS,MAAM,aAAa;;;;;ACjChE,MAAM,+BAA+B;CACnC,MAAM;CACN,SAAS;CACV;;;;AAKD,SAAgB,2BACd,QAC4B;AAC5B,KAAI,OAAO,WACT,QAAO,OAAO;AAGhB,KAAI,YAAY,OACd,QAAO,OAAO,OAAO,kBAAkB;;AAiC3C,eAAe,SAAS,SAAoD;CAE1E,MAAM,YADU,MAAM,QAAQ,WAAW,QAAQ,KAAK,UAAU,OAAO,CAAC,CAAC,EAChD,MACtB,WAA4C,OAAO,WAAW,WAChE;AAED,KAAI,SACF,OAAM,SAAS;;AAInB,eAAe,kBACb,QACA,YACkC;AAClC,KAAI,YAAY,OACd,QAAO;EACL,QAAQ,OAAO;EACf,OAAO,YAAY;EACpB;AAGH,KAAI,OA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AGH,MAAI,SAAS,UAAU,SAAS,SAC9B,qBACE,QACA,MAAM,QACN,UACA,QAAQ,UACR,cACA,0CAA0C,SAAS,KAAK,0BAA0B,SAAS,QAC5F;AAGH,SAAO,iBAAiB,QAAQ,OAAO,MAAM;UACtC,OAAO;AACd,QAAM,OAAO,OAAO,CAAC,YAAY,GAAG;AACpC,QAAM"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { h as ResolvedToolProvider, t as Executor } from "../executor-DcnjQGwA.cjs";
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { Implementation } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
5
|
+
|
|
6
|
+
//#region src/mcp/createMcpToolProvider.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Source used to discover MCP tools for wrapping.
|
|
10
|
+
*/
|
|
11
|
+
type McpToolSource = {
|
|
12
|
+
client: Client;
|
|
13
|
+
serverInfo?: Implementation;
|
|
14
|
+
} | {
|
|
15
|
+
server: McpServer;
|
|
16
|
+
serverInfo?: Implementation;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Returns the upstream server identity when the source can provide one.
|
|
20
|
+
*/
|
|
21
|
+
declare function getMcpToolSourceServerInfo(source: McpToolSource): Implementation | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Options for wrapping MCP tools into a code-execution provider.
|
|
24
|
+
*/
|
|
25
|
+
interface CreateMcpToolProviderOptions {
|
|
26
|
+
/** Namespace exposed to guest code for the wrapped tools. */
|
|
27
|
+
namespace?: string;
|
|
28
|
+
/** Implementation metadata exposed to local `{ server }` sources as the client identity. */
|
|
29
|
+
clientInfo?: Implementation;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Explicit handle for a wrapped MCP provider and any owned source connections.
|
|
33
|
+
*/
|
|
34
|
+
interface McpToolProviderHandle {
|
|
35
|
+
/** Resolved provider exposed to the executor or wrapper server. */
|
|
36
|
+
provider: ResolvedToolProvider;
|
|
37
|
+
/** Best-effort upstream server identity when available. */
|
|
38
|
+
serverInfo?: Implementation;
|
|
39
|
+
/** Releases any internal MCP client/server connection opened for the provider. */
|
|
40
|
+
close: () => Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Opens an MCP tool source as a resolved execution provider with explicit cleanup.
|
|
44
|
+
*/
|
|
45
|
+
declare function openMcpToolProvider(source: McpToolSource, options?: CreateMcpToolProviderOptions): Promise<McpToolProviderHandle>;
|
|
46
|
+
/**
|
|
47
|
+
* Wraps MCP tools from a client or server as a resolved execution provider.
|
|
48
|
+
*/
|
|
49
|
+
declare function createMcpToolProvider(source: McpToolSource, options?: CreateMcpToolProviderOptions): Promise<ResolvedToolProvider>;
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/mcp/codeMcpServer.d.ts
|
|
52
|
+
/**
|
|
53
|
+
* Options for exposing wrapped MCP tool execution through an MCP server.
|
|
54
|
+
*/
|
|
55
|
+
interface CodeMcpServerOptions extends CreateMcpToolProviderOptions {
|
|
56
|
+
/** Executor used to run guest JavaScript against the wrapped provider. */
|
|
57
|
+
executor: Executor;
|
|
58
|
+
/** Implementation metadata exposed to downstream clients as the wrapper server identity. */
|
|
59
|
+
serverInfo?: Implementation;
|
|
60
|
+
/** Maximum number of text characters returned in text content blocks. */
|
|
61
|
+
maxTextChars?: number;
|
|
62
|
+
/** Wrapper tool layout to expose on the returned server. */
|
|
63
|
+
mode?: "both" | "single" | "split";
|
|
64
|
+
/** Optional custom names for the wrapper tools. */
|
|
65
|
+
names?: {
|
|
66
|
+
execute?: string;
|
|
67
|
+
search?: string;
|
|
68
|
+
single?: string;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Creates an MCP server that exposes code-execution tools for a wrapped MCP source.
|
|
73
|
+
*/
|
|
74
|
+
declare function codeMcpServer(source: McpToolSource, options: CodeMcpServerOptions): Promise<McpServer>;
|
|
75
|
+
//#endregion
|
|
76
|
+
export { type CodeMcpServerOptions, type CreateMcpToolProviderOptions, type McpToolProviderHandle, type McpToolSource, codeMcpServer, createMcpToolProvider, getMcpToolSourceServerInfo, openMcpToolProvider };
|
|
77
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/mcp/createMcpToolProvider.ts","../../src/mcp/codeMcpServer.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAYA;AACc,KADF,aAAA,GACE;EAAqB,MAAA,EAArB,MAAqB;EACrB,UAAA,CAAA,EADqB,cACrB;CAAwB,GAAA;EAAc,MAAA,EAAtC,SAAsC;EAUpC,UAAA,CAAA,EAVsB,cAUtB;AAiBhB,CAAA;AAUA;;;AAMe,iBAjCC,0BAAA,CAiCD,MAAA,EAhCL,aAgCK,CAAA,EA/BZ,cA+BY,GAAA,SAAA;;AA2Df;;AAEW,UA7EM,4BAAA,CA6EN;EACA;EAAR,SAAA,CAAA,EAAA,MAAA;EAAO;EAsDY,UAAA,CAAA,EAhIP,cAgI4B;;;;;AAGjC,UA7HO,qBAAA,CA6HP;;YA3HE;;ECtCK,UAAA,CAAA,EDwCF,cCxCuB;EAE1B;EAEG,KAAA,EAAA,GAAA,GDsCA,OCtCA,CAAA,IAAA,CAAA;;;AAiLf;;AAEW,iBDlFW,mBAAA,CCkFX,MAAA,EDjFD,aCiFC,EAAA,OAAA,CAAA,EDhFA,4BCgFA,CAAA,ED/ER,OC+EQ,CD/EA,qBC+EA,CAAA;;;;iBDzBW,qBAAA,SACZ,yBACC,+BACR,QAAQ;;;;;AApKX;AACc,UCEG,oBAAA,SAA6B,4BDFhC,CAAA;EAAqB;EACrB,QAAA,ECGF,QDHE;EAAwB;EAAc,UAAA,CAAA,ECKrC,cDLqC;EAUpC;EAiBC,YAAA,CAAA,EAAA,MAAA;EAUA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