UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.74 kB
import{l as isRecord}from"../record-coerce-BTbqdJ3-.mjs";import{t as appendConfigPathSegment}from"../dot-path-B1bYAWM5.mjs";import"../shared-D0HXA3v0.mjs";import{t as collectTtsApiKeyAssignments}from"../runtime-config-collectors-tts-cytR34hI.mjs"; //!src/secrets/channel-secret-tts-runtime.ts function collectNestedChannelTtsAssignments(e){const t=e.providerBlockKey??`tts`;const n=e.ownerId;const resolveOwnerId=e=>typeof n===`function`?t=>n({accountId:e,providerId:t}):n??`tts`;const r=e.channel[e.nestedKey];const i=isRecord(r)&&isRecord(r[t])?r[t]:void 0;if(i){const collectTopLevel=(n,r)=>collectTtsApiKeyAssignments({tts:i,pathPrefix:`channels.${e.channelKey}.${e.nestedKey}.${t}`,ownerId:resolveOwnerId(n),defaults:e.defaults,context:e.context,active:r,inactiveReason:e.topInactiveReason});if(typeof e.ownerId!==`function`)collectTopLevel(`default`,e.topLevelActive);else{const t=e.surface.hasExplicitAccounts?e.surface.accounts.filter(({account:t,enabled:n})=>e.topLevelActive&&n&&!Object.hasOwn(t,e.nestedKey)):e.topLevelActive?[{accountId:`default`}]:[];if(t.length===0)collectTopLevel(`default`,false);else for(const{accountId:e}of t)collectTopLevel(e,true)}}if(!e.surface.hasExplicitAccounts)return;for(const n of e.surface.accounts){const r=n.account[e.nestedKey];const i=isRecord(r)&&isRecord(r[t])?r[t]:void 0;if(!i)continue;collectTtsApiKeyAssignments({tts:i,pathPrefix:`${appendConfigPathSegment(`channels.${e.channelKey}.accounts`,n.accountId)}.${e.nestedKey}.${t}`,ownerId:resolveOwnerId(n.accountId),defaults:e.defaults,context:e.context,active:e.accountActive(n),inactiveReason:typeof e.accountInactiveReason===`function`?e.accountInactiveReason(n):e.accountInactiveReason})}}export{collectNestedChannelTtsAssignments};