What You’ll Build
An AI agent that:- Accepts natural language requests
- Generates JavaScript orchestration code via LLM
- Executes the code safely in Enclave
- Returns structured results
Prerequisites
- Node.js 18+
- An OpenAI API key (or other LLM provider)
- Basic TypeScript knowledge
Step 1: Project Setup
Step 2: Define Your Tools
Tools are the capabilities your agent exposes. Start with a simple set:Step 3: Create the LLM Prompt
Build a prompt that instructs the LLM to generate AgentScript-compatible code:Step 4: Set Up the Enclave
Configure the secure execution environment:Step 5: Build the Agent
Combine LLM code generation with Enclave execution:Step 6: Test Your Agent
Step 7: Add Error Handling
Make your agent more robust:Step 8: Add Streaming (Optional)
For real-time output, use EnclaveJS:Best Practices
- Validate tools - Check tool arguments before execution
- Log everything - Tool calls, durations, results for debugging
- Set limits - Always configure timeout, maxToolCalls, maxIterations
- Handle retries - LLM-generated code may need refinement
- Sandbox per request - Create a new Enclave for each execution
Next Steps
- Tool Integration - Connect real APIs
- Production Deployment - Deploy to production
- Security Hardening - Secure your agent
Related
- Quickstart - Basic setup
- Tool System - Deep dive on tools
- AgentScript - Language specification