Spaces:
Paused
Paused
fix: CognitiveMemory sql.js Docker compatibility
Browse files- Add getSqlJsDatabase() to export raw sql.js database with exec() method
- Update index.ts to use getSqlJsDatabase() for memory systems
- Memory systems (Pattern, Failure, Cognitive) need direct exec() access
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
apps/backend/src/database/index.ts
CHANGED
|
@@ -511,6 +511,14 @@ export function getDatabase(): Database {
|
|
| 511 |
};
|
| 512 |
}
|
| 513 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 514 |
export async function closeDatabase(): Promise<void> {
|
| 515 |
if (sqliteDb) {
|
| 516 |
sqliteDb.close();
|
|
|
|
| 511 |
};
|
| 512 |
}
|
| 513 |
|
| 514 |
+
/**
|
| 515 |
+
* Get raw sql.js Database for memory systems that need direct exec() access
|
| 516 |
+
* This is needed for CognitiveMemory, PatternMemory, FailureMemory
|
| 517 |
+
*/
|
| 518 |
+
export function getSqlJsDatabase(): SqliteDatabase | null {
|
| 519 |
+
return sqliteDb;
|
| 520 |
+
}
|
| 521 |
+
|
| 522 |
export async function closeDatabase(): Promise<void> {
|
| 523 |
if (sqliteDb) {
|
| 524 |
sqliteDb.close();
|
apps/backend/src/index.ts
CHANGED
|
@@ -392,14 +392,20 @@ async function startServer() {
|
|
| 392 |
const { getSourceRegistry } = await import('./mcp/SourceRegistry.js');
|
| 393 |
const { initAutonomousAgent, startAutonomousLearning } = await import('./mcp/autonomousRouter.js');
|
| 394 |
const { autonomousRouter } = await import('./mcp/autonomousRouter.js');
|
| 395 |
-
const {
|
| 396 |
const { existsSync } = await import('fs');
|
| 397 |
const { readFileSync } = await import('fs');
|
| 398 |
const yaml = (await import('js-yaml')).default;
|
| 399 |
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 403 |
|
| 404 |
// Initialize Unified Memory System
|
| 405 |
const { unifiedMemorySystem } = await import('./mcp/cognitive/UnifiedMemorySystem.js');
|
|
|
|
| 392 |
const { getSourceRegistry } = await import('./mcp/SourceRegistry.js');
|
| 393 |
const { initAutonomousAgent, startAutonomousLearning } = await import('./mcp/autonomousRouter.js');
|
| 394 |
const { autonomousRouter } = await import('./mcp/autonomousRouter.js');
|
| 395 |
+
const { getSqlJsDatabase } = await import('./database/index.js');
|
| 396 |
const { existsSync } = await import('fs');
|
| 397 |
const { readFileSync } = await import('fs');
|
| 398 |
const yaml = (await import('js-yaml')).default;
|
| 399 |
|
| 400 |
+
// Use raw sql.js database for memory systems (they need exec() method)
|
| 401 |
+
const sqlJsDb = getSqlJsDatabase();
|
| 402 |
+
if (sqlJsDb) {
|
| 403 |
+
initCognitiveMemory(sqlJsDb);
|
| 404 |
+
console.log('🧠 Cognitive Memory initialized');
|
| 405 |
+
} else {
|
| 406 |
+
console.warn('⚠️ Cognitive Memory running in degraded mode (no sql.js database)');
|
| 407 |
+
initCognitiveMemory();
|
| 408 |
+
}
|
| 409 |
|
| 410 |
// Initialize Unified Memory System
|
| 411 |
const { unifiedMemorySystem } = await import('./mcp/cognitive/UnifiedMemorySystem.js');
|