@infernetprotocol/cli 0.1.91 → 0.1.93
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/commands/chat.js +90 -1
- package/commands/help.js +1 -0
- package/commands/house-models.js +1 -2
- package/commands/mcp.js +26 -2
- package/commands/plugins.js +103 -0
- package/commands/setup.js +2 -4
- package/commands/start.js +1 -3
- package/index.js +3 -1
- package/lib/house-models.js +8 -12
- package/lib/plugins-client.js +78 -0
- package/package.json +9 -9
package/commands/chat.js
CHANGED
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
import { createEngine, MSG } from "@infernetprotocol/engine";
|
|
22
22
|
import { loadConfig } from "../lib/config.js";
|
|
23
23
|
import { submitChatJob, streamChatEvents } from "../lib/remote-chat.js";
|
|
24
|
+
import { createPluginsClient, readSse } from "../lib/plugins-client.js";
|
|
25
|
+
import { createInterface } from "node:readline/promises";
|
|
24
26
|
|
|
25
27
|
const HELP = `infernet chat — run a chat inference (P2P network or local)
|
|
26
28
|
|
|
@@ -44,6 +46,12 @@ Common flags:
|
|
|
44
46
|
|
|
45
47
|
Network-only flags:
|
|
46
48
|
--url <url> Control-plane URL override (default: config.controlPlane.url).
|
|
49
|
+
--no-plugins Do not use your plugins for this message (see \`infernet plugins\`).
|
|
50
|
+
--yes Allow plugin tools that change things without asking.
|
|
51
|
+
|
|
52
|
+
Plugins: when you are signed in (\`infernet login\`) and have plugins on, the
|
|
53
|
+
network turn runs with them: the model can call their tools, and tools that
|
|
54
|
+
change or delete things ask first. Plugin turns are sent in plaintext.
|
|
47
55
|
|
|
48
56
|
Local-only flags:
|
|
49
57
|
--backend <kind> ollama | mojo | stub. Default: auto.
|
|
@@ -126,6 +134,74 @@ async function runRemote({ baseUrl, messages, model, temperature, maxTokens, jso
|
|
|
126
134
|
return exitCode;
|
|
127
135
|
}
|
|
128
136
|
|
|
137
|
+
async function askApproval(call) {
|
|
138
|
+
if (!process.stdin.isTTY || !process.stderr.isTTY) return "deny";
|
|
139
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
140
|
+
try {
|
|
141
|
+
const args = JSON.stringify(call.arguments ?? {});
|
|
142
|
+
const a = await rl.question(`\n[plugin] allow ${call.pluginName || call.plugin} to run ${call.title || call.tool} ${args}? [y/N] `);
|
|
143
|
+
return /^y(es)?$/i.test(a.trim()) ? "allow" : "deny";
|
|
144
|
+
} finally {
|
|
145
|
+
rl.close();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** A network turn with your plugins: the server runs the tool loop, we render its events. */
|
|
150
|
+
async function runPluginChat({ baseUrl, token, messages, model, maxTokens, jsonMode, autoYes }) {
|
|
151
|
+
let body = { messages, plugins: true, ...(model ? { modelName: model } : {}), ...(typeof maxTokens === "number" ? { maxTokens } : {}) };
|
|
152
|
+
const tty = process.stdout.isTTY && !jsonMode;
|
|
153
|
+
for (let round = 0; round < 6; round++) {
|
|
154
|
+
const res = await fetch(new URL("/api/chat", baseUrl), {
|
|
155
|
+
method: "POST",
|
|
156
|
+
headers: { "content-type": "application/json", accept: "text/event-stream", authorization: `Bearer ${token}` },
|
|
157
|
+
body: JSON.stringify(body)
|
|
158
|
+
});
|
|
159
|
+
if (!res.ok || !(res.headers.get("content-type") ?? "").includes("text/event-stream")) {
|
|
160
|
+
const t = await res.text().catch(() => "");
|
|
161
|
+
let msg = t.slice(0, 300);
|
|
162
|
+
try { msg = JSON.parse(t).error ?? msg; } catch { /* text */ }
|
|
163
|
+
process.stderr.write(`error: ${msg || `HTTP ${res.status}`}\n`);
|
|
164
|
+
return 1;
|
|
165
|
+
}
|
|
166
|
+
let draft = "";
|
|
167
|
+
let printed = 0;
|
|
168
|
+
let pending = null;
|
|
169
|
+
let failed = false;
|
|
170
|
+
for await (const ev of readSse(res)) {
|
|
171
|
+
if (jsonMode) { emitJson(ev); }
|
|
172
|
+
if (ev.type === "step") { draft = ""; printed = 0; }
|
|
173
|
+
else if (ev.type === "token" && !jsonMode) {
|
|
174
|
+
draft += ev.text;
|
|
175
|
+
// Hold back a tool_call block; print prose as it streams.
|
|
176
|
+
const cut = draft.search(/```[ \t]*tool|<tool_call/i);
|
|
177
|
+
const shown = cut === -1 ? draft.replace(/`{1,3}$/, "") : draft.slice(0, cut);
|
|
178
|
+
if (shown.length > printed) { process.stdout.write(shown.slice(printed)); printed = shown.length; }
|
|
179
|
+
} else if (ev.type === "tool_call" && !jsonMode) {
|
|
180
|
+
if (printed) process.stdout.write("\n");
|
|
181
|
+
process.stderr.write(`[plugin] ${ev.plugin} · ${ev.title || ev.tool} ${JSON.stringify(ev.arguments ?? {})}\n`);
|
|
182
|
+
} else if (ev.type === "tool_result" && !jsonMode) {
|
|
183
|
+
const first = String(ev.text ?? "").split("\n").slice(0, 3).join(" ").slice(0, 200);
|
|
184
|
+
process.stderr.write(`[plugin] ${ev.denied ? "declined" : ev.isError ? "error" : "ok"}: ${first}\n`);
|
|
185
|
+
} else if (ev.type === "plugins_skipped" && !jsonMode) {
|
|
186
|
+
process.stderr.write(`[plugin] not used (sign in: infernet plugins connect <slug>): ${ev.skipped.map((s) => s.slug).join(", ")}\n`);
|
|
187
|
+
} else if (ev.type === "text" && !jsonMode) {
|
|
188
|
+
if (ev.text.length > printed) process.stdout.write(ev.text.slice(printed));
|
|
189
|
+
if (tty) process.stdout.write("\n");
|
|
190
|
+
} else if (ev.type === "approval_needed") {
|
|
191
|
+
pending = ev;
|
|
192
|
+
} else if (ev.type === "error") {
|
|
193
|
+
if (!jsonMode) process.stderr.write(`\nerror: ${ev.message}\n`);
|
|
194
|
+
failed = true;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (failed) return 1;
|
|
198
|
+
if (!pending) return 0;
|
|
199
|
+
const decision = autoYes ? "allow" : await askApproval(pending.call);
|
|
200
|
+
body = { plugins: true, resume: { approvalId: pending.approvalId, decision }, ...(model ? { modelName: model } : {}) };
|
|
201
|
+
}
|
|
202
|
+
return 0;
|
|
203
|
+
}
|
|
204
|
+
|
|
129
205
|
async function runLocal({ engineOpts, messages, model, temperature, maxTokens, jsonMode }) {
|
|
130
206
|
let engine;
|
|
131
207
|
try {
|
|
@@ -185,7 +261,7 @@ export default async function chat(args) {
|
|
|
185
261
|
|
|
186
262
|
// Reclaim values eaten by the greedy parser for known-boolean flags.
|
|
187
263
|
const reclaimed = [];
|
|
188
|
-
for (const name of ["json", "remote", "local"]) {
|
|
264
|
+
for (const name of ["json", "remote", "local", "no-plugins", "yes"]) {
|
|
189
265
|
const v = args.get(name);
|
|
190
266
|
if (typeof v === "string") reclaimed.push(v);
|
|
191
267
|
}
|
|
@@ -237,6 +313,19 @@ export default async function chat(args) {
|
|
|
237
313
|
);
|
|
238
314
|
return 2;
|
|
239
315
|
}
|
|
316
|
+
// Signed in with plugins on: the turn runs with them.
|
|
317
|
+
const token = config.auth?.bearerToken ?? null;
|
|
318
|
+
if (token && !args.has("no-plugins")) {
|
|
319
|
+
try {
|
|
320
|
+
const d = await createPluginsClient({ baseUrl: remoteUrl.replace(/\/+$/, ""), token }).list();
|
|
321
|
+
const usable = (d.plugins ?? []).filter((p) => p.enabled && !p.needs_sign_in);
|
|
322
|
+
if (usable.length) {
|
|
323
|
+
return runPluginChat({ baseUrl: remoteUrl, token, messages, model, maxTokens, jsonMode, autoYes: args.has("yes") });
|
|
324
|
+
}
|
|
325
|
+
} catch {
|
|
326
|
+
/* plugins unavailable: plain network turn */
|
|
327
|
+
}
|
|
328
|
+
}
|
|
240
329
|
return runRemote({
|
|
241
330
|
baseUrl: remoteUrl,
|
|
242
331
|
messages,
|
package/commands/help.js
CHANGED
|
@@ -41,6 +41,7 @@ Diagnostics:
|
|
|
41
41
|
Payments:
|
|
42
42
|
payout Earnings, withdrawals and payout address
|
|
43
43
|
payments Show recent payment transactions
|
|
44
|
+
plugins Tools the model can use in chat (remote MCP servers): add, ls, rm, on, off
|
|
44
45
|
credits Your consumer compute credits (not earnings); redeem a code
|
|
45
46
|
redeem Redeem a credit code: infernet redeem CR-XXXX-XXXX-XXXX-XXXX
|
|
46
47
|
invites Scarce invites (both sides get credits) and your affiliate link
|
package/commands/house-models.js
CHANGED
|
@@ -36,8 +36,7 @@ Flags:
|
|
|
36
36
|
--help Show this help
|
|
37
37
|
|
|
38
38
|
Environment (beats config.json): INFERNET_HOUSE_MODELS=0,
|
|
39
|
-
INFERNET_UNCENSORED_MODELS=
|
|
40
|
-
INFERNET_HOUSE_MODELS_MAX_GB=<n>.
|
|
39
|
+
INFERNET_UNCENSORED_MODELS=0, INFERNET_HOUSE_MODELS_MAX_GB=<n>.
|
|
41
40
|
|
|
42
41
|
House models are ON by default. The daemon checks
|
|
43
42
|
https://infernetprotocol.com/house-models.json on start and every 6 hours,
|
package/commands/mcp.js
CHANGED
|
@@ -15,6 +15,7 @@ import { resolveClientOptions, createReservationsClient } from '../lib/reservati
|
|
|
15
15
|
import { createOrdersClient, x402KeyFrom, DEFAULT_MAX_USD } from '../lib/orders-client.js';
|
|
16
16
|
import { resolveCreditsOptions, createCreditsClient } from '../lib/credits-client.js';
|
|
17
17
|
import { resolveBatchOptions, createBatchClient } from '../lib/batch-client.js';
|
|
18
|
+
import { resolvePluginsOptions, createPluginsClient } from '../lib/plugins-client.js';
|
|
18
19
|
import { CURRENT_VERSION } from '../lib/version.js';
|
|
19
20
|
|
|
20
21
|
const PROTOCOL_VERSION = '2025-06-18';
|
|
@@ -186,7 +187,29 @@ export const TOOLS = [
|
|
|
186
187
|
},
|
|
187
188
|
{ name: 'batch_status', description: 'A batch: status, item counts, cost so far, funding, and outputs once finished.', inputSchema: { type: 'object', required: ['id'], properties: { id: batchId } }, run: (c, a) => c.batch.status(a.id) },
|
|
188
189
|
{ name: 'batch_results', description: 'A batch\'s results as JSONL: custom_id, status, output, estimated tokens, cost.', inputSchema: { type: 'object', required: ['id'], properties: { id: batchId } }, run: (c, a) => c.batch.results(a.id) },
|
|
189
|
-
{ name: 'billing_balance', description: 'Your compute balance: earned (node earnings) spendable, prepaid available, holds, funding order.', inputSchema: { type: 'object', properties: {} }, run: (c) => c.batch.balance() }
|
|
190
|
+
{ name: 'billing_balance', description: 'Your compute balance: earned (node earnings) spendable, prepaid available, holds, funding order.', inputSchema: { type: 'object', properties: {} }, run: (c) => c.batch.balance() },
|
|
191
|
+
// Chat plugins (remote MCP servers on the signed-in account) used by /chat,
|
|
192
|
+
// `infernet chat` and the desktop app.
|
|
193
|
+
{
|
|
194
|
+
name: 'plugins_list',
|
|
195
|
+
description: 'Your chat plugins (remote MCP servers the Infernet chat model can use) with on/off and sign-in state, plus the catalog of one-click plugins.',
|
|
196
|
+
inputSchema: { type: 'object', properties: {} },
|
|
197
|
+
annotations: { readOnlyHint: true },
|
|
198
|
+
run: (c) => c.plugins.list()
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: 'plugins_add',
|
|
202
|
+
description: 'Add a chat plugin by URL (https://.../mcp) or catalog name (c0mpute, threatcrush). When it needs sign-in the result has connect_url: give that link to the person to open in a browser (valid 15 minutes). No client id or secret is needed.',
|
|
203
|
+
inputSchema: { type: 'object', required: ['url'], properties: { url: { type: 'string', description: 'plugin URL or catalog name' } } },
|
|
204
|
+
run: (c, a) => c.plugins.add(a.url)
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: 'plugins_remove',
|
|
208
|
+
description: 'Remove a chat plugin and its stored tokens.',
|
|
209
|
+
inputSchema: { type: 'object', required: ['slug'], properties: { slug: { type: 'string' } } },
|
|
210
|
+
annotations: { destructiveHint: true },
|
|
211
|
+
run: (c, a) => c.plugins.remove(a.slug)
|
|
212
|
+
}
|
|
190
213
|
];
|
|
191
214
|
|
|
192
215
|
/** Handle one JSON-RPC message; returns the response object or null for notifications. */
|
|
@@ -222,13 +245,14 @@ export async function handleMessage(msg, client) {
|
|
|
222
245
|
|
|
223
246
|
export default async function mcp(args) {
|
|
224
247
|
if (args.has('help') || args.has('h')) {
|
|
225
|
-
process.stdout.write('infernet mcp — MCP server (stdio): self-serve orders, managed-endpoint reservations, credits, invites
|
|
248
|
+
process.stdout.write('infernet mcp — MCP server (stdio): self-serve orders, managed-endpoint reservations, credits, invites, paid batch inference and chat plugins\n\n claude mcp add infernet -- infernet mcp\n');
|
|
226
249
|
return 0;
|
|
227
250
|
}
|
|
228
251
|
const client = createReservationsClient(await resolveClientOptions({ url: args.get('url'), token: args.get('token'), buyerToken: args.get('buyer-token') }));
|
|
229
252
|
client.orders = createOrdersClient({ baseUrl: (await resolveClientOptions({ url: args.get('url') })).baseUrl });
|
|
230
253
|
client.credits = createCreditsClient(await resolveCreditsOptions({ url: args.get('url'), token: args.get('token') }));
|
|
231
254
|
client.batch = createBatchClient(await resolveBatchOptions({ url: args.get('url'), key: args.get('key'), token: args.get('token') }));
|
|
255
|
+
client.plugins = createPluginsClient(await resolvePluginsOptions({ url: args.get('url'), token: args.get('token') }));
|
|
232
256
|
const rl = createInterface({ input: process.stdin });
|
|
233
257
|
for await (const line of rl) {
|
|
234
258
|
if (!line.trim()) continue;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `infernet plugins` — chat plugins: remote MCP servers the model can use in
|
|
3
|
+
* `infernet chat`, /chat on the site, and the desktop app.
|
|
4
|
+
*
|
|
5
|
+
* infernet plugins list yours (and the catalog)
|
|
6
|
+
* infernet plugins add <url|name> add one; opens the browser to sign in if it asks
|
|
7
|
+
* infernet plugins rm <slug> remove
|
|
8
|
+
* infernet plugins on|off <slug> turn on or off
|
|
9
|
+
* infernet plugins connect <slug> sign in again
|
|
10
|
+
*/
|
|
11
|
+
import { createPluginsClient, openBrowser, resolvePluginsOptions } from '../lib/plugins-client.js';
|
|
12
|
+
|
|
13
|
+
export const PLUGINS_HELP = `infernet plugins — tools the model can use in chat (remote MCP servers)
|
|
14
|
+
|
|
15
|
+
Usage:
|
|
16
|
+
infernet plugins Your plugins and the catalog
|
|
17
|
+
infernet plugins add <url|name> Add by URL (https://.../mcp) or catalog name (c0mpute, threatcrush).
|
|
18
|
+
If it wants sign-in, a browser opens on its own page; on a
|
|
19
|
+
headless box the one-time link is printed instead.
|
|
20
|
+
infernet plugins rm <slug> Remove a plugin and its tokens
|
|
21
|
+
infernet plugins on <slug> Turn on
|
|
22
|
+
infernet plugins off <slug> Turn off
|
|
23
|
+
infernet plugins connect <slug> Sign in (again)
|
|
24
|
+
|
|
25
|
+
Options: --json, --url <base>, --token <bearer>, --no-browser
|
|
26
|
+
Signed-in account required (\`infernet login\`). \`infernet chat\` uses enabled plugins automatically.
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
function out(args, data, text) {
|
|
30
|
+
process.stdout.write(args.has('json') ? `${JSON.stringify(data, null, 2)}\n` : `${text}\n`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function line(p) {
|
|
34
|
+
const state = p.needs_sign_in ? 'needs sign-in' : p.enabled ? 'on' : 'off';
|
|
35
|
+
return ` ${p.slug.padEnd(16)} ${state.padEnd(14)} ${String(p.tools.length).padStart(3)} tools ${p.name} ${p.url}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function signInHint(args, url) {
|
|
39
|
+
const opened = !args.has('no-browser') && openBrowser(url);
|
|
40
|
+
return opened
|
|
41
|
+
? `Opened your browser to sign in. If nothing appeared, open:\n ${url}`
|
|
42
|
+
: `Open this link in any browser to sign in (valid 15 minutes):\n ${url}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default async function plugins(args) {
|
|
46
|
+
const [sub = 'ls', ...rest] = args.positional ?? [];
|
|
47
|
+
if (args.has('help') || args.has('h') || sub === 'help') {
|
|
48
|
+
process.stdout.write(PLUGINS_HELP);
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
const c = createPluginsClient(await resolvePluginsOptions({ url: args.get('url'), token: args.get('token') }));
|
|
52
|
+
const arg = rest.join(' ').trim();
|
|
53
|
+
try {
|
|
54
|
+
if (sub === 'ls' || sub === 'list') {
|
|
55
|
+
const d = await c.list();
|
|
56
|
+
const mine = d.plugins ?? [];
|
|
57
|
+
const have = new Set(mine.map((p) => p.url));
|
|
58
|
+
const text = [
|
|
59
|
+
mine.length ? 'Your plugins:' : 'No plugins yet.',
|
|
60
|
+
...mine.map(line),
|
|
61
|
+
'',
|
|
62
|
+
'Catalog (infernet plugins add <name>):',
|
|
63
|
+
...(d.catalog ?? []).map((e) => ` ${e.slug.padEnd(16)} ${have.has(e.url) ? 'added' : ' '} ${e.name}: ${e.description ?? e.url}`)
|
|
64
|
+
].join('\n');
|
|
65
|
+
out(args, d, text);
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
if (sub === 'add' || sub === 'install') {
|
|
69
|
+
if (!arg) { process.stderr.write('Usage: infernet plugins add <url|name>\n'); return 2; }
|
|
70
|
+
const r = await c.add(arg);
|
|
71
|
+
const p = r.plugin;
|
|
72
|
+
let text = r.already ? `${p.name} (${p.slug}) is already added.` : `Added ${p.name} (${p.slug}), ${p.tools.length} tools.`;
|
|
73
|
+
if (r.connect_url && p.needs_sign_in) text += `\n${signInHint(args, r.connect_url)}`;
|
|
74
|
+
else if (r.connect_url && p.can_sign_in) text += `\nIt also offers sign-in for more tools: infernet plugins connect ${p.slug}`;
|
|
75
|
+
out(args, r, text);
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
if (sub === 'connect' || sub === 'login') {
|
|
79
|
+
if (!arg) { process.stderr.write('Usage: infernet plugins connect <slug>\n'); return 2; }
|
|
80
|
+
const r = await c.add((await c.list()).plugins.find((p) => p.slug === arg)?.url ?? arg);
|
|
81
|
+
if (!r.connect_url) { out(args, r, `${r.plugin.name} does not use sign-in.`); return 0; }
|
|
82
|
+
out(args, r, signInHint(args, r.connect_url));
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
if (sub === 'rm' || sub === 'remove' || sub === 'delete') {
|
|
86
|
+
if (!arg) { process.stderr.write('Usage: infernet plugins rm <slug>\n'); return 2; }
|
|
87
|
+
out(args, await c.remove(arg), `Removed ${arg}.`);
|
|
88
|
+
return 0;
|
|
89
|
+
}
|
|
90
|
+
if (sub === 'on' || sub === 'off' || sub === 'enable' || sub === 'disable') {
|
|
91
|
+
if (!arg) { process.stderr.write(`Usage: infernet plugins ${sub} <slug>\n`); return 2; }
|
|
92
|
+
const on = sub === 'on' || sub === 'enable';
|
|
93
|
+
const p = await c.toggle(arg, on);
|
|
94
|
+
out(args, p, `${p.slug} is ${p.enabled ? 'on' : 'off'}.`);
|
|
95
|
+
return 0;
|
|
96
|
+
}
|
|
97
|
+
process.stderr.write(`Unknown subcommand: ${sub}\n\n${PLUGINS_HELP}`);
|
|
98
|
+
return 2;
|
|
99
|
+
} catch (err) {
|
|
100
|
+
process.stderr.write(`${err.message}\n`);
|
|
101
|
+
return 1;
|
|
102
|
+
}
|
|
103
|
+
}
|
package/commands/setup.js
CHANGED
|
@@ -50,8 +50,7 @@ Flags:
|
|
|
50
50
|
--no-abliterated Don't default to the abliterated (uncensored) model
|
|
51
51
|
when it fits; pick the largest stock Qwen instead.
|
|
52
52
|
--no-house-models Don't pull Infernet house models (saved to config).
|
|
53
|
-
--uncensored-models
|
|
54
|
-
--no-uncensored-models Skip uncensored house models (the default; saved to config).
|
|
53
|
+
--no-uncensored-models Skip uncensored house models only (saved to config).
|
|
55
54
|
--house-models-max-gb <n>
|
|
56
55
|
Cap the disk house models may use (saved to config).
|
|
57
56
|
--backend <kind> Pin engine backend (vllm | ollama | mojo | stub). Default: auto (prefers vLLM, falls back to Ollama).
|
|
@@ -862,7 +861,6 @@ export default async function setup(args) {
|
|
|
862
861
|
if (isProvider) {
|
|
863
862
|
const patch = {};
|
|
864
863
|
if (args.has("no-house-models")) patch.enabled = false;
|
|
865
|
-
if (args.has("uncensored-models")) patch.uncensored = true;
|
|
866
864
|
if (args.has("no-uncensored-models")) patch.uncensored = false;
|
|
867
865
|
const capArg = Number(args.get("house-models-max-gb"));
|
|
868
866
|
if (args.get("house-models-max-gb") !== undefined && Number.isFinite(capArg)) patch.maxDiskGb = capArg;
|
|
@@ -993,7 +991,7 @@ export default async function setup(args) {
|
|
|
993
991
|
ok(`house models: ON — this node will pull the models listed at ${hs.manifestUrl}`);
|
|
994
992
|
process.stdout.write(` that fit it (RAM, and always leaving 10% of the disk free, 10-50 GB${hs.maxDiskGb != null ? `, capped at ${hs.maxDiskGb} GB` : ""}),\n`);
|
|
995
993
|
process.stdout.write(` in the background, and serve them on Infernet. Uncensored house models: ${hs.uncensored ? "on" : "off"}.\n`);
|
|
996
|
-
process.stdout.write(" Opt out: infernet house-models off (uncensored
|
|
994
|
+
process.stdout.write(" Opt out: infernet house-models off (uncensored only: infernet house-models uncensored off)\n");
|
|
997
995
|
} else {
|
|
998
996
|
ok("house models: off (turn on with `infernet house-models on`)");
|
|
999
997
|
}
|
package/commands/start.js
CHANGED
|
@@ -87,8 +87,7 @@ Flags:
|
|
|
87
87
|
--once Run one heartbeat + one poll and exit (debug)
|
|
88
88
|
--no-house-models Don't pull Infernet house models for this run
|
|
89
89
|
(persist with \`infernet house-models off\`)
|
|
90
|
-
--uncensored-models
|
|
91
|
-
--no-uncensored-models Skip uncensored house models (the default)
|
|
90
|
+
--no-uncensored-models Skip uncensored house models only
|
|
92
91
|
--house-models-max-gb <n> Cap the disk house models may use
|
|
93
92
|
--help Show this help
|
|
94
93
|
|
|
@@ -173,7 +172,6 @@ function passthroughArgs(args) {
|
|
|
173
172
|
if (args.has('no-advertise')) passthrough.push('--no-advertise');
|
|
174
173
|
if (args.has('once')) passthrough.push('--once');
|
|
175
174
|
if (args.has('no-house-models')) passthrough.push('--no-house-models');
|
|
176
|
-
if (args.has('uncensored-models')) passthrough.push('--uncensored-models');
|
|
177
175
|
if (args.has('no-uncensored-models')) passthrough.push('--no-uncensored-models');
|
|
178
176
|
const houseCap = args.get('house-models-max-gb');
|
|
179
177
|
if (houseCap) passthrough.push('--house-models-max-gb', houseCap);
|
package/index.js
CHANGED
|
@@ -56,6 +56,7 @@ import mcp from './commands/mcp.js';
|
|
|
56
56
|
import credits, { invites, redeem } from './commands/credits.js';
|
|
57
57
|
import batch, { billing, keys } from './commands/batch.js';
|
|
58
58
|
import price from './commands/price.js';
|
|
59
|
+
import plugins from './commands/plugins.js';
|
|
59
60
|
|
|
60
61
|
function parseArgs(argv) {
|
|
61
62
|
const positional = [];
|
|
@@ -119,11 +120,12 @@ const COMMANDS = {
|
|
|
119
120
|
start, status, stop, restart, stats, logs,
|
|
120
121
|
payout, payments, gpu, firewall, chat, setup, model, train, publish, inference, rpc, uncensored, reservation, reservations: reservation, order, orders: order, mcp, credits, invites, redeem, batch, batches: batch, billing, keys, tui, doctor, service, pubkey, debug, deploy, console: consoleCmd, help,
|
|
121
122
|
price, prices: price,
|
|
123
|
+
plugins, plugin: plugins,
|
|
122
124
|
'house-models': houseModels, house: houseModels
|
|
123
125
|
};
|
|
124
126
|
|
|
125
127
|
// Commands that can run without a loaded config.
|
|
126
|
-
const NO_CONFIG = new Set(['init', 'login', 'help', 'stats', 'logs', 'stop', 'restart', 'gpu', 'firewall', 'chat', 'setup', 'model', 'train', 'publish', 'inference', 'rpc', 'uncensored', 'reservation', 'reservations', 'order', 'orders', 'mcp', 'credits', 'invites', 'redeem', 'batch', 'batches', 'billing', 'keys', 'tui', 'doctor', 'service', 'pubkey', 'debug', 'deploy', 'console', 'upgrade', 'update', 'remove', 'uninstall', 'house-models', 'house', 'price', 'prices']);
|
|
128
|
+
const NO_CONFIG = new Set(['init', 'login', 'help', 'stats', 'logs', 'stop', 'restart', 'gpu', 'firewall', 'chat', 'setup', 'model', 'train', 'publish', 'inference', 'rpc', 'uncensored', 'reservation', 'reservations', 'order', 'orders', 'mcp', 'credits', 'invites', 'redeem', 'batch', 'batches', 'billing', 'keys', 'tui', 'doctor', 'service', 'pubkey', 'debug', 'deploy', 'console', 'upgrade', 'update', 'remove', 'uninstall', 'house-models', 'house', 'price', 'prices', 'plugins', 'plugin']);
|
|
127
129
|
// Commands that need a config but not a control-plane client (none today
|
|
128
130
|
// — kept as a future escape hatch).
|
|
129
131
|
const NO_CLIENT = new Set();
|
package/lib/house-models.js
CHANGED
|
@@ -19,10 +19,9 @@
|
|
|
19
19
|
* (10% of the disk, at least 10 GB, at most 50 GB), and house models as a
|
|
20
20
|
* whole stay under the operator's disk cap if one is set.
|
|
21
21
|
* - Opt out of everything with `--no-house-models`, `infernet house-models
|
|
22
|
-
* off` or INFERNET_HOUSE_MODELS=0
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* the daemon pulled.
|
|
22
|
+
* off` or INFERNET_HOUSE_MODELS=0; opt out of uncensored ones only with
|
|
23
|
+
* `--no-uncensored-models`, `infernet house-models uncensored off` or
|
|
24
|
+
* INFERNET_UNCENSORED_MODELS=0. Opting out removes what the daemon pulled.
|
|
26
25
|
*/
|
|
27
26
|
|
|
28
27
|
import fs from 'node:fs/promises';
|
|
@@ -160,17 +159,15 @@ export async function fetchManifest({ url = DEFAULT_MANIFEST_URL, fetchImpl = fe
|
|
|
160
159
|
}
|
|
161
160
|
|
|
162
161
|
/**
|
|
163
|
-
* Effective settings: CLI flags beat env, env beats config.json
|
|
164
|
-
* default ON
|
|
165
|
-
* (`--uncensored-models`, `infernet house-models uncensored on`,
|
|
166
|
-
* INFERNET_UNCENSORED_MODELS=1), so nobody serves them without choosing to.
|
|
162
|
+
* Effective settings: CLI flags beat env, env beats config.json, and the
|
|
163
|
+
* default is ON (house models and uncensored house models both).
|
|
167
164
|
*/
|
|
168
165
|
export function resolveSettings({ config = {}, env = process.env, args = null } = {}) {
|
|
169
166
|
const cfg = config?.houseModels ?? {};
|
|
170
167
|
let enabled = cfg.enabled !== false;
|
|
171
|
-
let uncensored = cfg.uncensored
|
|
168
|
+
let uncensored = cfg.uncensored !== false;
|
|
172
169
|
let maxDiskGb = Number.isFinite(Number(cfg.maxDiskGb)) && cfg.maxDiskGb !== null ? Number(cfg.maxDiskGb) : null;
|
|
173
|
-
const sources = { enabled: cfg.enabled === false ? 'config' : 'default', uncensored:
|
|
170
|
+
const sources = { enabled: cfg.enabled === false ? 'config' : 'default', uncensored: cfg.uncensored === false ? 'config' : 'default' };
|
|
174
171
|
|
|
175
172
|
if (isOff(env.INFERNET_HOUSE_MODELS)) { enabled = false; sources.enabled = 'env INFERNET_HOUSE_MODELS'; }
|
|
176
173
|
else if (isOn(env.INFERNET_HOUSE_MODELS)) { enabled = true; sources.enabled = 'env INFERNET_HOUSE_MODELS'; }
|
|
@@ -184,7 +181,6 @@ export function resolveSettings({ config = {}, env = process.env, args = null }
|
|
|
184
181
|
}
|
|
185
182
|
|
|
186
183
|
if (args?.has?.('no-house-models')) { enabled = false; sources.enabled = '--no-house-models'; }
|
|
187
|
-
if (args?.has?.('uncensored-models')) { uncensored = true; sources.uncensored = '--uncensored-models'; }
|
|
188
184
|
if (args?.has?.('no-uncensored-models')) { uncensored = false; sources.uncensored = '--no-uncensored-models'; }
|
|
189
185
|
const argCap = Number(args?.get?.('house-models-max-gb'));
|
|
190
186
|
if (Number.isFinite(argCap) && args?.get?.('house-models-max-gb') !== undefined) maxDiskGb = argCap;
|
|
@@ -614,6 +610,6 @@ export function formatStatus({ settings, state, installed = null }) {
|
|
|
614
610
|
lines.push(` last sync: ${ls.at}${ls.errors?.length ? `, ${ls.errors.length} error(s): ${ls.errors.map((e) => `${e.name ?? 'manifest'}: ${e.error}`).join('; ')}` : ''}`);
|
|
615
611
|
for (const s of ls.skipped ?? []) lines.push(` skipped ${s.name}: ${s.reason}`);
|
|
616
612
|
}
|
|
617
|
-
lines.push(' opt out: infernet house-models off | uncensored
|
|
613
|
+
lines.push(' opt out: infernet house-models off | uncensored only: infernet house-models uncensored off');
|
|
618
614
|
return lines.join('\n');
|
|
619
615
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for chat plugins (remote MCP servers on your account), shared by
|
|
3
|
+
* `infernet plugins`, `infernet chat` and `infernet mcp`.
|
|
4
|
+
*
|
|
5
|
+
* Base URL: --url, INFERNET_URL, config.controlPlane.url, else infernetprotocol.com
|
|
6
|
+
* Auth: the `infernet login` bearer (config.auth.bearerToken) or --token
|
|
7
|
+
*/
|
|
8
|
+
import { spawn } from 'node:child_process';
|
|
9
|
+
import { loadConfig } from './config.js';
|
|
10
|
+
|
|
11
|
+
const DEFAULT_URL = 'https://infernetprotocol.com';
|
|
12
|
+
|
|
13
|
+
export async function resolvePluginsOptions(opts = {}) {
|
|
14
|
+
const config = await loadConfig().catch(() => null);
|
|
15
|
+
return {
|
|
16
|
+
baseUrl: String(opts.url || process.env.INFERNET_URL || config?.controlPlane?.url || DEFAULT_URL).replace(/\/+$/, ''),
|
|
17
|
+
token: opts.token || config?.auth?.bearerToken || null
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function createPluginsClient({ baseUrl, token, fetchImpl = fetch }) {
|
|
22
|
+
async function call(method, path, body) {
|
|
23
|
+
if (!token) throw new Error('not signed in: run `infernet login` first');
|
|
24
|
+
const headers = { accept: 'application/json', authorization: `Bearer ${token}` };
|
|
25
|
+
if (body !== undefined) headers['content-type'] = 'application/json';
|
|
26
|
+
const res = await fetchImpl(`${baseUrl}${path}`, { method, headers, body: body === undefined ? undefined : JSON.stringify(body) });
|
|
27
|
+
const text = await res.text();
|
|
28
|
+
let json = null;
|
|
29
|
+
try { json = text ? JSON.parse(text) : null; } catch { /* non-JSON */ }
|
|
30
|
+
if (!res.ok) {
|
|
31
|
+
const err = new Error(json?.error ?? `${method} ${path} -> HTTP ${res.status} ${text.slice(0, 200)}`);
|
|
32
|
+
err.status = res.status;
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
return json?.data ?? json;
|
|
36
|
+
}
|
|
37
|
+
const enc = encodeURIComponent;
|
|
38
|
+
return {
|
|
39
|
+
list: () => call('GET', '/api/v1/plugins'),
|
|
40
|
+
add: (url) => call('POST', '/api/v1/plugins', { url }),
|
|
41
|
+
remove: (slug) => call('DELETE', `/api/v1/plugins/${enc(slug)}`),
|
|
42
|
+
toggle: (slug, enabled) => call('POST', `/api/v1/plugins/${enc(slug)}/toggle`, typeof enabled === 'boolean' ? { enabled } : {}),
|
|
43
|
+
connectUrl: (slug) => `${baseUrl}/api/v1/plugins/${enc(slug)}/connect`
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Open a URL in the default browser; false when there is no way to (headless box). */
|
|
48
|
+
export function openBrowser(url) {
|
|
49
|
+
if (process.env.INFERNET_NO_BROWSER === '1') return false;
|
|
50
|
+
const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open';
|
|
51
|
+
const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url];
|
|
52
|
+
if (process.platform === 'linux' && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY) return false;
|
|
53
|
+
try {
|
|
54
|
+
const child = spawn(cmd, args, { stdio: 'ignore', detached: true });
|
|
55
|
+
child.on('error', () => {});
|
|
56
|
+
child.unref();
|
|
57
|
+
return true;
|
|
58
|
+
} catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Parse an SSE body into JSON events. */
|
|
64
|
+
export async function* readSse(res) {
|
|
65
|
+
const decoder = new TextDecoder();
|
|
66
|
+
let buf = '';
|
|
67
|
+
for await (const chunk of res.body) {
|
|
68
|
+
buf += decoder.decode(chunk, { stream: true });
|
|
69
|
+
let idx;
|
|
70
|
+
while ((idx = buf.indexOf('\n\n')) !== -1) {
|
|
71
|
+
const frame = buf.slice(0, idx);
|
|
72
|
+
buf = buf.slice(idx + 2);
|
|
73
|
+
const data = frame.split('\n').filter((l) => l.startsWith('data:')).map((l) => l.slice(5).trimStart()).join('\n');
|
|
74
|
+
if (!data) continue;
|
|
75
|
+
try { yield JSON.parse(data); } catch { /* skip */ }
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infernetprotocol/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.93",
|
|
4
4
|
"description": "GPU-node CLI / daemon for the Infernet Protocol — register a GPU server with a Supabase control plane and start earning.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"ora": "^9.4.1",
|
|
33
33
|
"react": "^17.0.2",
|
|
34
34
|
"react-blessed": "^0.7.2",
|
|
35
|
-
"@infernetprotocol/auth": "0.1.
|
|
36
|
-
"@infernetprotocol/config": "0.1.
|
|
37
|
-
"@infernetprotocol/deploy-providers": "0.1.
|
|
38
|
-
"@infernetprotocol/engine": "0.1.
|
|
39
|
-
"@infernetprotocol/gpu": "0.1.
|
|
40
|
-
"@infernetprotocol/liquid-agent": "0.1.
|
|
41
|
-
"@infernetprotocol/rpc-adapter": "0.1.
|
|
42
|
-
"@infernetprotocol/training": "0.1.
|
|
35
|
+
"@infernetprotocol/auth": "0.1.93",
|
|
36
|
+
"@infernetprotocol/config": "0.1.93",
|
|
37
|
+
"@infernetprotocol/deploy-providers": "0.1.93",
|
|
38
|
+
"@infernetprotocol/engine": "0.1.93",
|
|
39
|
+
"@infernetprotocol/gpu": "0.1.93",
|
|
40
|
+
"@infernetprotocol/liquid-agent": "0.1.93",
|
|
41
|
+
"@infernetprotocol/rpc-adapter": "0.1.93",
|
|
42
|
+
"@infernetprotocol/training": "0.1.93"
|
|
43
43
|
},
|
|
44
44
|
"repository": {
|
|
45
45
|
"type": "git",
|