UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 2.07 kB
import{r as asNullableRecord}from"./record-coerce-BTbqdJ3-.mjs";import{r as resolveChannelAccount}from"./account-resolution-BMEKSThh.mjs";import{i as hasResolvedCredentialValue,r as hasConfiguredUnavailableCredentialStatus}from"./account-snapshot-fields-Dt8EOHJC.mjs";import{a as resolveUnavailableChannelAccountSnapshot}from"./account-state--nk_6U8k.mjs";import{i as buildChannelAccountSummary,n as buildChannelAccountSnapshotFromInspection,o as resolveChannelAccountConfigured,s as resolveChannelAccountEnabled}from"./account-summary-lwAo0b5h.mjs";import{t as inspectReadOnlyChannelAccount}from"./read-only-account-inspect-DIBat5m6.mjs"; //!src/channels/account-inspection.ts async function inspectChannelAccount(e){return e.plugin.config.inspectAccount?.(e.cfg,e.accountId)??await inspectReadOnlyChannelAccount({channelId:e.plugin.id,cfg:e.cfg,accountId:e.accountId})}async function resolveInspectedChannelAccount(e){const t=resolveUnavailableChannelAccountSnapshot(e.cfg,{channelId:e.plugin.id,accountId:e.accountId});if(t)return{kind:`unavailable`,account:t,enabled:t.enabled!==false,configured:t.configured===true,snapshot:t};const n=await inspectChannelAccount({...e,cfg:e.sourceConfig});const r=e.sourceConfig===e.cfg?n:await inspectChannelAccount(e);const i=asNullableRecord(r);const a=asNullableRecord(n);const o=Boolean(n&&hasConfiguredUnavailableCredentialStatus(n)&&(!hasResolvedCredentialValue(r)||a?.configured===true&&i?.configured===false))?n:r;if(o!=null){const t=buildChannelAccountSnapshotFromInspection({account:o,accountId:e.accountId});return{kind:`inspected`,account:o,enabled:t.enabled!==false,configured:t.configured,snapshot:t}}const s=await resolveChannelAccount(e);const c=resolveChannelAccountEnabled({plugin:e.plugin,account:s,cfg:e.cfg});const l=await resolveChannelAccountConfigured({plugin:e.plugin,account:s,cfg:e.cfg});return{kind:`resolved`,account:s,enabled:c,configured:l,snapshot:await buildChannelAccountSummary({...e,account:s,enabled:c,configured:l})}}export{resolveInspectedChannelAccount as n,inspectChannelAccount as t};