@@ -606,3 +606,111 @@ describe("snowflake-cortex provider", () => {
606606 }
607607 } )
608608} )
609+
610+ // ---------------------------------------------------------------------------
611+ // Provider.all() — unauthenticated discoverability
612+ // ---------------------------------------------------------------------------
613+
614+ describe ( "Provider.all() discoverability" , ( ) => {
615+ test ( "includes snowflake-cortex even without oauth auth" , async ( ) => {
616+ const savedAuth = await Auth . get ( "snowflake-cortex" )
617+ if ( savedAuth ) await Auth . remove ( "snowflake-cortex" )
618+ try {
619+ await using tmp = await tmpdir ( {
620+ init : async ( dir ) => {
621+ await Bun . write ( path . join ( dir , "opencode.json" ) , JSON . stringify ( { $schema : "https://altimate.ai/config.json" } ) )
622+ } ,
623+ } )
624+ await Instance . provide ( {
625+ directory : tmp . path ,
626+ init : async ( ) => {
627+ Env . remove ( "SNOWFLAKE_ACCOUNT" )
628+ } ,
629+ fn : async ( ) => {
630+ const allProviders = await Provider . all ( )
631+ expect ( allProviders [ "snowflake-cortex" ] ) . toBeDefined ( )
632+ expect ( allProviders [ "snowflake-cortex" ] . name ) . toBe ( "Snowflake Cortex" )
633+ // list() still returns nothing (not authenticated)
634+ const connected = await Provider . list ( )
635+ expect ( connected [ "snowflake-cortex" ] ) . toBeUndefined ( )
636+ } ,
637+ } )
638+ } finally {
639+ if ( savedAuth ) await Auth . set ( "snowflake-cortex" , savedAuth )
640+ }
641+ } )
642+
643+ test ( "all() includes snowflake-cortex models" , async ( ) => {
644+ await using tmp = await tmpdir ( {
645+ init : async ( dir ) => {
646+ await Bun . write ( path . join ( dir , "opencode.json" ) , JSON . stringify ( { $schema : "https://altimate.ai/config.json" } ) )
647+ } ,
648+ } )
649+ await Instance . provide ( {
650+ directory : tmp . path ,
651+ fn : async ( ) => {
652+ const allProviders = await Provider . all ( )
653+ const models = allProviders [ "snowflake-cortex" ] ?. models
654+ expect ( models ) . toBeDefined ( )
655+ expect ( models [ "claude-sonnet-4-6" ] ) . toBeDefined ( )
656+ expect ( models [ "deepseek-r1" ] ) . toBeDefined ( )
657+ } ,
658+ } )
659+ } )
660+
661+ test ( "disabled_providers config suppresses snowflake-cortex from all()" , async ( ) => {
662+ await using tmp = await tmpdir ( {
663+ init : async ( dir ) => {
664+ await Bun . write (
665+ path . join ( dir , "opencode.json" ) ,
666+ JSON . stringify ( { $schema : "https://altimate.ai/config.json" , disabled_providers : [ "snowflake-cortex" ] } ) ,
667+ )
668+ } ,
669+ } )
670+ await Instance . provide ( {
671+ directory : tmp . path ,
672+ fn : async ( ) => {
673+ // Provider.all() returns raw database, config filtering happens at the route level.
674+ // Verify the route-level filtering logic: a disabled provider should not appear
675+ // in the merged provider list used by GET /provider.
676+ const allProviders = await Provider . all ( )
677+ const connected = await Provider . list ( )
678+ // Simulate the route filtering (same logic as routes/provider.ts)
679+ const disabled = new Set ( [ "snowflake-cortex" ] )
680+ const customProviders : Record < string , ( typeof allProviders ) [ string ] > = { }
681+ for ( const [ key , value ] of Object . entries ( allProviders ) ) {
682+ if ( key in connected ) continue
683+ if ( ! disabled . has ( key ) ) customProviders [ key ] = value
684+ }
685+ expect ( customProviders [ "snowflake-cortex" ] ) . toBeUndefined ( )
686+ } ,
687+ } )
688+ } )
689+
690+ test ( "enabled_providers config suppresses snowflake-cortex when not listed" , async ( ) => {
691+ await using tmp = await tmpdir ( {
692+ init : async ( dir ) => {
693+ await Bun . write (
694+ path . join ( dir , "opencode.json" ) ,
695+ JSON . stringify ( { $schema : "https://altimate.ai/config.json" , enabled_providers : [ "anthropic" ] } ) ,
696+ )
697+ } ,
698+ } )
699+ await Instance . provide ( {
700+ directory : tmp . path ,
701+ fn : async ( ) => {
702+ const allProviders = await Provider . all ( )
703+ const connected = await Provider . list ( )
704+ // Simulate route filtering with enabled_providers
705+ // (snowflake-cortex is not in the enabled list, so it should be excluded)
706+ const enabled = new Set ( [ "anthropic" ] )
707+ const customProviders : Record < string , ( typeof allProviders ) [ string ] > = { }
708+ for ( const [ key , value ] of Object . entries ( allProviders ) ) {
709+ if ( key in connected ) continue
710+ if ( enabled . has ( key ) ) customProviders [ key ] = value
711+ }
712+ expect ( customProviders [ "snowflake-cortex" ] ) . toBeUndefined ( )
713+ } ,
714+ } )
715+ } )
716+ } )
0 commit comments