import { createAnthropic } from "@ai-sdk/anthropic";
const DEFAULT_MODEL = "claude-haiku-4-5-20251001";
const DEFAULT_MODELS = [
  {
    id: "claude-haiku-4-5-20251001",
    name: "Claude Haiku 4.5",
    contextWindow: 2e5,
    tags: ["budget"]
  },
  {
    id: "claude-sonnet-4-6-20260107",
    name: "Claude Sonnet 4.6",
    contextWindow: 2e5,
    tags: ["flagship"]
  },
  {
    id: "claude-opus-4-6-20260107",
    name: "Claude Opus 4.6",
    contextWindow: 1e6,
    tags: ["flagship", "reasoning"]
  }
];
function createAnthropicAdapter() {
  const envKeys = ["ANTHROPIC_API_KEY", "OPENCODE_ANTHROPIC_API_KEY"];
  function resolveApiKey(env) {
    const lookup = env ?? process.env;
    for (const key of envKeys) {
      const value = lookup[key];
      if (typeof value === "string") {
        const trimmed = value.trim();
        if (trimmed.length > 0) return trimmed;
      }
    }
    return null;
  }
  return {
    id: "anthropic",
    name: "Anthropic",
    envKeys,
    defaultModel: DEFAULT_MODEL,
    defaultModels: DEFAULT_MODELS,
    isConfigured(env) {
      return resolveApiKey(env) !== null;
    },
    resolveApiKey,
    getConfiguredEnvKey(env) {
      const lookup = env ?? process.env;
      for (const key of envKeys) {
        const value = lookup[key];
        if (typeof value === "string" && value.trim().length > 0) {
          return key;
        }
      }
      return envKeys[0];
    },
    createModel(options) {
      const anthropic = createAnthropic({
        apiKey: options.apiKey,
        ...options.baseURL ? { baseURL: options.baseURL } : {}
      });
      return anthropic(options.modelId);
    }
  };
}
export {
  createAnthropicAdapter
};
//# sourceMappingURL=anthropic.js.map
