UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

24 lines (23 loc) • 1.44 kB
import { a as resolveGlobalSingleton } from "./global-singleton-D7yf05nR.mjs"; import { t as runInDetachedAsyncContext } from "./detached-async-context-D_mi-wUl.mjs"; //#region src/infra/gateway-native-worker-recovery.ts const nativeWorkerRecovery = resolveGlobalSingleton(Symbol.for("openclaw.gatewayNativeWorkerRecovery"), () => ({})); const reportGatewayRuntimeRecoveryOnly = (e) => ({ status: "report-only", reason: `Automatic runtime recovery is report-only: ${e}` }); /** Worker owners retain native custody; only the registered process owner may restart. */ function requestGatewayNativeWorkerRecovery(e) { const t = nativeWorkerRecovery.request; if (!t) return Promise.resolve(reportGatewayRuntimeRecoveryOnly("no Gateway process lifecycle owns recovery.")); return runInDetachedAsyncContext(() => Promise.resolve().then(() => t(e)).catch(() => reportGatewayRuntimeRecoveryOnly("service or restart preparation failed. Inspect the native worker and restart through the service owner."))); } /** Bind requests to the latest process owner without letting an earlier release clear its replacement. */ function registerGatewayNativeWorkerRecovery(e) { nativeWorkerRecovery.request = e; return () => { if (nativeWorkerRecovery.request === e) nativeWorkerRecovery.request = void 0; }; } //#endregion export { reportGatewayRuntimeRecoveryOnly as n, requestGatewayNativeWorkerRecovery as r, registerGatewayNativeWorkerRecovery as t };