@marlinjai/studio-mcp 0.18.1 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -630,6 +630,26 @@ var ROUTES = [
630
630
  withReferences: { "1080p": "fal/kling-o3-pro-reference-to-video" }
631
631
  }
632
632
  },
633
+ {
634
+ kind: "video",
635
+ id: "route/gemini-omni",
636
+ label: "Gemini Omni 1.1 Flash (KIE, fal fallback)",
637
+ primary: "kie/gemini-omni-flash-1-1-image-to-video",
638
+ // fal renders every length KIE does (4 to 10 s in even steps) and the same
639
+ // sizes and shapes, from the same frame fields (2026-11-03). One difference:
640
+ // fal always renders sound with the clip, so a clip that falls back has it.
641
+ fallback: { start: "fal/gemini-omni-flash-1-1-image-to-video" }
642
+ },
643
+ {
644
+ kind: "video",
645
+ id: "route/minimax-h3",
646
+ label: "MiniMax H3 (KIE, fal fallback)",
647
+ primary: "kie/minimax-h3-image-to-video",
648
+ // fal renders KIE's sizes (768P and 2K) and lengths from 5 to 15 s from the
649
+ // same frame fields (2026-11-04); KIE also renders 4 s, which fal does not,
650
+ // so a 4 s clip has no fallback. fal always renders sound with the clip.
651
+ fallback: { start: "fal/minimax-h3-image-to-video" }
652
+ },
633
653
  {
634
654
  kind: "video",
635
655
  id: "route/seedance-2-0",
@@ -929,6 +949,71 @@ var CATALOG_ENTRIES = [
929
949
  description: "ByteDance Seedream 5 Pro edit via fal, up to 10 reference images, 1K or 2K.",
930
950
  capabilities: { resolutions: ["1K", "2K"], needsImageInput: true, maxInputImages: 10 }
931
951
  },
952
+ // ── fal.ai: Ideogram 4.5 Edit, precise local edits ─────────────────────
953
+ {
954
+ id: "fal/ideogram-4-5-edit",
955
+ provider: "fal",
956
+ modality: "image",
957
+ task: "image-edit",
958
+ label: "Ideogram 4.5 Edit (fal)",
959
+ // Measured 2026-11-04 on a series of edits of one portrait: the background
960
+ // held at a structural similarity (SSIM) of 0.9999 between successive
961
+ // edits, against 0.98 for Nano Banana 2 Edit, which reframed the shot on
962
+ // the first edit. Ideogram's first edit smoothed the face a little; after
963
+ // that the face held.
964
+ description: "Ideogram 4.5 in precise edit mode: changes what the prompt asks for (a garment, a prop, the background) and keeps every pixel it did not touch, so a series of edits keeps the shot. Image 1 is the image edited, up to 4 more are references, and the result keeps the shape of image 1. Quality low, medium or high.",
965
+ capabilities: {
966
+ // The tiers carry Ideogram's QUALITY (providers/fal.ts, `ideogramQuality`):
967
+ // 0.5K low, 1K medium (the default), 2K high. fal's very_low is not
968
+ // offered (decided 2026-11-04). Labelled as qualities
969
+ // wherever shown (`imageTierLabel`).
970
+ resolutions: ["0.5K", "1K", "2K"],
971
+ tierKind: "quality",
972
+ editsFirstImage: true,
973
+ needsImageInput: true,
974
+ maxInputImages: 5
975
+ }
976
+ },
977
+ // ── fal.ai: OpenAI GPT Image 2, text in images and exact edits ─────────
978
+ // Added 2026-11-04 (plan 2026-11-04-skool-prompting, item M2): the course
979
+ // Marlin follows names it the best model for rendering text (labels,
980
+ // packaging) and for edits that change only what was asked.
981
+ {
982
+ id: "fal/gpt-image-2",
983
+ provider: "fal",
984
+ modality: "image",
985
+ task: "text-to-image",
986
+ label: "GPT Image 2 (fal)",
987
+ description: "OpenAI GPT Image 2 via fal: the strongest at text inside the image (labels, packaging, signs, posters) and at following long, detailed prompts. Slower than Nano Banana. Quality low, medium or high, about 1 megapixel in every shape; prompts up to about 4000 characters of English (4000 bytes).",
988
+ capabilities: {
989
+ // The tiers carry GPT Image 2's QUALITY (providers/fal.ts,
990
+ // `tierQuality`): 0.5K low, 1K medium (the default), 2K high. The size
991
+ // follows the shape alone (`FAL_GPT_IMAGE_2_SIZE_BY_ASPECT`).
992
+ resolutions: ["0.5K", "1K", "2K"],
993
+ tierKind: "quality",
994
+ maxInputImages: 0
995
+ }
996
+ },
997
+ {
998
+ id: "fal/gpt-image-2-edit",
999
+ provider: "fal",
1000
+ modality: "image",
1001
+ task: "image-edit",
1002
+ label: "GPT Image 2 Edit (fal)",
1003
+ description: "OpenAI GPT Image 2 edit via fal: changes only what the prompt asks for and renders text and labels cleanly (packaging, signs). Studio sends the image to edit first and up to 7 references after it; say in the prompt what to change. The result takes the shape you pick: pick the source image's shape to keep it. Slower than Nano Banana. Quality low, medium or high, about 1 megapixel in every shape; prompts up to about 4000 characters of English (4000 bytes).",
1004
+ capabilities: {
1005
+ resolutions: ["0.5K", "1K", "2K"],
1006
+ tierKind: "quality",
1007
+ // fal's `image_urls` is a plain list with no field for the image
1008
+ // edited. Studio's convention: the image to edit goes first and the
1009
+ // mention prompt names it image 1, which is what lets the composer, the
1010
+ // generate route and the canvas refuse an edit with no image before
1011
+ // anything is admitted (`editSourceHold`).
1012
+ editsFirstImage: true,
1013
+ needsImageInput: true,
1014
+ maxInputImages: 8
1015
+ }
1016
+ },
932
1017
  {
933
1018
  id: "fal/flux-1-1-pro",
934
1019
  provider: "fal",
@@ -1214,7 +1299,7 @@ var CATALOG_ENTRIES = [
1214
1299
  modality: "video",
1215
1300
  task: "image-to-video",
1216
1301
  label: "Gemini Omni 1.1 Flash (KIE)",
1217
- description: "Google Gemini Omni 1.1 Flash via KIE, first-and-last-frame mode. A start frame and an optional end frame, 4, 6, 8 or 10 s, 720p to 4K, 16:9 or 9:16. KIE refuses registered characters in this mode, so identity comes from the frames alone. Accepted a minted character's photoreal stills on 2026-09-24 (set 9:16 for a portrait still: it defaults to 16:9 and crops). No fal equivalent.",
1302
+ description: "Google Gemini Omni 1.1 Flash via KIE, first-and-last-frame mode. A start frame and an optional end frame, 4, 6, 8 or 10 s, 720p to 4K, 16:9 or 9:16. KIE refuses registered characters in this mode, so identity comes from the frames alone. Accepted a minted character's photoreal stills on 2026-09-24 (set 9:16 for a portrait still: it defaults to 16:9 and crops).",
1218
1303
  capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1219
1304
  },
1220
1305
  {
@@ -1310,6 +1395,53 @@ var CATALOG_ENTRIES = [
1310
1395
  characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 7 }
1311
1396
  }
1312
1397
  },
1398
+ {
1399
+ id: "fal/gemini-omni-flash-1-1-image-to-video",
1400
+ provider: "fal",
1401
+ modality: "video",
1402
+ task: "image-to-video",
1403
+ label: "Gemini Omni 1.1 Flash (image-to-video)",
1404
+ description: "Google Gemini Omni 1.1 Flash via fal, the fallback for the KIE entry and the route that runs images of people. A start frame and an optional end frame, 3 to 10 s, 720p, 1080p or 4K, 16:9 or 9:16 (16:9 unless set, so set 9:16 for a portrait still), with audio included. No seed. Not yet tested with a minted character on fal (the KIE route accepted one).",
1405
+ // 8 s at fal's 720p default, the length and size the KIE entry renders.
1406
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1407
+ },
1408
+ {
1409
+ id: "fal/kling-3-0-standard-image-to-video",
1410
+ provider: "fal",
1411
+ modality: "video",
1412
+ task: "image-to-video",
1413
+ label: "Kling 3.0 Standard (image-to-video)",
1414
+ description: "Kuaishou Kling 3.0 Standard via fal, a model of its own next to Kling O3 (Kling 3.0 Omni). A start frame and an optional end frame, 3 to 15 s, in the start frame's shape at the tier's size, silent unless the job sets generateAudio. Takes a negative prompt, no seed. Not yet tested with a minted character.",
1415
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1416
+ },
1417
+ {
1418
+ id: "fal/kling-3-0-pro-image-to-video",
1419
+ provider: "fal",
1420
+ modality: "video",
1421
+ task: "image-to-video",
1422
+ label: "Kling 3.0 Pro (image-to-video)",
1423
+ description: "Kuaishou Kling 3.0 Pro via fal, a model of its own next to Kling O3 (Kling 3.0 Omni). A start frame and an optional end frame, 3 to 15 s, in the start frame's shape at the tier's size, silent unless the job sets generateAudio. Takes a negative prompt, no seed. Not yet tested with a minted character.",
1424
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1425
+ },
1426
+ {
1427
+ id: "fal/minimax-h3-image-to-video",
1428
+ provider: "fal",
1429
+ modality: "video",
1430
+ task: "image-to-video",
1431
+ label: "MiniMax H3 (image-to-video)",
1432
+ description: "MiniMax H3 via fal (the base model, not fal's post-trained H3 Max), the fallback for the KIE entry and the route that runs images of people. A start frame and an optional end frame, 5 to 15 s, 768p (the 720p setting), 2K (the 1080p setting, used unless set) or 4K, in the start frame's shape, always with sound. Takes a seed, no negative prompt. Rendered a 5 s test clip on 2026-11-04; not yet tested with a minted character on fal (the KIE route accepted one).",
1433
+ // 5 s at fal's 2K default.
1434
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1435
+ },
1436
+ {
1437
+ id: "fal/kling-4-0-image-to-video",
1438
+ provider: "fal",
1439
+ modality: "video",
1440
+ task: "image-to-video",
1441
+ label: "Kling 4.0 (image-to-video)",
1442
+ description: "Kuaishou Kling 4.0 via fal; not served by KIE. A start frame and an optional end frame, 3 to 30 s, 720p or 1080p (1080p unless set), in the start frame's shape, always with sound. No seed or negative prompt. fal also takes in-between keyframes and per-shot prompts, which Studio does not send yet. Rendered a 3 s test clip on 2026-11-03; not yet tested with a minted character.",
1443
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1444
+ },
1313
1445
  {
1314
1446
  id: "fal/ltx-2-5-fast-image-to-video",
1315
1447
  provider: "fal",
@@ -1426,6 +1558,37 @@ var CATALOG_ENTRIES = [
1426
1558
  // resolution, so the settings panel offers none and validation refuses one.
1427
1559
  capabilities: { needsImageInput: true, maxInputImages: 4, resolutions: [] }
1428
1560
  },
1561
+ // ── fal.ai: lip sync (face image + audio -> talking video) ─────────────
1562
+ // Inputs, limits and prices from each model's fal page, checked 2026-11-28
1563
+ // (providers/lip-sync-specs.ts holds the limits).
1564
+ {
1565
+ id: "fal/heygen-avatar-6",
1566
+ provider: "fal",
1567
+ modality: "video",
1568
+ task: "lip-sync",
1569
+ label: "HeyGen Avatar 6 (lip sync)",
1570
+ description: "HeyGen Avatar 6 via fal. Makes one face image speak an audio file (MP3 or WAV, up to 300 s) as a 1080p talking video, calm head motion. An optional prompt describes the motion. Run the speech node first, then this one: Studio reads the length of the audio before it starts. Default lip sync.",
1571
+ capabilities: { needsImageInput: true, maxInputImages: 1, resolutions: [] },
1572
+ isDefault: true
1573
+ },
1574
+ {
1575
+ id: "fal/heygen-avatar-6-turbo",
1576
+ provider: "fal",
1577
+ modality: "video",
1578
+ task: "lip-sync",
1579
+ label: "HeyGen Avatar 6 Turbo (lip sync)",
1580
+ description: "HeyGen Avatar 6 Turbo via fal: the faster variant of Avatar 6, with the same inputs.",
1581
+ capabilities: { needsImageInput: true, maxInputImages: 1, resolutions: [] }
1582
+ },
1583
+ {
1584
+ id: "fal/omnihuman-v2",
1585
+ provider: "fal",
1586
+ modality: "video",
1587
+ task: "lip-sync",
1588
+ label: "OmniHuman v2 (lip sync)",
1589
+ description: "ByteDance OmniHuman v2 via fal. Makes one face image speak an audio file (MP3 or WAV, 4 to 300 s) as a talking video.",
1590
+ capabilities: { needsImageInput: true, maxInputImages: 1, resolutions: [] }
1591
+ },
1429
1592
  // ── fal.ai: vision + utility (B4) ──────────────────────────────────────
1430
1593
  {
1431
1594
  id: "fal/florence-2-detailed-caption",
@@ -1534,6 +1697,29 @@ var CATALOG_ENTRIES = [
1534
1697
  },
1535
1698
  isDefault: true
1536
1699
  },
1700
+ {
1701
+ id: "elevenlabs/tts-v4",
1702
+ provider: "elevenlabs",
1703
+ modality: "audio",
1704
+ task: "text-to-speech",
1705
+ label: "ElevenLabs Eleven v4 (TTS)",
1706
+ description: "ElevenLabs Eleven v4 text-to-speech. 90+ languages, follows audio tags such as [whispers] written into the text. Takes Stability and Similarity, no Speed. Returns mp3 bytes synchronously. Up to 10,000 characters per request.",
1707
+ // Checked 2026-11-28. ElevenLabs' v4 page: two voice settings, Stability
1708
+ // and Similarity; "Style and Speed sliders are not available". The text
1709
+ // limit: its API price page says 10,000 characters per request, while
1710
+ // GET /v1/models and the models page say 100,000. Studio takes the lower
1711
+ // figure, which both accept; it is also what a voice node whose text
1712
+ // arrives at run time is held at.
1713
+ capabilities: {
1714
+ speech: {
1715
+ maxCharacters: 1e4,
1716
+ voiceSettings: {
1717
+ stability: { min: 0, max: 1, step: 0.05, default: 0.5 },
1718
+ similarityBoost: { min: 0, max: 1, step: 0.05, default: 0.75 }
1719
+ }
1720
+ }
1721
+ }
1722
+ },
1537
1723
  {
1538
1724
  id: "elevenlabs/scribe-v1",
1539
1725
  provider: "elevenlabs",
@@ -1663,6 +1849,18 @@ function routeEntry(id) {
1663
1849
  function tryGetModel(id) {
1664
1850
  return MODEL_CATALOG.find((m) => m.id === id) ?? routeEntry(id);
1665
1851
  }
1852
+ var ASPECT_RATIOS = [
1853
+ "1:1",
1854
+ "3:2",
1855
+ "2:3",
1856
+ "3:4",
1857
+ "4:3",
1858
+ "4:5",
1859
+ "5:4",
1860
+ "9:16",
1861
+ "16:9",
1862
+ "21:9"
1863
+ ];
1666
1864
  function omniReferencesPrompt(prompt, elements) {
1667
1865
  const parts = ["Image 1 is the exact scene and the first frame of the video: start the clip on it and keep its setting, framing and light."];
1668
1866
  let next = 2;
@@ -1986,6 +2184,15 @@ var OPENROUTER_VIDEO_SPECS = {
1986
2184
  "google/veo-3.1-fast": veoSpec2("Veo 3.1 Fast", ["720p", "1080p", "4k"]),
1987
2185
  "google/veo-3.1": veoSpec2("Veo 3.1", ["720p", "1080p", "4k"])
1988
2186
  };
2187
+ var HEYGEN_AVATAR_6_ENDPOINT = "heygen/avatar-6/image-to-video";
2188
+ var HEYGEN_AVATAR_6_TURBO_ENDPOINT = "heygen/avatar-6/turbo/image-to-video";
2189
+ var OMNIHUMAN_V2_ENDPOINT = "bytedance/omnihuman/v2";
2190
+ var LIP_SYNC_MAX_AUDIO_BYTES = 15 * 1024 * 1024;
2191
+ var LIP_SYNC_SPECS = {
2192
+ [HEYGEN_AVATAR_6_ENDPOINT]: { minSeconds: 1, maxSeconds: 300, promptField: "motion_prompt", motionExpressiveness: true },
2193
+ [HEYGEN_AVATAR_6_TURBO_ENDPOINT]: { minSeconds: 1, maxSeconds: 300, promptField: "motion_prompt", motionExpressiveness: true },
2194
+ [OMNIHUMAN_V2_ENDPOINT]: { minSeconds: 4, maxSeconds: 300, promptField: "prompt", motionExpressiveness: false }
2195
+ };
1989
2196
  var GROK_IMAGINE_I2V_ENDPOINT = "xai/grok-imagine-video/image-to-video";
1990
2197
  var GROK_IMAGINE_15_I2V_ENDPOINT = "xai/grok-imagine-video/v1.5/image-to-video";
1991
2198
  var WAN_30_I2V_ENDPOINT = "alibaba/wan-3.0/image-to-video";
@@ -1993,6 +2200,12 @@ var KLING_26_I2V_ENDPOINT = "fal-ai/kling-video/v2.6/pro/image-to-video";
1993
2200
  var KLING_O3_STANDARD_I2V_ENDPOINT = "fal-ai/kling-video/o3/standard/image-to-video";
1994
2201
  var KLING_O3_PRO_I2V_ENDPOINT = "fal-ai/kling-video/o3/pro/image-to-video";
1995
2202
  var KLING_O3_I2V_ENDPOINTS = [KLING_O3_STANDARD_I2V_ENDPOINT, KLING_O3_PRO_I2V_ENDPOINT];
2203
+ var GEMINI_OMNI_11_I2V_ENDPOINT = "google/gemini-omni-flash/v1.1/image-to-video";
2204
+ var KLING_V3_STANDARD_I2V_ENDPOINT = "fal-ai/kling-video/v3/standard/image-to-video";
2205
+ var KLING_V3_PRO_I2V_ENDPOINT = "fal-ai/kling-video/v3/pro/image-to-video";
2206
+ var KLING_V3_I2V_ENDPOINTS = [KLING_V3_STANDARD_I2V_ENDPOINT, KLING_V3_PRO_I2V_ENDPOINT];
2207
+ var KLING_V4_I2V_ENDPOINT = "kling/v4/image-to-video";
2208
+ var MINIMAX_H3_I2V_ENDPOINT = "minimax/h3/image-to-video";
1996
2209
  var KLING_O3_PRO_R2V_ENDPOINT = "fal-ai/kling-video/o3/pro/reference-to-video";
1997
2210
  var FAL_CHARACTER_REFERENCE_LIMITS = {
1998
2211
  [KLING_O3_PRO_R2V_ENDPOINT]: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 7 }
@@ -2021,12 +2234,20 @@ var VIDEO_FIXED_RESOLUTION = {
2021
2234
  "blackforestlabs/flux-3/draft-enhance": "1080p",
2022
2235
  // Not a resolution the caller picks: Kling O3 Edit renders at the source's.
2023
2236
  "fal-ai/kling-video/o3/pro/video-to-video/edit": "source",
2237
+ // Lip sync: no size knob. HeyGen is sent without one and renders its 1080p
2238
+ // default; OmniHuman v2 declares none.
2239
+ "heygen/avatar-6/image-to-video": "1080p",
2240
+ "heygen/avatar-6/turbo/image-to-video": "1080p",
2241
+ "bytedance/omnihuman/v2": "fixed",
2024
2242
  // Kling 2.6 Pro takes no resolution; it renders 1080p.
2025
2243
  [KLING_26_I2V_ENDPOINT]: "1080p",
2026
2244
  // Not a resolution the caller picks: Kling O3's tier sets the size.
2027
2245
  [KLING_O3_STANDARD_I2V_ENDPOINT]: "fixed",
2028
2246
  [KLING_O3_PRO_I2V_ENDPOINT]: "fixed",
2029
- [KLING_O3_PRO_R2V_ENDPOINT]: "fixed"
2247
+ [KLING_O3_PRO_R2V_ENDPOINT]: "fixed",
2248
+ // Kling 3.0 likewise: its tier sets the size.
2249
+ [KLING_V3_STANDARD_I2V_ENDPOINT]: "fixed",
2250
+ [KLING_V3_PRO_I2V_ENDPOINT]: "fixed"
2030
2251
  };
2031
2252
  var VIDEO_PINNED_DEFAULT_SECONDS = {
2032
2253
  [GROK_IMAGINE_I2V_ENDPOINT]: 5,
@@ -2041,6 +2262,13 @@ var VIDEO_PINNED_DEFAULT_SECONDS = {
2041
2262
  [KLING_O3_STANDARD_I2V_ENDPOINT]: 5,
2042
2263
  [KLING_O3_PRO_I2V_ENDPOINT]: 5,
2043
2264
  [KLING_O3_PRO_R2V_ENDPOINT]: 5,
2265
+ [GEMINI_OMNI_11_I2V_ENDPOINT]: 8,
2266
+ // fal's own default on Kling 3.0 and 4.0 (schemas read 2026-11-03).
2267
+ [KLING_V3_STANDARD_I2V_ENDPOINT]: 5,
2268
+ [KLING_V3_PRO_I2V_ENDPOINT]: 5,
2269
+ [KLING_V4_I2V_ENDPOINT]: 5,
2270
+ // fal's own default on MiniMax H3 (schema read 2026-11-04).
2271
+ [MINIMAX_H3_I2V_ENDPOINT]: 5,
2044
2272
  // LTX-2.5 defaults to "auto", a length nobody can price up front; 6 s is its
2045
2273
  // shortest clip on both tiers.
2046
2274
  [LTX_25_FAST_I2V_ENDPOINT]: 6,
@@ -2073,6 +2301,12 @@ var VIDEO_DEFAULT_RESOLUTION = {
2073
2301
  [GROK_IMAGINE_15_I2V_ENDPOINT]: "720p",
2074
2302
  // fal schema default: Wan 3.0 renders 1080p unless asked for less.
2075
2303
  [WAN_30_I2V_ENDPOINT]: "1080p",
2304
+ // fal schema default: Gemini Omni renders 720p, as on KIE.
2305
+ [GEMINI_OMNI_11_I2V_ENDPOINT]: "720p",
2306
+ // fal schema default: Kling 4.0 renders 1080p unless asked for 720p.
2307
+ [KLING_V4_I2V_ENDPOINT]: "1080p",
2308
+ // fal schema default: MiniMax H3 renders 2K (the canvas's 1080p) unless asked.
2309
+ [MINIMAX_H3_I2V_ENDPOINT]: "1080p",
2076
2310
  // fal schema default: LTX-2.5 renders 1080p unless asked for less.
2077
2311
  [LTX_25_FAST_I2V_ENDPOINT]: "1080p",
2078
2312
  [LTX_25_PRO_I2V_ENDPOINT]: "1080p"
@@ -2119,7 +2353,18 @@ var VIDEO_ALLOWED_VALUES = {
2119
2353
  aspectRatio: ["auto", "16:9", "9:16"],
2120
2354
  resolution: ["720p", "1080p"],
2121
2355
  durationSeconds: { values: [6, 8, 10] }
2122
- }
2356
+ },
2357
+ // fal also renders 360p, which the canvas does not offer.
2358
+ [GEMINI_OMNI_11_I2V_ENDPOINT]: {
2359
+ aspectRatio: ["16:9", "9:16"],
2360
+ resolution: ["720p", "1080p", "4k"],
2361
+ durationSeconds: { min: 3, max: 10 }
2362
+ },
2363
+ ...Object.fromEntries(KLING_V3_I2V_ENDPOINTS.map((e) => [e, { durationSeconds: { min: 3, max: 15 } }])),
2364
+ [KLING_V4_I2V_ENDPOINT]: { resolution: ["720p", "1080p"], durationSeconds: { min: 3, max: 30 } },
2365
+ // fal also renders 480P, which the canvas does not offer. Its shortest clip
2366
+ // is 5 s (KIE's is 4 s), so a 4 s job on the H3 route has no fal fallback.
2367
+ [MINIMAX_H3_I2V_ENDPOINT]: { resolution: ["720p", "1080p", "4k"], durationSeconds: { min: 5, max: 15 } }
2123
2368
  };
2124
2369
  var VIDEO_MAX_SECONDS_AT_RESOLUTION = {
2125
2370
  [LTX_25_FAST_I2V_ENDPOINT]: { "4k": 10 }
@@ -2143,6 +2388,10 @@ var VIDEO_UNSUPPORTED_PARAMS = {
2143
2388
  "generateAudio",
2144
2389
  "durationSeconds"
2145
2390
  ],
2391
+ // Lip sync: the length is the audio's, the shape the face image's.
2392
+ ...Object.fromEntries(
2393
+ Object.keys(LIP_SYNC_SPECS).map((e) => [e, ["resolution", "seed", "negativePrompt", "aspectRatio", "generateAudio", "durationSeconds"]])
2394
+ ),
2146
2395
  // Wan's output is also as long as its source; it takes resolution and seed.
2147
2396
  "fal-ai/wan/v2.2-14b/animate/replace": ["durationSeconds", "negativePrompt", "aspectRatio", "generateAudio"],
2148
2397
  "blackforestlabs/flux-3/keyframes-to-video/draft": ["resolution", "seed", "negativePrompt"],
@@ -2175,13 +2424,26 @@ var VIDEO_UNSUPPORTED_PARAMS = {
2175
2424
  ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS.map((e) => [e, ["resolution", "aspectRatio", "seed", "negativePrompt"]])),
2176
2425
  // Its tier sets the size; it takes an aspect ratio, but no seed or negative prompt.
2177
2426
  [KLING_O3_PRO_R2V_ENDPOINT]: ["resolution", "seed", "negativePrompt"],
2178
- ...Object.fromEntries(LTX_25_I2V_ENDPOINTS.map((e) => [e, ["seed", "negativePrompt"]]))
2427
+ ...Object.fromEntries(LTX_25_I2V_ENDPOINTS.map((e) => [e, ["seed", "negativePrompt"]])),
2428
+ // Its schema declares no seed, negative prompt or audio switch: it always
2429
+ // renders audio, at no extra charge.
2430
+ [GEMINI_OMNI_11_I2V_ENDPOINT]: ["seed", "negativePrompt", "generateAudio"],
2431
+ // Kling 3.0: the tier sets the size and the start frame the shape; it takes a
2432
+ // negative prompt but no seed.
2433
+ ...Object.fromEntries(KLING_V3_I2V_ENDPOINTS.map((e) => [e, ["resolution", "aspectRatio", "seed"]])),
2434
+ // Kling 4.0 follows the start frame's shape and always renders sound.
2435
+ [KLING_V4_I2V_ENDPOINT]: ["aspectRatio", "seed", "negativePrompt", "generateAudio"],
2436
+ // MiniMax H3 follows the start frame's shape and always renders sound (a 5 s
2437
+ // test render of 2026-11-04 had a video and an audio track); it takes a seed.
2438
+ [MINIMAX_H3_I2V_ENDPOINT]: ["aspectRatio", "negativePrompt", "generateAudio"]
2179
2439
  };
2180
2440
  var VIDEO_AUDIO_SWITCH = {
2181
2441
  ...Object.fromEntries(VEO_ENDPOINTS.map((e) => [e, { default: false }])),
2182
2442
  [KLING_26_I2V_ENDPOINT]: { default: false },
2183
2443
  ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS.map((e) => [e, { default: false }])),
2184
2444
  [KLING_O3_PRO_R2V_ENDPOINT]: { default: false },
2445
+ // Kling 3.0 renders sound unless sent false; Studio sends it silent unless asked.
2446
+ ...Object.fromEntries(KLING_V3_I2V_ENDPOINTS.map((e) => [e, { default: false }])),
2185
2447
  "bytedance/seedance-2.5/image-to-video": { default: true },
2186
2448
  "bytedance/seedance-2.0/image-to-video": { default: true },
2187
2449
  [WAN_30_I2V_ENDPOINT]: { default: true },
@@ -2903,6 +3165,10 @@ function searchMeshyAnimations(query, limit = 25) {
2903
3165
  }
2904
3166
  return out;
2905
3167
  }
3168
+ var IMAGE_ASPECT_RATIOS = ASPECT_RATIOS.map((value) => ({
3169
+ value,
3170
+ label: value
3171
+ }));
2906
3172
  var PORT_TYPES = ["text", "image", "video", "mask", "mesh3d", "audio", "json", "reference"];
2907
3173
  var INPUT_PORT_TYPES = PORT_TYPES.filter(
2908
3174
  (p) => p !== "mask" && p !== "reference"
@@ -2939,6 +3205,9 @@ var MODEL_TASKS = [
2939
3205
  "text-to-video",
2940
3206
  "image-to-video",
2941
3207
  "video-to-video",
3208
+ // Lip sync (2026-11-28): one face image and one audio file in, a talking
3209
+ // video as long as the audio out.
3210
+ "lip-sync",
2942
3211
  // A finishing pass over a DRAFT video: the upstream draft's cache bundle is
2943
3212
  // the only input, and the output is the full-quality render of the same take.
2944
3213
  "video-enhance",
@@ -2997,6 +3266,8 @@ var TASK_PORTS = {
2997
3266
  // Video-to-video (character replace): a source video plus ONE reference image
2998
3267
  // (the person to swap in). The two-input contract lives in the fal adapter.
2999
3268
  "video-to-video": { inputs: ["video", "image"], output: "video" },
3269
+ // Lip sync: the face image and the audio it speaks.
3270
+ "lip-sync": { inputs: ["image", "audio"], output: "video" },
3000
3271
  // Video-enhance: the upstream DRAFT video's cache bundle is the whole input.
3001
3272
  // The wire is typed 'video' so it only accepts a video node; whether that
3002
3273
  // node actually produced a draft cache is checked at run time, loudly.
@@ -3033,13 +3304,14 @@ var TASK_PORTS = {
3033
3304
  function taskPorts(task) {
3034
3305
  return TASK_PORTS[task];
3035
3306
  }
3307
+ var MAX_JSON_ARRAY_ITEMS = 1e4;
3036
3308
  var JsonValueSchema = z.lazy(
3037
3309
  () => z.union([
3038
3310
  z.string(),
3039
3311
  z.number().finite(),
3040
3312
  z.boolean(),
3041
3313
  z.null(),
3042
- z.array(JsonValueSchema),
3314
+ z.array(JsonValueSchema).max(MAX_JSON_ARRAY_ITEMS),
3043
3315
  z.record(z.string(), JsonValueSchema)
3044
3316
  ])
3045
3317
  );
@@ -3047,7 +3319,7 @@ var JsonNonNullValueSchema = z.union([
3047
3319
  z.string(),
3048
3320
  z.number().finite(),
3049
3321
  z.boolean(),
3050
- z.array(JsonValueSchema),
3322
+ z.array(JsonValueSchema).max(MAX_JSON_ARRAY_ITEMS),
3051
3323
  z.record(z.string(), JsonValueSchema)
3052
3324
  ]);
3053
3325
  function toJsonValue(value, what = "value") {
@@ -3055,6 +3327,11 @@ function toJsonValue(value, what = "value") {
3055
3327
  if (!r.success) throw new TypeError(`${what} is not a JSON value: ${r.error.issues[0]?.message ?? "invalid"}`);
3056
3328
  return r.data;
3057
3329
  }
3330
+ var MAX_DOCUMENT_NODES = 2e3;
3331
+ var MAX_DEFINITION_PARAMS = 200;
3332
+ var MAX_CAST_MEMBERS = 100;
3333
+ var MAX_CAST_SOURCES = 100;
3334
+ var MAX_LIST_BINDING_ITEMS = 500;
3058
3335
  var WORKFLOW_SCHEMA_VERSION = 1;
3059
3336
  var SchemaVersionSchema = z2.object({
3060
3337
  schema: z2.number().int().positive()
@@ -3088,7 +3365,7 @@ var ListItemBindingSchema = z2.discriminatedUnion("kind", [
3088
3365
  ]);
3089
3366
  var ListBindingSchema = z2.object({
3090
3367
  kind: z2.literal("list"),
3091
- items: z2.array(ListItemBindingSchema)
3368
+ items: z2.array(ListItemBindingSchema).max(MAX_LIST_BINDING_ITEMS)
3092
3369
  });
3093
3370
  var BindingSchema = z2.discriminatedUnion("kind", [
3094
3371
  LiteralBindingSchema,
@@ -3101,12 +3378,38 @@ var RetryPolicySchema = z2.object({
3101
3378
  maxAttempts: z2.number().int().positive(),
3102
3379
  backoffMs: z2.number().int().nonnegative()
3103
3380
  });
3381
+ var CastMemberSchema = z2.object({
3382
+ kind: z2.enum(["character", "product", "location"]),
3383
+ id: z2.string().min(1),
3384
+ name: z2.string(),
3385
+ sources: z2.array(z2.string()).max(MAX_CAST_SOURCES).optional()
3386
+ });
3104
3387
  var WorkflowNodeSchema = z2.object({
3105
3388
  id: z2.string().min(1),
3106
3389
  task: WorkflowTaskSchema,
3107
3390
  model: z2.string().min(1),
3108
3391
  inputs: z2.record(z2.string(), BindingSchema).default({}),
3109
- retry: RetryPolicySchema.optional()
3392
+ retry: RetryPolicySchema.optional(),
3393
+ /**
3394
+ * The cast the node's prompt names, in prompt order. Not a job input: the
3395
+ * executor reads it at send time to put the identity clauses Create sends
3396
+ * in front of the prompt (the reference order, the identity lock with each
3397
+ * character's description; for a clip, which element is who), and never
3398
+ * stores them in the node's prompt. Absent on a node that names no cast.
3399
+ */
3400
+ cast: z2.array(CastMemberSchema).max(MAX_CAST_MEMBERS).optional(),
3401
+ /**
3402
+ * The cast is what the node's own reference stack shows (its
3403
+ * `castReferences` setting), not mentions the canvas's prompt bar edits; a
3404
+ * fork of the run brings it back under that setting. Absent otherwise.
3405
+ */
3406
+ castOwn: z2.literal(true).optional(),
3407
+ /**
3408
+ * The node's images come from its image wire, which wins over a baked
3409
+ * stack: the cast's baked references are then not what is sent. Set with
3410
+ * `cast` only, so the executor can say which next step works.
3411
+ */
3412
+ imagesWired: z2.literal(true).optional()
3110
3413
  });
3111
3414
  var WorkflowParamSpecSchema = z2.object({
3112
3415
  name: z2.string().min(1),
@@ -3129,8 +3432,8 @@ var WorkflowDefinitionSchema = z2.object({
3129
3432
  version: SchemaVersionSchema.default({ schema: WORKFLOW_SCHEMA_VERSION }),
3130
3433
  id: z2.string().min(1),
3131
3434
  label: z2.string().optional(),
3132
- params: z2.array(WorkflowParamSpecSchema).default([]),
3133
- nodes: z2.array(WorkflowNodeSchema).min(1)
3435
+ params: z2.array(WorkflowParamSpecSchema).max(MAX_DEFINITION_PARAMS).default([]),
3436
+ nodes: z2.array(WorkflowNodeSchema).min(1).max(MAX_DOCUMENT_NODES)
3134
3437
  });
3135
3438
  function kahnOrder(ids, edges) {
3136
3439
  const indegree = /* @__PURE__ */ new Map();
@@ -3167,7 +3470,8 @@ var KeySchema = z3.string().regex(/^[A-Za-z_][A-Za-z0-9_.-]{0,63}$/, "key must b
3167
3470
  var InputNameSchema = z3.string().regex(/^[A-Za-z_][A-Za-z0-9_-]{0,63}$/, "input name must be 1 to 64 chars of letters, digits, _ -").refine(notReserved, "reserved name");
3168
3471
  var LabelSchema = z3.string().max(200);
3169
3472
  var DescriptionSchema = z3.string().max(2e3);
3170
- var PromptTextSchema = z3.string().max(2e4);
3473
+ var MAX_PROMPT_TEXT_LENGTH = 2e4;
3474
+ var PromptTextSchema = z3.string().max(MAX_PROMPT_TEXT_LENGTH);
3171
3475
  var ModelIdSchema = z3.string().max(256);
3172
3476
  var UrlSchema = z3.string().max(4096);
3173
3477
  var AssetIdSchema = z3.string().max(128);
@@ -3258,7 +3562,7 @@ var DocEdgeSchema = z3.object({
3258
3562
  var DocGroupSchema = z3.object({
3259
3563
  id: IdSchema,
3260
3564
  label: LabelSchema.optional(),
3261
- nodeIds: z3.array(IdSchema).min(1)
3565
+ nodeIds: z3.array(IdSchema).min(1).max(MAX_DOCUMENT_NODES)
3262
3566
  });
3263
3567
  var EDGE_ROUTINGS = ["curved", "orthogonal"];
3264
3568
  var EdgeRoutingSchema = z3.enum(EDGE_ROUTINGS);
@@ -3276,7 +3580,7 @@ var WorkflowDocumentSchema = z3.object({
3276
3580
  schema: z3.number().int().positive(),
3277
3581
  id: IdSchema,
3278
3582
  label: LabelSchema.default(""),
3279
- nodes: z3.array(DocNodeSchema).max(2e3),
3583
+ nodes: z3.array(DocNodeSchema).max(MAX_DOCUMENT_NODES),
3280
3584
  edges: z3.array(DocEdgeSchema).max(8e3),
3281
3585
  layout: z3.record(IdSchema, PositionSchema).default({}),
3282
3586
  groups: z3.array(DocGroupSchema).max(500).default([]),
@@ -3365,6 +3669,26 @@ var ROUTES2 = [
3365
3669
  withReferences: { "1080p": "fal/kling-o3-pro-reference-to-video" }
3366
3670
  }
3367
3671
  },
3672
+ {
3673
+ kind: "video",
3674
+ id: "route/gemini-omni",
3675
+ label: "Gemini Omni 1.1 Flash (KIE, fal fallback)",
3676
+ primary: "kie/gemini-omni-flash-1-1-image-to-video",
3677
+ // fal renders every length KIE does (4 to 10 s in even steps) and the same
3678
+ // sizes and shapes, from the same frame fields (2026-11-03). One difference:
3679
+ // fal always renders sound with the clip, so a clip that falls back has it.
3680
+ fallback: { start: "fal/gemini-omni-flash-1-1-image-to-video" }
3681
+ },
3682
+ {
3683
+ kind: "video",
3684
+ id: "route/minimax-h3",
3685
+ label: "MiniMax H3 (KIE, fal fallback)",
3686
+ primary: "kie/minimax-h3-image-to-video",
3687
+ // fal renders KIE's sizes (768P and 2K) and lengths from 5 to 15 s from the
3688
+ // same frame fields (2026-11-04); KIE also renders 4 s, which fal does not,
3689
+ // so a 4 s clip has no fallback. fal always renders sound with the clip.
3690
+ fallback: { start: "fal/minimax-h3-image-to-video" }
3691
+ },
3368
3692
  {
3369
3693
  kind: "video",
3370
3694
  id: "route/seedance-2-0",
@@ -3664,6 +3988,71 @@ var CATALOG_ENTRIES2 = [
3664
3988
  description: "ByteDance Seedream 5 Pro edit via fal, up to 10 reference images, 1K or 2K.",
3665
3989
  capabilities: { resolutions: ["1K", "2K"], needsImageInput: true, maxInputImages: 10 }
3666
3990
  },
3991
+ // ── fal.ai: Ideogram 4.5 Edit, precise local edits ─────────────────────
3992
+ {
3993
+ id: "fal/ideogram-4-5-edit",
3994
+ provider: "fal",
3995
+ modality: "image",
3996
+ task: "image-edit",
3997
+ label: "Ideogram 4.5 Edit (fal)",
3998
+ // Measured 2026-11-04 on a series of edits of one portrait: the background
3999
+ // held at a structural similarity (SSIM) of 0.9999 between successive
4000
+ // edits, against 0.98 for Nano Banana 2 Edit, which reframed the shot on
4001
+ // the first edit. Ideogram's first edit smoothed the face a little; after
4002
+ // that the face held.
4003
+ description: "Ideogram 4.5 in precise edit mode: changes what the prompt asks for (a garment, a prop, the background) and keeps every pixel it did not touch, so a series of edits keeps the shot. Image 1 is the image edited, up to 4 more are references, and the result keeps the shape of image 1. Quality low, medium or high.",
4004
+ capabilities: {
4005
+ // The tiers carry Ideogram's QUALITY (providers/fal.ts, `ideogramQuality`):
4006
+ // 0.5K low, 1K medium (the default), 2K high. fal's very_low is not
4007
+ // offered (decided 2026-11-04). Labelled as qualities
4008
+ // wherever shown (`imageTierLabel`).
4009
+ resolutions: ["0.5K", "1K", "2K"],
4010
+ tierKind: "quality",
4011
+ editsFirstImage: true,
4012
+ needsImageInput: true,
4013
+ maxInputImages: 5
4014
+ }
4015
+ },
4016
+ // ── fal.ai: OpenAI GPT Image 2, text in images and exact edits ─────────
4017
+ // Added 2026-11-04 (plan 2026-11-04-skool-prompting, item M2): the course
4018
+ // Marlin follows names it the best model for rendering text (labels,
4019
+ // packaging) and for edits that change only what was asked.
4020
+ {
4021
+ id: "fal/gpt-image-2",
4022
+ provider: "fal",
4023
+ modality: "image",
4024
+ task: "text-to-image",
4025
+ label: "GPT Image 2 (fal)",
4026
+ description: "OpenAI GPT Image 2 via fal: the strongest at text inside the image (labels, packaging, signs, posters) and at following long, detailed prompts. Slower than Nano Banana. Quality low, medium or high, about 1 megapixel in every shape; prompts up to about 4000 characters of English (4000 bytes).",
4027
+ capabilities: {
4028
+ // The tiers carry GPT Image 2's QUALITY (providers/fal.ts,
4029
+ // `tierQuality`): 0.5K low, 1K medium (the default), 2K high. The size
4030
+ // follows the shape alone (`FAL_GPT_IMAGE_2_SIZE_BY_ASPECT`).
4031
+ resolutions: ["0.5K", "1K", "2K"],
4032
+ tierKind: "quality",
4033
+ maxInputImages: 0
4034
+ }
4035
+ },
4036
+ {
4037
+ id: "fal/gpt-image-2-edit",
4038
+ provider: "fal",
4039
+ modality: "image",
4040
+ task: "image-edit",
4041
+ label: "GPT Image 2 Edit (fal)",
4042
+ description: "OpenAI GPT Image 2 edit via fal: changes only what the prompt asks for and renders text and labels cleanly (packaging, signs). Studio sends the image to edit first and up to 7 references after it; say in the prompt what to change. The result takes the shape you pick: pick the source image's shape to keep it. Slower than Nano Banana. Quality low, medium or high, about 1 megapixel in every shape; prompts up to about 4000 characters of English (4000 bytes).",
4043
+ capabilities: {
4044
+ resolutions: ["0.5K", "1K", "2K"],
4045
+ tierKind: "quality",
4046
+ // fal's `image_urls` is a plain list with no field for the image
4047
+ // edited. Studio's convention: the image to edit goes first and the
4048
+ // mention prompt names it image 1, which is what lets the composer, the
4049
+ // generate route and the canvas refuse an edit with no image before
4050
+ // anything is admitted (`editSourceHold`).
4051
+ editsFirstImage: true,
4052
+ needsImageInput: true,
4053
+ maxInputImages: 8
4054
+ }
4055
+ },
3667
4056
  {
3668
4057
  id: "fal/flux-1-1-pro",
3669
4058
  provider: "fal",
@@ -3949,7 +4338,7 @@ var CATALOG_ENTRIES2 = [
3949
4338
  modality: "video",
3950
4339
  task: "image-to-video",
3951
4340
  label: "Gemini Omni 1.1 Flash (KIE)",
3952
- description: "Google Gemini Omni 1.1 Flash via KIE, first-and-last-frame mode. A start frame and an optional end frame, 4, 6, 8 or 10 s, 720p to 4K, 16:9 or 9:16. KIE refuses registered characters in this mode, so identity comes from the frames alone. Accepted a minted character's photoreal stills on 2026-09-24 (set 9:16 for a portrait still: it defaults to 16:9 and crops). No fal equivalent.",
4341
+ description: "Google Gemini Omni 1.1 Flash via KIE, first-and-last-frame mode. A start frame and an optional end frame, 4, 6, 8 or 10 s, 720p to 4K, 16:9 or 9:16. KIE refuses registered characters in this mode, so identity comes from the frames alone. Accepted a minted character's photoreal stills on 2026-09-24 (set 9:16 for a portrait still: it defaults to 16:9 and crops).",
3953
4342
  capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
3954
4343
  },
3955
4344
  {
@@ -4045,6 +4434,53 @@ var CATALOG_ENTRIES2 = [
4045
4434
  characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 7 }
4046
4435
  }
4047
4436
  },
4437
+ {
4438
+ id: "fal/gemini-omni-flash-1-1-image-to-video",
4439
+ provider: "fal",
4440
+ modality: "video",
4441
+ task: "image-to-video",
4442
+ label: "Gemini Omni 1.1 Flash (image-to-video)",
4443
+ description: "Google Gemini Omni 1.1 Flash via fal, the fallback for the KIE entry and the route that runs images of people. A start frame and an optional end frame, 3 to 10 s, 720p, 1080p or 4K, 16:9 or 9:16 (16:9 unless set, so set 9:16 for a portrait still), with audio included. No seed. Not yet tested with a minted character on fal (the KIE route accepted one).",
4444
+ // 8 s at fal's 720p default, the length and size the KIE entry renders.
4445
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
4446
+ },
4447
+ {
4448
+ id: "fal/kling-3-0-standard-image-to-video",
4449
+ provider: "fal",
4450
+ modality: "video",
4451
+ task: "image-to-video",
4452
+ label: "Kling 3.0 Standard (image-to-video)",
4453
+ description: "Kuaishou Kling 3.0 Standard via fal, a model of its own next to Kling O3 (Kling 3.0 Omni). A start frame and an optional end frame, 3 to 15 s, in the start frame's shape at the tier's size, silent unless the job sets generateAudio. Takes a negative prompt, no seed. Not yet tested with a minted character.",
4454
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
4455
+ },
4456
+ {
4457
+ id: "fal/kling-3-0-pro-image-to-video",
4458
+ provider: "fal",
4459
+ modality: "video",
4460
+ task: "image-to-video",
4461
+ label: "Kling 3.0 Pro (image-to-video)",
4462
+ description: "Kuaishou Kling 3.0 Pro via fal, a model of its own next to Kling O3 (Kling 3.0 Omni). A start frame and an optional end frame, 3 to 15 s, in the start frame's shape at the tier's size, silent unless the job sets generateAudio. Takes a negative prompt, no seed. Not yet tested with a minted character.",
4463
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
4464
+ },
4465
+ {
4466
+ id: "fal/minimax-h3-image-to-video",
4467
+ provider: "fal",
4468
+ modality: "video",
4469
+ task: "image-to-video",
4470
+ label: "MiniMax H3 (image-to-video)",
4471
+ description: "MiniMax H3 via fal (the base model, not fal's post-trained H3 Max), the fallback for the KIE entry and the route that runs images of people. A start frame and an optional end frame, 5 to 15 s, 768p (the 720p setting), 2K (the 1080p setting, used unless set) or 4K, in the start frame's shape, always with sound. Takes a seed, no negative prompt. Rendered a 5 s test clip on 2026-11-04; not yet tested with a minted character on fal (the KIE route accepted one).",
4472
+ // 5 s at fal's 2K default.
4473
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
4474
+ },
4475
+ {
4476
+ id: "fal/kling-4-0-image-to-video",
4477
+ provider: "fal",
4478
+ modality: "video",
4479
+ task: "image-to-video",
4480
+ label: "Kling 4.0 (image-to-video)",
4481
+ description: "Kuaishou Kling 4.0 via fal; not served by KIE. A start frame and an optional end frame, 3 to 30 s, 720p or 1080p (1080p unless set), in the start frame's shape, always with sound. No seed or negative prompt. fal also takes in-between keyframes and per-shot prompts, which Studio does not send yet. Rendered a 3 s test clip on 2026-11-03; not yet tested with a minted character.",
4482
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
4483
+ },
4048
4484
  {
4049
4485
  id: "fal/ltx-2-5-fast-image-to-video",
4050
4486
  provider: "fal",
@@ -4161,6 +4597,37 @@ var CATALOG_ENTRIES2 = [
4161
4597
  // resolution, so the settings panel offers none and validation refuses one.
4162
4598
  capabilities: { needsImageInput: true, maxInputImages: 4, resolutions: [] }
4163
4599
  },
4600
+ // ── fal.ai: lip sync (face image + audio -> talking video) ─────────────
4601
+ // Inputs, limits and prices from each model's fal page, checked 2026-11-28
4602
+ // (providers/lip-sync-specs.ts holds the limits).
4603
+ {
4604
+ id: "fal/heygen-avatar-6",
4605
+ provider: "fal",
4606
+ modality: "video",
4607
+ task: "lip-sync",
4608
+ label: "HeyGen Avatar 6 (lip sync)",
4609
+ description: "HeyGen Avatar 6 via fal. Makes one face image speak an audio file (MP3 or WAV, up to 300 s) as a 1080p talking video, calm head motion. An optional prompt describes the motion. Run the speech node first, then this one: Studio reads the length of the audio before it starts. Default lip sync.",
4610
+ capabilities: { needsImageInput: true, maxInputImages: 1, resolutions: [] },
4611
+ isDefault: true
4612
+ },
4613
+ {
4614
+ id: "fal/heygen-avatar-6-turbo",
4615
+ provider: "fal",
4616
+ modality: "video",
4617
+ task: "lip-sync",
4618
+ label: "HeyGen Avatar 6 Turbo (lip sync)",
4619
+ description: "HeyGen Avatar 6 Turbo via fal: the faster variant of Avatar 6, with the same inputs.",
4620
+ capabilities: { needsImageInput: true, maxInputImages: 1, resolutions: [] }
4621
+ },
4622
+ {
4623
+ id: "fal/omnihuman-v2",
4624
+ provider: "fal",
4625
+ modality: "video",
4626
+ task: "lip-sync",
4627
+ label: "OmniHuman v2 (lip sync)",
4628
+ description: "ByteDance OmniHuman v2 via fal. Makes one face image speak an audio file (MP3 or WAV, 4 to 300 s) as a talking video.",
4629
+ capabilities: { needsImageInput: true, maxInputImages: 1, resolutions: [] }
4630
+ },
4164
4631
  // ── fal.ai: vision + utility (B4) ──────────────────────────────────────
4165
4632
  {
4166
4633
  id: "fal/florence-2-detailed-caption",
@@ -4269,6 +4736,29 @@ var CATALOG_ENTRIES2 = [
4269
4736
  },
4270
4737
  isDefault: true
4271
4738
  },
4739
+ {
4740
+ id: "elevenlabs/tts-v4",
4741
+ provider: "elevenlabs",
4742
+ modality: "audio",
4743
+ task: "text-to-speech",
4744
+ label: "ElevenLabs Eleven v4 (TTS)",
4745
+ description: "ElevenLabs Eleven v4 text-to-speech. 90+ languages, follows audio tags such as [whispers] written into the text. Takes Stability and Similarity, no Speed. Returns mp3 bytes synchronously. Up to 10,000 characters per request.",
4746
+ // Checked 2026-11-28. ElevenLabs' v4 page: two voice settings, Stability
4747
+ // and Similarity; "Style and Speed sliders are not available". The text
4748
+ // limit: its API price page says 10,000 characters per request, while
4749
+ // GET /v1/models and the models page say 100,000. Studio takes the lower
4750
+ // figure, which both accept; it is also what a voice node whose text
4751
+ // arrives at run time is held at.
4752
+ capabilities: {
4753
+ speech: {
4754
+ maxCharacters: 1e4,
4755
+ voiceSettings: {
4756
+ stability: { min: 0, max: 1, step: 0.05, default: 0.5 },
4757
+ similarityBoost: { min: 0, max: 1, step: 0.05, default: 0.75 }
4758
+ }
4759
+ }
4760
+ }
4761
+ },
4272
4762
  {
4273
4763
  id: "elevenlabs/scribe-v1",
4274
4764
  provider: "elevenlabs",
@@ -4376,6 +4866,147 @@ function withRouteNote2(entry) {
4376
4866
  return { ...entry, description: [entry.description ?? "", note, person ?? ""].filter(Boolean).join(" ").trim() };
4377
4867
  }
4378
4868
  var MODEL_CATALOG2 = CATALOG_ENTRIES2.map(withRouteNote2);
4869
+ var PROVIDER_API_NAMES = {
4870
+ "vertex/gemini-2-5-flash-image": "gemini-2.5-flash-image",
4871
+ "vertex/gemini-3-pro-image-preview": "gemini-3-pro-image-preview",
4872
+ "vertex/gemini-3-1-flash-image-preview": "gemini-3.1-flash-image-preview",
4873
+ "kie/nano-banana-2": "nano-banana-2",
4874
+ "kie/nano-banana-2-edit": "nano-banana-2",
4875
+ "kie/nano-banana-pro": "nano-banana-pro",
4876
+ "kie/nano-banana-pro-edit": "nano-banana-pro",
4877
+ "kie/seedream-5-lite": "seedream/5-lite-text-to-image",
4878
+ "kie/seedream-5-lite-edit": "seedream/5-lite-image-to-image",
4879
+ "kie/seedream-5-pro": "seedream/5-pro-text-to-image",
4880
+ "kie/seedream-5-pro-edit": "seedream/5-pro-image-to-image",
4881
+ "kie/imagen-4-fast": "google/imagen4-fast",
4882
+ "kie/seedream-v4": "bytedance/seedream-v4-text-to-image",
4883
+ // fal endpoint ids. The provider auto-routes nano-banana-2 to the `/edit`
4884
+ // variant when inputImages are present; both -edit and -edit-i2i catalog
4885
+ // entries share the same upstream id.
4886
+ "fal/nano-banana-2": "fal-ai/nano-banana-2",
4887
+ "fal/nano-banana-pro": "fal-ai/nano-banana-pro",
4888
+ "fal/nano-banana-pro-edit": "fal-ai/nano-banana-pro/edit",
4889
+ "fal/seedream-5-lite": "fal-ai/bytedance/seedream/v5/lite/text-to-image",
4890
+ "fal/seedream-5-lite-edit": "fal-ai/bytedance/seedream/v5/lite/edit",
4891
+ "fal/seedream-5-pro": "bytedance/seedream/v5/pro/text-to-image",
4892
+ "fal/seedream-5-pro-edit": "bytedance/seedream/v5/pro/edit",
4893
+ "fal/nano-banana-2-edit": "fal-ai/nano-banana-2/edit",
4894
+ // No fal-ai prefix: owner `ideogram`, alias `v4.5`, path `edit`.
4895
+ "fal/ideogram-4-5-edit": "ideogram/v4.5/edit",
4896
+ // No fal-ai prefix: owner `openai`. `fal-ai/gpt-image-2` is an alias of the
4897
+ // same model; the edit is `/edit` (there is no `image-to-image` path).
4898
+ "fal/gpt-image-2": "openai/gpt-image-2",
4899
+ "fal/gpt-image-2-edit": "openai/gpt-image-2/edit",
4900
+ "fal/nano-banana-2-edit-i2i": "fal-ai/nano-banana-2/edit",
4901
+ "fal/flux-1-1-pro": "fal-ai/flux-pro/v1.1",
4902
+ "fal/flux-schnell": "fal-ai/flux/schnell",
4903
+ "fal/flux-kontext-pro": "fal-ai/flux-pro/kontext",
4904
+ // fal virtual try-on endpoint (E3). Sync via subscribe (submit+poll wrapped).
4905
+ "fal/fashn-tryon-v1-6": "fal-ai/fashn/tryon/v1.6",
4906
+ // fal video endpoints (B1). Async via the queue API.
4907
+ "fal/kling-v2-5-image-to-video": "fal-ai/kling-video/v2.5-turbo/pro/image-to-video",
4908
+ "fal/seedance-pro-image-to-video": "fal-ai/bytedance/seedance/v1/pro/image-to-video",
4909
+ // Seedance 2.x ids carry no `fal-ai/` prefix and are nested (owner/alias/path),
4910
+ // like the Wan entry above; the fal SDK derives queue URLs from owner/alias.
4911
+ "fal/seedance-2-5-image-to-video": "bytedance/seedance-2.5/image-to-video",
4912
+ "fal/seedance-2-0-image-to-video": "bytedance/seedance-2.0/image-to-video",
4913
+ "fal/seedance-pro-text-to-video": "fal-ai/bytedance/seedance/v1/pro/text-to-video",
4914
+ // Grok Imagine: nested id, the SDK derives owner/alias itself.
4915
+ "fal/grok-imagine-image-to-video": "xai/grok-imagine-video/image-to-video",
4916
+ // KIE video: the upstream KIE model ids (providers/kie-video.ts).
4917
+ "kie/veo-3-1-lite": "veo3_lite",
4918
+ "kie/veo-3-1-fast": "veo3_fast",
4919
+ "kie/veo-3-1": "veo3",
4920
+ "kie/grok-imagine-image-to-video": "grok-imagine/image-to-video",
4921
+ "kie/grok-imagine-1-5-image-to-video": "grok-imagine-video-1-5-preview",
4922
+ "kie/kling-v2-5-turbo-pro-image-to-video": "kling/v2-5-turbo-image-to-video-pro",
4923
+ "kie/kling-2-6-image-to-video": "kling-2.6/image-to-video",
4924
+ "kie/seedance-2-0-image-to-video": "bytedance/seedance-2",
4925
+ "kie/seedance-2-5-image-to-video": "bytedance/seedance-2-5",
4926
+ "kie/wan-3-0-image-to-video": "wan/3-0-video",
4927
+ "kie/minimax-h3-image-to-video": "minimax-h3/image-to-video",
4928
+ "kie/gemini-omni-flash-1-1-image-to-video": "google/gemini-omni-flash-1-1",
4929
+ // The same KIE model in its reference mode: a spec key of its own, sent to
4930
+ // KIE as `google/gemini-omni-flash-1-1` (`KieVideoSpec.upstreamModel`).
4931
+ "kie/gemini-omni-flash-1-1-reference-to-video": "google/gemini-omni-flash-1-1/references",
4932
+ "kie/kling-o3-image-to-video": "kling-3.0-omni/image-to-video",
4933
+ // OpenRouter video: the OpenRouter model ids (providers/openrouter-video.ts).
4934
+ "openrouter/veo-3-1-lite": "google/veo-3.1-lite",
4935
+ "openrouter/veo-3-1-fast": "google/veo-3.1-fast",
4936
+ "openrouter/veo-3-1": "google/veo-3.1",
4937
+ // The fal twins of KIE-only models.
4938
+ "fal/grok-imagine-1-5-image-to-video": "xai/grok-imagine-video/v1.5/image-to-video",
4939
+ "fal/wan-3-0-image-to-video": "alibaba/wan-3.0/image-to-video",
4940
+ "fal/kling-2-6-image-to-video": "fal-ai/kling-video/v2.6/pro/image-to-video",
4941
+ "fal/kling-o3-standard-image-to-video": "fal-ai/kling-video/o3/standard/image-to-video",
4942
+ "fal/kling-o3-pro-image-to-video": "fal-ai/kling-video/o3/pro/image-to-video",
4943
+ "fal/kling-o3-pro-reference-to-video": "fal-ai/kling-video/o3/pro/reference-to-video",
4944
+ "fal/gemini-omni-flash-1-1-image-to-video": "google/gemini-omni-flash/v1.1/image-to-video",
4945
+ "fal/kling-3-0-standard-image-to-video": "fal-ai/kling-video/v3/standard/image-to-video",
4946
+ "fal/kling-3-0-pro-image-to-video": "fal-ai/kling-video/v3/pro/image-to-video",
4947
+ "fal/kling-4-0-image-to-video": "kling/v4/image-to-video",
4948
+ "fal/minimax-h3-image-to-video": "minimax/h3/image-to-video",
4949
+ // Lightricks LTX-2.5: nested ids, the SDK derives owner/alias itself.
4950
+ "fal/ltx-2-5-fast-image-to-video": "lightricks/ltx-2.5/image-to-video/fast",
4951
+ "fal/ltx-2-5-pro-image-to-video": "lightricks/ltx-2.5/image-to-video/pro",
4952
+ // Google Veo 3.1: nested ids, the SDK derives owner/alias itself.
4953
+ "fal/veo-3-1-lite-image-to-video": "fal-ai/veo3.1/lite/image-to-video",
4954
+ "fal/veo-3-1-lite-first-last-frame": "fal-ai/veo3.1/lite/first-last-frame-to-video",
4955
+ "fal/veo-3-1-fast-image-to-video": "fal-ai/veo3.1/fast/image-to-video",
4956
+ "fal/veo-3-1-fast-first-last-frame": "fal-ai/veo3.1/fast/first-last-frame-to-video",
4957
+ "fal/veo-3-1-image-to-video": "fal-ai/veo3.1/image-to-video",
4958
+ "fal/veo-3-1-first-last-frame": "fal-ai/veo3.1/first-last-frame-to-video",
4959
+ // FLUX.3 draft endpoints. Nested ids without the `fal-ai/` prefix, like Seedance 2.x.
4960
+ "fal/flux-3-image-to-video-draft": "blackforestlabs/flux-3/image-to-video/draft",
4961
+ "fal/flux-3-first-last-frame-to-video-draft": "blackforestlabs/flux-3/first-last-frame-to-video/draft",
4962
+ "fal/flux-3-keyframes-to-video-draft": "blackforestlabs/flux-3/keyframes-to-video/draft",
4963
+ "fal/flux-3-image-to-video": "blackforestlabs/flux-3/image-to-video",
4964
+ "fal/flux-3-first-last-frame-to-video": "blackforestlabs/flux-3/first-last-frame-to-video",
4965
+ "fal/flux-3-keyframes-to-video": "blackforestlabs/flux-3/keyframes-to-video",
4966
+ "fal/flux-3-draft-enhance": "blackforestlabs/flux-3/draft-enhance",
4967
+ // fal video-to-video (Wan 2.2 Animate Replace). Nested endpoint id: the queue
4968
+ // status / result URLs use only `fal-ai/wan` (owner/alias), which the fal SDK
4969
+ // derives itself (parseEndpointId); submit takes the full id.
4970
+ "fal/wan-animate-replace": "fal-ai/wan/v2.2-14b/animate/replace",
4971
+ "fal/heygen-avatar-6": "heygen/avatar-6/image-to-video",
4972
+ "fal/heygen-avatar-6-turbo": "heygen/avatar-6/turbo/image-to-video",
4973
+ "fal/omnihuman-v2": "bytedance/omnihuman/v2",
4974
+ // Kling O3 Pro Edit: nested id like Wan's, the SDK derives owner/alias itself.
4975
+ "fal/kling-o3-edit": "fal-ai/kling-video/o3/pro/video-to-video/edit",
4976
+ // fal vision + utility endpoints (B4). Sync via subscribe.
4977
+ "fal/florence-2-detailed-caption": "fal-ai/florence-2-large/detailed-caption",
4978
+ "fal/moondream-next-vqa": "fal-ai/moondream-next",
4979
+ // Judge (P3): same underlying endpoint as the entry above. Not dispatched
4980
+ // yet: a judge node parks the run on a person (J2) and does not call a model
4981
+ // until J5 wires the ranking. Mapped now so J5 needs no catalog change.
4982
+ "fal/moondream-next-vqa-judge": "fal-ai/moondream-next",
4983
+ "fal/meshy-rigging": "fal-ai/meshy/rigging",
4984
+ "fal/aura-sr-upscale": "fal-ai/aura-sr",
4985
+ "fal/birefnet-v2-background-remove": "fal-ai/birefnet/v2",
4986
+ // audio: Suno music via KIE (B2). The upstream `model` field KIE expects on
4987
+ // its Suno job API ("V5"), distinct from the dashed catalog id.
4988
+ "kie/suno-v5": "V5",
4989
+ // audio: ElevenLabs voice (B2). The upstream model_id the ElevenLabs API
4990
+ // expects on the TTS / STT endpoints.
4991
+ "elevenlabs/tts-multilingual-v2": "eleven_multilingual_v2",
4992
+ "elevenlabs/tts-v4": "eleven_v4",
4993
+ "elevenlabs/scribe-v1": "scribe_v1",
4994
+ // text: LLM director (B3). KIE-Claude expects the bare Anthropic model id on
4995
+ // its Messages endpoint; OpenRouter expects the provider-prefixed id.
4996
+ "kie/claude-sonnet-4-5": "claude-sonnet-4-5",
4997
+ "kie/claude-opus-4-5": "claude-opus-4-5",
4998
+ "openrouter/claude-sonnet-4-6": "anthropic/claude-sonnet-4-6",
4999
+ "openrouter/gpt-6-astra": "openai/gpt-6-astra",
5000
+ "openrouter/claude-opus-5-5": "anthropic/claude-opus-5.5"
5001
+ };
5002
+ function getProviderModelName(id) {
5003
+ const route = getRoute2(id);
5004
+ if (route) return getProviderModelName(route.primary);
5005
+ const mapped = PROVIDER_API_NAMES[id];
5006
+ if (mapped) return mapped;
5007
+ const slashIdx = id.indexOf("/");
5008
+ return slashIdx === -1 ? id : id.slice(slashIdx + 1);
5009
+ }
4379
5010
  var routeEntries2 = /* @__PURE__ */ new Map();
4380
5011
  function routeEntry2(id) {
4381
5012
  const cached = routeEntries2.get(id);
@@ -4398,6 +5029,24 @@ function routeEntry2(id) {
4398
5029
  function tryGetModel2(id) {
4399
5030
  return MODEL_CATALOG2.find((m) => m.id === id) ?? routeEntry2(id);
4400
5031
  }
5032
+ var IMAGE_SIZE_OF_TIER = {
5033
+ "0.5K": "512px",
5034
+ "1K": "1K",
5035
+ "2K": "2K",
5036
+ "4K": "4K"
5037
+ };
5038
+ var IMAGE_QUALITY_LABEL_OF_TIER = {
5039
+ "0.5K": "Low",
5040
+ "1K": "Medium",
5041
+ "2K": "High",
5042
+ // No quality model declares 4K today; named as fal names the step above high.
5043
+ "4K": "Very high"
5044
+ };
5045
+ function imageTierLabel(model, value) {
5046
+ const tier = imageResolutionTier(value);
5047
+ if (!tier) return value;
5048
+ return model?.capabilities?.tierKind === "quality" ? IMAGE_QUALITY_LABEL_OF_TIER[tier] : IMAGE_SIZE_OF_TIER[tier];
5049
+ }
4401
5050
  function imageResolutionTier(value) {
4402
5051
  if (typeof value !== "string") return null;
4403
5052
  switch (value.trim().toLowerCase()) {
@@ -4415,61 +5064,743 @@ function imageResolutionTier(value) {
4415
5064
  return null;
4416
5065
  }
4417
5066
  }
4418
- function supportedResolutions(model) {
4419
- const declared = model?.capabilities?.resolutions;
4420
- return declared ? declared : null;
4421
- }
4422
- function resolutionRefusal(model, resolution) {
4423
- if (resolution === void 0 || resolution === null || resolution === "") return null;
4424
- const supported = supportedResolutions(model);
4425
- if (!model || supported === null) return null;
4426
- const name = model.label ?? model.id;
4427
- if (supported.length === 0) {
4428
- return `${name} takes no resolution setting and always renders at its own size, so "${String(resolution)}" would be silently ignored. Clear the resolution, or pick a model that honours it, such as Nano Banana 2.`;
5067
+ var ASPECT_RATIOS2 = [
5068
+ "1:1",
5069
+ "3:2",
5070
+ "2:3",
5071
+ "3:4",
5072
+ "4:3",
5073
+ "4:5",
5074
+ "5:4",
5075
+ "9:16",
5076
+ "16:9",
5077
+ "21:9"
5078
+ ];
5079
+ function omniReferencesPrompt2(prompt, elements) {
5080
+ const parts = ["Image 1 is the exact scene and the first frame of the video: start the clip on it and keep its setting, framing and light."];
5081
+ let next = 2;
5082
+ for (const [i, e] of elements.entries()) {
5083
+ const count2 = 1 + e.referenceImageUrls.length;
5084
+ const span = count2 === 1 ? `Image ${next} shows` : `Images ${next} to ${next + count2 - 1} show`;
5085
+ parts.push(
5086
+ `${span} character ${i + 1}${count2 > 1 ? ", the first of them from the front" : ""}; keep their face, hair and clothing exactly as shown for the whole clip.`
5087
+ );
5088
+ next += count2;
4429
5089
  }
4430
- const tier = imageResolutionTier(resolution);
4431
- if (tier && supported.includes(tier)) return null;
4432
- return `${name} renders at ${supported.join(", ")}, not "${String(resolution)}". Pick one of those.`;
4433
- }
4434
- var PROMPT_REQUIRED = /* @__PURE__ */ new Set([
4435
- "text-to-image",
4436
- "image-to-image",
4437
- "image-edit",
4438
- "text-to-3d",
4439
- "image-to-3d",
4440
- "multiview-to-3d",
4441
- "text-to-video",
4442
- // Texture: 3D AI Studio refuses a texture request without a prompt or a
4443
- // reference image (probed 2026-09-26), and Studio sends no reference image,
4444
- // so the material description is required. It binds `texturePrompt`, see
4445
- // `promptInputKey`.
4446
- "texture",
4447
- // Audio is prompt-only: a music description (text-to-audio) / the text to
4448
- // speak (text-to-speech). No upstream wire, so no portBinding entry.
4449
- "text-to-audio",
4450
- "text-to-speech"
4451
- ]);
4452
- var PROMPT_OPTIONAL = /* @__PURE__ */ new Set(["image-to-video", "image-to-json", "video-to-video"]);
4453
- function taskNeedsPrompt(task) {
4454
- return PROMPT_REQUIRED.has(task) || PROMPT_OPTIONAL.has(task);
4455
- }
4456
- function taskRequiresPrompt(task) {
4457
- return PROMPT_REQUIRED.has(task);
4458
- }
4459
- function promptInputKey(task) {
4460
- return task === "texture" ? "texturePrompt" : "prompt";
5090
+ const text = prompt?.trim() ?? "";
5091
+ return text ? `${parts.join(" ")} ${text}` : parts.join(" ");
4461
5092
  }
4462
- function portBinding(task, port) {
4463
- if (port === "image" && (task === "image-to-3d" || task === "multiview-to-3d" || task === "image-to-video" || task === "image-to-text" || task === "image-to-json")) {
4464
- return { key: "inputImageUrl", path: "url" };
4465
- }
4466
- if (port === "reference" && task === "image-to-video") {
4467
- return { key: "referenceImageUrls", path: "url", wrap: "array" };
4468
- }
4469
- if (port === "mesh3d" && (task === "remesh" || task === "texture" || task === "rig")) {
4470
- return { key: "parentAssetId", path: "assetId" };
4471
- }
4472
- if (port === "video" && task === "video-to-text") {
5093
+ var OMNI_MAX_REFERENCE_IMAGES2 = 7;
5094
+ function veoSpec3(model, label) {
5095
+ return {
5096
+ family: "veo",
5097
+ label,
5098
+ endFrame: true,
5099
+ aspectRatios: ["auto", "16:9", "9:16"],
5100
+ resolutions: ["720p", "1080p", "4k"],
5101
+ durations: { values: [4, 6, 8] },
5102
+ defaultSeconds: 8,
5103
+ defaultResolution: "720p",
5104
+ audioSwitch: false,
5105
+ defaultAudio: true,
5106
+ build: (i) => ({
5107
+ prompt: i.prompt,
5108
+ model,
5109
+ imageUrls: i.end ? [i.start, i.end] : [i.start],
5110
+ // KIE's "Auto" letterboxed a 4:3 still into 16:9 on 2026-09-23; an explicit
5111
+ // ratio is honoured, so only auto maps to KIE's own word for it.
5112
+ ...i.aspectRatio ? { aspect_ratio: i.aspectRatio === "auto" ? "Auto" : i.aspectRatio } : {},
5113
+ resolution: i.resolution,
5114
+ duration: i.seconds
5115
+ })
5116
+ };
5117
+ }
5118
+ var SEEDANCE_ASPECTS2 = ["auto", "1:1", "4:3", "3:4", "16:9", "9:16", "21:9"];
5119
+ var seedanceAspect2 = (a) => a === "auto" ? "adaptive" : a;
5120
+ var KIE_VIDEO_SPECS2 = {
5121
+ veo3_lite: veoSpec3("veo3_lite", "Veo 3.1 Lite"),
5122
+ veo3_fast: veoSpec3("veo3_fast", "Veo 3.1 Fast"),
5123
+ veo3: veoSpec3("veo3", "Veo 3.1"),
5124
+ "grok-imagine/image-to-video": {
5125
+ family: "job",
5126
+ label: "Grok Imagine",
5127
+ endFrame: false,
5128
+ resolutions: ["480p", "720p", "1080p"],
5129
+ durations: { min: 6, max: 30 },
5130
+ defaultSeconds: 6,
5131
+ defaultResolution: "720p",
5132
+ // Not a contradiction with the catalog saying Grok renders with audio: xAI
5133
+ // always renders audio and KIE exposes no switch for it. `defaultAudio`
5134
+ // here only feeds `price()`, which ignores it, so it states no audio fact.
5135
+ audioSwitch: false,
5136
+ defaultAudio: false,
5137
+ build: (i) => ({
5138
+ image_urls: [i.start],
5139
+ prompt: i.prompt,
5140
+ mode: "normal",
5141
+ duration: String(i.seconds),
5142
+ resolution: i.resolution,
5143
+ nsfw_checker: true
5144
+ })
5145
+ },
5146
+ "grok-imagine-video-1-5-preview": {
5147
+ family: "job",
5148
+ label: "Grok Imagine 1.5",
5149
+ endFrame: false,
5150
+ // KIE lists no 1080p price for 1.5, so 1080p is not offered.
5151
+ resolutions: ["480p", "720p"],
5152
+ durations: { min: 1, max: 15 },
5153
+ defaultSeconds: 8,
5154
+ defaultResolution: "720p",
5155
+ // As for Grok Imagine 1.0 above: audio is always rendered, with no switch.
5156
+ audioSwitch: false,
5157
+ defaultAudio: false,
5158
+ build: (i) => ({
5159
+ image_urls: [i.start],
5160
+ prompt: i.prompt,
5161
+ duration: i.seconds,
5162
+ resolution: i.resolution,
5163
+ nsfw_checker: true
5164
+ })
5165
+ },
5166
+ "kling/v2-5-turbo-image-to-video-pro": {
5167
+ family: "job",
5168
+ label: "Kling 2.5 Turbo Pro",
5169
+ endFrame: true,
5170
+ resolutions: [],
5171
+ durations: { values: [5, 10] },
5172
+ defaultSeconds: 5,
5173
+ defaultResolution: "",
5174
+ audioSwitch: false,
5175
+ defaultAudio: false,
5176
+ build: (i) => ({
5177
+ prompt: i.prompt,
5178
+ image_url: i.start,
5179
+ ...i.end ? { tail_image_url: i.end } : {},
5180
+ duration: String(i.seconds),
5181
+ ...i.negativePrompt ? { negative_prompt: i.negativePrompt } : {}
5182
+ })
5183
+ },
5184
+ "kling-2.6/image-to-video": {
5185
+ family: "job",
5186
+ label: "Kling 2.6",
5187
+ endFrame: false,
5188
+ resolutions: [],
5189
+ durations: { values: [5, 10] },
5190
+ defaultSeconds: 5,
5191
+ defaultResolution: "",
5192
+ audioSwitch: true,
5193
+ defaultAudio: false,
5194
+ build: (i) => ({
5195
+ prompt: i.prompt,
5196
+ image_urls: [i.start],
5197
+ sound: i.audio,
5198
+ duration: String(i.seconds)
5199
+ })
5200
+ },
5201
+ "bytedance/seedance-2": {
5202
+ family: "job",
5203
+ label: "Seedance 2.0",
5204
+ endFrame: true,
5205
+ aspectRatios: SEEDANCE_ASPECTS2,
5206
+ resolutions: ["480p", "720p", "1080p", "4k"],
5207
+ durations: { min: 4, max: 15 },
5208
+ defaultSeconds: 5,
5209
+ defaultResolution: "720p",
5210
+ audioSwitch: true,
5211
+ defaultAudio: true,
5212
+ build: (i) => ({
5213
+ prompt: i.prompt,
5214
+ first_frame_url: i.start,
5215
+ ...i.end ? { last_frame_url: i.end } : {},
5216
+ generate_audio: i.audio,
5217
+ resolution: i.resolution,
5218
+ ...i.aspectRatio ? { aspect_ratio: seedanceAspect2(i.aspectRatio) } : {},
5219
+ duration: i.seconds,
5220
+ nsfw_checker: true
5221
+ })
5222
+ },
5223
+ "bytedance/seedance-2-5": {
5224
+ family: "job",
5225
+ label: "Seedance 2.5",
5226
+ endFrame: true,
5227
+ aspectRatios: SEEDANCE_ASPECTS2,
5228
+ resolutions: ["480p", "720p", "1080p"],
5229
+ durations: { min: 4, max: 30 },
5230
+ defaultSeconds: 5,
5231
+ defaultResolution: "720p",
5232
+ audioSwitch: true,
5233
+ defaultAudio: true,
5234
+ build: (i) => ({
5235
+ prompt: i.prompt,
5236
+ first_frame_url: i.start,
5237
+ ...i.end ? { last_frame_url: i.end } : {},
5238
+ generate_audio: i.audio,
5239
+ resolution: i.resolution,
5240
+ ...i.aspectRatio ? { aspect_ratio: seedanceAspect2(i.aspectRatio) } : {},
5241
+ duration: i.seconds,
5242
+ nsfw_checker: true
5243
+ })
5244
+ },
5245
+ "wan/3-0-video": {
5246
+ family: "job",
5247
+ label: "Wan 3.0",
5248
+ endFrame: true,
5249
+ aspectRatios: ["auto", "16:9", "4:3", "1:1", "3:4", "9:16"],
5250
+ resolutions: ["480p", "720p", "1080p"],
5251
+ durations: { min: 2, max: 30 },
5252
+ defaultSeconds: 5,
5253
+ defaultResolution: "720p",
5254
+ audioSwitch: true,
5255
+ defaultAudio: true,
5256
+ build: (i) => ({
5257
+ prompt: i.prompt,
5258
+ first_frame_url: i.start,
5259
+ ...i.end ? { last_frame_url: i.end } : {},
5260
+ resolution: i.resolution.toUpperCase(),
5261
+ ...i.aspectRatio ? { aspect_ratio: i.aspectRatio === "auto" ? "adaptive" : i.aspectRatio } : {},
5262
+ duration: i.seconds,
5263
+ audio: i.audio,
5264
+ ...i.seed !== void 0 ? { seed: i.seed } : {},
5265
+ nsfw_checker: true
5266
+ })
5267
+ },
5268
+ "minimax-h3/image-to-video": {
5269
+ family: "job",
5270
+ label: "MiniMax H3",
5271
+ endFrame: true,
5272
+ // KIE renders 768P or 2K; the canvas's 720p and 1080p map onto them.
5273
+ resolutions: ["720p", "1080p"],
5274
+ durations: { min: 4, max: 15 },
5275
+ defaultSeconds: 6,
5276
+ defaultResolution: "720p",
5277
+ audioSwitch: false,
5278
+ defaultAudio: false,
5279
+ build: (i) => ({
5280
+ prompt: i.prompt,
5281
+ first_frame_url: i.start,
5282
+ ...i.end ? { last_frame_url: i.end } : {},
5283
+ duration: i.seconds,
5284
+ resolution: i.resolution === "1080p" ? "2K" : "768P"
5285
+ })
5286
+ },
5287
+ "google/gemini-omni-flash-1-1": {
5288
+ family: "job",
5289
+ label: "Gemini Omni 1.1 Flash",
5290
+ endFrame: true,
5291
+ aspectRatios: ["16:9", "9:16"],
5292
+ // KIE also renders 360p; the canvas offers none below 480p.
5293
+ resolutions: ["720p", "1080p", "4k"],
5294
+ durations: { values: [4, 6, 8, 10] },
5295
+ defaultSeconds: 8,
5296
+ defaultResolution: "720p",
5297
+ audioSwitch: false,
5298
+ defaultAudio: false,
5299
+ // The first-and-last-frame mode: KIE refuses it combined with registered
5300
+ // characters, reference images, audio or video, so none are sent.
5301
+ build: (i) => ({
5302
+ prompt: i.prompt,
5303
+ first_frame_url: i.start,
5304
+ ...i.end ? { last_frame_url: i.end } : {},
5305
+ duration: String(i.seconds),
5306
+ resolution: i.resolution,
5307
+ ...i.aspectRatio ? { aspect_ratio: i.aspectRatio } : {},
5308
+ ...i.seed !== void 0 ? { seed: i.seed } : {}
5309
+ })
5310
+ },
5311
+ // Gemini Omni 1.1 Flash in its REFERENCE mode: up to seven `image_urls`
5312
+ // ("Multiple reference images can be uploaded to provide references for
5313
+ // characters, scenes, styles, or storyboards"; "Maximum of 7 images"), and
5314
+ // no locked first frame, because KIE makes `first_frame_url` "mutually
5315
+ // exclusive with `image_urls`" (docs.kie.ai, read 2026-10-24). The start
5316
+ // keyframe goes first among the images and the prompt names it the exact
5317
+ // scene and first frame (`omniReferencesPrompt`); each character's views
5318
+ // follow. Same model, same price as the first-frame mode.
5319
+ "google/gemini-omni-flash-1-1/references": {
5320
+ family: "job",
5321
+ label: "Gemini Omni 1.1 Flash with references",
5322
+ upstreamModel: "google/gemini-omni-flash-1-1",
5323
+ endFrame: false,
5324
+ aspectRatios: ["16:9", "9:16"],
5325
+ resolutions: ["720p", "1080p", "4k"],
5326
+ durations: { values: [4, 6, 8, 10] },
5327
+ defaultSeconds: 8,
5328
+ defaultResolution: "720p",
5329
+ audioSwitch: false,
5330
+ defaultAudio: false,
5331
+ // Six character images, because the start keyframe takes one of the seven.
5332
+ characterReferences: {
5333
+ maxElements: 6,
5334
+ minImagesPerElement: 1,
5335
+ maxImagesPerElement: 6,
5336
+ maxTotalImages: OMNI_MAX_REFERENCE_IMAGES2 - 1
5337
+ },
5338
+ maxPromptChars: 2e4,
5339
+ referencesPrompt: omniReferencesPrompt2,
5340
+ build: (i) => ({
5341
+ prompt: i.prompt,
5342
+ image_urls: [i.start, ...(i.elements ?? []).flatMap((e) => [e.frontalImageUrl, ...e.referenceImageUrls])],
5343
+ duration: String(i.seconds),
5344
+ resolution: i.resolution,
5345
+ ...i.aspectRatio ? { aspect_ratio: i.aspectRatio } : {},
5346
+ ...i.seed !== void 0 ? { seed: i.seed } : {}
5347
+ })
5348
+ },
5349
+ "kling-3.0-omni/image-to-video": {
5350
+ family: "job",
5351
+ label: "Kling O3",
5352
+ endFrame: true,
5353
+ // Kling O3 takes an aspect ratio only for multi-shot prompts; a single shot
5354
+ // follows the start frame.
5355
+ resolutions: ["720p", "1080p", "4k"],
5356
+ durations: { min: 3, max: 15 },
5357
+ defaultSeconds: 5,
5358
+ defaultResolution: "720p",
5359
+ audioSwitch: true,
5360
+ defaultAudio: false,
5361
+ // KIE's "Single First Frame" and "First and Last Frames" request shapes
5362
+ // both carry `elements`: "up to 3 subjects", and "for a multi-image
5363
+ // subject, provide 2 to 4 images" (docs.kie.ai, kling-3.0-omni
5364
+ // image-to-video, read 2026-10-23). Each element needs a name the prompt
5365
+ // can mention as `@name` and a description.
5366
+ characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 12 },
5367
+ maxPromptChars: 3072,
5368
+ build: (i) => ({
5369
+ prompt: i.prompt,
5370
+ image_urls: i.end ? [i.start, i.end] : [i.start],
5371
+ duration: i.seconds,
5372
+ resolution: i.resolution,
5373
+ audio: i.audio,
5374
+ // Named Element1, Element2, ... so one prompt convention (`@Element1`)
5375
+ // holds on KIE and on the fal twin alike.
5376
+ ...i.elements && i.elements.length > 0 ? {
5377
+ elements: i.elements.map((e, n) => ({
5378
+ name: `Element${n + 1}`,
5379
+ description: `character ${n + 1}`,
5380
+ element_input_urls: [e.frontalImageUrl, ...e.referenceImageUrls]
5381
+ }))
5382
+ } : {}
5383
+ })
5384
+ }
5385
+ };
5386
+ function veoSpec22(label, resolutions) {
5387
+ return {
5388
+ label,
5389
+ // OpenRouter's Veo has no auto: it renders exactly one of these.
5390
+ aspectRatios: ["16:9", "9:16"],
5391
+ resolutions,
5392
+ durations: { values: [4, 6, 8] },
5393
+ defaultSeconds: 8,
5394
+ defaultResolution: "720p"
5395
+ };
5396
+ }
5397
+ var OPENROUTER_VIDEO_SPECS2 = {
5398
+ "google/veo-3.1-lite": veoSpec22("Veo 3.1 Lite", ["720p", "1080p"]),
5399
+ "google/veo-3.1-fast": veoSpec22("Veo 3.1 Fast", ["720p", "1080p", "4k"]),
5400
+ "google/veo-3.1": veoSpec22("Veo 3.1", ["720p", "1080p", "4k"])
5401
+ };
5402
+ var HEYGEN_AVATAR_6_ENDPOINT2 = "heygen/avatar-6/image-to-video";
5403
+ var HEYGEN_AVATAR_6_TURBO_ENDPOINT2 = "heygen/avatar-6/turbo/image-to-video";
5404
+ var OMNIHUMAN_V2_ENDPOINT2 = "bytedance/omnihuman/v2";
5405
+ var LIP_SYNC_MAX_AUDIO_BYTES2 = 15 * 1024 * 1024;
5406
+ var LIP_SYNC_SPECS2 = {
5407
+ [HEYGEN_AVATAR_6_ENDPOINT2]: { minSeconds: 1, maxSeconds: 300, promptField: "motion_prompt", motionExpressiveness: true },
5408
+ [HEYGEN_AVATAR_6_TURBO_ENDPOINT2]: { minSeconds: 1, maxSeconds: 300, promptField: "motion_prompt", motionExpressiveness: true },
5409
+ [OMNIHUMAN_V2_ENDPOINT2]: { minSeconds: 4, maxSeconds: 300, promptField: "prompt", motionExpressiveness: false }
5410
+ };
5411
+ var GROK_IMAGINE_I2V_ENDPOINT2 = "xai/grok-imagine-video/image-to-video";
5412
+ var GROK_IMAGINE_15_I2V_ENDPOINT2 = "xai/grok-imagine-video/v1.5/image-to-video";
5413
+ var WAN_30_I2V_ENDPOINT2 = "alibaba/wan-3.0/image-to-video";
5414
+ var KLING_26_I2V_ENDPOINT2 = "fal-ai/kling-video/v2.6/pro/image-to-video";
5415
+ var KLING_O3_STANDARD_I2V_ENDPOINT2 = "fal-ai/kling-video/o3/standard/image-to-video";
5416
+ var KLING_O3_PRO_I2V_ENDPOINT2 = "fal-ai/kling-video/o3/pro/image-to-video";
5417
+ var KLING_O3_I2V_ENDPOINTS2 = [KLING_O3_STANDARD_I2V_ENDPOINT2, KLING_O3_PRO_I2V_ENDPOINT2];
5418
+ var GEMINI_OMNI_11_I2V_ENDPOINT2 = "google/gemini-omni-flash/v1.1/image-to-video";
5419
+ var KLING_V3_STANDARD_I2V_ENDPOINT2 = "fal-ai/kling-video/v3/standard/image-to-video";
5420
+ var KLING_V3_PRO_I2V_ENDPOINT2 = "fal-ai/kling-video/v3/pro/image-to-video";
5421
+ var KLING_V3_I2V_ENDPOINTS2 = [KLING_V3_STANDARD_I2V_ENDPOINT2, KLING_V3_PRO_I2V_ENDPOINT2];
5422
+ var KLING_V4_I2V_ENDPOINT2 = "kling/v4/image-to-video";
5423
+ var MINIMAX_H3_I2V_ENDPOINT2 = "minimax/h3/image-to-video";
5424
+ var KLING_O3_PRO_R2V_ENDPOINT2 = "fal-ai/kling-video/o3/pro/reference-to-video";
5425
+ var FAL_CHARACTER_REFERENCE_LIMITS2 = {
5426
+ [KLING_O3_PRO_R2V_ENDPOINT2]: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 7 }
5427
+ };
5428
+ var LTX_25_FAST_I2V_ENDPOINT2 = "lightricks/ltx-2.5/image-to-video/fast";
5429
+ var LTX_25_PRO_I2V_ENDPOINT2 = "lightricks/ltx-2.5/image-to-video/pro";
5430
+ var LTX_25_I2V_ENDPOINTS2 = [LTX_25_FAST_I2V_ENDPOINT2, LTX_25_PRO_I2V_ENDPOINT2];
5431
+ var VEO_LITE_I2V_ENDPOINT2 = "fal-ai/veo3.1/lite/image-to-video";
5432
+ var VEO_LITE_FLF_ENDPOINT2 = "fal-ai/veo3.1/lite/first-last-frame-to-video";
5433
+ var VEO_FAST_I2V_ENDPOINT2 = "fal-ai/veo3.1/fast/image-to-video";
5434
+ var VEO_FAST_FLF_ENDPOINT2 = "fal-ai/veo3.1/fast/first-last-frame-to-video";
5435
+ var VEO_I2V_ENDPOINT2 = "fal-ai/veo3.1/image-to-video";
5436
+ var VEO_FLF_ENDPOINT2 = "fal-ai/veo3.1/first-last-frame-to-video";
5437
+ var VEO_ENDPOINTS2 = [
5438
+ VEO_LITE_I2V_ENDPOINT2,
5439
+ VEO_LITE_FLF_ENDPOINT2,
5440
+ VEO_FAST_I2V_ENDPOINT2,
5441
+ VEO_FAST_FLF_ENDPOINT2,
5442
+ VEO_I2V_ENDPOINT2,
5443
+ VEO_FLF_ENDPOINT2
5444
+ ];
5445
+ var VIDEO_FIXED_RESOLUTION2 = {
5446
+ "blackforestlabs/flux-3/keyframes-to-video/draft": "720p",
5447
+ "blackforestlabs/flux-3/first-last-frame-to-video/draft": "720p",
5448
+ "blackforestlabs/flux-3/image-to-video/draft": "720p",
5449
+ "blackforestlabs/flux-3/draft-enhance": "1080p",
5450
+ // Not a resolution the caller picks: Kling O3 Edit renders at the source's.
5451
+ "fal-ai/kling-video/o3/pro/video-to-video/edit": "source",
5452
+ // Lip sync: no size knob. HeyGen is sent without one and renders its 1080p
5453
+ // default; OmniHuman v2 declares none.
5454
+ "heygen/avatar-6/image-to-video": "1080p",
5455
+ "heygen/avatar-6/turbo/image-to-video": "1080p",
5456
+ "bytedance/omnihuman/v2": "fixed",
5457
+ // Kling 2.6 Pro takes no resolution; it renders 1080p.
5458
+ [KLING_26_I2V_ENDPOINT2]: "1080p",
5459
+ // Not a resolution the caller picks: Kling O3's tier sets the size.
5460
+ [KLING_O3_STANDARD_I2V_ENDPOINT2]: "fixed",
5461
+ [KLING_O3_PRO_I2V_ENDPOINT2]: "fixed",
5462
+ [KLING_O3_PRO_R2V_ENDPOINT2]: "fixed",
5463
+ // Kling 3.0 likewise: its tier sets the size.
5464
+ [KLING_V3_STANDARD_I2V_ENDPOINT2]: "fixed",
5465
+ [KLING_V3_PRO_I2V_ENDPOINT2]: "fixed"
5466
+ };
5467
+ var VIDEO_PINNED_DEFAULT_SECONDS2 = {
5468
+ [GROK_IMAGINE_I2V_ENDPOINT2]: 5,
5469
+ // Veo defaults to 8 s itself, and 8 s is the only length Lite first-and-last
5470
+ // renders; pinning it keeps the bill and the clip in step either way.
5471
+ ...Object.fromEntries(VEO_ENDPOINTS2.map((e) => [e, 8])),
5472
+ // The fal twins render the length their KIE entries default to, so a clip
5473
+ // falling back from KIE to fal has the same length.
5474
+ [GROK_IMAGINE_15_I2V_ENDPOINT2]: 8,
5475
+ [WAN_30_I2V_ENDPOINT2]: 5,
5476
+ [KLING_26_I2V_ENDPOINT2]: 5,
5477
+ [KLING_O3_STANDARD_I2V_ENDPOINT2]: 5,
5478
+ [KLING_O3_PRO_I2V_ENDPOINT2]: 5,
5479
+ [KLING_O3_PRO_R2V_ENDPOINT2]: 5,
5480
+ [GEMINI_OMNI_11_I2V_ENDPOINT2]: 8,
5481
+ // fal's own default on Kling 3.0 and 4.0 (schemas read 2026-11-03).
5482
+ [KLING_V3_STANDARD_I2V_ENDPOINT2]: 5,
5483
+ [KLING_V3_PRO_I2V_ENDPOINT2]: 5,
5484
+ [KLING_V4_I2V_ENDPOINT2]: 5,
5485
+ // fal's own default on MiniMax H3 (schema read 2026-11-04).
5486
+ [MINIMAX_H3_I2V_ENDPOINT2]: 5,
5487
+ // LTX-2.5 defaults to "auto", a length nobody can price up front; 6 s is its
5488
+ // shortest clip on both tiers.
5489
+ [LTX_25_FAST_I2V_ENDPOINT2]: 6,
5490
+ [LTX_25_PRO_I2V_ENDPOINT2]: 6,
5491
+ // fal's own default is 5 s on these (schemas read 2026-10-25); sent so the
5492
+ // bill cannot drift from the clip if fal ever changes it.
5493
+ "fal-ai/kling-video/v2.5-turbo/pro/image-to-video": 5,
5494
+ "fal-ai/bytedance/seedance/v1/pro/image-to-video": 5,
5495
+ "fal-ai/bytedance/seedance/v1/pro/text-to-video": 5,
5496
+ "blackforestlabs/flux-3/first-last-frame-to-video": 5,
5497
+ "blackforestlabs/flux-3/first-last-frame-to-video/draft": 5,
5498
+ "blackforestlabs/flux-3/keyframes-to-video": 5,
5499
+ "blackforestlabs/flux-3/keyframes-to-video/draft": 5,
5500
+ // `auto` by default on these (fal schemas, 2026-10-25): the model would pick
5501
+ // a length nobody can price. 5 s is the shortest FLUX.3 renders and the clip
5502
+ // the Seedance anchors were priced at.
5503
+ "bytedance/seedance-2.0/image-to-video": 5,
5504
+ "bytedance/seedance-2.5/image-to-video": 5,
5505
+ "bytedance/seedance-2.5/text-to-video": 5,
5506
+ "blackforestlabs/flux-3/image-to-video": 5,
5507
+ "blackforestlabs/flux-3/image-to-video/draft": 5
5508
+ };
5509
+ var VIDEO_DEFAULT_RESOLUTION2 = {
5510
+ "blackforestlabs/flux-3/keyframes-to-video": "720p",
5511
+ "blackforestlabs/flux-3/first-last-frame-to-video": "720p",
5512
+ "blackforestlabs/flux-3/image-to-video": "720p",
5513
+ // fal schema default: Grok renders 720p.
5514
+ [GROK_IMAGINE_I2V_ENDPOINT2]: "720p",
5515
+ ...Object.fromEntries(VEO_ENDPOINTS2.map((e) => [e, "720p"])),
5516
+ [GROK_IMAGINE_15_I2V_ENDPOINT2]: "720p",
5517
+ // fal schema default: Wan 3.0 renders 1080p unless asked for less.
5518
+ [WAN_30_I2V_ENDPOINT2]: "1080p",
5519
+ // fal schema default: Gemini Omni renders 720p, as on KIE.
5520
+ [GEMINI_OMNI_11_I2V_ENDPOINT2]: "720p",
5521
+ // fal schema default: Kling 4.0 renders 1080p unless asked for 720p.
5522
+ [KLING_V4_I2V_ENDPOINT2]: "1080p",
5523
+ // fal schema default: MiniMax H3 renders 2K (the canvas's 1080p) unless asked.
5524
+ [MINIMAX_H3_I2V_ENDPOINT2]: "1080p",
5525
+ // fal schema default: LTX-2.5 renders 1080p unless asked for less.
5526
+ [LTX_25_FAST_I2V_ENDPOINT2]: "1080p",
5527
+ [LTX_25_PRO_I2V_ENDPOINT2]: "1080p"
5528
+ };
5529
+ var VIDEO_ALLOWED_VALUES2 = {
5530
+ // Seedance 2.5 derives its aspect from the input image.
5531
+ "bytedance/seedance-2.5/image-to-video": { aspectRatio: ["auto"] },
5532
+ "fal-ai/kling-video/v2.5-turbo/pro/image-to-video": {
5533
+ aspectRatio: ["16:9", "9:16", "1:1"],
5534
+ durationSeconds: { values: [5, 10] }
5535
+ },
5536
+ [GROK_IMAGINE_I2V_ENDPOINT2]: {
5537
+ aspectRatio: ["auto", "16:9", "4:3", "3:2", "1:1", "2:3", "3:4", "9:16"],
5538
+ resolution: ["480p", "720p"],
5539
+ durationSeconds: { min: 1, max: 15 }
5540
+ },
5541
+ ...Object.fromEntries(
5542
+ VEO_ENDPOINTS2.map((e) => [
5543
+ e,
5544
+ {
5545
+ aspectRatio: ["auto", "16:9", "9:16"],
5546
+ resolution: e === VEO_LITE_I2V_ENDPOINT2 || e === VEO_LITE_FLF_ENDPOINT2 ? ["720p", "1080p"] : ["720p", "1080p", "4k"],
5547
+ // Lite first-and-last renders 8 s only (its schema pins the const).
5548
+ durationSeconds: { values: e === VEO_LITE_FLF_ENDPOINT2 ? [8] : [4, 6, 8] }
5549
+ }
5550
+ ])
5551
+ ),
5552
+ [GROK_IMAGINE_15_I2V_ENDPOINT2]: { resolution: ["480p", "720p", "1080p"], durationSeconds: { min: 1, max: 15 } },
5553
+ [WAN_30_I2V_ENDPOINT2]: {
5554
+ aspectRatio: ["auto", "16:9", "4:3", "1:1", "3:4", "9:16"],
5555
+ resolution: ["480p", "720p", "1080p"]
5556
+ },
5557
+ [KLING_26_I2V_ENDPOINT2]: { durationSeconds: { values: [5, 10] } },
5558
+ ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS2.map((e) => [e, { durationSeconds: { min: 3, max: 15 } }])),
5559
+ // Reference-to-video renders at a set ratio (default 16:9), not the frame's.
5560
+ [KLING_O3_PRO_R2V_ENDPOINT2]: { aspectRatio: ["16:9", "9:16", "1:1"], durationSeconds: { min: 3, max: 15 } },
5561
+ [LTX_25_FAST_I2V_ENDPOINT2]: {
5562
+ aspectRatio: ["auto", "16:9", "9:16"],
5563
+ // fal also renders 1440p, which the canvas does not offer.
5564
+ resolution: ["720p", "1080p", "4k"],
5565
+ durationSeconds: { values: [6, 8, 10, 12, 14, 16, 18, 20] }
5566
+ },
5567
+ [LTX_25_PRO_I2V_ENDPOINT2]: {
5568
+ aspectRatio: ["auto", "16:9", "9:16"],
5569
+ resolution: ["720p", "1080p"],
5570
+ durationSeconds: { values: [6, 8, 10] }
5571
+ },
5572
+ // fal also renders 360p, which the canvas does not offer.
5573
+ [GEMINI_OMNI_11_I2V_ENDPOINT2]: {
5574
+ aspectRatio: ["16:9", "9:16"],
5575
+ resolution: ["720p", "1080p", "4k"],
5576
+ durationSeconds: { min: 3, max: 10 }
5577
+ },
5578
+ ...Object.fromEntries(KLING_V3_I2V_ENDPOINTS2.map((e) => [e, { durationSeconds: { min: 3, max: 15 } }])),
5579
+ [KLING_V4_I2V_ENDPOINT2]: { resolution: ["720p", "1080p"], durationSeconds: { min: 3, max: 30 } },
5580
+ // fal also renders 480P, which the canvas does not offer. Its shortest clip
5581
+ // is 5 s (KIE's is 4 s), so a 4 s job on the H3 route has no fal fallback.
5582
+ [MINIMAX_H3_I2V_ENDPOINT2]: { resolution: ["720p", "1080p", "4k"], durationSeconds: { min: 5, max: 15 } }
5583
+ };
5584
+ var VIDEO_MAX_SECONDS_AT_RESOLUTION2 = {
5585
+ [LTX_25_FAST_I2V_ENDPOINT2]: { "4k": 10 }
5586
+ };
5587
+ var VIDEO_UNSUPPORTED_PARAMS2 = {
5588
+ // Kling 2.5 Turbo and Seedance 1.0 Pro render silent clips and their schemas
5589
+ // declare no audio field at all (fal model schemas, checked 2026-10-25), so a
5590
+ // sound choice is refused before submit instead of being sent and ignored.
5591
+ "fal-ai/kling-video/v2.5-turbo/pro/image-to-video": ["generateAudio"],
5592
+ "fal-ai/bytedance/seedance/v1/pro/image-to-video": ["generateAudio"],
5593
+ "fal-ai/bytedance/seedance/v1/pro/text-to-video": ["generateAudio"],
5594
+ // Kling O3 Edit follows the source clip: its length, frame, size and look are
5595
+ // the source's, and the endpoint declares none of these knobs. A duration in
5596
+ // particular would only have been a (wrong) billing figure; the completer
5597
+ // measures the result instead.
5598
+ "fal-ai/kling-video/o3/pro/video-to-video/edit": [
5599
+ "resolution",
5600
+ "seed",
5601
+ "negativePrompt",
5602
+ "aspectRatio",
5603
+ "generateAudio",
5604
+ "durationSeconds"
5605
+ ],
5606
+ // Lip sync: the length is the audio's, the shape the face image's.
5607
+ ...Object.fromEntries(
5608
+ Object.keys(LIP_SYNC_SPECS2).map((e) => [e, ["resolution", "seed", "negativePrompt", "aspectRatio", "generateAudio", "durationSeconds"]])
5609
+ ),
5610
+ // Wan's output is also as long as its source; it takes resolution and seed.
5611
+ "fal-ai/wan/v2.2-14b/animate/replace": ["durationSeconds", "negativePrompt", "aspectRatio", "generateAudio"],
5612
+ "blackforestlabs/flux-3/keyframes-to-video/draft": ["resolution", "seed", "negativePrompt"],
5613
+ "blackforestlabs/flux-3/first-last-frame-to-video/draft": ["resolution", "seed", "negativePrompt"],
5614
+ "blackforestlabs/flux-3/image-to-video/draft": ["resolution", "seed", "negativePrompt"],
5615
+ // The direct tier adds `resolution` (720p | 1080p) and nothing else: `seed` is
5616
+ // OUTPUT only on every FLUX.3 endpoint, so a caller cannot pin a take by seed.
5617
+ "blackforestlabs/flux-3/keyframes-to-video": ["seed", "negativePrompt"],
5618
+ "blackforestlabs/flux-3/first-last-frame-to-video": ["seed", "negativePrompt"],
5619
+ "blackforestlabs/flux-3/image-to-video": ["seed", "negativePrompt"],
5620
+ // Enhance renders whatever the cache holds: duration, aspect, audio and prompt
5621
+ // are all baked in, and the output is a fixed 1080p. `durationSeconds` is NOT
5622
+ // banned although it is not forwarded either (buildFalVideoInput sends only
5623
+ // the cache url + safety_tolerance): the executor injects the upstream
5624
+ // draft's duration as a COST hint, since enhance bills per second and
5625
+ // the request itself carries nothing the estimate could read.
5626
+ "blackforestlabs/flux-3/draft-enhance": [
5627
+ "resolution",
5628
+ "seed",
5629
+ "negativePrompt",
5630
+ "aspectRatio",
5631
+ "generateAudio"
5632
+ ],
5633
+ // Grok's schema declares no seed, negative prompt or audio switch: it always
5634
+ // renders audio.
5635
+ [GROK_IMAGINE_I2V_ENDPOINT2]: ["seed", "negativePrompt", "generateAudio"],
5636
+ [GROK_IMAGINE_15_I2V_ENDPOINT2]: ["aspectRatio", "seed", "negativePrompt", "generateAudio"],
5637
+ [WAN_30_I2V_ENDPOINT2]: ["negativePrompt"],
5638
+ [KLING_26_I2V_ENDPOINT2]: ["resolution", "aspectRatio", "seed"],
5639
+ ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS2.map((e) => [e, ["resolution", "aspectRatio", "seed", "negativePrompt"]])),
5640
+ // Its tier sets the size; it takes an aspect ratio, but no seed or negative prompt.
5641
+ [KLING_O3_PRO_R2V_ENDPOINT2]: ["resolution", "seed", "negativePrompt"],
5642
+ ...Object.fromEntries(LTX_25_I2V_ENDPOINTS2.map((e) => [e, ["seed", "negativePrompt"]])),
5643
+ // Its schema declares no seed, negative prompt or audio switch: it always
5644
+ // renders audio, at no extra charge.
5645
+ [GEMINI_OMNI_11_I2V_ENDPOINT2]: ["seed", "negativePrompt", "generateAudio"],
5646
+ // Kling 3.0: the tier sets the size and the start frame the shape; it takes a
5647
+ // negative prompt but no seed.
5648
+ ...Object.fromEntries(KLING_V3_I2V_ENDPOINTS2.map((e) => [e, ["resolution", "aspectRatio", "seed"]])),
5649
+ // Kling 4.0 follows the start frame's shape and always renders sound.
5650
+ [KLING_V4_I2V_ENDPOINT2]: ["aspectRatio", "seed", "negativePrompt", "generateAudio"],
5651
+ // MiniMax H3 follows the start frame's shape and always renders sound (a 5 s
5652
+ // test render of 2026-11-04 had a video and an audio track); it takes a seed.
5653
+ [MINIMAX_H3_I2V_ENDPOINT2]: ["aspectRatio", "negativePrompt", "generateAudio"]
5654
+ };
5655
+ var VIDEO_AUDIO_SWITCH2 = {
5656
+ ...Object.fromEntries(VEO_ENDPOINTS2.map((e) => [e, { default: false }])),
5657
+ [KLING_26_I2V_ENDPOINT2]: { default: false },
5658
+ ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS2.map((e) => [e, { default: false }])),
5659
+ [KLING_O3_PRO_R2V_ENDPOINT2]: { default: false },
5660
+ // Kling 3.0 renders sound unless sent false; Studio sends it silent unless asked.
5661
+ ...Object.fromEntries(KLING_V3_I2V_ENDPOINTS2.map((e) => [e, { default: false }])),
5662
+ "bytedance/seedance-2.5/image-to-video": { default: true },
5663
+ "bytedance/seedance-2.0/image-to-video": { default: true },
5664
+ [WAN_30_I2V_ENDPOINT2]: { default: true },
5665
+ ...Object.fromEntries(LTX_25_I2V_ENDPOINTS2.map((e) => [e, { default: true }])),
5666
+ "blackforestlabs/flux-3/image-to-video/draft": { default: true },
5667
+ "blackforestlabs/flux-3/first-last-frame-to-video/draft": { default: true },
5668
+ "blackforestlabs/flux-3/keyframes-to-video/draft": { default: true },
5669
+ "blackforestlabs/flux-3/image-to-video": { default: true },
5670
+ "blackforestlabs/flux-3/first-last-frame-to-video": { default: true },
5671
+ "blackforestlabs/flux-3/keyframes-to-video": { default: true }
5672
+ };
5673
+ var NO_AUDIO_SWITCH = { switchable: false };
5674
+ function videoSettingSupport(model) {
5675
+ if (!model?.id || model.modality !== "video") return null;
5676
+ const upstream = getProviderModelName(model.id);
5677
+ if (model.provider === "kie") {
5678
+ const spec = KIE_VIDEO_SPECS2[upstream];
5679
+ if (!spec) return null;
5680
+ return {
5681
+ aspectRatios: spec.aspectRatios ?? [],
5682
+ resolutions: spec.resolutions,
5683
+ durations: spec.durations,
5684
+ defaultSeconds: spec.defaultSeconds,
5685
+ // The KIE spec says whether the job may switch audio (`audioSwitch`, the
5686
+ // rule its pre-submit check refuses by); its `defaultAudio` is the state
5687
+ // only where there is a switch.
5688
+ generateAudio: spec.audioSwitch ? { switchable: true, default: spec.defaultAudio } : NO_AUDIO_SWITCH
5689
+ };
5690
+ }
5691
+ if (model.provider === "openrouter") {
5692
+ const spec = OPENROUTER_VIDEO_SPECS2[upstream];
5693
+ if (!spec) return null;
5694
+ return {
5695
+ aspectRatios: spec.aspectRatios,
5696
+ resolutions: spec.resolutions,
5697
+ durations: spec.durations,
5698
+ defaultSeconds: spec.defaultSeconds,
5699
+ // Every OpenRouter video model is sent `generate_audio`, silent unless
5700
+ // the job asks (`openRouterVideoPlan`).
5701
+ generateAudio: { switchable: true, default: false }
5702
+ };
5703
+ }
5704
+ if (model.provider === "fal") {
5705
+ const allowed = VIDEO_ALLOWED_VALUES2[upstream];
5706
+ const unsupported = VIDEO_UNSUPPORTED_PARAMS2[upstream] ?? [];
5707
+ const pinned = VIDEO_PINNED_DEFAULT_SECONDS2[upstream];
5708
+ const maxSecondsAt = VIDEO_MAX_SECONDS_AT_RESOLUTION2[upstream];
5709
+ return {
5710
+ ...maxSecondsAt ? { maxSecondsAt } : {},
5711
+ aspectRatios: unsupported.includes("aspectRatio") ? [] : allowed?.aspectRatio ?? null,
5712
+ resolutions: unsupported.includes("resolution") ? [] : allowed?.resolution ?? null,
5713
+ durations: unsupported.includes("durationSeconds") ? { values: [] } : allowed?.durationSeconds ?? null,
5714
+ ...pinned !== void 0 ? { defaultSeconds: pinned } : {},
5715
+ generateAudio: falAudioSupport(upstream, unsupported)
5716
+ };
5717
+ }
5718
+ return null;
5719
+ }
5720
+ function falAudioSupport(endpoint, unsupported) {
5721
+ if (unsupported.includes("generateAudio")) return NO_AUDIO_SWITCH;
5722
+ const declared = VIDEO_AUDIO_SWITCH2[endpoint];
5723
+ return declared ? { switchable: true, default: declared.default } : null;
5724
+ }
5725
+ function supportedResolutions(model) {
5726
+ const declared = model?.capabilities?.resolutions;
5727
+ return declared ? declared : null;
5728
+ }
5729
+ function resolutionRefusal(model, resolution) {
5730
+ if (resolution === void 0 || resolution === null || resolution === "") return null;
5731
+ const supported = supportedResolutions(model);
5732
+ if (!model || supported === null) return null;
5733
+ const name = model.label ?? model.id;
5734
+ if (supported.length === 0) {
5735
+ return `${name} takes no resolution setting and always renders at its own size, so "${String(resolution)}" would be silently ignored. Clear the resolution, or pick a model that honours it, such as Nano Banana 2.`;
5736
+ }
5737
+ const tier = imageResolutionTier(resolution);
5738
+ if (tier && supported.includes(tier)) return null;
5739
+ if (model.capabilities?.tierKind === "quality") {
5740
+ const offered = supported.map((t) => `${imageTierLabel(model, t).toLowerCase()} (${IMAGE_SIZE_OF_TIER[t]})`).join(", ");
5741
+ return `${name} takes the quality ${offered}, not "${String(resolution)}". Pick one of those.`;
5742
+ }
5743
+ return `${name} renders at ${supported.join(", ")}, not "${String(resolution)}". Pick one of those.`;
5744
+ }
5745
+ function sendableSettings(settings, model) {
5746
+ if (!settings || !("generateAudio" in settings)) return settings;
5747
+ if (videoSettingSupport(model)?.generateAudio?.switchable === true) return settings;
5748
+ const kept = { ...settings };
5749
+ delete kept.generateAudio;
5750
+ return kept;
5751
+ }
5752
+ function sendableOptions(options, model) {
5753
+ if (!options || typeof options !== "object" || Array.isArray(options) || !("generateAudio" in options)) return options;
5754
+ if (videoSettingSupport(model)?.generateAudio?.switchable === true) return options;
5755
+ const kept = { ...options };
5756
+ delete kept.generateAudio;
5757
+ return kept;
5758
+ }
5759
+ function voiceSettingsRefusal(model, voiceSettings) {
5760
+ const speech = model?.capabilities?.speech;
5761
+ if (!speech || speech.voiceSettings.speed) return null;
5762
+ if (!voiceSettings || typeof voiceSettings !== "object" || voiceSettings.speed === void 0) return null;
5763
+ return `${model?.label ?? model?.id ?? "This model"} has no Speed setting. Remove voiceSettings.speed, or pick a model that has it.`;
5764
+ }
5765
+ var PROMPT_REQUIRED = /* @__PURE__ */ new Set([
5766
+ "text-to-image",
5767
+ "image-to-image",
5768
+ "image-edit",
5769
+ "text-to-3d",
5770
+ "image-to-3d",
5771
+ "multiview-to-3d",
5772
+ "text-to-video",
5773
+ // Texture: 3D AI Studio refuses a texture request without a prompt or a
5774
+ // reference image (probed 2026-09-26), and Studio sends no reference image,
5775
+ // so the material description is required. It binds `texturePrompt`, see
5776
+ // `promptInputKey`.
5777
+ "texture",
5778
+ // Audio is prompt-only: a music description (text-to-audio) / the text to
5779
+ // speak (text-to-speech). No upstream wire, so no portBinding entry.
5780
+ "text-to-audio",
5781
+ "text-to-speech"
5782
+ ]);
5783
+ var PROMPT_OPTIONAL = /* @__PURE__ */ new Set(["image-to-video", "image-to-json", "video-to-video", "lip-sync"]);
5784
+ function taskNeedsPrompt(task) {
5785
+ return PROMPT_REQUIRED.has(task) || PROMPT_OPTIONAL.has(task);
5786
+ }
5787
+ function taskRequiresPrompt(task) {
5788
+ return PROMPT_REQUIRED.has(task);
5789
+ }
5790
+ function promptInputKey(task) {
5791
+ return task === "texture" ? "texturePrompt" : "prompt";
5792
+ }
5793
+ function portBinding(task, port) {
5794
+ if (port === "image" && (task === "image-to-3d" || task === "multiview-to-3d" || task === "image-to-video" || task === "lip-sync" || task === "image-to-text" || task === "image-to-json")) {
5795
+ return { key: "inputImageUrl", path: "url" };
5796
+ }
5797
+ if (port === "reference" && task === "image-to-video") {
5798
+ return { key: "referenceImageUrls", path: "url", wrap: "array" };
5799
+ }
5800
+ if (port === "mesh3d" && (task === "remesh" || task === "texture" || task === "rig")) {
5801
+ return { key: "parentAssetId", path: "assetId" };
5802
+ }
5803
+ if (port === "video" && task === "video-to-text") {
4473
5804
  return { key: "inputVideoUrl", path: "url" };
4474
5805
  }
4475
5806
  if (port === "video" && task === "video-to-video") {
@@ -4490,7 +5821,7 @@ function portBinding(task, port) {
4490
5821
  if (port === "image" && (task === "upscale" || task === "background-remove")) {
4491
5822
  return { key: "parentAssetId", path: "assetId" };
4492
5823
  }
4493
- if (port === "audio" && task === "speech-to-text") {
5824
+ if (port === "audio" && (task === "speech-to-text" || task === "lip-sync")) {
4494
5825
  return { key: "inputAudioUrl", path: "url" };
4495
5826
  }
4496
5827
  if (port === "image" && task === "judge") {
@@ -4550,10 +5881,10 @@ function orderedPortKey(task, port, ordinal, model) {
4550
5881
  if (portCardinality(task, port, model) === "two" && ordinal === 1) return "endImageUrl";
4551
5882
  return canonical.key;
4552
5883
  }
4553
- function sourcePortOf(node) {
4554
- switch (node.kind) {
5884
+ function sourcePortOf(node2) {
5885
+ switch (node2.kind) {
4555
5886
  case "task":
4556
- return taskPorts(node.task).output;
5887
+ return taskPorts(node2.task).output;
4557
5888
  case "prompt-source":
4558
5889
  return "text";
4559
5890
  case "image-source":
@@ -4561,35 +5892,35 @@ function sourcePortOf(node) {
4561
5892
  case "video-source":
4562
5893
  return "video";
4563
5894
  case "input":
4564
- return node.type;
5895
+ return node2.type;
4565
5896
  }
4566
5897
  }
4567
- function targetCardinality(node, port) {
4568
- if (node.kind !== "task") return "none";
4569
- return portCardinality(node.task, port, node.model);
5898
+ function targetCardinality(node2, port) {
5899
+ if (node2.kind !== "task") return "none";
5900
+ return portCardinality(node2.task, port, node2.model);
4570
5901
  }
4571
- function slotRefusal(node, port, wired) {
4572
- const cardinality = targetCardinality(node, port);
5902
+ function slotRefusal(node2, port, wired) {
5903
+ const cardinality = targetCardinality(node2, port);
4573
5904
  let limit = cardinalityLimit(cardinality);
4574
- if (port === "reference" && node.kind === "task") {
4575
- const refs = modelCharacterReferences(node.model);
5905
+ if (port === "reference" && node2.kind === "task") {
5906
+ const refs = modelCharacterReferences(node2.model);
4576
5907
  if (refs) limit = Math.min(limit, refs.maxTotalImages);
4577
5908
  if (wired < limit) return null;
4578
5909
  if (!refs) {
4579
- return `node "${node.id}" (${node.model || "no model"}) takes no character references; pick a model that holds identity from reference images (Kling elements) or remove the reference wires`;
5910
+ return `node "${node2.id}" (${node2.model || "no model"}) takes no character references; pick a model that holds identity from reference images (Kling elements) or remove the reference wires`;
4580
5911
  }
4581
- return `node "${node.id}" (${node.model}) takes at most ${limit} character reference images in all`;
5912
+ return `node "${node2.id}" (${node2.model}) takes at most ${limit} character reference images in all`;
4582
5913
  }
4583
- if (cardinality === "many" && node.kind === "task" && node.model) {
4584
- const cap = tryGetModel2(node.model)?.capabilities?.maxInputImages;
5914
+ if (cardinality === "many" && node2.kind === "task" && node2.model) {
5915
+ const cap = tryGetModel2(node2.model)?.capabilities?.maxInputImages;
4585
5916
  if (typeof cap === "number" && cap > 0) limit = Math.min(limit, cap);
4586
5917
  }
4587
5918
  if (wired < limit) return null;
4588
- if (cardinality === "one") return `node "${node.id}" accepts one ${port} wire, got more`;
5919
+ if (cardinality === "one") return `node "${node2.id}" accepts one ${port} wire, got more`;
4589
5920
  if (cardinality === "two") {
4590
- return `node "${node.id}" takes two ${port} wires (start frame, end frame), got more. A shot that needs more than two keyframes wants a keyframes model (FLUX.3 keyframes), which takes up to ten.`;
5921
+ return `node "${node2.id}" takes two ${port} wires (start frame, end frame), got more. A shot that needs more than two keyframes wants a keyframes model (FLUX.3 keyframes), which takes up to ten.`;
4591
5922
  }
4592
- return `node "${node.id}" (${node.kind === "task" ? node.model : node.kind}) takes at most ${limit} ${port} wires`;
5923
+ return `node "${node2.id}" (${node2.kind === "task" ? node2.model : node2.kind}) takes at most ${limit} ${port} wires`;
4593
5924
  }
4594
5925
  function wireLegality(source, target, port) {
4595
5926
  if (source.id === target.id) return { ok: false, code: "cycle", message: `node "${source.id}" cannot wire into itself` };
@@ -4651,17 +5982,17 @@ function validateDocument(doc) {
4651
5982
  };
4652
5983
  }
4653
5984
  const byId = /* @__PURE__ */ new Map();
4654
- for (const node of doc.nodes) {
4655
- if (byId.has(node.id)) return { ok: false, code: "conflict", message: `duplicate node id "${node.id}"` };
4656
- byId.set(node.id, node);
5985
+ for (const node2 of doc.nodes) {
5986
+ if (byId.has(node2.id)) return { ok: false, code: "conflict", message: `duplicate node id "${node2.id}"` };
5987
+ byId.set(node2.id, node2);
4657
5988
  }
4658
5989
  const inputNames = /* @__PURE__ */ new Set();
4659
- for (const node of doc.nodes) {
4660
- if (node.kind !== "input") continue;
4661
- if (inputNames.has(node.name)) {
4662
- return { ok: false, code: "conflict", message: `duplicate input name "${node.name}"` };
5990
+ for (const node2 of doc.nodes) {
5991
+ if (node2.kind !== "input") continue;
5992
+ if (inputNames.has(node2.name)) {
5993
+ return { ok: false, code: "conflict", message: `duplicate input name "${node2.name}"` };
4663
5994
  }
4664
- inputNames.add(node.name);
5995
+ inputNames.add(node2.name);
4665
5996
  }
4666
5997
  const edgeKeys = /* @__PURE__ */ new Set();
4667
5998
  const slots = /* @__PURE__ */ new Map();
@@ -4695,12 +6026,16 @@ function validateDocument(doc) {
4695
6026
  };
4696
6027
  }
4697
6028
  }
4698
- for (const node of doc.nodes) {
4699
- if (node.kind !== "task" || !node.model) continue;
4700
- const baked = node.bakedInputs?.imageSize;
4701
- const requested = node.settings?.resolution ?? (baked && baked.kind === "literal" ? baked.value : void 0);
4702
- const refusal = resolutionRefusal(tryGetModel2(node.model), requested);
4703
- if (refusal) return { ok: false, code: "unsupported", message: `"${node.id}": ${refusal}` };
6029
+ for (const node2 of doc.nodes) {
6030
+ if (node2.kind !== "task" || !node2.model) continue;
6031
+ const baked = node2.bakedInputs?.imageSize;
6032
+ const requested = node2.settings?.resolution ?? (baked && baked.kind === "literal" ? baked.value : void 0);
6033
+ const refusal = resolutionRefusal(tryGetModel2(node2.model), requested);
6034
+ if (refusal) return { ok: false, code: "unsupported", message: `"${node2.id}": ${refusal}` };
6035
+ const baking = node2.bakedInputs?.options;
6036
+ const bakedVoice = baking && baking.kind === "literal" && baking.value && typeof baking.value === "object" ? baking.value.voiceSettings : void 0;
6037
+ const voiceRefusal = voiceSettingsRefusal(tryGetModel2(node2.model), node2.settings?.voiceSettings ?? bakedVoice);
6038
+ if (voiceRefusal) return { ok: false, code: "unsupported", message: `"${node2.id}": ${voiceRefusal}` };
4704
6039
  }
4705
6040
  if (documentTopologicalOrder(doc) === null) {
4706
6041
  return { ok: false, code: "cycle", message: `document "${doc.id}" has a cycle in its wires` };
@@ -4765,7 +6100,7 @@ var InputNodePropsSchema = z4.object({
4765
6100
  }).partial().strict();
4766
6101
  var GroupPropsSchema = z4.object({
4767
6102
  label: LabelSchema.nullable(),
4768
- nodeIds: z4.array(IdSchema).min(1)
6103
+ nodeIds: z4.array(IdSchema).min(1).max(MAX_DOCUMENT_NODES)
4769
6104
  }).partial().strict();
4770
6105
  var DocumentPropsSchema = z4.object({
4771
6106
  label: LabelSchema,
@@ -4861,7 +6196,7 @@ var GroupOpSchema = z4.object({
4861
6196
  type: z4.literal("group"),
4862
6197
  id: IdSchema,
4863
6198
  label: LabelSchema.optional(),
4864
- nodeIds: z4.array(IdSchema).min(1),
6199
+ nodeIds: z4.array(IdSchema).min(1).max(MAX_DOCUMENT_NODES),
4865
6200
  index: Index.optional()
4866
6201
  });
4867
6202
  var UngroupOpSchema = z4.object({
@@ -4991,6 +6326,10 @@ function likenessConfirmationRequiredMessage() {
4991
6326
  function likenessConfirmationToolDescription() {
4992
6327
  return `Must be the literal true. It records this confirmation on the character: "${LIKENESS_ACKNOWLEDGEMENT}" Ask the human you act for and pass true only after they confirm it for this character; never assert it on your own. Terms and acceptable use: ${TERMS_URL}`;
4993
6328
  }
6329
+ var IMAGE_ASPECT_RATIOS2 = ASPECT_RATIOS2.map((value) => ({
6330
+ value,
6331
+ label: value
6332
+ }));
4994
6333
  function taskModality(task) {
4995
6334
  const out = taskPorts(task).output;
4996
6335
  switch (out) {
@@ -5015,6 +6354,17 @@ function lit(value) {
5015
6354
  function isFiniteNumber(v) {
5016
6355
  return typeof v === "number" && Number.isFinite(v);
5017
6356
  }
6357
+ function voiceSettingsOf(v) {
6358
+ if (!v || typeof v !== "object" || Array.isArray(v)) return null;
6359
+ const o = v;
6360
+ if (!isFiniteNumber(o.stability) || !isFiniteNumber(o.similarityBoost)) return null;
6361
+ if (o.speed !== void 0 && !isFiniteNumber(o.speed)) return null;
6362
+ return {
6363
+ stability: o.stability,
6364
+ similarityBoost: o.similarityBoost,
6365
+ ...o.speed !== void 0 ? { speed: o.speed } : {}
6366
+ };
6367
+ }
5018
6368
  function settingsBindings(task, settings) {
5019
6369
  if (!task || !settings || Object.keys(settings).length === 0) return {};
5020
6370
  const modality = taskModality(task);
@@ -5028,6 +6378,7 @@ function settingsBindings(task, settings) {
5028
6378
  }
5029
6379
  case "video": {
5030
6380
  const options = {};
6381
+ if (task === "lip-sync") return {};
5031
6382
  if (task === "video-to-video") {
5032
6383
  if (typeof settings.resolution === "string") options.resolution = settings.resolution;
5033
6384
  return Object.keys(options).length > 0 ? { options: lit(options) } : {};
@@ -5035,11 +6386,17 @@ function settingsBindings(task, settings) {
5035
6386
  if (typeof settings.aspectRatio === "string") options.aspectRatio = settings.aspectRatio;
5036
6387
  if (typeof settings.resolution === "string") options.resolution = settings.resolution;
5037
6388
  if (isFiniteNumber(settings.duration)) options.durationSeconds = settings.duration;
6389
+ if (typeof settings.generateAudio === "boolean") options.generateAudio = settings.generateAudio;
5038
6390
  return Object.keys(options).length > 0 ? { options: lit(options) } : {};
5039
6391
  }
5040
6392
  case "audio": {
5041
6393
  const options = {};
5042
6394
  if (isFiniteNumber(settings.duration)) options.durationSeconds = settings.duration;
6395
+ if (task === "text-to-speech") {
6396
+ if (typeof settings.voiceId === "string" && settings.voiceId) options.voiceId = settings.voiceId;
6397
+ const voice = voiceSettingsOf(settings.voiceSettings);
6398
+ if (voice) options.voiceSettings = voice;
6399
+ }
5043
6400
  return Object.keys(options).length > 0 ? { options: lit(options) } : {};
5044
6401
  }
5045
6402
  default:
@@ -5092,6 +6449,41 @@ function keyframePositionsFor(sourceIds, settings) {
5092
6449
  return { ok: true, frames };
5093
6450
  }
5094
6451
  var REFERENCE_ELEMENTS_SETTING = "referenceElements";
6452
+ var CAST_MENTIONS_SETTING = "castMentions";
6453
+ var CAST_REFERENCES_SETTING = "castReferences";
6454
+ var CAST_TASKS = /* @__PURE__ */ new Set(["text-to-image", "image-edit", "image-to-image", "image-to-video"]);
6455
+ function castSettingOf(task, settings) {
6456
+ const none = { cast: [], own: false };
6457
+ if (!CAST_TASKS.has(task)) return none;
6458
+ const mentions = settings?.[CAST_MENTIONS_SETTING];
6459
+ const own = !(Array.isArray(mentions) && mentions.length > 0);
6460
+ const raw = own ? settings?.[CAST_REFERENCES_SETTING] : mentions;
6461
+ if (!Array.isArray(raw)) return none;
6462
+ const cast = raw.flatMap((r) => {
6463
+ const parsed = CastMemberSchema.safeParse(r);
6464
+ return parsed.success ? [parsed.data] : [];
6465
+ });
6466
+ return { cast, own: own && cast.length > 0 };
6467
+ }
6468
+ function castByElement(cast, elementOf) {
6469
+ const again = "Type the mention again in the prompt bar so its views are wired anew, or set the character number on its reference cards.";
6470
+ const characters = cast.filter((m) => m.kind === "character");
6471
+ const placed = [];
6472
+ for (const member of characters) {
6473
+ const elements = new Set((member.sources ?? []).filter((s) => elementOf.has(s)).map((s) => elementOf.get(s)));
6474
+ if (elements.size === 0) return { ok: false, reason: `${member.name}'s reference images are no longer wired into this clip. ${again}` };
6475
+ if (elements.size > 1) return { ok: false, reason: `${member.name}'s reference images are set to more than one character number. ${again}` };
6476
+ const element = [...elements][0];
6477
+ const twin = placed.find((p) => p.element === element);
6478
+ if (twin) return { ok: false, reason: `${twin.member.name} and ${member.name} are wired as the same character. ${again}` };
6479
+ placed.push({ member, element });
6480
+ }
6481
+ const wired = new Set(elementOf.values());
6482
+ if (wired.size !== placed.length) {
6483
+ return { ok: false, reason: `This clip's references show ${wired.size} character${wired.size === 1 ? "" : "s"}, and its prompt names ${placed.length}. Remove the reference cards of anyone the prompt does not name, or name them in the prompt.` };
6484
+ }
6485
+ return { ok: true, cast: placed.sort((a, b) => a.element - b.element).map((p) => p.member) };
6486
+ }
5095
6487
  function referenceElementsFor(sourceIds, settings, limits) {
5096
6488
  const raw = settings?.[REFERENCE_ELEMENTS_SETTING];
5097
6489
  if (raw !== void 0 && (raw === null || typeof raw !== "object" || Array.isArray(raw))) {
@@ -5167,6 +6559,7 @@ var TASK_TO_KIND = {
5167
6559
  // video-to-video (character replace via Wan 2.2 Animate or Kling O3 Edit): rides the same
5168
6560
  // generate_video job; the fal provider routes the task to the replace endpoint.
5169
6561
  "video-to-video": "generate_video",
6562
+ "lip-sync": "generate_video",
5170
6563
  // video-enhance (FLUX.3 draft-enhance): the same generate_video job; the fal
5171
6564
  // provider sends the upstream draft's cache bundle instead of frames.
5172
6565
  "video-enhance": "generate_video",
@@ -5255,26 +6648,28 @@ function documentToDefinition(doc, opts = {}) {
5255
6648
  ...n.default !== void 0 ? { default: n.default } : {}
5256
6649
  }));
5257
6650
  let nodes = [];
5258
- for (const node of doc.nodes) {
5259
- if (node.kind !== "task") continue;
5260
- const { task } = node;
6651
+ const elementOfSource = /* @__PURE__ */ new Map();
6652
+ const referencesRefused = /* @__PURE__ */ new Set();
6653
+ for (const node2 of doc.nodes) {
6654
+ if (node2.kind !== "task") continue;
6655
+ const { task } = node2;
5261
6656
  if (taskExecution(task) === null) {
5262
6657
  issues.push({
5263
6658
  code: "not_runnable",
5264
- nodeId: node.id,
5265
- message: `Node "${node.id}" (${task}) is not runnable yet.`
6659
+ nodeId: node2.id,
6660
+ message: `Node "${node2.id}" (${task}) is not runnable yet.`
5266
6661
  });
5267
6662
  continue;
5268
6663
  }
5269
- if (node.model.length === 0) {
6664
+ if (node2.model.length === 0) {
5270
6665
  issues.push({
5271
6666
  code: "no_model",
5272
- nodeId: node.id,
5273
- message: `Node "${node.id}" needs a model.`
6667
+ nodeId: node2.id,
6668
+ message: `Node "${node2.id}" needs a model.`
5274
6669
  });
5275
6670
  }
5276
6671
  const inputs = {};
5277
- const wires = incoming.get(node.id) ?? [];
6672
+ const wires = incoming.get(node2.id) ?? [];
5278
6673
  const textWire = wires.find((e) => e.port === "text");
5279
6674
  let promptMissing = false;
5280
6675
  if (taskNeedsPrompt(task)) {
@@ -5292,15 +6687,15 @@ function documentToDefinition(doc, opts = {}) {
5292
6687
  path: portBinding(task, "text").path
5293
6688
  };
5294
6689
  } else {
5295
- const text = node.prompt.trim();
6690
+ const text = node2.prompt.trim();
5296
6691
  if (text.length > 0) inputs[key] = { kind: "literal", value: text };
5297
6692
  }
5298
6693
  if (!(key in inputs) && taskRequiresPrompt(task)) {
5299
6694
  promptMissing = true;
5300
6695
  issues.push({
5301
6696
  code: "prompt_required",
5302
- nodeId: node.id,
5303
- message: `Node "${node.id}" (${task}) needs a prompt.`
6697
+ nodeId: node2.id,
6698
+ message: `Node "${node2.id}" (${task}) needs a prompt.`
5304
6699
  });
5305
6700
  }
5306
6701
  }
@@ -5313,17 +6708,17 @@ function documentToDefinition(doc, opts = {}) {
5313
6708
  }
5314
6709
  for (const [port, portWires] of byPort) {
5315
6710
  const b = portBinding(task, port);
5316
- const cardinality = portCardinality(task, port, node.model);
5317
- const keyframes = port === "image" && task === "image-to-video" && modelAcceptsKeyframes(node.model);
6711
+ const cardinality = portCardinality(task, port, node2.model);
6712
+ const keyframes = port === "image" && task === "image-to-video" && modelAcceptsKeyframes(node2.model);
5318
6713
  const references = port === "reference";
5319
- const listKey = orderedPortKey(task, port, 0, node.model) ?? b.key;
6714
+ const listKey = orderedPortKey(task, port, 0, node2.model) ?? b.key;
5320
6715
  const items2 = [];
5321
6716
  const itemSources = [];
5322
6717
  let uploading = false;
5323
6718
  for (const [ordinal, e] of portWires.entries()) {
5324
6719
  const source = byId.get(e.source);
5325
6720
  const single = !keyframes && !references && (cardinality !== "many" || portWires.length === 1);
5326
- const key = orderedPortKey(task, port, ordinal, node.model) ?? b.key;
6721
+ const key = orderedPortKey(task, port, ordinal, node2.model) ?? b.key;
5327
6722
  const wrap = single && b.wrap === "array";
5328
6723
  let item = null;
5329
6724
  if (source.kind === "image-source") {
@@ -5331,8 +6726,8 @@ function documentToDefinition(doc, opts = {}) {
5331
6726
  if (!isUsableSourceUrl(url)) {
5332
6727
  issues.push({
5333
6728
  code: "source_uploading",
5334
- nodeId: node.id,
5335
- message: `Image source for "${node.id}" is still uploading; wait for it to finish.`
6729
+ nodeId: node2.id,
6730
+ message: `Image source for "${node2.id}" is still uploading; wait for it to finish.`
5336
6731
  });
5337
6732
  uploading = true;
5338
6733
  continue;
@@ -5343,8 +6738,8 @@ function documentToDefinition(doc, opts = {}) {
5343
6738
  if (!isUsableSourceUrl(clip)) {
5344
6739
  issues.push({
5345
6740
  code: "source_uploading",
5346
- nodeId: node.id,
5347
- message: `Video source for "${node.id}" is still uploading; wait for it to finish.`
6741
+ nodeId: node2.id,
6742
+ message: `Video source for "${node2.id}" is still uploading; wait for it to finish.`
5348
6743
  });
5349
6744
  uploading = true;
5350
6745
  continue;
@@ -5363,20 +6758,21 @@ function documentToDefinition(doc, opts = {}) {
5363
6758
  }
5364
6759
  }
5365
6760
  if (references && !uploading && items2.length > 0) {
5366
- const limits = modelCharacterReferences(node.model);
6761
+ const limits = modelCharacterReferences(node2.model);
5367
6762
  const grouped = limits ? referenceElementsFor(
5368
6763
  itemSources,
5369
- node.settings,
6764
+ node2.settings,
5370
6765
  limits
5371
6766
  ) : {
5372
6767
  ok: false,
5373
- reason: `${node.model || "this model"} takes no character references`
6768
+ reason: `${node2.model || "this model"} takes no character references`
5374
6769
  };
5375
6770
  if (grouped.ok) {
5376
6771
  inputs[listKey] = {
5377
6772
  kind: "list",
5378
6773
  items: grouped.order.map((i) => items2[i])
5379
6774
  };
6775
+ elementOfSource.set(node2.id, new Map(grouped.order.map((i, k) => [itemSources[i], grouped.elements[k]])));
5380
6776
  inputs.referenceElementIndexes = {
5381
6777
  kind: "literal",
5382
6778
  value: grouped.elements
@@ -5384,9 +6780,10 @@ function documentToDefinition(doc, opts = {}) {
5384
6780
  } else {
5385
6781
  issues.push({
5386
6782
  code: "character_references",
5387
- nodeId: node.id,
5388
- message: `Node "${node.id}": ${grouped.reason}`
6783
+ nodeId: node2.id,
6784
+ message: `Node "${node2.id}": ${grouped.reason}`
5389
6785
  });
6786
+ referencesRefused.add(node2.id);
5390
6787
  }
5391
6788
  continue;
5392
6789
  }
@@ -5395,7 +6792,7 @@ function documentToDefinition(doc, opts = {}) {
5395
6792
  if (keyframes && !uploading && items2.length > 0) {
5396
6793
  const positions = keyframePositionsFor(
5397
6794
  portWires.map((e) => e.source),
5398
- node.settings
6795
+ node2.settings
5399
6796
  );
5400
6797
  if (positions.ok) {
5401
6798
  inputs.keyframeFrameIndexes = {
@@ -5405,30 +6802,48 @@ function documentToDefinition(doc, opts = {}) {
5405
6802
  } else {
5406
6803
  issues.push({
5407
6804
  code: "keyframe_positions",
5408
- nodeId: node.id,
5409
- message: `Node "${node.id}": ${positions.reason}`
6805
+ nodeId: node2.id,
6806
+ message: `Node "${node2.id}": ${positions.reason}`
5410
6807
  });
5411
6808
  }
5412
6809
  }
5413
6810
  }
5414
- for (const [key, binding] of Object.entries(node.bakedInputs))
5415
- if (!(key in inputs)) inputs[key] = binding;
6811
+ const imagesWired = "inputImages" in inputs;
6812
+ for (const [key, binding] of Object.entries(node2.bakedInputs)) {
6813
+ if (key in inputs) continue;
6814
+ if (key === "options" && binding.kind === "literal") {
6815
+ const kept = sendableOptions(binding.value, tryGetModel2(node2.model));
6816
+ inputs[key] = kept === binding.value ? binding : { kind: "literal", value: kept };
6817
+ } else inputs[key] = binding;
6818
+ }
5416
6819
  if (task === "image-to-video" && "referenceImageUrls" in inputs && !("inputImageUrl" in inputs)) {
5417
6820
  issues.push({
5418
6821
  code: "character_references",
5419
- nodeId: node.id,
5420
- message: `Node "${node.id}": character references need a start frame; wire one into the image port.`
6822
+ nodeId: node2.id,
6823
+ message: `Node "${node2.id}": character references need a start frame; wire one into the image port.`
5421
6824
  });
5422
6825
  }
5423
6826
  if (Object.keys(inputs).length === 0 && !promptMissing) {
5424
6827
  issues.push({
5425
6828
  code: "no_inputs",
5426
- nodeId: node.id,
5427
- message: `Node "${node.id}" (${task}) needs an input: wire in an upstream asset or type a prompt.`
6829
+ nodeId: node2.id,
6830
+ message: `Node "${node2.id}" (${task}) needs an input: wire in an upstream asset or type a prompt.`
5428
6831
  });
5429
6832
  }
5430
- Object.assign(inputs, settingsBindings(task, node.settings));
5431
- nodes.push({ id: node.id, task, model: node.model, inputs });
6833
+ Object.assign(inputs, settingsBindings(task, sendableSettings(node2.settings, tryGetModel2(node2.model))));
6834
+ const named = castSettingOf(task, node2.settings);
6835
+ const { own } = named;
6836
+ let cast = named.cast;
6837
+ if (task === "image-to-video" && cast.length > 0 && referencesRefused.has(node2.id)) cast = [];
6838
+ else if (task === "image-to-video" && cast.length > 0) {
6839
+ const placed = castByElement(cast, elementOfSource.get(node2.id) ?? /* @__PURE__ */ new Map());
6840
+ if (placed.ok) cast = placed.cast;
6841
+ else {
6842
+ issues.push({ code: "character_references", nodeId: node2.id, message: `Node "${node2.id}": ${placed.reason}` });
6843
+ cast = [];
6844
+ }
6845
+ }
6846
+ nodes.push({ id: node2.id, task, model: node2.model, inputs, ...cast.length > 0 ? { cast } : {}, ...own ? { castOwn: true } : {}, ...cast.length > 0 && imagesWired ? { imagesWired: true } : {} });
5432
6847
  }
5433
6848
  if (scope) {
5434
6849
  const projected = new Set(nodes.map((n) => n.id));
@@ -5477,13 +6892,19 @@ function documentToDefinition(doc, opts = {}) {
5477
6892
  }
5478
6893
 
5479
6894
  // src/characterSheet.ts
6895
+ var OVERVIEW_CATEGORY = "overview";
6896
+ var OVERVIEW_ASPECT_RATIO = "21:9";
6897
+ var OVERVIEW_RESOLUTION = "4K";
5480
6898
  var IDENTITY_INSTRUCTION = "This is the same person, same face, same identity as the reference image: keep the facial structure, features, hair, and proportions identical. Do not invent a new face.";
5481
- var NEUTRAL_STUDIO = "Plain light-gray seamless studio background, no props, no text, no watermark, photorealistic, sharp focus.";
6899
+ var NEUTRAL_STUDIO = "Plain light-gray seamless studio background, no props, no text, no labels, no numbers, no watermark, photorealistic, sharp focus. Natural, unretouched skin with visible texture and slight natural asymmetry; no beauty filter, no airbrushing.";
6900
+ var SCREEN_SIDE_INSTRUCTION = 'The camera stays fixed and the person rotates on the vertical axis only. "Screen-left" and "screen-right" mean the left and right edge of the image as the viewer sees it. Do not mirror or flip the image.';
6901
+ var CHAINED_BACK_INPUTS_INSTRUCTION = "Input images: image 1 is the person's face, the identity reference: keep the hair colour, hair length and texture, skin tone and build exactly as in image 1. Image 2 is the same person's front full-body view, the figure to turn round: keep its clothing, shoes, body proportions and stance exactly, and show them from behind.";
6902
+ var TURNAROUND_CAMERA_INSTRUCTION = "Camera: straight-on, at the person's chest height, the same height in every view, long lens with no wide-angle distortion, like an orthographic turnaround. Even, soft, neutral studio lighting.";
5482
6903
  var WARDROBE_STANDARD_PHRASE = "plain heather-gray crew-neck t-shirt";
5483
6904
  var WARDROBE_INSTRUCTION = `Wardrobe: the character is wearing a ${WARDROBE_STANDARD_PHRASE}, unbranded, with no logos, graphics, prints, or patterns.`;
5484
- var FULL_BODY_WARDROBE_INSTRUCTION = `Wardrobe: the character is wearing a ${WARDROBE_STANDARD_PHRASE} and plain dark straight-leg trousers, unbranded, with no logos, graphics, prints, or patterns.`;
6905
+ var FULL_BODY_WARDROBE_INSTRUCTION = `Wardrobe: the character is wearing a ${WARDROBE_STANDARD_PHRASE}, plain dark straight-leg trousers and plain dark shoes, unbranded, with no logos, graphics, prints, or patterns.`;
5485
6906
  function wardrobeInstructionForCategory(category) {
5486
- return category === "full-body" ? FULL_BODY_WARDROBE_INSTRUCTION : WARDROBE_INSTRUCTION;
6907
+ return category === "full-body" || category === "back" ? FULL_BODY_WARDROBE_INSTRUCTION : WARDROBE_INSTRUCTION;
5487
6908
  }
5488
6909
  function identityAnchor(description) {
5489
6910
  return `Character identity (keep identical in every view): ${description.trim()}`;
@@ -5499,44 +6920,64 @@ function seedFacePrompt(description) {
5499
6920
  ].join("\n\n");
5500
6921
  }
5501
6922
  var VIEW_INSTRUCTION = {
5502
- "three-quarter": "Three-quarter (45 degree) view: turn the head and upper body slightly to one side. Chest-up framing, square 1:1 crop. Even neutral studio lighting.",
5503
- profile: "Full side profile (90 degree) view. Chest-up framing, square 1:1 crop. Even neutral studio lighting.",
5504
- "full-body": "Full-body head-to-toe view: the character standing in a relaxed neutral pose, facing forward. 3:4 portrait crop with the whole figure in frame. Even neutral studio lighting.",
5505
- "close-up": "Tight front-facing close-up of the face, capturing fine facial detail. Square 1:1 crop. Even neutral studio lighting.",
5506
- "lighting-warm": "Front-facing head-and-shoulders portrait, square 1:1 crop, under warm golden-hour key lighting.",
5507
- "lighting-cool": "Front-facing head-and-shoulders portrait, square 1:1 crop, under cool blue-toned key lighting."
6923
+ "full-body": "FRONT VIEW, 0 degrees: full-body head-to-toe view, the person standing in a relaxed neutral pose facing directly toward the camera. Both eyes visible. Chest, hips, knees and feet facing forward. 3:4 portrait crop with the whole figure in frame, feet included.",
6924
+ "three-quarter-left": "45 DEGREE TURN TO SCREEN-LEFT: the person is rotated exactly 45 degrees toward screen-left. The nose points 45 degrees toward the left edge of the image. Both eyes visible, the far eye partly hidden by the bridge of the nose. Shoulders and chest rotated 45 degrees toward screen-left as well. The face must not turn toward screen-right. Chest-up framing, square 1:1 crop.",
6925
+ "profile-left": "90 DEGREE PROFILE FACING SCREEN-LEFT: a strict side profile, the person facing fully toward the left edge of the image. Exactly 90 degrees: only one eye visible, the nose silhouetted against the background on the left side of the face. Shoulders and chest aligned toward screen-left. The face must not turn toward screen-right or toward the camera. Chest-up framing, square 1:1 crop.",
6926
+ "profile-right": "90 DEGREE PROFILE FACING SCREEN-RIGHT: a strict side profile, the person facing fully toward the right edge of the image. Exactly 90 degrees: only one eye visible, the nose silhouetted against the background on the right side of the face. Shoulders and chest aligned toward screen-right. The face must not turn toward screen-left or toward the camera. Chest-up framing, square 1:1 crop.",
6927
+ "three-quarter-right": "45 DEGREE TURN TO SCREEN-RIGHT: the person is rotated exactly 45 degrees toward screen-right. The nose points 45 degrees toward the right edge of the image. Both eyes visible, the far eye partly hidden by the bridge of the nose. Shoulders and chest rotated 45 degrees toward screen-right as well. The face must not turn toward screen-left. Chest-up framing, square 1:1 crop.",
6928
+ back: "BACK VIEW, 180 degrees: full-body head-to-toe view of the person facing completely away from the camera. Show the back of the head and hair, the back of the clothing, the back silhouette and a rear-facing standing posture. No face visible, no eyes, no profile: the head is not turned. Heels, calves, hips and shoulders all face away from the camera. 3:4 portrait crop with the whole figure in frame, feet included."
5508
6929
  };
5509
6930
  function turnaroundViewPrompt(view, seedDescription) {
5510
6931
  return [
5511
6932
  identityAnchor(seedDescription),
5512
6933
  VIEW_INSTRUCTION[view],
6934
+ ...view === "back" ? [CHAINED_BACK_INPUTS_INSTRUCTION] : [],
6935
+ SCREEN_SIDE_INSTRUCTION,
6936
+ TURNAROUND_CAMERA_INSTRUCTION,
6937
+ // View strings mirror the freeze categories, so the wardrobe line keys off
6938
+ // the view directly (head-to-toe views add trousers and shoes).
5513
6939
  wardrobeInstructionForCategory(view),
5514
6940
  NEUTRAL_STUDIO,
5515
6941
  IDENTITY_INSTRUCTION
5516
6942
  ].join("\n\n");
5517
6943
  }
6944
+ function overviewSheetPrompt(description) {
6945
+ return [
6946
+ "Create one clean photorealistic character turnaround sheet of the person in the reference image.",
6947
+ `Character identity: ${description.trim()}`,
6948
+ `${FULL_BODY_WARDROBE_INSTRUCTION} The same outfit in every column.`,
6949
+ "Exactly six columns, no more and no fewer: six full-body figures in the top row and six portraits in the bottom row, twelve pictures of the same person in total. Never repeat a column and never add a seventh.",
6950
+ "Layout: six vertical columns of equal width side by side, separated by thin light borders, on a plain light-gray studio background. In each column, a full-body view head to toe on top, the whole figure inside its cell with the shoes and a little floor visible below them, and below it a head-and-shoulders portrait whose face points in exactly the same direction as the full body above it.",
6951
+ "The person turns step by step, the way a turnaround sheet reads, and directions are the edges of the picture as the viewer sees it. Column 1, the leftmost: facing the camera, both eyes visible. Column 2: turned halfway so the nose points toward the RIGHT EDGE of the picture, both eyes visible. Column 3: a strict side profile, the nose pointing at the RIGHT EDGE of the picture, only one eye visible. Column 4: a strict side profile, the nose pointing at the LEFT EDGE of the picture, only one eye visible. Column 5: turned halfway so the nose points toward the LEFT EDGE of the picture, both eyes visible. Column 6, the rightmost: seen from behind, no face; its portrait shows the back of the head. So the two profiles in columns 3 and 4 face each other.",
6952
+ "Same camera height for every full body, same crop for every portrait, no perspective distortion, photorealistic studio lighting, sharp detail.",
6953
+ "No text anywhere in the image: no headings, no titles, no angle numbers, no degree signs, no labels, no captions, no logos, no watermark. The background above the figures stays empty.",
6954
+ IDENTITY_INSTRUCTION
6955
+ ].join("\n\n");
6956
+ }
5518
6957
  var CHARACTER_SHEET_NODES = [
5519
6958
  { nodeId: "seed", param: "seedPrompt", category: "face", label: "Face" },
5520
- { nodeId: "view-three-quarter", param: "threeQuarterPrompt", category: "three-quarter", label: "Three-quarter", view: "three-quarter" },
5521
- { nodeId: "view-profile", param: "profilePrompt", category: "profile", label: "Profile", view: "profile" },
5522
- { nodeId: "view-full-body", param: "fullBodyPrompt", category: "full-body", label: "Full body", view: "full-body" },
5523
- { nodeId: "view-close-up", param: "closeUpPrompt", category: "close-up", label: "Close-up", view: "close-up" },
5524
- { nodeId: "view-lighting-warm", param: "lightingWarmPrompt", category: "lighting-warm", label: "Warm lighting", view: "lighting-warm" },
5525
- { nodeId: "view-lighting-cool", param: "lightingCoolPrompt", category: "lighting-cool", label: "Cool lighting", view: "lighting-cool" }
6959
+ { nodeId: "view-full-body", param: "fullBodyPrompt", category: "full-body", label: "Front", view: "full-body" },
6960
+ { nodeId: "view-three-quarter-left", param: "threeQuarterLeftPrompt", category: "three-quarter-left", label: "Turned left", view: "three-quarter-left" },
6961
+ { nodeId: "view-profile-left", param: "profileLeftPrompt", category: "profile-left", label: "Profile left", view: "profile-left" },
6962
+ { nodeId: "view-profile-right", param: "profileRightPrompt", category: "profile-right", label: "Profile right", view: "profile-right" },
6963
+ { nodeId: "view-three-quarter-right", param: "threeQuarterRightPrompt", category: "three-quarter-right", label: "Turned right", view: "three-quarter-right" },
6964
+ { nodeId: "view-back", param: "backPrompt", category: "back", label: "Back", view: "back" },
6965
+ { nodeId: "overview", param: "overviewPrompt", category: OVERVIEW_CATEGORY, label: "Overview", overview: true }
5526
6966
  ];
5527
6967
  var MINT_REFERENCE_CATEGORIES = Object.fromEntries(
5528
6968
  CHARACTER_SHEET_NODES.map((n) => [n.nodeId, n.category])
5529
6969
  );
5530
6970
  function buildCharacterSheetParams(description) {
5531
6971
  const params = {};
5532
- for (const node of CHARACTER_SHEET_NODES) {
5533
- params[node.param] = node.view ? turnaroundViewPrompt(node.view, description) : seedFacePrompt(description);
6972
+ for (const node2 of CHARACTER_SHEET_NODES) {
6973
+ params[node2.param] = node2.view ? turnaroundViewPrompt(node2.view, description) : node2.overview ? overviewSheetPrompt(description) : seedFacePrompt(description);
5534
6974
  }
5535
6975
  return params;
5536
6976
  }
5537
6977
  var CHARACTER_SHEET_ID = "character-sheet";
5538
6978
  var SEED_MODEL = "fal/nano-banana-2";
5539
6979
  var VIEW_MODEL = "fal/nano-banana-2-edit";
6980
+ var OVERVIEW_MODEL = VIEW_MODEL;
5540
6981
  function viewNode(n, aspectRatio) {
5541
6982
  return {
5542
6983
  id: n.nodeId,
@@ -5549,6 +6990,7 @@ function viewNode(n, aspectRatio) {
5549
6990
  }
5550
6991
  };
5551
6992
  }
6993
+ var node = (id) => CHARACTER_SHEET_NODES.find((n) => n.nodeId === id);
5552
6994
  var CHARACTER_SHEET_DEFINITION = {
5553
6995
  version: { schema: 1 },
5554
6996
  id: CHARACTER_SHEET_ID,
@@ -5569,16 +7011,47 @@ var CHARACTER_SHEET_DEFINITION = {
5569
7011
  aspectRatio: { kind: "literal", value: "1:1" }
5570
7012
  }
5571
7013
  },
5572
- ...CHARACTER_SHEET_NODES.filter((n) => n.view !== void 0).map(
5573
- (n) => viewNode(n, n.category === "full-body" ? "3:4" : "1:1")
5574
- )
7014
+ viewNode(node("view-full-body"), "3:4"),
7015
+ viewNode(node("view-three-quarter-left"), "1:1"),
7016
+ viewNode(node("view-profile-left"), "1:1"),
7017
+ viewNode(node("view-profile-right"), "1:1"),
7018
+ viewNode(node("view-three-quarter-right"), "1:1"),
7019
+ // The back turns the front full body round, with the seed first as its
7020
+ // identity image ([face, full body]; its prompt says which is which).
7021
+ {
7022
+ id: "view-back",
7023
+ task: "image-edit",
7024
+ model: VIEW_MODEL,
7025
+ inputs: {
7026
+ prompt: { kind: "param", name: "backPrompt" },
7027
+ inputImages: {
7028
+ kind: "list",
7029
+ items: [
7030
+ { kind: "ref", node: "seed", path: "url" },
7031
+ { kind: "ref", node: "view-full-body", path: "url" }
7032
+ ]
7033
+ },
7034
+ aspectRatio: { kind: "literal", value: "3:4" }
7035
+ }
7036
+ },
7037
+ {
7038
+ id: "overview",
7039
+ task: "image-edit",
7040
+ model: OVERVIEW_MODEL,
7041
+ inputs: {
7042
+ prompt: { kind: "param", name: "overviewPrompt" },
7043
+ inputImages: { kind: "ref", node: "seed", path: "url", wrap: "array" },
7044
+ aspectRatio: { kind: "literal", value: OVERVIEW_ASPECT_RATIO },
7045
+ imageSize: { kind: "literal", value: OVERVIEW_RESOLUTION }
7046
+ }
7047
+ }
5575
7048
  ]
5576
7049
  };
5577
7050
  function characterSheetDefinition(overrides) {
5578
7051
  const def = structuredClone(CHARACTER_SHEET_DEFINITION);
5579
7052
  if (overrides?.seedModel || overrides?.viewModel) {
5580
7053
  def.nodes = def.nodes.map(
5581
- (node) => node.id === "seed" ? { ...node, model: overrides.seedModel ?? node.model } : { ...node, model: overrides.viewModel ?? node.model }
7054
+ (node2) => node2.id === "seed" ? { ...node2, model: overrides.seedModel ?? node2.model } : { ...node2, model: overrides.viewModel ?? node2.model }
5582
7055
  );
5583
7056
  }
5584
7057
  return def;
@@ -5758,13 +7231,20 @@ function buildCharacterSwapDefinition(input) {
5758
7231
  ]
5759
7232
  };
5760
7233
  }
5761
- var CHARACTER_REFERENCE_PREFERENCE = ["full-body", "three-quarter", "face"];
7234
+ var CHARACTER_REFERENCE_PREFERENCE = [
7235
+ "full-body",
7236
+ "three-quarter-left",
7237
+ "three-quarter-right",
7238
+ "three-quarter",
7239
+ "face"
7240
+ ];
7241
+ var NEVER_AUTOMATIC = /* @__PURE__ */ new Set(["back", "overview"]);
5762
7242
  function pickCharacterReferenceUrl(references) {
5763
7243
  for (const category of CHARACTER_REFERENCE_PREFERENCE) {
5764
7244
  const hit = references.find((r) => r.category === category && typeof r.url === "string" && r.url.length > 0);
5765
7245
  if (hit) return { url: hit.url, category };
5766
7246
  }
5767
- const any = references.find((r) => typeof r.url === "string" && r.url.length > 0);
7247
+ const any = references.find((r) => typeof r.url === "string" && r.url.length > 0 && !NEVER_AUTOMATIC.has(r.category));
5768
7248
  return any ? { url: any.url, category: any.category } : null;
5769
7249
  }
5770
7250
 
@@ -5800,7 +7280,7 @@ function parseDocument(raw, what) {
5800
7280
  }
5801
7281
  return r.data;
5802
7282
  }
5803
- var OpsSchema = z6.array(OpSchema);
7283
+ var OpsSchema = z6.array(OpSchema).max(MAX_PATCH_OPS * 20);
5804
7284
  function parseOps(raw, what) {
5805
7285
  const r = OpsSchema.safeParse(raw);
5806
7286
  if (!r.success) {
@@ -5831,32 +7311,32 @@ function wireCounts(doc) {
5831
7311
  }
5832
7312
  return counts;
5833
7313
  }
5834
- function summarizeNode(node, wires) {
5835
- const base = { id: node.id, kind: node.kind, wires: { ...wires } };
5836
- if (node.label !== void 0) base.label = node.label;
5837
- switch (node.kind) {
7314
+ function summarizeNode(node2, wires) {
7315
+ const base = { id: node2.id, kind: node2.kind, wires: { ...wires } };
7316
+ if (node2.label !== void 0) base.label = node2.label;
7317
+ switch (node2.kind) {
5838
7318
  case "task":
5839
- base.task = node.task;
5840
- base.model = node.model;
5841
- base.prompt = clipText(node.prompt);
5842
- base.promptLength = node.prompt.length;
5843
- if (node.activeGeneration !== void 0) base.activeGeneration = node.activeGeneration;
7319
+ base.task = node2.task;
7320
+ base.model = node2.model;
7321
+ base.prompt = clipText(node2.prompt);
7322
+ base.promptLength = node2.prompt.length;
7323
+ if (node2.activeGeneration !== void 0) base.activeGeneration = node2.activeGeneration;
5844
7324
  break;
5845
7325
  case "prompt-source":
5846
- base.prompt = clipText(node.text);
5847
- base.promptLength = node.text.length;
7326
+ base.prompt = clipText(node2.text);
7327
+ base.promptLength = node2.text.length;
5848
7328
  break;
5849
7329
  case "image-source":
5850
- base.imageUrl = clipText(node.imageUrl);
7330
+ base.imageUrl = clipText(node2.imageUrl);
5851
7331
  break;
5852
7332
  case "video-source":
5853
- base.videoUrl = clipText(node.videoUrl);
7333
+ base.videoUrl = clipText(node2.videoUrl);
5854
7334
  break;
5855
7335
  case "input":
5856
- base.name = node.name;
5857
- base.type = node.type;
5858
- base.required = node.required;
5859
- if (node.cardinality !== void 0) base.cardinality = node.cardinality;
7336
+ base.name = node2.name;
7337
+ base.type = node2.type;
7338
+ base.required = node2.required;
7339
+ if (node2.cardinality !== void 0) base.cardinality = node2.cardinality;
5860
7340
  break;
5861
7341
  }
5862
7342
  return base;
@@ -5889,8 +7369,8 @@ function affectedNodes(doc, ids) {
5889
7369
  const wires = wireCounts(doc);
5890
7370
  const byId = new Map(doc.nodes.map((n) => [n.id, n]));
5891
7371
  return ids.map((id) => {
5892
- const node = byId.get(id);
5893
- return node ? summarizeNode(node, wires.get(id) ?? { in: 0, out: 0 }) : { id, removed: true };
7372
+ const node2 = byId.get(id);
7373
+ return node2 ? summarizeNode(node2, wires.get(id) ?? { in: 0, out: 0 }) : { id, removed: true };
5894
7374
  });
5895
7375
  }
5896
7376
 
@@ -6286,6 +7766,8 @@ var ID = /^[A-Za-z0-9_][A-Za-z0-9_.:-]{0,127}$/;
6286
7766
  var CompositionIdSchema = z22.string().regex(ID, "an id is letters, digits and _ . : -");
6287
7767
  var COLOR_ROLE = z22.string().regex(/^[a-z0-9][a-z0-9-]{0,31}$/, "a colour is named by its kit id");
6288
7768
  var unit = z22.number().min(0).max(1);
7769
+ var STUDIO_DEFAULT_FONT_ROLE = "studio-default";
7770
+ var TEXT_FONT_ROLES = [...BRAND_KIT_FONT_ROLES, STUDIO_DEFAULT_FONT_ROLE];
6289
7771
  var BoxSchema = z22.object({ x: unit, y: unit, w: z22.number().min(MIN_BOX_SIDE).max(1), h: z22.number().min(MIN_BOX_SIDE).max(1) }).strict().refine((b) => b.x + b.w <= 1 + 1e-9 && b.y + b.h <= 1 + 1e-9, "a box must stay inside the frame");
6290
7772
  var TimingShape = {
6291
7773
  start: z22.number().min(0).optional(),
@@ -6297,7 +7779,7 @@ var TextOverlaySchema = z22.object({
6297
7779
  box: BoxSchema,
6298
7780
  text: z22.string().min(1, "a text overlay needs text").max(MAX_OVERLAY_TEXT),
6299
7781
  styleRole: z22.enum(BRAND_KIT_TYPE_ROLES),
6300
- fontRole: z22.enum(BRAND_KIT_FONT_ROLES),
7782
+ fontRole: z22.enum(TEXT_FONT_ROLES),
6301
7783
  weight: z22.number().int().min(100).max(900),
6302
7784
  italic: z22.boolean(),
6303
7785
  colorRole: COLOR_ROLE,
@@ -6357,7 +7839,9 @@ var CompositionDocumentSchema = z22.object({
6357
7839
  brandSlug: z22.string().min(1).max(64),
6358
7840
  /** The kit version the document was last edited against; a newer kit is worth a look before rendering. */
6359
7841
  kitVersionAtEdit: z22.number().int().nonnegative(),
6360
- items: z22.array(ItemSchema),
7842
+ // The larger of the two kinds' item caps, checked before any item is
7843
+ // parsed; the per-kind count is enforced by the integrity check below.
7844
+ items: z22.array(ItemSchema).max(Math.max(MAX_REEL_CLIPS, MAX_CAROUSEL_SLIDES)),
6361
7845
  /** Overlays across the whole reel (a logo bug, an end card line). Always empty on a carousel. */
6362
7846
  reelOverlays: z22.array(OverlaySchema).max(MAX_OVERLAYS_PER_ITEM)
6363
7847
  }).strict();
@@ -6512,7 +7996,7 @@ var studioListAssets = defineTool({
6512
7996
  });
6513
7997
  var studioBrandKitGet = defineTool({
6514
7998
  name: "studio_brand_kit_get",
6515
- description: "Read a brand kit: the only colours (by id), type sizes (headline, body), fonts (primary, secondary, with the weights and styles each has) and logos (light, dark) a composition overlay may use. Free, read-only. Use the ids and roles it lists in studio_composition_apply ops; anything else is refused.",
7999
+ description: 'Read a brand kit: the only colours (by id), type sizes (headline, body), fonts (primary, secondary, with the weights and styles each has) and logos (light, dark) a composition overlay may use. Free, read-only. Use the ids and roles it lists in studio_composition_apply ops; anything else is refused. While the kit has no font, text uses fontRole "studio-default" (Inter, built into Studio, weight 400 or 700).',
6516
8000
  inputSchema: { brandSlug: z9.string().min(1).describe("The brand slug, as studio_create_brand made it.") },
6517
8001
  handler: async (args, ctx) => {
6518
8002
  const { kit } = await ctx.client.getBrandKit(args.brandSlug);
@@ -6546,7 +8030,7 @@ var studioCompositionDescribe = defineTool({
6546
8030
  shapes: {
6547
8031
  slide: '{ id, type: "slide", background: { assetId?, fit: "cover"|"contain", focal: { x, y }, fill? (kit colour id) }, overlays: [] } (an image asset of the project, or a fill)',
6548
8032
  clip: '{ id, type: "clip", assetId (a video asset of the project), trimIn, trimOut (seconds), overlays: [] }',
6549
- text: '{ id, type: "text", box: { x, y, w, h } (fractions of the frame), text, styleRole: "headline"|"body", fontRole: "primary"|"secondary", weight (one the font has), italic, colorRole (kit colour id), align: "left"|"center"|"right", background?: { colorRole, opacity, padding }, start?, end? (reels only) }',
8033
+ text: '{ id, type: "text", box: { x, y, w, h } (fractions of the frame), text, styleRole: "headline"|"body", fontRole: "primary"|"secondary"|"studio-default" (Inter, built into Studio, for a brand whose kit has no font yet; weights 400 and 700, no italic), weight (one the font has), italic, colorRole (kit colour id), align: "left"|"center"|"right", background?: { colorRole, opacity, padding }, start?, end? (reels only) }',
6550
8034
  logo: '{ id, type: "logo", box, variant: "light"|"dark", start?, end? }',
6551
8035
  shape: '{ id, type: "shape", box, shape: "rect"|"pill", colorRole, opacity, start?, end? }'
6552
8036
  },
@@ -7077,6 +8561,7 @@ var studioPromptsDelete = defineTool({
7077
8561
  var PROMPT_TOOLS = [studioPromptsList, studioPromptsSave, studioPromptsDelete];
7078
8562
 
7079
8563
  // src/tools.ts
8564
+ var MAX_REFERENCE_TAGS = 50;
7080
8565
  var slug = z12.string().regex(/^[a-z0-9-]+$/, "lowercase letters, numbers and hyphens only").describe("URL-safe identifier: lowercase letters, numbers, hyphens.");
7081
8566
  var waitSeconds = z12.number().int().min(1).max(3600).default(DEFAULT_TIMEOUT_MS / 1e3).describe("Maximum seconds to wait before giving up and returning the id to poll later. Default 600.");
7082
8567
  var httpUrl = z12.string().url().refine((u) => /^https?:\/\//i.test(u), "must be an http(s) URL");
@@ -7178,6 +8663,9 @@ var studioGenerateImage = defineTool({
7178
8663
  candidateCount: z12.number().int().min(1).max(4).optional().describe(
7179
8664
  "Number of candidates (1 to 4). Not every model takes a count: most KIE image models render one image whatever is asked, and a `route/...` model runs on KIE first, so expect one there too (its fal fallback may render up to four). The result carries `candidates: { requested, rendered, mayRender? }`, plus a `notice` whenever fewer will be rendered than were asked for; only rendered images are charged."
7180
8665
  ),
8666
+ variety: z12.enum(["varied", "same"]).optional().describe(
8667
+ 'With candidateCount above 1: "varied" gives each image its own pose and camera line, chosen by the Studio from a curated list of editorial poses and lenses, so the candidates are genuinely different pictures; "same" (the default) renders the prompt as written for every candidate, which on Gemini-class models gives near-identical images. Varied applies on fal models with no attached image to edit; the answer then carries `variety: "varied"`. Same price either way.'
8668
+ ),
7181
8669
  wait: z12.boolean().default(true).describe("Poll until the job finishes (default true)."),
7182
8670
  waitSeconds
7183
8671
  },
@@ -7188,6 +8676,7 @@ var studioGenerateImage = defineTool({
7188
8676
  if (args.imageSize) settings.imageSize = args.imageSize;
7189
8677
  if (args.seed !== void 0) settings.seed = args.seed;
7190
8678
  if (args.candidateCount !== void 0) settings.candidateCount = args.candidateCount;
8679
+ if (args.variety) settings.variety = args.variety;
7191
8680
  const submitted = await ctx.client.generate({
7192
8681
  ...args.brandSlug ? { brandSlug: args.brandSlug } : {},
7193
8682
  ...args.brandMode ? { brandMode: args.brandMode } : {},
@@ -7199,7 +8688,8 @@ var studioGenerateImage = defineTool({
7199
8688
  });
7200
8689
  const plan = {
7201
8690
  ...submitted.candidates ? { candidates: submitted.candidates } : {},
7202
- ...typeof submitted.notice === "string" && submitted.notice.length > 0 ? { notice: submitted.notice } : {}
8691
+ ...typeof submitted.notice === "string" && submitted.notice.length > 0 ? { notice: submitted.notice } : {},
8692
+ ...submitted.variety === "varied" ? { variety: "varied" } : {}
7203
8693
  };
7204
8694
  if (!args.wait) return { jobId: submitted.jobId, kind: submitted.kind, status: "queued", ...plan };
7205
8695
  const done = await waitForJob(ctx.client, submitted.jobId, pollOpts(ctx, args.waitSeconds));
@@ -7321,8 +8811,8 @@ var studioRig3d = defineTool({
7321
8811
  });
7322
8812
  if (!args.wait) return { runId: started.runId, status: "queued" };
7323
8813
  const run = await waitForRun(ctx.client, started.runId, pollOpts(ctx, args.waitSeconds));
7324
- const node = run.nodeRuns.find((n) => n.nodeId === "rig");
7325
- const [rig, ...clips] = node?.results ?? [];
8814
+ const node2 = run.nodeRuns.find((n) => n.nodeId === "rig");
8815
+ const [rig, ...clips] = node2?.results ?? [];
7326
8816
  if (run.run.status !== "succeeded" || !rig?.url) {
7327
8817
  const failure = runFailureSummary(run);
7328
8818
  throw new Error(`Rig run ${started.runId} ended ${run.run.status}.${failure ? ` ${failure}.` : ""} Cost so far $${runCostUsd(run).toFixed(2)}.`);
@@ -7363,7 +8853,7 @@ var studioListCharacters = defineTool({
7363
8853
  });
7364
8854
  var studioGetCharacter = defineTool({
7365
8855
  name: "studio_get_character",
7366
- description: "Fetch one character by slug with its full context: descriptor and negative prompts plus every frozen reference image (category such as face, three-quarter, profile, full-body, close-up, lighting-warm, lighting-cool; URL). The full-body or face reference URL is what studio_replace_character_in_video needs as characterImageUrl. For a character your company owns the URL is a direct image URL. For a character another company shared (owned: false) it is a Studio address: pass it unchanged as an image input to any Studio tool and the Studio resolves it when the job runs, but it is not a public image URL, and it stops working the moment the owner stops sharing.",
8856
+ description: "Fetch one character by slug with its full context: descriptor and negative prompts plus every frozen reference image (category such as face, full-body, three-quarter-left, profile-left, profile-right, three-quarter-right, back, or on a character minted before November 2026 three-quarter, profile, close-up, lighting-warm, lighting-cool; URL; the back view shows no face, so use it only for a person seen from behind). The full-body or face reference URL is what studio_replace_character_in_video needs as characterImageUrl. For a character your company owns the URL is a direct image URL. For a character another company shared (owned: false) it is a Studio address: pass it unchanged as an image input to any Studio tool and the Studio resolves it when the job runs, but it is not a public image URL, and it stops working the moment the owner stops sharing.",
7367
8857
  inputSchema: { slug },
7368
8858
  annotations: { readOnlyHint: true },
7369
8859
  handler: async (args, ctx) => {
@@ -7384,7 +8874,9 @@ var studioPromptEnhance = defineTool({
7384
8874
  name: z12.string().max(200).optional()
7385
8875
  })
7386
8876
  ).max(10).optional().describe("Every mention token of the prompt (at most 10). The returned mentions carry the names your company gave them."),
7387
- model: z12.string().optional().describe('Optional. The image or video model the prompt will be rendered with (e.g. "kie/nano-banana-2"), so the rewrite suits it. It must make the target.'),
8877
+ model: z12.string().optional().describe('Optional. The image or video model the prompt will be rendered with (e.g. "kie/nano-banana-2"), so the rewrite suits it. It must make the target. A model that always edits its first image (Ideogram 4.5 Edit) always gets an edit instruction.'),
8878
+ startFrame: z12.boolean().optional().describe("Optional, video only. True when the clip starts from an image (a start frame): the image already shows the scene, so the rewrite describes only the motion, what the subject does and how the camera moves."),
8879
+ imageAttached: z12.boolean().optional().describe("Optional, image only. True when you will send an image with the generation (a reference or the image to edit): if the prompt asks to change that image, the rewrite is one edit instruction that keeps everything else; if it asks for a new picture, a scene."),
7388
8880
  brandSlug: slug.optional().describe("Optional. A brand of your company whose style the rewrite should follow."),
7389
8881
  brandMode: z12.string().optional().describe('Optional brand mode (e.g. "hero"). Only meaningful with brandSlug.')
7390
8882
  },
@@ -7395,6 +8887,8 @@ var studioPromptEnhance = defineTool({
7395
8887
  target: args.target,
7396
8888
  ...args.mentions && args.mentions.length > 0 ? { mentions: args.mentions } : {},
7397
8889
  ...args.model ? { model: args.model } : {},
8890
+ ...args.startFrame ? { startFrame: true } : {},
8891
+ ...args.imageAttached ? { imageAttached: true } : {},
7398
8892
  ...args.brandSlug ? { brandSlug: args.brandSlug } : {},
7399
8893
  ...args.brandMode ? { brandMode: args.brandMode } : {}
7400
8894
  });
@@ -7431,7 +8925,7 @@ var studioCreateCharacter = defineTool({
7431
8925
  });
7432
8926
  var studioMintCharacter = defineTool({
7433
8927
  name: "studio_mint_character",
7434
- description: "Mint a consistent character from a text description: runs the curated character-sheet workflow (a face with fal/nano-banana-2, then six identity-pinned edits with fal/nano-banana-2-edit: three-quarter, profile, full-body, close-up, warm lighting, cool lighting), waits for it, creates the character, and uploads the 7 views as frozen references with the right categories. Returns the slug, reference count, per-view URLs, the runId and total cost (about $0.30). The description should cover face, hair, age, build and distinguishing features; wardrobe is standardized to a plain gray tee. Takes 2 to 5 minutes. Requires likenessRightsConfirmed: true, which you may only pass after the human you act for confirmed it for this character; without it the tool refuses before the run starts, so nothing is spent.",
8928
+ description: "Mint a consistent character from a text description: runs the curated character-sheet workflow (a face with fal/nano-banana-2, then six identity-pinned edits with fal/nano-banana-2-edit: front full body, turned 45 degrees to screen-left, profile facing screen-left, profile facing screen-right, turned 45 degrees to screen-right, and the back, edited from the face and the front full body; plus one overview image of all six angles at 4K, for people only, never used as a reference), waits for it, creates the character, and uploads the views as frozen references with the right categories (face, full-body, three-quarter-left, profile-left, profile-right, three-quarter-right, back) and the overview as category overview. Returns the slug, reference count, per-view URLs, the runId and total cost (about $0.72 at provider prices). If only the overview failed, the character is still created and the result says so. The description should cover face, hair, age, build and distinguishing features; wardrobe is standardized to a plain gray tee, dark trousers and dark shoes. Takes 2 to 5 minutes. Requires likenessRightsConfirmed: true, which you may only pass after the human you act for confirmed it for this character; without it the tool refuses before the run starts, so nothing is spent.",
7435
8929
  inputSchema: {
7436
8930
  projectId: z12.string().min(1).describe("Project id from studio_list_projects."),
7437
8931
  name: z12.string().min(1).describe("Display name."),
@@ -7460,7 +8954,9 @@ var studioMintCharacter = defineTool({
7460
8954
  ...args.visibility ? { visibility: args.visibility } : {}
7461
8955
  });
7462
8956
  const run = await waitForRun(ctx.client, started.runId, pollOpts(ctx, args.waitSeconds));
7463
- const views = CHARACTER_SHEET_NODES.map((n) => ({ ...n, url: nodeUrl(run, n.nodeId) }));
8957
+ const outputs = CHARACTER_SHEET_NODES.map((n) => ({ ...n, url: nodeUrl(run, n.nodeId) }));
8958
+ const views = outputs.filter((v) => !v.overview);
8959
+ const overview = outputs.find((v) => v.overview);
7464
8960
  const missing = views.filter((v) => !v.url);
7465
8961
  if (missing.length > 0) {
7466
8962
  const failure = runFailureSummary(run);
@@ -7477,7 +8973,7 @@ var studioMintCharacter = defineTool({
7477
8973
  ...args.defaultModel !== void 0 ? { defaultModel: args.defaultModel } : {}
7478
8974
  });
7479
8975
  const references = [];
7480
- for (const view of views) {
8976
+ for (const view of overview?.url ? [...views, overview] : views) {
7481
8977
  const file = await ctx.client.downloadUrl(view.url);
7482
8978
  const category = MINT_REFERENCE_CATEGORIES[view.nodeId];
7483
8979
  const { reference } = await ctx.client.uploadCharacterReference(args.slug, {
@@ -7491,8 +8987,9 @@ var studioMintCharacter = defineTool({
7491
8987
  slug: character.slug,
7492
8988
  name: character.name,
7493
8989
  runId: started.runId,
7494
- referenceCount: references.length,
8990
+ referenceCount: references.filter((r) => r.category !== OVERVIEW_CATEGORY).length,
7495
8991
  references,
8992
+ overview: overview?.url ? { made: true } : { made: false, note: "The overview image failed; the character and its seven reference images were created without it." },
7496
8993
  costUsd: runCostUsd(run)
7497
8994
  };
7498
8995
  }
@@ -7528,7 +9025,7 @@ var studioUploadBrandReference = defineTool({
7528
9025
  source: z12.string().min(1).describe("Local file path or http(s) URL of an image."),
7529
9026
  category: z12.string().optional().describe('Library category, default "general".'),
7530
9027
  label: z12.string().optional().describe("Optional file name / label."),
7531
- tags: z12.array(z12.string()).optional(),
9028
+ tags: z12.array(z12.string()).max(MAX_REFERENCE_TAGS).optional(),
7532
9029
  score: z12.number().int().min(1).max(10).optional()
7533
9030
  },
7534
9031
  handler: async (args, ctx) => {
@@ -7543,7 +9040,8 @@ var studioUploadBrandReference = defineTool({
7543
9040
  return { reference };
7544
9041
  }
7545
9042
  });
7546
- var workflowDefinitionSchema = WorkflowDefinitionSchema.describe(
9043
+ var AgentDefinitionSchema = WorkflowDefinitionSchema.extend({ nodes: z12.array(WorkflowNodeSchema.omit({ cast: true, castOwn: true, imagesWired: true })).min(1).max(MAX_DOCUMENT_NODES) });
9044
+ var workflowDefinitionSchema = AgentDefinitionSchema.describe(
7547
9045
  `Inline workflow DAG: { id, label?, params?: [{ name, type: string|number|boolean|json, required?, label?, description?, inputType?, cardinality?: one|many, default? }], nodes: [{ id, task (one of the model tasks listed), model (catalog id, e.g. fal/nano-banana-2-edit), inputs, retry? }] }. Node inputs are bindings: {kind:"literal",value}, {kind:"param",name,wrap?:"array"}, {kind:"ref",node,path:"url",wrap?:"array"} or an ordered {kind:"list",items:[...]} of those. Image-edit nodes take inputImages (an array: one wrapped ref/param, or a list in reference order, scene frame first); image-to-video nodes take inputImageUrl (start frame) and optionally endImageUrl (end frame, on models that accept one), EXCEPT on a keyframes model (fal/flux-3-keyframes-to-video and its -draft tier), which instead takes keyframeImageUrls (an ordered list of up to 10 images) with keyframeFrameIndexes (one strictly increasing frame per image on a fixed 24 fps timeline). Pass one shape or the other, never both. To hold a character's identity through the clip, an image-to-video node on a model with character references (route/kling-o3 or fal/kling-o3-pro-reference-to-video; a model pinned to KIE, kie/..., is not available for images of people and refuses a run whose node carries a character, a try-on, a swap or an uploaded or referenced image or video, so use the fal or route/ entry for those) also takes referenceImageUrls (a list of character photos, grouped by character, each character's frontal view first, 2 to 4 images per character, up to 3 characters) with referenceElementIndexes (the 0-based character of each image, ascending without gaps, e.g. [0,0,0,1,1]); they never count as the start or end frame, and they need inputImageUrl. kie/gemini-omni-flash-1-1-reference-to-video takes the same two fields with 1 to 6 character images in all and no end frame: its start frame goes in as reference image 1, named in the prompt as the exact scene and first frame, because KIE does not lock a first frame in its reference mode. It runs on KIE, so while Studio keeps people off KIE it is refused for character references like every other kie/ model.`
7548
9046
  );
7549
9047
  var studioRunWorkflow = defineTool({
@@ -7554,7 +9052,7 @@ var studioRunWorkflow = defineTool({
7554
9052
  definition: workflowDefinitionSchema.optional(),
7555
9053
  savedId: z12.string().optional().describe("Id of a saved workflow (from studio_workflow_create, studio_workflow_get or a listed run) to run instead of an inline definition. An unknown id is a 404 naming it; a workflow that is not runnable yet comes back as not_runnable with per-node issues."),
7556
9054
  params: z12.record(z12.string(), z12.unknown()).optional().describe("Values for the definition's params."),
7557
- nodeIds: z12.array(z12.string()).optional().describe("Run only this subset of nodes (requires an inline `definition` or a `savedId`)."),
9055
+ nodeIds: z12.array(z12.string()).max(MAX_DOCUMENT_NODES).optional().describe("Run only this subset of nodes (requires an inline `definition` or a `savedId`)."),
7558
9056
  upstreamGenerations: z12.record(z12.string(), z12.string()).optional().describe(
7559
9057
  'Pin WHICH generation of an upstream node feeds this subset run: { "<upstream node id>": "<node-run id>" } (the per-node `id` that studio_get_run returns). A verified pin is reused even when the planner has no matching cache key for it (an inline first batch, or a node edited and reverted), so a follow-up node wired from an earlier generation runs against exactly that image. An unknown id is refused naming the node, never silently replaced by the latest.'
7560
9058
  ),
@@ -7897,7 +9395,7 @@ function registerTools(server, base) {
7897
9395
 
7898
9396
  // src/server.ts
7899
9397
  var SERVER_NAME = "lumitra-studio";
7900
- var SERVER_VERSION = "0.18.1";
9398
+ var SERVER_VERSION = "0.22.0";
7901
9399
  function createStudioMcpServer(opts = {}) {
7902
9400
  const config = opts.config ?? resolveConfig(opts.env ?? process.env);
7903
9401
  const client = new StudioClient(config, {