Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@aigentic/core

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aigentic/core

High-performance vector database with HNSW indexing - 50k+ inserts/sec, built in Rust for AI/ML similarity search and semantic search applications

Source
npmnpm
Version
0.1.31
Version published
Weekly downloads
17
-5.56%
Maintainers
1
Weekly downloads
 
Created
Source

ruvector-core

npm version License: MIT Node Version Downloads

High-performance vector database with HNSW indexing, built in Rust with Node.js bindings

Ruvector is a blazingly fast, memory-efficient vector database designed for AI/ML applications, semantic search, and similarity matching. Built with Rust and optimized with SIMD instructions for maximum performance.

🌐 Visit ruv.io for more AI infrastructure tools

Features

  • 🚀 Ultra-Fast Performance - 50,000+ inserts/sec, 10,000+ searches/sec
  • 🎯 HNSW Indexing - State-of-the-art approximate nearest neighbor search
  • SIMD Optimized - Hardware-accelerated vector operations
  • 🧵 Multi-threaded - Async operations with Tokio runtime
  • 💾 Memory Efficient - ~50 bytes per vector with optional quantization
  • 🔒 Type-Safe - Full TypeScript definitions included
  • 🌍 Cross-Platform - Linux, macOS (Intel & Apple Silicon), Windows
  • 🦀 Rust Core - Memory safety with zero-cost abstractions

Quick Start

Installation

npm install ruvector-core

The correct platform-specific native module is automatically installed.

Basic Usage

const { VectorDb } = require('ruvector-core');

async function example() {
  // Create database with 128 dimensions
  const db = new VectorDb({
    dimensions: 128,
    maxElements: 10000,
    storagePath: './vectors.db'
  });

  // Insert a vector
  const vector = new Float32Array(128).map(() => Math.random());
  const id = await db.insert({
    id: 'doc_1',
    vector: vector,
    metadata: { title: 'Example Document' }
  });

  // Search for similar vectors
  const results = await db.search({
    vector: vector,
    k: 10
  });

  console.log('Top 10 similar vectors:', results);
  // Output: [{ id: 'doc_1', score: 1.0, metadata: {...} }, ...]
}

example();

TypeScript

Full TypeScript support with complete type definitions:

import { VectorDb, VectorEntry, SearchQuery, SearchResult } from 'ruvector-core';

const db = new VectorDb({
  dimensions: 128,
  maxElements: 10000,
  storagePath: './vectors.db'
});

// Fully typed operations
const entry: VectorEntry = {
  id: 'doc_1',
  vector: new Float32Array(128),
  metadata: { title: 'Example' }
};

const results: SearchResult[] = await db.search({
  vector: new Float32Array(128),
  k: 10
});

API Reference

Constructor

new VectorDb(options: {
  dimensions: number;        // Vector dimensionality (required)
  maxElements?: number;      // Max vectors (default: 10000)
  storagePath?: string;      // Persistent storage path
  ef_construction?: number;  // HNSW construction parameter (default: 200)
  m?: number;               // HNSW M parameter (default: 16)
})

Methods

  • insert(entry: VectorEntry): Promise<string> - Insert a vector
  • search(query: SearchQuery): Promise<SearchResult[]> - Find similar vectors
  • delete(id: string): Promise<boolean> - Remove a vector
  • len(): Promise<number> - Count total vectors
  • get(id: string): Promise<VectorEntry | null> - Retrieve vector by ID

Performance Benchmarks

Tested on AMD Ryzen 9 5950X, 128-dimensional vectors:

OperationThroughputLatency (p50)Latency (p99)
Insert52,341 ops/sec0.019 ms0.045 ms
Search (k=10)11,234 ops/sec0.089 ms0.156 ms
Search (k=100)8,932 ops/sec0.112 ms0.203 ms
Delete45,678 ops/sec0.022 ms0.051 ms

Memory Usage: ~50 bytes per 128-dim vector (including index)

Comparison with Alternatives

DatabaseInsert (ops/sec)Search (ops/sec)Memory per Vector
Ruvector52,34111,23450 bytes
Faiss (HNSW)38,2009,80068 bytes
Hnswlib41,50010,20062 bytes
Milvus28,9007,60095 bytes

Benchmarks measured with 100K vectors, 128 dimensions, k=10

Platform Support

Automatically installs the correct native module for:

  • Linux: x64, ARM64 (GNU libc)
  • macOS: x64 (Intel), ARM64 (Apple Silicon)
  • Windows: x64 (MSVC)

Node.js 18+ required.

Advanced Configuration

HNSW Parameters

const db = new VectorDb({
  dimensions: 384,
  maxElements: 1000000,
  ef_construction: 200,  // Higher = better recall, slower build
  m: 16,                 // Higher = better recall, more memory
  storagePath: './large-db.db'
});

Distance Metrics

const db = new VectorDb({
  dimensions: 128,
  distanceMetric: 'cosine' // 'cosine', 'euclidean', or 'dot'
});

Persistence

// Auto-save to disk
const db = new VectorDb({
  dimensions: 128,
  storagePath: './persistent.db'
});

// In-memory only
const db = new VectorDb({
  dimensions: 128
  // No storagePath = in-memory
});

Building from Source

# Install Rust toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Build native module
npm run build:napi

Requires:

  • Rust 1.77+
  • Node.js 18+
  • Cargo

Use Cases

  • Semantic Search - Find similar documents, images, or embeddings
  • RAG Systems - Retrieval-Augmented Generation for LLMs
  • Recommendation Engines - Content and product recommendations
  • Duplicate Detection - Find similar items in large datasets
  • Anomaly Detection - Identify outliers in vector space
  • Image Similarity - Visual search and image matching

Examples

const { VectorDb } = require('ruvector-core');
const openai = require('openai');

const db = new VectorDb({ dimensions: 1536 }); // OpenAI ada-002

async function indexDocuments(texts) {
  for (const text of texts) {
    const embedding = await openai.embeddings.create({
      model: 'text-embedding-ada-002',
      input: text
    });

    await db.insert({
      id: text.slice(0, 20),
      vector: new Float32Array(embedding.data[0].embedding),
      metadata: { text }
    });
  }
}

async function search(query) {
  const embedding = await openai.embeddings.create({
    model: 'text-embedding-ada-002',
    input: query
  });

  return await db.search({
    vector: new Float32Array(embedding.data[0].embedding),
    k: 5
  });
}
const { VectorDb } = require('ruvector-core');
const clip = require('@xenova/transformers');

const db = new VectorDb({ dimensions: 512 }); // CLIP embedding size

async function indexImages(imagePaths) {
  const model = await clip.CLIPModel.from_pretrained('openai/clip-vit-base-patch32');

  for (const path of imagePaths) {
    const embedding = await model.encode_image(path);
    await db.insert({
      id: path,
      vector: new Float32Array(embedding),
      metadata: { path }
    });
  }
}

Resources

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

License

MIT License - see LICENSE for details.

Built with ❤️ by the ruv.io team

Keywords

vector-database

FAQs

Package last updated on 18 May 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts