/**
 * @license
 * Copyright 2025 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import Anthropic from '@anthropic-ai/sdk';
/**
 * Anthropic provider implementation
 */
export class AnthropicProvider {
    name = 'anthropic';
    client;
    constructor(config) {
        this.client = new Anthropic({ apiKey: config.apiKey });
    }
    async execute(prompt, options = {}) {
        const message = await this.client.messages.create({
            model: options.model || 'claude-3-sonnet-20240229',
            max_tokens: options.maxTokens || 4096,
            temperature: options.temperature ?? 0.7,
            messages: [{ role: 'user', content: prompt }],
            stop_sequences: options.stopSequences,
        });
        const content = message.content[0];
        const text = content.type === 'text' ? content.text : '';
        return {
            text,
            usage: {
                promptTokens: message.usage.input_tokens,
                completionTokens: message.usage.output_tokens,
                totalTokens: message.usage.input_tokens + message.usage.output_tokens,
            },
            model: message.model,
            finishReason: message.stop_reason || 'stop',
            metadata: {
                id: message.id,
                type: message.type,
                role: message.role,
            },
        };
    }
    async getModels() {
        // Anthropic doesn't have a models API, return known models
        return [
            {
                id: 'claude-3-opus-20240229',
                name: 'Claude 3 Opus',
                provider: 'anthropic',
                contextWindow: 200000,
                supportsVision: true,
                supportsFunctionCalling: true,
                inputPricing: 0.015,
                outputPricing: 0.075,
            },
            {
                id: 'claude-3-sonnet-20240229',
                name: 'Claude 3 Sonnet',
                provider: 'anthropic',
                contextWindow: 200000,
                supportsVision: true,
                supportsFunctionCalling: true,
                inputPricing: 0.003,
                outputPricing: 0.015,
            },
            {
                id: 'claude-3-haiku-20240307',
                name: 'Claude 3 Haiku',
                provider: 'anthropic',
                contextWindow: 200000,
                supportsVision: true,
                supportsFunctionCalling: true,
                inputPricing: 0.00025,
                outputPricing: 0.00125,
            },
            {
                id: 'claude-3-5-sonnet-20240620',
                name: 'Claude 3.5 Sonnet',
                provider: 'anthropic',
                contextWindow: 200000,
                supportsVision: true,
                supportsFunctionCalling: true,
                inputPricing: 0.003,
                outputPricing: 0.015,
            },
        ];
    }
    async checkLimits() {
        // Anthropic doesn't provide usage API, return configured limits
        return {
            requestsPerMinute: 50,
            requestsPerDay: 1000,
            tokensPerMinute: 50000,
            tokensPerDay: 200000,
            currentUsage: {
                requestsToday: 0,
                tokensToday: 0,
                lastReset: new Date().toISOString().split('T')[0],
            },
        };
    }
    async validateConnection() {
        try {
            // Try a simple request to validate the API key
            await this.client.messages.create({
                model: 'claude-3-haiku-20240307',
                max_tokens: 10,
                messages: [{ role: 'user', content: 'Hello' }],
            });
            return true;
        }
        catch {
            return false;
        }
    }
}
//# sourceMappingURL=anthropic.js.map