Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

refactor: make client runnerFamilies.js a re-export of server/lib/runners.js (#6818)

[._.]/ Adam Eivye79c32484a8d
diff --git a/client/src/lib/runnerFamilies.js b/client/src/lib/runnerFamilies.js
index 0553c5ceb4..90b579bf19 100644
--- a/client/src/lib/runnerFamilies.js
+++ b/client/src/lib/runnerFamilies.js
@@ -1,136 +1,19 @@
-// Mirror of server/lib/runners.js — keep byte-for-byte in sync.
-// Vite's fs.allow doesn't cross the server/ boundary, so the client carries
-// its own copy of the canonical runner-family ids. The shape-invariant test
-// in server/lib/runners.test.js is the contract.
-
-export const RUNNER_FAMILIES = Object.freeze({
- MFLUX: 'mflux',
- FLUX2: 'flux2',
- Z_IMAGE: 'z-image',
- ERNIE: 'ernie',
- HIDREAM: 'hidream',
- QWEN: 'qwen',
-});
-
-// Predicate: model runs through the generic diffusers runner script and so
-// shares the FLUX.2 venv's health check (isFlux2VenvHealthy in
-// server/lib/pythonSetup.js) — Z-Image, ERNIE, HiDream, and Qwen all dispatch
-// through that same shared torch venv rather than the mflux interpreter.
-// Mirror of server/lib/runners.js#usesDiffusersRunner.
-const DIFFUSERS_RUNNER_SET = new Set([
- RUNNER_FAMILIES.Z_IMAGE, RUNNER_FAMILIES.ERNIE, RUNNER_FAMILIES.HIDREAM, RUNNER_FAMILIES.QWEN,
-]);
-export const usesDiffusersRunner = (model) => DIFFUSERS_RUNNER_SET.has(model?.runner);
-
-// Video-LoRA families — kept separate from the image RUNNER_FAMILIES so the
-// Civitai iteration (which only knows image baseModels) never sees them. Video
-// LoRAs are imported from HuggingFace. Mirror of server/lib/runners.js.
-export const VIDEO_LORA_FAMILIES = Object.freeze({
- LTX_VIDEO: 'ltx-video',
- MINIMAX_H3: 'minimax-h3',
-});
-
-// Predicate: is this LoRA family a video family (vs. an image RUNNER_FAMILIES
-// one)? Backs the Image/Video filter on /models/loras. Anything not in
-// VIDEO_LORA_FAMILIES (including null/legacy) is treated as image. Mirror of
-// server/lib/runners.js.
-const VIDEO_LORA_FAMILY_SET = new Set(Object.values(VIDEO_LORA_FAMILIES));
-export const isVideoLoraFamily = (family) => VIDEO_LORA_FAMILY_SET.has(family);
-// The MiniMax H3 runtimes: PipeNetwork's Apple-Silicon MLX port (`minimax_h3`)
-// and the diffusers + CUDA path Windows/Linux NVIDIA boxes run
-// (`minimax_h3_cuda`). They load the same weights family, so every control H3
-// fixes in the model itself — 24 fps, joint video+audio, CFG-distilled (no
-// negative prompt), the 17n+5 frame grid, no tiling knob — is true of both.
-// Gates asserting one of those facts ask this predicate instead of naming a
-// single runtime, which is what would silently exempt the other one.
-// Mirror of server/lib/runners.js.
-export const MINIMAX_H3_REF2VA_RUNTIME = 'minimax_h3_ref2va';
-export const MINIMAX_H3_RUNTIMES = Object.freeze([
- 'minimax_h3',
- 'minimax_h3_cuda',
+export {
+ RUNNER_FAMILIES,
+ VIDEO_LORA_FAMILIES,
+ isVideoLoraFamily,
MINIMAX_H3_REF2VA_RUNTIME,
-]);
-const MINIMAX_H3_RUNTIME_SET = new Set(MINIMAX_H3_RUNTIMES);
-export const isMiniMaxH3Runtime = (runtime) => MINIMAX_H3_RUNTIME_SET.has(runtime);
-// dgrauet's LTX-2.3 pin (`ltx2`) and the LTX-2.5 fork (`ltx25`) share the
-// same pipeline surface — true FFLF, video-conditioned extend, a2v, IC-LoRA —
-// so capability gates ask this predicate instead of naming one id. The venvs
-// stay separate: 2.5 is a different checkout and cannot load on the 2.3 pin.
-// Mirror of server/lib/runners.js.
-export const LTX2_FAMILY_RUNTIMES = Object.freeze(['ltx2', 'ltx25']);
-const LTX2_FAMILY_RUNTIME_SET = new Set(LTX2_FAMILY_RUNTIMES);
-export const isLtx2FamilyRuntime = (runtime) => LTX2_FAMILY_RUNTIME_SET.has(runtime);
-export const AUDIO_TO_VIDEO_RUNTIMES = Object.freeze([
- ...LTX2_FAMILY_RUNTIMES,
- MINIMAX_H3_REF2VA_RUNTIME,
-]);
-const AUDIO_TO_VIDEO_RUNTIME_SET = new Set(AUDIO_TO_VIDEO_RUNTIMES);
-export const isAudioToVideoRuntime = (runtime) => AUDIO_TO_VIDEO_RUNTIME_SET.has(runtime);
-
-// The family an INSTALLED LoRA belongs to. `loraCompatKey` is the refined key
-// (e.g. flux2-9b) written by the importer; `runnerFamily` is the coarse legacy
-// field a pre-sidecar install may be the only thing carrying. One helper so the
-// `||` fallback can't drift between the pickers, the family filters, and the
-// deep-link handoff. Mirror of server/lib/runners.js#loraFamilyOf.
-export const loraFamilyOf = (lora) => lora?.loraCompatKey || lora?.runnerFamily || null;
-
-// A LoRA-quantization marker (`q4` / `q8`) in a model's id/repo/name. Leading
-// boundary + trailing non-digit lookahead catches delimited (`-q4`, `q8_0`) and
-// suffixed (`q4bit`) forms while not matching `q40`. Mirror of server/lib/runners.js.
-const QUANTIZED_LTX_RE = /(?:^|[-_/\s])q(?:4|8)(?![0-9])/i;
-
-// True when an mlx_video-runtime model is a non-quantized LTX-2.x model whose
-// LoRAs PortOS can fuse offline (scripts/generate_av_lora.py merges the deltas
-// into the transformer before generation). Excludes quantized q4/q8 variants
-// (bf16-only scope) and the Windows LTX-Video 0.9.5 model. Mirror of
-// server/lib/runners.js#isMlxVideoLtxLoraCapable.
-export const isMlxVideoLtxLoraCapable = (model) => {
- if (model?.runtime !== 'mlx_video') return false;
- const hay = `${model?.id || ''} ${model?.repo || ''} ${model?.name || ''}`;
- if (!/ltx-?2/i.test(hay)) return false;
- if (QUANTIZED_LTX_RE.test(hay)) return false;
- return true;
-};
-
-// Map a video model (carries `runtime`, not `runner`) to its LoRA family. Both
-// the dgrauet `ltx2` runtime and non-quantized LTX-2.x `mlx_video` models fuse
-// user LoRAs. `minimax_h3` can take them only when the *installed* runner can
-// apply them to the quantized DiT at runtime — a property of the pinned
-// checkout that the client can't derive, so the server decorates each model
-// with `runtimeLoraCapable` and this reads it off the payload. Everything else
-// returns null so the VideoGen picker hides itself.
-// Mirror of server/lib/runners.js#videoLoraFamily.
-export const videoLoraFamily = (model) => {
- if (isLtx2FamilyRuntime(model?.runtime) || isMlxVideoLtxLoraCapable(model)) return VIDEO_LORA_FAMILIES.LTX_VIDEO;
- if (model?.runtime === 'minimax_h3' && model?.runtimeLoraCapable === true) return VIDEO_LORA_FAMILIES.MINIMAX_H3;
- return null;
-};
-
-// FLUX.2 Klein ships in two sizes with different transformer hidden dims (4B =
-// 3072, 9B = 4096), so a LoRA trained for one can't load on the other. The
-// size is encoded in the model id/repo. Returns '4b' | '9b' | null. Mirror of
-// the same helper in server/lib/runners.js.
-export const flux2VariantFromModel = (model) => {
- for (const s of [model?.id, model?.repo]) {
- if (typeof s !== 'string') continue;
- const m = s.match(/(?:^|[-_/])(?:klein-?)?([49])b(?:[-_./]|$)/i);
- if (m) return `${m[1]}b`;
- }
- return null;
-};
-
-// Encode a (runner family, size variant) pair into the compat-key string the
-// LoRA picker matches on. The ONE place the `<family>-<variant>` convention is
-// written client-side (LoraPicker.familyOf decodes it). Mirror of
-// server/lib/runners.js.
-export const composeCompatKey = (family, variant) =>
- family === RUNNER_FAMILIES.FLUX2 && variant ? `${family}-${variant}` : family;
-
-// Fine-grained LoRA compatibility key for a model. FLUX.2 → `flux2-4b` /
-// `flux2-9b` (or bare `flux2` when size is unknown); every other family → its
-// runner id.
-export const loraCompatKey = (model) =>
- composeCompatKey(
- model?.runner || RUNNER_FAMILIES.MFLUX,
- model?.runner === RUNNER_FAMILIES.FLUX2 ? flux2VariantFromModel(model) : null,
- );
+ MINIMAX_H3_RUNTIMES,
+ isMiniMaxH3Runtime,
+ LTX2_FAMILY_RUNTIMES,
+ isLtx2FamilyRuntime,
+ AUDIO_TO_VIDEO_RUNTIMES,
+ isAudioToVideoRuntime,
+ loraFamilyOf,
+ isMlxVideoLtxLoraCapable,
+ videoLoraFamily,
+ flux2VariantFromModel,
+ composeCompatKey,
+ loraCompatKey,
+ usesDiffusersRunner,
+} from '../../../server/lib/runners.js';
diff --git a/client/src/lib/runnerFamilies.test.js b/client/src/lib/runnerFamilies.test.js
deleted file mode 100644
index e9e4186674..0000000000
--- a/client/src/lib/runnerFamilies.test.js
+++ /dev/null
@@ -1,74 +0,0 @@
-import { describe, it, expect } from 'vitest';
-import {
- RUNNER_FAMILIES, VIDEO_LORA_FAMILIES, flux2VariantFromModel, isVideoLoraFamily,
- loraCompatKey, composeCompatKey, loraFamilyOf, videoLoraFamily, usesDiffusersRunner,
-} from './runnerFamilies';
-
-// This is the client mirror of server/lib/runners.js. The server suite greps
-// this file for the helper *names*; these tests pin their *behavior* so the
-// two copies can't silently diverge.
-describe('runnerFamilies mirror', () => {
- it('exports the canonical ids', () => {
- expect(RUNNER_FAMILIES.FLUX2).toBe('flux2');
- expect(RUNNER_FAMILIES.MFLUX).toBe('mflux');
- });
-
- it('flux2VariantFromModel reads the size from id then repo', () => {
- expect(flux2VariantFromModel({ id: 'flux2-klein-4b' })).toBe('4b');
- expect(flux2VariantFromModel({ id: 'flux2-klein-9b-bf16' })).toBe('9b');
- expect(flux2VariantFromModel({ id: 'x', repo: 'Disty0/FLUX.2-klein-9B-SDNQ' })).toBe('9b');
- expect(flux2VariantFromModel({ id: 'flux2-klein' })).toBe(null);
- expect(flux2VariantFromModel(null)).toBe(null);
- });
-
- it('loraCompatKey refines flux2 and passes other families through', () => {
- expect(loraCompatKey({ runner: 'flux2', id: 'flux2-klein-4b' })).toBe('flux2-4b');
- expect(loraCompatKey({ runner: 'flux2', id: 'flux2-klein-9b' })).toBe('flux2-9b');
- expect(loraCompatKey({ runner: 'flux2', id: 'flux2-klein' })).toBe('flux2');
- expect(loraCompatKey({ runner: 'z-image', id: 'z-image-turbo-bf16' })).toBe('z-image');
- expect(loraCompatKey({ id: 'dev' })).toBe('mflux');
- });
-
- it('composeCompatKey encodes a flux2 variant and leaves other cases bare', () => {
- expect(composeCompatKey('flux2', '9b')).toBe('flux2-9b');
- expect(composeCompatKey('flux2', null)).toBe('flux2');
- expect(composeCompatKey('mflux', '4b')).toBe('mflux');
- expect(composeCompatKey(null, null)).toBe(null);
- });
-
- // The picker is driven entirely by this function, so a mirror drift here
- // shows the user a LoRA control the server would then 400 on.
- it('videoLoraFamily gates minimax_h3 on the server-decorated runtime capability', () => {
- expect(videoLoraFamily({ runtime: 'ltx2' })).toBe(VIDEO_LORA_FAMILIES.LTX_VIDEO);
- expect(videoLoraFamily({ runtime: 'minimax_h3', runtimeLoraCapable: true })).toBe(VIDEO_LORA_FAMILIES.MINIMAX_H3);
- expect(videoLoraFamily({ runtime: 'minimax_h3', runtimeLoraCapable: false })).toBe(null);
- // undecorated payload (server older than this client) must fail closed
- expect(videoLoraFamily({ runtime: 'minimax_h3' })).toBe(null);
- expect(videoLoraFamily({ runtime: 'wan22', runtimeLoraCapable: true })).toBe(null);
- });
-
- it('loraFamilyOf prefers the refined compat key over the legacy coarse field', () => {
- expect(loraFamilyOf({ loraCompatKey: 'flux2-9b', runnerFamily: 'flux2' })).toBe('flux2-9b');
- expect(loraFamilyOf({ runnerFamily: 'ltx-video' })).toBe('ltx-video');
- expect(loraFamilyOf({})).toBe(null);
- expect(loraFamilyOf(null)).toBe(null);
- });
-
- it('usesDiffusersRunner matches the shared-torch-venv families, not flux2/mflux', () => {
- expect(usesDiffusersRunner({ runner: RUNNER_FAMILIES.Z_IMAGE })).toBe(true);
- expect(usesDiffusersRunner({ runner: RUNNER_FAMILIES.ERNIE })).toBe(true);
- expect(usesDiffusersRunner({ runner: RUNNER_FAMILIES.HIDREAM })).toBe(true);
- expect(usesDiffusersRunner({ runner: RUNNER_FAMILIES.QWEN })).toBe(true);
- expect(usesDiffusersRunner({ runner: RUNNER_FAMILIES.FLUX2 })).toBe(false);
- expect(usesDiffusersRunner({ runner: RUNNER_FAMILIES.MFLUX })).toBe(false);
- expect(usesDiffusersRunner(null)).toBe(false);
- });
-
- it('treats both video families as video, so an H3 LoRA deep-links to Video Gen', () => {
- expect(isVideoLoraFamily(VIDEO_LORA_FAMILIES.MINIMAX_H3)).toBe(true);
- expect(isVideoLoraFamily(VIDEO_LORA_FAMILIES.LTX_VIDEO)).toBe(true);
- expect(isVideoLoraFamily(RUNNER_FAMILIES.FLUX2)).toBe(false);
- expect(isVideoLoraFamily(null)).toBe(false);
- });
-});
-// @vitest-environment node
diff --git a/server/lib/runners.js b/server/lib/runners.js
index e6e8c81370..3ea376c310 100644
--- a/server/lib/runners.js
+++ b/server/lib/runners.js
@@ -11,9 +11,8 @@
* `runner === 'z-image'` (right). Importing from this module locks the
* canonical strings in place.
*
- * The client mirrors this list at `client/src/lib/runnerFamilies.js` —
- * Vite's fs.allow doesn't cross the server/ boundary, so we keep the two
- * files manually in sync (same convention as `scenePrompt.js`).
+ * `client/src/lib/runnerFamilies.js` re-exports this module directly (same
+ * convention as `scenePrompt.js`) — there is no separate client copy to drift.
*/
export const RUNNER_FAMILIES = Object.freeze({
diff --git a/server/lib/runners.test.js b/server/lib/runners.test.js
index fffcd9f092..c0877e7215 100644
--- a/server/lib/runners.test.js
+++ b/server/lib/runners.test.js
@@ -1,13 +1,6 @@
import { describe, it, expect } from 'vitest';
-import { readFileSync } from 'fs';
-import { dirname, join } from 'path';
-import { fileURLToPath } from 'url';
-
import { RUNNER_FAMILIES, VIDEO_LORA_FAMILIES, MINIMAX_H3_RUNTIMES, LTX2_FAMILY_RUNTIMES, AUDIO_TO_VIDEO_RUNTIMES, videoLoraFamily, isMiniMaxH3Runtime, isLtx2FamilyRuntime, isAudioToVideoRuntime, isMlxVideoLtxLoraCapable, loraFamilyOf, isMflux, isFlux2, isZImage, isErnie, isHiDream, isQwen, flux2VariantFromModel, loraCompatKey, composeCompatKey } from './runners.js';
-const __dirname_self = dirname(fileURLToPath(import.meta.url));
-const CLIENT_MIRROR_PATH = join(__dirname_self, '..', '..', 'client', 'src', 'lib', 'runnerFamilies.js');
-
describe('RUNNER_FAMILIES', () => {
it('exports the canonical runner ids', () => {
expect(RUNNER_FAMILIES.MFLUX).toBe('mflux');
@@ -22,20 +15,6 @@ describe('RUNNER_FAMILIES', () => {
expect(Object.isFrozen(RUNNER_FAMILIES)).toBe(true);
});
- it('client mirror at client/src/lib/runnerFamilies.js carries the same ids', () => {
- // The mirror is plain JS (not importable from a Vitest server suite —
- // Vite's fs.allow doesn't cross), so we string-grep the file. Any
- // change to a canonical id has to be reflected in both places, or this
- // test fails.
- const text = readFileSync(CLIENT_MIRROR_PATH, 'utf-8');
- expect(text).toMatch(/MFLUX:\s*'mflux'/);
- expect(text).toMatch(/FLUX2:\s*'flux2'/);
- expect(text).toMatch(/Z_IMAGE:\s*'z-image'/);
- expect(text).toMatch(/ERNIE:\s*'ernie'/);
- expect(text).toMatch(/HIDREAM:\s*'hidream'/);
- expect(text).toMatch(/QWEN:\s*'qwen'/);
- });
-
it('predicate helpers match on the canonical runner ids', () => {
expect(isMflux({ runner: 'mflux' })).toBe(true);
expect(isFlux2({ runner: 'flux2' })).toBe(true);
@@ -119,20 +98,6 @@ describe('VIDEO_LORA_FAMILIES / videoLoraFamily', () => {
expect(composeCompatKey('ltx-video', null)).toBe('ltx-video');
expect(composeCompatKey('ltx-video', '9b')).toBe('ltx-video');
});
-
- it('client mirror carries the video family + helpers', () => {
- const text = readFileSync(CLIENT_MIRROR_PATH, 'utf-8');
- expect(text).toMatch(/LTX_VIDEO:\s*'ltx-video'/);
- expect(text).toMatch(/MINIMAX_H3:\s*'minimax-h3'/);
- expect(text).toMatch(/runtimeLoraCapable === true/);
- expect(text).toMatch(/export const videoLoraFamily/);
- expect(text).toMatch(/export const isMlxVideoLtxLoraCapable/);
- expect(text).toMatch(/export const loraFamilyOf/);
- expect(text).toMatch(/export const isMiniMaxH3Runtime/);
- expect(text).toMatch(/MINIMAX_H3_REF2VA_RUNTIME = 'minimax_h3_ref2va'/);
- expect(text).toMatch(/export const isLtx2FamilyRuntime/);
- expect(text).toMatch(/'ltx2', 'ltx25'/);
- });
});
describe('flux2VariantFromModel', () => {
@@ -178,13 +143,6 @@ describe('loraCompatKey', () => {
it('defaults a runner-less model to mflux (matches the picker default)', () => {
expect(loraCompatKey({ id: 'dev' })).toBe('mflux');
});
-
- it('client mirror carries the same helpers', () => {
- const text = readFileSync(CLIENT_MIRROR_PATH, 'utf-8');
- expect(text).toMatch(/export const flux2VariantFromModel/);
- expect(text).toMatch(/export const loraCompatKey/);
- expect(text).toMatch(/export const composeCompatKey/);
- });
});
describe('composeCompatKey', () => {