/**
 * @license
 * Copyright 2025 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import { GoogleGenerativeAI } from '@google/generative-ai';
/**
 * Google Gemini provider implementation
 */
export class GeminiProvider {
    name = 'gemini';
    client;
    constructor(config) {
        this.client = new GoogleGenerativeAI(config.apiKey);
    }
    async execute(prompt, options = {}) {
        const model = this.client.getGenerativeModel({
            model: options.model || 'gemini-pro',
        });
        const result = await model.generateContent(prompt);
        const response = result.response;
        return {
            text: response.text(),
            usage: {
                promptTokens: response.usageMetadata?.promptTokenCount || 0,
                completionTokens: response.usageMetadata?.candidatesTokenCount || 0,
                totalTokens: response.usageMetadata?.totalTokenCount || 0,
            },
            model: options.model || 'gemini-pro',
            finishReason: 'stop',
            metadata: {
                candidates: response.candidates?.length || 0,
                safetyRatings: response.candidates?.[0]?.safetyRatings,
            },
        };
    }
    async getModels() {
        // Gemini doesn't have a models API, return known models
        return [
            {
                id: 'gemini-pro',
                name: 'Gemini Pro',
                provider: 'gemini',
                contextWindow: 32768,
                supportsVision: false,
                supportsFunctionCalling: false,
                inputPricing: 0.0005, // $0.0005 per 1K characters
                outputPricing: 0.0015, // $0.0015 per 1K characters
            },
            {
                id: 'gemini-pro-vision',
                name: 'Gemini Pro Vision',
                provider: 'gemini',
                contextWindow: 16384,
                supportsVision: true,
                supportsFunctionCalling: false,
                inputPricing: 0.0005,
                outputPricing: 0.0015,
            },
            {
                id: 'gemini-1.5-pro',
                name: 'Gemini 1.5 Pro',
                provider: 'gemini',
                contextWindow: 1048576, // 1M tokens
                supportsVision: true,
                supportsFunctionCalling: true,
                inputPricing: 0.00125,
                outputPricing: 0.005,
            },
            {
                id: 'gemini-1.5-flash',
                name: 'Gemini 1.5 Flash',
                provider: 'gemini',
                contextWindow: 1048576,
                supportsVision: true,
                supportsFunctionCalling: true,
                inputPricing: 0.000075,
                outputPricing: 0.0003,
            },
        ];
    }
    async checkLimits() {
        // Gemini has different limits based on the plan
        // These are approximate free tier limits
        return {
            requestsPerMinute: 60,
            requestsPerDay: 1000,
            tokensPerMinute: 10000,
            tokensPerDay: 100000,
            currentUsage: {
                requestsToday: 0,
                tokensToday: 0,
                lastReset: new Date().toISOString().split('T')[0],
            },
        };
    }
    async validateConnection() {
        try {
            const model = this.client.getGenerativeModel({ model: 'gemini-pro' });
            await model.generateContent('Hello');
            return true;
        }
        catch {
            return false;
        }
    }
}
//# sourceMappingURL=gemini.js.map