import { type MessageFamily } from "./families.ts"; import { type QosLane } from "./lanes.ts"; /** * A single agentic-channel frame: the QoS lane it rides, the message family it * belongs to, a monotonic sequence number (used by the relay for * resume-from-offset), and a JSON-serialisable family payload. * * The codec is an ENVELOPE codec — it does not interpret `payload` beyond * round-tripping it as JSON. Per-family payload shape is validated separately * (see `payloads.ts`). */ export interface Frame { readonly lane: QosLane; readonly family: MessageFamily; readonly seq: number; readonly payload: unknown; } /** * Wire layout (all integers big-endian, unsigned): * * offset size field * 0 2 magic 0x4E41 ("NA") * 2 1 version = 1 * 3 1 lane code 0=control | 1=interactive | 2=bulk * 4 1 family code 1..9 (see FAMILY_CODES) * 5 4 seq uint32 * 9 4 payloadLen uint32 (bytes of UTF-8 JSON that follow) * 13 N payload UTF-8 JSON */ export declare const FRAME_MAGIC = 20033; export declare const FRAME_VERSION = 1; export declare const FRAME_HEADER_BYTES = 13; export declare const MAX_SEQ = 4294967295; export type FrameDecodeErrorCode = "empty" | "short-header" | "bad-magic" | "unsupported-version" | "unknown-lane" | "unknown-family" | "truncated-payload" | "trailing-bytes" | "invalid-payload-json"; export declare class FrameDecodeError extends Error { readonly code: FrameDecodeErrorCode; constructor(code: FrameDecodeErrorCode, message: string); } export type FrameEncodeErrorCode = "invalid-lane" | "invalid-family" | "invalid-seq" | "unserialisable-payload"; export declare class FrameEncodeError extends Error { readonly code: FrameEncodeErrorCode; constructor(code: FrameEncodeErrorCode, message: string); } export declare function encodeFrame(frame: Frame): Uint8Array; export declare function decodeFrame(bytes: Uint8Array): Frame;