@soulcraft/brainy 1.0.0-rc.1 → 1.0.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 +296 -95
- package/bin/brainy.js +235 -3
- package/dist/brainyData.d.ts +46 -1
- package/dist/brainyData.js +209 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|

|
|
4
4
|
|
|
5
5
|
[](https://badge.fury.io/js/%40soulcraft%2Fbrainy)
|
|
6
|
+
[](https://github.com/soulcraftlabs/brainy/releases/tag/v1.0.0)
|
|
6
7
|
[](https://opensource.org/licenses/MIT)
|
|
7
|
-
[](https://soulcraft.com)
|
|
9
|
+
[](https://soulcraft.com)
|
|
9
10
|
[](https://nodejs.org/)
|
|
10
11
|
[](https://www.typescriptlang.org/)
|
|
11
12
|
|
|
@@ -19,6 +20,61 @@
|
|
|
19
20
|
|
|
20
21
|
---
|
|
21
22
|
|
|
23
|
+
## 💖 **Support Brainy's Development**
|
|
24
|
+
|
|
25
|
+
<div align="center">
|
|
26
|
+
|
|
27
|
+
**Brainy is 100% open source and free forever!** Help us keep it that way:
|
|
28
|
+
|
|
29
|
+
[](https://github.com/soulcraftlabs/brainy)
|
|
30
|
+
[](https://soulcraft.com)
|
|
31
|
+
[](https://github.com/soulcraftlabs/brainy)
|
|
32
|
+
|
|
33
|
+
**Every sponsorship helps us:** Build more features • Fix bugs faster • Keep Brainy free
|
|
34
|
+
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 🎉 **NEW: Brainy 1.0 - The Unified API**
|
|
40
|
+
|
|
41
|
+
**The Great Cleanup is complete!** Brainy 1.0 introduces the **unified API** - ONE way to do everything with just **9 core methods**:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Install Brainy 1.0
|
|
45
|
+
npm install @soulcraft/brainy
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```javascript
|
|
49
|
+
import { BrainyData, NounType, VerbType } from '@soulcraft/brainy'
|
|
50
|
+
|
|
51
|
+
const brain = new BrainyData()
|
|
52
|
+
await brain.init()
|
|
53
|
+
|
|
54
|
+
// 🎯 THE 9 UNIFIED METHODS - One way to do everything!
|
|
55
|
+
await brain.add("Smart data") // 1. Smart addition
|
|
56
|
+
await brain.search("query", 10) // 2. Unified search
|
|
57
|
+
await brain.import(["data1", "data2"]) // 3. Bulk import
|
|
58
|
+
await brain.addNoun("John", NounType.Person) // 4. Typed entities
|
|
59
|
+
await brain.addVerb(id1, id2, VerbType.Knows) // 5. Relationships
|
|
60
|
+
await brain.update(id, "new data") // 6. Smart updates
|
|
61
|
+
await brain.delete(id) // 7. Soft delete
|
|
62
|
+
brain.augment(myAugmentation) // 8. Extend capabilities
|
|
63
|
+
await brain.export({ format: 'json' }) // 9. Export data
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### ✨ **What's New in 1.0:**
|
|
67
|
+
- **🔥 40+ methods consolidated** → 9 unified methods
|
|
68
|
+
- **🧠 Smart by default** - `add()` auto-detects and processes intelligently
|
|
69
|
+
- **🔐 Universal encryption** - Built-in encryption for sensitive data
|
|
70
|
+
- **🐳 Container ready** - Model preloading for production deployments
|
|
71
|
+
- **📦 16% smaller package** despite major new features
|
|
72
|
+
- **🔄 Soft delete default** - Better performance, no reindexing needed
|
|
73
|
+
|
|
74
|
+
**Breaking Changes:** See [MIGRATION.md](MIGRATION.md) for complete upgrade guide.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
22
78
|
## ✅ 100% Free & Open Source
|
|
23
79
|
|
|
24
80
|
**Brainy is completely free. No license keys. No limits. No catch.**
|
|
@@ -35,11 +91,57 @@ Every feature you see here works without any payment or registration:
|
|
|
35
91
|
|
|
36
92
|
---
|
|
37
93
|
|
|
94
|
+
## 💫 Why Brainy? The Problem We Solve
|
|
95
|
+
|
|
96
|
+
### ❌ **The Old Way: Database Frankenstein**
|
|
97
|
+
```
|
|
98
|
+
Pinecone ($750/mo) + Neo4j ($500/mo) + Elasticsearch ($300/mo) +
|
|
99
|
+
Sync nightmares + 3 different APIs + Vendor lock-in = 😱💸
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### ✅ **The Brainy Way: One Brain, All Dimensions**
|
|
103
|
+
```
|
|
104
|
+
Vector + Graph + Search + AI = Brainy (Free & Open Source) = 🧠✨
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Your data gets superpowers. Your wallet stays happy.**
|
|
108
|
+
|
|
109
|
+
### 🧠 **Why Developers Love Brainy 1.0**
|
|
110
|
+
|
|
111
|
+
#### **⚡ One API to Rule Them All**
|
|
112
|
+
```javascript
|
|
113
|
+
// Before: Learning 10+ different database APIs
|
|
114
|
+
pinecone.upsert(), neo4j.run(), elasticsearch.search()
|
|
115
|
+
supabase.insert(), mongodb.find(), redis.set()
|
|
116
|
+
|
|
117
|
+
// After: 9 methods handle EVERYTHING
|
|
118
|
+
brain.add(), brain.search(), brain.import()
|
|
119
|
+
brain.addNoun(), brain.addVerb(), brain.update()
|
|
120
|
+
brain.delete(), brain.augment(), brain.export()
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### **🤯 Mind-Blowing Features Out of the Box**
|
|
124
|
+
- **Smart by Default**: `add()` automatically understands your data
|
|
125
|
+
- **Graph + Vector**: Relationships AND semantic similarity in one query
|
|
126
|
+
- **Zero Config**: Works instantly, optimizes itself
|
|
127
|
+
- **Universal Encryption**: Secure everything with one flag
|
|
128
|
+
- **Perfect Memory**: Nothing ever gets lost or forgotten
|
|
129
|
+
|
|
130
|
+
#### **💰 Cost Comparison**
|
|
131
|
+
| Traditional Stack | Monthly Cost | Brainy 1.0 |
|
|
132
|
+
|------------------|--------------|-------------|
|
|
133
|
+
| Pinecone + Neo4j + Search | $1,500+ | **$0** |
|
|
134
|
+
| 3 different APIs to learn | Weeks | **Minutes** |
|
|
135
|
+
| Sync complexity | High | **None** |
|
|
136
|
+
| Vendor lock-in | Yes | **MIT License** |
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
38
140
|
## 🚀 What Can You Build?
|
|
39
141
|
|
|
40
142
|
### 💬 **AI Chat Apps** - That Actually Remember
|
|
41
143
|
```javascript
|
|
42
|
-
// Your users' conversations persist across sessions
|
|
144
|
+
// Your users' conversations persist across sessions
|
|
43
145
|
const brain = new BrainyData()
|
|
44
146
|
await brain.add("User prefers dark mode")
|
|
45
147
|
await brain.add("User is learning Spanish")
|
|
@@ -51,17 +153,30 @@ const context = await brain.search("user preferences")
|
|
|
51
153
|
|
|
52
154
|
### 🤖 **Smart Assistants** - With Real Knowledge Graphs
|
|
53
155
|
```javascript
|
|
54
|
-
// Build assistants that understand relationships
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
156
|
+
// Build assistants that understand relationships (NEW 1.0 API!)
|
|
157
|
+
import { BrainyData, NounType, VerbType } from '@soulcraft/brainy'
|
|
158
|
+
|
|
159
|
+
const brain = new BrainyData()
|
|
160
|
+
await brain.init()
|
|
161
|
+
|
|
162
|
+
// Create typed entities
|
|
163
|
+
const sarahId = await brain.addNoun("Sarah Thompson", NounType.Person)
|
|
164
|
+
const johnId = await brain.addNoun("John Davis", NounType.Person)
|
|
165
|
+
const projectId = await brain.addNoun("Project Apollo", NounType.Project)
|
|
166
|
+
|
|
167
|
+
// Create relationships with metadata
|
|
168
|
+
await brain.addVerb(sarahId, johnId, VerbType.ReportsTo, {
|
|
169
|
+
role: "Design Manager",
|
|
170
|
+
startDate: "2024-01-15"
|
|
171
|
+
})
|
|
172
|
+
await brain.addVerb(sarahId, projectId, VerbType.WorksWith, {
|
|
173
|
+
responsibility: "Lead Designer",
|
|
174
|
+
allocation: "75%"
|
|
63
175
|
})
|
|
64
|
-
|
|
176
|
+
|
|
177
|
+
// Query complex relationships with graph traversal
|
|
178
|
+
const sarahData = await brain.getNounWithVerbs(sarahId)
|
|
179
|
+
// Returns: complete graph view with all relationships and metadata
|
|
65
180
|
```
|
|
66
181
|
|
|
67
182
|
### 📊 **RAG Applications** - Without the Complexity
|
|
@@ -84,19 +199,77 @@ const results = await brain.search("premium smartphones with metal build")
|
|
|
84
199
|
|
|
85
200
|
### 🎯 **Recommendation Engines** - With Graph Intelligence
|
|
86
201
|
```javascript
|
|
87
|
-
// Netflix-style recommendations with
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
202
|
+
// Netflix-style recommendations with 1.0 unified API
|
|
203
|
+
import { BrainyData, NounType, VerbType } from '@soulcraft/brainy'
|
|
204
|
+
|
|
205
|
+
const brain = new BrainyData()
|
|
206
|
+
await brain.init()
|
|
207
|
+
|
|
208
|
+
// Create entities and relationships
|
|
209
|
+
const userId = await brain.addNoun("User123", NounType.Person)
|
|
210
|
+
const movieId = await brain.addNoun("Inception", NounType.Content)
|
|
211
|
+
|
|
212
|
+
// Track user behavior with metadata
|
|
213
|
+
await brain.addVerb(userId, movieId, VerbType.InteractedWith, {
|
|
214
|
+
action: "watched",
|
|
215
|
+
rating: 5,
|
|
216
|
+
timestamp: new Date(),
|
|
217
|
+
genre: "sci-fi"
|
|
218
|
+
})
|
|
91
219
|
|
|
92
|
-
|
|
93
|
-
|
|
220
|
+
// Get intelligent recommendations based on relationships
|
|
221
|
+
const recommendations = await brain.getNounWithVerbs(userId, {
|
|
222
|
+
verbTypes: [VerbType.InteractedWith],
|
|
94
223
|
depth: 2
|
|
95
224
|
})
|
|
96
|
-
// Returns:
|
|
225
|
+
// Returns: Similar movies based on rating patterns and genre preferences
|
|
97
226
|
```
|
|
98
227
|
|
|
99
|
-
|
|
228
|
+
### 🤖 **Multi-Agent AI Systems** - With Shared Memory
|
|
229
|
+
```javascript
|
|
230
|
+
// Multiple AI agents sharing the same brain
|
|
231
|
+
const sharedBrain = new BrainyData({ instance: 'multi-agent-brain' })
|
|
232
|
+
await sharedBrain.init()
|
|
233
|
+
|
|
234
|
+
// Sales Agent adds customer intelligence
|
|
235
|
+
const customerId = await sharedBrain.addNoun("Acme Corp", NounType.Organization)
|
|
236
|
+
await sharedBrain.addVerb(customerId, "enterprise-plan", VerbType.InterestedIn, {
|
|
237
|
+
priority: "high",
|
|
238
|
+
budget: "$50k",
|
|
239
|
+
timeline: "Q2 2025"
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
// Support Agent instantly sees the context
|
|
243
|
+
const customerData = await sharedBrain.getNounWithVerbs(customerId)
|
|
244
|
+
// Support knows: customer interested in enterprise plan with $50k budget
|
|
245
|
+
|
|
246
|
+
// Marketing Agent learns from both
|
|
247
|
+
const insights = await sharedBrain.search("enterprise customers budget 50k", 10)
|
|
248
|
+
// Marketing can create targeted campaigns for similar prospects
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### 🏥 **Customer Support Bots** - With Perfect Memory
|
|
252
|
+
```javascript
|
|
253
|
+
// Support bot that remembers every interaction
|
|
254
|
+
const customerId = await brain.addNoun("Customer_456", NounType.Person)
|
|
255
|
+
|
|
256
|
+
// Track support history with rich metadata
|
|
257
|
+
await brain.addVerb(customerId, "password-reset", VerbType.RequestedHelp, {
|
|
258
|
+
issue: "Password reset",
|
|
259
|
+
resolved: true,
|
|
260
|
+
date: "2025-01-10",
|
|
261
|
+
satisfaction: 5,
|
|
262
|
+
agent: "Sarah"
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
// Next conversation - bot instantly knows history
|
|
266
|
+
const history = await brain.getNounWithVerbs(customerId)
|
|
267
|
+
// Bot: "I see you had a password issue last week. Everything working smoothly now?"
|
|
268
|
+
|
|
269
|
+
// Proactive insights
|
|
270
|
+
const commonIssues = await brain.search("password reset common issues", 5)
|
|
271
|
+
// Bot offers preventive tips before problems occur
|
|
272
|
+
```
|
|
100
273
|
|
|
101
274
|
### ❌ **The Old Way: Database Frankenstein**
|
|
102
275
|
```
|
|
@@ -111,15 +284,6 @@ Vector + Graph + Search + AI = Brainy (Free & Open Source) = 🧠✨
|
|
|
111
284
|
|
|
112
285
|
**Your data gets superpowers. Your wallet stays happy.**
|
|
113
286
|
|
|
114
|
-
## 🎮 Try It Now - No Install Required!
|
|
115
|
-
|
|
116
|
-
<div align="center">
|
|
117
|
-
|
|
118
|
-
### [**→ Live Demos at soulcraft.com/demo ←**](https://soulcraft.com/demo)
|
|
119
|
-
|
|
120
|
-
Try Brainy instantly in your browser. No signup. No credit card.
|
|
121
|
-
|
|
122
|
-
</div>
|
|
123
287
|
|
|
124
288
|
## ⚡ Quick Start (60 Seconds)
|
|
125
289
|
|
|
@@ -161,9 +325,9 @@ import { BrainyData, Cortex } from '@soulcraft/brainy'
|
|
|
161
325
|
const brain = new BrainyData()
|
|
162
326
|
const cortex = new Cortex()
|
|
163
327
|
|
|
164
|
-
// Add premium augmentations (requires
|
|
165
|
-
|
|
166
|
-
|
|
328
|
+
// Add premium augmentations (requires Brain Cloud subscription)
|
|
329
|
+
brain.register(new AIMemory())
|
|
330
|
+
brain.register(new AgentCoordinator())
|
|
167
331
|
|
|
168
332
|
// Now your AI remembers everything across all sessions!
|
|
169
333
|
await brain.add("User prefers TypeScript over JavaScript")
|
|
@@ -199,30 +363,49 @@ await neural.neuralImport('data.csv') // Automatically extracts entities & rela
|
|
|
199
363
|
- ✅ **Simple Search** - Text and vector search
|
|
200
364
|
- ✅ **Graph Traversal** - Relationship queries
|
|
201
365
|
|
|
202
|
-
### 🌟 **Community Augmentations** (
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
|
|
366
|
+
### 🌟 **Community Augmentations** (Coming Soon!)
|
|
367
|
+
```javascript
|
|
368
|
+
// 🚧 FUTURE: Community augmentations will be available soon!
|
|
369
|
+
// These are examples of what the community could build:
|
|
370
|
+
|
|
371
|
+
// Example: Sentiment Analysis (not yet available)
|
|
372
|
+
// npm install brainy-sentiment
|
|
373
|
+
// brain.register(new SentimentAnalyzer())
|
|
374
|
+
|
|
375
|
+
// Example: Translation (not yet available)
|
|
376
|
+
// npm install brainy-translate
|
|
377
|
+
// brain.register(new Translator())
|
|
206
378
|
```
|
|
207
379
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
380
|
+
**Ideas for Community Augmentations:**
|
|
381
|
+
*Want to build one of these? We'll help promote it!*
|
|
382
|
+
- 🎭 Sentiment Analysis - Analyze emotional tone
|
|
383
|
+
- 🌍 Translation - Multi-language support
|
|
384
|
+
- 📧 Email Parser - Extract structured data from emails
|
|
385
|
+
- 🔗 URL Extractor - Find and validate URLs
|
|
386
|
+
- 📊 Data Visualizer - Generate charts from data
|
|
387
|
+
- 🎨 Image Understanding - Analyze image content
|
|
388
|
+
|
|
389
|
+
**Be the First!** Create an augmentation and we'll feature it here.
|
|
390
|
+
[See how to build augmentations →](UNIFIED-API.md#creating-your-own-augmentation)
|
|
211
391
|
|
|
212
|
-
|
|
213
|
-
|
|
392
|
+
### ☁️ **Brain Cloud** - Power Up Your Brain! 🚀
|
|
393
|
+
**Try it FREE:** Get persistent memory, team sync, and enterprise connectors!
|
|
394
|
+
|
|
395
|
+
```bash
|
|
396
|
+
# Coming Soon! Brain Cloud is in development
|
|
397
|
+
# Join the waitlist:
|
|
398
|
+
# Visit: soulcraft.com
|
|
214
399
|
```
|
|
215
400
|
|
|
216
|
-
**
|
|
217
|
-
-
|
|
218
|
-
-
|
|
219
|
-
-
|
|
220
|
-
-
|
|
221
|
-
-
|
|
222
|
-
- 🎨 Image Understanding
|
|
401
|
+
**Why Brain Cloud?**
|
|
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!
|
|
223
407
|
|
|
224
|
-
|
|
225
|
-
🌟 **Brainy works perfectly without this!** Brain Cloud adds team features:
|
|
408
|
+
**Special Offer:** First 100GB FREE, then just $9/month for individuals, $49/team
|
|
226
409
|
|
|
227
410
|
```javascript
|
|
228
411
|
// Brain Cloud features are in the main package
|
|
@@ -234,7 +417,7 @@ const brain = new BrainyVectorDB({
|
|
|
234
417
|
cloud: { apiKey: process.env.BRAIN_CLOUD_KEY } // Optional
|
|
235
418
|
})
|
|
236
419
|
|
|
237
|
-
|
|
420
|
+
brain.register(aiMemory) // AI remembers everything
|
|
238
421
|
```
|
|
239
422
|
|
|
240
423
|
**AI Memory & Coordination:**
|
|
@@ -250,20 +433,6 @@ cortex.register(aiMemory) // AI remembers everything
|
|
|
250
433
|
- 🔄 **Postgres** - Real-time replication
|
|
251
434
|
- 🏢 **Slack** - Team knowledge base
|
|
252
435
|
|
|
253
|
-
### 🎮 **Try Online** (Free Playground)
|
|
254
|
-
Test Brainy instantly without installing:
|
|
255
|
-
|
|
256
|
-
```javascript
|
|
257
|
-
// Visit soulcraft.com/demo
|
|
258
|
-
// No signup required - just start coding!
|
|
259
|
-
// Perfect for:
|
|
260
|
-
// - Testing Brainy before installing
|
|
261
|
-
// - Prototyping ideas quickly
|
|
262
|
-
// - Learning the API
|
|
263
|
-
// - Sharing examples with others
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
**[→ Try Live Demos](https://soulcraft.com/demo)** - Multiple interactive demos showcasing Brainy's capabilities
|
|
267
436
|
|
|
268
437
|
### ☁️ **Brain Cloud** (Managed Service)
|
|
269
438
|
For teams that want zero-ops:
|
|
@@ -303,27 +472,31 @@ await brain.connect('brain-cloud.soulcraft.com', {
|
|
|
303
472
|
### Build & Share Your Augmentation
|
|
304
473
|
|
|
305
474
|
```typescript
|
|
306
|
-
import {
|
|
475
|
+
import { IAugmentation } from '@soulcraft/brainy'
|
|
307
476
|
|
|
308
|
-
export class MovieRecommender implements
|
|
477
|
+
export class MovieRecommender implements IAugmentation {
|
|
309
478
|
name = 'movie-recommender'
|
|
479
|
+
type = 'cognition' // sense|conduit|cognition|memory
|
|
310
480
|
description = 'AI-powered movie recommendations'
|
|
311
481
|
enabled = true
|
|
312
482
|
|
|
313
|
-
async processRawData(data:
|
|
483
|
+
async processRawData(data: any) {
|
|
314
484
|
// Your recommendation logic
|
|
315
485
|
const movies = await this.analyzePreferences(data)
|
|
316
486
|
|
|
317
487
|
return {
|
|
318
488
|
success: true,
|
|
319
489
|
data: {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
metadata: { genres: movies.map(m => m.genre) }
|
|
490
|
+
recommendations: movies,
|
|
491
|
+
confidence: 0.95
|
|
323
492
|
}
|
|
324
493
|
}
|
|
325
494
|
}
|
|
326
495
|
}
|
|
496
|
+
|
|
497
|
+
// Register with Brainy
|
|
498
|
+
const brain = new BrainyData()
|
|
499
|
+
brain.register(new MovieRecommender())
|
|
327
500
|
```
|
|
328
501
|
|
|
329
502
|
**Share with the community:**
|
|
@@ -380,22 +553,50 @@ const context = await agentBrain.search("customer plan interest")
|
|
|
380
553
|
const insights = await agentBrain.getRelated("enterprise plan")
|
|
381
554
|
```
|
|
382
555
|
|
|
383
|
-
## 🏗️ Architecture
|
|
556
|
+
## 🏗️ Architecture - Unified & Simple
|
|
384
557
|
|
|
385
558
|
```
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
559
|
+
┌─────────────────────────────────────────────┐
|
|
560
|
+
│ 🎯 YOUR APP - One Simple API │
|
|
561
|
+
│ brain.add() brain.search() brain.addVerb() │
|
|
562
|
+
└─────────────────┬───────────────────────────┘
|
|
563
|
+
│
|
|
564
|
+
┌─────────────────▼───────────────────────────┐
|
|
565
|
+
│ 🧠 BRAINY 1.0 - THE UNIFIED BRAIN │
|
|
566
|
+
│ │
|
|
567
|
+
│ ┌─────────────┐ ┌─────────────┐ ┌────────┐ │
|
|
568
|
+
│ │ Vector │ │ Graph │ │ Facets │ │
|
|
569
|
+
│ │ Search │ │Relationships│ │Metadata│ │
|
|
570
|
+
│ └─────────────┘ └─────────────┘ └────────┘ │
|
|
571
|
+
│ │
|
|
572
|
+
│ ┌─────────────┐ ┌─────────────┐ ┌────────┐ │
|
|
573
|
+
│ │ Encryption │ │ Memory │ │ Cache │ │
|
|
574
|
+
│ │ Universal │ │ Management │ │ 3-Tier │ │
|
|
575
|
+
│ └─────────────┘ └─────────────┘ └────────┘ │
|
|
576
|
+
└─────────────────┬───────────────────────────┘
|
|
577
|
+
│
|
|
578
|
+
┌─────────────────▼───────────────────────────┐
|
|
579
|
+
│ 💾 STORAGE - Universal Adapters │
|
|
580
|
+
│ Memory • FileSystem • S3 • OPFS • Custom │
|
|
581
|
+
└─────────────────────────────────────────────┘
|
|
397
582
|
```
|
|
398
583
|
|
|
584
|
+
### **What Makes 1.0 Different:**
|
|
585
|
+
- **🎯 One API**: 9 methods handle everything (was 40+ methods)
|
|
586
|
+
- **🧠 Smart Core**: Automatic data understanding and processing
|
|
587
|
+
- **🔗 Graph Built-in**: Relationships are first-class citizens
|
|
588
|
+
- **🔐 Security Native**: Encryption integrated, not bolted-on
|
|
589
|
+
- **🧩 Extensible**: Augment with custom capabilities
|
|
590
|
+
- **📤 Portable**: Export in any format (json, csv, graph)
|
|
591
|
+
- **⚡ Zero Config**: Works perfectly out of the box
|
|
592
|
+
|
|
593
|
+
### **The Magic:**
|
|
594
|
+
1. **You call** `brain.add("complex data")`
|
|
595
|
+
2. **Brainy understands** → detects type, extracts meaning
|
|
596
|
+
3. **Brainy stores** → vector + graph + metadata simultaneously
|
|
597
|
+
4. **Brainy optimizes** → indexes, caches, tunes performance
|
|
598
|
+
5. **You get superpowers** → semantic search + graph traversal + more
|
|
599
|
+
|
|
399
600
|
## 💡 Core Features
|
|
400
601
|
|
|
401
602
|
### 🔍 Multi-Dimensional Search
|
|
@@ -404,11 +605,12 @@ Augmentations (Capabilities)
|
|
|
404
605
|
- **Faceted**: Metadata filtering (property-based)
|
|
405
606
|
- **Hybrid**: All combined (maximum power)
|
|
406
607
|
|
|
407
|
-
### ⚡ Performance
|
|
408
|
-
- **Speed**: 100,000+ ops/second
|
|
409
|
-
- **Scale**: Millions of
|
|
410
|
-
- **Memory**: ~100MB for 1M vectors
|
|
411
|
-
- **Latency**: <10ms searches
|
|
608
|
+
### ⚡ Performance - Production Ready
|
|
609
|
+
- **Speed**: 100,000+ ops/second (faster with 1.0 optimizations)
|
|
610
|
+
- **Scale**: Millions of entities + relationships
|
|
611
|
+
- **Memory**: ~100MB for 1M vectors (16% smaller than 0.x)
|
|
612
|
+
- **Latency**: <10ms searches with 3-tier caching
|
|
613
|
+
- **Intelligence**: Auto-tuning learns from your usage patterns
|
|
412
614
|
|
|
413
615
|
### 🔒 Production Ready
|
|
414
616
|
- **Encryption**: End-to-end available
|
|
@@ -455,10 +657,9 @@ Augmentations (Capabilities)
|
|
|
455
657
|
- 📢 Spread the word
|
|
456
658
|
|
|
457
659
|
### Get Help & Connect
|
|
458
|
-
- 💬 [Discord Community](https://discord.gg/brainy)
|
|
459
|
-
- 🐦 [Twitter Updates](https://twitter.com/soulcraftlabs)
|
|
460
660
|
- 📧 [Email Support](mailto:support@soulcraft.com)
|
|
461
|
-
-
|
|
661
|
+
- 🐛 [GitHub Issues](https://github.com/soulcraftlabs/brainy/issues)
|
|
662
|
+
- 💬 [GitHub Discussions](https://github.com/soulcraftlabs/brainy/discussions)
|
|
462
663
|
|
|
463
664
|
## 📈 Who's Using Brainy?
|
|
464
665
|
|
|
@@ -480,10 +681,10 @@ Premium augmentations available at [soulcraft.com](https://soulcraft.com)
|
|
|
480
681
|
|
|
481
682
|
### 🧠⚛️ **Give Your Data a Brain Upgrade**
|
|
482
683
|
|
|
483
|
-
**[Get Started](docs/getting-started/quick-start.md)** •
|
|
684
|
+
**[Get Started](docs/getting-started/quick-start-1.0.md)** •
|
|
484
685
|
**[Examples](examples/)** •
|
|
485
|
-
**[API Docs](
|
|
486
|
-
**[
|
|
686
|
+
**[API Docs](UNIFIED-API.md)** •
|
|
687
|
+
**[GitHub](https://github.com/soulcraftlabs/brainy)**
|
|
487
688
|
|
|
488
689
|
⭐ **Star us on GitHub to support open source AI!** ⭐
|
|
489
690
|
|
package/bin/brainy.js
CHANGED
|
@@ -869,15 +869,247 @@ program
|
|
|
869
869
|
}
|
|
870
870
|
}))
|
|
871
871
|
|
|
872
|
-
// Command 6:
|
|
872
|
+
// Command 6: AUGMENT - Manage augmentations (The 8th Unified Method!)
|
|
873
|
+
program
|
|
874
|
+
.command('augment <action>')
|
|
875
|
+
.description('Manage augmentations to extend Brainy\'s capabilities')
|
|
876
|
+
.option('-n, --name <name>', 'Augmentation name')
|
|
877
|
+
.option('-t, --type <type>', 'Augmentation type (sense, conduit, cognition, memory)')
|
|
878
|
+
.option('-p, --path <path>', 'Path to augmentation module')
|
|
879
|
+
.option('-l, --list', 'List all augmentations')
|
|
880
|
+
.action(wrapAction(async (action, options) => {
|
|
881
|
+
const brainy = await initBrainy()
|
|
882
|
+
console.log(colors.brain('🧩 Augmentation Management'))
|
|
883
|
+
|
|
884
|
+
const actions = {
|
|
885
|
+
list: async () => {
|
|
886
|
+
const augmentations = brainy.listAugmentations()
|
|
887
|
+
if (augmentations.length === 0) {
|
|
888
|
+
console.log(colors.warning('No augmentations registered'))
|
|
889
|
+
return
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
const table = new Table({
|
|
893
|
+
head: [colors.brain('Name'), colors.brain('Type'), colors.brain('Status'), colors.brain('Description')],
|
|
894
|
+
style: { head: [], border: [] }
|
|
895
|
+
})
|
|
896
|
+
|
|
897
|
+
augmentations.forEach(aug => {
|
|
898
|
+
table.push([
|
|
899
|
+
colors.primary(aug.name),
|
|
900
|
+
colors.info(aug.type),
|
|
901
|
+
aug.enabled ? colors.success('✅ Enabled') : colors.dim('⚪ Disabled'),
|
|
902
|
+
colors.dim(aug.description || '')
|
|
903
|
+
])
|
|
904
|
+
})
|
|
905
|
+
|
|
906
|
+
console.log(table.toString())
|
|
907
|
+
console.log(colors.info(`\nTotal: ${augmentations.length} augmentations`))
|
|
908
|
+
},
|
|
909
|
+
|
|
910
|
+
enable: async () => {
|
|
911
|
+
if (!options.name) {
|
|
912
|
+
console.log(colors.error('Name required: --name <augmentation-name>'))
|
|
913
|
+
return
|
|
914
|
+
}
|
|
915
|
+
const success = brainy.enableAugmentation(options.name)
|
|
916
|
+
if (success) {
|
|
917
|
+
console.log(colors.success(`✅ Enabled augmentation: ${options.name}`))
|
|
918
|
+
} else {
|
|
919
|
+
console.log(colors.error(`Failed to enable: ${options.name} (not found)`))
|
|
920
|
+
}
|
|
921
|
+
},
|
|
922
|
+
|
|
923
|
+
disable: async () => {
|
|
924
|
+
if (!options.name) {
|
|
925
|
+
console.log(colors.error('Name required: --name <augmentation-name>'))
|
|
926
|
+
return
|
|
927
|
+
}
|
|
928
|
+
const success = brainy.disableAugmentation(options.name)
|
|
929
|
+
if (success) {
|
|
930
|
+
console.log(colors.warning(`⚪ Disabled augmentation: ${options.name}`))
|
|
931
|
+
} else {
|
|
932
|
+
console.log(colors.error(`Failed to disable: ${options.name} (not found)`))
|
|
933
|
+
}
|
|
934
|
+
},
|
|
935
|
+
|
|
936
|
+
register: async () => {
|
|
937
|
+
if (!options.path) {
|
|
938
|
+
console.log(colors.error('Path required: --path <augmentation-module>'))
|
|
939
|
+
return
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
try {
|
|
943
|
+
// Dynamic import of custom augmentation
|
|
944
|
+
const customModule = await import(options.path)
|
|
945
|
+
const AugmentationClass = customModule.default || customModule[Object.keys(customModule)[0]]
|
|
946
|
+
|
|
947
|
+
if (!AugmentationClass) {
|
|
948
|
+
console.log(colors.error('No augmentation class found in module'))
|
|
949
|
+
return
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
const augmentation = new AugmentationClass()
|
|
953
|
+
brainy.register(augmentation)
|
|
954
|
+
console.log(colors.success(`✅ Registered augmentation: ${augmentation.name}`))
|
|
955
|
+
console.log(colors.info(`Type: ${augmentation.type}`))
|
|
956
|
+
if (augmentation.description) {
|
|
957
|
+
console.log(colors.dim(`Description: ${augmentation.description}`))
|
|
958
|
+
}
|
|
959
|
+
} catch (error) {
|
|
960
|
+
console.log(colors.error(`Failed to register augmentation: ${error.message}`))
|
|
961
|
+
}
|
|
962
|
+
},
|
|
963
|
+
|
|
964
|
+
unregister: async () => {
|
|
965
|
+
if (!options.name) {
|
|
966
|
+
console.log(colors.error('Name required: --name <augmentation-name>'))
|
|
967
|
+
return
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
brainy.unregister(options.name)
|
|
971
|
+
console.log(colors.warning(`🗑️ Unregistered augmentation: ${options.name}`))
|
|
972
|
+
},
|
|
973
|
+
|
|
974
|
+
'enable-type': async () => {
|
|
975
|
+
if (!options.type) {
|
|
976
|
+
console.log(colors.error('Type required: --type <augmentation-type>'))
|
|
977
|
+
console.log(colors.info('Valid types: sense, conduit, cognition, memory, perception, dialog, activation'))
|
|
978
|
+
return
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
const count = brainy.enableAugmentationType(options.type)
|
|
982
|
+
console.log(colors.success(`✅ Enabled ${count} ${options.type} augmentations`))
|
|
983
|
+
},
|
|
984
|
+
|
|
985
|
+
'disable-type': async () => {
|
|
986
|
+
if (!options.type) {
|
|
987
|
+
console.log(colors.error('Type required: --type <augmentation-type>'))
|
|
988
|
+
console.log(colors.info('Valid types: sense, conduit, cognition, memory, perception, dialog, activation'))
|
|
989
|
+
return
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
const count = brainy.disableAugmentationType(options.type)
|
|
993
|
+
console.log(colors.warning(`⚪ Disabled ${count} ${options.type} augmentations`))
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
if (actions[action]) {
|
|
998
|
+
await actions[action]()
|
|
999
|
+
} else {
|
|
1000
|
+
console.log(colors.error('Valid actions: list, enable, disable, register, unregister, enable-type, disable-type'))
|
|
1001
|
+
console.log(colors.info('\nExamples:'))
|
|
1002
|
+
console.log(colors.dim(' brainy augment list # List all augmentations'))
|
|
1003
|
+
console.log(colors.dim(' brainy augment enable --name neural-import # Enable an augmentation'))
|
|
1004
|
+
console.log(colors.dim(' brainy augment register --path ./my-augmentation.js # Register custom augmentation'))
|
|
1005
|
+
console.log(colors.dim(' brainy augment enable-type --type sense # Enable all sense augmentations'))
|
|
1006
|
+
}
|
|
1007
|
+
}))
|
|
1008
|
+
|
|
1009
|
+
// Command 7: EXPORT - Export your data
|
|
1010
|
+
program
|
|
1011
|
+
.command('export')
|
|
1012
|
+
.description('Export your brain data in various formats')
|
|
1013
|
+
.option('-f, --format <format>', 'Export format (json, csv, graph, embeddings)', 'json')
|
|
1014
|
+
.option('-o, --output <file>', 'Output file path')
|
|
1015
|
+
.option('--vectors', 'Include vector embeddings')
|
|
1016
|
+
.option('--no-metadata', 'Exclude metadata')
|
|
1017
|
+
.option('--no-relationships', 'Exclude relationships')
|
|
1018
|
+
.option('--filter <json>', 'Filter by metadata')
|
|
1019
|
+
.option('-l, --limit <number>', 'Limit number of items')
|
|
1020
|
+
.action(wrapAction(async (options) => {
|
|
1021
|
+
const brainy = await initBrainy()
|
|
1022
|
+
console.log(colors.brain('📤 Exporting Brain Data'))
|
|
1023
|
+
|
|
1024
|
+
const spinner = ora('Exporting data...').start()
|
|
1025
|
+
|
|
1026
|
+
try {
|
|
1027
|
+
const exportOptions = {
|
|
1028
|
+
format: options.format,
|
|
1029
|
+
includeVectors: options.vectors || false,
|
|
1030
|
+
includeMetadata: options.metadata !== false,
|
|
1031
|
+
includeRelationships: options.relationships !== false,
|
|
1032
|
+
filter: options.filter ? JSON.parse(options.filter) : {},
|
|
1033
|
+
limit: options.limit ? parseInt(options.limit) : undefined
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
const data = await brainy.export(exportOptions)
|
|
1037
|
+
|
|
1038
|
+
spinner.succeed('Export complete')
|
|
1039
|
+
|
|
1040
|
+
if (options.output) {
|
|
1041
|
+
// Write to file
|
|
1042
|
+
const fs = require('fs')
|
|
1043
|
+
const content = typeof data === 'string' ? data : JSON.stringify(data, null, 2)
|
|
1044
|
+
fs.writeFileSync(options.output, content)
|
|
1045
|
+
console.log(colors.success(`✅ Exported to: ${options.output}`))
|
|
1046
|
+
|
|
1047
|
+
// Show summary
|
|
1048
|
+
const items = Array.isArray(data) ? data.length : (data.nodes ? data.nodes.length : 1)
|
|
1049
|
+
console.log(colors.info(`📊 Format: ${options.format}`))
|
|
1050
|
+
console.log(colors.info(`📁 Items: ${items}`))
|
|
1051
|
+
if (options.vectors) {
|
|
1052
|
+
console.log(colors.info(`🔢 Vectors: Included`))
|
|
1053
|
+
}
|
|
1054
|
+
} else {
|
|
1055
|
+
// Output to console
|
|
1056
|
+
if (typeof data === 'string') {
|
|
1057
|
+
console.log(data)
|
|
1058
|
+
} else {
|
|
1059
|
+
console.log(JSON.stringify(data, null, 2))
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
} catch (error) {
|
|
1063
|
+
spinner.fail('Export failed')
|
|
1064
|
+
console.error(colors.error(error.message))
|
|
1065
|
+
process.exit(1)
|
|
1066
|
+
}
|
|
1067
|
+
}))
|
|
1068
|
+
|
|
1069
|
+
// Command 8: CLOUD - Premium features connection
|
|
873
1070
|
program
|
|
874
1071
|
.command('cloud <action>')
|
|
875
|
-
.description('
|
|
1072
|
+
.description('☁️ Brain Cloud - AI Memory, Team Sync, Enterprise Connectors (FREE TRIAL!)')
|
|
876
1073
|
.option('-i, --instance <id>', 'Brain Cloud instance ID')
|
|
1074
|
+
.option('-e, --email <email>', 'Your email for signup')
|
|
877
1075
|
.action(wrapAction(async (action, options) => {
|
|
878
|
-
console.log(
|
|
1076
|
+
console.log(boxen(
|
|
1077
|
+
colors.brain('☁️ BRAIN CLOUD - SUPERCHARGE YOUR BRAIN! 🚀\n\n') +
|
|
1078
|
+
colors.success('✨ FREE TRIAL: First 100GB FREE!\n') +
|
|
1079
|
+
colors.info('💰 Then just $9/month (individuals) or $49/month (teams)\n\n') +
|
|
1080
|
+
colors.primary('Features:\n') +
|
|
1081
|
+
colors.dim(' • AI Memory that persists across sessions\n') +
|
|
1082
|
+
colors.dim(' • Multi-agent coordination\n') +
|
|
1083
|
+
colors.dim(' • Automatic backups & sync\n') +
|
|
1084
|
+
colors.dim(' • Premium connectors (Notion, Slack, etc.)'),
|
|
1085
|
+
{ padding: 1, borderStyle: 'round', borderColor: 'cyan' }
|
|
1086
|
+
))
|
|
879
1087
|
|
|
880
1088
|
const cloudActions = {
|
|
1089
|
+
setup: async () => {
|
|
1090
|
+
console.log(colors.brain('\n🚀 Quick Setup - 30 seconds to superpowers!\n'))
|
|
1091
|
+
|
|
1092
|
+
if (!options.email) {
|
|
1093
|
+
const { email } = await prompts({
|
|
1094
|
+
type: 'text',
|
|
1095
|
+
name: 'email',
|
|
1096
|
+
message: 'Enter your email for FREE trial:',
|
|
1097
|
+
validate: (value) => value.includes('@') || 'Please enter a valid email'
|
|
1098
|
+
})
|
|
1099
|
+
options.email = email
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
console.log(colors.success(`\n✅ Setting up Brain Cloud for: ${options.email}`))
|
|
1103
|
+
console.log(colors.info('\n📧 Check your email for activation link!'))
|
|
1104
|
+
console.log(colors.dim('\nOr visit: https://app.soulcraft.com/activate\n'))
|
|
1105
|
+
|
|
1106
|
+
// TODO: Actually call Brain Cloud API when ready
|
|
1107
|
+
console.log(colors.brain('🎉 Your Brain Cloud trial is ready!'))
|
|
1108
|
+
console.log(colors.success('\nNext steps:'))
|
|
1109
|
+
console.log(colors.dim(' 1. Check your email for API key'))
|
|
1110
|
+
console.log(colors.dim(' 2. Run: brainy cloud connect --key YOUR_KEY'))
|
|
1111
|
+
console.log(colors.dim(' 3. Start using persistent AI memory!'))
|
|
1112
|
+
},
|
|
881
1113
|
connect: async () => {
|
|
882
1114
|
console.log(colors.info('🔗 Connecting to Brain Cloud...'))
|
|
883
1115
|
// Dynamic import to avoid loading premium code unnecessarily
|
package/dist/brainyData.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { HNSWIndexOptimized, HNSWOptimizedConfig } from './hnsw/hnswIndexOptimiz
|
|
|
7
7
|
import { DistanceFunction, GraphVerb, EmbeddingFunction, HNSWConfig, SearchResult, SearchCursor, PaginatedSearchResult, StorageAdapter, Vector, VectorDocument } from './coreTypes.js';
|
|
8
8
|
import { MetadataIndexManager, MetadataIndexConfig } from './utils/metadataIndex.js';
|
|
9
9
|
import { NounType, VerbType } from './types/graphTypes.js';
|
|
10
|
-
import { WebSocketConnection } from './types/augmentations.js';
|
|
10
|
+
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';
|
|
@@ -1474,6 +1474,51 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
|
|
|
1474
1474
|
* Exposed for Cortex reindex command
|
|
1475
1475
|
*/
|
|
1476
1476
|
rebuildMetadataIndex(): Promise<void>;
|
|
1477
|
+
/**
|
|
1478
|
+
* UNIFIED API METHOD #8: Augment - Complete augmentation management
|
|
1479
|
+
* Register, enable, disable, list, and manage augmentations
|
|
1480
|
+
*
|
|
1481
|
+
* @param action The action to perform or augmentation to register
|
|
1482
|
+
* @param options Additional options for the action
|
|
1483
|
+
* @returns Various return types based on action
|
|
1484
|
+
*/
|
|
1485
|
+
augment(action: IAugmentation | 'list' | 'enable' | 'disable' | 'unregister' | 'enable-type' | 'disable-type', options?: string | {
|
|
1486
|
+
name?: string;
|
|
1487
|
+
type?: string;
|
|
1488
|
+
}): this | any;
|
|
1489
|
+
/**
|
|
1490
|
+
* UNIFIED API METHOD #9: Export - Extract your data in various formats
|
|
1491
|
+
* Export your brain's knowledge for backup, migration, or integration
|
|
1492
|
+
*
|
|
1493
|
+
* @param options Export configuration
|
|
1494
|
+
* @returns The exported data in the specified format
|
|
1495
|
+
*/
|
|
1496
|
+
export(options?: {
|
|
1497
|
+
format?: 'json' | 'csv' | 'graph' | 'embeddings';
|
|
1498
|
+
includeVectors?: boolean;
|
|
1499
|
+
includeMetadata?: boolean;
|
|
1500
|
+
includeRelationships?: boolean;
|
|
1501
|
+
filter?: any;
|
|
1502
|
+
limit?: number;
|
|
1503
|
+
}): Promise<any>;
|
|
1504
|
+
/**
|
|
1505
|
+
* Helper: Convert data to CSV format
|
|
1506
|
+
* @private
|
|
1507
|
+
*/
|
|
1508
|
+
private convertToCSV;
|
|
1509
|
+
/**
|
|
1510
|
+
* Helper: Convert data to graph format
|
|
1511
|
+
* @private
|
|
1512
|
+
*/
|
|
1513
|
+
private convertToGraphFormat;
|
|
1514
|
+
/**
|
|
1515
|
+
* Unregister an augmentation by name
|
|
1516
|
+
* Remove augmentations from the pipeline
|
|
1517
|
+
*
|
|
1518
|
+
* @param name The name of the augmentation to unregister
|
|
1519
|
+
* @returns The BrainyData instance for chaining
|
|
1520
|
+
*/
|
|
1521
|
+
unregister(name: string): this;
|
|
1477
1522
|
/**
|
|
1478
1523
|
* Enable an augmentation by name
|
|
1479
1524
|
* Universal control for built-in, community, and premium augmentations
|
package/dist/brainyData.js
CHANGED
|
@@ -5344,6 +5344,215 @@ export class BrainyData {
|
|
|
5344
5344
|
}
|
|
5345
5345
|
}
|
|
5346
5346
|
// ===== Augmentation Control Methods =====
|
|
5347
|
+
/**
|
|
5348
|
+
* UNIFIED API METHOD #8: Augment - Complete augmentation management
|
|
5349
|
+
* Register, enable, disable, list, and manage augmentations
|
|
5350
|
+
*
|
|
5351
|
+
* @param action The action to perform or augmentation to register
|
|
5352
|
+
* @param options Additional options for the action
|
|
5353
|
+
* @returns Various return types based on action
|
|
5354
|
+
*/
|
|
5355
|
+
augment(action, options) {
|
|
5356
|
+
// If it's an augmentation object, register it
|
|
5357
|
+
if (typeof action === 'object' && 'name' in action && 'type' in action) {
|
|
5358
|
+
augmentationPipeline.register(action);
|
|
5359
|
+
return this;
|
|
5360
|
+
}
|
|
5361
|
+
// Handle string actions
|
|
5362
|
+
switch (action) {
|
|
5363
|
+
case 'list':
|
|
5364
|
+
// Return list of all augmentations with status
|
|
5365
|
+
return this.listAugmentations();
|
|
5366
|
+
case 'enable':
|
|
5367
|
+
// Enable specific augmentation by name
|
|
5368
|
+
if (typeof options === 'string') {
|
|
5369
|
+
this.enableAugmentation(options);
|
|
5370
|
+
}
|
|
5371
|
+
else if (options?.name) {
|
|
5372
|
+
this.enableAugmentation(options.name);
|
|
5373
|
+
}
|
|
5374
|
+
return this;
|
|
5375
|
+
case 'disable':
|
|
5376
|
+
// Disable specific augmentation by name
|
|
5377
|
+
if (typeof options === 'string') {
|
|
5378
|
+
this.disableAugmentation(options);
|
|
5379
|
+
}
|
|
5380
|
+
else if (options?.name) {
|
|
5381
|
+
this.disableAugmentation(options.name);
|
|
5382
|
+
}
|
|
5383
|
+
return this;
|
|
5384
|
+
case 'unregister':
|
|
5385
|
+
// Remove augmentation from pipeline
|
|
5386
|
+
if (typeof options === 'string') {
|
|
5387
|
+
this.unregister(options);
|
|
5388
|
+
}
|
|
5389
|
+
else if (options?.name) {
|
|
5390
|
+
this.unregister(options.name);
|
|
5391
|
+
}
|
|
5392
|
+
return this;
|
|
5393
|
+
case 'enable-type':
|
|
5394
|
+
// Enable all augmentations of a type
|
|
5395
|
+
if (typeof options === 'string') {
|
|
5396
|
+
const validTypes = ['sense', 'conduit', 'cognition', 'memory', 'perception', 'dialog', 'activation', 'webSocket'];
|
|
5397
|
+
if (validTypes.includes(options)) {
|
|
5398
|
+
return this.enableAugmentationType(options);
|
|
5399
|
+
}
|
|
5400
|
+
}
|
|
5401
|
+
else if (options?.type) {
|
|
5402
|
+
const validTypes = ['sense', 'conduit', 'cognition', 'memory', 'perception', 'dialog', 'activation', 'webSocket'];
|
|
5403
|
+
if (validTypes.includes(options.type)) {
|
|
5404
|
+
return this.enableAugmentationType(options.type);
|
|
5405
|
+
}
|
|
5406
|
+
}
|
|
5407
|
+
throw new Error('Invalid augmentation type');
|
|
5408
|
+
case 'disable-type':
|
|
5409
|
+
// Disable all augmentations of a type
|
|
5410
|
+
if (typeof options === 'string') {
|
|
5411
|
+
const validTypes = ['sense', 'conduit', 'cognition', 'memory', 'perception', 'dialog', 'activation', 'webSocket'];
|
|
5412
|
+
if (validTypes.includes(options)) {
|
|
5413
|
+
return this.disableAugmentationType(options);
|
|
5414
|
+
}
|
|
5415
|
+
}
|
|
5416
|
+
else if (options?.type) {
|
|
5417
|
+
const validTypes = ['sense', 'conduit', 'cognition', 'memory', 'perception', 'dialog', 'activation', 'webSocket'];
|
|
5418
|
+
if (validTypes.includes(options.type)) {
|
|
5419
|
+
return this.disableAugmentationType(options.type);
|
|
5420
|
+
}
|
|
5421
|
+
}
|
|
5422
|
+
throw new Error('Invalid augmentation type');
|
|
5423
|
+
default:
|
|
5424
|
+
throw new Error(`Unknown augment action: ${action}`);
|
|
5425
|
+
}
|
|
5426
|
+
}
|
|
5427
|
+
/**
|
|
5428
|
+
* UNIFIED API METHOD #9: Export - Extract your data in various formats
|
|
5429
|
+
* Export your brain's knowledge for backup, migration, or integration
|
|
5430
|
+
*
|
|
5431
|
+
* @param options Export configuration
|
|
5432
|
+
* @returns The exported data in the specified format
|
|
5433
|
+
*/
|
|
5434
|
+
async export(options = {}) {
|
|
5435
|
+
const { format = 'json', includeVectors = false, includeMetadata = true, includeRelationships = true, filter = {}, limit } = options;
|
|
5436
|
+
// Get all data with optional filtering
|
|
5437
|
+
const nounsResult = await this.getNouns();
|
|
5438
|
+
const allNouns = nounsResult.items || [];
|
|
5439
|
+
let exportData = [];
|
|
5440
|
+
// Apply filters and limits
|
|
5441
|
+
let nouns = allNouns;
|
|
5442
|
+
if (Object.keys(filter).length > 0) {
|
|
5443
|
+
nouns = allNouns.filter((noun) => {
|
|
5444
|
+
return Object.entries(filter).every(([key, value]) => {
|
|
5445
|
+
return noun.metadata?.[key] === value;
|
|
5446
|
+
});
|
|
5447
|
+
});
|
|
5448
|
+
}
|
|
5449
|
+
if (limit) {
|
|
5450
|
+
nouns = nouns.slice(0, limit);
|
|
5451
|
+
}
|
|
5452
|
+
// Build export data
|
|
5453
|
+
for (const noun of nouns) {
|
|
5454
|
+
const exportItem = {
|
|
5455
|
+
id: noun.id,
|
|
5456
|
+
text: noun.text || noun.metadata?.text || noun.id
|
|
5457
|
+
};
|
|
5458
|
+
if (includeVectors && noun.vector) {
|
|
5459
|
+
exportItem.vector = noun.vector;
|
|
5460
|
+
}
|
|
5461
|
+
if (includeMetadata && noun.metadata) {
|
|
5462
|
+
exportItem.metadata = noun.metadata;
|
|
5463
|
+
}
|
|
5464
|
+
if (includeRelationships) {
|
|
5465
|
+
const relationships = await this.getNounWithVerbs(noun.id);
|
|
5466
|
+
const allVerbs = [
|
|
5467
|
+
...(relationships?.incomingVerbs || []),
|
|
5468
|
+
...(relationships?.outgoingVerbs || [])
|
|
5469
|
+
];
|
|
5470
|
+
if (allVerbs.length > 0) {
|
|
5471
|
+
exportItem.relationships = allVerbs;
|
|
5472
|
+
}
|
|
5473
|
+
}
|
|
5474
|
+
exportData.push(exportItem);
|
|
5475
|
+
}
|
|
5476
|
+
// Format output based on requested format
|
|
5477
|
+
switch (format) {
|
|
5478
|
+
case 'csv':
|
|
5479
|
+
return this.convertToCSV(exportData);
|
|
5480
|
+
case 'graph':
|
|
5481
|
+
return this.convertToGraphFormat(exportData);
|
|
5482
|
+
case 'embeddings':
|
|
5483
|
+
return exportData.map(item => ({
|
|
5484
|
+
id: item.id,
|
|
5485
|
+
vector: item.vector || []
|
|
5486
|
+
}));
|
|
5487
|
+
case 'json':
|
|
5488
|
+
default:
|
|
5489
|
+
return exportData;
|
|
5490
|
+
}
|
|
5491
|
+
}
|
|
5492
|
+
/**
|
|
5493
|
+
* Helper: Convert data to CSV format
|
|
5494
|
+
* @private
|
|
5495
|
+
*/
|
|
5496
|
+
convertToCSV(data) {
|
|
5497
|
+
if (data.length === 0)
|
|
5498
|
+
return '';
|
|
5499
|
+
// Get all unique keys
|
|
5500
|
+
const keys = new Set();
|
|
5501
|
+
data.forEach(item => {
|
|
5502
|
+
Object.keys(item).forEach(key => keys.add(key));
|
|
5503
|
+
});
|
|
5504
|
+
// Create header
|
|
5505
|
+
const headers = Array.from(keys);
|
|
5506
|
+
const csv = [headers.join(',')];
|
|
5507
|
+
// Add data rows
|
|
5508
|
+
data.forEach(item => {
|
|
5509
|
+
const row = headers.map(header => {
|
|
5510
|
+
const value = item[header];
|
|
5511
|
+
if (typeof value === 'object') {
|
|
5512
|
+
return JSON.stringify(value);
|
|
5513
|
+
}
|
|
5514
|
+
return value || '';
|
|
5515
|
+
});
|
|
5516
|
+
csv.push(row.join(','));
|
|
5517
|
+
});
|
|
5518
|
+
return csv.join('\n');
|
|
5519
|
+
}
|
|
5520
|
+
/**
|
|
5521
|
+
* Helper: Convert data to graph format
|
|
5522
|
+
* @private
|
|
5523
|
+
*/
|
|
5524
|
+
convertToGraphFormat(data) {
|
|
5525
|
+
const nodes = data.map(item => ({
|
|
5526
|
+
id: item.id,
|
|
5527
|
+
label: item.text || item.id,
|
|
5528
|
+
metadata: item.metadata
|
|
5529
|
+
}));
|
|
5530
|
+
const edges = [];
|
|
5531
|
+
data.forEach(item => {
|
|
5532
|
+
if (item.relationships) {
|
|
5533
|
+
item.relationships.forEach((rel) => {
|
|
5534
|
+
edges.push({
|
|
5535
|
+
source: item.id,
|
|
5536
|
+
target: rel.targetId,
|
|
5537
|
+
type: rel.verbType,
|
|
5538
|
+
metadata: rel.metadata
|
|
5539
|
+
});
|
|
5540
|
+
});
|
|
5541
|
+
}
|
|
5542
|
+
});
|
|
5543
|
+
return { nodes, edges };
|
|
5544
|
+
}
|
|
5545
|
+
/**
|
|
5546
|
+
* Unregister an augmentation by name
|
|
5547
|
+
* Remove augmentations from the pipeline
|
|
5548
|
+
*
|
|
5549
|
+
* @param name The name of the augmentation to unregister
|
|
5550
|
+
* @returns The BrainyData instance for chaining
|
|
5551
|
+
*/
|
|
5552
|
+
unregister(name) {
|
|
5553
|
+
augmentationPipeline.unregister(name);
|
|
5554
|
+
return this;
|
|
5555
|
+
}
|
|
5347
5556
|
/**
|
|
5348
5557
|
* Enable an augmentation by name
|
|
5349
5558
|
* Universal control for built-in, community, and premium augmentations
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.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",
|