@infernetprotocol/cli 0.1.22
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 +15 -0
- package/commands/chat.js +268 -0
- package/commands/console.js +229 -0
- package/commands/debug.js +222 -0
- package/commands/deploy.js +524 -0
- package/commands/doctor.js +501 -0
- package/commands/firewall.js +39 -0
- package/commands/gpu.js +130 -0
- package/commands/help.js +54 -0
- package/commands/init.js +304 -0
- package/commands/login.js +305 -0
- package/commands/logs.js +93 -0
- package/commands/model.js +359 -0
- package/commands/payments.js +92 -0
- package/commands/payout.js +128 -0
- package/commands/pubkey.js +116 -0
- package/commands/register.js +304 -0
- package/commands/remove.js +230 -0
- package/commands/service.js +255 -0
- package/commands/setup.js +869 -0
- package/commands/start.js +903 -0
- package/commands/stats.js +85 -0
- package/commands/status.js +116 -0
- package/commands/stop.js +81 -0
- package/commands/train.js +563 -0
- package/commands/tui.js +285 -0
- package/commands/uncensored.js +222 -0
- package/commands/update.js +80 -0
- package/commands/upgrade.js +2 -0
- package/examples/app.js +153 -0
- package/index.js +207 -0
- package/lib/chat-executor.js +232 -0
- package/lib/config.js +148 -0
- package/lib/daemonize.js +46 -0
- package/lib/firewall.js +190 -0
- package/lib/hf-model.js +166 -0
- package/lib/identity.js +18 -0
- package/lib/ipc.js +114 -0
- package/lib/model-fit.js +67 -0
- package/lib/model-key.js +52 -0
- package/lib/network.js +240 -0
- package/lib/nip44.js +130 -0
- package/lib/node-client.js +152 -0
- package/lib/peers.js +133 -0
- package/lib/prompt.js +49 -0
- package/lib/remote-chat.js +115 -0
- package/lib/route.js +44 -0
- package/lib/runtime-config.js +130 -0
- package/lib/version.js +32 -0
- package/package.json +57 -0
package/commands/tui.js
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `infernet tui` — terminal dashboard.
|
|
3
|
+
*
|
|
4
|
+
* React + blessed live monitor for the daemon. Polls the IPC socket
|
|
5
|
+
* every 2s for the daemon's stats snapshot and the local Ollama for
|
|
6
|
+
* loaded-model info, lays it out in four panels: System, Jobs,
|
|
7
|
+
* Engine, Peers.
|
|
8
|
+
*
|
|
9
|
+
* Plain JS (no JSX build step) — uses React.createElement directly so
|
|
10
|
+
* the CLI ships without a transpile.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* infernet tui
|
|
14
|
+
* infernet tui --refresh 1000 # poll faster (ms)
|
|
15
|
+
*
|
|
16
|
+
* Keys: q / Ctrl-C to quit, r to force a refresh.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import React, { useEffect, useState, useCallback } from "react";
|
|
20
|
+
import blessed from "blessed";
|
|
21
|
+
import { render } from "react-blessed";
|
|
22
|
+
|
|
23
|
+
import { isDaemonAlive, sendToDaemon } from "../lib/ipc.js";
|
|
24
|
+
import { loadConfig, getConfigPath } from "../lib/config.js";
|
|
25
|
+
|
|
26
|
+
const e = React.createElement;
|
|
27
|
+
const HELP = `infernet tui — terminal dashboard
|
|
28
|
+
|
|
29
|
+
Usage:
|
|
30
|
+
infernet tui [flags]
|
|
31
|
+
|
|
32
|
+
Flags:
|
|
33
|
+
--refresh <ms> Poll interval (default 2000).
|
|
34
|
+
-h, --help Show this help.
|
|
35
|
+
|
|
36
|
+
Keys (in TUI):
|
|
37
|
+
q / Ctrl-C quit
|
|
38
|
+
r refresh now
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
const DEFAULT_OLLAMA_HOST = "http://localhost:11434";
|
|
42
|
+
|
|
43
|
+
function fmtUptime(ms) {
|
|
44
|
+
if (typeof ms !== "number") return "?";
|
|
45
|
+
const s = Math.floor(ms / 1000);
|
|
46
|
+
const h = Math.floor(s / 3600);
|
|
47
|
+
const m = Math.floor((s % 3600) / 60);
|
|
48
|
+
const sec = s % 60;
|
|
49
|
+
if (h > 0) return `${h}h ${m}m ${sec}s`;
|
|
50
|
+
if (m > 0) return `${m}m ${sec}s`;
|
|
51
|
+
return `${sec}s`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function fmtTs(iso) {
|
|
55
|
+
if (!iso) return "—";
|
|
56
|
+
try {
|
|
57
|
+
return new Date(iso).toLocaleTimeString();
|
|
58
|
+
} catch {
|
|
59
|
+
return iso;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function fetchOllama(host) {
|
|
64
|
+
try {
|
|
65
|
+
const ctrl = new AbortController();
|
|
66
|
+
const t = setTimeout(() => ctrl.abort(), 1500);
|
|
67
|
+
const res = await fetch(new URL("/api/tags", host), { signal: ctrl.signal });
|
|
68
|
+
clearTimeout(t);
|
|
69
|
+
if (!res.ok) return { reachable: false };
|
|
70
|
+
const body = await res.json();
|
|
71
|
+
return { reachable: true, models: body.models ?? [] };
|
|
72
|
+
} catch {
|
|
73
|
+
return { reachable: false };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function Panel({ label, top, left, width, height, children, borderColor = "cyan" }) {
|
|
78
|
+
return e(
|
|
79
|
+
"box",
|
|
80
|
+
{
|
|
81
|
+
label: ` ${label} `,
|
|
82
|
+
top,
|
|
83
|
+
left,
|
|
84
|
+
width,
|
|
85
|
+
height,
|
|
86
|
+
border: { type: "line" },
|
|
87
|
+
style: { border: { fg: borderColor }, label: { fg: "white", bold: true } }
|
|
88
|
+
},
|
|
89
|
+
children
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function KV({ k, v, top }) {
|
|
94
|
+
return e(
|
|
95
|
+
"box",
|
|
96
|
+
{ top, left: 1, height: 1, content: `{bold}${k}{/bold} ${v ?? "—"}`, tags: true }
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function App({ refreshMs }) {
|
|
101
|
+
const [config, setConfig] = useState(null);
|
|
102
|
+
const [snap, setSnap] = useState(null);
|
|
103
|
+
const [daemon, setDaemon] = useState({ alive: false });
|
|
104
|
+
const [ollama, setOllama] = useState({ reachable: false, models: [] });
|
|
105
|
+
const [tick, setTick] = useState(0);
|
|
106
|
+
const [error, setError] = useState(null);
|
|
107
|
+
|
|
108
|
+
const refresh = useCallback(async () => {
|
|
109
|
+
try {
|
|
110
|
+
const cfg = await loadConfig();
|
|
111
|
+
setConfig(cfg);
|
|
112
|
+
const alive = await isDaemonAlive(500);
|
|
113
|
+
setDaemon({ alive });
|
|
114
|
+
if (alive) {
|
|
115
|
+
const r = await sendToDaemon("stats", null, { timeoutMs: 1500 });
|
|
116
|
+
if (r?.ok) setSnap(r.data);
|
|
117
|
+
else setError(r?.error ?? "stats failed");
|
|
118
|
+
} else {
|
|
119
|
+
setSnap(null);
|
|
120
|
+
}
|
|
121
|
+
const ollamaHost = cfg?.engine?.ollamaHost ?? process.env.OLLAMA_HOST ?? DEFAULT_OLLAMA_HOST;
|
|
122
|
+
setOllama(await fetchOllama(ollamaHost));
|
|
123
|
+
setError(null);
|
|
124
|
+
} catch (err) {
|
|
125
|
+
setError(err?.message ?? String(err));
|
|
126
|
+
}
|
|
127
|
+
setTick((t) => t + 1);
|
|
128
|
+
}, []);
|
|
129
|
+
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
refresh();
|
|
132
|
+
const id = setInterval(refresh, refreshMs);
|
|
133
|
+
return () => clearInterval(id);
|
|
134
|
+
}, [refresh, refreshMs]);
|
|
135
|
+
|
|
136
|
+
const stats = snap?.stats ?? {};
|
|
137
|
+
const nodeName = config?.node?.name ?? config?.node?.nodeId ?? "(no node configured)";
|
|
138
|
+
const role = config?.node?.role ?? "—";
|
|
139
|
+
const cpUrl = config?.controlPlane?.url ?? "(not set)";
|
|
140
|
+
const engineCfg = config?.engine ?? {};
|
|
141
|
+
|
|
142
|
+
const headerText =
|
|
143
|
+
`{bold}Infernet TUI{/bold} ${nodeName} [${role}] ` +
|
|
144
|
+
`${daemon.alive ? "{green-fg}● daemon up{/}" : "{red-fg}○ daemon down{/}"} ` +
|
|
145
|
+
`${ollama.reachable ? "{green-fg}● ollama up{/}" : "{red-fg}○ ollama down{/}"} ` +
|
|
146
|
+
`tick=${tick}`;
|
|
147
|
+
|
|
148
|
+
return e(
|
|
149
|
+
"element",
|
|
150
|
+
{},
|
|
151
|
+
e(
|
|
152
|
+
"box",
|
|
153
|
+
{
|
|
154
|
+
top: 0, left: 0, width: "100%", height: 1,
|
|
155
|
+
content: headerText, tags: true,
|
|
156
|
+
style: { fg: "white", bg: "blue" }
|
|
157
|
+
}
|
|
158
|
+
),
|
|
159
|
+
|
|
160
|
+
e(
|
|
161
|
+
Panel,
|
|
162
|
+
{ label: "System", top: 1, left: 0, width: "50%", height: "45%-1", borderColor: "cyan" },
|
|
163
|
+
e(KV, { top: 1, k: "daemon:", v: daemon.alive ? "running" : "offline" }),
|
|
164
|
+
e(KV, { top: 2, k: "uptime:", v: snap ? fmtUptime(snap.uptimeMs) : "—" }),
|
|
165
|
+
e(KV, { top: 3, k: "pid: ", v: snap?.pid ?? "—" }),
|
|
166
|
+
e(KV, { top: 4, k: "node: ", v: nodeName }),
|
|
167
|
+
e(KV, { top: 5, k: "role: ", v: role }),
|
|
168
|
+
e(KV, { top: 6, k: "ctrl: ", v: cpUrl }),
|
|
169
|
+
e(KV, { top: 7, k: "p2p: ", v: snap?.p2p?.enabled ? snap.p2p.endpoint : "disabled" }),
|
|
170
|
+
e(KV, { top: 8, k: "config:", v: getConfigPath() })
|
|
171
|
+
),
|
|
172
|
+
|
|
173
|
+
e(
|
|
174
|
+
Panel,
|
|
175
|
+
{ label: "Jobs", top: 1, left: "50%", width: "50%", height: "45%-1", borderColor: "magenta" },
|
|
176
|
+
e(KV, { top: 1, k: "picked: ", v: stats.jobsPicked ?? 0 }),
|
|
177
|
+
e(KV, { top: 2, k: "completed: ", v: stats.jobsCompleted ?? 0 }),
|
|
178
|
+
e(KV, { top: 3, k: "failed: ", v: stats.jobsFailed ?? 0 }),
|
|
179
|
+
e(KV, { top: 4, k: "active: ", v: stats.activeJobs ?? 0 }),
|
|
180
|
+
e(KV, { top: 5, k: "last job: ", v: fmtTs(stats.lastJobAt) }),
|
|
181
|
+
e(KV, { top: 6, k: "polls ok: ", v: `${stats.pollsOk ?? 0} / ${(stats.pollsOk ?? 0) + (stats.pollsFailed ?? 0)}` }),
|
|
182
|
+
e(KV, { top: 7, k: "last poll: ", v: fmtTs(stats.lastPollAt) }),
|
|
183
|
+
e(KV, { top: 8, k: "heartbeats:", v: `${stats.heartbeatsOk ?? 0} ok / ${stats.heartbeatsFailed ?? 0} fail` })
|
|
184
|
+
),
|
|
185
|
+
|
|
186
|
+
e(
|
|
187
|
+
Panel,
|
|
188
|
+
{ label: "Engine", top: "45%", left: 0, width: "50%", height: "50%-1", borderColor: "yellow" },
|
|
189
|
+
e(KV, { top: 1, k: "backend:", v: engineCfg.backend ?? "auto" }),
|
|
190
|
+
e(KV, { top: 2, k: "model: ", v: engineCfg.model ?? "(unset)" }),
|
|
191
|
+
e(KV, { top: 3, k: "ollama: ", v: ollama.reachable ? `up (${ollama.models.length} model${ollama.models.length === 1 ? "" : "s"})` : "down" }),
|
|
192
|
+
e(
|
|
193
|
+
"box",
|
|
194
|
+
{
|
|
195
|
+
top: 5, left: 1, width: "100%-2", height: "100%-7",
|
|
196
|
+
content: ollama.reachable
|
|
197
|
+
? (ollama.models.length === 0
|
|
198
|
+
? "(no models pulled — try: infernet model pull qwen2.5:7b)"
|
|
199
|
+
: ollama.models.slice(0, 8).map((m) => {
|
|
200
|
+
const size =
|
|
201
|
+
typeof m.size === "number"
|
|
202
|
+
? `${(m.size / 1024 / 1024 / 1024).toFixed(1)} GB`
|
|
203
|
+
: "?";
|
|
204
|
+
const active = m.name === engineCfg.model ? " *" : "";
|
|
205
|
+
return ` ${m.name.padEnd(20)} ${size}${active}`;
|
|
206
|
+
}).join("\n"))
|
|
207
|
+
: "ollama not reachable — run `infernet setup`",
|
|
208
|
+
tags: false
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
),
|
|
212
|
+
|
|
213
|
+
e(
|
|
214
|
+
Panel,
|
|
215
|
+
{ label: "Peers (IPIP-0002, not yet implemented)", top: "45%", left: "50%", width: "50%", height: "50%-1", borderColor: "white" },
|
|
216
|
+
e(
|
|
217
|
+
"box",
|
|
218
|
+
{
|
|
219
|
+
top: 1, left: 1, width: "100%-2", height: "100%-2",
|
|
220
|
+
content:
|
|
221
|
+
"Operator-to-operator chat is specified in IPIP-0002.\n\n" +
|
|
222
|
+
"Once implemented, this panel will show:\n" +
|
|
223
|
+
" • Default rooms: #general #support #news #offtopic\n" +
|
|
224
|
+
" • Unread DM count\n" +
|
|
225
|
+
" • Connected relays\n\n" +
|
|
226
|
+
"Spec: ipips/ipip-0002.md"
|
|
227
|
+
}
|
|
228
|
+
)
|
|
229
|
+
),
|
|
230
|
+
|
|
231
|
+
e(
|
|
232
|
+
"box",
|
|
233
|
+
{
|
|
234
|
+
bottom: 0, left: 0, width: "100%", height: 1,
|
|
235
|
+
content: error
|
|
236
|
+
? `{red-bg}{white-fg} ${error} {/} q: quit r: refresh`
|
|
237
|
+
: `q: quit r: refresh refresh=${refreshMs}ms`,
|
|
238
|
+
tags: true,
|
|
239
|
+
style: { fg: "white", bg: "black" }
|
|
240
|
+
}
|
|
241
|
+
)
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export default async function tui(args) {
|
|
246
|
+
if (args.has("help") || args.has("h")) {
|
|
247
|
+
process.stdout.write(HELP);
|
|
248
|
+
return 0;
|
|
249
|
+
}
|
|
250
|
+
if (!process.stdout.isTTY) {
|
|
251
|
+
process.stderr.write("error: infernet tui requires a TTY\n");
|
|
252
|
+
return 2;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const refreshMs = Number.parseInt(args.get("refresh") ?? "", 10) || 2000;
|
|
256
|
+
|
|
257
|
+
const screen = blessed.screen({
|
|
258
|
+
smartCSR: true,
|
|
259
|
+
title: "Infernet TUI",
|
|
260
|
+
fullUnicode: true
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
screen.key(["q", "C-c"], () => {
|
|
264
|
+
screen.destroy();
|
|
265
|
+
process.exit(0);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
let triggerRefresh = null;
|
|
269
|
+
screen.key(["r"], () => {
|
|
270
|
+
if (triggerRefresh) triggerRefresh();
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// Wrap App so we can grab its `refresh` callback for the `r` keybind.
|
|
274
|
+
function Root() {
|
|
275
|
+
const [, force] = useState(0);
|
|
276
|
+
triggerRefresh = () => force((n) => n + 1);
|
|
277
|
+
return e(App, { refreshMs });
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
render(e(Root), screen);
|
|
281
|
+
|
|
282
|
+
// Block until quit. The exit handler in screen.key("q") calls
|
|
283
|
+
// process.exit(0), so this promise never resolves intentionally.
|
|
284
|
+
return new Promise(() => {});
|
|
285
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `infernet uncensored` — download and configure an uncensored LLM.
|
|
3
|
+
*
|
|
4
|
+
* Auto-detects available VRAM and picks the best-fitting uncensored model
|
|
5
|
+
* from a curated list. Uses Ollama (dolphin3) for quick local inference,
|
|
6
|
+
* or HuggingFace + vLLM/SGLang for full-GPU hosting on the Infernet network.
|
|
7
|
+
*
|
|
8
|
+
* infernet uncensored auto-pick based on VRAM
|
|
9
|
+
* infernet uncensored --ollama force Ollama backend (dolphin3)
|
|
10
|
+
* infernet uncensored --list print the curated model table
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { loadConfig, saveConfig, getConfigPath } from '../lib/config.js';
|
|
14
|
+
import { detectCapacity } from '../lib/model-fit.js';
|
|
15
|
+
import {
|
|
16
|
+
resolveHfToken,
|
|
17
|
+
fetchHfModelInfo,
|
|
18
|
+
downloadHfModel,
|
|
19
|
+
} from '../lib/hf-model.js';
|
|
20
|
+
import { spawn } from 'node:child_process';
|
|
21
|
+
|
|
22
|
+
const HELP = `infernet uncensored — download an uncensored LLM onto this node
|
|
23
|
+
|
|
24
|
+
Usage:
|
|
25
|
+
infernet uncensored [flags]
|
|
26
|
+
|
|
27
|
+
Flags:
|
|
28
|
+
--ollama Use Ollama backend (dolphin3 series) instead of HuggingFace
|
|
29
|
+
--list Show the curated uncensored model table and exit
|
|
30
|
+
--force Skip VRAM capacity check
|
|
31
|
+
--help Show this help
|
|
32
|
+
|
|
33
|
+
How it works:
|
|
34
|
+
Detects your available VRAM and picks the best-fitting uncensored model.
|
|
35
|
+
HuggingFace models are downloaded locally and served via vLLM or SGLang,
|
|
36
|
+
making your node a paid provider for uncensored inference on Infernet.
|
|
37
|
+
|
|
38
|
+
Curated models (HuggingFace / vLLM):
|
|
39
|
+
≥ 8 GB VRAM NousResearch/Hermes-3-Llama-3.1-8B (Apache 2.0, ~5 GB @ 4-bit)
|
|
40
|
+
≥ 40 GB VRAM cognitivecomputations/dolphin-2.9.4-llama3.1-70b
|
|
41
|
+
|
|
42
|
+
Curated models (Ollama):
|
|
43
|
+
≥ 4 GB VRAM dolphin3:2b
|
|
44
|
+
≥ 6 GB VRAM dolphin3:8b (recommended)
|
|
45
|
+
≥ 30 GB VRAM dolphin-mixtral:8x7b
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
// HuggingFace models, ordered by VRAM requirement ascending
|
|
49
|
+
const HF_MODELS = [
|
|
50
|
+
{
|
|
51
|
+
repoId: 'NousResearch/Hermes-3-Llama-3.1-8B',
|
|
52
|
+
sizeGb: 15.0,
|
|
53
|
+
sizeGb4bit: 5.0,
|
|
54
|
+
minVramGb: 8,
|
|
55
|
+
description: 'Hermes 3 8B (Nous Research) — uncensored, instruction-tuned, Apache 2.0',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
repoId: 'cognitivecomputations/dolphin-2.9.4-llama3.1-70b',
|
|
59
|
+
sizeGb: 140.0,
|
|
60
|
+
sizeGb4bit: 40.0,
|
|
61
|
+
minVramGb: 40,
|
|
62
|
+
description: 'Dolphin 2.9.4 70B (Eric Hartford) — uncensored, Llama 3.1 base',
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
// Ollama models, ordered by VRAM requirement ascending
|
|
67
|
+
const OLLAMA_MODELS = [
|
|
68
|
+
{ name: 'dolphin3:2b', sizeGb: 2.2, minVramGb: 4, description: 'Dolphin 3 2B — lightweight uncensored' },
|
|
69
|
+
{ name: 'dolphin3:8b', sizeGb: 4.9, minVramGb: 6, description: 'Dolphin 3 8B — recommended uncensored (Llama 3.1)' },
|
|
70
|
+
{ name: 'dolphin-mixtral:8x7b', sizeGb: 26.1, minVramGb: 30, description: 'Dolphin Mixtral 8x7B — high-capacity uncensored' },
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
function pickHfModel(vramGb) {
|
|
74
|
+
// Pick the largest model that fits
|
|
75
|
+
const fits = HF_MODELS.filter(m => vramGb === 0 || vramGb >= m.minVramGb);
|
|
76
|
+
return fits.length > 0 ? fits[fits.length - 1] : HF_MODELS[0];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function pickOllamaModel(vramGb) {
|
|
80
|
+
const fits = OLLAMA_MODELS.filter(m => vramGb === 0 || vramGb >= m.minVramGb);
|
|
81
|
+
return fits.length > 0 ? fits[fits.length - 1] : OLLAMA_MODELS[0];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function printModelTable() {
|
|
85
|
+
process.stdout.write('\nHuggingFace / vLLM (for hosting on Infernet):\n');
|
|
86
|
+
process.stdout.write(` ${'MODEL'.padEnd(55)} ${'VRAM'.padEnd(8)} DESCRIPTION\n`);
|
|
87
|
+
for (const m of HF_MODELS) {
|
|
88
|
+
process.stdout.write(` ${m.repoId.padEnd(55)} ${('>= ' + m.minVramGb + ' GB').padEnd(8)} ${m.description}\n`);
|
|
89
|
+
}
|
|
90
|
+
process.stdout.write('\nOllama (local inference, quick start):\n');
|
|
91
|
+
process.stdout.write(` ${'MODEL'.padEnd(30)} ${'SIZE'.padEnd(8)} ${'VRAM'.padEnd(8)} DESCRIPTION\n`);
|
|
92
|
+
for (const m of OLLAMA_MODELS) {
|
|
93
|
+
process.stdout.write(` ${m.name.padEnd(30)} ${(m.sizeGb + ' GB').padEnd(8)} ${('>= ' + m.minVramGb + ' GB').padEnd(8)} ${m.description}\n`);
|
|
94
|
+
}
|
|
95
|
+
process.stdout.write('\n');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function streamOllamaPull(name) {
|
|
99
|
+
return new Promise((resolve, reject) => {
|
|
100
|
+
const child = spawn('ollama', ['pull', name], { stdio: 'inherit' });
|
|
101
|
+
child.on('exit', code => code === 0 ? resolve() : reject(new Error(`ollama pull exited ${code}`)));
|
|
102
|
+
child.on('error', reject);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function setActiveModel(repoIdOrName, backend) {
|
|
107
|
+
const cfg = (await loadConfig()) ?? {};
|
|
108
|
+
await saveConfig({ ...cfg, engine: { ...(cfg.engine ?? {}), model: repoIdOrName, backend } });
|
|
109
|
+
process.stdout.write(`engine.model = ${repoIdOrName} (backend: ${backend})\n`);
|
|
110
|
+
process.stdout.write(`Saved to ${getConfigPath()}\n`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export default async function uncensored(args) {
|
|
114
|
+
if (args.has('help') || args.has('h')) {
|
|
115
|
+
process.stdout.write(HELP);
|
|
116
|
+
return 0;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (args.has('list')) {
|
|
120
|
+
printModelTable();
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const useOllama = args.has('ollama');
|
|
125
|
+
const force = args.has('force') || args.has('f');
|
|
126
|
+
|
|
127
|
+
// Detect VRAM
|
|
128
|
+
const cap = await detectCapacity();
|
|
129
|
+
const vramGb = cap.vram_gb;
|
|
130
|
+
|
|
131
|
+
if (vramGb > 0) {
|
|
132
|
+
process.stdout.write(`Detected ${vramGb.toFixed(1)} GB VRAM\n`);
|
|
133
|
+
} else if (cap.ram_gb > 0) {
|
|
134
|
+
process.stdout.write(`No GPU detected — ${cap.ram_gb.toFixed(1)} GB RAM available (CPU inference only)\n`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (useOllama) {
|
|
138
|
+
const m = pickOllamaModel(vramGb);
|
|
139
|
+
process.stdout.write(`\nSelected: ${m.name}\n`);
|
|
140
|
+
process.stdout.write(` ${m.description}\n`);
|
|
141
|
+
process.stdout.write(` size: ${m.sizeGb} GB\n\n`);
|
|
142
|
+
|
|
143
|
+
if (!force && vramGb > 0 && vramGb < m.minVramGb) {
|
|
144
|
+
process.stderr.write(
|
|
145
|
+
`warning: ${m.name} needs ~${m.minVramGb} GB VRAM but only ${vramGb.toFixed(1)} GB detected.\n` +
|
|
146
|
+
`Add --force to pull anyway.\n`
|
|
147
|
+
);
|
|
148
|
+
return 1;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
try {
|
|
152
|
+
await streamOllamaPull(m.name);
|
|
153
|
+
} catch (err) {
|
|
154
|
+
process.stderr.write(`error: ${err?.message ?? err}\n`);
|
|
155
|
+
return 1;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
await setActiveModel(m.name, 'ollama');
|
|
159
|
+
process.stdout.write(`\nReady. Start chatting:\n infernet chat\n\n`);
|
|
160
|
+
return 0;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// HuggingFace / vLLM path
|
|
164
|
+
const m = pickHfModel(vramGb);
|
|
165
|
+
process.stdout.write(`\nSelected: ${m.repoId}\n`);
|
|
166
|
+
process.stdout.write(` ${m.description}\n`);
|
|
167
|
+
process.stdout.write(` size: ~${m.sizeGb} GB (fp16) / ~${m.sizeGb4bit} GB (4-bit)\n`);
|
|
168
|
+
process.stdout.write(` min VRAM: ${m.minVramGb} GB\n\n`);
|
|
169
|
+
|
|
170
|
+
if (!force && vramGb > 0 && vramGb < m.minVramGb) {
|
|
171
|
+
process.stderr.write(
|
|
172
|
+
`warning: ${m.repoId} needs ~${m.minVramGb} GB VRAM but only ${vramGb.toFixed(1)} GB detected.\n` +
|
|
173
|
+
` Use --force to download anyway, or --ollama for a smaller Ollama model.\n`
|
|
174
|
+
);
|
|
175
|
+
return 1;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const token = await resolveHfToken();
|
|
179
|
+
|
|
180
|
+
// Fetch metadata
|
|
181
|
+
process.stdout.write(`Fetching metadata from HuggingFace…\n`);
|
|
182
|
+
let info;
|
|
183
|
+
try {
|
|
184
|
+
info = await fetchHfModelInfo(m.repoId, token);
|
|
185
|
+
} catch (err) {
|
|
186
|
+
process.stderr.write(`error: ${err?.message ?? err}\n`);
|
|
187
|
+
return 1;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
process.stdout.write(` pipeline: ${info.pipeline}\n`);
|
|
191
|
+
process.stdout.write(` license: ${info.license ?? 'unknown'}\n`);
|
|
192
|
+
if (info.downloads) process.stdout.write(` downloads: ${info.downloads.toLocaleString()}\n`);
|
|
193
|
+
process.stdout.write('\n');
|
|
194
|
+
|
|
195
|
+
// Download
|
|
196
|
+
let localPath;
|
|
197
|
+
try {
|
|
198
|
+
localPath = await downloadHfModel(m.repoId, token, {});
|
|
199
|
+
} catch (err) {
|
|
200
|
+
process.stderr.write(`error: ${err?.message ?? err}\n`);
|
|
201
|
+
return 1;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Save to config
|
|
205
|
+
const cfg = (await loadConfig()) ?? {};
|
|
206
|
+
const hfModels = cfg.engine?.hfModels ?? [];
|
|
207
|
+
const existing = hfModels.findIndex(e => e.repoId === m.repoId);
|
|
208
|
+
const entry = { repoId: m.repoId, localPath, sizeGb: info.sizeGb, pulledAt: new Date().toISOString() };
|
|
209
|
+
if (existing >= 0) hfModels[existing] = entry;
|
|
210
|
+
else hfModels.push(entry);
|
|
211
|
+
await saveConfig({ ...cfg, engine: { ...(cfg.engine ?? {}), hfModels, model: m.repoId, backend: 'vllm' } });
|
|
212
|
+
|
|
213
|
+
process.stdout.write(`\nDownloaded to: ${localPath}\n\n`);
|
|
214
|
+
process.stdout.write(`To serve this model (earn Infernet rewards):\n`);
|
|
215
|
+
process.stdout.write(` vllm serve ${m.repoId} --host 0.0.0.0 --port 8000\n\n`);
|
|
216
|
+
process.stdout.write(`Then register your node and start the daemon:\n`);
|
|
217
|
+
process.stdout.write(` infernet register\n`);
|
|
218
|
+
process.stdout.write(` infernet start\n\n`);
|
|
219
|
+
return 0;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export { HELP };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `infernet update` — pull the latest CLI and run autonomous post-upgrade setup.
|
|
3
|
+
*
|
|
4
|
+
* Pulls the latest binary via the official installer, then runs
|
|
5
|
+
* `infernet setup --yes` to regenerate keys, re-register specs, and
|
|
6
|
+
* restart the daemon. No manual steps needed.
|
|
7
|
+
*
|
|
8
|
+
* `infernet upgrade` is an alias for this command.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { spawn } from 'node:child_process';
|
|
12
|
+
import setup from './setup.js';
|
|
13
|
+
|
|
14
|
+
const HELP = `infernet update — pull latest CLI + autonomous post-upgrade setup
|
|
15
|
+
|
|
16
|
+
Usage:
|
|
17
|
+
infernet update [flags]
|
|
18
|
+
|
|
19
|
+
Flags:
|
|
20
|
+
--skip-setup Just re-run the installer; don't run setup afterward.
|
|
21
|
+
--help Show this help.
|
|
22
|
+
|
|
23
|
+
What it does (fully autonomous, no manual steps):
|
|
24
|
+
1. Re-runs the official installer — pulls the latest source from
|
|
25
|
+
infernetprotocol.com/install.sh, refreshes node_modules, re-writes
|
|
26
|
+
the wrapper. Idempotent.
|
|
27
|
+
2. Runs \`infernet setup --yes\` which:
|
|
28
|
+
- Generates any missing model keypairs (IPIP-0028)
|
|
29
|
+
- Re-registers specs with the control plane
|
|
30
|
+
- Restarts the daemon so the new code is live
|
|
31
|
+
- Verifies the heartbeat reaches the control plane
|
|
32
|
+
|
|
33
|
+
\`infernet upgrade\` is an alias for this command.
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
const INSTALLER_URL = "https://infernetprotocol.com/install.sh";
|
|
37
|
+
|
|
38
|
+
function runShell(cmd) {
|
|
39
|
+
return new Promise((resolve) => {
|
|
40
|
+
const child = spawn("sh", ["-c", cmd], { stdio: "inherit" });
|
|
41
|
+
child.on("exit", (code) => resolve(code ?? 1));
|
|
42
|
+
child.on("error", () => resolve(1));
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function pullLatestBinary() {
|
|
47
|
+
process.stdout.write(`\n→ Pulling latest CLI from ${INSTALLER_URL}\n\n`);
|
|
48
|
+
const code = await runShell(`curl -fsSL ${INSTALLER_URL} | sh`);
|
|
49
|
+
if (code !== 0) {
|
|
50
|
+
process.stderr.write(`\nerror: installer exited ${code}.\n`);
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default async function update(args, ctx) {
|
|
57
|
+
if (args.has('help') || args.has('h')) {
|
|
58
|
+
process.stdout.write(HELP);
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const ok = await pullLatestBinary();
|
|
63
|
+
if (!ok) return 1;
|
|
64
|
+
|
|
65
|
+
if (args.has('skip-setup')) {
|
|
66
|
+
process.stdout.write("\n✓ Binary updated (skipped setup).\n");
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
process.stdout.write("\n→ Running post-upgrade setup (keys + register + daemon restart)\n");
|
|
71
|
+
|
|
72
|
+
const setupArgs = new Map([['yes', true], ['confirm', true], ['skip-pull', true]]);
|
|
73
|
+
for (const k of ['port', 'address', 'no-advertise']) {
|
|
74
|
+
if (args.has(k)) setupArgs.set(k, args.get(k) ?? true);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return setup(setupArgs, ctx);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { HELP, INSTALLER_URL };
|