UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

4 lines • 2.39 kB
import{a as asOptionalRecord}from"./record-coerce-BTbqdJ3-.mjs";import{a as getOpenClawDatabaseMaintenanceScope}from"./openclaw-state-maintenance-context-D-pYfco8.mjs";import{s as resolveOpenClawStateSqlitePath}from"./openclaw-state-db.paths-CbgXfEg1.mjs";import"./openclaw-state-db-async-lifecycle-DlV0ztcV.mjs";import{a as withArtifactPreservingStateReads}from"./artifact-preserving-state-reads-CWuQPqxe.mjs";import{l as resolveCronStoreSelectionAsync}from"./paths-BFxu7LPC.mjs";import{t as note}from"./note-e4DtVgg2.mjs";import{i as repairCronDefaultStoreSelectionForDoctor}from"./store-repair-CIGQuno0.mjs"; //!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))}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`);if(o.warnings.length>0)note(o.warnings.join(` `),`Doctor warnings`);return true}export{readCronStoreSelectionForDoctor as n,maybeRepairCronStoreSelection as t};