@soulcraft/brainy 0.62.2 → 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/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  [![Node.js](https://img.shields.io/badge/node-%3E%3D24.4.1-brightgreen.svg)](https://nodejs.org/)
10
10
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.4.5-blue.svg)](https://www.typescriptlang.org/)
11
11
 
12
- # 🧠 The World's First Multi-Dimensional AI Database™
12
+ # The World's First Multi-Dimensional AI Database™
13
13
 
14
14
  *Vector similarity • Graph relationships • Metadata facets • Neural understanding*
15
15
 
package/bin/brainy.js CHANGED
@@ -76,9 +76,10 @@ program
76
76
 
77
77
  program
78
78
  .command('add [data]')
79
- .description('Add data across multiple dimensions (vector, graph, facets)')
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
- await cortex.add(data, metadata)
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-powered chat with multi-dimensional context')
128
- .option('-l, --llm <model>', 'LLM model to use')
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 cortex.chat(question)
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
  // ========================================
@@ -537,7 +686,7 @@ augment
537
686
  }
538
687
 
539
688
  console.log(chalk.dim('🚀 Join Early Access: https://soulcraft.com/brain-cloud'))
540
- console.log(chalk.dim('📦 Install: npm install @soulcraft/brain-cloud'))
689
+ console.log(chalk.dim('🌐 Authenticate: brainy cloud auth'))
541
690
  }))
542
691
 
543
692
  augment
@@ -595,7 +744,7 @@ augment
595
744
  tier: 'Premium',
596
745
  popular: true,
597
746
  example: `
598
- import { AIMemory } from '@soulcraft/brain-cloud'
747
+ // AI Memory auto-loads after 'brainy cloud auth' - no imports needed!
599
748
 
600
749
  const cortex = new Cortex()
601
750
  cortex.register(new AIMemory())
@@ -718,7 +867,7 @@ program
718
867
  console.log(' • More at app.soulcraft.com/augmentations')
719
868
  console.log('')
720
869
  console.log(chalk.dim('Sign up: app.soulcraft.com (14-day free trial)'))
721
- console.log(chalk.dim('Install: npm install @soulcraft/brain-cloud'))
870
+ console.log(chalk.dim('Authenticate: brainy cloud auth'))
722
871
  } else {
723
872
  await cortex.listAugmentations()
724
873
  }
@@ -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 full context')
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
@@ -1233,18 +1503,18 @@ async function installBrainCloudPackage() {
1233
1503
  const hasPackageJson = existsSync('package.json')
1234
1504
 
1235
1505
  if (hasPackageJson) {
1236
- await execWithProgress('npm install @soulcraft/brain-cloud')
1506
+ // Auto-configured with 'brainy cloud auth' - no package installation needed!
1237
1507
  console.log('✅ Brain Cloud package installed in current project')
1238
1508
  } else {
1239
1509
  // Install globally for non-project usage
1240
- await execWithProgress('npm install -g @soulcraft/brain-cloud')
1510
+ console.log(' Run \'brainy cloud auth\' to authenticate and auto-configure')
1241
1511
  console.log('✅ Brain Cloud package installed globally')
1242
1512
  }
1243
1513
 
1244
1514
  } catch (error) {
1245
1515
  stopSpinner()
1246
1516
  console.log('⚠️ Could not auto-install Brain Cloud package')
1247
- console.log(' You can install it manually: npm install @soulcraft/brain-cloud')
1517
+ console.log(' Authenticate manually: brainy cloud auth')
1248
1518
  // Don't throw error, this is optional
1249
1519
  }
1250
1520
  }
@@ -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();