@infernetprotocol/cli 0.1.73 → 0.1.79

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.
@@ -0,0 +1,213 @@
1
+ /**
2
+ * `infernet batch` / `infernet billing` / `infernet keys` — paid batch
3
+ * inference on the network. Talks to /api/v1/batches/*, /api/v1/billing/*
4
+ * and /api/v1/keys.
5
+ */
6
+ import { randomUUID } from 'node:crypto';
7
+ import { resolveBatchOptions, createBatchClient, readBatchFile, formatBillingBalance } from '../lib/batch-client.js';
8
+
9
+ export const BATCH_HELP = `infernet batch — paid batch inference
10
+
11
+ Many chat requests in one job, prepaid, priced per token. The server holds the
12
+ most the batch can cost up front (input estimate + max_tokens x output price),
13
+ charges each item what it really produced and releases the rest. Token counts
14
+ are server-side estimates: ceil(characters / 4).
15
+
16
+ Input: a JSONL file, one request per line:
17
+ {"custom_id":"q1","messages":[{"role":"user","content":"hi"}],"max_tokens":256}
18
+
19
+ Usage:
20
+ infernet batch quote <file.jsonl> --model qwen2.5:7b max cost, no spend
21
+ infernet batch submit <file.jsonl> --model qwen2.5:7b --max-cost 2.50
22
+ [--funding earned_first|prepaid_first|earned_only|prepaid_only|no_wallet]
23
+ [--idempotency-key K] default: a new uuid (printed; reuse it to retry safely)
24
+ infernet batch status <batch id>
25
+ infernet batch results <batch id> [--out file.jsonl]
26
+ infernet batch receipt <batch id>
27
+ infernet batch cancel <batch id>
28
+
29
+ Auth: INFERNET_API_KEY=ik_live_... (infernet keys create) or \`infernet login\`.
30
+ Options: --json, --url <base>, --key <ik_live_...>
31
+ `;
32
+
33
+ export const BILLING_HELP = `infernet billing — the balance batch inference spends
34
+
35
+ Usage:
36
+ infernet billing balance earned (node earnings), prepaid, holds
37
+ infernet billing topup <usd> CoinPay checkout URL (any coin or PayPal)
38
+ infernet billing topup-status <id> credited once CoinPay confirms payment
39
+ infernet billing funding earned,prepaid,wallet set your default funding order
40
+
41
+ Earned = your confirmed node earnings (c0mpute and Infernet nodes are one
42
+ balance), spendable on compute with no fee; whatever you do not spend stays
43
+ withdrawable with \`infernet payout\`.
44
+ `;
45
+
46
+ export const KEYS_HELP = `infernet keys — API keys for the batch API (needs \`infernet login\`)
47
+
48
+ Usage:
49
+ infernet keys create [--name <label>] prints the key once
50
+ infernet keys list
51
+ infernet keys revoke <key id>
52
+ `;
53
+
54
+ async function client(args) {
55
+ return createBatchClient(await resolveBatchOptions({ url: args.get('url'), key: args.get('key'), token: args.get('token') }));
56
+ }
57
+
58
+ function out(args, data, text) {
59
+ process.stdout.write(args.has('json') ? `${JSON.stringify(data, null, 2)}\n` : `${text}\n`);
60
+ }
61
+
62
+ function batchLine(b) {
63
+ const c = b.counts ?? {};
64
+ return `${b.id} ${b.status}${b.cancelling ? ' (cancelling)' : ''} ${b.model} ${c.completed ?? 0}/${c.total ?? 0} done, ${c.failed ?? 0} failed, ${c.queued ?? 0} queued cost $${b.cost_so_far_usd} of max $${b.max_cost_usd}`;
65
+ }
66
+
67
+ export async function batch(args) {
68
+ const [sub, a1] = args.positional;
69
+ if (!sub || args.has('help') || sub === 'help') {
70
+ process.stdout.write(BATCH_HELP);
71
+ return sub || args.has('help') ? 0 : 1;
72
+ }
73
+ const c = await client(args);
74
+ switch (sub) {
75
+ case 'quote': {
76
+ if (!a1 || !args.get('model')) throw new Error('usage: infernet batch quote <file.jsonl> --model <model>');
77
+ const q = await c.quote({ model: args.get('model'), items: readBatchFile(a1) });
78
+ out(args, q, `${q.item_count} items on ${q.model}: at most $${q.total_max_cost_usd} (input ~${q.estimated_input_tokens} tokens, up to ${q.max_output_tokens} output)\nquote ${q.quote_id}, valid until ${q.expires_at}\n${q.token_counts}`);
79
+ return 0;
80
+ }
81
+ case 'submit': {
82
+ if (!a1 || !args.get('model')) throw new Error('usage: infernet batch submit <file.jsonl> --model <model> --max-cost <usd>');
83
+ const maxCost = args.get('max-cost');
84
+ if (!maxCost) throw new Error('--max-cost <usd> is required: the most this batch may cost');
85
+ const key = args.get('idempotency-key') || randomUUID();
86
+ const body = { model: args.get('model'), items: readBatchFile(a1), max_cost_usd: String(maxCost), idempotency_key: key };
87
+ if (args.get('funding')) body.funding = args.get('funding');
88
+ try {
89
+ const b = await c.submit(body);
90
+ out(args, { ...b, idempotency_key: key }, `${batchLine(b)}\nidempotency key ${key}\nthen: infernet batch status ${b.id}`);
91
+ return 0;
92
+ } catch (err) {
93
+ if (err.status === 402 && err.body) {
94
+ const x = err.body;
95
+ process.stderr.write(`${x.error}: need $${x.needed_usd}, short $${x.shortfall_usd} (earned $${x.earned_spendable_usd}, prepaid $${x.prepaid_available_usd})\n`);
96
+ process.stderr.write(`top up: infernet billing topup <usd>, then retry with --idempotency-key ${key}\n`);
97
+ return 1;
98
+ }
99
+ throw err;
100
+ }
101
+ }
102
+ case 'status': {
103
+ if (!a1) throw new Error('usage: infernet batch status <batch id>');
104
+ const b = await c.status(a1);
105
+ out(args, b, batchLine(b));
106
+ return 0;
107
+ }
108
+ case 'results': {
109
+ if (!a1) throw new Error('usage: infernet batch results <batch id>');
110
+ const text = await c.results(a1);
111
+ if (args.get('out')) {
112
+ const { writeFileSync } = await import('node:fs');
113
+ writeFileSync(args.get('out'), text);
114
+ process.stdout.write(`wrote ${text.split('\n').filter(Boolean).length} lines to ${args.get('out')}\n`);
115
+ } else {
116
+ process.stdout.write(text);
117
+ }
118
+ return 0;
119
+ }
120
+ case 'receipt': {
121
+ if (!a1) throw new Error('usage: infernet batch receipt <batch id>');
122
+ const r = await c.receipt(a1);
123
+ out(args, r, [
124
+ `batch ${r.batch_id} ${r.model} ${r.status}`,
125
+ `items ${r.items.completed}/${r.items.total} completed, ${r.items.failed} failed, ${r.items.cancelled} cancelled`,
126
+ `estimated tokens: ${r.estimated_input_tokens} in, ${r.estimated_output_tokens} out at $${r.price.input_per_m_usd}/$${r.price.output_per_m_usd} per 1M`,
127
+ `charged $${r.total_charged_usd} (provider $${r.provider_share_usd}, platform $${r.platform_fee_usd}); released $${r.released_usd}`,
128
+ `paid from: earned $${r.funding.paid_from.earned_usd}, prepaid $${r.funding.paid_from.prepaid_usd}, wallet $${r.funding.paid_from.wallet_usd}; returned to earnings $${r.funding.returned_to_earnings_usd}`
129
+ ].join('\n'));
130
+ return 0;
131
+ }
132
+ case 'cancel': {
133
+ if (!a1) throw new Error('usage: infernet batch cancel <batch id>');
134
+ const r = await c.cancel(a1);
135
+ out(args, r, `cancelled ${r.cancelled_items} queued items\n${batchLine(r.batch)}`);
136
+ return 0;
137
+ }
138
+ default:
139
+ process.stderr.write(`unknown subcommand: ${sub}\n\n${BATCH_HELP}`);
140
+ return 1;
141
+ }
142
+ }
143
+
144
+ export async function billing(args) {
145
+ const [sub, a1] = args.positional;
146
+ if (args.has('help') || sub === 'help') {
147
+ process.stdout.write(BILLING_HELP);
148
+ return 0;
149
+ }
150
+ const c = await client(args);
151
+ switch (sub ?? 'balance') {
152
+ case 'balance': {
153
+ const b = await c.balance();
154
+ out(args, b, formatBillingBalance(b));
155
+ return 0;
156
+ }
157
+ case 'topup': {
158
+ if (!a1) throw new Error('usage: infernet billing topup <usd>');
159
+ const t = await c.topup(a1);
160
+ out(args, t, `pay here: ${t.checkout_url}\nthen: infernet billing topup-status ${t.topup.id}`);
161
+ return 0;
162
+ }
163
+ case 'topup-status': {
164
+ if (!a1) throw new Error('usage: infernet billing topup-status <id>');
165
+ const t = await c.topupStatus(a1);
166
+ out(args, t, `top-up ${t.id}: ${t.status} $${t.amount_usd}${t.credited ? ' (credited now)' : ''}`);
167
+ return 0;
168
+ }
169
+ case 'funding': {
170
+ if (!a1) throw new Error('usage: infernet billing funding earned,prepaid,wallet');
171
+ const r = await c.setFunding(String(a1).split(',').map((s) => s.trim()).filter(Boolean));
172
+ out(args, r, `funding order: ${r.funding_order.join(' > ')}`);
173
+ return 0;
174
+ }
175
+ default:
176
+ process.stderr.write(`unknown subcommand: ${sub}\n\n${BILLING_HELP}`);
177
+ return 1;
178
+ }
179
+ }
180
+
181
+ export async function keys(args) {
182
+ const [sub, a1] = args.positional;
183
+ if (args.has('help') || sub === 'help') {
184
+ process.stdout.write(KEYS_HELP);
185
+ return 0;
186
+ }
187
+ const c = await client(args);
188
+ switch (sub ?? 'list') {
189
+ case 'create': {
190
+ const k = await c.createKey(args.get('name'));
191
+ out(args, k, `API key (shown once, keep it):\n ${k.key}\nid ${k.id}\nuse: export INFERNET_API_KEY=${k.key}`);
192
+ return 0;
193
+ }
194
+ case 'list': {
195
+ const rows = await c.listKeys();
196
+ out(args, rows, rows.length
197
+ ? rows.map((k) => `${k.id} ${k.prefix}… ${k.name ?? ''} ${k.revoked_at ? 'revoked' : `last used ${k.last_used_at ?? 'never'}`}`).join('\n')
198
+ : 'No keys. infernet keys create');
199
+ return 0;
200
+ }
201
+ case 'revoke': {
202
+ if (!a1) throw new Error('usage: infernet keys revoke <key id>');
203
+ const k = await c.revokeKey(a1);
204
+ out(args, k, `revoked ${k.id} (${k.prefix}…)`);
205
+ return 0;
206
+ }
207
+ default:
208
+ process.stderr.write(`unknown subcommand: ${sub}\n\n${KEYS_HELP}`);
209
+ return 1;
210
+ }
211
+ }
212
+
213
+ export default batch;
package/commands/help.js CHANGED
@@ -44,11 +44,16 @@ Payments:
44
44
  redeem Redeem a credit code: infernet redeem CR-XXXX-XXXX-XXXX-XXXX
45
45
  invites Scarce invites (both sides get credits) and your affiliate link
46
46
 
47
+ Paid inference:
48
+ batch Paid batch inference from a JSONL file: quote, submit, status, results
49
+ billing Compute balance: node earnings, prepaid top-ups, funding order
50
+ keys API keys (ik_live_...) for the batch API
51
+
47
52
  Managed endpoints:
48
53
  reservation Book a pinned operator + exact model by the hour; keys, limits,
49
54
  per-minute availability report, post-paid invoice data
50
55
  order Order a dedicated model endpoint yourself: pay by x402 or CoinPay
51
- mcp MCP server (stdio): order, reservation, credit and invite tools
56
+ mcp MCP server (stdio): order, reservation, credit, invite and batch tools
52
57
 
53
58
  Other:
54
59
  help Show this help
package/commands/mcp.js CHANGED
@@ -14,6 +14,7 @@ import { createInterface } from 'node:readline';
14
14
  import { resolveClientOptions, createReservationsClient } from '../lib/reservations-client.js';
15
15
  import { createOrdersClient, x402KeyFrom, DEFAULT_MAX_USD } from '../lib/orders-client.js';
16
16
  import { resolveCreditsOptions, createCreditsClient } from '../lib/credits-client.js';
17
+ import { resolveBatchOptions, createBatchClient } from '../lib/batch-client.js';
17
18
  import { CURRENT_VERSION } from '../lib/version.js';
18
19
 
19
20
  const PROTOCOL_VERSION = '2025-06-18';
@@ -27,6 +28,22 @@ const ORDER_PROPS = {
27
28
  email: { type: 'string' },
28
29
  name: { type: 'string' }
29
30
  };
31
+ const BATCH_ITEMS = {
32
+ type: 'array',
33
+ description: 'requests: { custom_id, messages: [{ role, content }], max_tokens, temperature? }',
34
+ items: {
35
+ type: 'object',
36
+ required: ['custom_id', 'messages', 'max_tokens'],
37
+ properties: {
38
+ custom_id: { type: 'string' },
39
+ messages: { type: 'array', items: { type: 'object', properties: { role: { type: 'string' }, content: { type: 'string' } } } },
40
+ max_tokens: { type: 'integer', minimum: 1 },
41
+ temperature: { type: 'number' }
42
+ }
43
+ }
44
+ };
45
+ const batchId = { type: 'string', description: 'batch id (uuid)' };
46
+
30
47
  const orderInput = (a) => Object.fromEntries(['gpu_class', 'models', 'hours', 'start_at', 'email', 'name'].filter((k) => a[k] !== undefined).map((k) => [k, a[k]]));
31
48
 
32
49
  export const TOOLS = [
@@ -135,7 +152,41 @@ export const TOOLS = [
135
152
  description: 'Create a single-use invite link (shown once). Both people get credits when a new account joins on it and confirms its email.',
136
153
  inputSchema: { type: 'object', properties: { note: { type: 'string' } } },
137
154
  run: (c, a) => c.credits.createInvite(a.note)
138
- }
155
+ },
156
+ // Paid batch inference (INFERNET_API_KEY or the login bearer). Only
157
+ // batch_submit can spend, and only up to the max_cost_usd you pass.
158
+ {
159
+ name: 'batch_quote',
160
+ description: 'Price a batch of chat requests without spending: per-item and total max cost and a quote_id valid 15 minutes. Token counts are server-side estimates (ceil(chars/4)).',
161
+ inputSchema: { type: 'object', required: ['model', 'items'], properties: { model: { type: 'string' }, items: BATCH_ITEMS } },
162
+ run: (c, a) => c.batch.quote({ model: a.model, items: a.items })
163
+ },
164
+ {
165
+ name: 'batch_submit',
166
+ description: 'SPENDS MONEY. Submit a paid batch: holds up to max_cost_usd from your funding sources (node earnings, prepaid balance; never a wallet payment from here), charges each item its estimated cost and releases the rest. Pass quote_id (from batch_quote) or model + items. max_cost_usd and idempotency_key are required; the same key returns the same batch.',
167
+ inputSchema: {
168
+ type: 'object',
169
+ required: ['max_cost_usd', 'idempotency_key'],
170
+ properties: {
171
+ quote_id: { type: 'string' },
172
+ model: { type: 'string' },
173
+ items: BATCH_ITEMS,
174
+ max_cost_usd: { type: 'string', description: 'hard cap in USD, e.g. "2.50"' },
175
+ idempotency_key: { type: 'string' },
176
+ funding: { type: 'string', enum: ['earned_first', 'prepaid_first', 'earned_only', 'prepaid_only', 'no_wallet'] }
177
+ }
178
+ },
179
+ run: async (c, a) => {
180
+ if (a.max_cost_usd === undefined || a.max_cost_usd === null || a.max_cost_usd === '') throw new Error('max_cost_usd is required');
181
+ if (!a.idempotency_key) throw new Error('idempotency_key is required');
182
+ const body = { max_cost_usd: String(a.max_cost_usd), idempotency_key: a.idempotency_key, funding: a.funding ?? 'no_wallet' };
183
+ if (a.quote_id) body.quote_id = a.quote_id; else Object.assign(body, { model: a.model, items: a.items });
184
+ return c.batch.submit(body);
185
+ }
186
+ },
187
+ { 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
+ { 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() }
139
190
  ];
140
191
 
141
192
  /** Handle one JSON-RPC message; returns the response object or null for notifications. */
@@ -171,12 +222,13 @@ export async function handleMessage(msg, client) {
171
222
 
172
223
  export default async function mcp(args) {
173
224
  if (args.has('help') || args.has('h')) {
174
- process.stdout.write('infernet mcp — MCP server (stdio): self-serve orders, managed-endpoint reservations, credits and invites\n\n claude mcp add infernet -- infernet mcp\n');
225
+ process.stdout.write('infernet mcp — MCP server (stdio): self-serve orders, managed-endpoint reservations, credits, invites and paid batch inference\n\n claude mcp add infernet -- infernet mcp\n');
175
226
  return 0;
176
227
  }
177
228
  const client = createReservationsClient(await resolveClientOptions({ url: args.get('url'), token: args.get('token'), buyerToken: args.get('buyer-token') }));
178
229
  client.orders = createOrdersClient({ baseUrl: (await resolveClientOptions({ url: args.get('url') })).baseUrl });
179
230
  client.credits = createCreditsClient(await resolveCreditsOptions({ url: args.get('url'), token: args.get('token') }));
231
+ client.batch = createBatchClient(await resolveBatchOptions({ url: args.get('url'), key: args.get('key'), token: args.get('token') }));
180
232
  const rl = createInterface({ input: process.stdin });
181
233
  for await (const line of rl) {
182
234
  if (!line.trim()) continue;
@@ -21,10 +21,11 @@ import {
21
21
  setupRuntime,
22
22
  verifyBundle
23
23
  } from "@infernetprotocol/liquid-agent";
24
+ import { cmdTextRuntime, cmdTextTrain, isTextJob, TEXT_HELP } from "./model-text.js";
24
25
 
25
26
  export const TEMPORAL_SUBCOMMANDS = new Set(["train", "evaluate", "eval", "predict", "serve", "capabilities", "runtime", "synth"]);
26
27
 
27
- export const TEMPORAL_HELP = `
28
+ export const TEMPORAL_HELP = `${TEXT_HELP}
28
29
  Temporal policies (workloads ${WORKLOADS.TRAIN}, ${WORKLOADS.INFER}):
29
30
  infernet model runtime [status] Is the infernet-liquid runtime installed?
30
31
  infernet model runtime setup [--accelerator cpu|cuda] [--yes]
@@ -285,10 +286,16 @@ async function cmdSynth(args) {
285
286
  export async function runTemporal(sub, args) {
286
287
  switch (sub) {
287
288
  case "runtime":
288
- return cmdRuntime(args);
289
+ return args.has("peft") ? cmdTextRuntime(args) : cmdRuntime(args);
289
290
  case "capabilities":
290
291
  return cmdCapabilities(args);
291
292
  case "train":
293
+ // A text job (kind lora/peft) goes to the peft backend; anything
294
+ // else is a liquid-agent temporal job as before.
295
+ if (args.has("job") && !args.has("dataset")) {
296
+ const job = await readJson(args.get("job")).catch(() => null);
297
+ if (isTextJob(job)) return cmdTextTrain(args, args.get("job"));
298
+ }
292
299
  return cmdTrain(args);
293
300
  case "evaluate":
294
301
  case "eval":
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Text fine-tunes (workload infernet.text.train): `infernet model train --job
3
+ * <job.json>` with `kind: "lora"` runs the @infernetprotocol/training peft
4
+ * backend instead of the temporal runtime.
5
+ *
6
+ * infernet model runtime setup --peft [--accelerator cpu|cuda] --yes
7
+ * infernet model runtime status --peft [--json]
8
+ * infernet model train --job job.json [--json]
9
+ *
10
+ * With --json, stdout is the training-protocol v1 event stream, one JSON object
11
+ * per line, ending with `done` (what c0mpute's text worker relays to the
12
+ * buyer). Without it, a progress line per step on stderr and a summary.
13
+ */
14
+
15
+ import path from "node:path";
16
+ import { readFile } from "node:fs/promises";
17
+ import {
18
+ createPeftBackend,
19
+ PEFT_KINDS,
20
+ peftRuntimeStatus,
21
+ setupPeftRuntime
22
+ } from "@infernetprotocol/training";
23
+
24
+ export const TEXT_HELP = `
25
+ Text fine-tunes (workload infernet.text.train):
26
+ infernet model runtime setup --peft [--accelerator cpu|cuda] [--yes]
27
+ Install the peft runtime (PyTorch + transformers
28
+ + peft in their own venv, ~1 GB on CPU).
29
+ infernet model runtime status --peft [--json]
30
+ infernet model train --job <job.json> [--json]
31
+ LoRA-tune job.base_model on job.dataset (jsonl of
32
+ {title, text}); --json streams v1 events.
33
+ `;
34
+
35
+ export function isTextJob(job) {
36
+ return Boolean(job && PEFT_KINDS.includes(job.kind));
37
+ }
38
+
39
+ export async function cmdTextRuntime(args) {
40
+ const sub = args.positional?.[1] ?? "status";
41
+ const accelerator = args.has("accelerator") ? args.get("accelerator") : "cpu";
42
+ if (sub === "setup") {
43
+ if (!args.has("yes") && !args.has("y") && process.env.INFERNET_NONINTERACTIVE !== "1") {
44
+ process.stdout.write(`This installs the peft runtime: a Python venv with PyTorch (${accelerator}), transformers and peft (about ${accelerator === "cuda" ? "5" : "1"} GB). Re-run with --yes to proceed.\n`);
45
+ return 1;
46
+ }
47
+ const rt = await setupPeftRuntime({ accelerator, log: (l) => process.stderr.write(`${l}\n`) });
48
+ process.stdout.write(`installed: ${rt.python} (${rt.accelerator})\n`);
49
+ return 0;
50
+ }
51
+ const st = await peftRuntimeStatus();
52
+ if (args.has("json")) process.stdout.write(`${JSON.stringify(st ? { installed: true, ...st } : { installed: false })}\n`);
53
+ else process.stdout.write(st ? `peft runtime: torch ${st.torch}, transformers ${st.transformers}, peft ${st.peft}, cuda ${st.cuda}\n ${st.python}\n` : "peft runtime: not installed (infernet model runtime setup --peft --yes)\n");
54
+ return st ? 0 : 1;
55
+ }
56
+
57
+ export async function cmdTextTrain(args, jobPath) {
58
+ const file = path.resolve(jobPath);
59
+ const job = JSON.parse(await readFile(file, "utf8"));
60
+ if (!isTextJob(job)) {
61
+ process.stderr.write(`error: ${jobPath} is not a text job (kind must be one of ${PEFT_KINDS.join(", ")})\n`);
62
+ return 2;
63
+ }
64
+ const json = args.has("json");
65
+ const backend = createPeftBackend();
66
+ const run = backend.start({ config: job, jobPath: file });
67
+ const onSignal = () => run.cancel();
68
+ process.once("SIGINT", onSignal);
69
+ process.once("SIGTERM", onSignal);
70
+ let done = null;
71
+ let checkpoint = null;
72
+ for await (const ev of run.stream) {
73
+ if (json) process.stdout.write(`${JSON.stringify(ev)}\n`);
74
+ else if (ev.type === "step") process.stderr.write(`step ${ev.step}/${ev.total_steps ?? "?"} loss ${ev.loss}\n`);
75
+ else if (ev.type === "eval") process.stderr.write(`eval @${ev.step}: ${JSON.stringify(ev.metrics)}\n`);
76
+ else if (ev.type === "error") process.stderr.write(`error: ${ev.message}\n`);
77
+ if (ev.type === "checkpoint") checkpoint = ev;
78
+ if (ev.type === "done") done = ev;
79
+ }
80
+ await backend.shutdown();
81
+ if (!json && checkpoint) process.stdout.write(`adapter ${checkpoint.model} ${checkpoint.path}\n`);
82
+ return done?.reason === "complete" ? 0 : 1;
83
+ }
package/commands/model.js CHANGED
@@ -39,7 +39,7 @@ Usage:
39
39
  (node id or row id, public nodes only).
40
40
  --url <control-plane> default infernetprotocol.com
41
41
  infernet model recommend [flags] Recommend models for your hardware.
42
- --use-case <chat|coding|study|agents|uncensored|vision>
42
+ --use-case <chat|marketing|research|coding|study|agents|uncensored|vision>
43
43
  --uncensored
44
44
  --install install the top pick
45
45
  --install-all install everything that fits on disk
@@ -183,7 +183,7 @@ async function cmdListNode(nodeId, args) {
183
183
  async function cmdRecommend(args) {
184
184
  const useCase = args.get("use-case") ?? args.get("for") ?? null;
185
185
  const uncensoredOnly = args.has("uncensored");
186
- const limit = Number.parseInt(args.get("limit") ?? "5", 10);
186
+ const limit = Number.parseInt(args.get("limit") ?? "3", 10);
187
187
  const wantInstall = args.has("install") || args.has("i");
188
188
  const wantInstallAll = args.has("install-all");
189
189
 
@@ -60,7 +60,8 @@ export function formatBalance(b = {}) {
60
60
  return [
61
61
  `Earnings: ${fmtUsd(b.pending_approval_usd)} pending approval, ${fmtUsd(b.pending_usd)} awaiting client payment, ${fmtUsd(b.confirmed_usd)} confirmed`,
62
62
  `Payouts: ${fmtUsd(b.paid_usd)} paid, ${fmtUsd(b.requested_usd)} requested, ${fmtUsd(b.available_usd)} available to withdraw`,
63
- `Jobs: ${b.jobs_credited ?? 0} credited`
63
+ `Jobs: ${b.jobs_credited ?? 0} credited`,
64
+ ...(Number(b.spent_on_compute_usd) > 0 ? [`Compute: ${fmtUsd(b.spent_on_compute_usd)} spent on batch inference (infernet billing balance)`] : [])
64
65
  ].join('\n');
65
66
  }
66
67
 
@@ -116,7 +117,7 @@ async function runList(args, ctx) {
116
117
  for (const e of recent) {
117
118
  const when = String(e.earned_at ?? '').replace('T', ' ').slice(0, 16);
118
119
  process.stdout.write(
119
- ` ${when} ${String(e.job_id).slice(0, 8)} ${(e.model_name ?? '-').padEnd(18)} ` +
120
+ ` ${when} ${e.job_id ? String(e.job_id).slice(0, 8) : `res ${String(e.reservation_id ?? '').slice(0, 4)}`} ${(e.model_name ?? '-').padEnd(18)} ` +
120
121
  `${String(e.output_tokens ?? 0).padStart(6)} tok ${fmtUsd(e.amount_usd).padStart(11)} ` +
121
122
  `${e.kind} ${STATUS_LABEL[e.status] ?? e.status}\n`
122
123
  );
@@ -204,6 +204,8 @@ export async function gatherCoarseSpecs() {
204
204
  const served_models = [...new Set([...pulledModels.map((m) => m.name), ...vllmModels])];
205
205
 
206
206
  return {
207
+ e2e_capable: true,
208
+ e2e_version: 'nip44-v2',
207
209
  cpu: summarizeCpu(),
208
210
  gpu_count: gpus.length,
209
211
  gpus: gpus.map((g) => ({
@@ -212,6 +212,10 @@ export default async function remove(args, ctx) {
212
212
  }
213
213
 
214
214
  if (!keepBinary) {
215
+ try {
216
+ const { removeAutoUpdate } = await import('@profullstack/cli/auto-update');
217
+ await removeAutoUpdate('infernet');
218
+ } catch { /* older installs may not have the shared updater dependency */ }
215
219
  const { removed, skipped } = await uninstallBinary();
216
220
  for (const p of removed) process.stdout.write(`Removed ${p}\n`);
217
221
  if (skipped.length > 0) {
package/commands/setup.js CHANGED
@@ -76,7 +76,7 @@ skip the prompts.
76
76
  export const ABLITERATED_DEFAULT = "huihui_ai/Qwen3.8-abliterated:27b";
77
77
 
78
78
  const MODEL_SUGGESTIONS = [
79
- { name: "qwen2.5:0.5b", size_gb: 0.4, size: "≈400 MB", note: "smoke test, runs on CPU" },
79
+ { name: "qwen2.5:0.5b", size_gb: 0.4, size: "≈400 MB", note: "small-memory fallback / smoke test, runs on CPU", cpuFallback: true },
80
80
  { name: "qwen2.5:3b", size_gb: 2.0, size: "≈2 GB", note: "fits 6 GB+ GPU / 8 GB+ RAM" },
81
81
  { name: "qwen2.5:7b", size_gb: 4.4, size: "≈4.4 GB", note: "fits 8 GB+ GPU / 12 GB+ RAM" },
82
82
  { name: "qwen2.5:14b", size_gb: 9.0, size: "≈9 GB", note: "fits 16 GB+ GPU / 24 GB+ RAM" },
@@ -91,7 +91,14 @@ const MODEL_SUGGESTIONS = [
91
91
  * out), otherwise the largest stock model that fits.
92
92
  */
93
93
  export function pickDefaultSuggestion(evaluated, { isCpuOnly, abliterated = true } = {}) {
94
- if (isCpuOnly) return MODEL_SUGGESTIONS[0].name;
94
+ if (isCpuOnly) {
95
+ // Prefer a useful small model on CPU; keep the 0.5B option for hosts
96
+ // that cannot fit 3B in RAM.
97
+ const cpuDefault = evaluated.find((m) => m.name === "qwen2.5:3b");
98
+ if (cpuDefault?.fits) return cpuDefault.name;
99
+ return evaluated.find((m) => m.cpuFallback && m.fits)?.name
100
+ ?? MODEL_SUGGESTIONS[0].name;
101
+ }
95
102
  const fitting = evaluated.filter((m) => m.fits);
96
103
  if (abliterated) {
97
104
  const abl = fitting.find((m) => m.abliterated);
package/commands/start.js CHANGED
@@ -92,7 +92,7 @@ live queries (see \`infernet status\`, \`infernet stats\`, \`infernet logs\`).
92
92
 
93
93
  const DEFAULT_HEARTBEAT_MS = 30_000;
94
94
  const DEFAULT_POLL_MS = 15_000;
95
- const UPDATE_CHECK_MS = 5 * 60 * 1000; // 5 minutes
95
+ const UPDATE_CHECK_MS = 60_000; // 60 seconds
96
96
  const UPDATE_DRAIN_MS = 10 * 60 * 1000; // wait for in-flight jobs before restarting
97
97
  const UPDATE_PAUSE_MS = 6 * 60 * 60 * 1000; // after an update that installed nothing newer
98
98
  const SHUTDOWN_DEADLINE_MS = 5_000; // hard exit: a half-shut daemon must never outlive its pidfile
@@ -492,6 +492,11 @@ async function runDaemon(args, ctx) {
492
492
 
493
493
  return {
494
494
  ...base,
495
+ // Every provider daemon implements NIP-44 prompt and response
496
+ // encryption. Publish the capability so the control plane can
497
+ // exclude daemons that have not upgraded yet.
498
+ e2e_capable: true,
499
+ e2e_version: 'nip44-v2',
495
500
  ...(bench ? { bench } : {}),
496
501
  load,
497
502
  ...(reachable ? { reachable } : {}),
@@ -544,11 +549,15 @@ async function runDaemon(args, ctx) {
544
549
  recordBench(result);
545
550
  resultPayload = {
546
551
  type: 'chat',
547
- text: result.text,
548
552
  token_count: result.token_count,
549
553
  duration_ms: result.duration_ms,
550
554
  completed_by: node.nodeId
551
555
  };
556
+ // For an E2E job, response text was delivered in encrypted
557
+ // job events. Do not send a plaintext copy in the completion
558
+ // payload, which is readable by the control plane.
559
+ if (result.e2e) resultPayload.e2e = true;
560
+ else resultPayload.text = result.text;
552
561
  } else {
553
562
  await new Promise((resolve) => setTimeout(resolve, 500));
554
563
  resultPayload = { stub: true, completed_by: node.nodeId };
@@ -1621,7 +1630,7 @@ async function runDaemon(args, ctx) {
1621
1630
  if (typeof trainingTimer.unref === 'function') trainingTimer.unref();
1622
1631
  }
1623
1632
 
1624
- // Self-update: check npm registry every 5 minutes. If a newer version is
1633
+ // Self-update: check the GitHub release feed every 60 seconds. If a newer version is
1625
1634
  // available, pull the installer, re-generate any missing keys + re-register
1626
1635
  // specs (idempotent), then re-exec so the new code is running immediately.
1627
1636
  let isUpgrading = false;
@@ -1631,7 +1640,7 @@ async function runDaemon(args, ctx) {
1631
1640
  // version. For a second daemon on the same install, e.g. an aggregator, so
1632
1641
  // two daemons never run the installer at once.
1633
1642
  const followOnly = process.env.INFERNET_AUTO_UPDATE === 'follow';
1634
- const updateTimer = setInterval(async () => {
1643
+ const checkForUpdate = async () => {
1635
1644
  if (shuttingDown || isUpgrading || Date.now() < updatePausedUntil) return;
1636
1645
  // Never start an upgrade under a running job; the next check retries.
1637
1646
  if (stats.activeJobIds.size > 0) return;
@@ -1651,7 +1660,7 @@ async function runDaemon(args, ctx) {
1651
1660
  }
1652
1661
  // The installer can succeed without changing this install (a git checkout
1653
1662
  // whose package.json lagged the release, or npm writing to another
1654
- // prefix). Restarting then would rerun the same update every 5 minutes
1663
+ // prefix). Restarting then would rerun the same update every 60 seconds
1655
1664
  // forever, so keep serving and try again much later.
1656
1665
  const installed = readInstalledVersion();
1657
1666
  if (!isNewerVersion(CURRENT_VERSION, installed)) {
@@ -1726,8 +1735,11 @@ async function runDaemon(args, ctx) {
1726
1735
  }).unref();
1727
1736
 
1728
1737
  process.exit(0);
1729
- }, UPDATE_CHECK_MS);
1738
+ };
1739
+ const updateTimer = setInterval(checkForUpdate, UPDATE_CHECK_MS);
1730
1740
  if (typeof updateTimer.unref === 'function') updateTimer.unref();
1741
+ // Check immediately on startup, then repeat on the 60-second cadence.
1742
+ void checkForUpdate();
1731
1743
 
1732
1744
  await new Promise(() => {});
1733
1745
  return 0;
@@ -9,7 +9,9 @@
9
9
  */
10
10
 
11
11
  import { spawn } from 'node:child_process';
12
+ import { compareVersions } from '@profullstack/cli';
12
13
  import setup from './setup.js';
14
+ import { CURRENT_VERSION, fetchLatestVersion } from '../lib/version.js';
13
15
 
14
16
  const HELP = `infernet update — pull latest CLI + autonomous post-upgrade setup
15
17
 
@@ -17,6 +19,9 @@ Usage:
17
19
  infernet update [flags]
18
20
 
19
21
  Flags:
22
+ --check Check for a newer release without installing it.
23
+ --force Reinstall when the published version matches (never downgrades).
24
+ --quiet Suppress routine update progress.
20
25
  --skip-setup Just re-run the installer; don't run setup afterward.
21
26
  --help Show this help.
22
27
 
@@ -43,8 +48,8 @@ function runShell(cmd) {
43
48
  });
44
49
  }
45
50
 
46
- export async function pullLatestBinary() {
47
- process.stdout.write(`\n→ Pulling latest CLI from ${INSTALLER_URL}\n\n`);
51
+ export async function pullLatestBinary({ quiet = false } = {}) {
52
+ if (!quiet) process.stdout.write(`\n→ Pulling latest CLI from ${INSTALLER_URL}\n\n`);
48
53
  // INFERNET_AUTOSTART=0: the installer would otherwise run `infernet setup`,
49
54
  // which restarts (or, next to infernet.service, duplicates) the daemon from
50
55
  // inside its own self-update. Both callers run setup themselves afterwards.
@@ -62,7 +67,31 @@ export default async function update(args, ctx) {
62
67
  return 0;
63
68
  }
64
69
 
65
- const ok = await pullLatestBinary();
70
+ const quiet = args.has('quiet');
71
+ const latest = await fetchLatestVersion();
72
+ if (!latest) {
73
+ process.stderr.write('error: could not check the latest Infernet version; installer was not run.\n');
74
+ return 1;
75
+ }
76
+ const comparison = compareVersions(CURRENT_VERSION, latest);
77
+ if (comparison === null) {
78
+ process.stderr.write('error: invalid version from the Infernet update feed; installer was not run.\n');
79
+ return 1;
80
+ }
81
+ if (comparison > 0) {
82
+ if (!quiet) process.stdout.write(`Infernet ${CURRENT_VERSION} is newer than the published ${latest}; refusing to downgrade.\n`);
83
+ return 0;
84
+ }
85
+ if (comparison === 0 && !args.has('force')) {
86
+ if (!quiet) process.stdout.write(`Infernet ${CURRENT_VERSION} is already current; skipping reinstall.\n`);
87
+ return 0;
88
+ }
89
+ if (args.has('check')) {
90
+ if (!quiet) process.stdout.write(`Infernet update available: ${CURRENT_VERSION} → ${latest}.\n`);
91
+ return 0;
92
+ }
93
+
94
+ const ok = await pullLatestBinary({ quiet });
66
95
  if (!ok) return 1;
67
96
 
68
97
  if (args.has('skip-setup')) {
package/index.js CHANGED
@@ -52,6 +52,7 @@ import reservation from './commands/reservation.js';
52
52
  import order from './commands/order.js';
53
53
  import mcp from './commands/mcp.js';
54
54
  import credits, { invites, redeem } from './commands/credits.js';
55
+ import batch, { billing, keys } from './commands/batch.js';
55
56
 
56
57
  function parseArgs(argv) {
57
58
  const positional = [];
@@ -113,11 +114,11 @@ const COMMANDS = {
113
114
  // aliases
114
115
  uninstall: remove,
115
116
  start, status, stop, restart, stats, logs,
116
- payout, payments, gpu, firewall, chat, setup, model, train, publish, inference, rpc, uncensored, reservation, reservations: reservation, order, orders: order, mcp, credits, invites, redeem, tui, doctor, service, pubkey, debug, deploy, console: consoleCmd, help
117
+ 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
117
118
  };
118
119
 
119
120
  // Commands that can run without a loaded config.
120
- 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', 'tui', 'doctor', 'service', 'pubkey', 'debug', 'deploy', 'console', 'upgrade', 'update', 'remove', 'uninstall']);
121
+ 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']);
121
122
  // Commands that need a config but not a control-plane client (none today
122
123
  // — kept as a future escape hatch).
123
124
  const NO_CLIENT = new Set();
@@ -0,0 +1,92 @@
1
+ /**
2
+ * HTTP client for paid batch inference, the compute balance and API keys
3
+ * (/api/v1/batches/*, /api/v1/billing/*, /api/v1/keys) — shared by
4
+ * `infernet batch`, `infernet billing`, `infernet keys` and `infernet mcp`.
5
+ *
6
+ * Auth: an API key (--key, INFERNET_API_KEY: ik_live_...) or the
7
+ * `infernet login` bearer. Keys are created/revoked with the login bearer.
8
+ */
9
+ import { readFileSync } from 'node:fs';
10
+ import { loadConfig } from './config.js';
11
+
12
+ const DEFAULT_URL = 'https://infernetprotocol.com';
13
+
14
+ export async function resolveBatchOptions(opts = {}) {
15
+ const config = await loadConfig().catch(() => null);
16
+ const bearer = config?.auth?.bearerToken || null;
17
+ return {
18
+ baseUrl: String(opts.url || process.env.INFERNET_URL || config?.controlPlane?.url || DEFAULT_URL).replace(/\/+$/, ''),
19
+ apiKey: opts.key || process.env.INFERNET_API_KEY || null,
20
+ userToken: opts.token || bearer
21
+ };
22
+ }
23
+
24
+ /** Parse a JSONL file of { custom_id, messages, max_tokens, temperature? } lines. */
25
+ export function readBatchJsonl(text) {
26
+ const items = [];
27
+ String(text).split(/\r?\n/).forEach((line, i) => {
28
+ if (!line.trim()) return;
29
+ let row;
30
+ try { row = JSON.parse(line); } catch { throw new Error(`line ${i + 1}: not valid JSON`); }
31
+ if (!row || typeof row !== 'object' || Array.isArray(row)) throw new Error(`line ${i + 1}: expected an object`);
32
+ items.push(row);
33
+ });
34
+ if (items.length === 0) throw new Error('the file has no items');
35
+ return items;
36
+ }
37
+
38
+ export function readBatchFile(path) {
39
+ return readBatchJsonl(readFileSync(path, 'utf8'));
40
+ }
41
+
42
+ export function createBatchClient({ baseUrl, apiKey, userToken, fetchImpl = fetch }) {
43
+ async function call(method, path, { body, signedIn = false, raw = false, headers: extra = {} } = {}) {
44
+ const token = signedIn ? userToken : (apiKey || userToken);
45
+ if (!token) {
46
+ throw new Error(signedIn
47
+ ? 'not signed in: run `infernet login` first'
48
+ : 'set INFERNET_API_KEY (ik_live_..., from `infernet keys create`) or run `infernet login`');
49
+ }
50
+ const headers = { accept: raw ? '*/*' : 'application/json', authorization: `Bearer ${token}`, ...extra };
51
+ if (body !== undefined) headers['content-type'] = 'application/json';
52
+ const res = await fetchImpl(`${baseUrl}${path}`, { method, headers, body: body === undefined ? undefined : JSON.stringify(body) });
53
+ const text = await res.text();
54
+ if (raw && res.ok) return text;
55
+ let json = null;
56
+ try { json = text ? JSON.parse(text) : null; } catch { /* non-JSON */ }
57
+ if (!res.ok) {
58
+ const detail = json?.details ? `: ${json.details.join('; ')}` : '';
59
+ const err = new Error(`${json?.error ?? `HTTP ${res.status} ${text.slice(0, 200)}`}${detail}`);
60
+ err.status = res.status;
61
+ err.body = json;
62
+ throw err;
63
+ }
64
+ return json?.data ?? json;
65
+ }
66
+ const enc = encodeURIComponent;
67
+ return {
68
+ quote: (body) => call('POST', '/api/v1/batches/quote', { body }),
69
+ /** max_cost_usd and idempotency_key are required; the server refuses without them. */
70
+ submit: (body) => call('POST', '/api/v1/batches', { body }),
71
+ status: (id) => call('GET', `/api/v1/batches/${enc(id)}`),
72
+ results: (id) => call('GET', `/api/v1/batches/${enc(id)}/results`, { raw: true }),
73
+ cancel: (id) => call('POST', `/api/v1/batches/${enc(id)}/cancel`),
74
+ receipt: (id) => call('GET', `/api/v1/batches/${enc(id)}/receipt`),
75
+ balance: () => call('GET', '/api/v1/billing/balance'),
76
+ topup: (amountUsd) => call('POST', '/api/v1/billing/topup', { body: { amount_usd: amountUsd } }),
77
+ topupStatus: (id) => call('GET', `/api/v1/billing/topup/${enc(id)}`),
78
+ setFunding: (order) => call('PUT', '/api/v1/billing/funding', { body: { funding_order: order } }),
79
+ createKey: (name) => call('POST', '/api/v1/keys', { body: { name: name ?? null }, signedIn: true }),
80
+ listKeys: () => call('GET', '/api/v1/keys', { signedIn: true }),
81
+ revokeKey: (id) => call('DELETE', `/api/v1/keys/${enc(id)}`, { signedIn: true })
82
+ };
83
+ }
84
+
85
+ export function formatBillingBalance(b = {}) {
86
+ return [
87
+ `Earned (spendable on compute): $${b.earned_spendable_usd ?? '0'} confirmed node earnings, Infernet + c0mpute`,
88
+ `Prepaid available: $${b.prepaid_available_usd ?? '0'} (balance $${b.balance_usd ?? '0'}, held $${b.held_usd ?? '0'})`,
89
+ `Total spendable: $${b.total_spendable_usd ?? '0'}`,
90
+ `Funding order: ${(b.funding_order ?? []).join(' > ')}`
91
+ ].join('\n');
92
+ }
@@ -14,7 +14,7 @@
14
14
 
15
15
  import { createEngine, MSG } from "@infernetprotocol/engine";
16
16
  import { loadConfig } from "./config.js";
17
- import { getConversationKey, decrypt } from "./nip44.js";
17
+ import { getConversationKey, decrypt, encrypt } from "./nip44.js";
18
18
  import { getModelKeyPair } from "./model-key.js";
19
19
 
20
20
  // Flush the event buffer when it hits this many tokens OR when we haven't
@@ -55,9 +55,10 @@ function mergeTokens(events) {
55
55
  }
56
56
 
57
57
  class EventBuffer {
58
- constructor(client, jobId) {
58
+ constructor(client, jobId, conversationKey = null) {
59
59
  this.client = client;
60
60
  this.jobId = jobId;
61
+ this.conversationKey = conversationKey;
61
62
  this.events = [];
62
63
  this.lastFlush = Date.now();
63
64
  }
@@ -72,13 +73,33 @@ class EventBuffer {
72
73
  }
73
74
  async flush() {
74
75
  if (this.events.length === 0) return;
75
- const batch = mergeTokens(this.events);
76
+ const batch = mergeTokens(this.events).map((event) => {
77
+ if (!this.conversationKey) return event;
78
+ if (event.event_type === "token") {
79
+ return {
80
+ ...event,
81
+ data: { encrypted_text: encrypt(this.conversationKey, event.data?.text ?? "") }
82
+ };
83
+ }
84
+ if (event.event_type === "done") {
85
+ const { text = "", ...metadata } = event.data ?? {};
86
+ return {
87
+ ...event,
88
+ data: {
89
+ ...metadata,
90
+ encrypted_text: encrypt(this.conversationKey, text)
91
+ }
92
+ };
93
+ }
94
+ return event;
95
+ });
76
96
  this.events = [];
77
97
  this.lastFlush = Date.now();
78
98
  try {
79
99
  await this.client.postJobEvents(this.jobId, batch);
80
100
  } catch (err) {
81
101
  process.stderr.write(`postJobEvents failed: ${err?.message ?? err}\n`);
102
+ throw err;
82
103
  }
83
104
  }
84
105
  }
@@ -210,7 +231,7 @@ export async function executeChatJob({ client, job, node }) {
210
231
  }
211
232
 
212
233
  const engine = await getEngineForModel(job.model_name);
213
- const buffer = new EventBuffer(client, job.id);
234
+ const buffer = new EventBuffer(client, job.id, convKey);
214
235
 
215
236
  const t0 = Date.now();
216
237
  const generation = engine.generate({
@@ -262,7 +283,7 @@ export async function executeChatJob({ client, job, node }) {
262
283
 
263
284
  await buffer.flush();
264
285
  const duration_ms = Date.now() - t0;
265
- return { text: accumulated, token_count: tokenCount, duration_ms };
286
+ return { text: accumulated, token_count: tokenCount, duration_ms, e2e: Boolean(convKey) };
266
287
  }
267
288
 
268
289
  export async function failChatJob({ client, jobId, message }) {
@@ -19,35 +19,35 @@ export const CATALOG = [
19
19
  // ── ultra-light (CPU / phone-tier GPU) ──
20
20
  { id: "tinyllama", name: "TinyLlama 1.1B", paramsB: 1.1, vramMin: 0, ramMin: 4, pullName: "tinyllama", backend: "ollama", quality: 2, speed: 10, useCases: ["chat","testing"], notes: "Good only for testing the stack." },
21
21
  { id: "llama3.2-1b", name: "Llama 3.2 1B", paramsB: 1, vramMin: 0, ramMin: 4, pullName: "llama3.2:1b", backend: "ollama", quality: 4, speed: 10, useCases: ["chat","summary"], notes: "Light, fast Q&A." },
22
- { id: "qwen2.5-1.5b", name: "Qwen2.5 1.5B", paramsB: 1.5, vramMin: 0, ramMin: 4, pullName: "qwen2.5:1.5b", backend: "ollama", quality: 5, speed: 9, useCases: ["chat","study"] },
22
+ { id: "qwen2.5-1.5b", name: "Qwen2.5 1.5B", paramsB: 1.5, vramMin: 0, ramMin: 4, pullName: "qwen2.5:1.5b", backend: "ollama", quality: 5, speed: 9, useCases: ["chat","study","marketing"] },
23
23
 
24
24
  // ── light (small GPU / 16GB RAM) ──
25
25
  { id: "llama3.2-3b", name: "Llama 3.2 3B", paramsB: 3, vramMin: 2, ramMin: 8, pullName: "llama3.2:3b", backend: "ollama", quality: 6, speed: 8, useCases: ["chat","study","agents"] },
26
- { id: "qwen2.5-3b", name: "Qwen2.5 3B", paramsB: 3, vramMin: 2, ramMin: 8, pullName: "qwen2.5:3b", backend: "ollama", quality: 6, speed: 8, useCases: ["chat","study"] },
26
+ { id: "qwen2.5-3b", name: "Qwen2.5 3B", paramsB: 3, vramMin: 2, ramMin: 8, pullName: "qwen2.5:3b", backend: "ollama", quality: 6, speed: 8, useCases: ["chat","study","marketing"] },
27
27
  { id: "phi4-mini", name: "Phi-4 Mini 3.8B", paramsB: 3.8, vramMin: 4, ramMin: 8, pullName: "phi4-mini", backend: "ollama", quality: 8, speed: 7, useCases: ["chat","study","agents","coding"] },
28
28
  { id: "gemma3-4b", name: "Gemma 3 4B (vision)",paramsB: 4, vramMin: 4, ramMin: 8, pullName: "gemma3:4b", backend: "ollama", quality: 7, speed: 7, useCases: ["chat","vision","study"] },
29
29
 
30
30
  // ── 7-8B (RTX 3060/4060+, 16GB+ RAM) ──
31
- { id: "qwen2.5-7b", name: "Qwen2.5 7B", paramsB: 7, vramMin: 6, ramMin: 16, pullName: "qwen2.5:7b", backend: "ollama", quality: 8, speed: 6, useCases: ["chat","study","coding","agents"] },
31
+ { id: "qwen2.5-7b", name: "Qwen2.5 7B", paramsB: 7, vramMin: 6, ramMin: 16, pullName: "qwen2.5:7b", backend: "ollama", quality: 8, speed: 6, useCases: ["chat","study","coding","agents","marketing"] },
32
32
  { id: "llama3.1-8b", name: "Llama 3.1 8B", paramsB: 8, vramMin: 6, ramMin: 16, pullName: "llama3.1:8b", backend: "ollama", quality: 8, speed: 6, useCases: ["chat","study","agents"] },
33
33
  { id: "mistral-7b", name: "Mistral 7B", paramsB: 7, vramMin: 6, ramMin: 16, pullName: "mistral:7b", backend: "ollama", quality: 7, speed: 6, useCases: ["chat","study","coding"] },
34
34
  { id: "qwen2.5-coder-7b",name: "Qwen2.5 Coder 7B", paramsB: 7, vramMin: 6, ramMin: 16, pullName: "qwen2.5-coder:7b", backend: "ollama", quality: 9, speed: 6, useCases: ["coding","agents"], notes: "Best 7B coding model." },
35
35
  { id: "dolphin3-8b", name: "Dolphin 3 8B (uncensored)", paramsB: 8, vramMin: 6, ramMin: 16, pullName: "dolphin3:8b", backend: "ollama", quality: 8, speed: 6, useCases: ["chat","uncensored"], uncensored: true, notes: "Eric Hartford's Dolphin series, no alignment." },
36
- { id: "deepseek-r1-7b", name: "DeepSeek-R1 7B", paramsB: 7, vramMin: 6, ramMin: 16, pullName: "deepseek-r1:7b", backend: "ollama", quality: 8, speed: 4, useCases: ["study","coding","reasoning"], notes: "Reasoning-focused; slower because it thinks." },
36
+ { id: "deepseek-r1-7b", name: "DeepSeek-R1 7B", paramsB: 7, vramMin: 6, ramMin: 16, pullName: "deepseek-r1:7b", backend: "ollama", quality: 8, speed: 4, useCases: ["study","coding","research","reasoning"], notes: "Reasoning-focused; slower because it thinks." },
37
37
  { id: "hermes3-llama3-8b",name:"Hermes 3 Llama-3.1 8B (uncensored)", paramsB: 8, vramMin: 8, ramMin: 16, pullName: "hf:NousResearch/Hermes-3-Llama-3.1-8B", backend: "vllm", quality: 8, speed: 6, useCases: ["chat","uncensored","agents"], uncensored: true },
38
38
 
39
39
  // ── 13-14B (16GB+ VRAM) ──
40
- { id: "qwen2.5-14b", name: "Qwen2.5 14B", paramsB: 14, vramMin: 12, ramMin: 32, pullName: "qwen2.5:14b", backend: "ollama", quality: 9, speed: 5, useCases: ["chat","coding","study","agents"] },
40
+ { id: "qwen2.5-14b", name: "Qwen2.5 14B", paramsB: 14, vramMin: 12, ramMin: 32, pullName: "qwen2.5:14b", backend: "ollama", quality: 9, speed: 5, useCases: ["chat","coding","study","agents","marketing"] },
41
41
  { id: "qwen2.5-coder-14b",name:"Qwen2.5 Coder 14B", paramsB: 14, vramMin: 12, ramMin: 32, pullName: "qwen2.5-coder:14b", backend: "ollama", quality: 9, speed: 5, useCases: ["coding","agents"] },
42
42
 
43
43
  // ── 32B (24GB+ VRAM, RTX 4090 / A100 sweet spot) ──
44
44
  { id: "qwen3.5-9b-heretic", name: "Qwen3.5 9B Heretic (uncensored)", paramsB: 9, vramMin: 24, ramMin: 32, pullName: "hf:DavidAU/Qwen3.5-9B-Claude-4.6-HighIQ-THINKING-HERETIC-UNCENSORED", backend: "vllm", quality: 8, speed: 6, useCases: ["chat","uncensored","vision","agents","study"], uncensored: true },
45
- { id: "qwen2.5-32b", name: "Qwen2.5 32B", paramsB: 32, vramMin: 24, ramMin: 48, pullName: "qwen2.5:32b", backend: "ollama", quality: 9, speed: 4, useCases: ["chat","coding","study","agents"], notes: "Single-80GB-GPU sweet spot." },
45
+ { id: "qwen2.5-32b", name: "Qwen2.5 32B", paramsB: 32, vramMin: 24, ramMin: 48, pullName: "qwen2.5:32b", backend: "ollama", quality: 9, speed: 4, useCases: ["chat","coding","study","agents","marketing","research"], notes: "Single-80GB-GPU sweet spot." },
46
46
  { id: "qwen2.5-coder-32b",name:"Qwen2.5 Coder 32B", paramsB: 32, vramMin: 24, ramMin: 48, pullName: "qwen2.5-coder:32b", backend: "ollama", quality: 10, speed: 4, useCases: ["coding","agents"] },
47
47
 
48
48
  // ── 70B (40-80GB VRAM, Q4 fits 24GB) ──
49
- { id: "llama3.3-70b", name: "Llama 3.3 70B", paramsB: 70, vramMin: 40, ramMin: 64, pullName: "llama3.3:70b", backend: "ollama", quality: 10, speed: 3, useCases: ["chat","study","coding","agents"], notes: "Frontier-class at home with 80GB." },
50
- { id: "qwen2.5-72b", name: "Qwen2.5 72B", paramsB: 72, vramMin: 40, ramMin: 64, pullName: "qwen2.5:72b", backend: "ollama", quality: 10, speed: 3, useCases: ["chat","coding","study","agents"] },
49
+ { id: "llama3.3-70b", name: "Llama 3.3 70B", paramsB: 70, vramMin: 40, ramMin: 64, pullName: "llama3.3:70b", backend: "ollama", quality: 10, speed: 3, useCases: ["chat","study","coding","agents","marketing"], notes: "Frontier-class at home with 80GB." },
50
+ { id: "qwen2.5-72b", name: "Qwen2.5 72B", paramsB: 72, vramMin: 40, ramMin: 64, pullName: "qwen2.5:72b", backend: "ollama", quality: 10, speed: 3, useCases: ["chat","coding","study","agents","marketing","research"] },
51
51
 
52
52
  // ── MoE (high VRAM, vLLM only) ──
53
53
  { id: "mixtral-8x7b", name: "Mixtral 8x7B", paramsB: 47, vramMin: 30, ramMin: 64, pullName: "dolphin-mixtral:8x7b", backend: "ollama", quality: 9, speed: 5, useCases: ["chat","coding","uncensored"], uncensored: true },
@@ -98,7 +98,7 @@ function scoreModel(m, { vramGb, ramGb, useCase }) {
98
98
  * @param {object} opts
99
99
  * @param {number} opts.vramGb
100
100
  * @param {number} opts.ramGb
101
- * @param {string} [opts.useCase] chat | coding | study | agents | uncensored | vision
101
+ * @param {string} [opts.useCase] chat | marketing | research | coding | study | agents | uncensored | vision
102
102
  * @param {boolean} [opts.uncensoredOnly]
103
103
  * @param {number} [opts.limit=3]
104
104
  * @returns {Array<{model, score, fits}>}
@@ -126,6 +126,11 @@ export function renderInvoice(inv) {
126
126
  ''
127
127
  ];
128
128
  for (const l of inv.lines) lines.push(` h${String(l.hour).padStart(3)} ${l.start} ${l.status.padEnd(13)} ${String(l.confirmed_minutes).padStart(2)} min ${money(l.amount)}`);
129
- lines.push('', `amount due: ${money(inv.amount_due)}`, inv.note);
129
+ lines.push('');
130
+ if (inv.billing === 'prepaid') {
131
+ lines.push(`amount paid: ${money(inv.amount_paid)}${inv.payment_tx_hash ? ` tx ${inv.payment_tx_hash}` : ''}`);
132
+ lines.push(`refundable: ${money(inv.refundable_usd)}${inv.refund_state ? ` (${inv.refund_state})` : ''}`);
133
+ }
134
+ lines.push(`amount due: ${money(inv.amount_due)}`, inv.note);
130
135
  return lines.join('\n');
131
136
  }
package/lib/version.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { join, dirname } from 'node:path';
3
+ import { homedir } from 'node:os';
3
4
  import { fileURLToPath } from 'node:url';
4
5
 
5
6
  const _dir = dirname(fileURLToPath(import.meta.url));
@@ -9,26 +10,39 @@ export const CURRENT_VERSION = readInstalledVersion();
9
10
  * The version on disk right now, read fresh (CURRENT_VERSION is what this
10
11
  * process started with). Self-update compares the two after the installer
11
12
  * runs: if nothing newer landed, restarting would only repeat the same update
12
- * every 5 minutes.
13
+ * every 60 seconds.
13
14
  */
14
15
  export function readInstalledVersion() {
16
+ const versions = [];
15
17
  try {
16
- return JSON.parse(readFileSync(join(_dir, '../package.json'), 'utf8')).version;
17
- } catch {
18
- return '0.0.0';
19
- }
18
+ versions.push(JSON.parse(readFileSync(join(_dir, '../package.json'), 'utf8')).version);
19
+ } catch { /* this install may be a source checkout, not an npm package */ }
20
+
21
+ // When npm is behind master, install.sh deliberately switches to the git
22
+ // checkout at ~/.infernet/source. The running process still imports this
23
+ // helper from its old npm package, so its adjacent package.json stays at
24
+ // the old version even though the source install and wrapper now point at
25
+ // the newer CLI. Include that source version or the updater will pause for
26
+ // six hours and never restart into the version it just installed.
27
+ const sourceHome = process.env.INFERNET_HOME || join(homedir(), '.infernet');
28
+ try {
29
+ versions.push(JSON.parse(readFileSync(join(sourceHome, 'source', 'apps', 'cli', 'package.json'), 'utf8')).version);
30
+ } catch { /* no source install */ }
31
+
32
+ return versions.reduce((latest, version) =>
33
+ typeof version === 'string' && isNewerVersion(latest, version) ? version : latest,
34
+ '0.0.0');
20
35
  }
21
36
 
22
37
  export async function fetchLatestVersion() {
23
38
  try {
24
39
  const res = await fetch(
25
- 'https://api.github.com/repos/infernetprotocol/infernet-protocol/releases/latest',
26
- { headers: { accept: 'application/vnd.github+json', 'user-agent': 'infernet-daemon' }, signal: AbortSignal.timeout(10_000) }
40
+ 'https://infernetprotocol.com/api/cli/latest-version',
41
+ { headers: { accept: 'application/json', 'user-agent': 'infernet-daemon' }, signal: AbortSignal.timeout(10_000) }
27
42
  );
28
43
  if (!res.ok) return null;
29
44
  const data = await res.json();
30
- const tag = typeof data.tag_name === 'string' ? data.tag_name.replace(/^v/, '') : null;
31
- return tag;
45
+ return typeof data.version === 'string' ? data.version.replace(/^v/, '') : null;
32
46
  } catch {
33
47
  return null;
34
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infernetprotocol/cli",
3
- "version": "0.1.73",
3
+ "version": "0.1.79",
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",
@@ -25,19 +25,21 @@
25
25
  "@noble/ciphers": "^2.4.0",
26
26
  "@noble/curves": "^2.4.0",
27
27
  "@noble/hashes": "^2.4.0",
28
+ "@profullstack/cli": "^0.2.0",
28
29
  "@profullstack/x402-client": "^0.3.0",
29
30
  "blessed": "^0.1.81",
30
31
  "dotenv": "^18.0.9",
31
32
  "ora": "^9.4.1",
32
33
  "react": "^17.0.2",
33
34
  "react-blessed": "^0.7.2",
34
- "@infernetprotocol/auth": "0.1.73",
35
- "@infernetprotocol/config": "0.1.73",
36
- "@infernetprotocol/engine": "0.1.73",
37
- "@infernetprotocol/gpu": "0.1.73",
38
- "@infernetprotocol/liquid-agent": "0.1.73",
39
- "@infernetprotocol/rpc-adapter": "0.1.73",
40
- "@infernetprotocol/deploy-providers": "0.1.73"
35
+ "@infernetprotocol/auth": "0.1.79",
36
+ "@infernetprotocol/config": "0.1.79",
37
+ "@infernetprotocol/deploy-providers": "0.1.79",
38
+ "@infernetprotocol/engine": "0.1.79",
39
+ "@infernetprotocol/gpu": "0.1.79",
40
+ "@infernetprotocol/liquid-agent": "0.1.79",
41
+ "@infernetprotocol/rpc-adapter": "0.1.79",
42
+ "@infernetprotocol/training": "0.1.79"
41
43
  },
42
44
  "repository": {
43
45
  "type": "git",