openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 3.06 kB
JavaScript
import{i as listAgentIds,t as hasAgentRosterProperty}from"./agent-roster-4XrgUgPK.mjs";import{v as resolveEffectiveAgentDir}from"./agent-scope-config-CG9CFpGX.mjs";import{s as captureSqliteDatabaseAdmissions}from"./sqlite-database-admission-wait-FbF9W-eV.mjs";import{o as getOrLoadSqliteDatabaseAdmissionForPath}from"./sqlite-database-admission-B3KDkUt-.mjs";import{T as getPostgresPhysicalFactsForPath,b as schemaAdmission}from"./sqlite-schema-facts-CWOeTpUB.mjs";import{n as createDatabaseStoreDiagnostic,t as listLocalDatabaseDiagnosticStores}from"./local-diagnostics-o6eq7hSq.mjs";import{t as databasePortProviders}from"./port-provider-CdqIxw1H.mjs";import{t as describeDatabaseEngineSelection}from"./report-IvbNxPY6.mjs";import path from"node:path";
//!src/infra/database-engine/admitted-diagnostics.ts
function unknownStore(e,t){const n=createDatabaseStoreDiagnostic({family:e,path:null,configured:t});n.issues.push(`Status reports admitted facts; unobserved facts remain unknown.`);n.nextSteps.push(`Run openclaw doctor on the Gateway host for physical connectivity, schema migrations, and ownership diagnostics.`);return n}function describeAdmittedDatabaseStores(e){const t=describeDatabaseEngineSelection(e);const n=/* @__PURE__ */ new Map;for(const e of captureSqliteDatabaseAdmissions()){const r=getPostgresPhysicalFactsForPath(e.location);const i=r?void 0:getOrLoadSqliteDatabaseAdmissionForPath(e.location,schemaAdmission,()=>void 0);const a=r?databasePortProviders.filter(e=>e.id===r.store):i?databasePortProviders.filter(e=>e.matchesSqlite(i.tables)):[];const o=a.length===1?a[0]:void 0;const s=o?t.find(e=>e.id===o.id):void 0;if(!s||!r&&!i)continue;const c=unknownStore(s.id,{default:s.default,override:s.override,effective:s.effective,fixedLocal:s.fixedLocal});c.path=e.location;c.observed=r?`postgres`:`sqlite`;c.mismatch=c.observed!==c.configured.effective;if(r||s.id===`state`||s.id===`agent`){c.schema.versioning=`versioned`;c.schema.version=r?.version??i?.userVersion??null}if(r){c.namespace=r.namespace;c.storeId=r.storeId}else c.connectivity=`local`;if(c.mismatch){c.issues.push(`Configured ${c.configured.effective}, observed ${c.observed}.`);c.nextSteps.unshift(`Stop the Gateway and run openclaw database port --family ${c.family}, or restore the matching engine configuration.`)}const l=n.get(s.id)??[];l.push(c);n.set(s.id,l)}const r=t.flatMap(t=>{const r={default:t.default,override:t.override,effective:t.effective,fixedLocal:t.fixedLocal};const i=n.get(t.id)??[];if(t.id===`agent`&&hasAgentRosterProperty(e))for(const n of listAgentIds(e)){const a=path.join(resolveEffectiveAgentDir(e,n),`openclaw-agent.sqlite`);if(!i.some(e=>e.path===a)){const e=unknownStore(t.id,r);e.path=a;i.push(e)}}return i.length?i.toSorted((e,t)=>(e.path??``).localeCompare(t.path??``)):[unknownStore(t.id,r)]});for(const n of listLocalDatabaseDiagnosticStores())if(!t.some(e=>e.id===n.id))r.push(unknownStore(n.id,{default:e.database?.engine??`sqlite`,override:null,effective:`sqlite`,fixedLocal:true}));return r}export{describeAdmittedDatabaseStores};