@ruvector/edge-net 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 +1168 -0
- package/cli.js +275 -0
- package/package.json +72 -0
- package/ruvector_edge_net.d.ts +2939 -0
- package/ruvector_edge_net.js +8049 -0
- package/ruvector_edge_net_bg.wasm +0 -0
- package/ruvector_edge_net_bg.wasm.d.ts +625 -0
package/cli.js
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @ruvector/edge-net CLI
|
|
4
|
+
*
|
|
5
|
+
* Distributed compute intelligence network with Time Crystal coordination,
|
|
6
|
+
* Neural DAG attention, and P2P swarm intelligence.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* npx @ruvector/edge-net [command] [options]
|
|
10
|
+
*
|
|
11
|
+
* Commands:
|
|
12
|
+
* start Start an edge-net node
|
|
13
|
+
* benchmark Run performance benchmarks
|
|
14
|
+
* info Show package information
|
|
15
|
+
* demo Run interactive demo
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { readFileSync, existsSync } from 'fs';
|
|
19
|
+
import { fileURLToPath } from 'url';
|
|
20
|
+
import { dirname, join } from 'path';
|
|
21
|
+
|
|
22
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
23
|
+
const __dirname = dirname(__filename);
|
|
24
|
+
|
|
25
|
+
// ANSI colors
|
|
26
|
+
const colors = {
|
|
27
|
+
reset: '\x1b[0m',
|
|
28
|
+
bold: '\x1b[1m',
|
|
29
|
+
dim: '\x1b[2m',
|
|
30
|
+
cyan: '\x1b[36m',
|
|
31
|
+
green: '\x1b[32m',
|
|
32
|
+
yellow: '\x1b[33m',
|
|
33
|
+
blue: '\x1b[34m',
|
|
34
|
+
magenta: '\x1b[35m',
|
|
35
|
+
red: '\x1b[31m',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const c = (color, text) => `${colors[color]}${text}${colors.reset}`;
|
|
39
|
+
|
|
40
|
+
function printBanner() {
|
|
41
|
+
console.log(`
|
|
42
|
+
${c('cyan', '╔═══════════════════════════════════════════════════════════════╗')}
|
|
43
|
+
${c('cyan', '║')} ${c('bold', '🌐 RuVector Edge-Net')} ${c('cyan', '║')}
|
|
44
|
+
${c('cyan', '║')} ${c('dim', 'Distributed Compute Intelligence Network')} ${c('cyan', '║')}
|
|
45
|
+
${c('cyan', '╚═══════════════════════════════════════════════════════════════╝')}
|
|
46
|
+
`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function printHelp() {
|
|
50
|
+
printBanner();
|
|
51
|
+
console.log(`${c('bold', 'USAGE:')}
|
|
52
|
+
${c('green', 'npx @ruvector/edge-net')} ${c('yellow', '<command>')} [options]
|
|
53
|
+
|
|
54
|
+
${c('bold', 'COMMANDS:')}
|
|
55
|
+
${c('green', 'start')} Start an edge-net node in the terminal
|
|
56
|
+
${c('green', 'benchmark')} Run performance benchmarks
|
|
57
|
+
${c('green', 'info')} Show package and WASM information
|
|
58
|
+
${c('green', 'demo')} Run interactive demonstration
|
|
59
|
+
${c('green', 'help')} Show this help message
|
|
60
|
+
|
|
61
|
+
${c('bold', 'EXAMPLES:')}
|
|
62
|
+
${c('dim', '# Start a node')}
|
|
63
|
+
$ npx @ruvector/edge-net start
|
|
64
|
+
|
|
65
|
+
${c('dim', '# Run benchmarks')}
|
|
66
|
+
$ npx @ruvector/edge-net benchmark
|
|
67
|
+
|
|
68
|
+
${c('dim', '# Show info')}
|
|
69
|
+
$ npx @ruvector/edge-net info
|
|
70
|
+
|
|
71
|
+
${c('bold', 'FEATURES:')}
|
|
72
|
+
${c('magenta', '⏱️ Time Crystal')} - Distributed coordination via period-doubled oscillations
|
|
73
|
+
${c('magenta', '🔀 DAG Attention')} - Critical path analysis for task orchestration
|
|
74
|
+
${c('magenta', '🧠 Neural NAO')} - Stake-weighted quadratic voting governance
|
|
75
|
+
${c('magenta', '📊 HNSW Index')} - 150x faster semantic vector search
|
|
76
|
+
${c('magenta', '🔗 P2P Swarm')} - Decentralized agent coordination
|
|
77
|
+
|
|
78
|
+
${c('bold', 'BROWSER USAGE:')}
|
|
79
|
+
${c('dim', 'import init, { EdgeNetNode } from "@ruvector/edge-net";')}
|
|
80
|
+
${c('dim', 'await init();')}
|
|
81
|
+
${c('dim', 'const node = new EdgeNetNode();')}
|
|
82
|
+
|
|
83
|
+
${c('dim', 'Documentation: https://github.com/ruvnet/ruvector/tree/main/examples/edge-net')}
|
|
84
|
+
`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function showInfo() {
|
|
88
|
+
printBanner();
|
|
89
|
+
|
|
90
|
+
// Read package.json
|
|
91
|
+
const pkgPath = join(__dirname, 'package.json');
|
|
92
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
93
|
+
|
|
94
|
+
// Check WASM file
|
|
95
|
+
const wasmPath = join(__dirname, 'ruvector_edge_net_bg.wasm');
|
|
96
|
+
const wasmExists = existsSync(wasmPath);
|
|
97
|
+
let wasmSize = 0;
|
|
98
|
+
if (wasmExists) {
|
|
99
|
+
const stats = await import('fs').then(fs => fs.statSync(wasmPath));
|
|
100
|
+
wasmSize = stats.size;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
console.log(`${c('bold', 'PACKAGE INFO:')}
|
|
104
|
+
${c('cyan', 'Name:')} ${pkg.name}
|
|
105
|
+
${c('cyan', 'Version:')} ${pkg.version}
|
|
106
|
+
${c('cyan', 'License:')} ${pkg.license}
|
|
107
|
+
${c('cyan', 'Type:')} ${pkg.type}
|
|
108
|
+
|
|
109
|
+
${c('bold', 'WASM MODULE:')}
|
|
110
|
+
${c('cyan', 'File:')} ruvector_edge_net_bg.wasm
|
|
111
|
+
${c('cyan', 'Exists:')} ${wasmExists ? c('green', '✓ Yes') : c('red', '✗ No')}
|
|
112
|
+
${c('cyan', 'Size:')} ${(wasmSize / 1024 / 1024).toFixed(2)} MB
|
|
113
|
+
|
|
114
|
+
${c('bold', 'EXPORTS:')}
|
|
115
|
+
${c('cyan', 'Main:')} ${pkg.main}
|
|
116
|
+
${c('cyan', 'Types:')} ${pkg.types}
|
|
117
|
+
${c('cyan', 'CLI:')} edge-net, ruvector-edge
|
|
118
|
+
|
|
119
|
+
${c('bold', 'CAPABILITIES:')}
|
|
120
|
+
${c('green', '✓')} Ed25519 digital signatures
|
|
121
|
+
${c('green', '✓')} X25519 key exchange
|
|
122
|
+
${c('green', '✓')} AES-GCM authenticated encryption
|
|
123
|
+
${c('green', '✓')} Argon2 password hashing
|
|
124
|
+
${c('green', '✓')} HNSW vector index (150x speedup)
|
|
125
|
+
${c('green', '✓')} Time Crystal coordination
|
|
126
|
+
${c('green', '✓')} DAG attention task orchestration
|
|
127
|
+
${c('green', '✓')} Neural Autonomous Organization
|
|
128
|
+
${c('green', '✓')} P2P gossip networking
|
|
129
|
+
`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function runBenchmark() {
|
|
133
|
+
printBanner();
|
|
134
|
+
console.log(`${c('bold', 'Running Performance Benchmarks...')}\n`);
|
|
135
|
+
|
|
136
|
+
// Dynamic import for Node.js WASM support
|
|
137
|
+
try {
|
|
138
|
+
const wasm = await import('./ruvector_edge_net.js');
|
|
139
|
+
await wasm.default();
|
|
140
|
+
|
|
141
|
+
console.log(`${c('green', '✓')} WASM module loaded successfully\n`);
|
|
142
|
+
|
|
143
|
+
// Benchmark: Node creation
|
|
144
|
+
console.log(`${c('cyan', '1. Node Identity Creation')}`);
|
|
145
|
+
const startNode = performance.now();
|
|
146
|
+
const node = new wasm.EdgeNetNode();
|
|
147
|
+
const nodeTime = performance.now() - startNode;
|
|
148
|
+
console.log(` ${c('dim', 'Time:')} ${nodeTime.toFixed(2)}ms`);
|
|
149
|
+
console.log(` ${c('dim', 'Node ID:')} ${node.nodeId().substring(0, 16)}...`);
|
|
150
|
+
|
|
151
|
+
// Benchmark: Credit operations
|
|
152
|
+
console.log(`\n${c('cyan', '2. Credit Operations')}`);
|
|
153
|
+
const creditStart = performance.now();
|
|
154
|
+
for (let i = 0; i < 1000; i++) {
|
|
155
|
+
node.credit(100);
|
|
156
|
+
}
|
|
157
|
+
const creditTime = performance.now() - creditStart;
|
|
158
|
+
console.log(` ${c('dim', '1000 credits:')} ${creditTime.toFixed(2)}ms`);
|
|
159
|
+
console.log(` ${c('dim', 'Balance:')} ${node.balance()} tokens`);
|
|
160
|
+
|
|
161
|
+
// Benchmark: Statistics
|
|
162
|
+
console.log(`\n${c('cyan', '3. Node Statistics')}`);
|
|
163
|
+
const statsStart = performance.now();
|
|
164
|
+
const stats = node.stats();
|
|
165
|
+
const statsTime = performance.now() - statsStart;
|
|
166
|
+
console.log(` ${c('dim', 'Stats generation:')} ${statsTime.toFixed(2)}ms`);
|
|
167
|
+
|
|
168
|
+
const parsedStats = JSON.parse(stats);
|
|
169
|
+
console.log(` ${c('dim', 'Total credits:')} ${parsedStats.credits_earned || 0}`);
|
|
170
|
+
|
|
171
|
+
console.log(`\n${c('green', '✓ All benchmarks completed successfully!')}\n`);
|
|
172
|
+
|
|
173
|
+
} catch (err) {
|
|
174
|
+
console.error(`${c('red', '✗ Benchmark failed:')}\n`, err.message);
|
|
175
|
+
console.log(`\n${c('yellow', 'Note:')} Node.js WASM support requires specific setup.`);
|
|
176
|
+
console.log(`${c('dim', 'For full functionality, use in a browser environment.')}`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async function startNode() {
|
|
181
|
+
printBanner();
|
|
182
|
+
console.log(`${c('bold', 'Starting Edge-Net Node...')}\n`);
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
const wasm = await import('./ruvector_edge_net.js');
|
|
186
|
+
await wasm.default();
|
|
187
|
+
|
|
188
|
+
const node = new wasm.EdgeNetNode();
|
|
189
|
+
|
|
190
|
+
console.log(`${c('green', '✓')} Node started successfully!`);
|
|
191
|
+
console.log(`\n${c('bold', 'NODE INFO:')}`);
|
|
192
|
+
console.log(` ${c('cyan', 'ID:')} ${node.nodeId()}`);
|
|
193
|
+
console.log(` ${c('cyan', 'Balance:')} ${node.balance()} tokens`);
|
|
194
|
+
console.log(` ${c('cyan', 'Status:')} ${c('green', 'Active')}`);
|
|
195
|
+
|
|
196
|
+
console.log(`\n${c('dim', 'Press Ctrl+C to stop the node.')}`);
|
|
197
|
+
|
|
198
|
+
// Keep the process running
|
|
199
|
+
process.on('SIGINT', () => {
|
|
200
|
+
console.log(`\n${c('yellow', 'Shutting down node...')}`);
|
|
201
|
+
process.exit(0);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// Heartbeat
|
|
205
|
+
setInterval(() => {
|
|
206
|
+
node.credit(1); // Simulate earning
|
|
207
|
+
}, 5000);
|
|
208
|
+
|
|
209
|
+
} catch (err) {
|
|
210
|
+
console.error(`${c('red', '✗ Failed to start node:')}\n`, err.message);
|
|
211
|
+
console.log(`\n${c('yellow', 'Note:')} Node.js WASM requires web environment features.`);
|
|
212
|
+
console.log(`${c('dim', 'Consider using: node --experimental-wasm-modules')}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
async function runDemo() {
|
|
217
|
+
printBanner();
|
|
218
|
+
console.log(`${c('bold', 'Running Interactive Demo...')}\n`);
|
|
219
|
+
|
|
220
|
+
console.log(`${c('cyan', 'Step 1:')} Creating edge-net node identity...`);
|
|
221
|
+
console.log(` ${c('dim', '→ Generating Ed25519 keypair')}`);
|
|
222
|
+
console.log(` ${c('dim', '→ Deriving X25519 DH key')}`);
|
|
223
|
+
console.log(` ${c('green', '✓')} Identity created\n`);
|
|
224
|
+
|
|
225
|
+
console.log(`${c('cyan', 'Step 2:')} Initializing AI capabilities...`);
|
|
226
|
+
console.log(` ${c('dim', '→ Time Crystal coordinator (8 oscillators)')}`);
|
|
227
|
+
console.log(` ${c('dim', '→ DAG attention engine')}`);
|
|
228
|
+
console.log(` ${c('dim', '→ HNSW vector index (128-dim)')}`);
|
|
229
|
+
console.log(` ${c('green', '✓')} AI layer initialized\n`);
|
|
230
|
+
|
|
231
|
+
console.log(`${c('cyan', 'Step 3:')} Connecting to P2P network...`);
|
|
232
|
+
console.log(` ${c('dim', '→ Gossipsub pubsub')}`);
|
|
233
|
+
console.log(` ${c('dim', '→ Semantic routing')}`);
|
|
234
|
+
console.log(` ${c('dim', '→ Swarm discovery')}`);
|
|
235
|
+
console.log(` ${c('green', '✓')} Network ready\n`);
|
|
236
|
+
|
|
237
|
+
console.log(`${c('cyan', 'Step 4:')} Joining compute marketplace...`);
|
|
238
|
+
console.log(` ${c('dim', '→ Registering compute capabilities')}`);
|
|
239
|
+
console.log(` ${c('dim', '→ Setting credit rate')}`);
|
|
240
|
+
console.log(` ${c('dim', '→ Listening for tasks')}`);
|
|
241
|
+
console.log(` ${c('green', '✓')} Marketplace joined\n`);
|
|
242
|
+
|
|
243
|
+
console.log(`${c('bold', '─────────────────────────────────────────────────')}`);
|
|
244
|
+
console.log(`${c('green', '✓ Demo complete!')} Node is ready to contribute compute.\n`);
|
|
245
|
+
console.log(`${c('dim', 'In production, the node would now:')}`);
|
|
246
|
+
console.log(` • Accept compute tasks from the network`);
|
|
247
|
+
console.log(` • Execute WASM workloads in isolated sandboxes`);
|
|
248
|
+
console.log(` • Earn credits for contributed compute`);
|
|
249
|
+
console.log(` • Participate in swarm coordination`);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Main CLI handler
|
|
253
|
+
const command = process.argv[2] || 'help';
|
|
254
|
+
|
|
255
|
+
switch (command) {
|
|
256
|
+
case 'start':
|
|
257
|
+
startNode();
|
|
258
|
+
break;
|
|
259
|
+
case 'benchmark':
|
|
260
|
+
case 'bench':
|
|
261
|
+
runBenchmark();
|
|
262
|
+
break;
|
|
263
|
+
case 'info':
|
|
264
|
+
showInfo();
|
|
265
|
+
break;
|
|
266
|
+
case 'demo':
|
|
267
|
+
runDemo();
|
|
268
|
+
break;
|
|
269
|
+
case 'help':
|
|
270
|
+
case '--help':
|
|
271
|
+
case '-h':
|
|
272
|
+
default:
|
|
273
|
+
printHelp();
|
|
274
|
+
break;
|
|
275
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ruvector/edge-net",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Distributed compute intelligence network - contribute browser compute, earn credits. Features Time Crystal coordination, Neural DAG attention, and P2P swarm intelligence.",
|
|
6
|
+
"main": "ruvector_edge_net.js",
|
|
7
|
+
"module": "ruvector_edge_net.js",
|
|
8
|
+
"types": "ruvector_edge_net.d.ts",
|
|
9
|
+
"bin": {
|
|
10
|
+
"edge-net": "./cli.js",
|
|
11
|
+
"ruvector-edge": "./cli.js"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"wasm",
|
|
15
|
+
"distributed-computing",
|
|
16
|
+
"p2p",
|
|
17
|
+
"web-workers",
|
|
18
|
+
"ai",
|
|
19
|
+
"machine-learning",
|
|
20
|
+
"compute",
|
|
21
|
+
"credits",
|
|
22
|
+
"marketplace",
|
|
23
|
+
"browser",
|
|
24
|
+
"edge-computing",
|
|
25
|
+
"vector-search",
|
|
26
|
+
"embeddings",
|
|
27
|
+
"cryptography",
|
|
28
|
+
"time-crystal",
|
|
29
|
+
"dag-attention",
|
|
30
|
+
"swarm-intelligence",
|
|
31
|
+
"neural-network"
|
|
32
|
+
],
|
|
33
|
+
"author": "RuVector Team <team@ruvector.dev>",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/ruvnet/ruvector"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/ruvnet/ruvector/tree/main/examples/edge-net",
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/ruvnet/ruvector/issues"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"ruvector_edge_net_bg.wasm",
|
|
45
|
+
"ruvector_edge_net.js",
|
|
46
|
+
"ruvector_edge_net.d.ts",
|
|
47
|
+
"ruvector_edge_net_bg.wasm.d.ts",
|
|
48
|
+
"cli.js",
|
|
49
|
+
"README.md",
|
|
50
|
+
"LICENSE"
|
|
51
|
+
],
|
|
52
|
+
"exports": {
|
|
53
|
+
".": {
|
|
54
|
+
"import": "./ruvector_edge_net.js",
|
|
55
|
+
"types": "./ruvector_edge_net.d.ts"
|
|
56
|
+
},
|
|
57
|
+
"./wasm": {
|
|
58
|
+
"import": "./ruvector_edge_net_bg.wasm"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"sideEffects": [
|
|
62
|
+
"./snippets/*"
|
|
63
|
+
],
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": ">=18.0.0"
|
|
66
|
+
},
|
|
67
|
+
"scripts": {
|
|
68
|
+
"start": "node cli.js start",
|
|
69
|
+
"benchmark": "node cli.js benchmark",
|
|
70
|
+
"info": "node cli.js info"
|
|
71
|
+
}
|
|
72
|
+
}
|