@soulcraft/brainy 0.9.35 → 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
@@ -506,4 +506,3 @@ export declare class BrainyData<T = any> implements BrainyDataInterface<T> {
506
506
  }>;
507
507
  }
508
508
  export { euclideanDistance, cosineDistance, manhattanDistance, dotProductDistance } from './utils/index.js';
509
- //# sourceMappingURL=brainyData.d.ts.map
@@ -128,4 +128,3 @@ export interface StorageAdapter {
128
128
  details?: Record<string, any>;
129
129
  }>;
130
130
  }
131
- //# sourceMappingURL=coreTypes.d.ts.map
@@ -2,4 +2,3 @@
2
2
  * Basic usage example for the Soulcraft Brainy database
3
3
  */
4
4
  export {};
5
- //# sourceMappingURL=basicUsage.d.ts.map
@@ -95,4 +95,3 @@ export declare class HNSWIndex {
95
95
  */
96
96
  private getRandomLevel;
97
97
  }
98
- //# sourceMappingURL=hnswIndex.d.ts.map
@@ -164,4 +164,3 @@ export declare class HNSWIndexOptimized extends HNSWIndex {
164
164
  getUseProductQuantization(): boolean;
165
165
  }
166
166
  export {};
167
- //# sourceMappingURL=hnswIndexOptimized.d.ts.map
package/dist/index.d.ts CHANGED
@@ -9,7 +9,8 @@ import { euclideanDistance, cosineDistance, manhattanDistance, dotProductDistanc
9
9
  export { euclideanDistance, cosineDistance, manhattanDistance, dotProductDistance };
10
10
  import { UniversalSentenceEncoder, createEmbeddingFunction, createTensorFlowEmbeddingFunction, createThreadedEmbeddingFunction, defaultEmbeddingFunction } from './utils/embedding.js';
11
11
  import { executeInThread, cleanupWorkerPools } from './utils/workerUtils.js';
12
- export { UniversalSentenceEncoder, createEmbeddingFunction, createTensorFlowEmbeddingFunction, createThreadedEmbeddingFunction, defaultEmbeddingFunction, executeInThread, cleanupWorkerPools };
12
+ import { isBrowser, isNode, isWebWorker, areWebWorkersAvailable, areWorkerThreadsAvailable, areWorkerThreadsAvailableSync, isThreadingAvailable, isThreadingAvailableAsync } from './utils/environment.js';
13
+ export { UniversalSentenceEncoder, createEmbeddingFunction, createTensorFlowEmbeddingFunction, createThreadedEmbeddingFunction, defaultEmbeddingFunction, executeInThread, cleanupWorkerPools, isBrowser, isNode, isWebWorker, areWebWorkersAvailable, areWorkerThreadsAvailable, areWorkerThreadsAvailableSync, isThreadingAvailable, isThreadingAvailableAsync };
13
14
  import { OPFSStorage, MemoryStorage, createStorage } from './storage/opfsStorage.js';
14
15
  import { FileSystemStorage } from './storage/fileSystemStorage.js';
15
16
  import { R2Storage, S3CompatibleStorage } from './storage/s3CompatibleStorage.js';
@@ -47,4 +48,3 @@ import { BrainyMCPAdapter, MCPAugmentationToolset, BrainyMCPService } from './mc
47
48
  import { MCPRequest, MCPResponse, MCPDataAccessRequest, MCPToolExecutionRequest, MCPSystemInfoRequest, MCPAuthenticationRequest, MCPRequestType, MCPServiceOptions, MCPTool, MCP_VERSION } from './types/mcpTypes.js';
48
49
  export { BrainyMCPAdapter, MCPAugmentationToolset, BrainyMCPService, MCPRequestType, MCP_VERSION };
49
50
  export type { MCPRequest, MCPResponse, MCPDataAccessRequest, MCPToolExecutionRequest, MCPSystemInfoRequest, MCPAuthenticationRequest, MCPServiceOptions, MCPTool };
50
- //# sourceMappingURL=index.d.ts.map
@@ -66,4 +66,3 @@ export declare class BrainyMCPAdapter {
66
66
  */
67
67
  generateRequestId(): string;
68
68
  }
69
- //# sourceMappingURL=brainyMCPAdapter.d.ts.map
@@ -96,4 +96,3 @@ export declare class BrainyMCPService {
96
96
  */
97
97
  handleMCPRequest(request: MCPRequest): Promise<MCPResponse>;
98
98
  }
99
- //# sourceMappingURL=brainyMCPService.d.ts.map
@@ -11,4 +11,3 @@ export { BrainyMCPAdapter };
11
11
  export { MCPAugmentationToolset };
12
12
  export { BrainyMCPService };
13
13
  export * from '../types/mcpTypes.js';
14
- //# sourceMappingURL=index.d.ts.map
@@ -65,4 +65,3 @@ export declare class MCPAugmentationToolset {
65
65
  */
66
66
  generateRequestId(): string;
67
67
  }
68
- //# sourceMappingURL=mcpAugmentationToolset.d.ts.map
@@ -278,4 +278,3 @@ export declare const createStreamingPipeline: <T, R>(source: IAugmentation, sour
278
278
  export declare const StreamlinedExecutionMode: typeof ExecutionMode;
279
279
  export type StreamlinedPipelineOptions = PipelineOptions;
280
280
  export type StreamlinedPipelineResult<T> = PipelineResult<T>;
281
- //# sourceMappingURL=pipeline.d.ts.map
@@ -111,4 +111,3 @@ export declare class SequentialPipeline {
111
111
  }>;
112
112
  }
113
113
  export declare const sequentialPipeline: SequentialPipeline;
114
- //# sourceMappingURL=sequentialPipeline.d.ts.map
@@ -120,4 +120,3 @@ export declare class FileSystemStorage implements StorageAdapter {
120
120
  details?: Record<string, any>;
121
121
  }>;
122
122
  }
123
- //# sourceMappingURL=fileSystemStorage.d.ts.map
@@ -241,4 +241,3 @@ export declare function createStorage(options?: {
241
241
  forceMemoryStorage?: boolean;
242
242
  }): Promise<StorageAdapter>;
243
243
  export {};
244
- //# sourceMappingURL=opfsStorage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"opfsStorage.d.ts","sourceRoot":"","sources":["../../src/storage/opfsStorage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,iBA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AAe,CAAC,EAAE,MAAM,CAAA;QACxB,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,CAAA;IACD,eAAe,CAAC,EAAE;QAChB,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,eAAe,CAAC,EAAE,MAAM,CAAA;QACxB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAA;CACxB,GACL,OAAO,CAAC,cAAc,CAAC,CAoOzB"}
@@ -155,4 +155,3 @@ export declare class S3CompatibleStorage implements StorageAdapter {
155
155
  */
156
156
  private mapToObject;
157
157
  }
158
- //# sourceMappingURL=s3CompatibleStorage.d.ts.map
@@ -321,4 +321,3 @@ export type IWebSocketPerceptionAugmentation = BrainyAugmentations.IPerceptionAu
321
321
  export type IWebSocketDialogAugmentation = BrainyAugmentations.IDialogAugmentation & IWebSocketSupport;
322
322
  export type IWebSocketActivationAugmentation = BrainyAugmentations.IActivationAugmentation & IWebSocketSupport;
323
323
  export {};
324
- //# sourceMappingURL=augmentations.d.ts.map
@@ -48,4 +48,3 @@ export interface BrainyDataInterface<T = unknown> {
48
48
  limit?: number;
49
49
  }): Promise<unknown[]>;
50
50
  }
51
- //# sourceMappingURL=brainyDataInterface.d.ts.map
@@ -3,4 +3,3 @@
3
3
  * Extends the FileSystemDirectoryHandle interface to include the [Symbol.asyncIterator] method
4
4
  */
5
5
  export declare const fileSystemTypesLoaded = true;
6
- //# sourceMappingURL=fileSystemTypes.d.ts.map
@@ -131,4 +131,3 @@ export declare const VerbType: {
131
131
  };
132
132
  export type VerbType = (typeof VerbType)[keyof typeof VerbType];
133
133
  export {};
134
- //# sourceMappingURL=graphTypes.d.ts.map
@@ -137,4 +137,3 @@ export interface MCPServiceOptions {
137
137
  credentials: boolean;
138
138
  };
139
139
  }
140
- //# sourceMappingURL=mcpTypes.d.ts.map
@@ -24,4 +24,3 @@ export type AugmentationRegistry = {
24
24
  export interface IPipeline {
25
25
  register<T extends IAugmentation>(augmentation: T): IPipeline;
26
26
  }
27
- //# sourceMappingURL=pipelineTypes.d.ts.map
@@ -24,4 +24,3 @@ declare global {
24
24
  importTensorFlow?: () => Promise<any>;
25
25
  }
26
26
  }
27
- //# sourceMappingURL=tensorflowTypes.d.ts.map
package/dist/unified.d.ts CHANGED
@@ -9,4 +9,3 @@ export declare const environment: {
9
9
  isServerless: boolean;
10
10
  };
11
11
  export * from './index.js';
12
- //# sourceMappingURL=unified.d.ts.map
package/dist/unified.js CHANGED
@@ -2394,6 +2394,137 @@ ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
2394
2394
  }
2395
2395
  } (buffer$1));
2396
2396
 
2397
+ /**
2398
+ * Unified Text Encoding Utilities
2399
+ *
2400
+ * This module provides a consistent way to handle text encoding/decoding across all environments
2401
+ * without relying on TextEncoder/TextDecoder polyfills or patches.
2402
+ */
2403
+ /**
2404
+ * A simple text encoder that works in all environments
2405
+ * This avoids the need for TextEncoder polyfills and patches
2406
+ */
2407
+ class SimpleTextEncoder {
2408
+ /**
2409
+ * Encode a string to a Uint8Array
2410
+ * @param input - The string to encode
2411
+ * @returns A Uint8Array containing the encoded string
2412
+ */
2413
+ encode(input) {
2414
+ // Simple UTF-8 encoding implementation that works everywhere
2415
+ return new Uint8Array([...input].map((c) => c.charCodeAt(0)));
2416
+ }
2417
+ }
2418
+ /**
2419
+ * A simple text decoder that works in all environments
2420
+ * This avoids the need for TextDecoder polyfills and patches
2421
+ */
2422
+ class SimpleTextDecoder {
2423
+ /**
2424
+ * Decode a Uint8Array to a string
2425
+ * @param input - The Uint8Array to decode
2426
+ * @returns The decoded string
2427
+ */
2428
+ decode(input) {
2429
+ // Simple UTF-8 decoding implementation that works everywhere
2430
+ return String.fromCharCode.apply(null, [...input]);
2431
+ }
2432
+ }
2433
+ /**
2434
+ * A constructor function for TextEncoder that works in all environments
2435
+ */
2436
+ function UniversalTextEncoder() {
2437
+ if (!(this instanceof UniversalTextEncoder)) {
2438
+ return new UniversalTextEncoder();
2439
+ }
2440
+ try {
2441
+ // Try to use the native TextEncoder if available
2442
+ const nativeEncoder = new TextEncoder();
2443
+ this.encode = nativeEncoder.encode.bind(nativeEncoder);
2444
+ }
2445
+ catch (e) {
2446
+ // Fall back to our simple implementation
2447
+ const simpleEncoder = new SimpleTextEncoder();
2448
+ this.encode = simpleEncoder.encode.bind(simpleEncoder);
2449
+ }
2450
+ }
2451
+ /**
2452
+ * A constructor function for TextDecoder that works in all environments
2453
+ */
2454
+ function UniversalTextDecoder() {
2455
+ if (!(this instanceof UniversalTextDecoder)) {
2456
+ return new UniversalTextDecoder();
2457
+ }
2458
+ try {
2459
+ // Try to use the native TextDecoder if available
2460
+ const nativeDecoder = new TextDecoder();
2461
+ this.decode = nativeDecoder.decode.bind(nativeDecoder);
2462
+ }
2463
+ catch (e) {
2464
+ // Fall back to our simple implementation
2465
+ const simpleDecoder = new SimpleTextDecoder();
2466
+ this.decode = simpleDecoder.decode.bind(simpleDecoder);
2467
+ }
2468
+ }
2469
+ /**
2470
+ * Get a text encoder that works in the current environment
2471
+ * @returns A text encoder object with an encode method
2472
+ */
2473
+ function getTextEncoder() {
2474
+ return new UniversalTextEncoder();
2475
+ }
2476
+ /**
2477
+ * Get a text decoder that works in the current environment
2478
+ * @returns A text decoder object with a decode method
2479
+ */
2480
+ function getTextDecoder() {
2481
+ return new UniversalTextDecoder();
2482
+ }
2483
+ /**
2484
+ * Apply the TensorFlow.js platform patch if needed
2485
+ * This function patches the global object to provide a PlatformNode class
2486
+ * that uses our text encoding utilities instead of relying on TextEncoder/TextDecoder
2487
+ */
2488
+ function applyTensorFlowPatch() {
2489
+ // Only apply in Node.js environment
2490
+ if (typeof global !== 'undefined' &&
2491
+ typeof process !== 'undefined' &&
2492
+ process.versions &&
2493
+ process.versions.node) {
2494
+ try {
2495
+ // Get encoders/decoders
2496
+ const encoder = getTextEncoder();
2497
+ const decoder = getTextDecoder();
2498
+ // Define a custom PlatformNode class
2499
+ class PlatformNode {
2500
+ constructor() {
2501
+ // Create a util object with necessary methods and constructors
2502
+ this.util = {
2503
+ isFloat32Array: (arr) => !!(arr instanceof Float32Array ||
2504
+ (arr &&
2505
+ Object.prototype.toString.call(arr) ===
2506
+ '[object Float32Array]')),
2507
+ isTypedArray: (arr) => !!(ArrayBuffer.isView(arr) && !(arr instanceof DataView)),
2508
+ // Add TextEncoder and TextDecoder as constructors
2509
+ TextEncoder: UniversalTextEncoder,
2510
+ TextDecoder: UniversalTextDecoder
2511
+ };
2512
+ // Initialize using the constructors from util
2513
+ this.textEncoder = new TextEncoder();
2514
+ this.textDecoder = new TextDecoder();
2515
+ }
2516
+ }
2517
+ // Assign the PlatformNode class to the global object
2518
+ ;
2519
+ global.PlatformNode = PlatformNode;
2520
+ global.platformNode = new PlatformNode();
2521
+ }
2522
+ catch (error) {
2523
+ console.warn('Failed to apply TensorFlow.js platform patch:', error);
2524
+ }
2525
+ }
2526
+ }
2527
+
2397
2528
  // Unique ID creation requires a high quality random # generator. In the browser we therefore
2398
2529
  // require the crypto API and do not support built-in fallback to lower quality random number
2399
2530
  // generators (like Math.random()).
@@ -2686,12 +2817,35 @@ function isNode() {
2686
2817
  process.versions != null &&
2687
2818
  process.versions.node != null);
2688
2819
  }
2820
+ /**
2821
+ * Check if code is running in a Web Worker environment
2822
+ */
2823
+ function isWebWorker() {
2824
+ return (typeof self === 'object' &&
2825
+ self.constructor &&
2826
+ self.constructor.name === 'DedicatedWorkerGlobalScope');
2827
+ }
2689
2828
  /**
2690
2829
  * Check if Web Workers are available in the current environment
2691
2830
  */
2692
2831
  function areWebWorkersAvailable() {
2693
2832
  return isBrowser$1() && typeof Worker !== 'undefined';
2694
2833
  }
2834
+ /**
2835
+ * Check if Worker Threads are available in the current environment (Node.js)
2836
+ */
2837
+ async function areWorkerThreadsAvailable() {
2838
+ if (!isNode())
2839
+ return false;
2840
+ try {
2841
+ // Use dynamic import to avoid errors in browser environments
2842
+ await import('worker_threads');
2843
+ return true;
2844
+ }
2845
+ catch (e) {
2846
+ return false;
2847
+ }
2848
+ }
2695
2849
  /**
2696
2850
  * Synchronous version that doesn't actually try to load the module
2697
2851
  * This is safer in ES module environments
@@ -2709,6 +2863,12 @@ function areWorkerThreadsAvailableSync() {
2709
2863
  function isThreadingAvailable() {
2710
2864
  return areWebWorkersAvailable() || areWorkerThreadsAvailableSync();
2711
2865
  }
2866
+ /**
2867
+ * Async version of isThreadingAvailable
2868
+ */
2869
+ async function isThreadingAvailableAsync() {
2870
+ return areWebWorkersAvailable() || (await areWorkerThreadsAvailable());
2871
+ }
2712
2872
 
2713
2873
  /**
2714
2874
  * Utility functions for executing functions in Worker Threads (Node.js) or Web Workers (Browser)
@@ -2734,7 +2894,31 @@ function executeInThread(fnString, args) {
2734
2894
  else {
2735
2895
  // Fallback to main thread execution
2736
2896
  try {
2737
- const fn = new Function('return ' + fnString)();
2897
+ // Try different approaches to create a function from string
2898
+ let fn;
2899
+ try {
2900
+ // First try with 'return' prefix
2901
+ fn = new Function('return ' + fnString)();
2902
+ }
2903
+ catch (functionError) {
2904
+ console.warn('Fallback: Error creating function with return syntax, trying alternative approaches', functionError);
2905
+ try {
2906
+ // Try wrapping in parentheses for function expressions
2907
+ fn = new Function('return (' + fnString + ')')();
2908
+ }
2909
+ catch (wrapError) {
2910
+ console.warn('Fallback: Error creating function with parentheses wrapping', wrapError);
2911
+ try {
2912
+ // Try direct approach for named functions
2913
+ fn = new Function(fnString)();
2914
+ }
2915
+ catch (directError) {
2916
+ console.error('Fallback: All approaches to create function failed', directError);
2917
+ throw new Error('Failed to create function from string: ' +
2918
+ functionError.message);
2919
+ }
2920
+ }
2921
+ }
2738
2922
  return Promise.resolve(fn(args));
2739
2923
  }
2740
2924
  catch (error) {
@@ -2750,7 +2934,8 @@ function executeInNodeWorker(fnString, args) {
2750
2934
  return new Promise((resolve, reject) => {
2751
2935
  try {
2752
2936
  // Dynamically import worker_threads (Node.js only)
2753
- import('node:worker_threads').then(({ Worker, isMainThread, parentPort, workerData }) => {
2937
+ import('node:worker_threads')
2938
+ .then(({ Worker, isMainThread, parentPort, workerData }) => {
2754
2939
  if (!isMainThread && parentPort) {
2755
2940
  // We're inside a worker, execute the function
2756
2941
  const fn = new Function('return ' + workerData.fnString)();
@@ -2809,7 +2994,8 @@ function executeInNodeWorker(fnString, args) {
2809
2994
  reject(new Error(`Worker stopped with exit code ${code}`));
2810
2995
  }
2811
2996
  });
2812
- }).catch(reject);
2997
+ })
2998
+ .catch(reject);
2813
2999
  }
2814
3000
  catch (error) {
2815
3001
  reject(error);
@@ -2822,21 +3008,131 @@ function executeInNodeWorker(fnString, args) {
2822
3008
  function executeInWebWorker(fnString, args) {
2823
3009
  return new Promise((resolve, reject) => {
2824
3010
  try {
2825
- const workerCode = `
2826
- self.onmessage = function(e) {
2827
- try {
2828
- const fn = new Function('return ' + e.data.fnString)();
2829
- const result = fn(e.data.args);
2830
- self.postMessage({ result: result });
2831
- } catch (error) {
2832
- self.postMessage({ error: error.message });
2833
- }
2834
- };
2835
- `;
2836
- const blob = new Blob([workerCode], { type: 'application/javascript' });
2837
- const url = URL.createObjectURL(blob);
2838
- const worker = new Worker(url);
3011
+ // Use the dedicated worker.js file instead of creating a blob
3012
+ // Try different approaches to locate the worker.js file
3013
+ let workerPath = './worker.js';
3014
+ try {
3015
+ // First try to use the import.meta.url if available (modern browsers)
3016
+ if (typeof import.meta !== 'undefined' && import.meta.url) {
3017
+ const baseUrl = import.meta.url.substring(0, import.meta.url.lastIndexOf('/') + 1);
3018
+ workerPath = `${baseUrl}worker.js`;
3019
+ }
3020
+ // Fallback to a relative path based on the unified.js location
3021
+ else if (typeof document !== 'undefined') {
3022
+ // Find the script tag that loaded unified.js
3023
+ const scripts = document.getElementsByTagName('script');
3024
+ for (let i = 0; i < scripts.length; i++) {
3025
+ const src = scripts[i].src;
3026
+ if (src && src.includes('unified.js')) {
3027
+ // Get the directory path
3028
+ workerPath =
3029
+ src.substring(0, src.lastIndexOf('/') + 1) + 'worker.js';
3030
+ break;
3031
+ }
3032
+ }
3033
+ }
3034
+ }
3035
+ catch (e) {
3036
+ console.warn('Could not determine worker path from import.meta.url, using relative path', e);
3037
+ }
3038
+ // If we couldn't determine the path, try some common locations
3039
+ if (workerPath === './worker.js' && typeof window !== 'undefined') {
3040
+ // Try to find the worker.js in the same directory as the current page
3041
+ const pageUrl = window.location.href;
3042
+ const pageDir = pageUrl.substring(0, pageUrl.lastIndexOf('/') + 1);
3043
+ workerPath = `${pageDir}worker.js`;
3044
+ // Also check for dist/worker.js
3045
+ if (typeof document !== 'undefined') {
3046
+ const distWorkerPath = `${pageDir}dist/worker.js`;
3047
+ // Create a test request to see if the file exists
3048
+ const xhr = new XMLHttpRequest();
3049
+ xhr.open('HEAD', distWorkerPath, false);
3050
+ try {
3051
+ xhr.send();
3052
+ if (xhr.status >= 200 && xhr.status < 300) {
3053
+ workerPath = distWorkerPath;
3054
+ }
3055
+ }
3056
+ catch (e) {
3057
+ // Ignore errors, we'll use the default path
3058
+ }
3059
+ }
3060
+ }
3061
+ console.log('Using worker path:', workerPath);
3062
+ // Try to create a worker, but fall back to inline worker or main thread execution if it fails
3063
+ let worker;
3064
+ try {
3065
+ worker = new Worker(workerPath);
3066
+ }
3067
+ catch (error) {
3068
+ console.warn('Failed to create Web Worker from file, trying inline worker:', error);
3069
+ try {
3070
+ // Create an inline worker using a Blob
3071
+ const workerCode = `
3072
+ // Brainy Inline Worker Script
3073
+ console.log('Brainy Inline Worker: Started');
3074
+
3075
+ self.onmessage = function (e) {
3076
+ try {
3077
+ console.log('Brainy Inline Worker: Received message', e.data ? 'with data' : 'without data');
3078
+
3079
+ if (!e.data || !e.data.fnString) {
3080
+ throw new Error('Invalid message: missing function string');
3081
+ }
3082
+
3083
+ console.log('Brainy Inline Worker: Creating function from string');
3084
+ const fn = new Function('return ' + e.data.fnString)();
3085
+
3086
+ console.log('Brainy Inline Worker: Executing function with args');
3087
+ const result = fn(e.data.args);
3088
+
3089
+ console.log('Brainy Inline Worker: Function executed successfully, posting result');
3090
+ self.postMessage({ result: result });
3091
+ } catch (error) {
3092
+ console.error('Brainy Inline Worker: Error executing function', error);
3093
+ self.postMessage({
3094
+ error: error.message,
3095
+ stack: error.stack
3096
+ });
3097
+ }
3098
+ };
3099
+ `;
3100
+ const blob = new Blob([workerCode], {
3101
+ type: 'application/javascript'
3102
+ });
3103
+ const blobUrl = URL.createObjectURL(blob);
3104
+ worker = new Worker(blobUrl);
3105
+ console.log('Created inline worker using Blob URL');
3106
+ }
3107
+ catch (inlineWorkerError) {
3108
+ console.warn('Failed to create inline Web Worker, falling back to main thread execution:', inlineWorkerError);
3109
+ // Execute in main thread as fallback
3110
+ try {
3111
+ const fn = new Function('return ' + fnString)();
3112
+ resolve(fn(args));
3113
+ return;
3114
+ }
3115
+ catch (mainThreadError) {
3116
+ reject(mainThreadError);
3117
+ return;
3118
+ }
3119
+ }
3120
+ }
3121
+ // Set a timeout to prevent hanging
3122
+ const timeoutId = setTimeout(() => {
3123
+ console.warn('Web Worker execution timed out, falling back to main thread');
3124
+ worker.terminate();
3125
+ // Execute in main thread as fallback
3126
+ try {
3127
+ const fn = new Function('return ' + fnString)();
3128
+ resolve(fn(args));
3129
+ }
3130
+ catch (mainThreadError) {
3131
+ reject(mainThreadError);
3132
+ }
3133
+ }, 25000); // 25 second timeout (less than the 30 second test timeout)
2839
3134
  worker.onmessage = function (e) {
3135
+ clearTimeout(timeoutId);
2840
3136
  if (e.data.error) {
2841
3137
  reject(new Error(e.data.error));
2842
3138
  }
@@ -2844,12 +3140,19 @@ function executeInWebWorker(fnString, args) {
2844
3140
  resolve(e.data.result);
2845
3141
  }
2846
3142
  worker.terminate();
2847
- URL.revokeObjectURL(url);
2848
3143
  };
2849
3144
  worker.onerror = function (e) {
2850
- reject(new Error(`Worker error: ${e.message}`));
3145
+ clearTimeout(timeoutId);
3146
+ console.warn('Web Worker error, falling back to main thread execution:', e.message);
2851
3147
  worker.terminate();
2852
- URL.revokeObjectURL(url);
3148
+ // Execute in main thread as fallback
3149
+ try {
3150
+ const fn = new Function('return ' + fnString)();
3151
+ resolve(fn(args));
3152
+ }
3153
+ catch (mainThreadError) {
3154
+ reject(mainThreadError);
3155
+ }
2853
3156
  };
2854
3157
  worker.postMessage({ fnString, args });
2855
3158
  }
@@ -2864,13 +3167,15 @@ function executeInWebWorker(fnString, args) {
2864
3167
  */
2865
3168
  function cleanupWorkerPools() {
2866
3169
  if (isNode()) {
2867
- import('node:worker_threads').then(({ Worker }) => {
3170
+ import('node:worker_threads')
3171
+ .then(({ Worker }) => {
2868
3172
  for (const worker of workerPool.values()) {
2869
3173
  worker.terminate();
2870
3174
  }
2871
3175
  workerPool.clear();
2872
3176
  console.log('Worker pools cleaned up');
2873
- }).catch(console.error);
3177
+ })
3178
+ .catch(console.error);
2874
3179
  }
2875
3180
  }
2876
3181
 
@@ -13888,15 +14193,20 @@ class BrainyMCPService {
13888
14193
  }
13889
14194
  }
13890
14195
 
14196
+ /**
14197
+ * OPFS BrainyData
14198
+ * A vector database using HNSW indexing with Origin Private File System storage
14199
+ */
14200
+ // Import unified text encoding utilities first to ensure they're available
14201
+ // Apply the TensorFlow.js platform patch if needed
14202
+ applyTensorFlowPatch();
14203
+
13891
14204
  // Make Buffer available globally
13892
14205
  if (typeof window !== 'undefined' && typeof globalThis.Buffer === 'undefined') {
13893
14206
  globalThis.Buffer = buffer$1.Buffer;
13894
14207
  }
13895
- /**
13896
- * Unified entry point for Brainy
13897
- * This file exports everything from index.ts
13898
- * Environment detection is handled here and made available to all components
13899
- */
14208
+ // Apply the TensorFlow.js platform patch if needed
14209
+ applyTensorFlowPatch();
13900
14210
  // Export environment information
13901
14211
  const environment = {
13902
14212
  isBrowser: typeof window !== 'undefined',
@@ -22002,7 +22312,7 @@ class PlatformNode {
22002
22312
  this.util = require$$1;
22003
22313
  // According to the spec, the built-in encoder can do only UTF-8 encoding.
22004
22314
  // https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder/TextEncoder
22005
- this.textEncoder = new this.util.TextEncoder();
22315
+ this.textEncoder = new TextEncoder();
22006
22316
  }
22007
22317
  fetch(path, requestInits) {
22008
22318
  if (env().global.fetch != null) {
@@ -87225,5 +87535,5 @@ var _child_processShim = /*#__PURE__*/Object.freeze({
87225
87535
  __proto__: null
87226
87536
  });
87227
87537
 
87228
- 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 };
87538
+ 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 };
87229
87539
  //# sourceMappingURL=unified.js.map