openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 2.23 kB
JavaScript
import{_ as resolveDefaultAgentId,f as resolveAgentWorkspaceDir}from"./agent-scope-config-CG9CFpGX.mjs";import"./agent-scope-Dw5XRSEh.mjs";import{c as normalizeChannelMeta}from"./bundled-CcedQErj.mjs";import{r as isChannelVisibleInSetup}from"./channel-meta-CjLF10Ak.mjs";import{r as listChatChannels}from"./chat-meta-CPf8a-2D.mjs";import{i as listTrustedChannelPluginCatalogEntries,n as listManifestInstalledChannelIds,r as listSetupDiscoveryChannelPluginCatalogEntries}from"./trusted-catalog-BvCsWGaP.mjs";import{t as isStaticallyChannelConfigured}from"./channel-configured-shared-DS1vbAhA.mjs";
//!src/commands/channel-setup/discovery.ts
function shouldShowChannelInSetup(e){return isChannelVisibleInSetup(e)}function resolveWorkspaceDir(e,t){return t??resolveAgentWorkspaceDir(e,resolveDefaultAgentId(e))}function isCatalogChannelInstalled(e){return listManifestInstalledChannelIds(e).has(e.entry.id)}function resolveChannelSetupEntries(e){const t=resolveWorkspaceDir(e.cfg,e.workspaceDir);const n=listManifestInstalledChannelIds({cfg:e.cfg,workspaceDir:t,env:e.env});const r=new Set(e.installedPlugins.map(e=>e.id));const i=listTrustedChannelPluginCatalogEntries({cfg:e.cfg,workspaceDir:t,env:e.env});const a=listSetupDiscoveryChannelPluginCatalogEntries({cfg:e.cfg,workspaceDir:t,env:e.env});const catalogEntries=(t,i)=>t.filter(t=>!r.has(t.id)&&n.has(t.id)===i&&(i||!isStaticallyChannelConfigured(e.cfg,t.id,e.env??process.env))&&shouldShowChannelInSetup(t.meta)).map(e=>Object.assign({},e,{meta:normalizeChannelMeta({id:e.id,meta:e.meta})}));const o=catalogEntries(i,true);const s=catalogEntries(a,false);const c=new Map(listChatChannels().map(e=>[e.id,normalizeChannelMeta({id:e.id,meta:e})]));for(const t of e.installedPlugins)c.set(t.id,normalizeChannelMeta({id:t.id,meta:t.meta,existing:c.get(t.id)}));for(const e of[...o,...s])if(!c.has(e.id))c.set(e.id,e.meta);return{entries:Array.from(c,([e,t])=>({id:e,meta:t})).filter(e=>shouldShowChannelInSetup(e.meta)),installedCatalogEntries:o,installableCatalogEntries:s,installedCatalogById:new Map(o.map(e=>[e.id,e])),installableCatalogById:new Map(s.map(e=>[e.id,e]))}}export{resolveChannelSetupEntries as n,shouldShowChannelInSetup as r,isCatalogChannelInstalled as t};