Merge commit 'd803bfe2b1fe7f5e219e50ac20d6801a0a58ac75' as 'vendor/ruvector'
This commit is contained in:
21
vendor/ruvector/examples/edge-full/pkg/LICENSE
vendored
Normal file
21
vendor/ruvector/examples/edge-full/pkg/LICENSE
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 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.
|
||||
390
vendor/ruvector/examples/edge-full/pkg/README.md
vendored
Normal file
390
vendor/ruvector/examples/edge-full/pkg/README.md
vendored
Normal file
@@ -0,0 +1,390 @@
|
||||
# @ruvector/edge-full
|
||||
|
||||
[](https://www.npmjs.com/package/@ruvector/edge-full)
|
||||
[](https://www.rust-lang.org/)
|
||||
[](LICENSE)
|
||||
[]()
|
||||
|
||||
## The Complete Edge AI Toolkit
|
||||
|
||||
**Run AI agent swarms, graph databases, neural networks, workflow engines, and ONNX inference - all in the browser, all for free.**
|
||||
|
||||
@ruvector/edge-full is the batteries-included version of the RuVector edge computing platform. It bundles six powerful WASM modules into a single package, giving you everything you need to build sophisticated distributed AI systems that run entirely on user devices.
|
||||
|
||||
### What's Inside
|
||||
|
||||
| Module | Size | What It Does |
|
||||
|--------|------|--------------|
|
||||
| **Edge Core** | 364KB | Cryptographic identity (Ed25519), AES-256-GCM encryption, HNSW vector search, Raft consensus, spiking neural networks, post-quantum signatures |
|
||||
| **Graph DB** | 288KB | Neo4j-style graph database with Cypher query language, relationship modeling, traversal algorithms |
|
||||
| **RVLite** | 260KB | Multi-query vector database supporting SQL, SPARQL, and Cypher - semantic search with familiar syntax |
|
||||
| **SONA** | 238KB | Self-Optimizing Neural Architecture - LoRA fine-tuning, EWC++, ReasoningBank for adaptive learning |
|
||||
| **DAG** | 132KB | Directed acyclic graph engine for workflow orchestration, dependency resolution, topological execution |
|
||||
| **ONNX** | 7.1MB | Full ONNX inference engine with 6 pre-trained HuggingFace embedding models, parallel worker support |
|
||||
|
||||
**Total: 1.28MB core + 7.1MB optional ONNX = 8.4MB complete**
|
||||
|
||||
### Why Use This?
|
||||
|
||||
- **Zero Infrastructure Cost**: Everything runs in the browser. No servers, no API keys, no monthly bills.
|
||||
- **Complete Feature Set**: Vector search + graph database + neural networks + workflow engine + embeddings. All in one package.
|
||||
- **True P2P**: Agents communicate directly via WebRTC, GUN.js, libp2p, or Nostr. No central server required.
|
||||
- **Self-Learning**: SONA provides continuous improvement through LoRA fine-tuning and experience replay.
|
||||
- **Production-Ready**: Post-quantum cryptography, Byzantine fault tolerance, encrypted communication.
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
npm install @ruvector/edge-full
|
||||
```
|
||||
|
||||
### Initialize All Modules
|
||||
|
||||
```javascript
|
||||
import { initAll } from '@ruvector/edge-full';
|
||||
|
||||
// Initialize all core modules (excludes ONNX for faster startup)
|
||||
const { edge, graph, rvlite, sona, dag } = await initAll();
|
||||
|
||||
// Create agent identity
|
||||
const identity = new edge.WasmIdentity.generate();
|
||||
console.log(`Agent: ${identity.agent_id()}`);
|
||||
|
||||
// Build a knowledge graph
|
||||
const graphStore = new graph.WasmGraphStore();
|
||||
graphStore.run_cypher("CREATE (a:Agent {id: 'agent-1', type: 'researcher'})");
|
||||
|
||||
// Vector search with SQL
|
||||
const db = new rvlite.Database();
|
||||
db.execute("CREATE TABLE memories (id TEXT, embedding BLOB)");
|
||||
|
||||
// Self-learning neural routing
|
||||
const sonaEngine = new sona.SonaEngine();
|
||||
sonaEngine.route_request({ task: "analyze code", context: "rust" });
|
||||
|
||||
// Workflow orchestration
|
||||
const workflow = new dag.Dag();
|
||||
workflow.add_node("fetch");
|
||||
workflow.add_node("process");
|
||||
workflow.add_edge("fetch", "process");
|
||||
```
|
||||
|
||||
### Selective Module Loading
|
||||
|
||||
```javascript
|
||||
import { initModules } from '@ruvector/edge-full';
|
||||
|
||||
// Only load what you need
|
||||
const { edge, graph } = await initModules(['edge', 'graph']);
|
||||
|
||||
// Or import modules directly
|
||||
import init from '@ruvector/edge-full/edge';
|
||||
import graphInit, { WasmGraphStore } from '@ruvector/edge-full/graph';
|
||||
|
||||
await init();
|
||||
await graphInit();
|
||||
```
|
||||
|
||||
### Add ONNX Embeddings
|
||||
|
||||
```javascript
|
||||
import onnxInit, { WasmEmbedder } from '@ruvector/edge-full/onnx';
|
||||
|
||||
await onnxInit();
|
||||
|
||||
const embedder = new WasmEmbedder();
|
||||
await embedder.load_model('all-MiniLM-L6-v2'); // 384-dimensional embeddings
|
||||
|
||||
const embedding = await embedder.embed("The quick brown fox");
|
||||
console.log(`Dimensions: ${embedding.length}`); // 384
|
||||
```
|
||||
|
||||
## Module Deep Dive
|
||||
|
||||
### Edge Core - Cryptographic Foundation
|
||||
|
||||
```javascript
|
||||
import init, {
|
||||
WasmIdentity, // Ed25519 key pairs
|
||||
WasmCrypto, // AES-256-GCM encryption
|
||||
WasmHnswIndex, // 150x faster vector search
|
||||
WasmRaftNode, // Distributed consensus
|
||||
WasmHybridKeyPair, // Post-quantum signatures
|
||||
WasmSpikingNetwork // Bio-inspired neural nets
|
||||
} from '@ruvector/edge-full/edge';
|
||||
|
||||
await init();
|
||||
|
||||
// Create cryptographic identity
|
||||
const identity = WasmIdentity.generate();
|
||||
const signature = identity.sign(new TextEncoder().encode("hello"));
|
||||
const verified = identity.verify(new TextEncoder().encode("hello"), signature);
|
||||
|
||||
// Encrypted communication
|
||||
const crypto = new WasmCrypto();
|
||||
const encrypted = crypto.encrypt(data, key, nonce);
|
||||
|
||||
// HNSW vector index (150x faster than brute force)
|
||||
const index = new WasmHnswIndex(384, 16, 200); // dimensions, M, ef_construction
|
||||
index.add(0, embedding1);
|
||||
index.add(1, embedding2);
|
||||
const neighbors = index.search(queryVector, 10); // top 10 results
|
||||
|
||||
// Raft consensus for distributed state
|
||||
const node = new WasmRaftNode('node-1', ['node-1', 'node-2', 'node-3']);
|
||||
node.start_election();
|
||||
```
|
||||
|
||||
### Graph DB - Neo4j in the Browser
|
||||
|
||||
```javascript
|
||||
import graphInit, { WasmGraphStore } from '@ruvector/edge-full/graph';
|
||||
|
||||
await graphInit();
|
||||
|
||||
const store = new WasmGraphStore();
|
||||
|
||||
// Create nodes and relationships
|
||||
store.run_cypher(`
|
||||
CREATE (alice:Person {name: 'Alice', role: 'researcher'})
|
||||
CREATE (bob:Person {name: 'Bob', role: 'developer'})
|
||||
CREATE (alice)-[:COLLABORATES_WITH]->(bob)
|
||||
`);
|
||||
|
||||
// Query the graph
|
||||
const results = store.run_cypher(`
|
||||
MATCH (p:Person)-[:COLLABORATES_WITH]->(colleague)
|
||||
RETURN p.name, colleague.name
|
||||
`);
|
||||
|
||||
// Complex traversals
|
||||
const paths = store.run_cypher(`
|
||||
MATCH path = (start:Person)-[:KNOWS*1..3]->(end:Person)
|
||||
WHERE start.name = 'Alice'
|
||||
RETURN path
|
||||
`);
|
||||
```
|
||||
|
||||
### RVLite - SQL + SPARQL + Cypher Vector DB
|
||||
|
||||
```javascript
|
||||
import rvliteInit, { Database } from '@ruvector/edge-full/rvlite';
|
||||
|
||||
await rvliteInit();
|
||||
|
||||
const db = new Database();
|
||||
|
||||
// SQL for familiar operations
|
||||
db.execute(`
|
||||
CREATE TABLE documents (
|
||||
id TEXT PRIMARY KEY,
|
||||
content TEXT,
|
||||
embedding BLOB
|
||||
)
|
||||
`);
|
||||
|
||||
db.execute(`INSERT INTO documents VALUES (?, ?, ?)`,
|
||||
['doc-1', 'Machine learning basics', embedding1]);
|
||||
|
||||
// Semantic search
|
||||
const similar = db.execute(`
|
||||
SELECT * FROM documents
|
||||
ORDER BY vector_distance(embedding, ?)
|
||||
LIMIT 5
|
||||
`, [queryEmbedding]);
|
||||
|
||||
// SPARQL for knowledge graphs
|
||||
const sparqlResults = db.sparql(`
|
||||
PREFIX ex: <http://example.org/>
|
||||
SELECT ?name ?type
|
||||
WHERE {
|
||||
?entity ex:type ?type .
|
||||
?entity ex:name ?name .
|
||||
FILTER (?type = "Agent")
|
||||
}
|
||||
`);
|
||||
```
|
||||
|
||||
### SONA - Self-Learning Neural Router
|
||||
|
||||
```javascript
|
||||
import sonaInit, { SonaEngine, ReasoningBank } from '@ruvector/edge-full/sona';
|
||||
|
||||
await sonaInit();
|
||||
|
||||
const engine = new SonaEngine();
|
||||
const reasoningBank = new ReasoningBank();
|
||||
|
||||
// Route tasks to best agent
|
||||
const decision = await engine.route_request({
|
||||
task: "review pull request",
|
||||
context: { language: "rust", complexity: "high" },
|
||||
available_agents: [
|
||||
{ id: "agent-1", capabilities: ["rust", "code-review"] },
|
||||
{ id: "agent-2", capabilities: ["testing", "qa"] }
|
||||
]
|
||||
});
|
||||
|
||||
console.log(`Routed to: ${decision.selected_agent}`);
|
||||
console.log(`Confidence: ${decision.confidence}`);
|
||||
|
||||
// Learn from outcomes
|
||||
reasoningBank.record_trajectory({
|
||||
state: "review pull request",
|
||||
action: decision.selected_agent,
|
||||
reward: 0.95, // positive outcome
|
||||
timestamp: Date.now()
|
||||
});
|
||||
|
||||
// Apply LoRA fine-tuning
|
||||
await engine.apply_lora_update({
|
||||
positive_examples: ["rust expert handled rust code well"],
|
||||
negative_examples: []
|
||||
});
|
||||
```
|
||||
|
||||
### DAG - Workflow Orchestration
|
||||
|
||||
```javascript
|
||||
import dagInit, { Dag } from '@ruvector/edge-full/dag';
|
||||
|
||||
await dagInit();
|
||||
|
||||
const workflow = new Dag();
|
||||
|
||||
// Define workflow steps
|
||||
workflow.add_node("fetch_data");
|
||||
workflow.add_node("validate");
|
||||
workflow.add_node("transform");
|
||||
workflow.add_node("store");
|
||||
|
||||
// Define dependencies
|
||||
workflow.add_edge("fetch_data", "validate");
|
||||
workflow.add_edge("validate", "transform");
|
||||
workflow.add_edge("transform", "store");
|
||||
|
||||
// Get execution order
|
||||
const order = workflow.topological_sort();
|
||||
console.log(order); // ["fetch_data", "validate", "transform", "store"]
|
||||
|
||||
// Check for cycles
|
||||
if (workflow.has_cycle()) {
|
||||
console.error("Invalid workflow!");
|
||||
}
|
||||
|
||||
// Get dependencies for a node
|
||||
const deps = workflow.get_dependencies("transform");
|
||||
console.log(deps); // ["validate"]
|
||||
```
|
||||
|
||||
### ONNX - HuggingFace Embeddings
|
||||
|
||||
```javascript
|
||||
import onnxInit, { WasmEmbedder } from '@ruvector/edge-full/onnx';
|
||||
|
||||
await onnxInit();
|
||||
|
||||
const embedder = new WasmEmbedder();
|
||||
|
||||
// Available models:
|
||||
// - all-MiniLM-L6-v2 (384D, fastest)
|
||||
// - all-MiniLM-L12-v2 (384D, better quality)
|
||||
// - bge-small-en-v1.5 (384D, SOTA)
|
||||
// - bge-base-en-v1.5 (768D, highest quality)
|
||||
// - e5-small-v2 (384D, search/retrieval)
|
||||
// - gte-small (384D, multilingual)
|
||||
|
||||
await embedder.load_model('bge-small-en-v1.5');
|
||||
|
||||
// Single embedding
|
||||
const embedding = await embedder.embed("What is machine learning?");
|
||||
|
||||
// Batch processing (3.8x faster with parallel workers)
|
||||
const embeddings = await embedder.embed_batch([
|
||||
"First document about AI",
|
||||
"Second document about ML",
|
||||
"Third document about neural networks"
|
||||
]);
|
||||
|
||||
// Compute similarity
|
||||
function cosineSimilarity(a, b) {
|
||||
let dot = 0, normA = 0, normB = 0;
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
dot += a[i] * b[i];
|
||||
normA += a[i] * a[i];
|
||||
normB += b[i] * b[i];
|
||||
}
|
||||
return dot / (Math.sqrt(normA) * Math.sqrt(normB));
|
||||
}
|
||||
|
||||
const similarity = cosineSimilarity(embeddings[0], embeddings[1]);
|
||||
```
|
||||
|
||||
## Interactive Generator
|
||||
|
||||
The package includes an interactive HTML generator that creates ready-to-use code for any combination of:
|
||||
|
||||
- **6 Network Topologies**: Mesh, Star, Hierarchical, Ring, Gossip, Sharded
|
||||
- **4 P2P Transports**: GUN.js, WebRTC, libp2p, Nostr
|
||||
- **6 Use Cases**: AI Assistants, Data Pipeline, Gaming, IoT, Marketplace, Research
|
||||
- **6 WASM Modules**: Edge, Graph, RVLite, SONA, DAG, ONNX
|
||||
- **8 Core Features**: Identity, Encryption, HNSW, Semantic Match, Raft, Post-Quantum, Spiking NN, Compression
|
||||
- **7 Exotic Patterns**: MCP Tools, Byzantine Fault, Quantum Resistant, Neural Consensus, Swarm Intelligence, Self-Healing, Emergent Behavior
|
||||
|
||||
Open `generator.html` in your browser to start generating code.
|
||||
|
||||
## Bundle Size Comparison
|
||||
|
||||
| Configuration | Size | Use Case |
|
||||
|--------------|------|----------|
|
||||
| Edge only | 364KB | Minimal crypto + vectors |
|
||||
| Edge + Graph | 652KB | Agent relationships |
|
||||
| Edge + RVLite | 624KB | SQL-style queries |
|
||||
| Edge + SONA | 602KB | Self-learning routing |
|
||||
| All Core | 1.28MB | Full capabilities |
|
||||
| With ONNX | 8.4MB | ML embeddings |
|
||||
|
||||
## Free Infrastructure
|
||||
|
||||
All components use free public infrastructure:
|
||||
|
||||
| Service | Free Providers |
|
||||
|---------|----------------|
|
||||
| P2P Relay | GUN.js (gun-manhattan, gun-us-west) |
|
||||
| STUN | Google, Twilio, Cloudflare |
|
||||
| Signaling | PeerJS Cloud (free tier) |
|
||||
| Nostr Relays | nostr.wine, relay.damus.io, nos.lol |
|
||||
|
||||
## Performance
|
||||
|
||||
| Module | Operation | Performance |
|
||||
|--------|-----------|-------------|
|
||||
| Edge | Ed25519 sign/verify | 50,000 ops/sec |
|
||||
| Edge | AES-256-GCM | 1 GB/sec |
|
||||
| Edge | HNSW search | 150x faster than brute force |
|
||||
| Graph | Cypher query | <1ms for simple queries |
|
||||
| RVLite | Vector search | Sub-millisecond |
|
||||
| SONA | Route decision | <5ms |
|
||||
| ONNX | Single embed | ~20ms (MiniLM-L6) |
|
||||
| ONNX | Batch embed | 3.8x speedup with workers |
|
||||
|
||||
## Examples
|
||||
|
||||
See the `/examples` directory for:
|
||||
|
||||
- Multi-agent chat with shared memory
|
||||
- Distributed RAG pipeline
|
||||
- Real-time multiplayer coordination
|
||||
- IoT sensor swarm
|
||||
- Knowledge graph construction
|
||||
- Workflow automation
|
||||
|
||||
## License
|
||||
|
||||
MIT License - Use freely for any purpose.
|
||||
|
||||
## Links
|
||||
|
||||
- [npm](https://www.npmjs.com/package/@ruvector/edge-full)
|
||||
- [GitHub](https://github.com/ruvnet/ruvector)
|
||||
- [@ruvector/edge](https://www.npmjs.com/package/@ruvector/edge) (lightweight version)
|
||||
105
vendor/ruvector/examples/edge-full/pkg/dag/ruvector_dag_wasm.d.ts
vendored
Normal file
105
vendor/ruvector/examples/edge-full/pkg/dag/ruvector_dag_wasm.d.ts
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
export class WasmDag {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Get number of edges
|
||||
*/
|
||||
edge_count(): number;
|
||||
/**
|
||||
* Deserialize from bytes
|
||||
*/
|
||||
static from_bytes(data: Uint8Array): WasmDag;
|
||||
/**
|
||||
* Get number of nodes
|
||||
*/
|
||||
node_count(): number;
|
||||
/**
|
||||
* Find critical path (longest path by cost)
|
||||
* Returns JSON: {"path": [node_ids], "cost": total}
|
||||
*/
|
||||
critical_path(): any;
|
||||
/**
|
||||
* Create new empty DAG
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Serialize to JSON
|
||||
*/
|
||||
to_json(): string;
|
||||
/**
|
||||
* Add edge from -> to
|
||||
* Returns false if creates cycle (simple check)
|
||||
*/
|
||||
add_edge(from: number, to: number): boolean;
|
||||
/**
|
||||
* Add a node with operator type and cost
|
||||
* Returns node ID
|
||||
*/
|
||||
add_node(op: number, cost: number): number;
|
||||
/**
|
||||
* Serialize to bytes (bincode format)
|
||||
*/
|
||||
to_bytes(): Uint8Array;
|
||||
/**
|
||||
* Compute attention scores for nodes
|
||||
* mechanism: 0=topological, 1=critical_path, 2=uniform
|
||||
*/
|
||||
attention(mechanism: number): Float32Array;
|
||||
/**
|
||||
* Deserialize from JSON
|
||||
*/
|
||||
static from_json(json: string): WasmDag;
|
||||
/**
|
||||
* Topological sort using Kahn's algorithm
|
||||
* Returns node IDs in topological order
|
||||
*/
|
||||
topo_sort(): Uint32Array;
|
||||
}
|
||||
|
||||
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
||||
|
||||
export interface InitOutput {
|
||||
readonly memory: WebAssembly.Memory;
|
||||
readonly __wbg_wasmdag_free: (a: number, b: number) => void;
|
||||
readonly wasmdag_add_edge: (a: number, b: number, c: number) => number;
|
||||
readonly wasmdag_add_node: (a: number, b: number, c: number) => number;
|
||||
readonly wasmdag_attention: (a: number, b: number, c: number) => void;
|
||||
readonly wasmdag_critical_path: (a: number) => number;
|
||||
readonly wasmdag_edge_count: (a: number) => number;
|
||||
readonly wasmdag_from_bytes: (a: number, b: number, c: number) => void;
|
||||
readonly wasmdag_from_json: (a: number, b: number, c: number) => void;
|
||||
readonly wasmdag_new: () => number;
|
||||
readonly wasmdag_node_count: (a: number) => number;
|
||||
readonly wasmdag_to_bytes: (a: number, b: number) => void;
|
||||
readonly wasmdag_to_json: (a: number, b: number) => void;
|
||||
readonly wasmdag_topo_sort: (a: number, b: number) => void;
|
||||
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
||||
readonly __wbindgen_export: (a: number, b: number) => number;
|
||||
readonly __wbindgen_export2: (a: number, b: number, c: number) => void;
|
||||
readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
|
||||
}
|
||||
|
||||
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
||||
|
||||
/**
|
||||
* Instantiates the given `module`, which can either be bytes or
|
||||
* a precompiled `WebAssembly.Module`.
|
||||
*
|
||||
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
||||
*
|
||||
* @returns {InitOutput}
|
||||
*/
|
||||
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
||||
|
||||
/**
|
||||
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
||||
* for everything else, calls `WebAssembly.instantiate` directly.
|
||||
*
|
||||
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
||||
*
|
||||
* @returns {Promise<InitOutput>}
|
||||
*/
|
||||
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
||||
466
vendor/ruvector/examples/edge-full/pkg/dag/ruvector_dag_wasm.js
vendored
Normal file
466
vendor/ruvector/examples/edge-full/pkg/dag/ruvector_dag_wasm.js
vendored
Normal file
@@ -0,0 +1,466 @@
|
||||
let wasm;
|
||||
|
||||
function addHeapObject(obj) {
|
||||
if (heap_next === heap.length) heap.push(heap.length + 1);
|
||||
const idx = heap_next;
|
||||
heap_next = heap[idx];
|
||||
|
||||
heap[idx] = obj;
|
||||
return idx;
|
||||
}
|
||||
|
||||
function dropObject(idx) {
|
||||
if (idx < 132) return;
|
||||
heap[idx] = heap_next;
|
||||
heap_next = idx;
|
||||
}
|
||||
|
||||
function getArrayF32FromWasm0(ptr, len) {
|
||||
ptr = ptr >>> 0;
|
||||
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
||||
}
|
||||
|
||||
function getArrayU32FromWasm0(ptr, len) {
|
||||
ptr = ptr >>> 0;
|
||||
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
||||
}
|
||||
|
||||
function getArrayU8FromWasm0(ptr, len) {
|
||||
ptr = ptr >>> 0;
|
||||
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
||||
}
|
||||
|
||||
let cachedDataViewMemory0 = null;
|
||||
function getDataViewMemory0() {
|
||||
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
||||
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
||||
}
|
||||
return cachedDataViewMemory0;
|
||||
}
|
||||
|
||||
let cachedFloat32ArrayMemory0 = null;
|
||||
function getFloat32ArrayMemory0() {
|
||||
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
||||
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachedFloat32ArrayMemory0;
|
||||
}
|
||||
|
||||
function getStringFromWasm0(ptr, len) {
|
||||
ptr = ptr >>> 0;
|
||||
return decodeText(ptr, len);
|
||||
}
|
||||
|
||||
let cachedUint32ArrayMemory0 = null;
|
||||
function getUint32ArrayMemory0() {
|
||||
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
||||
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachedUint32ArrayMemory0;
|
||||
}
|
||||
|
||||
let cachedUint8ArrayMemory0 = null;
|
||||
function getUint8ArrayMemory0() {
|
||||
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
||||
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachedUint8ArrayMemory0;
|
||||
}
|
||||
|
||||
function getObject(idx) { return heap[idx]; }
|
||||
|
||||
let heap = new Array(128).fill(undefined);
|
||||
heap.push(undefined, null, true, false);
|
||||
|
||||
let heap_next = heap.length;
|
||||
|
||||
function passArray8ToWasm0(arg, malloc) {
|
||||
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
||||
getUint8ArrayMemory0().set(arg, ptr / 1);
|
||||
WASM_VECTOR_LEN = arg.length;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
function passStringToWasm0(arg, malloc, realloc) {
|
||||
if (realloc === undefined) {
|
||||
const buf = cachedTextEncoder.encode(arg);
|
||||
const ptr = malloc(buf.length, 1) >>> 0;
|
||||
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
||||
WASM_VECTOR_LEN = buf.length;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
let len = arg.length;
|
||||
let ptr = malloc(len, 1) >>> 0;
|
||||
|
||||
const mem = getUint8ArrayMemory0();
|
||||
|
||||
let offset = 0;
|
||||
|
||||
for (; offset < len; offset++) {
|
||||
const code = arg.charCodeAt(offset);
|
||||
if (code > 0x7F) break;
|
||||
mem[ptr + offset] = code;
|
||||
}
|
||||
if (offset !== len) {
|
||||
if (offset !== 0) {
|
||||
arg = arg.slice(offset);
|
||||
}
|
||||
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
||||
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
||||
const ret = cachedTextEncoder.encodeInto(arg, view);
|
||||
|
||||
offset += ret.written;
|
||||
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
||||
}
|
||||
|
||||
WASM_VECTOR_LEN = offset;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
function takeObject(idx) {
|
||||
const ret = getObject(idx);
|
||||
dropObject(idx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
||||
cachedTextDecoder.decode();
|
||||
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
||||
let numBytesDecoded = 0;
|
||||
function decodeText(ptr, len) {
|
||||
numBytesDecoded += len;
|
||||
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
||||
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
||||
cachedTextDecoder.decode();
|
||||
numBytesDecoded = len;
|
||||
}
|
||||
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
||||
}
|
||||
|
||||
const cachedTextEncoder = new TextEncoder();
|
||||
|
||||
if (!('encodeInto' in cachedTextEncoder)) {
|
||||
cachedTextEncoder.encodeInto = function (arg, view) {
|
||||
const buf = cachedTextEncoder.encode(arg);
|
||||
view.set(buf);
|
||||
return {
|
||||
read: arg.length,
|
||||
written: buf.length
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
let WASM_VECTOR_LEN = 0;
|
||||
|
||||
const WasmDagFinalization = (typeof FinalizationRegistry === 'undefined')
|
||||
? { register: () => {}, unregister: () => {} }
|
||||
: new FinalizationRegistry(ptr => wasm.__wbg_wasmdag_free(ptr >>> 0, 1));
|
||||
|
||||
/**
|
||||
* Minimal DAG structure for WASM
|
||||
* Self-contained with no external dependencies beyond wasm-bindgen
|
||||
*/
|
||||
export class WasmDag {
|
||||
static __wrap(ptr) {
|
||||
ptr = ptr >>> 0;
|
||||
const obj = Object.create(WasmDag.prototype);
|
||||
obj.__wbg_ptr = ptr;
|
||||
WasmDagFinalization.register(obj, obj.__wbg_ptr, obj);
|
||||
return obj;
|
||||
}
|
||||
__destroy_into_raw() {
|
||||
const ptr = this.__wbg_ptr;
|
||||
this.__wbg_ptr = 0;
|
||||
WasmDagFinalization.unregister(this);
|
||||
return ptr;
|
||||
}
|
||||
free() {
|
||||
const ptr = this.__destroy_into_raw();
|
||||
wasm.__wbg_wasmdag_free(ptr, 0);
|
||||
}
|
||||
/**
|
||||
* Get number of edges
|
||||
* @returns {number}
|
||||
*/
|
||||
edge_count() {
|
||||
const ret = wasm.wasmdag_edge_count(this.__wbg_ptr);
|
||||
return ret >>> 0;
|
||||
}
|
||||
/**
|
||||
* Deserialize from bytes
|
||||
* @param {Uint8Array} data
|
||||
* @returns {WasmDag}
|
||||
*/
|
||||
static from_bytes(data) {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
wasm.wasmdag_from_bytes(retptr, ptr0, len0);
|
||||
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
||||
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
||||
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
||||
if (r2) {
|
||||
throw takeObject(r1);
|
||||
}
|
||||
return WasmDag.__wrap(r0);
|
||||
} finally {
|
||||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get number of nodes
|
||||
* @returns {number}
|
||||
*/
|
||||
node_count() {
|
||||
const ret = wasm.wasmdag_node_count(this.__wbg_ptr);
|
||||
return ret >>> 0;
|
||||
}
|
||||
/**
|
||||
* Find critical path (longest path by cost)
|
||||
* Returns JSON: {"path": [node_ids], "cost": total}
|
||||
* @returns {any}
|
||||
*/
|
||||
critical_path() {
|
||||
const ret = wasm.wasmdag_critical_path(this.__wbg_ptr);
|
||||
return takeObject(ret);
|
||||
}
|
||||
/**
|
||||
* Create new empty DAG
|
||||
*/
|
||||
constructor() {
|
||||
const ret = wasm.wasmdag_new();
|
||||
this.__wbg_ptr = ret >>> 0;
|
||||
WasmDagFinalization.register(this, this.__wbg_ptr, this);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Serialize to JSON
|
||||
* @returns {string}
|
||||
*/
|
||||
to_json() {
|
||||
let deferred1_0;
|
||||
let deferred1_1;
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||
wasm.wasmdag_to_json(retptr, this.__wbg_ptr);
|
||||
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
||||
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
||||
deferred1_0 = r0;
|
||||
deferred1_1 = r1;
|
||||
return getStringFromWasm0(r0, r1);
|
||||
} finally {
|
||||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||||
wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Add edge from -> to
|
||||
* Returns false if creates cycle (simple check)
|
||||
* @param {number} from
|
||||
* @param {number} to
|
||||
* @returns {boolean}
|
||||
*/
|
||||
add_edge(from, to) {
|
||||
const ret = wasm.wasmdag_add_edge(this.__wbg_ptr, from, to);
|
||||
return ret !== 0;
|
||||
}
|
||||
/**
|
||||
* Add a node with operator type and cost
|
||||
* Returns node ID
|
||||
* @param {number} op
|
||||
* @param {number} cost
|
||||
* @returns {number}
|
||||
*/
|
||||
add_node(op, cost) {
|
||||
const ret = wasm.wasmdag_add_node(this.__wbg_ptr, op, cost);
|
||||
return ret >>> 0;
|
||||
}
|
||||
/**
|
||||
* Serialize to bytes (bincode format)
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
to_bytes() {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||
wasm.wasmdag_to_bytes(retptr, this.__wbg_ptr);
|
||||
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
||||
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
||||
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
||||
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
||||
return v1;
|
||||
} finally {
|
||||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Compute attention scores for nodes
|
||||
* mechanism: 0=topological, 1=critical_path, 2=uniform
|
||||
* @param {number} mechanism
|
||||
* @returns {Float32Array}
|
||||
*/
|
||||
attention(mechanism) {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||
wasm.wasmdag_attention(retptr, this.__wbg_ptr, mechanism);
|
||||
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
||||
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
||||
var v1 = getArrayF32FromWasm0(r0, r1).slice();
|
||||
wasm.__wbindgen_export2(r0, r1 * 4, 4);
|
||||
return v1;
|
||||
} finally {
|
||||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Deserialize from JSON
|
||||
* @param {string} json
|
||||
* @returns {WasmDag}
|
||||
*/
|
||||
static from_json(json) {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export3);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
wasm.wasmdag_from_json(retptr, ptr0, len0);
|
||||
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
||||
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
||||
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
||||
if (r2) {
|
||||
throw takeObject(r1);
|
||||
}
|
||||
return WasmDag.__wrap(r0);
|
||||
} finally {
|
||||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Topological sort using Kahn's algorithm
|
||||
* Returns node IDs in topological order
|
||||
* @returns {Uint32Array}
|
||||
*/
|
||||
topo_sort() {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||
wasm.wasmdag_topo_sort(retptr, this.__wbg_ptr);
|
||||
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
||||
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
||||
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
||||
wasm.__wbindgen_export2(r0, r1 * 4, 4);
|
||||
return v1;
|
||||
} finally {
|
||||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Symbol.dispose) WasmDag.prototype[Symbol.dispose] = WasmDag.prototype.free;
|
||||
|
||||
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
||||
|
||||
async function __wbg_load(module, imports) {
|
||||
if (typeof Response === 'function' && module instanceof Response) {
|
||||
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
||||
try {
|
||||
return await WebAssembly.instantiateStreaming(module, imports);
|
||||
} catch (e) {
|
||||
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
||||
|
||||
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
||||
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
||||
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const bytes = await module.arrayBuffer();
|
||||
return await WebAssembly.instantiate(bytes, imports);
|
||||
} else {
|
||||
const instance = await WebAssembly.instantiate(module, imports);
|
||||
|
||||
if (instance instanceof WebAssembly.Instance) {
|
||||
return { instance, module };
|
||||
} else {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function __wbg_get_imports() {
|
||||
const imports = {};
|
||||
imports.wbg = {};
|
||||
imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
||||
throw new Error(getStringFromWasm0(arg0, arg1));
|
||||
};
|
||||
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
||||
// Cast intrinsic for `Ref(String) -> Externref`.
|
||||
const ret = getStringFromWasm0(arg0, arg1);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
|
||||
return imports;
|
||||
}
|
||||
|
||||
function __wbg_finalize_init(instance, module) {
|
||||
wasm = instance.exports;
|
||||
__wbg_init.__wbindgen_wasm_module = module;
|
||||
cachedDataViewMemory0 = null;
|
||||
cachedFloat32ArrayMemory0 = null;
|
||||
cachedUint32ArrayMemory0 = null;
|
||||
cachedUint8ArrayMemory0 = null;
|
||||
|
||||
|
||||
|
||||
return wasm;
|
||||
}
|
||||
|
||||
function initSync(module) {
|
||||
if (wasm !== undefined) return wasm;
|
||||
|
||||
|
||||
if (typeof module !== 'undefined') {
|
||||
if (Object.getPrototypeOf(module) === Object.prototype) {
|
||||
({module} = module)
|
||||
} else {
|
||||
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
||||
}
|
||||
}
|
||||
|
||||
const imports = __wbg_get_imports();
|
||||
if (!(module instanceof WebAssembly.Module)) {
|
||||
module = new WebAssembly.Module(module);
|
||||
}
|
||||
const instance = new WebAssembly.Instance(module, imports);
|
||||
return __wbg_finalize_init(instance, module);
|
||||
}
|
||||
|
||||
async function __wbg_init(module_or_path) {
|
||||
if (wasm !== undefined) return wasm;
|
||||
|
||||
|
||||
if (typeof module_or_path !== 'undefined') {
|
||||
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
||||
({module_or_path} = module_or_path)
|
||||
} else {
|
||||
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof module_or_path === 'undefined') {
|
||||
module_or_path = new URL('ruvector_dag_wasm_bg.wasm', import.meta.url);
|
||||
}
|
||||
const imports = __wbg_get_imports();
|
||||
|
||||
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
||||
module_or_path = fetch(module_or_path);
|
||||
}
|
||||
|
||||
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
||||
|
||||
return __wbg_finalize_init(instance, module);
|
||||
}
|
||||
|
||||
export { initSync };
|
||||
export default __wbg_init;
|
||||
BIN
vendor/ruvector/examples/edge-full/pkg/dag/ruvector_dag_wasm_bg.wasm
vendored
Normal file
BIN
vendor/ruvector/examples/edge-full/pkg/dag/ruvector_dag_wasm_bg.wasm
vendored
Normal file
Binary file not shown.
20
vendor/ruvector/examples/edge-full/pkg/dag/ruvector_dag_wasm_bg.wasm.d.ts
vendored
Normal file
20
vendor/ruvector/examples/edge-full/pkg/dag/ruvector_dag_wasm_bg.wasm.d.ts
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const memory: WebAssembly.Memory;
|
||||
export const __wbg_wasmdag_free: (a: number, b: number) => void;
|
||||
export const wasmdag_add_edge: (a: number, b: number, c: number) => number;
|
||||
export const wasmdag_add_node: (a: number, b: number, c: number) => number;
|
||||
export const wasmdag_attention: (a: number, b: number, c: number) => void;
|
||||
export const wasmdag_critical_path: (a: number) => number;
|
||||
export const wasmdag_edge_count: (a: number) => number;
|
||||
export const wasmdag_from_bytes: (a: number, b: number, c: number) => void;
|
||||
export const wasmdag_from_json: (a: number, b: number, c: number) => void;
|
||||
export const wasmdag_new: () => number;
|
||||
export const wasmdag_node_count: (a: number) => number;
|
||||
export const wasmdag_to_bytes: (a: number, b: number) => void;
|
||||
export const wasmdag_to_json: (a: number, b: number) => void;
|
||||
export const wasmdag_topo_sort: (a: number, b: number) => void;
|
||||
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
||||
export const __wbindgen_export: (a: number, b: number) => number;
|
||||
export const __wbindgen_export2: (a: number, b: number, c: number) => void;
|
||||
export const __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
|
||||
351
vendor/ruvector/examples/edge-full/pkg/edge/ruvector_edge.d.ts
vendored
Normal file
351
vendor/ruvector/examples/edge-full/pkg/edge/ruvector_edge.d.ts
vendored
Normal file
@@ -0,0 +1,351 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
export class WasmAdaptiveCompressor {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Update network metrics (bandwidth in Mbps, latency in ms)
|
||||
*/
|
||||
updateMetrics(bandwidth_mbps: number, latency_ms: number): void;
|
||||
/**
|
||||
* Create new adaptive compressor
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Compress vector based on network conditions
|
||||
*/
|
||||
compress(data: Float32Array): any;
|
||||
/**
|
||||
* Get current network condition
|
||||
*/
|
||||
condition(): string;
|
||||
}
|
||||
|
||||
export class WasmCrypto {
|
||||
private constructor();
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Generate a local CID for data
|
||||
*/
|
||||
static generateCid(data: Uint8Array): string;
|
||||
/**
|
||||
* SHA-256 hash of string as hex
|
||||
*/
|
||||
static sha256String(text: string): string;
|
||||
/**
|
||||
* SHA-256 hash as hex string
|
||||
*/
|
||||
static sha256(data: Uint8Array): string;
|
||||
/**
|
||||
* Decrypt data with AES-256-GCM
|
||||
*/
|
||||
static decrypt(encrypted: any, key_hex: string): Uint8Array;
|
||||
/**
|
||||
* Encrypt data with AES-256-GCM (key as hex)
|
||||
*/
|
||||
static encrypt(data: Uint8Array, key_hex: string): any;
|
||||
}
|
||||
|
||||
export class WasmHnswIndex {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Create with custom parameters (m = connections per node, ef = search width)
|
||||
*/
|
||||
static withParams(m: number, ef_construction: number): WasmHnswIndex;
|
||||
/**
|
||||
* Get number of vectors in index
|
||||
*/
|
||||
len(): number;
|
||||
/**
|
||||
* Create new HNSW index with default parameters
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Insert a vector with an ID
|
||||
*/
|
||||
insert(id: string, vector: Float32Array): void;
|
||||
/**
|
||||
* Search for k nearest neighbors, returns JSON array of {id, distance}
|
||||
*/
|
||||
search(query: Float32Array, k: number): any;
|
||||
/**
|
||||
* Check if index is empty
|
||||
*/
|
||||
isEmpty(): boolean;
|
||||
}
|
||||
|
||||
export class WasmHybridKeyPair {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Get public key bytes as hex
|
||||
*/
|
||||
publicKeyHex(): string;
|
||||
/**
|
||||
* Generate new hybrid keypair
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Sign message with hybrid signature
|
||||
*/
|
||||
sign(message: Uint8Array): string;
|
||||
/**
|
||||
* Verify hybrid signature (pubkey and signature both as JSON)
|
||||
*/
|
||||
static verify(public_key_json: string, message: Uint8Array, signature_json: string): boolean;
|
||||
}
|
||||
|
||||
export class WasmIdentity {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Sign raw bytes and return signature as hex
|
||||
*/
|
||||
signBytes(data: Uint8Array): string;
|
||||
/**
|
||||
* Generate a random nonce
|
||||
*/
|
||||
static generateNonce(): string;
|
||||
/**
|
||||
* Get Ed25519 public key as hex string
|
||||
*/
|
||||
publicKeyHex(): string;
|
||||
/**
|
||||
* Create a signed registration for this identity
|
||||
*/
|
||||
createRegistration(agent_id: string, capabilities: any): any;
|
||||
/**
|
||||
* Get X25519 public key as hex string (for key exchange)
|
||||
*/
|
||||
x25519PublicKeyHex(): string;
|
||||
/**
|
||||
* Create a new identity with generated keys
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Sign a message and return signature as hex
|
||||
*/
|
||||
sign(message: string): string;
|
||||
/**
|
||||
* Verify a signature (static method)
|
||||
*/
|
||||
static verify(public_key_hex: string, message: string, signature_hex: string): boolean;
|
||||
}
|
||||
|
||||
export class WasmQuantizer {
|
||||
private constructor();
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Binary quantize a vector (32x compression)
|
||||
*/
|
||||
static binaryQuantize(vector: Float32Array): Uint8Array;
|
||||
/**
|
||||
* Scalar quantize a vector (4x compression)
|
||||
*/
|
||||
static scalarQuantize(vector: Float32Array): any;
|
||||
/**
|
||||
* Compute hamming distance between binary quantized vectors
|
||||
*/
|
||||
static hammingDistance(a: Uint8Array, b: Uint8Array): number;
|
||||
/**
|
||||
* Reconstruct from scalar quantized
|
||||
*/
|
||||
static scalarDequantize(quantized: any): Float32Array;
|
||||
}
|
||||
|
||||
export class WasmRaftNode {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Append entry to log (leader only), returns log index or null
|
||||
*/
|
||||
appendEntry(data: Uint8Array): any;
|
||||
/**
|
||||
* Get log length
|
||||
*/
|
||||
getLogLength(): number;
|
||||
/**
|
||||
* Start an election (returns vote request as JSON)
|
||||
*/
|
||||
startElection(): any;
|
||||
/**
|
||||
* Get commit index
|
||||
*/
|
||||
getCommitIndex(): bigint;
|
||||
/**
|
||||
* Handle a vote request (returns vote response as JSON)
|
||||
*/
|
||||
handleVoteRequest(request: any): any;
|
||||
/**
|
||||
* Handle a vote response (returns true if we became leader)
|
||||
*/
|
||||
handleVoteResponse(response: any): boolean;
|
||||
/**
|
||||
* Create new Raft node with cluster members
|
||||
*/
|
||||
constructor(node_id: string, members: any);
|
||||
/**
|
||||
* Get current term
|
||||
*/
|
||||
term(): bigint;
|
||||
/**
|
||||
* Get current state (Follower, Candidate, Leader)
|
||||
*/
|
||||
state(): string;
|
||||
/**
|
||||
* Check if this node is the leader
|
||||
*/
|
||||
isLeader(): boolean;
|
||||
}
|
||||
|
||||
export class WasmSemanticMatcher {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Get number of registered agents
|
||||
*/
|
||||
agentCount(): number;
|
||||
/**
|
||||
* Find best matching agent for a task, returns {agentId, score} or null
|
||||
*/
|
||||
matchAgent(task_description: string): any;
|
||||
/**
|
||||
* Register an agent with capability description
|
||||
*/
|
||||
registerAgent(agent_id: string, capabilities: string): void;
|
||||
/**
|
||||
* Create new semantic matcher
|
||||
*/
|
||||
constructor();
|
||||
}
|
||||
|
||||
export class WasmSpikingNetwork {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Apply STDP learning rule
|
||||
*/
|
||||
stdpUpdate(pre: Uint8Array, post: Uint8Array, learning_rate: number): void;
|
||||
/**
|
||||
* Create new spiking network
|
||||
*/
|
||||
constructor(input_size: number, hidden_size: number, output_size: number);
|
||||
/**
|
||||
* Reset network state
|
||||
*/
|
||||
reset(): void;
|
||||
/**
|
||||
* Process input spikes and return output spikes
|
||||
*/
|
||||
forward(inputs: Uint8Array): Uint8Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the WASM module (call once on load)
|
||||
*/
|
||||
export function init(): void;
|
||||
|
||||
/**
|
||||
* Get library version
|
||||
*/
|
||||
export function version(): string;
|
||||
|
||||
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
||||
|
||||
export interface InitOutput {
|
||||
readonly memory: WebAssembly.Memory;
|
||||
readonly __wbg_wasmadaptivecompressor_free: (a: number, b: number) => void;
|
||||
readonly __wbg_wasmcrypto_free: (a: number, b: number) => void;
|
||||
readonly __wbg_wasmhnswindex_free: (a: number, b: number) => void;
|
||||
readonly __wbg_wasmhybridkeypair_free: (a: number, b: number) => void;
|
||||
readonly __wbg_wasmidentity_free: (a: number, b: number) => void;
|
||||
readonly __wbg_wasmquantizer_free: (a: number, b: number) => void;
|
||||
readonly __wbg_wasmraftnode_free: (a: number, b: number) => void;
|
||||
readonly __wbg_wasmsemanticmatcher_free: (a: number, b: number) => void;
|
||||
readonly __wbg_wasmspikingnetwork_free: (a: number, b: number) => void;
|
||||
readonly version: () => [number, number];
|
||||
readonly wasmadaptivecompressor_compress: (a: number, b: number, c: number) => any;
|
||||
readonly wasmadaptivecompressor_condition: (a: number) => [number, number];
|
||||
readonly wasmadaptivecompressor_new: () => number;
|
||||
readonly wasmadaptivecompressor_updateMetrics: (a: number, b: number, c: number) => void;
|
||||
readonly wasmcrypto_decrypt: (a: any, b: number, c: number) => [number, number, number, number];
|
||||
readonly wasmcrypto_encrypt: (a: number, b: number, c: number, d: number) => [number, number, number];
|
||||
readonly wasmcrypto_generateCid: (a: number, b: number) => [number, number];
|
||||
readonly wasmcrypto_sha256: (a: number, b: number) => [number, number];
|
||||
readonly wasmhnswindex_insert: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
readonly wasmhnswindex_isEmpty: (a: number) => number;
|
||||
readonly wasmhnswindex_len: (a: number) => number;
|
||||
readonly wasmhnswindex_new: () => number;
|
||||
readonly wasmhnswindex_search: (a: number, b: number, c: number, d: number) => any;
|
||||
readonly wasmhnswindex_withParams: (a: number, b: number) => number;
|
||||
readonly wasmhybridkeypair_new: () => number;
|
||||
readonly wasmhybridkeypair_publicKeyHex: (a: number) => [number, number];
|
||||
readonly wasmhybridkeypair_sign: (a: number, b: number, c: number) => [number, number];
|
||||
readonly wasmhybridkeypair_verify: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
||||
readonly wasmidentity_createRegistration: (a: number, b: number, c: number, d: any) => [number, number, number];
|
||||
readonly wasmidentity_generateNonce: () => [number, number];
|
||||
readonly wasmidentity_new: () => number;
|
||||
readonly wasmidentity_publicKeyHex: (a: number) => [number, number];
|
||||
readonly wasmidentity_sign: (a: number, b: number, c: number) => [number, number];
|
||||
readonly wasmidentity_verify: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
||||
readonly wasmidentity_x25519PublicKeyHex: (a: number) => [number, number];
|
||||
readonly wasmquantizer_binaryQuantize: (a: number, b: number) => [number, number];
|
||||
readonly wasmquantizer_hammingDistance: (a: number, b: number, c: number, d: number) => number;
|
||||
readonly wasmquantizer_scalarDequantize: (a: any) => [number, number, number, number];
|
||||
readonly wasmquantizer_scalarQuantize: (a: number, b: number) => any;
|
||||
readonly wasmraftnode_appendEntry: (a: number, b: number, c: number) => any;
|
||||
readonly wasmraftnode_getCommitIndex: (a: number) => bigint;
|
||||
readonly wasmraftnode_getLogLength: (a: number) => number;
|
||||
readonly wasmraftnode_handleVoteRequest: (a: number, b: any) => [number, number, number];
|
||||
readonly wasmraftnode_handleVoteResponse: (a: number, b: any) => [number, number, number];
|
||||
readonly wasmraftnode_isLeader: (a: number) => number;
|
||||
readonly wasmraftnode_new: (a: number, b: number, c: any) => [number, number, number];
|
||||
readonly wasmraftnode_startElection: (a: number) => any;
|
||||
readonly wasmraftnode_state: (a: number) => [number, number];
|
||||
readonly wasmraftnode_term: (a: number) => bigint;
|
||||
readonly wasmsemanticmatcher_agentCount: (a: number) => number;
|
||||
readonly wasmsemanticmatcher_matchAgent: (a: number, b: number, c: number) => any;
|
||||
readonly wasmsemanticmatcher_new: () => number;
|
||||
readonly wasmsemanticmatcher_registerAgent: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
readonly wasmspikingnetwork_forward: (a: number, b: number, c: number) => [number, number];
|
||||
readonly wasmspikingnetwork_new: (a: number, b: number, c: number) => number;
|
||||
readonly wasmspikingnetwork_reset: (a: number) => void;
|
||||
readonly wasmspikingnetwork_stdpUpdate: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
||||
readonly init: () => void;
|
||||
readonly wasmidentity_signBytes: (a: number, b: number, c: number) => [number, number];
|
||||
readonly wasmcrypto_sha256String: (a: number, b: number) => [number, number];
|
||||
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
||||
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
||||
readonly __wbindgen_exn_store: (a: number) => void;
|
||||
readonly __externref_table_alloc: () => number;
|
||||
readonly __wbindgen_externrefs: WebAssembly.Table;
|
||||
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
||||
readonly __externref_table_dealloc: (a: number) => void;
|
||||
readonly __wbindgen_start: () => void;
|
||||
}
|
||||
|
||||
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
||||
|
||||
/**
|
||||
* Instantiates the given `module`, which can either be bytes or
|
||||
* a precompiled `WebAssembly.Module`.
|
||||
*
|
||||
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
||||
*
|
||||
* @returns {InitOutput}
|
||||
*/
|
||||
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
||||
|
||||
/**
|
||||
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
||||
* for everything else, calls `WebAssembly.instantiate` directly.
|
||||
*
|
||||
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
||||
*
|
||||
* @returns {Promise<InitOutput>}
|
||||
*/
|
||||
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
||||
1452
vendor/ruvector/examples/edge-full/pkg/edge/ruvector_edge.js
vendored
Normal file
1452
vendor/ruvector/examples/edge-full/pkg/edge/ruvector_edge.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
vendor/ruvector/examples/edge-full/pkg/edge/ruvector_edge_bg.wasm
vendored
Normal file
BIN
vendor/ruvector/examples/edge-full/pkg/edge/ruvector_edge_bg.wasm
vendored
Normal file
Binary file not shown.
71
vendor/ruvector/examples/edge-full/pkg/edge/ruvector_edge_bg.wasm.d.ts
vendored
Normal file
71
vendor/ruvector/examples/edge-full/pkg/edge/ruvector_edge_bg.wasm.d.ts
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const memory: WebAssembly.Memory;
|
||||
export const __wbg_wasmadaptivecompressor_free: (a: number, b: number) => void;
|
||||
export const __wbg_wasmcrypto_free: (a: number, b: number) => void;
|
||||
export const __wbg_wasmhnswindex_free: (a: number, b: number) => void;
|
||||
export const __wbg_wasmhybridkeypair_free: (a: number, b: number) => void;
|
||||
export const __wbg_wasmidentity_free: (a: number, b: number) => void;
|
||||
export const __wbg_wasmquantizer_free: (a: number, b: number) => void;
|
||||
export const __wbg_wasmraftnode_free: (a: number, b: number) => void;
|
||||
export const __wbg_wasmsemanticmatcher_free: (a: number, b: number) => void;
|
||||
export const __wbg_wasmspikingnetwork_free: (a: number, b: number) => void;
|
||||
export const version: () => [number, number];
|
||||
export const wasmadaptivecompressor_compress: (a: number, b: number, c: number) => any;
|
||||
export const wasmadaptivecompressor_condition: (a: number) => [number, number];
|
||||
export const wasmadaptivecompressor_new: () => number;
|
||||
export const wasmadaptivecompressor_updateMetrics: (a: number, b: number, c: number) => void;
|
||||
export const wasmcrypto_decrypt: (a: any, b: number, c: number) => [number, number, number, number];
|
||||
export const wasmcrypto_encrypt: (a: number, b: number, c: number, d: number) => [number, number, number];
|
||||
export const wasmcrypto_generateCid: (a: number, b: number) => [number, number];
|
||||
export const wasmcrypto_sha256: (a: number, b: number) => [number, number];
|
||||
export const wasmhnswindex_insert: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
export const wasmhnswindex_isEmpty: (a: number) => number;
|
||||
export const wasmhnswindex_len: (a: number) => number;
|
||||
export const wasmhnswindex_new: () => number;
|
||||
export const wasmhnswindex_search: (a: number, b: number, c: number, d: number) => any;
|
||||
export const wasmhnswindex_withParams: (a: number, b: number) => number;
|
||||
export const wasmhybridkeypair_new: () => number;
|
||||
export const wasmhybridkeypair_publicKeyHex: (a: number) => [number, number];
|
||||
export const wasmhybridkeypair_sign: (a: number, b: number, c: number) => [number, number];
|
||||
export const wasmhybridkeypair_verify: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
||||
export const wasmidentity_createRegistration: (a: number, b: number, c: number, d: any) => [number, number, number];
|
||||
export const wasmidentity_generateNonce: () => [number, number];
|
||||
export const wasmidentity_new: () => number;
|
||||
export const wasmidentity_publicKeyHex: (a: number) => [number, number];
|
||||
export const wasmidentity_sign: (a: number, b: number, c: number) => [number, number];
|
||||
export const wasmidentity_verify: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
||||
export const wasmidentity_x25519PublicKeyHex: (a: number) => [number, number];
|
||||
export const wasmquantizer_binaryQuantize: (a: number, b: number) => [number, number];
|
||||
export const wasmquantizer_hammingDistance: (a: number, b: number, c: number, d: number) => number;
|
||||
export const wasmquantizer_scalarDequantize: (a: any) => [number, number, number, number];
|
||||
export const wasmquantizer_scalarQuantize: (a: number, b: number) => any;
|
||||
export const wasmraftnode_appendEntry: (a: number, b: number, c: number) => any;
|
||||
export const wasmraftnode_getCommitIndex: (a: number) => bigint;
|
||||
export const wasmraftnode_getLogLength: (a: number) => number;
|
||||
export const wasmraftnode_handleVoteRequest: (a: number, b: any) => [number, number, number];
|
||||
export const wasmraftnode_handleVoteResponse: (a: number, b: any) => [number, number, number];
|
||||
export const wasmraftnode_isLeader: (a: number) => number;
|
||||
export const wasmraftnode_new: (a: number, b: number, c: any) => [number, number, number];
|
||||
export const wasmraftnode_startElection: (a: number) => any;
|
||||
export const wasmraftnode_state: (a: number) => [number, number];
|
||||
export const wasmraftnode_term: (a: number) => bigint;
|
||||
export const wasmsemanticmatcher_agentCount: (a: number) => number;
|
||||
export const wasmsemanticmatcher_matchAgent: (a: number, b: number, c: number) => any;
|
||||
export const wasmsemanticmatcher_new: () => number;
|
||||
export const wasmsemanticmatcher_registerAgent: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
export const wasmspikingnetwork_forward: (a: number, b: number, c: number) => [number, number];
|
||||
export const wasmspikingnetwork_new: (a: number, b: number, c: number) => number;
|
||||
export const wasmspikingnetwork_reset: (a: number) => void;
|
||||
export const wasmspikingnetwork_stdpUpdate: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
||||
export const init: () => void;
|
||||
export const wasmidentity_signBytes: (a: number, b: number, c: number) => [number, number];
|
||||
export const wasmcrypto_sha256String: (a: number, b: number) => [number, number];
|
||||
export const __wbindgen_malloc: (a: number, b: number) => number;
|
||||
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
||||
export const __wbindgen_exn_store: (a: number) => void;
|
||||
export const __externref_table_alloc: () => number;
|
||||
export const __wbindgen_externrefs: WebAssembly.Table;
|
||||
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
||||
export const __externref_table_dealloc: (a: number) => void;
|
||||
export const __wbindgen_start: () => void;
|
||||
2009
vendor/ruvector/examples/edge-full/pkg/generator.html
vendored
Normal file
2009
vendor/ruvector/examples/edge-full/pkg/generator.html
vendored
Normal file
File diff suppressed because it is too large
Load Diff
380
vendor/ruvector/examples/edge-full/pkg/graph/ruvector_graph_wasm.d.ts
vendored
Normal file
380
vendor/ruvector/examples/edge-full/pkg/graph/ruvector_graph_wasm.d.ts
vendored
Normal file
@@ -0,0 +1,380 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
export class AsyncQueryExecutor {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Execute query in a Web Worker for background processing
|
||||
*/
|
||||
executeInWorker(_query: string): Promise<any>;
|
||||
/**
|
||||
* Execute query asynchronously with streaming results
|
||||
* This is useful for large result sets
|
||||
*/
|
||||
executeStreaming(_query: string): Promise<any>;
|
||||
/**
|
||||
* Create a new async query executor
|
||||
*/
|
||||
constructor(batch_size?: number | null);
|
||||
/**
|
||||
* Get batch size
|
||||
*/
|
||||
batchSize: number;
|
||||
}
|
||||
|
||||
export class AsyncTransaction {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Add operation to transaction
|
||||
*/
|
||||
addOperation(operation: string): void;
|
||||
/**
|
||||
* Create a new transaction
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Commit transaction asynchronously
|
||||
*/
|
||||
commit(): Promise<any>;
|
||||
/**
|
||||
* Rollback transaction
|
||||
*/
|
||||
rollback(): void;
|
||||
/**
|
||||
* Check if committed
|
||||
*/
|
||||
readonly isCommitted: boolean;
|
||||
/**
|
||||
* Get operation count
|
||||
*/
|
||||
readonly operationCount: number;
|
||||
}
|
||||
|
||||
export class BatchOperations {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Execute multiple Cypher statements in batch
|
||||
*/
|
||||
executeBatch(statements: string[]): Promise<any>;
|
||||
/**
|
||||
* Create a new batch operations handler
|
||||
*/
|
||||
constructor(max_batch_size?: number | null);
|
||||
/**
|
||||
* Get max batch size
|
||||
*/
|
||||
readonly maxBatchSize: number;
|
||||
}
|
||||
|
||||
export class GraphDB {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Create a new edge (relationship)
|
||||
*
|
||||
* # Arguments
|
||||
* * `from` - Source node ID
|
||||
* * `to` - Target node ID
|
||||
* * `edge_type` - Relationship type
|
||||
* * `properties` - JavaScript object with edge properties
|
||||
*
|
||||
* # Returns
|
||||
* Edge ID
|
||||
*/
|
||||
createEdge(from: string, to: string, edge_type: string, properties: any): string;
|
||||
/**
|
||||
* Create a new node
|
||||
*
|
||||
* # Arguments
|
||||
* * `labels` - Array of label strings
|
||||
* * `properties` - JavaScript object with node properties
|
||||
*
|
||||
* # Returns
|
||||
* Node ID
|
||||
*/
|
||||
createNode(labels: string[], properties: any): string;
|
||||
/**
|
||||
* Delete an edge by ID
|
||||
*/
|
||||
deleteEdge(id: string): boolean;
|
||||
/**
|
||||
* Delete a node by ID
|
||||
*
|
||||
* # Arguments
|
||||
* * `id` - Node ID
|
||||
*
|
||||
* # Returns
|
||||
* True if deleted, false if not found
|
||||
*/
|
||||
deleteNode(id: string): boolean;
|
||||
/**
|
||||
* Export database as Cypher CREATE statements
|
||||
*
|
||||
* # Returns
|
||||
* String containing Cypher statements
|
||||
*/
|
||||
exportCypher(): string;
|
||||
/**
|
||||
* Get a hyperedge by ID
|
||||
*/
|
||||
getHyperedge(id: string): JsHyperedge | undefined;
|
||||
/**
|
||||
* Import Cypher statements
|
||||
*
|
||||
* # Arguments
|
||||
* * `statements` - Array of Cypher CREATE statements
|
||||
*
|
||||
* # Returns
|
||||
* Number of statements executed
|
||||
*/
|
||||
importCypher(statements: string[]): Promise<number>;
|
||||
/**
|
||||
* Create a hyperedge (n-ary relationship)
|
||||
*
|
||||
* # Arguments
|
||||
* * `nodes` - Array of node IDs
|
||||
* * `description` - Natural language description of the relationship
|
||||
* * `embedding` - Optional embedding vector (auto-generated if not provided)
|
||||
* * `confidence` - Optional confidence score (0.0-1.0, defaults to 1.0)
|
||||
*
|
||||
* # Returns
|
||||
* Hyperedge ID
|
||||
*/
|
||||
createHyperedge(nodes: string[], description: string, embedding?: Float32Array | null, confidence?: number | null): string;
|
||||
/**
|
||||
* Create a new GraphDB instance
|
||||
*
|
||||
* # Arguments
|
||||
* * `metric` - Distance metric for hypergraph embeddings ("euclidean", "cosine", "dotproduct", "manhattan")
|
||||
*/
|
||||
constructor(metric?: string | null);
|
||||
/**
|
||||
* Execute a Cypher query (basic implementation)
|
||||
*
|
||||
* # Arguments
|
||||
* * `cypher` - Cypher query string
|
||||
*
|
||||
* # Returns
|
||||
* Promise<QueryResult> with matching nodes, edges, and hyperedges
|
||||
*/
|
||||
query(cypher: string): Promise<QueryResult>;
|
||||
/**
|
||||
* Get database statistics
|
||||
*/
|
||||
stats(): any;
|
||||
/**
|
||||
* Get an edge by ID
|
||||
*/
|
||||
getEdge(id: string): JsEdge | undefined;
|
||||
/**
|
||||
* Get a node by ID
|
||||
*
|
||||
* # Arguments
|
||||
* * `id` - Node ID
|
||||
*
|
||||
* # Returns
|
||||
* JsNode or null if not found
|
||||
*/
|
||||
getNode(id: string): JsNode | undefined;
|
||||
}
|
||||
|
||||
export class JsEdge {
|
||||
private constructor();
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
getProperty(key: string): any;
|
||||
readonly properties: any;
|
||||
readonly id: string;
|
||||
readonly to: string;
|
||||
readonly from: string;
|
||||
readonly type: string;
|
||||
}
|
||||
|
||||
export class JsHyperedge {
|
||||
private constructor();
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
readonly confidence: number;
|
||||
readonly properties: any;
|
||||
readonly description: string;
|
||||
readonly id: string;
|
||||
readonly nodes: string[];
|
||||
readonly order: number;
|
||||
readonly embedding: Float32Array;
|
||||
}
|
||||
|
||||
export class JsNode {
|
||||
private constructor();
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Get a specific property value
|
||||
*/
|
||||
getProperty(key: string): any;
|
||||
/**
|
||||
* Check if node has a specific label
|
||||
*/
|
||||
hasLabel(label: string): boolean;
|
||||
readonly properties: any;
|
||||
readonly id: string;
|
||||
readonly labels: string[];
|
||||
readonly embedding: Float32Array | undefined;
|
||||
}
|
||||
|
||||
export class QueryResult {
|
||||
private constructor();
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Check if result is empty
|
||||
*/
|
||||
isEmpty(): boolean;
|
||||
readonly hyperedges: JsHyperedge[];
|
||||
readonly data: any;
|
||||
readonly count: number;
|
||||
readonly edges: JsEdge[];
|
||||
readonly nodes: JsNode[];
|
||||
}
|
||||
|
||||
export class ResultStream {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Get next chunk of results
|
||||
*/
|
||||
nextChunk(): Promise<any>;
|
||||
/**
|
||||
* Create a new result stream
|
||||
*/
|
||||
constructor(chunk_size?: number | null);
|
||||
/**
|
||||
* Reset stream to beginning
|
||||
*/
|
||||
reset(): void;
|
||||
/**
|
||||
* Get chunk size
|
||||
*/
|
||||
readonly chunkSize: number;
|
||||
/**
|
||||
* Get current offset
|
||||
*/
|
||||
readonly offset: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize panic hook for better error messages
|
||||
*/
|
||||
export function init(): void;
|
||||
|
||||
/**
|
||||
* Get version information
|
||||
*/
|
||||
export function version(): string;
|
||||
|
||||
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
||||
|
||||
export interface InitOutput {
|
||||
readonly memory: WebAssembly.Memory;
|
||||
readonly __wbg_asyncqueryexecutor_free: (a: number, b: number) => void;
|
||||
readonly __wbg_asynctransaction_free: (a: number, b: number) => void;
|
||||
readonly __wbg_graphdb_free: (a: number, b: number) => void;
|
||||
readonly __wbg_jsedge_free: (a: number, b: number) => void;
|
||||
readonly __wbg_jshyperedge_free: (a: number, b: number) => void;
|
||||
readonly __wbg_jsnode_free: (a: number, b: number) => void;
|
||||
readonly __wbg_queryresult_free: (a: number, b: number) => void;
|
||||
readonly __wbg_resultstream_free: (a: number, b: number) => void;
|
||||
readonly asyncqueryexecutor_batchSize: (a: number) => number;
|
||||
readonly asyncqueryexecutor_executeInWorker: (a: number, b: number, c: number) => number;
|
||||
readonly asyncqueryexecutor_executeStreaming: (a: number, b: number, c: number) => number;
|
||||
readonly asyncqueryexecutor_new: (a: number) => number;
|
||||
readonly asyncqueryexecutor_set_batchSize: (a: number, b: number) => void;
|
||||
readonly asynctransaction_addOperation: (a: number, b: number, c: number) => void;
|
||||
readonly asynctransaction_commit: (a: number) => number;
|
||||
readonly asynctransaction_isCommitted: (a: number) => number;
|
||||
readonly asynctransaction_new: () => number;
|
||||
readonly asynctransaction_operationCount: (a: number) => number;
|
||||
readonly asynctransaction_rollback: (a: number) => void;
|
||||
readonly batchoperations_executeBatch: (a: number, b: number, c: number) => number;
|
||||
readonly batchoperations_new: (a: number) => number;
|
||||
readonly graphdb_createEdge: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
||||
readonly graphdb_createHyperedge: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
||||
readonly graphdb_createNode: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
readonly graphdb_deleteEdge: (a: number, b: number, c: number) => number;
|
||||
readonly graphdb_deleteNode: (a: number, b: number, c: number) => number;
|
||||
readonly graphdb_exportCypher: (a: number, b: number) => void;
|
||||
readonly graphdb_getEdge: (a: number, b: number, c: number) => number;
|
||||
readonly graphdb_getHyperedge: (a: number, b: number, c: number) => number;
|
||||
readonly graphdb_getNode: (a: number, b: number, c: number) => number;
|
||||
readonly graphdb_importCypher: (a: number, b: number, c: number) => number;
|
||||
readonly graphdb_new: (a: number, b: number, c: number) => void;
|
||||
readonly graphdb_query: (a: number, b: number, c: number) => number;
|
||||
readonly graphdb_stats: (a: number) => number;
|
||||
readonly jsedge_from: (a: number, b: number) => void;
|
||||
readonly jsedge_getProperty: (a: number, b: number, c: number) => number;
|
||||
readonly jsedge_id: (a: number, b: number) => void;
|
||||
readonly jsedge_properties: (a: number) => number;
|
||||
readonly jsedge_to: (a: number, b: number) => void;
|
||||
readonly jsedge_type: (a: number, b: number) => void;
|
||||
readonly jshyperedge_confidence: (a: number) => number;
|
||||
readonly jshyperedge_description: (a: number, b: number) => void;
|
||||
readonly jshyperedge_embedding: (a: number, b: number) => void;
|
||||
readonly jshyperedge_id: (a: number, b: number) => void;
|
||||
readonly jshyperedge_nodes: (a: number, b: number) => void;
|
||||
readonly jshyperedge_order: (a: number) => number;
|
||||
readonly jshyperedge_properties: (a: number) => number;
|
||||
readonly jsnode_embedding: (a: number, b: number) => void;
|
||||
readonly jsnode_getProperty: (a: number, b: number, c: number) => number;
|
||||
readonly jsnode_hasLabel: (a: number, b: number, c: number) => number;
|
||||
readonly jsnode_id: (a: number, b: number) => void;
|
||||
readonly jsnode_labels: (a: number, b: number) => void;
|
||||
readonly jsnode_properties: (a: number) => number;
|
||||
readonly queryresult_count: (a: number) => number;
|
||||
readonly queryresult_data: (a: number) => number;
|
||||
readonly queryresult_edges: (a: number, b: number) => void;
|
||||
readonly queryresult_hyperedges: (a: number, b: number) => void;
|
||||
readonly queryresult_isEmpty: (a: number) => number;
|
||||
readonly queryresult_nodes: (a: number, b: number) => void;
|
||||
readonly resultstream_new: (a: number) => number;
|
||||
readonly resultstream_nextChunk: (a: number) => number;
|
||||
readonly resultstream_offset: (a: number) => number;
|
||||
readonly resultstream_reset: (a: number) => void;
|
||||
readonly version: (a: number) => void;
|
||||
readonly init: () => void;
|
||||
readonly batchoperations_maxBatchSize: (a: number) => number;
|
||||
readonly resultstream_chunkSize: (a: number) => number;
|
||||
readonly __wbg_batchoperations_free: (a: number, b: number) => void;
|
||||
readonly __wasm_bindgen_func_elem_446: (a: number, b: number, c: number) => void;
|
||||
readonly __wasm_bindgen_func_elem_445: (a: number, b: number) => void;
|
||||
readonly __wasm_bindgen_func_elem_774: (a: number, b: number, c: number, d: number) => void;
|
||||
readonly __wbindgen_export: (a: number, b: number) => number;
|
||||
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
||||
readonly __wbindgen_export3: (a: number) => void;
|
||||
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
||||
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
||||
readonly __wbindgen_start: () => void;
|
||||
}
|
||||
|
||||
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
||||
|
||||
/**
|
||||
* Instantiates the given `module`, which can either be bytes or
|
||||
* a precompiled `WebAssembly.Module`.
|
||||
*
|
||||
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
||||
*
|
||||
* @returns {InitOutput}
|
||||
*/
|
||||
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
||||
|
||||
/**
|
||||
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
||||
* for everything else, calls `WebAssembly.instantiate` directly.
|
||||
*
|
||||
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
||||
*
|
||||
* @returns {Promise<InitOutput>}
|
||||
*/
|
||||
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
||||
1787
vendor/ruvector/examples/edge-full/pkg/graph/ruvector_graph_wasm.js
vendored
Normal file
1787
vendor/ruvector/examples/edge-full/pkg/graph/ruvector_graph_wasm.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
vendor/ruvector/examples/edge-full/pkg/graph/ruvector_graph_wasm_bg.wasm
vendored
Normal file
BIN
vendor/ruvector/examples/edge-full/pkg/graph/ruvector_graph_wasm_bg.wasm
vendored
Normal file
Binary file not shown.
80
vendor/ruvector/examples/edge-full/pkg/graph/ruvector_graph_wasm_bg.wasm.d.ts
vendored
Normal file
80
vendor/ruvector/examples/edge-full/pkg/graph/ruvector_graph_wasm_bg.wasm.d.ts
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const memory: WebAssembly.Memory;
|
||||
export const __wbg_asyncqueryexecutor_free: (a: number, b: number) => void;
|
||||
export const __wbg_asynctransaction_free: (a: number, b: number) => void;
|
||||
export const __wbg_graphdb_free: (a: number, b: number) => void;
|
||||
export const __wbg_jsedge_free: (a: number, b: number) => void;
|
||||
export const __wbg_jshyperedge_free: (a: number, b: number) => void;
|
||||
export const __wbg_jsnode_free: (a: number, b: number) => void;
|
||||
export const __wbg_queryresult_free: (a: number, b: number) => void;
|
||||
export const __wbg_resultstream_free: (a: number, b: number) => void;
|
||||
export const asyncqueryexecutor_batchSize: (a: number) => number;
|
||||
export const asyncqueryexecutor_executeInWorker: (a: number, b: number, c: number) => number;
|
||||
export const asyncqueryexecutor_executeStreaming: (a: number, b: number, c: number) => number;
|
||||
export const asyncqueryexecutor_new: (a: number) => number;
|
||||
export const asyncqueryexecutor_set_batchSize: (a: number, b: number) => void;
|
||||
export const asynctransaction_addOperation: (a: number, b: number, c: number) => void;
|
||||
export const asynctransaction_commit: (a: number) => number;
|
||||
export const asynctransaction_isCommitted: (a: number) => number;
|
||||
export const asynctransaction_new: () => number;
|
||||
export const asynctransaction_operationCount: (a: number) => number;
|
||||
export const asynctransaction_rollback: (a: number) => void;
|
||||
export const batchoperations_executeBatch: (a: number, b: number, c: number) => number;
|
||||
export const batchoperations_new: (a: number) => number;
|
||||
export const graphdb_createEdge: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
||||
export const graphdb_createHyperedge: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
||||
export const graphdb_createNode: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
export const graphdb_deleteEdge: (a: number, b: number, c: number) => number;
|
||||
export const graphdb_deleteNode: (a: number, b: number, c: number) => number;
|
||||
export const graphdb_exportCypher: (a: number, b: number) => void;
|
||||
export const graphdb_getEdge: (a: number, b: number, c: number) => number;
|
||||
export const graphdb_getHyperedge: (a: number, b: number, c: number) => number;
|
||||
export const graphdb_getNode: (a: number, b: number, c: number) => number;
|
||||
export const graphdb_importCypher: (a: number, b: number, c: number) => number;
|
||||
export const graphdb_new: (a: number, b: number, c: number) => void;
|
||||
export const graphdb_query: (a: number, b: number, c: number) => number;
|
||||
export const graphdb_stats: (a: number) => number;
|
||||
export const jsedge_from: (a: number, b: number) => void;
|
||||
export const jsedge_getProperty: (a: number, b: number, c: number) => number;
|
||||
export const jsedge_id: (a: number, b: number) => void;
|
||||
export const jsedge_properties: (a: number) => number;
|
||||
export const jsedge_to: (a: number, b: number) => void;
|
||||
export const jsedge_type: (a: number, b: number) => void;
|
||||
export const jshyperedge_confidence: (a: number) => number;
|
||||
export const jshyperedge_description: (a: number, b: number) => void;
|
||||
export const jshyperedge_embedding: (a: number, b: number) => void;
|
||||
export const jshyperedge_id: (a: number, b: number) => void;
|
||||
export const jshyperedge_nodes: (a: number, b: number) => void;
|
||||
export const jshyperedge_order: (a: number) => number;
|
||||
export const jshyperedge_properties: (a: number) => number;
|
||||
export const jsnode_embedding: (a: number, b: number) => void;
|
||||
export const jsnode_getProperty: (a: number, b: number, c: number) => number;
|
||||
export const jsnode_hasLabel: (a: number, b: number, c: number) => number;
|
||||
export const jsnode_id: (a: number, b: number) => void;
|
||||
export const jsnode_labels: (a: number, b: number) => void;
|
||||
export const jsnode_properties: (a: number) => number;
|
||||
export const queryresult_count: (a: number) => number;
|
||||
export const queryresult_data: (a: number) => number;
|
||||
export const queryresult_edges: (a: number, b: number) => void;
|
||||
export const queryresult_hyperedges: (a: number, b: number) => void;
|
||||
export const queryresult_isEmpty: (a: number) => number;
|
||||
export const queryresult_nodes: (a: number, b: number) => void;
|
||||
export const resultstream_new: (a: number) => number;
|
||||
export const resultstream_nextChunk: (a: number) => number;
|
||||
export const resultstream_offset: (a: number) => number;
|
||||
export const resultstream_reset: (a: number) => void;
|
||||
export const version: (a: number) => void;
|
||||
export const init: () => void;
|
||||
export const batchoperations_maxBatchSize: (a: number) => number;
|
||||
export const resultstream_chunkSize: (a: number) => number;
|
||||
export const __wbg_batchoperations_free: (a: number, b: number) => void;
|
||||
export const __wasm_bindgen_func_elem_446: (a: number, b: number, c: number) => void;
|
||||
export const __wasm_bindgen_func_elem_445: (a: number, b: number) => void;
|
||||
export const __wasm_bindgen_func_elem_774: (a: number, b: number, c: number, d: number) => void;
|
||||
export const __wbindgen_export: (a: number, b: number) => number;
|
||||
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
||||
export const __wbindgen_export3: (a: number) => void;
|
||||
export const __wbindgen_export4: (a: number, b: number, c: number) => void;
|
||||
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
||||
export const __wbindgen_start: () => void;
|
||||
64
vendor/ruvector/examples/edge-full/pkg/index.d.ts
vendored
Normal file
64
vendor/ruvector/examples/edge-full/pkg/index.d.ts
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @ruvector/edge-full - Complete WASM toolkit for edge AI
|
||||
*/
|
||||
|
||||
// Module namespaces
|
||||
export * as edge from './edge/ruvector_edge';
|
||||
export * as graph from './graph/ruvector_graph_wasm';
|
||||
export * as rvlite from './rvlite/rvlite';
|
||||
export * as sona from './sona/ruvector_sona';
|
||||
export * as dag from './dag/ruvector_dag_wasm';
|
||||
|
||||
// ONNX init function
|
||||
export { default as onnxInit } from './onnx/ruvector_onnx_embeddings_wasm';
|
||||
|
||||
// Module info interface
|
||||
export interface ModuleInfo {
|
||||
name: string;
|
||||
size: string;
|
||||
features: string[];
|
||||
}
|
||||
|
||||
export interface ModulesMap {
|
||||
edge: ModuleInfo;
|
||||
graph: ModuleInfo;
|
||||
rvlite: ModuleInfo;
|
||||
sona: ModuleInfo;
|
||||
dag: ModuleInfo;
|
||||
onnx: ModuleInfo;
|
||||
}
|
||||
|
||||
export const modules: ModulesMap;
|
||||
|
||||
export interface TotalSize {
|
||||
core: string;
|
||||
withOnnx: string;
|
||||
}
|
||||
|
||||
export const totalSize: TotalSize;
|
||||
|
||||
/**
|
||||
* Initialize all core modules (excludes ONNX due to size)
|
||||
*/
|
||||
export function initAll(): Promise<{
|
||||
edge: typeof import('./edge/ruvector_edge');
|
||||
graph: typeof import('./graph/ruvector_graph_wasm');
|
||||
rvlite: typeof import('./rvlite/rvlite');
|
||||
sona: typeof import('./sona/ruvector_sona');
|
||||
dag: typeof import('./dag/ruvector_dag_wasm');
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Initialize only specific modules
|
||||
* @param moduleNames - Array of module names to init
|
||||
*/
|
||||
export function initModules(moduleNames: Array<'edge' | 'graph' | 'rvlite' | 'sona' | 'dag' | 'onnx'>): Promise<{
|
||||
edge?: typeof import('./edge/ruvector_edge');
|
||||
graph?: typeof import('./graph/ruvector_graph_wasm');
|
||||
rvlite?: typeof import('./rvlite/rvlite');
|
||||
sona?: typeof import('./sona/ruvector_sona');
|
||||
dag?: typeof import('./dag/ruvector_dag_wasm');
|
||||
onnx?: typeof import('./onnx/ruvector_onnx_embeddings_wasm');
|
||||
}>;
|
||||
|
||||
export const quickStart: string;
|
||||
182
vendor/ruvector/examples/edge-full/pkg/index.js
vendored
Normal file
182
vendor/ruvector/examples/edge-full/pkg/index.js
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
/**
|
||||
* @ruvector/edge-full - Complete WASM toolkit for edge AI
|
||||
*
|
||||
* This package bundles all RuVector WASM modules for comprehensive
|
||||
* edge computing capabilities:
|
||||
*
|
||||
* - edge: Cryptographic identity, P2P, vector search, neural networks
|
||||
* - graph: Neo4j-style graph database with Cypher queries
|
||||
* - rvlite: SQL/SPARQL/Cypher vector database
|
||||
* - sona: Self-optimizing neural architecture with LoRA
|
||||
* - dag: Directed acyclic graph for workflow orchestration
|
||||
* - onnx: ONNX inference with HuggingFace embedding models
|
||||
*
|
||||
* Each module can be imported separately:
|
||||
*
|
||||
* import { WasmIdentity, WasmHnswIndex } from '@ruvector/edge-full/edge';
|
||||
* import { WasmGraphStore } from '@ruvector/edge-full/graph';
|
||||
* import { Database } from '@ruvector/edge-full/rvlite';
|
||||
* import { SonaEngine } from '@ruvector/edge-full/sona';
|
||||
* import { Dag } from '@ruvector/edge-full/dag';
|
||||
* import { OnnxEmbedder } from '@ruvector/edge-full/onnx';
|
||||
*
|
||||
* Or use the unified init for quick setup:
|
||||
*
|
||||
* import { initAll, edge, graph, rvlite, sona, dag } from '@ruvector/edge-full';
|
||||
* await initAll();
|
||||
*/
|
||||
|
||||
// Re-export all modules for convenience
|
||||
export * as edge from './edge/ruvector_edge.js';
|
||||
export * as graph from './graph/ruvector_graph_wasm.js';
|
||||
export * as rvlite from './rvlite/rvlite.js';
|
||||
export * as sona from './sona/ruvector_sona.js';
|
||||
export * as dag from './dag/ruvector_dag_wasm.js';
|
||||
|
||||
// ONNX is large (7MB), export separately
|
||||
export { default as onnxInit } from './onnx/ruvector_onnx_embeddings_wasm.js';
|
||||
|
||||
// Module info
|
||||
export const modules = {
|
||||
edge: {
|
||||
name: 'RuVector Edge',
|
||||
size: '364KB',
|
||||
features: ['Ed25519 identity', 'AES-256-GCM encryption', 'HNSW vector search',
|
||||
'Raft consensus', 'Neural networks', 'Post-quantum crypto']
|
||||
},
|
||||
graph: {
|
||||
name: 'Graph Database',
|
||||
size: '288KB',
|
||||
features: ['Neo4j-style API', 'Cypher queries', 'Hypergraph support',
|
||||
'Worker threads', 'IndexedDB persistence']
|
||||
},
|
||||
rvlite: {
|
||||
name: 'RVLite Vector DB',
|
||||
size: '260KB',
|
||||
features: ['SQL queries', 'SPARQL queries', 'Cypher queries',
|
||||
'Multi-index', 'Browser/Node/Edge']
|
||||
},
|
||||
sona: {
|
||||
name: 'SONA Neural',
|
||||
size: '238KB',
|
||||
features: ['Two-tier LoRA', 'EWC++', 'ReasoningBank',
|
||||
'Adaptive learning', 'Router optimization']
|
||||
},
|
||||
dag: {
|
||||
name: 'DAG Workflows',
|
||||
size: '132KB',
|
||||
features: ['Workflow orchestration', 'Dependency tracking',
|
||||
'Topological sort', 'Minimal footprint']
|
||||
},
|
||||
onnx: {
|
||||
name: 'ONNX Embeddings',
|
||||
size: '7.1MB',
|
||||
features: ['HuggingFace models', '6 pre-trained models',
|
||||
'Parallel workers', 'SIMD acceleration']
|
||||
}
|
||||
};
|
||||
|
||||
// Calculate total size
|
||||
export const totalSize = {
|
||||
core: '1.28MB', // edge + graph + rvlite + sona + dag
|
||||
withOnnx: '8.4MB' // including ONNX
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize all core modules (excludes ONNX due to size)
|
||||
* For ONNX, import and init separately:
|
||||
* import onnxInit from '@ruvector/edge-full/onnx';
|
||||
* await onnxInit();
|
||||
*/
|
||||
export async function initAll() {
|
||||
const { default: edgeInit } = await import('./edge/ruvector_edge.js');
|
||||
const { default: graphInit } = await import('./graph/ruvector_graph_wasm.js');
|
||||
const { default: rvliteInit } = await import('./rvlite/rvlite.js');
|
||||
const { default: sonaInit } = await import('./sona/ruvector_sona.js');
|
||||
const { default: dagInit } = await import('./dag/ruvector_dag_wasm.js');
|
||||
|
||||
await Promise.all([
|
||||
edgeInit(),
|
||||
graphInit(),
|
||||
rvliteInit(),
|
||||
sonaInit(),
|
||||
dagInit()
|
||||
]);
|
||||
|
||||
return { edge, graph, rvlite, sona, dag };
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize only specific modules
|
||||
* @param {string[]} moduleNames - Array of module names to init
|
||||
*/
|
||||
export async function initModules(moduleNames) {
|
||||
const results = {};
|
||||
|
||||
for (const name of moduleNames) {
|
||||
switch (name) {
|
||||
case 'edge':
|
||||
const { default: edgeInit } = await import('./edge/ruvector_edge.js');
|
||||
await edgeInit();
|
||||
results.edge = await import('./edge/ruvector_edge.js');
|
||||
break;
|
||||
case 'graph':
|
||||
const { default: graphInit } = await import('./graph/ruvector_graph_wasm.js');
|
||||
await graphInit();
|
||||
results.graph = await import('./graph/ruvector_graph_wasm.js');
|
||||
break;
|
||||
case 'rvlite':
|
||||
const { default: rvliteInit } = await import('./rvlite/rvlite.js');
|
||||
await rvliteInit();
|
||||
results.rvlite = await import('./rvlite/rvlite.js');
|
||||
break;
|
||||
case 'sona':
|
||||
const { default: sonaInit } = await import('./sona/ruvector_sona.js');
|
||||
await sonaInit();
|
||||
results.sona = await import('./sona/ruvector_sona.js');
|
||||
break;
|
||||
case 'dag':
|
||||
const { default: dagInit } = await import('./dag/ruvector_dag_wasm.js');
|
||||
await dagInit();
|
||||
results.dag = await import('./dag/ruvector_dag_wasm.js');
|
||||
break;
|
||||
case 'onnx':
|
||||
const { default: onnxInit } = await import('./onnx/ruvector_onnx_embeddings_wasm.js');
|
||||
await onnxInit();
|
||||
results.onnx = await import('./onnx/ruvector_onnx_embeddings_wasm.js');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
// Quick start example
|
||||
export const quickStart = `
|
||||
// Initialize all core modules (1.28MB total)
|
||||
import { initAll } from '@ruvector/edge-full';
|
||||
|
||||
const { edge, graph, rvlite, sona, dag } from await initAll();
|
||||
|
||||
// Create cryptographic identity
|
||||
const identity = new edge.WasmIdentity.generate();
|
||||
console.log('Agent:', identity.agent_id());
|
||||
|
||||
// Build a graph
|
||||
const graphStore = new graph.WasmGraphStore();
|
||||
graphStore.run_cypher("CREATE (a:Agent {id: 'agent-1'})");
|
||||
|
||||
// Vector search with SQL
|
||||
const db = new rvlite.Database();
|
||||
db.execute("INSERT INTO vectors (embedding) VALUES ([1,2,3])");
|
||||
|
||||
// Self-learning neural routing
|
||||
const sonaEngine = new sona.SonaEngine();
|
||||
sonaEngine.route_request({ task: "analyze" });
|
||||
|
||||
// Workflow orchestration
|
||||
const workflow = new dag.Dag();
|
||||
workflow.add_node("start");
|
||||
workflow.add_node("process");
|
||||
workflow.add_edge("start", "process");
|
||||
`;
|
||||
112
vendor/ruvector/examples/edge-full/pkg/onnx/ruvector_onnx_embeddings_wasm.d.ts
vendored
Normal file
112
vendor/ruvector/examples/edge-full/pkg/onnx/ruvector_onnx_embeddings_wasm.d.ts
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
/**
|
||||
* Strategy for pooling token embeddings into a single sentence embedding
|
||||
*/
|
||||
export enum PoolingStrategy {
|
||||
/**
|
||||
* Average all token embeddings (most common)
|
||||
*/
|
||||
Mean = 0,
|
||||
/**
|
||||
* Use only the [CLS] token embedding
|
||||
*/
|
||||
Cls = 1,
|
||||
/**
|
||||
* Take the maximum value across all tokens for each dimension
|
||||
*/
|
||||
Max = 2,
|
||||
/**
|
||||
* Mean pooling normalized by sqrt of sequence length
|
||||
*/
|
||||
MeanSqrtLen = 3,
|
||||
/**
|
||||
* Use the last token embedding (for decoder models)
|
||||
*/
|
||||
LastToken = 4,
|
||||
}
|
||||
|
||||
export class WasmEmbedder {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Get maximum sequence length
|
||||
*/
|
||||
maxLength(): number;
|
||||
/**
|
||||
* Compute similarity between two texts
|
||||
*/
|
||||
similarity(text1: string, text2: string): number;
|
||||
/**
|
||||
* Generate embeddings for multiple texts
|
||||
*/
|
||||
embedBatch(texts: string[]): Float32Array;
|
||||
/**
|
||||
* Create embedder with custom configuration
|
||||
*/
|
||||
static withConfig(model_bytes: Uint8Array, tokenizer_json: string, config: WasmEmbedderConfig): WasmEmbedder;
|
||||
/**
|
||||
* Create a new embedder from model and tokenizer bytes
|
||||
*
|
||||
* # Arguments
|
||||
* * `model_bytes` - ONNX model file bytes
|
||||
* * `tokenizer_json` - Tokenizer JSON configuration
|
||||
*/
|
||||
constructor(model_bytes: Uint8Array, tokenizer_json: string);
|
||||
/**
|
||||
* Get the embedding dimension
|
||||
*/
|
||||
dimension(): number;
|
||||
/**
|
||||
* Generate embedding for a single text
|
||||
*/
|
||||
embedOne(text: string): Float32Array;
|
||||
}
|
||||
|
||||
export class WasmEmbedderConfig {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Set pooling strategy (0=Mean, 1=Cls, 2=Max, 3=MeanSqrtLen, 4=LastToken)
|
||||
*/
|
||||
setPooling(pooling: number): WasmEmbedderConfig;
|
||||
/**
|
||||
* Set whether to normalize embeddings
|
||||
*/
|
||||
setNormalize(normalize: boolean): WasmEmbedderConfig;
|
||||
/**
|
||||
* Set maximum sequence length
|
||||
*/
|
||||
setMaxLength(max_length: number): WasmEmbedderConfig;
|
||||
/**
|
||||
* Create a new configuration
|
||||
*/
|
||||
constructor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute cosine similarity between two embedding vectors (JS-friendly)
|
||||
*/
|
||||
export function cosineSimilarity(a: Float32Array, b: Float32Array): number;
|
||||
|
||||
/**
|
||||
* Initialize panic hook for better error messages in WASM
|
||||
*/
|
||||
export function init(): void;
|
||||
|
||||
/**
|
||||
* L2 normalize an embedding vector (JS-friendly)
|
||||
*/
|
||||
export function normalizeL2(embedding: Float32Array): Float32Array;
|
||||
|
||||
/**
|
||||
* Check if SIMD is available (for performance info)
|
||||
* Returns true if compiled with WASM SIMD128 support
|
||||
*/
|
||||
export function simd_available(): boolean;
|
||||
|
||||
/**
|
||||
* Get the library version
|
||||
*/
|
||||
export function version(): string;
|
||||
635
vendor/ruvector/examples/edge-full/pkg/onnx/ruvector_onnx_embeddings_wasm.js
vendored
Normal file
635
vendor/ruvector/examples/edge-full/pkg/onnx/ruvector_onnx_embeddings_wasm.js
vendored
Normal file
@@ -0,0 +1,635 @@
|
||||
|
||||
let imports = {};
|
||||
imports['__wbindgen_placeholder__'] = module.exports;
|
||||
|
||||
function addToExternrefTable0(obj) {
|
||||
const idx = wasm.__externref_table_alloc();
|
||||
wasm.__wbindgen_externrefs.set(idx, obj);
|
||||
return idx;
|
||||
}
|
||||
|
||||
function _assertClass(instance, klass) {
|
||||
if (!(instance instanceof klass)) {
|
||||
throw new Error(`expected instance of ${klass.name}`);
|
||||
}
|
||||
}
|
||||
|
||||
function getArrayF32FromWasm0(ptr, len) {
|
||||
ptr = ptr >>> 0;
|
||||
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
||||
}
|
||||
|
||||
function getArrayU8FromWasm0(ptr, len) {
|
||||
ptr = ptr >>> 0;
|
||||
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
||||
}
|
||||
|
||||
let cachedDataViewMemory0 = null;
|
||||
function getDataViewMemory0() {
|
||||
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
||||
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
||||
}
|
||||
return cachedDataViewMemory0;
|
||||
}
|
||||
|
||||
let cachedFloat32ArrayMemory0 = null;
|
||||
function getFloat32ArrayMemory0() {
|
||||
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
||||
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachedFloat32ArrayMemory0;
|
||||
}
|
||||
|
||||
function getStringFromWasm0(ptr, len) {
|
||||
ptr = ptr >>> 0;
|
||||
return decodeText(ptr, len);
|
||||
}
|
||||
|
||||
let cachedUint8ArrayMemory0 = null;
|
||||
function getUint8ArrayMemory0() {
|
||||
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
||||
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachedUint8ArrayMemory0;
|
||||
}
|
||||
|
||||
function handleError(f, args) {
|
||||
try {
|
||||
return f.apply(this, args);
|
||||
} catch (e) {
|
||||
const idx = addToExternrefTable0(e);
|
||||
wasm.__wbindgen_exn_store(idx);
|
||||
}
|
||||
}
|
||||
|
||||
function isLikeNone(x) {
|
||||
return x === undefined || x === null;
|
||||
}
|
||||
|
||||
function passArray8ToWasm0(arg, malloc) {
|
||||
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
||||
getUint8ArrayMemory0().set(arg, ptr / 1);
|
||||
WASM_VECTOR_LEN = arg.length;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
function passArrayF32ToWasm0(arg, malloc) {
|
||||
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
||||
getFloat32ArrayMemory0().set(arg, ptr / 4);
|
||||
WASM_VECTOR_LEN = arg.length;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
function passArrayJsValueToWasm0(array, malloc) {
|
||||
const ptr = malloc(array.length * 4, 4) >>> 0;
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const add = addToExternrefTable0(array[i]);
|
||||
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
||||
}
|
||||
WASM_VECTOR_LEN = array.length;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
function passStringToWasm0(arg, malloc, realloc) {
|
||||
if (realloc === undefined) {
|
||||
const buf = cachedTextEncoder.encode(arg);
|
||||
const ptr = malloc(buf.length, 1) >>> 0;
|
||||
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
||||
WASM_VECTOR_LEN = buf.length;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
let len = arg.length;
|
||||
let ptr = malloc(len, 1) >>> 0;
|
||||
|
||||
const mem = getUint8ArrayMemory0();
|
||||
|
||||
let offset = 0;
|
||||
|
||||
for (; offset < len; offset++) {
|
||||
const code = arg.charCodeAt(offset);
|
||||
if (code > 0x7F) break;
|
||||
mem[ptr + offset] = code;
|
||||
}
|
||||
if (offset !== len) {
|
||||
if (offset !== 0) {
|
||||
arg = arg.slice(offset);
|
||||
}
|
||||
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
||||
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
||||
const ret = cachedTextEncoder.encodeInto(arg, view);
|
||||
|
||||
offset += ret.written;
|
||||
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
||||
}
|
||||
|
||||
WASM_VECTOR_LEN = offset;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
function takeFromExternrefTable0(idx) {
|
||||
const value = wasm.__wbindgen_externrefs.get(idx);
|
||||
wasm.__externref_table_dealloc(idx);
|
||||
return value;
|
||||
}
|
||||
|
||||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
||||
cachedTextDecoder.decode();
|
||||
function decodeText(ptr, len) {
|
||||
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
||||
}
|
||||
|
||||
const cachedTextEncoder = new TextEncoder();
|
||||
|
||||
if (!('encodeInto' in cachedTextEncoder)) {
|
||||
cachedTextEncoder.encodeInto = function (arg, view) {
|
||||
const buf = cachedTextEncoder.encode(arg);
|
||||
view.set(buf);
|
||||
return {
|
||||
read: arg.length,
|
||||
written: buf.length
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
let WASM_VECTOR_LEN = 0;
|
||||
|
||||
const WasmEmbedderFinalization = (typeof FinalizationRegistry === 'undefined')
|
||||
? { register: () => {}, unregister: () => {} }
|
||||
: new FinalizationRegistry(ptr => wasm.__wbg_wasmembedder_free(ptr >>> 0, 1));
|
||||
|
||||
const WasmEmbedderConfigFinalization = (typeof FinalizationRegistry === 'undefined')
|
||||
? { register: () => {}, unregister: () => {} }
|
||||
: new FinalizationRegistry(ptr => wasm.__wbg_wasmembedderconfig_free(ptr >>> 0, 1));
|
||||
|
||||
/**
|
||||
* Strategy for pooling token embeddings into a single sentence embedding
|
||||
* @enum {0 | 1 | 2 | 3 | 4}
|
||||
*/
|
||||
const PoolingStrategy = Object.freeze({
|
||||
/**
|
||||
* Average all token embeddings (most common)
|
||||
*/
|
||||
Mean: 0, "0": "Mean",
|
||||
/**
|
||||
* Use only the [CLS] token embedding
|
||||
*/
|
||||
Cls: 1, "1": "Cls",
|
||||
/**
|
||||
* Take the maximum value across all tokens for each dimension
|
||||
*/
|
||||
Max: 2, "2": "Max",
|
||||
/**
|
||||
* Mean pooling normalized by sqrt of sequence length
|
||||
*/
|
||||
MeanSqrtLen: 3, "3": "MeanSqrtLen",
|
||||
/**
|
||||
* Use the last token embedding (for decoder models)
|
||||
*/
|
||||
LastToken: 4, "4": "LastToken",
|
||||
});
|
||||
exports.PoolingStrategy = PoolingStrategy;
|
||||
|
||||
/**
|
||||
* WASM-compatible embedder using Tract for inference
|
||||
*/
|
||||
class WasmEmbedder {
|
||||
static __wrap(ptr) {
|
||||
ptr = ptr >>> 0;
|
||||
const obj = Object.create(WasmEmbedder.prototype);
|
||||
obj.__wbg_ptr = ptr;
|
||||
WasmEmbedderFinalization.register(obj, obj.__wbg_ptr, obj);
|
||||
return obj;
|
||||
}
|
||||
__destroy_into_raw() {
|
||||
const ptr = this.__wbg_ptr;
|
||||
this.__wbg_ptr = 0;
|
||||
WasmEmbedderFinalization.unregister(this);
|
||||
return ptr;
|
||||
}
|
||||
free() {
|
||||
const ptr = this.__destroy_into_raw();
|
||||
wasm.__wbg_wasmembedder_free(ptr, 0);
|
||||
}
|
||||
/**
|
||||
* Get maximum sequence length
|
||||
* @returns {number}
|
||||
*/
|
||||
maxLength() {
|
||||
const ret = wasm.wasmembedder_maxLength(this.__wbg_ptr);
|
||||
return ret >>> 0;
|
||||
}
|
||||
/**
|
||||
* Compute similarity between two texts
|
||||
* @param {string} text1
|
||||
* @param {string} text2
|
||||
* @returns {number}
|
||||
*/
|
||||
similarity(text1, text2) {
|
||||
const ptr0 = passStringToWasm0(text1, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
const ptr1 = passStringToWasm0(text2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const len1 = WASM_VECTOR_LEN;
|
||||
const ret = wasm.wasmembedder_similarity(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
||||
if (ret[2]) {
|
||||
throw takeFromExternrefTable0(ret[1]);
|
||||
}
|
||||
return ret[0];
|
||||
}
|
||||
/**
|
||||
* Generate embeddings for multiple texts
|
||||
* @param {string[]} texts
|
||||
* @returns {Float32Array}
|
||||
*/
|
||||
embedBatch(texts) {
|
||||
const ptr0 = passArrayJsValueToWasm0(texts, wasm.__wbindgen_malloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
const ret = wasm.wasmembedder_embedBatch(this.__wbg_ptr, ptr0, len0);
|
||||
if (ret[3]) {
|
||||
throw takeFromExternrefTable0(ret[2]);
|
||||
}
|
||||
var v2 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
||||
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
||||
return v2;
|
||||
}
|
||||
/**
|
||||
* Create embedder with custom configuration
|
||||
* @param {Uint8Array} model_bytes
|
||||
* @param {string} tokenizer_json
|
||||
* @param {WasmEmbedderConfig} config
|
||||
* @returns {WasmEmbedder}
|
||||
*/
|
||||
static withConfig(model_bytes, tokenizer_json, config) {
|
||||
const ptr0 = passArray8ToWasm0(model_bytes, wasm.__wbindgen_malloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
const ptr1 = passStringToWasm0(tokenizer_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const len1 = WASM_VECTOR_LEN;
|
||||
_assertClass(config, WasmEmbedderConfig);
|
||||
var ptr2 = config.__destroy_into_raw();
|
||||
const ret = wasm.wasmembedder_withConfig(ptr0, len0, ptr1, len1, ptr2);
|
||||
if (ret[2]) {
|
||||
throw takeFromExternrefTable0(ret[1]);
|
||||
}
|
||||
return WasmEmbedder.__wrap(ret[0]);
|
||||
}
|
||||
/**
|
||||
* Create a new embedder from model and tokenizer bytes
|
||||
*
|
||||
* # Arguments
|
||||
* * `model_bytes` - ONNX model file bytes
|
||||
* * `tokenizer_json` - Tokenizer JSON configuration
|
||||
* @param {Uint8Array} model_bytes
|
||||
* @param {string} tokenizer_json
|
||||
*/
|
||||
constructor(model_bytes, tokenizer_json) {
|
||||
const ptr0 = passArray8ToWasm0(model_bytes, wasm.__wbindgen_malloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
const ptr1 = passStringToWasm0(tokenizer_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const len1 = WASM_VECTOR_LEN;
|
||||
const ret = wasm.wasmembedder_new(ptr0, len0, ptr1, len1);
|
||||
if (ret[2]) {
|
||||
throw takeFromExternrefTable0(ret[1]);
|
||||
}
|
||||
this.__wbg_ptr = ret[0] >>> 0;
|
||||
WasmEmbedderFinalization.register(this, this.__wbg_ptr, this);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Get the embedding dimension
|
||||
* @returns {number}
|
||||
*/
|
||||
dimension() {
|
||||
const ret = wasm.wasmembedder_dimension(this.__wbg_ptr);
|
||||
return ret >>> 0;
|
||||
}
|
||||
/**
|
||||
* Generate embedding for a single text
|
||||
* @param {string} text
|
||||
* @returns {Float32Array}
|
||||
*/
|
||||
embedOne(text) {
|
||||
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
const ret = wasm.wasmembedder_embedOne(this.__wbg_ptr, ptr0, len0);
|
||||
if (ret[3]) {
|
||||
throw takeFromExternrefTable0(ret[2]);
|
||||
}
|
||||
var v2 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
||||
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
||||
return v2;
|
||||
}
|
||||
}
|
||||
if (Symbol.dispose) WasmEmbedder.prototype[Symbol.dispose] = WasmEmbedder.prototype.free;
|
||||
exports.WasmEmbedder = WasmEmbedder;
|
||||
|
||||
/**
|
||||
* Configuration for the WASM embedder
|
||||
*/
|
||||
class WasmEmbedderConfig {
|
||||
static __wrap(ptr) {
|
||||
ptr = ptr >>> 0;
|
||||
const obj = Object.create(WasmEmbedderConfig.prototype);
|
||||
obj.__wbg_ptr = ptr;
|
||||
WasmEmbedderConfigFinalization.register(obj, obj.__wbg_ptr, obj);
|
||||
return obj;
|
||||
}
|
||||
__destroy_into_raw() {
|
||||
const ptr = this.__wbg_ptr;
|
||||
this.__wbg_ptr = 0;
|
||||
WasmEmbedderConfigFinalization.unregister(this);
|
||||
return ptr;
|
||||
}
|
||||
free() {
|
||||
const ptr = this.__destroy_into_raw();
|
||||
wasm.__wbg_wasmembedderconfig_free(ptr, 0);
|
||||
}
|
||||
/**
|
||||
* Set pooling strategy (0=Mean, 1=Cls, 2=Max, 3=MeanSqrtLen, 4=LastToken)
|
||||
* @param {number} pooling
|
||||
* @returns {WasmEmbedderConfig}
|
||||
*/
|
||||
setPooling(pooling) {
|
||||
const ptr = this.__destroy_into_raw();
|
||||
const ret = wasm.wasmembedderconfig_setPooling(ptr, pooling);
|
||||
return WasmEmbedderConfig.__wrap(ret);
|
||||
}
|
||||
/**
|
||||
* Set whether to normalize embeddings
|
||||
* @param {boolean} normalize
|
||||
* @returns {WasmEmbedderConfig}
|
||||
*/
|
||||
setNormalize(normalize) {
|
||||
const ptr = this.__destroy_into_raw();
|
||||
const ret = wasm.wasmembedderconfig_setNormalize(ptr, normalize);
|
||||
return WasmEmbedderConfig.__wrap(ret);
|
||||
}
|
||||
/**
|
||||
* Set maximum sequence length
|
||||
* @param {number} max_length
|
||||
* @returns {WasmEmbedderConfig}
|
||||
*/
|
||||
setMaxLength(max_length) {
|
||||
const ptr = this.__destroy_into_raw();
|
||||
const ret = wasm.wasmembedderconfig_setMaxLength(ptr, max_length);
|
||||
return WasmEmbedderConfig.__wrap(ret);
|
||||
}
|
||||
/**
|
||||
* Create a new configuration
|
||||
*/
|
||||
constructor() {
|
||||
const ret = wasm.wasmembedderconfig_new();
|
||||
this.__wbg_ptr = ret >>> 0;
|
||||
WasmEmbedderConfigFinalization.register(this, this.__wbg_ptr, this);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
if (Symbol.dispose) WasmEmbedderConfig.prototype[Symbol.dispose] = WasmEmbedderConfig.prototype.free;
|
||||
exports.WasmEmbedderConfig = WasmEmbedderConfig;
|
||||
|
||||
/**
|
||||
* Compute cosine similarity between two embedding vectors (JS-friendly)
|
||||
* @param {Float32Array} a
|
||||
* @param {Float32Array} b
|
||||
* @returns {number}
|
||||
*/
|
||||
function cosineSimilarity(a, b) {
|
||||
const ptr0 = passArrayF32ToWasm0(a, wasm.__wbindgen_malloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
const ptr1 = passArrayF32ToWasm0(b, wasm.__wbindgen_malloc);
|
||||
const len1 = WASM_VECTOR_LEN;
|
||||
const ret = wasm.cosineSimilarity(ptr0, len0, ptr1, len1);
|
||||
return ret;
|
||||
}
|
||||
exports.cosineSimilarity = cosineSimilarity;
|
||||
|
||||
/**
|
||||
* Initialize panic hook for better error messages in WASM
|
||||
*/
|
||||
function init() {
|
||||
wasm.init();
|
||||
}
|
||||
exports.init = init;
|
||||
|
||||
/**
|
||||
* L2 normalize an embedding vector (JS-friendly)
|
||||
* @param {Float32Array} embedding
|
||||
* @returns {Float32Array}
|
||||
*/
|
||||
function normalizeL2(embedding) {
|
||||
const ptr0 = passArrayF32ToWasm0(embedding, wasm.__wbindgen_malloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
const ret = wasm.normalizeL2(ptr0, len0);
|
||||
var v2 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
||||
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
||||
return v2;
|
||||
}
|
||||
exports.normalizeL2 = normalizeL2;
|
||||
|
||||
/**
|
||||
* Check if SIMD is available (for performance info)
|
||||
* Returns true if compiled with WASM SIMD128 support
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function simd_available() {
|
||||
const ret = wasm.simd_available();
|
||||
return ret !== 0;
|
||||
}
|
||||
exports.simd_available = simd_available;
|
||||
|
||||
/**
|
||||
* Get the library version
|
||||
* @returns {string}
|
||||
*/
|
||||
function version() {
|
||||
let deferred1_0;
|
||||
let deferred1_1;
|
||||
try {
|
||||
const ret = wasm.version();
|
||||
deferred1_0 = ret[0];
|
||||
deferred1_1 = ret[1];
|
||||
return getStringFromWasm0(ret[0], ret[1]);
|
||||
} finally {
|
||||
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
||||
}
|
||||
}
|
||||
exports.version = version;
|
||||
|
||||
exports.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
|
||||
const ret = typeof(arg0) === 'function';
|
||||
return ret;
|
||||
};
|
||||
|
||||
exports.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
|
||||
const val = arg0;
|
||||
const ret = typeof(val) === 'object' && val !== null;
|
||||
return ret;
|
||||
};
|
||||
|
||||
exports.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
|
||||
const ret = typeof(arg0) === 'string';
|
||||
return ret;
|
||||
};
|
||||
|
||||
exports.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
|
||||
const ret = arg0 === undefined;
|
||||
return ret;
|
||||
};
|
||||
|
||||
exports.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
|
||||
const obj = arg1;
|
||||
const ret = typeof(obj) === 'string' ? obj : undefined;
|
||||
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
var len1 = WASM_VECTOR_LEN;
|
||||
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
||||
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
||||
};
|
||||
|
||||
exports.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
||||
throw new Error(getStringFromWasm0(arg0, arg1));
|
||||
};
|
||||
|
||||
exports.__wbg_call_3020136f7a2d6e44 = function() { return handleError(function (arg0, arg1, arg2) {
|
||||
const ret = arg0.call(arg1, arg2);
|
||||
return ret;
|
||||
}, arguments) };
|
||||
|
||||
exports.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
|
||||
const ret = arg0.call(arg1);
|
||||
return ret;
|
||||
}, arguments) };
|
||||
|
||||
exports.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
|
||||
const ret = arg0.crypto;
|
||||
return ret;
|
||||
};
|
||||
|
||||
exports.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
|
||||
let deferred0_0;
|
||||
let deferred0_1;
|
||||
try {
|
||||
deferred0_0 = arg0;
|
||||
deferred0_1 = arg1;
|
||||
console.error(getStringFromWasm0(arg0, arg1));
|
||||
} finally {
|
||||
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
||||
}
|
||||
};
|
||||
|
||||
exports.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
|
||||
arg0.getRandomValues(arg1);
|
||||
}, arguments) };
|
||||
|
||||
exports.__wbg_length_22ac23eaec9d8053 = function(arg0) {
|
||||
const ret = arg0.length;
|
||||
return ret;
|
||||
};
|
||||
|
||||
exports.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
|
||||
const ret = arg0.msCrypto;
|
||||
return ret;
|
||||
};
|
||||
|
||||
exports.__wbg_new_8a6f238a6ece86ea = function() {
|
||||
const ret = new Error();
|
||||
return ret;
|
||||
};
|
||||
|
||||
exports.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) {
|
||||
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
||||
return ret;
|
||||
};
|
||||
|
||||
exports.__wbg_new_with_length_aa5eaf41d35235e5 = function(arg0) {
|
||||
const ret = new Uint8Array(arg0 >>> 0);
|
||||
return ret;
|
||||
};
|
||||
|
||||
exports.__wbg_node_905d3e251edff8a2 = function(arg0) {
|
||||
const ret = arg0.node;
|
||||
return ret;
|
||||
};
|
||||
|
||||
exports.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
|
||||
const ret = arg0.process;
|
||||
return ret;
|
||||
};
|
||||
|
||||
exports.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
|
||||
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
||||
};
|
||||
|
||||
exports.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
|
||||
arg0.randomFillSync(arg1);
|
||||
}, arguments) };
|
||||
|
||||
exports.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
|
||||
const ret = module.require;
|
||||
return ret;
|
||||
}, arguments) };
|
||||
|
||||
exports.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
||||
const ret = arg1.stack;
|
||||
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const len1 = WASM_VECTOR_LEN;
|
||||
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
||||
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
||||
};
|
||||
|
||||
exports.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() {
|
||||
const ret = typeof global === 'undefined' ? null : global;
|
||||
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
||||
};
|
||||
|
||||
exports.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
|
||||
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
||||
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
||||
};
|
||||
|
||||
exports.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
|
||||
const ret = typeof self === 'undefined' ? null : self;
|
||||
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
||||
};
|
||||
|
||||
exports.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() {
|
||||
const ret = typeof window === 'undefined' ? null : window;
|
||||
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
||||
};
|
||||
|
||||
exports.__wbg_subarray_845f2f5bce7d061a = function(arg0, arg1, arg2) {
|
||||
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
||||
return ret;
|
||||
};
|
||||
|
||||
exports.__wbg_versions_c01dfd4722a88165 = function(arg0) {
|
||||
const ret = arg0.versions;
|
||||
return ret;
|
||||
};
|
||||
|
||||
exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
||||
// Cast intrinsic for `Ref(String) -> Externref`.
|
||||
const ret = getStringFromWasm0(arg0, arg1);
|
||||
return ret;
|
||||
};
|
||||
|
||||
exports.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
|
||||
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
||||
const ret = getArrayU8FromWasm0(arg0, arg1);
|
||||
return ret;
|
||||
};
|
||||
|
||||
exports.__wbindgen_init_externref_table = function() {
|
||||
const table = wasm.__wbindgen_externrefs;
|
||||
const offset = table.grow(4);
|
||||
table.set(0, undefined);
|
||||
table.set(offset + 0, undefined);
|
||||
table.set(offset + 1, null);
|
||||
table.set(offset + 2, true);
|
||||
table.set(offset + 3, false);
|
||||
};
|
||||
|
||||
const wasmPath = `${__dirname}/ruvector_onnx_embeddings_wasm_bg.wasm`;
|
||||
const wasmBytes = require('fs').readFileSync(wasmPath);
|
||||
const wasmModule = new WebAssembly.Module(wasmBytes);
|
||||
const wasm = exports.__wasm = new WebAssembly.Instance(wasmModule, imports).exports;
|
||||
|
||||
wasm.__wbindgen_start();
|
||||
629
vendor/ruvector/examples/edge-full/pkg/onnx/ruvector_onnx_embeddings_wasm_bg.js
vendored
Normal file
629
vendor/ruvector/examples/edge-full/pkg/onnx/ruvector_onnx_embeddings_wasm_bg.js
vendored
Normal file
@@ -0,0 +1,629 @@
|
||||
let wasm;
|
||||
export function __wbg_set_wasm(val) {
|
||||
wasm = val;
|
||||
}
|
||||
|
||||
function addToExternrefTable0(obj) {
|
||||
const idx = wasm.__externref_table_alloc();
|
||||
wasm.__wbindgen_externrefs.set(idx, obj);
|
||||
return idx;
|
||||
}
|
||||
|
||||
function _assertClass(instance, klass) {
|
||||
if (!(instance instanceof klass)) {
|
||||
throw new Error(`expected instance of ${klass.name}`);
|
||||
}
|
||||
}
|
||||
|
||||
function getArrayF32FromWasm0(ptr, len) {
|
||||
ptr = ptr >>> 0;
|
||||
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
||||
}
|
||||
|
||||
function getArrayU8FromWasm0(ptr, len) {
|
||||
ptr = ptr >>> 0;
|
||||
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
||||
}
|
||||
|
||||
let cachedDataViewMemory0 = null;
|
||||
function getDataViewMemory0() {
|
||||
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
||||
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
||||
}
|
||||
return cachedDataViewMemory0;
|
||||
}
|
||||
|
||||
let cachedFloat32ArrayMemory0 = null;
|
||||
function getFloat32ArrayMemory0() {
|
||||
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
||||
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachedFloat32ArrayMemory0;
|
||||
}
|
||||
|
||||
function getStringFromWasm0(ptr, len) {
|
||||
ptr = ptr >>> 0;
|
||||
return decodeText(ptr, len);
|
||||
}
|
||||
|
||||
let cachedUint8ArrayMemory0 = null;
|
||||
function getUint8ArrayMemory0() {
|
||||
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
||||
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachedUint8ArrayMemory0;
|
||||
}
|
||||
|
||||
function handleError(f, args) {
|
||||
try {
|
||||
return f.apply(this, args);
|
||||
} catch (e) {
|
||||
const idx = addToExternrefTable0(e);
|
||||
wasm.__wbindgen_exn_store(idx);
|
||||
}
|
||||
}
|
||||
|
||||
function isLikeNone(x) {
|
||||
return x === undefined || x === null;
|
||||
}
|
||||
|
||||
function passArray8ToWasm0(arg, malloc) {
|
||||
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
||||
getUint8ArrayMemory0().set(arg, ptr / 1);
|
||||
WASM_VECTOR_LEN = arg.length;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
function passArrayF32ToWasm0(arg, malloc) {
|
||||
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
||||
getFloat32ArrayMemory0().set(arg, ptr / 4);
|
||||
WASM_VECTOR_LEN = arg.length;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
function passArrayJsValueToWasm0(array, malloc) {
|
||||
const ptr = malloc(array.length * 4, 4) >>> 0;
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const add = addToExternrefTable0(array[i]);
|
||||
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
||||
}
|
||||
WASM_VECTOR_LEN = array.length;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
function passStringToWasm0(arg, malloc, realloc) {
|
||||
if (realloc === undefined) {
|
||||
const buf = cachedTextEncoder.encode(arg);
|
||||
const ptr = malloc(buf.length, 1) >>> 0;
|
||||
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
||||
WASM_VECTOR_LEN = buf.length;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
let len = arg.length;
|
||||
let ptr = malloc(len, 1) >>> 0;
|
||||
|
||||
const mem = getUint8ArrayMemory0();
|
||||
|
||||
let offset = 0;
|
||||
|
||||
for (; offset < len; offset++) {
|
||||
const code = arg.charCodeAt(offset);
|
||||
if (code > 0x7F) break;
|
||||
mem[ptr + offset] = code;
|
||||
}
|
||||
if (offset !== len) {
|
||||
if (offset !== 0) {
|
||||
arg = arg.slice(offset);
|
||||
}
|
||||
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
||||
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
||||
const ret = cachedTextEncoder.encodeInto(arg, view);
|
||||
|
||||
offset += ret.written;
|
||||
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
||||
}
|
||||
|
||||
WASM_VECTOR_LEN = offset;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
function takeFromExternrefTable0(idx) {
|
||||
const value = wasm.__wbindgen_externrefs.get(idx);
|
||||
wasm.__externref_table_dealloc(idx);
|
||||
return value;
|
||||
}
|
||||
|
||||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
||||
cachedTextDecoder.decode();
|
||||
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
||||
let numBytesDecoded = 0;
|
||||
function decodeText(ptr, len) {
|
||||
numBytesDecoded += len;
|
||||
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
||||
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
||||
cachedTextDecoder.decode();
|
||||
numBytesDecoded = len;
|
||||
}
|
||||
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
||||
}
|
||||
|
||||
const cachedTextEncoder = new TextEncoder();
|
||||
|
||||
if (!('encodeInto' in cachedTextEncoder)) {
|
||||
cachedTextEncoder.encodeInto = function (arg, view) {
|
||||
const buf = cachedTextEncoder.encode(arg);
|
||||
view.set(buf);
|
||||
return {
|
||||
read: arg.length,
|
||||
written: buf.length
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
let WASM_VECTOR_LEN = 0;
|
||||
|
||||
const WasmEmbedderFinalization = (typeof FinalizationRegistry === 'undefined')
|
||||
? { register: () => {}, unregister: () => {} }
|
||||
: new FinalizationRegistry(ptr => wasm.__wbg_wasmembedder_free(ptr >>> 0, 1));
|
||||
|
||||
const WasmEmbedderConfigFinalization = (typeof FinalizationRegistry === 'undefined')
|
||||
? { register: () => {}, unregister: () => {} }
|
||||
: new FinalizationRegistry(ptr => wasm.__wbg_wasmembedderconfig_free(ptr >>> 0, 1));
|
||||
|
||||
/**
|
||||
* Strategy for pooling token embeddings into a single sentence embedding
|
||||
* @enum {0 | 1 | 2 | 3 | 4}
|
||||
*/
|
||||
export const PoolingStrategy = Object.freeze({
|
||||
/**
|
||||
* Average all token embeddings (most common)
|
||||
*/
|
||||
Mean: 0, "0": "Mean",
|
||||
/**
|
||||
* Use only the [CLS] token embedding
|
||||
*/
|
||||
Cls: 1, "1": "Cls",
|
||||
/**
|
||||
* Take the maximum value across all tokens for each dimension
|
||||
*/
|
||||
Max: 2, "2": "Max",
|
||||
/**
|
||||
* Mean pooling normalized by sqrt of sequence length
|
||||
*/
|
||||
MeanSqrtLen: 3, "3": "MeanSqrtLen",
|
||||
/**
|
||||
* Use the last token embedding (for decoder models)
|
||||
*/
|
||||
LastToken: 4, "4": "LastToken",
|
||||
});
|
||||
|
||||
/**
|
||||
* WASM-compatible embedder using Tract for inference
|
||||
*/
|
||||
export class WasmEmbedder {
|
||||
static __wrap(ptr) {
|
||||
ptr = ptr >>> 0;
|
||||
const obj = Object.create(WasmEmbedder.prototype);
|
||||
obj.__wbg_ptr = ptr;
|
||||
WasmEmbedderFinalization.register(obj, obj.__wbg_ptr, obj);
|
||||
return obj;
|
||||
}
|
||||
__destroy_into_raw() {
|
||||
const ptr = this.__wbg_ptr;
|
||||
this.__wbg_ptr = 0;
|
||||
WasmEmbedderFinalization.unregister(this);
|
||||
return ptr;
|
||||
}
|
||||
free() {
|
||||
const ptr = this.__destroy_into_raw();
|
||||
wasm.__wbg_wasmembedder_free(ptr, 0);
|
||||
}
|
||||
/**
|
||||
* Get maximum sequence length
|
||||
* @returns {number}
|
||||
*/
|
||||
maxLength() {
|
||||
const ret = wasm.wasmembedder_maxLength(this.__wbg_ptr);
|
||||
return ret >>> 0;
|
||||
}
|
||||
/**
|
||||
* Compute similarity between two texts
|
||||
* @param {string} text1
|
||||
* @param {string} text2
|
||||
* @returns {number}
|
||||
*/
|
||||
similarity(text1, text2) {
|
||||
const ptr0 = passStringToWasm0(text1, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
const ptr1 = passStringToWasm0(text2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const len1 = WASM_VECTOR_LEN;
|
||||
const ret = wasm.wasmembedder_similarity(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
||||
if (ret[2]) {
|
||||
throw takeFromExternrefTable0(ret[1]);
|
||||
}
|
||||
return ret[0];
|
||||
}
|
||||
/**
|
||||
* Generate embeddings for multiple texts
|
||||
* @param {string[]} texts
|
||||
* @returns {Float32Array}
|
||||
*/
|
||||
embedBatch(texts) {
|
||||
const ptr0 = passArrayJsValueToWasm0(texts, wasm.__wbindgen_malloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
const ret = wasm.wasmembedder_embedBatch(this.__wbg_ptr, ptr0, len0);
|
||||
if (ret[3]) {
|
||||
throw takeFromExternrefTable0(ret[2]);
|
||||
}
|
||||
var v2 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
||||
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
||||
return v2;
|
||||
}
|
||||
/**
|
||||
* Create embedder with custom configuration
|
||||
* @param {Uint8Array} model_bytes
|
||||
* @param {string} tokenizer_json
|
||||
* @param {WasmEmbedderConfig} config
|
||||
* @returns {WasmEmbedder}
|
||||
*/
|
||||
static withConfig(model_bytes, tokenizer_json, config) {
|
||||
const ptr0 = passArray8ToWasm0(model_bytes, wasm.__wbindgen_malloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
const ptr1 = passStringToWasm0(tokenizer_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const len1 = WASM_VECTOR_LEN;
|
||||
_assertClass(config, WasmEmbedderConfig);
|
||||
var ptr2 = config.__destroy_into_raw();
|
||||
const ret = wasm.wasmembedder_withConfig(ptr0, len0, ptr1, len1, ptr2);
|
||||
if (ret[2]) {
|
||||
throw takeFromExternrefTable0(ret[1]);
|
||||
}
|
||||
return WasmEmbedder.__wrap(ret[0]);
|
||||
}
|
||||
/**
|
||||
* Create a new embedder from model and tokenizer bytes
|
||||
*
|
||||
* # Arguments
|
||||
* * `model_bytes` - ONNX model file bytes
|
||||
* * `tokenizer_json` - Tokenizer JSON configuration
|
||||
* @param {Uint8Array} model_bytes
|
||||
* @param {string} tokenizer_json
|
||||
*/
|
||||
constructor(model_bytes, tokenizer_json) {
|
||||
const ptr0 = passArray8ToWasm0(model_bytes, wasm.__wbindgen_malloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
const ptr1 = passStringToWasm0(tokenizer_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const len1 = WASM_VECTOR_LEN;
|
||||
const ret = wasm.wasmembedder_new(ptr0, len0, ptr1, len1);
|
||||
if (ret[2]) {
|
||||
throw takeFromExternrefTable0(ret[1]);
|
||||
}
|
||||
this.__wbg_ptr = ret[0] >>> 0;
|
||||
WasmEmbedderFinalization.register(this, this.__wbg_ptr, this);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Get the embedding dimension
|
||||
* @returns {number}
|
||||
*/
|
||||
dimension() {
|
||||
const ret = wasm.wasmembedder_dimension(this.__wbg_ptr);
|
||||
return ret >>> 0;
|
||||
}
|
||||
/**
|
||||
* Generate embedding for a single text
|
||||
* @param {string} text
|
||||
* @returns {Float32Array}
|
||||
*/
|
||||
embedOne(text) {
|
||||
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
const ret = wasm.wasmembedder_embedOne(this.__wbg_ptr, ptr0, len0);
|
||||
if (ret[3]) {
|
||||
throw takeFromExternrefTable0(ret[2]);
|
||||
}
|
||||
var v2 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
||||
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
||||
return v2;
|
||||
}
|
||||
}
|
||||
if (Symbol.dispose) WasmEmbedder.prototype[Symbol.dispose] = WasmEmbedder.prototype.free;
|
||||
|
||||
/**
|
||||
* Configuration for the WASM embedder
|
||||
*/
|
||||
export class WasmEmbedderConfig {
|
||||
static __wrap(ptr) {
|
||||
ptr = ptr >>> 0;
|
||||
const obj = Object.create(WasmEmbedderConfig.prototype);
|
||||
obj.__wbg_ptr = ptr;
|
||||
WasmEmbedderConfigFinalization.register(obj, obj.__wbg_ptr, obj);
|
||||
return obj;
|
||||
}
|
||||
__destroy_into_raw() {
|
||||
const ptr = this.__wbg_ptr;
|
||||
this.__wbg_ptr = 0;
|
||||
WasmEmbedderConfigFinalization.unregister(this);
|
||||
return ptr;
|
||||
}
|
||||
free() {
|
||||
const ptr = this.__destroy_into_raw();
|
||||
wasm.__wbg_wasmembedderconfig_free(ptr, 0);
|
||||
}
|
||||
/**
|
||||
* Set pooling strategy (0=Mean, 1=Cls, 2=Max, 3=MeanSqrtLen, 4=LastToken)
|
||||
* @param {number} pooling
|
||||
* @returns {WasmEmbedderConfig}
|
||||
*/
|
||||
setPooling(pooling) {
|
||||
const ptr = this.__destroy_into_raw();
|
||||
const ret = wasm.wasmembedderconfig_setPooling(ptr, pooling);
|
||||
return WasmEmbedderConfig.__wrap(ret);
|
||||
}
|
||||
/**
|
||||
* Set whether to normalize embeddings
|
||||
* @param {boolean} normalize
|
||||
* @returns {WasmEmbedderConfig}
|
||||
*/
|
||||
setNormalize(normalize) {
|
||||
const ptr = this.__destroy_into_raw();
|
||||
const ret = wasm.wasmembedderconfig_setNormalize(ptr, normalize);
|
||||
return WasmEmbedderConfig.__wrap(ret);
|
||||
}
|
||||
/**
|
||||
* Set maximum sequence length
|
||||
* @param {number} max_length
|
||||
* @returns {WasmEmbedderConfig}
|
||||
*/
|
||||
setMaxLength(max_length) {
|
||||
const ptr = this.__destroy_into_raw();
|
||||
const ret = wasm.wasmembedderconfig_setMaxLength(ptr, max_length);
|
||||
return WasmEmbedderConfig.__wrap(ret);
|
||||
}
|
||||
/**
|
||||
* Create a new configuration
|
||||
*/
|
||||
constructor() {
|
||||
const ret = wasm.wasmembedderconfig_new();
|
||||
this.__wbg_ptr = ret >>> 0;
|
||||
WasmEmbedderConfigFinalization.register(this, this.__wbg_ptr, this);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
if (Symbol.dispose) WasmEmbedderConfig.prototype[Symbol.dispose] = WasmEmbedderConfig.prototype.free;
|
||||
|
||||
/**
|
||||
* Compute cosine similarity between two embedding vectors (JS-friendly)
|
||||
* @param {Float32Array} a
|
||||
* @param {Float32Array} b
|
||||
* @returns {number}
|
||||
*/
|
||||
export function cosineSimilarity(a, b) {
|
||||
const ptr0 = passArrayF32ToWasm0(a, wasm.__wbindgen_malloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
const ptr1 = passArrayF32ToWasm0(b, wasm.__wbindgen_malloc);
|
||||
const len1 = WASM_VECTOR_LEN;
|
||||
const ret = wasm.cosineSimilarity(ptr0, len0, ptr1, len1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize panic hook for better error messages in WASM
|
||||
*/
|
||||
export function init() {
|
||||
wasm.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* L2 normalize an embedding vector (JS-friendly)
|
||||
* @param {Float32Array} embedding
|
||||
* @returns {Float32Array}
|
||||
*/
|
||||
export function normalizeL2(embedding) {
|
||||
const ptr0 = passArrayF32ToWasm0(embedding, wasm.__wbindgen_malloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
const ret = wasm.normalizeL2(ptr0, len0);
|
||||
var v2 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
||||
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
||||
return v2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if SIMD is available (for performance info)
|
||||
* Returns true if compiled with WASM SIMD128 support
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function simd_available() {
|
||||
const ret = wasm.simd_available();
|
||||
return ret !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the library version
|
||||
* @returns {string}
|
||||
*/
|
||||
export function version() {
|
||||
let deferred1_0;
|
||||
let deferred1_1;
|
||||
try {
|
||||
const ret = wasm.version();
|
||||
deferred1_0 = ret[0];
|
||||
deferred1_1 = ret[1];
|
||||
return getStringFromWasm0(ret[0], ret[1]);
|
||||
} finally {
|
||||
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
export function __wbg___wbindgen_is_function_8d400b8b1af978cd(arg0) {
|
||||
const ret = typeof(arg0) === 'function';
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbg___wbindgen_is_object_ce774f3490692386(arg0) {
|
||||
const val = arg0;
|
||||
const ret = typeof(val) === 'object' && val !== null;
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbg___wbindgen_is_string_704ef9c8fc131030(arg0) {
|
||||
const ret = typeof(arg0) === 'string';
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbg___wbindgen_is_undefined_f6b95eab589e0269(arg0) {
|
||||
const ret = arg0 === undefined;
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbg___wbindgen_string_get_a2a31e16edf96e42(arg0, arg1) {
|
||||
const obj = arg1;
|
||||
const ret = typeof(obj) === 'string' ? obj : undefined;
|
||||
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
var len1 = WASM_VECTOR_LEN;
|
||||
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
||||
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
||||
};
|
||||
|
||||
export function __wbg___wbindgen_throw_dd24417ed36fc46e(arg0, arg1) {
|
||||
throw new Error(getStringFromWasm0(arg0, arg1));
|
||||
};
|
||||
|
||||
export function __wbg_call_3020136f7a2d6e44() { return handleError(function (arg0, arg1, arg2) {
|
||||
const ret = arg0.call(arg1, arg2);
|
||||
return ret;
|
||||
}, arguments) };
|
||||
|
||||
export function __wbg_call_abb4ff46ce38be40() { return handleError(function (arg0, arg1) {
|
||||
const ret = arg0.call(arg1);
|
||||
return ret;
|
||||
}, arguments) };
|
||||
|
||||
export function __wbg_crypto_574e78ad8b13b65f(arg0) {
|
||||
const ret = arg0.crypto;
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbg_error_7534b8e9a36f1ab4(arg0, arg1) {
|
||||
let deferred0_0;
|
||||
let deferred0_1;
|
||||
try {
|
||||
deferred0_0 = arg0;
|
||||
deferred0_1 = arg1;
|
||||
console.error(getStringFromWasm0(arg0, arg1));
|
||||
} finally {
|
||||
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
||||
}
|
||||
};
|
||||
|
||||
export function __wbg_getRandomValues_b8f5dbd5f3995a9e() { return handleError(function (arg0, arg1) {
|
||||
arg0.getRandomValues(arg1);
|
||||
}, arguments) };
|
||||
|
||||
export function __wbg_length_22ac23eaec9d8053(arg0) {
|
||||
const ret = arg0.length;
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbg_msCrypto_a61aeb35a24c1329(arg0) {
|
||||
const ret = arg0.msCrypto;
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbg_new_8a6f238a6ece86ea() {
|
||||
const ret = new Error();
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbg_new_no_args_cb138f77cf6151ee(arg0, arg1) {
|
||||
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbg_new_with_length_aa5eaf41d35235e5(arg0) {
|
||||
const ret = new Uint8Array(arg0 >>> 0);
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbg_node_905d3e251edff8a2(arg0) {
|
||||
const ret = arg0.node;
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbg_process_dc0fbacc7c1c06f7(arg0) {
|
||||
const ret = arg0.process;
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbg_prototypesetcall_dfe9b766cdc1f1fd(arg0, arg1, arg2) {
|
||||
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
||||
};
|
||||
|
||||
export function __wbg_randomFillSync_ac0988aba3254290() { return handleError(function (arg0, arg1) {
|
||||
arg0.randomFillSync(arg1);
|
||||
}, arguments) };
|
||||
|
||||
export function __wbg_require_60cc747a6bc5215a() { return handleError(function () {
|
||||
const ret = module.require;
|
||||
return ret;
|
||||
}, arguments) };
|
||||
|
||||
export function __wbg_stack_0ed75d68575b0f3c(arg0, arg1) {
|
||||
const ret = arg1.stack;
|
||||
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const len1 = WASM_VECTOR_LEN;
|
||||
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
||||
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
||||
};
|
||||
|
||||
export function __wbg_static_accessor_GLOBAL_769e6b65d6557335() {
|
||||
const ret = typeof global === 'undefined' ? null : global;
|
||||
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
||||
};
|
||||
|
||||
export function __wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1() {
|
||||
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
||||
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
||||
};
|
||||
|
||||
export function __wbg_static_accessor_SELF_08f5a74c69739274() {
|
||||
const ret = typeof self === 'undefined' ? null : self;
|
||||
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
||||
};
|
||||
|
||||
export function __wbg_static_accessor_WINDOW_a8924b26aa92d024() {
|
||||
const ret = typeof window === 'undefined' ? null : window;
|
||||
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
||||
};
|
||||
|
||||
export function __wbg_subarray_845f2f5bce7d061a(arg0, arg1, arg2) {
|
||||
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbg_versions_c01dfd4722a88165(arg0) {
|
||||
const ret = arg0.versions;
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
|
||||
// Cast intrinsic for `Ref(String) -> Externref`.
|
||||
const ret = getStringFromWasm0(arg0, arg1);
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbindgen_cast_cb9088102bce6b30(arg0, arg1) {
|
||||
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
||||
const ret = getArrayU8FromWasm0(arg0, arg1);
|
||||
return ret;
|
||||
};
|
||||
|
||||
export function __wbindgen_init_externref_table() {
|
||||
const table = wasm.__wbindgen_externrefs;
|
||||
const offset = table.grow(4);
|
||||
table.set(0, undefined);
|
||||
table.set(offset + 0, undefined);
|
||||
table.set(offset + 1, null);
|
||||
table.set(offset + 2, true);
|
||||
table.set(offset + 3, false);
|
||||
};
|
||||
BIN
vendor/ruvector/examples/edge-full/pkg/onnx/ruvector_onnx_embeddings_wasm_bg.wasm
vendored
Normal file
BIN
vendor/ruvector/examples/edge-full/pkg/onnx/ruvector_onnx_embeddings_wasm_bg.wasm
vendored
Normal file
Binary file not shown.
29
vendor/ruvector/examples/edge-full/pkg/onnx/ruvector_onnx_embeddings_wasm_bg.wasm.d.ts
vendored
Normal file
29
vendor/ruvector/examples/edge-full/pkg/onnx/ruvector_onnx_embeddings_wasm_bg.wasm.d.ts
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const memory: WebAssembly.Memory;
|
||||
export const __wbg_wasmembedder_free: (a: number, b: number) => void;
|
||||
export const __wbg_wasmembedderconfig_free: (a: number, b: number) => void;
|
||||
export const cosineSimilarity: (a: number, b: number, c: number, d: number) => number;
|
||||
export const normalizeL2: (a: number, b: number) => [number, number];
|
||||
export const wasmembedder_dimension: (a: number) => number;
|
||||
export const wasmembedder_embedBatch: (a: number, b: number, c: number) => [number, number, number, number];
|
||||
export const wasmembedder_embedOne: (a: number, b: number, c: number) => [number, number, number, number];
|
||||
export const wasmembedder_maxLength: (a: number) => number;
|
||||
export const wasmembedder_new: (a: number, b: number, c: number, d: number) => [number, number, number];
|
||||
export const wasmembedder_similarity: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
||||
export const wasmembedder_withConfig: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
||||
export const wasmembedderconfig_new: () => number;
|
||||
export const wasmembedderconfig_setMaxLength: (a: number, b: number) => number;
|
||||
export const wasmembedderconfig_setNormalize: (a: number, b: number) => number;
|
||||
export const wasmembedderconfig_setPooling: (a: number, b: number) => number;
|
||||
export const init: () => void;
|
||||
export const simd_available: () => number;
|
||||
export const version: () => [number, number];
|
||||
export const __wbindgen_malloc: (a: number, b: number) => number;
|
||||
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
||||
export const __wbindgen_exn_store: (a: number) => void;
|
||||
export const __externref_table_alloc: () => number;
|
||||
export const __wbindgen_externrefs: WebAssembly.Table;
|
||||
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
||||
export const __externref_table_dealloc: (a: number) => void;
|
||||
export const __wbindgen_start: () => void;
|
||||
86
vendor/ruvector/examples/edge-full/pkg/package.json
vendored
Normal file
86
vendor/ruvector/examples/edge-full/pkg/package.json
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
{
|
||||
"name": "@ruvector/edge-full",
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"description": "Complete WASM toolkit for edge AI: vector search, graph DB, neural networks, DAG workflows, SQL/SPARQL/Cypher, and ONNX inference - all running in browser",
|
||||
"main": "index.js",
|
||||
"module": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"keywords": [
|
||||
"wasm",
|
||||
"rust",
|
||||
"ai",
|
||||
"edge",
|
||||
"browser",
|
||||
"vector-search",
|
||||
"hnsw",
|
||||
"graph-database",
|
||||
"cypher",
|
||||
"sparql",
|
||||
"sql",
|
||||
"neural-network",
|
||||
"onnx",
|
||||
"embeddings",
|
||||
"dag",
|
||||
"workflow",
|
||||
"post-quantum",
|
||||
"cryptography",
|
||||
"consensus",
|
||||
"raft",
|
||||
"p2p",
|
||||
"swarm"
|
||||
],
|
||||
"author": "RuVector Team",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ruvnet/ruvector"
|
||||
},
|
||||
"homepage": "https://github.com/ruvnet/ruvector/tree/main/examples/edge-full",
|
||||
"bugs": {
|
||||
"url": "https://github.com/ruvnet/ruvector/issues"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"edge/",
|
||||
"graph/",
|
||||
"rvlite/",
|
||||
"sona/",
|
||||
"dag/",
|
||||
"onnx/",
|
||||
"generator.html",
|
||||
"LICENSE"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./index.js",
|
||||
"types": "./index.d.ts"
|
||||
},
|
||||
"./edge": {
|
||||
"import": "./edge/ruvector_edge.js",
|
||||
"types": "./edge/ruvector_edge.d.ts"
|
||||
},
|
||||
"./graph": {
|
||||
"import": "./graph/ruvector_graph_wasm.js",
|
||||
"types": "./graph/ruvector_graph_wasm.d.ts"
|
||||
},
|
||||
"./rvlite": {
|
||||
"import": "./rvlite/rvlite.js",
|
||||
"types": "./rvlite/rvlite.d.ts"
|
||||
},
|
||||
"./sona": {
|
||||
"import": "./sona/ruvector_sona.js",
|
||||
"types": "./sona/ruvector_sona.d.ts"
|
||||
},
|
||||
"./dag": {
|
||||
"import": "./dag/ruvector_dag_wasm.js",
|
||||
"types": "./dag/ruvector_dag_wasm.d.ts"
|
||||
},
|
||||
"./onnx": {
|
||||
"import": "./onnx/ruvector_onnx_embeddings_wasm.js",
|
||||
"types": "./onnx/ruvector_onnx_embeddings_wasm.d.ts"
|
||||
}
|
||||
},
|
||||
"sideEffects": false
|
||||
}
|
||||
556
vendor/ruvector/examples/edge-full/pkg/rvlite/rvlite.d.ts
vendored
Normal file
556
vendor/ruvector/examples/edge-full/pkg/rvlite/rvlite.d.ts
vendored
Normal file
@@ -0,0 +1,556 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
export class BaseLoRA {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
distillFrom(micro: MicroLoRA, blend_factor: number): void;
|
||||
applyGradients(): void;
|
||||
constructor(config: LoraConfig);
|
||||
stats(): any;
|
||||
forward(input: Float32Array): Float32Array;
|
||||
}
|
||||
|
||||
export class Embedder {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Get embedding dimensions
|
||||
*/
|
||||
dimensions(): number;
|
||||
/**
|
||||
* Compute similarity between two texts
|
||||
*/
|
||||
similarity(text_a: string, text_b: string): number;
|
||||
/**
|
||||
* Batch embed multiple texts
|
||||
* Takes JsValue array of strings, returns JsValue array of Float32Arrays
|
||||
*/
|
||||
embed_batch(texts: any): any;
|
||||
/**
|
||||
* Create embedder with custom config
|
||||
*/
|
||||
static with_config(config: EmbeddingConfig): Embedder;
|
||||
/**
|
||||
* Compute cosine similarity between two embeddings (JS arrays)
|
||||
*/
|
||||
static cosine_similarity(a: Float32Array, b: Float32Array): number;
|
||||
/**
|
||||
* Create a new embedder with default config
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Generate embeddings for a single text
|
||||
* Uses hash-based projection for lightweight WASM operation
|
||||
* Returns Float32Array for direct JS consumption
|
||||
*/
|
||||
embed(text: string): Float32Array;
|
||||
}
|
||||
|
||||
export class EmbeddingConfig {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Create config for larger models
|
||||
*/
|
||||
static with_dimensions(dimensions: number): EmbeddingConfig;
|
||||
constructor();
|
||||
/**
|
||||
* Create config for all-MiniLM-L6-v2 (default)
|
||||
*/
|
||||
static minilm(): EmbeddingConfig;
|
||||
/**
|
||||
* Model dimensions (384 for all-MiniLM-L6-v2)
|
||||
*/
|
||||
dimensions: number;
|
||||
/**
|
||||
* Normalize output vectors
|
||||
*/
|
||||
normalize: boolean;
|
||||
/**
|
||||
* Max sequence length
|
||||
*/
|
||||
max_length: number;
|
||||
}
|
||||
|
||||
export class LoraConfig {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Create custom LoRA configuration
|
||||
*/
|
||||
constructor(hidden_dim: number, rank: number, alpha: number, learning_rate: number);
|
||||
/**
|
||||
* Create BaseLoRA configuration (background training)
|
||||
*/
|
||||
static base(hidden_dim: number): LoraConfig;
|
||||
/**
|
||||
* Create MicroLoRA configuration (per-request, <100μs)
|
||||
*/
|
||||
static micro(hidden_dim: number): LoraConfig;
|
||||
/**
|
||||
* Export as JSON
|
||||
*/
|
||||
toJSON(): any;
|
||||
/**
|
||||
* Validate configuration
|
||||
*/
|
||||
validate(): void;
|
||||
/**
|
||||
* LoRA rank (1-2 for micro, 4-16 for base)
|
||||
*/
|
||||
readonly rank: number;
|
||||
/**
|
||||
* Alpha scaling factor
|
||||
*/
|
||||
readonly alpha: number;
|
||||
/**
|
||||
* Learning rate for adaptation
|
||||
*/
|
||||
readonly learning_rate: number;
|
||||
/**
|
||||
* Hidden dimension
|
||||
*/
|
||||
readonly hidden_dim: number;
|
||||
}
|
||||
|
||||
export class MicroLoRA {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
exportWeights(): any;
|
||||
applyGradients(): void;
|
||||
accumulateGradient(input: Float32Array, feedback: number): void;
|
||||
constructor(config: LoraConfig);
|
||||
reset(): void;
|
||||
stats(): any;
|
||||
forward(input: Float32Array): Float32Array;
|
||||
}
|
||||
|
||||
export class RvLite {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Get configuration
|
||||
*/
|
||||
get_config(): any;
|
||||
/**
|
||||
* Get version string
|
||||
*/
|
||||
get_version(): string;
|
||||
/**
|
||||
* Get enabled features
|
||||
*/
|
||||
get_features(): any;
|
||||
/**
|
||||
* Insert a vector with a specific ID
|
||||
*/
|
||||
insert_with_id(id: string, vector: Float32Array, metadata?: any | null): void;
|
||||
/**
|
||||
* Search with metadata filter
|
||||
*/
|
||||
search_with_filter(query_vector: Float32Array, k: number, filter: any): any;
|
||||
/**
|
||||
* Get a vector by ID
|
||||
*/
|
||||
get(id: string): any;
|
||||
/**
|
||||
* Get the number of vectors in the database
|
||||
*/
|
||||
len(): number;
|
||||
/**
|
||||
* Create a new RvLite database
|
||||
*/
|
||||
constructor(config: RvLiteConfig);
|
||||
/**
|
||||
* Execute SQL query (not yet implemented)
|
||||
*/
|
||||
sql(_query: string): Promise<any>;
|
||||
/**
|
||||
* Execute Cypher query (not yet implemented)
|
||||
*/
|
||||
cypher(_query: string): Promise<any>;
|
||||
/**
|
||||
* Delete a vector by ID
|
||||
*/
|
||||
delete(id: string): boolean;
|
||||
/**
|
||||
* Insert a vector with optional metadata
|
||||
* Returns the vector ID
|
||||
*/
|
||||
insert(vector: Float32Array, metadata?: any | null): string;
|
||||
/**
|
||||
* Search for similar vectors
|
||||
* Returns a JavaScript array of search results
|
||||
*/
|
||||
search(query_vector: Float32Array, k: number): any;
|
||||
/**
|
||||
* Execute SPARQL query (not yet implemented)
|
||||
*/
|
||||
sparql(_query: string): Promise<any>;
|
||||
/**
|
||||
* Create with default configuration (384 dimensions, cosine similarity)
|
||||
*/
|
||||
static default(): RvLite;
|
||||
/**
|
||||
* Check if database is empty
|
||||
*/
|
||||
is_empty(): boolean;
|
||||
/**
|
||||
* Check if database is ready
|
||||
*/
|
||||
is_ready(): boolean;
|
||||
}
|
||||
|
||||
export class RvLiteConfig {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Set distance metric (euclidean, cosine, dotproduct, manhattan)
|
||||
*/
|
||||
with_distance_metric(metric: string): RvLiteConfig;
|
||||
constructor(dimensions: number);
|
||||
}
|
||||
|
||||
export class TrmConfig {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Enable/disable attention variant
|
||||
*/
|
||||
withAttention(use_attention: boolean): TrmConfig;
|
||||
/**
|
||||
* Set default K iterations
|
||||
*/
|
||||
withDefaultK(k: number): TrmConfig;
|
||||
/**
|
||||
* Enable/disable early stopping
|
||||
*/
|
||||
withEarlyStopping(enabled: boolean): TrmConfig;
|
||||
/**
|
||||
* Set latent iterations per K step
|
||||
*/
|
||||
withLatentIterations(n: number): TrmConfig;
|
||||
/**
|
||||
* Set confidence threshold
|
||||
*/
|
||||
withConfidenceThreshold(threshold: number): TrmConfig;
|
||||
/**
|
||||
* Create a new TRM configuration
|
||||
*/
|
||||
constructor(embedding_dim: number, hidden_dim: number, max_k: number);
|
||||
/**
|
||||
* Create configuration optimized for speed
|
||||
*/
|
||||
static fast(embedding_dim: number): TrmConfig;
|
||||
/**
|
||||
* Create configuration optimized for quality
|
||||
*/
|
||||
static quality(embedding_dim: number): TrmConfig;
|
||||
/**
|
||||
* Export configuration as JSON
|
||||
*/
|
||||
toJSON(): any;
|
||||
/**
|
||||
* Create balanced configuration (recommended)
|
||||
*/
|
||||
static balanced(embedding_dim: number): TrmConfig;
|
||||
/**
|
||||
* Validate configuration
|
||||
*/
|
||||
validate(): void;
|
||||
/**
|
||||
* Import configuration from JSON
|
||||
*/
|
||||
static fromJSON(value: any): TrmConfig;
|
||||
/**
|
||||
* Embedding dimension (input/output size)
|
||||
*/
|
||||
readonly embedding_dim: number;
|
||||
/**
|
||||
* Hidden dimension for latent state
|
||||
*/
|
||||
readonly hidden_dim: number;
|
||||
/**
|
||||
* Maximum K iterations
|
||||
*/
|
||||
readonly max_k: number;
|
||||
/**
|
||||
* Default K iterations
|
||||
*/
|
||||
readonly default_k: number;
|
||||
/**
|
||||
* Latent updates per K iteration
|
||||
*/
|
||||
readonly latent_iterations: number;
|
||||
/**
|
||||
* Use attention variant (more expressive, slower)
|
||||
*/
|
||||
readonly use_attention: boolean;
|
||||
/**
|
||||
* Number of attention heads
|
||||
*/
|
||||
readonly num_heads: number;
|
||||
/**
|
||||
* Confidence threshold for early stopping
|
||||
*/
|
||||
readonly confidence_threshold: number;
|
||||
/**
|
||||
* Enable early stopping
|
||||
*/
|
||||
readonly early_stopping: boolean;
|
||||
/**
|
||||
* Minimum iterations before early stopping
|
||||
*/
|
||||
readonly min_iterations: number;
|
||||
/**
|
||||
* Convergence threshold for plateau detection
|
||||
*/
|
||||
readonly convergence_threshold: number;
|
||||
/**
|
||||
* Residual scale for answer refinement
|
||||
*/
|
||||
readonly residual_scale: number;
|
||||
}
|
||||
|
||||
export class TrmEngine {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
getConfig(): any;
|
||||
reasonWithK(question: Float32Array, answer: Float32Array, k: number): TrmResult;
|
||||
constructor(config: TrmConfig);
|
||||
reset(): void;
|
||||
stats(): any;
|
||||
reason(question: Float32Array, answer: Float32Array): TrmResult;
|
||||
}
|
||||
|
||||
export class TrmResult {
|
||||
private constructor();
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
getAnswer(): Float32Array;
|
||||
toJSON(): any;
|
||||
readonly confidence: number;
|
||||
readonly iterations_used: number;
|
||||
readonly early_stopped: boolean;
|
||||
readonly latency_ms: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick benchmark for embeddings
|
||||
*/
|
||||
export function benchmark_embeddings(iterations: number): any;
|
||||
|
||||
/**
|
||||
* Quick benchmark function
|
||||
*/
|
||||
export function benchmark_trm(iterations: number, hidden_dim: number): any;
|
||||
|
||||
/**
|
||||
* Compute cosine similarity
|
||||
*/
|
||||
export function cosineSimilarity(a: Float32Array, b: Float32Array): number;
|
||||
|
||||
/**
|
||||
* Dot product
|
||||
*/
|
||||
export function dotProduct(a: Float32Array, b: Float32Array): number;
|
||||
|
||||
/**
|
||||
* Get feature info
|
||||
*/
|
||||
export function features(): any;
|
||||
|
||||
export function init(): void;
|
||||
|
||||
/**
|
||||
* Compute L2 distance
|
||||
*/
|
||||
export function l2Distance(a: Float32Array, b: Float32Array): number;
|
||||
|
||||
/**
|
||||
* Linear interpolation
|
||||
*/
|
||||
export function lerp(a: Float32Array, b: Float32Array, t: number): Float32Array;
|
||||
|
||||
/**
|
||||
* Mean pooling for token embeddings
|
||||
*/
|
||||
export function meanPooling(embeddings: any, attention_mask?: Float32Array | null): Float32Array;
|
||||
|
||||
/**
|
||||
* Normalize a vector to unit length
|
||||
*/
|
||||
export function normalizeVector(vec: Float32Array): Float32Array;
|
||||
|
||||
/**
|
||||
* Create a random vector
|
||||
*/
|
||||
export function randomVector(dim: number, seed?: number | null): Float32Array;
|
||||
|
||||
/**
|
||||
* Softmax function
|
||||
*/
|
||||
export function softmax(vec: Float32Array): Float32Array;
|
||||
|
||||
/**
|
||||
* Get version string
|
||||
*/
|
||||
export function version(): string;
|
||||
|
||||
/**
|
||||
* Create a zero vector
|
||||
*/
|
||||
export function zeros(dim: number): Float32Array;
|
||||
|
||||
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
||||
|
||||
export interface InitOutput {
|
||||
readonly memory: WebAssembly.Memory;
|
||||
readonly __wbg_baselora_free: (a: number, b: number) => void;
|
||||
readonly __wbg_embedder_free: (a: number, b: number) => void;
|
||||
readonly __wbg_embeddingconfig_free: (a: number, b: number) => void;
|
||||
readonly __wbg_get_embeddingconfig_dimensions: (a: number) => number;
|
||||
readonly __wbg_get_embeddingconfig_max_length: (a: number) => number;
|
||||
readonly __wbg_get_embeddingconfig_normalize: (a: number) => number;
|
||||
readonly __wbg_get_loraconfig_alpha: (a: number) => number;
|
||||
readonly __wbg_get_loraconfig_hidden_dim: (a: number) => number;
|
||||
readonly __wbg_get_loraconfig_learning_rate: (a: number) => number;
|
||||
readonly __wbg_get_trmconfig_confidence_threshold: (a: number) => number;
|
||||
readonly __wbg_get_trmconfig_convergence_threshold: (a: number) => number;
|
||||
readonly __wbg_get_trmconfig_early_stopping: (a: number) => number;
|
||||
readonly __wbg_get_trmconfig_latent_iterations: (a: number) => number;
|
||||
readonly __wbg_get_trmconfig_max_k: (a: number) => number;
|
||||
readonly __wbg_get_trmconfig_min_iterations: (a: number) => number;
|
||||
readonly __wbg_get_trmconfig_num_heads: (a: number) => number;
|
||||
readonly __wbg_get_trmconfig_residual_scale: (a: number) => number;
|
||||
readonly __wbg_get_trmconfig_use_attention: (a: number) => number;
|
||||
readonly __wbg_get_trmresult_confidence: (a: number) => number;
|
||||
readonly __wbg_get_trmresult_early_stopped: (a: number) => number;
|
||||
readonly __wbg_get_trmresult_iterations_used: (a: number) => number;
|
||||
readonly __wbg_get_trmresult_latency_ms: (a: number) => number;
|
||||
readonly __wbg_loraconfig_free: (a: number, b: number) => void;
|
||||
readonly __wbg_microlora_free: (a: number, b: number) => void;
|
||||
readonly __wbg_rvlite_free: (a: number, b: number) => void;
|
||||
readonly __wbg_rvliteconfig_free: (a: number, b: number) => void;
|
||||
readonly __wbg_set_embeddingconfig_dimensions: (a: number, b: number) => void;
|
||||
readonly __wbg_set_embeddingconfig_max_length: (a: number, b: number) => void;
|
||||
readonly __wbg_set_embeddingconfig_normalize: (a: number, b: number) => void;
|
||||
readonly __wbg_trmconfig_free: (a: number, b: number) => void;
|
||||
readonly __wbg_trmengine_free: (a: number, b: number) => void;
|
||||
readonly __wbg_trmresult_free: (a: number, b: number) => void;
|
||||
readonly baselora_applyGradients: (a: number) => void;
|
||||
readonly baselora_distillFrom: (a: number, b: number, c: number, d: number) => void;
|
||||
readonly baselora_forward: (a: number, b: number, c: number, d: number) => void;
|
||||
readonly baselora_new: (a: number, b: number) => void;
|
||||
readonly baselora_stats: (a: number) => number;
|
||||
readonly benchmark_embeddings: (a: number) => number;
|
||||
readonly benchmark_trm: (a: number, b: number) => number;
|
||||
readonly cosineSimilarity: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
readonly dotProduct: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
readonly embedder_cosine_similarity: (a: number, b: number) => number;
|
||||
readonly embedder_dimensions: (a: number) => number;
|
||||
readonly embedder_embed: (a: number, b: number, c: number) => number;
|
||||
readonly embedder_embed_batch: (a: number, b: number, c: number) => void;
|
||||
readonly embedder_new: () => number;
|
||||
readonly embedder_similarity: (a: number, b: number, c: number, d: number, e: number) => number;
|
||||
readonly embedder_with_config: (a: number) => number;
|
||||
readonly embeddingconfig_minilm: () => number;
|
||||
readonly embeddingconfig_with_dimensions: (a: number) => number;
|
||||
readonly features: () => number;
|
||||
readonly init: () => void;
|
||||
readonly l2Distance: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
readonly lerp: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
||||
readonly loraconfig_base: (a: number) => number;
|
||||
readonly loraconfig_micro: (a: number) => number;
|
||||
readonly loraconfig_new: (a: number, b: number, c: number, d: number) => number;
|
||||
readonly loraconfig_toJSON: (a: number) => number;
|
||||
readonly loraconfig_validate: (a: number, b: number) => void;
|
||||
readonly meanPooling: (a: number, b: number, c: number, d: number) => void;
|
||||
readonly microlora_accumulateGradient: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
readonly microlora_applyGradients: (a: number) => void;
|
||||
readonly microlora_exportWeights: (a: number) => number;
|
||||
readonly microlora_forward: (a: number, b: number, c: number, d: number) => void;
|
||||
readonly microlora_new: (a: number, b: number) => void;
|
||||
readonly microlora_reset: (a: number) => void;
|
||||
readonly microlora_stats: (a: number) => number;
|
||||
readonly normalizeVector: (a: number, b: number, c: number) => void;
|
||||
readonly randomVector: (a: number, b: number, c: number) => void;
|
||||
readonly rvlite_cypher: (a: number, b: number, c: number) => number;
|
||||
readonly rvlite_default: (a: number) => void;
|
||||
readonly rvlite_delete: (a: number, b: number, c: number, d: number) => void;
|
||||
readonly rvlite_get: (a: number, b: number, c: number, d: number) => void;
|
||||
readonly rvlite_get_config: (a: number, b: number) => void;
|
||||
readonly rvlite_get_features: (a: number, b: number) => void;
|
||||
readonly rvlite_get_version: (a: number, b: number) => void;
|
||||
readonly rvlite_insert: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
readonly rvlite_insert_with_id: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
||||
readonly rvlite_is_empty: (a: number, b: number) => void;
|
||||
readonly rvlite_is_ready: (a: number) => number;
|
||||
readonly rvlite_len: (a: number, b: number) => void;
|
||||
readonly rvlite_new: (a: number, b: number) => void;
|
||||
readonly rvlite_search: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
readonly rvlite_search_with_filter: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
||||
readonly rvlite_sparql: (a: number, b: number, c: number) => number;
|
||||
readonly rvlite_sql: (a: number, b: number, c: number) => number;
|
||||
readonly rvliteconfig_new: (a: number) => number;
|
||||
readonly rvliteconfig_with_distance_metric: (a: number, b: number, c: number) => number;
|
||||
readonly softmax: (a: number, b: number, c: number) => void;
|
||||
readonly trmconfig_balanced: (a: number) => number;
|
||||
readonly trmconfig_fast: (a: number) => number;
|
||||
readonly trmconfig_fromJSON: (a: number, b: number) => void;
|
||||
readonly trmconfig_new: (a: number, b: number, c: number) => number;
|
||||
readonly trmconfig_quality: (a: number) => number;
|
||||
readonly trmconfig_toJSON: (a: number) => number;
|
||||
readonly trmconfig_validate: (a: number, b: number) => void;
|
||||
readonly trmconfig_withAttention: (a: number, b: number) => number;
|
||||
readonly trmconfig_withConfidenceThreshold: (a: number, b: number) => number;
|
||||
readonly trmconfig_withDefaultK: (a: number, b: number) => number;
|
||||
readonly trmconfig_withEarlyStopping: (a: number, b: number) => number;
|
||||
readonly trmconfig_withLatentIterations: (a: number, b: number) => number;
|
||||
readonly trmengine_getConfig: (a: number) => number;
|
||||
readonly trmengine_new: (a: number, b: number) => void;
|
||||
readonly trmengine_reason: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
||||
readonly trmengine_reasonWithK: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
||||
readonly trmengine_reset: (a: number) => void;
|
||||
readonly trmengine_stats: (a: number) => number;
|
||||
readonly trmresult_getAnswer: (a: number, b: number) => void;
|
||||
readonly trmresult_toJSON: (a: number) => number;
|
||||
readonly version: (a: number) => void;
|
||||
readonly zeros: (a: number, b: number) => void;
|
||||
readonly embeddingconfig_new: () => number;
|
||||
readonly __wbg_get_trmconfig_embedding_dim: (a: number) => number;
|
||||
readonly __wbg_get_loraconfig_rank: (a: number) => number;
|
||||
readonly __wbg_get_trmconfig_hidden_dim: (a: number) => number;
|
||||
readonly __wbg_get_trmconfig_default_k: (a: number) => number;
|
||||
readonly __wasm_bindgen_func_elem_690: (a: number, b: number, c: number) => void;
|
||||
readonly __wasm_bindgen_func_elem_684: (a: number, b: number) => void;
|
||||
readonly __wasm_bindgen_func_elem_1412: (a: number, b: number, c: number, d: number) => void;
|
||||
readonly __wbindgen_export: (a: number, b: number) => number;
|
||||
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
||||
readonly __wbindgen_export3: (a: number) => void;
|
||||
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
||||
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
||||
readonly __wbindgen_start: () => void;
|
||||
}
|
||||
|
||||
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
||||
|
||||
/**
|
||||
* Instantiates the given `module`, which can either be bytes or
|
||||
* a precompiled `WebAssembly.Module`.
|
||||
*
|
||||
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
||||
*
|
||||
* @returns {InitOutput}
|
||||
*/
|
||||
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
||||
|
||||
/**
|
||||
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
||||
* for everything else, calls `WebAssembly.instantiate` directly.
|
||||
*
|
||||
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
||||
*
|
||||
* @returns {Promise<InitOutput>}
|
||||
*/
|
||||
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
||||
2366
vendor/ruvector/examples/edge-full/pkg/rvlite/rvlite.js
vendored
Normal file
2366
vendor/ruvector/examples/edge-full/pkg/rvlite/rvlite.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
vendor/ruvector/examples/edge-full/pkg/rvlite/rvlite_bg.wasm
vendored
Normal file
BIN
vendor/ruvector/examples/edge-full/pkg/rvlite/rvlite_bg.wasm
vendored
Normal file
Binary file not shown.
128
vendor/ruvector/examples/edge-full/pkg/rvlite/rvlite_bg.wasm.d.ts
vendored
Normal file
128
vendor/ruvector/examples/edge-full/pkg/rvlite/rvlite_bg.wasm.d.ts
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const memory: WebAssembly.Memory;
|
||||
export const __wbg_baselora_free: (a: number, b: number) => void;
|
||||
export const __wbg_embedder_free: (a: number, b: number) => void;
|
||||
export const __wbg_embeddingconfig_free: (a: number, b: number) => void;
|
||||
export const __wbg_get_embeddingconfig_dimensions: (a: number) => number;
|
||||
export const __wbg_get_embeddingconfig_max_length: (a: number) => number;
|
||||
export const __wbg_get_embeddingconfig_normalize: (a: number) => number;
|
||||
export const __wbg_get_loraconfig_alpha: (a: number) => number;
|
||||
export const __wbg_get_loraconfig_hidden_dim: (a: number) => number;
|
||||
export const __wbg_get_loraconfig_learning_rate: (a: number) => number;
|
||||
export const __wbg_get_trmconfig_confidence_threshold: (a: number) => number;
|
||||
export const __wbg_get_trmconfig_convergence_threshold: (a: number) => number;
|
||||
export const __wbg_get_trmconfig_early_stopping: (a: number) => number;
|
||||
export const __wbg_get_trmconfig_latent_iterations: (a: number) => number;
|
||||
export const __wbg_get_trmconfig_max_k: (a: number) => number;
|
||||
export const __wbg_get_trmconfig_min_iterations: (a: number) => number;
|
||||
export const __wbg_get_trmconfig_num_heads: (a: number) => number;
|
||||
export const __wbg_get_trmconfig_residual_scale: (a: number) => number;
|
||||
export const __wbg_get_trmconfig_use_attention: (a: number) => number;
|
||||
export const __wbg_get_trmresult_confidence: (a: number) => number;
|
||||
export const __wbg_get_trmresult_early_stopped: (a: number) => number;
|
||||
export const __wbg_get_trmresult_iterations_used: (a: number) => number;
|
||||
export const __wbg_get_trmresult_latency_ms: (a: number) => number;
|
||||
export const __wbg_loraconfig_free: (a: number, b: number) => void;
|
||||
export const __wbg_microlora_free: (a: number, b: number) => void;
|
||||
export const __wbg_rvlite_free: (a: number, b: number) => void;
|
||||
export const __wbg_rvliteconfig_free: (a: number, b: number) => void;
|
||||
export const __wbg_set_embeddingconfig_dimensions: (a: number, b: number) => void;
|
||||
export const __wbg_set_embeddingconfig_max_length: (a: number, b: number) => void;
|
||||
export const __wbg_set_embeddingconfig_normalize: (a: number, b: number) => void;
|
||||
export const __wbg_trmconfig_free: (a: number, b: number) => void;
|
||||
export const __wbg_trmengine_free: (a: number, b: number) => void;
|
||||
export const __wbg_trmresult_free: (a: number, b: number) => void;
|
||||
export const baselora_applyGradients: (a: number) => void;
|
||||
export const baselora_distillFrom: (a: number, b: number, c: number, d: number) => void;
|
||||
export const baselora_forward: (a: number, b: number, c: number, d: number) => void;
|
||||
export const baselora_new: (a: number, b: number) => void;
|
||||
export const baselora_stats: (a: number) => number;
|
||||
export const benchmark_embeddings: (a: number) => number;
|
||||
export const benchmark_trm: (a: number, b: number) => number;
|
||||
export const cosineSimilarity: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
export const dotProduct: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
export const embedder_cosine_similarity: (a: number, b: number) => number;
|
||||
export const embedder_dimensions: (a: number) => number;
|
||||
export const embedder_embed: (a: number, b: number, c: number) => number;
|
||||
export const embedder_embed_batch: (a: number, b: number, c: number) => void;
|
||||
export const embedder_new: () => number;
|
||||
export const embedder_similarity: (a: number, b: number, c: number, d: number, e: number) => number;
|
||||
export const embedder_with_config: (a: number) => number;
|
||||
export const embeddingconfig_minilm: () => number;
|
||||
export const embeddingconfig_with_dimensions: (a: number) => number;
|
||||
export const features: () => number;
|
||||
export const init: () => void;
|
||||
export const l2Distance: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
export const lerp: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
||||
export const loraconfig_base: (a: number) => number;
|
||||
export const loraconfig_micro: (a: number) => number;
|
||||
export const loraconfig_new: (a: number, b: number, c: number, d: number) => number;
|
||||
export const loraconfig_toJSON: (a: number) => number;
|
||||
export const loraconfig_validate: (a: number, b: number) => void;
|
||||
export const meanPooling: (a: number, b: number, c: number, d: number) => void;
|
||||
export const microlora_accumulateGradient: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
export const microlora_applyGradients: (a: number) => void;
|
||||
export const microlora_exportWeights: (a: number) => number;
|
||||
export const microlora_forward: (a: number, b: number, c: number, d: number) => void;
|
||||
export const microlora_new: (a: number, b: number) => void;
|
||||
export const microlora_reset: (a: number) => void;
|
||||
export const microlora_stats: (a: number) => number;
|
||||
export const normalizeVector: (a: number, b: number, c: number) => void;
|
||||
export const randomVector: (a: number, b: number, c: number) => void;
|
||||
export const rvlite_cypher: (a: number, b: number, c: number) => number;
|
||||
export const rvlite_default: (a: number) => void;
|
||||
export const rvlite_delete: (a: number, b: number, c: number, d: number) => void;
|
||||
export const rvlite_get: (a: number, b: number, c: number, d: number) => void;
|
||||
export const rvlite_get_config: (a: number, b: number) => void;
|
||||
export const rvlite_get_features: (a: number, b: number) => void;
|
||||
export const rvlite_get_version: (a: number, b: number) => void;
|
||||
export const rvlite_insert: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
export const rvlite_insert_with_id: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
||||
export const rvlite_is_empty: (a: number, b: number) => void;
|
||||
export const rvlite_is_ready: (a: number) => number;
|
||||
export const rvlite_len: (a: number, b: number) => void;
|
||||
export const rvlite_new: (a: number, b: number) => void;
|
||||
export const rvlite_search: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
export const rvlite_search_with_filter: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
||||
export const rvlite_sparql: (a: number, b: number, c: number) => number;
|
||||
export const rvlite_sql: (a: number, b: number, c: number) => number;
|
||||
export const rvliteconfig_new: (a: number) => number;
|
||||
export const rvliteconfig_with_distance_metric: (a: number, b: number, c: number) => number;
|
||||
export const softmax: (a: number, b: number, c: number) => void;
|
||||
export const trmconfig_balanced: (a: number) => number;
|
||||
export const trmconfig_fast: (a: number) => number;
|
||||
export const trmconfig_fromJSON: (a: number, b: number) => void;
|
||||
export const trmconfig_new: (a: number, b: number, c: number) => number;
|
||||
export const trmconfig_quality: (a: number) => number;
|
||||
export const trmconfig_toJSON: (a: number) => number;
|
||||
export const trmconfig_validate: (a: number, b: number) => void;
|
||||
export const trmconfig_withAttention: (a: number, b: number) => number;
|
||||
export const trmconfig_withConfidenceThreshold: (a: number, b: number) => number;
|
||||
export const trmconfig_withDefaultK: (a: number, b: number) => number;
|
||||
export const trmconfig_withEarlyStopping: (a: number, b: number) => number;
|
||||
export const trmconfig_withLatentIterations: (a: number, b: number) => number;
|
||||
export const trmengine_getConfig: (a: number) => number;
|
||||
export const trmengine_new: (a: number, b: number) => void;
|
||||
export const trmengine_reason: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
||||
export const trmengine_reasonWithK: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
||||
export const trmengine_reset: (a: number) => void;
|
||||
export const trmengine_stats: (a: number) => number;
|
||||
export const trmresult_getAnswer: (a: number, b: number) => void;
|
||||
export const trmresult_toJSON: (a: number) => number;
|
||||
export const version: (a: number) => void;
|
||||
export const zeros: (a: number, b: number) => void;
|
||||
export const embeddingconfig_new: () => number;
|
||||
export const __wbg_get_trmconfig_embedding_dim: (a: number) => number;
|
||||
export const __wbg_get_loraconfig_rank: (a: number) => number;
|
||||
export const __wbg_get_trmconfig_hidden_dim: (a: number) => number;
|
||||
export const __wbg_get_trmconfig_default_k: (a: number) => number;
|
||||
export const __wasm_bindgen_func_elem_690: (a: number, b: number, c: number) => void;
|
||||
export const __wasm_bindgen_func_elem_684: (a: number, b: number) => void;
|
||||
export const __wasm_bindgen_func_elem_1412: (a: number, b: number, c: number, d: number) => void;
|
||||
export const __wbindgen_export: (a: number, b: number) => number;
|
||||
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
||||
export const __wbindgen_export3: (a: number) => void;
|
||||
export const __wbindgen_export4: (a: number, b: number, c: number) => void;
|
||||
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
||||
export const __wbindgen_start: () => void;
|
||||
513
vendor/ruvector/examples/edge-full/pkg/sona/ruvector_sona.d.ts
vendored
Normal file
513
vendor/ruvector/examples/edge-full/pkg/sona/ruvector_sona.d.ts
vendored
Normal file
@@ -0,0 +1,513 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
export class WasmEphemeralAgent {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Force learning cycle on agent's engine
|
||||
*/
|
||||
forceLearn(): string;
|
||||
/**
|
||||
* Create agent with custom configuration
|
||||
*
|
||||
* # Arguments
|
||||
* * `agent_id` - Unique identifier
|
||||
* * `config` - JSON configuration object
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* const config = {
|
||||
* hidden_dim: 256,
|
||||
* trajectory_capacity: 500,
|
||||
* pattern_clusters: 25
|
||||
* };
|
||||
* const agent = WasmEphemeralAgent.with_config("agent-1", config);
|
||||
* ```
|
||||
*/
|
||||
static withConfig(agent_id: string, config: any): WasmEphemeralAgent;
|
||||
/**
|
||||
* Export agent state for coordinator aggregation
|
||||
*
|
||||
* # Returns
|
||||
* JSON object containing agent state, trajectories, and statistics
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* const state = agent.export_state();
|
||||
* console.log('Trajectories:', state.trajectories.length);
|
||||
* coordinator.aggregate(state);
|
||||
* ```
|
||||
*/
|
||||
exportState(): any;
|
||||
/**
|
||||
* Get learned patterns from agent
|
||||
*/
|
||||
getPatterns(): any;
|
||||
/**
|
||||
* Process a task and record trajectory
|
||||
*
|
||||
* # Arguments
|
||||
* * `embedding` - Query embedding as Float32Array
|
||||
* * `quality` - Task quality score [0.0, 1.0]
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* const embedding = new Float32Array(256).fill(0.1);
|
||||
* agent.process_task(embedding, 0.85);
|
||||
* ```
|
||||
*/
|
||||
processTask(embedding: Float32Array, quality: number): void;
|
||||
/**
|
||||
* Get agent uptime in seconds
|
||||
*/
|
||||
uptimeSeconds(): bigint;
|
||||
/**
|
||||
* Get average quality of collected trajectories
|
||||
*/
|
||||
averageQuality(): number;
|
||||
/**
|
||||
* Get number of collected trajectories
|
||||
*/
|
||||
trajectoryCount(): number;
|
||||
/**
|
||||
* Process task with model route information
|
||||
*
|
||||
* # Arguments
|
||||
* * `embedding` - Query embedding
|
||||
* * `quality` - Quality score
|
||||
* * `route` - Model route used (e.g., "gpt-4", "claude-3")
|
||||
*/
|
||||
processTaskWithRoute(embedding: Float32Array, quality: number, route: string): void;
|
||||
/**
|
||||
* Create a new ephemeral agent with default config
|
||||
*
|
||||
* # Arguments
|
||||
* * `agent_id` - Unique identifier for this agent
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* const agent = new WasmEphemeralAgent("agent-1");
|
||||
* ```
|
||||
*/
|
||||
constructor(agent_id: string);
|
||||
/**
|
||||
* Clear collected trajectories (after export)
|
||||
*/
|
||||
clear(): void;
|
||||
/**
|
||||
* Get agent statistics
|
||||
*
|
||||
* # Returns
|
||||
* JSON object with trajectory count, quality stats, uptime
|
||||
*/
|
||||
getStats(): any;
|
||||
}
|
||||
|
||||
export class WasmFederatedCoordinator {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Apply coordinator's learned LoRA to input
|
||||
*/
|
||||
applyLora(input: Float32Array): Float32Array;
|
||||
/**
|
||||
* Get total number of contributing agents
|
||||
*/
|
||||
agentCount(): number;
|
||||
/**
|
||||
* Consolidate learning from all aggregated trajectories
|
||||
*
|
||||
* Should be called periodically after aggregating multiple agents.
|
||||
*
|
||||
* # Returns
|
||||
* Learning result as JSON string
|
||||
*/
|
||||
consolidate(): string;
|
||||
/**
|
||||
* Create coordinator with custom configuration
|
||||
*
|
||||
* # Arguments
|
||||
* * `coordinator_id` - Unique identifier
|
||||
* * `config` - JSON configuration object
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* const config = {
|
||||
* hidden_dim: 256,
|
||||
* trajectory_capacity: 50000,
|
||||
* pattern_clusters: 200,
|
||||
* ewc_lambda: 2000.0
|
||||
* };
|
||||
* const coordinator = WasmFederatedCoordinator.with_config("central", config);
|
||||
* ```
|
||||
*/
|
||||
static withConfig(coordinator_id: string, config: any): WasmFederatedCoordinator;
|
||||
/**
|
||||
* Get all learned patterns from coordinator
|
||||
*/
|
||||
getPatterns(): any;
|
||||
/**
|
||||
* Find similar patterns to query
|
||||
*
|
||||
* # Arguments
|
||||
* * `query_embedding` - Query vector
|
||||
* * `k` - Number of patterns to return
|
||||
*/
|
||||
findPatterns(query_embedding: Float32Array, k: number): any;
|
||||
/**
|
||||
* Get total trajectories aggregated
|
||||
*/
|
||||
totalTrajectories(): number;
|
||||
/**
|
||||
* Set quality threshold for accepting trajectories
|
||||
*
|
||||
* # Arguments
|
||||
* * `threshold` - Minimum quality [0.0, 1.0], default 0.4
|
||||
*/
|
||||
setQualityThreshold(threshold: number): void;
|
||||
/**
|
||||
* Create a new federated coordinator with default config
|
||||
*
|
||||
* # Arguments
|
||||
* * `coordinator_id` - Unique identifier for this coordinator
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* const coordinator = new WasmFederatedCoordinator("central");
|
||||
* ```
|
||||
*/
|
||||
constructor(coordinator_id: string);
|
||||
/**
|
||||
* Clear all agent contributions (reset coordinator)
|
||||
*/
|
||||
clear(): void;
|
||||
/**
|
||||
* Aggregate agent export into coordinator
|
||||
*
|
||||
* # Arguments
|
||||
* * `agent_export` - JSON export from agent.export_state()
|
||||
*
|
||||
* # Returns
|
||||
* JSON aggregation result with accepted/rejected counts
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* const agentState = agent.export_state();
|
||||
* const result = coordinator.aggregate(agentState);
|
||||
* console.log('Accepted:', result.accepted);
|
||||
* ```
|
||||
*/
|
||||
aggregate(agent_export: any): any;
|
||||
/**
|
||||
* Get coordinator statistics
|
||||
*
|
||||
* # Returns
|
||||
* JSON object with agent count, trajectory count, quality stats
|
||||
*/
|
||||
getStats(): any;
|
||||
}
|
||||
|
||||
export class WasmSonaEngine {
|
||||
free(): void;
|
||||
[Symbol.dispose](): void;
|
||||
/**
|
||||
* Apply LoRA transformation to input vector
|
||||
*
|
||||
* # Arguments
|
||||
* * `input` - Input vector as Float32Array
|
||||
*
|
||||
* # Returns
|
||||
* Transformed vector as Float32Array
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* const input = new Float32Array(256).fill(1.0);
|
||||
* const output = engine.apply_lora(input);
|
||||
* ```
|
||||
*/
|
||||
applyLora(input: Float32Array): Float32Array;
|
||||
/**
|
||||
* Get configuration
|
||||
*
|
||||
* # Returns
|
||||
* Configuration as JSON object
|
||||
*/
|
||||
getConfig(): any;
|
||||
/**
|
||||
* Check if engine is enabled
|
||||
*
|
||||
* # Returns
|
||||
* true if enabled, false otherwise
|
||||
*/
|
||||
isEnabled(): boolean;
|
||||
/**
|
||||
* Force background learning cycle
|
||||
*
|
||||
* # Returns
|
||||
* Learning statistics as JSON string
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* const stats = engine.force_learn();
|
||||
* console.log('Learning results:', stats);
|
||||
* ```
|
||||
*/
|
||||
forceLearn(): string;
|
||||
/**
|
||||
* Record a step in the trajectory
|
||||
*
|
||||
* # Arguments
|
||||
* * `trajectory_id` - ID returned from start_trajectory
|
||||
* * `node_id` - Graph node visited
|
||||
* * `score` - Step quality score [0.0, 1.0]
|
||||
* * `latency_us` - Step latency in microseconds
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* engine.record_step(trajectoryId, 42, 0.8, 1000);
|
||||
* ```
|
||||
*/
|
||||
recordStep(trajectory_id: bigint, node_id: number, score: number, latency_us: bigint): void;
|
||||
/**
|
||||
* Enable or disable the engine
|
||||
*
|
||||
* # Arguments
|
||||
* * `enabled` - Whether to enable the engine
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* engine.set_enabled(false); // Pause learning
|
||||
* ```
|
||||
*/
|
||||
setEnabled(enabled: boolean): void;
|
||||
/**
|
||||
* Create engine with custom configuration
|
||||
*
|
||||
* # Arguments
|
||||
* * `config` - JSON configuration object
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* const config = {
|
||||
* hidden_dim: 256,
|
||||
* embedding_dim: 256,
|
||||
* micro_lora_rank: 2,
|
||||
* base_lora_rank: 16,
|
||||
* micro_lora_lr: 0.001,
|
||||
* base_lora_lr: 0.0001,
|
||||
* ewc_lambda: 1000.0,
|
||||
* pattern_clusters: 128,
|
||||
* trajectory_capacity: 10000,
|
||||
* quality_threshold: 0.6
|
||||
* };
|
||||
* const engine = WasmSonaEngine.with_config(config);
|
||||
* ```
|
||||
*/
|
||||
static withConfig(config: any): WasmSonaEngine;
|
||||
/**
|
||||
* Find similar patterns to query
|
||||
*
|
||||
* # Arguments
|
||||
* * `query_embedding` - Query vector as Float32Array
|
||||
* * `k` - Number of patterns to return
|
||||
*
|
||||
* # Returns
|
||||
* Array of similar patterns as JSON
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* const query = new Float32Array(256).fill(0.5);
|
||||
* const patterns = engine.find_patterns(query, 5);
|
||||
* console.log('Similar patterns:', patterns);
|
||||
* ```
|
||||
*/
|
||||
findPatterns(query_embedding: Float32Array, k: number): any;
|
||||
/**
|
||||
* End the trajectory and submit for learning
|
||||
*
|
||||
* # Arguments
|
||||
* * `trajectory_id` - ID returned from start_trajectory
|
||||
* * `final_score` - Overall trajectory quality [0.0, 1.0]
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* engine.end_trajectory(trajectoryId, 0.85);
|
||||
* ```
|
||||
*/
|
||||
endTrajectory(trajectory_id: bigint, final_score: number): void;
|
||||
/**
|
||||
* Apply LoRA transformation to specific layer
|
||||
*
|
||||
* # Arguments
|
||||
* * `layer_idx` - Layer index
|
||||
* * `input` - Input vector as Float32Array
|
||||
*
|
||||
* # Returns
|
||||
* Transformed vector as Float32Array
|
||||
*/
|
||||
applyLoraLayer(layer_idx: number, input: Float32Array): Float32Array;
|
||||
/**
|
||||
* Start recording a new trajectory
|
||||
*
|
||||
* # Arguments
|
||||
* * `query_embedding` - Query vector as Float32Array
|
||||
*
|
||||
* # Returns
|
||||
* Trajectory ID (u64)
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* const embedding = new Float32Array(256).fill(0.1);
|
||||
* const trajectoryId = engine.start_trajectory(embedding);
|
||||
* ```
|
||||
*/
|
||||
startTrajectory(query_embedding: Float32Array): bigint;
|
||||
/**
|
||||
* Run instant learning cycle
|
||||
*
|
||||
* Flushes accumulated micro-LoRA updates
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* engine.run_instant_cycle();
|
||||
* ```
|
||||
*/
|
||||
runInstantCycle(): void;
|
||||
/**
|
||||
* Apply learning from user feedback
|
||||
*
|
||||
* # Arguments
|
||||
* * `success` - Whether the operation succeeded
|
||||
* * `latency_ms` - Operation latency in milliseconds
|
||||
* * `quality` - User-perceived quality [0.0, 1.0]
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* engine.learn_from_feedback(true, 50.0, 0.9);
|
||||
* ```
|
||||
*/
|
||||
learnFromFeedback(success: boolean, latency_ms: number, quality: number): void;
|
||||
/**
|
||||
* Create a new SONA engine with specified hidden dimension
|
||||
*
|
||||
* # Arguments
|
||||
* * `hidden_dim` - Size of hidden layer (typically 256, 512, or 1024)
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* const engine = new WasmSonaEngine(256);
|
||||
* ```
|
||||
*/
|
||||
constructor(hidden_dim: number);
|
||||
/**
|
||||
* Try to run background learning cycle
|
||||
*
|
||||
* Returns true if cycle was executed, false if not due yet
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* if (engine.tick()) {
|
||||
* console.log('Background learning completed');
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
tick(): boolean;
|
||||
/**
|
||||
* Get engine statistics
|
||||
*
|
||||
* # Returns
|
||||
* Statistics as JSON object
|
||||
*
|
||||
* # Example
|
||||
* ```javascript
|
||||
* const stats = engine.get_stats();
|
||||
* console.log('Trajectories buffered:', stats.trajectories_buffered);
|
||||
* console.log('Patterns learned:', stats.patterns_learned);
|
||||
* ```
|
||||
*/
|
||||
getStats(): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize WASM module (called automatically)
|
||||
*/
|
||||
export function wasm_init(): void;
|
||||
|
||||
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
||||
|
||||
export interface InitOutput {
|
||||
readonly memory: WebAssembly.Memory;
|
||||
readonly __wbg_wasmephemeralagent_free: (a: number, b: number) => void;
|
||||
readonly __wbg_wasmfederatedcoordinator_free: (a: number, b: number) => void;
|
||||
readonly __wbg_wasmsonaengine_free: (a: number, b: number) => void;
|
||||
readonly wasmephemeralagent_averageQuality: (a: number) => number;
|
||||
readonly wasmephemeralagent_clear: (a: number) => void;
|
||||
readonly wasmephemeralagent_exportState: (a: number) => number;
|
||||
readonly wasmephemeralagent_forceLearn: (a: number, b: number) => void;
|
||||
readonly wasmephemeralagent_getPatterns: (a: number) => number;
|
||||
readonly wasmephemeralagent_getStats: (a: number) => number;
|
||||
readonly wasmephemeralagent_new: (a: number, b: number, c: number) => void;
|
||||
readonly wasmephemeralagent_processTask: (a: number, b: number, c: number, d: number) => void;
|
||||
readonly wasmephemeralagent_processTaskWithRoute: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
||||
readonly wasmephemeralagent_trajectoryCount: (a: number) => number;
|
||||
readonly wasmephemeralagent_uptimeSeconds: (a: number) => bigint;
|
||||
readonly wasmephemeralagent_withConfig: (a: number, b: number, c: number, d: number) => void;
|
||||
readonly wasmfederatedcoordinator_agentCount: (a: number) => number;
|
||||
readonly wasmfederatedcoordinator_aggregate: (a: number, b: number) => number;
|
||||
readonly wasmfederatedcoordinator_applyLora: (a: number, b: number, c: number, d: number) => void;
|
||||
readonly wasmfederatedcoordinator_clear: (a: number) => void;
|
||||
readonly wasmfederatedcoordinator_consolidate: (a: number, b: number) => void;
|
||||
readonly wasmfederatedcoordinator_findPatterns: (a: number, b: number, c: number, d: number) => number;
|
||||
readonly wasmfederatedcoordinator_getPatterns: (a: number) => number;
|
||||
readonly wasmfederatedcoordinator_getStats: (a: number) => number;
|
||||
readonly wasmfederatedcoordinator_new: (a: number, b: number, c: number) => void;
|
||||
readonly wasmfederatedcoordinator_setQualityThreshold: (a: number, b: number) => void;
|
||||
readonly wasmfederatedcoordinator_totalTrajectories: (a: number) => number;
|
||||
readonly wasmfederatedcoordinator_withConfig: (a: number, b: number, c: number, d: number) => void;
|
||||
readonly wasmsonaengine_applyLora: (a: number, b: number, c: number, d: number) => void;
|
||||
readonly wasmsonaengine_applyLoraLayer: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
readonly wasmsonaengine_endTrajectory: (a: number, b: bigint, c: number) => void;
|
||||
readonly wasmsonaengine_findPatterns: (a: number, b: number, c: number, d: number) => number;
|
||||
readonly wasmsonaengine_forceLearn: (a: number, b: number) => void;
|
||||
readonly wasmsonaengine_getConfig: (a: number) => number;
|
||||
readonly wasmsonaengine_getStats: (a: number) => number;
|
||||
readonly wasmsonaengine_isEnabled: (a: number) => number;
|
||||
readonly wasmsonaengine_learnFromFeedback: (a: number, b: number, c: number, d: number) => void;
|
||||
readonly wasmsonaengine_new: (a: number, b: number) => void;
|
||||
readonly wasmsonaengine_recordStep: (a: number, b: bigint, c: number, d: number, e: bigint) => void;
|
||||
readonly wasmsonaengine_runInstantCycle: (a: number) => void;
|
||||
readonly wasmsonaengine_setEnabled: (a: number, b: number) => void;
|
||||
readonly wasmsonaengine_startTrajectory: (a: number, b: number, c: number) => bigint;
|
||||
readonly wasmsonaengine_tick: (a: number) => number;
|
||||
readonly wasmsonaengine_withConfig: (a: number, b: number) => void;
|
||||
readonly wasm_init: () => void;
|
||||
readonly __wbindgen_export: (a: number, b: number) => number;
|
||||
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
||||
readonly __wbindgen_export3: (a: number) => void;
|
||||
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
||||
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
||||
readonly __wbindgen_start: () => void;
|
||||
}
|
||||
|
||||
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
||||
|
||||
/**
|
||||
* Instantiates the given `module`, which can either be bytes or
|
||||
* a precompiled `WebAssembly.Module`.
|
||||
*
|
||||
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
||||
*
|
||||
* @returns {InitOutput}
|
||||
*/
|
||||
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
||||
|
||||
/**
|
||||
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
||||
* for everything else, calls `WebAssembly.instantiate` directly.
|
||||
*
|
||||
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
||||
*
|
||||
* @returns {Promise<InitOutput>}
|
||||
*/
|
||||
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
||||
1290
vendor/ruvector/examples/edge-full/pkg/sona/ruvector_sona.js
vendored
Normal file
1290
vendor/ruvector/examples/edge-full/pkg/sona/ruvector_sona.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
vendor/ruvector/examples/edge-full/pkg/sona/ruvector_sona_bg.wasm
vendored
Normal file
BIN
vendor/ruvector/examples/edge-full/pkg/sona/ruvector_sona_bg.wasm
vendored
Normal file
Binary file not shown.
53
vendor/ruvector/examples/edge-full/pkg/sona/ruvector_sona_bg.wasm.d.ts
vendored
Normal file
53
vendor/ruvector/examples/edge-full/pkg/sona/ruvector_sona_bg.wasm.d.ts
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const memory: WebAssembly.Memory;
|
||||
export const __wbg_wasmephemeralagent_free: (a: number, b: number) => void;
|
||||
export const __wbg_wasmfederatedcoordinator_free: (a: number, b: number) => void;
|
||||
export const __wbg_wasmsonaengine_free: (a: number, b: number) => void;
|
||||
export const wasmephemeralagent_averageQuality: (a: number) => number;
|
||||
export const wasmephemeralagent_clear: (a: number) => void;
|
||||
export const wasmephemeralagent_exportState: (a: number) => number;
|
||||
export const wasmephemeralagent_forceLearn: (a: number, b: number) => void;
|
||||
export const wasmephemeralagent_getPatterns: (a: number) => number;
|
||||
export const wasmephemeralagent_getStats: (a: number) => number;
|
||||
export const wasmephemeralagent_new: (a: number, b: number, c: number) => void;
|
||||
export const wasmephemeralagent_processTask: (a: number, b: number, c: number, d: number) => void;
|
||||
export const wasmephemeralagent_processTaskWithRoute: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
||||
export const wasmephemeralagent_trajectoryCount: (a: number) => number;
|
||||
export const wasmephemeralagent_uptimeSeconds: (a: number) => bigint;
|
||||
export const wasmephemeralagent_withConfig: (a: number, b: number, c: number, d: number) => void;
|
||||
export const wasmfederatedcoordinator_agentCount: (a: number) => number;
|
||||
export const wasmfederatedcoordinator_aggregate: (a: number, b: number) => number;
|
||||
export const wasmfederatedcoordinator_applyLora: (a: number, b: number, c: number, d: number) => void;
|
||||
export const wasmfederatedcoordinator_clear: (a: number) => void;
|
||||
export const wasmfederatedcoordinator_consolidate: (a: number, b: number) => void;
|
||||
export const wasmfederatedcoordinator_findPatterns: (a: number, b: number, c: number, d: number) => number;
|
||||
export const wasmfederatedcoordinator_getPatterns: (a: number) => number;
|
||||
export const wasmfederatedcoordinator_getStats: (a: number) => number;
|
||||
export const wasmfederatedcoordinator_new: (a: number, b: number, c: number) => void;
|
||||
export const wasmfederatedcoordinator_setQualityThreshold: (a: number, b: number) => void;
|
||||
export const wasmfederatedcoordinator_totalTrajectories: (a: number) => number;
|
||||
export const wasmfederatedcoordinator_withConfig: (a: number, b: number, c: number, d: number) => void;
|
||||
export const wasmsonaengine_applyLora: (a: number, b: number, c: number, d: number) => void;
|
||||
export const wasmsonaengine_applyLoraLayer: (a: number, b: number, c: number, d: number, e: number) => void;
|
||||
export const wasmsonaengine_endTrajectory: (a: number, b: bigint, c: number) => void;
|
||||
export const wasmsonaengine_findPatterns: (a: number, b: number, c: number, d: number) => number;
|
||||
export const wasmsonaengine_forceLearn: (a: number, b: number) => void;
|
||||
export const wasmsonaengine_getConfig: (a: number) => number;
|
||||
export const wasmsonaengine_getStats: (a: number) => number;
|
||||
export const wasmsonaengine_isEnabled: (a: number) => number;
|
||||
export const wasmsonaengine_learnFromFeedback: (a: number, b: number, c: number, d: number) => void;
|
||||
export const wasmsonaengine_new: (a: number, b: number) => void;
|
||||
export const wasmsonaengine_recordStep: (a: number, b: bigint, c: number, d: number, e: bigint) => void;
|
||||
export const wasmsonaengine_runInstantCycle: (a: number) => void;
|
||||
export const wasmsonaengine_setEnabled: (a: number, b: number) => void;
|
||||
export const wasmsonaengine_startTrajectory: (a: number, b: number, c: number) => bigint;
|
||||
export const wasmsonaengine_tick: (a: number) => number;
|
||||
export const wasmsonaengine_withConfig: (a: number, b: number) => void;
|
||||
export const wasm_init: () => void;
|
||||
export const __wbindgen_export: (a: number, b: number) => number;
|
||||
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
||||
export const __wbindgen_export3: (a: number) => void;
|
||||
export const __wbindgen_export4: (a: number, b: number, c: number) => void;
|
||||
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
||||
export const __wbindgen_start: () => void;
|
||||
Reference in New Issue
Block a user