/**
 * Model detection utilities for capability checking
 */
import { IMAGE_GENERATION_MODELS } from "../core/constants.js";
/**
 * Check if model name is valid for detection functions
 */
function isValidModelName(modelName) {
    return typeof modelName === "string" && modelName.length > 0;
}
export function isGemini3Model(modelName) {
    if (!isValidModelName(modelName)) {
        return false;
    }
    return /^gemini-3(\.\d+)?(-.*)?$/i.test(modelName);
}
export function isGemini25Model(modelName) {
    if (!isValidModelName(modelName)) {
        return false;
    }
    return /^gemini-2\.5(-.*)?$/i.test(modelName);
}
export function supportsThinkingConfig(modelName) {
    if (!isValidModelName(modelName)) {
        return false;
    }
    const thinkingModels = [
        /^gemini-3/i,
        /^gemini-2\.5-pro/i,
        /^gemini-2\.5-flash/i,
    ];
    return thinkingModels.some((pattern) => pattern.test(modelName));
}
export function supportsPromptCaching(modelName) {
    if (!isValidModelName(modelName)) {
        return false;
    }
    const cachingModels = [
        /^gemini-3/i,
        /^gemini-2\.5/i,
        /^gpt-4/i,
        /^claude-3/i,
    ];
    return cachingModels.some((pattern) => pattern.test(modelName));
}
export function getMaxThinkingBudgetTokens(modelName) {
    if (!isValidModelName(modelName)) {
        return 10000;
    }
    if (/^gemini-3(\.\d+)?-pro/i.test(modelName)) {
        return 100000;
    }
    if (/^gemini-3(\.\d+)?-flash/i.test(modelName)) {
        return 50000;
    }
    if (/^gemini-2\.5/i.test(modelName)) {
        return 32000;
    }
    return 10000;
}
export function getModelFamily(modelName) {
    if (!isValidModelName(modelName)) {
        return "unknown";
    }
    if (/^gemini-3/i.test(modelName)) {
        return "gemini-3";
    }
    if (/^gemini-2\.5/i.test(modelName)) {
        return "gemini-2.5";
    }
    if (/^gemini-2/i.test(modelName)) {
        return "gemini-2";
    }
    if (/^gpt-4/i.test(modelName)) {
        return "gpt-4";
    }
    if (/^claude-3/i.test(modelName)) {
        return "claude-3";
    }
    return "unknown";
}
// Compiled once at module load — hasRestrictedOutputLimit() is called per
// request and previously rebuilt this array on every call.
const IMAGE_MODEL_PATTERNS = IMAGE_GENERATION_MODELS.map((m) => new RegExp(`^${m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"));
/**
 * Check if a model has restricted output token limit (32768 max)
 * This applies to:
 * - All Gemini 3 models (gemini-3-flash, gemini-3-pro, etc.)
 * - Image generation models (gemini-2.5-flash-image, gemini-3-pro-image-preview)
 */
export function hasRestrictedOutputLimit(modelName) {
    if (!isValidModelName(modelName)) {
        return false;
    }
    // Check for Gemini 3 models (anchored regex for consistency)
    if (/^gemini-3/i.test(modelName)) {
        return true;
    }
    if (IMAGE_MODEL_PATTERNS.some((pattern) => pattern.test(modelName))) {
        return true;
    }
    return false;
}
/**
 * Get the max output tokens for a model (32768 for restricted models)
 */
export const RESTRICTED_OUTPUT_TOKEN_LIMIT = 32768;
//# sourceMappingURL=modelDetection.js.map