UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.65 kB
import{t as runWithLocalStateOwner}from"./local-state-owner-fjzTarAw.mjs";import"./cli-state-owner-DaSXYnIM.mjs";import{t as drainSessionBackfill}from"./session-backfill-drain-DxlCumTy.mjs"; //!extensions/memory-core/src/cli-session-backfill.ts async function runMemorySessionBackfillCli(e,t){if(e.rollback&&(e.apply||e.rem||e.from||e.to||e.archiveFiles?.length))throw new Error(`Memory session-backfill --rollback cannot be combined with input, range, --rem, or --apply options.`);const n=e.rollback?`rollback`:e.apply?`apply`:`preview`;let r;const executeBatch=async()=>{const i=await runWithLocalStateOwner({method:`memory.sessionBackfill.${n}.owner`,params:{agentId:e.agent,...e.rollback?{}:{from:e.from,to:e.to,limitDays:e.limitDays},cliResult:true,...r?{operationOwnerId:r}:{}},target:`memory session backfill`,databaseEngine:`configured`,recoveryCommand:`openclaw memory session-backfill --json`,...e.rem||e.archiveFiles?.length?{onForeignOwner:`refuse`}:{},runLocal:async()=>{if(r)throw new Error(`The selected Gateway is no longer running; inspect the operation before retrying.`);await(await import(`./cli.runtime-Of87jA9X.mjs`)).runMemorySessionBackfill(e,t);return null}});if(i)r??=i.ownerId;return i};const i=await executeBatch();if(!i)return;let a=i.execution;const o=e.apply&&!e.rollback?await drainSessionBackfill({executeBatch:async()=>{if(a){const e=a;a=void 0;return e}const e=await executeBatch();if(!e)throw new Error(`Memory backfill lost its Gateway owner.`);return e.execution}}):i.execution.result;const{printSessionBackfillResult:s}=await import(`./cli-rem.runtime-DWZLltdL.mjs`);s(o,e)}export{runMemorySessionBackfillCli};