"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ConversationMemory_1 = require("./memory/ConversationMemory");
function assert(condition, message) {
    if (!condition)
        throw new Error(message);
}
async function main() {
    const fakeMemory = {
        async search(query) {
            return `hit:${query}`;
        }
    };
    const fakeSession = {
        getSession(userId) {
            return {
                id: userId,
                lastActive: new Date().toISOString(),
                history: [
                    { role: 'user', content: 'quero evoluir a memória', timestamp: new Date().toISOString() },
                    { role: 'agent', content: 'vamos melhorar recuperação', timestamp: new Date().toISOString() }
                ]
            };
        }
    };
    const cm = new ConversationMemory_1.ConversationMemory(fakeMemory, fakeSession);
    const context = await cm.recoverContext('rafa', 'memory retrieval');
    assert(context.memorySnippet.includes('hit:memory retrieval'), 'should include memory search result');
    assert(context.recentHistory.includes('quero evoluir a memória'), 'should include recent history');
    assert(context.autoRecovered === true, 'should mark context as recovered');
    console.log('TEST_CONVERSATION_MEMORY_OK');
}
main().catch((error) => {
    console.error(error.message || error);
    process.exit(1);
});
