@infernetprotocol/cli 0.1.48 → 0.1.50

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/start.js CHANGED
@@ -629,50 +629,54 @@ async function runDaemon(args, ctx) {
629
629
  let result;
630
630
  if (command === 'model_install') {
631
631
  const modelName = String(args?.model);
632
- if (modelName.startsWith('hf:')) {
633
- // HuggingFace model → download the weights, then TURN ON
634
- // vLLM to serve them (Ollama can't — it 400s on an hf: repo).
635
- if (!vllmInstalled()) {
636
- throw new Error(
637
- `${modelName} needs vLLM, which isn't installed on this node. ` +
638
- `Re-run the installer on this NVIDIA host (it installs vLLM), or: pip install vllm.`
639
- );
640
- }
641
- const repoId = modelName.slice(3);
632
+ // The node decides the backend by HARDWARE: prefer vLLM (GPU),
633
+ // fall back to Ollama (CPU/Mac). A catalog model carries an
634
+ // `hf` repo (ungated, vLLM-servable); a bare `hf:` name is
635
+ // vLLM-only; everything else is an Ollama tag.
636
+ const hfRepo = args?.hf
637
+ ? String(args.hf)
638
+ : (modelName.startsWith('hf:') ? modelName.slice(3) : null);
639
+
640
+ if (vllmInstalled() && hfRepo) {
641
+ // GPU path — serve the HF weights on vLLM. Keep the friendly
642
+ // name (e.g. "qwen2.5:7b" or "hf:org/repo") as the served
643
+ // model name so chat requests + served_models match, but the
644
+ // engine underneath is vLLM.
642
645
  const token = process.env.HF_TOKEN || (await resolveHfToken().catch(() => null));
643
- const localPath = await downloadHfModel(repoId, token);
644
- // Serve the repo id, not a computed cache path — vLLM
645
- // resolves it straight from the HF cache we just filled
646
- // (the snapshot dir is a commit hash, not "main"). Serve
647
- // under the hf: pull name so it matches chat requests and
648
- // gets advertised in served_models → shows in /chat.
649
- const serve = await startVllmServe({ source: repoId, servedName: modelName, token });
646
+ const localPath = await downloadHfModel(hfRepo, token);
650
647
  // Don't report "completed" on spawn — wait until vLLM has
651
648
  // mapped the weights and /v1/models actually lists the model.
652
- // If it never comes up (OOM, unsupported arch, bad dtype),
653
- // fail the command WITH the log tail so the operator sees why
654
- // instead of a lying "completed".
655
- process.stdout.write(`[${new Date().toISOString()}] ${modelName} downloaded; waiting for vLLM to load weights…\n`);
649
+ // If it never comes up (OOM, unsupported arch, gated repo),
650
+ // fail the command WITH the log root cause instead of lying.
651
+ const serve = await startVllmServe({ source: hfRepo, servedName: modelName, token });
652
+ process.stdout.write(`[${new Date().toISOString()}] ${modelName} (${hfRepo}) downloaded; waiting for vLLM to load weights…\n`);
656
653
  const up = await waitForVllmModel(modelName, { pid: serve.pid, timeoutMs: 300_000 });
657
654
  if (!up.serving) {
658
655
  const tail = await extractVllmError();
659
656
  throw new Error(
660
- `vLLM failed to serve ${modelName}: ${up.reason}.` +
657
+ `vLLM failed to serve ${modelName} (${hfRepo}): ${up.reason}.` +
661
658
  (tail ? `\n--- vllm.log (root cause) ---\n${tail}` : ' (no vllm.log output)')
662
659
  );
663
660
  }
664
- // Serving for real — bust the specs cache so the very next
665
- // heartbeat advertises the new model in served_models
666
- // (otherwise it's stale until the TTL lapses).
667
661
  invalidateSpecsCache();
668
662
  result = {
669
663
  model: modelName,
670
664
  backend: 'vllm',
665
+ source: hfRepo,
671
666
  localPath,
672
667
  vllm: { pid: serve.pid, port: serve.port },
673
668
  note: `Serving on vLLM :${serve.port} and advertised in served_models.`,
674
669
  };
670
+ } else if (modelName.startsWith('hf:')) {
671
+ // hf: model requested but this node has no vLLM (CPU/Mac).
672
+ throw new Error(
673
+ `${modelName} needs vLLM, which isn't installed on this node. ` +
674
+ `Re-run the installer on an NVIDIA host (it installs vLLM), or: pip install vllm. ` +
675
+ `Alternatively push an Ollama model — those run on CPU.`
676
+ );
675
677
  } else {
678
+ // CPU/Mac path (or a GPU box without a vLLM-servable repo) —
679
+ // Ollama serves the GGUF tag.
676
680
  const fits = await checkModelFits(modelName);
677
681
  if (fits && !fits.ok) {
678
682
  throw new Error(formatFitFailure(modelName, fits));
package/lib/vllm.js CHANGED
@@ -112,7 +112,7 @@ const VLLM_ERROR_PATTERNS = [
112
112
  * few useless traceback frames. Finds the first genuine error line and returns
113
113
  * a window around it; falls back to the plain tail if nothing matches.
114
114
  */
115
- export async function extractVllmError({ context = 24, fallbackTail = 60 } = {}) {
115
+ export async function extractVllmError({ headLines = 16, tailLines = 30, fallbackTail = 60 } = {}) {
116
116
  let txt;
117
117
  try {
118
118
  txt = await fs.readFile(logPath(), 'utf8');
@@ -128,9 +128,20 @@ export async function extractVllmError({ context = 24, fallbackTail = 60 } = {})
128
128
  if (firstErr === -1) {
129
129
  return lines.slice(-fallbackTail).join('\n').trim();
130
130
  }
131
- const start = Math.max(0, firstErr - 2);
132
- const end = Math.min(lines.length, firstErr + context);
133
- return lines.slice(start, end).join('\n').trim();
131
+ // The error region runs from the first error line to the end of the log.
132
+ // vLLM's ACTUAL exception (RuntimeError/OutOfMemory/ValueError) is the LAST
133
+ // line of the traceback, so we must show the tail — not just the head where
134
+ // the "EngineCore failed to start" banner sits. For a long region, show the
135
+ // banner + the final exception with the middle elided.
136
+ const region = lines.slice(Math.max(0, firstErr - 2));
137
+ if (region.length <= headLines + tailLines) {
138
+ return region.join('\n').trim();
139
+ }
140
+ return [
141
+ ...region.slice(0, headLines),
142
+ ` … (${region.length - headLines - tailLines} lines elided) …`,
143
+ ...region.slice(-tailLines),
144
+ ].join('\n').trim();
134
145
  }
135
146
 
136
147
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infernetprotocol/cli",
3
- "version": "0.1.48",
3
+ "version": "0.1.50",
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",
@@ -30,12 +30,12 @@
30
30
  "ora": "^9.4.0",
31
31
  "react": "^17.0.2",
32
32
  "react-blessed": "^0.7.2",
33
- "@infernetprotocol/auth": "0.1.48",
34
- "@infernetprotocol/config": "0.1.48",
35
- "@infernetprotocol/engine": "0.1.48",
36
- "@infernetprotocol/deploy-providers": "0.1.48",
37
- "@infernetprotocol/gpu": "0.1.48",
38
- "@infernetprotocol/rpc-adapter": "0.1.48"
33
+ "@infernetprotocol/auth": "0.1.50",
34
+ "@infernetprotocol/config": "0.1.50",
35
+ "@infernetprotocol/engine": "0.1.50",
36
+ "@infernetprotocol/gpu": "0.1.50",
37
+ "@infernetprotocol/deploy-providers": "0.1.50",
38
+ "@infernetprotocol/rpc-adapter": "0.1.50"
39
39
  },
40
40
  "repository": {
41
41
  "type": "git",