@@ -114,15 +114,46 @@ const IGNORED_MEMORY_WATCH_DIR_NAMES = new Set([
114114] ) ;
115115
116116const log = createSubsystemLogger ( "memory" ) ;
117+ const MEMORY_CORE_TRANSCRIPT_UPDATE_SUBSCRIBER_KEY = Symbol . for (
118+ "openclaw.memoryCore.sessionTranscriptUpdateSubscriber" ,
119+ ) ;
117120const TEST_MEMORY_WATCH_FACTORY_KEY = Symbol . for ( "openclaw.test.memoryWatchFactory" ) ;
118121const TEST_MEMORY_NATIVE_WATCH_FACTORY_KEY = Symbol . for ( "openclaw.test.memoryNativeWatchFactory" ) ;
119122
123+ type MemorySessionTranscriptUpdate = {
124+ agentId ?: string ;
125+ sessionFile ?: string ;
126+ sessionKey ?: string ;
127+ target ?: {
128+ agentId : string ;
129+ sessionId : string ;
130+ sessionKey : string ;
131+ targetKind : "active-session-file" | "runtime-session" ;
132+ } ;
133+ } ;
134+
135+ type MemoryTranscriptUpdateSubscriber = (
136+ listener : ( update : MemorySessionTranscriptUpdate ) => void ,
137+ ) => ( ) => void ;
138+
120139type NativeMemoryWatchPair = {
121140 dir : string ;
122141 main : fsSync . FSWatcher ;
123142 parent : fsSync . FSWatcher | null ;
124143} ;
125144
145+ function subscribeMemorySessionTranscriptUpdates (
146+ listener : ( update : MemorySessionTranscriptUpdate ) => void ,
147+ ) : ( ) => void {
148+ const injected = ( globalThis as Record < symbol , unknown > ) [
149+ MEMORY_CORE_TRANSCRIPT_UPDATE_SUBSCRIBER_KEY
150+ ] ;
151+ if ( typeof injected === "function" ) {
152+ return ( injected as MemoryTranscriptUpdateSubscriber ) ( listener ) ;
153+ }
154+ return onSessionTranscriptUpdate ( listener ) ;
155+ }
156+
126157function resolveMemoryWatchFactory ( ) : typeof chokidar . watch {
127158 if ( process . env . VITEST === "true" || process . env . NODE_ENV === "test" ) {
128159 const override = ( globalThis as Record < PropertyKey , unknown > ) [ TEST_MEMORY_WATCH_FACTORY_KEY ] ;
@@ -776,7 +807,7 @@ export abstract class MemoryManagerSyncOps {
776807 if ( ! this . sources . has ( "sessions" ) || this . sessionUnsubscribe ) {
777808 return ;
778809 }
779- this . sessionUnsubscribe = onSessionTranscriptUpdate ( ( update ) => {
810+ this . sessionUnsubscribe = subscribeMemorySessionTranscriptUpdates ( ( update ) => {
780811 if ( this . closed ) {
781812 return ;
782813 }
0 commit comments