@soulcraft/brainy 0.62.0 → 0.62.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 +29 -15
- package/bin/brainy.js +18 -15
- package/dist/utils/modelLoader.d.ts +12 -0
- package/dist/utils/modelLoader.js +88 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,6 +20,22 @@
|
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
|
+
## ✅ 100% Free & Open Source
|
|
24
|
+
|
|
25
|
+
**Brainy is completely free. No license keys. No limits. No catch.**
|
|
26
|
+
|
|
27
|
+
Every feature you see here works without any payment or registration:
|
|
28
|
+
- ✓ Full vector database
|
|
29
|
+
- ✓ Graph relationships
|
|
30
|
+
- ✓ Semantic search
|
|
31
|
+
- ✓ All storage adapters
|
|
32
|
+
- ✓ Complete API
|
|
33
|
+
- ✓ Forever free
|
|
34
|
+
|
|
35
|
+
> 🌩️ **Brain Cloud** is an optional add-on for teams who want cloud sync and enterprise connectors.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
23
39
|
## 🚀 What Can You Build?
|
|
24
40
|
|
|
25
41
|
### 💬 **AI Chat Apps** - That Actually Remember
|
|
@@ -134,13 +150,14 @@ const results = await brain.search("companies founded by Elon")
|
|
|
134
150
|
# Auto-setup with cloud instance provisioning (RECOMMENDED)
|
|
135
151
|
brainy cloud setup --email your@email.com
|
|
136
152
|
|
|
137
|
-
#
|
|
138
|
-
|
|
153
|
+
# Sign up at app.soulcraft.com (free trial)
|
|
154
|
+
brainy cloud auth # Auto-configures based on your plan
|
|
139
155
|
```
|
|
140
156
|
|
|
141
157
|
```javascript
|
|
142
158
|
import { BrainyData, Cortex } from '@soulcraft/brainy'
|
|
143
|
-
|
|
159
|
+
// After authentication, augmentations auto-load
|
|
160
|
+
// No imports needed - they're managed by your account!
|
|
144
161
|
|
|
145
162
|
const brain = new BrainyData()
|
|
146
163
|
const cortex = new Cortex()
|
|
@@ -205,20 +222,17 @@ cortex.register(new Translator()) // Multi-language support
|
|
|
205
222
|
- 📊 Data Visualizer
|
|
206
223
|
- 🎨 Image Understanding
|
|
207
224
|
|
|
208
|
-
###
|
|
209
|
-
|
|
225
|
+
### ☁️ **Brain Cloud** (Optional Add-On)
|
|
226
|
+
🌟 **Brainy works perfectly without this!** Brain Cloud adds team features:
|
|
210
227
|
|
|
211
228
|
```javascript
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
// Requires license key - get one at soulcraft.com
|
|
220
|
-
const aiMemory = new AIMemory({
|
|
221
|
-
licenseKey: process.env.BRAINY_LICENSE_KEY
|
|
229
|
+
// Brain Cloud features are in the main package
|
|
230
|
+
// But require API key to activate cloud services
|
|
231
|
+
import { BrainyVectorDB } from '@soulcraft/brainy'
|
|
232
|
+
|
|
233
|
+
// Activate Brain Cloud features with API key
|
|
234
|
+
const brain = new BrainyVectorDB({
|
|
235
|
+
cloud: { apiKey: process.env.BRAIN_CLOUD_KEY } // Optional
|
|
222
236
|
})
|
|
223
237
|
|
|
224
238
|
cortex.register(aiMemory) // AI remembers everything
|
package/bin/brainy.js
CHANGED
|
@@ -345,7 +345,7 @@ program
|
|
|
345
345
|
|
|
346
346
|
try {
|
|
347
347
|
// Test connection to Brain Cloud worker
|
|
348
|
-
const healthUrl = `https://brain-cloud
|
|
348
|
+
const healthUrl = `https://api.soulcraft.com/brain-cloud/health`
|
|
349
349
|
const response = await fetch(healthUrl, {
|
|
350
350
|
headers: { 'x-customer-id': options.connect }
|
|
351
351
|
})
|
|
@@ -357,7 +357,7 @@ program
|
|
|
357
357
|
console.log(chalk.gray(`⏰ Connected at: ${new Date(data.timestamp).toLocaleString()}`))
|
|
358
358
|
|
|
359
359
|
// Test memories endpoint
|
|
360
|
-
const memoriesResponse = await fetch(`https://brain-cloud
|
|
360
|
+
const memoriesResponse = await fetch(`https://api.soulcraft.com/brain-cloud/memories`, {
|
|
361
361
|
headers: { 'x-customer-id': options.connect }
|
|
362
362
|
})
|
|
363
363
|
|
|
@@ -384,7 +384,7 @@ program
|
|
|
384
384
|
console.log(chalk.green(`📦 Exporting data from Brain Cloud instance: ${options.export}`))
|
|
385
385
|
|
|
386
386
|
try {
|
|
387
|
-
const response = await fetch(`https://brain-cloud
|
|
387
|
+
const response = await fetch(`https://api.soulcraft.com/brain-cloud/export`, {
|
|
388
388
|
headers: { 'x-customer-id': options.export }
|
|
389
389
|
})
|
|
390
390
|
|
|
@@ -408,7 +408,7 @@ program
|
|
|
408
408
|
console.log(chalk.green(`🔍 Checking status of Brain Cloud instance: ${options.status}`))
|
|
409
409
|
|
|
410
410
|
try {
|
|
411
|
-
const response = await fetch(`https://brain-cloud
|
|
411
|
+
const response = await fetch(`https://api.soulcraft.com/brain-cloud/health`, {
|
|
412
412
|
headers: { 'x-customer-id': options.status }
|
|
413
413
|
})
|
|
414
414
|
|
|
@@ -419,7 +419,7 @@ program
|
|
|
419
419
|
console.log(chalk.gray(`⏰ Last check: ${new Date(data.timestamp).toLocaleString()}`))
|
|
420
420
|
|
|
421
421
|
// Get memory count
|
|
422
|
-
const memoriesResponse = await fetch(`https://brain-cloud
|
|
422
|
+
const memoriesResponse = await fetch(`https://api.soulcraft.com/brain-cloud/memories`, {
|
|
423
423
|
headers: { 'x-customer-id': options.status }
|
|
424
424
|
})
|
|
425
425
|
|
|
@@ -549,9 +549,12 @@ augment
|
|
|
549
549
|
output: process.stdout
|
|
550
550
|
})
|
|
551
551
|
|
|
552
|
-
console.log(chalk.cyan('
|
|
552
|
+
console.log(chalk.cyan('☁️ Brain Cloud Activation (Optional Premium)'))
|
|
553
553
|
console.log('')
|
|
554
|
-
console.log('
|
|
554
|
+
console.log(chalk.yellow('Note: Brainy core is 100% free and fully functional!'))
|
|
555
|
+
console.log('Brain Cloud adds optional team & sync features.')
|
|
556
|
+
console.log('')
|
|
557
|
+
console.log('Get Brain Cloud at: ' + chalk.green('app.soulcraft.com'))
|
|
555
558
|
console.log('(14-day free trial available)')
|
|
556
559
|
console.log('')
|
|
557
560
|
|
|
@@ -567,12 +570,12 @@ augment
|
|
|
567
570
|
|
|
568
571
|
console.log(chalk.green('✅ License saved!'))
|
|
569
572
|
console.log('')
|
|
570
|
-
console.log('
|
|
571
|
-
console.log(
|
|
573
|
+
console.log('// Brain Cloud is NOT an npm package!')
|
|
574
|
+
console.log('// Augmentations auto-load based on your subscription')
|
|
572
575
|
console.log('')
|
|
573
|
-
console.log('
|
|
574
|
-
console.log(chalk.
|
|
575
|
-
console.log(chalk.gray('
|
|
576
|
+
console.log('Next steps:')
|
|
577
|
+
console.log(chalk.cyan(' brainy cloud auth'))
|
|
578
|
+
console.log(chalk.gray(' # Your augmentations will auto-load'))
|
|
576
579
|
} else {
|
|
577
580
|
console.log(chalk.red('Invalid license key'))
|
|
578
581
|
}
|
|
@@ -915,7 +918,7 @@ async function detectCustomerId() {
|
|
|
915
918
|
const testIds = ['demo-test-auto', 'demo-test123']
|
|
916
919
|
for (const id of testIds) {
|
|
917
920
|
try {
|
|
918
|
-
const response = await fetch(`https://brain-cloud
|
|
921
|
+
const response = await fetch(`https://api.soulcraft.com/brain-cloud/health`, {
|
|
919
922
|
headers: { 'x-customer-id': id }
|
|
920
923
|
})
|
|
921
924
|
if (response.ok) {
|
|
@@ -947,7 +950,7 @@ async function setupBrainCloudMemory(customerId) {
|
|
|
947
950
|
args: ["brainy-mcp-server.js"],
|
|
948
951
|
env: {
|
|
949
952
|
CUSTOMER_ID: customerId,
|
|
950
|
-
BRAIN_CLOUD_URL: "https://brain-cloud
|
|
953
|
+
BRAIN_CLOUD_URL: "https://api.soulcraft.com/brain-cloud"
|
|
951
954
|
}
|
|
952
955
|
}
|
|
953
956
|
}
|
|
@@ -1001,7 +1004,7 @@ When working with multiple AI assistants, we automatically coordinate:
|
|
|
1001
1004
|
try {
|
|
1002
1005
|
const brainyConfig = {
|
|
1003
1006
|
brainCloudCustomerId: customerId,
|
|
1004
|
-
brainCloudUrl: 'https://brain-cloud
|
|
1007
|
+
brainCloudUrl: 'https://api.soulcraft.com/brain-cloud',
|
|
1005
1008
|
lastConnected: new Date().toISOString()
|
|
1006
1009
|
}
|
|
1007
1010
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart Model Loader - Zero Configuration ML Models
|
|
3
|
+
* Downloads models on-demand, caches intelligently
|
|
4
|
+
*/
|
|
5
|
+
export declare class SmartModelLoader {
|
|
6
|
+
private static readonly MODEL_SOURCES;
|
|
7
|
+
static loadModel(modelName: string): Promise<ArrayBuffer>;
|
|
8
|
+
private static tryLoadFrom;
|
|
9
|
+
private static cacheLocally;
|
|
10
|
+
private static generateFallbackModel;
|
|
11
|
+
}
|
|
12
|
+
export declare function getEmbedding(text: string): Promise<Float32Array>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart Model Loader - Zero Configuration ML Models
|
|
3
|
+
* Downloads models on-demand, caches intelligently
|
|
4
|
+
*/
|
|
5
|
+
export class SmartModelLoader {
|
|
6
|
+
static async loadModel(modelName) {
|
|
7
|
+
// Try each source in order
|
|
8
|
+
for (const source of this.MODEL_SOURCES) {
|
|
9
|
+
try {
|
|
10
|
+
const model = await this.tryLoadFrom(source, modelName);
|
|
11
|
+
if (model) {
|
|
12
|
+
await this.cacheLocally(model, modelName);
|
|
13
|
+
return model;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
continue; // Try next source
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// Fallback: Generate lightweight random embeddings
|
|
21
|
+
console.warn('Using fallback embeddings (reduced accuracy)');
|
|
22
|
+
return this.generateFallbackModel(modelName);
|
|
23
|
+
}
|
|
24
|
+
static async tryLoadFrom(source, model) {
|
|
25
|
+
if (source.startsWith('http')) {
|
|
26
|
+
// Download from CDN
|
|
27
|
+
const response = await fetch(`${source}/${model}`);
|
|
28
|
+
if (response.ok) {
|
|
29
|
+
return await response.arrayBuffer();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// Check local filesystem
|
|
34
|
+
try {
|
|
35
|
+
const fs = await import('fs');
|
|
36
|
+
return fs.readFileSync(`${source}/${model}`);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
static async cacheLocally(model, name) {
|
|
45
|
+
// Cache in best available location
|
|
46
|
+
if (typeof window !== 'undefined' && 'caches' in window) {
|
|
47
|
+
// Browser: Use Cache API
|
|
48
|
+
const cache = await caches.open('brainy-models');
|
|
49
|
+
await cache.put(name, new Response(model));
|
|
50
|
+
}
|
|
51
|
+
else if (typeof process !== 'undefined') {
|
|
52
|
+
// Node: Use filesystem cache
|
|
53
|
+
const fs = await import('fs');
|
|
54
|
+
const path = await import('path');
|
|
55
|
+
const cacheDir = path.join(process.env.HOME || '', '.brainy', 'models');
|
|
56
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
57
|
+
fs.writeFileSync(path.join(cacheDir, name), Buffer.from(model));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
static generateFallbackModel(name) {
|
|
61
|
+
// Deterministic "random" embeddings based on input
|
|
62
|
+
// Good enough for development/testing
|
|
63
|
+
const seed = name.split('').reduce((a, b) => a + b.charCodeAt(0), 0);
|
|
64
|
+
const model = new Float32Array(384); // Standard embedding size
|
|
65
|
+
for (let i = 0; i < model.length; i++) {
|
|
66
|
+
model[i] = Math.sin(seed * (i + 1)) * 0.1;
|
|
67
|
+
}
|
|
68
|
+
return model.buffer;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
SmartModelLoader.MODEL_SOURCES = [
|
|
72
|
+
// 1. Check if bundled locally
|
|
73
|
+
'./models',
|
|
74
|
+
'../models',
|
|
75
|
+
// 2. Check user's cache
|
|
76
|
+
'~/.brainy/models',
|
|
77
|
+
// 3. Check CDN (fast, free)
|
|
78
|
+
'https://cdn.jsdelivr.net/npm/@brainy/models@latest',
|
|
79
|
+
'https://unpkg.com/@brainy/models',
|
|
80
|
+
// 4. Check Hugging Face (original source)
|
|
81
|
+
'https://huggingface.co/Xenova/all-MiniLM-L6-v2/resolve/main'
|
|
82
|
+
];
|
|
83
|
+
// Usage - Zero configuration required!
|
|
84
|
+
export async function getEmbedding(text) {
|
|
85
|
+
const model = await SmartModelLoader.loadModel('encoder.onnx');
|
|
86
|
+
// ... use model
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=modelLoader.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "0.62.
|
|
3
|
+
"version": "0.62.1",
|
|
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",
|