openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
39 lines (38 loc) • 1.86 kB
JavaScript
import { n as isPostgresSqlConnection } from "./sql-connection-Beiyg5Dt.mjs";
import { c as withSqlitePostCommitPublications } from "./sqlite-post-commit-BrUVQObC.mjs";
import { n as readSqliteBusyTimeout } from "./sqlite-busy-timeout-BEDmnGR_.mjs";
import { i as runSqliteImmediateTransaction } from "./sqlite-transaction-BHHu6P5-.mjs";
import { n as assertAgentDeletionDatabaseCleanupAccess, o as getAgentDeletionDatabaseCleanup } from "./agent-deletion-cleanup-BweMIhGD.mjs";
import { r as cloneEnvWithPlatformSemantics } from "./config-env-vars-ByeGN-9N.mjs";
import { i as retainAgentDatabase, n as getOpenClawAgentDatabaseIfOpen } from "./openclaw-agent-db-borrower-BrziJlyo.mjs";
import { i as openOpenClawAgentDatabase } from "./openclaw-agent-db-CwXW4hGa.mjs";
//#region src/state/openclaw-agent-db-transaction.ts
/** Yield only for BEGIN admission; admitted writes and publications are never replayed. */
async function runOpenClawAgentWriteWithYieldingAdmission(e, t, n = {}) {
const r = {
...t,
env: cloneEnvWithPlatformSemantics(t.env ?? process.env)
};
const i = openOpenClawAgentDatabase(r);
r.path = i.path;
const a = retainAgentDatabase(i.db);
try {
return await runSqliteImmediateTransaction(i.db, async () => () => {
assertAgentDeletionDatabaseCleanupAccess(i, r);
return e(i);
}, {
...n,
...isPostgresSqlConnection(i.db) ? {} : { busyTimeoutMs: readSqliteBusyTimeout(i.db) },
databaseLabel: i.path,
operationLabel: n.operationLabel ?? "agent.write",
withCommit: getAgentDeletionDatabaseCleanup(r)?.withCommit
}, (e) => {
if (getOpenClawAgentDatabaseIfOpen(r) !== i) throw new Error(`Agent database closed or replaced before write: ${i.path}`);
return withSqlitePostCommitPublications(i.db, e);
});
} finally {
a();
}
}
//#endregion
export { runOpenClawAgentWriteWithYieldingAdmission as t };