Basic Usage
Transformation Output
Transformation Options
Main Wrapper
The main wrapper enables top-level await and provides an entry point:__ag_main() to execute the script.
Safe callTool
ThecallTool transformation proxies all tool calls through the runtime:
__safe_callTool proxy:
- Counts tool calls against
maxToolCallslimit - Routes calls through the configured
toolHandler - Sanitizes arguments and return values
Safe Loops
Loop transformations enforce iteration limits:Safe Console
Console methods are proxied for rate limiting:__safe_console proxy:
- Counts calls against
maxConsoleCalls - Tracks output bytes against
maxConsoleOutputBytes - Captures output for streaming to clients
Reserved Prefixes
The transformation reserves these prefixes that user code cannot use:__ag_- AgentScript internal identifiers__safe_- Safe runtime proxies
ReservedPrefixRule.
Custom Transformation
For advanced use cases, you can customize transformations:Integration with enclave-vm
enclave-vm automatically applies transformations whentransform: true (default):
Transformation Without Validation
You can transform code independently of validation:Related
- Overview - Getting started
- AgentScript Preset - Preset configuration
- enclave-vm - Runtime sandbox