Scripts that say what they take and what they return.
Write TypeScript with a zod schema for its input and output. Volvel draws the form, checks what comes in, keeps every run, and retries or stops it the way you said. The same script runs from a schedule, a webhook, a flow, a button in an app or an agent.
- TypeScript
- zod schemas
- retries and timeouts
- kept in git
A script is a function with a contract.
The schema is the contract. Forms, flows, apps and agents all read it, so nobody has to guess what a script expects or what it gives back.
- Input is checked before the script starts, and output before it's kept.
- It names the connections, variables, tables and events it uses. A deploy says what a workspace still has to bind, and promotion to production stops until it's bound.
- Settings sit beside the code, so a reviewer sees the retries and the timeout in the same diff.
export const syncOrders = defineScript({
path: "orders/sync",
input: z.object({ since: z.iso.datetime().optional() }),
output: z.object({ sent: z.number(), skipped: z.number() }),
connections: [shop, erp],
timeoutSeconds: 120,
retries: { limit: 3, delaySeconds: 30 },
// Two syncs at once would send the same orders twice.
concurrency: 1,
onFailure: { script: "alerts/run-failed", notify: alerts },
async run(input, ctx) {
const erpApi = await ctx.connection("erp");
// The ERP ignores an order it has seen with this key,
// so a retry is safe.
await erpApi.post("/import/orders", order, {
headers: { "idempotency-key": `order-${order.id}` },
});
// …
},
}); Shortened from the Acme example repository.
What a script can reach.
Everything comes through ctx, and only what the script declared. There are no credentials in the code and no ambient access to the rest of the workspace.
| Call | What it gives |
|---|---|
ctx.table() | The rows of a workspace table, typed from its definition: find, insert, update, delete and totals. .as(person) reads and writes as whoever started the run, so their row rules apply. |
ctx.connection() | A client for a connection bound in this workspace, such as an HTTP API with its auth, a mail server, or a connector your team wrote. |
ctx.connections() | One member of a connection group, picked by data at run time: the right shop or the right client's API. |
ctx.secret(), ctx.variable() | Values set per workspace, so dev and production differ without a code change. |
ctx.source() | The tables of an outside Postgres database the workspace connects to. |
ctx.files, ctx.events | Store a file for a row or for later, and publish an event that starts its subscribers. |
ctx.run | Which attempt this is, the run's idempotency key, who or what started it, and tags to find it by later. |
ctx.log, ctx.signal | Structured logs kept with the run, and a signal that aborts when the run is cancelled or out of time. |
When a run goes wrong.
You write the work. The platform handles the parts every script needs and few people remember to write.
- Retries with a limit, a delay and a backoff, set on the script.
- Each attempt runs in its own process with a memory cap, and is stopped at its timeout, even if it ignores the signal.
- Delivery is at least once, so every attempt carries the same idempotency key to pass to the systems you call.
- After the last attempt,
onFailurestarts a script with the failed run as input, posts a summary to a connection, or both.
Settings that live on the script.
Each one is a line in the definition, reviewed and deployed with the code it governs.
- A form from the schema
- Run it by hand from a form drawn from its input. Run a past run again with its input edited.
- Concurrency, with a key
- A limit on runs at once, or one lane per value, such as one per customer, so runs for different customers still go ahead.
- Where it runs
- Name a worker pool, and the script runs only there: inside a client's network, or next to the database it needs.
- Memory and time
- A timeout and a memory limit per script. Past either, the attempt ends and the failure says why.
- Tags
- Label a run with an order number or a customer, up to ten per run, and find it by that label.
- A tool for agents
- Every script is a tool over MCP. Give it a fixed name so a rename never breaks the agent that calls it.
- A step for the flow editor
- Give it a label and an icon, and it appears in the flow editor's palette, with its form drawn from its input.
- Results you can read
- Output shown as a table or as text, with the raw JSON a click away.
Write it where you like.
In your own editor and deploy with the CLI, or in the console, with the SDK's types to hand and a test run of the draft one key away.
- A draft can be run before anything is deployed.
- The TypeScript source travels in the bundle with a source map, so a failure points at its line.
- Drafts keep their history. Setting one aside never loses the earlier text.
Related
Write the first script.
One file, one schema, and every run is kept from the start.