11import { normalizeOptionalString } from "../shared/string-coerce.js" ;
2- import { isNonSecretApiKeyMarker } from "./model-auth-markers.js" ;
32import type { ProviderConfig } from "./models-config.providers.secrets.js" ;
43
54export type ExistingProviderConfig = ProviderConfig & {
@@ -179,25 +178,6 @@ function resolveProviderApiSurface(
179178 return resolveProviderApi ( entry ) ?? resolveModelApiSurface ( entry ) ;
180179}
181180
182- function shouldPreserveExistingApiKey ( params : {
183- providerKey : string ;
184- existing : ExistingProviderConfig ;
185- nextEntry : ProviderConfig ;
186- secretRefManagedProviders : ReadonlySet < string > ;
187- } ) : boolean {
188- const { providerKey, existing, nextEntry, secretRefManagedProviders } = params ;
189- const nextApiKey = typeof nextEntry . apiKey === "string" ? nextEntry . apiKey : "" ;
190- if ( nextApiKey && isNonSecretApiKeyMarker ( nextApiKey ) ) {
191- return false ;
192- }
193- return (
194- ! secretRefManagedProviders . has ( providerKey ) &&
195- typeof existing . apiKey === "string" &&
196- existing . apiKey . length > 0 &&
197- ! isNonSecretApiKeyMarker ( existing . apiKey , { includeEnvVarName : false } )
198- ) ;
199- }
200-
201181function shouldPreserveExistingBaseUrl ( params : {
202182 existing : ExistingProviderConfig ;
203183 nextEntry : ProviderConfig ;
@@ -217,7 +197,7 @@ export function mergeWithExistingProviderSecrets(params: {
217197 existingProviders : Record < string , ExistingProviderConfig > ;
218198 secretRefManagedProviders : ReadonlySet < string > ;
219199} ) : Record < string , ProviderConfig > {
220- const { nextProviders, existingProviders, secretRefManagedProviders } = params ;
200+ const { nextProviders, existingProviders } = params ;
221201 const mergedProviders : Record < string , ProviderConfig > = { } ;
222202 for ( const [ key , entry ] of Object . entries ( existingProviders ) ) {
223203 mergedProviders [ key ] = entry ;
@@ -229,16 +209,6 @@ export function mergeWithExistingProviderSecrets(params: {
229209 continue ;
230210 }
231211 const preserved : Record < string , unknown > = { } ;
232- if (
233- shouldPreserveExistingApiKey ( {
234- providerKey : key ,
235- existing,
236- nextEntry : newEntry ,
237- secretRefManagedProviders,
238- } )
239- ) {
240- preserved . apiKey = existing . apiKey ;
241- }
242212 if (
243213 shouldPreserveExistingBaseUrl ( {
244214 existing,
0 commit comments