import { CodexCliClient } from "./codex.js";
import { GeminiClient } from "./gemini.js";
import { GeminiWrapperClient } from "./geminiWrapper.js";
import { NvidiaClient } from "./nvidia.js";
import { OllamaClient } from "./ollama.js";
import { OpenRouterClient } from "./openrouter.js";
export function createModelClient(options) {
    if (options.provider === "gemini") {
        return new GeminiClient();
    }
    if (options.provider === "gemini-wrapper") {
        return new GeminiWrapperClient();
    }
    if (options.provider === "codex") {
        return new CodexCliClient({
            workspace: options.workspace ?? process.cwd()
        });
    }
    if (options.provider === "openrouter") {
        return new OpenRouterClient();
    }
    if (options.provider === "nvidia") {
        return new NvidiaClient();
    }
    return new OllamaClient(options.ollamaUrl);
}
export function readModelProvider(env = process.env) {
    return normalizeModelProvider(env.PATCHPILOT_PROVIDER ?? env.PATCHPILOT_MODEL_PROVIDER ?? "ollama");
}
export function normalizeModelProvider(value) {
    const normalizedValue = value.trim().toLowerCase();
    if (normalizedValue === "gemini" || normalizedValue === "google") {
        return "gemini";
    }
    if (normalizedValue === "gemini-wrapper" || normalizedValue === "geminiwrapper" || normalizedValue === "google-wrapper") {
        return "gemini-wrapper";
    }
    if (normalizedValue === "codex" || normalizedValue === "openai" || normalizedValue === "openai-codex") {
        return "codex";
    }
    if (normalizedValue === "openrouter" || normalizedValue === "open-router") {
        return "openrouter";
    }
    if (normalizedValue === "nvidia" || normalizedValue === "nim") {
        return "nvidia";
    }
    return "ollama";
}
//# sourceMappingURL=modelClient.js.map