@execbox/core 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -84
- package/dist/errors-B9ADBuDH.d.cts +29 -0
- package/dist/errors-B9ADBuDH.d.cts.map +1 -0
- package/dist/errors-DlbJQYs7.d.ts +29 -0
- package/dist/errors-DlbJQYs7.d.ts.map +1 -0
- package/dist/{errors-CgBwm39w.js → errors-wS8yjQhS.js} +1 -1
- package/dist/{errors-CgBwm39w.js.map → errors-wS8yjQhS.js.map} +1 -1
- package/dist/{errors-CTel18cM.cjs → errors-xD8r6fCf.cjs} +1 -1
- package/dist/{errors-CTel18cM.cjs.map → errors-xD8r6fCf.cjs.map} +1 -1
- package/dist/{executor-B-Qe_q5_.d.ts → executor-B7q7K_27.d.ts} +2 -2
- package/dist/{executor-B-Qe_q5_.d.ts.map → executor-B7q7K_27.d.ts.map} +1 -1
- package/dist/{executor-C7YjuD7r.d.cts → executor-BsE5nF-j.d.cts} +2 -2
- package/dist/{executor-C7YjuD7r.d.cts.map → executor-BsE5nF-j.d.cts.map} +1 -1
- package/dist/index.cjs +3 -61
- package/dist/index.d.cts +4 -63
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +4 -63
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -50
- package/dist/mcp/index.cjs +2 -2
- 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.js +2 -2
- package/dist/protocol/index.cjs +2 -2
- package/dist/protocol/index.d.cts +1 -1
- package/dist/protocol/index.d.ts +1 -1
- package/dist/protocol/index.js +2 -2
- package/dist/{resolveProvider-D__uEvDj.cjs → resolveProvider-BZYSw8Qk.cjs} +2 -2
- package/dist/{resolveProvider-D__uEvDj.cjs.map → resolveProvider-BZYSw8Qk.cjs.map} +1 -1
- package/dist/{resolveProvider-TuOLZT2_.js → resolveProvider-UqQxdF4j.js} +2 -2
- package/dist/{resolveProvider-TuOLZT2_.js.map → resolveProvider-UqQxdF4j.js.map} +1 -1
- package/dist/{runner-8eVWfKxh.js → runner-6GMM-5ur.js} +2 -2
- package/dist/{runner-8eVWfKxh.js.map → runner-6GMM-5ur.js.map} +1 -1
- package/dist/{runner-CbC-ncVb.d.ts → runner-ClFrFnz9.d.ts} +1 -1
- package/dist/{runner-CbC-ncVb.d.ts.map → runner-ClFrFnz9.d.ts.map} +1 -1
- package/dist/{runner-Dt--9M2r.cjs → runner-CsrfDub-.cjs} +2 -2
- package/dist/{runner-Dt--9M2r.cjs.map → runner-CsrfDub-.cjs.map} +1 -1
- package/dist/{runner-BJu1lZFi.d.cts → runner-DSgvu6Ad.d.cts} +1 -1
- package/dist/{runner-BJu1lZFi.d.cts.map → runner-DSgvu6Ad.d.cts.map} +1 -1
- package/dist/runtime.cjs +90 -0
- package/dist/runtime.cjs.map +1 -0
- package/dist/runtime.d.cts +65 -0
- package/dist/runtime.d.cts.map +1 -0
- package/dist/runtime.d.ts +65 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +74 -0
- package/dist/runtime.js.map +1 -0
- package/package.json +10 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,120 +1,93 @@
|
|
|
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, with inline, worker, and process host modes |
|
|
24
|
-
| [`@execbox/remote`](https://www.npmjs.com/package/@execbox/remote) | Same executor API, but with a caller-supplied remote boundary |
|
|
25
|
-
| [`@execbox/isolated-vm`](https://www.npmjs.com/package/@execbox/isolated-vm) | Native `isolated-vm` backend when you specifically want that runtime |
|
|
17
|
+
`@execbox/core` defines the provider and tool boundary, but it does not execute guest code on its own.
|
|
26
18
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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)
|
|
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. |
|
|
37
24
|
|
|
38
25
|
## Install
|
|
39
26
|
|
|
27
|
+
Most users start with QuickJS:
|
|
28
|
+
|
|
40
29
|
```bash
|
|
41
30
|
npm install @execbox/core @execbox/quickjs
|
|
42
31
|
```
|
|
43
32
|
|
|
44
|
-
Swap in `@execbox/isolated-vm` when you
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
- Hard isolation depends on the executor and deployment boundary you pair with `@execbox/core`.
|
|
53
|
-
- Providers are explicit capability grants. Every tool you expose is authority you are handing to guest code.
|
|
54
|
-
- In the default deployment model, provider and MCP tool definitions are controlled by the application, not by the end user.
|
|
55
|
-
- Third-party MCP integrations should be reviewed as dependency-trust decisions, not folded into the primary end-user attacker model.
|
|
56
|
-
- If the code source is hostile, prefer stronger isolation such as `QuickJsExecutor` with `host: "process"`, `@execbox/remote`, a container, or a VM.
|
|
57
|
-
|
|
58
|
-
## Architecture Docs
|
|
59
|
-
|
|
60
|
-
- [Execbox architecture overview](https://github.com/aallam/execbox/blob/main/docs/architecture/README.md)
|
|
61
|
-
- [Execbox core architecture](https://github.com/aallam/execbox/blob/main/docs/architecture/execbox-core.md)
|
|
62
|
-
- [Execbox executors](https://github.com/aallam/execbox/blob/main/docs/architecture/execbox-executors.md)
|
|
63
|
-
- [Execbox MCP adapters and protocol](https://github.com/aallam/execbox/blob/main/docs/architecture/execbox-mcp-and-protocol.md)
|
|
64
|
-
|
|
65
|
-
## Exports
|
|
66
|
-
|
|
67
|
-
- `@execbox/core`
|
|
68
|
-
- `ExecutionOptions`
|
|
69
|
-
- `resolveProvider`
|
|
70
|
-
- `normalizeCode`
|
|
71
|
-
- `sanitizeToolName`
|
|
72
|
-
- `extractProviderManifests`
|
|
73
|
-
- `createToolCallDispatcher`
|
|
74
|
-
- JSON Schema type generation and executor/result types
|
|
75
|
-
- `@execbox/core/mcp`
|
|
76
|
-
- `createMcpToolProvider`
|
|
77
|
-
- `openMcpToolProvider`
|
|
78
|
-
- `getMcpToolSourceServerInfo`
|
|
79
|
-
- `McpToolClientSource`
|
|
80
|
-
- `McpToolServerSource`
|
|
81
|
-
- `codeMcpServer`
|
|
82
|
-
|
|
83
|
-
## Basic Usage
|
|
33
|
+
Swap in `@execbox/remote` or `@execbox/isolated-vm` when you need a different runtime boundary.
|
|
34
|
+
|
|
35
|
+
## Runtime Implementer Surface
|
|
36
|
+
|
|
37
|
+
Application code should usually import from `@execbox/core`, `@execbox/core/mcp`, or `@execbox/core/protocol`.
|
|
38
|
+
Executor and runner packages should import shared runtime helpers from `@execbox/core/runtime` instead. That subpath contains the manifest dispatcher, runtime option defaults, timeout helpers, log formatting, code normalization, and error normalization used to keep runtime implementations aligned.
|
|
39
|
+
|
|
40
|
+
## Smallest Working Usage
|
|
84
41
|
|
|
85
42
|
```ts
|
|
86
43
|
import { resolveProvider } from "@execbox/core";
|
|
87
44
|
import { QuickJsExecutor } from "@execbox/quickjs";
|
|
88
|
-
import * as z from "zod";
|
|
89
45
|
|
|
90
46
|
const provider = resolveProvider({
|
|
91
47
|
name: "tools",
|
|
92
48
|
tools: {
|
|
93
|
-
|
|
94
|
-
inputSchema:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return { sum: x + y };
|
|
49
|
+
greet: {
|
|
50
|
+
inputSchema: {
|
|
51
|
+
type: "object",
|
|
52
|
+
required: ["name"],
|
|
53
|
+
properties: {
|
|
54
|
+
name: { type: "string" },
|
|
55
|
+
},
|
|
101
56
|
},
|
|
57
|
+
execute: async (input) => ({
|
|
58
|
+
message: `Hello, ${(input as { name: string }).name}!`,
|
|
59
|
+
}),
|
|
102
60
|
},
|
|
103
61
|
},
|
|
104
62
|
});
|
|
105
63
|
|
|
106
64
|
const executor = new QuickJsExecutor();
|
|
107
|
-
const result = await executor.execute(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
);
|
|
65
|
+
const result = await executor.execute(`await tools.greet({ name: "World" })`, [
|
|
66
|
+
provider,
|
|
67
|
+
]);
|
|
68
|
+
|
|
69
|
+
console.log(result);
|
|
112
70
|
```
|
|
113
71
|
|
|
114
|
-
## MCP
|
|
72
|
+
## MCP Support
|
|
73
|
+
|
|
74
|
+
Use `@execbox/core/mcp` when you want MCP on either side of the boundary:
|
|
75
|
+
|
|
76
|
+
- wrap an upstream MCP server or client into a provider with `createMcpToolProvider()` or `openMcpToolProvider()`
|
|
77
|
+
- expose execbox code execution back out through an MCP server with `codeMcpServer()`
|
|
78
|
+
- preserve raw MCP `CallToolResult` envelopes so guest code can inspect `structuredContent` first and fall back to `content`
|
|
79
|
+
|
|
80
|
+
## Operational Notes
|
|
81
|
+
|
|
82
|
+
- Providers are the capability boundary. If guest code can call a tool, it can exercise that authority.
|
|
83
|
+
- Execbox gives you JSON-only tool/result boundaries, schema validation, bounded logs, and timeout-aware execution controls.
|
|
84
|
+
- Hard isolation depends on the executor and deployment boundary you choose, not on `@execbox/core` by itself.
|
|
115
85
|
|
|
116
|
-
|
|
86
|
+
## Read Next
|
|
117
87
|
|
|
118
|
-
-
|
|
119
|
-
-
|
|
120
|
-
-
|
|
88
|
+
- [Getting Started](https://execbox.aallam.com/getting-started)
|
|
89
|
+
- [Examples](https://execbox.aallam.com/examples)
|
|
90
|
+
- [Security & Boundaries](https://execbox.aallam.com/security)
|
|
91
|
+
- [Architecture Overview](https://execbox.aallam.com/architecture/)
|
|
92
|
+
- [Core Architecture](https://execbox.aallam.com/architecture/execbox-core)
|
|
93
|
+
- [MCP And Protocol](https://execbox.aallam.com/architecture/execbox-mcp-and-protocol)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Public TypeScript declarations for this package entrypoint.
|
|
4
|
+
*/
|
|
5
|
+
import { u as ExecuteErrorCode } from "./runner-DSgvu6Ad.cjs";
|
|
6
|
+
|
|
7
|
+
//#region src/errors.d.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Structured failure used internally to propagate executor and tool errors.
|
|
11
|
+
*/
|
|
12
|
+
declare class ExecuteFailure extends Error {
|
|
13
|
+
code: ExecuteErrorCode;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a structured failure with a trusted executor or tool error code.
|
|
16
|
+
*/
|
|
17
|
+
constructor(code: ExecuteErrorCode, message: string);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns whether a thrown value is an {@link ExecuteFailure}.
|
|
21
|
+
*/
|
|
22
|
+
declare function isExecuteFailure(value: unknown): value is ExecuteFailure;
|
|
23
|
+
/**
|
|
24
|
+
* Returns whether a value can be serialized through the JSON-only host/guest boundary.
|
|
25
|
+
*/
|
|
26
|
+
declare function isJsonSerializable(value: unknown, active?: Set<object>, memo?: WeakSet<object>): boolean;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { isExecuteFailure as n, isJsonSerializable as r, ExecuteFailure as t };
|
|
29
|
+
//# sourceMappingURL=errors-B9ADBuDH.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-B9ADBuDH.d.cts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAKA,CAAA,CAAA;AACQ,OAAA,CAAA,KAAA,CADK,cAAA,CAAA,OAAA,CAAuB,KAAA,CAC5B;EAKY,IAAA,CAAA,CALZ,gBAKY;EANgB,CAAA,CAAA;;AAgBpC,CAAA,CAAA,CAAA,CAAA;EAOgB,WAAA,CAAA,IAAA,CAAA,CAjBI,gBAmBZ,CAAA,CAAA,OACF,CAAA,CAAA,MAAA,CAAA;;;;;iBAVU,gBAAA,2BAA2C;;;;iBAO3C,kBAAA,0BAER,oBACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Public TypeScript declarations for this package entrypoint.
|
|
4
|
+
*/
|
|
5
|
+
import { u as ExecuteErrorCode } from "./runner-ClFrFnz9.js";
|
|
6
|
+
|
|
7
|
+
//#region src/errors.d.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Structured failure used internally to propagate executor and tool errors.
|
|
11
|
+
*/
|
|
12
|
+
declare class ExecuteFailure extends Error {
|
|
13
|
+
code: ExecuteErrorCode;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a structured failure with a trusted executor or tool error code.
|
|
16
|
+
*/
|
|
17
|
+
constructor(code: ExecuteErrorCode, message: string);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns whether a thrown value is an {@link ExecuteFailure}.
|
|
21
|
+
*/
|
|
22
|
+
declare function isExecuteFailure(value: unknown): value is ExecuteFailure;
|
|
23
|
+
/**
|
|
24
|
+
* Returns whether a value can be serialized through the JSON-only host/guest boundary.
|
|
25
|
+
*/
|
|
26
|
+
declare function isJsonSerializable(value: unknown, active?: Set<object>, memo?: WeakSet<object>): boolean;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { isExecuteFailure as n, isJsonSerializable as r, ExecuteFailure as t };
|
|
29
|
+
//# sourceMappingURL=errors-DlbJQYs7.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-DlbJQYs7.d.ts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAKA,CAAA,CAAA;AACQ,OAAA,CAAA,KAAA,CADK,cAAA,CAAA,OAAA,CAAuB,KAAA,CAC5B;EAKY,IAAA,CAAA,CALZ,gBAKY;EANgB,CAAA,CAAA;;AAgBpC,CAAA,CAAA,CAAA,CAAA;EAOgB,WAAA,CAAA,IAAA,CAAA,CAjBI,gBAmBZ,CAAA,CAAA,OACF,CAAA,CAAA,MAAA,CAAA;;;;;iBAVU,gBAAA,2BAA2C;;;;iBAO3C,kBAAA,0BAER,oBACF"}
|
|
@@ -58,4 +58,4 @@ function isJsonSerializable(value, active = /* @__PURE__ */ new Set(), memo = /*
|
|
|
58
58
|
|
|
59
59
|
//#endregion
|
|
60
60
|
export { isExecuteFailure as n, isJsonSerializable as r, ExecuteFailure as t };
|
|
61
|
-
//# sourceMappingURL=errors-
|
|
61
|
+
//# sourceMappingURL=errors-wS8yjQhS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors-
|
|
1
|
+
{"version":3,"file":"errors-wS8yjQhS.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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors-
|
|
1
|
+
{"version":3,"file":"errors-xD8r6fCf.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"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
* Public TypeScript declarations for this package entrypoint.
|
|
4
4
|
*/
|
|
5
|
-
import { d as ExecuteResult, m as ResolvedToolProvider, t as ExecutionOptions } from "./runner-
|
|
5
|
+
import { d as ExecuteResult, m as ResolvedToolProvider, t as ExecutionOptions } from "./runner-ClFrFnz9.js";
|
|
6
6
|
|
|
7
7
|
//#region src/executor/executor.d.ts
|
|
8
8
|
|
|
@@ -26,4 +26,4 @@ interface Executor {
|
|
|
26
26
|
}
|
|
27
27
|
//#endregion
|
|
28
28
|
export { ExecutorPoolOptions as n, Executor as t };
|
|
29
|
-
//# sourceMappingURL=executor-
|
|
29
|
+
//# sourceMappingURL=executor-B7q7K_27.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor-
|
|
1
|
+
{"version":3,"file":"executor-B7q7K_27.d.ts","names":[],"sources":["../src/executor/executor.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAOA,CAAA,CAAA,CAAA,QAAA,CAAA,OAAA,CAAA,QAAA,CAAA,GAAA,CAAA,QAAA,CAAA,eAAA,CAAA,IAAA,CAAA,GAAA,CAAA;AAUA,CAAA,CAAA,CAAA,IAAA,CAAA,IAAA,CAAA,MAAA,CAAA,KAAA,CAAA,KAAA,CAAA,QAAA,CAAA,CAAA,CAAA,KAAA,CAAA,KAAA,CAAA,OAAA,CAAA,GAAA,CAAA,SAAA;;AAIc,SAAA,CAdG,mBAAA,CAcH;EACD,aAAA,CAAA,CAAA,CAAA,MAAA;EAAR,OAAA,CAAA,CAAA,MAAA;EACS,OAAA,CAAA,CAAA,CAAA,MAAA;EACc,OAAA,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,MAAA;;;;;UAPX,QAAA;mCAGF,kCACD,mBACT,QAAQ;cACC;4BACc"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
* Public TypeScript declarations for this package entrypoint.
|
|
4
4
|
*/
|
|
5
|
-
import { d as ExecuteResult, m as ResolvedToolProvider, t as ExecutionOptions } from "./runner-
|
|
5
|
+
import { d as ExecuteResult, m as ResolvedToolProvider, t as ExecutionOptions } from "./runner-DSgvu6Ad.cjs";
|
|
6
6
|
|
|
7
7
|
//#region src/executor/executor.d.ts
|
|
8
8
|
|
|
@@ -26,4 +26,4 @@ interface Executor {
|
|
|
26
26
|
}
|
|
27
27
|
//#endregion
|
|
28
28
|
export { ExecutorPoolOptions as n, Executor as t };
|
|
29
|
-
//# sourceMappingURL=executor-
|
|
29
|
+
//# sourceMappingURL=executor-BsE5nF-j.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor-
|
|
1
|
+
{"version":3,"file":"executor-BsE5nF-j.d.cts","names":[],"sources":["../src/executor/executor.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAOA,CAAA,CAAA,CAAA,QAAA,CAAA,OAAA,CAAA,QAAA,CAAA,GAAA,CAAA,QAAA,CAAA,eAAA,CAAA,IAAA,CAAA,GAAA,CAAA;AAUA,CAAA,CAAA,CAAA,IAAA,CAAA,IAAA,CAAA,MAAA,CAAA,KAAA,CAAA,KAAA,CAAA,QAAA,CAAA,CAAA,CAAA,KAAA,CAAA,KAAA,CAAA,OAAA,CAAA,GAAA,CAAA,SAAA;;AAIc,SAAA,CAdG,mBAAA,CAcH;EACD,aAAA,CAAA,CAAA,CAAA,MAAA;EAAR,OAAA,CAAA,CAAA,MAAA;EACS,OAAA,CAAA,CAAA,CAAA,MAAA;EACc,OAAA,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,CAAA,MAAA;;;;;UAPX,QAAA;mCAGF,kCACD,mBACT,QAAQ;cACC;4BACc"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,72 +1,14 @@
|
|
|
1
|
-
const require_resolveProvider = require('./resolveProvider-
|
|
2
|
-
const
|
|
3
|
-
const require_errors = require('./errors-CTel18cM.cjs');
|
|
4
|
-
let acorn = require("acorn");
|
|
1
|
+
const require_resolveProvider = require('./resolveProvider-BZYSw8Qk.cjs');
|
|
2
|
+
const require_errors = require('./errors-xD8r6fCf.cjs');
|
|
5
3
|
|
|
6
|
-
//#region src/normalize.ts
|
|
7
|
-
function stripCodeFences(source) {
|
|
8
|
-
const match = source.match(/^\s*```[^\n]*\n([\s\S]*?)\n?```\s*$/);
|
|
9
|
-
return match ? match[1] : source;
|
|
10
|
-
}
|
|
11
|
-
function wrapAsync(body) {
|
|
12
|
-
if (body.trim().length === 0) return "async () => {}";
|
|
13
|
-
return `async () => {\n${body}\n}`;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Normalizes model-produced JavaScript into an executable async function body.
|
|
17
|
-
*/
|
|
18
|
-
function normalizeCode(source) {
|
|
19
|
-
const normalizedSource = stripCodeFences(source).trim();
|
|
20
|
-
if (normalizedSource.length === 0) return "async () => {}";
|
|
21
|
-
try {
|
|
22
|
-
const program = (0, acorn.parse)(normalizedSource, {
|
|
23
|
-
ecmaVersion: "latest",
|
|
24
|
-
sourceType: "module"
|
|
25
|
-
});
|
|
26
|
-
if (program.body?.length === 1) {
|
|
27
|
-
const [statement] = program.body;
|
|
28
|
-
if (statement.type === "FunctionDeclaration" && statement.id?.name) return wrapAsync(`${normalizedSource}\nreturn ${statement.id.name}();`);
|
|
29
|
-
if (statement.type === "ExpressionStatement" && statement.expression) {
|
|
30
|
-
if (statement.expression.type === "ArrowFunctionExpression" && statement.expression.async) return normalizedSource;
|
|
31
|
-
return wrapAsync(`return (${normalizedSource});`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const lastStatement = (program.body ?? []).at(-1);
|
|
35
|
-
if (lastStatement?.type === "ExpressionStatement" && lastStatement.expression) {
|
|
36
|
-
const bodyPrefix = normalizedSource.slice(0, lastStatement.start).trimEnd();
|
|
37
|
-
const expressionSource = normalizedSource.slice(lastStatement.expression.start, lastStatement.expression.end);
|
|
38
|
-
const lines = [];
|
|
39
|
-
if (bodyPrefix.length > 0) lines.push(bodyPrefix);
|
|
40
|
-
lines.push(`return (${expressionSource});`);
|
|
41
|
-
return wrapAsync(lines.join("\n"));
|
|
42
|
-
}
|
|
43
|
-
return wrapAsync(normalizedSource);
|
|
44
|
-
} catch {
|
|
45
|
-
return wrapAsync(normalizedSource);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
//#endregion
|
|
50
4
|
exports.ExecuteFailure = require_errors.ExecuteFailure;
|
|
51
5
|
exports.assertValidIdentifier = require_resolveProvider.assertValidIdentifier;
|
|
52
|
-
exports.createExecutionContext = require_runner.createExecutionContext;
|
|
53
|
-
exports.createTimeoutExecuteResult = require_runner.createTimeoutExecuteResult;
|
|
54
|
-
exports.createToolCallDispatcher = require_runner.createToolCallDispatcher;
|
|
55
|
-
exports.extractProviderManifests = require_runner.extractProviderManifests;
|
|
56
|
-
exports.formatConsoleLine = require_runner.formatConsoleLine;
|
|
57
6
|
exports.generateTypesFromJsonSchema = require_resolveProvider.generateTypesFromJsonSchema;
|
|
58
|
-
exports.getExecutionTimeoutMessage = require_runner.getExecutionTimeoutMessage;
|
|
59
7
|
exports.isExecuteFailure = require_errors.isExecuteFailure;
|
|
60
8
|
exports.isJsonSerializable = require_errors.isJsonSerializable;
|
|
61
|
-
exports.isKnownExecuteErrorCode = require_runner.isKnownExecuteErrorCode;
|
|
62
9
|
exports.isReservedWord = require_resolveProvider.isReservedWord;
|
|
63
10
|
exports.isValidIdentifier = require_resolveProvider.isValidIdentifier;
|
|
64
|
-
exports.normalizeCode = normalizeCode;
|
|
65
|
-
exports.normalizeThrownMessage = require_runner.normalizeThrownMessage;
|
|
66
|
-
exports.normalizeThrownName = require_runner.normalizeThrownName;
|
|
67
11
|
exports.resolveProvider = require_resolveProvider.resolveProvider;
|
|
68
12
|
exports.sanitizeIdentifier = require_resolveProvider.sanitizeIdentifier;
|
|
69
13
|
exports.sanitizeToolName = require_resolveProvider.sanitizeToolName;
|
|
70
|
-
exports.serializePropertyName = require_resolveProvider.serializePropertyName;
|
|
71
|
-
exports.truncateLogs = require_runner.truncateLogs;
|
|
72
|
-
//# sourceMappingURL=index.cjs.map
|
|
14
|
+
exports.serializePropertyName = require_resolveProvider.serializePropertyName;
|
package/dist/index.d.cts
CHANGED
|
@@ -2,43 +2,10 @@
|
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
* Public TypeScript declarations for this package entrypoint.
|
|
4
4
|
*/
|
|
5
|
-
import { _ as ToolProvider, a as ToolCall,
|
|
6
|
-
import { n as ExecutorPoolOptions, t as Executor } from "./executor-
|
|
5
|
+
import { _ as ToolProvider, a as ToolCall, d as ExecuteResult, f as JsonSchema, g as ToolExecutionContext, h as ToolDescriptor, i as ProviderToolManifest, l as ExecuteError, m as ResolvedToolProvider, n as ExecutorRuntimeOptions, o as ToolCallResult, p as ResolvedToolDescriptor, r as ProviderManifest, t as ExecutionOptions, u as ExecuteErrorCode, v as ToolSchema, y as TypegenToolDescriptor } from "./runner-DSgvu6Ad.cjs";
|
|
6
|
+
import { n as ExecutorPoolOptions, t as Executor } from "./executor-BsE5nF-j.cjs";
|
|
7
|
+
import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-B9ADBuDH.cjs";
|
|
7
8
|
|
|
8
|
-
//#region src/executor/shared.d.ts
|
|
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
9
|
//#region src/identifier.d.ts
|
|
43
10
|
/**
|
|
44
11
|
* Returns whether the value is a valid JavaScript identifier.
|
|
@@ -61,38 +28,12 @@ declare function sanitizeIdentifier(value: string): string;
|
|
|
61
28
|
*/
|
|
62
29
|
declare function serializePropertyName(name: string): string;
|
|
63
30
|
//#endregion
|
|
64
|
-
//#region src/normalize.d.ts
|
|
65
|
-
/**
|
|
66
|
-
* Normalizes model-produced JavaScript into an executable async function body.
|
|
67
|
-
*/
|
|
68
|
-
declare function normalizeCode(source: string): string;
|
|
69
|
-
//#endregion
|
|
70
31
|
//#region src/sanitize.d.ts
|
|
71
32
|
/**
|
|
72
33
|
* Converts a raw tool name into a safe JavaScript identifier.
|
|
73
34
|
*/
|
|
74
35
|
declare function sanitizeToolName(name: string): string;
|
|
75
36
|
//#endregion
|
|
76
|
-
//#region src/errors.d.ts
|
|
77
|
-
/**
|
|
78
|
-
* Structured failure used internally to propagate executor and tool errors.
|
|
79
|
-
*/
|
|
80
|
-
declare class ExecuteFailure extends Error {
|
|
81
|
-
code: ExecuteErrorCode;
|
|
82
|
-
/**
|
|
83
|
-
* Creates a structured failure with a trusted executor or tool error code.
|
|
84
|
-
*/
|
|
85
|
-
constructor(code: ExecuteErrorCode, message: string);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Returns whether a thrown value is an {@link ExecuteFailure}.
|
|
89
|
-
*/
|
|
90
|
-
declare function isExecuteFailure(value: unknown): value is ExecuteFailure;
|
|
91
|
-
/**
|
|
92
|
-
* Returns whether a value can be serialized through the JSON-only host/guest boundary.
|
|
93
|
-
*/
|
|
94
|
-
declare function isJsonSerializable(value: unknown, active?: Set<object>, memo?: WeakSet<object>): boolean;
|
|
95
|
-
//#endregion
|
|
96
37
|
//#region src/provider/resolveProvider.d.ts
|
|
97
38
|
/**
|
|
98
39
|
* Resolves a tool provider into the validated, sanitized shape consumed by executors.
|
|
@@ -105,5 +46,5 @@ declare function resolveProvider(provider: ToolProvider): ResolvedToolProvider;
|
|
|
105
46
|
*/
|
|
106
47
|
declare function generateTypesFromJsonSchema(providerName: string, tools: Record<string, TypegenToolDescriptor>): string;
|
|
107
48
|
//#endregion
|
|
108
|
-
export { type ExecuteError, type ExecuteErrorCode, ExecuteFailure, type ExecuteResult, type ExecutionOptions, type Executor, type ExecutorPoolOptions, type ExecutorRuntimeOptions, type JsonSchema, type ProviderManifest, type ProviderToolManifest, type ResolvedToolDescriptor, type ResolvedToolProvider, type ToolCall, type ToolCallResult, type ToolDescriptor, type ToolExecutionContext, type ToolProvider, type ToolSchema, type TypegenToolDescriptor, assertValidIdentifier,
|
|
49
|
+
export { type ExecuteError, type ExecuteErrorCode, ExecuteFailure, type ExecuteResult, type ExecutionOptions, type Executor, type ExecutorPoolOptions, type ExecutorRuntimeOptions, type JsonSchema, type ProviderManifest, type ProviderToolManifest, type ResolvedToolDescriptor, type ResolvedToolProvider, type ToolCall, type ToolCallResult, type ToolDescriptor, type ToolExecutionContext, type ToolProvider, type ToolSchema, type TypegenToolDescriptor, assertValidIdentifier, generateTypesFromJsonSchema, isExecuteFailure, isJsonSerializable, isReservedWord, isValidIdentifier, resolveProvider, sanitizeIdentifier, sanitizeToolName, serializePropertyName };
|
|
109
50
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/identifier.ts","../src/sanitize.ts","../src/provider/resolveProvider.ts","../src/typegen/jsonSchema.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;iBA6DgB,iBAAA;;AAAhB,CAAA,CAAA,CAAA,OAAA,CAAA,OAAA,CAAA,GAAA,CAAA,UAAA,CAAA,EAAA,CAAA,QAAA,CAAA,EAAA,CAAA,UAAA,CAAA,MAAA;AAOA,CAAA,CAAA;AAOgB,OAAA,CAAA,QAAA,CAPA,cAAA,CAOqB,KAAA,CAAA,CAAA,MAAA,CAAA,CAAA,CAAA,OAAA;AAYrC,CAAA,CAAA;AAqBA,CAAA,CAAA,CAAA,MAAA,CAAA,IAAA,CAAA,GAAA,CAAA,KAAA,CAAA,MAAA,CAAA,EAAA,CAAA,IAAA,CAAA,EAAA,CAAA,CAAA,CAAA,IAAA,CAAA,UAAA,CAAA,UAAA;;iBAjCgB,qBAAA;;ACtEhB,CAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,GAAA,CAAA,UAAA,CAAA,IAAA,CAAA,KAAA,CAAA,IAAA,CAAA,CAAA,CAAA,IAAA,CAAA,UAAA,CAAA,UAAA;;iBDkFgB,kBAAA;;AE3ChB,CAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,IAAA,CAAA,EAAA,CAAA,CAAA,CAAA,IAAA,CAAA,UAAA,CAAA,IAAA,CAAA,QAAA,CAAA,CAAA,SAAA,CAAA,EAAA,CAAA,CAAA,CAAA,MAAA,CAAA,OAAA;;iBFgEgB,qBAAA;;;;;;iBCvGA,gBAAA;;;;;;iBCuCA,eAAA,WAA0B,eAAe;;;AFwBzD,CAAA,CAAA;AAOA,CAAA,CAAA,CAAA,SAAA,CAAA,CAAA,CAAA,SAAA,CAAA,WAAA,CAAA,GAAA,CAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,IAAA,CAAA,OAAA;AAYA,CAAA,CAAA;AAqBgB,OAAA,CAAA,QAAA,CGJA,2BAAA,CHIqB,YAAA,CAAA,CAAA,MAAA,CAAA,CAAA,KAAA,CAAA,CGF5B,MHE4B,CAAA,MAAA,CAAA,CGFb,qBHEa,CAAA,CAAA,CAAA,CAAA,MAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,43 +2,10 @@
|
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
* Public TypeScript declarations for this package entrypoint.
|
|
4
4
|
*/
|
|
5
|
-
import { _ as ToolProvider, a as ToolCall,
|
|
6
|
-
import { n as ExecutorPoolOptions, t as Executor } from "./executor-
|
|
5
|
+
import { _ as ToolProvider, a as ToolCall, d as ExecuteResult, f as JsonSchema, g as ToolExecutionContext, h as ToolDescriptor, i as ProviderToolManifest, l as ExecuteError, m as ResolvedToolProvider, n as ExecutorRuntimeOptions, o as ToolCallResult, p as ResolvedToolDescriptor, r as ProviderManifest, t as ExecutionOptions, u as ExecuteErrorCode, v as ToolSchema, y as TypegenToolDescriptor } from "./runner-ClFrFnz9.js";
|
|
6
|
+
import { n as ExecutorPoolOptions, t as Executor } from "./executor-B7q7K_27.js";
|
|
7
|
+
import { n as isExecuteFailure, r as isJsonSerializable, t as ExecuteFailure } from "./errors-DlbJQYs7.js";
|
|
7
8
|
|
|
8
|
-
//#region src/executor/shared.d.ts
|
|
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
9
|
//#region src/identifier.d.ts
|
|
43
10
|
/**
|
|
44
11
|
* Returns whether the value is a valid JavaScript identifier.
|
|
@@ -61,38 +28,12 @@ declare function sanitizeIdentifier(value: string): string;
|
|
|
61
28
|
*/
|
|
62
29
|
declare function serializePropertyName(name: string): string;
|
|
63
30
|
//#endregion
|
|
64
|
-
//#region src/normalize.d.ts
|
|
65
|
-
/**
|
|
66
|
-
* Normalizes model-produced JavaScript into an executable async function body.
|
|
67
|
-
*/
|
|
68
|
-
declare function normalizeCode(source: string): string;
|
|
69
|
-
//#endregion
|
|
70
31
|
//#region src/sanitize.d.ts
|
|
71
32
|
/**
|
|
72
33
|
* Converts a raw tool name into a safe JavaScript identifier.
|
|
73
34
|
*/
|
|
74
35
|
declare function sanitizeToolName(name: string): string;
|
|
75
36
|
//#endregion
|
|
76
|
-
//#region src/errors.d.ts
|
|
77
|
-
/**
|
|
78
|
-
* Structured failure used internally to propagate executor and tool errors.
|
|
79
|
-
*/
|
|
80
|
-
declare class ExecuteFailure extends Error {
|
|
81
|
-
code: ExecuteErrorCode;
|
|
82
|
-
/**
|
|
83
|
-
* Creates a structured failure with a trusted executor or tool error code.
|
|
84
|
-
*/
|
|
85
|
-
constructor(code: ExecuteErrorCode, message: string);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Returns whether a thrown value is an {@link ExecuteFailure}.
|
|
89
|
-
*/
|
|
90
|
-
declare function isExecuteFailure(value: unknown): value is ExecuteFailure;
|
|
91
|
-
/**
|
|
92
|
-
* Returns whether a value can be serialized through the JSON-only host/guest boundary.
|
|
93
|
-
*/
|
|
94
|
-
declare function isJsonSerializable(value: unknown, active?: Set<object>, memo?: WeakSet<object>): boolean;
|
|
95
|
-
//#endregion
|
|
96
37
|
//#region src/provider/resolveProvider.d.ts
|
|
97
38
|
/**
|
|
98
39
|
* Resolves a tool provider into the validated, sanitized shape consumed by executors.
|
|
@@ -105,5 +46,5 @@ declare function resolveProvider(provider: ToolProvider): ResolvedToolProvider;
|
|
|
105
46
|
*/
|
|
106
47
|
declare function generateTypesFromJsonSchema(providerName: string, tools: Record<string, TypegenToolDescriptor>): string;
|
|
107
48
|
//#endregion
|
|
108
|
-
export { type ExecuteError, type ExecuteErrorCode, ExecuteFailure, type ExecuteResult, type ExecutionOptions, type Executor, type ExecutorPoolOptions, type ExecutorRuntimeOptions, type JsonSchema, type ProviderManifest, type ProviderToolManifest, type ResolvedToolDescriptor, type ResolvedToolProvider, type ToolCall, type ToolCallResult, type ToolDescriptor, type ToolExecutionContext, type ToolProvider, type ToolSchema, type TypegenToolDescriptor, assertValidIdentifier,
|
|
49
|
+
export { type ExecuteError, type ExecuteErrorCode, ExecuteFailure, type ExecuteResult, type ExecutionOptions, type Executor, type ExecutorPoolOptions, type ExecutorRuntimeOptions, type JsonSchema, type ProviderManifest, type ProviderToolManifest, type ResolvedToolDescriptor, type ResolvedToolProvider, type ToolCall, type ToolCallResult, type ToolDescriptor, type ToolExecutionContext, type ToolProvider, type ToolSchema, type TypegenToolDescriptor, assertValidIdentifier, generateTypesFromJsonSchema, isExecuteFailure, isJsonSerializable, isReservedWord, isValidIdentifier, resolveProvider, sanitizeIdentifier, sanitizeToolName, serializePropertyName };
|
|
109
50
|
//# sourceMappingURL=index.d.ts.map
|