const REASONING_EFFORT_ALIASES = {
    off: "none",
    none: "none",
    min: "low",
    low: "low",
    medium: "medium",
    med: "medium",
    mid: "medium",
    high: "high",
    xhigh: "xhigh",
    "x-high": "xhigh",
    "extra-high": "xhigh",
};
export function parseOpenAiReasoningEffort(raw, label = "reasoning effort") {
    const normalized = raw.trim().toLowerCase();
    const parsed = REASONING_EFFORT_ALIASES[normalized];
    if (parsed)
        return parsed;
    throw new Error(`Unsupported ${label}: ${raw} (expected none, low, medium, high, or xhigh)`);
}
export function parseOpenAiTextVerbosity(raw, label = "text verbosity") {
    const normalized = raw.trim().toLowerCase();
    if (normalized === "low" || normalized === "medium" || normalized === "high") {
        return normalized;
    }
    throw new Error(`Unsupported ${label}: ${raw} (expected low, medium, or high)`);
}
export function parseOpenAiServiceTier(raw, label = "service tier") {
    const normalized = raw.trim().toLowerCase();
    if (normalized === "default" ||
        normalized === "fast" ||
        normalized === "priority" ||
        normalized === "flex") {
        return normalized;
    }
    throw new Error(`Unsupported ${label}: ${raw} (expected default, fast, priority, or flex)`);
}
export function mergeModelRequestOptions(...entries) {
    const merged = {};
    for (const entry of entries) {
        if (!entry)
            continue;
        if (typeof entry.serviceTier === "string" && entry.serviceTier.trim().length > 0) {
            merged.serviceTier = entry.serviceTier.trim();
        }
        if (entry.reasoningEffort ?? entry.thinking) {
            merged.reasoningEffort = entry.reasoningEffort ?? entry.thinking;
        }
        if (entry.textVerbosity)
            merged.textVerbosity = entry.textVerbosity;
    }
    return Object.keys(merged).length > 0 ? merged : undefined;
}
/**
 * Merge request options for a specific provider.
 *
 * - `openaiGlobalDefault` comes from the persisted `openai.*` config block — a
 *   provider-scoped default that must NOT bleed into non-openai requests.
 * - `openaiOverride` comes from `--fast` / `--service-tier`, which are
 *   documented as OpenAI-only knobs. Also only for the openai provider.
 * - `cliReasoningEffortOverride` comes from the explicit `--thinking` CLI flag,
 *   which is cross-provider (the user opted in for this run). It is forwarded
 *   to whichever provider is dispatched.
 * - `attemptOptions` is the per-attempt options bag (from the model config or
 *   provider-prefixed CLI id) and applies to every provider.
 */
export function mergeRequestOptionsForProvider({ provider, openaiGlobalDefault, attemptOptions, openaiOverride, cliReasoningEffortOverride, }) {
    const cliReasoningEntry = cliReasoningEffortOverride
        ? { reasoningEffort: cliReasoningEffortOverride }
        : undefined;
    if (provider === "openai") {
        return mergeModelRequestOptions(openaiGlobalDefault, attemptOptions, openaiOverride, cliReasoningEntry);
    }
    return mergeModelRequestOptions(attemptOptions, cliReasoningEntry);
}
export function toOpenAiServiceTierParam(serviceTier) {
    const normalized = serviceTier?.trim();
    if (!normalized)
        return undefined;
    const lower = normalized.toLowerCase();
    if (lower === "default")
        return undefined;
    return lower === "fast" ? "priority" : normalized;
}
//# sourceMappingURL=model-options.js.map