File size: 1,301 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
27
28
29
30
31
32
33
34
35
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]?.();
}