UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

73 lines (72 loc) 3.95 kB
import { a as getPluginCache, l as getProcessPluginCache } from "./plugin-cache-DGWspMEc.js"; import { s as setCurrentManifestModelIdNormalizationPolicies } from "./provider-model-id-normalization-BFjPahr6.js"; //#region src/plugins/current-plugin-metadata-state.ts /** Owns config identity reuse for the current immutable metadata snapshot. */ const currentPluginMetadataConfigIdentityCache = { add(config) { getProcessPluginCache().metadata.current.configIdentities.add(config); }, capture() { return getProcessPluginCache().metadata.current.configIdentities; }, clear() { getProcessPluginCache().metadata.current.configIdentities = /* @__PURE__ */ new WeakSet(); }, has(config) { return getProcessPluginCache().metadata.current.configIdentities.has(config); }, restore(identities) { getProcessPluginCache().metadata.current.configIdentities = identities; } }; /** Stores the process-current plugin metadata snapshot and compatible config fingerprints. */ function setCurrentPluginMetadataSnapshotState(snapshot, configFingerprint, compatiblePolicyHashes, compatibleConfigFingerprints, modelIdNormalizationPolicies, owner = "operation", envFingerprint, defaultDiscoveryCompatible = false) { const state = getProcessPluginCache().metadata.current; state.snapshot = snapshot; state.owner = owner; state.configFingerprint = snapshot ? configFingerprint : void 0; state.envFingerprint = snapshot ? envFingerprint : void 0; state.defaultDiscoveryCompatible = Boolean(snapshot && defaultDiscoveryCompatible); state.compatiblePolicyHashes = snapshot ? compatiblePolicyHashes : void 0; state.compatibleConfigFingerprints = snapshot ? compatibleConfigFingerprints : void 0; state.modelIdNormalizationPolicies = snapshot ? modelIdNormalizationPolicies : void 0; setCurrentManifestModelIdNormalizationPolicies(state.modelIdNormalizationPolicies); state.revision = Symbol("plugin-metadata-snapshot"); return state.revision; } /** Clears the snapshot, its identity cache, and process-wide model normalization. */ function clearCurrentPluginMetadataSnapshot() { currentPluginMetadataConfigIdentityCache.clear(); setCurrentPluginMetadataSnapshotState(void 0, void 0); } /** Install-ledger writes cannot retire metadata owned by a running Gateway. */ function isGatewayPluginMetadataSnapshotActive() { const state = getProcessPluginCache().metadata.current; return state.owner === "gateway" && state.snapshot !== void 0; } /** Reads the boot inventory without importing discovery into lightweight consumers. */ function getGatewayPluginMetadataSnapshot() { const cache = getPluginCache(); if (cache.kind === "process" && cache.metadata.current.owner === "gateway") return cache.metadata.current.snapshot; } /** Management compares a fresh candidate with boot state without making boot its read context. */ function getProcessGatewayPluginMetadataSnapshot() { if (isGatewayPluginMetadataSnapshotActive()) return getProcessPluginCache().metadata.current.snapshot; } /** Captures the current snapshot and the policies eligible for process-wide publication. */ function getCurrentPluginMetadataSnapshotState() { const state = getProcessPluginCache().metadata.current; return { snapshot: state.snapshot, owner: state.owner, configFingerprint: state.configFingerprint, envFingerprint: state.envFingerprint, defaultDiscoveryCompatible: state.defaultDiscoveryCompatible, compatiblePolicyHashes: state.compatiblePolicyHashes, compatibleConfigFingerprints: state.compatibleConfigFingerprints, modelIdNormalizationPolicies: state.modelIdNormalizationPolicies, revision: state.revision }; } //#endregion export { getProcessGatewayPluginMetadataSnapshot as a, getGatewayPluginMetadataSnapshot as i, currentPluginMetadataConfigIdentityCache as n, isGatewayPluginMetadataSnapshotActive as o, getCurrentPluginMetadataSnapshotState as r, setCurrentPluginMetadataSnapshotState as s, clearCurrentPluginMetadataSnapshot as t };