openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
53 lines (52 loc) • 2.66 kB
JavaScript
import { a as asOptionalRecord } from "./record-coerce-CVPuDqcc.mjs";
import { a as getOpenClawDatabaseMaintenanceScope } from "./openclaw-state-maintenance-context-D6i7Zdhn.mjs";
import { r as withArtifactPreservingStateReads } from "./artifact-preserving-state-reads-BfhmBr-V.mjs";
import { s as resolveOpenClawStateSqlitePath } from "./openclaw-state-db.paths-R3ArRCcz.mjs";
import "./openclaw-state-db-async-lifecycle-CH8q4Sdl.mjs";
import { l as resolveCronStoreSelectionAsync } from "./paths-CY4cvrR6.mjs";
import { t as note } from "./note-CnLgHvug.mjs";
import { i as repairCronDefaultStoreSelectionForDoctor } from "./store-repair-Dv1WdfLr.mjs";
//#region src/commands/doctor/cron/default-store-selection.ts
function readCronStoreSelectionForDoctor(e, t = process.env) {
const n = asOptionalRecord(e.cron)?.store;
return withArtifactPreservingStateReads(() => resolveCronStoreSelectionAsync(typeof n === "string" ? n : void 0, t));
}
/** Selection is the only deferred cron operation; unrelated Doctor work remains available. */
async function maybeRepairCronStoreSelection(e) {
const t = e.env ?? process.env;
const n = await readCronStoreSelectionForDoctor(e.cfg, t);
if (n.status === "ready") return true;
note(n.message, "Cron partition selection");
if (!(e.options.repair || e.options.yes) || !e.prompter.selectRuntimeRepair) return false;
const r = n.partitions.length ? n.partitions.map((e) => ({
value: e.storeKey,
label: e.storeKey,
hint: `${e.jobs} jobs, ${e.scratch} scratch rows, ${e.receipts} receipts, ${e.history} runs, ${e.quarantine} quarantined, ${e.proactiveReceipts} provisioning receipts`
})) : [{
value: n.storePath,
label: n.storePath,
hint: "Empty cron store"
}];
const i = await e.prompter.selectRuntimeRepair({
message: "Select the default cron partition",
options: [...r, {
value: void 0,
label: "Leave cron paused and decide later"
}]
}, void 0);
if (i === void 0) return false;
const a = getOpenClawDatabaseMaintenanceScope();
if (!a?.ownsSchemaMaintenance) {
note("Selection requires offline Doctor maintenance. Run openclaw doctor --fix again.", "Cron");
return false;
}
const assertCurrent = () => a.assertDatabaseAccess(resolveOpenClawStateSqlitePath(t));
const o = await repairCronDefaultStoreSelectionForDoctor({ env: t }, {
assertCurrent,
assertOwnedInTransaction: assertCurrent
}, n, i);
note(`Selected default cron partition ${JSON.stringify(i)}. Saved pre-repair backup: ${o.backupPath}. Restart the Gateway to resume cron.`, "Doctor changes");
return true;
}
//#endregion
export { readCronStoreSelectionForDoctor as n, maybeRepairCronStoreSelection as t };