UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

522 lines (521 loc) • 22.8 kB
import { r as asNullableRecord, u as isStringArray } from "./record-coerce-CVPuDqcc.mjs"; import { b as publishSqliteDatabaseAdmission, o as getSqliteDatabaseAdmission } from "./sqlite-database-admission-DQIqro3d.mjs"; import { s as stageSqliteTransactionState } from "./sqlite-post-commit-BrUVQObC.mjs"; import { i as executeSqliteQuerySync, s as getNodeSqliteKysely } from "./kysely-sync-YJo2lmGV.mjs"; import { t as encodeOpenClawStateWorkerError } from "./openclaw-state-worker-error-C8y1JGQN.mjs"; import { a as deferSqliteWorkerCommitReceipt } from "./sqlite-worker-operation-settlement-OZQM-wtd.mjs"; import "./sqlite-worker-operation-admission-9E_X-oRy.mjs"; import { l as loadDeliveryQueueEntryInDatabase, t as hasLiveDeliveryQueueClaim, y as oldestDeliveryQueueMediaStageAdmission } from "./delivery-queue-sqlite.types-B7uW265Q.mjs"; import { l as runOpenClawStateWriteTransaction } from "./openclaw-state-db-ARhwdPJg.mjs"; import { a as generateSecureUuid } from "./secure-random-CW5OZnK1.mjs"; import { a as OUTBOUND_DELIVERY_PREPARATION_QUEUE_NAME, c as OUTBOUND_LEGACY_PREPARATION_QUEUE_NAME, i as OUTBOUND_DELIVERY_MIGRATION_QUEUE_NAME, l as outboundDeliveryQueueName, n as DELIVERY_QUEUE_MEDIA_STAGING_QUEUE_NAME, o as OUTBOUND_DELIVERY_QUEUE_NAME, r as LEGACY_OUTBOUND_DELIVERY_QUEUE_NAME, s as OUTBOUND_EXECUTABLE_QUEUE_NAMES } from "./delivery-queue-namespaces-HQn65gG8.mjs"; import { _ as upsertDeliveryQueueEntryInDatabase, a as deleteDeliveryQueueEntryInDatabase, c as getDeliveryQueueEntriesOwnersInDatabase, f as prepareDeliveryQueueTerminalEntry, g as updateDeliveryQueueEntryInDatabase, h as terminalizePendingDeliveryQueueEntryInDatabase, i as countPendingDeliveryQueueEntriesInDatabase, m as reserveDeliveryQueueEntryAttemptInDatabase, n as completeLoadedDeliveryQueueEntryInDatabase, p as pruneExpiredDeliveryQueueTombstonesInDatabase, r as countFailedDeliveryQueueEntriesInDatabase, s as expireStagingAndLoadDeliveryQueueEntriesInDatabase, u as inspectDeliveryQueueReceiptInDatabase } from "./delivery-queue-sqlite.kernel-Cv08QjUU.mjs"; import { n as collectEntrySpoolPaths } from "./delivery-queue-media-paths-Bhk9Ljz0.mjs"; import { l as preparedOutboundPayloads, n as encodeOutboundDeliverySnapshot, r as projectOutboundDelivery, t as decodeOutboundDeliverySnapshot } from "./delivery-queue-projection-BhmCxxmH.mjs"; import { t as hasActiveDeliveryOwner } from "./delivery-queue-types-CVbI1W4D.mjs"; import { a as promoteDeliveryQueueEntryPlatformSendInDatabase, i as dispatchDeliveryQueueEntryPlatformSendInDatabase, n as claimDeliveryQueueEntryPlatformSendInDatabase, o as renewDeliveryQueueEntryPlatformSendLeaseInDatabase, s as transitionOwnedDeliveryQueueEntryInDatabase } from "./delivery-queue-sqlite-claim.kernel-D74In62c.mjs"; import { a as upsertDeliveryQueueEntryOnceAcrossNamespacesInDatabase, i as replacePendingDeliveryQueueEntryInDatabase, n as completePendingDeliveryQueueEntryInDatabase, r as movePendingDeliveryQueueEntryNamespaceInDatabase, t as commitStagedDeliveryQueueEntryOnceAcrossNamespacesInDatabase } from "./delivery-queue-sqlite-namespace.kernel-BaIvgfpz.mjs"; import { randomUUID } from "node:crypto"; //#region src/infra/outbound/delivery-queue-media-staging.kernel.ts function entryPayloads(e) { if (Array.isArray(e.payloads)) return e.payloads; return (e.preparedBatch?.entries ?? []).flatMap((e) => e.status === "accepted" && e.payload ? [e.payload] : []); } function createDeliveryQueueMediaRetentionInDatabase(e, t, n, r = { id: generateSecureUuid(), enqueuedAt: Date.now() }) { const { id: i, enqueuedAt: a } = r; const o = { id: i, enqueuedAt: a, retryCount: 0, artifacts: [...t] }; if (!upsertDeliveryQueueEntryInDatabase({ queueName: "outbound-media-staging", entry: o, metadata: { entryKind: n }, insertOnly: true }, e)) throw new Error(`Delivery queue media stage already exists: ${i}`); const s = getSqliteDatabaseAdmission(e.db, oldestDeliveryQueueMediaStageAdmission); if (s !== void 0) publishSqliteDatabaseAdmission(e.db, oldestDeliveryQueueMediaStageAdmission, s === null ? a : Math.min(s, a)); return i; } /** * Atomically expire abandoned stages and return every artifact still owned by * either a replayable outbound row or a producer that may still commit one. */ function loadDeliveryQueueMediaRetentionSnapshotInDatabase(e, t) { const n = expireStagingAndLoadDeliveryQueueEntriesInDatabase(e, { queueNames: [ ...OUTBOUND_EXECUTABLE_QUEUE_NAMES, LEGACY_OUTBOUND_DELIVERY_QUEUE_NAME, OUTBOUND_LEGACY_PREPARATION_QUEUE_NAME, OUTBOUND_DELIVERY_MIGRATION_QUEUE_NAME ], expireBeforeMs: t.expireBeforeMs }); const { rows: r } = executeSqliteQuerySync(e.db, getNodeSqliteKysely(e.db).selectFrom("migration_sources").select("report_json").where("migration_kind", "=", "delivery-queues").where("removed_source", "=", 0)); const i = r.flatMap((e) => { const t = asNullableRecord(JSON.parse(e.report_json)); if (t?.mediaPreserved === true) return []; const n = t?.mediaPaths; if (!isStringArray(n)) throw new Error("Cannot safely collect queue media with an invalid migration receipt"); return n; }); return { payloads: n.entries.map((e) => entryPayloads(e)), stagedArtifacts: n.stagingEntries.flatMap((e) => { const t = e.artifacts; return Array.isArray(t) ? t.filter((e) => typeof e === "string") : []; }).concat(i) }; } //#endregion //#region src/infra/outbound/delivery-queue-ownership.kernel.ts const OUTBOUND_DELIVERY_NAMESPACE_DESCRIPTORS = [ ...OUTBOUND_EXECUTABLE_QUEUE_NAMES.map((e) => [e, "prepared"]), [OUTBOUND_DELIVERY_PREPARATION_QUEUE_NAME, "preparing"], [OUTBOUND_DELIVERY_MIGRATION_QUEUE_NAME, "migration"], [OUTBOUND_LEGACY_PREPARATION_QUEUE_NAME, "legacy-preparing"], [LEGACY_OUTBOUND_DELIVERY_QUEUE_NAME, "legacy"] ]; /** Exact IDs share one custody owner across the executable outbound formats. */ function resolveOutboundDeliveryQueueNameInDatabase(e, t) { const n = getDeliveryQueueEntriesOwnersInDatabase(e, OUTBOUND_EXECUTABLE_QUEUE_NAMES, [t]).get(t); if (n && n.size > 1) throw new Error(`Ambiguous outbound delivery custody: ${t}`); return n?.keys().next().value ?? "outbound-prepared-v1"; } function findDeliveryIntentOwnersInDatabase(e, t) { const n = getDeliveryQueueEntriesOwnersInDatabase(e, OUTBOUND_DELIVERY_NAMESPACE_DESCRIPTORS.map(([e]) => e), t.ids); return t.ids.map((e) => { const t = n.get(e); if (OUTBOUND_EXECUTABLE_QUEUE_NAMES.filter((e) => t?.has(e)).length > 1) throw new Error(`Ambiguous outbound delivery custody: ${e}`); for (const [e, n] of OUTBOUND_DELIVERY_NAMESPACE_DESCRIPTORS) { const r = t?.get(e); if (r) return { queueName: e, namespace: n, retired: n !== "prepared", ...r }; } return null; }); } //#endregion //#region src/infra/outbound/delivery-queue-ack.kernel.ts /** Retires an unsent live claim while its adapter preparation still owns resources. */ function retireUnsentDeliveryInDatabase(e, t, n) { const r = t.stateDir; const i = resolveOutboundDeliveryQueueNameInDatabase(e, t.id); let a; transitionOwnedDeliveryQueueEntryInDatabase(e, { queueName: i, id: t.id, platformSendAttemptId: t.producerClaimId }, (o) => { if (o.recoveryState !== "producer_claimed" || o.platformSendAttemptId !== void 0 || o.platformSendStartedAt !== void 0 || !hasLiveDeliveryQueueClaim(o, t.producerClaimId, Date.now())) return; const s = o; if (n === "failed" && s.deliveryCompletion) return; const c = collectEntrySpoolPaths(preparedOutboundPayloads(s.preparedBatch), r); if (n === "failed" && terminalizePendingDeliveryQueueEntryInDatabase(e, prepareDeliveryQueueTerminalEntry({ queueName: i, id: s.id, entry: s, expectedStatus: "pending" })).status !== "terminalized") return; const l = c.length ? createDeliveryQueueMediaRetentionInDatabase(e, c, "outbound-media-recovery-lease") : void 0; if (n !== "failed") deleteDeliveryQueueEntryInDatabase(e, i, s.id); a = { spoolPaths: c, retention: l }; }); return a; } function ackDeliveryInDatabase(e, t, n, r) { const i = n; const a = resolveOutboundDeliveryQueueNameInDatabase(e, t); let o = []; const s = Boolean(r && "expectedPlatformSendAttemptId" in r); if (!transitionOwnedDeliveryQueueEntryInDatabase(e, { queueName: a, id: t, platformSendAttemptId: r?.expectedPlatformSendAttemptId ?? null, allowMissingEntry: !s }, (n) => { const s = n; o = collectEntrySpoolPaths(preparedOutboundPayloads(s.preparedBatch), i); if (s.completionRetention && r?.suppressCompletionReceipt !== true) completeLoadedDeliveryQueueEntryInDatabase(e, a, t, s); else deleteDeliveryQueueEntryInDatabase(e, a, t); })) throw new Error(`Delivery platform claim was lost: ${t}`); return o; } /** Conditionally dead-letter a freshly re-read pending entry without a claimed state. */ function failPendingDeliveryInDatabase(e, t, n) { const r = outboundDeliveryQueueName(t.entry); const i = { queueName: r, id: t.id, entry: t.entry }; const a = t.expectedPlatformSendAttemptId === void 0 ? n ?? prepareDeliveryQueueTerminalEntry(i) : void 0; let o = false; const terminalize = () => { o = terminalizePendingDeliveryQueueEntryInDatabase(e, a ?? prepareDeliveryQueueTerminalEntry(i)).status === "terminalized"; }; if (t.expectedPlatformSendAttemptId !== void 0) transitionOwnedDeliveryQueueEntryInDatabase(e, { queueName: r, id: t.id, platformSendAttemptId: t.expectedPlatformSendAttemptId }, terminalize); else terminalize(); return { status: o ? "failed" : "not_pending" }; } //#endregion //#region src/infra/outbound/delivery-queue-enqueue.worker.ts function executeDeliveryQueueEnqueue(e, t) { const n = JSON.parse(e.entryJson); const r = outboundDeliveryQueueName(n); const i = [ ...OUTBOUND_EXECUTABLE_QUEUE_NAMES.filter((e) => e !== r), OUTBOUND_DELIVERY_MIGRATION_QUEUE_NAME, OUTBOUND_LEGACY_PREPARATION_QUEUE_NAME, LEGACY_OUTBOUND_DELIVERY_QUEUE_NAME ]; let a = false; try { return runOpenClawStateWriteTransaction((t) => { deferSqliteWorkerCommitReceipt(t.db, true); stageSqliteTransactionState(t.db, { stage: () => { a = false; }, commit: () => { a = false; }, rollback: () => { a = true; } }); if (e.kind === "random" && !e.mediaStageId) { upsertDeliveryQueueEntryInDatabase({ queueName: r, entry: n }, t); return "created"; } if (e.kind === "prepared") return movePendingDeliveryQueueEntryNamespaceInDatabase(t, { sourceQueueName: OUTBOUND_DELIVERY_PREPARATION_QUEUE_NAME, destinationQueueName: r, conflictQueueNames: i, expectedSourceEntry: JSON.parse(e.preparationJson), destinationEntry: n, ...e.mediaStageId ? { stagingQueueName: DELIVERY_QUEUE_MEDIA_STAGING_QUEUE_NAME, stagingId: e.mediaStageId } : {} }); const o = { queueName: r, conflictQueueNames: e.kind === "stable" ? [...i, OUTBOUND_DELIVERY_PREPARATION_QUEUE_NAME] : [], entry: n }; if (e.mediaStageId) return commitStagedDeliveryQueueEntryOnceAcrossNamespacesInDatabase(t, { ...o, stagingId: e.mediaStageId, stagingQueueName: DELIVERY_QUEUE_MEDIA_STAGING_QUEUE_NAME }); return upsertDeliveryQueueEntryOnceAcrossNamespacesInDatabase(t, o) ? "created" : "existing"; }, t, { operationLabel: "enqueue outbound delivery" }); } catch (e) { if (a) { const t = encodeOpenClawStateWorkerError(e, { includeOrdinary: true }); if (t) return { status: "not-published", error: t }; } throw e; } } //#endregion //#region src/infra/outbound/delivery-queue-pending-failure.worker.ts function executePendingDeliveryFailure(e, t) { const n = JSON.parse(e.entryJson); const r = { ...e, entry: n }; const i = e.expectedPlatformSendAttemptId !== void 0 ? runOpenClawStateWriteTransaction((t) => failPendingDeliveryInDatabase(t, r, e.prepared), t, { operationLabel: `mutate owned ${OUTBOUND_DELIVERY_QUEUE_NAME} delivery platform send` }) : failPendingDeliveryInDatabase(t.database, r, e.prepared); return { result: i, spoolPaths: i.status === "failed" && e.retainSpoolArtifacts !== true ? collectEntrySpoolPaths(preparedOutboundPayloads(n.preparedBatch), e.stateDir) : [] }; } //#endregion //#region src/infra/outbound/delivery-queue-storage.kernel.ts /** Restore the exact pre-attempt row while its original owner still holds custody. */ function restoreDeliveryAttemptBeforeDispatchInDatabase(e, t, n, r) { const i = outboundDeliveryQueueName(t); if (!transitionOwnedDeliveryQueueEntryInDatabase(e, { queueName: i, id: t.id, platformSendAttemptId: r ?? null }, (r) => { const a = r; if (a.attemptCount !== n) throw new Error(`Delivery attempt reservation changed before rollback: ${t.id}`); const o = { ...a, attemptCount: t.attemptCount, availableAt: t.availableAt, producerClaimId: t.producerClaimId, platformSendAttemptId: t.platformSendAttemptId, platformSendStartedAt: t.platformSendStartedAt, effectiveReplyToId: t.effectiveReplyToId, recoveryState: t.recoveryState }; upsertDeliveryQueueEntryInDatabase({ queueName: i, entry: o }, e); })) throw new Error(`Delivery platform claim was lost: ${t.id}`); } function loadOutboundDeliveryInDatabase(e, t, n) { const r = resolveOutboundDeliveryQueueNameInDatabase(e, t); const i = loadDeliveryQueueEntryInDatabase(e, r, t, n); return i ? projectOutboundDelivery(r, i) : null; } //#endregion //#region src/infra/delivery-queue.worker.ts function claimPreparation(e, t) { const n = Date.now(); const r = { id: t, enqueuedAt: n, retryCount: 0, attemptCount: 0, retainOnFailure: true, preparationState: "claimed", preparationOwnerId: randomUUID(), preparationLeaseExpiresAt: n + 3e5 }; const i = OUTBOUND_DELIVERY_PREPARATION_QUEUE_NAME; if (upsertDeliveryQueueEntryOnceAcrossNamespacesInDatabase(e, { queueName: i, entry: r, conflictQueueNames: [ ...OUTBOUND_EXECUTABLE_QUEUE_NAMES, "outbound-prepared-migration-v1", "outbound-legacy-preparing-v1", "outbound" ] })) return { status: "claimed", entry: r }; const a = loadDeliveryQueueEntryInDatabase(e, i, t, "pending"); if (!a || (a.preparationLeaseExpiresAt ?? 0) > Date.now()) return { status: "existing" }; if (a.preparationState !== "claimed") { terminalizePendingDeliveryQueueEntryInDatabase(e, prepareDeliveryQueueTerminalEntry({ queueName: i, id: t, entry: a })); return { status: "existing" }; } return replacePendingDeliveryQueueEntryInDatabase(e, { queueName: i, expectedEntry: a, replacementEntry: r }) ? { status: "claimed", entry: r } : { status: "existing" }; } function mutateOutbound(e, t) { const n = resolveOutboundDeliveryQueueNameInDatabase(e, t.id); const r = t.expectedPlatformSendAttemptId; if ((t.kind === "start" || t.kind === "dispatch") && typeof r === "string") { if (!(t.kind === "start" ? promoteDeliveryQueueEntryPlatformSendInDatabase : dispatchDeliveryQueueEntryPlatformSendInDatabase)(e, { queueName: n, id: t.id, claimId: r, route: t.route })) throw new Error(`Delivery platform claim was lost: ${t.id}`); return; } const update = (e) => { const n = Date.now(); switch (t.kind) { case "fail": case "fail-before-send": case "fail-after-send": return { ...e, retryCount: e.retryCount + 1, lastAttemptAt: n, lastError: t.error, ambiguousTransportError: t.ambiguousTransportError, maxRetries: e.retryAmbiguousFinalText === true && t.ambiguousTransportError === true ? 2 : e.maxRetries, availableAt: void 0, producerClaimId: void 0, ...t.kind === "fail-before-send" ? { platformSendAttemptId: void 0, platformSendStartedAt: void 0, recoveryState: void 0 } : t.kind === "fail-after-send" ? { platformSendStartedAt: e.platformSendStartedAt ?? n, recoveryState: "unknown_after_send" } : { recoveryState: e.recoveryState === "producer_claimed" ? void 0 : e.recoveryState } }; case "start": case "dispatch": return { ...e, availableAt: void 0, producerClaimId: void 0, platformSendStartedAt: t.kind === "dispatch" ? n : e.platformSendStartedAt ?? n, ...t.route && "replyToId" in t.route ? { effectiveReplyToId: t.route.replyToId ?? null } : {}, recoveryState: t.kind === "dispatch" && e.recoveryState === "unknown_after_send" ? e.recoveryState : "send_attempt_started" }; case "unknown": return { ...e, availableAt: r && e.requiresProducerClaim === true && e.platformSendAttemptId === r ? e.availableAt : void 0, producerClaimId: void 0, platformSendStartedAt: e.platformSendStartedAt ?? n, recoveryState: "unknown_after_send" }; } return t; }; if (r !== void 0) { if (!transitionOwnedDeliveryQueueEntryInDatabase(e, { queueName: n, id: t.id, platformSendAttemptId: r }, (t) => { upsertDeliveryQueueEntryInDatabase({ queueName: n, entry: update(projectOutboundDelivery(n, t)) }, e); })) throw new Error(`Delivery platform claim was lost: ${t.id}`); } else updateDeliveryQueueEntryInDatabase(e, n, t.id, (e) => { return update(projectOutboundDelivery(n, e)); }); } function stageFailure(e, t) { const { entry: n, settlement: r, claimedAttemptId: i } = t; const a = outboundDeliveryQueueName(n); if (n.settlement) { const t = loadOutboundDeliveryInDatabase(e, n.id, "unfinished"); return t && JSON.stringify(t) === JSON.stringify(n) ? t : void 0; } const o = n.recoveryState === "producer_claimed" && i === void 0; const s = o ? claimDeliveryQueueEntryPlatformSendInDatabase(e, { queueName: a, id: n.id }) : i ?? n.platformSendAttemptId ?? null; if (o && !s) return; let c; transitionOwnedDeliveryQueueEntryInDatabase(e, { queueName: a, id: n.id, platformSendAttemptId: s ?? null }, (t) => { if (!o && i === void 0 && hasActiveDeliveryOwner(t, Date.now())) return; c = { ...projectOutboundDelivery(a, t), recoveryState: "settlement_pending", settlement: r }; upsertDeliveryQueueEntryInDatabase({ queueName: a, entry: c, status: "failed", updatePendingOnly: true }, e); }); return c; } function writeOperation(e, t) { return (n, { open: r, stateOptions: i }) => runOpenClawStateWriteTransaction((e) => t(e, n), { database: r(), ...i() }, { operationLabel: e }); } function readOperation(e) { return (t, { open: n }) => e(n(), t); } const deliveryQueueOperations = { "deliveryQueue.claimPreparation": writeOperation("deliveryQueue.claimPreparation", (e, t) => claimPreparation(e, t.id)), "deliveryQueue.replacePreparation": writeOperation("deliveryQueue.replacePreparation", (e, t) => replacePendingDeliveryQueueEntryInDatabase(e, { queueName: OUTBOUND_DELIVERY_PREPARATION_QUEUE_NAME, ...t })), "deliveryQueue.completePreparation": writeOperation("deliveryQueue.completePreparation", (e, t) => completePendingDeliveryQueueEntryInDatabase(e, { queueName: OUTBOUND_DELIVERY_PREPARATION_QUEUE_NAME, ...t })), "deliveryQueue.failPreparation": writeOperation("deliveryQueue.failPreparation", (e, t) => { terminalizePendingDeliveryQueueEntryInDatabase(e, prepareDeliveryQueueTerminalEntry({ queueName: OUTBOUND_DELIVERY_PREPARATION_QUEUE_NAME, id: t.entry.id, entry: t.entry })); }), "deliveryQueue.mutateOutbound": writeOperation("deliveryQueue.mutateOutbound", mutateOutbound), "deliveryQueue.reserveOutbound": writeOperation("deliveryQueue.reserveOutbound", (e, t) => reserveDeliveryQueueEntryAttemptInDatabase(e, { ...t, queueName: resolveOutboundDeliveryQueueNameInDatabase(e, t.id) })), "deliveryQueue.restoreOutbound": writeOperation("deliveryQueue.restoreOutbound", (e, t) => restoreDeliveryAttemptBeforeDispatchInDatabase(e, decodeOutboundDeliverySnapshot(t.entry), t.reservedAttemptCount, t.claimedAttemptId)), "deliveryQueue.stageFailure": writeOperation("deliveryQueue.stageFailure", (e, t) => { const n = decodeOutboundDeliverySnapshot(t.entry); const r = decodeOutboundDeliverySnapshot(t.settlementEntry); if (r.id !== n.id || t.settlementEntry.queueName !== t.entry.queueName || !r.settlement) throw new Error(`Invalid outbound delivery settlement snapshot: ${n.id}`); const i = stageFailure(e, { entry: n, settlement: r.settlement, claimedAttemptId: t.claimedAttemptId }); return i && encodeOutboundDeliverySnapshot(i); }), "deliveryQueue.finalizeFailure": writeOperation("deliveryQueue.finalizeFailure", (e, t) => { const n = decodeOutboundDeliverySnapshot(t.entry); return terminalizePendingDeliveryQueueEntryInDatabase(e, prepareDeliveryQueueTerminalEntry({ queueName: outboundDeliveryQueueName(n), id: n.id, entry: n, expectedStatus: "failed" })).status === "terminalized"; }), "deliveryQueue.retireUnsent": writeOperation("deliveryQueue.retireUnsent", (e, t) => retireUnsentDeliveryInDatabase(e, t, t.terminalOutcome)), "deliveryQueue.claimPlatformSend": writeOperation("deliveryQueue.claimPlatformSend", (e, t) => claimDeliveryQueueEntryPlatformSendInDatabase(e, { ...t, queueName: resolveOutboundDeliveryQueueNameInDatabase(e, t.id) }, t.claimId)), "deliveryQueue.renewPlatformSendLease": writeOperation("deliveryQueue.renewPlatformSendLease", (e, t) => renewDeliveryQueueEntryPlatformSendLeaseInDatabase(e, { ...t, queueName: resolveOutboundDeliveryQueueNameInDatabase(e, t.id) })), "deliveryQueue.ack": writeOperation(`mutate owned ${OUTBOUND_DELIVERY_QUEUE_NAME} delivery platform send`, (e, t) => ackDeliveryInDatabase(e, t.id, t.stateDir, t.options)), "deliveryQueue.enqueue": (e, { open: t, stateOptions: n }) => executeDeliveryQueueEnqueue(e, { database: t(), ...n() }), "deliveryQueue.failPending": (e, { open: t, stateOptions: n }) => executePendingDeliveryFailure(e, { database: t(), ...n() }), "deliveryQueue.findIntentOwners": readOperation(findDeliveryIntentOwnersInDatabase), "deliveryQueue.inspectReceipt": readOperation(inspectDeliveryQueueReceiptInDatabase), "deliveryQueue.countFailed": (e, { open: t }) => countFailedDeliveryQueueEntriesInDatabase(t()), "deliveryQueue.countPending": (e, { open: t }) => countPendingDeliveryQueueEntriesInDatabase(t(), e.queueNames), "deliveryQueue.pruneTombstones": (e, { open: t }) => pruneExpiredDeliveryQueueTombstonesInDatabase(t()), "deliveryQueue.createMediaRetention": writeOperation("deliveryQueue.createMediaRetention", (e, t) => createDeliveryQueueMediaRetentionInDatabase(e, t.artifacts, t.entryKind, t.prepared)), "deliveryQueue.cancelMediaRetention": writeOperation("deliveryQueue.cancelMediaRetention", (e, t) => deleteDeliveryQueueEntryInDatabase(e, DELIVERY_QUEUE_MEDIA_STAGING_QUEUE_NAME, t.id)), "deliveryQueue.mediaRetentionSnapshot": readOperation(loadDeliveryQueueMediaRetentionSnapshotInDatabase) }; //#endregion export { deliveryQueueOperations };