@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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mouaad Aallam
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # @execbox/core
2
+
3
+ Executor-agnostic core for guest JavaScript that can call host tools directly or wrap MCP servers and clients into callable namespaces.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/%40execbox%2Fcore?style=flat-square)](https://www.npmjs.com/package/@execbox/core)
6
+ [![License](https://img.shields.io/github/license/aallam/execbox?style=flat-square)](https://github.com/aallam/execbox/blob/main/LICENSE)
7
+
8
+ ## What You Get
9
+
10
+ - Resolve host tools into deterministic guest namespaces with name sanitization.
11
+ - Validate tool inputs and outputs with JSON Schema, full Zod schemas, or MCP SDK-style raw Zod shapes.
12
+ - Normalize user code before execution and generate namespace typings from resolved schemas.
13
+ - Wrap MCP servers or clients into execbox providers, or expose code-execution tools from an MCP server.
14
+
15
+ ## Pair It With an Executor
16
+
17
+ `@execbox/core` does not execute code on its own. Pair it with one of the executor packages:
18
+
19
+ | Package | Best for |
20
+ | ---------------------------------------------------------------------------- | -------------------------------------------------------------------- |
21
+ | [`@execbox/quickjs`](https://www.npmjs.com/package/@execbox/quickjs) | Easiest setup, no native addon, good default backend |
22
+ | [`@execbox/remote`](https://www.npmjs.com/package/@execbox/remote) | Same executor API, but with a caller-supplied remote boundary |
23
+ | [`@execbox/process`](https://www.npmjs.com/package/@execbox/process) | QuickJS execution in a child process with a stronger lifecycle split |
24
+ | [`@execbox/worker`](https://www.npmjs.com/package/@execbox/worker) | QuickJS execution on a worker thread with a message boundary |
25
+ | [`@execbox/isolated-vm`](https://www.npmjs.com/package/@execbox/isolated-vm) | Native `isolated-vm` backend when you specifically want that runtime |
26
+
27
+ ## Examples
28
+
29
+ - [Basic provider execution](https://github.com/aallam/execbox/blob/main/examples/execbox-basic.ts)
30
+ - [Process-backed provider execution](https://github.com/aallam/execbox/blob/main/examples/execbox-process.ts)
31
+ - [Remote provider execution](https://github.com/aallam/execbox/blob/main/examples/execbox-remote.ts)
32
+ - [Worker-backed provider execution](https://github.com/aallam/execbox/blob/main/examples/execbox-worker.ts)
33
+ - [Wrap MCP tools into a provider](https://github.com/aallam/execbox/blob/main/examples/execbox-mcp-provider.ts)
34
+ - [Expose MCP code-execution tools from a server](https://github.com/aallam/execbox/blob/main/examples/execbox-mcp-server.ts)
35
+ - [Run the same flow on `isolated-vm`](https://github.com/aallam/execbox/blob/main/examples/execbox-isolated-vm-basic.ts)
36
+ - [Full examples index](https://github.com/aallam/execbox/tree/main/examples)
37
+
38
+ ## Install
39
+
40
+ ```bash
41
+ npm install @execbox/core @execbox/quickjs
42
+ ```
43
+
44
+ Swap in `@execbox/isolated-vm` when you want the native executor instead.
45
+ Swap in `@execbox/process` when you want the QuickJS runtime to live in a fresh child process.
46
+ Swap in `@execbox/remote` when you want the same API but a caller-managed remote transport boundary.
47
+
48
+ ## Security Posture
49
+
50
+ - Execbox gives you fresh execution state, JSON-only tool boundaries, schema validation, timeout handling, memory limits, and bounded logs.
51
+ - Execbox does not give you a hard security boundary for hostile code by itself. The actual boundary depends on which executor you pair it with.
52
+ - Providers are explicit capability grants. Every tool you expose is authority you are handing to guest code.
53
+ - In the default deployment model, provider and MCP tool definitions are controlled by the application, not by the end user.
54
+ - Third-party MCP integrations should be reviewed as dependency-trust decisions, not folded into the primary end-user attacker model.
55
+ - If the code source is hostile, prefer stronger isolation such as `@execbox/process`, `@execbox/remote`, a container, or a VM.
56
+
57
+ ## Architecture Docs
58
+
59
+ - [Execbox architecture overview](https://github.com/aallam/execbox/blob/main/docs/execbox/architecture/README.md)
60
+ - [Execbox core architecture](https://github.com/aallam/execbox/blob/main/docs/execbox/architecture/execbox-core.md)
61
+ - [Execbox executors](https://github.com/aallam/execbox/blob/main/docs/execbox/architecture/execbox-executors.md)
62
+ - [Execbox MCP adapters and protocol](https://github.com/aallam/execbox/blob/main/docs/execbox/architecture/execbox-mcp-and-protocol.md)
63
+
64
+ ## Exports
65
+
66
+ - `@execbox/core`
67
+ - `ExecutionOptions`
68
+ - `resolveProvider`
69
+ - `normalizeCode`
70
+ - `sanitizeToolName`
71
+ - `extractProviderManifests`
72
+ - `createToolCallDispatcher`
73
+ - JSON Schema type generation and executor/result types
74
+ - `@execbox/core/mcp`
75
+ - `createMcpToolProvider`
76
+ - `openMcpToolProvider`
77
+ - `getMcpToolSourceServerInfo`
78
+ - `codeMcpServer`
79
+
80
+ ## Basic Usage
81
+
82
+ ```ts
83
+ import { resolveProvider } from "@execbox/core";
84
+ import { QuickJsExecutor } from "@execbox/quickjs";
85
+ import * as z from "zod";
86
+
87
+ const provider = resolveProvider({
88
+ name: "tools",
89
+ tools: {
90
+ add: {
91
+ inputSchema: z.object({
92
+ x: z.number(),
93
+ y: z.number(),
94
+ }),
95
+ execute: async (input) => {
96
+ const { x, y } = input as { x: number; y: number };
97
+ return { sum: x + y };
98
+ },
99
+ },
100
+ },
101
+ });
102
+
103
+ const executor = new QuickJsExecutor();
104
+ const result = await executor.execute(
105
+ "await tools.add({ x: 2, y: 5 })",
106
+ [provider],
107
+ { timeoutMs: 250 },
108
+ );
109
+ ```
110
+
111
+ ## MCP Adapters
112
+
113
+ Use `@execbox/core/mcp` when you want to wrap an MCP server or client into a tool provider, or expose code-execution tools from an MCP server. Wrapped tools preserve raw MCP `CallToolResult` envelopes so guest code can inspect `structuredContent` first and fall back to `content`.
@@ -0,0 +1,182 @@
1
+ import { ZodRawShape, ZodTypeAny } from "zod";
2
+
3
+ //#region src/types.d.ts
4
+
5
+ /**
6
+ * JSON Schema-like object used by the public tool and type-generation APIs.
7
+ */
8
+ type JsonSchema = Record<string, unknown>;
9
+ /**
10
+ * Supported authoring formats for tool schemas.
11
+ */
12
+ type ToolSchema = JsonSchema | ZodTypeAny | ZodRawShape;
13
+ /**
14
+ * Stable error codes returned by executors and wrapped tool calls.
15
+ */
16
+ type ExecuteErrorCode = "timeout" | "memory_limit" | "validation_error" | "tool_error" | "runtime_error" | "serialization_error" | "internal_error";
17
+ /**
18
+ * Structured execution failure returned in {@link ExecuteResult}.
19
+ */
20
+ interface ExecuteError {
21
+ /** Machine-readable error category. */
22
+ code: ExecuteErrorCode;
23
+ /** Human-readable failure message. */
24
+ message: string;
25
+ }
26
+ /**
27
+ * Structured result returned by every executor invocation.
28
+ */
29
+ type ExecuteResult<T = unknown> = {
30
+ durationMs: number;
31
+ logs: string[];
32
+ ok: true;
33
+ result: T;
34
+ } | {
35
+ durationMs: number;
36
+ error: ExecuteError;
37
+ logs: string[];
38
+ ok: false;
39
+ };
40
+ /**
41
+ * Context passed to every tool execution.
42
+ */
43
+ interface ToolExecutionContext {
44
+ /** Abort signal cancelled when execution times out or tears down. */
45
+ signal: AbortSignal;
46
+ /** Provider namespace visible in guest code. */
47
+ providerName: string;
48
+ /** Sanitized tool identifier exposed inside the sandbox. */
49
+ safeToolName: string;
50
+ /** Original upstream tool name before sanitization. */
51
+ originalToolName: string;
52
+ }
53
+ /**
54
+ * Host-side tool definition before provider resolution.
55
+ */
56
+ interface ToolDescriptor {
57
+ /** Optional human-readable description used in generated types and docs. */
58
+ description?: string;
59
+ /** Optional input schema validated before the tool is invoked. */
60
+ inputSchema?: ToolSchema;
61
+ /** Optional output schema validated after the tool resolves. */
62
+ outputSchema?: ToolSchema;
63
+ /** Tool implementation invoked by the host runtime. */
64
+ execute: (input: unknown, context: ToolExecutionContext) => Promise<unknown> | unknown;
65
+ }
66
+ /**
67
+ * Collection of tools exposed under a single guest namespace.
68
+ */
69
+ interface ToolProvider {
70
+ /** Optional namespace shown in guest code. Defaults to `codemode`. */
71
+ name?: string;
72
+ /** Raw tools keyed by their original names. */
73
+ tools: Record<string, ToolDescriptor>;
74
+ /** Optional hand-authored type declarations overriding generated types. */
75
+ types?: string;
76
+ }
77
+ /**
78
+ * Tool descriptor after validation, sanitization, and execution wrapping.
79
+ */
80
+ interface ResolvedToolDescriptor {
81
+ /** Optional human-readable description used in generated types and docs. */
82
+ description?: string;
83
+ /** Normalized JSON Schema validated before the tool is invoked. */
84
+ inputSchema?: JsonSchema;
85
+ /** Normalized JSON Schema validated after the tool resolves. */
86
+ outputSchema?: JsonSchema;
87
+ /** Original upstream tool name. */
88
+ originalName: string;
89
+ /** Sanitized tool name visible in guest code. */
90
+ safeName: string;
91
+ /** Wrapped tool execution function used by executors. */
92
+ execute: (input: unknown, context: ToolExecutionContext) => Promise<unknown>;
93
+ }
94
+ /**
95
+ * Fully resolved provider consumed by executors and MCP adapters.
96
+ */
97
+ interface ResolvedToolProvider {
98
+ /** Validated namespace visible in guest code. */
99
+ name: string;
100
+ /** Mapping from upstream tool names to sanitized guest names. */
101
+ originalToSafeName: Record<string, string>;
102
+ /** Reverse mapping from sanitized guest names to upstream tool names. */
103
+ safeToOriginalName: Record<string, string>;
104
+ /** Wrapped tools keyed by their sanitized names. */
105
+ tools: Record<string, ResolvedToolDescriptor>;
106
+ /** Generated or user-supplied type declarations for the provider namespace. */
107
+ types: string;
108
+ }
109
+ /**
110
+ * Tool shape consumed by JSON Schema type generation.
111
+ */
112
+ type TypegenToolDescriptor = Pick<ResolvedToolDescriptor, "description" | "inputSchema" | "outputSchema"> & Partial<Pick<ResolvedToolDescriptor, "execute">>;
113
+ //#endregion
114
+ //#region src/runner.d.ts
115
+ /**
116
+ * Transport-safe metadata for one exposed tool.
117
+ */
118
+ interface ProviderToolManifest {
119
+ description?: string;
120
+ originalName: string;
121
+ safeName: string;
122
+ }
123
+ /**
124
+ * Namespace manifest shared with runner implementations.
125
+ */
126
+ interface ProviderManifest {
127
+ name: string;
128
+ tools: Record<string, ProviderToolManifest>;
129
+ types: string;
130
+ }
131
+ /**
132
+ * Execution limits forwarded to runner implementations.
133
+ */
134
+ interface ExecutorRuntimeOptions {
135
+ maxLogChars?: number;
136
+ maxLogLines?: number;
137
+ memoryLimitBytes?: number;
138
+ timeoutMs?: number;
139
+ }
140
+ /**
141
+ * Public execution options accepted by executors per call.
142
+ */
143
+ interface ExecutionOptions extends ExecutorRuntimeOptions {
144
+ signal?: AbortSignal;
145
+ }
146
+ /**
147
+ * Tool invocation request emitted from a runner.
148
+ */
149
+ interface ToolCall {
150
+ input: unknown;
151
+ providerName: string;
152
+ safeToolName: string;
153
+ }
154
+ /**
155
+ * Trusted host response to a tool invocation request.
156
+ */
157
+ type ToolCallResult = {
158
+ ok: true;
159
+ result: unknown;
160
+ } | {
161
+ error: ExecuteError;
162
+ ok: false;
163
+ };
164
+ /**
165
+ * Converts resolved providers into manifest metadata that reveals only namespace details.
166
+ */
167
+ declare function extractProviderManifests(providers: ResolvedToolProvider[]): ProviderManifest[];
168
+ /**
169
+ * Creates a host-side dispatcher for runner-emitted tool calls.
170
+ */
171
+ declare function createToolCallDispatcher(providers: ResolvedToolProvider[], signal: AbortSignal): (call: ToolCall) => Promise<ToolCallResult>;
172
+ //#endregion
173
+ //#region src/executor/executor.d.ts
174
+ /**
175
+ * Executes JavaScript against one or more resolved tool providers.
176
+ */
177
+ interface Executor {
178
+ execute(code: string, providers: ResolvedToolProvider[], options?: ExecutionOptions): Promise<ExecuteResult>;
179
+ }
180
+ //#endregion
181
+ export { ToolExecutionContext as _, ProviderToolManifest as a, TypegenToolDescriptor as b, createToolCallDispatcher as c, ExecuteErrorCode as d, ExecuteResult as f, ToolDescriptor as g, ResolvedToolProvider as h, ProviderManifest as i, extractProviderManifests as l, ResolvedToolDescriptor as m, ExecutionOptions as n, ToolCall as o, JsonSchema as p, ExecutorRuntimeOptions as r, ToolCallResult as s, Executor as t, ExecuteError as u, ToolProvider as v, ToolSchema as y };
182
+ //# sourceMappingURL=executor-C0lf5vWT.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor-C0lf5vWT.d.ts","names":[],"sources":["../src/types.ts","../src/runner.ts","../src/executor/executor.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;AAKY,KALA,UAAA,GAAa,MAKH,CAAA,MAAA,EAAA,OAAA,CAAA;;;;AAAwC,KAAlD,UAAA,GAAa,UAAqC,GAAxB,UAAwB,GAAX,WAAW;AAK9D;AAYA;AAUA;AAiBiB,KAvCL,gBAAA,GAuCyB,SAE3B,GAAA,cAAW,GAAA,kBAAA,GAAA,YAAA,GAAA,eAAA,GAAA,qBAAA,GAAA,gBAAA;AAYrB;;;AAUa,UAnDI,YAAA,CAmDJ;EACN;EAAO,IAAA,EAlDN,gBAkDM;EAMG;EAYA,OAAA,EAAA,MAAA;;;;;AAYoD,KAxEzD,aAwEyD,CAAA,IAAA,OAAA,CAAA,GAAA;EAMpD,UAAA,EAAA,MAAA;EAIK,IAAA,EAAA,MAAA,EAAA;EAEA,EAAA,EAAA,IAAA;EAEE,MAAA,EAjFV,CAiFU;CAAf,GAAA;EAAM,UAAA,EAAA,MAAA;EAQH,KAAA,EArFC,YAqF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,YAAA,EAAA,MAAA;;;;ACxHT;AASiB,KAmCL,cAAA,GAnCqB;EAShB,EAAA,EAAA,IAAA;EAUA,MAAA,EAAA,OAAA;AAOjB,CAAA,GAAiB;EASL,KAAA,EAMC,YANa;EA2BV,EAAA,EAAA,KAAA;AAsBhB,CAAA;;;;AAG+B,iBAzBf,wBAAA,CAyBe,SAAA,EAxBlB,oBAwBkB,EAAA,CAAA,EAvB5B,gBAuB4B,EAAA;;;;iBAHf,wBAAA,YACH,gCACH,qBACA,aAAa,QAAQ;;;;AD1G/B;AAKA;AAAyB,UEJR,QAAA,CFIQ;EAAa,OAAA,CAAA,IAAA,EAAA,MAAA,EAAA,SAAA,EEDvB,oBFCuB,EAAA,EAAA,OAAA,CAAA,EEAxB,gBFAwB,CAAA,EECjC,OFDiC,CECzB,aFDyB,CAAA"}
@@ -0,0 +1,182 @@
1
+ import { ZodRawShape, ZodTypeAny } from "zod";
2
+
3
+ //#region src/types.d.ts
4
+
5
+ /**
6
+ * JSON Schema-like object used by the public tool and type-generation APIs.
7
+ */
8
+ type JsonSchema = Record<string, unknown>;
9
+ /**
10
+ * Supported authoring formats for tool schemas.
11
+ */
12
+ type ToolSchema = JsonSchema | ZodTypeAny | ZodRawShape;
13
+ /**
14
+ * Stable error codes returned by executors and wrapped tool calls.
15
+ */
16
+ type ExecuteErrorCode = "timeout" | "memory_limit" | "validation_error" | "tool_error" | "runtime_error" | "serialization_error" | "internal_error";
17
+ /**
18
+ * Structured execution failure returned in {@link ExecuteResult}.
19
+ */
20
+ interface ExecuteError {
21
+ /** Machine-readable error category. */
22
+ code: ExecuteErrorCode;
23
+ /** Human-readable failure message. */
24
+ message: string;
25
+ }
26
+ /**
27
+ * Structured result returned by every executor invocation.
28
+ */
29
+ type ExecuteResult<T = unknown> = {
30
+ durationMs: number;
31
+ logs: string[];
32
+ ok: true;
33
+ result: T;
34
+ } | {
35
+ durationMs: number;
36
+ error: ExecuteError;
37
+ logs: string[];
38
+ ok: false;
39
+ };
40
+ /**
41
+ * Context passed to every tool execution.
42
+ */
43
+ interface ToolExecutionContext {
44
+ /** Abort signal cancelled when execution times out or tears down. */
45
+ signal: AbortSignal;
46
+ /** Provider namespace visible in guest code. */
47
+ providerName: string;
48
+ /** Sanitized tool identifier exposed inside the sandbox. */
49
+ safeToolName: string;
50
+ /** Original upstream tool name before sanitization. */
51
+ originalToolName: string;
52
+ }
53
+ /**
54
+ * Host-side tool definition before provider resolution.
55
+ */
56
+ interface ToolDescriptor {
57
+ /** Optional human-readable description used in generated types and docs. */
58
+ description?: string;
59
+ /** Optional input schema validated before the tool is invoked. */
60
+ inputSchema?: ToolSchema;
61
+ /** Optional output schema validated after the tool resolves. */
62
+ outputSchema?: ToolSchema;
63
+ /** Tool implementation invoked by the host runtime. */
64
+ execute: (input: unknown, context: ToolExecutionContext) => Promise<unknown> | unknown;
65
+ }
66
+ /**
67
+ * Collection of tools exposed under a single guest namespace.
68
+ */
69
+ interface ToolProvider {
70
+ /** Optional namespace shown in guest code. Defaults to `codemode`. */
71
+ name?: string;
72
+ /** Raw tools keyed by their original names. */
73
+ tools: Record<string, ToolDescriptor>;
74
+ /** Optional hand-authored type declarations overriding generated types. */
75
+ types?: string;
76
+ }
77
+ /**
78
+ * Tool descriptor after validation, sanitization, and execution wrapping.
79
+ */
80
+ interface ResolvedToolDescriptor {
81
+ /** Optional human-readable description used in generated types and docs. */
82
+ description?: string;
83
+ /** Normalized JSON Schema validated before the tool is invoked. */
84
+ inputSchema?: JsonSchema;
85
+ /** Normalized JSON Schema validated after the tool resolves. */
86
+ outputSchema?: JsonSchema;
87
+ /** Original upstream tool name. */
88
+ originalName: string;
89
+ /** Sanitized tool name visible in guest code. */
90
+ safeName: string;
91
+ /** Wrapped tool execution function used by executors. */
92
+ execute: (input: unknown, context: ToolExecutionContext) => Promise<unknown>;
93
+ }
94
+ /**
95
+ * Fully resolved provider consumed by executors and MCP adapters.
96
+ */
97
+ interface ResolvedToolProvider {
98
+ /** Validated namespace visible in guest code. */
99
+ name: string;
100
+ /** Mapping from upstream tool names to sanitized guest names. */
101
+ originalToSafeName: Record<string, string>;
102
+ /** Reverse mapping from sanitized guest names to upstream tool names. */
103
+ safeToOriginalName: Record<string, string>;
104
+ /** Wrapped tools keyed by their sanitized names. */
105
+ tools: Record<string, ResolvedToolDescriptor>;
106
+ /** Generated or user-supplied type declarations for the provider namespace. */
107
+ types: string;
108
+ }
109
+ /**
110
+ * Tool shape consumed by JSON Schema type generation.
111
+ */
112
+ type TypegenToolDescriptor = Pick<ResolvedToolDescriptor, "description" | "inputSchema" | "outputSchema"> & Partial<Pick<ResolvedToolDescriptor, "execute">>;
113
+ //#endregion
114
+ //#region src/runner.d.ts
115
+ /**
116
+ * Transport-safe metadata for one exposed tool.
117
+ */
118
+ interface ProviderToolManifest {
119
+ description?: string;
120
+ originalName: string;
121
+ safeName: string;
122
+ }
123
+ /**
124
+ * Namespace manifest shared with runner implementations.
125
+ */
126
+ interface ProviderManifest {
127
+ name: string;
128
+ tools: Record<string, ProviderToolManifest>;
129
+ types: string;
130
+ }
131
+ /**
132
+ * Execution limits forwarded to runner implementations.
133
+ */
134
+ interface ExecutorRuntimeOptions {
135
+ maxLogChars?: number;
136
+ maxLogLines?: number;
137
+ memoryLimitBytes?: number;
138
+ timeoutMs?: number;
139
+ }
140
+ /**
141
+ * Public execution options accepted by executors per call.
142
+ */
143
+ interface ExecutionOptions extends ExecutorRuntimeOptions {
144
+ signal?: AbortSignal;
145
+ }
146
+ /**
147
+ * Tool invocation request emitted from a runner.
148
+ */
149
+ interface ToolCall {
150
+ input: unknown;
151
+ providerName: string;
152
+ safeToolName: string;
153
+ }
154
+ /**
155
+ * Trusted host response to a tool invocation request.
156
+ */
157
+ type ToolCallResult = {
158
+ ok: true;
159
+ result: unknown;
160
+ } | {
161
+ error: ExecuteError;
162
+ ok: false;
163
+ };
164
+ /**
165
+ * Converts resolved providers into manifest metadata that reveals only namespace details.
166
+ */
167
+ declare function extractProviderManifests(providers: ResolvedToolProvider[]): ProviderManifest[];
168
+ /**
169
+ * Creates a host-side dispatcher for runner-emitted tool calls.
170
+ */
171
+ declare function createToolCallDispatcher(providers: ResolvedToolProvider[], signal: AbortSignal): (call: ToolCall) => Promise<ToolCallResult>;
172
+ //#endregion
173
+ //#region src/executor/executor.d.ts
174
+ /**
175
+ * Executes JavaScript against one or more resolved tool providers.
176
+ */
177
+ interface Executor {
178
+ execute(code: string, providers: ResolvedToolProvider[], options?: ExecutionOptions): Promise<ExecuteResult>;
179
+ }
180
+ //#endregion
181
+ export { ToolExecutionContext as _, ProviderToolManifest as a, TypegenToolDescriptor as b, createToolCallDispatcher as c, ExecuteErrorCode as d, ExecuteResult as f, ToolDescriptor as g, ResolvedToolProvider as h, ProviderManifest as i, extractProviderManifests as l, ResolvedToolDescriptor as m, ExecutionOptions as n, ToolCall as o, JsonSchema as p, ExecutorRuntimeOptions as r, ToolCallResult as s, Executor as t, ExecuteError as u, ToolProvider as v, ToolSchema as y };
182
+ //# sourceMappingURL=executor-DcnjQGwA.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor-DcnjQGwA.d.cts","names":[],"sources":["../src/types.ts","../src/runner.ts","../src/executor/executor.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;AAKY,KALA,UAAA,GAAa,MAKH,CAAA,MAAA,EAAA,OAAA,CAAA;;;;AAAwC,KAAlD,UAAA,GAAa,UAAqC,GAAxB,UAAwB,GAAX,WAAW;AAK9D;AAYA;AAUA;AAiBiB,KAvCL,gBAAA,GAuCyB,SAE3B,GAAA,cAAW,GAAA,kBAAA,GAAA,YAAA,GAAA,eAAA,GAAA,qBAAA,GAAA,gBAAA;AAYrB;;;AAUa,UAnDI,YAAA,CAmDJ;EACN;EAAO,IAAA,EAlDN,gBAkDM;EAMG;EAYA,OAAA,EAAA,MAAA;;;;;AAYoD,KAxEzD,aAwEyD,CAAA,IAAA,OAAA,CAAA,GAAA;EAMpD,UAAA,EAAA,MAAA;EAIK,IAAA,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