navada-edge-cli 3.2.0 → 3.3.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/docker-compose.yml +1 -1
- package/lib/commands/edge.js +186 -0
- package/lib/commands/index.js +1 -1
- package/package.json +1 -1
package/docker-compose.yml
CHANGED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const ui = require('../ui');
|
|
4
|
+
const config = require('../config');
|
|
5
|
+
const navada = require('navada-edge-sdk');
|
|
6
|
+
|
|
7
|
+
const PORTAL_URL = 'https://portal.navada-edge-server.uk';
|
|
8
|
+
const VALIDATE_ENDPOINTS = [
|
|
9
|
+
'https://api.navada-edge-server.uk/api/v1/public/validate-key',
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
module.exports = function(reg) {
|
|
13
|
+
|
|
14
|
+
// /onboard — open portal in browser
|
|
15
|
+
reg('onboard', 'Open NAVADA Edge Portal to create account and get API key', async () => {
|
|
16
|
+
console.log(ui.header('NAVADA EDGE NETWORK — ONBOARDING'));
|
|
17
|
+
console.log('');
|
|
18
|
+
console.log(ui.label('Step 1', 'Create account at the Edge Portal'));
|
|
19
|
+
console.log(ui.label('Step 2', 'Generate an API key (Dashboard > API Keys)'));
|
|
20
|
+
console.log(ui.label('Step 3', 'Connect: /edge login nv_edge_your_key'));
|
|
21
|
+
console.log('');
|
|
22
|
+
|
|
23
|
+
// Try to open browser
|
|
24
|
+
const url = PORTAL_URL + '/sign-up';
|
|
25
|
+
try {
|
|
26
|
+
const { exec } = require('child_process');
|
|
27
|
+
const cmd = process.platform === 'win32' ? `start ${url}`
|
|
28
|
+
: process.platform === 'darwin' ? `open ${url}`
|
|
29
|
+
: `xdg-open ${url}`;
|
|
30
|
+
exec(cmd);
|
|
31
|
+
console.log(ui.success(`Opening ${url} in your browser...`));
|
|
32
|
+
} catch {
|
|
33
|
+
console.log(ui.dim(`Open this URL in your browser:`));
|
|
34
|
+
console.log(ui.label('Portal', url));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
console.log('');
|
|
38
|
+
console.log(ui.dim('After signing up and generating a key, run:'));
|
|
39
|
+
console.log(ui.dim(' /edge login nv_edge_your_key_here'));
|
|
40
|
+
}, { category: 'EDGE', aliases: ['signup', 'register'] });
|
|
41
|
+
|
|
42
|
+
// /edge — edge network commands
|
|
43
|
+
reg('edge', 'NAVADA Edge Network commands', async (args) => {
|
|
44
|
+
const sub = args[0];
|
|
45
|
+
|
|
46
|
+
if (!sub || sub === 'help') {
|
|
47
|
+
console.log(ui.header('NAVADA EDGE NETWORK'));
|
|
48
|
+
console.log(ui.dim('Connect your CLI to the 24/7 Edge Network'));
|
|
49
|
+
console.log('');
|
|
50
|
+
console.log(ui.cmd('edge login <key>', 'Connect with your NAVADA Edge API key'));
|
|
51
|
+
console.log(ui.cmd('edge status', 'Check your Edge Network connection'));
|
|
52
|
+
console.log(ui.cmd('edge logout', 'Disconnect from Edge Network'));
|
|
53
|
+
console.log(ui.cmd('edge tier', 'Show your current tier and limits'));
|
|
54
|
+
console.log(ui.cmd('onboard', 'Create account and get API key'));
|
|
55
|
+
console.log('');
|
|
56
|
+
console.log(ui.dim('Get started: /onboard'));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// /edge login <key>
|
|
61
|
+
if (sub === 'login') {
|
|
62
|
+
const key = args[1];
|
|
63
|
+
if (!key) {
|
|
64
|
+
console.log(ui.error('Usage: /edge login nv_edge_your_key_here'));
|
|
65
|
+
console.log(ui.dim('Get a key: /onboard'));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!key.startsWith('nv_edge_') || key.length !== 56) {
|
|
70
|
+
console.log(ui.error('Invalid key format. NAVADA Edge keys start with nv_edge_ and are 56 characters.'));
|
|
71
|
+
console.log(ui.dim('Get a key: /onboard'));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Validate against the Edge Network
|
|
76
|
+
const ora = require('ora');
|
|
77
|
+
const spinner = ora({ text: ' Validating key with NAVADA Edge Network...', color: 'white' }).start();
|
|
78
|
+
|
|
79
|
+
let validated = false;
|
|
80
|
+
for (const endpoint of VALIDATE_ENDPOINTS) {
|
|
81
|
+
try {
|
|
82
|
+
const r = await navada.request(endpoint, {
|
|
83
|
+
method: 'POST',
|
|
84
|
+
body: { key },
|
|
85
|
+
timeout: 10000,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
if (r.status === 200 && r.data?.valid) {
|
|
89
|
+
spinner.stop();
|
|
90
|
+
config.set('edgeKey', key);
|
|
91
|
+
config.set('edgeTier', r.data.tier || 'free');
|
|
92
|
+
config.set('edgeUserId', r.data.userId || '');
|
|
93
|
+
config.set('edgeConnected', true);
|
|
94
|
+
|
|
95
|
+
console.log(ui.success('Connected to NAVADA Edge Network'));
|
|
96
|
+
console.log(ui.label('Tier', (r.data.tier || 'FREE').toUpperCase()));
|
|
97
|
+
console.log(ui.label('User', r.data.name || r.data.userId || 'connected'));
|
|
98
|
+
console.log('');
|
|
99
|
+
console.log(ui.dim('You now have access to:'));
|
|
100
|
+
console.log(ui.dim(' /status — network health'));
|
|
101
|
+
console.log(ui.dim(' /doctor — test connections'));
|
|
102
|
+
console.log(ui.dim(' /offload — run tasks 24/7 (coming soon)'));
|
|
103
|
+
console.log(ui.dim(' /sessions — view running tasks (coming soon)'));
|
|
104
|
+
validated = true;
|
|
105
|
+
break;
|
|
106
|
+
} else if (r.status === 401) {
|
|
107
|
+
spinner.stop();
|
|
108
|
+
console.log(ui.error('Key not recognised. Check your key or generate a new one: /onboard'));
|
|
109
|
+
validated = true;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
} catch {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (!validated) {
|
|
118
|
+
spinner.stop();
|
|
119
|
+
// Can't reach server — store key locally anyway (offline-first)
|
|
120
|
+
config.set('edgeKey', key);
|
|
121
|
+
config.set('edgeConnected', false);
|
|
122
|
+
console.log(ui.warn('Could not reach NAVADA Edge Network to validate key.'));
|
|
123
|
+
console.log(ui.dim('Key saved locally. It will be validated when the network is reachable.'));
|
|
124
|
+
console.log(ui.dim('Check: /edge status'));
|
|
125
|
+
}
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// /edge status
|
|
130
|
+
if (sub === 'status') {
|
|
131
|
+
const key = config.get('edgeKey');
|
|
132
|
+
if (!key) {
|
|
133
|
+
console.log(ui.warn('Not connected to NAVADA Edge Network'));
|
|
134
|
+
console.log(ui.dim('Get started: /onboard'));
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
console.log(ui.header('EDGE NETWORK STATUS'));
|
|
139
|
+
console.log(ui.label('Key', key.substring(0, 12) + '...' + key.slice(-4)));
|
|
140
|
+
console.log(ui.label('Tier', (config.get('edgeTier') || 'FREE').toUpperCase()));
|
|
141
|
+
console.log(ui.label('Connected', config.get('edgeConnected') ? 'yes' : 'pending validation'));
|
|
142
|
+
|
|
143
|
+
// Ping the network
|
|
144
|
+
try {
|
|
145
|
+
const r = await navada.request('https://api.navada-edge-server.uk/api/health', { timeout: 5000 });
|
|
146
|
+
console.log(ui.online('Edge Network', r.status === 200, 'api.navada-edge-server.uk'));
|
|
147
|
+
} catch {
|
|
148
|
+
console.log(ui.online('Edge Network', false, 'unreachable'));
|
|
149
|
+
}
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// /edge logout
|
|
154
|
+
if (sub === 'logout') {
|
|
155
|
+
config.set('edgeKey', '');
|
|
156
|
+
config.set('edgeTier', '');
|
|
157
|
+
config.set('edgeUserId', '');
|
|
158
|
+
config.set('edgeConnected', false);
|
|
159
|
+
console.log(ui.success('Disconnected from NAVADA Edge Network'));
|
|
160
|
+
console.log(ui.dim('Your local CLI still works. Reconnect anytime: /edge login <key>'));
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// /edge tier
|
|
165
|
+
if (sub === 'tier') {
|
|
166
|
+
const tier = (config.get('edgeTier') || 'free').toUpperCase();
|
|
167
|
+
console.log(ui.header('EDGE NETWORK TIER'));
|
|
168
|
+
console.log(ui.label('Current', tier));
|
|
169
|
+
console.log('');
|
|
170
|
+
if (tier === 'FREE') {
|
|
171
|
+
console.log(ui.dim('Free tier includes:'));
|
|
172
|
+
console.log(ui.dim(' 100 requests/day'));
|
|
173
|
+
console.log(ui.dim(' 50K tokens/day'));
|
|
174
|
+
console.log(ui.dim(' 10 edge tasks'));
|
|
175
|
+
console.log(ui.dim(' 5min max runtime per task'));
|
|
176
|
+
console.log('');
|
|
177
|
+
console.log(ui.dim('Upgrade: coming soon'));
|
|
178
|
+
}
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
console.log(ui.dim('Unknown subcommand. Try /edge help'));
|
|
183
|
+
|
|
184
|
+
}, { category: 'EDGE', subs: ['login', 'status', 'logout', 'tier', 'help'] });
|
|
185
|
+
|
|
186
|
+
};
|
package/lib/commands/index.js
CHANGED
|
@@ -6,7 +6,7 @@ const { register } = require('../registry');
|
|
|
6
6
|
const moduleNames = [
|
|
7
7
|
'network', 'mcp', 'lucas', 'docker', 'database', 'cloudflare',
|
|
8
8
|
'ai', 'azure', 'agents', 'tasks', 'keys', 'setup', 'system',
|
|
9
|
-
'learn', 'sandbox', 'nvidia',
|
|
9
|
+
'learn', 'sandbox', 'nvidia', 'edge',
|
|
10
10
|
];
|
|
11
11
|
|
|
12
12
|
function loadAll() {
|
package/package.json
CHANGED