UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 2.66 kB
import{c as normalizeOptionalLowercaseString}from"./string-coerce-CpTFcSwY.mjs";import{u as normalizePluginsConfig}from"./config-state-C1eV6UWf.mjs";import{a as resolveManifestOwnerBasePolicyBlock}from"./manifest-owner-policy-DVnu9FAE.mjs";import{n as getCurrentPluginMetadataSnapshotRuntime}from"./plugin-metadata-snapshot.runtime.js";import{t as MissingPublicSurfaceError}from"./facade-loader-BQF_V8Ba.mjs";import{r as loadPluginPublicArtifactModuleSync,t as loadBundledPluginPublicArtifactModuleFromCandidatesSync}from"./public-surface-loader-BNZQgUD9.mjs"; //!src/media/channel-inbound-roots.ts const CHANNEL_MEDIA_CONTRACT_ARTIFACT=`media-contract-api.js`;function resolveInstalledChannelMediaContractOwners(e){try{const t=getCurrentPluginMetadataSnapshotRuntime({config:e.cfg,allowScopedSnapshot:true,allowWorkspaceScopedSnapshot:true});const n=normalizePluginsConfig(e.cfg.plugins);return(t?.manifestRegistry.plugins??[]).filter(t=>t.origin===`global`&&t.trustedOfficialInstall===true&&t.channels.some(t=>normalizeOptionalLowercaseString(t)===e.channelId)&&resolveManifestOwnerBasePolicyBlock({plugin:t,normalizedConfig:n})===null).toSorted((e,t)=>e.id.localeCompare(t.id))}catch{return[]}}function findChannelMediaContractApi(e){const t=normalizeOptionalLowercaseString(e.channelId);if(!t)return;const n=loadBundledPluginPublicArtifactModuleFromCandidatesSync({dirName:t,artifactCandidates:[CHANNEL_MEDIA_CONTRACT_ARTIFACT]});if(n&&typeof n[e.resolver]===`function`)return n;for(const n of resolveInstalledChannelMediaContractOwners({channelId:t,cfg:e.cfg}))try{const t=loadPluginPublicArtifactModuleSync({pluginRoot:n.rootDir,artifactBasename:CHANNEL_MEDIA_CONTRACT_ARTIFACT,origin:`global`});if(typeof t[e.resolver]===`function`)return t}catch(e){if(!(e instanceof MissingPublicSurfaceError))throw e}}function resolveChannelInboundAttachmentRoots(e){return resolveChannelInboundAttachmentRootsForChannel({cfg:e.cfg,channelId:e.ctx.Surface??e.ctx.Provider,accountId:e.ctx.AccountId})}function resolveChannelInboundAttachmentRootsForChannel(e){return findChannelMediaContractApi({channelId:e.channelId,cfg:e.cfg,resolver:`resolveInboundAttachmentRoots`})?.resolveInboundAttachmentRoots?.({cfg:e.cfg,accountId:e.accountId??void 0})}function resolveChannelRemoteInboundAttachmentRoots(e){return findChannelMediaContractApi({channelId:e.ctx.Surface??e.ctx.Provider,cfg:e.cfg,resolver:`resolveRemoteInboundAttachmentRoots`})?.resolveRemoteInboundAttachmentRoots?.({cfg:e.cfg,accountId:e.ctx.AccountId})}export{resolveChannelInboundAttachmentRootsForChannel as n,resolveChannelRemoteInboundAttachmentRoots as r,resolveChannelInboundAttachmentRoots as t};