openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
151 lines • 38.5 kB
JavaScript
import{Cn as e,xt as t}from"./openclaw-state-read-subsystem-Dwoo5bcz.mjs";import{B as n,Ct as r,D as i,F as a,I as o,L as s,M as c,N as l,R as u,X as d,Z as f,c as p,d as m,i as h,o as g,r as _,t as v,v as y,w as b,y as x,z as S}from"./openclaw-state-read-sqlite-database-admission-CrkztOzk.mjs";import{t as C,u as w}from"./openclaw-state-read-sqlite-post-commit-CsXPYVOo.mjs";import{o as T,u as E}from"./openclaw-state-read-kysely-sync-cache-state-C7JSbWq6.mjs";import{a as D,c as O}from"./openclaw-state-read-sqlite-schema-sql-BnVx4b5A.mjs";import{t as k}from"./openclaw-state-read-physical-facts-contract-D2VkVin1.mjs";import{isMainThread as A}from"node:worker_threads";import{createHash as j,randomUUID as M}from"node:crypto";import{isDeepStrictEqual as N}from"node:util";function canonical(e){return JSON.stringify(e,(e,t)=>typeof t==`object`&&t&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).toSorted(([e],[t])=>e.localeCompare(t,`en`))):t)}function assertPostgresCatalog(e,t){if(!N(e.map(canonical).toSorted(),t.map(canonical).toSorted()))throw Error(`PostgreSQL catalog differs from its generated contract; use the matching OpenClaw version or restore the matching PostgreSQL schema and anchor.`)}function readPostgresCatalog(e){if(!Array.isArray(e)||!e.every(e=>typeof e==`object`&&!!e&&typeof e.table==`string`&&typeof e.kind==`string`&&`value`in e))throw Error(`PostgreSQL did not return catalog facts`);return e}function postgresCatalogQuery(e,t=!1){let n=`'${e.replaceAll(`'`,`''`)}'`,columns=(e,t)=>`(SELECT jsonb_agg(a.attname ORDER BY k.ordinality) FROM unnest(${t}) WITH ORDINALITY k(num, ordinality) JOIN pg_catalog.pg_attribute a ON a.attrelid = ${e} AND a.attnum = k.num)`,action=e=>`CASE ${e} WHEN 'a' THEN 'NO ACTION' WHEN 'r' THEN 'RESTRICT' WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' WHEN 'd' THEN 'SET DEFAULT' END`;return`WITH relations AS (
SELECT c.oid, c.relname FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE n.nspname = ${n} AND c.relkind IN ('r', 'p')
), attributes AS (
SELECT r.relname, a.attname, a.atttypid, a.atttypmod, a.attnotnull,
a.attidentity, a.attnum, a.attgenerated, a.attcollation,
pg_catalog.pg_get_expr(d.adbin, d.adrelid) AS default_expression
FROM relations r JOIN pg_catalog.pg_attribute a ON a.attrelid = r.oid
LEFT JOIN pg_catalog.pg_attrdef d ON d.adrelid = r.oid AND d.adnum = a.attnum
WHERE a.attnum > 0 AND NOT a.attisdropped
), facts AS (
SELECT r.relname AS "table", 'table' AS kind, 'null'::jsonb AS value FROM relations r
UNION ALL SELECT a.relname, 'column', jsonb_build_object(
'name', a.attname, 'type', pg_catalog.format_type(a.atttypid, a.atttypmod),
'nullable', NOT a.attnotnull, 'identity', a.attidentity = 'd', 'position', a.attnum,
'default', regexp_replace(a.default_expression, '::(text|bigint|double precision)$', ''))
FROM attributes a
UNION ALL SELECT r.relname, CASE c.contype WHEN 'p' THEN 'primaryKey' ELSE 'unique' END,
${columns(`r.oid`,`c.conkey`)} FROM relations r JOIN pg_catalog.pg_constraint c ON c.conrelid = r.oid WHERE c.contype IN ('p', 'u')
UNION ALL SELECT r.relname, 'foreignKey', jsonb_build_object(
'columns', ${columns(`r.oid`,`c.conkey`)}, 'target', target.relname,
'targetColumns', ${columns(`c.confrelid`,`c.confkey`)},
'onUpdate', ${action(`c.confupdtype`)}, 'onDelete', ${action(`c.confdeltype`)},
'deferrable', c.condeferrable, 'deferred', c.condeferred)
FROM relations r JOIN pg_catalog.pg_constraint c ON c.conrelid = r.oid
JOIN pg_catalog.pg_class target ON target.oid = c.confrelid WHERE c.contype = 'f'
UNION ALL SELECT r.relname, 'indexes', to_jsonb((SELECT count(*) FROM pg_catalog.pg_index i WHERE i.indrelid = r.oid)) FROM relations r
UNION ALL SELECT r.relname, 'checks', to_jsonb((SELECT count(*) FROM pg_catalog.pg_constraint c WHERE c.conrelid = r.oid AND c.contype = 'c')) FROM relations r
${t?`UNION ALL SELECT r.relname, 'constraintDefinition', jsonb_build_object('name', c.conname, 'definition', pg_catalog.pg_get_constraintdef(c.oid)) FROM relations r JOIN pg_catalog.pg_constraint c ON c.conrelid = r.oid
UNION ALL SELECT r.relname, 'indexDefinition', jsonb_build_object('name', c.relname, 'definition', pg_catalog.pg_get_indexdef(i.indexrelid), 'valid', i.indisvalid) FROM relations r JOIN pg_catalog.pg_index i ON i.indrelid = r.oid JOIN pg_catalog.pg_class c ON c.oid = i.indexrelid
UNION ALL SELECT a.relname, 'columnDefinition', jsonb_build_object('name', a.attname, 'default', a.default_expression, 'generated', a.attgenerated, 'identity', a.attidentity, 'collation', a.attcollation::regcollation::text) FROM attributes a
UNION ALL SELECT r.relname, 'triggerDefinition', jsonb_build_object('name', t.tgname, 'definition', pg_catalog.pg_get_triggerdef(t.oid), 'enabled', t.tgenabled, 'function', pg_catalog.pg_get_functiondef(t.tgfoid)) FROM relations r JOIN pg_catalog.pg_trigger t ON t.tgrelid = r.oid WHERE NOT t.tgisinternal
UNION ALL SELECT c.relname, 'viewDefinition', to_jsonb(pg_catalog.pg_get_viewdef(c.oid)) FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = ${n} AND c.relkind IN ('v', 'm')
UNION ALL SELECT c.cfgname, 'textSearchDefinition', jsonb_build_object('token', m.maptokentype, 'order', m.mapseqno, 'dictionary', d.dictname, 'namespace', dn.nspname)
FROM pg_catalog.pg_ts_config c JOIN pg_catalog.pg_namespace n ON n.oid = c.cfgnamespace
JOIN pg_catalog.pg_ts_config_map m ON m.mapcfg = c.oid JOIN pg_catalog.pg_ts_dict d ON d.oid = m.mapdict
JOIN pg_catalog.pg_namespace dn ON dn.oid = d.dictnamespace WHERE n.nspname = ${n} AND c.cfgname = 'openclaw_simple_unaccent'
UNION ALL SELECT p.proname, 'functionDefinition', to_jsonb(pg_catalog.pg_get_functiondef(p.oid)) FROM pg_catalog.pg_proc p JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace WHERE n.nspname = ${n} AND p.proname = 'openclaw_vector' AND p.prokind = 'f'`:``}
) SELECT coalesce(jsonb_agg(facts), '[]'::jsonb) AS catalog FROM facts`}var DatabaseSearchCapabilityUnavailableError=class extends Error{constructor(e,t){super(t??`Database ${e} search capability is unavailable.`),this.capability=e,this.code=`DATABASE_SEARCH_CAPABILITY_UNAVAILABLE`,this.name=`DatabaseSearchCapabilityUnavailableError`}};const pgSearchName=e=>`"${e.replaceAll(`"`,`""`)}"`,P=`openclaw_simple_unaccent`;function postgresSearchVectorSql(e,t,n=1){let r=`coalesce(${t}, '')`;return`to_tsvector(${e}::regconfig, ${n===2?`regexp_replace(${r}, '[[:punct:]]+', ' ', 'g')`:r})`}function postgresSearchTextTriggerSql(e){let{table:t,field:n,sync:r}=e;return`CREATE FUNCTION ${r}() RETURNS trigger LANGUAGE plpgsql AS $$
BEGIN
NEW.openclaw_search := ${postgresSearchVectorSql(`format('%I.%I', TG_TABLE_SCHEMA, '${P}')`,`NEW.${n}`,2)};
RETURN NEW;
END $$;
CREATE TRIGGER ${r} BEFORE INSERT OR UPDATE OF ${n} ON ${t} FOR EACH ROW EXECUTE FUNCTION ${r}();`}const F={name:`database.postgres.search`,schemaDependent:!0};function admitPostgresSearch(e,t,n,r=1){let i=JSON.stringify(t);if(g(e,F)?.some(e=>e.signature===i&&e.vectorSearchVersion>=r))return;let a=/* @__PURE__ */ new Set;Object.keys(t.text??{}).length&&a.add(`unaccent`),Object.values(t.text??{}).some(e=>e.postgres?.mode===`trigram`)&&a.add(`pg_trgm`),t.mode!==`keyword-only`&&Object.keys(t.vector??{}).length&&a.add(`vector`);for(let e of t.mode===`keyword-only`?[]:Object.values(t.vector??{})){let t=e.postgres?.dimensions;if(!Number.isInteger(t)||t<1||t>16e3)throw Error(`PostgreSQL vector capability unavailable: dimensions must be 1–16000; choose a supported embedding dimension and rebuild the derived index.`)}let o=t.extensionSchema??`public`,s=e.prepare(`SELECT a.name, e.extname, e.extversion, n.nspname FROM pg_catalog.pg_available_extensions a
LEFT JOIN pg_catalog.pg_extension e ON e.extname = a.name
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = e.extnamespace
WHERE a.name IN ('unaccent', 'pg_trgm', 'vector')`).all();for(let e of a){let t=s.find(t=>t.name===e);if(!t?.extname||t.nspname!==o){let n=t?t.extname?`Configure the store's extensionSchema as ${String(t.nspname)}, or have a database administrator relocate the extension; installation SQL is`:`Have a database administrator run`:`Install the server extension package for ${e}, then have a database administrator run`;throw new DatabaseSearchCapabilityUnavailableError(e===`vector`?`vector`:`fullText`,`PostgreSQL ${e} capability unavailable. ${n}: CREATE EXTENSION IF NOT EXISTS ${pgSearchName(e)} WITH SCHEMA ${pgSearchName(o)};${e===`vector`?` For keyword-only memory explicitly set memory.search.provider to "none".`:``}`)}if(e===`vector`&&r===2){let e=/^(\d+)\.(\d+)/.exec(String(t.extversion));if(!e||Number(e[1])===0&&Number(e[2])<7)throw new DatabaseSearchCapabilityUnavailableError(`vector`,`PostgreSQL binary vector search requires pgvector 0.7 or newer. Upgrade the server extension package, then have a database administrator run ALTER EXTENSION vector UPDATE before reopening the store.`)}}if(e.prepare(`SELECT coalesce(has_schema_privilege(to_regnamespace(?), 'CREATE'), has_database_privilege(current_database(), 'CREATE'))::int AS allowed`).get(n)?.allowed!==1)throw Error(`PostgreSQL search capability unavailable: insufficient CREATE privilege. Have the database owner grant CREATE on schema ${pgSearchName(n)} (or on the database before initial admission).`);return()=>publishPostgresSearch(e,t,r)}function publishPostgresSearch(e,t,n=1){let r=JSON.stringify(t),i=g(e,F)??[],a=i.find(e=>e.signature===r);y(e,F,[...i.filter(e=>e.signature!==r),{signature:r,vectorSearchVersion:a?.vectorSearchVersion===2?2:n}])}function postgresVectorDecoderSql(e,t=1,n=!1){let r=pgSearchName(e);return t===1?`CREATE ${n?`OR REPLACE `:``}FUNCTION openclaw_vector(bytes bytea, dimensions integer) RETURNS ${r}.vector
LANGUAGE plpgsql IMMUTABLE STRICT AS $$
DECLARE vals real[] := '{}'; bits bigint; exponent integer; fraction double precision; value double precision;
BEGIN
IF octet_length(bytes) <> dimensions * 8 THEN RAISE EXCEPTION 'embedding dimension mismatch; rebuild the derived vector index'; END IF;
FOR i IN 0..dimensions-1 LOOP
bits := 0;
FOR j IN 0..7 LOOP bits := bits | (get_byte(bytes, i*8+j)::bigint << (j*8)); END LOOP;
exponent := ((bits >> 52) & 2047)::integer;
IF exponent = 2047 THEN RAISE EXCEPTION 'embedding must be finite'; END IF;
fraction := (bits & 4503599627370495)::double precision / 4503599627370496;
IF exponent < 873 OR (exponent = 873 AND fraction = 0) THEN value := 0;
ELSE value := (1 + fraction) * power(2::double precision, exponent - 1023); END IF;
IF bits < 0 THEN value := -value; END IF;
vals := array_append(vals, value::real);
END LOOP;
RETURN vals::${r}.vector;
END $$;`:`CREATE ${n?`OR REPLACE `:``}FUNCTION openclaw_vector(bytes bytea, dimensions integer) RETURNS ${r}.vector
LANGUAGE plpgsql IMMUTABLE STRICT AS $$
DECLARE vals double precision[]; first_nonfinite integer;
BEGIN
IF octet_length(bytes) <> dimensions * 8 THEN RAISE EXCEPTION 'embedding dimension mismatch; rebuild the derived vector index'; END IF;
-- Flatten TOAST once: repeated get_byte calls otherwise detoast the entire embedding.
bytes := bytes || '\\x'::bytea;
WITH bits AS MATERIALIZED (
SELECT i,
get_byte(bytes, i*8)::bigint |
(get_byte(bytes, i*8+1)::bigint << 8) |
(get_byte(bytes, i*8+2)::bigint << 16) |
(get_byte(bytes, i*8+3)::bigint << 24) |
(get_byte(bytes, i*8+4)::bigint << 32) |
(get_byte(bytes, i*8+5)::bigint << 40) |
(get_byte(bytes, i*8+6)::bigint << 48) |
(get_byte(bytes, i*8+7)::bigint << 56) AS b
FROM generate_series(0, dimensions-1) AS i
), parts AS (
SELECT i, b, ((b >> 52) & 2047)::integer AS exponent,
(b & 4503599627370495)::double precision / 4503599627370496 AS fraction
FROM bits
)
SELECT coalesce(array_agg(
CASE WHEN b < 0 THEN -1::double precision ELSE 1::double precision END *
CASE WHEN exponent = 2047 OR exponent < 873 OR (exponent = 873 AND fraction = 0)
THEN 0::double precision
ELSE (1 + fraction) * power(2::double precision, exponent - 1023)
END ORDER BY i
), ARRAY[]::double precision[]), min(i) FILTER (WHERE exponent = 2047)
INTO vals, first_nonfinite FROM parts;
IF first_nonfinite IS NOT NULL THEN
-- Preserve the old left-to-right overflow versus nonfinite error precedence.
PERFORM vals[1:first_nonfinite]::real[];
RAISE EXCEPTION 'embedding must be finite';
END IF;
RETURN vals::real[]::${r}.vector;
END $$;`}function postgresSearchSql(e,t,n={},r=1,i=1,a=1){let o=pgSearchName(e.extensionSchema??`public`),s=`${pgSearchName(t)}.${pgSearchName(P)}`,c=`'${s.replaceAll(`'`,`''`)}'`,l=[];Object.keys(e.text??{}).length&&!n.text&&l.push(`CREATE TEXT SEARCH CONFIGURATION ${s} (COPY = pg_catalog.simple);
ALTER TEXT SEARCH CONFIGURATION ${s} ALTER MAPPING FOR hword, hword_part, word, numword, numhword, hword_numpart WITH ${o}.unaccent, pg_catalog.simple;`);for(let t of Object.values(e.text??{})){if(!t.postgres||t.fields.length!==1)throw Error(`PostgreSQL text index requires one field and a declared source identity`);let e=pgSearchName(t.table),n=pgSearchName(t.fields[0]);l.push(a===2?`ALTER TABLE ${e} ADD COLUMN openclaw_search tsvector;
${postgresSearchTextTriggerSql({table:e,field:n,sync:pgSearchName(`${t.table}_search_sync`)})}
UPDATE ${e} SET openclaw_search = ${postgresSearchVectorSql(c,n,2)};`:`ALTER TABLE ${e} ADD COLUMN openclaw_search tsvector GENERATED ALWAYS AS (${postgresSearchVectorSql(c,n)}) STORED;`),l.push(`CREATE INDEX ${pgSearchName(`${t.table}_search_gin`)} ON ${e} USING gin(openclaw_search);`),t.postgres.mode===`trigram`&&l.push(`CREATE INDEX ${pgSearchName(`${t.table}_trgm_gin`)} ON ${e} USING gin(${n} ${o}.gin_trgm_ops);`)}if(e.mode===`keyword-only`)return l.join(`
`);Object.keys(e.vector??{}).length&&!n.vector&&l.push(postgresVectorDecoderSql(e.extensionSchema??`public`,r));for(let t of Object.values(e.vector??{})){let e=t.postgres;if(!e)throw Error(`PostgreSQL vector index requires a canonical embedding source`);let n=pgSearchName(t.table),r=pgSearchName(e.source),a=pgSearchName(e.key),s=pgSearchName(e.embedding),c=`INSERT INTO ${n}(id, embedding) SELECT ${a}, openclaw_vector(${s}, ${e.dimensions}) FROM ${r} WHERE octet_length(${s}) > 0`,u=i===2?`, embedding_bits bit(${e.dimensions}) GENERATED ALWAYS AS (CASE WHEN ${o}.vector_norm(embedding) > 0 THEN ${o}.binary_quantize(embedding)::bit(${e.dimensions}) ELSE NULL END) STORED`:``;l.push(`CREATE TABLE ${n} (id TEXT PRIMARY KEY REFERENCES ${r}(${a}) ON UPDATE CASCADE ON DELETE CASCADE, embedding ${o}.vector(${e.dimensions}) NOT NULL${u});
CREATE FUNCTION ${pgSearchName(`${t.table}_sync`)}() RETURNS trigger LANGUAGE plpgsql AS $$
BEGIN
IF TG_OP = 'UPDATE' AND OLD.${s} IS NOT DISTINCT FROM NEW.${s} THEN RETURN NEW; END IF;
IF octet_length(NEW.${s}) > 0 THEN
INSERT INTO ${n}(id, embedding) VALUES (NEW.${a}, openclaw_vector(NEW.${s}, ${e.dimensions}))
ON CONFLICT (id) DO UPDATE SET embedding = EXCLUDED.embedding;
ELSE
DELETE FROM ${n} WHERE id = NEW.${a};
END IF;
RETURN NEW;
END $$;
CREATE TRIGGER ${pgSearchName(`${t.table}_sync`)} AFTER INSERT OR UPDATE OF ${s} ON ${r} FOR EACH ROW EXECUTE FUNCTION ${pgSearchName(`${t.table}_sync`)}();
${c};`)}return l.join(`
`)}function postgresStoreNamespace(e,t,n){return`${e}_${t}_${n.replaceAll(`-`,``).slice(0,16)}`}const I=`CREATE TABLE openclaw_schema_meta (
store TEXT PRIMARY KEY, version BIGINT NOT NULL, store_id TEXT NOT NULL,
fingerprint TEXT, ddl_hash TEXT, server_major BIGINT)`,L=`Use a compatible OpenClaw binary or restore the matching PostgreSQL schema and anchor; do not edit schema metadata.`,R=`openclaw_schema`,quote=e=>`"${e.replaceAll(`"`,`""`)}"`,hash$1=e=>j(`sha256`).update(e).digest(`hex`),z=/* @__PURE__ */ new WeakMap,B={name:`database.postgres.schema`,schemaDependent:!0},getAdmittedPostgresSchema=e=>g(e,B),retainPostgresSchema=(e,t)=>{let{postgresMigrations:n,...r}=t;y(e,B,r)};function admitPostgresCapabilities(e){let t=z.get(e);if(t)return t;let n=e.prepare(`SELECT current_setting('server_version_num')::int AS version, current_setting('server_encoding') AS server_encoding, current_setting('client_encoding') AS client_encoding`).get();if(!n||typeof n.version!=`number`||n.version<16e4||n.server_encoding!==`UTF8`||n.client_encoding!==`UTF8`)throw Error(`PostgreSQL requires version 16 or newer and UTF8 server/client encoding; upgrade the server or port to a UTF8 database and set client_encoding=UTF8.`);let r={serverMajor:Math.floor(n.version/1e4),serverEncoding:`UTF8`,clientEncoding:`UTF8`};return z.set(e,r),r}function readPostgresSchema(e,t,n){let r=e.query(`WITH captured AS (${postgresCatalogQuery(t,!0)})
SELECT catalog::text, to_jsonb(meta)::text AS metadata FROM captured
CROSS JOIN ${quote(t)}.openclaw_schema_meta meta WHERE meta.store = ?`,[n]).rows[0];if(!r||typeof r.catalog!=`string`||typeof r.metadata!=`string`)throw Error(`Missing PostgreSQL catalog or metadata. ${L}`);let i=JSON.parse(r.metadata);return{catalog:readPostgresCatalog(JSON.parse(r.catalog)),metadata:i}}function withPostgresSearchExtensions(e,t){return{...e,searchExtensions:JSON.parse(t.metadata.search_extensions??`{}`)}}function postgresSchemaFingerprint(e,t){let n=e.filter(e=>e.table!==`openclaw_schema_meta`).map(e=>JSON.stringify(e)).toSorted().join(`
`);if(!t)return hash$1(n);let r=JSON.stringify(t.from).slice(1,-1),i=JSON.stringify(quote(t.from)).slice(1,-1),a=JSON.stringify(t.to).slice(1,-1);return hash$1(n.replaceAll(`${i}.`,`${r}.`).replaceAll(r,a))}function postgresSchemaSql(e,t,n){let r=new Set(n?.filter(e=>e.kind===`table`).map(e=>e.table)),i=e.postgresFragments?.filter(e=>n?e.tables.some(e=>r.has(e)):e.activation===`version-additive`)??[],a=/* @__PURE__ */ new Map,add=t=>{if(!a.has(t.id)){for(let n of t.dependencies){let t=e.postgresFragments?.find(e=>e.id===n);if(!t)throw Error(`Missing PostgreSQL fragment dependency ${n}`);add(t)}a.set(t.id,t.sql)}};i.forEach(add);let o=[e.search,...Object.values(e.searchExtensions??{})].filter(e=>e!==void 0),s={text:!1,vector:!1},c=o.map(n=>{let r=postgresSearchSql(n,t,s,e.postgresVectorDecoderVersion,e.postgresVectorSearchVersion,e.postgresTextSearchVersion);return s.text||=Object.keys(n.text??{}).length>0,s.vector||=n.mode!==`keyword-only`&&Object.keys(n.vector??{}).length>0,`;\n${r}`});return[e.postgres??``,...a.values(),...c].join(`
`)}function recordPostgresSchema(e,t,n,r){if(!e.isTransaction)throw Error(`PostgreSQL schema publication requires the owner's writer transaction`);let i=r??readPostgresSchema(e,t,n.id);e.prepare(`UPDATE openclaw_schema_meta SET fingerprint = ?, ddl_hash = ?, server_major = ? WHERE store = ?`).run(postgresSchemaFingerprint(i.catalog),hash$1(postgresSchemaSql(n,R,i.catalog)),admitPostgresCapabilities(e).serverMajor,n.id)}function verifyPostgresSchema(e,t,n,r,i=!1){let a=postgresSchemaFingerprint(r.catalog),o=postgresSchemaSql(n,R,r.catalog),{metadata:s}=r,c=admitPostgresCapabilities(e).serverMajor;if(s.server_major===c&&s.fingerprint&&s.fingerprint!==a)throw Error(`PostgreSQL schema drift detected. ${L}`);s.server_major===c&&s.fingerprint&&s.ddl_hash===hash$1(o)||(i?e.runTransaction(()=>verifyPostgresSchemaDefinition(e,t,n,r)):verifyAndRecordPostgresSchema(e,t,n,r))}function verifyPostgresSchemaDefinition(e,t,n,r){let i=postgresSchemaFingerprint(r.catalog,{from:t,to:t}),a=`openclaw_check_${M().replaceAll(`-`,``)}`;e.exec(`CREATE SCHEMA ${quote(a)}`);try{e.exec(`SET LOCAL search_path TO ${quote(a)}`),e.exec(postgresSchemaSql(n,a,r.catalog));let o=e.query(`SELECT catalog::text FROM (${postgresCatalogQuery(a,!0)}) captured`).rows[0];if(postgresSchemaFingerprint(readPostgresCatalog(JSON.parse(String(o?.catalog))),{from:a,to:t})!==i)throw Error(`PostgreSQL schema drift detected against generated DDL. ${L}`)}finally{e.exec(`SET LOCAL search_path TO ${quote(t)}`),e.exec(`DROP SCHEMA ${quote(a)} CASCADE`)}}function verifyAndRecordPostgresSchema(e,t,n,r=readPostgresSchema(e,t,n.id)){return e.runTransaction(()=>{verifyPostgresSchemaDefinition(e,t,n,r),r.metadata.ddl_hash||e.exec(`ALTER TABLE openclaw_schema_meta ADD COLUMN IF NOT EXISTS fingerprint TEXT, ADD COLUMN IF NOT EXISTS ddl_hash TEXT, ADD COLUMN IF NOT EXISTS server_major BIGINT`),recordPostgresSchema(e,t,n,r)}),r}const V=`Use the matching OpenClaw version or restore the matching PostgreSQL schema and anchor.`;function getPostgresPhysicalFacts(e,t){return g(e,k,t)}function admitPostgresPhysicalFacts(e){let t=getPostgresPhysicalFacts(e.db);if(t)return t;let n=admitPostgresCapabilities(e.db),r;try{r=readPostgresSchema(e.db,e.namespace,e.store)}catch(e){throw Error(`Cannot read PostgreSQL catalog or metadata. ${V}`,{cause:e})}let{metadata:i,catalog:a}=r;if(i.version!==e.version||i.store_id!==e.storeId)throw Error(`PostgreSQL metadata identity or version mismatch. ${V}`);if(e.schema){let t=withPostgresSearchExtensions(e.schema,r);e.recordSchema?recordPostgresSchema(e.db,e.namespace,t,r):verifyPostgresSchema(e.db,e.namespace,t,r,e.preserveSchemaSeal),retainPostgresSchema(e.db,t)}let o={engine:`postgres`,admissionId:M(),store:e.store,namespace:e.namespace,storeId:i.store_id,version:i.version,capabilities:n,catalog:a};return y(e.db,k,o),o}function requireNativeDatabaseFile(e,t){if(e===`postgres`)throw Error(`PostgreSQL cannot use SQLite ${t}; stop the Gateway and back up/restore the PostgreSQL schema with its matching anchor (P3-6 export support pending).`)}const H=e(Symbol.for(`openclaw.sqlitePinnedReadSnapshots`),()=>/* @__PURE__ */ new WeakMap);function getSqlitePinnedReadSnapshot(e){return H.get(e)}function runSqliteSchemaReadSnapshotSync(e,t){let n=H.get(e);for(let r=0;;r+=1){H.set(e,n??{});try{let n=T(e,`PRAGMA schema_version`,[],e=>{let n;try{let i;try{n=e.iterate(),i=n.next()}catch(e){if(!A&&r<4&&(f(e)===261||d(e)===`SQLITE_BUSY_RECOVERY`))return{retry:!0};throw e}if(i.done)throw Error(`SQLite schema_version query returned no row`);return{retry:!1,value:t(Number(i.value.schema_version))}}finally{n?.return?.()}});if(!n.retry)return n.value}finally{n||H.delete(e)}}}const U={name:`sqlite-schema`,writer:`connection`,lifetime:`process`,schemaDependent:!0,read:e=>t(e)?e:void 0},W={name:`sqlite-text-encoding`,writer:`connection`,lifetime:`process`,read:e=>typeof e==`string`?e:void 0};function readSqliteTextEncoding(e){let t=g(e,W);if(t!==void 0)return t;let n=T(e,`PRAGMA encoding`,[],e=>e.get());if(typeof n?.encoding!=`string`)throw Error(`SQLite did not report its text encoding`);return n.encoding}function readSqliteSchemaObjects(e){return T(e,`SELECT type, name, tbl_name, sql FROM main.sqlite_schema WHERE type IN ('table', 'view', 'index', 'trigger')`,[],e=>e.all())}function captureSqliteSchemaFacts(e,t=0,n){let r=g(e,W),i=runSqliteSchemaReadSnapshotSync(e,i=>{let a=T(e,`PRAGMA user_version`,[],e=>e.get()),o=Number(a?.user_version??0);n?.(o);let s=r??readSqliteTextEncoding(e),c=readSqliteSchemaObjects(e),l={admissionId:M(),revision:t,userVersion:o,textEncoding:s,schemaVersion:i,tables:/* @__PURE__ */ new Set,views:/* @__PURE__ */ new Set,tableSql:/* @__PURE__ */ new Map,indexes:/* @__PURE__ */ new Set,indexDefinitions:/* @__PURE__ */ new Map,triggers:/* @__PURE__ */ new Map};for(let e of c){if(typeof e.name!=`string`)continue;let t=typeof e.sql==`string`?e.sql:null;switch(e.type){case`table`:l.tables.add(e.name),l.tableSql.set(e.name,t);break;case`view`:l.views.add(e.name);break;case`index`:l.indexes.add(e.name),typeof e.tbl_name==`string`&&l.indexDefinitions.set(e.name,{table:e.tbl_name,sql:t});break;case`trigger`:typeof e.tbl_name==`string`&&l.triggers.set(e.name,{table:e.tbl_name,sql:t})}}return l});return r===void 0&&(i.tables.size>0||i.views.size>0)&&y(e,W,i.textEncoding),i}function captureTrackedSqliteSchemaFacts(e,t,n){t.capturing=!0;try{return captureSqliteSchemaFacts(e,t.revision,n)}finally{t.capturing=!1}}function invalidateTrackedSqliteSchemaFacts(e){e.revision+=1,e.facts=void 0}function observeSchemaLifetime(e,t,n){t.snapshot&&t.snapshot!==n&&((!e.isTransaction||!t.transactionCatalogBound)&&invalidateTrackedSqliteSchemaFacts(t),t.snapshot=void 0,t.qualifiedSnapshot=void 0);let r=p(e),i=t.processRevision!==void 0&&t.processRevision!==r;return i&&!t.transactionalSchema&&(e.isTransaction&&t.transactionCatalogBound||t.facts&&n&&t.qualifiedSnapshot===n)?(t.transactionalFacts||=e.isTransaction,t.snapshot=n,!1):(t.processRevision=r,i&&invalidateTrackedSqliteSchemaFacts(t),(t.transactionalSchema||t.transactionalTempSchema||t.transactionalFacts)&&!e.isTransaction&&(t.transactionalSchema&&x(e),invalidateTrackedSqliteSchemaFacts(t),t.transactionalSchema=!1,t.transactionalTempSchema=!1,t.transactionalFacts=!1),i)}function prepareSqliteTempTrackingSchema(e,t){let{createSql:n,objects:r}=prepareTranscriptIndexSchema(t),i=new Map(r.map(e=>[e.name.toLowerCase(),e])),a=r.map(e=>e.name),o=r.filter(e=>e.type===`table`).map(e=>e.name),s=[...a,...o],c=T(e,`SELECT type, name, tbl_name, sql FROM temp.sqlite_schema
WHERE name COLLATE NOCASE IN (${a.map(()=>`?`).join(`,`)})
OR (type = 'trigger' AND tbl_name COLLATE NOCASE IN (${o.map(()=>`?`).join(`,`)}))`,s,e=>e.all(...s)),l=c.some(e=>{let t=typeof e.name==`string`?i.get(e.name.toLowerCase()):void 0;return!t||e.type!==t.type||e.tbl_name!==t.table||typeof e.sql!=`string`||D(e.sql)!==D(t.sql)});return{sql:n(new Set(c.flatMap(e=>e.type===`trigger`&&typeof e.name==`string`?[e.name.toLowerCase()]:[]))),unexpected:l}}function prepareTranscriptIndexSchema(e){let t=O(e.statusTable),n=O(e.pendingTable),r=O(e.pendingIndex),i=`${t} (
id INTEGER PRIMARY KEY CHECK (id = 1), sibling_write_revision INTEGER NOT NULL,
schema_version INTEGER NOT NULL, complete INTEGER NOT NULL, after_session TEXT,
completed_traversals INTEGER NOT NULL
) STRICT`,a=`${n} (session_id TEXT PRIMARY KEY, state INTEGER NOT NULL) STRICT`,o=`${r} ON ${n}(state, session_id)`,s=e.observedTables.flatMap(e=>[`INSERT`,`UPDATE`,`DELETE`].map(t=>{let r=`openclaw_${e}_projection_${t.toLowerCase()}`,i=t===`UPDATE`?[`OLD`,`NEW`]:[t===`DELETE`?`OLD`:`NEW`];return{name:r,table:e,definition:`TRIGGER ${O(r)} AFTER ${t} ON main.${O(e)}
WHEN ${i.map(e=>`NOT EXISTS (
SELECT 1 FROM ${n}
WHERE session_id = ${e}.session_id AND state = 0
)`).join(` OR `)} BEGIN
${i.map(e=>`
UPDATE ${n} SET state = 0 WHERE session_id = ${e}.session_id;
INSERT INTO ${n}
SELECT ${e}.session_id, 0 WHERE NOT EXISTS (
SELECT 1 FROM ${n} WHERE session_id = ${e}.session_id
);`).join(`
`)}
END`}}));return{createSql:e=>`
CREATE TEMP TABLE IF NOT EXISTS ${i};
INSERT INTO temp.${t} VALUES (1, -1, -1, 0, NULL, 0)
ON CONFLICT(id) DO UPDATE SET sibling_write_revision = -1;
CREATE TEMP TABLE IF NOT EXISTS ${a};
CREATE INDEX IF NOT EXISTS temp.${o};
${s.map(({name:t,definition:n})=>`${e.has(t.toLowerCase())?`DROP TRIGGER IF EXISTS temp.${O(t)};`:``}CREATE TEMP ${n};`).join(`
`)}
`,objects:[{name:e.statusTable,type:`table`,table:e.statusTable,sql:`CREATE TABLE ${i}`},{name:e.pendingTable,type:`table`,table:e.pendingTable,sql:`CREATE TABLE ${a}`},{name:e.pendingIndex,type:`index`,table:e.pendingTable,sql:`CREATE INDEX ${o}`},...s.map(e=>({name:e.name,type:`trigger`,table:e.table,sql:`CREATE ${e.definition}`}))]}}const G=e(Symbol.for(`openclaw.postgresReadSnapshots`),()=>/* @__PURE__ */ new WeakMap);function beginPostgresReadSnapshotScope(e){let t=getPostgresPhysicalFacts(e),n=b(e);return t&&n!==void 0&&G.set(e,{schema:t,writeRevision:n,mutationRevision:e.mutationRevision,snapshot:{}}),()=>G.delete(e)}function isPostgresReadReceiptCurrent(e,t){let n=getPostgresPhysicalFacts(e);return e.isOpen&&n?.namespace===t.schema.namespace&&n.storeId===t.schema.storeId&&n.admissionId===t.schema.admissionId&&e.mutationRevision===t.mutationRevision&&b(e)===t.writeRevision}function publishSqliteReadOperationFacts(e,t,n){w(e)&&t.snapshot?C(e,()=>{isPostgresReadReceiptCurrent(e,t)&&n()}):n()}function invalidateSqliteSchemaFacts(e){p(e),invalidateSchemaFacts(e,!0)}function invalidateSchemaFacts(e,t,n=`main`,r=n!==`temp`){let i=s.get(e);if(i){let a=n===`main`;if(i.isolatedTempTables.clear(),e.isTransaction&&(i.transactionMutationRevision=void 0),a&&m(e),a&&e.isTransaction&&!i.transactionalSchema&&(i.transactionBaseFacts=i.facts),r)for(let e of i.mutationListeners??[])e(void 0);invalidateTrackedSqliteSchemaFacts(i),i.transactionalSchema||=a&&e.isTransaction,i.transactionalTempSchema||=n===`temp`&&e.isTransaction,i.pendingSchema||=a&&i.nativeDepth>0,t&&a&&!e.isTransaction&&i.nativeDepth===0&&x(e)}}function registerSqliteSchemaMutationListener(e,t){let n=s.get(e);if(!n)throw Error(`SQLite schema observation requires a tracked connection`);let r=n.mutationListeners??=/* @__PURE__ */ new Set;return r.add(t),()=>r.delete(t)}function trackSchemaChanges(e,t,s,c){let settle=(n=!1,r=!1)=>{if(r){let n=getSqlitePinnedReadSnapshot(e),r=n&&(t.transactionalSchema?t.transactionBaseFacts:t.facts);_(e),invalidateTrackedSqliteSchemaFacts(t),t.transactionalSchema=!1,t.transactionalTempSchema=!1,t.transactionalFacts=!1,n&&t.admitted&&!t.authorizerActive&&(t.facts=r?{...r,revision:t.revision}:captureTrackedSqliteSchemaFacts(e,t),t.snapshot=n,t.qualifiedSnapshot=n),t.transactionBaseFacts=void 0}else(n||!e.isTransaction)&&(t.transactionalSchema||t.transactionalTempSchema||t.transactionalFacts)&&(t.transactionalSchema&&x(e),invalidateTrackedSqliteSchemaFacts(t),t.transactionalSchema&&=e.isTransaction,t.transactionalTempSchema&&=e.isTransaction,t.transactionalFacts=!1)},d=S(e,s,(i,s)=>{if(t.settling)return{finish:()=>{}};let{control:l,dataChange:u}=i,d=l?.outerRollback!==!0&&i.schemaChange,f=i.mainSchemaChange&&l?.outerRollback!==!0;o(e,t);let m=s===`bind`?void 0:getSqlitePinnedReadSnapshot(e),y=s!==`bind`&&!m&&!t.capturing?{}:void 0;if(m&&m!==t.snapshot&&!t.capturing){if(e.isTransaction&&(t.transactionRead||t.transactionCatalogBound)&&t.processRevision!==p(e))t.transactionCatalogBound||invalidateTrackedSqliteSchemaFacts(t),t.transactionalFacts=!0;else if(observeSchemaLifetime(e,t,void 0),!t.facts&&!t.transactionalSchema){let n=g(e,U);n&&(t.facts={...n,revision:t.revision})}t.snapshot=m,t.qualifiedSnapshot=m}t.nativeDepth===0&&settle();let b=e.isTransaction;if((c||t.processRevision===void 0)&&!b&&(l?.kind===`BEGIN`||l?.kind===`SAVEPOINT`)){let n=p(e);t.processRevision??=n}let S=!b&&l?.kind===`BEGIN`&&l.single?t.mutationRevision:void 0;!b&&l?.kind===`BEGIN`&&t.admitted&&getAdmittedSqliteSchemaFacts(e);let C=!!l&&!n(l,b),w=l?.kind===`ROLLBACK`,T=w&&t.transactionalSchema&&!l.outerRollback,E=d&&!i.temporaryTableSchemaChange||w&&t.transactionalSchema,D=f||T?`main`:w?t.transactionalTempSchema&&!t.transactionalSchema?`temp`:`rollback`:i.temporaryTableSchemaChange?`temp`:`local`;w&&_(e),(d||w)&&invalidateSchemaFacts(e,!1,D,E),(u||i.temporaryTableSchemaChange||l?.kind===`ROLLBACK`)&&(t.mutationRevision+=1),s!==`bind`&&b&&!l&&!t.transactionCatalogBound&&(t.transactionRead=!0);let O=d||u||l!==void 0,k=i.temporaryWriteTables?.every(e=>t.isolatedTempTables.has(e));(u&&!k||f)&&v(e,f||t.nativeDepth>0),O&&(t.mutationDepth+=1),t.nativeDepth+=1;let A=r(e),j=t.schemaMutationRevision;return f&&(t.schemaMutationRevision+=1),t.pendingSchema||=f,y&&t.unmanagedSnapshots.add(y),{stepped:()=>{m&&t.facts&&e.isTransaction&&(t.transactionCatalogBound=!0)},finish:(n,r,i)=>{if(y&&t.unmanagedSnapshots.delete(y)&&t.iteratorFacts&&(invalidateTrackedSqliteSchemaFacts(t),t.iteratorFacts=!1),A(),--t.nativeDepth,O&&--t.mutationDepth,!e.isOpen)return;(d||w)&&(w&&_(e),invalidateSchemaFacts(e,!1,D,E));let o=n&&b&&l?.outerRollback===!0&&!e.isTransaction&&!f&&t.schemaMutationRevision===j;if(o&&(settle(!1,!0),t.pendingSchema=!1),t.nativeDepth===0){t.settling=!0;try{let i=t.pendingSchema||t.transactionalSchema;!o&&t.pendingSchema&&!e.isTransaction&&!t.transactionalSchema&&x(e),o||settle(C),i&&!e.isTransaction&&!o&&(invalidateTrackedSqliteSchemaFacts(t),n||_(e),t.admitted&&!t.authorizerActive&&!r&&(getAdmittedSqliteSchemaFacts(e),t.transactionBaseFacts=void 0)),t.pendingSchema=!1}finally{t.settling=!1}}a(e,t,b,C,n,S),t.mutationDepth===0&&!e.isTransaction&&h(e,i),t.transactionRead||=e.isTransaction&&!(!l||l.single)}}});u(e,()=>{h(e),i(e)}),t.installTempTrackingSchema=n=>{let{sql:r,unexpected:i}=prepareSqliteTempTrackingSchema(e,n);try{if(d(()=>s.DatabaseSync.prototype.exec.call(e,r),{schemaChange:i,mainSchemaChange:i,temporaryTableSchemaChange:!1,dataChange:!0,temporaryWriteTables:[],control:void 0}),!i)for(let e of[n.statusTable,n.pendingTable])t.isolatedTempTables.add(e.toLowerCase())}catch(t){throw invalidateSqliteSchemaFacts(e),t}},typeof e.setAuthorizer==`function`&&(e.setAuthorizer=n=>{s.DatabaseSync.prototype.setAuthorizer.call(e,n),t.authorizerActive=n!==null,l(e,t.authorizerActive),invalidateTrackedSqliteSchemaFacts(t)}),E(e,()=>{invalidateTrackedSqliteSchemaFacts(t),t.readRevision=void 0,t.transactionSnapshot=void 0})}function readSqliteNativeMutationRevision(e){return w(e)?e.mutationRevision:s.get(e)?.mutationRevision}function hasUncommittedSqliteWrites(e){if(w(e))return e.isTransaction&&!G.has(e);let t=s.get(e);return t&&o(e,t),!t||t.authorizerActive||t.mutationDepth>0||t.unmanagedSnapshots.size>0||getSqlitePinnedReadSnapshot(e)!==void 0||e.isTransaction&&(t.transactionMutationRevision===void 0||t.transactionMutationRevision!==t.mutationRevision)}function canReuseSqliteSchemaInTransaction(e){if(w(e))return!1;let t=s.get(e);return t!==void 0&&!t.authorizerActive&&e.isTransaction}function getSqliteReadOperationRevision(e){if(w(e)){let t=G.get(e);return t&&e.isTransaction&&isPostgresReadReceiptCurrent(e,t)?t:void 0}if(e.isTransaction||getSqlitePinnedReadSnapshot(e))return;let t=getSqliteReadScopeRevision(e);return t?.snapshot===void 0?t:void 0}function getSqliteReadScopeRevision(e){if(w(e)){let t=G.get(e);return e.isOpen&&e.isTransaction&&t?.mutationRevision===e.mutationRevision?t:void 0}let t=s.get(e);if(t&&o(e,t),!t?.admitted||!t.facts||t.authorizerActive||t.readDepth===0||t.mutationDepth!==0||t.unmanagedSnapshots.size>0)return;let n=getSqlitePinnedReadSnapshot(e)??(e.isTransaction?t.transactionSnapshot??={}:void 0),r=t.readRevision;if(n)return r?.schema===t.facts&&r.snapshot===n&&r.mutationRevision===t.mutationRevision?r:t.readRevision={schema:t.facts,mutationRevision:t.mutationRevision,snapshot:n,writeRevision:void 0};let i=b(e);if(i!==void 0)return r?.schema===t.facts&&r.snapshot===void 0&&r.writeRevision===i&&r.mutationRevision===t.mutationRevision?r:t.readRevision={schema:t.facts,snapshot:void 0,writeRevision:i,mutationRevision:t.mutationRevision}}function runSqliteReadOperationSync(e,t){if(w(e))return t();let n=s.get(e);if(!n||n.authorizerActive)return t();n.readDepth+=1;try{return n.admitted&&getAdmittedSqliteSchemaFacts(e),t()}finally{--n.readDepth}}function trackSqliteSchema(e,t,n=!0){if(!s.has(e)){let r={admitted:!1,publicationReady:!1,revision:0,readDepth:0,mutationRevision:0,mutationDepth:0,transactionOpen:e.isOpen&&e.isTransaction,transactionRead:!1,transactionCatalogBound:!1,nativeDepth:0,pendingSchema:!1,schemaMutationRevision:0,settling:!1,capturing:!1,transactionalSchema:!1,transactionalTempSchema:!1,transactionalFacts:!1,authorizerActive:!1,unmanagedSnapshots:/* @__PURE__ */ new Set,isolatedTempTables:/* @__PURE__ */ new Set,iteratorFacts:!1};s.set(e,r),trackSchemaChanges(e,r,t,n);let i=p(e,{existingOnly:!0}),a=g(e,U,{existingOnly:!0});a&&(r.admitted=!0,r.facts={...a,revision:r.revision},r.processRevision=i)}}function isSqliteSchemaAdmissionCold(e){let t=s.get(e);return!(!t||t.admitted||t.authorizerActive)}function admitSqliteSchema(e,t){let n=s.get(e);if(!n)throw Error(`SQLite schema admission requires a connection tracked from native open`);n.admitted=!0;let r=getAdmittedSqliteSchemaFacts(e,t);!n.publicationReady&&r&&n.unmanagedSnapshots.size===0&&!getSqlitePinnedReadSnapshot(e)&&(n.publicationReady=c(e))}function adoptSqliteSchemaFacts(e,t){let n=s.get(e);if(!n||n.authorizerActive||e.isTransaction||n.unmanagedSnapshots.size>0)return!1;n.admitted=!0;let r=getAdmittedSqliteSchemaFacts(e);return r!==void 0&&r.schemaVersion===t.schemaVersion&&r.userVersion===t.userVersion}function getAdmittedSqlSchemaFacts(e){return w(e)?getPostgresPhysicalFacts(e):getAdmittedSqliteSchemaFacts(e)}function getAdmittedSqliteSchemaFacts(e,t){if(w(e))return;let n=s.get(e);if(!n?.admitted||n.authorizerActive)return;let r=getSqlitePinnedReadSnapshot(e),i=e.isTransaction&&(n.transactionRead||n.transactionCatalogBound)&&n.processRevision!==p(e)||n.unmanagedSnapshots.size>0,a=observeSchemaLifetime(e,n,r);if(n.facts)t?.(n.facts.userVersion);else{n.snapshot=r,n.transactionalFacts||=e.isTransaction&&(n.readDepth===0||a);let o=i||!!r||n.transactionalSchema,s=n.transactionalSchema||o?void 0:g(e,U);if(s)return t?.(s.userVersion),n.facts={...s,revision:n.revision},n.facts;let c=p(e);n.facts=captureTrackedSqliteSchemaFacts(e,n,t),n.iteratorFacts||=n.unmanagedSnapshots.size>0,n.qualifiedSnapshot=r,n.transactionCatalogBound||=e.isTransaction,o||y(e,U,n.facts,{schemaRevision:c})}return n.facts}export{postgresStoreNamespace as A,admitPostgresPhysicalFacts as C,getAdmittedPostgresSchema as D,admitPostgresCapabilities as E,admitPostgresSearch as F,postgresSearchTextTriggerSql as I,postgresSearchVectorSql as L,verifyAndRecordPostgresSchema as M,verifyPostgresSchema as N,I as O,withPostgresSearchExtensions as P,postgresVectorDecoderSql as R,runSqliteSchemaReadSnapshotSync as S,requireNativeDatabaseFile as T,captureSqliteSchemaFacts as _,getAdmittedSqlSchemaFacts as a,U as b,getSqliteReadScopeRevision as c,isSqliteSchemaAdmissionCold as d,publishSqliteReadOperationFacts as f,trackSqliteSchema as g,runSqliteReadOperationSync as h,canReuseSqliteSchemaInTransaction as i,readPostgresSchema as j,postgresSchemaSql as k,hasUncommittedSqliteWrites as l,registerSqliteSchemaMutationListener as m,adoptSqliteSchemaFacts as n,getAdmittedSqliteSchemaFacts as o,readSqliteNativeMutationRevision as p,beginPostgresReadSnapshotScope as r,getSqliteReadOperationRevision as s,admitSqliteSchema as t,invalidateSqliteSchemaFacts as u,readSqliteSchemaObjects as v,getPostgresPhysicalFacts as w,getSqlitePinnedReadSnapshot as x,readSqliteTextEncoding as y,assertPostgresCatalog as z};