Start-up line: an installed engine with no model loaded is not 'No Strata engine' (J), and the wrong-make notice wiring

This commit is contained in:
Niko1221 committed 2026-10-19 19:40:57 +02:00
1 parent 40bf5f5c40
commit 5b4db785ca
3 files changed
+47 -2

No files matched your search

+14 -2
View File
@@ -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}`);
+12
View File
@@ -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;
}
+21
View File
@@ -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/);
});