/** Custom packet id for the components channel. * * 160-191 is toxcore's LOSSLESS range — a form must not be silently dropped. * decentlan owns 161 (session), 162 (dora), 163 (IP), 164 (rate); 165 is the * first free slot. Clients that don't implement this id never see the packet, * which is exactly the backward-compatibility story we want. */ export declare const PACKET_ID_CHAT_COMPONENTS = 165; /** Payload version. Receivers ignore payloads they don't know how to read * rather than best-effort parsing a future shape. */ export declare const COMPONENTS_WIRE_VERSION = 1; export declare const MAX_COMPONENTS = 12; export declare const MAX_OPTIONS = 40; export declare const MAX_LABEL_LEN = 120; export declare const MAX_ID_LEN = 64; export declare const MAX_VALUE_LEN = 512; export declare const MAX_CUSTOM_ID_LEN = 128; /** Hard ceiling on a decoded payload before we even try to parse it. */ export declare const MAX_PAYLOAD_BYTES: number; export type ComponentType = "select" | "submit" | "text" | "button" | "attachment"; export interface SelectOption { label: string; value: string; } export interface ChatComponent { type: ComponentType; id: string; label?: string; required?: boolean; default?: string; placeholder?: string; options?: SelectOption[]; } export interface ComponentsMessage { v: number; type: "components"; /** Chosen by the agent; echoed back so it can route the reply. */ custom_id: string; components: ChatComponent[]; } export interface InteractionMessage { v: number; type: "interaction"; custom_id: string; /** id of the submit/button that fired. */ component: string; values: Record; } /** * Validate a remote components payload. Returns null when nothing renderable * survives — the caller then shows only the text message, which is the correct * degraded state, never an error. */ export declare function parseComponentsMessage(raw: unknown): ComponentsMessage | null; /** Build the interaction reply. Values are the user's own input, but they are * bounded here too so a pathological local state can't emit an oversized * packet at the peer. */ export declare function buildInteraction(customId: string, component: string, values: Record): InteractionMessage; /** Decode a received packet. Returns null for anything malformed or oversized — * a peer must not be able to make us throw on the receive path. */ export declare function decodePacket(data: Uint8Array): ComponentsMessage | InteractionMessage | null; /** Validate an inbound interaction (the agent side of the channel). */ export declare function parseInteractionMessage(raw: unknown): InteractionMessage | null; export declare function encodePacket(msg: ComponentsMessage | InteractionMessage): Uint8Array;