UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

85 lines (84 loc) • 3.65 kB
import { i as listAgentIds, t as hasAgentRosterProperty } from "./agent-roster-t1ooUdXp.mjs"; import { v as resolveEffectiveAgentDir } from "./agent-scope-config-DmXgFGKP.mjs"; import { n as captureSqliteDatabaseAdmissions } from "./sqlite-database-admission-context-DdNyQqMy.mjs"; import { a as getOrLoadSqliteDatabaseAdmissionForPath } from "./sqlite-database-admission-DQIqro3d.mjs"; import { T as getPostgresPhysicalFactsForPath, b as schemaAdmission } from "./sqlite-schema-facts-B1bVE8IB.mjs"; import { t as databasePortProviders } from "./port-provider-CZISFP-d.mjs"; import { n as createDatabaseStoreDiagnostic, t as listLocalDatabaseDiagnosticStores } from "./local-diagnostics-Bhc6pVK7.mjs"; import { t as describeDatabaseEngineSelection } from "./report-zZFRy8iT.mjs"; import path from "node:path"; //#region 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; } /** Configured paths and admission facts only; never opens stores or probes PostgreSQL. */ 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; } //#endregion export { describeAdmittedDatabaseStores };