Prerequisites
- Node.js 22 or later
- npm, pnpm, or yarn
Step 1: Install Packages
Step 2: Create Your First Sandbox
Create a new filesandbox.ts:
Step 3: Run It
What Just Happened?
-
AST Validation - Before executing, Enclave validated the code using ast-guard to block dangerous constructs like
eval,process, and prototype manipulation. - Code Transformation - The code was wrapped in a safe execution context with rate-limited loops and proxied tool calls.
- Sandboxed Execution - The code ran in an isolated Node.js vm context with no access to the host environment.
- Tool Calls - The script called your tools through a controlled interface, letting you audit and control all external interactions.
Security Levels
Enclave provides preset security levels. The most common:| Level | Use Case | Restrictions |
|---|---|---|
STRICT | Untrusted AI/user code | Maximum restrictions |
SECURE | Semi-trusted automation | Balanced security |
STANDARD | Internal tools | Basic guardrails |
What’s Blocked?
AgentScript (the language subset Enclave uses) blocks:eval,Function,setTimeout,setIntervalprocess,require,importwindow,global,globalThis__proto__,constructor,prototype- User-defined functions (prevents recursion bombs)
whileanddo-whileloops (prevents infinite loops)
Next Steps
Concepts
Understand the architecture and security model
@enclave-vm/core
Deep dive into configuration and features
Guides
Build a complete AI agent with tools
Examples
Copy-paste examples for common use cases