import { EventEmitter } from 'node:events';
import { Socket } from 'node:net';
export interface RpcRequest {
    id: number;
    method: string;
    params?: unknown;
}
export interface RpcResponse {
    id: number;
    ok: boolean;
    result?: unknown;
    error?: RpcErrorPayload;
}
interface RpcErrorPayload {
    message: string;
    name?: string;
    code?: unknown;
    errno?: unknown;
}
export type RpcHandler = (method: string, params: unknown, peer: RpcPeer) => Promise<unknown> | unknown;
export declare class RpcPeer extends EventEmitter {
    private readonly socket;
    private readonly handler?;
    private nextId;
    private buffer;
    private readonly pending;
    constructor(socket: Socket, handler?: RpcHandler | undefined);
    call<T = unknown>(method: string, params?: unknown): Promise<T>;
    close(): void;
    private receive;
    private dispatch;
    private write;
}
export declare function listenRpc(port: number, handler: RpcHandler): Promise<{
    port: number;
    close: () => Promise<void>;
}>;
export declare function connectRpc(port: number): Promise<RpcPeer>;
export {};
//# sourceMappingURL=mysql-session-rpc.d.ts.map