Run a browser task
Receive one bounded assignment, obtain local authorization, execute through the wrapper’s browser driver, and return ordered progress plus a structured result.
Executor example
This executor contains wrapper-owned browser behavior. The shared runtime sees only its capability, bounded work input, progress, result, and proof hook.
import {
BodyExecutorRegistry,
type BodyExecutor,
type BrowserDriver,
} from "@tabworker/sdk";
export function registerBrowserTask(driver: BrowserDriver) {
const executor: BodyExecutor = {
capability: { namespace: "com.example", name: "browser_task", version: "1" },
async execute(work, context) {
await context.progress({ stage: "opening" });
await driver.navigate(String(work.input.url));
const page = await driver.inspect();
return {
result: { title: page.title ?? "", url: page.url },
proofInput: { pageUrl: page.url },
};
},
};
const executors = new BodyExecutorRegistry();
executors.register(executor);
return executors;
}
States
| State | Allowed next operations | What the wrapper owns |
|---|---|---|
| disconnected | connect | Transport construction and credentials |
| connected | pair, disconnect | Existing pairing flow |
| paired | receivePinnedWork, claimPinnedWork, disconnect | How pinned work is obtained |
| claimed | authorize, cancel | Local consent and authorization UI |
| authorized | start, cancel | Final pre-execution checks |
| started | heartbeat, progress, complete, cancel | Domain execution and proof creation |
| finished | disconnect | Local cleanup and result retention |
Progress and results
Progress sequences start at 1 and increase by one. Completion contains a structured JSON result and an opaque proof reference. The wrapper produces and stores proof material; acknowledgement is not review, payment, or settlement.
Cancellation
Cancellation is valid after claim, authorization, or start. Give the transport a bounded reason, stop local execution at a safe boundary, and disconnect. If execution throws, wrappers should attempt cancellation without hiding the primary error.
Reconnect and revoke
BodyRuntime retains the active assignment and last progress sequence across a bounded reconnect, then asks the brain to resume the same attempt. Revocation stops the node and must not allow later browser mutations or completion.