import { z } from "zod"; import { PROTOCOL_VERSION } from "./protocol-version"; import { runnerMessageSchema } from "./messages"; /** * The runner-protocol envelope (ADR-027): every wire message — both * directions — is wrapped in it. Carries the pinned protocol version and * the workspace-scoped auth token that the hello/ready handshake (and * every subsequent message) is gated on. */ export const envelopeSchema = z .object({ protocolVersion: z.literal(PROTOCOL_VERSION), /** * Workspace-scoped auth token. Scoped to exactly one workspace — * possession authorizes talking to that workspace's runner and * nothing else. */ token: z.string().min(1), message: runnerMessageSchema, }) .strict(); export type Envelope = z.infer;