@@ -771,27 +771,27 @@ async function runTestCase(configStoreCtor: ConfigStoreCtor, testCase: TestCase)
771771}
772772
773773async function runConfigNormalizationTests ( configStoreCtor : ConfigStoreCtor ) : Promise < void > {
774- activeState = createState ( [ {
775- name : 'Vendor' ,
776- baseUrl : 'https://example.test/v1' ,
777- apiStyle : 'anthropic' ,
778- defaultVision : true ,
774+ activeState = createState ( [ {
775+ name : 'Vendor' ,
776+ baseUrl : 'https://example.test/v1' ,
777+ apiStyle : 'anthropic' ,
778+ defaultVision : true ,
779779 models : [ { name : 'claude-3' } ]
780780 } ] ) ;
781781
782- let configStore = new configStoreCtor ( createExtensionContext ( ) as never ) ;
783- try {
784- const vendor = configStore . getVendors ( ) [ 0 ] ;
785- assert . equal ( vendor ?. defaultApiStyle , 'anthropic' ) ;
786- assert . equal ( vendor ?. models [ 0 ] ?. apiStyle , 'anthropic' ) ;
787- assert . deepEqual ( vendor ?. models [ 0 ] ?. capabilities , { tools : true , vision : true } ) ;
788- assert . equal ( vendor ?. models [ 0 ] ?. maxOutputTokens , 0 ) ;
789- assert . equal ( vendor ?. defaultTemperature , undefined ) ;
790- assert . equal ( vendor ?. defaultTopP , undefined ) ;
791- console . log ( 'PASS 兼容旧 apiStyle、补齐模型默认能力并将 maxOutputTokens 默认归一化为 0' ) ;
792- } finally {
793- configStore . dispose ( ) ;
794- }
782+ let configStore = new configStoreCtor ( createExtensionContext ( ) as never ) ;
783+ try {
784+ const vendor = configStore . getVendors ( ) [ 0 ] ;
785+ assert . equal ( vendor ?. defaultApiStyle , 'anthropic' ) ;
786+ assert . equal ( vendor ?. models [ 0 ] ?. apiStyle , 'anthropic' ) ;
787+ assert . deepEqual ( vendor ?. models [ 0 ] ?. capabilities , { tools : true , vision : true } ) ;
788+ assert . equal ( vendor ?. models [ 0 ] ?. maxOutputTokens , 0 ) ;
789+ assert . equal ( vendor ?. defaultTemperature , undefined ) ;
790+ assert . equal ( vendor ?. defaultTopP , undefined ) ;
791+ console . log ( 'PASS 兼容旧 apiStyle、补齐模型默认能力并将 maxOutputTokens 默认归一化为 0' ) ;
792+ } finally {
793+ configStore . dispose ( ) ;
794+ }
795795
796796 activeState = createState ( [ {
797797 name : 'Vendor' ,
@@ -974,6 +974,31 @@ async function runConfigNormalizationTests(configStoreCtor: ConfigStoreCtor): Pr
974974 } finally {
975975 configStore . dispose ( ) ;
976976 }
977+
978+ activeState = createState ( [ {
979+ name : 'Vendor' ,
980+ baseUrl : 'https://example.test/v1' ,
981+ defaultApiStyle : 'openai-chat' ,
982+ defaultVision : false ,
983+ models : [
984+ { name : 'claude-4-sonnet' } ,
985+ { name : ' claude-4-sonnet ' } ,
986+ { name : 'CLAUDE-4-SONNET' } ,
987+ { name : 'claude-4-opus' }
988+ ]
989+ } ] ) ;
990+
991+ configStore = new configStoreCtor ( createExtensionContext ( ) as never ) ;
992+ try {
993+ const vendor = configStore . getVendors ( ) [ 0 ] ;
994+ assert . deepEqual (
995+ vendor ?. models . map ( model => model . name ) ,
996+ [ 'claude-4-sonnet' , 'claude-4-opus' ]
997+ ) ;
998+ console . log ( 'PASS vendors[].models 在归一化阶段按名称去重,避免模型列表重复显示' ) ;
999+ } finally {
1000+ configStore . dispose ( ) ;
1001+ }
9771002}
9781003
9791004async function runConfigStoreVendorApiKeyPriorityTests ( configStoreCtor : ConfigStoreCtor ) : Promise < void > {
@@ -3533,6 +3558,7 @@ async function runLMChatProviderAdapterModelFilteringTests(
35333558 const models = [
35343559 {
35353560 id : 'Vendor/coder' ,
3561+ vendor : 'coding-plans' ,
35363562 name : 'coder' ,
35373563 family : 'Vendor' ,
35383564 description : 'Vendor coder' ,
@@ -3541,8 +3567,20 @@ async function runLMChatProviderAdapterModelFilteringTests(
35413567 maxOutputTokens : 16000 ,
35423568 capabilities : { toolCalling : true , imageInput : false }
35433569 } ,
3570+ {
3571+ id : 'Vendor/coder' ,
3572+ vendor : 'coding-plans' ,
3573+ name : 'coder' ,
3574+ family : 'Vendor' ,
3575+ description : 'Vendor coder duplicate' ,
3576+ version : 'Vendor' ,
3577+ maxInputTokens : 32000 ,
3578+ maxOutputTokens : 16000 ,
3579+ capabilities : { toolCalling : true , imageInput : false }
3580+ } ,
35443581 {
35453582 id : 'Other/coder' ,
3583+ vendor : 'coding-plans' ,
35463584 name : 'coder' ,
35473585 family : 'Other' ,
35483586 description : 'Other coder' ,
@@ -3579,10 +3617,11 @@ async function runLMChatProviderAdapterModelFilteringTests(
35793617 try {
35803618 const stableApiModels = await adapter . provideLanguageModelChatInformation ( { silent : false } as never , { } as never ) ;
35813619 assert . deepEqual ( stableApiModels . map ( model => model . id ) , [ 'Vendor/coder' , 'Other/coder' ] ) ;
3620+ assert . deepEqual ( stableApiModels . map ( model => model . name ) , [ 'Vendor/coder' , 'Other/coder' ] ) ;
35823621 assert . equal ( ( stableApiModels [ 0 ] as { isUserSelectable ?: boolean } ) . isUserSelectable , true ) ;
35833622
3584- const allModels = await adapter . provideLanguageModelChatInformation ( { group : 'Group' } as never , { } as never ) ;
3585- assert . deepEqual ( allModels . map ( model => model . id ) , [ 'Vendor/coder' , 'Other/coder' ] ) ;
3623+ const groupedModels = await adapter . provideLanguageModelChatInformation ( { group : 'Group' } as never , { } as never ) ;
3624+ assert . deepEqual ( groupedModels . map ( model => model . id ) , [ ] ) ;
35863625
35873626 const vendorModels = await adapter . provideLanguageModelChatInformation ( {
35883627 group : 'Group' ,
@@ -3595,7 +3634,7 @@ async function runLMChatProviderAdapterModelFilteringTests(
35953634 const placeholderModels = await adapter . provideLanguageModelChatInformation ( { silent : true } as never , { } as never ) ;
35963635 assert . equal ( refreshCount , 1 ) ;
35973636 assert . deepEqual ( placeholderModels . map ( model => model . id ) , [ 'coding-plans__setup_api_key__' ] ) ;
3598- console . log ( 'PASS LMChatProviderAdapter 兼容 stable picker 调用、标记 user-selectable,并保留旧 vendorName 过滤' ) ;
3637+ console . log ( 'PASS LMChatProviderAdapter 避免无范围 group 查询重复枚举模型,并保留 vendorName 过滤' ) ;
35993638 } finally {
36003639 adapter . dispose ( ) ;
36013640 configStore . dispose ( ) ;
0 commit comments