





















@@ -249,6 +249,9 @@ const MAX_PLUGIN_REGISTRY_CACHE_ENTRIES = 128;
249249const pluginLoaderCacheState = new PluginLoaderCacheState<CachedPluginState>(
250250MAX_PLUGIN_REGISTRY_CACHE_ENTRIES,
251251);
252+const fullWorkspacePluginLoaderCacheState = new PluginLoaderCacheState<CachedPluginState>(
253+MAX_PLUGIN_REGISTRY_CACHE_ENTRIES,
254+);
252255const LAZY_RUNTIME_REFLECTION_KEYS = [
253256"version",
254257"config",
@@ -281,6 +284,7 @@ function createPluginCandidatesFromManifestRegistry(
281284282285export function clearPluginLoaderCache(): void {
283286pluginLoaderCacheState.clear();
287+fullWorkspacePluginLoaderCacheState.clear();
284288clearAgentHarnesses();
285289clearPluginCommands();
286290clearCompactionProviders();
@@ -525,15 +529,27 @@ export const __testing = {
525529},
526530setMaxPluginRegistryCacheEntriesForTest(value?: number) {
527531pluginLoaderCacheState.setMaxEntriesForTest(value);
532+fullWorkspacePluginLoaderCacheState.setMaxEntriesForTest(value);
528533},
529534};
530535531-function getCachedPluginRegistry(cacheKey: string): CachedPluginState | undefined {
532-return pluginLoaderCacheState.get(cacheKey);
536+function getPluginRegistryCache(onlyPluginIds?: string[]) {
537+return onlyPluginIds ? pluginLoaderCacheState : fullWorkspacePluginLoaderCacheState;
538+}
539+540+function getCachedPluginRegistry(
541+cacheKey: string,
542+onlyPluginIds?: string[],
543+): CachedPluginState | undefined {
544+return getPluginRegistryCache(onlyPluginIds).get(cacheKey);
533545}
534546535-function setCachedPluginRegistry(cacheKey: string, state: CachedPluginState): void {
536-pluginLoaderCacheState.set(cacheKey, state);
547+function setCachedPluginRegistry(
548+cacheKey: string,
549+state: CachedPluginState,
550+onlyPluginIds?: string[],
551+): void {
552+getPluginRegistryCache(onlyPluginIds).set(cacheKey, state);
537553}
538554539555function resolveBundledPackageRootForCache(stockRoot?: string): string | undefined {
@@ -1225,7 +1241,7 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi
1225124112261242const cacheEnabled = options.cache !== false;
12271243if (cacheEnabled) {
1228-const cached = getCachedPluginRegistry(cacheKey);
1244+const cached = getCachedPluginRegistry(cacheKey, onlyPluginIds);
12291245if (cached) {
12301246if (shouldActivate) {
12311247restoreRegisteredAgentHarnesses(cached.agentHarnesses);
@@ -2142,21 +2158,25 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi
21422158}
2143215921442160if (cacheEnabled) {
2145-setCachedPluginRegistry(cacheKey, {
2146-commands: listRegisteredPluginCommands(),
2147-detachedTaskRuntimeRegistration: getDetachedTaskLifecycleRuntimeRegistration(),
2148-interactiveHandlers: listPluginInteractiveHandlers(),
2149-memoryCapability: getMemoryCapabilityRegistration(),
2150-memoryCorpusSupplements: listMemoryCorpusSupplements(),
2151- registry,
2152-agentHarnesses: listRegisteredAgentHarnesses(),
2153-compactionProviders: listRegisteredCompactionProviders(),
2154-memoryEmbeddingProviders: listRegisteredMemoryEmbeddingProviders(),
2155-memoryFlushPlanResolver: getMemoryFlushPlanResolver(),
2156-memoryPromptBuilder: getMemoryPromptSectionBuilder(),
2157-memoryPromptSupplements: listMemoryPromptSupplements(),
2158-memoryRuntime: getMemoryRuntime(),
2159-});
2161+setCachedPluginRegistry(
2162+cacheKey,
2163+{
2164+commands: listRegisteredPluginCommands(),
2165+detachedTaskRuntimeRegistration: getDetachedTaskLifecycleRuntimeRegistration(),
2166+interactiveHandlers: listPluginInteractiveHandlers(),
2167+memoryCapability: getMemoryCapabilityRegistration(),
2168+memoryCorpusSupplements: listMemoryCorpusSupplements(),
2169+ registry,
2170+agentHarnesses: listRegisteredAgentHarnesses(),
2171+compactionProviders: listRegisteredCompactionProviders(),
2172+memoryEmbeddingProviders: listRegisteredMemoryEmbeddingProviders(),
2173+memoryFlushPlanResolver: getMemoryFlushPlanResolver(),
2174+memoryPromptBuilder: getMemoryPromptSectionBuilder(),
2175+memoryPromptSupplements: listMemoryPromptSupplements(),
2176+memoryRuntime: getMemoryRuntime(),
2177+},
2178+onlyPluginIds,
2179+);
21602180}
21612181if (shouldActivate) {
21622182activatePluginRegistry(registry, cacheKey, runtimeSubagentMode, options.workspaceDir);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。