@@ -163,16 +163,56 @@ export function resolveProviderEnvVars(
163163 } ;
164164}
165165
166+ function createLazyReadonlyRecord (
167+ resolve : ( ) => Record < string , readonly string [ ] > ,
168+ ) : Record < string , readonly string [ ] > {
169+ let cached : Record < string , readonly string [ ] > | undefined ;
170+ const getResolved = ( ) : Record < string , readonly string [ ] > => {
171+ cached ??= resolve ( ) ;
172+ return cached ;
173+ } ;
174+
175+ return new Proxy ( { } as Record < string , readonly string [ ] > , {
176+ get ( _target , prop ) {
177+ if ( typeof prop !== "string" ) {
178+ return undefined ;
179+ }
180+ return getResolved ( ) [ prop ] ;
181+ } ,
182+ has ( _target , prop ) {
183+ return typeof prop === "string" && Object . hasOwn ( getResolved ( ) , prop ) ;
184+ } ,
185+ ownKeys ( ) {
186+ return Reflect . ownKeys ( getResolved ( ) ) ;
187+ } ,
188+ getOwnPropertyDescriptor ( _target , prop ) {
189+ if ( typeof prop !== "string" ) {
190+ return undefined ;
191+ }
192+ const value = getResolved ( ) [ prop ] ;
193+ if ( value === undefined ) {
194+ return undefined ;
195+ }
196+ return {
197+ configurable : true ,
198+ enumerable : true ,
199+ value,
200+ writable : false ,
201+ } ;
202+ } ,
203+ } ) ;
204+ }
205+
166206/**
167207 * Provider auth env candidates used by generic auth resolution.
168208 *
169209 * Order matters: the first non-empty value wins for helpers such as
170210 * `resolveEnvApiKey()`. Bundled providers source this from plugin manifest
171211 * metadata so auth probes do not need to load plugin runtime.
172212 */
173- export const PROVIDER_AUTH_ENV_VAR_CANDIDATES : Record < string , readonly string [ ] > = {
174- ... resolveProviderAuthEnvVarCandidates ( ) ,
175- } ;
213+ export const PROVIDER_AUTH_ENV_VAR_CANDIDATES = createLazyReadonlyRecord ( ( ) =>
214+ resolveProviderAuthEnvVarCandidates ( ) ,
215+ ) ;
176216
177217/**
178218 * Provider env vars used for setup/default secret refs and broad secret
@@ -183,9 +223,7 @@ export const PROVIDER_AUTH_ENV_VAR_CANDIDATES: Record<string, readonly string[]>
183223 * is only for true core/non-plugin providers and a few setup-specific ordering
184224 * overrides where generic onboarding wants a different preferred env var.
185225 */
186- export const PROVIDER_ENV_VARS : Record < string , readonly string [ ] > = {
187- ...resolveProviderEnvVars ( ) ,
188- } ;
226+ export const PROVIDER_ENV_VARS = createLazyReadonlyRecord ( ( ) => resolveProviderEnvVars ( ) ) ;
189227
190228export function getProviderEnvVars (
191229 providerId : string ,
0 commit comments