UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

57 lines (56 loc) • 2.75 kB
import { t as formatErrorMessage } from "./errors-BvOkmQM5.mjs"; import { t as createSubsystemLogger } from "./subsystem-4NzR43uz.mjs"; import { t as isDiagnosticFlagEnabled } from "./diagnostic-flags-CaSenm_x.mjs"; import { p as listContextEngineQuarantines } from "./registry-BSFHwbcu.mjs"; import { t as captureDeliveryQueueStateContext } from "./delivery-queue-state-context-CpJOlAo7.mjs"; import { t as countFailedDeliveryQueueEntries } from "./delivery-queue-sqlite-DCCj1ADm.mjs"; import { n as countFailedChannelIngressQueueEntries, t as countChannelIngressQueuePressure } from "./ingress-queue-health-Bi4gQP22.mjs"; //#region src/gateway/health/context-engine.ts /** Projects active context-engine quarantines into the public health shape. */ async function buildContextEngineHealthSummary() { const quarantined = (await listContextEngineQuarantines()).map((entry) => { const summary = { engineId: entry.engineId, operation: entry.operation, reason: entry.reason, failedAt: entry.failedAt.getTime() }; return entry.owner ? Object.assign(summary, { owner: entry.owner }) : summary; }); return quarantined.length > 0 ? { quarantined } : void 0; } //#endregion //#region src/gateway/health/delivery-queue.ts const healthLog = createSubsystemLogger("health"); async function readQueueHealth(message, read) { try { return await read(); } catch (error) { if (isDiagnosticFlagEnabled("health")) healthLog.info(message, { error: formatErrorMessage(error) }); return []; } } function captureDeliveryQueueHealthContext() { try { return { stateContext: captureDeliveryQueueStateContext() }; } catch (error) { return { error }; } } /** Builds redacted inbound pressure and dead-letter health for gateway snapshots. */ async function buildDeliveryQueueHealthSummary(cachedIngressPressure, context = captureDeliveryQueueHealthContext()) { const failed = await readQueueHealth("outbound delivery queue health read failed", () => { if ("error" in context) throw context.error; return countFailedDeliveryQueueEntries(void 0, context.stateContext); }); const ingressFailed = await readQueueHealth("channel ingress failed queue health read failed", countFailedChannelIngressQueueEntries); const ingressPressure = cachedIngressPressure ?? await readQueueHealth("channel ingress pressure health read failed", countChannelIngressQueuePressure); if (failed.length === 0 && ingressFailed.length === 0 && ingressPressure.length === 0) return; return { failed, ...ingressFailed.length > 0 ? { ingressFailed } : {}, ...ingressPressure.length > 0 ? { ingressPressure } : {} }; } //#endregion export { captureDeliveryQueueHealthContext as n, buildContextEngineHealthSummary as r, buildDeliveryQueueHealthSummary as t };