/** Header length: 16-byte session_id + 1-byte frame_type. */ export declare const SHELL_HEADER_LEN = 17; /** 16-byte raw UUID length (matches Rust `Uuid::as_bytes()` length). */ export declare const SESSION_ID_LEN = 16; /** Resize payload length: cols (u16 BE) + rows (u16 BE). */ export declare const RESIZE_PAYLOAD_LEN = 4; /** Wire-numeric frame type. Values are part of the public protocol — DO NOT renumber. */ export declare const FrameType: { readonly Data: 0; readonly Resize: 1; readonly Close: 2; readonly OpenControl: 3; readonly CloseControl: 4; readonly Sftp: 6; readonly SftpRoot: 7; }; export type FrameTypeValue = (typeof FrameType)[keyof typeof FrameType]; /** * Inverse lookup: byte → typed name. Returns `null` for unknown / reserved. * Mirrors Rust `FrameType::from_u8` exactly. */ export declare function frameTypeFromByte(b: number): FrameTypeValue | null; /** Generate a fresh 16-byte session id (UUID v4 raw bytes). */ export declare function newSessionId(): Buffer; /** * Convert a UUID string ("550e8400-e29b-41d4-a716-446655440000" or * already-stripped 32-hex form) to the 16-byte session id used on the wire. * Returns null on invalid input. Mirrors Rust `Uuid::parse_str` then `as_bytes`. */ export declare function sessionIdFromString(id: string): Buffer | null; /** Convert a 16-byte session id back to canonical UUID string (with dashes). */ export declare function sessionIdToString(bytes: Uint8Array): string | null; export interface ShellFrame { /** 16-byte raw session id (NOT a hex string). */ readonly sessionId: Uint8Array; readonly frameType: FrameTypeValue; readonly payload: Uint8Array; } /** * Build a `data` frame carrying raw PTY bytes (or browser keystrokes, the * wire is symmetric). Mirrors Rust `ShellFrame::data`. */ export declare function dataFrame(sessionId: Uint8Array, payload: Uint8Array): ShellFrame; /** * Build a `resize` frame. Payload is 4 big-endian bytes: cols u16 BE + rows u16 BE. * Mirrors Rust `ShellFrame::resize`. */ export declare function resizeFrame(sessionId: Uint8Array, cols: number, rows: number): ShellFrame; /** * Build a `close` frame (no payload). Mirrors Rust `ShellFrame::close`. */ export declare function closeFrame(sessionId: Uint8Array): ShellFrame; /** * Encode a frame to its on-wire byte representation. Matches the Rust * `ShellFrame::encode` exactly: `[16 session_id][1 frame_type][payload...]`. */ export declare function encodeFrame(frame: ShellFrame): Buffer; /** * Decode the on-wire bytes into a frame. Returns null if the buffer is * shorter than `SHELL_HEADER_LEN` (17 bytes) or the frame-type byte is * unknown / reserved. Mirrors Rust `ShellFrame::decode`. * * The payload is COPIED (not aliased) so callers can safely reuse the input * buffer for the next frame — mirrors the Rust comment about copying into * the reader task buffer. */ export declare function decodeFrame(bytes: Uint8Array): ShellFrame | null; /** * Decode a resize frame's payload into [cols, rows]. Returns null if the * payload is not exactly 4 bytes (defensive — encoder always emits 4 bytes * but a malformed peer might send something else). */ export declare function decodeResizePayload(payload: Uint8Array): { cols: number; rows: number; } | null; export declare const __RESERVED_FRAME_TYPE_5__: 5;