The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Cinema: a World take that steers a world turn by turn, with its camera path, redo and export
Claudec8034a01fe3c
diff --git a/docs/research/new-models-10.json b/docs/research/new-models-10.jsonindex 7d024aec..2a3e88f9 100644--- a/docs/research/new-models-10.json+++ b/docs/research/new-models-10.json@@ -300,14 +300,15 @@{"name": "Hy-Nomas (interactive world model)","area": "world model / long steerable video",- "licence": "Apache-2.0 (HF tag)",+ "licence": "Apache-2.0 (code and weights: LICENSE at tencent/Hy-Nomas bb6a8ca4, read 2026-11-03; third-party components keep their own licences). The PixelUMM decoder is Tencent's fine-tune of NVIDIA PixelUMM: the converted file (nynxz/Hy-Nomas) is under the NVIDIA One-Way Noncommercial License per its card. The prompt enhancer (PE, ~55 GB in 18 shards) is in the same Apache-2.0 repository and is only needed by the web demo","vram": "8 GPUs reference; one 4090 with INT8 DiT + FP8 decoder + offload; port: 5090 ~21 s per 3 s turn at 1280x704","hosted": [],- "comfy": "community port Nynxz/ComfyUI-HyNomas (stock loaders)",+ "comfy": "community port Nynxz/ComfyUI-HyNomas at a89e0515 (Apache-2.0, stock loaders; weights nynxz/Hy-Nomas at e8ddc4bf: int8 ConvRot DiT 8.97 GB, bf16 DiT 17.11 GB, PixelUMM VAE bf16 15.78 GB; text encoder qwen_2.5_vl_7b from Comfy-Org/Qwen-Image, already pinned). History lives in ComfyUI's memory (NOMAS_WORLD + an int8 KV cache in temp/nomas_history): separate /prompt calls carry it only through ComfyUI's output cache (the same upstream nodes and inputs) or the Nomas Explore node's in-process sessions","released": "2026-10-21","url": "https://huggingface.co/tencent/Hy-Nomas",- "inFuobe": false,- "confirmed": true+ "inFuobe": true,+ "confirmed": true,+ "fuobe": "World mode in Cinema (nm10-hy-nomas-world): oss-hy-nomas-world, graph world-hy-nomas-turn, open engine only"},{"name": "MiniMax H3 Max Director (realtime steering)",@@ -328,7 +329,9 @@"released": "2026-09-03 / 2026-10-15","url": "https://fal.ai/models/minimax/h3-max/director","inFuobe": false,- "confirmed": true+ "confirmed": true,+ "pricing": "fal (read 2026-11-03): $0.08/s, 1080p $0.16/s from 2026-11-16 (30% off 11-01 to 11-15: $0.056 / $0.112); every session billed at least 60 s. Reference Director: no price listed on fal's model list",+ "notes": "Realtime WebRTC sessions with live prompts (fal's 'worlds' category). A different model from Hy-Nomas, not a stand-in for World mode; offering it under its own name is the owner's call"},{"name": "Prism (Tencent/Fudan/ZJU joint 2K audio-video, preview)",@@ -1273,6 +1276,75 @@"notes": "\"<qma> {azimuth} {elevation} {distance}\": 8 azimuths relative to the original camera, 4 elevations, 3 distances; strength 1.0, 30 steps, CFG 3, euler / simple, ~1 MP. Not hostable: fal's Qwen-Image 2.1 takes no LoRAs.","inFuobe": true,"confirmed": true+ },+ {+ "name": "Abot World 0 (Alibaba)",+ "area": "interactive world (realtime)",+ "licence": "commercial (fal listing)",+ "vram": "hosted (realtime session)",+ "hosted": [+ {+ "provider": "fal",+ "endpoint": "alibaba/abot-world-0"+ }+ ],+ "comfy": "no",+ "released": "2026-10-15",+ "url": "https://fal.ai/models/alibaba/abot-world-0",+ "inFuobe": false,+ "confirmed": true,+ "pricing": "not listed on fal's model list (read 2026-11-03)",+ "notes": "fal 'worlds': explore interactive worlds in real time with movement and camera controls. A different model from Hy-Nomas, not a stand-in; offering it under its own name is the owner's call"+ },+ {+ "name": "Lingbot World 2 (Robbyant)",+ "area": "interactive world (realtime)",+ "licence": "research (fal listing: licenseType 'research')",+ "vram": "hosted (realtime session)",+ "hosted": [+ {+ "provider": "fal",+ "endpoint": "robbyant/lingbot-world-2"+ }+ ],+ "comfy": "no",+ "released": "2026-10-16",+ "url": "https://fal.ai/models/robbyant/lingbot-world-2",+ "inFuobe": false,+ "confirmed": true,+ "pricing": "not listed on fal's model list (read 2026-11-03)",+ "notes": "fal 'worlds': realtime movement and camera controls. Research licence on fal. A different model from Hy-Nomas; the owner's call"+ },+ {+ "name": "VAST Eden Live (5B / 14B, Game and Video)",+ "area": "realtime game worlds and video-to-video",+ "licence": "commercial (fal listing)",+ "vram": "hosted (realtime session)",+ "hosted": [+ {+ "provider": "fal",+ "endpoint": "vast/eden-live-14b-game"+ },+ {+ "provider": "fal",+ "endpoint": "vast/eden-live-5b-game"+ },+ {+ "provider": "fal",+ "endpoint": "vast/eden-live-14b-video"+ },+ {+ "provider": "fal",+ "endpoint": "vast/eden-live-5b-video"+ }+ ],+ "comfy": "no",+ "released": "2026-10-22",+ "url": "https://fal.ai/models/vast/eden-live-14b-game",+ "inFuobe": false,+ "confirmed": true,+ "pricing": "fal (read 2026-11-03): 14B $0.01 per generated second, 5B $0.0035, each session billed at least 10 s",+ "notes": "Game models in fal's 'worlds' category; the Video ones are video-to-video. Different models from Hy-Nomas; the owner's call"}],"packages": [diff --git a/src/components/cinema/projects-view.tsx b/src/components/cinema/projects-view.tsxindex 3b33a7ef..2d52fc28 100644--- a/src/components/cinema/projects-view.tsx+++ b/src/components/cinema/projects-view.tsx@@ -1,6 +1,6 @@"use client";-import { Box, Clapperboard, Copy, ExternalLink, MoreHorizontal, Pin, PinOff, Plus, Settings2 } from "lucide-react";+import { Box, Clapperboard, Copy, ExternalLink, Globe, MoreHorizontal, Pin, PinOff, Plus, Settings2 } from "lucide-react";import Link from "next/link";import { useRouter, useSearchParams } from "next/navigation";import { Suspense, useCallback, useEffect, useState } from "react";@@ -104,14 +104,16 @@ function ProjectCard({ project, onSettings, query = "" }: { project: CinemaProje}/**- * /cinema?blockout=1 (the GPU board's Blockout to film row): the list says to pick the project, and a project opened- * or started from it opens Blockout to film. Read in its own Suspense boundary, so the rest of the list prerenders.+ * /cinema?blockout=1 (the GPU board's Blockout to film row) or /cinema?world=1 (its World mode row): the list says to+ * pick the project, and a project opened or started from it opens Blockout to film or World. Read in its own Suspense+ * boundary, so the rest of the list prerenders.*/-function BlockoutQuery({ onBlockout }: { onBlockout: () => void }) {- const on = useSearchParams().get("blockout") === "1";+function OpenerQuery({ onOpener }: { onOpener: (o: "blockout" | "world") => void }) {+ const params = useSearchParams();+ const on = params.get("blockout") === "1" ? "blockout" : params.get("world") === "1" ? "world" : null;useEffect(() => {- if (on) onBlockout();- }, [on, onBlockout]);+ if (on) onOpener(on);+ }, [on, onOpener]);return null;}@@ -172,9 +174,10 @@ export function CinemaProjects() {const visitor = useIsVisitor();const onCreate = visitor ? undefined : () => setCreating(true);useHadItems("cinema-projects", data?.length);- const [blockout, setBlockout] = useState(false);- const markBlockout = useCallback(() => setBlockout(true), []);- const query = blockout ? "?blockout=1" : "";+ const [opener, setOpener] = useState<"blockout" | "world" | null>(null);+ const markOpener = useCallback((o: "blockout" | "world") => setOpener(o), []);+ const blockout = opener === "blockout";+ const query = opener ? `?${opener}=1` : "";return (<PageShell wide><PageHeader title="Cinema Studio" description="Direct films shot by shot: genre, camera, lens, palette and light, with characters and locations that stay the same.">@@ -185,13 +188,18 @@ export function CinemaProjects() {)}</PageHeader><Suspense fallback={null}>- <BlockoutQuery onBlockout={markBlockout} />+ <OpenerQuery onOpener={markOpener} /></Suspense>{blockout && !!data?.length && (<p className="mb-5 flex items-center gap-2 rounded-xl bg-brand-faint px-3 py-2.5 text-[13px] text-brand-text"><Box className="size-4 shrink-0" /> Blockout to film: pick the project to film it in{onCreate ? ", or start a new one" : ""}.</p>)}+ {opener === "world" && !!data?.length && (+ <p className="mb-5 flex items-center gap-2 rounded-xl bg-brand-faint px-3 py-2.5 text-[13px] text-brand-text">+ <Globe className="size-4 shrink-0" /> World: pick the project to film it in{onCreate ? ", or start a new one" : ""}.+ </p>+ )}{isLoading ? (// Both shapes are in the server's shell; the one this browser saw last time shows from the first paint.<div key="loading">diff --git a/src/components/cinema/prompt-bar.tsx b/src/components/cinema/prompt-bar.tsxindex 8e7a1ef2..803d052a 100644--- a/src/components/cinema/prompt-bar.tsx+++ b/src/components/cinema/prompt-bar.tsx@@ -1,35 +1,6 @@"use client";-import {- ArrowLeftToLine,- ArrowRightToLine,- ArrowUp,- AtSign,- AudioLines,- Box,- Check,- ChevronDown,- Clapperboard,- Clock,- Copy as CopyIcon,- FileVideo,- Grid2x2,- ImageIcon,- ImagePlus,- Loader2,- MapPin,- Maximize,- Plus,- RectangleHorizontal,- SlidersHorizontal,- Sparkles,- UserRoundPlus,- Video,- Volume2,- VolumeX,- Wand2,- X,-} from "lucide-react";+import { ArrowLeftToLine, ArrowRightToLine, ArrowUp, AtSign, AudioLines, Box, Check, ChevronDown, Clapperboard, Clock, Copy as CopyIcon, FileVideo, Globe, Grid2x2, ImageIcon, ImagePlus, Loader2, MapPin, Maximize, Plus, RectangleHorizontal, SlidersHorizontal, Sparkles, UserRoundPlus, Video, Volume2, VolumeX, Wand2, X } from "lucide-react";import { nanoid } from "nanoid";import { useEffect, useId, useMemo, useRef, useState } from "react";import { toast } from "sonner";@@ -343,6 +314,8 @@ export interface PromptBarProps {onLocation: () => void;/** Blockout to film: a grey-box blockout (uploaded or built) as the take's camera, blocking and timing. */onBlockout?: () => void;+ /** World mode (nm10-hy-nomas-world): a world described once, steered turn by turn. Absent when the engine mode is "Paid APIs only". */+ onWorld?: () => void;}const ACTIONS: { id: BarAction; label: string; icon: typeof Video; hint: string }[] = [@@ -610,6 +583,19 @@ export function PromptBar(props: PromptBarProps) {<TooltipContent>Blockout to film: a grey box from Blender or built here sets the camera and timing</TooltipContent></Tooltip>)}+ {draft.mode === "video" && props.onWorld && (+ <Tooltip>+ <TooltipTrigger asChild>+ <button type="button" onClick={() => {+ setDirectorOpen(false);+ props.onWorld!();+ }} className={cn(chip, chipIdle)} aria-label="World: describe a world, then steer it turn by turn">+ <Globe className="size-3.5" /> World+ </button>+ </TooltipTrigger>+ <TooltipContent>World: describe a world once, then steer it turn by turn with words and camera moves (your GPU)</TooltipContent>+ </Tooltip>+ )}</>);const picks = directorPicks(settings, draft.mode);diff --git a/src/components/cinema/workspace.tsx b/src/components/cinema/workspace.tsxindex 565c6b4a..9f8de4fe 100644--- a/src/components/cinema/workspace.tsx+++ b/src/components/cinema/workspace.tsx@@ -38,6 +38,7 @@ import { SceneCreateDialog, askSceneConfirmAgain, sceneTake, skipSceneConfirm, uimport { SidePanel } from "./side-panel";import { SoulCastDialog, SoulLocationDialog } from "./soul-builders";import { BlockoutPanel, initialBlockout, withBuilt, type BlockoutDraft } from "./blockout-panel";+import { WorldPanel } from "./world-panel";import type { BlockoutScene } from "@/lib/blockout";/** What a browser that can only write WebM is told: Seedance 2.5 takes MP4 or MOV reference clips. */@@ -183,7 +184,7 @@ function Workspace({ data, items, loading }: { data: ProjectView; items: CinemaGconst id = project.id;const router = useRouter();const share = useShare();- const [engine, setEngine] = useEngine();+ const [engine, setEngine, engineMode] = useEngine();const [view, setView] = useState<CinemaView>({ kind: "home" });const [nested, setNested] = useState(true);const [draft, setDraftState] = useState<CinemaDraft>(() => restoreDraft(id));@@ -222,6 +223,9 @@ function Workspace({ data, items, loading }: { data: ProjectView; items: CinemaG// /cinema/<id>?blockout=1 (a link to Blockout to film) opens it.const search = useSearchParams();const [blockoutOpen, setBlockoutOpen] = useState(() => search.get("blockout") === "1");+ // World mode: /cinema/<id>?world=1 (the GPU board's World mode row) opens it. Hidden when the engine mode is "Paid APIs+ // only": Hy-Nomas runs on your GPU alone.+ const [worldOpen, setWorldOpen] = useState(() => search.get("world") === "1");const [blockout, setBlockout] = useState<BlockoutDraft>(initialBlockout);const [builder, setBuilder] = useState<BlockoutScene | null>(null);const [dropping, setDropping] = useState(false);@@ -594,6 +598,7 @@ function Workspace({ data, items, loading }: { data: ProjectView; items: CinemaGonCast={() => setCastOpen(true)}onLocation={() => setLocationOpen(true)}onBlockout={() => setBlockoutOpen(true)}+ onWorld={engineMode === "cloud" ? undefined : () => setWorldOpen(true)}/></div></div>@@ -685,6 +690,19 @@ function Workspace({ data, items, loading }: { data: ProjectView; items: CinemaG}}/>)}+ <WorldPanel+ open={worldOpen && engineMode !== "cloud"}+ onOpenChange={setWorldOpen}+ projectId={id}+ folderId={folderId}+ engine={engine}+ onEngine={setEngine}+ openAllowed={engineMode !== "cloud"}+ settings={settings}+ brief={project.brief.body}+ context={context}+ takes={items}+ /><SoulCastDialog open={castOpen} onOpenChange={setCastOpen} {...builderProps} /><SoulLocationDialog open={locationOpen} onOpenChange={setLocationOpen} {...builderProps} /><ProjectDialog open={settingsOpen} onOpenChange={setSettingsOpen} project={project} spentUsd={spentUsd} onDone={() => setSettingsOpen(false)} onDeleted={() => router.push("/cinema")} />diff --git a/src/components/cinema/world-panel.tsx b/src/components/cinema/world-panel.tsxnew file mode 100644index 00000000..458498a2--- /dev/null+++ b/src/components/cinema/world-panel.tsx@@ -0,0 +1,384 @@+"use client";++import { Clapperboard, Film, Globe, Loader2, Music, Plus, Route, RotateCcw, Trash2, Volume2 } from "lucide-react";+import Link from "next/link";+import { useEffect, useMemo, useState } from "react";+import { toast } from "sonner";+import { Button } from "@/components/ui/button";+import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";+import { Input } from "@/components/ui/input";+import { Textarea } from "@/components/ui/textarea";+import { useStatus } from "@/lib/api";+import { planCinema, type CinemaGenerateInput, type DirectorSettings } from "@/lib/catalog/cinema";+import type { Engine } from "@/lib/catalog/types";+import { placeholdersOn } from "@/lib/demo-mode";+import { toastError } from "@/lib/refusals";+import { cn } from "@/lib/utils";+import {+ PERSPECTIVES,+ STYLES,+ WORLD_LIMITS,+ WORLD_MOVES,+ allTurns,+ canRun,+ clampSeconds,+ clipSeconds,+ clipsFromTakes,+ exportClips,+ newTurn,+ newWorld,+ nextTurn,+ normalizeWorld,+ worldProblem,+ worldSeconds,+ type TurnState,+ type WorldScript,+ type WorldTakeLike,+ type WorldTurn,+} from "@/lib/world";+import { pathSketch } from "@/lib/world-path";+import { useCinemaGenerate } from "./hooks";++/**+ * World mode in Cinema's take composer (package nm10-hy-nomas-world): the opening (the world in words, who the camera+ * follows, the look), then turns, each with what changes, a camera move from the fly-path library and its length; the+ * camera's path from above; Run turn, Redo from here (the turns before it stay), and Export, which joins the turns into+ * one film. Hy-Nomas runs on your GPU only, and makes no sound: Sound for video and Music come after.+ */++const STORE = (projectId: string) => `fuobe.cinema.world.${projectId}`;+const section = "space-y-2.5 border-t pt-4 first:border-t-0 first:pt-0";+const h3 = "text-[12px] font-medium tracking-wide text-muted-foreground uppercase";+const select = "h-8 min-w-0 rounded-full border bg-background px-3 text-[12.5px]";+/** A colour per turn, for the timeline and the path (the brand hue turning round the wheel). */+const hue = (k: number) => `oklch(0.66 0.15 ${(250 + k * 47) % 360})`;++function restore(projectId: string, takes: readonly WorldTakeLike[]): WorldScript {+ try {+ const raw = localStorage.getItem(STORE(projectId));+ if (raw) return normalizeWorld(JSON.parse(raw) as WorldScript);+ } catch {+ // A private window or blocked storage: start from the takes, or a new world.+ }+ const last = [...takes].filter((t) => t.take?.world && !t.take.world.joined).sort((a, b) => b.createdAt - a.createdAt)[0] as (WorldTakeLike & { take?: { world?: { script?: WorldScript } } }) | undefined;+ return last?.take?.world?.script ? normalizeWorld(last.take.world.script) : newWorld();+}++const STATE_WORDS: Record<TurnState, string> = { done: "Ready", running: "Filming…", failed: "Didn't finish", stale: "Changed: run it again", none: "Not run yet" };++export interface WorldPanelProps {+ open: boolean;+ onOpenChange: (o: boolean) => void;+ projectId: string;+ folderId: string | null;+ engine: Engine;+ onEngine: (e: Engine) => void;+ /** The engine mode allows the open engine (not "Paid APIs only"). */+ openAllowed: boolean;+ settings: DirectorSettings;+ brief: string;+ context: { cloudAllowed: boolean; civitai?: boolean; worldcast?: boolean };+ /** The project's takes: the World turns' clips come from them. */+ takes: readonly WorldTakeLike[];+}++export function WorldPanel(props: WorldPanelProps) {+ const { open, onOpenChange, projectId, folderId, engine, onEngine, openAllowed, settings, brief, context, takes } = props;+ const generate = useCinemaGenerate(projectId);+ const demo = placeholdersOn(useStatus().data?.demoMode);+ const [script, setScript] = useState<WorldScript | null>(null);+ const [redoAt, setRedoAt] = useState<Record<number, number>>({});+ const [showPath, setShowPath] = useState(false);+ const [busy, setBusy] = useState<number | "export" | null>(null);++ // The script is read once the panel opens (the browser's copy, else the newest World take's), then kept as edited.+ if (open && !script) setScript(restore(projectId, takes));+ useEffect(() => {+ if (!script) return;+ try {+ localStorage.setItem(STORE(projectId), JSON.stringify(script));+ } catch {+ // Not saved in this browser: the takes keep the script each turn was made from.+ }+ }, [script, projectId]);++ const w = script ?? newWorld(0);+ const { clips, states } = useMemo(() => clipsFromTakes(w, takes, redoAt), [w, takes, redoAt]);+ const next = nextTurn(w, clips);+ const exported = exportClips(w, clips);+ const target = next >= 0 ? next : w.turns.length;+ const input = (k: number, join?: string[]): Omit<CinemaGenerateInput, "brief"> => ({ engine, mode: "video", action: "world", prompt: "", settings, world: { script: w, turn: k, ...(join ? { join } : {}) } });+ const plan = useMemo(() => planCinema({ ...input(target), brief }, context), [w, target, engine, settings, brief, context]); // eslint-disable-line react-hooks/exhaustive-deps+ const price = demo ? "Placeholder · free" : "Free";+ const total = worldSeconds(w);+ const sketch = useMemo(() => pathSketch(allTurns(w).map((t) => ({ move: t.move, seconds: t.seconds }))), [w]);++ const set = (fn: (s: WorldScript) => WorldScript) => setScript((s) => fn(s ?? newWorld()));+ const setTurn = (k: number, patch: Partial<WorldTurn>) =>+ set((s) => (k === 0 ? { ...s, opening: { ...s.opening, ...patch } } : { ...s, turns: s.turns.map((t, i) => (i === k - 1 ? { ...t, ...patch } : t)) }));++ const run = async (k: number) => {+ const problem = engine !== "open" ? "World mode runs on your GPU (open source)" : worldProblem(w, k);+ if (problem) return toast.error(problem);+ setBusy(k);+ try {+ await generate.mutateAsync({ input: input(k) as CinemaGenerateInput, folderId });+ toast.success(k === 0 ? "Filming the opening on your GPU — it lands in this scene as a new take" : `Filming turn ${k} on your GPU — it lands in this scene as a new take`);+ } catch (e) {+ toastError(e, "Couldn't film that turn");+ } finally {+ setBusy(null);+ }+ };+ const redo = (k: number) => {+ // A little before now: the take's time is the server's clock.+ setRedoAt((r) => ({ ...r, [k]: Date.now() - 2000 }));+ void run(k);+ };+ const exportFilm = async () => {+ if (!exported) return;+ setBusy("export");+ try {+ await generate.mutateAsync({ input: input(w.turns.length, exported) as CinemaGenerateInput, folderId });+ toast.success("Joining the turns into one film — it lands in this scene as a new take", {+ duration: 8000,+ description: "Hy-Nomas makes no sound: add it afterwards.",+ action: { label: "Sound for video", onClick: () => window.open("/audio/video", "_self") },+ });+ } catch (e) {+ toastError(e, "Couldn't join the turns");+ } finally {+ setBusy(null);+ }+ };++ const turnCard = (t: WorldTurn, k: number) => {+ const clip = clips[k];+ const state = states[k];+ const runnable = canRun(w, clips, k);+ const opening = k === 0;+ return (+ <li key={k} className="grid gap-2 rounded-xl border p-3" style={{ borderLeft: `4px solid ${hue(k)}` }}>+ <div className="flex flex-wrap items-center gap-2">+ <span className="text-[13.5px] font-medium">{opening ? "Opening" : `Turn ${k}`}</span>+ <span className={cn("rounded-full px-2 py-0.5 text-[11.5px]", state === "done" ? "bg-brand-faint text-brand-text" : state === "failed" ? "bg-destructive/10 text-destructive" : "bg-muted text-muted-foreground")}>+ {state === "running" && <Loader2 className="mr-1 inline size-3 animate-spin" />}+ {STATE_WORDS[state]}+ </span>+ <span className="ml-auto flex items-center gap-1">+ {!opening && (+ <button type="button" onClick={() => set((s) => ({ ...s, turns: s.turns.filter((_, i) => i !== k - 1) }))} className="grid size-7 place-items-center rounded-md hover:bg-accent" aria-label={`Remove turn ${k}`}>+ <Trash2 className="size-3.5" />+ </button>+ )}+ </span>+ </div>+ <Textarea+ value={t.words}+ onChange={(e) => setTurn(k, { words: e.target.value.slice(0, opening ? WORLD_LIMITS.maxScene : WORLD_LIMITS.maxWords) })}+ rows={opening ? 3 : 2}+ placeholder={opening ? "The world it starts in: a stone path through a forest at dusk, blue fireflies between mossy trees, mist on the ground" : "What changes: a wooden bridge crosses a glowing stream ahead"}+ className="min-h-0 resize-none text-[13px]"+ aria-label={opening ? "The world, in words" : `Turn ${k}: what changes`}+ />+ {opening && (+ <div className="grid gap-2 sm:grid-cols-2">+ <Input value={w.opening.subject ?? ""} onChange={(e) => set((s) => ({ ...s, opening: { ...s.opening, subject: e.target.value.slice(0, 120) } }))} placeholder="Who the camera follows (optional): a small orange fox" className="h-8 text-[13px]" aria-label="Who the camera follows" />+ <Input value={w.opening.details ?? ""} onChange={(e) => set((s) => ({ ...s, opening: { ...s.opening, details: e.target.value.slice(0, WORLD_LIMITS.maxWords) } }))} placeholder="How they look (optional)" className="h-8 text-[13px]" aria-label="How they look" />+ </div>+ )}+ <Input value={t.action ?? ""} onChange={(e) => setTurn(k, { action: e.target.value.slice(0, WORLD_LIMITS.maxWords) })} placeholder={opening ? "What happens first (optional): the fox walks along the path" : "What they do (optional)"} className="h-8 text-[13px]" aria-label={opening ? "What happens first" : `Turn ${k}: what they do`} />+ <div className="flex flex-wrap items-center gap-2">+ {opening && (+ <>+ <select value={w.opening.perspective} onChange={(e) => set((s) => ({ ...s, opening: { ...s.opening, perspective: e.target.value as WorldScript["opening"]["perspective"] } }))} className={select} aria-label="Camera">+ {PERSPECTIVES.map((p) => (+ <option key={p.id} value={p.id}>+ {p.name}+ </option>+ ))}+ </select>+ <select value={w.opening.style} onChange={(e) => set((s) => ({ ...s, opening: { ...s.opening, style: e.target.value as WorldScript["opening"]["style"] } }))} className={select} aria-label="Look">+ {STYLES.map((p) => (+ <option key={p.id} value={p.id}>+ {p.name}+ </option>+ ))}+ </select>+ </>+ )}+ <select value={t.move} onChange={(e) => setTurn(k, { move: e.target.value })} className={cn(select, "font-medium")} aria-label={opening ? "Opening camera move" : `Turn ${k}: camera move`} title={WORLD_MOVES.find((m) => m.id === t.move)?.description}>+ {WORLD_MOVES.map((m) => (+ <option key={m.id} value={m.id}>+ {m.name}+ </option>+ ))}+ </select>+ <label className="flex items-center gap-1 text-[12.5px] text-muted-foreground">+ <Input+ type="number"+ min={WORLD_LIMITS.minSeconds}+ max={WORLD_LIMITS.maxSeconds}+ step={WORLD_LIMITS.step}+ value={t.seconds}+ onChange={(e) => setTurn(k, { seconds: Number(e.target.value) })}+ onBlur={() => setTurn(k, { seconds: clampSeconds(t.seconds) })}+ className="h-8 w-16 px-2 text-[12.5px] tabular-nums"+ aria-label={opening ? "Opening length in seconds" : `Turn ${k} length in seconds`}+ />+ s+ </label>+ </div>+ {clip?.url && <video src={clip.url} controls muted playsInline className="aspect-video w-full rounded-lg bg-black" aria-label={opening ? "The opening" : `Turn ${k}`} />}+ <div className="flex flex-wrap gap-1.5">+ {!clip && (+ <Button size="sm" onClick={() => run(k)} disabled={!runnable || busy !== null}>+ {busy === k ? <Loader2 className="size-3.5 animate-spin" /> : <Clapperboard className="size-3.5" />} Run {opening ? "the opening" : "turn"}+ </Button>+ )}+ {(clip || state === "stale") && (+ <Button size="sm" variant="outline" onClick={() => redo(k)} disabled={!canRun(w, clips, k) || busy !== null} title="Films this turn again and the ones after it; the turns before it stay. The same words and move give the same turn: change them for a different one">+ <RotateCcw className="size-3.5" /> Redo from here+ </Button>+ )}+ {!runnable && !clip && k > 0 && <span className="self-center text-[12px] text-muted-foreground">Runs once the turn before it is ready</span>}+ </div>+ </li>+ );+ };++ return (+ <Dialog open={open} onOpenChange={onOpenChange}>+ <DialogContent className="flex max-h-[100svh] w-full max-w-[calc(100%-1rem)] flex-col gap-0 overflow-hidden p-0 sm:max-h-[92svh] sm:max-w-2xl">+ <DialogHeader className="border-b px-4 pt-4 pb-3 text-left sm:px-5">+ <DialogTitle className="flex items-center gap-2 text-[16px]">+ <Globe className="size-4" /> World+ </DialogTitle>+ <DialogDescription className="text-[12.5px]">Describe a world once, then steer it turn by turn with words and camera moves. Each turn picks up where the last one stopped.</DialogDescription>+ </DialogHeader>+ <div className="min-h-0 flex-1 space-y-4 overflow-y-auto px-4 py-4 sm:px-5">+ {engine !== "open" && (+ <div className="flex flex-col gap-2 rounded-xl bg-muted/60 p-3 text-[12.5px] sm:flex-row sm:items-center">+ <p className="min-w-0 flex-1">+ <span className="font-medium">Runs on your GPU (open source).</span> World mode uses Hy-Nomas, which no cloud service offers yet.+ </p>+ {openAllowed && (+ <Button size="sm" variant="outline" onClick={() => onEngine("open")}>+ Use your GPU+ </Button>+ )}+ </div>+ )}+ <section className={section} aria-label="Turns">+ <div className="flex items-center justify-between gap-2">+ <h3 className={h3}>Turns</h3>+ <span className="text-[12px] text-muted-foreground tabular-nums">+ {total} s of {WORLD_LIMITS.maxTotal} s+ </span>+ </div>+ <div className="flex h-2 overflow-hidden rounded-full bg-muted" aria-hidden>+ {allTurns(w).map((t, k) => (+ <div key={k} style={{ width: `${(t.seconds / WORLD_LIMITS.maxTotal) * 100}%`, background: hue(k), opacity: states[k] === "done" ? 1 : 0.35 }} />+ ))}+ </div>+ <ol className="space-y-2">{allTurns(w).map((t, k) => turnCard(t, k))}</ol>+ <Button+ size="sm"+ variant="outline"+ onClick={() => set((s) => ({ ...s, turns: [...s.turns, newTurn()] }))}+ disabled={w.turns.length + 1 >= WORLD_LIMITS.maxTurns || total + newTurn().seconds > WORLD_LIMITS.maxTotal}+ >+ <Plus className="size-3.5" /> Add a turn+ </Button>+ </section>++ <section className={section} aria-label="Camera path">+ <div className="flex items-center justify-between gap-2">+ <h3 className={h3}>Camera path</h3>+ <Button size="sm" variant="ghost" onClick={() => setShowPath((v) => !v)} aria-expanded={showPath}>+ <Route className="size-3.5" /> {showPath ? "Hide the path" : "Preview the path"}+ </Button>+ </div>+ {showPath && <PathSketch sketch={sketch} />}+ </section>++ <section className={section} aria-label="Sound">+ <h3 className={h3}>Sound</h3>+ <p className="text-[12.5px] text-muted-foreground">Hy-Nomas films without sound. Add it to the finished film afterwards:</p>+ <div className="flex flex-wrap gap-1.5">+ <Button asChild size="sm" variant="outline">+ <Link href="/audio/video">+ <Volume2 className="size-3.5" /> Sound for video+ </Link>+ </Button>+ <Button asChild size="sm" variant="outline">+ <Link href="/audio/music">+ <Music className="size-3.5" /> Music+ </Link>+ </Button>+ </div>+ </section>+ </div>+ <div className="border-t px-4 py-3 sm:px-5">+ {!!plan.notes.length && engine === "open" && (+ <ul className="mb-2 space-y-0.5 text-[12px] text-muted-foreground">+ {plan.notes.map((n) => (+ <li key={n}>· {n}</li>+ ))}+ </ul>+ )}+ <div className="flex flex-wrap items-center gap-2">+ <p className="min-w-0 flex-1 text-[12.5px]">+ <span className="font-medium">{price}</span>+ <span className="text-muted-foreground"> · Hy-Nomas on your GPU · about {clipSeconds(allTurns(w)[target] ?? w.opening)} s a turn</span>+ {plan.blocker && <span className="block truncate text-[12px] text-muted-foreground">{plan.blocker}</span>}+ </p>+ <Button variant="outline" onClick={exportFilm} disabled={!exported || exported.length < 2 || busy !== null || engine !== "open"}>+ {busy === "export" ? <Loader2 className="size-4 animate-spin" /> : <Film className="size-4" />} Export+ </Button>+ {next >= 0 && (+ <Button onClick={() => run(next)} disabled={!!plan.blocker || !canRun(w, clips, next) || busy !== null}>+ {busy === next ? <Loader2 className="size-4 animate-spin" /> : <Clapperboard className="size-4" />} {next === 0 ? "Run the opening" : `Run turn ${next}`}+ </Button>+ )}+ </div>+ </div>+ </DialogContent>+ </Dialog>+ );+}++/** The camera's path from above: one line per turn in its colour, a dot where each turn starts, the camera's heading at the end. */+function PathSketch({ sketch }: { sketch: ReturnType<typeof pathSketch> }) {+ const { points, starts, headings } = sketch;+ const xs = points.map((p) => p[0]);+ const zs = points.map((p) => p[1]);+ const pad = 0.4;+ const minX = Math.min(...xs) - pad;+ const maxX = Math.max(...xs) + pad;+ const minZ = Math.min(...zs) - pad;+ const maxZ = Math.max(...zs) + pad;+ const size = Math.max(maxX - minX, maxZ - minZ, 1);+ const cx = (minX + maxX) / 2;+ const cz = (minZ + maxZ) / 2;+ const view = `${cx - size / 2} ${cz - size / 2} ${size} ${size}`;+ const stroke = size / 120;+ const segments = starts.map((s, k) => points.slice(s, (starts[k + 1] ?? points.length - 1) + 1));+ const last = points[points.length - 1];+ const yaw = headings[headings.length - 1] ?? 0;+ const arrow = size / 14;+ return (+ <figure className="space-y-1.5">+ <svg viewBox={view} className="aspect-square w-full max-w-[320px] rounded-xl border bg-muted/40" role="img" aria-label="The camera's path from above, one colour per turn">+ {segments.map((seg, k) => (+ <polyline key={k} points={seg.map((p) => p.join(",")).join(" ")} fill="none" stroke={hue(k)} strokeWidth={stroke * 2.2} strokeLinecap="round" strokeLinejoin="round" />+ ))}+ {starts.map((s, k) => (+ <circle key={k} cx={points[s][0]} cy={points[s][1]} r={stroke * 3} fill={hue(k)} />+ ))}+ {last && <line x1={last[0]} y1={last[1]} x2={last[0] - Math.sin(yaw) * arrow} y2={last[1] - Math.cos(yaw) * arrow} stroke="currentColor" strokeWidth={stroke * 1.6} strokeLinecap="round" />}+ </svg>+ <figcaption className="text-[12px] text-muted-foreground">Seen from above: the camera starts at the first dot; the line at the end shows where it looks.</figcaption>+ </figure>+ );+}diff --git a/src/lib/licences.ts b/src/lib/licences.tsindex 5218200e..3f4b014f 100644--- a/src/lib/licences.ts+++ b/src/lib/licences.ts@@ -548,6 +548,13 @@ export const NODE_PACKS: NodePack[] = [url: SPDX("Apache-2.0"),note: "Idol's crop modes, predicted camera and splat pruning; Apache-2.0 code, no model code; ports idol-sdk's preprocess and camera code (Apache-2.0)",}),+ // World mode (nm10-hy-nomas-world), pinned in workflows/comfyui/packs.json: the LICENSE and NOTICE files read at the pinned commit.+ pack("ComfyUI-HyNomas", "https://github.com/Nynxz/ComfyUI-HyNomas/tree/a89e0515619924da71093aa3fe52dbb7104cb06e", {+ name: "Apache-2.0",+ class: "commercial",+ url: SPDX("Apache-2.0"),+ note: "Hy-Nomas world generation on ComfyUI's own loaders; Apache-2.0 code reimplementing Tencent's Apache-2.0 model code. The Hy-Nomas DiT is Apache-2.0; the PixelUMM decoder it loads is under the NVIDIA One-Way Noncommercial License",+ }),// Krea 2's edits (the owner's SOTA image families, 2026-10-31).pack("comfyui-krea2edit", "https://github.com/lbouaraba/comfyui-krea2edit", {name: "Apache-2.0",diff --git a/src/lib/world.ts b/src/lib/world.tsindex 3316b8f0..f63933ce 100644--- a/src/lib/world.ts+++ b/src/lib/world.ts@@ -113,7 +113,8 @@ export function newWorld(seed = Math.floor(Math.random() * 2 ** 31)): WorldScrip};}-const clampSeconds = (s: number) => {+/** A turn's length as World mode takes it: on the half second, 3–12 s. */+export const clampSeconds = (s: number) => {const n = Number.isFinite(s) ? s : 5;return Math.min(WORLD_LIMITS.maxSeconds, Math.max(WORLD_LIMITS.minSeconds, Math.round(n / WORLD_LIMITS.step) * WORLD_LIMITS.step));};@@ -212,6 +213,46 @@ export function exportClips(script: WorldScript, clips: readonly (WorldClip | unreturn urls;}+/** What a World take carries (a Cinema take's generation and its take.world). */+export interface WorldTakeLike {+ id: string;+ status: string;+ createdAt: number;+ outputs?: { url: string; kind?: string }[];+ take?: { world?: { turn: number; made: string; joined?: boolean } };+}++/** A turn's status on the timeline. */+export type TurnState = "done" | "running" | "failed" | "stale" | "none";++/**+ * The clips of the script's turns from the project's takes: per turn, the newest take made from the script as it is now+ * (nothing up to that turn changed since), made after the turn's last Redo from here (`redoAt[k]`, ms). A take that+ * failed or was cancelled is not a clip. Also each turn's state, for the timeline.+ */+export function clipsFromTakes(script: WorldScript, takes: readonly WorldTakeLike[], redoAt: Readonly<Record<number, number>> = {}): { clips: (WorldClip | undefined)[]; states: TurnState[] } {+ const n = script.turns.length + 1;+ const clips: (WorldClip | undefined)[] = [];+ const states: TurnState[] = [];+ const sorted = [...takes].filter((t) => t.take?.world && !t.take.world.joined).sort((a, b) => b.createdAt - a.createdAt);+ for (let k = 0; k < n; k++) {+ const key = scriptKey(script, k);+ const since = Math.max(0, ...Object.entries(redoAt).filter(([i]) => Number(i) <= k).map(([, at]) => at));+ const mine = sorted.filter((t) => t.take!.world!.turn === k && t.createdAt >= since);+ const current = mine.find((t) => t.take!.world!.made === key && t.status !== "failed" && t.status !== "canceled");+ if (current) {+ const url = current.status === "succeeded" ? current.outputs?.find((o) => !o.kind || o.kind === "video")?.url : undefined;+ clips.push({ generationId: current.id, made: key, ...(url ? { url } : {}) });+ states.push(url ? "done" : current.status === "succeeded" ? "failed" : "running");+ continue;+ }+ clips.push(undefined);+ const last = mine[0];+ states.push(!last ? "none" : last.take!.world!.made !== key ? "stale" : last.status === "failed" ? "failed" : "none");+ }+ return { clips, states };+}+/** A turn's label for the timeline ("Opening", "Turn 2 · Arc 90° left · 5 s"). */export function turnLabel(t: WorldTurn, k: number): string {const move = WORLD_MOVES.find((m) => m.id === t.move)?.name ?? "Still";diff --git a/src/server/gpu/tools.ts b/src/server/gpu/tools.tsindex 8d81100b..28b1eaf8 100644--- a/src/server/gpu/tools.ts+++ b/src/server/gpu/tools.ts@@ -11,6 +11,7 @@ import { CLEAN_MODEL } from "@/lib/av/clean-voice";import { getModel, getPreset, MODELS, modelsFor, PRESETS } from "@/lib/catalog";import { graphLoras, PERSON_REMOVER_LORA } from "@/lib/catalog/character-swap";import { BLOCKOUT_MODELS, PATH_MODELS } from "@/lib/catalog/cinema";+import { WORLD_JOIN, WORLD_MODEL } from "@/lib/world";import { dualEngine, onEngine, runsOn } from "@/lib/catalog/engines";import { FRAMES_MODELS } from "@/lib/catalog/keyframes";import { PERSON_REMOVAL_TOOLS, REMOVE_TOOLS } from "@/lib/catalog/remove-object";@@ -266,6 +267,17 @@ export const STUDIO_ROWS: StudioRowDef[] = [{ modelId: "oss-join-encoded", op: "concat" },],},+ // World mode (nm10-hy-nomas-world): Cinema's World take, Hy-Nomas turn by turn on Nynxz's port, and the turns joined into+ // one film. The projects list takes ?world=1 on to the project picked, which opens the World panel.+ {+ href: "/cinema?world=1",+ label: "World mode",+ group: "Video",+ steps: [+ { modelId: WORLD_MODEL, op: "world-turn" },+ { modelId: WORLD_JOIN, op: "concat" },+ ],+ },// The turnaround (N7-6): Frames mode's start/end-frame clips joined into one film, with the sides it has no picture of// drawn first by the Angles app (src/lib/catalog/turnaround.ts).{diff --git a/tests/world-mode.test.ts b/tests/world-mode.test.tsnew file mode 100644index 00000000..e6977307--- /dev/null+++ b/tests/world-mode.test.ts@@ -0,0 +1,341 @@+import fs from "node:fs";+import os from "node:os";+import path from "node:path";+import { afterAll, beforeAll, describe, expect, it } from "vitest";+import type { CinemaGenerateInput } from "@/lib/catalog/cinema";+import type { ComfyWorkflow, Manifest } from "@/lib/comfy";+import type { WorldScript } from "@/lib/world";++/**+ * World mode (nm10-hy-nomas-world): Hy-Nomas's graph in the library (its pack and weights pinned, checked against the+ * port's node list, which isn't on the validation server), the graph rebuilt per turn, the turn state, the provider's+ * bindings, Cinema's World take (open engine only) and the GPU pre-flight row.+ */++const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-world-"));+process.env.FUOBE_DATA_DIR = tmp;+process.env.COMFYUI_URL = "http://127.0.0.1:9";+process.env.OLLAMA_URL = "http://127.0.0.1:9";++const { setSetting } = await import("@/server/settings");+const gens = await import("@/server/generations");+const cinema = await import("@/server/cinema");+const generateRoute = await import("@/app/api/cinema/projects/[id]/generate/route");+const { prepareWorkflow } = await import("@/server/providers/comfyui");+const { STUDIO_ROWS } = await import("@/server/gpu/tools");+const { getModel, getPreset } = await import("@/lib/catalog");+const { planGeneration } = await import("@/lib/catalog/plan");+const { planCinema, WORLD_OPEN_ONLY, WORLD_SOUND } = await import("@/lib/catalog/cinema");+const { NODE_PACKS } = await import("@/lib/licences");+const W = await import("@/lib/world");+const { parseScript } = await import("@/lib/world-path");++beforeAll(() => {+ setSetting("demoMode", "auto");+ setSetting("enhanceProvider", "none");+});+afterAll(() => fs.rmSync(tmp, { recursive: true, force: true }));++const dir = path.join(process.cwd(), "workflows/comfyui");+const read = <T>(f: string) => JSON.parse(fs.readFileSync(path.join(dir, f), "utf8")) as T;+const manifest = read<Manifest>("manifest.json");+const packs = read<Record<string, { repo: string; commit: string; subdir: string | null; registry: unknown }>>("packs.json");+const pins = read<Record<string, { revision: string; sizeBytes: number; sha256?: string }>>("model-pins.json");+const requirements = read<{ workflows: Record<string, { packs: Record<string, string[]>; files: string[]; optional: string[]; vramGb: number }> }>("requirements.json");+type Info = { python_module: string; input: { required: Record<string, [unknown, Record<string, unknown>?]>; optional?: Record<string, [unknown, Record<string, unknown>?]> }; output: string[] };+const subset = read<Record<string, Info>>("object_info.subset.json");+const ID = "world-hy-nomas-turn";+const entry = manifest.workflows.find((w) => w.id === ID)!;+const template = read<ComfyWorkflow>(`${ID}.json`);++/** The inputs of the port's nodes at a89e0515 (nomas/nodes.py define_schema). */+const PORT_NODES: Record<string, string[]> = {+ NomasWorldPrompt: ["perspective", "style", "subject", "subject_details", "scene", "action", "seconds"],+ NomasCameraPath: ["script"],+ NomasWorldGenerate: ["model", "clip", "turn", "camera", "seed", "width", "height", "steps", "history"],+ NomasWorldContinue: ["model", "clip", "world", "change", "action", "camera", "seconds", "steps"],+};++/** ComfyUI's own check of a prompt, against the node list: known classes, known inputs, required ones present, links typed. */+function validate(wf: ComfyWorkflow): string[] {+ const problems: string[] = [];+ for (const [id, n] of Object.entries(wf)) {+ const info = subset[n.class_type];+ if (!info) {+ problems.push(`${id}: ${n.class_type} unknown`);+ continue;+ }+ const all = { ...info.input.required, ...(info.input.optional ?? {}) };+ for (const [k, v] of Object.entries(n.inputs)) {+ if (k.includes(".")) continue; // dynamic combo children (SaveVideo format.codec)+ const spec = all[k];+ if (!spec) problems.push(`${id}.${k}: not an input of ${n.class_type}`);+ else if (Array.isArray(v) && typeof v[0] === "string" && typeof v[1] === "number") {+ const from = wf[v[0]];+ if (!from) problems.push(`${id}.${k}: links to missing node ${v[0]}`);+ else {+ const out = subset[from.class_type]?.output?.[v[1]];+ const want = spec[0];+ if (typeof want === "string" && want !== "*" && out !== want) problems.push(`${id}.${k}: ${out} into ${want}`);+ }+ } else if (/_name$/.test(k)) continue; // a model file: the validation server lists placeholders, not the weights+ else if (Array.isArray(spec[0]) && !spec[0].includes(v as never) && (spec[0] as unknown[]).length) problems.push(`${id}.${k}: ${String(v)} not offered`);+ else if (spec[0] === "COMBO" && !(spec[1]?.options as unknown[] | undefined)?.some((o) => o === v || (o as { key?: unknown })?.key === v)) problems.push(`${id}.${k}: ${String(v)} not offered`);+ }+ for (const k of Object.keys(info.input.required)) if (!(k in n.inputs)) problems.push(`${id}.${k}: required, missing`);+ }+ return problems;+}++const script = (over: Partial<WorldScript> = {}): WorldScript =>+ W.normalizeWorld({+ opening: { words: "A small orange fox stands on a stone path in a forest at dusk.", subject: "a small orange fox", details: "Orange fur, a white chest.", action: "The fox walks along the path.", move: "zoom_in", seconds: 5 },+ turns: [+ { words: "a wooden bridge crosses a glowing stream ahead", action: "a small orange fox trots onto the bridge", move: "orbit_90_ccw", seconds: 4 },+ { words: "rain begins to fall", move: "still", seconds: 3 },+ ],+ seed: 1234,+ ...over,+ });++describe("Hy-Nomas's graph in the library", () => {+ it("waits for the pinned port, lists its weights pinned, and says each file's licence", () => {+ expect(entry.capability).toBe("world-turn");+ expect(entry.expand).toBe("world");+ expect(entry.validated).toBe(false);+ expect(entry.customNodes.map((c) => c.name)).toEqual(["ComfyUI-HyNomas"]);+ expect(packs["ComfyUI-HyNomas"]).toMatchObject({ repo: "https://github.com/Nynxz/ComfyUI-HyNomas", commit: "a89e0515619924da71093aa3fe52dbb7104cb06e", registry: null });+ expect(entry.license).toMatch(/^Apache-2\.0 \(Hy-Nomas DiT/);+ expect(entry.license).toMatch(/NVIDIA One-Way Noncommercial License \(NON-COMMERCIAL/);+ expect(entry.vramGb).toBe(24);+ const files = entry.models.filter((m) => !m.optional);+ expect(files.map((m) => m.file).sort()).toEqual(["nomas_dit_distilled_int8_convrot.safetensors", "nomas_pixelumm_vae_bf16.safetensors", "qwen_2.5_vl_7b.safetensors"]);+ // About 25 GB of new files beside the text encoder Qwen-Image already pins.+ const own = files.filter((m) => m.file.startsWith("nomas_")).reduce((s, m) => s + (m.sizeGb ?? 0), 0);+ expect(own).toBeGreaterThan(24);+ expect(own).toBeLessThan(25.5);+ for (const m of entry.models.filter((x) => x.file.startsWith("nomas_"))) {+ const pin = pins[m.url!];+ expect(pin, m.file).toMatchObject({ revision: "e8ddc4bfa664d69213930552493c220c3af56f41" });+ expect(pin.sha256).toMatch(/^[0-9a-f]{64}$/);+ }+ expect(requirements.workflows[ID].packs["ComfyUI-HyNomas"]).toEqual(["NomasCameraPath", "NomasWorldContinue", "NomasWorldGenerate", "NomasWorldPrompt"]);+ expect(requirements.workflows[ID].optional).toEqual(["diffusion_models/nomas_dit_distilled_bf16.safetensors"]);+ const sh = fs.readFileSync(path.join(process.cwd(), "scripts/comfy/install-comfyui.sh"), "utf8");+ expect(sh).toContain(`[ComfyUI-HyNomas]="https://github.com/Nynxz/ComfyUI-HyNomas ${packs["ComfyUI-HyNomas"].commit}"`);+ const pack = NODE_PACKS.find((p) => p.name === "ComfyUI-HyNomas")!;+ expect(pack).toBeTruthy();+ expect(JSON.stringify(pack)).toMatch(/Apache-2\.0/);+ });++ it("follows the port's node list, and the template passes ComfyUI's checks against it", () => {+ for (const [cls, inputs] of Object.entries(PORT_NODES)) {+ expect(subset[cls].python_module).toBe("custom_nodes.ComfyUI-HyNomas");+ expect(Object.keys({ ...subset[cls].input.required, ...subset[cls].input.optional }).sort()).toEqual([...inputs].sort());+ }+ expect(subset.NomasWorldGenerate.output).toEqual(["LATENT", "NOMAS_WORLD"]);+ expect(validate(template)).toEqual([]);+ expect(template["2"].inputs).toMatchObject({ clip_name: "qwen_2.5_vl_7b.safetensors", type: "qwen_image" });+ expect(template["6"].inputs).toMatchObject({ width: 1280, height: 704, steps: 8, history: "window" });+ });+});++describe("the graph for one turn", () => {+ it("chains the opening and every turn up to the one asked for, and saves that turn alone", () => {+ const s = script();+ for (let k = 0; k <= 2; k++) {+ const wf = W.expandWorldWorkflow(template, s, k);+ expect(validate(wf), `turn ${k}`).toEqual([]);+ const turns = Object.entries(wf).filter(([, n]) => n.class_type === "NomasWorldContinue");+ expect(turns.map(([id]) => id)).toEqual(Array.from({ length: k }, (_, i) => `w${i + 1}`));+ expect(wf["9"].inputs).toEqual({ samples: [k ? `w${k}` : "w0", 0], trim_amount: W.latentsBefore(s, k) });+ }+ });++ it("gives the same nodes the same ids and inputs every time, so ComfyUI reuses the turns it already made", () => {+ const s = script();+ const a = W.expandWorldWorkflow(template, s, 1);+ const b = W.expandWorldWorkflow(template, s, 2);+ for (const id of ["o", "c0", "w0", "c1", "w1"]) expect(b[id], id).toEqual(a[id]);+ // Changing turn 2 leaves the opening and turn 1 as they were.+ const c = W.expandWorldWorkflow(template, { ...s, turns: [s.turns[0], { ...s.turns[1], words: "snow begins to fall" }] }, 2);+ for (const id of ["o", "c0", "w0", "c1", "w1"]) expect(c[id], id).toEqual(b[id]);+ expect(c.w2.inputs.change).toBe("snow begins to fall");+ });++ it("writes the subject as the port's token, places it in view, and leaves a still turn without a camera", () => {+ const wf = W.expandWorldWorkflow(template, script(), 2);+ expect(wf.o.inputs).toMatchObject({ subject: "a small orange fox", scene: "<|Subject1|> stands on a stone path in a forest at dusk.", action: "The fox walks along the path.", seconds: 5, perspective: "third-person follow" });+ expect(wf.w1.inputs).toMatchObject({ change: "a wooden bridge crosses a glowing stream ahead", action: "<|Subject1|> trots onto the bridge", seconds: 4, world: ["w0", 1], camera: ["c1", 0] });+ expect(wf.w2.inputs.camera).toBeUndefined();+ expect(wf.c2).toBeUndefined();+ expect(parseScript(String(wf.c0.inputs.script))).toHaveLength(5 * 24);+ expect(parseScript(String(wf.c1.inputs.script))).toHaveLength(4 * 24);+ expect(W.openingInputs({ words: "A misty valley at dawn.", move: "still", seconds: 5, subject: "a heron" }).scene).toBe("A misty valley at dawn. <|Subject1|> is in view.");+ expect(W.openingInputs({ words: "A misty valley at dawn.", move: "still", seconds: 5 }).subject).toBe("the camera");+ });++ it("counts each turn's latent frames as the port does", () => {+ // A camera move makes frames + 1 poses: 5 s → 120 ticks → 121 frames → 31 latents. Words alone: 120 frames → 30.+ expect(W.turnLatents({ move: "zoom_in", seconds: 5 })).toBe(31);+ expect(W.turnLatents({ move: "still", seconds: 5 })).toBe(30);+ expect(W.turnLatents({ move: "still", seconds: 3 })).toBe(18);+ expect(W.latentsBefore(script(), 2)).toBe(31 + 25);+ expect(W.clipSeconds({ move: "still", seconds: 3 })).toBe(3);+ });++ it("refuses a script it can't run", () => {+ expect(() => W.expandWorldWorkflow(template, script({ opening: { words: "", move: "still", seconds: 5 } }), 0)).toThrow(/Describe the world first/);+ expect(() => W.expandWorldWorkflow(template, script(), 5)).toThrow(/isn't in this world/);+ const empty = script({ turns: [{ words: "", move: "still", seconds: 5 }] });+ expect(W.worldProblem(empty, 1)).toMatch(/needs words or a camera move/);+ // Ten turns of 12 s are the whole 120 s the port's noise bank holds: the longest world fits.+ const long = script({ opening: { words: "A plain.", move: "still", seconds: 12 }, turns: Array.from({ length: 12 }, () => ({ words: "on", move: "still", seconds: 12 })) });+ expect(long.turns).toHaveLength(9);+ expect(W.worldSeconds(long)).toBe(120);+ expect(W.worldProblem(long, 9)).toBeNull();+ });+});++describe("the turn state", () => {+ const s = script();+ const take = (id: string, turn: number, made: string, status = "succeeded", createdAt = 1000, url = `/api/files/${id}.mp4`) => ({+ id,+ status,+ createdAt,+ outputs: status === "succeeded" ? [{ url, kind: "video" }] : [],+ take: { world: { turn, made } },+ });++ it("tidies a script: lengths on the half second within 3–12 s, known moves, at most 10 turns", () => {+ const n = W.normalizeWorld({ opening: { words: " x ", move: "warp", seconds: 1.3 }, turns: Array.from({ length: 12 }, () => ({ words: "y", move: "orbit_360", seconds: 20.2 })), seed: -1 });+ expect(n.opening).toMatchObject({ words: "x", move: "still", seconds: 3 });+ expect(n.turns).toHaveLength(9);+ expect(n.turns[0]).toMatchObject({ move: "orbit_360", seconds: 12 });+ expect(n.seed).toBe(0);+ });++ it("keeps a turn's clip only while nothing up to it has changed", () => {+ const takes = [take("a", 0, W.scriptKey(s, 0)), take("b", 1, W.scriptKey(s, 1))];+ let r = W.clipsFromTakes(s, takes);+ expect(r.states).toEqual(["done", "done", "none"]);+ expect(W.nextTurn(s, r.clips)).toBe(2);+ expect(W.canRun(s, r.clips, 2)).toBe(true);+ // Turn 1's words change: its clip and everything after it are out of date; the opening stays.+ const edited = { ...s, turns: [{ ...s.turns[0], words: "a stone bridge" }, s.turns[1]] };+ r = W.clipsFromTakes(edited, takes);+ expect(r.states).toEqual(["done", "stale", "none"]);+ expect(W.nextTurn(edited, r.clips)).toBe(1);+ expect(W.canRun(edited, r.clips, 2)).toBe(false);+ });++ it("says a turn is filming until its clip arrives, and doesn't count a failed one", () => {+ const r = W.clipsFromTakes(s, [take("a", 0, W.scriptKey(s, 0), "running"), take("b", 1, W.scriptKey(s, 1), "failed")]);+ expect(r.states.slice(0, 2)).toEqual(["running", "failed"]);+ expect(r.clips[0]).toMatchObject({ generationId: "a" });+ expect(r.clips[0]?.url).toBeUndefined();+ expect(W.canRun(s, r.clips, 1)).toBe(false);+ });++ it("Redo from here keeps the turns before it and drops the clips from it on", () => {+ const takes = [take("a", 0, W.scriptKey(s, 0), "succeeded", 1000), take("b", 1, W.scriptKey(s, 1), "succeeded", 1000), take("c", 2, W.scriptKey(s, 2), "succeeded", 1000)];+ const r = W.clipsFromTakes(s, takes, { 1: 5000 });+ expect(r.clips.map((c) => c?.generationId)).toEqual(["a", undefined, undefined]);+ expect(W.redoFrom(W.clipsFromTakes(s, takes).clips, 1).map((c) => c?.generationId)).toEqual(["a"]);+ // The new take of turn 1 counts again.+ const again = W.clipsFromTakes(s, [...takes, take("d", 1, W.scriptKey(s, 1), "succeeded", 6000)], { 1: 5000 });+ expect(again.clips.map((c) => c?.generationId)).toEqual(["a", "d", undefined]);+ });++ it("exports only when every turn has a finished, current clip", () => {+ const done = [0, 1, 2].map((k) => take(`t${k}`, k, W.scriptKey(s, k)));+ expect(W.exportClips(s, W.clipsFromTakes(s, done).clips)).toEqual(["/api/files/t0.mp4", "/api/files/t1.mp4", "/api/files/t2.mp4"]);+ expect(W.exportClips(s, W.clipsFromTakes(s, done.slice(0, 2)).clips)).toBeNull();+ });+});++describe("the provider", () => {+ it("rebuilds the graph for the turn asked for, on the script's own seed", async () => {+ const s = script();+ const out = await prepareWorkflow(ID, { prompt: "", seed: 7, extra: { world: s, turn: 2 } }, { generationId: "g-world", op: "world-turn", upload: async (_d, _t, name) => `up_${name}` });+ const wf = out.workflow;+ expect(wf.w0.inputs).toMatchObject({ seed: 1234, width: 1280, height: 704, steps: 8, history: "window", turn: ["o", 0], camera: ["c0", 0] });+ expect(wf.w2.inputs).toMatchObject({ world: ["w1", 1], change: "rain begins to fall", seconds: 3 });+ expect(wf["9"].inputs.trim_amount).toBe(56);+ expect(wf["12"].inputs.filename_prefix).toBe("fuobe/g-world");+ expect(validate(wf)).toEqual([]);+ });++ it("refuses a run with no script, or a turn it doesn't have", async () => {+ const ctx = { generationId: "g", op: "world-turn" as const, upload: async () => "x" };+ await expect(prepareWorkflow(ID, { prompt: "", extra: {} }, ctx)).rejects.toThrow(/Describe the world first/);+ await expect(prepareWorkflow(ID, { prompt: "", extra: { world: script(), turn: 4 } }, ctx)).rejects.toThrow(/isn't in this world/);+ });++ it("plans as a free open-engine run with the script's words checked", () => {+ const model = getModel(W.WORLD_MODEL)!;+ expect(model.engine).toBe("open");+ expect(model.hidden).toBe(true);+ expect(model.routes.map((r) => [r.provider, r.endpoint, r.op])).toEqual([["comfyui", ID, "world-turn"]]);+ const ok = planGeneration({ feature: "cinema-world", modelId: model.id, op: "world-turn", params: { numOutputs: 1, extra: { world: script(), turn: 1 } } } as never, getModel, getPreset);+ expect(ok).toBeTruthy();+ expect(() => planGeneration({ feature: "cinema-world", modelId: model.id, op: "world-turn", params: { numOutputs: 1, extra: {} } } as never, getModel, getPreset)).toThrow(/Describe the world first/);+ });+});++describe("Cinema's World take", () => {+ const ctx = { cloudAllowed: true };+ const take = (engine: "open" | "cloud", world: CinemaGenerateInput["world"]): CinemaGenerateInput => ({ engine, mode: "video", action: "world", prompt: "", settings: {}, world });++ it("runs on your GPU only: the cloud says so and offers no stand-in", () => {+ const plan = planCinema(take("cloud", { script: script(), turn: 0 }), ctx);+ expect(plan.blocker).toBe(WORLD_OPEN_ONLY);+ expect(plan.steps).toEqual([]);+ });++ it("plans one turn: free, 1280 × 704 at 24 fps, no sound", () => {+ const plan = planCinema(take("open", { script: script(), turn: 1 }), ctx);+ expect(plan.blocker).toBeUndefined();+ expect(plan.costUsd).toBe(0);+ expect(plan.model.id).toBe(W.WORLD_MODEL);+ expect(plan.steps).toHaveLength(1);+ expect(plan.steps[0].request).toMatchObject({ feature: "cinema-world", op: "world-turn", params: { extra: { turn: 1 } } });+ expect(plan.notes.join(" ")).toMatch(/Turn 1 of 2 on your GPU/);+ expect(plan.notes).toContain(WORLD_SOUND);+ });++ it("exports the turns as one film with the open engine's join", () => {+ const plan = planCinema(take("open", { script: script(), turn: 2, join: ["/api/files/a.mp4", "/api/files/b.mp4", "/api/files/c.mp4"] }), ctx);+ expect(plan.blocker).toBeUndefined();+ expect(plan.steps[0].request).toMatchObject({ modelId: W.WORLD_JOIN, op: "concat", inputs: { videos: ["/api/files/a.mp4", "/api/files/b.mp4", "/api/files/c.mp4"] } });+ });++ it("files a turn in demo mode as a take that remembers its turn and script", async () => {+ const p = cinema.createProject({ name: "Worlds" });+ const req = new Request("http://x/api", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ input: take("open", { script: script(), turn: 0 }) }) });+ const res = await generateRoute.POST(req, { params: Promise.resolve({ id: p.id }) });+ expect(res.status).toBe(201);+ const out = (await res.json()) as { items: { id: string; feature: string; op: string }[] };+ expect(out.items).toHaveLength(1);+ expect(out.items[0]).toMatchObject({ feature: "cinema-world", op: "world-turn" });+ const item = cinema.listItems(p.id)[0];+ expect(item.take?.action).toBe("world");+ expect(item.take?.world).toMatchObject({ turn: 0, made: W.scriptKey(script(), 0) });+ expect(item.take?.world?.script.turns).toEqual([]);+ expect(gens.getGeneration(out.items[0].id)!.provider).toBe("mock");+ // The cloud is refused before anything runs.+ const cloud = new Request("http://x/api", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ input: take("cloud", { script: script(), turn: 0 }) }) });+ const refused = await generateRoute.POST(cloud, { params: Promise.resolve({ id: p.id }) });+ expect(refused.status).toBe(422);+ });++ it("has a row on the GPU pre-flight board", () => {+ const row = STUDIO_ROWS.find((r) => r.href === "/cinema?world=1")!;+ expect(row).toMatchObject({ label: "World mode", group: "Video" });+ expect(row.steps?.map((s) => [s.modelId, s.op])).toEqual([+ [W.WORLD_MODEL, "world-turn"],+ [W.WORLD_JOIN, "concat"],+ ]);+ expect(new Set(STUDIO_ROWS.map((r) => r.href)).size).toBe(STUDIO_ROWS.length);+ });+});