@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/index.js CHANGED
@@ -622,6 +622,26 @@ var ROUTES = [
622
622
  withReferences: { "1080p": "fal/kling-o3-pro-reference-to-video" }
623
623
  }
624
624
  },
625
+ {
626
+ kind: "video",
627
+ id: "route/gemini-omni",
628
+ label: "Gemini Omni 1.1 Flash (KIE, fal fallback)",
629
+ primary: "kie/gemini-omni-flash-1-1-image-to-video",
630
+ // fal renders every length KIE does (4 to 10 s in even steps) and the same
631
+ // sizes and shapes, from the same frame fields (2026-11-03). One difference:
632
+ // fal always renders sound with the clip, so a clip that falls back has it.
633
+ fallback: { start: "fal/gemini-omni-flash-1-1-image-to-video" }
634
+ },
635
+ {
636
+ kind: "video",
637
+ id: "route/minimax-h3",
638
+ label: "MiniMax H3 (KIE, fal fallback)",
639
+ primary: "kie/minimax-h3-image-to-video",
640
+ // fal renders KIE's sizes (768P and 2K) and lengths from 5 to 15 s from the
641
+ // same frame fields (2026-11-04); KIE also renders 4 s, which fal does not,
642
+ // so a 4 s clip has no fallback. fal always renders sound with the clip.
643
+ fallback: { start: "fal/minimax-h3-image-to-video" }
644
+ },
625
645
  {
626
646
  kind: "video",
627
647
  id: "route/seedance-2-0",
@@ -921,6 +941,71 @@ var CATALOG_ENTRIES = [
921
941
  description: "ByteDance Seedream 5 Pro edit via fal, up to 10 reference images, 1K or 2K.",
922
942
  capabilities: { resolutions: ["1K", "2K"], needsImageInput: true, maxInputImages: 10 }
923
943
  },
944
+ // ── fal.ai: Ideogram 4.5 Edit, precise local edits ─────────────────────
945
+ {
946
+ id: "fal/ideogram-4-5-edit",
947
+ provider: "fal",
948
+ modality: "image",
949
+ task: "image-edit",
950
+ label: "Ideogram 4.5 Edit (fal)",
951
+ // Measured 2026-11-04 on a series of edits of one portrait: the background
952
+ // held at a structural similarity (SSIM) of 0.9999 between successive
953
+ // edits, against 0.98 for Nano Banana 2 Edit, which reframed the shot on
954
+ // the first edit. Ideogram's first edit smoothed the face a little; after
955
+ // that the face held.
956
+ 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.",
957
+ capabilities: {
958
+ // The tiers carry Ideogram's QUALITY (providers/fal.ts, `ideogramQuality`):
959
+ // 0.5K low, 1K medium (the default), 2K high. fal's very_low is not
960
+ // offered (decided 2026-11-04). Labelled as qualities
961
+ // wherever shown (`imageTierLabel`).
962
+ resolutions: ["0.5K", "1K", "2K"],
963
+ tierKind: "quality",
964
+ editsFirstImage: true,
965
+ needsImageInput: true,
966
+ maxInputImages: 5
967
+ }
968
+ },
969
+ // ── fal.ai: OpenAI GPT Image 2, text in images and exact edits ─────────
970
+ // Added 2026-11-04 (plan 2026-11-04-skool-prompting, item M2): the course
971
+ // Marlin follows names it the best model for rendering text (labels,
972
+ // packaging) and for edits that change only what was asked.
973
+ {
974
+ id: "fal/gpt-image-2",
975
+ provider: "fal",
976
+ modality: "image",
977
+ task: "text-to-image",
978
+ label: "GPT Image 2 (fal)",
979
+ 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).",
980
+ capabilities: {
981
+ // The tiers carry GPT Image 2's QUALITY (providers/fal.ts,
982
+ // `tierQuality`): 0.5K low, 1K medium (the default), 2K high. The size
983
+ // follows the shape alone (`FAL_GPT_IMAGE_2_SIZE_BY_ASPECT`).
984
+ resolutions: ["0.5K", "1K", "2K"],
985
+ tierKind: "quality",
986
+ maxInputImages: 0
987
+ }
988
+ },
989
+ {
990
+ id: "fal/gpt-image-2-edit",
991
+ provider: "fal",
992
+ modality: "image",
993
+ task: "image-edit",
994
+ label: "GPT Image 2 Edit (fal)",
995
+ 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).",
996
+ capabilities: {
997
+ resolutions: ["0.5K", "1K", "2K"],
998
+ tierKind: "quality",
999
+ // fal's `image_urls` is a plain list with no field for the image
1000
+ // edited. Studio's convention: the image to edit goes first and the
1001
+ // mention prompt names it image 1, which is what lets the composer, the
1002
+ // generate route and the canvas refuse an edit with no image before
1003
+ // anything is admitted (`editSourceHold`).
1004
+ editsFirstImage: true,
1005
+ needsImageInput: true,
1006
+ maxInputImages: 8
1007
+ }
1008
+ },
924
1009
  {
925
1010
  id: "fal/flux-1-1-pro",
926
1011
  provider: "fal",
@@ -1206,7 +1291,7 @@ var CATALOG_ENTRIES = [
1206
1291
  modality: "video",
1207
1292
  task: "image-to-video",
1208
1293
  label: "Gemini Omni 1.1 Flash (KIE)",
1209
- 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.",
1294
+ 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).",
1210
1295
  capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1211
1296
  },
1212
1297
  {
@@ -1302,6 +1387,53 @@ var CATALOG_ENTRIES = [
1302
1387
  characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 7 }
1303
1388
  }
1304
1389
  },
1390
+ {
1391
+ id: "fal/gemini-omni-flash-1-1-image-to-video",
1392
+ provider: "fal",
1393
+ modality: "video",
1394
+ task: "image-to-video",
1395
+ label: "Gemini Omni 1.1 Flash (image-to-video)",
1396
+ 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).",
1397
+ // 8 s at fal's 720p default, the length and size the KIE entry renders.
1398
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1399
+ },
1400
+ {
1401
+ id: "fal/kling-3-0-standard-image-to-video",
1402
+ provider: "fal",
1403
+ modality: "video",
1404
+ task: "image-to-video",
1405
+ label: "Kling 3.0 Standard (image-to-video)",
1406
+ 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.",
1407
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1408
+ },
1409
+ {
1410
+ id: "fal/kling-3-0-pro-image-to-video",
1411
+ provider: "fal",
1412
+ modality: "video",
1413
+ task: "image-to-video",
1414
+ label: "Kling 3.0 Pro (image-to-video)",
1415
+ 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.",
1416
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1417
+ },
1418
+ {
1419
+ id: "fal/minimax-h3-image-to-video",
1420
+ provider: "fal",
1421
+ modality: "video",
1422
+ task: "image-to-video",
1423
+ label: "MiniMax H3 (image-to-video)",
1424
+ 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).",
1425
+ // 5 s at fal's 2K default.
1426
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1427
+ },
1428
+ {
1429
+ id: "fal/kling-4-0-image-to-video",
1430
+ provider: "fal",
1431
+ modality: "video",
1432
+ task: "image-to-video",
1433
+ label: "Kling 4.0 (image-to-video)",
1434
+ 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.",
1435
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1436
+ },
1305
1437
  {
1306
1438
  id: "fal/ltx-2-5-fast-image-to-video",
1307
1439
  provider: "fal",
@@ -1418,6 +1550,37 @@ var CATALOG_ENTRIES = [
1418
1550
  // resolution, so the settings panel offers none and validation refuses one.
1419
1551
  capabilities: { needsImageInput: true, maxInputImages: 4, resolutions: [] }
1420
1552
  },
1553
+ // ── fal.ai: lip sync (face image + audio -> talking video) ─────────────
1554
+ // Inputs, limits and prices from each model's fal page, checked 2026-11-28
1555
+ // (providers/lip-sync-specs.ts holds the limits).
1556
+ {
1557
+ id: "fal/heygen-avatar-6",
1558
+ provider: "fal",
1559
+ modality: "video",
1560
+ task: "lip-sync",
1561
+ label: "HeyGen Avatar 6 (lip sync)",
1562
+ 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.",
1563
+ capabilities: { needsImageInput: true, maxInputImages: 1, resolutions: [] },
1564
+ isDefault: true
1565
+ },
1566
+ {
1567
+ id: "fal/heygen-avatar-6-turbo",
1568
+ provider: "fal",
1569
+ modality: "video",
1570
+ task: "lip-sync",
1571
+ label: "HeyGen Avatar 6 Turbo (lip sync)",
1572
+ description: "HeyGen Avatar 6 Turbo via fal: the faster variant of Avatar 6, with the same inputs.",
1573
+ capabilities: { needsImageInput: true, maxInputImages: 1, resolutions: [] }
1574
+ },
1575
+ {
1576
+ id: "fal/omnihuman-v2",
1577
+ provider: "fal",
1578
+ modality: "video",
1579
+ task: "lip-sync",
1580
+ label: "OmniHuman v2 (lip sync)",
1581
+ 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.",
1582
+ capabilities: { needsImageInput: true, maxInputImages: 1, resolutions: [] }
1583
+ },
1421
1584
  // ── fal.ai: vision + utility (B4) ──────────────────────────────────────
1422
1585
  {
1423
1586
  id: "fal/florence-2-detailed-caption",
@@ -1526,6 +1689,29 @@ var CATALOG_ENTRIES = [
1526
1689
  },
1527
1690
  isDefault: true
1528
1691
  },
1692
+ {
1693
+ id: "elevenlabs/tts-v4",
1694
+ provider: "elevenlabs",
1695
+ modality: "audio",
1696
+ task: "text-to-speech",
1697
+ label: "ElevenLabs Eleven v4 (TTS)",
1698
+ 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.",
1699
+ // Checked 2026-11-28. ElevenLabs' v4 page: two voice settings, Stability
1700
+ // and Similarity; "Style and Speed sliders are not available". The text
1701
+ // limit: its API price page says 10,000 characters per request, while
1702
+ // GET /v1/models and the models page say 100,000. Studio takes the lower
1703
+ // figure, which both accept; it is also what a voice node whose text
1704
+ // arrives at run time is held at.
1705
+ capabilities: {
1706
+ speech: {
1707
+ maxCharacters: 1e4,
1708
+ voiceSettings: {
1709
+ stability: { min: 0, max: 1, step: 0.05, default: 0.5 },
1710
+ similarityBoost: { min: 0, max: 1, step: 0.05, default: 0.75 }
1711
+ }
1712
+ }
1713
+ }
1714
+ },
1529
1715
  {
1530
1716
  id: "elevenlabs/scribe-v1",
1531
1717
  provider: "elevenlabs",
@@ -1655,6 +1841,18 @@ function routeEntry(id) {
1655
1841
  function tryGetModel(id) {
1656
1842
  return MODEL_CATALOG.find((m) => m.id === id) ?? routeEntry(id);
1657
1843
  }
1844
+ var ASPECT_RATIOS = [
1845
+ "1:1",
1846
+ "3:2",
1847
+ "2:3",
1848
+ "3:4",
1849
+ "4:3",
1850
+ "4:5",
1851
+ "5:4",
1852
+ "9:16",
1853
+ "16:9",
1854
+ "21:9"
1855
+ ];
1658
1856
  function omniReferencesPrompt(prompt, elements) {
1659
1857
  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."];
1660
1858
  let next = 2;
@@ -1978,6 +2176,15 @@ var OPENROUTER_VIDEO_SPECS = {
1978
2176
  "google/veo-3.1-fast": veoSpec2("Veo 3.1 Fast", ["720p", "1080p", "4k"]),
1979
2177
  "google/veo-3.1": veoSpec2("Veo 3.1", ["720p", "1080p", "4k"])
1980
2178
  };
2179
+ var HEYGEN_AVATAR_6_ENDPOINT = "heygen/avatar-6/image-to-video";
2180
+ var HEYGEN_AVATAR_6_TURBO_ENDPOINT = "heygen/avatar-6/turbo/image-to-video";
2181
+ var OMNIHUMAN_V2_ENDPOINT = "bytedance/omnihuman/v2";
2182
+ var LIP_SYNC_MAX_AUDIO_BYTES = 15 * 1024 * 1024;
2183
+ var LIP_SYNC_SPECS = {
2184
+ [HEYGEN_AVATAR_6_ENDPOINT]: { minSeconds: 1, maxSeconds: 300, promptField: "motion_prompt", motionExpressiveness: true },
2185
+ [HEYGEN_AVATAR_6_TURBO_ENDPOINT]: { minSeconds: 1, maxSeconds: 300, promptField: "motion_prompt", motionExpressiveness: true },
2186
+ [OMNIHUMAN_V2_ENDPOINT]: { minSeconds: 4, maxSeconds: 300, promptField: "prompt", motionExpressiveness: false }
2187
+ };
1981
2188
  var GROK_IMAGINE_I2V_ENDPOINT = "xai/grok-imagine-video/image-to-video";
1982
2189
  var GROK_IMAGINE_15_I2V_ENDPOINT = "xai/grok-imagine-video/v1.5/image-to-video";
1983
2190
  var WAN_30_I2V_ENDPOINT = "alibaba/wan-3.0/image-to-video";
@@ -1985,6 +2192,12 @@ var KLING_26_I2V_ENDPOINT = "fal-ai/kling-video/v2.6/pro/image-to-video";
1985
2192
  var KLING_O3_STANDARD_I2V_ENDPOINT = "fal-ai/kling-video/o3/standard/image-to-video";
1986
2193
  var KLING_O3_PRO_I2V_ENDPOINT = "fal-ai/kling-video/o3/pro/image-to-video";
1987
2194
  var KLING_O3_I2V_ENDPOINTS = [KLING_O3_STANDARD_I2V_ENDPOINT, KLING_O3_PRO_I2V_ENDPOINT];
2195
+ var GEMINI_OMNI_11_I2V_ENDPOINT = "google/gemini-omni-flash/v1.1/image-to-video";
2196
+ var KLING_V3_STANDARD_I2V_ENDPOINT = "fal-ai/kling-video/v3/standard/image-to-video";
2197
+ var KLING_V3_PRO_I2V_ENDPOINT = "fal-ai/kling-video/v3/pro/image-to-video";
2198
+ var KLING_V3_I2V_ENDPOINTS = [KLING_V3_STANDARD_I2V_ENDPOINT, KLING_V3_PRO_I2V_ENDPOINT];
2199
+ var KLING_V4_I2V_ENDPOINT = "kling/v4/image-to-video";
2200
+ var MINIMAX_H3_I2V_ENDPOINT = "minimax/h3/image-to-video";
1988
2201
  var KLING_O3_PRO_R2V_ENDPOINT = "fal-ai/kling-video/o3/pro/reference-to-video";
1989
2202
  var FAL_CHARACTER_REFERENCE_LIMITS = {
1990
2203
  [KLING_O3_PRO_R2V_ENDPOINT]: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 7 }
@@ -2013,12 +2226,20 @@ var VIDEO_FIXED_RESOLUTION = {
2013
2226
  "blackforestlabs/flux-3/draft-enhance": "1080p",
2014
2227
  // Not a resolution the caller picks: Kling O3 Edit renders at the source's.
2015
2228
  "fal-ai/kling-video/o3/pro/video-to-video/edit": "source",
2229
+ // Lip sync: no size knob. HeyGen is sent without one and renders its 1080p
2230
+ // default; OmniHuman v2 declares none.
2231
+ "heygen/avatar-6/image-to-video": "1080p",
2232
+ "heygen/avatar-6/turbo/image-to-video": "1080p",
2233
+ "bytedance/omnihuman/v2": "fixed",
2016
2234
  // Kling 2.6 Pro takes no resolution; it renders 1080p.
2017
2235
  [KLING_26_I2V_ENDPOINT]: "1080p",
2018
2236
  // Not a resolution the caller picks: Kling O3's tier sets the size.
2019
2237
  [KLING_O3_STANDARD_I2V_ENDPOINT]: "fixed",
2020
2238
  [KLING_O3_PRO_I2V_ENDPOINT]: "fixed",
2021
- [KLING_O3_PRO_R2V_ENDPOINT]: "fixed"
2239
+ [KLING_O3_PRO_R2V_ENDPOINT]: "fixed",
2240
+ // Kling 3.0 likewise: its tier sets the size.
2241
+ [KLING_V3_STANDARD_I2V_ENDPOINT]: "fixed",
2242
+ [KLING_V3_PRO_I2V_ENDPOINT]: "fixed"
2022
2243
  };
2023
2244
  var VIDEO_PINNED_DEFAULT_SECONDS = {
2024
2245
  [GROK_IMAGINE_I2V_ENDPOINT]: 5,
@@ -2033,6 +2254,13 @@ var VIDEO_PINNED_DEFAULT_SECONDS = {
2033
2254
  [KLING_O3_STANDARD_I2V_ENDPOINT]: 5,
2034
2255
  [KLING_O3_PRO_I2V_ENDPOINT]: 5,
2035
2256
  [KLING_O3_PRO_R2V_ENDPOINT]: 5,
2257
+ [GEMINI_OMNI_11_I2V_ENDPOINT]: 8,
2258
+ // fal's own default on Kling 3.0 and 4.0 (schemas read 2026-11-03).
2259
+ [KLING_V3_STANDARD_I2V_ENDPOINT]: 5,
2260
+ [KLING_V3_PRO_I2V_ENDPOINT]: 5,
2261
+ [KLING_V4_I2V_ENDPOINT]: 5,
2262
+ // fal's own default on MiniMax H3 (schema read 2026-11-04).
2263
+ [MINIMAX_H3_I2V_ENDPOINT]: 5,
2036
2264
  // LTX-2.5 defaults to "auto", a length nobody can price up front; 6 s is its
2037
2265
  // shortest clip on both tiers.
2038
2266
  [LTX_25_FAST_I2V_ENDPOINT]: 6,
@@ -2065,6 +2293,12 @@ var VIDEO_DEFAULT_RESOLUTION = {
2065
2293
  [GROK_IMAGINE_15_I2V_ENDPOINT]: "720p",
2066
2294
  // fal schema default: Wan 3.0 renders 1080p unless asked for less.
2067
2295
  [WAN_30_I2V_ENDPOINT]: "1080p",
2296
+ // fal schema default: Gemini Omni renders 720p, as on KIE.
2297
+ [GEMINI_OMNI_11_I2V_ENDPOINT]: "720p",
2298
+ // fal schema default: Kling 4.0 renders 1080p unless asked for 720p.
2299
+ [KLING_V4_I2V_ENDPOINT]: "1080p",
2300
+ // fal schema default: MiniMax H3 renders 2K (the canvas's 1080p) unless asked.
2301
+ [MINIMAX_H3_I2V_ENDPOINT]: "1080p",
2068
2302
  // fal schema default: LTX-2.5 renders 1080p unless asked for less.
2069
2303
  [LTX_25_FAST_I2V_ENDPOINT]: "1080p",
2070
2304
  [LTX_25_PRO_I2V_ENDPOINT]: "1080p"
@@ -2111,7 +2345,18 @@ var VIDEO_ALLOWED_VALUES = {
2111
2345
  aspectRatio: ["auto", "16:9", "9:16"],
2112
2346
  resolution: ["720p", "1080p"],
2113
2347
  durationSeconds: { values: [6, 8, 10] }
2114
- }
2348
+ },
2349
+ // fal also renders 360p, which the canvas does not offer.
2350
+ [GEMINI_OMNI_11_I2V_ENDPOINT]: {
2351
+ aspectRatio: ["16:9", "9:16"],
2352
+ resolution: ["720p", "1080p", "4k"],
2353
+ durationSeconds: { min: 3, max: 10 }
2354
+ },
2355
+ ...Object.fromEntries(KLING_V3_I2V_ENDPOINTS.map((e) => [e, { durationSeconds: { min: 3, max: 15 } }])),
2356
+ [KLING_V4_I2V_ENDPOINT]: { resolution: ["720p", "1080p"], durationSeconds: { min: 3, max: 30 } },
2357
+ // fal also renders 480P, which the canvas does not offer. Its shortest clip
2358
+ // is 5 s (KIE's is 4 s), so a 4 s job on the H3 route has no fal fallback.
2359
+ [MINIMAX_H3_I2V_ENDPOINT]: { resolution: ["720p", "1080p", "4k"], durationSeconds: { min: 5, max: 15 } }
2115
2360
  };
2116
2361
  var VIDEO_MAX_SECONDS_AT_RESOLUTION = {
2117
2362
  [LTX_25_FAST_I2V_ENDPOINT]: { "4k": 10 }
@@ -2135,6 +2380,10 @@ var VIDEO_UNSUPPORTED_PARAMS = {
2135
2380
  "generateAudio",
2136
2381
  "durationSeconds"
2137
2382
  ],
2383
+ // Lip sync: the length is the audio's, the shape the face image's.
2384
+ ...Object.fromEntries(
2385
+ Object.keys(LIP_SYNC_SPECS).map((e) => [e, ["resolution", "seed", "negativePrompt", "aspectRatio", "generateAudio", "durationSeconds"]])
2386
+ ),
2138
2387
  // Wan's output is also as long as its source; it takes resolution and seed.
2139
2388
  "fal-ai/wan/v2.2-14b/animate/replace": ["durationSeconds", "negativePrompt", "aspectRatio", "generateAudio"],
2140
2389
  "blackforestlabs/flux-3/keyframes-to-video/draft": ["resolution", "seed", "negativePrompt"],
@@ -2167,13 +2416,26 @@ var VIDEO_UNSUPPORTED_PARAMS = {
2167
2416
  ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS.map((e) => [e, ["resolution", "aspectRatio", "seed", "negativePrompt"]])),
2168
2417
  // Its tier sets the size; it takes an aspect ratio, but no seed or negative prompt.
2169
2418
  [KLING_O3_PRO_R2V_ENDPOINT]: ["resolution", "seed", "negativePrompt"],
2170
- ...Object.fromEntries(LTX_25_I2V_ENDPOINTS.map((e) => [e, ["seed", "negativePrompt"]]))
2419
+ ...Object.fromEntries(LTX_25_I2V_ENDPOINTS.map((e) => [e, ["seed", "negativePrompt"]])),
2420
+ // Its schema declares no seed, negative prompt or audio switch: it always
2421
+ // renders audio, at no extra charge.
2422
+ [GEMINI_OMNI_11_I2V_ENDPOINT]: ["seed", "negativePrompt", "generateAudio"],
2423
+ // Kling 3.0: the tier sets the size and the start frame the shape; it takes a
2424
+ // negative prompt but no seed.
2425
+ ...Object.fromEntries(KLING_V3_I2V_ENDPOINTS.map((e) => [e, ["resolution", "aspectRatio", "seed"]])),
2426
+ // Kling 4.0 follows the start frame's shape and always renders sound.
2427
+ [KLING_V4_I2V_ENDPOINT]: ["aspectRatio", "seed", "negativePrompt", "generateAudio"],
2428
+ // MiniMax H3 follows the start frame's shape and always renders sound (a 5 s
2429
+ // test render of 2026-11-04 had a video and an audio track); it takes a seed.
2430
+ [MINIMAX_H3_I2V_ENDPOINT]: ["aspectRatio", "negativePrompt", "generateAudio"]
2171
2431
  };
2172
2432
  var VIDEO_AUDIO_SWITCH = {
2173
2433
  ...Object.fromEntries(VEO_ENDPOINTS.map((e) => [e, { default: false }])),
2174
2434
  [KLING_26_I2V_ENDPOINT]: { default: false },
2175
2435
  ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS.map((e) => [e, { default: false }])),
2176
2436
  [KLING_O3_PRO_R2V_ENDPOINT]: { default: false },
2437
+ // Kling 3.0 renders sound unless sent false; Studio sends it silent unless asked.
2438
+ ...Object.fromEntries(KLING_V3_I2V_ENDPOINTS.map((e) => [e, { default: false }])),
2177
2439
  "bytedance/seedance-2.5/image-to-video": { default: true },
2178
2440
  "bytedance/seedance-2.0/image-to-video": { default: true },
2179
2441
  [WAN_30_I2V_ENDPOINT]: { default: true },
@@ -2895,6 +3157,10 @@ function searchMeshyAnimations(query, limit = 25) {
2895
3157
  }
2896
3158
  return out;
2897
3159
  }
3160
+ var IMAGE_ASPECT_RATIOS = ASPECT_RATIOS.map((value) => ({
3161
+ value,
3162
+ label: value
3163
+ }));
2898
3164
  var PORT_TYPES = ["text", "image", "video", "mask", "mesh3d", "audio", "json", "reference"];
2899
3165
  var INPUT_PORT_TYPES = PORT_TYPES.filter(
2900
3166
  (p) => p !== "mask" && p !== "reference"
@@ -2931,6 +3197,9 @@ var MODEL_TASKS = [
2931
3197
  "text-to-video",
2932
3198
  "image-to-video",
2933
3199
  "video-to-video",
3200
+ // Lip sync (2026-11-28): one face image and one audio file in, a talking
3201
+ // video as long as the audio out.
3202
+ "lip-sync",
2934
3203
  // A finishing pass over a DRAFT video: the upstream draft's cache bundle is
2935
3204
  // the only input, and the output is the full-quality render of the same take.
2936
3205
  "video-enhance",
@@ -2989,6 +3258,8 @@ var TASK_PORTS = {
2989
3258
  // Video-to-video (character replace): a source video plus ONE reference image
2990
3259
  // (the person to swap in). The two-input contract lives in the fal adapter.
2991
3260
  "video-to-video": { inputs: ["video", "image"], output: "video" },
3261
+ // Lip sync: the face image and the audio it speaks.
3262
+ "lip-sync": { inputs: ["image", "audio"], output: "video" },
2992
3263
  // Video-enhance: the upstream DRAFT video's cache bundle is the whole input.
2993
3264
  // The wire is typed 'video' so it only accepts a video node; whether that
2994
3265
  // node actually produced a draft cache is checked at run time, loudly.
@@ -3025,13 +3296,14 @@ var TASK_PORTS = {
3025
3296
  function taskPorts(task) {
3026
3297
  return TASK_PORTS[task];
3027
3298
  }
3299
+ var MAX_JSON_ARRAY_ITEMS = 1e4;
3028
3300
  var JsonValueSchema = z.lazy(
3029
3301
  () => z.union([
3030
3302
  z.string(),
3031
3303
  z.number().finite(),
3032
3304
  z.boolean(),
3033
3305
  z.null(),
3034
- z.array(JsonValueSchema),
3306
+ z.array(JsonValueSchema).max(MAX_JSON_ARRAY_ITEMS),
3035
3307
  z.record(z.string(), JsonValueSchema)
3036
3308
  ])
3037
3309
  );
@@ -3039,7 +3311,7 @@ var JsonNonNullValueSchema = z.union([
3039
3311
  z.string(),
3040
3312
  z.number().finite(),
3041
3313
  z.boolean(),
3042
- z.array(JsonValueSchema),
3314
+ z.array(JsonValueSchema).max(MAX_JSON_ARRAY_ITEMS),
3043
3315
  z.record(z.string(), JsonValueSchema)
3044
3316
  ]);
3045
3317
  function toJsonValue(value, what = "value") {
@@ -3047,6 +3319,11 @@ function toJsonValue(value, what = "value") {
3047
3319
  if (!r.success) throw new TypeError(`${what} is not a JSON value: ${r.error.issues[0]?.message ?? "invalid"}`);
3048
3320
  return r.data;
3049
3321
  }
3322
+ var MAX_DOCUMENT_NODES = 2e3;
3323
+ var MAX_DEFINITION_PARAMS = 200;
3324
+ var MAX_CAST_MEMBERS = 100;
3325
+ var MAX_CAST_SOURCES = 100;
3326
+ var MAX_LIST_BINDING_ITEMS = 500;
3050
3327
  var WORKFLOW_SCHEMA_VERSION = 1;
3051
3328
  var SchemaVersionSchema = z2.object({
3052
3329
  schema: z2.number().int().positive()
@@ -3080,7 +3357,7 @@ var ListItemBindingSchema = z2.discriminatedUnion("kind", [
3080
3357
  ]);
3081
3358
  var ListBindingSchema = z2.object({
3082
3359
  kind: z2.literal("list"),
3083
- items: z2.array(ListItemBindingSchema)
3360
+ items: z2.array(ListItemBindingSchema).max(MAX_LIST_BINDING_ITEMS)
3084
3361
  });
3085
3362
  var BindingSchema = z2.discriminatedUnion("kind", [
3086
3363
  LiteralBindingSchema,
@@ -3093,12 +3370,38 @@ var RetryPolicySchema = z2.object({
3093
3370
  maxAttempts: z2.number().int().positive(),
3094
3371
  backoffMs: z2.number().int().nonnegative()
3095
3372
  });
3373
+ var CastMemberSchema = z2.object({
3374
+ kind: z2.enum(["character", "product", "location"]),
3375
+ id: z2.string().min(1),
3376
+ name: z2.string(),
3377
+ sources: z2.array(z2.string()).max(MAX_CAST_SOURCES).optional()
3378
+ });
3096
3379
  var WorkflowNodeSchema = z2.object({
3097
3380
  id: z2.string().min(1),
3098
3381
  task: WorkflowTaskSchema,
3099
3382
  model: z2.string().min(1),
3100
3383
  inputs: z2.record(z2.string(), BindingSchema).default({}),
3101
- retry: RetryPolicySchema.optional()
3384
+ retry: RetryPolicySchema.optional(),
3385
+ /**
3386
+ * The cast the node's prompt names, in prompt order. Not a job input: the
3387
+ * executor reads it at send time to put the identity clauses Create sends
3388
+ * in front of the prompt (the reference order, the identity lock with each
3389
+ * character's description; for a clip, which element is who), and never
3390
+ * stores them in the node's prompt. Absent on a node that names no cast.
3391
+ */
3392
+ cast: z2.array(CastMemberSchema).max(MAX_CAST_MEMBERS).optional(),
3393
+ /**
3394
+ * The cast is what the node's own reference stack shows (its
3395
+ * `castReferences` setting), not mentions the canvas's prompt bar edits; a
3396
+ * fork of the run brings it back under that setting. Absent otherwise.
3397
+ */
3398
+ castOwn: z2.literal(true).optional(),
3399
+ /**
3400
+ * The node's images come from its image wire, which wins over a baked
3401
+ * stack: the cast's baked references are then not what is sent. Set with
3402
+ * `cast` only, so the executor can say which next step works.
3403
+ */
3404
+ imagesWired: z2.literal(true).optional()
3102
3405
  });
3103
3406
  var WorkflowParamSpecSchema = z2.object({
3104
3407
  name: z2.string().min(1),
@@ -3121,8 +3424,8 @@ var WorkflowDefinitionSchema = z2.object({
3121
3424
  version: SchemaVersionSchema.default({ schema: WORKFLOW_SCHEMA_VERSION }),
3122
3425
  id: z2.string().min(1),
3123
3426
  label: z2.string().optional(),
3124
- params: z2.array(WorkflowParamSpecSchema).default([]),
3125
- nodes: z2.array(WorkflowNodeSchema).min(1)
3427
+ params: z2.array(WorkflowParamSpecSchema).max(MAX_DEFINITION_PARAMS).default([]),
3428
+ nodes: z2.array(WorkflowNodeSchema).min(1).max(MAX_DOCUMENT_NODES)
3126
3429
  });
3127
3430
  function kahnOrder(ids, edges) {
3128
3431
  const indegree = /* @__PURE__ */ new Map();
@@ -3159,7 +3462,8 @@ var KeySchema = z3.string().regex(/^[A-Za-z_][A-Za-z0-9_.-]{0,63}$/, "key must b
3159
3462
  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");
3160
3463
  var LabelSchema = z3.string().max(200);
3161
3464
  var DescriptionSchema = z3.string().max(2e3);
3162
- var PromptTextSchema = z3.string().max(2e4);
3465
+ var MAX_PROMPT_TEXT_LENGTH = 2e4;
3466
+ var PromptTextSchema = z3.string().max(MAX_PROMPT_TEXT_LENGTH);
3163
3467
  var ModelIdSchema = z3.string().max(256);
3164
3468
  var UrlSchema = z3.string().max(4096);
3165
3469
  var AssetIdSchema = z3.string().max(128);
@@ -3250,7 +3554,7 @@ var DocEdgeSchema = z3.object({
3250
3554
  var DocGroupSchema = z3.object({
3251
3555
  id: IdSchema,
3252
3556
  label: LabelSchema.optional(),
3253
- nodeIds: z3.array(IdSchema).min(1)
3557
+ nodeIds: z3.array(IdSchema).min(1).max(MAX_DOCUMENT_NODES)
3254
3558
  });
3255
3559
  var EDGE_ROUTINGS = ["curved", "orthogonal"];
3256
3560
  var EdgeRoutingSchema = z3.enum(EDGE_ROUTINGS);
@@ -3268,7 +3572,7 @@ var WorkflowDocumentSchema = z3.object({
3268
3572
  schema: z3.number().int().positive(),
3269
3573
  id: IdSchema,
3270
3574
  label: LabelSchema.default(""),
3271
- nodes: z3.array(DocNodeSchema).max(2e3),
3575
+ nodes: z3.array(DocNodeSchema).max(MAX_DOCUMENT_NODES),
3272
3576
  edges: z3.array(DocEdgeSchema).max(8e3),
3273
3577
  layout: z3.record(IdSchema, PositionSchema).default({}),
3274
3578
  groups: z3.array(DocGroupSchema).max(500).default([]),
@@ -3357,6 +3661,26 @@ var ROUTES2 = [
3357
3661
  withReferences: { "1080p": "fal/kling-o3-pro-reference-to-video" }
3358
3662
  }
3359
3663
  },
3664
+ {
3665
+ kind: "video",
3666
+ id: "route/gemini-omni",
3667
+ label: "Gemini Omni 1.1 Flash (KIE, fal fallback)",
3668
+ primary: "kie/gemini-omni-flash-1-1-image-to-video",
3669
+ // fal renders every length KIE does (4 to 10 s in even steps) and the same
3670
+ // sizes and shapes, from the same frame fields (2026-11-03). One difference:
3671
+ // fal always renders sound with the clip, so a clip that falls back has it.
3672
+ fallback: { start: "fal/gemini-omni-flash-1-1-image-to-video" }
3673
+ },
3674
+ {
3675
+ kind: "video",
3676
+ id: "route/minimax-h3",
3677
+ label: "MiniMax H3 (KIE, fal fallback)",
3678
+ primary: "kie/minimax-h3-image-to-video",
3679
+ // fal renders KIE's sizes (768P and 2K) and lengths from 5 to 15 s from the
3680
+ // same frame fields (2026-11-04); KIE also renders 4 s, which fal does not,
3681
+ // so a 4 s clip has no fallback. fal always renders sound with the clip.
3682
+ fallback: { start: "fal/minimax-h3-image-to-video" }
3683
+ },
3360
3684
  {
3361
3685
  kind: "video",
3362
3686
  id: "route/seedance-2-0",
@@ -3656,6 +3980,71 @@ var CATALOG_ENTRIES2 = [
3656
3980
  description: "ByteDance Seedream 5 Pro edit via fal, up to 10 reference images, 1K or 2K.",
3657
3981
  capabilities: { resolutions: ["1K", "2K"], needsImageInput: true, maxInputImages: 10 }
3658
3982
  },
3983
+ // ── fal.ai: Ideogram 4.5 Edit, precise local edits ─────────────────────
3984
+ {
3985
+ id: "fal/ideogram-4-5-edit",
3986
+ provider: "fal",
3987
+ modality: "image",
3988
+ task: "image-edit",
3989
+ label: "Ideogram 4.5 Edit (fal)",
3990
+ // Measured 2026-11-04 on a series of edits of one portrait: the background
3991
+ // held at a structural similarity (SSIM) of 0.9999 between successive
3992
+ // edits, against 0.98 for Nano Banana 2 Edit, which reframed the shot on
3993
+ // the first edit. Ideogram's first edit smoothed the face a little; after
3994
+ // that the face held.
3995
+ 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.",
3996
+ capabilities: {
3997
+ // The tiers carry Ideogram's QUALITY (providers/fal.ts, `ideogramQuality`):
3998
+ // 0.5K low, 1K medium (the default), 2K high. fal's very_low is not
3999
+ // offered (decided 2026-11-04). Labelled as qualities
4000
+ // wherever shown (`imageTierLabel`).
4001
+ resolutions: ["0.5K", "1K", "2K"],
4002
+ tierKind: "quality",
4003
+ editsFirstImage: true,
4004
+ needsImageInput: true,
4005
+ maxInputImages: 5
4006
+ }
4007
+ },
4008
+ // ── fal.ai: OpenAI GPT Image 2, text in images and exact edits ─────────
4009
+ // Added 2026-11-04 (plan 2026-11-04-skool-prompting, item M2): the course
4010
+ // Marlin follows names it the best model for rendering text (labels,
4011
+ // packaging) and for edits that change only what was asked.
4012
+ {
4013
+ id: "fal/gpt-image-2",
4014
+ provider: "fal",
4015
+ modality: "image",
4016
+ task: "text-to-image",
4017
+ label: "GPT Image 2 (fal)",
4018
+ 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).",
4019
+ capabilities: {
4020
+ // The tiers carry GPT Image 2's QUALITY (providers/fal.ts,
4021
+ // `tierQuality`): 0.5K low, 1K medium (the default), 2K high. The size
4022
+ // follows the shape alone (`FAL_GPT_IMAGE_2_SIZE_BY_ASPECT`).
4023
+ resolutions: ["0.5K", "1K", "2K"],
4024
+ tierKind: "quality",
4025
+ maxInputImages: 0
4026
+ }
4027
+ },
4028
+ {
4029
+ id: "fal/gpt-image-2-edit",
4030
+ provider: "fal",
4031
+ modality: "image",
4032
+ task: "image-edit",
4033
+ label: "GPT Image 2 Edit (fal)",
4034
+ 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).",
4035
+ capabilities: {
4036
+ resolutions: ["0.5K", "1K", "2K"],
4037
+ tierKind: "quality",
4038
+ // fal's `image_urls` is a plain list with no field for the image
4039
+ // edited. Studio's convention: the image to edit goes first and the
4040
+ // mention prompt names it image 1, which is what lets the composer, the
4041
+ // generate route and the canvas refuse an edit with no image before
4042
+ // anything is admitted (`editSourceHold`).
4043
+ editsFirstImage: true,
4044
+ needsImageInput: true,
4045
+ maxInputImages: 8
4046
+ }
4047
+ },
3659
4048
  {
3660
4049
  id: "fal/flux-1-1-pro",
3661
4050
  provider: "fal",
@@ -3941,7 +4330,7 @@ var CATALOG_ENTRIES2 = [
3941
4330
  modality: "video",
3942
4331
  task: "image-to-video",
3943
4332
  label: "Gemini Omni 1.1 Flash (KIE)",
3944
- 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.",
4333
+ 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).",
3945
4334
  capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
3946
4335
  },
3947
4336
  {
@@ -4037,6 +4426,53 @@ var CATALOG_ENTRIES2 = [
4037
4426
  characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 7 }
4038
4427
  }
4039
4428
  },
4429
+ {
4430
+ id: "fal/gemini-omni-flash-1-1-image-to-video",
4431
+ provider: "fal",
4432
+ modality: "video",
4433
+ task: "image-to-video",
4434
+ label: "Gemini Omni 1.1 Flash (image-to-video)",
4435
+ 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).",
4436
+ // 8 s at fal's 720p default, the length and size the KIE entry renders.
4437
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
4438
+ },
4439
+ {
4440
+ id: "fal/kling-3-0-standard-image-to-video",
4441
+ provider: "fal",
4442
+ modality: "video",
4443
+ task: "image-to-video",
4444
+ label: "Kling 3.0 Standard (image-to-video)",
4445
+ 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.",
4446
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
4447
+ },
4448
+ {
4449
+ id: "fal/kling-3-0-pro-image-to-video",
4450
+ provider: "fal",
4451
+ modality: "video",
4452
+ task: "image-to-video",
4453
+ label: "Kling 3.0 Pro (image-to-video)",
4454
+ 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.",
4455
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
4456
+ },
4457
+ {
4458
+ id: "fal/minimax-h3-image-to-video",
4459
+ provider: "fal",
4460
+ modality: "video",
4461
+ task: "image-to-video",
4462
+ label: "MiniMax H3 (image-to-video)",
4463
+ 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).",
4464
+ // 5 s at fal's 2K default.
4465
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
4466
+ },
4467
+ {
4468
+ id: "fal/kling-4-0-image-to-video",
4469
+ provider: "fal",
4470
+ modality: "video",
4471
+ task: "image-to-video",
4472
+ label: "Kling 4.0 (image-to-video)",
4473
+ 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.",
4474
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
4475
+ },
4040
4476
  {
4041
4477
  id: "fal/ltx-2-5-fast-image-to-video",
4042
4478
  provider: "fal",
@@ -4153,6 +4589,37 @@ var CATALOG_ENTRIES2 = [
4153
4589
  // resolution, so the settings panel offers none and validation refuses one.
4154
4590
  capabilities: { needsImageInput: true, maxInputImages: 4, resolutions: [] }
4155
4591
  },
4592
+ // ── fal.ai: lip sync (face image + audio -> talking video) ─────────────
4593
+ // Inputs, limits and prices from each model's fal page, checked 2026-11-28
4594
+ // (providers/lip-sync-specs.ts holds the limits).
4595
+ {
4596
+ id: "fal/heygen-avatar-6",
4597
+ provider: "fal",
4598
+ modality: "video",
4599
+ task: "lip-sync",
4600
+ label: "HeyGen Avatar 6 (lip sync)",
4601
+ 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.",
4602
+ capabilities: { needsImageInput: true, maxInputImages: 1, resolutions: [] },
4603
+ isDefault: true
4604
+ },
4605
+ {
4606
+ id: "fal/heygen-avatar-6-turbo",
4607
+ provider: "fal",
4608
+ modality: "video",
4609
+ task: "lip-sync",
4610
+ label: "HeyGen Avatar 6 Turbo (lip sync)",
4611
+ description: "HeyGen Avatar 6 Turbo via fal: the faster variant of Avatar 6, with the same inputs.",
4612
+ capabilities: { needsImageInput: true, maxInputImages: 1, resolutions: [] }
4613
+ },
4614
+ {
4615
+ id: "fal/omnihuman-v2",
4616
+ provider: "fal",
4617
+ modality: "video",
4618
+ task: "lip-sync",
4619
+ label: "OmniHuman v2 (lip sync)",
4620
+ 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.",
4621
+ capabilities: { needsImageInput: true, maxInputImages: 1, resolutions: [] }
4622
+ },
4156
4623
  // ── fal.ai: vision + utility (B4) ──────────────────────────────────────
4157
4624
  {
4158
4625
  id: "fal/florence-2-detailed-caption",
@@ -4261,6 +4728,29 @@ var CATALOG_ENTRIES2 = [
4261
4728
  },
4262
4729
  isDefault: true
4263
4730
  },
4731
+ {
4732
+ id: "elevenlabs/tts-v4",
4733
+ provider: "elevenlabs",
4734
+ modality: "audio",
4735
+ task: "text-to-speech",
4736
+ label: "ElevenLabs Eleven v4 (TTS)",
4737
+ 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.",
4738
+ // Checked 2026-11-28. ElevenLabs' v4 page: two voice settings, Stability
4739
+ // and Similarity; "Style and Speed sliders are not available". The text
4740
+ // limit: its API price page says 10,000 characters per request, while
4741
+ // GET /v1/models and the models page say 100,000. Studio takes the lower
4742
+ // figure, which both accept; it is also what a voice node whose text
4743
+ // arrives at run time is held at.
4744
+ capabilities: {
4745
+ speech: {
4746
+ maxCharacters: 1e4,
4747
+ voiceSettings: {
4748
+ stability: { min: 0, max: 1, step: 0.05, default: 0.5 },
4749
+ similarityBoost: { min: 0, max: 1, step: 0.05, default: 0.75 }
4750
+ }
4751
+ }
4752
+ }
4753
+ },
4264
4754
  {
4265
4755
  id: "elevenlabs/scribe-v1",
4266
4756
  provider: "elevenlabs",
@@ -4368,6 +4858,147 @@ function withRouteNote2(entry) {
4368
4858
  return { ...entry, description: [entry.description ?? "", note, person ?? ""].filter(Boolean).join(" ").trim() };
4369
4859
  }
4370
4860
  var MODEL_CATALOG2 = CATALOG_ENTRIES2.map(withRouteNote2);
4861
+ var PROVIDER_API_NAMES = {
4862
+ "vertex/gemini-2-5-flash-image": "gemini-2.5-flash-image",
4863
+ "vertex/gemini-3-pro-image-preview": "gemini-3-pro-image-preview",
4864
+ "vertex/gemini-3-1-flash-image-preview": "gemini-3.1-flash-image-preview",
4865
+ "kie/nano-banana-2": "nano-banana-2",
4866
+ "kie/nano-banana-2-edit": "nano-banana-2",
4867
+ "kie/nano-banana-pro": "nano-banana-pro",
4868
+ "kie/nano-banana-pro-edit": "nano-banana-pro",
4869
+ "kie/seedream-5-lite": "seedream/5-lite-text-to-image",
4870
+ "kie/seedream-5-lite-edit": "seedream/5-lite-image-to-image",
4871
+ "kie/seedream-5-pro": "seedream/5-pro-text-to-image",
4872
+ "kie/seedream-5-pro-edit": "seedream/5-pro-image-to-image",
4873
+ "kie/imagen-4-fast": "google/imagen4-fast",
4874
+ "kie/seedream-v4": "bytedance/seedream-v4-text-to-image",
4875
+ // fal endpoint ids. The provider auto-routes nano-banana-2 to the `/edit`
4876
+ // variant when inputImages are present; both -edit and -edit-i2i catalog
4877
+ // entries share the same upstream id.
4878
+ "fal/nano-banana-2": "fal-ai/nano-banana-2",
4879
+ "fal/nano-banana-pro": "fal-ai/nano-banana-pro",
4880
+ "fal/nano-banana-pro-edit": "fal-ai/nano-banana-pro/edit",
4881
+ "fal/seedream-5-lite": "fal-ai/bytedance/seedream/v5/lite/text-to-image",
4882
+ "fal/seedream-5-lite-edit": "fal-ai/bytedance/seedream/v5/lite/edit",
4883
+ "fal/seedream-5-pro": "bytedance/seedream/v5/pro/text-to-image",
4884
+ "fal/seedream-5-pro-edit": "bytedance/seedream/v5/pro/edit",
4885
+ "fal/nano-banana-2-edit": "fal-ai/nano-banana-2/edit",
4886
+ // No fal-ai prefix: owner `ideogram`, alias `v4.5`, path `edit`.
4887
+ "fal/ideogram-4-5-edit": "ideogram/v4.5/edit",
4888
+ // No fal-ai prefix: owner `openai`. `fal-ai/gpt-image-2` is an alias of the
4889
+ // same model; the edit is `/edit` (there is no `image-to-image` path).
4890
+ "fal/gpt-image-2": "openai/gpt-image-2",
4891
+ "fal/gpt-image-2-edit": "openai/gpt-image-2/edit",
4892
+ "fal/nano-banana-2-edit-i2i": "fal-ai/nano-banana-2/edit",
4893
+ "fal/flux-1-1-pro": "fal-ai/flux-pro/v1.1",
4894
+ "fal/flux-schnell": "fal-ai/flux/schnell",
4895
+ "fal/flux-kontext-pro": "fal-ai/flux-pro/kontext",
4896
+ // fal virtual try-on endpoint (E3). Sync via subscribe (submit+poll wrapped).
4897
+ "fal/fashn-tryon-v1-6": "fal-ai/fashn/tryon/v1.6",
4898
+ // fal video endpoints (B1). Async via the queue API.
4899
+ "fal/kling-v2-5-image-to-video": "fal-ai/kling-video/v2.5-turbo/pro/image-to-video",
4900
+ "fal/seedance-pro-image-to-video": "fal-ai/bytedance/seedance/v1/pro/image-to-video",
4901
+ // Seedance 2.x ids carry no `fal-ai/` prefix and are nested (owner/alias/path),
4902
+ // like the Wan entry above; the fal SDK derives queue URLs from owner/alias.
4903
+ "fal/seedance-2-5-image-to-video": "bytedance/seedance-2.5/image-to-video",
4904
+ "fal/seedance-2-0-image-to-video": "bytedance/seedance-2.0/image-to-video",
4905
+ "fal/seedance-pro-text-to-video": "fal-ai/bytedance/seedance/v1/pro/text-to-video",
4906
+ // Grok Imagine: nested id, the SDK derives owner/alias itself.
4907
+ "fal/grok-imagine-image-to-video": "xai/grok-imagine-video/image-to-video",
4908
+ // KIE video: the upstream KIE model ids (providers/kie-video.ts).
4909
+ "kie/veo-3-1-lite": "veo3_lite",
4910
+ "kie/veo-3-1-fast": "veo3_fast",
4911
+ "kie/veo-3-1": "veo3",
4912
+ "kie/grok-imagine-image-to-video": "grok-imagine/image-to-video",
4913
+ "kie/grok-imagine-1-5-image-to-video": "grok-imagine-video-1-5-preview",
4914
+ "kie/kling-v2-5-turbo-pro-image-to-video": "kling/v2-5-turbo-image-to-video-pro",
4915
+ "kie/kling-2-6-image-to-video": "kling-2.6/image-to-video",
4916
+ "kie/seedance-2-0-image-to-video": "bytedance/seedance-2",
4917
+ "kie/seedance-2-5-image-to-video": "bytedance/seedance-2-5",
4918
+ "kie/wan-3-0-image-to-video": "wan/3-0-video",
4919
+ "kie/minimax-h3-image-to-video": "minimax-h3/image-to-video",
4920
+ "kie/gemini-omni-flash-1-1-image-to-video": "google/gemini-omni-flash-1-1",
4921
+ // The same KIE model in its reference mode: a spec key of its own, sent to
4922
+ // KIE as `google/gemini-omni-flash-1-1` (`KieVideoSpec.upstreamModel`).
4923
+ "kie/gemini-omni-flash-1-1-reference-to-video": "google/gemini-omni-flash-1-1/references",
4924
+ "kie/kling-o3-image-to-video": "kling-3.0-omni/image-to-video",
4925
+ // OpenRouter video: the OpenRouter model ids (providers/openrouter-video.ts).
4926
+ "openrouter/veo-3-1-lite": "google/veo-3.1-lite",
4927
+ "openrouter/veo-3-1-fast": "google/veo-3.1-fast",
4928
+ "openrouter/veo-3-1": "google/veo-3.1",
4929
+ // The fal twins of KIE-only models.
4930
+ "fal/grok-imagine-1-5-image-to-video": "xai/grok-imagine-video/v1.5/image-to-video",
4931
+ "fal/wan-3-0-image-to-video": "alibaba/wan-3.0/image-to-video",
4932
+ "fal/kling-2-6-image-to-video": "fal-ai/kling-video/v2.6/pro/image-to-video",
4933
+ "fal/kling-o3-standard-image-to-video": "fal-ai/kling-video/o3/standard/image-to-video",
4934
+ "fal/kling-o3-pro-image-to-video": "fal-ai/kling-video/o3/pro/image-to-video",
4935
+ "fal/kling-o3-pro-reference-to-video": "fal-ai/kling-video/o3/pro/reference-to-video",
4936
+ "fal/gemini-omni-flash-1-1-image-to-video": "google/gemini-omni-flash/v1.1/image-to-video",
4937
+ "fal/kling-3-0-standard-image-to-video": "fal-ai/kling-video/v3/standard/image-to-video",
4938
+ "fal/kling-3-0-pro-image-to-video": "fal-ai/kling-video/v3/pro/image-to-video",
4939
+ "fal/kling-4-0-image-to-video": "kling/v4/image-to-video",
4940
+ "fal/minimax-h3-image-to-video": "minimax/h3/image-to-video",
4941
+ // Lightricks LTX-2.5: nested ids, the SDK derives owner/alias itself.
4942
+ "fal/ltx-2-5-fast-image-to-video": "lightricks/ltx-2.5/image-to-video/fast",
4943
+ "fal/ltx-2-5-pro-image-to-video": "lightricks/ltx-2.5/image-to-video/pro",
4944
+ // Google Veo 3.1: nested ids, the SDK derives owner/alias itself.
4945
+ "fal/veo-3-1-lite-image-to-video": "fal-ai/veo3.1/lite/image-to-video",
4946
+ "fal/veo-3-1-lite-first-last-frame": "fal-ai/veo3.1/lite/first-last-frame-to-video",
4947
+ "fal/veo-3-1-fast-image-to-video": "fal-ai/veo3.1/fast/image-to-video",
4948
+ "fal/veo-3-1-fast-first-last-frame": "fal-ai/veo3.1/fast/first-last-frame-to-video",
4949
+ "fal/veo-3-1-image-to-video": "fal-ai/veo3.1/image-to-video",
4950
+ "fal/veo-3-1-first-last-frame": "fal-ai/veo3.1/first-last-frame-to-video",
4951
+ // FLUX.3 draft endpoints. Nested ids without the `fal-ai/` prefix, like Seedance 2.x.
4952
+ "fal/flux-3-image-to-video-draft": "blackforestlabs/flux-3/image-to-video/draft",
4953
+ "fal/flux-3-first-last-frame-to-video-draft": "blackforestlabs/flux-3/first-last-frame-to-video/draft",
4954
+ "fal/flux-3-keyframes-to-video-draft": "blackforestlabs/flux-3/keyframes-to-video/draft",
4955
+ "fal/flux-3-image-to-video": "blackforestlabs/flux-3/image-to-video",
4956
+ "fal/flux-3-first-last-frame-to-video": "blackforestlabs/flux-3/first-last-frame-to-video",
4957
+ "fal/flux-3-keyframes-to-video": "blackforestlabs/flux-3/keyframes-to-video",
4958
+ "fal/flux-3-draft-enhance": "blackforestlabs/flux-3/draft-enhance",
4959
+ // fal video-to-video (Wan 2.2 Animate Replace). Nested endpoint id: the queue
4960
+ // status / result URLs use only `fal-ai/wan` (owner/alias), which the fal SDK
4961
+ // derives itself (parseEndpointId); submit takes the full id.
4962
+ "fal/wan-animate-replace": "fal-ai/wan/v2.2-14b/animate/replace",
4963
+ "fal/heygen-avatar-6": "heygen/avatar-6/image-to-video",
4964
+ "fal/heygen-avatar-6-turbo": "heygen/avatar-6/turbo/image-to-video",
4965
+ "fal/omnihuman-v2": "bytedance/omnihuman/v2",
4966
+ // Kling O3 Pro Edit: nested id like Wan's, the SDK derives owner/alias itself.
4967
+ "fal/kling-o3-edit": "fal-ai/kling-video/o3/pro/video-to-video/edit",
4968
+ // fal vision + utility endpoints (B4). Sync via subscribe.
4969
+ "fal/florence-2-detailed-caption": "fal-ai/florence-2-large/detailed-caption",
4970
+ "fal/moondream-next-vqa": "fal-ai/moondream-next",
4971
+ // Judge (P3): same underlying endpoint as the entry above. Not dispatched
4972
+ // yet: a judge node parks the run on a person (J2) and does not call a model
4973
+ // until J5 wires the ranking. Mapped now so J5 needs no catalog change.
4974
+ "fal/moondream-next-vqa-judge": "fal-ai/moondream-next",
4975
+ "fal/meshy-rigging": "fal-ai/meshy/rigging",
4976
+ "fal/aura-sr-upscale": "fal-ai/aura-sr",
4977
+ "fal/birefnet-v2-background-remove": "fal-ai/birefnet/v2",
4978
+ // audio: Suno music via KIE (B2). The upstream `model` field KIE expects on
4979
+ // its Suno job API ("V5"), distinct from the dashed catalog id.
4980
+ "kie/suno-v5": "V5",
4981
+ // audio: ElevenLabs voice (B2). The upstream model_id the ElevenLabs API
4982
+ // expects on the TTS / STT endpoints.
4983
+ "elevenlabs/tts-multilingual-v2": "eleven_multilingual_v2",
4984
+ "elevenlabs/tts-v4": "eleven_v4",
4985
+ "elevenlabs/scribe-v1": "scribe_v1",
4986
+ // text: LLM director (B3). KIE-Claude expects the bare Anthropic model id on
4987
+ // its Messages endpoint; OpenRouter expects the provider-prefixed id.
4988
+ "kie/claude-sonnet-4-5": "claude-sonnet-4-5",
4989
+ "kie/claude-opus-4-5": "claude-opus-4-5",
4990
+ "openrouter/claude-sonnet-4-6": "anthropic/claude-sonnet-4-6",
4991
+ "openrouter/gpt-6-astra": "openai/gpt-6-astra",
4992
+ "openrouter/claude-opus-5-5": "anthropic/claude-opus-5.5"
4993
+ };
4994
+ function getProviderModelName(id) {
4995
+ const route = getRoute2(id);
4996
+ if (route) return getProviderModelName(route.primary);
4997
+ const mapped = PROVIDER_API_NAMES[id];
4998
+ if (mapped) return mapped;
4999
+ const slashIdx = id.indexOf("/");
5000
+ return slashIdx === -1 ? id : id.slice(slashIdx + 1);
5001
+ }
4371
5002
  var routeEntries2 = /* @__PURE__ */ new Map();
4372
5003
  function routeEntry2(id) {
4373
5004
  const cached = routeEntries2.get(id);
@@ -4390,6 +5021,24 @@ function routeEntry2(id) {
4390
5021
  function tryGetModel2(id) {
4391
5022
  return MODEL_CATALOG2.find((m) => m.id === id) ?? routeEntry2(id);
4392
5023
  }
5024
+ var IMAGE_SIZE_OF_TIER = {
5025
+ "0.5K": "512px",
5026
+ "1K": "1K",
5027
+ "2K": "2K",
5028
+ "4K": "4K"
5029
+ };
5030
+ var IMAGE_QUALITY_LABEL_OF_TIER = {
5031
+ "0.5K": "Low",
5032
+ "1K": "Medium",
5033
+ "2K": "High",
5034
+ // No quality model declares 4K today; named as fal names the step above high.
5035
+ "4K": "Very high"
5036
+ };
5037
+ function imageTierLabel(model, value) {
5038
+ const tier = imageResolutionTier(value);
5039
+ if (!tier) return value;
5040
+ return model?.capabilities?.tierKind === "quality" ? IMAGE_QUALITY_LABEL_OF_TIER[tier] : IMAGE_SIZE_OF_TIER[tier];
5041
+ }
4393
5042
  function imageResolutionTier(value) {
4394
5043
  if (typeof value !== "string") return null;
4395
5044
  switch (value.trim().toLowerCase()) {
@@ -4407,61 +5056,743 @@ function imageResolutionTier(value) {
4407
5056
  return null;
4408
5057
  }
4409
5058
  }
4410
- function supportedResolutions(model) {
4411
- const declared = model?.capabilities?.resolutions;
4412
- return declared ? declared : null;
4413
- }
4414
- function resolutionRefusal(model, resolution) {
4415
- if (resolution === void 0 || resolution === null || resolution === "") return null;
4416
- const supported = supportedResolutions(model);
4417
- if (!model || supported === null) return null;
4418
- const name = model.label ?? model.id;
4419
- if (supported.length === 0) {
4420
- 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.`;
5059
+ var ASPECT_RATIOS2 = [
5060
+ "1:1",
5061
+ "3:2",
5062
+ "2:3",
5063
+ "3:4",
5064
+ "4:3",
5065
+ "4:5",
5066
+ "5:4",
5067
+ "9:16",
5068
+ "16:9",
5069
+ "21:9"
5070
+ ];
5071
+ function omniReferencesPrompt2(prompt, elements) {
5072
+ 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."];
5073
+ let next = 2;
5074
+ for (const [i, e] of elements.entries()) {
5075
+ const count2 = 1 + e.referenceImageUrls.length;
5076
+ const span = count2 === 1 ? `Image ${next} shows` : `Images ${next} to ${next + count2 - 1} show`;
5077
+ parts.push(
5078
+ `${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.`
5079
+ );
5080
+ next += count2;
4421
5081
  }
4422
- const tier = imageResolutionTier(resolution);
4423
- if (tier && supported.includes(tier)) return null;
4424
- return `${name} renders at ${supported.join(", ")}, not "${String(resolution)}". Pick one of those.`;
4425
- }
4426
- var PROMPT_REQUIRED = /* @__PURE__ */ new Set([
4427
- "text-to-image",
4428
- "image-to-image",
4429
- "image-edit",
4430
- "text-to-3d",
4431
- "image-to-3d",
4432
- "multiview-to-3d",
4433
- "text-to-video",
4434
- // Texture: 3D AI Studio refuses a texture request without a prompt or a
4435
- // reference image (probed 2026-09-26), and Studio sends no reference image,
4436
- // so the material description is required. It binds `texturePrompt`, see
4437
- // `promptInputKey`.
4438
- "texture",
4439
- // Audio is prompt-only: a music description (text-to-audio) / the text to
4440
- // speak (text-to-speech). No upstream wire, so no portBinding entry.
4441
- "text-to-audio",
4442
- "text-to-speech"
4443
- ]);
4444
- var PROMPT_OPTIONAL = /* @__PURE__ */ new Set(["image-to-video", "image-to-json", "video-to-video"]);
4445
- function taskNeedsPrompt(task) {
4446
- return PROMPT_REQUIRED.has(task) || PROMPT_OPTIONAL.has(task);
4447
- }
4448
- function taskRequiresPrompt(task) {
4449
- return PROMPT_REQUIRED.has(task);
4450
- }
4451
- function promptInputKey(task) {
4452
- return task === "texture" ? "texturePrompt" : "prompt";
5082
+ const text = prompt?.trim() ?? "";
5083
+ return text ? `${parts.join(" ")} ${text}` : parts.join(" ");
4453
5084
  }
4454
- function portBinding(task, port) {
4455
- if (port === "image" && (task === "image-to-3d" || task === "multiview-to-3d" || task === "image-to-video" || task === "image-to-text" || task === "image-to-json")) {
4456
- return { key: "inputImageUrl", path: "url" };
4457
- }
4458
- if (port === "reference" && task === "image-to-video") {
4459
- return { key: "referenceImageUrls", path: "url", wrap: "array" };
4460
- }
4461
- if (port === "mesh3d" && (task === "remesh" || task === "texture" || task === "rig")) {
4462
- return { key: "parentAssetId", path: "assetId" };
4463
- }
4464
- if (port === "video" && task === "video-to-text") {
5085
+ var OMNI_MAX_REFERENCE_IMAGES2 = 7;
5086
+ function veoSpec3(model, label) {
5087
+ return {
5088
+ family: "veo",
5089
+ label,
5090
+ endFrame: true,
5091
+ aspectRatios: ["auto", "16:9", "9:16"],
5092
+ resolutions: ["720p", "1080p", "4k"],
5093
+ durations: { values: [4, 6, 8] },
5094
+ defaultSeconds: 8,
5095
+ defaultResolution: "720p",
5096
+ audioSwitch: false,
5097
+ defaultAudio: true,
5098
+ build: (i) => ({
5099
+ prompt: i.prompt,
5100
+ model,
5101
+ imageUrls: i.end ? [i.start, i.end] : [i.start],
5102
+ // KIE's "Auto" letterboxed a 4:3 still into 16:9 on 2026-09-23; an explicit
5103
+ // ratio is honoured, so only auto maps to KIE's own word for it.
5104
+ ...i.aspectRatio ? { aspect_ratio: i.aspectRatio === "auto" ? "Auto" : i.aspectRatio } : {},
5105
+ resolution: i.resolution,
5106
+ duration: i.seconds
5107
+ })
5108
+ };
5109
+ }
5110
+ var SEEDANCE_ASPECTS2 = ["auto", "1:1", "4:3", "3:4", "16:9", "9:16", "21:9"];
5111
+ var seedanceAspect2 = (a) => a === "auto" ? "adaptive" : a;
5112
+ var KIE_VIDEO_SPECS2 = {
5113
+ veo3_lite: veoSpec3("veo3_lite", "Veo 3.1 Lite"),
5114
+ veo3_fast: veoSpec3("veo3_fast", "Veo 3.1 Fast"),
5115
+ veo3: veoSpec3("veo3", "Veo 3.1"),
5116
+ "grok-imagine/image-to-video": {
5117
+ family: "job",
5118
+ label: "Grok Imagine",
5119
+ endFrame: false,
5120
+ resolutions: ["480p", "720p", "1080p"],
5121
+ durations: { min: 6, max: 30 },
5122
+ defaultSeconds: 6,
5123
+ defaultResolution: "720p",
5124
+ // Not a contradiction with the catalog saying Grok renders with audio: xAI
5125
+ // always renders audio and KIE exposes no switch for it. `defaultAudio`
5126
+ // here only feeds `price()`, which ignores it, so it states no audio fact.
5127
+ audioSwitch: false,
5128
+ defaultAudio: false,
5129
+ build: (i) => ({
5130
+ image_urls: [i.start],
5131
+ prompt: i.prompt,
5132
+ mode: "normal",
5133
+ duration: String(i.seconds),
5134
+ resolution: i.resolution,
5135
+ nsfw_checker: true
5136
+ })
5137
+ },
5138
+ "grok-imagine-video-1-5-preview": {
5139
+ family: "job",
5140
+ label: "Grok Imagine 1.5",
5141
+ endFrame: false,
5142
+ // KIE lists no 1080p price for 1.5, so 1080p is not offered.
5143
+ resolutions: ["480p", "720p"],
5144
+ durations: { min: 1, max: 15 },
5145
+ defaultSeconds: 8,
5146
+ defaultResolution: "720p",
5147
+ // As for Grok Imagine 1.0 above: audio is always rendered, with no switch.
5148
+ audioSwitch: false,
5149
+ defaultAudio: false,
5150
+ build: (i) => ({
5151
+ image_urls: [i.start],
5152
+ prompt: i.prompt,
5153
+ duration: i.seconds,
5154
+ resolution: i.resolution,
5155
+ nsfw_checker: true
5156
+ })
5157
+ },
5158
+ "kling/v2-5-turbo-image-to-video-pro": {
5159
+ family: "job",
5160
+ label: "Kling 2.5 Turbo Pro",
5161
+ endFrame: true,
5162
+ resolutions: [],
5163
+ durations: { values: [5, 10] },
5164
+ defaultSeconds: 5,
5165
+ defaultResolution: "",
5166
+ audioSwitch: false,
5167
+ defaultAudio: false,
5168
+ build: (i) => ({
5169
+ prompt: i.prompt,
5170
+ image_url: i.start,
5171
+ ...i.end ? { tail_image_url: i.end } : {},
5172
+ duration: String(i.seconds),
5173
+ ...i.negativePrompt ? { negative_prompt: i.negativePrompt } : {}
5174
+ })
5175
+ },
5176
+ "kling-2.6/image-to-video": {
5177
+ family: "job",
5178
+ label: "Kling 2.6",
5179
+ endFrame: false,
5180
+ resolutions: [],
5181
+ durations: { values: [5, 10] },
5182
+ defaultSeconds: 5,
5183
+ defaultResolution: "",
5184
+ audioSwitch: true,
5185
+ defaultAudio: false,
5186
+ build: (i) => ({
5187
+ prompt: i.prompt,
5188
+ image_urls: [i.start],
5189
+ sound: i.audio,
5190
+ duration: String(i.seconds)
5191
+ })
5192
+ },
5193
+ "bytedance/seedance-2": {
5194
+ family: "job",
5195
+ label: "Seedance 2.0",
5196
+ endFrame: true,
5197
+ aspectRatios: SEEDANCE_ASPECTS2,
5198
+ resolutions: ["480p", "720p", "1080p", "4k"],
5199
+ durations: { min: 4, max: 15 },
5200
+ defaultSeconds: 5,
5201
+ defaultResolution: "720p",
5202
+ audioSwitch: true,
5203
+ defaultAudio: true,
5204
+ build: (i) => ({
5205
+ prompt: i.prompt,
5206
+ first_frame_url: i.start,
5207
+ ...i.end ? { last_frame_url: i.end } : {},
5208
+ generate_audio: i.audio,
5209
+ resolution: i.resolution,
5210
+ ...i.aspectRatio ? { aspect_ratio: seedanceAspect2(i.aspectRatio) } : {},
5211
+ duration: i.seconds,
5212
+ nsfw_checker: true
5213
+ })
5214
+ },
5215
+ "bytedance/seedance-2-5": {
5216
+ family: "job",
5217
+ label: "Seedance 2.5",
5218
+ endFrame: true,
5219
+ aspectRatios: SEEDANCE_ASPECTS2,
5220
+ resolutions: ["480p", "720p", "1080p"],
5221
+ durations: { min: 4, max: 30 },
5222
+ defaultSeconds: 5,
5223
+ defaultResolution: "720p",
5224
+ audioSwitch: true,
5225
+ defaultAudio: true,
5226
+ build: (i) => ({
5227
+ prompt: i.prompt,
5228
+ first_frame_url: i.start,
5229
+ ...i.end ? { last_frame_url: i.end } : {},
5230
+ generate_audio: i.audio,
5231
+ resolution: i.resolution,
5232
+ ...i.aspectRatio ? { aspect_ratio: seedanceAspect2(i.aspectRatio) } : {},
5233
+ duration: i.seconds,
5234
+ nsfw_checker: true
5235
+ })
5236
+ },
5237
+ "wan/3-0-video": {
5238
+ family: "job",
5239
+ label: "Wan 3.0",
5240
+ endFrame: true,
5241
+ aspectRatios: ["auto", "16:9", "4:3", "1:1", "3:4", "9:16"],
5242
+ resolutions: ["480p", "720p", "1080p"],
5243
+ durations: { min: 2, max: 30 },
5244
+ defaultSeconds: 5,
5245
+ defaultResolution: "720p",
5246
+ audioSwitch: true,
5247
+ defaultAudio: true,
5248
+ build: (i) => ({
5249
+ prompt: i.prompt,
5250
+ first_frame_url: i.start,
5251
+ ...i.end ? { last_frame_url: i.end } : {},
5252
+ resolution: i.resolution.toUpperCase(),
5253
+ ...i.aspectRatio ? { aspect_ratio: i.aspectRatio === "auto" ? "adaptive" : i.aspectRatio } : {},
5254
+ duration: i.seconds,
5255
+ audio: i.audio,
5256
+ ...i.seed !== void 0 ? { seed: i.seed } : {},
5257
+ nsfw_checker: true
5258
+ })
5259
+ },
5260
+ "minimax-h3/image-to-video": {
5261
+ family: "job",
5262
+ label: "MiniMax H3",
5263
+ endFrame: true,
5264
+ // KIE renders 768P or 2K; the canvas's 720p and 1080p map onto them.
5265
+ resolutions: ["720p", "1080p"],
5266
+ durations: { min: 4, max: 15 },
5267
+ defaultSeconds: 6,
5268
+ defaultResolution: "720p",
5269
+ audioSwitch: false,
5270
+ defaultAudio: false,
5271
+ build: (i) => ({
5272
+ prompt: i.prompt,
5273
+ first_frame_url: i.start,
5274
+ ...i.end ? { last_frame_url: i.end } : {},
5275
+ duration: i.seconds,
5276
+ resolution: i.resolution === "1080p" ? "2K" : "768P"
5277
+ })
5278
+ },
5279
+ "google/gemini-omni-flash-1-1": {
5280
+ family: "job",
5281
+ label: "Gemini Omni 1.1 Flash",
5282
+ endFrame: true,
5283
+ aspectRatios: ["16:9", "9:16"],
5284
+ // KIE also renders 360p; the canvas offers none below 480p.
5285
+ resolutions: ["720p", "1080p", "4k"],
5286
+ durations: { values: [4, 6, 8, 10] },
5287
+ defaultSeconds: 8,
5288
+ defaultResolution: "720p",
5289
+ audioSwitch: false,
5290
+ defaultAudio: false,
5291
+ // The first-and-last-frame mode: KIE refuses it combined with registered
5292
+ // characters, reference images, audio or video, so none are sent.
5293
+ build: (i) => ({
5294
+ prompt: i.prompt,
5295
+ first_frame_url: i.start,
5296
+ ...i.end ? { last_frame_url: i.end } : {},
5297
+ duration: String(i.seconds),
5298
+ resolution: i.resolution,
5299
+ ...i.aspectRatio ? { aspect_ratio: i.aspectRatio } : {},
5300
+ ...i.seed !== void 0 ? { seed: i.seed } : {}
5301
+ })
5302
+ },
5303
+ // Gemini Omni 1.1 Flash in its REFERENCE mode: up to seven `image_urls`
5304
+ // ("Multiple reference images can be uploaded to provide references for
5305
+ // characters, scenes, styles, or storyboards"; "Maximum of 7 images"), and
5306
+ // no locked first frame, because KIE makes `first_frame_url` "mutually
5307
+ // exclusive with `image_urls`" (docs.kie.ai, read 2026-10-24). The start
5308
+ // keyframe goes first among the images and the prompt names it the exact
5309
+ // scene and first frame (`omniReferencesPrompt`); each character's views
5310
+ // follow. Same model, same price as the first-frame mode.
5311
+ "google/gemini-omni-flash-1-1/references": {
5312
+ family: "job",
5313
+ label: "Gemini Omni 1.1 Flash with references",
5314
+ upstreamModel: "google/gemini-omni-flash-1-1",
5315
+ endFrame: false,
5316
+ aspectRatios: ["16:9", "9:16"],
5317
+ resolutions: ["720p", "1080p", "4k"],
5318
+ durations: { values: [4, 6, 8, 10] },
5319
+ defaultSeconds: 8,
5320
+ defaultResolution: "720p",
5321
+ audioSwitch: false,
5322
+ defaultAudio: false,
5323
+ // Six character images, because the start keyframe takes one of the seven.
5324
+ characterReferences: {
5325
+ maxElements: 6,
5326
+ minImagesPerElement: 1,
5327
+ maxImagesPerElement: 6,
5328
+ maxTotalImages: OMNI_MAX_REFERENCE_IMAGES2 - 1
5329
+ },
5330
+ maxPromptChars: 2e4,
5331
+ referencesPrompt: omniReferencesPrompt2,
5332
+ build: (i) => ({
5333
+ prompt: i.prompt,
5334
+ image_urls: [i.start, ...(i.elements ?? []).flatMap((e) => [e.frontalImageUrl, ...e.referenceImageUrls])],
5335
+ duration: String(i.seconds),
5336
+ resolution: i.resolution,
5337
+ ...i.aspectRatio ? { aspect_ratio: i.aspectRatio } : {},
5338
+ ...i.seed !== void 0 ? { seed: i.seed } : {}
5339
+ })
5340
+ },
5341
+ "kling-3.0-omni/image-to-video": {
5342
+ family: "job",
5343
+ label: "Kling O3",
5344
+ endFrame: true,
5345
+ // Kling O3 takes an aspect ratio only for multi-shot prompts; a single shot
5346
+ // follows the start frame.
5347
+ resolutions: ["720p", "1080p", "4k"],
5348
+ durations: { min: 3, max: 15 },
5349
+ defaultSeconds: 5,
5350
+ defaultResolution: "720p",
5351
+ audioSwitch: true,
5352
+ defaultAudio: false,
5353
+ // KIE's "Single First Frame" and "First and Last Frames" request shapes
5354
+ // both carry `elements`: "up to 3 subjects", and "for a multi-image
5355
+ // subject, provide 2 to 4 images" (docs.kie.ai, kling-3.0-omni
5356
+ // image-to-video, read 2026-10-23). Each element needs a name the prompt
5357
+ // can mention as `@name` and a description.
5358
+ characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 12 },
5359
+ maxPromptChars: 3072,
5360
+ build: (i) => ({
5361
+ prompt: i.prompt,
5362
+ image_urls: i.end ? [i.start, i.end] : [i.start],
5363
+ duration: i.seconds,
5364
+ resolution: i.resolution,
5365
+ audio: i.audio,
5366
+ // Named Element1, Element2, ... so one prompt convention (`@Element1`)
5367
+ // holds on KIE and on the fal twin alike.
5368
+ ...i.elements && i.elements.length > 0 ? {
5369
+ elements: i.elements.map((e, n) => ({
5370
+ name: `Element${n + 1}`,
5371
+ description: `character ${n + 1}`,
5372
+ element_input_urls: [e.frontalImageUrl, ...e.referenceImageUrls]
5373
+ }))
5374
+ } : {}
5375
+ })
5376
+ }
5377
+ };
5378
+ function veoSpec22(label, resolutions) {
5379
+ return {
5380
+ label,
5381
+ // OpenRouter's Veo has no auto: it renders exactly one of these.
5382
+ aspectRatios: ["16:9", "9:16"],
5383
+ resolutions,
5384
+ durations: { values: [4, 6, 8] },
5385
+ defaultSeconds: 8,
5386
+ defaultResolution: "720p"
5387
+ };
5388
+ }
5389
+ var OPENROUTER_VIDEO_SPECS2 = {
5390
+ "google/veo-3.1-lite": veoSpec22("Veo 3.1 Lite", ["720p", "1080p"]),
5391
+ "google/veo-3.1-fast": veoSpec22("Veo 3.1 Fast", ["720p", "1080p", "4k"]),
5392
+ "google/veo-3.1": veoSpec22("Veo 3.1", ["720p", "1080p", "4k"])
5393
+ };
5394
+ var HEYGEN_AVATAR_6_ENDPOINT2 = "heygen/avatar-6/image-to-video";
5395
+ var HEYGEN_AVATAR_6_TURBO_ENDPOINT2 = "heygen/avatar-6/turbo/image-to-video";
5396
+ var OMNIHUMAN_V2_ENDPOINT2 = "bytedance/omnihuman/v2";
5397
+ var LIP_SYNC_MAX_AUDIO_BYTES2 = 15 * 1024 * 1024;
5398
+ var LIP_SYNC_SPECS2 = {
5399
+ [HEYGEN_AVATAR_6_ENDPOINT2]: { minSeconds: 1, maxSeconds: 300, promptField: "motion_prompt", motionExpressiveness: true },
5400
+ [HEYGEN_AVATAR_6_TURBO_ENDPOINT2]: { minSeconds: 1, maxSeconds: 300, promptField: "motion_prompt", motionExpressiveness: true },
5401
+ [OMNIHUMAN_V2_ENDPOINT2]: { minSeconds: 4, maxSeconds: 300, promptField: "prompt", motionExpressiveness: false }
5402
+ };
5403
+ var GROK_IMAGINE_I2V_ENDPOINT2 = "xai/grok-imagine-video/image-to-video";
5404
+ var GROK_IMAGINE_15_I2V_ENDPOINT2 = "xai/grok-imagine-video/v1.5/image-to-video";
5405
+ var WAN_30_I2V_ENDPOINT2 = "alibaba/wan-3.0/image-to-video";
5406
+ var KLING_26_I2V_ENDPOINT2 = "fal-ai/kling-video/v2.6/pro/image-to-video";
5407
+ var KLING_O3_STANDARD_I2V_ENDPOINT2 = "fal-ai/kling-video/o3/standard/image-to-video";
5408
+ var KLING_O3_PRO_I2V_ENDPOINT2 = "fal-ai/kling-video/o3/pro/image-to-video";
5409
+ var KLING_O3_I2V_ENDPOINTS2 = [KLING_O3_STANDARD_I2V_ENDPOINT2, KLING_O3_PRO_I2V_ENDPOINT2];
5410
+ var GEMINI_OMNI_11_I2V_ENDPOINT2 = "google/gemini-omni-flash/v1.1/image-to-video";
5411
+ var KLING_V3_STANDARD_I2V_ENDPOINT2 = "fal-ai/kling-video/v3/standard/image-to-video";
5412
+ var KLING_V3_PRO_I2V_ENDPOINT2 = "fal-ai/kling-video/v3/pro/image-to-video";
5413
+ var KLING_V3_I2V_ENDPOINTS2 = [KLING_V3_STANDARD_I2V_ENDPOINT2, KLING_V3_PRO_I2V_ENDPOINT2];
5414
+ var KLING_V4_I2V_ENDPOINT2 = "kling/v4/image-to-video";
5415
+ var MINIMAX_H3_I2V_ENDPOINT2 = "minimax/h3/image-to-video";
5416
+ var KLING_O3_PRO_R2V_ENDPOINT2 = "fal-ai/kling-video/o3/pro/reference-to-video";
5417
+ var FAL_CHARACTER_REFERENCE_LIMITS2 = {
5418
+ [KLING_O3_PRO_R2V_ENDPOINT2]: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 7 }
5419
+ };
5420
+ var LTX_25_FAST_I2V_ENDPOINT2 = "lightricks/ltx-2.5/image-to-video/fast";
5421
+ var LTX_25_PRO_I2V_ENDPOINT2 = "lightricks/ltx-2.5/image-to-video/pro";
5422
+ var LTX_25_I2V_ENDPOINTS2 = [LTX_25_FAST_I2V_ENDPOINT2, LTX_25_PRO_I2V_ENDPOINT2];
5423
+ var VEO_LITE_I2V_ENDPOINT2 = "fal-ai/veo3.1/lite/image-to-video";
5424
+ var VEO_LITE_FLF_ENDPOINT2 = "fal-ai/veo3.1/lite/first-last-frame-to-video";
5425
+ var VEO_FAST_I2V_ENDPOINT2 = "fal-ai/veo3.1/fast/image-to-video";
5426
+ var VEO_FAST_FLF_ENDPOINT2 = "fal-ai/veo3.1/fast/first-last-frame-to-video";
5427
+ var VEO_I2V_ENDPOINT2 = "fal-ai/veo3.1/image-to-video";
5428
+ var VEO_FLF_ENDPOINT2 = "fal-ai/veo3.1/first-last-frame-to-video";
5429
+ var VEO_ENDPOINTS2 = [
5430
+ VEO_LITE_I2V_ENDPOINT2,
5431
+ VEO_LITE_FLF_ENDPOINT2,
5432
+ VEO_FAST_I2V_ENDPOINT2,
5433
+ VEO_FAST_FLF_ENDPOINT2,
5434
+ VEO_I2V_ENDPOINT2,
5435
+ VEO_FLF_ENDPOINT2
5436
+ ];
5437
+ var VIDEO_FIXED_RESOLUTION2 = {
5438
+ "blackforestlabs/flux-3/keyframes-to-video/draft": "720p",
5439
+ "blackforestlabs/flux-3/first-last-frame-to-video/draft": "720p",
5440
+ "blackforestlabs/flux-3/image-to-video/draft": "720p",
5441
+ "blackforestlabs/flux-3/draft-enhance": "1080p",
5442
+ // Not a resolution the caller picks: Kling O3 Edit renders at the source's.
5443
+ "fal-ai/kling-video/o3/pro/video-to-video/edit": "source",
5444
+ // Lip sync: no size knob. HeyGen is sent without one and renders its 1080p
5445
+ // default; OmniHuman v2 declares none.
5446
+ "heygen/avatar-6/image-to-video": "1080p",
5447
+ "heygen/avatar-6/turbo/image-to-video": "1080p",
5448
+ "bytedance/omnihuman/v2": "fixed",
5449
+ // Kling 2.6 Pro takes no resolution; it renders 1080p.
5450
+ [KLING_26_I2V_ENDPOINT2]: "1080p",
5451
+ // Not a resolution the caller picks: Kling O3's tier sets the size.
5452
+ [KLING_O3_STANDARD_I2V_ENDPOINT2]: "fixed",
5453
+ [KLING_O3_PRO_I2V_ENDPOINT2]: "fixed",
5454
+ [KLING_O3_PRO_R2V_ENDPOINT2]: "fixed",
5455
+ // Kling 3.0 likewise: its tier sets the size.
5456
+ [KLING_V3_STANDARD_I2V_ENDPOINT2]: "fixed",
5457
+ [KLING_V3_PRO_I2V_ENDPOINT2]: "fixed"
5458
+ };
5459
+ var VIDEO_PINNED_DEFAULT_SECONDS2 = {
5460
+ [GROK_IMAGINE_I2V_ENDPOINT2]: 5,
5461
+ // Veo defaults to 8 s itself, and 8 s is the only length Lite first-and-last
5462
+ // renders; pinning it keeps the bill and the clip in step either way.
5463
+ ...Object.fromEntries(VEO_ENDPOINTS2.map((e) => [e, 8])),
5464
+ // The fal twins render the length their KIE entries default to, so a clip
5465
+ // falling back from KIE to fal has the same length.
5466
+ [GROK_IMAGINE_15_I2V_ENDPOINT2]: 8,
5467
+ [WAN_30_I2V_ENDPOINT2]: 5,
5468
+ [KLING_26_I2V_ENDPOINT2]: 5,
5469
+ [KLING_O3_STANDARD_I2V_ENDPOINT2]: 5,
5470
+ [KLING_O3_PRO_I2V_ENDPOINT2]: 5,
5471
+ [KLING_O3_PRO_R2V_ENDPOINT2]: 5,
5472
+ [GEMINI_OMNI_11_I2V_ENDPOINT2]: 8,
5473
+ // fal's own default on Kling 3.0 and 4.0 (schemas read 2026-11-03).
5474
+ [KLING_V3_STANDARD_I2V_ENDPOINT2]: 5,
5475
+ [KLING_V3_PRO_I2V_ENDPOINT2]: 5,
5476
+ [KLING_V4_I2V_ENDPOINT2]: 5,
5477
+ // fal's own default on MiniMax H3 (schema read 2026-11-04).
5478
+ [MINIMAX_H3_I2V_ENDPOINT2]: 5,
5479
+ // LTX-2.5 defaults to "auto", a length nobody can price up front; 6 s is its
5480
+ // shortest clip on both tiers.
5481
+ [LTX_25_FAST_I2V_ENDPOINT2]: 6,
5482
+ [LTX_25_PRO_I2V_ENDPOINT2]: 6,
5483
+ // fal's own default is 5 s on these (schemas read 2026-10-25); sent so the
5484
+ // bill cannot drift from the clip if fal ever changes it.
5485
+ "fal-ai/kling-video/v2.5-turbo/pro/image-to-video": 5,
5486
+ "fal-ai/bytedance/seedance/v1/pro/image-to-video": 5,
5487
+ "fal-ai/bytedance/seedance/v1/pro/text-to-video": 5,
5488
+ "blackforestlabs/flux-3/first-last-frame-to-video": 5,
5489
+ "blackforestlabs/flux-3/first-last-frame-to-video/draft": 5,
5490
+ "blackforestlabs/flux-3/keyframes-to-video": 5,
5491
+ "blackforestlabs/flux-3/keyframes-to-video/draft": 5,
5492
+ // `auto` by default on these (fal schemas, 2026-10-25): the model would pick
5493
+ // a length nobody can price. 5 s is the shortest FLUX.3 renders and the clip
5494
+ // the Seedance anchors were priced at.
5495
+ "bytedance/seedance-2.0/image-to-video": 5,
5496
+ "bytedance/seedance-2.5/image-to-video": 5,
5497
+ "bytedance/seedance-2.5/text-to-video": 5,
5498
+ "blackforestlabs/flux-3/image-to-video": 5,
5499
+ "blackforestlabs/flux-3/image-to-video/draft": 5
5500
+ };
5501
+ var VIDEO_DEFAULT_RESOLUTION2 = {
5502
+ "blackforestlabs/flux-3/keyframes-to-video": "720p",
5503
+ "blackforestlabs/flux-3/first-last-frame-to-video": "720p",
5504
+ "blackforestlabs/flux-3/image-to-video": "720p",
5505
+ // fal schema default: Grok renders 720p.
5506
+ [GROK_IMAGINE_I2V_ENDPOINT2]: "720p",
5507
+ ...Object.fromEntries(VEO_ENDPOINTS2.map((e) => [e, "720p"])),
5508
+ [GROK_IMAGINE_15_I2V_ENDPOINT2]: "720p",
5509
+ // fal schema default: Wan 3.0 renders 1080p unless asked for less.
5510
+ [WAN_30_I2V_ENDPOINT2]: "1080p",
5511
+ // fal schema default: Gemini Omni renders 720p, as on KIE.
5512
+ [GEMINI_OMNI_11_I2V_ENDPOINT2]: "720p",
5513
+ // fal schema default: Kling 4.0 renders 1080p unless asked for 720p.
5514
+ [KLING_V4_I2V_ENDPOINT2]: "1080p",
5515
+ // fal schema default: MiniMax H3 renders 2K (the canvas's 1080p) unless asked.
5516
+ [MINIMAX_H3_I2V_ENDPOINT2]: "1080p",
5517
+ // fal schema default: LTX-2.5 renders 1080p unless asked for less.
5518
+ [LTX_25_FAST_I2V_ENDPOINT2]: "1080p",
5519
+ [LTX_25_PRO_I2V_ENDPOINT2]: "1080p"
5520
+ };
5521
+ var VIDEO_ALLOWED_VALUES2 = {
5522
+ // Seedance 2.5 derives its aspect from the input image.
5523
+ "bytedance/seedance-2.5/image-to-video": { aspectRatio: ["auto"] },
5524
+ "fal-ai/kling-video/v2.5-turbo/pro/image-to-video": {
5525
+ aspectRatio: ["16:9", "9:16", "1:1"],
5526
+ durationSeconds: { values: [5, 10] }
5527
+ },
5528
+ [GROK_IMAGINE_I2V_ENDPOINT2]: {
5529
+ aspectRatio: ["auto", "16:9", "4:3", "3:2", "1:1", "2:3", "3:4", "9:16"],
5530
+ resolution: ["480p", "720p"],
5531
+ durationSeconds: { min: 1, max: 15 }
5532
+ },
5533
+ ...Object.fromEntries(
5534
+ VEO_ENDPOINTS2.map((e) => [
5535
+ e,
5536
+ {
5537
+ aspectRatio: ["auto", "16:9", "9:16"],
5538
+ resolution: e === VEO_LITE_I2V_ENDPOINT2 || e === VEO_LITE_FLF_ENDPOINT2 ? ["720p", "1080p"] : ["720p", "1080p", "4k"],
5539
+ // Lite first-and-last renders 8 s only (its schema pins the const).
5540
+ durationSeconds: { values: e === VEO_LITE_FLF_ENDPOINT2 ? [8] : [4, 6, 8] }
5541
+ }
5542
+ ])
5543
+ ),
5544
+ [GROK_IMAGINE_15_I2V_ENDPOINT2]: { resolution: ["480p", "720p", "1080p"], durationSeconds: { min: 1, max: 15 } },
5545
+ [WAN_30_I2V_ENDPOINT2]: {
5546
+ aspectRatio: ["auto", "16:9", "4:3", "1:1", "3:4", "9:16"],
5547
+ resolution: ["480p", "720p", "1080p"]
5548
+ },
5549
+ [KLING_26_I2V_ENDPOINT2]: { durationSeconds: { values: [5, 10] } },
5550
+ ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS2.map((e) => [e, { durationSeconds: { min: 3, max: 15 } }])),
5551
+ // Reference-to-video renders at a set ratio (default 16:9), not the frame's.
5552
+ [KLING_O3_PRO_R2V_ENDPOINT2]: { aspectRatio: ["16:9", "9:16", "1:1"], durationSeconds: { min: 3, max: 15 } },
5553
+ [LTX_25_FAST_I2V_ENDPOINT2]: {
5554
+ aspectRatio: ["auto", "16:9", "9:16"],
5555
+ // fal also renders 1440p, which the canvas does not offer.
5556
+ resolution: ["720p", "1080p", "4k"],
5557
+ durationSeconds: { values: [6, 8, 10, 12, 14, 16, 18, 20] }
5558
+ },
5559
+ [LTX_25_PRO_I2V_ENDPOINT2]: {
5560
+ aspectRatio: ["auto", "16:9", "9:16"],
5561
+ resolution: ["720p", "1080p"],
5562
+ durationSeconds: { values: [6, 8, 10] }
5563
+ },
5564
+ // fal also renders 360p, which the canvas does not offer.
5565
+ [GEMINI_OMNI_11_I2V_ENDPOINT2]: {
5566
+ aspectRatio: ["16:9", "9:16"],
5567
+ resolution: ["720p", "1080p", "4k"],
5568
+ durationSeconds: { min: 3, max: 10 }
5569
+ },
5570
+ ...Object.fromEntries(KLING_V3_I2V_ENDPOINTS2.map((e) => [e, { durationSeconds: { min: 3, max: 15 } }])),
5571
+ [KLING_V4_I2V_ENDPOINT2]: { resolution: ["720p", "1080p"], durationSeconds: { min: 3, max: 30 } },
5572
+ // fal also renders 480P, which the canvas does not offer. Its shortest clip
5573
+ // is 5 s (KIE's is 4 s), so a 4 s job on the H3 route has no fal fallback.
5574
+ [MINIMAX_H3_I2V_ENDPOINT2]: { resolution: ["720p", "1080p", "4k"], durationSeconds: { min: 5, max: 15 } }
5575
+ };
5576
+ var VIDEO_MAX_SECONDS_AT_RESOLUTION2 = {
5577
+ [LTX_25_FAST_I2V_ENDPOINT2]: { "4k": 10 }
5578
+ };
5579
+ var VIDEO_UNSUPPORTED_PARAMS2 = {
5580
+ // Kling 2.5 Turbo and Seedance 1.0 Pro render silent clips and their schemas
5581
+ // declare no audio field at all (fal model schemas, checked 2026-10-25), so a
5582
+ // sound choice is refused before submit instead of being sent and ignored.
5583
+ "fal-ai/kling-video/v2.5-turbo/pro/image-to-video": ["generateAudio"],
5584
+ "fal-ai/bytedance/seedance/v1/pro/image-to-video": ["generateAudio"],
5585
+ "fal-ai/bytedance/seedance/v1/pro/text-to-video": ["generateAudio"],
5586
+ // Kling O3 Edit follows the source clip: its length, frame, size and look are
5587
+ // the source's, and the endpoint declares none of these knobs. A duration in
5588
+ // particular would only have been a (wrong) billing figure; the completer
5589
+ // measures the result instead.
5590
+ "fal-ai/kling-video/o3/pro/video-to-video/edit": [
5591
+ "resolution",
5592
+ "seed",
5593
+ "negativePrompt",
5594
+ "aspectRatio",
5595
+ "generateAudio",
5596
+ "durationSeconds"
5597
+ ],
5598
+ // Lip sync: the length is the audio's, the shape the face image's.
5599
+ ...Object.fromEntries(
5600
+ Object.keys(LIP_SYNC_SPECS2).map((e) => [e, ["resolution", "seed", "negativePrompt", "aspectRatio", "generateAudio", "durationSeconds"]])
5601
+ ),
5602
+ // Wan's output is also as long as its source; it takes resolution and seed.
5603
+ "fal-ai/wan/v2.2-14b/animate/replace": ["durationSeconds", "negativePrompt", "aspectRatio", "generateAudio"],
5604
+ "blackforestlabs/flux-3/keyframes-to-video/draft": ["resolution", "seed", "negativePrompt"],
5605
+ "blackforestlabs/flux-3/first-last-frame-to-video/draft": ["resolution", "seed", "negativePrompt"],
5606
+ "blackforestlabs/flux-3/image-to-video/draft": ["resolution", "seed", "negativePrompt"],
5607
+ // The direct tier adds `resolution` (720p | 1080p) and nothing else: `seed` is
5608
+ // OUTPUT only on every FLUX.3 endpoint, so a caller cannot pin a take by seed.
5609
+ "blackforestlabs/flux-3/keyframes-to-video": ["seed", "negativePrompt"],
5610
+ "blackforestlabs/flux-3/first-last-frame-to-video": ["seed", "negativePrompt"],
5611
+ "blackforestlabs/flux-3/image-to-video": ["seed", "negativePrompt"],
5612
+ // Enhance renders whatever the cache holds: duration, aspect, audio and prompt
5613
+ // are all baked in, and the output is a fixed 1080p. `durationSeconds` is NOT
5614
+ // banned although it is not forwarded either (buildFalVideoInput sends only
5615
+ // the cache url + safety_tolerance): the executor injects the upstream
5616
+ // draft's duration as a COST hint, since enhance bills per second and
5617
+ // the request itself carries nothing the estimate could read.
5618
+ "blackforestlabs/flux-3/draft-enhance": [
5619
+ "resolution",
5620
+ "seed",
5621
+ "negativePrompt",
5622
+ "aspectRatio",
5623
+ "generateAudio"
5624
+ ],
5625
+ // Grok's schema declares no seed, negative prompt or audio switch: it always
5626
+ // renders audio.
5627
+ [GROK_IMAGINE_I2V_ENDPOINT2]: ["seed", "negativePrompt", "generateAudio"],
5628
+ [GROK_IMAGINE_15_I2V_ENDPOINT2]: ["aspectRatio", "seed", "negativePrompt", "generateAudio"],
5629
+ [WAN_30_I2V_ENDPOINT2]: ["negativePrompt"],
5630
+ [KLING_26_I2V_ENDPOINT2]: ["resolution", "aspectRatio", "seed"],
5631
+ ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS2.map((e) => [e, ["resolution", "aspectRatio", "seed", "negativePrompt"]])),
5632
+ // Its tier sets the size; it takes an aspect ratio, but no seed or negative prompt.
5633
+ [KLING_O3_PRO_R2V_ENDPOINT2]: ["resolution", "seed", "negativePrompt"],
5634
+ ...Object.fromEntries(LTX_25_I2V_ENDPOINTS2.map((e) => [e, ["seed", "negativePrompt"]])),
5635
+ // Its schema declares no seed, negative prompt or audio switch: it always
5636
+ // renders audio, at no extra charge.
5637
+ [GEMINI_OMNI_11_I2V_ENDPOINT2]: ["seed", "negativePrompt", "generateAudio"],
5638
+ // Kling 3.0: the tier sets the size and the start frame the shape; it takes a
5639
+ // negative prompt but no seed.
5640
+ ...Object.fromEntries(KLING_V3_I2V_ENDPOINTS2.map((e) => [e, ["resolution", "aspectRatio", "seed"]])),
5641
+ // Kling 4.0 follows the start frame's shape and always renders sound.
5642
+ [KLING_V4_I2V_ENDPOINT2]: ["aspectRatio", "seed", "negativePrompt", "generateAudio"],
5643
+ // MiniMax H3 follows the start frame's shape and always renders sound (a 5 s
5644
+ // test render of 2026-11-04 had a video and an audio track); it takes a seed.
5645
+ [MINIMAX_H3_I2V_ENDPOINT2]: ["aspectRatio", "negativePrompt", "generateAudio"]
5646
+ };
5647
+ var VIDEO_AUDIO_SWITCH2 = {
5648
+ ...Object.fromEntries(VEO_ENDPOINTS2.map((e) => [e, { default: false }])),
5649
+ [KLING_26_I2V_ENDPOINT2]: { default: false },
5650
+ ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS2.map((e) => [e, { default: false }])),
5651
+ [KLING_O3_PRO_R2V_ENDPOINT2]: { default: false },
5652
+ // Kling 3.0 renders sound unless sent false; Studio sends it silent unless asked.
5653
+ ...Object.fromEntries(KLING_V3_I2V_ENDPOINTS2.map((e) => [e, { default: false }])),
5654
+ "bytedance/seedance-2.5/image-to-video": { default: true },
5655
+ "bytedance/seedance-2.0/image-to-video": { default: true },
5656
+ [WAN_30_I2V_ENDPOINT2]: { default: true },
5657
+ ...Object.fromEntries(LTX_25_I2V_ENDPOINTS2.map((e) => [e, { default: true }])),
5658
+ "blackforestlabs/flux-3/image-to-video/draft": { default: true },
5659
+ "blackforestlabs/flux-3/first-last-frame-to-video/draft": { default: true },
5660
+ "blackforestlabs/flux-3/keyframes-to-video/draft": { default: true },
5661
+ "blackforestlabs/flux-3/image-to-video": { default: true },
5662
+ "blackforestlabs/flux-3/first-last-frame-to-video": { default: true },
5663
+ "blackforestlabs/flux-3/keyframes-to-video": { default: true }
5664
+ };
5665
+ var NO_AUDIO_SWITCH = { switchable: false };
5666
+ function videoSettingSupport(model) {
5667
+ if (!model?.id || model.modality !== "video") return null;
5668
+ const upstream = getProviderModelName(model.id);
5669
+ if (model.provider === "kie") {
5670
+ const spec = KIE_VIDEO_SPECS2[upstream];
5671
+ if (!spec) return null;
5672
+ return {
5673
+ aspectRatios: spec.aspectRatios ?? [],
5674
+ resolutions: spec.resolutions,
5675
+ durations: spec.durations,
5676
+ defaultSeconds: spec.defaultSeconds,
5677
+ // The KIE spec says whether the job may switch audio (`audioSwitch`, the
5678
+ // rule its pre-submit check refuses by); its `defaultAudio` is the state
5679
+ // only where there is a switch.
5680
+ generateAudio: spec.audioSwitch ? { switchable: true, default: spec.defaultAudio } : NO_AUDIO_SWITCH
5681
+ };
5682
+ }
5683
+ if (model.provider === "openrouter") {
5684
+ const spec = OPENROUTER_VIDEO_SPECS2[upstream];
5685
+ if (!spec) return null;
5686
+ return {
5687
+ aspectRatios: spec.aspectRatios,
5688
+ resolutions: spec.resolutions,
5689
+ durations: spec.durations,
5690
+ defaultSeconds: spec.defaultSeconds,
5691
+ // Every OpenRouter video model is sent `generate_audio`, silent unless
5692
+ // the job asks (`openRouterVideoPlan`).
5693
+ generateAudio: { switchable: true, default: false }
5694
+ };
5695
+ }
5696
+ if (model.provider === "fal") {
5697
+ const allowed = VIDEO_ALLOWED_VALUES2[upstream];
5698
+ const unsupported = VIDEO_UNSUPPORTED_PARAMS2[upstream] ?? [];
5699
+ const pinned = VIDEO_PINNED_DEFAULT_SECONDS2[upstream];
5700
+ const maxSecondsAt = VIDEO_MAX_SECONDS_AT_RESOLUTION2[upstream];
5701
+ return {
5702
+ ...maxSecondsAt ? { maxSecondsAt } : {},
5703
+ aspectRatios: unsupported.includes("aspectRatio") ? [] : allowed?.aspectRatio ?? null,
5704
+ resolutions: unsupported.includes("resolution") ? [] : allowed?.resolution ?? null,
5705
+ durations: unsupported.includes("durationSeconds") ? { values: [] } : allowed?.durationSeconds ?? null,
5706
+ ...pinned !== void 0 ? { defaultSeconds: pinned } : {},
5707
+ generateAudio: falAudioSupport(upstream, unsupported)
5708
+ };
5709
+ }
5710
+ return null;
5711
+ }
5712
+ function falAudioSupport(endpoint, unsupported) {
5713
+ if (unsupported.includes("generateAudio")) return NO_AUDIO_SWITCH;
5714
+ const declared = VIDEO_AUDIO_SWITCH2[endpoint];
5715
+ return declared ? { switchable: true, default: declared.default } : null;
5716
+ }
5717
+ function supportedResolutions(model) {
5718
+ const declared = model?.capabilities?.resolutions;
5719
+ return declared ? declared : null;
5720
+ }
5721
+ function resolutionRefusal(model, resolution) {
5722
+ if (resolution === void 0 || resolution === null || resolution === "") return null;
5723
+ const supported = supportedResolutions(model);
5724
+ if (!model || supported === null) return null;
5725
+ const name = model.label ?? model.id;
5726
+ if (supported.length === 0) {
5727
+ 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.`;
5728
+ }
5729
+ const tier = imageResolutionTier(resolution);
5730
+ if (tier && supported.includes(tier)) return null;
5731
+ if (model.capabilities?.tierKind === "quality") {
5732
+ const offered = supported.map((t) => `${imageTierLabel(model, t).toLowerCase()} (${IMAGE_SIZE_OF_TIER[t]})`).join(", ");
5733
+ return `${name} takes the quality ${offered}, not "${String(resolution)}". Pick one of those.`;
5734
+ }
5735
+ return `${name} renders at ${supported.join(", ")}, not "${String(resolution)}". Pick one of those.`;
5736
+ }
5737
+ function sendableSettings(settings, model) {
5738
+ if (!settings || !("generateAudio" in settings)) return settings;
5739
+ if (videoSettingSupport(model)?.generateAudio?.switchable === true) return settings;
5740
+ const kept = { ...settings };
5741
+ delete kept.generateAudio;
5742
+ return kept;
5743
+ }
5744
+ function sendableOptions(options, model) {
5745
+ if (!options || typeof options !== "object" || Array.isArray(options) || !("generateAudio" in options)) return options;
5746
+ if (videoSettingSupport(model)?.generateAudio?.switchable === true) return options;
5747
+ const kept = { ...options };
5748
+ delete kept.generateAudio;
5749
+ return kept;
5750
+ }
5751
+ function voiceSettingsRefusal(model, voiceSettings) {
5752
+ const speech = model?.capabilities?.speech;
5753
+ if (!speech || speech.voiceSettings.speed) return null;
5754
+ if (!voiceSettings || typeof voiceSettings !== "object" || voiceSettings.speed === void 0) return null;
5755
+ return `${model?.label ?? model?.id ?? "This model"} has no Speed setting. Remove voiceSettings.speed, or pick a model that has it.`;
5756
+ }
5757
+ var PROMPT_REQUIRED = /* @__PURE__ */ new Set([
5758
+ "text-to-image",
5759
+ "image-to-image",
5760
+ "image-edit",
5761
+ "text-to-3d",
5762
+ "image-to-3d",
5763
+ "multiview-to-3d",
5764
+ "text-to-video",
5765
+ // Texture: 3D AI Studio refuses a texture request without a prompt or a
5766
+ // reference image (probed 2026-09-26), and Studio sends no reference image,
5767
+ // so the material description is required. It binds `texturePrompt`, see
5768
+ // `promptInputKey`.
5769
+ "texture",
5770
+ // Audio is prompt-only: a music description (text-to-audio) / the text to
5771
+ // speak (text-to-speech). No upstream wire, so no portBinding entry.
5772
+ "text-to-audio",
5773
+ "text-to-speech"
5774
+ ]);
5775
+ var PROMPT_OPTIONAL = /* @__PURE__ */ new Set(["image-to-video", "image-to-json", "video-to-video", "lip-sync"]);
5776
+ function taskNeedsPrompt(task) {
5777
+ return PROMPT_REQUIRED.has(task) || PROMPT_OPTIONAL.has(task);
5778
+ }
5779
+ function taskRequiresPrompt(task) {
5780
+ return PROMPT_REQUIRED.has(task);
5781
+ }
5782
+ function promptInputKey(task) {
5783
+ return task === "texture" ? "texturePrompt" : "prompt";
5784
+ }
5785
+ function portBinding(task, port) {
5786
+ 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")) {
5787
+ return { key: "inputImageUrl", path: "url" };
5788
+ }
5789
+ if (port === "reference" && task === "image-to-video") {
5790
+ return { key: "referenceImageUrls", path: "url", wrap: "array" };
5791
+ }
5792
+ if (port === "mesh3d" && (task === "remesh" || task === "texture" || task === "rig")) {
5793
+ return { key: "parentAssetId", path: "assetId" };
5794
+ }
5795
+ if (port === "video" && task === "video-to-text") {
4465
5796
  return { key: "inputVideoUrl", path: "url" };
4466
5797
  }
4467
5798
  if (port === "video" && task === "video-to-video") {
@@ -4482,7 +5813,7 @@ function portBinding(task, port) {
4482
5813
  if (port === "image" && (task === "upscale" || task === "background-remove")) {
4483
5814
  return { key: "parentAssetId", path: "assetId" };
4484
5815
  }
4485
- if (port === "audio" && task === "speech-to-text") {
5816
+ if (port === "audio" && (task === "speech-to-text" || task === "lip-sync")) {
4486
5817
  return { key: "inputAudioUrl", path: "url" };
4487
5818
  }
4488
5819
  if (port === "image" && task === "judge") {
@@ -4542,10 +5873,10 @@ function orderedPortKey(task, port, ordinal, model) {
4542
5873
  if (portCardinality(task, port, model) === "two" && ordinal === 1) return "endImageUrl";
4543
5874
  return canonical.key;
4544
5875
  }
4545
- function sourcePortOf(node) {
4546
- switch (node.kind) {
5876
+ function sourcePortOf(node2) {
5877
+ switch (node2.kind) {
4547
5878
  case "task":
4548
- return taskPorts(node.task).output;
5879
+ return taskPorts(node2.task).output;
4549
5880
  case "prompt-source":
4550
5881
  return "text";
4551
5882
  case "image-source":
@@ -4553,35 +5884,35 @@ function sourcePortOf(node) {
4553
5884
  case "video-source":
4554
5885
  return "video";
4555
5886
  case "input":
4556
- return node.type;
5887
+ return node2.type;
4557
5888
  }
4558
5889
  }
4559
- function targetCardinality(node, port) {
4560
- if (node.kind !== "task") return "none";
4561
- return portCardinality(node.task, port, node.model);
5890
+ function targetCardinality(node2, port) {
5891
+ if (node2.kind !== "task") return "none";
5892
+ return portCardinality(node2.task, port, node2.model);
4562
5893
  }
4563
- function slotRefusal(node, port, wired) {
4564
- const cardinality = targetCardinality(node, port);
5894
+ function slotRefusal(node2, port, wired) {
5895
+ const cardinality = targetCardinality(node2, port);
4565
5896
  let limit = cardinalityLimit(cardinality);
4566
- if (port === "reference" && node.kind === "task") {
4567
- const refs = modelCharacterReferences(node.model);
5897
+ if (port === "reference" && node2.kind === "task") {
5898
+ const refs = modelCharacterReferences(node2.model);
4568
5899
  if (refs) limit = Math.min(limit, refs.maxTotalImages);
4569
5900
  if (wired < limit) return null;
4570
5901
  if (!refs) {
4571
- 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`;
5902
+ 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`;
4572
5903
  }
4573
- return `node "${node.id}" (${node.model}) takes at most ${limit} character reference images in all`;
5904
+ return `node "${node2.id}" (${node2.model}) takes at most ${limit} character reference images in all`;
4574
5905
  }
4575
- if (cardinality === "many" && node.kind === "task" && node.model) {
4576
- const cap = tryGetModel2(node.model)?.capabilities?.maxInputImages;
5906
+ if (cardinality === "many" && node2.kind === "task" && node2.model) {
5907
+ const cap = tryGetModel2(node2.model)?.capabilities?.maxInputImages;
4577
5908
  if (typeof cap === "number" && cap > 0) limit = Math.min(limit, cap);
4578
5909
  }
4579
5910
  if (wired < limit) return null;
4580
- if (cardinality === "one") return `node "${node.id}" accepts one ${port} wire, got more`;
5911
+ if (cardinality === "one") return `node "${node2.id}" accepts one ${port} wire, got more`;
4581
5912
  if (cardinality === "two") {
4582
- 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.`;
5913
+ 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.`;
4583
5914
  }
4584
- return `node "${node.id}" (${node.kind === "task" ? node.model : node.kind}) takes at most ${limit} ${port} wires`;
5915
+ return `node "${node2.id}" (${node2.kind === "task" ? node2.model : node2.kind}) takes at most ${limit} ${port} wires`;
4585
5916
  }
4586
5917
  function wireLegality(source, target, port) {
4587
5918
  if (source.id === target.id) return { ok: false, code: "cycle", message: `node "${source.id}" cannot wire into itself` };
@@ -4643,17 +5974,17 @@ function validateDocument(doc) {
4643
5974
  };
4644
5975
  }
4645
5976
  const byId = /* @__PURE__ */ new Map();
4646
- for (const node of doc.nodes) {
4647
- if (byId.has(node.id)) return { ok: false, code: "conflict", message: `duplicate node id "${node.id}"` };
4648
- byId.set(node.id, node);
5977
+ for (const node2 of doc.nodes) {
5978
+ if (byId.has(node2.id)) return { ok: false, code: "conflict", message: `duplicate node id "${node2.id}"` };
5979
+ byId.set(node2.id, node2);
4649
5980
  }
4650
5981
  const inputNames = /* @__PURE__ */ new Set();
4651
- for (const node of doc.nodes) {
4652
- if (node.kind !== "input") continue;
4653
- if (inputNames.has(node.name)) {
4654
- return { ok: false, code: "conflict", message: `duplicate input name "${node.name}"` };
5982
+ for (const node2 of doc.nodes) {
5983
+ if (node2.kind !== "input") continue;
5984
+ if (inputNames.has(node2.name)) {
5985
+ return { ok: false, code: "conflict", message: `duplicate input name "${node2.name}"` };
4655
5986
  }
4656
- inputNames.add(node.name);
5987
+ inputNames.add(node2.name);
4657
5988
  }
4658
5989
  const edgeKeys = /* @__PURE__ */ new Set();
4659
5990
  const slots = /* @__PURE__ */ new Map();
@@ -4687,12 +6018,16 @@ function validateDocument(doc) {
4687
6018
  };
4688
6019
  }
4689
6020
  }
4690
- for (const node of doc.nodes) {
4691
- if (node.kind !== "task" || !node.model) continue;
4692
- const baked = node.bakedInputs?.imageSize;
4693
- const requested = node.settings?.resolution ?? (baked && baked.kind === "literal" ? baked.value : void 0);
4694
- const refusal = resolutionRefusal(tryGetModel2(node.model), requested);
4695
- if (refusal) return { ok: false, code: "unsupported", message: `"${node.id}": ${refusal}` };
6021
+ for (const node2 of doc.nodes) {
6022
+ if (node2.kind !== "task" || !node2.model) continue;
6023
+ const baked = node2.bakedInputs?.imageSize;
6024
+ const requested = node2.settings?.resolution ?? (baked && baked.kind === "literal" ? baked.value : void 0);
6025
+ const refusal = resolutionRefusal(tryGetModel2(node2.model), requested);
6026
+ if (refusal) return { ok: false, code: "unsupported", message: `"${node2.id}": ${refusal}` };
6027
+ const baking = node2.bakedInputs?.options;
6028
+ const bakedVoice = baking && baking.kind === "literal" && baking.value && typeof baking.value === "object" ? baking.value.voiceSettings : void 0;
6029
+ const voiceRefusal = voiceSettingsRefusal(tryGetModel2(node2.model), node2.settings?.voiceSettings ?? bakedVoice);
6030
+ if (voiceRefusal) return { ok: false, code: "unsupported", message: `"${node2.id}": ${voiceRefusal}` };
4696
6031
  }
4697
6032
  if (documentTopologicalOrder(doc) === null) {
4698
6033
  return { ok: false, code: "cycle", message: `document "${doc.id}" has a cycle in its wires` };
@@ -4757,7 +6092,7 @@ var InputNodePropsSchema = z4.object({
4757
6092
  }).partial().strict();
4758
6093
  var GroupPropsSchema = z4.object({
4759
6094
  label: LabelSchema.nullable(),
4760
- nodeIds: z4.array(IdSchema).min(1)
6095
+ nodeIds: z4.array(IdSchema).min(1).max(MAX_DOCUMENT_NODES)
4761
6096
  }).partial().strict();
4762
6097
  var DocumentPropsSchema = z4.object({
4763
6098
  label: LabelSchema,
@@ -4853,7 +6188,7 @@ var GroupOpSchema = z4.object({
4853
6188
  type: z4.literal("group"),
4854
6189
  id: IdSchema,
4855
6190
  label: LabelSchema.optional(),
4856
- nodeIds: z4.array(IdSchema).min(1),
6191
+ nodeIds: z4.array(IdSchema).min(1).max(MAX_DOCUMENT_NODES),
4857
6192
  index: Index.optional()
4858
6193
  });
4859
6194
  var UngroupOpSchema = z4.object({
@@ -4983,6 +6318,10 @@ function likenessConfirmationRequiredMessage() {
4983
6318
  function likenessConfirmationToolDescription() {
4984
6319
  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}`;
4985
6320
  }
6321
+ var IMAGE_ASPECT_RATIOS2 = ASPECT_RATIOS2.map((value) => ({
6322
+ value,
6323
+ label: value
6324
+ }));
4986
6325
  function taskModality(task) {
4987
6326
  const out = taskPorts(task).output;
4988
6327
  switch (out) {
@@ -5007,6 +6346,17 @@ function lit(value) {
5007
6346
  function isFiniteNumber(v) {
5008
6347
  return typeof v === "number" && Number.isFinite(v);
5009
6348
  }
6349
+ function voiceSettingsOf(v) {
6350
+ if (!v || typeof v !== "object" || Array.isArray(v)) return null;
6351
+ const o = v;
6352
+ if (!isFiniteNumber(o.stability) || !isFiniteNumber(o.similarityBoost)) return null;
6353
+ if (o.speed !== void 0 && !isFiniteNumber(o.speed)) return null;
6354
+ return {
6355
+ stability: o.stability,
6356
+ similarityBoost: o.similarityBoost,
6357
+ ...o.speed !== void 0 ? { speed: o.speed } : {}
6358
+ };
6359
+ }
5010
6360
  function settingsBindings(task, settings) {
5011
6361
  if (!task || !settings || Object.keys(settings).length === 0) return {};
5012
6362
  const modality = taskModality(task);
@@ -5020,6 +6370,7 @@ function settingsBindings(task, settings) {
5020
6370
  }
5021
6371
  case "video": {
5022
6372
  const options = {};
6373
+ if (task === "lip-sync") return {};
5023
6374
  if (task === "video-to-video") {
5024
6375
  if (typeof settings.resolution === "string") options.resolution = settings.resolution;
5025
6376
  return Object.keys(options).length > 0 ? { options: lit(options) } : {};
@@ -5027,11 +6378,17 @@ function settingsBindings(task, settings) {
5027
6378
  if (typeof settings.aspectRatio === "string") options.aspectRatio = settings.aspectRatio;
5028
6379
  if (typeof settings.resolution === "string") options.resolution = settings.resolution;
5029
6380
  if (isFiniteNumber(settings.duration)) options.durationSeconds = settings.duration;
6381
+ if (typeof settings.generateAudio === "boolean") options.generateAudio = settings.generateAudio;
5030
6382
  return Object.keys(options).length > 0 ? { options: lit(options) } : {};
5031
6383
  }
5032
6384
  case "audio": {
5033
6385
  const options = {};
5034
6386
  if (isFiniteNumber(settings.duration)) options.durationSeconds = settings.duration;
6387
+ if (task === "text-to-speech") {
6388
+ if (typeof settings.voiceId === "string" && settings.voiceId) options.voiceId = settings.voiceId;
6389
+ const voice = voiceSettingsOf(settings.voiceSettings);
6390
+ if (voice) options.voiceSettings = voice;
6391
+ }
5035
6392
  return Object.keys(options).length > 0 ? { options: lit(options) } : {};
5036
6393
  }
5037
6394
  default:
@@ -5084,6 +6441,41 @@ function keyframePositionsFor(sourceIds, settings) {
5084
6441
  return { ok: true, frames };
5085
6442
  }
5086
6443
  var REFERENCE_ELEMENTS_SETTING = "referenceElements";
6444
+ var CAST_MENTIONS_SETTING = "castMentions";
6445
+ var CAST_REFERENCES_SETTING = "castReferences";
6446
+ var CAST_TASKS = /* @__PURE__ */ new Set(["text-to-image", "image-edit", "image-to-image", "image-to-video"]);
6447
+ function castSettingOf(task, settings) {
6448
+ const none = { cast: [], own: false };
6449
+ if (!CAST_TASKS.has(task)) return none;
6450
+ const mentions = settings?.[CAST_MENTIONS_SETTING];
6451
+ const own = !(Array.isArray(mentions) && mentions.length > 0);
6452
+ const raw = own ? settings?.[CAST_REFERENCES_SETTING] : mentions;
6453
+ if (!Array.isArray(raw)) return none;
6454
+ const cast = raw.flatMap((r) => {
6455
+ const parsed = CastMemberSchema.safeParse(r);
6456
+ return parsed.success ? [parsed.data] : [];
6457
+ });
6458
+ return { cast, own: own && cast.length > 0 };
6459
+ }
6460
+ function castByElement(cast, elementOf) {
6461
+ 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.";
6462
+ const characters = cast.filter((m) => m.kind === "character");
6463
+ const placed = [];
6464
+ for (const member of characters) {
6465
+ const elements = new Set((member.sources ?? []).filter((s) => elementOf.has(s)).map((s) => elementOf.get(s)));
6466
+ if (elements.size === 0) return { ok: false, reason: `${member.name}'s reference images are no longer wired into this clip. ${again}` };
6467
+ if (elements.size > 1) return { ok: false, reason: `${member.name}'s reference images are set to more than one character number. ${again}` };
6468
+ const element = [...elements][0];
6469
+ const twin = placed.find((p) => p.element === element);
6470
+ if (twin) return { ok: false, reason: `${twin.member.name} and ${member.name} are wired as the same character. ${again}` };
6471
+ placed.push({ member, element });
6472
+ }
6473
+ const wired = new Set(elementOf.values());
6474
+ if (wired.size !== placed.length) {
6475
+ 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.` };
6476
+ }
6477
+ return { ok: true, cast: placed.sort((a, b) => a.element - b.element).map((p) => p.member) };
6478
+ }
5087
6479
  function referenceElementsFor(sourceIds, settings, limits) {
5088
6480
  const raw = settings?.[REFERENCE_ELEMENTS_SETTING];
5089
6481
  if (raw !== void 0 && (raw === null || typeof raw !== "object" || Array.isArray(raw))) {
@@ -5159,6 +6551,7 @@ var TASK_TO_KIND = {
5159
6551
  // video-to-video (character replace via Wan 2.2 Animate or Kling O3 Edit): rides the same
5160
6552
  // generate_video job; the fal provider routes the task to the replace endpoint.
5161
6553
  "video-to-video": "generate_video",
6554
+ "lip-sync": "generate_video",
5162
6555
  // video-enhance (FLUX.3 draft-enhance): the same generate_video job; the fal
5163
6556
  // provider sends the upstream draft's cache bundle instead of frames.
5164
6557
  "video-enhance": "generate_video",
@@ -5247,26 +6640,28 @@ function documentToDefinition(doc, opts = {}) {
5247
6640
  ...n.default !== void 0 ? { default: n.default } : {}
5248
6641
  }));
5249
6642
  let nodes = [];
5250
- for (const node of doc.nodes) {
5251
- if (node.kind !== "task") continue;
5252
- const { task } = node;
6643
+ const elementOfSource = /* @__PURE__ */ new Map();
6644
+ const referencesRefused = /* @__PURE__ */ new Set();
6645
+ for (const node2 of doc.nodes) {
6646
+ if (node2.kind !== "task") continue;
6647
+ const { task } = node2;
5253
6648
  if (taskExecution(task) === null) {
5254
6649
  issues.push({
5255
6650
  code: "not_runnable",
5256
- nodeId: node.id,
5257
- message: `Node "${node.id}" (${task}) is not runnable yet.`
6651
+ nodeId: node2.id,
6652
+ message: `Node "${node2.id}" (${task}) is not runnable yet.`
5258
6653
  });
5259
6654
  continue;
5260
6655
  }
5261
- if (node.model.length === 0) {
6656
+ if (node2.model.length === 0) {
5262
6657
  issues.push({
5263
6658
  code: "no_model",
5264
- nodeId: node.id,
5265
- message: `Node "${node.id}" needs a model.`
6659
+ nodeId: node2.id,
6660
+ message: `Node "${node2.id}" needs a model.`
5266
6661
  });
5267
6662
  }
5268
6663
  const inputs = {};
5269
- const wires = incoming.get(node.id) ?? [];
6664
+ const wires = incoming.get(node2.id) ?? [];
5270
6665
  const textWire = wires.find((e) => e.port === "text");
5271
6666
  let promptMissing = false;
5272
6667
  if (taskNeedsPrompt(task)) {
@@ -5284,15 +6679,15 @@ function documentToDefinition(doc, opts = {}) {
5284
6679
  path: portBinding(task, "text").path
5285
6680
  };
5286
6681
  } else {
5287
- const text = node.prompt.trim();
6682
+ const text = node2.prompt.trim();
5288
6683
  if (text.length > 0) inputs[key] = { kind: "literal", value: text };
5289
6684
  }
5290
6685
  if (!(key in inputs) && taskRequiresPrompt(task)) {
5291
6686
  promptMissing = true;
5292
6687
  issues.push({
5293
6688
  code: "prompt_required",
5294
- nodeId: node.id,
5295
- message: `Node "${node.id}" (${task}) needs a prompt.`
6689
+ nodeId: node2.id,
6690
+ message: `Node "${node2.id}" (${task}) needs a prompt.`
5296
6691
  });
5297
6692
  }
5298
6693
  }
@@ -5305,17 +6700,17 @@ function documentToDefinition(doc, opts = {}) {
5305
6700
  }
5306
6701
  for (const [port, portWires] of byPort) {
5307
6702
  const b = portBinding(task, port);
5308
- const cardinality = portCardinality(task, port, node.model);
5309
- const keyframes = port === "image" && task === "image-to-video" && modelAcceptsKeyframes(node.model);
6703
+ const cardinality = portCardinality(task, port, node2.model);
6704
+ const keyframes = port === "image" && task === "image-to-video" && modelAcceptsKeyframes(node2.model);
5310
6705
  const references = port === "reference";
5311
- const listKey = orderedPortKey(task, port, 0, node.model) ?? b.key;
6706
+ const listKey = orderedPortKey(task, port, 0, node2.model) ?? b.key;
5312
6707
  const items2 = [];
5313
6708
  const itemSources = [];
5314
6709
  let uploading = false;
5315
6710
  for (const [ordinal, e] of portWires.entries()) {
5316
6711
  const source = byId.get(e.source);
5317
6712
  const single = !keyframes && !references && (cardinality !== "many" || portWires.length === 1);
5318
- const key = orderedPortKey(task, port, ordinal, node.model) ?? b.key;
6713
+ const key = orderedPortKey(task, port, ordinal, node2.model) ?? b.key;
5319
6714
  const wrap = single && b.wrap === "array";
5320
6715
  let item = null;
5321
6716
  if (source.kind === "image-source") {
@@ -5323,8 +6718,8 @@ function documentToDefinition(doc, opts = {}) {
5323
6718
  if (!isUsableSourceUrl(url)) {
5324
6719
  issues.push({
5325
6720
  code: "source_uploading",
5326
- nodeId: node.id,
5327
- message: `Image source for "${node.id}" is still uploading; wait for it to finish.`
6721
+ nodeId: node2.id,
6722
+ message: `Image source for "${node2.id}" is still uploading; wait for it to finish.`
5328
6723
  });
5329
6724
  uploading = true;
5330
6725
  continue;
@@ -5335,8 +6730,8 @@ function documentToDefinition(doc, opts = {}) {
5335
6730
  if (!isUsableSourceUrl(clip)) {
5336
6731
  issues.push({
5337
6732
  code: "source_uploading",
5338
- nodeId: node.id,
5339
- message: `Video source for "${node.id}" is still uploading; wait for it to finish.`
6733
+ nodeId: node2.id,
6734
+ message: `Video source for "${node2.id}" is still uploading; wait for it to finish.`
5340
6735
  });
5341
6736
  uploading = true;
5342
6737
  continue;
@@ -5355,20 +6750,21 @@ function documentToDefinition(doc, opts = {}) {
5355
6750
  }
5356
6751
  }
5357
6752
  if (references && !uploading && items2.length > 0) {
5358
- const limits = modelCharacterReferences(node.model);
6753
+ const limits = modelCharacterReferences(node2.model);
5359
6754
  const grouped = limits ? referenceElementsFor(
5360
6755
  itemSources,
5361
- node.settings,
6756
+ node2.settings,
5362
6757
  limits
5363
6758
  ) : {
5364
6759
  ok: false,
5365
- reason: `${node.model || "this model"} takes no character references`
6760
+ reason: `${node2.model || "this model"} takes no character references`
5366
6761
  };
5367
6762
  if (grouped.ok) {
5368
6763
  inputs[listKey] = {
5369
6764
  kind: "list",
5370
6765
  items: grouped.order.map((i) => items2[i])
5371
6766
  };
6767
+ elementOfSource.set(node2.id, new Map(grouped.order.map((i, k) => [itemSources[i], grouped.elements[k]])));
5372
6768
  inputs.referenceElementIndexes = {
5373
6769
  kind: "literal",
5374
6770
  value: grouped.elements
@@ -5376,9 +6772,10 @@ function documentToDefinition(doc, opts = {}) {
5376
6772
  } else {
5377
6773
  issues.push({
5378
6774
  code: "character_references",
5379
- nodeId: node.id,
5380
- message: `Node "${node.id}": ${grouped.reason}`
6775
+ nodeId: node2.id,
6776
+ message: `Node "${node2.id}": ${grouped.reason}`
5381
6777
  });
6778
+ referencesRefused.add(node2.id);
5382
6779
  }
5383
6780
  continue;
5384
6781
  }
@@ -5387,7 +6784,7 @@ function documentToDefinition(doc, opts = {}) {
5387
6784
  if (keyframes && !uploading && items2.length > 0) {
5388
6785
  const positions = keyframePositionsFor(
5389
6786
  portWires.map((e) => e.source),
5390
- node.settings
6787
+ node2.settings
5391
6788
  );
5392
6789
  if (positions.ok) {
5393
6790
  inputs.keyframeFrameIndexes = {
@@ -5397,30 +6794,48 @@ function documentToDefinition(doc, opts = {}) {
5397
6794
  } else {
5398
6795
  issues.push({
5399
6796
  code: "keyframe_positions",
5400
- nodeId: node.id,
5401
- message: `Node "${node.id}": ${positions.reason}`
6797
+ nodeId: node2.id,
6798
+ message: `Node "${node2.id}": ${positions.reason}`
5402
6799
  });
5403
6800
  }
5404
6801
  }
5405
6802
  }
5406
- for (const [key, binding] of Object.entries(node.bakedInputs))
5407
- if (!(key in inputs)) inputs[key] = binding;
6803
+ const imagesWired = "inputImages" in inputs;
6804
+ for (const [key, binding] of Object.entries(node2.bakedInputs)) {
6805
+ if (key in inputs) continue;
6806
+ if (key === "options" && binding.kind === "literal") {
6807
+ const kept = sendableOptions(binding.value, tryGetModel2(node2.model));
6808
+ inputs[key] = kept === binding.value ? binding : { kind: "literal", value: kept };
6809
+ } else inputs[key] = binding;
6810
+ }
5408
6811
  if (task === "image-to-video" && "referenceImageUrls" in inputs && !("inputImageUrl" in inputs)) {
5409
6812
  issues.push({
5410
6813
  code: "character_references",
5411
- nodeId: node.id,
5412
- message: `Node "${node.id}": character references need a start frame; wire one into the image port.`
6814
+ nodeId: node2.id,
6815
+ message: `Node "${node2.id}": character references need a start frame; wire one into the image port.`
5413
6816
  });
5414
6817
  }
5415
6818
  if (Object.keys(inputs).length === 0 && !promptMissing) {
5416
6819
  issues.push({
5417
6820
  code: "no_inputs",
5418
- nodeId: node.id,
5419
- message: `Node "${node.id}" (${task}) needs an input: wire in an upstream asset or type a prompt.`
6821
+ nodeId: node2.id,
6822
+ message: `Node "${node2.id}" (${task}) needs an input: wire in an upstream asset or type a prompt.`
5420
6823
  });
5421
6824
  }
5422
- Object.assign(inputs, settingsBindings(task, node.settings));
5423
- nodes.push({ id: node.id, task, model: node.model, inputs });
6825
+ Object.assign(inputs, settingsBindings(task, sendableSettings(node2.settings, tryGetModel2(node2.model))));
6826
+ const named = castSettingOf(task, node2.settings);
6827
+ const { own } = named;
6828
+ let cast = named.cast;
6829
+ if (task === "image-to-video" && cast.length > 0 && referencesRefused.has(node2.id)) cast = [];
6830
+ else if (task === "image-to-video" && cast.length > 0) {
6831
+ const placed = castByElement(cast, elementOfSource.get(node2.id) ?? /* @__PURE__ */ new Map());
6832
+ if (placed.ok) cast = placed.cast;
6833
+ else {
6834
+ issues.push({ code: "character_references", nodeId: node2.id, message: `Node "${node2.id}": ${placed.reason}` });
6835
+ cast = [];
6836
+ }
6837
+ }
6838
+ nodes.push({ id: node2.id, task, model: node2.model, inputs, ...cast.length > 0 ? { cast } : {}, ...own ? { castOwn: true } : {}, ...cast.length > 0 && imagesWired ? { imagesWired: true } : {} });
5424
6839
  }
5425
6840
  if (scope) {
5426
6841
  const projected = new Set(nodes.map((n) => n.id));
@@ -5469,13 +6884,19 @@ function documentToDefinition(doc, opts = {}) {
5469
6884
  }
5470
6885
 
5471
6886
  // src/characterSheet.ts
6887
+ var OVERVIEW_CATEGORY = "overview";
6888
+ var OVERVIEW_ASPECT_RATIO = "21:9";
6889
+ var OVERVIEW_RESOLUTION = "4K";
5472
6890
  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.";
5473
- var NEUTRAL_STUDIO = "Plain light-gray seamless studio background, no props, no text, no watermark, photorealistic, sharp focus.";
6891
+ 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.";
6892
+ 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.';
6893
+ 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.";
6894
+ 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.";
5474
6895
  var WARDROBE_STANDARD_PHRASE = "plain heather-gray crew-neck t-shirt";
5475
6896
  var WARDROBE_INSTRUCTION = `Wardrobe: the character is wearing a ${WARDROBE_STANDARD_PHRASE}, unbranded, with no logos, graphics, prints, or patterns.`;
5476
- 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.`;
6897
+ 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.`;
5477
6898
  function wardrobeInstructionForCategory(category) {
5478
- return category === "full-body" ? FULL_BODY_WARDROBE_INSTRUCTION : WARDROBE_INSTRUCTION;
6899
+ return category === "full-body" || category === "back" ? FULL_BODY_WARDROBE_INSTRUCTION : WARDROBE_INSTRUCTION;
5479
6900
  }
5480
6901
  function identityAnchor(description) {
5481
6902
  return `Character identity (keep identical in every view): ${description.trim()}`;
@@ -5491,30 +6912,49 @@ function seedFacePrompt(description) {
5491
6912
  ].join("\n\n");
5492
6913
  }
5493
6914
  var VIEW_INSTRUCTION = {
5494
- "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.",
5495
- profile: "Full side profile (90 degree) view. Chest-up framing, square 1:1 crop. Even neutral studio lighting.",
5496
- "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.",
5497
- "close-up": "Tight front-facing close-up of the face, capturing fine facial detail. Square 1:1 crop. Even neutral studio lighting.",
5498
- "lighting-warm": "Front-facing head-and-shoulders portrait, square 1:1 crop, under warm golden-hour key lighting.",
5499
- "lighting-cool": "Front-facing head-and-shoulders portrait, square 1:1 crop, under cool blue-toned key lighting."
6915
+ "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.",
6916
+ "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.",
6917
+ "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.",
6918
+ "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.",
6919
+ "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.",
6920
+ 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."
5500
6921
  };
5501
6922
  function turnaroundViewPrompt(view, seedDescription) {
5502
6923
  return [
5503
6924
  identityAnchor(seedDescription),
5504
6925
  VIEW_INSTRUCTION[view],
6926
+ ...view === "back" ? [CHAINED_BACK_INPUTS_INSTRUCTION] : [],
6927
+ SCREEN_SIDE_INSTRUCTION,
6928
+ TURNAROUND_CAMERA_INSTRUCTION,
6929
+ // View strings mirror the freeze categories, so the wardrobe line keys off
6930
+ // the view directly (head-to-toe views add trousers and shoes).
5505
6931
  wardrobeInstructionForCategory(view),
5506
6932
  NEUTRAL_STUDIO,
5507
6933
  IDENTITY_INSTRUCTION
5508
6934
  ].join("\n\n");
5509
6935
  }
6936
+ function overviewSheetPrompt(description) {
6937
+ return [
6938
+ "Create one clean photorealistic character turnaround sheet of the person in the reference image.",
6939
+ `Character identity: ${description.trim()}`,
6940
+ `${FULL_BODY_WARDROBE_INSTRUCTION} The same outfit in every column.`,
6941
+ "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.",
6942
+ "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.",
6943
+ "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.",
6944
+ "Same camera height for every full body, same crop for every portrait, no perspective distortion, photorealistic studio lighting, sharp detail.",
6945
+ "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.",
6946
+ IDENTITY_INSTRUCTION
6947
+ ].join("\n\n");
6948
+ }
5510
6949
  var CHARACTER_SHEET_NODES = [
5511
6950
  { nodeId: "seed", param: "seedPrompt", category: "face", label: "Face" },
5512
- { nodeId: "view-three-quarter", param: "threeQuarterPrompt", category: "three-quarter", label: "Three-quarter", view: "three-quarter" },
5513
- { nodeId: "view-profile", param: "profilePrompt", category: "profile", label: "Profile", view: "profile" },
5514
- { nodeId: "view-full-body", param: "fullBodyPrompt", category: "full-body", label: "Full body", view: "full-body" },
5515
- { nodeId: "view-close-up", param: "closeUpPrompt", category: "close-up", label: "Close-up", view: "close-up" },
5516
- { nodeId: "view-lighting-warm", param: "lightingWarmPrompt", category: "lighting-warm", label: "Warm lighting", view: "lighting-warm" },
5517
- { nodeId: "view-lighting-cool", param: "lightingCoolPrompt", category: "lighting-cool", label: "Cool lighting", view: "lighting-cool" }
6951
+ { nodeId: "view-full-body", param: "fullBodyPrompt", category: "full-body", label: "Front", view: "full-body" },
6952
+ { nodeId: "view-three-quarter-left", param: "threeQuarterLeftPrompt", category: "three-quarter-left", label: "Turned left", view: "three-quarter-left" },
6953
+ { nodeId: "view-profile-left", param: "profileLeftPrompt", category: "profile-left", label: "Profile left", view: "profile-left" },
6954
+ { nodeId: "view-profile-right", param: "profileRightPrompt", category: "profile-right", label: "Profile right", view: "profile-right" },
6955
+ { nodeId: "view-three-quarter-right", param: "threeQuarterRightPrompt", category: "three-quarter-right", label: "Turned right", view: "three-quarter-right" },
6956
+ { nodeId: "view-back", param: "backPrompt", category: "back", label: "Back", view: "back" },
6957
+ { nodeId: "overview", param: "overviewPrompt", category: OVERVIEW_CATEGORY, label: "Overview", overview: true }
5518
6958
  ];
5519
6959
  var MINT_REFERENCE_CATEGORIES = Object.fromEntries(
5520
6960
  CHARACTER_SHEET_NODES.map((n) => [n.nodeId, n.category])
@@ -5524,14 +6964,15 @@ function categoryForNode(nodeId) {
5524
6964
  }
5525
6965
  function buildCharacterSheetParams(description) {
5526
6966
  const params = {};
5527
- for (const node of CHARACTER_SHEET_NODES) {
5528
- params[node.param] = node.view ? turnaroundViewPrompt(node.view, description) : seedFacePrompt(description);
6967
+ for (const node2 of CHARACTER_SHEET_NODES) {
6968
+ params[node2.param] = node2.view ? turnaroundViewPrompt(node2.view, description) : node2.overview ? overviewSheetPrompt(description) : seedFacePrompt(description);
5529
6969
  }
5530
6970
  return params;
5531
6971
  }
5532
6972
  var CHARACTER_SHEET_ID = "character-sheet";
5533
6973
  var SEED_MODEL = "fal/nano-banana-2";
5534
6974
  var VIEW_MODEL = "fal/nano-banana-2-edit";
6975
+ var OVERVIEW_MODEL = VIEW_MODEL;
5535
6976
  function viewNode(n, aspectRatio) {
5536
6977
  return {
5537
6978
  id: n.nodeId,
@@ -5544,6 +6985,7 @@ function viewNode(n, aspectRatio) {
5544
6985
  }
5545
6986
  };
5546
6987
  }
6988
+ var node = (id) => CHARACTER_SHEET_NODES.find((n) => n.nodeId === id);
5547
6989
  var CHARACTER_SHEET_DEFINITION = {
5548
6990
  version: { schema: 1 },
5549
6991
  id: CHARACTER_SHEET_ID,
@@ -5564,16 +7006,47 @@ var CHARACTER_SHEET_DEFINITION = {
5564
7006
  aspectRatio: { kind: "literal", value: "1:1" }
5565
7007
  }
5566
7008
  },
5567
- ...CHARACTER_SHEET_NODES.filter((n) => n.view !== void 0).map(
5568
- (n) => viewNode(n, n.category === "full-body" ? "3:4" : "1:1")
5569
- )
7009
+ viewNode(node("view-full-body"), "3:4"),
7010
+ viewNode(node("view-three-quarter-left"), "1:1"),
7011
+ viewNode(node("view-profile-left"), "1:1"),
7012
+ viewNode(node("view-profile-right"), "1:1"),
7013
+ viewNode(node("view-three-quarter-right"), "1:1"),
7014
+ // The back turns the front full body round, with the seed first as its
7015
+ // identity image ([face, full body]; its prompt says which is which).
7016
+ {
7017
+ id: "view-back",
7018
+ task: "image-edit",
7019
+ model: VIEW_MODEL,
7020
+ inputs: {
7021
+ prompt: { kind: "param", name: "backPrompt" },
7022
+ inputImages: {
7023
+ kind: "list",
7024
+ items: [
7025
+ { kind: "ref", node: "seed", path: "url" },
7026
+ { kind: "ref", node: "view-full-body", path: "url" }
7027
+ ]
7028
+ },
7029
+ aspectRatio: { kind: "literal", value: "3:4" }
7030
+ }
7031
+ },
7032
+ {
7033
+ id: "overview",
7034
+ task: "image-edit",
7035
+ model: OVERVIEW_MODEL,
7036
+ inputs: {
7037
+ prompt: { kind: "param", name: "overviewPrompt" },
7038
+ inputImages: { kind: "ref", node: "seed", path: "url", wrap: "array" },
7039
+ aspectRatio: { kind: "literal", value: OVERVIEW_ASPECT_RATIO },
7040
+ imageSize: { kind: "literal", value: OVERVIEW_RESOLUTION }
7041
+ }
7042
+ }
5570
7043
  ]
5571
7044
  };
5572
7045
  function characterSheetDefinition(overrides) {
5573
7046
  const def = structuredClone(CHARACTER_SHEET_DEFINITION);
5574
7047
  if (overrides?.seedModel || overrides?.viewModel) {
5575
7048
  def.nodes = def.nodes.map(
5576
- (node) => node.id === "seed" ? { ...node, model: overrides.seedModel ?? node.model } : { ...node, model: overrides.viewModel ?? node.model }
7049
+ (node2) => node2.id === "seed" ? { ...node2, model: overrides.seedModel ?? node2.model } : { ...node2, model: overrides.viewModel ?? node2.model }
5577
7050
  );
5578
7051
  }
5579
7052
  return def;
@@ -5753,13 +7226,20 @@ function buildCharacterSwapDefinition(input) {
5753
7226
  ]
5754
7227
  };
5755
7228
  }
5756
- var CHARACTER_REFERENCE_PREFERENCE = ["full-body", "three-quarter", "face"];
7229
+ var CHARACTER_REFERENCE_PREFERENCE = [
7230
+ "full-body",
7231
+ "three-quarter-left",
7232
+ "three-quarter-right",
7233
+ "three-quarter",
7234
+ "face"
7235
+ ];
7236
+ var NEVER_AUTOMATIC = /* @__PURE__ */ new Set(["back", "overview"]);
5757
7237
  function pickCharacterReferenceUrl(references) {
5758
7238
  for (const category of CHARACTER_REFERENCE_PREFERENCE) {
5759
7239
  const hit = references.find((r) => r.category === category && typeof r.url === "string" && r.url.length > 0);
5760
7240
  if (hit) return { url: hit.url, category };
5761
7241
  }
5762
- const any = references.find((r) => typeof r.url === "string" && r.url.length > 0);
7242
+ const any = references.find((r) => typeof r.url === "string" && r.url.length > 0 && !NEVER_AUTOMATIC.has(r.category));
5763
7243
  return any ? { url: any.url, category: any.category } : null;
5764
7244
  }
5765
7245
 
@@ -5795,7 +7275,7 @@ function parseDocument(raw, what) {
5795
7275
  }
5796
7276
  return r.data;
5797
7277
  }
5798
- var OpsSchema = z6.array(OpSchema);
7278
+ var OpsSchema = z6.array(OpSchema).max(MAX_PATCH_OPS * 20);
5799
7279
  function parseOps(raw, what) {
5800
7280
  const r = OpsSchema.safeParse(raw);
5801
7281
  if (!r.success) {
@@ -5826,32 +7306,32 @@ function wireCounts(doc) {
5826
7306
  }
5827
7307
  return counts;
5828
7308
  }
5829
- function summarizeNode(node, wires) {
5830
- const base = { id: node.id, kind: node.kind, wires: { ...wires } };
5831
- if (node.label !== void 0) base.label = node.label;
5832
- switch (node.kind) {
7309
+ function summarizeNode(node2, wires) {
7310
+ const base = { id: node2.id, kind: node2.kind, wires: { ...wires } };
7311
+ if (node2.label !== void 0) base.label = node2.label;
7312
+ switch (node2.kind) {
5833
7313
  case "task":
5834
- base.task = node.task;
5835
- base.model = node.model;
5836
- base.prompt = clipText(node.prompt);
5837
- base.promptLength = node.prompt.length;
5838
- if (node.activeGeneration !== void 0) base.activeGeneration = node.activeGeneration;
7314
+ base.task = node2.task;
7315
+ base.model = node2.model;
7316
+ base.prompt = clipText(node2.prompt);
7317
+ base.promptLength = node2.prompt.length;
7318
+ if (node2.activeGeneration !== void 0) base.activeGeneration = node2.activeGeneration;
5839
7319
  break;
5840
7320
  case "prompt-source":
5841
- base.prompt = clipText(node.text);
5842
- base.promptLength = node.text.length;
7321
+ base.prompt = clipText(node2.text);
7322
+ base.promptLength = node2.text.length;
5843
7323
  break;
5844
7324
  case "image-source":
5845
- base.imageUrl = clipText(node.imageUrl);
7325
+ base.imageUrl = clipText(node2.imageUrl);
5846
7326
  break;
5847
7327
  case "video-source":
5848
- base.videoUrl = clipText(node.videoUrl);
7328
+ base.videoUrl = clipText(node2.videoUrl);
5849
7329
  break;
5850
7330
  case "input":
5851
- base.name = node.name;
5852
- base.type = node.type;
5853
- base.required = node.required;
5854
- if (node.cardinality !== void 0) base.cardinality = node.cardinality;
7331
+ base.name = node2.name;
7332
+ base.type = node2.type;
7333
+ base.required = node2.required;
7334
+ if (node2.cardinality !== void 0) base.cardinality = node2.cardinality;
5855
7335
  break;
5856
7336
  }
5857
7337
  return base;
@@ -5884,8 +7364,8 @@ function affectedNodes(doc, ids) {
5884
7364
  const wires = wireCounts(doc);
5885
7365
  const byId = new Map(doc.nodes.map((n) => [n.id, n]));
5886
7366
  return ids.map((id) => {
5887
- const node = byId.get(id);
5888
- return node ? summarizeNode(node, wires.get(id) ?? { in: 0, out: 0 }) : { id, removed: true };
7367
+ const node2 = byId.get(id);
7368
+ return node2 ? summarizeNode(node2, wires.get(id) ?? { in: 0, out: 0 }) : { id, removed: true };
5889
7369
  });
5890
7370
  }
5891
7371
 
@@ -6281,6 +7761,8 @@ var ID = /^[A-Za-z0-9_][A-Za-z0-9_.:-]{0,127}$/;
6281
7761
  var CompositionIdSchema = z22.string().regex(ID, "an id is letters, digits and _ . : -");
6282
7762
  var COLOR_ROLE = z22.string().regex(/^[a-z0-9][a-z0-9-]{0,31}$/, "a colour is named by its kit id");
6283
7763
  var unit = z22.number().min(0).max(1);
7764
+ var STUDIO_DEFAULT_FONT_ROLE = "studio-default";
7765
+ var TEXT_FONT_ROLES = [...BRAND_KIT_FONT_ROLES, STUDIO_DEFAULT_FONT_ROLE];
6284
7766
  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");
6285
7767
  var TimingShape = {
6286
7768
  start: z22.number().min(0).optional(),
@@ -6292,7 +7774,7 @@ var TextOverlaySchema = z22.object({
6292
7774
  box: BoxSchema,
6293
7775
  text: z22.string().min(1, "a text overlay needs text").max(MAX_OVERLAY_TEXT),
6294
7776
  styleRole: z22.enum(BRAND_KIT_TYPE_ROLES),
6295
- fontRole: z22.enum(BRAND_KIT_FONT_ROLES),
7777
+ fontRole: z22.enum(TEXT_FONT_ROLES),
6296
7778
  weight: z22.number().int().min(100).max(900),
6297
7779
  italic: z22.boolean(),
6298
7780
  colorRole: COLOR_ROLE,
@@ -6352,7 +7834,9 @@ var CompositionDocumentSchema = z22.object({
6352
7834
  brandSlug: z22.string().min(1).max(64),
6353
7835
  /** The kit version the document was last edited against; a newer kit is worth a look before rendering. */
6354
7836
  kitVersionAtEdit: z22.number().int().nonnegative(),
6355
- items: z22.array(ItemSchema),
7837
+ // The larger of the two kinds' item caps, checked before any item is
7838
+ // parsed; the per-kind count is enforced by the integrity check below.
7839
+ items: z22.array(ItemSchema).max(Math.max(MAX_REEL_CLIPS, MAX_CAROUSEL_SLIDES)),
6356
7840
  /** Overlays across the whole reel (a logo bug, an end card line). Always empty on a carousel. */
6357
7841
  reelOverlays: z22.array(OverlaySchema).max(MAX_OVERLAYS_PER_ITEM)
6358
7842
  }).strict();
@@ -6507,7 +7991,7 @@ var studioListAssets = defineTool({
6507
7991
  });
6508
7992
  var studioBrandKitGet = defineTool({
6509
7993
  name: "studio_brand_kit_get",
6510
- 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.",
7994
+ 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).',
6511
7995
  inputSchema: { brandSlug: z9.string().min(1).describe("The brand slug, as studio_create_brand made it.") },
6512
7996
  handler: async (args, ctx) => {
6513
7997
  const { kit } = await ctx.client.getBrandKit(args.brandSlug);
@@ -6541,7 +8025,7 @@ var studioCompositionDescribe = defineTool({
6541
8025
  shapes: {
6542
8026
  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)',
6543
8027
  clip: '{ id, type: "clip", assetId (a video asset of the project), trimIn, trimOut (seconds), overlays: [] }',
6544
- 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) }',
8028
+ 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) }',
6545
8029
  logo: '{ id, type: "logo", box, variant: "light"|"dark", start?, end? }',
6546
8030
  shape: '{ id, type: "shape", box, shape: "rect"|"pill", colorRole, opacity, start?, end? }'
6547
8031
  },
@@ -7072,6 +8556,7 @@ var studioPromptsDelete = defineTool({
7072
8556
  var PROMPT_TOOLS = [studioPromptsList, studioPromptsSave, studioPromptsDelete];
7073
8557
 
7074
8558
  // src/tools.ts
8559
+ var MAX_REFERENCE_TAGS = 50;
7075
8560
  var slug = z12.string().regex(/^[a-z0-9-]+$/, "lowercase letters, numbers and hyphens only").describe("URL-safe identifier: lowercase letters, numbers, hyphens.");
7076
8561
  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.");
7077
8562
  var httpUrl = z12.string().url().refine((u) => /^https?:\/\//i.test(u), "must be an http(s) URL");
@@ -7173,6 +8658,9 @@ var studioGenerateImage = defineTool({
7173
8658
  candidateCount: z12.number().int().min(1).max(4).optional().describe(
7174
8659
  "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."
7175
8660
  ),
8661
+ variety: z12.enum(["varied", "same"]).optional().describe(
8662
+ '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.'
8663
+ ),
7176
8664
  wait: z12.boolean().default(true).describe("Poll until the job finishes (default true)."),
7177
8665
  waitSeconds
7178
8666
  },
@@ -7183,6 +8671,7 @@ var studioGenerateImage = defineTool({
7183
8671
  if (args.imageSize) settings.imageSize = args.imageSize;
7184
8672
  if (args.seed !== void 0) settings.seed = args.seed;
7185
8673
  if (args.candidateCount !== void 0) settings.candidateCount = args.candidateCount;
8674
+ if (args.variety) settings.variety = args.variety;
7186
8675
  const submitted = await ctx.client.generate({
7187
8676
  ...args.brandSlug ? { brandSlug: args.brandSlug } : {},
7188
8677
  ...args.brandMode ? { brandMode: args.brandMode } : {},
@@ -7194,7 +8683,8 @@ var studioGenerateImage = defineTool({
7194
8683
  });
7195
8684
  const plan = {
7196
8685
  ...submitted.candidates ? { candidates: submitted.candidates } : {},
7197
- ...typeof submitted.notice === "string" && submitted.notice.length > 0 ? { notice: submitted.notice } : {}
8686
+ ...typeof submitted.notice === "string" && submitted.notice.length > 0 ? { notice: submitted.notice } : {},
8687
+ ...submitted.variety === "varied" ? { variety: "varied" } : {}
7198
8688
  };
7199
8689
  if (!args.wait) return { jobId: submitted.jobId, kind: submitted.kind, status: "queued", ...plan };
7200
8690
  const done = await waitForJob(ctx.client, submitted.jobId, pollOpts(ctx, args.waitSeconds));
@@ -7316,8 +8806,8 @@ var studioRig3d = defineTool({
7316
8806
  });
7317
8807
  if (!args.wait) return { runId: started.runId, status: "queued" };
7318
8808
  const run = await waitForRun(ctx.client, started.runId, pollOpts(ctx, args.waitSeconds));
7319
- const node = run.nodeRuns.find((n) => n.nodeId === "rig");
7320
- const [rig, ...clips] = node?.results ?? [];
8809
+ const node2 = run.nodeRuns.find((n) => n.nodeId === "rig");
8810
+ const [rig, ...clips] = node2?.results ?? [];
7321
8811
  if (run.run.status !== "succeeded" || !rig?.url) {
7322
8812
  const failure = runFailureSummary(run);
7323
8813
  throw new Error(`Rig run ${started.runId} ended ${run.run.status}.${failure ? ` ${failure}.` : ""} Cost so far $${runCostUsd(run).toFixed(2)}.`);
@@ -7358,7 +8848,7 @@ var studioListCharacters = defineTool({
7358
8848
  });
7359
8849
  var studioGetCharacter = defineTool({
7360
8850
  name: "studio_get_character",
7361
- 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.",
8851
+ 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.",
7362
8852
  inputSchema: { slug },
7363
8853
  annotations: { readOnlyHint: true },
7364
8854
  handler: async (args, ctx) => {
@@ -7379,7 +8869,9 @@ var studioPromptEnhance = defineTool({
7379
8869
  name: z12.string().max(200).optional()
7380
8870
  })
7381
8871
  ).max(10).optional().describe("Every mention token of the prompt (at most 10). The returned mentions carry the names your company gave them."),
7382
- 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.'),
8872
+ 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.'),
8873
+ 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."),
8874
+ 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."),
7383
8875
  brandSlug: slug.optional().describe("Optional. A brand of your company whose style the rewrite should follow."),
7384
8876
  brandMode: z12.string().optional().describe('Optional brand mode (e.g. "hero"). Only meaningful with brandSlug.')
7385
8877
  },
@@ -7390,6 +8882,8 @@ var studioPromptEnhance = defineTool({
7390
8882
  target: args.target,
7391
8883
  ...args.mentions && args.mentions.length > 0 ? { mentions: args.mentions } : {},
7392
8884
  ...args.model ? { model: args.model } : {},
8885
+ ...args.startFrame ? { startFrame: true } : {},
8886
+ ...args.imageAttached ? { imageAttached: true } : {},
7393
8887
  ...args.brandSlug ? { brandSlug: args.brandSlug } : {},
7394
8888
  ...args.brandMode ? { brandMode: args.brandMode } : {}
7395
8889
  });
@@ -7426,7 +8920,7 @@ var studioCreateCharacter = defineTool({
7426
8920
  });
7427
8921
  var studioMintCharacter = defineTool({
7428
8922
  name: "studio_mint_character",
7429
- 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.",
8923
+ 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.",
7430
8924
  inputSchema: {
7431
8925
  projectId: z12.string().min(1).describe("Project id from studio_list_projects."),
7432
8926
  name: z12.string().min(1).describe("Display name."),
@@ -7455,7 +8949,9 @@ var studioMintCharacter = defineTool({
7455
8949
  ...args.visibility ? { visibility: args.visibility } : {}
7456
8950
  });
7457
8951
  const run = await waitForRun(ctx.client, started.runId, pollOpts(ctx, args.waitSeconds));
7458
- const views = CHARACTER_SHEET_NODES.map((n) => ({ ...n, url: nodeUrl(run, n.nodeId) }));
8952
+ const outputs = CHARACTER_SHEET_NODES.map((n) => ({ ...n, url: nodeUrl(run, n.nodeId) }));
8953
+ const views = outputs.filter((v) => !v.overview);
8954
+ const overview = outputs.find((v) => v.overview);
7459
8955
  const missing = views.filter((v) => !v.url);
7460
8956
  if (missing.length > 0) {
7461
8957
  const failure = runFailureSummary(run);
@@ -7472,7 +8968,7 @@ var studioMintCharacter = defineTool({
7472
8968
  ...args.defaultModel !== void 0 ? { defaultModel: args.defaultModel } : {}
7473
8969
  });
7474
8970
  const references = [];
7475
- for (const view of views) {
8971
+ for (const view of overview?.url ? [...views, overview] : views) {
7476
8972
  const file = await ctx.client.downloadUrl(view.url);
7477
8973
  const category = MINT_REFERENCE_CATEGORIES[view.nodeId];
7478
8974
  const { reference } = await ctx.client.uploadCharacterReference(args.slug, {
@@ -7486,8 +8982,9 @@ var studioMintCharacter = defineTool({
7486
8982
  slug: character.slug,
7487
8983
  name: character.name,
7488
8984
  runId: started.runId,
7489
- referenceCount: references.length,
8985
+ referenceCount: references.filter((r) => r.category !== OVERVIEW_CATEGORY).length,
7490
8986
  references,
8987
+ overview: overview?.url ? { made: true } : { made: false, note: "The overview image failed; the character and its seven reference images were created without it." },
7491
8988
  costUsd: runCostUsd(run)
7492
8989
  };
7493
8990
  }
@@ -7523,7 +9020,7 @@ var studioUploadBrandReference = defineTool({
7523
9020
  source: z12.string().min(1).describe("Local file path or http(s) URL of an image."),
7524
9021
  category: z12.string().optional().describe('Library category, default "general".'),
7525
9022
  label: z12.string().optional().describe("Optional file name / label."),
7526
- tags: z12.array(z12.string()).optional(),
9023
+ tags: z12.array(z12.string()).max(MAX_REFERENCE_TAGS).optional(),
7527
9024
  score: z12.number().int().min(1).max(10).optional()
7528
9025
  },
7529
9026
  handler: async (args, ctx) => {
@@ -7538,7 +9035,8 @@ var studioUploadBrandReference = defineTool({
7538
9035
  return { reference };
7539
9036
  }
7540
9037
  });
7541
- var workflowDefinitionSchema = WorkflowDefinitionSchema.describe(
9038
+ var AgentDefinitionSchema = WorkflowDefinitionSchema.extend({ nodes: z12.array(WorkflowNodeSchema.omit({ cast: true, castOwn: true, imagesWired: true })).min(1).max(MAX_DOCUMENT_NODES) });
9039
+ var workflowDefinitionSchema = AgentDefinitionSchema.describe(
7542
9040
  `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.`
7543
9041
  );
7544
9042
  var studioRunWorkflow = defineTool({
@@ -7549,7 +9047,7 @@ var studioRunWorkflow = defineTool({
7549
9047
  definition: workflowDefinitionSchema.optional(),
7550
9048
  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."),
7551
9049
  params: z12.record(z12.string(), z12.unknown()).optional().describe("Values for the definition's params."),
7552
- nodeIds: z12.array(z12.string()).optional().describe("Run only this subset of nodes (requires an inline `definition` or a `savedId`)."),
9050
+ nodeIds: z12.array(z12.string()).max(MAX_DOCUMENT_NODES).optional().describe("Run only this subset of nodes (requires an inline `definition` or a `savedId`)."),
7553
9051
  upstreamGenerations: z12.record(z12.string(), z12.string()).optional().describe(
7554
9052
  '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.'
7555
9053
  ),
@@ -7892,7 +9390,7 @@ function registerTools(server, base) {
7892
9390
 
7893
9391
  // src/server.ts
7894
9392
  var SERVER_NAME = "lumitra-studio";
7895
- var SERVER_VERSION = "0.18.1";
9393
+ var SERVER_VERSION = "0.22.0";
7896
9394
  function createStudioMcpServer(opts = {}) {
7897
9395
  const config = opts.config ?? resolveConfig(opts.env ?? process.env);
7898
9396
  const client = new StudioClient(config, {