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
scope each local authoring batch to its own scenes and storyboard shots
[._.]/ Adam Eivyc3db6efa4139
diff --git a/server/services/musicVideo/codeGeneration.js b/server/services/musicVideo/codeGeneration.jsindex e41fd82be7..cc99e9a068 100644--- a/server/services/musicVideo/codeGeneration.js+++ b/server/services/musicVideo/codeGeneration.js@@ -34,12 +34,23 @@ export async function styleLinesFor(project) {}}-/** The approved procedural direction's definitions and rules, for a code-authoring request. */-export const castAndSetsCodeContext = (project) => [- productionFeedbackContext(project),- musicVideoCodeDirectionContext(approvedCastAndSetsDirection(project)),- project.productionReview?.draft && `HUMAN-REVIEWED VISUAL/MOTION GUIDE AND SHOT CHOREOGRAPHY:\n${JSON.stringify(project.productionReview.draft)}`,-].filter(Boolean).join('\n\n');+/**+ * The approved procedural direction's definitions and rules, for a code-authoring request.+ * `sceneIds` scopes the guide's shot choreography to the scenes a batch authors: every+ * shot of a long storyboard otherwise rides in each section's prompt.+ */+export const castAndSetsCodeContext = (project, { sceneIds = null } = {}) => {+ const draft = project.productionReview?.draft;+ const wanted = sceneIds ? new Set(sceneIds) : null;+ const guide = draft && wanted && Array.isArray(draft.storyboard)+ ? { ...draft, storyboard: draft.storyboard.filter((shot) => wanted.has(shot.sceneId)) }+ : draft;+ return [+ productionFeedbackContext(project),+ musicVideoCodeDirectionContext(approvedCastAndSetsDirection(project)),+ guide && `HUMAN-REVIEWED VISUAL/MOTION GUIDE AND SHOT CHOREOGRAPHY:\n${JSON.stringify(guide)}`,+ ].filter(Boolean).join('\n\n');+};function acceptSources(parsed, ids) {const wanted = new Set(ids);diff --git a/server/services/musicVideo/documentGeneration.js b/server/services/musicVideo/documentGeneration.jsindex b573305e2d..bba79dff8f 100644--- a/server/services/musicVideo/documentGeneration.js+++ b/server/services/musicVideo/documentGeneration.js@@ -204,6 +204,12 @@ async function authoringContext(project) {// provider authors sections in bounded batches instead of one whole-song request.export const LOCAL_PROMPT_BUDGET_CHARS = 100_000;+// The scenes overlapping any of `sections` (all of them when every section is listed).+export function batchScenes(scenes, sections) {+ return (scenes || []).filter((scene) => !Number.isFinite(scene.startSec) || !Number.isFinite(scene.endSec)+ || sections.some((section) => scene.startSec < section.endSec && scene.endSec > section.startSec));+}+const isLocalProvider = (provider) => isOllamaBackedProvider(provider) || isLocalInstanceEndpoint(provider?.endpoint);// Greedily pack consecutive section ids into batches whose prompt stays within budget.@@ -283,12 +289,18 @@ async function runAuthoring(projectId, { providerId, model, effort, sectionId =styleLines: [...await styleLinesFor(project), ...styleGrammarLines(project)],...(project.composition?.styleGrammarId ? { styleGrammarId: project.composition.styleGrammarId } : {}),};- const promptFor = (batchIds) => buildMixedMediaDocumentPrompt({- renderer: musicVideoDocumentRenderer(project), mediaMode: musicVideoMediaMode(project),- title: project.name, song: { ...context.song, sections: context.song.sections.filter((section) => batchIds.includes(section.id)) }, palette: context.palette, treatment: project.treatment,- visualSpec: project.visualSpec, scenes: context.scenes, styleLines: sharedStyle.styleLines,- onlySectionId: sectionId, sharedStyle, directionContext: castAndSetsCodeContext(project),- });+ const promptFor = (batchIds) => {+ const sections = context.song.sections.filter((section) => batchIds.includes(section.id));+ // Only the scenes (and storyboard shots) a batch's sections cover: a long storyboard would+ // otherwise put every shot in each batch and push it past a local model's budget.+ const scenes = batchScenes(context.scenes, sections);+ return buildMixedMediaDocumentPrompt({+ renderer: musicVideoDocumentRenderer(project), mediaMode: musicVideoMediaMode(project),+ title: project.name, song: { ...context.song, sections }, palette: context.palette, treatment: project.treatment,+ visualSpec: project.visualSpec, scenes, styleLines: sharedStyle.styleLines,+ onlySectionId: sectionId, sharedStyle, directionContext: castAndSetsCodeContext(project, { sceneIds: scenes.map((scene) => scene.sceneId) }),+ });+ };const withFeedback = (prompt) => (feedback ? `${prompt}\n\nReview findings for this section (retain the approved medium and selected assets; never invent a footage fallback):\n${feedback.slice(0, 8000)}` : prompt);const guardedBeforeSubmit = async (submission) => {const current = await getProject(projectId);diff --git a/server/services/musicVideo/documentGeneration.test.js b/server/services/musicVideo/documentGeneration.test.jsindex 32ce43bf3e..829e54a86e 100644--- a/server/services/musicVideo/documentGeneration.test.js+++ b/server/services/musicVideo/documentGeneration.test.js@@ -110,6 +110,28 @@ describe('treatment-driven mixed-media document authoring', () => {.rejects.toMatchObject({ code: 'COMPOSITION_PROMPT_TOO_LARGE', message: expect.stringMatching(/\d+ characters/) });});+ it('scopes each local batch to the scenes and storyboard shots its sections cover', async () => {+ const id = await fixture();+ await projects.mutateProjectRecord(id, (current) => ({ project: { ...current, productionReview: { ...current.productionReview, draft: {+ ...(current.productionReview?.draft || {}),+ storyboard: ['s-intro', 's-still', 's-clip'].map((sceneId) => ({ sceneId, lyricCueIds: [], action: `choreography for ${sceneId}`, staging: '', camera: '', transition: '' })),+ } } } }));+ h.provider = { id: 'ollama', type: 'api' };+ const prompts = [];+ h.onSubmit = async () => { prompts.push(h.prompt); };+ await generateMixedMediaDocument(id, { providerId: 'ollama' });+ const whole = prompts[0];+ expect(whole).toContain('choreography for s-clip');++ prompts.length = 0;+ // A budget that only fits one section per request.+ await generateMixedMediaDocument(id, { providerId: 'ollama', promptBudgetChars: whole.length - 200 });+ const intro = prompts.find((prompt) => prompt.includes('"id":"intro"'));+ expect(intro).toContain('choreography for s-intro');+ expect(intro).not.toContain('choreography for s-clip');+ expect(intro).not.toContain('"sceneId":"s-clip"');+ });+it('names the prompt size when authoring times out with no output (#10515)', async () => {const id = await fixture();h.onSubmit = async () => { throw new Error('API execution timed out after 600000ms with no stream progress'); };