UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

68 lines (67 loc) • 3.53 kB
import { o as setCurrentManifestModelIdNormalizationPolicies } from "./provider-model-id-normalization-Yii1-7Le.mjs"; import { a as getPluginCache, d as getProcessPluginCache, t as adoptProcessPluginCache } from "./plugin-cache-B_eRuqTM.mjs"; //#region src/plugins/current-plugin-metadata-state.ts /** Selects an owned inventory and its prepared process-wide normalization policy together. */ function selectCurrentPluginMetadataCache(e) { adoptProcessPluginCache(e); const t = e.metadata.current; setCurrentManifestModelIdNormalizationPolicies(t.owner === "gateway" || t.defaultDiscoveryCompatible ? t.snapshot?.owners.modelIdNormalizationPolicies : void 0); } /** Owns config identity reuse for the current immutable metadata snapshot. */ const currentPluginMetadataConfigIdentityCache = { add(e) { getProcessPluginCache().metadata.current.configIdentities.add(e); }, clear() { getProcessPluginCache().metadata.current.configIdentities = /* @__PURE__ */ new WeakSet(); }, has(e) { return getProcessPluginCache().metadata.current.configIdentities.has(e); } }; /** Stores the process-current plugin metadata snapshot and compatible config fingerprints. */ function setCurrentPluginMetadataSnapshotState(e, t, n, r, i = "operation", a, o = false, s) { const c = getProcessPluginCache().metadata.current; c.snapshot = e; c.owner = i; c.configFingerprint = e ? t : void 0; c.agentWorkspaceFingerprint = e ? s : void 0; c.envFingerprint = e ? a : void 0; c.defaultDiscoveryCompatible = Boolean(e && o); c.compatibleConfigFingerprints = e ? n : void 0; setCurrentManifestModelIdNormalizationPolicies(e ? r : void 0); } /** 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 e = getProcessPluginCache().metadata.current; return e.owner === "gateway" && e.snapshot !== void 0; } /** Reads the boot inventory without importing discovery into lightweight consumers. */ function getGatewayPluginMetadataSnapshot() { const e = getPluginCache(); if (e.kind === "process" && e.metadata.current.owner === "gateway") return e.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 e = getProcessPluginCache().metadata.current; return { snapshot: e.snapshot, owner: e.owner, configFingerprint: e.configFingerprint, agentWorkspaceFingerprint: e.agentWorkspaceFingerprint, envFingerprint: e.envFingerprint, defaultDiscoveryCompatible: e.defaultDiscoveryCompatible, compatibleConfigFingerprints: e.compatibleConfigFingerprints }; } //#endregion export { getProcessGatewayPluginMetadataSnapshot as a, setCurrentPluginMetadataSnapshotState as c, getGatewayPluginMetadataSnapshot as i, currentPluginMetadataConfigIdentityCache as n, isGatewayPluginMetadataSnapshotActive as o, getCurrentPluginMetadataSnapshotState as r, selectCurrentPluginMetadataCache as s, clearCurrentPluginMetadataSnapshot as t };