import { z } from "zod"; /** * Terminal stream binary frame codec (architecture/websocket-protocol.md § Binary frames, * features/terminals.md § Binary stream protocol). * * Frame layout: `[1-byte opcode][1-byte slot][payload]`. * - `slot` demuxes multiple terminals on one socket (0–255). * - Output/Input/Snapshot/Restore payloads are raw bytes (pass-through). * - Resize payload is UTF-8 JSON `{ rows, cols }`. * * Uses `Uint8Array` (not Node `Buffer`) so the codec runs in browser/RN as well as Node. */ /** * Terminal frame opcodes. `Restore` (0x05) carries a reflowable-tier snapshot — a serialization of * the daemon's screen model, not raw bytes — for a subscription that negotiated the reflowable * restore mode (`terminals.md` § Restore / snapshot tier 2, sprint-053/task-004/005). */ export declare const TerminalOpcode: { readonly Output: 1; readonly Input: 2; readonly Resize: 3; readonly Snapshot: 4; readonly Restore: 5; }; export type TerminalOpcodeName = keyof typeof TerminalOpcode; export type TerminalOpcodeValue = (typeof TerminalOpcode)[TerminalOpcodeName]; /** Resize payload schema (`{ rows, cols }`, non-negative integers). */ export declare const terminalResizeSchema: z.ZodObject<{ rows: z.ZodNumber; cols: z.ZodNumber; }, "strip", z.ZodTypeAny, { rows: number; cols: number; }, { rows: number; cols: number; }>; export type TerminalResize = z.infer; export type TerminalFrame = { opcode: "Output"; slot: number; data: Uint8Array; } | { opcode: "Input"; slot: number; data: Uint8Array; } | { opcode: "Resize"; slot: number; rows: number; cols: number; } | { opcode: "Snapshot"; slot: number; data: Uint8Array; } | { opcode: "Restore"; slot: number; data: Uint8Array; }; /** Thrown when a frame cannot be decoded (too short, unknown opcode, bad payload). */ export declare class TerminalFrameError extends Error { constructor(message: string); } /** Encode a typed terminal frame to bytes. */ export declare function encodeTerminalFrame(frame: TerminalFrame): Uint8Array; /** Decode bytes into a typed terminal frame. Throws `TerminalFrameError` on invalid input. */ export declare function decodeTerminalFrame(bytes: Uint8Array): TerminalFrame; /** Returns the decoded frame, or `null` instead of throwing (safe handling of unknown opcodes). */ export declare function tryDecodeTerminalFrame(bytes: Uint8Array): TerminalFrame | null; //# sourceMappingURL=terminal-stream-protocol.d.ts.map