Skip to main content

Module executor

Module executor 

Source
Expand description

AST-based JavaScript execution for Code Mode.

This module provides secure execution of validated JavaScript code by:

  1. Compiling the SWC AST to an ExecutionPlan
  2. 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§

ApiCallLog
Log entry for an API call.
ExecutionConfig
Configuration for execution.
ExecutionPlan
An execution plan compiled from JavaScript AST.
ExecutionResult
Result of executing a plan.
MockHttpExecutor
Mock HTTP executor for dry-run validation and testing.
MockedCall
A recorded mock call with request and response.
PathTemplate
A path template that may contain interpolations.
PlanCompiler
Compiler that converts SWC AST to ExecutionPlan.
PlanExecutor
Executes a compiled execution plan.
PlanMetadata
Metadata about the execution plan.

Enums§

ArrayMethodCall
Array method calls.
BinaryOperator
Binary operators.
BuiltinFunction
Built-in global functions and static methods.
CompileError
Error during plan compilation.
MockExecutionMode
Execution mode for the mock executor.
NumberMethodCall
Number method calls.
ObjectField
A field within an object literal, either a regular key-value pair or a spread.
PathPart
A part of a path template.
PlanStep
A single step in the execution plan.
UnaryOperator
Unary operators.
ValueExpr
An expression that produces a value.

Traits§

HttpExecutor
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.