brainy/src/shared/default-augmentations.ts
David Snelling 54e39883a4 feat: v0.57.0 - rename CLI to brainy and Neural Import to Cortex
BREAKING CHANGES:
- CLI command renamed from 'cortex' to 'brainy'
- Neural Import renamed to Cortex augmentation
- Class CortexSenseAugmentation (was NeuralImportSenseAugmentation)

Benefits:
- npx @soulcraft/brainy now works automatically
- Better conceptual clarity: Cortex = AI intelligence layer
- Cleaner architecture: CLI = brainy, AI = Cortex, DB = BrainyData
2025-08-07 20:13:02 -07:00

130 lines
No EOL
4 KiB
TypeScript

/**
* Default Augmentation Registry
*
* 🧠⚛️ Pre-installed augmentations that come with every Brainy installation
* These are the core "sensory organs" of the atomic age brain-in-jar system
*/
import { BrainyDataInterface } from '../types/brainyDataInterface.js'
/**
* Default augmentations that ship with Brainy
* These are automatically registered on startup
*/
export class DefaultAugmentationRegistry {
private brainy: BrainyDataInterface
constructor(brainy: BrainyDataInterface) {
this.brainy = brainy
}
/**
* Initialize all default augmentations
* Called during Brainy startup to register core functionality
*/
async initializeDefaults(): Promise<void> {
console.log('🧠⚛️ Initializing default augmentations...')
// Register Cortex as default SENSE augmentation
await this.registerCortex()
console.log('🧠⚛️ Default augmentations initialized')
}
/**
* Cortex - Default SENSE Augmentation
* AI-powered data understanding and entity extraction
*/
private async registerCortex(): Promise<void> {
try {
// Import the Cortex augmentation
const { CortexSenseAugmentation } = await import('../augmentations/cortexSense.js')
// Note: The actual registration is commented out since BrainyData doesn't have addAugmentation method yet
// This would create instance with default configuration
/*
const cortex = new CortexSenseAugmentation(this.brainy as any, {
confidenceThreshold: 0.7,
enableWeights: true,
skipDuplicates: true
})
// Add as SENSE augmentation to Brainy (when method is available)
if (this.brainy.addAugmentation) {
await this.brainy.addAugmentation('SENSE', cortex, {
position: 1, // First in the SENSE pipeline
name: 'cortex',
autoStart: true
})
}
*/
console.log('🧠⚛️ Cortex module loaded (awaiting BrainyData augmentation support)')
} catch (error) {
console.error('❌ Failed to register Cortex:', error instanceof Error ? error.message : String(error))
// Don't throw - Brainy should still work without Neural Import
}
}
/**
* Check if Cortex is available and working
*/
async checkCortexHealth(): Promise<{
available: boolean
status: string
version?: string
}> {
try {
// Check if Cortex is registered as an augmentation
// Note: hasAugmentation method doesn't exist yet in BrainyData
const hasCortex = false // this.brainy.hasAugmentation && this.brainy.hasAugmentation('SENSE', 'cortex')
return {
available: hasCortex || false,
status: hasCortex ? 'active' : 'not registered (awaiting BrainyData support)',
version: '1.0.0'
}
} catch (error) {
return {
available: false,
status: `Error: ${error instanceof Error ? error.message : String(error)}`
}
}
}
/**
* Reinstall Cortex if it's missing or corrupted
*/
async reinstallCortex(): Promise<void> {
try {
// Remove existing if present
// Note: removeAugmentation method doesn't exist yet in BrainyData
/*
if (this.brainy.removeAugmentation) {
try {
await this.brainy.removeAugmentation('SENSE', 'cortex')
} catch (error) {
// Ignore errors if augmentation doesn't exist
}
}
*/
// Re-register
await this.registerCortex()
console.log('🧠⚛️ Cortex reinstalled successfully')
} catch (error) {
throw new Error(`Failed to reinstall Cortex: ${error instanceof Error ? error.message : String(error)}`)
}
}
}
/**
* Helper function to initialize default augmentations for any Brainy instance
*/
export async function initializeDefaultAugmentations(brainy: BrainyDataInterface): Promise<DefaultAugmentationRegistry> {
const registry = new DefaultAugmentationRegistry(brainy)
await registry.initializeDefaults()
return registry
}