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

fix: make the render-target parity test importable in the server CI job

[._.]/ Adam Eivy0c1d8ebd56e2
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index 079a47ee9a..2a784ad3e5 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -55,7 +55,8 @@ grep -i "what you want to do" client/src/lib/README.md
| `pipelineImageDefaults.js` | Pipeline comic-page image-gen defaults + settings reader. |
| `reverseOutlineGrid.js` | `buildPlotlineGrid` (reverse-outline scenes + plotlines → plotline-by-sequence grid rows/cells) + `sceneComponentCount`. Used by the Reverse Outline page. |
| `wrImageDefaults.js` | Writers Room per-scene image-gen defaults + style discriminators. |
-| `imageGenBackends.js` | `IMAGE_GEN_MODE` enum (local / codex / external) + metadata; `deriveAvailableBackends`; `I2I_CAPABLE_MODES` / `isI2iCapableMode(mode)` / `pickI2iMode(backends)` — image-to-image capability gating + best-backend selection. |
+| `imageGenBackends.js` | Icon metadata + `deriveAvailableBackends` for the image-gen backends; re-exports everything from `imageGenModes.js` so consumers keep one import site. |
+| `imageGenModes.js` | Node-safe (dependency-free) image/video backend constants + pure helpers: `IMAGE_GEN_MODE`, render-target mirror (`RENDER_TARGET_OPTIONS`, `normalizeRenderPinValue`), `VIDEO_RENDER_MODES`, `modeLabel`, cloud/model-override/i2i capability gating. Imported by the server-side parity suite — must stay importable without client packages. |
| `imageGenDefaults.js` | Shared `DEFAULT_NEGATIVE_PROMPT` used by the Image Gen form and quick-submit entry points. Mirrors server-side default. |
| `imageGenResolutions.js` | Shared resolution presets for image generation. |
| `importerDeepLink.js` | The Importer deep-link contract both ways: `buildImporterLink({ universeId, seriesId, seriesName })` builds the `/importer?…` URL a Series Pipeline page navigates to; `resolveImporterDeepLink(...)` reads those params back into the universe + series names the importer matches on. |
diff --git a/client/src/lib/imageGenBackends.js b/client/src/lib/imageGenBackends.js
index bc0929855c..3fef17ee83 100644
--- a/client/src/lib/imageGenBackends.js
+++ b/client/src/lib/imageGenBackends.js
@@ -1,143 +1,38 @@
-import { Cpu, Terminal, Cloud, Sparkles } from 'lucide-react';
-
-export const IMAGE_GEN_MODE = Object.freeze({
- LOCAL: 'local',
- CODEX: 'codex',
- GROK: 'grok',
- AGY: 'agy',
- EXTERNAL: 'external',
-});
-
-// Shipped default Codex reasoning-effort level — the client mirror of the
-// server's CODEX_IMAGEGEN_DEFAULT_EFFORT (server/services/imageGen/modes.js).
-// A Codex job with no explicit effort renders at this level, so any UI that
-// displays or pre-fills "the effort a job used" must resolve an absent value to
-// this default rather than showing a blank.
-export const CODEX_IMAGEGEN_DEFAULT_EFFORT = 'low';
-
-// Client mirror of the server's AGY_IMAGEGEN_DEFAULT_MODEL
-// (server/services/imageGen/modes.js, #3231) — the cheap-tier agent/session
-// model an unpinned agy render runs on. Any UI naming "the model an agy job
-// used" must resolve an absent value to this, not to "agy's own default"
-// (which stopped being true when the pin shipped).
-export const AGY_IMAGEGEN_DEFAULT_MODEL = 'gemini-3.5-flash-low';
+/**
+ * Image-gen backend metadata for the UI. The pure constants + helpers live in
+ * `imageGenModes.js` (a dependency-free leaf the server-side parity suite can
+ * import — see its header) and are re-exported here so client consumers keep
+ * one import site; this file adds only what needs client packages: the
+ * per-mode lucide icons and the settings-driven backend derivation.
+ */
-// Client mirror of AGY_IMAGEGEN_IMAGE_MODEL — the image model behind agy's
-// generate_image tool, fixed server-side by Antigravity and NOT selectable by
-// PortOS (all three channels probed and closed — see the server constant's
-// comment). Surfaced read-only in Settings so the agent-model field can't be
-// mistaken for an image-model picker.
-export const AGY_IMAGEGEN_IMAGE_MODEL = 'imagen-3.0-generate-002';
-
-// Client mirror of the server's render-target alphabet
-// (server/lib/renderTargets.js, #3231) — the surfaces whose default backend +
-// model are pinnable via settings.renderDefaults. Only targets whose resolver
-// is LIVE are listed here — showing a pin no resolver reads would be a control
-// that silently does nothing. Labels are the Settings-UI display names.
-// `video: true` marks the targets whose VIDEO lane also consults
-// `renderDefaults[target].videoMode` (#3231 Phase 4): music-video (scene clips
-// + new-project backend seeding) and creative-agent (commission video steps).
-// Video pins are backend-only — grok video has no model knob
-// (supportsModelOverride: false) and local video models are picked on the
-// surface itself, so no video-model control is offered anywhere.
-export const RENDER_TARGET_BACKEND_AUTO = 'auto';
-export const RENDER_TARGET_OPTIONS = Object.freeze([
- { id: 'universe-bible', label: 'Universe Bible batch renders' },
- { id: 'universe-character-sheet', label: 'Universe character sheets' },
- { id: 'series-first-pass', label: 'Series first-pass portraits & frames' },
- { id: 'sprite-reference', label: 'Sprite references & anchors' },
- { id: 'pipeline-visual', label: 'Pipeline visuals (storyboards, comics, covers)' },
- { id: 'music-video', label: 'Music Video scene frames & clips', video: true },
- { id: 'lora-dataset', label: 'LoRA training datasets' },
- { id: 'creative-agent', label: 'Creative agent renders', video: true },
-]);
-
-// Client mirror of the server's VIDEO_GEN_MODES (services/videoGen/modes.js) —
-// the backend alphabet for the video pin controls above and the install-wide
-// `settings.videoGen.mode` pin.
-export const VIDEO_RENDER_MODES = Object.freeze(['local', 'grok']);
-
-// Client mirror of the server's normalizeRenderPinValue
-// (server/lib/renderTargets.js) — THE one render-pin normalization rule: trim;
-// the 'auto' sentinel and blank strings collapse to null ("no pin").
-export const normalizeRenderPinValue = (v) => {
- const s = typeof v === 'string' ? v.trim() : '';
- return s && s !== RENDER_TARGET_BACKEND_AUTO ? s : null;
-};
+import { Cpu, Terminal, Cloud, Sparkles } from 'lucide-react';
+import { IMAGE_GEN_MODE, MODE_LABELS } from './imageGenModes.js';
-// Client mirror of the server's GROK_ASPECT_RATIOS (imageGen/grok.js) — the
-// aspect ratios grok's image_gen/image_edit tools accept, offered as the
-// default-ratio picker in Settings → Image Gen → Grok.
-export const GROK_ASPECT_RATIOS = Object.freeze(['1:1', '16:9', '9:16', '4:3', '3:4', '3:2', '2:3']);
+export * from './imageGenModes.js';
-const META = {
- [IMAGE_GEN_MODE.LOCAL]: { label: 'Local', icon: Cpu },
- [IMAGE_GEN_MODE.CODEX]: { label: 'Codex', icon: Terminal },
- [IMAGE_GEN_MODE.GROK]: { label: 'Grok', icon: Sparkles },
- [IMAGE_GEN_MODE.AGY]: { label: 'Agy', icon: Sparkles },
- [IMAGE_GEN_MODE.EXTERNAL]: { label: 'External', icon: Cloud },
+const MODE_ICONS = {
+ [IMAGE_GEN_MODE.LOCAL]: Cpu,
+ [IMAGE_GEN_MODE.CODEX]: Terminal,
+ [IMAGE_GEN_MODE.GROK]: Sparkles,
+ [IMAGE_GEN_MODE.AGY]: Sparkles,
+ [IMAGE_GEN_MODE.EXTERNAL]: Cloud,
};
-// Client mirror of the server's CLOUD_IMAGE_GEN_MODES (imageGen/modes.js) —
-// cloud-CLI backends that pick model/steps/seed internally,
-// run through the media queue's parallel cloud lane, and need a prompt for
-// text-to-image. Use `isCloudCliMode` instead of hand-rolled
-// `mode === CODEX || mode === GROK` disjunctions.
-export const CLOUD_IMAGE_GEN_MODES = Object.freeze([
- IMAGE_GEN_MODE.CODEX,
- IMAGE_GEN_MODE.GROK,
- IMAGE_GEN_MODE.AGY,
-]);
-export const isCloudCliMode = (mode) => CLOUD_IMAGE_GEN_MODES.includes(mode);
-
-// Client mirror of the server's `supportsModelOverride` spec flag
-// (imageGen/cloudProviderConfig.js) — cloud CLIs that accept a per-render
-// `cloudModel` replacing the saved `settings.imageGen.<mode>.model` for one
-// queue item. Grok is absent because its image tools run on a fixed xAI backend
-// with no model knob, so offering the control there would be a lie.
-// Use `supportsCloudModelOverride` instead of hand-rolled
-// `mode === CODEX || mode === AGY` disjunctions — the two must stay in lock-step
-// with the server spec, and a new CLI backend should be one entry here.
-export const MODEL_OVERRIDE_CAPABLE_MODES = Object.freeze([
- IMAGE_GEN_MODE.CODEX,
- IMAGE_GEN_MODE.AGY,
-]);
-export const supportsCloudModelOverride = (mode) => MODEL_OVERRIDE_CAPABLE_MODES.includes(mode);
-
-// Human-facing name for a backend ('Local', 'Codex', 'Grok', 'Agy', 'External').
-// Shared so label ladders (`isCodex ? 'Codex model' : …`) don't re-type what META
-// already holds and grow a branch per backend.
-export const modeLabel = (mode) => META[mode]?.label || mode || '';
-
-// Backends that support image-to-image (init image / reference editing). The
-// external SD-API path does not. Single source of truth for i2i gating in the UI.
-export const I2I_CAPABLE_MODES = Object.freeze([IMAGE_GEN_MODE.LOCAL, IMAGE_GEN_MODE.CODEX, IMAGE_GEN_MODE.GROK]);
-
-// True when a mode can run image-to-image.
-export const isI2iCapableMode = (mode) => I2I_CAPABLE_MODES.includes(mode);
-
-// Pick the best available i2i backend from a list of `{ id }` backends,
-// preferring local (its form exposes strength + LoRAs), else codex, else grok.
-// Returns null when none is installed.
-export function pickI2iMode(backends) {
- for (const mode of I2I_CAPABLE_MODES) {
- if (backends.some((b) => b.id === mode)) return mode;
- }
- return null;
-}
+const metaFor = (mode) => ({ label: MODE_LABELS[mode], icon: MODE_ICONS[mode] });
export function deriveAvailableBackends(settings, { excludeExternal = false } = {}) {
const ig = settings?.imageGen || {};
const out = [];
if ((ig.local?.pythonPath || '').trim())
- out.push({ id: IMAGE_GEN_MODE.LOCAL, ...META[IMAGE_GEN_MODE.LOCAL] });
+ out.push({ id: IMAGE_GEN_MODE.LOCAL, ...metaFor(IMAGE_GEN_MODE.LOCAL) });
if (ig.codex?.enabled === true)
- out.push({ id: IMAGE_GEN_MODE.CODEX, ...META[IMAGE_GEN_MODE.CODEX] });
+ out.push({ id: IMAGE_GEN_MODE.CODEX, ...metaFor(IMAGE_GEN_MODE.CODEX) });
if (ig.grok?.enabled === true)
- out.push({ id: IMAGE_GEN_MODE.GROK, ...META[IMAGE_GEN_MODE.GROK] });
+ out.push({ id: IMAGE_GEN_MODE.GROK, ...metaFor(IMAGE_GEN_MODE.GROK) });
if (ig.agy?.enabled === true)
- out.push({ id: IMAGE_GEN_MODE.AGY, ...META[IMAGE_GEN_MODE.AGY] });
+ out.push({ id: IMAGE_GEN_MODE.AGY, ...metaFor(IMAGE_GEN_MODE.AGY) });
if (!excludeExternal && (ig.external?.sdapiUrl || ig.sdapiUrl || '').trim())
- out.push({ id: IMAGE_GEN_MODE.EXTERNAL, ...META[IMAGE_GEN_MODE.EXTERNAL] });
+ out.push({ id: IMAGE_GEN_MODE.EXTERNAL, ...metaFor(IMAGE_GEN_MODE.EXTERNAL) });
return out;
}
diff --git a/client/src/lib/imageGenModes.js b/client/src/lib/imageGenModes.js
new file mode 100644
index 0000000000..dbed54cb0f
--- /dev/null
+++ b/client/src/lib/imageGenModes.js
@@ -0,0 +1,138 @@
+/**
+ * Image/video render-backend constants + pure helpers — the NODE-SAFE half of
+ * `imageGenBackends.js`, split out (#3231 Phase 4) because the server-side
+ * parity suite (`server/lib/renderTargets.parity.test.js`) and the server CI
+ * job import this module directly, where client-only packages (lucide-react)
+ * are not installed. Nothing here may import React, icons, or any package —
+ * keep this file dependency-free. Icon metadata and settings-driven backend
+ * derivation stay in `imageGenBackends.js`, which re-exports everything below
+ * so client consumers keep a single import site.
+ */
+
+export const IMAGE_GEN_MODE = Object.freeze({
+ LOCAL: 'local',
+ CODEX: 'codex',
+ GROK: 'grok',
+ AGY: 'agy',
+ EXTERNAL: 'external',
+});
+
+// Shipped default Codex reasoning-effort level — the client mirror of the
+// server's CODEX_IMAGEGEN_DEFAULT_EFFORT (server/services/imageGen/modes.js).
+// A Codex job with no explicit effort renders at this level, so any UI that
+// displays or pre-fills "the effort a job used" must resolve an absent value to
+// this default rather than showing a blank.
+export const CODEX_IMAGEGEN_DEFAULT_EFFORT = 'low';
+
+// Client mirror of the server's AGY_IMAGEGEN_DEFAULT_MODEL
+// (server/services/imageGen/modes.js, #3231) — the cheap-tier agent/session
+// model an unpinned agy render runs on. Any UI naming "the model an agy job
+// used" must resolve an absent value to this, not to "agy's own default"
+// (which stopped being true when the pin shipped).
+export const AGY_IMAGEGEN_DEFAULT_MODEL = 'gemini-3.5-flash-low';
+
+// Client mirror of AGY_IMAGEGEN_IMAGE_MODEL — the image model behind agy's
+// generate_image tool, fixed server-side by Antigravity and NOT selectable by
+// PortOS (all three channels probed and closed — see the server constant's
+// comment). Surfaced read-only in Settings so the agent-model field can't be
+// mistaken for an image-model picker.
+export const AGY_IMAGEGEN_IMAGE_MODEL = 'imagen-3.0-generate-002';
+
+// Client mirror of the server's render-target alphabet
+// (server/lib/renderTargets.js, #3231) — the surfaces whose default backend +
+// model are pinnable via settings.renderDefaults. Only targets whose resolver
+// is LIVE are listed here — showing a pin no resolver reads would be a control
+// that silently does nothing. Labels are the Settings-UI display names.
+// `video: true` marks the targets whose VIDEO lane also consults
+// `renderDefaults[target].videoMode` (#3231 Phase 4): music-video (scene clips
+// + new-project backend seeding) and creative-agent (commission video steps).
+// Video pins are backend-only — grok video has no model knob
+// (supportsModelOverride: false) and local video models are picked on the
+// surface itself, so no video-model control is offered anywhere.
+export const RENDER_TARGET_BACKEND_AUTO = 'auto';
+export const RENDER_TARGET_OPTIONS = Object.freeze([
+ { id: 'universe-bible', label: 'Universe Bible batch renders' },
+ { id: 'universe-character-sheet', label: 'Universe character sheets' },
+ { id: 'series-first-pass', label: 'Series first-pass portraits & frames' },
+ { id: 'sprite-reference', label: 'Sprite references & anchors' },
+ { id: 'pipeline-visual', label: 'Pipeline visuals (storyboards, comics, covers)' },
+ { id: 'music-video', label: 'Music Video scene frames & clips', video: true },
+ { id: 'lora-dataset', label: 'LoRA training datasets' },
+ { id: 'creative-agent', label: 'Creative agent renders', video: true },
+]);
+
+// Client mirror of the server's VIDEO_GEN_MODES (services/videoGen/modes.js) —
+// the backend alphabet for the video pin controls above and the install-wide
+// `settings.videoGen.mode` pin.
+export const VIDEO_RENDER_MODES = Object.freeze(['local', 'grok']);
+
+// Client mirror of the server's normalizeRenderPinValue
+// (server/lib/renderTargets.js) — THE one render-pin normalization rule: trim;
+// the 'auto' sentinel and blank strings collapse to null ("no pin").
+export const normalizeRenderPinValue = (v) => {
+ const s = typeof v === 'string' ? v.trim() : '';
+ return s && s !== RENDER_TARGET_BACKEND_AUTO ? s : null;
+};
+
+// Client mirror of the server's GROK_ASPECT_RATIOS (imageGen/grok.js) — the
+// aspect ratios grok's image_gen/image_edit tools accept, offered as the
+// default-ratio picker in Settings → Image Gen → Grok.
+export const GROK_ASPECT_RATIOS = Object.freeze(['1:1', '16:9', '9:16', '4:3', '3:4', '3:2', '2:3']);
+
+// Human-facing backend names — the pure half of imageGenBackends' per-mode
+// metadata (its icon half stays there with the lucide import).
+export const MODE_LABELS = Object.freeze({
+ [IMAGE_GEN_MODE.LOCAL]: 'Local',
+ [IMAGE_GEN_MODE.CODEX]: 'Codex',
+ [IMAGE_GEN_MODE.GROK]: 'Grok',
+ [IMAGE_GEN_MODE.AGY]: 'Agy',
+ [IMAGE_GEN_MODE.EXTERNAL]: 'External',
+});
+
+// Client mirror of the server's CLOUD_IMAGE_GEN_MODES (imageGen/modes.js) —
+// cloud-CLI backends that pick model/steps/seed internally,
+// run through the media queue's parallel cloud lane, and need a prompt for
+// text-to-image. Use `isCloudCliMode` instead of hand-rolled
+// `mode === CODEX || mode === GROK` disjunctions.
+export const CLOUD_IMAGE_GEN_MODES = Object.freeze([
+ IMAGE_GEN_MODE.CODEX,
+ IMAGE_GEN_MODE.GROK,
+ IMAGE_GEN_MODE.AGY,
+]);
+export const isCloudCliMode = (mode) => CLOUD_IMAGE_GEN_MODES.includes(mode);
+
+// Client mirror of the server's `supportsModelOverride` spec flag
+// (imageGen/cloudProviderConfig.js) — cloud CLIs that accept a per-render
+// `cloudModel` replacing the saved `settings.imageGen.<mode>.model` for one
+// queue item. Grok is absent because its image tools run on a fixed xAI backend
+// with no model knob, so offering the control there would be a lie.
+// Use `supportsCloudModelOverride` instead of hand-rolled
+// `mode === CODEX || mode === AGY` disjunctions — the two must stay in lock-step
+// with the server spec, and a new CLI backend should be one entry here.
+export const MODEL_OVERRIDE_CAPABLE_MODES = Object.freeze([
+ IMAGE_GEN_MODE.CODEX,
+ IMAGE_GEN_MODE.AGY,
+]);
+export const supportsCloudModelOverride = (mode) => MODEL_OVERRIDE_CAPABLE_MODES.includes(mode);
+
+// Human-facing name for a backend ('Local', 'Codex', 'Grok', 'Agy', 'External').
+// Shared so label ladders (`isCodex ? 'Codex model' : …`) don't re-type what
+// MODE_LABELS already holds and grow a branch per backend.
+export const modeLabel = (mode) => MODE_LABELS[mode] || mode || '';
+
+// Backends that support image-to-image (init image / reference editing). The
+// external SD-API path does not. Single source of truth for i2i gating in the UI.
+export const I2I_CAPABLE_MODES = Object.freeze([IMAGE_GEN_MODE.LOCAL, IMAGE_GEN_MODE.CODEX, IMAGE_GEN_MODE.GROK]);
+
+// True when a mode can run image-to-image.
+export const isI2iCapableMode = (mode) => I2I_CAPABLE_MODES.includes(mode);
+
+// Pick the best available i2i backend from a list of `{ id }` backends,
+// preferring local (its form exposes strength + LoRAs), else codex, else grok.
+// Returns null when none is installed.
+export function pickI2iMode(backends) {
+ for (const mode of I2I_CAPABLE_MODES) {
+ if (backends.some((b) => b.id === mode)) return mode;
+ }
+ return null;
+}
diff --git a/client/src/lib/index.js b/client/src/lib/index.js
index e81b26e71e..e6b0f386f9 100644
--- a/client/src/lib/index.js
+++ b/client/src/lib/index.js
@@ -28,6 +28,9 @@ export * from './editorialRoadmap.js';
export * from './grokVideoClip.js';
export * from './imageCleaners.js';
export * from './imageGenBackends.js';
+// Namespace export: imageGenBackends re-exports every imageGenModes symbol
+// flat (one import site for consumers), so a flat export here would collide.
+export * as imageGenModes from './imageGenModes.js';
export * from './imageGenDefaults.js';
export * from './imageGenResolutions.js';
export * from './importerDeepLink.js';
diff --git a/server/lib/renderTargets.parity.test.js b/server/lib/renderTargets.parity.test.js
index a838b41cf6..85825befe5 100644
--- a/server/lib/renderTargets.parity.test.js
+++ b/server/lib/renderTargets.parity.test.js
@@ -16,10 +16,13 @@
import { describe, it, expect } from 'vitest';
import { RENDER_TARGETS, RENDER_TARGET_BACKEND_AUTO } from './renderTargets.js';
+// Import the node-safe leaf, NOT imageGenBackends.js — that module imports
+// lucide-react, which is not installed in the server CI job (this exact import
+// broke main's CI when Phase 2 landed pointing at imageGenBackends).
import {
RENDER_TARGET_OPTIONS as CLIENT_OPTIONS,
RENDER_TARGET_BACKEND_AUTO as CLIENT_AUTO,
-} from '../../client/src/lib/imageGenBackends.js';
+} from '../../client/src/lib/imageGenModes.js';
// Targets the Settings UI deliberately does NOT list — a pin nobody's
// resolver reads would be a control that silently does nothing. Empty since