UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

44 lines (43 loc) • 1.68 kB
//#region src/flows/health-check-registry.ts const REGISTRY = /* @__PURE__ */ new Map(); var HealthCheckRegistrationError = class extends Error { constructor(checkId) { super(`health check already registered: ${checkId}`); this.checkId = checkId; this.code = "OC_DOCTOR_DUPLICATE_CHECK"; this.name = "HealthCheckRegistrationError"; } }; function registerHealthCheck(check) { if (REGISTRY.has(check.id)) throw new HealthCheckRegistrationError(check.id); REGISTRY.set(check.id, check); } /** Returns registered checks in insertion order for deterministic doctor output. */ function listHealthChecks() { return [...REGISTRY.values()]; } /** Returns registered extension checks after rejecting any reserved core doctor id claims. */ function listExtensionHealthChecksForDoctor(coreChecks, unavailablePlugins = []) { const coreIds = new Set(coreChecks.map((check) => check.id)); const registeredChecks = listHealthChecks(); for (const check of registeredChecks) if (check.id.startsWith("core/doctor/") || coreIds.has(check.id)) throw new HealthCheckRegistrationError(check.id); const checks = []; for (const check of registeredChecks) { if (check.kind === "core") continue; const unavailable = unavailablePlugins.find((finding) => finding.source !== void 0 && finding.source === check.source); checks.push(unavailable ? { ...check, detect: async () => [{ ...unavailable, checkId: check.id }], repair: void 0 } : check); } return checks; } function getHealthCheck(id) { return REGISTRY.get(id); } //#endregion export { registerHealthCheck as i, listExtensionHealthChecksForDoctor as n, listHealthChecks as r, getHealthCheck as t };