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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
derive the client image-gen alphabets from the server leaves instead of hand-copying them
[._.]/ Adam Eivy71d52f3e4d02
diff --git a/client/src/lib/README.md b/client/src/lib/README.mdindex f94bb1fb7b..3e4257d243 100644--- a/client/src/lib/README.md+++ b/client/src/lib/README.md@@ -84,7 +84,7 @@ grep -i "what you want to do" client/src/lib/README.md| `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` | Icon metadata, `deriveAvailableBackends`, and `imageGenReadiness(status)` — a compatibility-safe `ready` / `unavailable` / `unknown` read of image-gen status responses; 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`, `applyRecordRenderPin` — fold a record's `imageMode`/`imageModelId` pin over a settings-derived cfg), `VIDEO_RENDER_MODES`/`isCloudVideoMode`, `modeLabel`, `mediaJobLane` (a projected media job's scheduler lane, with a `fallbackExecutionLane` derivation for responses predating the server's `executionLane` field), cloud/model-override/i2i capability gating. Imported by the server-side parity suite — must stay importable without client packages. |+| `imageGenModes.js` | Node-safe image/video backend constants + pure helpers. The backend / render-target / execution-lane alphabets (`IMAGE_GEN_MODE`, `CLOUD_IMAGE_GEN_MODES`, `RENDER_TARGET`, `VIDEO_RENDER_MODES`, `MEDIA_JOB_LANES`, `normalizeRenderPinValue`) are re-exported from the dependency-free server leaves `server/lib/generationModes.js` + `server/lib/renderTargets.js`, never copied. Adds the Settings rows (`RENDER_TARGET_OPTIONS`), `applyRecordRenderPin` (fold a record's `imageMode`/`imageModelId` pin over a settings-derived cfg), `isCloudVideoMode`, `modeLabel`, `mediaJobLane` (a projected media job's scheduler lane, with a `fallbackExecutionLane` read for responses predating the server's `executionLane` field), and the cloud/model-override/i2i capability mirrors of the server service specs. 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. || `imageTo3dReasons.js` | Client mirror of the image-to-3D unavailable-reason labels in `server/services/imageTo3d/targets.js`: `UNAVAILABLE_REASONS` (reason code → user-facing label), `UNAVAILABLE_REASON_FALLBACK`, and `unavailableReasonLabel(code, fallback?)`, plus `isTargetReady(target)` — the shared readiness predicate (`installed` is tri-state: `null` = a hosted lane with no install concept, ready as soon as it is available). Use these anywhere a target's `unavailableReason` or readiness is rendered — never re-declare the codes or re-derive readiness from `target.installed` truthiness. Parity + code coverage enforced by `server/services/imageTo3d/unavailableReasons.parity.test.js`. |diff --git a/client/src/lib/imageGenModes.js b/client/src/lib/imageGenModes.jsindex 8276115dc1..65599c42ae 100644--- a/client/src/lib/imageGenModes.js+++ b/client/src/lib/imageGenModes.js@@ -4,18 +4,43 @@* 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.+ * the only imports allowed are the two dependency-free server leaves below,+ * the same way `Layout.jsx` reads `server/lib/navManifest.js`. Icon metadata+ * and settings-driven backend derivation stay in `imageGenBackends.js`, which+ * re-exports everything below so client consumers keep a single import site.+ *+ * The backend / render-target / execution-lane ALPHABETS are not copied here:+ * they are re-exported from `server/lib/generationModes.js` and+ * `server/lib/renderTargets.js`, so a backend added server-side reaches every+ * client picker and the Render Queue's lane grouping in the same commit. A+ * hand-copied alphabet is how fal.ai and Reactor video renders came to be+ * filed under "Local machine" (#6292). What remains a mirror is only what+ * lives in server SERVICE modules the browser bundle cannot load (per-provider+ * capability specs, shipped default models) — each is labeled below and bound+ * to its server value by the parity suite.*/-export const IMAGE_GEN_MODE = Object.freeze({- LOCAL: 'local',- CODEX: 'codex',- GROK: 'grok',- AGY: 'agy',- EXTERNAL: 'external',-});+import {+ CLOUD_IMAGE_GEN_MODES,+ CLOUD_VIDEO_GEN_MODES,+ IMAGE_GEN_MODE,+ MEDIA_JOB_EXECUTION_LANES,+ VIDEO_GEN_MODES,+ mediaJobExecutionLane,+} from '../../../server/lib/generationModes.js';+import {+ RENDER_TARGET,+ RENDER_TARGET_BACKEND_AUTO,+ normalizeRenderPinValue,+} from '../../../server/lib/renderTargets.js';++export {+ CLOUD_IMAGE_GEN_MODES,+ IMAGE_GEN_MODE,+ RENDER_TARGET,+ RENDER_TARGET_BACKEND_AUTO,+ normalizeRenderPinValue,+};// Shipped default Codex reasoning-effort level — the client mirror of the// server's CODEX_IMAGEGEN_DEFAULT_EFFORT (server/services/imageGen/modes.js).@@ -38,60 +63,41 @@ export const AGY_IMAGEGEN_DEFAULT_MODEL = 'gemini-3.5-flash-low';// 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 ++// The Settings → Image Gen → Defaults rows for the server's render-target+// alphabet (`RENDER_TARGET`, #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';-// Named ids for the targets the CLIENT resolves itself (via `renderTargetPin`),-// so a call site names the surface instead of retyping the string. The ids are-// bound to the server's RENDER_TARGETS by renderTargets.parity.test.js.-export const RENDER_TARGET = Object.freeze({- UNIVERSE_BIBLE: 'universe-bible',- PIPELINE_VISUAL: 'pipeline-visual',-});+// that silently does nothing; the parity suite fails on a server target that+// is neither listed nor explicitly allowlisted as unlisted. 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_OPTIONS = Object.freeze([- { id: 'universe-bible', label: 'Universe Bible & canon 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 },+ { id: RENDER_TARGET.UNIVERSE_BIBLE, label: 'Universe Bible & canon renders' },+ { id: RENDER_TARGET.UNIVERSE_CHARACTER_SHEET, label: 'Universe character sheets' },+ { id: RENDER_TARGET.SERIES_FIRST_PASS, label: 'Series first-pass portraits & frames' },+ { id: RENDER_TARGET.SPRITE_REFERENCE, label: 'Sprite references & anchors' },+ { id: RENDER_TARGET.PIPELINE_VISUAL, label: 'Pipeline visuals (storyboards, comics, covers)' },+ { id: RENDER_TARGET.MUSIC_VIDEO, label: 'Music Video scene frames & clips', video: true },+ { id: RENDER_TARGET.LORA_DATASET, label: 'LoRA training datasets' },+ { id: RENDER_TARGET.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', 'fal', 'reactor']);+// The server's VIDEO_GEN_MODES — the backend alphabet for the video pin+// controls above and the install-wide `settings.videoGen.mode` pin.+export const VIDEO_RENDER_MODES = VIDEO_GEN_MODES;-// Client mirror of the server's CLOUD_VIDEO_GEN_MODES (lib/generationModes.js)-// — the video backends that render in a provider's cloud rather than on the-// local accelerator. 'local' is the only non-cloud entry of VIDEO_RENDER_MODES.-export const CLOUD_VIDEO_RENDER_MODES = Object.freeze(- VIDEO_RENDER_MODES.filter((mode) => mode !== IMAGE_GEN_MODE.LOCAL),-);+// The server's CLOUD_VIDEO_GEN_MODES — the video backends that render in a+// provider's cloud rather than on the local accelerator.+export const CLOUD_VIDEO_RENDER_MODES = CLOUD_VIDEO_GEN_MODES;export const isCloudVideoMode = (mode) => CLOUD_VIDEO_RENDER_MODES.includes(mode);-// Client mirror of the server's MEDIA_JOB_EXECUTION_LANES-// (server/lib/generationModes.js) — the lanes the media-job scheduler runs in.-export const MEDIA_JOB_LANES = Object.freeze(['gpu', 'cloud', 'remote']);--// 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;-};+// The server's MEDIA_JOB_EXECUTION_LANES — the lanes the media-job scheduler+// runs in.+export const MEDIA_JOB_LANES = MEDIA_JOB_EXECUTION_LANES;// 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@@ -110,16 +116,11 @@ export const MODE_LABELS = Object.freeze({reactor: 'Reactor.inc',});-// 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,-]);+// The server's CLOUD_IMAGE_GEN_MODES (re-exported above) — 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 isCloudCliMode = (mode) => CLOUD_IMAGE_GEN_MODES.includes(mode);// Client mirror of the server's `supportsModelOverride` spec flag@@ -227,22 +228,17 @@ export const I2I_CAPABLE_MODES = Object.freeze([export const isI2iCapableMode = (mode) => I2I_CAPABLE_MODES.includes(mode);// Backward-compatibility read of a media job's execution lane for a queue-// response carrying no `executionLane` (server/lib/generationModes.js#-// mediaJobExecutionLane). The bundle is served by the same install whose API it-// calls, so this is not routine version skew — it covers the window where a-// rebuilt client is already being served by a server process that has not-// restarted yet, and a replayed/hand-edited response. A federated job-// is already identifiable from `renderer`; otherwise the cloud alphabets-// decide, and every remaining mode — including local video's semantic-// text/image/fflf values, which are not backend names at all — is a local GPU-// render. Never call this when `executionLane` is present: the server's own+// response carrying no `executionLane`. The bundle is served by the same+// install whose API it calls, so this is not routine version skew — it covers+// the window where a rebuilt client is already being served by a server+// process that has not restarted yet, and a replayed/hand-edited response. The+// classification itself is the scheduler's own `mediaJobExecutionLane`; the+// only client-side work is reading "federated" off the projected `renderer`+// field. Never call this when `executionLane` is present: the server's own// classification is authoritative.-export const fallbackExecutionLane = ({ kind, mode, renderer } = {}) => {- if (renderer === 'remote') return 'remote';- if (kind === 'image' && isCloudCliMode(mode)) return 'cloud';- if (kind === 'video' && isCloudVideoMode(mode)) return 'cloud';- return 'gpu';-};+export const fallbackExecutionLane = ({ kind, mode, renderer } = {}) => (+ mediaJobExecutionLane({ kind, mode, remote: renderer === 'remote' })+);// THE one lane read for a projected media job: the server's classification when// it is there, the compatibility derivation when it isn't.diff --git a/server/lib/generationModes.js b/server/lib/generationModes.jsindex 189a0d4898..08e9ff92ff 100644--- a/server/lib/generationModes.js+++ b/server/lib/generationModes.js@@ -59,7 +59,7 @@ export const CLOUD_VIDEO_GEN_MODES = Object.freeze([* semantic modes included) serializes on the local accelerator.** Kept here rather than in mediaJobQueue so a light consumer — sanitizeJob, a- * route handler, a client mirror's counterpart test — can classify a job+ * route handler, the client's re-export — can classify a job* without importing the queue.*/export const MEDIA_JOB_EXECUTION_LANES = Object.freeze(['gpu', 'cloud', 'remote']);diff --git a/server/lib/renderTargets.parity.test.js b/server/lib/renderTargets.parity.test.jsindex 22f6fa5946..b05264becf 100644--- a/server/lib/renderTargets.parity.test.js+++ b/server/lib/renderTargets.parity.test.js@@ -1,40 +1,40 @@/**- * Cross-package parity for the render-target alphabet (#3231).+ * Cross-package parity for the image-gen capability mirrors (#3231).*- * `server/lib/renderTargets.js` is the source of truth; the client's- * `RENDER_TARGET_OPTIONS` (client/src/lib/imageGenBackends.js) is a- * hand-maintained mirror feeding the Settings → Image Gen → Defaults tab. A- * typo'd or renamed id in the client list would make the strict- * `renderDefaultsSettingsSchema` 400 the ENTIRE settings PUT — and both- * suites would stay green, because the client test mocks updateSettings- * (the exact mocked-client-suite blind spot this repo has shipped before).- * This suite imports both and fails on drift instead.+ * The backend, render-target, and execution-lane ALPHABETS are no longer+ * mirrored: `client/src/lib/imageGenModes.js` re-exports them from the+ * dependency-free server leaves (`lib/generationModes.js`,+ * `lib/renderTargets.js`), so they cannot drift and nothing here asserts them.+ *+ * What this suite still binds is the client's copy of facts that live in+ * server SERVICE modules the browser bundle cannot load (they import+ * `errorHandler.js`, and through it Node's `events`): the per-provider+ * input-image capability specs on `CLOUD_PROVIDER_SPECS`, the i2i-capable+ * complement of `EDIT_INCAPABLE_IMAGE_MODES`, and the one presentation+ * decision the Settings tab owns — which render targets get a Defaults row.+ * Drift there is invisible to either suite alone: the client tests assert the+ * client's own literals, and the server never loads the client mirror. A+ * typo'd id in the Settings rows would make the strict+ * `renderDefaultsSettingsSchema` 400 the ENTIRE settings PUT while the+ * client test (which mocks updateSettings) stayed green.** Lives server-side because the server runner loads the pure client lib fine,- * while the client (jsdom) runner can't load server modules.+ * while the client (happy-dom) runner can't load service modules.*/import { describe, it, expect } from 'vitest';-import { RENDER_TARGET, RENDER_TARGETS, RENDER_TARGET_BACKEND_AUTO } from './renderTargets.js';-import {- CLOUD_IMAGE_GEN_MODES, IMAGE_GEN_MODES, VIDEO_GEN_MODES,- CLOUD_VIDEO_GEN_MODES, MEDIA_JOB_EXECUTION_LANES, mediaJobExecutionLane,-} from './generationModes.js';+import { RENDER_TARGET, RENDER_TARGETS } from './renderTargets.js';+import { CLOUD_IMAGE_GEN_MODES, IMAGE_GEN_MODES } from './generationModes.js';import { EDIT_INCAPABLE_IMAGE_MODES } from '../services/imageGen/modes.js';import { cloudPromptRequired, maxInputImages } from '../services/imageGen/cloudProviderConfig.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 as CLIENT_RENDER_TARGET,RENDER_TARGET_OPTIONS as CLIENT_OPTIONS,- RENDER_TARGET_BACKEND_AUTO as CLIENT_AUTO,I2I_CAPABLE_MODES as CLIENT_I2I_CAPABLE,MAX_INPUT_IMAGES as CLIENT_MAX_INPUT_IMAGES,cloudPromptRequired as clientCloudPromptRequired,- CLOUD_VIDEO_RENDER_MODES as CLIENT_CLOUD_VIDEO_MODES,- MEDIA_JOB_LANES as CLIENT_MEDIA_JOB_LANES,- fallbackExecutionLane as clientFallbackExecutionLane,} from '../../client/src/lib/imageGenModes.js';// Targets the Settings UI deliberately does NOT list — a pin nobody's@@ -44,8 +44,11 @@ import {// resolver guard.const DELIBERATELY_UNLISTED = new Set([RENDER_TARGET.FABLELOOM_PRODUCTION]);-describe('render-target client mirror parity (#3231)', () => {- it('every client option id is a real server render target', () => {+describe('render-target Settings rows (#3231)', () => {+ // The rows key their ids off the server's RENDER_TARGET map, so a mistyped+ // member name surfaces here as an `undefined` id rather than as a 400 on+ // the whole settings PUT.+ it('every Settings row names a real server render target', () => {const server = new Set(RENDER_TARGETS);for (const { id } of CLIENT_OPTIONS) {expect(server.has(id), `client RENDER_TARGET_OPTIONS id "${id}" is not in server RENDER_TARGETS`).toBe(true);@@ -59,20 +62,6 @@ describe('render-target client mirror parity (#3231)', () => {`server render target "${id}" is neither in client RENDER_TARGET_OPTIONS nor allowlisted as deliberately unlisted`).toBe(true);}});-- // The client's named-id map is the subset of targets the CLIENT resolves- // itself via `renderTargetPin`. A drifting id there is worse than a drifting- // option label: the pin silently reads an absent `settings.renderDefaults`- // key and every render falls through to the install default with no error.- it('every client RENDER_TARGET id matches the server constant of the same name', () => {- for (const [name, id] of Object.entries(CLIENT_RENDER_TARGET)) {- expect(RENDER_TARGET[name], `client RENDER_TARGET.${name} has no server counterpart`).toBe(id);- }- });-- it('the auto sentinel matches across packages', () => {- expect(CLIENT_AUTO).toBe(RENDER_TARGET_BACKEND_AUTO);- });});/**@@ -127,34 +116,3 @@ describe('cloud input-image capability client mirror parity', () => {}});});--/**- * The Render Queue groups rows by the lane the scheduler actually chose, and- * derives it client-side when a response carries no `executionLane`. That- * derivation is a second copy of the rule, and a second copy nothing binds to- * the first is exactly how fal.ai and Reactor video renders came to be filed- * under "Local machine" (#6292). Bind it here: adding a cloud backend- * server-side now fails this suite until the client mirror follows.- */-describe('media-job execution-lane client mirror parity', () => {- it('mirrors the cloud video alphabet and the lane vocabulary', () => {- expect([...CLIENT_CLOUD_VIDEO_MODES].sort()).toEqual([...CLOUD_VIDEO_GEN_MODES].sort());- expect([...CLIENT_MEDIA_JOB_LANES].sort()).toEqual([...MEDIA_JOB_EXECUTION_LANES].sort());- });-- it('derives the same lane as the scheduler for every kind/mode/remote combination', () => {- // 'text' stands in for the semantic (non-backend) modes a local video- // render carries; an unknown value stands in for a backend this build has- // never heard of. Both must resolve to the GPU lane.- const modes = [...new Set([...IMAGE_GEN_MODES, ...VIDEO_GEN_MODES, 'text', 'unknown-future-backend', undefined])];- for (const kind of ['image', 'video', 'training', 'audio']) {- for (const mode of modes) {- for (const remote of [false, true]) {- expect(clientFallbackExecutionLane({ kind, mode, renderer: remote ? 'remote' : 'local' }),- `client fallbackExecutionLane(${kind}, ${mode}, remote=${remote}) disagrees with the scheduler`)- .toBe(mediaJobExecutionLane({ kind, mode, remote }));- }- }- }- });-});