import { type IByteStream } from '../../srpc/SrpcByteStream';
import { type SrpcConnection } from '../../srpc/types';
export interface MeshRemoteConnectionTransport<TMeta> {
    reserveSenderIds(connection: MeshRemoteSrpcConnection<TMeta>): Promise<number[]>;
    releaseSenderIds?(connection: MeshRemoteSrpcConnection<TMeta>, ids: number[]): Promise<void>;
    disconnect(connection: MeshRemoteSrpcConnection<TMeta>, reason?: string): Promise<void>;
    writeStream(connection: MeshRemoteSrpcConnection<TMeta>, streamId: number, data: Uint8Array): Promise<void>;
    finishStream(connection: MeshRemoteSrpcConnection<TMeta>, streamId: number): Promise<void>;
    destroyStream(connection: MeshRemoteSrpcConnection<TMeta>, streamId: number, error?: unknown): Promise<void>;
    attachReceiver(connection: MeshRemoteSrpcConnection<TMeta>, streamId: number): Promise<void>;
    /** Optional v2 signal that an allocated sender ID became a live stream. */
    activateSender?(connection: MeshRemoteSrpcConnection<TMeta>, streamId: number): Promise<void>;
}
export interface MeshRemoteSrpcConnectionOptions<TMeta> {
    id: string;
    clientId: string;
    meta: TMeta;
    connectedAt: number;
    ownerNodeId: number;
    ownerProcessId?: string;
    ownerEndpointId?: string;
    ownerEndpointPublicKey?: string;
    /** Opaque v2 handle capability minted by the remote owner. */
    capability?: string;
    senderIds: number[];
    /** Whether the owning mesh link supports returning unused reservations. */
    supportsSenderIdRelease?: boolean;
    transport: MeshRemoteConnectionTransport<TMeta>;
}
export declare class MeshRemoteSrpcConnection<TMeta = object> implements SrpcConnection<TMeta> {
    readonly id: string;
    readonly clientId: string;
    readonly connectedAt: number;
    readonly ownerNodeId: number;
    readonly ownerProcessId?: string;
    readonly ownerEndpointId?: string;
    readonly ownerEndpointPublicKey?: string;
    readonly capability?: string;
    readonly byteStream: IByteStream;
    private readonly senderIds;
    private readonly activeSenderIds;
    private readonly transport;
    private readonly supportsSenderIdRelease;
    private readonly disconnectHandlers;
    private readonly backpressuredReceivers;
    private readonly receiverBufferedBytes;
    private _meta;
    private stale;
    private refillPending?;
    private lastUsedAt;
    constructor(options: MeshRemoteSrpcConnectionOptions<TMeta>);
    get connected(): boolean;
    resolveByteStream(): IByteStream;
    get meta(): TMeta;
    get idleSince(): number;
    get hasActiveStreams(): boolean;
    touch(): void;
    applyMetadata(metadata: unknown): void;
    close(reason?: string): Promise<void>;
    receiveWrite(streamId: number, data: Uint8Array): boolean;
    receiveFinish(streamId: number): void;
    receiveDestroy(streamId: number, error?: string): void;
    markStale(): void;
    takeReservedSenderIds(): number[];
    private finishStream;
    private destroyStream;
    private activateSender;
    private refillSenderIds;
    private assertConnected;
    private updateReceiverBufferedBytes;
    private clearReceiverPressure;
    private totalReceiverBufferedBytes;
    private releaseReservedSenderIds;
}
//# sourceMappingURL=mesh-srpc-remote-connection.d.ts.map