openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.42 kB
JavaScript
import{d as e}from"./openclaw-state-read-home-dir-BQZX1pD2.mjs";import{t}from"./openclaw-state-read-ids-hELWYH4S.mjs";const n=Symbol.for(`openclaw.pluginRegistryState`);let r;function getActivePluginChannelRegistrySnapshotFromState(){let e=globalThis[n],t=e?.activeRegistry??null,i=e?.activeVersion??0,a=r;if(a&&a.registry===t&&a.version===i)return a;let o={registry:t,version:i};return r=o,o}let i;function setLookupEntry(e,t,n){t&&!e.has(t)&&e.set(t,n)}function resolveRegisteredChannelPluginLookup(t){let n=getActivePluginChannelRegistrySnapshotFromState(),r=i,a=t===void 0||t===n.registry;if(a&&r?.snapshot===n)return r;let o=t??n.registry,s=o?.channels??[],c=/* @__PURE__ */ new Map,l=/* @__PURE__ */ new Map,u=/* @__PURE__ */ new Map;for(let t of s){u.has(t.plugin.id)||u.set(t.plugin.id,t),setLookupEntry(l,e(t.plugin.id),t);for(let n of t.plugin.meta?.aliases??[])setLookupEntry(c,e(n),t)}for(let[e,t]of l)c.set(e,t);let d={snapshot:a?n:{registry:o,version:0},currentRegistry:a,entries:s,byKey:c,byId:l,byExactId:u};return a&&(i=d),d}function findRegisteredChannelPluginEntry(e){return resolveRegisteredChannelPluginLookup().byKey.get(e)}function normalizeAnyChannelId(t){let n=e(t);return n?findRegisteredChannelPluginEntry(n)?.plugin.id??null:null}function normalizeMessageChannel(n){let r=e(n);return r?r===`webchat`?`webchat`:t(r)||(normalizeAnyChannelId(r)??r):void 0}export{normalizeMessageChannel as t};