The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
feat(create): Studio-Rollen, Presets und Prompt-Ideen aus dem Web portiert (P2)
purple773a72711070
diff --git a/src/lib/render/__tests__/create-studio.test.ts b/src/lib/render/__tests__/create-studio.test.tsnew file mode 100644index 00000000..c71f27f1--- /dev/null+++ b/src/lib/render/__tests__/create-studio.test.ts@@ -0,0 +1,103 @@+// Der Create-Tab und das Preset-Fenster bieten dieselben Modelle an.+//+// 19.09.2026, Entscheid von David: die neuen Endpunkte sollen auch in den+// Unterkategorien von Create waehlbar sein. Bis dahin kannte der normale+// Composer den Studio-Pfad ueberhaupt nicht, und die Unterkategorien zeigten+// eine eigene, aeltere Liste. Der Fall unten haelt beide Seiten zusammen.+//+// Desktop port (P2): 'video_upscale' ist im Web eine eigene Absicht, getrennt+// von 'upscale' (Bild-Upscale). Der Desktop kennt bislang nur ein einziges+// 'upscale' fuer Bild UND Video (aelterer Utility-Op-Pfad in createStore.ts,+// P5's Datei). StudioIntent in create-studio.ts ist der lokale Behelf dafuer;+// siehe die Notiz dort und den Bericht fuer P9.+import { describe, expect, it } from 'vitest'+import {+ intentPickerModels, intentRequiredInputs, intentRoleFor, intentRoles,+ isStudioModel, resolveIntentPick, createStudioCost, type StudioIntent,+} from '../create-studio'+import { STUDIO_MODELS } from '../studio-contract'+import { opPickerModels } from '../../../stores/cloudCatalogStore'+import type { CreateIntent } from '../../../stores/createStore'++const MIT_ROLLE: StudioIntent[] = ['lipsync', 'music', 'extend', 'motion', 'video_upscale']++describe('die Unterkategorien von Create fahren dieselben Modelle wie die Presets', () => {+ it('jede Unterkategorie mit einer Rolle hat eine Auswahl, und jedes Mitglied steht einmal drin', () => {+ for (const intent of MIT_ROLLE) {+ const list = intentPickerModels(intent)+ expect(list.length, intent).toBeGreaterThan(1)+ expect(new Set(list.map((m) => m.id)).size, intent).toBe(list.length)+ }+ })++ it('nimmt keiner Unterkategorie ein Modell weg, das sie vorher schon hatte', () => {+ // Die Regression, die beim Umbau am leichtesten passiert: die Rolle+ // ersetzt die alte Liste, statt sie zu erweitern.+ for (const [intent, op] of [['lipsync', 'lipsync'], ['music', 'music'], ['extend', 'extend'], ['motion', 'motion']] as const) {+ const jetzt = intentPickerModels(intent).map((m) => m.id)+ for (const alt of opPickerModels(op)) {+ // Ein klassischer Eintrag darf durch seinen Studio-Zwilling ersetzt+ // sein: dann faehrt derselbe Endpunkt, nur ueber die Registrierung.+ const zwilling = Object.entries(STUDIO_MODELS).find(([, m]) => m.sourceModel === alt.id)?.[0]+ expect(jetzt.includes(alt.id) || (!!zwilling && jetzt.includes(zwilling)), `${intent}/${alt.id}`).toBe(true)+ }+ }+ })++ it('bringt die neuen Endpunkte wirklich in ihre Unterkategorie', () => {+ const hat = (intent: StudioIntent, id: string) => intentPickerModels(intent).some((m) => m.id === id)+ for (const id of ['longcat-avatar', 'lipsync-3-avatar', 'seedance-2.5-avatar', 'heygen-twin']) {+ expect(hat('lipsync', id), id).toBe(true)+ }+ for (const id of ['minimax-music', 'mureka-song', 'eleven-music']) expect(hat('music', id), id).toBe(true)+ for (const id of ['wan-3.0-extend', 'seedance-2.5-extend', 'preset-wan-2.2-spicy-extend']) {+ expect(hat('extend', id), id).toBe(true)+ }+ expect(hat('motion', 'wan-2.2-animate-2')).toBe(true)+ for (const id of ['flashvsr', 'crystal-upscaler', 'video-upscaler-pro']) {+ expect(hat('video_upscale', id), id).toBe(true)+ }+ })++ it('laesst Enhance Video auf dem Endpunkt starten, auf dem es bisher lief', () => {+ // Ohne Auswahl lief diese Unterkategorie fest auf wavespeed-ai/video-upscaler.+ // Wer nichts waehlt, bekommt weiterhin genau den.+ expect(intentPickerModels('video_upscale')[0].id).toBe('video-upscaler')+ expect(resolveIntentPick('video_upscale', '')).toBe('video-upscaler')+ expect(STUDIO_MODELS['video-upscaler'].endpoint).toBe('wavespeed-ai/video-upscaler')+ })++ it('haelt eine gueltige Wahl fest und faengt eine fremde ab', () => {+ expect(resolveIntentPick('music', 'mureka-song')).toBe('mureka-song')+ // Eine Wahl aus einer anderen Unterkategorie darf nicht ueberleben.+ expect(resolveIntentPick('music', 'flashvsr')).toBe(intentPickerModels('music')[0].id)+ // Eine Absicht ohne Rolle laesst die Wahl unberuehrt.+ expect(resolveIntentPick('image', 'chroma')).toBe('chroma')+ })++ it('kennt zu jedem Mitglied die Rolle, die Eingaben und einen Preis groesser null', () => {+ for (const intent of MIT_ROLLE) {+ for (const m of intentPickerModels(intent)) {+ if (!isStudioModel(m.id)) continue+ expect(intentRoleFor(intent, m.id), `${intent}/${m.id}`).toBeTruthy()+ expect(intentRequiredInputs(intent, m.id), `${intent}/${m.id}`).toBeDefined()+ expect(createStudioCost(m.id, {}), `${intent}/${m.id}`).toBeGreaterThan(0)+ }+ }+ })++ it('verlangt vom Presenter kein eigenes Foto, von den anderen schon', () => {+ // Genau die Unterscheidung, an der der Startknopf haengt.+ expect(intentRequiredInputs('lipsync', 'heygen-twin')).toEqual(['audio_path'])+ for (const id of ['longcat-avatar', 'seedance-2.5-avatar', 'lipsync-3-avatar']) {+ expect(intentRequiredInputs('lipsync', id).sort(), id).toEqual(['audio_path', 'source_path'])+ }+ })++ it('gibt keiner Absicht ohne Rolle eine Auswahl', () => {+ for (const intent of ['image', 'video', 'animate', 'edit', 'character', 'upscale'] as CreateIntent[]) {+ expect(intentRoles(intent), intent).toEqual([])+ expect(intentPickerModels(intent), intent).toEqual([])+ }+ })+})diff --git a/src/lib/render/__tests__/preset-models.test.ts b/src/lib/render/__tests__/preset-models.test.tsnew file mode 100644index 00000000..d603a37f--- /dev/null+++ b/src/lib/render/__tests__/preset-models.test.ts@@ -0,0 +1,175 @@+// Ein Modell, das in einem Preset-Schritt auswaehlbar ist, muss diesen Schritt+// auch wirklich rechnen koennen.+//+// 19.09.2026, Entscheid von David: der Kunde waehlt im Preset selbst, welches+// Modell den Schritt faehrt. Damit ist jede Liste hier ein Versprechen. Der+// Fall unten loest es ein: fuer jedes Mitglied gibt es einen Preis auf beiden+// Seiten und einen Op, den die Submit-Route annimmt.+//+// Desktop port (P2): zwei Web-Faelle sind gestrichen, nicht angepasst.+// "Der Worker hat fuer jedes Mitglied eine Route" liest+// services/render-worker/src/providers/wavespeed.ts, eine Serverdatei, die es+// im Desktop-Checkout gar nicht gibt (Portplan Abschnitt 2.3: Worker NICHT+// portiert). "jedes Mitglied hat einen Preis, und der klassische ist der der+// Route" vergleicht gegen creditCost aus app/api/jobs/route.ts, ebenfalls+// Server, ebenfalls nicht im Desktop. Die verbleibenden Faelle pruefen die+// Vertraege, die der Desktop wirklich hat: die Rollenlisten und den Preis aus+// der lebenden cloudCatalogStore-Bruecke (classicCredits).+//+// Zwei weitere Faelle sind gegenueber dem Web angepasst statt uebernommen:+// der Notvorrat CLOUD_MODEL_SEED fuehrt fuer mehrere klassische Videomodelle+// bewusst noch keinen Preis (katalog-paritaet-web.test.ts nennt das+// "Altbestand"; erst die lebende Katalogantwort liefert ihn). Ein Test, der+// hier "hat immer einen Preis" verlangt, wuerde eine Vollstaendigkeit+// behaupten, die die Testumgebung ohne Netz gar nicht hat.+import { describe, expect, it } from 'vitest'+import {+ ALL_ROLES, classicCredits, presetModels, requiredRoleInputs, roleForModel,+ roleHasChoice, roleInputs,+} from '../preset-models'+import { CREATE_PRESETS } from '../create-presets'+import { STUDIO_MODELS } from '../studio-contract'+import { cloudModelById, cloudModelSupportsOp, useCloudCatalogStore } from '../../../stores/cloudCatalogStore'+import { videoDurations } from '../video-duration'++// Die Ops, die die Submit-Route pro Art annimmt. Spiegel von SUPPORTED_OPS in+// app/api/jobs/route.ts (Server): was dort fehlt, wird vor dem Abbuchen+// abgelehnt.+const SUPPORTED_OPS: Record<string, readonly string[]> = {+ image: ['studio', 'generate', 'edit', 'removebg', 'eraser', 'upscale', 'lora-train'],+ video: ['studio', 'generate', 'animate', 'upscale', 'lipsync', 'extend', 'motion', 'lora-train'],+ audio: ['studio', 'music', 'tts'],+}++describe('jedes waehlbare Modell faehrt seinen Schritt', () => {+ it('jede Rolle hat Mitglieder, und jedes Mitglied steht genau einmal drin', () => {+ for (const role of ALL_ROLES) {+ const list = presetModels(role)+ expect(list.length, role).toBeGreaterThan(0)+ expect(new Set(list.map((m) => m.id)).size, role).toBe(list.length)+ }+ })++ it('kein Endpunkt steht zweimal in derselben Rolle', () => {+ for (const role of ALL_ROLES) {+ // Ein Studio-Eintrag verdraengt seinen klassischen Zwilling. Stuende+ // beides drin, waehlte der Kunde zweimal dasselbe unter einem Namen.+ const twins = presetModels(role)+ .map((m) => STUDIO_MODELS[m.id]?.sourceModel ?? m.id)+ expect(new Set(twins).size, role).toBe(twins.length)+ }+ })++ it('die Submit-Route nimmt den Op jedes Mitglieds an', () => {+ for (const role of ALL_ROLES) {+ for (const m of presetModels(role)) {+ expect(SUPPORTED_OPS[m.kind], `${role}/${m.id}`).toContain(m.op)+ if (m.op !== 'studio') {+ const catalog = cloudModelById(m.id)+ expect(catalog, `${role}/${m.id}`).toBeDefined()+ expect(cloudModelSupportsOp(catalog!, m.op), `${role}/${m.id}`).toBe(true)+ }+ }+ }+ })++ it('jedes klassische Mitglied hat entweder einen Preis, oder der Notvorrat fuehrt wirklich keinen', () => {+ for (const role of ALL_ROLES) {+ for (const m of presetModels(role)) {+ if (STUDIO_MODELS[m.id] || m.op === 'studio') continue+ const seconds = m.kind === 'video' ? (videoDurations(m.id)[0] ?? 5) : undefined+ const params = m.kind === 'video' && role === 'animate'+ ? { frames: seconds! * 16, fps: 16 }+ : {}+ const ours = classicCredits(m.kind, m.id, m.op, params)+ if (ours === null) {+ // Kein Wiring-Fehler: dieses Mitglied traegt im Notvorrat wirklich+ // kein `credits`-Feld, erst die lebende Katalogantwort liefert es.+ expect(cloudModelById(m.id)?.credits, `${role}/${m.id}`).toBeUndefined()+ } else {+ expect(ours, `${role}/${m.id}`).toBeGreaterThan(0)+ }+ }+ }+ })++ it('eine laengere Sekunde kostet mehr, wenn der Katalog eine lange Rate fuehrt', () => {+ // Positivkontrolle fuer die Abbildung frames/fps auf runCredits: nimmt sie+ // die Dauer nicht an, bleibt der Preis gleich und der Fall faellt um. Der+ // Notvorrat fuehrt heute bei keinem klassischen Videomodell eine+ // gesonderte Langrate (nur `base`), deshalb steht hier ein synthetischer+ // Katalogeintrag statt eines echten Notvorrat-Modells, das den Fall gar+ // nicht ausloesen wuerde.+ const before = useCloudCatalogStore.getState().models+ useCloudCatalogStore.setState({+ models: [+ ...before,+ { id: 'p2-test-scaling-clip', label: 'Test scaling clip', kind: 'video', t2v: true, i2v: true, credits: { base: 1000, long: 3000 } },+ ],+ })+ try {+ const kurz = classicCredits('video', 'p2-test-scaling-clip', 'generate', { frames: 5 * 16, fps: 16 })+ const lang = classicCredits('video', 'p2-test-scaling-clip', 'generate', { frames: 8 * 16, fps: 16 })+ expect(kurz).not.toBeNull()+ expect(lang).not.toBeNull()+ expect(lang ?? 0).toBeGreaterThan(kurz ?? 0)+ } finally {+ useCloudCatalogStore.setState({ models: before })+ }+ })++ it('jedes Studio-Modell gehoert zu genau einer Rolle', () => {+ for (const id of Object.keys(STUDIO_MODELS)) {+ const roles = ALL_ROLES.filter((r) => presetModels(r).some((m) => m.id === id))+ expect(roles, id).toHaveLength(1)+ expect(roleForModel(id), id).toBe(roles[0])+ }+ })++ it('eine Eingrenzung nennt nur Mitglieder der eigenen Rolle, und nie eine leere Liste', () => {+ // Ein Schritt darf seine Auswahl verkleinern, aber nicht erfinden: stuende+ // dort eine Id, die die Rolle nicht kennt, zeigte das Fenster eine leere+ // Auswahl und der Schritt waere nicht mehr zu starten.+ const eingegrenzt = CREATE_PRESETS.flatMap((p) => p.steps).filter((s) => s.models)+ expect(eingegrenzt.length).toBeGreaterThan(0)+ for (const step of eingegrenzt) {+ const rolle = presetModels(step.role).map((m) => m.id)+ expect(step.models!.length, step.title).toBeGreaterThan(0)+ for (const id of step.models!) expect(rolle, `${step.title}/${id}`).toContain(id)+ expect(step.models, step.title).toContain(step.model)+ }+ })++ it('eine Eingrenzung in einem freigegebenen Preset nennt nur offene Modelle', () => {+ // 19.09.2026: die Horrorschritte grenzen ein. Stuende dort ein gefilterter+ // Endpunkt, lehnte er die Szene ab und der Kunde haette trotzdem gezahlt.+ for (const preset of CREATE_PRESETS.filter((p) => p.adult)) {+ for (const step of preset.steps.filter((s) => s.models)) {+ const offen = presetModels(step.role, true).map((m) => m.id)+ for (const id of step.models!) expect(offen, `${preset.id}/${id}`).toContain(id)+ }+ }+ })++ it('jeder Preset-Schritt startet auf einem Modell seiner eigenen Rolle', () => {+ for (const preset of CREATE_PRESETS) {+ for (const step of preset.steps) {+ expect(presetModels(step.role).map((m) => m.id), `${preset.id}/${step.title}`).toContain(step.model)+ }+ }+ })++ it('die noetigen Eingaben eines Mitglieds sind eine Teilmenge dessen, was es liest', () => {+ for (const role of ALL_ROLES) {+ for (const m of presetModels(role)) {+ const reads = new Set(Object.values(roleInputs(role, m.id)))+ for (const key of requiredRoleInputs(role, m.id)) expect(reads, `${role}/${m.id}`).toContain(key)+ }+ }+ })++ it('genau die Rollen ohne Alternative zeigen keine Auswahl', () => {+ const ohne = ALL_ROLES.filter((r) => !roleHasChoice(r))+ expect(ohne.sort()).toEqual(['angles', 'presenter', 'restyle'])+ })+})diff --git a/src/lib/render/__tests__/prompt-ideas.test.ts b/src/lib/render/__tests__/prompt-ideas.test.tsnew file mode 100644index 00000000..0fe61ac8--- /dev/null+++ b/src/lib/render/__tests__/prompt-ideas.test.ts@@ -0,0 +1,77 @@+// Die Vorgaben sind eine Lehre, kein Zierrat.+//+// 19.09.2026, zwei Befunde von David an einem Tag: ein Satz auf einem+// Tag-Modell brachte das Haus statt der Figur, und eine Stimmung auf einem+// Videomodell brachte einen Vogel, der stillsteht. Also muss an den Vorgaben+// ABLESBAR sein, was in einen Prompt gehoert: das Wort fotorealistisch beim+// Bild, und eine Bewegung beim Video.+import { describe, expect, it } from 'vitest'+import { createIdeas, promptIdeas } from '../prompt-ideas'+import { CREATE_PRESETS } from '../create-presets'++describe('Prompt-Vorgaben', () => {+ it('sagt bei jedem Bild-Set, dass fotorealistisch in den Prompt gehoert', () => {+ for (const kategorie of ['Horror', 'Character', 'Product'] as const) {+ const ideen = promptIdeas('image', kategorie)+ expect(ideen.length, kategorie).toBe(10)+ const mitWort = ideen.filter((i) => /photorealistic/.test(i.text))+ // Nicht jede einzelne: eine bewusst als Schwarzweissfilm. Aber die+ // grosse Mehrheit, damit das Wort als Muster erkennbar ist.+ expect(mitWort.length, kategorie).toBeGreaterThanOrEqual(9)+ }+ })++ it('beschreibt bei Bewegung, was sich bewegt, und nicht nur die Kamera', () => {+ const ideen = promptIdeas('animate', 'Horror')+ expect(ideen).toHaveLength(10)+ const motiv = ideen.filter((i) => /the subject/.test(i.text))+ expect(motiv.length).toBeGreaterThanOrEqual(5)+ // Und keine davon verkauft eine Stimmung als Bewegung.+ for (const i of ideen) expect(i.text, i.label).not.toMatch(/\b(mood|feels|stressed|happy|sad)\b/)+ })++ it('gibt jedem Schritt mit einem Szenenfeld Anfaenge, und den anderen keine', () => {+ for (const preset of CREATE_PRESETS) {+ for (const step of preset.steps) {+ const ideen = promptIdeas(step.role, preset.category)+ const brauchtWelche = ['image', 'animate', 'extend', 'soundtrack', 'edit'].includes(step.role)+ expect(ideen.length > 0, `${preset.id}/${step.title}`).toBe(brauchtWelche)+ }+ }+ })++ it('bietet im Create-Fenster genau das an, was die Absicht braucht', () => {+ expect(createIdeas('video').map((g) => g.label)).toEqual(['Movement'])+ expect(createIdeas('animate').map((g) => g.label)).toEqual(['Movement'])+ expect(createIdeas('music').map((g) => g.label)).toEqual(['Sound'])+ expect(createIdeas('image').map((g) => g.label)).toEqual(['Horror', 'Character', 'Product', 'Video'])+ // Wo ein Prompt keine Szene beschreibt, steht auch keine Liste.+ for (const intent of ['lipsync', 'motion', 'character', 'removebg']) {+ expect(createIdeas(intent), intent).toEqual([])+ }+ })++ it('jede Vorgabe traegt eine kurze Beschriftung und einen brauchbaren Text', () => {+ const alle = [...createIdeas('image'), ...createIdeas('video'), ...createIdeas('music')].flatMap((g) => g.ideas)+ expect(alle.length).toBeGreaterThan(40)+ for (const i of alle) {+ // Die Beschriftung muss in eine schmale Liste passen.+ expect(i.label.length, i.label).toBeLessThanOrEqual(22)+ expect(i.text.length, i.label).toBeGreaterThan(30)+ }+ })++ it('kein Eintrag einer Liste traegt denselben Namen wie ein anderer darin', () => {+ // In EINER Liste muss der Name eindeutig sein, sonst laege beim Klick der+ // falsche Text im Feld. Ueber getrennte Listen hinweg darf er sich+ // wiederholen: sie stehen nie zusammen auf dem Schirm.+ for (const intent of ['image', 'video', 'music']) {+ const namen = createIdeas(intent).flatMap((g) => g.ideas.map((i) => `${g.label}/${i.label}`))+ expect(new Set(namen).size, intent).toBe(namen.length)+ }+ for (const kategorie of ['Horror', 'Character', 'Product', 'Video']) {+ const namen = promptIdeas('image', kategorie).map((i) => i.label)+ expect(new Set(namen).size, kategorie).toBe(namen.length)+ }+ })+})diff --git a/src/lib/render/create-presets.ts b/src/lib/render/create-presets.tsnew file mode 100644index 00000000..727dfccb--- /dev/null+++ b/src/lib/render/create-presets.ts@@ -0,0 +1,56 @@+import { STUDIO_MODELS, studioBaseCredits } from './studio-contract'+import { runCredits } from '../../stores/cloudCatalogStore'+import { type PresetOp, type StepRole } from './preset-models'+import type { RenderKind } from './cloud-jobs'+// `role` is what the step DOES. The model named here is the preset's+// suggestion; the role decides which other models the customer may pick+// instead. See lib/render/preset-models.ts.+// `models` grenzt die Auswahl dieses Schrittes auf eine Teilmenge seiner Rolle+// ein. 19.09.2026, Entscheid von David: bei Horror passen Prefect Pony und+// Neta Lumina nicht, auch wenn sie offen sind. Die Rolle bleibt, was sie ist;+// der Schritt sagt, welche ihrer Mitglieder er wirklich verantworten kann.+export interface PresetStep { model: string; kind: RenderKind; op: PresetOp; title: string; role: StepRole; models?: string[] }+export interface CreatePreset { id: string; title: string; summary: string; category: 'Character'|'Horror'|'Product'|'Video'|'Audio'; adult: boolean; accent: string; steps: PresetStep[]; note?: string }+const image = (model:string,models?:string[]): PresetStep => ({model:'preset-'+model,kind:'image',op:'studio',title:'Create the image',role:'image',...(models?{models}:{})})+const animate = (model:string): PresetStep => ({model:'preset-'+model,kind:'video',op:'studio',title:'Bring it to life',role:'animate'})+const studio = (model:string,title:string,role:StepRole): PresetStep => ({model,kind:STUDIO_MODELS[model].kind,op:'studio',title,role})+// Die Bildmodelle, die eine Horrorszene wirklich tragen. Geprueft am+// 19.09.2026 an einem identischen Prompt mit gleichem Seed ueber alle offenen+// Bildmodelle des Katalogs: Prefect Pony und Neta Lumina liefern Illustration+// statt Szene und stehen hier deshalb nicht, obwohl sie offen sind. Die vier+// neuen stellen die Szene fotorealistisch und weichen sie nicht auf; FLUX SRPO+// lehnte denselben Prompt ab, Anima liefert Stilbild statt Foto.+const HORROR_IMAGE = ['preset-chroma', 'z-image', 'nucleus-image', 'jib-mix-qwen', 'wan-2.2-realism']+export const CREATE_PRESETS: CreatePreset[] = [+ {id:'spicy-character',title:'Spicy Character Clip',summary:'Create a character, animate the scene, then add sound.',category:'Character',adult:true,accent:'rose',steps:[image('prefect-pony'),animate('wan-2.2-spicy'),studio('mmaudio-v2','Add a soundtrack','soundtrack')]},+ {id:'horror-creature',title:'Horror Creature',summary:'From creature concept to a cinematic clip with native audio.',category:'Horror',adult:true,accent:'emerald',steps:[image('chroma',HORROR_IMAGE),studio('open-video','Animate with native audio','animate')]},+ {id:'horror-negative',title:'Horror • More Control',summary:'Shape the atmosphere and exclude unwanted details with a negative prompt.',category:'Horror',adult:true,accent:'emerald',steps:[image('chroma',HORROR_IMAGE),animate('wan-2.7-spicy')]},+ {id:'spicy-anime',title:'Spicy Anime',summary:'Illustrate an anime scene, add motion and finish with sound.',category:'Character',adult:true,accent:'rose',steps:[image('neta-lumina'),animate('wan-2.2-spicy'),studio('mmaudio-v2','Add a soundtrack','soundtrack')]},+ {id:'your-character',title:'Your Character • OpenVideo',summary:'Animate a character reference with native audio and style controls.',category:'Character',adult:true,accent:'rose',steps:[studio('open-video-lora','Animate your reference','animate')],note:'OpenVideo accepts curated style LoRAs. It does not accept your trained Character Studio weights. Use an image of your character as the reference.'},+ {id:'long-spicy-cut',title:'Long Spicy Cut',summary:'Continue a clip from your gallery into the next scene.',category:'Video',adult:true,accent:'rose',steps:[{model:'preset-wan-2.2-spicy-extend',kind:'video',op:'studio',title:'Continue your clip',role:'extend'}]},+ {id:'talking-avatar',title:'Talking Avatar',summary:'Write the words, create a voice and bring your portrait to life.',category:'Character',adult:false,accent:'violet',steps:[{model:'preset-qwen3-tts',kind:'audio',op:'studio',title:'Create the voice',role:'speech'},studio('infinitetalk','Animate the speaker','talking')]},+ {id:'two-speakers',title:'Two-Character Dialogue',summary:'One image, two voices. Choose who speaks first.',category:'Character',adult:false,accent:'violet',steps:[studio('infinitetalk-multi','Direct the conversation','duo')]},+ {id:'product-360',title:'Product 360° Views',summary:'Explore your product from new camera angles.',category:'Product',adult:false,accent:'amber',steps:[studio('qwen-image-angles','Choose the camera angle','angles')],note:'Each run creates one still image from the selected angle, not a rotating video.'},+ {id:'product-scene',title:'Product in a Scene',summary:'Keep your product. Reimagine the setting.',category:'Product',adult:false,accent:'amber',steps:[studio('minimax-h3-edit','Set the scene','edit')]},+ {id:'animate-character',title:'Animate a Character',summary:'Transfer movement from a reference video to your character.',category:'Character',adult:false,accent:'violet',steps:[studio('scail-2','Transfer the movement','motion')]},+ {id:'restyle-video',title:'Restyle a Video',summary:'Give an existing clip a completely different visual style.',category:'Video',adult:false,accent:'sky',steps:[studio('wan-ditto','Choose your style','restyle')]},+ {id:'sharpen-4k',title:'Sharpen to 4K',summary:'Make a finished clip sharp. Up to 4K, or 8K on Crystal.',category:'Video',adult:false,accent:'sky',steps:[studio('flashvsr','Sharpen your clip','upscale')]},+ {id:'song-from-words',title:'Song from Words',summary:'Describe a song and get a finished track with vocals.',category:'Audio',adult:false,accent:'violet',steps:[studio('minimax-music','Write the song','music')]},+ {id:'presenter-script',title:'Presenter Reads Your Script',summary:'Write the words. A presenter says them on camera.',category:'Character',adult:false,accent:'violet',steps:[{model:'preset-qwen3-tts',kind:'audio',op:'studio',title:'Create the voice',role:'speech'},studio('heygen-twin','Pick your presenter','presenter')]},+]+// Desktop port (P2): the web sums this from its own price table+// (mediaCredits(s.kind, s.model, 5, s.op)), which the desktop does not have.+// Here a non-studio step prices from the live catalog via runCredits, the+// same reasoning as classicCredits in preset-models.ts. `null` for the whole+// preset when ANY step has no catalog price: a partial total would read as a+// real quote when it is not one.+export function presetBaseCredits(preset: CreatePreset): number | null {+ let total = 0+ for (const s of preset.steps) {+ if (s.op === 'studio') { total += studioBaseCredits(s.model); continue }+ const priced = runCredits(s.kind, s.op, s.model, 5, Number.NaN)+ if (!Number.isFinite(priced)) return null+ total += priced+ }+ return total+}diff --git a/src/lib/render/create-studio.ts b/src/lib/render/create-studio.tsnew file mode 100644index 00000000..5ad0984b--- /dev/null+++ b/src/lib/render/create-studio.ts@@ -0,0 +1,133 @@+// Die Bruecke zwischen dem Create-Tab und der Studio-Registrierung.+//+// 19.09.2026, Entscheid von David: die neuen Endpunkte sollen nicht nur in den+// Presets waehlbar sein, sondern auch in den Unterkategorien von Create. Bis+// heute war der Studio-Pfad ausschliesslich im Preset-Fenster zu Hause, und+// keine der Unterkategorien konnte ein Studio-Modell fahren.+//+// Statt eine zweite Liste zu pflegen, bekommt jede spezialisierte Absicht die+// Rolle, die sie ohnehin schon meint. Damit sind Preset-Fenster und Create-Tab+// per Bauart dieselbe Menge, und der Vertragstest in preset-models.test.ts+// deckt beide Oberflaechen ab.++import type { CreateIntent } from '../../stores/createStore'+import { STUDIO_MODELS, studioBaseCredits, studioPreviewCredits } from './studio-contract'+import { presetModels, requiredRoleInputs, roleInputs, type PresetModel, type StepRole } from './preset-models'+import { opPickerModels } from '../../stores/cloudCatalogStore'++// Desktop port (P2): the web's CreateIntent already carries 'video_upscale'+// as a distinct intent from the plain 'upscale' (image upscale). The+// desktop's CreateIntent (in stores/createStore.ts, P5's file) has a single+// 'upscale' that serves BOTH image and video upscale today via the older+// utility-op path; splitting it into its own value is a store/Composer+// decision (P5/P7), not this package's. StudioIntent stands in locally so+// tsc stays green without touching createStore.ts. P9: once P5/P7 decide how+// video upscale reaches the Composer (new CloudOp, or a kind check on+// 'upscale'), fold this back into CreateIntent and drop the shim below.+export type StudioIntent = CreateIntent | 'video_upscale'++/** Die Rolle, die eine Create-Unterkategorie faehrt. Absichten ohne Eintrag+ * (Bild, Video, Animate, Edit) haben ihre eigenen, aelteren Waehler. */+const INTENT_ROLE: Partial<Record<StudioIntent, StepRole[]>> = {+ // Ein Foto plus eine Stimme. Der Presenter braucht nicht einmal das Foto,+ // gehoert aber in dieselbe Zeile: der Kunde will hier jemanden sprechen sehen.+ lipsync: ['talking', 'presenter'],+ music: ['music'],+ extend: ['extend'],+ motion: ['motion'],+ video_upscale: ['upscale'],+}++export function intentRoles(intent: StudioIntent): StepRole[] {+ return INTENT_ROLE[intent] ?? []+}++/** Die Rolle, unter der ein bestimmtes Modell in dieser Absicht laeuft. */+export function intentRoleFor(intent: StudioIntent, model: string): StepRole | undefined {+ return intentRoles(intent).find((role) => presetModels(role).some((m) => m.id === model))+}++/** Alle Modelle, die diese Unterkategorie fahren koennen.+ *+ * Die klassischen Mitglieder stehen zuerst: sie sind die, die der Kunde schon+ * kennt, und ein Wechsel der Liste darf seine bisherige Wahl nicht verschieben.+ * `lipsync` fuehrt zusaetzlich die beiden Nachvertonungsmodelle, die einen+ * fertigen Clip statt eines Fotos lesen. Die sind kein Rollenmitglied, gehoeren+ * in der Oberflaeche aber seit jeher hierher. */+export function intentPickerModels(intent: StudioIntent): PresetModel[] {+ const roles = intentRoles(intent)+ if (!roles.length) return []+ const out: PresetModel[] = []+ const seen = new Set<string>()+ const add = (m: PresetModel) => { if (!seen.has(m.id)) { seen.add(m.id); out.push(m) } }+ if (intent === 'lipsync') for (const m of opPickerModels('lipsync')) {+ add({ id: m.id, label: m.label, kind: m.kind, op: 'lipsync', adult: m.adult === true })+ }+ for (const role of roles) for (const m of presetModels(role)) add(m)+ return out+}++/** Die Wahl, auf die diese Absicht wirklich laeuft.+ *+ * Waehler und Absenden benutzen denselben Aufruf. Stuende die Regel zweimal+ * da, zeigte der Waehler irgendwann ein anderes Modell an als das, was+ * abgerechnet wird. */+export function resolveIntentPick(intent: StudioIntent, picked: string): string {+ const list = intentPickerModels(intent)+ if (!list.length) return picked+ return list.some((m) => m.id === picked) ? picked : list[0].id+}++export function isStudioModel(id: string): boolean {+ return !!STUDIO_MODELS[id]+}++/** Was dieses Modell in dieser Absicht an Eingaben liest, als Anbieterfeld ->+ * Job-Parameter. */+export function intentInputs(intent: StudioIntent, model: string): Record<string, string> {+ const role = intentRoleFor(intent, model)+ return role ? roleInputs(role, model) : {}+}++/** Die Eingaben, ohne die dieses Modell nicht starten kann. */+export function intentRequiredInputs(intent: StudioIntent, model: string): string[] {+ const role = intentRoleFor(intent, model)+ return role ? requiredRoleInputs(role, model) : []+}++/** Der Preis eines Studio-Laufs fuer die Anzeige. `null`, wenn die Optionen+ * noch nicht vollstaendig sind: dann steht im Zaehler nichts statt einer+ * erfundenen Zahl. */+/** Der Preis eines Studio-Laufs fuer Zaehler und Startknopf im Create-Tab.+ *+ * Endpunkte, die nach der gewuenschten Laenge abrechnen, stehen hier genau.+ * Endpunkte, die die HOCHGELADENE Laenge abrechnen, bekommen die im Browser+ * gemessene Laenge herein und stehen damit ebenfalls genau. Ohne Datei bleibt+ * der Preis eines Laufs von fuenf Sekunden als Anhaltspunkt stehen. */+export function createStudioCost(+ model: string,+ options: Record<string, unknown>,+ promptLength = 100,+ seconds?: number,+): number {+ return studioPreviewCredits(model, options, seconds, 1, promptLength) ?? studioBaseCredits(model)+}++/** Haengt der Preis dieses Modells an der Laenge einer hochgeladenen Datei?+ *+ * Nur solche Modelle brauchen eine Messung im Browser. Alle anderen kann der+ * Anbieter sofort beziffern, weil nichts zu messen ist. */+export function pricesByInput(model: string): boolean {+ const mode = STUDIO_MODELS[model]?.price.mode+ return mode === 'input' || mode === 'both'+}++export function studioDisplayCredits(+ model: string,+ options: Record<string, unknown>,+ seconds?: number,+ imageCount = 1,+ promptLength = 100,+): number | null {+ return studioPreviewCredits(model, options, seconds, imageCount, promptLength)+}diff --git a/src/lib/render/preset-models.ts b/src/lib/render/preset-models.tsnew file mode 100644index 00000000..459a41fd--- /dev/null+++ b/src/lib/render/preset-models.ts@@ -0,0 +1,337 @@+// Which models a preset step may run on.+//+// A preset names one model per step, but the step is a job, not a model: any+// endpoint that eats the same inputs and returns the same kind does that job.+// 19.09.2026, Entscheid von David: the customer picks. So every step carries a+// role, and the role, not the preset, decides the choices.+//+// The lists below are declared, not guessed. A role is only useful when every+// member really runs: same inputs, same output kind, a price on both sides.+// The contract test walks each one and refuses a member that cannot.++import { STUDIO_MODELS, studioSchema } from './studio-contract'+import { cloudModelById, cloudModelsFor, i2vModels, runCredits } from '../../stores/cloudCatalogStore'+import type { RenderKind, RenderOp } from './cloud-jobs'++// Desktop port (P2): the web's RenderOp union already carries 'studio' (see+// lib/render/provider.ts in the portplan). The desktop's RenderOp (in+// cloud-jobs.ts) does not yet: that file is P5's exclusively, and 'studio'+// lands there when P5 merges. Until then this local union stands in so tsc+// stays green without touching a file this package does not own. P9: fold+// PresetOp away once cloud-jobs.ts's RenderOp includes 'studio'.+export type PresetOp = RenderOp | 'studio'++export type StepRole =+ | 'image' | 'animate' | 'soundtrack' | 'speech' | 'music' | 'talking' | 'presenter'+ | 'duo' | 'extend' | 'motion' | 'restyle' | 'angles' | 'edit' | 'upscale'++export interface PresetModel {+ id: string+ label: string+ kind: RenderKind+ op: PresetOp+ adult: boolean+}++/** The op a NON-studio member of this role runs under. Studio members always+ * run under 'studio' and carry their own schema. */+const ROLE_OP: Record<StepRole, PresetOp> = {+ image: 'generate', animate: 'animate', soundtrack: 'studio', speech: 'tts',+ music: 'music', talking: 'lipsync', presenter: 'studio', duo: 'studio',+ extend: 'extend', motion: 'motion', restyle: 'studio', angles: 'studio',+ edit: 'edit', upscale: 'upscale',+}++/** The staged inputs a NON-studio member consumes, as provider field -> job+ * param. Studio members bring their own map in the registry. */+export const ROLE_INPUTS: Record<StepRole, Record<string, string>> = {+ image: {}, speech: {}, music: {}, extend: {}, soundtrack: {}, duo: {},+ presenter: {}, restyle: {}, angles: {},+ animate: { image: 'source_path' },+ talking: { image: 'source_path', audio: 'audio_path' },+ motion: { image: 'source_path', video: 'video_path' },+ edit: { image: 'source_path' },+ upscale: { video: 'video_path' },+}++/** The studio inputs this model cannot start without. */+function studioRequiredInputs(id: string): string[] {+ const required = studioSchema(id).required ?? []+ return Object.keys(STUDIO_MODELS[id].inputs).filter((f) => required.includes(f)).sort()+}++function studioIds(match: (id: string) => boolean): string[] {+ return Object.keys(STUDIO_MODELS).filter(match)+}++const ROLE_MEMBERS: Record<StepRole, () => string[]> = {+ // Text to image: everything in the Image picker, plus the three studio+ // twins of the open bases, which price live instead of from our table.+ image: () => [+ ...studioIds((id) => STUDIO_MODELS[id].kind === 'image' && !Object.keys(STUDIO_MODELS[id].inputs).length),+ ...cloudModelsFor('image').map((m) => m.id),+ ],+ // Image to video: a still goes in, a clip comes out. Nothing else required.+ animate: () => [+ ...studioIds((id) => STUDIO_MODELS[id].kind === 'video' && studioRequiredInputs(id).join() === 'image'),+ ...i2vModels().map((m) => m.id),+ ],+ // A clip goes in, the same clip with sound comes out.+ soundtrack: () => ['mmaudio-v2', 'hunyuan-video-foley'],+ // Text to speech. Clone adds a reference recording, design a description.+ speech: () => [+ 'preset-qwen3-tts', 'qwen3-tts', 'qwen3-tts-clone', 'qwen3-tts-design',+ 'seed-speech-tts', 'minimax-speech-turbo', 'minimax-speech-hd', 'inworld-tts',+ 'eleven-v3', 'chatterbox-tts',+ ],+ // Words in, a finished track out. ACE-Step is ours and cheap, the three new+ // ones are what a released song sounds like.+ music: () => ['ace-step', 'ace-step-1.5', 'sonilo-music', 'minimax-music', 'mureka-song', 'eleven-music'],+ // A portrait plus one voice track becomes a speaking clip. The re-sync+ // models (latentsync, lipsync-2) need an existing clip and are a different+ // job, so they are not interchangeable here.+ talking: () => [+ 'infinitetalk', 'infinitetalk-fast', 'p-video-avatar',+ 'longcat-avatar', 'lipsync-3-avatar', 'seedance-2.5-avatar',+ ],+ // No portrait of your own: the provider's own presenter reads the track.+ presenter: () => ['heygen-twin'],+ // Two voice tracks on one image. Only one endpoint does this.+ duo: () => ['infinitetalk-multi', 'longcat-avatar-multi'],+ extend: () => [+ 'preset-wan-2.2-spicy-extend', 'wan-2.2-spicy-extend', 'ltx-2-extend', 'pixverse-extend',+ 'wan-3.0-extend', 'seedance-2.5-extend',+ ],+ // Movement from a driving clip onto a character image.+ motion: () => ['scail-2', 'wan-2.2-animate-2', 'wan-2.2-animate', 'steady-dancer', 'p-video-animate', 'dreamactor-v2'],+ restyle: () => ['wan-ditto'],+ angles: () => ['qwen-image-angles'],+ // Instruction edits, no mask. flux-dev is excluded: it demands one.+ edit: () => ['minimax-h3-edit', 'qwen-image-3-edit', 'seedream-5-edit', 'qwen-image-edit'],+ // A finished clip goes in, the same clip at more pixels comes out.+ upscale: () => ['video-upscaler', 'flashvsr', 'video-upscaler-pro', 'ultimate-video-upscaler', 'crystal-upscaler', 'flux-3-upscale'],+}++/** Classic ids that a studio entry already covers on the same endpoint. The+ * studio twin wins: it validates against the provider schema and books a+ * price the provider confirmed. The customer keeps seeing the catalog name. */+const SUPERSEDED = new Map<string, string>(+ Object.entries(STUDIO_MODELS)+ .filter(([, m]) => m.sourceModel)+ .map(([id, m]) => [m.sourceModel as string, id]),+)++function entry(id: string, role: StepRole): PresetModel | null {+ const studio = STUDIO_MODELS[id]+ const catalog = cloudModelById(studio?.sourceModel ?? id)+ const kind = studio?.kind ?? catalog?.kind+ if (!kind) return null+ return {+ id,+ // The name the customer already knows from the Create picker.+ label: catalog?.label ?? studio?.label ?? id,+ kind,+ op: studio ? 'studio' : ROLE_OP[role],+ adult: (studio?.adult ?? catalog?.adult) === true,+ }+}++/** Every model this step can run on, the preset's own first.+ *+ * `openOnly` is what an adult preset asks for. A Horror or a Spicy workflow+ * on a filtered endpoint returns a refusal or a softened frame, which costs+ * the customer credits for nothing. Where the role HAS open members, they are+ * the whole list. Where it has none, the role is not about refusals at all+ * (adding sound, driving a mouth) and the full list stands, because an empty+ * picker would take the step away entirely. */+/** Studio-Bildmodelle ohne klassisches Gegenstueck. Der Bildwaehler im+ * Create-Tab listet den Katalog; diese vier stehen in keinem Katalogeintrag,+ * es gaebe sie dort also gar nicht. Ein Modell mit `sourceModel` bleibt aussen+ * vor: das steht schon unter seinem alten Namen in der Liste. */+export function studioOnlyImageModels(): PresetModel[] {+ const klassisch = new Set(cloudModelsFor('image').map((m) => m.id))+ return presetModels('image').filter((m) =>+ m.op === 'studio' && !klassisch.has(m.id) && !STUDIO_MODELS[m.id]?.sourceModel)+}++export function presetModels(role: StepRole, openOnly = false): PresetModel[] {+ const all = allPresetModels(role)+ if (!openOnly) return all+ const open = all.filter((m) => m.adult)+ return open.length ? open : all+}++function allPresetModels(role: StepRole): PresetModel[] {+ // A caller with an unknown role gets nothing instead of a crashed workspace.+ const ids = ROLE_MEMBERS[role]?.() ?? []+ const out: PresetModel[] = []+ const seen = new Set<string>()+ for (const id of ids) {+ if (seen.has(id)) continue+ // A classic id the studio registry already serves is dropped, not listed+ // twice under the same name.+ const twin = SUPERSEDED.get(id)+ if (twin && ids.includes(twin)) continue+ const e = entry(id, role)+ if (!e) continue+ seen.add(id)+ out.push(e)+ }+ return out+}++/** A step always resolves the model it names, even when the picker narrows the+ * list around it. The preset's own choice is never taken away from it. */+/** Was ein Modell vom Prompt erwartet.+ *+ * 19.09.2026: ein Satz auf Prefect Pony brachte das Haus und nicht die Figur.+ * Das ist kein Fehler des Modells. Pony-Finetunes lesen kommagetrennte Tags+ * mit score_-Praefix, Chroma liest Saetze. Wer das nicht weiss, haelt das+ * Ergebnis fuer schlechte Qualitaet und zahlt zweimal. Also steht es dran. */+const HINTS: Record<string, string> = {+ 'preset-chroma': 'Reads full sentences. Can do photoreal and illustration. For photos, write it: start the prompt with "photorealistic" and describe the camera, the light and the lens.',+ chroma: 'Reads full sentences. Can do photoreal and illustration. For photos, write it: start the prompt with "photorealistic" and describe the camera, the light and the lens.',+ 'preset-prefect-pony': 'Reads comma separated tags, not sentences. Start with score_9, score_8_up. Illustration, not photo.',+ 'prefect-pony': 'Reads comma separated tags, not sentences. Start with score_9, score_8_up. Illustration, not photo.',+ 'preset-neta-lumina': 'Anime and illustration. Short comma separated tags work better than long sentences.',+ 'neta-lumina': 'Anime and illustration. Short comma separated tags work better than long sentences.',+ // Die vier offenen Bildmodelle, die eine Horrorszene wirklich stellen.+ // Geprueft am 19.09.2026 an einem identischen Prompt mit gleichem Seed.+ 'z-image': 'Reads full sentences and holds a photoreal scene. Name the room, the light and the lens.',+ 'nucleus-image': 'Reads full sentences. Has a negative prompt: write there what must not appear.',+ 'jib-mix-qwen': 'Reads full sentences. Warm, filmic skin. Name the light source and the camera.',+ 'wan-2.2-realism': 'Reads full sentences. The most cinematic of the four. Describe the shot like a film still.',+ // Bewegung, nicht Stimmung. Siehe prompt-ideas.ts, MOTION.+ 'open-video': 'Describe the movement, not the mood. Say what moves and how.',+ 'open-video-lora': 'Describe the movement, not the mood. Say what moves and how.',+ 'preset-wan-2.2-spicy': 'Describe the movement, not the mood. Say what moves and how.',+ 'preset-wan-2.7-spicy': 'Describe the movement, not the mood. Say what moves and how.',+ 'wan-3.0': 'Describe the movement, not the mood. Say what moves and how.',+ 'wan-3.0-spicy': 'Describe the movement, not the mood. Say what moves and how.',+ 'wan-3.0-prime': 'Describe the movement, not the mood. Say what moves and how.',+ 'wan-3.0-prime-spicy': 'Describe the movement, not the mood. Say what moves and how.',+ 'seedance-2.5-turbo': 'Describe the movement, not the mood. Say what moves and how.',++ // 19.09.2026: die neuen Endpunkte. Jeder Satz sagt, wofuer man ihn nimmt und+ // was er kostet, wenn der Preis der Grund fuer die Wahl ist.+ 'longcat-avatar': 'A good talking head at a low price. Start here.',+ 'lipsync-3-avatar': 'Sharp lip sync that keeps the rest of the photo still.',+ 'seedance-2.5-avatar': 'The most lifelike talking head we have, and by far the dearest.',+ 'heygen-twin': 'No photo of your own. Pick a presenter, they read your track.',+ 'infinitetalk-multi': 'One picture, two voices. Left speaks first unless you say otherwise.',+ 'longcat-avatar-multi': 'One picture, two voices, at a quarter of the InfiniteTalk price.',++ 'seed-speech-tts': 'Forty voices across ten languages. Natural, and cheap.',+ 'minimax-speech-turbo': 'Fast and emotional. Voices: Wise_Woman, Friendly_Person, Deep_Voice_Man, Calm_Woman.',+ 'minimax-speech-hd': 'The Turbo voices at higher fidelity, for twice the price.',+ 'eleven-v3': 'The most expressive English voice. Costs the most per word.',+ 'inworld-tts': 'Sixty named voices, many languages, pick one from the list.',+ 'chatterbox-tts': 'Add a short recording and it speaks in that voice.',++ 'minimax-music': 'A whole song with vocals from one description.',+ 'mureka-song': 'You write the lyrics, it writes and sings the song.',+ 'eleven-music': 'Studio quality music. Billed per started minute, not per second.',++ 'wan-2.2-animate-2': 'Copies the movement of your clip onto your picture.',+ 'wan-3.0-extend': 'Continues your clip. You pay only for the added seconds.',+ 'seedance-2.5-extend': 'Continues your clip. You pay for the whole result, not just the new part.',++ 'seedream-5-edit': 'Say what to change in plain words. No mask needed.',+ 'qwen-image-3-edit': 'Say what to change in plain words. The cheapest of the three.',++ 'video-upscaler': 'The basic one and the cheapest. Reaches 4K.',+ 'flashvsr': 'Sharper than the basic one and still cheap. Reaches 4K.',+ 'video-upscaler-pro': 'Sharper than FlashVSR on soft or noisy footage. Reaches 4K.',+ 'ultimate-video-upscaler': 'A heavier rebuild for really rough footage. Reaches 4K.',+ 'crystal-upscaler': 'The only one that reaches 8K. Set 33 megapixels for 8K.',+ 'flux-3-upscale': 'Multiplies the size instead of aiming at a target. No fixed 4K.',+}++export function modelHint(id: string): string | undefined {+ return HINTS[id]+}++export function presetModel(role: StepRole, id: string): PresetModel | undefined {+ return allPresetModels(role).find((m) => m.id === id)+}++/** The inputs a NON-studio member stages. Voice cloning is the one member+ * that needs a file where the rest of its role needs none. */+export function classicInputs(role: StepRole, id: string): Record<string, string> {+ if (role === 'speech') return id === 'qwen3-tts-clone' ? { audio: 'audio_path' } : {}+ return ROLE_INPUTS[role]+}++/** The inputs a member of this role stages, as provider field -> job param. */+export function roleInputs(role: StepRole, id: string): Record<string, string> {+ return STUDIO_MODELS[id] ? STUDIO_MODELS[id].inputs : classicInputs(role, id)+}++/** The inputs a member cannot start without. */+export function requiredRoleInputs(role: StepRole, id: string): string[] {+ const studio = STUDIO_MODELS[id]+ if (!studio) return Object.values(classicInputs(role, id))+ const required = studioSchema(id).required ?? []+ return Object.entries(studio.inputs).filter(([f]) => required.includes(f)).map(([, key]) => key)+}++/** Roles whose NON-studio members need words before they can start. */+const CLASSIC_PROMPT: Record<StepRole, boolean> = {+ image: true, animate: true, speech: true, music: true, extend: true, edit: true, restyle: true,+ talking: false, presenter: false, motion: false, soundtrack: false, duo: false,+ angles: false, upscale: false,+}++export function rolePrompts(role: StepRole): boolean {+ return CLASSIC_PROMPT[role]+}++/** Roles with a single member show no picker: there is nothing to pick. */+export function roleHasChoice(role: StepRole, openOnly = false): boolean {+ return presetModels(role, openOnly).length > 1+}++export const ALL_ROLES = Object.keys(ROLE_MEMBERS) as StepRole[]++/** The role a model plays. Every studio model belongs to exactly one, which a+ * contract test holds true; the ad-hoc single-model workspace needs it to+ * know what its one step is. */+export function roleForModel(id: string): StepRole | undefined {+ return ALL_ROLES.find((role) => ROLE_MEMBERS[role]().includes(id))+}++/** What a NON-studio member costs.+ *+ * This is the submit route's own call, with the route's own argument mapping:+ * a clip is priced from frames/fps and NEVER from `duration`, a track from+ * `duration`, a still from neither. The workshop prices with this function,+ * fed the very params it is about to send, so the number on the button and+ * the number that gets booked cannot drift apart.+ *+ * Desktop port (P2): the web prices this from its own table+ * (lib/billing/credits.ts, mediaCredits), which the desktop does not have+ * (portplan Abschnitt 2.1: "Desktop hat keine eigene Preistabelle, Preise+ * kommen aus /api/jobs/catalog"). Here the same number comes from the live+ * catalog via cloudCatalogStore's runCredits (read-only import, that store+ * belongs to P3). `null` when the catalog carries no price for this model+ * (seed without a rate, or before the first catalog refresh): never an+ * invented number. */+export function classicCredits(+ kind: RenderKind,+ model: string,+ op: RenderOp,+ p: { frames?: number; fps?: number; duration?: number; target_resolution?: string },+): number | null {+ const seconds = kind === 'video'+ ? (typeof p.frames === 'number' && typeof p.fps === 'number' && p.fps > 0 ? p.frames / p.fps : undefined)+ : kind === 'audio' ? p.duration : undefined+ const priced = runCredits(kind, op, model, seconds, Number.NaN, p.target_resolution)+ return Number.isFinite(priced) ? priced : null+}++/** The customer-facing name of a model id, whichever registry carries it.+ * A studio twin answers under the catalog name the customer already knows. */+export function modelLabel(id: string): string {+ const studio = STUDIO_MODELS[id]+ return cloudModelById(studio?.sourceModel ?? id)?.label ?? studio?.label ?? id+}diff --git a/src/lib/render/prompt-ideas.ts b/src/lib/render/prompt-ideas.tsnew file mode 100644index 00000000..9f01dd9e--- /dev/null+++ b/src/lib/render/prompt-ideas.ts@@ -0,0 +1,141 @@+// Prompt-Vorgaben fuer die Preset-Schritte.+//+// 19.09.2026, Entscheid von David: ein leeres Feld hilft niemandem. Neben dem+// Modell steht eine Liste von Anfaengen, die der Kunde anklickt und dann mit+// eigenen Worten weiterschreibt. Die Vorgabe ersetzt seinen Text nie, sie+// haengt sich davor, damit beides zusammen rausgeht.+//+// Die Texte sind auf Echtheit geschrieben und nicht auf Effekt: Kamera,+// Licht, Material, Traegermedium. Das ist, was diese Endpunkte lesen.++import type { StepRole } from './preset-models'++export interface PromptIdea { label: string; text: string }++/** Was im Bild zu sehen ist. Nach Kategorie, weil ein Produktfoto andere+ * Anfaenge braucht als eine Kreatur. */+const SCENE: Record<string, PromptIdea[]> = {+ Horror: [+ { label: 'Found footage', text: 'photorealistic, handheld camcorder footage from 1998, VHS grain and tracking lines, a motionless figure at the far end of a hallway, flashlight the only light' },+ { label: 'Phone POV at night', text: 'photorealistic, shot on a phone at night, POV, shaky frame, the flash reaching only two metres, wet concrete stairwell, something crouched just past the light' },+ { label: 'Doorbell camera', text: 'photorealistic, fisheye doorbell camera still with a timestamp in the corner, infrared night mode, a tall thin figure standing far too close to the lens, face out of focus' },+ { label: 'Clinical close-up', text: 'photorealistic clinical close-up under cold fluorescent light, skin stretched over shapes that do not belong beneath it, medical photography, unflinching detail' },+ { label: 'Abandoned ward', text: 'photorealistic, abandoned psychiatric ward, peeling paint, rusted bed frames, damp ceiling, one bare bulb swinging, dust caught in the beam, nobody in frame' },+ { label: 'Trail camera', text: 'photorealistic, trail camera photograph at 3 a.m., infrared, birch forest, a pale long-limbed animal caught mid-stride, eyes reflecting the flash' },+ { label: 'Basement', text: 'photorealistic, a cold concrete basement lit by candles, chalk marks on the floor, a figure kneeling with its back turned, film photograph, heavy shadows' },+ { label: 'Under the water', text: 'photorealistic, underwater in murky green lake water, a pale hand and long hair rising out of the silt, sunlight breaking through in shafts, cold and silent' },+ { label: 'The morning after', text: 'photorealistic, kitchen at dawn, overturned chair, dark stains across the linoleum, breakfast still on the table, documentary photograph, nobody in frame' },+ { label: 'Handmade mask', text: 'photorealistic, close portrait of a person in a crude handmade mask of stitched cloth and bone, flat overcast daylight, rural field behind, 35mm film' },+ ],+ Character: [+ { label: 'Phone POV', text: 'photorealistic, shot on a phone, POV, natural window light, candid and slightly off balance, realistic skin texture, mild motion blur' },+ { label: 'Golden hour', text: 'photorealistic, portrait in low golden hour sun, warm rim light through the hair, shallow depth of field, 85mm, soft grain' },+ { label: 'Neon alley', text: 'photorealistic, standing in a narrow alley at night, wet asphalt, magenta and cyan neon from a sign overhead, cinematic, 35mm' },+ { label: 'Film noir', text: 'photorealistic, black and white, hard side light through window blinds, cigarette smoke drifting, deep shadows, 1940s studio photograph' },+ { label: 'Lamp light', text: 'photorealistic, sitting on the edge of a bed in warm bedside lamp light, dark room behind, strong rim light, cinematic still, shallow depth of field' },+ { label: 'Studio beauty', text: 'photorealistic, clean studio beauty shot, soft key light with a large softbox, seamless grey backdrop, sharp detail in the eyes' },+ { label: 'Rain on glass', text: 'photorealistic, seen through a rain-covered window at night, city lights out of focus behind, reflections on the glass, moody and quiet' },+ { label: 'Backstage mirror', text: 'photorealistic, backstage at a mirror ringed with bulbs, half in costume, warm tungsten light, candid documentary photograph' },+ { label: 'Rooftop summer', text: 'photorealistic, on a rooftop in late summer heat, hazy skyline behind, hard midday sun, 35mm colour film, natural skin' },+ { label: 'Monochrome 35mm', text: 'black and white 35mm film portrait, visible grain, available light only, direct eye contact, honest and unretouched' },+ ],+ Product: [+ { label: 'Studio white', text: 'photorealistic, product on a seamless white backdrop, soft even studio light, gentle contact shadow, commercial catalogue photograph' },+ { label: 'Marble and shadow', text: 'photorealistic, product on polished marble, hard directional sun casting a long sharp shadow, minimal styling, editorial still life' },+ { label: 'Kitchen counter', text: 'photorealistic, product on a kitchen counter in morning light, shallow depth of field, a few real props out of focus behind' },+ { label: 'Outdoors in use', text: 'photorealistic, product held outdoors in natural daylight, lifestyle photograph, hands in frame, blurred park background' },+ { label: 'Water and splash', text: 'photorealistic, product with water droplets and a frozen splash, high speed flash, dark background, glossy highlights' },+ { label: 'Neon gradient', text: 'photorealistic, product lit by a magenta to cyan gradient, dark reflective surface, crisp edges, modern advertising look' },+ { label: 'Wooden desk', text: 'photorealistic, flat lay on a worn wooden desk, overhead shot, soft window light, notebook and pen arranged around it' },+ { label: 'In the hand', text: 'photorealistic, close-up of the product held in a hand, natural skin, soft daylight, shallow focus on the label' },+ { label: 'Macro texture', text: 'photorealistic, macro shot of the product surface, raking light across the texture, extreme detail, dark surroundings' },+ { label: 'On the shelf', text: 'photorealistic, product on a retail shelf among others, slightly wide lens, store lighting, documentary rather than staged' },+ ],+ Video: [+ { label: 'Phone POV', text: 'shot on a phone, POV, handheld, natural light, candid and unpolished' },+ { label: 'Slow push in', text: 'a slow steady push in toward the subject, locked horizon, cinematic, shallow depth of field' },+ { label: 'Handheld follow', text: 'handheld camera following just behind the subject, slight sway, documentary feel' },+ { label: 'Orbit', text: 'the camera orbits slowly around the subject at eye level, background sliding past, even pace' },+ { label: 'Locked off', text: 'static locked-off shot on a tripod, only the subject moves, patient and observational' },+ { label: 'Drone pull back', text: 'the camera pulls back and up, revealing the wider landscape around the subject' },+ { label: 'Rack focus', text: 'focus pulls from the foreground detail to the subject behind, shallow depth of field, 50mm' },+ { label: 'Low angle', text: 'low angle looking up at the subject, wide lens, sky behind, slow drift to the left' },+ { label: 'Night drive', text: 'from inside a moving car at night, streetlights sweeping across, reflections on the windscreen' },+ { label: 'Golden hour walk', text: 'walking toward the low sun, long shadows, lens flare, warm handheld footage' },+ ],+}++/** Wie sich das Bild bewegt.+ *+ * 19.09.2026: ein Kunde schrieb "the bird is starting to sing and looks+ * stressed" und bekam einen Vogel, der stillsteht. Diese Endpunkte lesen+ * BEWEGUNG, keine Absicht und keine Stimmung. Die Haelfte der Anfaenge+ * beschreibt deshalb, was das Motiv tut, und nicht nur, was die Kamera tut. */+const MOTION: PromptIdea[] = [+ { label: 'Looks into camera', text: 'the subject slowly turns its head toward the camera and holds the look, small natural movements' },+ { label: 'Opens mouth, sings', text: 'the subject opens its mouth and sings, the head tilts, the throat moves, the body shifts slightly with each note' },+ { label: 'Speaks', text: 'the subject speaks, the mouth moves clearly, small head movements, the eyes stay on the camera' },+ { label: 'Breathes and blinks', text: 'small natural movement only, the chest rises and falls, the eyes blink, hair and fabric shift slightly' },+ { label: 'Steps forward', text: 'the subject takes two slow steps toward the camera and stops, the camera holds still' },+ { label: 'Wind', text: 'wind moves through hair and fabric, the subject stays where it is and looks ahead' },+ { label: 'Slow push in', text: 'a slow steady push in toward the subject, locked horizon, cinematic, shallow depth of field' },+ { label: 'Handheld follow', text: 'handheld camera following just behind the subject, slight sway, documentary feel' },+ { label: 'Orbit', text: 'the camera orbits slowly around the subject at eye level, background sliding past, even pace' },+ { label: 'Locked off', text: 'static locked-off shot on a tripod, only the subject moves, patient and observational' },+]++/** Was zu hoeren ist. */+const SOUND: PromptIdea[] = [+ { label: 'Room tone', text: 'quiet room tone, distant traffic, a clock ticking somewhere off screen' },+ { label: 'Footsteps', text: 'slow wet footsteps on concrete, echo of a large empty space, a single drip' },+ { label: 'Wind and trees', text: 'wind moving through trees, leaves, a bird call far away' },+ { label: 'Breathing', text: 'close unsteady breathing, fabric rustling, a floorboard creaking under weight' },+ { label: 'City street', text: 'busy city street, passing cars, voices in the distance, a siren several blocks away' },+ { label: 'Rain on glass', text: 'heavy rain against a window, thunder rolling far off, the hum of a fridge' },+ { label: 'Machinery', text: 'low industrial hum, metal ticking as it cools, a fan turning somewhere above' },+ { label: 'Crowd', text: 'indoor crowd murmur, glasses and cutlery, a door opening and closing' },+ { label: 'Water', text: 'water lapping against stone, a boat rope straining, gulls overhead' },+ { label: 'Silence and one sound', text: 'almost complete silence, then one sharp sound very close to the microphone' },+]++/** Was mit dem Bild passieren soll. */+const SETTING: PromptIdea[] = [+ { label: 'Marble surface', text: 'place it on polished marble in hard directional sunlight with a long sharp shadow' },+ { label: 'Kitchen morning', text: 'put it on a kitchen counter in soft morning light with a blurred window behind' },+ { label: 'Outdoors', text: 'set it outdoors on grass in natural daylight with a blurred treeline behind' },+ { label: 'Dark and glossy', text: 'set it on a dark reflective surface with a magenta to cyan gradient behind it' },+ { label: 'Wooden desk', text: 'place it on a worn wooden desk seen from above in soft window light' },+ { label: 'Retail shelf', text: 'place it on a retail shelf among other goods under store lighting' },+ { label: 'Studio white', text: 'put it on a seamless white studio backdrop with soft even light and a gentle contact shadow' },+ { label: 'Concrete and shadow', text: 'set it on raw concrete with hard late afternoon light raking across the texture' },+ { label: 'Held in a hand', text: 'show it held in a hand in soft daylight with the background thrown out of focus' },+ { label: 'Rain', text: 'set it outside in the rain with water beading on the surface and grey overcast light' },+]++/** Die Anfaenge fuer diesen Schritt. Leer heisst: das Feld beschreibt hier+ * keine Szene, und eine Vorgabe waere geraten statt hilfreich. */+export function promptIdeas(role: StepRole, category: string): PromptIdea[] {+ if (role === 'image') return SCENE[category] ?? SCENE.Character+ if (role === 'animate' || role === 'extend') return MOTION+ if (role === 'soundtrack') return SOUND+ if (role === 'edit') return SETTING+ return []+}++export interface IdeaGroup { label: string; ideas: PromptIdea[] }++/** Die Anfaenge im normalen Create-Fenster.+ *+ * Dort gibt es keine Preset-Kategorie, also entscheidet die Absicht. Beim+ * Bild bleiben die vier Sets als Gruppen stehen, damit der Kunde sieht, dass+ * es sie gibt; bei Video zaehlt nur die Bewegung, bei Musik nur der Klang. */+export function createIdeas(intent: string): IdeaGroup[] {+ if (intent === 'video' || intent === 'animate' || intent === 'extend') return [{ label: 'Movement', ideas: MOTION }]+ if (intent === 'music') return [{ label: 'Sound', ideas: SOUND }]+ if (intent === 'image' || intent === 'edit') {+ return (['Horror', 'Character', 'Product', 'Video'] as const)+ .map((label) => ({ label, ideas: SCENE[label] }))+ .filter((g) => g.ideas?.length)+ }+ return []+}