Principle:A9T9 RPA Sandbox Initialization
| Knowledge Sources | |
|---|---|
| Domains | Scripting_API, Sandboxing |
| Last Updated | 2026-10-22 00:00 GMT |
Overview
Mechanism for executing user-authored JavaScript in a controlled interpreter sandbox with a bridged API surface, enabling step-by-step execution with pause and breakpoint support.
Description
Sandbox Initialization is the process of creating an isolated execution environment for user-authored JS macro code. The sandbox must:
- Isolate: user code runs in an interpreter that does not have direct access to the browser's global scope — all external operations are bridged
- Bridge: the `uiv.*` API is injected as a set of functions in the sandbox's global object. Calls to these functions are serialized and dispatched to the host environment, which performs the actual operation (DOM manipulation, input dispatch, OCR, etc.) and returns the result
- Step: the interpreter executes synchronously, one step at a time, driven by a timer loop. This allows the UI to remain responsive and enables pause/resume and breakpoint functionality
- Manage lifecycle: the sandbox tracks running state, handles early exit (`uiv.exit`), and reports errors with line attribution
The JS-Interpreter (a vendored ES5 interpreter based on Neil Fraser's project) provides the isolation and step-by-step execution. The host injects bridge functions (`__uiv_bridge`, `__uiv_pause`, `__uiv_exit`, `__uiv_get`) that the `uiv.*` polyfill calls internally.
Usage
Use this principle when executing untrusted or user-authored code that must not have direct access to the browser environment, and when pause/resume/breakpoint control is required.
Theoretical Basis
The sandbox is an interpreted execution model with a bridge boundary:
Each step is synchronous; the host loop calls `interpreter.step()` in a timer-driven cycle:
Pseudo-code Logic:
# Abstract sandbox execution (NOT real implementation)
interpreter = create_interpreter(transpiled_code, inject=uiv_api)
while not interpreter.done():
if paused: wait_for_resume()
if at_breakpoint: pause()
interpreter.step() # one AST node per call
yield_to_ui() # keep UI responsive