1- import { getApiProtocol } from "../provider-settings .js"
1+ import { getApiProtocol , providerIdentifiers , type ProviderName } from "../index .js"
22
33describe ( "getApiProtocol" , ( ) => {
44 describe ( "Anthropic-style providers" , ( ) => {
@@ -15,6 +15,19 @@ describe("getApiProtocol", () => {
1515 } )
1616
1717 describe ( "Vertex provider with Claude models" , ( ) => {
18+ it ( "uses the canonical Vertex identifier for Claude protocol selection" , ( ) => {
19+ const identifiers = providerIdentifiers as Record < string , string >
20+ const originalIdentifier = identifiers . vertex !
21+
22+ try {
23+ identifiers . vertex = "canonical-vertex"
24+
25+ expect ( getApiProtocol ( identifiers . vertex as ProviderName , "claude-3-opus" ) ) . toBe ( "anthropic" )
26+ } finally {
27+ identifiers . vertex = originalIdentifier
28+ }
29+ } )
30+
1831 it ( "should return 'anthropic' for vertex provider with claude models" , ( ) => {
1932 expect ( getApiProtocol ( "vertex" , "claude-3-opus" ) ) . toBe ( "anthropic" )
2033 expect ( getApiProtocol ( "vertex" , "Claude-3-Sonnet" ) ) . toBe ( "anthropic" )
@@ -34,6 +47,27 @@ describe("getApiProtocol", () => {
3447 } )
3548
3649 describe ( "Vercel AI Gateway provider" , ( ) => {
50+ it ( "uses canonical gateway identifiers for Anthropic model protocol selection" , ( ) => {
51+ const identifiers = providerIdentifiers as Record < string , string >
52+ const originalVercelIdentifier = identifiers . vercelAiGateway !
53+ const originalZooIdentifier = identifiers . zooGateway !
54+
55+ try {
56+ identifiers . vercelAiGateway = "canonical-vercel-ai-gateway"
57+ identifiers . zooGateway = "canonical-zoo-gateway"
58+
59+ expect ( getApiProtocol ( identifiers . vercelAiGateway as ProviderName , "anthropic/claude-3-opus" ) ) . toBe (
60+ "anthropic" ,
61+ )
62+ expect ( getApiProtocol ( identifiers . zooGateway as ProviderName , "anthropic/claude-3-opus" ) ) . toBe (
63+ "anthropic" ,
64+ )
65+ } finally {
66+ identifiers . vercelAiGateway = originalVercelIdentifier
67+ identifiers . zooGateway = originalZooIdentifier
68+ }
69+ } )
70+
3771 it ( "should return 'anthropic' for vercel-ai-gateway provider with anthropic models" , ( ) => {
3872 expect ( getApiProtocol ( "vercel-ai-gateway" , "anthropic/claude-3-opus" ) ) . toBe ( "anthropic" )
3973 expect ( getApiProtocol ( "vercel-ai-gateway" , "anthropic/claude-3.5-sonnet" ) ) . toBe ( "anthropic" )
@@ -54,6 +88,19 @@ describe("getApiProtocol", () => {
5488 } )
5589
5690 describe ( "Opencode Go provider" , ( ) => {
91+ it ( "uses the canonical OpenCode Go identifier for model-specific protocol selection" , ( ) => {
92+ const identifiers = providerIdentifiers as Record < string , string >
93+ const originalIdentifier = identifiers . opencodeGo !
94+
95+ try {
96+ identifiers . opencodeGo = "canonical-opencode-go"
97+
98+ expect ( getApiProtocol ( identifiers . opencodeGo as ProviderName , "qwen3.7-max" ) ) . toBe ( "anthropic" )
99+ } finally {
100+ identifiers . opencodeGo = originalIdentifier
101+ }
102+ } )
103+
57104 it ( "should return 'anthropic' for opencode-go Anthropic-format models (Qwen/MiniMax)" , ( ) => {
58105 expect ( getApiProtocol ( "opencode-go" , "qwen3.7-max" ) ) . toBe ( "anthropic" )
59106 expect ( getApiProtocol ( "opencode-go" , "qwen3.7-plus" ) ) . toBe ( "anthropic" )
0 commit comments