openclaw / src /plugins /runtime /load-context-state.ts
SaylorTwift's picture
SaylorTwift HF Staff
Add files using upload-large-folder tool
4c76b0d verified
Raw
History Blame Contribute Delete
1.3 kB
import type { DeclaredProviderOwnerIndex } from "../provider-owner-index.js";
export type PluginRuntimeLoadContextState = {
activationInputFingerprint: string;
activationResultFingerprint: string;
controlPlaneFingerprint: string;
registrationConfigKey: string;
loaderCacheIdentity?: Readonly<{ requestKey: string; resolvedKey: string }>;
declaredProviderOwners: DeclaredProviderOwnerIndex;
};
// Keep private config/env out of diagnostic traversal while registry spreads
// preserve the exact owning context across source and built readers.
const pluginRuntimeLoadContext = Symbol.for("openclaw.pluginRuntimeLoadContext");
type ContextCarrier = { [pluginRuntimeLoadContext]?: () => PluginRuntimeLoadContextState };
export function bindPluginRuntimeLoadContextState(
registry: object,
context: PluginRuntimeLoadContextState,
): void {
Object.defineProperty(registry, pluginRuntimeLoadContext, {
value: () => context,
configurable: true,
writable: true,
enumerable: true,
});
}
export function getPluginRuntimeLoadContextState(
registry: object | undefined,
): PluginRuntimeLoadContextState | undefined {
// SAFETY: Only the owning setter writes this private registry slot.
return (registry as ContextCarrier | undefined)?.[pluginRuntimeLoadContext]?.();
}