Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:A9T9 RPA Sandbox Initialization

From Leeroopedia
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:

Execute(code)=Step(Interpret(code,Bridge(API)))

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

Related Pages

Implemented By

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment