@ruvector/edge-net 0.1.1 → 0.1.3
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/README.md +279 -0
- package/agents.js +965 -0
- package/cli.js +17 -0
- package/join.html +985 -0
- package/join.js +1333 -0
- package/network.js +820 -0
- package/networks.js +817 -0
- package/package.json +33 -5
- package/webrtc.js +964 -0
package/README.md
CHANGED
|
@@ -29,12 +29,14 @@ A distributed computing platform that enables collective resource sharing for AI
|
|
|
29
29
|
|
|
30
30
|
## Table of Contents
|
|
31
31
|
|
|
32
|
+
- [WebRTC P2P Networking](#webrtc-p2p-networking)
|
|
32
33
|
- [What is Edge-Net?](#what-is-edge-net)
|
|
33
34
|
- [Key Features](#key-features)
|
|
34
35
|
- [Quick Start](#quick-start)
|
|
35
36
|
- [How It Works](#how-it-works)
|
|
36
37
|
- [AI Computing Tasks](#ai-computing-tasks)
|
|
37
38
|
- [Pi-Key Identity System](#pi-key-identity-system)
|
|
39
|
+
- [Security Architecture](#security-architecture)
|
|
38
40
|
- [Self-Optimization](#self-optimization)
|
|
39
41
|
- [Tutorials](#tutorials)
|
|
40
42
|
- [API Reference](#api-reference)
|
|
@@ -42,6 +44,124 @@ A distributed computing platform that enables collective resource sharing for AI
|
|
|
42
44
|
- [Exotic AI Capabilities](#exotic-ai-capabilities)
|
|
43
45
|
- [Core Architecture & Capabilities](#core-architecture--capabilities)
|
|
44
46
|
- [Self-Learning Hooks & MCP Integration](#self-learning-hooks--mcp-integration)
|
|
47
|
+
- [Distributed AI Agents & Workers](#distributed-ai-agents--workers)
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## WebRTC P2P Networking
|
|
52
|
+
|
|
53
|
+
Edge-net implements **real WebRTC peer-to-peer connectivity** for direct browser-to-browser communication, with Google Cloud genesis nodes for global coordination.
|
|
54
|
+
|
|
55
|
+
### P2P Architecture
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
59
|
+
│ WEBRTC P2P NETWORK ARCHITECTURE │
|
|
60
|
+
├─────────────────────────────────────────────────────────────────────────────┤
|
|
61
|
+
│ │
|
|
62
|
+
│ ┌─────────────┐ Signaling ┌─────────────┐ │
|
|
63
|
+
│ │ Browser A │◄──────────────────►│ Relay │ (WebSocket) │
|
|
64
|
+
│ │ (Node 1) │ offer/answer │ Server │ │
|
|
65
|
+
│ └──────┬──────┘ ICE candidates └─────────────┘ │
|
|
66
|
+
│ │ │
|
|
67
|
+
│ │ WebRTC Data Channel (DTLS encrypted, direct P2P) │
|
|
68
|
+
│ │ │
|
|
69
|
+
│ ▼ │
|
|
70
|
+
│ ┌─────────────┐ ┌─────────────┐ │
|
|
71
|
+
│ │ Browser B │◄──────────────────►│ Browser C │ │
|
|
72
|
+
│ │ (Node 2) │ Direct P2P │ (Node 3) │ │
|
|
73
|
+
│ └─────────────┘ └─────────────┘ │
|
|
74
|
+
│ │
|
|
75
|
+
│ Genesis Nodes (Google Cloud): │
|
|
76
|
+
│ • us-central1 • europe-west1 • asia-east1 │
|
|
77
|
+
│ │
|
|
78
|
+
└─────────────────────────────────────────────────────────────────────────────┘
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### WebRTC Features
|
|
82
|
+
|
|
83
|
+
| Feature | Description |
|
|
84
|
+
|---------|-------------|
|
|
85
|
+
| **Real P2P Data Channels** | Direct browser-to-browser communication |
|
|
86
|
+
| **ICE/STUN/TURN** | NAT traversal with Google STUN servers |
|
|
87
|
+
| **DTLS Encryption** | End-to-end encrypted data channels |
|
|
88
|
+
| **WebSocket Signaling** | Relay server for connection establishment |
|
|
89
|
+
| **Automatic Reconnection** | Self-healing connections with exponential backoff |
|
|
90
|
+
| **Heartbeat Monitoring** | Connection health with 5s heartbeat |
|
|
91
|
+
| **Connection Quality Metrics** | Latency, throughput, packet loss tracking |
|
|
92
|
+
| **Fallback Simulation** | Offline mode when signaling unavailable |
|
|
93
|
+
|
|
94
|
+
### Genesis Nodes (Google Cloud)
|
|
95
|
+
|
|
96
|
+
| Region | Host | Purpose |
|
|
97
|
+
|--------|------|---------|
|
|
98
|
+
| **us-central1** | edge-net-genesis-us.ruvector.dev | Americas coordination |
|
|
99
|
+
| **europe-west1** | edge-net-genesis-eu.ruvector.dev | EMEA coordination |
|
|
100
|
+
| **asia-east1** | edge-net-genesis-asia.ruvector.dev | APAC coordination |
|
|
101
|
+
|
|
102
|
+
### WebRTC Security
|
|
103
|
+
|
|
104
|
+
| Security Feature | Implementation |
|
|
105
|
+
|-----------------|----------------|
|
|
106
|
+
| **DTLS 1.2+** | Data channel encryption |
|
|
107
|
+
| **SCTP** | Reliable ordered delivery |
|
|
108
|
+
| **Origin Validation** | CORS whitelist for browser connections |
|
|
109
|
+
| **Rate Limiting** | 100 msg/min per node |
|
|
110
|
+
| **Message Size Limits** | 64KB max message size |
|
|
111
|
+
| **Connection Limits** | 5 connections per IP |
|
|
112
|
+
| **Heartbeat Timeout** | 30s stale connection cleanup |
|
|
113
|
+
| **SDP Sanitization** | Prevent injection attacks |
|
|
114
|
+
|
|
115
|
+
### Relay Server
|
|
116
|
+
|
|
117
|
+
The relay server (`relay/index.js`) handles:
|
|
118
|
+
|
|
119
|
+
```javascript
|
|
120
|
+
// WebRTC signaling message types
|
|
121
|
+
'webrtc_offer' // Relay SDP offer to target peer
|
|
122
|
+
'webrtc_answer' // Relay SDP answer back
|
|
123
|
+
'webrtc_ice' // Relay ICE candidates
|
|
124
|
+
'webrtc_disconnect' // Notify peer of disconnection
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Testing & Benchmarks
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
cd examples/edge-net/relay
|
|
131
|
+
npm install
|
|
132
|
+
node index.js &
|
|
133
|
+
|
|
134
|
+
cd ../test
|
|
135
|
+
npm install
|
|
136
|
+
|
|
137
|
+
# Run P2P connectivity test
|
|
138
|
+
npm test
|
|
139
|
+
|
|
140
|
+
# Run security audit
|
|
141
|
+
npm run security
|
|
142
|
+
|
|
143
|
+
# Run latency benchmark
|
|
144
|
+
npm run benchmark
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Browser Integration
|
|
148
|
+
|
|
149
|
+
```javascript
|
|
150
|
+
// join.html implements real WebRTC
|
|
151
|
+
const WEBRTC_CONFIG = {
|
|
152
|
+
iceServers: [
|
|
153
|
+
{ urls: 'stun:stun.l.google.com:19302' },
|
|
154
|
+
{ urls: 'stun:stun1.l.google.com:19302' },
|
|
155
|
+
]
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// Connects to relay server
|
|
159
|
+
const RELAY_URL = 'ws://localhost:8080';
|
|
160
|
+
|
|
161
|
+
// Real peer connections via RTCPeerConnection
|
|
162
|
+
const pc = new RTCPeerConnection(WEBRTC_CONFIG);
|
|
163
|
+
const channel = pc.createDataChannel('edge-net');
|
|
164
|
+
```
|
|
45
165
|
|
|
46
166
|
---
|
|
47
167
|
|
|
@@ -1119,6 +1239,165 @@ ruvector hooks remember <content> -t <type> # Store memory
|
|
|
1119
1239
|
ruvector hooks recall <query> # Semantic search
|
|
1120
1240
|
```
|
|
1121
1241
|
|
|
1242
|
+
---
|
|
1243
|
+
|
|
1244
|
+
## Distributed AI Agents & Workers
|
|
1245
|
+
|
|
1246
|
+
Edge-net enables spawning AI agents and distributed worker pools across the collective compute network. This transforms passive compute contribution into active distributed AI execution.
|
|
1247
|
+
|
|
1248
|
+
### Architecture
|
|
1249
|
+
|
|
1250
|
+
```
|
|
1251
|
+
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
1252
|
+
│ DISTRIBUTED AI AGENT SYSTEM │
|
|
1253
|
+
├─────────────────────────────────────────────────────────────────────────────┤
|
|
1254
|
+
│ │
|
|
1255
|
+
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
|
|
1256
|
+
│ │ AgentSpawner │ │ WorkerPool │ │ TaskOrchestrator│ │
|
|
1257
|
+
│ │ │ │ │ │ │ │
|
|
1258
|
+
│ │ • Type routing │ │ • Load balance │ │ • Workflows │ │
|
|
1259
|
+
│ │ • rUv costing │ │ • Auto-scaling │ │ • Dependencies │ │
|
|
1260
|
+
│ │ • Priority mgmt │ │ • Fault tolerant│ │ • Parallel exec │ │
|
|
1261
|
+
│ └────────┬────────┘ └────────┬────────┘ └────────┬────────┘ │
|
|
1262
|
+
│ │ │ │ │
|
|
1263
|
+
│ └───────────────────────┼───────────────────────┘ │
|
|
1264
|
+
│ │ │
|
|
1265
|
+
│ ┌────────────┴────────────┐ │
|
|
1266
|
+
│ │ Edge-Net P2P Network │ │
|
|
1267
|
+
│ │ (WebRTC Data Channels) │ │
|
|
1268
|
+
│ └──────────────────────────┘ │
|
|
1269
|
+
│ │
|
|
1270
|
+
│ Agent Types: researcher | coder | reviewer | tester | analyst | │
|
|
1271
|
+
│ optimizer | coordinator | embedder │
|
|
1272
|
+
│ │
|
|
1273
|
+
└─────────────────────────────────────────────────────────────────────────────┘
|
|
1274
|
+
```
|
|
1275
|
+
|
|
1276
|
+
### Agent Types
|
|
1277
|
+
|
|
1278
|
+
| Type | Capabilities | Base rUv | Use Cases |
|
|
1279
|
+
|------|-------------|----------|-----------|
|
|
1280
|
+
| **researcher** | search, analyze, summarize, extract | 10 | Codebase analysis, documentation research |
|
|
1281
|
+
| **coder** | code, refactor, debug, test | 15 | Feature implementation, bug fixes |
|
|
1282
|
+
| **reviewer** | review, audit, validate, suggest | 12 | Code review, security audit |
|
|
1283
|
+
| **tester** | test, benchmark, validate, report | 10 | Test creation, coverage analysis |
|
|
1284
|
+
| **analyst** | analyze, metrics, report, visualize | 8 | Performance analysis, data insights |
|
|
1285
|
+
| **optimizer** | optimize, profile, benchmark, improve | 15 | Performance tuning, efficiency |
|
|
1286
|
+
| **coordinator** | orchestrate, route, schedule, monitor | 20 | Multi-agent workflows |
|
|
1287
|
+
| **embedder** | embed, vectorize, similarity, search | 5 | Vector operations, semantic search |
|
|
1288
|
+
|
|
1289
|
+
### CLI Commands
|
|
1290
|
+
|
|
1291
|
+
```bash
|
|
1292
|
+
# Show Edge-Net information
|
|
1293
|
+
ruvector edge-net info
|
|
1294
|
+
|
|
1295
|
+
# Spawn a distributed AI agent
|
|
1296
|
+
ruvector edge-net spawn researcher "Analyze the authentication system"
|
|
1297
|
+
ruvector edge-net spawn coder "Implement user profile feature" --max-ruv 50 --priority high
|
|
1298
|
+
|
|
1299
|
+
# Create and use worker pools
|
|
1300
|
+
ruvector edge-net pool create --size 10 --capabilities compute,embed
|
|
1301
|
+
ruvector edge-net pool execute "Process batch embeddings"
|
|
1302
|
+
|
|
1303
|
+
# Run multi-agent workflows
|
|
1304
|
+
ruvector edge-net workflow code-review
|
|
1305
|
+
ruvector edge-net workflow feature-dev
|
|
1306
|
+
ruvector edge-net workflow optimization
|
|
1307
|
+
|
|
1308
|
+
# Check network status
|
|
1309
|
+
ruvector edge-net status
|
|
1310
|
+
```
|
|
1311
|
+
|
|
1312
|
+
### MCP Tools
|
|
1313
|
+
|
|
1314
|
+
The following MCP tools are available when `ruvector` is configured as an MCP server:
|
|
1315
|
+
|
|
1316
|
+
| Tool | Description | Parameters |
|
|
1317
|
+
|------|-------------|------------|
|
|
1318
|
+
| `edge_net_info` | Get Edge-Net information | - |
|
|
1319
|
+
| `edge_net_spawn` | Spawn distributed agent | type, task, max_ruv, priority |
|
|
1320
|
+
| `edge_net_pool_create` | Create worker pool | min_workers, max_workers |
|
|
1321
|
+
| `edge_net_pool_execute` | Execute on pool | task, pool_id |
|
|
1322
|
+
| `edge_net_workflow` | Run workflow | name (code-review, feature-dev, etc.) |
|
|
1323
|
+
| `edge_net_status` | Network status | - |
|
|
1324
|
+
|
|
1325
|
+
### Workflows
|
|
1326
|
+
|
|
1327
|
+
Pre-built multi-agent workflows:
|
|
1328
|
+
|
|
1329
|
+
| Workflow | Steps | Est. rUv | Description |
|
|
1330
|
+
|----------|-------|----------|-------------|
|
|
1331
|
+
| **code-review** | analyst → reviewer → tester → optimizer | 45 | Comprehensive code analysis |
|
|
1332
|
+
| **feature-dev** | researcher → coder → tester → reviewer | 60 | Full feature development cycle |
|
|
1333
|
+
| **bug-fix** | analyst → coder → tester | 35 | Bug diagnosis and fix |
|
|
1334
|
+
| **optimization** | analyst → optimizer → coder → tester | 50 | Performance improvement |
|
|
1335
|
+
| **research** | researcher → analyst → embedder | 30 | Deep research with embeddings |
|
|
1336
|
+
|
|
1337
|
+
### JavaScript API
|
|
1338
|
+
|
|
1339
|
+
```javascript
|
|
1340
|
+
import { AgentSpawner, WorkerPool, TaskOrchestrator, AGENT_TYPES } from '@ruvector/edge-net/agents';
|
|
1341
|
+
|
|
1342
|
+
// Spawn a distributed agent
|
|
1343
|
+
const spawner = new AgentSpawner(edgeNetNode);
|
|
1344
|
+
const agent = await spawner.spawn('coder', 'Implement authentication', {
|
|
1345
|
+
maxRuv: 30,
|
|
1346
|
+
priority: 'high'
|
|
1347
|
+
});
|
|
1348
|
+
|
|
1349
|
+
// Create a worker pool
|
|
1350
|
+
const pool = new WorkerPool(edgeNetNode, {
|
|
1351
|
+
minWorkers: 5,
|
|
1352
|
+
maxWorkers: 20,
|
|
1353
|
+
capabilities: ['compute', 'embed', 'analyze']
|
|
1354
|
+
});
|
|
1355
|
+
await pool.scale(10);
|
|
1356
|
+
|
|
1357
|
+
// Execute tasks on the pool
|
|
1358
|
+
const result = await pool.execute({
|
|
1359
|
+
type: 'parallel',
|
|
1360
|
+
task: 'Process batch data',
|
|
1361
|
+
data: largeDataset
|
|
1362
|
+
});
|
|
1363
|
+
|
|
1364
|
+
// Run multi-agent workflow
|
|
1365
|
+
const orchestrator = new TaskOrchestrator(edgeNetNode, spawner);
|
|
1366
|
+
await orchestrator.runWorkflow('feature-dev', 'Add user authentication');
|
|
1367
|
+
```
|
|
1368
|
+
|
|
1369
|
+
### Event System
|
|
1370
|
+
|
|
1371
|
+
Agents and workers emit events for monitoring:
|
|
1372
|
+
|
|
1373
|
+
```javascript
|
|
1374
|
+
agent.on('started', ({ id, type }) => console.log(`Agent ${id} started`));
|
|
1375
|
+
agent.on('progress', ({ progress }) => console.log(`Progress: ${progress}%`));
|
|
1376
|
+
agent.on('completed', ({ result }) => console.log('Done:', result));
|
|
1377
|
+
agent.on('error', ({ error }) => console.error('Error:', error));
|
|
1378
|
+
|
|
1379
|
+
pool.on('scaled', ({ workers }) => console.log(`Pool scaled to ${workers}`));
|
|
1380
|
+
pool.on('task_completed', ({ taskId }) => console.log(`Task ${taskId} done`));
|
|
1381
|
+
```
|
|
1382
|
+
|
|
1383
|
+
### rUv Economics for Agents
|
|
1384
|
+
|
|
1385
|
+
| Factor | Impact |
|
|
1386
|
+
|--------|--------|
|
|
1387
|
+
| **Base Cost** | Agent type determines base rUv per task |
|
|
1388
|
+
| **Task Complexity** | Longer/complex tasks cost more |
|
|
1389
|
+
| **Priority** | High priority = 1.5x cost, Critical = 2x |
|
|
1390
|
+
| **Network Load** | Dynamic pricing based on availability |
|
|
1391
|
+
| **Early Adopter** | 10x multiplier during genesis phase |
|
|
1392
|
+
|
|
1393
|
+
### Security Considerations
|
|
1394
|
+
|
|
1395
|
+
- All agent communications are encrypted via DTLS
|
|
1396
|
+
- Task execution sandboxed in WebWorkers
|
|
1397
|
+
- rUv spending limits prevent runaway costs
|
|
1398
|
+
- Input validation on all MCP tools
|
|
1399
|
+
- Rate limiting on agent spawning
|
|
1400
|
+
|
|
1122
1401
|
### Claude Code Hook Events
|
|
1123
1402
|
|
|
1124
1403
|
| Event | Trigger | Action |
|