UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.46 kB
import{a as asOptionalRecord}from"./record-coerce-BTbqdJ3-.mjs";import{i as resolveChannelAccountKey,n as resolveAccountKey}from"./account-lookup-DXbrh7Os.mjs"; //!src/config/channel-account-config.ts function mergeAccountConfig(e){const t=/* @__PURE__ */ new Set([`accounts`,...e.omitKeys??[]]);const n=Object.fromEntries(Object.entries(e.channelConfig??{}).filter(([e])=>!t.has(e)));const r=e.accountConfig;const i={...n,...r};const a=i;for(const[t,i]of Object.entries(e.inheritEmptyKeys??{})){const e=r?.[t];const o=i===`array`?Array.isArray(e)?e:void 0:asOptionalRecord(e);if(o&&Object.keys(o).length===0)a[t]=n[t]}for(const t of e.nestedObjectKeys??[]){const e=asOptionalRecord(n[t]);const i=asOptionalRecord(r?.[t]);if(e&&i)a[t]={...e,...i}}if(e.preserveRootAllowFrom&&Array.isArray(n.allowFrom)&&Array.isArray(r?.allowFrom)){if(n.allowFrom.some(e=>{const t=String(e).trim();return t.length>0&&t!==`*`})&&r.allowFrom.some(e=>String(e).trim()===`*`)){const e=r.allowFrom.filter(e=>String(e).trim()!==`*`);a.allowFrom=e.length>0?e:n.allowFrom}}return i}function resolveMergedAccountConfig(e){const t=e.channelId?resolveChannelAccountKey(e.accounts,e.accountId,e.channelId,e.normalizeAccountId,e.accountKeyPolicy):resolveAccountKey(e.accounts,e.accountId,e.normalizeAccountId,e.accountKeyPolicy);const n=t===void 0?void 0:e.accounts?.[t];return mergeAccountConfig({...e,accountConfig:n})}export{resolveMergedAccountConfig as n,mergeAccountConfig as t};