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

1.6 KB
Raw Blame
import { basename } from 'node:path';
import { resolveGalleryImage } from '../../lib/pathSafety.js';
import { promptAddition } from '../../lib/modelInput.js';
import { musicVideoStyleImages, musicVideoStylePrompt, musicVideoStyleReferenceCapacity } from '../../lib/musicVideoConditioning.js';

/** Resolve style capacity on the actual route, preserving every explicit identity input. */
export async function withMusicVideoStyle(project, params, mode, model, settings) {
  if (!project?.styleReferences?.length) return params;
  let localModel = null;
  if (mode === 'local') {
    const [{ selectLocalImageModelFromSettings }, { getImageModels }] = await Promise.all([
      import('../imageGen/prepareParams.js'), import('../../lib/mediaModels.js'),
    ]);
    localModel = selectLocalImageModelFromSettings(settings, model, getImageModels());
  }
  const identities = params.referenceImagePaths || [];
  const capacity = musicVideoStyleReferenceCapacity(mode, localModel);
  const styles = musicVideoStyleImages(project, identities.map((p) => basename(p)), capacity)
    .map((id) => resolveGalleryImage(id, { mustExist: false })).filter((p) => p && !identities.includes(p));
  const look = musicVideoStylePrompt(project, styles.length);
  return {
    ...params,
    prompt: [params.prompt, look].filter(Boolean).join('. '),
    promptAdditions: [...(params.promptAdditions || []), promptAddition('mood-board-style', 'Mood board style', look)].filter(Boolean),
    ...(styles.length ? {
      referenceImagePaths: [...identities, ...styles],
      referenceImageStrengths: [...(params.referenceImageStrengths || identities.map(() => 1)), ...styles.map(() => 1)],
    } : {}),
  };
}