Expand description
The interpreter core: evaluate one script, call one global function with one JSON argument, and hand back its JSON result or its refusal.
This crate depends on Boa and serde_json and nothing else — no file
system, no network, no store — so the same interpreter runs natively and
in a wasm32-unknown-unknown build. Everything that reaches outside the
interpreter is installed by the caller through call’s install
argument; boa_engine is re-exported so those bindings name the same
engine version.
Beside call, modules::with_module evaluates an in-memory graph of
ES modules, and worker is a restricted execution protocol driven by
host messages (worker::Realm). See the README for an example.
§A fresh interpreter per call
Every call builds a new Context, evaluates the file, and drops it. No
state leaks from one hook call into the next, a script edited on disk is
simply the script the next call evaluates, and a Context (which is not
Send) never has to cross a thread.
§What is bounded, honestly
Boa’s RuntimeLimits bound three things;
the first two are set here and the stack size keeps Boa’s default:
- each CALL FRAME may run at most
LOOP_ITERATION_LIMITloop iterations in total (Boa counts per frame, not per loop) — an infinitewhile (true)throws instead of hanging, but a loop that calls a function whose own loops stay under the limit is not bounded in total; - call depth is at most
RECURSION_LIMIT— runaway recursion throws; - the VM stack size.
There is NO wall-clock limit: Boa cannot pre-empt a running script. A script of many individually-bounded loops can still run long, and a script blocked inside a host function (an HTTP call, a child process) is bounded only by that host function’s own timeout.
Re-exports§
pub use boa_engine;
Modules§
- modules
- In-memory ESM execution, separate from the legacy global-function hook API.
- worker
- The code-mode worker process (a host binary started with its worker flag).
The code-mode worker: one restricted JavaScript execution in a process of
its own, on Boa. A host binary becomes this process when it is started
with the hidden worker flag (
BREP_mcp_corecad::code::worker_entry).
Structs§
- Failure
- A call that threw, failed to parse, or named a function the file does not
define.
messageis what a person reads: forthrow new Error("x")it isx, forthrow "x"it isx. - Success
- A call that returned.
Constants§
- LOOP_
ITERATION_ LIMIT - The most loop iterations any one call frame may run before it throws.
- RECURSION_
LIMIT - The deepest call stack a script may build before it throws.
Functions§
- call
- Evaluate
source(namedfilein messages), then call the global functionfunctionwithinputas its single argument. - describe
- The message a person should read for
error. - text_of
- One argument as the text a log line shows: strings verbatim, everything else as JSON.
Type Aliases§
- Logs
- Lines a script wrote through
console.log, kept for the caller — the test run shows them, and a failing hook’s log goes to the server log.