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++
host: STRATA_TEST_HARDWARE stands in for the probes in tests; the two lifecycle tests no longer depend on the memory of the PC running them
Niko1221135430b0769a
diff --git a/apps/host/server/hardware.mjs b/apps/host/server/hardware.mjsindex 347d586ce..e747ead78 100644--- a/apps/host/server/hardware.mjs+++ b/apps/host/server/hardware.mjs@@ -31,17 +31,26 @@ export function cachedHardware() {return cached ?? null;}+function testHardware() {+ const raw = process.env.STRATA_TEST_HARDWARE;+ if (!raw) return null;+ try { const value = JSON.parse(raw); return value && typeof value === 'object' ? value : null; } catch { return null; }+}+export async function detect({ force = false } = {}) {if (!force && cached && Date.now() - cachedAt < 30_000) return cached;const platform = process.platform;const arch = process.arch;- const totalGb = os.totalmem() / 1024 ** 3;+ // Tests only: STRATA_TEST_HARDWARE='{"totalGb":128,"freeGb":100,"gpus":[...]}' stands in for the probes, so a+ // test about routing or lifecycle does not depend on how much memory the machine running it has.+ const forced = testHardware();+ const totalGb = forced?.totalGb ?? os.totalmem() / 1024 ** 3;// os.freemem() ignores reclaimable pages, which reads as "0 GB free" on macOS.- const freeGb = (await availableMemoryGb(platform)) ?? os.freemem() / 1024 ** 3;+ const freeGb = forced?.freeGb ?? (await availableMemoryGb(platform)) ?? os.freemem() / 1024 ** 3;const cpu = await detectCpu(platform);- const gpus = await detectGpus(platform, totalGb);+ const gpus = forced?.gpus ?? await detectGpus(platform, totalGb);const accelerator = pickAccelerator(gpus, cpu, totalGb);const hw = {diff --git a/apps/host/tests/helpers/hardware.mjs b/apps/host/tests/helpers/hardware.mjsnew file mode 100644index 000000000..402aa7bc6--- /dev/null+++ b/apps/host/tests/helpers/hardware.mjs@@ -0,0 +1,9 @@+/** A roomy machine for tests about routing and lifecycle, whatever the memory of the PC running them. */+export const ROOMY_HOST = JSON.stringify({+ totalGb: 256,+ freeGb: 200,+ gpus: [+ { id: 'GPU-test-0', index: 0, sensorIndex: 0, vendor: 'nvidia', name: 'NVIDIA RTX 6000 Test', vramGb: 96, unified: false, backend: 'cuda', driver: '999.0' },+ { id: 'GPU-test-1', index: 1, sensorIndex: 1, vendor: 'nvidia', name: 'NVIDIA RTX 6000 Test', vramGb: 96, unified: false, backend: 'cuda', driver: '999.0' },+ ],+});diff --git a/apps/host/tests/local-models.test.mjs b/apps/host/tests/local-models.test.mjsindex ad1281291..6aebd7031 100644--- a/apps/host/tests/local-models.test.mjs+++ b/apps/host/tests/local-models.test.mjs@@ -1,3 +1,4 @@+import { ROOMY_HOST } from './helpers/hardware.mjs';import { fileURLToPath } from 'node:url';import test from 'node:test';import assert from 'node:assert/strict';@@ -60,7 +61,7 @@ async function freePort(){const server=createServer();await new Promise(r=>servetest('HTTP import leaves the running model intact, loads through normal controls, protects active references and preserves files on removal',{timeout:30000},async t=>{const root=fixture(t),home=join(root,'host'),file=join(root,'huihui-Orca.gguf');mkdirSync(join(home,'data'),{recursive:true});ggufFixture(file);writeFileSync(join(home,'data','state.json'),JSON.stringify({setup:{complete:true,step:4,flowVersion:2},installed:{'qwen38-q4_k_m':{simulated:true}},loaded:'qwen38-q4_k_m'}));- const port=await freePort(),base=`http://127.0.0.1:${port}`,host=spawn(process.execPath,['server/index.mjs'],{cwd,env:{...process.env,STRATA_HOME:home,STRATA_MODELS_DIR:join(home,'models'),STRATA_REAL_ENGINE:'0',STRATA_PORT:String(port),STRATA_BIND:'127.0.0.1'},stdio:'ignore'});+ const port=await freePort(),base=`http://127.0.0.1:${port}`,host=spawn(process.execPath,['server/index.mjs'],{cwd,env:{...process.env,STRATA_HOME:home,STRATA_MODELS_DIR:join(home,'models'),STRATA_REAL_ENGINE:'0',STRATA_TEST_HARDWARE:ROOMY_HOST,STRATA_PORT:String(port),STRATA_BIND:'127.0.0.1'},stdio:'ignore'});async function call(path,body,method){const response=await fetch(base+path,{method:method??(body===undefined?'GET':'POST'),headers:{'content-type':'application/json'},body:body===undefined?undefined:JSON.stringify(body)});return {status:response.status,body:await response.json()};}try {let ready=false;for(let i=0;i<100;i++){try{ready=(await call('/api/runtime')).status===200;if(ready)break;}catch{}await pause(100);}assert.ok(ready);diff --git a/apps/host/tests/runtime-api.test.mjs b/apps/host/tests/runtime-api.test.mjsindex 4afd6ef22..42fdd2734 100644--- a/apps/host/tests/runtime-api.test.mjs+++ b/apps/host/tests/runtime-api.test.mjs@@ -1,3 +1,4 @@+import { ROOMY_HOST } from './helpers/hardware.mjs';import { fileURLToPath } from 'node:url';import test from 'node:test';import assert from 'node:assert/strict';@@ -12,7 +13,7 @@ test('HTTP gateway lists all models, routes both protocols exactly, and isolatesconst home=await mkdtemp(join(tmpdir(),'strata-multiple-model-test-'));await mkdir(join(home,'data'));await writeFile(join(home,'data','state.json'),JSON.stringify({installed:{'qwen38-q4_k_m':{installedAt:'2026-10-14',simulated:true},'qwen36-q4_k_m':{installedAt:'2026-10-14',simulated:true}}}));const port=await freePort(),base=`http://127.0.0.1:${port}`;- const host=spawn(process.execPath,['server/index.mjs'],{cwd:fileURLToPath(new URL('..',import.meta.url)),env:{...process.env,STRATA_HOME:home,STRATA_MODELS_DIR:join(home,'models'),STRATA_REAL_ENGINE:'0',STRATA_PORT:String(port),STRATA_BIND:'127.0.0.1'},stdio:'ignore'});+ const host=spawn(process.execPath,['server/index.mjs'],{cwd:fileURLToPath(new URL('..',import.meta.url)),env:{...process.env,STRATA_HOME:home,STRATA_MODELS_DIR:join(home,'models'),STRATA_REAL_ENGINE:'0',STRATA_TEST_HARDWARE:ROOMY_HOST,STRATA_PORT:String(port),STRATA_BIND:'127.0.0.1'},stdio:'ignore'});async function call(path,body){const response=await fetch(base+path,{method:body===undefined?'GET':'POST',headers:{'content-type':'application/json'},body:body===undefined?undefined:JSON.stringify(body)});return {status:response.status,body:await response.json()};}try{let ready=false;for(let i=0;i<80;i++){try{ready=(await call('/api/runtime')).status===200;if(ready)break;}catch{}await delay(100);}assert.ok(ready,'test host started');