/**
 * GatewayRpcConnection — the JSON-RPC request lifecycle for the gateway contract.
 *
 * Owns the per-request bookkeeping: the gateway contract (dedup/settle/expire), the
 * in-flight request ledger (id → meta), and the deadline timers; plus the wire-side
 * response builders. Extracted from StdioServer to separate its "protocol routing"
 * concern from its "runtime state container" concern — StdioServer keeps the
 * transport, message dispatch, and ACP routing, and delegates the request-lifecycle
 * mechanics here through thin sendResponse/sendError methods.
 *
 * It does NOT own the transport: the raw frame writer is injected via `write`, so the
 * server stays in charge of transport ownership / start / close / ACP routing.
 *
 * Covered by stdio-server.contract.test.ts (contract gate, dedup, deadline expiry,
 * late-response drop).
 */
import { GatewayRpcContract, type AgentRpcError, type AgentRpcRequest } from "../protocol/wire/index.js";
export interface GatewayRpcConnectionDeps {
    /** Raw transport send — writes one JSON-RPC frame to the wire. */
    write: (msg: unknown) => void;
    log: (message: string) => void;
}
export declare class GatewayRpcConnection {
    private readonly contract;
    private readonly inflight;
    private readonly deadlineTimers;
    private readonly write;
    private readonly log;
    constructor(deps: GatewayRpcConnectionDeps);
    /** The gateway contract — exposed for control-handler metrics/cancel. */
    get rpcContract(): GatewayRpcContract;
    /** True while a request id is in flight (no response settled yet). */
    hasInFlight(id: string | number): boolean;
    /**
     * Run the gateway contract gate for an inbound request (caller guarantees the
     * id is present and the method is not meta-optional). Returns true if the caller
     * should dispatch; false if the request was rejected/deduped — in which case a
     * response has already been written.
     */
    begin(id: string | number, msg: AgentRpcRequest): boolean;
    sendResponse(id: string | number, result?: unknown, error?: AgentRpcError): void;
    /** Convenience over sendResponse for handlers that build the error inline. */
    sendError(id: string | number, code: AgentRpcError["code"], message: string, data?: unknown): void;
    /** Clear the in-flight ledger + deadline timers (server shutdown). */
    dispose(): void;
    private clearLifecycle;
    private sendContractError;
    private sendContractErrorOrResult;
    private scheduleDeadline;
}
