@nodetool-ai/protocol
v0.8.2
Published
Shared message types and protocol definitions for the NodeTool workflow runtime
Readme
@nodetool-ai/protocol
Shared message types and protocol definitions for the NodeTool workflow runtime.
This is the base dependency for nearly every other package — it defines the wire types (graph nodes/edges, processing messages, type metadata, API schemas) that the kernel, runtime, websocket server, and clients all agree on.
Responsibilities
- Graph transport types (
NodeDescriptor,Edge) and correlation/lineage signals. - Processing message union (
output_update,edge_update,job_update, …), Zod-first: everyProcessingMessagevariant insrc/messages.tsis a Zod schema, with its TypeScript type derived viaz.infer(the two shapes Zod can't infer exactly — the recursiveTaskRef/StepRefpair — keep a hand-written interface with az.ZodType<...>-annotated schema instead).processingMessageSchemais the singlez.discriminatedUnion("type", ...)validator for the whole union;processingMessageSchemasindexes the per-type schemas by discriminator;is*guard functions (isJobUpdate,isChunk, …) do a cheap discriminant-only check, andisProcessingMessagedoes full structural validation. TypeMetadataparser and type-compatibility checks.- Zod schemas for the REST/tRPC boundary (
api-schemas/).
Usage
import type { NodeDescriptor, Edge } from "@nodetool-ai/protocol";
import { graphNode } from "@nodetool-ai/protocol";Develop
npm run build --workspace=packages/protocol # tsc build, then the JSON Schema step below
npm run test --workspace=packages/protocol # vitest
npm run lint --workspace=packages/protocol # tsc --noEmitImports use @nodetool-ai/<package>; never import from dist/. See the root
AGENTS.md for the monorepo build order.
Generated processing-messages JSON Schema
npm run build (via generate:processing-messages-schema, wired in after the
tsc step) converts processingMessageSchema to JSON Schema with
z.toJSONSchema and writes it to dist/processing-messages.schema.json — a
build artifact (dist/ is gitignored, like the rest of this package's output),
regenerated on every build rather than checked in. Non-TypeScript consumers —
the Python worker, external SDKs — validate wire messages against this file
instead of hand-copying the TS shapes (RELIABILITY_ARCHITECTURE.md §8.2).
npm run generate:processing-messages-schema --workspace=packages/protocol # (re)write it
npm run check:processing-messages-schema --workspace=packages/protocol # verify, no write (CI)