openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
36 lines (35 loc) • 1.76 kB
JavaScript
import { l as isRecord } from "./record-coerce-CVPuDqcc.mjs";
import { n as isPostgresSqlConnection } from "./sql-connection-Beiyg5Dt.mjs";
import { w as readSqliteDatabaseIntegrityVerification } from "./sqlite-database-admission-DQIqro3d.mjs";
import { a as readOpenClawAgentDatabaseIdentity, r as findOpenClawAgentDatabaseIdentity } from "./openclaw-agent-db-identity-C8MGU8lp.mjs";
import { randomUUID } from "node:crypto";
//#region src/state/openclaw-agent-db-validation-facts.ts
const agentDatabaseValidationKey = {
name: "agent.completed-validation",
lifetime: "process",
read(e) {
return isRecord(e) ? e : void 0;
}
};
function matchesAgentDatabaseValidation(e, t) {
const n = findOpenClawAgentDatabaseIdentity(e);
return t.agentId === e.agentId && t.identity === n?.identity && t.birthtime === n?.birthtime && Atomics.load(new Int32Array(t.valid), 0) === 1;
}
function createOpenClawAgentDatabaseValidationReceipt(e, t) {
const { identity: n, birthtime: r } = readOpenClawAgentDatabaseIdentity(e);
if (typeof n !== "string" || r === void 0) throw new Error("Only persistent agent databases retain integrity validation");
const i = {
agentId: e.agentId,
identity: n,
birthtime: r,
receiptId: randomUUID(),
integrityVerifiedAt: isPostgresSqlConnection(e.db) ? void 0 : readSqliteDatabaseIntegrityVerification(e.db)?.verifiedAt,
valid: new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT),
canonicalReady: new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)
};
if (t) Atomics.store(new Int32Array(i.canonicalReady), 0, 1);
Atomics.store(new Int32Array(i.valid), 0, 1);
return i;
}
//#endregion
export { createOpenClawAgentDatabaseValidationReceipt as n, matchesAgentDatabaseValidation as r, agentDatabaseValidationKey as t };