feat: add universal adapters for browser compatibility

- Create universal adapters for cross-platform support (browser/Node/serverless)
- Replace Node.js-specific imports with universal implementations
- Add OPFS support for browser persistent storage
- Maintain same BrainyData interface across all environments
- Enable real Brainy usage in browser console UI
- Keep package size optimized (no bloat)

Universal adapters in /src/universal/:
- uuid.ts: Cross-platform UUID generation
- crypto.ts: Browser/Node crypto operations
- fs.ts: OPFS/FileSystem/Memory storage adapter
- path.ts: Universal path operations
- events.ts: EventEmitter compatibility layer

This enables 'write once, run anywhere' for Brainy while maintaining
the exact same API. No breaking changes to existing code.
This commit is contained in:
David Snelling 2025-08-08 15:22:38 -07:00
parent 87d2fbb413
commit a653655de9
31 changed files with 2120 additions and 2028 deletions

View file

@ -8,7 +8,7 @@ import { BrainyData } from '../brainyData.js'
import { BrainyChat } from '../chat/brainyChat.js'
import { PerformanceMonitor } from './performanceMonitor.js'
import { HealthCheck } from './healthCheck.js'
import { LicensingSystem } from './licensingSystem.js'
// Licensing system moved to quantum-vault
import * as readline from 'readline'
import * as fs from 'fs/promises'
import * as path from 'path'
@ -81,7 +81,7 @@ export class Cortex {
private chatInstance?: BrainyChat
private performanceMonitor?: PerformanceMonitor
private healthCheck?: HealthCheck
private licensingSystem?: LicensingSystem
// private licensingSystem?: LicensingSystem // Moved to quantum-vault
private configPath: string
private config: CortexConfig
private encryptionKey?: Buffer
@ -1734,8 +1734,8 @@ export class Cortex {
this.healthCheck = new HealthCheck(this.brainy)
// Initialize licensing system
this.licensingSystem = new LicensingSystem()
await this.licensingSystem.initialize()
// Licensing system moved to quantum-vault for premium features
// Open source version has full functionality available
}
private async saveConfig(): Promise<void> {