"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProviderChain = void 0;
exports.getProviderChain = getProviderChain;
exports.resetProviderChain = resetProviderChain;
const AICore_1 = require("../core/ai/AICore");
/**
 * Simplified Provider Chain for MyContext CLI
 *
 * Re-implemented as a wrapper around AICore to ensure unification.
 */
class ProviderChain {
    constructor() {
        this.clientType = "hybrid";
        this.supportsTools = true;
        this.supportsStreaming = false;
        // AICore is likely already initialized
        try {
            AICore_1.AICore.getInstance();
        }
        catch (e) {
            AICore_1.AICore.getInstance({
                workingDirectory: process.cwd(),
                fallbackEnabled: true
            });
        }
    }
    get client() {
        return AICore_1.AICore.getInstance().getBestClient();
    }
    hasApiKey() {
        return this.client.hasApiKey();
    }
    setApiKey(apiKey) {
        this.client.setApiKey(apiKey);
    }
    async checkConnection() {
        return this.client.checkConnection();
    }
    async generateText(prompt, options = {}) {
        return this.client.generateText(prompt, options);
    }
    async generateComponent(prompt, context, options = {}) {
        return this.client.generateComponent(prompt, context, options);
    }
    async generateComponentRefinement(componentCode, prompt, context, options = {}) {
        return this.client.generateComponentRefinement(componentCode, prompt, context, options);
    }
    async listModels() {
        return this.client.listModels();
    }
    async generateVisionText(prompt, imagePath, options = {}) {
        return AICore_1.AICore.getInstance().generateVisionText(prompt, imagePath, options);
    }
    async generateImage(prompt, outputPath, options = {}) {
        return AICore_1.AICore.getInstance().generateImage(prompt, outputPath, options);
    }
    // Legacy compatibility methods
    getPrimaryProvider() {
        return this.client;
    }
    getProvider(name) {
        return this.client;
    }
    getProviderStatus() {
        return [{
                name: "AICore",
                hasKey: this.hasApiKey(),
                connected: true
            }];
    }
    async checkAllConnections() {
        return this.getProviderStatus();
    }
    async cleanup() {
        if (this.client.cleanup) {
            await this.client.cleanup();
        }
    }
}
exports.ProviderChain = ProviderChain;
let providerChainInstance = null;
function getProviderChain() {
    if (!providerChainInstance) {
        providerChainInstance = new ProviderChain();
    }
    return providerChainInstance;
}
function resetProviderChain() {
    providerChainInstance = null;
}
//# sourceMappingURL=ProviderChain.js.map