import { BaseProvider } from "../BaseProvider.js";
import { DEFAULT_ANTHROPIC_BASE_URL } from "../../constants.js";
import { Capabilities } from "./Capabilities.js";
import { AnthropicChat } from "./Chat.js";
import { AnthropicStreaming } from "./Streaming.js";
import { AnthropicModels } from "./Models.js";
export class AnthropicProvider extends BaseProvider {
    options;
    baseUrl;
    chatHandler;
    streamHandler;
    modelsHandler;
    capabilities = {
        supportsVision: (model) => Capabilities.supportsVision(model),
        supportsTools: (model) => Capabilities.supportsTools(model),
        supportsStructuredOutput: (model) => Capabilities.supportsJsonMode(model),
        supportsEmbeddings: (_model) => false,
        supportsImageGeneration: (_model) => false,
        supportsTranscription: (_model) => false,
        supportsModeration: (_model) => false,
        supportsReasoning: (_model) => false,
        supportsDeveloperRole: (_model) => true,
        getContextWindow: (model) => Capabilities.getContextWindow(model)
    };
    constructor(options) {
        super();
        this.options = options;
        this.baseUrl = options.baseUrl ?? DEFAULT_ANTHROPIC_BASE_URL;
        this.chatHandler = new AnthropicChat(this.baseUrl, options.apiKey);
        this.streamHandler = new AnthropicStreaming(this.baseUrl, options.apiKey);
        this.modelsHandler = new AnthropicModels(this.baseUrl, options.apiKey);
    }
    apiBase() {
        return this.baseUrl;
    }
    headers() {
        return {
            "x-api-key": this.options.apiKey,
            "anthropic-version": "2023-06-01",
            "Content-Type": "application/json"
        };
    }
    providerName() {
        return "Anthropic";
    }
    defaultModel(_feature) {
        return "claude-3-5-haiku-20241022";
    }
    async chat(request) {
        return this.chatHandler.execute(request);
    }
    async *stream(request) {
        yield* this.streamHandler.execute(request);
    }
    async listModels() {
        return this.modelsHandler.execute();
    }
}
