/**
 * economy/economy-router — High-level EconomyRouter with tier catalog + circuit breaker.
 *
 * Promoted from forge/src/agents/shared/economy/forge-economy.ts (inline logic)
 * to a reusable SDK module.
 *
 * Design goals:
 *   - Tier catalog is data-driven (injected via EconomyRouterOpts.tiers)
 *   - Circuit breaker triggers on $/h threshold (configurable, default $10)
 *   - Cost recording with optional EventBusPort publish `cc.cost.recorded`
 *   - Multi-tenant isolation via forTenant()
 *
 * @public
 */
import type { EventBusPort } from "../ports/event-bus.js";
export interface ProviderTier {
    name: "free" | "cheap" | "mid" | "premium";
    costPerInputToken: number;
    costPerOutputToken: number;
    qualityScore: number;
}
export interface EconomyRouterOpts {
    tiers: ProviderTier[];
    hourlyBudgetUsd: number;
    monthlyBudgetUsd: number;
    defaultTier: ProviderTier["name"];
    /** Called when the circuit breaker opens. */
    onCircuitBreak?: (reason: string) => void;
    /** Optional event bus for publishing cc.cost.recorded events. */
    eventBus?: EventBusPort;
    /** Rolling window for hourly budget. Default: 3_600_000ms (1h). */
    windowMs?: number;
    /** Monthly window. Default: 30 * 24 * 3_600_000ms. */
    monthlyWindowMs?: number;
    /** Injected clock for testability. Default: Date.now. */
    _now?: () => number;
    /** Tenant identifier (set by forTenant). */
    _tenantId?: string;
}
export interface CostEntry {
    agentId: string;
    costUsd: number;
    inputTokens: number;
    outputTokens: number;
    ts: number;
}
export declare class EconomyRouter {
    private readonly _tiers;
    private readonly _opts;
    private readonly _hourlyWindowMs;
    private readonly _monthlyWindowMs;
    private readonly _now;
    private readonly _history;
    private _circuitOpen;
    private _circuitOpenedAt;
    /** Cooldown before circuit can auto-reset. 5 minutes. */
    private static readonly COOLDOWN_MS;
    constructor(opts: EconomyRouterOpts);
    /**
     * Select the most appropriate tier for a given complexity (0-1 scale).
     * Falls back to defaultTier if the mapped tier is not in the catalog.
     */
    selectTier(complexity: number, _agentId?: string): ProviderTier;
    /**
     * Record a completed cycle's cost. Publishes cc.cost.recorded if an
     * EventBusPort is provided.
     */
    recordCycle(agentId: string, costUsd: number, tokens: {
        input: number;
        output: number;
    }): void;
    /**
     * Total cost in the rolling hourly window.
     */
    hourlySpend(): number;
    /**
     * Total cost in the rolling monthly window.
     */
    monthlySpend(): number;
    /**
     * Check whether a new cycle may proceed given estimated cost.
     *
     * Returns `{ ok: false, reason }` if:
     *   - Circuit breaker is open
     *   - Estimated cost would push hourly spend over budget
     *   - Estimated cost would push monthly spend over budget
     */
    canProceed(estimatedCostUsd: number): {
        ok: true;
    } | {
        ok: false;
        reason: string;
    };
    /**
     * Create a scoped router for a specific tenant.
     *
     * The scoped router shares the same tier catalog and configuration
     * but maintains isolated spend history and circuit breaker state.
     */
    forTenant(tenantId: string): EconomyRouter;
    private _defaultTier;
}
//# sourceMappingURL=economy-router.d.ts.map