2026-04-07 23:05:49 +09:00
|
|
|
import type { AdapterModel } from "@paperclipai/adapter-utils";
|
2026-04-07 23:24:37 +09:00
|
|
|
import { models as DIRECT_MODELS } from "../index.js";
|
2026-04-07 23:05:49 +09:00
|
|
|
|
|
|
|
|
/** AWS Bedrock model IDs — region-qualified identifiers required by the Bedrock API. */
|
|
|
|
|
const BEDROCK_MODELS: AdapterModel[] = [
|
|
|
|
|
{ id: "us.anthropic.claude-opus-4-6-v1", label: "Bedrock Opus 4.6" },
|
|
|
|
|
{ id: "us.anthropic.claude-sonnet-4-5-20250929-v2:0", label: "Bedrock Sonnet 4.5" },
|
|
|
|
|
{ id: "us.anthropic.claude-haiku-4-5-20251001-v1:0", label: "Bedrock Haiku 4.5" },
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
function isBedrockEnv(): boolean {
|
|
|
|
|
return (
|
|
|
|
|
process.env.CLAUDE_CODE_USE_BEDROCK === "1" ||
|
|
|
|
|
process.env.CLAUDE_CODE_USE_BEDROCK === "true" ||
|
|
|
|
|
(typeof process.env.ANTHROPIC_BEDROCK_BASE_URL === "string" &&
|
|
|
|
|
process.env.ANTHROPIC_BEDROCK_BASE_URL.trim().length > 0)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the model list appropriate for the current auth mode.
|
|
|
|
|
* When Bedrock env vars are detected, returns Bedrock-native model IDs;
|
|
|
|
|
* otherwise returns standard Anthropic API model IDs.
|
|
|
|
|
*/
|
|
|
|
|
export async function listClaudeModels(): Promise<AdapterModel[]> {
|
|
|
|
|
return isBedrockEnv() ? BEDROCK_MODELS : DIRECT_MODELS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Check whether a model ID is a Bedrock-native identifier (not an Anthropic API short name). */
|
2026-04-07 23:24:37 +09:00
|
|
|
/** Bedrock model IDs use region-qualified prefixes (e.g. us.anthropic.*, eu.anthropic.*) or ARNs. */
|
2026-04-07 23:05:49 +09:00
|
|
|
export function isBedrockModelId(model: string): boolean {
|
2026-04-07 23:24:37 +09:00
|
|
|
return /^\w+\.anthropic\./.test(model) || model.startsWith("arn:aws:bedrock:");
|
2026-04-07 23:05:49 +09:00
|
|
|
}
|