UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

35 lines (34 loc) • 1.8 kB
import { r as captureOpenClawStateWorkerContext } from "./openclaw-state-worker-context-DAKL_dnZ.mjs"; import { t as note } from "./note-CnLgHvug.mjs"; import { t as BLOAT_MIN_FILE_BYTES } from "./doctor-db-bloat.constants-Cx5qGUKb.mjs"; import { n as formatBytes } from "./doctor-disk-space-Xliu0I8N.mjs"; //#region src/commands/doctor-db-bloat.ts const BLOAT_MIN_FREE_BYTES = 33554432; const BLOAT_FREE_RATIO = .25; const LARGE_DB_WARN_BYTES = 1073741824; function describeBloat(e, t) { const n = t.fileBytes > 0 ? t.freeBytes / t.fileBytes : 0; if (t.fileBytes >= 134217728 && t.freeBytes >= BLOAT_MIN_FREE_BYTES && n >= BLOAT_FREE_RATIO) { const n = t.incrementalAutoVacuum ? "incremental vacuum will release it gradually" : "use offline Doctor SQLite compaction to reclaim it and enable incremental vacuum (gateway stopped; see https://docs.openclaw.ai/cli/doctor/sqlite-maintenance)"; return `${e}: ${formatBytes(t.fileBytes)} on disk with ${formatBytes(t.freeBytes)} reclaimable free pages; ${n}.`; } if (t.fileBytes >= LARGE_DB_WARN_BYTES) return `${e}: ${formatBytes(t.fileBytes)} on disk; review session/transcript retention settings if growth is unexpected.`; return null; } async function noteSqliteDatabaseBloat(e) { const t = captureOpenClawStateWorkerContext({ env: e?.env }); const { runOpenClawStateWorkerOperation: n } = await import("./openclaw-state-worker-store-BURqchns.mjs"); const r = await n(t, (e) => e.execute({ type: "doctor.databaseBloat", input: void 0 }), { existingOnly: true }); t.admission.assertCurrent(); const i = (r ?? []).flatMap(({ label: e, stats: t }) => { const n = describeBloat(e, t); return n ? [n] : []; }); if (i.length === 0) return; note(i.join("\n"), "SQLite database size"); } //#endregion export { noteSqliteDatabaseBloat };