mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
- engine_component: component:strata-q4-lite/<program> resolves the component as before (hashes and signature checked) and returns the sibling program; a package without it says Qwen4-35B-A3B needs a newer engine (exit 5); a program name is a plain file name; plain references are byte-identical.
- qwen4_family: STRATA_PROGRAM, GGUF_PROGRAM, exe_reference(build), program_of, engine_has_program, QWEN4_STRATA_ENGINE_MIN (None until packaging reports the first version); shape_engine.exe_name("q4_lite") stays strata.
- shape_engine: EXTRA_PROGRAMS, the install test-start also runs strata-q4-lite --version when present (first token must be its name); a package with only strata still installs and the GGUF build works.
- setup, adopt, launcher, serve, MCP and the host write and read the right reference per build; the catalog row carries engine_has_program for the .strata sizes and the Models panel shows the existing needs-a-newer-engine text and update button.
- package_engine chmods the shape extra programs; Q4-GGUF's packager must --include strata-q4-lite.
- tests: test_q4_programs (23), engine-program.test.mjs, launch tests and the spawn-site count updated.
43 lines
2.6 KiB
JavaScript
43 lines
2.6 KiB
JavaScript
/**
|
|
* Does the installed engine read a model's files? The catalog (tools/strata_mcp.py, from setup.py's MODELS) names the first engine
|
|
* that does (`engine_min`, e.g. Gyro: 0.1.45.1, because its expert files are native_experts v5 and the released 0.1.45 stops at v4).
|
|
* An older engine would start the download and then fail on the files, so the app says "needs a newer engine" first.
|
|
*/
|
|
export function parseEngineVersion(value) {
|
|
const m = /^\s*v?(\d+(?:\.\d+){0,3})/.exec(String(value ?? ''));
|
|
return m ? m[1].split('.').map(Number) : null;
|
|
}
|
|
|
|
/** True when `installed` is known and older than `minimum`. An engine built from this checkout ('local') or one whose version cannot be read is never called too old. */
|
|
export function engineTooOld(installed, minimum, source = null) {
|
|
if (!minimum || source === 'local') return false;
|
|
const have = parseEngineVersion(installed), need = parseEngineVersion(minimum);
|
|
if (!have || !need) return false;
|
|
for (let i = 0; i < 4; i++) {
|
|
const a = have[i] ?? 0, b = need[i] ?? 0;
|
|
if (a !== b) return a < b;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/** A size that names the program it runs on (Qwen4's .strata builds: `strata-q4-lite` inside the q4_lite engine folder, `engine_has_program` from the catalog) needs a newer engine
|
|
* when the installed folder lacks it. Only an explicit false counts: a catalog without the field, or null (no engine installed yet), never marks a size. */
|
|
export function lacksProgram(size) {
|
|
return size?.engine_has_program === false;
|
|
}
|
|
|
|
/** The catalog with `needsNewerEngine` on every size the installed engine cannot read. */
|
|
export function markEngine(catalog, engine) {
|
|
if (!catalog || !Array.isArray(catalog.families)) return catalog;
|
|
const version = engine?.version ?? null, source = engine?.source ?? null;
|
|
return { ...catalog, families: catalog.families.map(f => ({ ...f, sizes: (f.sizes ?? []).map(s => ({ ...s, needsNewerEngine: lacksProgram(s) || engineTooOld(version, s.engine_min, source) })) })) };
|
|
}
|
|
|
|
/** The plain sentence for a refused install or load, or null when the engine is new enough. */
|
|
export function engineRefusal(catalog, modelId, engine) {
|
|
const size = catalog?.families?.flatMap(f => f.sizes ?? []).find(s => s.id === modelId);
|
|
if (!size?.needsNewerEngine) return null;
|
|
if (lacksProgram(size)) return `This model needs a newer engine: ${size.model} runs on a program the installed engine does not have yet. Update the engine in Settings, then try again.`;
|
|
return `This model needs a newer engine: ${size.model} needs engine ${size.engine_min} or newer, and this one is ${engine?.version}. Update the engine in Settings, then try again.`;
|
|
}
|