import { describe, expect, it } from 'vitest'; import { InMemoryMemoryStore, Persona } from '../src'; describe('sleepMemory', () => { it('objectivizes and persists extracted durable facts through the memory model', async () => { const memory = new InMemoryMemoryStore(); const persona = new Persona('Mina', 'Mina remembers stable details.', { memory, now: '2026-05-01T10:00:00.000Z', models: { memoryExtraction: { async extract(input) { expect(input.formattedMessageHistory).toContain('user@2026-05-01T15:00:00.000Z: 나는 타입스크립트를 2025년부터 시작했어'); expect(input.instruction).toContain('Objectivize'); return [ { statement: 'The user started TypeScript in 2025.', topics: ['user', 'TypeScript', '2025'], confidence: 0.9, }, ]; }, }, }, }); const space = await persona.ready(); const drafts = await persona.sleepMemory({ datetime: '2026-05-02T00:00:00.000Z', messageHistory: [{ sender: 'user', time: '2026-05-01T15:00:00.000Z', content: '나는 타입스크립트를 2025년부터 시작했어' }], }); expect(drafts).toHaveLength(1); const facts = await memory.findFacts(space.id, ['TypeScript']); expect(facts[0]).toMatchObject({ statement: 'The user started TypeScript in 2025.', source: 'boxbrain.sleepMemory' }); expect(facts[0]?.topics).toContain('sleepMemory'); }); });