openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.46 kB
JavaScript
import{t as formatErrorMessage}from"./errors-D37BJTfI.mjs";import{n as executeExistingOpenClawStateRead}from"./openclaw-state-db-readonly-Cd5_cxBs.mjs";import{r as resolveChannelIngressStateEnv,t as channelIngressHealthCache}from"./ingress-queue-health-cache-CPwCNO9b.mjs";
//!src/channels/message/ingress-queue-health.ts
async function countFailedChannelIngressQueueEntries(e){const t=await executeExistingOpenClawStateRead({env:resolveChannelIngressStateEnv(e)},{type:`channelIngress.failedHealth`});if(!t)return[];return t.result}async function countChannelIngressQueueHealth(e,t){const n=t?channelIngressHealthCache(t):void 0;const r=Date.now();const i=n?.failed;const a=n?.pressure&&r>=n.pressure.readAtMs&&r<(n.pressure.nextClaimExpiryAtMs??Infinity)?n.pressure.pressure:void 0;if(i&&a)return{failed:i,pressure:a};try{const t=await executeExistingOpenClawStateRead({env:resolveChannelIngressStateEnv(e)},{type:`channelIngress.health`,input:{now:r,failed:!i,pressure:!a}});if(!t)return{failed:i??[],pressure:a??[]};if(n){if(t.result.failed)n.failed=t.result.failed;if(t.result.pressure)n.pressure={...t.result.pressure,readAtMs:r}}return{failed:t.result.failed??i??[],pressure:t.result.pressure?.pressure??a??[],errors:t.result.errors}}catch(e){const t=formatErrorMessage(e);return{failed:i??[],pressure:a??[],errors:{...!i?{failed:t}:{},...!a?{pressure:t}:{}}}}}export{countFailedChannelIngressQueueEntries as n,countChannelIngressQueueHealth as t};