export type RealtimeMode = "websocket" | "sse";
export interface RealtimeMessage {
    type: string;
    [key: string]: unknown;
}
export interface RealtimeTransportAdapter {
    readonly mode: RealtimeMode;
    isOpen(): boolean;
    send(message: RealtimeMessage): void;
    /**
     * Sends and resolves once the message is known to have reached the server (WebSocket: on
     * synchronous send; SSE: when the POST completes). Resolves false if it could not be delivered.
     * Used by callers that must not record server-side state until delivery is confirmed (e.g.
     * agent subscriptions).
     */
    sendWithAck(message: RealtimeMessage): Promise<boolean>;
    close(): void;
}
export declare function setReconnectHandler(fn: ((reason: string) => void) | null): void;
export interface EditorRealtimeHandle {
    /** Sends a client->server message over whichever transport is active. No-op if none is open. */
    send(message: RealtimeMessage): boolean;
    /** Sends and resolves once delivery to the server is confirmed (false if not delivered). */
    sendWithAck(message: RealtimeMessage): Promise<boolean>;
    /** True when a transport is attached and able to send. */
    isOpen(): boolean;
    /** "websocket" | "sse" | null when disconnected. */
    mode(): RealtimeMode | null;
    /** Drops the active transport so the hook's connect loop re-establishes it (recovery paths). */
    reconnect(reason: string): void;
}
/** Installs the global handle. Idempotent; call once at module load. */
export declare function ensureEditorRealtimeHandle(): EditorRealtimeHandle;
export declare function getEditorRealtime(): EditorRealtimeHandle;
/** Sets the active transport (called by the connection hook when WS/SSE attaches). */
export declare function setActiveTransport(transport: RealtimeTransportAdapter | null): void;
export declare function getActiveTransport(): RealtimeTransportAdapter | null;
export declare function createWebSocketAdapter(socket: WebSocket): RealtimeTransportAdapter;
export interface SseTransportCallbacks {
    onOpen: () => void;
    onMessage: (event: {
        data: string;
    }) => void;
    onError: (error: Event) => void;
    onSessionRevoked: () => void;
}
export interface SseTransport extends RealtimeTransportAdapter {
    readonly eventSource: EventSource;
}
/**
 * Opens an EventSource to the SSE stream and returns an adapter whose `send` POSTs client->server
 * messages through a per-session FIFO queue (HTTP POSTs have no ordering guarantee, unlike a
 * WebSocket). Consecutive pending `caret-position` messages collapse to the latest (the server
 * coalesces them anyway); all other message types preserve strict order.
 */
export declare function createSseTransport(sessionId: string, callbacks: SseTransportCallbacks): SseTransport;
