Merge commit 'd803bfe2b1fe7f5e219e50ac20d6801a0a58ac75' as 'vendor/ruvector'

This commit is contained in:
ruv
2026-02-28 14:39:40 -05:00
7854 changed files with 3522914 additions and 0 deletions

45
vendor/ruvector/npm/core/.npmignore vendored Normal file
View File

@@ -0,0 +1,45 @@
# Source files
src/
*.ts
!*.d.ts
# Build config
tsconfig.json
tsconfig.*.json
# Development
node_modules/
.git/
.github/
.gitignore
tests/
examples/
*.test.js
*.test.ts
*.spec.js
*.spec.ts
# Logs and temp files
*.log
*.tmp
.DS_Store
.cache/
*.tsbuildinfo
# CI/CD
.travis.yml
.gitlab-ci.yml
azure-pipelines.yml
.circleci/
# Documentation (keep README.md)
docs/
*.md
!README.md
# Editor
.vscode/
.idea/
*.swp
*.swo
*~

21
vendor/ruvector/npm/core/LICENSE vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 rUv
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

229
vendor/ruvector/npm/core/README.md vendored Normal file
View File

@@ -0,0 +1,229 @@
# @ruvector/core
High-performance Rust vector database for Node.js with HNSW indexing and SIMD optimizations.
## Features
- 🚀 **Blazing Fast**: Rust + SIMD optimizations for maximum performance
- 🎯 **HNSW Indexing**: State-of-the-art approximate nearest neighbor search
- 📦 **Zero-Copy**: Efficient buffer sharing between Rust and Node.js
- 🔍 **Multiple Distance Metrics**: Euclidean, Cosine, Dot Product, Manhattan
- 💾 **Persistent Storage**: Optional disk-based storage with memory mapping
- 🔧 **Quantization**: Scalar, Product, and Binary quantization support
- 📊 **TypeScript**: Full type definitions included
- 🌍 **Cross-Platform**: Linux, macOS, and Windows support
## Installation
```bash
npm install @ruvector/core
```
The package will automatically install the correct native binding for your platform:
- Linux x64 (GNU)
- Linux ARM64 (GNU)
- macOS x64 (Intel)
- macOS ARM64 (Apple Silicon)
- Windows x64 (MSVC)
## Quick Start
```typescript
import { VectorDB, DistanceMetric } from '@ruvector/core';
// Create a database
const db = new VectorDB({
dimensions: 384,
distanceMetric: DistanceMetric.Cosine,
storagePath: './vectors.db',
hnswConfig: {
m: 32,
efConstruction: 200,
efSearch: 100
}
});
// Insert vectors
const id = await db.insert({
vector: new Float32Array([1.0, 2.0, 3.0, ...])
});
// Search for similar vectors
const results = await db.search({
vector: new Float32Array([1.0, 2.0, 3.0, ...]),
k: 10
});
console.log(results);
// [{ id: 'vector-id', score: 0.95 }, ...]
```
## API Reference
### VectorDB
#### Constructor
```typescript
new VectorDB(options: DbOptions)
```
Creates a new vector database with the specified options.
**Options:**
- `dimensions` (number, required): Vector dimensions
- `distanceMetric` (DistanceMetric, optional): Distance metric (default: Cosine)
- `storagePath` (string, optional): Path for persistent storage (default: './ruvector.db')
- `hnswConfig` (HnswConfig, optional): HNSW index configuration
- `quantization` (QuantizationConfig, optional): Quantization configuration
#### Static Methods
```typescript
VectorDB.withDimensions(dimensions: number): VectorDB
```
Creates a vector database with default options.
#### Instance Methods
##### insert(entry: VectorEntry): Promise<string>
Inserts a vector into the database.
```typescript
const id = await db.insert({
id: 'optional-id',
vector: new Float32Array([1, 2, 3])
});
```
##### insertBatch(entries: VectorEntry[]): Promise<string[]>
Inserts multiple vectors in a batch.
```typescript
const ids = await db.insertBatch([
{ vector: new Float32Array([1, 2, 3]) },
{ vector: new Float32Array([4, 5, 6]) }
]);
```
##### search(query: SearchQuery): Promise<SearchResult[]>
Searches for similar vectors.
```typescript
const results = await db.search({
vector: new Float32Array([1, 2, 3]),
k: 10,
efSearch: 100
});
```
##### delete(id: string): Promise<boolean>
Deletes a vector by ID.
```typescript
const deleted = await db.delete('vector-id');
```
##### get(id: string): Promise<VectorEntry | null>
Retrieves a vector by ID.
```typescript
const entry = await db.get('vector-id');
```
##### len(): Promise<number>
Returns the number of vectors in the database.
```typescript
const count = await db.len();
```
##### isEmpty(): Promise<boolean>
Checks if the database is empty.
```typescript
const empty = await db.isEmpty();
```
### Types
#### DistanceMetric
```typescript
enum DistanceMetric {
Euclidean = 'Euclidean',
Cosine = 'Cosine',
DotProduct = 'DotProduct',
Manhattan = 'Manhattan'
}
```
#### DbOptions
```typescript
interface DbOptions {
dimensions: number;
distanceMetric?: DistanceMetric;
storagePath?: string;
hnswConfig?: HnswConfig;
quantization?: QuantizationConfig;
}
```
#### HnswConfig
```typescript
interface HnswConfig {
m?: number;
efConstruction?: number;
efSearch?: number;
maxElements?: number;
}
```
#### QuantizationConfig
```typescript
interface QuantizationConfig {
type: 'none' | 'scalar' | 'product' | 'binary';
subspaces?: number;
k?: number;
}
```
## Performance
rUvector delivers exceptional performance:
- **150x faster** than pure JavaScript implementations
- **1M+ vectors/second** insertion rate
- **Sub-millisecond** search latency
- **4-32x memory reduction** with quantization
## Platform Support
| Platform | Architecture | Package |
|----------|-------------|---------|
| Linux | x64 | @ruvector/core-linux-x64-gnu |
| Linux | ARM64 | @ruvector/core-linux-arm64-gnu |
| macOS | x64 (Intel) | @ruvector/core-darwin-x64 |
| macOS | ARM64 (Apple Silicon) | @ruvector/core-darwin-arm64 |
| Windows | x64 | @ruvector/core-win32-x64-msvc |
## License
MIT
## Links
- [GitHub Repository](https://github.com/ruvnet/ruvector)
- [Documentation](https://github.com/ruvnet/ruvector#readme)
- [Issue Tracker](https://github.com/ruvnet/ruvector/issues)

View File

@@ -0,0 +1,62 @@
/**
* Native binding wrapper for linux-x64
*/
const nativeBinding = require('./ruvector.node');
// The native module exports VectorDb (lowercase 'b') but we want VectorDB
// Also need to add the withDimensions static method since it's not exported properly
class VectorDB {
constructor(options) {
// Create internal instance
this._db = new nativeBinding.VectorDb(options);
}
static withDimensions(dimensions) {
// Factory method - create with default options
return new VectorDB({
dimensions: dimensions,
distanceMetric: 'Cosine',
storagePath: './ruvector.db'
});
}
async insert(entry) {
return this._db.insert(entry);
}
async insertBatch(entries) {
return this._db.insertBatch(entries);
}
async search(query) {
return this._db.search(query);
}
async delete(id) {
return this._db.delete(id);
}
async get(id) {
return this._db.get(id);
}
async len() {
return this._db.len();
}
async isEmpty() {
return this._db.isEmpty();
}
}
module.exports = {
VectorDB,
CollectionManager: nativeBinding.CollectionManager,
version: nativeBinding.version,
hello: nativeBinding.hello,
getMetrics: nativeBinding.getMetrics,
getHealth: nativeBinding.getHealth,
DistanceMetric: nativeBinding.JsDistanceMetric
};

Binary file not shown.

68
vendor/ruvector/npm/core/package.json vendored Normal file
View File

@@ -0,0 +1,68 @@
{
"name": "@ruvector/core",
"version": "0.1.17",
"description": "High-performance Rust vector database for Node.js with HNSW indexing and SIMD optimizations",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"type": "module",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
}
},
"engines": {
"node": ">= 18"
},
"scripts": {
"build": "npm run build:esm && npm run build:cjs && npm run build:rename-cjs",
"build:esm": "tsc --project tsconfig.json",
"build:cjs": "tsc --project tsconfig.cjs.json",
"build:rename-cjs": "mv dist-cjs/index.cjs.js dist/index.cjs && rm -rf dist-cjs",
"prepublishOnly": "npm run build",
"test": "node --test",
"clean": "rm -rf dist dist-cjs"
},
"devDependencies": {
"@types/node": "^20.19.25",
"typescript": "^5.9.3"
},
"optionalDependencies": {
"@ruvector/attention": "^0.1.0"
},
"files": [
"dist",
"platforms",
"native",
"*.node",
"README.md",
"LICENSE"
],
"keywords": [
"vector",
"database",
"embeddings",
"similarity-search",
"hnsw",
"rust",
"napi",
"semantic-search",
"machine-learning",
"rag",
"simd",
"performance",
"napi-rs"
],
"author": "rUv",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/ruvnet/ruvector.git",
"directory": "npm/core"
},
"homepage": "https://github.com/ruvnet/ruvector#readme",
"bugs": {
"url": "https://github.com/ruvnet/ruvector/issues"
}
}

View File

@@ -0,0 +1,53 @@
# @ruvector/core-darwin-arm64
Native macOS ARM64 bindings for @ruvector/core.
This package contains the native Node.js addon for macOS (Apple Silicon) systems.
## Installation
This package is automatically installed as an optional dependency of `@ruvector/core` when running on macOS ARM64 systems.
```bash
npm install @ruvector/core
```
## Direct Installation
You can also install this package directly:
```bash
npm install @ruvector/core-darwin-arm64
```
## Usage
```javascript
const { VectorDb } = require('@ruvector/core-darwin-arm64');
const db = new VectorDb({
dimensions: 128,
storagePath: './vectors.db'
});
// Insert vectors
await db.insert({
id: 'vec1',
vector: new Float32Array([...])
});
// Search
const results = await db.search({
vector: new Float32Array([...]),
k: 10
});
```
## Requirements
- Node.js >= 18
- macOS (Apple Silicon - M1, M2, M3, etc.)
## License
MIT

View File

@@ -0,0 +1,14 @@
const { join } = require('path');
let nativeBinding;
try {
nativeBinding = require('./ruvector.node');
} catch (error) {
throw new Error(
'Failed to load native binding for darwin-arm64. ' +
'This package may have been installed incorrectly. ' +
'Error: ' + error.message
);
}
module.exports = nativeBinding;

View File

@@ -0,0 +1,60 @@
{
"name": "ruvector-core-darwin-arm64",
"version": "0.1.25",
"description": "macOS ARM64 (Apple Silicon M1/M2/M3) native binding for ruvector-core - High-performance vector database with HNSW indexing built in Rust",
"main": "index.js",
"type": "commonjs",
"os": [
"darwin"
],
"cpu": [
"arm64"
],
"author": "ruv.io Team <info@ruv.io> (https://ruv.io)",
"homepage": "https://ruv.io",
"engines": {
"node": ">= 18"
},
"files": [
"index.js",
"ruvector.node",
"*.node",
"README.md"
],
"keywords": [
"ruvector",
"vector-database",
"vector-search",
"similarity-search",
"semantic-search",
"hnsw",
"native",
"napi",
"rust",
"macos",
"darwin",
"arm64",
"apple-silicon",
"m1",
"m2",
"m3",
"ai",
"machine-learning",
"embedding-database",
"simd",
"performance",
"ruv"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/ruvnet/ruvector.git",
"directory": "npm/core/platforms/darwin-arm64"
},
"bugs": {
"url": "https://github.com/ruvnet/ruvector/issues"
},
"publishConfig": {
"access": "public"
}
}

Binary file not shown.

View File

@@ -0,0 +1,53 @@
# @ruvector/core-darwin-x64
Native macOS x64 bindings for @ruvector/core.
This package contains the native Node.js addon for macOS (Intel) systems.
## Installation
This package is automatically installed as an optional dependency of `@ruvector/core` when running on macOS x64 systems.
```bash
npm install @ruvector/core
```
## Direct Installation
You can also install this package directly:
```bash
npm install @ruvector/core-darwin-x64
```
## Usage
```javascript
const { VectorDb } = require('@ruvector/core-darwin-x64');
const db = new VectorDb({
dimensions: 128,
storagePath: './vectors.db'
});
// Insert vectors
await db.insert({
id: 'vec1',
vector: new Float32Array([...])
});
// Search
const results = await db.search({
vector: new Float32Array([...]),
k: 10
});
```
## Requirements
- Node.js >= 18
- macOS (Intel processors)
## License
MIT

View File

@@ -0,0 +1,14 @@
const { join } = require('path');
let nativeBinding;
try {
nativeBinding = require('./ruvector.node');
} catch (error) {
throw new Error(
'Failed to load native binding for darwin-x64. ' +
'This package may have been installed incorrectly. ' +
'Error: ' + error.message
);
}
module.exports = nativeBinding;

View File

@@ -0,0 +1,53 @@
{
"name": "ruvector-core-darwin-x64",
"version": "0.1.25",
"description": "macOS x64 (Intel) native binding for ruvector-core - High-performance vector database with HNSW indexing built in Rust",
"main": "index.js",
"type": "commonjs",
"os": ["darwin"],
"cpu": ["x64"],
"author": "ruv.io Team <info@ruv.io> (https://ruv.io)",
"homepage": "https://ruv.io",
"engines": {
"node": ">= 18"
},
"files": [
"index.js",
"ruvector.node",
"*.node",
"README.md"
],
"keywords": [
"ruvector",
"vector-database",
"vector-search",
"similarity-search",
"semantic-search",
"hnsw",
"native",
"napi",
"rust",
"macos",
"darwin",
"x64",
"intel",
"ai",
"machine-learning",
"embedding-database",
"simd",
"performance",
"ruv"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/ruvnet/ruvector.git",
"directory": "npm/core/platforms/darwin-x64"
},
"bugs": {
"url": "https://github.com/ruvnet/ruvector/issues"
},
"publishConfig": {
"access": "public"
}
}

Binary file not shown.

View File

@@ -0,0 +1,135 @@
# ruvector-core-linux-arm64-gnu
[![npm version](https://badge.fury.io/js/ruvector-core-linux-arm64-gnu.svg)](https://www.npmjs.com/package/ruvector-core-linux-arm64-gnu)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
**Linux ARM64 GNU native binding for ruvector-core**
This package contains the native Node.js binding (`.node` file) for Linux ARM64 systems with GNU libc. It is automatically installed as an optional dependency when you install `ruvector-core` on a compatible system.
🌐 **[Visit ruv.io](https://ruv.io)** for more AI infrastructure tools
## Installation
**You should not install this package directly.** Instead, install the main package:
```bash
npm install ruvector-core
```
The correct platform-specific package will be automatically installed based on your system.
## System Requirements
- **Operating System**: Linux (GNU libc)
- **Architecture**: ARM64 / AArch64
- **Node.js**: 18.0.0 or higher
- **libc**: GNU C Library (glibc)
## Compatibility
This package is compatible with:
- Ubuntu 18.04+ (ARM64)
- Debian 10+ Buster (ARM64)
- CentOS 7+ / RHEL 7+ (ARM64)
- Amazon Linux 2+ (Graviton processors)
- Raspberry Pi OS 64-bit
- Most ARM64 Linux distributions using glibc
## What's Inside
This package contains:
- **ruvector.node** - Native binary module compiled from Rust for ARM64
- **index.js** - Module loader with error handling
- Full HNSW indexing implementation
- SIMD-optimized vector operations for ARM NEON
- Multi-threaded async operations via Tokio
## Performance
When running on Linux ARM64 systems (like AWS Graviton), you can expect:
- **50,000+ vector inserts per second**
- **10,000+ searches per second** (k=10)
- **~50 bytes memory per 128-dim vector**
- **Sub-millisecond latency** for most operations
- Optimized for ARM NEON SIMD instructions
## Popular ARM64 Platforms
- **AWS Graviton** (EC2 instances)
- **Raspberry Pi 4/5** (64-bit OS)
- **NVIDIA Jetson** (edge AI devices)
- **Apple Silicon** (via Docker/Linux)
- **Oracle Cloud** (Ampere processors)
## Building from Source
If you need to rebuild the native module:
```bash
# Clone the repository
git clone https://github.com/ruvnet/ruvector.git
cd ruvector
# Install Rust toolchain with ARM64 target
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup target add aarch64-unknown-linux-gnu
# Build for Linux ARM64
cd npm/packages/core
npm run build:napi -- --target aarch64-unknown-linux-gnu
```
## Troubleshooting
### Module Not Found Error
If you see "Cannot find module 'ruvector-core-linux-arm64-gnu'":
1. Verify you're on a Linux ARM64 system: `uname -m` should output `aarch64`
2. Reinstall with optional dependencies: `npm install --include=optional ruvector-core`
3. Check Node.js version: `node --version` should be 18.0.0 or higher
### Binary Compatibility Issues
If the module fails to load:
1. Ensure you have glibc installed: `ldd --version`
2. The binary requires glibc 2.17+ (CentOS 7+) or 2.27+ (Ubuntu 18.04+)
3. For Alpine Linux or musl-based systems, this package will not work (use a glibc-based distro)
### Cross-Compilation
When building on x64 for ARM64:
```bash
# Install cross-compilation tools
sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
# Set environment variable
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
# Build
npm run build:napi -- --target aarch64-unknown-linux-gnu
```
## Related Packages
- **[ruvector-core](https://www.npmjs.com/package/ruvector-core)** - Main package (install this)
- **[ruvector-core-linux-x64-gnu](https://www.npmjs.com/package/ruvector-core-linux-x64-gnu)** - Linux x64
- **[ruvector-core-darwin-x64](https://www.npmjs.com/package/ruvector-core-darwin-x64)** - macOS Intel
- **[ruvector-core-darwin-arm64](https://www.npmjs.com/package/ruvector-core-darwin-arm64)** - macOS Apple Silicon
- **[ruvector-core-win32-x64-msvc](https://www.npmjs.com/package/ruvector-core-win32-x64-msvc)** - Windows x64
## Resources
- 🏠 [Homepage](https://ruv.io)
- 📦 [GitHub Repository](https://github.com/ruvnet/ruvector)
- 📚 [Documentation](https://github.com/ruvnet/ruvector/tree/main/docs)
- 🐛 [Issue Tracker](https://github.com/ruvnet/ruvector/issues)
## License
MIT License - see [LICENSE](https://github.com/ruvnet/ruvector/blob/main/LICENSE) for details.
---
Built with ❤️ by the [ruv.io](https://ruv.io) team

View File

@@ -0,0 +1,14 @@
const { join } = require('path');
let nativeBinding;
try {
nativeBinding = require('./ruvector.node');
} catch (error) {
throw new Error(
'Failed to load native binding for linux-arm64-gnu. ' +
'This package may have been installed incorrectly. ' +
'Error: ' + error.message
);
}
module.exports = nativeBinding;

View File

@@ -0,0 +1,58 @@
{
"name": "ruvector-core-linux-arm64-gnu",
"version": "0.1.25",
"description": "Linux ARM64 GNU native binding for ruvector-core - High-performance vector database with HNSW indexing built in Rust",
"main": "index.js",
"type": "commonjs",
"os": [
"linux"
],
"cpu": [
"arm64"
],
"author": "ruv.io Team <info@ruv.io> (https://ruv.io)",
"homepage": "https://ruv.io",
"engines": {
"node": ">= 18"
},
"files": [
"index.js",
"ruvector.node",
"*.node",
"README.md"
],
"keywords": [
"ruvector",
"vector-database",
"vector-search",
"similarity-search",
"semantic-search",
"hnsw",
"native",
"napi",
"rust",
"linux",
"arm64",
"aarch64",
"gnu",
"glibc",
"ai",
"machine-learning",
"embedding-database",
"simd",
"performance",
"ruv"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/ruvnet/ruvector.git",
"directory": "npm/core/platforms/linux-arm64-gnu"
},
"bugs": {
"url": "https://github.com/ruvnet/ruvector/issues"
},
"publishConfig": {
"access": "public"
}
}

Binary file not shown.

View File

@@ -0,0 +1,111 @@
# ruvector-core-linux-x64-gnu
[![npm version](https://badge.fury.io/js/ruvector-core-linux-x64-gnu.svg)](https://www.npmjs.com/package/ruvector-core-linux-x64-gnu)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
**Linux x64 GNU native binding for ruvector-core**
This package contains the native Node.js binding (`.node` file) for Linux x64 systems with GNU libc. It is automatically installed as an optional dependency when you install `ruvector-core` on a compatible system.
🌐 **[Visit ruv.io](https://ruv.io)** for more AI infrastructure tools
## Installation
**You should not install this package directly.** Instead, install the main package:
```bash
npm install ruvector-core
```
The correct platform-specific package will be automatically installed based on your system.
## System Requirements
- **Operating System**: Linux (GNU libc)
- **Architecture**: x86_64 (x64)
- **Node.js**: 18.0.0 or higher
- **libc**: GNU C Library (glibc)
## Compatibility
This package is compatible with:
- Ubuntu 18.04+ (all versions)
- Debian 10+ (Buster and later)
- CentOS 7+ / RHEL 7+
- Fedora (all supported versions)
- Amazon Linux 2+
- Most Linux distributions using glibc
## What's Inside
This package contains:
- **ruvector.node** - Native binary module (4.3 MB) compiled from Rust
- **index.js** - Module loader with error handling
- Full HNSW indexing implementation
- SIMD-optimized vector operations
- Multi-threaded async operations via Tokio
## Performance
When running on Linux x64 systems, you can expect:
- **50,000+ vector inserts per second**
- **10,000+ searches per second** (k=10)
- **~50 bytes memory per 128-dim vector**
- **Sub-millisecond latency** for most operations
## Building from Source
If you need to rebuild the native module:
```bash
# Clone the repository
git clone https://github.com/ruvnet/ruvector.git
cd ruvector
# Install Rust toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Build for Linux x64
cd npm/packages/core
npm run build:napi -- --target x86_64-unknown-linux-gnu
```
## Troubleshooting
### Module Not Found Error
If you see "Cannot find module 'ruvector-core-linux-x64-gnu'":
1. Verify you're on a Linux x64 system: `uname -m` should output `x86_64`
2. Reinstall with optional dependencies: `npm install --include=optional ruvector-core`
3. Check Node.js version: `node --version` should be 18.0.0 or higher
### Binary Compatibility Issues
If the module fails to load:
1. Ensure you have glibc installed: `ldd --version`
2. The binary requires glibc 2.17+ (CentOS 7+) or 2.27+ (Ubuntu 18.04+)
3. For Alpine Linux or musl-based systems, this package will not work (use a glibc-based distro)
## Related Packages
- **[ruvector-core](https://www.npmjs.com/package/ruvector-core)** - Main package (install this)
- **[ruvector-core-linux-arm64-gnu](https://www.npmjs.com/package/ruvector-core-linux-arm64-gnu)** - Linux ARM64
- **[ruvector-core-darwin-x64](https://www.npmjs.com/package/ruvector-core-darwin-x64)** - macOS Intel
- **[ruvector-core-darwin-arm64](https://www.npmjs.com/package/ruvector-core-darwin-arm64)** - macOS Apple Silicon
- **[ruvector-core-win32-x64-msvc](https://www.npmjs.com/package/ruvector-core-win32-x64-msvc)** - Windows x64
## Resources
- 🏠 [Homepage](https://ruv.io)
- 📦 [GitHub Repository](https://github.com/ruvnet/ruvector)
- 📚 [Documentation](https://github.com/ruvnet/ruvector/tree/main/docs)
- 🐛 [Issue Tracker](https://github.com/ruvnet/ruvector/issues)
## License
MIT License - see [LICENSE](https://github.com/ruvnet/ruvector/blob/main/LICENSE) for details.
---
Built with ❤️ by the [ruv.io](https://ruv.io) team

View File

@@ -0,0 +1,14 @@
const { join } = require('path');
let nativeBinding;
try {
nativeBinding = require('./ruvector.node');
} catch (error) {
throw new Error(
'Failed to load native binding for linux-x64-gnu. ' +
'This package may have been installed incorrectly. ' +
'Error: ' + error.message
);
}
module.exports = nativeBinding;

View File

@@ -0,0 +1,57 @@
{
"name": "ruvector-core-linux-x64-gnu",
"version": "0.1.26",
"description": "Linux x64 GNU native binding for ruvector-core - High-performance vector database with HNSW indexing built in Rust",
"main": "index.js",
"type": "commonjs",
"os": [
"linux"
],
"cpu": [
"x64"
],
"author": "ruv.io Team <info@ruv.io> (https://ruv.io)",
"homepage": "https://ruv.io",
"engines": {
"node": ">= 18"
},
"files": [
"index.js",
"ruvector.node",
"*.node",
"README.md"
],
"keywords": [
"ruvector",
"vector-database",
"vector-search",
"similarity-search",
"semantic-search",
"hnsw",
"native",
"napi",
"rust",
"linux",
"x64",
"gnu",
"glibc",
"ai",
"machine-learning",
"embedding-database",
"simd",
"performance",
"ruv"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/ruvnet/ruvector.git",
"directory": "npm/core/platforms/linux-x64-gnu"
},
"bugs": {
"url": "https://github.com/ruvnet/ruvector/issues"
},
"publishConfig": {
"access": "public"
}
}

Binary file not shown.

View File

@@ -0,0 +1,151 @@
# ruvector-core-win32-x64-msvc
[![npm version](https://badge.fury.io/js/ruvector-core-win32-x64-msvc.svg)](https://www.npmjs.com/package/ruvector-core-win32-x64-msvc)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
**Windows x64 MSVC native binding for ruvector-core**
This package contains the native Node.js binding (`.node` file) for Windows x64 systems compiled with MSVC. It is automatically installed as an optional dependency when you install `ruvector-core` on a compatible system.
🌐 **[Visit ruv.io](https://ruv.io)** for more AI infrastructure tools
## Installation
**You should not install this package directly.** Instead, install the main package:
```bash
npm install ruvector-core
```
The correct platform-specific package will be automatically installed based on your system.
## System Requirements
- **Operating System**: Windows 10 (1809+) or Windows 11, Windows Server 2019+
- **Architecture**: x86_64 (64-bit)
- **Node.js**: 18.0.0 or higher
- **Visual C++ Runtime**: Automatically included with Node.js
## Compatibility
This package is compatible with:
- **Windows 10** (version 1809 or later)
- **Windows 11** (all versions)
- **Windows Server 2019** and newer
- Most Windows development environments
**Note:** Windows ARM64 is not currently supported.
## What's Inside
This package contains:
- **ruvector.node** - Native binary module compiled from Rust with MSVC
- **index.js** - Module loader with error handling
- Full HNSW indexing implementation
- SIMD-optimized vector operations (AVX2, SSE4.2)
- Multi-threaded async operations via Tokio
## Performance
When running on Windows x64 systems, you can expect:
- **50,000+ vector inserts per second**
- **10,000+ searches per second** (k=10)
- **~50 bytes memory per 128-dim vector**
- **Sub-millisecond latency** for most operations
- Optimized for Intel/AMD AVX2 SIMD instructions
## Building from Source
If you need to rebuild the native module:
### Prerequisites
1. Install **Visual Studio 2022** (or 2019) with "Desktop development with C++" workload
2. Install **Rust**: https://rustup.rs/
3. Open "x64 Native Tools Command Prompt for VS 2022"
### Build Steps
```bash
# Clone the repository
git clone https://github.com/ruvnet/ruvector.git
cd ruvector
# Build for Windows x64
cd npm\packages\core
npm run build:napi -- --target x86_64-pc-windows-msvc
```
## Troubleshooting
### Module Not Found Error
If you see "Cannot find module 'ruvector-core-win32-x64-msvc'":
1. Verify you're on Windows 64-bit: `wmic os get osarchitecture` should show "64-bit"
2. Reinstall with optional dependencies: `npm install --include=optional ruvector-core`
3. Check Node.js version: `node --version` should be 18.0.0 or higher
### DLL Loading Issues
If the module fails to load with DLL errors:
1. **Install Visual C++ Redistributable**:
- Download from: https://aka.ms/vs/17/release/vc_redist.x64.exe
- Node.js usually includes this, but manual install may be needed
2. **Check Windows Updates**:
- Ensure Windows is up to date
- Some MSVC runtimes come through Windows Update
3. **Verify Node.js Installation**:
- Reinstall Node.js from nodejs.org
- Use the Windows Installer (.msi) version
### Long Path Issues
If you encounter "path too long" errors:
1. **Enable Long Paths in Windows**:
```powershell
# Run PowerShell as Administrator
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
```
2. **Or use shorter paths**:
- Install Node modules closer to drive root (e.g., `C:\projects\`)
### Antivirus False Positives
Some antivirus software may flag native `.node` files:
- Add an exception for `node_modules\ruvector-core-win32-x64-msvc\`
- Or temporarily disable real-time scanning during npm install
### WSL2 (Windows Subsystem for Linux)
If you're using WSL2:
- Use the Linux packages instead (`ruvector-core-linux-x64-gnu`)
- This Windows package is for native Windows Node.js only
## Related Packages
- **[ruvector-core](https://www.npmjs.com/package/ruvector-core)** - Main package (install this)
- **[ruvector-core-linux-x64-gnu](https://www.npmjs.com/package/ruvector-core-linux-x64-gnu)** - Linux x64
- **[ruvector-core-linux-arm64-gnu](https://www.npmjs.com/package/ruvector-core-linux-arm64-gnu)** - Linux ARM64
- **[ruvector-core-darwin-x64](https://www.npmjs.com/package/ruvector-core-darwin-x64)** - macOS Intel
- **[ruvector-core-darwin-arm64](https://www.npmjs.com/package/ruvector-core-darwin-arm64)** - macOS Apple Silicon
## Resources
- 🏠 [Homepage](https://ruv.io)
- 📦 [GitHub Repository](https://github.com/ruvnet/ruvector)
- 📚 [Documentation](https://github.com/ruvnet/ruvector/tree/main/docs)
- 🐛 [Issue Tracker](https://github.com/ruvnet/ruvector/issues)
## License
MIT License - see [LICENSE](https://github.com/ruvnet/ruvector/blob/main/LICENSE) for details.
---
Built with ❤️ by the [ruv.io](https://ruv.io) team

View File

@@ -0,0 +1,15 @@
const { join } = require('path');
let nativeBinding;
try {
nativeBinding = require('./ruvector.node');
} catch (error) {
throw new Error(
'Failed to load native binding for win32-x64-msvc. ' +
'This package may have been installed incorrectly. ' +
'Ensure you have Visual C++ Redistributable installed. ' +
'Error: ' + error.message
);
}
module.exports = nativeBinding;

View File

@@ -0,0 +1,57 @@
{
"name": "ruvector-core-win32-x64-msvc",
"version": "0.1.25",
"description": "Windows x64 MSVC native binding for ruvector-core - High-performance vector database with HNSW indexing built in Rust",
"main": "index.js",
"type": "commonjs",
"os": [
"win32"
],
"cpu": [
"x64"
],
"author": "ruv.io Team <info@ruv.io> (https://ruv.io)",
"homepage": "https://ruv.io",
"engines": {
"node": ">= 18"
},
"files": [
"index.js",
"ruvector.node",
"*.node",
"README.md"
],
"keywords": [
"ruvector",
"vector-database",
"vector-search",
"similarity-search",
"semantic-search",
"hnsw",
"native",
"napi",
"rust",
"windows",
"win32",
"x64",
"msvc",
"ai",
"machine-learning",
"embedding-database",
"simd",
"performance",
"ruv"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/ruvnet/ruvector.git",
"directory": "npm/core/platforms/win32-x64-msvc"
},
"bugs": {
"url": "https://github.com/ruvnet/ruvector/issues"
},
"publishConfig": {
"access": "public"
}
}

Binary file not shown.

View File

@@ -0,0 +1,17 @@
/**
* @ruvector/core - CommonJS wrapper
*
* This file provides CommonJS compatibility for projects using require()
*/
/**
* Distance metric for similarity calculation
*/
export declare enum DistanceMetric {
/** Euclidean (L2) distance */
Euclidean = "euclidean",
/** Cosine similarity (1 - cosine distance) */
Cosine = "cosine",
/** Dot product similarity */
DotProduct = "dot"
}
//# sourceMappingURL=index.cjs.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.cjs.d.ts","sourceRoot":"","sources":["index.cjs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;GAEG;AACH,oBAAY,cAAc;IACxB,8BAA8B;IAC9B,SAAS,cAAc;IACvB,8CAA8C;IAC9C,MAAM,WAAW;IACjB,6BAA6B;IAC7B,UAAU,QAAQ;CACnB"}

View File

@@ -0,0 +1,101 @@
"use strict";
/**
* @ruvector/core - CommonJS wrapper
*
* This file provides CommonJS compatibility for projects using require()
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.DistanceMetric = void 0;
const node_os_1 = require("node:os");
/**
* Distance metric for similarity calculation
*/
var DistanceMetric;
(function (DistanceMetric) {
/** Euclidean (L2) distance */
DistanceMetric["Euclidean"] = "euclidean";
/** Cosine similarity (1 - cosine distance) */
DistanceMetric["Cosine"] = "cosine";
/** Dot product similarity */
DistanceMetric["DotProduct"] = "dot";
})(DistanceMetric || (exports.DistanceMetric = DistanceMetric = {}));
/**
* Get platform-specific package name
*/
function getPlatformPackage() {
const plat = (0, node_os_1.platform)();
const architecture = (0, node_os_1.arch)();
// Map Node.js platform names to package names
const packageMap = {
'linux-x64': 'ruvector-core-linux-x64-gnu',
'linux-arm64': 'ruvector-core-linux-arm64-gnu',
'darwin-x64': 'ruvector-core-darwin-x64',
'darwin-arm64': 'ruvector-core-darwin-arm64',
'win32-x64': 'ruvector-core-win32-x64-msvc',
};
const key = `${plat}-${architecture}`;
const packageName = packageMap[key];
if (!packageName) {
throw new Error(`Unsupported platform: ${plat}-${architecture}. ` +
`Supported platforms: ${Object.keys(packageMap).join(', ')}`);
}
return packageName;
}
/**
* Load the native binding for the current platform
*/
function loadNativeBinding() {
const packageName = getPlatformPackage();
try {
// Try to require the platform-specific package
return require(packageName);
}
catch (error) {
// Fallback: try loading from local platforms directory
try {
const plat = (0, node_os_1.platform)();
const architecture = (0, node_os_1.arch)();
const platformKey = `${plat}-${architecture}`;
const platformMap = {
'linux-x64': 'linux-x64-gnu',
'linux-arm64': 'linux-arm64-gnu',
'darwin-x64': 'darwin-x64',
'darwin-arm64': 'darwin-arm64',
'win32-x64': 'win32-x64-msvc',
};
const localPath = `../platforms/${platformMap[platformKey]}/ruvector.node`;
return require(localPath);
}
catch (fallbackError) {
throw new Error(`Failed to load native binding: ${error.message}\n` +
`Fallback also failed: ${fallbackError.message}\n` +
`Platform: ${(0, node_os_1.platform)()}-${(0, node_os_1.arch)()}\n` +
`Expected package: ${packageName}`);
}
}
}
// Load the native module
const nativeBinding = loadNativeBinding();
// Try to load optional attention module
let attention = null;
try {
attention = require('@ruvector/attention');
}
catch {
// Attention module not installed - this is optional
}
// Export everything from the native binding
module.exports = nativeBinding;
// Add VectorDB alias (native exports as VectorDb)
if (nativeBinding.VectorDb && !nativeBinding.VectorDB) {
module.exports.VectorDB = nativeBinding.VectorDb;
}
// Also export as default
module.exports.default = nativeBinding;
// Re-export DistanceMetric
module.exports.DistanceMetric = DistanceMetric;
// Export attention if available
if (attention) {
module.exports.attention = attention;
}
//# sourceMappingURL=index.cjs.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.cjs.js","sourceRoot":"","sources":["index.cjs.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,qCAAyC;AAMzC;;GAEG;AACH,IAAY,cAOX;AAPD,WAAY,cAAc;IACxB,8BAA8B;IAC9B,yCAAuB,CAAA;IACvB,8CAA8C;IAC9C,mCAAiB,CAAA;IACjB,6BAA6B;IAC7B,oCAAkB,CAAA;AACpB,CAAC,EAPW,cAAc,8BAAd,cAAc,QAOzB;AAED;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B,CAAC;YACF,MAAM,SAAS,GAAG,gBAAgB,WAAW,CAAC,WAAW,CAAC,gBAAgB,CAAC;YAC3E,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,aAAkB,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CACb,kCAAkC,KAAK,CAAC,OAAO,IAAI;gBACnD,yBAAyB,aAAa,CAAC,OAAO,IAAI;gBAClD,aAAa,IAAA,kBAAQ,GAAE,IAAI,IAAA,cAAI,GAAE,IAAI;gBACrC,qBAAqB,WAAW,EAAE,CACnC,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED,yBAAyB;AACzB,MAAM,aAAa,GAAG,iBAAiB,EAAE,CAAC;AAE1C,wCAAwC;AACxC,IAAI,SAAS,GAAG,IAAI,CAAC;AACrB,IAAI,CAAC;IACH,SAAS,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAC7C,CAAC;AAAC,MAAM,CAAC;IACP,oDAAoD;AACtD,CAAC;AAED,4CAA4C;AAC5C,MAAM,CAAC,OAAO,GAAG,aAAa,CAAC;AAE/B,kDAAkD;AAClD,IAAI,aAAa,CAAC,QAAQ,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;IACtD,MAAM,CAAC,OAAO,CAAC,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC;AACnD,CAAC;AAED,yBAAyB;AACzB,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,aAAa,CAAC;AAEvC,2BAA2B;AAC3B,MAAM,CAAC,OAAO,CAAC,cAAc,GAAG,cAAc,CAAC;AAE/C,gCAAgC;AAChC,IAAI,SAAS,EAAE,CAAC;IACd,MAAM,CAAC,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;AACvC,CAAC"}

View File

@@ -0,0 +1,117 @@
/**
* @ruvector/core - CommonJS wrapper
*
* This file provides CommonJS compatibility for projects using require()
*/
import { platform, arch } from 'node:os';
// Platform detection types
type Platform = 'linux' | 'darwin' | 'win32';
type Architecture = 'x64' | 'arm64';
/**
* Distance metric for similarity calculation
*/
export enum DistanceMetric {
/** Euclidean (L2) distance */
Euclidean = 'euclidean',
/** Cosine similarity (1 - cosine distance) */
Cosine = 'cosine',
/** Dot product similarity */
DotProduct = 'dot',
}
/**
* Get platform-specific package name
*/
function getPlatformPackage(): string {
const plat = platform() as Platform;
const architecture = arch() as Architecture;
// Map Node.js platform names to package names
const packageMap: Record<string, string> = {
'linux-x64': 'ruvector-core-linux-x64-gnu',
'linux-arm64': 'ruvector-core-linux-arm64-gnu',
'darwin-x64': 'ruvector-core-darwin-x64',
'darwin-arm64': 'ruvector-core-darwin-arm64',
'win32-x64': 'ruvector-core-win32-x64-msvc',
};
const key = `${plat}-${architecture}`;
const packageName = packageMap[key];
if (!packageName) {
throw new Error(
`Unsupported platform: ${plat}-${architecture}. ` +
`Supported platforms: ${Object.keys(packageMap).join(', ')}`
);
}
return packageName;
}
/**
* Load the native binding for the current platform
*/
function loadNativeBinding() {
const packageName = getPlatformPackage();
try {
// Try to require the platform-specific package
return require(packageName);
} catch (error: any) {
// Fallback: try loading from local platforms directory
try {
const plat = platform() as Platform;
const architecture = arch() as Architecture;
const platformKey = `${plat}-${architecture}`;
const platformMap: Record<string, string> = {
'linux-x64': 'linux-x64-gnu',
'linux-arm64': 'linux-arm64-gnu',
'darwin-x64': 'darwin-x64',
'darwin-arm64': 'darwin-arm64',
'win32-x64': 'win32-x64-msvc',
};
const localPath = `../platforms/${platformMap[platformKey]}/ruvector.node`;
return require(localPath);
} catch (fallbackError: any) {
throw new Error(
`Failed to load native binding: ${error.message}\n` +
`Fallback also failed: ${fallbackError.message}\n` +
`Platform: ${platform()}-${arch()}\n` +
`Expected package: ${packageName}`
);
}
}
}
// Load the native module
const nativeBinding = loadNativeBinding();
// Try to load optional attention module
let attention = null;
try {
attention = require('@ruvector/attention');
} catch {
// Attention module not installed - this is optional
}
// Export everything from the native binding
module.exports = nativeBinding;
// Add VectorDB alias (native exports as VectorDb)
if (nativeBinding.VectorDb && !nativeBinding.VectorDB) {
module.exports.VectorDB = nativeBinding.VectorDb;
}
// Also export as default
module.exports.default = nativeBinding;
// Re-export DistanceMetric
module.exports.DistanceMetric = DistanceMetric;
// Export attention if available
if (attention) {
module.exports.attention = attention;
}

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH;;GAEG;AACH,oBAAY,cAAc;IACxB,8BAA8B;IAC9B,SAAS,cAAc;IACvB,gDAAgD;IAChD,MAAM,WAAW;IACjB,2DAA2D;IAC3D,UAAU,eAAe;IACzB,8BAA8B;IAC9B,SAAS,cAAc;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,wBAAwB;IACxB,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IAC/C,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,0CAA0C;IAC1C,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,yDAAyD;IACzD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,wBAAwB;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yBAAyB;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,iCAAiC;IACjC,YAAY,CAAC,EAAE,kBAAkB,CAAC;CACnC;AAED;;GAEG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B,GAAG,aAAa,CAAC,iBAAiB,CAAC;AACpD,QAAA,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC;AAChC,QAAA,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;AAC5B,QAAA,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC;AACtC,QAAA,SAAS,GAAG,aAAa,CAAC,SAAS,CAAC;AAEjD,wCAAwC;AACxC,IAAI,SAAS,GAAQ,IAAI,CAAC;AAQjB,8BAAS;AAPlB,IAAI,CAAC;IACH,oBAAA,SAAS,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAC7C,CAAC;AAAC,MAAM,CAAC;IACP,oDAAoD;AACtD,CAAC;AAKD,iBAAiB;AACjB,kBAAe;IACb,QAAQ,EAAR,gBAAQ;IACR,iBAAiB,EAAjB,yBAAiB;IACjB,OAAO,EAAP,eAAO;IACP,KAAK,EAAL,aAAK;IACL,UAAU,EAAV,kBAAU;IACV,SAAS,EAAT,iBAAS;IACT,cAAc;IACd,iCAAiC;IACjC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;CACpC,CAAC"}

396
vendor/ruvector/npm/core/src/index.ts vendored Normal file
View File

@@ -0,0 +1,396 @@
/**
* @ruvector/core - High-performance Rust vector database for Node.js
*
* Automatically detects platform and loads the appropriate native binding.
*/
import { platform, arch } from 'node:os';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
// Platform detection types
type Platform = 'linux' | 'darwin' | 'win32';
type Architecture = 'x64' | 'arm64';
/**
* Distance metric for similarity calculation
*/
export enum DistanceMetric {
/** Euclidean (L2) distance */
Euclidean = 'Euclidean',
/** Cosine similarity (converted to distance) */
Cosine = 'Cosine',
/** Dot product (converted to distance for maximization) */
DotProduct = 'DotProduct',
/** Manhattan (L1) distance */
Manhattan = 'Manhattan'
}
/**
* Quantization configuration
*/
export interface QuantizationConfig {
/** Quantization type */
type: 'none' | 'scalar' | 'product' | 'binary';
/** Number of subspaces (for product quantization) */
subspaces?: number;
/** Codebook size (for product quantization) */
k?: number;
}
/**
* HNSW index configuration
*/
export interface HnswConfig {
/** Number of connections per layer (M) */
m?: number;
/** Size of dynamic candidate list during construction */
efConstruction?: number;
/** Size of dynamic candidate list during search */
efSearch?: number;
/** Maximum number of elements */
maxElements?: number;
}
/**
* Database configuration options
*/
export interface DbOptions {
/** Vector dimensions */
dimensions: number;
/** Distance metric */
distanceMetric?: DistanceMetric;
/** Storage path */
storagePath?: string;
/** HNSW configuration */
hnswConfig?: HnswConfig;
/** Quantization configuration */
quantization?: QuantizationConfig;
}
/**
* Vector entry
*/
export interface VectorEntry {
/** Optional ID (auto-generated if not provided) */
id?: string;
/** Vector data as Float32Array or array of numbers */
vector: Float32Array | number[];
}
/**
* Search query parameters
*/
export interface SearchQuery {
/** Query vector as Float32Array or array of numbers */
vector: Float32Array | number[];
/** Number of results to return (top-k) */
k: number;
/** Optional ef_search parameter for HNSW */
efSearch?: number;
}
/**
* Search result with similarity score
*/
export interface SearchResult {
/** Vector ID */
id: string;
/** Distance/similarity score (lower is better for distance metrics) */
score: number;
}
/**
* High-performance vector database with HNSW indexing
*/
export interface VectorDB {
/**
* Insert a vector entry into the database
* @param entry Vector entry to insert
* @returns Promise resolving to the ID of the inserted vector
*/
insert(entry: VectorEntry): Promise<string>;
/**
* Insert multiple vectors in a batch
* @param entries Array of vector entries to insert
* @returns Promise resolving to an array of IDs for the inserted vectors
*/
insertBatch(entries: VectorEntry[]): Promise<string[]>;
/**
* Search for similar vectors
* @param query Search query parameters
* @returns Promise resolving to an array of search results sorted by similarity
*/
search(query: SearchQuery): Promise<SearchResult[]>;
/**
* Delete a vector by ID
* @param id Vector ID to delete
* @returns Promise resolving to true if deleted, false if not found
*/
delete(id: string): Promise<boolean>;
/**
* Get a vector by ID
* @param id Vector ID to retrieve
* @returns Promise resolving to the vector entry if found, null otherwise
*/
get(id: string): Promise<VectorEntry | null>;
/**
* Get the number of vectors in the database
* @returns Promise resolving to the number of vectors
*/
len(): Promise<number>;
/**
* Check if the database is empty
* @returns Promise resolving to true if empty, false otherwise
*/
isEmpty(): Promise<boolean>;
}
/**
* VectorDB constructor interface
*/
export interface VectorDBConstructor {
new(options: DbOptions): VectorDB;
withDimensions(dimensions: number): VectorDB;
}
/**
* Filter for metadata-based search
*/
export interface Filter {
/** Field name to filter on */
field: string;
/** Operator: "eq", "ne", "gt", "gte", "lt", "lte", "in", "match" */
operator: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'match';
/** Value to compare against (JSON string) */
value: string;
}
/**
* Collection configuration
*/
export interface CollectionConfig {
/** Vector dimensions */
dimensions: number;
/** Distance metric */
distanceMetric?: DistanceMetric;
/** HNSW configuration */
hnswConfig?: HnswConfig;
/** Quantization configuration */
quantization?: QuantizationConfig;
}
/**
* Collection statistics
*/
export interface CollectionStats {
/** Number of vectors in the collection */
vectorsCount: number;
/** Disk space used in bytes */
diskSizeBytes: number;
/** RAM space used in bytes */
ramSizeBytes: number;
}
/**
* Collection alias
*/
export interface Alias {
/** Alias name */
alias: string;
/** Collection name */
collection: string;
}
/**
* Health response
*/
export interface HealthResponse {
/** Status: "healthy", "degraded", or "unhealthy" */
status: 'healthy' | 'degraded' | 'unhealthy';
/** Version string */
version: string;
/** Uptime in seconds */
uptimeSeconds: number;
}
/**
* Collection manager for multi-collection support
*/
export interface CollectionManager {
/**
* Create a new collection
* @param name Collection name
* @param config Collection configuration
*/
createCollection(name: string, config: CollectionConfig): Promise<void>;
/**
* List all collections
* @returns Array of collection names
*/
listCollections(): Promise<string[]>;
/**
* Delete a collection
* @param name Collection name to delete
*/
deleteCollection(name: string): Promise<void>;
/**
* Get collection statistics
* @param name Collection name
* @returns Collection statistics
*/
getStats(name: string): Promise<CollectionStats>;
/**
* Create an alias for a collection
* @param alias Alias name
* @param collection Collection name
*/
createAlias(alias: string, collection: string): Promise<void>;
/**
* Delete an alias
* @param alias Alias name to delete
*/
deleteAlias(alias: string): Promise<void>;
/**
* List all aliases
* @returns Array of alias mappings
*/
listAliases(): Promise<Alias[]>;
}
/**
* CollectionManager constructor interface
*/
export interface CollectionManagerConstructor {
new(basePath?: string): CollectionManager;
}
/**
* Native binding interface
*/
export interface NativeBinding {
VectorDB: VectorDBConstructor;
CollectionManager: CollectionManagerConstructor;
version(): string;
hello(): string;
getMetrics(): string;
getHealth(): HealthResponse;
}
/**
* Detect the current platform and architecture
*/
function detectPlatform(): { platform: Platform; arch: Architecture; packageName: string } {
const currentPlatform = platform() as Platform;
const currentArch = arch() as Architecture;
// Map platform and architecture to package names
const platformMap: Record<string, string> = {
'linux-x64': '@ruvector/core-linux-x64-gnu',
'linux-arm64': '@ruvector/core-linux-arm64-gnu',
'darwin-x64': '@ruvector/core-darwin-x64',
'darwin-arm64': '@ruvector/core-darwin-arm64',
'win32-x64': '@ruvector/core-win32-x64-msvc'
};
const key = `${currentPlatform}-${currentArch}`;
const packageName = platformMap[key];
if (!packageName) {
throw new Error(
`Unsupported platform: ${currentPlatform}-${currentArch}. ` +
`Supported platforms: ${Object.keys(platformMap).join(', ')}`
);
}
return { platform: currentPlatform, arch: currentArch, packageName };
}
/**
* Load the native binding for the current platform
*/
function loadNativeBinding(): NativeBinding {
const currentPlatform = platform();
const currentArch = arch();
const platformKey = `${currentPlatform}-${currentArch}`;
try {
// Try to load from native directory first (for direct builds)
// Use the wrapper index.cjs if it exists, otherwise load the .node file directly
try {
const nativeBinding = require(`../native/${platformKey}/index.cjs`) as NativeBinding;
return nativeBinding;
} catch {
const nativeBinding = require(`../native/${platformKey}/ruvector.node`) as NativeBinding;
return nativeBinding;
}
} catch (error) {
// Fallback to platform-specific packages
const { packageName } = detectPlatform();
try {
const nativeBinding = require(packageName) as NativeBinding;
return nativeBinding;
} catch (packageError) {
// Provide helpful error message
const err = packageError as NodeJS.ErrnoException;
if (err.code === 'MODULE_NOT_FOUND') {
throw new Error(
`Failed to load native binding for ${platformKey}. ` +
`Tried: ../native/${platformKey}/ruvector.node and ${packageName}. ` +
`Please ensure the package is installed by running: npm install ${packageName}`
);
}
throw new Error(`Failed to load native binding: ${err.message}`);
}
}
}
// Load the native binding
const nativeBinding = loadNativeBinding();
// Re-export the VectorDB class and utility functions
// Note: NAPI-RS exports as VectorDb (lowercase d), we re-export as VectorDB for consistency
export const VectorDB = (nativeBinding as any).VectorDb || nativeBinding.VectorDB;
export const CollectionManager = nativeBinding.CollectionManager;
export const version = nativeBinding.version;
export const hello = nativeBinding.hello;
export const getMetrics = nativeBinding.getMetrics;
export const getHealth = nativeBinding.getHealth;
// Try to load optional attention module
let attention: any = null;
try {
attention = require('@ruvector/attention');
} catch {
// Attention module not installed - this is optional
}
// Export attention if available
export { attention };
// Default export
export default {
VectorDB,
CollectionManager,
version,
hello,
getMetrics,
getHealth,
DistanceMetric,
// Include attention if available
...(attention ? { attention } : {})
};

View File

@@ -0,0 +1,46 @@
/**
* Test to inspect what's actually exported from the native binding
*/
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
try {
const nativeBinding = require('./native/linux-x64/ruvector.node');
console.log('=== Native Binding Inspection ===\n');
console.log('Type:', typeof nativeBinding);
console.log('Is null:', nativeBinding === null);
console.log('Is undefined:', nativeBinding === undefined);
console.log('\nKeys:', Object.keys(nativeBinding));
console.log('\nProperties:');
for (const key of Object.keys(nativeBinding)) {
const value = nativeBinding[key];
console.log(` ${key}: ${typeof value}`);
if (typeof value === 'object' && value !== null) {
console.log(` Methods:`, Object.keys(value));
}
if (typeof value === 'function') {
console.log(` Is constructor:`, value.prototype !== undefined);
if (value.prototype) {
console.log(` Prototype methods:`, Object.getOwnPropertyNames(value.prototype));
}
}
}
console.log('\n=== Testing Functions ===\n');
if (nativeBinding.version) {
console.log('version():', nativeBinding.version());
}
if (nativeBinding.hello) {
console.log('hello():', nativeBinding.hello());
}
} catch (error) {
console.error('Error:', error.message);
console.error(error.stack);
}

View File

@@ -0,0 +1,77 @@
/**
* Test script to verify native module loads correctly
*/
import ruvector from './dist/index.js';
console.log('=== Ruvector Native Module Test ===\n');
try {
// Test 1: Load module
console.log('✓ Module imported successfully');
console.log('Available exports:', Object.keys(ruvector));
// Test 2: Get version
console.log('\n--- Version Info ---');
console.log('Version:', ruvector.version());
// Test 3: Hello function
console.log('\n--- Hello Test ---');
console.log(ruvector.hello());
// Test 4: Create VectorDB instance
console.log('\n--- VectorDB Creation ---');
const db = ruvector.VectorDB.withDimensions(384);
console.log('✓ VectorDB created with 384 dimensions');
// Test 5: Check database is empty
console.log('\n--- Database Status ---');
const isEmpty = await db.isEmpty();
console.log('Database is empty:', isEmpty);
const len = await db.len();
console.log('Database length:', len);
// Test 6: Insert a vector
console.log('\n--- Insert Vector ---');
const testVector = new Float32Array(384).fill(0.1);
const id = await db.insert({
vector: testVector,
});
console.log('✓ Inserted vector with ID:', id);
const newLen = await db.len();
console.log('Database length after insert:', newLen);
// Test 7: Search
console.log('\n--- Search Test ---');
const queryVector = new Float32Array(384).fill(0.15);
const results = await db.search({
vector: queryVector,
k: 10
});
console.log('✓ Search completed');
console.log('Found', results.length, 'results');
if (results.length > 0) {
console.log('First result:', {
id: results[0].id,
score: results[0].score
});
}
// Test 8: Get vector
console.log('\n--- Get Vector Test ---');
const retrieved = await db.get(id);
if (retrieved) {
console.log('✓ Retrieved vector with ID:', retrieved.id);
console.log('Vector length:', retrieved.vector.length);
}
console.log('\n=== ✅ All tests passed! ===\n');
process.exit(0);
} catch (error) {
console.error('\n❌ Test failed:', error.message);
console.error(error.stack);
process.exit(1);
}

View File

@@ -0,0 +1,124 @@
#!/usr/bin/env node
/**
* Test script for @ruvector/core-linux-x64-gnu package
* Verifies that the native binary loads correctly
*/
const fs = require('fs');
const path = require('path');
console.log('🧪 Testing @ruvector/core-linux-x64-gnu package...\n');
// Test 1: Check files exist
console.log('📁 Test 1: Checking file structure...');
const platformDir = path.join(__dirname, 'platforms/linux-x64-gnu');
const requiredFiles = [
'index.js',
'ruvector.node',
'package.json',
'README.md'
];
let filesOk = true;
for (const file of requiredFiles) {
const filePath = path.join(platformDir, file);
if (fs.existsSync(filePath)) {
const stats = fs.statSync(filePath);
const size = stats.size > 1024 * 1024
? `${(stats.size / (1024 * 1024)).toFixed(2)} MB`
: `${(stats.size / 1024).toFixed(2)} KB`;
console.log(`${file} (${size})`);
} else {
console.log(`${file} - MISSING`);
filesOk = false;
}
}
if (!filesOk) {
console.error('\n❌ File structure test FAILED');
process.exit(1);
}
console.log('\n✅ File structure test PASSED\n');
// Test 2: Load native module
console.log('📦 Test 2: Loading native module...');
try {
const nativeModule = require(path.join(platformDir, 'index.js'));
console.log(' ✅ Native module loaded successfully');
console.log(' Module exports:', Object.keys(nativeModule).join(', '));
console.log('\n✅ Native module test PASSED\n');
} catch (error) {
console.error(' ❌ Failed to load native module:', error.message);
console.error('\n❌ Native module test FAILED');
process.exit(1);
}
// Test 3: Create database instance
console.log('🗄️ Test 3: Creating database instance...');
try {
const { VectorDb } = require(path.join(platformDir, 'index.js'));
const db = new VectorDb({
dimensions: 128,
maxElements: 1000,
storagePath: `/tmp/ruvector-test-${Date.now()}-1.db`
});
console.log(' ✅ Database instance created successfully');
console.log('\n✅ Database creation test PASSED\n');
} catch (error) {
console.error(' ❌ Failed to create database:', error.message);
console.error('\n❌ Database creation test FAILED');
process.exit(1);
}
// Test 4: Basic operations
console.log('🔧 Test 4: Testing basic operations...');
(async () => {
try {
const { VectorDb } = require(path.join(platformDir, 'index.js'));
const db = new VectorDb({
dimensions: 3,
maxElements: 100,
storagePath: `/tmp/ruvector-test-${Date.now()}-2.db`
});
// Insert vector
const vector = new Float32Array([0.1, 0.2, 0.3]);
const id = await db.insert({
id: 'test_vector',
vector: vector
});
console.log(` ✅ Inserted vector with ID: ${id}`);
// Count vectors
const count = await db.len();
console.log(` ✅ Vector count: ${count}`);
// Search
const queryVector = new Float32Array([0.1, 0.2, 0.3]);
const results = await db.search({
vector: queryVector,
k: 1
});
console.log(` ✅ Search returned ${results.length} result(s)`);
if (results.length > 0) {
console.log(` - ID: ${results[0].id}, Score: ${results[0].score.toFixed(6)}`);
}
// Delete
const deleted = await db.delete('test_vector');
console.log(` ✅ Deleted vector: ${deleted}`);
console.log('\n✅ Basic operations test PASSED\n');
console.log('🎉 All tests PASSED!\n');
console.log('Package is ready for publishing.');
} catch (error) {
console.error(' ❌ Basic operations failed:', error.message);
console.error(error.stack);
console.error('\n❌ Basic operations test FAILED');
process.exit(1);
}
})();

View File

@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"moduleResolution": "Node",
"outDir": "./dist-cjs",
"target": "ES2020"
},
"include": ["src/index.cjs.ts"],
"exclude": ["node_modules", "dist"]
}

25
vendor/ruvector/npm/core/tsconfig.json vendored Normal file
View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "Node16",
"moduleResolution": "Node16",
"lib": ["ES2022"],
"outDir": "./dist",
"rootDir": "./src",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "**/*.test.ts"]
}