@execbox/core 0.3.1 → 0.4.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 +52 -85
- package/dist/_internal/index.cjs +45 -0
- package/dist/_internal/index.cjs.map +1 -0
- package/dist/_internal/index.d.cts +21 -0
- package/dist/_internal/index.d.cts.map +1 -0
- package/dist/_internal/index.d.ts +22 -0
- package/dist/_internal/index.d.ts.map +1 -0
- package/dist/_internal/index.js +30 -0
- package/dist/_internal/index.js.map +1 -0
- package/dist/errors-B3IY3ID-.d.cts +69 -0
- package/dist/errors-B3IY3ID-.d.cts.map +1 -0
- package/dist/errors-BGSgVV40.cjs +79 -0
- package/dist/errors-BGSgVV40.cjs.map +1 -0
- package/dist/errors-BXpyBhCI.js +61 -0
- package/dist/errors-BXpyBhCI.js.map +1 -0
- package/dist/errors-BbUru7ko.d.ts +69 -0
- package/dist/errors-BbUru7ko.d.ts.map +1 -0
- package/dist/executor-CEXp0gYP.d.cts +29 -0
- package/dist/executor-CEXp0gYP.d.cts.map +1 -0
- package/dist/executor-_CO7E1U7.d.ts +29 -0
- package/dist/executor-_CO7E1U7.d.ts.map +1 -0
- package/dist/index.cjs +18 -233
- package/dist/index.d.cts +3 -62
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +3 -62
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -220
- package/dist/mcp/index.cjs +2 -1
- package/dist/mcp/index.cjs.map +1 -1
- package/dist/mcp/index.d.cts +2 -2
- package/dist/mcp/index.d.cts.map +1 -1
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +2 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/normalize-B80ZCnxe.cjs +54 -0
- package/dist/normalize-B80ZCnxe.cjs.map +1 -0
- package/dist/normalize-dfQC7HWx.js +48 -0
- package/dist/normalize-dfQC7HWx.js.map +1 -0
- package/dist/protocol/index.cjs +345 -0
- package/dist/protocol/index.cjs.map +1 -0
- package/dist/protocol/index.d.cts +169 -0
- package/dist/protocol/index.d.cts.map +1 -0
- package/dist/protocol/index.d.ts +169 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +341 -0
- package/dist/protocol/index.js.map +1 -0
- package/dist/{resolveProvider-Cqe2G7Dc.js → resolveProvider-BHuwOGBm.js} +3 -61
- package/dist/resolveProvider-BHuwOGBm.js.map +1 -0
- package/dist/{resolveProvider-Dt30Su4V.cjs → resolveProvider-DfcSnwnp.cjs} +7 -83
- package/dist/resolveProvider-DfcSnwnp.cjs.map +1 -0
- package/dist/runner-BxbJ5eWb.cjs +235 -0
- package/dist/runner-BxbJ5eWb.cjs.map +1 -0
- package/dist/{executor-DgNzFGsH.d.ts → runner-DSgvu6Ad.d.cts} +2 -22
- package/dist/runner-DSgvu6Ad.d.cts.map +1 -0
- package/dist/{executor-B_GaIEgz.d.cts → runner-FSGSGEpx.d.ts} +2 -22
- package/dist/runner-FSGSGEpx.d.ts.map +1 -0
- package/dist/runner-nUCF59Au.js +176 -0
- package/dist/runner-nUCF59Au.js.map +1 -0
- package/package.json +21 -1
- package/dist/executor-B_GaIEgz.d.cts.map +0 -1
- package/dist/executor-DgNzFGsH.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/resolveProvider-Cqe2G7Dc.js.map +0 -1
- package/dist/resolveProvider-Dt30Su4V.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,121 +1,88 @@
|
|
|
1
1
|
# @execbox/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Core execution contract for execbox. Use it to resolve host tools into callable guest namespaces, validate tool boundaries, and bridge MCP servers or clients into the same execution model.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@execbox/core)
|
|
6
6
|
[](https://github.com/aallam/execbox/blob/main/LICENSE)
|
|
7
|
+
[](https://execbox.aallam.com)
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
## Use `@execbox/core` When
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
- Validate tool inputs and outputs with JSON Schema, full Zod schemas, or MCP SDK-style raw Zod shapes.
|
|
14
|
-
- Normalize user code before execution and generate namespace typings from resolved schemas.
|
|
15
|
-
- Wrap MCP servers or clients into execbox providers, or expose code-execution tools from an MCP server.
|
|
11
|
+
- you want to expose host capabilities to guest code through explicit tool providers
|
|
12
|
+
- you want one execution contract across QuickJS, remote, or `isolated-vm` runtimes
|
|
13
|
+
- you want to wrap MCP servers or clients into callable namespaces instead of exposing raw tool loops
|
|
16
14
|
|
|
17
15
|
## Pair It With an Executor
|
|
18
16
|
|
|
19
|
-
`@execbox/core` does not execute code on its own.
|
|
20
|
-
|
|
21
|
-
| Package | Best for |
|
|
22
|
-
| ---------------------------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
23
|
-
| [`@execbox/quickjs`](https://www.npmjs.com/package/@execbox/quickjs) | Easiest setup, no native addon, good default backend |
|
|
24
|
-
| [`@execbox/remote`](https://www.npmjs.com/package/@execbox/remote) | Same executor API, but with a caller-supplied remote boundary |
|
|
25
|
-
| [`@execbox/process`](https://www.npmjs.com/package/@execbox/process) | QuickJS execution in a child process with a stronger lifecycle split |
|
|
26
|
-
| [`@execbox/worker`](https://www.npmjs.com/package/@execbox/worker) | QuickJS execution on a worker thread with a message boundary |
|
|
27
|
-
| [`@execbox/isolated-vm`](https://www.npmjs.com/package/@execbox/isolated-vm) | Native `isolated-vm` backend when you specifically want that runtime |
|
|
28
|
-
|
|
29
|
-
## Examples
|
|
17
|
+
`@execbox/core` defines the provider and tool boundary, but it does not execute guest code on its own.
|
|
30
18
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
- [Expose MCP code-execution tools from a server](https://github.com/aallam/execbox/blob/main/examples/execbox-mcp-server.ts)
|
|
37
|
-
- [Run the same flow on `isolated-vm`](https://github.com/aallam/execbox/blob/main/examples/execbox-isolated-vm-basic.ts)
|
|
38
|
-
- [Full examples index](https://github.com/aallam/execbox/tree/main/examples)
|
|
19
|
+
| Package | Start here when |
|
|
20
|
+
| ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
|
|
21
|
+
| [`@execbox/quickjs`](https://www.npmjs.com/package/@execbox/quickjs) | You want the default path with inline, worker, or process-hosted QuickJS. |
|
|
22
|
+
| [`@execbox/remote`](https://www.npmjs.com/package/@execbox/remote) | Your runtime already lives behind an application-owned transport boundary. |
|
|
23
|
+
| [`@execbox/isolated-vm`](https://www.npmjs.com/package/@execbox/isolated-vm) | You explicitly want the `isolated-vm` runtime and can support its constraints. |
|
|
39
24
|
|
|
40
25
|
## Install
|
|
41
26
|
|
|
27
|
+
Most users start with QuickJS:
|
|
28
|
+
|
|
42
29
|
```bash
|
|
43
30
|
npm install @execbox/core @execbox/quickjs
|
|
44
31
|
```
|
|
45
32
|
|
|
46
|
-
Swap in `@execbox/isolated-vm` when you
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
## Security Posture
|
|
51
|
-
|
|
52
|
-
- Execbox gives you fresh execution state, JSON-only tool boundaries, schema validation, timeout handling, memory limits, and bounded logs.
|
|
53
|
-
- Hard isolation depends on the executor and deployment boundary you pair with `@execbox/core`.
|
|
54
|
-
- Providers are explicit capability grants. Every tool you expose is authority you are handing to guest code.
|
|
55
|
-
- In the default deployment model, provider and MCP tool definitions are controlled by the application, not by the end user.
|
|
56
|
-
- Third-party MCP integrations should be reviewed as dependency-trust decisions, not folded into the primary end-user attacker model.
|
|
57
|
-
- If the code source is hostile, prefer stronger isolation such as `@execbox/process`, `@execbox/remote`, a container, or a VM.
|
|
58
|
-
|
|
59
|
-
## Architecture Docs
|
|
60
|
-
|
|
61
|
-
- [Execbox architecture overview](https://github.com/aallam/execbox/blob/main/docs/architecture/README.md)
|
|
62
|
-
- [Execbox core architecture](https://github.com/aallam/execbox/blob/main/docs/architecture/execbox-core.md)
|
|
63
|
-
- [Execbox executors](https://github.com/aallam/execbox/blob/main/docs/architecture/execbox-executors.md)
|
|
64
|
-
- [Execbox MCP adapters and protocol](https://github.com/aallam/execbox/blob/main/docs/architecture/execbox-mcp-and-protocol.md)
|
|
65
|
-
|
|
66
|
-
## Exports
|
|
67
|
-
|
|
68
|
-
- `@execbox/core`
|
|
69
|
-
- `ExecutionOptions`
|
|
70
|
-
- `resolveProvider`
|
|
71
|
-
- `normalizeCode`
|
|
72
|
-
- `sanitizeToolName`
|
|
73
|
-
- `extractProviderManifests`
|
|
74
|
-
- `createToolCallDispatcher`
|
|
75
|
-
- JSON Schema type generation and executor/result types
|
|
76
|
-
- `@execbox/core/mcp`
|
|
77
|
-
- `createMcpToolProvider`
|
|
78
|
-
- `openMcpToolProvider`
|
|
79
|
-
- `getMcpToolSourceServerInfo`
|
|
80
|
-
- `McpToolClientSource`
|
|
81
|
-
- `McpToolServerSource`
|
|
82
|
-
- `codeMcpServer`
|
|
83
|
-
|
|
84
|
-
## Basic Usage
|
|
33
|
+
Swap in `@execbox/remote` or `@execbox/isolated-vm` when you need a different runtime boundary.
|
|
34
|
+
|
|
35
|
+
## Smallest Working Usage
|
|
85
36
|
|
|
86
37
|
```ts
|
|
87
38
|
import { resolveProvider } from "@execbox/core";
|
|
88
39
|
import { QuickJsExecutor } from "@execbox/quickjs";
|
|
89
|
-
import * as z from "zod";
|
|
90
40
|
|
|
91
41
|
const provider = resolveProvider({
|
|
92
42
|
name: "tools",
|
|
93
43
|
tools: {
|
|
94
|
-
|
|
95
|
-
inputSchema:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return { sum: x + y };
|
|
44
|
+
greet: {
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: "object",
|
|
47
|
+
required: ["name"],
|
|
48
|
+
properties: {
|
|
49
|
+
name: { type: "string" },
|
|
50
|
+
},
|
|
102
51
|
},
|
|
52
|
+
execute: async (input) => ({
|
|
53
|
+
message: `Hello, ${(input as { name: string }).name}!`,
|
|
54
|
+
}),
|
|
103
55
|
},
|
|
104
56
|
},
|
|
105
57
|
});
|
|
106
58
|
|
|
107
59
|
const executor = new QuickJsExecutor();
|
|
108
|
-
const result = await executor.execute(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
);
|
|
60
|
+
const result = await executor.execute(`await tools.greet({ name: "World" })`, [
|
|
61
|
+
provider,
|
|
62
|
+
]);
|
|
63
|
+
|
|
64
|
+
console.log(result);
|
|
113
65
|
```
|
|
114
66
|
|
|
115
|
-
## MCP
|
|
67
|
+
## MCP Support
|
|
68
|
+
|
|
69
|
+
Use `@execbox/core/mcp` when you want MCP on either side of the boundary:
|
|
70
|
+
|
|
71
|
+
- wrap an upstream MCP server or client into a provider with `createMcpToolProvider()` or `openMcpToolProvider()`
|
|
72
|
+
- expose execbox code execution back out through an MCP server with `codeMcpServer()`
|
|
73
|
+
- preserve raw MCP `CallToolResult` envelopes so guest code can inspect `structuredContent` first and fall back to `content`
|
|
74
|
+
|
|
75
|
+
## Operational Notes
|
|
76
|
+
|
|
77
|
+
- Providers are the capability boundary. If guest code can call a tool, it can exercise that authority.
|
|
78
|
+
- Execbox gives you JSON-only tool/result boundaries, schema validation, bounded logs, and timeout-aware execution controls.
|
|
79
|
+
- Hard isolation depends on the executor and deployment boundary you choose, not on `@execbox/core` by itself.
|
|
116
80
|
|
|
117
|
-
|
|
81
|
+
## Read Next
|
|
118
82
|
|
|
119
|
-
-
|
|
120
|
-
-
|
|
121
|
-
-
|
|
83
|
+
- [Getting Started](https://execbox.aallam.com/getting-started)
|
|
84
|
+
- [Examples](https://execbox.aallam.com/examples)
|
|
85
|
+
- [Security & Boundaries](https://execbox.aallam.com/security)
|
|
86
|
+
- [Architecture Overview](https://execbox.aallam.com/architecture/)
|
|
87
|
+
- [Core Architecture](https://execbox.aallam.com/architecture/execbox-core)
|
|
88
|
+
- [MCP And Protocol](https://execbox.aallam.com/architecture/execbox-mcp-and-protocol)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const require_runner = require('../runner-BxbJ5eWb.cjs');
|
|
2
|
+
const require_normalize = require('../normalize-B80ZCnxe.cjs');
|
|
3
|
+
const require_errors = require('../errors-BGSgVV40.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/runtimeOptions.ts
|
|
6
|
+
/**
|
|
7
|
+
* Default runtime limits shared across the built-in executor implementations.
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_EXECUTOR_RUNTIME_OPTIONS = {
|
|
10
|
+
maxLogChars: 64e3,
|
|
11
|
+
maxLogLines: 100,
|
|
12
|
+
memoryLimitBytes: 64 * 1024 * 1024,
|
|
13
|
+
timeoutMs: 5e3
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Resolves executor runtime limits by applying explicit overrides on top of a
|
|
17
|
+
* base options object and finally the shared defaults.
|
|
18
|
+
*/
|
|
19
|
+
function resolveExecutorRuntimeOptions(options = {}, overrides = {}) {
|
|
20
|
+
return {
|
|
21
|
+
maxLogChars: overrides.maxLogChars ?? options.maxLogChars ?? DEFAULT_EXECUTOR_RUNTIME_OPTIONS.maxLogChars,
|
|
22
|
+
maxLogLines: overrides.maxLogLines ?? options.maxLogLines ?? DEFAULT_EXECUTOR_RUNTIME_OPTIONS.maxLogLines,
|
|
23
|
+
memoryLimitBytes: overrides.memoryLimitBytes ?? options.memoryLimitBytes ?? DEFAULT_EXECUTOR_RUNTIME_OPTIONS.memoryLimitBytes,
|
|
24
|
+
timeoutMs: overrides.timeoutMs ?? options.timeoutMs ?? DEFAULT_EXECUTOR_RUNTIME_OPTIONS.timeoutMs
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
exports.DEFAULT_EXECUTOR_RUNTIME_OPTIONS = DEFAULT_EXECUTOR_RUNTIME_OPTIONS;
|
|
30
|
+
exports.ExecuteFailure = require_errors.ExecuteFailure;
|
|
31
|
+
exports.createExecutionContext = require_runner.createExecutionContext;
|
|
32
|
+
exports.createTimeoutExecuteResult = require_runner.createTimeoutExecuteResult;
|
|
33
|
+
exports.createToolCallDispatcher = require_runner.createToolCallDispatcher;
|
|
34
|
+
exports.extractProviderManifests = require_runner.extractProviderManifests;
|
|
35
|
+
exports.formatConsoleLine = require_runner.formatConsoleLine;
|
|
36
|
+
exports.getExecutionTimeoutMessage = require_runner.getExecutionTimeoutMessage;
|
|
37
|
+
exports.isExecuteFailure = require_errors.isExecuteFailure;
|
|
38
|
+
exports.isJsonSerializable = require_errors.isJsonSerializable;
|
|
39
|
+
exports.isKnownExecuteErrorCode = require_runner.isKnownExecuteErrorCode;
|
|
40
|
+
exports.normalizeCode = require_normalize.normalizeCode;
|
|
41
|
+
exports.normalizeThrownMessage = require_runner.normalizeThrownMessage;
|
|
42
|
+
exports.normalizeThrownName = require_runner.normalizeThrownName;
|
|
43
|
+
exports.resolveExecutorRuntimeOptions = resolveExecutorRuntimeOptions;
|
|
44
|
+
exports.truncateLogs = require_runner.truncateLogs;
|
|
45
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["DEFAULT_EXECUTOR_RUNTIME_OPTIONS: ResolvedExecutorRuntimeOptions"],"sources":["../../src/runtimeOptions.ts"],"sourcesContent":["import type { ExecutorRuntimeOptions } from \"./runner.ts\";\n\ntype ResolvedExecutorRuntimeOptions = Readonly<\n Required<ExecutorRuntimeOptions>\n>;\n\n/**\n * Default runtime limits shared across the built-in executor implementations.\n */\nconst DEFAULT_EXECUTOR_RUNTIME_OPTIONS: ResolvedExecutorRuntimeOptions = {\n maxLogChars: 64_000,\n maxLogLines: 100,\n memoryLimitBytes: 64 * 1024 * 1024,\n timeoutMs: 5000,\n};\n\nexport { DEFAULT_EXECUTOR_RUNTIME_OPTIONS };\n\n/**\n * Resolves executor runtime limits by applying explicit overrides on top of a\n * base options object and finally the shared defaults.\n */\nexport function resolveExecutorRuntimeOptions(\n options: ExecutorRuntimeOptions = {},\n overrides: ExecutorRuntimeOptions = {},\n): Required<ExecutorRuntimeOptions> {\n return {\n maxLogChars:\n overrides.maxLogChars ??\n options.maxLogChars ??\n DEFAULT_EXECUTOR_RUNTIME_OPTIONS.maxLogChars,\n maxLogLines:\n overrides.maxLogLines ??\n options.maxLogLines ??\n DEFAULT_EXECUTOR_RUNTIME_OPTIONS.maxLogLines,\n memoryLimitBytes:\n overrides.memoryLimitBytes ??\n options.memoryLimitBytes ??\n DEFAULT_EXECUTOR_RUNTIME_OPTIONS.memoryLimitBytes,\n timeoutMs:\n overrides.timeoutMs ??\n options.timeoutMs ??\n DEFAULT_EXECUTOR_RUNTIME_OPTIONS.timeoutMs,\n };\n}\n"],"mappings":";;;;;;;;AASA,MAAMA,mCAAmE;CACvE,aAAa;CACb,aAAa;CACb,kBAAkB,KAAK,OAAO;CAC9B,WAAW;CACZ;;;;;AAQD,SAAgB,8BACd,UAAkC,EAAE,EACpC,YAAoC,EAAE,EACJ;AAClC,QAAO;EACL,aACE,UAAU,eACV,QAAQ,eACR,iCAAiC;EACnC,aACE,UAAU,eACV,QAAQ,eACR,iCAAiC;EACnC,kBACE,UAAU,oBACV,QAAQ,oBACR,iCAAiC;EACnC,WACE,UAAU,aACV,QAAQ,aACR,iCAAiC;EACpC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Public TypeScript declarations for this package entrypoint.
|
|
4
|
+
*/
|
|
5
|
+
import { c as extractProviderManifests, n as ExecutorRuntimeOptions, s as createToolCallDispatcher } from "../runner-DSgvu6Ad.cjs";
|
|
6
|
+
import { a as createExecutionContext, c as getExecutionTimeoutMessage, d as normalizeThrownName, f as truncateLogs, i as normalizeCode, l as isKnownExecuteErrorCode, n as isExecuteFailure, o as createTimeoutExecuteResult, r as isJsonSerializable, s as formatConsoleLine, t as ExecuteFailure, u as normalizeThrownMessage } from "../errors-B3IY3ID-.cjs";
|
|
7
|
+
|
|
8
|
+
//#region src/runtimeOptions.d.ts
|
|
9
|
+
type ResolvedExecutorRuntimeOptions = Readonly<Required<ExecutorRuntimeOptions>>;
|
|
10
|
+
/**
|
|
11
|
+
* Default runtime limits shared across the built-in executor implementations.
|
|
12
|
+
*/
|
|
13
|
+
declare const DEFAULT_EXECUTOR_RUNTIME_OPTIONS: ResolvedExecutorRuntimeOptions;
|
|
14
|
+
/**
|
|
15
|
+
* Resolves executor runtime limits by applying explicit overrides on top of a
|
|
16
|
+
* base options object and finally the shared defaults.
|
|
17
|
+
*/
|
|
18
|
+
declare function resolveExecutorRuntimeOptions(options?: ExecutorRuntimeOptions, overrides?: ExecutorRuntimeOptions): Required<ExecutorRuntimeOptions>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { DEFAULT_EXECUTOR_RUNTIME_OPTIONS, ExecuteFailure, createExecutionContext, createTimeoutExecuteResult, createToolCallDispatcher, extractProviderManifests, formatConsoleLine, getExecutionTimeoutMessage, isExecuteFailure, isJsonSerializable, isKnownExecuteErrorCode, normalizeCode, normalizeThrownMessage, normalizeThrownName, resolveExecutorRuntimeOptions, truncateLogs };
|
|
21
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/runtimeOptions.ts"],"sourcesContent":[],"mappings":";;;;;;;;KAEK,8BAAA,CAAA,CAAA,CAAiC,SACpC,SAAS;;;AAH+C,CAAA,CAAA;cASpD,gCANK,CAAA,CAM6B,8BAN7B;;;AADmC,CAAA,CAAA,CAAA,IAAA,CAAA,OAAA,CAAA,MAAA,CAAA,GAAA,CAAA,OAAA,CAAA,GAAA,CAAA,MAAA,CAAA,QAAA;AAoB9C,CAAA,CAAA;AACW,OAAA,CAAA,QAAA,CADK,6BAAA,CACL,OAAA,CAAA,CAAA,CAAA,sBAAA,CAAA,CAAA,SAAA,CAAA,CAAA,CACE,sBADF,CAAA,CAAA,CAER,QAFQ,CAEC,sBAFD,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Public TypeScript declarations for this package entrypoint.
|
|
4
|
+
*/
|
|
5
|
+
import { c as extractProviderManifests, n as ExecutorRuntimeOptions, s as createToolCallDispatcher } from "../runner-FSGSGEpx.js";
|
|
6
|
+
import { a as createExecutionContext, c as getExecutionTimeoutMessage, d as normalizeThrownName, f as truncateLogs, i as normalizeCode, l as isKnownExecuteErrorCode, n as isExecuteFailure, o as createTimeoutExecuteResult, r as isJsonSerializable, s as formatConsoleLine, t as ExecuteFailure, u as normalizeThrownMessage } from "../errors-BbUru7ko.js";
|
|
7
|
+
import "../executor-_CO7E1U7.js";
|
|
8
|
+
|
|
9
|
+
//#region src/runtimeOptions.d.ts
|
|
10
|
+
type ResolvedExecutorRuntimeOptions = Readonly<Required<ExecutorRuntimeOptions>>;
|
|
11
|
+
/**
|
|
12
|
+
* Default runtime limits shared across the built-in executor implementations.
|
|
13
|
+
*/
|
|
14
|
+
declare const DEFAULT_EXECUTOR_RUNTIME_OPTIONS: ResolvedExecutorRuntimeOptions;
|
|
15
|
+
/**
|
|
16
|
+
* Resolves executor runtime limits by applying explicit overrides on top of a
|
|
17
|
+
* base options object and finally the shared defaults.
|
|
18
|
+
*/
|
|
19
|
+
declare function resolveExecutorRuntimeOptions(options?: ExecutorRuntimeOptions, overrides?: ExecutorRuntimeOptions): Required<ExecutorRuntimeOptions>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { DEFAULT_EXECUTOR_RUNTIME_OPTIONS, ExecuteFailure, createExecutionContext, createTimeoutExecuteResult, createToolCallDispatcher, extractProviderManifests, formatConsoleLine, getExecutionTimeoutMessage, isExecuteFailure, isJsonSerializable, isKnownExecuteErrorCode, normalizeCode, normalizeThrownMessage, normalizeThrownName, resolveExecutorRuntimeOptions, truncateLogs };
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/runtimeOptions.ts"],"sourcesContent":[],"mappings":";;;;;;;;;KAEK,8BAAA,CAAA,CAAA,CAAiC,SACpC,SAAS;;;;AAH+C,OAAA,CAAA,KAAA,CASpD,gCAP6B,CAAA,CAOK,8BAPL;;;;AAAW,CAAA,CAAA;AAoB9B,OAAA,CAAA,QAAA,CAAA,6BAAA,CAA6B,OAAA,CAAA,CAAA,CAClC,sBADkC,CAAA,CAAA,SAAA,CAAA,CAAA,CAEhC,sBAFgC,CAAA,CAAA,CAG1C,QAH0C,CAGjC,sBAHiC,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { a as formatConsoleLine, c as normalizeThrownMessage, i as createTimeoutExecuteResult, l as normalizeThrownName, n as extractProviderManifests, o as getExecutionTimeoutMessage, r as createExecutionContext, s as isKnownExecuteErrorCode, t as createToolCallDispatcher, u as truncateLogs } from "../runner-nUCF59Au.js";
|
|
2
|
+
import { t as normalizeCode } from "../normalize-dfQC7HWx.js";
|
|
3
|
+
import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "../errors-BXpyBhCI.js";
|
|
4
|
+
|
|
5
|
+
//#region src/runtimeOptions.ts
|
|
6
|
+
/**
|
|
7
|
+
* Default runtime limits shared across the built-in executor implementations.
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_EXECUTOR_RUNTIME_OPTIONS = {
|
|
10
|
+
maxLogChars: 64e3,
|
|
11
|
+
maxLogLines: 100,
|
|
12
|
+
memoryLimitBytes: 64 * 1024 * 1024,
|
|
13
|
+
timeoutMs: 5e3
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Resolves executor runtime limits by applying explicit overrides on top of a
|
|
17
|
+
* base options object and finally the shared defaults.
|
|
18
|
+
*/
|
|
19
|
+
function resolveExecutorRuntimeOptions(options = {}, overrides = {}) {
|
|
20
|
+
return {
|
|
21
|
+
maxLogChars: overrides.maxLogChars ?? options.maxLogChars ?? DEFAULT_EXECUTOR_RUNTIME_OPTIONS.maxLogChars,
|
|
22
|
+
maxLogLines: overrides.maxLogLines ?? options.maxLogLines ?? DEFAULT_EXECUTOR_RUNTIME_OPTIONS.maxLogLines,
|
|
23
|
+
memoryLimitBytes: overrides.memoryLimitBytes ?? options.memoryLimitBytes ?? DEFAULT_EXECUTOR_RUNTIME_OPTIONS.memoryLimitBytes,
|
|
24
|
+
timeoutMs: overrides.timeoutMs ?? options.timeoutMs ?? DEFAULT_EXECUTOR_RUNTIME_OPTIONS.timeoutMs
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { DEFAULT_EXECUTOR_RUNTIME_OPTIONS, ExecuteFailure, createExecutionContext, createTimeoutExecuteResult, createToolCallDispatcher, extractProviderManifests, formatConsoleLine, getExecutionTimeoutMessage, isExecuteFailure, isJsonSerializable, isKnownExecuteErrorCode, normalizeCode, normalizeThrownMessage, normalizeThrownName, resolveExecutorRuntimeOptions, truncateLogs };
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["DEFAULT_EXECUTOR_RUNTIME_OPTIONS: ResolvedExecutorRuntimeOptions"],"sources":["../../src/runtimeOptions.ts"],"sourcesContent":["import type { ExecutorRuntimeOptions } from \"./runner.ts\";\n\ntype ResolvedExecutorRuntimeOptions = Readonly<\n Required<ExecutorRuntimeOptions>\n>;\n\n/**\n * Default runtime limits shared across the built-in executor implementations.\n */\nconst DEFAULT_EXECUTOR_RUNTIME_OPTIONS: ResolvedExecutorRuntimeOptions = {\n maxLogChars: 64_000,\n maxLogLines: 100,\n memoryLimitBytes: 64 * 1024 * 1024,\n timeoutMs: 5000,\n};\n\nexport { DEFAULT_EXECUTOR_RUNTIME_OPTIONS };\n\n/**\n * Resolves executor runtime limits by applying explicit overrides on top of a\n * base options object and finally the shared defaults.\n */\nexport function resolveExecutorRuntimeOptions(\n options: ExecutorRuntimeOptions = {},\n overrides: ExecutorRuntimeOptions = {},\n): Required<ExecutorRuntimeOptions> {\n return {\n maxLogChars:\n overrides.maxLogChars ??\n options.maxLogChars ??\n DEFAULT_EXECUTOR_RUNTIME_OPTIONS.maxLogChars,\n maxLogLines:\n overrides.maxLogLines ??\n options.maxLogLines ??\n DEFAULT_EXECUTOR_RUNTIME_OPTIONS.maxLogLines,\n memoryLimitBytes:\n overrides.memoryLimitBytes ??\n options.memoryLimitBytes ??\n DEFAULT_EXECUTOR_RUNTIME_OPTIONS.memoryLimitBytes,\n timeoutMs:\n overrides.timeoutMs ??\n options.timeoutMs ??\n DEFAULT_EXECUTOR_RUNTIME_OPTIONS.timeoutMs,\n };\n}\n"],"mappings":";;;;;;;;AASA,MAAMA,mCAAmE;CACvE,aAAa;CACb,aAAa;CACb,kBAAkB,KAAK,OAAO;CAC9B,WAAW;CACZ;;;;;AAQD,SAAgB,8BACd,UAAkC,EAAE,EACpC,YAAoC,EAAE,EACJ;AAClC,QAAO;EACL,aACE,UAAU,eACV,QAAQ,eACR,iCAAiC;EACnC,aACE,UAAU,eACV,QAAQ,eACR,iCAAiC;EACnC,kBACE,UAAU,oBACV,QAAQ,oBACR,iCAAiC;EACnC,WACE,UAAU,aACV,QAAQ,aACR,iCAAiC;EACpC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Public TypeScript declarations for this package entrypoint.
|
|
4
|
+
*/
|
|
5
|
+
import { d as ExecuteResult, g as ToolExecutionContext, u as ExecuteErrorCode } from "./runner-DSgvu6Ad.cjs";
|
|
6
|
+
|
|
7
|
+
//#region src/executor/shared.d.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Returns whether the value is one of execbox's stable execution error codes.
|
|
11
|
+
*/
|
|
12
|
+
declare function isKnownExecuteErrorCode(value: unknown): value is ExecuteErrorCode;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the stable timeout message used across executor implementations.
|
|
15
|
+
*/
|
|
16
|
+
declare function getExecutionTimeoutMessage(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Creates the canonical timeout failure result used for preflight cancellation.
|
|
19
|
+
*/
|
|
20
|
+
declare function createTimeoutExecuteResult(durationMs?: number): ExecuteResult;
|
|
21
|
+
/**
|
|
22
|
+
* Normalizes an unknown thrown value into a human-readable message.
|
|
23
|
+
*/
|
|
24
|
+
declare function normalizeThrownMessage(error: unknown): string;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the thrown error name when one is available.
|
|
27
|
+
*/
|
|
28
|
+
declare function normalizeThrownName(error: unknown): string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Builds the standard tool execution context passed to resolved tool wrappers.
|
|
31
|
+
*/
|
|
32
|
+
declare function createExecutionContext(signal: AbortSignal, providerName: string, safeToolName: string, originalToolName: string): ToolExecutionContext;
|
|
33
|
+
/**
|
|
34
|
+
* Truncates captured logs to the configured line and character limits.
|
|
35
|
+
*/
|
|
36
|
+
declare function truncateLogs(logs: string[], maxLogLines: number, maxLogChars: number): string[];
|
|
37
|
+
/**
|
|
38
|
+
* Formats guest console arguments into a single host-side log line.
|
|
39
|
+
*/
|
|
40
|
+
declare function formatConsoleLine(values: unknown[]): string;
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/normalize.d.ts
|
|
43
|
+
/**
|
|
44
|
+
* Normalizes model-produced JavaScript into an executable async function body.
|
|
45
|
+
*/
|
|
46
|
+
declare function normalizeCode(source: string): string;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/errors.d.ts
|
|
49
|
+
/**
|
|
50
|
+
* Structured failure used internally to propagate executor and tool errors.
|
|
51
|
+
*/
|
|
52
|
+
declare class ExecuteFailure extends Error {
|
|
53
|
+
code: ExecuteErrorCode;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a structured failure with a trusted executor or tool error code.
|
|
56
|
+
*/
|
|
57
|
+
constructor(code: ExecuteErrorCode, message: string);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns whether a thrown value is an {@link ExecuteFailure}.
|
|
61
|
+
*/
|
|
62
|
+
declare function isExecuteFailure(value: unknown): value is ExecuteFailure;
|
|
63
|
+
/**
|
|
64
|
+
* Returns whether a value can be serialized through the JSON-only host/guest boundary.
|
|
65
|
+
*/
|
|
66
|
+
declare function isJsonSerializable(value: unknown, active?: Set<object>, memo?: WeakSet<object>): boolean;
|
|
67
|
+
//#endregion
|
|
68
|
+
export { createExecutionContext as a, getExecutionTimeoutMessage as c, normalizeThrownName as d, truncateLogs as f, normalizeCode as i, isKnownExecuteErrorCode as l, isExecuteFailure as n, createTimeoutExecuteResult as o, isJsonSerializable as r, formatConsoleLine as s, ExecuteFailure as t, normalizeThrownMessage as u };
|
|
69
|
+
//# sourceMappingURL=errors-B3IY3ID-.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-B3IY3ID-.d.cts","names":[],"sources":["../src/executor/shared.ts","../src/normalize.ts","../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAyBA,CAAA,CAAA;AASgB,OAAA,CAAA,QAAA,CATA,uBAAA,CAS0B,KAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,KAAA,CAAA,EAAA,CAP9B,gBAO8B;AAO1C,CAAA,CAAA;AAeA,CAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,MAAA,CAAA,OAAA,CAAA,OAAA,CAAA,IAAA,CAAA,MAAA,CAAA,QAAA,CAAA,eAAA;AAkBA,CAAA,CAAA;AAkBgB,OAAA,CAAA,QAAA,CA1DA,0BAAA,CAAA,CA2DN,CAAA,CAIP,MAAA;AAYH,CAAA,CAAA;AA8CA,CAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,SAAA,CAAA,OAAA,CAAA,OAAA,CAAA,MAAA,CAAA,IAAA,CAAA,GAAA,CAAA,SAAA,CAAA,YAAA;;iBAlHgB,0BAAA,uBAA4C;;ACX5D,CAAA,CAAA,CAAA,UAAA,CAAA,EAAA,CAAA,OAAA,CAAA,MAAA,CAAA,KAAA,CAAA,IAAA,CAAA,CAAA,CAAA,KAAA,CAAA,QAAA,CAAA,OAAA;;iBD0BgB,sBAAA;;AEnDhB,CAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,MAAA,CAAA,KAAA,CAAA,IAAA,CAAA,IAAA,CAAA,GAAA,CAAA,EAAA,CAAA,SAAA;;AAMoB,OAAA,CAAA,QAAA,CF+DJ,mBAAA,CE/DI,KAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,MAAA,CAAA,CAAA,CAAA,SAAA;;;AAUpB,CAAA,CAAA;AAOgB,OAAA,CAAA,QAAA,CFgEA,sBAAA,CE7DV,MAAA,CAAA,CF8DI,WE9DJ,CAAA,CAAA,YAAA,CAAA,CAAA,MAAA,CAAA,CAAA,YAAA,CAAA,CAAA,MAAA,CAAA,CAAA,gBAAA,CAAA,CAAA,MAAA,CAAA,CAAA,CFkEH,oBElEG;;;;iBF8EU,YAAA;;;;iBA8CA,iBAAA;;;;;;AAlIA,OAAA,CAAA,QAAA,CCKA,aAAA,CDLuB,MAE3B,CAAA,CAAA,MAAA,CAAA,CAAA,CAAA,MAAgB;;;;;AAF5B,CAAA,CAAA;AASgB,OAAA,CAAA,KAAA,CE7BH,cAAA,CAAA,OAAA,CAAuB,KAAA,CF6BM;EAO1B,IAAA,CAAA,CEnCR,gBFmCQ;EAeA,CAAA,CAAA;AAkBhB,CAAA,CAAA,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,UAAA,CAAA,OAAA,CAAA,IAAA,CAAA,CAAA,CAAA,OAAA,CAAA,QAAA,CAAA,EAAA,CAAA,IAAA,CAAA,KAAA,CAAA,IAAA;AAkBA,CAAA,CAAA,CAAA,CAAA;EAiBgB,WAAA,CAAA,IAAY,CAAA,CElGR,gBFkGQ,CAAA,CAAA,OAAA,CAAA,CAAA,MAAA,CAAA;AA8C5B;;;;AC7HgB,OAAA,CAAA,QAAA,CCTA,gBAAA,CDSa,KAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,KAAA,CAAA,EAAA,CCT8B,cDS9B;;;;ACzBhB,OAAA,CAAA,QAAA,CAuBG,kBAAA,CAvBY,KAAA,CAAA,CAAA,OAAA,CAAA,CAAA,MAAA,CAAA,CAAA,CAyBpB,GAzBoB,CAAA,MAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CA0BtB,OA1BsB,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA,OAAA"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/errors.ts
|
|
3
|
+
/**
|
|
4
|
+
* Structured failure used internally to propagate executor and tool errors.
|
|
5
|
+
*/
|
|
6
|
+
var ExecuteFailure = class extends Error {
|
|
7
|
+
code;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a structured failure with a trusted executor or tool error code.
|
|
10
|
+
*/
|
|
11
|
+
constructor(code, message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.name = "ExecuteFailure";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Returns whether a thrown value is an {@link ExecuteFailure}.
|
|
19
|
+
*/
|
|
20
|
+
function isExecuteFailure(value) {
|
|
21
|
+
return value instanceof ExecuteFailure;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns whether a value can be serialized through the JSON-only host/guest boundary.
|
|
25
|
+
*/
|
|
26
|
+
function isJsonSerializable(value, active = /* @__PURE__ */ new Set(), memo = /* @__PURE__ */ new WeakSet()) {
|
|
27
|
+
if (value === null) return true;
|
|
28
|
+
switch (typeof value) {
|
|
29
|
+
case "string":
|
|
30
|
+
case "boolean": return true;
|
|
31
|
+
case "number": return Number.isFinite(value);
|
|
32
|
+
case "bigint":
|
|
33
|
+
case "function":
|
|
34
|
+
case "symbol":
|
|
35
|
+
case "undefined": return false;
|
|
36
|
+
case "object": {
|
|
37
|
+
const objectValue = value;
|
|
38
|
+
if (memo.has(objectValue)) return true;
|
|
39
|
+
if (active.has(objectValue)) return false;
|
|
40
|
+
active.add(objectValue);
|
|
41
|
+
let isSerializable = false;
|
|
42
|
+
try {
|
|
43
|
+
if (Array.isArray(value)) {
|
|
44
|
+
isSerializable = value.every((item) => isJsonSerializable(item, active, memo));
|
|
45
|
+
return isSerializable;
|
|
46
|
+
}
|
|
47
|
+
const prototype = Object.getPrototypeOf(value);
|
|
48
|
+
if (prototype !== Object.prototype && prototype !== null) return false;
|
|
49
|
+
isSerializable = Object.values(value).every((item) => isJsonSerializable(item, active, memo));
|
|
50
|
+
return isSerializable;
|
|
51
|
+
} finally {
|
|
52
|
+
active.delete(objectValue);
|
|
53
|
+
if (isSerializable) memo.add(objectValue);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
Object.defineProperty(exports, 'ExecuteFailure', {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function () {
|
|
64
|
+
return ExecuteFailure;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(exports, 'isExecuteFailure', {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function () {
|
|
70
|
+
return isExecuteFailure;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(exports, 'isJsonSerializable', {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function () {
|
|
76
|
+
return isJsonSerializable;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
//# sourceMappingURL=errors-BGSgVV40.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-BGSgVV40.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import type { ExecuteErrorCode } from \"./types\";\n\n/**\n * Structured failure used internally to propagate executor and tool errors.\n */\nexport class ExecuteFailure extends Error {\n code: ExecuteErrorCode;\n\n /**\n * Creates a structured failure with a trusted executor or tool error code.\n */\n constructor(code: ExecuteErrorCode, message: string) {\n super(message);\n this.code = code;\n this.name = \"ExecuteFailure\";\n }\n}\n\n/**\n * Returns whether a thrown value is an {@link ExecuteFailure}.\n */\nexport function isExecuteFailure(value: unknown): value is ExecuteFailure {\n return value instanceof ExecuteFailure;\n}\n\n/**\n * Returns whether a value can be serialized through the JSON-only host/guest boundary.\n */\nexport function isJsonSerializable(\n value: unknown,\n active = new Set<object>(),\n memo = new WeakSet<object>(),\n): boolean {\n if (value === null) {\n return true;\n }\n\n switch (typeof value) {\n case \"string\":\n case \"boolean\":\n return true;\n case \"number\":\n return Number.isFinite(value);\n case \"bigint\":\n case \"function\":\n case \"symbol\":\n case \"undefined\":\n return false;\n case \"object\": {\n const objectValue = value as object;\n\n if (memo.has(objectValue)) {\n return true;\n }\n\n if (active.has(objectValue)) {\n return false;\n }\n\n active.add(objectValue);\n let isSerializable = false;\n\n try {\n if (Array.isArray(value)) {\n isSerializable = value.every((item) =>\n isJsonSerializable(item, active, memo),\n );\n return isSerializable;\n }\n\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n return false;\n }\n\n isSerializable = Object.values(value).every((item) =>\n isJsonSerializable(item, active, memo),\n );\n return isSerializable;\n } finally {\n active.delete(objectValue);\n if (isSerializable) {\n memo.add(objectValue);\n }\n }\n }\n }\n\n return false;\n}\n"],"mappings":";;;;;AAKA,IAAa,iBAAb,cAAoC,MAAM;CACxC;;;;CAKA,YAAY,MAAwB,SAAiB;AACnD,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO;;;;;;AAOhB,SAAgB,iBAAiB,OAAyC;AACxE,QAAO,iBAAiB;;;;;AAM1B,SAAgB,mBACd,OACA,yBAAS,IAAI,KAAa,EAC1B,uBAAO,IAAI,SAAiB,EACnB;AACT,KAAI,UAAU,KACZ,QAAO;AAGT,SAAQ,OAAO,OAAf;EACE,KAAK;EACL,KAAK,UACH,QAAO;EACT,KAAK,SACH,QAAO,OAAO,SAAS,MAAM;EAC/B,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,YACH,QAAO;EACT,KAAK,UAAU;GACb,MAAM,cAAc;AAEpB,OAAI,KAAK,IAAI,YAAY,CACvB,QAAO;AAGT,OAAI,OAAO,IAAI,YAAY,CACzB,QAAO;AAGT,UAAO,IAAI,YAAY;GACvB,IAAI,iBAAiB;AAErB,OAAI;AACF,QAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,sBAAiB,MAAM,OAAO,SAC5B,mBAAmB,MAAM,QAAQ,KAAK,CACvC;AACD,YAAO;;IAGT,MAAM,YAAY,OAAO,eAAe,MAAM;AAC9C,QAAI,cAAc,OAAO,aAAa,cAAc,KAClD,QAAO;AAGT,qBAAiB,OAAO,OAAO,MAAM,CAAC,OAAO,SAC3C,mBAAmB,MAAM,QAAQ,KAAK,CACvC;AACD,WAAO;aACC;AACR,WAAO,OAAO,YAAY;AAC1B,QAAI,eACF,MAAK,IAAI,YAAY;;;;AAM7B,QAAO"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//#region src/errors.ts
|
|
2
|
+
/**
|
|
3
|
+
* Structured failure used internally to propagate executor and tool errors.
|
|
4
|
+
*/
|
|
5
|
+
var ExecuteFailure = class extends Error {
|
|
6
|
+
code;
|
|
7
|
+
/**
|
|
8
|
+
* Creates a structured failure with a trusted executor or tool error code.
|
|
9
|
+
*/
|
|
10
|
+
constructor(code, message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.code = code;
|
|
13
|
+
this.name = "ExecuteFailure";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Returns whether a thrown value is an {@link ExecuteFailure}.
|
|
18
|
+
*/
|
|
19
|
+
function isExecuteFailure(value) {
|
|
20
|
+
return value instanceof ExecuteFailure;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns whether a value can be serialized through the JSON-only host/guest boundary.
|
|
24
|
+
*/
|
|
25
|
+
function isJsonSerializable(value, active = /* @__PURE__ */ new Set(), memo = /* @__PURE__ */ new WeakSet()) {
|
|
26
|
+
if (value === null) return true;
|
|
27
|
+
switch (typeof value) {
|
|
28
|
+
case "string":
|
|
29
|
+
case "boolean": return true;
|
|
30
|
+
case "number": return Number.isFinite(value);
|
|
31
|
+
case "bigint":
|
|
32
|
+
case "function":
|
|
33
|
+
case "symbol":
|
|
34
|
+
case "undefined": return false;
|
|
35
|
+
case "object": {
|
|
36
|
+
const objectValue = value;
|
|
37
|
+
if (memo.has(objectValue)) return true;
|
|
38
|
+
if (active.has(objectValue)) return false;
|
|
39
|
+
active.add(objectValue);
|
|
40
|
+
let isSerializable = false;
|
|
41
|
+
try {
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
isSerializable = value.every((item) => isJsonSerializable(item, active, memo));
|
|
44
|
+
return isSerializable;
|
|
45
|
+
}
|
|
46
|
+
const prototype = Object.getPrototypeOf(value);
|
|
47
|
+
if (prototype !== Object.prototype && prototype !== null) return false;
|
|
48
|
+
isSerializable = Object.values(value).every((item) => isJsonSerializable(item, active, memo));
|
|
49
|
+
return isSerializable;
|
|
50
|
+
} finally {
|
|
51
|
+
active.delete(objectValue);
|
|
52
|
+
if (isSerializable) memo.add(objectValue);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { isExecuteFailure as n, isJsonSerializable as r, ExecuteFailure as t };
|
|
61
|
+
//# sourceMappingURL=errors-BXpyBhCI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-BXpyBhCI.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import type { ExecuteErrorCode } from \"./types\";\n\n/**\n * Structured failure used internally to propagate executor and tool errors.\n */\nexport class ExecuteFailure extends Error {\n code: ExecuteErrorCode;\n\n /**\n * Creates a structured failure with a trusted executor or tool error code.\n */\n constructor(code: ExecuteErrorCode, message: string) {\n super(message);\n this.code = code;\n this.name = \"ExecuteFailure\";\n }\n}\n\n/**\n * Returns whether a thrown value is an {@link ExecuteFailure}.\n */\nexport function isExecuteFailure(value: unknown): value is ExecuteFailure {\n return value instanceof ExecuteFailure;\n}\n\n/**\n * Returns whether a value can be serialized through the JSON-only host/guest boundary.\n */\nexport function isJsonSerializable(\n value: unknown,\n active = new Set<object>(),\n memo = new WeakSet<object>(),\n): boolean {\n if (value === null) {\n return true;\n }\n\n switch (typeof value) {\n case \"string\":\n case \"boolean\":\n return true;\n case \"number\":\n return Number.isFinite(value);\n case \"bigint\":\n case \"function\":\n case \"symbol\":\n case \"undefined\":\n return false;\n case \"object\": {\n const objectValue = value as object;\n\n if (memo.has(objectValue)) {\n return true;\n }\n\n if (active.has(objectValue)) {\n return false;\n }\n\n active.add(objectValue);\n let isSerializable = false;\n\n try {\n if (Array.isArray(value)) {\n isSerializable = value.every((item) =>\n isJsonSerializable(item, active, memo),\n );\n return isSerializable;\n }\n\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n return false;\n }\n\n isSerializable = Object.values(value).every((item) =>\n isJsonSerializable(item, active, memo),\n );\n return isSerializable;\n } finally {\n active.delete(objectValue);\n if (isSerializable) {\n memo.add(objectValue);\n }\n }\n }\n }\n\n return false;\n}\n"],"mappings":";;;;AAKA,IAAa,iBAAb,cAAoC,MAAM;CACxC;;;;CAKA,YAAY,MAAwB,SAAiB;AACnD,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO;;;;;;AAOhB,SAAgB,iBAAiB,OAAyC;AACxE,QAAO,iBAAiB;;;;;AAM1B,SAAgB,mBACd,OACA,yBAAS,IAAI,KAAa,EAC1B,uBAAO,IAAI,SAAiB,EACnB;AACT,KAAI,UAAU,KACZ,QAAO;AAGT,SAAQ,OAAO,OAAf;EACE,KAAK;EACL,KAAK,UACH,QAAO;EACT,KAAK,SACH,QAAO,OAAO,SAAS,MAAM;EAC/B,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,YACH,QAAO;EACT,KAAK,UAAU;GACb,MAAM,cAAc;AAEpB,OAAI,KAAK,IAAI,YAAY,CACvB,QAAO;AAGT,OAAI,OAAO,IAAI,YAAY,CACzB,QAAO;AAGT,UAAO,IAAI,YAAY;GACvB,IAAI,iBAAiB;AAErB,OAAI;AACF,QAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,sBAAiB,MAAM,OAAO,SAC5B,mBAAmB,MAAM,QAAQ,KAAK,CACvC;AACD,YAAO;;IAGT,MAAM,YAAY,OAAO,eAAe,MAAM;AAC9C,QAAI,cAAc,OAAO,aAAa,cAAc,KAClD,QAAO;AAGT,qBAAiB,OAAO,OAAO,MAAM,CAAC,OAAO,SAC3C,mBAAmB,MAAM,QAAQ,KAAK,CACvC;AACD,WAAO;aACC;AACR,WAAO,OAAO,YAAY;AAC1B,QAAI,eACF,MAAK,IAAI,YAAY;;;;AAM7B,QAAO"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Public TypeScript declarations for this package entrypoint.
|
|
4
|
+
*/
|
|
5
|
+
import { d as ExecuteResult, g as ToolExecutionContext, u as ExecuteErrorCode } from "./runner-FSGSGEpx.js";
|
|
6
|
+
|
|
7
|
+
//#region src/executor/shared.d.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Returns whether the value is one of execbox's stable execution error codes.
|
|
11
|
+
*/
|
|
12
|
+
declare function isKnownExecuteErrorCode(value: unknown): value is ExecuteErrorCode;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the stable timeout message used across executor implementations.
|
|
15
|
+
*/
|
|
16
|
+
declare function getExecutionTimeoutMessage(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Creates the canonical timeout failure result used for preflight cancellation.
|
|
19
|
+
*/
|
|
20
|
+
declare function createTimeoutExecuteResult(durationMs?: number): ExecuteResult;
|
|
21
|
+
/**
|
|
22
|
+
* Normalizes an unknown thrown value into a human-readable message.
|
|
23
|
+
*/
|
|
24
|
+
declare function normalizeThrownMessage(error: unknown): string;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the thrown error name when one is available.
|
|
27
|
+
*/
|
|
28
|
+
declare function normalizeThrownName(error: unknown): string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Builds the standard tool execution context passed to resolved tool wrappers.
|
|
31
|
+
*/
|
|
32
|
+
declare function createExecutionContext(signal: AbortSignal, providerName: string, safeToolName: string, originalToolName: string): ToolExecutionContext;
|
|
33
|
+
/**
|
|
34
|
+
* Truncates captured logs to the configured line and character limits.
|
|
35
|
+
*/
|
|
36
|
+
declare function truncateLogs(logs: string[], maxLogLines: number, maxLogChars: number): string[];
|
|
37
|
+
/**
|
|
38
|
+
* Formats guest console arguments into a single host-side log line.
|
|
39
|
+
*/
|
|
40
|
+
declare function formatConsoleLine(values: unknown[]): string;
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/normalize.d.ts
|
|
43
|
+
/**
|
|
44
|
+
* Normalizes model-produced JavaScript into an executable async function body.
|
|
45
|
+
*/
|
|
46
|
+
declare function normalizeCode(source: string): string;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/errors.d.ts
|
|
49
|
+
/**
|
|
50
|
+
* Structured failure used internally to propagate executor and tool errors.
|
|
51
|
+
*/
|
|
52
|
+
declare class ExecuteFailure extends Error {
|
|
53
|
+
code: ExecuteErrorCode;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a structured failure with a trusted executor or tool error code.
|
|
56
|
+
*/
|
|
57
|
+
constructor(code: ExecuteErrorCode, message: string);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns whether a thrown value is an {@link ExecuteFailure}.
|
|
61
|
+
*/
|
|
62
|
+
declare function isExecuteFailure(value: unknown): value is ExecuteFailure;
|
|
63
|
+
/**
|
|
64
|
+
* Returns whether a value can be serialized through the JSON-only host/guest boundary.
|
|
65
|
+
*/
|
|
66
|
+
declare function isJsonSerializable(value: unknown, active?: Set<object>, memo?: WeakSet<object>): boolean;
|
|
67
|
+
//#endregion
|
|
68
|
+
export { createExecutionContext as a, getExecutionTimeoutMessage as c, normalizeThrownName as d, truncateLogs as f, normalizeCode as i, isKnownExecuteErrorCode as l, isExecuteFailure as n, createTimeoutExecuteResult as o, isJsonSerializable as r, formatConsoleLine as s, ExecuteFailure as t, normalizeThrownMessage as u };
|
|
69
|
+
//# sourceMappingURL=errors-BbUru7ko.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-BbUru7ko.d.ts","names":[],"sources":["../src/executor/shared.ts","../src/normalize.ts","../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAyBA,CAAA,CAAA;AASgB,OAAA,CAAA,QAAA,CATA,uBAAA,CAS0B,KAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,KAAA,CAAA,EAAA,CAP9B,gBAO8B;AAO1C,CAAA,CAAA;AAeA,CAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,MAAA,CAAA,OAAA,CAAA,OAAA,CAAA,IAAA,CAAA,MAAA,CAAA,QAAA,CAAA,eAAA;AAkBA,CAAA,CAAA;AAkBgB,OAAA,CAAA,QAAA,CA1DA,0BAAA,CAAA,CA2DN,CAAA,CAIP,MAAA;AAYH,CAAA,CAAA;AA8CA,CAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,SAAA,CAAA,OAAA,CAAA,OAAA,CAAA,MAAA,CAAA,IAAA,CAAA,GAAA,CAAA,SAAA,CAAA,YAAA;;iBAlHgB,0BAAA,uBAA4C;;ACX5D,CAAA,CAAA,CAAA,UAAA,CAAA,EAAA,CAAA,OAAA,CAAA,MAAA,CAAA,KAAA,CAAA,IAAA,CAAA,CAAA,CAAA,KAAA,CAAA,QAAA,CAAA,OAAA;;iBD0BgB,sBAAA;;AEnDhB,CAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,MAAA,CAAA,KAAA,CAAA,IAAA,CAAA,IAAA,CAAA,GAAA,CAAA,EAAA,CAAA,SAAA;;AAMoB,OAAA,CAAA,QAAA,CF+DJ,mBAAA,CE/DI,KAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,MAAA,CAAA,CAAA,CAAA,SAAA;;;AAUpB,CAAA,CAAA;AAOgB,OAAA,CAAA,QAAA,CFgEA,sBAAA,CE7DV,MAAA,CAAA,CF8DI,WE9DJ,CAAA,CAAA,YAAA,CAAA,CAAA,MAAA,CAAA,CAAA,YAAA,CAAA,CAAA,MAAA,CAAA,CAAA,gBAAA,CAAA,CAAA,MAAA,CAAA,CAAA,CFkEH,oBElEG;;;;iBF8EU,YAAA;;;;iBA8CA,iBAAA;;;;;;AAlIA,OAAA,CAAA,QAAA,CCKA,aAAA,CDLuB,MAE3B,CAAA,CAAA,MAAA,CAAA,CAAA,CAAA,MAAgB;;;;;AAF5B,CAAA,CAAA;AASgB,OAAA,CAAA,KAAA,CE7BH,cAAA,CAAA,OAAA,CAAuB,KAAA,CF6BM;EAO1B,IAAA,CAAA,CEnCR,gBFmCQ;EAeA,CAAA,CAAA;AAkBhB,CAAA,CAAA,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,UAAA,CAAA,OAAA,CAAA,IAAA,CAAA,CAAA,CAAA,OAAA,CAAA,QAAA,CAAA,EAAA,CAAA,IAAA,CAAA,KAAA,CAAA,IAAA;AAkBA,CAAA,CAAA,CAAA,CAAA;EAiBgB,WAAA,CAAA,IAAY,CAAA,CElGR,gBFkGQ,CAAA,CAAA,OAAA,CAAA,CAAA,MAAA,CAAA;AA8C5B;;;;AC7HgB,OAAA,CAAA,QAAA,CCTA,gBAAA,CDSa,KAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,KAAA,CAAA,EAAA,CCT8B,cDS9B;;;;ACzBhB,OAAA,CAAA,QAAA,CAuBG,kBAAA,CAvBY,KAAA,CAAA,CAAA,OAAA,CAAA,CAAA,MAAA,CAAA,CAAA,CAyBpB,GAzBoB,CAAA,MAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CA0BtB,OA1BsB,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA,OAAA"}
|