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
Hosted catch-up: reference counts, portrait shape, insert points and canvas choices checked before a paid run
Claudedbe10f6b841c
diff --git a/scripts/gen-cloud-models.py b/scripts/gen-cloud-models.pyindex 87ba5d7a..829c9da2 100644--- a/scripts/gen-cloud-models.py+++ b/scripts/gen-cloud-models.py@@ -643,8 +643,8 @@ model("minimax-h3-max-turbo", "MiniMax H3 Max Turbo", "MiniMax", "hailuo", "vide{"byResolution": {"480P": 0.025, "768P": 0.04, "1080P": 0.08},"promo": {"until": "2026-11-15", "usd": 0.028, "byResolution": {"480P": 0.0175, "768P": 0.028, "1080P": 0.056}}}))model("minimax-h3-max-turbo-refs", "MiniMax H3 Max Turbo · references", "MiniMax", "hailuo", "video",- "Turbo with up to 9 pictures, 3 clips and 3 sound clips as references (Image 1, Video 1, Audio 1 in the prompt)",- [("ref2v", "minimax/h3-max-turbo/reference-to-video")], badges=["new", "audio"], fit_values=True,+ "Turbo with up to 12 references — pictures, clips and sound together (Image 1, Video 1, Audio 1 in the prompt)",+ [("ref2v", "minimax/h3-max-turbo/reference-to-video")], badges=["new", "audio"], fit_values=True, options={"maxReferences": 12},defaults={"aspectRatio": "16:9", "duration": 5, "resolution": "768P"}, ranged_durations=True,pricing=("second", 0.08, "768P; 480P $0.05, 1080P $0.16; references past the first 4,096 tokens add $0.016 per 1,000",{"byResolution": {"480P": 0.05, "768P": 0.08, "1080P": 0.16}}))@@ -924,7 +924,7 @@ model("vidu-q3", "Vidu Q3", "Shengshu", "vidu", "video", "Anime-friendly video w# sound on request, 3-16 s up to 4K. Vidu's own API takes more references than fal's schema exposes; Fuobe sends what fal takes.model("vidu-q4", "Vidu Q4", "Shengshu", "vidu", "video", "Vidu's newest: a start frame or up to 12 references and 3 voices, 3–16 s, up to 4K",[("i2v", "fal-ai/vidu/q4/image-to-video"), ("ref2v", "fal-ai/vidu/q4/reference-to-video")], badges=["new", "4k", "audio"], ranged_durations=True,- defaults={"aspectRatio": "16:9", "duration": 5, "resolution": "720p"}, options={"maxImages": 12}, prompt_max=True, fit_values=True,+ defaults={"aspectRatio": "16:9", "duration": 5, "resolution": "720p"}, options={"maxImages": 12, "referenceAudio": "mp3"}, prompt_max=True, fit_values=True,pricing=("second", 0.0665, "720p; 540p $0.0315, 1080p $0.084, 2K $0.133, 4K $0.273; sound costs nothing extra",{"byResolution": {"540p": 0.0315, "720p": 0.0665, "1080p": 0.084, "2K": 0.133, "4K": 0.273}}))model("luma-ray-3-2", "Luma Ray 3.2", "Luma", "luma", "video", "HDR, physically convincing motion",@@ -1359,10 +1359,12 @@ for _v in ("7", "6"):model(f"meshy-{_v}-retexture", f"Meshy {_v} Retexture", "Meshy", "meshy", "model3d", "New textures on a 3D model, from words or a style picture",[("retexture-3d", f"meshy/v{_v}/retexture")], badges=["new"], prompt_max=True, controls=[("texture_resolution", "Texture size")],options={"promptOptional": True}, fixed={"enable_pbr": True},- pricing=("request", 0.3, "2K or 4K textures; 8K $0.45; PBR maps included", {"factors": [{"param": "texture_resolution", "values": {"8k": 1.5}}]}))+ pricing=("request", 0.3, "2K or 4K textures; 8K $0.45; realistic surface detail included", {"factors": [{"param": "texture_resolution", "values": {"8k": 1.5}}]}))# Tripo P2: Tripo's production tier. $1.10 a model with fast or standard textures, $1.20 detailed, $1.30 extreme ($1.00 untextured).-model("tripo-p2", "Tripo P2", "Tripo", "tripo", "model3d", "Tripo's production tier: game-ready meshes with PBR textures, quads on request",+# Its "fast" textures need texture version v3.5-20260815 (fal's schema), the newest, which every quality takes: it always goes.+model("tripo-p2", "Tripo P2", "Tripo", "tripo", "model3d", "Tripo's production tier: detailed 3D models with realistic textures",[("image-to-3d", "tripo3d/p2/image-to-3d")], badges=["new", "pro"], controls=[("texture_quality", "Texture")],+ fixed={"texture_version": "v3.5-20260815"},pricing=("request", 1.1, "standard textures; detailed $1.20, extreme $1.30",{"factors": [{"param": "texture_quality", "values": {"detailed": 1.2 / 1.1, "extreme": 1.3 / 1.1}}]}))# Cinema Studio's "Create 3D scene" on the cloud (part 4 §8): a depth map of the whole frame, which the browser@@ -2199,7 +2201,11 @@ def build_route(op, ep, provider, m, opts, ropts=None):fmap["duration"]["suffix"] = "s"lo, hi = num(spec.get("minimum")), num(spec.get("maximum"))if m.get("ranged_durations") and lo is not None and hi is not None:- opts["durations"] = union(opts.get("durations", []), [v for v in NICE_DURATIONS if lo <= v <= hi] or [lo])+ picks = [v for v in NICE_DURATIONS if lo <= v <= hi] or [lo]+ # The longest whole second the API takes is always one of them (Vidu Q4's 16 s, H3 Max insert's 13 s).+ if hi == int(hi) and hi not in picks and hi <= max(NICE_DURATIONS):+ picks.append(int(hi))+ opts["durations"] = union(opts.get("durations", []), picks)if key.endswith("_ms"):fmap["duration"]["multiplier"] = 1000part4_ranges(op, inputs, fmap)diff --git a/src/components/model3d/retexture-dialog.tsx b/src/components/model3d/retexture-dialog.tsxindex d2b18dca..ff3c813a 100644--- a/src/components/model3d/retexture-dialog.tsx+++ b/src/components/model3d/retexture-dialog.tsx@@ -58,7 +58,7 @@ export function RetextureDialog({ glb, open, onOpenChange, cloudAllowed }: { glb<DialogContent className="sm:max-w-md"><DialogHeader><DialogTitle>Retexture</DialogTitle>- <DialogDescription>The same model with new textures: describe the look, or add a picture of the style. PBR maps are included.</DialogDescription>+ <DialogDescription>The same model with new textures: describe the look, or add a picture of the style. Realistic surface detail — shine, roughness and bumps — is included.</DialogDescription></DialogHeader>{!cloudAllowed ? (<p className="rounded-xl bg-muted p-3 text-[13px] text-muted-foreground" role="note">diff --git a/src/components/studio/studio-page.tsx b/src/components/studio/studio-page.tsxindex ba89cf3f..39734f00 100644--- a/src/components/studio/studio-page.tsx+++ b/src/components/studio/studio-page.tsx@@ -297,6 +297,17 @@ function ActivePresetHeader() {);}+/**+ * The line under the hero. It follows the picked model: a relight that matches a light picked on a sphere (H3 Max relight)+ * takes no words, so it says to pick a light.+ */+function StudioSubtitle({ text }: { text: string }) {+ const { draft } = useStudio();+ const catalog = useCatalog();+ const sphere = !!catalog.getModel(draft.modelId)?.options.lightSphere;+ return <p className="mt-2 max-w-xl text-[13px] text-muted-foreground">{sphere ? "Pick a light — its direction, colour and softness — and the shot is relit to match." : text}</p>;+}+/*** Example prompts under the hero. Its own component: it follows the picked model (a model that* takes no prompt, like FASHN try-on, gets none), so it re-renders with the draft, not the page.@@ -520,7 +531,7 @@ function StudioBody({ header, tabs, examples }: { header?: React.ReactNode; tabs) : (<div className="flex flex-col items-center pt-6 text-center sm:pt-[16vh]"><h2 className="font-heading text-display text-balance">{config.hero}</h2>- {config.subtitle && <p className="mt-2 max-w-xl text-[13px] text-muted-foreground">{config.subtitle}</p>}+ {config.subtitle && <StudioSubtitle text={config.subtitle} />}{config.related && (<Link href={config.related.href} className="mt-3 inline-flex items-center gap-1 rounded-full bg-muted px-3 py-1 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none">{config.related.label}diff --git a/src/lib/av/model3d.ts b/src/lib/av/model3d.tsindex f60bcac8..f623e3bb 100644--- a/src/lib/av/model3d.ts+++ b/src/lib/av/model3d.ts@@ -35,7 +35,7 @@ export const MODELS_3D: Record<Model3dMode, Record<Engine, Model3dChoice[]>> = {{ id: "trellis-2", note: "Detailed geometry · ≈ $0.30" },{ id: "tripo-h3-1", note: "Clean topology, PBR · ≈ $0.30" },{ id: "meshy-7-1", note: "Textured, optional rigging · ≈ $1.20" },- { id: "tripo-p2", note: "Production tier: game-ready, PBR · ≈ $1.10" },+ { id: "tripo-p2", note: "Production tier, realistic textures · ≈ $1.10" },],open: [{ id: "oss-pixal3d", note: "Most faithful to your photo, with a turntable video" },diff --git a/src/lib/catalog/canvas.ts b/src/lib/catalog/canvas.tsindex 5005d036..232a65d6 100644--- a/src/lib/catalog/canvas.ts+++ b/src/lib/catalog/canvas.ts@@ -347,12 +347,16 @@ export function nodeLabel(n: Pick<CanvasNode, "type" | "data">): string {/*** Ops the canvas can't feed (masks, browser-only tools, multi-speaker scripts, draft finishing, and- * inputs it has no port for: a 3D model to rig, a list of audio clips to join).+ * inputs it has no port for: a 3D model to rig or retexture, a list of audio clips to join, the two points of an+ * inserted moment).*/-const UNSUPPORTED_OPS = new Set<Operation>(["grade", "inpaint", "finalize", "dialogue", "rig-3d", "audio-join"]);+const UNSUPPORTED_OPS = new Set<Operation>(["grade", "inpaint", "finalize", "dialogue", "rig-3d", "retexture-3d", "audio-join", "insert-moment"]);-/** Models that only run on a painted mask or clicked points (VACE inpaint, Bria's point eraser): the canvas has neither. */-const needsMarks = (m: ModelDef) => !!(m.options.requires?.mask || m.options.requires?.points);+/**+ * Models that only run on a painted mask or clicked points (VACE inpaint, Bria's point eraser), or on a light picked on a+ * sphere (H3 Max relight): the canvas has none of these.+ */+const needsMarks = (m: ModelDef) => !!(m.options.requires?.mask || m.options.requires?.points || m.options.lightSphere);/** Preferred defaults; anything missing falls back to the first catalog model for that op and engine. */const PREFERRED: Partial<Record<Operation, Partial<Record<Engine, string>>>> = {diff --git a/src/lib/catalog/clip-windows.ts b/src/lib/catalog/clip-windows.tsindex 7926a62f..f36e584d 100644--- a/src/lib/catalog/clip-windows.ts+++ b/src/lib/catalog/clip-windows.ts@@ -16,8 +16,9 @@ const SOURCE_SECONDS: Record<string, { min?: number; max?: number }> = {"gemini-omni-flash": { max: 10 },// fal's H3 Max relight: "up to 15 seconds", resampled to 24 fps and trimmed to 17n+5 frames, "at least 56 frames (about 2.33 seconds)"."minimax-h3-max-relight": { min: 2.4, max: 15 },- // fal's H3 Max insert takes start and resume times up to 60 s into the clip, the start at least 1.625 s in.- "minimax-h3-max-insert": { min: 1.7, max: 60 },+ // fal's H3 Max insert takes start and resume times up to 60 s into the clip, the resume at least 2.625 s in; the clip itself has+ // no upper limit (the points keep to its first minute: insertRangeProblem).+ "minimax-h3-max-insert": { min: 2.625 },// fal's H3 Max Turbo extend: "Must be 1.625 s to 60 s long"."minimax-h3-max-turbo-extend": { min: 1.625, max: 60 },};@@ -47,14 +48,15 @@ export function portraitShapeProblem(model: { id: string; name: string }, width:}/**- * Where a new moment may go inside a clip (fal's H3 Max insert: start_time 1.625–60 s, resume_time after it and at most 60 s), in- * Generate's words, or null. `clip` is the clip's length when known: both points must be inside it.+ * Where a new moment may go inside a clip (fal's H3 Max insert: start_time 1.625–60 s, resume_time 2.625–60 s and after the+ * start), in Generate's words, or null. `clip` is the clip's length when known: both points must be inside it.*/-export const INSERT_RANGE = { minStart: 1.625, max: 60 } as const;+export const INSERT_RANGE = { minStart: 1.625, minResume: 2.625, max: 60 } as const;export function insertRangeProblem(start: number | undefined, resume: number | undefined, clip?: number): string | null {if (start === undefined || resume === undefined || !Number.isFinite(start) || !Number.isFinite(resume)) return "Mark where the new moment starts and where the clip picks up again";if (start < INSERT_RANGE.minStart - 1e-6) return `The new moment can start ${INSERT_RANGE.minStart} s into the clip at the earliest: move the first handle right`;if (resume <= start + 1e-6) return "The clip has to pick up again after the new moment starts: move the second handle right";+ if (resume < INSERT_RANGE.minResume - 1e-6) return `The clip can pick up again ${INSERT_RANGE.minResume} s in at the earliest: move the second handle right`;if (resume > INSERT_RANGE.max + 1e-6) return `Both points have to be within the first ${INSERT_RANGE.max} s of the clip: trim it first`;if (clip !== undefined && clip > 0 && resume > clip + 0.05) return `The clip is ${secs(clip)} long, so it can't pick up again at ${secs(resume)}: move the second handle left`;return null;@@ -66,17 +68,17 @@ export const INSERT_STEP = 0.125;/*** The two handles of Edit video's "Insert a moment" range on a clip `clip` seconds long (unknown while its header is read): the* track runs from the earliest start to the clip's end (at most 60 s), and the handles keep to it, the start before the resume- * by a step at least, on 1/8 s stops. Without a value they open around the clip's middle.+ * by a step at least and the resume no earlier than 2.625 s, on 1/8 s stops. Without a value they open around the clip's middle.*/export function insertHandles(clip: number | undefined, value?: [number | undefined, number | undefined]): { min: number; max: number; start: number; resume: number } {const snap = (n: number) => Math.round(n / INSERT_STEP) * INSERT_STEP;const min = INSERT_RANGE.minStart;- const max = Math.max(min + INSERT_STEP, Math.floor(Math.min(INSERT_RANGE.max, clip && clip > 0 ? clip : INSERT_RANGE.max) / INSERT_STEP) * INSERT_STEP);+ const max = Math.max(INSERT_RANGE.minResume, Math.floor(Math.min(INSERT_RANGE.max, clip && clip > 0 ? clip : INSERT_RANGE.max) / INSERT_STEP) * INSERT_STEP);const mid = clip && clip > 0 ? clip / 2 : min + 2;let start = snap(value?.[0] ?? mid - 0.5);start = Math.min(Math.max(min, start), max - INSERT_STEP);let resume = snap(value?.[1] ?? start + 1);- resume = Math.min(Math.max(start + INSERT_STEP, resume), max);+ resume = Math.min(Math.max(start + INSERT_STEP, INSERT_RANGE.minResume, resume), max);return { min, max, start, resume };}diff --git a/src/lib/catalog/cloud-models.generated.ts b/src/lib/catalog/cloud-models.generated.tsindex 777664d5..3fb43e9c 100644--- a/src/lib/catalog/cloud-models.generated.ts+++ b/src/lib/catalog/cloud-models.generated.ts@@ -7428,7 +7428,8 @@ export const CLOUD_MODELS: ModelDef[] = [6,8,10,- 12+ 12,+ 13],"maxImages": 9,"promptOptional": true@@ -7950,7 +7951,7 @@ export const CLOUD_MODELS: ModelDef[] = ["family": "hailuo","engine": "cloud","kind": "video",- "tagline": "Turbo with up to 9 pictures, 3 clips and 3 sound clips as references (Image 1, Video 1, Audio 1 in the prompt)",+ "tagline": "Turbo with up to 12 references \u2014 pictures, clips and sound together (Image 1, Video 1, Audio 1 in the prompt)","routes": [{"op": "ref2v",@@ -8017,7 +8018,8 @@ export const CLOUD_MODELS: ModelDef[] = [12,15],- "maxImages": 9+ "maxImages": 9,+ "maxReferences": 12},"badges": ["new",@@ -9569,7 +9571,8 @@ export const CLOUD_MODELS: ModelDef[] = [8,10,12,- 15+ 15,+ 16],"maxImages": 12,"maxAudios": 3,@@ -9580,7 +9583,8 @@ export const CLOUD_MODELS: ModelDef[] = ["4:3","3:4","1:1"- ]+ ],+ "referenceAudio": "mp3"},"badges": ["new",@@ -17727,7 +17731,7 @@ export const CLOUD_MODELS: ModelDef[] = ["pricing": {"unit": "request","usd": 0.3,- "note": "2K or 4K textures; 8K $0.45; PBR maps included",+ "note": "2K or 4K textures; 8K $0.45; realistic surface detail included","factors": [{"param": "texture_resolution",@@ -17785,7 +17789,7 @@ export const CLOUD_MODELS: ModelDef[] = ["pricing": {"unit": "request","usd": 0.3,- "note": "2K or 4K textures; 8K $0.45; PBR maps included",+ "note": "2K or 4K textures; 8K $0.45; realistic surface detail included","factors": [{"param": "texture_resolution",@@ -17803,7 +17807,7 @@ export const CLOUD_MODELS: ModelDef[] = ["family": "tripo","engine": "cloud","kind": "model3d",- "tagline": "Tripo's production tier: game-ready meshes with PBR textures, quads on request",+ "tagline": "Tripo's production tier: detailed 3D models with realistic textures","routes": [{"op": "image-to-3d",@@ -17812,7 +17816,10 @@ export const CLOUD_MODELS: ModelDef[] = ["map": {"prompt": false,"image": "image_url",- "seed": "model_seed"+ "seed": "model_seed",+ "fixed": {+ "texture_version": "v3.5-20260815"+ }}}],diff --git a/src/lib/catalog/plan.ts b/src/lib/catalog/plan.tsindex cb826304..7171bcea 100644--- a/src/lib/catalog/plan.ts+++ b/src/lib/catalog/plan.ts@@ -878,12 +878,45 @@ export function hostedInputProblem(model: Pick<ModelDef, "name" | "routes" | "opif (Number.isFinite(max) && prompt.length > max) {return `${model.name} takes up to ${max.toLocaleString("en-US")} characters of prompt, and this one has ${prompt.length.toLocaleString("en-US")}: shorten it`;}+ const refs = referenceProblem(model, op, req);+ if (refs) return refs;if (op === "insert-moment") return insertRangeProblem(params.startTime, params.endTime, params.sourceDuration);if (op === "relight-video" && model.options.lightSphere && !req.inputs?.images?.length) return `Pick a light: ${model.name} matches the light on a sphere you choose`;if (op === "retexture-3d" && !prompt.trim() && !req.inputs?.images?.length) return "Describe the new look, or add a style picture";return null;}+const plural = (n: number, [one, many]: readonly [string, string]) => `${n} ${n === 1 ? one : many}`;++/**+ * Reference lists past what the endpoint's lists take (their schema's maxItems, or the count its description gives: H3 Max insert+ * 9 pictures and 3 clips, Vidu Q4 12 pictures and 3 voices), past a total across the lists (ModelOptions.maxReferences: H3 Max+ * Turbo's 12 files), or a voice in a format the endpoint doesn't read (ModelOptions.referenceAudio: Vidu Q4's mp3). Only lists a+ * route of `op` sends whole, so a start frame or an element's pictures are never counted; needs the routes' field maps.+ */+function referenceProblem(model: Pick<ModelDef, "name" | "routes" | "options">, op: Operation, req: Pick<GenerationRequest, "inputs">): string | null {+ const routes = model.routes.filter((r) => r.op === op);+ if (!routes.length || routes.some((r) => !r.map || r.map.elements || r.map.image)) return null;+ const sends = (k: "images" | "videos" | "audios") => routes.every((r) => !!r.map![k]);+ const i = req.inputs ?? {};+ const counts = { images: sends("images") ? (i.images?.length ?? 0) : 0, videos: sends("videos") ? (i.videos?.length ?? 0) : 0, audios: sends("audios") ? (i.audios?.length ?? 0) : 0 };+ const limits = { images: imageLimit(model, op), videos: model.options.maxVideos, audios: model.options.maxAudios };+ const words = { images: ["picture", "pictures"], videos: ["clip", "clips"], audios: ["sound clip", "sound clips"] } as const;+ for (const k of ["images", "videos", "audios"] as const) {+ const most = limits[k];+ if (most !== undefined && counts[k] > most) return `${model.name} takes up to ${plural(most, words[k])} as references, and this run has ${counts[k]}: remove ${counts[k] - most}`;+ }+ const total = counts.images + counts.videos + counts.audios;+ const cap = model.options.maxReferences;+ if (cap !== undefined && total > cap) return `${model.name} takes up to ${cap} references in all — pictures, clips and sound together — and this run has ${total}: remove ${total - cap}`;+ const format = model.options.referenceAudio;+ if (format && counts.audios) {+ const ext = (u: string) => (u.startsWith("data:") ? (/^data:audio\/(mpeg|mp3)[;,]/i.test(u) ? "mp3" : "other") : /\.([a-z0-9]{2,5})(?:[?#]|$)/i.exec(u)?.[1]?.toLowerCase());+ if (i.audios!.some((u) => { const e = ext(u); return e !== undefined && e !== format; })) return `${model.name} takes ${format.toUpperCase()} voice clips only: convert the others to ${format.toUpperCase()} first`;+ }+ return null;+}+/** Models that need several images (try-on: the person, then the garment). */function missingImages(model: ModelDef, req: Pick<GenerationRequest, "inputs">): string | null {const min = model.options.minImages ?? 0;diff --git a/src/lib/catalog/types.ts b/src/lib/catalog/types.tsindex a669f719..722b5c53 100644--- a/src/lib/catalog/types.ts+++ b/src/lib/catalog/types.ts@@ -666,6 +666,10 @@ export interface ModelOptions {/** Max reference videos / audio clips it accepts (reference-to-video: inputs.videos / inputs.audios). */maxVideos?: number;maxAudios?: number;+ /** The most references across its pictures, clips and sound clips together (fal's H3 Max Turbo references: 12 files). */+ maxReferences?: number;+ /** The one format its reference voices are read in (fal's Vidu Q4: mp3); a clip in another is refused before the run. */+ referenceAudio?: string;/** Spoken languages it can be told (transcription, captions): sent as params.sourceLanguage; unset = its default. */sourceLanguages?: string[];/**diff --git a/src/server/generations.ts b/src/server/generations.tsindex 8eb859ba..3f31594f 100644--- a/src/server/generations.ts+++ b/src/server/generations.ts@@ -12,7 +12,7 @@ import { cueText, type Cue } from "@/lib/cues";import { HELPER_FEATURES, HELPER_SUFFIX, isReviewStatus, type AssetUse, type ReviewFilter } from "@/lib/library";import { upscaleTier } from "@/lib/av/upscale";import { chainedWaitMessage, framesWait, keyframeChain } from "@/lib/catalog/keyframes";-import { clipFpsProblem, clipSizeProblem, clipTotalProblem, clipWindowProblem, elementClipProblem, insertRangeProblem, sourceFrames, voiceWindowProblem } from "@/lib/catalog/clip-windows";+import { clipFpsProblem, clipSizeProblem, clipTotalProblem, clipWindowProblem, elementClipProblem, insertRangeProblem, portraitShapeProblem, sourceFrames, voiceWindowProblem } from "@/lib/catalog/clip-windows";import { avatarSeconds, clipEditSeconds, estimateCost, inferOperation, movedAppRequest, planGeneration, presetRoute, routeLoras, routesFor, withoutTriggers } from "@/lib/catalog/plan";import { framedLength, keepMatte, sizeValue } from "@/lib/catalog/payload";import { fitLoras, loraName, lorasFit } from "@/lib/catalog/loras";@@ -691,6 +691,18 @@ function sizedEdit(plan: ReturnType<typeof planGeneration>, req: GenerationRequereturn { ...plan, params: { ...plan.params, extra: { ...plan.params.extra, [field.key]: fit } } };}+/**+ * A talking avatar's picture held to the shape the hosted model takes (fal's H3 Max lip sync: 0.4 to 2.5 wide), read from the+ * file's header before the run is paid for. A picture that isn't a file in Fuobe (or isn't the run's own) goes as it is.+ */+function portraitProblem(plan: ReturnType<typeof planGeneration>, req: GenerationRequest): string | null {+ if (plan.op !== "avatar" || plan.model.engine === "open") return null;+ const first = req.inputs?.images?.[0];+ const head = first ? localHead(first) : null;+ const size = head ? imageSize(head) : null;+ return size ? portraitShapeProblem(plan.model, size.width, size.height) : null;+}+/*** The elements "@Name" can mention: the owner's. An account's run or a visitor's price check has none, so "@Name" stays* words there (an owner's element photo or LoRA never reaches someone else's run).@@ -712,6 +724,8 @@ function prepare(original: GenerationRequest) {const lookup = (id: string) => (model && id === model.id ? model : getModel(id));const req = model ? stripMotionPaths(applySketch(applyMentions(worded, model, mentionElements()).request, model).request, model) : worded;let plan = sizedEdit(sizedMixedFrame(planGeneration(req, lookup, getPreset), req), req);+ const portrait = portraitProblem(plan, req);+ if (portrait) throw new Error(portrait);if (mode !== "both" && plan.model.engine !== mode) {// An account on the open engine has no key of its own that opens (Your keys), or the studio is open-source only.const cloud = mode === "open" && tenantAccount() ? plan.model.routes.map((r) => r.provider).find(isCloudProvider) : undefined;diff --git a/tests/hosted-catchup.test.ts b/tests/hosted-catchup.test.tsindex a7e22099..7ea720e4 100644--- a/tests/hosted-catchup.test.ts+++ b/tests/hosted-catchup.test.ts@@ -202,7 +202,10 @@ describe("payloads match the stored schemas", () => {expect(payloadFor("tripo-p2", { prompt: "", inputs: { images: [IMG] }, params: { extra: { texture_quality: "detailed" } } }).payload).toMatchObject({image_url: IMG,texture_quality: "detailed",+ // fal: "The fast quality requires v3.5-20260815"; the newest version goes with every quality.+ texture_version: "v3.5-20260815",});+ expect(payloadFor("tripo-p2", { prompt: "", inputs: { images: [IMG] }, params: { extra: { texture_quality: "fast" } } }).payload).toMatchObject({ texture_quality: "fast", texture_version: "v3.5-20260815" });expect(MODELS_3D.image.cloud.some((m) => m.id === "tripo-p2")).toBe(true);});});@@ -265,13 +268,14 @@ describe("hosted limits are checked before a paid call, in Fuobe's words", () =>expect(() => planGeneration(retextureRequest({ glb: GLB }), getModel, getPreset)).toThrow("Describe the new look, or add a style picture");});- it("insert-video's range: start 1.625 s or later, the resume after it, both within 60 s and the clip", () => {+ it("insert-video's range: start 1.625 s or later, the resume 2.625 s or later and after it, both within 60 s and the clip", () => {expect(insertRangeProblem(undefined, 5)).toMatch(/Mark where/);expect(insertRangeProblem(1.5, 5)).toMatch(/1.625 s into the clip/);expect(insertRangeProblem(4, 4)).toMatch(/after the new moment starts/);expect(insertRangeProblem(4, 61)).toMatch(/first 60 s/);expect(insertRangeProblem(4, 9, 8)).toMatch(/The clip is 8 s long/);- expect(insertRangeProblem(INSERT_RANGE.minStart, 2, 8)).toBeNull();+ expect(insertRangeProblem(INSERT_RANGE.minStart, 2, 8)).toBe("The clip can pick up again 2.625 s in at the earliest: move the second handle right");+ expect(insertRangeProblem(INSERT_RANGE.minStart, INSERT_RANGE.minResume, 8)).toBeNull();expect(() => planGeneration({ feature: "video-edit", modelId: "minimax-h3-max-insert", prompt: "", inputs: { video: CLIP } } as Req, getModel, getPreset)).toThrow(/Mark where/);});@@ -288,6 +292,76 @@ describe("hosted limits are checked before a paid call, in Fuobe's words", () =>expect(portraitShapeProblem(lip, 1000, 3000)).toMatch(/0.4:1 \(tall\)/);expect(portraitShapeProblem(lip, 1080, 1920)).toBeNull();});++ it("an inserted moment takes a clip of any length past 2.625 s: only the two points keep to its first minute", () => {+ const insert = getModel("minimax-h3-max-insert")!;+ expect(clipWindowProblem(insert, 90)).toBeNull();+ expect(clipBlocker("insert-moment", { duration: 90 }, {}, insert, undefined)).toBeNull();+ expect(clipWindowProblem(insert, 2)).toMatch(/at least 2.625 s|2.625/);+ expect(insertRangeProblem(10, 12, 90)).toBeNull();+ });++ it("reference lists past what the endpoint takes, Turbo's 12 references in all, and Vidu Q4's mp3 voices", () => {+ const plan = (modelId: string, inputs: Req["inputs"]) => () => planGeneration({ feature: "video", modelId, prompt: "Image 1 walks", inputs } as Req, getModel, getPreset);+ const n = (k: number, u: string) => Array.from({ length: k }, () => u);+ expect(plan("minimax-h3-max-insert", { video: CLIP, images: n(10, IMG) })).toThrow("MiniMax H3 Max Insert a moment takes up to 9 pictures as references, and this run has 10: remove 1");+ expect(plan("minimax-h3-max-insert", { video: CLIP, videos: n(4, CLIP) })).toThrow(/up to 3 clips as references/);+ expect(plan("minimax-h3-max-turbo-refs", { videos: n(4, CLIP) })).toThrow(/up to 3 clips/);+ expect(plan("minimax-h3-lite", { images: [IMG, IMG], audios: n(4, VOICE) })).toThrow("MiniMax H3 Lite takes up to 3 sound clips as references, and this run has 4: remove 1");+ expect(plan("vidu-q4", { images: n(13, IMG) })).toThrow(/up to 12 pictures/);+ expect(plan("minimax-h3-max-turbo-refs", { images: n(9, IMG), videos: n(3, CLIP), audios: n(3, VOICE) })).toThrow(+ "MiniMax H3 Max Turbo · references takes up to 12 references in all — pictures, clips and sound together — and this run has 15: remove 3",+ );+ expect(plan("minimax-h3-max-turbo-refs", { images: n(6, IMG), videos: n(3, CLIP), audios: n(3, VOICE) })).not.toThrow();+ expect(plan("vidu-q4", { images: [IMG, IMG], audios: ["https://example.com/voice.wav"] })).toThrow("Vidu Q4 takes MP3 voice clips only: convert the others to MP3 first");+ expect(plan("vidu-q4", { images: [IMG, IMG], audios: [VOICE, "data:audio/mpeg;base64,AAAA"] })).not.toThrow();+ // A start frame is never counted as a reference.+ expect(plan("vidu-q4", { images: [IMG] })).not.toThrow();+ });++ it("the longest whole-second length each API takes is offered (Vidu Q4 16 s, H3 Max insert 13 s)", () => {+ expect(getModel("vidu-q4")!.options.durations?.at(-1)).toBe(16);+ expect(getModel("minimax-h3-max-insert")!.options.durations?.at(-1)).toBe(13);+ });+});++describe("a talking portrait's shape, read from the file before the run", () => {+ /** A PNG header of the given size (enough for imageSize). */+ const png = (w: number, h: number) => {+ const b = Buffer.alloc(33);+ Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]).copy(b, 0);+ b.writeUInt32BE(13, 8);+ b.write("IHDR", 12, "ascii");+ b.writeUInt32BE(w, 16);+ b.writeUInt32BE(h, 20);+ b[24] = 8;+ b[25] = 6;+ return b;+ };+ it("H3 Max lip sync refuses a picture too tall or too wide, and takes a phone portrait", async () => {+ const { saveFile } = await import("@/server/storage");+ const { previewGeneration } = await import("@/server/generations");+ const run = (w: number, h: number) => () =>+ previewGeneration({ feature: "lipsync", modelId: "minimax-h3-max-lipsync", engine: "cloud", prompt: "", inputs: { images: [saveFile({ data: png(w, h), contentType: "image/png", source: "upload" }).id], audio: VOICE } } as Req);+ expect(run(400, 1200)).toThrow("MiniMax H3 Max Lip Sync · up to 15 min takes pictures from 0.4:1 (tall) to 2.5:1 (wide), and this one is 400×1200: crop it first");+ expect(run(3000, 1000)).toThrow(/2.5:1 \(wide\)/);+ // (Past the shape it goes on to need a fal key here: no shape refusal.)+ expect(run(1080, 1920)).not.toThrow(/crop it first/);+ });+});++describe("the canvas", () => {+ it("leaves out what it can't feed: a 3D model to retexture, the two points of an inserted moment, a light picked on a sphere", async () => {+ const { modelChoices, nodeOps } = await import("@/lib/catalog/canvas");+ const ids = (kind: string) => modelChoices({ type: "model", data: { mediaKind: kind } } as never).map((m) => m.id);+ expect(ids("model3d")).not.toContain("meshy-7-retexture");+ expect(ids("model3d")).not.toContain("meshy-6-retexture");+ expect(ids("model3d")).toContain("tripo-p2");+ expect(ids("video")).not.toContain("minimax-h3-max-insert");+ expect(ids("video")).not.toContain("minimax-h3-max-relight");+ expect(ids("video")).toContain("minimax-h3-max-turbo");+ expect(nodeOps({ type: "model", data: {} } as never, getModel("meshy-7-retexture")!)).toEqual([]);+ });});describe("the insert range control", () => {@@ -298,7 +372,8 @@ describe("the insert range control", () => {});it("keeps the handles in order and inside the track", () => {- expect(insertHandles(10, [0.2, 0.3])).toMatchObject({ start: 1.625, resume: 1.75 });+ expect(insertHandles(10, [0.2, 0.3])).toMatchObject({ start: 1.625, resume: 2.625 });+ expect(insertHandles(10, [2.5, 2.75])).toMatchObject({ start: 2.5, resume: 2.75 });expect(insertHandles(10, [9.9, 12])).toMatchObject({ start: 9.875, resume: 10 });expect(insertHandles(10, [5, 4])).toMatchObject({ start: 5, resume: 5.125 });const h = insertHandles(7.3, [2.06, 6.94]);