@@ -46,6 +46,82 @@ func DisplayName(providerID string) string {
4646 return providerID
4747}
4848
49+ // ChatProviderPreferenceOrder returns provider ids ordered by chat/runtime preference.
50+ func ChatProviderPreferenceOrder () []string {
51+ specs := DefaultRegistry .All ()
52+ sort .Slice (specs , func (i , j int ) bool {
53+ left := specs [i ].ChatPreference
54+ right := specs [j ].ChatPreference
55+ if left == 0 {
56+ left = specs [i ].SortOrder + 10_000
57+ }
58+ if right == 0 {
59+ right = specs [j ].SortOrder + 10_000
60+ }
61+ if left != right {
62+ return left < right
63+ }
64+ return specs [i ].ProviderID < specs [j ].ProviderID
65+ })
66+ out := make ([]string , 0 , len (specs ))
67+ for _ , spec := range specs {
68+ if spec .ProviderID != "" {
69+ out = append (out , spec .ProviderID )
70+ }
71+ }
72+ return out
73+ }
74+
75+ // RuntimeProfileKey returns the config runtime-profile key for a provider.
76+ func RuntimeProfileKey (providerID string ) string {
77+ if spec , ok := SpecByProviderID (providerID ); ok {
78+ return strings .TrimSpace (spec .RuntimeProfileKey )
79+ }
80+ return ""
81+ }
82+
83+ // DirectFallbackProviderIDs returns direct-provider fallback ids for providerID.
84+ func DirectFallbackProviderIDs (providerID string ) []string {
85+ spec , ok := SpecByProviderID (providerID )
86+ if ! ok || len (spec .DirectFallbacks ) == 0 {
87+ return nil
88+ }
89+ out := make ([]string , 0 , len (spec .DirectFallbacks ))
90+ for _ , id := range spec .DirectFallbacks {
91+ if trimmed := strings .TrimSpace (id ); trimmed != "" {
92+ out = append (out , trimmed )
93+ }
94+ }
95+ return out
96+ }
97+
98+ // CredentialAliases returns compatibility env var names for providerID.
99+ func CredentialAliases (providerID string ) []string {
100+ spec , ok := SpecByProviderID (providerID )
101+ if ! ok || len (spec .CredentialAliases ) == 0 {
102+ return nil
103+ }
104+ out := make ([]string , 0 , len (spec .CredentialAliases ))
105+ for _ , env := range spec .CredentialAliases {
106+ if trimmed := strings .TrimSpace (env ); trimmed != "" {
107+ out = append (out , trimmed )
108+ }
109+ }
110+ return out
111+ }
112+
113+ // CredentialEnvPreparedProviders returns providers that need config-derived env before discovery.
114+ func CredentialEnvPreparedProviders () []string {
115+ var out []string
116+ for _ , spec := range DefaultRegistry .All () {
117+ if spec .PrepareCredentialEnv && spec .ProviderID != "" {
118+ out = append (out , spec .ProviderID )
119+ }
120+ }
121+ sort .Strings (out )
122+ return out
123+ }
124+
49125// CredentialRegistry derives credential rows from provider specs.
50126func CredentialRegistry () []CredentialSpec {
51127 specs := DefaultRegistry .All ()
0 commit comments