@soulcraft/brainy 2.6.0 → 2.7.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 CHANGED
@@ -71,6 +71,18 @@ const filtered = await brain.find({
71
71
  })
72
72
  ```
73
73
 
74
+ ## 📋 System Requirements
75
+
76
+ **Node.js Version:** 22 LTS or later (recommended)
77
+
78
+ - ✅ **Node.js 22 LTS** - Fully supported and recommended for production
79
+ - ✅ **Node.js 20 LTS** - Compatible (maintenance mode)
80
+ - ❌ **Node.js 24** - Not supported (known ONNX runtime compatibility issues)
81
+
82
+ > **Important:** Brainy uses ONNX runtime for AI embeddings. Node.js 24 has known compatibility issues that cause crashes during inference operations. We recommend Node.js 22 LTS for maximum stability.
83
+
84
+ If using nvm: `nvm use` (we provide a `.nvmrc` file)
85
+
74
86
  ## 🚀 Key Features
75
87
 
76
88
  ### World's First Triple Intelligence™ Engine
@@ -23,7 +23,7 @@ export declare class UniversalMemoryManager {
23
23
  embed(data: string | string[]): Promise<Vector>;
24
24
  private checkMemoryLimits;
25
25
  private ensureEmbeddingFunction;
26
- private initNodeWorker;
26
+ private initNodeDirect;
27
27
  private initServerless;
28
28
  private initBrowser;
29
29
  private initFallback;
@@ -13,18 +13,21 @@ const isServerless = typeof process !== 'undefined' && (process.env.VERCEL ||
13
13
  process.env.FUNCTIONS_WORKER_RUNTIME);
14
14
  export class UniversalMemoryManager {
15
15
  constructor() {
16
+ // CRITICAL FIX: Never use worker threads with ONNX Runtime
17
+ // Worker threads cause HandleScope V8 API errors due to isolate issues
18
+ // Always use direct embedding on main thread for ONNX compatibility
16
19
  this.embeddingFunction = null;
17
20
  this.embedCount = 0;
18
21
  this.restartCount = 0;
19
22
  this.lastRestart = 0;
20
- // Choose strategy based on environment
21
23
  if (isServerless) {
22
24
  this.strategy = 'serverless-restart';
23
25
  this.maxEmbeddings = 50; // Restart frequently in serverless
24
26
  }
25
27
  else if (isNode && !isBrowser) {
26
- this.strategy = 'node-worker';
27
- this.maxEmbeddings = 100; // Worker can handle more
28
+ // CHANGED: Use direct strategy instead of node-worker to avoid V8 isolate issues
29
+ this.strategy = 'node-direct';
30
+ this.maxEmbeddings = 200; // Main thread can handle more with single model instance
28
31
  }
29
32
  else if (isBrowser) {
30
33
  this.strategy = 'browser-dispose';
@@ -35,6 +38,7 @@ export class UniversalMemoryManager {
35
38
  this.maxEmbeddings = 75;
36
39
  }
37
40
  console.log(`🧠 Universal Memory Manager: Using ${this.strategy} strategy`);
41
+ console.log('✅ UNIVERSAL: Memory-safe embedding system initialized');
38
42
  }
39
43
  async getEmbeddingFunction() {
40
44
  return async (data) => {
@@ -62,8 +66,8 @@ export class UniversalMemoryManager {
62
66
  return;
63
67
  }
64
68
  switch (this.strategy) {
65
- case 'node-worker':
66
- await this.initNodeWorker();
69
+ case 'node-direct':
70
+ await this.initNodeDirect();
67
71
  break;
68
72
  case 'serverless-restart':
69
73
  await this.initServerless();
@@ -75,19 +79,12 @@ export class UniversalMemoryManager {
75
79
  await this.initFallback();
76
80
  }
77
81
  }
78
- async initNodeWorker() {
82
+ async initNodeDirect() {
79
83
  if (isNode) {
80
- try {
81
- // Try to use worker threads if available
82
- const { workerEmbeddingManager } = await import('./worker-manager.js');
83
- this.embeddingFunction = workerEmbeddingManager;
84
- console.log('✅ Using Node.js worker threads for embeddings');
85
- }
86
- catch (error) {
87
- console.warn('⚠️ Worker threads not available, falling back to direct embedding');
88
- console.warn('Error:', error instanceof Error ? error.message : String(error));
89
- await this.initDirect();
90
- }
84
+ // CRITICAL: Use direct embedding to avoid worker thread V8 isolate issues
85
+ // This prevents HandleScope errors and ensures single model instance
86
+ console.log('✅ Using Node.js direct embedding (main thread - ONNX compatible)');
87
+ await this.initDirect();
91
88
  }
92
89
  }
93
90
  async initServerless() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "2.6.0",
3
+ "version": "2.7.1",
4
4
  "description": "Universal Knowledge Protocol™ - World's first Triple Intelligence database unifying vector, graph, and document search in one API. 31 nouns × 40 verbs for infinite expressiveness.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -55,7 +55,7 @@
55
55
  }
56
56
  },
57
57
  "engines": {
58
- "node": ">=18.0.0"
58
+ "node": ">=22.0.0"
59
59
  },
60
60
  "scripts": {
61
61
  "build": "npm run build:patterns:if-needed && tsc",