Typed bindings

The worker protocol is published as machine-readable schemas. Point a code generator at them for typed request and response bindings in your language, instead of hand-writing the wire types.

Artifacts

Both live in schemas/ and are generated from the engine's Rust types.

FileCovers
protocol.schema.jsonEvery wire type, one JSON Schema. Top-level type Protocol.
worker.openapi.jsonThe worker endpoint: POST /, DecisionRequest to DecisionResponse.

Generating

Point a generator at protocol.schema.json. The examples commit the output as protocol.ts, protocol.go, or protocol.py.

TypeScript and Go, with quicktype:

npx quicktype --src-lang schema --lang typescript \
    --src schemas/protocol.schema.json --top-level Protocol \
    --just-types --prefer-unions -o protocol.ts

Swap --lang go --package main -o protocol.go for Go.

Python, with datamodel-code-generator:

datamodel-codegen \
    --input schemas/protocol.schema.json --input-file-type jsonschema \
    --output-model-type pydantic_v2.BaseModel --output protocol.py

For OpenAPI tooling, generate from worker.openapi.json instead.

Next