openclaw / src /plugins /runtime /generation-state.ts
SaylorTwift's picture
SaylorTwift HF Staff
Add files using upload-large-folder tool
4c76b0d verified
Raw
History Blame Contribute Delete
957 Bytes
// 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);
}