/**
 * Transport abstraction for action communication.
 *
 * Provides the `Transport` interface and `Transports` registry for managing
 * multiple transports with fallback behavior.
 *
 * @module
 */
import { z } from 'zod';
import type { JsonrpcMessageFromClientToServer, JsonrpcMessageFromServerToClient, JsonrpcNotification, JsonrpcRequest, JsonrpcResponseOrError, JsonrpcErrorResponse } from '../http/jsonrpc.js';
/** WebSocket close code for session revocation. */
export declare const WS_CLOSE_SESSION_REVOKED = 4001;
/** WebSocket close code — client timed out waiting for a response. */
export declare const WS_CLOSE_CLIENT_HEARTBEAT_TIMEOUT = 4002;
/** WebSocket close code — server timed out with no incoming activity. */
export declare const WS_CLOSE_SERVER_HEARTBEAT_TIMEOUT = 4003;
export declare const TransportName: z.ZodString;
export type TransportName = z.infer<typeof TransportName>;
/**
 * Per-call options accepted by every transport's `send`. Optional and
 * extensible — adding a field is non-breaking. Source of truth for the
 * shared option shape; `ActionPeerSendOptions` and `RpcClientCallOptions`
 * extend it.
 */
export interface TransportSendOptions {
    /**
     * Per-call cancellation. Bottoms out at
     * `FrontendWebsocketClient.request({signal})` on the WS path (sends the
     * shared `cancel` notification on abort) and at `fetch({signal})` on
     * HTTP. Backend transport has no per-call abort surface to honor.
     */
    signal?: AbortSignal;
    /**
     * Per-call durable-queue opt-in. Names the **client-authoritative vs
     * server-authoritative** distinction — server-authoritative consumers
     * (e.g. zzz completion calls) fail fast with `service_unavailable` when
     * the transport is down; client-authoritative consumers (games,
     * real-time apps) buffer and replay on reconnect because the user
     * already committed to the action at click time. Honored only by
     * `FrontendWebsocketTransport` on the `request_response` path (default
     * `false`). HTTP and backend transports ignore it; WS notifications
     * also ignore it and always fail-fast when disconnected (fire-and-forget
     * `connection.send` has no queue semantic).
     */
    queue?: boolean;
}
export interface Transport {
    transport_name: TransportName;
    send(message: JsonrpcRequest, options?: TransportSendOptions): Promise<JsonrpcResponseOrError>;
    send(message: JsonrpcNotification, options?: TransportSendOptions): Promise<JsonrpcErrorResponse | null>;
    send(message: JsonrpcMessageFromClientToServer, options?: TransportSendOptions): Promise<JsonrpcMessageFromServerToClient | null>;
    is_ready: () => boolean;
    dispose?: () => void;
}
export declare class Transports {
    #private;
    /**
     * Whether to allow fallback to other transports if the current one is not available.
     * @default true
     */
    allow_fallback: boolean;
    /**
     * Registers a transport. The first transport registered also becomes the current.
     *
     * @mutates this - inserts into `#transport_by_name`; sets `#current_transport`
     *   if no current is set
     */
    register_transport(transport: Transport): void;
    /**
     * Switch the current transport selection by name.
     *
     * @mutates this - sets `#current_transport`
     * @throws Error if no transport with `transport_name` has been registered
     */
    set_current_transport(transport_name: TransportName): void;
    /**
     * Resolve a transport. With `allow_fallback`, walks specified → current →
     * any-ready; without, returns the named transport (or current) only when
     * it's ready.
     *
     * @returns the resolved transport, or `null` when none is ready
     */
    get_transport(transport_name?: TransportName): Transport | null;
    is_ready(): boolean | null;
    get_current_transport(): Transport | null;
    get_current_transport_name(): TransportName | null;
    get_transport_by_name(transport_name: TransportName): Transport | null;
}
//# sourceMappingURL=transports.d.ts.map