Skip to content

armgit / fuobe

Public Imported from GitHub
0

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.

Hosted runs: check inputs against each endpoint's documented limits before sending

Adarsh6c391ad9b13c
diff --git a/src/lib/catalog/still-limits.ts b/src/lib/catalog/still-limits.ts
new file mode 100644
index 00000000..b971e28a
--- /dev/null
+++ b/src/lib/catalog/still-limits.ts
@@ -0,0 +1,105 @@
+/**
+ * The limits fal documents for an endpoint's still inputs (the field descriptions in its OpenAPI, fetched 2026-11-06),
+ * and what a picture needs before it's sent: a smaller or larger copy, another format, no alpha, or a refusal in
+ * Fuobe's words. The hosted hand-over (src/server/generations.ts prep) makes the copy; this file only decides.
+ * Pure data and logic (client and server).
+ */
+
+export type StillFormat = "png" | "jpeg" | "webp" | "gif" | "svg" | "other";
+
+export interface StillLimits {
+ /** Each side at least this many pixels. */
+ minSide?: number;
+ /** Each side at most this many pixels. */
+ maxSide?: number;
+ minPixels?: number;
+ maxPixels?: number;
+ /** Longest side over shortest side. */
+ maxAspect?: number;
+ maxBytes?: number;
+ /** The formats the endpoint reads; another is converted to the first of these. */
+ formats?: StillFormat[];
+ /** A PNG must have no alpha channel (Qwen Image 3 edit): it's flattened on white. */
+ noAlpha?: boolean;
+}
+
+const MB = 1024 * 1024;
+const LAYERIZE: StillLimits = { minPixels: 512 * 512, maxPixels: 6000 * 6000, maxAspect: 16, maxBytes: 30 * MB };
+
+/** By endpoint. Each line quotes its source; "less than" limits are kept strictly below. */
+export const STILL_LIMITS: Readonly<Record<string, StillLimits>> = {
+ // "Resolution: 384-2048px each dimension. Max size: 10MB each. Formats: JPEG, JPG, PNG (no alpha), WEBP."
+ "alibaba/qwen-image-3/edit": { minSide: 384, maxSide: 2048, maxBytes: 10 * MB, formats: ["jpeg", "png", "webp"], noAlpha: true },
+ // "PNG, JPG or WEBP format, less than 5 MB in size, have resolution less than 16 MP and max dimension less than
+ // 4096 pixels, min dimension more than 256 pixels."
+ "fal-ai/recraft/vectorize": { minSide: 257, maxSide: 4095, maxPixels: 16_000_000 - 1, maxBytes: 5 * MB - 1, formats: ["png", "jpeg", "webp"] },
+ // "The URL of the image to be upscaled. Must be in PNG format."
+ "fal-ai/recraft/upscale/crisp": { formats: ["png"] },
+ // "between 512x512 and 6000x6000 total pixels, have an aspect ratio between 1/16 and 16, and be no larger than 30 MB."
+ "bytedance/seedream/v5/pro/layerize": LAYERIZE,
+ "bytedance/seedream/v5/flash/layerize": LAYERIZE,
+ // "JPEG, PNG and WebP formats are supported (maximum file size 10MB)."
+ "fal-ai/ideogram/remove-background": { maxBytes: 10 * MB, formats: ["png", "jpeg", "webp"] },
+ // "Must be JPEG, PNG, or WebP (max 10MB)."
+ "fal-ai/ideogram/v3/layerize-text": { maxBytes: 10 * MB, formats: ["png", "jpeg", "webp"] },
+ // "Accepted formats are jpeg, jpg, png, webp. Maximum file size 12MB."
+ "fal-ai/bria/product-shot": { maxBytes: 12 * MB, formats: ["png", "jpeg", "webp"] },
+ // "Each must be at least 256 pixels per dimension. Oversized images are automatically downscaled".
+ "blackforestlabs/flux-3/edit-image": { minSide: 256 },
+};
+
+export interface StillFacts {
+ width: number;
+ height: number;
+ bytes: number;
+ format: StillFormat;
+}
+
+export interface StillPlan {
+ /** A copy at this size (aspect kept, rounded down; up only for a minimum side). */
+ resize?: { width: number; height: number };
+ toFormat?: "png" | "jpeg" | "webp";
+ flatten?: boolean;
+}
+
+/** What the picture needs before it's sent to the endpoint; null when it's fine as it is (or the endpoint states none). */
+export function stillPlan(endpoint: string, f: StillFacts): StillPlan | null {
+ const lim = STILL_LIMITS[endpoint];
+ if (!lim || f.width <= 0 || f.height <= 0) return null;
+ const plan: StillPlan = {};
+ const long = Math.max(f.width, f.height);
+ const short = Math.min(f.width, f.height);
+ let s = 1;
+ if (lim.maxSide && long > lim.maxSide) s = Math.min(s, lim.maxSide / long);
+ if (lim.maxPixels && f.width * f.height > lim.maxPixels) s = Math.min(s, Math.sqrt(lim.maxPixels / (f.width * f.height)));
+ if (s === 1 && lim.minSide && short < lim.minSide) {
+ const up = lim.minSide / short;
+ if (!lim.maxSide || long * up <= lim.maxSide) s = up;
+ }
+ if (s === 1 && lim.minPixels && f.width * f.height < lim.minPixels) s = Math.sqrt(lim.minPixels / (f.width * f.height));
+ if (s !== 1) {
+ const round = s < 1 ? Math.floor : Math.ceil;
+ plan.resize = { width: Math.max(1, round(f.width * s)), height: Math.max(1, round(f.height * s)) };
+ }
+ if (lim.formats && !lim.formats.includes(f.format)) plan.toFormat = lim.formats[0] as StillPlan["toFormat"];
+ if (lim.noAlpha && (plan.toFormat ?? f.format) === "png") plan.flatten = true;
+ // A file over the byte limit at its own size is written again (JPEG where it may be, else the same format).
+ if (lim.maxBytes && f.bytes > lim.maxBytes && !plan.toFormat) plan.toFormat = lim.formats && !lim.formats.includes("jpeg") ? (lim.formats[0] as StillPlan["toFormat"]) : "jpeg";
+ return plan.resize || plan.toFormat || plan.flatten ? plan : null;
+}
+
+/** Why the endpoint would still refuse the picture (after any copy), in Fuobe's words; null when it's within its limits. */
+export function stillProblem(endpoint: string, f: StillFacts): string | null {
+ const lim = STILL_LIMITS[endpoint];
+ if (!lim) return null;
+ const long = Math.max(f.width, f.height);
+ const short = Math.min(f.width, f.height);
+ if (lim.minSide && short < lim.minSide) return `This model needs a picture at least ${lim.minSide} pixels on each side.`;
+ if (lim.maxSide && long > lim.maxSide) return `This model takes pictures up to ${lim.maxSide} pixels on a side.`;
+ if (lim.minPixels && f.width * f.height < lim.minPixels) return "This picture is too small for this model.";
+ if (lim.maxPixels && f.width * f.height > lim.maxPixels) return "This picture is too large for this model.";
+ if (lim.maxAspect && long / short > lim.maxAspect) return `This model takes pictures up to ${lim.maxAspect}:1 in shape.`;
+ if (lim.maxBytes && f.bytes > lim.maxBytes) return `This model takes picture files up to ${Math.floor(lim.maxBytes / MB)} MB.`;
+ if (lim.formats && !lim.formats.includes(f.format)) return `This model takes ${lim.formats.map((x) => x.toUpperCase()).join(", ")} pictures.`;
+ return null;
+}
diff --git a/src/lib/composer.ts b/src/lib/composer.ts
index c771c331..733c1d50 100644
--- a/src/lib/composer.ts
+++ b/src/lib/composer.ts
@@ -317,8 +317,10 @@ export function clipBlocker(
model: (Pick<ModelDef, "engine" | "options" | "defaults"> & Partial<Pick<ModelDef, "id" | "name">>) | undefined,
ramBytes: number | undefined,
): string | null {
- // (A clip relit, extended or given a new moment on a hosted model with a window of its own: H3 Max relight up to 15 s.)
- if ((op === "v2v" || op === "relight-video" || op === "insert-moment" || op === "extend") && model?.id && (facts?.duration || facts?.width)) {
+ // (A clip relit, extended, reframed, erased from, driving a motion transfer or given a new moment on a hosted model with a
+ // window of its own: H3 Max relight up to 15 s, Luma Ray 3.2 reframe up to 10 s.)
+ const windowed = op === "v2v" || op === "relight-video" || op === "insert-moment" || op === "extend" || op === "reframe" || op === "remove-object" || op === "motion-transfer";
+ if (windowed && model?.id && (facts?.duration || facts?.width)) {
const named = { id: model.id, name: model.name ?? model.id, engine: model.engine };
return (
(facts.duration ? clipWindowProblem(named, facts.duration, facts.fps) : null) ??
diff --git a/src/server/fit-still.ts b/src/server/fit-still.ts
new file mode 100644
index 00000000..fdcee292
--- /dev/null
+++ b/src/server/fit-still.ts
@@ -0,0 +1,38 @@
+import "server-only";
+import sharp from "sharp";
+import { STILL_LIMITS, stillPlan, stillProblem, type StillFormat } from "@/lib/catalog/still-limits";
+import { imageSize } from "@/lib/image-size";
+
+/**
+ * A still fitted to the limits its endpoint documents (src/lib/catalog/still-limits.ts) before it's uploaded: a copy at
+ * a size, in a format and without alpha the endpoint takes. One it can't take even then is refused in Fuobe's words, so
+ * the run fails before it's queued and paid for. Anything that isn't a picture, a picture whose size can't be read, and
+ * an endpoint with no stated limits pass through as they are.
+ */
+type StillFile = { data: Buffer; contentType: string; name: string };
+
+const formatOf = (contentType: string): StillFormat =>
+ /png/i.test(contentType) ? "png" : /jpe?g/i.test(contentType) ? "jpeg" : /webp/i.test(contentType) ? "webp" : /gif/i.test(contentType) ? "gif" : /svg/i.test(contentType) ? "svg" : "other";
+
+export async function fitStill(endpoint: string, f: StillFile): Promise<StillFile> {
+ if (!STILL_LIMITS[endpoint] || !/^image\//i.test(f.contentType)) return f;
+ const size = imageSize(f.data);
+ if (!size) return f;
+ const plan = stillPlan(endpoint, { ...size, bytes: f.data.length, format: formatOf(f.contentType) });
+ let out = f;
+ if (plan) {
+ let img = sharp(f.data);
+ if (plan.resize) img = img.resize(plan.resize.width, plan.resize.height, { fit: "fill" });
+ // (A copy of a GIF or SVG, which sharp can't write, is a PNG.)
+ const own = formatOf(f.contentType);
+ const to = plan.toFormat ?? (own === "jpeg" || own === "webp" ? own : "png");
+ // A JPEG has no alpha: a cut-out is set on white, as a picture without alpha is, never on black.
+ if (plan.flatten || to === "jpeg") img = img.flatten({ background: "#ffffff" });
+ img = to === "png" ? img.png() : to === "webp" ? img.webp({ quality: 92 }) : img.jpeg({ quality: 92 });
+ out = { data: await img.toBuffer(), contentType: `image/${to}`, name: `${f.name.replace(/\.[^.]+$/, "")}.${to === "jpeg" ? "jpg" : to}` };
+ }
+ const now = imageSize(out.data);
+ const problem = now ? stillProblem(endpoint, { ...now, bytes: out.data.length, format: formatOf(out.contentType) }) : null;
+ if (problem) throw new Error(problem);
+ return out;
+}
diff --git a/src/server/generations.ts b/src/server/generations.ts
index 0754d784..8699f3ef 100644
--- a/src/server/generations.ts
+++ b/src/server/generations.ts
@@ -18,7 +18,7 @@ import { HELPER_FEATURES, HELPER_SUFFIX, isReviewStatus, type AssetUse, type Rev
import { checkWatermarkBoxes, COPY as WATERMARK_COPY, parseScanReport, rejectedRepair, type WatermarkQuality } from "@/lib/watermark";
import { sideMultipleProblem, upscaleTier } from "@/lib/av/upscale";
import { chainedWaitMessage, framesWait, keyframeChain } from "@/lib/catalog/keyframes";
-import { clipFpsProblem, clipSizeProblem, clipTotalProblem, clipWindowProblem, elementClipProblem, insertRangeProblem, portraitShapeProblem, sourceFrames, voiceWindowProblem } from "@/lib/catalog/clip-windows";
+import { clipBytesProblem, clipFileProblem, clipFpsProblem, clipSizeProblem, clipTotalProblem, clipWindowProblem, elementClipProblem, hasReferenceVoiceWindow, insertRangeProblem, portraitShapeProblem, referenceClipsProblem, referenceSeconds, referenceVoiceProblem, sourceFrames, voiceWindowProblem } from "@/lib/catalog/clip-windows";
import { avatarSeconds, clipEditSeconds, estimateCost, inferOperation, movedAppRequest, planGeneration, presetRoute, routeLoras, routesFor, sourceLengthProblem, withoutTriggers } from "@/lib/catalog/plan";
import { formatCost } from "@/lib/format";
import { framedLength, keepMatte, sizeValue } from "@/lib/catalog/payload";
@@ -126,6 +126,7 @@ import { offeredLoras, offeredRoutes, requireOffered } from "./model-access";
import { llmBackends, llmLabel, llmMissing, llmUsesClaude, probeLocal } from "./providers/llm";
import type { PollContext, PollResult, ProviderAdapter, RemoteOutput } from "./providers/types";
import { mediaFacts } from "./media-facts";
+import { fitStill } from "./fit-still";
import { renderPathVideo } from "./path-render";
import { songFormat, songToolProblem } from "@/lib/lyrics";
import { hostedUntested } from "@/lib/catalog/hosted-untested";
@@ -3332,7 +3333,11 @@ async function handOver(id: string, route: ModelRoute, providerId: ProviderId, p
if (was) return was;
return gate(async () => {
const f = await readRef(ref);
- return upload(`file:${ref}`, f.data, f.contentType, f.name);
+ // A picture outside the limits its endpoint documents (Qwen Image 3 edit: 384-2048 px, 10 MB, PNG without alpha;
+ // Recraft Crisp: PNG only) goes as a fitted copy, or is refused here before it is queued and paid for. Anything that
+ // isn't a picture, and endpoints with no stated limits, pass through unchanged.
+ const g = providerId === "mock" || plan.model.engine === "open" ? f : await fitStill(route.endpoint, f);
+ return upload(`file:${ref}`, g.data, g.contentType, g.name);
});
};
// An end-frame step crops the start frame before the edit (the recipe's crop of the subject).
@@ -3349,11 +3354,21 @@ async function handOver(id: string, route: ModelRoute, providerId: ProviderId, p
};
// The input clip's header (size, frame rate, length): upscalers that take a factor and frame-count routes read it.
let source: Pick<GenInput, "sourceSize" | "sourceFps" | "sourceDuration"> = {};
+ /** The input clip's file size (fal's H3 Max Turbo extend takes up to 50 MB: clipBytesProblem). */
+ let sourceBytes: number | undefined;
+ // A clip or voice in a container or of a size the endpoint documents it refuses (Kling O3 edit: .mp4/.mov up to 200 MB;
+ // FLUX.3 edit: MP4 under 50 MB; OmniHuman 2: a WAV or MP3 voice up to 15 MB) is refused here, in Fuobe's words, before
+ // it is uploaded and sent.
+ const fileProblem = (kind: "video" | "audio", f: { contentType: string; data: Buffer }) =>
+ providerId === "mock" || plan.model.engine === "open" ? null : clipFileProblem(plan.model, plan.op, kind, f.contentType, f.data.length);
const prepVideo = async (ref?: string) => {
if (!ref) return undefined;
return gate(async () => {
const f = await readRef(ref);
+ const kind = fileProblem("video", f);
+ if (kind) throw new Error(kind);
const facts = mediaFacts(f.data);
+ sourceBytes = f.data.length;
source = {
...(facts.width && facts.height ? { sourceSize: { width: facts.width, height: facts.height } } : {}),
...(facts.fps ? { sourceFps: facts.fps } : {}),
@@ -3367,6 +3382,8 @@ async function handOver(id: string, route: ModelRoute, providerId: ProviderId, p
if (!ref) return undefined;
return gate(async () => {
const f = await readRef(ref);
+ const kind = fileProblem("audio", f);
+ if (kind) throw new Error(kind);
const facts = mediaFacts(f.data);
if (facts.duration && !source.sourceDuration) source = { ...source, sourceDuration: facts.duration };
return upload(`file:${ref}`, f.data, f.contentType, f.name);
@@ -3391,8 +3408,28 @@ async function handOver(id: string, route: ModelRoute, providerId: ProviderId, p
// By the clip's place in inputs.videos, so a clip element (params.elements' video) finds its own length.
const clipLengths: (number | undefined)[] = [];
const billsClips = !!plan.model.pricing?.clipInput;
+ // Reference voices a model holds to a length (fal's Vidu Q4: 3 to 12 s each): one outside it is refused here, from its
+ // header, before it's sent or paid for. A header that says no length goes as it is.
+ const checksVoices = plan.op === "ref2v" && hasReferenceVoiceWindow(plan.model) && providerId !== "mock" && plan.model.engine !== "open";
+ // Reference clips and sound a hosted route holds to a window (fal's MiniMax H3 and H3 Max Turbo: 2–15 s each, 15 s of each
+ // kind together): their headers' lengths too, by their place in inputs.videos and inputs.audios.
+ const refWindow = providerId !== "mock" && plan.model.engine !== "open" ? referenceSeconds(plan.model.id) : undefined;
+ const audioLengths: (number | undefined)[] = [];
+ const prepRefVoice = async (ref: string | undefined, i: number) => {
+ if (!ref || !(checksVoices || refWindow?.kinds.includes("audios"))) return prep(ref);
+ const was = sent?.get(`file:${ref}`);
+ if (was) return was;
+ return gate(async () => {
+ const f = await readRef(ref);
+ const seconds = mediaFacts(f.data).duration;
+ if (seconds) audioLengths[i] = seconds;
+ const problem = seconds && checksVoices ? referenceVoiceProblem(plan.model, seconds, i + 1) : null;
+ if (problem) throw new Error(problem);
+ return upload(`file:${ref}`, f.data, f.contentType, f.name);
+ });
+ };
const prepClip = async (ref: string | undefined, i: number) => {
- if (!ref || !billsClips) return prep(ref);
+ if (!ref || !(billsClips || refWindow?.kinds.includes("videos"))) return prep(ref);
return gate(async () => {
const f = await readRef(ref);
const facts = mediaFacts(f.data);
@@ -3482,7 +3519,7 @@ async function handOver(id: string, route: ModelRoute, providerId: ProviderId, p
voiceAudio: await prep(req.inputs?.voiceAudio),
voiceAudio2: await prep(req.inputs?.voiceAudio2),
videos: (await Promise.all((req.inputs?.videos ?? []).map((ref, i) => prepClip(ref, i)))).filter(Boolean) as string[],
- audios: (await Promise.all((req.inputs?.audios ?? []).map(prep))).filter(Boolean) as string[],
+ audios: (await Promise.all((req.inputs?.audios ?? []).map((ref, i) => prepRefVoice(ref, i)))).filter(Boolean) as string[],
model3d: await prep(req.inputs?.model3d),
loras: plan.loras,
// Vary seeds across a batch so N jobs don't return N identical results.
@@ -3524,9 +3561,11 @@ async function handOver(id: string, route: ModelRoute, providerId: ProviderId, p
if (input.sourceDuration && !req.chain?.length && providerId !== "mock" && plan.model.engine !== "open") {
const problem =
plan.op === "avatar"
- ? voiceWindowProblem(plan.model, input.sourceDuration)
- : plan.op === "relight-video" || plan.op === "extend"
- ? clipWindowProblem(plan.model, input.sourceDuration, input.sourceFps)
+ ? voiceWindowProblem(plan.model, input.sourceDuration, input.resolution)
+ : plan.op === "relight-video" || plan.op === "extend" || plan.op === "reframe" || plan.op === "remove-object" || plan.op === "motion-transfer"
+ ? (clipWindowProblem(plan.model, input.sourceDuration, input.sourceFps) ??
+ (input.sourceSize ? clipSizeProblem(plan.model, input.sourceSize.width, input.sourceSize.height) : null) ??
+ clipBytesProblem(plan.model, sourceBytes))
: plan.op === "insert-moment"
? (clipWindowProblem(plan.model, input.sourceDuration, input.sourceFps) ?? insertRangeProblem(input.startTime, input.endTime, input.sourceDuration))
: null;
@@ -3534,6 +3573,14 @@ async function handOver(id: string, route: ModelRoute, providerId: ProviderId, p
// A relight is billed on the clip's length: priced for it once the header is read (an API call that didn't say).
if (plan.op === "relight-video" && plan.params.sourceDuration === undefined) update(id, { cost_usd: estimateCost(plan.model, { ...plan.params, sourceDuration: input.sourceDuration }, 1, plan.op) });
}
+ // Reference clips and sound outside the hosted route's window (fal's H3 and H3 Max Turbo: 2–15 s each, 15 s of each kind
+ // together) are refused once their headers are read, before the run is paid for.
+ if (refWindow) {
+ const problem =
+ referenceClipsProblem(plan.model, "videos", clipLengths.slice(0, req.inputs?.videos?.length ?? 0)) ??
+ referenceClipsProblem(plan.model, "audios", audioLengths.slice(0, req.inputs?.audios?.length ?? 0));
+ if (problem) throw new Error(problem);
+ }
const edits = plan.op === "v2v" || plan.op === "video-swap" || plan.op === "video-insert";
// An edit whose route sends no length keeps the clip's own (Kling 4.0's edit, swap and insert), whatever the request
// said: the clip is held to the model's window, sides, shape and frame rate before it's paid for. Frame-billed routes
@@ -3604,6 +3651,8 @@ async function handOver(id: string, route: ModelRoute, providerId: ProviderId, p
// a task of this database, made by this send: the mark says so.)
markSending(id, !!req.account, providerId === "comfyui" && onPoolWorkers());
const res = await adapter.submit({ generationId: id, model: plan.model, route, input });
+ // A talking video as long as its voice: the time its render may take (runningLimitMs).
+ const runLimitMs = plan.op === "avatar" && isCloudProvider(providerId) && input.sourceDuration ? Math.round(input.sourceDuration * LONG_RENDER_MS_PER_SECOND) : 0;
// A saved voice the cloud just cloned keeps the embedding (the owner's runs only), so its next line skips the clone.
if (typeof res.meta?.voiceEmbedding === "string" && !req.account) void keepVoiceEmbedding(req.inputs?.voiceAudio, res.meta.voiceEmbedding).catch(() => {});
const now = Date.now();
@@ -3628,6 +3677,7 @@ async function handOver(id: string, route: ModelRoute, providerId: ProviderId, p
jobIndex: index,
...(before.resent && { resent: true }),
...(before.declined && { declined: before.declined }),
+ ...(runLimitMs > 0 && { runLimitMs }),
}),
payload: res.payload ? JSON.stringify(res.payload).slice(0, 200_000) : null,
// A run sent again after its GPU lost it says so until its GPU reports on it; an Ideogram 4 run made again after
@@ -3669,6 +3719,13 @@ const TIMEOUT_MS = 45 * 60 * 1000;
const WORLDCAST_TIMEOUT_MS = 3 * 60 * 60 * 1000;
/** …and how long it may wait in the provider's queue first (a busy local GPU works through jobs one by one). */
const QUEUE_TIMEOUT_MS = 4 * 60 * 60 * 1000;
+/**
+ * A cloud talking video renders as long as its voice (fal's H3 Max lip sync: 5 s to 15 min, made in windows), and a cancel of a
+ * job in progress only signals fal's runner ("the request can still complete", and is billed): such a job may run this long
+ * for each second of its voice (meta.runLimitMs), never less than TIMEOUT_MS. A starting value, to be set from a live run's
+ * timings.
+ */
+const LONG_RENDER_MS_PER_SECOND = 10_000;
/**
* A row this old with no external id whose turn no app process that still runs holds (takeSubmitTurn) was cut off by a
* restart: a wait goes on, a hand-over fails. Tests make it shorter.
@@ -4064,7 +4121,8 @@ async function fastTick(): Promise<void> {
*/
function runningLimitMs(r: Pick<Row, "provider">, meta: Record<string, unknown>, account: string | undefined, onPool: boolean): number {
if (r.provider === "worldcast") return WORLDCAST_TIMEOUT_MS;
- if (r.provider !== "comfyui" || (account && !onPool)) return TIMEOUT_MS;
+ // (A cloud talking video as long as its voice may take longer: meta.runLimitMs, set when it was sent.)
+ if (r.provider !== "comfyui" || (account && !onPool)) return Math.max(TIMEOUT_MS, typeof meta.runLimitMs === "number" ? meta.runLimitMs : 0);
const wf = typeof meta.workflowId === "string" && !meta.workflowId.includes("{") ? meta.workflowId : null;
return runCeilingMs(wf ? poolLane(wf) : null);
}
diff --git a/tests/h3-reference-windows-server.test.ts b/tests/h3-reference-windows-server.test.ts
index 271cc5d5..9c4f4c27 100644
--- a/tests/h3-reference-windows-server.test.ts
+++ b/tests/h3-reference-windows-server.test.ts
@@ -108,8 +108,7 @@ const REFS = "minimax/h3-max-turbo/reference-to-video";
const EXTEND = "minimax/h3-max-turbo/extend-video";
const prompt = "Image 1 is the woman; she dances to Audio 1";
-// Skipped until the server side lands: src/server/generations.ts handOver reads the reference clips' and the extend clip's headers and checks referenceClipsProblem, clipSizeProblem and clipBytesProblem before the job. It fails without that change.
-describe.skip("reference clips and sound outside fal's window are refused before the job is sent", () => {
+describe("reference clips and sound outside fal's window are refused before the job is sent", () => {
it("H3 Max Turbo references: a clip under 2 s, clips over 15 s together, sound under 2 s", async () => {
const refs = (inputs: Record<string, unknown>) => ({ feature: "video", modelId: "minimax-h3-max-turbo-refs", op: "ref2v" as const, prompt, inputs });
expect(await outcome(refs({ images: [still()], videos: [clip(1)] }), REFS)).toEqual({ sent: false, error: expect.stringMatching(/^Reference clip 1 is 1 s, and .* needs at least 2 s/) });
diff --git a/tests/h3max-lipsync-long-run.test.ts b/tests/h3max-lipsync-long-run.test.ts
index 8624b1f8..5971cf03 100644
--- a/tests/h3max-lipsync-long-run.test.ts
+++ b/tests/h3max-lipsync-long-run.test.ts
@@ -75,8 +75,7 @@ async function after(id: string, minutes: number) {
return row(id);
}
-// Skipped until the server side lands: src/server/generations.ts runningLimitMs gives a long lip sync a run limit that follows its voice's length. It fails without that change.
-describe.skip("fal's H3 Max lip sync: a long voice's render isn't cut at 45 minutes", () => {
+describe("fal's H3 Max lip sync: a long voice's render isn't cut at 45 minutes", () => {
it("a 10-minute voice still runs 46 minutes in, and nothing is cancelled at fal", async () => {
const id = await lipsync(600);
const r = await after(id, 46);
diff --git a/tests/still-limits.test.ts b/tests/still-limits.test.ts
new file mode 100644
index 00000000..1d909bab
--- /dev/null
+++ b/tests/still-limits.test.ts
@@ -0,0 +1,35 @@
+import { describe, expect, it } from "vitest";
+import { STILL_LIMITS, stillPlan, stillProblem } from "@/lib/catalog/still-limits";
+
+const MB = 1024 * 1024;
+
+describe("still input limits documented by fal", () => {
+ it("Qwen Image 3 edit: a 4K PNG becomes a 2048 px copy without alpha", () => {
+ const p = stillPlan("alibaba/qwen-image-3/edit", { width: 3840, height: 2160, bytes: 9 * MB, format: "png" });
+ expect(p).toEqual({ resize: { width: 2048, height: 1152 }, flatten: true });
+ expect(stillProblem("alibaba/qwen-image-3/edit", { width: 2048, height: 1152, bytes: 3 * MB, format: "jpeg" })).toBeNull();
+ expect(stillProblem("alibaba/qwen-image-3/edit", { width: 3840, height: 2160, bytes: 3 * MB, format: "jpeg" })).toMatch(/2048/);
+ });
+ it("Qwen Image 3 edit: a small picture is enlarged to 384 px", () => {
+ expect(stillPlan("alibaba/qwen-image-3/edit", { width: 300, height: 600, bytes: MB, format: "jpeg" })?.resize).toEqual({ width: 384, height: 768 });
+ });
+ it("Recraft Crisp takes PNG only", () => {
+ expect(stillPlan("fal-ai/recraft/upscale/crisp", { width: 1024, height: 1024, bytes: MB, format: "jpeg" })).toEqual({ toFormat: "png" });
+ expect(stillPlan("fal-ai/recraft/upscale/crisp", { width: 1024, height: 1024, bytes: MB, format: "png" })).toBeNull();
+ });
+ it("Recraft vectorize stays under 16 MP and 4096 px", () => {
+ const p = stillPlan("fal-ai/recraft/vectorize", { width: 6000, height: 4000, bytes: 4 * MB, format: "jpeg" })!;
+ expect(p.resize!.width).toBeLessThanOrEqual(4095);
+ expect(p.resize!.width * p.resize!.height).toBeLessThan(16_000_000);
+ });
+ it("Seedream layerize refuses a strip thinner than 1:16", () => {
+ expect(stillProblem("bytedance/seedream/v5/pro/layerize", { width: 6000, height: 300, bytes: MB, format: "png" })).toMatch(/16:1/);
+ });
+ it("an oversize file is written again as JPEG", () => {
+ expect(stillPlan("fal-ai/bria/product-shot", { width: 2000, height: 2000, bytes: 20 * MB, format: "png" })).toEqual({ toFormat: "jpeg" });
+ });
+ it("endpoints with no stated limits are left alone", () => {
+ expect(stillPlan("fal-ai/nano-banana-pro/edit", { width: 8000, height: 8000, bytes: 50 * MB, format: "png" })).toBeNull();
+ expect(Object.keys(STILL_LIMITS).length).toBe(9);
+ });
+});
diff --git a/tests/vidu-reference-voices-run.test.ts b/tests/vidu-reference-voices-run.test.ts
index 3aad4083..9784534e 100644
--- a/tests/vidu-reference-voices-run.test.ts
+++ b/tests/vidu-reference-voices-run.test.ts
@@ -62,8 +62,7 @@ const run = (voices: string[]) =>
inputs: { images: [PNG_DATA_URI], audios: voices },
} as import("@/lib/catalog/types").GenerationRequest)[0];
-// Skipped until the server side lands: src/server/generations.ts handOver reads each reference voice's header and checks referenceVoiceProblem before the job. It fails without that change.
-describe.skip("Vidu Q4's reference voices", () => {
+describe("Vidu Q4's reference voices", () => {
it("refuses a voice shorter than 3 s or longer than 12 s before anything is sent to fal", async () => {
for (const [voices, words] of [
[[mp3(2)], "Vidu Q4 needs voice clips of at least 3 s, and Voice 1 is 2 s: use a longer one"],