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
Keep catalog-linked cast and places as fixed casting in Cast & Sets (#11926)
[._.]/b1dc75c020cd
diff --git a/server/services/musicVideo/castAndSetsDirection.js b/server/services/musicVideo/castAndSetsDirection.jsindex 0daebd8ef1..cd27831b9b 100644--- a/server/services/musicVideo/castAndSetsDirection.js+++ b/server/services/musicVideo/castAndSetsDirection.js@@ -35,6 +35,7 @@ import { z } from 'zod';import { ServerError } from '../../lib/errorHandler.js';import { extractJson } from '../../lib/jsonExtract.js';import { musicVideoCreativeContext, musicVideoSongStyleContext, withoutPeople } from '../../lib/musicVideoCreativeContext.js';+import { isOutsideMusicVideoReference } from '../../lib/musicVideoConditioning.js';import { musicVideoBriefTools as briefTools } from '../../lib/musicVideoMediumPlan.js';import { trimTo } from '../../lib/textUtils.js';import { CAST_SETS_DEFINITION_LIMITS, normalizeDefinitions } from './castAndSetsDefinitions.js';@@ -143,6 +144,39 @@ export function moodBoardImageList(board, resolveItem) {return out;}+export const CAST_SETS_SUBJECT_PREFIX = 'cs-';++/**+ * Catalog-linked cast and places the director chose in Creative setup: fixed+ * casting the check-in keeps instead of redesigning. Each carries the image+ * the Look step pulled for it (a reference labelled with its name), which+ * conditions its sheet or plate. Cast & Sets' own earlier subjects are left+ * out, so a regenerate can still redesign them.+ */+export function fixedCasting(project) {+ const refs = project?.visualSpec?.references || [];+ return (project?.concept?.subjects || [])+ .filter((s) => s?.ingredientId && s.name && (s.kind === 'character' || s.kind === 'place')+ && !String(s.id || '').startsWith(CAST_SETS_SUBJECT_PREFIX))+ .map((s) => {+ const role = s.kind === 'place' ? 'set' : 'character';+ const name = s.name.trim().toLowerCase();+ const ref = refs.find((r) => r?.imageId && r.role === role && String(r.label || '').trim().toLowerCase() === name+ && !isOutsideMusicVideoReference(r));+ return { kind: s.kind, name: s.name.trim(), role: s.role || null, description: s.description || '', imageId: ref?.imageId || null };+ });+}++function fixedCastingBlock(project) {+ const fixed = fixedCasting(project);+ if (!fixed.length) return '';+ return [+ 'FIXED CASTING (catalog records the director chose; keep them):',+ ...fixed.map((f) => `- ${f.kind}${f.role === 'protagonist' ? ' (protagonist)' : ''}: ${trimTo(f.name, 120)}${f.description ? ` — ${trimTo(f.description, 500)}` : ''}`),+ 'Use each one as given: the same name, and its description for face, hair and wardrobe, or for the empty location. A character marked protagonist is the protagonist unless a character style above fixes it; other characters go in "cast"; places become sets. Design only what this list leaves missing.',+ ].join('\n');+}+const OUTPUT_SHAPE = `{"logline": "<one or two sentences: who, where, what happens>","interpretation": "<how the song's references and themes shape this world>",@@ -310,6 +344,7 @@ export function buildCastAndSetsPrompt(project, { moodImages = [], board = null,header,facts,characterStyle,+ fixedCastingBlock(project),songStyle,`Lyrics (section headers and delivery directions in brackets):\n${lyrics || '(instrumental — no lyrics)'}`,sectionLines.length ? `Song sections (index. label start–end):\n${sectionLines.join('\n')}` : 'The song has not been sectioned.',diff --git a/server/services/musicVideo/castAndSetsPlan.js b/server/services/musicVideo/castAndSetsPlan.jsindex 8f1c9bae51..c554abd237 100644--- a/server/services/musicVideo/castAndSetsPlan.js+++ b/server/services/musicVideo/castAndSetsPlan.js@@ -29,7 +29,7 @@ import { trimTo } from '../../lib/textUtils.js';import { isOutsideMusicVideoReference } from '../../lib/musicVideoConditioning.js';// A sentence naming a person or the protagonist puts someone in an empty plate.import { withoutPeople } from '../../lib/musicVideoCreativeContext.js';-import { songSections } from './castAndSetsDirection.js';+import { CAST_SETS_SUBJECT_PREFIX, fixedCasting, songSections } from './castAndSetsDirection.js';export const CAST_SETS_IMAGE_SIZE = Object.freeze({ width: 1536, height: 1024 });// Mirrors MUSIC_VIDEO_MAX_CONDITIONING_REFERENCES / the visual spec's list cap.@@ -37,7 +37,7 @@ const MAX_CONDITIONING = 4;const MAX_REFERENCES = 24;const MAX_SUBJECTS = 24;export const CAST_SETS_REF_PREFIX = 'mvr-cs-';-export const CAST_SETS_SUBJECT_PREFIX = 'cs-';+export { CAST_SETS_SUBJECT_PREFIX };// Only the medium is fixed; the look (film stock, light, texture) comes from// the project's own mood board / style via `direction.look`.@@ -138,7 +138,8 @@ function buildProceduralImagePlan(direction, { revisionNotes = {} } = {}) {* Build the full image plan for a direction: `{ [key]: { key, kind, label,* prompt, deps, refKeys, refImages?, setId?, testIndex? } }`. `refKeys` name* other plan keys whose image is passed as a reference (in order), then- * `refImages` (the director's character identity images) follow: only the+ * `refImages` (the director's character identity images, or a linked catalog+ * record's image) follow: only the* project's own images, never mood board images. A revision note for a key is* appended to its prompt.*/@@ -150,7 +151,14 @@ export function buildCastAndSetsImagePlan(project, direction, { revisionNotes =const style = trimTo(direction.look, 500) || trimTo(project?.concept?.style, 500);const firstLight = direction.sets?.[0]?.lighting || '';const note = (key) => (revisionNotes[key] ? `Revision: ${revisionNotes[key]}` : '');- const identities = identityImages(project);+ // A linked catalog record's image conditions the sheet or plate of the+ // protagonist, cast member or set the direction kept it as (by name).+ const fixed = fixedCasting(project).filter((f) => f.imageId);+ const fixedImage = (kind, name) => {+ const key = String(name || '').trim().toLowerCase();+ return fixed.find((f) => f.kind === kind && f.name.toLowerCase() === key)?.imageId || null;+ };+ const identities = [...new Set([fixedImage('character', p.name), ...identityImages(project)].filter(Boolean))].slice(0, MAX_CONDITIONING);const plan = {};plan.character = {@@ -216,6 +224,7 @@ export function buildCastAndSetsImagePlan(project, direction, { revisionNotes =// the same five views as the protagonist's, so shots naming them keep them.for (const c of direction.cast || []) {const key = `cast:${c.id}`;+ const castImage = fixedImage('character', c.name);plan[key] = {key,kind: 'cast',@@ -223,8 +232,10 @@ export function buildCastAndSetsImagePlan(project, direction, { revisionNotes =castId: c.id,deps: [],refKeys: [],+ ...(castImage ? { refImages: [castImage] } : {}),prompt: join(`Photographic character reference sheet of ONE consistent person, ${c.name}${c.role ? `, the ${c.role}` : ''}: ${c.description || ''}`,+ castImage && 'The SAME person as the reference image: keep their face, hair and build exactly',identity(c),c.wardrobe && `Wearing ${c.wardrobe}`,p.name && `A different person from ${p.name}`,@@ -240,6 +251,7 @@ export function buildCastAndSetsImagePlan(project, direction, { revisionNotes =for (const set of direction.sets || []) {const key = `set:${set.id}`;const plateLight = withoutPeople(set.lighting, p.name);+ const placeImage = fixedImage('place', set.name);plan[key] = {key,kind: 'plate',@@ -247,8 +259,10 @@ export function buildCastAndSetsImagePlan(project, direction, { revisionNotes =setId: set.id,deps: [],refKeys: [],+ ...(placeImage ? { refImages: [placeImage] } : {}),prompt: join('Empty set plate, no people',+ placeImage && 'The same location as the reference image',withoutPeople(set.description, p.name) || set.name,plateLight && `Lighting: ${plateLight}`,plateStyle && `Look: ${plateStyle}`,diff --git a/server/services/musicVideo/castAndSetsService.test.js b/server/services/musicVideo/castAndSetsService.test.jsindex ca11a68475..245e5db2f2 100644--- a/server/services/musicVideo/castAndSetsService.test.js+++ b/server/services/musicVideo/castAndSetsService.test.js@@ -910,6 +910,40 @@ it('conditions the character, expressions and looks sheets on the director\'s owexpect(refs('set:lab')).toBeUndefined();});+it('keeps catalog-linked cast and places as fixed casting, conditioned on their images', async () => {+ runPrompt.mockResolvedValue({ text: JSON.stringify({ ...DIRECTION, cast: [{ id: 'mate', name: 'Mate', role: 'deckhand', description: 'young', face: 'freckles', hair: 'red', wardrobe: 'peacoat' }] }) });+ const project = await seed({+ concept: { prompt: 'a vigil', subjects: [+ { id: 'mvc-1', kind: 'character', name: 'Keeper', role: 'protagonist', description: 'grey braid', ingredientId: 'cat-chr-1' },+ { id: 'mvc-2', kind: 'character', name: 'Mate', role: 'supporting', ingredientId: 'cat-chr-2' },+ { id: 'mvc-3', kind: 'place', name: 'Harbor', description: 'stone quay', ingredientId: 'cat-plc-1' },+ { id: 'mvc-4', kind: 'place', name: 'Cliff' },+ ] },+ visualSpec: { references: [+ { id: 'mvr-pull-1', imageId: 'keeper.png', role: 'character', label: 'Keeper', condition: false },+ { id: 'mvr-pull-2', imageId: 'mate.png', role: 'character', label: 'Mate', condition: false },+ { id: 'mvr-pull-3', imageId: 'harbor.png', role: 'set', label: 'Harbor', condition: false },+ { id: 'mvr-pull-4', imageId: 'cliff.png', role: 'set', label: 'Cliff', condition: false },+ ] },+ });+ await service.startCastAndSets(project.id);+ await runTo(project.id, 'review');+ const prompt = runPrompt.mock.calls[0][0].prompt;+ expect(prompt).toContain('FIXED CASTING');+ expect(prompt).toContain('- character (protagonist): Keeper — grey braid');+ expect(prompt).toContain('- place: Harbor — stone quay');+ expect(prompt).not.toContain('- place: Cliff');+ const job = (key) => jobs.findLast((j) => keyOf(j) === key);+ const refs = (key) => job(key).params.referenceImagePaths?.map((p) => p.split(/[\\/]/).pop());+ expect(refs('character')).toEqual(['keeper.png']);+ expect(refs('cast:mate')).toEqual(['mate.png']);+ expect(job('cast:mate').params.prompt).toContain('SAME person as the reference image');+ expect(refs('set:harbor')).toEqual(['harbor.png']);+ expect(job('set:harbor').params.prompt).toContain('The same location as the reference image');+ // An unlinked place is designed fresh.+ expect(refs('set:roof')).toBeUndefined();+});+it('keeps people out of set plates: no mood board person in the look, no character action in a set', async () => {const personBoard = { ...board, style: { prompt: 'An adult woman with tousled curls sits alone beside a rain-speckled window. Amber haze.' } };service.__setCastAndSetsDepsForTests(testDeps({ loadBoard: async () => personBoard }));