UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 2.44 kB
import{r as asNullableRecord}from"./record-coerce-BTbqdJ3-.mjs";import{t as asBoolean}from"./boolean-Dt_JCqyW.mjs";import{t as formatErrorMessage}from"./errors-D37BJTfI.mjs";import{r as resolveChannelAccount}from"./account-resolution-BMEKSThh.mjs";import{r as hasConfiguredUnavailableCredentialStatus}from"./account-snapshot-fields-Dt8EOHJC.mjs";import{o as resolveChannelAccountConfigured,s as resolveChannelAccountEnabled}from"./account-summary-lwAo0b5h.mjs";import{t as inspectChannelAccount}from"./account-inspection-iqk7WB2T.mjs"; //!src/gateway/health/account-context.ts const PUBLIC_IMESSAGE_FULL_DISK_ACCESS_ERROR=`imsg cannot access ~/Library/Messages/chat.db. Grant Full Disk Access to the Gateway/launcher process and restart Gateway.`;function buildNonSensitiveProbeFailure(e,t){const n=asNullableRecord(t);if(e!==`imessage`||!n||n.ok!==false)return;if(typeof n.error!==`string`)return;const r=n.error.trim().replaceAll(/\/Users\/[^/\s]+\/Library\/Messages\/chat\.db/g,`~/Library/Messages/chat.db`);if(!/\bimsg\b/i.test(r)||!r.includes(`~/Library/Messages/chat.db`)||!/\bFull Disk Access\b/i.test(r))return;return{ok:false,error:PUBLIC_IMESSAGE_FULL_DISK_ACCESS_ERROR}}async function resolveHealthAccountContext(e){const t=[];let n;try{n=await inspectChannelAccount(e)}catch(n){t.push(`${e.plugin.id}:${e.accountId}: failed to inspect account (${formatErrorMessage(n)}).`)}const r=asNullableRecord(n);const i=asBoolean(r?.enabled);const a=asBoolean(r?.configured);let o;if(i!==false&&!hasConfiguredUnavailableCredentialStatus(n))try{o=await resolveChannelAccount(e)}catch(n){t.push(`${e.plugin.id}:${e.accountId}: failed to resolve account (${formatErrorMessage(n)}).`)}if(o===null||o===void 0)return{probeAccount:void 0,inspectedAccount:n,enabled:i??false,configured:a,diagnostics:t};let s=asBoolean(asNullableRecord(o)?.enabled)??true;try{s=resolveChannelAccountEnabled({plugin:e.plugin,account:o,cfg:e.cfg})}catch(n){t.push(`${e.plugin.id}:${e.accountId}: failed to evaluate enabled state (${formatErrorMessage(n)}).`)}let c=asBoolean(asNullableRecord(o)?.configured)??true;try{c=await resolveChannelAccountConfigured({plugin:e.plugin,account:o,cfg:e.cfg})}catch(n){t.push(`${e.plugin.id}:${e.accountId}: failed to evaluate configured state (${formatErrorMessage(n)}).`)}return{probeAccount:o,inspectedAccount:n,enabled:s,configured:c,diagnostics:t}}export{resolveHealthAccountContext as n,buildNonSensitiveProbeFailure as t};