Run Events

View as Markdown

Run events are machine-readable observations emitted by a run. Use them when you need precise event data for browser navigation, pages, contexts, artifacts, commands, tool calls, and other run-scoped records.

Start from the runtime and get the active run.

1const run = await runtime.currentRun();

List events

1const { events, nextCursor } = await run.events.list({
2 type: ["page.load"],
3 limit: 100,
4});
5
6for (const event of events) {
7 console.log(event.time, event.type, event.source);
8}

Wait for an event

1const { event, timedOut } = await run.events.wait({
2 type: ["page.load"],
3 timeoutMs: 30_000,
4});
5
6if (timedOut) {
7 throw new Error("Timed out waiting for page load");
8}

HTTP equivalents

1GET /v1/runs/{runId}/events
2POST /v1/runs/{runId}/events/wait