import type { EmailDriver } from "../types.mjs"; /** Circuit-breaker states: * - `closed` — requests pass through * - `open` — requests short-circuit with a CANCELLED error * - `half-open` — a probe request is allowed; success closes, failure re-opens */ export type CircuitState = "closed" | "open" | "half-open"; export interface CircuitBreakerOptions { /** Consecutive failures that trip the breaker. Default: 5. */ threshold?: number; /** How long to stay `open` before transitioning to `half-open`. Default: 30s. */ cooldownMs?: number; /** Called on state transitions — useful for telemetry. */ onStateChange?: (state: CircuitState) => void; /** Injected for tests. */ now?: () => number; } /** Wrap a driver in a circuit breaker. Prevents cascading failures when a * provider is down by short-circuiting after `threshold` consecutive * errors. */ export declare function withCircuitBreaker(driver: EmailDriver, options?: CircuitBreakerOptions): EmailDriver;