Skip to main content

Module script

Module script 

Source
Expand description

ScriptSpec v1 — unified AST for declarative crawl scripts.

Playwright/Puppeteer-inspired contract that lets a single file describe everything a render job should do end-to-end: selectors, steps, captures, assertions, exports. JSON, YAML and Lua all parse to this same AST so the executor is backend-agnostic.

§Example (JSON)

{
  "version": 1,
  "defaults": { "timeout_ms": 10000 },
  "selectors": {
    "email": "role=textbox[name=\"Email\"]",
    "login": "role=button[name=\"Sign in\"]"
  },
  "steps": [
    { "goto": "https://example.com/login" },
    { "type": { "locator": "@email", "text": "a@b.c" } },
    { "click": { "locator": "@login" } },
    { "wait_for": { "locator": "role=heading[name=\"Dashboard\"]" } }
  ],
  "captures": [
    { "screenshot": { "mode": "full_page", "name": "dashboard" } },
    { "snapshot": { "kind": "post_js_html" } }
  ],
  "assertions": [
    { "contains": { "locator": "body", "text": "Welcome" } }
  ],
  "exports": {
    "title": "text=h1",
    "items": { "locator": "@cards", "as": "list" }
  }
}

Selector names prefixed with @ reference the selectors map; bare selectors use the full selector DSL (see render::selector).

Design notes:

  • defaults.timeout_ms sets the fallback actionability timeout per step; individual steps can override.
  • captures always emit artifact.saved NDJSON events with a stage matching the capture kind.
  • assertions are checked in order; a failure emits job.failed with why=assertion:<name> and halts the script.
  • exports populate the ExtractCompleted event payload.

Re-exports§

pub use executor::plan;
pub use executor::Plan;
pub use executor::PlanError;
pub use executor::ResolvedExport;
pub use executor::ResolvedStep;
pub use legacy::actions_to_script_spec;
pub use runner::ArtifactRef;
pub use runner::RunOutcome;
pub use runner::ScriptRunner;
pub use runner::StepOutcome;
pub use spec::*;

Modules§

executor
ScriptSpec → backend translation.
legacy
Adapters from legacy interaction inputs to ScriptSpec.
runner
ScriptSpec runner — executes a resolved Plan against a live chromiumoxide::Page (our in-tree CDP client fork at render::chrome::page::Page).
spec
ScriptSpec AST — the common target of JSON/YAML/Lua script inputs.