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
N7-6: /api/turnaround and Cinema's "turnaround" action
Claudedb7deaec83c5
diff --git a/src/app/api/turnaround/route.ts b/src/app/api/turnaround/route.tsnew file mode 100644index 00000000..02863f14--- /dev/null+++ b/src/app/api/turnaround/route.ts@@ -0,0 +1,26 @@+import { z } from "zod";+import { recordExists } from "@/server/records";+import { body, handle, once } from "@/server/shorts-schemas";+import { createTurnaround, previewTurnaround, TurnaroundSchema } from "@/server/turnaround";++const Body = TurnaroundSchema.extend({+ /** Made from a character's page: the film goes into that character's feed. */+ elementId: z.string().max(40).optional(),+ /** A repeated requestId (a second click) gets the run the first one started. */+ requestId: z.string().max(80).optional(),+});++/**+ * Turnaround video (build plan N7-6): a 360° turnaround of a cast sheet or a character, on either engine. `?preview=1` plans+ * and prices it (the route, the pictures drawn first, the film's frames, the GPU it needs) without running it.+ */+export async function POST(request: Request) {+ return handle(async () => {+ const { elementId, requestId, ...input } = await body(request, Body, "Pick the engine and the character's pictures");+ if (elementId && !recordExists({ kind: "element", ids: [elementId] })) return Response.json({ error: "Character not found" }, { status: 404 });+ const run = { ...input, ...(elementId && { feature: `element:${elementId}` }) };+ if (new URL(request.url).searchParams.get("preview")) return Response.json(previewTurnaround(run));+ const result = await once("turnaround", requestId, () => createTurnaround(run));+ return Response.json(result, { status: 201 });+ });+}diff --git a/src/components/cinema/cinema-feed.tsx b/src/components/cinema/cinema-feed.tsxindex 5238a626..2c111f85 100644--- a/src/components/cinema/cinema-feed.tsx+++ b/src/components/cinema/cinema-feed.tsx@@ -156,10 +156,10 @@ function dayLabel(ts: number): string {return d.toLocaleDateString(undefined, { weekday: diff < 7 ? "long" : undefined, month: "short", day: "numeric", year: d.getFullYear() === today.getFullYear() ? undefined : "numeric" });}-const FEATURE_TITLES: Record<string, string> = { "cinema-scene": "3D scene", "cinema-recompose": "Recomposed view", "cinema-path": "Fly path" };+const FEATURE_TITLES: Record<string, string> = { "cinema-scene": "3D scene", "cinema-recompose": "Recomposed view", "cinema-path": "Fly path", "cinema-turnaround": "Turnaround" };const promptOf = (g: CinemaGeneration) => g.take?.prompt?.trim() || FEATURE_TITLES[g.feature] || g.request.prompt?.trim() || g.prompt || "Untitled";-const STEP_HINT: Record<string, string> = { "cinema-cast": "Cast", "cinema-location": "Location", "cinema-grid": "Grid", "cinema-scene": "3D scene", "cinema-recompose": "Recomposed", "cinema-path": "Fly path" };+const STEP_HINT: Record<string, string> = { "cinema-cast": "Cast", "cinema-location": "Location", "cinema-grid": "Grid", "cinema-scene": "3D scene", "cinema-recompose": "Recomposed", "cinema-path": "Fly path", "cinema-turnaround": "Turnaround" };function Badge({ children, className }: { children: React.ReactNode; className?: string }) {return <span className={cn("inline-flex h-5 items-center rounded-full bg-black/50 px-1.5 text-[10.5px] font-medium text-white backdrop-blur", className)}>{children}</span>;diff --git a/src/lib/catalog/cinema.ts b/src/lib/catalog/cinema.tsindex 3513088e..260b4e02 100644--- a/src/lib/catalog/cinema.ts+++ b/src/lib/catalog/cinema.ts@@ -7,6 +7,7 @@ import { localOnly, needsToken, triggerOf } from "./loras";import { ANGLES_2511_LORA } from "./open-tools";import { composeShots, estimateCost, planGeneration, routesFor } from "./plan";import { soulRecipe } from "./soul";+import { planTurnaround, type TurnaroundInput } from "./turnaround";import { CAST_LOOK } from "./soul-cards";import type { Engine, GenerationRequest, GenParams, LoraRef, ModelDef, Operation } from "./types";@@ -198,7 +199,7 @@ export interface DirectorMessage {}export type CinemaMode = "video" | "image";-export type CinemaAction = "generate" | "extend-forward" | "extend-backward" | "edit" | "grid" | "cast" | "location" | "location-view" | "scene" | "recompose" | "path";+export type CinemaAction = "generate" | "extend-forward" | "extend-backward" | "edit" | "grid" | "cast" | "location" | "location-view" | "scene" | "recompose" | "path" | "turnaround";export type GridSize = "2x2" | "3x3" | "4x4";export type GridType = "freeform" | "zooms" | "shots" | "next_shots" | "prev_shots";export type CastValues = Record<string, string | number | string[] | undefined>;@@ -234,6 +235,8 @@ export interface CinemaGenerateInput {capture?: SceneCapture;/** "path": the camera path keyframed in the 3D scene (and, on the open engine, the browser's render along it). */path?: ScenePath;+ /** "turnaround": a 360° turnaround of a Soul Cast result (build plan N7-6: src/lib/catalog/turnaround.ts). */+ turnaround?: Omit<TurnaroundInput, "engine" | "feature" | "stepFeature">;}export interface ScenePath {@@ -1371,6 +1374,7 @@ const FEATURES: Partial<Record<CinemaAction, string>> = {scene: "cinema-scene",recompose: "cinema-recompose",path: "cinema-path",+ turnaround: "cinema-turnaround",};const feature = (action: CinemaAction, mode: CinemaMode) => FEATURES[action] ?? (mode === "image" ? "cinema-image" : "cinema");@@ -2036,6 +2040,15 @@ export function pathTake(input: Pick<CinemaGenerateInput, "engine" | "path">, plreturn { keys: params?.cameraPath ?? normalizeKeys(input.path?.keys ?? []), duration, ...(input.path?.preset ? { preset: input.path.preset } : {}) };}+// ---------------------------------------------------------------------------+// Turnaround (build plan N7-6): a Soul Cast result filmed all the way round, as a new take in the project++/** The turnaround's own steps (src/lib/catalog/turnaround.ts), filed as Cinema takes and priced as Cinema prices them. */+function planTurnaroundTake(input: CinemaGenerateInput, ctx: CinemaContext): CinemaPlan {+ const plan = planTurnaround({ ...input.turnaround, engine: input.engine, feature: "cinema-turnaround", stepFeature: "cinema-turnaround" }, { has: ctx.has });+ return finish(plan.model, plan.steps, plan.notes, plan.blocker);+}+/** Everything a Generate press would run, priced, without running it (the browser shows it live). */export function planCinema(input: CinemaGenerateInput, ctx: CinemaContext): CinemaPlan {const i = { ...input, settings: input.settings ?? {}, prompt: input.prompt ?? "" };@@ -2058,6 +2071,8 @@ export function planCinema(input: CinemaGenerateInput, ctx: CinemaContext): Cinereturn planRecompose(i);case "path":return planPath(i);+ case "turnaround":+ return planTurnaroundTake(i, ctx);default:return i.mode === "image" ? planStill(i) : planVideo(i, ctx);}diff --git a/src/lib/catalog/turnaround.ts b/src/lib/catalog/turnaround.tsindex 789e0e37..5a58a925 100644--- a/src/lib/catalog/turnaround.ts+++ b/src/lib/catalog/turnaround.ts@@ -272,8 +272,10 @@ export interface TurnaroundInput {prompt?: string;/** The character's name, for the title. */name?: string;- /** Where the takes are filed (the feature of every step); default "turnaround". */+ /** Where the film is filed (its feature); default "turnaround". */feature?: string;+ /** The feature of the pictures drawn first (a helper "-step" feature by default, so feeds show the film, not its parts). */+ stepFeature?: string;seed?: number;}@@ -384,6 +386,7 @@ export function planTurnaround(input: TurnaroundInput, ctx: TurnaroundContext =const info = TURN_ROUTES[route];const model = getModel(info.modelId)!;const feature = input.feature ?? "turnaround";+ const stepFeature = input.stepFeature ?? "turnaround-step";const views: Partial<Record<TurnSide, string>> = {};for (const s of TURN_SIDES) if (input.views?.[s]) views[s] = input.views[s];const sheet = input.sheet || undefined;@@ -402,7 +405,7 @@ export function planTurnaround(input: TurnaroundInput, ctx: TurnaroundContext =steps.push({key: "front",request: {- feature,+ feature: stepFeature,modelId: m.id,op: "edit",prompt: SHEET_FRONT_PROMPT,@@ -418,9 +421,9 @@ export function planTurnaround(input: TurnaroundInput, ctx: TurnaroundContext =const horizontal = anglesHorizontal(side);const request: GenerationRequest =engine === "cloud"- ? { feature, modelId: fillModel.id, op: "edit", prompt: FILL_KEEP, params: { numOutputs: 1, extra: { horizontal_angle: horizontal, vertical_angle: 0, zoom: 5 } } }+ ? { feature: stepFeature, modelId: fillModel.id, op: "edit", prompt: FILL_KEEP, params: { numOutputs: 1, extra: { horizontal_angle: horizontal, vertical_angle: 0, zoom: 5 } } }: {- feature,+ feature: stepFeature,modelId: fillModel.id,op: "edit",prompt: `<sks> ${poseWords({ horizontal, vertical: 0, zoom: 5 })}. ${FILL_KEEP}`,diff --git a/src/server/cinema-schemas.ts b/src/server/cinema-schemas.tsindex fff6d4e1..fe1968fe 100644--- a/src/server/cinema-schemas.ts+++ b/src/server/cinema-schemas.ts@@ -3,6 +3,7 @@ import { z } from "zod";import { DISTANCE, MAX_KEYS } from "@/lib/camera-path";import { APERTURE, LENS } from "@/lib/scene3d";import { CinemaError } from "./cinema";+import { TurnaroundSchema } from "./turnaround";/** Request bodies of /api/cinema/** (zod drops unknown keys). */@@ -80,7 +81,7 @@ export const GenerateBody = z.object({input: z.object({engine: z.enum(["cloud", "open"]),mode: z.enum(["video", "image"]),- action: z.enum(["generate", "extend-forward", "extend-backward", "edit", "grid", "cast", "location", "location-view", "scene", "recompose", "path"]).default("generate"),+ action: z.enum(["generate", "extend-forward", "extend-backward", "edit", "grid", "cast", "location", "location-view", "scene", "recompose", "path", "turnaround"]).default("generate"),modelId: z.string().max(80).optional(),prompt: z.string().max(60_000).default(""),moves: z.array(z.string().max(40)).max(12).optional(),@@ -138,6 +139,8 @@ export const GenerateBody = z.object({preset: z.string().max(40).optional(),}).optional(),+ // Turnaround (N7-6): the Soul Cast result's pictures by side, the route and length (the engine is the run's).+ turnaround: TurnaroundSchema.omit({ engine: true, realPerson: true, consent: true }).optional(),}),});diff --git a/src/server/turnaround.ts b/src/server/turnaround.tsnew file mode 100644index 00000000..f964eeed--- /dev/null+++ b/src/server/turnaround.ts@@ -0,0 +1,185 @@+import "server-only";+import { nanoid } from "nanoid";+import { z } from "zod";+import { getModel } from "@/lib/catalog";+import { routesFor } from "@/lib/catalog/plan";+import { planTurnaround, type TurnaroundContext, type TurnaroundInput, type TurnaroundPlan, type TurnStep } from "@/lib/catalog/turnaround";+import type { Generation } from "@/lib/catalog/types";+import { cancelGeneration, createGenerations, previewChained, previewGeneration } from "./generations";+import { isOffered } from "./model-access";+import { loadManifest } from "./providers/comfyui";++/**+ * Turnaround video (build plan N7-6): the plan from src/lib/catalog/turnaround.ts, checked step by step on this install+ * (keys, demo mode, Settings → Models & licences, the engine mode) and run as one batch. The Character Sheet page and a+ * character's page call it through /api/turnaround; Cinema runs the same steps as its "turnaround" action.+ */++const FileRef = z.string().startsWith("/api/files/").max(300);++/** A turnaround as API clients send it (the Character Sheet page, a character's page, Cinema's Soul Cast, the eval harness). */+export const TurnaroundSchema = z.object({+ engine: z.enum(["cloud", "open"]),+ views: z.object({ front: FileRef.optional(), right: FileRef.optional(), back: FileRef.optional(), left: FileRef.optional() }).default({}),+ sheet: FileRef.optional(),+ route: z.enum(["frames", "references", "keyframes", "camera"]).optional(),+ fill: z.boolean().optional(),+ path: z.string().max(40).optional(),+ duration: z.number().min(1).max(30).optional(),+ aspectRatio: z.enum(["9:16", "16:9"]).optional(),+ prompt: z.string().max(1000).optional(),+ name: z.string().max(60).optional(),+ seed: z.number().int().min(0).max(4_294_967_295).optional(),+ realPerson: z.boolean().optional(),+ consent: z.boolean().optional(),+});++export class TurnaroundError extends Error {+ constructor(+ message: string,+ public status = 422,+ ) {+ super(message);+ }+}++export interface TurnaroundRequest extends TurnaroundInput {+ /** The pictures show a real person (not one Fuobe made): Soul ID's consent line must be confirmed. */+ realPerson?: boolean;+ consent?: boolean;+}++/** What this install offers (Settings → Models & licences). */+export function turnaroundContext(): TurnaroundContext {+ return { has: (id) => !!getModel(id) && isOffered(id) };+}++/** Said when a real person's pictures go without the consent line (Soul ID's, src/lib/catalog/training.ts). */+export const NEEDS_CONSENT = "Confirm the consent line first: a real person is only filmed with their permission";++type Check = { costUsd: number | null; demo: boolean; notes: string[] };++/** Check and price each step as the runner will run it: a step that can't run stops the whole run before anything starts. */+function checkSteps(plan: TurnaroundPlan): Check {+ let cost: number | null = 0;+ let demo = false;+ const notes: string[] = [];+ for (const s of plan.steps) {+ let p: ReturnType<typeof previewGeneration>;+ try {+ p = s.after?.length ? previewChained(s.request, s.after.length) : previewGeneration(s.request);+ } catch (e) {+ throw new TurnaroundError((e as Error).message);+ }+ demo ||= p.demo;+ cost = p.costUsd === null || cost === null ? null : cost + p.costUsd;+ for (const n of p.notes ?? []) if (!notes.includes(n)) notes.push(n);+ }+ return { costUsd: cost === null ? null : Math.round(cost * 1000) / 1000, demo, notes };+}++/** The most VRAM any open step's ComfyUI graph needs (the manifest's figure), for the "on your GPU" line. */+function gpuGb(plan: TurnaroundPlan): number | undefined {+ if (plan.engine !== "open") return undefined;+ const flows = loadManifest().workflows;+ let most: number | undefined;+ for (const s of plan.steps) {+ const m = getModel(s.request.modelId);+ const route = m && routesFor(m, s.request.op ?? "edit").find((r) => r.provider === "comfyui");+ const gb = route && flows.find((w) => w.id === route.endpoint)?.vramGb;+ if (typeof gb === "number") most = Math.max(most ?? 0, gb);+ }+ return most;+}++export interface TurnaroundPreview {+ route: TurnaroundPlan["route"];+ routes: TurnaroundPlan["routes"];+ model: { id: string; name: string };+ duration: number;+ durations: number[];+ frames: TurnaroundPlan["frames"];+ fills: TurnaroundPlan["fills"];+ frontFromSheet: boolean;+ fill: boolean;+ steps: number;+ notes: string[];+ blocker?: string;+ costUsd: number | null;+ /** Some step runs on the demo provider (no key, or ComfyUI not reachable, with demo mode on). */+ demo: boolean;+ /** The open engine: the most VRAM a step needs (GB). */+ gpuGb?: number;+}++/** The run as the server would make it, priced, without running it. */+export function previewTurnaround(input: TurnaroundRequest): TurnaroundPreview {+ const plan = planTurnaround(input, turnaroundContext());+ let check: Check = { costUsd: plan.costUsd, demo: false, notes: [] };+ let blocker = plan.blocker;+ if (!blocker) {+ try {+ check = checkSteps(plan);+ } catch (e) {+ blocker = (e as Error).message;+ }+ }+ if (!blocker && input.realPerson && !input.consent) blocker = NEEDS_CONSENT;+ return {+ route: plan.route,+ routes: plan.routes,+ model: { id: plan.model.id, name: plan.model.name },+ duration: plan.duration,+ durations: plan.durations,+ frames: plan.frames,+ fills: plan.fills,+ frontFromSheet: plan.frontFromSheet,+ fill: plan.fill,+ steps: plan.steps.length,+ notes: [...plan.notes, ...check.notes.filter((n) => !plan.notes.includes(n))],+ ...(blocker && { blocker }),+ costUsd: check.demo ? 0 : check.costUsd,+ demo: check.demo,+ ...(gpuGb(plan) !== undefined && { gpuGb: gpuGb(plan) }),+ };+}++/**+ * Run a plan's steps in order as one batch: each waits for the steps it names (their outputs go into its chain slots).+ * Returns every generation made, the film first. Steps already made are canceled when a later one can't be.+ */+export function runTurnaroundSteps(steps: TurnStep[], batchId = nanoid(10)): Generation[] {+ const made: Record<string, Generation[]> = {};+ const all: Generation[] = [];+ try {+ for (const s of steps) {+ const deps = s.after?.map((k) => made[k]?.[0]?.id).filter((x): x is string => !!x) ?? [];+ const created = createGenerations(s.request, { batchId, ...(deps.length && { dependsOn: deps }) });+ made[s.key] = created;+ all.push(...created);+ }+ } catch (e) {+ for (const g of all) void cancelGeneration(g.id);+ throw new TurnaroundError((e as Error).message);+ }+ const film = made.main?.[0];+ return film ? [film, ...all.filter((g) => g.id !== film.id)] : all;+}++export interface TurnaroundResult {+ items: Generation[];+ /** The finished turnaround's generation (the film, or the one clip). */+ filmId: string;+ batchId: string;+ plan: TurnaroundPreview;+}++/** Plan, check every step, then run them; a real person's pictures need the consent line. */+export function createTurnaround(input: TurnaroundRequest): TurnaroundResult {+ const preview = previewTurnaround(input);+ if (preview.blocker) throw new TurnaroundError(preview.blocker);+ const plan = planTurnaround(input, turnaroundContext());+ const batchId = nanoid(10);+ const items = runTurnaroundSteps(plan.steps, batchId);+ return { items, filmId: items[0].id, batchId, plan: preview };+}diff --git a/tests/turnaround-api.test.ts b/tests/turnaround-api.test.tsnew file mode 100644index 00000000..8ff2f919--- /dev/null+++ b/tests/turnaround-api.test.ts@@ -0,0 +1,130 @@+import fs from "node:fs";+import os from "node:os";+import path from "node:path";+import { afterAll, beforeAll, describe, expect, it } from "vitest";++/** Turnaround video (build plan N7-6) through /api/turnaround and Cinema's "turnaround" action, on the demo provider. */++const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-turnaround-"));+process.env.FUOBE_DATA_DIR = dir;+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 route = await import("@/app/api/turnaround/route");+const cinemaRoute = await import("@/app/api/cinema/projects/[id]/generate/route");+const { saveFile } = await import("@/server/storage");+const { encodePng } = await import("@/server/png");+const { NEEDS_CONSENT } = await import("@/server/turnaround");+const { ORBIT_PROMPT } = await import("@/lib/catalog/turnaround");++beforeAll(() => {+ setSetting("demoMode", "auto");+ setSetting("enhanceProvider", "none");+});+afterAll(() => fs.rmSync(dir, { recursive: true, force: true }));++const upload = (name: string, width = 18, height = 32) => saveFile({ data: encodePng({ width, height, data: Buffer.alloc(width * height * 4, 128) }), contentType: "image/png", name, source: "upload" }).url;+const post = (body: unknown, preview = false) =>+ route.POST(new Request(`http://x/api/turnaround${preview ? "?preview=1" : ""}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }));++async function settle(id: string, ms = 60_000) {+ const until = Date.now() + ms;+ for (;;) {+ const g = gens.getGeneration(id)!;+ if (["succeeded", "failed", "canceled"].includes(g.status)) return g;+ if (Date.now() > until) throw new Error(`timed out: ${g.status} ${g.message}`);+ await new Promise((r) => setTimeout(r, 300));+ }+}++describe("/api/turnaround", () => {+ it("previews the open engine's run: the sides drawn first, the film's frames, Free, the GPU it needs", async () => {+ const front = upload("front.png");+ const back = upload("back.png");+ const res = await post({ engine: "open", views: { front, back } }, true);+ expect(res.status).toBe(200);+ const p = await res.json();+ expect(p).toMatchObject({ route: "frames", routes: ["frames"], fills: ["right", "left"], steps: 3, costUsd: 0, demo: true, gpuGb: 24, duration: 8 });+ expect(p.frames.map((f: { side: string; from: string }) => `${f.side}:${f.from}`)).toEqual(["front:picture", "right:angles", "back:picture", "left:angles", "front:picture"]);+ expect(p.blocker).toBeUndefined();+ });++ it("runs it as one batch: the sides drawn, then each quarter turn waits for its own frames, then the film", async () => {+ const front = upload("front2.png");+ const back = upload("back2.png");+ const res = await post({ engine: "open", views: { front, back }, name: "Ada", requestId: "turn-open-1" });+ expect(res.status).toBe(201);+ const { items, filmId, batchId } = await res.json();+ expect(items[0].id).toBe(filmId);+ expect(items[0]).toMatchObject({ modelId: "oss-join-clips", op: "concat", feature: "turnaround", prompt: "Turnaround · Ada" });+ const steps = items.slice(1);+ expect(steps.filter((g: { feature: string }) => g.feature === "turnaround-step").map((g: { request: { step: { label: string } } }) => g.request.step.label)).toEqual(["Right side (Angles)", "Left side (Angles)"]);+ const clips = steps.filter((g: { op: string }) => g.op === "flf2v");+ expect(clips).toHaveLength(4);+ expect(clips.every((g: { batchId: string; request: { prompt: string } }) => g.batchId === batchId && g.request.prompt === ORBIT_PROMPT)).toBe(true);+ // A second click gets the same run.+ const again = await (await post({ engine: "open", views: { front, back }, name: "Ada", requestId: "turn-open-1" })).json();+ expect(again.filmId).toBe(filmId);+ const done = await settle(filmId);+ expect(done).toMatchObject({ status: "succeeded", kind: "video" });+ }, 90_000);++ it("runs the cloud's reference route as a demo with no key, priced as a demo", async () => {+ const pics = { front: upload("cf.png"), right: upload("cr.png"), back: upload("cb.png"), left: upload("cl.png") };+ const preview = await (await post({ engine: "cloud", views: pics }, true)).json();+ expect(preview).toMatchObject({ route: "references", fills: [], demo: true, costUsd: 0, model: { id: "minimax-h3-max" } });+ expect(preview.gpuGb).toBeUndefined();+ const res = await post({ engine: "cloud", views: pics, route: "keyframes" });+ expect(res.status).toBe(201);+ const { filmId, items } = await res.json();+ expect(items[0]).toMatchObject({ modelId: "flux-3-max", op: "keyframes", feature: "turnaround" });+ expect((await settle(filmId)).status).toBe("succeeded");+ }, 60_000);++ it("asks for Soul ID's consent line before filming a real person, and files a character's run in its feed", async () => {+ const front = upload("real.png");+ const blocked = await (await post({ engine: "cloud", views: { front }, realPerson: true }, true)).json();+ expect(blocked.blocker).toBe(NEEDS_CONSENT);+ const refused = await post({ engine: "cloud", views: { front }, realPerson: true });+ expect(refused.status).toBe(422);+ expect((await refused.json()).error).toBe(NEEDS_CONSENT);+ expect((await post({ engine: "cloud", views: { front }, elementId: "nope" })).status).toBe(404);+ const { createElement } = await import("@/server/elements");+ const el = createElement({ name: "Ada", kind: "character", references: [front] });+ const res = await post({ engine: "cloud", views: { front }, realPerson: true, consent: true, elementId: el.id });+ expect(res.status).toBe(201);+ const { items, filmId } = await res.json();+ expect(items[0]).toMatchObject({ modelId: "minimax-h3-max-camera", op: "camera-path", feature: `element:${el.id}` });+ await settle(filmId);+ }, 60_000);++ it("refuses pictures not uploaded here, and a run with no front view", async () => {+ expect((await post({ engine: "open", views: { front: "https://elsewhere.test/a.png" } })).status).toBe(400);+ const back = upload("only-back.png");+ const res = await post({ engine: "open", views: { back } });+ expect(res.status).toBe(422);+ expect((await res.json()).error).toMatch(/Pick the front view/);+ });+});++describe("Cinema: a Soul Cast result's turnaround as a take", () => {+ it("files the sheet's turnaround in the project, drawing its front and sides first on the open engine", async () => {+ const p = cinema.createProject({ name: "Casting" });+ const sheet = upload("sheet.png", 64, 36);+ const input = { engine: "open", mode: "video", action: "turnaround", prompt: "", turnaround: { sheet, name: "Rae" } };+ const res = await cinemaRoute.POST(new Request("http://x/api", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ input }) }), { params: Promise.resolve({ id: p.id }) });+ expect(res.status).toBe(201);+ const { items, plan } = await res.json();+ expect(plan.modelId).toBe("oss-wan22-14b");+ expect(plan.costUsd).toBe(0);+ const film = items.find((g: { op: string }) => g.op === "concat");+ expect(film).toMatchObject({ feature: "cinema-turnaround", prompt: "Turnaround · Rae" });+ expect(items.filter((g: { op: string }) => g.op === "edit")).toHaveLength(4);+ const listed = cinema.listItems(p.id).map((g) => g.id);+ expect(items.every((g: { id: string }) => listed.includes(g.id))).toBe(true);+ expect((await settle(film.id, 90_000)).status).toBe("succeeded");+ }, 100_000);+});