Interface SandboxedToolSpec

Implementation specification for a tool whose logic is arbitrary code executed in a memory/time-bounded sandbox.

The sandboxed function signature must be:

async function run(input: unknown): Promise<unknown>

The engine calls run(input) and returns its resolved value as the tool output.

interface SandboxedToolSpec {
    mode: "sandbox";
    code: string;
    allowlist: SandboxAPI[];
}

Properties

Properties

mode: "sandbox"

Discriminant: always 'sandbox' for sandboxed specs.

code: string

The full source code of the sandboxed module. Must export or define an async run function as its entry point.

Example

async function run(input) {
const res = await fetch(`https://api.example.com?q=${input.query}`);
return res.json();
}
allowlist: SandboxAPI[]

Explicit allowlist of sandbox APIs the code may invoke. Any call to an API not in this list will throw at runtime.