mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-06-16 13:34:04 +08:00
feat: add AWS Bedrock (API Key) Claude Code provider preset with tests
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -571,4 +571,39 @@ export const providerPresets: ProviderPreset[] = [
|
||||
icon: "aws",
|
||||
iconColor: "#FF9900",
|
||||
},
|
||||
{
|
||||
name: "AWS Bedrock (API Key)",
|
||||
websiteUrl: "https://aws.amazon.com/bedrock/",
|
||||
apiKeyField: "ANTHROPIC_API_KEY",
|
||||
settingsConfig: {
|
||||
apiKey: "${BEDROCK_API_KEY}",
|
||||
env: {
|
||||
ANTHROPIC_BASE_URL:
|
||||
"https://bedrock-runtime.${AWS_REGION}.amazonaws.com",
|
||||
AWS_REGION: "${AWS_REGION}",
|
||||
ANTHROPIC_MODEL: "global.anthropic.claude-opus-4-6-v1",
|
||||
ANTHROPIC_DEFAULT_HAIKU_MODEL:
|
||||
"global.anthropic.claude-haiku-4-5-20251001-v1:0",
|
||||
ANTHROPIC_DEFAULT_SONNET_MODEL:
|
||||
"global.anthropic.claude-sonnet-4-5-20250929-v1:0",
|
||||
ANTHROPIC_DEFAULT_OPUS_MODEL: "global.anthropic.claude-opus-4-6-v1",
|
||||
CLAUDE_CODE_USE_BEDROCK: "1",
|
||||
},
|
||||
},
|
||||
category: "cloud_provider",
|
||||
templateValues: {
|
||||
AWS_REGION: {
|
||||
label: "AWS Region",
|
||||
placeholder: "us-west-2",
|
||||
editorValue: "us-west-2",
|
||||
},
|
||||
BEDROCK_API_KEY: {
|
||||
label: "Bedrock API Key",
|
||||
placeholder: "your-bedrock-api-key",
|
||||
editorValue: "",
|
||||
},
|
||||
},
|
||||
icon: "aws",
|
||||
iconColor: "#FF9900",
|
||||
},
|
||||
];
|
||||
|
||||
@@ -42,4 +42,38 @@ describe("AWS Bedrock Provider Presets", () => {
|
||||
const env = (bedrockAksk!.settingsConfig as any).env;
|
||||
expect(env.ANTHROPIC_MODEL).toContain("anthropic.claude");
|
||||
});
|
||||
|
||||
const bedrockApiKey = providerPresets.find(
|
||||
(p) => p.name === "AWS Bedrock (API Key)",
|
||||
);
|
||||
|
||||
it("should include AWS Bedrock (API Key) preset", () => {
|
||||
expect(bedrockApiKey).toBeDefined();
|
||||
});
|
||||
|
||||
it("API Key preset should have apiKey template and AWS env variables", () => {
|
||||
const config = bedrockApiKey!.settingsConfig as any;
|
||||
expect(config).toHaveProperty("apiKey", "${BEDROCK_API_KEY}");
|
||||
expect(config.env).toHaveProperty("AWS_REGION");
|
||||
expect(config.env).toHaveProperty("CLAUDE_CODE_USE_BEDROCK", "1");
|
||||
});
|
||||
|
||||
it("API Key preset should NOT have AKSK env variables", () => {
|
||||
const env = (bedrockApiKey!.settingsConfig as any).env;
|
||||
expect(env).not.toHaveProperty("AWS_ACCESS_KEY_ID");
|
||||
expect(env).not.toHaveProperty("AWS_SECRET_ACCESS_KEY");
|
||||
});
|
||||
|
||||
it("API Key preset should have template values for API key and region", () => {
|
||||
expect(bedrockApiKey!.templateValues).toBeDefined();
|
||||
expect(bedrockApiKey!.templateValues!.BEDROCK_API_KEY).toBeDefined();
|
||||
expect(bedrockApiKey!.templateValues!.AWS_REGION).toBeDefined();
|
||||
expect(bedrockApiKey!.templateValues!.AWS_REGION.editorValue).toBe(
|
||||
"us-west-2",
|
||||
);
|
||||
});
|
||||
|
||||
it("API Key preset should have cloud_provider category", () => {
|
||||
expect(bedrockApiKey!.category).toBe("cloud_provider");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user