File size: 957 Bytes
4c76b0d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | // Keep retained registry reads independent of metadata discovery and plugin loading.
import { AsyncLocalStorage } from "node:async_hooks";
import { resolveGlobalSingleton } from "../../shared/global-singleton.js";
import type { PluginRegistry } from "../registry-types.js";
const registryScope = resolveGlobalSingleton<AsyncLocalStorage<PluginRegistry>>(
Symbol.for("openclaw.pluginRuntimeGenerationRegistryScope"),
() => new AsyncLocalStorage<PluginRegistry>(),
);
export function withPluginRuntimeGenerationRegistryScope<T>(
registry: PluginRegistry,
run: () => T,
): T {
return registryScope.run(registry, run);
}
/** Exact registry owned by the prepared generation, including empty selections. */
export function getPluginRuntimeGenerationRegistry(): PluginRegistry | undefined {
return registryScope.getStore();
}
export function runOutsidePluginRuntimeGenerationRegistryScope<T>(run: () => T): T {
return registryScope.exit(run);
}
|