@@ -111,25 +111,17 @@ describe('Integration Tests', () => {
111111 describe ( 'Claude Headers Integration' , ( ) => {
112112 it ( 'should automatically add Claude headers when resolving Claude models' , ( ) => {
113113 // Test with Claude model
114- const claudeModel = resolveModel (
115- undefined ,
116- 'claude-3-sonnet' ,
117- 'anthropic'
118- ) ;
119-
114+ const claudeModel = resolveModel ( undefined , 'claude-3-sonnet' , 'anthropic' ) ;
115+
120116 expect ( claudeModel . headers ?. [ 'anthropic-beta' ] ) . toBe (
121- 'fine-grained-tool-streaming-2025-05-14,token-efficient-tools-2025-02-19'
117+ 'fine-grained-tool-streaming-2025-05-14,token-efficient-tools-2025-02-19' ,
122118 ) ;
123119 } ) ;
124120
125121 it ( 'should not add Claude headers for non-Claude models' , ( ) => {
126122 // Test with non-Claude model
127- const openaiModel = resolveModel (
128- undefined ,
129- 'gpt-4' ,
130- 'openai'
131- ) ;
132-
123+ const openaiModel = resolveModel ( undefined , 'gpt-4' , 'openai' ) ;
124+
133125 expect ( openaiModel . headers ?. [ 'anthropic-beta' ] ) . toBeUndefined ( ) ;
134126 } ) ;
135127
@@ -139,14 +131,14 @@ describe('Integration Tests', () => {
139131 provider : 'anthropic' ,
140132 headers : {
141133 'X-Custom' : 'value' ,
142- ' Authorization' : 'Bearer token'
143- }
134+ Authorization : 'Bearer token' ,
135+ } ,
144136 } ) ;
145-
137+
146138 expect ( customModel . headers ?. [ 'X-Custom' ] ) . toBe ( 'value' ) ;
147139 expect ( customModel . headers ?. [ 'Authorization' ] ) . toBe ( 'Bearer token' ) ;
148140 expect ( customModel . headers ?. [ 'anthropic-beta' ] ) . toBe (
149- 'fine-grained-tool-streaming-2025-05-14,token-efficient-tools-2025-02-19'
141+ 'fine-grained-tool-streaming-2025-05-14,token-efficient-tools-2025-02-19' ,
150142 ) ;
151143 } ) ;
152144
@@ -155,13 +147,13 @@ describe('Integration Tests', () => {
155147 'claude-3-sonnet' ,
156148 'claude-3-5-sonnet-20241022' ,
157149 'claude-3-haiku' ,
158- 'anthropic/claude-3-opus'
150+ 'anthropic/claude-3-opus' ,
159151 ] ;
160-
161- models . forEach ( modelId => {
152+
153+ models . forEach ( ( modelId ) => {
162154 const model = resolveModel ( undefined , modelId , 'anthropic' ) ;
163155 expect ( model . headers ?. [ 'anthropic-beta' ] ) . toBe (
164- 'fine-grained-tool-streaming-2025-05-14,token-efficient-tools-2025-02-19'
156+ 'fine-grained-tool-streaming-2025-05-14,token-efficient-tools-2025-02-19' ,
165157 ) ;
166158 } ) ;
167159 } ) ;
@@ -173,16 +165,17 @@ describe('Integration Tests', () => {
173165 } ) ;
174166
175167 describe ( 'Error handling' , ( ) => {
176- it ( 'should handle invalid provider gracefully' , ( ) => {
177- // TypeScript should prevent this, but test runtime behavior
168+ it ( 'should handle unknown provider by falling back to openai-compatible' , ( ) => {
169+ // Unknown providers (like 'kimi') should default to openai-compatible
170+ // to support custom OpenAI-compatible APIs
178171 const resolved = resolveModel (
179172 undefined ,
180173 'test-model' ,
181174 'invalid-provider' as ModelProviderName ,
182175 ) ;
183176
184177 expect ( resolved . provider ) . toBe ( 'invalid-provider' ) ;
185- expect ( resolved . baseProvider ) . toBe ( 'invalid-provider ' ) ; // Falls back to same name
178+ expect ( resolved . baseProvider ) . toBe ( 'openai-compatible ' ) ; // Falls back to openai-compatible for unknown providers
186179 expect ( resolved . baseURL ) . toBeUndefined ( ) ;
187180 expect ( resolved . apiKey ) . toBeUndefined ( ) ;
188181 } ) ;
0 commit comments