/**
 * Sampling-parameter policy for provider model calls.
 *
 * Some reasoning models (Anthropic Opus 4.7+, OpenAI o-series, catalog entries
 * flagged `reasoning: true`) reject `temperature` / `top_p` / `top_k`. The
 * runtime omits those fields rather than failing at the provider.
 */
/** Provider-native ids that reject sampling params even without curated metadata. */
export function providerModelIdDisallowsSampling(providerModelId) {
    const id = providerModelId.toLowerCase();
    // Anthropic Opus 4.7 generation and later.
    if (/^claude-opus-4-(?:7|[89]|\d{2,})/.test(id))
        return true;
    // OpenAI reasoning / o-series models.
    if (/^o[0-9]/.test(id))
        return true;
    return false;
}
/** Whether a resolved model should not receive temperature / top_p / top_k. */
export function modelDisallowsSampling(providerModelId, capabilities) {
    if (capabilities?.reasoning)
        return true;
    return providerModelIdDisallowsSampling(providerModelId);
}
/** Return temperature only when the model accepts sampling parameters. */
export function resolveTemperatureForModel(providerModelId, capabilities, temperature) {
    if (typeof temperature !== 'number')
        return undefined;
    if (modelDisallowsSampling(providerModelId, capabilities))
        return undefined;
    return temperature;
}
const SAMPLING_PARAM_HINT = 'The selected model does not support temperature. Choose a non-reasoning text model (e.g. Claude Sonnet) in Settings > AI.';
/** Map provider sampling rejections to an actionable admin message. */
export function samplingParamProviderMessage(providerMessage) {
    const lower = providerMessage.toLowerCase();
    if (lower.includes('temperature') &&
        (lower.includes('deprecated') ||
            lower.includes('not support') ||
            lower.includes('unsupported') ||
            lower.includes('invalid') ||
            lower.includes('removed'))) {
        return SAMPLING_PARAM_HINT;
    }
    if ((lower.includes('top_p') || lower.includes('top_k')) &&
        (lower.includes('not support') || lower.includes('unsupported') || lower.includes('invalid'))) {
        return SAMPLING_PARAM_HINT;
    }
    return undefined;
}
//# sourceMappingURL=sampling.js.map