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

feat(pipeline): character wardrobes (Cluster A)

[._.]/ Adam Eivy763154ebc6a5
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 8f82b83867..8ab5d77fda 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -2,6 +2,26 @@
## Added
+- **Character canon: wardrobes (Cluster A).** Every entry under
+ `universe.characters[]` gains an optional `wardrobes[]` array — each entry
+ is an `{ id, name, description, createdAt, updatedAt }` outfit/styling
+ variant layered on top of `physicalDescription`. Each character supports
+ up to 10 wardrobes; `name` is the only required field (sanitizer drops
+ nameless entries). The Universe Canon + Nouns stage cards render a
+ collapsible "Outfits" section per character with an inline editor —
+ click-to-expand, inline name + description inputs that buffer drafts and
+ PATCH on blur (no per-keystroke round-trips), per-row trash, "Add outfit"
+ that stays client-side-only until the user types a name (so a
+ half-created row doesn't get sanitized away mid-type). Selective draft
+ pruning on row delete preserves in-flight keystrokes in unrelated rows.
+ Scene-level wardrobe picking (a panel says "Don Carlos in Wedding
+ outfit") is deferred — captured in PLAN.md once the UX is settled.
+ Touches: `server/lib/storyBible.js`
+ (`sanitizeWardrobe` + `sanitizeWardrobeList` + `BIBLE_LIMITS.WARDROBE_*` +
+ `PROMPT_FIELDS` + `MERGE_CONFIG.userEditable`),
+ `server/lib/validation.js` (Zod parity sourcing limits from BIBLE_LIMITS),
+ `client/src/components/pipeline/CanonCard.jsx` (new `WardrobeSection`).
+
- **Setting canon: INT/EXT + time-of-day metadata (Cluster A).** Every entry
under `universe.settings[]` gains two new optional fields — `intExt`
(`'INT'`/`'EXT'`/null) and `timeOfDay` (`'dawn'`/`'day'`/`'dusk'`/`'night'`
diff --git a/PLAN.md b/PLAN.md
index 215f26318f..4855318e1a 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -244,6 +244,8 @@ Skeleton landed in `server/services/pipeline/` + `client/src/pages/Pipeline*.jsx
- **4c.3: 3rd-party music engine stubs.** Same UI affordance as the VO engines — once 4c.2 lands the abstraction, 3rd-party engines plug in as sibling sources.
- **4d.2: VO line muxing into the CD stitch.** Today's mux only lays the music bed; per-line VO is unmixed. Walk `storyboards.scenes[].dialogue` to map each audio line to a scene, compute scene-start offsets from the per-clip durations (already in `buildTimelineClips`), then build an ffmpeg filter_complex that places each line at `sceneStart + lineOffsetInScene` and ducks the music bed underneath. Open question worth real-world testing: gap-between-lines heuristic (fixed 800ms? scene-length-aware? based on prose pacing?). Touch sites: `server/services/pipeline/audioMux.js` (extend `muxMusicBed` to `muxPipelineAudio` or add a sibling export), `server/services/creativeDirector/stitchRunner.js#maybeMuxPipelineAudio` (compute timing from `clips[]` + storyboards mapping).
- [ ] **Lift `runFfmpegProcess({ args, signal, stderrTailBytes }) → { ok, reason }` into `server/lib/ffmpeg.js`.** Three call sites today share the spawn → stderr-tail → close → SIGTERM-on-abort pattern: `audioMux.js#runFfmpeg`, `server/lib/ffmpeg.js#upscaleVideo2x`, `server/lib/ffmpeg.js#optimizeForStreaming`. `videoTimeline/local.js` has a fourth variant with per-line broadcast that complicates a full migration — leave that one local. The two simpler call sites collapse to one-liners. Surfaced from /simplify on Phase 4d.
+- [ ] **Scene-level wardrobe picking (Cluster A2 follow-up).** The wardrobe data model + per-character editor shipped 2026-05-16, but downstream scene prompts don't yet know which outfit a character is wearing in a given panel/scene. Two design questions to settle first: (1) does the LLM scene-extractor guess from prose, or does the user pick per-scene? (2) does the prompt-composer append the wardrobe's description after `physicalDescription` (additive), or substitute the body fields the wardrobe overrides (less prone to outfit-and-physical contradicting each other)? Reasonable v1: per-scene `characterAppearances: [{ characterId, wardrobeId? }]` on storyboard scenes, with a wardrobe-picker dropdown next to each named character. Touch sites: `server/lib/sceneExtractor.js` (output schema + LLM prompt), `server/lib/scenePrompt.js#buildScenePrompt` (composer), `client/src/components/pipeline/stages/StoryboardsStage.jsx` (per-scene wardrobe picker chips).
+- [ ] **Extract `sanitizeListWith(raw, sanitizer, cap)` helper in `server/lib/storyBible.js`.** Three sites today walk an array calling a per-item sanitizer + capping length: `sanitizeBibleList`, `sanitizeWardrobeList`, the per-kind `cleanStringArray`. Net negative LOC after extraction. Surfaced from /simplify on the Cluster A wardrobes work.
- [ ] **Extract `useCanonPatch(universe, setUniverse, universeId, mountedRef)` if a third caller appears.** Today `UniverseCanon.jsx#handlePatchEntry` and `NounsStage.jsx#handlePatchEntry` are 95% identical (optimistic UI update + `updateUniverse` PATCH + on-success reconcile). Extract into `client/src/hooks/useCanonPatch.js` so the third caller doesn't fork the pattern. YAGNI at two call sites today. Surfaced from /simplify on the Cluster A setting-metadata work.
- [ ] **AbortSignal listener cleanup in `audioMux.js#runFfmpeg`.** Today the `signal.addEventListener('abort', kill, { once: true })` is never removed on normal completion. Only a leak if the same `AbortController` is reused across many calls — the stitch step doesn't yet pass a signal, so this is theoretical. Fix when wiring real cancellation: capture the handler ref + `signal.removeEventListener('abort', handler)` in both `close` and `error` paths. Surfaced from /simplify on Phase 4d.
- [ ] **Extract `listDirectoryByExtension(dir, { extensions, mapEntry })` helper in `server/lib/fileUtils.js`.** Three call sites today follow the same readdir + filter-by-extension + stat-per-entry shape: `server/services/loras.js#listLoras` (sidecar reads), `server/services/imageGen/local.js#listGallery` (civitai-aware fields), `server/services/pipeline/musicLibrary.js#listMusicLibrary`. Each carries domain-specific per-entry mapping, so the shared helper takes a `mapEntry(dirent, statResult) → entry|null` callback. Saves ~15 LOC at each site plus a single fix-point for future "use `readdir(withFileTypes:true)` to skip the stat when only `.isFile()` is needed" optimization. Surfaced from the /simplify pass on Phase 4c.
diff --git a/client/src/components/pipeline/CanonCard.jsx b/client/src/components/pipeline/CanonCard.jsx
index e8e2fd6c96..369fcb05b6 100644
--- a/client/src/components/pipeline/CanonCard.jsx
+++ b/client/src/components/pipeline/CanonCard.jsx
@@ -7,8 +7,8 @@
* universe, Phase A and beyond).
*/
-import { useEffect, useRef } from 'react';
-import { Loader2, ImagePlus, WandSparkles, Lock, Unlock } from 'lucide-react';
+import { useEffect, useRef, useState } from 'react';
+import { Loader2, ImagePlus, WandSparkles, Lock, Unlock, Shirt, Plus, Trash2, ChevronDown, ChevronRight } from 'lucide-react';
import useMediaJobProgress from '../../hooks/useMediaJobProgress';
import MediaJobThumb from './MediaJobThumb';
@@ -52,6 +52,159 @@ function ReadonlyChip({ children }) {
);
}
+// Wardrobes (A2) — collapsed summary by default; click to expand into an
+// inline editor when `editable`. Per-field edits are buffered in a draft
+// state and only PATCHed on blur, so a textarea keystroke doesn't fire a
+// universe-wide round-trip per character.
+function WardrobeSection({ wardrobes, editable, onChange }) {
+ const [open, setOpen] = useState(false);
+ // Per-field drafts keyed by `${idx}:${field}`. `undefined` means the
+ // textarea reflects the persisted value verbatim.
+ const [drafts, setDrafts] = useState({});
+ // Pending new rows live entirely client-side until the user types a name
+ // — committing immediately would PATCH a nameless entry, the server-side
+ // sanitizer would drop it, and the row would vanish mid-type.
+ const [pendingNew, setPendingNew] = useState([]);
+
+ const merged = pendingNew.length
+ ? [...wardrobes, ...pendingNew]
+ : wardrobes;
+
+ if (!editable && merged.length === 0) return null;
+
+ const summary = merged.map((w) => w.name).filter(Boolean).join(', ');
+ const isPending = (idx) => idx >= wardrobes.length;
+ const draftValue = (idx, field, fallback) => {
+ const key = `${idx}:${field}`;
+ return key in drafts ? drafts[key] : (fallback ?? '');
+ };
+ const setDraft = (idx, field, value) => {
+ setDrafts((prev) => ({ ...prev, [`${idx}:${field}`]: value }));
+ };
+ const commitField = (idx, field) => {
+ const key = `${idx}:${field}`;
+ if (!(key in drafts)) return;
+ const value = drafts[key];
+ setDrafts((prev) => { const next = { ...prev }; delete next[key]; return next; });
+
+ if (isPending(idx)) {
+ const pendingIdx = idx - wardrobes.length;
+ const current = pendingNew[pendingIdx] || { name: '', description: '' };
+ if ((current[field] || '') === value) return;
+ const nextPending = pendingNew.map((p, i) => i === pendingIdx ? { ...p, [field]: value } : p);
+ // Once a pending row has a non-empty name it's safe to promote into
+ // the persisted list (server sanitizer no longer drops it).
+ if (field === 'name' && value.trim()) {
+ const promoted = nextPending[pendingIdx];
+ const remaining = nextPending.filter((_, i) => i !== pendingIdx);
+ setPendingNew(remaining);
+ onChange([...wardrobes, promoted]);
+ } else {
+ setPendingNew(nextPending);
+ }
+ return;
+ }
+
+ if ((wardrobes[idx]?.[field] || '') === value) return;
+ const nextList = wardrobes.map((w, i) => (i === idx ? { ...w, [field]: value } : w));
+ onChange(nextList);
+ };
+ const removeAt = (idx) => {
+ // Selective draft pruning — keep drafts in earlier indices untouched
+ // so editing outfit 3 while deleting outfit 1 doesn't lose the
+ // outfit-3 keystrokes. Indices past the removed row shift down by 1.
+ setDrafts((prev) => {
+ const next = {};
+ for (const [k, v] of Object.entries(prev)) {
+ const sep = k.indexOf(':');
+ if (sep < 0) continue;
+ const i = Number(k.slice(0, sep));
+ const field = k.slice(sep + 1);
+ if (i < idx) next[k] = v;
+ else if (i > idx) next[`${i - 1}:${field}`] = v;
+ }
+ return next;
+ });
+ if (isPending(idx)) {
+ const pendingIdx = idx - wardrobes.length;
+ setPendingNew(pendingNew.filter((_, i) => i !== pendingIdx));
+ return;
+ }
+ onChange(wardrobes.filter((_, i) => i !== idx));
+ };
+ const addOne = () => {
+ setOpen(true);
+ setPendingNew((prev) => [...prev, { name: '', description: '' }]);
+ };
+
+ return (
+ <div className="mt-2">
+ <button
+ type="button"
+ onClick={() => setOpen((v) => !v)}
+ className="inline-flex items-center gap-1 text-[10px] uppercase tracking-wider text-gray-500 hover:text-white"
+ >
+ {open ? <ChevronDown size={10} /> : <ChevronRight size={10} />}
+ <Shirt size={10} />
+ Outfits ({merged.length}){summary && !open ? `: ${summary}` : ''}
+ </button>
+ {open ? (
+ <div className="mt-1.5 pl-3 border-l border-port-border space-y-1.5">
+ {merged.map((w, i) => (
+ <div key={w.id || i} className="space-y-1">
+ {editable ? (
+ <div className="flex items-center gap-1.5">
+ <input
+ type="text"
+ value={draftValue(i, 'name', w.name)}
+ onChange={(e) => setDraft(i, 'name', e.target.value)}
+ onBlur={() => commitField(i, 'name')}
+ placeholder="Outfit name (e.g. Wedding)"
+ className="flex-1 min-w-0 px-1.5 py-0.5 text-xs bg-port-bg border border-port-border rounded text-white"
+ maxLength={120}
+ />
+ <button
+ type="button"
+ onClick={() => removeAt(i)}
+ title={`Remove ${w.name || 'this outfit'}`}
+ className="shrink-0 text-gray-500 hover:text-port-error"
+ >
+ <Trash2 size={12} />
+ </button>
+ </div>
+ ) : (
+ <div className="text-xs text-port-accent font-medium">{w.name}</div>
+ )}
+ {editable ? (
+ <textarea
+ value={draftValue(i, 'description', w.description)}
+ onChange={(e) => setDraft(i, 'description', e.target.value)}
+ onBlur={() => commitField(i, 'description')}
+ placeholder="What's the character wearing? (image-gen-ready prose)"
+ rows={2}
+ className="w-full px-1.5 py-0.5 text-xs bg-port-bg border border-port-border rounded text-white"
+ maxLength={800}
+ />
+ ) : w.description ? (
+ <p className="text-[11px] text-gray-400 whitespace-pre-wrap">{w.description}</p>
+ ) : null}
+ </div>
+ ))}
+ {editable ? (
+ <button
+ type="button"
+ onClick={addOne}
+ className="inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded border border-port-border text-gray-400 hover:text-white hover:border-gray-500"
+ >
+ <Plus size={10} /> Add outfit
+ </button>
+ ) : null}
+ </div>
+ ) : null}
+ </div>
+ );
+}
+
export default function CanonCard({
kind, entry,
inFlightJobId,
@@ -153,6 +306,13 @@ export default function CanonCard({
{entry.timeOfDay ? <ReadonlyChip>{entry.timeOfDay}</ReadonlyChip> : null}
</div>
) : null}
+ {kind.key === 'characters' ? (
+ <WardrobeSection
+ wardrobes={Array.isArray(entry.wardrobes) ? entry.wardrobes : []}
+ editable={!!onPatchEntry && !locked}
+ onChange={(next) => onPatchEntry?.(entry.id, { wardrobes: next })}
+ />
+ ) : null}
</div>
<div className="shrink-0 flex flex-col gap-1 items-stretch">
{onToggleLock ? (
diff --git a/server/lib/storyBible.js b/server/lib/storyBible.js
index 7763626aca..95f356fee6 100644
--- a/server/lib/storyBible.js
+++ b/server/lib/storyBible.js
@@ -28,6 +28,11 @@ export const BIBLE_LIMITS = Object.freeze({
NOTES_MAX: 4000,
IMAGE_REF_MAX: 500,
IMAGE_REFS_PER_ENTRY_MAX: 12,
+ // Wardrobes per character — A2 in the AnyFilm gap analysis. Each entry
+ // is an outfit/styling variant; first one is the visual default.
+ WARDROBE_NAME_MAX: 120,
+ WARDROBE_DESCRIPTION_MAX: 800,
+ WARDROBES_PER_CHARACTER_MAX: 10,
EVIDENCE_ITEM_MAX: 500,
EVIDENCE_PER_ENTRY_MAX: 20,
// Settings
@@ -113,7 +118,7 @@ export const BIBLE_KINDS = Object.freeze(Object.values(BIBLE_KIND));
// `existing<X>Json` prompt variable (bibleExtractor) and into the script
// stage's bibles context (evaluator). Excludes ids/timestamps/source/notes.
export const PROMPT_FIELDS = Object.freeze({
- [BIBLE_KIND.CHARACTER]: ['name', 'aliases', 'role', 'physicalDescription', 'personality', 'background', 'voiceId', 'prompt', 'tags'],
+ [BIBLE_KIND.CHARACTER]: ['name', 'aliases', 'role', 'physicalDescription', 'personality', 'background', 'voiceId', 'wardrobes', 'prompt', 'tags'],
[BIBLE_KIND.SETTING]: ['name', 'slugline', 'description', 'palette', 'era', 'weather', 'intExt', 'timeOfDay', 'recurringDetails', 'prompt', 'tags'],
[BIBLE_KIND.OBJECT]: ['name', 'aliases', 'description', 'significance', 'prompt', 'tags'],
});
@@ -176,6 +181,34 @@ function ensureFirstAppearance(raw) {
return isStr(raw) && raw.trim() ? raw.trim().slice(0, 200) : null;
}
+// Wardrobe sanitizer (A2). One entry per outfit/styling variant; the
+// description is image-gen-ready prose ("worn linen suit, gold pocket watch,
+// scuffed wingtips"). Reference images per wardrobe land in a follow-up.
+function sanitizeWardrobe(raw, { preserveTimestamps = true } = {}) {
+ if (!raw || typeof raw !== 'object') return null;
+ const name = trimTo(raw.name, BIBLE_LIMITS.WARDROBE_NAME_MAX);
+ if (!name) return null;
+ return {
+ id: ensureId(raw.id, 'wd-'),
+ name,
+ description: trimTo(raw.description, BIBLE_LIMITS.WARDROBE_DESCRIPTION_MAX),
+ createdAt: preserveTimestamps && isStr(raw.createdAt) ? raw.createdAt : nowIso(),
+ updatedAt: preserveTimestamps && isStr(raw.updatedAt) ? raw.updatedAt : nowIso(),
+ };
+}
+
+function sanitizeWardrobeList(raw, opts = {}) {
+ if (!Array.isArray(raw)) return [];
+ const out = [];
+ for (const w of raw) {
+ const sanitized = sanitizeWardrobe(w, opts);
+ if (!sanitized) continue;
+ out.push(sanitized);
+ if (out.length >= BIBLE_LIMITS.WARDROBES_PER_CHARACTER_MAX) break;
+ }
+ return out;
+}
+
// Shared canon extras applied to every kind. `locked` follows the on-disk
// minimization pattern from universe-builder variations: only `true` is
// persisted, missing/false collapses to absent.
@@ -216,6 +249,10 @@ export function sanitizeCharacter(raw, { idPrefix = DEFAULT_ID_PREFIX.character,
// when configured). null = use the project default at synth time.
voiceId: trimTo(raw.voiceId, BIBLE_LIMITS.VOICE_ID_MAX) || null,
imageRefs: cleanStringArray(raw.imageRefs, BIBLE_LIMITS.IMAGE_REF_MAX, BIBLE_LIMITS.IMAGE_REFS_PER_ENTRY_MAX),
+ // Wardrobes (A2): outfit/styling variants applied on top of
+ // physicalDescription. Empty array stays the legacy shape — every
+ // existing character keeps rendering through physicalDescription alone.
+ wardrobes: sanitizeWardrobeList(raw.wardrobes, { preserveTimestamps }),
firstAppearance: ensureFirstAppearance(raw.firstAppearance),
evidence: cleanStringArray(raw.evidence, BIBLE_LIMITS.EVIDENCE_ITEM_MAX, BIBLE_LIMITS.EVIDENCE_PER_ENTRY_MAX),
missingFromProse: cleanStringArray(raw.missingFromProse, BIBLE_LIMITS.EVIDENCE_ITEM_MAX, BIBLE_LIMITS.EVIDENCE_PER_ENTRY_MAX),
@@ -315,7 +352,7 @@ const SANITIZERS = Object.freeze({
// so a later entry in the same batch resolves to the canonical record.
const MERGE_CONFIG = Object.freeze({
character: {
- userEditable: ['role', 'physicalDescription', 'personality', 'background'],
+ userEditable: ['role', 'physicalDescription', 'personality', 'background', 'wardrobes'],
keyFields: [
{ field: 'name', normalize: normalizeBibleName },
{ field: 'aliases', normalize: normalizeBibleName },
diff --git a/server/lib/storyBible.test.js b/server/lib/storyBible.test.js
index b21e2d6dd8..21d04d0b38 100644
--- a/server/lib/storyBible.test.js
+++ b/server/lib/storyBible.test.js
@@ -146,6 +146,73 @@ describe('storyBible — sanitizeCharacter', () => {
expect(o.prompt).toBe('striped tape coil');
expect(o.source).toBe('manual');
});
+
+ describe('wardrobes (Cluster A)', () => {
+ it('defaults to an empty array when omitted', () => {
+ const out = sanitizeCharacter({ name: 'A' });
+ expect(out.wardrobes).toEqual([]);
+ });
+
+ it('sanitizes well-formed wardrobe entries + assigns ids', () => {
+ const out = sanitizeCharacter({
+ name: 'Don Carlos',
+ wardrobes: [
+ { name: 'Wedding', description: 'cream silk suit, gold pocket watch' },
+ { name: 'Backalley', description: 'worn leather jacket, scuffed boots' },
+ ],
+ });
+ expect(out.wardrobes).toHaveLength(2);
+ expect(out.wardrobes[0].name).toBe('Wedding');
+ expect(out.wardrobes[0].description).toBe('cream silk suit, gold pocket watch');
+ expect(out.wardrobes[0].id).toMatch(/^wd-/);
+ expect(out.wardrobes[0].id).not.toBe(out.wardrobes[1].id);
+ });
+
+ it('preserves caller-supplied ids (round-trip after a PATCH)', () => {
+ const out = sanitizeCharacter({
+ name: 'Aria',
+ wardrobes: [{ id: 'wd-fixed-1', name: 'Tactical' }],
+ });
+ expect(out.wardrobes[0].id).toBe('wd-fixed-1');
+ });
+
+ it('drops entries with no name (the only required field)', () => {
+ const out = sanitizeCharacter({
+ name: 'Aria',
+ wardrobes: [
+ { description: 'no name on this one' },
+ { name: 'Real Wardrobe', description: 'has a name' },
+ ],
+ });
+ expect(out.wardrobes).toHaveLength(1);
+ expect(out.wardrobes[0].name).toBe('Real Wardrobe');
+ });
+
+ it('caps the list at BIBLE_LIMITS.WARDROBES_PER_CHARACTER_MAX', () => {
+ const tooMany = Array.from({ length: BIBLE_LIMITS.WARDROBES_PER_CHARACTER_MAX + 5 }, (_, i) => ({
+ name: `Outfit ${i}`,
+ }));
+ const out = sanitizeCharacter({ name: 'A', wardrobes: tooMany });
+ expect(out.wardrobes).toHaveLength(BIBLE_LIMITS.WARDROBES_PER_CHARACTER_MAX);
+ });
+
+ it('caps individual field lengths', () => {
+ const out = sanitizeCharacter({
+ name: 'A',
+ wardrobes: [{
+ name: 'n'.repeat(BIBLE_LIMITS.WARDROBE_NAME_MAX + 100),
+ description: 'd'.repeat(BIBLE_LIMITS.WARDROBE_DESCRIPTION_MAX + 100),
+ }],
+ });
+ expect(out.wardrobes[0].name.length).toBe(BIBLE_LIMITS.WARDROBE_NAME_MAX);
+ expect(out.wardrobes[0].description.length).toBe(BIBLE_LIMITS.WARDROBE_DESCRIPTION_MAX);
+ });
+
+ it('coerces a non-array wardrobes field to an empty array', () => {
+ const out = sanitizeCharacter({ name: 'A', wardrobes: 'not an array' });
+ expect(out.wardrobes).toEqual([]);
+ });
+ });
});
describe('storyBible — sanitizeSetting', () => {
diff --git a/server/lib/validation.js b/server/lib/validation.js
index d0b041df77..a07f0ab16f 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -3,6 +3,7 @@ import { ServerError } from './errorHandler.js';
import { ASPECT_RATIOS, QUALITIES, PROJECT_STATUSES, SCENE_STATUSES } from './creativeDirectorPresets.js';
import { WORK_KINDS, WORK_STATUSES, ANALYSIS_KINDS } from './writersRoomPresets.js';
import { ALL_STYLE_IDS, STYLE_ID } from './writersRoomStylePresets.js';
+import { BIBLE_LIMITS } from './storyBible.js';
// gpt-image-2 (codex backend) caps at 3840px per edge and 8,294,400 total
// pixels. Mirror the ceiling for every image-gen route. Local mflux can
@@ -631,6 +632,16 @@ const wrCharTextField = z.string().max(2000);
// `engine:voiceName` (e.g. `kokoro:af_heart`). Nullable so a UI clear path
// can null it explicitly.
const wrVoiceIdField = z.string().trim().max(200).nullable();
+// Wardrobe array (A2). `id` is omitted on POSTs by the UI — the sanitizer
+// fills it from the server-side UUID factory. Limits sourced from
+// BIBLE_LIMITS so bumping the constant updates Zod automatically.
+const wrWardrobeField = z.array(z.object({
+ id: z.string().trim().max(64).optional(),
+ name: z.string().trim().min(1).max(BIBLE_LIMITS.WARDROBE_NAME_MAX),
+ description: z.string().max(BIBLE_LIMITS.WARDROBE_DESCRIPTION_MAX).optional(),
+ createdAt: z.string().optional(),
+ updatedAt: z.string().optional(),
+}).strict()).max(BIBLE_LIMITS.WARDROBES_PER_CHARACTER_MAX);
export const writersRoomCharacterCreateSchema = z.object({
name: z.string().trim().min(1).max(200),
aliases: z.array(z.string().trim().min(1).max(200)).max(20).optional(),
@@ -640,6 +651,7 @@ export const writersRoomCharacterCreateSchema = z.object({
background: wrCharTextField.optional(),
notes: wrCharTextField.optional(),
voiceId: wrVoiceIdField.optional(),
+ wardrobes: wrWardrobeField.optional(),
}).strict();
export const writersRoomCharacterUpdateSchema = z.object({
name: z.string().trim().min(1).max(200).optional(),
@@ -650,6 +662,7 @@ export const writersRoomCharacterUpdateSchema = z.object({
background: wrCharTextField.optional(),
notes: wrCharTextField.optional(),
voiceId: wrVoiceIdField.optional(),
+ wardrobes: wrWardrobeField.optional(),
}).strict();
const wrSettingTextField = z.string().max(2000);