@soulcraft/brainy 1.0.0 → 1.1.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 +52 -47
- package/bin/brainy.js +102 -1
- package/dist/augmentationManager.d.ts +87 -0
- package/dist/augmentationManager.js +112 -0
- package/dist/brainyData.d.ts +15 -5
- package/dist/brainyData.js +28 -38
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -59,12 +59,17 @@ await brain.addNoun("John", NounType.Person) // 4. Typed entities
|
|
|
59
59
|
await brain.addVerb(id1, id2, VerbType.Knows) // 5. Relationships
|
|
60
60
|
await brain.update(id, "new data") // 6. Smart updates
|
|
61
61
|
await brain.delete(id) // 7. Soft delete
|
|
62
|
-
brain.
|
|
63
|
-
|
|
62
|
+
await brain.export({ format: 'json' }) // 8. Export data
|
|
63
|
+
brain.augment(myAugmentation) // 9. Extend infinitely! ♾️
|
|
64
|
+
|
|
65
|
+
// NEW: Type-safe augmentation management via brain.augmentations
|
|
66
|
+
brain.augmentations.list() // See all augmentations
|
|
67
|
+
brain.augmentations.enable(name) // Enable/disable dynamically
|
|
64
68
|
```
|
|
65
69
|
|
|
66
70
|
### ✨ **What's New in 1.0:**
|
|
67
71
|
- **🔥 40+ methods consolidated** → 9 unified methods
|
|
72
|
+
- **♾️ The 9th method** - `augment()` lets you extend Brainy infinitely!
|
|
68
73
|
- **🧠 Smart by default** - `add()` auto-detects and processes intelligently
|
|
69
74
|
- **🔐 Universal encryption** - Built-in encryption for sensitive data
|
|
70
75
|
- **🐳 Container ready** - Model preloading for production deployments
|
|
@@ -87,7 +92,7 @@ Every feature you see here works without any payment or registration:
|
|
|
87
92
|
- ✓ Complete API
|
|
88
93
|
- ✓ Forever free
|
|
89
94
|
|
|
90
|
-
> 🌩️ **Brain Cloud** is
|
|
95
|
+
> 🌩️ **Brain Cloud** is our optional cloud service that helps sustain Brainy's development. Currently in early access at [soulcraft.com](https://soulcraft.com).
|
|
91
96
|
|
|
92
97
|
---
|
|
93
98
|
|
|
@@ -117,7 +122,9 @@ supabase.insert(), mongodb.find(), redis.set()
|
|
|
117
122
|
// After: 9 methods handle EVERYTHING
|
|
118
123
|
brain.add(), brain.search(), brain.import()
|
|
119
124
|
brain.addNoun(), brain.addVerb(), brain.update()
|
|
120
|
-
brain.delete(), brain.
|
|
125
|
+
brain.delete(), brain.export(), brain.augment()
|
|
126
|
+
|
|
127
|
+
// Why 9? The 9th method (augment) gives you methods 10 → ∞!
|
|
121
128
|
```
|
|
122
129
|
|
|
123
130
|
#### **🤯 Mind-Blowing Features Out of the Box**
|
|
@@ -300,12 +307,12 @@ const brain = new BrainyData()
|
|
|
300
307
|
await brain.init()
|
|
301
308
|
|
|
302
309
|
// Add any data - text, objects, relationships
|
|
303
|
-
await brain.add("
|
|
304
|
-
await brain.add({ company: "
|
|
305
|
-
await brain.addVerb("
|
|
310
|
+
await brain.add("Satya Nadella became CEO of Microsoft in 2014")
|
|
311
|
+
await brain.add({ company: "Anthropic", ceo: "Dario Amodei", founded: 2021 })
|
|
312
|
+
await brain.addVerb("Sundar Pichai", "leads", "Google")
|
|
306
313
|
|
|
307
314
|
// Search naturally
|
|
308
|
-
const results = await brain.search("companies
|
|
315
|
+
const results = await brain.search("tech companies and their leaders")
|
|
309
316
|
```
|
|
310
317
|
|
|
311
318
|
### ☁️ Brain Cloud (AI Memory + Agent Coordination)
|
|
@@ -332,11 +339,11 @@ brain.register(new AgentCoordinator())
|
|
|
332
339
|
// Now your AI remembers everything across all sessions!
|
|
333
340
|
await brain.add("User prefers TypeScript over JavaScript")
|
|
334
341
|
// This memory persists and syncs across all devices
|
|
335
|
-
// Returns:
|
|
342
|
+
// Returns: Microsoft and Anthropic with relevance scores
|
|
336
343
|
|
|
337
344
|
// Query relationships
|
|
338
|
-
const companies = await brain.getRelated("
|
|
339
|
-
// Returns:
|
|
345
|
+
const companies = await brain.getRelated("Sundar Pichai", { verb: "leads" })
|
|
346
|
+
// Returns: Google, Alphabet
|
|
340
347
|
|
|
341
348
|
// Filter with metadata
|
|
342
349
|
const recent = await brain.search("companies", 10, {
|
|
@@ -389,53 +396,51 @@ await neural.neuralImport('data.csv') // Automatically extracts entities & rela
|
|
|
389
396
|
**Be the First!** Create an augmentation and we'll feature it here.
|
|
390
397
|
[See how to build augmentations →](UNIFIED-API.md#creating-your-own-augmentation)
|
|
391
398
|
|
|
392
|
-
### ☁️ **Brain Cloud** -
|
|
393
|
-
**Try it FREE:** Get persistent memory, team sync, and enterprise connectors!
|
|
399
|
+
### ☁️ **Brain Cloud** - Optional Cloud Services (Early Access) 🎆
|
|
394
400
|
|
|
395
|
-
|
|
396
|
-
# Coming Soon! Brain Cloud is in development
|
|
397
|
-
# Join the waitlist:
|
|
398
|
-
# Visit: soulcraft.com
|
|
399
|
-
```
|
|
401
|
+
**Currently in Early Access** - Join at [soulcraft.com](https://soulcraft.com)
|
|
400
402
|
|
|
401
|
-
**
|
|
402
|
-
- 🧠 **AI Memory That Never Forgets** - Conversations persist across sessions
|
|
403
|
-
- 🤝 **Multi-Agent Coordination** - AI agents work together seamlessly
|
|
404
|
-
- 💾 **Automatic Backups** - Never lose your brain's knowledge
|
|
405
|
-
- 🔄 **Team Sync** - Share knowledge across your organization
|
|
406
|
-
- 🔌 **Premium Connectors** - Notion, Slack, Salesforce, and more!
|
|
403
|
+
**Available Tiers:**
|
|
407
404
|
|
|
408
|
-
|
|
405
|
+
#### 🆓 **Free Forever** - Local Database
|
|
406
|
+
- ✓ Full multi-dimensional database
|
|
407
|
+
- ✓ Works offline
|
|
408
|
+
- ✓ No API keys required
|
|
409
|
+
- ✓ Your data stays private
|
|
409
410
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
411
|
+
#### ☁️ **Cloud Sync** - $19/month
|
|
412
|
+
- ✓ Everything in Free tier
|
|
413
|
+
- ✓ Team collaboration
|
|
414
|
+
- ✓ Cross-device synchronization
|
|
415
|
+
- ✓ Automatic backups
|
|
416
|
+
- ✓ Real-time sync
|
|
417
|
+
|
|
418
|
+
#### 🏢 **Enterprise** - $99/month
|
|
419
|
+
- ✓ Everything in Cloud Sync
|
|
420
|
+
- ✓ Dedicated infrastructure
|
|
421
|
+
- ✓ Service Level Agreement (SLA)
|
|
422
|
+
- ✓ Priority support
|
|
423
|
+
- ✓ Custom integrations
|
|
414
424
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
425
|
+
```javascript
|
|
426
|
+
// Brain Cloud integration (when available):
|
|
427
|
+
const brain = new BrainyData({
|
|
428
|
+
cloud: {
|
|
429
|
+
enabled: true, // Enable cloud sync
|
|
430
|
+
apiKey: process.env.BRAIN_CLOUD_KEY // Optional for premium features
|
|
431
|
+
}
|
|
418
432
|
})
|
|
419
433
|
|
|
420
|
-
|
|
434
|
+
// Works perfectly without cloud too:
|
|
435
|
+
const brain = new BrainyData()
|
|
436
|
+
await brain.init()
|
|
437
|
+
// Full database functionality, locally!
|
|
421
438
|
```
|
|
422
439
|
|
|
423
|
-
**AI Memory & Coordination:**
|
|
424
|
-
- 🧠 **AI Memory** - Persistent across sessions
|
|
425
|
-
- 🤝 **Agent Coordinator** - Multi-agent handoffs
|
|
426
|
-
- 👥 **Team Sync** - Real-time collaboration
|
|
427
|
-
- 💾 **Cloud Backup** - Automatic backups
|
|
428
|
-
|
|
429
|
-
**Enterprise Connectors:**
|
|
430
|
-
- 📝 **Notion Sync** - Bidirectional sync
|
|
431
|
-
- 💼 **Salesforce** - CRM integration
|
|
432
|
-
- 📊 **Airtable** - Database sync
|
|
433
|
-
- 🔄 **Postgres** - Real-time replication
|
|
434
|
-
- 🏢 **Slack** - Team knowledge base
|
|
435
440
|
|
|
441
|
+
### 🌐 **Why Brain Cloud?**
|
|
436
442
|
|
|
437
|
-
|
|
438
|
-
For teams that want zero-ops:
|
|
443
|
+
Brain Cloud adds optional cloud services to sustain Brainy's development:
|
|
439
444
|
|
|
440
445
|
```javascript
|
|
441
446
|
// Connect to Brain Cloud - your brain in the cloud
|
package/bin/brainy.js
CHANGED
|
@@ -669,7 +669,108 @@ program
|
|
|
669
669
|
}
|
|
670
670
|
}))
|
|
671
671
|
|
|
672
|
-
// Command
|
|
672
|
+
// Command 6A: ADD-NOUN - Create typed entities (Method #4)
|
|
673
|
+
program
|
|
674
|
+
.command('add-noun <name>')
|
|
675
|
+
.description('Add a typed entity to your knowledge graph')
|
|
676
|
+
.option('-t, --type <type>', 'Noun type (Person, Organization, Project, Event, Concept, Location, Product)', 'Concept')
|
|
677
|
+
.option('-m, --metadata <json>', 'Metadata as JSON')
|
|
678
|
+
.option('--encrypt', 'Encrypt this entity')
|
|
679
|
+
.action(wrapAction(async (name, options) => {
|
|
680
|
+
const brainy = await getBrainy()
|
|
681
|
+
|
|
682
|
+
// Validate noun type
|
|
683
|
+
const validTypes = ['Person', 'Organization', 'Project', 'Event', 'Concept', 'Location', 'Product']
|
|
684
|
+
if (!validTypes.includes(options.type)) {
|
|
685
|
+
console.log(colors.error(`❌ Invalid noun type: ${options.type}`))
|
|
686
|
+
console.log(colors.info(`Valid types: ${validTypes.join(', ')}`))
|
|
687
|
+
process.exit(1)
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
let metadata = {}
|
|
691
|
+
if (options.metadata) {
|
|
692
|
+
try {
|
|
693
|
+
metadata = JSON.parse(options.metadata)
|
|
694
|
+
} catch {
|
|
695
|
+
console.error(colors.error('❌ Invalid JSON metadata'))
|
|
696
|
+
process.exit(1)
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
if (options.encrypt) {
|
|
701
|
+
metadata.encrypted = true
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
try {
|
|
705
|
+
const { NounType } = await import('../dist/types/graphTypes.js')
|
|
706
|
+
const id = await brainy.addNoun(name, NounType[options.type], metadata)
|
|
707
|
+
|
|
708
|
+
console.log(colors.success('✅ Noun added successfully!'))
|
|
709
|
+
console.log(colors.info(`🆔 ID: ${id}`))
|
|
710
|
+
console.log(colors.info(`👤 Name: ${name}`))
|
|
711
|
+
console.log(colors.info(`🏷️ Type: ${options.type}`))
|
|
712
|
+
if (Object.keys(metadata).length > 0) {
|
|
713
|
+
console.log(colors.info(`📝 Metadata: ${JSON.stringify(metadata, null, 2)}`))
|
|
714
|
+
}
|
|
715
|
+
} catch (error) {
|
|
716
|
+
console.log(colors.error('❌ Failed to add noun:'))
|
|
717
|
+
console.log(colors.error(error.message))
|
|
718
|
+
process.exit(1)
|
|
719
|
+
}
|
|
720
|
+
}))
|
|
721
|
+
|
|
722
|
+
// Command 6B: ADD-VERB - Create relationships (Method #5)
|
|
723
|
+
program
|
|
724
|
+
.command('add-verb <source> <target>')
|
|
725
|
+
.description('Create a relationship between two entities')
|
|
726
|
+
.option('-t, --type <type>', 'Verb type (WorksFor, Knows, CreatedBy, BelongsTo, Uses, etc.)', 'RelatedTo')
|
|
727
|
+
.option('-m, --metadata <json>', 'Relationship metadata as JSON')
|
|
728
|
+
.option('--encrypt', 'Encrypt this relationship')
|
|
729
|
+
.action(wrapAction(async (source, target, options) => {
|
|
730
|
+
const brainy = await getBrainy()
|
|
731
|
+
|
|
732
|
+
// Common verb types for validation
|
|
733
|
+
const commonTypes = ['WorksFor', 'Knows', 'CreatedBy', 'BelongsTo', 'Uses', 'LeadsProject', 'MemberOf', 'RelatedTo', 'InteractedWith']
|
|
734
|
+
if (!commonTypes.includes(options.type)) {
|
|
735
|
+
console.log(colors.warning(`⚠️ Uncommon verb type: ${options.type}`))
|
|
736
|
+
console.log(colors.info(`Common types: ${commonTypes.join(', ')}`))
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
let metadata = {}
|
|
740
|
+
if (options.metadata) {
|
|
741
|
+
try {
|
|
742
|
+
metadata = JSON.parse(options.metadata)
|
|
743
|
+
} catch {
|
|
744
|
+
console.error(colors.error('❌ Invalid JSON metadata'))
|
|
745
|
+
process.exit(1)
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
if (options.encrypt) {
|
|
750
|
+
metadata.encrypted = true
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
try {
|
|
754
|
+
const { VerbType } = await import('../dist/types/graphTypes.js')
|
|
755
|
+
|
|
756
|
+
// Use the provided type or fall back to RelatedTo
|
|
757
|
+
const verbType = VerbType[options.type] || options.type
|
|
758
|
+
const id = await brainy.addVerb(source, target, verbType, metadata)
|
|
759
|
+
|
|
760
|
+
console.log(colors.success('✅ Relationship added successfully!'))
|
|
761
|
+
console.log(colors.info(`🆔 ID: ${id}`))
|
|
762
|
+
console.log(colors.info(`🔗 ${source} --[${options.type}]--> ${target}`))
|
|
763
|
+
if (Object.keys(metadata).length > 0) {
|
|
764
|
+
console.log(colors.info(`📝 Metadata: ${JSON.stringify(metadata, null, 2)}`))
|
|
765
|
+
}
|
|
766
|
+
} catch (error) {
|
|
767
|
+
console.log(colors.error('❌ Failed to add relationship:'))
|
|
768
|
+
console.log(colors.error(error.message))
|
|
769
|
+
process.exit(1)
|
|
770
|
+
}
|
|
771
|
+
}))
|
|
772
|
+
|
|
773
|
+
// Command 7: STATUS - Database health & info
|
|
673
774
|
program
|
|
674
775
|
.command('status')
|
|
675
776
|
.description('Show brain status and comprehensive statistics')
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-safe augmentation management system for Brainy
|
|
3
|
+
* Provides a clean API for managing augmentations without string literals
|
|
4
|
+
*/
|
|
5
|
+
import { IAugmentation, AugmentationType } from './types/augmentations.js';
|
|
6
|
+
export interface AugmentationInfo {
|
|
7
|
+
name: string;
|
|
8
|
+
type: string;
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
description: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Type-safe augmentation manager
|
|
14
|
+
* Accessed via brain.augmentations for all management operations
|
|
15
|
+
*/
|
|
16
|
+
export declare class AugmentationManager {
|
|
17
|
+
private pipeline;
|
|
18
|
+
/**
|
|
19
|
+
* List all registered augmentations with their status
|
|
20
|
+
* @returns Array of augmentation information
|
|
21
|
+
*/
|
|
22
|
+
list(): AugmentationInfo[];
|
|
23
|
+
/**
|
|
24
|
+
* Get information about a specific augmentation
|
|
25
|
+
* @param name The augmentation name
|
|
26
|
+
* @returns Augmentation info or undefined if not found
|
|
27
|
+
*/
|
|
28
|
+
get(name: string): AugmentationInfo | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Check if an augmentation is enabled
|
|
31
|
+
* @param name The augmentation name
|
|
32
|
+
* @returns True if enabled, false otherwise
|
|
33
|
+
*/
|
|
34
|
+
isEnabled(name: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Enable a specific augmentation
|
|
37
|
+
* @param name The augmentation name
|
|
38
|
+
* @returns True if successfully enabled
|
|
39
|
+
*/
|
|
40
|
+
enable(name: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Disable a specific augmentation
|
|
43
|
+
* @param name The augmentation name
|
|
44
|
+
* @returns True if successfully disabled
|
|
45
|
+
*/
|
|
46
|
+
disable(name: string): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Remove an augmentation from the pipeline
|
|
49
|
+
* @param name The augmentation name
|
|
50
|
+
* @returns True if successfully removed
|
|
51
|
+
*/
|
|
52
|
+
remove(name: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Enable all augmentations of a specific type
|
|
55
|
+
* @param type The augmentation type
|
|
56
|
+
* @returns Number of augmentations enabled
|
|
57
|
+
*/
|
|
58
|
+
enableType(type: AugmentationType): number;
|
|
59
|
+
/**
|
|
60
|
+
* Disable all augmentations of a specific type
|
|
61
|
+
* @param type The augmentation type
|
|
62
|
+
* @returns Number of augmentations disabled
|
|
63
|
+
*/
|
|
64
|
+
disableType(type: AugmentationType): number;
|
|
65
|
+
/**
|
|
66
|
+
* Get all augmentations of a specific type
|
|
67
|
+
* @param type The augmentation type
|
|
68
|
+
* @returns Array of augmentations of that type
|
|
69
|
+
*/
|
|
70
|
+
listByType(type: AugmentationType): AugmentationInfo[];
|
|
71
|
+
/**
|
|
72
|
+
* Get all enabled augmentations
|
|
73
|
+
* @returns Array of enabled augmentations
|
|
74
|
+
*/
|
|
75
|
+
listEnabled(): AugmentationInfo[];
|
|
76
|
+
/**
|
|
77
|
+
* Get all disabled augmentations
|
|
78
|
+
* @returns Array of disabled augmentations
|
|
79
|
+
*/
|
|
80
|
+
listDisabled(): AugmentationInfo[];
|
|
81
|
+
/**
|
|
82
|
+
* Register a new augmentation (internal use)
|
|
83
|
+
* @param augmentation The augmentation to register
|
|
84
|
+
*/
|
|
85
|
+
register(augmentation: IAugmentation): void;
|
|
86
|
+
}
|
|
87
|
+
export { AugmentationType } from './types/augmentations.js';
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-safe augmentation management system for Brainy
|
|
3
|
+
* Provides a clean API for managing augmentations without string literals
|
|
4
|
+
*/
|
|
5
|
+
import { augmentationPipeline } from './augmentationPipeline.js';
|
|
6
|
+
/**
|
|
7
|
+
* Type-safe augmentation manager
|
|
8
|
+
* Accessed via brain.augmentations for all management operations
|
|
9
|
+
*/
|
|
10
|
+
export class AugmentationManager {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.pipeline = augmentationPipeline;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* List all registered augmentations with their status
|
|
16
|
+
* @returns Array of augmentation information
|
|
17
|
+
*/
|
|
18
|
+
list() {
|
|
19
|
+
return this.pipeline.listAugmentationsWithStatus();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get information about a specific augmentation
|
|
23
|
+
* @param name The augmentation name
|
|
24
|
+
* @returns Augmentation info or undefined if not found
|
|
25
|
+
*/
|
|
26
|
+
get(name) {
|
|
27
|
+
const all = this.list();
|
|
28
|
+
return all.find(a => a.name === name);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check if an augmentation is enabled
|
|
32
|
+
* @param name The augmentation name
|
|
33
|
+
* @returns True if enabled, false otherwise
|
|
34
|
+
*/
|
|
35
|
+
isEnabled(name) {
|
|
36
|
+
const aug = this.get(name);
|
|
37
|
+
return aug?.enabled ?? false;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Enable a specific augmentation
|
|
41
|
+
* @param name The augmentation name
|
|
42
|
+
* @returns True if successfully enabled
|
|
43
|
+
*/
|
|
44
|
+
enable(name) {
|
|
45
|
+
return this.pipeline.enableAugmentation(name);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Disable a specific augmentation
|
|
49
|
+
* @param name The augmentation name
|
|
50
|
+
* @returns True if successfully disabled
|
|
51
|
+
*/
|
|
52
|
+
disable(name) {
|
|
53
|
+
return this.pipeline.disableAugmentation(name);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Remove an augmentation from the pipeline
|
|
57
|
+
* @param name The augmentation name
|
|
58
|
+
* @returns True if successfully removed
|
|
59
|
+
*/
|
|
60
|
+
remove(name) {
|
|
61
|
+
this.pipeline.unregister(name);
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Enable all augmentations of a specific type
|
|
66
|
+
* @param type The augmentation type
|
|
67
|
+
* @returns Number of augmentations enabled
|
|
68
|
+
*/
|
|
69
|
+
enableType(type) {
|
|
70
|
+
return this.pipeline.enableAugmentationType(type);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Disable all augmentations of a specific type
|
|
74
|
+
* @param type The augmentation type
|
|
75
|
+
* @returns Number of augmentations disabled
|
|
76
|
+
*/
|
|
77
|
+
disableType(type) {
|
|
78
|
+
return this.pipeline.disableAugmentationType(type);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get all augmentations of a specific type
|
|
82
|
+
* @param type The augmentation type
|
|
83
|
+
* @returns Array of augmentations of that type
|
|
84
|
+
*/
|
|
85
|
+
listByType(type) {
|
|
86
|
+
return this.list().filter(a => a.type === type);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get all enabled augmentations
|
|
90
|
+
* @returns Array of enabled augmentations
|
|
91
|
+
*/
|
|
92
|
+
listEnabled() {
|
|
93
|
+
return this.list().filter(a => a.enabled);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get all disabled augmentations
|
|
97
|
+
* @returns Array of disabled augmentations
|
|
98
|
+
*/
|
|
99
|
+
listDisabled() {
|
|
100
|
+
return this.list().filter(a => !a.enabled);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Register a new augmentation (internal use)
|
|
104
|
+
* @param augmentation The augmentation to register
|
|
105
|
+
*/
|
|
106
|
+
register(augmentation) {
|
|
107
|
+
this.pipeline.register(augmentation);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Export types for external use
|
|
111
|
+
export { AugmentationType } from './types/augmentations.js';
|
|
112
|
+
//# sourceMappingURL=augmentationManager.js.map
|
package/dist/brainyData.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { WebSocketConnection, IAugmentation } from './types/augmentations.js';
|
|
|
11
11
|
import { BrainyDataInterface } from './types/brainyDataInterface.js';
|
|
12
12
|
import { DistributedConfig } from './types/distributedTypes.js';
|
|
13
13
|
import { SearchCacheConfig } from './utils/searchCache.js';
|
|
14
|
+
import { AugmentationManager } from './augmentationManager.js';
|
|
14
15
|
export interface BrainyDataConfig {
|
|
15
16
|
/**
|
|
16
17
|
* HNSW index configuration
|
|
@@ -369,6 +370,11 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
|
|
|
369
370
|
private loggingConfig;
|
|
370
371
|
private defaultService;
|
|
371
372
|
private searchCache;
|
|
373
|
+
/**
|
|
374
|
+
* Type-safe augmentation management
|
|
375
|
+
* Access all augmentation operations through this property
|
|
376
|
+
*/
|
|
377
|
+
readonly augmentations: AugmentationManager;
|
|
372
378
|
private cacheAutoConfigurator;
|
|
373
379
|
private timeoutConfig;
|
|
374
380
|
private retryConfig;
|
|
@@ -1475,12 +1481,16 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
|
|
|
1475
1481
|
*/
|
|
1476
1482
|
rebuildMetadataIndex(): Promise<void>;
|
|
1477
1483
|
/**
|
|
1478
|
-
* UNIFIED API METHOD #
|
|
1479
|
-
*
|
|
1484
|
+
* UNIFIED API METHOD #9: Augment - Register new augmentations
|
|
1485
|
+
*
|
|
1486
|
+
* For registration: brain.augment(new MyAugmentation())
|
|
1487
|
+
* For management: Use brain.augmentations.enable(), .disable(), .list() etc.
|
|
1488
|
+
*
|
|
1489
|
+
* @param action The augmentation to register OR legacy string command
|
|
1490
|
+
* @param options Legacy options for string commands (deprecated)
|
|
1491
|
+
* @returns this for chaining when registering, various for legacy commands
|
|
1480
1492
|
*
|
|
1481
|
-
* @
|
|
1482
|
-
* @param options Additional options for the action
|
|
1483
|
-
* @returns Various return types based on action
|
|
1493
|
+
* @deprecated String-based commands are deprecated. Use brain.augmentations.* instead
|
|
1484
1494
|
*/
|
|
1485
1495
|
augment(action: IAugmentation | 'list' | 'enable' | 'disable' | 'unregister' | 'enable-type' | 'disable-type', options?: string | {
|
|
1486
1496
|
name?: string;
|
package/dist/brainyData.js
CHANGED
|
@@ -21,6 +21,7 @@ import { DistributedConfigManager, HashPartitioner, OperationalModeFactory, Doma
|
|
|
21
21
|
import { SearchCache } from './utils/searchCache.js';
|
|
22
22
|
import { CacheAutoConfigurator } from './utils/cacheAutoConfig.js';
|
|
23
23
|
import { StatisticsCollector } from './utils/statisticsCollector.js';
|
|
24
|
+
import { AugmentationManager } from './augmentationManager.js';
|
|
24
25
|
export class BrainyData {
|
|
25
26
|
/**
|
|
26
27
|
* Get the vector dimensions
|
|
@@ -204,6 +205,8 @@ export class BrainyData {
|
|
|
204
205
|
}
|
|
205
206
|
// Initialize search cache with final configuration
|
|
206
207
|
this.searchCache = new SearchCache(finalSearchCacheConfig);
|
|
208
|
+
// Initialize augmentation manager
|
|
209
|
+
this.augmentations = new AugmentationManager();
|
|
207
210
|
// Initialize intelligent verb scoring if enabled
|
|
208
211
|
if (config.intelligentVerbScoring?.enabled) {
|
|
209
212
|
this.intelligentVerbScoring = new IntelligentVerbScoring(config.intelligentVerbScoring);
|
|
@@ -5345,79 +5348,66 @@ export class BrainyData {
|
|
|
5345
5348
|
}
|
|
5346
5349
|
// ===== Augmentation Control Methods =====
|
|
5347
5350
|
/**
|
|
5348
|
-
* UNIFIED API METHOD #
|
|
5349
|
-
* Register, enable, disable, list, and manage augmentations
|
|
5351
|
+
* UNIFIED API METHOD #9: Augment - Register new augmentations
|
|
5350
5352
|
*
|
|
5351
|
-
*
|
|
5352
|
-
*
|
|
5353
|
-
*
|
|
5353
|
+
* For registration: brain.augment(new MyAugmentation())
|
|
5354
|
+
* For management: Use brain.augmentations.enable(), .disable(), .list() etc.
|
|
5355
|
+
*
|
|
5356
|
+
* @param action The augmentation to register OR legacy string command
|
|
5357
|
+
* @param options Legacy options for string commands (deprecated)
|
|
5358
|
+
* @returns this for chaining when registering, various for legacy commands
|
|
5359
|
+
*
|
|
5360
|
+
* @deprecated String-based commands are deprecated. Use brain.augmentations.* instead
|
|
5354
5361
|
*/
|
|
5355
5362
|
augment(action, options) {
|
|
5356
|
-
//
|
|
5357
|
-
if (typeof action === 'object' && 'name' in action
|
|
5358
|
-
|
|
5363
|
+
// PRIMARY USE: Register new augmentation
|
|
5364
|
+
if (typeof action === 'object' && 'name' in action) {
|
|
5365
|
+
this.augmentations.register(action);
|
|
5359
5366
|
return this;
|
|
5360
5367
|
}
|
|
5361
|
-
// Handle string actions
|
|
5368
|
+
// LEGACY: Handle string actions (deprecated - use brain.augmentations instead)
|
|
5369
|
+
console.warn(`Deprecated: brain.augment('${action}') - Use brain.augmentations.${action}() instead`);
|
|
5362
5370
|
switch (action) {
|
|
5363
5371
|
case 'list':
|
|
5364
|
-
|
|
5365
|
-
return this.listAugmentations();
|
|
5372
|
+
return this.augmentations.list();
|
|
5366
5373
|
case 'enable':
|
|
5367
|
-
// Enable specific augmentation by name
|
|
5368
5374
|
if (typeof options === 'string') {
|
|
5369
|
-
this.
|
|
5375
|
+
this.augmentations.enable(options);
|
|
5370
5376
|
}
|
|
5371
5377
|
else if (options?.name) {
|
|
5372
|
-
this.
|
|
5378
|
+
this.augmentations.enable(options.name);
|
|
5373
5379
|
}
|
|
5374
5380
|
return this;
|
|
5375
5381
|
case 'disable':
|
|
5376
|
-
// Disable specific augmentation by name
|
|
5377
5382
|
if (typeof options === 'string') {
|
|
5378
|
-
this.
|
|
5383
|
+
this.augmentations.disable(options);
|
|
5379
5384
|
}
|
|
5380
5385
|
else if (options?.name) {
|
|
5381
|
-
this.
|
|
5386
|
+
this.augmentations.disable(options.name);
|
|
5382
5387
|
}
|
|
5383
5388
|
return this;
|
|
5384
5389
|
case 'unregister':
|
|
5385
|
-
// Remove augmentation from pipeline
|
|
5386
5390
|
if (typeof options === 'string') {
|
|
5387
|
-
this.
|
|
5391
|
+
this.augmentations.remove(options);
|
|
5388
5392
|
}
|
|
5389
5393
|
else if (options?.name) {
|
|
5390
|
-
this.
|
|
5394
|
+
this.augmentations.remove(options.name);
|
|
5391
5395
|
}
|
|
5392
5396
|
return this;
|
|
5393
5397
|
case 'enable-type':
|
|
5394
|
-
// Enable all augmentations of a type
|
|
5395
5398
|
if (typeof options === 'string') {
|
|
5396
|
-
|
|
5397
|
-
if (validTypes.includes(options)) {
|
|
5398
|
-
return this.enableAugmentationType(options);
|
|
5399
|
-
}
|
|
5399
|
+
return this.augmentations.enableType(options);
|
|
5400
5400
|
}
|
|
5401
5401
|
else if (options?.type) {
|
|
5402
|
-
|
|
5403
|
-
if (validTypes.includes(options.type)) {
|
|
5404
|
-
return this.enableAugmentationType(options.type);
|
|
5405
|
-
}
|
|
5402
|
+
return this.augmentations.enableType(options.type);
|
|
5406
5403
|
}
|
|
5407
5404
|
throw new Error('Invalid augmentation type');
|
|
5408
5405
|
case 'disable-type':
|
|
5409
|
-
// Disable all augmentations of a type
|
|
5410
5406
|
if (typeof options === 'string') {
|
|
5411
|
-
|
|
5412
|
-
if (validTypes.includes(options)) {
|
|
5413
|
-
return this.disableAugmentationType(options);
|
|
5414
|
-
}
|
|
5407
|
+
return this.augmentations.disableType(options);
|
|
5415
5408
|
}
|
|
5416
5409
|
else if (options?.type) {
|
|
5417
|
-
|
|
5418
|
-
if (validTypes.includes(options.type)) {
|
|
5419
|
-
return this.disableAugmentationType(options.type);
|
|
5420
|
-
}
|
|
5410
|
+
return this.augmentations.disableType(options.type);
|
|
5421
5411
|
}
|
|
5422
5412
|
throw new Error('Invalid augmentation type');
|
|
5423
5413
|
default:
|
package/dist/index.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ export { HNSWIndex, HNSWIndexOptimized };
|
|
|
50
50
|
export type { Vector, VectorDocument, SearchResult, DistanceFunction, EmbeddingFunction, EmbeddingModel, HNSWNoun, HNSWVerb, HNSWConfig, HNSWOptimizedConfig, StorageAdapter };
|
|
51
51
|
import type { IAugmentation, AugmentationResponse, IWebSocketSupport, ISenseAugmentation, IConduitAugmentation, ICognitionAugmentation, IMemoryAugmentation, IPerceptionAugmentation, IDialogAugmentation, IActivationAugmentation } from './types/augmentations.js';
|
|
52
52
|
import { AugmentationType, BrainyAugmentations } from './types/augmentations.js';
|
|
53
|
+
export { AugmentationManager, type AugmentationInfo } from './augmentationManager.js';
|
|
53
54
|
export type { IAugmentation, AugmentationResponse, IWebSocketSupport };
|
|
54
55
|
export { AugmentationType, BrainyAugmentations, ISenseAugmentation, IConduitAugmentation, ICognitionAugmentation, IMemoryAugmentation, IPerceptionAugmentation, IDialogAugmentation, IActivationAugmentation };
|
|
55
56
|
export type { IWebSocketCognitionAugmentation, IWebSocketSenseAugmentation, IWebSocketPerceptionAugmentation, IWebSocketActivationAugmentation, IWebSocketDialogAugmentation, IWebSocketConduitAugmentation, IWebSocketMemoryAugmentation } from './types/augmentations.js';
|
package/dist/index.js
CHANGED
|
@@ -79,6 +79,8 @@ import { HNSWIndex } from './hnsw/hnswIndex.js';
|
|
|
79
79
|
import { HNSWIndexOptimized } from './hnsw/hnswIndexOptimized.js';
|
|
80
80
|
export { HNSWIndex, HNSWIndexOptimized };
|
|
81
81
|
import { AugmentationType } from './types/augmentations.js';
|
|
82
|
+
// Export augmentation manager for type-safe augmentation management
|
|
83
|
+
export { AugmentationManager } from './augmentationManager.js';
|
|
82
84
|
export { AugmentationType };
|
|
83
85
|
import { NounType, VerbType } from './types/graphTypes.js';
|
|
84
86
|
// Export type utility functions
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Multi-Dimensional AI Database - Vector similarity, graph relationships, metadata facets with HNSW indexing and OPFS storage",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|