ruvector 0.1.20 → 0.1.21

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/dist/index.mjs ADDED
@@ -0,0 +1,306 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
+ }) : x)(function(x) {
5
+ if (typeof require !== "undefined") return require.apply(this, arguments);
6
+ throw Error('Dynamic require of "' + x + '" is not supported');
7
+ });
8
+ var __commonJS = (cb, mod) => function __require2() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+
12
+ // ../node_modules/@ruvector/core/dist/index.cjs
13
+ var require_dist = __commonJS({
14
+ "../node_modules/@ruvector/core/dist/index.cjs"(exports, module) {
15
+ "use strict";
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.DistanceMetric = void 0;
18
+ var node_os_1 = __require("os");
19
+ var DistanceMetric;
20
+ (function(DistanceMetric2) {
21
+ DistanceMetric2["Euclidean"] = "euclidean";
22
+ DistanceMetric2["Cosine"] = "cosine";
23
+ DistanceMetric2["DotProduct"] = "dot";
24
+ })(DistanceMetric || (exports.DistanceMetric = DistanceMetric = {}));
25
+ function getPlatformPackage() {
26
+ const plat = (0, node_os_1.platform)();
27
+ const architecture = (0, node_os_1.arch)();
28
+ const packageMap = {
29
+ "linux-x64": "ruvector-core-linux-x64-gnu",
30
+ "linux-arm64": "ruvector-core-linux-arm64-gnu",
31
+ "darwin-x64": "ruvector-core-darwin-x64",
32
+ "darwin-arm64": "ruvector-core-darwin-arm64",
33
+ "win32-x64": "ruvector-core-win32-x64-msvc"
34
+ };
35
+ const key = `${plat}-${architecture}`;
36
+ const packageName = packageMap[key];
37
+ if (!packageName) {
38
+ throw new Error(`Unsupported platform: ${plat}-${architecture}. Supported platforms: ${Object.keys(packageMap).join(", ")}`);
39
+ }
40
+ return packageName;
41
+ }
42
+ function loadNativeBinding() {
43
+ const packageName = getPlatformPackage();
44
+ try {
45
+ return __require(packageName);
46
+ } catch (error) {
47
+ try {
48
+ const plat = (0, node_os_1.platform)();
49
+ const architecture = (0, node_os_1.arch)();
50
+ const platformKey = `${plat}-${architecture}`;
51
+ const platformMap = {
52
+ "linux-x64": "linux-x64-gnu",
53
+ "linux-arm64": "linux-arm64-gnu",
54
+ "darwin-x64": "darwin-x64",
55
+ "darwin-arm64": "darwin-arm64",
56
+ "win32-x64": "win32-x64-msvc"
57
+ };
58
+ const localPath = `../platforms/${platformMap[platformKey]}/ruvector.node`;
59
+ return __require(localPath);
60
+ } catch (fallbackError) {
61
+ throw new Error(`Failed to load native binding: ${error.message}
62
+ Fallback also failed: ${fallbackError.message}
63
+ Platform: ${(0, node_os_1.platform)()}-${(0, node_os_1.arch)()}
64
+ Expected package: ${packageName}`);
65
+ }
66
+ }
67
+ }
68
+ var nativeBinding = loadNativeBinding();
69
+ module.exports = nativeBinding;
70
+ module.exports.default = nativeBinding;
71
+ module.exports.DistanceMetric = DistanceMetric;
72
+ }
73
+ });
74
+
75
+ // package.json
76
+ var require_package = __commonJS({
77
+ "package.json"(exports, module) {
78
+ module.exports = {
79
+ name: "ruvector",
80
+ version: "0.1.21",
81
+ description: "All-in-one vector database: HNSW search, Cypher queries, GNN layers, compression. Pinecone + Neo4j + PyTorch in one package.",
82
+ main: "./dist/index.js",
83
+ types: "./dist/index.d.ts",
84
+ bin: {
85
+ ruvector: "./bin/ruvector.js"
86
+ },
87
+ exports: {
88
+ ".": {
89
+ types: "./dist/index.d.ts",
90
+ require: "./dist/index.js",
91
+ import: "./dist/index.mjs"
92
+ }
93
+ },
94
+ files: [
95
+ "dist",
96
+ "bin",
97
+ "README.md"
98
+ ],
99
+ scripts: {
100
+ build: "tsup src/index.ts --format cjs,esm --dts --clean",
101
+ dev: "tsup src/index.ts --format cjs,esm --dts --watch",
102
+ typecheck: "tsc --noEmit",
103
+ prepublishOnly: "npm run build"
104
+ },
105
+ keywords: [
106
+ "vector",
107
+ "database",
108
+ "embeddings",
109
+ "similarity-search",
110
+ "machine-learning",
111
+ "ai",
112
+ "rust",
113
+ "napi",
114
+ "wasm",
115
+ "graph",
116
+ "cypher",
117
+ "neo4j",
118
+ "gnn",
119
+ "neural-network",
120
+ "compression",
121
+ "hnsw",
122
+ "rag"
123
+ ],
124
+ author: "rUv",
125
+ license: "MIT",
126
+ repository: {
127
+ type: "git",
128
+ url: "https://github.com/ruvnet/ruvector.git",
129
+ directory: "npm/ruvector"
130
+ },
131
+ dependencies: {
132
+ commander: "^11.1.0",
133
+ chalk: "^4.1.2",
134
+ ora: "^5.4.1",
135
+ "cli-table3": "^0.6.3",
136
+ inquirer: "^8.2.6"
137
+ },
138
+ optionalDependencies: {
139
+ "@ruvector/core": "^0.1.1",
140
+ "@ruvector/graph-node": "^0.1.0",
141
+ "@ruvector/graph-wasm": "^0.1.0",
142
+ "@ruvector/gnn-node": "^0.1.0",
143
+ "@ruvector/gnn-wasm": "^0.1.0"
144
+ },
145
+ devDependencies: {
146
+ "@types/node": "^20.10.0",
147
+ "@types/inquirer": "^8.2.10",
148
+ typescript: "^5.3.3",
149
+ tsup: "^8.0.0"
150
+ },
151
+ engines: {
152
+ node: ">=16.0.0"
153
+ }
154
+ };
155
+ }
156
+ });
157
+
158
+ // src/index.ts
159
+ var backend;
160
+ var backendType = "wasm";
161
+ function loadBackend() {
162
+ if (backend) {
163
+ return backend;
164
+ }
165
+ try {
166
+ backend = require_dist();
167
+ backendType = "native";
168
+ console.log("\u2713 Loaded native rUvector bindings");
169
+ return backend;
170
+ } catch (e) {
171
+ try {
172
+ backend = __require("@ruvector/wasm");
173
+ backendType = "wasm";
174
+ console.warn("\u26A0 Native bindings not available, using WASM fallback");
175
+ console.warn(" For better performance, install @ruvector/core");
176
+ return backend;
177
+ } catch (wasmError) {
178
+ throw new Error(
179
+ `Failed to load rUvector backend. Please ensure either @ruvector/core or @ruvector/wasm is installed.
180
+ Native error: ${e}
181
+ WASM error: ${wasmError}`
182
+ );
183
+ }
184
+ }
185
+ }
186
+ var VectorIndex = class _VectorIndex {
187
+ constructor(options) {
188
+ const backend2 = loadBackend();
189
+ this.index = new backend2.VectorIndex(options);
190
+ }
191
+ async insert(vector) {
192
+ return this.index.insert(vector);
193
+ }
194
+ async insertBatch(vectors, options) {
195
+ if (this.index.insertBatch) {
196
+ return this.index.insertBatch(vectors, options);
197
+ }
198
+ const batchSize = options?.batchSize || 1e3;
199
+ const total = vectors.length;
200
+ for (let i = 0; i < total; i += batchSize) {
201
+ const batch = vectors.slice(i, Math.min(i + batchSize, total));
202
+ await Promise.all(batch.map((v) => this.insert(v)));
203
+ if (options?.progressCallback) {
204
+ options.progressCallback(Math.min(i + batchSize, total) / total);
205
+ }
206
+ }
207
+ }
208
+ async search(query, options) {
209
+ return this.index.search(query, options);
210
+ }
211
+ async get(id) {
212
+ return this.index.get(id);
213
+ }
214
+ async delete(id) {
215
+ return this.index.delete(id);
216
+ }
217
+ async stats() {
218
+ return this.index.stats();
219
+ }
220
+ async save(path) {
221
+ return this.index.save(path);
222
+ }
223
+ static async load(path) {
224
+ const backend2 = loadBackend();
225
+ const index = await backend2.VectorIndex.load(path);
226
+ const wrapper = Object.create(_VectorIndex.prototype);
227
+ wrapper.index = index;
228
+ return wrapper;
229
+ }
230
+ async clear() {
231
+ return this.index.clear();
232
+ }
233
+ async optimize() {
234
+ if (this.index.optimize) {
235
+ return this.index.optimize();
236
+ }
237
+ }
238
+ };
239
+ var Utils = {
240
+ cosineSimilarity(a, b) {
241
+ if (a.length !== b.length) {
242
+ throw new Error("Vectors must have the same dimension");
243
+ }
244
+ let dotProduct = 0;
245
+ let normA = 0;
246
+ let normB = 0;
247
+ for (let i = 0; i < a.length; i++) {
248
+ dotProduct += a[i] * b[i];
249
+ normA += a[i] * a[i];
250
+ normB += b[i] * b[i];
251
+ }
252
+ return dotProduct / (Math.sqrt(normA) * Math.sqrt(normB));
253
+ },
254
+ euclideanDistance(a, b) {
255
+ if (a.length !== b.length) {
256
+ throw new Error("Vectors must have the same dimension");
257
+ }
258
+ let sum = 0;
259
+ for (let i = 0; i < a.length; i++) {
260
+ const diff = a[i] - b[i];
261
+ sum += diff * diff;
262
+ }
263
+ return Math.sqrt(sum);
264
+ },
265
+ normalize(vector) {
266
+ const norm = Math.sqrt(vector.reduce((sum, val) => sum + val * val, 0));
267
+ return vector.map((val) => val / norm);
268
+ },
269
+ randomVector(dimension) {
270
+ const vector = new Array(dimension);
271
+ for (let i = 0; i < dimension; i++) {
272
+ vector[i] = Math.random() * 2 - 1;
273
+ }
274
+ return this.normalize(vector);
275
+ }
276
+ };
277
+ function getBackendInfo() {
278
+ loadBackend();
279
+ const features = [];
280
+ if (backendType === "native") {
281
+ features.push("SIMD", "Multi-threading", "Memory-mapped I/O");
282
+ } else {
283
+ features.push("Browser-compatible", "No native dependencies");
284
+ }
285
+ return {
286
+ type: backendType,
287
+ version: require_package().version,
288
+ features
289
+ };
290
+ }
291
+ function isNativeAvailable() {
292
+ try {
293
+ __require.resolve("@ruvector/core");
294
+ return true;
295
+ } catch {
296
+ return false;
297
+ }
298
+ }
299
+ var index_default = VectorIndex;
300
+ export {
301
+ Utils,
302
+ VectorIndex,
303
+ index_default as default,
304
+ getBackendInfo,
305
+ isNativeAvailable
306
+ };
package/package.json CHANGED
@@ -1,58 +1,77 @@
1
1
  {
2
2
  "name": "ruvector",
3
- "version": "0.1.20",
4
- "description": "High-performance vector database for Node.js with automatic native/WASM fallback",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
3
+ "version": "0.1.21",
4
+ "description": "All-in-one vector database: HNSW search, Cypher queries, GNN layers, compression. Pinecone + Neo4j + PyTorch in one package.",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
7
  "bin": {
8
- "ruvector": "./bin/cli.js"
8
+ "ruvector": "./bin/ruvector.js"
9
9
  },
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "require": "./dist/index.js",
14
+ "import": "./dist/index.mjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "bin",
20
+ "README.md"
21
+ ],
10
22
  "scripts": {
11
- "build": "tsc",
12
- "prepublishOnly": "npm run build",
13
- "test": "node test/integration.js"
23
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean",
24
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
25
+ "typecheck": "tsc --noEmit",
26
+ "prepublishOnly": "npm run build"
14
27
  },
15
28
  "keywords": [
16
29
  "vector",
17
30
  "database",
18
- "vector-database",
19
- "vector-search",
20
- "similarity-search",
21
- "semantic-search",
22
31
  "embeddings",
23
- "hnsw",
24
- "ann",
25
- "ai",
32
+ "similarity-search",
26
33
  "machine-learning",
27
- "rag",
34
+ "ai",
28
35
  "rust",
36
+ "napi",
29
37
  "wasm",
30
- "native",
31
- "ruv",
32
- "ruvector"
38
+ "graph",
39
+ "cypher",
40
+ "neo4j",
41
+ "gnn",
42
+ "neural-network",
43
+ "compression",
44
+ "hnsw",
45
+ "rag"
33
46
  ],
34
- "author": "ruv.io Team <info@ruv.io> (https://ruv.io)",
35
- "homepage": "https://ruv.io",
36
- "bugs": {
37
- "url": "https://github.com/ruvnet/ruvector/issues"
38
- },
47
+ "author": "rUv",
39
48
  "license": "MIT",
40
49
  "repository": {
41
50
  "type": "git",
42
51
  "url": "https://github.com/ruvnet/ruvector.git",
43
- "directory": "npm/packages/ruvector"
52
+ "directory": "npm/ruvector"
44
53
  },
45
54
  "dependencies": {
46
- "@ruvector/core": "^0.1.14",
47
55
  "commander": "^11.1.0",
48
56
  "chalk": "^4.1.2",
49
- "ora": "^5.4.1"
57
+ "ora": "^5.4.1",
58
+ "cli-table3": "^0.6.3",
59
+ "inquirer": "^8.2.6"
60
+ },
61
+ "optionalDependencies": {
62
+ "@ruvector/core": "^0.1.1",
63
+ "@ruvector/graph-node": "^0.1.0",
64
+ "@ruvector/graph-wasm": "^0.1.0",
65
+ "@ruvector/gnn-node": "^0.1.0",
66
+ "@ruvector/gnn-wasm": "^0.1.0"
50
67
  },
51
68
  "devDependencies": {
52
- "@types/node": "^20.10.5",
53
- "typescript": "^5.3.3"
69
+ "@types/node": "^20.10.0",
70
+ "@types/inquirer": "^8.2.10",
71
+ "typescript": "^5.3.3",
72
+ "tsup": "^8.0.0"
54
73
  },
55
74
  "engines": {
56
- "node": ">=14.0.0"
75
+ "node": ">=16.0.0"
57
76
  }
58
77
  }
@@ -1 +0,0 @@
1
- {}
@@ -1,87 +0,0 @@
1
- {
2
- "startTime": 1764098223504,
3
- "sessionId": "session-1764098223504",
4
- "lastActivity": 1764098223504,
5
- "sessionDuration": 0,
6
- "totalTasks": 1,
7
- "successfulTasks": 1,
8
- "failedTasks": 0,
9
- "totalAgents": 0,
10
- "activeAgents": 0,
11
- "neuralEvents": 0,
12
- "memoryMode": {
13
- "reasoningbankOperations": 0,
14
- "basicOperations": 0,
15
- "autoModeSelections": 0,
16
- "modeOverrides": 0,
17
- "currentMode": "auto"
18
- },
19
- "operations": {
20
- "store": {
21
- "count": 0,
22
- "totalDuration": 0,
23
- "errors": 0
24
- },
25
- "retrieve": {
26
- "count": 0,
27
- "totalDuration": 0,
28
- "errors": 0
29
- },
30
- "query": {
31
- "count": 0,
32
- "totalDuration": 0,
33
- "errors": 0
34
- },
35
- "list": {
36
- "count": 0,
37
- "totalDuration": 0,
38
- "errors": 0
39
- },
40
- "delete": {
41
- "count": 0,
42
- "totalDuration": 0,
43
- "errors": 0
44
- },
45
- "search": {
46
- "count": 0,
47
- "totalDuration": 0,
48
- "errors": 0
49
- },
50
- "init": {
51
- "count": 0,
52
- "totalDuration": 0,
53
- "errors": 0
54
- }
55
- },
56
- "performance": {
57
- "avgOperationDuration": 0,
58
- "minOperationDuration": null,
59
- "maxOperationDuration": null,
60
- "slowOperations": 0,
61
- "fastOperations": 0,
62
- "totalOperationTime": 0
63
- },
64
- "storage": {
65
- "totalEntries": 0,
66
- "reasoningbankEntries": 0,
67
- "basicEntries": 0,
68
- "databaseSize": 0,
69
- "lastBackup": null,
70
- "growthRate": 0
71
- },
72
- "errors": {
73
- "total": 0,
74
- "byType": {},
75
- "byOperation": {},
76
- "recent": []
77
- },
78
- "reasoningbank": {
79
- "semanticSearches": 0,
80
- "sqlFallbacks": 0,
81
- "embeddingGenerated": 0,
82
- "consolidations": 0,
83
- "avgQueryTime": 0,
84
- "cacheHits": 0,
85
- "cacheMisses": 0
86
- }
87
- }
@@ -1,10 +0,0 @@
1
- [
2
- {
3
- "id": "cmd-hooks-1764098223654",
4
- "type": "hooks",
5
- "success": true,
6
- "duration": 9.898746000000017,
7
- "timestamp": 1764098223664,
8
- "metadata": {}
9
- }
10
- ]