@execbox/quickjs 0.1.2 → 0.2.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 +6 -2
- package/dist/index.cjs +70 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -4
- package/dist/index.js.map +1 -1
- package/dist/runner/index.cjs +1 -1
- package/dist/runner/index.d.cts +11 -77
- package/dist/runner/index.d.cts.map +1 -1
- package/dist/runner/index.d.ts +11 -77
- package/dist/runner/index.d.ts.map +1 -1
- package/dist/runner/index.js +1 -1
- package/dist/runner/protocolEndpoint.cjs +5 -1
- package/dist/runner/protocolEndpoint.cjs.map +1 -1
- package/dist/runner/protocolEndpoint.d.cts +4 -0
- package/dist/runner/protocolEndpoint.d.cts.map +1 -1
- package/dist/runner/protocolEndpoint.d.ts +4 -0
- package/dist/runner/protocolEndpoint.d.ts.map +1 -1
- package/dist/runner/protocolEndpoint.js +5 -1
- package/dist/runner/protocolEndpoint.js.map +1 -1
- package/dist/{runner-9_N9h2rp.cjs → runner-BqkDnP0t.cjs} +109 -1
- package/dist/{runner-9_N9h2rp.cjs.map → runner-BqkDnP0t.cjs.map} +1 -1
- package/dist/{runner-O4f_FOhI.js → runner-CVaY4RVQ.js} +68 -2
- package/dist/{runner-O4f_FOhI.js.map → runner-CVaY4RVQ.js.map} +1 -1
- package/dist/{types-BB8mb_-T.d.cts → types-BXi8Lqtk.d.ts} +6 -2
- package/dist/types-BXi8Lqtk.d.ts.map +1 -0
- package/dist/{types-D7uau0GM.d.ts → types-CVE2n2LY.d.cts} +6 -2
- package/dist/types-CVE2n2LY.d.cts.map +1 -0
- package/package.json +15 -6
- package/dist/types-BB8mb_-T.d.cts.map +0 -1
- package/dist/types-D7uau0GM.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -5,6 +5,8 @@ QuickJS executor backend for `@execbox/core`.
|
|
|
5
5
|
[](https://www.npmjs.com/package/@execbox/quickjs)
|
|
6
6
|
[](https://github.com/aallam/execbox/blob/main/LICENSE)
|
|
7
7
|
|
|
8
|
+
Docs: https://execbox.aallam.com
|
|
9
|
+
|
|
8
10
|
## Choose QuickJS When
|
|
9
11
|
|
|
10
12
|
- you want the easiest execbox backend to install
|
|
@@ -16,8 +18,8 @@ QuickJS executor backend for `@execbox/core`.
|
|
|
16
18
|
- Each execution gets a fresh QuickJS runtime with no ambient Node globals injected by execbox.
|
|
17
19
|
- Tool calls cross a JSON-only bridge, and executor timeouts propagate abort signals to in-flight provider work.
|
|
18
20
|
- In the default deployment model, provider definitions are controlled by the host application, while hostile users control guest code and tool inputs.
|
|
19
|
-
- This package is not
|
|
20
|
-
- If you need a stronger boundary,
|
|
21
|
+
- This package is designed for host-controlled deployments and does not by itself create a hard isolation boundary for hostile code.
|
|
22
|
+
- If you need a stronger boundary, move execution into a separate process, container, or remote runtime.
|
|
21
23
|
|
|
22
24
|
## Architecture Docs
|
|
23
25
|
|
|
@@ -63,3 +65,5 @@ const result = await executor.execute("await codemode.echo({ ok: true })", [
|
|
|
63
65
|
```
|
|
64
66
|
|
|
65
67
|
Each execution runs in a fresh QuickJS runtime with timeout handling, captured logs, and JSON-only result and tool boundaries.
|
|
68
|
+
|
|
69
|
+
`QuickJsExecutor` intentionally stays ephemeral. Every `execute()` call creates a fresh QuickJS runtime/context, and the package does not expose a pooling API.
|
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,77 @@
|
|
|
1
|
-
const require_runner = require('./runner-
|
|
2
|
-
let __execbox_core = require("@execbox/core");
|
|
1
|
+
const require_runner = require('./runner-BqkDnP0t.cjs');
|
|
3
2
|
|
|
3
|
+
//#region ../core/src/runner.ts
|
|
4
|
+
function toTrustedExecuteError(error) {
|
|
5
|
+
if (require_runner.isExecuteFailure(error)) return {
|
|
6
|
+
code: error.code,
|
|
7
|
+
message: error.message
|
|
8
|
+
};
|
|
9
|
+
return {
|
|
10
|
+
code: "tool_error",
|
|
11
|
+
message: require_runner.normalizeThrownMessage(error)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Converts resolved providers into manifest metadata that reveals only namespace details.
|
|
16
|
+
*/
|
|
17
|
+
function extractProviderManifests(providers) {
|
|
18
|
+
return providers.map((provider) => ({
|
|
19
|
+
name: provider.name,
|
|
20
|
+
tools: Object.fromEntries(Object.entries(provider.tools).map(([safeToolName, descriptor]) => [safeToolName, {
|
|
21
|
+
description: descriptor.description,
|
|
22
|
+
originalName: descriptor.originalName,
|
|
23
|
+
safeName: descriptor.safeName
|
|
24
|
+
}])),
|
|
25
|
+
types: provider.types
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a host-side dispatcher for runner-emitted tool calls.
|
|
30
|
+
*/
|
|
31
|
+
function createToolCallDispatcher(providers, signal) {
|
|
32
|
+
const providerMap = new Map(providers.map((provider) => [provider.name, provider]));
|
|
33
|
+
return async (call) => {
|
|
34
|
+
const provider = providerMap.get(call.providerName);
|
|
35
|
+
const descriptor = provider?.tools[call.safeToolName];
|
|
36
|
+
if (!provider || !descriptor) return {
|
|
37
|
+
error: {
|
|
38
|
+
code: "internal_error",
|
|
39
|
+
message: `Unknown tool ${call.providerName}.${call.safeToolName}`
|
|
40
|
+
},
|
|
41
|
+
ok: false
|
|
42
|
+
};
|
|
43
|
+
try {
|
|
44
|
+
if (signal.aborted) return {
|
|
45
|
+
error: {
|
|
46
|
+
code: "timeout",
|
|
47
|
+
message: require_runner.getExecutionTimeoutMessage()
|
|
48
|
+
},
|
|
49
|
+
ok: false
|
|
50
|
+
};
|
|
51
|
+
const result = await descriptor.execute(call.input, require_runner.createExecutionContext(signal, provider.name, descriptor.safeName, descriptor.originalName));
|
|
52
|
+
if (result !== void 0 && !require_runner.isJsonSerializable(result)) throw new require_runner.ExecuteFailure("serialization_error", "Host value is not JSON-serializable");
|
|
53
|
+
return {
|
|
54
|
+
ok: true,
|
|
55
|
+
result
|
|
56
|
+
};
|
|
57
|
+
} catch (error) {
|
|
58
|
+
return {
|
|
59
|
+
error: toTrustedExecuteError(error),
|
|
60
|
+
ok: false
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
4
67
|
//#region src/quickjsExecutor.ts
|
|
5
68
|
/**
|
|
6
|
-
* QuickJS-backed executor for
|
|
69
|
+
* QuickJS-backed executor for ephemeral sandboxed JavaScript runs.
|
|
7
70
|
*/
|
|
8
71
|
var QuickJsExecutor = class {
|
|
9
72
|
options;
|
|
10
73
|
/**
|
|
11
|
-
* Creates a QuickJS executor with
|
|
74
|
+
* Creates a QuickJS executor with ephemeral runtime limits and host bridging configuration.
|
|
12
75
|
*/
|
|
13
76
|
constructor(options = {}) {
|
|
14
77
|
this.options = options;
|
|
@@ -17,9 +80,9 @@ var QuickJsExecutor = class {
|
|
|
17
80
|
* Executes JavaScript against the provided tool namespaces in a fresh QuickJS runtime.
|
|
18
81
|
*/
|
|
19
82
|
async execute(code, providers, options = {}) {
|
|
20
|
-
if (options.signal?.aborted) return
|
|
83
|
+
if (options.signal?.aborted) return require_runner.createTimeoutExecuteResult();
|
|
21
84
|
const abortController = new AbortController();
|
|
22
|
-
const onToolCall =
|
|
85
|
+
const onToolCall = createToolCallDispatcher(providers, abortController.signal);
|
|
23
86
|
const onAbort = () => {
|
|
24
87
|
abortController.abort();
|
|
25
88
|
};
|
|
@@ -29,7 +92,7 @@ var QuickJsExecutor = class {
|
|
|
29
92
|
abortController,
|
|
30
93
|
code,
|
|
31
94
|
onToolCall,
|
|
32
|
-
providers:
|
|
95
|
+
providers: extractProviderManifests(providers)
|
|
33
96
|
}, {
|
|
34
97
|
...this.options,
|
|
35
98
|
...options
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["runQuickJsSession"],"sources":["../src/quickjsExecutor.ts"],"sourcesContent":["import {\n createTimeoutExecuteResult,\n createToolCallDispatcher,\n extractProviderManifests,\n
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["isExecuteFailure","normalizeThrownMessage","getExecutionTimeoutMessage","createExecutionContext","isJsonSerializable","ExecuteFailure","createTimeoutExecuteResult","runQuickJsSession"],"sources":["../../core/src/runner.ts","../src/quickjsExecutor.ts"],"sourcesContent":["import {\n createExecutionContext,\n getExecutionTimeoutMessage,\n normalizeThrownMessage,\n} from \"./executor/shared.ts\";\nimport {\n ExecuteFailure,\n isExecuteFailure,\n isJsonSerializable,\n} from \"./errors.ts\";\nimport type { ExecuteError, ResolvedToolProvider } from \"./types.ts\";\n\n/**\n * Transport-safe metadata for one exposed tool.\n */\nexport interface ProviderToolManifest {\n description?: string;\n originalName: string;\n safeName: string;\n}\n\n/**\n * Namespace manifest shared with runner implementations.\n */\nexport interface ProviderManifest {\n name: string;\n tools: Record<string, ProviderToolManifest>;\n types: string;\n}\n\n/**\n * Execution limits forwarded to runner implementations.\n */\nexport interface ExecutorRuntimeOptions {\n maxLogChars?: number;\n maxLogLines?: number;\n memoryLimitBytes?: number;\n timeoutMs?: number;\n}\n\n/**\n * Public execution options accepted by executors per call.\n */\nexport interface ExecutionOptions extends ExecutorRuntimeOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Tool invocation request emitted from a runner.\n */\nexport interface ToolCall {\n input: unknown;\n providerName: string;\n safeToolName: string;\n}\n\n/**\n * Trusted host response to a tool invocation request.\n */\nexport type ToolCallResult =\n | {\n ok: true;\n result: unknown;\n }\n | {\n error: ExecuteError;\n ok: false;\n };\n\nfunction toTrustedExecuteError(error: unknown): ExecuteError {\n if (isExecuteFailure(error)) {\n return {\n code: error.code,\n message: error.message,\n };\n }\n\n return {\n code: \"tool_error\",\n message: normalizeThrownMessage(error),\n };\n}\n\n/**\n * Converts resolved providers into manifest metadata that reveals only namespace details.\n */\nexport function extractProviderManifests(\n providers: ResolvedToolProvider[],\n): ProviderManifest[] {\n return providers.map((provider) => ({\n name: provider.name,\n tools: Object.fromEntries(\n Object.entries(provider.tools).map(([safeToolName, descriptor]) => [\n safeToolName,\n {\n description: descriptor.description,\n originalName: descriptor.originalName,\n safeName: descriptor.safeName,\n },\n ]),\n ),\n types: provider.types,\n }));\n}\n\n/**\n * Creates a host-side dispatcher for runner-emitted tool calls.\n */\nexport function createToolCallDispatcher(\n providers: ResolvedToolProvider[],\n signal: AbortSignal,\n): (call: ToolCall) => Promise<ToolCallResult> {\n const providerMap = new Map(\n providers.map((provider) => [provider.name, provider] as const),\n );\n\n return async (call) => {\n const provider = providerMap.get(call.providerName);\n const descriptor = provider?.tools[call.safeToolName];\n\n if (!provider || !descriptor) {\n return {\n error: {\n code: \"internal_error\",\n message: `Unknown tool ${call.providerName}.${call.safeToolName}`,\n },\n ok: false,\n };\n }\n\n try {\n if (signal.aborted) {\n return {\n error: {\n code: \"timeout\",\n message: getExecutionTimeoutMessage(),\n },\n ok: false,\n };\n }\n\n const result = await descriptor.execute(\n call.input,\n createExecutionContext(\n signal,\n provider.name,\n descriptor.safeName,\n descriptor.originalName,\n ),\n );\n\n if (result !== undefined && !isJsonSerializable(result)) {\n throw new ExecuteFailure(\n \"serialization_error\",\n \"Host value is not JSON-serializable\",\n );\n }\n\n return {\n ok: true,\n result,\n };\n } catch (error) {\n return {\n error: toTrustedExecuteError(error),\n ok: false,\n };\n }\n };\n}\n","import {\n createTimeoutExecuteResult,\n createToolCallDispatcher,\n extractProviderManifests,\n} from \"../../core/src/runtime.ts\";\nimport type {\n ExecutionOptions,\n ExecuteResult,\n Executor,\n ResolvedToolProvider,\n} from \"@execbox/core\";\n\nimport { runQuickJsSession } from \"./runner/index.ts\";\nimport type { QuickJsExecutorOptions } from \"./types\";\n\n/**\n * QuickJS-backed executor for ephemeral sandboxed JavaScript runs.\n */\nexport class QuickJsExecutor implements Executor {\n private readonly options: QuickJsExecutorOptions;\n\n /**\n * Creates a QuickJS executor with ephemeral runtime limits and host bridging configuration.\n */\n constructor(options: QuickJsExecutorOptions = {}) {\n this.options = options;\n }\n\n /**\n * Executes JavaScript against the provided tool namespaces in a fresh QuickJS runtime.\n */\n async execute(\n code: string,\n providers: ResolvedToolProvider[],\n options: ExecutionOptions = {},\n ): Promise<ExecuteResult> {\n if (options.signal?.aborted) {\n return createTimeoutExecuteResult();\n }\n\n const abortController = new AbortController();\n const onToolCall = createToolCallDispatcher(\n providers,\n abortController.signal,\n );\n const onAbort = () => {\n abortController.abort();\n };\n\n options.signal?.addEventListener(\"abort\", onAbort, { once: true });\n\n try {\n return await runQuickJsSession(\n {\n abortController,\n code,\n onToolCall,\n providers: extractProviderManifests(providers),\n },\n {\n ...this.options,\n ...options,\n },\n );\n } finally {\n options.signal?.removeEventListener(\"abort\", onAbort);\n abortController.abort();\n }\n }\n}\n"],"mappings":";;;AAqEA,SAAS,sBAAsB,OAA8B;AAC3D,KAAIA,gCAAiB,MAAM,CACzB,QAAO;EACL,MAAM,MAAM;EACZ,SAAS,MAAM;EAChB;AAGH,QAAO;EACL,MAAM;EACN,SAASC,sCAAuB,MAAM;EACvC;;;;;AAMH,SAAgB,yBACd,WACoB;AACpB,QAAO,UAAU,KAAK,cAAc;EAClC,MAAM,SAAS;EACf,OAAO,OAAO,YACZ,OAAO,QAAQ,SAAS,MAAM,CAAC,KAAK,CAAC,cAAc,gBAAgB,CACjE,cACA;GACE,aAAa,WAAW;GACxB,cAAc,WAAW;GACzB,UAAU,WAAW;GACtB,CACF,CAAC,CACH;EACD,OAAO,SAAS;EACjB,EAAE;;;;;AAML,SAAgB,yBACd,WACA,QAC6C;CAC7C,MAAM,cAAc,IAAI,IACtB,UAAU,KAAK,aAAa,CAAC,SAAS,MAAM,SAAS,CAAU,CAChE;AAED,QAAO,OAAO,SAAS;EACrB,MAAM,WAAW,YAAY,IAAI,KAAK,aAAa;EACnD,MAAM,aAAa,UAAU,MAAM,KAAK;AAExC,MAAI,CAAC,YAAY,CAAC,WAChB,QAAO;GACL,OAAO;IACL,MAAM;IACN,SAAS,gBAAgB,KAAK,aAAa,GAAG,KAAK;IACpD;GACD,IAAI;GACL;AAGH,MAAI;AACF,OAAI,OAAO,QACT,QAAO;IACL,OAAO;KACL,MAAM;KACN,SAASC,2CAA4B;KACtC;IACD,IAAI;IACL;GAGH,MAAM,SAAS,MAAM,WAAW,QAC9B,KAAK,OACLC,sCACE,QACA,SAAS,MACT,WAAW,UACX,WAAW,aACZ,CACF;AAED,OAAI,WAAW,UAAa,CAACC,kCAAmB,OAAO,CACrD,OAAM,IAAIC,8BACR,uBACA,sCACD;AAGH,UAAO;IACL,IAAI;IACJ;IACD;WACM,OAAO;AACd,UAAO;IACL,OAAO,sBAAsB,MAAM;IACnC,IAAI;IACL;;;;;;;;;;ACpJP,IAAa,kBAAb,MAAiD;CAC/C,AAAiB;;;;CAKjB,YAAY,UAAkC,EAAE,EAAE;AAChD,OAAK,UAAU;;;;;CAMjB,MAAM,QACJ,MACA,WACA,UAA4B,EAAE,EACN;AACxB,MAAI,QAAQ,QAAQ,QAClB,QAAOC,2CAA4B;EAGrC,MAAM,kBAAkB,IAAI,iBAAiB;EAC7C,MAAM,aAAa,yBACjB,WACA,gBAAgB,OACjB;EACD,MAAM,gBAAgB;AACpB,mBAAgB,OAAO;;AAGzB,UAAQ,QAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,MAAM,CAAC;AAElE,MAAI;AACF,UAAO,MAAMC,iCACX;IACE;IACA;IACA;IACA,WAAW,yBAAyB,UAAU;IAC/C,EACD;IACE,GAAG,KAAK;IACR,GAAG;IACJ,CACF;YACO;AACR,WAAQ,QAAQ,oBAAoB,SAAS,QAAQ;AACrD,mBAAgB,OAAO"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Public TypeScript declarations for this package entrypoint.
|
|
4
|
+
*/
|
|
5
|
+
import { t as QuickJsExecutorOptions } from "./types-CVE2n2LY.cjs";
|
|
2
6
|
import { ExecuteResult, ExecutionOptions, Executor, ResolvedToolProvider } from "@execbox/core";
|
|
3
7
|
|
|
4
8
|
//#region src/quickjsExecutor.d.ts
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
|
-
* QuickJS-backed executor for
|
|
11
|
+
* QuickJS-backed executor for ephemeral sandboxed JavaScript runs.
|
|
8
12
|
*/
|
|
9
13
|
declare class QuickJsExecutor implements Executor {
|
|
10
14
|
private readonly options;
|
|
11
15
|
/**
|
|
12
|
-
* Creates a QuickJS executor with
|
|
16
|
+
* Creates a QuickJS executor with ephemeral runtime limits and host bridging configuration.
|
|
13
17
|
*/
|
|
14
18
|
constructor(options?: QuickJsExecutorOptions);
|
|
15
19
|
/**
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/quickjsExecutor.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/quickjsExecutor.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAkBA,CAAA,CAAA;AAMuB,OAAA,CAAA,KAAA,CANV,eAAA,CAAA,UAAA,CAA2B,QAMjB,CAAA;EASR,OAAA,CAAA,QAAA,CAAA,OAAA;EACF,CAAA,CAAA;;;EAhB2B,WAAA,CAAA,OAAA,CAAA,CAAA,CAMjB,sBANiB,CAAA;EAAQ,CAAA,CAAA;;;mCAejC,kCACF,mBACR,QAAQ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Public TypeScript declarations for this package entrypoint.
|
|
4
|
+
*/
|
|
5
|
+
import { t as QuickJsExecutorOptions } from "./types-BXi8Lqtk.js";
|
|
2
6
|
import { ExecuteResult, ExecutionOptions, Executor, ResolvedToolProvider } from "@execbox/core";
|
|
3
7
|
|
|
4
8
|
//#region src/quickjsExecutor.d.ts
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
|
-
* QuickJS-backed executor for
|
|
11
|
+
* QuickJS-backed executor for ephemeral sandboxed JavaScript runs.
|
|
8
12
|
*/
|
|
9
13
|
declare class QuickJsExecutor implements Executor {
|
|
10
14
|
private readonly options;
|
|
11
15
|
/**
|
|
12
|
-
* Creates a QuickJS executor with
|
|
16
|
+
* Creates a QuickJS executor with ephemeral runtime limits and host bridging configuration.
|
|
13
17
|
*/
|
|
14
18
|
constructor(options?: QuickJsExecutorOptions);
|
|
15
19
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/quickjsExecutor.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/quickjsExecutor.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAkBA,CAAA,CAAA;AAMuB,OAAA,CAAA,KAAA,CANV,eAAA,CAAA,UAAA,CAA2B,QAMjB,CAAA;EASR,OAAA,CAAA,QAAA,CAAA,OAAA;EACF,CAAA,CAAA;;;EAhB2B,WAAA,CAAA,OAAA,CAAA,CAAA,CAMjB,sBANiB,CAAA;EAAQ,CAAA,CAAA;;;mCAejC,kCACF,mBACR,QAAQ"}
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,77 @@
|
|
|
1
|
-
import { t as runQuickJsSession } from "./runner-
|
|
2
|
-
import { createTimeoutExecuteResult, createToolCallDispatcher, extractProviderManifests } from "@execbox/core";
|
|
1
|
+
import { a as createExecutionContext, c as normalizeThrownMessage, i as isJsonSerializable, n as ExecuteFailure, o as createTimeoutExecuteResult, r as isExecuteFailure, s as getExecutionTimeoutMessage, t as runQuickJsSession } from "./runner-CVaY4RVQ.js";
|
|
3
2
|
|
|
3
|
+
//#region ../core/src/runner.ts
|
|
4
|
+
function toTrustedExecuteError(error) {
|
|
5
|
+
if (isExecuteFailure(error)) return {
|
|
6
|
+
code: error.code,
|
|
7
|
+
message: error.message
|
|
8
|
+
};
|
|
9
|
+
return {
|
|
10
|
+
code: "tool_error",
|
|
11
|
+
message: normalizeThrownMessage(error)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Converts resolved providers into manifest metadata that reveals only namespace details.
|
|
16
|
+
*/
|
|
17
|
+
function extractProviderManifests(providers) {
|
|
18
|
+
return providers.map((provider) => ({
|
|
19
|
+
name: provider.name,
|
|
20
|
+
tools: Object.fromEntries(Object.entries(provider.tools).map(([safeToolName, descriptor]) => [safeToolName, {
|
|
21
|
+
description: descriptor.description,
|
|
22
|
+
originalName: descriptor.originalName,
|
|
23
|
+
safeName: descriptor.safeName
|
|
24
|
+
}])),
|
|
25
|
+
types: provider.types
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a host-side dispatcher for runner-emitted tool calls.
|
|
30
|
+
*/
|
|
31
|
+
function createToolCallDispatcher(providers, signal) {
|
|
32
|
+
const providerMap = new Map(providers.map((provider) => [provider.name, provider]));
|
|
33
|
+
return async (call) => {
|
|
34
|
+
const provider = providerMap.get(call.providerName);
|
|
35
|
+
const descriptor = provider?.tools[call.safeToolName];
|
|
36
|
+
if (!provider || !descriptor) return {
|
|
37
|
+
error: {
|
|
38
|
+
code: "internal_error",
|
|
39
|
+
message: `Unknown tool ${call.providerName}.${call.safeToolName}`
|
|
40
|
+
},
|
|
41
|
+
ok: false
|
|
42
|
+
};
|
|
43
|
+
try {
|
|
44
|
+
if (signal.aborted) return {
|
|
45
|
+
error: {
|
|
46
|
+
code: "timeout",
|
|
47
|
+
message: getExecutionTimeoutMessage()
|
|
48
|
+
},
|
|
49
|
+
ok: false
|
|
50
|
+
};
|
|
51
|
+
const result = await descriptor.execute(call.input, createExecutionContext(signal, provider.name, descriptor.safeName, descriptor.originalName));
|
|
52
|
+
if (result !== void 0 && !isJsonSerializable(result)) throw new ExecuteFailure("serialization_error", "Host value is not JSON-serializable");
|
|
53
|
+
return {
|
|
54
|
+
ok: true,
|
|
55
|
+
result
|
|
56
|
+
};
|
|
57
|
+
} catch (error) {
|
|
58
|
+
return {
|
|
59
|
+
error: toTrustedExecuteError(error),
|
|
60
|
+
ok: false
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
4
67
|
//#region src/quickjsExecutor.ts
|
|
5
68
|
/**
|
|
6
|
-
* QuickJS-backed executor for
|
|
69
|
+
* QuickJS-backed executor for ephemeral sandboxed JavaScript runs.
|
|
7
70
|
*/
|
|
8
71
|
var QuickJsExecutor = class {
|
|
9
72
|
options;
|
|
10
73
|
/**
|
|
11
|
-
* Creates a QuickJS executor with
|
|
74
|
+
* Creates a QuickJS executor with ephemeral runtime limits and host bridging configuration.
|
|
12
75
|
*/
|
|
13
76
|
constructor(options = {}) {
|
|
14
77
|
this.options = options;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/quickjsExecutor.ts"],"sourcesContent":["import {\n createTimeoutExecuteResult,\n createToolCallDispatcher,\n extractProviderManifests,\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../core/src/runner.ts","../src/quickjsExecutor.ts"],"sourcesContent":["import {\n createExecutionContext,\n getExecutionTimeoutMessage,\n normalizeThrownMessage,\n} from \"./executor/shared.ts\";\nimport {\n ExecuteFailure,\n isExecuteFailure,\n isJsonSerializable,\n} from \"./errors.ts\";\nimport type { ExecuteError, ResolvedToolProvider } from \"./types.ts\";\n\n/**\n * Transport-safe metadata for one exposed tool.\n */\nexport interface ProviderToolManifest {\n description?: string;\n originalName: string;\n safeName: string;\n}\n\n/**\n * Namespace manifest shared with runner implementations.\n */\nexport interface ProviderManifest {\n name: string;\n tools: Record<string, ProviderToolManifest>;\n types: string;\n}\n\n/**\n * Execution limits forwarded to runner implementations.\n */\nexport interface ExecutorRuntimeOptions {\n maxLogChars?: number;\n maxLogLines?: number;\n memoryLimitBytes?: number;\n timeoutMs?: number;\n}\n\n/**\n * Public execution options accepted by executors per call.\n */\nexport interface ExecutionOptions extends ExecutorRuntimeOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Tool invocation request emitted from a runner.\n */\nexport interface ToolCall {\n input: unknown;\n providerName: string;\n safeToolName: string;\n}\n\n/**\n * Trusted host response to a tool invocation request.\n */\nexport type ToolCallResult =\n | {\n ok: true;\n result: unknown;\n }\n | {\n error: ExecuteError;\n ok: false;\n };\n\nfunction toTrustedExecuteError(error: unknown): ExecuteError {\n if (isExecuteFailure(error)) {\n return {\n code: error.code,\n message: error.message,\n };\n }\n\n return {\n code: \"tool_error\",\n message: normalizeThrownMessage(error),\n };\n}\n\n/**\n * Converts resolved providers into manifest metadata that reveals only namespace details.\n */\nexport function extractProviderManifests(\n providers: ResolvedToolProvider[],\n): ProviderManifest[] {\n return providers.map((provider) => ({\n name: provider.name,\n tools: Object.fromEntries(\n Object.entries(provider.tools).map(([safeToolName, descriptor]) => [\n safeToolName,\n {\n description: descriptor.description,\n originalName: descriptor.originalName,\n safeName: descriptor.safeName,\n },\n ]),\n ),\n types: provider.types,\n }));\n}\n\n/**\n * Creates a host-side dispatcher for runner-emitted tool calls.\n */\nexport function createToolCallDispatcher(\n providers: ResolvedToolProvider[],\n signal: AbortSignal,\n): (call: ToolCall) => Promise<ToolCallResult> {\n const providerMap = new Map(\n providers.map((provider) => [provider.name, provider] as const),\n );\n\n return async (call) => {\n const provider = providerMap.get(call.providerName);\n const descriptor = provider?.tools[call.safeToolName];\n\n if (!provider || !descriptor) {\n return {\n error: {\n code: \"internal_error\",\n message: `Unknown tool ${call.providerName}.${call.safeToolName}`,\n },\n ok: false,\n };\n }\n\n try {\n if (signal.aborted) {\n return {\n error: {\n code: \"timeout\",\n message: getExecutionTimeoutMessage(),\n },\n ok: false,\n };\n }\n\n const result = await descriptor.execute(\n call.input,\n createExecutionContext(\n signal,\n provider.name,\n descriptor.safeName,\n descriptor.originalName,\n ),\n );\n\n if (result !== undefined && !isJsonSerializable(result)) {\n throw new ExecuteFailure(\n \"serialization_error\",\n \"Host value is not JSON-serializable\",\n );\n }\n\n return {\n ok: true,\n result,\n };\n } catch (error) {\n return {\n error: toTrustedExecuteError(error),\n ok: false,\n };\n }\n };\n}\n","import {\n createTimeoutExecuteResult,\n createToolCallDispatcher,\n extractProviderManifests,\n} from \"../../core/src/runtime.ts\";\nimport type {\n ExecutionOptions,\n ExecuteResult,\n Executor,\n ResolvedToolProvider,\n} from \"@execbox/core\";\n\nimport { runQuickJsSession } from \"./runner/index.ts\";\nimport type { QuickJsExecutorOptions } from \"./types\";\n\n/**\n * QuickJS-backed executor for ephemeral sandboxed JavaScript runs.\n */\nexport class QuickJsExecutor implements Executor {\n private readonly options: QuickJsExecutorOptions;\n\n /**\n * Creates a QuickJS executor with ephemeral runtime limits and host bridging configuration.\n */\n constructor(options: QuickJsExecutorOptions = {}) {\n this.options = options;\n }\n\n /**\n * Executes JavaScript against the provided tool namespaces in a fresh QuickJS runtime.\n */\n async execute(\n code: string,\n providers: ResolvedToolProvider[],\n options: ExecutionOptions = {},\n ): Promise<ExecuteResult> {\n if (options.signal?.aborted) {\n return createTimeoutExecuteResult();\n }\n\n const abortController = new AbortController();\n const onToolCall = createToolCallDispatcher(\n providers,\n abortController.signal,\n );\n const onAbort = () => {\n abortController.abort();\n };\n\n options.signal?.addEventListener(\"abort\", onAbort, { once: true });\n\n try {\n return await runQuickJsSession(\n {\n abortController,\n code,\n onToolCall,\n providers: extractProviderManifests(providers),\n },\n {\n ...this.options,\n ...options,\n },\n );\n } finally {\n options.signal?.removeEventListener(\"abort\", onAbort);\n abortController.abort();\n }\n }\n}\n"],"mappings":";;;AAqEA,SAAS,sBAAsB,OAA8B;AAC3D,KAAI,iBAAiB,MAAM,CACzB,QAAO;EACL,MAAM,MAAM;EACZ,SAAS,MAAM;EAChB;AAGH,QAAO;EACL,MAAM;EACN,SAAS,uBAAuB,MAAM;EACvC;;;;;AAMH,SAAgB,yBACd,WACoB;AACpB,QAAO,UAAU,KAAK,cAAc;EAClC,MAAM,SAAS;EACf,OAAO,OAAO,YACZ,OAAO,QAAQ,SAAS,MAAM,CAAC,KAAK,CAAC,cAAc,gBAAgB,CACjE,cACA;GACE,aAAa,WAAW;GACxB,cAAc,WAAW;GACzB,UAAU,WAAW;GACtB,CACF,CAAC,CACH;EACD,OAAO,SAAS;EACjB,EAAE;;;;;AAML,SAAgB,yBACd,WACA,QAC6C;CAC7C,MAAM,cAAc,IAAI,IACtB,UAAU,KAAK,aAAa,CAAC,SAAS,MAAM,SAAS,CAAU,CAChE;AAED,QAAO,OAAO,SAAS;EACrB,MAAM,WAAW,YAAY,IAAI,KAAK,aAAa;EACnD,MAAM,aAAa,UAAU,MAAM,KAAK;AAExC,MAAI,CAAC,YAAY,CAAC,WAChB,QAAO;GACL,OAAO;IACL,MAAM;IACN,SAAS,gBAAgB,KAAK,aAAa,GAAG,KAAK;IACpD;GACD,IAAI;GACL;AAGH,MAAI;AACF,OAAI,OAAO,QACT,QAAO;IACL,OAAO;KACL,MAAM;KACN,SAAS,4BAA4B;KACtC;IACD,IAAI;IACL;GAGH,MAAM,SAAS,MAAM,WAAW,QAC9B,KAAK,OACL,uBACE,QACA,SAAS,MACT,WAAW,UACX,WAAW,aACZ,CACF;AAED,OAAI,WAAW,UAAa,CAAC,mBAAmB,OAAO,CACrD,OAAM,IAAI,eACR,uBACA,sCACD;AAGH,UAAO;IACL,IAAI;IACJ;IACD;WACM,OAAO;AACd,UAAO;IACL,OAAO,sBAAsB,MAAM;IACnC,IAAI;IACL;;;;;;;;;;ACpJP,IAAa,kBAAb,MAAiD;CAC/C,AAAiB;;;;CAKjB,YAAY,UAAkC,EAAE,EAAE;AAChD,OAAK,UAAU;;;;;CAMjB,MAAM,QACJ,MACA,WACA,UAA4B,EAAE,EACN;AACxB,MAAI,QAAQ,QAAQ,QAClB,QAAO,4BAA4B;EAGrC,MAAM,kBAAkB,IAAI,iBAAiB;EAC7C,MAAM,aAAa,yBACjB,WACA,gBAAgB,OACjB;EACD,MAAM,gBAAgB;AACpB,mBAAgB,OAAO;;AAGzB,UAAQ,QAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,MAAM,CAAC;AAElE,MAAI;AACF,UAAO,MAAM,kBACX;IACE;IACA;IACA;IACA,WAAW,yBAAyB,UAAU;IAC/C,EACD;IACE,GAAG,KAAK;IACR,GAAG;IACJ,CACF;YACO;AACR,WAAQ,QAAQ,oBAAoB,SAAS,QAAQ;AACrD,mBAAgB,OAAO"}
|
package/dist/runner/index.cjs
CHANGED
package/dist/runner/index.d.cts
CHANGED
|
@@ -1,81 +1,13 @@
|
|
|
1
|
-
import { t as QuickJsExecutorOptions } from "../types-BB8mb_-T.cjs";
|
|
2
|
-
|
|
3
|
-
//#region ../core/src/types.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Stable error codes returned by executors and wrapped tool calls.
|
|
7
|
-
*/
|
|
8
|
-
type ExecuteErrorCode = "timeout" | "memory_limit" | "validation_error" | "tool_error" | "runtime_error" | "serialization_error" | "internal_error";
|
|
9
|
-
/**
|
|
10
|
-
* Structured execution failure returned in {@link ExecuteResult}.
|
|
11
|
-
*/
|
|
12
|
-
interface ExecuteError {
|
|
13
|
-
/** Machine-readable error category. */
|
|
14
|
-
code: ExecuteErrorCode;
|
|
15
|
-
/** Human-readable failure message. */
|
|
16
|
-
message: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Structured result returned by every executor invocation.
|
|
20
|
-
*/
|
|
21
|
-
type ExecuteResult<T = unknown> = {
|
|
22
|
-
durationMs: number;
|
|
23
|
-
logs: string[];
|
|
24
|
-
ok: true;
|
|
25
|
-
result: T;
|
|
26
|
-
} | {
|
|
27
|
-
durationMs: number;
|
|
28
|
-
error: ExecuteError;
|
|
29
|
-
logs: string[];
|
|
30
|
-
ok: false;
|
|
31
|
-
};
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region ../core/src/runner.d.ts
|
|
34
|
-
/**
|
|
35
|
-
* Transport-safe metadata for one exposed tool.
|
|
36
|
-
*/
|
|
37
|
-
interface ProviderToolManifest {
|
|
38
|
-
description?: string;
|
|
39
|
-
originalName: string;
|
|
40
|
-
safeName: string;
|
|
41
|
-
}
|
|
42
1
|
/**
|
|
43
|
-
*
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Public TypeScript declarations for this package entrypoint.
|
|
44
4
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Execution limits forwarded to runner implementations.
|
|
52
|
-
*/
|
|
53
|
-
interface ExecutorRuntimeOptions {
|
|
54
|
-
maxLogChars?: number;
|
|
55
|
-
maxLogLines?: number;
|
|
56
|
-
memoryLimitBytes?: number;
|
|
57
|
-
timeoutMs?: number;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Tool invocation request emitted from a runner.
|
|
61
|
-
*/
|
|
62
|
-
interface ToolCall {
|
|
63
|
-
input: unknown;
|
|
64
|
-
providerName: string;
|
|
65
|
-
safeToolName: string;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Trusted host response to a tool invocation request.
|
|
69
|
-
*/
|
|
70
|
-
type ToolCallResult = {
|
|
71
|
-
ok: true;
|
|
72
|
-
result: unknown;
|
|
73
|
-
} | {
|
|
74
|
-
error: ExecuteError;
|
|
75
|
-
ok: false;
|
|
76
|
-
};
|
|
77
|
-
//#endregion
|
|
5
|
+
import { t as QuickJsExecutorOptions } from "../types-CVE2n2LY.cjs";
|
|
6
|
+
import { ExecuteResult, ExecutorRuntimeOptions, ProviderManifest, ToolCall, ToolCallResult } from "@execbox/core";
|
|
7
|
+
import { QuickJSWASMModule } from "quickjs-emscripten";
|
|
8
|
+
|
|
78
9
|
//#region src/runner/index.d.ts
|
|
10
|
+
|
|
79
11
|
/**
|
|
80
12
|
* Transport-neutral host tool call emitted from a QuickJS session.
|
|
81
13
|
*/
|
|
@@ -94,11 +26,13 @@ interface QuickJsSessionRequest {
|
|
|
94
26
|
/**
|
|
95
27
|
* Options controlling one transport-backed QuickJS session.
|
|
96
28
|
*/
|
|
97
|
-
type QuickJsSessionOptions = QuickJsExecutorOptions & ExecutorRuntimeOptions
|
|
29
|
+
type QuickJsSessionOptions = QuickJsExecutorOptions & ExecutorRuntimeOptions & {
|
|
30
|
+
module?: QuickJSWASMModule;
|
|
31
|
+
};
|
|
98
32
|
/**
|
|
99
33
|
* Runs one QuickJS-backed execution session using a transport-neutral tool callback.
|
|
100
34
|
*/
|
|
101
35
|
declare function runQuickJsSession(request: QuickJsSessionRequest, options?: QuickJsSessionOptions): Promise<ExecuteResult>;
|
|
102
36
|
//#endregion
|
|
103
|
-
export { QuickJsSessionOptions, QuickJsSessionRequest, QuickJsSessionToolCall, runQuickJsSession };
|
|
37
|
+
export { type QuickJsExecutorOptions, QuickJsSessionOptions, QuickJsSessionRequest, QuickJsSessionToolCall, runQuickJsSession };
|
|
104
38
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/runner/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AA0DA,CAAA,CAAA,CAAA,SAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,IAAA,CAAA,OAAA,CAAA,IAAA,CAAA,CAAA,CAAA,OAAA,CAAA,OAAA;AAKA,CAAA,CAAA;AACoB,IAAA,CANR,sBAAA,CAAA,CAAA,CAAyB,QAMjB;;;;AAEwC,SAAA,CAH3C,qBAAA,CAG2C;EAE/C,eAAA,CAAA,CAAA,CAJO,eAIP;EACF,IAAA,CAAA,CAAA,MAAA;EAAW,UAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAHD,QAGC,CAAA,CAAA,CAAA,CAAA,CAHY,OAGZ,CAHoB,cAGpB,CAAA,CAAA,CAAA,CAHsC,cAGtC;EAMV,SAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAA;EAAwB,SAAA,CAAA,CAPvB,gBAOuB,CAAA,CAAA;EAClC,MAAA,CAAA,CAAA,CAPS,WAOT;;;AA6TF,CAAA,CAAA,CAAA,OAAA,CAAA,WAAA,CAAA,GAAA,CAAA,SAAA,CAAA,MAAA,CAAA,OAAA,CAAA,OAAA;;AAEW,IAAA,CAhUC,qBAAA,CAAA,CAAA,CAAwB,sBAgUzB,CAAA,CAAA,CA/TT,sBA+TS,CAAA,CAAA,CAAA;EACA,MAAA,CAAA,CAAA,CA/TE,iBA+TF;CAAR;;;;iBAHmB,iBAAA,UACX,iCACA,wBACR,QAAQ"}
|
package/dist/runner/index.d.ts
CHANGED
|
@@ -1,81 +1,13 @@
|
|
|
1
|
-
import { t as QuickJsExecutorOptions } from "../types-D7uau0GM.js";
|
|
2
|
-
|
|
3
|
-
//#region ../core/src/types.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Stable error codes returned by executors and wrapped tool calls.
|
|
7
|
-
*/
|
|
8
|
-
type ExecuteErrorCode = "timeout" | "memory_limit" | "validation_error" | "tool_error" | "runtime_error" | "serialization_error" | "internal_error";
|
|
9
|
-
/**
|
|
10
|
-
* Structured execution failure returned in {@link ExecuteResult}.
|
|
11
|
-
*/
|
|
12
|
-
interface ExecuteError {
|
|
13
|
-
/** Machine-readable error category. */
|
|
14
|
-
code: ExecuteErrorCode;
|
|
15
|
-
/** Human-readable failure message. */
|
|
16
|
-
message: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Structured result returned by every executor invocation.
|
|
20
|
-
*/
|
|
21
|
-
type ExecuteResult<T = unknown> = {
|
|
22
|
-
durationMs: number;
|
|
23
|
-
logs: string[];
|
|
24
|
-
ok: true;
|
|
25
|
-
result: T;
|
|
26
|
-
} | {
|
|
27
|
-
durationMs: number;
|
|
28
|
-
error: ExecuteError;
|
|
29
|
-
logs: string[];
|
|
30
|
-
ok: false;
|
|
31
|
-
};
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region ../core/src/runner.d.ts
|
|
34
|
-
/**
|
|
35
|
-
* Transport-safe metadata for one exposed tool.
|
|
36
|
-
*/
|
|
37
|
-
interface ProviderToolManifest {
|
|
38
|
-
description?: string;
|
|
39
|
-
originalName: string;
|
|
40
|
-
safeName: string;
|
|
41
|
-
}
|
|
42
1
|
/**
|
|
43
|
-
*
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Public TypeScript declarations for this package entrypoint.
|
|
44
4
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Execution limits forwarded to runner implementations.
|
|
52
|
-
*/
|
|
53
|
-
interface ExecutorRuntimeOptions {
|
|
54
|
-
maxLogChars?: number;
|
|
55
|
-
maxLogLines?: number;
|
|
56
|
-
memoryLimitBytes?: number;
|
|
57
|
-
timeoutMs?: number;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Tool invocation request emitted from a runner.
|
|
61
|
-
*/
|
|
62
|
-
interface ToolCall {
|
|
63
|
-
input: unknown;
|
|
64
|
-
providerName: string;
|
|
65
|
-
safeToolName: string;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Trusted host response to a tool invocation request.
|
|
69
|
-
*/
|
|
70
|
-
type ToolCallResult = {
|
|
71
|
-
ok: true;
|
|
72
|
-
result: unknown;
|
|
73
|
-
} | {
|
|
74
|
-
error: ExecuteError;
|
|
75
|
-
ok: false;
|
|
76
|
-
};
|
|
77
|
-
//#endregion
|
|
5
|
+
import { t as QuickJsExecutorOptions } from "../types-BXi8Lqtk.js";
|
|
6
|
+
import { QuickJSWASMModule } from "quickjs-emscripten";
|
|
7
|
+
import { ExecuteResult, ExecutorRuntimeOptions, ProviderManifest, ToolCall, ToolCallResult } from "@execbox/core";
|
|
8
|
+
|
|
78
9
|
//#region src/runner/index.d.ts
|
|
10
|
+
|
|
79
11
|
/**
|
|
80
12
|
* Transport-neutral host tool call emitted from a QuickJS session.
|
|
81
13
|
*/
|
|
@@ -94,11 +26,13 @@ interface QuickJsSessionRequest {
|
|
|
94
26
|
/**
|
|
95
27
|
* Options controlling one transport-backed QuickJS session.
|
|
96
28
|
*/
|
|
97
|
-
type QuickJsSessionOptions = QuickJsExecutorOptions & ExecutorRuntimeOptions
|
|
29
|
+
type QuickJsSessionOptions = QuickJsExecutorOptions & ExecutorRuntimeOptions & {
|
|
30
|
+
module?: QuickJSWASMModule;
|
|
31
|
+
};
|
|
98
32
|
/**
|
|
99
33
|
* Runs one QuickJS-backed execution session using a transport-neutral tool callback.
|
|
100
34
|
*/
|
|
101
35
|
declare function runQuickJsSession(request: QuickJsSessionRequest, options?: QuickJsSessionOptions): Promise<ExecuteResult>;
|
|
102
36
|
//#endregion
|
|
103
|
-
export { QuickJsSessionOptions, QuickJsSessionRequest, QuickJsSessionToolCall, runQuickJsSession };
|
|
37
|
+
export { type QuickJsExecutorOptions, QuickJsSessionOptions, QuickJsSessionRequest, QuickJsSessionToolCall, runQuickJsSession };
|
|
104
38
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/runner/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AA0DA,CAAA,CAAA,CAAA,SAAA,CAAA,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,IAAA,CAAA,OAAA,CAAA,IAAA,CAAA,CAAA,CAAA,OAAA,CAAA,OAAA;AAKA,CAAA,CAAA;AACoB,IAAA,CANR,sBAAA,CAAA,CAAA,CAAyB,QAMjB;;;;AAEwC,SAAA,CAH3C,qBAAA,CAG2C;EAE/C,eAAA,CAAA,CAAA,CAJO,eAIP;EACF,IAAA,CAAA,CAAA,MAAA;EAAW,UAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAHD,QAGC,CAAA,CAAA,CAAA,CAAA,CAHY,OAGZ,CAHoB,cAGpB,CAAA,CAAA,CAAA,CAHsC,cAGtC;EAMV,SAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAA;EAAwB,SAAA,CAAA,CAPvB,gBAOuB,CAAA,CAAA;EAClC,MAAA,CAAA,CAAA,CAPS,WAOT;;;AA6TF,CAAA,CAAA,CAAA,OAAA,CAAA,WAAA,CAAA,GAAA,CAAA,SAAA,CAAA,MAAA,CAAA,OAAA,CAAA,OAAA;;AAEW,IAAA,CAhUC,qBAAA,CAAA,CAAA,CAAwB,sBAgUzB,CAAA,CAAA,CA/TT,sBA+TS,CAAA,CAAA,CAAA;EACA,MAAA,CAAA,CAAA,CA/TE,iBA+TF;CAAR;;;;iBAHmB,iBAAA,UACX,iCACA,wBACR,QAAQ"}
|
package/dist/runner/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_runner = require('../runner-
|
|
1
|
+
const require_runner = require('../runner-BqkDnP0t.cjs');
|
|
2
2
|
let node_crypto = require("node:crypto");
|
|
3
3
|
|
|
4
4
|
//#region ../protocol/src/messages.ts
|
|
@@ -39,6 +39,10 @@ function isDispatcherMessage(value) {
|
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/runner/protocolEndpoint.ts
|
|
41
41
|
/**
|
|
42
|
+
* @packageDocumentation
|
|
43
|
+
* Public API for the `@execbox/quickjs/runner/protocol-endpoint` entrypoint.
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
42
46
|
* Attaches the shared QuickJS protocol loop to a worker/process messaging port.
|
|
43
47
|
*/
|
|
44
48
|
function attachQuickJsProtocolEndpoint(port) {
|