AgentSkillsCN

@ruvector/edge-full

完整的 WASM 边缘工具包:向量搜索、图数据库、神经网络、DAG 工作流、SQL/SPARQL/Cypher、ONNX 推理。适用于用户需要在浏览器或边缘环境中,拥有一站式边缘 AI 运行时,同时支持向量搜索、图查询、神经推理、任务调度,或多种查询语言的协同使用。

SKILL.md
--- frontmatter
name: "@ruvector/edge-full"
description: "Complete WASM edge toolkit: vector search, graph DB, neural networks, DAG workflows, SQL/SPARQL/Cypher, ONNX inference. Use when the user needs an all-in-one edge AI runtime with vector search, graph queries, neural inference, task scheduling, or multi-query-language support in browser or edge environments."

@ruvector/edge-full

Complete WASM edge toolkit combining vector search, graph database, neural networks, DAG-based workflow scheduling, SQL/SPARQL/Cypher query support, and ONNX inference into a single browser-compatible package.

Quick Command Reference

TaskCode
Initialize runtimeconst rt = new EdgeRuntime()
Start runtimeawait rt.start()
Vector searchawait rt.vectors.search(query, 10)
Graph queryawait rt.graph.query("MATCH (n) RETURN n")
Neural inferenceawait rt.neural.infer(input)
DAG workflowawait rt.dag.execute(workflow)
SQL queryawait rt.sql("SELECT * FROM vectors WHERE ...")
SPARQL queryawait rt.sparql("SELECT ?s WHERE { ?s ?p ?o }")

Installation

Hub install (recommended): npx ruvector@latest includes this package. Standalone: npx @ruvector/edge-full@latest See Installation Guide for the full ecosystem.

Core API

EdgeRuntime Constructor

typescript
import { EdgeRuntime } from '@ruvector/edge-full';

const rt = new EdgeRuntime({
  vectorDimensions: 384,
  enableGraph: true,
  enableNeural: true,
  enableDAG: true,
  workers: 4,
});
await rt.start();

Constructor Options:

ParameterTypeDescriptionDefault
vectorDimensionsnumberVector DB dimensions384
vectorMetricstringDistance metric'cosine'
enableGraphbooleanEnable graph DBtrue
enableNeuralbooleanEnable ONNX inferencefalse
enableDAGbooleanEnable DAG workflowstrue
workersnumberWeb Worker countAuto
persistToIndexedDBbooleanAuto-persist to IndexedDBfalse

Vector Search Subsystem (rt.vectors)

typescript
await rt.vectors.insert('doc-1', vector, metadata);
await rt.vectors.batchInsert(items);
const results = await rt.vectors.search(queryVector, 10);
await rt.vectors.buildIndex();
await rt.vectors.delete('doc-1');

Graph DB Subsystem (rt.graph)

typescript
// Cypher queries
await rt.graph.query("CREATE (n:Person {name: 'Alice'})");
const result = await rt.graph.query("MATCH (n:Person) RETURN n");

// Vertex/Edge operations
await rt.graph.addVertex('person', { name: 'Alice' });
await rt.graph.addEdge('person:1', 'person:2', 'KNOWS', { since: 2024 });
const neighbors = await rt.graph.neighbors('person:1');

Neural Inference Subsystem (rt.neural)

typescript
await rt.neural.loadModel('/models/classifier.onnx');
const output = await rt.neural.infer(inputTensor);
await rt.neural.unloadModel();

DAG Workflow Engine (rt.dag)

typescript
const workflow = {
  nodes: [
    { id: 'embed', fn: embedText },
    { id: 'search', fn: searchVectors, deps: ['embed'] },
    { id: 'rank', fn: rerankResults, deps: ['search'] },
  ],
};
const result = await rt.dag.execute(workflow);

Multi-Language Queries

typescript
// SQL
await rt.sql("SELECT id, metadata FROM vectors WHERE score > 0.8");

// SPARQL
await rt.sparql("SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10");

// Cypher
await rt.graph.query("MATCH (a)-[:KNOWS]->(b) RETURN a.name, b.name");

Common Patterns

Full RAG Pipeline in Browser

typescript
const rt = new EdgeRuntime({ vectorDimensions: 384, enableNeural: true });
await rt.start();
await rt.neural.loadModel('/models/embedder.onnx');
// Embed and index documents
for (const doc of docs) {
  const vec = await rt.neural.infer(tokenize(doc.text));
  await rt.vectors.insert(doc.id, vec, { text: doc.text });
}
await rt.vectors.buildIndex();
// Query
const queryVec = await rt.neural.infer(tokenize(userQuery));
const results = await rt.vectors.search(queryVec, 5);

Knowledge Graph with Vector Search

typescript
// Combine graph traversal with vector similarity
await rt.graph.query("CREATE (n:Topic {name: 'AI', embedding: $vec})", { vec: aiVector });
const graphResults = await rt.graph.query("MATCH (n:Topic) RETURN n");
const similarTopics = await rt.vectors.search(queryVector, 10);

Offline DAG Pipeline

typescript
const pipeline = {
  nodes: [
    { id: 'fetch', fn: fetchFromCache },
    { id: 'process', fn: processData, deps: ['fetch'] },
    { id: 'store', fn: storeResults, deps: ['process'] },
  ],
};
await rt.dag.execute(pipeline); // Runs fully offline

Key Options

FeatureComponent
Vector searchHNSW (WASM)
Graph DBCypher + SPARQL
Neural inferenceONNX Runtime (WASM)
WorkflowsDAG scheduler
Query languagesSQL, SPARQL, Cypher
PersistenceIndexedDB

RAN DDD Context

Bounded Context: Edge/WASM Runtime

References