UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 2.11 kB
import{a as e,i as t}from"./transcript-string-coerce-DTk-8HSr.mjs";import{t as n}from"./transcript-ids-CI0hGh_r.mjs";import{t as r}from"./transcript-string-readers-HOXt1pkc.mjs";import"./transcript-chat-display-projection.canvas-BVwGQyPV.mjs";import{t as i}from"./transcript-runtime-state-key-BezltqJW.mjs";import"node:util";let a;function getActivePluginChannelRegistrySnapshotFromState(){let e=globalThis[i],t=e?.activeRegistry??null,n=e?.activeVersion??0,r=a;if(r&&r.registry===t&&r.version===n)return r;let o={registry:t,version:n};return a=o,o}let o;function setLookupEntry(e,t,n){t&&!e.has(t)&&e.set(t,n)}function resolveRegisteredChannelPluginLookup(e){let n=getActivePluginChannelRegistrySnapshotFromState(),r=o,i=e===void 0||e===n.registry;if(i&&r?.snapshot===n)return r;let a=e??n.registry,s=a?.channels??[],c=/* @__PURE__ */ new Map,l=/* @__PURE__ */ new Map,u=/* @__PURE__ */ new Map;for(let e of s){u.has(e.plugin.id)||u.set(e.plugin.id,e),setLookupEntry(l,t(e.plugin.id),e);for(let n of e.plugin.meta?.aliases??[])setLookupEntry(c,t(n),e)}for(let[e,t]of l)c.set(e,t);let d={snapshot:i?n:{registry:a,version:0},currentRegistry:i,entries:s,byKey:c,byId:l,byExactId:u};return i&&(o=d),d}function findRegisteredChannelPluginEntry(e){return resolveRegisteredChannelPluginLookup().byKey.get(e)}function normalizeAnyChannelId(e){let n=t(e);return n?findRegisteredChannelPluginEntry(n)?.plugin.id??null:null}const s=`webchat`,c=[`heartbeat`,`cron`,`webhook`,`voice`,`sessions_send`];function isInternalNonDeliveryChannel(e){return r(e,c)}function normalizeMessageChannel(e){let r=t(e);return r?r===`webchat`?s:n(r)||(normalizeAnyChannelId(r)??r):void 0}function isNormalizedMessageChannel(e){let t=normalizeMessageChannel(e);return t!==void 0&&t!==`webchat`&&t===e}function buildRunUserTurnIdempotencyKey(e){return`${e}:user`}function normalizePersistedSteerTargetRunId(t){let n=e(t);return n&&n.length<=512?n:void 0}export{s as a,normalizeMessageChannel as i,normalizePersistedSteerTargetRunId as n,isInternalNonDeliveryChannel as o,isNormalizedMessageChannel as r,buildRunUserTurnIdempotencyKey as t};