/**
 * Circuit breaker + backpressure for MCP tool calls.
 *
 * Circuit breaker: track p99 latency over a rolling window per tool.
 * If p99 exceeds CIRCUIT_TRIP_MS, tool is force-gated (async even for fast calls).
 * Resets automatically after RESET_WINDOW_MS of clean calls.
 *
 * Backpressure: global in-flight counter. If above QUEUE_CAPACITY,
 * return {busy: true, retryAfterMs} instead of queuing more work.
 */
export type CircuitState = 'closed' | 'open' | 'half-open';
export interface CircuitStats {
    tool: string;
    state: CircuitState;
    p99Ms: number;
    sampleCount: number;
    trippedAt?: number;
}
declare class CircuitManager {
    private circuits;
    private inFlight;
    private getCircuit;
    /** Check backpressure BEFORE enqueuing. Returns retryAfterMs or 0 if OK. */
    checkCapacity(): number;
    /** True if circuit is open (tool force-gated to async). */
    isForceAsync(tool: string): boolean;
    /** Record a completed call. Pass durationMs for p99 tracking. */
    recordComplete(tool: string, durationMs: number, success: boolean): void;
    /** Call when work starts (increments in-flight). */
    recordStart(tool: string): void;
    getStats(tool: string): CircuitStats;
    getAllStats(): CircuitStats[];
    getInFlight(): number;
}
export declare function getCircuitManager(): CircuitManager;
export declare function checkBackpressure(): {
    ok: boolean;
    retryAfterMs?: number;
};
export {};
