/**
 * Model Routing Facade
 *
 * Encapsulates model routing and cost tracking operations.
 * This facade handles:
 * - Model selection and routing decisions
 * - Cost tracking and limits
 * - Routing statistics and savings calculation
 */
/**
 * Facade for model routing and cost management in agents.
 *
 * Responsibilities:
 * - Enabling/disabling model routing
 * - Tracking routing decisions
 * - Calculating costs and savings
 * - Providing routing statistics
 */
export class ModelRoutingFacade {
    modelRouter;
    costTracker;
    useModelRouting = false;
    lastRoutingDecision = null;
    sessionCostLimit = 10;
    sessionCost = 0;
    constructor(deps) {
        this.modelRouter = deps.modelRouter;
        this.costTracker = deps.costTracker;
    }
    // ============================================================================
    // Model Routing
    // ============================================================================
    /**
     * Enable or disable model routing
     */
    setModelRouting(enabled) {
        this.useModelRouting = enabled;
    }
    /**
     * Check if model routing is enabled
     */
    isModelRoutingEnabled() {
        return this.useModelRouting;
    }
    /**
     * Get the model router instance (for advanced operations)
     */
    getModelRouter() {
        return this.modelRouter;
    }
    /**
     * Get the last routing decision
     */
    getLastRoutingDecision() {
        return this.lastRoutingDecision;
    }
    /**
     * Set the last routing decision (called after routing)
     */
    setLastRoutingDecision(decision) {
        this.lastRoutingDecision = decision;
    }
    /**
     * Get comprehensive model routing statistics
     */
    getStats() {
        return {
            enabled: this.useModelRouting,
            totalCost: this.modelRouter.getTotalCost(),
            savings: this.modelRouter.getEstimatedSavings(),
            usageByModel: Object.fromEntries(this.modelRouter.getUsageStats()),
            lastDecision: this.lastRoutingDecision,
        };
    }
    /**
     * Format routing statistics as a human-readable string
     */
    formatStats() {
        const stats = this.getStats();
        const lines = [
            'Model Routing Statistics',
            `|- Enabled: ${stats.enabled ? 'Yes' : 'No'}`,
            `|- Total Cost: $${stats.totalCost.toFixed(4)}`,
            `|- Savings: $${stats.savings.saved.toFixed(4)} (${stats.savings.percentage.toFixed(1)}%)`,
        ];
        if (stats.lastDecision) {
            lines.push(`|- Last Model: ${stats.lastDecision.recommendedModel}`);
            lines.push(`\\- Reason: ${stats.lastDecision.reason}`);
        }
        else {
            lines.push('\\- No routing decisions yet');
        }
        return lines.join('\n');
    }
    // ============================================================================
    // Cost Management
    // ============================================================================
    /**
     * Get current session cost
     */
    getSessionCost() {
        return this.sessionCost;
    }
    /**
     * Add to session cost
     */
    addSessionCost(cost) {
        this.sessionCost += cost;
    }
    /**
     * Set session cost directly
     */
    setSessionCost(cost) {
        this.sessionCost = cost;
    }
    /**
     * Get session cost limit
     */
    getSessionCostLimit() {
        return this.sessionCostLimit;
    }
    /**
     * Set session cost limit
     */
    setSessionCostLimit(limit) {
        this.sessionCostLimit = limit;
    }
    /**
     * Check if session cost limit has been reached
     */
    isSessionCostLimitReached() {
        return this.sessionCost >= this.sessionCostLimit;
    }
    /**
     * Get the cost tracker instance (for advanced operations)
     */
    getCostTracker() {
        return this.costTracker;
    }
}
//# sourceMappingURL=model-routing-facade.js.map