1- import { listAgentIds } from "openclaw/plugin-sdk/agent-runtime" ;
21import { readPositiveIntegerParam , readStringParam } from "openclaw/plugin-sdk/channel-actions" ;
32import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts" ;
43import {
54 ErrorCodes ,
65 errorShape ,
76 type GatewayRequestHandlerOptions ,
87} from "openclaw/plugin-sdk/gateway-runtime" ;
8+ import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime" ;
9+ import { listAgentIds } from "openclaw/plugin-sdk/memory-core-host-runtime-core" ;
910import { resolveMemoryRemDreamingConfig } from "openclaw/plugin-sdk/memory-core-host-status" ;
1011import { resolvePluginConfigObject } from "openclaw/plugin-sdk/plugin-config-runtime" ;
1112import type { OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry" ;
1213import { normalizeAgentId } from "openclaw/plugin-sdk/routing" ;
13- import {
14- executeSessionBackfill ,
15- executeSessionBackfillBatch ,
16- normalizeSessionBackfillSelection ,
17- type RunSessionBackfillParams ,
18- type SessionBackfillResult ,
19- } from "./session-backfill.js" ;
14+ import type { SessionBackfillResult } from "./session-backfill-contract.js" ;
15+ import { normalizeSessionBackfillSelection } from "./session-backfill-selection.js" ;
2016
2117const SESSION_BACKFILL_GATEWAY_METHODS = {
2218 preview : "memory.sessionBackfill.preview" ,
2319 apply : "memory.sessionBackfill.apply" ,
2420 rollback : "memory.sessionBackfill.rollback" ,
2521} as const ;
2622
27- type SessionBackfillGatewayParams = Pick <
28- RunSessionBackfillParams ,
29- "agentId" | "from" | "to" | "limitDays"
30- > ;
23+ type SessionBackfillGatewayParams = {
24+ agentId : string ;
25+ from ?: string ;
26+ to ?: string ;
27+ limitDays : number ;
28+ } ;
3129
3230type SessionBackfillGatewayResult = {
3331 days : number ;
@@ -44,6 +42,10 @@ type SessionBackfillGatewayResult = {
4442
4543class InvalidSessionBackfillRequestError extends Error { }
4644
45+ const loadSessionBackfillGatewayRuntime = createLazyRuntimeModule (
46+ ( ) => import ( "./session-backfill-gateway.runtime.js" ) ,
47+ ) ;
48+
4749function paramsRecord ( value : unknown ) : Record < string , unknown > {
4850 if ( ! value || typeof value !== "object" || Array . isArray ( value ) ) {
4951 throw new Error ( "params must be an object." ) ;
@@ -165,6 +167,7 @@ export function registerSessionBackfillGatewayMethods(api: OpenClawPluginApi): v
165167 }
166168 try {
167169 const context = resolveExecutionContext ( api , request . agentId ) ;
170+ const { executeSessionBackfillBatch } = await loadSessionBackfillGatewayRuntime ( ) ;
168171 const execution = await executeSessionBackfillBatch ( {
169172 ...request ,
170173 ...context ,
@@ -203,6 +206,7 @@ export function registerSessionBackfillGatewayMethods(api: OpenClawPluginApi): v
203206 }
204207 try {
205208 const context = resolveExecutionContext ( api , request . agentId ) ;
209+ const { executeSessionBackfill } = await loadSessionBackfillGatewayRuntime ( ) ;
206210 const result = await executeSessionBackfill ( { ...request , ...context , rollback : true } ) ;
207211 respond ( true , {
208212 removedDiaryEntries : result . rollback ?. removedDiaryEntries ?? 0 ,
0 commit comments