import { type AgentRpcError, type AgentRpcMeta, type AgentRpcRequest, type AgentRpcChannel } from "./agent-rpc.js";
export type GatewayRpcMutability = "read" | "write";
export interface GatewayRpcClassification {
    channel: AgentRpcChannel;
    mutability: GatewayRpcMutability;
    defaultTimeoutMs: number;
}
export interface GatewayRpcMetrics {
    activeRequests: number;
    completedRequests: number;
    cancelledRequests: number;
    deadlineExceededRequests: number;
    dedupedRequests: number;
    lateResponsesDropped: number;
    invalidRequests: number;
}
export declare function classifyGatewayRpcMethod(method: string): GatewayRpcClassification;
export declare function requiresIdempotencyKey(method: string): boolean;
export declare function buildAgentRpcMeta(method: string, options?: {
    now?: number;
    timeoutMs?: number;
    requestId?: string;
    idempotencyKey?: string;
    traceId?: string;
    channel?: AgentRpcChannel;
}): AgentRpcMeta;
export declare function requireGatewayRpcMeta(request: Pick<AgentRpcRequest, "method" | "meta">, now?: number): {
    ok: true;
    meta: AgentRpcMeta;
} | {
    ok: false;
    error: AgentRpcError;
};
export declare class GatewayRpcContract {
    private readonly now;
    private readonly active;
    private readonly idempotency;
    private readonly counters;
    constructor(options?: {
        now?: () => number;
    });
    begin(method: string, meta: AgentRpcMeta): {
        status: "started";
    } | {
        status: "deduped";
        result?: unknown;
        error?: AgentRpcError;
    } | {
        status: "rejected";
        error: AgentRpcError;
    };
    cancel(requestId: string, reason?: string): boolean;
    expire(requestId: string): boolean;
    settle(requestId: string, result?: unknown, error?: AgentRpcError): {
        accepted: true;
    } | {
        accepted: false;
        reason: "unknown" | "cancelled" | "deadline_exceeded";
    };
    metrics(): GatewayRpcMetrics;
}
