UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

36 lines (35 loc) • 2.01 kB
import { b as extractSqliteTableSchema, h as runSqliteReadOperationSync, i as getAdmittedSqliteSchemaFacts } from "./sqlite-schema-facts-BVf0E_0z.mjs"; import { a as runSqliteImmediateTransactionSync } from "./sqlite-transaction-DBRLvCDM.mjs"; import { t as OPENCLAW_AGENT_SCHEMA_SQL } from "./openclaw-agent-schema-V6rru8Sr.mjs"; //#region src/infra/sqlite-schema-ensure.ts /** Install missing additive objects using the connection's admitted schema lifecycle. */ function createSqliteSchemaEnsurer(schemaSql, objects) { const present = (database) => { const facts = getAdmittedSqliteSchemaFacts(database); return facts !== void 0 && objects.tables.every((table) => facts.tables.has(table)) && (objects.indexes?.every((index) => facts.indexes.has(index)) ?? true); }; return (database) => { runSqliteReadOperationSync(database, () => { if (present(database)) return; const install = () => { if (!present(database)) database.exec(schemaSql()); }; if (database.isTransaction) install(); else runSqliteImmediateTransactionSync(database, install); }); }; } //#endregion //#region src/state/openclaw-agent-session-transcript-archive-schema.ts const SESSION_TRANSCRIPT_ARCHIVES_TABLE = "session_transcript_archives"; /** Lazily installs the additive canonical archive owner on first archive use. */ const ensureSessionTranscriptArchiveSchema = createSqliteSchemaEnsurer(() => extractSqliteTableSchema(OPENCLAW_AGENT_SCHEMA_SQL, SESSION_TRANSCRIPT_ARCHIVES_TABLE, { endMarker: "CREATE TABLE IF NOT EXISTS transcript_rewrite_watermarks (", includeEndMarker: false, errorMessage: "OpenClaw session transcript archive schema markers are missing." }), { tables: [SESSION_TRANSCRIPT_ARCHIVES_TABLE, "session_transcript_cold_archives"], indexes: ["idx_agent_session_transcript_archives_pending", "idx_agent_session_transcript_archives_retention"] }); //#endregion export { ensureSessionTranscriptArchiveSchema as n, createSqliteSchemaEnsurer as r, SESSION_TRANSCRIPT_ARCHIVES_TABLE as t };