UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 3.19 kB
import{l as e,t,u as n}from"./sqlite-readonly-sqlite-readonly-location-CrsaHxKY.mjs";import{c as r,o as i}from"./sqlite-readonly-node-sqlite-C-jA8uc4.mjs";import{m as a}from"./sqlite-readonly-location.worker.js";import{o}from"./sqlite-readonly-openclaw-state-db-schema-version-Coirf-v2.mjs";import{M as s,n as c}from"./sqlite-readonly-openclaw-state-db-maintenance-CuC5fpCz.mjs";import{n as l}from"./sqlite-readonly-sqlite-readonly-inspection-CF7sn5Rb.mjs";import{n as u}from"./sqlite-readonly-physical-store-inspection-BaNgFJEq.mjs";function observeLease(e,t){e.lease=!t||t.state===`dead`?`none`:t.state===`live`?`live-owner`:`unverifiable`,e.lease===`unverifiable`&&e.nextSteps.push(`Inspect the recorded Gateway lease before offline maintenance.`)}function observeVersion(e,t){e.schema.versioning=`versioned`,e.schema.version=t;let n=e.schema.expectedVersion;n!==null&&(e.schema.pending=Math.max(0,n-t),t<n?(e.issues.push(`Schema migrations pending: version ${t}, expected ${n}.`),e.nextSteps.push(`Run openclaw doctor --fix with the matching OpenClaw version.`)):t>n&&(e.issues.push(`Schema version ${t} is newer than supported version ${n}.`),e.nextSteps.push(`Use an OpenClaw version that supports this schema, or restore its matching backup.`)))}function inspectSqlite(e,t,n){i(t);let a=r(t);e.connectivity=`local`,e.extensions=[];let l=a.userVersion;try{if(e.family===`state`)l=o(t),c(t,{pathname:`shared-state diagnostic snapshot`}),observeVersion(e,l);else if(n?.inspectSqliteSource){let r=n.inspectSqliteSource(t);observeVersion(e,r.version),r.migrationRequired&&r.version===e.schema.expectedVersion&&(e.issues.push(`Store preparation is required before porting.`),e.nextSteps.push(`Database porting performs this preparation on a private copy.`))}else e.schema.versioning===`versioned`&&observeVersion(e,l)}catch{(e.family===`state`||e.family===`agent`)&&observeVersion(e,l),e.issues.push(`The SQLite schema could not be admitted by its store owner.`),e.nextSteps.push(`Run openclaw doctor --fix with the matching OpenClaw version.`)}if(e.family===`state`)try{observeLease(e,s(t))}catch{e.issues.push(`The recorded Gateway lease could not be verified.`),e.nextSteps.push(`Check the Gateway owner and rerun openclaw doctor.`)}}function inspectSqliteStoreImage(e,t,n,r){let i=u(t,n);return e.observed=i.engine,e.mismatch=i.engine!==e.configured.effective,e.mismatch&&(e.issues.push(`Configured ${e.configured.effective}, but the physical store is ${i.engine}.`),e.nextSteps.push(e.configured.fixedLocal?`Restore the fixed-local SQLite store from its verified backup.`:`Stop the Gateway and run openclaw database port --family ${e.family} --to ${e.configured.effective}, or restore the matching engine configuration.`)),i.engine===`sqlite`&&inspectSqlite(e,t,r),i}function isLiveWalSource(r){try{let t=n(r);return e(r)===`wal`&&t.wal&&t.shm}catch(e){if(e instanceof t)return!1;throw e}}const d={"databaseStore.inspectLive":(e,t)=>{if(t.assertCurrent(),!isLiveWalSource(t.path)||!a(t.path))return;let n=l(t.path,n=>{let{diagnostic:r}=e;return{diagnostic:r,engine:inspectSqliteStoreImage(r,n,t.path)}});return t.assertCurrent(),n?.value}};export{d as databaseStoreLiveReadOperations};