@marlinjai/studio-mcp 0.18.1 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -630,6 +630,26 @@ var ROUTES = [
630
630
  withReferences: { "1080p": "fal/kling-o3-pro-reference-to-video" }
631
631
  }
632
632
  },
633
+ {
634
+ kind: "video",
635
+ id: "route/gemini-omni",
636
+ label: "Gemini Omni 1.1 Flash (KIE, fal fallback)",
637
+ primary: "kie/gemini-omni-flash-1-1-image-to-video",
638
+ // fal renders every length KIE does (4 to 10 s in even steps) and the same
639
+ // sizes and shapes, from the same frame fields (2026-11-03). One difference:
640
+ // fal always renders sound with the clip, so a clip that falls back has it.
641
+ fallback: { start: "fal/gemini-omni-flash-1-1-image-to-video" }
642
+ },
643
+ {
644
+ kind: "video",
645
+ id: "route/minimax-h3",
646
+ label: "MiniMax H3 (KIE, fal fallback)",
647
+ primary: "kie/minimax-h3-image-to-video",
648
+ // fal renders KIE's sizes (768P and 2K) and lengths from 5 to 15 s from the
649
+ // same frame fields (2026-11-04); KIE also renders 4 s, which fal does not,
650
+ // so a 4 s clip has no fallback. fal always renders sound with the clip.
651
+ fallback: { start: "fal/minimax-h3-image-to-video" }
652
+ },
633
653
  {
634
654
  kind: "video",
635
655
  id: "route/seedance-2-0",
@@ -929,6 +949,71 @@ var CATALOG_ENTRIES = [
929
949
  description: "ByteDance Seedream 5 Pro edit via fal, up to 10 reference images, 1K or 2K.",
930
950
  capabilities: { resolutions: ["1K", "2K"], needsImageInput: true, maxInputImages: 10 }
931
951
  },
952
+ // ── fal.ai: Ideogram 4.5 Edit, precise local edits ─────────────────────
953
+ {
954
+ id: "fal/ideogram-4-5-edit",
955
+ provider: "fal",
956
+ modality: "image",
957
+ task: "image-edit",
958
+ label: "Ideogram 4.5 Edit (fal)",
959
+ // Measured 2026-11-04 on a series of edits of one portrait: the background
960
+ // held at a structural similarity (SSIM) of 0.9999 between successive
961
+ // edits, against 0.98 for Nano Banana 2 Edit, which reframed the shot on
962
+ // the first edit. Ideogram's first edit smoothed the face a little; after
963
+ // that the face held.
964
+ description: "Ideogram 4.5 in precise edit mode: changes what the prompt asks for (a garment, a prop, the background) and keeps every pixel it did not touch, so a series of edits keeps the shot. Image 1 is the image edited, up to 4 more are references, and the result keeps the shape of image 1. Quality low, medium or high.",
965
+ capabilities: {
966
+ // The tiers carry Ideogram's QUALITY (providers/fal.ts, `ideogramQuality`):
967
+ // 0.5K low, 1K medium (the default), 2K high. fal's very_low is not
968
+ // offered (decided 2026-11-04). Labelled as qualities
969
+ // wherever shown (`imageTierLabel`).
970
+ resolutions: ["0.5K", "1K", "2K"],
971
+ tierKind: "quality",
972
+ editsFirstImage: true,
973
+ needsImageInput: true,
974
+ maxInputImages: 5
975
+ }
976
+ },
977
+ // ── fal.ai: OpenAI GPT Image 2, text in images and exact edits ─────────
978
+ // Added 2026-11-04 (plan 2026-11-04-skool-prompting, item M2): the course
979
+ // Marlin follows names it the best model for rendering text (labels,
980
+ // packaging) and for edits that change only what was asked.
981
+ {
982
+ id: "fal/gpt-image-2",
983
+ provider: "fal",
984
+ modality: "image",
985
+ task: "text-to-image",
986
+ label: "GPT Image 2 (fal)",
987
+ description: "OpenAI GPT Image 2 via fal: the strongest at text inside the image (labels, packaging, signs, posters) and at following long, detailed prompts. Slower than Nano Banana. Quality low, medium or high, about 1 megapixel in every shape; prompts up to about 4000 characters of English (4000 bytes).",
988
+ capabilities: {
989
+ // The tiers carry GPT Image 2's QUALITY (providers/fal.ts,
990
+ // `tierQuality`): 0.5K low, 1K medium (the default), 2K high. The size
991
+ // follows the shape alone (`FAL_GPT_IMAGE_2_SIZE_BY_ASPECT`).
992
+ resolutions: ["0.5K", "1K", "2K"],
993
+ tierKind: "quality",
994
+ maxInputImages: 0
995
+ }
996
+ },
997
+ {
998
+ id: "fal/gpt-image-2-edit",
999
+ provider: "fal",
1000
+ modality: "image",
1001
+ task: "image-edit",
1002
+ label: "GPT Image 2 Edit (fal)",
1003
+ description: "OpenAI GPT Image 2 edit via fal: changes only what the prompt asks for and renders text and labels cleanly (packaging, signs). Studio sends the image to edit first and up to 7 references after it; say in the prompt what to change. The result takes the shape you pick: pick the source image's shape to keep it. Slower than Nano Banana. Quality low, medium or high, about 1 megapixel in every shape; prompts up to about 4000 characters of English (4000 bytes).",
1004
+ capabilities: {
1005
+ resolutions: ["0.5K", "1K", "2K"],
1006
+ tierKind: "quality",
1007
+ // fal's `image_urls` is a plain list with no field for the image
1008
+ // edited. Studio's convention: the image to edit goes first and the
1009
+ // mention prompt names it image 1, which is what lets the composer, the
1010
+ // generate route and the canvas refuse an edit with no image before
1011
+ // anything is admitted (`editSourceHold`).
1012
+ editsFirstImage: true,
1013
+ needsImageInput: true,
1014
+ maxInputImages: 8
1015
+ }
1016
+ },
932
1017
  {
933
1018
  id: "fal/flux-1-1-pro",
934
1019
  provider: "fal",
@@ -1214,7 +1299,7 @@ var CATALOG_ENTRIES = [
1214
1299
  modality: "video",
1215
1300
  task: "image-to-video",
1216
1301
  label: "Gemini Omni 1.1 Flash (KIE)",
1217
- description: "Google Gemini Omni 1.1 Flash via KIE, first-and-last-frame mode. A start frame and an optional end frame, 4, 6, 8 or 10 s, 720p to 4K, 16:9 or 9:16. KIE refuses registered characters in this mode, so identity comes from the frames alone. Accepted a minted character's photoreal stills on 2026-09-24 (set 9:16 for a portrait still: it defaults to 16:9 and crops). No fal equivalent.",
1302
+ description: "Google Gemini Omni 1.1 Flash via KIE, first-and-last-frame mode. A start frame and an optional end frame, 4, 6, 8 or 10 s, 720p to 4K, 16:9 or 9:16. KIE refuses registered characters in this mode, so identity comes from the frames alone. Accepted a minted character's photoreal stills on 2026-09-24 (set 9:16 for a portrait still: it defaults to 16:9 and crops).",
1218
1303
  capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1219
1304
  },
1220
1305
  {
@@ -1310,6 +1395,53 @@ var CATALOG_ENTRIES = [
1310
1395
  characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 7 }
1311
1396
  }
1312
1397
  },
1398
+ {
1399
+ id: "fal/gemini-omni-flash-1-1-image-to-video",
1400
+ provider: "fal",
1401
+ modality: "video",
1402
+ task: "image-to-video",
1403
+ label: "Gemini Omni 1.1 Flash (image-to-video)",
1404
+ description: "Google Gemini Omni 1.1 Flash via fal, the fallback for the KIE entry and the route that runs images of people. A start frame and an optional end frame, 3 to 10 s, 720p, 1080p or 4K, 16:9 or 9:16 (16:9 unless set, so set 9:16 for a portrait still), with audio included. No seed. Not yet tested with a minted character on fal (the KIE route accepted one).",
1405
+ // 8 s at fal's 720p default, the length and size the KIE entry renders.
1406
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1407
+ },
1408
+ {
1409
+ id: "fal/kling-3-0-standard-image-to-video",
1410
+ provider: "fal",
1411
+ modality: "video",
1412
+ task: "image-to-video",
1413
+ label: "Kling 3.0 Standard (image-to-video)",
1414
+ description: "Kuaishou Kling 3.0 Standard via fal, a model of its own next to Kling O3 (Kling 3.0 Omni). A start frame and an optional end frame, 3 to 15 s, in the start frame's shape at the tier's size, silent unless the job sets generateAudio. Takes a negative prompt, no seed. Not yet tested with a minted character.",
1415
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1416
+ },
1417
+ {
1418
+ id: "fal/kling-3-0-pro-image-to-video",
1419
+ provider: "fal",
1420
+ modality: "video",
1421
+ task: "image-to-video",
1422
+ label: "Kling 3.0 Pro (image-to-video)",
1423
+ description: "Kuaishou Kling 3.0 Pro via fal, a model of its own next to Kling O3 (Kling 3.0 Omni). A start frame and an optional end frame, 3 to 15 s, in the start frame's shape at the tier's size, silent unless the job sets generateAudio. Takes a negative prompt, no seed. Not yet tested with a minted character.",
1424
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1425
+ },
1426
+ {
1427
+ id: "fal/minimax-h3-image-to-video",
1428
+ provider: "fal",
1429
+ modality: "video",
1430
+ task: "image-to-video",
1431
+ label: "MiniMax H3 (image-to-video)",
1432
+ description: "MiniMax H3 via fal (the base model, not fal's post-trained H3 Max), the fallback for the KIE entry and the route that runs images of people. A start frame and an optional end frame, 5 to 15 s, 768p (the 720p setting), 2K (the 1080p setting, used unless set) or 4K, in the start frame's shape, always with sound. Takes a seed, no negative prompt. Rendered a 5 s test clip on 2026-11-04; not yet tested with a minted character on fal (the KIE route accepted one).",
1433
+ // 5 s at fal's 2K default.
1434
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1435
+ },
1436
+ {
1437
+ id: "fal/kling-4-0-image-to-video",
1438
+ provider: "fal",
1439
+ modality: "video",
1440
+ task: "image-to-video",
1441
+ label: "Kling 4.0 (image-to-video)",
1442
+ description: "Kuaishou Kling 4.0 via fal; not served by KIE. A start frame and an optional end frame, 3 to 30 s, 720p or 1080p (1080p unless set), in the start frame's shape, always with sound. No seed or negative prompt. fal also takes in-between keyframes and per-shot prompts, which Studio does not send yet. Rendered a 3 s test clip on 2026-11-03; not yet tested with a minted character.",
1443
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1444
+ },
1313
1445
  {
1314
1446
  id: "fal/ltx-2-5-fast-image-to-video",
1315
1447
  provider: "fal",
@@ -1663,6 +1795,18 @@ function routeEntry(id) {
1663
1795
  function tryGetModel(id) {
1664
1796
  return MODEL_CATALOG.find((m) => m.id === id) ?? routeEntry(id);
1665
1797
  }
1798
+ var ASPECT_RATIOS = [
1799
+ "1:1",
1800
+ "3:2",
1801
+ "2:3",
1802
+ "3:4",
1803
+ "4:3",
1804
+ "4:5",
1805
+ "5:4",
1806
+ "9:16",
1807
+ "16:9",
1808
+ "21:9"
1809
+ ];
1666
1810
  function omniReferencesPrompt(prompt, elements) {
1667
1811
  const parts = ["Image 1 is the exact scene and the first frame of the video: start the clip on it and keep its setting, framing and light."];
1668
1812
  let next = 2;
@@ -1993,6 +2137,12 @@ var KLING_26_I2V_ENDPOINT = "fal-ai/kling-video/v2.6/pro/image-to-video";
1993
2137
  var KLING_O3_STANDARD_I2V_ENDPOINT = "fal-ai/kling-video/o3/standard/image-to-video";
1994
2138
  var KLING_O3_PRO_I2V_ENDPOINT = "fal-ai/kling-video/o3/pro/image-to-video";
1995
2139
  var KLING_O3_I2V_ENDPOINTS = [KLING_O3_STANDARD_I2V_ENDPOINT, KLING_O3_PRO_I2V_ENDPOINT];
2140
+ var GEMINI_OMNI_11_I2V_ENDPOINT = "google/gemini-omni-flash/v1.1/image-to-video";
2141
+ var KLING_V3_STANDARD_I2V_ENDPOINT = "fal-ai/kling-video/v3/standard/image-to-video";
2142
+ var KLING_V3_PRO_I2V_ENDPOINT = "fal-ai/kling-video/v3/pro/image-to-video";
2143
+ var KLING_V3_I2V_ENDPOINTS = [KLING_V3_STANDARD_I2V_ENDPOINT, KLING_V3_PRO_I2V_ENDPOINT];
2144
+ var KLING_V4_I2V_ENDPOINT = "kling/v4/image-to-video";
2145
+ var MINIMAX_H3_I2V_ENDPOINT = "minimax/h3/image-to-video";
1996
2146
  var KLING_O3_PRO_R2V_ENDPOINT = "fal-ai/kling-video/o3/pro/reference-to-video";
1997
2147
  var FAL_CHARACTER_REFERENCE_LIMITS = {
1998
2148
  [KLING_O3_PRO_R2V_ENDPOINT]: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 7 }
@@ -2026,7 +2176,10 @@ var VIDEO_FIXED_RESOLUTION = {
2026
2176
  // Not a resolution the caller picks: Kling O3's tier sets the size.
2027
2177
  [KLING_O3_STANDARD_I2V_ENDPOINT]: "fixed",
2028
2178
  [KLING_O3_PRO_I2V_ENDPOINT]: "fixed",
2029
- [KLING_O3_PRO_R2V_ENDPOINT]: "fixed"
2179
+ [KLING_O3_PRO_R2V_ENDPOINT]: "fixed",
2180
+ // Kling 3.0 likewise: its tier sets the size.
2181
+ [KLING_V3_STANDARD_I2V_ENDPOINT]: "fixed",
2182
+ [KLING_V3_PRO_I2V_ENDPOINT]: "fixed"
2030
2183
  };
2031
2184
  var VIDEO_PINNED_DEFAULT_SECONDS = {
2032
2185
  [GROK_IMAGINE_I2V_ENDPOINT]: 5,
@@ -2041,6 +2194,13 @@ var VIDEO_PINNED_DEFAULT_SECONDS = {
2041
2194
  [KLING_O3_STANDARD_I2V_ENDPOINT]: 5,
2042
2195
  [KLING_O3_PRO_I2V_ENDPOINT]: 5,
2043
2196
  [KLING_O3_PRO_R2V_ENDPOINT]: 5,
2197
+ [GEMINI_OMNI_11_I2V_ENDPOINT]: 8,
2198
+ // fal's own default on Kling 3.0 and 4.0 (schemas read 2026-11-03).
2199
+ [KLING_V3_STANDARD_I2V_ENDPOINT]: 5,
2200
+ [KLING_V3_PRO_I2V_ENDPOINT]: 5,
2201
+ [KLING_V4_I2V_ENDPOINT]: 5,
2202
+ // fal's own default on MiniMax H3 (schema read 2026-11-04).
2203
+ [MINIMAX_H3_I2V_ENDPOINT]: 5,
2044
2204
  // LTX-2.5 defaults to "auto", a length nobody can price up front; 6 s is its
2045
2205
  // shortest clip on both tiers.
2046
2206
  [LTX_25_FAST_I2V_ENDPOINT]: 6,
@@ -2073,6 +2233,12 @@ var VIDEO_DEFAULT_RESOLUTION = {
2073
2233
  [GROK_IMAGINE_15_I2V_ENDPOINT]: "720p",
2074
2234
  // fal schema default: Wan 3.0 renders 1080p unless asked for less.
2075
2235
  [WAN_30_I2V_ENDPOINT]: "1080p",
2236
+ // fal schema default: Gemini Omni renders 720p, as on KIE.
2237
+ [GEMINI_OMNI_11_I2V_ENDPOINT]: "720p",
2238
+ // fal schema default: Kling 4.0 renders 1080p unless asked for 720p.
2239
+ [KLING_V4_I2V_ENDPOINT]: "1080p",
2240
+ // fal schema default: MiniMax H3 renders 2K (the canvas's 1080p) unless asked.
2241
+ [MINIMAX_H3_I2V_ENDPOINT]: "1080p",
2076
2242
  // fal schema default: LTX-2.5 renders 1080p unless asked for less.
2077
2243
  [LTX_25_FAST_I2V_ENDPOINT]: "1080p",
2078
2244
  [LTX_25_PRO_I2V_ENDPOINT]: "1080p"
@@ -2119,7 +2285,18 @@ var VIDEO_ALLOWED_VALUES = {
2119
2285
  aspectRatio: ["auto", "16:9", "9:16"],
2120
2286
  resolution: ["720p", "1080p"],
2121
2287
  durationSeconds: { values: [6, 8, 10] }
2122
- }
2288
+ },
2289
+ // fal also renders 360p, which the canvas does not offer.
2290
+ [GEMINI_OMNI_11_I2V_ENDPOINT]: {
2291
+ aspectRatio: ["16:9", "9:16"],
2292
+ resolution: ["720p", "1080p", "4k"],
2293
+ durationSeconds: { min: 3, max: 10 }
2294
+ },
2295
+ ...Object.fromEntries(KLING_V3_I2V_ENDPOINTS.map((e) => [e, { durationSeconds: { min: 3, max: 15 } }])),
2296
+ [KLING_V4_I2V_ENDPOINT]: { resolution: ["720p", "1080p"], durationSeconds: { min: 3, max: 30 } },
2297
+ // fal also renders 480P, which the canvas does not offer. Its shortest clip
2298
+ // is 5 s (KIE's is 4 s), so a 4 s job on the H3 route has no fal fallback.
2299
+ [MINIMAX_H3_I2V_ENDPOINT]: { resolution: ["720p", "1080p", "4k"], durationSeconds: { min: 5, max: 15 } }
2123
2300
  };
2124
2301
  var VIDEO_MAX_SECONDS_AT_RESOLUTION = {
2125
2302
  [LTX_25_FAST_I2V_ENDPOINT]: { "4k": 10 }
@@ -2175,13 +2352,26 @@ var VIDEO_UNSUPPORTED_PARAMS = {
2175
2352
  ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS.map((e) => [e, ["resolution", "aspectRatio", "seed", "negativePrompt"]])),
2176
2353
  // Its tier sets the size; it takes an aspect ratio, but no seed or negative prompt.
2177
2354
  [KLING_O3_PRO_R2V_ENDPOINT]: ["resolution", "seed", "negativePrompt"],
2178
- ...Object.fromEntries(LTX_25_I2V_ENDPOINTS.map((e) => [e, ["seed", "negativePrompt"]]))
2355
+ ...Object.fromEntries(LTX_25_I2V_ENDPOINTS.map((e) => [e, ["seed", "negativePrompt"]])),
2356
+ // Its schema declares no seed, negative prompt or audio switch: it always
2357
+ // renders audio, at no extra charge.
2358
+ [GEMINI_OMNI_11_I2V_ENDPOINT]: ["seed", "negativePrompt", "generateAudio"],
2359
+ // Kling 3.0: the tier sets the size and the start frame the shape; it takes a
2360
+ // negative prompt but no seed.
2361
+ ...Object.fromEntries(KLING_V3_I2V_ENDPOINTS.map((e) => [e, ["resolution", "aspectRatio", "seed"]])),
2362
+ // Kling 4.0 follows the start frame's shape and always renders sound.
2363
+ [KLING_V4_I2V_ENDPOINT]: ["aspectRatio", "seed", "negativePrompt", "generateAudio"],
2364
+ // MiniMax H3 follows the start frame's shape and always renders sound (a 5 s
2365
+ // test render of 2026-11-04 had a video and an audio track); it takes a seed.
2366
+ [MINIMAX_H3_I2V_ENDPOINT]: ["aspectRatio", "negativePrompt", "generateAudio"]
2179
2367
  };
2180
2368
  var VIDEO_AUDIO_SWITCH = {
2181
2369
  ...Object.fromEntries(VEO_ENDPOINTS.map((e) => [e, { default: false }])),
2182
2370
  [KLING_26_I2V_ENDPOINT]: { default: false },
2183
2371
  ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS.map((e) => [e, { default: false }])),
2184
2372
  [KLING_O3_PRO_R2V_ENDPOINT]: { default: false },
2373
+ // Kling 3.0 renders sound unless sent false; Studio sends it silent unless asked.
2374
+ ...Object.fromEntries(KLING_V3_I2V_ENDPOINTS.map((e) => [e, { default: false }])),
2185
2375
  "bytedance/seedance-2.5/image-to-video": { default: true },
2186
2376
  "bytedance/seedance-2.0/image-to-video": { default: true },
2187
2377
  [WAN_30_I2V_ENDPOINT]: { default: true },
@@ -2903,6 +3093,10 @@ function searchMeshyAnimations(query, limit = 25) {
2903
3093
  }
2904
3094
  return out;
2905
3095
  }
3096
+ var IMAGE_ASPECT_RATIOS = ASPECT_RATIOS.map((value) => ({
3097
+ value,
3098
+ label: value
3099
+ }));
2906
3100
  var PORT_TYPES = ["text", "image", "video", "mask", "mesh3d", "audio", "json", "reference"];
2907
3101
  var INPUT_PORT_TYPES = PORT_TYPES.filter(
2908
3102
  (p) => p !== "mask" && p !== "reference"
@@ -3033,13 +3227,14 @@ var TASK_PORTS = {
3033
3227
  function taskPorts(task) {
3034
3228
  return TASK_PORTS[task];
3035
3229
  }
3230
+ var MAX_JSON_ARRAY_ITEMS = 1e4;
3036
3231
  var JsonValueSchema = z.lazy(
3037
3232
  () => z.union([
3038
3233
  z.string(),
3039
3234
  z.number().finite(),
3040
3235
  z.boolean(),
3041
3236
  z.null(),
3042
- z.array(JsonValueSchema),
3237
+ z.array(JsonValueSchema).max(MAX_JSON_ARRAY_ITEMS),
3043
3238
  z.record(z.string(), JsonValueSchema)
3044
3239
  ])
3045
3240
  );
@@ -3047,7 +3242,7 @@ var JsonNonNullValueSchema = z.union([
3047
3242
  z.string(),
3048
3243
  z.number().finite(),
3049
3244
  z.boolean(),
3050
- z.array(JsonValueSchema),
3245
+ z.array(JsonValueSchema).max(MAX_JSON_ARRAY_ITEMS),
3051
3246
  z.record(z.string(), JsonValueSchema)
3052
3247
  ]);
3053
3248
  function toJsonValue(value, what = "value") {
@@ -3055,6 +3250,11 @@ function toJsonValue(value, what = "value") {
3055
3250
  if (!r.success) throw new TypeError(`${what} is not a JSON value: ${r.error.issues[0]?.message ?? "invalid"}`);
3056
3251
  return r.data;
3057
3252
  }
3253
+ var MAX_DOCUMENT_NODES = 2e3;
3254
+ var MAX_DEFINITION_PARAMS = 200;
3255
+ var MAX_CAST_MEMBERS = 100;
3256
+ var MAX_CAST_SOURCES = 100;
3257
+ var MAX_LIST_BINDING_ITEMS = 500;
3058
3258
  var WORKFLOW_SCHEMA_VERSION = 1;
3059
3259
  var SchemaVersionSchema = z2.object({
3060
3260
  schema: z2.number().int().positive()
@@ -3088,7 +3288,7 @@ var ListItemBindingSchema = z2.discriminatedUnion("kind", [
3088
3288
  ]);
3089
3289
  var ListBindingSchema = z2.object({
3090
3290
  kind: z2.literal("list"),
3091
- items: z2.array(ListItemBindingSchema)
3291
+ items: z2.array(ListItemBindingSchema).max(MAX_LIST_BINDING_ITEMS)
3092
3292
  });
3093
3293
  var BindingSchema = z2.discriminatedUnion("kind", [
3094
3294
  LiteralBindingSchema,
@@ -3101,12 +3301,38 @@ var RetryPolicySchema = z2.object({
3101
3301
  maxAttempts: z2.number().int().positive(),
3102
3302
  backoffMs: z2.number().int().nonnegative()
3103
3303
  });
3304
+ var CastMemberSchema = z2.object({
3305
+ kind: z2.enum(["character", "product", "location"]),
3306
+ id: z2.string().min(1),
3307
+ name: z2.string(),
3308
+ sources: z2.array(z2.string()).max(MAX_CAST_SOURCES).optional()
3309
+ });
3104
3310
  var WorkflowNodeSchema = z2.object({
3105
3311
  id: z2.string().min(1),
3106
3312
  task: WorkflowTaskSchema,
3107
3313
  model: z2.string().min(1),
3108
3314
  inputs: z2.record(z2.string(), BindingSchema).default({}),
3109
- retry: RetryPolicySchema.optional()
3315
+ retry: RetryPolicySchema.optional(),
3316
+ /**
3317
+ * The cast the node's prompt names, in prompt order. Not a job input: the
3318
+ * executor reads it at send time to put the identity clauses Create sends
3319
+ * in front of the prompt (the reference order, the identity lock with each
3320
+ * character's description; for a clip, which element is who), and never
3321
+ * stores them in the node's prompt. Absent on a node that names no cast.
3322
+ */
3323
+ cast: z2.array(CastMemberSchema).max(MAX_CAST_MEMBERS).optional(),
3324
+ /**
3325
+ * The cast is what the node's own reference stack shows (its
3326
+ * `castReferences` setting), not mentions the canvas's prompt bar edits; a
3327
+ * fork of the run brings it back under that setting. Absent otherwise.
3328
+ */
3329
+ castOwn: z2.literal(true).optional(),
3330
+ /**
3331
+ * The node's images come from its image wire, which wins over a baked
3332
+ * stack: the cast's baked references are then not what is sent. Set with
3333
+ * `cast` only, so the executor can say which next step works.
3334
+ */
3335
+ imagesWired: z2.literal(true).optional()
3110
3336
  });
3111
3337
  var WorkflowParamSpecSchema = z2.object({
3112
3338
  name: z2.string().min(1),
@@ -3129,8 +3355,8 @@ var WorkflowDefinitionSchema = z2.object({
3129
3355
  version: SchemaVersionSchema.default({ schema: WORKFLOW_SCHEMA_VERSION }),
3130
3356
  id: z2.string().min(1),
3131
3357
  label: z2.string().optional(),
3132
- params: z2.array(WorkflowParamSpecSchema).default([]),
3133
- nodes: z2.array(WorkflowNodeSchema).min(1)
3358
+ params: z2.array(WorkflowParamSpecSchema).max(MAX_DEFINITION_PARAMS).default([]),
3359
+ nodes: z2.array(WorkflowNodeSchema).min(1).max(MAX_DOCUMENT_NODES)
3134
3360
  });
3135
3361
  function kahnOrder(ids, edges) {
3136
3362
  const indegree = /* @__PURE__ */ new Map();
@@ -3167,7 +3393,8 @@ var KeySchema = z3.string().regex(/^[A-Za-z_][A-Za-z0-9_.-]{0,63}$/, "key must b
3167
3393
  var InputNameSchema = z3.string().regex(/^[A-Za-z_][A-Za-z0-9_-]{0,63}$/, "input name must be 1 to 64 chars of letters, digits, _ -").refine(notReserved, "reserved name");
3168
3394
  var LabelSchema = z3.string().max(200);
3169
3395
  var DescriptionSchema = z3.string().max(2e3);
3170
- var PromptTextSchema = z3.string().max(2e4);
3396
+ var MAX_PROMPT_TEXT_LENGTH = 2e4;
3397
+ var PromptTextSchema = z3.string().max(MAX_PROMPT_TEXT_LENGTH);
3171
3398
  var ModelIdSchema = z3.string().max(256);
3172
3399
  var UrlSchema = z3.string().max(4096);
3173
3400
  var AssetIdSchema = z3.string().max(128);
@@ -3258,7 +3485,7 @@ var DocEdgeSchema = z3.object({
3258
3485
  var DocGroupSchema = z3.object({
3259
3486
  id: IdSchema,
3260
3487
  label: LabelSchema.optional(),
3261
- nodeIds: z3.array(IdSchema).min(1)
3488
+ nodeIds: z3.array(IdSchema).min(1).max(MAX_DOCUMENT_NODES)
3262
3489
  });
3263
3490
  var EDGE_ROUTINGS = ["curved", "orthogonal"];
3264
3491
  var EdgeRoutingSchema = z3.enum(EDGE_ROUTINGS);
@@ -3276,7 +3503,7 @@ var WorkflowDocumentSchema = z3.object({
3276
3503
  schema: z3.number().int().positive(),
3277
3504
  id: IdSchema,
3278
3505
  label: LabelSchema.default(""),
3279
- nodes: z3.array(DocNodeSchema).max(2e3),
3506
+ nodes: z3.array(DocNodeSchema).max(MAX_DOCUMENT_NODES),
3280
3507
  edges: z3.array(DocEdgeSchema).max(8e3),
3281
3508
  layout: z3.record(IdSchema, PositionSchema).default({}),
3282
3509
  groups: z3.array(DocGroupSchema).max(500).default([]),
@@ -3365,6 +3592,26 @@ var ROUTES2 = [
3365
3592
  withReferences: { "1080p": "fal/kling-o3-pro-reference-to-video" }
3366
3593
  }
3367
3594
  },
3595
+ {
3596
+ kind: "video",
3597
+ id: "route/gemini-omni",
3598
+ label: "Gemini Omni 1.1 Flash (KIE, fal fallback)",
3599
+ primary: "kie/gemini-omni-flash-1-1-image-to-video",
3600
+ // fal renders every length KIE does (4 to 10 s in even steps) and the same
3601
+ // sizes and shapes, from the same frame fields (2026-11-03). One difference:
3602
+ // fal always renders sound with the clip, so a clip that falls back has it.
3603
+ fallback: { start: "fal/gemini-omni-flash-1-1-image-to-video" }
3604
+ },
3605
+ {
3606
+ kind: "video",
3607
+ id: "route/minimax-h3",
3608
+ label: "MiniMax H3 (KIE, fal fallback)",
3609
+ primary: "kie/minimax-h3-image-to-video",
3610
+ // fal renders KIE's sizes (768P and 2K) and lengths from 5 to 15 s from the
3611
+ // same frame fields (2026-11-04); KIE also renders 4 s, which fal does not,
3612
+ // so a 4 s clip has no fallback. fal always renders sound with the clip.
3613
+ fallback: { start: "fal/minimax-h3-image-to-video" }
3614
+ },
3368
3615
  {
3369
3616
  kind: "video",
3370
3617
  id: "route/seedance-2-0",
@@ -3664,6 +3911,71 @@ var CATALOG_ENTRIES2 = [
3664
3911
  description: "ByteDance Seedream 5 Pro edit via fal, up to 10 reference images, 1K or 2K.",
3665
3912
  capabilities: { resolutions: ["1K", "2K"], needsImageInput: true, maxInputImages: 10 }
3666
3913
  },
3914
+ // ── fal.ai: Ideogram 4.5 Edit, precise local edits ─────────────────────
3915
+ {
3916
+ id: "fal/ideogram-4-5-edit",
3917
+ provider: "fal",
3918
+ modality: "image",
3919
+ task: "image-edit",
3920
+ label: "Ideogram 4.5 Edit (fal)",
3921
+ // Measured 2026-11-04 on a series of edits of one portrait: the background
3922
+ // held at a structural similarity (SSIM) of 0.9999 between successive
3923
+ // edits, against 0.98 for Nano Banana 2 Edit, which reframed the shot on
3924
+ // the first edit. Ideogram's first edit smoothed the face a little; after
3925
+ // that the face held.
3926
+ 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.",
3927
+ capabilities: {
3928
+ // The tiers carry Ideogram's QUALITY (providers/fal.ts, `ideogramQuality`):
3929
+ // 0.5K low, 1K medium (the default), 2K high. fal's very_low is not
3930
+ // offered (decided 2026-11-04). Labelled as qualities
3931
+ // wherever shown (`imageTierLabel`).
3932
+ resolutions: ["0.5K", "1K", "2K"],
3933
+ tierKind: "quality",
3934
+ editsFirstImage: true,
3935
+ needsImageInput: true,
3936
+ maxInputImages: 5
3937
+ }
3938
+ },
3939
+ // ── fal.ai: OpenAI GPT Image 2, text in images and exact edits ─────────
3940
+ // Added 2026-11-04 (plan 2026-11-04-skool-prompting, item M2): the course
3941
+ // Marlin follows names it the best model for rendering text (labels,
3942
+ // packaging) and for edits that change only what was asked.
3943
+ {
3944
+ id: "fal/gpt-image-2",
3945
+ provider: "fal",
3946
+ modality: "image",
3947
+ task: "text-to-image",
3948
+ label: "GPT Image 2 (fal)",
3949
+ 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).",
3950
+ capabilities: {
3951
+ // The tiers carry GPT Image 2's QUALITY (providers/fal.ts,
3952
+ // `tierQuality`): 0.5K low, 1K medium (the default), 2K high. The size
3953
+ // follows the shape alone (`FAL_GPT_IMAGE_2_SIZE_BY_ASPECT`).
3954
+ resolutions: ["0.5K", "1K", "2K"],
3955
+ tierKind: "quality",
3956
+ maxInputImages: 0
3957
+ }
3958
+ },
3959
+ {
3960
+ id: "fal/gpt-image-2-edit",
3961
+ provider: "fal",
3962
+ modality: "image",
3963
+ task: "image-edit",
3964
+ label: "GPT Image 2 Edit (fal)",
3965
+ 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).",
3966
+ capabilities: {
3967
+ resolutions: ["0.5K", "1K", "2K"],
3968
+ tierKind: "quality",
3969
+ // fal's `image_urls` is a plain list with no field for the image
3970
+ // edited. Studio's convention: the image to edit goes first and the
3971
+ // mention prompt names it image 1, which is what lets the composer, the
3972
+ // generate route and the canvas refuse an edit with no image before
3973
+ // anything is admitted (`editSourceHold`).
3974
+ editsFirstImage: true,
3975
+ needsImageInput: true,
3976
+ maxInputImages: 8
3977
+ }
3978
+ },
3667
3979
  {
3668
3980
  id: "fal/flux-1-1-pro",
3669
3981
  provider: "fal",
@@ -3949,7 +4261,7 @@ var CATALOG_ENTRIES2 = [
3949
4261
  modality: "video",
3950
4262
  task: "image-to-video",
3951
4263
  label: "Gemini Omni 1.1 Flash (KIE)",
3952
- description: "Google Gemini Omni 1.1 Flash via KIE, first-and-last-frame mode. A start frame and an optional end frame, 4, 6, 8 or 10 s, 720p to 4K, 16:9 or 9:16. KIE refuses registered characters in this mode, so identity comes from the frames alone. Accepted a minted character's photoreal stills on 2026-09-24 (set 9:16 for a portrait still: it defaults to 16:9 and crops). No fal equivalent.",
4264
+ description: "Google Gemini Omni 1.1 Flash via KIE, first-and-last-frame mode. A start frame and an optional end frame, 4, 6, 8 or 10 s, 720p to 4K, 16:9 or 9:16. KIE refuses registered characters in this mode, so identity comes from the frames alone. Accepted a minted character's photoreal stills on 2026-09-24 (set 9:16 for a portrait still: it defaults to 16:9 and crops).",
3953
4265
  capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
3954
4266
  },
3955
4267
  {
@@ -4045,6 +4357,53 @@ var CATALOG_ENTRIES2 = [
4045
4357
  characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 7 }
4046
4358
  }
4047
4359
  },
4360
+ {
4361
+ id: "fal/gemini-omni-flash-1-1-image-to-video",
4362
+ provider: "fal",
4363
+ modality: "video",
4364
+ task: "image-to-video",
4365
+ label: "Gemini Omni 1.1 Flash (image-to-video)",
4366
+ 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).",
4367
+ // 8 s at fal's 720p default, the length and size the KIE entry renders.
4368
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
4369
+ },
4370
+ {
4371
+ id: "fal/kling-3-0-standard-image-to-video",
4372
+ provider: "fal",
4373
+ modality: "video",
4374
+ task: "image-to-video",
4375
+ label: "Kling 3.0 Standard (image-to-video)",
4376
+ 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.",
4377
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
4378
+ },
4379
+ {
4380
+ id: "fal/kling-3-0-pro-image-to-video",
4381
+ provider: "fal",
4382
+ modality: "video",
4383
+ task: "image-to-video",
4384
+ label: "Kling 3.0 Pro (image-to-video)",
4385
+ 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.",
4386
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
4387
+ },
4388
+ {
4389
+ id: "fal/minimax-h3-image-to-video",
4390
+ provider: "fal",
4391
+ modality: "video",
4392
+ task: "image-to-video",
4393
+ label: "MiniMax H3 (image-to-video)",
4394
+ 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).",
4395
+ // 5 s at fal's 2K default.
4396
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
4397
+ },
4398
+ {
4399
+ id: "fal/kling-4-0-image-to-video",
4400
+ provider: "fal",
4401
+ modality: "video",
4402
+ task: "image-to-video",
4403
+ label: "Kling 4.0 (image-to-video)",
4404
+ 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.",
4405
+ capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
4406
+ },
4048
4407
  {
4049
4408
  id: "fal/ltx-2-5-fast-image-to-video",
4050
4409
  provider: "fal",
@@ -4376,6 +4735,143 @@ function withRouteNote2(entry) {
4376
4735
  return { ...entry, description: [entry.description ?? "", note, person ?? ""].filter(Boolean).join(" ").trim() };
4377
4736
  }
4378
4737
  var MODEL_CATALOG2 = CATALOG_ENTRIES2.map(withRouteNote2);
4738
+ var PROVIDER_API_NAMES = {
4739
+ "vertex/gemini-2-5-flash-image": "gemini-2.5-flash-image",
4740
+ "vertex/gemini-3-pro-image-preview": "gemini-3-pro-image-preview",
4741
+ "vertex/gemini-3-1-flash-image-preview": "gemini-3.1-flash-image-preview",
4742
+ "kie/nano-banana-2": "nano-banana-2",
4743
+ "kie/nano-banana-2-edit": "nano-banana-2",
4744
+ "kie/nano-banana-pro": "nano-banana-pro",
4745
+ "kie/nano-banana-pro-edit": "nano-banana-pro",
4746
+ "kie/seedream-5-lite": "seedream/5-lite-text-to-image",
4747
+ "kie/seedream-5-lite-edit": "seedream/5-lite-image-to-image",
4748
+ "kie/seedream-5-pro": "seedream/5-pro-text-to-image",
4749
+ "kie/seedream-5-pro-edit": "seedream/5-pro-image-to-image",
4750
+ "kie/imagen-4-fast": "google/imagen4-fast",
4751
+ "kie/seedream-v4": "bytedance/seedream-v4-text-to-image",
4752
+ // fal endpoint ids. The provider auto-routes nano-banana-2 to the `/edit`
4753
+ // variant when inputImages are present; both -edit and -edit-i2i catalog
4754
+ // entries share the same upstream id.
4755
+ "fal/nano-banana-2": "fal-ai/nano-banana-2",
4756
+ "fal/nano-banana-pro": "fal-ai/nano-banana-pro",
4757
+ "fal/nano-banana-pro-edit": "fal-ai/nano-banana-pro/edit",
4758
+ "fal/seedream-5-lite": "fal-ai/bytedance/seedream/v5/lite/text-to-image",
4759
+ "fal/seedream-5-lite-edit": "fal-ai/bytedance/seedream/v5/lite/edit",
4760
+ "fal/seedream-5-pro": "bytedance/seedream/v5/pro/text-to-image",
4761
+ "fal/seedream-5-pro-edit": "bytedance/seedream/v5/pro/edit",
4762
+ "fal/nano-banana-2-edit": "fal-ai/nano-banana-2/edit",
4763
+ // No fal-ai prefix: owner `ideogram`, alias `v4.5`, path `edit`.
4764
+ "fal/ideogram-4-5-edit": "ideogram/v4.5/edit",
4765
+ // No fal-ai prefix: owner `openai`. `fal-ai/gpt-image-2` is an alias of the
4766
+ // same model; the edit is `/edit` (there is no `image-to-image` path).
4767
+ "fal/gpt-image-2": "openai/gpt-image-2",
4768
+ "fal/gpt-image-2-edit": "openai/gpt-image-2/edit",
4769
+ "fal/nano-banana-2-edit-i2i": "fal-ai/nano-banana-2/edit",
4770
+ "fal/flux-1-1-pro": "fal-ai/flux-pro/v1.1",
4771
+ "fal/flux-schnell": "fal-ai/flux/schnell",
4772
+ "fal/flux-kontext-pro": "fal-ai/flux-pro/kontext",
4773
+ // fal virtual try-on endpoint (E3). Sync via subscribe (submit+poll wrapped).
4774
+ "fal/fashn-tryon-v1-6": "fal-ai/fashn/tryon/v1.6",
4775
+ // fal video endpoints (B1). Async via the queue API.
4776
+ "fal/kling-v2-5-image-to-video": "fal-ai/kling-video/v2.5-turbo/pro/image-to-video",
4777
+ "fal/seedance-pro-image-to-video": "fal-ai/bytedance/seedance/v1/pro/image-to-video",
4778
+ // Seedance 2.x ids carry no `fal-ai/` prefix and are nested (owner/alias/path),
4779
+ // like the Wan entry above; the fal SDK derives queue URLs from owner/alias.
4780
+ "fal/seedance-2-5-image-to-video": "bytedance/seedance-2.5/image-to-video",
4781
+ "fal/seedance-2-0-image-to-video": "bytedance/seedance-2.0/image-to-video",
4782
+ "fal/seedance-pro-text-to-video": "fal-ai/bytedance/seedance/v1/pro/text-to-video",
4783
+ // Grok Imagine: nested id, the SDK derives owner/alias itself.
4784
+ "fal/grok-imagine-image-to-video": "xai/grok-imagine-video/image-to-video",
4785
+ // KIE video: the upstream KIE model ids (providers/kie-video.ts).
4786
+ "kie/veo-3-1-lite": "veo3_lite",
4787
+ "kie/veo-3-1-fast": "veo3_fast",
4788
+ "kie/veo-3-1": "veo3",
4789
+ "kie/grok-imagine-image-to-video": "grok-imagine/image-to-video",
4790
+ "kie/grok-imagine-1-5-image-to-video": "grok-imagine-video-1-5-preview",
4791
+ "kie/kling-v2-5-turbo-pro-image-to-video": "kling/v2-5-turbo-image-to-video-pro",
4792
+ "kie/kling-2-6-image-to-video": "kling-2.6/image-to-video",
4793
+ "kie/seedance-2-0-image-to-video": "bytedance/seedance-2",
4794
+ "kie/seedance-2-5-image-to-video": "bytedance/seedance-2-5",
4795
+ "kie/wan-3-0-image-to-video": "wan/3-0-video",
4796
+ "kie/minimax-h3-image-to-video": "minimax-h3/image-to-video",
4797
+ "kie/gemini-omni-flash-1-1-image-to-video": "google/gemini-omni-flash-1-1",
4798
+ // The same KIE model in its reference mode: a spec key of its own, sent to
4799
+ // KIE as `google/gemini-omni-flash-1-1` (`KieVideoSpec.upstreamModel`).
4800
+ "kie/gemini-omni-flash-1-1-reference-to-video": "google/gemini-omni-flash-1-1/references",
4801
+ "kie/kling-o3-image-to-video": "kling-3.0-omni/image-to-video",
4802
+ // OpenRouter video: the OpenRouter model ids (providers/openrouter-video.ts).
4803
+ "openrouter/veo-3-1-lite": "google/veo-3.1-lite",
4804
+ "openrouter/veo-3-1-fast": "google/veo-3.1-fast",
4805
+ "openrouter/veo-3-1": "google/veo-3.1",
4806
+ // The fal twins of KIE-only models.
4807
+ "fal/grok-imagine-1-5-image-to-video": "xai/grok-imagine-video/v1.5/image-to-video",
4808
+ "fal/wan-3-0-image-to-video": "alibaba/wan-3.0/image-to-video",
4809
+ "fal/kling-2-6-image-to-video": "fal-ai/kling-video/v2.6/pro/image-to-video",
4810
+ "fal/kling-o3-standard-image-to-video": "fal-ai/kling-video/o3/standard/image-to-video",
4811
+ "fal/kling-o3-pro-image-to-video": "fal-ai/kling-video/o3/pro/image-to-video",
4812
+ "fal/kling-o3-pro-reference-to-video": "fal-ai/kling-video/o3/pro/reference-to-video",
4813
+ "fal/gemini-omni-flash-1-1-image-to-video": "google/gemini-omni-flash/v1.1/image-to-video",
4814
+ "fal/kling-3-0-standard-image-to-video": "fal-ai/kling-video/v3/standard/image-to-video",
4815
+ "fal/kling-3-0-pro-image-to-video": "fal-ai/kling-video/v3/pro/image-to-video",
4816
+ "fal/kling-4-0-image-to-video": "kling/v4/image-to-video",
4817
+ "fal/minimax-h3-image-to-video": "minimax/h3/image-to-video",
4818
+ // Lightricks LTX-2.5: nested ids, the SDK derives owner/alias itself.
4819
+ "fal/ltx-2-5-fast-image-to-video": "lightricks/ltx-2.5/image-to-video/fast",
4820
+ "fal/ltx-2-5-pro-image-to-video": "lightricks/ltx-2.5/image-to-video/pro",
4821
+ // Google Veo 3.1: nested ids, the SDK derives owner/alias itself.
4822
+ "fal/veo-3-1-lite-image-to-video": "fal-ai/veo3.1/lite/image-to-video",
4823
+ "fal/veo-3-1-lite-first-last-frame": "fal-ai/veo3.1/lite/first-last-frame-to-video",
4824
+ "fal/veo-3-1-fast-image-to-video": "fal-ai/veo3.1/fast/image-to-video",
4825
+ "fal/veo-3-1-fast-first-last-frame": "fal-ai/veo3.1/fast/first-last-frame-to-video",
4826
+ "fal/veo-3-1-image-to-video": "fal-ai/veo3.1/image-to-video",
4827
+ "fal/veo-3-1-first-last-frame": "fal-ai/veo3.1/first-last-frame-to-video",
4828
+ // FLUX.3 draft endpoints. Nested ids without the `fal-ai/` prefix, like Seedance 2.x.
4829
+ "fal/flux-3-image-to-video-draft": "blackforestlabs/flux-3/image-to-video/draft",
4830
+ "fal/flux-3-first-last-frame-to-video-draft": "blackforestlabs/flux-3/first-last-frame-to-video/draft",
4831
+ "fal/flux-3-keyframes-to-video-draft": "blackforestlabs/flux-3/keyframes-to-video/draft",
4832
+ "fal/flux-3-image-to-video": "blackforestlabs/flux-3/image-to-video",
4833
+ "fal/flux-3-first-last-frame-to-video": "blackforestlabs/flux-3/first-last-frame-to-video",
4834
+ "fal/flux-3-keyframes-to-video": "blackforestlabs/flux-3/keyframes-to-video",
4835
+ "fal/flux-3-draft-enhance": "blackforestlabs/flux-3/draft-enhance",
4836
+ // fal video-to-video (Wan 2.2 Animate Replace). Nested endpoint id: the queue
4837
+ // status / result URLs use only `fal-ai/wan` (owner/alias), which the fal SDK
4838
+ // derives itself (parseEndpointId); submit takes the full id.
4839
+ "fal/wan-animate-replace": "fal-ai/wan/v2.2-14b/animate/replace",
4840
+ // Kling O3 Pro Edit: nested id like Wan's, the SDK derives owner/alias itself.
4841
+ "fal/kling-o3-edit": "fal-ai/kling-video/o3/pro/video-to-video/edit",
4842
+ // fal vision + utility endpoints (B4). Sync via subscribe.
4843
+ "fal/florence-2-detailed-caption": "fal-ai/florence-2-large/detailed-caption",
4844
+ "fal/moondream-next-vqa": "fal-ai/moondream-next",
4845
+ // Judge (P3): same underlying endpoint as the entry above. Not dispatched
4846
+ // yet: a judge node parks the run on a person (J2) and does not call a model
4847
+ // until J5 wires the ranking. Mapped now so J5 needs no catalog change.
4848
+ "fal/moondream-next-vqa-judge": "fal-ai/moondream-next",
4849
+ "fal/meshy-rigging": "fal-ai/meshy/rigging",
4850
+ "fal/aura-sr-upscale": "fal-ai/aura-sr",
4851
+ "fal/birefnet-v2-background-remove": "fal-ai/birefnet/v2",
4852
+ // audio: Suno music via KIE (B2). The upstream `model` field KIE expects on
4853
+ // its Suno job API ("V5"), distinct from the dashed catalog id.
4854
+ "kie/suno-v5": "V5",
4855
+ // audio: ElevenLabs voice (B2). The upstream model_id the ElevenLabs API
4856
+ // expects on the TTS / STT endpoints.
4857
+ "elevenlabs/tts-multilingual-v2": "eleven_multilingual_v2",
4858
+ "elevenlabs/scribe-v1": "scribe_v1",
4859
+ // text: LLM director (B3). KIE-Claude expects the bare Anthropic model id on
4860
+ // its Messages endpoint; OpenRouter expects the provider-prefixed id.
4861
+ "kie/claude-sonnet-4-5": "claude-sonnet-4-5",
4862
+ "kie/claude-opus-4-5": "claude-opus-4-5",
4863
+ "openrouter/claude-sonnet-4-6": "anthropic/claude-sonnet-4-6",
4864
+ "openrouter/gpt-6-astra": "openai/gpt-6-astra",
4865
+ "openrouter/claude-opus-5-5": "anthropic/claude-opus-5.5"
4866
+ };
4867
+ function getProviderModelName(id) {
4868
+ const route = getRoute2(id);
4869
+ if (route) return getProviderModelName(route.primary);
4870
+ const mapped = PROVIDER_API_NAMES[id];
4871
+ if (mapped) return mapped;
4872
+ const slashIdx = id.indexOf("/");
4873
+ return slashIdx === -1 ? id : id.slice(slashIdx + 1);
4874
+ }
4379
4875
  var routeEntries2 = /* @__PURE__ */ new Map();
4380
4876
  function routeEntry2(id) {
4381
4877
  const cached = routeEntries2.get(id);
@@ -4398,6 +4894,24 @@ function routeEntry2(id) {
4398
4894
  function tryGetModel2(id) {
4399
4895
  return MODEL_CATALOG2.find((m) => m.id === id) ?? routeEntry2(id);
4400
4896
  }
4897
+ var IMAGE_SIZE_OF_TIER = {
4898
+ "0.5K": "512px",
4899
+ "1K": "1K",
4900
+ "2K": "2K",
4901
+ "4K": "4K"
4902
+ };
4903
+ var IMAGE_QUALITY_LABEL_OF_TIER = {
4904
+ "0.5K": "Low",
4905
+ "1K": "Medium",
4906
+ "2K": "High",
4907
+ // No quality model declares 4K today; named as fal names the step above high.
4908
+ "4K": "Very high"
4909
+ };
4910
+ function imageTierLabel(model, value) {
4911
+ const tier = imageResolutionTier(value);
4912
+ if (!tier) return value;
4913
+ return model?.capabilities?.tierKind === "quality" ? IMAGE_QUALITY_LABEL_OF_TIER[tier] : IMAGE_SIZE_OF_TIER[tier];
4914
+ }
4401
4915
  function imageResolutionTier(value) {
4402
4916
  if (typeof value !== "string") return null;
4403
4917
  switch (value.trim().toLowerCase()) {
@@ -4415,92 +4929,750 @@ function imageResolutionTier(value) {
4415
4929
  return null;
4416
4930
  }
4417
4931
  }
4418
- function supportedResolutions(model) {
4419
- const declared = model?.capabilities?.resolutions;
4420
- return declared ? declared : null;
4421
- }
4422
- function resolutionRefusal(model, resolution) {
4423
- if (resolution === void 0 || resolution === null || resolution === "") return null;
4424
- const supported = supportedResolutions(model);
4425
- if (!model || supported === null) return null;
4426
- const name = model.label ?? model.id;
4427
- if (supported.length === 0) {
4428
- return `${name} takes no resolution setting and always renders at its own size, so "${String(resolution)}" would be silently ignored. Clear the resolution, or pick a model that honours it, such as Nano Banana 2.`;
4429
- }
4430
- const tier = imageResolutionTier(resolution);
4431
- if (tier && supported.includes(tier)) return null;
4432
- return `${name} renders at ${supported.join(", ")}, not "${String(resolution)}". Pick one of those.`;
4433
- }
4434
- var PROMPT_REQUIRED = /* @__PURE__ */ new Set([
4435
- "text-to-image",
4436
- "image-to-image",
4437
- "image-edit",
4438
- "text-to-3d",
4439
- "image-to-3d",
4440
- "multiview-to-3d",
4441
- "text-to-video",
4442
- // Texture: 3D AI Studio refuses a texture request without a prompt or a
4443
- // reference image (probed 2026-09-26), and Studio sends no reference image,
4444
- // so the material description is required. It binds `texturePrompt`, see
4445
- // `promptInputKey`.
4446
- "texture",
4447
- // Audio is prompt-only: a music description (text-to-audio) / the text to
4448
- // speak (text-to-speech). No upstream wire, so no portBinding entry.
4449
- "text-to-audio",
4450
- "text-to-speech"
4451
- ]);
4452
- var PROMPT_OPTIONAL = /* @__PURE__ */ new Set(["image-to-video", "image-to-json", "video-to-video"]);
4453
- function taskNeedsPrompt(task) {
4454
- return PROMPT_REQUIRED.has(task) || PROMPT_OPTIONAL.has(task);
4455
- }
4456
- function taskRequiresPrompt(task) {
4457
- return PROMPT_REQUIRED.has(task);
4458
- }
4459
- function promptInputKey(task) {
4460
- return task === "texture" ? "texturePrompt" : "prompt";
4461
- }
4462
- function portBinding(task, port) {
4463
- if (port === "image" && (task === "image-to-3d" || task === "multiview-to-3d" || task === "image-to-video" || task === "image-to-text" || task === "image-to-json")) {
4464
- return { key: "inputImageUrl", path: "url" };
4465
- }
4466
- if (port === "reference" && task === "image-to-video") {
4467
- return { key: "referenceImageUrls", path: "url", wrap: "array" };
4468
- }
4469
- if (port === "mesh3d" && (task === "remesh" || task === "texture" || task === "rig")) {
4470
- return { key: "parentAssetId", path: "assetId" };
4471
- }
4472
- if (port === "video" && task === "video-to-text") {
4473
- return { key: "inputVideoUrl", path: "url" };
4474
- }
4475
- if (port === "video" && task === "video-to-video") {
4476
- return { key: "inputVideoUrl", path: "url" };
4477
- }
4478
- if (port === "image" && task === "video-to-video") {
4479
- return { key: "inputImages", path: "url", wrap: "array" };
4480
- }
4481
- if (port === "video" && task === "video-enhance") {
4482
- return { key: "draftCacheUrl", path: "draftCacheUrl" };
4483
- }
4484
- if (port === "image" && (task === "image-edit" || task === "image-to-image")) {
4485
- return { key: "inputImages", path: "url", wrap: "array" };
4486
- }
4487
- if (port === "text" && taskNeedsPrompt(task)) {
4488
- return { key: promptInputKey(task), path: "text" };
4489
- }
4490
- if (port === "image" && (task === "upscale" || task === "background-remove")) {
4491
- return { key: "parentAssetId", path: "assetId" };
4492
- }
4493
- if (port === "audio" && task === "speech-to-text") {
4494
- return { key: "inputAudioUrl", path: "url" };
4495
- }
4496
- if (port === "image" && task === "judge") {
4497
- return { key: "candidateAssetIds", path: "assetId", wrap: "array" };
4932
+ var ASPECT_RATIOS2 = [
4933
+ "1:1",
4934
+ "3:2",
4935
+ "2:3",
4936
+ "3:4",
4937
+ "4:3",
4938
+ "4:5",
4939
+ "5:4",
4940
+ "9:16",
4941
+ "16:9",
4942
+ "21:9"
4943
+ ];
4944
+ function omniReferencesPrompt2(prompt, elements) {
4945
+ 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."];
4946
+ let next = 2;
4947
+ for (const [i, e] of elements.entries()) {
4948
+ const count2 = 1 + e.referenceImageUrls.length;
4949
+ const span = count2 === 1 ? `Image ${next} shows` : `Images ${next} to ${next + count2 - 1} show`;
4950
+ parts.push(
4951
+ `${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.`
4952
+ );
4953
+ next += count2;
4498
4954
  }
4499
- return null;
4955
+ const text = prompt?.trim() ?? "";
4956
+ return text ? `${parts.join(" ")} ${text}` : parts.join(" ");
4500
4957
  }
4501
- function canConnect(sourceOut, targetTask, targetPort) {
4502
- if (sourceOut !== portContent(targetPort)) return false;
4503
- return portBinding(targetTask, targetPort) !== null;
4958
+ var OMNI_MAX_REFERENCE_IMAGES2 = 7;
4959
+ function veoSpec3(model, label) {
4960
+ return {
4961
+ family: "veo",
4962
+ label,
4963
+ endFrame: true,
4964
+ aspectRatios: ["auto", "16:9", "9:16"],
4965
+ resolutions: ["720p", "1080p", "4k"],
4966
+ durations: { values: [4, 6, 8] },
4967
+ defaultSeconds: 8,
4968
+ defaultResolution: "720p",
4969
+ audioSwitch: false,
4970
+ defaultAudio: true,
4971
+ build: (i) => ({
4972
+ prompt: i.prompt,
4973
+ model,
4974
+ imageUrls: i.end ? [i.start, i.end] : [i.start],
4975
+ // KIE's "Auto" letterboxed a 4:3 still into 16:9 on 2026-09-23; an explicit
4976
+ // ratio is honoured, so only auto maps to KIE's own word for it.
4977
+ ...i.aspectRatio ? { aspect_ratio: i.aspectRatio === "auto" ? "Auto" : i.aspectRatio } : {},
4978
+ resolution: i.resolution,
4979
+ duration: i.seconds
4980
+ })
4981
+ };
4982
+ }
4983
+ var SEEDANCE_ASPECTS2 = ["auto", "1:1", "4:3", "3:4", "16:9", "9:16", "21:9"];
4984
+ var seedanceAspect2 = (a) => a === "auto" ? "adaptive" : a;
4985
+ var KIE_VIDEO_SPECS2 = {
4986
+ veo3_lite: veoSpec3("veo3_lite", "Veo 3.1 Lite"),
4987
+ veo3_fast: veoSpec3("veo3_fast", "Veo 3.1 Fast"),
4988
+ veo3: veoSpec3("veo3", "Veo 3.1"),
4989
+ "grok-imagine/image-to-video": {
4990
+ family: "job",
4991
+ label: "Grok Imagine",
4992
+ endFrame: false,
4993
+ resolutions: ["480p", "720p", "1080p"],
4994
+ durations: { min: 6, max: 30 },
4995
+ defaultSeconds: 6,
4996
+ defaultResolution: "720p",
4997
+ // Not a contradiction with the catalog saying Grok renders with audio: xAI
4998
+ // always renders audio and KIE exposes no switch for it. `defaultAudio`
4999
+ // here only feeds `price()`, which ignores it, so it states no audio fact.
5000
+ audioSwitch: false,
5001
+ defaultAudio: false,
5002
+ build: (i) => ({
5003
+ image_urls: [i.start],
5004
+ prompt: i.prompt,
5005
+ mode: "normal",
5006
+ duration: String(i.seconds),
5007
+ resolution: i.resolution,
5008
+ nsfw_checker: true
5009
+ })
5010
+ },
5011
+ "grok-imagine-video-1-5-preview": {
5012
+ family: "job",
5013
+ label: "Grok Imagine 1.5",
5014
+ endFrame: false,
5015
+ // KIE lists no 1080p price for 1.5, so 1080p is not offered.
5016
+ resolutions: ["480p", "720p"],
5017
+ durations: { min: 1, max: 15 },
5018
+ defaultSeconds: 8,
5019
+ defaultResolution: "720p",
5020
+ // As for Grok Imagine 1.0 above: audio is always rendered, with no switch.
5021
+ audioSwitch: false,
5022
+ defaultAudio: false,
5023
+ build: (i) => ({
5024
+ image_urls: [i.start],
5025
+ prompt: i.prompt,
5026
+ duration: i.seconds,
5027
+ resolution: i.resolution,
5028
+ nsfw_checker: true
5029
+ })
5030
+ },
5031
+ "kling/v2-5-turbo-image-to-video-pro": {
5032
+ family: "job",
5033
+ label: "Kling 2.5 Turbo Pro",
5034
+ endFrame: true,
5035
+ resolutions: [],
5036
+ durations: { values: [5, 10] },
5037
+ defaultSeconds: 5,
5038
+ defaultResolution: "",
5039
+ audioSwitch: false,
5040
+ defaultAudio: false,
5041
+ build: (i) => ({
5042
+ prompt: i.prompt,
5043
+ image_url: i.start,
5044
+ ...i.end ? { tail_image_url: i.end } : {},
5045
+ duration: String(i.seconds),
5046
+ ...i.negativePrompt ? { negative_prompt: i.negativePrompt } : {}
5047
+ })
5048
+ },
5049
+ "kling-2.6/image-to-video": {
5050
+ family: "job",
5051
+ label: "Kling 2.6",
5052
+ endFrame: false,
5053
+ resolutions: [],
5054
+ durations: { values: [5, 10] },
5055
+ defaultSeconds: 5,
5056
+ defaultResolution: "",
5057
+ audioSwitch: true,
5058
+ defaultAudio: false,
5059
+ build: (i) => ({
5060
+ prompt: i.prompt,
5061
+ image_urls: [i.start],
5062
+ sound: i.audio,
5063
+ duration: String(i.seconds)
5064
+ })
5065
+ },
5066
+ "bytedance/seedance-2": {
5067
+ family: "job",
5068
+ label: "Seedance 2.0",
5069
+ endFrame: true,
5070
+ aspectRatios: SEEDANCE_ASPECTS2,
5071
+ resolutions: ["480p", "720p", "1080p", "4k"],
5072
+ durations: { min: 4, max: 15 },
5073
+ defaultSeconds: 5,
5074
+ defaultResolution: "720p",
5075
+ audioSwitch: true,
5076
+ defaultAudio: true,
5077
+ build: (i) => ({
5078
+ prompt: i.prompt,
5079
+ first_frame_url: i.start,
5080
+ ...i.end ? { last_frame_url: i.end } : {},
5081
+ generate_audio: i.audio,
5082
+ resolution: i.resolution,
5083
+ ...i.aspectRatio ? { aspect_ratio: seedanceAspect2(i.aspectRatio) } : {},
5084
+ duration: i.seconds,
5085
+ nsfw_checker: true
5086
+ })
5087
+ },
5088
+ "bytedance/seedance-2-5": {
5089
+ family: "job",
5090
+ label: "Seedance 2.5",
5091
+ endFrame: true,
5092
+ aspectRatios: SEEDANCE_ASPECTS2,
5093
+ resolutions: ["480p", "720p", "1080p"],
5094
+ durations: { min: 4, max: 30 },
5095
+ defaultSeconds: 5,
5096
+ defaultResolution: "720p",
5097
+ audioSwitch: true,
5098
+ defaultAudio: true,
5099
+ build: (i) => ({
5100
+ prompt: i.prompt,
5101
+ first_frame_url: i.start,
5102
+ ...i.end ? { last_frame_url: i.end } : {},
5103
+ generate_audio: i.audio,
5104
+ resolution: i.resolution,
5105
+ ...i.aspectRatio ? { aspect_ratio: seedanceAspect2(i.aspectRatio) } : {},
5106
+ duration: i.seconds,
5107
+ nsfw_checker: true
5108
+ })
5109
+ },
5110
+ "wan/3-0-video": {
5111
+ family: "job",
5112
+ label: "Wan 3.0",
5113
+ endFrame: true,
5114
+ aspectRatios: ["auto", "16:9", "4:3", "1:1", "3:4", "9:16"],
5115
+ resolutions: ["480p", "720p", "1080p"],
5116
+ durations: { min: 2, max: 30 },
5117
+ defaultSeconds: 5,
5118
+ defaultResolution: "720p",
5119
+ audioSwitch: true,
5120
+ defaultAudio: true,
5121
+ build: (i) => ({
5122
+ prompt: i.prompt,
5123
+ first_frame_url: i.start,
5124
+ ...i.end ? { last_frame_url: i.end } : {},
5125
+ resolution: i.resolution.toUpperCase(),
5126
+ ...i.aspectRatio ? { aspect_ratio: i.aspectRatio === "auto" ? "adaptive" : i.aspectRatio } : {},
5127
+ duration: i.seconds,
5128
+ audio: i.audio,
5129
+ ...i.seed !== void 0 ? { seed: i.seed } : {},
5130
+ nsfw_checker: true
5131
+ })
5132
+ },
5133
+ "minimax-h3/image-to-video": {
5134
+ family: "job",
5135
+ label: "MiniMax H3",
5136
+ endFrame: true,
5137
+ // KIE renders 768P or 2K; the canvas's 720p and 1080p map onto them.
5138
+ resolutions: ["720p", "1080p"],
5139
+ durations: { min: 4, max: 15 },
5140
+ defaultSeconds: 6,
5141
+ defaultResolution: "720p",
5142
+ audioSwitch: false,
5143
+ defaultAudio: false,
5144
+ build: (i) => ({
5145
+ prompt: i.prompt,
5146
+ first_frame_url: i.start,
5147
+ ...i.end ? { last_frame_url: i.end } : {},
5148
+ duration: i.seconds,
5149
+ resolution: i.resolution === "1080p" ? "2K" : "768P"
5150
+ })
5151
+ },
5152
+ "google/gemini-omni-flash-1-1": {
5153
+ family: "job",
5154
+ label: "Gemini Omni 1.1 Flash",
5155
+ endFrame: true,
5156
+ aspectRatios: ["16:9", "9:16"],
5157
+ // KIE also renders 360p; the canvas offers none below 480p.
5158
+ resolutions: ["720p", "1080p", "4k"],
5159
+ durations: { values: [4, 6, 8, 10] },
5160
+ defaultSeconds: 8,
5161
+ defaultResolution: "720p",
5162
+ audioSwitch: false,
5163
+ defaultAudio: false,
5164
+ // The first-and-last-frame mode: KIE refuses it combined with registered
5165
+ // characters, reference images, audio or video, so none are sent.
5166
+ build: (i) => ({
5167
+ prompt: i.prompt,
5168
+ first_frame_url: i.start,
5169
+ ...i.end ? { last_frame_url: i.end } : {},
5170
+ duration: String(i.seconds),
5171
+ resolution: i.resolution,
5172
+ ...i.aspectRatio ? { aspect_ratio: i.aspectRatio } : {},
5173
+ ...i.seed !== void 0 ? { seed: i.seed } : {}
5174
+ })
5175
+ },
5176
+ // Gemini Omni 1.1 Flash in its REFERENCE mode: up to seven `image_urls`
5177
+ // ("Multiple reference images can be uploaded to provide references for
5178
+ // characters, scenes, styles, or storyboards"; "Maximum of 7 images"), and
5179
+ // no locked first frame, because KIE makes `first_frame_url` "mutually
5180
+ // exclusive with `image_urls`" (docs.kie.ai, read 2026-10-24). The start
5181
+ // keyframe goes first among the images and the prompt names it the exact
5182
+ // scene and first frame (`omniReferencesPrompt`); each character's views
5183
+ // follow. Same model, same price as the first-frame mode.
5184
+ "google/gemini-omni-flash-1-1/references": {
5185
+ family: "job",
5186
+ label: "Gemini Omni 1.1 Flash with references",
5187
+ upstreamModel: "google/gemini-omni-flash-1-1",
5188
+ endFrame: false,
5189
+ aspectRatios: ["16:9", "9:16"],
5190
+ resolutions: ["720p", "1080p", "4k"],
5191
+ durations: { values: [4, 6, 8, 10] },
5192
+ defaultSeconds: 8,
5193
+ defaultResolution: "720p",
5194
+ audioSwitch: false,
5195
+ defaultAudio: false,
5196
+ // Six character images, because the start keyframe takes one of the seven.
5197
+ characterReferences: {
5198
+ maxElements: 6,
5199
+ minImagesPerElement: 1,
5200
+ maxImagesPerElement: 6,
5201
+ maxTotalImages: OMNI_MAX_REFERENCE_IMAGES2 - 1
5202
+ },
5203
+ maxPromptChars: 2e4,
5204
+ referencesPrompt: omniReferencesPrompt2,
5205
+ build: (i) => ({
5206
+ prompt: i.prompt,
5207
+ image_urls: [i.start, ...(i.elements ?? []).flatMap((e) => [e.frontalImageUrl, ...e.referenceImageUrls])],
5208
+ duration: String(i.seconds),
5209
+ resolution: i.resolution,
5210
+ ...i.aspectRatio ? { aspect_ratio: i.aspectRatio } : {},
5211
+ ...i.seed !== void 0 ? { seed: i.seed } : {}
5212
+ })
5213
+ },
5214
+ "kling-3.0-omni/image-to-video": {
5215
+ family: "job",
5216
+ label: "Kling O3",
5217
+ endFrame: true,
5218
+ // Kling O3 takes an aspect ratio only for multi-shot prompts; a single shot
5219
+ // follows the start frame.
5220
+ resolutions: ["720p", "1080p", "4k"],
5221
+ durations: { min: 3, max: 15 },
5222
+ defaultSeconds: 5,
5223
+ defaultResolution: "720p",
5224
+ audioSwitch: true,
5225
+ defaultAudio: false,
5226
+ // KIE's "Single First Frame" and "First and Last Frames" request shapes
5227
+ // both carry `elements`: "up to 3 subjects", and "for a multi-image
5228
+ // subject, provide 2 to 4 images" (docs.kie.ai, kling-3.0-omni
5229
+ // image-to-video, read 2026-10-23). Each element needs a name the prompt
5230
+ // can mention as `@name` and a description.
5231
+ characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 12 },
5232
+ maxPromptChars: 3072,
5233
+ build: (i) => ({
5234
+ prompt: i.prompt,
5235
+ image_urls: i.end ? [i.start, i.end] : [i.start],
5236
+ duration: i.seconds,
5237
+ resolution: i.resolution,
5238
+ audio: i.audio,
5239
+ // Named Element1, Element2, ... so one prompt convention (`@Element1`)
5240
+ // holds on KIE and on the fal twin alike.
5241
+ ...i.elements && i.elements.length > 0 ? {
5242
+ elements: i.elements.map((e, n) => ({
5243
+ name: `Element${n + 1}`,
5244
+ description: `character ${n + 1}`,
5245
+ element_input_urls: [e.frontalImageUrl, ...e.referenceImageUrls]
5246
+ }))
5247
+ } : {}
5248
+ })
5249
+ }
5250
+ };
5251
+ function veoSpec22(label, resolutions) {
5252
+ return {
5253
+ label,
5254
+ // OpenRouter's Veo has no auto: it renders exactly one of these.
5255
+ aspectRatios: ["16:9", "9:16"],
5256
+ resolutions,
5257
+ durations: { values: [4, 6, 8] },
5258
+ defaultSeconds: 8,
5259
+ defaultResolution: "720p"
5260
+ };
5261
+ }
5262
+ var OPENROUTER_VIDEO_SPECS2 = {
5263
+ "google/veo-3.1-lite": veoSpec22("Veo 3.1 Lite", ["720p", "1080p"]),
5264
+ "google/veo-3.1-fast": veoSpec22("Veo 3.1 Fast", ["720p", "1080p", "4k"]),
5265
+ "google/veo-3.1": veoSpec22("Veo 3.1", ["720p", "1080p", "4k"])
5266
+ };
5267
+ var GROK_IMAGINE_I2V_ENDPOINT2 = "xai/grok-imagine-video/image-to-video";
5268
+ var GROK_IMAGINE_15_I2V_ENDPOINT2 = "xai/grok-imagine-video/v1.5/image-to-video";
5269
+ var WAN_30_I2V_ENDPOINT2 = "alibaba/wan-3.0/image-to-video";
5270
+ var KLING_26_I2V_ENDPOINT2 = "fal-ai/kling-video/v2.6/pro/image-to-video";
5271
+ var KLING_O3_STANDARD_I2V_ENDPOINT2 = "fal-ai/kling-video/o3/standard/image-to-video";
5272
+ var KLING_O3_PRO_I2V_ENDPOINT2 = "fal-ai/kling-video/o3/pro/image-to-video";
5273
+ var KLING_O3_I2V_ENDPOINTS2 = [KLING_O3_STANDARD_I2V_ENDPOINT2, KLING_O3_PRO_I2V_ENDPOINT2];
5274
+ var GEMINI_OMNI_11_I2V_ENDPOINT2 = "google/gemini-omni-flash/v1.1/image-to-video";
5275
+ var KLING_V3_STANDARD_I2V_ENDPOINT2 = "fal-ai/kling-video/v3/standard/image-to-video";
5276
+ var KLING_V3_PRO_I2V_ENDPOINT2 = "fal-ai/kling-video/v3/pro/image-to-video";
5277
+ var KLING_V3_I2V_ENDPOINTS2 = [KLING_V3_STANDARD_I2V_ENDPOINT2, KLING_V3_PRO_I2V_ENDPOINT2];
5278
+ var KLING_V4_I2V_ENDPOINT2 = "kling/v4/image-to-video";
5279
+ var MINIMAX_H3_I2V_ENDPOINT2 = "minimax/h3/image-to-video";
5280
+ var KLING_O3_PRO_R2V_ENDPOINT2 = "fal-ai/kling-video/o3/pro/reference-to-video";
5281
+ var FAL_CHARACTER_REFERENCE_LIMITS2 = {
5282
+ [KLING_O3_PRO_R2V_ENDPOINT2]: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 7 }
5283
+ };
5284
+ var LTX_25_FAST_I2V_ENDPOINT2 = "lightricks/ltx-2.5/image-to-video/fast";
5285
+ var LTX_25_PRO_I2V_ENDPOINT2 = "lightricks/ltx-2.5/image-to-video/pro";
5286
+ var LTX_25_I2V_ENDPOINTS2 = [LTX_25_FAST_I2V_ENDPOINT2, LTX_25_PRO_I2V_ENDPOINT2];
5287
+ var VEO_LITE_I2V_ENDPOINT2 = "fal-ai/veo3.1/lite/image-to-video";
5288
+ var VEO_LITE_FLF_ENDPOINT2 = "fal-ai/veo3.1/lite/first-last-frame-to-video";
5289
+ var VEO_FAST_I2V_ENDPOINT2 = "fal-ai/veo3.1/fast/image-to-video";
5290
+ var VEO_FAST_FLF_ENDPOINT2 = "fal-ai/veo3.1/fast/first-last-frame-to-video";
5291
+ var VEO_I2V_ENDPOINT2 = "fal-ai/veo3.1/image-to-video";
5292
+ var VEO_FLF_ENDPOINT2 = "fal-ai/veo3.1/first-last-frame-to-video";
5293
+ var VEO_ENDPOINTS2 = [
5294
+ VEO_LITE_I2V_ENDPOINT2,
5295
+ VEO_LITE_FLF_ENDPOINT2,
5296
+ VEO_FAST_I2V_ENDPOINT2,
5297
+ VEO_FAST_FLF_ENDPOINT2,
5298
+ VEO_I2V_ENDPOINT2,
5299
+ VEO_FLF_ENDPOINT2
5300
+ ];
5301
+ var VIDEO_FIXED_RESOLUTION2 = {
5302
+ "blackforestlabs/flux-3/keyframes-to-video/draft": "720p",
5303
+ "blackforestlabs/flux-3/first-last-frame-to-video/draft": "720p",
5304
+ "blackforestlabs/flux-3/image-to-video/draft": "720p",
5305
+ "blackforestlabs/flux-3/draft-enhance": "1080p",
5306
+ // Not a resolution the caller picks: Kling O3 Edit renders at the source's.
5307
+ "fal-ai/kling-video/o3/pro/video-to-video/edit": "source",
5308
+ // Kling 2.6 Pro takes no resolution; it renders 1080p.
5309
+ [KLING_26_I2V_ENDPOINT2]: "1080p",
5310
+ // Not a resolution the caller picks: Kling O3's tier sets the size.
5311
+ [KLING_O3_STANDARD_I2V_ENDPOINT2]: "fixed",
5312
+ [KLING_O3_PRO_I2V_ENDPOINT2]: "fixed",
5313
+ [KLING_O3_PRO_R2V_ENDPOINT2]: "fixed",
5314
+ // Kling 3.0 likewise: its tier sets the size.
5315
+ [KLING_V3_STANDARD_I2V_ENDPOINT2]: "fixed",
5316
+ [KLING_V3_PRO_I2V_ENDPOINT2]: "fixed"
5317
+ };
5318
+ var VIDEO_PINNED_DEFAULT_SECONDS2 = {
5319
+ [GROK_IMAGINE_I2V_ENDPOINT2]: 5,
5320
+ // Veo defaults to 8 s itself, and 8 s is the only length Lite first-and-last
5321
+ // renders; pinning it keeps the bill and the clip in step either way.
5322
+ ...Object.fromEntries(VEO_ENDPOINTS2.map((e) => [e, 8])),
5323
+ // The fal twins render the length their KIE entries default to, so a clip
5324
+ // falling back from KIE to fal has the same length.
5325
+ [GROK_IMAGINE_15_I2V_ENDPOINT2]: 8,
5326
+ [WAN_30_I2V_ENDPOINT2]: 5,
5327
+ [KLING_26_I2V_ENDPOINT2]: 5,
5328
+ [KLING_O3_STANDARD_I2V_ENDPOINT2]: 5,
5329
+ [KLING_O3_PRO_I2V_ENDPOINT2]: 5,
5330
+ [KLING_O3_PRO_R2V_ENDPOINT2]: 5,
5331
+ [GEMINI_OMNI_11_I2V_ENDPOINT2]: 8,
5332
+ // fal's own default on Kling 3.0 and 4.0 (schemas read 2026-11-03).
5333
+ [KLING_V3_STANDARD_I2V_ENDPOINT2]: 5,
5334
+ [KLING_V3_PRO_I2V_ENDPOINT2]: 5,
5335
+ [KLING_V4_I2V_ENDPOINT2]: 5,
5336
+ // fal's own default on MiniMax H3 (schema read 2026-11-04).
5337
+ [MINIMAX_H3_I2V_ENDPOINT2]: 5,
5338
+ // LTX-2.5 defaults to "auto", a length nobody can price up front; 6 s is its
5339
+ // shortest clip on both tiers.
5340
+ [LTX_25_FAST_I2V_ENDPOINT2]: 6,
5341
+ [LTX_25_PRO_I2V_ENDPOINT2]: 6,
5342
+ // fal's own default is 5 s on these (schemas read 2026-10-25); sent so the
5343
+ // bill cannot drift from the clip if fal ever changes it.
5344
+ "fal-ai/kling-video/v2.5-turbo/pro/image-to-video": 5,
5345
+ "fal-ai/bytedance/seedance/v1/pro/image-to-video": 5,
5346
+ "fal-ai/bytedance/seedance/v1/pro/text-to-video": 5,
5347
+ "blackforestlabs/flux-3/first-last-frame-to-video": 5,
5348
+ "blackforestlabs/flux-3/first-last-frame-to-video/draft": 5,
5349
+ "blackforestlabs/flux-3/keyframes-to-video": 5,
5350
+ "blackforestlabs/flux-3/keyframes-to-video/draft": 5,
5351
+ // `auto` by default on these (fal schemas, 2026-10-25): the model would pick
5352
+ // a length nobody can price. 5 s is the shortest FLUX.3 renders and the clip
5353
+ // the Seedance anchors were priced at.
5354
+ "bytedance/seedance-2.0/image-to-video": 5,
5355
+ "bytedance/seedance-2.5/image-to-video": 5,
5356
+ "bytedance/seedance-2.5/text-to-video": 5,
5357
+ "blackforestlabs/flux-3/image-to-video": 5,
5358
+ "blackforestlabs/flux-3/image-to-video/draft": 5
5359
+ };
5360
+ var VIDEO_DEFAULT_RESOLUTION2 = {
5361
+ "blackforestlabs/flux-3/keyframes-to-video": "720p",
5362
+ "blackforestlabs/flux-3/first-last-frame-to-video": "720p",
5363
+ "blackforestlabs/flux-3/image-to-video": "720p",
5364
+ // fal schema default: Grok renders 720p.
5365
+ [GROK_IMAGINE_I2V_ENDPOINT2]: "720p",
5366
+ ...Object.fromEntries(VEO_ENDPOINTS2.map((e) => [e, "720p"])),
5367
+ [GROK_IMAGINE_15_I2V_ENDPOINT2]: "720p",
5368
+ // fal schema default: Wan 3.0 renders 1080p unless asked for less.
5369
+ [WAN_30_I2V_ENDPOINT2]: "1080p",
5370
+ // fal schema default: Gemini Omni renders 720p, as on KIE.
5371
+ [GEMINI_OMNI_11_I2V_ENDPOINT2]: "720p",
5372
+ // fal schema default: Kling 4.0 renders 1080p unless asked for 720p.
5373
+ [KLING_V4_I2V_ENDPOINT2]: "1080p",
5374
+ // fal schema default: MiniMax H3 renders 2K (the canvas's 1080p) unless asked.
5375
+ [MINIMAX_H3_I2V_ENDPOINT2]: "1080p",
5376
+ // fal schema default: LTX-2.5 renders 1080p unless asked for less.
5377
+ [LTX_25_FAST_I2V_ENDPOINT2]: "1080p",
5378
+ [LTX_25_PRO_I2V_ENDPOINT2]: "1080p"
5379
+ };
5380
+ var VIDEO_ALLOWED_VALUES2 = {
5381
+ // Seedance 2.5 derives its aspect from the input image.
5382
+ "bytedance/seedance-2.5/image-to-video": { aspectRatio: ["auto"] },
5383
+ "fal-ai/kling-video/v2.5-turbo/pro/image-to-video": {
5384
+ aspectRatio: ["16:9", "9:16", "1:1"],
5385
+ durationSeconds: { values: [5, 10] }
5386
+ },
5387
+ [GROK_IMAGINE_I2V_ENDPOINT2]: {
5388
+ aspectRatio: ["auto", "16:9", "4:3", "3:2", "1:1", "2:3", "3:4", "9:16"],
5389
+ resolution: ["480p", "720p"],
5390
+ durationSeconds: { min: 1, max: 15 }
5391
+ },
5392
+ ...Object.fromEntries(
5393
+ VEO_ENDPOINTS2.map((e) => [
5394
+ e,
5395
+ {
5396
+ aspectRatio: ["auto", "16:9", "9:16"],
5397
+ resolution: e === VEO_LITE_I2V_ENDPOINT2 || e === VEO_LITE_FLF_ENDPOINT2 ? ["720p", "1080p"] : ["720p", "1080p", "4k"],
5398
+ // Lite first-and-last renders 8 s only (its schema pins the const).
5399
+ durationSeconds: { values: e === VEO_LITE_FLF_ENDPOINT2 ? [8] : [4, 6, 8] }
5400
+ }
5401
+ ])
5402
+ ),
5403
+ [GROK_IMAGINE_15_I2V_ENDPOINT2]: { resolution: ["480p", "720p", "1080p"], durationSeconds: { min: 1, max: 15 } },
5404
+ [WAN_30_I2V_ENDPOINT2]: {
5405
+ aspectRatio: ["auto", "16:9", "4:3", "1:1", "3:4", "9:16"],
5406
+ resolution: ["480p", "720p", "1080p"]
5407
+ },
5408
+ [KLING_26_I2V_ENDPOINT2]: { durationSeconds: { values: [5, 10] } },
5409
+ ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS2.map((e) => [e, { durationSeconds: { min: 3, max: 15 } }])),
5410
+ // Reference-to-video renders at a set ratio (default 16:9), not the frame's.
5411
+ [KLING_O3_PRO_R2V_ENDPOINT2]: { aspectRatio: ["16:9", "9:16", "1:1"], durationSeconds: { min: 3, max: 15 } },
5412
+ [LTX_25_FAST_I2V_ENDPOINT2]: {
5413
+ aspectRatio: ["auto", "16:9", "9:16"],
5414
+ // fal also renders 1440p, which the canvas does not offer.
5415
+ resolution: ["720p", "1080p", "4k"],
5416
+ durationSeconds: { values: [6, 8, 10, 12, 14, 16, 18, 20] }
5417
+ },
5418
+ [LTX_25_PRO_I2V_ENDPOINT2]: {
5419
+ aspectRatio: ["auto", "16:9", "9:16"],
5420
+ resolution: ["720p", "1080p"],
5421
+ durationSeconds: { values: [6, 8, 10] }
5422
+ },
5423
+ // fal also renders 360p, which the canvas does not offer.
5424
+ [GEMINI_OMNI_11_I2V_ENDPOINT2]: {
5425
+ aspectRatio: ["16:9", "9:16"],
5426
+ resolution: ["720p", "1080p", "4k"],
5427
+ durationSeconds: { min: 3, max: 10 }
5428
+ },
5429
+ ...Object.fromEntries(KLING_V3_I2V_ENDPOINTS2.map((e) => [e, { durationSeconds: { min: 3, max: 15 } }])),
5430
+ [KLING_V4_I2V_ENDPOINT2]: { resolution: ["720p", "1080p"], durationSeconds: { min: 3, max: 30 } },
5431
+ // fal also renders 480P, which the canvas does not offer. Its shortest clip
5432
+ // is 5 s (KIE's is 4 s), so a 4 s job on the H3 route has no fal fallback.
5433
+ [MINIMAX_H3_I2V_ENDPOINT2]: { resolution: ["720p", "1080p", "4k"], durationSeconds: { min: 5, max: 15 } }
5434
+ };
5435
+ var VIDEO_MAX_SECONDS_AT_RESOLUTION2 = {
5436
+ [LTX_25_FAST_I2V_ENDPOINT2]: { "4k": 10 }
5437
+ };
5438
+ var VIDEO_UNSUPPORTED_PARAMS2 = {
5439
+ // Kling 2.5 Turbo and Seedance 1.0 Pro render silent clips and their schemas
5440
+ // declare no audio field at all (fal model schemas, checked 2026-10-25), so a
5441
+ // sound choice is refused before submit instead of being sent and ignored.
5442
+ "fal-ai/kling-video/v2.5-turbo/pro/image-to-video": ["generateAudio"],
5443
+ "fal-ai/bytedance/seedance/v1/pro/image-to-video": ["generateAudio"],
5444
+ "fal-ai/bytedance/seedance/v1/pro/text-to-video": ["generateAudio"],
5445
+ // Kling O3 Edit follows the source clip: its length, frame, size and look are
5446
+ // the source's, and the endpoint declares none of these knobs. A duration in
5447
+ // particular would only have been a (wrong) billing figure; the completer
5448
+ // measures the result instead.
5449
+ "fal-ai/kling-video/o3/pro/video-to-video/edit": [
5450
+ "resolution",
5451
+ "seed",
5452
+ "negativePrompt",
5453
+ "aspectRatio",
5454
+ "generateAudio",
5455
+ "durationSeconds"
5456
+ ],
5457
+ // Wan's output is also as long as its source; it takes resolution and seed.
5458
+ "fal-ai/wan/v2.2-14b/animate/replace": ["durationSeconds", "negativePrompt", "aspectRatio", "generateAudio"],
5459
+ "blackforestlabs/flux-3/keyframes-to-video/draft": ["resolution", "seed", "negativePrompt"],
5460
+ "blackforestlabs/flux-3/first-last-frame-to-video/draft": ["resolution", "seed", "negativePrompt"],
5461
+ "blackforestlabs/flux-3/image-to-video/draft": ["resolution", "seed", "negativePrompt"],
5462
+ // The direct tier adds `resolution` (720p | 1080p) and nothing else: `seed` is
5463
+ // OUTPUT only on every FLUX.3 endpoint, so a caller cannot pin a take by seed.
5464
+ "blackforestlabs/flux-3/keyframes-to-video": ["seed", "negativePrompt"],
5465
+ "blackforestlabs/flux-3/first-last-frame-to-video": ["seed", "negativePrompt"],
5466
+ "blackforestlabs/flux-3/image-to-video": ["seed", "negativePrompt"],
5467
+ // Enhance renders whatever the cache holds: duration, aspect, audio and prompt
5468
+ // are all baked in, and the output is a fixed 1080p. `durationSeconds` is NOT
5469
+ // banned although it is not forwarded either (buildFalVideoInput sends only
5470
+ // the cache url + safety_tolerance): the executor injects the upstream
5471
+ // draft's duration as a COST hint, since enhance bills per second and
5472
+ // the request itself carries nothing the estimate could read.
5473
+ "blackforestlabs/flux-3/draft-enhance": [
5474
+ "resolution",
5475
+ "seed",
5476
+ "negativePrompt",
5477
+ "aspectRatio",
5478
+ "generateAudio"
5479
+ ],
5480
+ // Grok's schema declares no seed, negative prompt or audio switch: it always
5481
+ // renders audio.
5482
+ [GROK_IMAGINE_I2V_ENDPOINT2]: ["seed", "negativePrompt", "generateAudio"],
5483
+ [GROK_IMAGINE_15_I2V_ENDPOINT2]: ["aspectRatio", "seed", "negativePrompt", "generateAudio"],
5484
+ [WAN_30_I2V_ENDPOINT2]: ["negativePrompt"],
5485
+ [KLING_26_I2V_ENDPOINT2]: ["resolution", "aspectRatio", "seed"],
5486
+ ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS2.map((e) => [e, ["resolution", "aspectRatio", "seed", "negativePrompt"]])),
5487
+ // Its tier sets the size; it takes an aspect ratio, but no seed or negative prompt.
5488
+ [KLING_O3_PRO_R2V_ENDPOINT2]: ["resolution", "seed", "negativePrompt"],
5489
+ ...Object.fromEntries(LTX_25_I2V_ENDPOINTS2.map((e) => [e, ["seed", "negativePrompt"]])),
5490
+ // Its schema declares no seed, negative prompt or audio switch: it always
5491
+ // renders audio, at no extra charge.
5492
+ [GEMINI_OMNI_11_I2V_ENDPOINT2]: ["seed", "negativePrompt", "generateAudio"],
5493
+ // Kling 3.0: the tier sets the size and the start frame the shape; it takes a
5494
+ // negative prompt but no seed.
5495
+ ...Object.fromEntries(KLING_V3_I2V_ENDPOINTS2.map((e) => [e, ["resolution", "aspectRatio", "seed"]])),
5496
+ // Kling 4.0 follows the start frame's shape and always renders sound.
5497
+ [KLING_V4_I2V_ENDPOINT2]: ["aspectRatio", "seed", "negativePrompt", "generateAudio"],
5498
+ // MiniMax H3 follows the start frame's shape and always renders sound (a 5 s
5499
+ // test render of 2026-11-04 had a video and an audio track); it takes a seed.
5500
+ [MINIMAX_H3_I2V_ENDPOINT2]: ["aspectRatio", "negativePrompt", "generateAudio"]
5501
+ };
5502
+ var VIDEO_AUDIO_SWITCH2 = {
5503
+ ...Object.fromEntries(VEO_ENDPOINTS2.map((e) => [e, { default: false }])),
5504
+ [KLING_26_I2V_ENDPOINT2]: { default: false },
5505
+ ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS2.map((e) => [e, { default: false }])),
5506
+ [KLING_O3_PRO_R2V_ENDPOINT2]: { default: false },
5507
+ // Kling 3.0 renders sound unless sent false; Studio sends it silent unless asked.
5508
+ ...Object.fromEntries(KLING_V3_I2V_ENDPOINTS2.map((e) => [e, { default: false }])),
5509
+ "bytedance/seedance-2.5/image-to-video": { default: true },
5510
+ "bytedance/seedance-2.0/image-to-video": { default: true },
5511
+ [WAN_30_I2V_ENDPOINT2]: { default: true },
5512
+ ...Object.fromEntries(LTX_25_I2V_ENDPOINTS2.map((e) => [e, { default: true }])),
5513
+ "blackforestlabs/flux-3/image-to-video/draft": { default: true },
5514
+ "blackforestlabs/flux-3/first-last-frame-to-video/draft": { default: true },
5515
+ "blackforestlabs/flux-3/keyframes-to-video/draft": { default: true },
5516
+ "blackforestlabs/flux-3/image-to-video": { default: true },
5517
+ "blackforestlabs/flux-3/first-last-frame-to-video": { default: true },
5518
+ "blackforestlabs/flux-3/keyframes-to-video": { default: true }
5519
+ };
5520
+ var NO_AUDIO_SWITCH = { switchable: false };
5521
+ function videoSettingSupport(model) {
5522
+ if (!model?.id || model.modality !== "video") return null;
5523
+ const upstream = getProviderModelName(model.id);
5524
+ if (model.provider === "kie") {
5525
+ const spec = KIE_VIDEO_SPECS2[upstream];
5526
+ if (!spec) return null;
5527
+ return {
5528
+ aspectRatios: spec.aspectRatios ?? [],
5529
+ resolutions: spec.resolutions,
5530
+ durations: spec.durations,
5531
+ defaultSeconds: spec.defaultSeconds,
5532
+ // The KIE spec says whether the job may switch audio (`audioSwitch`, the
5533
+ // rule its pre-submit check refuses by); its `defaultAudio` is the state
5534
+ // only where there is a switch.
5535
+ generateAudio: spec.audioSwitch ? { switchable: true, default: spec.defaultAudio } : NO_AUDIO_SWITCH
5536
+ };
5537
+ }
5538
+ if (model.provider === "openrouter") {
5539
+ const spec = OPENROUTER_VIDEO_SPECS2[upstream];
5540
+ if (!spec) return null;
5541
+ return {
5542
+ aspectRatios: spec.aspectRatios,
5543
+ resolutions: spec.resolutions,
5544
+ durations: spec.durations,
5545
+ defaultSeconds: spec.defaultSeconds,
5546
+ // Every OpenRouter video model is sent `generate_audio`, silent unless
5547
+ // the job asks (`openRouterVideoPlan`).
5548
+ generateAudio: { switchable: true, default: false }
5549
+ };
5550
+ }
5551
+ if (model.provider === "fal") {
5552
+ const allowed = VIDEO_ALLOWED_VALUES2[upstream];
5553
+ const unsupported = VIDEO_UNSUPPORTED_PARAMS2[upstream] ?? [];
5554
+ const pinned = VIDEO_PINNED_DEFAULT_SECONDS2[upstream];
5555
+ const maxSecondsAt = VIDEO_MAX_SECONDS_AT_RESOLUTION2[upstream];
5556
+ return {
5557
+ ...maxSecondsAt ? { maxSecondsAt } : {},
5558
+ aspectRatios: unsupported.includes("aspectRatio") ? [] : allowed?.aspectRatio ?? null,
5559
+ resolutions: unsupported.includes("resolution") ? [] : allowed?.resolution ?? null,
5560
+ durations: unsupported.includes("durationSeconds") ? { values: [] } : allowed?.durationSeconds ?? null,
5561
+ ...pinned !== void 0 ? { defaultSeconds: pinned } : {},
5562
+ generateAudio: falAudioSupport(upstream, unsupported)
5563
+ };
5564
+ }
5565
+ return null;
5566
+ }
5567
+ function falAudioSupport(endpoint, unsupported) {
5568
+ if (unsupported.includes("generateAudio")) return NO_AUDIO_SWITCH;
5569
+ const declared = VIDEO_AUDIO_SWITCH2[endpoint];
5570
+ return declared ? { switchable: true, default: declared.default } : null;
5571
+ }
5572
+ function supportedResolutions(model) {
5573
+ const declared = model?.capabilities?.resolutions;
5574
+ return declared ? declared : null;
5575
+ }
5576
+ function resolutionRefusal(model, resolution) {
5577
+ if (resolution === void 0 || resolution === null || resolution === "") return null;
5578
+ const supported = supportedResolutions(model);
5579
+ if (!model || supported === null) return null;
5580
+ const name = model.label ?? model.id;
5581
+ if (supported.length === 0) {
5582
+ 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.`;
5583
+ }
5584
+ const tier = imageResolutionTier(resolution);
5585
+ if (tier && supported.includes(tier)) return null;
5586
+ if (model.capabilities?.tierKind === "quality") {
5587
+ const offered = supported.map((t) => `${imageTierLabel(model, t).toLowerCase()} (${IMAGE_SIZE_OF_TIER[t]})`).join(", ");
5588
+ return `${name} takes the quality ${offered}, not "${String(resolution)}". Pick one of those.`;
5589
+ }
5590
+ return `${name} renders at ${supported.join(", ")}, not "${String(resolution)}". Pick one of those.`;
5591
+ }
5592
+ function sendableSettings(settings, model) {
5593
+ if (!settings || !("generateAudio" in settings)) return settings;
5594
+ if (videoSettingSupport(model)?.generateAudio?.switchable === true) return settings;
5595
+ const kept = { ...settings };
5596
+ delete kept.generateAudio;
5597
+ return kept;
5598
+ }
5599
+ function sendableOptions(options, model) {
5600
+ if (!options || typeof options !== "object" || Array.isArray(options) || !("generateAudio" in options)) return options;
5601
+ if (videoSettingSupport(model)?.generateAudio?.switchable === true) return options;
5602
+ const kept = { ...options };
5603
+ delete kept.generateAudio;
5604
+ return kept;
5605
+ }
5606
+ var PROMPT_REQUIRED = /* @__PURE__ */ new Set([
5607
+ "text-to-image",
5608
+ "image-to-image",
5609
+ "image-edit",
5610
+ "text-to-3d",
5611
+ "image-to-3d",
5612
+ "multiview-to-3d",
5613
+ "text-to-video",
5614
+ // Texture: 3D AI Studio refuses a texture request without a prompt or a
5615
+ // reference image (probed 2026-09-26), and Studio sends no reference image,
5616
+ // so the material description is required. It binds `texturePrompt`, see
5617
+ // `promptInputKey`.
5618
+ "texture",
5619
+ // Audio is prompt-only: a music description (text-to-audio) / the text to
5620
+ // speak (text-to-speech). No upstream wire, so no portBinding entry.
5621
+ "text-to-audio",
5622
+ "text-to-speech"
5623
+ ]);
5624
+ var PROMPT_OPTIONAL = /* @__PURE__ */ new Set(["image-to-video", "image-to-json", "video-to-video"]);
5625
+ function taskNeedsPrompt(task) {
5626
+ return PROMPT_REQUIRED.has(task) || PROMPT_OPTIONAL.has(task);
5627
+ }
5628
+ function taskRequiresPrompt(task) {
5629
+ return PROMPT_REQUIRED.has(task);
5630
+ }
5631
+ function promptInputKey(task) {
5632
+ return task === "texture" ? "texturePrompt" : "prompt";
5633
+ }
5634
+ function portBinding(task, port) {
5635
+ if (port === "image" && (task === "image-to-3d" || task === "multiview-to-3d" || task === "image-to-video" || task === "image-to-text" || task === "image-to-json")) {
5636
+ return { key: "inputImageUrl", path: "url" };
5637
+ }
5638
+ if (port === "reference" && task === "image-to-video") {
5639
+ return { key: "referenceImageUrls", path: "url", wrap: "array" };
5640
+ }
5641
+ if (port === "mesh3d" && (task === "remesh" || task === "texture" || task === "rig")) {
5642
+ return { key: "parentAssetId", path: "assetId" };
5643
+ }
5644
+ if (port === "video" && task === "video-to-text") {
5645
+ return { key: "inputVideoUrl", path: "url" };
5646
+ }
5647
+ if (port === "video" && task === "video-to-video") {
5648
+ return { key: "inputVideoUrl", path: "url" };
5649
+ }
5650
+ if (port === "image" && task === "video-to-video") {
5651
+ return { key: "inputImages", path: "url", wrap: "array" };
5652
+ }
5653
+ if (port === "video" && task === "video-enhance") {
5654
+ return { key: "draftCacheUrl", path: "draftCacheUrl" };
5655
+ }
5656
+ if (port === "image" && (task === "image-edit" || task === "image-to-image")) {
5657
+ return { key: "inputImages", path: "url", wrap: "array" };
5658
+ }
5659
+ if (port === "text" && taskNeedsPrompt(task)) {
5660
+ return { key: promptInputKey(task), path: "text" };
5661
+ }
5662
+ if (port === "image" && (task === "upscale" || task === "background-remove")) {
5663
+ return { key: "parentAssetId", path: "assetId" };
5664
+ }
5665
+ if (port === "audio" && task === "speech-to-text") {
5666
+ return { key: "inputAudioUrl", path: "url" };
5667
+ }
5668
+ if (port === "image" && task === "judge") {
5669
+ return { key: "candidateAssetIds", path: "assetId", wrap: "array" };
5670
+ }
5671
+ return null;
5672
+ }
5673
+ function canConnect(sourceOut, targetTask, targetPort) {
5674
+ if (sourceOut !== portContent(targetPort)) return false;
5675
+ return portBinding(targetTask, targetPort) !== null;
4504
5676
  }
4505
5677
  function portCardinality(task, port, model) {
4506
5678
  if (portBinding(task, port) === null) return "none";
@@ -4550,10 +5722,10 @@ function orderedPortKey(task, port, ordinal, model) {
4550
5722
  if (portCardinality(task, port, model) === "two" && ordinal === 1) return "endImageUrl";
4551
5723
  return canonical.key;
4552
5724
  }
4553
- function sourcePortOf(node) {
4554
- switch (node.kind) {
5725
+ function sourcePortOf(node2) {
5726
+ switch (node2.kind) {
4555
5727
  case "task":
4556
- return taskPorts(node.task).output;
5728
+ return taskPorts(node2.task).output;
4557
5729
  case "prompt-source":
4558
5730
  return "text";
4559
5731
  case "image-source":
@@ -4561,35 +5733,35 @@ function sourcePortOf(node) {
4561
5733
  case "video-source":
4562
5734
  return "video";
4563
5735
  case "input":
4564
- return node.type;
5736
+ return node2.type;
4565
5737
  }
4566
5738
  }
4567
- function targetCardinality(node, port) {
4568
- if (node.kind !== "task") return "none";
4569
- return portCardinality(node.task, port, node.model);
5739
+ function targetCardinality(node2, port) {
5740
+ if (node2.kind !== "task") return "none";
5741
+ return portCardinality(node2.task, port, node2.model);
4570
5742
  }
4571
- function slotRefusal(node, port, wired) {
4572
- const cardinality = targetCardinality(node, port);
5743
+ function slotRefusal(node2, port, wired) {
5744
+ const cardinality = targetCardinality(node2, port);
4573
5745
  let limit = cardinalityLimit(cardinality);
4574
- if (port === "reference" && node.kind === "task") {
4575
- const refs = modelCharacterReferences(node.model);
5746
+ if (port === "reference" && node2.kind === "task") {
5747
+ const refs = modelCharacterReferences(node2.model);
4576
5748
  if (refs) limit = Math.min(limit, refs.maxTotalImages);
4577
5749
  if (wired < limit) return null;
4578
5750
  if (!refs) {
4579
- return `node "${node.id}" (${node.model || "no model"}) takes no character references; pick a model that holds identity from reference images (Kling elements) or remove the reference wires`;
5751
+ return `node "${node2.id}" (${node2.model || "no model"}) takes no character references; pick a model that holds identity from reference images (Kling elements) or remove the reference wires`;
4580
5752
  }
4581
- return `node "${node.id}" (${node.model}) takes at most ${limit} character reference images in all`;
5753
+ return `node "${node2.id}" (${node2.model}) takes at most ${limit} character reference images in all`;
4582
5754
  }
4583
- if (cardinality === "many" && node.kind === "task" && node.model) {
4584
- const cap = tryGetModel2(node.model)?.capabilities?.maxInputImages;
5755
+ if (cardinality === "many" && node2.kind === "task" && node2.model) {
5756
+ const cap = tryGetModel2(node2.model)?.capabilities?.maxInputImages;
4585
5757
  if (typeof cap === "number" && cap > 0) limit = Math.min(limit, cap);
4586
5758
  }
4587
5759
  if (wired < limit) return null;
4588
- if (cardinality === "one") return `node "${node.id}" accepts one ${port} wire, got more`;
5760
+ if (cardinality === "one") return `node "${node2.id}" accepts one ${port} wire, got more`;
4589
5761
  if (cardinality === "two") {
4590
- return `node "${node.id}" takes two ${port} wires (start frame, end frame), got more. A shot that needs more than two keyframes wants a keyframes model (FLUX.3 keyframes), which takes up to ten.`;
5762
+ return `node "${node2.id}" takes two ${port} wires (start frame, end frame), got more. A shot that needs more than two keyframes wants a keyframes model (FLUX.3 keyframes), which takes up to ten.`;
4591
5763
  }
4592
- return `node "${node.id}" (${node.kind === "task" ? node.model : node.kind}) takes at most ${limit} ${port} wires`;
5764
+ return `node "${node2.id}" (${node2.kind === "task" ? node2.model : node2.kind}) takes at most ${limit} ${port} wires`;
4593
5765
  }
4594
5766
  function wireLegality(source, target, port) {
4595
5767
  if (source.id === target.id) return { ok: false, code: "cycle", message: `node "${source.id}" cannot wire into itself` };
@@ -4651,17 +5823,17 @@ function validateDocument(doc) {
4651
5823
  };
4652
5824
  }
4653
5825
  const byId = /* @__PURE__ */ new Map();
4654
- for (const node of doc.nodes) {
4655
- if (byId.has(node.id)) return { ok: false, code: "conflict", message: `duplicate node id "${node.id}"` };
4656
- byId.set(node.id, node);
5826
+ for (const node2 of doc.nodes) {
5827
+ if (byId.has(node2.id)) return { ok: false, code: "conflict", message: `duplicate node id "${node2.id}"` };
5828
+ byId.set(node2.id, node2);
4657
5829
  }
4658
5830
  const inputNames = /* @__PURE__ */ new Set();
4659
- for (const node of doc.nodes) {
4660
- if (node.kind !== "input") continue;
4661
- if (inputNames.has(node.name)) {
4662
- return { ok: false, code: "conflict", message: `duplicate input name "${node.name}"` };
5831
+ for (const node2 of doc.nodes) {
5832
+ if (node2.kind !== "input") continue;
5833
+ if (inputNames.has(node2.name)) {
5834
+ return { ok: false, code: "conflict", message: `duplicate input name "${node2.name}"` };
4663
5835
  }
4664
- inputNames.add(node.name);
5836
+ inputNames.add(node2.name);
4665
5837
  }
4666
5838
  const edgeKeys = /* @__PURE__ */ new Set();
4667
5839
  const slots = /* @__PURE__ */ new Map();
@@ -4695,12 +5867,12 @@ function validateDocument(doc) {
4695
5867
  };
4696
5868
  }
4697
5869
  }
4698
- for (const node of doc.nodes) {
4699
- if (node.kind !== "task" || !node.model) continue;
4700
- const baked = node.bakedInputs?.imageSize;
4701
- const requested = node.settings?.resolution ?? (baked && baked.kind === "literal" ? baked.value : void 0);
4702
- const refusal = resolutionRefusal(tryGetModel2(node.model), requested);
4703
- if (refusal) return { ok: false, code: "unsupported", message: `"${node.id}": ${refusal}` };
5870
+ for (const node2 of doc.nodes) {
5871
+ if (node2.kind !== "task" || !node2.model) continue;
5872
+ const baked = node2.bakedInputs?.imageSize;
5873
+ const requested = node2.settings?.resolution ?? (baked && baked.kind === "literal" ? baked.value : void 0);
5874
+ const refusal = resolutionRefusal(tryGetModel2(node2.model), requested);
5875
+ if (refusal) return { ok: false, code: "unsupported", message: `"${node2.id}": ${refusal}` };
4704
5876
  }
4705
5877
  if (documentTopologicalOrder(doc) === null) {
4706
5878
  return { ok: false, code: "cycle", message: `document "${doc.id}" has a cycle in its wires` };
@@ -4765,7 +5937,7 @@ var InputNodePropsSchema = z4.object({
4765
5937
  }).partial().strict();
4766
5938
  var GroupPropsSchema = z4.object({
4767
5939
  label: LabelSchema.nullable(),
4768
- nodeIds: z4.array(IdSchema).min(1)
5940
+ nodeIds: z4.array(IdSchema).min(1).max(MAX_DOCUMENT_NODES)
4769
5941
  }).partial().strict();
4770
5942
  var DocumentPropsSchema = z4.object({
4771
5943
  label: LabelSchema,
@@ -4861,7 +6033,7 @@ var GroupOpSchema = z4.object({
4861
6033
  type: z4.literal("group"),
4862
6034
  id: IdSchema,
4863
6035
  label: LabelSchema.optional(),
4864
- nodeIds: z4.array(IdSchema).min(1),
6036
+ nodeIds: z4.array(IdSchema).min(1).max(MAX_DOCUMENT_NODES),
4865
6037
  index: Index.optional()
4866
6038
  });
4867
6039
  var UngroupOpSchema = z4.object({
@@ -4991,6 +6163,10 @@ function likenessConfirmationRequiredMessage() {
4991
6163
  function likenessConfirmationToolDescription() {
4992
6164
  return `Must be the literal true. It records this confirmation on the character: "${LIKENESS_ACKNOWLEDGEMENT}" Ask the human you act for and pass true only after they confirm it for this character; never assert it on your own. Terms and acceptable use: ${TERMS_URL}`;
4993
6165
  }
6166
+ var IMAGE_ASPECT_RATIOS2 = ASPECT_RATIOS2.map((value) => ({
6167
+ value,
6168
+ label: value
6169
+ }));
4994
6170
  function taskModality(task) {
4995
6171
  const out = taskPorts(task).output;
4996
6172
  switch (out) {
@@ -5015,6 +6191,12 @@ function lit(value) {
5015
6191
  function isFiniteNumber(v) {
5016
6192
  return typeof v === "number" && Number.isFinite(v);
5017
6193
  }
6194
+ function voiceSettingsOf(v) {
6195
+ if (!v || typeof v !== "object" || Array.isArray(v)) return null;
6196
+ const o = v;
6197
+ if (!isFiniteNumber(o.stability) || !isFiniteNumber(o.similarityBoost) || !isFiniteNumber(o.speed)) return null;
6198
+ return { stability: o.stability, similarityBoost: o.similarityBoost, speed: o.speed };
6199
+ }
5018
6200
  function settingsBindings(task, settings) {
5019
6201
  if (!task || !settings || Object.keys(settings).length === 0) return {};
5020
6202
  const modality = taskModality(task);
@@ -5035,11 +6217,17 @@ function settingsBindings(task, settings) {
5035
6217
  if (typeof settings.aspectRatio === "string") options.aspectRatio = settings.aspectRatio;
5036
6218
  if (typeof settings.resolution === "string") options.resolution = settings.resolution;
5037
6219
  if (isFiniteNumber(settings.duration)) options.durationSeconds = settings.duration;
6220
+ if (typeof settings.generateAudio === "boolean") options.generateAudio = settings.generateAudio;
5038
6221
  return Object.keys(options).length > 0 ? { options: lit(options) } : {};
5039
6222
  }
5040
6223
  case "audio": {
5041
6224
  const options = {};
5042
6225
  if (isFiniteNumber(settings.duration)) options.durationSeconds = settings.duration;
6226
+ if (task === "text-to-speech") {
6227
+ if (typeof settings.voiceId === "string" && settings.voiceId) options.voiceId = settings.voiceId;
6228
+ const voice = voiceSettingsOf(settings.voiceSettings);
6229
+ if (voice) options.voiceSettings = voice;
6230
+ }
5043
6231
  return Object.keys(options).length > 0 ? { options: lit(options) } : {};
5044
6232
  }
5045
6233
  default:
@@ -5092,6 +6280,41 @@ function keyframePositionsFor(sourceIds, settings) {
5092
6280
  return { ok: true, frames };
5093
6281
  }
5094
6282
  var REFERENCE_ELEMENTS_SETTING = "referenceElements";
6283
+ var CAST_MENTIONS_SETTING = "castMentions";
6284
+ var CAST_REFERENCES_SETTING = "castReferences";
6285
+ var CAST_TASKS = /* @__PURE__ */ new Set(["text-to-image", "image-edit", "image-to-image", "image-to-video"]);
6286
+ function castSettingOf(task, settings) {
6287
+ const none = { cast: [], own: false };
6288
+ if (!CAST_TASKS.has(task)) return none;
6289
+ const mentions = settings?.[CAST_MENTIONS_SETTING];
6290
+ const own = !(Array.isArray(mentions) && mentions.length > 0);
6291
+ const raw = own ? settings?.[CAST_REFERENCES_SETTING] : mentions;
6292
+ if (!Array.isArray(raw)) return none;
6293
+ const cast = raw.flatMap((r) => {
6294
+ const parsed = CastMemberSchema.safeParse(r);
6295
+ return parsed.success ? [parsed.data] : [];
6296
+ });
6297
+ return { cast, own: own && cast.length > 0 };
6298
+ }
6299
+ function castByElement(cast, elementOf) {
6300
+ 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.";
6301
+ const characters = cast.filter((m) => m.kind === "character");
6302
+ const placed = [];
6303
+ for (const member of characters) {
6304
+ const elements = new Set((member.sources ?? []).filter((s) => elementOf.has(s)).map((s) => elementOf.get(s)));
6305
+ if (elements.size === 0) return { ok: false, reason: `${member.name}'s reference images are no longer wired into this clip. ${again}` };
6306
+ if (elements.size > 1) return { ok: false, reason: `${member.name}'s reference images are set to more than one character number. ${again}` };
6307
+ const element = [...elements][0];
6308
+ const twin = placed.find((p) => p.element === element);
6309
+ if (twin) return { ok: false, reason: `${twin.member.name} and ${member.name} are wired as the same character. ${again}` };
6310
+ placed.push({ member, element });
6311
+ }
6312
+ const wired = new Set(elementOf.values());
6313
+ if (wired.size !== placed.length) {
6314
+ 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.` };
6315
+ }
6316
+ return { ok: true, cast: placed.sort((a, b) => a.element - b.element).map((p) => p.member) };
6317
+ }
5095
6318
  function referenceElementsFor(sourceIds, settings, limits) {
5096
6319
  const raw = settings?.[REFERENCE_ELEMENTS_SETTING];
5097
6320
  if (raw !== void 0 && (raw === null || typeof raw !== "object" || Array.isArray(raw))) {
@@ -5255,26 +6478,28 @@ function documentToDefinition(doc, opts = {}) {
5255
6478
  ...n.default !== void 0 ? { default: n.default } : {}
5256
6479
  }));
5257
6480
  let nodes = [];
5258
- for (const node of doc.nodes) {
5259
- if (node.kind !== "task") continue;
5260
- const { task } = node;
6481
+ const elementOfSource = /* @__PURE__ */ new Map();
6482
+ const referencesRefused = /* @__PURE__ */ new Set();
6483
+ for (const node2 of doc.nodes) {
6484
+ if (node2.kind !== "task") continue;
6485
+ const { task } = node2;
5261
6486
  if (taskExecution(task) === null) {
5262
6487
  issues.push({
5263
6488
  code: "not_runnable",
5264
- nodeId: node.id,
5265
- message: `Node "${node.id}" (${task}) is not runnable yet.`
6489
+ nodeId: node2.id,
6490
+ message: `Node "${node2.id}" (${task}) is not runnable yet.`
5266
6491
  });
5267
6492
  continue;
5268
6493
  }
5269
- if (node.model.length === 0) {
6494
+ if (node2.model.length === 0) {
5270
6495
  issues.push({
5271
6496
  code: "no_model",
5272
- nodeId: node.id,
5273
- message: `Node "${node.id}" needs a model.`
6497
+ nodeId: node2.id,
6498
+ message: `Node "${node2.id}" needs a model.`
5274
6499
  });
5275
6500
  }
5276
6501
  const inputs = {};
5277
- const wires = incoming.get(node.id) ?? [];
6502
+ const wires = incoming.get(node2.id) ?? [];
5278
6503
  const textWire = wires.find((e) => e.port === "text");
5279
6504
  let promptMissing = false;
5280
6505
  if (taskNeedsPrompt(task)) {
@@ -5292,15 +6517,15 @@ function documentToDefinition(doc, opts = {}) {
5292
6517
  path: portBinding(task, "text").path
5293
6518
  };
5294
6519
  } else {
5295
- const text = node.prompt.trim();
6520
+ const text = node2.prompt.trim();
5296
6521
  if (text.length > 0) inputs[key] = { kind: "literal", value: text };
5297
6522
  }
5298
6523
  if (!(key in inputs) && taskRequiresPrompt(task)) {
5299
6524
  promptMissing = true;
5300
6525
  issues.push({
5301
6526
  code: "prompt_required",
5302
- nodeId: node.id,
5303
- message: `Node "${node.id}" (${task}) needs a prompt.`
6527
+ nodeId: node2.id,
6528
+ message: `Node "${node2.id}" (${task}) needs a prompt.`
5304
6529
  });
5305
6530
  }
5306
6531
  }
@@ -5313,17 +6538,17 @@ function documentToDefinition(doc, opts = {}) {
5313
6538
  }
5314
6539
  for (const [port, portWires] of byPort) {
5315
6540
  const b = portBinding(task, port);
5316
- const cardinality = portCardinality(task, port, node.model);
5317
- const keyframes = port === "image" && task === "image-to-video" && modelAcceptsKeyframes(node.model);
6541
+ const cardinality = portCardinality(task, port, node2.model);
6542
+ const keyframes = port === "image" && task === "image-to-video" && modelAcceptsKeyframes(node2.model);
5318
6543
  const references = port === "reference";
5319
- const listKey = orderedPortKey(task, port, 0, node.model) ?? b.key;
6544
+ const listKey = orderedPortKey(task, port, 0, node2.model) ?? b.key;
5320
6545
  const items2 = [];
5321
6546
  const itemSources = [];
5322
6547
  let uploading = false;
5323
6548
  for (const [ordinal, e] of portWires.entries()) {
5324
6549
  const source = byId.get(e.source);
5325
6550
  const single = !keyframes && !references && (cardinality !== "many" || portWires.length === 1);
5326
- const key = orderedPortKey(task, port, ordinal, node.model) ?? b.key;
6551
+ const key = orderedPortKey(task, port, ordinal, node2.model) ?? b.key;
5327
6552
  const wrap = single && b.wrap === "array";
5328
6553
  let item = null;
5329
6554
  if (source.kind === "image-source") {
@@ -5331,8 +6556,8 @@ function documentToDefinition(doc, opts = {}) {
5331
6556
  if (!isUsableSourceUrl(url)) {
5332
6557
  issues.push({
5333
6558
  code: "source_uploading",
5334
- nodeId: node.id,
5335
- message: `Image source for "${node.id}" is still uploading; wait for it to finish.`
6559
+ nodeId: node2.id,
6560
+ message: `Image source for "${node2.id}" is still uploading; wait for it to finish.`
5336
6561
  });
5337
6562
  uploading = true;
5338
6563
  continue;
@@ -5343,8 +6568,8 @@ function documentToDefinition(doc, opts = {}) {
5343
6568
  if (!isUsableSourceUrl(clip)) {
5344
6569
  issues.push({
5345
6570
  code: "source_uploading",
5346
- nodeId: node.id,
5347
- message: `Video source for "${node.id}" is still uploading; wait for it to finish.`
6571
+ nodeId: node2.id,
6572
+ message: `Video source for "${node2.id}" is still uploading; wait for it to finish.`
5348
6573
  });
5349
6574
  uploading = true;
5350
6575
  continue;
@@ -5363,20 +6588,21 @@ function documentToDefinition(doc, opts = {}) {
5363
6588
  }
5364
6589
  }
5365
6590
  if (references && !uploading && items2.length > 0) {
5366
- const limits = modelCharacterReferences(node.model);
6591
+ const limits = modelCharacterReferences(node2.model);
5367
6592
  const grouped = limits ? referenceElementsFor(
5368
6593
  itemSources,
5369
- node.settings,
6594
+ node2.settings,
5370
6595
  limits
5371
6596
  ) : {
5372
6597
  ok: false,
5373
- reason: `${node.model || "this model"} takes no character references`
6598
+ reason: `${node2.model || "this model"} takes no character references`
5374
6599
  };
5375
6600
  if (grouped.ok) {
5376
6601
  inputs[listKey] = {
5377
6602
  kind: "list",
5378
6603
  items: grouped.order.map((i) => items2[i])
5379
6604
  };
6605
+ elementOfSource.set(node2.id, new Map(grouped.order.map((i, k) => [itemSources[i], grouped.elements[k]])));
5380
6606
  inputs.referenceElementIndexes = {
5381
6607
  kind: "literal",
5382
6608
  value: grouped.elements
@@ -5384,9 +6610,10 @@ function documentToDefinition(doc, opts = {}) {
5384
6610
  } else {
5385
6611
  issues.push({
5386
6612
  code: "character_references",
5387
- nodeId: node.id,
5388
- message: `Node "${node.id}": ${grouped.reason}`
6613
+ nodeId: node2.id,
6614
+ message: `Node "${node2.id}": ${grouped.reason}`
5389
6615
  });
6616
+ referencesRefused.add(node2.id);
5390
6617
  }
5391
6618
  continue;
5392
6619
  }
@@ -5395,7 +6622,7 @@ function documentToDefinition(doc, opts = {}) {
5395
6622
  if (keyframes && !uploading && items2.length > 0) {
5396
6623
  const positions = keyframePositionsFor(
5397
6624
  portWires.map((e) => e.source),
5398
- node.settings
6625
+ node2.settings
5399
6626
  );
5400
6627
  if (positions.ok) {
5401
6628
  inputs.keyframeFrameIndexes = {
@@ -5405,30 +6632,48 @@ function documentToDefinition(doc, opts = {}) {
5405
6632
  } else {
5406
6633
  issues.push({
5407
6634
  code: "keyframe_positions",
5408
- nodeId: node.id,
5409
- message: `Node "${node.id}": ${positions.reason}`
6635
+ nodeId: node2.id,
6636
+ message: `Node "${node2.id}": ${positions.reason}`
5410
6637
  });
5411
6638
  }
5412
6639
  }
5413
6640
  }
5414
- for (const [key, binding] of Object.entries(node.bakedInputs))
5415
- if (!(key in inputs)) inputs[key] = binding;
6641
+ const imagesWired = "inputImages" in inputs;
6642
+ for (const [key, binding] of Object.entries(node2.bakedInputs)) {
6643
+ if (key in inputs) continue;
6644
+ if (key === "options" && binding.kind === "literal") {
6645
+ const kept = sendableOptions(binding.value, tryGetModel2(node2.model));
6646
+ inputs[key] = kept === binding.value ? binding : { kind: "literal", value: kept };
6647
+ } else inputs[key] = binding;
6648
+ }
5416
6649
  if (task === "image-to-video" && "referenceImageUrls" in inputs && !("inputImageUrl" in inputs)) {
5417
6650
  issues.push({
5418
6651
  code: "character_references",
5419
- nodeId: node.id,
5420
- message: `Node "${node.id}": character references need a start frame; wire one into the image port.`
6652
+ nodeId: node2.id,
6653
+ message: `Node "${node2.id}": character references need a start frame; wire one into the image port.`
5421
6654
  });
5422
6655
  }
5423
6656
  if (Object.keys(inputs).length === 0 && !promptMissing) {
5424
6657
  issues.push({
5425
6658
  code: "no_inputs",
5426
- nodeId: node.id,
5427
- message: `Node "${node.id}" (${task}) needs an input: wire in an upstream asset or type a prompt.`
6659
+ nodeId: node2.id,
6660
+ message: `Node "${node2.id}" (${task}) needs an input: wire in an upstream asset or type a prompt.`
5428
6661
  });
5429
6662
  }
5430
- Object.assign(inputs, settingsBindings(task, node.settings));
5431
- nodes.push({ id: node.id, task, model: node.model, inputs });
6663
+ Object.assign(inputs, settingsBindings(task, sendableSettings(node2.settings, tryGetModel2(node2.model))));
6664
+ const named = castSettingOf(task, node2.settings);
6665
+ const { own } = named;
6666
+ let cast = named.cast;
6667
+ if (task === "image-to-video" && cast.length > 0 && referencesRefused.has(node2.id)) cast = [];
6668
+ else if (task === "image-to-video" && cast.length > 0) {
6669
+ const placed = castByElement(cast, elementOfSource.get(node2.id) ?? /* @__PURE__ */ new Map());
6670
+ if (placed.ok) cast = placed.cast;
6671
+ else {
6672
+ issues.push({ code: "character_references", nodeId: node2.id, message: `Node "${node2.id}": ${placed.reason}` });
6673
+ cast = [];
6674
+ }
6675
+ }
6676
+ nodes.push({ id: node2.id, task, model: node2.model, inputs, ...cast.length > 0 ? { cast } : {}, ...own ? { castOwn: true } : {}, ...cast.length > 0 && imagesWired ? { imagesWired: true } : {} });
5432
6677
  }
5433
6678
  if (scope) {
5434
6679
  const projected = new Set(nodes.map((n) => n.id));
@@ -5477,13 +6722,19 @@ function documentToDefinition(doc, opts = {}) {
5477
6722
  }
5478
6723
 
5479
6724
  // src/characterSheet.ts
6725
+ var OVERVIEW_CATEGORY = "overview";
6726
+ var OVERVIEW_ASPECT_RATIO = "21:9";
6727
+ var OVERVIEW_RESOLUTION = "4K";
5480
6728
  var IDENTITY_INSTRUCTION = "This is the same person, same face, same identity as the reference image: keep the facial structure, features, hair, and proportions identical. Do not invent a new face.";
5481
- var NEUTRAL_STUDIO = "Plain light-gray seamless studio background, no props, no text, no watermark, photorealistic, sharp focus.";
6729
+ 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.";
6730
+ 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.';
6731
+ 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.";
6732
+ var TURNAROUND_CAMERA_INSTRUCTION = "Camera: straight-on, at the person's chest height, the same height in every view, long lens with no wide-angle distortion, like an orthographic turnaround. Even, soft, neutral studio lighting.";
5482
6733
  var WARDROBE_STANDARD_PHRASE = "plain heather-gray crew-neck t-shirt";
5483
6734
  var WARDROBE_INSTRUCTION = `Wardrobe: the character is wearing a ${WARDROBE_STANDARD_PHRASE}, unbranded, with no logos, graphics, prints, or patterns.`;
5484
- var FULL_BODY_WARDROBE_INSTRUCTION = `Wardrobe: the character is wearing a ${WARDROBE_STANDARD_PHRASE} and plain dark straight-leg trousers, unbranded, with no logos, graphics, prints, or patterns.`;
6735
+ var FULL_BODY_WARDROBE_INSTRUCTION = `Wardrobe: the character is wearing a ${WARDROBE_STANDARD_PHRASE}, plain dark straight-leg trousers and plain dark shoes, unbranded, with no logos, graphics, prints, or patterns.`;
5485
6736
  function wardrobeInstructionForCategory(category) {
5486
- return category === "full-body" ? FULL_BODY_WARDROBE_INSTRUCTION : WARDROBE_INSTRUCTION;
6737
+ return category === "full-body" || category === "back" ? FULL_BODY_WARDROBE_INSTRUCTION : WARDROBE_INSTRUCTION;
5487
6738
  }
5488
6739
  function identityAnchor(description) {
5489
6740
  return `Character identity (keep identical in every view): ${description.trim()}`;
@@ -5499,44 +6750,64 @@ function seedFacePrompt(description) {
5499
6750
  ].join("\n\n");
5500
6751
  }
5501
6752
  var VIEW_INSTRUCTION = {
5502
- "three-quarter": "Three-quarter (45 degree) view: turn the head and upper body slightly to one side. Chest-up framing, square 1:1 crop. Even neutral studio lighting.",
5503
- profile: "Full side profile (90 degree) view. Chest-up framing, square 1:1 crop. Even neutral studio lighting.",
5504
- "full-body": "Full-body head-to-toe view: the character standing in a relaxed neutral pose, facing forward. 3:4 portrait crop with the whole figure in frame. Even neutral studio lighting.",
5505
- "close-up": "Tight front-facing close-up of the face, capturing fine facial detail. Square 1:1 crop. Even neutral studio lighting.",
5506
- "lighting-warm": "Front-facing head-and-shoulders portrait, square 1:1 crop, under warm golden-hour key lighting.",
5507
- "lighting-cool": "Front-facing head-and-shoulders portrait, square 1:1 crop, under cool blue-toned key lighting."
6753
+ "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.",
6754
+ "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.",
6755
+ "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.",
6756
+ "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.",
6757
+ "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.",
6758
+ back: "BACK VIEW, 180 degrees: full-body head-to-toe view of the person facing completely away from the camera. Show the back of the head and hair, the back of the clothing, the back silhouette and a rear-facing standing posture. No face visible, no eyes, no profile: the head is not turned. Heels, calves, hips and shoulders all face away from the camera. 3:4 portrait crop with the whole figure in frame, feet included."
5508
6759
  };
5509
6760
  function turnaroundViewPrompt(view, seedDescription) {
5510
6761
  return [
5511
6762
  identityAnchor(seedDescription),
5512
6763
  VIEW_INSTRUCTION[view],
6764
+ ...view === "back" ? [CHAINED_BACK_INPUTS_INSTRUCTION] : [],
6765
+ SCREEN_SIDE_INSTRUCTION,
6766
+ TURNAROUND_CAMERA_INSTRUCTION,
6767
+ // View strings mirror the freeze categories, so the wardrobe line keys off
6768
+ // the view directly (head-to-toe views add trousers and shoes).
5513
6769
  wardrobeInstructionForCategory(view),
5514
6770
  NEUTRAL_STUDIO,
5515
6771
  IDENTITY_INSTRUCTION
5516
6772
  ].join("\n\n");
5517
6773
  }
6774
+ function overviewSheetPrompt(description) {
6775
+ return [
6776
+ "Create one clean photorealistic character turnaround sheet of the person in the reference image.",
6777
+ `Character identity: ${description.trim()}`,
6778
+ `${FULL_BODY_WARDROBE_INSTRUCTION} The same outfit in every column.`,
6779
+ "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.",
6780
+ "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.",
6781
+ "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.",
6782
+ "Same camera height for every full body, same crop for every portrait, no perspective distortion, photorealistic studio lighting, sharp detail.",
6783
+ "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.",
6784
+ IDENTITY_INSTRUCTION
6785
+ ].join("\n\n");
6786
+ }
5518
6787
  var CHARACTER_SHEET_NODES = [
5519
6788
  { nodeId: "seed", param: "seedPrompt", category: "face", label: "Face" },
5520
- { nodeId: "view-three-quarter", param: "threeQuarterPrompt", category: "three-quarter", label: "Three-quarter", view: "three-quarter" },
5521
- { nodeId: "view-profile", param: "profilePrompt", category: "profile", label: "Profile", view: "profile" },
5522
- { nodeId: "view-full-body", param: "fullBodyPrompt", category: "full-body", label: "Full body", view: "full-body" },
5523
- { nodeId: "view-close-up", param: "closeUpPrompt", category: "close-up", label: "Close-up", view: "close-up" },
5524
- { nodeId: "view-lighting-warm", param: "lightingWarmPrompt", category: "lighting-warm", label: "Warm lighting", view: "lighting-warm" },
5525
- { nodeId: "view-lighting-cool", param: "lightingCoolPrompt", category: "lighting-cool", label: "Cool lighting", view: "lighting-cool" }
6789
+ { nodeId: "view-full-body", param: "fullBodyPrompt", category: "full-body", label: "Front", view: "full-body" },
6790
+ { nodeId: "view-three-quarter-left", param: "threeQuarterLeftPrompt", category: "three-quarter-left", label: "Turned left", view: "three-quarter-left" },
6791
+ { nodeId: "view-profile-left", param: "profileLeftPrompt", category: "profile-left", label: "Profile left", view: "profile-left" },
6792
+ { nodeId: "view-profile-right", param: "profileRightPrompt", category: "profile-right", label: "Profile right", view: "profile-right" },
6793
+ { nodeId: "view-three-quarter-right", param: "threeQuarterRightPrompt", category: "three-quarter-right", label: "Turned right", view: "three-quarter-right" },
6794
+ { nodeId: "view-back", param: "backPrompt", category: "back", label: "Back", view: "back" },
6795
+ { nodeId: "overview", param: "overviewPrompt", category: OVERVIEW_CATEGORY, label: "Overview", overview: true }
5526
6796
  ];
5527
6797
  var MINT_REFERENCE_CATEGORIES = Object.fromEntries(
5528
6798
  CHARACTER_SHEET_NODES.map((n) => [n.nodeId, n.category])
5529
6799
  );
5530
6800
  function buildCharacterSheetParams(description) {
5531
6801
  const params = {};
5532
- for (const node of CHARACTER_SHEET_NODES) {
5533
- params[node.param] = node.view ? turnaroundViewPrompt(node.view, description) : seedFacePrompt(description);
6802
+ for (const node2 of CHARACTER_SHEET_NODES) {
6803
+ params[node2.param] = node2.view ? turnaroundViewPrompt(node2.view, description) : node2.overview ? overviewSheetPrompt(description) : seedFacePrompt(description);
5534
6804
  }
5535
6805
  return params;
5536
6806
  }
5537
6807
  var CHARACTER_SHEET_ID = "character-sheet";
5538
6808
  var SEED_MODEL = "fal/nano-banana-2";
5539
6809
  var VIEW_MODEL = "fal/nano-banana-2-edit";
6810
+ var OVERVIEW_MODEL = VIEW_MODEL;
5540
6811
  function viewNode(n, aspectRatio) {
5541
6812
  return {
5542
6813
  id: n.nodeId,
@@ -5549,6 +6820,7 @@ function viewNode(n, aspectRatio) {
5549
6820
  }
5550
6821
  };
5551
6822
  }
6823
+ var node = (id) => CHARACTER_SHEET_NODES.find((n) => n.nodeId === id);
5552
6824
  var CHARACTER_SHEET_DEFINITION = {
5553
6825
  version: { schema: 1 },
5554
6826
  id: CHARACTER_SHEET_ID,
@@ -5569,16 +6841,47 @@ var CHARACTER_SHEET_DEFINITION = {
5569
6841
  aspectRatio: { kind: "literal", value: "1:1" }
5570
6842
  }
5571
6843
  },
5572
- ...CHARACTER_SHEET_NODES.filter((n) => n.view !== void 0).map(
5573
- (n) => viewNode(n, n.category === "full-body" ? "3:4" : "1:1")
5574
- )
6844
+ viewNode(node("view-full-body"), "3:4"),
6845
+ viewNode(node("view-three-quarter-left"), "1:1"),
6846
+ viewNode(node("view-profile-left"), "1:1"),
6847
+ viewNode(node("view-profile-right"), "1:1"),
6848
+ viewNode(node("view-three-quarter-right"), "1:1"),
6849
+ // The back turns the front full body round, with the seed first as its
6850
+ // identity image ([face, full body]; its prompt says which is which).
6851
+ {
6852
+ id: "view-back",
6853
+ task: "image-edit",
6854
+ model: VIEW_MODEL,
6855
+ inputs: {
6856
+ prompt: { kind: "param", name: "backPrompt" },
6857
+ inputImages: {
6858
+ kind: "list",
6859
+ items: [
6860
+ { kind: "ref", node: "seed", path: "url" },
6861
+ { kind: "ref", node: "view-full-body", path: "url" }
6862
+ ]
6863
+ },
6864
+ aspectRatio: { kind: "literal", value: "3:4" }
6865
+ }
6866
+ },
6867
+ {
6868
+ id: "overview",
6869
+ task: "image-edit",
6870
+ model: OVERVIEW_MODEL,
6871
+ inputs: {
6872
+ prompt: { kind: "param", name: "overviewPrompt" },
6873
+ inputImages: { kind: "ref", node: "seed", path: "url", wrap: "array" },
6874
+ aspectRatio: { kind: "literal", value: OVERVIEW_ASPECT_RATIO },
6875
+ imageSize: { kind: "literal", value: OVERVIEW_RESOLUTION }
6876
+ }
6877
+ }
5575
6878
  ]
5576
6879
  };
5577
6880
  function characterSheetDefinition(overrides) {
5578
6881
  const def = structuredClone(CHARACTER_SHEET_DEFINITION);
5579
6882
  if (overrides?.seedModel || overrides?.viewModel) {
5580
6883
  def.nodes = def.nodes.map(
5581
- (node) => node.id === "seed" ? { ...node, model: overrides.seedModel ?? node.model } : { ...node, model: overrides.viewModel ?? node.model }
6884
+ (node2) => node2.id === "seed" ? { ...node2, model: overrides.seedModel ?? node2.model } : { ...node2, model: overrides.viewModel ?? node2.model }
5582
6885
  );
5583
6886
  }
5584
6887
  return def;
@@ -5758,13 +7061,20 @@ function buildCharacterSwapDefinition(input) {
5758
7061
  ]
5759
7062
  };
5760
7063
  }
5761
- var CHARACTER_REFERENCE_PREFERENCE = ["full-body", "three-quarter", "face"];
7064
+ var CHARACTER_REFERENCE_PREFERENCE = [
7065
+ "full-body",
7066
+ "three-quarter-left",
7067
+ "three-quarter-right",
7068
+ "three-quarter",
7069
+ "face"
7070
+ ];
7071
+ var NEVER_AUTOMATIC = /* @__PURE__ */ new Set(["back", "overview"]);
5762
7072
  function pickCharacterReferenceUrl(references) {
5763
7073
  for (const category of CHARACTER_REFERENCE_PREFERENCE) {
5764
7074
  const hit = references.find((r) => r.category === category && typeof r.url === "string" && r.url.length > 0);
5765
7075
  if (hit) return { url: hit.url, category };
5766
7076
  }
5767
- const any = references.find((r) => typeof r.url === "string" && r.url.length > 0);
7077
+ const any = references.find((r) => typeof r.url === "string" && r.url.length > 0 && !NEVER_AUTOMATIC.has(r.category));
5768
7078
  return any ? { url: any.url, category: any.category } : null;
5769
7079
  }
5770
7080
 
@@ -5800,7 +7110,7 @@ function parseDocument(raw, what) {
5800
7110
  }
5801
7111
  return r.data;
5802
7112
  }
5803
- var OpsSchema = z6.array(OpSchema);
7113
+ var OpsSchema = z6.array(OpSchema).max(MAX_PATCH_OPS * 20);
5804
7114
  function parseOps(raw, what) {
5805
7115
  const r = OpsSchema.safeParse(raw);
5806
7116
  if (!r.success) {
@@ -5831,32 +7141,32 @@ function wireCounts(doc) {
5831
7141
  }
5832
7142
  return counts;
5833
7143
  }
5834
- function summarizeNode(node, wires) {
5835
- const base = { id: node.id, kind: node.kind, wires: { ...wires } };
5836
- if (node.label !== void 0) base.label = node.label;
5837
- switch (node.kind) {
7144
+ function summarizeNode(node2, wires) {
7145
+ const base = { id: node2.id, kind: node2.kind, wires: { ...wires } };
7146
+ if (node2.label !== void 0) base.label = node2.label;
7147
+ switch (node2.kind) {
5838
7148
  case "task":
5839
- base.task = node.task;
5840
- base.model = node.model;
5841
- base.prompt = clipText(node.prompt);
5842
- base.promptLength = node.prompt.length;
5843
- if (node.activeGeneration !== void 0) base.activeGeneration = node.activeGeneration;
7149
+ base.task = node2.task;
7150
+ base.model = node2.model;
7151
+ base.prompt = clipText(node2.prompt);
7152
+ base.promptLength = node2.prompt.length;
7153
+ if (node2.activeGeneration !== void 0) base.activeGeneration = node2.activeGeneration;
5844
7154
  break;
5845
7155
  case "prompt-source":
5846
- base.prompt = clipText(node.text);
5847
- base.promptLength = node.text.length;
7156
+ base.prompt = clipText(node2.text);
7157
+ base.promptLength = node2.text.length;
5848
7158
  break;
5849
7159
  case "image-source":
5850
- base.imageUrl = clipText(node.imageUrl);
7160
+ base.imageUrl = clipText(node2.imageUrl);
5851
7161
  break;
5852
7162
  case "video-source":
5853
- base.videoUrl = clipText(node.videoUrl);
7163
+ base.videoUrl = clipText(node2.videoUrl);
5854
7164
  break;
5855
7165
  case "input":
5856
- base.name = node.name;
5857
- base.type = node.type;
5858
- base.required = node.required;
5859
- if (node.cardinality !== void 0) base.cardinality = node.cardinality;
7166
+ base.name = node2.name;
7167
+ base.type = node2.type;
7168
+ base.required = node2.required;
7169
+ if (node2.cardinality !== void 0) base.cardinality = node2.cardinality;
5860
7170
  break;
5861
7171
  }
5862
7172
  return base;
@@ -5889,8 +7199,8 @@ function affectedNodes(doc, ids) {
5889
7199
  const wires = wireCounts(doc);
5890
7200
  const byId = new Map(doc.nodes.map((n) => [n.id, n]));
5891
7201
  return ids.map((id) => {
5892
- const node = byId.get(id);
5893
- return node ? summarizeNode(node, wires.get(id) ?? { in: 0, out: 0 }) : { id, removed: true };
7202
+ const node2 = byId.get(id);
7203
+ return node2 ? summarizeNode(node2, wires.get(id) ?? { in: 0, out: 0 }) : { id, removed: true };
5894
7204
  });
5895
7205
  }
5896
7206
 
@@ -6286,6 +7596,8 @@ var ID = /^[A-Za-z0-9_][A-Za-z0-9_.:-]{0,127}$/;
6286
7596
  var CompositionIdSchema = z22.string().regex(ID, "an id is letters, digits and _ . : -");
6287
7597
  var COLOR_ROLE = z22.string().regex(/^[a-z0-9][a-z0-9-]{0,31}$/, "a colour is named by its kit id");
6288
7598
  var unit = z22.number().min(0).max(1);
7599
+ var STUDIO_DEFAULT_FONT_ROLE = "studio-default";
7600
+ var TEXT_FONT_ROLES = [...BRAND_KIT_FONT_ROLES, STUDIO_DEFAULT_FONT_ROLE];
6289
7601
  var BoxSchema = z22.object({ x: unit, y: unit, w: z22.number().min(MIN_BOX_SIDE).max(1), h: z22.number().min(MIN_BOX_SIDE).max(1) }).strict().refine((b) => b.x + b.w <= 1 + 1e-9 && b.y + b.h <= 1 + 1e-9, "a box must stay inside the frame");
6290
7602
  var TimingShape = {
6291
7603
  start: z22.number().min(0).optional(),
@@ -6297,7 +7609,7 @@ var TextOverlaySchema = z22.object({
6297
7609
  box: BoxSchema,
6298
7610
  text: z22.string().min(1, "a text overlay needs text").max(MAX_OVERLAY_TEXT),
6299
7611
  styleRole: z22.enum(BRAND_KIT_TYPE_ROLES),
6300
- fontRole: z22.enum(BRAND_KIT_FONT_ROLES),
7612
+ fontRole: z22.enum(TEXT_FONT_ROLES),
6301
7613
  weight: z22.number().int().min(100).max(900),
6302
7614
  italic: z22.boolean(),
6303
7615
  colorRole: COLOR_ROLE,
@@ -6357,7 +7669,9 @@ var CompositionDocumentSchema = z22.object({
6357
7669
  brandSlug: z22.string().min(1).max(64),
6358
7670
  /** The kit version the document was last edited against; a newer kit is worth a look before rendering. */
6359
7671
  kitVersionAtEdit: z22.number().int().nonnegative(),
6360
- items: z22.array(ItemSchema),
7672
+ // The larger of the two kinds' item caps, checked before any item is
7673
+ // parsed; the per-kind count is enforced by the integrity check below.
7674
+ items: z22.array(ItemSchema).max(Math.max(MAX_REEL_CLIPS, MAX_CAROUSEL_SLIDES)),
6361
7675
  /** Overlays across the whole reel (a logo bug, an end card line). Always empty on a carousel. */
6362
7676
  reelOverlays: z22.array(OverlaySchema).max(MAX_OVERLAYS_PER_ITEM)
6363
7677
  }).strict();
@@ -6512,7 +7826,7 @@ var studioListAssets = defineTool({
6512
7826
  });
6513
7827
  var studioBrandKitGet = defineTool({
6514
7828
  name: "studio_brand_kit_get",
6515
- description: "Read a brand kit: the only colours (by id), type sizes (headline, body), fonts (primary, secondary, with the weights and styles each has) and logos (light, dark) a composition overlay may use. Free, read-only. Use the ids and roles it lists in studio_composition_apply ops; anything else is refused.",
7829
+ description: 'Read a brand kit: the only colours (by id), type sizes (headline, body), fonts (primary, secondary, with the weights and styles each has) and logos (light, dark) a composition overlay may use. Free, read-only. Use the ids and roles it lists in studio_composition_apply ops; anything else is refused. While the kit has no font, text uses fontRole "studio-default" (Inter, built into Studio, weight 400 or 700).',
6516
7830
  inputSchema: { brandSlug: z9.string().min(1).describe("The brand slug, as studio_create_brand made it.") },
6517
7831
  handler: async (args, ctx) => {
6518
7832
  const { kit } = await ctx.client.getBrandKit(args.brandSlug);
@@ -6546,7 +7860,7 @@ var studioCompositionDescribe = defineTool({
6546
7860
  shapes: {
6547
7861
  slide: '{ id, type: "slide", background: { assetId?, fit: "cover"|"contain", focal: { x, y }, fill? (kit colour id) }, overlays: [] } (an image asset of the project, or a fill)',
6548
7862
  clip: '{ id, type: "clip", assetId (a video asset of the project), trimIn, trimOut (seconds), overlays: [] }',
6549
- text: '{ id, type: "text", box: { x, y, w, h } (fractions of the frame), text, styleRole: "headline"|"body", fontRole: "primary"|"secondary", weight (one the font has), italic, colorRole (kit colour id), align: "left"|"center"|"right", background?: { colorRole, opacity, padding }, start?, end? (reels only) }',
7863
+ text: '{ id, type: "text", box: { x, y, w, h } (fractions of the frame), text, styleRole: "headline"|"body", fontRole: "primary"|"secondary"|"studio-default" (Inter, built into Studio, for a brand whose kit has no font yet; weights 400 and 700, no italic), weight (one the font has), italic, colorRole (kit colour id), align: "left"|"center"|"right", background?: { colorRole, opacity, padding }, start?, end? (reels only) }',
6550
7864
  logo: '{ id, type: "logo", box, variant: "light"|"dark", start?, end? }',
6551
7865
  shape: '{ id, type: "shape", box, shape: "rect"|"pill", colorRole, opacity, start?, end? }'
6552
7866
  },
@@ -7077,6 +8391,7 @@ var studioPromptsDelete = defineTool({
7077
8391
  var PROMPT_TOOLS = [studioPromptsList, studioPromptsSave, studioPromptsDelete];
7078
8392
 
7079
8393
  // src/tools.ts
8394
+ var MAX_REFERENCE_TAGS = 50;
7080
8395
  var slug = z12.string().regex(/^[a-z0-9-]+$/, "lowercase letters, numbers and hyphens only").describe("URL-safe identifier: lowercase letters, numbers, hyphens.");
7081
8396
  var waitSeconds = z12.number().int().min(1).max(3600).default(DEFAULT_TIMEOUT_MS / 1e3).describe("Maximum seconds to wait before giving up and returning the id to poll later. Default 600.");
7082
8397
  var httpUrl = z12.string().url().refine((u) => /^https?:\/\//i.test(u), "must be an http(s) URL");
@@ -7178,6 +8493,9 @@ var studioGenerateImage = defineTool({
7178
8493
  candidateCount: z12.number().int().min(1).max(4).optional().describe(
7179
8494
  "Number of candidates (1 to 4). Not every model takes a count: most KIE image models render one image whatever is asked, and a `route/...` model runs on KIE first, so expect one there too (its fal fallback may render up to four). The result carries `candidates: { requested, rendered, mayRender? }`, plus a `notice` whenever fewer will be rendered than were asked for; only rendered images are charged."
7180
8495
  ),
8496
+ variety: z12.enum(["varied", "same"]).optional().describe(
8497
+ '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.'
8498
+ ),
7181
8499
  wait: z12.boolean().default(true).describe("Poll until the job finishes (default true)."),
7182
8500
  waitSeconds
7183
8501
  },
@@ -7188,6 +8506,7 @@ var studioGenerateImage = defineTool({
7188
8506
  if (args.imageSize) settings.imageSize = args.imageSize;
7189
8507
  if (args.seed !== void 0) settings.seed = args.seed;
7190
8508
  if (args.candidateCount !== void 0) settings.candidateCount = args.candidateCount;
8509
+ if (args.variety) settings.variety = args.variety;
7191
8510
  const submitted = await ctx.client.generate({
7192
8511
  ...args.brandSlug ? { brandSlug: args.brandSlug } : {},
7193
8512
  ...args.brandMode ? { brandMode: args.brandMode } : {},
@@ -7199,7 +8518,8 @@ var studioGenerateImage = defineTool({
7199
8518
  });
7200
8519
  const plan = {
7201
8520
  ...submitted.candidates ? { candidates: submitted.candidates } : {},
7202
- ...typeof submitted.notice === "string" && submitted.notice.length > 0 ? { notice: submitted.notice } : {}
8521
+ ...typeof submitted.notice === "string" && submitted.notice.length > 0 ? { notice: submitted.notice } : {},
8522
+ ...submitted.variety === "varied" ? { variety: "varied" } : {}
7203
8523
  };
7204
8524
  if (!args.wait) return { jobId: submitted.jobId, kind: submitted.kind, status: "queued", ...plan };
7205
8525
  const done = await waitForJob(ctx.client, submitted.jobId, pollOpts(ctx, args.waitSeconds));
@@ -7321,8 +8641,8 @@ var studioRig3d = defineTool({
7321
8641
  });
7322
8642
  if (!args.wait) return { runId: started.runId, status: "queued" };
7323
8643
  const run = await waitForRun(ctx.client, started.runId, pollOpts(ctx, args.waitSeconds));
7324
- const node = run.nodeRuns.find((n) => n.nodeId === "rig");
7325
- const [rig, ...clips] = node?.results ?? [];
8644
+ const node2 = run.nodeRuns.find((n) => n.nodeId === "rig");
8645
+ const [rig, ...clips] = node2?.results ?? [];
7326
8646
  if (run.run.status !== "succeeded" || !rig?.url) {
7327
8647
  const failure = runFailureSummary(run);
7328
8648
  throw new Error(`Rig run ${started.runId} ended ${run.run.status}.${failure ? ` ${failure}.` : ""} Cost so far $${runCostUsd(run).toFixed(2)}.`);
@@ -7363,7 +8683,7 @@ var studioListCharacters = defineTool({
7363
8683
  });
7364
8684
  var studioGetCharacter = defineTool({
7365
8685
  name: "studio_get_character",
7366
- description: "Fetch one character by slug with its full context: descriptor and negative prompts plus every frozen reference image (category such as face, three-quarter, profile, full-body, close-up, lighting-warm, lighting-cool; URL). The full-body or face reference URL is what studio_replace_character_in_video needs as characterImageUrl. For a character your company owns the URL is a direct image URL. For a character another company shared (owned: false) it is a Studio address: pass it unchanged as an image input to any Studio tool and the Studio resolves it when the job runs, but it is not a public image URL, and it stops working the moment the owner stops sharing.",
8686
+ description: "Fetch one character by slug with its full context: descriptor and negative prompts plus every frozen reference image (category such as face, full-body, three-quarter-left, profile-left, profile-right, three-quarter-right, back, or on a character minted before November 2026 three-quarter, profile, close-up, lighting-warm, lighting-cool; URL; the back view shows no face, so use it only for a person seen from behind). The full-body or face reference URL is what studio_replace_character_in_video needs as characterImageUrl. For a character your company owns the URL is a direct image URL. For a character another company shared (owned: false) it is a Studio address: pass it unchanged as an image input to any Studio tool and the Studio resolves it when the job runs, but it is not a public image URL, and it stops working the moment the owner stops sharing.",
7367
8687
  inputSchema: { slug },
7368
8688
  annotations: { readOnlyHint: true },
7369
8689
  handler: async (args, ctx) => {
@@ -7384,7 +8704,9 @@ var studioPromptEnhance = defineTool({
7384
8704
  name: z12.string().max(200).optional()
7385
8705
  })
7386
8706
  ).max(10).optional().describe("Every mention token of the prompt (at most 10). The returned mentions carry the names your company gave them."),
7387
- model: z12.string().optional().describe('Optional. The image or video model the prompt will be rendered with (e.g. "kie/nano-banana-2"), so the rewrite suits it. It must make the target.'),
8707
+ 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.'),
8708
+ 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."),
8709
+ imageAttached: z12.boolean().optional().describe("Optional, image only. True when you will send an image with the generation (a reference or the image to edit): if the prompt asks to change that image, the rewrite is one edit instruction that keeps everything else; if it asks for a new picture, a scene."),
7388
8710
  brandSlug: slug.optional().describe("Optional. A brand of your company whose style the rewrite should follow."),
7389
8711
  brandMode: z12.string().optional().describe('Optional brand mode (e.g. "hero"). Only meaningful with brandSlug.')
7390
8712
  },
@@ -7395,6 +8717,8 @@ var studioPromptEnhance = defineTool({
7395
8717
  target: args.target,
7396
8718
  ...args.mentions && args.mentions.length > 0 ? { mentions: args.mentions } : {},
7397
8719
  ...args.model ? { model: args.model } : {},
8720
+ ...args.startFrame ? { startFrame: true } : {},
8721
+ ...args.imageAttached ? { imageAttached: true } : {},
7398
8722
  ...args.brandSlug ? { brandSlug: args.brandSlug } : {},
7399
8723
  ...args.brandMode ? { brandMode: args.brandMode } : {}
7400
8724
  });
@@ -7431,7 +8755,7 @@ var studioCreateCharacter = defineTool({
7431
8755
  });
7432
8756
  var studioMintCharacter = defineTool({
7433
8757
  name: "studio_mint_character",
7434
- description: "Mint a consistent character from a text description: runs the curated character-sheet workflow (a face with fal/nano-banana-2, then six identity-pinned edits with fal/nano-banana-2-edit: three-quarter, profile, full-body, close-up, warm lighting, cool lighting), waits for it, creates the character, and uploads the 7 views as frozen references with the right categories. Returns the slug, reference count, per-view URLs, the runId and total cost (about $0.30). The description should cover face, hair, age, build and distinguishing features; wardrobe is standardized to a plain gray tee. Takes 2 to 5 minutes. Requires likenessRightsConfirmed: true, which you may only pass after the human you act for confirmed it for this character; without it the tool refuses before the run starts, so nothing is spent.",
8758
+ description: "Mint a consistent character from a text description: runs the curated character-sheet workflow (a face with fal/nano-banana-2, then six identity-pinned edits with fal/nano-banana-2-edit: front full body, turned 45 degrees to screen-left, profile facing screen-left, profile facing screen-right, turned 45 degrees to screen-right, and the back, edited from the face and the front full body; plus one overview image of all six angles at 4K, for people only, never used as a reference), waits for it, creates the character, and uploads the views as frozen references with the right categories (face, full-body, three-quarter-left, profile-left, profile-right, three-quarter-right, back) and the overview as category overview. Returns the slug, reference count, per-view URLs, the runId and total cost (about $0.72 at provider prices). If only the overview failed, the character is still created and the result says so. The description should cover face, hair, age, build and distinguishing features; wardrobe is standardized to a plain gray tee, dark trousers and dark shoes. Takes 2 to 5 minutes. Requires likenessRightsConfirmed: true, which you may only pass after the human you act for confirmed it for this character; without it the tool refuses before the run starts, so nothing is spent.",
7435
8759
  inputSchema: {
7436
8760
  projectId: z12.string().min(1).describe("Project id from studio_list_projects."),
7437
8761
  name: z12.string().min(1).describe("Display name."),
@@ -7460,7 +8784,9 @@ var studioMintCharacter = defineTool({
7460
8784
  ...args.visibility ? { visibility: args.visibility } : {}
7461
8785
  });
7462
8786
  const run = await waitForRun(ctx.client, started.runId, pollOpts(ctx, args.waitSeconds));
7463
- const views = CHARACTER_SHEET_NODES.map((n) => ({ ...n, url: nodeUrl(run, n.nodeId) }));
8787
+ const outputs = CHARACTER_SHEET_NODES.map((n) => ({ ...n, url: nodeUrl(run, n.nodeId) }));
8788
+ const views = outputs.filter((v) => !v.overview);
8789
+ const overview = outputs.find((v) => v.overview);
7464
8790
  const missing = views.filter((v) => !v.url);
7465
8791
  if (missing.length > 0) {
7466
8792
  const failure = runFailureSummary(run);
@@ -7477,7 +8803,7 @@ var studioMintCharacter = defineTool({
7477
8803
  ...args.defaultModel !== void 0 ? { defaultModel: args.defaultModel } : {}
7478
8804
  });
7479
8805
  const references = [];
7480
- for (const view of views) {
8806
+ for (const view of overview?.url ? [...views, overview] : views) {
7481
8807
  const file = await ctx.client.downloadUrl(view.url);
7482
8808
  const category = MINT_REFERENCE_CATEGORIES[view.nodeId];
7483
8809
  const { reference } = await ctx.client.uploadCharacterReference(args.slug, {
@@ -7491,8 +8817,9 @@ var studioMintCharacter = defineTool({
7491
8817
  slug: character.slug,
7492
8818
  name: character.name,
7493
8819
  runId: started.runId,
7494
- referenceCount: references.length,
8820
+ referenceCount: references.filter((r) => r.category !== OVERVIEW_CATEGORY).length,
7495
8821
  references,
8822
+ overview: overview?.url ? { made: true } : { made: false, note: "The overview image failed; the character and its seven reference images were created without it." },
7496
8823
  costUsd: runCostUsd(run)
7497
8824
  };
7498
8825
  }
@@ -7528,7 +8855,7 @@ var studioUploadBrandReference = defineTool({
7528
8855
  source: z12.string().min(1).describe("Local file path or http(s) URL of an image."),
7529
8856
  category: z12.string().optional().describe('Library category, default "general".'),
7530
8857
  label: z12.string().optional().describe("Optional file name / label."),
7531
- tags: z12.array(z12.string()).optional(),
8858
+ tags: z12.array(z12.string()).max(MAX_REFERENCE_TAGS).optional(),
7532
8859
  score: z12.number().int().min(1).max(10).optional()
7533
8860
  },
7534
8861
  handler: async (args, ctx) => {
@@ -7543,7 +8870,8 @@ var studioUploadBrandReference = defineTool({
7543
8870
  return { reference };
7544
8871
  }
7545
8872
  });
7546
- var workflowDefinitionSchema = WorkflowDefinitionSchema.describe(
8873
+ var AgentDefinitionSchema = WorkflowDefinitionSchema.extend({ nodes: z12.array(WorkflowNodeSchema.omit({ cast: true, castOwn: true, imagesWired: true })).min(1).max(MAX_DOCUMENT_NODES) });
8874
+ var workflowDefinitionSchema = AgentDefinitionSchema.describe(
7547
8875
  `Inline workflow DAG: { id, label?, params?: [{ name, type: string|number|boolean|json, required?, label?, description?, inputType?, cardinality?: one|many, default? }], nodes: [{ id, task (one of the model tasks listed), model (catalog id, e.g. fal/nano-banana-2-edit), inputs, retry? }] }. Node inputs are bindings: {kind:"literal",value}, {kind:"param",name,wrap?:"array"}, {kind:"ref",node,path:"url",wrap?:"array"} or an ordered {kind:"list",items:[...]} of those. Image-edit nodes take inputImages (an array: one wrapped ref/param, or a list in reference order, scene frame first); image-to-video nodes take inputImageUrl (start frame) and optionally endImageUrl (end frame, on models that accept one), EXCEPT on a keyframes model (fal/flux-3-keyframes-to-video and its -draft tier), which instead takes keyframeImageUrls (an ordered list of up to 10 images) with keyframeFrameIndexes (one strictly increasing frame per image on a fixed 24 fps timeline). Pass one shape or the other, never both. To hold a character's identity through the clip, an image-to-video node on a model with character references (route/kling-o3 or fal/kling-o3-pro-reference-to-video; a model pinned to KIE, kie/..., is not available for images of people and refuses a run whose node carries a character, a try-on, a swap or an uploaded or referenced image or video, so use the fal or route/ entry for those) also takes referenceImageUrls (a list of character photos, grouped by character, each character's frontal view first, 2 to 4 images per character, up to 3 characters) with referenceElementIndexes (the 0-based character of each image, ascending without gaps, e.g. [0,0,0,1,1]); they never count as the start or end frame, and they need inputImageUrl. kie/gemini-omni-flash-1-1-reference-to-video takes the same two fields with 1 to 6 character images in all and no end frame: its start frame goes in as reference image 1, named in the prompt as the exact scene and first frame, because KIE does not lock a first frame in its reference mode. It runs on KIE, so while Studio keeps people off KIE it is refused for character references like every other kie/ model.`
7548
8876
  );
7549
8877
  var studioRunWorkflow = defineTool({
@@ -7554,7 +8882,7 @@ var studioRunWorkflow = defineTool({
7554
8882
  definition: workflowDefinitionSchema.optional(),
7555
8883
  savedId: z12.string().optional().describe("Id of a saved workflow (from studio_workflow_create, studio_workflow_get or a listed run) to run instead of an inline definition. An unknown id is a 404 naming it; a workflow that is not runnable yet comes back as not_runnable with per-node issues."),
7556
8884
  params: z12.record(z12.string(), z12.unknown()).optional().describe("Values for the definition's params."),
7557
- nodeIds: z12.array(z12.string()).optional().describe("Run only this subset of nodes (requires an inline `definition` or a `savedId`)."),
8885
+ nodeIds: z12.array(z12.string()).max(MAX_DOCUMENT_NODES).optional().describe("Run only this subset of nodes (requires an inline `definition` or a `savedId`)."),
7558
8886
  upstreamGenerations: z12.record(z12.string(), z12.string()).optional().describe(
7559
8887
  'Pin WHICH generation of an upstream node feeds this subset run: { "<upstream node id>": "<node-run id>" } (the per-node `id` that studio_get_run returns). A verified pin is reused even when the planner has no matching cache key for it (an inline first batch, or a node edited and reverted), so a follow-up node wired from an earlier generation runs against exactly that image. An unknown id is refused naming the node, never silently replaced by the latest.'
7560
8888
  ),
@@ -7897,7 +9225,7 @@ function registerTools(server, base) {
7897
9225
 
7898
9226
  // src/server.ts
7899
9227
  var SERVER_NAME = "lumitra-studio";
7900
- var SERVER_VERSION = "0.18.1";
9228
+ var SERVER_VERSION = "0.21.1";
7901
9229
  function createStudioMcpServer(opts = {}) {
7902
9230
  const config = opts.config ?? resolveConfig(opts.env ?? process.env);
7903
9231
  const client = new StudioClient(config, {