TypeScript · MIT · open source
Procedures as data. Call them from everywhere.
Write a typed procedure once. Your code, the mark CLI, HTTP, WebSocket and the MCP tools of Claude Code call the same registry. A program is plain JSON, so you can store it, send it, draw it and compose it.
npm install @procedures/client{
"$proc": ["client", "chain"],
"input": {
"steps": [
{
"$proc": ["client", "range"],
"input": { "start": 1, "end": 6 },
"$name": "numbers"
},
{
"$proc": ["client", "map"],
"input": {
"items": {
"$ref": "numbers"
},
"fn": {
"$proc": [
"client",
"multiply"
],
"input": {
"a": {
"$ref": "item"
},
"b": {
"$ref": "item"
}
}
}
},
"$name": "squares"
},
{
"$proc": ["client", "sum"],
"input": {
"values": {
"$ref": "squares.results"
}
},
"$name": "total"
},
{
"$proc": ["client", "template"],
"input": {
"template": "The sum of the squares is {{total}}",
"values": {
"total": {
"$ref": "total"
}
}
}
}
]
}
}- client.chainsteps [{ "$proc": ["client", "range"], "input": { "st…→ { "results": [[1, 2, 3, 4, 5], { "results": [1,…
- client.rangestart 1, end 6→ [1, 2, 3, 4, 5]
- client.mapitems { "$ref": "numbers" }, fn { "$proc": ["client", "multiply"], "input": { "…→ { "results": [1, 4, 9, 16, 25] }
- client.multiplya 1, b 1→ 1
- client.multiplya 2, b 2→ 4
- client.multiplya 3, b 3→ 9
- client.multiplya 4, b 4→ 16
- client.multiplya 5, b 5→ 25
- client.sumvalues [1, 4, 9, 16, 25]→ 55
- client.templatetemplate "The sum of the squares is {{total}}", values { "total": 55 }→ "The sum of the squares is 55"
Measured when this site was built: the procedures of the registry, the it and test calls in the test files, and the source lines without the tests.
How it works
Define a procedure
A path, an input schema, an output schema and a handler. An import registers nothing: a host registers the module of the package.
import { defineProcedure } from "@procedures/client"; import * as z from "zod"; export const add = defineProcedure({ path: ["math", "add"], input: z.object({ a: z.number(), b: z.number() }), output: z.number(), handler: ({ a, b }) => a + b, });Call it from any host
In process, from the CLI, over HTTP or WebSocket, or as a tool of Claude Code. One invocation path validates each call.
await client.exec(["math", "add"], { a: 2, b: 3 }); // 5 $ mark math add --a 2 --b 3 $ curl -X POST http://127.0.0.1:3000/api/math/add \ -H "content-type: application/json" \ -H "authorization: Bearer $TOKEN" \ -d '{"a":2,"b":3}'Compose programs as JSON
A call can be the input of another call.
chain,map,conditionaland$refmake programs that you can store and send.{ "$proc": ["math", "add"], "input": { "a": { "$proc": ["math", "add"], "input": { "a": 2, "b": 3 } }, "b": 10 } }
Write it once, call it from everywhere
client.exec(["math", "add"], { a: 2, b: 3 })The registry runs in your process. No server.
Host 1 of 6. Each host uses the same registry.
What is in the box
Control flow as data
chain, parallel, conditional, tryCatch, map and reduce. A branch that is not selected does not run.
Tools as procedures
git, docker, pnpm, vitest, cue, the file system, MongoDB, SQLite and S3, each a package of typed procedures.
Middleware and streams
Retry, timeout, cache, circuit breaker and rate limit around each call. Streams with flow control on each transport.
Explore
The middleware lab →
The real middlewares run around a server that you break: latency, errors, a dead peer, a slow stream. Watch each request go through the layers.
The Composer →
Build a program with blocks, JSON or TypeScript, or start from the gallery. The Graph tab draws it as a tree of calls, and the trace shows each call.
The journey of one call →
Follow one streaming call through the middlewares, the transport, the server and the interceptors, over HTTP, WebSocket or MCP. Each step comes from the real code.
The status board →
The open work of the roadmap, the open pull requests and the open issues. Each build reads them again.