UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

53 lines (52 loc) • 1.94 kB
import { t as runWithLocalStateOwner } from "./local-state-owner-DTl7OHpC.mjs"; import "./cli-state-owner-DWH5gh7o.mjs"; import { t as drainSessionBackfill } from "./session-backfill-drain-BXN8KjQW.mjs"; //#region 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.js")).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.js"); s(o, e); } //#endregion export { runMemorySessionBackfillCli };