Files
openclaw/docs/concepts/typebox.md

37 lines
1.0 KiB
Markdown
Raw Normal View History

---
summary: "TypeBox schemas as the single source of truth for the gateway protocol"
read_when:
- Updating protocol schemas or codegen
---
2026-01-08 23:06:56 +01:00
# TypeBox as protocol source of truth
2026-01-08 23:06:56 +01:00
Last updated: 2026-01-08
2026-01-08 23:06:56 +01:00
TypeBox schemas define the Gateway control plane (connect/req/res/event frames and
payloads). All generated artifacts must come from these schemas.
## Current pipeline
2026-01-08 23:06:56 +01:00
- `pnpm protocol:gen`
- writes the JSON Schema output (draft07)
- `pnpm protocol:gen:swift`
- generates Swift gateway models
- `pnpm protocol:check`
- runs both generators and verifies the output is committed
2026-01-08 23:06:56 +01:00
## Swift codegen behavior
2026-01-08 23:06:56 +01:00
The Swift generator emits:
2026-01-08 23:06:56 +01:00
- `GatewayFrame` enum with `req`, `res`, `event`, and `unknown` cases
- Strongly typed payload structs/enums
- `ErrorCode` values and `GATEWAY_PROTOCOL_VERSION`
2026-01-08 23:06:56 +01:00
Unknown frame types are preserved as raw payloads for forward compatibility.
2026-01-08 23:06:56 +01:00
## When you change schemas
2026-01-08 23:06:56 +01:00
1) Update the TypeBox schemas.
2) Run `pnpm protocol:check`.
3) Commit the regenerated schema + Swift models.