@soulcraft/brainy 0.11.0 → 0.12.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.
Files changed (37) hide show
  1. package/README.md +2 -43
  2. package/dist/brainy.js +776 -252
  3. package/dist/brainy.min.js +765 -749
  4. package/dist/brainyData.d.ts +29 -0
  5. package/dist/patched-platform-node.d.ts +17 -0
  6. package/dist/setup.d.ts +16 -0
  7. package/dist/storage/fileSystemStorage.d.ts.map +1 -1
  8. package/dist/unified.d.ts +5 -3
  9. package/dist/unified.js +775 -253
  10. package/dist/unified.min.js +765 -749
  11. package/dist/utils/distance.d.ts.map +1 -1
  12. package/dist/utils/embedding.d.ts +25 -4
  13. package/dist/utils/embedding.d.ts.map +1 -1
  14. package/dist/utils/environment.d.ts.map +1 -1
  15. package/dist/utils/textEncoding.d.ts +13 -20
  16. package/dist/utils/textEncoding.d.ts.map +1 -1
  17. package/dist/utils/version.d.ts +1 -1
  18. package/package.json +30 -11
  19. package/dist/augmentations/huggingfaceActivation.d.ts +0 -57
  20. package/dist/augmentations/huggingfaceActivation.d.ts.map +0 -1
  21. package/dist/augmentations/huggingfaceActivationRegistration.d.ts +0 -6
  22. package/dist/augmentations/huggingfaceActivationRegistration.d.ts.map +0 -1
  23. package/dist/cli.d.ts +0 -7
  24. package/dist/utils/distance-js.d.ts +0 -38
  25. package/dist/utils/distance-js.d.ts.map +0 -1
  26. package/dist/utils/distance-wasm.d.ts +0 -36
  27. package/dist/utils/distance-wasm.d.ts.map +0 -1
  28. package/dist/utils/huggingfaceEmbedding.d.ts +0 -53
  29. package/dist/utils/huggingfaceEmbedding.d.ts.map +0 -1
  30. package/dist/utils/tensorflowBridge.d.ts +0 -14
  31. package/dist/utils/tensorflowBridge.d.ts.map +0 -1
  32. package/dist/utils/textEncoderPolyfill.d.ts +0 -6
  33. package/dist/utils/textEncoderPolyfill.d.ts.map +0 -1
  34. package/dist/utils/universalDebug.d.ts +0 -21
  35. package/dist/utils/universalDebug.d.ts.map +0 -1
  36. package/dist/utils/universalUuid.d.ts +0 -26
  37. package/dist/utils/universalUuid.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"distance.d.ts","sourceRoot":"","sources":["../../src/utils/distance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAI1D;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAe/B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,gBA2B5B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAU/B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAahC,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EAAE,EACjB,gBAAgB,GAAE,gBAAoC,GACrD,OAAO,CAAC,MAAM,EAAE,CAAC,CAmLnB"}
1
+ {"version":3,"file":"distance.d.ts","sourceRoot":"","sources":["../../src/utils/distance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAI1D;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAe/B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,gBA2B5B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAU/B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAahC,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EAAE,EACjB,gBAAgB,GAAE,gBAAoC,GACrD,OAAO,CAAC,MAAM,EAAE,CAAC,CAqMnB"}
@@ -18,9 +18,30 @@ export declare class UniversalSentenceEncoder implements EmbeddingModel {
18
18
  private backend;
19
19
  /**
20
20
  * Add polyfills and patches for TensorFlow.js compatibility
21
- * This addresses issues with TensorFlow.js in Node.js environments
21
+ * This addresses issues with TensorFlow.js across all server environments
22
+ * (Node.js, serverless, and other server environments)
23
+ *
24
+ * Note: The main TensorFlow.js patching is now centralized in textEncoding.ts
25
+ * and applied through setup.ts. This method only adds additional utility functions
26
+ * that might be needed by TensorFlow.js.
22
27
  */
23
- private addNodeCompatibilityPolyfills;
28
+ private addServerCompatibilityPolyfills;
29
+ /**
30
+ * Check if we're running in a test environment
31
+ */
32
+ private isTestEnvironment;
33
+ /**
34
+ * Log message only if not in test environment
35
+ */
36
+ private logIfNotTest;
37
+ /**
38
+ * Load the Universal Sentence Encoder model with retry logic
39
+ * This helps handle network failures and JSON parsing errors from TensorFlow Hub
40
+ * @param loadFunction The function to load the model
41
+ * @param maxRetries Maximum number of retry attempts
42
+ * @param baseDelay Base delay in milliseconds for exponential backoff
43
+ */
44
+ private loadModelWithRetry;
24
45
  /**
25
46
  * Initialize the embedding model
26
47
  */
@@ -44,9 +65,9 @@ export declare class UniversalSentenceEncoder implements EmbeddingModel {
44
65
  }
45
66
  /**
46
67
  * Create an embedding function from an embedding model
47
- * @param model Embedding model to use
68
+ * @param model Embedding model to use (optional, defaults to UniversalSentenceEncoder)
48
69
  */
49
- export declare function createEmbeddingFunction(model: EmbeddingModel): EmbeddingFunction;
70
+ export declare function createEmbeddingFunction(model?: EmbeddingModel): EmbeddingFunction;
50
71
  export declare function createTensorFlowEmbeddingFunction(): EmbeddingFunction;
51
72
  /**
52
73
  * Default embedding function
@@ -1 +1 @@
1
- {"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../src/utils/embedding.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAG3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,CAEhD;AAED;;GAEG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,OAAO,CAAC,CAUlE;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,IAAI,OAAO,CAKvD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED;;GAEG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,OAAO,CAAC,CAElE"}
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/utils/environment.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAYhC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAMrC;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD;AAED;;GAEG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,OAAO,CAAC,CAUlE;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,IAAI,OAAO,CAKvD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED;;GAEG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,OAAO,CAAC,CAElE"}
@@ -1,22 +1,15 @@
1
- /**
2
- * Unified Text Encoding Utilities
3
- *
4
- * This module provides a consistent way to handle text encoding/decoding across all environments
5
- * using the native TextEncoder/TextDecoder APIs.
6
- */
7
- /**
8
- * Get a text encoder that works in the current environment
9
- * @returns A TextEncoder instance
10
- */
1
+ declare global {
2
+ let _utilShim: any;
3
+ let __TextEncoder__: typeof TextEncoder;
4
+ let __TextDecoder__: typeof TextDecoder;
5
+ let __brainy_util__: any;
6
+ let __utilShim: any;
7
+ }
8
+ /**
9
+ * Apply the TensorFlow.js platform patch if it hasn't been applied already
10
+ * This is a safety measure in case the module-level patch didn't run
11
+ * Now works across all environments: browser, Node.js, and serverless/server
12
+ */
13
+ export declare function applyTensorFlowPatch(): Promise<void>;
11
14
  export declare function getTextEncoder(): TextEncoder;
12
- /**
13
- * Get a text decoder that works in the current environment
14
- * @returns A TextDecoder instance
15
- */
16
15
  export declare function getTextDecoder(): TextDecoder;
17
- /**
18
- * Apply the TensorFlow.js platform patch if needed
19
- * This function patches the global object to provide a PlatformNode class
20
- * that uses native TextEncoder/TextDecoder
21
- */
22
- export declare function applyTensorFlowPatch(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"textEncoding.d.ts","sourceRoot":"","sources":["../../src/utils/textEncoding.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAE5C;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAE5C;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAiE3C"}
1
+ {"version":3,"file":"textEncoding.d.ts","sourceRoot":"","sources":["../../src/utils/textEncoding.ts"],"names":[],"mappings":"AAMA,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,SAAS,EAAE,GAAG,CAAA;IAClB,IAAI,eAAe,EAAE,OAAO,WAAW,CAAA;IACvC,IAAI,eAAe,EAAE,OAAO,WAAW,CAAA;IACvC,IAAI,eAAe,EAAE,GAAG,CAAA;IACxB,IAAI,UAAU,EAAE,GAAG,CAAA;CACpB;AAiPD;;;;GAIG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAqE1D;AAED,wBAAgB,cAAc,IAAI,WAAW,CAE5C;AAED,wBAAgB,cAAc,IAAI,WAAW,CAE5C"}
@@ -2,4 +2,4 @@
2
2
  * This file is auto-generated during the build process.
3
3
  * Do not modify this file directly.
4
4
  */
5
- export declare const VERSION = "0.11.0";
5
+ export declare const VERSION = "0.12.0";
package/package.json CHANGED
@@ -1,12 +1,17 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "A vector graph database using HNSW indexing with Origin Private File System storage",
5
5
  "main": "dist/unified.js",
6
6
  "module": "dist/unified.js",
7
7
  "types": "dist/unified.d.ts",
8
8
  "type": "module",
9
- "sideEffects": false,
9
+ "sideEffects": [
10
+ "./dist/setup.js",
11
+ "./dist/utils/textEncoding.js",
12
+ "./src/setup.ts",
13
+ "./src/utils/textEncoding.ts"
14
+ ],
10
15
  "exports": {
11
16
  ".": {
12
17
  "import": "./dist/unified.js",
@@ -15,6 +20,10 @@
15
20
  "./min": {
16
21
  "import": "./dist/unified.min.js"
17
22
  },
23
+ "./setup": {
24
+ "import": "./dist/setup.js",
25
+ "types": "./dist/setup.d.ts"
26
+ },
18
27
  "./types/graphTypes": {
19
28
  "import": "./dist/types/graphTypes.js",
20
29
  "types": "./dist/types/graphTypes.d.ts"
@@ -30,6 +39,10 @@
30
39
  "./dist/utils/textEncoding.js": {
31
40
  "import": "./dist/utils/textEncoding.js",
32
41
  "types": "./dist/utils/textEncoding.d.ts"
42
+ },
43
+ "./dist/setup.js": {
44
+ "import": "./dist/setup.js",
45
+ "types": "./dist/setup.d.ts"
33
46
  }
34
47
  },
35
48
  "engines": {
@@ -54,16 +67,16 @@
54
67
  "prepare": "npm run build",
55
68
  "deploy": "npm run build && npm publish && node scripts/create-github-release.js",
56
69
  "deploy:cli": "node scripts/generate-version.js && cd cli-package && npm run build && npm publish",
57
- "deploy:cloud:aws": "cd cloud-wrapper && npm run build && npm run deploy:aws",
58
- "deploy:cloud:gcp": "cd cloud-wrapper && npm run build && npm run deploy:gcp",
59
- "deploy:cloud:cloudflare": "cd cloud-wrapper && npm run build && npm run deploy:cloudflare",
60
- "deploy:cloud": "echo 'Please use one of the following commands to deploy to a specific cloud provider:' && echo ' npm run deploy:cloud:aws' && echo ' npm run deploy:cloud:gcp' && echo ' npm run deploy:cloud:cloudflare'",
61
70
  "postinstall": "echo 'Note: If you encounter dependency conflicts with TensorFlow.js packages, please use: npm install --legacy-peer-deps'",
62
71
  "dry-run": "npm pack --dry-run",
63
- "test:cli": "node scripts/test-cli-locally.js",
64
- "test:tensorflow": "node test-tensorflow-textencoder.js",
65
- "test:all": "node scripts/test-all-environments.js",
66
- "test": "npm run test:all"
72
+ "test": "vitest run",
73
+ "test:watch": "vitest",
74
+ "test:ui": "vitest --ui",
75
+ "test:node": "vitest run tests/environment.node.test.ts tests/core.test.ts tests/vector-operations.test.ts tests/tensorflow-patch.test.ts",
76
+ "test:browser": "vitest run tests/environment.browser.test.ts --environment jsdom",
77
+ "test:core": "vitest run tests/core.test.ts",
78
+ "test:coverage": "vitest run --coverage",
79
+ "test:all": "npm run build && vitest run"
67
80
  },
68
81
  "keywords": [
69
82
  "vector-database",
@@ -111,16 +124,22 @@
111
124
  "@rollup/plugin-node-resolve": "^15.2.3",
112
125
  "@rollup/plugin-replace": "^5.0.5",
113
126
  "@rollup/plugin-typescript": "^11.1.6",
127
+ "@types/jsdom": "^21.1.7",
114
128
  "@types/node": "^20.11.30",
115
129
  "@types/uuid": "^10.0.0",
116
130
  "@typescript-eslint/eslint-plugin": "^7.4.0",
117
131
  "@typescript-eslint/parser": "^7.4.0",
132
+ "@vitest/ui": "^3.2.4",
118
133
  "eslint": "^8.57.0",
134
+ "happy-dom": "^18.0.1",
135
+ "jsdom": "^26.1.0",
119
136
  "puppeteer": "^22.5.0",
120
137
  "rollup": "^4.13.0",
121
138
  "rollup-plugin-terser": "^7.0.2",
122
139
  "tslib": "^2.6.2",
123
- "typescript": "^5.4.5"
140
+ "typescript": "^5.4.5",
141
+ "vitest": "^3.2.4",
142
+ "@vitest/coverage-v8": "^3.2.4"
124
143
  },
125
144
  "dependencies": {
126
145
  "@aws-sdk/client-s3": "^3.540.0",
@@ -1,57 +0,0 @@
1
- /**
2
- * Huggingface Activation Augmentation
3
- *
4
- * This augmentation provides embedding and text generation capabilities using Huggingface models.
5
- * It implements the IActivationAugmentation interface to make it pluggable with other solutions.
6
- */
7
- import { AugmentationResponse, IActivationAugmentation } from '../types/augmentations.js';
8
- /**
9
- * Huggingface Activation Augmentation
10
- *
11
- * This augmentation uses Huggingface transformers and sentence_transformers (specifically all-MiniLM-L6-v2)
12
- * for embedding and text generation capabilities.
13
- */
14
- export declare class HuggingfaceActivation implements IActivationAugmentation {
15
- readonly name: string;
16
- readonly description: string;
17
- enabled: boolean;
18
- private embeddingModel;
19
- private embeddingFunction;
20
- private initialized;
21
- private hfInference;
22
- constructor();
23
- /**
24
- * Initializes the augmentation
25
- */
26
- initialize(): Promise<void>;
27
- /**
28
- * Shuts down the augmentation
29
- */
30
- shutDown(): Promise<void>;
31
- /**
32
- * Gets the status of the augmentation
33
- */
34
- getStatus(): Promise<'active' | 'inactive' | 'error'>;
35
- /**
36
- * Triggers an action based on a processed command or internal state
37
- * @param actionName The name of the action to trigger
38
- * @param parameters Optional parameters for the action
39
- */
40
- triggerAction(actionName: string, parameters?: Record<string, unknown>): Promise<AugmentationResponse<unknown>>;
41
- /**
42
- * Generates an expressive output or response from Brainy
43
- * @param knowledgeId The identifier of the knowledge to express
44
- * @param format The desired output format (e.g., 'text', 'json')
45
- */
46
- generateOutput(knowledgeId: string, format: string): Promise<AugmentationResponse<string | Record<string, unknown>>>;
47
- /**
48
- * Interacts with an external system or API
49
- * @param systemId The identifier of the external system
50
- * @param payload The data to send to the external system
51
- */
52
- interactExternal(systemId: string, payload: Record<string, unknown>): Promise<AugmentationResponse<unknown>>;
53
- }
54
- /**
55
- * Creates a new instance of the Huggingface Activation Augmentation
56
- */
57
- export declare function createHuggingfaceActivation(): IActivationAugmentation;
@@ -1 +0,0 @@
1
- {"version":3,"file":"huggingfaceActivation.d.ts","sourceRoot":"","sources":["../../src/augmentations/huggingfaceActivation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,oBAAoB,EAAoB,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AAI3G;;;;;GAKG;AACH,qBAAa,qBAAsB,YAAW,uBAAuB;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAA2B;IAChD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA2F;IACvH,OAAO,EAAE,OAAO,CAAO;IAEvB,OAAO,CAAC,cAAc,CAAgC;IACtD,OAAO,CAAC,iBAAiB,CAAgC;IACzD,OAAO,CAAC,WAAW,CAAiB;IACpC,OAAO,CAAC,WAAW,CAAY;;IAO/B;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA2BjC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB/B;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;IAI3D;;;;OAIG;IACG,aAAa,CACjB,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAsEzC;;;;OAIG;IACG,cAAc,CAClB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,oBAAoB,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IA+ClE;;;;OAIG;IACG,gBAAgB,CACpB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;CAoD1C;AAED;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,uBAAuB,CAErE"}
@@ -1,6 +0,0 @@
1
- /**
2
- * Registration file for Huggingface Activation Augmentation
3
- *
4
- * This file registers the Huggingface Activation Augmentation with the augmentation registry.
5
- */
6
- export declare function registerHuggingfaceActivation(): void;
@@ -1 +0,0 @@
1
- {"version":3,"file":"huggingfaceActivationRegistration.d.ts","sourceRoot":"","sources":["../../src/augmentations/huggingfaceActivationRegistration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD"}
package/dist/cli.d.ts DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Brainy CLI
4
- * A command-line interface for interacting with the Brainy vector database
5
- */
6
- export {};
7
- //# sourceMappingURL=cli.d.ts.map
@@ -1,38 +0,0 @@
1
- /**
2
- * JavaScript implementations of distance functions for vector similarity calculations
3
- * Used as fallbacks when WebAssembly is not available
4
- */
5
- import { DistanceFunction, Vector } from '../coreTypes.js';
6
- /**
7
- * Calculates the Euclidean distance between two vectors
8
- * Lower values indicate higher similarity
9
- */
10
- export declare const euclideanDistance: DistanceFunction;
11
- /**
12
- * Calculates the cosine distance between two vectors
13
- * Lower values indicate higher similarity
14
- * Range: 0 (identical) to 2 (opposite)
15
- */
16
- export declare const cosineDistance: DistanceFunction;
17
- /**
18
- * Calculates the Manhattan (L1) distance between two vectors
19
- * Lower values indicate higher similarity
20
- */
21
- export declare const manhattanDistance: DistanceFunction;
22
- /**
23
- * Calculates the dot product similarity between two vectors
24
- * Higher values indicate higher similarity
25
- * Converted to a distance metric (lower is better)
26
- */
27
- export declare const dotProductDistance: DistanceFunction;
28
- /**
29
- * Batch distance calculation
30
- * Calculates distances between a query vector and multiple vectors
31
- *
32
- * @param queryVector The query vector to compare against all vectors
33
- * @param vectors Array of vectors to compare against
34
- * @param distanceFunction The distance function to use
35
- * @returns Promise resolving to array of distances
36
- */
37
- export declare function calculateDistancesBatch(queryVector: Vector, vectors: Vector[], distanceFunction?: DistanceFunction): Promise<number[]>;
38
- //# sourceMappingURL=distance-js.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"distance-js.d.ts","sourceRoot":"","sources":["../../src/utils/distance-js.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAE1D;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAc/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,gBA4B5B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAa/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAgBhC,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EAAE,EACjB,gBAAgB,GAAE,gBAAoC,GACrD,OAAO,CAAC,MAAM,EAAE,CAAC,CAEnB"}
@@ -1,36 +0,0 @@
1
- /**
2
- * WebAssembly implementation of distance functions for vector similarity calculations
3
- * High-performance implementation with GPU acceleration when available
4
- */
5
- import { DistanceFunction, Vector } from '../coreTypes.js';
6
- /**
7
- * Load the WebAssembly module
8
- * @returns Promise that resolves when the module is loaded
9
- */
10
- export declare function loadWasmModule(): Promise<void>;
11
- /**
12
- * Calculates the Euclidean distance between two vectors
13
- * Uses WebAssembly implementation when available, falls back to JavaScript
14
- */
15
- export declare const euclideanDistance: DistanceFunction;
16
- /**
17
- * Calculates the cosine distance between two vectors
18
- * Uses WebAssembly implementation when available, falls back to JavaScript
19
- */
20
- export declare const cosineDistance: DistanceFunction;
21
- /**
22
- * Calculates the Manhattan distance between two vectors
23
- * Uses WebAssembly implementation when available, falls back to JavaScript
24
- */
25
- export declare const manhattanDistance: DistanceFunction;
26
- /**
27
- * Calculates the dot product distance between two vectors
28
- * Uses WebAssembly implementation when available, falls back to JavaScript
29
- */
30
- export declare const dotProductDistance: DistanceFunction;
31
- /**
32
- * Batch distance calculation
33
- * Uses WebAssembly implementation when available, falls back to JavaScript
34
- */
35
- export declare function calculateDistancesBatch(queryVector: Vector, vectors: Vector[], distanceFunction?: DistanceFunction): Promise<number[]>;
36
- //# sourceMappingURL=distance-wasm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"distance-wasm.d.ts","sourceRoot":"","sources":["../../src/utils/distance-wasm.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAwC1D;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAiIpD;AAWD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAqB/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,gBAqB5B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAqB/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAqBhC,CAAA;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EAAE,EACjB,gBAAgB,GAAE,gBAAoC,GACrD,OAAO,CAAC,MAAM,EAAE,CAAC,CAiDnB"}
@@ -1,53 +0,0 @@
1
- /**
2
- * Embedding functions for converting data to vectors using Huggingface transformers
3
- */
4
- import { EmbeddingFunction, EmbeddingModel, Vector } from '../coreTypes.js';
5
- /**
6
- * Huggingface Sentence Transformer embedding model
7
- * This model provides high-quality text embeddings using the all-MiniLM-L6-v2 model
8
- *
9
- * This implementation uses the @huggingface/inference library to generate embeddings.
10
- */
11
- export declare class HuggingfaceSentenceTransformer implements EmbeddingModel {
12
- private hfInference;
13
- private initialized;
14
- private modelName;
15
- /**
16
- * Initialize the embedding model
17
- */
18
- init(): Promise<void>;
19
- /**
20
- * Embed text into a vector using Huggingface Inference API
21
- * @param data Text to embed
22
- */
23
- embed(data: string | string[]): Promise<Vector>;
24
- /**
25
- * Embed multiple texts into vectors using Huggingface Inference API
26
- * This is more efficient than calling embed() multiple times
27
- * @param dataArray Array of texts to embed
28
- * @returns Array of embedding vectors
29
- */
30
- embedBatch(dataArray: string[]): Promise<Vector[]>;
31
- /**
32
- * Dispose of the model resources
33
- */
34
- dispose(): Promise<void>;
35
- }
36
- /**
37
- * Create an embedding function from an embedding model
38
- * @param model Embedding model to use
39
- */
40
- export declare function createEmbeddingFunction(model: EmbeddingModel): EmbeddingFunction;
41
- export declare function createHuggingfaceEmbeddingFunction(): EmbeddingFunction;
42
- /**
43
- * Default embedding function
44
- * Uses HuggingfaceSentenceTransformer for all text embeddings
45
- */
46
- export declare const defaultEmbeddingFunction: EmbeddingFunction;
47
- export declare const defaultBatchEmbeddingFunction: (dataArray: string[]) => Promise<Vector[]>;
48
- /**
49
- * Creates an embedding function that runs in a separate thread
50
- * This is a wrapper around createEmbeddingFunction that uses executeInThread
51
- * @param model Embedding model to use
52
- */
53
- export declare function createThreadedEmbeddingFunction(model: EmbeddingModel): EmbeddingFunction;
@@ -1 +0,0 @@
1
- {"version":3,"file":"huggingfaceEmbedding.d.ts","sourceRoot":"","sources":["../../src/utils/huggingfaceEmbedding.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAG3E;;;;;GAKG;AACH,qBAAa,8BAA+B,YAAW,cAAc;IACnE,OAAO,CAAC,WAAW,CAAY;IAC/B,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,SAAS,CAAmD;IAEpE;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAqBlC;;;OAGG;IACU,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAkD5D;;;;;OAKG;IACU,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IA4D/D;;OAEG;IACU,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAatC;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,cAAc,GACpB,iBAAiB,CAInB;AAWD,wBAAgB,kCAAkC,IAAI,iBAAiB,CAiBtE;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,iBACD,CAAA;AAYtC,eAAO,MAAM,6BAA6B,EAAE,CAC1C,SAAS,EAAE,MAAM,EAAE,KAChB,OAAO,CAAC,MAAM,EAAE,CAepB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,cAAc,GACpB,iBAAiB,CAUnB"}
@@ -1,14 +0,0 @@
1
- /**
2
- * Bridge file for TensorFlow.js dependencies
3
- * This file imports the TensorFlow.js dependencies statically and exports them for use in other modules
4
- */
5
- import '@tensorflow/tfjs-backend-cpu';
6
- import '@tensorflow/tfjs-backend-webgl';
7
- import * as use from '@tensorflow-models/universal-sentence-encoder';
8
- interface TensorFlowCore {
9
- setBackend: (backendName: string) => Promise<boolean>;
10
- }
11
- export declare const tf: TensorFlowCore;
12
- export declare const universalSentenceEncoder: typeof use;
13
- export declare function initTensorFlow(backend?: string): Promise<void>;
14
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"tensorflowBridge.d.ts","sourceRoot":"","sources":["../../src/utils/tensorflowBridge.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,8BAA8B,CAAA;AACrC,OAAO,gCAAgC,CAAA;AACvC,OAAO,KAAK,GAAG,MAAM,+CAA+C,CAAA;AAGpE,UAAU,cAAc;IACtB,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CACtD;AAGD,eAAO,MAAM,EAAE,EAAwB,cAAc,CAAA;AACrD,eAAO,MAAM,wBAAwB,YAAM,CAAA;AAG3C,wBAAsB,cAAc,CAAC,OAAO,GAAE,MAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAW3E"}
@@ -1,6 +0,0 @@
1
- /**
2
- * TextEncoder/TextDecoder Polyfill for Node.js and Browser environments
3
- * This module provides a consistent way to use TextEncoder/TextDecoder across all environments
4
- */
5
- export declare function ensureTextEncoderPolyfill(): boolean;
6
- //# sourceMappingURL=textEncoderPolyfill.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"textEncoderPolyfill.d.ts","sourceRoot":"","sources":["../../src/utils/textEncoderPolyfill.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA+FH,wBAAgB,yBAAyB,YAGxC"}
@@ -1,21 +0,0 @@
1
- /**
2
- * Debug Implementation
3
- *
4
- * This module re-exports the standard 'debug' package functions.
5
- * It maintains the same interface as the previous custom implementation
6
- * for backward compatibility.
7
- */
8
- /**
9
- * Create a debug function with the given namespace
10
- * @param namespace - The debug namespace
11
- * @returns A debug function
12
- */
13
- export declare function createDebug(namespace: string): (...args: any[]) => void;
14
- /**
15
- * Export a function that can be used as a drop-in replacement for debug
16
- */
17
- export declare const debug: typeof createDebug;
18
- /**
19
- * Export the debug function as the default export
20
- */
21
- export default createDebug;
@@ -1 +0,0 @@
1
- {"version":3,"file":"universalDebug.d.ts","sourceRoot":"","sources":["../../src/utils/universalDebug.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAEvE;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,oBAAc,CAAC;AAEjC;;GAEG;AACH,eAAe,WAAW,CAAC"}
@@ -1,26 +0,0 @@
1
- /**
2
- * UUID Implementation
3
- *
4
- * This module re-exports the standard 'uuid' package functions.
5
- * It maintains the same interface as the previous custom implementation
6
- * for backward compatibility.
7
- */
8
- /**
9
- * Generate a random UUID v4 string
10
- * @returns A UUID v4 string
11
- */
12
- export declare function generateUuidV4(): string;
13
- /**
14
- * Export a function that can be used as a drop-in replacement for uuid.v4
15
- */
16
- export declare const uuidv4: typeof generateUuidV4;
17
- /**
18
- * Export an object with a v4 property to match the structure of the uuid package
19
- */
20
- export declare const uuid: {
21
- v4: typeof generateUuidV4;
22
- };
23
- /**
24
- * Export a named export v4 to match the structure of the uuid package
25
- */
26
- export declare const v4: typeof generateUuidV4;
@@ -1 +0,0 @@
1
- {"version":3,"file":"universalUuid.d.ts","sourceRoot":"","sources":["../../src/utils/universalUuid.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;GAEG;AACH,eAAO,MAAM,MAAM,uBAAiB,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,IAAI;;CAEhB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,EAAE,uBAAiB,CAAC"}