UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

55 lines (54 loc) • 1.87 kB
import { s as OPENCLAW_SQLITE_BUSY_TIMEOUT_MS } from "../openclaw-state-db-contract-BYv0nUQr.mjs"; import { a as runSqliteImmediateTransactionSync, t as assertTransactionUsable } from "../sqlite-transaction-DBRLvCDM.mjs"; import { t as encodeOpenClawStateWorkerError } from "../openclaw-state-worker-error-Bi-BnNrV.mjs"; import { n as ensureMessageToolRunOutcomeSchema } from "../openclaw-agent-message-tool-outcome-schema-DeqG2jjh.mjs"; import { t as recordMessageToolRunOutcomeInDatabase } from "../message-tool-run-outcome-store.kernel-B9dPqQrJ.mjs"; //#region src/infra/message-tool-run-outcome-store.worker.ts function bindSqliteWorkerBackend(_input, context) { const db = context.database; return { execute(command) { try { if (command.type === "prepare") { ensureMessageToolRunOutcomeSchema(db, (stage) => context.admit(stage)); return { ok: true, value: void 0 }; } runSqliteImmediateTransactionSync(db, () => { context.admit("transaction"); recordMessageToolRunOutcomeInDatabase(db, command.input); }, { operationLabel: "message-tool.run-outcome.record", busyTimeoutMs: OPENCLAW_SQLITE_BUSY_TIMEOUT_MS, databaseLabel: context.databasePath, withCommit(commit) { context.admit("commit"); commit(); } }); return { ok: true, value: void 0 }; } catch (error) { assertTransactionUsable(db); if (!db.isOpen || db.isTransaction) throw error; const failure = encodeOpenClawStateWorkerError(error, { includeOrdinary: true }); if (!failure) throw error; return { ok: false, error: failure }; } }, assertSettled() { assertTransactionUsable(db); if (db.isTransaction) throw new Error("Message-tool outcome transaction did not settle"); }, close() {} }; } //#endregion export { bindSqliteWorkerBackend };