Files
openclaw/src/plugins/loader-cache.ts
T
Peter Steinberger ccee629359 refactor(plugins): delete registry compat scaffolding (#117749)
* refactor(plugins): delete registry compat scaffolding

* test(plugins): update CLI registry handle mock

* fix(plugins): preserve explicitly initialized hook registries

* test(plugins): update registry ownership fixtures

* fix(channels): restore registry snapshot memo
2026-08-01 21:18:47 -07:00

33 lines
1.3 KiB
TypeScript

import { PluginLoaderCacheState } from "./loader-cache-state.js";
import { resolvePluginLoadCacheContext } from "./loader-load-context.js";
import type { PluginLoadOptions } from "./loader-types.js";
import { clearPluginRuntimeArtifactResolutionMemo } from "./plugin-runtime-artifact-resolution.js";
import type { PluginRegistry } from "./registry-types.js";
const MAX_PLUGIN_REGISTRY_CACHE_ENTRIES = 128;
export const pluginLoaderCacheState = new PluginLoaderCacheState<PluginRegistry>(
MAX_PLUGIN_REGISTRY_CACHE_ENTRIES,
);
export function setCachedPluginRegistry(cacheKey: string, registry: PluginRegistry): void {
pluginLoaderCacheState.set(cacheKey, registry);
}
export function getReusableCachedPluginRegistry(cacheKey: string): PluginRegistry | undefined {
return pluginLoaderCacheState.get(cacheKey);
}
export function clearPluginRegistryLoadCache(): void {
clearPluginRuntimeArtifactResolutionMemo();
pluginLoaderCacheState.clearCachedRegistries();
}
export function resolvePluginRegistryLoadCacheKey(options: PluginLoadOptions = {}): string {
return resolvePluginLoadCacheContext(options).cacheKey;
}
export function isPluginRegistryLoadInFlight(options: PluginLoadOptions = {}): boolean {
return pluginLoaderCacheState.isLoadInFlight(resolvePluginRegistryLoadCacheKey(options));
}