UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

44 lines (43 loc) • 1.42 kB
//#region src/flows/health-check-registry.ts const REGISTRY = /* @__PURE__ */ new Map(); var HealthCheckRegistrationError = class extends Error { constructor(e) { super(`health check already registered: ${e}`); this.checkId = e; this.code = "OC_DOCTOR_DUPLICATE_CHECK"; this.name = "HealthCheckRegistrationError"; } }; function registerHealthCheck(e) { if (REGISTRY.has(e.id)) throw new HealthCheckRegistrationError(e.id); REGISTRY.set(e.id, e); } /** 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(e, t = []) { const n = new Set(e.map((e) => e.id)); const r = listHealthChecks(); for (const e of r) if (e.id.startsWith("core/doctor/") || n.has(e.id)) throw new HealthCheckRegistrationError(e.id); const i = []; for (const e of r) { if (e.kind === "core") continue; const n = t.find((t) => t.source !== void 0 && t.source === e.source); i.push(n ? { ...e, detect: async () => [{ ...n, checkId: e.id }], repair: void 0 } : e); } return i; } function getHealthCheck(e) { return REGISTRY.get(e); } //#endregion export { registerHealthCheck as i, listExtensionHealthChecksForDoctor as n, listHealthChecks as r, getHealthCheck as t };