


























@@ -5,12 +5,7 @@ import type { OpenClawConfig } from "../../config/types.openclaw.js";
55import { withFileLock } from "../../infra/file-lock.js";
66import { loadJsonFile, saveJsonFile } from "../../infra/json-file.js";
77import { cloneAuthProfileStore } from "./clone.js";
8-import {
9-AUTH_STORE_LOCK_OPTIONS,
10-AUTH_STORE_VERSION,
11-EXTERNAL_CLI_SYNC_TTL_MS,
12-log,
13-} from "./constants.js";
8+import { AUTH_STORE_LOCK_OPTIONS, AUTH_STORE_VERSION, log } from "./constants.js";
149import {
1510overlayExternalAuthProfiles,
1611shouldPersistExternalAuthProfile,
@@ -40,6 +35,11 @@ import {
4035setRuntimeAuthProfileStoreSnapshot,
4136} from "./runtime-snapshots.js";
4237import { savePersistedAuthProfileState } from "./state.js";
38+import {
39+clearLoadedAuthStoreCache,
40+readCachedAuthProfileStore,
41+writeCachedAuthProfileStore,
42+} from "./store-cache.js";
4343import type { AuthProfileStore } from "./types.js";
44444545type LoadAuthProfileStoreOptions = {
@@ -75,16 +75,6 @@ type ExternalCliSyncResult = {
7575cacheable: boolean;
7676};
777778-const loadedAuthStoreCache = new Map<
79-string,
80-{
81-authMtimeMs: number | null;
82-stateMtimeMs: number | null;
83-syncedAtMs: number;
84-store: AuthProfileStore;
85-}
86->();
87-8878function isInheritedMainOAuthCredential(params: {
8979agentDir?: string;
9080profileId: string;
@@ -235,39 +225,6 @@ function acquireAuthStoreLockSync(authPath: string): (() => void) | null {
235225}
236226}
237227238-function readCachedAuthProfileStore(params: {
239-authPath: string;
240-authMtimeMs: number | null;
241-stateMtimeMs: number | null;
242-}): AuthProfileStore | null {
243-const cached = loadedAuthStoreCache.get(params.authPath);
244-if (
245-!cached ||
246-cached.authMtimeMs !== params.authMtimeMs ||
247-cached.stateMtimeMs !== params.stateMtimeMs
248-) {
249-return null;
250-}
251-if (Date.now() - cached.syncedAtMs >= EXTERNAL_CLI_SYNC_TTL_MS) {
252-return null;
253-}
254-return cloneAuthProfileStore(cached.store);
255-}
256-257-function writeCachedAuthProfileStore(params: {
258-authPath: string;
259-authMtimeMs: number | null;
260-stateMtimeMs: number | null;
261-store: AuthProfileStore;
262-}): void {
263-loadedAuthStoreCache.set(params.authPath, {
264-authMtimeMs: params.authMtimeMs,
265-stateMtimeMs: params.stateMtimeMs,
266-syncedAtMs: Date.now(),
267-store: cloneAuthProfileStore(params.store),
268-});
269-}
270-271228function resolveExternalCliOverlayOptions(
272229options: LoadAuthProfileStoreOptions | undefined,
273230): ResolvedExternalCliOverlayOptions {
@@ -735,7 +692,7 @@ export function replaceRuntimeAuthProfileStoreSnapshots(
735692736693export function clearRuntimeAuthProfileStoreSnapshots(): void {
737694clearRuntimeAuthProfileStoreSnapshotsImpl();
738-loadedAuthStoreCache.clear();
695+clearLoadedAuthStoreCache();
739696}
740697741698export function saveAuthProfileStore(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。