- One module. Its default export is
async function main(input). Input and output are JSON. - Three imports.
rewind:tools(the toolset’s tools),rewind:workflows(the workflows it pins) andrewind(the standard library). No npm packages, no relative imports, no dynamicimport(). - Strict TypeScript. The script is type-checked against the toolset’s declarations before it runs.
Prompting the model
Put the toolset’s declarations in the system prompt, and say how you want the model to work:- Ask for one script per task, which returns only what the conversation needs. Intermediate data stays in the run.
- Mention
retry_run. A failed run is fixed by a fork that does not repeat its calls, rather than by a new run that does. - Describe your host tools well. Their
descriptionis the model’s only documentation, and so are your MCP servers’ tool descriptions. - Give output schemas to host tools. MCP tools without one get observed types after their first results.
Patterns
Calls in parallel
Calls in parallel
Tool calls are promises: run independent ones together. A run has at most 16 calls in flight; the others wait
for a slot.
Handle a tool's failure
Handle a tool's failure
A failed call throws a
ToolError. Catch it where the script can do something better than fail.error.outcomeUnknown is true when the call was interrupted and may have taken effect: check before calling
again.Wait for a person
Wait for a person
signal_run, sends the signal. See Human in the loop.Wait for time to pass
Wait for time to pass
Poll until something is ready
Poll until something is ready
Log what matters
Log what matters
console.log lines are journaled, shown in the dashboard next to their line, and returned with the run: the
model sees the last ones.Fan out over a workflow
Fan out over a workflow