UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

108 lines (107 loc) • 5.01 kB
import { r as resolveStateDir } from "./state-dir-DiG0gXzD.mjs"; import "./paths-DAcAg5aV.mjs"; import { i as ensureSqliteLibrarySelected } from "./bun-sqlite-library-BvzuPYCx.mjs"; import { t as findSqlitePathsOnNetworkFilesystems } from "./sqlite-wal-filesystem-LJsoYuDu.mjs"; import { t as describeDatabaseEngineSelection } from "./report-zZFRy8iT.mjs"; import { t as note } from "./note-CnLgHvug.mjs"; import { t as formatDatabaseStoreDiagnostic } from "./diagnostics-format-DcgPeps-.mjs"; //#region src/commands/doctor-database-engine.ts function collectDatabaseEngineHealthFindings(e, t = {}) { const n = describeDatabaseEngineSelection(e); const r = []; for (const e of n) if (t[e.id]?.some((t) => t !== e.effective)) r.push({ checkId: "core/doctor/database-engine", severity: "warning", source: "doctor", path: e.fixedLocal ? "database" : `database.families.${e.id}.engine`, message: `${e.label}: configured ${e.effective}, observed ${t[e.id].join(" and ")}. Changing configuration does not migrate existing data.`, fixHint: e.fixedLocal ? "Restore the local SQLite safety store from its verified backup." : `Keep the Gateway stopped and use openclaw database port --family ${e.id} to migrate this family, or restore its matching engine selection.` }); return r; } function stateRootFindings(e, t) { const n = describeDatabaseEngineSelection(e).find((e) => e.id === "state").effective; const r = t.stateRoots.filter(({ physical: e }) => e.engine !== n).map(({ path: e, physical: t }) => ({ checkId: "core/doctor/database-engine", severity: "warning", source: "doctor", path: e, message: `Shared state root ${e}: physical=${t.engine}, configured=${n} (engine mismatch).`, fixHint: `Restore the matching state-family engine setting, or stop the Gateway and use openclaw database port --family state --to ${n}.` })); if (t.discoveryFailed) r.push({ checkId: "core/doctor/database-engine", severity: "warning", source: "doctor", path: "database.families.state.engine", message: "Database roots could not all be inspected.", fixHint: "Verify the selected database connection and installed plugin inventory, then rerun openclaw doctor." }); return r; } async function inspect(e, t) { const { inspectDoctorDatabaseEngines: n } = await import("./doctor-database-engine-inspection-Fa4N9pOa.mjs"); const r = t.env ?? process.env; return n({ config: e, stateDir: resolveStateDir(r), env: r }); } function collectInspectionFindings(e, t) { const n = { ...t.observed, state: void 0 }; const r = (t.stores ?? []).flatMap((e) => e.path && (e.observed === "sqlite" || e.observed === "unknown" && e.configured.effective === "sqlite") ? [e.path] : []); return [ ...collectDatabaseEngineHealthFindings(e, n), ...stateRootFindings(e, t), ...findSqlitePathsOnNetworkFilesystems(r).map((e) => ({ checkId: "core/doctor/database-engine", severity: "warning", source: "doctor", path: e, message: `SQLite path ${e} is on a network filesystem, where WAL can cause corruption. OpenClaw uses rollback journaling on supported network filesystems.`, fixHint: "Stop the Gateway, back up the state, and move the state directory and any custom database paths to a local disk before restarting." })), ...(t.stores ?? []).map((e) => ({ checkId: "core/doctor/database-engine", severity: e.issues.length || e.legacyMigrations.state !== "none" ? "warning" : "info", source: "doctor", target: e.path ?? e.family, path: e.path ?? `database.families.${e.family}`, message: formatDatabaseStoreDiagnostic(e), fixHint: e.nextSteps.join(" ") || void 0, details: { ...e } })) ]; } async function collectDoctorDatabaseEngineHealthFindings(e, t = {}) { return collectInspectionFindings(e, await inspect(e, t)); } async function noteDatabaseEngines(e, t = {}) { const n = await inspect(e, t); const r = collectInspectionFindings(e, n); const i = describeDatabaseEngineSelection(e).map((e) => { const t = e.fixedLocal ? "fixed local" : e.override ?? "inherit"; const r = n.observed[e.id]?.length ? `; observed=${n.observed[e.id].join(",")}` : ""; return `${e.label}: default=${e.default}, override=${t}, effective=${e.effective} (configured)${r}`; }); for (const { path: e, physical: t } of n.stateRoots) { const n = t.engine === "postgres" ? `, namespace=${t.namespace}` : ""; i.push(`Shared state root: ${e} (physical=${t.engine}${n})`); } for (const e of n.stores ?? []) i.push(formatDatabaseStoreDiagnostic(e)); const a = ensureSqliteLibrarySelected(); if (a.source !== "runtime") i.push(`SQLite (doctor process): ${a.path} (${a.version}, extension loading enabled)`); else if (a.ignoredOverride) i.push(`SQLite (doctor process): ${a.ignoredOverride}; override ignored`); for (const e of r) { if (e.details) continue; i.push("", e.message, e.fixHint ?? ""); } note(i.join("\n"), "Database engines"); return r; } //#endregion export { collectDoctorDatabaseEngineHealthFindings, noteDatabaseEngines };