import type { WsClientEvent } from './types.js';
import { type InternalOrigin } from './origin.js';
export type EventHandler<T = WsClientEvent> = (event: T) => void;
export interface WsClientOptions {
    token: string | (() => string | Promise<string>);
    baseUrl?: string;
    path?: string;
    nodeRegistration?: () => Record<string, unknown> | Promise<Record<string, unknown>>;
    autoAckDeliveries?: boolean;
    maxReconnectAttempts?: number;
    reconnectJitter?: boolean;
    reconnectBaseDelayMs?: number;
    reconnectMaxDelayMs?: number;
    circuitBreakerMaxAttempts?: number;
    /** Log warnings for dropped/malformed WebSocket messages via console.warn. */
    debug?: boolean;
    /**
     * Optional User-Agent-style originActor identifier, forwarded as the `originActor`
     * query param (browsers can't set custom WS headers). See {@link sanitizeOriginActor}.
     */
    originActor?: string;
    /**
     * Optional Agent Relay distinct telemetry id, forwarded as the
     * `agent_relay_distinct_id` query param (browsers can't set custom WS
     * headers). Invalid values are dropped.
     */
    agentRelayDistinctId?: string;
    /**
     * Optional Agent Relay Cloud user id of the signed-in operator, forwarded as
     * the `agent_relay_user_id` query param. Doubles as the distinct id when
     * `agentRelayDistinctId` is unset.
     */
    agentRelayUserId?: string;
    /** Optional hashed machine id, forwarded as `agent_relay_machine_id`. */
    agentRelayMachineId?: string;
    /** Optional Agent Relay Cloud organization id, for group analytics. */
    agentRelayOrgId?: string;
    /** Optional organization slug, for readable analytics breakdowns. */
    agentRelayOrgSlug?: string;
}
export declare function withInternalWsOrigin<T extends WsClientOptions>(options: T, origin: InternalOrigin): T;
export declare class WsClient {
    private token;
    private baseUrl;
    private path;
    private nodeRegistration?;
    private autoAckDeliveries;
    private nodeMode;
    private lastNodeRegistration;
    private ws;
    private connecting;
    private handlers;
    private isOpen;
    private reconnectAttempt;
    private maxReconnectAttempts;
    private reconnectJitter;
    private reconnectBaseDelayMs;
    private reconnectMaxDelayMs;
    private circuitBreakerMaxAttempts;
    private permanentlyDisconnected;
    private reconnectTimer;
    private connectTimer;
    private connectTimeoutMs;
    private pingTimer;
    private closed;
    private debug;
    private originClient;
    private originVersion;
    private originActor?;
    private identity;
    /** Highest `agent_seq` observed across delivered events; null until the first stamped event. */
    private lastSeenSeq;
    /** Receive time of the last seq-stamped event, used as `since` for DB-backed replay. */
    private lastEventAt;
    /** Recently dispatched event ids (insertion-ordered for LRU eviction) for replay dedupe. */
    private seenEventIds;
    constructor(options: WsClientOptions);
    connect(): void;
    private openSocket;
    private handleOpen;
    disconnect(): void;
    reconnect(): void;
    subscribe(channels: string[]): void;
    unsubscribe(channels: string[]): void;
    on(event: string, handler: EventHandler): () => void;
    off(event: string, handler: EventHandler): void;
    get connected(): boolean;
    private emit;
    private handleNodeMessage;
    private emitServerLikeEvent;
    private transformServerLikeEvent;
    private sendJson;
    /**
     * Request replay of events missed while disconnected. The server replays its
     * resync ring past `last_seen_seq`, falls back to a DB-backed replay from
     * `since` when the gap exceeds the ring, and answers with `resync_ack`.
     * No-op until at least one seq-stamped event has been received.
     */
    private sendResync;
    private rememberEventId;
    private startPing;
    private stopPing;
    private clearConnectTimer;
    private computeReconnectDelayMs;
    private tripCircuitBreaker;
    private scheduleReconnect;
}
//# sourceMappingURL=ws.d.ts.map