"use strict";
/**
 * Model Warnings — Concern G
 *
 * Emits console warnings when the active model (or any tier model in composite
 * variants) is flagged as broken in the model catalog.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.warnBrokenModels = void 0;
const ui_1 = require("../../utils/ui");
const model_config_1 = require("../config/model-config");
const model_catalog_1 = require("../model-catalog");
/**
 * Check all active models for known issues and emit warnings.
 *
 * For composite variants, checks every tier model.
 * For simple providers, checks the currently configured model.
 */
function warnBrokenModels(context) {
    const { provider, cfg, skipLocalAuth } = context;
    if (cfg.isComposite && cfg.compositeTiers) {
        // Check all tier models in composite variant
        const tiers = ['opus', 'sonnet', 'haiku'];
        for (const tier of tiers) {
            const tierConfig = cfg.compositeTiers[tier];
            if (tierConfig && (0, model_catalog_1.isModelBroken)(tierConfig.provider, tierConfig.model)) {
                const modelEntry = (0, model_catalog_1.findModel)(tierConfig.provider, tierConfig.model);
                const issueUrl = (0, model_catalog_1.getModelIssueUrl)(tierConfig.provider, tierConfig.model);
                console.error('');
                console.error((0, ui_1.warn)(`${tier} tier: ${modelEntry?.name || tierConfig.model} has known issues with Claude Code`));
                console.error('    Tool calls will fail. Consider changing the model in config.yaml.');
                if (issueUrl) {
                    console.error(`    Tracking: ${issueUrl}`);
                }
                console.error('');
            }
        }
    }
    else {
        const currentModel = (0, model_config_1.getCurrentModel)(provider, cfg.customSettingsPath);
        if (currentModel && (0, model_catalog_1.isModelBroken)(provider, currentModel)) {
            const modelEntry = (0, model_catalog_1.findModel)(provider, currentModel);
            const issueUrl = (0, model_catalog_1.getModelIssueUrl)(provider, currentModel);
            const replacementModel = (0, model_catalog_1.getSuggestedReplacementModel)(provider, currentModel);
            console.error('');
            console.error((0, ui_1.warn)(`${modelEntry?.name || currentModel} has known issues with Claude Code`));
            if (replacementModel) {
                console.error(`    Tool calls will fail. Use "${replacementModel}" instead.`);
            }
            else {
                console.error('    Tool calls will fail. Consider changing the model in config.yaml.');
            }
            if (issueUrl) {
                console.error(`    Tracking: ${issueUrl}`);
            }
            if (skipLocalAuth) {
                console.error('    Note: Model may be overridden by remote proxy configuration.');
            }
            else {
                console.error(`    Run "ccs ${provider} --config" to change model.`);
            }
            console.error('');
        }
    }
}
exports.warnBrokenModels = warnBrokenModels;
//# sourceMappingURL=model-warnings.js.map