@soulcraft/brainy 0.60.0 → 0.61.1
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 +7 -5
- package/bin/brainy.js +66 -80
- package/dist/augmentations/memoryAugmentations.js +32 -22
- package/dist/brainyData.d.ts +18 -8
- package/dist/brainyData.js +140 -74
- package/dist/coreTypes.d.ts +0 -12
- package/dist/cortex/cortex.js +5 -5
- package/dist/storage/adapters/baseStorageAdapter.d.ts +0 -12
- package/dist/storage/adapters/opfsStorage.js +26 -20
- package/dist/storage/adapters/s3CompatibleStorage.d.ts +0 -12
- package/dist/storage/adapters/s3CompatibleStorage.js +70 -40
- package/dist/storage/baseStorage.d.ts +6 -8
- package/dist/storage/baseStorage.js +12 -20
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
[](https://nodejs.org/)
|
|
8
8
|
[](https://www.typescriptlang.org/)
|
|
9
9
|
|
|
10
|
-
# BRAINY:
|
|
10
|
+
# BRAINY: Multi-Dimensional AI Database™
|
|
11
11
|
|
|
12
|
-
**The world's
|
|
12
|
+
**The world's first Multi-Dimensional AI Database**
|
|
13
|
+
*Vector similarity • Graph relationships • Metadata facets • AI context*
|
|
13
14
|
|
|
14
15
|
*Zero-to-Smart™ technology that thinks so you don't have to*
|
|
15
16
|
|
|
@@ -48,13 +49,13 @@ const results = await brainy.search("AI language models", 5, {
|
|
|
48
49
|
Pinecone ($$$) + Neo4j ($$$) + Elasticsearch ($$$) + Sync Hell = 😱
|
|
49
50
|
```
|
|
50
51
|
|
|
51
|
-
### ✅ The Brainy Way: One
|
|
52
|
+
### ✅ The Brainy Way: One Multi-Dimensional Brain
|
|
52
53
|
|
|
53
54
|
```
|
|
54
|
-
Vector
|
|
55
|
+
Multi-Dimensional AI Database = Vector + Graph + Facets + AI = 🧠✨
|
|
55
56
|
```
|
|
56
57
|
|
|
57
|
-
**Your data gets a brain upgrade. No assembly required.**
|
|
58
|
+
**Your data gets a multi-dimensional brain upgrade. No assembly required.**
|
|
58
59
|
|
|
59
60
|
## ⚡ QUICK & EASY: From Zero to Smart in 60 Seconds
|
|
60
61
|
|
|
@@ -458,6 +459,7 @@ brainy augment trial notion # Start 14-day free trial
|
|
|
458
459
|
|
|
459
460
|
### Advanced Topics
|
|
460
461
|
|
|
462
|
+
- [**🏗️ Storage & Retrieval Architecture**](docs/technical/STORAGE_AND_RETRIEVAL_ARCHITECTURE.md) - Multi-dimensional database internals
|
|
461
463
|
- [**Brainy CLI**](docs/brainy-cli.md) - Command-line superpowers
|
|
462
464
|
- [**Brainy Chat**](BRAINY-CHAT.md) - Conversational AI interface
|
|
463
465
|
- [**Cortex AI**](CORTEX.md) - Intelligence augmentation
|
package/bin/brainy.js
CHANGED
|
@@ -13,6 +13,7 @@ import chalk from 'chalk'
|
|
|
13
13
|
import { readFileSync } from 'fs'
|
|
14
14
|
import { dirname, join } from 'path'
|
|
15
15
|
import { fileURLToPath } from 'url'
|
|
16
|
+
import { createInterface } from 'readline'
|
|
16
17
|
|
|
17
18
|
// Use native fetch (available in Node.js 18+)
|
|
18
19
|
|
|
@@ -57,7 +58,7 @@ const wrapInteractive = (fn) => {
|
|
|
57
58
|
|
|
58
59
|
program
|
|
59
60
|
.name('brainy')
|
|
60
|
-
.description('🧠 Brainy -
|
|
61
|
+
.description('🧠 Brainy - Multi-Dimensional AI Database')
|
|
61
62
|
.version(packageJson.version)
|
|
62
63
|
|
|
63
64
|
// ========================================
|
|
@@ -66,7 +67,7 @@ program
|
|
|
66
67
|
|
|
67
68
|
program
|
|
68
69
|
.command('init')
|
|
69
|
-
.description('
|
|
70
|
+
.description('Initialize Brainy in your project')
|
|
70
71
|
.option('-s, --storage <type>', 'Storage type (filesystem, s3, r2, gcs, memory)')
|
|
71
72
|
.option('-e, --encryption', 'Enable encryption for secrets')
|
|
72
73
|
.action(wrapAction(async (options) => {
|
|
@@ -75,8 +76,8 @@ program
|
|
|
75
76
|
|
|
76
77
|
program
|
|
77
78
|
.command('add [data]')
|
|
78
|
-
.description('
|
|
79
|
-
.option('-m, --metadata <json>', 'Metadata as JSON')
|
|
79
|
+
.description('Add data across multiple dimensions (vector, graph, facets)')
|
|
80
|
+
.option('-m, --metadata <json>', 'Metadata facets as JSON')
|
|
80
81
|
.option('-i, --id <id>', 'Custom ID')
|
|
81
82
|
.action(wrapAction(async (data, options) => {
|
|
82
83
|
let metadata = {}
|
|
@@ -96,11 +97,11 @@ program
|
|
|
96
97
|
|
|
97
98
|
program
|
|
98
99
|
.command('search <query>')
|
|
99
|
-
.description('
|
|
100
|
+
.description('Multi-dimensional search across vector, graph, and facets')
|
|
100
101
|
.option('-l, --limit <number>', 'Number of results', '10')
|
|
101
|
-
.option('-f, --filter <json>', '
|
|
102
|
-
.option('-v, --verbs <types>', '
|
|
103
|
-
.option('-d, --depth <number>', '
|
|
102
|
+
.option('-f, --filter <json>', 'Filter by metadata facets')
|
|
103
|
+
.option('-v, --verbs <types>', 'Include related data (comma-separated)')
|
|
104
|
+
.option('-d, --depth <number>', 'Relationship depth', '1')
|
|
104
105
|
.action(wrapAction(async (query, options) => {
|
|
105
106
|
const searchOptions = { limit: parseInt(options.limit) }
|
|
106
107
|
|
|
@@ -123,7 +124,7 @@ program
|
|
|
123
124
|
|
|
124
125
|
program
|
|
125
126
|
.command('chat [question]')
|
|
126
|
-
.description('
|
|
127
|
+
.description('AI-powered chat with multi-dimensional context')
|
|
127
128
|
.option('-l, --llm <model>', 'LLM model to use')
|
|
128
129
|
.action(wrapInteractive(async (question, options) => {
|
|
129
130
|
await cortex.chat(question)
|
|
@@ -131,7 +132,7 @@ program
|
|
|
131
132
|
|
|
132
133
|
program
|
|
133
134
|
.command('stats')
|
|
134
|
-
.description('
|
|
135
|
+
.description('Show database statistics and insights')
|
|
135
136
|
.option('-d, --detailed', 'Show detailed statistics')
|
|
136
137
|
.action(wrapAction(async (options) => {
|
|
137
138
|
await cortex.stats(options.detailed)
|
|
@@ -139,7 +140,7 @@ program
|
|
|
139
140
|
|
|
140
141
|
program
|
|
141
142
|
.command('health')
|
|
142
|
-
.description('
|
|
143
|
+
.description('Check system health')
|
|
143
144
|
.option('--auto-fix', 'Automatically apply safe repairs')
|
|
144
145
|
.action(wrapAction(async (options) => {
|
|
145
146
|
await cortex.health(options)
|
|
@@ -147,21 +148,21 @@ program
|
|
|
147
148
|
|
|
148
149
|
program
|
|
149
150
|
.command('find')
|
|
150
|
-
.description('
|
|
151
|
+
.description('Advanced intelligent search (interactive)')
|
|
151
152
|
.action(wrapInteractive(async () => {
|
|
152
153
|
await cortex.advancedSearch()
|
|
153
154
|
}))
|
|
154
155
|
|
|
155
156
|
program
|
|
156
157
|
.command('explore [nodeId]')
|
|
157
|
-
.description('
|
|
158
|
+
.description('Explore data relationships interactively')
|
|
158
159
|
.action(wrapInteractive(async (nodeId) => {
|
|
159
160
|
await cortex.explore(nodeId)
|
|
160
161
|
}))
|
|
161
162
|
|
|
162
163
|
program
|
|
163
164
|
.command('backup')
|
|
164
|
-
.description('
|
|
165
|
+
.description('Create database backup')
|
|
165
166
|
.option('-c, --compress', 'Compress backup')
|
|
166
167
|
.option('-o, --output <file>', 'Output file')
|
|
167
168
|
.action(wrapAction(async (options) => {
|
|
@@ -170,7 +171,7 @@ program
|
|
|
170
171
|
|
|
171
172
|
program
|
|
172
173
|
.command('restore <file>')
|
|
173
|
-
.description('
|
|
174
|
+
.description('Restore from backup')
|
|
174
175
|
.action(wrapInteractive(async (file) => {
|
|
175
176
|
await cortex.restore(file)
|
|
176
177
|
}))
|
|
@@ -181,35 +182,30 @@ program
|
|
|
181
182
|
|
|
182
183
|
program
|
|
183
184
|
.command('connect')
|
|
184
|
-
.description('
|
|
185
|
+
.description('Connect to Brain Cloud for AI memory')
|
|
185
186
|
.action(wrapInteractive(async () => {
|
|
186
|
-
console.log(chalk.cyan('\n🧠
|
|
187
|
-
console.log(chalk.gray('━'.repeat(
|
|
187
|
+
console.log(chalk.cyan('\n🧠 Brain Cloud Setup'))
|
|
188
|
+
console.log(chalk.gray('━'.repeat(40)))
|
|
188
189
|
|
|
189
190
|
try {
|
|
190
191
|
// Detect customer ID
|
|
191
192
|
const customerId = await detectCustomerId()
|
|
192
193
|
|
|
193
194
|
if (customerId) {
|
|
194
|
-
console.log(chalk.green(`✅ Found
|
|
195
|
-
console.log('\n🔧
|
|
196
|
-
console.log(chalk.yellow(' • Update
|
|
195
|
+
console.log(chalk.green(`✅ Found Brain Cloud: ${customerId}`))
|
|
196
|
+
console.log('\n🔧 Setting up AI memory:')
|
|
197
|
+
console.log(chalk.yellow(' • Update configuration'))
|
|
197
198
|
console.log(chalk.yellow(' • Add memory instructions'))
|
|
198
199
|
console.log(chalk.yellow(' • Enable cross-session memory'))
|
|
199
200
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (proceed) {
|
|
205
|
-
await setupBrainCloudMemory(customerId)
|
|
206
|
-
console.log(chalk.green('\n🎉 AI Memory Connected!'))
|
|
207
|
-
console.log(chalk.cyan('Restart Claude Code and I\'ll remember everything!'))
|
|
208
|
-
}
|
|
201
|
+
console.log(chalk.cyan('\n🚀 Configuring...'))
|
|
202
|
+
await setupBrainCloudMemory(customerId)
|
|
203
|
+
console.log(chalk.green('\n✅ AI memory connected!'))
|
|
204
|
+
console.log(chalk.cyan('Restart Claude Code to activate memory.'))
|
|
209
205
|
} else {
|
|
210
|
-
console.log(chalk.yellow('
|
|
211
|
-
console.log('\n1. Visit: ' + chalk.cyan('https://
|
|
212
|
-
console.log('2. Sign up for Brain Cloud
|
|
206
|
+
console.log(chalk.yellow('No Brain Cloud found. Setting up:'))
|
|
207
|
+
console.log('\n1. Visit: ' + chalk.cyan('https://soulcraft.com'))
|
|
208
|
+
console.log('2. Sign up for Brain Cloud')
|
|
213
209
|
console.log('3. Run ' + chalk.green('brainy connect') + ' again')
|
|
214
210
|
}
|
|
215
211
|
} catch (error) {
|
|
@@ -219,7 +215,7 @@ program
|
|
|
219
215
|
|
|
220
216
|
program
|
|
221
217
|
.command('cloud [action]')
|
|
222
|
-
.description('
|
|
218
|
+
.description('Manage Brain Cloud connection')
|
|
223
219
|
.option('--connect <id>', 'Connect to existing Brain Cloud instance')
|
|
224
220
|
.option('--export <id>', 'Export all data from Brain Cloud instance')
|
|
225
221
|
.option('--status <id>', 'Check status of Brain Cloud instance')
|
|
@@ -264,11 +260,11 @@ program
|
|
|
264
260
|
} else {
|
|
265
261
|
console.log(chalk.red('❌ Could not connect to Brain Cloud'))
|
|
266
262
|
console.log(chalk.yellow('💡 Make sure you have an active instance'))
|
|
267
|
-
console.log('\nSign up at: ' + chalk.cyan('https://app.
|
|
263
|
+
console.log('\nSign up at: ' + chalk.cyan('https://app.soulcraft.com'))
|
|
268
264
|
}
|
|
269
265
|
} catch (error) {
|
|
270
266
|
console.log(chalk.red('❌ Connection failed:'), error.message)
|
|
271
|
-
console.log('\nSign up at: ' + chalk.cyan('https://app.
|
|
267
|
+
console.log('\nSign up at: ' + chalk.cyan('https://app.soulcraft.com'))
|
|
272
268
|
}
|
|
273
269
|
} else if (options.export) {
|
|
274
270
|
console.log(chalk.green(`📦 Exporting data from Brain Cloud instance: ${options.export}`))
|
|
@@ -326,7 +322,7 @@ program
|
|
|
326
322
|
} else if (options.dashboard) {
|
|
327
323
|
console.log(chalk.green(`🌐 Opening dashboard for Brain Cloud instance: ${options.dashboard}`))
|
|
328
324
|
|
|
329
|
-
const dashboardUrl = `https://app.
|
|
325
|
+
const dashboardUrl = `https://app.soulcraft.com/dashboard.html?customer_id=${options.dashboard}`
|
|
330
326
|
console.log(chalk.cyan(`\n🔗 Dashboard URL: ${dashboardUrl}`))
|
|
331
327
|
console.log(chalk.gray('Opening in your default browser...'))
|
|
332
328
|
|
|
@@ -346,7 +342,7 @@ program
|
|
|
346
342
|
}
|
|
347
343
|
} else {
|
|
348
344
|
console.log(chalk.yellow('📡 Brain Cloud Setup'))
|
|
349
|
-
console.log('\n1. Sign up at: ' + chalk.cyan('https://app.
|
|
345
|
+
console.log('\n1. Sign up at: ' + chalk.cyan('https://app.soulcraft.com'))
|
|
350
346
|
console.log('2. Get your customer ID')
|
|
351
347
|
console.log('3. Connect with: ' + chalk.green('brainy cloud --connect YOUR_ID'))
|
|
352
348
|
console.log('\nBenefits:')
|
|
@@ -363,7 +359,7 @@ program
|
|
|
363
359
|
|
|
364
360
|
program
|
|
365
361
|
.command('install <augmentation>')
|
|
366
|
-
.description('
|
|
362
|
+
.description('Install augmentation')
|
|
367
363
|
.option('-m, --mode <type>', 'Installation mode (free|premium)', 'free')
|
|
368
364
|
.option('-c, --config <json>', 'Configuration as JSON')
|
|
369
365
|
.action(wrapAction(async (augmentation, options) => {
|
|
@@ -386,7 +382,7 @@ program
|
|
|
386
382
|
|
|
387
383
|
program
|
|
388
384
|
.command('run <augmentation>')
|
|
389
|
-
.description('
|
|
385
|
+
.description('Run augmentation')
|
|
390
386
|
.option('-c, --config <json>', 'Runtime configuration as JSON')
|
|
391
387
|
.action(wrapAction(async (augmentation, options) => {
|
|
392
388
|
if (augmentation === 'brain-jar') {
|
|
@@ -400,7 +396,7 @@ program
|
|
|
400
396
|
|
|
401
397
|
program
|
|
402
398
|
.command('status [augmentation]')
|
|
403
|
-
.description('
|
|
399
|
+
.description('Show augmentation status')
|
|
404
400
|
.action(wrapAction(async (augmentation) => {
|
|
405
401
|
if (augmentation === 'brain-jar') {
|
|
406
402
|
await cortex.brainJarStatus()
|
|
@@ -415,7 +411,7 @@ program
|
|
|
415
411
|
|
|
416
412
|
program
|
|
417
413
|
.command('stop [augmentation]')
|
|
418
|
-
.description('
|
|
414
|
+
.description('Stop augmentation')
|
|
419
415
|
.action(wrapAction(async (augmentation) => {
|
|
420
416
|
if (augmentation === 'brain-jar') {
|
|
421
417
|
await cortex.brainJarStop()
|
|
@@ -426,11 +422,11 @@ program
|
|
|
426
422
|
|
|
427
423
|
program
|
|
428
424
|
.command('list')
|
|
429
|
-
.description('
|
|
425
|
+
.description('List installed augmentations')
|
|
430
426
|
.option('-a, --available', 'Show available augmentations')
|
|
431
427
|
.action(wrapAction(async (options) => {
|
|
432
428
|
if (options.available) {
|
|
433
|
-
console.log(chalk.cyan('
|
|
429
|
+
console.log(chalk.cyan('Available Augmentations:'))
|
|
434
430
|
console.log(' • brain-jar - AI coordination and collaboration')
|
|
435
431
|
console.log(' • encryption - Data encryption and security')
|
|
436
432
|
console.log(' • neural-import - AI-powered data analysis')
|
|
@@ -442,30 +438,17 @@ program
|
|
|
442
438
|
}
|
|
443
439
|
}))
|
|
444
440
|
|
|
445
|
-
// ========================================
|
|
446
|
-
// BRAIN CLOUD SUPER COMMAND (New!)
|
|
447
|
-
// ========================================
|
|
448
|
-
|
|
449
|
-
program
|
|
450
|
-
.command('cloud')
|
|
451
|
-
.description('☁️ Setup Brain Cloud - AI coordination across all devices')
|
|
452
|
-
.option('-m, --mode <type>', 'Setup mode (free|premium)', 'interactive')
|
|
453
|
-
.option('-k, --key <key>', 'License key for premium features')
|
|
454
|
-
.option('-s, --skip-install', 'Skip Brain Jar installation')
|
|
455
|
-
.action(wrapInteractive(async (options) => {
|
|
456
|
-
await cortex.setupBrainCloud(options)
|
|
457
|
-
}))
|
|
458
441
|
|
|
459
442
|
// ========================================
|
|
460
443
|
// BRAIN JAR SPECIFIC COMMANDS (Rich UX)
|
|
461
444
|
// ========================================
|
|
462
445
|
|
|
463
446
|
const brainJar = program.command('brain-jar')
|
|
464
|
-
.description('
|
|
447
|
+
.description('AI coordination and collaboration')
|
|
465
448
|
|
|
466
449
|
brainJar
|
|
467
450
|
.command('install')
|
|
468
|
-
.description('
|
|
451
|
+
.description('Install Brain Jar coordination')
|
|
469
452
|
.option('-m, --mode <type>', 'Installation mode (free|premium)', 'free')
|
|
470
453
|
.action(wrapAction(async (options) => {
|
|
471
454
|
await cortex.brainJarInstall(options.mode)
|
|
@@ -473,7 +456,7 @@ brainJar
|
|
|
473
456
|
|
|
474
457
|
brainJar
|
|
475
458
|
.command('start')
|
|
476
|
-
.description('
|
|
459
|
+
.description('Start Brain Jar coordination')
|
|
477
460
|
.option('-s, --server <url>', 'Custom server URL')
|
|
478
461
|
.option('-n, --name <name>', 'Agent name')
|
|
479
462
|
.option('-r, --role <role>', 'Agent role')
|
|
@@ -483,7 +466,7 @@ brainJar
|
|
|
483
466
|
|
|
484
467
|
brainJar
|
|
485
468
|
.command('dashboard')
|
|
486
|
-
.description('
|
|
469
|
+
.description('Open Brain Jar dashboard')
|
|
487
470
|
.option('-o, --open', 'Auto-open in browser', true)
|
|
488
471
|
.action(wrapAction(async (options) => {
|
|
489
472
|
await cortex.brainJarDashboard(options.open)
|
|
@@ -491,28 +474,28 @@ brainJar
|
|
|
491
474
|
|
|
492
475
|
brainJar
|
|
493
476
|
.command('status')
|
|
494
|
-
.description('
|
|
477
|
+
.description('Show Brain Jar status')
|
|
495
478
|
.action(wrapAction(async () => {
|
|
496
479
|
await cortex.brainJarStatus()
|
|
497
480
|
}))
|
|
498
481
|
|
|
499
482
|
brainJar
|
|
500
483
|
.command('agents')
|
|
501
|
-
.description('
|
|
484
|
+
.description('List connected agents')
|
|
502
485
|
.action(wrapAction(async () => {
|
|
503
486
|
await cortex.brainJarAgents()
|
|
504
487
|
}))
|
|
505
488
|
|
|
506
489
|
brainJar
|
|
507
490
|
.command('message <text>')
|
|
508
|
-
.description('
|
|
491
|
+
.description('Send message to coordination channel')
|
|
509
492
|
.action(wrapAction(async (text) => {
|
|
510
493
|
await cortex.brainJarMessage(text)
|
|
511
494
|
}))
|
|
512
495
|
|
|
513
496
|
brainJar
|
|
514
497
|
.command('search <query>')
|
|
515
|
-
.description('
|
|
498
|
+
.description('Search coordination history')
|
|
516
499
|
.option('-l, --limit <number>', 'Number of results', '10')
|
|
517
500
|
.action(wrapAction(async (query, options) => {
|
|
518
501
|
await cortex.brainJarSearch(query, parseInt(options.limit))
|
|
@@ -523,7 +506,7 @@ brainJar
|
|
|
523
506
|
// ========================================
|
|
524
507
|
|
|
525
508
|
const config = program.command('config')
|
|
526
|
-
.description('
|
|
509
|
+
.description('Manage configuration')
|
|
527
510
|
|
|
528
511
|
config
|
|
529
512
|
.command('set <key> <value>')
|
|
@@ -557,11 +540,11 @@ config
|
|
|
557
540
|
// ========================================
|
|
558
541
|
|
|
559
542
|
const cortexCmd = program.command('cortex')
|
|
560
|
-
.description('
|
|
543
|
+
.description('Legacy Cortex commands (deprecated - use direct commands)')
|
|
561
544
|
|
|
562
545
|
cortexCmd
|
|
563
546
|
.command('chat [question]')
|
|
564
|
-
.description('
|
|
547
|
+
.description('Chat with your data')
|
|
565
548
|
.action(wrapInteractive(async (question) => {
|
|
566
549
|
console.log(chalk.yellow('⚠️ Deprecated: Use "brainy chat" instead'))
|
|
567
550
|
await cortex.chat(question)
|
|
@@ -569,7 +552,7 @@ cortexCmd
|
|
|
569
552
|
|
|
570
553
|
cortexCmd
|
|
571
554
|
.command('add [data]')
|
|
572
|
-
.description('
|
|
555
|
+
.description('Add data')
|
|
573
556
|
.action(wrapAction(async (data) => {
|
|
574
557
|
console.log(chalk.yellow('⚠️ Deprecated: Use "brainy add" instead'))
|
|
575
558
|
await cortex.add(data, {})
|
|
@@ -581,7 +564,7 @@ cortexCmd
|
|
|
581
564
|
|
|
582
565
|
program
|
|
583
566
|
.command('shell')
|
|
584
|
-
.description('
|
|
567
|
+
.description('Interactive Brainy shell')
|
|
585
568
|
.action(wrapInteractive(async () => {
|
|
586
569
|
console.log(chalk.cyan('🧠 Brainy Interactive Shell'))
|
|
587
570
|
console.log(chalk.dim('Type "help" for commands, "exit" to quit\n'))
|
|
@@ -596,21 +579,24 @@ program.parse(process.argv)
|
|
|
596
579
|
|
|
597
580
|
// Show help if no command
|
|
598
581
|
if (!process.argv.slice(2).length) {
|
|
599
|
-
console.log(chalk.cyan('
|
|
600
|
-
console.log('')
|
|
601
|
-
|
|
602
|
-
console.log(chalk.green(' brainy cloud # Setup Brain Cloud (recommended!)'))
|
|
603
|
-
console.log('')
|
|
582
|
+
console.log(chalk.cyan('🧠 Brainy - Multi-Dimensional AI Database'))
|
|
583
|
+
console.log(chalk.gray('Vector similarity, graph relationships, metadata facets, and AI context.\n'))
|
|
584
|
+
|
|
604
585
|
console.log(chalk.bold('Quick Start:'))
|
|
605
586
|
console.log(' brainy init # Initialize project')
|
|
606
|
-
console.log(' brainy add "some data" # Add data')
|
|
607
|
-
console.log(' brainy search "query" # Search
|
|
608
|
-
console.log(' brainy chat #
|
|
587
|
+
console.log(' brainy add "some data" # Add multi-dimensional data')
|
|
588
|
+
console.log(' brainy search "query" # Search across all dimensions')
|
|
589
|
+
console.log(' brainy chat # AI chat with full context')
|
|
590
|
+
console.log('')
|
|
591
|
+
console.log(chalk.bold('AI Memory:'))
|
|
592
|
+
console.log(chalk.green(' brainy connect # Connect to Brain Cloud'))
|
|
593
|
+
console.log(' brainy cloud --status <id> # Check cloud status')
|
|
609
594
|
console.log('')
|
|
610
595
|
console.log(chalk.bold('AI Coordination:'))
|
|
611
|
-
console.log(' brainy install brain-jar # Install
|
|
596
|
+
console.log(' brainy install brain-jar # Install coordination')
|
|
612
597
|
console.log(' brainy brain-jar start # Start coordination')
|
|
613
|
-
console.log('
|
|
598
|
+
console.log('')
|
|
599
|
+
console.log(chalk.dim('Learn more: https://soulcraft.com'))
|
|
614
600
|
console.log('')
|
|
615
601
|
program.outputHelp()
|
|
616
602
|
}
|
|
@@ -129,31 +129,41 @@ class BaseMemoryAugmentation {
|
|
|
129
129
|
error: 'Query must be a vector (array of numbers) for vector search'
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
|
-
//
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
//
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
// Get metadata for the node
|
|
142
|
-
const metadata = await this.storage.getMetadata(node.id);
|
|
143
|
-
// Calculate distance between query vector and node vector
|
|
144
|
-
const distance = cosineDistance(queryVector, node.vector);
|
|
145
|
-
// Convert distance to similarity score (1 - distance for cosine)
|
|
146
|
-
// This way higher scores are better (more similar)
|
|
147
|
-
const score = 1 - distance;
|
|
148
|
-
results.push({
|
|
149
|
-
id: node.id,
|
|
150
|
-
score,
|
|
151
|
-
data: metadata
|
|
132
|
+
// Process nodes in batches to avoid loading everything into memory
|
|
133
|
+
const allResults = [];
|
|
134
|
+
let hasMore = true;
|
|
135
|
+
let cursor;
|
|
136
|
+
while (hasMore) {
|
|
137
|
+
// Get a batch of nodes
|
|
138
|
+
const batchResult = await this.storage.getNouns({
|
|
139
|
+
pagination: { limit: 100, cursor }
|
|
152
140
|
});
|
|
141
|
+
// Process this batch
|
|
142
|
+
for (const noun of batchResult.items) {
|
|
143
|
+
// Skip nodes that don't have a vector
|
|
144
|
+
if (!noun.vector || !Array.isArray(noun.vector)) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
// Get metadata for the node
|
|
148
|
+
const metadata = await this.storage.getMetadata(noun.id);
|
|
149
|
+
// Calculate distance between query vector and node vector
|
|
150
|
+
const distance = cosineDistance(queryVector, noun.vector);
|
|
151
|
+
// Convert distance to similarity score (1 - distance for cosine)
|
|
152
|
+
// This way higher scores are better (more similar)
|
|
153
|
+
const score = 1 - distance;
|
|
154
|
+
allResults.push({
|
|
155
|
+
id: noun.id,
|
|
156
|
+
score,
|
|
157
|
+
data: metadata
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
// Update pagination state
|
|
161
|
+
hasMore = batchResult.hasMore;
|
|
162
|
+
cursor = batchResult.nextCursor;
|
|
153
163
|
}
|
|
154
164
|
// Sort results by score (descending) and take top k
|
|
155
|
-
|
|
156
|
-
const topResults =
|
|
165
|
+
allResults.sort((a, b) => b.score - a.score);
|
|
166
|
+
const topResults = allResults.slice(0, k);
|
|
157
167
|
return {
|
|
158
168
|
success: true,
|
|
159
169
|
data: topResults
|
package/dist/brainyData.d.ts
CHANGED
|
@@ -736,11 +736,6 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
|
|
|
736
736
|
* @returns Promise<Array<VectorDocument<T> | null>> Array of documents (null for missing IDs)
|
|
737
737
|
*/
|
|
738
738
|
getBatch(ids: string[]): Promise<Array<VectorDocument<T> | null>>;
|
|
739
|
-
/**
|
|
740
|
-
* Get all nouns in the database
|
|
741
|
-
* @returns Array of vector documents
|
|
742
|
-
*/
|
|
743
|
-
getAllNouns(): Promise<VectorDocument<T>[]>;
|
|
744
739
|
/**
|
|
745
740
|
* Get nouns with pagination and filtering
|
|
746
741
|
* @param options Pagination and filtering options
|
|
@@ -830,10 +825,25 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
|
|
|
830
825
|
*/
|
|
831
826
|
getVerb(id: string): Promise<GraphVerb | null>;
|
|
832
827
|
/**
|
|
833
|
-
*
|
|
834
|
-
* @
|
|
828
|
+
* Internal performance optimization: intelligently load verbs when beneficial
|
|
829
|
+
* @internal - Used by search, indexing, and caching optimizations
|
|
830
|
+
*/
|
|
831
|
+
private _optimizedLoadAllVerbs;
|
|
832
|
+
/**
|
|
833
|
+
* Internal performance optimization: intelligently load nouns when beneficial
|
|
834
|
+
* @internal - Used by search, indexing, and caching optimizations
|
|
835
|
+
*/
|
|
836
|
+
private _optimizedLoadAllNouns;
|
|
837
|
+
/**
|
|
838
|
+
* Intelligent decision making for when to preload all data
|
|
839
|
+
* @internal
|
|
840
|
+
*/
|
|
841
|
+
private _shouldPreloadAllData;
|
|
842
|
+
/**
|
|
843
|
+
* Estimate if dataset size is reasonable for in-memory loading
|
|
844
|
+
* @internal
|
|
835
845
|
*/
|
|
836
|
-
|
|
846
|
+
private _isDatasetSizeReasonable;
|
|
837
847
|
/**
|
|
838
848
|
* Get verbs with pagination and filtering
|
|
839
849
|
* @param options Pagination and filtering options
|