/** §8.7 channel tag: a standalone SSP2 response message — a delta. */ export declare const REALTIME_TAG_DELTA = 0; /** §8.7 channel tag: one chunk of the in-flight sync round's byte * stream (request client→server, response server→client). */ export declare const REALTIME_TAG_ROUND = 1; export interface RealtimeHelloEvent { event: 'hello'; data: { protocolVersion: number; sessionId: string; actorId: string; clientId: string; cursor: number; latestCursor: number; requiresSync: boolean; timestamp: number; }; } export type WakeReason = 'delta-too-large' | 'catchup-required' | 'reset-required'; export interface RealtimeSyncEvent { event: 'sync'; data: { cursor: number; requiresPull: true; reason: WakeReason; timestamp: number; }; } export interface RealtimeHeartbeatEvent { event: 'heartbeat'; data: { timestamp: number; }; } /** §8.6.2 presence fanout kind — a closed set of three. */ export type PresenceKind = 'join' | 'update' | 'leave'; /** * Server → client presence fanout (§8.6.2): a scope-mate's presence for a * key the receiver holds changed. `doc` is the peer's document for * `join`/`update` and `null` for `leave`. An `error` variant carries a * client-runtime `presence.*` code back to the publisher (size cap / * forbidden, §8.6.2); it never fans out to peers. */ export interface RealtimePresenceEvent { event: 'presence'; data: { scopeKey: string; kind?: PresenceKind; actorId?: string; clientId?: string; doc?: Record | null; error?: string; timestamp?: number; }; } export type RealtimeServerEvent = RealtimeHelloEvent | RealtimeSyncEvent | RealtimeHeartbeatEvent | RealtimePresenceEvent; /** Client → server delta acknowledgement (§8.2). */ export interface RealtimeAck { type: 'ack'; cursor: number; } /** Client → server presence publish/leave (§8.6.2). `doc: null` = leave. */ export interface RealtimePresencePublish { event: 'presence'; data: { scopeKey: string; doc: Record | null; }; } export type ParsedRealtimeEvent = { known: true; event: RealtimeServerEvent; } | { known: false; eventName: string; }; /** Serialize a client→server presence publish/leave (§8.6.2). */ export declare function encodePresencePublish(scopeKey: string, doc: Record | null): string; /** Serialize a server→client presence fanout event (§8.6.2). */ export declare function encodePresenceFanout(scopeKey: string, kind: PresenceKind, actorId: string, clientId: string, doc: Record | null, timestamp: number): string; /** Serialize a server→client presence error directed at the publisher * (§8.6.2 `presence.too_large` / `presence.forbidden`). */ export declare function encodePresenceError(scopeKey: string, error: string, timestamp: number): string; export declare function parseRealtimeServerEvent(text: string): ParsedRealtimeEvent; /** * Parse a client → server presence publish/leave (§8.6.2). Used by the * server to validate inbound `presence` control messages. A malformed * message (missing/empty `scopeKey`, or a `doc` that is neither an object * nor `null`) throws a `DecodeError` — a known event with wrong-shape data * is never a tolerated variant (§8.1). */ export declare function parseRealtimePresencePublish(text: string): RealtimePresencePublish;