@@ -6,7 +6,57 @@ import {
66 type MetamemoryState ,
77 type CompactionResult ,
88 type ThreadClass ,
9- } from '../src/metamemory/index.js' ;
9+ } from '../src/metamemory-old/index.js' ;
10+
11+ vi . mock ( '@just-every/ensemble' , async ( importOriginal ) => {
12+ const original : any = await importOriginal ( ) ;
13+ return {
14+ ...original ,
15+ ensembleRequest : vi . fn ( async function * ( _messages : any , agent : any ) {
16+ const instr = agent . instructions as string ;
17+ if ( instr . includes ( 'Analyze the following conversation messages' ) ) {
18+ yield {
19+ type : 'response_output' ,
20+ message : {
21+ type : 'message' ,
22+ role : 'assistant' ,
23+ content : JSON . stringify ( {
24+ messageAnalysis : [
25+ { messageId : 'msg1' , threadIds : [ 'thread1' ] , confidence : 0.9 } ,
26+ { messageId : 'msg2' , threadIds : [ 'thread1' ] , confidence : 0.85 }
27+ ] ,
28+ threadOperations : {
29+ create : [
30+ { id : 'thread1' , name : 'Test Thread' , initialMessages : [ 'msg1' ] }
31+ ]
32+ } ,
33+ reasoning : ''
34+ } )
35+ }
36+ } ;
37+ } else if ( instr . includes ( 'Summarize the following conversation thread' ) ) {
38+ yield {
39+ type : 'response_output' ,
40+ message : {
41+ type : 'message' ,
42+ role : 'assistant' ,
43+ content : JSON . stringify ( {
44+ threadId : 'thread1' ,
45+ title : 'Test Thread Summary' ,
46+ class : 'active' ,
47+ keySummary : 'This thread discusses testing the metamemory system.' ,
48+ keyPoints : [ 'Created test messages' , 'Analyzed thread structure' ] ,
49+ status : 'active' ,
50+ importance : 75
51+ } )
52+ }
53+ } ;
54+ } else {
55+ yield { type : 'response_output' , message : { type : 'message' , role : 'assistant' , content : '{}' } } ;
56+ }
57+ } )
58+ } ;
59+ } ) ;
1060
1161// Mock agent for testing
1262const createMockAgent = ( ) => {
@@ -244,8 +294,8 @@ describe('Metamemory System', () => {
244294 expect ( coreMessage ?. isCompacted ) . toBe ( false ) ;
245295
246296 // Ephemeral thread should be summarized
247- const ephemeralSummary = result . messages . find ( m =>
248- m . content . includes ( 'Thread: Casual Chat ' ) && m . isCompacted
297+ const ephemeralSummary = result . messages . find ( m =>
298+ m . content . includes ( 'Brief social interaction ' ) && m . isCompacted
249299 ) ;
250300 expect ( ephemeralSummary ) . toBeDefined ( ) ;
251301 expect ( ephemeralSummary ?. isCompacted ) . toBe ( true ) ;
0 commit comments