@@ -499,3 +499,46 @@ describe('provider capability helpers', () => {
499499 expect ( caps . modelDiscoveryMode ) . toBe ( 'manual' ) ;
500500 } ) ;
501501} ) ;
502+
503+ describe ( 'zai builtin provider' , ( ) => {
504+ it ( 'has a well-formed zai entry in BUILTIN_PROVIDERS' , ( ) => {
505+ const zai = BUILTIN_PROVIDERS . zai ;
506+ expect ( zai ) . toBeDefined ( ) ;
507+ expect ( zai . id ) . toBe ( 'zai' ) ;
508+ expect ( zai . name ) . toBe ( 'Z.ai (GLM Coding Plan)' ) ;
509+ expect ( zai . builtin ) . toBe ( true ) ;
510+ expect ( zai . wire ) . toBe ( 'anthropic' ) ;
511+ expect ( zai . baseUrl ) . toBe ( 'https://api.z.ai/api/anthropic' ) ;
512+ expect ( zai . defaultModel ) . toBe ( 'glm-5.1' ) ;
513+ expect ( zai . modelsHint ) . toEqual ( [ 'glm-5.1' , 'glm-5-turbo' , 'glm-4.7' , 'glm-4.5-air' ] ) ;
514+ expect ( zai . requiresApiKey ) . toBe ( true ) ;
515+ } ) ;
516+
517+ it ( 'zai capabilities are set for static-hint discovery with reasoning' , ( ) => {
518+ const caps = resolveProviderCapabilities ( 'zai' , BUILTIN_PROVIDERS . zai ) ;
519+ expect ( caps . supportsKeyless ) . toBe ( false ) ;
520+ expect ( caps . supportsModelsEndpoint ) . toBe ( false ) ;
521+ expect ( caps . supportsReasoning ) . toBe ( true ) ;
522+ expect ( caps . modelDiscoveryMode ) . toBe ( 'static-hint' ) ;
523+ } ) ;
524+
525+ it ( 'zai is included in SUPPORTED_ONBOARDING_PROVIDERS' , ( ) => {
526+ expect ( SUPPORTED_ONBOARDING_PROVIDERS ) . toContain ( 'zai' ) ;
527+ } ) ;
528+
529+ it ( 'detects z.ai anthropic URL as anthropic wire' , ( ) => {
530+ expect ( detectWireFromBaseUrl ( 'https://api.z.ai/api/anthropic' ) ) . toBe ( 'anthropic' ) ;
531+ } ) ;
532+
533+ it ( 'accepts zai as active provider in v3 config' , ( ) => {
534+ const parsed = ConfigV3Schema . parse ( {
535+ version : 3 ,
536+ activeProvider : 'zai' ,
537+ activeModel : 'glm-5.1' ,
538+ secrets : { zai : { ciphertext : 'plain:sk-test' , mask : 'sk-***test' } } ,
539+ providers : { zai : BUILTIN_PROVIDERS . zai } ,
540+ } ) ;
541+ expect ( parsed . activeProvider ) . toBe ( 'zai' ) ;
542+ expect ( parsed . activeModel ) . toBe ( 'glm-5.1' ) ;
543+ } ) ;
544+ } ) ;
0 commit comments