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
apply /simplify review: reuse shared verify/repair, render the disclosure, drop dead lanes
[._.]/ Adam Eivyb9e78276b1fa
diff --git a/client/src/components/videoGen/TextEncoderPicker.jsx b/client/src/components/videoGen/TextEncoderPicker.jsxindex b1001af699..a7dcae49fc 100644--- a/client/src/components/videoGen/TextEncoderPicker.jsx+++ b/client/src/components/videoGen/TextEncoderPicker.jsx@@ -8,19 +8,27 @@* control for that choice.** Presentational: options, selection, and download status are all owned by the- * VideoGen page. Rendered only when the model actually offers more than one- * option (the server decorates the list per model), so no runtime check lives- * here.+ * VideoGen page. It renders only when the model offers a real choice; the server+ * ships the true option list (including a lone stock entry), so the+ * hide-when-there-is-nothing-to-pick rule lives here rather than in the+ * server-side accessor every validation predicate is built on.** A substitute is a separate multi-GB pull, so its Download badge sits inline* with the select rather than behind the collapsed Advanced panel — the user has* to see the cost at the moment they pick it, and the page gates Generate on the* same status.*/+import { FormField } from '../ui/FormField';+import ModelSelect from '../ModelSelect';import ModelDownloadBadge from '../media/ModelDownloadBadge';+import FactLink from './FactLink';import { formatBytes } from '../../utils/formatters.js';-const inputCls = 'w-full bg-port-bg border border-port-border rounded-lg px-2 py-2 text-sm text-white focus:outline-none focus:border-port-accent disabled:opacity-50';+// The option text carries its own download size, so the shared ModelSelect gets+// a getLabel rather than the default `m.name` (these entries have `label`).+const optionLabel = (option) => (+ option.sizeBytes ? `${option.label} (~${formatBytes(option.sizeBytes)} download)` : option.label+);export default function TextEncoderPicker({options = [],@@ -33,33 +41,26 @@ export default function TextEncoderPicker({}) {if (options.length < 2) return null;const selected = options.find((option) => option.id === value) || options[0];- // Formatted from the option's exact published byte count rather than a second- // "~N GB" literal on the registry entry, so the option text, the Download- // button and the post-download "Available · N" badge can never disagree.- const sizeLabel = selected.sizeBytes ? formatBytes(selected.sizeBytes) : null;// Built-in conditioners ship inside the model's own weights, so they have no// separate download of their own to badge.const needsDownload = !selected.builtIn && (status === null || status.cached === false || status.downloading);+ const card = selected.disclosure?.modelCardUrl;+ const license = selected.disclosure?.weightsLicense;return (- <div className="mt-2">- <label htmlFor="video-text-encoder" className="block text-xs font-medium text-gray-400 mb-1">- Text encoder- </label>- <select+ <FormField+ className="mt-2"+ label="Text encoder"+ labelClassName="block text-xs font-medium text-gray-400 mb-1"+ >+ <ModelSelectid="video-text-encoder"+ models={options}value={selected.id}onChange={(e) => onChange(e.target.value)}+ getLabel={optionLabel}disabled={disabled}- className={inputCls}- >- {options.map((option) => (- <option key={option.id} value={option.id}>- {option.label}- {option.sizeBytes ? ` (~${formatBytes(option.sizeBytes)} download)` : ''}- </option>- ))}- </select>+ />{selected.description && (<p className="text-[10px] text-gray-500 leading-snug mt-1">{selected.description}</p>)}@@ -68,16 +69,24 @@ export default function TextEncoderPicker({{selected.advisory && (<p className="text-[10px] text-port-warning leading-snug mt-1">{selected.advisory}</p>)}+ {/* Same provenance affordance a MODEL gets (ModelDisclosure/FactLink): a+ substitute is someone else's tens-of-GB checkpoint, so its card and+ license stay one click away instead of being facts only the registry+ knows. */}+ {(card || license) && (+ <p className="text-[10px] text-gray-500 leading-snug mt-1 flex flex-wrap items-center gap-x-2">+ {card && <FactLink href={card}>Model card</FactLink>}+ {license && <FactLink href={license.url}>{license.name}</FactLink>}+ </p>+ )}{needsDownload && (- <div className="mt-1">- <ModelDownloadBadge- status={status}- onDownload={() => onDownload?.(selected.id)}- onCancel={onCancel}- estimateLabel={sizeLabel ? `~${sizeLabel}` : undefined}- />- </div>+ <ModelDownloadBadge+ status={status}+ onDownload={() => onDownload?.(selected.id)}+ onCancel={onCancel}+ estimateLabel={selected.sizeBytes ? `~${formatBytes(selected.sizeBytes)}` : undefined}+ />)}- </div>+ </FormField>);}diff --git a/client/src/components/videoGen/TextEncoderPicker.test.jsx b/client/src/components/videoGen/TextEncoderPicker.test.jsxindex e9906a6bf8..9b63269cd5 100644--- a/client/src/components/videoGen/TextEncoderPicker.test.jsx+++ b/client/src/components/videoGen/TextEncoderPicker.test.jsx@@ -11,6 +11,10 @@ const HERETIC = {builtIn: false,sizeBytes: 51506295440,advisory: 'This conditioner has had its refusal behavior removed.',+ disclosure: {+ modelCardUrl: 'https://huggingface.co/example/heretic',+ weightsLicense: { name: 'Apache-2.0', url: 'https://www.apache.org/licenses/LICENSE-2.0' },+ },};const OPTIONS = [STOCK, HERETIC];@@ -105,6 +109,20 @@ describe('TextEncoderPicker', () => {expect(screen.getByLabelText('Text encoder')).toHaveValue('stock');});+ // A substitute is someone else's tens-of-GB checkpoint — its provenance stays+ // one click away, the same affordance a MODEL gets. The built-in option has+ // no separate card or license of its own, so it shows neither.+ it('links the selected substitute’s model card and license', () => {+ const { rerender } = render(<TextEncoderPicker options={OPTIONS} value="stock" onChange={vi.fn()} />);+ expect(screen.queryByRole('link', { name: /Model card/ })).not.toBeInTheDocument();++ rerender(<TextEncoderPicker options={OPTIONS} value="heretic-bf16" onChange={vi.fn()} />);+ expect(screen.getByRole('link', { name: /Model card/ }))+ .toHaveAttribute('href', HERETIC.disclosure.modelCardUrl);+ expect(screen.getByRole('link', { name: /Apache-2\.0/ }))+ .toHaveAttribute('href', HERETIC.disclosure.weightsLicense.url);+ });+it('disables the select while a render is in flight', () => {render(<TextEncoderPicker options={OPTIONS} value="stock" onChange={vi.fn()} disabled />);expect(screen.getByLabelText('Text encoder')).toBeDisabled();diff --git a/client/src/hooks/useModelDownloadStatus.js b/client/src/hooks/useModelDownloadStatus.jsindex 36f619facf..2338be31ed 100644--- a/client/src/hooks/useModelDownloadStatus.js+++ b/client/src/hooks/useModelDownloadStatus.js@@ -14,17 +14,26 @@ import {// callers and the hook agree on the magic string.export const TEXT_ENCODER_DOWNLOAD_ID = '__text_encoder__';-// IC-LoRA remix weights (issue #3100) are downloadable but aren't registry-// models, so — like the text encoder — they route to a dedicated endpoint.-// Callers pass the remix mode itself ('ic-control') as the download id, and-// membership in the mode registry (NOT a raw `ic-` string prefix) is what-// identifies one — so an id can never be misrouted by coincidence of naming.// Namespace for a substitutable prompt-conditioner download id (#4081). The// video form passes `textEncoderDownloadId(option.id)` to start()/repair(); the// prefix keeps those ids from ever colliding with a registry model id.export const TEXT_ENCODER_OPTION_PREFIX = '__text_encoder_option__:';export const textEncoderDownloadId = (id) => `${TEXT_ENCODER_OPTION_PREFIX}${id}`;+// The registry id inside a namespaced download id, or `null` when this isn't+// one. One place decides both questions, so the URL builder, the repair+// dispatch and the status lookup can't disagree about what counts as a+// conditioner id or where the bare id starts.+const textEncoderOptionIdOf = (downloadId) => (+ String(downloadId).startsWith(TEXT_ENCODER_OPTION_PREFIX)+ ? String(downloadId).slice(TEXT_ENCODER_OPTION_PREFIX.length)+ : null+);+// IC-LoRA remix weights (issue #3100) are downloadable but aren't registry+// models, so — like the text encoder — they route to a dedicated endpoint.+// Callers pass the remix mode itself ('ic-control') as the download id, and+// membership in the mode registry (NOT a raw `ic-` string prefix) is what+// identifies one — so an id can never be misrouted by coincidence of naming.export const buildDownloadUrl = (kind, modelId, force = false) => {if (!modelId) return null;// A repair-initiated re-download appends `?force=1` so the server re-fetches@@ -41,12 +50,12 @@ export const buildDownloadUrl = (kind, modelId, force = false) => {return `/api/video-gen/ic-loras/${encodeURIComponent(modelId)}/download${q}`;}// Substitutable prompt conditioners (#4081) are downloadable but aren't- // registry models either. Identified by the TEXT_ENCODER_OPTION_PREFIX the- // caller wraps the registry id in, rather than by the bare id — otherwise a- // future model whose id happened to match one would be misrouted.- if (kind === 'video' && String(modelId).startsWith(TEXT_ENCODER_OPTION_PREFIX)) {- const id = String(modelId).slice(TEXT_ENCODER_OPTION_PREFIX.length);- return `/api/video-gen/text-encoders/${encodeURIComponent(id)}/download${q}`;+ // registry models either. Identified by the namespace the caller wraps the+ // registry id in, rather than by the bare id — otherwise a future model whose+ // id happened to match one would be misrouted.+ const encoderOptionId = kind === 'video' ? textEncoderOptionIdOf(modelId) : null;+ if (encoderOptionId) {+ return `/api/video-gen/text-encoders/${encodeURIComponent(encoderOptionId)}/download${q}`;}return `/api/${kind}-gen/models/${encodeURIComponent(modelId)}/download${q}`;};@@ -165,16 +174,15 @@ export function useModelDownloadStatus({ kind = 'image' } = {}) {// The shared text encoder isn't a model id, so its repair hits the scalar// /text-encoder/repair endpoint; the sentinel `start()` below already maps// to the dedicated /text-encoder/download SSE for the clean re-fetch.- const isTextEncoder = kind === 'video' && modelId === TEXT_ENCODER_DOWNLOAD_ID;- const isIcLora = kind === 'video' && isIcLoraMode(modelId);- const isEncoderOption = kind === 'video' && String(modelId).startsWith(TEXT_ENCODER_OPTION_PREFIX);- const run = isTextEncoder- ? () => repairTextEncoder({ deep })- : isIcLora- ? () => repairIcLora(modelId, { deep })- : isEncoderOption- ? () => repairTextEncoderOption(String(modelId).slice(TEXT_ENCODER_OPTION_PREFIX.length), { deep })- : () => (kind === 'video' ? repairVideoModel : repairImageModel)(modelId, { deep });+ const run = () => {+ if (kind === 'video') {+ if (modelId === TEXT_ENCODER_DOWNLOAD_ID) return repairTextEncoder({ deep });+ if (isIcLoraMode(modelId)) return repairIcLora(modelId, { deep });+ const encoderOptionId = textEncoderOptionIdOf(modelId);+ if (encoderOptionId) return repairTextEncoderOption(encoderOptionId, { deep });+ }+ return (kind === 'video' ? repairVideoModel : repairImageModel)(modelId, { deep });+ };const result = await run().catch((err) => {toast.error(err?.message || 'Repair failed');return null;@@ -217,10 +225,10 @@ export function useModelDownloadStatus({ kind = 'image' } = {}) {if (ic) return ic;// Conditioner entries are keyed by their BARE registry id in the status// payload, so unwrap the download namespace before matching.- if (String(modelId).startsWith(TEXT_ENCODER_OPTION_PREFIX)) {- const bare = String(modelId).slice(TEXT_ENCODER_OPTION_PREFIX.length);- const list = Array.isArray(extra.textEncoderOptions) ? extra.textEncoderOptions : [];- return list.find((s) => s.id === bare) || null;+ const encoderOptionId = textEncoderOptionIdOf(modelId);+ if (encoderOptionId) {+ const encoders = Array.isArray(extra.textEncoderOptions) ? extra.textEncoderOptions : [];+ return encoders.find((s) => s.id === encoderOptionId) || null;}return null;}, [statuses, extra.icLoras, extra.textEncoderOptions]);diff --git a/client/src/hooks/useVideoGenForm.js b/client/src/hooks/useVideoGenForm.jsindex d62950c29d..9002bdfd29 100644--- a/client/src/hooks/useVideoGenForm.js+++ b/client/src/hooks/useVideoGenForm.js@@ -18,6 +18,7 @@ import {normalizeFramesForModel, normalizeFpsForModel,icLoraSpecForMode, icResolutionIssue,STOCK_TEXT_ENCODER_ID, textEncoderOptionsForModel, normalizeTextEncoderForModel,+ textEncoderIdFromRecord,} from '../lib/videoGenParams.js';/**@@ -888,9 +889,7 @@ export function useVideoGenForm({ models, status, availableLoras, grokEnabled })// 'stock' and must clear a leftover override rather than silently reusing it// on a render the user asked to reproduce faithfully. The currentModel effect// snaps an id this model can't load back to stock.- setTextEncoderId(typeof item.textEncoderId === 'string' && item.textEncoderId- ? item.textEncoderId- : STOCK_TEXT_ENCODER_ID);+ setTextEncoderId(textEncoderIdFromRecord(item.textEncoderId));// disableAudio: always set explicitly (true/false) so the toggle reliably// matches the remixed render. Skipping the false branch would leave the// toggle stuck ON when the user remixes a clip that had audio enabled.@@ -989,9 +988,7 @@ export function useVideoGenForm({ models, status, availableLoras, grokEnabled })if (p.seed != null) setSeed(String(p.seed));if (p.tiling) setTiling(p.tiling);// Resume echoes the field only for a non-stock render, so absence is 'stock'.- setTextEncoderId(typeof p.textEncoderId === 'string' && p.textEncoderId- ? p.textEncoderId- : STOCK_TEXT_ENCODER_ID);+ setTextEncoderId(textEncoderIdFromRecord(p.textEncoderId));if (typeof p.disableAudio === 'boolean') setDisableAudio(p.disableAudio);if (p.mode === 'grok') {// Grok job: 'grok' is the queue discriminator, not a semantic videodiff --git a/client/src/lib/videoGenParams.js b/client/src/lib/videoGenParams.jsindex 3b1c2e18a8..640ae29e5b 100644--- a/client/src/lib/videoGenParams.js+++ b/client/src/lib/videoGenParams.js@@ -98,6 +98,14 @@ export const textEncoderOptionsForModel = (model) => (export const normalizeTextEncoderForModel = (id, model) => (textEncoderOptionsForModel(model).some((option) => option.id === id) ? id : STOCK_TEXT_ENCODER_ID);+// Read a conditioner out of a persisted record (a history entry, a resumed+// job's params). Both only record a SUBSTITUTE, so a missing field means stock —+// and must CLEAR a leftover selection rather than carry it into a render the+// user asked to reproduce. Keeping that rule next to the sentinel stops the two+// restore paths from drifting on it.+export const textEncoderIdFromRecord = (value) => (+ typeof value === 'string' && value ? value : STOCK_TEXT_ENCODER_ID+);// Per-edge bounds for video: mirrors the videoGen route (64..2048). The base// grid is 64px, while a model may declare a finer resolutionStep (H3 uses 32).diff --git a/client/src/pages/VideoGen.jsx b/client/src/pages/VideoGen.jsxindex 8c43814621..1255ce662f 100644--- a/client/src/pages/VideoGen.jsx+++ b/client/src/pages/VideoGen.jsx@@ -475,8 +475,10 @@ export default function VideoGen() {// the model's own weights, so only a substitute has a download of its own to// track — and only then can it gate Generate.const selectedTextEncoder = textEncoderOptions.find((option) => option.id === textEncoderId) || null;- const textEncoderOptionNeedsWeights = !!selectedTextEncoder && !selectedTextEncoder.builtIn;- const textEncoderOptionDownloadId = textEncoderOptionNeedsWeights+ // Non-null exactly when the selection has a download of its own — a built-in+ // conditioner ships inside the model's weights. Doubles as the "needs+ // weights" predicate so there's one derivation, not two.+ const textEncoderOptionDownloadId = selectedTextEncoder && !selectedTextEncoder.builtIn? textEncoderDownloadId(selectedTextEncoder.id): null;const textEncoderOptionStatus = textEncoderOptionDownloadId@@ -490,7 +492,7 @@ export default function VideoGen() {&& (modelDownload.loading || textEncoderStatus === null || textEncoderStatus?.cached === false);const icWeightsBlocked = !isGrok && icModeActive&& (modelDownload.loading || icWeightStatus === null || icWeightStatus?.cached === false);- const textEncoderOptionBlocked = !isGrok && textEncoderOptionNeedsWeights+ const textEncoderOptionBlocked = !isGrok && !!textEncoderOptionDownloadId&& (modelDownload.loading || textEncoderOptionStatus === null || textEncoderOptionStatus?.cached === false);const weightsGateBlocked = modelWeightsBlocked || textEncoderWeightsBlocked|| textEncoderOptionBlocked || icWeightsBlocked;@@ -526,6 +528,22 @@ export default function VideoGen() {const [dismissedEncoderIntegrityKey, setDismissedEncoderIntegrityKey] = useState(null);const showEncoderIntegrityBanner = encoderIntegrityBad && dismissedEncoderIntegrityKey !== encoderIntegrityKey && !modelDownload.downloading;+ // A substituted conditioner is a separate pinned file, so it gets the same+ // treatment: the model-keyed and shared-encoder repairs above can't reach it,+ // and a corrupt one degrades the render rather than failing it.+ const textEncoderOptionIntegrity = textEncoderOptionStatus && !textEncoderOptionStatus.downloading+ ? textEncoderOptionStatus.integrity+ : null;+ const textEncoderOptionIntegrityBad = textEncoderOptionIntegrity?.status === 'bad';+ const textEncoderOptionIntegrityBadCount = textEncoderOptionIntegrityBad ? (textEncoderOptionIntegrity.badFiles || []).length : 0;+ const textEncoderOptionIntegrityKey = textEncoderOptionIntegrityBad+ ? `${textEncoderOptionDownloadId}:${(textEncoderOptionIntegrity.badFiles || []).map((f) => f.name).join(',')}`+ : null;+ const [dismissedTextEncoderOptionIntegrityKey, setDismissedTextEncoderOptionIntegrityKey] = useState(null);+ const showTextEncoderOptionIntegrityBanner = textEncoderOptionIntegrityBad+ && dismissedTextEncoderOptionIntegrityKey !== textEncoderOptionIntegrityKey+ && !modelDownload.downloading;+// IC-LoRA weights are independent downloads too. Keep their corruption// recovery on the originating Video Gen surface instead of requiring a CLI// cache purge or leaving the user with a disabled Generate button.@@ -844,6 +862,26 @@ export default function VideoGen() {repairing={modelDownload.repairing}/>)}+ {/* A substituted conditioner is its own multi-GB file, so a corrupt+ one needs its own Repair path — neither the model-keyed banner nor+ the shared-encoder one above can reach it. Same failure mode as a+ corrupt model: the render completes and comes out garbled. */}+ {showTextEncoderOptionIntegrityBanner && (+ <ModelRepairBanner+ message={<>+ The <strong className="font-semibold">{selectedTextEncoder?.label}</strong> text encoder has {textEncoderOptionIntegrityBadCount || 'corrupt'} damaged file{textEncoderOptionIntegrityBadCount === 1 ? '' : 's'} — renders may come out garbled.+ Repair deletes the bad file{textEncoderOptionIntegrityBadCount === 1 ? '' : 's'} and re-downloads a clean copy.+ </>}+ repairLabel="Repair text encoder"+ onRepair={() => {+ setDismissedTextEncoderOptionIntegrityKey(textEncoderOptionIntegrityKey);+ modelDownload.repair(textEncoderOptionDownloadId);+ }}+ onDismiss={() => setDismissedTextEncoderOptionIntegrityKey(textEncoderOptionIntegrityKey)}+ disabled={modelDownload.repairing || modelDownload.downloading}+ repairing={modelDownload.repairing}+ />+ )}{showIcIntegrityBanner && (<ModelRepairBannermessage={<>diff --git a/server/lib/README.md b/server/lib/README.mdindex cec5912fe7..90456dfb11 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -117,7 +117,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `videoDisclosure.js` | Video Gen provenance/licensing + backend policy-scope facts (#3674). `VIDEO_MODEL_DISCLOSURES` maps each shipped video model id to `{ shippedRepo, disclosure }` (model card URL, weights license, runtime license, pinned-snapshot download size in decimal GB, review date) — every value checked against a primary upstream source, and any fact that could not be established is OMITTED so the UI renders "Unknown" instead of guessing. `applyVideoDisclosures(list)` is the load-time backfill (twin of migration 237) with the same preservation guards: an existing `disclosure` key wins, a custom id is skipped, and a `repo` pointed at a fork keeps Unknown. `VIDEO_BACKEND_DISCLOSURES` / `videoBackendDisclosure(id)` state where inference runs (`execution: local or hosted`) and whose policy applies — execution facts only, never a restrictiveness ranking. || `videoFinishProfiles.js` | Draft → delivery ("Finish") relationships between video models (#3696). `VIDEO_FINISH_PROFILES` declares each fast draft entry id → `{ shippedRepo, finishModelId }`, only for pairs that share a runtime, base repo and supported modes (the same weights at a different step budget), so re-rendering the draft's seed reproduces its composition instead of re-rolling it. `applyVideoFinishProfiles(list)` is the load-time backfill (twin of migration 238) with the usual preservation guards (existing key wins, custom id skipped, forked `repo` skipped); `validateFinishProfileGraph(list)` returns the graph problems (missing / self-referencing / chained target, runtime / repo / supportedModes mismatch) and `sanitizeFinishProfiles(list)` warns + strips them at load so a typo can never surface a Finish button targeting nothing. `finishTargetForModel(model, availableModels)` resolves the delivery entry scoped to what this install can run. || `videoModeProfiles.js` | The shipped `supportedModes` fact per video runtime (#3737), so "which modes does this model support?" has one answer on the registry entry instead of 25+ `runtime === '…'` comparisons. `VIDEO_RUNTIME_MODES` maps each runtime to the base semantic modes its helper's argv can actually render (`mlx_video`/`ltx2` text+image+fflf+extend, `wan22` text+image, `minimax_h3` text+image+fflf — also the mode ceiling in `videoGen/modeContract.js` — `hunyuan` text only, replacing the legacy unread `mode: 't2v'` field); `VIDEO_BASE_MODES` is the fallback for an unknown (user-added or peer-synced) runtime, deliberately the full base set so a custom model doesn't vanish from every picker. `resolveVideoSupportedModes(entry)` (declared non-empty list always wins) and `applyVideoSupportedModes(list)` — the read-time decoration `mediaModels.js#getVideoModels` applies, so the derived list never lands in `data/media-models.json` where it would read back as a *declared* list no later correction could reach. a2v and the IC-LoRA remix ids are NOT enumerated here: they're ltx2 pipeline capabilities, gated by runtime (`A2V_REQUIRES_LTX2` / `IC_LORA_REQUIRES_LTX2`). |-| `videoTextEncoders.js` | Swappable prompt conditioners for local video runtimes. MiniMax H3 reads the *unnormalized* hidden state after Qwen3-VL language layer 49 (layers 50-63, the final norm and `lm_head` are never evaluated), so any checkpoint carrying the same embedding + layers 0-49 + vision tower is a drop-in conditioner — swapping it changes how the model reads a prompt without touching the diffusion weights. `TEXT_ENCODERS_BY_RUNTIME` declares the shipped options per runtime (pinned repo/revision/file, in code rather than the media-models registry so a stale `data/media-models.json` can't name a file the runner can't map); `videoTextEncoderOptions(model)` returns them stock-first (empty when the runtime has no substitutions, so the picker is absent rather than single-entry), `resolveVideoTextEncoder(model, id)` returns `null` for the stock choice or throws `VIDEO_TEXT_ENCODER_UNSUPPORTED`, and `downloadableVideoTextEncoders()` / `downloadableVideoTextEncoder(id)` feed the `/api/video-gen/text-encoders/:id/(download\|repair)` lane. Two loader-mechanics fields exist because a ComfyUI-packaged conditioner is namespaced differently from the HF checkpoint the MLX port matches: `keyPrefixMap` (`model.` → `model.language_model.`, `visual.` → `model.visual.`) is applied to every checkpoint key by `scripts/generate_minimax_h3.py` BEFORE the pinned loader sees it — no fork of the pinned runtime — and `finalNormKey` names where the runner synthesizes a ones-filled `norm.weight` for a checkpoint published without one (correct upstream, since H3 reads the state *before* the norm, but the pinned loader refuses to load with any parameter missing). `publicTextEncoderOption(entry)` is the client projection and deliberately drops both, so the UI can't reimplement the remap. |+| `videoTextEncoders.js` | Swappable prompt conditioners for local video runtimes. MiniMax H3 reads the *unnormalized* hidden state after Qwen3-VL language layer 49 (layers 50-63, the final norm and `lm_head` are never evaluated), so any checkpoint carrying the same embedding + layers 0-49 + vision tower is a drop-in conditioner — swapping it changes how the model reads a prompt without touching the diffusion weights. `TEXT_ENCODERS_BY_RUNTIME` declares the shipped options per runtime (pinned repo/revision/file, in code rather than the media-models registry so a stale `data/media-models.json` can't name a file the runner can't map); `videoTextEncoderOptions(model)` returns the TRUE list stock-first (it deliberately does NOT collapse a one-entry runtime to `[]` — that is a presentation rule, and folding it in here would change what the server believes a model supports and empty the "offers …" list in the error; `TextEncoderPicker` owns the hide-when-there-is-no-real-choice check), `isStockTextEncoder(id)` makes absence and the `stock` sentinel the same request, `resolveVideoTextEncoder(model, id)` returns `null` for the stock choice or throws `VIDEO_TEXT_ENCODER_UNSUPPORTED` (with the non-throwing `supportsVideoTextEncoder` + `videoTextEncoderUnsupportedError` split out so the request path can reject before staging uploads), and `downloadableVideoTextEncoders()` (deduped by id — the table is keyed by RUNTIME, so one conditioner can be offered by two) / `downloadableVideoTextEncoder(id)` feed the `/api/video-gen/text-encoders/:id/(download\|repair)` lane. Two loader-mechanics fields exist because a ComfyUI-packaged conditioner is namespaced differently from the HF checkpoint the MLX port matches: `keyPrefixMap` (`model.` → `model.language_model.`, `visual.` → `model.visual.`) is applied to every checkpoint key by `scripts/generate_minimax_h3.py` BEFORE the pinned loader sees it — no fork of the pinned runtime — and `finalNormKey` names where the runner synthesizes a ones-filled `norm.weight` for a checkpoint published without one (correct upstream, since H3 reads the state *before* the norm, but the pinned loader refuses to load with any parameter missing). `publicTextEncoderOption(entry)` is the client projection and deliberately drops both, so the UI can't reimplement the remap. || `providerModels.js` | Provider model resolution sentinels + helpers (`CODEX_CONFIGURED_DEFAULT` / `ANTIGRAVITY_CONFIGURED_DEFAULT` / `GROK_CONFIGURED_DEFAULT` / `KIMI_CONFIGURED_DEFAULT`, `resolveCliModel`, `filterSelectableModels`, Bedrock/OpenCode model mappers, model-flag scan helpers incl. `stripBrokenModelFlags`, `isCodexProvider`, `isKimiProvider`, `isAntigravityProvider`) plus reasoning-effort helpers for the claude/codex/agy CLIs (`CLAUDE_EFFORT_LEVELS` / `CODEX_EFFORT_LEVELS` / `ANTIGRAVITY_EFFORT_LEVELS` / `EFFORT_LEVELS`, `effortLevelsForProvider`, `resolveCliEffort` — clamps an out-of-range effort to the nearest level the target CLI accepts rather than dropping it, so a value saved against a wider ladder survives a provider switch — `hasEffortFlag`, and `buildEffortArgs` — the one emitter of `--effort <level>` / `-c model_reasoning_effort=<level>`) plus codex startup-arg helpers (`CODEX_UPDATE_CHECK_KEY`, `hasCodexUpdateCheckConfig`, `buildCodexStartupArgs` — the one emitter of `-c check_for_update_on_startup=false`, spread by every codex spawn builder to disable the blocking startup update modal). || `providerVendors.js` | `PROVIDER_VENDORS` — one row per coding-agent CLI/TUI vendor (claude/codex/antigravity/opencode/grok/kimi/cursor, plus a deliberately-incomplete legacy `gemini-cli` row), consumed by every dispatch site that used to hand-roll its own vendor if-chain across ~8 branches in 5 files (#3618): `applyCommandDefaults`/`prepareCliPrompt` (re-exported from `tuiHandshake.js`/`cliProviderArgs.js`), `buildVendorCliArgs`/`buildVendorSpawnConfig` (consumed by `cliProviderArgs.js#buildCliArgs` / `agentCliSpawning.js#buildCliSpawnConfig`), `inferTuiCommand` (re-exported from `tuiHandshake.js`), and `injectTuiModelAndEffort` — the shared antigravity-validates-the-pair-vs-everyone-else `--model`/`--effort` injection used by both `tuiHandshake.js#buildTuiInvocation` and `agentTuiSpawning.js#buildTuiSpawnConfig`, replacing a second copy of that split that had already drifted once before this file existed. Doesn't rewrite any vendor's argv-building logic — that stays in `antigravity.js`/`grok.js`/`kimi.js`/`cursor.js`/`codex.js`. Dependency-light on purpose, mirroring those files. || `modelPricing.js` | Per-model API billing rates for the /devtools/usage cost estimates — `resolveModelRates(providerId, model)` (exact → family regex → provider default → blended fallback, with a `matched` tier; also derives `cacheReadPer1M`/`cacheWritePer1M` from the input rate via per-family multipliers), `isFreeProvider` (ollama/lmstudio/`ollamaBacked`/localhost = free), `estimateCostUsd(tokensIn, tokensOut, rates, cache?)` — `tokensIn` is UNCACHED input; cache tiers are priced separately via the optional 4th arg — and `PRICING_AS_OF`. Informational only (PortOS runs on subscriptions); still excludes batch/long-context tiers. |diff --git a/server/lib/videoDisclosure.js b/server/lib/videoDisclosure.jsindex 2470e16394..28e8f7afc7 100644--- a/server/lib/videoDisclosure.js+++ b/server/lib/videoDisclosure.js@@ -32,7 +32,10 @@ export const VIDEO_DISCLOSURE_REVIEWED_AT = '2026-08-09';// License descriptors reused across entries. `url` points at the primary text// of the license, or at the model card when the card declares a custom license// without publishing a distinct document.-const APACHE_2 = { name: 'Apache-2.0', url: 'https://www.apache.org/licenses/LICENSE-2.0' };+// Exported for lib/videoTextEncoders.js, whose substitutable conditioners carry+// the same `disclosure` shape — a license-text correction here has to reach+// both tables, which a second inline literal would prevent.+export const APACHE_2 = { name: 'Apache-2.0', url: 'https://www.apache.org/licenses/LICENSE-2.0' };const TENCENT_HUNYUAN_WEIGHTS = {name: 'Tencent Hunyuan Community License',url: 'https://huggingface.co/tencent/HunyuanVideo/blob/main/LICENSE',diff --git a/server/lib/videoTextEncoders.js b/server/lib/videoTextEncoders.jsindex 7ebd7cd714..95e19ba220 100644--- a/server/lib/videoTextEncoders.js+++ b/server/lib/videoTextEncoders.js@@ -31,6 +31,7 @@*/import { ServerError } from './errorHandler.js';+import { APACHE_2 } from './videoDisclosure.js';// Every runtime's built-in conditioner option. Selected by default and always// present, so the picker never renders a single-option select and a render that@@ -73,19 +74,21 @@ const TEXT_ENCODERS_BY_RUNTIME = Object.freeze({// size the UI shows — the picker formats it rather than carrying a second,// driftable "~N GB" literal.sizeBytes: 51506295440,+ // Same shape as VIDEO_MODEL_DISCLOSURES, and rendered by the same+ // FactLink affordance — reusing that module's license descriptor rather+ // than restating the Apache text URL. `estimatedDownloadGb` is omitted on+ // purpose: `sizeBytes` above is the one size, and the UI formats it.disclosure: Object.freeze({modelCardUrl: 'https://huggingface.co/ethanfel/Qwen3-VL-32B-Ultra-Heretic-H3-ComfyUI-INT8-ConvRot',- weightsLicense: Object.freeze({- name: 'Apache-2.0',- url: 'https://huggingface.co/Qwen/Qwen3-VL-32B-Instruct',- }),- baseModel: 'Qwen/Qwen3-VL-32B-Instruct',- // Decimal GB, matching lib/videoDisclosure.js's convention.- estimatedDownloadGb: 51.5,+ weightsLicense: APACHE_2,reviewedAt: '2026-08-14',}),- // The stock conditioner is aligned; this one is deliberately not. Surface- // that in the picker rather than burying it in a model card.+ // Informational, NOT a terms gate. H3's own `termsGate` already gates the+ // render on its Community License, and this conditioner is plain+ // Apache-2.0 with nothing extra to accept — so a second acknowledgement+ // click would be friction with no legal basis behind it. What the user+ // does need is to know the behavior changed, which the picker states+ // inline at the moment of choosing.advisory:'This conditioner has had its refusal behavior removed. It will follow prompts the stock '+ 'conditioner declines. You remain responsible for what you generate.',@@ -94,14 +97,16 @@ const TEXT_ENCODERS_BY_RUNTIME = Object.freeze({});/**- * Every conditioner option a model can render with, stock first.- * Returns `[]` for a runtime with no substitutions — the caller renders no- * picker rather than a select with one entry.+ * Every conditioner option a model can render with, stock first — `[]` for a+ * runtime this build has no conditioner table for.+ *+ * Deliberately NOT filtered down to "more than one option": that is a+ * presentation rule, and folding it in here would quietly change what the+ * SERVER believes a model supports (and empty the "offers …" list in the error+ * below) for a reason that is only about how a `<select>` looks. The picker+ * owns the hide-when-there-is-no-real-choice check.*/-export const videoTextEncoderOptions = (model) => {- const list = TEXT_ENCODERS_BY_RUNTIME[model?.runtime];- return list && list.length > 1 ? list : [];-};+export const videoTextEncoderOptions = (model) => TEXT_ENCODERS_BY_RUNTIME[model?.runtime] || [];/** Resolve one option by id, or `null` when the model can't render with it. */export const videoTextEncoderOption = (model, id) =>@@ -143,8 +148,9 @@ export const videoTextEncoderUnsupportedError = (model, id) => {*/export const resolveVideoTextEncoder = (model, id) => {if (isStockTextEncoder(id)) return null;- if (!supportsVideoTextEncoder(model, id)) throw videoTextEncoderUnsupportedError(model, id);- return videoTextEncoderOption(model, id);+ const option = videoTextEncoderOption(model, id);+ if (!option || option.builtIn) throw videoTextEncoderUnsupportedError(model, id);+ return option;};/**@@ -152,24 +158,28 @@ export const resolveVideoTextEncoder = (model, id) => {* /models/status lane and the download/repair routes enumerate. The built-in* options are excluded: they ride the model's own download.*/-export const downloadableVideoTextEncoders = () => {- const seen = new Map();- for (const list of Object.values(TEXT_ENCODERS_BY_RUNTIME)) {- for (const entry of list) {- if (!entry.builtIn && !seen.has(entry.id)) seen.set(entry.id, entry);- }- }- return [...seen.values()];-};+// Deduped by id, not merely flattened: the table is keyed by RUNTIME, so one+// conditioner can legitimately be offered by two of them — and a duplicate here+// would mean two download targets and two status rows for one file.+export const downloadableVideoTextEncoders = () => [...new Map(+ Object.values(TEXT_ENCODERS_BY_RUNTIME).flat()+ .filter((entry) => !entry.builtIn)+ .map((entry) => [entry.id, entry]),+).values()];/** Resolve a downloadable conditioner by id for the download/repair routes. */export const downloadableVideoTextEncoder = (id) =>downloadableVideoTextEncoders().find((entry) => entry.id === id) || null;/**- * The client-facing projection of an option. Deliberately drops `keyPrefixMap`- * and `finalNormKey` — loader mechanics the UI has no use for and that would- * only invite a client-side reimplementation of the remap.+ * The client-facing projection of an option — exactly what the picker renders,+ * nothing more.+ *+ * Deliberately drops `keyPrefixMap` / `finalNormKey` (loader mechanics that+ * would only invite a client-side reimplementation of the remap), `revision`,+ * and `file`: the client never addresses the weight by path — it passes the+ * option's `id` and the server resolves the rest. `repo` stays because the+ * download badge names it in its tooltip.*/export const publicTextEncoderOption = (entry) => ({id: entry.id,@@ -177,8 +187,14 @@ export const publicTextEncoderOption = (entry) => ({description: entry.description,builtIn: !!entry.builtIn,...(entry.repo ? { repo: entry.repo } : {}),- ...(entry.file ? { file: entry.file } : {}),...(entry.sizeBytes ? { sizeBytes: entry.sizeBytes } : {}),...(entry.advisory ? { advisory: entry.advisory } : {}),...(entry.disclosure ? { disclosure: entry.disclosure } : {}),});++/**+ * The client-facing option list for a model — what `decorateVideoModel`+ * attaches to every registry entry.+ */+export const publicVideoTextEncoderOptions = (model) =>+ videoTextEncoderOptions(model).map(publicTextEncoderOption);diff --git a/server/lib/videoTextEncoders.parity.test.js b/server/lib/videoTextEncoders.parity.test.jsnew file mode 100644index 0000000000..b8c0b42ec6--- /dev/null+++ b/server/lib/videoTextEncoders.parity.test.js@@ -0,0 +1,58 @@+/**+ * Cross-package parity for the swappable prompt-conditioner sentinel (#4081).+ *+ * Unlike the IC-LoRA registry next door, the OPTIONS themselves are not+ * mirrored — the server decorates each model entry with its own+ * `textEncoderOptions` (videoGen/local.js#decorateVideoModel), so the picker+ * renders whatever this build's runner can key-map and there is nothing on the+ * client to drift.+ *+ * The one duplicated value is the "no override" sentinel, and it carries real+ * weight in both directions: the client's submit builder DROPS the field when+ * it holds this value, and the server treats an absent field and this id+ * identically (`isStockTextEncoder`). If the two strings ever diverged, the+ * client would post `textEncoderId: 'stock'` to a server that reads it as a+ * substitute id and 400s VIDEO_TEXT_ENCODER_UNSUPPORTED on every H3 render.+ *+ * Lives server-side because the server module can't load under the client+ * (jsdom) runner, while the pure client mirror loads fine here.+ */++import { describe, it, expect } from 'vitest';+import { STOCK_TEXT_ENCODER_ID, isStockTextEncoder, videoTextEncoderOptions } from './videoTextEncoders.js';+import {+ STOCK_TEXT_ENCODER_ID as CLIENT_STOCK_TEXT_ENCODER_ID,+ normalizeTextEncoderForModel,+ textEncoderIdFromRecord,+} from '../../client/src/lib/videoGenParams.js';++describe('video text-encoder client/server parity', () => {+ it('mirrors the stock sentinel exactly', () => {+ expect(CLIENT_STOCK_TEXT_ENCODER_ID).toBe(STOCK_TEXT_ENCODER_ID);+ });++ // The client emits this value in three places (initial state, the+ // model-change reset, the record restore). Every one of them must land on+ // something the server reads as "no override".+ it('produces a sentinel the server accepts as no-override', () => {+ expect(isStockTextEncoder(CLIENT_STOCK_TEXT_ENCODER_ID)).toBe(true);+ expect(isStockTextEncoder(textEncoderIdFromRecord(undefined))).toBe(true);+ expect(isStockTextEncoder(textEncoderIdFromRecord(''))).toBe(true);+ expect(isStockTextEncoder(normalizeTextEncoderForModel('gone', { runtime: 'minimax_h3' }))).toBe(true);+ });++ // The server ships the true option list (including a lone built-in entry), so+ // the client's normalizer has to agree that a stock-only model offers no+ // substitute to select.+ it('agrees that the built-in option is the stock sentinel', () => {+ const options = videoTextEncoderOptions({ runtime: 'minimax_h3' });+ const builtIn = options.filter((option) => option.builtIn);+ expect(builtIn).toHaveLength(1);+ expect(builtIn[0].id).toBe(CLIENT_STOCK_TEXT_ENCODER_ID);++ // A substitute the model really offers survives normalization unchanged.+ const substitute = options.find((option) => !option.builtIn);+ const model = { runtime: 'minimax_h3', textEncoderOptions: options };+ expect(normalizeTextEncoderForModel(substitute.id, model)).toBe(substitute.id);+ });+});diff --git a/server/lib/videoTextEncoders.test.js b/server/lib/videoTextEncoders.test.jsindex c78ff53232..92cbf68c59 100644--- a/server/lib/videoTextEncoders.test.js+++ b/server/lib/videoTextEncoders.test.js@@ -122,17 +122,25 @@ describe('videoTextEncoders', () => {expect(projected.sizeBytes).toBeUndefined();});- // Size is declared once, as bytes. A GB figure also appears in `disclosure`- // (the convention lib/videoDisclosure.js uses for its own entries), so pin it- // against the byte count rather than letting the two drift.- it('keeps the disclosure GB figure consistent with the byte count', () => {+ // Size is declared ONCE, as bytes, and the UI formats it. A second GB literal+ // (the shape lib/videoDisclosure.js uses for its own entries) would be a+ // driftable restatement of the same fact.+ it('declares size only as bytes', () => {for (const entry of downloadableVideoTextEncoders()) {- const declaredGb = entry.disclosure?.estimatedDownloadGb;- expect(declaredGb).toBeGreaterThan(0);- expect(declaredGb).toBeCloseTo(entry.sizeBytes / 1e9, 0);+ expect(entry.sizeBytes).toBeGreaterThan(0);+ expect(entry.disclosure?.estimatedDownloadGb).toBeUndefined();}});+ // The licence descriptor is the SHARED one from lib/videoDisclosure.js, not a+ // local restatement — a correction to the licence text URL has to reach both+ // tables from one edit.+ it('reuses the shared license descriptors', async () => {+ const { APACHE_2 } = await import('./videoDisclosure.js');+ const entry = videoTextEncoderOption(H3, 'heretic-bf16');+ expect(entry.disclosure.weightsLicense).toBe(APACHE_2);+ });+// An uncensored conditioner is a deliberate choice; the picker states what// changed rather than leaving it to an external model card.it('carries an advisory on every non-built-in option', () => {diff --git a/server/routes/videoGen.integrity.test.js b/server/routes/videoGen.integrity.test.jsindex 15616658cb..79e9fb0327 100644--- a/server/routes/videoGen.integrity.test.js+++ b/server/routes/videoGen.integrity.test.js@@ -235,8 +235,10 @@ describe('Video Gen integrity routes', () => {// The mocked verify reports 'bad', but an uncached file gets the Download// badge rather than a Repair banner — same rule as repoCacheStatus.expect(entry.integrity).toBeNull();+ // Through the shared target verifier, so the badge is checked exactly the+ // way the integrity scan and the repair route check it.expect(verifyCachedRepoFiles).toHaveBeenCalledWith(- encoder().repo, [encoder().file], { revision: encoder().revision },+ encoder().repo, [encoder().file], { deep: false, revision: encoder().revision },);});diff --git a/server/routes/videoGen.js b/server/routes/videoGen.jsindex 57c376f2d3..9a816c21bb 100644--- a/server/routes/videoGen.js+++ b/server/routes/videoGen.js@@ -625,11 +625,15 @@ const modelDownloadTargets = (model) => {// pinned file inside a repo that also publishes quantizations and generation// tails PortOS's MLX loader can't read, so these are ALWAYS scoped to `only:// [file]` — a repo-wide snapshot would pull ~130 GB of unusable variants.-const textEncoderDownloadTargets = () => downloadableVideoTextEncoders().map((entry) => ({+const textEncoderDownloadTarget = (entry) => ({repo: entry.repo,revision: entry.revision || null,only: [entry.file],-}));+});+// Paired with its entry so the status lane can project the registry fields+// (label, advisory, size) alongside the cache verdict without a second lookup.+const textEncoderDownloadTargets = () => downloadableVideoTextEncoders()+ .map((entry) => ({ entry, target: textEncoderDownloadTarget(entry) }));const targetKey = (target) => `${target.repo}@${target.revision || 'latest'}::${target.only.join(',')}`;const targetVerifyOptions = (target, deep) => ({@@ -654,7 +658,7 @@ const reposToVerify = (modelId) => {// Substitutable prompt conditioners are single pinned files the render path// depends on, so an unscoped scan must reach them too — a truncated one// otherwise only surfaces as a load failure minutes into a render.- targets.push(...textEncoderDownloadTargets());+ targets.push(...textEncoderDownloadTargets().map(({ target }) => target));// IC-LoRA remix weights are separate HF pulls that the render path depends// on, so an unscoped integrity scan must cover them too — otherwise a// corrupt IC weight only surfaces as a garbled render.@@ -715,10 +719,11 @@ router.get('/models/status', asyncHandler(async (_req, res) => {// the IC weights, so the video form renders their Download button and// Repair banner with the existing components. Scoped to the ONE pinned file// (never the repo) for the reason in textEncoderDownloadTargets.- Promise.all(downloadableVideoTextEncoders().map(async (entry) => {- const verify = await verifyCachedRepoFiles(entry.repo, [entry.file], {- ...(entry.revision ? { revision: entry.revision } : {}),- });+ Promise.all(textEncoderDownloadTargets().map(async ({ entry, target }) => {+ // Through the shared target verifier, so the badge, the integrity scan+ // and the repair route can't drift on how a pinned single-file target is+ // checked.+ const verify = await verifyDownloadTarget(target);const cached = verify.status === 'ok';return {...publicTextEncoderOption(entry),@@ -914,7 +919,7 @@ router.get('/text-encoders/:id/download', asyncHandler(async (req, res) => {await startHfDownloadStream({req,res,- repos: [{ repo: entry.repo, revision: entry.revision || null, only: [entry.file] }],+ repos: [textEncoderDownloadTarget(entry)],force: req.query.force === '1',});}));@@ -923,12 +928,10 @@ router.post('/text-encoders/:id/repair', asyncHandler(async (req, res) => {const entry = textEncoderFromParam(req.params.id);const parsed = z.object({ deep: z.boolean().optional() }).safeParse(req.body || {});if (!parsed.success) failValidation(parsed);- const result = await repairCachedRepoFiles(entry.repo, [entry.file], {- deep: parsed.data.deep || false,- ...(entry.revision ? { revision: entry.revision } : {}),- });+ const deep = parsed.data.deep || false;+ const result = await repairDownloadTarget(textEncoderDownloadTarget(entry), { deep });res.json({- deep: parsed.data.deep || false,+ deep,deleted: result.deleted.map((name) => ({ repo: entry.repo, name })),repos: [entry.repo],});diff --git a/server/services/videoGen/local.js b/server/services/videoGen/local.jsindex 59393911a4..90bd8d1fce 100644--- a/server/services/videoGen/local.js+++ b/server/services/videoGen/local.js@@ -45,7 +45,7 @@ import {isVideoModelTermsAccepted, acceptedVideoModelTerms, videoModelTermsGateId, videoModelTermsError,} from '../../lib/videoDisclosure.js';import {- videoTextEncoderOptions, publicTextEncoderOption, resolveVideoTextEncoder,+ publicVideoTextEncoderOptions, resolveVideoTextEncoder,} from '../../lib/videoTextEncoders.js';import { getSettings } from '../settings.js';import {@@ -175,7 +175,7 @@ const decorateVideoModel = (m) => (m ? {...m,lastFrameAnchored: modelAnchorsLastFrame(m),runtimeLoraCapable: byovRuntimeLoraCapable(m.runtime),- textEncoderOptions: videoTextEncoderOptions(m).map(publicTextEncoderOption),+ textEncoderOptions: publicVideoTextEncoderOptions(m),} : m);export const resolveVideoModel = (modelId) =>