From 5b4db785ca966034d12d64d3e710a39dfc3c4aac Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Mon, 19 Oct 2026 19:40:57 +0200 Subject: [PATCH] Start-up line: an installed engine with no model loaded is not 'No Strata engine' (J), and the wrong-make notice wiring --- apps/host/server/index.mjs | 16 ++++++++++++++-- apps/host/server/inference.mjs | 12 ++++++++++++ apps/host/tests/inference-line.test.mjs | 21 +++++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 apps/host/tests/inference-line.test.mjs diff --git a/apps/host/server/index.mjs b/apps/host/server/index.mjs index 2852b8f0..27c84d10 100644 --- a/apps/host/server/index.mjs +++ b/apps/host/server/index.mjs @@ -44,7 +44,7 @@ import * as serving from './serving.mjs'; import * as store from './store.mjs'; import * as supervisor from './supervisor.mjs'; import * as engineInstall from './engine-install.mjs'; -import { detectBackend, currentBackend, streamChat } from './inference.mjs'; +import { detectBackend, currentBackend, streamChat, inferenceLine } from './inference.mjs'; import { CONTEXT_TOKENS, VARIANTS, localModels, variant } from './catalog.mjs'; import { browseLocalModels, inspectLocalModel } from './local-models.mjs'; import { EventHub, error, json, readBody, readRaw, uid } from './util.mjs'; @@ -126,6 +126,16 @@ const bundledEngine = control && !process.env.STRATA_NO_BUNDLED_ENGINE : Promise.resolve({ action: 'none' }); let bundledEngineSettled = !(control && !process.env.STRATA_NO_BUNDLED_ENGINE); bundledEngine.then(() => { bundledEngineSettled = true; }, () => { bundledEngineSettled = true; }); +/* A build made for another make of graphics card is not unpacked; Control's answer then carries the plain sentence (with the right download) instead of its own. */ +let bundledWrongMake = null; +bundledEngine.then(result => { if (result?.action === 'wrong-make') { bundledWrongMake = result.notice; console.log(result.notice); } }, () => {}); +if (control) { + const engineOf = control.engine.bind(control); + control.engine = async (...args) => { + const answer = await engineOf(...args); + return answer && !answer.usable && bundledWrongMake ? { ...answer, notice: bundledWrongMake, wrongMake: true } : answer; + }; +} const native=createNativeControl({control,ready:bundledEngine,appUpdater,hardwareProbe:()=>(hardware.cachedHardware()?.gpus??[]).map((g,n)=>({index:g.index??n,vram_gb:g.vramGb})),directory:store.DATA_DIR,modelsDirectory:()=>store.MODELS_DIR,nativeDataDirectory:store.nativeDataDirectory,beforeLoad:async()=>{if(models.REAL&&models.library().loaded){if(serving.state().requests.some(r=>runtimeModels.state().instances.some(i=>i.id===r.instanceId)&&["queued","generating"].includes(r.state)))throw new Error("Finish requests before switching engines.");await models.unload();runtimeState();}},requests:()=>serving.state().requests,changed:value=>hub.send('native',value)}); /* The agent: chats become DeepSeek Harness sessions when that component is installed. It is a separate pinned component (STRATA_HARNESS_DIR), not part of this host, so its absence is a visible capability @@ -240,7 +250,9 @@ const backend = await detectBackend({ force: true }); console.log(`strata host · http://${HOST}:${PORT}`); console.log(`hardware · ${boot.accelerator.label} / ${boot.accelerator.backend} / ${boot.cpu.cores} cores / ${Math.round(boot.memory.totalGb)} GB`); -console.log(`inference · ${models.REAL ? (bundledEngineSettled ? backend.name : 'unpacking the bundled engine… (about a minute the first time)') : 'simulated (design iteration) — set STRATA_REAL_ENGINE=1 for a real engine'}`); +const printInference = engine => console.log(`inference · ${models.REAL ? inferenceLine({ backend, engine, settled: bundledEngineSettled }) : 'simulated (design iteration) — set STRATA_REAL_ENGINE=1 for a real engine'}`); +if (models.REAL && control && backend.kind === 'unavailable' && bundledEngineSettled) void control.engine().catch(() => null).then(printInference); +else printInference(null); console.log(`models dir · ${store.MODELS_DIR}`); console.log(`workspace · ${WORKSPACE}`); diff --git a/apps/host/server/inference.mjs b/apps/host/server/inference.mjs index c3735863..838348e3 100644 --- a/apps/host/server/inference.mjs +++ b/apps/host/server/inference.mjs @@ -523,3 +523,15 @@ async function demoCompletion({ message, modelLabel, onFrame, signal, engine, ca onFrame({ type: 'done', tokensIn: promptTokens, tokensOut: emitted, tps, durationMs, demo: true, usageSource: 'demo' }); return { tokensIn: promptTokens, tokensOut: emitted, durationMs, tps, usageSource: 'demo' }; } + +/** + * The start-up line "inference · ...". The worker that serves a model is only running once a model is loaded, so on a restart nothing answers + * at the worker's address even though the engine is installed and usable; the line says that instead of "No Strata engine". + * `engine` is Control's answer (null when there is no Control, as in a source checkout). + */ +export function inferenceLine({ backend, engine = null, settled = true }) { + if (!settled) return 'unpacking the bundled engine… (about a minute the first time)'; + if (backend?.kind !== 'unavailable' || !engine) return backend?.name ?? 'No Strata engine'; + if (engine.usable) return `Strata engine${engine.engine?.version ? ' ' + engine.engine.version : ''} is installed; no model is loaded yet`; + return engine.notice ? `No Strata engine for this PC. ${engine.notice}` : backend.name; +} diff --git a/apps/host/tests/inference-line.test.mjs b/apps/host/tests/inference-line.test.mjs new file mode 100644 index 00000000..7bd52982 --- /dev/null +++ b/apps/host/tests/inference-line.test.mjs @@ -0,0 +1,21 @@ +/** The start-up "inference" line: an installed engine with no model loaded is not "No Strata engine" (rx9070 AppImage, second start). */ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { inferenceLine } from '../server/inference.mjs'; + +const none = { kind: 'unavailable', name: 'No Strata engine' }; + +test('a restart with the engine installed and no model loaded says so', () => { + const line = inferenceLine({ backend: none, engine: { usable: true, engine: { version: '0.1.45.3' } } }); + assert.equal(line, 'Strata engine 0.1.45.3 is installed; no model is loaded yet'); +}); + +test('no usable engine keeps the plain reason', () => { + assert.equal(inferenceLine({ backend: none, engine: { usable: false, notice: 'This Strata is for AMD cards.' } }), 'No Strata engine for this PC. This Strata is for AMD cards.'); + assert.equal(inferenceLine({ backend: none, engine: null }), 'No Strata engine'); +}); + +test('a running worker and the unpacking message are unchanged', () => { + assert.equal(inferenceLine({ backend: { kind: 'strata', name: 'Strata engine' }, engine: null }), 'Strata engine'); + assert.match(inferenceLine({ backend: none, settled: false }), /^unpacking/); +});