UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

32 lines (31 loc) • 1.21 kB
import { l as respondApprovalStorageUnavailable } from "./approval-shared-C8HrUVTB.mjs"; import { t as captureWorkerTurnLiveEventOwner } from "./worker-turn-run-owner-DBR48cWF.mjs"; //#region src/gateway/server-methods/approval-registration.ts /** Capture the validated requester before any approval preparation can yield. */ function captureApprovalWorkerOwner(e) { const t = e?.delegatedAuthority; return t?.kind === "worker" ? captureWorkerTurnLiveEventOwner({ sessionId: t.turnClaim.sessionId, turnClaim: t.turnClaim }) : void 0; } /** Registers an approval record and converts manager registration errors to gateway errors. */ async function registerPendingApprovalRecord(e) { try { const t = await e.manager.register(e.record, e.timeoutMs); if (e.workerOwner && e.manager.isPending(e.record)) { const n = e.workerOwner.beginApprovalWait(e.record.expiresAtMs, () => e.manager.isPending(e.record)); if (n) t.decision.then(() => n.close(), () => n.close()); } return t; } catch (t) { respondApprovalStorageUnavailable({ ...e, operation: "request", error: t }); return; } } //#endregion export { registerPendingApprovalRecord as n, captureApprovalWorkerOwner as t };