openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
48 lines (47 loc) • 2.91 kB
JavaScript
import { r as resolveStateDir } from "./state-dir-DiG0gXzD.mjs";
import { a as getOpenClawDatabaseMaintenanceScope } from "./openclaw-state-maintenance-context-D6i7Zdhn.mjs";
import "./openclaw-state-db-async-lifecycle-CH8q4Sdl.mjs";
import { t as quoteCliArg } from "./quote-cli-arg-J7A9UE6m.mjs";
import { t as note } from "./note-CnLgHvug.mjs";
import { n as formatBytes } from "./doctor-disk-space-Xliu0I8N.mjs";
import { t as inspectOtherOpenClawProcesses } from "./openclaw-process-census-Bo4-nXZ2.mjs";
import { n as pruneLegacyPluginSourceCaptures, r as pruneUnreferencedPluginNativeCaptures, t as inspectLegacyPluginSourceCaptureRoots } from "./plugin-source-capture-report-CFAkjIcm.mjs";
import { t as inspectDoctorTemporaryDirectories } from "./temporary-directories-DM4O9F0P.mjs";
//#region src/commands/doctor-plugin-source-captures.ts
async function noteLegacyPluginSourceCaptures(e, t = false) {
const { directories: n, warnings: r } = await inspectDoctorTemporaryDirectories(e);
const i = await inspectLegacyPluginSourceCaptureRoots(resolveStateDir(e), n);
r.push(...i.warnings);
const a = [];
const o = getOpenClawDatabaseMaintenanceScope();
const assertCurrent = () => {
if (!o?.ownsSchemaMaintenance) throw new Error("Doctor does not hold Gateway maintenance; captures were preserved.");
o.assertAdmission();
};
const assertLegacyUnowned = () => {
assertCurrent();
const e = inspectOtherOpenClawProcesses();
if ("error" in e) throw new Error(e.error);
if (e.pids.length > 0) throw new Error(`Other OpenClaw processes are still running (PIDs: ${e.pids.join(", ")}).`);
assertCurrent();
};
if (i.roots.length > 0) {
a.push(`${i.roots.length} legacy plugin capture root(s), ${formatBytes(i.totalBytes)} in known regular files.`, ...i.roots.map((e) => `- ${quoteCliArg(e.path)} (${formatBytes(e.bytes)})`), "They will be reclaimed at the next maintenance.");
if (t) {
const e = await pruneLegacyPluginSourceCaptures(i, assertLegacyUnowned);
if (e.removed.length > 0) a.push(`Removed ${e.removed.length} legacy plugin capture root(s), ${formatBytes(e.removed.reduce((e, t) => e + t.bytes, 0))}.`, ...e.removed.map((e) => `Removed ${quoteCliArg(e.path)} (${formatBytes(e.bytes)}).`));
if (e.blockedReason) a.push(`Legacy capture cleanup skipped: ${e.blockedReason}`);
a.push(...e.skipped.map((e) => `Kept ${quoteCliArg(e.path)}: ${e.reason}.`));
r.push(...e.warnings);
}
}
if (t) {
const t = await pruneUnreferencedPluginNativeCaptures(resolveStateDir(e), assertCurrent, e);
if (t.removed.length > 0) a.push(`Removed ${t.removed.length} unreferenced native plugin capture root(s).`);
r.push(...t.warnings);
}
if (r.length > 0) a.push("Legacy capture inspection or cleanup was incomplete; sizes may be partial.", ...r);
if (a.length > 0) note(a.join("\n"), "Legacy plugin captures");
}
//#endregion
export { noteLegacyPluginSourceCaptures };