Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

Starter model list: with the real engine on, the host refuses to download from it (unpinned files); it is display only

Niko12217662bf85c493
diff --git a/apps/host/server/index.mjs b/apps/host/server/index.mjs
index 2852b8f03..514a21e35 100644
--- a/apps/host/server/index.mjs
+++ b/apps/host/server/index.mjs
@@ -1410,7 +1410,7 @@ async function api(req, res, path, method, url) {
if (modelMatch) {
const [, id, action] = modelMatch;
if (method === 'DELETE') {if(runtimeModels.hasVariant(id))return error(res,409,'Unload every instance of this model before deleting its files.');return json(res, 200, runtimeModels.libraryState(models.remove(id)));}
- if (method === 'POST' && action === 'install') return json(res, 200, runtimeModels.libraryState(await models.install(id)));
+ if (method === 'POST' && action === 'install') { try { return json(res, 200, runtimeModels.libraryState(await models.install(id))); } catch (err) { return error(res, err.status ?? 500, err.message); } }
if (method === 'POST' && action === 'cancel') return json(res, 200, runtimeModels.libraryState(models.cancel(id)));
if (method === 'POST' && action === 'load') {
const hw = await hardware.detect();
diff --git a/apps/host/server/models.mjs b/apps/host/server/models.mjs
index 42d2ce3c3..2f64650c7 100644
--- a/apps/host/server/models.mjs
+++ b/apps/host/server/models.mjs
@@ -1,14 +1,11 @@
/**
* Model library.
*
- * Downloads are real: weights stream from Hugging Face into the configured model folder (Documents/Strata/Models by default)
- * with progress, resume-by-restart and a size check. Loading starts a real
- * engine process through the supervisor — no model files, no process, no load.
+ * With the real engine on, the app downloads models from the Models screen of the native engine, not from this list (see install). Loading
+ * starts a real engine process through the supervisor — no model files, no process, no load.
*/
-import { createWriteStream, existsSync, mkdirSync, renameSync, rmSync, statSync } from 'node:fs';
+import { existsSync, rmSync, statSync } from 'node:fs';
import { join } from 'node:path';
-import { Readable } from 'node:stream';
-import { pipeline } from 'node:stream/promises';
import { CONTEXT_TOKENS, VARIANTS, downloadUrl, footprint, localModels, refreshLocalCatalog, variant } from './catalog.mjs';
@@ -140,6 +137,12 @@ function emit() {
/* ---------------------------------------------------------------- download --- */
+/**
+ * With the real engine on, models come from the Models screen of the native engine (its installer pins every file by hash). This
+ * starter list names files by name only and has no hash, so it is never downloaded: the route refuses before any request is made.
+ */
+export const LIST_DOWNLOAD_REFUSED = "The app downloads models from the Models screen of the native engine, not from this list.";
+
export async function install(id) {
const v = variant(id);
if (!v) throw new Error(`Unknown model ${id}`);
@@ -153,99 +156,7 @@ export async function install(id) {
if (downloads.has(id)) return library();
if (!REAL) return simulateInstall(v);
-
- const dir = join(MODELS_DIR, v.id);
- mkdirSync(dir, { recursive: true });
- const finalPath = pathFor(v);
- const partPath = `${finalPath}.part`;
- const controller = new AbortController();
- downloads.set(id, controller);
-
- const startedAt = Date.now();
- runtime.set(id, {
- state: 'downloading',
- progress: { pct: 0, mbps: 0, etaSec: 0, stage: `Fetching ${v.source.file}` },
- });
- emit();
- hubRef?.send('log', { level: 'info', message: `Downloading ${v.label} from ${v.source.repo}`, at: nowIso() });
-
- // Keep the UI fed even while the socket is quiet.
- const ticker = setInterval(() => {
- const entry = runtime.get(id);
- if (!entry || entry.state !== 'downloading') return;
- emit();
- }, 400);
-
- try {
- const res = await fetch(downloadUrl(v), { signal: controller.signal, redirect: 'follow' });
- if (!res.ok || !res.body) throw new Error(`Download failed (${res.status} ${res.statusText})`);
-
- const total = Number(res.headers.get('content-length')) || v.source.bytes;
- let received = 0;
- let lastEmit = 0;
-
- const progressStream = new ReadableStream({
- start(controllerStream) {
- const reader = res.body.getReader();
- const pump = async () => {
- for (;;) {
- const { done, value } = await reader.read();
- if (done) break;
- received += value.byteLength;
- controllerStream.enqueue(value);
- const now = Date.now();
- if (now - lastEmit > 350) {
- lastEmit = now;
- const seconds = (now - startedAt) / 1000;
- const mbps = received / 1024 ** 2 / Math.max(seconds, 0.001);
- runtime.set(id, {
- state: 'downloading',
- progress: {
- pct: (received / total) * 100,
- mbps,
- etaSec: mbps > 0 ? (total - received) / 1024 ** 2 / mbps : 0,
- stage: received / total < 0.9 ? `Fetching ${v.source.file}` : 'Verifying and finalising',
- },
- });
- }
- }
- controllerStream.close();
- };
- void pump().catch((err) => controllerStream.error(err));
- },
- });
-
- await pipeline(Readable.fromWeb(progressStream), createWriteStream(partPath));
- renameSync(partPath, finalPath);
-
- const size = statSync(finalPath).size;
- if (size < v.source.bytes * 0.9) {
- throw new Error(`File is smaller than expected (${(size / 1e9).toFixed(2)} GB of ${(v.source.bytes / 1e9).toFixed(2)} GB)`);
- }
-
- const s = getStore();
- update({
- installed: { ...(s.installed ?? {}), [id]: { installedAt: nowIso(), bytes: size } },
- current: s.current ?? id,
- });
- runtime.set(id, { state: 'installed' });
- hubRef?.send('log', { level: 'info', message: `${v.label} installed (${(size / 1e9).toFixed(2)} GB)`, at: nowIso() });
- } catch (err) {
- const aborted = err?.name === 'AbortError';
- try {
- if (existsSync(partPath)) rmSync(partPath);
- } catch {
- /* ignore */
- }
- runtime.set(id, aborted ? { state: 'available' } : { state: 'error', error: err.message });
- if (!aborted) hubRef?.send('log', { level: 'error', message: `Download failed: ${err.message}`, at: nowIso() });
- } finally {
- clearInterval(ticker);
- downloads.delete(id);
- emit();
- }
-
- return library();
+ throw Object.assign(new Error(LIST_DOWNLOAD_REFUSED), { status: 409 });
}
export function cancel(id) {
diff --git a/apps/host/server/real-model-catalog.mjs b/apps/host/server/real-model-catalog.mjs
index b0e0df3db..5229054ff 100644
--- a/apps/host/server/real-model-catalog.mjs
+++ b/apps/host/server/real-model-catalog.mjs
@@ -1,4 +1,8 @@
-/** Verified file identities for the optional real engine. Never relabel these as demo weights. */
+/**
+ * The starter list shown with the optional real engine. It is display only: nothing downloads from it (models.install refuses when the real
+ * engine is on), because these files are named without a hash. Models come from the Models screen of the native engine, which pins them.
+ * Never relabel these as demo weights.
+ */
export const REAL_VARIANTS = [
{
id: 'qwen2.5-0.5b-q4km',
diff --git a/apps/host/tests/models-list-refused.test.mjs b/apps/host/tests/models-list-refused.test.mjs
new file mode 100644
index 000000000..42aef8e6f
--- /dev/null
+++ b/apps/host/tests/models-list-refused.test.mjs
@@ -0,0 +1,31 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { mkdtempSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+
+/**
+ * The starter list (real-model-catalog.mjs) names five files by repository and file name with no hash. With the real engine on, nothing
+ * may download from it. REAL is read when the module loads, and node --test runs each file in its own process, so this file sets it first.
+ */
+const home = mkdtempSync(join(tmpdir(), 'strata-list-'));
+process.env.STRATA_HOME = home;
+process.env.STRATA_MODELS_DIR = join(home, 'models');
+process.env.STRATA_REAL_ENGINE = '1';
+const calls = [];
+const realFetch = globalThis.fetch;
+globalThis.fetch = (...args) => { calls.push(String(args[0])); return Promise.reject(new Error('no network in this test')); };
+const models = await import('../server/models.mjs');
+const { REAL_VARIANTS } = await import('../server/real-model-catalog.mjs');
+test.after(() => { globalThis.fetch = realFetch; rmSync(home, { recursive: true, force: true }); });
+
+test('with the real engine on, installing from the starter list is refused before any request, for every entry', async () => {
+ assert.equal(models.REAL, true);
+ assert.ok(REAL_VARIANTS.length >= 1);
+ for (const v of REAL_VARIANTS) {
+ await assert.rejects(models.install(v.id), err => err.status === 409 && err.message === 'The app downloads models from the Models screen of the native engine, not from this list.', v.id);
+ }
+ assert.deepEqual(calls, [], 'no request was made');
+ // nothing was left half-started
+ for (const v of REAL_VARIANTS) assert.notEqual(models.library().variants.find(row => row.id === v.id)?.state, 'downloading');
+});