Skip to main content
The simplest possible Enclave example - execute code and get results.

Basic Example

With TypeScript

With Console Output

A script may use console when the enclave has a consoleHandler. The handler receives each call as (level, message); the result does not carry the output.
Without a consoleHandler, console is available only at the PERMISSIVE security level; at the other levels a script that uses it fails validation.

With Variables

Pass data into the execution:

With Tool Calls

Execute code that calls tools:

Error Handling

run() does not reject for a failing script: the failure is in the result. error.message and error.name are plain strings, and an error made inside the sandbox has no stack. AgentScript has no Error constructor; a script signals a failure by returning a value that says so, or by letting a tool’s error pass.

Complete Example

Expected Output

Next Steps