Reference
Protocol overview
The canonical wire format package and where its pieces are documented.
packages/protocol (@repo/protocol) is the source of truth for the Nodus
wire format. It is a pure schema/type package:
- no dependency on
packages/core,relay-client, orwebrtc-transport; - zod runtime validation of every message (not just TypeScript types);
- a single
parseMessage(raw)entry point that validates the envelope, dispatches to the type-specific schema, and returns a typed result or a structured error — it never throws on malformed input.
Rust and Go do not import the TypeScript types. They reference generated JSON Schema:
cd packages/protocol
pnpm generate:schemas # emits schemas/*.schema.json + manifest.jsonGenerated artifacts are deterministic and committed, so Rust and Go treat them as the canonical wire contract.
Envelope
All messages share a common envelope before their type-specific payload:
{
"type": "shard_upload",
"schema_version": "1.8",
"message_id": "uuid",
"payload": { "...": "..." }
}Field naming is snake_case on the wire; TypeScript maps to/from camelCase
at the serialize boundary.