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++
Engine bundle cleanup: one function (cleanupAfterInstall) writes the removed and kept lines to the host output, with a test that both reach it
Niko122167a6ee76f406
diff --git a/apps/host/server/bundled-engine.mjs b/apps/host/server/bundled-engine.mjsindex 1260eb942..62e160295 100644--- a/apps/host/server/bundled-engine.mjs+++ b/apps/host/server/bundled-engine.mjs@@ -276,3 +276,11 @@ function keepBundle(log, why) {log(`engine bundle: kept in the install folder (${why})`);return { removed: false, reason: why };}++/**+ * What the host does once its engine step has settled: for an engine that is (or was) there, look at the install folder's leftover bundle.+ * The lines go to the host's output (console.log), which the desktop shell copies to its log file (`[host] engine bundle: ...`).+ */+export function cleanupAfterInstall(settled, { bundleDir, components, log = line => console.log(line) } = {}) {+ return Promise.resolve(settled).then(result => (['installed', 'kept', 'repaired'].includes(result?.action) ? removeVerifiedBundle({ bundleDir, components, log }) : null), () => null);+}diff --git a/apps/host/server/index.mjs b/apps/host/server/index.mjsindex d0549df3d..0025520ad 100644--- a/apps/host/server/index.mjs+++ b/apps/host/server/index.mjs@@ -70,7 +70,7 @@ import { createImageModels } from './image-models.mjs';import { createRuntimeModels } from './runtime-models.mjs';import { createNativeControl } from './native-control.mjs';import { nativeUnloadPlan } from './storage-check.mjs';-import { installBundledEngine, removeVerifiedBundle } from './bundled-engine.mjs';+import { installBundledEngine, cleanupAfterInstall } from './bundled-engine.mjs';import { findControl, createControl, componentsDirectory } from './control-runtime.mjs';import { forbidden as acquisitionForbidden } from './acquisition.mjs';import { randomBytes, timingSafeEqual } from 'node:crypto';@@ -133,7 +133,7 @@ const bundledEngine = control && !process.env.STRATA_NO_BUNDLED_ENGINE: Promise.resolve({ action: 'none' });const engineBundleDir = process.env.STRATA_ENGINE_BUNDLE_DIR || resolve(HERE, '..', '..', 'engine-bundle');/* An update from a per-GPU installer leaves its engine-bundle behind; it goes only when the same engine is complete in the store (sizes and hashes). */-bundledEngine.then(result => { if (['installed', 'kept', 'repaired'].includes(result?.action)) return removeVerifiedBundle({ bundleDir: engineBundleDir, components: componentsDirectory(), log: line => console.log(line) }); }, () => {});+cleanupAfterInstall(bundledEngine, { bundleDir: engineBundleDir, components: componentsDirectory() });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. */diff --git a/apps/host/tests/bundled-engine.test.mjs b/apps/host/tests/bundled-engine.test.mjsindex 4ebcee2a4..520bd443b 100644--- a/apps/host/tests/bundled-engine.test.mjs+++ b/apps/host/tests/bundled-engine.test.mjs@@ -5,7 +5,7 @@ import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, readdiimport { createHash } from 'node:crypto';import { tmpdir } from 'node:os';import { join } from 'node:path';-import { installBundledEngine, removeVerifiedBundle, compareVersions, wrongMakeNotice } from '../server/bundled-engine.mjs';+import { installBundledEngine, removeVerifiedBundle, cleanupAfterInstall, compareVersions, wrongMakeNotice } from '../server/bundled-engine.mjs';// the make of card is read from this computer unless a test names it; the existing tests are written for an NVIDIA PCprocess.env.STRATA_ENGINE_BACKEND = 'cuda';@@ -229,3 +229,30 @@ test('after an update, the engine bundle of the old install folder is removed onassert.ok(existsSync(join(t.bundle, other)));} finally { t.cleanup(); }});++test('the bundle cleanup lines reach the output of the host (the desktop log copies it), for "removed" and for "kept"', async () => {+ const t = setup();+ const seen = [], real = console.log;+ try {+ const name = makePackage(t.bundle, '0.1.48');+ console.log = line => { seen.push(String(line)); };+ // kept: the engine is not in the store yet+ await cleanupAfterInstall(Promise.resolve({ action: 'kept' }), { bundleDir: t.bundle, components: t.components });+ assert.equal(seen.length, 1);+ assert.match(seen[0], /^engine bundle: kept in the install folder/);+ // removed: the engine is in the store and whole+ const installed = await installBundledEngine({ bundleDir: t.bundle, components: t.components });+ assert.equal(installed.action, 'installed');+ seen.length = 0;+ await cleanupAfterInstall(Promise.resolve({ action: 'kept' }), { bundleDir: t.bundle, components: t.components });+ assert.equal(seen.length, 1);+ assert.match(seen[0], /^engine bundle: the copy that came with the installer \(.*\) was removed/);+ assert.equal(existsSync(join(t.bundle, name)), false);+ // nothing to say when the engine step did nothing (no bundle) or was refused+ seen.length = 0;+ await cleanupAfterInstall(Promise.resolve({ action: 'none' }), { bundleDir: t.bundle, components: t.components });+ await cleanupAfterInstall(Promise.resolve({ action: 'wrong-make' }), { bundleDir: t.bundle, components: t.components });+ await cleanupAfterInstall(Promise.reject(new Error('boom')), { bundleDir: t.bundle, components: t.components });+ assert.deepEqual(seen, []);+ } finally { console.log = real; t.cleanup(); }+});