@johnhenry/aimatey-tool-protocols 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/dist/cjs/andbox-executor.js +171 -0
- package/dist/cjs/andbox-executor.js.map +1 -0
- package/dist/cjs/auto.js +34 -0
- package/dist/cjs/auto.js.map +1 -0
- package/dist/cjs/code-api.js +166 -0
- package/dist/cjs/code-api.js.map +1 -0
- package/dist/cjs/code.js +162 -0
- package/dist/cjs/code.js.map +1 -0
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/text.js +310 -0
- package/dist/cjs/text.js.map +1 -0
- package/dist/esm/andbox-executor.js +133 -0
- package/dist/esm/andbox-executor.js.map +1 -0
- package/dist/esm/auto.js +30 -0
- package/dist/esm/auto.js.map +1 -0
- package/dist/esm/code-api.js +160 -0
- package/dist/esm/code-api.js.map +1 -0
- package/dist/esm/code.js +151 -0
- package/dist/esm/code.js.map +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/text.js +307 -0
- package/dist/esm/text.js.map +1 -0
- package/dist/types/andbox-executor.d.ts +33 -0
- package/dist/types/andbox-executor.d.ts.map +1 -0
- package/dist/types/auto.d.ts +18 -0
- package/dist/types/auto.d.ts.map +1 -0
- package/dist/types/code-api.d.ts +28 -0
- package/dist/types/code-api.d.ts.map +1 -0
- package/dist/types/code.d.ts +77 -0
- package/dist/types/code.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/text.d.ts +25 -0
- package/dist/types/text.d.ts.map +1 -0
- package/package.json +77 -4
- package/readme.md +83 -0
- package/README.md +0 -3
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `code` tool protocol: the model writes JavaScript against a generated
|
|
3
|
+
* `tools.*` API; a {@link CodeExecutor} runs it and every tool call inside
|
|
4
|
+
* goes back through the loop's `invoke` (validation, gate, execute).
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import type { ToolDefinition, ToolProtocol } from '@johnhenry/aimatey-types';
|
|
9
|
+
export { generateToolsInterface, schemaToTs, buildCodePrompt, buildLegacyCodePrompt, } from './code-api.js';
|
|
10
|
+
export { andboxExecutor, type AndboxExecutorOptions } from './andbox-executor.js';
|
|
11
|
+
/** Resource limits for one snippet. Executors apply what they support. */
|
|
12
|
+
export interface CodeLimits {
|
|
13
|
+
/** Deterministic instruction budget. */
|
|
14
|
+
fuel?: number;
|
|
15
|
+
/** Guest heap cap in bytes. */
|
|
16
|
+
memoryBytes?: number;
|
|
17
|
+
/** Guest call-stack cap in bytes. */
|
|
18
|
+
stackBytes?: number;
|
|
19
|
+
/** Wall-clock deadline for the snippet, including tool time. */
|
|
20
|
+
deadlineMs?: number;
|
|
21
|
+
/** Maximum tool calls one snippet may make. */
|
|
22
|
+
maxToolCalls?: number;
|
|
23
|
+
}
|
|
24
|
+
/** What an executor gets for one snippet. */
|
|
25
|
+
export interface CodeRunOptions {
|
|
26
|
+
/** Run a tool through the host. Rejects (throws in the guest) when the call fails or is denied. */
|
|
27
|
+
callTool(name: string, input: unknown): Promise<unknown>;
|
|
28
|
+
/** Names of the tools to expose as `tools.<name>`. */
|
|
29
|
+
toolNames: string[];
|
|
30
|
+
limits?: CodeLimits;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
}
|
|
33
|
+
/** Outcome of running one snippet. */
|
|
34
|
+
export interface CodeRunResult {
|
|
35
|
+
/** Lines the snippet printed with `console.*`. */
|
|
36
|
+
logs: string[];
|
|
37
|
+
/** The value the snippet returned (JSON-safe), if any. */
|
|
38
|
+
result?: unknown;
|
|
39
|
+
/** Set when the snippet called `final(answer)`. */
|
|
40
|
+
final?: {
|
|
41
|
+
answer: unknown;
|
|
42
|
+
};
|
|
43
|
+
error?: {
|
|
44
|
+
name: string;
|
|
45
|
+
message: string;
|
|
46
|
+
code?: string;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Runs model-written JavaScript. The interface has no sandbox dependency;
|
|
51
|
+
* `andboxExecutor()` is the bundled implementation. Implementations must
|
|
52
|
+
* expose `tools.<name>(input)`, `console.*` and `final(answer)` to the code.
|
|
53
|
+
*/
|
|
54
|
+
export interface CodeExecutor {
|
|
55
|
+
run(code: string, options: CodeRunOptions): Promise<CodeRunResult>;
|
|
56
|
+
}
|
|
57
|
+
export interface CodeProtocolOptions {
|
|
58
|
+
executor: CodeExecutor;
|
|
59
|
+
/** Truncate the feedback message to this many characters. @default 4000 */
|
|
60
|
+
maxLogChars?: number;
|
|
61
|
+
limits?: CodeLimits;
|
|
62
|
+
/**
|
|
63
|
+
* Build the system prompt from the tools. Defaults to {@link buildCodePrompt} (v2).
|
|
64
|
+
* Pass `buildLegacyCodePrompt` to reproduce the original prompt.
|
|
65
|
+
*/
|
|
66
|
+
systemPrompt?: (tools: Readonly<Record<string, ToolDefinition>>) => string;
|
|
67
|
+
}
|
|
68
|
+
/** First js/javascript/ts fenced block (or an untagged one); tolerates a missing closing fence. */
|
|
69
|
+
export declare function extractCodeBlock(text: string): string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Create the `code` protocol. The model writes JavaScript instead of
|
|
72
|
+
* emitting tool calls; tools are not sent in `request.tools`.
|
|
73
|
+
*/
|
|
74
|
+
export declare function codeProtocol(options: CodeProtocolOptions): ToolProtocol;
|
|
75
|
+
/** Register the `code` protocol so `runTools({ protocol: 'code' })` resolves it. */
|
|
76
|
+
export declare function registerCodeProtocol(executor: CodeExecutor, options?: Omit<CodeProtocolOptions, 'executor'>): ToolProtocol;
|
|
77
|
+
//# sourceMappingURL=code.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../src/code.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAIV,cAAc,EACd,YAAY,EAKb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,sBAAsB,EACtB,UAAU,EACV,eAAe,EACf,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAElF,0EAA0E;AAC1E,MAAM,WAAW,UAAU;IACzB,wCAAwC;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,6CAA6C;AAC7C,MAAM,WAAW,cAAc;IAC7B,mGAAmG;IACnG,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACzD,sDAAsD;IACtD,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,kDAAkD;IAClD,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,0DAA0D;IAC1D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,mDAAmD;IACnD,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;IAC5B,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1D;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CACpE;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,CAAC;IACvB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,KAAK,MAAM,CAAC;CAC5E;AAID,mGAAmG;AACnG,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CASjE;AA+BD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAoGvE;AAED,oFAAoF;AACpF,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,YAAY,EACtB,OAAO,GAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAM,GAClD,YAAY,CAId"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `text` tool protocol: tool calling for models with no native tool
|
|
3
|
+
* support. Tools are described in a system message; the model replies with a
|
|
4
|
+
* fenced JSON action block, or a plain-text final answer.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import type { ToolProtocol } from '@johnhenry/aimatey-types';
|
|
9
|
+
/** Options for {@link textProtocol}. */
|
|
10
|
+
export interface TextProtocolOptions {
|
|
11
|
+
/** Extra instructions appended to the generated system prompt. */
|
|
12
|
+
readonly instructions?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Tool calling through plain text. Works with any model, including ones with
|
|
16
|
+
* no native tool support.
|
|
17
|
+
*
|
|
18
|
+
* The model is told to reply with one fenced JSON block
|
|
19
|
+
* (`{"tool": "name", "args": {...}}`, or an array when parallel calls are
|
|
20
|
+
* allowed) to call a tool, or with plain text to answer. A reply that tries
|
|
21
|
+
* to call a tool but cannot be read is fed back as an error and uses up an
|
|
22
|
+
* iteration.
|
|
23
|
+
*/
|
|
24
|
+
export declare function textProtocol(options?: TextProtocolOptions): ToolProtocol;
|
|
25
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/text.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAKV,YAAY,EAKb,MAAM,0BAA0B,CAAC;AAElC,wCAAwC;AACxC,MAAM,WAAW,mBAAmB;IAClC,kEAAkE;IAClE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AA+PD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,YAAY,CAiE5E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,79 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnhenry/aimatey-tool-protocols",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Tool-calling protocols for Aimatey runTools: text (models without native tools) and code (sandboxed JavaScript actions)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/cjs/index.js",
|
|
7
|
+
"module": "./dist/esm/index.js",
|
|
8
|
+
"types": "./dist/types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/types/index.d.ts",
|
|
13
|
+
"default": "./dist/esm/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/types/index.d.ts",
|
|
17
|
+
"default": "./dist/cjs/index.js"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"readme.md",
|
|
24
|
+
"CHANGELOG.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "npm run build:esm && npm run build:cjs && npm run build:types",
|
|
29
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
30
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
31
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
32
|
+
"clean": "rm -rf dist",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"lint": "eslint src --ext .ts",
|
|
35
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"test:watch": "vitest"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@johnhenry/aimatey-types": "^0.10.0",
|
|
41
|
+
"@johnhenry/aimatey-utils": "^0.6.4"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"typescript": "^5.9.3",
|
|
45
|
+
"vitest": "^3.2.4",
|
|
46
|
+
"@johnhenry/aimatey-core": "^0.8.0"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"ai",
|
|
50
|
+
"llm",
|
|
51
|
+
"tool-calling",
|
|
52
|
+
"code-mode",
|
|
53
|
+
"sandbox",
|
|
54
|
+
"ai-matey"
|
|
55
|
+
],
|
|
56
|
+
"author": "Aimatey",
|
|
57
|
+
"license": "MIT",
|
|
58
|
+
"homepage": "https://github.com/johnhenry/aimatey#readme",
|
|
59
|
+
"bugs": {
|
|
60
|
+
"url": "https://github.com/johnhenry/aimatey/issues"
|
|
61
|
+
},
|
|
62
|
+
"repository": {
|
|
63
|
+
"type": "git",
|
|
64
|
+
"url": "git+https://github.com/johnhenry/aimatey.git",
|
|
65
|
+
"directory": "packages/tool-protocols"
|
|
66
|
+
},
|
|
67
|
+
"engines": {
|
|
68
|
+
"node": ">=26.0.0"
|
|
69
|
+
},
|
|
70
|
+
"peerDependencies": {
|
|
71
|
+
"@johnhenry/aimatey-core": ">=0.7.0",
|
|
72
|
+
"@johnhenry/andbox": ">=0.0.8"
|
|
73
|
+
},
|
|
74
|
+
"peerDependenciesMeta": {
|
|
75
|
+
"@johnhenry/andbox": {
|
|
76
|
+
"optional": true
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# @johnhenry/aimatey-tool-protocols
|
|
2
|
+
|
|
3
|
+
Tool-calling protocols for `bridge.runTools()`: `text` (models without native tool support) and `code` (sandboxed JavaScript actions). Work in progress; see johnhenry/aimatey#237.
|
|
4
|
+
|
|
5
|
+
## text and auto
|
|
6
|
+
|
|
7
|
+
`text` lets models with no native tool support use `bridge.runTools()`. Tools are described (name, description, JSON schema) in a system message; the model replies with one fenced JSON block to call a tool, or plain text to answer.
|
|
8
|
+
|
|
9
|
+
````ts
|
|
10
|
+
import { textProtocol, autoProtocol } from '@johnhenry/aimatey-tool-protocols';
|
|
11
|
+
|
|
12
|
+
await bridge.runTools({ prompt, tools, protocol: textProtocol() });
|
|
13
|
+
````
|
|
14
|
+
|
|
15
|
+
The model is asked to reply with:
|
|
16
|
+
|
|
17
|
+
````
|
|
18
|
+
```json
|
|
19
|
+
{"tool": "get_weather", "args": {"city": "Paris"}}
|
|
20
|
+
```
|
|
21
|
+
````
|
|
22
|
+
|
|
23
|
+
(an array of such objects when `parallelToolCalls` is on). Parsing is tolerant: prose around the block, a missing fence and trailing commas are accepted. A reply that clearly tried to call a tool but cannot be read (invalid JSON, no `tool` key) is sent back to the model as an error and uses up an iteration. Unknown tools and invalid arguments come back as error results. Every call goes through the same validation, `gate` and `execute` path as native calls. Results return as a user message: `Tool result for add (text-1-0): 5`.
|
|
24
|
+
|
|
25
|
+
`autoProtocol()` uses native tool calling when the backend advertises it and `text` otherwise; an unknown capability counts as native.
|
|
26
|
+
|
|
27
|
+
To select by name (`protocol: 'text'` or `'auto'`), register them once:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { registerTextProtocols } from '@johnhenry/aimatey-tool-protocols';
|
|
31
|
+
registerTextProtocols();
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`runMcpTools` accepts `protocol` too, so MCP tools work on any model.
|
|
35
|
+
|
|
36
|
+
## `code` protocol: sandboxed JavaScript actions
|
|
37
|
+
|
|
38
|
+
The model writes one JavaScript snippet instead of emitting tool calls. The snippet calls your tools as `await tools.name({...})`, prints with `console.log`, and finishes with `return` or `final(answer)`. A reply with no code block is the final answer.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { codeProtocol, andboxExecutor } from '@johnhenry/aimatey-tool-protocols';
|
|
42
|
+
|
|
43
|
+
const result = await bridge.runTools({
|
|
44
|
+
prompt: 'Which of these cities is warmest?',
|
|
45
|
+
tools, // the same ToolDefinition record you use with native calling
|
|
46
|
+
protocol: codeProtocol({
|
|
47
|
+
executor: andboxExecutor(),
|
|
48
|
+
limits: { fuel: 20_000, memoryBytes: 32 * 1024 * 1024, deadlineMs: 10_000, maxToolCalls: 50 },
|
|
49
|
+
maxLogChars: 4000,
|
|
50
|
+
}),
|
|
51
|
+
gate, // sees every call the snippet makes
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`registerCodeProtocol(executor)` registers it so `protocol: 'code'` works. Install the optional peer and its pinned engine (andbox is never a dependency of this package):
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
npm install @johnhenry/andbox
|
|
59
|
+
npm install --save-exact quickjs-emscripten-core@0.32.0 @jitl/quickjs-ng-wasmfile-release-sync@0.32.0
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Without them `andboxExecutor()` fails on first use with andbox's `ERR_ANDBOX_ENGINE_MISSING` / an install message. Bring your own sandbox by implementing `CodeExecutor` (`run(code, { callTool, toolNames, limits, signal }) => { logs, result, final, error }`); the interface has no sandbox dependency.
|
|
63
|
+
|
|
64
|
+
### What the loop guarantees
|
|
65
|
+
|
|
66
|
+
- Every `tools.name(...)` call goes through `ctx.invoke`: unknown-tool check, argument validation, your `gate`, then `execute`. Denials and validation errors throw inside the snippet (catchable with `try/catch`), and denials count toward `maxDenials`.
|
|
67
|
+
- Calls made by a snippet appear in `RunToolsStep.toolCalls` with ids `code-<iteration>-<n>`. (If a snippet calls `final(answer)`, the loop ends with a `final` outcome, which carries no call list; the gate and `denials` still saw every call.)
|
|
68
|
+
- Snippet errors (syntax, thrown, fuel, memory, deadline) go back to the model as a readable message and use up an iteration. Output is truncated to `maxLogChars` with a `[truncated N chars]` marker.
|
|
69
|
+
- A fresh sandbox per snippet: nothing persists between steps.
|
|
70
|
+
|
|
71
|
+
### Security model (read this)
|
|
72
|
+
|
|
73
|
+
`andboxExecutor` uses andbox's `mode: 'wasm'` only. The snippet runs in QuickJS-ng compiled to WebAssembly, inside a worker thread (Node) or Worker (browser). The engine has no `fetch`, timers, `process`, `require` or imports; its only way out is the tool bridge. Fuel, memory, stack and a wall-clock deadline are enforced, so an infinite loop or allocation bomb ends the snippet and the loop carries on.
|
|
74
|
+
|
|
75
|
+
What it does not give you:
|
|
76
|
+
|
|
77
|
+
- It is not a containment guarantee against engine bugs. A bug in QuickJS or the host's WebAssembly engine is outside this package's control, and a worker thread shares the process. For hostile code on a server add OS-level isolation. See andbox's [threat model by mode](https://github.com/johnhenry/andbox#threat-model-by-mode).
|
|
78
|
+
- The tools are the whole attack surface. A tool that reads any path or fetches any URL is an escape hatch; validate arguments in the tool and use `gate`.
|
|
79
|
+
- Arguments and results cross the boundary as JSON: no `Map`, `Set`, `Date`, typed arrays; `bigint` becomes a string, cycles become `"[Circular]"`, `undefined` becomes `null`. Tool results are converted this way automatically rather than failing.
|
|
80
|
+
- Time is still observable (`Date.now()`), and fuel/memory/deadline bound one snippet, not how many the model writes (`maxIterations` does that).
|
|
81
|
+
- Treat the snippet's return value as untrusted model-influenced input.
|
|
82
|
+
- Browsers need the engine module and `.wasm` served by your app (pass `sandboxOptions: { engineURL, wasmURL }`); see andbox's "Installing the engine".
|
|
83
|
+
- Each snippet creates a new worker and QuickJS runtime; expect about 100 ms of fixed overhead per snippet on a typical Linux box.
|
package/README.md
DELETED