type BreakerPhase = 'closed' | 'open' | 'half-open'; declare class CircuitBreaker { private states; private threshold; private baseCooldownMs; constructor(threshold?: number, cooldownMs?: number); /** Record a failed invocation. Returns true if the breaker just opened. */ recordFailure(agent: string): boolean; /** Record a successful invocation. Closes the breaker, resets counters. */ recordSuccess(agent: string): void; /** Release a claimed half-open probe without treating caller cancellation, * policy denial, or a local watchdog as provider success/failure. */ recordNeutral(agent: string): void; /** * Check if an agent is currently blocked (breaker open AND cooldown still * active). After cooldown elapses we transition to half-open and *return * false for the first caller only* — that caller becomes the probe. * * NOTE: this method has a SIDE EFFECT (it claims the half-open probe). * It must therefore only be called at most once per actual invocation, * right when the caller commits to running the agent. Read-only callers * (routing filters, pre-call gates that may bail out) must use the pure * {@link peek} instead, otherwise the probe is silently consumed and the * breaker can get stuck in `half-open` forever (no paired record*). * Production routing uses {@link peek} + {@link acquireProbe}; `isOpen` * is retained for its documented probe-granting semantics. */ isOpen(agent: string): boolean; /** * Pure, side-effect-free view of whether an agent is currently blocked. * Unlike {@link isOpen} it NEVER grants the half-open probe, so it is safe * to call from `filter()` predicates and from pre-call gates that may * early-return before the agent is actually invoked. * * An `open` breaker whose cooldown has elapsed is reported as NOT blocked * (`false`) — it is eligible for the next call, which will claim the probe * via {@link acquireProbe}. */ peek(agent: string): boolean; /** * Claim the single half-open probe slot. Call this exactly once, at the * moment the caller commits to actually invoking the agent (i.e. paired * with a guaranteed downstream recordSuccess/recordFailure). Transitions * `open → half-open` once the cooldown has elapsed; no-op when the breaker * is `closed` or already `half-open`. */ acquireProbe(agent: string): void; /** Get status for display / debug. */ getStatus(agent: string): { failures: number; open: boolean; phase: BreakerPhase; openedAt: number | null; cooldownMs: number; }; /** List all agents currently blocked (open or half-open with active probe). */ listOpen(): string[]; /** * Manually clear breaker state. Pass an agent name to reset just that * one, or no argument to reset everything. Useful for an operator * `/router reset ` command. */ reset(agent?: string): void; private get; } export declare const circuitBreaker: CircuitBreaker; export {}; //# sourceMappingURL=circuit-breaker.d.ts.map