ruvector 0.1.96 → 0.1.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +182 -1
- package/bin/cli.js +292 -1
- package/bin/mcp-server.js +464 -22
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/rvf-wrapper.d.ts +86 -0
- package/dist/core/rvf-wrapper.d.ts.map +1 -0
- package/dist/core/rvf-wrapper.js +102 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -28
- package/package.json +4 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RVF Wrapper - Persistent vector store via @ruvector/rvf
|
|
3
|
+
*
|
|
4
|
+
* Wraps @ruvector/rvf RvfDatabase through thin convenience functions.
|
|
5
|
+
* Falls back to clear error messages when the package is not installed.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isRvfAvailable(): boolean;
|
|
8
|
+
export interface RvfStoreOptions {
|
|
9
|
+
dimensions: number;
|
|
10
|
+
metric?: 'l2' | 'cosine' | 'dotproduct';
|
|
11
|
+
compression?: 'none' | 'scalar' | 'product';
|
|
12
|
+
m?: number;
|
|
13
|
+
efConstruction?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface RvfEntry {
|
|
16
|
+
id: string;
|
|
17
|
+
vector: Float32Array | number[];
|
|
18
|
+
metadata?: Record<string, any>;
|
|
19
|
+
}
|
|
20
|
+
export interface RvfResult {
|
|
21
|
+
id: string;
|
|
22
|
+
distance: number;
|
|
23
|
+
}
|
|
24
|
+
export interface RvfStoreStatus {
|
|
25
|
+
totalVectors: number;
|
|
26
|
+
totalSegments: number;
|
|
27
|
+
fileSizeBytes: number;
|
|
28
|
+
epoch: number;
|
|
29
|
+
compactionState: string;
|
|
30
|
+
deadSpaceRatio: number;
|
|
31
|
+
readOnly: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface RvfQueryOpts {
|
|
34
|
+
efSearch?: number;
|
|
35
|
+
filter?: any;
|
|
36
|
+
timeoutMs?: number;
|
|
37
|
+
}
|
|
38
|
+
export type RvfStore = any;
|
|
39
|
+
/**
|
|
40
|
+
* Create a new RVF store at the given path.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createRvfStore(path: string, options: RvfStoreOptions): Promise<RvfStore>;
|
|
43
|
+
/**
|
|
44
|
+
* Open an existing RVF store for read-write access.
|
|
45
|
+
*/
|
|
46
|
+
export declare function openRvfStore(path: string): Promise<RvfStore>;
|
|
47
|
+
/**
|
|
48
|
+
* Ingest a batch of vectors into an open store.
|
|
49
|
+
*/
|
|
50
|
+
export declare function rvfIngest(store: RvfStore, entries: RvfEntry[]): Promise<{
|
|
51
|
+
accepted: number;
|
|
52
|
+
rejected: number;
|
|
53
|
+
epoch: number;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Query for the k nearest neighbors.
|
|
57
|
+
*/
|
|
58
|
+
export declare function rvfQuery(store: RvfStore, vector: Float32Array | number[], k: number, options?: RvfQueryOpts): Promise<RvfResult[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Soft-delete vectors by their IDs.
|
|
61
|
+
*/
|
|
62
|
+
export declare function rvfDelete(store: RvfStore, ids: string[]): Promise<{
|
|
63
|
+
deleted: number;
|
|
64
|
+
epoch: number;
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Get the current store status.
|
|
68
|
+
*/
|
|
69
|
+
export declare function rvfStatus(store: RvfStore): Promise<RvfStoreStatus>;
|
|
70
|
+
/**
|
|
71
|
+
* Run compaction to reclaim dead space.
|
|
72
|
+
*/
|
|
73
|
+
export declare function rvfCompact(store: RvfStore): Promise<{
|
|
74
|
+
segmentsCompacted: number;
|
|
75
|
+
bytesReclaimed: number;
|
|
76
|
+
epoch: number;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* Derive a child store from a parent for lineage tracking.
|
|
80
|
+
*/
|
|
81
|
+
export declare function rvfDerive(store: RvfStore, childPath: string): Promise<RvfStore>;
|
|
82
|
+
/**
|
|
83
|
+
* Close the store, releasing the writer lock and flushing data.
|
|
84
|
+
*/
|
|
85
|
+
export declare function rvfClose(store: RvfStore): Promise<void>;
|
|
86
|
+
//# sourceMappingURL=rvf-wrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rvf-wrapper.d.ts","sourceRoot":"","sources":["../../src/core/rvf-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoBH,wBAAgB,cAAc,IAAI,OAAO,CAOxC;AAMD,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,IAAI,GAAG,QAAQ,GAAG,YAAY,CAAC;IACxC,WAAW,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC5C,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,YAAY,GAAG,MAAM,EAAE,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC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BAAsB,SAAS,CAC7B,KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,QAAQ,CAAC,CAEnB;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7D"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* RVF Wrapper - Persistent vector store via @ruvector/rvf
|
|
4
|
+
*
|
|
5
|
+
* Wraps @ruvector/rvf RvfDatabase through thin convenience functions.
|
|
6
|
+
* Falls back to clear error messages when the package is not installed.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.isRvfAvailable = isRvfAvailable;
|
|
10
|
+
exports.createRvfStore = createRvfStore;
|
|
11
|
+
exports.openRvfStore = openRvfStore;
|
|
12
|
+
exports.rvfIngest = rvfIngest;
|
|
13
|
+
exports.rvfQuery = rvfQuery;
|
|
14
|
+
exports.rvfDelete = rvfDelete;
|
|
15
|
+
exports.rvfStatus = rvfStatus;
|
|
16
|
+
exports.rvfCompact = rvfCompact;
|
|
17
|
+
exports.rvfDerive = rvfDerive;
|
|
18
|
+
exports.rvfClose = rvfClose;
|
|
19
|
+
let rvfModule = null;
|
|
20
|
+
let loadError = null;
|
|
21
|
+
function getRvfModule() {
|
|
22
|
+
if (rvfModule)
|
|
23
|
+
return rvfModule;
|
|
24
|
+
if (loadError)
|
|
25
|
+
throw loadError;
|
|
26
|
+
try {
|
|
27
|
+
rvfModule = require('@ruvector/rvf');
|
|
28
|
+
return rvfModule;
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
loadError = new Error('@ruvector/rvf is not installed. Run: npm install @ruvector/rvf');
|
|
32
|
+
throw loadError;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function isRvfAvailable() {
|
|
36
|
+
try {
|
|
37
|
+
getRvfModule();
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
// Wrapper functions
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
/**
|
|
48
|
+
* Create a new RVF store at the given path.
|
|
49
|
+
*/
|
|
50
|
+
async function createRvfStore(path, options) {
|
|
51
|
+
const mod = getRvfModule();
|
|
52
|
+
return mod.RvfDatabase.create(path, options);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Open an existing RVF store for read-write access.
|
|
56
|
+
*/
|
|
57
|
+
async function openRvfStore(path) {
|
|
58
|
+
const mod = getRvfModule();
|
|
59
|
+
return mod.RvfDatabase.open(path);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Ingest a batch of vectors into an open store.
|
|
63
|
+
*/
|
|
64
|
+
async function rvfIngest(store, entries) {
|
|
65
|
+
return store.ingestBatch(entries);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Query for the k nearest neighbors.
|
|
69
|
+
*/
|
|
70
|
+
async function rvfQuery(store, vector, k, options) {
|
|
71
|
+
return store.query(vector, k, options);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Soft-delete vectors by their IDs.
|
|
75
|
+
*/
|
|
76
|
+
async function rvfDelete(store, ids) {
|
|
77
|
+
return store.delete(ids);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get the current store status.
|
|
81
|
+
*/
|
|
82
|
+
async function rvfStatus(store) {
|
|
83
|
+
return store.status();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Run compaction to reclaim dead space.
|
|
87
|
+
*/
|
|
88
|
+
async function rvfCompact(store) {
|
|
89
|
+
return store.compact();
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Derive a child store from a parent for lineage tracking.
|
|
93
|
+
*/
|
|
94
|
+
async function rvfDerive(store, childPath) {
|
|
95
|
+
return store.derive(childPath);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Close the store, releasing the writer lock and flushing data.
|
|
99
|
+
*/
|
|
100
|
+
async function rvfClose(store) {
|
|
101
|
+
return store.close();
|
|
102
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This package automatically detects and uses the best available implementation:
|
|
5
5
|
* 1. Native (Rust-based, fastest) - if available for your platform
|
|
6
|
-
* 2.
|
|
6
|
+
* 2. RVF (persistent store) - if @ruvector/rvf is installed
|
|
7
|
+
* 3. Stub (testing fallback) - limited functionality
|
|
7
8
|
*
|
|
8
9
|
* Also provides safe wrappers for GNN and Attention modules that handle
|
|
9
10
|
* array type conversions automatically.
|
|
@@ -15,13 +16,17 @@ declare let implementation: any;
|
|
|
15
16
|
/**
|
|
16
17
|
* Get the current implementation type
|
|
17
18
|
*/
|
|
18
|
-
export declare function getImplementationType(): 'native' | 'wasm';
|
|
19
|
+
export declare function getImplementationType(): 'native' | 'rvf' | 'wasm';
|
|
19
20
|
/**
|
|
20
21
|
* Check if native implementation is being used
|
|
21
22
|
*/
|
|
22
23
|
export declare function isNative(): boolean;
|
|
23
24
|
/**
|
|
24
|
-
* Check if
|
|
25
|
+
* Check if RVF implementation is being used
|
|
26
|
+
*/
|
|
27
|
+
export declare function isRvf(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Check if stub/fallback implementation is being used
|
|
25
30
|
*/
|
|
26
31
|
export declare function isWasm(): boolean;
|
|
27
32
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAU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,YAAY,GAAG,MAAM,EAAE,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,YAAY,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,CAAC,CAAC;IAuB1N;;OAEG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,YAAY,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,IAAI,CAAC;IAW5G;;OAEG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI1C;;OAEG;IACG,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;IAI5B;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;CAGlC;AAGD,eAAO,MAAM,QAAQ,wBAAkB,CAAC;AACxC,eAAO,MAAM,QAAQ,wBAAkB,CAAC;AAGxC,eAAO,MAAM,cAAc,KAA0B,CAAC;AAGtD,eAAe,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* This package automatically detects and uses the best available implementation:
|
|
6
6
|
* 1. Native (Rust-based, fastest) - if available for your platform
|
|
7
|
-
* 2.
|
|
7
|
+
* 2. RVF (persistent store) - if @ruvector/rvf is installed
|
|
8
|
+
* 3. Stub (testing fallback) - limited functionality
|
|
8
9
|
*
|
|
9
10
|
* Also provides safe wrappers for GNN and Attention modules that handle
|
|
10
11
|
* array type conversions automatically.
|
|
@@ -27,6 +28,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
27
28
|
exports.NativeVectorDb = exports.VectorDB = exports.VectorDb = void 0;
|
|
28
29
|
exports.getImplementationType = getImplementationType;
|
|
29
30
|
exports.isNative = isNative;
|
|
31
|
+
exports.isRvf = isRvf;
|
|
30
32
|
exports.isWasm = isWasm;
|
|
31
33
|
exports.getVersion = getVersion;
|
|
32
34
|
__exportStar(require("./types"), exports);
|
|
@@ -35,35 +37,60 @@ __exportStar(require("./core"), exports);
|
|
|
35
37
|
__exportStar(require("./services"), exports);
|
|
36
38
|
let implementation;
|
|
37
39
|
let implementationType = 'wasm';
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
// Check for explicit --backend rvf flag or RUVECTOR_BACKEND env var
|
|
41
|
+
const rvfRequested = process.env.RUVECTOR_BACKEND === 'rvf' ||
|
|
42
|
+
process.argv.includes('--backend') && process.argv[process.argv.indexOf('--backend') + 1] === 'rvf';
|
|
43
|
+
if (rvfRequested) {
|
|
44
|
+
// Explicit rvf backend requested - fail hard if not available
|
|
45
|
+
try {
|
|
46
|
+
implementation = require('@ruvector/rvf');
|
|
47
|
+
implementationType = 'rvf';
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
throw new Error('@ruvector/rvf is not installed.\n' +
|
|
51
|
+
' Run: npm install @ruvector/rvf\n' +
|
|
52
|
+
' The --backend rvf flag requires this package.');
|
|
45
53
|
}
|
|
46
54
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
VectorDb
|
|
54
|
-
|
|
55
|
-
console.warn('[RuVector] Using stub VectorDb - install @ruvector/core for native performance');
|
|
56
|
-
}
|
|
57
|
-
async insert() { return 'stub-id-' + Date.now(); }
|
|
58
|
-
async insertBatch(entries) { return entries.map(() => 'stub-id-' + Date.now()); }
|
|
59
|
-
async search() { return []; }
|
|
60
|
-
async delete() { return true; }
|
|
61
|
-
async get() { return null; }
|
|
62
|
-
async len() { return 0; }
|
|
63
|
-
async isEmpty() { return true; }
|
|
55
|
+
else {
|
|
56
|
+
try {
|
|
57
|
+
// Try to load native module first
|
|
58
|
+
implementation = require('@ruvector/core');
|
|
59
|
+
implementationType = 'native';
|
|
60
|
+
// Verify it's actually working (native module exports VectorDb, not VectorDB)
|
|
61
|
+
if (typeof implementation.VectorDb !== 'function') {
|
|
62
|
+
throw new Error('Native module loaded but VectorDb class not found');
|
|
64
63
|
}
|
|
65
|
-
}
|
|
66
|
-
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
// Try rvf (persistent store) as second fallback
|
|
67
|
+
try {
|
|
68
|
+
implementation = require('@ruvector/rvf');
|
|
69
|
+
implementationType = 'rvf';
|
|
70
|
+
}
|
|
71
|
+
catch (rvfErr) {
|
|
72
|
+
// Graceful fallback - don't crash, just warn
|
|
73
|
+
console.warn('[RuVector] Native module not available:', e.message);
|
|
74
|
+
console.warn('[RuVector] RVF module not available:', rvfErr.message);
|
|
75
|
+
console.warn('[RuVector] Vector operations will be limited. Install @ruvector/core or @ruvector/rvf for full functionality.');
|
|
76
|
+
// Create a stub implementation that provides basic functionality
|
|
77
|
+
implementation = {
|
|
78
|
+
VectorDb: class StubVectorDb {
|
|
79
|
+
constructor() {
|
|
80
|
+
console.warn('[RuVector] Using stub VectorDb - install @ruvector/core for native performance');
|
|
81
|
+
}
|
|
82
|
+
async insert() { return 'stub-id-' + Date.now(); }
|
|
83
|
+
async insertBatch(entries) { return entries.map(() => 'stub-id-' + Date.now()); }
|
|
84
|
+
async search() { return []; }
|
|
85
|
+
async delete() { return true; }
|
|
86
|
+
async get() { return null; }
|
|
87
|
+
async len() { return 0; }
|
|
88
|
+
async isEmpty() { return true; }
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
implementationType = 'wasm'; // Mark as fallback mode
|
|
92
|
+
}
|
|
93
|
+
}
|
|
67
94
|
}
|
|
68
95
|
/**
|
|
69
96
|
* Get the current implementation type
|
|
@@ -78,7 +105,13 @@ function isNative() {
|
|
|
78
105
|
return implementationType === 'native';
|
|
79
106
|
}
|
|
80
107
|
/**
|
|
81
|
-
* Check if
|
|
108
|
+
* Check if RVF implementation is being used
|
|
109
|
+
*/
|
|
110
|
+
function isRvf() {
|
|
111
|
+
return implementationType === 'rvf';
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Check if stub/fallback implementation is being used
|
|
82
115
|
*/
|
|
83
116
|
function isWasm() {
|
|
84
117
|
return implementationType === 'wasm';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ruvector",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.98",
|
|
4
4
|
"description": "High-performance vector database for Node.js with automatic native/WASM fallback",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -64,6 +64,9 @@
|
|
|
64
64
|
"commander": "^11.1.0",
|
|
65
65
|
"ora": "^5.4.1"
|
|
66
66
|
},
|
|
67
|
+
"optionalDependencies": {
|
|
68
|
+
"@ruvector/rvf": "^0.1.0"
|
|
69
|
+
},
|
|
67
70
|
"devDependencies": {
|
|
68
71
|
"@types/node": "^20.10.5",
|
|
69
72
|
"typescript": "^5.3.3"
|