Table of contents
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Block Internals
How the 42 built-in blocks in src/core/blocks/ are put together: the definition contract as the engine
actually calls it, what a block can reach through ctx, how its settings become editor widgets, the shared
helpers, and a per-block implementation table. Read this before changing a block or writing a new one
(then follow Adding a Block). For what each block does from the user's side, see the
generated block reference.
Source: index.ts, pageCommon.ts,
dataCommon.ts, every other file in src/core/blocks/,
plus the contract in types.ts (BlockDefinition, BlockContext, FieldSpec) and
config.ts (defaults, templating, validation).
The definition contract
A block is one exported constant of type BlockDefinition<C> (src/core/types.ts), where C is the block's
own config interface (TimerConfig, ClickConfig…). Blocks are plain objects: no classes, no registration
side effects. The registry erases C (AnyBlockDefinition).
| Member | Required | Used by | Notes |
|---|---|---|---|
type |
yes | engine, saved workflows | The id stored in NodeDef.type. Never rename: saved workflows reference it (Open Tab is still open-url). Must be unique, BlockRegistry.register throws otherwise. |
label, description, icon |
yes | editor palette and config panel, guide | description and field labels/help are copied into docs/guide/blocks.* by scripts/guide.ts. |
accent |
yes | editor | Colour of the block. PAGE_ACCENT / DATA_ACCENT for page and data blocks. |
category |
no | palette | Do not set it in the block: createDefaultRegistry() stamps it from BLOCK_GROUPS in index.ts. |
defaultConfig: C |
yes | withDefaults() |
Merged under the saved config ({...defaultConfig, ...raw}) on every resolve, so new keys get a value in old workflows. |
fields: FieldSpec[] |
yes | editor, validation, templating, guide | One entry per editable key. Order = order in the config panel. See Settings and the editor. |
outputs: OutputSpec[] |
yes | editor ("Data this block passes on"), guide | Documentation only; the engine never checks it. Use (same data) for pass-through blocks. |
summary?(config) |
no | BlockNode.tsx |
One line on the canvas. Receives the saved config with defaults applied, not template-rendered. |
ports?: string[] | (config) => string[] |
no | engine, editor handles, validation, check, script, layout, exporter | Named outputs; default ['out']. The engine appends error when step.onError === 'port' (nodePorts() in ports.ts). A function = dynamic ports from the config (defaults applied, not rendered); must not throw, never return error, and keep names stable while a setting is typed (Switch: stand-in case<N>). Always read through nodePorts(def, node). |
timeoutSeconds? |
no | stepTimeoutSeconds() |
Default step timeout for this block type; the engine default is 60 (DEFAULT_TIMEOUT_SECONDS). A node's step.timeoutSeconds overrides it. |
permissions? |
no | ConfigPanel.tsx → PermissionNote.tsx |
Optional browser permissions (OptionalPermission: 'debugger', 'userScripts', 'cookies', 'declarativeNetRequest', 'browsingData') the editor offers to grant: a list, or a function of the config (defaults applied) for blocks that need one only for some settings (Screenshot, Cookies & Storage, Wait For captureBody, Route, Assert console-errors). The Firefox build hides debugger (no such API there). |
validate?(config) |
no | check.ts (import), validate.ts (editor) |
Rules over several settings that required cannot express. Receives the config with defaults applied (not rendered) and returns ConfigProblem[] ({ key, code, message }, code usually config.required, or config.value / config.url.invalid). Import reports each at .../config/<key> and refuses the file; the editor shows the message on the block. Must not throw. In: Assert (element subjects need locator, attribute and css need name, aria-snapshot needs a template that parses, checked unless it has {{…}}), Press Key (key, or text in mode: "text"), Wait For (element modes → locator, text modes → text, url/response → url), Upload File (url or content by source), Download (dataset or value by from), Read Element (name for attribute/has-class), Navigate (url for goto, valid when not templated), Schedule (at is HH:MM for day), Extract List / Extract Table (html in HTML mode, validateSource). |
legacyKeys? |
no | check.ts |
Config keys that are no longer settings but that run still reads from old workflows (Open Tab: newTab), so import does not call them unknown (config.key.unknown). Renamed keys go in RENAMED_KEYS (migrate.ts) instead. |
start?(ctx) |
no | root blocks when a workflow is switched on | Schedule yourself here (timers), or just log (event-driven triggers). |
trigger?(ctx) |
no | Run button / Run Workflow on a root | What a start block sends "right now". Return null to send nothing. |
run?(ctx, input) |
no | every step | The normal path. Returns RunOutput. |
onTimer?(ctx, name, data) |
no | handleTimer() |
Called when a timer this node set fires. |
When the engine calls what
| Situation | Entry point (engine.ts) |
Block method called |
|---|---|---|
| Workflow switched on, edited, browser start-up | runner.start() → startRoot() per root |
start(ctx) if defined; otherwise run(ctx, {}) once, as a new run with trigger start |
| ▶ Run button | runOnce() → runRoots(run, {}) |
trigger(ctx) (its result merged over the input) if defined, else run(ctx, {}) |
| Called by Run Workflow | runAsCall(input) → runRoots(run, input) |
as above, with the caller's payload as input |
| Upstream block sent data | emitFrom() → runStep() |
run(ctx, input); a block without run is skipped with a warning |
| A timer fired | handleTimer(key) |
onTimer(ctx, name, data) (config resolved against {}) |
| Page Visited / context menu event | handleEvent(nodeId, payload) |
run(ctx, payload) in a new run (trigger event) |
start and onTimer run outside any run: ctx.runId is '', ctx.timeoutMs is the 60 s default,
softFail only logs, callWorkflow throws, and ctx.emit() opens a new run whose first step is the
block's own firing. start/onTimer errors are caught and logged (guard()), never retried. Step
settings (timeout, retries, onError, disabled, screenshots) apply only to run/trigger calls. Background
on why runs start this way: ARCHITECTURE: Engine model.
What run returns
| Return | Effect |
|---|---|
a Payload |
Sent out of the block's first port (usually out). Each connected block gets a shallow copy. |
routeTo(port, payload) (ports.ts) |
Sent out of port. A port not in nodePorts() fails the step: sent data to an output it does not have. |
null / undefined |
The path ends here; the step is still passed (Stop "pass", HTTP Request with failOnError, Read Element "not found", Timer delay). |
| throw | The step failed; the engine retries (step.retries) and then applies step.onError. Throw Errors with a message the user can act on. |
ctx.softFail(msg) then return |
Step and run marked failed, but the output still flows (soft Assert). |
Pass-through blocks return input (or { ...input, extra }): later blocks need everything upstream put in
the payload, including $session.
The context (BlockContext<C>)
| Field | What it is | Notes |
|---|---|---|
config: C |
Settings: defaults applied, templated fields rendered against the input (plus secret.*), validated |
Validation errors stop the step before run is called, so run may trust required fields and selects. |
host: Host |
Everything outside the engine (tabs, page agent, HTTP, datasets…) | The only way out of src/core. See Core Engine and Browser Host. |
emit(payload, port?) |
Send now, possibly several times | Inside a run it awaits the whole downstream subtree (loops rely on this) and resolves with the data the last path reached ended with (undefined if every path stopped). From start/onTimer it starts a new run. |
timers.set(name, {delayMs, periodMs?}, data?) / clear(name) |
Durable timers via Host.scheduler |
Key is bf::<workflowId>::<nodeId>::<name> (timerKey.ts). data is stored, so it must be JSON. runner.start() and stop() clear every timer of the workflow. See Scheduling and Timers. |
state.get(key) / state.set(key, value) |
Per-node key/value store via Host.state |
Stored under <workflowId>::<nodeId>::<key> (stateKey()); survives worker restarts and is not cleared when the workflow restarts. JSON values only. |
log(level, message) |
Run log line for this node | Secrets are masked by the engine. |
softFail(message) |
Soft failure (see above) | |
callWorkflow(id, input) |
Child run, resolves with its last output | Only inside a run; nesting limit MAX_CALL_DEPTH (8). |
timeoutMs |
This step's timeout in ms | Page blocks wait a little less (pageWaitMs). |
realInput |
step.realInput |
inPage() forwards it to Host.page.act. |
isRoot |
Nothing feeds this node | Available, but no built-in block reads it: they distinguish root vs. inline by which method is called. |
workflowId, workflowName, nodeId, runId |
Identity | runId is '' outside a run. |
Rules that follow from the MV3 worker sleeping (from CLAUDE.md): never use
setTimeout/setInterval for workflow timing (use ctx.timers + onTimer, or ctx.host.sleep for short
waits inside one step), and keep anything you must remember in ctx.state, never in module variables. The
one module-level variable in the blocks, Watch Element's inFlight set, is only an overlap guard that may
safely be lost.
Settings: fields and the editor
fields drives four things at once: the config panel (ConfigPanel.tsx), validation (config.ts),
template rendering (resolveConfig()), and the generated guide/JSON schema (scripts/guide.ts). There is
no per-block editor code.
kind |
Editor widget | Run-time handling |
|---|---|---|
text |
<input>; <textarea> when multiline; TemplateInput (with {{…}} suggestions) when templated |
Rendered if templated; required = non-blank |
url |
same as text | Rendered if templated; must be http(s) (in design mode a value containing {{ is accepted) |
selector / locator |
text input + 🎯 Pick on page button | pickerUrlKey names a config key the picker also fills with the page URL; pickPrefers: 'stable' asks for a structural CSS selector instead of a readable locator |
number |
<input type=number> with min/max/step |
Numeric strings are coerced by withDefaults(); min/max enforced |
boolean |
checkbox | must be a boolean |
select |
<select> of options |
value must be one of options[].value |
rows |
table of columns, + Add row, ✕; a 🎯 button per locator: true column; 🎯 Detect fields when detectForm |
Each cell rendered if its column is templated; required = at least one non-empty row; every non-empty row needs its first column |
workflow |
<select> of saved workflows |
stores the workflow id |
Validation runs twice: in design mode while editing (validateWorkflow() in validate.ts, which also
reports {{ }} syntax errors in templated fields) and in run mode just before each step.
Keep the strings user-facing and unchanged unless you mean to change the docs: labels, help, option labels
and description all land in docs/guide/blocks.md, and npm run guide:check fails until you run
npm run guide:sync.
Shared helpers
pageCommon.ts
| Export | Signature / value | Purpose |
|---|---|---|
PAGE_ACCENT |
'#7c3aed' |
Accent of page blocks. |
PAGE_TIMEOUT_SECONDS |
30 |
Default timeoutSeconds for page actions (Playwright's default too). |
tabField |
TextField (key: 'tab', not templated) |
The "Tab" setting. Empty = main. Wait for Popup spreads it with another label. |
locatorField(key = 'locator', label = 'Element', required = true) |
TextField |
Templated kind: 'locator' field with the standard placeholder/help. Spread and override help/placeholder per block. |
pageWaitMs(ctx) |
Math.max(1000, ctx.timeoutMs - 500) |
The wait passed to the host: slightly under the step timeout, so the page's own reason ("waiting for #x to be visible") wins over the engine's generic timeout. |
WithTab |
{ tab: string } |
Config constraint of inPage. |
inPage(ctx, input, request) |
Promise<{ tabId, result }> |
requireSessionTab(input, config.tab) then host.page.act(tabId, request, pageWaitMs(ctx), realInput ? {realInput: true} : undefined). Throws "No tab named … Put an Open Tab block…" when the tab is missing. |
Blocks that need a tab but not the agent (Dialogs, Run Script, Wait For URL/load/response, Navigate, Wait
for Popup, Assert url/title) call requireSessionTab from src/core/session.ts directly. Tabs live in
the payload under $session.tabs; see Core Engine and
ARCHITECTURE: Page blocks.
dataCommon.ts
| Export | Signature | Purpose |
|---|---|---|
DATA_ACCENT |
'#0d9488' |
Accent of data and loop blocks. |
listField(key = 'list', label = 'List', placeholder = 'items') |
TextField |
A required, non-templated field holding an expression (items, data.results). |
valueAt(expression, input, label = 'List') |
unknown |
evaluate() from expression.ts; errors are prefixed with label. |
listAt(expression, input, label = 'List') |
unknown[] |
valueAt that insists on an array ("is not in the data" / "is not a list"). |
Expression fields (listField, Transform's expression column, Save to Dataset's and Download's value)
are deliberately not templated: they are evaluated by the block and keep their types (a list stays a
list), whereas templates always produce strings. See Core Modules.
Helpers exported from block files
| Export | File | Used by |
|---|---|---|
SourceConfig, sourceFields, inSource(ctx, input, request) |
extractList.ts |
Extract List, Extract Table: run an agent op on a tab (host.page.act) or on HTML in the data (host.html.act). No realInput. |
tableToObjects(result) |
extractList.ts |
Rebuilds {columns, values} into objects in column order (Chrome sorts object keys in executeScript results; see ARCHITECTURE: Data and scraping). |
WAIT_UNTIL_OPTIONS |
openUrl.ts |
"Continue when" options of Open Tab, Navigate, Wait for Popup. |
currentTabPayload(ctx) |
pageVisited.ts |
trigger of Page Visited and Context Menu: the active web tab becomes main. |
textToBase64(text) |
uploadFile.ts |
UTF-8 safe base64 for Upload File's text source. |
decodeFileData(text) |
uploadFile.ts |
Upload File's data source: base64 (whitespace and URL-safe characters allowed) or a data: URL (base64 or percent-encoded) → {base64, mime?}; config.invalid otherwise. |
parseModifiers, parsePosition, modifierProblems, positionProblems, modifiersOf, positionOf |
pageCommon.ts |
Click and Drag: "Control+Shift" → ['Control', 'Shift'] (Ctrl, Cmd, Command, Option accepted), "10,5" → {x, y}; validate problems (config.value) and run-time values. |
parseRouteRules(raw), dnrCompatible(rules), MAX_ROUTE_RULES (100), MAX_ROUTE_BODY (1 000 000) |
route.ts |
Route validate/run and src/browser/routes.ts (the browser boundary re-validates). |
emulateProblems(config) |
emulate.ts |
Emulate validate and run (after templates render). |
parseSiteOrigins(text) |
clearSiteData.ts |
Clear Site Data and src/browser/environment.ts. |
clickOptions(config) |
click.ts |
The mouse fields of a click request, only those that differ from the defaults (old configs send the same request as before M2). Also used by the Playwright exporter. |
index.ts
BLOCK_GROUPS lists every block by palette category, in palette order; createDefaultRegistry() registers
each with category set. Every block constant is also re-exported by name. The same registry is built by
the background worker, the editor (src/entrypoints/editor/registry.ts), scripts/guide.ts and the test
harness (tests/helpers/fakeHost.ts), so registering a block in BLOCK_GROUPS is all it takes to make it
appear everywhere.
All blocks
Ports are out unless listed; every block also gets error when step.onError is port. "Timeout" is the
block's default step timeout (60 = engine default). Page ops are the AgentRequest ops it sends (see
Page Protocol); other host calls are Host methods.
Start (category: 'start')
Block (type) |
File | Methods | Host / page ops | Timers · state | Timeout | Implementation notes |
|---|---|---|---|---|---|---|
Start (start) |
manualStart.ts | run | none | none | 60 | Returns {...startingValues, ...input}, so a Run Workflow caller's values win. Has no start, so (like any plain root) it also runs once when the workflow is switched on. |
Timer (timer) |
timer.ts | start, trigger, run, onTimer | host.now |
tick (periodic if repeat), delay:<uid> one-shot carrying the payload · count |
60 | Root: start resets count and sets tick. Inline: run sets a delay timer and returns null; onTimer emits {...data, firedAt}. Because onTimer has no run, everything after a delay continues in a new run (trigger timer). |
Schedule (schedule) |
scheduleBlock.ts | start, trigger, onTimer | host.now |
next one-shot carrying scheduledFor |
60 | nextOccurrence() from schedule.ts; plans the next timer before emitting so a failing run does not stop the schedule. No run: cannot take input. |
Page Visited (page-visited) |
pageVisited.ts | start (log only), trigger, run | tabs.current |
none | 60 | The trigger lives in the background worker (webNavigation listeners call handleEvent with $session.tabs.main); run passes the event payload through. See Background Worker. |
Context Menu (context-menu) |
contextMenu.ts | start (log only), trigger, run | tabs.current |
none | 60 | Same pattern; menu items are created by the background from title/contexts. |
Watch Element (watch-element) |
watchElement.ts | start, trigger, run, onTimer | page.readElement (background tab per URL, not page.act) |
poll (periodic) · last = {signature, value} |
60 | Schedules poll before the first check so a failing check does not stop it. First read is a baseline unless emitOnFirstRead; signature `url |
Tabs (browser)
Block (type) |
File | Methods | Host / page ops | Timers · state | Timeout | Implementation notes |
|---|---|---|---|---|---|---|
Open Tab (open-url) |
openUrl.ts | run | tabs.open |
state tabId (for where: 'workflow') |
45 | Adds url, tabId and $session.tabs[tab] (withSessionTab). Legacy newTab: false with where: 'new' means current. Load wait is timeoutMs - 500. |
Navigate (navigate) |
navigate.ts | run | tabs.navigate |
none | 45 | URL validated only for goto. Adds url. |
Wait for Popup (wait-for-popup) |
waitForPopup.ts | run | tabs.waitForPopup (look-back 15 s), tabs.waitForLoad, tabs.info |
none | 30 | Look-back catches a popup opened by the Click just before. Names the new tab in $session. |
Wait for Download (wait-for-download) |
waitForDownload.ts | run | downloads.waitFor (look-back 15 s), downloads.readText (with the session tab, for blob:), datasets.write (replace) |
none | 60 | Adds download {filename, url, path, size, mime, downloadId}; with read: content / rows (csvToObjects) / data (bad JSON → download.failed), datasetSize. The tab is optional (sessionTab). |
Cookies & Storage (cookies-storage) |
cookiesStorage.ts | run | cookies: cookies.get/set/remove (site = url, else tabs.info of the session tab); local/session: storage op with action |
none | 30 | permissions: cookies only for area: cookies. maxAgeSeconds → expires from host.now(). Adds value (+ cookies for the cookie area) or deleted. |
Route (route) |
route.ts | run | network.route |
none | 30 | rules is templated JSON parsed by parseRouteRules: 1–100 rules, unknown keys, bad patterns, status outside 100–599 or not on fulfill, delayMs over 30 000, headers/body outside fulfill/modify, a non-http(s) redirectUrl are all config.invalid. permissions: none for clear; declarativeNetRequest for dnr, or auto with only abort/redirect without delay; else debugger. backend: dnr with mock rules fails validate. Rules last until clear or run end; newest match wins. Adds route {rules, backend}. |
HAR Record (har-record) |
harRecord.ts | run | network.har, secrets.all, datasets.write (replace), downloads.save |
none | 60 | permissions: ['debugger']. start refuses a dataset/filename. On stop the HAR is masked with secrets of 3+ characters before it is written to the dataset (its entries) or downloaded as JSON. Adds recording, har, truncated?, datasetSize?. |
Emulate (emulate) |
emulate.ts | run | environment.emulate |
none | 60 | permissions: ['debugger']. emulateProblems checks width/height together (0 = preset/default, ≤ 10000), scale ≤ 8, both coordinates or none (±90 / ±180), locale (Intl.getCanonicalLocales), IANA timezone, no newline in the UA; templated values are checked again in run. Only non-empty settings are sent. Overrides last until clear or run end. Adds emulated (the options sent). |
Clear Site Data (clear-site-data) |
clearSiteData.ts | run | environment.clearSiteData |
none | 60 | permissions: ['browsingData']. parseSiteOrigins: 1–50 exact http(s) origins (no path, query, fragment, credentials or *), deduplicated. Adds clearedOrigins. Cookies go for the whole registrable domain. |
Close Tab (close-tab) |
closeTab.ts | run | tabs.close |
none | 60 | Uses sessionTab (not require…): a missing tab is only a warning. Removes the name from $session. |
Page actions (page)
Block (type) |
File | Page ops / host | Timeout | Implementation notes |
|---|---|---|---|---|
Click (click) |
click.ts | click |
30 | Logs "the page navigated" when the driver answers navigated. Pass-through. action is the quick choice and button, modifiers, position, clickCount refine it: right forces the right button (validate refuses button: middle with it), double means at least 2 presses, hover ignores button and count. |
Element Action (element-action) |
elementAction.ts | focus, blur, clear, scroll (to: element), dispatch |
30 | detail is templated JSON (parseDetail, config.invalid when it does not parse; validate checks it when it has no {{). Dispatch adds defaultPrevented; the rest pass through. |
Drag (drag) |
drag.ts | drag |
30 | from is sent as the request's locator (so errors and frames work as for other ops). Offers realInput. Adds dragMode; warns when an HTML5 target did not accept the drop. |
Fill (fill) |
fill.ts | fill |
30 | Pass-through. |
Fill Form (fill-form) |
fillForm.ts | set-field per row, then click |
30 | Rows with empty locator or value are skipped; a row's error is prefixed with its locator. All rows share one step timeout, but each inPage call gets the full pageWaitMs. |
Select Option (select-option) |
selectOption.ts | select |
30 | value split on ` |
Check (check) |
check.ts | check |
30 | No-op when already in the wanted state (result.changed). |
Press Key (press-key) |
pressKey.ts | press, or insert-text with mode: "text" |
30 | locator omitted from the request when blank. mode defaults to key (configs from before v0.4 have none); text is templated. |
Upload File (upload-file) |
uploadFile.ts | upload (dropzone: true for target: dropzone); http.download for URLs |
30 | Text source encoded with textToBase64; source: data through decodeFileData (a data URL's MIME wins over mime; default name upload.bin). Adds uploaded. |
Scroll (scroll) |
scroll.ts | scroll; host.sleep |
120 | to: 'end' is block-only: repeats scroll bottom until result.height is unchanged twice or maxScrolls. Adds scrolls. |
Dialogs (dialogs) |
dialogs.ts | page.dialogs (not the agent) |
15 | Installs handlers in the page's MAIN world; lasts until the page navigates. Adds dialogs, lastDialog. |
Wait For (wait-for) |
waitFor.ts | wait; tabs.waitForUrl, tabs.waitForResponse (look-back 10 s; method, captureBody), tabs.waitForRequest (look-back 10 s), tabs.waitForLoad, tabs.info |
30 | WaitMode = agent WaitState + url/load/networkidle/response/request (host-side). Adds url (or response / request). permissions: debugger only with captureBody on response. |
Run Script (run-script) |
runScript.ts | page.runScript |
30 | permissions: ['userScripts']. Code is not templated; it receives the input as data. Result stored under into. |
Read & scrape (read)
Block (type) |
File | Page ops / host | Timers · state | Timeout | Implementation notes |
|---|---|---|---|---|---|
Read Element (read-element) |
readElement.ts | URL set: page.readElement; else read op via page.act (wait ≤ 5 s) + tabs.info |
state last = {signature, value} |
60 | Tab mode treats a "Timed out" error as not found. Not found → logs a warning and returns null (path ends). Signature `url |
Extract List (extract-list) |
extractList.ts | extract via inSource |
none | 30 | Fields with blank names dropped; limit sent only when > 0. Adds [into] and count. |
Extract Table (extract-table) |
extractTable.ts | table via inSource |
none | 30 | Adds [into] and count. |
Paginate (paginate) · ports each, done |
paginate.ts | read (kind enabled), click (next >> nth=0); host.sleep(150), tabs.waitForLoad('networkidle') |
none | 1800 | Emits each with page, then stops when Next is missing/disabled (enabled answers false for a missing element instead of waiting) or at maxPages. Returns routeTo('done', {pages}). |
Page Info (page-info) |
pageInfo.ts | page-info or storage |
none | 30 | Adds page or value. |
Screenshot (screenshot) |
screenshot.ts | screenshots.take (which uses the measure op) |
none | 30 | permissions: debugger for full / element (Chromium; not needed in Firefox). Adds screenshotId (the engine shows it on the step) and screenshot {id, width, height, area}. M5.3 compare (with threshold 0..1, maxDiffRatio 0..1, mask rows {region} and updateBaseline): strict validate (compareProblems, also run before capturing: PNG only, ranges, parseMaskRows; updateBaseline / mask without compare are errors), then host.visual.compare (none → config.invalid); a mismatch throws CodedError('visual.mismatch') with the share differing; otherwise adds visual {status, diffRatio, diffPixels, comparisonId} and logs whether the baseline was saved, updated or matched. |
Page Snapshot (page-snapshot) |
pageSnapshot.ts | snapshot (with locator when set, maxLines at least 10) |
none | 30 | Adds snapshot (the outline text) and elements; logs a warning when the outline was cut. Playwright export: ariaSnapshot() of the body or the locator. The editor's 📸 Snapshot page button on Open Tab uses the same op, not this block. |
Test (test)
Block (type) |
File | Host / page ops | Timeout | Implementation notes |
|---|---|---|---|---|
Assert (assert) |
assert.ts | read via page.act (300 ms each), tabs.info, host.sleep(250) |
10 | Page subjects retry a number of attempts computed from pageWaitMs (no wall clock). Yes/no subjects (STATES: visible, hidden, checked, unchecked, enabled, disabled, focused, editable, in-viewport) compare with a fixed answer; others (READS: text, input, attribute, count, class, css, accessible-name, accessible-description) use testClause from condition.ts, except class with contains / not-contains, which test class tokens (every expected class present), not a substring. console-errors (no element, permissions: ['debugger']) compares the number of level: 'error' entries from network.console (console errors, failed console.assert, uncaught exceptions in this run) as a string. A failure is a CodedError('assert.failed') with the element's locator (page subjects); soft passes it to ctx.softFail. Adds actual. aria-snapshot (M5.4, locator optional = whole page) has its own loop (runAria): each attempt is a snapshot page op, parseAriaOutline + matchAriaSnapshot from ariaSnapshot.ts; the failure message is the match explanation (after the custom message, if any), actual the page in template form; a template that does not parse fails with config.invalid. expected is a multi-line field. |
Manual Step (manual-step) |
manualStep.ts | prompt.ask |
600 | false from the user throws. Pass-through. |
Stop (stop) |
stopRun.ts | none | 60 | fail throws message; pass logs and returns null. outputs: []. |
Logic & loops (logic)
Block (type) |
File | Ports | Timeout | Implementation notes |
|---|---|---|---|---|
If (if) |
ifBlock.ts | true, false |
60 | testClause(config); returns routeTo(...) with the input unchanged. |
For Each (for-each) |
forEach.ts | each, done |
3600 | listAt(list); awaits emit({...input, [as]: item, index, total}, 'each') per item, then routeTo('done', {...input, count}). The step timeout covers all iterations; every downstream step counts toward the 1000-step budget. |
Switch (switch) |
switchBlock.ts | one per case (cases[].port), then default (dynamic: ports(config)) |
60 | casePorts(config): valid unique names in row order, else stand-in case<N>. run tests { left: value, operator, right: row.value } per row with testClause (the engine renders value and the templated value column); first match → routeTo(port, input), none → default. validate: names (/^[A-Za-z_][\w-]{0,39}$/, unique, not in RESERVED_CASE_NAMES) and operators. |
Repeat (repeat) |
repeat.ts | each, done |
3600 | mode times (default; old configs with only times): iteration from 1, done gets {...input, iterations}. until / while: left/right are perItem (rendered by the block per check with evalEnv) against what the last emit resolved with ({...input, iteration: 0} before any round), iteration = rounds so far; until checks after a round, while before; max caps (throws unless failAtMax: false, then logs a warning); done gets the last checked data plus iterations. |
Run Workflow (run-workflow) |
runWorkflow.ts | out |
300 | ctx.callWorkflow(workflow, input); the child's last output becomes this block's output. The workflow field kind renders a workflow picker. |
Data (data)
Block (type) |
File | Host | Implementation notes |
|---|---|---|---|
Set Variable (set-variable) |
setVariable.ts | none | Value is templated, so always a string (use Transform for typed values). |
Transform (transform) |
transform.ts | none | Rows evaluated top to bottom with valueAt; each sees the ones above. |
Filter (filter) |
filter.ts | none | left/right are rendered by the block per item with {...input, item} (not templated fields, so the engine leaves them alone and no secret.* is in scope). Result key must be a simple name. Adds count. |
Data Table (data-table) |
dataTable.ts | none | JSON if the text starts with [/{, else csvToObjects. |
Save to Dataset (save-dataset) |
saveDataset.ts | datasets.write |
A list adds one row per item; anything else one row. Adds datasetSize. |
Download (download) |
download.ts | datasets.read, downloads.save |
CSV via toCsv, JSON pretty-printed, text as is. Adds file. |
All data blocks use the 60 s default timeout and out.
Send & log (output)
Block (type) |
File | Host | Implementation notes |
|---|---|---|---|
Notify (notify) |
notify.ts | notify |
Adds notified: true. |
HTTP Request (http-request) |
httpRequest.ts | http.fetch |
Headers parsed from Name: value lines; body sent for every method but GET when non-empty. Non-2xx with failOnError returns null (the path ends, the step passes). Adds url, status, ok, body, and data when the body parses as JSON. responseType: base64 asks the host for the body as base64 and adds body64 and mime instead (body is empty, no data). |
Log (log) |
log.ts | none | Pass-through. |
Gotchas
- Renaming is breaking.
type, config keys and select option values are stored in users' workflows and exports. Add a new key with a default instead, and read old shapes inrun(see Open Tab'snewTab, listed in itslegacyKeysso import accepts it), or rename throughRENAMED_KEYSin migrate.ts. - Import rejects unknown config keys (
config.key.unknown). A key a block reads but does not declare as a field must be inlegacyKeys, or files using it will be refused. - Rules between settings belong in
validate, not only inrun: then import and the editor report them before the run, with a path. Keep theruncheck too (it guards templated values). defaultConfigis merged shallowly. A savedrowsvalue replaces the default list entirely.- Templated output is a string.
{{count}}renders to"3". Compare numbers with If/Assert (which coerce) or compute with Transform. - Timer data and state must be JSON. They go to
storage.local. ctx.emitfrom a loop is sequential and holds the loop step open; a long downstream chain needs the loop block's timeout to be long (For Each/Repeat use 3600 s, Paginate 1800 s).- A Timer delay splits the run. Data after it arrives in a new run (trigger
timer), so a ▶ Run or a Run Workflow call ends at the Timer. summary()sees raw templates ({{url}}), and must not throw on missing values: use?? ''and|| 'placeholder'as the existing blocks do.
See also
- Adding a Block: step-by-step guide and checklist
- Core Engine: runner, runs, ports,
Host - Page Protocol: every
AgentRequestop and its answer - Page Agent: how ops are carried out in the page
- Scheduling and Timers: what happens behind
ctx.timers - Editor Components:
ConfigPanel,BlockNode - Testing:
FakeHostand theharness() - Block reference (generated, user-facing)
- ARCHITECTURE.md
Using BlockFlow
- What is BlockFlow
- Installing
- Getting Started
- Concepts
- Using the Editor
- Workflows as Scripts
- Recipes
- Capabilities and Limitations
- Troubleshooting
- Roadmap
Reference
Internals: engine
Internals: browser
Outside access (M4)
Internals: page and editor
Project
Generated from docs/wiki in the repo by npm run wiki:publish. Edit the repo files, not this wiki.