rewind
sleep(duration)
duration: a number of milliseconds, or a string such as "30s", "10d" or "1h30m" (units ms, s,
m, h, d, w). The wait is durable: the run survives restarts and deploys, and costs nothing while it waits.
Afterwards, Date.now() is at least the time before plus duration.
signal(name, opts?)
name sent to this run, and returns its payload. A signal sent before the script waits
is kept in the name’s mailbox, first in, first out, so none is lost. With a timeout, returns undefined if none arrived
in time; without one, the wait lasts as long as the run. Names starting with rewind: are reserved.
In a run of a workflow, name must be one of its declared signals, and the payload has the declared type.
webhook(name)
name: every request posted to it becomes a signal name on this
run, with the request’s body as payload. Give the URL to an external system, then wait with signal(name).
run
run.id diverges from its parent there.
ToolError
Thrown by a tool call that failed. Catch it to handle the failure; uncaught, it fails the run.
CancelledError
Rejects every pending await of the script when the run is cancelled. Catch it to clean up: the script then has one
chance to end by itself.
WorkflowError
Thrown by result() when a run of a workflow this run started failed, was cancelled or aborted, or returned an output
its workflow’s schema refuses.
rewind:tools
Generated for the run’s toolset: one export per MCP server (by the name the toolset gives it) or group of host tools,
and one per host tool without a group. Each tool is an async function taking one object of arguments.
TypeError
at the call site. A failed call throws a ToolError.
rewind:workflows
Generated for the run’s toolset: one export per workflow it pins.
A run started without
detached: true is attached: this run does not end before it, and cancels it if this run fails
or is cancelled.
Globals
The sandbox has the ECMAScript built-ins (ES2025,Temporal, explicit resource management) and exactly these globals:
The isolate runs with
TZ=UTC and the en-US locale. See The sandbox for what is removed and why.