import WebSocket from 'ws';
import { type MeshLinkFrame, type MeshLinkFrameHeader } from './protocol';
export type MeshLinkRequestHandler = (peer: MeshLinkPeer, frame: MeshLinkFrame) => Promise<MeshLinkFrame>;
export interface MeshLinkIncomingBudget {
    activeRequests: number;
    activeBytes: number;
}
export declare class MeshLinkPeer {
    readonly processId: string;
    private readonly ws;
    private readonly maxFrameBytes;
    private readonly maxBufferedBytes;
    private readonly handler;
    readonly endpointId: string;
    private readonly incomingBudget?;
    /** Verified v2 endpoint signing key (SPKI DER/base64). */
    readonly publicKey: string;
    private readonly pending;
    private readonly closeHandlers;
    private closed;
    private closeNotified;
    private lastActivityAt;
    private lastPongAt;
    private activeIncomingRequests;
    private activeIncomingBytes;
    private readonly activeIncoming;
    /** Per-handler reservations that guarantee a completed-request tombstone can be retained. */
    private readonly activeIncomingTombstones;
    private activeIncomingTombstoneBytes;
    private readonly completedIncoming;
    private completedIncomingBytes;
    private readonly pingTimer;
    constructor(processId: string, ws: WebSocket, maxFrameBytes: number, maxBufferedBytes: number, handler: MeshLinkRequestHandler, endpointId?: string, incomingBudget?: MeshLinkIncomingBudget | undefined, 
    /** Verified v2 endpoint signing key (SPKI DER/base64). */
    publicKey?: string);
    get connected(): boolean;
    get idleSince(): number;
    get hasActiveWork(): boolean;
    onClose(handler: () => void): () => void;
    request(header: Omit<MeshLinkFrameHeader, 'version' | 'id'>, body: Uint8Array, timeoutMs: number): Promise<MeshLinkFrame>;
    send(header: Omit<MeshLinkFrameHeader, 'version'>, body?: Uint8Array): void;
    close(code?: number, reason?: string): void;
    private handleMessage;
    private releaseIncomingRequest;
    private handleClose;
    private sendReply;
    private rememberCompleted;
    private createCompletedTombstone;
    private canReserveCompletedRequest;
    private storeCompleted;
    private removeCompleted;
    private pruneCompletedIncoming;
    private ping;
}
//# sourceMappingURL=peer.d.ts.map