#!/usr/bin/env node // Simulate missing better-sqlite3 by intercepting require const Module = require('module'); const originalRequire = Module.prototype.require; Module.prototype.require = function(id) { if (id === 'better-sqlite3') { throw new Error('Cannot find module \'better-sqlite3\''); } return originalRequire.apply(this, arguments); }; // Now test the memory system const { EnhancedMemory } = require('./src/memory/enhanced-memory.js'); async function testFallback() { console.log('๐Ÿงช Testing SQLite Fallback Mechanism\n'); const memory = new EnhancedMemory(); try { await memory.initialize(); console.log('โœ… Memory initialized successfully'); console.log(`๐Ÿ“Š Using fallback: ${memory.useFallback ? 'YES (in-memory)' : 'NO (SQLite)'}`); // Test basic operations console.log('\n๐Ÿ”ง Testing memory operations:'); await memory.store('test-key', 'test-value', { namespace: 'test' }); console.log('โœ… Store operation successful'); const value = await memory.retrieve('test-key', { namespace: 'test' }); console.log(`โœ… Retrieve operation successful: ${value}`); const items = await memory.list({ namespace: 'test' }); console.log(`โœ… List operation successful: ${items.length} items`); console.log('\n๐ŸŽ‰ All operations completed successfully!'); console.log('๐Ÿ’ก The fallback mechanism is working correctly.'); } catch (error) { console.error('โŒ Error:', error.message); process.exit(1); } } testFallback();