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.

Kling 4.0: browser check and a research correction

Claude33c4f970b2e6
diff --git a/docs/research/new-models-10.md b/docs/research/new-models-10.md
index ad1dc790..83a3cdbe 100644
--- a/docs/research/new-models-10.md
+++ b/docs/research/new-models-10.md
@@ -645,6 +645,7 @@ Every brief also carries the standard CLOUD ONLY WHERE IT IS HOSTED, MAIN CHANGE
- **Reddit.** No search returned threads from r/StableDiffusion, r/comfyui, r/LocalLLaMA, r/aivideo or r/VideoEditing for September-October 2026, and the pages were not fetched directly. Community interest is measured here by Hugging Face trending and likes, the ComfyUI Wiki feed (which summarises Reddit and Discord launches) and GitHub. A pass on Reddit itself is still owed.
- **Kling 4.0:** text-to-video and video edit `llms.txt` pages show live endpoints; image-to-video and reference-to-video were not re-fetched (the brief says to). Whether Kling 4.0 reached general availability in Kling's own app is reported by one secondary source only. The Replicate schema for `kwaivgi/kling-v4.0` was not fetched.
+ - _Checked by `nm10-kling-4` on 2026-11-01 (correction):_ all four fal endpoints are `active` in fal's catalog with live `llms.txt` pages (re-read with `scripts/fetch-hosted-schemas.py --part4` into `paid-model-apis-4.json`), and Replicate's official `kwaivgi/kling-v4.0` (version f4dc4504, 2026-10-26) was read: one model for text, start/middle/end frames, reference images and clips and edits (`base_video`), with no shots or elements. Since round 4 the fal schemas gained `middle_image_urls` (up to 8 ordered keyframes between the first and last frame, with no time for each) on image- and reference-to-video, `video_urls` (up to 4) and `voice_ids` on the edit, and `voice_ids` / `end_image_url` on references; an element's clip is 3-8 s. So the hosted API does take ordered keyframes, but not timed ones: Frames mode stays on FLUX 3 Max, as §6.2 says, for that reason.
- **Licences not confirmed from a LICENSE file:** FastH3 Omni, Sol-H3-VAE (HF tag empty), LightVAE, Veda, the LightX2V Qwen-Image 2.1 Lightning LoRA (HF tag empty; comfyui-wiki says Apache-2.0), akhaliq's Qwen-Image 2.1 Next-Scene and Multiple-Angles LoRAs (HF API refused an anonymous read), FeyNoBg, UltraTex, the NVIDIA VFX node pack, Kroma, Krea 2 Edit V2, Anima Reference Adapter. MiniMax Music 3's own LICENSE ("MiniMax-Music3 Community License") differs from the Comfy-Org repack's Apache-2.0 tag: both are recorded.
- **VRAM:** almost no publisher gives consumer-GPU VRAM. Figures here are the publisher's tests (FastH3 Trim's 8 GB cap; FLUX 3 Klein's B200 peaks; CorridorKey's 4-6 GB; VoxCPM2's 8 GB) or third-party measurements (Freefield's 17.8 GB for Klein; one tester's ~90 GB for Alpha-Gen at 4K; the Hy-Nomas port's 5090 timings). Nothing ran on a GPU here.
- **Quality claims** (Pika's DesignArena rank and five-metric win; FLUX 3 Klein's arena Elo as cited by Freefield; FastH3 Trim's speed; Sol-H3-VAE's 16x decode; Zen Image Edit's similarity scores) are the authors' or a single third party's.
diff --git a/tests/account-kling-clips.test.ts b/tests/account-kling-clips.test.ts
index 8f356da4..44757195 100644
--- a/tests/account-kling-clips.test.ts
+++ b/tests/account-kling-clips.test.ts
@@ -38,19 +38,46 @@ afterAll(() => {
});
const CLIP = Buffer.from("not really an mp4, but a stored file");
-const asA = <T,>(fn: () => T) => runAsTenant({ kind: "account", id: a }, fn);
+const asA = <T>(fn: () => T) => runAsTenant({ kind: "account", id: a }, fn);
const kling = getModel("kling-4")!;
-const run = (videos: string[]): Req => ({ feature: "video", modelId: "kling-4", op: "ref2v", prompt: "@Maya walks in", inputs: { videos }, params: { duration: 10 } });
+const run = (videos: string[]): Req => ({
+ feature: "video",
+ modelId: "kling-4",
+ op: "ref2v",
+ prompt: "@Maya walks in",
+ inputs: { videos },
+ params: { duration: 10 },
+});
describe("an account's Kling 4.0 reference clips", () => {
it("are its own uploads: another's clip is refused before the run and again when its header is read", async () => {
- const mine = saveFile({ data: CLIP, contentType: "video/mp4", source: "upload", accountId: a });
- const theirs = saveFile({ data: CLIP, contentType: "video/mp4", source: "upload", accountId: b });
- const owners = saveFile({ data: CLIP, contentType: "video/mp4", source: "upload" });
+ const mine = saveFile({
+ data: CLIP,
+ contentType: "video/mp4",
+ source: "upload",
+ accountId: a,
+ });
+ const theirs = saveFile({
+ data: CLIP,
+ contentType: "video/mp4",
+ source: "upload",
+ accountId: b,
+ });
+ const owners = saveFile({
+ data: CLIP,
+ contentType: "video/mp4",
+ source: "upload",
+ });
expect(accountInputProblem(run([mine.url]), a)).toBeNull();
- expect(accountInputProblem(run([mine.url, theirs.url]), a)).toMatchObject({ code: "input-not-yours" });
- expect(accountInputProblem(run([owners.url]), a)).toMatchObject({ code: "input-not-yours" });
- expect(accountInputProblem(run(["https://example.com/clip.mp4"]), a)).toMatchObject({ code: "input-not-allowed" });
+ expect(accountInputProblem(run([mine.url, theirs.url]), a)).toMatchObject({
+ code: "input-not-yours",
+ });
+ expect(accountInputProblem(run([owners.url]), a)).toMatchObject({
+ code: "input-not-yours",
+ });
+ expect(
+ accountInputProblem(run(["https://example.com/clip.mp4"]), a),
+ ).toMatchObject({ code: "input-not-allowed" });
// The read that measures a clip for the price (generations.ts prepClip) goes through readRef's guard.
await asA(async () => {
expect((await readRef(mine.url)).data.equals(CLIP)).toBe(true);
@@ -60,12 +87,22 @@ describe("an account's Kling 4.0 reference clips", () => {
});
it("never take the owner's Elements as Kling elements", () => {
- const clip = saveFile({ data: CLIP, contentType: "video/mp4", source: "upload" });
+ const clip = saveFile({
+ data: CLIP,
+ contentType: "video/mp4",
+ source: "upload",
+ });
createElement({ name: "Maya", kind: "character", references: [clip.url] });
// The owner's run turns @Maya into a clip element; an account's sees no Elements, so its request stays as it was.
- expect(applyMentions(run([]), kling, mentionElements()).request.params?.elements).toEqual([{ video: 0 }]);
+ expect(
+ applyMentions(run([]), kling, mentionElements()).request.params?.elements,
+ ).toEqual([{ video: 0 }]);
asA(() => {
- const { request, mentioned } = applyMentions(run([]), kling, mentionElements());
+ const { request, mentioned } = applyMentions(
+ run([]),
+ kling,
+ mentionElements(),
+ );
expect(mentioned).toEqual([]);
expect(request.inputs?.videos).toEqual([]);
expect(request.params?.elements).toBeUndefined();
diff --git a/tests/e2e/kling-4.mjs b/tests/e2e/kling-4.mjs
new file mode 100644
index 00000000..3dff4344
--- /dev/null
+++ b/tests/e2e/kling-4.mjs
@@ -0,0 +1,333 @@
+// Kling 4.0 in the cloud (build package nm10-kling-4), browser check at 1440 and 390 px, light and dark: the Video
+// studio's Best list has Kling 4.0 next to Seedance 2.5 with its Top and 30 s badges and its price, the @ menu says its
+// elements take no voices yet; a Cinema take on Kling 4.0 runs (demo); Edit video lists Kling 4.0 at its edit rate
+// (in + out), says what a 720p clip is billed on before the total, and refuses a clip under 700 px before Generate;
+// nothing scrolls sideways.
+// Usage: node tests/e2e/kling-4.mjs [appUrl] [--shots <dir>] (app running in demo mode, ComfyUI unreachable; needs ffmpeg).
+// Exits 1 on a failed check.
+import { spawnSync } from "node:child_process";
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { launch, root } from "./_browser.mjs";
+
+const argv = process.argv.slice(2);
+const app = (
+ argv.find(
+ (a) => !a.startsWith("--") && argv[argv.indexOf(a) - 1] !== "--shots",
+ ) ?? "http://localhost:3000"
+).replace(/\/$/, "");
+const shots = argv.includes("--shots")
+ ? argv[argv.indexOf("--shots") + 1]
+ : undefined;
+if (shots) fs.mkdirSync(shots, { recursive: true });
+
+const failures = [];
+const check = (label, ok, extra = "") => {
+ console.log(
+ `${ok ? "ok " : "FAIL"} ${label.padEnd(76)}${extra ? ` ${extra}` : ""}`,
+ );
+ if (!ok) failures.push(label);
+};
+
+// A 4 s 1280×720 clip Kling 4.0 takes, and the 432×768 fixture it doesn't (under 700 px on a side).
+const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-kling-4-e2e-"));
+const clip720 = path.join(tmp, "clip-720p.mp4");
+const made = spawnSync("ffmpeg", [
+ "-v",
+ "error",
+ "-y",
+ "-f",
+ "lavfi",
+ "-i",
+ "testsrc=size=1280x720:rate=24",
+ "-t",
+ "4",
+ "-pix_fmt",
+ "yuv420p",
+ clip720,
+]);
+if (made.status !== 0) throw new Error(`ffmpeg failed: ${made.stderr}`);
+const narrow = path.join(root, "scripts/eval/fixtures/walk-6s.mp4");
+
+const browser = await launch();
+try {
+ for (const [width, height] of [
+ [1440, 900],
+ [390, 844],
+ ]) {
+ for (const scheme of ["light", "dark"]) {
+ const tag = `${width} ${scheme}`;
+ const context = await browser.newContext({
+ viewport: { width, height },
+ colorScheme: scheme,
+ ...(width < 500 ? { isMobile: true, hasTouch: true } : {}),
+ });
+ await context.addInitScript(() => {
+ try {
+ localStorage.setItem("fuobe.engine", "cloud");
+ } catch {}
+ });
+ const page = await context.newPage();
+ const shot = async (name) =>
+ shots &&
+ (await page.screenshot({
+ path: path.join(shots, `${name}-${width}-${scheme}.png`),
+ }));
+ const sideways = () =>
+ page.evaluate(
+ () =>
+ document.documentElement.scrollWidth -
+ document.documentElement.clientWidth,
+ );
+ const call = async (url, method = "GET", data) => {
+ const r = await page.request.fetch(app + url, {
+ method,
+ headers: { "Content-Type": "application/json" },
+ data: data === undefined ? undefined : JSON.stringify(data),
+ });
+ return r.json();
+ };
+
+ // ---- Video studio: the Best list and the @ menu.
+ await page.goto(`${app}/video`, { waitUntil: "load", timeout: 180_000 });
+ const chip = page.getByRole("button", { name: /^Model: / }).first();
+ await chip.waitFor({ timeout: 120_000 });
+ await page.waitForTimeout(800);
+ await chip.click();
+ const best = page
+ .locator("[cmdk-group]")
+ .filter({ hasText: /Best/ })
+ .first();
+ await best.waitFor({ timeout: 15_000 });
+ const ids = await best
+ .locator("[cmdk-item]")
+ .evaluateAll((els) =>
+ els.map((e) => (e.getAttribute("data-value") ?? "").split(":")[1]),
+ );
+ check(
+ `${tag}: Best lists Kling 4.0 right after Seedance 2.5`,
+ ids.indexOf("kling-4") === ids.indexOf("seedance-2-5") + 1 &&
+ ids.includes("kling-4"),
+ ids.join(", "),
+ );
+ const row = page.locator('[cmdk-item][data-value="best:kling-4"]');
+ const rowText = await row.innerText();
+ check(
+ `${tag}: its row shows Top, 30 s and the per-second price`,
+ /Top/.test(rowText) &&
+ /30 s/.test(rowText) &&
+ /\$0\.235\/sec/.test(rowText),
+ rowText.replace(/\n/g, " | "),
+ );
+ await shot("video-picker");
+ check(
+ `${tag}: no sideways scroll with the picker open`,
+ (await sideways()) <= 1,
+ `${await sideways()} px`,
+ );
+ await row.click();
+ await page.waitForTimeout(500);
+ check(
+ `${tag}: Kling 4.0 is picked`,
+ /Model: Kling 4\.0/.test(
+ (await page
+ .getByRole("button", { name: /^Model: / })
+ .first()
+ .getAttribute("aria-label")) ?? "",
+ ),
+ );
+ const prompt = page.locator("textarea").first();
+ await prompt.click();
+ await prompt.fill("A lighthouse keeper with @");
+ await page.waitForTimeout(400);
+ const menu = await page
+ .getByRole("listbox")
+ .filter({ hasText: /Elements/ })
+ .first()
+ .innerText()
+ .catch(() => "");
+ check(
+ `${tag}: the @ menu says Kling elements take no voices yet`,
+ /voices: not yet/.test(menu),
+ menu.replace(/\n/g, " | ").slice(0, 160),
+ );
+ await shot("video-mention");
+ await prompt.fill("");
+
+ // ---- Cinema: a Kling 4.0 take (demo).
+ const project = await call("/api/cinema/projects", "POST", {
+ name: `Kling 4 ${tag}`,
+ });
+ await page.goto(`${app}/cinema/${project.id}`, {
+ waitUntil: "load",
+ timeout: 180_000,
+ });
+ const scene = page.getByPlaceholder(/Describe your scene/);
+ await scene.waitFor({ timeout: 180_000 });
+ const engine = page.getByRole("radiogroup", { name: "Engine" });
+ const cloud = engine.getByRole("radio", { name: /Cloud/ });
+ for (
+ let i = 0;
+ i < 4 &&
+ (await cloud.count()) &&
+ (await cloud.getAttribute("aria-checked")) !== "true";
+ i++
+ ) {
+ await cloud.click();
+ await page.waitForTimeout(400);
+ }
+ const modelChip = page
+ .getByRole("button", { name: /^Model: / })
+ .locator("visible=true")
+ .first();
+ await modelChip.click();
+ const cmenu = page.getByRole("menu");
+ await cmenu.waitFor();
+ const items = (await cmenu.getByRole("menuitem").allInnerTexts()).map(
+ (t) => t.split("\n")[0],
+ );
+ check(
+ `${tag}: Cinema lists Kling 4.0 after Seedance 2.5`,
+ items.indexOf("Kling 4.0") === items.indexOf("Seedance 2.5") + 1,
+ items.join(", "),
+ );
+ await cmenu
+ .getByRole("menuitem")
+ .filter({ hasText: /^Kling 4\.0/ })
+ .first()
+ .click();
+ await cmenu.waitFor({ state: "hidden" });
+ await scene.fill(
+ "A storm over the bay, the lighthouse beam sweeping the waves",
+ );
+ await page.waitForTimeout(600);
+ await shot("cinema-bar");
+ check(
+ `${tag}: no sideways scroll in Cinema`,
+ (await sideways()) <= 1,
+ `${await sideways()} px`,
+ );
+ const before = (await call(`/api/cinema/projects/${project.id}/items`))
+ .items.length;
+ await page
+ .getByRole("button", { name: /^Generate/ })
+ .locator("visible=true")
+ .first()
+ .click();
+ let takes = [];
+ for (let i = 0; i < 20 && takes.length <= before; i++) {
+ await page.waitForTimeout(750);
+ takes = (await call(`/api/cinema/projects/${project.id}/items`)).items;
+ }
+ check(
+ `${tag}: Generate makes a Kling 4.0 take (demo)`,
+ takes.length === before + 1 && takes[0]?.modelId === "kling-4",
+ takes.map((g) => g.modelId).join(","),
+ );
+
+ // ---- Edit video: the edit's rate, what's billed, and the clip limits.
+ await page.goto(`${app}/video-edit?model=kling-4`, {
+ waitUntil: "load",
+ timeout: 180_000,
+ });
+ const editChip = page.getByRole("button", { name: /^Model: / }).first();
+ await editChip.waitFor({ timeout: 120_000 });
+ // The link's model applies once the page has hydrated.
+ await page
+ .waitForFunction(
+ () =>
+ /Model: Kling 4\.0/.test(
+ document
+ .querySelector("button[aria-label^='Model: ']")
+ ?.getAttribute("aria-label") ?? "",
+ ),
+ null,
+ { timeout: 15_000 },
+ )
+ .catch(() => {});
+ check(
+ `${tag}: Edit video opens on Kling 4.0`,
+ /Model: Kling 4\.0/.test(
+ (await editChip.getAttribute("aria-label")) ?? "",
+ ),
+ (await editChip.getAttribute("aria-label")) ?? "",
+ );
+ await editChip.click();
+ const editRow = page
+ .locator('[cmdk-item][data-value$=":kling-4"]')
+ .first();
+ await editRow.waitFor({ timeout: 15_000 });
+ const editRowText = await editRow.innerText();
+ check(
+ `${tag}: the picker prices Kling 4.0 as an edit (in + out)`,
+ /\$0\.141\/sec in\+out/.test(editRowText),
+ editRowText.replace(/\n/g, " | "),
+ );
+ await page.keyboard.press("Escape");
+ await page.waitForTimeout(300);
+ await page
+ .locator('input[type="file"][accept^="video/"]')
+ .first()
+ .setInputFiles(clip720);
+ const line = page.getByText(/in \+ \d+(\.\d)? s out: billed on/);
+ const shown = await line
+ .first()
+ .waitFor({ timeout: 30_000 })
+ .then(
+ () => true,
+ () => false,
+ );
+ check(
+ `${tag}: the clip's billing shows before the total`,
+ shown &&
+ /4 s in \+ 4 s out: billed on 8 s at \$0\.141\/s/.test(
+ await line.first().innerText(),
+ ),
+ shown ? await line.first().innerText() : "no line",
+ );
+ await page.locator("textarea").first().fill("Make it snow");
+ await page.waitForTimeout(500);
+ await shot("edit-video");
+ check(
+ `${tag}: no sideways scroll in Edit video`,
+ (await sideways()) <= 1,
+ `${await sideways()} px`,
+ );
+ // A clip under 700 px on a side: Generate says so instead of running.
+ await page
+ .getByRole("button", { name: /Remove|Clear/ })
+ .filter({ hasText: "" })
+ .first()
+ .click({ timeout: 3000 })
+ .catch(() => {});
+ await page
+ .locator('input[type="file"][accept^="video/"]')
+ .first()
+ .setInputFiles(narrow);
+ const blocked = await page
+ .waitForFunction(
+ () =>
+ [
+ ...document.querySelectorAll("button[aria-label^='Generate']"),
+ ].some((b) => /700 px/.test(b.getAttribute("aria-label") ?? "")),
+ null,
+ { timeout: 30_000 },
+ )
+ .then(
+ () => true,
+ () => false,
+ );
+ check(`${tag}: a 432×768 clip is refused before Generate`, blocked);
+ await context.close();
+ }
+ }
+} finally {
+ await browser.close();
+ fs.rmSync(tmp, { recursive: true, force: true });
+}
+if (failures.length) {
+ console.log(`\n${failures.length} failed`);
+ process.exit(1);
+}
+console.log("\nall passed");
diff --git a/tests/kling-4.test.ts b/tests/kling-4.test.ts
index 31391fdd..8b1d8676 100644
--- a/tests/kling-4.test.ts
+++ b/tests/kling-4.test.ts
@@ -14,14 +14,18 @@ process.env.FUOBE_DATA_DIR = dir;
process.env.COMFYUI_URL = "http://127.0.0.1:9";
afterAll(() => fs.rmSync(dir, { recursive: true, force: true }));
-const { getModel, getPreset, MODELS, modelsFor } = await import("@/lib/catalog");
+const { getModel, getPreset, MODELS, modelsFor } =
+ await import("@/lib/catalog");
const { buildPayload } = await import("@/lib/catalog/payload");
-const { clipBilling, estimateCost, planGeneration, routesFor } = await import("@/lib/catalog/plan");
+const { clipBilling, estimateCost, planGeneration, routesFor } =
+ await import("@/lib/catalog/plan");
const { applyMentions, elementsNote } = await import("@/lib/catalog/elements");
const { planCinema } = await import("@/lib/catalog/cinema");
-const { clipSizeProblem, clipTotalProblem, clipWindowProblem } = await import("@/lib/catalog/clip-windows");
+const { clipSizeProblem, clipTotalProblem, clipWindowProblem } =
+ await import("@/lib/catalog/clip-windows");
const { frameSupport } = await import("@/lib/catalog/keyframes");
-const { genjutsuProblem, getMaker, makerPrompt } = await import("@/lib/catalog/genjutsu");
+const { genjutsuProblem, getMaker, makerPrompt } =
+ await import("@/lib/catalog/genjutsu");
const { studioBest, clipBlocker, clipOutcome } = await import("@/lib/composer");
const { pickerPrice } = await import("@/lib/model-rows");
const { VIDEO_STUDIO } = await import("@/lib/studios");
@@ -31,13 +35,34 @@ type Req = import("@/lib/catalog/types").GenerationRequest;
type Route = import("@/lib/catalog/types").ModelRoute;
type StudioElement = import("@/lib/catalog/elements").StudioElement;
-type Spec = { type?: string; values?: unknown[]; maxItems?: number; minimum?: number; maximum?: number; required?: boolean; itemSchema?: Record<string, Spec> };
-type Endpoint = { provider: string; endpoint: string; status: string; checked?: string; inputs: Record<string, Spec>; keyFields: Record<string, string> };
-const research = (JSON.parse(fs.readFileSync("docs/research/paid-model-apis-4.json", "utf8")) as { endpoints: Endpoint[] }).endpoints;
-const schemaOf = (r: Route) => research.find((e) => e.provider === r.provider && e.endpoint === r.endpoint)!;
+type Spec = {
+ type?: string;
+ values?: unknown[];
+ maxItems?: number;
+ minimum?: number;
+ maximum?: number;
+ required?: boolean;
+ itemSchema?: Record<string, Spec>;
+};
+type Endpoint = {
+ provider: string;
+ endpoint: string;
+ status: string;
+ checked?: string;
+ inputs: Record<string, Spec>;
+ keyFields: Record<string, string>;
+};
+const research = (
+ JSON.parse(
+ fs.readFileSync("docs/research/paid-model-apis-4.json", "utf8"),
+ ) as { endpoints: Endpoint[] }
+).endpoints;
+const schemaOf = (r: Route) =>
+ research.find((e) => e.provider === r.provider && e.endpoint === r.endpoint)!;
const kling = getModel("kling-4")!;
-const route = (op: string, provider = "fal") => kling.routes.find((r) => r.op === op && r.provider === provider)!;
+const route = (op: string, provider = "fal") =>
+ kling.routes.find((r) => r.op === op && r.provider === provider)!;
/** Every field the payload sends is one the stored schema has, with a value its enum and limits allow. */
function checkAgainstSchema(r: Route, payload: Record<string, unknown>) {
@@ -46,20 +71,47 @@ function checkAgainstSchema(r: Route, payload: Record<string, unknown>) {
const spec = inputs[k];
expect(spec, `${r.endpoint} has no ${k}`).toBeDefined();
if (spec.values) expect(spec.values, `${r.endpoint} ${k}`).toContain(v);
- if (spec.type === "integer") expect(Number.isInteger(v), `${k} is whole`).toBe(true);
- if (typeof v === "number" && spec.minimum !== undefined) expect(v).toBeGreaterThanOrEqual(spec.minimum);
- if (typeof v === "number" && spec.maximum !== undefined) expect(v).toBeLessThanOrEqual(spec.maximum);
- if (Array.isArray(v) && spec.maxItems !== undefined) expect(v.length, `${k} items`).toBeLessThanOrEqual(spec.maxItems);
- if (Array.isArray(v) && spec.itemSchema) for (const item of v as Record<string, unknown>[]) for (const f of Object.keys(item)) expect(spec.itemSchema[f], `${k}.${f}`).toBeDefined();
+ if (spec.type === "integer")
+ expect(Number.isInteger(v), `${k} is whole`).toBe(true);
+ if (typeof v === "number" && spec.minimum !== undefined)
+ expect(v).toBeGreaterThanOrEqual(spec.minimum);
+ if (typeof v === "number" && spec.maximum !== undefined)
+ expect(v).toBeLessThanOrEqual(spec.maximum);
+ if (Array.isArray(v) && spec.maxItems !== undefined)
+ expect(v.length, `${k} items`).toBeLessThanOrEqual(spec.maxItems);
+ if (Array.isArray(v) && spec.itemSchema)
+ for (const item of v as Record<string, unknown>[])
+ for (const f of Object.keys(item))
+ expect(spec.itemSchema[f], `${k}.${f}`).toBeDefined();
}
- for (const [k, spec] of Object.entries(inputs)) if (spec.required) expect(payload[k], `${r.endpoint} requires ${k}`).toBeDefined();
+ for (const [k, spec] of Object.entries(inputs))
+ if (spec.required)
+ expect(payload[k], `${r.endpoint} requires ${k}`).toBeDefined();
}
/** Plan a request as the server does and build the payload its route sends. */
function payloadFor(req: Partial<Req>, provider = "fal") {
- const plan = planGeneration({ feature: "video", modelId: "kling-4", prompt: "A lighthouse keeper climbs the stairs", ...req } as Req, getModel, getPreset);
- const r = routesFor(plan.model, plan.op).find((x) => x.provider === provider)!;
- const payload = buildPayload(r.map!, { ...plan.params, prompt: plan.prompt, images: plan.request?.inputs?.images ?? req.inputs?.images, endImage: req.inputs?.endImage, video: req.inputs?.video, videos: req.inputs?.videos } as never);
+ const plan = planGeneration(
+ {
+ feature: "video",
+ modelId: "kling-4",
+ prompt: "A lighthouse keeper climbs the stairs",
+ ...req,
+ } as Req,
+ getModel,
+ getPreset,
+ );
+ const r = routesFor(plan.model, plan.op).find(
+ (x) => x.provider === provider,
+ )!;
+ const payload = buildPayload(r.map!, {
+ ...plan.params,
+ prompt: plan.prompt,
+ images: req.inputs?.images,
+ endImage: req.inputs?.endImage,
+ video: req.inputs?.video,
+ videos: req.inputs?.videos,
+ } as never);
return { plan, route: r, payload };
}
@@ -78,16 +130,27 @@ const el = (over: Partial<StudioElement>): StudioElement => ({
describe("research: Kling 4.0's API is open", () => {
it("records all four fal endpoints as active on 2026-11-01, and Replicate's model", () => {
- for (const ep of ["text-to-video", "image-to-video", "reference-to-video", "video-to-video/edit"]) {
+ for (const ep of [
+ "text-to-video",
+ "image-to-video",
+ "reference-to-video",
+ "video-to-video/edit",
+ ]) {
const e = research.find((x) => x.endpoint === `kling/v4/${ep}`)!;
expect(e.status, ep).toBe("active");
expect(e.checked, ep).toBe("2026-11-01");
}
- const rep = research.find((x) => x.endpoint === "kwaivgi/kling-v4.0" && x.provider === "replicate")!;
+ const rep = research.find(
+ (x) => x.endpoint === "kwaivgi/kling-v4.0" && x.provider === "replicate",
+ )!;
expect(rep.status).toBe("active");
- for (const f of Object.values(rep.keyFields)) expect(rep.inputs[f], f).toBeDefined();
+ for (const f of Object.values(rep.keyFields))
+ expect(rep.inputs[f], f).toBeDefined();
// The edit's reference clips came after round 4.
- expect(research.find((x) => x.endpoint === "kling/v4/video-to-video/edit")!.inputs.video_urls.maxItems).toBe(4);
+ expect(
+ research.find((x) => x.endpoint === "kling/v4/video-to-video/edit")!
+ .inputs.video_urls.maxItems,
+ ).toBe(4);
});
});
@@ -95,22 +158,60 @@ describe("catalog", () => {
it("is a closed cloud model with text, frames, references, edits and Genjutsu's swap and insert", () => {
expect(kling.engine).toBe("cloud");
expect(kling.badges).toEqual(expect.arrayContaining(["top", "30s"]));
- expect([...new Set(kling.routes.map((r) => r.op))].sort()).toEqual(["extend", "flf2v", "i2v", "ref2v", "t2v", "v2v", "video-insert", "video-swap"]);
+ expect([...new Set(kling.routes.map((r) => r.op))].sort()).toEqual([
+ "extend",
+ "flf2v",
+ "i2v",
+ "ref2v",
+ "t2v",
+ "v2v",
+ "video-insert",
+ "video-swap",
+ ]);
// Extend Video continues a take from its last frame with Kling's own image-to-video (the Kling family's chain).
- expect(kling.routes.find((r) => r.op === "extend")?.note).toMatch(/last frame/);
- expect(kling.routes.filter((r) => r.provider === "replicate").map((r) => r.op).sort()).toEqual(["flf2v", "i2v", "t2v"]);
+ expect(kling.routes.find((r) => r.op === "extend")?.note).toMatch(
+ /last frame/,
+ );
+ expect(
+ kling.routes
+ .filter((r) => r.provider === "replicate")
+ .map((r) => r.op)
+ .sort(),
+ ).toEqual(["flf2v", "i2v", "t2v"]);
expect(kling.defaults).toMatchObject({ resolution: "1080p", duration: 5 });
- expect(kling.options.durations).toEqual(expect.arrayContaining([3, 5, 10, 15, 20, 30]));
- expect(kling.options.aspectRatios).toEqual(expect.arrayContaining(["16:9", "9:16", "1:1", "21:9"]));
- expect(kling.options.elements).toMatchObject({ max: 7, views: 3, videos: 3, voices: false });
+ expect(kling.options.durations).toEqual(
+ expect.arrayContaining([3, 5, 10, 15, 20, 30]),
+ );
+ expect(kling.options.aspectRatios).toEqual(
+ expect.arrayContaining(["16:9", "9:16", "1:1", "21:9"]),
+ );
+ expect(kling.options.elements).toMatchObject({
+ max: 7,
+ views: 3,
+ videos: 3,
+ voices: false,
+ });
});
it("is in the Video studio's Best list next to Seedance 2.5, on the cloud only", () => {
- const best = studioBest(MODELS, "cloud", VIDEO_STUDIO.defaultModels.cloud, VIDEO_STUDIO.ops);
+ const best = studioBest(
+ MODELS,
+ "cloud",
+ VIDEO_STUDIO.defaultModels.cloud,
+ VIDEO_STUDIO.ops,
+ );
expect(best.indexOf("kling-4")).toBe(best.indexOf("seedance-2-5") + 1);
// "Open source only" lists open models: Kling 4.0 isn't one of them.
- expect(modelsFor({ kind: "video", ops: ["t2v"], engine: "open" }).map((m) => m.id)).not.toContain("kling-4");
- expect(modelsFor({ kind: "video", ops: ["v2v"], engine: "cloud" }).map((m) => m.id)).toContain("kling-4");
+ expect(
+ modelsFor({ kind: "video", ops: ["t2v"], engine: "open" }).map(
+ (m) => m.id,
+ ),
+ ).not.toContain("kling-4");
+ expect(
+ modelsFor({ kind: "video", ops: ["v2v"], engine: "cloud" }).map(
+ (m) => m.id,
+ ),
+ ).toContain("kling-4");
});
it("is a paid API in Settings → Models & licences, switched on", () => {
@@ -129,9 +230,16 @@ describe("catalog", () => {
describe("payloads against the stored schemas", () => {
it("text to video: 1080p by default, 21:9, whole seconds", () => {
- const { route: r, payload } = payloadFor({ params: { aspectRatio: "21:9", duration: 12 } });
+ const { route: r, payload } = payloadFor({
+ params: { aspectRatio: "21:9", duration: 12 },
+ });
expect(r.endpoint).toBe("kling/v4/text-to-video");
- expect(payload).toMatchObject({ prompt: expect.any(String), aspect_ratio: "21:9", duration: 12, resolution: "1080p" });
+ expect(payload).toMatchObject({
+ prompt: expect.any(String),
+ aspect_ratio: "21:9",
+ duration: 12,
+ resolution: "1080p",
+ });
checkAgainstSchema(r, payload);
});
@@ -148,35 +256,83 @@ describe("payloads against the stored schemas", () => {
expect(sent.reduce((n, s) => n + s.duration, 0)).toBe(payload.duration);
expect(payload.prompt).toBeUndefined();
// Each shot's prompt within the 512 characters the API takes.
- expect(Math.max(...sent.map((s) => s.prompt.length))).toBeLessThanOrEqual(512);
+ expect(Math.max(...sent.map((s) => s.prompt.length))).toBeLessThanOrEqual(
+ 512,
+ );
checkAgainstSchema(r, payload);
});
it("start and end frames", () => {
- const { route: r, payload } = payloadFor({ op: "flf2v", inputs: { images: ["https://x/start.png"], endImage: "https://x/end.png" } });
+ const { route: r, payload } = payloadFor({
+ op: "flf2v",
+ inputs: {
+ images: ["https://x/start.png"],
+ endImage: "https://x/end.png",
+ },
+ });
expect(r.endpoint).toBe("kling/v4/image-to-video");
- expect(payload).toMatchObject({ start_image_url: "https://x/start.png", end_image_url: "https://x/end.png" });
+ expect(payload).toMatchObject({
+ start_image_url: "https://x/start.png",
+ end_image_url: "https://x/end.png",
+ });
checkAgainstSchema(r, payload);
// Replicate takes the same run (a second provider), with its own names.
- const rep = payloadFor({ op: "flf2v", inputs: { images: ["https://x/start.png"], endImage: "https://x/end.png" } }, "replicate");
- expect(rep.payload).toMatchObject({ start_image: "https://x/start.png", end_image: "https://x/end.png", resolution: "1080p" });
+ const rep = payloadFor(
+ {
+ op: "flf2v",
+ inputs: {
+ images: ["https://x/start.png"],
+ endImage: "https://x/end.png",
+ },
+ },
+ "replicate",
+ );
+ expect(rep.payload).toMatchObject({
+ start_image: "https://x/start.png",
+ end_image: "https://x/end.png",
+ resolution: "1080p",
+ });
expect(rep.payload.reference_images).toBeUndefined();
checkAgainstSchema(rep.route, rep.payload);
});
it("references: images and clips, never the first reference as a start frame", () => {
- const { route: r, payload } = payloadFor({ op: "ref2v", inputs: { images: ["https://x/a.png", "https://x/b.png"], videos: ["https://x/c.mp4"] } });
+ const { route: r, payload } = payloadFor({
+ op: "ref2v",
+ inputs: {
+ images: ["https://x/a.png", "https://x/b.png"],
+ videos: ["https://x/c.mp4"],
+ },
+ });
expect(r.endpoint).toBe("kling/v4/reference-to-video");
- expect(payload).toMatchObject({ image_urls: ["https://x/a.png", "https://x/b.png"], video_urls: ["https://x/c.mp4"] });
+ expect(payload).toMatchObject({
+ image_urls: ["https://x/a.png", "https://x/b.png"],
+ video_urls: ["https://x/c.mp4"],
+ });
expect(payload.start_image_url).toBeUndefined();
checkAgainstSchema(r, payload);
});
it("an edit: the clip as @Video1, 4 reference clips, its own length (no duration sent)", () => {
- const videos = ["https://x/r1.mp4", "https://x/r2.mp4", "https://x/r3.mp4", "https://x/r4.mp4"];
- const { route: r, payload } = payloadFor({ feature: "video-edit", op: "v2v", prompt: "Make it snow", inputs: { video: "https://x/src.mp4", videos } });
+ const videos = [
+ "https://x/r1.mp4",
+ "https://x/r2.mp4",
+ "https://x/r3.mp4",
+ "https://x/r4.mp4",
+ ];
+ const { route: r, payload } = payloadFor({
+ feature: "video-edit",
+ op: "v2v",
+ prompt: "Make it snow",
+ inputs: { video: "https://x/src.mp4", videos },
+ });
expect(r.endpoint).toBe("kling/v4/video-to-video/edit");
- expect(payload).toMatchObject({ prompt: "Make it snow", video_url: "https://x/src.mp4", video_urls: videos, resolution: "1080p" });
+ expect(payload).toMatchObject({
+ prompt: "Make it snow",
+ video_url: "https://x/src.mp4",
+ video_urls: videos,
+ resolution: "1080p",
+ });
expect(payload.duration).toBeUndefined();
checkAgainstSchema(r, payload);
});
@@ -184,11 +340,28 @@ describe("payloads against the stored schemas", () => {
it("7 elements: a frontal photo and up to 3 angles each, or a clip, out of the image and clip lists", () => {
const r = route("ref2v");
const images = Array.from({ length: 16 }, (_, i) => `https://x/i${i}.png`);
- const groups = [{ images: [0, 1, 2, 3, 4] }, { images: [5] }, { video: 1 }, { images: [6, 7] }, { images: [8] }, { images: [9] }, { images: [10] }, { images: [11] }];
- const payload = buildPayload(r.map!, { prompt: "@Element1 meets @Element2", images, videos: ["https://x/ref.mp4", "https://x/el.mp4"], elements: groups });
+ const groups = [
+ { images: [0, 1, 2, 3, 4] },
+ { images: [5] },
+ { video: 1 },
+ { images: [6, 7] },
+ { images: [8] },
+ { images: [9] },
+ { images: [10] },
+ { images: [11] },
+ ];
+ const payload = buildPayload(r.map!, {
+ prompt: "@Element1 meets @Element2",
+ images,
+ videos: ["https://x/ref.mp4", "https://x/el.mp4"],
+ elements: groups,
+ });
const list = payload.elements as Record<string, unknown>[];
expect(list).toHaveLength(7);
- expect(list[0]).toEqual({ frontal_image_url: images[0], reference_image_urls: [images[1], images[2], images[3]] });
+ expect(list[0]).toEqual({
+ frontal_image_url: images[0],
+ reference_image_urls: [images[1], images[2], images[3]],
+ });
expect(list[1]).toEqual({ frontal_image_url: images[5] });
expect(list[2]).toEqual({ video_url: "https://x/el.mp4" });
// The images and clip the elements took leave their lists; the rest keep their order (@Image1.., @Video1..).
@@ -200,27 +373,73 @@ describe("payloads against the stored schemas", () => {
});
describe("@mentions become Kling elements", () => {
- const maya = el({ id: "m", name: "Maya", handle: "Maya", kind: "character", references: ["/api/files/m1.png", "/api/files/m2.png", "/api/files/m3.png"] });
- const cup = el({ id: "c", name: "Cup", handle: "Cup", kind: "prop", references: ["/api/files/cup.mp4"] });
- const bay = el({ id: "b", name: "Bay", handle: "Bay", kind: "location", references: ["/api/files/bay.png"] });
+ const maya = el({
+ id: "m",
+ name: "Maya",
+ handle: "Maya",
+ kind: "character",
+ references: ["/api/files/m1.png", "/api/files/m2.png", "/api/files/m3.png"],
+ });
+ const cup = el({
+ id: "c",
+ name: "Cup",
+ handle: "Cup",
+ kind: "prop",
+ references: ["/api/files/cup.mp4"],
+ });
+ const bay = el({
+ id: "b",
+ name: "Bay",
+ handle: "Bay",
+ kind: "location",
+ references: ["/api/files/bay.png"],
+ });
it("characters and props as @Element1.. (a clip as a video element), locations as reference images", () => {
- const req = { feature: "video", modelId: "kling-4", prompt: "@Maya drinks from @Cup on @Bay", params: {} } as Req;
+ const req = {
+ feature: "video",
+ modelId: "kling-4",
+ prompt: "@Maya drinks from @Cup on @Bay",
+ params: {},
+ } as Req;
const { request, notes } = applyMentions(req, kling, [maya, cup, bay]);
expect(request.op).toBe("ref2v");
expect(request.prompt).toMatch(/^@Element1 drinks from @Element2 on Bay/);
expect(request.prompt).toMatch(/Bay is the location in image 1/);
- expect(request.inputs?.images).toEqual(["/api/files/bay.png", ...maya.references]);
+ expect(request.inputs?.images).toEqual([
+ "/api/files/bay.png",
+ ...maya.references,
+ ]);
expect(request.inputs?.videos).toEqual(["/api/files/cup.mp4"]);
- expect(request.params?.elements).toEqual([{ images: [1, 2, 3] }, { video: 0 }]);
+ expect(request.params?.elements).toEqual([
+ { images: [1, 2, 3] },
+ { video: 0 },
+ ]);
expect(notes).toEqual([]);
- const payload = buildPayload(route("ref2v").map!, { prompt: request.prompt, images: request.inputs!.images, videos: request.inputs!.videos, elements: request.params!.elements });
+ const payload = buildPayload(route("ref2v").map!, {
+ prompt: request.prompt,
+ images: request.inputs!.images,
+ videos: request.inputs!.videos,
+ elements: request.params!.elements,
+ });
expect(payload.image_urls).toEqual(["/api/files/bay.png"]);
- expect(payload.elements).toEqual([{ frontal_image_url: maya.references[0], reference_image_urls: maya.references.slice(1) }, { video_url: "/api/files/cup.mp4" }]);
+ expect(payload.elements).toEqual([
+ {
+ frontal_image_url: maya.references[0],
+ reference_image_urls: maya.references.slice(1),
+ },
+ { video_url: "/api/files/cup.mp4" },
+ ]);
});
it("in an edit, the mention goes as an element of the edit", () => {
- const req = { feature: "video-edit", modelId: "kling-4", op: "v2v", prompt: "Replace the man with @Maya", inputs: { video: "/api/files/src.mp4" } } as Req;
+ const req = {
+ feature: "video-edit",
+ modelId: "kling-4",
+ op: "v2v",
+ prompt: "Replace the man with @Maya",
+ inputs: { video: "/api/files/src.mp4" },
+ } as Req;
const { request } = applyMentions(req, kling, [maya]);
expect(request.op).toBe("v2v");
expect(request.prompt).toBe("Replace the man with @Element1");
@@ -235,26 +454,67 @@ describe("@mentions become Kling elements", () => {
describe("price", () => {
it("text and frames: per output second by resolution (5 s at 720p = $0.785)", () => {
- expect(estimateCost(kling, { duration: 5, resolution: "720p" }, 1, "t2v")).toBe(0.785);
+ expect(
+ estimateCost(kling, { duration: 5, resolution: "720p" }, 1, "t2v"),
+ ).toBe(0.785);
expect(estimateCost(kling, { duration: 5 }, 1, "t2v")).toBe(1.175);
});
it("an edit bills max(input + output, 2x output) seconds at the clip rate", () => {
// A 10 s clip at 1080p: 10 in + 10 out = 20 billed at $0.141.
- expect(clipBilling(kling, { sourceDuration: 10 }, "v2v")).toMatchObject({ input: 10, output: 10, billed: 20, rate: 0.141 });
+ expect(clipBilling(kling, { sourceDuration: 10 }, "v2v")).toMatchObject({
+ input: 10,
+ output: 10,
+ billed: 20,
+ rate: 0.141,
+ });
expect(estimateCost(kling, { sourceDuration: 10 }, 1, "v2v")).toBe(2.82);
- expect(estimateCost(kling, { sourceDuration: 10, resolution: "720p" }, 1, "video-swap")).toBe(1.88);
+ expect(
+ estimateCost(
+ kling,
+ { sourceDuration: 10, resolution: "720p" },
+ 1,
+ "video-swap",
+ ),
+ ).toBe(1.88);
});
it("reference clips: input plus output, at least twice the output; their length unknown until read", () => {
// 4 s of clips with a 10 s take: 14 < 20, so twice the output.
- expect(estimateCost(kling, { duration: 10, resolution: "720p", clipSeconds: 4 }, 1, "ref2v")).toBe(1.88);
+ expect(
+ estimateCost(
+ kling,
+ { duration: 10, resolution: "720p", clipSeconds: 4 },
+ 1,
+ "ref2v",
+ ),
+ ).toBe(1.88);
// 15 s of clips: 25 s billed.
- expect(estimateCost(kling, { duration: 10, resolution: "720p", clipSeconds: 15 }, 1, "ref2v")).toBe(2.35);
+ expect(
+ estimateCost(
+ kling,
+ { duration: 10, resolution: "720p", clipSeconds: 15 },
+ 1,
+ "ref2v",
+ ),
+ ).toBe(2.35);
// Reference images alone are the plain rate.
- expect(estimateCost(kling, { duration: 10, resolution: "720p" }, 1, "ref2v")).toBe(1.57);
+ expect(
+ estimateCost(kling, { duration: 10, resolution: "720p" }, 1, "ref2v"),
+ ).toBe(1.57);
// The planner marks a run with clips, so its estimate is never the plain rate.
- const plan = planGeneration({ feature: "video", modelId: "kling-4", op: "ref2v", prompt: "x", inputs: { videos: ["/api/files/r.mp4"] }, params: { duration: 10, resolution: "720p" } } as Req, getModel, getPreset);
+ const plan = planGeneration(
+ {
+ feature: "video",
+ modelId: "kling-4",
+ op: "ref2v",
+ prompt: "x",
+ inputs: { videos: ["/api/files/r.mp4"] },
+ params: { duration: 10, resolution: "720p" },
+ } as Req,
+ getModel,
+ getPreset,
+ );
expect(plan.params.clipSeconds).toBe(0);
expect(estimateCost(plan.model, plan.params, 1, plan.op)).toBe(1.88);
});
@@ -262,7 +522,14 @@ describe("price", () => {
it("Edit video shows the edit's rate in the picker and what's billed before the total", () => {
expect(pickerPrice(kling, 0)).toBe("$0.235/sec");
expect(pickerPrice(kling, 0, true)).toBe("$0.141/sec in+out");
- expect(clipOutcome("v2v", { duration: 10, width: 1920, height: 1080 }, {}, kling)).toBe("10 s in + 10 s out: billed on 20 s at $0.141/s");
+ expect(
+ clipOutcome(
+ "v2v",
+ { duration: 10, width: 1920, height: 1080 },
+ {},
+ kling,
+ ),
+ ).toBe("10 s in + 10 s out: billed on 20 s at $0.141/s");
});
});
@@ -272,7 +539,15 @@ describe("limits checked before a paid call", () => {
expect(clipWindowProblem(kling, 30.03)).toBeNull();
expect(clipSizeProblem(kling, 640, 360)).toMatch(/700 px/);
expect(clipSizeProblem(kling, 1920, 1080)).toBeNull();
- expect(clipBlocker("v2v", { duration: 12, width: 640, height: 360 }, {}, kling, undefined)).toMatch(/700 px/);
+ expect(
+ clipBlocker(
+ "v2v",
+ { duration: 12, width: 640, height: 360 },
+ {},
+ kling,
+ undefined,
+ ),
+ ).toMatch(/700 px/);
expect(clipTotalProblem(kling, 34)).toMatch(/30 s of clips in all/);
expect(clipTotalProblem(kling, 30)).toBeNull();
});
@@ -287,7 +562,17 @@ describe("Cinema Studio", () => {
{ prompt: "A ship turns toward the light", duration: 8 },
];
const plan = planCinema(
- { engine: "cloud", mode: "video", action: "generate", modelId: "kling-4", prompt: "A storm at night", settings: SETTINGS, duration: 30, batch: 1, multiShot: { mode: "manual", shots } },
+ {
+ engine: "cloud",
+ mode: "video",
+ action: "generate",
+ modelId: "kling-4",
+ prompt: "A storm at night",
+ settings: SETTINGS,
+ duration: 30,
+ batch: 1,
+ multiShot: { mode: "manual", shots },
+ },
{ cloudAllowed: true },
);
expect(plan.model.id).toBe("kling-4");
@@ -296,15 +581,32 @@ describe("Cinema Studio", () => {
expect(req.params?.shots?.map((s) => s.duration)).toEqual([12, 10, 8]);
const planned = planGeneration(req, getModel, getPreset);
expect(planned.params.duration).toBe(30);
- const r = routesFor(planned.model, planned.op).find((x) => x.provider === "fal")!;
- const payload = buildPayload(r.map!, { ...planned.params, prompt: planned.prompt });
+ const r = routesFor(planned.model, planned.op).find(
+ (x) => x.provider === "fal",
+ )!;
+ const payload = buildPayload(r.map!, {
+ ...planned.params,
+ prompt: planned.prompt,
+ });
expect((payload.multi_prompt as unknown[]).length).toBe(3);
expect(payload.duration).toBe(30);
expect(plan.costUsd).toBeCloseTo(30 * 0.235, 3);
});
it("any whole second from 3 to 30 for a single take", () => {
- const plan = planCinema({ engine: "cloud", mode: "video", action: "generate", modelId: "kling-4", prompt: "x", settings: SETTINGS, duration: 25, batch: 1 }, { cloudAllowed: true });
+ const plan = planCinema(
+ {
+ engine: "cloud",
+ mode: "video",
+ action: "generate",
+ modelId: "kling-4",
+ prompt: "x",
+ settings: SETTINGS,
+ duration: 25,
+ batch: 1,
+ },
+ { cloudAllowed: true },
+ );
expect(plan.steps[0].request.params?.duration).toBe(25);
expect(plan.notes.join(" ")).not.toMatch(/makes \d+s clips/);
});
@@ -314,19 +616,66 @@ describe("Genjutsu", () => {
it("offers Kling 4.0's edit for Object swap and Insert, with @Video1 and @Image tags and its own limits", () => {
const m = getMaker("kling-4", "cloud")!;
expect(m.modes).toEqual(["swap", "insert"]);
- expect(makerPrompt({ mode: "swap", maker: m, subject: "the red car", refs: 2 })).toMatch(/^Replace the red car in @Video1 with @Image1, @Image2/);
- expect(makerPrompt({ mode: "insert", maker: m, refs: 1, prompt: "on the table" })).toMatch(/^Add @Image1 to @Video1: on the table/);
- const check = { mode: "swap" as const, maker: m, references: 1, subject: "the car", target: "type" as const, range: { start: 0, end: 10 } };
- expect(genjutsuProblem({ ...check, source: { url: "/api/files/s.mp4", duration: 10, width: 640, height: 360 } } as never)).toMatch(/700 px/);
- expect(genjutsuProblem({ ...check, source: { url: "/api/files/s.mp4", duration: 10, width: 1920, height: 1080 } } as never)).toBeNull();
+ expect(
+ makerPrompt({ mode: "swap", maker: m, subject: "the red car", refs: 2 }),
+ ).toMatch(/^Replace the red car in @Video1 with @Image1, @Image2/);
+ expect(
+ makerPrompt({
+ mode: "insert",
+ maker: m,
+ refs: 1,
+ prompt: "on the table",
+ }),
+ ).toMatch(/^Add @Image1 to @Video1: on the table/);
+ const check = {
+ mode: "swap" as const,
+ maker: m,
+ references: 1,
+ subject: "the car",
+ target: "type" as const,
+ range: { start: 0, end: 10 },
+ };
+ expect(
+ genjutsuProblem({
+ ...check,
+ source: {
+ url: "/api/files/s.mp4",
+ duration: 10,
+ width: 640,
+ height: 360,
+ },
+ } as never),
+ ).toMatch(/700 px/);
+ expect(
+ genjutsuProblem({
+ ...check,
+ source: {
+ url: "/api/files/s.mp4",
+ duration: 10,
+ width: 1920,
+ height: 1080,
+ },
+ } as never),
+ ).toBeNull();
});
});
describe("demo mode", () => {
it("the mock provider makes a placeholder clip for every route, with no key", async () => {
for (const r of kling.routes) {
- const sub = await mockProvider.submit({ generationId: "g", model: kling, route: r, input: { prompt: "x", images: ["a.png"], video: "v.mp4", duration: 5 } });
- const res = await mockProvider.poll({ externalId: sub.externalId, meta: { ...sub.meta, startedAt: 0 }, route: r, model: kling, createdAt: 0 });
+ const sub = await mockProvider.submit({
+ generationId: "g",
+ model: kling,
+ route: r,
+ input: { prompt: "x", images: ["a.png"], video: "v.mp4", duration: 5 },
+ });
+ const res = await mockProvider.poll({
+ externalId: sub.externalId,
+ meta: { ...sub.meta, startedAt: 0 },
+ route: r,
+ model: kling,
+ createdAt: 0,
+ });
if (res.state !== "succeeded") throw new Error(`${r.op}: ${res.state}`);
expect(res.outputs[0].kind, r.op).toBe("video");
}