





















@@ -21,6 +21,7 @@ import {
2121getActiveSecretsRuntimeEnv as getActiveSecretsRuntimeEnvState,
2222getActiveSecretsRuntimeRefreshContext,
2323getActiveSecretsRuntimeSnapshot as getActiveSecretsRuntimeSnapshotState,
24+getLiveSecretsRuntimeAuthStores,
2425getPreparedSecretsRuntimeSnapshotRefreshContext,
2526registerSecretsRuntimeStateClearHook,
2627setPreparedSecretsRuntimeSnapshotRefreshContext,
@@ -123,6 +124,7 @@ export async function prepareSecretsRuntimeSnapshot(params: {
123124setPreparedSecretsRuntimeSnapshotRefreshContext(snapshot, {
124125env: runtimeEnv,
125126explicitAgentDirs: params.agentDirs?.length ? [...candidateDirs] : null,
127+ includeAuthStoreRefs,
126128loadAuthStore: fastPathLoadAuthStore,
127129loadablePluginOrigins: params.loadablePluginOrigins ?? new Map<string, PluginOrigin>(),
128130});
@@ -197,6 +199,7 @@ export async function prepareSecretsRuntimeSnapshot(params: {
197199setPreparedSecretsRuntimeSnapshotRefreshContext(snapshot, {
198200env: runtimeEnv,
199201explicitAgentDirs: params.agentDirs?.length ? [...candidateDirs] : null,
202+ includeAuthStoreRefs,
200203loadAuthStore: params.loadAuthStore ?? loadAuthProfileStoreForSecretsRuntime,
201204 loadablePluginOrigins,
202205});
@@ -210,27 +213,36 @@ export function activateSecretsRuntimeSnapshot(snapshot: PreparedSecretsRuntimeS
210213({
211214env: { ...process.env } as Record<string, string | undefined>,
212215explicitAgentDirs: null,
216+includeAuthStoreRefs: snapshot.authStores.length > 0,
213217loadAuthStore: loadAuthProfileStoreForSecretsRuntime,
214218loadablePluginOrigins: new Map<string, PluginOrigin>(),
215219} satisfies SecretsRuntimeRefreshContext);
216220activateSecretsRuntimeSnapshotState({
217221 snapshot,
218222 refreshContext,
219223refreshHandler: {
220-refresh: async ({ sourceConfig }) => {
224+refresh: async ({ sourceConfig, includeAuthStoreRefs }) => {
221225const activeRefreshContext = getActiveSecretsRuntimeRefreshContext();
222-if (!getActiveSecretsRuntimeSnapshotState() || !activeRefreshContext) {
226+const activeSnapshot = getActiveSecretsRuntimeSnapshotState();
227+if (!activeSnapshot || !activeRefreshContext) {
223228return false;
224229}
230+const oneShotSkipAuthStoreRefs =
231+includeAuthStoreRefs === false && activeRefreshContext.includeAuthStoreRefs;
225232const refreshed = await prepareSecretsRuntimeSnapshot({
226233config: sourceConfig,
227234env: activeRefreshContext.env,
228235agentDirs: resolveRefreshAgentDirs(sourceConfig, activeRefreshContext),
236+includeAuthStoreRefs: includeAuthStoreRefs ?? activeRefreshContext.includeAuthStoreRefs,
229237loadablePluginOrigins: activeRefreshContext.loadablePluginOrigins,
230238 ...(activeRefreshContext.loadAuthStore
231239 ? { loadAuthStore: activeRefreshContext.loadAuthStore }
232240 : {}),
233241});
242+if (oneShotSkipAuthStoreRefs) {
243+refreshed.authStores = getLiveSecretsRuntimeAuthStores();
244+setPreparedSecretsRuntimeSnapshotRefreshContext(refreshed, activeRefreshContext);
245+}
234246activateSecretsRuntimeSnapshot(refreshed);
235247return true;
236248},
@@ -248,6 +260,7 @@ export async function refreshActiveSecretsRuntimeSnapshot(): Promise<boolean> {
248260config: activeSnapshot.sourceConfig,
249261env: activeRefreshContext.env,
250262agentDirs: resolveRefreshAgentDirs(activeSnapshot.sourceConfig, activeRefreshContext),
263+includeAuthStoreRefs: activeRefreshContext.includeAuthStoreRefs,
251264loadablePluginOrigins: activeRefreshContext.loadablePluginOrigins,
252265 ...(activeRefreshContext.loadAuthStore
253266 ? { loadAuthStore: activeRefreshContext.loadAuthStore }
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。