@@ -197,6 +197,10 @@ import {
197197 invalidateAccountManagerCacheState ,
198198 reloadAccountManagerFromDiskState ,
199199} from "./lib/runtime/account-manager-cache.js" ;
200+ import {
201+ invalidateAccountManagerCacheEntry ,
202+ reloadAccountManagerFromDiskEntry ,
203+ } from "./lib/runtime/account-manager-cache-entry.js" ;
200204import {
201205 type TokenSuccessWithAccount as AccountPoolTokenSuccessWithAccount ,
202206 persistAccountPoolResults ,
@@ -524,28 +528,36 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
524528 } ;
525529
526530 const invalidateAccountManagerCache = ( ) : void => {
527- const next = invalidateAccountManagerCacheState ( ) ;
528- cachedAccountManager = next . cachedAccountManager ;
529- accountManagerPromise = next . accountManagerPromise ;
531+ invalidateAccountManagerCacheEntry < AccountManager > ( {
532+ invalidateAccountManagerCacheState,
533+ setCachedAccountManager : ( manager ) => {
534+ cachedAccountManager = manager ;
535+ } ,
536+ setAccountManagerPromise : ( promise ) => {
537+ accountManagerPromise = promise ;
538+ } ,
539+ } ) ;
530540 } ;
531541
532542 const reloadAccountManagerFromDisk = async (
533543 authFallback ?: OAuthAuthDetails ,
534- ) : Promise < AccountManager > => {
535- accountReloadInFlight = reloadAccountManagerFromDiskState ( {
544+ ) : Promise < AccountManager > =>
545+ reloadAccountManagerFromDiskEntry < AccountManager > ( {
546+ authFallback,
536547 currentReloadInFlight : accountReloadInFlight ,
548+ reloadAccountManagerFromDiskState,
537549 loadFromDisk : ( fallback ) => AccountManager . loadFromDisk ( fallback ) ,
538- authFallback,
539550 onLoaded : ( reloaded ) => {
540551 cachedAccountManager = reloaded ;
541552 accountManagerPromise = Promise . resolve ( reloaded ) ;
542553 } ,
543554 onSettled : ( ) => {
544555 accountReloadInFlight = null ;
545556 } ,
557+ setReloadInFlight : ( promise ) => {
558+ accountReloadInFlight = promise ;
559+ } ,
546560 } ) ;
547- return accountReloadInFlight ;
548- } ;
549561
550562 const applyAccountStorageScope = (
551563 pluginConfig : ReturnType < typeof loadPluginConfig > ,
0 commit comments