@soulcraft/brainy 0.9.36 → 0.9.37

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +1 -1
  3. package/dist/augmentationFactory.d.ts +0 -1
  4. package/dist/augmentationPipeline.d.ts +0 -1
  5. package/dist/augmentationRegistry.d.ts +0 -1
  6. package/dist/augmentationRegistryLoader.d.ts +0 -1
  7. package/dist/augmentations/conduitAugmentations.d.ts +0 -1
  8. package/dist/augmentations/memoryAugmentations.d.ts +0 -1
  9. package/dist/augmentations/serverSearchAugmentations.d.ts +0 -1
  10. package/dist/brainy.js +338 -28
  11. package/dist/brainy.min.js +749 -748
  12. package/dist/brainyData.d.ts +0 -1
  13. package/dist/coreTypes.d.ts +0 -1
  14. package/dist/examples/basicUsage.d.ts +0 -1
  15. package/dist/hnsw/hnswIndex.d.ts +0 -1
  16. package/dist/hnsw/hnswIndexOptimized.d.ts +0 -1
  17. package/dist/index.d.ts +2 -2
  18. package/dist/mcp/brainyMCPAdapter.d.ts +0 -1
  19. package/dist/mcp/brainyMCPService.d.ts +0 -1
  20. package/dist/mcp/index.d.ts +0 -1
  21. package/dist/mcp/mcpAugmentationToolset.d.ts +0 -1
  22. package/dist/pipeline.d.ts +0 -1
  23. package/dist/sequentialPipeline.d.ts +0 -1
  24. package/dist/storage/fileSystemStorage.d.ts +0 -1
  25. package/dist/storage/opfsStorage.d.ts +0 -1
  26. package/dist/storage/opfsStorage.d.ts.map +1 -1
  27. package/dist/storage/s3CompatibleStorage.d.ts +0 -1
  28. package/dist/types/augmentations.d.ts +0 -1
  29. package/dist/types/brainyDataInterface.d.ts +0 -1
  30. package/dist/types/fileSystemTypes.d.ts +0 -1
  31. package/dist/types/graphTypes.d.ts +0 -1
  32. package/dist/types/mcpTypes.d.ts +0 -1
  33. package/dist/types/pipelineTypes.d.ts +0 -1
  34. package/dist/types/tensorflowTypes.d.ts +0 -1
  35. package/dist/unified.d.ts +0 -1
  36. package/dist/unified.js +339 -29
  37. package/dist/unified.min.js +749 -748
  38. package/dist/utils/distance.d.ts +0 -1
  39. package/dist/utils/embedding.d.ts +0 -1
  40. package/dist/utils/environment.d.ts +0 -1
  41. package/dist/utils/index.d.ts +0 -1
  42. package/dist/utils/tensorflowUtils.d.ts +0 -1
  43. package/dist/utils/tensorflowUtils.d.ts.map +1 -1
  44. package/dist/utils/textEncoderPolyfill.d.ts +6 -0
  45. package/dist/utils/textEncoderPolyfill.d.ts.map +1 -0
  46. package/dist/utils/textEncoding.d.ts +67 -0
  47. package/dist/utils/textEncoding.d.ts.map +1 -0
  48. package/dist/utils/version.d.ts +1 -2
  49. package/dist/utils/workerUtils.d.ts +0 -1
  50. package/dist/utils/workerUtils.d.ts.map +1 -1
  51. package/dist/worker.d.ts +1 -0
  52. package/package.json +6 -5
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.9.36] - 2025-07-04
6
+
7
+ **Full Changelog**: https://github.com/soulcraft-research/brainy/commits/v0.9.36
8
+
5
9
  ## [0.9.34] - 2024-07-01
6
10
 
7
11
  This is the initial changelog entry. Future releases will automatically update this file with release notes from GitHub.
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  [![Node.js](https://img.shields.io/badge/node-%3E%3D24.3.0-brightgreen.svg)](https://nodejs.org/)
7
7
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.4.5-blue.svg)](https://www.typescriptlang.org/)
8
8
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)
9
- [![npm](https://img.shields.io/badge/npm-v0.9.36-blue.svg)](https://www.npmjs.com/package/@soulcraft/brainy)
9
+ [![npm](https://img.shields.io/badge/npm-v0.9.37-blue.svg)](https://www.npmjs.com/package/@soulcraft/brainy)
10
10
 
11
11
  [//]: # ([![Cartographer](https://img.shields.io/badge/Cartographer-Official%20Standard-brightgreen)](https://github.com/sodal-project/cartographer))
12
12
 
@@ -84,4 +84,3 @@ export declare function loadAugmentationModule(modulePromise: Promise<any>, opti
84
84
  autoRegister?: boolean;
85
85
  autoInitialize?: boolean;
86
86
  }): Promise<IAugmentation[]>;
87
- //# sourceMappingURL=augmentationFactory.d.ts.map
@@ -202,4 +202,3 @@ export declare class AugmentationPipeline {
202
202
  private executeTypedPipeline;
203
203
  }
204
204
  export declare const augmentationPipeline: AugmentationPipeline;
205
- //# sourceMappingURL=augmentationPipeline.d.ts.map
@@ -45,4 +45,3 @@ export declare function setAugmentationEnabled(name: string, enabled: boolean):
45
45
  * @returns An array of all augmentations of the specified type
46
46
  */
47
47
  export declare function getAugmentationsByType(type: AugmentationType): IAugmentation[];
48
- //# sourceMappingURL=augmentationRegistry.d.ts.map
@@ -144,4 +144,3 @@ export declare function createAugmentationRegistryRollupPlugin(options: {
144
144
  pattern: RegExp;
145
145
  options: AugmentationRegistryLoaderOptions;
146
146
  };
147
- //# sourceMappingURL=augmentationRegistryLoader.d.ts.map
@@ -170,4 +170,3 @@ export declare class WebRTCConduitAugmentation extends BaseConduitAugmentation i
170
170
  */
171
171
  export declare function createConduitAugmentation(type: 'websocket' | 'webrtc', name?: string, options?: Record<string, unknown>): Promise<IConduitAugmentation & IWebSocketSupport>;
172
172
  export {};
173
- //# sourceMappingURL=conduitAugmentations.d.ts.map
@@ -68,4 +68,3 @@ export declare function createMemoryAugmentation(name: string, options?: {
68
68
  requestPersistentStorage?: boolean;
69
69
  }): Promise<IMemoryAugmentation>;
70
70
  export {};
71
- //# sourceMappingURL=memoryAugmentations.d.ts.map
@@ -165,4 +165,3 @@ export declare function createServerSearchAugmentations(serverUrl: string, optio
165
165
  activation: ServerSearchActivationAugmentation;
166
166
  connection: WebSocketConnection;
167
167
  }>;
168
- //# sourceMappingURL=serverSearchAugmentations.d.ts.map
package/dist/brainy.js CHANGED
@@ -2396,6 +2396,137 @@ ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
2396
2396
  }
2397
2397
  } (buffer$1));
2398
2398
 
2399
+ /**
2400
+ * Unified Text Encoding Utilities
2401
+ *
2402
+ * This module provides a consistent way to handle text encoding/decoding across all environments
2403
+ * without relying on TextEncoder/TextDecoder polyfills or patches.
2404
+ */
2405
+ /**
2406
+ * A simple text encoder that works in all environments
2407
+ * This avoids the need for TextEncoder polyfills and patches
2408
+ */
2409
+ class SimpleTextEncoder {
2410
+ /**
2411
+ * Encode a string to a Uint8Array
2412
+ * @param input - The string to encode
2413
+ * @returns A Uint8Array containing the encoded string
2414
+ */
2415
+ encode(input) {
2416
+ // Simple UTF-8 encoding implementation that works everywhere
2417
+ return new Uint8Array([...input].map((c) => c.charCodeAt(0)));
2418
+ }
2419
+ }
2420
+ /**
2421
+ * A simple text decoder that works in all environments
2422
+ * This avoids the need for TextDecoder polyfills and patches
2423
+ */
2424
+ class SimpleTextDecoder {
2425
+ /**
2426
+ * Decode a Uint8Array to a string
2427
+ * @param input - The Uint8Array to decode
2428
+ * @returns The decoded string
2429
+ */
2430
+ decode(input) {
2431
+ // Simple UTF-8 decoding implementation that works everywhere
2432
+ return String.fromCharCode.apply(null, [...input]);
2433
+ }
2434
+ }
2435
+ /**
2436
+ * A constructor function for TextEncoder that works in all environments
2437
+ */
2438
+ function UniversalTextEncoder() {
2439
+ if (!(this instanceof UniversalTextEncoder)) {
2440
+ return new UniversalTextEncoder();
2441
+ }
2442
+ try {
2443
+ // Try to use the native TextEncoder if available
2444
+ const nativeEncoder = new TextEncoder();
2445
+ this.encode = nativeEncoder.encode.bind(nativeEncoder);
2446
+ }
2447
+ catch (e) {
2448
+ // Fall back to our simple implementation
2449
+ const simpleEncoder = new SimpleTextEncoder();
2450
+ this.encode = simpleEncoder.encode.bind(simpleEncoder);
2451
+ }
2452
+ }
2453
+ /**
2454
+ * A constructor function for TextDecoder that works in all environments
2455
+ */
2456
+ function UniversalTextDecoder() {
2457
+ if (!(this instanceof UniversalTextDecoder)) {
2458
+ return new UniversalTextDecoder();
2459
+ }
2460
+ try {
2461
+ // Try to use the native TextDecoder if available
2462
+ const nativeDecoder = new TextDecoder();
2463
+ this.decode = nativeDecoder.decode.bind(nativeDecoder);
2464
+ }
2465
+ catch (e) {
2466
+ // Fall back to our simple implementation
2467
+ const simpleDecoder = new SimpleTextDecoder();
2468
+ this.decode = simpleDecoder.decode.bind(simpleDecoder);
2469
+ }
2470
+ }
2471
+ /**
2472
+ * Get a text encoder that works in the current environment
2473
+ * @returns A text encoder object with an encode method
2474
+ */
2475
+ function getTextEncoder() {
2476
+ return new UniversalTextEncoder();
2477
+ }
2478
+ /**
2479
+ * Get a text decoder that works in the current environment
2480
+ * @returns A text decoder object with a decode method
2481
+ */
2482
+ function getTextDecoder() {
2483
+ return new UniversalTextDecoder();
2484
+ }
2485
+ /**
2486
+ * Apply the TensorFlow.js platform patch if needed
2487
+ * This function patches the global object to provide a PlatformNode class
2488
+ * that uses our text encoding utilities instead of relying on TextEncoder/TextDecoder
2489
+ */
2490
+ function applyTensorFlowPatch() {
2491
+ // Only apply in Node.js environment
2492
+ if (typeof global !== 'undefined' &&
2493
+ typeof process !== 'undefined' &&
2494
+ process.versions &&
2495
+ process.versions.node) {
2496
+ try {
2497
+ // Get encoders/decoders
2498
+ const encoder = getTextEncoder();
2499
+ const decoder = getTextDecoder();
2500
+ // Define a custom PlatformNode class
2501
+ class PlatformNode {
2502
+ constructor() {
2503
+ // Create a util object with necessary methods and constructors
2504
+ this.util = {
2505
+ isFloat32Array: (arr) => !!(arr instanceof Float32Array ||
2506
+ (arr &&
2507
+ Object.prototype.toString.call(arr) ===
2508
+ '[object Float32Array]')),
2509
+ isTypedArray: (arr) => !!(ArrayBuffer.isView(arr) && !(arr instanceof DataView)),
2510
+ // Add TextEncoder and TextDecoder as constructors
2511
+ TextEncoder: UniversalTextEncoder,
2512
+ TextDecoder: UniversalTextDecoder
2513
+ };
2514
+ // Initialize using the constructors from util
2515
+ this.textEncoder = new this.util.TextEncoder();
2516
+ this.textDecoder = new this.util.TextDecoder();
2517
+ }
2518
+ }
2519
+ // Assign the PlatformNode class to the global object
2520
+ ;
2521
+ global.PlatformNode = PlatformNode;
2522
+ global.platformNode = new PlatformNode();
2523
+ }
2524
+ catch (error) {
2525
+ console.warn('Failed to apply TensorFlow.js platform patch:', error);
2526
+ }
2527
+ }
2528
+ }
2529
+
2399
2530
  // Unique ID creation requires a high quality random # generator. In the browser we therefore
2400
2531
  // require the crypto API and do not support built-in fallback to lower quality random number
2401
2532
  // generators (like Math.random()).
@@ -2688,12 +2819,35 @@ function isNode() {
2688
2819
  process.versions != null &&
2689
2820
  process.versions.node != null);
2690
2821
  }
2822
+ /**
2823
+ * Check if code is running in a Web Worker environment
2824
+ */
2825
+ function isWebWorker() {
2826
+ return (typeof self === 'object' &&
2827
+ self.constructor &&
2828
+ self.constructor.name === 'DedicatedWorkerGlobalScope');
2829
+ }
2691
2830
  /**
2692
2831
  * Check if Web Workers are available in the current environment
2693
2832
  */
2694
2833
  function areWebWorkersAvailable() {
2695
2834
  return isBrowser$1() && typeof Worker !== 'undefined';
2696
2835
  }
2836
+ /**
2837
+ * Check if Worker Threads are available in the current environment (Node.js)
2838
+ */
2839
+ async function areWorkerThreadsAvailable() {
2840
+ if (!isNode())
2841
+ return false;
2842
+ try {
2843
+ // Use dynamic import to avoid errors in browser environments
2844
+ await import('worker_threads');
2845
+ return true;
2846
+ }
2847
+ catch (e) {
2848
+ return false;
2849
+ }
2850
+ }
2697
2851
  /**
2698
2852
  * Synchronous version that doesn't actually try to load the module
2699
2853
  * This is safer in ES module environments
@@ -2711,6 +2865,12 @@ function areWorkerThreadsAvailableSync() {
2711
2865
  function isThreadingAvailable() {
2712
2866
  return areWebWorkersAvailable() || areWorkerThreadsAvailableSync();
2713
2867
  }
2868
+ /**
2869
+ * Async version of isThreadingAvailable
2870
+ */
2871
+ async function isThreadingAvailableAsync() {
2872
+ return areWebWorkersAvailable() || (await areWorkerThreadsAvailable());
2873
+ }
2714
2874
 
2715
2875
  /**
2716
2876
  * Utility functions for executing functions in Worker Threads (Node.js) or Web Workers (Browser)
@@ -2736,7 +2896,31 @@ function executeInThread(fnString, args) {
2736
2896
  else {
2737
2897
  // Fallback to main thread execution
2738
2898
  try {
2739
- const fn = new Function('return ' + fnString)();
2899
+ // Try different approaches to create a function from string
2900
+ let fn;
2901
+ try {
2902
+ // First try with 'return' prefix
2903
+ fn = new Function('return ' + fnString)();
2904
+ }
2905
+ catch (functionError) {
2906
+ console.warn('Fallback: Error creating function with return syntax, trying alternative approaches', functionError);
2907
+ try {
2908
+ // Try wrapping in parentheses for function expressions
2909
+ fn = new Function('return (' + fnString + ')')();
2910
+ }
2911
+ catch (wrapError) {
2912
+ console.warn('Fallback: Error creating function with parentheses wrapping', wrapError);
2913
+ try {
2914
+ // Try direct approach for named functions
2915
+ fn = new Function(fnString)();
2916
+ }
2917
+ catch (directError) {
2918
+ console.error('Fallback: All approaches to create function failed', directError);
2919
+ throw new Error('Failed to create function from string: ' +
2920
+ functionError.message);
2921
+ }
2922
+ }
2923
+ }
2740
2924
  return Promise.resolve(fn(args));
2741
2925
  }
2742
2926
  catch (error) {
@@ -2752,7 +2936,8 @@ function executeInNodeWorker(fnString, args) {
2752
2936
  return new Promise((resolve, reject) => {
2753
2937
  try {
2754
2938
  // Dynamically import worker_threads (Node.js only)
2755
- import('node:worker_threads').then(({ Worker, isMainThread, parentPort, workerData }) => {
2939
+ import('node:worker_threads')
2940
+ .then(({ Worker, isMainThread, parentPort, workerData }) => {
2756
2941
  if (!isMainThread && parentPort) {
2757
2942
  // We're inside a worker, execute the function
2758
2943
  const fn = new Function('return ' + workerData.fnString)();
@@ -2811,7 +2996,8 @@ function executeInNodeWorker(fnString, args) {
2811
2996
  reject(new Error(`Worker stopped with exit code ${code}`));
2812
2997
  }
2813
2998
  });
2814
- }).catch(reject);
2999
+ })
3000
+ .catch(reject);
2815
3001
  }
2816
3002
  catch (error) {
2817
3003
  reject(error);
@@ -2824,21 +3010,131 @@ function executeInNodeWorker(fnString, args) {
2824
3010
  function executeInWebWorker(fnString, args) {
2825
3011
  return new Promise((resolve, reject) => {
2826
3012
  try {
2827
- const workerCode = `
2828
- self.onmessage = function(e) {
2829
- try {
2830
- const fn = new Function('return ' + e.data.fnString)();
2831
- const result = fn(e.data.args);
2832
- self.postMessage({ result: result });
2833
- } catch (error) {
2834
- self.postMessage({ error: error.message });
2835
- }
2836
- };
2837
- `;
2838
- const blob = new Blob([workerCode], { type: 'application/javascript' });
2839
- const url = URL.createObjectURL(blob);
2840
- const worker = new Worker(url);
3013
+ // Use the dedicated worker.js file instead of creating a blob
3014
+ // Try different approaches to locate the worker.js file
3015
+ let workerPath = './worker.js';
3016
+ try {
3017
+ // First try to use the import.meta.url if available (modern browsers)
3018
+ if (typeof import.meta !== 'undefined' && import.meta.url) {
3019
+ const baseUrl = import.meta.url.substring(0, import.meta.url.lastIndexOf('/') + 1);
3020
+ workerPath = `${baseUrl}worker.js`;
3021
+ }
3022
+ // Fallback to a relative path based on the unified.js location
3023
+ else if (typeof document !== 'undefined') {
3024
+ // Find the script tag that loaded unified.js
3025
+ const scripts = document.getElementsByTagName('script');
3026
+ for (let i = 0; i < scripts.length; i++) {
3027
+ const src = scripts[i].src;
3028
+ if (src && src.includes('unified.js')) {
3029
+ // Get the directory path
3030
+ workerPath =
3031
+ src.substring(0, src.lastIndexOf('/') + 1) + 'worker.js';
3032
+ break;
3033
+ }
3034
+ }
3035
+ }
3036
+ }
3037
+ catch (e) {
3038
+ console.warn('Could not determine worker path from import.meta.url, using relative path', e);
3039
+ }
3040
+ // If we couldn't determine the path, try some common locations
3041
+ if (workerPath === './worker.js' && typeof window !== 'undefined') {
3042
+ // Try to find the worker.js in the same directory as the current page
3043
+ const pageUrl = window.location.href;
3044
+ const pageDir = pageUrl.substring(0, pageUrl.lastIndexOf('/') + 1);
3045
+ workerPath = `${pageDir}worker.js`;
3046
+ // Also check for dist/worker.js
3047
+ if (typeof document !== 'undefined') {
3048
+ const distWorkerPath = `${pageDir}dist/worker.js`;
3049
+ // Create a test request to see if the file exists
3050
+ const xhr = new XMLHttpRequest();
3051
+ xhr.open('HEAD', distWorkerPath, false);
3052
+ try {
3053
+ xhr.send();
3054
+ if (xhr.status >= 200 && xhr.status < 300) {
3055
+ workerPath = distWorkerPath;
3056
+ }
3057
+ }
3058
+ catch (e) {
3059
+ // Ignore errors, we'll use the default path
3060
+ }
3061
+ }
3062
+ }
3063
+ console.log('Using worker path:', workerPath);
3064
+ // Try to create a worker, but fall back to inline worker or main thread execution if it fails
3065
+ let worker;
3066
+ try {
3067
+ worker = new Worker(workerPath);
3068
+ }
3069
+ catch (error) {
3070
+ console.warn('Failed to create Web Worker from file, trying inline worker:', error);
3071
+ try {
3072
+ // Create an inline worker using a Blob
3073
+ const workerCode = `
3074
+ // Brainy Inline Worker Script
3075
+ console.log('Brainy Inline Worker: Started');
3076
+
3077
+ self.onmessage = function (e) {
3078
+ try {
3079
+ console.log('Brainy Inline Worker: Received message', e.data ? 'with data' : 'without data');
3080
+
3081
+ if (!e.data || !e.data.fnString) {
3082
+ throw new Error('Invalid message: missing function string');
3083
+ }
3084
+
3085
+ console.log('Brainy Inline Worker: Creating function from string');
3086
+ const fn = new Function('return ' + e.data.fnString)();
3087
+
3088
+ console.log('Brainy Inline Worker: Executing function with args');
3089
+ const result = fn(e.data.args);
3090
+
3091
+ console.log('Brainy Inline Worker: Function executed successfully, posting result');
3092
+ self.postMessage({ result: result });
3093
+ } catch (error) {
3094
+ console.error('Brainy Inline Worker: Error executing function', error);
3095
+ self.postMessage({
3096
+ error: error.message,
3097
+ stack: error.stack
3098
+ });
3099
+ }
3100
+ };
3101
+ `;
3102
+ const blob = new Blob([workerCode], {
3103
+ type: 'application/javascript'
3104
+ });
3105
+ const blobUrl = URL.createObjectURL(blob);
3106
+ worker = new Worker(blobUrl);
3107
+ console.log('Created inline worker using Blob URL');
3108
+ }
3109
+ catch (inlineWorkerError) {
3110
+ console.warn('Failed to create inline Web Worker, falling back to main thread execution:', inlineWorkerError);
3111
+ // Execute in main thread as fallback
3112
+ try {
3113
+ const fn = new Function('return ' + fnString)();
3114
+ resolve(fn(args));
3115
+ return;
3116
+ }
3117
+ catch (mainThreadError) {
3118
+ reject(mainThreadError);
3119
+ return;
3120
+ }
3121
+ }
3122
+ }
3123
+ // Set a timeout to prevent hanging
3124
+ const timeoutId = setTimeout(() => {
3125
+ console.warn('Web Worker execution timed out, falling back to main thread');
3126
+ worker.terminate();
3127
+ // Execute in main thread as fallback
3128
+ try {
3129
+ const fn = new Function('return ' + fnString)();
3130
+ resolve(fn(args));
3131
+ }
3132
+ catch (mainThreadError) {
3133
+ reject(mainThreadError);
3134
+ }
3135
+ }, 25000); // 25 second timeout (less than the 30 second test timeout)
2841
3136
  worker.onmessage = function (e) {
3137
+ clearTimeout(timeoutId);
2842
3138
  if (e.data.error) {
2843
3139
  reject(new Error(e.data.error));
2844
3140
  }
@@ -2846,12 +3142,19 @@ function executeInWebWorker(fnString, args) {
2846
3142
  resolve(e.data.result);
2847
3143
  }
2848
3144
  worker.terminate();
2849
- URL.revokeObjectURL(url);
2850
3145
  };
2851
3146
  worker.onerror = function (e) {
2852
- reject(new Error(`Worker error: ${e.message}`));
3147
+ clearTimeout(timeoutId);
3148
+ console.warn('Web Worker error, falling back to main thread execution:', e.message);
2853
3149
  worker.terminate();
2854
- URL.revokeObjectURL(url);
3150
+ // Execute in main thread as fallback
3151
+ try {
3152
+ const fn = new Function('return ' + fnString)();
3153
+ resolve(fn(args));
3154
+ }
3155
+ catch (mainThreadError) {
3156
+ reject(mainThreadError);
3157
+ }
2855
3158
  };
2856
3159
  worker.postMessage({ fnString, args });
2857
3160
  }
@@ -2866,13 +3169,15 @@ function executeInWebWorker(fnString, args) {
2866
3169
  */
2867
3170
  function cleanupWorkerPools() {
2868
3171
  if (isNode()) {
2869
- import('node:worker_threads').then(({ Worker }) => {
3172
+ import('node:worker_threads')
3173
+ .then(({ Worker }) => {
2870
3174
  for (const worker of workerPool.values()) {
2871
3175
  worker.terminate();
2872
3176
  }
2873
3177
  workerPool.clear();
2874
3178
  console.log('Worker pools cleaned up');
2875
- }).catch(console.error);
3179
+ })
3180
+ .catch(console.error);
2876
3181
  }
2877
3182
  }
2878
3183
 
@@ -13890,15 +14195,20 @@ class BrainyMCPService {
13890
14195
  }
13891
14196
  }
13892
14197
 
14198
+ /**
14199
+ * OPFS BrainyData
14200
+ * A vector database using HNSW indexing with Origin Private File System storage
14201
+ */
14202
+ // Import unified text encoding utilities first to ensure they're available
14203
+ // Apply the TensorFlow.js platform patch if needed
14204
+ applyTensorFlowPatch();
14205
+
13893
14206
  // Make Buffer available globally
13894
14207
  if (typeof window !== 'undefined' && typeof globalThis.Buffer === 'undefined') {
13895
14208
  globalThis.Buffer = buffer$1.Buffer;
13896
14209
  }
13897
- /**
13898
- * Unified entry point for Brainy
13899
- * This file exports everything from index.ts
13900
- * Environment detection is handled here and made available to all components
13901
- */
14210
+ // Apply the TensorFlow.js platform patch if needed
14211
+ applyTensorFlowPatch();
13902
14212
  // Export environment information
13903
14213
  const environment = {
13904
14214
  isBrowser: typeof window !== 'undefined',
@@ -87227,5 +87537,5 @@ var _child_processShim = /*#__PURE__*/Object.freeze({
87227
87537
  __proto__: null
87228
87538
  });
87229
87539
 
87230
- export { AugmentationType, BrainyData, BrainyMCPAdapter, BrainyMCPService, ExecutionMode$1 as ExecutionMode, FileSystemStorage, FileSystemStorageAugmentation, HNSWIndex, HNSWIndexOptimized, MCPAugmentationToolset, MCPRequestType, MCP_VERSION, MemoryStorage, MemoryStorageAugmentation, NounType, OPFSStorage, OPFSStorageAugmentation, Pipeline, S3CompatibleStorage as R2Storage, S3CompatibleStorage, SequentialPipeline, ServerSearchActivationAugmentation, ServerSearchConduitAugmentation, StreamlinedExecutionMode, UniversalSentenceEncoder$1 as UniversalSentenceEncoder, VerbType, WebRTCConduitAugmentation, WebSocketConduitAugmentation, addWebSocketSupport, augmentationPipeline$1 as augmentationPipeline, availableAugmentations, cleanupWorkerPools, cosineDistance$1 as cosineDistance, createAugmentationRegistryPlugin, createAugmentationRegistryRollupPlugin, createConduitAugmentation, createEmbeddingFunction, createMemoryAugmentation, createPipeline, createSenseAugmentation, createServerSearchAugmentations, createStorage, createStreamingPipeline, createTensorFlowEmbeddingFunction, createThreadedEmbeddingFunction, defaultEmbeddingFunction, dotProductDistance, environment, euclideanDistance, executeAugmentation, executeByType, executeInThread, executeSingle, executeStreamlined, getAugmentationsByType, initializeAugmentationPipeline, loadAugmentationModule, loadAugmentationsFromModules, manhattanDistance, pipeline, processStaticData, processStreamingData, registerAugmentation, sequentialPipeline, setAugmentationEnabled };
87540
+ export { AugmentationType, BrainyData, BrainyMCPAdapter, BrainyMCPService, ExecutionMode$1 as ExecutionMode, FileSystemStorage, FileSystemStorageAugmentation, HNSWIndex, HNSWIndexOptimized, MCPAugmentationToolset, MCPRequestType, MCP_VERSION, MemoryStorage, MemoryStorageAugmentation, NounType, OPFSStorage, OPFSStorageAugmentation, Pipeline, S3CompatibleStorage as R2Storage, S3CompatibleStorage, SequentialPipeline, ServerSearchActivationAugmentation, ServerSearchConduitAugmentation, StreamlinedExecutionMode, UniversalSentenceEncoder$1 as UniversalSentenceEncoder, VerbType, WebRTCConduitAugmentation, WebSocketConduitAugmentation, addWebSocketSupport, areWebWorkersAvailable, areWorkerThreadsAvailable, areWorkerThreadsAvailableSync, augmentationPipeline$1 as augmentationPipeline, availableAugmentations, cleanupWorkerPools, cosineDistance$1 as cosineDistance, createAugmentationRegistryPlugin, createAugmentationRegistryRollupPlugin, createConduitAugmentation, createEmbeddingFunction, createMemoryAugmentation, createPipeline, createSenseAugmentation, createServerSearchAugmentations, createStorage, createStreamingPipeline, createTensorFlowEmbeddingFunction, createThreadedEmbeddingFunction, defaultEmbeddingFunction, dotProductDistance, environment, euclideanDistance, executeAugmentation, executeByType, executeInThread, executeSingle, executeStreamlined, getAugmentationsByType, initializeAugmentationPipeline, isBrowser$1 as isBrowser, isNode, isThreadingAvailable, isThreadingAvailableAsync, isWebWorker, loadAugmentationModule, loadAugmentationsFromModules, manhattanDistance, pipeline, processStaticData, processStreamingData, registerAugmentation, sequentialPipeline, setAugmentationEnabled };
87231
87541
  //# sourceMappingURL=brainy.js.map