Skip to main content
The Babel preset extends the AgentScript preset to enable secure TSX/JSX transformation inside the enclave. It adds the Babel global while maintaining all AgentScript security guarantees.

Overview

The Babel preset provides:
  • Babel.transform() - Transform TSX/JSX to JavaScript
  • Security configs - Per-level limits for input size, output size, timeouts
  • Preset whitelist - Only allowed Babel presets can be used
  • Full AgentScript validation - All blocked constructs remain blocked

Basic Usage

Security Configurations

The Babel preset defines security limits per security level:

Configuration by Security Level

Use STRICT for untrusted input where you only need JSX transformation. Use STANDARD for typical LLM-generated TypeScript+React code.

Configuration Options

Default Configurations

Allowed Globals

The Babel preset adds these globals to the AgentScript allowlist: All other AgentScript allowed globals remain available.

What’s Blocked

The Babel preset inherits all AgentScript security rules:
  • Dangerous Babel options - plugins, sourceMaps, ast, babelrc, configFile
  • Disallowed presets - Any preset not in the security level’s allowlist
  • All AgentScript blocked constructs - eval, Function, process, etc.
Babel plugins are completely blocked because they can execute arbitrary code during transformation. Only presets from the allowlist can be used.

Creating the Preset

Using with Enclave

The enclave automatically uses the Babel preset when configured:

API Reference

createBabelPreset(options)

Creates validation rules for the Babel preset.

getBabelConfig(level)

Gets Babel security configuration for a security level.

BABEL_SECURITY_CONFIGS

Direct access to all security configurations.