@ruvector/edge-full 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +390 -0
- package/dag/ruvector_dag_wasm.d.ts +105 -0
- package/dag/ruvector_dag_wasm.js +466 -0
- package/dag/ruvector_dag_wasm_bg.wasm +0 -0
- package/dag/ruvector_dag_wasm_bg.wasm.d.ts +20 -0
- package/edge/ruvector_edge.d.ts +351 -0
- package/edge/ruvector_edge.js +1452 -0
- package/edge/ruvector_edge_bg.wasm +0 -0
- package/edge/ruvector_edge_bg.wasm.d.ts +71 -0
- package/generator.html +2009 -0
- package/graph/ruvector_graph_wasm.d.ts +380 -0
- package/graph/ruvector_graph_wasm.js +1787 -0
- package/graph/ruvector_graph_wasm_bg.wasm +0 -0
- package/graph/ruvector_graph_wasm_bg.wasm.d.ts +80 -0
- package/index.d.ts +64 -0
- package/index.js +182 -0
- package/onnx/ruvector_onnx_embeddings_wasm.d.ts +112 -0
- package/onnx/ruvector_onnx_embeddings_wasm.js +635 -0
- package/onnx/ruvector_onnx_embeddings_wasm_bg.js +629 -0
- package/onnx/ruvector_onnx_embeddings_wasm_bg.wasm +0 -0
- package/onnx/ruvector_onnx_embeddings_wasm_bg.wasm.d.ts +29 -0
- package/package.json +86 -0
- package/rvlite/rvlite.d.ts +556 -0
- package/rvlite/rvlite.js +2366 -0
- package/rvlite/rvlite_bg.wasm +0 -0
- package/rvlite/rvlite_bg.wasm.d.ts +128 -0
- package/sona/ruvector_sona.d.ts +513 -0
- package/sona/ruvector_sona.js +1290 -0
- package/sona/ruvector_sona_bg.wasm +0 -0
- package/sona/ruvector_sona_bg.wasm.d.ts +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 rUv
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
# @ruvector/edge-full
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@ruvector/edge-full)
|
|
4
|
+
[](https://www.rust-lang.org/)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[]()
|
|
7
|
+
|
|
8
|
+
## The Complete Edge AI Toolkit
|
|
9
|
+
|
|
10
|
+
**Run AI agent swarms, graph databases, neural networks, workflow engines, and ONNX inference - all in the browser, all for free.**
|
|
11
|
+
|
|
12
|
+
@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.
|
|
13
|
+
|
|
14
|
+
### What's Inside
|
|
15
|
+
|
|
16
|
+
| Module | Size | What It Does |
|
|
17
|
+
|--------|------|--------------|
|
|
18
|
+
| **Edge Core** | 364KB | Cryptographic identity (Ed25519), AES-256-GCM encryption, HNSW vector search, Raft consensus, spiking neural networks, post-quantum signatures |
|
|
19
|
+
| **Graph DB** | 288KB | Neo4j-style graph database with Cypher query language, relationship modeling, traversal algorithms |
|
|
20
|
+
| **RVLite** | 260KB | Multi-query vector database supporting SQL, SPARQL, and Cypher - semantic search with familiar syntax |
|
|
21
|
+
| **SONA** | 238KB | Self-Optimizing Neural Architecture - LoRA fine-tuning, EWC++, ReasoningBank for adaptive learning |
|
|
22
|
+
| **DAG** | 132KB | Directed acyclic graph engine for workflow orchestration, dependency resolution, topological execution |
|
|
23
|
+
| **ONNX** | 7.1MB | Full ONNX inference engine with 6 pre-trained HuggingFace embedding models, parallel worker support |
|
|
24
|
+
|
|
25
|
+
**Total: 1.28MB core + 7.1MB optional ONNX = 8.4MB complete**
|
|
26
|
+
|
|
27
|
+
### Why Use This?
|
|
28
|
+
|
|
29
|
+
- **Zero Infrastructure Cost**: Everything runs in the browser. No servers, no API keys, no monthly bills.
|
|
30
|
+
- **Complete Feature Set**: Vector search + graph database + neural networks + workflow engine + embeddings. All in one package.
|
|
31
|
+
- **True P2P**: Agents communicate directly via WebRTC, GUN.js, libp2p, or Nostr. No central server required.
|
|
32
|
+
- **Self-Learning**: SONA provides continuous improvement through LoRA fine-tuning and experience replay.
|
|
33
|
+
- **Production-Ready**: Post-quantum cryptography, Byzantine fault tolerance, encrypted communication.
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install @ruvector/edge-full
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Initialize All Modules
|
|
42
|
+
|
|
43
|
+
```javascript
|
|
44
|
+
import { initAll } from '@ruvector/edge-full';
|
|
45
|
+
|
|
46
|
+
// Initialize all core modules (excludes ONNX for faster startup)
|
|
47
|
+
const { edge, graph, rvlite, sona, dag } = await initAll();
|
|
48
|
+
|
|
49
|
+
// Create agent identity
|
|
50
|
+
const identity = new edge.WasmIdentity.generate();
|
|
51
|
+
console.log(`Agent: ${identity.agent_id()}`);
|
|
52
|
+
|
|
53
|
+
// Build a knowledge graph
|
|
54
|
+
const graphStore = new graph.WasmGraphStore();
|
|
55
|
+
graphStore.run_cypher("CREATE (a:Agent {id: 'agent-1', type: 'researcher'})");
|
|
56
|
+
|
|
57
|
+
// Vector search with SQL
|
|
58
|
+
const db = new rvlite.Database();
|
|
59
|
+
db.execute("CREATE TABLE memories (id TEXT, embedding BLOB)");
|
|
60
|
+
|
|
61
|
+
// Self-learning neural routing
|
|
62
|
+
const sonaEngine = new sona.SonaEngine();
|
|
63
|
+
sonaEngine.route_request({ task: "analyze code", context: "rust" });
|
|
64
|
+
|
|
65
|
+
// Workflow orchestration
|
|
66
|
+
const workflow = new dag.Dag();
|
|
67
|
+
workflow.add_node("fetch");
|
|
68
|
+
workflow.add_node("process");
|
|
69
|
+
workflow.add_edge("fetch", "process");
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Selective Module Loading
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
75
|
+
import { initModules } from '@ruvector/edge-full';
|
|
76
|
+
|
|
77
|
+
// Only load what you need
|
|
78
|
+
const { edge, graph } = await initModules(['edge', 'graph']);
|
|
79
|
+
|
|
80
|
+
// Or import modules directly
|
|
81
|
+
import init from '@ruvector/edge-full/edge';
|
|
82
|
+
import graphInit, { WasmGraphStore } from '@ruvector/edge-full/graph';
|
|
83
|
+
|
|
84
|
+
await init();
|
|
85
|
+
await graphInit();
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Add ONNX Embeddings
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
import onnxInit, { WasmEmbedder } from '@ruvector/edge-full/onnx';
|
|
92
|
+
|
|
93
|
+
await onnxInit();
|
|
94
|
+
|
|
95
|
+
const embedder = new WasmEmbedder();
|
|
96
|
+
await embedder.load_model('all-MiniLM-L6-v2'); // 384-dimensional embeddings
|
|
97
|
+
|
|
98
|
+
const embedding = await embedder.embed("The quick brown fox");
|
|
99
|
+
console.log(`Dimensions: ${embedding.length}`); // 384
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Module Deep Dive
|
|
103
|
+
|
|
104
|
+
### Edge Core - Cryptographic Foundation
|
|
105
|
+
|
|
106
|
+
```javascript
|
|
107
|
+
import init, {
|
|
108
|
+
WasmIdentity, // Ed25519 key pairs
|
|
109
|
+
WasmCrypto, // AES-256-GCM encryption
|
|
110
|
+
WasmHnswIndex, // 150x faster vector search
|
|
111
|
+
WasmRaftNode, // Distributed consensus
|
|
112
|
+
WasmHybridKeyPair, // Post-quantum signatures
|
|
113
|
+
WasmSpikingNetwork // Bio-inspired neural nets
|
|
114
|
+
} from '@ruvector/edge-full/edge';
|
|
115
|
+
|
|
116
|
+
await init();
|
|
117
|
+
|
|
118
|
+
// Create cryptographic identity
|
|
119
|
+
const identity = WasmIdentity.generate();
|
|
120
|
+
const signature = identity.sign(new TextEncoder().encode("hello"));
|
|
121
|
+
const verified = identity.verify(new TextEncoder().encode("hello"), signature);
|
|
122
|
+
|
|
123
|
+
// Encrypted communication
|
|
124
|
+
const crypto = new WasmCrypto();
|
|
125
|
+
const encrypted = crypto.encrypt(data, key, nonce);
|
|
126
|
+
|
|
127
|
+
// HNSW vector index (150x faster than brute force)
|
|
128
|
+
const index = new WasmHnswIndex(384, 16, 200); // dimensions, M, ef_construction
|
|
129
|
+
index.add(0, embedding1);
|
|
130
|
+
index.add(1, embedding2);
|
|
131
|
+
const neighbors = index.search(queryVector, 10); // top 10 results
|
|
132
|
+
|
|
133
|
+
// Raft consensus for distributed state
|
|
134
|
+
const node = new WasmRaftNode('node-1', ['node-1', 'node-2', 'node-3']);
|
|
135
|
+
node.start_election();
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Graph DB - Neo4j in the Browser
|
|
139
|
+
|
|
140
|
+
```javascript
|
|
141
|
+
import graphInit, { WasmGraphStore } from '@ruvector/edge-full/graph';
|
|
142
|
+
|
|
143
|
+
await graphInit();
|
|
144
|
+
|
|
145
|
+
const store = new WasmGraphStore();
|
|
146
|
+
|
|
147
|
+
// Create nodes and relationships
|
|
148
|
+
store.run_cypher(`
|
|
149
|
+
CREATE (alice:Person {name: 'Alice', role: 'researcher'})
|
|
150
|
+
CREATE (bob:Person {name: 'Bob', role: 'developer'})
|
|
151
|
+
CREATE (alice)-[:COLLABORATES_WITH]->(bob)
|
|
152
|
+
`);
|
|
153
|
+
|
|
154
|
+
// Query the graph
|
|
155
|
+
const results = store.run_cypher(`
|
|
156
|
+
MATCH (p:Person)-[:COLLABORATES_WITH]->(colleague)
|
|
157
|
+
RETURN p.name, colleague.name
|
|
158
|
+
`);
|
|
159
|
+
|
|
160
|
+
// Complex traversals
|
|
161
|
+
const paths = store.run_cypher(`
|
|
162
|
+
MATCH path = (start:Person)-[:KNOWS*1..3]->(end:Person)
|
|
163
|
+
WHERE start.name = 'Alice'
|
|
164
|
+
RETURN path
|
|
165
|
+
`);
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### RVLite - SQL + SPARQL + Cypher Vector DB
|
|
169
|
+
|
|
170
|
+
```javascript
|
|
171
|
+
import rvliteInit, { Database } from '@ruvector/edge-full/rvlite';
|
|
172
|
+
|
|
173
|
+
await rvliteInit();
|
|
174
|
+
|
|
175
|
+
const db = new Database();
|
|
176
|
+
|
|
177
|
+
// SQL for familiar operations
|
|
178
|
+
db.execute(`
|
|
179
|
+
CREATE TABLE documents (
|
|
180
|
+
id TEXT PRIMARY KEY,
|
|
181
|
+
content TEXT,
|
|
182
|
+
embedding BLOB
|
|
183
|
+
)
|
|
184
|
+
`);
|
|
185
|
+
|
|
186
|
+
db.execute(`INSERT INTO documents VALUES (?, ?, ?)`,
|
|
187
|
+
['doc-1', 'Machine learning basics', embedding1]);
|
|
188
|
+
|
|
189
|
+
// Semantic search
|
|
190
|
+
const similar = db.execute(`
|
|
191
|
+
SELECT * FROM documents
|
|
192
|
+
ORDER BY vector_distance(embedding, ?)
|
|
193
|
+
LIMIT 5
|
|
194
|
+
`, [queryEmbedding]);
|
|
195
|
+
|
|
196
|
+
// SPARQL for knowledge graphs
|
|
197
|
+
const sparqlResults = db.sparql(`
|
|
198
|
+
PREFIX ex: <http://example.org/>
|
|
199
|
+
SELECT ?name ?type
|
|
200
|
+
WHERE {
|
|
201
|
+
?entity ex:type ?type .
|
|
202
|
+
?entity ex:name ?name .
|
|
203
|
+
FILTER (?type = "Agent")
|
|
204
|
+
}
|
|
205
|
+
`);
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### SONA - Self-Learning Neural Router
|
|
209
|
+
|
|
210
|
+
```javascript
|
|
211
|
+
import sonaInit, { SonaEngine, ReasoningBank } from '@ruvector/edge-full/sona';
|
|
212
|
+
|
|
213
|
+
await sonaInit();
|
|
214
|
+
|
|
215
|
+
const engine = new SonaEngine();
|
|
216
|
+
const reasoningBank = new ReasoningBank();
|
|
217
|
+
|
|
218
|
+
// Route tasks to best agent
|
|
219
|
+
const decision = await engine.route_request({
|
|
220
|
+
task: "review pull request",
|
|
221
|
+
context: { language: "rust", complexity: "high" },
|
|
222
|
+
available_agents: [
|
|
223
|
+
{ id: "agent-1", capabilities: ["rust", "code-review"] },
|
|
224
|
+
{ id: "agent-2", capabilities: ["testing", "qa"] }
|
|
225
|
+
]
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
console.log(`Routed to: ${decision.selected_agent}`);
|
|
229
|
+
console.log(`Confidence: ${decision.confidence}`);
|
|
230
|
+
|
|
231
|
+
// Learn from outcomes
|
|
232
|
+
reasoningBank.record_trajectory({
|
|
233
|
+
state: "review pull request",
|
|
234
|
+
action: decision.selected_agent,
|
|
235
|
+
reward: 0.95, // positive outcome
|
|
236
|
+
timestamp: Date.now()
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// Apply LoRA fine-tuning
|
|
240
|
+
await engine.apply_lora_update({
|
|
241
|
+
positive_examples: ["rust expert handled rust code well"],
|
|
242
|
+
negative_examples: []
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### DAG - Workflow Orchestration
|
|
247
|
+
|
|
248
|
+
```javascript
|
|
249
|
+
import dagInit, { Dag } from '@ruvector/edge-full/dag';
|
|
250
|
+
|
|
251
|
+
await dagInit();
|
|
252
|
+
|
|
253
|
+
const workflow = new Dag();
|
|
254
|
+
|
|
255
|
+
// Define workflow steps
|
|
256
|
+
workflow.add_node("fetch_data");
|
|
257
|
+
workflow.add_node("validate");
|
|
258
|
+
workflow.add_node("transform");
|
|
259
|
+
workflow.add_node("store");
|
|
260
|
+
|
|
261
|
+
// Define dependencies
|
|
262
|
+
workflow.add_edge("fetch_data", "validate");
|
|
263
|
+
workflow.add_edge("validate", "transform");
|
|
264
|
+
workflow.add_edge("transform", "store");
|
|
265
|
+
|
|
266
|
+
// Get execution order
|
|
267
|
+
const order = workflow.topological_sort();
|
|
268
|
+
console.log(order); // ["fetch_data", "validate", "transform", "store"]
|
|
269
|
+
|
|
270
|
+
// Check for cycles
|
|
271
|
+
if (workflow.has_cycle()) {
|
|
272
|
+
console.error("Invalid workflow!");
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Get dependencies for a node
|
|
276
|
+
const deps = workflow.get_dependencies("transform");
|
|
277
|
+
console.log(deps); // ["validate"]
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### ONNX - HuggingFace Embeddings
|
|
281
|
+
|
|
282
|
+
```javascript
|
|
283
|
+
import onnxInit, { WasmEmbedder } from '@ruvector/edge-full/onnx';
|
|
284
|
+
|
|
285
|
+
await onnxInit();
|
|
286
|
+
|
|
287
|
+
const embedder = new WasmEmbedder();
|
|
288
|
+
|
|
289
|
+
// Available models:
|
|
290
|
+
// - all-MiniLM-L6-v2 (384D, fastest)
|
|
291
|
+
// - all-MiniLM-L12-v2 (384D, better quality)
|
|
292
|
+
// - bge-small-en-v1.5 (384D, SOTA)
|
|
293
|
+
// - bge-base-en-v1.5 (768D, highest quality)
|
|
294
|
+
// - e5-small-v2 (384D, search/retrieval)
|
|
295
|
+
// - gte-small (384D, multilingual)
|
|
296
|
+
|
|
297
|
+
await embedder.load_model('bge-small-en-v1.5');
|
|
298
|
+
|
|
299
|
+
// Single embedding
|
|
300
|
+
const embedding = await embedder.embed("What is machine learning?");
|
|
301
|
+
|
|
302
|
+
// Batch processing (3.8x faster with parallel workers)
|
|
303
|
+
const embeddings = await embedder.embed_batch([
|
|
304
|
+
"First document about AI",
|
|
305
|
+
"Second document about ML",
|
|
306
|
+
"Third document about neural networks"
|
|
307
|
+
]);
|
|
308
|
+
|
|
309
|
+
// Compute similarity
|
|
310
|
+
function cosineSimilarity(a, b) {
|
|
311
|
+
let dot = 0, normA = 0, normB = 0;
|
|
312
|
+
for (let i = 0; i < a.length; i++) {
|
|
313
|
+
dot += a[i] * b[i];
|
|
314
|
+
normA += a[i] * a[i];
|
|
315
|
+
normB += b[i] * b[i];
|
|
316
|
+
}
|
|
317
|
+
return dot / (Math.sqrt(normA) * Math.sqrt(normB));
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const similarity = cosineSimilarity(embeddings[0], embeddings[1]);
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## Interactive Generator
|
|
324
|
+
|
|
325
|
+
The package includes an interactive HTML generator that creates ready-to-use code for any combination of:
|
|
326
|
+
|
|
327
|
+
- **6 Network Topologies**: Mesh, Star, Hierarchical, Ring, Gossip, Sharded
|
|
328
|
+
- **4 P2P Transports**: GUN.js, WebRTC, libp2p, Nostr
|
|
329
|
+
- **6 Use Cases**: AI Assistants, Data Pipeline, Gaming, IoT, Marketplace, Research
|
|
330
|
+
- **6 WASM Modules**: Edge, Graph, RVLite, SONA, DAG, ONNX
|
|
331
|
+
- **8 Core Features**: Identity, Encryption, HNSW, Semantic Match, Raft, Post-Quantum, Spiking NN, Compression
|
|
332
|
+
- **7 Exotic Patterns**: MCP Tools, Byzantine Fault, Quantum Resistant, Neural Consensus, Swarm Intelligence, Self-Healing, Emergent Behavior
|
|
333
|
+
|
|
334
|
+
Open `generator.html` in your browser to start generating code.
|
|
335
|
+
|
|
336
|
+
## Bundle Size Comparison
|
|
337
|
+
|
|
338
|
+
| Configuration | Size | Use Case |
|
|
339
|
+
|--------------|------|----------|
|
|
340
|
+
| Edge only | 364KB | Minimal crypto + vectors |
|
|
341
|
+
| Edge + Graph | 652KB | Agent relationships |
|
|
342
|
+
| Edge + RVLite | 624KB | SQL-style queries |
|
|
343
|
+
| Edge + SONA | 602KB | Self-learning routing |
|
|
344
|
+
| All Core | 1.28MB | Full capabilities |
|
|
345
|
+
| With ONNX | 8.4MB | ML embeddings |
|
|
346
|
+
|
|
347
|
+
## Free Infrastructure
|
|
348
|
+
|
|
349
|
+
All components use free public infrastructure:
|
|
350
|
+
|
|
351
|
+
| Service | Free Providers |
|
|
352
|
+
|---------|----------------|
|
|
353
|
+
| P2P Relay | GUN.js (gun-manhattan, gun-us-west) |
|
|
354
|
+
| STUN | Google, Twilio, Cloudflare |
|
|
355
|
+
| Signaling | PeerJS Cloud (free tier) |
|
|
356
|
+
| Nostr Relays | nostr.wine, relay.damus.io, nos.lol |
|
|
357
|
+
|
|
358
|
+
## Performance
|
|
359
|
+
|
|
360
|
+
| Module | Operation | Performance |
|
|
361
|
+
|--------|-----------|-------------|
|
|
362
|
+
| Edge | Ed25519 sign/verify | 50,000 ops/sec |
|
|
363
|
+
| Edge | AES-256-GCM | 1 GB/sec |
|
|
364
|
+
| Edge | HNSW search | 150x faster than brute force |
|
|
365
|
+
| Graph | Cypher query | <1ms for simple queries |
|
|
366
|
+
| RVLite | Vector search | Sub-millisecond |
|
|
367
|
+
| SONA | Route decision | <5ms |
|
|
368
|
+
| ONNX | Single embed | ~20ms (MiniLM-L6) |
|
|
369
|
+
| ONNX | Batch embed | 3.8x speedup with workers |
|
|
370
|
+
|
|
371
|
+
## Examples
|
|
372
|
+
|
|
373
|
+
See the `/examples` directory for:
|
|
374
|
+
|
|
375
|
+
- Multi-agent chat with shared memory
|
|
376
|
+
- Distributed RAG pipeline
|
|
377
|
+
- Real-time multiplayer coordination
|
|
378
|
+
- IoT sensor swarm
|
|
379
|
+
- Knowledge graph construction
|
|
380
|
+
- Workflow automation
|
|
381
|
+
|
|
382
|
+
## License
|
|
383
|
+
|
|
384
|
+
MIT License - Use freely for any purpose.
|
|
385
|
+
|
|
386
|
+
## Links
|
|
387
|
+
|
|
388
|
+
- [npm](https://www.npmjs.com/package/@ruvector/edge-full)
|
|
389
|
+
- [GitHub](https://github.com/ruvnet/ruvector)
|
|
390
|
+
- [@ruvector/edge](https://www.npmjs.com/package/@ruvector/edge) (lightweight version)
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class WasmDag {
|
|
5
|
+
free(): void;
|
|
6
|
+
[Symbol.dispose](): void;
|
|
7
|
+
/**
|
|
8
|
+
* Get number of edges
|
|
9
|
+
*/
|
|
10
|
+
edge_count(): number;
|
|
11
|
+
/**
|
|
12
|
+
* Deserialize from bytes
|
|
13
|
+
*/
|
|
14
|
+
static from_bytes(data: Uint8Array): WasmDag;
|
|
15
|
+
/**
|
|
16
|
+
* Get number of nodes
|
|
17
|
+
*/
|
|
18
|
+
node_count(): number;
|
|
19
|
+
/**
|
|
20
|
+
* Find critical path (longest path by cost)
|
|
21
|
+
* Returns JSON: {"path": [node_ids], "cost": total}
|
|
22
|
+
*/
|
|
23
|
+
critical_path(): any;
|
|
24
|
+
/**
|
|
25
|
+
* Create new empty DAG
|
|
26
|
+
*/
|
|
27
|
+
constructor();
|
|
28
|
+
/**
|
|
29
|
+
* Serialize to JSON
|
|
30
|
+
*/
|
|
31
|
+
to_json(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Add edge from -> to
|
|
34
|
+
* Returns false if creates cycle (simple check)
|
|
35
|
+
*/
|
|
36
|
+
add_edge(from: number, to: number): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Add a node with operator type and cost
|
|
39
|
+
* Returns node ID
|
|
40
|
+
*/
|
|
41
|
+
add_node(op: number, cost: number): number;
|
|
42
|
+
/**
|
|
43
|
+
* Serialize to bytes (bincode format)
|
|
44
|
+
*/
|
|
45
|
+
to_bytes(): Uint8Array;
|
|
46
|
+
/**
|
|
47
|
+
* Compute attention scores for nodes
|
|
48
|
+
* mechanism: 0=topological, 1=critical_path, 2=uniform
|
|
49
|
+
*/
|
|
50
|
+
attention(mechanism: number): Float32Array;
|
|
51
|
+
/**
|
|
52
|
+
* Deserialize from JSON
|
|
53
|
+
*/
|
|
54
|
+
static from_json(json: string): WasmDag;
|
|
55
|
+
/**
|
|
56
|
+
* Topological sort using Kahn's algorithm
|
|
57
|
+
* Returns node IDs in topological order
|
|
58
|
+
*/
|
|
59
|
+
topo_sort(): Uint32Array;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
63
|
+
|
|
64
|
+
export interface InitOutput {
|
|
65
|
+
readonly memory: WebAssembly.Memory;
|
|
66
|
+
readonly __wbg_wasmdag_free: (a: number, b: number) => void;
|
|
67
|
+
readonly wasmdag_add_edge: (a: number, b: number, c: number) => number;
|
|
68
|
+
readonly wasmdag_add_node: (a: number, b: number, c: number) => number;
|
|
69
|
+
readonly wasmdag_attention: (a: number, b: number, c: number) => void;
|
|
70
|
+
readonly wasmdag_critical_path: (a: number) => number;
|
|
71
|
+
readonly wasmdag_edge_count: (a: number) => number;
|
|
72
|
+
readonly wasmdag_from_bytes: (a: number, b: number, c: number) => void;
|
|
73
|
+
readonly wasmdag_from_json: (a: number, b: number, c: number) => void;
|
|
74
|
+
readonly wasmdag_new: () => number;
|
|
75
|
+
readonly wasmdag_node_count: (a: number) => number;
|
|
76
|
+
readonly wasmdag_to_bytes: (a: number, b: number) => void;
|
|
77
|
+
readonly wasmdag_to_json: (a: number, b: number) => void;
|
|
78
|
+
readonly wasmdag_topo_sort: (a: number, b: number) => void;
|
|
79
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
80
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
81
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number) => void;
|
|
82
|
+
readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
89
|
+
* a precompiled `WebAssembly.Module`.
|
|
90
|
+
*
|
|
91
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
92
|
+
*
|
|
93
|
+
* @returns {InitOutput}
|
|
94
|
+
*/
|
|
95
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
99
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
100
|
+
*
|
|
101
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
102
|
+
*
|
|
103
|
+
* @returns {Promise<InitOutput>}
|
|
104
|
+
*/
|
|
105
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|