Expand description
AST-based JavaScript execution for Code Mode.
This module provides secure execution of validated JavaScript code by:
- Compiling the SWC AST to an ExecutionPlan
- Executing the plan in pure Rust (no JS runtime)
§Security Model
Only operations that can be represented in the ExecutionPlan are allowed. The plan is a simple tree structure that’s fully auditable before execution.
§Supported Operations
- API calls:
api.get(),api.post(),api.put(),api.delete(),api.patch() - Variable assignment:
const x = ... - Property access:
user.id,response.data - Array methods:
.map(),.filter(),.slice(),.find(),.length - Template literals:
`/users/${id}` - Object literals:
{ name: "test", id: 123 } - Array literals:
[1, 2, 3] - Conditionals:
if/else - Bounded loops:
for (const x of arr.slice(0, N)) - Return statements
Structs§
- ApiCall
Log - Log entry for an API call.
- Execution
Config - Configuration for execution.
- Execution
Plan - An execution plan compiled from JavaScript AST.
- Execution
Result - Result of executing a plan.
- Mock
Http Executor - Mock HTTP executor for dry-run validation and testing.
- Mocked
Call - A recorded mock call with request and response.
- Path
Template - A path template that may contain interpolations.
- Plan
Compiler - Compiler that converts SWC AST to ExecutionPlan.
- Plan
Executor - Executes a compiled execution plan.
- Plan
Metadata - Metadata about the execution plan.
Enums§
- Array
Method Call - Array method calls.
- Binary
Operator - Binary operators.
- Builtin
Function - Built-in global functions and static methods.
- Compile
Error - Error during plan compilation.
- Mock
Execution Mode - Execution mode for the mock executor.
- Number
Method Call - Number method calls.
- Object
Field - A field within an object literal, either a regular key-value pair or a spread.
- Path
Part - A part of a path template.
- Plan
Step - A single step in the execution plan.
- Unary
Operator - Unary operators.
- Value
Expr - An expression that produces a value.
Traits§
- Http
Executor - Trait for making HTTP requests during execution.
- McpExecutor
- Executor for MCP foundation server calls.
- SdkExecutor
- Executor for SDK-backed API calls.
Functions§
- filter_
blocked_ fields - Recursively filter blocked fields from a JSON value.
- find_
blocked_ fields_ in_ output - Find blocked fields that appear in a JSON value (output validation).
Type Aliases§
- JsExecutor
- Legacy JsExecutor type alias for backward compatibility.