UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

5 lines • 2.88 kB
import{i as asOptionalObjectRecord,r as asNullableRecord}from"./record-coerce-BTbqdJ3-.mjs";import{f as normalizeStringEntries}from"./string-normalization-D_oBUpO3.mjs";import{t as findBundledChannelCatalogMetadata}from"./bundled-channel-catalog-read-CX1nvZIw.mjs";import{n as getBundledChannelPlugin}from"./bundled-CcedQErj.mjs";import{t as normalizeAnyChannelId}from"./registry-normalize-BP0gv89S.mjs";import"./registry-yecJKTDP.mjs";import{t as getChannelPlugin}from"./registry-CpNh6QcT.mjs";import{r as resolveChannelAccount}from"./account-resolution-BMEKSThh.mjs";import"./plugins-DxOycUNJ.mjs"; //!src/commands/doctor/channel-capabilities.ts const DEFAULT_DOCTOR_CHANNEL_CAPABILITIES={dmAllowFromMode:`topOnly`,groupModel:`sender`,groupAllowFromFallbackToAllowFrom:true,warnOnEmptyGroupSenderAllowlist:true};function mergeDoctorChannelCapabilities(e){const valueFor=t=>e?.[t]??DEFAULT_DOCTOR_CHANNEL_CAPABILITIES[t];return{dmAllowFromMode:valueFor(`dmAllowFromMode`),...typeof e?.openDmRequiresAllowFromWildcard===`boolean`?{openDmRequiresAllowFromWildcard:e.openDmRequiresAllowFromWildcard}:{},groupModel:valueFor(`groupModel`),groupAllowFromFallbackToAllowFrom:valueFor(`groupAllowFromFallbackToAllowFrom`),warnOnEmptyGroupSenderAllowlist:valueFor(`warnOnEmptyGroupSenderAllowlist`)}}function getDoctorChannelCapabilities(e){if(!e)return DEFAULT_DOCTOR_CHANNEL_CAPABILITIES;const t=findBundledChannelCatalogMetadata(e)?.doctorCapabilities;if(t)return mergeDoctorChannelCapabilities(t);const n=normalizeAnyChannelId(e);if(!n)return DEFAULT_DOCTOR_CHANNEL_CAPABILITIES;return mergeDoctorChannelCapabilities((getChannelPlugin(n)?.doctor??getBundledChannelPlugin(n)?.doctor)||findBundledChannelCatalogMetadata(n)?.doctorCapabilities)}async function resolveDoctorChannelAccountIds(e,t,n){const r=normalizeAnyChannelId(e);if(!r)return;try{const e=getChannelPlugin(r)??getBundledChannelPlugin(r);if(!e)return;const resolveAccountIds=async n=>{const r=await Promise.all(n.map(async n=>{const r=await resolveChannelAccount({plugin:e,cfg:t,accountId:n});const i=asOptionalObjectRecord(r)?.accountId;return typeof i===`string`&&i?i:void 0}));return r.every(e=>e!==void 0)?r:void 0};const i=await resolveAccountIds(n);const a=await resolveAccountIds(e.config.listAccountIds(t));return i&&a?{configured:i,runtime:a}:void 0}catch{return}} //!src/commands/doctor/shared/allowlist.ts function hasAllowFromEntries(e){return Array.isArray(e)&&normalizeStringEntries(e).length>0}function*iterateDoctorChannelAccounts(e,t,n=false){yield{account:e,prefix:t};for(const[r,i]of Object.entries(asNullableRecord(e.accounts)??{})){const a=asOptionalObjectRecord(i);if(a&&(!n||a.enabled!==false))yield{account:a,parent:e,accountId:r,prefix:`${t}.accounts.${r}`}}}export{resolveDoctorChannelAccountIds as i,iterateDoctorChannelAccounts as n,getDoctorChannelCapabilities as r,hasAllowFromEntries as t};