@soulcraft/brainy 0.62.3 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/brainy.js +276 -6
- package/dist/augmentationPipeline.d.ts +60 -0
- package/dist/augmentationPipeline.js +94 -0
- package/dist/augmentations/neuralImport.d.ts +199 -0
- package/dist/augmentations/neuralImport.js +750 -0
- package/dist/brainyData.d.ts +90 -5
- package/dist/brainyData.js +110 -5
- package/dist/chat/BrainyChat.d.ts +113 -0
- package/dist/chat/BrainyChat.js +374 -0
- package/dist/chat/ChatCLI.d.ts +61 -0
- package/dist/chat/ChatCLI.js +351 -0
- package/dist/connectors/interfaces/IConnector.d.ts +3 -3
- package/dist/connectors/interfaces/IConnector.js +1 -1
- package/dist/cortex/cortex-legacy.d.ts +5 -0
- package/dist/cortex/cortex-legacy.js +75 -15
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -1
- package/dist/shared/default-augmentations.d.ts +3 -3
- package/dist/shared/default-augmentations.js +10 -10
- package/package.json +1 -1
package/bin/brainy.js
CHANGED
|
@@ -76,9 +76,10 @@ program
|
|
|
76
76
|
|
|
77
77
|
program
|
|
78
78
|
.command('add [data]')
|
|
79
|
-
.description('Add data
|
|
79
|
+
.description('🔒 Add data literally (safe, no AI processing)')
|
|
80
80
|
.option('-m, --metadata <json>', 'Metadata facets as JSON')
|
|
81
81
|
.option('-i, --id <id>', 'Custom ID')
|
|
82
|
+
.option('--smart', 'Enable AI processing (same as smart-add command)')
|
|
82
83
|
.action(wrapAction(async (data, options) => {
|
|
83
84
|
let metadata = {}
|
|
84
85
|
if (options.metadata) {
|
|
@@ -92,7 +93,38 @@ program
|
|
|
92
93
|
if (options.id) {
|
|
93
94
|
metadata.id = options.id
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
+
|
|
97
|
+
// Use smart processing if --smart flag is provided
|
|
98
|
+
if (options.smart) {
|
|
99
|
+
console.log(chalk.dim('🧠 AI processing enabled'))
|
|
100
|
+
await cortex.addSmart(data, metadata)
|
|
101
|
+
} else {
|
|
102
|
+
console.log(chalk.dim('🔒 Literal storage (safe for secrets/API keys)'))
|
|
103
|
+
await cortex.add(data, metadata)
|
|
104
|
+
}
|
|
105
|
+
}))
|
|
106
|
+
|
|
107
|
+
program
|
|
108
|
+
.command('smart-add [data]')
|
|
109
|
+
.description('🧠 Add data with AI processing (Neural Import, entity detection)')
|
|
110
|
+
.option('-m, --metadata <json>', 'Metadata facets as JSON')
|
|
111
|
+
.option('-i, --id <id>', 'Custom ID')
|
|
112
|
+
.action(wrapAction(async (data, options) => {
|
|
113
|
+
let metadata = {}
|
|
114
|
+
if (options.metadata) {
|
|
115
|
+
try {
|
|
116
|
+
metadata = JSON.parse(options.metadata)
|
|
117
|
+
} catch {
|
|
118
|
+
console.error(chalk.red('Invalid JSON metadata'))
|
|
119
|
+
process.exit(1)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (options.id) {
|
|
123
|
+
metadata.id = options.id
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
console.log(chalk.dim('🧠 AI processing enabled (Neural Import + entity detection)'))
|
|
127
|
+
await cortex.addSmart(data, metadata)
|
|
96
128
|
}))
|
|
97
129
|
|
|
98
130
|
program
|
|
@@ -124,10 +156,125 @@ program
|
|
|
124
156
|
|
|
125
157
|
program
|
|
126
158
|
.command('chat [question]')
|
|
127
|
-
.description('AI
|
|
128
|
-
.option('-l, --
|
|
159
|
+
.description('🧠 Beautiful AI chat with local memory')
|
|
160
|
+
.option('-l, --list', 'List all chat sessions')
|
|
161
|
+
.option('-s, --search <query>', 'Search all conversations')
|
|
162
|
+
.option('-h, --history [limit]', 'Show conversation history (default: 10)')
|
|
163
|
+
.option('--session <id>', 'Use specific chat session')
|
|
164
|
+
.option('--new', 'Start a new session')
|
|
165
|
+
.option('--role <name>', 'Agent role (premium feature preview)', 'assistant')
|
|
166
|
+
.option('--ui <mode>', 'UI mode: terminal (default) or web (premium)', 'terminal')
|
|
129
167
|
.action(wrapInteractive(async (question, options) => {
|
|
130
|
-
await
|
|
168
|
+
const { BrainyData } = await import('../dist/brainyData.js')
|
|
169
|
+
|
|
170
|
+
const brainy = new BrainyData()
|
|
171
|
+
await brainy.init()
|
|
172
|
+
|
|
173
|
+
// Handle web UI mode (premium feature)
|
|
174
|
+
if (options.ui === 'web') {
|
|
175
|
+
console.log(chalk.cyan('🌐 Starting Brain Cloud Coordination Interface...'))
|
|
176
|
+
console.log()
|
|
177
|
+
|
|
178
|
+
try {
|
|
179
|
+
// Check if Brain Cloud is available
|
|
180
|
+
const hasLicense = process.env.BRAINY_LICENSE_KEY || await checkBrainCloudAuth()
|
|
181
|
+
|
|
182
|
+
if (!hasLicense) {
|
|
183
|
+
console.log(chalk.yellow('🔐 Brain Cloud Authentication Required'))
|
|
184
|
+
console.log('The web coordination UI requires Brain Cloud authentication.')
|
|
185
|
+
console.log()
|
|
186
|
+
console.log('Get started:')
|
|
187
|
+
console.log(' 1. ' + chalk.green('brainy cloud auth') + ' - Authenticate with Brain Cloud')
|
|
188
|
+
console.log(' 2. ' + chalk.cyan('https://app.soulcraft.com') + ' - Sign up for Brain Cloud')
|
|
189
|
+
console.log()
|
|
190
|
+
console.log('Falling back to terminal chat...')
|
|
191
|
+
console.log()
|
|
192
|
+
options.ui = 'terminal'
|
|
193
|
+
} else {
|
|
194
|
+
// Import and start coordination server
|
|
195
|
+
const { createCoordinationServer } = await import('@soulcraft/brain-cloud/coordination/server.js')
|
|
196
|
+
|
|
197
|
+
const server = createCoordinationServer({
|
|
198
|
+
brainy,
|
|
199
|
+
port: 3001
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
await server.start()
|
|
203
|
+
|
|
204
|
+
console.log(chalk.green('✅ Brain Cloud coordination interface started!'))
|
|
205
|
+
console.log()
|
|
206
|
+
console.log('🤝 Multi-agent coordination available at:')
|
|
207
|
+
console.log(' ' + chalk.cyan('http://localhost:3001/coordination'))
|
|
208
|
+
console.log()
|
|
209
|
+
console.log('💡 Features available:')
|
|
210
|
+
console.log(' • Visual agent coordination')
|
|
211
|
+
console.log(' • Real-time multi-agent handoffs')
|
|
212
|
+
console.log(' • Session management')
|
|
213
|
+
console.log(' • Premium Brain Cloud integration')
|
|
214
|
+
console.log()
|
|
215
|
+
|
|
216
|
+
// Try to open browser
|
|
217
|
+
try {
|
|
218
|
+
const { exec } = await import('child_process')
|
|
219
|
+
const { promisify } = await import('util')
|
|
220
|
+
const execAsync = promisify(exec)
|
|
221
|
+
|
|
222
|
+
const command = process.platform === 'win32' ? 'start' :
|
|
223
|
+
process.platform === 'darwin' ? 'open' : 'xdg-open'
|
|
224
|
+
|
|
225
|
+
await execAsync(`${command} "http://localhost:3001/coordination"`)
|
|
226
|
+
console.log(chalk.green('🌐 Opening coordination interface in your browser...'))
|
|
227
|
+
} catch (error) {
|
|
228
|
+
console.log(chalk.yellow('💡 Copy the URL above to open in your browser'))
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
console.log()
|
|
232
|
+
console.log(chalk.dim('Press Ctrl+C to stop the server'))
|
|
233
|
+
|
|
234
|
+
// Keep server running
|
|
235
|
+
process.on('SIGINT', async () => {
|
|
236
|
+
console.log('\n🛑 Stopping coordination server...')
|
|
237
|
+
await server.stop()
|
|
238
|
+
process.exit(0)
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
// Wait indefinitely
|
|
242
|
+
return new Promise(() => {})
|
|
243
|
+
}
|
|
244
|
+
} catch (error) {
|
|
245
|
+
console.log(chalk.red('❌ Failed to start web coordination interface:'), error.message)
|
|
246
|
+
console.log(chalk.yellow('Falling back to terminal chat...'))
|
|
247
|
+
console.log()
|
|
248
|
+
options.ui = 'terminal'
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Terminal chat mode (default)
|
|
253
|
+
const { ChatCLI } = await import('../dist/chat/ChatCLI.js')
|
|
254
|
+
const chatCLI = new ChatCLI(brainy)
|
|
255
|
+
|
|
256
|
+
// Handle different modes
|
|
257
|
+
if (options.list) {
|
|
258
|
+
await chatCLI.listSessions()
|
|
259
|
+
} else if (options.search) {
|
|
260
|
+
await chatCLI.searchConversations(options.search)
|
|
261
|
+
} else if (options.history) {
|
|
262
|
+
const limit = typeof options.history === 'string' ? parseInt(options.history) : 10
|
|
263
|
+
await chatCLI.showHistory(limit)
|
|
264
|
+
} else if (question) {
|
|
265
|
+
// Single message mode
|
|
266
|
+
await chatCLI.sendMessage(question, {
|
|
267
|
+
sessionId: options.session,
|
|
268
|
+
speaker: options.role
|
|
269
|
+
})
|
|
270
|
+
} else {
|
|
271
|
+
// Interactive chat mode
|
|
272
|
+
await chatCLI.startInteractiveChat({
|
|
273
|
+
sessionId: options.session,
|
|
274
|
+
speaker: options.role,
|
|
275
|
+
newSession: options.new
|
|
276
|
+
})
|
|
277
|
+
}
|
|
131
278
|
}))
|
|
132
279
|
|
|
133
280
|
program
|
|
@@ -176,6 +323,8 @@ program
|
|
|
176
323
|
await cortex.restore(file)
|
|
177
324
|
}))
|
|
178
325
|
|
|
326
|
+
// Chat commands moved to main chat command above
|
|
327
|
+
|
|
179
328
|
// ========================================
|
|
180
329
|
// BRAIN CLOUD INTEGRATION
|
|
181
330
|
// ========================================
|
|
@@ -857,6 +1006,99 @@ program
|
|
|
857
1006
|
await cortex.chat()
|
|
858
1007
|
}))
|
|
859
1008
|
|
|
1009
|
+
// ========================================
|
|
1010
|
+
// AUGMENTATION CONTROL COMMANDS
|
|
1011
|
+
// ========================================
|
|
1012
|
+
|
|
1013
|
+
program
|
|
1014
|
+
.command('augment')
|
|
1015
|
+
.description('List all augmentations with their status')
|
|
1016
|
+
.action(wrapAction(async () => {
|
|
1017
|
+
const { BrainyData } = await import('../dist/brainyData.js')
|
|
1018
|
+
const brainy = new BrainyData()
|
|
1019
|
+
await brainy.init()
|
|
1020
|
+
|
|
1021
|
+
const augmentations = brainy.listAugmentations()
|
|
1022
|
+
|
|
1023
|
+
if (augmentations.length === 0) {
|
|
1024
|
+
console.log(chalk.yellow('No augmentations registered'))
|
|
1025
|
+
return
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
console.log(chalk.cyan('🔧 Augmentations Status\n'))
|
|
1029
|
+
|
|
1030
|
+
const grouped = augmentations.reduce((acc, aug) => {
|
|
1031
|
+
if (!acc[aug.type]) acc[aug.type] = []
|
|
1032
|
+
acc[aug.type].push(aug)
|
|
1033
|
+
return acc
|
|
1034
|
+
}, {})
|
|
1035
|
+
|
|
1036
|
+
for (const [type, augs] of Object.entries(grouped)) {
|
|
1037
|
+
console.log(chalk.bold(`${type.toUpperCase()}:`))
|
|
1038
|
+
for (const aug of augs) {
|
|
1039
|
+
const status = aug.enabled ? chalk.green('✅ enabled') : chalk.red('❌ disabled')
|
|
1040
|
+
console.log(` ${aug.name} - ${status}`)
|
|
1041
|
+
console.log(chalk.dim(` ${aug.description}`))
|
|
1042
|
+
}
|
|
1043
|
+
console.log('')
|
|
1044
|
+
}
|
|
1045
|
+
}))
|
|
1046
|
+
|
|
1047
|
+
program
|
|
1048
|
+
.command('augment enable <name>')
|
|
1049
|
+
.description('Enable an augmentation by name')
|
|
1050
|
+
.action(wrapAction(async (name) => {
|
|
1051
|
+
const { BrainyData } = await import('../dist/brainyData.js')
|
|
1052
|
+
const brainy = new BrainyData()
|
|
1053
|
+
await brainy.init()
|
|
1054
|
+
|
|
1055
|
+
const success = brainy.enableAugmentation(name)
|
|
1056
|
+
|
|
1057
|
+
if (success) {
|
|
1058
|
+
console.log(chalk.green(`✅ Enabled augmentation: ${name}`))
|
|
1059
|
+
} else {
|
|
1060
|
+
console.log(chalk.red(`❌ Augmentation not found: ${name}`))
|
|
1061
|
+
console.log(chalk.dim('Use "brainy augment" to see available augmentations'))
|
|
1062
|
+
}
|
|
1063
|
+
}))
|
|
1064
|
+
|
|
1065
|
+
program
|
|
1066
|
+
.command('augment disable <name>')
|
|
1067
|
+
.description('Disable an augmentation by name')
|
|
1068
|
+
.action(wrapAction(async (name) => {
|
|
1069
|
+
const { BrainyData } = await import('../dist/brainyData.js')
|
|
1070
|
+
const brainy = new BrainyData()
|
|
1071
|
+
await brainy.init()
|
|
1072
|
+
|
|
1073
|
+
const success = brainy.disableAugmentation(name)
|
|
1074
|
+
|
|
1075
|
+
if (success) {
|
|
1076
|
+
console.log(chalk.green(`✅ Disabled augmentation: ${name}`))
|
|
1077
|
+
} else {
|
|
1078
|
+
console.log(chalk.red(`❌ Augmentation not found: ${name}`))
|
|
1079
|
+
console.log(chalk.dim('Use "brainy augment" to see available augmentations'))
|
|
1080
|
+
}
|
|
1081
|
+
}))
|
|
1082
|
+
|
|
1083
|
+
program
|
|
1084
|
+
.command('augment status <name>')
|
|
1085
|
+
.description('Check if an augmentation is enabled')
|
|
1086
|
+
.action(wrapAction(async (name) => {
|
|
1087
|
+
const { BrainyData } = await import('../dist/brainyData.js')
|
|
1088
|
+
const brainy = new BrainyData()
|
|
1089
|
+
await brainy.init()
|
|
1090
|
+
|
|
1091
|
+
const enabled = brainy.isAugmentationEnabled(name)
|
|
1092
|
+
|
|
1093
|
+
if (enabled !== undefined) {
|
|
1094
|
+
const status = enabled ? chalk.green('✅ enabled') : chalk.red('❌ disabled')
|
|
1095
|
+
console.log(`${name}: ${status}`)
|
|
1096
|
+
} else {
|
|
1097
|
+
console.log(chalk.red(`❌ Augmentation not found: ${name}`))
|
|
1098
|
+
console.log(chalk.dim('Use "brainy augment" to see available augmentations'))
|
|
1099
|
+
}
|
|
1100
|
+
}))
|
|
1101
|
+
|
|
860
1102
|
// ========================================
|
|
861
1103
|
// PARSE AND HANDLE
|
|
862
1104
|
// ========================================
|
|
@@ -872,7 +1114,15 @@ if (!process.argv.slice(2).length) {
|
|
|
872
1114
|
console.log(' brainy init # Initialize project')
|
|
873
1115
|
console.log(' brainy add "some data" # Add multi-dimensional data')
|
|
874
1116
|
console.log(' brainy search "query" # Search across all dimensions')
|
|
875
|
-
console.log(' brainy chat # AI chat with
|
|
1117
|
+
console.log(' brainy chat # 🧠 Magical AI chat with perfect memory')
|
|
1118
|
+
console.log('')
|
|
1119
|
+
console.log(chalk.bold('Chat & Memory:'))
|
|
1120
|
+
console.log(' brainy chat # Interactive chat with local memory')
|
|
1121
|
+
console.log(' brainy chat "question" # Single question with context')
|
|
1122
|
+
console.log(' brainy chat --list # List all chat sessions')
|
|
1123
|
+
console.log(' brainy chat --search "query" # Search all conversations')
|
|
1124
|
+
console.log(' brainy chat --history # Show conversation history')
|
|
1125
|
+
console.log(' brainy chat --ui=web # 🌐 Premium web coordination interface')
|
|
876
1126
|
console.log('')
|
|
877
1127
|
console.log(chalk.bold('Brain Cloud (Premium):'))
|
|
878
1128
|
console.log(chalk.green(' brainy cloud setup # Auto-setup with provisioning'))
|
|
@@ -892,6 +1142,26 @@ if (!process.argv.slice(2).length) {
|
|
|
892
1142
|
// BRAIN CLOUD MEMORY SETUP FUNCTIONS
|
|
893
1143
|
// ========================================
|
|
894
1144
|
|
|
1145
|
+
async function checkBrainCloudAuth() {
|
|
1146
|
+
try {
|
|
1147
|
+
// Check for license file
|
|
1148
|
+
const { readFile } = await import('fs/promises')
|
|
1149
|
+
const { join } = await import('path')
|
|
1150
|
+
const { homedir } = await import('os')
|
|
1151
|
+
|
|
1152
|
+
try {
|
|
1153
|
+
const licensePath = join(homedir(), '.brainy', 'license')
|
|
1154
|
+
const license = await readFile(licensePath, 'utf8')
|
|
1155
|
+
return license.trim().startsWith('lic_')
|
|
1156
|
+
} catch {}
|
|
1157
|
+
|
|
1158
|
+
// Check for existing customer ID
|
|
1159
|
+
return await detectCustomerId() !== null
|
|
1160
|
+
} catch {
|
|
1161
|
+
return false
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
|
|
895
1165
|
async function detectCustomerId() {
|
|
896
1166
|
try {
|
|
897
1167
|
// Method 1: Check for existing brainy config
|
|
@@ -10,6 +10,19 @@
|
|
|
10
10
|
* @deprecated AugmentationPipeline - Use Cortex instead
|
|
11
11
|
*/
|
|
12
12
|
import { BrainyAugmentations, IAugmentation, IWebSocketSupport, AugmentationResponse, AugmentationType } from './types/augmentations.js';
|
|
13
|
+
/**
|
|
14
|
+
* Type definitions for the augmentation registry
|
|
15
|
+
*/
|
|
16
|
+
type AugmentationRegistry = {
|
|
17
|
+
sense: BrainyAugmentations.ISenseAugmentation[];
|
|
18
|
+
conduit: BrainyAugmentations.IConduitAugmentation[];
|
|
19
|
+
cognition: BrainyAugmentations.ICognitionAugmentation[];
|
|
20
|
+
memory: BrainyAugmentations.IMemoryAugmentation[];
|
|
21
|
+
perception: BrainyAugmentations.IPerceptionAugmentation[];
|
|
22
|
+
dialog: BrainyAugmentations.IDialogAugmentation[];
|
|
23
|
+
activation: BrainyAugmentations.IActivationAugmentation[];
|
|
24
|
+
webSocket: IWebSocketSupport[];
|
|
25
|
+
};
|
|
13
26
|
/**
|
|
14
27
|
* Execution mode for the pipeline
|
|
15
28
|
*/
|
|
@@ -205,7 +218,54 @@ export declare class Cortex {
|
|
|
205
218
|
* @returns A promise that resolves with the results from all augmentations
|
|
206
219
|
*/
|
|
207
220
|
private executeTypedPipeline;
|
|
221
|
+
/**
|
|
222
|
+
* Enable an augmentation by name
|
|
223
|
+
*
|
|
224
|
+
* @param name The name of the augmentation to enable
|
|
225
|
+
* @returns True if augmentation was found and enabled
|
|
226
|
+
*/
|
|
227
|
+
enableAugmentation(name: string): boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Disable an augmentation by name
|
|
230
|
+
*
|
|
231
|
+
* @param name The name of the augmentation to disable
|
|
232
|
+
* @returns True if augmentation was found and disabled
|
|
233
|
+
*/
|
|
234
|
+
disableAugmentation(name: string): boolean;
|
|
235
|
+
/**
|
|
236
|
+
* Check if an augmentation is enabled
|
|
237
|
+
*
|
|
238
|
+
* @param name The name of the augmentation to check
|
|
239
|
+
* @returns True if augmentation is found and enabled, false otherwise
|
|
240
|
+
*/
|
|
241
|
+
isAugmentationEnabled(name: string): boolean;
|
|
242
|
+
/**
|
|
243
|
+
* Get all augmentations with their enabled status
|
|
244
|
+
*
|
|
245
|
+
* @returns Array of augmentations with name, type, and enabled status
|
|
246
|
+
*/
|
|
247
|
+
listAugmentationsWithStatus(): Array<{
|
|
248
|
+
name: string;
|
|
249
|
+
type: keyof AugmentationRegistry;
|
|
250
|
+
enabled: boolean;
|
|
251
|
+
description: string;
|
|
252
|
+
}>;
|
|
253
|
+
/**
|
|
254
|
+
* Enable all augmentations of a specific type
|
|
255
|
+
*
|
|
256
|
+
* @param type The type of augmentations to enable
|
|
257
|
+
* @returns Number of augmentations enabled
|
|
258
|
+
*/
|
|
259
|
+
enableAugmentationType(type: keyof AugmentationRegistry): number;
|
|
260
|
+
/**
|
|
261
|
+
* Disable all augmentations of a specific type
|
|
262
|
+
*
|
|
263
|
+
* @param type The type of augmentations to disable
|
|
264
|
+
* @returns Number of augmentations disabled
|
|
265
|
+
*/
|
|
266
|
+
disableAugmentationType(type: keyof AugmentationRegistry): number;
|
|
208
267
|
}
|
|
209
268
|
export declare const cortex: Cortex;
|
|
210
269
|
export declare const AugmentationPipeline: typeof Cortex;
|
|
211
270
|
export declare const augmentationPipeline: Cortex;
|
|
271
|
+
export {};
|
|
@@ -471,6 +471,100 @@ export class Cortex {
|
|
|
471
471
|
return results;
|
|
472
472
|
}
|
|
473
473
|
}
|
|
474
|
+
/**
|
|
475
|
+
* Enable an augmentation by name
|
|
476
|
+
*
|
|
477
|
+
* @param name The name of the augmentation to enable
|
|
478
|
+
* @returns True if augmentation was found and enabled
|
|
479
|
+
*/
|
|
480
|
+
enableAugmentation(name) {
|
|
481
|
+
for (const type of Object.keys(this.registry)) {
|
|
482
|
+
const augmentation = this.registry[type].find(aug => aug.name === name);
|
|
483
|
+
if (augmentation) {
|
|
484
|
+
augmentation.enabled = true;
|
|
485
|
+
return true;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
return false;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Disable an augmentation by name
|
|
492
|
+
*
|
|
493
|
+
* @param name The name of the augmentation to disable
|
|
494
|
+
* @returns True if augmentation was found and disabled
|
|
495
|
+
*/
|
|
496
|
+
disableAugmentation(name) {
|
|
497
|
+
for (const type of Object.keys(this.registry)) {
|
|
498
|
+
const augmentation = this.registry[type].find(aug => aug.name === name);
|
|
499
|
+
if (augmentation) {
|
|
500
|
+
augmentation.enabled = false;
|
|
501
|
+
return true;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return false;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Check if an augmentation is enabled
|
|
508
|
+
*
|
|
509
|
+
* @param name The name of the augmentation to check
|
|
510
|
+
* @returns True if augmentation is found and enabled, false otherwise
|
|
511
|
+
*/
|
|
512
|
+
isAugmentationEnabled(name) {
|
|
513
|
+
for (const type of Object.keys(this.registry)) {
|
|
514
|
+
const augmentation = this.registry[type].find(aug => aug.name === name);
|
|
515
|
+
if (augmentation) {
|
|
516
|
+
return augmentation.enabled;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Get all augmentations with their enabled status
|
|
523
|
+
*
|
|
524
|
+
* @returns Array of augmentations with name, type, and enabled status
|
|
525
|
+
*/
|
|
526
|
+
listAugmentationsWithStatus() {
|
|
527
|
+
const result = [];
|
|
528
|
+
for (const [type, augmentations] of Object.entries(this.registry)) {
|
|
529
|
+
for (const aug of augmentations) {
|
|
530
|
+
result.push({
|
|
531
|
+
name: aug.name,
|
|
532
|
+
type: type,
|
|
533
|
+
enabled: aug.enabled,
|
|
534
|
+
description: aug.description
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
return result;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Enable all augmentations of a specific type
|
|
542
|
+
*
|
|
543
|
+
* @param type The type of augmentations to enable
|
|
544
|
+
* @returns Number of augmentations enabled
|
|
545
|
+
*/
|
|
546
|
+
enableAugmentationType(type) {
|
|
547
|
+
let count = 0;
|
|
548
|
+
for (const aug of this.registry[type]) {
|
|
549
|
+
aug.enabled = true;
|
|
550
|
+
count++;
|
|
551
|
+
}
|
|
552
|
+
return count;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Disable all augmentations of a specific type
|
|
556
|
+
*
|
|
557
|
+
* @param type The type of augmentations to disable
|
|
558
|
+
* @returns Number of augmentations disabled
|
|
559
|
+
*/
|
|
560
|
+
disableAugmentationType(type) {
|
|
561
|
+
let count = 0;
|
|
562
|
+
for (const aug of this.registry[type]) {
|
|
563
|
+
aug.enabled = false;
|
|
564
|
+
count++;
|
|
565
|
+
}
|
|
566
|
+
return count;
|
|
567
|
+
}
|
|
474
568
|
}
|
|
475
569
|
// Create and export a default instance of the cortex
|
|
476
570
|
export const cortex = new Cortex();
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Neural Import Augmentation - AI-Powered Data Understanding
|
|
3
|
+
*
|
|
4
|
+
* 🧠 Built-in AI augmentation for intelligent data processing
|
|
5
|
+
* ⚛️ Always free, always included, always enabled
|
|
6
|
+
*
|
|
7
|
+
* This is the default AI-powered augmentation that comes with every Brainy installation.
|
|
8
|
+
* It provides intelligent data understanding, entity detection, and relationship analysis.
|
|
9
|
+
*/
|
|
10
|
+
import { ISenseAugmentation, AugmentationResponse } from '../types/augmentations.js';
|
|
11
|
+
import { BrainyData } from '../brainyData.js';
|
|
12
|
+
export interface NeuralAnalysisResult {
|
|
13
|
+
detectedEntities: DetectedEntity[];
|
|
14
|
+
detectedRelationships: DetectedRelationship[];
|
|
15
|
+
confidence: number;
|
|
16
|
+
insights: NeuralInsight[];
|
|
17
|
+
}
|
|
18
|
+
export interface DetectedEntity {
|
|
19
|
+
originalData: any;
|
|
20
|
+
nounType: string;
|
|
21
|
+
confidence: number;
|
|
22
|
+
suggestedId: string;
|
|
23
|
+
reasoning: string;
|
|
24
|
+
alternativeTypes: Array<{
|
|
25
|
+
type: string;
|
|
26
|
+
confidence: number;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
export interface DetectedRelationship {
|
|
30
|
+
sourceId: string;
|
|
31
|
+
targetId: string;
|
|
32
|
+
verbType: string;
|
|
33
|
+
confidence: number;
|
|
34
|
+
weight: number;
|
|
35
|
+
reasoning: string;
|
|
36
|
+
context: string;
|
|
37
|
+
metadata?: Record<string, any>;
|
|
38
|
+
}
|
|
39
|
+
export interface NeuralInsight {
|
|
40
|
+
type: 'hierarchy' | 'cluster' | 'pattern' | 'anomaly' | 'opportunity';
|
|
41
|
+
description: string;
|
|
42
|
+
confidence: number;
|
|
43
|
+
affectedEntities: string[];
|
|
44
|
+
recommendation?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface NeuralImportConfig {
|
|
47
|
+
confidenceThreshold: number;
|
|
48
|
+
enableWeights: boolean;
|
|
49
|
+
skipDuplicates: boolean;
|
|
50
|
+
categoryFilter?: string[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Neural Import SENSE Augmentation - The Brain's Perceptual System
|
|
54
|
+
*/
|
|
55
|
+
export declare class NeuralImportAugmentation implements ISenseAugmentation {
|
|
56
|
+
readonly name: string;
|
|
57
|
+
readonly description: string;
|
|
58
|
+
enabled: boolean;
|
|
59
|
+
private brainy;
|
|
60
|
+
private config;
|
|
61
|
+
constructor(brainy: BrainyData, config?: Partial<NeuralImportConfig>);
|
|
62
|
+
initialize(): Promise<void>;
|
|
63
|
+
shutDown(): Promise<void>;
|
|
64
|
+
getStatus(): Promise<'active' | 'inactive' | 'error'>;
|
|
65
|
+
/**
|
|
66
|
+
* Process raw data into structured nouns and verbs using neural analysis
|
|
67
|
+
*/
|
|
68
|
+
processRawData(rawData: Buffer | string, dataType: string, options?: Record<string, unknown>): Promise<AugmentationResponse<{
|
|
69
|
+
nouns: string[];
|
|
70
|
+
verbs: string[];
|
|
71
|
+
confidence?: number;
|
|
72
|
+
insights?: Array<{
|
|
73
|
+
type: string;
|
|
74
|
+
description: string;
|
|
75
|
+
confidence: number;
|
|
76
|
+
}>;
|
|
77
|
+
metadata?: Record<string, unknown>;
|
|
78
|
+
}>>;
|
|
79
|
+
/**
|
|
80
|
+
* Listen to real-time data feeds and process them
|
|
81
|
+
*/
|
|
82
|
+
listenToFeed(feedUrl: string, callback: (data: {
|
|
83
|
+
nouns: string[];
|
|
84
|
+
verbs: string[];
|
|
85
|
+
confidence?: number;
|
|
86
|
+
}) => void): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Analyze data structure without processing (preview mode)
|
|
89
|
+
*/
|
|
90
|
+
analyzeStructure(rawData: Buffer | string, dataType: string, options?: Record<string, unknown>): Promise<AugmentationResponse<{
|
|
91
|
+
entityTypes: Array<{
|
|
92
|
+
type: string;
|
|
93
|
+
count: number;
|
|
94
|
+
confidence: number;
|
|
95
|
+
}>;
|
|
96
|
+
relationshipTypes: Array<{
|
|
97
|
+
type: string;
|
|
98
|
+
count: number;
|
|
99
|
+
confidence: number;
|
|
100
|
+
}>;
|
|
101
|
+
dataQuality: {
|
|
102
|
+
completeness: number;
|
|
103
|
+
consistency: number;
|
|
104
|
+
accuracy: number;
|
|
105
|
+
};
|
|
106
|
+
recommendations: string[];
|
|
107
|
+
}>>;
|
|
108
|
+
/**
|
|
109
|
+
* Validate data compatibility with current knowledge base
|
|
110
|
+
*/
|
|
111
|
+
validateCompatibility(rawData: Buffer | string, dataType: string): Promise<AugmentationResponse<{
|
|
112
|
+
compatible: boolean;
|
|
113
|
+
issues: Array<{
|
|
114
|
+
type: string;
|
|
115
|
+
description: string;
|
|
116
|
+
severity: 'low' | 'medium' | 'high';
|
|
117
|
+
}>;
|
|
118
|
+
suggestions: string[];
|
|
119
|
+
}>>;
|
|
120
|
+
/**
|
|
121
|
+
* Get the full neural analysis result (custom method for Cortex integration)
|
|
122
|
+
*/
|
|
123
|
+
getNeuralAnalysis(rawData: Buffer | string, dataType: string): Promise<NeuralAnalysisResult>;
|
|
124
|
+
/**
|
|
125
|
+
* Parse raw data based on type
|
|
126
|
+
*/
|
|
127
|
+
private parseRawData;
|
|
128
|
+
/**
|
|
129
|
+
* Basic CSV parser
|
|
130
|
+
*/
|
|
131
|
+
private parseCSV;
|
|
132
|
+
/**
|
|
133
|
+
* Perform neural analysis on parsed data
|
|
134
|
+
*/
|
|
135
|
+
private performNeuralAnalysis;
|
|
136
|
+
/**
|
|
137
|
+
* Neural Entity Detection - The Core AI Engine
|
|
138
|
+
*/
|
|
139
|
+
private detectEntitiesWithNeuralAnalysis;
|
|
140
|
+
/**
|
|
141
|
+
* Calculate entity type confidence using AI
|
|
142
|
+
*/
|
|
143
|
+
private calculateEntityTypeConfidence;
|
|
144
|
+
/**
|
|
145
|
+
* Field-based confidence calculation
|
|
146
|
+
*/
|
|
147
|
+
private calculateFieldBasedConfidence;
|
|
148
|
+
/**
|
|
149
|
+
* Pattern-based confidence calculation
|
|
150
|
+
*/
|
|
151
|
+
private calculatePatternBasedConfidence;
|
|
152
|
+
/**
|
|
153
|
+
* Generate reasoning for entity type selection
|
|
154
|
+
*/
|
|
155
|
+
private generateEntityReasoning;
|
|
156
|
+
/**
|
|
157
|
+
* Neural Relationship Detection
|
|
158
|
+
*/
|
|
159
|
+
private detectRelationshipsWithNeuralAnalysis;
|
|
160
|
+
/**
|
|
161
|
+
* Calculate relationship confidence
|
|
162
|
+
*/
|
|
163
|
+
private calculateRelationshipConfidence;
|
|
164
|
+
/**
|
|
165
|
+
* Calculate relationship weight/strength
|
|
166
|
+
*/
|
|
167
|
+
private calculateRelationshipWeight;
|
|
168
|
+
/**
|
|
169
|
+
* Generate Neural Insights - The Intelligence Layer
|
|
170
|
+
*/
|
|
171
|
+
private generateNeuralInsights;
|
|
172
|
+
/**
|
|
173
|
+
* Helper methods for the neural system
|
|
174
|
+
*/
|
|
175
|
+
private extractMainText;
|
|
176
|
+
private generateSmartId;
|
|
177
|
+
private extractRelationshipContext;
|
|
178
|
+
private calculateTypeCompatibility;
|
|
179
|
+
private getVerbSpecificity;
|
|
180
|
+
private getRelevantFields;
|
|
181
|
+
private getMatchedPatterns;
|
|
182
|
+
private pruneRelationships;
|
|
183
|
+
private detectHierarchies;
|
|
184
|
+
private detectClusters;
|
|
185
|
+
private detectPatterns;
|
|
186
|
+
private calculateOverallConfidence;
|
|
187
|
+
private storeNeuralAnalysis;
|
|
188
|
+
private getDataTypeFromPath;
|
|
189
|
+
private generateRelationshipReasoning;
|
|
190
|
+
private extractRelationshipMetadata;
|
|
191
|
+
/**
|
|
192
|
+
* Assess data quality metrics
|
|
193
|
+
*/
|
|
194
|
+
private assessDataQuality;
|
|
195
|
+
/**
|
|
196
|
+
* Generate recommendations based on analysis
|
|
197
|
+
*/
|
|
198
|
+
private generateRecommendations;
|
|
199
|
+
}
|