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
Autopilot clips use the run's own video tool and production runs take each shot's song window (#11119)
[._.]/02d6c224a475
diff --git a/server/services/musicVideo/autonomousService.js b/server/services/musicVideo/autonomousService.jsindex e96cc79e19..04dbdadeba 100644--- a/server/services/musicVideo/autonomousService.js+++ b/server/services/musicVideo/autonomousService.js@@ -92,6 +92,7 @@ import { withBackupAssetPublication } from '../../lib/backupSnapshotBoundary.js'import { getProject, mutateProjectRecord } from './projects.js';import { musicVideoEvents } from './events.js';import { musicVideoDependencyChanges } from '../../lib/musicVideoDependencies.js';+import { isPerformanceScene, performanceCapability } from '../../lib/musicVideoShotTiming.js';const PROCESS_ID = `proc-${randomUUID()}`;const inflight = new Map();@@ -147,6 +148,12 @@ const defaults = {reviseFromFeedback: async (...args) => (await import('./productionReviewService.js')).reviseProductionFromFeedback(...args),guideImagePath: async (artifact) => (await import('./devArtifactStore.js')).resolveDevArtifactFile(artifact.file),// A gallery image (a Cast & Sets plate, a production still) the orchestrator looks at.+ // Can this local video model take a shot's song window (an LTX a2v model)?+ localVideoTakesSongAudio: async (modelId) => {+ const [{ resolveVideoModelSelection }, { supportsSourceAudioWindow }] = await Promise.all([+ import('../videoGen/modelSelection.js'), import('../federatedMedia/sourceAudio.js')]);+ return supportsSourceAudioWindow((await resolveVideoModelSelection(modelId || undefined)).model);+ },galleryImagePath: async (filename) => (await import('../../lib/pathSafety.js')).resolveGalleryImage(filename),finalReviewFrames: async (jobId) => (await import('./orchestratorReview.js')).captureFinalReviewFrames(jobId),// The overlay text pass before a final render: resolves the finished check.@@ -1428,6 +1435,19 @@ const emptyStages = () => Object.fromEntries(AUTONOMOUS_STAGE_IDS.map((id) => [i* yet) and begins the pipeline in the background. Returns `{ project, run }`.*//** The production pool a brief allows on this project. */+/**+ * The project video settings the run's own video tool implies, so the plan and+ * production agree on what can render: its backend and local model, and Supplied+ * song audio when that local model takes a shot's song window. With no video tool+ * it is local video, which plans no lip-sync shots.+ */+async function briefVideoSettings(tools, models) {+ const route = autonomousPool(tools, models).find((entry) => entry.kind === 'video');+ if (!route || route.mode !== 'local') return { backend: route?.mode || 'local', generationMode: 'image' };+ const songAudio = await deps.localVideoTakesSongAudio(route.model).catch(() => false);+ return { backend: 'local', modelId: route.model || null, generationMode: songAudio ? 'suppliedAudio' : 'image' };+}+const briefProductionPool = (brief, project) => autonomousPool(brief.tools, brief.models).filter((route) => musicVideoAllowsMedia(project, route.kind));@@ -1481,6 +1501,7 @@ export async function startAutonomousVideo(input, { autoApproveAuthorized = falsname: brief.name || trimTo(brief.prompt.replace(/\s+/g, ' '), 60) || 'Autonomous music video',mode: 'autonomous',mediaMode: brief.mediaMode,+ videoSettings: await briefVideoSettings(brief.tools, brief.models),...(brief.mediaMode !== 'code-images-video' ? { productionPolicy: { strategy: 'code-first', maxGeneratedVideoPercent: 0 } } : {}),// ...as does its production policy (a project with none is legacy), so a footage project stays one,// also when the request names a mode that allows footage; a code-only or stills mode keeps no footage.@@ -1658,10 +1679,15 @@ export async function resumeAutonomousVideo(projectId, edits = {}, { autoApprove};});if (retakenTrackId) await unlinkRunTrack(projectId, out.run.id, retakenTrackId);- // The project's brief tools gate what production may submit (a video tool for clips), so they follow too.- if (toolsPatch) {+ // The project's brief tools gate what production may submit (a video tool for clips), so they follow+ // too, as do its video settings. Performance shots no route can lip-sync play as cutaways.+ if (toolsPatch || modelsPatch) {+ const video = await briefVideoSettings(tools, modelsPatch || run.brief.models || {});+ const lipSync = !!performanceCapability(video.backend);await mutateProjectRecord(projectId, (current) => ({ project: { ...current,- automation: { ...current.automation, tools: [...new Set([...(current.automation?.tools || []), ...added])] } } }));+ ...(toolsPatch ? { automation: { ...current.automation, tools: [...new Set([...(current.automation?.tools || []), ...added])] } } : {}),+ videoSettings: { ...current.videoSettings, ...video },+ ...(lipSync ? {} : { scenes: (current.scenes || []).map((scene) => (isPerformanceScene(scene) ? { ...scene, shotMode: 'cutaway' } : scene)) }) } }));}const { resume } = produceContinuation(out.run);if (resume.kind === 'final-revision') {diff --git a/server/services/musicVideo/autonomousService.test.js b/server/services/musicVideo/autonomousService.test.jsindex 312eaa02ec..bfead2a1f5 100644--- a/server/services/musicVideo/autonomousService.test.js+++ b/server/services/musicVideo/autonomousService.test.js@@ -70,6 +70,7 @@ beforeEach(() => {store.clear();calls = [];doubles = {+ localVideoTakesSongAudio: vi.fn(async () => false),createProject: stub('createProject', async (input) => {const project = { id: 'mv-auto', productionReview: { proof: { basis: 'test-proof', excerptId: 'test-proof' } }, excerpts: [{ id: 'test-proof', status: 'complete', filename: 'test-proof.mp4' }], ...input };store.set(project.id, clone(project));@@ -642,6 +643,17 @@ describe('starting on an existing project\'s song (fromProjectId)', () => {expect(codeOnly.productionPolicy).toMatchObject({ strategy: 'code-first', maxGeneratedVideoPercent: 0 });});+ // Uniquely catches the install's video pin (fal, say) planning lip-sync shots the run's own video tool cannot render.+ it('sets the project\'s video settings from the run\'s own video tool', async () => {+ doubles.localVideoTakesSongAudio.mockResolvedValue(true);+ const { project } = await service.startAutonomousVideo({ prompt: 'p', fromProjectId: 'mv-src', tools: ['image:local', 'video:local'], models: { 'video:local': 'example-ltx' } });+ expect(project.videoSettings).toEqual({ backend: 'local', modelId: 'example-ltx', generationMode: 'suppliedAudio' });+ expect(doubles.localVideoTakesSongAudio).toHaveBeenCalledWith('example-ltx');+ store.delete('mv-auto');+ const { project: stills } = await service.startAutonomousVideo({ prompt: 'p', fromProjectId: 'mv-src', tools: ['image:local'] });+ expect(stills.videoSettings).toEqual({ backend: 'local', generationMode: 'image' });+ });+// Uniquely catches a reused song re-running lyrics/Suno/analysis or the new project inheriting the source's look.it('copies only the song, writes no lyrics, makes no song, skips analysis, and leaves the source untouched', async () => {const { project, run } = await service.startAutonomousVideo({ prompt: 'skatepark at golden hour', fromProjectId: 'mv-src', checkpoints: ['lyrics', 'song', 'style'] });@@ -1466,10 +1478,15 @@ describe('orchestrated mode (brief.orchestrator)', () => {expect(reviews().filter((r) => r.startsWith('stills'))).toEqual(['stills:revise', 'stills:approve']);expect(runOf()).toMatchObject({ status: 'awaiting-approval', awaiting: 'stills' });store.get('mv-auto').productionRuns = [{ id: 'mvpr-1', status: 'awaiting-video', createdAt: new Date().toISOString() }];+ store.get('mv-auto').scenes[0].shotMode = 'performance';doubles.resumeProduction.mockClear();+ doubles.localVideoTakesSongAudio.mockResolvedValue(true);await service.resumeAutonomousVideo('mv-auto', { addTools: ['video:local'] });expect(runOf().brief).toMatchObject({ tools: ['image:local', 'video:local'], stopBeforeVideo: false });expect(store.get('mv-auto').automation.tools).toEqual(['image:local', 'video:local']);+ // The added local video tool sets the project's renderer, and a performance shot it cannot lip-sync plays as a cutaway.+ expect(store.get('mv-auto').videoSettings).toMatchObject({ backend: 'local', generationMode: 'suppliedAudio' });+ expect(store.get('mv-auto').scenes[0].shotMode).toBe('cutaway');expect(doubles.resumeProduction).toHaveBeenCalledWith('mv-auto', 'mvpr-1', expect.objectContaining({pool: expect.arrayContaining([expect.objectContaining({ kind: 'video', mode: 'local' })]) }));expect(doubles.resumeProduction.mock.calls[0][2].stopBefore).toBeUndefined();diff --git a/server/services/musicVideo/production.js b/server/services/musicVideo/production.jsindex ef8922ab91..78240810e1 100644--- a/server/services/musicVideo/production.js+++ b/server/services/musicVideo/production.js@@ -177,6 +177,8 @@ export function normalizeProductionPool(pool, { allowEmpty = false } = {}) {for (const entry of Array.isArray(pool) ? pool : []) {if (!entry || (entry.kind !== 'image' && entry.kind !== 'video') || !isNonBlankStr(entry.mode)) continue;const route = { kind: entry.kind, mode: entry.mode.trim(), model: isNonBlankStr(entry.model) ? entry.model.trim() : null };+ // A local video route may carry each shot's song window (Supplied song audio).+ if (route.kind === 'video' && route.mode === 'local' && entry.audio === 'supplied') route.audio = 'supplied';if (seen.has(routeKey(route))) continue;seen.add(routeKey(route));out.push(route);diff --git a/server/services/musicVideo/productionDispatch.js b/server/services/musicVideo/productionDispatch.jsindex 349c7cbd21..21e8a71a6b 100644--- a/server/services/musicVideo/productionDispatch.js+++ b/server/services/musicVideo/productionDispatch.js@@ -115,7 +115,8 @@ async function dispatchClip({ project, scene, route, tag }) {const isGrok = route.mode === 'grok';const prompt = [base, isGrok ? approximateMotionCues(project.phrases, scene.startSec, scene.endSec) : ''].filter(Boolean).join('. ');const byBackend = {- local: { modelId: route.model, disableAudio: true },+ // A supplied-audio route animates the frame from its shot's own song window.+ local: route.audio === 'supplied' ? { modelId: route.model, mode: 'a2v', _suppliedAudio: true } : { modelId: route.model, disableAudio: true },grok: { grokDuration: spanSec != null ? grokCoverage(spanSec).requestSec : (project.videoSettings?.grokDuration || 10), disableAudio: true },fal: falClipParams(project, scene, route),reactor: { disableAudio: true },diff --git a/server/services/musicVideo/productionDispatch.test.js b/server/services/musicVideo/productionDispatch.test.jsindex f702c2262c..1da73a104e 100644--- a/server/services/musicVideo/productionDispatch.test.js+++ b/server/services/musicVideo/productionDispatch.test.js@@ -129,6 +129,14 @@ describe('production scene dispatch (#9066)', () => {}), {});});+ // Uniquely catches a supplied-audio route rendering prompt motion instead of its shot's song window.+ it('submits a supplied-audio local clip as audio-to-video from its song window', async () => {+ const clipTag = { ...tag, productionStepKey: 'clip:mvs-a:base:1' };+ await dispatchProductionStep({ stepKind: 'clip', project, scene, route: { kind: 'video', mode: 'local', model: 'example-ltx', audio: 'supplied' }, tag: clipTag, settings });+ expect(submitVideoGenJob.mock.calls[0][0]).toMatchObject({ backend: 'local', mode: 'a2v', _suppliedAudio: true, modelId: 'example-ltx', sourceImageFile: 'frame-example.png' });+ expect(submitVideoGenJob.mock.calls[0][0].disableAudio).toBeUndefined();+ });+it('submits a fal clip as exactly the take the step was priced for (falSceneTake)', async () => {const clipTag = { ...tag, productionStepKey: 'clip:mvs-a:base:1' };const falProject = { ...project, videoSettings: { backend: 'fal', falModelId: 'fal-ai/veo3.1/fast/image-to-video', falResolution: '1080p' } };diff --git a/server/services/musicVideo/productionService.js b/server/services/musicVideo/productionService.jsindex dd508fa55a..0865284ef3 100644--- a/server/services/musicVideo/productionService.js+++ b/server/services/musicVideo/productionService.js@@ -633,6 +633,19 @@ async function cancelOwnedJobs(runId, { includeRunning = false, jobIds = null }// ---- director actions -----------------------------------------------------------+/**+ * A project rendering clips from Supplied song audio binds that into the run's+ * own video routes, so each clip takes its shot's song window and a later+ * settings change cannot alter a running grant. It needs local video.+ */+function bindSuppliedAudio(pool, project) {+ if (project.videoSettings?.generationMode !== 'suppliedAudio') return pool;+ if (pool.some((route) => route.kind === 'video' && route.mode !== 'local')) {+ throw new ServerError('Supplied song audio needs Local video; remove the other video routes or use Prompt motion', { status: 409, code: 'MUSIC_VIDEO_RENDER_POOL_UNAVAILABLE' });+ }+ return pool.map((route) => (route.kind === 'video' ? { ...route, audio: 'supplied' } : route));+}+/*** Start a run (explicit director request). Every pool route must be eligible* now. Returns `{ project, run }`; the run advances in the background.@@ -642,12 +655,9 @@ export async function startProduction(projectId, { directive, pool: requested, lif (project.videoSettings?.renderPool && project.videoSettings.renderPool.mode !== 'local') {throw new ServerError('Production runs require This Mac until immutable run pools support peer placement', { status: 409, code: 'MUSIC_VIDEO_RENDER_POOL_UNAVAILABLE' });}- if (project.videoSettings?.generationMode === 'suppliedAudio') {- throw new ServerError('Production runs do not yet bind supplied-audio windows in their immutable pool; use Prompt motion', { status: 409, code: 'MUSIC_VIDEO_RENDER_POOL_UNAVAILABLE' });- }const assets = codeFirstProductionAssets(project);const authoring = assets ? await deps.resolveAuthoring(requestedAuthoring) : null;- const pool = normalizeProductionPool(requested, { allowEmpty: !!assets });+ const pool = bindSuppliedAudio(normalizeProductionPool(requested, { allowEmpty: !!assets }), project);await assertPoolEligible(pool, await deps.loadEnv());// The autopilot cuts on the song (#9290) unless the director chose how it// cuts — set before the run captures its creative-setup basis.@@ -670,7 +680,7 @@ export async function resumeProduction(projectId, runId, { limits, acceptBasis =const before = await requireProject(projectId);const prior = findProductionRun(before, runId);const priorReviewId = prior.reviewRunId;- const pool = requested ? normalizeProductionPool(requested, { allowEmpty: !!prior.authoring }) : null;+ const pool = requested ? bindSuppliedAudio(normalizeProductionPool(requested, { allowEmpty: !!prior.authoring }), before) : null;if (pool) await assertPoolEligible(pool, await deps.loadEnv());const jobs = await liveJobs();await mutateProjectRecord(projectId, (current) => reconcileProductionSteps(current, runId, jobs));diff --git a/server/services/musicVideo/productionService.test.js b/server/services/musicVideo/productionService.test.jsindex bbfed2cf4f..2244a36077 100644--- a/server/services/musicVideo/productionService.test.js+++ b/server/services/musicVideo/productionService.test.js@@ -217,11 +217,14 @@ describe('music video production run (#9066)', () => {expect(current().productionRuns).toBeUndefined();});- it('refuses unbound supplied-audio windows before starting or spending a production budget', async () => {+ // Uniquely catches a Supplied song audio project refused by production, or its clips losing the song window.+ it('binds supplied song audio into the run\'s local video routes, and refuses it with a remote video route', async () => {seedProject({ videoSettings: { generationMode: 'suppliedAudio', renderPool: { mode: 'local', peers: [] } } });- await expect(start()).rejects.toMatchObject({ code: 'MUSIC_VIDEO_RENDER_POOL_UNAVAILABLE' });- expect(dispatch).not.toHaveBeenCalled();+ await expect(start({ pool: [...POOL, { kind: 'video', mode: 'fal' }] })).rejects.toMatchObject({ code: 'MUSIC_VIDEO_RENDER_POOL_UNAVAILABLE' });expect(current().productionRuns).toBeUndefined();+ await start();+ expect(theRun().pool.filter((route) => route.kind === 'video').every((route) => route.audio === 'supplied')).toBe(true);+ expect(theRun().pool.filter((route) => route.kind === 'image').some((route) => 'audio' in route)).toBe(false);});it('produces a reviewed draft from one Start: frames, then clips, then the continuous-excerpt review', async () => {diff --git a/server/services/musicVideo/renderPool.js b/server/services/musicVideo/renderPool.jsindex 11951c925f..ad85c00259 100644--- a/server/services/musicVideo/renderPool.js+++ b/server/services/musicVideo/renderPool.js@@ -15,8 +15,9 @@ export async function applyProjectRenderPool(body) {|| body.lastImageFile || body.keyframes?.length || body.chunks > 1)) {refuse('Supplied song audio does not support continuation, end frames, keyframes or chained clips');}- if (body.musicVideo.productionRunId && project?.videoSettings?.generationMode === 'suppliedAudio') {- refuse('Production runs do not yet bind supplied-audio windows in their immutable pool; use Prompt motion');+ // A production run's own routes decide: a supplied-audio route sends `_suppliedAudio` itself.+ if (body.musicVideo.productionRunId && project?.videoSettings?.generationMode === 'suppliedAudio' && !body._suppliedAudio) {+ refuse('This production run was started with Prompt motion; start a new run to use Supplied song audio');}// Existing projects retain their renderer pins until a pool is saved.if (!pool || pool.mode === 'local') {diff --git a/server/services/musicVideo/renderPool.test.js b/server/services/musicVideo/renderPool.test.jsindex 3019515846..8c6c0ae227 100644--- a/server/services/musicVideo/renderPool.test.js+++ b/server/services/musicVideo/renderPool.test.js@@ -88,6 +88,14 @@ describe('project render-pool submission policy', () => {expect(m.resolve).not.toHaveBeenCalled();expect(await applyProjectRenderPool(body())).toMatchObject({ mode: 'a2v', backend: 'local' });});+ // Uniquely catches a production clip losing its bound song window, or a prompt-motion run silently switching mode.+ it('lets a production run\'s supplied-audio route through and refuses a prompt-motion run after the switch', async () => {+ m.project.videoSettings.generationMode = 'suppliedAudio';+ m.project.videoSettings.renderPool.mode = 'local';+ const production = { ...body(), musicVideo: { ...body().musicVideo, productionRunId: 'run' } };+ expect(await applyProjectRenderPool({ ...production, mode: 'a2v', _suppliedAudio: true })).toMatchObject({ mode: 'a2v', backend: 'local', _suppliedAudio: true });+ await expect(applyProjectRenderPool(production)).rejects.toThrow(/Prompt motion/);+ });it('keeps node selections machine-local on outbound and inbound project sync', () => {const pool = m.project.videoSettings.renderPool;expect(stripMusicVideoLocalRenderPins(m.project, { stripVideoBackend: false }).videoSettings.renderPool).toBeUndefined();